From a29cb1cdd11a89bb22cea941da3deb455a9d6a1e Mon Sep 17 00:00:00 2001 From: PeterWeiWang <715533650@qq.com> Date: Tue, 12 Apr 2022 15:10:43 +0800 Subject: [PATCH] support for parallel queries. --- include/my_alloc.h | 32 +- include/my_dbug.h | 3 + include/priority_queue.h | 5 +- include/sql_string.h | 3 +- .../collections/disabled-pq-debug-kp.def | 16 + mysql-test/collections/disabled-pq-kp.def | 11 + mysql-test/collections/disabled-pq.def | 16 + mysql-test/include/common-tests.inc | 85 +- mysql-test/include/not_pq_test.inc | 4 + mysql-test/include/pq_test.inc | 4 + mysql-test/lib/mtr_cases.pm | 11 + mysql-test/mysql-test-run.pl | 12 + .../r/all_persisted_variables.result-pq | 66 + mysql-test/r/binary.result-pq | 213 + mysql-test/r/case.result-pq | 481 + mysql-test/r/cast.result-pq | 2300 + mysql-test/r/compare.result-pq | 205 + mysql-test/r/compress.result-pq | 4580 ++ mysql-test/r/condition_filter.result-pq | 108 + mysql-test/r/const_folding.result-pq | 55815 ++++++++++++++++ mysql-test/r/create.result-pq | 3065 + mysql-test/r/ctype_binary.result-pq | 2784 + mysql-test/r/ctype_collate.result-pq | 868 + mysql-test/r/ctype_cp1251.result-pq | 3188 + mysql-test/r/ctype_gb18030.result-pq | 1751 + mysql-test/r/ctype_uca.result-pq | 7610 +++ mysql-test/r/ctype_ucs.result-pq | 4459 ++ mysql-test/r/ctype_unicode900.result-pq | 3889 ++ mysql-test/r/ctype_unicode900_as_ci.result-pq | 1564 + mysql-test/r/ctype_unicode900_as_cs.result-pq | 2078 + mysql-test/r/ctype_utf16.result-pq | 1380 + mysql-test/r/ctype_utf16_uca.result-pq | 3597 + mysql-test/r/ctype_utf16le.result-pq | 1631 + mysql-test/r/ctype_utf32.result-pq | 1431 + mysql-test/r/ctype_utf32_uca.result-pq | 3621 + mysql-test/r/ctype_utf8mb4_innodb.result-pq | 2747 + mysql-test/r/delete.result-pq | 868 + mysql-test/r/derived.result-pq | 4613 ++ mysql-test/r/derived_correlated.result-pq | 3447 + mysql-test/r/desc_index_innodb.result-pq | 1718 + mysql-test/r/distinct_innodb.result-pq | 965 + mysql-test/r/endspace.result-pq | 243 + mysql-test/r/error_simulation.result-pq | 119 + ...for_connection_small_json_innodb.result-pq | 95 + mysql-test/r/explain_other.result-pq | 1526 + mysql-test/r/explain_tree.result-pq | 861 + mysql-test/r/filesort.result-pq | 153 + mysql-test/r/filesort_pack.result-pq | 31 + .../r/filter_single_col_idx_small.result-pq | 148 + mysql-test/r/func_comparison.result-pq | 18145 +++++ mysql-test/r/func_default.result-pq | 31 + mysql-test/r/func_group.result-pq | 2150 + mysql-test/r/func_group_innodb.result-pq | 217 + mysql-test/r/func_if.result-pq | 324 + mysql-test/r/func_in_all.result-pq | 998 + mysql-test/r/func_in_icp.result-pq | 998 + mysql-test/r/func_in_icp_mrr.result-pq | 998 + mysql-test/r/func_in_mrr.result-pq | 998 + mysql-test/r/func_in_mrr_cost.result-pq | 998 + mysql-test/r/func_in_none.result-pq | 997 + mysql-test/r/func_like.result-pq | 482 + mysql-test/r/func_math.result-pq | 2066 + mysql-test/r/func_prefix_key.result-pq | 943 + mysql-test/r/func_regexp.result-pq | 173 + mysql-test/r/func_str.result-pq | 5312 ++ mysql-test/r/func_test.result-pq | 740 + mysql-test/r/functional_index.result-pq | 641 + mysql-test/r/greedy_search.result-pq | 220 + mysql-test/r/group_by.result-pq | 4285 ++ mysql-test/r/group_by_fd_no_prot.result-pq | 2295 + mysql-test/r/group_min_max.result-pq | 4501 ++ mysql-test/r/group_min_max_ext.result-pq | 4112 ++ mysql-test/r/group_min_max_innodb.result-pq | 693 + mysql-test/r/handler_read_last.result-pq | 60 + mysql-test/r/hash_join.result-pq | 4019 ++ mysql-test/r/having.result-pq | 936 + mysql-test/r/heap.result-pq | 850 + mysql-test/r/histogram_equi_height.result-pq | 1718 + mysql-test/r/histogram_singleton.result-pq | 1591 + mysql-test/r/histograms.result-pq | 3391 + mysql-test/r/index_merge_innodb.result-pq | 2116 + ...nodb_explain_json_non_select_all.result-pq | 9486 +++ ...odb_explain_json_non_select_none.result-pq | 9409 +++ .../r/innodb_explain_non_select_all.result-pq | 2605 + .../innodb_explain_non_select_none.result-pq | 2602 + mysql-test/r/innodb_icp.result-pq | 1130 + mysql-test/r/innodb_icp_all.result-pq | 1130 + mysql-test/r/innodb_icp_none.result-pq | 1129 + mysql-test/r/innodb_mrr.result-pq | 801 + mysql-test/r/innodb_mrr_all.result-pq | 802 + mysql-test/r/innodb_mrr_cost.result-pq | 801 + mysql-test/r/innodb_mrr_cost_all.result-pq | 802 + mysql-test/r/innodb_mrr_cost_icp.result-pq | 801 + mysql-test/r/innodb_mrr_icp.result-pq | 801 + mysql-test/r/innodb_mrr_none.result-pq | 800 + .../r/innodb_pk_extension_off.result-pq | 496 + mysql-test/r/innodb_pk_extension_on.result-pq | 489 + .../r/innodb_tmp_table_heap_to_disk.result-pq | 125 + mysql-test/r/insert_update.result-pq | 1080 + mysql-test/r/invisible_indexes.result-pq | 600 + mysql-test/r/join.result-pq | 2155 + mysql-test/r/join_cache_bka.result-pq | 3245 + mysql-test/r/join_cache_bka_nobnl.result-pq | 3245 + mysql-test/r/join_cache_bnl.result-pq | 3245 + mysql-test/r/join_cache_nojb.result-pq | 3245 + mysql-test/r/join_nested.result-pq | 2649 + mysql-test/r/join_nested_bka.result-pq | 2777 + mysql-test/r/join_nested_bka_nobnl.result-pq | 2777 + mysql-test/r/join_outer.result-pq | 3834 ++ mysql-test/r/join_outer_bka.result-pq | 3837 ++ mysql-test/r/join_outer_bka_nobnl.result-pq | 3834 ++ mysql-test/r/join_outer_innodb.result-pq | 90 + mysql-test/r/key_diff.result-pq | 58 + mysql-test/r/kill_explain_analyze.result-pq | 30 + mysql-test/r/limit.result-pq | 780 + mysql-test/r/loose_scan.result-pq | 212 + mysql-test/r/metadata.result-pq | 454 + ...isam_explain_json_non_select_all.result-pq | 8249 +++ ...sam_explain_json_non_select_none.result-pq | 8270 +++ .../r/myisam_explain_non_select_all.result-pq | 2520 + .../myisam_explain_non_select_none.result-pq | 2517 + mysql-test/r/mysqld--help-notwin.result-pq | 1876 + mysql-test/r/negation_elimination.result-pq | 589 + mysql-test/r/null.result-pq | 440 + mysql-test/r/null_key_all_innodb.result-pq | 163 + mysql-test/r/null_key_icp_innodb.result-pq | 163 + mysql-test/r/null_key_none_innodb.result-pq | 162 + mysql-test/r/opt_costmodel.result-pq | 597 + mysql-test/r/opt_costmodel_flush.result-pq | 1163 + mysql-test/r/opt_costmodel_restart.result-pq | 276 + mysql-test/r/opt_hint_timeout.result-pq | 74 + mysql-test/r/opt_hints.result-pq | 2300 + mysql-test/r/opt_hints_index.result-pq | 230 + mysql-test/r/opt_hints_index_merge.result-pq | 560 + mysql-test/r/opt_hints_join_order.result-pq | 1150 + mysql-test/r/opt_hints_lowercase.result-pq | 36 + mysql-test/r/opt_hints_set_var.result-pq | 925 + mysql-test/r/opt_hints_subquery.result-pq | 1885 + mysql-test/r/order_by_all.result-pq | 3396 + mysql-test/r/order_by_icp_mrr.result-pq | 3396 + mysql-test/r/order_by_limit.result-pq | 477 + mysql-test/r/order_by_none.result-pq | 3396 + mysql-test/r/order_by_sortkey.result-pq | 269 + mysql-test/r/outfile.result-pq | Bin 0 -> 2457 bytes mysql-test/r/parser.result-pq | 2750 + mysql-test/r/partition.result-pq | 3326 + mysql-test/r/partition_range.result-pq | 1126 + mysql-test/r/ps_ddl1.result-pq | 480 + mysql-test/r/range_all.result-pq | 3997 ++ mysql-test/r/range_icp.result-pq | 3997 ++ mysql-test/r/range_icp_mrr.result-pq | 3997 ++ mysql-test/r/range_mrr.result-pq | 3997 ++ mysql-test/r/range_mrr_cost.result-pq | 3997 ++ mysql-test/r/range_none.result-pq | 3996 ++ mysql-test/r/row.result-pq | 662 + mysql-test/r/select_all.result-pq | 5700 ++ mysql-test/r/select_all_bka.result-pq | 5703 ++ mysql-test/r/select_all_bka_nobnl.result-pq | 5703 ++ mysql-test/r/select_count.result-pq | 578 + mysql-test/r/select_icp_mrr.result-pq | 5700 ++ mysql-test/r/select_icp_mrr_bka.result-pq | 5703 ++ .../r/select_icp_mrr_bka_nobnl.result-pq | 5703 ++ mysql-test/r/select_none.result-pq | 5699 ++ mysql-test/r/select_none_bka.result-pq | 5701 ++ mysql-test/r/select_none_bka_nobnl.result-pq | 5701 ++ mysql-test/r/skip_records_in_range.result-pq | 748 + mysql-test/r/skip_scan.result-pq | 1739 + mysql-test/r/slow_log_extra-big.result-pq | 37 + mysql-test/r/sp.result-pq | 8587 +++ mysql-test/r/ssl.result-pq | 2307 + mysql-test/r/ssl_compress.result-pq | 2297 + mysql-test/r/status.result-pq | 521 + mysql-test/r/subquery_antijoin.result-pq | 1155 + mysql-test/r/subquery_bugs.result-pq | 1887 + mysql-test/r/subquery_exists.result-pq | 541 + .../r/subquery_mat_mixed_types.result-pq | 10135 +++ mysql-test/r/subquery_sj_all.result-pq | 12993 ++++ mysql-test/r/subquery_sj_all_bka.result-pq | 13000 ++++ .../r/subquery_sj_all_bka_nobnl.result-pq | 13000 ++++ mysql-test/r/subquery_sj_dupsweed.result-pq | 12919 ++++ .../r/subquery_sj_dupsweed_bka.result-pq | 12921 ++++ .../subquery_sj_dupsweed_bka_nobnl.result-pq | 12908 ++++ mysql-test/r/subquery_sj_firstmatch.result-pq | 12945 ++++ .../r/subquery_sj_firstmatch_bka.result-pq | 12947 ++++ ...subquery_sj_firstmatch_bka_nobnl.result-pq | 12936 ++++ mysql-test/r/subquery_sj_innodb_all.result-pq | 191 + .../r/subquery_sj_innodb_all_bka.result-pq | 193 + ...subquery_sj_innodb_all_bka_nobnl.result-pq | 193 + mysql-test/r/subquery_sj_loosescan.result-pq | 12907 ++++ .../r/subquery_sj_loosescan_bka.result-pq | 12909 ++++ .../subquery_sj_loosescan_bka_nobnl.result-pq | 12899 ++++ mysql-test/r/subquery_sj_mat.result-pq | 13224 ++++ mysql-test/r/subquery_sj_mat_bka.result-pq | 13226 ++++ .../r/subquery_sj_mat_bka_nobnl.result-pq | 13216 ++++ mysql-test/r/subselect_debug.result-pq | 77 + mysql-test/r/temptable_fallback.result-pq | 165 + mysql-test/r/truth_value_transform.result-pq | 83 + mysql-test/r/type_bit_innodb.result-pq | 446 + mysql-test/r/type_date.result-pq | 611 + mysql-test/r/type_datetime.result-pq | 989 + mysql-test/r/type_enum.result-pq | 1975 + mysql-test/r/type_float.result-pq | 726 + .../r/type_temporal_fractional.result-pq | 17792 +++++ mysql-test/r/type_time.result-pq | 2820 + mysql-test/r/type_timestamp.result-pq | 686 + .../r/type_timestamp_explicit.result-pq | 872 + mysql-test/r/type_varchar.result-pq | 614 + mysql-test/r/update.result-pq | 983 + mysql-test/r/user_var.result-pq | 1087 + mysql-test/r/varbinary.result-pq | 717 + mysql-test/r/view.result-pq | 6745 ++ mysql-test/r/view_grant.result-pq | 2743 + .../r/window_functions_explain.result-pq | 16944 +++++ mysql-test/r/with_grant.result-pq | 55 + mysql-test/r/with_non_recursive.result-pq | 2230 + .../suite/gcol/r/gcol_keys_innodb.result-pq | 1790 + .../innodb/include/innodb_redo_debug.inc | 1 + .../innodb/r/innodb-2byte-collation.result-pq | 152 + .../innodb/r/innodb-index-debug.result-pq | 343 + .../innodb/r/innodb-index-online.result-pq | 330 + .../suite/innodb/r/innodb-index.result-pq | 2007 + .../innodb/r/innodb-index_ucs2.result-pq | 128 + .../innodb/r/innodb-table-online.result-pq | 365 + mysql-test/suite/innodb/r/innodb.result-pq | 3491 + .../r/innodb_autoinc_lock_mode_zero.result-pq | 43 + .../suite/innodb/r/innodb_bug30423.result-pq | 103 + .../r/innodb_bulk_create_index.result-pq | 1073 + ...db_bulk_create_index_replication.result-pq | 228 + .../innodb_bulk_create_index_small.result-pq | 151 + .../suite/innodb/r/innodb_mysql.result-pq | 3491 + .../r/instant_add_column_basic.result-pq | 6258 ++ mysql-test/suite/innodb/r/monitor.result-pq | 739 + .../r/optimizer_temporary_table.result-pq | 4825 ++ .../innodb/r/select_count_perf.result-pq | 1899 + .../innodb/r/tablespace_encrypt_9.result-pq | 137 + .../suite/innodb/t/innodb-index-debug.test | 9 +- .../innodb_zip/r/index_large_prefix.result-pq | 467 + .../r/index_large_prefix_4k.result-pq | 388 + .../r/index_large_prefix_8k.result-pq | 396 + .../opt_trace/r/bugs_no_prot_all.result-pq | 3121 + .../opt_trace/r/bugs_no_prot_none.result-pq | 2395 + .../suite/opt_trace/r/charset.result-pq | 889 + .../opt_trace/r/eq_range_statistics.result-pq | 1702 + .../suite/opt_trace/r/filesort_pack.result-pq | 947 + .../suite/opt_trace/r/histograms.result-pq | 166 + .../r/opt_hints_index_merge.result-pq | 1362 + .../suite/opt_trace/r/range_no_prot.result-pq | 7444 +++ .../opt_trace/r/security_no_prot.result-pq | 962 + .../suite/opt_trace/r/skip_scan.result-pq | 1225 + .../opt_trace/r/subquery_no_prot.result-pq | 3400 + .../suite/opt_trace/r/temp_table.result-pq | 1399 + .../suite/parallel_query/include/pq_test.inc | 4 + .../suite/parallel_query/r/pq_abort.result-pq | 116 + .../r/pq_aggr_no_record.result-pq | 34 + .../suite/parallel_query/r/pq_blob.result-pq | 27 + .../parallel_query/r/pq_charset.result-pq | 266 + .../r/pq_check_first_rewritten_tab.result-pq | Bin 0 -> 4406 bytes .../parallel_query/r/pq_coverage.result-pq | 130 + .../parallel_query/r/pq_coverage_index.result | 31 + .../suite/parallel_query/r/pq_demon.result-pq | 2 + .../parallel_query/r/pq_explain.result-pq | 822 + .../suite/parallel_query/r/pq_flush.result-pq | 32 + .../parallel_query/r/pq_fullscan.result-pq | 41 + .../suite/parallel_query/r/pq_group_by.result | 886 + .../parallel_query/r/pq_group_by.result-pq | 888 + .../parallel_query/r/pq_having.result-pq | 251 + .../r/pq_instant_add_column.result-pq | 36 + .../suite/parallel_query/r/pq_join.result-pq | 286 + .../parallel_query/r/pq_jt_ref.result-pq | 59 + .../parallel_query/r/pq_kill_query.result-pq | 33 + .../parallel_query/r/pq_mdl_lock.result-pq | 40 + .../r/pq_memory_limit.result-pq | 62 + .../parallel_query/r/pq_mq_error.result-pq | 58 + .../parallel_query/r/pq_not_equal.result-pq | Bin 0 -> 856 bytes .../parallel_query/r/pq_not_support.result-pq | 128 + .../parallel_query/r/pq_opt_trace.result-pq | 10 + .../r/pq_order_aggregation.result-pq | 496 + .../suite/parallel_query/r/pq_order_by.result | 232 + .../parallel_query/r/pq_order_by.result-pq | 363 + .../parallel_query/r/pq_order_const.result-pq | 181 + .../parallel_query/r/pq_range_clust.result | 30 + .../parallel_query/r/pq_range_clust.result-pq | 30 + .../r/pq_range_scan_reverse.result-pq | 90 + .../parallel_query/r/pq_range_sec.result-pq | 262 + .../parallel_query/r/pq_rec_visible.result-pq | 30 + .../r/pq_ref_reverse_scan.result-pq | 27 + .../r/pq_restart_after_select.result-pq | 11 + .../r/pq_reverse_index_scan.result-pq | 54 + .../r/pq_sec_index_min.result-pq | 22 + .../parallel_query/r/pq_sp_trigger.result-pq | 186 + .../parallel_query/r/pq_sql_cond.result-pq | 21 + .../r/pq_stable_output.result-pq | 31705 +++++++++ .../r/pq_tempory_table_release.result-pq | 26 + .../suite/parallel_query/r/pq_tpch.result-pq | 909 + .../parallel_query/r/pq_variables.result-pq | 142 + .../r/pq_worker_error.result-pq | 168 + .../suite/parallel_query/t/pq_abort.test | 115 + .../parallel_query/t/pq_aggr_no_record.test | 38 + .../suite/parallel_query/t/pq_blob.test | 27 + .../suite/parallel_query/t/pq_charset.test | 168 + .../t/pq_check_first_rewritten_tab.test | 45 + .../suite/parallel_query/t/pq_coverage.test | 170 + .../parallel_query/t/pq_coverage_index.test | 64 + .../suite/parallel_query/t/pq_demon.test | 5 + .../suite/parallel_query/t/pq_explain.test | 406 + .../suite/parallel_query/t/pq_flush.test | 55 + .../suite/parallel_query/t/pq_fullscan.test | 48 + .../suite/parallel_query/t/pq_group_by.test | 262 + .../suite/parallel_query/t/pq_having.test | 97 + .../t/pq_instant_add_column.test | 33 + .../suite/parallel_query/t/pq_join.test | 193 + .../suite/parallel_query/t/pq_jt_ref.test | 39 + .../suite/parallel_query/t/pq_kill_query.test | 58 + .../suite/parallel_query/t/pq_mdl_lock.test | 32 + .../parallel_query/t/pq_memory_limit.test | 75 + .../suite/parallel_query/t/pq_mq_error.test | 72 + .../suite/parallel_query/t/pq_not_equal.test | 30 + .../parallel_query/t/pq_not_support.test | 51 + .../suite/parallel_query/t/pq_opt_trace.test | 21 + .../t/pq_order_aggregation.test | 163 + .../suite/parallel_query/t/pq_order_by.test | 233 + .../parallel_query/t/pq_order_const.test | 80 + .../parallel_query/t/pq_range_clust.test | 62 + .../t/pq_range_scan_reverse.test | 39 + .../suite/parallel_query/t/pq_range_sec.test | 360 + .../parallel_query/t/pq_rec_visible.test | 34 + .../parallel_query/t/pq_ref_reverse_scan.test | 26 + .../t/pq_restart_after_select.test | 14 + .../t/pq_reverse_index_scan.test | 23 + .../parallel_query/t/pq_sec_index_min.test | 19 + .../suite/parallel_query/t/pq_sp_trigger.test | 238 + .../suite/parallel_query/t/pq_sql_cond.test | 10 + .../parallel_query/t/pq_stable_output.test | 428 + .../t/pq_tempory_table_release.test | 21 + .../suite/parallel_query/t/pq_tpch.test | 828 + .../suite/parallel_query/t/pq_variables.test | 129 + .../parallel_query/t/pq_worker_error.test | 183 + .../parts/r/partition_alter3_innodb.result-pq | 818 + .../r/batch_table_io_func.result-pq | 188 + .../r/dml_setup_instruments.result-pq | 87 + .../perfschema/r/innodb_table_io.result-pq | 146 + .../r/start_server_low_table_lock.result-pq | 207 + .../r/start_server_no_table_lock.result-pq | 143 + .../r/table_aggregate_global_2u_3t.result-pq | 1741 + .../r/table_aggregate_global_4u_2t.result-pq | 1722 + .../r/table_aggregate_hist_2u_3t.result-pq | 1859 + .../r/table_aggregate_hist_4u_2t.result-pq | 1800 + .../r/table_aggregate_hist_4u_3t.result-pq | 1859 + .../r/table_aggregate_thread_2u_2t.result-pq | 1722 + .../r/table_aggregate_thread_2u_3t.result-pq | 1741 + .../r/table_aggregate_thread_4u_2t.result-pq | 1722 + .../r/table_aggregate_thread_4u_3t.result-pq | 1741 + .../r/table_io_aggregate_hist_2u_2t.result-pq | 1762 + .../r/table_io_aggregate_hist_2u_3t.result-pq | 1801 + .../r/table_io_aggregate_hist_4u_2t.result-pq | 1762 + .../r/table_io_aggregate_hist_4u_3t.result-pq | 1801 + .../table_io_aggregate_thread_2u_2t.result-pq | 1724 + .../table_io_aggregate_thread_2u_3t.result-pq | 1743 + .../table_io_aggregate_thread_4u_2t.result-pq | 1724 + .../table_io_aggregate_thread_4u_3t.result-pq | 1743 + .../suite/perfschema/r/transaction.result-pq | 604 + .../r/transaction_nested_events.result-pq | 674 + .../suite/perfschema/t/transaction.test | 27 +- .../rpl/r/rpl_invisible_indexes.result-pq | 91 + .../secondary_engine/r/explain.result-pq | 105 + .../r/plan_cost_debug.result-pq | 84 + .../suite/sys_vars/r/all_vars.result-pq | 92 + .../r/debug_pq_worker_stall_basic.result-pq | 16 + .../r/innodb_monitor_disable_basic.result-pq | 686 + .../r/innodb_monitor_enable_basic.result-pq | 686 + .../innodb_monitor_reset_all_basic.result-pq | 686 + .../r/innodb_monitor_reset_basic.result-pq | 694 + .../r/max_seeks_for_key_func.result-pq | 95 + .../t/debug_pq_worker_stall_basic.test | 16 + ...r_statement_performance_analyzer.result-pq | 199 + .../r/test_sql_complex.result-pq | 6424 ++ .../x/r/crud_resultset_metadata.result-pq | 24 + .../find_crud_conditionalclauses_o.result-pq | 1469 + .../suite/x/r/find_table_find.result-pq | 202 + .../x/r/stmtexecute_query_result.result-pq | 102 + mysql-test/t/all_persisted_variables.test | 2 +- mysql-test/t/error_simulation.test | 10 +- mysql-test/t/mysqlpump.test | 12 +- mysql-test/t/opt_hint_timeout.test | 4 + mysql-test/t/opt_hints_set_var.test | 4 + mysys/dbug.cc | 13 + mysys/my_alloc.cc | 49 + share/messages_to_clients.txt | 17 + sql/CMakeLists.txt | 10 + sql/basic_row_iterators.h | 76 + sql/binary_heap.h | 190 + sql/cmp_varlen_keys.h | 37 +- sql/composite_iterators.cc | 15 +- sql/composite_iterators.h | 20 + sql/debug_sync.cc | 3 +- sql/exchange.cc | 223 + sql/exchange.h | 98 + sql/exchange_nosort.cc | 125 + sql/exchange_nosort.h | 57 + sql/exchange_sort.cc | 350 + sql/exchange_sort.h | 159 + sql/field.cc | 23 +- sql/field.h | 27 +- sql/field_conv.cc | 108 + sql/filesort.cc | 120 +- sql/filesort.h | 7 +- sql/handler.cc | 71 + sql/handler.h | 60 +- sql/item.cc | 144 +- sql/item.h | 171 +- sql/item_cmpfunc.cc | 2 + sql/item_cmpfunc.h | 66 + sql/item_func.cc | 33 +- sql/item_func.h | 103 +- sql/item_geofunc.h | 24 + sql/item_inetfunc.h | 9 + sql/item_json_func.h | 8 + sql/item_pfs_func.h | 4 + sql/item_regexp_func.h | 5 + sql/item_row.h | 3 + sql/item_strfunc.h | 71 +- sql/item_subselect.cc | 3 +- sql/item_sum.cc | 184 +- sql/item_sum.h | 88 +- sql/item_timefunc.h | 66 + sql/item_xmlfunc.h | 2 + sql/join_optimizer/access_path.cc | 19 + sql/join_optimizer/access_path.h | 59 +- sql/join_optimizer/explain_access_path.cc | 60 + sql/join_optimizer/walk_access_paths.h | 3 + sql/lex.h | 3 + sql/mdl.cc | 11 + sql/memory/aligned_atomic.h | 4 +- sql/msg_queue.cc | 394 + sql/msg_queue.h | 321 + sql/mysqld.cc | 31 +- sql/mysqld.h | 5 + sql/opt_explain.cc | 76 +- sql/opt_explain_format.h | 6 +- sql/opt_explain_json.cc | 129 +- sql/opt_explain_json.h | 2 + sql/opt_explain_traditional.cc | 7 +- sql/opt_hints.cc | 2 + sql/opt_hints.h | 3 + sql/opt_range.cc | 182 + sql/opt_range.h | 20 + sql/parse_tree_hints.cc | 10 + sql/parse_tree_items.h | 12 + sql/parse_tree_node_base.h | 2 + sql/parse_tree_nodes.cc | 3 + sql/pq_clone.cc | 1215 + sql/pq_clone.h | 58 + sql/pq_clone_item.cc | 1990 + sql/pq_condition.cc | 1014 + sql/pq_condition.h | 35 + sql/pq_global.h | 47 + sql/pq_range.h | 39 + sql/protocol_classic.h | 3 +- sql/psi_memory_key.cc | 4 + sql/psi_memory_key.h | 2 + sql/query_result.cc | 229 + sql/query_result.h | 51 + sql/records.cc | 353 +- sql/records.h | 3 +- sql/row_iterator.h | 9 + sql/signal_handler.cc | 4 + sql/sorting_iterator.h | 3 + sql/sp_head.cc | 10 + sql/sql_base.cc | 21 +- sql/sql_base.h | 3 +- sql/sql_class.cc | 118 +- sql/sql_class.h | 116 +- sql/sql_executor.cc | 170 +- sql/sql_executor.h | 33 +- sql/sql_hints.yy | 31 + sql/sql_lex.cc | 13 + sql/sql_lex.h | 38 +- sql/sql_lex_hints.cc | 3 + sql/sql_opt_exec_shared.h | 47 +- sql/sql_optimizer.cc | 295 +- sql/sql_optimizer.h | 130 +- sql/sql_parallel.cc | 1210 + sql/sql_parallel.h | 207 + sql/sql_parse.cc | 10 + sql/sql_prepare.cc | 5 + sql/sql_resolver.cc | 24 +- sql/sql_select.cc | 851 +- sql/sql_select.h | 19 + sql/sql_tmp_table.cc | 115 +- sql/sql_tmp_table.h | 15 +- sql/sql_union.cc | 53 +- sql/sys_vars.cc | 51 + sql/system_variables.h | 13 + sql/table.h | 15 +- sql/temp_table_param.h | 2 + storage/innobase/handler/ha_innodb.cc | 6 + storage/innobase/handler/ha_innodb.h | 19 + storage/innobase/handler/handler0alter.cc | 471 +- storage/innobase/include/btr0pcur.h | 3 +- storage/innobase/include/data0data.h | 4 + storage/innobase/include/data0data.ic | 11 + storage/innobase/include/db0err.h | 2 + storage/innobase/include/read0types.h | 8 +- storage/innobase/include/rem0cmp.h | 5 + storage/innobase/include/row0mysql.h | 11 + storage/innobase/include/row0pread-adapter.h | 3 +- .../innobase/include/row0pread-histogram.h | 2 + storage/innobase/include/row0pread.h | 86 +- storage/innobase/include/row0sel.h | 44 +- storage/innobase/include/row0sel.ic | 34 +- storage/innobase/include/trx0trx.h | 3 + storage/innobase/read/read0read.cc | 13 +- storage/innobase/rem/rem0cmp.cc | 90 +- storage/innobase/row/row0mysql.cc | 7 + storage/innobase/row/row0pread-adapter.cc | 5 +- storage/innobase/row/row0pread.cc | 501 +- storage/innobase/row/row0sel.cc | 87 +- storage/innobase/trx/trx0trx.cc | 11 + storage/innobase/ut/ut0ut.cc | 3 + storage/temptable/include/temptable/block.h | 16 +- 520 files changed, 835223 insertions(+), 628 deletions(-) create mode 100644 mysql-test/collections/disabled-pq-debug-kp.def create mode 100644 mysql-test/collections/disabled-pq-kp.def create mode 100644 mysql-test/collections/disabled-pq.def create mode 100644 mysql-test/include/not_pq_test.inc create mode 100644 mysql-test/include/pq_test.inc create mode 100644 mysql-test/r/all_persisted_variables.result-pq create mode 100644 mysql-test/r/binary.result-pq create mode 100644 mysql-test/r/case.result-pq create mode 100644 mysql-test/r/cast.result-pq create mode 100644 mysql-test/r/compare.result-pq create mode 100644 mysql-test/r/compress.result-pq create mode 100644 mysql-test/r/condition_filter.result-pq create mode 100644 mysql-test/r/const_folding.result-pq create mode 100644 mysql-test/r/create.result-pq create mode 100644 mysql-test/r/ctype_binary.result-pq create mode 100644 mysql-test/r/ctype_collate.result-pq create mode 100644 mysql-test/r/ctype_cp1251.result-pq create mode 100644 mysql-test/r/ctype_gb18030.result-pq create mode 100644 mysql-test/r/ctype_uca.result-pq create mode 100644 mysql-test/r/ctype_ucs.result-pq create mode 100644 mysql-test/r/ctype_unicode900.result-pq create mode 100644 mysql-test/r/ctype_unicode900_as_ci.result-pq create mode 100644 mysql-test/r/ctype_unicode900_as_cs.result-pq create mode 100644 mysql-test/r/ctype_utf16.result-pq create mode 100644 mysql-test/r/ctype_utf16_uca.result-pq create mode 100644 mysql-test/r/ctype_utf16le.result-pq create mode 100644 mysql-test/r/ctype_utf32.result-pq create mode 100644 mysql-test/r/ctype_utf32_uca.result-pq create mode 100644 mysql-test/r/ctype_utf8mb4_innodb.result-pq create mode 100644 mysql-test/r/delete.result-pq create mode 100644 mysql-test/r/derived.result-pq create mode 100644 mysql-test/r/derived_correlated.result-pq create mode 100644 mysql-test/r/desc_index_innodb.result-pq create mode 100644 mysql-test/r/distinct_innodb.result-pq create mode 100644 mysql-test/r/endspace.result-pq create mode 100644 mysql-test/r/error_simulation.result-pq create mode 100644 mysql-test/r/explain_for_connection_small_json_innodb.result-pq create mode 100644 mysql-test/r/explain_other.result-pq create mode 100644 mysql-test/r/explain_tree.result-pq create mode 100644 mysql-test/r/filesort.result-pq create mode 100644 mysql-test/r/filesort_pack.result-pq create mode 100644 mysql-test/r/filter_single_col_idx_small.result-pq create mode 100644 mysql-test/r/func_comparison.result-pq create mode 100644 mysql-test/r/func_default.result-pq create mode 100644 mysql-test/r/func_group.result-pq create mode 100644 mysql-test/r/func_group_innodb.result-pq create mode 100644 mysql-test/r/func_if.result-pq create mode 100644 mysql-test/r/func_in_all.result-pq create mode 100644 mysql-test/r/func_in_icp.result-pq create mode 100644 mysql-test/r/func_in_icp_mrr.result-pq create mode 100644 mysql-test/r/func_in_mrr.result-pq create mode 100644 mysql-test/r/func_in_mrr_cost.result-pq create mode 100644 mysql-test/r/func_in_none.result-pq create mode 100644 mysql-test/r/func_like.result-pq create mode 100644 mysql-test/r/func_math.result-pq create mode 100644 mysql-test/r/func_prefix_key.result-pq create mode 100644 mysql-test/r/func_regexp.result-pq create mode 100644 mysql-test/r/func_str.result-pq create mode 100644 mysql-test/r/func_test.result-pq create mode 100644 mysql-test/r/functional_index.result-pq create mode 100644 mysql-test/r/greedy_search.result-pq create mode 100644 mysql-test/r/group_by.result-pq create mode 100644 mysql-test/r/group_by_fd_no_prot.result-pq create mode 100644 mysql-test/r/group_min_max.result-pq create mode 100644 mysql-test/r/group_min_max_ext.result-pq create mode 100644 mysql-test/r/group_min_max_innodb.result-pq create mode 100644 mysql-test/r/handler_read_last.result-pq create mode 100644 mysql-test/r/hash_join.result-pq create mode 100644 mysql-test/r/having.result-pq create mode 100644 mysql-test/r/heap.result-pq create mode 100644 mysql-test/r/histogram_equi_height.result-pq create mode 100644 mysql-test/r/histogram_singleton.result-pq create mode 100644 mysql-test/r/histograms.result-pq create mode 100644 mysql-test/r/index_merge_innodb.result-pq create mode 100644 mysql-test/r/innodb_explain_json_non_select_all.result-pq create mode 100644 mysql-test/r/innodb_explain_json_non_select_none.result-pq create mode 100644 mysql-test/r/innodb_explain_non_select_all.result-pq create mode 100644 mysql-test/r/innodb_explain_non_select_none.result-pq create mode 100644 mysql-test/r/innodb_icp.result-pq create mode 100644 mysql-test/r/innodb_icp_all.result-pq create mode 100644 mysql-test/r/innodb_icp_none.result-pq create mode 100644 mysql-test/r/innodb_mrr.result-pq create mode 100644 mysql-test/r/innodb_mrr_all.result-pq create mode 100644 mysql-test/r/innodb_mrr_cost.result-pq create mode 100644 mysql-test/r/innodb_mrr_cost_all.result-pq create mode 100644 mysql-test/r/innodb_mrr_cost_icp.result-pq create mode 100644 mysql-test/r/innodb_mrr_icp.result-pq create mode 100644 mysql-test/r/innodb_mrr_none.result-pq create mode 100644 mysql-test/r/innodb_pk_extension_off.result-pq create mode 100644 mysql-test/r/innodb_pk_extension_on.result-pq create mode 100644 mysql-test/r/innodb_tmp_table_heap_to_disk.result-pq create mode 100644 mysql-test/r/insert_update.result-pq create mode 100644 mysql-test/r/invisible_indexes.result-pq create mode 100644 mysql-test/r/join.result-pq create mode 100644 mysql-test/r/join_cache_bka.result-pq create mode 100644 mysql-test/r/join_cache_bka_nobnl.result-pq create mode 100644 mysql-test/r/join_cache_bnl.result-pq create mode 100644 mysql-test/r/join_cache_nojb.result-pq create mode 100644 mysql-test/r/join_nested.result-pq create mode 100644 mysql-test/r/join_nested_bka.result-pq create mode 100644 mysql-test/r/join_nested_bka_nobnl.result-pq create mode 100644 mysql-test/r/join_outer.result-pq create mode 100644 mysql-test/r/join_outer_bka.result-pq create mode 100644 mysql-test/r/join_outer_bka_nobnl.result-pq create mode 100644 mysql-test/r/join_outer_innodb.result-pq create mode 100644 mysql-test/r/key_diff.result-pq create mode 100644 mysql-test/r/kill_explain_analyze.result-pq create mode 100644 mysql-test/r/limit.result-pq create mode 100644 mysql-test/r/loose_scan.result-pq create mode 100644 mysql-test/r/metadata.result-pq create mode 100644 mysql-test/r/myisam_explain_json_non_select_all.result-pq create mode 100644 mysql-test/r/myisam_explain_json_non_select_none.result-pq create mode 100644 mysql-test/r/myisam_explain_non_select_all.result-pq create mode 100644 mysql-test/r/myisam_explain_non_select_none.result-pq create mode 100644 mysql-test/r/mysqld--help-notwin.result-pq create mode 100644 mysql-test/r/negation_elimination.result-pq create mode 100644 mysql-test/r/null.result-pq create mode 100644 mysql-test/r/null_key_all_innodb.result-pq create mode 100644 mysql-test/r/null_key_icp_innodb.result-pq create mode 100644 mysql-test/r/null_key_none_innodb.result-pq create mode 100644 mysql-test/r/opt_costmodel.result-pq create mode 100644 mysql-test/r/opt_costmodel_flush.result-pq create mode 100644 mysql-test/r/opt_costmodel_restart.result-pq create mode 100644 mysql-test/r/opt_hint_timeout.result-pq create mode 100644 mysql-test/r/opt_hints.result-pq create mode 100644 mysql-test/r/opt_hints_index.result-pq create mode 100644 mysql-test/r/opt_hints_index_merge.result-pq create mode 100644 mysql-test/r/opt_hints_join_order.result-pq create mode 100644 mysql-test/r/opt_hints_lowercase.result-pq create mode 100644 mysql-test/r/opt_hints_set_var.result-pq create mode 100644 mysql-test/r/opt_hints_subquery.result-pq create mode 100644 mysql-test/r/order_by_all.result-pq create mode 100644 mysql-test/r/order_by_icp_mrr.result-pq create mode 100644 mysql-test/r/order_by_limit.result-pq create mode 100644 mysql-test/r/order_by_none.result-pq create mode 100644 mysql-test/r/order_by_sortkey.result-pq create mode 100644 mysql-test/r/outfile.result-pq create mode 100644 mysql-test/r/parser.result-pq create mode 100644 mysql-test/r/partition.result-pq create mode 100644 mysql-test/r/partition_range.result-pq create mode 100644 mysql-test/r/ps_ddl1.result-pq create mode 100644 mysql-test/r/range_all.result-pq create mode 100644 mysql-test/r/range_icp.result-pq create mode 100644 mysql-test/r/range_icp_mrr.result-pq create mode 100644 mysql-test/r/range_mrr.result-pq create mode 100644 mysql-test/r/range_mrr_cost.result-pq create mode 100644 mysql-test/r/range_none.result-pq create mode 100644 mysql-test/r/row.result-pq create mode 100644 mysql-test/r/select_all.result-pq create mode 100644 mysql-test/r/select_all_bka.result-pq create mode 100644 mysql-test/r/select_all_bka_nobnl.result-pq create mode 100644 mysql-test/r/select_count.result-pq create mode 100644 mysql-test/r/select_icp_mrr.result-pq create mode 100644 mysql-test/r/select_icp_mrr_bka.result-pq create mode 100644 mysql-test/r/select_icp_mrr_bka_nobnl.result-pq create mode 100644 mysql-test/r/select_none.result-pq create mode 100644 mysql-test/r/select_none_bka.result-pq create mode 100644 mysql-test/r/select_none_bka_nobnl.result-pq create mode 100644 mysql-test/r/skip_records_in_range.result-pq create mode 100644 mysql-test/r/skip_scan.result-pq create mode 100644 mysql-test/r/slow_log_extra-big.result-pq create mode 100644 mysql-test/r/sp.result-pq create mode 100644 mysql-test/r/ssl.result-pq create mode 100644 mysql-test/r/ssl_compress.result-pq create mode 100644 mysql-test/r/status.result-pq create mode 100644 mysql-test/r/subquery_antijoin.result-pq create mode 100644 mysql-test/r/subquery_bugs.result-pq create mode 100644 mysql-test/r/subquery_exists.result-pq create mode 100644 mysql-test/r/subquery_mat_mixed_types.result-pq create mode 100644 mysql-test/r/subquery_sj_all.result-pq create mode 100644 mysql-test/r/subquery_sj_all_bka.result-pq create mode 100644 mysql-test/r/subquery_sj_all_bka_nobnl.result-pq create mode 100644 mysql-test/r/subquery_sj_dupsweed.result-pq create mode 100644 mysql-test/r/subquery_sj_dupsweed_bka.result-pq create mode 100644 mysql-test/r/subquery_sj_dupsweed_bka_nobnl.result-pq create mode 100644 mysql-test/r/subquery_sj_firstmatch.result-pq create mode 100644 mysql-test/r/subquery_sj_firstmatch_bka.result-pq create mode 100644 mysql-test/r/subquery_sj_firstmatch_bka_nobnl.result-pq create mode 100644 mysql-test/r/subquery_sj_innodb_all.result-pq create mode 100644 mysql-test/r/subquery_sj_innodb_all_bka.result-pq create mode 100644 mysql-test/r/subquery_sj_innodb_all_bka_nobnl.result-pq create mode 100644 mysql-test/r/subquery_sj_loosescan.result-pq create mode 100644 mysql-test/r/subquery_sj_loosescan_bka.result-pq create mode 100644 mysql-test/r/subquery_sj_loosescan_bka_nobnl.result-pq create mode 100644 mysql-test/r/subquery_sj_mat.result-pq create mode 100644 mysql-test/r/subquery_sj_mat_bka.result-pq create mode 100644 mysql-test/r/subquery_sj_mat_bka_nobnl.result-pq create mode 100644 mysql-test/r/subselect_debug.result-pq create mode 100644 mysql-test/r/temptable_fallback.result-pq create mode 100644 mysql-test/r/truth_value_transform.result-pq create mode 100644 mysql-test/r/type_bit_innodb.result-pq create mode 100644 mysql-test/r/type_date.result-pq create mode 100644 mysql-test/r/type_datetime.result-pq create mode 100644 mysql-test/r/type_enum.result-pq create mode 100644 mysql-test/r/type_float.result-pq create mode 100644 mysql-test/r/type_temporal_fractional.result-pq create mode 100644 mysql-test/r/type_time.result-pq create mode 100644 mysql-test/r/type_timestamp.result-pq create mode 100644 mysql-test/r/type_timestamp_explicit.result-pq create mode 100644 mysql-test/r/type_varchar.result-pq create mode 100644 mysql-test/r/update.result-pq create mode 100644 mysql-test/r/user_var.result-pq create mode 100644 mysql-test/r/varbinary.result-pq create mode 100644 mysql-test/r/view.result-pq create mode 100644 mysql-test/r/view_grant.result-pq create mode 100644 mysql-test/r/window_functions_explain.result-pq create mode 100644 mysql-test/r/with_grant.result-pq create mode 100644 mysql-test/r/with_non_recursive.result-pq create mode 100644 mysql-test/suite/gcol/r/gcol_keys_innodb.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb-2byte-collation.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb-index-debug.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb-index-online.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb-index.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb-index_ucs2.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb-table-online.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb_autoinc_lock_mode_zero.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb_bug30423.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb_bulk_create_index.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result-pq create mode 100644 mysql-test/suite/innodb/r/innodb_mysql.result-pq create mode 100644 mysql-test/suite/innodb/r/instant_add_column_basic.result-pq create mode 100644 mysql-test/suite/innodb/r/monitor.result-pq create mode 100644 mysql-test/suite/innodb/r/optimizer_temporary_table.result-pq create mode 100644 mysql-test/suite/innodb/r/select_count_perf.result-pq create mode 100644 mysql-test/suite/innodb/r/tablespace_encrypt_9.result-pq create mode 100644 mysql-test/suite/innodb_zip/r/index_large_prefix.result-pq create mode 100644 mysql-test/suite/innodb_zip/r/index_large_prefix_4k.result-pq create mode 100644 mysql-test/suite/innodb_zip/r/index_large_prefix_8k.result-pq create mode 100644 mysql-test/suite/opt_trace/r/bugs_no_prot_all.result-pq create mode 100644 mysql-test/suite/opt_trace/r/bugs_no_prot_none.result-pq create mode 100644 mysql-test/suite/opt_trace/r/charset.result-pq create mode 100644 mysql-test/suite/opt_trace/r/eq_range_statistics.result-pq create mode 100644 mysql-test/suite/opt_trace/r/filesort_pack.result-pq create mode 100644 mysql-test/suite/opt_trace/r/histograms.result-pq create mode 100644 mysql-test/suite/opt_trace/r/opt_hints_index_merge.result-pq create mode 100644 mysql-test/suite/opt_trace/r/range_no_prot.result-pq create mode 100644 mysql-test/suite/opt_trace/r/security_no_prot.result-pq create mode 100644 mysql-test/suite/opt_trace/r/skip_scan.result-pq create mode 100644 mysql-test/suite/opt_trace/r/subquery_no_prot.result-pq create mode 100644 mysql-test/suite/opt_trace/r/temp_table.result-pq create mode 100644 mysql-test/suite/parallel_query/include/pq_test.inc create mode 100644 mysql-test/suite/parallel_query/r/pq_abort.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_aggr_no_record.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_blob.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_charset.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_check_first_rewritten_tab.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_coverage.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_coverage_index.result create mode 100644 mysql-test/suite/parallel_query/r/pq_demon.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_explain.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_flush.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_fullscan.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_group_by.result create mode 100644 mysql-test/suite/parallel_query/r/pq_group_by.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_having.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_instant_add_column.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_join.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_jt_ref.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_kill_query.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_mdl_lock.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_memory_limit.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_mq_error.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_not_equal.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_not_support.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_opt_trace.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_order_aggregation.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_order_by.result create mode 100644 mysql-test/suite/parallel_query/r/pq_order_by.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_order_const.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_range_clust.result create mode 100644 mysql-test/suite/parallel_query/r/pq_range_clust.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_range_scan_reverse.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_range_sec.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_rec_visible.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_ref_reverse_scan.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_restart_after_select.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_reverse_index_scan.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_sec_index_min.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_sp_trigger.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_sql_cond.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_stable_output.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_tempory_table_release.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_tpch.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_variables.result-pq create mode 100644 mysql-test/suite/parallel_query/r/pq_worker_error.result-pq create mode 100644 mysql-test/suite/parallel_query/t/pq_abort.test create mode 100644 mysql-test/suite/parallel_query/t/pq_aggr_no_record.test create mode 100644 mysql-test/suite/parallel_query/t/pq_blob.test create mode 100644 mysql-test/suite/parallel_query/t/pq_charset.test create mode 100644 mysql-test/suite/parallel_query/t/pq_check_first_rewritten_tab.test create mode 100644 mysql-test/suite/parallel_query/t/pq_coverage.test create mode 100644 mysql-test/suite/parallel_query/t/pq_coverage_index.test create mode 100644 mysql-test/suite/parallel_query/t/pq_demon.test create mode 100644 mysql-test/suite/parallel_query/t/pq_explain.test create mode 100644 mysql-test/suite/parallel_query/t/pq_flush.test create mode 100644 mysql-test/suite/parallel_query/t/pq_fullscan.test create mode 100644 mysql-test/suite/parallel_query/t/pq_group_by.test create mode 100644 mysql-test/suite/parallel_query/t/pq_having.test create mode 100644 mysql-test/suite/parallel_query/t/pq_instant_add_column.test create mode 100644 mysql-test/suite/parallel_query/t/pq_join.test create mode 100644 mysql-test/suite/parallel_query/t/pq_jt_ref.test create mode 100644 mysql-test/suite/parallel_query/t/pq_kill_query.test create mode 100644 mysql-test/suite/parallel_query/t/pq_mdl_lock.test create mode 100644 mysql-test/suite/parallel_query/t/pq_memory_limit.test create mode 100644 mysql-test/suite/parallel_query/t/pq_mq_error.test create mode 100644 mysql-test/suite/parallel_query/t/pq_not_equal.test create mode 100644 mysql-test/suite/parallel_query/t/pq_not_support.test create mode 100644 mysql-test/suite/parallel_query/t/pq_opt_trace.test create mode 100644 mysql-test/suite/parallel_query/t/pq_order_aggregation.test create mode 100644 mysql-test/suite/parallel_query/t/pq_order_by.test create mode 100644 mysql-test/suite/parallel_query/t/pq_order_const.test create mode 100644 mysql-test/suite/parallel_query/t/pq_range_clust.test create mode 100644 mysql-test/suite/parallel_query/t/pq_range_scan_reverse.test create mode 100644 mysql-test/suite/parallel_query/t/pq_range_sec.test create mode 100644 mysql-test/suite/parallel_query/t/pq_rec_visible.test create mode 100644 mysql-test/suite/parallel_query/t/pq_ref_reverse_scan.test create mode 100644 mysql-test/suite/parallel_query/t/pq_restart_after_select.test create mode 100644 mysql-test/suite/parallel_query/t/pq_reverse_index_scan.test create mode 100644 mysql-test/suite/parallel_query/t/pq_sec_index_min.test create mode 100644 mysql-test/suite/parallel_query/t/pq_sp_trigger.test create mode 100644 mysql-test/suite/parallel_query/t/pq_sql_cond.test create mode 100644 mysql-test/suite/parallel_query/t/pq_stable_output.test create mode 100644 mysql-test/suite/parallel_query/t/pq_tempory_table_release.test create mode 100644 mysql-test/suite/parallel_query/t/pq_tpch.test create mode 100644 mysql-test/suite/parallel_query/t/pq_variables.test create mode 100644 mysql-test/suite/parallel_query/t/pq_worker_error.test create mode 100644 mysql-test/suite/parts/r/partition_alter3_innodb.result-pq create mode 100644 mysql-test/suite/perfschema/r/batch_table_io_func.result-pq create mode 100644 mysql-test/suite/perfschema/r/dml_setup_instruments.result-pq create mode 100644 mysql-test/suite/perfschema/r/innodb_table_io.result-pq create mode 100644 mysql-test/suite/perfschema/r/start_server_low_table_lock.result-pq create mode 100644 mysql-test/suite/perfschema/r/start_server_no_table_lock.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result-pq create mode 100644 mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result-pq create mode 100644 mysql-test/suite/perfschema/r/transaction.result-pq create mode 100644 mysql-test/suite/perfschema/r/transaction_nested_events.result-pq create mode 100644 mysql-test/suite/rpl/r/rpl_invisible_indexes.result-pq create mode 100644 mysql-test/suite/secondary_engine/r/explain.result-pq create mode 100644 mysql-test/suite/secondary_engine/r/plan_cost_debug.result-pq create mode 100644 mysql-test/suite/sys_vars/r/all_vars.result-pq create mode 100644 mysql-test/suite/sys_vars/r/debug_pq_worker_stall_basic.result-pq create mode 100644 mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result-pq create mode 100644 mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result-pq create mode 100644 mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result-pq create mode 100644 mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result-pq create mode 100644 mysql-test/suite/sys_vars/r/max_seeks_for_key_func.result-pq create mode 100644 mysql-test/suite/sys_vars/t/debug_pq_worker_stall_basic.test create mode 100644 mysql-test/suite/sysschema/r/pr_statement_performance_analyzer.result-pq create mode 100644 mysql-test/suite/test_service_sql_api/r/test_sql_complex.result-pq create mode 100644 mysql-test/suite/x/r/crud_resultset_metadata.result-pq create mode 100644 mysql-test/suite/x/r/find_crud_conditionalclauses_o.result-pq create mode 100644 mysql-test/suite/x/r/find_table_find.result-pq create mode 100644 mysql-test/suite/x/r/stmtexecute_query_result.result-pq create mode 100644 sql/binary_heap.h create mode 100644 sql/exchange.cc create mode 100644 sql/exchange.h create mode 100644 sql/exchange_nosort.cc create mode 100644 sql/exchange_nosort.h create mode 100644 sql/exchange_sort.cc create mode 100644 sql/exchange_sort.h create mode 100644 sql/msg_queue.cc create mode 100644 sql/msg_queue.h create mode 100644 sql/pq_clone.cc create mode 100644 sql/pq_clone.h create mode 100644 sql/pq_clone_item.cc create mode 100644 sql/pq_condition.cc create mode 100644 sql/pq_condition.h create mode 100644 sql/pq_global.h create mode 100644 sql/pq_range.h create mode 100644 sql/sql_parallel.cc create mode 100644 sql/sql_parallel.h diff --git a/include/my_alloc.h b/include/my_alloc.h index b652bf896..5b651d442 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -44,6 +45,9 @@ #include "my_pointer_arithmetic.h" #include "mysql/psi/psi_memory.h" +typedef void CallBackFunc(PSI_memory_key key, size_t length, unsigned int id) ; +const int PQ_MEMORY_USED_BUCKET = 16; + /** * The MEM_ROOT is a simple arena, where allocations are carved out of * larger blocks. Using an arena over plain malloc gives you two main @@ -132,28 +136,7 @@ struct MEM_ROOT { * * The returned pointer will always be 8-aligned. */ - void *Alloc(size_t length) MY_ATTRIBUTE((malloc)) { - length = ALIGN_SIZE(length); - - // Skip the straight path if simulating OOM; it should always fail. - DBUG_EXECUTE_IF("simulate_out_of_memory", return AllocSlow(length);); - - // Fast path, used in the majority of cases. It would be faster here - // (saving one register due to CSE) to instead test - // - // m_current_free_start + length <= m_current_free_end - // - // but it would invoke undefined behavior, and in particular be prone - // to wraparound on 32-bit platforms. - if (static_cast(m_current_free_end - m_current_free_start) >= - length) { - void *ret = m_current_free_start; - m_current_free_start += length; - return ret; - } - - return AllocSlow(length); - } + void *Alloc(size_t length) MY_ATTRIBUTE((malloc)); /** Allocate “num” objects of type T, and default-construct them. @@ -389,6 +372,11 @@ struct MEM_ROOT { void (*m_error_handler)(void) = nullptr; PSI_memory_key m_psi_key = 0; + +public: + CallBackFunc *allocCBFunc = nullptr; + + CallBackFunc *freeCBFunc = nullptr; }; // Legacy C thunks. Do not use in new code. diff --git a/include/my_dbug.h b/include/my_dbug.h index 9a1437358..086ab4697 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -60,6 +61,8 @@ extern int _db_is_pushed_(void); extern void _db_process_(const char *name); extern void _db_push_(const char *control); extern void _db_pop_(void); +extern void pq_stack_copy(CODE_STATE *leader_cs); +extern void pq_stack_reset(); extern void _db_set_(const char *control); extern void _db_set_init_(const char *control); extern void _db_enter_(const char *_func_, int func_len, const char *_file_, diff --git a/include/priority_queue.h b/include/priority_queue.h index ee22f0e15..af9bb452c 100644 --- a/include/priority_queue.h +++ b/include/priority_queue.h @@ -1,4 +1,5 @@ /* Copyright (c) 2014, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -102,7 +103,7 @@ class Priority_queue : public Less { friend class priority_queue_unittest::PriorityQueueTest; - private: + public: // Deriving from Less allows empty base-class optimization in some cases. typedef Less Base; @@ -403,7 +404,7 @@ class Priority_queue : public Less { return false; } - private: + public: container_type m_container; }; diff --git a/include/sql_string.h b/include/sql_string.h index b4be536d1..a9cb41f2b 100644 --- a/include/sql_string.h +++ b/include/sql_string.h @@ -70,11 +70,10 @@ extern PSI_memory_key key_memory_String_value; Don't add new members or virual methods into this class! */ class Simple_cstring { - private: + public: const char *m_str; size_t m_length; - public: /** Initialize from a C string whose length is already known. */ diff --git a/mysql-test/collections/disabled-pq-debug-kp.def b/mysql-test/collections/disabled-pq-debug-kp.def new file mode 100644 index 000000000..c007fd83c --- /dev/null +++ b/mysql-test/collections/disabled-pq-debug-kp.def @@ -0,0 +1,16 @@ +# Tests in this file are disabled for --pq debug test. +main.ssl-big : BUG#000 origin code failed +main.mysql_load_data_local_dir : BUG#000 origin code failed +innodb.innodb_bug30899683 : BUG#000 origin code failed +innodb.innodb_buffer_pool_resize : BUG#000 origin code failed +innodb.lock_sys_resize : BUG#000 origin code failed +main.mtr_unit_tests : BUG#000 origin code failed +main.file_contents : BUG#000 origin code failed +main.dd_pfs : BUG#000 origin code failed +sys_vars.innodb_buffer_pool_size_basic : BUG#000 origin code failed +main.read_only_ddl : BUG#000 origin code failed +secondary_engine.cost_threshold : BUG#000 origin code failed +innodb.innodb_buffer_pool_resize_with_instances : BUG#000 origin code failed +main.log_buffered-big : BUG#000 origin code failed +innodb.innodb_buffer_pool_resize_with_chunks : BUG#000 origin code failed +innodb.innodb_bug30113362 : BUG#001 not apply to parallel queries diff --git a/mysql-test/collections/disabled-pq-kp.def b/mysql-test/collections/disabled-pq-kp.def new file mode 100644 index 000000000..6bb3aeaf1 --- /dev/null +++ b/mysql-test/collections/disabled-pq-kp.def @@ -0,0 +1,11 @@ +# Tests in this file are disabled for --pq test. +innodb.innodb_buffer_pool_resize : BUG#000 origin code failed +innodb.innodb_buffer_pool_resize_with_chunks : BUG#000 origin code failed +main.mysql_load_data_local_dir : BUG#000 origin code failed +main.mtr_unit_tests : BUG#000 origin code failed +main.dd_pfs : BUG#000 origin code failed +main.file_contents : BUG#000 origin code failed +main.read_only_ddl : BUG#000 origin code failed +secondary_engine.cost_threshold : BUG#000 origin code failed +sys_vars.innodb_buffer_pool_size_basic : BUG#000 origin code failed + diff --git a/mysql-test/collections/disabled-pq.def b/mysql-test/collections/disabled-pq.def new file mode 100644 index 000000000..934017554 --- /dev/null +++ b/mysql-test/collections/disabled-pq.def @@ -0,0 +1,16 @@ +# Tests in this file are disabled for ASAN runs in pushbuild. +# This is in addition to tests disabled by normal disabled.def files +parallel_query.pq_demon : BUG#194 skip example +innodb.lock_contention : BUG#000 DEBUG_SYNC +perfschema.table_aggregate_hist_2u_2t : BUG#245 PFS +perfschema.table_aggregate_global_4u_3t : BUG#245 PFS +perfschema.misc : BUG#245 PFS +perfschema.table_aggregate_global_2u_2t : BUG#245 PFS +main.events_1 : BUG#255 EVENT DATETIME +main.range_with_memory_limit : BUG#258 ANALYZE_TABLE +main.filesort_debug : BUG#254 DEBUG_SYNC +main.events_bugs : Bug#39863 events_bugs +main.events_1 : BUG#255 EVENT DATETIME +main.kill_debug : BUG#291 issue-291 DEBUG_EXE +main.mysql_client_test : BUG#293 issue-293 PTHREAD_JOIN +perfschema.idx_compare_ees_by_thread_by_error : BUG#294 issue-294 PFS diff --git a/mysql-test/include/common-tests.inc b/mysql-test/include/common-tests.inc index 8dc41b1c5..c36974df2 100644 --- a/mysql-test/include/common-tests.inc +++ b/mysql-test/include/common-tests.inc @@ -1543,7 +1543,14 @@ INSERT INTO t4 (companynr, companyname) VALUES (00,'Unknown'); --sorted_result select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; -select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +if ($PQ_TEST) +{ + select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr order by t2.companynr; +} +if (!$PQ_TEST) +{ + select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +} # # Full join (same alias) @@ -1647,7 +1654,14 @@ select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld # select count(*) from t1; -select companynr,count(*),sum(fld1) from t2 group by companynr; +if ($PQ_TEST) +{ + select companynr,count(*),sum(fld1) from t2 group by companynr order by companynr; +} +if (!$PQ_TEST) +{ + select companynr,count(*),sum(fld1) from t2 group by companynr; +} select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; --replace_column 10 # 11 # @@ -1656,12 +1670,26 @@ select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),vari select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr order by companynr,t2nr limit 10; select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr, t2nr order by companynr,t2nr limit 10; -select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +if ($PQ_TEST) +{ + select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr order by companynr; +} +if (!$PQ_TEST) +{ + select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +} select distinct mod(companynr,10) from t4 group by companynr; select distinct 1 from t4 group by companynr; select count(distinct fld1) from t2; select companynr,count(distinct fld1) from t2 group by companynr; -select companynr,count(*) from t2 group by companynr; +if ($PQ_TEST) +{ + select companynr,count(*) from t2 group by companynr order by companynr; +} +if (!$PQ_TEST) +{ + select companynr,count(*) from t2 group by companynr; +} select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; @@ -1695,7 +1723,14 @@ select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 grou # select sum(Period)/count(*) from t1; -select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +if ($PQ_TEST) +{ + select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr order by companynr; +} +if (!$PQ_TEST) +{ + select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +} select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; # @@ -1706,7 +1741,14 @@ select companynr,sum(price)/count(price) as avg from t3 group by companynr havin select companynr,count(*) from t2 group by companynr order by 2 desc; select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; -select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +if ($PQ_TEST) +{ + select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4 order by fld1; +} +if (!$PQ_TEST) +{ + select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +} # # group by with many tables @@ -1716,8 +1758,17 @@ select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) # send rows # -select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; -select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +if ($PQ_TEST) +{ + select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3 order by fld3; + select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr order by companynr; +} +if (!$PQ_TEST) +{ + select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; + select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +} + # # group with many tables and long group on many tables. group on formula @@ -1757,7 +1808,14 @@ select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; -select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +if ($PQ_TEST) +{ + select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40 order by t2.companynr; +} +if (!$PQ_TEST) +{ + select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +} # # MIN(), MAX() and COUNT() optimizing @@ -1780,7 +1838,14 @@ select min(fld1),max(fld1),count(*) from t2; --enable_ps_protocol select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; -select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +if ($PQ_TEST) +{ + select t2nr,count(*) from t3 where name='gems' group by t2nr order by t2nr limit 20; +} +if (!$PQ_TEST) +{ + select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +} select max(t2nr) from t3 where price=983543950; # diff --git a/mysql-test/include/not_pq_test.inc b/mysql-test/include/not_pq_test.inc new file mode 100644 index 000000000..60180d67e --- /dev/null +++ b/mysql-test/include/not_pq_test.inc @@ -0,0 +1,4 @@ +if ($PQ_TEST) +{ + --skip cannot run in '--pq' option +} diff --git a/mysql-test/include/pq_test.inc b/mysql-test/include/pq_test.inc new file mode 100644 index 000000000..a1199cf17 --- /dev/null +++ b/mysql-test/include/pq_test.inc @@ -0,0 +1,4 @@ +if (!$PQ_TEST) +{ + --skip Test needs '--pq' option +} diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index c80b81f4e..e9b4359d2 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -348,6 +348,12 @@ sub create_disabled_test_list($$) { "$::glob_mysql_test_dir/collections/disabled_ndb.def") if $::ndbcluster_enabled; + if ($::opt_pq) { + # Add 'disabled-pq.def' to the list of disabled files if pq is enabled. + unshift(@disabled_collection, + "$::glob_mysql_test_dir/collections/disabled-pq.def"); + } + # Check for the tests to be skipped in a sanitizer which are listed # in "mysql-test/collections/disabled-.list" file. if ($::opt_sanitize) { @@ -1174,6 +1180,11 @@ sub collect_one_test_case { shortname => $tname,); my $result_file = "$resdir/$tname.result"; + + if ($::opt_pq and ($::opt_record or -f "$resdir/$tname.result-pq")) { + $result_file = "$resdir/$tname.result-pq"; + } + if (-f $result_file) { $tinfo->{result_file} = $result_file; } else { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 8d16fa0d8..2080c8f5f 100644 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -264,6 +264,7 @@ our @DEFAULT_SUITES = qw( test_services x component_keyring_file + parallel_query ); our $DEFAULT_SUITES = join ',', @DEFAULT_SUITES; @@ -271,6 +272,7 @@ our $DEFAULT_SUITES = join ',', @DEFAULT_SUITES; # End of list of default suites our $opt_big_test = 0; +our $opt_pq = 0; our $opt_check_testcases = 1; our $opt_clean_vardir = $ENV{'MTR_CLEAN_VARDIR'}; our $opt_ctest = env_or_val(MTR_UNIT_TESTS => -1); @@ -1560,6 +1562,7 @@ sub command_line_setup { # Control what test suites or cases to run 'big-test' => \$opt_big_test, + 'pq' => \$opt_pq, 'combination=s' => \@opt_combinations, 'do-suite=s' => \$opt_do_suite, 'do-test=s' => \&collect_option, @@ -2022,6 +2025,8 @@ sub command_line_setup { $ENV{'BIG_TEST'} = 1 if ($opt_big_test or $opt_only_big_test); + $ENV{'PQ_TEST'} = 1 if ($opt_pq); + # Gcov flag if (($opt_gcov or $opt_gprof) and !$source_dist) { mtr_error("Coverage test needs the source - please use source dist"); @@ -2119,6 +2124,12 @@ sub command_line_setup { push(@opt_extra_mysqld_opt, "--optimizer-trace-max-mem-size=1000000"); } + # Check parallel query + if ($opt_pq) { + push(@opt_extra_mysqld_opt, "--force_parallel_execute=1"); + push(@opt_extra_mysqld_opt, "--parallel_cost_threshold=0"); + } + # Check valgrind arguments if ($opt_valgrind or $opt_valgrind_path or @valgrind_args) { mtr_report("Turning on valgrind for all executables"); @@ -7548,6 +7559,7 @@ Options to control what test suites or cases to run force Continue to run the suite after failure. include-ndb[cluster] Enable all tests that need cluster. only-big-test Run only big tests and skip the normal(non-big) tests. + pq run tests using 4 threads parallel query. print-testcases Don't run the tests but print details about all the selected tests, in the order they would be run. skip-ndb[cluster] Skip all tests that need cluster. This setting is diff --git a/mysql-test/r/all_persisted_variables.result-pq b/mysql-test/r/all_persisted_variables.result-pq new file mode 100644 index 000000000..985cf78bd --- /dev/null +++ b/mysql-test/r/all_persisted_variables.result-pq @@ -0,0 +1,66 @@ +*********************************************************************** +* Run only on debug build,non-windows as few server variables are not +* available on all platforms. +*********************************************************************** +call mtr.add_suppression("Failed to set up SSL because of the following SSL library error"); +call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* Changing innodb_extend_and_initialize not supported on this platform."); +call mtr.add_suppression("Failed to initialize TLS for channel: mysql_main"); +*************************************************************** +* 0. Verify that variables present in performance_schema.global +* variables are actually global variables and can be set using +* SET GLOBAL +*************************************************************** +CREATE TABLE global_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024)); +INSERT INTO global_vars (var_name, var_value) SELECT * FROM +performance_schema.global_variables WHERE variable_name NOT IN +('innodb_monitor_enable', +'innodb_monitor_disable', +'innodb_monitor_reset', +'innodb_monitor_reset_all', +'rbr_exec_mode'); +************************************************************ +* 1. Check that there are no persisted variable settings. +************************************************************ +include/assert.inc ['Expect 0 persisted variables.'] + +************************************************************ +* 2. Initialization. Test SET PERSIST. Verify persisted +* variables. +************************************************************ +CREATE TABLE all_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024)); +INSERT INTO all_vars (var_name, var_value) +SELECT * FROM performance_schema.global_variables +WHERE variable_name NOT IN +('rbr_exec_mode') +AND variable_name NOT LIKE 'ndb_%' +ORDER BY variable_name; + +include/assert.inc [Expect 500+ variables in the table. Due to open Bugs, we are checking for fewer ] + +# Test SET PERSIST + +include/assert.inc [Expect 419 persisted variables in the table.] + +************************************************************ +* 3. Restart server, it must preserve the persisted variable +* settings. Verify persisted configuration. +************************************************************ +# restart + +include/assert.inc [Expect 419 persisted variables in persisted_variables table.] +include/assert.inc [Expect 419 persisted variables shown as PERSISTED in variables_info table.] +include/assert.inc [Expect 419 persisted variables with matching peristed and global values.] + +************************************************************ +* 4. Test RESET PERSIST IF EXISTS. Verify persisted variable +* settings are removed. +************************************************************ + +include/assert.inc ['Expect 0 persisted variables.'] + +************************************************************ +* 5. Clean up. +************************************************************ +DROP TABLE all_vars; +DROP TABLE global_vars; +# restart diff --git a/mysql-test/r/binary.result-pq b/mysql-test/r/binary.result-pq new file mode 100644 index 000000000..fe2c7df09 --- /dev/null +++ b/mysql-test/r/binary.result-pq @@ -0,0 +1,213 @@ +drop table if exists t1,t2; +set names latin1; +create table t1 (name char(20) not null, primary key (name)) charset latin1; +create table t2 (name char(20) binary not null, primary key (name)); +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values (""); +insert into t1 values (""); +insert into t1 values (""); +insert into t2 select * from t1; +select * from t1 order by name; +name + + + +select concat("*",name,"*") from t1 order by 1; +concat("*",name,"*") +** +** +** +select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1; +min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*")) + ** ** +select * from t2 order by name; +name + + + +select concat("*",name,"*") from t2 order by 1; +concat("*",name,"*") +** +** +** +select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2; +min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*")) + ** ** +select name from t1 where name between '' and ''; +name + + +select name from t2 where name between '' and ''; +name + + + +select name from t2 where name between '' and ''; +name +drop table t1,t2; +create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b)) charset latin1; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values ("hello ","hello "),("hello2 ","hello2 "); +select concat("-",a,"-",b,"-") from t1 where a="hello"; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where a="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where b="hello"; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +alter table t1 modify b tinytext not null, drop key b, add key (b(100)); +select concat("-",a,"-",b,"-") from t1; +concat("-",a,"-",b,"-") +-hello-hello- +-hello2-hello2- +select concat("-",a,"-",b,"-") from t1 where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; +concat("-",a,"-",b,"-") +-hello-hello- +drop table t1; +create table t1 (b char(8)); +insert into t1 values(NULL); +select b from t1 where binary b like ''; +b +select b from t1 group by binary b like ''; +b +NULL +select b from t1 having binary b like ''; +b +drop table t1; +create table t1 (a char(3) binary, b binary(3)) charset latin1; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values ('aaa','bbb'),('AAA','BBB'); +select upper(a),upper(b) from t1; +upper(a) upper(b) +AAA bbb +AAA BBB +select lower(a),lower(b) from t1; +lower(a) lower(b) +aaa bbb +aaa BBB +select * from t1 where upper(a)='AAA'; +a b +aaa bbb +AAA BBB +select * from t1 where lower(a)='aaa'; +a b +aaa bbb +AAA BBB +select * from t1 where upper(b)='BBB'; +a b +AAA BBB +select * from t1 where lower(b)='bbb'; +a b +aaa bbb +select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1; +charset(a) charset(b) charset(binary 'ccc') +latin1 binary binary +select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1; +collation(a) collation(b) collation(binary 'ccc') +latin1_bin binary binary +drop table t1; +create table t1( firstname char(20), lastname char(20)); +insert into t1 values ("john","doe"),("John","Doe"); +select * from t1 where firstname='john' and firstname like binary 'john'; +firstname lastname +john doe +select * from t1 where firstname='john' and binary 'john' = firstname; +firstname lastname +john doe +select * from t1 where firstname='john' and firstname = binary 'john'; +firstname lastname +john doe +select * from t1 where firstname='John' and firstname like binary 'john'; +firstname lastname +john doe +select * from t1 where firstname='john' and firstname like binary 'John'; +firstname lastname +John Doe +drop table t1; +create table t1 (a binary) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` binary(1) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (col1 binary(4)); +insert into t1 values ('a'),('a '); +select hex(col1) from t1; +hex(col1) +61000000 +61200000 +alter table t1 modify col1 binary(10); +select hex(col1) from t1; +hex(col1) +61000000000000000000 +61200000000000000000 +insert into t1 values ('b'),('b '); +select hex(col1) from t1; +hex(col1) +61000000000000000000 +61200000000000000000 +62000000000000000000 +62200000000000000000 +drop table t1; +CREATE TABLE t1 ( +a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', +index idx(a) +); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707'); +SELECT hex(a) FROM t1 order by a; +hex(a) +1F9480179366F2BF567E1C4B964C1EF029080707 +1F9480179366F2BF567E1C4B964C1EF029082020 +1F9480179366F2BF567E1C4B964C1EF029087575 +EXPLAIN SELECT hex(a) FROM t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL idx 20 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`a`) AS `hex(a)` from `test`.`t1` order by `test`.`t1`.`a` +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +hex(a) +1F9480179366F2BF567E1C4B964C1EF029082020 +EXPLAIN +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx idx 20 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`a`) AS `hex(a)` from `test`.`t1` where (`test`.`t1`.`a` = (unhex('1F9480179366F2BF567E1C4B964C1EF029082020'))) +SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908'); +hex(a) +DROP TABLE t1; +CREATE TABLE t1 ( +id numeric(20) NOT NULL, +lang varchar(8) NOT NULL, +msg varchar(32) NOT NULL, +PRIMARY KEY (id,lang) +); +INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz'); +INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx'); +INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy'); +SELECT * FROM t1 WHERE id=32; +id lang msg +32 en yyyyyyy +DROP TABLE t1; diff --git a/mysql-test/r/case.result-pq b/mysql-test/r/case.result-pq new file mode 100644 index 000000000..ee30ab755 --- /dev/null +++ b/mysql-test/r/case.result-pq @@ -0,0 +1,481 @@ +drop table if exists t1, t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +select CASE "b" when "a" then 1 when "b" then 2 END; +CASE "b" when "a" then 1 when "b" then 2 END +2 +select CASE "c" when "a" then 1 when "b" then 2 END; +CASE "c" when "a" then 1 when "b" then 2 END +NULL +select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END; +CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END +3 +select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END; +CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END +ok +select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END; +CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END +ok +select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end; +CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end +a +select CASE when 1=0 then "true" else "false" END; +CASE when 1=0 then "true" else "false" END +false +select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END; +CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END +one +explain select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (case 1 when 1 then 'one' when 2 then 'two' else 'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END` +select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END; +CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END +two +select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0; +(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0 +2 +select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0; +(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0 +2.00 +select case 1/0 when "a" then "true" else "false" END; +case 1/0 when "a" then "true" else "false" END +false +select case 1/0 when "a" then "true" END; +case 1/0 when "a" then "true" END +NULL +select (case 1/0 when "a" then "true" END) | 0; +(case 1/0 when "a" then "true" END) | 0 +NULL +select (case 1/0 when "a" then "true" END) + 0.0; +(case 1/0 when "a" then "true" END) + 0.0 +NULL +select case when 1>0 then "TRUE" else "FALSE" END; +case when 1>0 then "TRUE" else "FALSE" END +TRUE +select case when 1<0 then "TRUE" else "FALSE" END; +case when 1<0 then "TRUE" else "FALSE" END +FALSE +create table t1 (a int); +insert into t1 values(1),(2),(3),(4); +select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase; +fcase count(*) +0 2 +2 1 +3 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end) AS `fcase`,count(0) AS `count(*)` from `test`.`t1` group by `fcase` +select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase; +fcase count(*) +nothing 2 +one 1 +two 1 +drop table t1; +create table t1 (`row` int not null, col int not null, val varchar(255) not null); +insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small'); +select max(case col when 1 then val else null end) as color from t1 group by `row`; +color +orange +yellow +green +drop table t1; +SET NAMES latin1; +CREATE TABLE t1 SELECT +CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1, +CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2, +CASE WHEN 1 THEN 'a' ELSE 1 END AS c3, +CASE WHEN 1 THEN 1 ELSE 'a' END AS c4, +CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, +CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, +CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, +CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, +CASE WHEN 1 THEN 1.0 END AS c9, +CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10, +CASE WHEN 1 THEN 0.1e1 else 1 END AS c11, +CASE WHEN 1 THEN 0.1e1 else '1' END AS c12 +; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '', + `c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '', + `c3` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c4` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c5` varchar(4) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c6` varchar(4) CHARACTER SET latin1 NOT NULL DEFAULT '', + `c7` decimal(2,1) NOT NULL DEFAULT '0.0', + `c8` decimal(2,1) NOT NULL DEFAULT '0.0', + `c9` decimal(2,1) DEFAULT NULL, + `c10` double NOT NULL DEFAULT '0', + `c11` double NOT NULL DEFAULT '0', + `c12` varchar(22) CHARACTER SET latin1 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SELECT CASE +WHEN 1 +THEN _latin1'a' COLLATE latin1_danish_ci +ELSE _latin1'a' COLLATE latin1_swedish_ci +END; +ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case' +SELECT CASE _latin1'a' COLLATE latin1_general_ci +WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1 +WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2 +END; +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case' +SELECT +CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END, +CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END, +CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END, +CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END +; +CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END +1 2 1 2 +CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'coalesce' +CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' +CREATE TABLE t1 SELECT +COALESCE(1), COALESCE(1.0),COALESCE('a'), +COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'), +COALESCE('a' COLLATE latin1_bin,'b'); +explain SELECT +COALESCE(1), COALESCE(1.0),COALESCE('a'), +COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'), +COALESCE('a' COLLATE latin1_bin,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce('a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,'1') AS `COALESCE(1,'1')`,coalesce(1.1,'1') AS `COALESCE(1.1,'1')`,coalesce(('a' collate latin1_bin),'b') AS `COALESCE('a' COLLATE latin1_bin,'b')` +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `COALESCE(1)` int NOT NULL DEFAULT '0', + `COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', + `COALESCE('a')` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', + `COALESCE(1,'1')` varchar(1) CHARACTER SET latin1 NOT NULL DEFAULT '', + `COALESCE(1.1,'1')` varchar(4) CHARACTER SET latin1 NOT NULL DEFAULT '', + `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'ifnull' +SELECT 'case+union+test' +UNION +SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; +case+union+test +case+union+test +nobug +SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END; +CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END +nobug +SELECT 'case+union+test' +UNION +SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; +case+union+test +case+union+test +nobug +create table t1(a float, b int default 3); +insert into t1 (a) values (2), (11), (8); +select min(a), min(case when 1=1 then a else NULL end), +min(case when 1!=1 then NULL else a end) +from t1 where b=3 group by b; +min(a) min(case when 1=1 then a else NULL end) min(case when 1!=1 then NULL else a end) +2 2 2 +drop table t1; +CREATE TABLE t1 (EMPNUM INT); +INSERT INTO t1 VALUES (0), (2); +CREATE TABLE t2 (EMPNUM DECIMAL (4, 2)); +INSERT INTO t2 VALUES (0.0), (9.0); +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM, +t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2 +FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM; +CEMPNUM EMPMUM1 EMPNUM2 +0.00 0 0.00 +2.00 2 NULL +SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM, +t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2 +FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM; +CEMPNUM EMPMUM1 EMPNUM2 +0.00 0 0.00 +2.00 2 NULL +DROP TABLE t1,t2; +End of 4.1 tests +create table t1 (a int, b bigint unsigned); +create table t2 (c int); +insert into t1 (a, b) values (1,4572794622775114594), (2,18196094287899841997), +(3,11120436154190595086); +insert into t2 (c) values (1), (2), (3); +select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1 +join t2 on t1.a=t2.c order by d; +a d +1 4572794622775114594 +3 11120436154190595086 +2 18196094287899841997 +select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1 +join t2 on t1.a=t2.c where b=11120436154190595086 order by d; +a d +3 11120436154190595086 +drop table t1, t2; +End of 5.0 tests +CREATE TABLE t1(a YEAR); +SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END; +1 +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#19875294 ASSERTION `SRC' FAILED IN MY_STRNXFRM_UNICODE +# (SIG 6 -STRINGS/CTYPE-UTF8.C:5151) +# +set @@sql_mode=''; +CREATE TABLE t1(c1 SET('','')CHARACTER SET ucs2) engine=innodb; +Warnings: +Note 1291 Column 'c1' has duplicated value '' in SET +INSERT INTO t1 VALUES(990101.102); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +SELECT COALESCE(c1)FROM t1 ORDER BY 1; +COALESCE(c1) + +DROP TABLE t1; +set @@sql_mode=default; +# Bug#24733658: IF and friends give wrong type for signed and unsigned +CREATE TABLE source(bt INTEGER, bf INTEGER, i8u BIGINT UNSIGNED, i8s BIGINT); +INSERT INTO source VALUES +(1,0,0,-9223372036854775808), (1,0,18446744073709551615,9223372036854775807); +CREATE TABLE target +SELECT IF(bt,i8u,i8s) AS u, IF(bf,i8u,i8s) AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT IF(bt,i8u,i8s) AS u, IF(bf,i8u,i8s) AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE target; +CREATE TABLE target +SELECT CASE WHEN bt THEN i8u ELSE i8s END AS u, +CASE WHEN bf THEN i8u ELSE i8s END AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT CASE WHEN bt THEN i8u ELSE i8s END AS u, +CASE WHEN bf THEN i8u ELSE i8s END AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE target; +CREATE TABLE target +SELECT CASE bt WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS u, +CASE bf WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT CASE bt WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS u, +CASE bf WHEN TRUE THEN i8u WHEN FALSE THEN i8s END AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE target; +CREATE TABLE target +SELECT COALESCE(i8u, i8s) AS u, COALESCE(i8s, i8u) AS s +FROM source; +SHOW CREATE TABLE target; +Table Create Table +target CREATE TABLE `target` ( + `u` decimal(20,0) DEFAULT NULL, + `s` decimal(20,0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT COALESCE(i8u, i8s) AS u, COALESCE(i8s, i8u) AS s +FROM source; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +SELECT * FROM target; +u s +0 -9223372036854775808 +18446744073709551615 9223372036854775807 +DROP TABLE source, target; +# Bug#25139420: BIT(n) data type confused when used with IF, IFNULL +CREATE TABLE t (a bit(5)); +INSERT INTO t VALUES +(0),(1),(2),(3),(4),(5),(6),(7),(8),(9), +(10),(11),(12),(19),(20),(21),(29),(30),(31); +SELECT HEX(a), +IFNULL(a,a) AS b, +IFNULL(a,a)+0 AS c, +IFNULL(a+0,a+0) AS d, +IFNULL(a+0,a) AS e, +IFNULL(a,a+0) AS f +FROM t; +HEX(a) b c d e f +0 0 0 0 0 0 +1 1 1 1 1 1 +2 2 2 2 2 2 +3 3 3 3 3 3 +4 4 4 4 4 4 +5 5 5 5 5 5 +6 6 6 6 6 6 +7 7 7 7 7 7 +8 8 8 8 8 8 +9 9 9 9 9 9 +A 10 10 10 10 10 +B 11 11 11 11 11 +C 12 12 12 12 12 +13 19 19 19 19 19 +14 20 20 20 20 20 +15 21 21 21 21 21 +1D 29 29 29 29 29 +1E 30 30 30 30 30 +1F 31 31 31 31 31 +CREATE TABLE u AS SELECT HEX(a), +IFNULL(a,a) AS b, +IFNULL(a,a)+0 AS c, +IFNULL(a+0,a+0) AS d, +IFNULL(a+0,a) AS e, +IFNULL(a,a+0) AS f +FROM t; +SHOW CREATE TABLE u; +Table Create Table +u CREATE TABLE `u` ( + `HEX(a)` varchar(10) CHARACTER SET latin1 DEFAULT NULL, + `b` bit(5) DEFAULT NULL, + `c` int unsigned DEFAULT NULL, + `d` bigint unsigned DEFAULT NULL, + `e` bigint unsigned DEFAULT NULL, + `f` bigint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t, u; +# Bug#26389402: Outer join optimized away with user-defined functions +CREATE TABLE t00(a INTEGER); +INSERT INTO t00 VALUES (1),(2); +CREATE TABLE t01(a INTEGER); +INSERT INTO t01 VALUES (1); +CREATE VIEW v0 AS +SELECT t00.a, t01.a AS b, IFNULL(t01.a, 666) AS c +FROM t00 LEFT JOIN t01 USING(a); +SELECT * FROM v0 +WHERE c >= 0; +a b c +1 1 1 +2 NULL 666 +CREATE FUNCTION f(a INTEGER) RETURNS INTEGER DETERMINISTIC +RETURN IFNULL(a, 666); +CREATE VIEW v1 AS +SELECT t00.a, t01.a AS b, f(t01.a) AS c +FROM t00 LEFT JOIN t01 USING(a); +SELECT * FROM v1 +WHERE c >= 0; +a b c +1 1 1 +2 NULL 666 +CREATE VIEW v2 AS +SELECT t00.a, t01.a AS b, f(IFNULL(t01.a, NULL)) AS c +FROM t00 LEFT JOIN t01 USING(a); +SELECT * FROM v2 +WHERE c >= 0; +a b c +1 1 1 +2 NULL 666 +SELECT t00.a, t01.a AS b, f(t01.a) AS c +FROM t00 LEFT JOIN t01 USING(a) +WHERE f(t01.a) >= 0; +a b c +1 1 1 +2 NULL 666 +DROP FUNCTION f; +DROP VIEW v0, v1, v2; +DROP TABLE t00, t01; +# +# Bug #25051195 Wrong calculation of decimals after point for IFNULL w/ GROUP BY using +# temporary table. +CREATE TABLE t (i1 INT, +d1 DOUBLE, +e2 DECIMAL(5,2)); +INSERT INTO t VALUES ( 6, 6.0, 10.0/3), +( null, 9.0, 10.0/3), +( 1, null, 10.0/3), +( 2, 2.0, null ); +Warnings: +Note 1265 Data truncated for column 'e2' at row 1 +Note 1265 Data truncated for column 'e2' at row 2 +Note 1265 Data truncated for column 'e2' at row 3 +IFNULL and IF should yield same number for decimals after point here +SELECT IFNULL(e2,i1) nullif_c, +IF(e2 IS NULL,i1,e2) if_c, +SUM(d1) FROM t +GROUP BY e2,i1 ORDER BY nullif_c, SUM(d1); +nullif_c if_c SUM(d1) +2.00 2.00 2 +3.33 3.33 NULL +3.33 3.33 6 +3.33 3.33 9 +DROP TABLE t; +# Bug#29463760 In cases like ifnull(datetime(2), time(3), wrong answer +SET TIMESTAMP=UNIX_TIMESTAMP('2019-03-11 12:00:00'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT CONCAT(IFNULL(t3, d)) AS col1 FROM t1; +col1 +2019-03-11 00:00:00.567 +SELECT CONCAT(IFNULL(t3, d)) AS col1 FROM t1 GROUP BY col1; +col1 +2019-03-11 00:00:00.567 +SET TIMESTAMP=DEFAULT; +DROP TABLE t1; +# +# Test for a memory leak in WL#6570 +# +CREATE TABLE t1 (a VARCHAR(110)); +INSERT INTO t1 VALUES (REPEAT("a",100)); +SELECT (t1.a,t1.a) IN (('a','c'),('a','b')) END FROM t1; +END +0 +SELECT CASE t1.a WHEN 'a' THEN 'c' ELSE 'd' END FROM t1; +CASE t1.a WHEN 'a' THEN 'c' ELSE 'd' END +d +DROP TABLE t1; +# +# Bug#32591239: VAL_JSON(JSON_WRAPPER*):ASSERTION +# `!CURRENT_THD->IS_ERROR() && HAS_VALUE' FAILED +# +CREATE TABLE t1 (col_int int, col_double double, j json); +INSERT INTO t1 VALUES (382218415, -36452.389, '{"key1": 220655528}'); +SELECT col_int FROM t1 +WHERE CASE WHEN POWER(col_double, col_int) THEN j ELSE j END; +ERROR 22003: DOUBLE value is out of range in 'pow(`test`.`t1`.`col_double`,`test`.`t1`.`col_int`)' +DROP TABLE t1; diff --git a/mysql-test/r/cast.result-pq b/mysql-test/r/cast.result-pq new file mode 100644 index 000000000..9cd26bb28 --- /dev/null +++ b/mysql-test/r/cast.result-pq @@ -0,0 +1,2300 @@ +select CAST(1-2 AS UNSIGNED); +CAST(1-2 AS UNSIGNED) +18446744073709551615 +select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER); +CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER) +-1 +select CAST('10 ' as unsigned integer); +CAST('10 ' as unsigned integer) +10 +select CAST('10x' as unsigned integer); +CAST('10x' as unsigned integer) +10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10x' +select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1; +cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1 +18446744073709551611 18446744073709551611 +select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1; +cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1 +18446744073709551610 18446744073709551612 +select ~5, cast(~5 as signed); +~5 cast(~5 as signed) +18446744073709551610 -6 +explain select ~5, cast(~5 as signed); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)` +select cast(5 as unsigned) -6.0; +cast(5 as unsigned) -6.0 +-1.0 +select cast(NULL as signed), cast(1/0 as signed); +cast(NULL as signed) cast(1/0 as signed) +NULL NULL +Warnings: +Warning 1365 Division by 0 +select cast(NULL as unsigned), cast(1/0 as unsigned); +cast(NULL as unsigned) cast(1/0 as unsigned) +NULL NULL +Warnings: +Warning 1365 Division by 0 +select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A"; +cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A" +0 1 +select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME); +cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME) +2001-01-01 2001-01-01 00:00:00 +select cast("1:2:3" as TIME); +cast("1:2:3" as TIME) +01:02:03 +select CONVERT("2004-01-22 21:45:33",DATE); +CONVERT("2004-01-22 21:45:33",DATE) +2004-01-22 +select 10+'10'; +10+'10' +20 +select 10.0+'10'; +10.0+'10' +20 +select 10E+0+'10'; +10E+0+'10' +20 +SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33" USING latin1); +CONVERT(TIMESTAMP "2004-01-22 21:45:33" USING latin1) +2004-01-22 21:45:33 +SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR); +CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR) +2004-01-22 21:45:33 +SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR(4)); +CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR(4)) +2004 +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33' +SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33", BINARY(4)); +CONVERT(TIMESTAMP "2004-01-22 21:45:33", BINARY(4)) +2004 +Warnings: +Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33' +select CAST(TIMESTAMP "2004-01-22 21:45:33" AS BINARY(4)); +CAST(TIMESTAMP "2004-01-22 21:45:33" AS BINARY(4)) +2004 +Warnings: +Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33' +select CAST(0xb3 as signed); +CAST(0xb3 as signed) +179 +select CAST(0x8fffffffffffffff as signed); +CAST(0x8fffffffffffffff as signed) +-8070450532247928833 +select CAST(0xffffffffffffffff as unsigned); +CAST(0xffffffffffffffff as unsigned) +18446744073709551615 +select CAST(0xfffffffffffffffe as signed); +CAST(0xfffffffffffffffe as signed) +-2 +select cast('-10a' as signed integer); +cast('-10a' as signed integer) +-10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '-10a' +select cast('a10' as unsigned integer); +cast('a10' as unsigned integer) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a10' +select 10+'a'; +10+'a' +10 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +select 10.0+cast('a' as decimal); +10.0+cast('a' as decimal) +10.0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'a' +select 10E+0+'a'; +10E+0+'a' +10 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +select cast('18446744073709551616' as unsigned); +cast('18446744073709551616' as unsigned) +18446744073709551615 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616' +select cast('18446744073709551616' as signed); +cast('18446744073709551616' as signed) +-1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616' +select cast('9223372036854775809' as signed); +cast('9223372036854775809' as signed) +-9223372036854775807 +Warnings: +Warning 1105 Cast to signed converted positive out-of-range integer to its negative complement +select cast('-1' as unsigned); +cast('-1' as unsigned) +18446744073709551615 +Warnings: +Warning 1105 Cast to unsigned converted negative integer to its positive complement +select cast('abc' as signed); +cast('abc' as signed) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'abc' +select cast('1a' as signed); +cast('1a' as signed) +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '1a' +select cast('' as signed); +cast('' as signed) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +set names binary; +select cast(_latin1'test' as char character set latin2); +cast(_latin1'test' as char character set latin2) +test +select cast(_koi8r'' as char character set cp1251); +cast(_koi8r'' as char character set cp1251) + +create table t1 select cast(_koi8r'' as char character set cp1251) as t; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +cast(_latin1'ab' AS char) as c1, +cast(_latin1'a ' AS char) as c2, +cast(_latin1'abc' AS char(2)) as c3, +cast(_latin1'a ' AS char(2)) as c4, +hex(cast(_latin1'a' AS char(2))) as c5; +c1 c2 c3 c4 c5 +ab a ab a 6100 +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'abc' +Warning 1292 Truncated incorrect BINARY(2) value: 'a ' +select cast(1000 as CHAR(3)); +cast(1000 as CHAR(3)) +100 +Warnings: +Warning 1292 Truncated incorrect BINARY(3) value: '1000' +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 select +cast(_latin1'ab' AS char) as c1, +cast(_latin1'a ' AS char) as c2, +cast(_latin1'abc' AS char(2)) as c3, +cast(_latin1'a ' AS char(2)) as c4, +cast(_latin1'a' AS char(2)) as c5; +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'abc' +Warning 1292 Truncated incorrect BINARY(2) value: 'a ' +select c1,c2,c3,c4,hex(c5) from t1; +c1 c2 c3 c4 hex(c5) +ab a ab a 6100 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '', + `c2` varbinary(2) NOT NULL DEFAULT '', + `c3` varbinary(2) NOT NULL DEFAULT '', + `c4` varbinary(2) NOT NULL DEFAULT '', + `c5` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +cast(_koi8r'' AS nchar) as c1, +cast(_koi8r' ' AS nchar) as c2, +cast(_koi8r'' AS nchar(2)) as c3, +cast(_koi8r' ' AS nchar(2)) as c4, +cast(_koi8r'' AS nchar(2)) as c5; +c1 c2 c3 c4 c5 +фг ф фг ф ф +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 1292 Truncated incorrect CHAR(4) value: 'фгх' +Warning 1292 Truncated incorrect CHAR(3) value: 'ф ' +create table t1 select +cast(_koi8r'' AS nchar) as c1, +cast(_koi8r' ' AS nchar) as c2, +cast(_koi8r'' AS nchar(2)) as c3, +cast(_koi8r' ' AS nchar(2)) as c4, +cast(_koi8r'' AS nchar(2)) as c5; +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 1292 Truncated incorrect CHAR(4) value: 'фгх' +Warning 1292 Truncated incorrect CHAR(3) value: 'ф ' +select * from t1; +c1 c2 c3 c4 c5 +фг ф фг ф ф +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c2` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c3` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c4` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c5` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +# +# Bug #24934161: FAILURE OF SYNONYMY OF NCHAR AND NATIONAL CHAR +# +SELECT +CAST(_gb2312 x'CAFDBEDD' AS NATIONAL CHAR) AS c1, +CAST(_gb2312 x'CAFD20' AS NATIONAL CHAR) AS c2, +CAST(_gb2312 x'CAFDBEDDBFE2' AS NATIONAL CHAR(2)) AS c3, +CAST(_gb2312 x'CAFD2020' AS NATIONAL CHAR(2)) AS c4, +CAST(_gb2312 x'CAFD' AS NATIONAL CHAR(2)) AS c5; +c1 c2 c3 c4 c5 +数据 数 数据 数 数 +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 1292 Truncated incorrect CHAR(6) value: '数据库' +Warning 1292 Truncated incorrect CHAR(4) value: '数 ' +CREATE TABLE t1 SELECT +CAST(_gb2312 x'CAFDBEDD' AS NATIONAL CHAR) AS c1, +CAST(_gb2312 x'CAFD20' AS NATIONAL CHAR) AS c2, +CAST(_gb2312 x'CAFDBEDDBFE2' AS NATIONAL CHAR(2)) AS c3, +CAST(_gb2312 x'CAFD2020' AS NATIONAL CHAR(2)) AS c4, +CAST(_gb2312 x'CAFD' AS NATIONAL CHAR(2)) AS c5; +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 1292 Truncated incorrect CHAR(6) value: '数据库' +Warning 1292 Truncated incorrect CHAR(4) value: '数 ' +SELECT * FROM t1; +c1 c2 c3 c4 c5 +数据 数 数据 数 数 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c2` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c3` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c4` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '', + `c5` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SET sql_mode = default; +create table t1 (a binary(4), b char(4) character set koi8r); +insert into t1 values (_binary'',_binary''); +select a,b,cast(a as char character set cp1251),cast(b as binary) from t1; +a b cast(a as char character set cp1251) cast(b as binary) + +set names koi8r; +select a,b,cast(a as char character set cp1251),cast(b as binary) from t1; +a b cast(a as char character set cp1251) cast(b as binary) + +set names cp1251; +select a,b,cast(a as char character set cp1251),cast(b as binary) from t1; +a b cast(a as char character set cp1251) cast(b as binary) + +drop table t1; +set names binary; +select cast("2001-1-1" as date) = "2001-01-01"; +cast("2001-1-1" as date) = "2001-01-01" +1 +select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"; +cast("2001-1-1" as datetime) = "2001-01-01 00:00:00" +1 +select cast("1:2:3" as TIME) = "1:02:03"; +cast("1:2:3" as TIME) = "1:02:03" +0 +select cast(NULL as DATE); +cast(NULL as DATE) +NULL +select cast(NULL as BINARY); +cast(NULL as BINARY) +NULL +CREATE TABLE t1 (a enum ('aac','aab','aaa') not null); +INSERT INTO t1 VALUES ('aaa'),('aab'),('aac'); +SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ; +a CAST(a AS CHAR) +aac aac +aab aab +aaa aaa +SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; +a CAST(a AS CHAR(3)) +aac aac +aab aab +aaa aaa +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'aaa' +Warning 1292 Truncated incorrect BINARY(2) value: 'aab' +Warning 1292 Truncated incorrect BINARY(2) value: 'aac' +Warning 1292 Truncated incorrect BINARY(2) value: 'aac' +Warning 1292 Truncated incorrect BINARY(2) value: 'aab' +Warning 1292 Truncated incorrect BINARY(2) value: 'aaa' +SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ; +a CAST(a AS UNSIGNED) +aaa 3 +aab 2 +aac 1 +SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a; +a CAST(a AS CHAR(2)) +aaa aa +aab aa +aac aa +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'aaa' +Warning 1292 Truncated incorrect BINARY(2) value: 'aab' +Warning 1292 Truncated incorrect BINARY(2) value: 'aac' +DROP TABLE t1; +select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour); +date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour) +2004-12-30 00:00:00 +select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00'); +timediff(cast('2004-12-30 12:00:00' as time), '12:00:00') +00:00:00 +select timediff(cast('1 12:00:00' as time), '12:00:00'); +timediff(cast('1 12:00:00' as time), '12:00:00') +24:00:00 +select cast(18446744073709551615 as unsigned); +cast(18446744073709551615 as unsigned) +18446744073709551615 +select cast(18446744073709551615 as signed); +cast(18446744073709551615 as signed) +-1 +select cast('18446744073709551615' as unsigned); +cast('18446744073709551615' as unsigned) +18446744073709551615 +select cast('18446744073709551615' as signed); +cast('18446744073709551615' as signed) +-1 +Warnings: +Warning 1105 Cast to signed converted positive out-of-range integer to its negative complement +select cast('9223372036854775807' as signed); +cast('9223372036854775807' as signed) +9223372036854775807 +select cast(concat('184467440','73709551615') as unsigned); +cast(concat('184467440','73709551615') as unsigned) +18446744073709551615 +select cast(concat('184467440','73709551615') as signed); +cast(concat('184467440','73709551615') as signed) +-1 +Warnings: +Warning 1105 Cast to signed converted positive out-of-range integer to its negative complement +select cast(repeat('1',20) as unsigned); +cast(repeat('1',20) as unsigned) +11111111111111111111 +select cast(repeat('1',20) as signed); +cast(repeat('1',20) as signed) +-7335632962598440505 +Warnings: +Warning 1105 Cast to signed converted positive out-of-range integer to its negative complement +select cast(1.0e+300 as signed int); +cast(1.0e+300 as signed int) +9223372036854775807 +CREATE TABLE t1 (f1 double); +INSERT INTO t1 SET f1 = -1.0e+30 ; +INSERT INTO t1 SET f1 = +1.0e+30 ; +SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; +double_val cast_val +-1e30 -9223372036854775808 +1e30 9223372036854775807 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '-1e30' +Warning 1292 Truncated incorrect INTEGER value: '1e30' +DROP TABLE t1; +select isnull(date(NULL)), isnull(cast(NULL as DATE)); +isnull(date(NULL)) isnull(cast(NULL as DATE)) +1 1 +SELECT CAST(cast('01-01-01' as date) AS UNSIGNED); +CAST(cast('01-01-01' as date) AS UNSIGNED) +20010101 +SELECT CAST(cast('01-01-01' as date) AS SIGNED); +CAST(cast('01-01-01' as date) AS SIGNED) +20010101 +End of 4.1 tests +select cast('1.2' as decimal(3,2)); +cast('1.2' as decimal(3,2)) +1.20 +select 1e18 * cast('1.2' as decimal(3,2)); +1e18 * cast('1.2' as decimal(3,2)) +1.2e18 +select cast(cast('1.2' as decimal(3,2)) as signed); +cast(cast('1.2' as decimal(3,2)) as signed) +1 +set @v1=1e18; +select cast(@v1 as decimal(22, 2)); +cast(@v1 as decimal(22, 2)) +1000000000000000000.00 +select cast(-1e18 as decimal(22,2)); +cast(-1e18 as decimal(22,2)) +-1000000000000000000.00 +create table t1(s1 time); +insert into t1 values ('11:11:11'); +select cast(s1 as decimal(7,2)) from t1; +cast(s1 as decimal(7,2)) +99999.99 +Warnings: +Warning 1264 Out of range value for column 'cast(s1 as decimal(7,2))' at row 1 +drop table t1; +CREATE TABLE t1 (v varchar(10), tt tinytext, t text, +mt mediumtext, lt longtext); +INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05'); +SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL), +CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1; +CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS DECIMAL) +1 2 3 4 5 +DROP TABLE t1; +select cast(NULL as decimal(6)) as t1; +t1 +NULL +set names latin1; +select hex(cast('a' as char(2) binary)); +hex(cast('a' as char(2) binary)) +61 +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +select hex(cast('a' as binary(2))); +hex(cast('a' as binary(2))) +6100 +select hex(cast('a' as char(2) binary)); +hex(cast('a' as char(2) binary)) +61 +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +CREATE TABLE t1 (d1 datetime); +INSERT INTO t1(d1) VALUES ('2007-07-19 08:30:00'), (NULL), +('2007-07-19 08:34:00'), (NULL), ('2007-07-19 08:36:00'); +SELECT cast(date(d1) as signed) FROM t1; +cast(date(d1) as signed) +20070719 +NULL +20070719 +NULL +20070719 +drop table t1; +CREATE TABLE t1 (f1 DATE); +INSERT INTO t1 VALUES ('2007-07-19'), (NULL); +SELECT HOUR(f1), +MINUTE(f1), +SECOND(f1) FROM t1; +HOUR(f1) MINUTE(f1) SECOND(f1) +0 0 0 +NULL NULL NULL +SELECT HOUR(CAST('2007-07-19' AS DATE)), +MINUTE(CAST('2007-07-19' AS DATE)), +SECOND(CAST('2007-07-19' AS DATE)); +HOUR(CAST('2007-07-19' AS DATE)) MINUTE(CAST('2007-07-19' AS DATE)) SECOND(CAST('2007-07-19' AS DATE)) +0 0 0 +SELECT HOUR(CAST(NULL AS DATE)), +MINUTE(CAST(NULL AS DATE)), +SECOND(CAST(NULL AS DATE)); +HOUR(CAST(NULL AS DATE)) MINUTE(CAST(NULL AS DATE)) SECOND(CAST(NULL AS DATE)) +NULL NULL NULL +SELECT HOUR(NULL), +MINUTE(NULL), +SECOND(NULL); +HOUR(NULL) MINUTE(NULL) SECOND(NULL) +NULL NULL NULL +DROP TABLE t1; +End of 5.0 tests +# +# Bug #44766: valgrind error when using convert() in a subquery +# +CREATE TABLE t1(a tinyint); +INSERT INTO t1 VALUES (127); +SELECT 1 FROM +( +SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1 +) AS s LIMIT 1; +1 +1 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +DROP TABLE t1; +# +# Bug #11765023: 57934: DOS POSSIBLE SINCE BINARY CASTING +# DOESN'T ADHERE TO MAX_ALLOWED_PACKET +SET @@GLOBAL.max_allowed_packet=2048; +Warnings: +Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length' +SELECT CONVERT('a', BINARY(2049)); +CONVERT('a', BINARY(2049)) +NULL +Warnings: +Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (2048) - truncated +SELECT CONVERT('a', CHAR(2049)); +CONVERT('a', CHAR(2049)) +NULL +Warnings: +Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated +SET @@GLOBAL.max_allowed_packet=default; +# +# Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET) +# +CREATE TABLE t1 (a VARCHAR(50)); +SELECT a FROM t1 +WHERE CAST(a as BINARY)=x'62736D697468' +AND CAST(a AS BINARY)=x'65736D697468'; +a +DROP TABLE t1; +End of 5.1 tests +# +# Bug#22885819: CAST( .. AS BINARY(N)) GETS UNEXPECTED NULL +# +SELECT CAST( 'a' AS BINARY(429496729)); +CAST( 'a' AS BINARY(429496729)) +NULL +Warnings: +Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated +SELECT CAST( 'a' AS BINARY(4294967294)); +CAST( 'a' AS BINARY(4294967294)) +NULL +Warnings: +Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated +SELECT CAST( 'a' AS BINARY(4294967295)); +CAST( 'a' AS BINARY(4294967295)) +NULL +Warnings: +Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated +SELECT CAST( 'a' AS BINARY(4294967296)); +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295) +SELECT CAST( 'a' AS BINARY(4294967296784564)); +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295) +# +# Bug#13581962 HIGH MEMORY USAGE ATTEMPT, THEN CRASH WITH LONGTEXT, UNION, USER VARIABLE +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 AS SELECT CONCAT(CAST(REPEAT('9', 1000) AS SIGNED)), +CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED)); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999' +Warning 1292 Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CONCAT(CAST(REPEAT('9', 1000) AS SIGNED))` varchar(21) CHARACTER SET latin1 NOT NULL DEFAULT '', + `CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED))` varchar(21) CHARACTER SET latin1 NOT NULL DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SET sql_mode = default; +End of 5.5 tests +# +# Bug#28547906 ENUM TYPE CASTING WORKS WRONG WITH SUBQUERIES +# +CREATE TABLE t (c1 ENUM('a','b','c')); +INSERT INTO t VALUES ('a'), ('b'), ('c'); +SELECT CAST(c1 AS UNSIGNED) AS c5 FROM t; +c5 +1 +2 +3 +SELECT CAST(c1 AS UNSIGNED) AS c5 FROM (SELECT c1 FROM t) t; +c5 +1 +2 +3 +DROP TABLE t; +# +# CAST as DOUBLE/FLOAT/REAL +# +SELECT CAST(1/3 AS FLOAT) as float_col, +CAST(1/3 AS DOUBLE) as double_col, +CAST(1/3 AS DOUBLE PRECISION) as double_prec_col, +CAST(1/3 AS REAL) as real_col; +float_col double_col double_prec_col real_col +0.333333 0.333333333 0.333333333 0.333333333 +SELECT CAST(1/3 AS FLOAT(10)), CAST(1/3 AS FLOAT(53)); +CAST(1/3 AS FLOAT(10)) CAST(1/3 AS FLOAT(53)) +0.333333 0.333333333 +SELECT CAST(1/3 AS FLOAT(-1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1 +SELECT CAST(1/3 AS FLOAT(54)); +ERROR 42000: Too-big precision 54 specified for 'CAST'. Maximum is 53. +SELECT CAST(1/3 AS DOUBLE(52)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(52))' at line 1 +SELECT CAST(1/3 AS REAL(34)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(34))' at line 1 +SELECT CAST(999.00009 AS FLOAT(7,4)) as float_col; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',4)) as float_col' at line 1 +SELECT CAST(999.00009 AS DOUBLE(7,4)) as double_col; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(7,4)) as double_col' at line 1 +SELECT CAST(999.00009 AS REAL(7,4)) as real_col; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(7,4)) as real_col' at line 1 +SELECT ADDDATE(CAST("20010101235959.9" AS DOUBLE), INTERVAL 1 DAY); +ADDDATE(CAST("20010101235959.9" AS DOUBLE), INTERVAL 1 DAY) +2001-01-02 23:59:59.898438 +SELECT TIMEDIFF(CAST("101112" AS DOUBLE), TIME'101010'); +TIMEDIFF(CAST("101112" AS DOUBLE), TIME'101010') +00:01:02.000000 +SELECT CAST(DATE'2000-01-01' AS FLOAT), CAST(DATE'2000-01-01' AS DOUBLE); +CAST(DATE'2000-01-01' AS FLOAT) CAST(DATE'2000-01-01' AS DOUBLE) +20000100 20000101 +SELECT CAST(TIME'23:59:59' AS FLOAT), CAST(TIME'23:59:59' AS DOUBLE); +CAST(TIME'23:59:59' AS FLOAT) CAST(TIME'23:59:59' AS DOUBLE) +235959 235959 +SELECT CAST(TIME'23:59:59.123456' AS FLOAT), +CAST(TIME'23:59:59.123456' AS DOUBLE); +CAST(TIME'23:59:59.123456' AS FLOAT) CAST(TIME'23:59:59.123456' AS DOUBLE) +235959 235959.123456 +SELECT CAST(TIMESTAMP'2000-01-01 23:59:59' AS FLOAT), +CAST(TIMESTAMP'2000-01-01 23:59:59' AS DOUBLE); +CAST(TIMESTAMP'2000-01-01 23:59:59' AS FLOAT) CAST(TIMESTAMP'2000-01-01 23:59:59' AS DOUBLE) +20000100000000 20000101235959 +SELECT CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS FLOAT), +CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS DOUBLE); +CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS FLOAT) CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS DOUBLE) +20000100000000 20000101235959.125 +CREATE TABLE t1 as SELECT CAST(1/3 AS FLOAT) as float_col, +CAST(1/3 AS DOUBLE) as double_col, +CAST(CAST(999.00009 AS DECIMAL(7,4)) AS DOUBLE) as d2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `float_col` float DEFAULT NULL, + `double_col` double DEFAULT NULL, + `d2` double NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SELECT PERIOD_ADD(200905, CAST(3.14e19 AS DOUBLE)); +ERROR 22003: BIGINT value is out of range in 'cast(3.14e19 as double)' +SELECT -1.0 * CAST(3.14e19 AS DOUBLE); +-1.0 * CAST(3.14e19 AS DOUBLE) +-3.14e19 +SELECT CAST("3.14e100" AS FLOAT); +ERROR 22003: DOUBLE value is out of range in 'cast('3.14e100' as float)' +SELECT CAST(-1e308 as FLOAT); +ERROR 22003: DOUBLE value is out of range in 'cast(-(1e308) as float)' +SELECT CONCAT("value=", CAST("3.4e5" AS FLOAT)); +CONCAT("value=", CAST("3.4e5" AS FLOAT)) +value=340000 +CREATE VIEW v1 AS SELECT CAST(1/3 AS REAL), CAST(1/3 AS FLOAT(2)), CAST(1/3 AS FLOAT(50)); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast((1 / 3) as double) AS `CAST(1/3 AS REAL)`,cast((1 / 3) as float) AS `CAST(1/3 AS FLOAT(2))`,cast((1 / 3) as double) AS `CAST(1/3 AS FLOAT(50))` latin1 latin1_swedish_ci +DROP VIEW v1; +SELECT CAST(NULL AS REAL), CAST(NULL AS FLOAT), CAST(NULL AS DOUBLE); +CAST(NULL AS REAL) CAST(NULL AS FLOAT) CAST(NULL AS DOUBLE) +NULL NULL NULL +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=REAL_AS_FLOAT; +CREATE TABLE t AS SELECT CAST(34 AS REAL); +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `CAST(34 AS REAL)` float NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t; +SET @@SQL_MODE=@OLD_SQL_MODE; +CREATE TABLE t AS SELECT CAST(34 AS REAL); +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `CAST(34 AS REAL)` double NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t; +SELECT MAKETIME(1, 2, CAST("1.6" AS FLOAT)); +MAKETIME(1, 2, CAST("1.6" AS FLOAT)) +01:02:01.600000 +# +# WL#12108: Inject type cast nodes into the item tree to avoid data +# type mismatches. +# +CREATE TABLE dt_t (dt DATETIME, d DATE, t TIME); +CREATE TABLE n_t (i INT, d DECIMAL, f FLOAT, dc DECIMAL); +# +# DATETIME + NUMERICS +# +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.dt = n_t.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`dt` as double) = cast(`test`.`n_t`.`i` as double)) +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.dt = n_t.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`dt` as double) = cast(`test`.`n_t`.`d` as double)) +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.dt = n_t.f; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`dt` as double) = `test`.`n_t`.`f`) +# +# DATE + NUMERICS +# +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.d = n_t.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = cast(`test`.`n_t`.`i` as double)) +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.d = n_t.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = cast(`test`.`n_t`.`d` as double)) +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.d = n_t.f; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = `test`.`n_t`.`f`) +EXPLAIN SELECT * from dt_t JOIN n_t on dt_t.d = n_t.dc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = cast(`test`.`n_t`.`dc` as double)) +# +# TIME + NUMERICS +# +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.t = n_t.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`t` as double) = cast(`test`.`n_t`.`i` as double)) +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.t = n_t.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`t` as double) = cast(`test`.`n_t`.`d` as double)) +EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.t = n_t.f; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`t` as double) = `test`.`n_t`.`f`) +# +# DATETIME + DATE +# +EXPLAIN SELECT * from dt_t dt1 JOIN dt_t dt2 ON dt1.dt = dt2.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE dt2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (`test`.`dt1`.`dt` = cast(`test`.`dt2`.`d` as datetime)) +# +# DATETIME + TIME +# +EXPLAIN SELECT * from dt_t dt1 JOIN dt_t dt2 ON dt1.dt = dt2.t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE dt2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (`test`.`dt1`.`dt` = cast(`test`.`dt2`.`t` as datetime)) +# +# DATE + TIME +# +EXPLAIN SELECT * from dt_t dt1 JOIN dt_t dt2 ON dt1.d = dt2.t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE dt2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (cast(`test`.`dt1`.`d` as datetime) = cast(`test`.`dt2`.`t` as datetime)) +EXPLAIN SELECT * FROM dt_t dt1 JOIN dt_t dt2 ON dt1.d = dt2.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE dt2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (`test`.`dt2`.`d` = `test`.`dt1`.`d`) +EXPLAIN SELECT dt_t.dt = n_t.i from dt_t, n_t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`dt_t`.`dt` as double) = cast(`test`.`n_t`.`i` as double)) AS `dt_t.dt = n_t.i` from `test`.`dt_t` join `test`.`n_t` +EXPLAIN SELECT MAX(dt_t.d) AS max_d, MAX(n_t.i) AS max_i +FROM dt_t, n_t HAVING max_d = max_i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE n_t NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`dt_t`.`d`) AS `max_d`,max(`test`.`n_t`.`i`) AS `max_i` from `test`.`dt_t` join `test`.`n_t` having (cast(`max_d` as double) = cast(`max_i` as double)) +EXPLAIN SELECT dt=d from dt_t ORDER BY dt = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select (`test`.`dt_t`.`dt` = cast(`test`.`dt_t`.`d` as datetime)) AS `dt=d` from `test`.`dt_t` order by `dt=d` +EXPLAIN SELECT * from dt_t ORDER BY dt = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t` from `test`.`dt_t` order by `(dt_t.dt = cast(dt_t.d as datetime))` +EXPLAIN SELECT d=t, LEAD(d,1) OVER w FROM dt_t WINDOW w AS (ORDER BY d=t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select (cast(`test`.`dt_t`.`d` as datetime) = cast(`test`.`dt_t`.`t` as datetime)) AS `d=t`,lead(`test`.`dt_t`.`d`,1) OVER `w` AS `LEAD(d,1) OVER w` from `test`.`dt_t` window `w` AS (ORDER BY (cast(`test`.`dt_t`.`d` as datetime) = cast(`test`.`dt_t`.`t` as datetime)) ) +EXPLAIN SELECT LEAD(d,1) OVER w FROM dt_t WINDOW w AS (ORDER BY d=t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dt_t NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select lead(`test`.`dt_t`.`d`,1) OVER `w` AS `LEAD(d,1) OVER w` from `test`.`dt_t` window `w` AS (ORDER BY (cast(`test`.`dt_t`.`d` as datetime) = cast(`test`.`dt_t`.`t` as datetime)) ) +DROP TABLE dt_t, n_t; +CREATE TABLE t1 (spID int, userID int, date date); +INSERT INTO t1 VALUES (1,1,'1998-01-01'); +INSERT INTO t1 VALUES (2,2,'2001-02-03'); +INSERT INTO t1 VALUES (3,1,'1988-12-20'); +INSERT INTO t1 VALUES (4,2,'1972-12-12'); +EXPLAIN SELECT MIN(t1.userID) = MIN(date) FROM t1 GROUP BY userid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select (cast(min(`min(t1.userID)`) as double) = cast(min(`min(t1.``date``)`) as double)) AS `MIN(t1.userID) = MIN(date)` from `test`.`t1` group by `test`.`t1`.`userID` +EXPLAIN SELECT FIRST_VALUE(date) OVER (ORDER BY spID = date) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select first_value(`test`.`t1`.`date`) OVER (ORDER BY (cast(`test`.`t1`.`spID` as double) = cast(`test`.`t1`.`date` as double)) ) AS `FIRST_VALUE(date) OVER (ORDER BY spID = date)` from `test`.`t1` +EXPLAIN SELECT date, spid = FIRST_VALUE(date) OVER (ORDER BY date ) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `test`.`t1`.`date` AS `date`,(cast(`test`.`t1`.`spID` as double) = cast(first_value(`test`.`t1`.`date`) OVER (ORDER BY `test`.`t1`.`date` ) as double)) AS `spid = FIRST_VALUE(date) OVER (ORDER BY date )` from `test`.`t1` +# +# No casts when constants or constant functions are involved +# +EXPLAIN SELECT * from t1 WHERE userID = DATE'2012-02-20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spID`,`test`.`t1`.`userID` AS `userID`,`test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`userID` = DATE'2012-02-20') +EXPLAIN SELECT * FROM t1 WHERE date = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spID`,`test`.`t1`.`userID` AS `userID`,`test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = NULL) +EXPLAIN SELECT * FROM t1 WHERE date = CAST('20:21:22' AS TIME); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spID`,`test`.`t1`.`userID` AS `userID`,`test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = (cast('20:21:22' as time))) +DROP TABLE t1; +# +# WL#13456: Inject CAST nodes for comparisons with STRING non-const expressions. +# +CREATE TABLE t(c CHAR(64), v VARCHAR(256), txt TEXT, b BINARY(64), vb VARBINARY(32), +e ENUM ("v1", "v2"), set1 SET('101', '102'), bl BLOB, i INT, +si SMALLINT, ti TINYINT, mi MEDIUMINT, bi BIGINT, bt BIT, +d DECIMAL, f FLOAT, dbl DOUBLE, dt DATETIME, dd DATE, t TIME, +y YEAR); +INSERT INTO t +VALUES ("char", "vchar","text", "binary", "varbinary", "v1", '101,102', "blob", +2001, 2, 3, 4, 200000002, 0x01, 2001.0, 2001.0, 2001.2, +"2001-01-02 22:00", "2001-01-02", "20:01", 2010); +# String vs INT +EXPLAIN SELECT v = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`i` as double)) AS `v = i` from `test`.`t` +# String vs SMALLINT +EXPLAIN SELECT v = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`si` as double)) AS `v = si` from `test`.`t` +# String vs TINYINT +EXPLAIN SELECT v = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`ti` as double)) AS `v = ti` from `test`.`t` +# String vs MEDIUMINT +EXPLAIN SELECT v = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`mi` as double)) AS `v = mi` from `test`.`t` +# String vs BIGINT +EXPLAIN SELECT v = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`bi` as double)) AS `v = bi` from `test`.`t` +# String vs BIT +EXPLAIN SELECT v = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`bt` as double)) AS `v = bt` from `test`.`t` +# String vs YEAR +EXPLAIN SELECT v = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`y` as double)) AS `v = y` from `test`.`t` +# String vs DECIMAL +EXPLAIN SELECT v = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`d` as double)) AS `v = d` from `test`.`t` +# String vs FLOAT +EXPLAIN SELECT v = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = `test`.`t`.`f`) AS `v = f` from `test`.`t` +# String vs DOUBLE +EXPLAIN SELECT v = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = `test`.`t`.`dbl`) AS `v = dbl` from `test`.`t` +# String vs DATETIME +EXPLAIN SELECT v = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as datetime(6)) = `test`.`t`.`dt`) AS `v = dt` from `test`.`t` +# String vs DATE +EXPLAIN SELECT v = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as date) = `test`.`t`.`dd`) AS `v = dd` from `test`.`t` +# String vs TIME +EXPLAIN SELECT v = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`v` = `test`.`t`.`t`) AS `v = t` from `test`.`t` +# String vs another equality +EXPLAIN SELECT v = (v = y) FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast((cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`y` as double)) as double)) AS `v = (v = y)` from `test`.`t` +# String vs expression +EXPLAIN SELECT v = 1 * i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) = cast((1 * `test`.`t`.`i`) as double)) AS `v = 1 * i` from `test`.`t` +# Other operators +EXPLAIN SELECT v <=> i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) <=> cast(`test`.`t`.`i` as double)) AS `v <=> i` from `test`.`t` +EXPLAIN SELECT v <> i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) <> cast(`test`.`t`.`i` as double)) AS `v <> i` from `test`.`t` +EXPLAIN SELECT v > i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) > cast(`test`.`t`.`i` as double)) AS `v > i` from `test`.`t` +EXPLAIN SELECT v >= i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) >= cast(`test`.`t`.`i` as double)) AS `v >= i` from `test`.`t` +EXPLAIN SELECT v <= i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) <= cast(`test`.`t`.`i` as double)) AS `v <= i` from `test`.`t` +EXPLAIN SELECT v < i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`v` as double) < cast(`test`.`t`.`i` as double)) AS `v < i` from `test`.`t` +# Test data type combinations +EXPLAIN SELECT c = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`i` as double)) AS `c = i` from `test`.`t` +EXPLAIN SELECT c = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`si` as double)) AS `c = si` from `test`.`t` +EXPLAIN SELECT c = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`ti` as double)) AS `c = ti` from `test`.`t` +EXPLAIN SELECT c = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`mi` as double)) AS `c = mi` from `test`.`t` +EXPLAIN SELECT c = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`bi` as double)) AS `c = bi` from `test`.`t` +EXPLAIN SELECT c = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`bt` as double)) AS `c = bt` from `test`.`t` +EXPLAIN SELECT c = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`y` as double)) AS `c = y` from `test`.`t` +EXPLAIN SELECT c = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`d` as double)) AS `c = d` from `test`.`t` +EXPLAIN SELECT c = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = `test`.`t`.`f`) AS `c = f` from `test`.`t` +EXPLAIN SELECT c = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as double) = `test`.`t`.`dbl`) AS `c = dbl` from `test`.`t` +EXPLAIN SELECT c = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as datetime(6)) = `test`.`t`.`dt`) AS `c = dt` from `test`.`t` +EXPLAIN SELECT c = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`c` as date) = `test`.`t`.`dd`) AS `c = dd` from `test`.`t` +EXPLAIN SELECT c = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`c` = `test`.`t`.`t`) AS `c = t` from `test`.`t` +EXPLAIN SELECT txt = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`i` as double)) AS `txt = i` from `test`.`t` +EXPLAIN SELECT txt = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`si` as double)) AS `txt = si` from `test`.`t` +EXPLAIN SELECT txt = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`ti` as double)) AS `txt = ti` from `test`.`t` +EXPLAIN SELECT txt = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`mi` as double)) AS `txt = mi` from `test`.`t` +EXPLAIN SELECT txt = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`bi` as double)) AS `txt = bi` from `test`.`t` +EXPLAIN SELECT txt = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`bt` as double)) AS `txt = bt` from `test`.`t` +EXPLAIN SELECT txt = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`y` as double)) AS `txt = y` from `test`.`t` +EXPLAIN SELECT txt = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`d` as double)) AS `txt = d` from `test`.`t` +EXPLAIN SELECT txt = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = `test`.`t`.`f`) AS `txt = f` from `test`.`t` +EXPLAIN SELECT txt = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as double) = `test`.`t`.`dbl`) AS `txt = dbl` from `test`.`t` +EXPLAIN SELECT txt = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as datetime(6)) = `test`.`t`.`dt`) AS `txt = dt` from `test`.`t` +EXPLAIN SELECT txt = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`txt` as date) = `test`.`t`.`dd`) AS `txt = dd` from `test`.`t` +EXPLAIN SELECT txt = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`txt` = `test`.`t`.`t`) AS `txt = t` from `test`.`t` +EXPLAIN SELECT b = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`i` as double)) AS `b = i` from `test`.`t` +EXPLAIN SELECT b = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`si` as double)) AS `b = si` from `test`.`t` +EXPLAIN SELECT b = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`ti` as double)) AS `b = ti` from `test`.`t` +EXPLAIN SELECT b = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`mi` as double)) AS `b = mi` from `test`.`t` +EXPLAIN SELECT b = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`bi` as double)) AS `b = bi` from `test`.`t` +EXPLAIN SELECT b = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`bt` as double)) AS `b = bt` from `test`.`t` +EXPLAIN SELECT b = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`y` as double)) AS `b = y` from `test`.`t` +EXPLAIN SELECT b = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`d` as double)) AS `b = d` from `test`.`t` +EXPLAIN SELECT b = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = `test`.`t`.`f`) AS `b = f` from `test`.`t` +EXPLAIN SELECT b = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as double) = `test`.`t`.`dbl`) AS `b = dbl` from `test`.`t` +EXPLAIN SELECT b = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as datetime(6)) = `test`.`t`.`dt`) AS `b = dt` from `test`.`t` +EXPLAIN SELECT b = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`b` as date) = `test`.`t`.`dd`) AS `b = dd` from `test`.`t` +EXPLAIN SELECT b = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`b` = `test`.`t`.`t`) AS `b = t` from `test`.`t` +EXPLAIN SELECT vb = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`i` as double)) AS `vb = i` from `test`.`t` +EXPLAIN SELECT vb = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`si` as double)) AS `vb = si` from `test`.`t` +EXPLAIN SELECT vb = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`ti` as double)) AS `vb = ti` from `test`.`t` +EXPLAIN SELECT vb = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`mi` as double)) AS `vb = mi` from `test`.`t` +EXPLAIN SELECT vb = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`bi` as double)) AS `vb = bi` from `test`.`t` +EXPLAIN SELECT vb = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`bt` as double)) AS `vb = bt` from `test`.`t` +EXPLAIN SELECT vb = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`y` as double)) AS `vb = y` from `test`.`t` +EXPLAIN SELECT vb = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`d` as double)) AS `vb = d` from `test`.`t` +EXPLAIN SELECT vb = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = `test`.`t`.`f`) AS `vb = f` from `test`.`t` +EXPLAIN SELECT vb = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as double) = `test`.`t`.`dbl`) AS `vb = dbl` from `test`.`t` +EXPLAIN SELECT vb = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as datetime(6)) = `test`.`t`.`dt`) AS `vb = dt` from `test`.`t` +EXPLAIN SELECT vb = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`vb` as date) = `test`.`t`.`dd`) AS `vb = dd` from `test`.`t` +EXPLAIN SELECT vb = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`vb` = `test`.`t`.`t`) AS `vb = t` from `test`.`t` +EXPLAIN SELECT e = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`i` as double)) AS `e = i` from `test`.`t` +EXPLAIN SELECT e = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`si` as double)) AS `e = si` from `test`.`t` +EXPLAIN SELECT e = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`ti` as double)) AS `e = ti` from `test`.`t` +EXPLAIN SELECT e = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`mi` as double)) AS `e = mi` from `test`.`t` +EXPLAIN SELECT e = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`bi` as double)) AS `e = bi` from `test`.`t` +EXPLAIN SELECT e = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`bt` as double)) AS `e = bt` from `test`.`t` +EXPLAIN SELECT e = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`y` as double)) AS `e = y` from `test`.`t` +EXPLAIN SELECT e = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`d` as double)) AS `e = d` from `test`.`t` +EXPLAIN SELECT e = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = `test`.`t`.`f`) AS `e = f` from `test`.`t` +EXPLAIN SELECT e = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as double) = `test`.`t`.`dbl`) AS `e = dbl` from `test`.`t` +EXPLAIN SELECT e = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as datetime(6)) = `test`.`t`.`dt`) AS `e = dt` from `test`.`t` +EXPLAIN SELECT e = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`e` as date) = `test`.`t`.`dd`) AS `e = dd` from `test`.`t` +EXPLAIN SELECT e = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`e` = `test`.`t`.`t`) AS `e = t` from `test`.`t` +EXPLAIN SELECT set1 = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`i` as double)) AS `set1 = i` from `test`.`t` +EXPLAIN SELECT set1 = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`si` as double)) AS `set1 = si` from `test`.`t` +EXPLAIN SELECT set1 = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`ti` as double)) AS `set1 = ti` from `test`.`t` +EXPLAIN SELECT set1 = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`mi` as double)) AS `set1 = mi` from `test`.`t` +EXPLAIN SELECT set1 = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`bi` as double)) AS `set1 = bi` from `test`.`t` +EXPLAIN SELECT set1 = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`bt` as double)) AS `set1 = bt` from `test`.`t` +EXPLAIN SELECT set1 = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`y` as double)) AS `set1 = y` from `test`.`t` +EXPLAIN SELECT set1 = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`d` as double)) AS `set1 = d` from `test`.`t` +EXPLAIN SELECT set1 = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = `test`.`t`.`f`) AS `set1 = f` from `test`.`t` +EXPLAIN SELECT set1 = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as double) = `test`.`t`.`dbl`) AS `set1 = dbl` from `test`.`t` +EXPLAIN SELECT set1 = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as datetime(6)) = `test`.`t`.`dt`) AS `set1 = dt` from `test`.`t` +EXPLAIN SELECT set1 = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`set1` as date) = `test`.`t`.`dd`) AS `set1 = dd` from `test`.`t` +EXPLAIN SELECT set1 = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`set1` = `test`.`t`.`t`) AS `set1 = t` from `test`.`t` +EXPLAIN SELECT bl = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`i` as double)) AS `bl = i` from `test`.`t` +EXPLAIN SELECT bl = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`si` as double)) AS `bl = si` from `test`.`t` +EXPLAIN SELECT bl = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`ti` as double)) AS `bl = ti` from `test`.`t` +EXPLAIN SELECT bl = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`mi` as double)) AS `bl = mi` from `test`.`t` +EXPLAIN SELECT bl = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`bi` as double)) AS `bl = bi` from `test`.`t` +EXPLAIN SELECT bl = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`bt` as double)) AS `bl = bt` from `test`.`t` +EXPLAIN SELECT bl = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`y` as double)) AS `bl = y` from `test`.`t` +EXPLAIN SELECT bl = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`d` as double)) AS `bl = d` from `test`.`t` +EXPLAIN SELECT bl = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = `test`.`t`.`f`) AS `bl = f` from `test`.`t` +EXPLAIN SELECT bl = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as double) = `test`.`t`.`dbl`) AS `bl = dbl` from `test`.`t` +EXPLAIN SELECT bl = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as datetime(6)) = `test`.`t`.`dt`) AS `bl = dt` from `test`.`t` +EXPLAIN SELECT bl = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (cast(`test`.`t`.`bl` as date) = `test`.`t`.`dd`) AS `bl = dd` from `test`.`t` +EXPLAIN SELECT bl = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`bl` = `test`.`t`.`t`) AS `bl = t` from `test`.`t` +# YEAR vs data types +EXPLAIN SELECT y = i FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`i`) AS `y = i` from `test`.`t` +EXPLAIN SELECT y = si FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`si`) AS `y = si` from `test`.`t` +EXPLAIN SELECT y = ti FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`ti`) AS `y = ti` from `test`.`t` +EXPLAIN SELECT y = mi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`mi`) AS `y = mi` from `test`.`t` +EXPLAIN SELECT y = bi FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`bi`) AS `y = bi` from `test`.`t` +EXPLAIN SELECT y = bt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`bt`) AS `y = bt` from `test`.`t` +EXPLAIN SELECT y = y FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`y`) AS `y = y` from `test`.`t` +EXPLAIN SELECT y = d FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`d`) AS `y = d` from `test`.`t` +EXPLAIN SELECT y = f FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`f`) AS `y = f` from `test`.`t` +EXPLAIN SELECT y = dbl FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`dbl`) AS `y = dbl` from `test`.`t` +EXPLAIN SELECT y = dt FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`dt`) AS `y = dt` from `test`.`t` +EXPLAIN SELECT y = dd FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`dd`) AS `y = dd` from `test`.`t` +EXPLAIN SELECT y = t FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`t`) AS `y = t` from `test`.`t` +# cleanup +DROP TABLE t; +# +# Bug#31023252: RESULTSET MISMATCH USING STRCMP() WITH DATE AND STRING DATATYPE +# +CREATE TABLE t1(a YEAR, b VARCHAR(10)); +INSERT INTO t1 VALUES ('1997','random_str'); +SELECT STRCMP(a, b) FROM t1; +STRCMP(a, b) +-1 +DROP TABLE t1; +# +# Bug#30626100: WL13456 RESULTSET DISTINCT DIFFERENCE +# +CREATE TABLE t (col_datetime datetime, col_date date, col_time time, col_char char); +insert into t values ('2013-03-15 18:35:20', '2013-03-15', '18:35:20','L'), +('2003-01-10 00:00:23', '2003-01-10', '00:00:23', NULL); +SELECT CAST(col_char AS DATETIME) FROM t; +CAST(col_char AS DATETIME) +NULL +NULL +Warnings: +Warning 1292 Incorrect datetime value: 'L' + +SELECT col_char /*CAST(col_char as datetime)*/ <> col_datetime FROM t; +col_char /*CAST(col_char as datetime)*/ <> col_datetime +1 +NULL +Warnings: +Warning 1292 Incorrect datetime value: 'L' + +SELECT CAST(col_char AS DATE) FROM t; +CAST(col_char AS DATE) +NULL +NULL +Warnings: +Warning 1292 Incorrect datetime value: 'L' + +SELECT col_char <> col_date FROM t; +col_char <> col_date +1 +NULL +Warnings: +Warning 1292 Incorrect datetime value: 'L' +SELECT CAST(col_char as TIME) FROM t; +CAST(col_char as TIME) +NULL +NULL +Warnings: +Warning 1292 Truncated incorrect time value: 'L' +SELECT col_char <> col_time FROM t; +col_char <> col_time +1 +NULL +DROP TABLE t; +# +# Bug#31095719 WL13456 RESULT SET COMPARISON DIFFERENCE WITH JOINS +# +CREATE TABLE `BB` (`col_char_key` char(1)); +CREATE TABLE `CC` ( `pk` int, `col_datetime_key` datetime, +KEY `idx_CC_col_datetime_key` (`col_datetime_key`)); +INSERT INTO `BB` VALUES ('X'); +INSERT INTO `CC` VALUES (1,'2027-03-17 00:10:00'), (2,'2004-11-14 12:46:43'); +SELECT COUNT(table1.pk) FROM CC table1 JOIN BB table3 JOIN CC table2 +WHERE (table3.col_char_key < table2.col_datetime_key); +COUNT(table1.pk) +4 +Warnings: +Warning 1292 Incorrect datetime value: 'X' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect datetime value: 'X' for column 'col_datetime_key' at row 1 +DROP TABLE `BB`; +DROP TABLE `CC`; +# +# CAST AS YEAR +# +SELECT CAST(CAST(-1 AS SIGNED) AS YEAR); +CAST(CAST(-1 AS SIGNED) AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '-1' +SELECT CAST(CAST(-99 AS SIGNED) AS YEAR); +CAST(CAST(-99 AS SIGNED) AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '-99' +SELECT CAST(CAST(0 AS SIGNED) AS YEAR); +CAST(CAST(0 AS SIGNED) AS YEAR) +0 +SELECT CAST(CAST(69 AS SIGNED) AS YEAR); +CAST(CAST(69 AS SIGNED) AS YEAR) +2069 +SELECT CAST(CAST(70 AS SIGNED) AS YEAR); +CAST(CAST(70 AS SIGNED) AS YEAR) +1970 +SELECT CAST(CAST(99 AS SIGNED) AS YEAR); +CAST(CAST(99 AS SIGNED) AS YEAR) +1999 +SELECT CAST(CAST(100 AS SIGNED) AS YEAR); +CAST(CAST(100 AS SIGNED) AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '100' +SELECT CAST(CAST(2010 AS SIGNED) AS YEAR); +CAST(CAST(2010 AS SIGNED) AS YEAR) +2010 +SELECT CAST(-1.1 AS YEAR); +CAST(-1.1 AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '-1' +SELECT CAST(1.1 AS YEAR); +CAST(1.1 AS YEAR) +2001 +SELECT CAST(0.0 AS YEAR); +CAST(0.0 AS YEAR) +0 +SELECT CAST(69.1 AS YEAR); +CAST(69.1 AS YEAR) +2069 +SELECT CAST(70.1 AS YEAR); +CAST(70.1 AS YEAR) +1970 +SELECT CAST(100.1 AS YEAR); +CAST(100.1 AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '100' +SELECT CAST(2010.9 AS YEAR); +CAST(2010.9 AS YEAR) +2011 +SELECT CAST(CAST(-1.1 AS DECIMAL) AS YEAR); +CAST(CAST(-1.1 AS DECIMAL) AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '-1' +SELECT CAST(CAST(1.1 AS DECIMAL) AS YEAR); +CAST(CAST(1.1 AS DECIMAL) AS YEAR) +2001 +SELECT CAST(CAST(0.0 AS DECIMAL) AS YEAR); +CAST(CAST(0.0 AS DECIMAL) AS YEAR) +0 +SELECT CAST(CAST(69.1 AS DECIMAL) AS YEAR); +CAST(CAST(69.1 AS DECIMAL) AS YEAR) +2069 +SELECT CAST(CAST(70.1 AS DECIMAL) AS YEAR); +CAST(CAST(70.1 AS DECIMAL) AS YEAR) +1970 +SELECT CAST(CAST(100.1 AS DECIMAL) AS YEAR); +CAST(CAST(100.1 AS DECIMAL) AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '100' +SELECT CAST(CAST(2010.9 AS DECIMAL) AS YEAR); +CAST(CAST(2010.9 AS DECIMAL) AS YEAR) +2011 +SELECT CAST("-1" AS YEAR); +CAST("-1" AS YEAR) +NULL +Warnings: +Warning 1525 Incorrect YEAR value: '-1' +SELECT CAST("-99" AS YEAR); +CAST("-99" AS YEAR) +NULL +Warnings: +Warning 1525 Incorrect YEAR value: '-99' +SELECT CAST("0" AS YEAR); +CAST("0" AS YEAR) +2000 +SELECT CAST("69" AS YEAR); +CAST("69" AS YEAR) +2069 +SELECT CAST("70" AS YEAR); +CAST("70" AS YEAR) +1970 +SELECT CAST("99" AS YEAR); +CAST("99" AS YEAR) +1999 +SELECT CAST("100" AS YEAR); +CAST("100" AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '100' +SELECT CAST("2010" AS YEAR); +CAST("2010" AS YEAR) +2010 +SELECT CAST("extra" AS YEAR); +CAST("extra" AS YEAR) +NULL +Warnings: +Warning 1525 Incorrect YEAR value: 'extra' +SELECT CAST("22extra" AS YEAR); +CAST("22extra" AS YEAR) +2022 +Warnings: +Warning 1292 Truncated incorrect YEAR value: '22extra' +SELECT CAST("2020extra" AS YEAR); +CAST("2020extra" AS YEAR) +2020 +Warnings: +Warning 1292 Truncated incorrect YEAR value: '2020extra' +SET timestamp = UNIX_TIMESTAMP('2020-12-22 03:30:00'); +SELECT CAST(TIMESTAMP'2010-01-01 00:00' AS YEAR); +CAST(TIMESTAMP'2010-01-01 00:00' AS YEAR) +2010 +SET SQL_MODE = ""; +SELECT CAST(TIMESTAMP'0000-00-00 00:00' AS YEAR); +CAST(TIMESTAMP'0000-00-00 00:00' AS YEAR) +0 +SET SQL_MODE = default; +SELECT CAST(TIMESTAMP'2010-01-01 08:09:10' AS YEAR); +CAST(TIMESTAMP'2010-01-01 08:09:10' AS YEAR) +2010 +SELECT CAST(TIME'08:09:10' AS YEAR); +CAST(TIME'08:09:10' AS YEAR) +2020 +SELECT CAST(TIME'00:00:00' AS YEAR); +CAST(TIME'00:00:00' AS YEAR) +2020 +SET timestamp = DEFAULT; +SELECT CAST(ST_PointFromText('POINT(10 10)') AS YEAR); +ERROR HY000: Incorrect arguments to cast_as_year +CREATE TABLE t AS SELECT CAST("2010" AS YEAR); +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `CAST("2010" AS YEAR)` year DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t; +SELECT CAST(JSON_EXTRACT('{"key_year":1934}', '$.key_year') AS YEAR); +CAST(JSON_EXTRACT('{"key_year":1934}', '$.key_year') AS YEAR) +1934 +SELECT CAST(CAST('{"_id":"192312412512"}' AS JSON) AS YEAR); +CAST(CAST('{"_id":"192312412512"}' AS JSON) AS YEAR) +0 +Warnings: +Warning 3156 Invalid JSON value for CAST to INTEGER from column cast_as_json at row 1 +CREATE TABLE t1 (i INT, j JSON) CHARSET utf8mb4; +INSERT INTO t1 VALUES (0, NULL); +INSERT INTO t1 VALUES (1, '"1901"'); +INSERT INTO t1 VALUES (2, 'true'); +INSERT INTO t1 VALUES (3, 'false'); +INSERT INTO t1 VALUES (4, 'null'); +INSERT INTO t1 VALUES (5, '-1'); +INSERT INTO t1 VALUES (6, CAST(CAST(1 AS UNSIGNED) AS JSON)); +INSERT INTO t1 VALUES (7, '1901'); +INSERT INTO t1 VALUES (8, '-1901'); +INSERT INTO t1 VALUES (9, '2147483647'); +INSERT INTO t1 VALUES (10, '2147483648'); +INSERT INTO t1 VALUES (11, '-2147483648'); +INSERT INTO t1 VALUES (12, '-2147483649'); +INSERT INTO t1 VALUES (13, '3.14'); +INSERT INTO t1 VALUES (14, '{}'); +INSERT INTO t1 VALUES (15, '[]'); +INSERT INTO t1 VALUES (16, CAST(CAST('2015-01-15 23:24:25' AS DATETIME) AS JSON)); +INSERT INTO t1 VALUES (17, CAST(CAST('23:24:25' AS TIME) AS JSON)); +INSERT INTO t1 VALUES (18, CAST(CAST('2015-01-15' AS DATE) AS JSON)); +INSERT INTO t1 VALUES (19, CAST(TIMESTAMP'2015-01-15 23:24:25' AS JSON)); +INSERT INTO t1 VALUES (20, CAST(ST_GeomFromText('POINT(1 1)') AS JSON)); +INSERT INTO t1 VALUES (21, CAST('1988' AS CHAR CHARACTER SET 'ascii')); +INSERT INTO t1 VALUES (22, CAST(x'07C4' AS JSON)); +INSERT INTO t1 VALUES (23, CAST(x'07C407C4' AS JSON)); +SELECT i, CAST(j AS YEAR), CAST(j AS SIGNED) FROM t1 ORDER BY i; +i CAST(j AS YEAR) CAST(j AS SIGNED) +0 NULL NULL +1 1901 1901 +2 2001 1 +3 0 0 +4 0 0 +5 NULL -1 +6 2001 1 +7 1901 1901 +8 NULL -1901 +9 NULL 2147483647 +10 NULL 2147483648 +11 NULL -2147483648 +12 NULL -2147483649 +13 2003 3 +14 0 0 +15 0 0 +16 0 0 +17 0 0 +18 0 0 +19 0 0 +20 0 0 +21 1988 1988 +22 0 0 +23 0 0 +Warnings: +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 5 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 5 +Warning 1292 Truncated incorrect YEAR value: '-1' +Warning 1292 Truncated incorrect YEAR value: '-1901' +Warning 1292 Truncated incorrect YEAR value: '2147483647' +Warning 1292 Truncated incorrect YEAR value: '2147483648' +Warning 1292 Truncated incorrect YEAR value: '-2147483648' +Warning 1292 Truncated incorrect YEAR value: '-2147483649' +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 15 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 15 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 16 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 16 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 17 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 17 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 18 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 18 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 19 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 19 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 20 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 20 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 21 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 21 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 23 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 23 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 24 +Warning 3156 Invalid JSON value for CAST to INTEGER from column j at row 24 +DROP TABLE t1; +CREATE TABLE t(numbers ENUM('0','1','2020'), colors ENUM('red', 'green', 'blue')); +INSERT INTO t values('2020', 'blue'); +SELECT CAST(numbers AS YEAR), CAST(colors AS YEAR) FROM t; +CAST(numbers AS YEAR) CAST(colors AS YEAR) +2003 2003 +DROP TABLE t; +CREATE TABLE t(y YEAR); +INSERT INTO t values(CAST("2020extra" AS YEAR)); +ERROR 22007: Truncated incorrect YEAR value: '2020extra' +INSERT INTO t values(CAST(20201 AS YEAR)); +ERROR 22007: Truncated incorrect YEAR value: '20201' +SET SQL_MODE = ""; +INSERT INTO t values(CAST("2020extra" AS YEAR)); +Warnings: +Warning 1292 Truncated incorrect YEAR value: '2020extra' +INSERT INTO t values(CAST(20201 AS YEAR)); +Warnings: +Warning 1292 Truncated incorrect YEAR value: '20201' +SELECT * FROM t; +y +2020 +NULL +SET SQL_MODE = default; +DROP TABLE t; +SELECT CAST(1988 AS YEAR), REPEAT(CAST(1988 AS YEAR), 3) AS c2; +CAST(1988 AS YEAR) c2 +1988 198819881988 +SELECT CONCAT('x', CAST(1988 AS YEAR)); +CONCAT('x', CAST(1988 AS YEAR)) +x1988 +SELECT CAST(1988 AS YEAR) + 1.5e0; +CAST(1988 AS YEAR) + 1.5e0 +1989.5 +SELECT CAST(CAST(1988 AS YEAR) AS DECIMAL); +CAST(CAST(1988 AS YEAR) AS DECIMAL) +1988 +SELECT DATE_ADD(CAST(1988 AS YEAR), INTERVAL 1 DAY); +DATE_ADD(CAST(1988 AS YEAR), INTERVAL 1 DAY) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '1988' +SELECT TIME_TO_SEC(CAST('2030' AS YEAR)); +TIME_TO_SEC(CAST('2030' AS YEAR)) +1230 +SELECT TIMESTAMPADD(MINUTE, 1, CAST(1988 AS YEAR)); +TIMESTAMPADD(MINUTE, 1, CAST(1988 AS YEAR)) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '1988' +SELECT CAST(CAST(1988 AS YEAR) AS SIGNED); +CAST(CAST(1988 AS YEAR) AS SIGNED) +1988 +SELECT CAST(CAST(1988 AS YEAR) AS UNSIGNED); +CAST(CAST(1988 AS YEAR) AS UNSIGNED) +1988 +SELECT CAST(TIMESTAMP'579-10-10 10:10:10' AS YEAR); +CAST(TIMESTAMP'579-10-10 10:10:10' AS YEAR) +NULL +Warnings: +Warning 1292 Truncated incorrect YEAR value: '579' +SELECT CAST(STR_TO_DATE('nope','%d-%m-%Y') AS YEAR); +CAST(STR_TO_DATE('nope','%d-%m-%Y') AS YEAR) +NULL +Warnings: +Warning 1411 Incorrect datetime value: 'nope' for function str_to_date +# WL#14109: Implement a consistent comparison type rule matrix +SET @zero_date = '0000-00-00'; +SET @zero_day = '2000-01-00'; +SET @zero_month = '2000-00-01'; +SET @zero_year = '0000-01-01'; +SET @invalid_date = '2000-02-31'; +SET @bad_date = 'YYYY-MM-DD'; +SET @zero_datetime = '0000-00-00 00:00:00.000000'; +SET @zero_day_dt = '2000-01-00 00:00:00.000000'; +SET @zero_month_dt = '2000-00-01 00:00:00.000000'; +SET @zero_year_dt = '0000-01-01 00:00:00.000000'; +SET @invalid_datetime = '2000-02-31 00:00:00.000000'; +SET @bad_datetime = 'YYYY-MM-DD HH:MM:SS.ffffff'; +SET SQL_MODE=DEFAULT; +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000000' +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-01-00 2000-01-00 2000-01-00 00:00:00.000000 2000-01-00 00:00:00.000000 +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-00-01 2000-00-01 2000-00-01 00:00:00.000000 2000-00-01 00:00:00.000000 +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-00-00 0000-00-00 0000-00-00 00:00:00.000000 0000-00-00 00:00:00.000000 +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-01-00 00:00:00.000000' +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-00-01 00:00:00.000000' +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +Warning 1292 Incorrect datetime value: '2000-02-31 00:00:00.000000' +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE='ALLOW_INVALID_DATES'; +SELECT CAST('0000-00-00' AS DATE) AS d1, +CAST(@zero_date AS DATE) AS d2, +CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-00-00 0000-00-00 0000-00-00 00:00:00.000000 0000-00-00 00:00:00.000000 +SELECT CAST('2000-01-00' AS DATE) AS d1, +CAST(@zero_day AS DATE) AS d2, +CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_day_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-01-00 2000-01-00 2000-01-00 00:00:00.000000 2000-01-00 00:00:00.000000 +SELECT CAST('2000-00-01' AS DATE) AS d1, +CAST(@zero_month AS DATE) AS d2, +CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_month_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-00-01 2000-00-01 2000-00-01 00:00:00.000000 2000-00-01 00:00:00.000000 +SELECT CAST('0000-01-01' AS DATE) AS d1, +CAST(@zero_year AS DATE) AS d2, +CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@zero_year_dt AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +0000-01-01 0000-01-01 0000-01-01 00:00:00.000000 0000-01-01 00:00:00.000000 +SELECT CAST('2000-02-31' AS DATE) AS d1, +CAST(@invalid_date AS DATE) AS d2, +CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1, +CAST(@invalid_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +2000-02-31 2000-02-31 2000-02-31 00:00:00.000000 2000-02-31 00:00:00.000000 +SELECT CAST('YYYY-MM-DD' AS DATE) AS d1, +CAST(@bad_date AS DATE) AS d2, +CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1, +CAST(@bad_datetime AS DATETIME(6)) AS dt2; +d1 d2 dt1 dt2 +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +Warning 1292 Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff' +SET SQL_MODE=DEFAULT; +# +# Bug#32371039: ITEM->MAX_LENGTH FIELD IS NOT ACCURATE FOR +# FROM_BASE64 FUNCTION +# +CREATE TABLE t AS +SELECT CONCAT(CAST(-1 AS UNSIGNED)) AS col1, +1.0 + CAST(-1 AS UNSIGNED) AS col2, +CONCAT(CAST(9223372036854775808 AS SIGNED)) AS col3; +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `col1` varchar(21) CHARACTER SET latin1 DEFAULT NULL, + `col2` decimal(23,1) NOT NULL DEFAULT '0.0', + `col3` varchar(21) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t; +col1 col2 col3 +18446744073709551615 18446744073709551616.0 -9223372036854775808 +DROP TABLE t; diff --git a/mysql-test/r/compare.result-pq b/mysql-test/r/compare.result-pq new file mode 100644 index 000000000..b3e010572 --- /dev/null +++ b/mysql-test/r/compare.result-pq @@ -0,0 +1,205 @@ +drop table if exists t1; +CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id)); +insert into t1 values ('000000000001'),('000000000002'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where id=000000000001; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 48 NULL 2 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'id' +Warning 1739 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'id' +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where (`test`.`t1`.`id` = 1) +select * from t1 where id=000000000001; +id +000000000001 +delete from t1 where id=000000000002; +select * from t1; +id +000000000001 +drop table t1; +set names latin1; +SELECT 'a' = 'a '; +'a' = 'a ' +1 +SELECT 'a\0' < 'a'; +'a\0' < 'a' +1 +SELECT 'a\0' < 'a '; +'a\0' < 'a ' +1 +SELECT 'a\t' < 'a'; +'a\t' < 'a' +1 +SELECT 'a\t' < 'a '; +'a\t' < 'a ' +1 +CREATE TABLE t1 (a char(10) not null) charset latin1; +INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); +SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; +hex(a) STRCMP(a,'a') STRCMP(a,'a ') +61 0 0 +6100 -1 -1 +6109 -1 -1 +61 0 0 +DROP TABLE t1; +set names default; +SELECT CHAR(31) = '', '' = CHAR(31); +CHAR(31) = '' '' = CHAR(31) +0 0 +SELECT CHAR(30) = '', '' = CHAR(30); +CHAR(30) = '' '' = CHAR(30) +0 0 +create table t1 (a tinyint(1),b binary(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (0x01,0x01); +select * from t1 where a=b; +a b +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x01' +select * from t1 where a=b and b=0x01; +a b +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x01' +drop table if exists t1; +CREATE TABLE t1 (b int(2) zerofill, c int(2) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (b,c) VALUES (1,2), (1,1), (2,2); +SELECT CONCAT(b,c), CONCAT(b,c) = '0101' FROM t1; +CONCAT(b,c) CONCAT(b,c) = '0101' +0102 0 +0101 1 +0202 0 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (concat('01',`test`.`t1`.`c`) = '0101')) +SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101'; +b c +01 01 +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (1),(2); +SELECT a, +(SELECT COUNT(*) FROM t1 +WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x +FROM t2 ORDER BY a; +a x +1 1 +2 0 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT a, +(SELECT COUNT(*) FROM t1 +WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x +FROM t2 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL x 100.00 Using filesort +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL x 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,(/* select#2 */ select count(0) from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (concat(`test`.`t1`.`b`,`test`.`t1`.`c`) = concat('0',`test`.`t2`.`a`,'01')))) AS `x` from `test`.`t2` order by `test`.`t2`.`a` +DROP TABLE t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES (NOW()),(NOW()),(NOW()); +SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00'; +a +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +CREATE TABLE t1(a INT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2; +1 +DROP TABLE t1; + +Bug #27452148: ASSERTION FAILED: (SLEN % 4) == 0 IN +MY_STRNNCOLLSP_UTF32_BIN + +SET NAMES latin1; +CREATE TABLE t1(a CHAR(10) CHARACTER SET utf32 COLLATE utf32_bin); +INSERT INTO t1 VALUES('a'),('b'),('c'); +SELECT ROW('1', '1') > ROW(a, '1') FROM t1; +ROW('1', '1') > ROW(a, '1') +0 +0 +0 +SELECT ROW(a, '1') > ROW('1', '1') FROM t1; +ROW(a, '1') > ROW('1', '1') +1 +1 +1 +DROP TABLE t1; +SET NAMES default; +# +# Bug#30961924 AND OF TWO PREDICATES WITH DIFFERENT COLLATION ON SAME COLUMN GIVES WRONG RESULT +# +CREATE TABLE t1( +firstname CHAR(20), +lastname CHAR(20) +) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; +INSERT INTO t1 VALUES("john","doe"), ("John","Doe"); +SELECT * FROM t1 WHERE firstname = 'john'; +firstname lastname +john doe +John Doe +SELECT * FROM t1 WHERE firstname = 'john' COLLATE utf8mb4_0900_ai_ci; +firstname lastname +john doe +John Doe +SELECT * FROM t1 WHERE firstname = 'john' COLLATE utf8mb4_0900_as_cs; +firstname lastname +john doe +SELECT * FROM t1 +WHERE firstname = 'john' COLLATE utf8mb4_0900_ai_ci AND +firstname = 'john' COLLATE utf8mb4_0900_as_cs; +firstname lastname +john doe +SELECT * FROM t1 +WHERE firstname = 'john' COLLATE utf8mb4_0900_as_cs AND +firstname = 'john' COLLATE utf8mb4_0900_ai_ci; +firstname lastname +john doe +DROP TABLE t1; +Comparisons with parameters and extreme values +CREATE TABLE t(a DECIMAL(30,0)); +INSERT INTO t VALUES(0); +SELECT * FROM t; +a +0 +set @maxint=18446744073709551615; +SELECT @maxint; +@maxint +18446744073709551615 +SELECT * FROM t WHERE a < @maxint; +a +0 +SELECT * FROM t WHERE a < 18446744073709551615; +a +0 +SELECT * FROM t WHERE 0 < 18446744073709551615; +a +0 +SELECT * FROM t WHERE 0 < @maxint; +a +0 +DROP TABLE t; diff --git a/mysql-test/r/compress.result-pq b/mysql-test/r/compress.result-pq new file mode 100644 index 000000000..d6b2c2a17 --- /dev/null +++ b/mysql-test/r/compress.result-pq @@ -0,0 +1,4580 @@ +SHOW STATUS LIKE 'Compression%'; +Variable_name Value +Compression ON +Compression_algorithm zlib +Compression_level 6 +drop table if exists t1,t2,t3,t4; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +37 +36 +50 +58 +29 +40 +53 +65 +41 +34 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; +fld3 repeat("a",length(fld3)) count(*) +Baird aaaaa 1 +balled aaaaaa 1 +ballgown aaaaaaaa 1 +Baltimorean aaaaaaaaaaa 1 +bankruptcies aaaaaaaaaaaa 1 +Barry aaaaa 1 +batting aaaaaaa 1 +beaner aaaaaa 1 +beasts aaaaaa 1 +beaters aaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL # # Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL # # Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL # # NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL # # NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const # # NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const # # NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10; +fld3 period +Abraham 9410 +Aden 9410 +Adolph 9410 +Aldrich 9410 +Alison 9410 +Anatole 9410 +Antarctica 9410 +Antares 9410 +Arabia 9410 +Artemia 9410 +Augustine 9410 +Baird 9410 +Beebe 9410 +Butterfield 9410 +CERN 9410 +Cassites 9410 +Chicana 9410 +Chippewa 9410 +Clayton 9410 +Conley 9410 +Connally 9410 +Crays 9410 +DiMaggio 9410 +Dutchman 9410 +Eulerian 9410 +Evanston 9410 +Everhart 9410 +Fenton 9410 +Fitzpatrick 9410 +Galatean 9410 +Gandhian 9410 +Ganymede 9410 +Goldstine 9410 +Gothicism 9410 +Graves 9410 +Greenberg 9410 +Gurkha 9410 +Hawaii 9410 +Hegelian 9410 +Hornblower 9410 +Huffman 9410 +Hunter 9410 +Joplin 9410 +Judas 9410 +Kane 9410 +Kantian 9410 +Kevin 9410 +Kinsey 9410 +Kline 9410 +Lars 9410 +Latinizes 9410 +Lillian 9410 +Lizzy 9410 +Majorca 9410 +Manhattanize 9410 +McGovern 9410 +Melinda 9410 +Merritt 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +Nabisco 9410 +Nazis 9410 +Newtonian 9410 +Norwalk 9410 +Pandora 9410 +Parsifal 9410 +Peruvian 9410 +Punjab 9410 +Pyle 9410 +Quixotism 9410 +Romano 9410 +Romans 9410 +Sabine 9410 +Sault 9410 +Saxony 9410 +Selfridge 9410 +Shanghais 9410 +Simla 9410 +Simon 9410 +Stalin 9410 +Steinberg 9410 +Taoism 9410 +Teresa 9410 +Tipperary 9410 +Weissmuller 9410 +Winsett 9410 +Wotan 9410 +abates 9410 +abrogating 9410 +accessed 9410 +admiring 9410 +admonishing 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +alike 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +arriving 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +chillingly 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +galling 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +governing 9410 +gradually 9410 +grazing 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +handgun 9410 +handy 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +hostess 9410 +humanness 9410 +humiliation 9410 +humility 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +journalizing 9410 +juveniles 9410 +kanji 9410 +kingdom 9410 +kiting 9410 +labeled 9410 +languages 9410 +laterally 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +linear 9410 +lists 9410 +lithograph 9410 +lore 9410 +luckily 9410 +males 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +metaphysically 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +navies 9410 +navigate 9410 +neat 9410 +neonatal 9410 +nested 9410 +noncritical 9410 +normalizes 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +parametrized 9410 +parenthood 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +quagmire 9410 +quitter 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +save 9410 +sawtooth 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +western 9410 +whiteners 9410 +widens 9410 +witchcraft 9410 +workers 9410 +yelped 9410 +youthfulness 9410 +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr order by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +analyze table t2,t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +label +labeled +labeled +landslide +laterally +leaflet +lewdly +Lillian +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr order by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr, t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr order by companynr; +companynr count(price) sum(price) min(price) max(price) avg(price) +37 12543 309394878010 5987435 39654943 24666736.6667 +78 8362 414611089292 726498 98439034 49582766.0000 +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +9 +8 +0 +4 +6 +7 +1 +3 +5 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr order by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +29 company 1 +68 company 10 +50 company 11 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +53 company 7 +58 company 8 +65 company 9 +0 Unknown +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr order by companynr; +companynr count sum diff func +37 12543 309394878010 0.0000 464091 +78 8362 414611089292 0.0000 652236 +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4 order by fld1; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3 order by fld3; +companynr fld3 sum(price) +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 Micronesia 786542 +512 Miles 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr order by companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # # Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +37 588 83602098 +29 95 14473298 +41 52 12816335 +34 70 17788966 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +37 +29 +41 +34 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40 order by t2.companynr; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr order by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A # NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A # NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A # NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +cont_nr int(11) NOT NULL auto_increment, +ver_nr int(11) NOT NULL default '0', +aufnr int(11) NOT NULL default '0', +username varchar(50) NOT NULL default '', +hdl_nr int(11) NOT NULL default '0', +eintrag date NOT NULL default '0000-00-00', +st_klasse varchar(40) NOT NULL default '', +st_wert varchar(40) NOT NULL default '', +st_zusatz varchar(40) NOT NULL default '', +st_bemerkung varchar(255) NOT NULL default '', +kunden_art varchar(40) NOT NULL default '', +mcbs_knr int(11) default NULL, +mcbs_aufnr int(11) NOT NULL default '0', +schufa_status char(1) default '?', +bemerkung text, +wirknetz text, +wf_igz int(11) NOT NULL default '0', +tarifcode varchar(80) default NULL, +recycle char(1) default NULL, +sim varchar(30) default NULL, +mcbs_tpl varchar(30) default NULL, +emp_nr int(11) NOT NULL default '0', +laufzeit int(11) default NULL, +hdl_name varchar(30) default NULL, +prov_hdl_nr int(11) NOT NULL default '0', +auto_wirknetz varchar(50) default NULL, +auto_billing varchar(50) default NULL, +touch timestamp NOT NULL, +kategorie varchar(50) default NULL, +kundentyp varchar(20) NOT NULL default '', +sammel_rech_msisdn varchar(30) NOT NULL default '', +p_nr varchar(9) NOT NULL default '', +suffix char(3) NOT NULL default '', +PRIMARY KEY (cont_nr), +KEY idx_aufnr(aufnr), +KEY idx_hdl_nr(hdl_nr), +KEY idx_st_klasse(st_klasse), +KEY ver_nr(ver_nr), +KEY eintrag_idx(eintrag), +KEY emp_nr_idx(emp_nr), +KEY wf_igz(wf_igz), +KEY touch(touch), +KEY hdl_tag(eintrag,hdl_nr), +KEY prov_hdl_nr(prov_hdl_nr), +KEY mcbs_aufnr(mcbs_aufnr), +KEY kundentyp(kundentyp), +KEY p_nr(p_nr,suffix) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET sql_mode = default; +INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007'); +INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie; +Kundentyp kategorie +Privat (Private Nutzung) Mobilfunk +Warnings: +Warning 1052 Column 'kundentyp' in group statement is ambiguous +drop table t1; +SHOW STATUS LIKE 'Compression%'; +Variable_name Value +Compression ON +Compression_algorithm zstd +Compression_level 10 +drop table if exists t1,t2,t3,t4; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +37 +36 +50 +58 +29 +40 +53 +65 +41 +34 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; +fld3 repeat("a",length(fld3)) count(*) +Baird aaaaa 1 +balled aaaaaa 1 +ballgown aaaaaaaa 1 +Baltimorean aaaaaaaaaaa 1 +bankruptcies aaaaaaaaaaaa 1 +Barry aaaaa 1 +batting aaaaaaa 1 +beaner aaaaaa 1 +beasts aaaaaa 1 +beaters aaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL # # Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL # # Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL # # NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL # # NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const # # NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const # # NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10; +fld3 period +Abraham 9410 +Aden 9410 +Adolph 9410 +Aldrich 9410 +Alison 9410 +Anatole 9410 +Antarctica 9410 +Antares 9410 +Arabia 9410 +Artemia 9410 +Augustine 9410 +Baird 9410 +Beebe 9410 +Butterfield 9410 +CERN 9410 +Cassites 9410 +Chicana 9410 +Chippewa 9410 +Clayton 9410 +Conley 9410 +Connally 9410 +Crays 9410 +DiMaggio 9410 +Dutchman 9410 +Eulerian 9410 +Evanston 9410 +Everhart 9410 +Fenton 9410 +Fitzpatrick 9410 +Galatean 9410 +Gandhian 9410 +Ganymede 9410 +Goldstine 9410 +Gothicism 9410 +Graves 9410 +Greenberg 9410 +Gurkha 9410 +Hawaii 9410 +Hegelian 9410 +Hornblower 9410 +Huffman 9410 +Hunter 9410 +Joplin 9410 +Judas 9410 +Kane 9410 +Kantian 9410 +Kevin 9410 +Kinsey 9410 +Kline 9410 +Lars 9410 +Latinizes 9410 +Lillian 9410 +Lizzy 9410 +Majorca 9410 +Manhattanize 9410 +McGovern 9410 +Melinda 9410 +Merritt 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +Nabisco 9410 +Nazis 9410 +Newtonian 9410 +Norwalk 9410 +Pandora 9410 +Parsifal 9410 +Peruvian 9410 +Punjab 9410 +Pyle 9410 +Quixotism 9410 +Romano 9410 +Romans 9410 +Sabine 9410 +Sault 9410 +Saxony 9410 +Selfridge 9410 +Shanghais 9410 +Simla 9410 +Simon 9410 +Stalin 9410 +Steinberg 9410 +Taoism 9410 +Teresa 9410 +Tipperary 9410 +Weissmuller 9410 +Winsett 9410 +Wotan 9410 +abates 9410 +abrogating 9410 +accessed 9410 +admiring 9410 +admonishing 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +alike 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +arriving 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +chillingly 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +galling 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +governing 9410 +gradually 9410 +grazing 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +handgun 9410 +handy 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +hostess 9410 +humanness 9410 +humiliation 9410 +humility 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +journalizing 9410 +juveniles 9410 +kanji 9410 +kingdom 9410 +kiting 9410 +labeled 9410 +languages 9410 +laterally 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +linear 9410 +lists 9410 +lithograph 9410 +lore 9410 +luckily 9410 +males 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +metaphysically 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +navies 9410 +navigate 9410 +neat 9410 +neonatal 9410 +nested 9410 +noncritical 9410 +normalizes 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +parametrized 9410 +parenthood 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +quagmire 9410 +quitter 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +save 9410 +sawtooth 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +western 9410 +whiteners 9410 +widens 9410 +witchcraft 9410 +workers 9410 +yelped 9410 +youthfulness 9410 +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr order by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +analyze table t2,t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +label +labeled +labeled +landslide +laterally +leaflet +lewdly +Lillian +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr order by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr, t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr order by companynr; +companynr count(price) sum(price) min(price) max(price) avg(price) +37 12543 309394878010 5987435 39654943 24666736.6667 +78 8362 414611089292 726498 98439034 49582766.0000 +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +9 +8 +0 +4 +6 +7 +1 +3 +5 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr order by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +29 company 1 +68 company 10 +50 company 11 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +53 company 7 +58 company 8 +65 company 9 +0 Unknown +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr order by companynr; +companynr count sum diff func +37 12543 309394878010 0.0000 464091 +78 8362 414611089292 0.0000 652236 +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4 order by fld1; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3 order by fld3; +companynr fld3 sum(price) +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 Micronesia 786542 +512 Miles 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr order by companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # # Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +37 588 83602098 +29 95 14473298 +41 52 12816335 +34 70 17788966 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +37 +29 +41 +34 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40 order by t2.companynr; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr order by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A # NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A # NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A # NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +cont_nr int(11) NOT NULL auto_increment, +ver_nr int(11) NOT NULL default '0', +aufnr int(11) NOT NULL default '0', +username varchar(50) NOT NULL default '', +hdl_nr int(11) NOT NULL default '0', +eintrag date NOT NULL default '0000-00-00', +st_klasse varchar(40) NOT NULL default '', +st_wert varchar(40) NOT NULL default '', +st_zusatz varchar(40) NOT NULL default '', +st_bemerkung varchar(255) NOT NULL default '', +kunden_art varchar(40) NOT NULL default '', +mcbs_knr int(11) default NULL, +mcbs_aufnr int(11) NOT NULL default '0', +schufa_status char(1) default '?', +bemerkung text, +wirknetz text, +wf_igz int(11) NOT NULL default '0', +tarifcode varchar(80) default NULL, +recycle char(1) default NULL, +sim varchar(30) default NULL, +mcbs_tpl varchar(30) default NULL, +emp_nr int(11) NOT NULL default '0', +laufzeit int(11) default NULL, +hdl_name varchar(30) default NULL, +prov_hdl_nr int(11) NOT NULL default '0', +auto_wirknetz varchar(50) default NULL, +auto_billing varchar(50) default NULL, +touch timestamp NOT NULL, +kategorie varchar(50) default NULL, +kundentyp varchar(20) NOT NULL default '', +sammel_rech_msisdn varchar(30) NOT NULL default '', +p_nr varchar(9) NOT NULL default '', +suffix char(3) NOT NULL default '', +PRIMARY KEY (cont_nr), +KEY idx_aufnr(aufnr), +KEY idx_hdl_nr(hdl_nr), +KEY idx_st_klasse(st_klasse), +KEY ver_nr(ver_nr), +KEY eintrag_idx(eintrag), +KEY emp_nr_idx(emp_nr), +KEY wf_igz(wf_igz), +KEY touch(touch), +KEY hdl_tag(eintrag,hdl_nr), +KEY prov_hdl_nr(prov_hdl_nr), +KEY mcbs_aufnr(mcbs_aufnr), +KEY kundentyp(kundentyp), +KEY p_nr(p_nr,suffix) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET sql_mode = default; +INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007'); +INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie; +Kundentyp kategorie +Privat (Private Nutzung) Mobilfunk +Warnings: +Warning 1052 Column 'kundentyp' in group statement is ambiguous +drop table t1; diff --git a/mysql-test/r/condition_filter.result-pq b/mysql-test/r/condition_filter.result-pq new file mode 100644 index 000000000..eddd059bd --- /dev/null +++ b/mysql-test/r/condition_filter.result-pq @@ -0,0 +1,108 @@ +# +# Bug 20219846: EXPLAIN FOR LIMIT QUERY SHOWS FILESORT BUT EXECUTION +# IS DONE WITH INDEX ONLY +# +CREATE TABLE t0 ( +i0 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +INDEX k1 (i1) +) ENGINE=InnoDB; +INSERT INTO t1 +SELECT a0.i0 + 10*a1.i0 + 100*a2.i0, +(a0.i0 + 10*a1.i0 + 100*a2.i0) % 50, +a0.i0 + 10*a1.i0 + 100*a2.i0 +FROM t0 AS a0, t0 AS a1, t0 AS a2; +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +INDEX k1 (i1) +) ENGINE=InnoDB; +INSERT INTO t2 +SELECT a0.i0 + 10*a1.i0 + 100*a2.i0, +(a0.i0 + 10*a1.i0 + 100*a2.i0) % 500, +a0.i0 + 10*a1.i0 + 100*a2.i0 +FROM t0 AS a0, t0 AS a1, t0 AS a2; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +# Explain should show "Using filesort" +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1=t2.i1 +WHERE t2.i2 > 3 +ORDER BY t1.i1 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL k1 NULL NULL NULL 1000 100.00 Using filesort +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t2`.`i2` > 3)) order by `test`.`t1`.`i1` limit 20 +FLUSH STATUS; +SELECT * +FROM t1 JOIN t2 ON t1.i1=t2.i1 +WHERE t2.i2 > 3 +ORDER BY t1.i1 LIMIT 20; +pk i1 i2 pk i1 i2 +0 0 0 500 0 500 +50 0 50 500 0 500 +100 0 100 500 0 500 +150 0 150 500 0 500 +200 0 200 500 0 500 +250 0 250 500 0 500 +300 0 300 500 0 500 +350 0 350 500 0 500 +400 0 400 500 0 500 +450 0 450 500 0 500 +500 0 500 500 0 500 +550 0 550 500 0 500 +600 0 600 500 0 500 +650 0 650 500 0 500 +700 0 700 500 0 500 +750 0 750 500 0 500 +800 0 800 500 0 500 +850 0 850 500 0 500 +900 0 900 500 0 500 +950 0 950 500 0 500 +# Status from execution should show that filesort was used +SHOW STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 1000 +Sort_scan 4 +DROP TABLE t0, t1, t2; +# +# Bug#30321546: OPTIMIZER TRACE SHOWS DIFFERENT ACTIONS FOR +# A QUERY IF ANOTHER QUERY RUN BEFORE +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t2 VALUES (1),(2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a, t2.a FROM t1 JOIN t2 +ON t1.a+t2.a = (SELECT COUNT(*) FROM t1); +a a +2 2 +3 1 +SET optimizer_trace="enabled=on"; +SELECT a + (SELECT SUM(a) + (SELECT COUNT(a) FROM t1) FROM t1) AS cnt +FROM t2; +cnt +15 +16 +SELECT TRACE NOT RLIKE '"final_filtering_effect": 1' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace="enabled=off"; +DROP TABLE t1, t2; diff --git a/mysql-test/r/const_folding.result-pq b/mysql-test/r/const_folding.result-pq new file mode 100644 index 000000000..07470ea82 --- /dev/null +++ b/mysql-test/r/const_folding.result-pq @@ -0,0 +1,55815 @@ +# +# Tests with UNSIGNED type TINYINT against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES (0), (1), +(0),(1),(3), +(254), (255), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 256; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 255; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 256; +colA +SELECT * FROM tinytbl WHERE colA >= 255; +colA +255 +SELECT * FROM tinytbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= -1; +colA +SELECT * FROM tinytbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 0; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 256; +colA +SELECT * FROM tinytbl WHERE colA <> 256; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 255; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> 255; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> 255); +colA +0 +1 +0 +1 +3 +254 +NULL +SELECT * FROM tinytbl WHERE colA <> 255; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> 0; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1; +colA +SELECT * FROM tinytbl WHERE colA <=> -1; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1=256; +SET @maxint=255; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 255; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbl WHERE 256 > colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 255 >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 256 < colA; +colA +SELECT * FROM tinytbl WHERE 255 <= colA; +colA +255 +SELECT * FROM tinytbl WHERE 255 < colA; +colA +SELECT * FROM tinytbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE -1 >= colA; +colA +SELECT * FROM tinytbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 0 < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 256 = colA; +colA +SELECT * FROM tinytbl WHERE 256 <=> colA; +colA +SELECT * FROM tinytbl WHERE 256 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 255 = colA; +colA +255 +SELECT * FROM tinytbl WHERE 255 <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE 255 <> colA; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE 0 <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE -1 = colA; +colA +SELECT * FROM tinytbl WHERE -1 <=> colA; +colA +SELECT * FROM tinytbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE 256 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 255 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 256 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 255 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 255 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 256 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 256 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 256 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE 255 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE 255 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 255 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT against decimal +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES (0), (1), +(0),(1),(3), +(254), (255), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.5; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5; +colA +SELECT * FROM tinytbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.5; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 255.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 255.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 255.00001; +colA +SELECT * FROM tinytbl WHERE colA >= 255.00001; +colA +SELECT * FROM tinytbl WHERE colA = 255.00001; +colA +SELECT * FROM tinytbl WHERE colA <> 255.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 254.99999; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA <= 254.99999; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA > 254.99999; +colA +255 +SELECT * FROM tinytbl WHERE colA >= 254.99999; +colA +255 +SELECT * FROM tinytbl WHERE colA = 254.99999; +colA +SELECT * FROM tinytbl WHERE colA <> 254.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 0.00001; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.00001; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.00001; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.00001; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.00001; +colA +SELECT * FROM tinytbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.99999; +colA +SELECT * FROM tinytbl WHERE colA <= -0.99999; +colA +SELECT * FROM tinytbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.99999; +colA +SELECT * FROM tinytbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=255.00001; +SET @dec_max_minus_delta=254.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +255 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type TINYINT against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES ('0'), ('1'), +(0),(1),(3), +('254'), ('255'), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < '256'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '255'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '256'; +colA +SELECT * FROM tinytbl WHERE colA >= '255'; +colA +255 +SELECT * FROM tinytbl WHERE colA > '-1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '-1'; +colA +SELECT * FROM tinytbl WHERE colA <= '0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA >= '0'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '256'; +colA +SELECT * FROM tinytbl WHERE colA <> '256'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '255'; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> '255'; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> '255'); +colA +0 +1 +0 +1 +3 +254 +NULL +SELECT * FROM tinytbl WHERE colA <> '255'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA = '0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <=> '0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> '0'); +colA +1 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '-1'; +colA +SELECT * FROM tinytbl WHERE colA <=> '-1'; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> '-1'); +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '-1'; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1='256'; +SET @maxint='255'; +SET @minint_minus_1='-1'; +SET @minint='0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '256'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '255'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbl WHERE '256' > colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255' >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256' < colA; +colA +SELECT * FROM tinytbl WHERE '255' <= colA; +colA +255 +SELECT * FROM tinytbl WHERE '255' < colA; +colA +SELECT * FROM tinytbl WHERE '-1' < colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1' >= colA; +colA +SELECT * FROM tinytbl WHERE '0' >= colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0' <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '0' < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256' = colA; +colA +SELECT * FROM tinytbl WHERE '256' <=> colA; +colA +SELECT * FROM tinytbl WHERE '256' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255' = colA; +colA +255 +SELECT * FROM tinytbl WHERE '255' <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE '255' <> colA; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE '0' = colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0' <=> colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0' <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1' = colA; +colA +SELECT * FROM tinytbl WHERE '-1' <=> colA; +colA +SELECT * FROM tinytbl WHERE '-1' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE '256' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '256' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '255' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '-1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '256' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '-1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('254.0'), ('255.0'), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < '256.1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '255.0'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '256.1'; +colA +SELECT * FROM tinytbl WHERE colA >= '255.0'; +colA +255 +SELECT * FROM tinytbl WHERE colA > '-1.1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '-1.1'; +colA +SELECT * FROM tinytbl WHERE colA <= '0.0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA >= '0.0'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '0.0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '256.1'; +colA +SELECT * FROM tinytbl WHERE colA <> '256.1'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '255.0'; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> '255.0'; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> '255.0'); +colA +0 +1 +0 +1 +3 +254 +NULL +SELECT * FROM tinytbl WHERE colA <> '255.0'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA = '0.0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <=> '0.0'; +colA +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> '0.0'); +colA +1 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '0.0'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '-1.1'; +colA +SELECT * FROM tinytbl WHERE colA <=> '-1.1'; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> '-1.1'); +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA <> '-1.1'; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1='256.1'; +SET @maxint='255.0'; +SET @minint_minus_1='-1.1'; +SET @minint='0.0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA > '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '256.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '255.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbl WHERE '256.1' > colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255.0' >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256.1' < colA; +colA +SELECT * FROM tinytbl WHERE '255.0' <= colA; +colA +255 +SELECT * FROM tinytbl WHERE '255.0' < colA; +colA +SELECT * FROM tinytbl WHERE '-1.1' < colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1.1' >= colA; +colA +SELECT * FROM tinytbl WHERE '0.0' >= colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0.0' <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '0.0' < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '256.1' = colA; +colA +SELECT * FROM tinytbl WHERE '256.1' <=> colA; +colA +SELECT * FROM tinytbl WHERE '256.1' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '255.0' = colA; +colA +255 +SELECT * FROM tinytbl WHERE '255.0' <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE '255.0' <> colA; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE '0.0' = colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0.0' <=> colA; +colA +0 +0 +SELECT * FROM tinytbl WHERE '0.0' <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE '-1.1' = colA; +colA +SELECT * FROM tinytbl WHERE '-1.1' <=> colA; +colA +SELECT * FROM tinytbl WHERE '-1.1' <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '256.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '255.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '0.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE '-1.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` is not null) +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT against decimal +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('254.0'), ('255.0'), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.5; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5; +colA +SELECT * FROM tinytbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.5; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA >= '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA = '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '254.99999'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA <= '254.99999'; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA > '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA >= '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA = '254.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '254.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '0.00001'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= '0.00001'; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '0.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '0.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <= '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA > '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta='255.00001'; +SET @dec_max_minus_delta='254.99999'; +SET @dec_min_plus_delta='0.00001'; +SET @dec_min_minus_delta='-0.99999'; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +255 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type TINYINT against reals +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED ); +INSERT INTO tinytbl VALUES (0.0E+00), (1.0E00), +(0),(1),(3), +(2.54E02), (2.55E02), +(NULL); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +NULL +SELECT * FROM tinytbl WHERE colA < 0.5E00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5E00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5E00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5E00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5E00; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.5E00; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5E00; +colA +SELECT * FROM tinytbl WHERE colA > -0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.5E00; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5E00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 255.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 255.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 255.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA >= 255.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA = 255.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 255.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 254.99999E+00; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA <= 254.99999E+00; +colA +0 +1 +0 +1 +3 +254 +SELECT * FROM tinytbl WHERE colA > 254.99999E+00; +colA +255 +SELECT * FROM tinytbl WHERE colA >= 254.99999E+00; +colA +255 +SELECT * FROM tinytbl WHERE colA = 254.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 254.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 0.00001E+00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.00001E+00; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.00001E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.00001E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.00001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 0.00001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -0.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA <= -0.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA > -0.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -0.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -0.99999E+00; +colA +SELECT * FROM tinytbl WHERE colA <> -0.99999E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001E+00; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001E+00; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <= 1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA >= 1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA = 1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA <> 1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA <= -1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA > -1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1.7976931348623157E+308; +colA +SELECT * FROM tinytbl WHERE colA <> -1.7976931348623157E+308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < 1.7976931348623157E-308; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA <= 1.7976931348623157E-308; +colA +0 +0 +SELECT * FROM tinytbl WHERE colA > 1.7976931348623157E-308; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 1.7976931348623157E-308; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA <> 1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA < -1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA <= -1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA > -1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= -1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1.7976931348623157E-308; +colA +SELECT * FROM tinytbl WHERE colA <> -1.7976931348623157E-308; +colA +0 +1 +0 +1 +3 +254 +255 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @real_0_5=0.5E00; +SET @real_minus_0_5=-0.5E00; +SET @real_max_plus_delta=255.00001E+00; +SET @real_max_minus_delta=254.99999E+00; +SET @real_min_plus_delta=0.00001E+00; +SET @real_min_minus_delta=-0.99999E+00; +SET @real_too_big_positive_for_any_int=18446744073709551615.00000001E+00; +SET @real_dec_too_big_negative_for_any_int=-9223372036854775808.00000001E+00; +SET @real_too_big_positive_for_any_decimal=1.7976931348623157E+308; +SET @real_too_big_negative_for_any_decimal=-1.7976931348623157E+308; +SET @dec_too_small_positive_for_any_int_as_real=1.7976931348623157E-308; +SET @dec_too_small_negative_for_any_int_as_real=-1.7976931348623157E-308; +SET @real_too_small_positive_for_any_decimal=1.7976931348623157E-308; +SET @real_too_small_negative_for_any_decimal=-1.7976931348623157E-308; +EXECUTE p_less USING @real_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @real_0_5; +colA +0 +0 +EXECUTE p_greater USING @real_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @real_0_5; +colA +EXECUTE p_n_equal USING @real_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_minus_0_5; +colA +EXECUTE p_less_eq USING @real_minus_0_5; +colA +EXECUTE p_greater USING @real_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_minus_0_5; +colA +EXECUTE p_n_equal USING @real_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @real_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @real_max_plus_delta; +colA +EXECUTE p_gret_eq USING @real_max_plus_delta; +colA +EXECUTE p_equal USING @real_max_plus_delta; +colA +EXECUTE p_n_equal USING @real_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_less_eq USING @real_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +EXECUTE p_greater USING @real_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @real_max_minus_delta; +colA +255 +EXECUTE p_equal USING @real_max_minus_delta; +colA +EXECUTE p_n_equal USING @real_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @real_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @real_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @real_min_plus_delta; +colA +EXECUTE p_n_equal USING @real_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_min_minus_delta; +colA +EXECUTE p_less_eq USING @real_min_minus_delta; +colA +EXECUTE p_greater USING @real_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_min_minus_delta; +colA +EXECUTE p_n_equal USING @real_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @real_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @real_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @real_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @real_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @real_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @real_dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @real_dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @real_dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_big_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less_eq USING @real_too_big_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_greater USING @real_too_big_positive_for_any_decimal; +colA +EXECUTE p_gret_eq USING @real_too_big_positive_for_any_decimal; +colA +EXECUTE p_equal USING @real_too_big_positive_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_big_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_big_negative_for_any_decimal; +colA +EXECUTE p_less_eq USING @real_too_big_negative_for_any_decimal; +colA +EXECUTE p_greater USING @real_too_big_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_too_big_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_too_big_negative_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_big_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_small_positive_for_any_decimal; +colA +0 +0 +EXECUTE p_less_eq USING @real_too_small_positive_for_any_decimal; +colA +0 +0 +EXECUTE p_greater USING @real_too_small_positive_for_any_decimal; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_too_small_positive_for_any_decimal; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @real_too_small_positive_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_small_positive_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_less USING @real_too_small_negative_for_any_decimal; +colA +EXECUTE p_less_eq USING @real_too_small_negative_for_any_decimal; +colA +EXECUTE p_greater USING @real_too_small_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @real_too_small_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +EXECUTE p_equal USING @real_too_small_negative_for_any_decimal; +colA +EXECUTE p_n_equal USING @real_too_small_negative_for_any_decimal; +colA +0 +1 +0 +1 +3 +254 +255 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT NOT NULL against int +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED NOT NULL); +INSERT INTO tinytbl VALUES (0.0E+00), (1.0E00), +(0),(1),(3), +(2.54E02), (2.55E02), +(0); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < 2.56E02; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= 2.55E02; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > 2.56E02; +colA +SELECT * FROM tinytbl WHERE colA >= 2.55E02; +colA +255 +SELECT * FROM tinytbl WHERE colA > -1.0E00; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= -1.0E00; +colA +SELECT * FROM tinytbl WHERE colA <= 0.0E+00; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA >= 0.0E+00; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > 0.0E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 2.56E02; +colA +SELECT * FROM tinytbl WHERE colA <> 2.56E02; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = 2.55E02; +colA +255 +SELECT * FROM tinytbl WHERE colA <=> 2.55E02; +colA +255 +SELECT * FROM tinytbl WHERE NOT(colA <=> 2.55E02); +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA <> 2.55E02; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA = 0.0E+00; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA <=> 0.0E+00; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE NOT(colA <=> 0.0E+00); +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA <> 0.0E+00; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = -1.0E00; +colA +SELECT * FROM tinytbl WHERE colA <=> -1.0E00; +colA +SELECT * FROM tinytbl WHERE NOT(colA <=> -1.0E00); +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <> -1.0E00; +colA +0 +1 +0 +1 +3 +254 +255 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @maxint_plus_1=2.56E02; +SET @maxint=2.55E02; +SET @minint_minus_1=-1.0E00; +SET @minint=0.0E+00; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +255 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE colA < 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA > 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA > -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA <= -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <= 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA >= 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA > 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` > 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 2.56E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE colA = 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 2.55E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 255) +EXPLAIN SELECT * FROM tinytbl WHERE colA = 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` = 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA <> 0.0E+00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (`test`.`tinytbl`.`colA` <> 0) +EXPLAIN SELECT * FROM tinytbl WHERE colA = -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <=> -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE colA <> -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +same queries but constant first +SELECT * FROM tinytbl WHERE 2.56E02 > colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 2.55E02 >= colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 2.56E02 < colA; +colA +SELECT * FROM tinytbl WHERE 2.55E02 <= colA; +colA +255 +SELECT * FROM tinytbl WHERE 2.55E02 < colA; +colA +SELECT * FROM tinytbl WHERE -1.0E00 < colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE -1.0E00 >= colA; +colA +SELECT * FROM tinytbl WHERE 0.0E+00 >= colA; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 <= colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 < colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE 2.56E02 = colA; +colA +SELECT * FROM tinytbl WHERE 2.56E02 <=> colA; +colA +SELECT * FROM tinytbl WHERE 2.56E02 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE 2.55E02 = colA; +colA +255 +SELECT * FROM tinytbl WHERE 2.55E02 <=> colA; +colA +255 +SELECT * FROM tinytbl WHERE 2.55E02 <> colA; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 = colA; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 <=> colA; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE 0.0E+00 <> colA; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE -1.0E00 = colA; +colA +SELECT * FROM tinytbl WHERE -1.0E00 <=> colA; +colA +SELECT * FROM tinytbl WHERE -1.0E00 <> colA; +colA +0 +1 +0 +1 +3 +254 +255 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +255 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_eq USING @maxint; +colA +255 +EXECUTE p_equal USING @maxint; +colA +255 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +254 +255 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +254 +255 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 < `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE 2.56E02 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 2.55E02 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (255 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 = `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <=> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE 0.0E+00 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where (0 <> `test`.`tinytbl`.`colA`) +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where false +EXPLAIN SELECT * FROM tinytbl WHERE -1.0E00 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbl`.`colA` AS `colA` from `test`.`tinytbl` where true +DROP TABLE tinytbl; +# +# Tests with UNSIGNED type TINYINT NOT NULL against decimal +# +CREATE TABLE tinytbl (colA TINYINT UNSIGNED NOT NULL); +INSERT INTO tinytbl VALUES (0.0E+00), (1.0E00), +(0),(1),(3), +(2.54E02), (2.55E02), +(0); +ANALYZE TABLE tinytbl; +Table Op Msg_type Msg_text +test.tinytbl analyze status OK +SELECT * FROM tinytbl; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < 0.5; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA <= 0.5; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA > 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= 0.5; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = 0.5; +colA +SELECT * FROM tinytbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < -0.5; +colA +SELECT * FROM tinytbl WHERE colA <= -0.5; +colA +SELECT * FROM tinytbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = -0.5; +colA +SELECT * FROM tinytbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA >= '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA = '255.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '255.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '254.99999'; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA <= '254.99999'; +colA +0 +1 +0 +1 +3 +254 +0 +SELECT * FROM tinytbl WHERE colA > '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA >= '254.99999'; +colA +255 +SELECT * FROM tinytbl WHERE colA = '254.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '254.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '0.00001'; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA <= '0.00001'; +colA +0 +0 +0 +SELECT * FROM tinytbl WHERE colA > '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA >= '0.00001'; +colA +1 +1 +3 +254 +255 +SELECT * FROM tinytbl WHERE colA = '0.00001'; +colA +SELECT * FROM tinytbl WHERE colA <> '0.00001'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <= '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA > '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA >= '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = '-0.99999'; +colA +SELECT * FROM tinytbl WHERE colA <> '-0.99999'; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +SELECT * FROM tinytbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +254 +255 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta='255.00001'; +SET @dec_max_minus_delta='254.99999'; +SET @dec_min_plus_delta='0.00001'; +SET @dec_min_minus_delta='-0.99999'; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +255 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +255 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +254 +255 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +254 +255 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type TINYINT against int +# +CREATE TABLE tinytbls (colA TINYINT ); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(NULL); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA < 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= 127; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > 128; +colA +SELECT * FROM tinytbls WHERE colA >= 127; +colA +127 +SELECT * FROM tinytbls WHERE colA > -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= -129; +colA +SELECT * FROM tinytbls WHERE colA <= -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA >= -128; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > -128; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 128; +colA +SELECT * FROM tinytbls WHERE colA <> 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 127; +colA +127 +SELECT * FROM tinytbls WHERE colA <=> 127; +colA +127 +SELECT * FROM tinytbls WHERE NOT(colA <=> 127); +colA +-128 +-127 +0 +1 +3 +126 +NULL +SELECT * FROM tinytbls WHERE colA <> 127; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE colA = -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA <=> -128; +colA +-128 +SELECT * FROM tinytbls WHERE NOT(colA <=> -128); +colA +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA <> -128; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -129; +colA +SELECT * FROM tinytbls WHERE colA <=> -129; +colA +SELECT * FROM tinytbls WHERE NOT(colA <=> -129); +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA <> -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @maxint_plus_1=128; +SET @maxint=127; +SET @minint_minus_1=-129; +SET @minint=-128; +EXECUTE p_less USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +127 +EXECUTE p_greater USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-128 +EXECUTE p_gret_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +NULL +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE colA < 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA <= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA > 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA >= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA > -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA >= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA > -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` > (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE colA = 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +same queries but constant first +SELECT * FROM tinytbls WHERE 128 > colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 127 >= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 128 < colA; +colA +SELECT * FROM tinytbls WHERE 127 <= colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 < colA; +colA +SELECT * FROM tinytbls WHERE -129 < colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE -129 >= colA; +colA +SELECT * FROM tinytbls WHERE -128 >= colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE -128 < colA; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 128 = colA; +colA +SELECT * FROM tinytbls WHERE 128 <=> colA; +colA +SELECT * FROM tinytbls WHERE 128 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE 127 = colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <=> colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE -128 = colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <=> colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <> colA; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE -129 = colA; +colA +SELECT * FROM tinytbls WHERE -129 <=> colA; +colA +SELECT * FROM tinytbls WHERE -129 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +127 +EXECUTE p_less USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-128 +EXECUTE p_less_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +NULL +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE 128 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE 127 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE 128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 127 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE -129 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -128 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE -128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) < `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +EXPLAIN SELECT * FROM tinytbls WHERE 127 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -129 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` is not null) +DROP TABLE tinytbls; +# +# Tests with type TINYINT against decimal +# +CREATE TABLE tinytbls (colA TINYINT ); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(NULL); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +NULL +SELECT * FROM tinytbls WHERE colA < 0.5; +colA +-128 +-127 +0 +SELECT * FROM tinytbls WHERE colA <= 0.5; +colA +-128 +-127 +0 +SELECT * FROM tinytbls WHERE colA > 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 0.5; +colA +SELECT * FROM tinytbls WHERE colA <> 0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA <= -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA > -0.5; +colA +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -0.5; +colA +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -0.5; +colA +SELECT * FROM tinytbls WHERE colA <> -0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > 127.00001; +colA +SELECT * FROM tinytbls WHERE colA >= 127.00001; +colA +SELECT * FROM tinytbls WHERE colA = 127.00001; +colA +SELECT * FROM tinytbls WHERE colA <> 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE colA <= 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +SELECT * FROM tinytbls WHERE colA > 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA >= 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA = 126.99999; +colA +SELECT * FROM tinytbls WHERE colA <> 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA <= -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA > -127.99999; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -127.99999; +colA +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -127.99999; +colA +SELECT * FROM tinytbls WHERE colA <> -127.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <= -128.00001; +colA +SELECT * FROM tinytbls WHERE colA > -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <> -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA <= 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA > -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=127.00001; +SET @dec_max_minus_delta=126.99999; +SET @dec_min_plus_delta=-127.99999; +SET @dec_min_minus_delta=-128.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-128 +-127 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-128 +-127 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +127 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +127 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type TINYINT NOT NULL against int +# +CREATE TABLE tinytbls (colA TINYINT NOT NULL); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(0); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= 127; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > 128; +colA +SELECT * FROM tinytbls WHERE colA >= 127; +colA +127 +SELECT * FROM tinytbls WHERE colA > -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= -129; +colA +SELECT * FROM tinytbls WHERE colA <= -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA >= -128; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > -128; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = 128; +colA +SELECT * FROM tinytbls WHERE colA <> 128; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = 127; +colA +127 +SELECT * FROM tinytbls WHERE colA <=> 127; +colA +127 +SELECT * FROM tinytbls WHERE NOT(colA <=> 127); +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA <> 127; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA = -128; +colA +-128 +SELECT * FROM tinytbls WHERE colA <=> -128; +colA +-128 +SELECT * FROM tinytbls WHERE NOT(colA <=> -128); +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <> -128; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -129; +colA +SELECT * FROM tinytbls WHERE colA <=> -129; +colA +SELECT * FROM tinytbls WHERE NOT(colA <=> -129); +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <> -129; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @maxint_plus_1=128; +SET @maxint=127; +SET @minint_minus_1=-129; +SET @minint=-128; +EXECUTE p_less USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +127 +EXECUTE p_greater USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-128 +EXECUTE p_gret_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE colA < 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA <= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA > 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA >= 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA > -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA >= -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA > -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` > (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE colA = 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> 127; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> 127) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <=> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` <> (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE colA = -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <=> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE colA <> -129; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +same queries but constant first +SELECT * FROM tinytbls WHERE 128 > colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 127 >= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 128 < colA; +colA +SELECT * FROM tinytbls WHERE 127 <= colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 < colA; +colA +SELECT * FROM tinytbls WHERE -129 < colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE -129 >= colA; +colA +SELECT * FROM tinytbls WHERE -128 >= colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <= colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE -128 < colA; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 128 = colA; +colA +SELECT * FROM tinytbls WHERE 128 <=> colA; +colA +SELECT * FROM tinytbls WHERE 128 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE 127 = colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <=> colA; +colA +127 +SELECT * FROM tinytbls WHERE 127 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE -128 = colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <=> colA; +colA +-128 +SELECT * FROM tinytbls WHERE -128 <> colA; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE -129 = colA; +colA +SELECT * FROM tinytbls WHERE -129 <=> colA; +colA +SELECT * FROM tinytbls WHERE -129 <> colA; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM tinytbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM tinytbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +127 +EXECUTE p_less USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-128 +EXECUTE p_less_eq USING @minint; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @maxint; +colA +127 +EXECUTE p_equal USING @maxint; +colA +127 +EXECUTE p_n_eq USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_n_equal USING @maxint; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_eq USING @minint; +colA +-128 +EXECUTE p_equal USING @minint; +colA +-128 +EXECUTE p_n_eq USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM tinytbls WHERE 128 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE 127 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE 128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 127 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE -129 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -128 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) = `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE -128 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) < `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE 128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +EXPLAIN SELECT * FROM tinytbls WHERE 127 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = 127) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE 127 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (127 <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where (`test`.`tinytbls`.`colA` = (-(128))) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <=> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -128 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where ((-(128)) <> `test`.`tinytbls`.`colA`) +EXPLAIN SELECT * FROM tinytbls WHERE -129 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where false +EXPLAIN SELECT * FROM tinytbls WHERE -129 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tinytbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`tinytbls`.`colA` AS `colA` from `test`.`tinytbls` where true +DROP TABLE tinytbls; +# +# Tests with type TINYINT NOT NULL against decimal +# +CREATE TABLE tinytbls (colA TINYINT NOT NULL); +INSERT INTO tinytbls VALUES (-128), (-127), +(0),(1),(3), +(126), (127), +(0); +ANALYZE TABLE tinytbls; +Table Op Msg_type Msg_text +test.tinytbls analyze status OK +SELECT * FROM tinytbls; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 0.5; +colA +-128 +-127 +0 +0 +SELECT * FROM tinytbls WHERE colA <= 0.5; +colA +-128 +-127 +0 +0 +SELECT * FROM tinytbls WHERE colA > 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA >= 0.5; +colA +1 +3 +126 +127 +SELECT * FROM tinytbls WHERE colA = 0.5; +colA +SELECT * FROM tinytbls WHERE colA <> 0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA <= -0.5; +colA +-128 +-127 +SELECT * FROM tinytbls WHERE colA > -0.5; +colA +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -0.5; +colA +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -0.5; +colA +SELECT * FROM tinytbls WHERE colA <> -0.5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > 127.00001; +colA +SELECT * FROM tinytbls WHERE colA >= 127.00001; +colA +SELECT * FROM tinytbls WHERE colA = 127.00001; +colA +SELECT * FROM tinytbls WHERE colA <> 127.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA <= 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +0 +SELECT * FROM tinytbls WHERE colA > 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA >= 126.99999; +colA +127 +SELECT * FROM tinytbls WHERE colA = 126.99999; +colA +SELECT * FROM tinytbls WHERE colA <> 126.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA <= -127.99999; +colA +-128 +SELECT * FROM tinytbls WHERE colA > -127.99999; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -127.99999; +colA +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -127.99999; +colA +SELECT * FROM tinytbls WHERE colA <> -127.99999; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <= -128.00001; +colA +SELECT * FROM tinytbls WHERE colA > -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -128.00001; +colA +SELECT * FROM tinytbls WHERE colA <> -128.00001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA <= 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> 18446744073709551615.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA > -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA >= -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +SELECT * FROM tinytbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM tinytbls WHERE colA <> -9223372036854775808.00000001; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +PREPARE p_less FROM 'SELECT * FROM tinytbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM tinytbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM tinytbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM tinytbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM tinytbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM tinytbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=127.00001; +SET @dec_max_minus_delta=126.99999; +SET @dec_min_plus_delta=-127.99999; +SET @dec_min_minus_delta=-128.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-128 +-127 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-128 +-127 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +126 +127 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-128 +-127 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +127 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +127 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-128 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-128 +-127 +0 +1 +3 +126 +127 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE tinytbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type SMALLINT against int +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED ); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(NULL); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA < 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= 65535; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 65536; +colA +SELECT * FROM smalltbl WHERE colA >= 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= -1; +colA +SELECT * FROM smalltbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 65536; +colA +SELECT * FROM smalltbl WHERE colA <> 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA <=> 65535; +colA +65535 +SELECT * FROM smalltbl WHERE NOT(colA <=> 65535); +colA +0 +1 +0 +1 +3 +65534 +NULL +SELECT * FROM smalltbl WHERE colA <> 65535; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM smalltbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA <> 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -1; +colA +SELECT * FROM smalltbl WHERE colA <=> -1; +colA +SELECT * FROM smalltbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @maxint_plus_1=65536; +SET @maxint=65535; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +65535 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE colA < 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA > 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` > 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +same queries but constant first +SELECT * FROM smalltbl WHERE 65536 > colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65535 >= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65536 < colA; +colA +SELECT * FROM smalltbl WHERE 65535 <= colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 < colA; +colA +SELECT * FROM smalltbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE -1 >= colA; +colA +SELECT * FROM smalltbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM smalltbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 0 < colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65536 = colA; +colA +SELECT * FROM smalltbl WHERE 65536 <=> colA; +colA +SELECT * FROM smalltbl WHERE 65536 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65535 = colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <=> colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <> colA; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM smalltbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM smalltbl WHERE 0 <> colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE -1 = colA; +colA +SELECT * FROM smalltbl WHERE -1 <=> colA; +colA +SELECT * FROM smalltbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +65535 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE 65536 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 65536 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 < `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65536 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` is not null) +DROP TABLE smalltbl; +# +# Tests with UNSIGNED type SMALLINT against decimal +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED ); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(NULL); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +NULL +SELECT * FROM smalltbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.5; +colA +SELECT * FROM smalltbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < -0.5; +colA +SELECT * FROM smalltbl WHERE colA <= -0.5; +colA +SELECT * FROM smalltbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -0.5; +colA +SELECT * FROM smalltbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA >= 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA = 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE colA <= 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +SELECT * FROM smalltbl WHERE colA > 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA >= 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA = 65534.99999; +colA +SELECT * FROM smalltbl WHERE colA <> 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 0.00001; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.00001; +colA +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <= -0.99999; +colA +SELECT * FROM smalltbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=65535.00001; +SET @dec_max_minus_delta=65534.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type SMALLINT NOT NULL against int +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED NOT NULL); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(0); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= 65535; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 65536; +colA +SELECT * FROM smalltbl WHERE colA >= 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= -1; +colA +SELECT * FROM smalltbl WHERE colA <= 0; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 65536; +colA +SELECT * FROM smalltbl WHERE colA <> 65536; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = 65535; +colA +65535 +SELECT * FROM smalltbl WHERE colA <=> 65535; +colA +65535 +SELECT * FROM smalltbl WHERE NOT(colA <=> 65535); +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA <> 65535; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA = 0; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA <=> 0; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA <> 0; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = -1; +colA +SELECT * FROM smalltbl WHERE colA <=> -1; +colA +SELECT * FROM smalltbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @maxint_plus_1=65536; +SET @maxint=65535; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +65535 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE colA < 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA > 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` > 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65536; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE colA = 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 65535; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 65535) +EXPLAIN SELECT * FROM smalltbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` <> 0) +EXPLAIN SELECT * FROM smalltbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +same queries but constant first +SELECT * FROM smalltbl WHERE 65536 > colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 65535 >= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 65536 < colA; +colA +SELECT * FROM smalltbl WHERE 65535 <= colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 < colA; +colA +SELECT * FROM smalltbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE -1 >= colA; +colA +SELECT * FROM smalltbl WHERE 0 >= colA; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 0 < colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE 65536 = colA; +colA +SELECT * FROM smalltbl WHERE 65536 <=> colA; +colA +SELECT * FROM smalltbl WHERE 65536 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE 65535 = colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <=> colA; +colA +65535 +SELECT * FROM smalltbl WHERE 65535 <> colA; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE 0 = colA; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE 0 <=> colA; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE 0 <> colA; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE -1 = colA; +colA +SELECT * FROM smalltbl WHERE -1 <=> colA; +colA +SELECT * FROM smalltbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +65535 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_eq USING @maxint; +colA +65535 +EXECUTE p_equal USING @maxint; +colA +65535 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbl WHERE 65536 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 65535 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 65536 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 = `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 < `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65536 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE 65536 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +EXPLAIN SELECT * FROM smalltbl WHERE 65535 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 65535) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 65535 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (65535 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (`test`.`smalltbl`.`colA` = 0) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <=> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where (0 <> `test`.`smalltbl`.`colA`) +EXPLAIN SELECT * FROM smalltbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where false +EXPLAIN SELECT * FROM smalltbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbl`.`colA` AS `colA` from `test`.`smalltbl` where true +DROP TABLE smalltbl; +# +# Tests with UNSIGNED type SMALLINT NOT NULL against decimal +# +CREATE TABLE smalltbl (colA SMALLINT UNSIGNED NOT NULL); +INSERT INTO smalltbl VALUES (0), (1), +(0),(1),(3), +(65534), (65535), +(0); +ANALYZE TABLE smalltbl; +Table Op Msg_type Msg_text +test.smalltbl analyze status OK +SELECT * FROM smalltbl; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 0.5; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.5; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.5; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.5; +colA +SELECT * FROM smalltbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < -0.5; +colA +SELECT * FROM smalltbl WHERE colA <= -0.5; +colA +SELECT * FROM smalltbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = -0.5; +colA +SELECT * FROM smalltbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA >= 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA = 65535.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 65535.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA <= 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +0 +SELECT * FROM smalltbl WHERE colA > 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA >= 65534.99999; +colA +65535 +SELECT * FROM smalltbl WHERE colA = 65534.99999; +colA +SELECT * FROM smalltbl WHERE colA <> 65534.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 0.00001; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA <= 0.00001; +colA +0 +0 +0 +SELECT * FROM smalltbl WHERE colA > 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA >= 0.00001; +colA +1 +1 +3 +65534 +65535 +SELECT * FROM smalltbl WHERE colA = 0.00001; +colA +SELECT * FROM smalltbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <= -0.99999; +colA +SELECT * FROM smalltbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = -0.99999; +colA +SELECT * FROM smalltbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +SELECT * FROM smalltbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=65535.00001; +SET @dec_max_minus_delta=65534.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +65535 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +65534 +65535 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +65534 +65535 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type SMALLINT against int +# +CREATE TABLE smalltbls (colA SMALLINT ); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(NULL); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA < 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > 32768; +colA +SELECT * FROM smalltbls WHERE colA >= 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA > -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= -32769; +colA +SELECT * FROM smalltbls WHERE colA <= -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA >= -32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 32768; +colA +SELECT * FROM smalltbls WHERE colA <> 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA <=> 32767; +colA +32767 +SELECT * FROM smalltbls WHERE NOT(colA <=> 32767); +colA +-32768 +-32767 +0 +1 +3 +32766 +NULL +SELECT * FROM smalltbls WHERE colA <> 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE colA = -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <=> -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE NOT(colA <=> -32768); +colA +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA <> -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -32769; +colA +SELECT * FROM smalltbls WHERE colA <=> -32769; +colA +SELECT * FROM smalltbls WHERE NOT(colA <=> -32769); +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA <> -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @maxint_plus_1=32768; +SET @maxint=32767; +SET @minint_minus_1=-32769; +SET @minint=-32768; +EXECUTE p_less USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +32767 +EXECUTE p_greater USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-32768 +EXECUTE p_gret_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +NULL +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE colA < 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA <= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA > 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA >= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA >= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` > (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +same queries but constant first +SELECT * FROM smalltbls WHERE 32768 > colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32767 >= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32768 < colA; +colA +SELECT * FROM smalltbls WHERE 32767 <= colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 < colA; +colA +SELECT * FROM smalltbls WHERE -32769 < colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE -32769 >= colA; +colA +SELECT * FROM smalltbls WHERE -32768 >= colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE -32768 < colA; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32768 = colA; +colA +SELECT * FROM smalltbls WHERE 32768 <=> colA; +colA +SELECT * FROM smalltbls WHERE 32768 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE 32767 = colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <=> colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE -32768 = colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <=> colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <> colA; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE -32769 = colA; +colA +SELECT * FROM smalltbls WHERE -32769 <=> colA; +colA +SELECT * FROM smalltbls WHERE -32769 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +32767 +EXECUTE p_less USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-32768 +EXECUTE p_less_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +NULL +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE 32768 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE 32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE -32769 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32768 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) < `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32769 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` is not null) +DROP TABLE smalltbls; +# +# Tests with type SMALLINT against decimal +# +CREATE TABLE smalltbls (colA SMALLINT ); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(NULL); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +NULL +SELECT * FROM smalltbls WHERE colA < 0.5; +colA +-32768 +-32767 +0 +SELECT * FROM smalltbls WHERE colA <= 0.5; +colA +-32768 +-32767 +0 +SELECT * FROM smalltbls WHERE colA > 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 0.5; +colA +SELECT * FROM smalltbls WHERE colA <> 0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA <= -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA > -0.5; +colA +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -0.5; +colA +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -0.5; +colA +SELECT * FROM smalltbls WHERE colA <> -0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA >= 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA = 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA <> 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE colA <= 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +SELECT * FROM smalltbls WHERE colA > 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA >= 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA = 32766.99999; +colA +SELECT * FROM smalltbls WHERE colA <> 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <= -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA > -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -32767.99999; +colA +SELECT * FROM smalltbls WHERE colA <> -32767.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <= -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA > -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <> -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA <= 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA > -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=32767.00001; +SET @dec_max_minus_delta=32766.99999; +SET @dec_min_plus_delta=-32767.99999; +SET @dec_min_minus_delta=-32768.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-32768 +-32767 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-32768 +-32767 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type SMALLINT NOT NULL against int +# +CREATE TABLE smalltbls (colA SMALLINT NOT NULL); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(0); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > 32768; +colA +SELECT * FROM smalltbls WHERE colA >= 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA > -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= -32769; +colA +SELECT * FROM smalltbls WHERE colA <= -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA >= -32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = 32768; +colA +SELECT * FROM smalltbls WHERE colA <> 32768; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = 32767; +colA +32767 +SELECT * FROM smalltbls WHERE colA <=> 32767; +colA +32767 +SELECT * FROM smalltbls WHERE NOT(colA <=> 32767); +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA <> 32767; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA = -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <=> -32768; +colA +-32768 +SELECT * FROM smalltbls WHERE NOT(colA <=> -32768); +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <> -32768; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -32769; +colA +SELECT * FROM smalltbls WHERE colA <=> -32769; +colA +SELECT * FROM smalltbls WHERE NOT(colA <=> -32769); +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <> -32769; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @maxint_plus_1=32768; +SET @maxint=32767; +SET @minint_minus_1=-32769; +SET @minint=-32768; +EXECUTE p_less USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +32767 +EXECUTE p_greater USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-32768 +EXECUTE p_gret_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE colA < 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA <= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA > 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA >= 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA >= -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA > -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` > (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE colA = 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> 32767; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> 32767) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <=> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32768; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` <> (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE colA = -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <=> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE colA <> -32769; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +same queries but constant first +SELECT * FROM smalltbls WHERE 32768 > colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32767 >= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32768 < colA; +colA +SELECT * FROM smalltbls WHERE 32767 <= colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 < colA; +colA +SELECT * FROM smalltbls WHERE -32769 < colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE -32769 >= colA; +colA +SELECT * FROM smalltbls WHERE -32768 >= colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <= colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE -32768 < colA; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32768 = colA; +colA +SELECT * FROM smalltbls WHERE 32768 <=> colA; +colA +SELECT * FROM smalltbls WHERE 32768 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE 32767 = colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <=> colA; +colA +32767 +SELECT * FROM smalltbls WHERE 32767 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE -32768 = colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <=> colA; +colA +-32768 +SELECT * FROM smalltbls WHERE -32768 <> colA; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE -32769 = colA; +colA +SELECT * FROM smalltbls WHERE -32769 <=> colA; +colA +SELECT * FROM smalltbls WHERE -32769 <> colA; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM smalltbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM smalltbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +32767 +EXECUTE p_less USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-32768 +EXECUTE p_less_eq USING @minint; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @maxint; +colA +32767 +EXECUTE p_equal USING @maxint; +colA +32767 +EXECUTE p_n_eq USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_n_equal USING @maxint; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_eq USING @minint; +colA +-32768 +EXECUTE p_equal USING @minint; +colA +-32768 +EXECUTE p_n_eq USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM smalltbls WHERE 32768 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE 32767 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE 32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE -32769 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32768 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) = `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE -32768 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) < `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE 32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +EXPLAIN SELECT * FROM smalltbls WHERE 32767 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = 32767) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE 32767 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (32767 <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where (`test`.`smalltbls`.`colA` = (-(32768))) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <=> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32768 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where ((-(32768)) <> `test`.`smalltbls`.`colA`) +EXPLAIN SELECT * FROM smalltbls WHERE -32769 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where false +EXPLAIN SELECT * FROM smalltbls WHERE -32769 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE smalltbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`smalltbls`.`colA` AS `colA` from `test`.`smalltbls` where true +DROP TABLE smalltbls; +# +# Tests with type SMALLINT NOT NULL against decimal +# +CREATE TABLE smalltbls (colA SMALLINT NOT NULL); +INSERT INTO smalltbls VALUES (-32768), (-32767), +(0),(1),(3), +(32766), (32767), +(0); +ANALYZE TABLE smalltbls; +Table Op Msg_type Msg_text +test.smalltbls analyze status OK +SELECT * FROM smalltbls; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 0.5; +colA +-32768 +-32767 +0 +0 +SELECT * FROM smalltbls WHERE colA <= 0.5; +colA +-32768 +-32767 +0 +0 +SELECT * FROM smalltbls WHERE colA > 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA >= 0.5; +colA +1 +3 +32766 +32767 +SELECT * FROM smalltbls WHERE colA = 0.5; +colA +SELECT * FROM smalltbls WHERE colA <> 0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA <= -0.5; +colA +-32768 +-32767 +SELECT * FROM smalltbls WHERE colA > -0.5; +colA +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -0.5; +colA +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -0.5; +colA +SELECT * FROM smalltbls WHERE colA <> -0.5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA >= 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA = 32767.00001; +colA +SELECT * FROM smalltbls WHERE colA <> 32767.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA <= 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +SELECT * FROM smalltbls WHERE colA > 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA >= 32766.99999; +colA +32767 +SELECT * FROM smalltbls WHERE colA = 32766.99999; +colA +SELECT * FROM smalltbls WHERE colA <> 32766.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA <= -32767.99999; +colA +-32768 +SELECT * FROM smalltbls WHERE colA > -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -32767.99999; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -32767.99999; +colA +SELECT * FROM smalltbls WHERE colA <> -32767.99999; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <= -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA > -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -32768.00001; +colA +SELECT * FROM smalltbls WHERE colA <> -32768.00001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA <= 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> 18446744073709551615.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA > -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA >= -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +SELECT * FROM smalltbls WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM smalltbls WHERE colA <> -9223372036854775808.00000001; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +PREPARE p_less FROM 'SELECT * FROM smalltbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM smalltbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM smalltbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM smalltbls WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM smalltbls WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM smalltbls WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=32767.00001; +SET @dec_max_minus_delta=32766.99999; +SET @dec_min_plus_delta=-32767.99999; +SET @dec_min_minus_delta=-32768.00001; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +-32768 +-32767 +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +-32768 +-32767 +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +3 +32766 +32767 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +-32768 +-32767 +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +0 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +32767 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +-32768 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +-32768 +-32767 +0 +1 +3 +32766 +32767 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE smalltbls; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type MEDIUMINT against int +# +CREATE TABLE mediumtbl (colA MEDIUMINT UNSIGNED ); +INSERT INTO mediumtbl VALUES (0), (1), +(0),(1),(3), +(16777214), (16777215), +(NULL); +ANALYZE TABLE mediumtbl; +Table Op Msg_type Msg_text +test.mediumtbl analyze status OK +SELECT * FROM mediumtbl; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +SELECT * FROM mediumtbl WHERE colA < 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA <= 16777215; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA > 16777216; +colA +SELECT * FROM mediumtbl WHERE colA >= 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA <= -1; +colA +SELECT * FROM mediumtbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM mediumtbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA > 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = 16777216; +colA +SELECT * FROM mediumtbl WHERE colA <> 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA <=> 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 16777215); +colA +0 +1 +0 +1 +3 +16777214 +NULL +SELECT * FROM mediumtbl WHERE colA <> 16777215; +colA +0 +1 +0 +1 +3 +16777214 +SELECT * FROM mediumtbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM mediumtbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +16777214 +16777215 +NULL +SELECT * FROM mediumtbl WHERE colA <> 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = -1; +colA +SELECT * FROM mediumtbl WHERE colA <=> -1; +colA +SELECT * FROM mediumtbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +SELECT * FROM mediumtbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE colA <> ?'; +SET @maxint_plus_1=16777216; +SET @maxint=16777215; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +16777215 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE colA < 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` > 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +same queries but constant first +SELECT * FROM mediumtbl WHERE 16777216 > colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777215 >= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777216 < colA; +colA +SELECT * FROM mediumtbl WHERE 16777215 <= colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 < colA; +colA +SELECT * FROM mediumtbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE -1 >= colA; +colA +SELECT * FROM mediumtbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM mediumtbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 0 < colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777216 = colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777215 = colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +SELECT * FROM mediumtbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM mediumtbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM mediumtbl WHERE 0 <> colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE -1 = colA; +colA +SELECT * FROM mediumtbl WHERE -1 <=> colA; +colA +SELECT * FROM mediumtbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +16777215 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 < `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` is not null) +DROP TABLE mediumtbl; +# +# Tests with UNSIGNED type MEDIUMINT NOT NULL against int +# +CREATE TABLE mediumtbl (colA MEDIUMINT UNSIGNED NOT NULL); +INSERT INTO mediumtbl VALUES (0), (1), +(0),(1),(3), +(16777214), (16777215), +(0); +ANALYZE TABLE mediumtbl; +Table Op Msg_type Msg_text +test.mediumtbl analyze status OK +SELECT * FROM mediumtbl; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA < 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA <= 16777215; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA > 16777216; +colA +SELECT * FROM mediumtbl WHERE colA >= 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA <= -1; +colA +SELECT * FROM mediumtbl WHERE colA <= 0; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA > 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = 16777216; +colA +SELECT * FROM mediumtbl WHERE colA <> 16777216; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA = 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE colA <=> 16777215; +colA +16777215 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 16777215); +colA +0 +1 +0 +1 +3 +16777214 +0 +SELECT * FROM mediumtbl WHERE colA <> 16777215; +colA +0 +1 +0 +1 +3 +16777214 +0 +SELECT * FROM mediumtbl WHERE colA = 0; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE colA <=> 0; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA <> 0; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE colA = -1; +colA +SELECT * FROM mediumtbl WHERE colA <=> -1; +colA +SELECT * FROM mediumtbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE colA <> ?'; +SET @maxint_plus_1=16777216; +SET @maxint=16777215; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +16777215 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE colA < 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` > 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777216; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 16777215; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` <> 0) +EXPLAIN SELECT * FROM mediumtbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +same queries but constant first +SELECT * FROM mediumtbl WHERE 16777216 > colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 16777215 >= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 16777216 < colA; +colA +SELECT * FROM mediumtbl WHERE 16777215 <= colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 < colA; +colA +SELECT * FROM mediumtbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE -1 >= colA; +colA +SELECT * FROM mediumtbl WHERE 0 >= colA; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 0 < colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE 16777216 = colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +colA +SELECT * FROM mediumtbl WHERE 16777216 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +SELECT * FROM mediumtbl WHERE 16777215 = colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +colA +16777215 +SELECT * FROM mediumtbl WHERE 16777215 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +0 +SELECT * FROM mediumtbl WHERE 0 = colA; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE 0 <=> colA; +colA +0 +0 +0 +SELECT * FROM mediumtbl WHERE 0 <> colA; +colA +1 +1 +3 +16777214 +16777215 +SELECT * FROM mediumtbl WHERE -1 = colA; +colA +SELECT * FROM mediumtbl WHERE -1 <=> colA; +colA +SELECT * FROM mediumtbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +16777215 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_eq USING @maxint; +colA +16777215 +EXECUTE p_equal USING @maxint; +colA +16777215 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +16777214 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +16777214 +16777215 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +16777214 +16777215 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 = `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 < `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE 16777216 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 16777215) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 16777215 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (16777215 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (`test`.`mediumtbl`.`colA` = 0) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <=> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where (0 <> `test`.`mediumtbl`.`colA`) +EXPLAIN SELECT * FROM mediumtbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where false +EXPLAIN SELECT * FROM mediumtbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbl`.`colA` AS `colA` from `test`.`mediumtbl` where true +DROP TABLE mediumtbl; +# +# Tests with type MEDIUMINT against int +# +CREATE TABLE mediumtbls (colA MEDIUMINT ); +INSERT INTO mediumtbls VALUES (-8388608), (-8388607), +(0),(1),(3), +(8388606), (8388607), +(NULL); +ANALYZE TABLE mediumtbls; +Table Op Msg_type Msg_text +test.mediumtbls analyze status OK +SELECT * FROM mediumtbls; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +SELECT * FROM mediumtbls WHERE colA < 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA <= 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA > 8388608; +colA +SELECT * FROM mediumtbls WHERE colA >= 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA > -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA <= -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <= -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA >= -8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA > -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA = 8388608; +colA +SELECT * FROM mediumtbls WHERE colA <> 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA = 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA <=> 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE NOT(colA <=> 8388607); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +NULL +SELECT * FROM mediumtbls WHERE colA <> 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +SELECT * FROM mediumtbls WHERE colA = -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA <=> -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388608); +colA +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +SELECT * FROM mediumtbls WHERE colA <> -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE colA = -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <=> -8388609; +colA +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388609); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +SELECT * FROM mediumtbls WHERE colA <> -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE colA <> ?'; +SET @maxint_plus_1=8388608; +SET @maxint=8388607; +SET @minint_minus_1=-8388609; +SET @minint=-8388608; +EXECUTE p_less USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +8388607 +EXECUTE p_greater USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-8388608 +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_greater USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +NULL +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE colA < 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` > (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +same queries but constant first +SELECT * FROM mediumtbls WHERE 8388608 > colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388607 >= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388608 < colA; +colA +SELECT * FROM mediumtbls WHERE 8388607 <= colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 < colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 < colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE -8388609 >= colA; +colA +SELECT * FROM mediumtbls WHERE -8388608 >= colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE -8388608 < colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388608 = colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE 8388607 = colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +SELECT * FROM mediumtbls WHERE -8388608 = colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <> colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +SELECT * FROM mediumtbls WHERE -8388609 = colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_gret_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +8388607 +EXECUTE p_less USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +EXECUTE p_less_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_less USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +NULL +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) < `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` is not null) +DROP TABLE mediumtbls; +# +# Tests with type MEDIUMINT NOT NULL against int +# +CREATE TABLE mediumtbls (colA MEDIUMINT NOT NULL); +INSERT INTO mediumtbls VALUES (-8388608), (-8388607), +(0),(1),(3), +(8388606), (8388607), +(0); +ANALYZE TABLE mediumtbls; +Table Op Msg_type Msg_text +test.mediumtbls analyze status OK +SELECT * FROM mediumtbls; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA < 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <= 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA > 8388608; +colA +SELECT * FROM mediumtbls WHERE colA >= 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA > -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <= -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <= -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA >= -8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA > -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA = 8388608; +colA +SELECT * FROM mediumtbls WHERE colA <> 8388608; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA = 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE colA <=> 8388607; +colA +8388607 +SELECT * FROM mediumtbls WHERE NOT(colA <=> 8388607); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +SELECT * FROM mediumtbls WHERE colA <> 8388607; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +SELECT * FROM mediumtbls WHERE colA = -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE colA <=> -8388608; +colA +-8388608 +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388608); +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <> -8388608; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA = -8388609; +colA +SELECT * FROM mediumtbls WHERE colA <=> -8388609; +colA +SELECT * FROM mediumtbls WHERE NOT(colA <=> -8388609); +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE colA <> -8388609; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE colA <> ?'; +SET @maxint_plus_1=8388608; +SET @maxint=8388607; +SET @minint_minus_1=-8388609; +SET @minint=-8388608; +EXECUTE p_less USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +8388607 +EXECUTE p_greater USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-8388608 +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_greater USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE colA < 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA > 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA >= -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA > -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` > (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE colA = 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> 8388607; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <=> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388608; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` <> (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE colA = -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <=> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE colA <> -8388609; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +same queries but constant first +SELECT * FROM mediumtbls WHERE 8388608 > colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388607 >= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388608 < colA; +colA +SELECT * FROM mediumtbls WHERE 8388607 <= colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 < colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 < colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE -8388609 >= colA; +colA +SELECT * FROM mediumtbls WHERE -8388608 >= colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <= colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE -8388608 < colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388608 = colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +colA +SELECT * FROM mediumtbls WHERE 8388608 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE 8388607 = colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +colA +8388607 +SELECT * FROM mediumtbls WHERE 8388607 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +SELECT * FROM mediumtbls WHERE -8388608 = colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +colA +-8388608 +SELECT * FROM mediumtbls WHERE -8388608 <> colA; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +SELECT * FROM mediumtbls WHERE -8388609 = colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +colA +SELECT * FROM mediumtbls WHERE -8388609 <> colA; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +PREPARE p_less FROM 'SELECT * FROM mediumtbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM mediumtbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM mediumtbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM mediumtbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM mediumtbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM mediumtbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM mediumtbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM mediumtbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +8388607 +EXECUTE p_less USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-8388608 +EXECUTE p_less_eq USING @minint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_less USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @maxint; +colA +8388607 +EXECUTE p_equal USING @maxint; +colA +8388607 +EXECUTE p_n_eq USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_n_equal USING @maxint; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +0 +EXECUTE p_eq USING @minint; +colA +-8388608 +EXECUTE p_equal USING @minint; +colA +-8388608 +EXECUTE p_n_eq USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint; +colA +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-8388608 +-8388607 +0 +1 +3 +8388606 +8388607 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) = `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) < `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE 8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = 8388607) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE 8388607 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (8388607 <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where (`test`.`mediumtbls`.`colA` = (-(8388608))) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <=> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388608 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where ((-(8388608)) <> `test`.`mediumtbls`.`colA`) +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where false +EXPLAIN SELECT * FROM mediumtbls WHERE -8388609 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE mediumtbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`mediumtbls`.`colA` AS `colA` from `test`.`mediumtbls` where true +DROP TABLE mediumtbls; +# +# Tests with UNSIGNED type INT against int +# +CREATE TABLE inttbl (colA INT UNSIGNED ); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(4294967294), (4294967295), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +SELECT * FROM inttbl WHERE colA < 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA <= 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA > 4294967296; +colA +SELECT * FROM inttbl WHERE colA >= 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA <= -1; +colA +SELECT * FROM inttbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA > 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = 4294967296; +colA +SELECT * FROM inttbl WHERE colA <> 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA <=> 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE NOT(colA <=> 4294967295); +colA +0 +1 +0 +1 +3 +4294967294 +NULL +SELECT * FROM inttbl WHERE colA <> 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +SELECT * FROM inttbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +4294967294 +4294967295 +NULL +SELECT * FROM inttbl WHERE colA <> 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = -1; +colA +SELECT * FROM inttbl WHERE colA <=> -1; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +SELECT * FROM inttbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1=4294967296; +SET @maxint=4294967295; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +4294967295 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE 4294967296 > colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967295 >= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967296 < colA; +colA +SELECT * FROM inttbl WHERE 4294967295 <= colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 < colA; +colA +SELECT * FROM inttbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE -1 >= colA; +colA +SELECT * FROM inttbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 0 < colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967296 = colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <=> colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967295 = colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <=> colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +SELECT * FROM inttbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <> colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE -1 = colA; +colA +SELECT * FROM inttbl WHERE -1 <=> colA; +colA +SELECT * FROM inttbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +4294967295 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type INT NOT NULL against int +# +CREATE TABLE inttbl (colA INT UNSIGNED NOT NULL); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(4294967294), (4294967295), +(0); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA < 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA <= 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA > 4294967296; +colA +SELECT * FROM inttbl WHERE colA >= 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA <= -1; +colA +SELECT * FROM inttbl WHERE colA <= 0; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA > 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = 4294967296; +colA +SELECT * FROM inttbl WHERE colA <> 4294967296; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA = 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE colA <=> 4294967295; +colA +4294967295 +SELECT * FROM inttbl WHERE NOT(colA <=> 4294967295); +colA +0 +1 +0 +1 +3 +4294967294 +0 +SELECT * FROM inttbl WHERE colA <> 4294967295; +colA +0 +1 +0 +1 +3 +4294967294 +0 +SELECT * FROM inttbl WHERE colA = 0; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA <=> 0; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA <> 0; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE colA = -1; +colA +SELECT * FROM inttbl WHERE colA <=> -1; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1=4294967296; +SET @maxint=4294967295; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +4294967295 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA = 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 4294967295; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +same queries but constant first +SELECT * FROM inttbl WHERE 4294967296 > colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 4294967295 >= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 4294967296 < colA; +colA +SELECT * FROM inttbl WHERE 4294967295 <= colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 < colA; +colA +SELECT * FROM inttbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE -1 >= colA; +colA +SELECT * FROM inttbl WHERE 0 >= colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 0 < colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE 4294967296 = colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <=> colA; +colA +SELECT * FROM inttbl WHERE 4294967296 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +SELECT * FROM inttbl WHERE 4294967295 = colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <=> colA; +colA +4294967295 +SELECT * FROM inttbl WHERE 4294967295 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +0 +SELECT * FROM inttbl WHERE 0 = colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE 0 <=> colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE 0 <> colA; +colA +1 +1 +3 +4294967294 +4294967295 +SELECT * FROM inttbl WHERE -1 = colA; +colA +SELECT * FROM inttbl WHERE -1 <=> colA; +colA +SELECT * FROM inttbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +4294967295 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_eq USING @maxint; +colA +4294967295 +EXECUTE p_equal USING @maxint; +colA +4294967295 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +4294967294 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +4294967294 +4294967295 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +4294967294 +4294967295 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 4294967296 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 4294967295) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 4294967295 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (4294967295 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +DROP TABLE inttbl; +# +# Tests with type INT against int +# +CREATE TABLE inttbls (colA INT ); +INSERT INTO inttbls VALUES (-2147483648), (-2147483647), +(0),(1),(3), +(2147483646), (2147483647), +(NULL); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +SELECT * FROM inttbls WHERE colA < 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA <= 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA > 2147483648; +colA +SELECT * FROM inttbls WHERE colA >= 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA > -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA <= -2147483649; +colA +SELECT * FROM inttbls WHERE colA <= -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA >= -2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA > -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA = 2147483648; +colA +SELECT * FROM inttbls WHERE colA <> 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA = 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA <=> 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE NOT(colA <=> 2147483647); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +NULL +SELECT * FROM inttbls WHERE colA <> 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +SELECT * FROM inttbls WHERE colA = -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA <=> -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483648); +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +SELECT * FROM inttbls WHERE colA <> -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE colA = -2147483649; +colA +SELECT * FROM inttbls WHERE colA <=> -2147483649; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483649); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +SELECT * FROM inttbls WHERE colA <> -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=2147483648; +SET @maxint=2147483647; +SET @minint_minus_1=-2147483649; +SET @minint=-2147483648; +EXECUTE p_less USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +2147483647 +EXECUTE p_greater USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_greater USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +NULL +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbls WHERE 2147483648 > colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483647 >= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483648 < colA; +colA +SELECT * FROM inttbls WHERE 2147483647 <= colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 < colA; +colA +SELECT * FROM inttbls WHERE -2147483649 < colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE -2147483649 >= colA; +colA +SELECT * FROM inttbls WHERE -2147483648 >= colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE -2147483648 < colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483648 = colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <=> colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE 2147483647 = colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <=> colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +SELECT * FROM inttbls WHERE -2147483648 = colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <=> colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <> colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +SELECT * FROM inttbls WHERE -2147483649 = colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <=> colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_gret_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +2147483647 +EXECUTE p_less USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_less USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +NULL +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +DROP TABLE inttbls; +# +# Tests with type INT NOT NULL against int +# +CREATE TABLE inttbls (colA INT NOT NULL); +INSERT INTO inttbls VALUES (-2147483648), (-2147483647), +(0),(1),(3), +(2147483646), (2147483647), +(0); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA < 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <= 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA > 2147483648; +colA +SELECT * FROM inttbls WHERE colA >= 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA > -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <= -2147483649; +colA +SELECT * FROM inttbls WHERE colA <= -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA >= -2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA > -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA = 2147483648; +colA +SELECT * FROM inttbls WHERE colA <> 2147483648; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA = 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE colA <=> 2147483647; +colA +2147483647 +SELECT * FROM inttbls WHERE NOT(colA <=> 2147483647); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +SELECT * FROM inttbls WHERE colA <> 2147483647; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +SELECT * FROM inttbls WHERE colA = -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE colA <=> -2147483648; +colA +-2147483648 +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483648); +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <> -2147483648; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA = -2147483649; +colA +SELECT * FROM inttbls WHERE colA <=> -2147483649; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -2147483649); +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE colA <> -2147483649; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=2147483648; +SET @maxint=2147483647; +SET @minint_minus_1=-2147483649; +SET @minint=-2147483648; +EXECUTE p_less USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +2147483647 +EXECUTE p_greater USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_greater USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA = 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 2147483647; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483648; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE colA = -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -2147483649; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +same queries but constant first +SELECT * FROM inttbls WHERE 2147483648 > colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483647 >= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483648 < colA; +colA +SELECT * FROM inttbls WHERE 2147483647 <= colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 < colA; +colA +SELECT * FROM inttbls WHERE -2147483649 < colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE -2147483649 >= colA; +colA +SELECT * FROM inttbls WHERE -2147483648 >= colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <= colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE -2147483648 < colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483648 = colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <=> colA; +colA +SELECT * FROM inttbls WHERE 2147483648 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE 2147483647 = colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <=> colA; +colA +2147483647 +SELECT * FROM inttbls WHERE 2147483647 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +SELECT * FROM inttbls WHERE -2147483648 = colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <=> colA; +colA +-2147483648 +SELECT * FROM inttbls WHERE -2147483648 <> colA; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +SELECT * FROM inttbls WHERE -2147483649 = colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <=> colA; +colA +SELECT * FROM inttbls WHERE -2147483649 <> colA; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +2147483647 +EXECUTE p_less USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-2147483648 +EXECUTE p_less_eq USING @minint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_less USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @maxint; +colA +2147483647 +EXECUTE p_equal USING @maxint; +colA +2147483647 +EXECUTE p_n_eq USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_n_equal USING @maxint; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +0 +EXECUTE p_eq USING @minint; +colA +-2147483648 +EXECUTE p_equal USING @minint; +colA +-2147483648 +EXECUTE p_n_eq USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint; +colA +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-2147483648 +-2147483647 +0 +1 +3 +2147483646 +2147483647 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 2147483647) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 2147483647 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (2147483647 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = (-(2147483648))) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483648 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where ((-(2147483648)) <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -2147483649 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +DROP TABLE inttbls; +# +# Tests with UNSIGNED type BIGINT against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(18446744073709551614), (18446744073709551615), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < 18446744073709551616; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551616; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > -1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= -1; +colA +SELECT * FROM inttbl WHERE colA <= 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= 0; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 0; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 18446744073709551616; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551616; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 18446744073709551615; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> 18446744073709551615; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> 18446744073709551615); +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +SELECT * FROM inttbl WHERE colA <> 18446744073709551615; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA = 0; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> 0; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> 0); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> 0; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -1; +colA +SELECT * FROM inttbl WHERE colA <=> -1; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> -1); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> -1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1=18446744073709551616; +SET @maxint=18446744073709551615; +SET @minint_minus_1=-1; +SET @minint=0; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> 18446744073709551616; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 18446744073709551615; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE 18446744073709551616 > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551616 < colA; +colA +SELECT * FROM inttbl WHERE 18446744073709551615 <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 < colA; +colA +SELECT * FROM inttbl WHERE -1 < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE -1 >= colA; +colA +SELECT * FROM inttbl WHERE 0 >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 0 < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551616 = colA; +colA +SELECT * FROM inttbl WHERE 18446744073709551616 <=> colA; +colA +SELECT * FROM inttbl WHERE 18446744073709551616 <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE 18446744073709551615 <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE 0 = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE 0 <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE -1 = colA; +colA +SELECT * FROM inttbl WHERE -1 <=> colA; +colA +SELECT * FROM inttbl WHERE -1 <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE -1 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 0 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 0 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551616 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 18446744073709551615 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE 0 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE 0 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE -1 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE -1 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT against decimal +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES (0), (1), +(0),(1),(3), +(18446744073709551614), (18446744073709551615), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 0.5; +colA +SELECT * FROM inttbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -0.5; +colA +SELECT * FROM inttbl WHERE colA <= -0.5; +colA +SELECT * FROM inttbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -0.5; +colA +SELECT * FROM inttbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551615.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551615.00001; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615.00001; +colA +SELECT * FROM inttbl WHERE colA = 18446744073709551615.00001; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551615.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551614.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA <= 18446744073709551614.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA > 18446744073709551614.99999; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 18446744073709551614.99999; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 18446744073709551614.99999; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551614.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 0.00001; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= 0.00001; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > 0.00001; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 0.00001; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 0.00001; +colA +SELECT * FROM inttbl WHERE colA <> 0.00001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -0.99999; +colA +SELECT * FROM inttbl WHERE colA <= -0.99999; +colA +SELECT * FROM inttbl WHERE colA > -0.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -0.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -0.99999; +colA +SELECT * FROM inttbl WHERE colA <> -0.99999; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta=18446744073709551615.00001; +SET @dec_max_minus_delta=18446744073709551614.99999; +SET @dec_min_plus_delta=0.00001; +SET @dec_min_minus_delta=-0.99999; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE inttbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with UNSIGNED type BIGINT against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES ('0'), ('1'), +(0),(1),(3), +('18446744073709551614'), ('18446744073709551615'), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '-1'; +colA +SELECT * FROM inttbl WHERE colA <= '0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= '0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> '18446744073709551615'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA = '0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> '0'; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> '0'); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-1'; +colA +SELECT * FROM inttbl WHERE colA <=> '-1'; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> '-1'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1='18446744073709551616'; +SET @maxint='18446744073709551615'; +SET @minint_minus_1='-1'; +SET @minint='0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +colA +SELECT * FROM inttbl WHERE '-1' < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1' >= colA; +colA +SELECT * FROM inttbl WHERE '0' >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0' <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '0' < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE '0' = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0' <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0' <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1' = colA; +colA +SELECT * FROM inttbl WHERE '-1' <=> colA; +colA +SELECT * FROM inttbl WHERE '-1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '-1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE '0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '-1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT NOT NULL against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED NOT NULL); +INSERT INTO inttbl VALUES ('0'), ('1'), +(0),(1),(3), +('18446744073709551614'), ('18446744073709551615'), +(0); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA <= '-1'; +colA +SELECT * FROM inttbl WHERE colA <= '0'; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA >= '0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA > '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +colA +SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> '18446744073709551615'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +SELECT * FROM inttbl WHERE colA = '0'; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE colA <=> '0'; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> '0'); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <> '0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-1'; +colA +SELECT * FROM inttbl WHERE colA <=> '-1'; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> '-1'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE colA <> '-1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1='18446744073709551616'; +SET @maxint='18446744073709551615'; +SET @minint_minus_1='-1'; +SET @minint='0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551616'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551615'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +same queries but constant first +SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +colA +SELECT * FROM inttbl WHERE '-1' < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '-1' >= colA; +colA +SELECT * FROM inttbl WHERE '0' >= colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE '0' <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '0' < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +SELECT * FROM inttbl WHERE '0' = colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE '0' <=> colA; +colA +0 +0 +0 +SELECT * FROM inttbl WHERE '0' <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1' = colA; +colA +SELECT * FROM inttbl WHERE '-1' <=> colA; +colA +SELECT * FROM inttbl WHERE '-1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +0 +EXECUTE p_eq USING @minint; +colA +0 +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '-1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE '0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '-1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where true +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT against int +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('18446744073709551614.0'), ('18446744073709551615.0'), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < '18446744073709551616.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615.0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551616.1'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615.0'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '-1.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= '-1.1'; +colA +SELECT * FROM inttbl WHERE colA <= '0.0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA >= '0.0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '0.0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551616.1'; +colA +SELECT * FROM inttbl WHERE colA <> '18446744073709551616.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551615.0'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <=> '18446744073709551615.0'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE NOT(colA <=> '18446744073709551615.0'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +SELECT * FROM inttbl WHERE colA <> '18446744073709551615.0'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA = '0.0'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <=> '0.0'; +colA +0 +0 +SELECT * FROM inttbl WHERE NOT(colA <=> '0.0'); +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '0.0'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-1.1'; +colA +SELECT * FROM inttbl WHERE colA <=> '-1.1'; +colA +SELECT * FROM inttbl WHERE NOT(colA <=> '-1.1'); +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA <> '-1.1'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @maxint_plus_1='18446744073709551616.1'; +SET @maxint='18446744073709551615.0'; +SET @minint_minus_1='-1.1'; +SET @minint='0.0'; +EXECUTE p_less USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_greater USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +0 +0 +EXECUTE p_gret_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE colA < '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA >= '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA > '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA <= '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA >= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA > '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` > 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551616.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE colA = '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '18446744073709551615.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE colA = '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <=> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA <> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` <> 0) +EXPLAIN SELECT * FROM inttbl WHERE colA = '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <=> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE colA <> '-1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbl WHERE '18446744073709551616.1' > colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' >= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616.1' < colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551615.0' <= colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' < colA; +colA +SELECT * FROM inttbl WHERE '-1.1' < colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1.1' >= colA; +colA +SELECT * FROM inttbl WHERE '0.0' >= colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0.0' <= colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '0.0' < colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551616.1' = colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616.1' <=> colA; +colA +SELECT * FROM inttbl WHERE '18446744073709551616.1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' = colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' <=> colA; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE '18446744073709551615.0' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE '0.0' = colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0.0' <=> colA; +colA +0 +0 +SELECT * FROM inttbl WHERE '0.0' <> colA; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE '-1.1' = colA; +colA +SELECT * FROM inttbl WHERE '-1.1' <=> colA; +colA +SELECT * FROM inttbl WHERE '-1.1' <> colA; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbl WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbl WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_less USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +0 +0 +EXECUTE p_less_eq USING @minint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @maxint; +colA +18446744073709551615 +EXECUTE p_equal USING @maxint; +colA +18446744073709551615 +EXECUTE p_n_eq USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_n_equal USING @maxint; +colA +0 +1 +0 +1 +3 +18446744073709551614 +NULL +EXECUTE p_eq USING @minint; +colA +0 +0 +EXECUTE p_equal USING @minint; +colA +0 +0 +EXECUTE p_n_eq USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_n_equal USING @minint_minus_1; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '0.0' >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 = `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 < `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551616.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 18446744073709551615) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '18446744073709551615.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (18446744073709551615 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` = 0) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <=> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '0.0' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (0 <> `test`.`inttbl`.`colA`) +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where false +EXPLAIN SELECT * FROM inttbl WHERE '-1.1' <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbl NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbl`.`colA` AS `colA` from `test`.`inttbl` where (`test`.`inttbl`.`colA` is not null) +DROP TABLE inttbl; +# +# Tests with UNSIGNED type BIGINT against decimal +# +CREATE TABLE inttbl (colA BIGINT UNSIGNED ); +INSERT INTO inttbl VALUES ('0.0'), ('1.0'), +(0),(1),(3), +('18446744073709551614.0'), ('18446744073709551615.0'), +(NULL); +ANALYZE TABLE inttbl; +Table Op Msg_type Msg_text +test.inttbl analyze status OK +SELECT * FROM inttbl; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +NULL +SELECT * FROM inttbl WHERE colA < 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= 0.5; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= 0.5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = 0.5; +colA +SELECT * FROM inttbl WHERE colA <> 0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -0.5; +colA +SELECT * FROM inttbl WHERE colA <= -0.5; +colA +SELECT * FROM inttbl WHERE colA > -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -0.5; +colA +SELECT * FROM inttbl WHERE colA <> -0.5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < '18446744073709551615.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA <= '18446744073709551615.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551615.00001'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551615.00001'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551615.00001'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <> '18446744073709551615.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA < '18446744073709551614.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA <= '18446744073709551614.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > '18446744073709551614.99999'; +colA +SELECT * FROM inttbl WHERE colA >= '18446744073709551614.99999'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '18446744073709551614.99999'; +colA +18446744073709551615 +SELECT * FROM inttbl WHERE colA <> '18446744073709551614.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +SELECT * FROM inttbl WHERE colA < '0.00001'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA <= '0.00001'; +colA +0 +0 +SELECT * FROM inttbl WHERE colA > '0.00001'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= '0.00001'; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '0.00001'; +colA +SELECT * FROM inttbl WHERE colA <> '0.00001'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < '-0.99999'; +colA +SELECT * FROM inttbl WHERE colA <= '-0.99999'; +colA +SELECT * FROM inttbl WHERE colA > '-0.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= '-0.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = '-0.99999'; +colA +SELECT * FROM inttbl WHERE colA <> '-0.99999'; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA <= 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA > 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA >= 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA = 18446744073709551615.00000001; +colA +SELECT * FROM inttbl WHERE colA <> 18446744073709551615.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA < -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <= -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA > -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA >= -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +SELECT * FROM inttbl WHERE colA = -9223372036854775808.00000001; +colA +SELECT * FROM inttbl WHERE colA <> -9223372036854775808.00000001; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +PREPARE p_less FROM 'SELECT * FROM inttbl WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbl WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbl WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbl WHERE colA >= ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbl WHERE colA = ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbl WHERE colA <> ?'; +SET @dec_0_5=0.5; +SET @dec_minus_0_5=-0.5; +SET @dec_max_plus_delta='18446744073709551615.00001'; +SET @dec_max_minus_delta='18446744073709551614.99999'; +SET @dec_min_plus_delta='0.00001'; +SET @dec_min_minus_delta='-0.99999'; +SET @dec_too_big_positive_for_any_int=18446744073709551615.00000001; +SET @dec_too_big_negative_for_any_int=-9223372036854775808.00000001; +EXECUTE p_less USING @dec_0_5; +colA +0 +0 +EXECUTE p_less_eq USING @dec_0_5; +colA +0 +0 +EXECUTE p_greater USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_0_5; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_0_5; +colA +EXECUTE p_n_equal USING @dec_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_minus_0_5; +colA +EXECUTE p_less_eq USING @dec_minus_0_5; +colA +EXECUTE p_greater USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_minus_0_5; +colA +EXECUTE p_n_equal USING @dec_minus_0_5; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_max_plus_delta; +colA +EXECUTE p_gret_eq USING @dec_max_plus_delta; +colA +EXECUTE p_equal USING @dec_max_plus_delta; +colA +EXECUTE p_n_equal USING @dec_max_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_less_eq USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +EXECUTE p_greater USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_gret_eq USING @dec_max_minus_delta; +colA +18446744073709551615 +EXECUTE p_equal USING @dec_max_minus_delta; +colA +EXECUTE p_n_equal USING @dec_max_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_less_eq USING @dec_min_plus_delta; +colA +0 +0 +EXECUTE p_greater USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_plus_delta; +colA +1 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_plus_delta; +colA +EXECUTE p_n_equal USING @dec_min_plus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_min_minus_delta; +colA +EXECUTE p_less_eq USING @dec_min_minus_delta; +colA +EXECUTE p_greater USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_min_minus_delta; +colA +EXECUTE p_n_equal USING @dec_min_minus_delta; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less_eq USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_greater USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_gret_eq USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_equal USING @dec_too_big_positive_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_positive_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_less USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_less_eq USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_greater USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_gret_eq USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +EXECUTE p_equal USING @dec_too_big_negative_for_any_int; +colA +EXECUTE p_n_equal USING @dec_too_big_negative_for_any_int; +colA +0 +1 +0 +1 +3 +18446744073709551614 +18446744073709551615 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_equal; +DROP TABLE inttbl; +Cruft inside string +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1), (0), (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i > 'A'; +i +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +EXPLAIN SELECT * FROM t WHERE i > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` > 0) +DROP TABLE t; +Detect decimal inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i BIGINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i = '1.1'; +i +EXPLAIN SELECT * FROM t WHERE i = '1.1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (1), (2); +SELECT * FROM t WHERE i > '1E10'; +i +EXPLAIN SELECT * FROM t WHERE i > '1E10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +Detect out of range real inside a string when compared to int +Used to return one row; should be none. +CREATE TABLE t(i TINYINT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (0); +SELECT * FROM t WHERE i = '1E-308'; +i +EXPLAIN SELECT * FROM t WHERE i = '1E-308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +Above query should yield the same as this: +SELECT * FROM t WHERE i = 1E-308; +i +EXPLAIN SELECT * FROM t WHERE i = 1E-308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where false +DROP TABLE t; +# +# Tests with type BIGINT against int +# +CREATE TABLE inttbls (colA BIGINT ); +INSERT INTO inttbls VALUES (-9223372036854775808), (-9223372036854775807), +(0),(1),(3), +(9223372036854775806), (9223372036854775807), +(NULL); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +SELECT * FROM inttbls WHERE colA < 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA > 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA > -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA > -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA = 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA = 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE NOT(colA <=> 9223372036854775807); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +NULL +SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +SELECT * FROM inttbls WHERE colA = -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775808); +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE colA = -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775809); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=9223372036854775808; +SET @maxint=9223372036854775807; +SET @minint_minus_1=-9223372036854775809; +SET @minint=-9223372036854775808; +EXECUTE p_less USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_greater USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_greater USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +NULL +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +same queries but constant first +SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_gret_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_less USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_less USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +NULL +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +NULL +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` is not null) +DROP TABLE inttbls; +# +# Tests with type BIGINT NOT NULL against int +# +CREATE TABLE inttbls (colA BIGINT NOT NULL); +INSERT INTO inttbls VALUES (-9223372036854775808), (-9223372036854775807), +(0),(1),(3), +(9223372036854775806), (9223372036854775807), +(0); +ANALYZE TABLE inttbls; +Table Op Msg_type Msg_text +test.inttbls analyze status OK +SELECT * FROM inttbls; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA < 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA > 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA > -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA > -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA = 9223372036854775808; +colA +SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA = 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE NOT(colA <=> 9223372036854775807); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +SELECT * FROM inttbls WHERE colA = -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775808); +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA = -9223372036854775809; +colA +SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +colA +SELECT * FROM inttbls WHERE NOT(colA <=> -9223372036854775809); +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE colA < ?'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE colA <= ?'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE colA > ?'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE colA >= ?'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE colA = ?'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE colA <=> ?'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(colA <=> ?)'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE colA <> ?'; +SET @maxint_plus_1=9223372036854775808; +SET @maxint=9223372036854775807; +SET @minint_minus_1=-9223372036854775809; +SET @minint=-9223372036854775808; +EXECUTE p_less USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_greater USING @maxint_plus_1; +colA +EXECUTE p_gret_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_greater USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less_eq USING @minint_minus_1; +colA +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_greater USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE colA < 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA >= 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA >= -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA > -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` > -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE colA = 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA <> 9223372036854775807; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <=> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775808; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` <> -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE colA = -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <=> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE colA <> -9223372036854775809; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +same queries but constant first +SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +colA +SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +colA +9223372036854775807 +SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +colA +-9223372036854775808 +SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +colA +SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +PREPARE p_less FROM 'SELECT * FROM inttbls WHERE ? < colA'; +PREPARE p_less_eq FROM 'SELECT * FROM inttbls WHERE ? <= colA'; +PREPARE p_greater FROM 'SELECT * FROM inttbls WHERE ? > colA'; +PREPARE p_gret_eq FROM 'SELECT * FROM inttbls WHERE ? >= colA'; +PREPARE p_eq FROM 'SELECT * FROM inttbls WHERE ? = colA'; +PREPARE p_equal FROM 'SELECT * FROM inttbls WHERE ? <=> colA'; +PREPARE p_n_eq FROM 'SELECT * FROM inttbls WHERE ? <> colA'; +PREPARE p_n_equal FROM 'SELECT * FROM inttbls WHERE NOT(? <=> colA)'; +EXECUTE p_greater USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_gret_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less USING @maxint_plus_1; +colA +EXECUTE p_less_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_less USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_gret_eq USING @minint_minus_1; +colA +EXECUTE p_gret_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_less_eq USING @minint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_less USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint_plus_1; +colA +EXECUTE p_equal USING @maxint_plus_1; +colA +EXECUTE p_n_eq USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @maxint_plus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @maxint; +colA +9223372036854775807 +EXECUTE p_equal USING @maxint; +colA +9223372036854775807 +EXECUTE p_n_eq USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_n_equal USING @maxint; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +0 +EXECUTE p_eq USING @minint; +colA +-9223372036854775808 +EXECUTE p_equal USING @minint; +colA +-9223372036854775808 +EXECUTE p_n_eq USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint; +colA +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_eq USING @minint_minus_1; +colA +EXECUTE p_equal USING @minint_minus_1; +colA +EXECUTE p_n_eq USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +EXECUTE p_n_equal USING @minint_minus_1; +colA +-9223372036854775808 +-9223372036854775807 +0 +1 +3 +9223372036854775806 +9223372036854775807 +0 +DROP PREPARE p_less; +DROP PREPARE p_less_eq; +DROP PREPARE p_greater; +DROP PREPARE p_gret_eq; +DROP PREPARE p_equal; +DROP PREPARE p_n_eq; +DROP PREPARE p_n_equal; +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 > colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 >= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 = `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <= colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 < colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 33.33 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 < `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = 9223372036854775807) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE 9223372036854775807 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (9223372036854775807 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (`test`.`inttbls`.`colA` = -9223372036854775808) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <=> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775808 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where (-9223372036854775808 <> `test`.`inttbls`.`colA`) +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 = colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <=> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where false +EXPLAIN SELECT * FROM inttbls WHERE -9223372036854775809 <> colA; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE inttbls NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`inttbls`.`colA` AS `colA` from `test`.`inttbls` where true +DROP TABLE inttbls; +CREATE TABLE t(u TINYINT UNSIGNED); +INSERT INTO t VALUES (0), (3), (255), (NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE u=256 IS NOT NULL; +u +0 +3 +255 +SELECT * FROM t WHERE u=256 IS NULL; +u +NULL +SELECT * FROM t WHERE u=256 IS UNKNOWN; +u +NULL +SELECT * FROM t WHERE ABS(u=256)=0; +u +0 +3 +255 +SELECT * FROM t WHERE u=256; +u +EXPLAIN SELECT * FROM t WHERE u=256 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where ((`test`.`t`.`u` <> `test`.`t`.`u`) is not null) +EXPLAIN SELECT * FROM t WHERE u=256 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where ((`test`.`t`.`u` <> `test`.`t`.`u`) is null) +EXPLAIN SELECT * FROM t WHERE u=256 IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where ((`test`.`t`.`u` <> `test`.`t`.`u`) is null) +EXPLAIN SELECT * FROM t WHERE ABS(u=256)=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where (abs((`test`.`t`.`u` <> `test`.`t`.`u`)) = 0) +EXPLAIN SELECT * FROM t WHERE u=256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +drop table t; +CREATE TABLE t(u TINYINT UNSIGNED NOT NULL); +INSERT INTO t VALUES (0), (3), (255); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE u=256 IS NOT NULL; +u +0 +3 +255 +SELECT * FROM t WHERE u=256 IS NULL; +u +SELECT * FROM t WHERE u=256 IS UNKNOWN; +u +SELECT * FROM t WHERE ABS(u=256)=0; +u +0 +3 +255 +SELECT * FROM t WHERE u=256; +u +EXPLAIN SELECT * FROM t WHERE u=256 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where true +EXPLAIN SELECT * FROM t WHERE u=256 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +EXPLAIN SELECT * FROM t WHERE u=256 IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +EXPLAIN SELECT * FROM t WHERE ABS(u=256)=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where true +EXPLAIN SELECT * FROM t WHERE u=256; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`u` AS `u` from `test`.`t` where false +DROP TABLE t; + +Constant folding in 3 way join with impossible condition due to +the constant being out of range of one tables' field type. + +CREATE TABLE t1(i TINYINT); +CREATE TABLE t2(i INT); +CREATE TABLE t3(i INT); +INSERT INTO t1 VALUES (127); +INSERT INTO t2 VALUES (128); +INSERT INTO t3 VALUES (128); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t1.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t1.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t1.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t1.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t1.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t1.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t1.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t1.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t1.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t3.i=t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t3.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t3.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t3.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t3.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t3.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t3.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t3.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t3.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t3.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t3.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=t1.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t3.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t3.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t3.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t2.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t2.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t3.i=t2.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t3.i=t2.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t2.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t2.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t2.i=t1.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t2.i=t3.i AND t1.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t2.i=t3.i AND t2.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t2.i=t3.i AND t3.i=128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=128 AND t1.i=t2.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=128 AND t1.i=t2.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t3.i=128 AND t1.i=t2.i AND t2.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where false + +Constant folding in 3 way join with always true condition due to +the constant being out of range of one table's field type. + +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t1.i=t2.i AND t1.i=t3.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t1.i <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t1`.`i` is not null)) +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t2.i <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` is not null)) +EXPLAIN SELECT * FROM t1,t2,t3 WHERE t2.i=t1.i AND t2.i=t3.i AND t3.i <> 4294967296; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` is not null)) +DROP TABLES t1, t2, t3; +CREATE TABLE t(d DECIMAL (3,1) ); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (NULL), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +NULL +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100; +d +EXPLAIN SELECT d FROM t WHERE d > 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100; +d +EXPLAIN SELECT d FROM t WHERE d >= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d <= 100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d = 100; +d +EXPLAIN SELECT d FROM t WHERE d = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE d > -100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d >= -100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d < -100; +d +EXPLAIN SELECT d FROM t WHERE d < -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100; +d +EXPLAIN SELECT d FROM t WHERE d <= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100; +d +EXPLAIN SELECT d FROM t WHERE d = -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Positive constant +SELECT d FROM t WHERE d > 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d >= 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 10.0) +SELECT d FROM t WHERE d < 10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 10.0) +SELECT d FROM t WHERE d <= 10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.0) +SELECT d FROM t WHERE d = 10; +d +EXPLAIN SELECT d FROM t WHERE d = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = 10.0) +SELECT d FROM t WHERE d <> 10; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> 10.0) +Negative constant +SELECT d FROM t WHERE d > -10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > -10.0) +SELECT d FROM t WHERE d >= -10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.0) +SELECT d FROM t WHERE d < -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.0) +SELECT d FROM t WHERE d <= -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= -10.0) +SELECT d FROM t WHERE d = -10; +d +EXPLAIN SELECT d FROM t WHERE d = -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = -10.0) +SELECT d FROM t WHERE d <> -10; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> -10.0) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100 < d; +d +EXPLAIN SELECT d FROM t WHERE 100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100 = d; +d +EXPLAIN SELECT d FROM t WHERE 100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE -100 < d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100 <= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100 > d; +d +EXPLAIN SELECT d FROM t WHERE -100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 = d; +d +EXPLAIN SELECT d FROM t WHERE -100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Ints inside strings +SELECT d FROM t WHERE d > '10'; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d > '100'; +d +EXPLAIN SELECT d FROM t WHERE d > '100'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +0x notation +SELECT d FROM t WHERE d > 0x100; +d +EXPLAIN SELECT d FROM t WHERE d > 0x100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +DROP TABLE t; +CREATE TABLE t(d DECIMAL(65, 30) ); +INSERT INTO t VALUES (184467440737095516160000); +INSERT INTO t VALUES (18446744073709551.3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +0x constant too large; gets truncated to 0xFFFFFFFFFFFFFFFF +i.e. 18446744073709551615. +SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +EXPLAIN SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 18446744073709551615.000000000000000000000000000000) +DROP TABLE t; +CREATE TABLE t(d DECIMAL (3,1) NOT NULL); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (0), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100; +d +EXPLAIN SELECT d FROM t WHERE d > 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100; +d +EXPLAIN SELECT d FROM t WHERE d >= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d <= 100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d = 100; +d +EXPLAIN SELECT d FROM t WHERE d = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE d > -100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d >= -100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d < -100; +d +EXPLAIN SELECT d FROM t WHERE d < -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100; +d +EXPLAIN SELECT d FROM t WHERE d <= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100; +d +EXPLAIN SELECT d FROM t WHERE d = -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Positive constant +SELECT d FROM t WHERE d > 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d >= 10; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 10.0) +SELECT d FROM t WHERE d < 10; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 10.0) +SELECT d FROM t WHERE d <= 10; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d <= 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.0) +SELECT d FROM t WHERE d = 10; +d +EXPLAIN SELECT d FROM t WHERE d = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = 10.0) +SELECT d FROM t WHERE d <> 10; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> 10.0) +Negative constant +SELECT d FROM t WHERE d > -10; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > -10.0) +SELECT d FROM t WHERE d >= -10; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.0) +SELECT d FROM t WHERE d < -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.0) +SELECT d FROM t WHERE d <= -10; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= -10.0) +SELECT d FROM t WHERE d = -10; +d +EXPLAIN SELECT d FROM t WHERE d = -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` = -10.0) +SELECT d FROM t WHERE d <> -10; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <> -10.0) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100 < d; +d +EXPLAIN SELECT d FROM t WHERE 100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100 = d; +d +EXPLAIN SELECT d FROM t WHERE 100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE -100 < d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100 <= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100 > d; +d +EXPLAIN SELECT d FROM t WHERE -100 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 = d; +d +EXPLAIN SELECT d FROM t WHERE -100 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Ints inside strings +SELECT d FROM t WHERE d > '10'; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.0) +SELECT d FROM t WHERE d > '100'; +d +EXPLAIN SELECT d FROM t WHERE d > '100'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +0x notation +SELECT d FROM t WHERE d > 0x100; +d +EXPLAIN SELECT d FROM t WHERE d > 0x100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +DROP TABLE t; +CREATE TABLE t(d DECIMAL(65, 30) NOT NULL); +INSERT INTO t VALUES (184467440737095516160000); +INSERT INTO t VALUES (18446744073709551.3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +0x constant too large; gets truncated to 0xFFFFFFFFFFFFFFFF +i.e. 18446744073709551615. +SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +EXPLAIN SELECT * FROM t WHERE d <= 0x1FFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'01ffffffffffffffff'' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +d +184467440737095516160000.000000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 18446744073709551615.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0x7FFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 9223372036854775807.000000000000000000000000000000) +0x constant within bounds, expect to warnings +SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +d +18446744073709551.300000000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d < 0xFFFFFFFFFFFFFFFF; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 18446744073709551615.000000000000000000000000000000) +DROP TABLE t; +CREATE TABLE t(d DECIMAL (3,1) ); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (NULL), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +NULL +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d <= 100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d = 100.0; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d >= -100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d < -100.0; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE d > 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE d > -10.31; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE -100.0 < d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0 <= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE 10.31 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE -10.31 < d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 <= d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Check that leading and trailing zeros are handled +SELECT d FROM t WHERE d > 10.30; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d > 010.3; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 010.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +Check decimals hidden inside strings +SELECT d FROM t WHERE d > '-10.31'; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '-10.31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +Cruft inside string, MySQL interprets as 0 with warning +SELECT d FROM t WHERE d > 'A'; +d +10.3 +10.4 +10.5 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +EXPLAIN SELECT d FROM t WHERE d > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 10.35; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 10.35; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; +CREATE TABLE t(d DECIMAL (3,1) NOT NULL); +INSERT INTO t VALUES (-10.5), (-10.4), (-10.3), (0), (10.3), (10.4), (10.5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d <= 100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d = 100.0; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d >= -100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d < -100.0; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE d > 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE d > -10.31; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE -100.0 < d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0 <= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE 10.31 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE -10.31 < d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 <= d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Check that leading and trailing zeros are handled +SELECT d FROM t WHERE d > 10.30; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d > 010.3; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 010.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +Check decimals hidden inside strings +SELECT d FROM t WHERE d > '-10.31'; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > '-10.31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +Cruft inside string, MySQL interprets as 0 with warning +SELECT d FROM t WHERE d > 'A'; +d +10.3 +10.4 +10.5 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +EXPLAIN SELECT d FROM t WHERE d > 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 10.35; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 10.35; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; +create table t(d decimal (3,1) ); +insert into t values (-10.5), (-10.4), (-10.3), (NULL), (10.3), (10.4), (10.5); +analyze table t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +NULL +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d <= 100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d = 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d >= -100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d < -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE d > 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE d > -10.31E00; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31E00; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31E00; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0E00 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0E00 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE 100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Out of range, negative constant +SELECT d FROM t WHERE -100.0E00 < d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0E00 <= d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE -100.0E00 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated positive constant +SELECT d FROM t WHERE 10.31E00 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 > d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 >= d; +d +-10.5 +-10.4 +-10.3 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Truncated negative constant +SELECT d FROM t WHERE -10.31E00 < d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 <= d; +d +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Check real underflow +SELECT d FROM t WHERE d > 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d >= 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d < 1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d <= 1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d = 1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 1.0E-100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +SELECT d FROM t WHERE d > -1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d >= -1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d < -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d <= -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d = -1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -1.0E-100; +d +-10.5 +-10.4 +-10.3 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 85.71 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +Test that reals inside strings are handled ok +SELECT d FROM t WHERE d < '1.0E0'; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < '1.0E0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 1.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 0.1035E02; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0.1035E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; +create table t(d decimal (3,1) NOT NULL); +insert into t values (-10.5), (-10.4), (-10.3), (0), (10.3), (10.4), (10.5); +analyze table t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT d FROM t; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +II.a.1 field cmp constant +Out of range, positive constant +SELECT d FROM t WHERE d > 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d > 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d >= 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d >= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d < 100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d < 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d <= 100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <= 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d = 100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE d > -100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d >= -100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d < -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d < -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <= -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d <= -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d = -100.0E00; +d +EXPLAIN SELECT d FROM t WHERE d = -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -100.0E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -100.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE d > 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d >= 10.31E00; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.3) +SELECT d FROM t WHERE d < 10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d < 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d <= 10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE d <= 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 10.3) +SELECT d FROM t WHERE d = 10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE d > -10.31E00; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d >= -10.31E00; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= -10.3) +SELECT d FROM t WHERE d < -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d < -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d <= -10.31E00; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE d <= -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < -10.3) +SELECT d FROM t WHERE d = -10.31E00; +d +EXPLAIN SELECT d FROM t WHERE d = -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -10.31E00; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -10.31E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +II.a.2 constant cmp field +Out of range, positive constant +SELECT d FROM t WHERE 100.0E00 < d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <= d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0E00 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE 100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Out of range, negative constant +SELECT d FROM t WHERE -100.0E00 < d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0E00 <= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE -100.0E00 > d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 >= d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -100.0E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -100.0E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -100.0E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated positive constant +SELECT d FROM t WHERE 10.31E00 < d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 <= d; +d +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 < `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 > d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 >= d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +EXPLAIN SELECT d FROM t WHERE 10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (10.3 >= `test`.`t`.`d`) +SELECT d FROM t WHERE 10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE 10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE 10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE 10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Truncated negative constant +SELECT d FROM t WHERE -10.31E00 < d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 < d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 <= d; +d +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 <= `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 > d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 > d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 >= d; +d +-10.5 +-10.4 +EXPLAIN SELECT d FROM t WHERE -10.31E00 >= d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (-10.3 > `test`.`t`.`d`) +SELECT d FROM t WHERE -10.31E00 = d; +d +EXPLAIN SELECT d FROM t WHERE -10.31E00 = d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE -10.31E00 <> d; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE -10.31E00 <> d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Check real underflow +SELECT d FROM t WHERE d > 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d >= 1.0E-100; +d +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0.0) +SELECT d FROM t WHERE d < 1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d < 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d <= 1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d <= 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0.0) +SELECT d FROM t WHERE d = 1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> 1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> 1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +SELECT d FROM t WHERE d > -1.0E-100; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d > -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d >= -1.0E-100; +d +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d >= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0.0) +SELECT d FROM t WHERE d < -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d < -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d <= -1.0E-100; +d +-10.5 +-10.4 +-10.3 +EXPLAIN SELECT d FROM t WHERE d <= -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0.0) +SELECT d FROM t WHERE d = -1.0E-100; +d +EXPLAIN SELECT d FROM t WHERE d = -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +SELECT d FROM t WHERE d <> -1.0E-100; +d +-10.5 +-10.4 +-10.3 +0.0 +10.3 +10.4 +10.5 +EXPLAIN SELECT d FROM t WHERE d <> -1.0E-100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where true +Test that reals inside strings are handled ok +SELECT d FROM t WHERE d < '1.0E0'; +d +-10.5 +-10.4 +-10.3 +0.0 +EXPLAIN SELECT d FROM t WHERE d < '1.0E0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 1.0) +DROP TABLE t; +Check that #digits in constant fraction is widenened as for fields +CREATE TABLE t(d DECIMAL(65,30)); +INSERT INTO t VALUES (10.34999), (10.350001); +SELECT * FROM t WHERE d > 0.1035E02; +d +10.350001000000000000000000000000 +EXPLAIN SELECT * FROM t WHERE d > 0.1035E02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 10.350000000000000000000000000000) +DROP TABLE t; + +AD-158 Folding of IS NOT NULL if argument is not nullable. + +CREATE TABLE t(i INT NOT NULL); +EXPLAIN SELECT * FROM t WHERE i IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where true +SELECT * FROM t WHERE i IS NOT NULL; +i +INSERT INTO t VALUES (3), (4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE i IS NOT NULL; +i +3 +4 +EXPLAIN SELECT * FROM t WHERE i IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where true +EXPLAIN SELECT * FROM t WHERE ABS(i IS NOT NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where true +DROP TABLE t; + +Bug in nested condition: expression interior folding didn't +materialize a TRUE in the case of the field being not nullable. +Interior foldings should always materialize. + +CREATE TABLE t(i TINYINT NOT NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +INSERT INTO t VALUES (10),(100),(1),(0); +EXPLAIN SELECT * FROM t WHERE i = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` = true) +SELECT * FROM t WHERE i = (i < 255); +i +1 +DROP TABLE t; +CREATE TABLE t(i TINYINT); +INSERT INTO t VALUES (10),(100),(1),(0),(NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * FROM t WHERE i = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (`test`.`t`.`i` = if((`test`.`t`.`i` is null),NULL,1)) +SELECT * FROM t WHERE i = (i < 255); +i +1 + +Bug#29179604 + +EXPLAIN SELECT * FROM t WHERE 1 = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (1 = if((`test`.`t`.`i` is null),NULL,1)) +SELECT * FROM t WHERE 1 = (i < 255); +i +10 +100 +1 +0 +Used to give wrong result: NULL/UNKNOWN was lost in folding +EXPLAIN SELECT * FROM t WHERE 0 = (i < 255); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` where (0 = if((`test`.`t`.`i` is null),NULL,1)) +SELECT * FROM t WHERE 0 = (i < 255); +i +DROP TABLE t; +CREATE TABLE t(d DECIMAL(65,0)); +EXPLAIN SELECT d FROM t WHERE d < 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d = 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > 45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d < -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d = -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > -45.34e306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d < 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` <= 0) +EXPLAIN SELECT d FROM t WHERE d = 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > 45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 0) +EXPLAIN SELECT d FROM t WHERE d < -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 0) +EXPLAIN SELECT d FROM t WHERE d = -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where false +EXPLAIN SELECT d FROM t WHERE d != -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` is not null) +EXPLAIN SELECT d FROM t WHERE d > -45.34e-306; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` >= 0) +DROP TABLE t; +# +# Tests with type FLOAT(5,2) against real constants +# +CREATE TABLE float_5_2_tbl (colA FLOAT(5,2) ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO float_5_2_tbl VALUES (-999.99), (-999.985), +(-999.984), +( 3.3), (0.0), (3.3), +(999.985), +(999.984), (999.99), +(NULL); +ANALYZE TABLE float_5_2_tbl; +Table Op Msg_type Msg_text +test.float_5_2_tbl analyze status OK +SELECT * FROM float_5_2_tbl; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM float_5_2_tbl WHERE colA <= -999.99; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < -999.99; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= -999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.99; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.984; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < -999.984; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.984; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.985; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < -999.985; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.985; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA < -999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= -999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA < -999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = -999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.99; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 999.99; +colA +SELECT * FROM float_5_2_tbl WHERE colA = 999.99; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.984; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 999.984; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 999.984; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.985; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 999.985; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 999.985; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_5_2_tbl WHERE colA >= 999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA > 999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA = 999.994; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= 999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA > 999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA = 999.995; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +DROP TABLE float_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type FLOAT(5,2) against real constants +# +CREATE TABLE float_5_2_tbl (colA FLOAT(5,2) ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO float_5_2_tbl VALUES ('-999.99'), ('-999.985'), +('-999.984'), +( 3.3), (0.0), (3.3), +('999.985'), +('999.984'), ('999.99'), +(NULL); +ANALYZE TABLE float_5_2_tbl; +Table Op Msg_type Msg_text +test.float_5_2_tbl analyze status OK +SELECT * FROM float_5_2_tbl; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.99'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '-999.99'; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.99'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.99'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.99'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.984'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '-999.984'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.984'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.984'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.984'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.985'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '-999.985'; +colA +-999.99 +-999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.985'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.985'; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.985'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA < '-999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '-999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA < '-999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= '-999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '-999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '-999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '-999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= -999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '-999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +DROP TABLE float_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with UNSIGNED type FLOAT(5,2) against real constants +# +CREATE TABLE float_5_2_tbl (colA FLOAT(5,2) UNSIGNED ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +INSERT INTO float_5_2_tbl VALUES (0.0), (0.005), +(0.004), +( 3.3), (0.0), (3.3), +('999.985'), +('999.984'), ('999.99'), +(NULL); +ANALYZE TABLE float_5_2_tbl; +Table Op Msg_type Msg_text +test.float_5_2_tbl analyze status OK +SELECT * FROM float_5_2_tbl; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.004; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.004; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA >= 0.004; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.004; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.004; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 0.004; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.005; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.005; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA >= 0.005; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.005; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.005; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> 0.005; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +colA +SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +colA +0.00 +0.00 +0.00 +0.00 +SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +colA +3.30 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +colA +999.99 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +colA +SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +colA +0.00 +0.00 +0.00 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.004; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.005; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 0) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` = 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.99'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <> 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.97998046875) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.984'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` < 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` >= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.985'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` <= 999.989990234375) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` > 999.989990234375) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.994'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA < '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA >= '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA > '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA = '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where false +EXPLAIN SELECT * FROM float_5_2_tbl WHERE colA <> '999.995'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_5_2_tbl`.`colA` AS `colA` from `test`.`float_5_2_tbl` where (`test`.`float_5_2_tbl`.`colA` is not null) +DROP TABLE float_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type FLOAT against real constants +# +CREATE TABLE float_tbl (colA FLOAT ); +INSERT INTO float_tbl VALUES (-3.4028234663852886e+38), (-3.4028234663852886e+38), +(-3.4028234663852886e+38), +( 3.3), (0.0), (3.3), +(3.4028234663852886e+38), +(3.4028234663852886e+38), (3.402823466E+38), +(NULL); +ANALYZE TABLE float_tbl; +Table Op Msg_type Msg_text +test.float_tbl analyze status OK +SELECT * FROM float_tbl; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +NULL +SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +colA +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= 3.402823466E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA < 3.402823466E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.402823466E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.402823466E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = 3.402823466E+38; +colA +SELECT * FROM float_tbl WHERE colA <> 3.402823466E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +colA +SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +colA +3.40282e38 +3.40282e38 +3.40282e38 +SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +colA +SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +colA +-3.40282e38 +-3.40282e38 +-3.40282e38 +3.3 +0 +3.3 +3.40282e38 +3.40282e38 +3.40282e38 +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.4028234663852886e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> -3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> -3.402823466385288e38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.402823466E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.402823466E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.4028234663852886e+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.4028234663852886e+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.402823466385288E+38) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA < 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` < 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA >= 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` >= 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA > 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` > 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA = 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` = 3.402823466385288E+38) +EXPLAIN SELECT * FROM float_tbl WHERE colA <> 3.402823466385288E+38; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE float_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`float_tbl`.`colA` AS `colA` from `test`.`float_tbl` where (`test`.`float_tbl`.`colA` <> 3.402823466385288E+38) +DROP TABLE float_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type DOUBLE(5,2) against real constants +# +CREATE TABLE double_5_2_tbl (colA DOUBLE(5,2) ); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO double_5_2_tbl VALUES (-999.99), (-999.985), +(-999.984), +( 3.3), (0.0), (3.3), +(999.985), +(999.984), (999.99), +(NULL); +ANALYZE TABLE double_5_2_tbl; +Table Op Msg_type Msg_text +test.double_5_2_tbl analyze status OK +SELECT * FROM double_5_2_tbl; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +NULL +SELECT * FROM double_5_2_tbl WHERE colA <= -999.99; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA < -999.99; +colA +SELECT * FROM double_5_2_tbl WHERE colA >= -999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.99; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA <> -999.99; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.984; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA < -999.984; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA >= -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.984; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.984; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.985; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA < -999.985; +colA +-999.99 +-999.99 +SELECT * FROM double_5_2_tbl WHERE colA >= -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.985; +colA +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.985; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA < -999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA >= -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= -999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA < -999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA >= -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = -999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> -999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA < 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.99; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > 999.99; +colA +SELECT * FROM double_5_2_tbl WHERE colA = 999.99; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <> 999.99; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA < 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.984; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > 999.984; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = 999.984; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.984; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA < 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.98 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.985; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA > 999.985; +colA +999.99 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA = 999.985; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.985; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA < 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM double_5_2_tbl WHERE colA >= 999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA > 999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA = 999.994; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.994; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA <= 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA < 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +SELECT * FROM double_5_2_tbl WHERE colA >= 999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA > 999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA = 999.995; +colA +SELECT * FROM double_5_2_tbl WHERE colA <> 999.995; +colA +-999.99 +-999.99 +-999.98 +3.30 +0.00 +3.30 +999.99 +999.98 +999.99 +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` = -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <> -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= -999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> -999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` = 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.99; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <> 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.98) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.984; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` < 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` >= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.985; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` <= 999.99) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` > 999.99) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.994; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA < 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA >= 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA > 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA = 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where false +EXPLAIN SELECT * FROM double_5_2_tbl WHERE colA <> 999.995; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_5_2_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_5_2_tbl`.`colA` AS `colA` from `test`.`double_5_2_tbl` where (`test`.`double_5_2_tbl`.`colA` is not null) +DROP TABLE double_5_2_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type DOUBLE against real constants +# +CREATE TABLE double_tbl (colA DOUBLE ); +INSERT INTO double_tbl VALUES (-1.7976931348623157E+308), (-1.7976931348623156E+308), +(-1.7976931348623156E+308), +( 3.3), (0.0), (3.3), +(1.7976931348623156E+308), +(1.7976931348623156E+308), (1.7976931348623157E+308), +(NULL); +ANALYZE TABLE double_tbl; +Table Op Msg_type Msg_text +test.double_tbl analyze status OK +SELECT * FROM double_tbl; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +NULL +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +colA +SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> -1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623156E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623156E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157E+308) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157E+308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> 1.7976931348623157E+308; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157E+308) +DROP TABLE double_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +# +# Tests with type DOUBLE against real constants +# +CREATE TABLE double_tbl (colA DOUBLE ); +INSERT INTO double_tbl VALUES ('-1.7976931348623157E+308'), ('-1.7976931348623156E+308'), +('-1.7976931348623156E+308'), +( 3.3), (0.0), (3.3), +('1.7976931348623156E+308'), +('1.7976931348623156E+308'), ('1.7976931348623157E+308'), +(NULL); +ANALYZE TABLE double_tbl; +Table Op Msg_type Msg_text +test.double_tbl analyze status OK +SELECT * FROM double_tbl; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +NULL +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +colA +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +colA +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +colA +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +Result here can be empty set, because MySQL performs operation in +double, e.g. colA >= 999.994 for FLOAT(5,2): +executes as nnn.nn0 >= 999.994, i.e. the .994 isn't truncated +to .99 before comparison +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +colA +SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +colA +1.7976931348623157e308 +SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +colA +-1.7976931348623157e308 +-1.7976931348623155e308 +-1.7976931348623155e308 +3.3 +0 +3.3 +1.7976931348623155e308 +1.7976931348623155e308 +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '-1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> -1.797693134862316e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623156E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623155e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157e308) +Cf explanation of semantics here under the SELECT above. The operator +is modified here to get the same semantics: we need > instead of >= +since we truncate the constant to the allowed range +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA < '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` < 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA >= '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` >= 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA > '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` > 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA = '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` = 1.7976931348623157e308) +EXPLAIN SELECT * FROM double_tbl WHERE colA <> '1.7976931348623157E+308'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE double_tbl NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`double_tbl`.`colA` AS `colA` from `test`.`double_tbl` where (`test`.`double_tbl`.`colA` <> 1.7976931348623157e308) +DROP TABLE double_tbl; +CREATE TABLE f(f FLOAT); +INSERT INTO f VALUES (-1), (2); +SELECT * FROM f WHERE f >= '2 garbage'; +f +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2 garbage' +DROP TABLE f; +CREATE TABLE f(f FLOAT); +CREATE TABLE f_fix(f FLOAT(5,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE d(d DOUBLE); +CREATE TABLE d_fix(d DOUBLE(5,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO f VALUES (-3.4028234663852886e+38), (0), (3.4028234663852886e+38); +INSERT INTO f_fix VALUES (-999.00), (0), (999.99); +INSERT INTO d VALUES (-1.7976931348623157E+308), (0), (1.7976931348623157E+308); +INSERT INTO d_fix VALUES (-999.00), (0), (999.99); +ANALYZE TABLE f; +Table Op Msg_type Msg_text +test.f analyze status OK +ANALYZE TABLE f_fix; +Table Op Msg_type Msg_text +test.f_fix analyze status OK +ANALYZE TABLE d; +Table Op Msg_type Msg_text +test.d analyze status OK +ANALYZE TABLE d_fix; +Table Op Msg_type Msg_text +test.d_fix analyze status OK +# With float we should see folding +SELECT * FROM f WHERE f < 99999999999999999999999999999999999999999999999999999999999999999.0; +f +-3.40282e38 +0 +3.40282e38 +EXPLAIN SELECT * FROM f WHERE f < 99999999999999999999999999999999999999999999999999999999999999999.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` is not null) +# With double, only type adjustment +SELECT * FROM d WHERE d < 99999999999999999999999999999999999999999999999999999999999999999.0; +d +-1.7976931348623157e308 +0 +EXPLAIN SELECT * FROM d WHERE d < 99999999999999999999999999999999999999999999999999999999999999999.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE d NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d`.`d` AS `d` from `test`.`d` where (`test`.`d`.`d` < 1e65) +# Check around max float in decimal +SELECT * FROM f WHERE f < 100000000000000000000000000000000000000.0; +f +-3.40282e38 +0 +EXPLAIN SELECT * FROM f WHERE f < 100000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` < 1e38) +SELECT * FROM f WHERE f > 100000000000000000000000000000000000000.0; +f +3.40282e38 +EXPLAIN SELECT * FROM f WHERE f > 100000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` > 1e38) +SELECT * FROM f WHERE f < 1000000000000000000000000000000000000000.0; +f +-3.40282e38 +0 +3.40282e38 +EXPLAIN SELECT * FROM f WHERE f < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE f NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where (`test`.`f`.`f` is not null) +SELECT * FROM f WHERE f > 1000000000000000000000000000000000000000.0; +f +EXPLAIN SELECT * FROM f WHERE f > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`f`.`f` AS `f` from `test`.`f` where false +# Then compare with a DOUBLE field +SELECT * FROM d WHERE d < 1000000000000000000000000000000000000000.0; +d +-1.7976931348623157e308 +0 +EXPLAIN SELECT * FROM d WHERE d < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE d NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d`.`d` AS `d` from `test`.`d` where (`test`.`d`.`d` < 1e39) +SELECT * FROM d WHERE d > 1000000000000000000000000000000000000000.0; +d +1.7976931348623157e308 +EXPLAIN SELECT * FROM d WHERE d > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE d NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d`.`d` AS `d` from `test`.`d` where (`test`.`d`.`d` > 1e39) +Then with the two fixed real type fields, both of which +should be folded +SELECT * FROM f_fix WHERE f < 1000000000000000000000000000000000000000.0; +f +-999.00 +0.00 +999.99 +EXPLAIN SELECT * FROM f_fix WHERE f < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE f_fix NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`f_fix`.`f` AS `f` from `test`.`f_fix` where (`test`.`f_fix`.`f` is not null) +SELECT * FROM f_fix WHERE f > 1000000000000000000000000000000000000000.0; +f +EXPLAIN SELECT * FROM f_fix WHERE f > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`f_fix`.`f` AS `f` from `test`.`f_fix` where false +SELECT * FROM d_fix WHERE d < 1000000000000000000000000000000000000000.0; +d +-999.00 +0.00 +999.99 +EXPLAIN SELECT * FROM d_fix WHERE d < 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE d_fix NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`d_fix`.`d` AS `d` from `test`.`d_fix` where (`test`.`d_fix`.`d` is not null) +SELECT * FROM d_fix WHERE d > 1000000000000000000000000000000000000000.0; +d +EXPLAIN SELECT * FROM d_fix WHERE d > 1000000000000000000000000000000000000000.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`d_fix`.`d` AS `d` from `test`.`d_fix` where false +DROP TABLE f, f_fix, d, d_fix; +# I N T constant +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0; +y +SELECT * FROM tbl_year WHERE y <= 0; +y +0000 +SELECT * FROM tbl_year WHERE y > 0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1; +y +SELECT * FROM tbl_year WHERE y <= -1; +y +SELECT * FROM tbl_year WHERE y > -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1; +y +SELECT * FROM tbl_year WHERE y <> -1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1; +y +SELECT * FROM tbl_year WHERE y <> 1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300; +y +0000 +SELECT * FROM tbl_year WHERE y > 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300; +y +SELECT * FROM tbl_year WHERE y <> 300; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900; +y +SELECT * FROM tbl_year WHERE y <> 1900; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902; +y +SELECT * FROM tbl_year WHERE y <> 1902; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154; +y +SELECT * FROM tbl_year WHERE y <> 2154; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155; +y +SELECT * FROM tbl_year WHERE y >= 2155; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156; +y +SELECT * FROM tbl_year WHERE y >= 2156; +y +SELECT * FROM tbl_year WHERE y = 2156; +y +SELECT * FROM tbl_year WHERE y <> 2156; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# I N T abbreviated constant +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0; +y +SELECT * FROM tbl_year WHERE y <= 0; +y +0000 +SELECT * FROM tbl_year WHERE y > 0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1; +y +SELECT * FROM tbl_year WHERE y <= -1; +y +SELECT * FROM tbl_year WHERE y > -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1; +y +SELECT * FROM tbl_year WHERE y <> -1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1; +y +SELECT * FROM tbl_year WHERE y <> 1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300; +y +0000 +SELECT * FROM tbl_year WHERE y > 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300; +y +SELECT * FROM tbl_year WHERE y <> 300; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900; +y +SELECT * FROM tbl_year WHERE y <> 1900; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 01; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 01; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 01; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 01; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 01; +y +SELECT * FROM tbl_year WHERE y <> 01; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 01; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 02; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 02; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 02; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 02; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 02; +y +SELECT * FROM tbl_year WHERE y <> 02; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y > 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y = 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 02; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2002) +SELECT * FROM tbl_year WHERE y < 18; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 18; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 18; +y +2155 +SELECT * FROM tbl_year WHERE y >= 18; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 18; +y +2018 +SELECT * FROM tbl_year WHERE y <> 18; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 18; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154; +y +SELECT * FROM tbl_year WHERE y <> 2154; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155; +y +SELECT * FROM tbl_year WHERE y >= 2155; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156; +y +SELECT * FROM tbl_year WHERE y >= 2156; +y +SELECT * FROM tbl_year WHERE y = 2156; +y +SELECT * FROM tbl_year WHERE y <> 2156; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# D E C I M A L constant with zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.0; +y +SELECT * FROM tbl_year WHERE y <= 0.0; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.0; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.0; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.0; +y +SELECT * FROM tbl_year WHERE y <= -1.0; +y +SELECT * FROM tbl_year WHERE y > -1.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.0; +y +SELECT * FROM tbl_year WHERE y <> -1.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.0; +y +SELECT * FROM tbl_year WHERE y <> 1.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.0; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.0; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.0; +y +SELECT * FROM tbl_year WHERE y <> 300.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.0; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.0; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.0; +y +SELECT * FROM tbl_year WHERE y <> 1900.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.0; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.0; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.0; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.0; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.0; +y +SELECT * FROM tbl_year WHERE y <> 1902.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.0; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.0; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.0; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.0; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.0; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.0; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.0; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.0; +y +SELECT * FROM tbl_year WHERE y <> 2154.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.0; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.0; +y +SELECT * FROM tbl_year WHERE y >= 2155.0; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155.0; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155.0; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.0; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.0; +y +SELECT * FROM tbl_year WHERE y >= 2156.0; +y +SELECT * FROM tbl_year WHERE y = 2156.0; +y +SELECT * FROM tbl_year WHERE y <> 2156.0; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# D E C I M A L constant with non-zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.1; +y +SELECT * FROM tbl_year WHERE y <= 0.1; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.1; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.1; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.1; +y +SELECT * FROM tbl_year WHERE y <= -1.1; +y +SELECT * FROM tbl_year WHERE y > -1.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.1; +y +SELECT * FROM tbl_year WHERE y <> -1.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.1; +y +SELECT * FROM tbl_year WHERE y <> 1.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.1; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.1; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.1; +y +SELECT * FROM tbl_year WHERE y <> 300.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.1; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.1; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.1; +y +SELECT * FROM tbl_year WHERE y <> 1900.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.1; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.1; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.1; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.1; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.1; +y +SELECT * FROM tbl_year WHERE y <> 1902.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.1; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.1; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.1; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.1; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.1; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.1; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.1; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.1; +y +SELECT * FROM tbl_year WHERE y <> 2154.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.1; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.1; +y +SELECT * FROM tbl_year WHERE y >= 2155.1; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155.1; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155.1; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.1; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.1; +y +SELECT * FROM tbl_year WHERE y >= 2156.1; +y +SELECT * FROM tbl_year WHERE y = 2156.1; +y +SELECT * FROM tbl_year WHERE y <> 2156.1; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 0.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 0.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.9; +y +SELECT * FROM tbl_year WHERE y <> 0.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < -1.9; +y +SELECT * FROM tbl_year WHERE y <= -1.9; +y +SELECT * FROM tbl_year WHERE y > -1.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.9; +y +SELECT * FROM tbl_year WHERE y <> -1.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.9; +y +SELECT * FROM tbl_year WHERE y <> 1.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2002) +SELECT * FROM tbl_year WHERE y < 300.9; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.9; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.9; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.9; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.9; +y +SELECT * FROM tbl_year WHERE y <> 300.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.9; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1900.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.9; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.9; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1900.9; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1901.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1901.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.9; +y +SELECT * FROM tbl_year WHERE y <> 1901.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 1902.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.9; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.9; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.9; +y +SELECT * FROM tbl_year WHERE y <> 1902.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1903) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1903) +SELECT * FROM tbl_year WHERE y < 2018.9; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2018.9; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.9; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.9; +y +2155 +SELECT * FROM tbl_year WHERE y = 2018.9; +y +SELECT * FROM tbl_year WHERE y <> 2018.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2019) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2019) +SELECT * FROM tbl_year WHERE y < 2154.9; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2154.9; +y +SELECT * FROM tbl_year WHERE y >= 2154.9; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.9; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2154.9; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2155.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2155.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.9; +y +SELECT * FROM tbl_year WHERE y >= 2155.9; +y +SELECT * FROM tbl_year WHERE y = 2155.9; +y +SELECT * FROM tbl_year WHERE y <> 2155.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 2156.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.9; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.9; +y +SELECT * FROM tbl_year WHERE y >= 2156.9; +y +SELECT * FROM tbl_year WHERE y = 2156.9; +y +SELECT * FROM tbl_year WHERE y <> 2156.9; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# R E A L constant with zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.0E00; +y +SELECT * FROM tbl_year WHERE y <= 0.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.0E00; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.0E00; +y +SELECT * FROM tbl_year WHERE y <= -1.0E00; +y +SELECT * FROM tbl_year WHERE y > -1.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.0E00; +y +SELECT * FROM tbl_year WHERE y <> -1.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.0E00; +y +SELECT * FROM tbl_year WHERE y <> 1.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.0E00; +y +SELECT * FROM tbl_year WHERE y <> 300.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.0E00; +y +SELECT * FROM tbl_year WHERE y <> 1900.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.0E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.0E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.0E00; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.0E00; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.0E00; +y +SELECT * FROM tbl_year WHERE y <> 1902.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.0E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.0E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.0E00; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.0E00; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.0E00; +y +SELECT * FROM tbl_year WHERE y <> 2154.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.0E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2155.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.0E00; +y +SELECT * FROM tbl_year WHERE y >= 2155.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y = 2155.0E00; +y +2155 +SELECT * FROM tbl_year WHERE y <> 2155.0E00; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < 2156.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.0E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.0E00; +y +SELECT * FROM tbl_year WHERE y >= 2156.0E00; +y +SELECT * FROM tbl_year WHERE y = 2156.0E00; +y +SELECT * FROM tbl_year WHERE y <> 2156.0E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.0E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# R E A L constant with non-zero fraction +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < 0.1E00; +y +SELECT * FROM tbl_year WHERE y <= 0.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 0.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 0.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 0.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <> 0.1E00; +y +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y > 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 0) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 0) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 0.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 0) +SELECT * FROM tbl_year WHERE y < -1.1E00; +y +SELECT * FROM tbl_year WHERE y <= -1.1E00; +y +SELECT * FROM tbl_year WHERE y > -1.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= -1.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = -1.1E00; +y +SELECT * FROM tbl_year WHERE y <> -1.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> -1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1.1E00; +y +SELECT * FROM tbl_year WHERE y <> 1.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < 300.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 300.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 300.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 300.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 300.1E00; +y +SELECT * FROM tbl_year WHERE y <> 300.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 300.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1900.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1900.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y > 1900.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1900.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1900.1E00; +y +SELECT * FROM tbl_year WHERE y <> 1900.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1900.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 1901.1E00; +y +0000 +SELECT * FROM tbl_year WHERE y <= 1901.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1901.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1901.1E00; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1901.1E00; +y +1901 +SELECT * FROM tbl_year WHERE y <> 1901.1E00; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1901.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < 1902.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 1902.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > 1902.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= 1902.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 1902.1E00; +y +SELECT * FROM tbl_year WHERE y <> 1902.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 1902.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < 2018.1E00; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= 2018.1E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2018.1E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2018.1E00; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = 2018.1E00; +y +2018 +SELECT * FROM tbl_year WHERE y <> 2018.1E00; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2018.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < 2154.1E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= 2154.1E00; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > 2154.1E00; +y +2155 +SELECT * FROM tbl_year WHERE y >= 2154.1E00; +y +2155 +SELECT * FROM tbl_year WHERE y = 2154.1E00; +y +SELECT * FROM tbl_year WHERE y <> 2154.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2154.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < 2155.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2155.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2155.1E00; +y +SELECT * FROM tbl_year WHERE y >= 2155.1E00; +y +SELECT * FROM tbl_year WHERE y = 2155.1E00; +y +SELECT * FROM tbl_year WHERE y <> 2155.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2155.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < 2156.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= 2156.1E00; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > 2156.1E00; +y +SELECT * FROM tbl_year WHERE y >= 2156.1E00; +y +SELECT * FROM tbl_year WHERE y = 2156.1E00; +y +SELECT * FROM tbl_year WHERE y <> 2156.1E00; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> 2156.1E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with I N T inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0'; +y +SELECT * FROM tbl_year WHERE y <> '0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1'; +y +SELECT * FROM tbl_year WHERE y <= '-1'; +y +SELECT * FROM tbl_year WHERE y > '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1'; +y +SELECT * FROM tbl_year WHERE y <> '-1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1'; +y +SELECT * FROM tbl_year WHERE y <> '1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300'; +y +SELECT * FROM tbl_year WHERE y <> '300'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900'; +y +SELECT * FROM tbl_year WHERE y <> '1900'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1901'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1901'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1901'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1901'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1901'; +y +1901 +SELECT * FROM tbl_year WHERE y <> '1901'; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1901'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < '1902'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1902'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1902'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1902'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1902'; +y +SELECT * FROM tbl_year WHERE y <> '1902'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1902'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < '2018'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '2018'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2018'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2018'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '2018'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '2018'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2018'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154'; +y +SELECT * FROM tbl_year WHERE y <> '2154'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155'; +y +SELECT * FROM tbl_year WHERE y >= '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156'; +y +SELECT * FROM tbl_year WHERE y >= '2156'; +y +SELECT * FROM tbl_year WHERE y = '2156'; +y +SELECT * FROM tbl_year WHERE y <> '2156'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with abbreviated I N T inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0'; +y +SELECT * FROM tbl_year WHERE y <> '0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1'; +y +SELECT * FROM tbl_year WHERE y <= '-1'; +y +SELECT * FROM tbl_year WHERE y > '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1'; +y +SELECT * FROM tbl_year WHERE y <> '-1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1'; +y +SELECT * FROM tbl_year WHERE y <> '1'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300'; +y +SELECT * FROM tbl_year WHERE y <> '300'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900'; +y +SELECT * FROM tbl_year WHERE y <> '1900'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '01'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '01'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '01'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '01'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '01'; +y +SELECT * FROM tbl_year WHERE y <> '01'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '02'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '02'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '02'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '02'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '02'; +y +SELECT * FROM tbl_year WHERE y <> '02'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y > '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y = '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2002) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '02'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2002) +SELECT * FROM tbl_year WHERE y < '18'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '18'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '18'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '18'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '18'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '18'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '18'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154'; +y +SELECT * FROM tbl_year WHERE y <> '2154'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155'; +y +SELECT * FROM tbl_year WHERE y >= '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156'; +y +SELECT * FROM tbl_year WHERE y >= '2156'; +y +SELECT * FROM tbl_year WHERE y = '2156'; +y +SELECT * FROM tbl_year WHERE y <> '2156'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with D E C I M A L inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0.0'; +y +SELECT * FROM tbl_year WHERE y <> '0.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1.0'; +y +SELECT * FROM tbl_year WHERE y <= '-1.0'; +y +SELECT * FROM tbl_year WHERE y > '-1.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1.0'; +y +SELECT * FROM tbl_year WHERE y <> '-1.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1.0'; +y +SELECT * FROM tbl_year WHERE y <> '1.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300.0'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300.0'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300.0'; +y +SELECT * FROM tbl_year WHERE y <> '300.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900.0'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900.0'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900.0'; +y +SELECT * FROM tbl_year WHERE y <> '1900.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1901.0'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1901.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1901.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1901.0'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1901.0'; +y +1901 +SELECT * FROM tbl_year WHERE y <> '1901.0'; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1901.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < '1902.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1902.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1902.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1902.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1902.0'; +y +SELECT * FROM tbl_year WHERE y <> '1902.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1902.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < '2018.0'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '2018.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2018.0'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2018.0'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '2018.0'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '2018.0'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2018.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154.0'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154.0'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154.0'; +y +SELECT * FROM tbl_year WHERE y <> '2154.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155.0'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155.0'; +y +SELECT * FROM tbl_year WHERE y >= '2155.0'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155.0'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155.0'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156.0'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156.0'; +y +SELECT * FROM tbl_year WHERE y >= '2156.0'; +y +SELECT * FROM tbl_year WHERE y = '2156.0'; +y +SELECT * FROM tbl_year WHERE y <> '2156.0'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156.0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +# S T R I N G constant with R E A L inside +CREATE TABLE tbl_year (y YEAR ); +INSERT INTO tbl_year VALUES (0), (1901), (2018), (2155); +ANALYZE TABLE tbl_year; +Table Op Msg_type Msg_text +test.tbl_year analyze status OK +SELECT * FROM tbl_year; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y < '0.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '0.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '0.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '0.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '0.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '0.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y > '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y = '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2000) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '0.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2000) +SELECT * FROM tbl_year WHERE y < '-1.0E00'; +y +SELECT * FROM tbl_year WHERE y <= '-1.0E00'; +y +SELECT * FROM tbl_year WHERE y > '-1.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '-1.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '-1.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '-1.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <= '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y > '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y = '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '-1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '1.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2001) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2001) +SELECT * FROM tbl_year WHERE y < '300.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '300.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y > '300.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '300.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '300.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '300.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 300) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y > '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 300) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 300) +EXPLAIN SELECT * FROM tbl_year WHERE y = '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '300.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1900.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1900.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y > '1900.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1900.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1900.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '1900.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1900) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1900.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +SELECT * FROM tbl_year WHERE y < '1901.0E00'; +y +0000 +SELECT * FROM tbl_year WHERE y <= '1901.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1901.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1901.0E00'; +y +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1901.0E00'; +y +1901 +SELECT * FROM tbl_year WHERE y <> '1901.0E00'; +y +0000 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1901) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1901.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1901) +SELECT * FROM tbl_year WHERE y < '1902.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '1902.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y > '1902.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y >= '1902.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '1902.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '1902.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y > '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y = '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 1902) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '1902.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 1902) +SELECT * FROM tbl_year WHERE y < '2018.0E00'; +y +0000 +1901 +SELECT * FROM tbl_year WHERE y <= '2018.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2018.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2018.0E00'; +y +2018 +2155 +SELECT * FROM tbl_year WHERE y = '2018.0E00'; +y +2018 +SELECT * FROM tbl_year WHERE y <> '2018.0E00'; +y +0000 +1901 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2018) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2018.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2018) +SELECT * FROM tbl_year WHERE y < '2154.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2154.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y > '2154.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y >= '2154.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2154.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '2154.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` > 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` >= 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2154) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2154.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2154) +SELECT * FROM tbl_year WHERE y < '2155.0E00'; +y +0000 +1901 +2018 +SELECT * FROM tbl_year WHERE y <= '2155.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2155.0E00'; +y +SELECT * FROM tbl_year WHERE y >= '2155.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y = '2155.0E00'; +y +2155 +SELECT * FROM tbl_year WHERE y <> '2155.0E00'; +y +0000 +1901 +2018 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` < 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y = '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` = 2155) +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2155.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` <> 2155) +SELECT * FROM tbl_year WHERE y < '2156.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y <= '2156.0E00'; +y +0000 +1901 +2018 +2155 +SELECT * FROM tbl_year WHERE y > '2156.0E00'; +y +SELECT * FROM tbl_year WHERE y >= '2156.0E00'; +y +SELECT * FROM tbl_year WHERE y = '2156.0E00'; +y +SELECT * FROM tbl_year WHERE y <> '2156.0E00'; +y +0000 +1901 +2018 +2155 +EXPLAIN SELECT * FROM tbl_year WHERE y < '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y <= '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +EXPLAIN SELECT * FROM tbl_year WHERE y > '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y >= '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y = '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where false +EXPLAIN SELECT * FROM tbl_year WHERE y <> '2156.0E00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_year NULL ALL NULL NULL NULL NULL 4 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_year`.`y` AS `y` from `test`.`tbl_year` where (`test`.`tbl_year`.`y` is not null) +DROP TABLE tbl_year; +CREATE TABLE tbl_ts (t TIMESTAMP ); +INSERT INTO tbl_ts VALUES ('1970-01-01 03:00:01'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07'); +ANALYZE TABLE tbl_ts; +Table Op Msg_type Msg_text +test.tbl_ts analyze status OK +SELECT * FROM tbl_ts; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +Zero date? +SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) + +Some in range constants + +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_ts WHERE t < 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t > 20380119061407; +t +SELECT * FROM tbl_ts WHERE t >= 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t <> 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018) +SELECT * FROM tbl_ts WHERE t < 0; +t +SELECT * FROM tbl_ts WHERE t <= 0; +t +SELECT * FROM tbl_ts WHERE t > 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 0; +t +SELECT * FROM tbl_ts WHERE t <> 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_ts WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018.55) +SELECT * FROM tbl_ts WHERE t < 0.00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00; +t +SELECT * FROM tbl_ts WHERE t > 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 0.00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_ts WHERE t < 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00E00; +t +SELECT * FROM tbl_ts WHERE t > 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t >= 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_ts WHERE t = 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_ts; +CREATE TABLE tbl_ts (t TIMESTAMP(2) ); +INSERT INTO tbl_ts VALUES ('1970-01-01 03:00:01.00'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.99'); +ANALYZE TABLE tbl_ts; +Table Op Msg_type Msg_text +test.tbl_ts analyze status OK +SELECT * FROM tbl_ts; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +Zero date? +SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) + +Some in range constants + +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_ts WHERE t < 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 20380119061407; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018) +SELECT * FROM tbl_ts WHERE t < 0; +t +SELECT * FROM tbl_ts WHERE t <= 0; +t +SELECT * FROM tbl_ts WHERE t > 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 0; +t +SELECT * FROM tbl_ts WHERE t <> 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_ts WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018.55) +SELECT * FROM tbl_ts WHERE t < 0.00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00; +t +SELECT * FROM tbl_ts WHERE t > 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 0.00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_ts WHERE t < 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00E00; +t +SELECT * FROM tbl_ts WHERE t > 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_ts WHERE t = 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_ts; +CREATE TABLE tbl_ts (t TIMESTAMP(6) ); +INSERT INTO tbl_ts VALUES ('1970-01-01 03:00:01.000000'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.999999'); +ANALYZE TABLE tbl_ts; +Table Op Msg_type Msg_text +test.tbl_ts analyze status OK +SELECT * FROM tbl_ts; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +Zero date? +SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where false +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` is not null) + +Some in range constants + +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_ts WHERE t < 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 20380119061407; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_ts WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018) +SELECT * FROM tbl_ts WHERE t < 0; +t +SELECT * FROM tbl_ts WHERE t <= 0; +t +SELECT * FROM tbl_ts WHERE t > 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 0; +t +SELECT * FROM tbl_ts WHERE t <> 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_ts WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t > 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t >= 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_ts WHERE t <> 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> 2018.55) +SELECT * FROM tbl_ts WHERE t < 0.00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00; +t +SELECT * FROM tbl_ts WHERE t > 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 0.00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'2038-01-19 06:14:05.550781') +SELECT * FROM tbl_ts WHERE t < 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <= 0.00E00; +t +SELECT * FROM tbl_ts WHERE t > 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_ts WHERE t = 0.00E00; +t +SELECT * FROM tbl_ts WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_ts WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_ts WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_ts NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_ts`.`t` AS `t` from `test`.`tbl_ts` where (`test`.`tbl_ts`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_ts; +CREATE TABLE tbl_datetime (t DATETIME ); +INSERT INTO tbl_datetime VALUES ('1970-01-01 03:00:01'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07'); +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +SELECT * FROM tbl_datetime; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') +Zero date? +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08.000000') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') + +Some in range constants + +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_datetime WHERE t < 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t > 20380119061407; +t +SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 20380119061407; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018) +SELECT * FROM tbl_datetime WHERE t < 0; +t +SELECT * FROM tbl_datetime WHERE t <= 0; +t +SELECT * FROM tbl_datetime WHERE t > 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 0; +t +SELECT * FROM tbl_datetime WHERE t <> 0; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_datetime WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018.55; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018.55) +SELECT * FROM tbl_datetime WHERE t < 0.00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 0.00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:06') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:06') +SELECT * FROM tbl_datetime WHERE t < 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +SELECT * FROM tbl_datetime WHERE t = 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +t +1970-01-01 03:00:01 +2018-06-19 21:00:00 +2038-01-19 06:14:07 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_datetime; +CREATE TABLE tbl_datetime (t DATETIME(2) ); +INSERT INTO tbl_datetime VALUES ('1970-01-01 03:00:01.00'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.99'); +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +SELECT * FROM tbl_datetime; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') +Zero date? +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08.000000') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') + +Some in range constants + +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.00 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_datetime WHERE t < 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 20380119061407; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018) +SELECT * FROM tbl_datetime WHERE t < 0; +t +SELECT * FROM tbl_datetime WHERE t <= 0; +t +SELECT * FROM tbl_datetime WHERE t > 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 0; +t +SELECT * FROM tbl_datetime WHERE t <> 0; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_datetime WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018.55; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018.55) +SELECT * FROM tbl_datetime WHERE t < 0.00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 0.00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_datetime WHERE t < 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +SELECT * FROM tbl_datetime WHERE t = 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.00 +2018-06-19 21:00:00.00 +2038-01-19 06:14:07.99 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_datetime; +CREATE TABLE tbl_datetime (t DATETIME(6) ); +INSERT INTO tbl_datetime VALUES ('1970-01-01 03:00:01.000000'), ('2018-06-19 21:00:00'), ('2038-01-19 06:14:07.999999'); +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +SELECT * FROM tbl_datetime; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + +TIMESTAMP: Some out of range constants (adjusted to TZ +0300 +for MTR) +DATETIME: 1970, 2038 just fine. +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 10:20:30') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 10:20:30'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 10:20:30') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') +Zero date? +SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '0000-00-00 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +Zero in date +SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +t +SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2018-00-03 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2018-00-03 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2018-00-03 00:00:00') + +Some in range string literals + +SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> '1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +2. TIMESTAMP literals +These are the same as above, but with TIMESTAMP prefix. + +TIMESTAMP field: Some out of range constants (adjusted to TZ ++0300 for MTR) +DATETIME field: in range +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07.999999') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:08.000000') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:08.000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:08.000000') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 00:00:01') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:00.999999'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:00.999999') + +Some in range constants + +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +t +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'2038-01-19 06:14:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +t +SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +t +1970-01-01 03:00:01.000000 +SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +t +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'1970-01-01 03:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> TIMESTAMP'1970-01-01 03:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'1970-01-01 03:00:01') + +3. Integer literals + +SELECT * FROM tbl_datetime WHERE t < 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 20380119061407; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:07') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061407; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:07') +SELECT * FROM tbl_datetime WHERE t < 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018) +SELECT * FROM tbl_datetime WHERE t < 0; +t +SELECT * FROM tbl_datetime WHERE t <= 0; +t +SELECT * FROM tbl_datetime WHERE t > 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 0; +t +SELECT * FROM tbl_datetime WHERE t <> 0; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Decimal literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.55') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.55') +SELECT * FROM tbl_datetime WHERE t < 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <= 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t > 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t >= 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t = 2018.55; +t +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +SELECT * FROM tbl_datetime WHERE t <> 2018.55; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = 2018.55) +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2018.55' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> 2018.55) +SELECT * FROM tbl_datetime WHERE t < 0.00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 0.00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') + +3. Real literals: rounded up to whole seconds + +SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +t +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +t +SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'2038-01-19 06:14:05.550781') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 20380119061405.55E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'2038-01-19 06:14:05.550781') +SELECT * FROM tbl_datetime WHERE t < 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t > 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +SELECT * FROM tbl_datetime WHERE t = 0.00E00; +t +SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +t +1970-01-01 03:00:01.000000 +2018-06-19 21:00:00.000000 +2038-01-19 06:14:07.999999 +EXPLAIN SELECT * FROM tbl_datetime WHERE t < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` < TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` > TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` >= TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` = TIMESTAMP'0000-00-00 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE t <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`t` AS `t` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`t` <> TIMESTAMP'0000-00-00 00:00:00') +DROP TABLE tbl_datetime; +CREATE TABLE tbl_date(d DATE); +INSERT INTO tbl_date VALUES ('0000-01-01'), ('2038-01-19'), ('9999-12-31'); +ANALYZE TABLE tbl_date; +Table Op Msg_type Msg_text +test.tbl_date analyze status OK +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=ALLOW_INVALID_DATES; + +1. String literals + + +Semi supported +SELECT * FROM tbl_date WHERE d < '0000-01-01'; +d +SELECT * FROM tbl_date WHERE d <= '0000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '0000-01-01'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '0000-01-01'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '0000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <> '0000-01-01'; +d +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d > '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d = '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '0000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-01-01') +SELECT * FROM tbl_date WHERE d < '2038-01-19'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '2038-01-19'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > '2038-01-19'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2038-01-19'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2038-01-19'; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> '2038-01-19'; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2038-01-19'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +SELECT * FROM tbl_date WHERE d < '1000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '1000-01-01'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '1000-01-01'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '1000-01-01'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '1000-01-01'; +d +SELECT * FROM tbl_date WHERE d <> '1000-01-01'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d > '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d = '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '1000-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'1000-01-01') +SELECT * FROM tbl_date WHERE d < '9999-12-31'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d <= '9999-12-31'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d > '9999-12-31'; +d +SELECT * FROM tbl_date WHERE d >= '9999-12-31'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d = '9999-12-31'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d <> '9999-12-31'; +d +0000-01-01 +2038-01-19 +EXPLAIN SELECT * FROM tbl_date WHERE d < '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d > '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d = '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '9999-12-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'9999-12-31') +Compare to a full datetime value instead of a date +SELECT * FROM tbl_date WHERE d < '2038-01-19 12:45:00'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d <= '2038-01-19 12:45:00'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > '2038-01-19 12:45:00'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2038-01-19 12:45:00'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2038-01-19 12:45:00'; +d +SELECT * FROM tbl_date WHERE d <> '2038-01-19 12:45:00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where false +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2038-01-19 12:45:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` is not null) +Zero date? +SELECT * FROM tbl_date WHERE d < '0000-00-00'; +d +SELECT * FROM tbl_date WHERE d <= '0000-00-00'; +d +SELECT * FROM tbl_date WHERE d > '0000-00-00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '0000-00-00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '0000-00-00'; +d +SELECT * FROM tbl_date WHERE d <> '0000-00-00'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '0000-00-00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') +Zero in date +SELECT * FROM tbl_date WHERE d < '2018-00-03'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '2018-00-03'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '2018-00-03'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2018-00-03'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2018-00-03'; +d +SELECT * FROM tbl_date WHERE d <> '2018-00-03'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2018-00-03') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2018-00-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2018-00-03') +Strangely, this does not give an error nor warning, and does +comparison using internal datetime comparison (pre-folding), so +we do the same. +SELECT * FROM tbl_date WHERE d < '2018-02-31'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= '2018-02-31'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d > '2018-02-31'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= '2018-02-31'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = '2018-02-31'; +d +SELECT * FROM tbl_date WHERE d <> '2018-02-31'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <= '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d > '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d >= '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d = '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2018-02-31') +EXPLAIN SELECT * FROM tbl_date WHERE d <> '2018-02-31'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2018-02-31') + +2. TIMESTAMP literals compared with DATE field + +SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:00'; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:00'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:00'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:00'; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:00'; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:00'; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = TIMESTAMP'2038-01-19 00:00:00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> TIMESTAMP'2038-01-19 00:00:00') +SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:01'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:01'; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:01'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:01'; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:01'; +d +SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:01'; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d <= TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d > TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d >= TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d = TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = TIMESTAMP'2038-01-19 00:00:01') +EXPLAIN SELECT * FROM tbl_date WHERE d <> TIMESTAMP'2038-01-19 00:00:01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> TIMESTAMP'2038-01-19 00:00:01') + +3. Integer literals + +in range +SELECT * FROM tbl_date WHERE d < 20380119; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +incorrect value; removes time part +SELECT * FROM tbl_date WHERE d < 20380119124500; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119124500; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119124500; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119124500; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119124500; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119124500; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119124500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +out of range; interpreted as a value smaller than TIMESTAMP min +SELECT * FROM tbl_date WHERE d < 2018; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <= 2018; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d > 2018; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d >= 2018; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d = 2018; +d +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <> 2018; +d +0000-01-01 +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +EXPLAIN SELECT * FROM tbl_date WHERE d < 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d <= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d > 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d >= 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d = 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = 2018) +EXPLAIN SELECT * FROM tbl_date WHERE d <> 2018; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect date value: '2018' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> 2018) +SELECT * FROM tbl_date WHERE d < 0; +d +SELECT * FROM tbl_date WHERE d <= 0; +d +SELECT * FROM tbl_date WHERE d > 0; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 0; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 0; +d +SELECT * FROM tbl_date WHERE d <> 0; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') + +3. Decimal literals + +SELECT * FROM tbl_date WHERE d < 20380119.00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119.00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119.00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119.00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119.00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119.00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +incorrect value; removes time part +SELECT * FROM tbl_date WHERE d < 20380119061405.00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119061405.00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119061405.00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119061405.00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119061405.00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119061405.00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119061405.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +out of range - compare using double +SELECT * FROM tbl_date WHERE d < 2018.55; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <= 2018.55; +d +0000-01-01 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d > 2018.55; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d >= 2018.55; +d +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d = 2018.55; +d +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +SELECT * FROM tbl_date WHERE d <> 2018.55; +d +0000-01-01 +2038-01-19 +9999-12-31 +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +EXPLAIN SELECT * FROM tbl_date WHERE d < 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d <= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d > 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d >= 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d = 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = 2018.55) +EXPLAIN SELECT * FROM tbl_date WHERE d <> 2018.55; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Warning 1292 Incorrect date value: '2018.55' for column 'd' at row 1 +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> 2018.55) +SELECT * FROM tbl_date WHERE d < 0.00; +d +SELECT * FROM tbl_date WHERE d <= 0.00; +d +SELECT * FROM tbl_date WHERE d > 0.00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 0.00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 0.00; +d +SELECT * FROM tbl_date WHERE d <> 0.00; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 0.00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') + +3. Real literals: rounded up to whole seconds + +in range +SELECT * FROM tbl_date WHERE d < 20380119E00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119E00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119E00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119E00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119E00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119E00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +incorrect value; removes time part +SELECT * FROM tbl_date WHERE d < 20380119194500E00; +d +0000-01-01 +SELECT * FROM tbl_date WHERE d <= 20380119194500E00; +d +0000-01-01 +2038-01-19 +SELECT * FROM tbl_date WHERE d > 20380119194500E00; +d +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 20380119194500E00; +d +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 20380119194500E00; +d +2038-01-19 +SELECT * FROM tbl_date WHERE d <> 20380119194500E00; +d +0000-01-01 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d > 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d = 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'2038-01-19') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 20380119194500E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'2038-01-19') +out of range compare using double +SELECT * FROM tbl_date WHERE d < 0.00E00; +d +SELECT * FROM tbl_date WHERE d <= 0.00E00; +d +SELECT * FROM tbl_date WHERE d > 0.00E00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d >= 0.00E00; +d +0000-01-01 +2038-01-19 +9999-12-31 +SELECT * FROM tbl_date WHERE d = 0.00E00; +d +SELECT * FROM tbl_date WHERE d <> 0.00E00; +d +0000-01-01 +2038-01-19 +9999-12-31 +EXPLAIN SELECT * FROM tbl_date WHERE d < 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` < DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d > 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` > DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d >= 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` >= DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d = 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` = DATE'0000-00-00') +EXPLAIN SELECT * FROM tbl_date WHERE d <> 0.00E00; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`d` AS `d` from `test`.`tbl_date` where (`test`.`tbl_date`.`d` <> DATE'0000-00-00') +DROP TABLE tbl_date; +SET SESSION sql_mode = DEFAULT; +CREATE TABLE t(t TIME); +INSERT INTO t VALUES ('18:00:00'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM t WHERE t = '18:00:00'; +t +18:00:00 +SELECT * FROM t WHERE t = '18:00:00.001'; +t +18:00:00 +SELECT * FROM t WHERE t = 180000; +t +18:00:00 +SELECT * FROM t WHERE t = 180000.001; +t +18:00:00 +SELECT * FROM t WHERE t = 'abra cadabra'; +t +Warnings: +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Note: for explicit TIME literal, the fraction part is not truncated +This is existing behavior, not changed for WL#11935. +SELECT * FROM t WHERE t = TIME'180000.001'; +t +EXPLAIN SELECT * FROM t WHERE t = '18:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = '18:00:00.001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = 180000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = 180000.001; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00') +EXPLAIN SELECT * FROM t WHERE t = TIME'180000.001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = TIME'18:00:00.001') +EXPLAIN SELECT * FROM t WHERE t = 'abra cadabra'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: 'abra cadabra' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = 'abra cadabra') +EXPLAIN SELECT * FROM t WHERE t = 3.14E44; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '3.14e44' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = 3.14E44) +EXPLAIN SELECT * FROM t WHERE t = 30000000000000000.3567; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '30000000000000000.3567' for column 't' at row 1 +Note 1003 /* select#1 */ select `test`.`t`.`t` AS `t` from `test`.`t` where (`test`.`t`.`t` = 30000000000000000.3567) +DROP TABLE t; +CREATE TABLE t(i TINYINT NOT NULL, j TINYINT NOT NULL); +INSERT INTO t VALUES (1,1), (1,2), (2,1), (2,2); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +Should fold to TRUE +SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`i`) AS `s`,`test`.`t`.`j` AS `j` from `test`.`t` where true group by `test`.`t`.`j` +SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j WITH ROLLUP; +s j +3 1 +3 2 +6 NULL +EXPLAIN SELECT SUM(i) s, j FROM t WHERE j != 128 GROUP BY j WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select rollup_sum_switcher(sum(`test`.`t`.`i`)) AS `s`,rollup_group_item(`test`.`t`.`j`,0) AS `j` from `test`.`t` where true group by `test`.`t`.`j` with rollup +SELECT SUM(i) s, j FROM t GROUP BY j HAVING j != 128; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t GROUP BY j HAVING j != 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`i`) AS `s`,`test`.`t`.`j` AS `j` from `test`.`t` group by `test`.`t`.`j` having true +Should fold to IS NOT NULL +SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j != 128; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j != 128; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select rollup_sum_switcher(sum(`test`.`t`.`i`)) AS `s`,rollup_group_item(`test`.`t`.`j`,0) AS `j` from `test`.`t` group by `test`.`t`.`j` with rollup having (rollup_group_item(rollup_group_item(`test`.`t`.`j`,0),0) <> 128) +SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j IS NOT NULL; +s j +3 1 +3 2 +EXPLAIN SELECT SUM(i) s, j FROM t GROUP BY j WITH ROLLUP HAVING j IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select rollup_sum_switcher(sum(`test`.`t`.`i`)) AS `s`,rollup_group_item(`test`.`t`.`j`,0) AS `j` from `test`.`t` group by `test`.`t`.`j` with rollup having (rollup_group_item(rollup_group_item(`test`.`t`.`j`,0),0) is not null) +DROP TABLE t; +CREATE TABLE a(col_int INT, col_date DATE); +SELECT col_date FROM a WHERE +(NULL, NULL) IN (SELECT col_date, col_date FROM a) OR +(col_int <> 'C') ; +col_date +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'C' +DROP TABLE a; +CREATE TABLE t11 (col_time TIME); +INSERT INTO t11 VALUES('11:00:00'); +An integer value that could not be converted into a TIME literal +should default to old behavior (comparing as double). +EXPLAIN SELECT col_time FROM t11 HAVING col_time > 156970; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Note 1003 /* select#1 */ select `test`.`t11`.`col_time` AS `col_time` from `test`.`t11` having (`test`.`t11`.`col_time` > 156970) +SELECT col_time FROM t11 HAVING col_time > 156970; +col_time +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +EXPLAIN SELECT col_time FROM t11 WHERE col_time > 156970; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Note 1003 /* select#1 */ select `test`.`t11`.`col_time` AS `col_time` from `test`.`t11` where (`test`.`t11`.`col_time` > 156970) +SELECT col_time FROM t11 WHERE col_time > 156970; +col_time +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +EXPLAIN SELECT col_time FROM t11 WHERE col_time < 156970; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Note 1003 /* select#1 */ select `test`.`t11`.`col_time` AS `col_time` from `test`.`t11` where (`test`.`t11`.`col_time` < 156970) +SELECT col_time FROM t11 WHERE col_time < 156970; +col_time +11:00:00 +Warnings: +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +Warning 1292 Incorrect time value: '156970' for column 'col_time' at row 1 +DROP TABLE t11; +CREATE TABLE t1(d DOUBLE); +INSERT INTO t1 VALUES (3.3); +CREATE TABLE t2 (ts TIMESTAMP); +INSERT INTO t2 VALUES ('2018-09-15 11:00:25.00'); +WITH RECURSIVE +cte1 AS ( SELECT ts AS a1 FROM t2 ), +cte2 AS ( SELECT LAST_DAY(18446744073709551615+1) AS a2 FROM t1 ) +SELECT * FROM cte1, cte2 WHERE cte1.a1 <> cte2.a2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1)' +DROP TABLE t1, t2; +CREATE TABLE t(c DECIMAL(9,3)); +SELECT * FROM t WHERE c <=> 8106.000000; +c +EXPLAIN SELECT * from t WHERE c <=> 8106.000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`c` AS `c` from `test`.`t` where (`test`.`t`.`c` <=> 8106.000) +DROP TABLE t; +CREATE TABLE t0(c0 TINYINT); +INSERT INTO t0(c0) VALUES(NULL); +SELECT * FROM t0 WHERE NOT(t0.c0 <=> 2035382037); +c0 +NULL +SELECT * FROM t0 WHERE t0.c0 <=> 2035382037; +c0 +DROP TABLE t0; +CREATE TABLE t0(c0 INT); +INSERT INTO t0(c0) VALUES (0); +SELECT * FROM t0 WHERE 0.9 > t0.c0; +c0 +0 +DROP TABLE t0; diff --git a/mysql-test/r/create.result-pq b/mysql-test/r/create.result-pq new file mode 100644 index 000000000..f9c11d0d2 --- /dev/null +++ b/mysql-test/r/create.result-pq @@ -0,0 +1,3065 @@ +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +drop table if exists t1,t2,t3,t4,t5; +drop database if exists mysqltest; +drop view if exists v1; +create table t1 (b char(0)); +insert into t1 values (""),(null); +select * from t1; +b + +NULL +drop table if exists t1; +create table t1 (b char(0) not null); +create table if not exists t1 (b char(0) not null); +Warnings: +Note 1050 Table 't1' already exists +insert into t1 values (""),(null); +Warnings: +Warning 1048 Column 'b' cannot be null +select * from t1; +b + + +drop table t1; +create table t1 (a int not null auto_increment,primary key (a)) engine=heap; +drop table t1; +create table t2 engine=heap select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table t2 select auto+1 from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 'test.t1' +Note 1051 Unknown table 'test.t2' +create table t1 (b char(0) not null, index(b)); +ERROR 42000: The used storage engine can't index column 'b' +create table t1 (a int not null,b text) engine=heap; +ERROR 42000: The used table type doesn't support BLOB/TEXT columns +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=heap; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +create table not_existing_database.test (a int); +ERROR 42000: Unknown database 'not_existing_database' +create temporary table not_existing_database.test (a int); +ERROR 42000: Unknown database 'not_existing_database' +create table `a/a` (a int); +show create table `a/a`; +Table Create Table +a/a CREATE TABLE `a/a` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t1 like `a/a`; +drop table `a/a`; +drop table `t1`; +create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int); +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int); +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +create table t1 (a int default 100 auto_increment); +ERROR 42000: Invalid default value for 'a' +create table t1 (a tinyint default 1000); +ERROR 42000: Invalid default value for 'a' +create table t1 (a varchar(5) default 'abcdef'); +ERROR 42000: Invalid default value for 'a' +create table t1 (a varchar(5) default 'abcde'); +insert into t1 values(); +select * from t1; +a +abcde +alter table t1 alter column a set default 'abcdef'; +ERROR 42000: Invalid default value for 'a' +drop table t1; +create table 1ea10 (1a20 int,1e int); +insert into 1ea10 values(1,1); +select 1ea10.1a20,1e+ 1e+10 from 1ea10; +1a20 1e+ 1e+10 +1 10000000001 +drop table 1ea10; +create table t1 (`index` int); +drop table t1; +drop database if exists mysqltest; +Warnings: +Note 1008 Can't drop database 'mysqltest'; database doesn't exist +create database mysqltest; +create table mysqltest.$test1 (a$1 int, $b int, c$ int); +insert into mysqltest.$test1 values (1,2,3); +select a$1, $b, c$ from mysqltest.$test1; +a$1 $b c$ +1 2 3 +create table mysqltest.test2$ (a int); +drop table mysqltest.test2$; +drop database mysqltest; +create table `` (a int); +ERROR 42000: Incorrect table name '' +drop table if exists ``; +ERROR 42000: Incorrect table name '' +create table t1 (`` int); +ERROR 42000: Incorrect column name '' +create table t1 (i int, index `` (i)); +ERROR 42000: Incorrect index name '' +create table t1 (i int); +lock tables t1 read; +create table t2 (j int); +ERROR HY000: Table 't2' was not locked with LOCK TABLES +create temporary table t2 (j int); +drop temporary table t2; +unlock tables; +drop table t1; +create table t1 (a int auto_increment not null primary key, B CHAR(20)); +insert into t1 (b) values ("hello"),("my"),("world"); +create table t2 (key (b)) select * from t1; +explain select * from t2 where b="world"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref B B 81 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`B` AS `B` from `test`.`t2` where (`test`.`t2`.`B` = 'world') +select * from t2 where b="world"; +a B +3 world +drop table t1,t2; +create table t1(x varchar(50) ); +create table t2 select x from t1 where 1=2; +describe t1; +Field Type Null Key Default Extra +x varchar(50) YES NULL +describe t2; +Field Type Null Key Default Extra +x varchar(50) YES NULL +drop table t2; +create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f; +describe t2; +Field Type Null Key Default Extra +a datetime NO 0000-00-00 00:00:00 +b time NO 00:00:00 +c date NO 0000-00-00 +d int NO 0 +e decimal(3,1) NO 0.0 +f bigint NO 0 +drop table t2; +create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt; +describe t2; +Field Type Null Key Default Extra +d date YES NULL +t time YES NULL +dt datetime YES NULL +drop table t1,t2; +create table t1 (a tinyint); +create table t2 (a int) select * from t1; +describe t1; +Field Type Null Key Default Extra +a tinyint YES NULL +describe t2; +Field Type Null Key Default Extra +a int YES NULL +drop table if exists t2; +create table t2 (a int, a float) select * from t1; +ERROR 42S21: Duplicate column name 'a' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +create table t2 (a int) select a as b, a+1 as b from t1; +ERROR 42S21: Duplicate column name 'b' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +create table t2 (b int) select a as b, a+1 as b from t1; +ERROR 42S21: Duplicate column name 'b' +drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t1 (a int not null); +INSERT INTO t1 values (1),(2),(1); +CREATE TABLE t2 (primary key(a)) SELECT * FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +DROP TABLE t1; +DROP TABLE IF EXISTS t2; +Warnings: +Note 1051 Unknown table 'test.t2' +create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b)); +Warnings: +Warning 1831 Duplicate index 'b_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_5' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_6' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_7' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_8' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_9' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_10' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_11' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_12' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_13' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_14' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_15' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_16' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_17' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_18' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_19' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_20' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_21' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_22' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_23' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_24' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_25' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_26' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_27' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_28' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_29' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_30' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +Warning 1831 Duplicate index 'b_31' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`), + KEY `b_2` (`b`), + KEY `b_3` (`b`), + KEY `b_4` (`b`), + KEY `b_5` (`b`), + KEY `b_6` (`b`), + KEY `b_7` (`b`), + KEY `b_8` (`b`), + KEY `b_9` (`b`), + KEY `b_10` (`b`), + KEY `b_11` (`b`), + KEY `b_12` (`b`), + KEY `b_13` (`b`), + KEY `b_14` (`b`), + KEY `b_15` (`b`), + KEY `b_16` (`b`), + KEY `b_17` (`b`), + KEY `b_18` (`b`), + KEY `b_19` (`b`), + KEY `b_20` (`b`), + KEY `b_21` (`b`), + KEY `b_22` (`b`), + KEY `b_23` (`b`), + KEY `b_24` (`b`), + KEY `b_25` (`b`), + KEY `b_26` (`b`), + KEY `b_27` (`b`), + KEY `b_28` (`b`), + KEY `b_29` (`b`), + KEY `b_30` (`b`), + KEY `b_31` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 select if(1,'1','0'), month("2002-08-02"); +drop table t1; +create table t1 select if('2002'='2002','Y','N'); +select * from t1; +if('2002'='2002','Y','N') +Y +drop table if exists t1; +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET SESSION default_storage_engine="gemini"; +ERROR 42000: Unknown storage engine 'gemini' +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET SESSION default_storage_engine=default; +drop table t1; +create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2)); +insert into t1 values ("a", 1), ("b", 2); +insert into t1 values ("c", NULL); +ERROR 23000: Column 'k2' cannot be null +insert into t1 values (NULL, 3); +ERROR 23000: Column 'k1' cannot be null +insert into t1 values (NULL, NULL); +ERROR 23000: Column 'k1' cannot be null +drop table t1; +create table t1 select x'4132'; +drop table t1; +create table t1 select 1,2,3; +create table if not exists t1 select 1,2; +Warnings: +Note 1050 Table 't1' already exists +create table if not exists t1 select 1,2,3,4; +Warnings: +Note 1050 Table 't1' already exists +create table if not exists t1 select 1; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +1 2 3 +1 2 3 +drop table t1; +flush status; +create table t1 (a int not null, b int, primary key (a)); +insert into t1 values (1,1); +create table if not exists t1 select 2; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a b +1 1 +create table if not exists t1 select 3 as 'a',4 as 'b'; +Warnings: +Note 1050 Table 't1' already exists +show warnings; +Level Code Message +Note 1050 Table 't1' already exists +show status like "Opened_tables"; +Variable_name Value +Opened_tables 1 +select * from t1; +a b +1 1 +drop table t1; +create table `t1 `(a int); +ERROR 42000: Incorrect table name 't1 ' +create database `db1 `; +ERROR 42000: Incorrect database name 'db1 ' +create table t1(`a ` int); +ERROR 42000: Incorrect column name 'a ' +create table t1 (a int,); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +create table t1 (a int,,b int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',b int)' at line 1 +create table t1 (,b int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',b int)' at line 1 +create table t1 (a int, key(a)); +create table t2 (b int, foreign key(b) references t1(a), key(b)); +drop table if exists t2,t1; +create table t1(id int not null, name char(20)); +insert into t1 values(10,'mysql'),(20,'monty- the creator'); +create table t2(id int not null); +insert into t2 values(10),(20); +create table t3 like t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3; +id name +create table if not exists t3 like t1; +Warnings: +Note 1050 Table 't3' already exists +select @@warning_count; +@@warning_count +1 +create temporary table t3 like t2; +show create table t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `id` int NOT NULL +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3; +id +drop table t3; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3; +id name +drop table t2, t3; +create database mysqltest; +create table mysqltest.t3 like t1; +create temporary table t3 like mysqltest.t3; +show create table t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 like t3; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `name` char(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t2; +id name +create table t3 like t1; +create table t3 like mysqltest.t3; +ERROR 42S01: Table 't3' already exists +create table non_existing_database.t1 like t1; +ERROR 42000: Unknown database 'non_existing_database' +create table t3 like non_existing_table; +ERROR 42S02: Table 'test.non_existing_table' doesn't exist +create temporary table t3 like t1; +ERROR 42S01: Table 't3' already exists +drop table t1, t2, t3; +drop table t3; +drop database mysqltest; +create table t1 (i int); +create table t2 (j int); +lock tables t1 read; +create table t3 like t1; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +create temporary table t3 like t1; +drop temporary table t3; +create temporary table t3 like t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop tables t1, t2; +SET SESSION default_storage_engine="heap"; +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET SESSION default_storage_engine="gemini"; +ERROR 42000: Unknown storage engine 'gemini' +SELECT @@default_storage_engine; +@@default_storage_engine +MEMORY +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET SESSION default_storage_engine=default; +drop table t1; +create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob); +insert into t1(a)values(1); +insert into t1(a,b,c,d,e,f,g,h) +values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data'); +select * from t1; +a b c d e f g h +1 NULL NULL NULL NULL NULL NULL NULL +2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data +select a, +ifnull(b,cast(-7 as signed)) as b, +ifnull(c,cast(7 as unsigned)) as c, +ifnull(d,cast('2000-01-01' as date)) as d, +ifnull(e,cast('b' as char)) as e, +ifnull(f,cast('2000-01-01' as datetime)) as f, +ifnull(g,cast('5:4:3' as time)) as g, +ifnull(h,cast('yet another binary data' as binary)) as h, +addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd +from t1; +a b c d e f g h dd +1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 +2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 +create table t2 +select +a, +ifnull(b,cast(-7 as signed)) as b, +ifnull(c,cast(7 as unsigned)) as c, +ifnull(d,cast('2000-01-01' as date)) as d, +ifnull(e,cast('b' as char)) as e, +ifnull(f,cast('2000-01-01' as datetime)) as f, +ifnull(g,cast('5:4:3' as time)) as g, +ifnull(h,cast('yet another binary data' as binary)) as h, +addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd +from t1; +explain t2; +Field Type Null Key Default Extra +a int YES NULL +b bigint NO 0 +c bigint unsigned NO 0 +d date YES NULL +e varchar(1) NO +f datetime YES NULL +g time YES NULL +h longblob NO NULL +dd time YES NULL +select * from t2; +a b c d e f g h dd +1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 +2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 +drop table t1, t2; +create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create table t2 select ifnull(a,a), ifnull(b,b), ifnull(c,c), ifnull(d,d), ifnull(e,e), ifnull(f,f), ifnull(g,g), ifnull(h,h), ifnull(i,i), ifnull(j,j), ifnull(k,k), ifnull(l,l), ifnull(m,m), ifnull(n,n), ifnull(o,o) from t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ifnull(a,a)` tinyint DEFAULT NULL, + `ifnull(b,b)` smallint DEFAULT NULL, + `ifnull(c,c)` mediumint DEFAULT NULL, + `ifnull(d,d)` int DEFAULT NULL, + `ifnull(e,e)` bigint DEFAULT NULL, + `ifnull(f,f)` float(3,2) DEFAULT NULL, + `ifnull(g,g)` double(4,3) DEFAULT NULL, + `ifnull(h,h)` decimal(5,4) DEFAULT NULL, + `ifnull(i,i)` year DEFAULT NULL, + `ifnull(j,j)` date DEFAULT NULL, + `ifnull(k,k)` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `ifnull(l,l)` datetime DEFAULT NULL, + `ifnull(m,m)` varchar(1) DEFAULT NULL, + `ifnull(n,n)` varchar(3) DEFAULT NULL, + `ifnull(o,o)` varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1,t2; +create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14'); +insert into t1 values ('','',0,0.0); +describe t1; +Field Type Null Key Default Extra +str varchar(10) YES def +strnull varchar(10) YES NULL +intg int YES 10 +rel double YES 3.14 +create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1; +describe t2; +Field Type Null Key Default Extra +str varchar(10) YES NULL +strnull varchar(10) YES NULL +intg int YES NULL +rel double YES NULL +drop table t1, t2; +create table t1(name varchar(10), age smallint default -1); +describe t1; +Field Type Null Key Default Extra +name varchar(10) YES NULL +age smallint YES -1 +create table t2(name varchar(10), age smallint default - 1); +describe t2; +Field Type Null Key Default Extra +name varchar(10) YES NULL +age smallint YES -1 +drop table t1, t2; +create table t1(cenum enum('a'), cset set('b')); +create table t2(cenum enum('a','a'), cset set('b','b')); +Warnings: +Note 1291 Column 'cenum' has duplicated value 'a' in ENUM +Note 1291 Column 'cset' has duplicated value 'b' in SET +create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d')); +Warnings: +Note 1291 Column 'cenum' has duplicated value 'a' in ENUM +Note 1291 Column 'cenum' has duplicated value 'A' in ENUM +Note 1291 Column 'cenum' has duplicated value 'c' in ENUM +Note 1291 Column 'cset' has duplicated value 'b' in SET +Note 1291 Column 'cset' has duplicated value 'B' in SET +Note 1291 Column 'cset' has duplicated value 'd' in SET +drop table t1, t2, t3; +create database mysqltest; +use mysqltest; +select database(); +database() +mysqltest +drop database mysqltest; +select database(); +database() +NULL +create user mysqltest_1; +select database(), user(); +database() user() +NULL mysqltest_1@localhost +drop user mysqltest_1; +use test; +create table t1 (a int, index `primary` (a)); +ERROR 42000: Incorrect index name 'primary' +create table t1 (a int, index `PRIMARY` (a)); +ERROR 42000: Incorrect index name 'PRIMARY' +create table t1 (`primary` int, index(`primary`)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `primary` int DEFAULT NULL, + KEY `primary_2` (`primary`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 (`PRIMARY` int, index(`PRIMARY`)); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `PRIMARY` int DEFAULT NULL, + KEY `PRIMARY_2` (`PRIMARY`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t3 (a int); +alter table t3 add index `primary` (a); +ERROR 42000: Incorrect index name 'primary' +alter table t3 add index `PRIMARY` (a); +ERROR 42000: Incorrect index name 'PRIMARY' +create table t4 (`primary` int); +alter table t4 add index(`primary`); +show create table t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `primary` int DEFAULT NULL, + KEY `primary_2` (`primary`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t5 (`PRIMARY` int); +alter table t5 add index(`PRIMARY`); +show create table t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `PRIMARY` int DEFAULT NULL, + KEY `PRIMARY_2` (`PRIMARY`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2, t3, t4, t5; +CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext); +INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL); +CREATE TABLE t2(id varchar(15) NOT NULL, proc varchar(100) NOT NULL, runID varchar(16) NOT NULL, start datetime NOT NULL, PRIMARY KEY (id,proc,runID,start)); +INSERT INTO t2 VALUES ('5000000001', 'proc01', '20031029090650', '2003-10-29 13:38:40'),('5000000001', 'proc02', '20031029090650', '2003-10-29 13:38:51'),('5000000001', 'proc03', '20031029090650', '2003-10-29 13:38:11'),('5000000002', 'proc09', '20031024013310', '2003-10-24 01:33:11'),('5000000002', 'proc09', '20031024153537', '2003-10-24 15:36:04'),('5000000004', 'proc01', '20031024013641', '2003-10-24 01:37:29'),('5000000004', 'proc02', '20031024013641', '2003-10-24 01:37:39'); +CREATE TABLE t3 SELECT t1.dsc,COUNT(DISTINCT t2.id) AS countOfRuns FROM t1 LEFT JOIN t2 ON (t1.id=t2.id) GROUP BY t1.id; +SELECT * FROM t3; +dsc countOfRuns +NULL 1 +Test 0 +NULL 1 +drop table t1, t2, t3; +create table t1 (b bool not null default false); +create table t2 (b bool not null default true); +insert into t1 values (); +insert into t2 values (); +select * from t1; +b +0 +select * from t2; +b +1 +drop table t1,t2; +create table t1 (a int); +create table t1 select * from t1; +ERROR 42S01: Table 't1' already exists +create table t2 union = (t1) select * from t1; +ERROR HY000: 'test.t2' is not BASE TABLE +flush tables with read lock; +unlock tables; +drop table t1; +create table t1(column.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.name int)' at line 1 +create table t1(test.column.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.column.name int)' at line 1 +create table t1(xyz.t1.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.t1.name int)' at line 1 +create table t1(t1.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.name int)' at line 1 +create table t2(test.t2.name int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.t2.name int)' at line 1 +CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1; +DESC t2; +Field Type Null Key Default Extra +f2 varchar(171) YES NULL +DROP TABLE t1,t2; +CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1; +SELECT * FROM t12913; +f1 +a +DROP TABLE t12913; +create database mysqltest; +use mysqltest; +drop database mysqltest; +create table test.t1 like x; +ERROR 3D000: No database selected +drop table if exists test.t1; +create database mysqltest; +use mysqltest; +create view v1 as select 'foo' from dual; +create table t1 like v1; +ERROR HY000: 'mysqltest.v1' is not BASE TABLE +drop view v1; +drop database mysqltest; +create database mysqltest; +create database if not exists mysqltest character set latin2; +Warnings: +Note 1007 Can't create database 'mysqltest'; database exists +show create database mysqltest; +Database Create Database +mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ +drop database mysqltest; +use test; +create table t1 (a int); +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +drop table t1; +create table t1 ( +a varchar(112) charset utf8 collate utf8_bin not null, +primary key (a) +) select 'test' as a ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(112) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +CREATE TABLE t2 ( +a int(11) default NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values(111); +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select a, 1 as b from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select a, 1 as c from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1364 Field 'b' doesn't have a default value +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int NOT NULL, + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `c` int NOT NULL DEFAULT '0', + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int null, primary key (a) +) select a, 1 as c from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `b` int DEFAULT NULL, + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `c` int NOT NULL DEFAULT '0', + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin not null, +b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 ( +a varchar(12) charset utf8 collate utf8_bin, +b int not null, primary key (a) +) select 'a' as a , 1 as b from t2 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 ( +a1 int not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, +primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +drop table t2; +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +drop table t1, t2; +create table t1 ( +a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int +); +insert into t1 values (1,1,1, 1,1,1, 1,1,1); +create table t2 ( +a1 varchar(12) charset utf8 collate utf8_bin not null, +a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, +primary key (a1) +) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +drop table t2; +create table t2 ( a int default 3, b int default 3) +select a1,a2 from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT '3', + `b` int DEFAULT '3', + `a1` int DEFAULT NULL, + `a2` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1(a set("a,b","c,d") not null); +ERROR 22007: Illegal set 'a,b' value found during parsing +create table t1 select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +create table t1 select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table t1 select coalesce(_latin1 'a' collate latin1_swedish_ci,_latin1 'b' collate latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' +create table t1 (primary key(a)) select "b" as b; +ERROR 42000: Key column 'a' doesn't exist in table +create table t1 (a int); +create table if not exists t1 select 1 as a, 2 as b; +Warnings: +Note 1050 Table 't1' already exists +drop table t1; +create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a); +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +create table t1 (i int); +create table t1 select 1 as i; +ERROR 42S01: Table 't1' already exists +create table if not exists t1 select 1 as i; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +i +create table if not exists t1 select * from t1; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +i +drop table t1; +create table t1 select coalesce(_latin1 'a' collate latin1_swedish_ci,_latin1 'b' collate latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' +create temporary table t1 (j int); +create table if not exists t1 select 1; +select * from t1; +j +drop temporary table t1; +select * from t1; +1 +1 +drop table t1; +create table t1 (i int); +insert into t1 values (1), (2); +lock tables t1 read; +create table t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +create table if not exists t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +create table t2 (j int); +lock tables t1 read; +create table t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +create table if not exists t2 select * from t1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +lock table t1 read, t2 read; +create table t2 select * from t1; +ERROR 42S01: Table 't2' already exists +create table if not exists t2 select * from t1; +Warnings: +Note 1050 Table 't2' already exists +unlock tables; +lock table t1 read, t2 write; +create table t2 select * from t1; +ERROR 42S01: Table 't2' already exists +create table if not exists t2 select * from t1; +Warnings: +Note 1050 Table 't2' already exists +select * from t1; +i +1 +2 +unlock tables; +drop table t2; +lock tables t1 read; +create temporary table t2 select * from t1; +create temporary table if not exists t2 select * from t1; +Warnings: +Note 1050 Table 't2' already exists +select * from t2; +i +1 +2 +unlock tables; +drop table t1, t2; +create table t1 (upgrade int); +drop table t1; + +Bug #26104 Bug on foreign key class constructor + +Check that ref_columns is initalized correctly in the constructor +and semantic checks in mysql_prepare_table work. + +We do not need a storage engine that supports foreign keys +for this test, as the checks are purely syntax-based, and the +syntax is supported for all engines. + +drop table if exists t1,t2; +create table t1(a int not null, b int not null, primary key (a, b)); +create table t2(a int not null, b int not null, c int not null, primary key (a), +constraint fk_bug26104 foreign key (b,c) references t1(a)); +ERROR 42000: Incorrect foreign key definition for 'fk_bug26104': Key reference and table reference don't match +drop table t1; +create table t1(f1 int,f2 int); +insert into t1 value(1,1),(1,2),(1,3),(2,1),(2,2),(2,3); +flush status; +create table t2 select sql_big_result f1,count(f2) from t1 group by f1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 23 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +drop table t1,t2; +CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1)); +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE); +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 c1 1 c1 NULL 0 NULL NULL YES HASH YES NULL +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 c1 1 c1 A NULL NULL NULL YES BTREE YES NULL +DROP TABLE t1; +create user mysqltest_1@'test@test'; +ERROR HY000: Malformed hostname (illegal symbol: '@') +CREATE TABLE t1 (a INTEGER AUTO_INCREMENT PRIMARY KEY, b INTEGER NOT NULL); +INSERT IGNORE INTO t1 (b) VALUES (5); +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) +SELECT a FROM t1; +INSERT INTO t2 SELECT a FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +INSERT INTO t2 SELECT a FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +DROP TABLE t1, t2; +# +# BUG#46384 - mysqld segfault when trying to create table with same +# name as existing view +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (1),(2),(3); +CREATE VIEW v1 AS SELECT t1.a FROM t1, t2; +CREATE TABLE v1 AS SELECT * FROM t1; +ERROR 42S01: Table 'v1' already exists +DROP VIEW v1; +DROP TABLE t1,t2; +End of 5.0 tests +CREATE TABLE t1 (a int, b int); +insert into t1 values (1,1),(1,2); +CREATE TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t2 (a int, b int, primary key (a)); +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +TRUNCATE table t2; +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t2; +CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t1,t2; +CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45; +use имя_базы_в_кодировке_утф8_длиной_больше_чем_45; +select database(); +database() +имя_базы_в_кодировке_утф8_длиной_больше_чем_45 +use test; +select SCHEMA_NAME from information_schema.schemata +where schema_name='имя_базы_в_кодировке_утф8_длиной_больше_чем_45'; +SCHEMA_NAME +имя_базы_в_кодировке_утф8_длиной_больше_чем_45 +drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45; +create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 +( +имя_поля_в_кодировке_утф8_длиной_больше_чем_45 int, +index имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 (имя_поля_в_кодировке_утф8_длиной_больше_чем_45) +); +create view имя_вью_кодировке_утф8_длиной_больше_чем_42 as +select имя_поля_в_кодировке_утф8_длиной_больше_чем_45 +from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +имя_поля_в_кодировке_утф8_длиной_больше_чем_45 +select TABLE_NAME from information_schema.tables where +table_schema='test' order by TABLE_NAME; +TABLE_NAME +имя_вью_кодировке_утф8_длиной_больше_чем_42 +имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 +select COLUMN_NAME from information_schema.columns where +table_schema='test' order by COLUMN_NAME; +COLUMN_NAME +имя_поля_в_кодировке_утф8_длиной_больше_чем_45 +имя_поля_в_кодировке_утф8_длиной_больше_чем_45 +select INDEX_NAME from information_schema.statistics where +table_schema='test' order by INDEX_NAME; +INDEX_NAME +имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 +select TABLE_NAME from information_schema.views where +table_schema='test' order by TABLE_NAME; +TABLE_NAME +имя_вью_кодировке_утф8_длиной_больше_чем_42 +show create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +Table Create Table +имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 CREATE TABLE `имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48` ( + `имя_поля_в_кодировке_утф8_длиной_больше_чем_45` int DEFAULT NULL, + KEY `имя_индекса_в_кодировке_утф8_длиной_больше_чем_48` (`имя_поля_в_кодировке_утф8_длиной_больше_чем_45`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create view имя_вью_кодировке_утф8_длиной_больше_чем_42; +View Create View character_set_client collation_connection +имя_вью_кодировке_утф8_длиной_больше_чем_42 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `имя_вью_кодировке_утф8_длиной_больше_чем_42` AS select `имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48`.`имя_поля_в_кодировке_утф8_длиной_больше_чем_45` AS `имя_поля_в_кодировке_утф8_длиной_больше_чем_45` from `имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48` utf8 utf8_general_ci +create trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49 +before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1; +select TRIGGER_NAME from information_schema.triggers where +trigger_schema='test'; +TRIGGER_NAME +имя_триггера_в_кодировке_утф8_длиной_больше_чем_49 +drop trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49; +create trigger +очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66 +before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +drop trigger очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +create procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50() +begin +end; +select ROUTINE_NAME from information_schema.routines where +routine_schema='test'; +ROUTINE_NAME +имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50 +drop procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50; +create procedure очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66() +begin +end; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +create function имя_функции_в_кодировке_утф8_длиной_больше_чем_49() +returns int +return 0; +select ROUTINE_NAME from information_schema.routines where +routine_schema='test'; +ROUTINE_NAME +имя_функции_в_кодировке_утф8_длиной_больше_чем_49 +drop function имя_функции_в_кодировке_утф8_длиной_больше_чем_49; +create function очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66() +returns int +return 0; +ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long +drop view имя_вью_кодировке_утф8_длиной_больше_чем_42; +drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +set names default; +drop table if exists t1,t2,t3; +drop function if exists f1; +create function f1() returns int +begin +declare res int; +create temporary table t3 select 1 i; +set res:= (select count(*) from t1); +drop temporary table t3; +return res; +end| +create table t1 as select 1; +create table t2 as select f1() from t1; +drop table t1,t2; +drop function f1; +create table t1 like information_schema.processlist; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `ID` bigint unsigned NOT NULL DEFAULT '0', + `USER` varchar(32) NOT NULL DEFAULT '', + `HOST` varchar(261) NOT NULL DEFAULT '', + `DB` varchar(64) DEFAULT NULL, + `COMMAND` varchar(16) NOT NULL DEFAULT '', + `TIME` int NOT NULL DEFAULT '0', + `STATE` varchar(64) DEFAULT NULL, + `INFO` longtext +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb3 +drop table t1; +create temporary table t1 like information_schema.processlist; +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `ID` bigint unsigned NOT NULL DEFAULT '0', + `USER` varchar(32) NOT NULL DEFAULT '', + `HOST` varchar(261) NOT NULL DEFAULT '', + `DB` varchar(64) DEFAULT NULL, + `COMMAND` varchar(16) NOT NULL DEFAULT '', + `TIME` int NOT NULL DEFAULT '0', + `STATE` varchar(64) DEFAULT NULL, + `INFO` longtext +) ENGINE=TMP_TABLE_ENGINE DEFAULT CHARSET=utf8mb3 +drop table t1; +create table t1 as select * from information_schema.character_sets; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CHARACTER_SET_NAME` varchar(64) CHARACTER SET utf8 NOT NULL, + `DEFAULT_COLLATE_NAME` varchar(64) CHARACTER SET utf8 NOT NULL, + `DESCRIPTION` varchar(2048) CHARACTER SET utf8 NOT NULL, + `MAXLEN` int unsigned NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; + +# -- +# -- Bug#21380: DEFAULT definition not always transfered by CREATE +# -- TABLE/SELECT to the new table. +# -- + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 INT DEFAULT 12 COMMENT 'column1', +c2 INT NULL COMMENT 'column2', +c3 INT NOT NULL COMMENT 'column3', +c4 VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a', +c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b', +c6 VARCHAR(255)) +COLLATE latin1_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. + +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int DEFAULT '12' COMMENT 'column1', + `c2` int DEFAULT NULL COMMENT 'column2', + `c3` int NOT NULL COMMENT 'column3', + `c4` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'a', + `c5` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'b', + `c6` varchar(255) COLLATE latin1_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin + +CREATE TABLE t2 AS SELECT * FROM t1; + +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int DEFAULT '12' COMMENT 'column1', + `c2` int DEFAULT NULL COMMENT 'column2', + `c3` int NOT NULL COMMENT 'column3', + `c4` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'a', + `c5` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'b', + `c6` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t2; +DROP TABLE t1; + +# -- End of test case for Bug#21380. + +# -- +# -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields +# -- + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; + +CREATE TABLE t1(c1 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, c2 TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'); + +SET sql_mode = 'NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. + +CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +DROP TABLE t2; + +# -- Check that NULL column still can be created. +CREATE TABLE t2(c1 TIMESTAMP NULL); + +# -- Check ALTER TABLE. +ALTER TABLE t1 ADD INDEX(c1); +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 + +# -- Check DATETIME. +SET sql_mode = ''; + +# -- Cleanup. +SET sql_mode = ''; +DROP TABLE t1; +DROP TABLE t2; + +# -- End of Bug#18834. + +# -- +# -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type. +# -- + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0); + +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` year DEFAULT '2008', + `c2` year DEFAULT '0000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +INSERT INTO t1 VALUES(); + +SELECT * FROM t1; +c1 c2 +2008 0000 + +ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0; + +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` year DEFAULT '0000', + `c2` year DEFAULT '0000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +INSERT INTO t1 VALUES(); + +SELECT * FROM t1; +c1 c2 +2008 0000 +0000 0000 + +DROP TABLE t1; + +# -- End of Bug#34274 +create table `me:i`(id int); +drop table `me:i`; + +# -- +# -- Bug#45829: CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing +# -- + +drop table if exists t1,t2,t3; +create table t1 (a int) transactional=0; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'transactional=0' at line 1 +create table t2 (a int) page_checksum=1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'page_checksum=1' at line 1 +create table t3 (a int) row_format=page; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'page' at line 1 + +# -- End of Bug#45829 + +End of 5.1 tests + +# -- +# -- Bug #43054 Assertion `!table->auto_increment_field_not_null' +# -- failed when redefining trigger + +CREATE TABLE B ( +pk INTEGER AUTO_INCREMENT, +int_key INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (int_key) +); +INSERT IGNORE INTO B VALUES ('9', '9'); +CREATE TABLE IF NOT EXISTS t1 ( +`pk` INTEGER NOT NULL AUTO_INCREMENT , +`int` INTEGER , +PRIMARY KEY ( `pk` ) +) SELECT `pk` , `int_key` FROM B ; +CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW +BEGIN +INSERT INTO t1 ( `int` ) VALUES (4 ),( 8 ),( 2 ) ; +END ; | +INSERT INTO t1 (pk, int_key) SELECT `pk` , `int_key` FROM B ; +ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. +CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW +BEGIN +UPDATE A SET `pk`=1 WHERE `pk`=0 ; +END ;| +ERROR HY000: Trigger already exists +DROP TABLE t1; +DROP TABLE B; +# +# Bug #47107 assert in notify_shared_lock on incorrect +# CREATE TABLE , HANDLER +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(f1 integer); +# The following CREATE TABLEs before gave an assert. +HANDLER t1 OPEN AS A; +CREATE TABLE t1 SELECT 1 AS f2; +ERROR 42S01: Table 't1' already exists +HANDLER t1 OPEN AS A; +CREATE TABLE t1(f1 integer); +ERROR 42S01: Table 't1' already exists +CREATE TABLE t2(f1 integer); +HANDLER t1 OPEN AS A; +CREATE TABLE t1 LIKE t2; +ERROR 42S01: Table 't1' already exists +DROP TABLE t2; +DROP TABLE t1; +# +# Bug #48800 CREATE TABLE t...SELECT fails if t is a +# temporary table +# +CREATE TEMPORARY TABLE t1 (a INT); +CREATE TABLE t1 (a INT); +CREATE TEMPORARY TABLE t2 (a INT); +CREATE VIEW t2 AS SELECT 1; +CREATE TABLE t3 (a INT); +CREATE TEMPORARY TABLE t3 SELECT 1; +CREATE TEMPORARY TABLE t4 (a INT); +CREATE TABLE t4 AS SELECT 1; +DROP TEMPORARY TABLE t1, t2, t3, t4; +DROP TABLE t1, t3, t4; +DROP VIEW t2; +# +# Bug #49193 CREATE TABLE reacts differently depending +# on whether data is selected or not +# +CREATE TEMPORARY TABLE t2 (ID INT); +INSERT INTO t2 VALUES (1),(2),(3); +CREATE TEMPORARY TABLE t1 (ID INT); +CREATE TABLE IF NOT EXISTS t1 (ID INT); +INSERT INTO t1 SELECT * FROM t2; +SELECT * FROM t1; +ID +1 +2 +3 +DROP TEMPORARY TABLE t1; +SELECT * FROM t1; +ID +DROP TABLE t1; +CREATE TEMPORARY TABLE t1 (ID INT); +CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2; +SELECT * FROM t1; +ID +DROP TEMPORARY TABLE t1; +SELECT * FROM t1; +ID +1 +2 +3 +DROP TABLE t1; +CREATE TEMPORARY TABLE t1 (ID INT); +CREATE TABLE t1 SELECT * FROM t2; +SELECT * FROM t1; +ID +DROP TEMPORARY TABLE t1; +SELECT * FROM t1; +ID +1 +2 +3 +DROP TABLE t1; +DROP TEMPORARY TABLE t2; +# +# Bug #22909 "Using CREATE ... LIKE is possible to create field +# with invalid default value" +# +# Altough original bug report suggests to use older version of MySQL +# for producing .FRM with invalid defaults we use sql_mode to achieve +# the same effect. +drop tables if exists t1, t2; +# Attempt to create table with invalid default should fail in normal mode +create table t1 (dt datetime default '2008-02-31 00:00:00'); +ERROR 42000: Invalid default value for 'dt' +set @old_mode= @@sql_mode; +set @@sql_mode='ALLOW_INVALID_DATES'; +# The same should be possible in relaxed mode +create table t1 (dt datetime default '2008-02-31 00:00:00'); +set @@sql_mode= @old_mode; +# In normal mode attempt to create copy of table with invalid +# default should fail +create table t2 like t1; +ERROR 42000: Invalid default value for 'dt' +set @@sql_mode='ALLOW_INVALID_DATES'; +# But should work in relaxed mode +create table t2 like t1; +# Check that table definitions match +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dt` datetime DEFAULT '2008-02-31 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `dt` datetime DEFAULT '2008-02-31 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @@sql_mode= @old_mode; +drop tables t1, t2; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int); +INSERT INTO t1 VALUES (1), (1); +INSERT INTO t2 VALUES (2), (2); +CREATE VIEW v1 AS SELECT id FROM t2; +CREATE TABLE IF NOT EXISTS v1(a int, b int) SELECT id, id FROM t1; +Warnings: +Note 1050 Table 'v1' already exists +SHOW CREATE TABLE v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t2`.`id` AS `id` from `t2` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM t2; +id +2 +2 +SELECT * FROM v1; +id +2 +2 +DROP VIEW v1; +CREATE TEMPORARY TABLE tt1 AS SELECT id FROM t2; +CREATE TEMPORARY TABLE IF NOT EXISTS tt1(a int, b int) SELECT id, id FROM t1; +Warnings: +Note 1050 Table 'tt1' already exists +SELECT * FROM t2; +id +2 +2 +SELECT * FROM tt1; +id +2 +2 +DROP TEMPORARY TABLE tt1; +DROP TABLE t1, t2; +# +# WL#5370 "Changing 'CREATE TABLE IF NOT EXISTS ... SELECT' +# behaviour. +# +# +# 1. Basic case: a base table. +# +create table if not exists t1 (a int) select 1 as a; +select * from t1; +a +1 +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# Produces an essential warning ER_TABLE_EXISTS. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +# No new data in t1. +select * from t1; +a +1 +drop table t1; +# +# 2. A temporary table. +# +create temporary table if not exists t1 (a int) select 1 as a; +select * from t1; +a +1 +create temporary table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# An essential warning. +create temporary table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +# No new data in t1. +select * from t1; +a +1 +drop temporary table t1; +# +# 3. Creating a base table in presence of a temporary table. +# +create table t1 (a int); +# Create a view for convenience of querying t1 shadowed by a temp. +create view v1 as select a from t1; +drop table t1; +create temporary table t1 (a int) select 1 as a; +create table if not exists t1 (a int) select 2 as a; +select * from t1; +a +1 +select * from v1; +a +2 +# Note: an essential warning. +create table if not exists t1 (a int) select 3 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +select * from v1; +a +2 +drop temporary table t1; +select * from t1; +a +2 +drop view v1; +drop table t1; +# +# 4. Creating a temporary table in presence of a base table. +# +create table t1 (a int) select 1 as a; +create temporary table if not exists t1 select 2 as a; +select * from t1; +a +2 +# Note: an essential warning. +create temporary table if not exists t1 select 3 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +2 +drop temporary table t1; +select * from t1; +a +1 +drop table t1; +# +# 5. Creating a base table in presence of an updatable view. +# +create table t2 (a int unique); +create view t1 as select a from t2; +insert into t1 (a) values (1); +create table t1 (a int); +ERROR 42S01: Table 't1' already exists +# Note: an essential warning. +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# Note: an essential warning. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +select * from t2; +a +1 +create temporary table if not exists t1 (a int) select 3 as a; +select * from t1; +a +3 +select * from t2; +a +1 +# Note: an essential warning. +create temporary table if not exists t1 (a int) select 4 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +3 +select * from t2; +a +1 +drop temporary table t1; +# +# Repeating the test with a non-updatable view. +# +drop view t1; +create view t1 as select a + 5 as a from t2; +insert into t1 (a) values (1); +ERROR HY000: Column 'a' is not updatable +update t1 set a=3 where a=2; +ERROR HY000: Column 'a' is not updatable +create table t1 (a int); +ERROR 42S01: Table 't1' already exists +# Note: an essential warning. +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +6 +# Note: an essential warning. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +6 +select * from t2; +a +1 +create temporary table if not exists t1 (a int) select 3 as a; +select * from t1; +a +3 +select * from t2; +a +1 +# Note: an essential warning. +create temporary table if not exists t1 (a int) select 4 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +3 +select * from t2; +a +1 +drop temporary table t1; +drop view t1; +drop table t2; +# +# Repeating the test with a view select a constant number +# +create view t1 as select 1 as a; +insert into t1 (a) values (1); +ERROR HY000: The target table t1 of the INSERT is not insertable-into +update t1 set a=3 where a=2; +ERROR HY000: The target table t1 of the UPDATE is not updatable +create table t1 (a int); +ERROR 42S01: Table 't1' already exists +# Note: an essential warning. +create table if not exists t1 (a int); +Warnings: +Note 1050 Table 't1' already exists +create table t1 (a int) select 2 as a; +ERROR 42S01: Table 't1' already exists +select * from t1; +a +1 +# Note: an essential warning. +create table if not exists t1 (a int) select 2 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +create temporary table if not exists t1 (a int) select 3 as a; +select * from t1; +a +3 +# Note: an essential warning. +create temporary table if not exists t1 (a int) select 4 as a; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +3 +drop temporary table t1; +drop view t1; +# +# 6. Test of unique_table(). +# +create table t1 (a int) select 1 as a; +create temporary table if not exists t1 (a int) select * from t1; +create temporary table if not exists t1 (a int) select * from t1; +ERROR HY000: Can't reopen table: 't1' +select * from t1; +a +1 +drop temporary table t1; +select * from t1; +a +1 +drop table t1; +create temporary table t1 (a int) select 1 as a; +create table if not exists t1 (a int) select * from t1; +create table if not exists t1 (a int) select * from t1; +Warnings: +Note 1050 Table 't1' already exists +select * from t1; +a +1 +drop temporary table t1; +select * from t1; +a +1 +drop table t1; +create table if not exists t1 (a int) select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +# +# 7. Test of non-matching columns, REPLACE and IGNORE. +# +create table t1 (a int) select 1 as b, 2 as c; +select * from t1; +a b c +NULL 1 2 +drop table t1; +create table if not exists t1 (a int, b date, c date) select 1 as b, 2 as c; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +select * from t1; +a b c +NULL 0000-00-00 0000-00-00 +drop table t1; +set @@session.sql_mode=default; +create table if not exists t1 (a int, b date, c date) select 1 as b, 2 as c; +ERROR 22007: Incorrect date value: '1' for column 'b' at row 1 +select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table if not exists t1 (a int, b date, c date) +replace select 1 as b, 2 as c; +ERROR 22007: Incorrect date value: '1' for column 'b' at row 1 +select * from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create table if not exists t1 (a int, b date, c date) +ignore select 1 as b, 2 as c; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +select * from t1; +a b c +NULL 0000-00-00 0000-00-00 +drop table t1; +create table if not exists t1 (a int unique, b int) +replace select 1 as a, 1 as b union select 1 as a, 2 as b; +select * from t1; +a b +1 2 +drop table t1; +create table if not exists t1 (a int unique, b int) +ignore select 1 as a, 1 as b union select 1 as a, 2 as b; +Warnings: +Warning 1062 Duplicate entry '1' for key 't1.a' +select * from t1; +a b +1 1 +drop table t1; +# +# +# WL#5576 Prohibit CREATE TABLE ... SELECT to modify other tables +# +create function f() +returns int +begin +insert into t2 values(1); +return 1; +end| +# +# 1. The function updates a base table +# +create table t2(c1 int); +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop table t2; +# +# 2. The function updates a view which derives from a base table +# +create table t3(c1 int); +create view t2 as select c1 from t3; +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop view t2; +# +# 3. The function updates a view which derives from two base tables +# +create table t4(c1 int); +create view t2 as select t3.c1 as c1 from t3, t4; +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop view t2; +drop tables t3, t4; +# +# 4. The function updates a view which selects a constant number +# +create view t2 as select 1; +create table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +create temporary table t1 select f(); +ERROR HY000: Can't update table 't2' while 't1' is being created. +drop view t2; +drop function f; +# +# BUG#11762377 - 54963: ENHANCE THE ERROR MESSAGE TO +# REDUCE USER CONFUSION +# +CREATE TABLE t1 (v varchar(65535) CHARACTER SET latin1); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +# +# Bug#11746295 - 25168: "INCORRECT TABLE NAME" INSTEAD OF "IDENTIFIER TOO +# LONG" IF TABLE NAME > 64 CHARACTERS +# +CREATE TABLE t01234567890123456789012345678901234567890123456789012345678901234567890123456789(a int); +ERROR 42000: Identifier name 't01234567890123456789012345678901234567890123456789012345678901234567890123456789' is too long +CREATE DATABASE t01234567890123456789012345678901234567890123456789012345678901234567890123456789; +ERROR 42000: Identifier name 't01234567890123456789012345678901234567890123456789012345678901234567890123456789' is too long +# +# Bug #20573701 DROP DATABASE ASSERT ON DEBUG WHEN OTHER FILES PRESENT IN +# DB FOLDER. +# +CREATE DATABASE db_with_no_tables_and_an_unrelated_file_in_data_directory; +DROP DATABASE db_with_no_tables_and_an_unrelated_file_in_data_directory; +ERROR HY000: Error dropping database (can't rmdir './db_with_no_tables_and_an_unrelated_file_in_data_directory/', errno: ## - ...) +DROP DATABASE db_with_no_tables_and_an_unrelated_file_in_data_directory; +CREATE DATABASE db_with_tables_and_an_unrelated_file_in_data_directory; +DROP DATABASE db_with_tables_and_an_unrelated_file_in_data_directory; +ERROR HY000: Error dropping database (can't rmdir './db_with_tables_and_an_unrelated_file_in_data_directory/', errno: ## - ...) +DROP DATABASE db_with_tables_and_an_unrelated_file_in_data_directory; +DROP DATABASE db_created_with_mkdir_and_an_unrelated_file_in_data_directory; +ERROR HY000: Schema 'db_created_with_mkdir_and_an_unrelated_file_in_data_directory' does not exist, but schema directory './db_created_with_mkdir_and_an_unrelated_file_in_data_directory/' was found. This must be resolved manually (e.g. by moving the schema directory to another location). +# +# Bug#20857556: IMPROPER ERROR DURING CREATE TABLE +# +# Without the patch ER_WRONG_TABLE_NAME was getting reported. +CREATE TABLE t1 (id INT) INDEX DIRECTORY = 'a#######################################################b#######################################################################################b#####################################################################################b######################################################################################b######################################################################################b#############################################################################################################'; +ERROR HY000: The path specified for INDEX DIRECTORY is too long. +CREATE TABLE t2 (id INT NOT NULL, name VARCHAR(30)) +ENGINE = InnoDB +PARTITION BY RANGE (id) ( +PARTITION p0 VALUES LESS THAN (10) INDEX DIRECTORY = 'a#######################################################b#######################################################################################b#####################################################################################b######################################################################################b######################################################################################b#############################################################################################################' +); +ERROR HY000: The path specified for INDEX DIRECTORY is too long. +CREATE TABLE t3 (id INT) INDEX DIRECTORY = 'test'; +ERROR HY000: Incorrect path value: 'test' +CREATE TABLE t4 (id INT NOT NULL, name VARCHAR(30)) +ENGINE = InnoDB +PARTITION BY RANGE (id) ( +PARTITION p0 VALUES LESS THAN (10) INDEX DIRECTORY = 'test' +); +ERROR HY000: Incorrect path value: 'test' +# +# BUG 27516741 - MYSQL SERVER DOES NOT WRITE INNODB ROW_TYPE +# TO .FRM FILE WHEN DEFAULT USED +# Set up. +SET @saved_innodb_default_row_format= @@global.innodb_default_row_format; +SET @saved_show_create_table_verbosity= @@session.show_create_table_verbosity; +# Current InnoDB default row format and 'show_create_table_verbosity' +# values respectively. +SELECT @@global.innodb_default_row_format; +@@global.innodb_default_row_format +dynamic +SELECT @@session.show_create_table_verbosity; +@@session.show_create_table_verbosity +0 +CREATE TABLE t1(fld1 INT) ENGINE= InnoDB; +CREATE TABLE t2(fld1 INT) ENGINE= InnoDB, ROW_FORMAT= DEFAULT; +SET GLOBAL innodb_default_row_format= 'COMPACT'; +CREATE TABLE t3(fld1 INT) ENGINE= InnoDB; +CREATE TABLE t4(fl1 INT) ENGINE= InnoDB, ROW_FORMAT= COMPRESSED; +# Test without show_create_table_verbosity enabled. +# Row format used is not displayed for all tables +# except t4 where it is explicitly specified. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPRESSED +# Test with show_create_table_verbosity enabled. +# Row format used is displayed for all tables. +SET SESSION show_create_table_verbosity= ON; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPRESSED +SET GLOBAL innodb_default_row_format= 'DYNAMIC'; +SET SESSION show_create_table_verbosity= OFF; +# Test with corresponding temporary tables. +CREATE TEMPORARY TABLE t1(fld1 INT) ENGINE= InnoDB; +CREATE TEMPORARY TABLE t2(fld1 INT) ENGINE= InnoDB, ROW_FORMAT= DEFAULT; +SET GLOBAL innodb_default_row_format= 'COMPACT'; +CREATE TEMPORARY TABLE t3(fld1 INT) ENGINE= InnoDB; +CREATE TEMPORARY TABLE t4(fl1 INT) ENGINE= InnoDB, ROW_FORMAT= REDUNDANT; +# Test without show_create_table_verbosity enabled. +# Row format used is not displayed for all tables +# except t4 where it is explicitly specified. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TEMPORARY TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +# Test with show_create_table_verbosity enabled. +# Row format used is displayed for all tables. +SET SESSION show_create_table_verbosity= ON; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `fld1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TEMPORARY TABLE `t4` ( + `fl1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +# Clean up. +DROP TABLE t1, t2, t3, t4; +DROP TABLE t1, t2, t3, t4; +SET GLOBAL innodb_default_row_format= @saved_innodb_default_row_format; +SET SESSION show_create_table_verbosity= @saved_show_create_table_verbosity; +# +# Bug#27592803: ASSERTION FAILED: RC == TYPE_OK, +# +# Make sure that it is possible to create enums using binary string +# values that are not valid utf8 +CREATE TABLE t0(a ENUM('aaa', 'bbb', 'ccc') BYTE); +SHOW CREATE TABLE t0; +Table Create Table +t0 CREATE TABLE `t0` ( + `a` enum('aaa','bbb','ccc') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t0; +Field Type Null Key Default Extra +a enum('aaa','bbb','ccc') YES NULL +# Tables t1 and t2 uses a binary value that is legal as utf8, so they +# would not trigger an assert. +CREATE TABLE t1(a ENUM( b'1001001')); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('I') DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a enum('I') YES NULL +CREATE TABLE t2(a ENUM( b'1001001') BYTE); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` enum('I') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +a enum('I') YES NULL +# Tables t3 - t6 contains binary values that are not valid utf8 +# which would previously result in assert. With the fix we get the hex +# representation of the binary value instead. +CREATE TABLE t3(a ENUM( b'10010010') BYTE); +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` enum(x'92') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t3; +Field Type Null Key Default Extra +a enum(x'92') YES NULL +CREATE TABLE t4(a ENUM( b'1001001101101111') BYTE); +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `a` enum(x'936f') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t4; +Field Type Null Key Default Extra +a enum(x'936f') YES NULL +CREATE TABLE t5(a ENUM( b'10010011011011111111011000011') BYTE); +SHOW CREATE TABLE t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `a` enum(x'126dfec3') CHARACTER SET binary COLLATE binary DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t5; +Field Type Null Key Default Extra +a enum(x'126dfec3') YES NULL +CREATE TABLE t6 (a INT); +ALTER TABLE t6 +MODIFY COLUMN a ENUM( b'10010011011011111111011000011') BYTE UNIQUE FIRST; +SHOW CREATE TABLE t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `a` enum(x'126dfec3') CHARACTER SET binary COLLATE binary DEFAULT NULL, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW COLUMNS FROM t6; +Field Type Null Key Default Extra +a enum(x'126dfec3') YES UNI NULL +DROP TABLE t6; +DROP TABLE t5; +DROP TABLE t4; +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; +DROP TABLE t0; +# Bug#17468242/Wl#11807: Provide an option to prevent creation of tables +# without a unique/pk +# +SET GLOBAL sql_require_primary_key= ON; +SELECT @@global.sql_require_primary_key; +@@global.sql_require_primary_key +1 +# Checking variable at session level +# Should not affect this session +SELECT @@session.sql_require_primary_key; +@@session.sql_require_primary_key +0 +CREATE TABLE t1(i INT); +CREATE TABLE t2(i INT PRIMARY KEY, j INT); +ALTER TABLE t2 DROP COLUMN i; +DROP TABLE t2; +DROP TABLE t1; +# Create new connection which will inherit global setting +SELECT @@session.sql_require_primary_key; +@@session.sql_require_primary_key +1 +CREATE TABLE t1(i INT); +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +CREATE TABLE t1(i INT PRIMARY KEY, j INT); +ALTER TABLE t1 DROP COLUMN i; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +DROP TABLE t1; +# Overdide inherited global setting locally +SET SESSION sql_require_primary_key= OFF; +SELECT @@session.sql_require_primary_key; +@@session.sql_require_primary_key +0 +CREATE TABLE t1(i INT); +CREATE TABLE t2(i INT PRIMARY KEY, j INT); +ALTER TABLE t2 DROP COLUMN i; +DROP TABLE t2; +DROP TABLE t1; +# Verify CREATE LIKE +CREATE TABLE t1(i INT); +SET SESSION sql_require_primary_key= ON; +CREATE TABLE t2 LIKE t1; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# Verify CREATE AS SELECT ... +CREATE TABLE t3 (I INT PRIMARY KEY); +CREATE TABLE t4 AS SELECT 1; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +CREATE TABLE t4 AS SELECT * FROM t1; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# PK attribute is not propagated by CREATE AS +CREATE TABLE t4 AS SELECT * FROM t3; +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# PK attribute specified explicitly is ok +CREATE TABLE t4(i INT PRIMARY KEY) AS SELECT * FROM t3; +SHOW CREATE TABLE t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `I` int NOT NULL, + PRIMARY KEY (`I`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# Drop and add PK in same ALTER statement should be ok +CREATE TABLE t5(i INT PRIMARY KEY, j INT); +ALTER TABLE t5 DROP PRIMARY KEY, ADD CONSTRAINT PRIMARY KEY (j); +# Restriction also applies to temporary tables +CREATE TEMPORARY TABLE t6(i INT); +ERROR HY000: Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. +# Cleanup +DROP TABLE t5; +DROP TABLE t4; +DROP TABLE t3; +DROP TABLE t1; +# Create user without SUPER privilege. +CREATE USER subuser@localhost; +REVOKE SUPER ON *.* FROM subuser@localhost; +Warnings: +Warning 1287 The SUPER privilege identifier is deprecated +# Connect as user subuser@localhost; +SET SESSION sql_require_primary_key= OFF; +ERROR 42000: Access denied; you need (at least one of) the SUPER, SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN privilege(s) for this operation +SET GLOBAL sql_require_primary_key= OFF; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SYSTEM_VARIABLES_ADMIN privilege(s) for this operation +DROP USER subuser@localhost; +SET GLOBAL sql_require_primary_key= OFF; +# +# Bug#28022129: NOW() DOESN?T HONOR NO_ZERO_DATE SQL_MODE +# +SET @saved_mode= @@sql_mode; +CREATE TABLE t1(fld1 int); +# NO_ZERO_DATE and STRICT SQL mode. +CREATE TABLE t2 SELECT fld1, CURDATE() fld2 FROM t1; +CREATE TABLE t3 AS SELECT now(); +# With patch, zero date is not generated as default. +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL, + `fld2` date NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `now()` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t3; +SET SQL_MODE= "NO_ZERO_DATE"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +# NO_ZERO_DATE SQL mode. +CREATE TABLE t2 SELECT fld1, CURDATE() fld2 FROM t1; +CREATE TABLE t3 AS SELECT now(); +# Zero date is generated as default in non strict mode. +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` int DEFAULT NULL, + `fld2` date NOT NULL DEFAULT '0000-00-00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `now()` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2, t3; +SET SQL_MODE= DEFAULT; +# Test cases added for coverage. +CREATE TABLE t1(fld1 DATETIME NOT NULL DEFAULT '1111:11:11'); +# CREATE TABLE..SELECT using fields of another table. +CREATE TABLE t2 AS SELECT * FROM t1; +# Default value is copied from the source table column. +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fld1` datetime NOT NULL DEFAULT '1111-11-11 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# CREATE TABLE..SELECT based on trigger fields. +CREATE TABLE t1 (fld1 INT, fld2 DATETIME DEFAULT '1211:1:1'); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 +FOR EACH ROW +BEGIN +CREATE TEMPORARY TABLE t2 AS SELECT NEW.fld1, NEW.fld2; +END +| +INSERT INTO t1 VALUES (1, '1111:11:11'); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `fld1` int DEFAULT NULL, + `fld2` datetime DEFAULT '1211-01-01 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +DROP TEMPORARY TABLE t2; +SET SQL_MODE= @saved_mode; +# +# Bug #29283055: CREATE TABLE IF NOT EXISTS .. SHOULD NOT ALWAYS +# FAIL ON SQL_REQUIRE_PRIMARY_KEY +# +# Create table without PK +CREATE TABLE t1(i INT); +SET SESSION sql_require_primary_key=1; +# This must not fail when t1 already exists, even if it does not have +# a pk +CREATE TABLE IF NOT EXISTS t1(i INT); +Warnings: +Note 1050 Table 't1' already exists +# Cleanup +SET SESSION sql_require_primary_key=DEFAULT; +DROP TABLE t1; +# +# WL#13127: Deprecate integer display width and ZEROFILL option +# +CREATE TABLE types(id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100)); +INSERT INTO types(name) VALUES +('TINYINT'), ('SMALLINT'), ('MEDIUMINT'), ('INT'), ('BIGINT'), +('TINYINT(10)'), ('SMALLINT(10)'), ('MEDIUMINT(10)'), ('INT(10)'), ('BIGINT(10)'), +('DOUBLE'), ('FLOAT'), ('DECIMAL(5, 2)'), ('YEAR'); +CREATE TABLE t1(col TINYINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 TINYINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 TINYINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x TINYINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS TINYINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x TINYINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col SMALLINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 SMALLINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 SMALLINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x SMALLINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS SMALLINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x SMALLINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col MEDIUMINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 MEDIUMINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 MEDIUMINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x MEDIUMINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS MEDIUMINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x MEDIUMINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col INT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 INT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 INT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x INT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS INT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x INT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col BIGINT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 BIGINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 BIGINT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x BIGINT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS BIGINT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x BIGINT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col TINYINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 TINYINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 TINYINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x TINYINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS TINYINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x TINYINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col SMALLINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 SMALLINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 SMALLINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x SMALLINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS SMALLINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x SMALLINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col MEDIUMINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 MEDIUMINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 MEDIUMINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x MEDIUMINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS MEDIUMINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x MEDIUMINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col INT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 INT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 INT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x INT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS INT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x INT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col BIGINT(10) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 BIGINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN col3 BIGINT(10) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x BIGINT(10) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f2(x INT) RETURNS BIGINT(10) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x BIGINT(10) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col DOUBLE ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 DOUBLE ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 DOUBLE ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x DOUBLE ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS DOUBLE ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x DOUBLE ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col FLOAT ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 FLOAT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 FLOAT ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x FLOAT ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS FLOAT ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x FLOAT ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col DECIMAL(5, 2) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 DECIMAL(5, 2) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 DECIMAL(5, 2) ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x DECIMAL(5, 2) ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS DECIMAL(5, 2) ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x DECIMAL(5, 2) ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +CREATE TABLE t1(col YEAR ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 AS SELECT * FROM t1; +ALTER TABLE t1 ADD COLUMN col2 VARCHAR(10); +ALTER TABLE t1 MODIFY COLUMN col2 YEAR ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +ALTER TABLE t1 ADD COLUMN col3 YEAR ZEROFILL; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP TABLE t1, t2, t3; +CREATE FUNCTION f1(x YEAR ZEROFILL) RETURNS INT DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f2(x INT) RETURNS YEAR ZEROFILL DETERMINISTIC RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +CREATE FUNCTION f3() RETURNS INT DETERMINISTIC +BEGIN +DECLARE x YEAR ZEROFILL DEFAULT 1; +RETURN x; +END// +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP TABLE types; +# +# WL#13528: Remove integer display width from SHOW CREATE output +# +CREATE TABLE t1( +a TINYINT, +b SMALLINT, +c MEDIUMINT, +d INT, +e BIGINT, +f TINYINT(1), +g SMALLINT(1), +h MEDIUMINT(1), +i INT(1), +j BIGINT(1), +k TINYINT ZEROFILL, +l SMALLINT ZEROFILL, +m MEDIUMINT ZEROFILL, +n INT ZEROFILL, +o BIGINT ZEROFILL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` tinyint DEFAULT NULL, + `b` smallint DEFAULT NULL, + `c` mediumint DEFAULT NULL, + `d` int DEFAULT NULL, + `e` bigint DEFAULT NULL, + `f` tinyint(1) DEFAULT NULL, + `g` smallint DEFAULT NULL, + `h` mediumint DEFAULT NULL, + `i` int DEFAULT NULL, + `j` bigint DEFAULT NULL, + `k` tinyint(3) unsigned zerofill DEFAULT NULL, + `l` smallint(5) unsigned zerofill DEFAULT NULL, + `m` mediumint(8) unsigned zerofill DEFAULT NULL, + `n` int(10) unsigned zerofill DEFAULT NULL, + `o` bigint(20) unsigned zerofill DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +COLUMN_TYPE +bigint +bigint +bigint(20) unsigned zerofill +int +int +int(10) unsigned zerofill +mediumint +mediumint +mediumint(8) unsigned zerofill +smallint +smallint +smallint(5) unsigned zerofill +tinyint +tinyint(1) +tinyint(3) unsigned zerofill +DESCRIBE t1; +Field Type Null Key Default Extra +a tinyint YES NULL +b smallint YES NULL +c mediumint YES NULL +d int YES NULL +e bigint YES NULL +f tinyint(1) YES NULL +g smallint YES NULL +h mediumint YES NULL +i int YES NULL +j bigint YES NULL +k tinyint(3) unsigned zerofill YES NULL +l smallint(5) unsigned zerofill YES NULL +m mediumint(8) unsigned zerofill YES NULL +n int(10) unsigned zerofill YES NULL +o bigint(20) unsigned zerofill YES NULL +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; +COLUMN_TYPE +bigint +bigint +bigint(20) unsigned zerofill +int +int +int(10) unsigned zerofill +mediumint +mediumint +mediumint(8) unsigned zerofill +smallint +smallint +smallint(5) unsigned zerofill +tinyint +tinyint(1) +tinyint(3) unsigned zerofill +DESCRIBE v1; +Field Type Null Key Default Extra +a tinyint YES NULL +b smallint YES NULL +c mediumint YES NULL +d int YES NULL +e bigint YES NULL +f tinyint(1) YES NULL +g smallint YES NULL +h mediumint YES NULL +i int YES NULL +j bigint YES NULL +k tinyint(3) unsigned zerofill YES NULL +l smallint(5) unsigned zerofill YES NULL +m mediumint(8) unsigned zerofill YES NULL +n int(10) unsigned zerofill YES NULL +o bigint(20) unsigned zerofill YES NULL +DROP VIEW v1; +DROP TABLE t1; +CREATE FUNCTION f1(a INT) RETURNS INT RETURN 1; +CREATE FUNCTION f2(a INT ZEROFILL) RETURNS INT ZEROFILL RETURN 1; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(a INT) RETURNS int +RETURN 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SHOW CREATE FUNCTION f2; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f2 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f2`(a INT ZEROFILL) RETURNS int(10) unsigned zerofill +RETURN 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f1'; +DTD_IDENTIFIER +int +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f2'; +DTD_IDENTIFIER +int(10) unsigned zerofill +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f1'; +DTD_IDENTIFIER +int +int +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f2'; +DTD_IDENTIFIER +int(10) unsigned zerofill +int(10) unsigned zerofill +DROP FUNCTION f1; +DROP FUNCTION f2; +CREATE PROCEDURE p1(a INT, b INT ZEROFILL) BEGIN END; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +SHOW CREATE PROCEDURE p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(a INT, b INT ZEROFILL) +BEGIN END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; +DTD_IDENTIFIER +int +int(10) unsigned zerofill +DROP PROCEDURE p1; +# +# Bug#30556657: REVERT I_S/SHOW CREATE CHANGES REGARDING TINYINT(1) +# +CREATE TABLE t1(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, d TINYINT(1) ZEROFILL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` tinyint(1) DEFAULT NULL, + `b` tinyint(1) DEFAULT NULL, + `c` tinyint unsigned DEFAULT NULL, + `d` tinyint(1) unsigned zerofill DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT GENERATION_EXPRESSION SRS_ID +def test t1 a 1 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references NULL +def test t1 b 2 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references NULL +def test t1 c 3 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint unsigned select,insert,update,references NULL +def test t1 d 4 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) unsigned zerofill select,insert,update,references NULL +DESCRIBE t1; +Field Type Null Key Default Extra +a tinyint(1) YES NULL +b tinyint(1) YES NULL +c tinyint unsigned YES NULL +d tinyint(1) unsigned zerofill YES NULL +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; +COLUMN_TYPE +tinyint unsigned +tinyint(1) +tinyint(1) +tinyint(1) unsigned zerofill +DESCRIBE v1; +Field Type Null Key Default Extra +a tinyint(1) YES NULL +b tinyint(1) YES NULL +c tinyint unsigned YES NULL +d tinyint(1) unsigned zerofill YES NULL +DROP VIEW v1; +DROP TABLE t1; +CREATE FUNCTION f1(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) RETURNS BOOLEAN RETURN 1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) RETURNS tinyint(1) +RETURN 1 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f1'; +DTD_IDENTIFIER +tinyint(1) +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f1'; +DTD_IDENTIFIER +tinyint unsigned +tinyint(1) +tinyint(1) +tinyint(1) +tinyint(1) unsigned zerofill +DROP FUNCTION f1; +CREATE PROCEDURE p1(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) BEGIN END; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SHOW CREATE PROCEDURE p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(a BOOLEAN, b TINYINT(1), c TINYINT(1) UNSIGNED, +d TINYINT(1) ZEROFILL) +BEGIN END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; +DTD_IDENTIFIER +tinyint unsigned +tinyint(1) +tinyint(1) +tinyint(1) unsigned zerofill +DROP PROCEDURE p1; +# +# Bug#32227101: CREATE TABLE PRODUCES CORE +# +# key_block_size = 2^31-1 - rejected by Innodb +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 2147483647; +ERROR HY000: Table storage engine for 't1' doesn't have this option +# key_block_size = -(2^31)+1 - rejected by Innodb +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = -2147483647; +ERROR HY000: Table storage engine for 't1' doesn't have this option +# key_block_size = 2^31 - now rejected by parser +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 2147483648; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2147483648' at line 1 +# key_block_size = -2^31 - now rejected by parser +CREATE TABLE t1(i INT PRIMARY KEY) KEY_BLOCK_SIZE = -2147483648; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2147483648' at line 1 +# key_block_size = 2^32-1 - now rejected by parser +CREATE TABLE t2(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 4294967295; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4294967295' at line 1 +# key_block_size = 2^32 - now rejected by parser +CREATE TABLE t3(i INT PRIMARY KEY) KEY_BLOCK_SIZE = 4294967296; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4294967296' at line 1 +# key_block_size = 3927749503218772669 - now rejected by parser +CREATE TABLE t4( +c0 DECIMAL ZEROFILL UNIQUE KEY STORAGE MEMORY, +c1 DECIMAL ZEROFILL PRIMARY KEY COLUMN_FORMAT DYNAMIC UNIQUE KEY STORAGE MEMORY NOT NULL, +c2 FLOAT ZEROFILL COMMENT 'asdf' COLUMN_FORMAT FIXED NULL STORAGE MEMORY, +c3 TINYINT(120) ZEROFILL STORAGE DISK UNIQUE KEY NULL COMMENT 'asdf' +) CHECKSUM = 1, AUTO_INCREMENT = 1093400439, KEY_BLOCK_SIZE = 3927749503218772669, COMPRESSION = 'NONE'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3927749503218772669, COMPRESSION = 'NONE'' at line 6 diff --git a/mysql-test/r/ctype_binary.result-pq b/mysql-test/r/ctype_binary.result-pq new file mode 100644 index 000000000..99a634f3c --- /dev/null +++ b/mysql-test/r/ctype_binary.result-pq @@ -0,0 +1,2784 @@ +set names binary; +# +# Start of 5.5 tests +# +# +# Start of WL#2649 Number-to-string conversions +# +select hex(concat(1)); +hex(concat(1)) +31 +create table t1 as select concat(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +31 +drop table t1; +select hex(concat(18446744073709551615)); +hex(concat(18446744073709551615)) +3138343436373434303733373039353531363135 +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +3138343436373434303733373039353531363135 +drop table t1; +select hex(concat(1.1)); +hex(concat(1.1)) +312E31 +create table t1 as select concat(1.1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +312E31 +drop table t1; +select hex(concat('a', 1+2)), charset(concat(1+2)); +hex(concat('a', 1+2)) charset(concat(1+2)) +6133 binary +create table t1 as select concat(1+2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1-2)); +hex(concat(1-2)) +2D31 +create table t1 as select concat(1-2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1*2)); +hex(concat(1*2)) +32 +create table t1 as select concat(1*2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1/2)); +hex(concat(1/2)) +302E35303030 +create table t1 as select concat(1/2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(7) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1 div 2)); +hex(concat(1 div 2)) +30 +create table t1 as select concat(1 div 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1 % 2)); +hex(concat(1 % 2)) +31 +create table t1 as select concat(1 % 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(-1)); +hex(concat(-1)) +2D31 +create table t1 as select concat(-1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(-(1+2))); +hex(concat(-(1+2))) +2D33 +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1|2)); +hex(concat(1|2)) +33 +create table t1 as select concat(1|2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1&2)); +hex(concat(1&2)) +30 +create table t1 as select concat(1&2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(bit_count(12))); +hex(concat(bit_count(12))) +32 +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(2<<1)); +hex(concat(2<<1)) +34 +create table t1 as select concat(2<<1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(2>>1)); +hex(concat(2>>1)) +31 +create table t1 as select concat(2>>1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(~0)); +hex(concat(~0)) +3138343436373434303733373039353531363135 +create table t1 as select concat(~0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(3^2)); +hex(concat(3^2)) +31 +create table t1 as select concat(3^2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(abs(-2))); +hex(concat(abs(-2))) +32 +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(exp(2)),1)); +hex(left(concat(exp(2)),1)) +37 +create table t1 as select concat(exp(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log(2)),1)); +hex(left(concat(log(2)),1)) +30 +create table t1 as select concat(log(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log2(2)),1)); +hex(left(concat(log2(2)),1)) +31 +create table t1 as select concat(log2(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log10(2)),1)); +hex(left(concat(log10(2)),1)) +30 +create table t1 as select concat(log10(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(sqrt(2)),1)); +hex(left(concat(sqrt(2)),1)) +31 +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(pow(2,2)),1)); +hex(left(concat(pow(2,2)),1)) +34 +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(acos(0.5)),1)); +hex(left(concat(acos(0.5)),1)) +31 +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(asin(0.5)),1)); +hex(left(concat(asin(0.5)),1)) +30 +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(atan(0.5)),1)); +hex(left(concat(atan(0.5)),1)) +30 +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(cos(0.5)),1)); +hex(left(concat(cos(0.5)),1)) +30 +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(sin(0.5)),1)); +hex(left(concat(sin(0.5)),1)) +30 +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(tan(0.5)),1)); +hex(left(concat(tan(0.5)),1)) +30 +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(degrees(0))); +hex(concat(degrees(0))) +30 +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(radians(0))); +hex(concat(radians(0))) +30 +create table t1 as select concat(radians(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ceiling(0.5))); +hex(concat(ceiling(0.5))) +31 +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(floor(0.5))); +hex(concat(floor(0.5))) +30 +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(round(0.5))); +hex(concat(round(0.5))) +31 +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sign(0.5))); +hex(concat(sign(0.5))) +31 +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(rand()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(length('a'))); +hex(concat(length('a'))) +31 +create table t1 as select concat(length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(char_length('a'))); +hex(concat(char_length('a'))) +31 +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(bit_length('a'))); +hex(concat(bit_length('a'))) +38 +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(coercibility('a'))); +hex(concat(coercibility('a'))) +34 +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(locate('a','a'))); +hex(concat(locate('a','a'))) +31 +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(field('c','a','b','c'))); +hex(concat(field('c','a','b','c'))) +33 +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ascii(61))); +hex(concat(ascii(61))) +3534 +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ord(61))); +hex(concat(ord(61))) +3534 +create table t1 as select concat(ord(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(find_in_set('b','a,b,c,d'))); +hex(concat(find_in_set('b','a,b,c,d'))) +32 +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select md5('a'), hex(md5('a')); +md5('a') hex(md5('a')) +0cc175b9c0f1b6a831c399e269772661 3063633137356239633066316236613833316333393965323639373732363631 +create table t1 as select md5('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(32) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select sha('a'), hex(sha('a')); +sha('a') hex(sha('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(40) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select sha1('a'), hex(sha1('a')); +sha1('a') hex(sha1('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha1('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(40) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('-1' as signed))); +hex(concat(cast('-1' as signed))) +2D31 +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('1' as unsigned))); +hex(concat(cast('1' as unsigned))) +31 +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast(1/2 as decimal(5,5)))); +hex(concat(cast(1/2 as decimal(5,5)))) +302E3530303030 +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(7) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as date))); +hex(concat(cast('2001-01-02 03:04:05' as date))) +323030312D30312D3032 +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2001-01-02 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as time))); +hex(concat(cast('2001-01-02 03:04:05' as time))) +30333A30343A3035 +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +03:04:05 +drop table t1; +select hex(concat(cast('2001-01-02' as datetime))); +hex(concat(cast('2001-01-02' as datetime))) +323030312D30312D30322030303A30303A3030 +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2001-01-02 00:00:00 +drop table t1; +select hex(concat(least(1,2))); +hex(concat(least(1,2))) +31 +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(greatest(1,2))); +hex(concat(greatest(1,2))) +32 +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(case when 11 then 22 else 33 end)); +hex(concat(case when 11 then 22 else 33 end)) +3232 +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(coalesce(1,2))); +hex(concat(coalesce(1,2))) +31 +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat_ws(1,2,3)); +hex(concat_ws(1,2,3)) +323133 +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(group_concat(1,2,3)); +hex(group_concat(1,2,3)) +313233 +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` blob +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1 order by c1; +hex(c1) +31 +61 +drop table t1; +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(benchmark(0,0))); +hex(concat(benchmark(0,0))) +30 +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sleep(0))); +hex(concat(sleep(0))) +30 +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(is_free_lock('xxxx'))); +hex(concat(is_free_lock('xxxx'))) +31 +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(crc32(''))); +hex(concat(crc32(''))) +30 +create table t1 as select concat(crc32('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(uncompressed_length(''))); +hex(concat(uncompressed_length(''))) +30 +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(connection_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(inet_aton('127.1.1.1'))); +hex(concat(inet_aton('127.1.1.1'))) +32313330373732323235 +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(inet_ntoa(2130772225))); +hex(concat(inet_ntoa(2130772225))) +3132372E312E312E31 +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +c1 +127.1.1.1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(31) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select 1; +1 +1 +select hex(concat(row_count())); +hex(concat(row_count())) +2D31 +create table t1 as select concat(row_count()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t2 ( f1 integer ); +insert into t2 values (1),(2),(3),(4); +select sql_calc_found_rows * from t2 limit 2; +f1 +1 +2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select hex(concat(found_rows())); +hex(concat(found_rows())) +34 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +create table t1 as select concat(found_rows()) as c1; +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(uuid()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +coercibility(uuid()) coercibility(cast('a' as char character set latin1)) +4 2 +select charset(concat(uuid(), cast('a' as char character set latin1))); +charset(concat(uuid(), cast('a' as char character set latin1))) +latin1 +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(37) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=1)); +hex(concat(@a1:=1)) +31 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +32 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL, + `c2` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=1; +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL, + `c2` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=sqrt(1))); +hex(concat(@a1:=sqrt(1))) +31 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=sqrt(1); +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=1.1)); +hex(concat(@a1:=1.1)) +312E31 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL, + `c2` decimal(2,1) NOT NULL DEFAULT '0.0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=1.1; +select hex(concat(@a2)); +hex(concat(@a2)) +312E31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(67) DEFAULT NULL, + `c2` decimal(65,30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@@ft_max_word_len)); +hex(concat(@@ft_max_word_len)) +3834 +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +hex(c1) +3834 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a'='a' IS TRUE)); +hex(concat('a'='a' IS TRUE)) +31 +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a'='a' IS NOT TRUE)); +hex(concat('a'='a' IS NOT TRUE)) +30 +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(NOT 'a'='a')); +hex(concat(NOT 'a'='a')) +30 +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' IS NULL)); +hex(concat('a' IS NULL)) +30 +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' IS NOT NULL)); +hex(concat('a' IS NOT NULL)) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' rlike 'a')); +hex(concat('a' rlike 'a')) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(strcmp('a','b'))); +hex(concat(strcmp('a','b'))) +2D31 +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' like 'a')); +hex(concat('a' like 'a')) +31 +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' between 'b' and 'c')); +hex(concat('a' between 'b' and 'c')) +30 +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' in ('a','b'))); +hex(concat('a' in ('a','b'))) +31 +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +hex(concat(interval(23, 1, 15, 17, 30, 44, 200))) +33 +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +30 +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +select hex(ifnull(1,'a')); +hex(ifnull(1,'a')) +31 +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ifnull(1,1))); +hex(concat(ifnull(1,1))) +31 +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ifnull(1.1,1.1))); +hex(concat(ifnull(1.1,1.1))) +312E31 +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(if(1,'b',1)); +hex(if(1,'b',1)) +62 +create table t1 as select if(1,'b',1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(if(1,1,'b')); +hex(if(1,1,'b')) +31 +create table t1 as select if(1,1,'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(if(1,1,1))); +hex(concat(if(1,1,1))) +31 +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(nullif(1,2))); +hex(concat(nullif(1,2))) +31 +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Dimension(ST_GeomFromText('LINESTRING(0 0,10 10)')))); +hex(concat(ST_Dimension(ST_GeomFromText('LINESTRING(0 0,10 10)')))) +31 +create table t1 as select concat(ST_Dimension(ST_GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +ERROR 22023: Invalid GIS data provided to function st_geomfromtext. +select hex(concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +32 +create table t1 as select concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)')))); +hex(concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)')))) +32 +create table t1 as select concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +30 +create table t1 as select concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +hex(concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))) +31 +create table t1 as select concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsEmpty(ST_GeomFromText('POINT(1 1)')))); +hex(concat(ST_IsEmpty(ST_GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(ST_IsEmpty(ST_GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsSimple(ST_GeomFromText('POINT(1 1)')))); +hex(concat(ST_IsSimple(ST_GeomFromText('POINT(1 1)')))) +31 +create table t1 as select concat(ST_IsSimple(ST_GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)')))); +hex(concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)')))) +30 +create table t1 as select concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)')))); +hex(concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)')))) +31 +create table t1 as select concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)'))) as c1; +drop table t1; +select hex(concat(ST_X(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_X(ST_GeomFromText('Point(1 2)')))) +31 +create table t1 as select concat(ST_X(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Y(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_Y(ST_GeomFromText('Point(1 2)')))) +32 +create table t1 as select concat(ST_X(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Length(ST_GeomFromText('LineString(1 2,2 2)')))); +hex(concat(ST_Length(ST_GeomFromText('LineString(1 2,2 2)')))) +31 +create table t1 as select concat(ST_Length(ST_GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +hex(concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))) +31 +create table t1 as select concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_GeometryType(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_GeometryType(ST_GeomFromText('Point(1 2)')))) +504F494E54 +create table t1 as select concat(ST_GeometryType(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(15) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_AsText(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_AsText(ST_GeomFromText('Point(1 2)')))) +504F494E542831203229 +create table t1 as select concat(ST_AsText(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` longblob +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(period_add(200902, 2))); +hex(concat(period_add(200902, 2))) +323030393034 +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = ''; +select hex(concat(period_diff(200902, 200802))); +hex(concat(period_diff(200902, 200802))) +3132 +create table t1 as select concat(period_add(200902, 200802)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = default; +select hex(concat(to_days(20090224))); +hex(concat(to_days(20090224))) +373333383237 +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(8) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofmonth(20090224))); +hex(concat(dayofmonth(20090224))) +3234 +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofyear(20090224))); +hex(concat(dayofyear(20090224))) +3535 +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(hour('10:11:12'))); +hex(concat(hour('10:11:12'))) +3130 +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(minute('10:11:12'))); +hex(concat(minute('10:11:12'))) +3131 +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(second('10:11:12'))); +hex(concat(second('10:11:12'))) +3132 +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(quarter(20090224))); +hex(concat(quarter(20090224))) +31 +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(week(20090224))); +hex(concat(week(20090224))) +38 +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(yearweek(20090224))); +hex(concat(yearweek(20090224))) +323030393038 +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(7) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(year(20090224))); +hex(concat(year(20090224))) +32303039 +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(5) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(weekday(20090224))); +hex(concat(weekday(20090224))) +31 +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofweek(20090224))); +hex(concat(dayofweek(20090224))) +33 +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(unix_timestamp(20090224))); +hex(concat(unix_timestamp(20090224))) +31323335343232383030 +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(time_to_sec('10:11:12'))); +hex(concat(time_to_sec('10:11:12'))) +3336363732 +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(extract(year from 20090702))); +hex(concat(extract(year from 20090702))) +32303039 +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(5) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(microsecond('12:00:00.123456'))); +hex(concat(microsecond('12:00:00.123456'))) +313233343536 +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(month(20090224))); +hex(concat(month(20090224))) +32 +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select c1, hex(c1) from t1; +c1 hex(c1) +2003-02-28 323030332D30322D3238 +drop table t1; +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select c1, hex(c1) from t1; +c1 hex(c1) +2000-07-03 323030302D30372D3033 +drop table t1; +create table t1 as select concat(curdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(utc_date()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(curtime()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(8) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +c1 hex(c1) +2008-07-18 323030382D30372D3138 +08:42:04 30383A34323A3034 +drop table t1; +create table t1 as select concat(utc_time()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(8) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sec_to_time(2378))); +hex(concat(sec_to_time(2378))) +30303A33393A3338 +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))) +32343A30303A3030 +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(maketime(10,11,12))); +hex(concat(maketime(10,11,12))) +31303A31313A3132 +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(get_format(DATE,'USA')); +hex(get_format(DATE,'USA')) +256D2E25642E2559 +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(17) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(from_unixtime(1111885200)),4)); +hex(left(concat(from_unixtime(1111885200)),4)) +32303035 +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))) +323030332D31322D33312032303A30303A3030 +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))) +323030342D30312D30322031323A30303A3030 +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(29) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2004-01-02 12:00:00 +drop table t1; +select hex(concat(makedate(2009,1))); +hex(concat(makedate(2009,1))) +323030392D30312D3031 +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2009-01-01 +drop table t1; +create table t1 as select concat(now()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(sysdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(addtime('00:00:00','11:22:33'))); +hex(concat(addtime('00:00:00','11:22:33'))) +31313A32323A3333 +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(29) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(subtime('23:59:59','11:22:33'))); +hex(concat(subtime('23:59:59','11:22:33'))) +31323A33373A3236 +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(29) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(elt(1,2,3)); +hex(elt(1,2,3)) +32 +create table t1 as select elt(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(export_set(1,2,3,4,2)); +hex(export_set(1,2,3,4,2)) +323433 +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(127) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(insert(1133,3,0,22)); +hex(insert(1133,3,0,22)) +313132323333 +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lcase(123)); +hex(lcase(123)) +313233 +create table t1 as select lcase(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(123,1)); +hex(left(123,1)) +31 +create table t1 as select left(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lower(123)); +hex(lower(123)) +313233 +create table t1 as select lower(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lpad(1,2,0)); +hex(lpad(1,2,0)) +3031 +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(ltrim(1)); +hex(ltrim(1)) +31 +create table t1 as select ltrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(mid(1,1,1)); +hex(mid(1,1,1)) +31 +create table t1 as select mid(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(repeat(1,2)); +hex(repeat(1,2)) +3131 +create table t1 as select repeat(1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(replace(1,1,2)); +hex(replace(1,1,2)) +32 +create table t1 as select replace(1,1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(reverse(12)); +hex(reverse(12)) +3231 +create table t1 as select reverse(12) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(right(123,1)); +hex(right(123,1)) +33 +create table t1 as select right(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(rpad(1,2,0)); +hex(rpad(1,2,0)) +3130 +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(rtrim(1)); +hex(rtrim(1)) +31 +create table t1 as select rtrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(soundex(1)); +hex(soundex(1)) + +create table t1 as select soundex(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(substring(1,1,1)); +hex(substring(1,1,1)) +31 +create table t1 as select substring(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(trim(1)); +hex(trim(1)) +31 +create table t1 as select trim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(ucase(1)); +hex(ucase(1)) +31 +create table t1 as select ucase(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(upper(1)); +hex(upper(1)) +31 +create table t1 as select upper(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varbinary(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +a hex(a) +1.1 312E31 +2.1 322E31 +update t1 set a= a + 0.1; +select a, hex(a) from t1; +a hex(a) +1.2000000000000002 312E32303030303030303030303030303032 +2.2 322E32 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a tinyint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303031 001 +303130 010 +313030 100 +drop table t1; +create table t1 (a tinyint(4) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303031 0001 +30303130 0010 +30313030 0100 +drop table t1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E3435 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(12) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a smallint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303031 00001 +3030303130 00010 +3030313030 00100 +3031303030 01000 +3130303030 10000 +drop table t1; +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(9) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a mediumint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303031 00000001 +3030303030303130 00000010 +3030303030313030 00000100 +3030303031303030 00001000 +3030303130303030 00010000 +drop table t1; +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a int zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303031 0000000001 +30303030303030303130 0000000010 +30303030303030313030 0000000100 +30303030303031303030 0000001000 +30303030303130303030 0000010000 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a bigint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303030303030303030303030303031 00000000000000000001 +3030303030303030303030303030303030303130 00000000000000000010 +3030303030303030303030303030303030313030 00000000000000000100 +3030303030303030303030303030303031303030 00000000000000001000 +3030303030303030303030303030303130303030 00000000000000010000 +drop table t1; +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(12) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030312E31 0000000001.1 +303030303030303031302E31 0000000010.1 +303030303030303130302E31 0000000100.1 +303030303030313030302E31 0000001000.1 +303030303031303030302E31 0000010000.1 +drop table t1; +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a double zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303030303030303030303030312E31 00000000000000000001.1 +30303030303030303030303030303030303031302E31 00000000000000000010.1 +30303030303030303030303030303030303130302E31 00000000000000000100.1 +30303030303030303030303030303030313030302E31 00000000000000001000.1 +30303030303030303030303030303031303030302E31 00000000000000010000.1 +drop table t1; +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +32303031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a bit(64)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0000000000000001 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +hex(concat(a)) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +select concat(a) from t1; +concat(a) +0000-00-00 00:00:00 +2001-02-03 04:05:06 +1980-02-03 04:05:06 +2001-02-03 04:05:06 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D3033 +323030312D30322D3033 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +hex(concat(a)) +30303A30303A3031 +30313A30323A3033 +select concat(a) from t1; +concat(a) +00:00:01 +01:02:03 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(19) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(4) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a tinyint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(3) YES NULL +select hex(a) from v1; +hex(a) +303031 +303130 +313030 +drop table t1; +drop view v1; +create table t1 (a tinyint(30) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(30) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030303030303030303030303030303030303030303031 +303030303030303030303030303030303030303030303030303030303130 +303030303030303030303030303030303030303030303030303030313030 +drop table t1; +drop view v1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E3435 +drop table t1; +drop view v1; +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(6) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a smallint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(5) YES NULL +select hex(a) from v1; +hex(a) +3030303031 +3030303130 +3030313030 +3031303030 +3130303030 +drop table t1; +drop view v1; +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(9) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a mediumint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(8) YES NULL +select hex(a) from v1; +hex(a) +3030303030303031 +3030303030303130 +3030303030313030 +3030303031303030 +3030303130303030 +drop table t1; +drop view v1; +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(11) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a int zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(10) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303031 +30303030303030303130 +30303030303030313030 +30303030303031303030 +30303030303130303030 +drop table t1; +drop view v1; +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(20) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a bigint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(20) YES NULL +select hex(a) from v1; +hex(a) +3030303030303030303030303030303030303031 +3030303030303030303030303030303030303130 +3030303030303030303030303030303030313030 +3030303030303030303030303030303031303030 +3030303030303030303030303030303130303030 +drop table t1; +drop view v1; +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(12) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030312E31 +303030303030303031302E31 +303030303030303130302E31 +303030303030313030302E31 +303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +concat(a) +123.456 +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(22) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a double zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(22) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303030303030303030303030312E31 +30303030303030303030303030303030303031302E31 +30303030303030303030303030303030303130302E31 +30303030303030303030303030303030313030302E31 +30303030303030303030303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(4) YES NULL +select hex(a) from v1; +hex(a) +32303031 +drop table t1; +drop view v1; +create table t1 (a bit(64)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(64) YES NULL +select hex(a) from v1; +hex(a) +0000000000000001 +drop table t1; +drop view v1; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(19) YES NULL +select hex(a) from v1; +hex(a) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(10) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D3033 +323030312D30322D3033 +drop table t1; +drop view v1; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(10) YES NULL +select hex(a) from v1; +hex(a) +30303A30303A3031 +30313A30323A3033 +drop table t1; +drop view v1; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(19) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +set @a= f1(1); +select hex(@a); +hex(@a) +1 +select hex(concat(f1(1))); +hex(concat(f1(1))) +31 +create table t1 as select f1(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(11) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` decimal(18,2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(20) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` float DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(12) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(12) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +hex(@a) +323030312D30312D3032 +select hex(concat(f1(cast('2001-01-02' as date)))); +hex(concat(f1(cast('2001-01-02' as date)))) +323030312D30312D3032 +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` date DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(10) YES NULL +drop table t1; +drop view v1; +drop function f1; +# +# End of WL#2649 Number-to-string conversions +# +# +# Bug#54668 User variable assignments get wrong type +# +SET @ST_X=md5('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +binary binary +SET @ST_X=sha('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +binary binary +SET @ST_X=sha1('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +binary binary +SET @ST_X=ST_astext(point(1,2)); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +binary binary +SET @ST_X=ST_AsWKT(point(1,2)); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +binary binary +# +# WL#5510 Functions to_base64 and from_base64 +# +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varbinary(8) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1; +to_base64 LENGTH(to_base64) HEX(to_base64) +dGVzdA== 8 6447567A64413D3D +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2; +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64) +test 4 74657374 +DROP TABLE t2; +DROP TABLE t1; +# +# Bug#58190 BETWEEN no longer uses indexes for date or datetime fields +# +SELECT @@collation_connection; +@@collation_connection +binary +CREATE TABLE t1 ( +id INT(11) DEFAULT NULL, +date_column DATE DEFAULT NULL, +KEY(date_column)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range date_column date_column 4 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`date_column` AS `date_column` from `test`.`t1` where (`test`.`t1`.`date_column` between '2010-09-01' and '2010-10-01') +ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range date_column date_column 6 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`date_column` AS `date_column` from `test`.`t1` where (`test`.`t1`.`date_column` between '2010-09-01' and '2010-10-01') +DROP TABLE t1; +# +# Bug #31384 DATE_ADD() and DATE_SUB() return binary data +# +SELECT @@collation_connection, @@character_set_results; +@@collation_connection @@character_set_results +binary binary +CREATE TABLE t1 AS +SELECT +DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1, +DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2, +DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date, +DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `field_str1` varbinary(29) DEFAULT NULL, + `field1_str2` varbinary(29) DEFAULT NULL, + `field_date` date DEFAULT NULL, + `field_datetime` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SELECT +DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1, +DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2, +DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date, +DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def field_str1 254 29 10 Y 128 31 63 +def field1_str2 254 29 19 Y 128 31 63 +def field_date 10 10 10 Y 128 0 63 +def field_datetime 12 19 19 Y 128 0 63 +field_str1 field1_str2 field_date field_datetime +2007-08-02 2007-08-03 17:32:00 2007-08-02 2007-08-03 17:32:00 +SELECT +HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1, +HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2, +HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date, +HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime; +field_str1 field1_str2 field_date field_datetime +323030372D30382D30322032333A35393A3030 323030372D30382D30332031373A33323A3030 323030372D30382D3032 323030372D30382D30332031373A33323A3030 +# +# Bug#11926811 / Bug#60625 Illegal mix of collations +# +SELECT @@collation_connection; +@@collation_connection +binary +CREATE PROCEDURE p1() +BEGIN +DECLARE v_LastPaymentDate DATETIME DEFAULT NULL; +SELECT v_LastPaymentDate < NOW(); +EXPLAIN SELECT v_LastPaymentDate < NOW(); +SHOW WARNINGS; +EXPLAIN SELECT CONCAT(v_LastPaymentDate, NOW()); +END// +CALL p1; +v_LastPaymentDate < NOW() +NULL +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 /* select#1 */ select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()` +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select concat(v_LastPaymentDate@0,now()) AS `CONCAT(v_LastPaymentDate, NOW())` +DROP PROCEDURE p1; +# +# Bug#52159 returning time type from function and empty left join causes debug assertion +# +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +f1() +00:00:01 +DROP FUNCTION f1; +DROP TABLE t1; +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (); +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +maketime(`a`,`a`,`a`) +00:00:00.000000 +DROP TABLE t1; +SET sql_mode=default; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +SET NAMES binary; +SELECT is_ipv4(inet_ntoa('1')); +is_ipv4(inet_ntoa('1')) +1 +SELECT is_ipv6(inet_ntoa('1')); +is_ipv6(inet_ntoa('1')) +0 +SELECT inet6_aton(inet_ntoa('1')); +inet6_aton(inet_ntoa('1')) + +SELECT inet6_ntoa(inet_ntoa('1')); +inet6_ntoa(inet_ntoa('1')) +NULL +# +# Bug#14040277 UNINITIALIZED VALUE REFERENCED IN STR_TO_IPV6 +# +SELECT inet6_aton(soundex('a')); +inet6_aton(soundex('a')) +NULL +# +# Bug#19047425 UNINITIALISED VALUE IN STR_TO_IPV6 +# +do is_ipv4_mapped(inet6_aton(convert(_ascii "a:" using binary))); +# +# End of 5.6 tests +# diff --git a/mysql-test/r/ctype_collate.result-pq b/mysql-test/r/ctype_collate.result-pq new file mode 100644 index 000000000..6eaad4bf7 --- /dev/null +++ b/mysql-test/r/ctype_collate.result-pq @@ -0,0 +1,868 @@ +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( +latin1_f CHAR(32) NOT NULL +) charset latin1; +CREATE TABLE t2 ( +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL +); +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +CREATE TABLE t2 ( +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL +); +ERROR HY000: Unknown collation: 'some_non_existing_col' +INSERT INTO t1 (latin1_f) VALUES (_latin1'A'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'a'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AD'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ad'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ae'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'AF'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'af'); +INSERT INTO t1 (latin1_f) VALUES (_latin1''); +INSERT INTO t1 (latin1_f) VALUES (_latin1''); +INSERT INTO t1 (latin1_f) VALUES (_latin1''); +INSERT INTO t1 (latin1_f) VALUES (_latin1''); +INSERT INTO t1 (latin1_f) VALUES (_latin1'B'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'b'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'U'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'u'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'UE'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ue'); +INSERT INTO t1 (latin1_f) VALUES (_latin1''); +INSERT INTO t1 (latin1_f) VALUES (_latin1''); +INSERT INTO t1 (latin1_f) VALUES (_latin1'SS'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'ss'); +INSERT INTO t1 (latin1_f) VALUES (_latin1''); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Y'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'y'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'Z'); +INSERT INTO t1 (latin1_f) VALUES (_latin1'z'); +SELECT latin1_f FROM t1 ORDER BY latin1_f, hex(latin1_f); +latin1_f +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Y +y +Ü +ü +Z +z +Å +å +Ä +ä +ß +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci, hex(latin1_f); +latin1_f +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Y +y +Ü +ü +Z +z +Å +å +Ä +ä +ß +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci, hex(latin1_f); +latin1_f +A +a +Å +å +AD +ad +AE +ae +Ä +ä +AF +af +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci, hex(latin1_f); +latin1_f +A +a +AD +ad +AE +ae +AF +af +Ä +ä +Å +å +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin; +latin1_f +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Å +Ü +ß +ä +å +ü +SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci; +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as, hex(latin1_f_as); +latin1_f_as +A +a +AD +ad +AE +ae +AF +af +B +b +SS +ss +U +u +UE +ue +Y +y +Ü +ü +Z +z +Å +å +Ä +ä +ß +SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as, hex(latin1_f_as); +latin1_f_as +A +a +Å +å +AD +ad +AE +ae +Ä +ä +AF +af +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as, hex(latin1_f_as); +latin1_f_as +A +a +AD +ad +AE +ae +AF +af +Ä +ä +Å +å +B +b +SS +ss +ß +U +u +UE +ue +Ü +ü +Y +y +Z +z +SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +latin1_f_as +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Å +Ü +ß +ä +å +ü +SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as; +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f ORDER BY latin1_f; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +B 2 +SS 2 +U 2 +UE 2 +Ü 4 +Z 2 +Å 2 +Ä 2 +ß 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci ORDER BY latin1_f COLLATE latin1_swedish_ci; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +B 2 +SS 2 +U 2 +UE 2 +Ü 4 +Z 2 +Å 2 +Ä 2 +ß 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci ORDER BY latin1_f COLLATE latin1_german2_ci; +latin1_f count(*) +A 4 +AD 2 +AE 4 +AF 2 +B 2 +SS 3 +U 2 +UE 4 +Y 2 +Z 2 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci ORDER BY latin1_f COLLATE latin1_general_ci; +latin1_f count(*) +A 2 +AD 2 +AE 2 +AF 2 +Ä 2 +Å 2 +B 2 +SS 2 +ß 1 +U 2 +UE 2 +Ü 2 +Y 2 +Z 2 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin ORDER BY latin1_f COLLATE latin1_bin; +latin1_f count(*) +A 1 +AD 1 +AE 1 +AF 1 +B 1 +SS 1 +U 1 +UE 1 +Y 1 +Z 1 +a 1 +ad 1 +ae 1 +af 1 +b 1 +ss 1 +u 1 +ue 1 +y 1 +z 1 +Ä 1 +Å 1 +Ü 1 +ß 1 +ä 1 +å 1 +ü 1 +SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci; +ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' +SELECT DISTINCT latin1_f FROM t1; +latin1_f +A +AD +AE +AF +B +SS +U +UE +Z +Ä +Å +Ü +ß +SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1; +latin1_f COLLATE latin1_swedish_ci +A +AD +AE +AF +B +SS +U +UE +Z +Ä +Å +Ü +ß +SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1; +latin1_f COLLATE latin1_german2_ci +A +AD +AE +AF +B +SS +U +UE +Y +Z +SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1; +latin1_f COLLATE latin1_general_ci +A +AD +AE +AF +B +SS +U +UE +Y +Z +Ä +Å +Ü +ß +SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1; +latin1_f COLLATE latin1_bin +A +AD +AE +AF +B +SS +U +UE +Y +Z +a +ad +ae +af +b +ss +u +ue +y +z +Ä +Å +Ü +ß +ä +å +ü +SELECT DISTINCT latin1_f COLLATE koi8r FROM t1; +ERROR HY000: Unknown collation: 'koi8r' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) NOT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +latin1_f char(32) NO NULL +ALTER TABLE t1 CHANGE latin1_f +latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +latin1_f char(32) YES NULL +ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `latin1_f` char(32) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +latin1_f char(32) YES NULL +SET CHARACTER SET 'latin1'; +SHOW VARIABLES LIKE 'character_set_client'; +Variable_name Value +character_set_client latin1 +SELECT charset(_latin1 'a'),collation(_latin1 'a'),coercibility('a'),'a'='A'; +charset(_latin1 'a') collation(_latin1 'a') coercibility('a') 'a'='A' +latin1 latin1_swedish_ci 4 1 +explain SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select charset('a') AS `charset('a')`,collation('a') AS `collation('a')`,coercibility('a') AS `coercibility('a')`,('a' = 'A') AS `'a'='A'` +SET CHARACTER SET koi8r; +SHOW VARIABLES LIKE 'collation_client'; +Variable_name Value +SELECT charset(_latin1 'a'),collation(_latin1 'a'),coercibility('a'),'a'='A'; +charset(_latin1 'a') collation(_latin1 'a') coercibility('a') 'a'='A' +latin1 latin1_swedish_ci 4 1 +SET CHARACTER SET 'DEFAULT'; +ERROR 42000: Unknown character set: 'DEFAULT' +DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci); +SELECT * FROM t1 WHERE s1 = s2; +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci, +s3 CHAR(5) COLLATE latin1_bin); +INSERT INTO t1 VALUES ('a','A','A'); +SELECT * FROM t1 WHERE s1 = s2; +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +SELECT * FROM t1 WHERE s1 = s3; +s1 s2 s3 +SELECT * FROM t1 WHERE s2 = s3; +s1 s2 s3 +a A A +DROP TABLE t1; +create table t1 (a varchar(1) character set latin1 collate latin1_general_ci); +insert into t1 values ('A'),('a'),('B'),('b'),('C'),('c'); +select * from t1 where a > _latin1 'B' collate latin1_bin; +a +a +b +C +c +select * from t1 where a <> _latin1 'B' collate latin1_bin; +a +A +a +b +C +c +create index i on t1 (a); +select * from t1 where a > _latin1 'B' collate latin1_bin; +a +a +b +C +c +select * from t1 where a <> _latin1 'B' collate latin1_bin; +a +A +a +b +C +c +drop table t1; +SET NAMES latin1; +CREATE TABLE t1 +(s1 char(10) COLLATE latin1_german1_ci, +s2 char(10) COLLATE latin1_swedish_ci, +KEY(s1), +KEY(s2)); +INSERT INTO t1 VALUES ('a','a'); +INSERT INTO t1 VALUES ('b','b'); +INSERT INTO t1 VALUES ('c','c'); +INSERT INTO t1 VALUES ('d','d'); +INSERT INTO t1 VALUES ('e','e'); +INSERT INTO t1 VALUES ('f','f'); +INSERT INTO t1 VALUES ('g','g'); +INSERT INTO t1 VALUES ('h','h'); +INSERT INTO t1 VALUES ('i','i'); +INSERT INTO t1 VALUES ('j','j'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE s1='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref s1 s1 11 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` = 'a') +EXPLAIN SELECT * FROM t1 WHERE s2='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref s2 s2 11 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` = 'a') +EXPLAIN SELECT * FROM t1 WHERE s1='a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref s1 s1 11 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` = ('a' collate latin1_german1_ci)) +EXPLAIN SELECT * FROM t1 WHERE s2='a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1739 Cannot use ref access on index 's2' due to type or collation conversion on field 's2' +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` = (('a' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s1 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range s1 s1 11 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` between 'a' and (('b' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s2 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.10 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 10.10 Using where +Warnings: +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` between 'a' and (('b' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s1 IN ('a','b' COLLATE latin1_german1_ci); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range s1 s1 11 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` in ('a',(('b' collate latin1_german1_ci)))) +EXPLAIN SELECT * FROM t1 WHERE s2 IN ('a','b' COLLATE latin1_german1_ci); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 20.00 Using where +Warnings: +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` in ('a',(('b' collate latin1_german1_ci)))) +EXPLAIN SELECT * FROM t1 WHERE s1 LIKE 'a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range s1 s1 11 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s1` like (('a' collate latin1_german1_ci))) +EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.10 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL s2 NULL NULL NULL 10 10.10 Using where +Warnings: +Warning 1739 Cannot use range access on index 's2' due to type or collation conversion on field 's2' +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where (`test`.`t1`.`s2` like (('a' collate latin1_german1_ci))) +DROP TABLE t1; +create table t1(f1 varchar(10) character set latin2 collate latin2_hungarian_ci, key(f1)); +insert into t1 set f1=0x3F3F9DC73F; +insert into t1 set f1=0x3F3F1E563F; +insert into t1 set f1=0x3F3F; +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a)); +insert into t1 set a=0x4c20; +insert into t1 set a=0x6c; +insert into t1 set a=0x4c98; +check table t1 extended; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); +least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) +a +create table t1 charset latin1 +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(1) CHARACTER SET latin5 NOT NULL DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +drop table t1; +select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate +latin5_turkish_ci then 2 else 3 end; +case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate +latin5_turkish_ci then 2 else 3 end +3 +select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); +concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) +abc +SET sql_mode = default; +# +# Bug#11765016 57926: ILLEGAL MIX OF COLLATIONS FOR OPERATION 'UNION' .. USING CONCAT/FUNCTION/ +# Not a bug: only adding coverage tests +# +SET NAMES latin1 COLLATE latin1_german2_ci; +CREATE DATABASE test1 DEFAULT CHARACTER SET latin1 COLLATE latin1_german2_ci; +USE test1; +# +# Using "COLLATE latin1_swedish_ci" as the default collation for latin1 +# +CREATE FUNCTION `getText`() RETURNS varchar(20) CHARSET latin1 +BEGIN +RETURN "Testtext"; +END;// +SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText()); +getText() CHARSET(getText()) COLLATION(getText()) COERCIBILITY(getText()) +Testtext latin1 latin1_swedish_ci 4 +CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText(); +ERROR HY000: Illegal mix of collations for operation 'UNION' +DROP FUNCTION getText; +# +# Using "CHARACTER SET latin1 COLLATE latin1_german2_ci" as the database defaults +# +CREATE FUNCTION `getText`() RETURNS varchar(20) +BEGIN +RETURN "Testtext"; +END;// +SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText()); +getText() CHARSET(getText()) COLLATION(getText()) COERCIBILITY(getText()) +Testtext latin1 latin1_german2_ci 4 +CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText(); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(20) COLLATE latin1_german2_ci DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +DROP TABLE t1; +DROP FUNCTION getText; +# +# Using explicit "CHARACTER SET latin1 COLLATE latin1_german2_ci" +# +CREATE FUNCTION `getText`() RETURNS varchar(20) CHARACTER SET latin1 COLLATE latin1_german2_ci +BEGIN +RETURN "Testtext"; +END;// +SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText()); +getText() CHARSET(getText()) COLLATION(getText()) COERCIBILITY(getText()) +Testtext latin1 latin1_german2_ci 4 +CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText(); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(20) COLLATE latin1_german2_ci DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +DROP TABLE t1; +DROP FUNCTION getText; +DROP DATABASE test1; +USE test; +SET NAMES latin1; +# Bug#20425399: CAN'T USE COLLATE +CREATE TABLE t1(a TINYINT, b SMALLINT, c MEDIUMINT, d INT, e BIGINT); +CREATE TABLE t2(a DECIMAL(5,2)); +CREATE TABLE t3(a FLOAT(5,2), b DOUBLE(5,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES(1, 2, 3, 4, 100); +INSERT INTO t1 VALUES(2, 3, 4, 100, 1); +INSERT INTO t1 VALUES(3, 4, 100, 1, 2); +INSERT INTO t1 VALUES(4, 100, 1, 2, 3); +INSERT INTO t1 VALUES(100, 1, 2, 3, 4); +SELECT * FROM t1 ORDER BY a; +a b c d e +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +4 100 1 2 3 +100 1 2 3 4 +SELECT * FROM t1 ORDER BY a COLLATE utf8_bin; +a b c d e +1 2 3 4 100 +100 1 2 3 4 +2 3 4 100 1 +3 4 100 1 2 +4 100 1 2 3 +SELECT * FROM t1 ORDER BY b; +a b c d e +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +4 100 1 2 3 +SELECT * FROM t1 ORDER BY b COLLATE latin1_swedish_ci; +a b c d e +100 1 2 3 4 +4 100 1 2 3 +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +SELECT * FROM t1 ORDER BY c; +a b c d e +4 100 1 2 3 +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +3 4 100 1 2 +SELECT * FROM t1 ORDER BY c COLLATE gb2312_chinese_ci; +a b c d e +4 100 1 2 3 +3 4 100 1 2 +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +SELECT * FROM t1 ORDER BY d; +a b c d e +3 4 100 1 2 +4 100 1 2 3 +100 1 2 3 4 +1 2 3 4 100 +2 3 4 100 1 +SELECT * FROM t1 ORDER BY d COLLATE ascii_general_ci; +a b c d e +3 4 100 1 2 +2 3 4 100 1 +4 100 1 2 3 +100 1 2 3 4 +1 2 3 4 100 +INSERT INTO t2 VALUES(1.01); +INSERT INTO t2 VALUES(2.99); +INSERT INTO t2 VALUES(100.49); +SELECT * FROM t2 ORDER BY a; +a +1.01 +2.99 +100.49 +SELECT * FROM t2 ORDER BY a COLLATE latin1_german1_ci; +a +1.01 +100.49 +2.99 +INSERT INTO t3 VALUES(1.01, 2.99); +INSERT INTO t3 VALUES(2.99, 100.49); +INSERT INTO t3 VALUES(100.49, 1.01); +SELECT * FROM t3 ORDER BY a; +a b +1.01 2.99 +2.99 100.49 +100.49 1.01 +SELECT * FROM t3 ORDER BY a COLLATE ascii_bin; +a b +1.01 2.99 +100.49 1.01 +2.99 100.49 +SELECT * FROM t3 ORDER BY b; +a b +100.49 1.01 +1.01 2.99 +2.99 100.49 +SELECT * FROM t3 ORDER BY b COLLATE utf8_general_ci; +a b +100.49 1.01 +2.99 100.49 +1.01 2.99 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/r/ctype_cp1251.result-pq b/mysql-test/r/ctype_cp1251.result-pq new file mode 100644 index 000000000..89742b564 --- /dev/null +++ b/mysql-test/r/ctype_cp1251.result-pq @@ -0,0 +1,3188 @@ +drop table if exists t1; +SET NAMES cp1251; +create table t1 (a varchar(10) not null) character set cp1251; +insert into t1 values ("a"),("ab"),("abc"); +select * from t1; +a +a +ab +abc +select a, left(a,1) as b from t1; +a b +a a +ab a +abc a +select a, left(a,1) as b from t1 group by a; +a b +a a +ab a +abc a +SELECT DISTINCT RIGHT(a,1) from t1; +RIGHT(a,1) +a +b +c +drop table t1; +create table t1 (a char(3) binary, b binary(3)) character set cp1251; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values ('aaa','bbb'),('AAA','BBB'); +select upper(a),upper(b) from t1; +upper(a) upper(b) +AAA bbb +AAA BBB +select lower(a),lower(b) from t1; +lower(a) lower(b) +aaa bbb +aaa BBB +select * from t1 where upper(a)='AAA'; +a b +aaa bbb +AAA BBB +select * from t1 where lower(a)='aaa'; +a b +aaa bbb +AAA BBB +select * from t1 where upper(b)='BBB'; +a b +AAA BBB +select * from t1 where lower(b)='bbb'; +a b +aaa bbb +select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1; +charset(a) charset(b) charset(binary 'ccc') +cp1251 binary binary +select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1; +collation(a) collation(b) collation(binary 'ccc') +cp1251_bin binary binary +drop table t1; +create table t1 ( +a varchar(16) character set cp1251 collate cp1251_bin not null, +b int(10) default null, +primary key(a) +) charset=cp1251; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (a) values ('air'), +('we'),('g'),('we_toshko'), ('s0urce'),('we_ivo'),('we_iliyan'), +('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'), +('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1'); +SELECT * FROM t1 WHERE a LIKE 'we_%' ORDER BY a; +a b +we_iliyan NULL +we_ivo NULL +we_martin NULL +we_toshko NULL +drop table t1; +# +# Start of 5.1 tests +# +SELECT @@collation_connection; +@@collation_connection +cp1251_general_ci +CREATE TABLE t1 AS SELECT ' ' AS a LIMIT 0; +INSERT INTO t1 VALUES (0x00),(0x01),(0x02),(0x03),(0x04),(0x05),(0x06),(0x07); +INSERT INTO t1 VALUES (0x08),(0x09),(0x0A),(0x0B),(0x0C),(0x0D),(0x0E),(0x0F); +INSERT INTO t1 VALUES (0x10),(0x11),(0x12),(0x13),(0x14),(0x15),(0x16),(0x17); +INSERT INTO t1 VALUES (0x18),(0x19),(0x1A),(0x1B),(0x1C),(0x1D),(0x1E),(0x1F); +INSERT INTO t1 VALUES (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27); +INSERT INTO t1 VALUES (0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F); +INSERT INTO t1 VALUES (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37); +INSERT INTO t1 VALUES (0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F); +INSERT INTO t1 VALUES (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47); +INSERT INTO t1 VALUES (0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F); +INSERT INTO t1 VALUES (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57); +INSERT INTO t1 VALUES (0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F); +INSERT INTO t1 VALUES (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67); +INSERT INTO t1 VALUES (0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F); +INSERT INTO t1 VALUES (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77); +INSERT INTO t1 VALUES (0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F); +INSERT INTO t1 VALUES (0x80),(0x81),(0x82),(0x83),(0x84),(0x85),(0x86),(0x87); +INSERT INTO t1 VALUES (0x88),(0x89),(0x8A),(0x8B),(0x8C),(0x8D),(0x8E),(0x8F); +INSERT INTO t1 VALUES (0x90),(0x91),(0x92),(0x93),(0x94),(0x95),(0x96),(0x97); +INSERT INTO t1 VALUES (0x98),(0x99),(0x9A),(0x9B),(0x9C),(0x9D),(0x9E),(0x9F); +INSERT INTO t1 VALUES (0xA0),(0xA1),(0xA2),(0xA3),(0xA4),(0xA5),(0xA6),(0xA7); +INSERT INTO t1 VALUES (0xA8),(0xA9),(0xAA),(0xAB),(0xAC),(0xAD),(0xAE),(0xAF); +INSERT INTO t1 VALUES (0xB0),(0xB1),(0xB2),(0xB3),(0xB4),(0xB5),(0xB6),(0xB7); +INSERT INTO t1 VALUES (0xB8),(0xB9),(0xBA),(0xBB),(0xBC),(0xBD),(0xBE),(0xBF); +INSERT INTO t1 VALUES (0xC0),(0xC1),(0xC2),(0xC3),(0xC4),(0xC5),(0xC6),(0xC7); +INSERT INTO t1 VALUES (0xC8),(0xC9),(0xCA),(0xCB),(0xCC),(0xCD),(0xCE),(0xCF); +INSERT INTO t1 VALUES (0xD0),(0xD1),(0xD2),(0xD3),(0xD4),(0xD5),(0xD6),(0xD7); +INSERT INTO t1 VALUES (0xD8),(0xD9),(0xDA),(0xDB),(0xDC),(0xDD),(0xDE),(0xDF); +INSERT INTO t1 VALUES (0xE0),(0xE1),(0xE2),(0xE3),(0xE4),(0xE5),(0xE6),(0xE7); +INSERT INTO t1 VALUES (0xE8),(0xE9),(0xEA),(0xEB),(0xEC),(0xED),(0xEE),(0xEF); +INSERT INTO t1 VALUES (0xF0),(0xF1),(0xF2),(0xF3),(0xF4),(0xF5),(0xF6),(0xF7); +INSERT INTO t1 VALUES (0xF8),(0xF9),(0xFA),(0xFB),(0xFC),(0xFD),(0xFE),(0xFF); +SELECT +HEX(a) AS chr, +HEX(LOWER(a)) AS upper, +HEX(LOWER(a)) AS lower, +HEX(@utf8:=CONVERT(a USING utf8)) AS utf8, +HEX(@roundtrip:=CAST(@utf8 AS CHAR)) AS roundtrip, +if(a=BINARY @roundtrip,'','Round trip unsafe') AS issafe +FROM t1 ORDER BY chr; +chr upper lower utf8 roundtrip issafe +00 00 00 00 00 +01 01 01 01 01 +02 02 02 02 02 +03 03 03 03 03 +04 04 04 04 04 +05 05 05 05 05 +06 06 06 06 06 +07 07 07 07 07 +08 08 08 08 08 +09 09 09 09 09 +0A 0A 0A 0A 0A +0B 0B 0B 0B 0B +0C 0C 0C 0C 0C +0D 0D 0D 0D 0D +0E 0E 0E 0E 0E +0F 0F 0F 0F 0F +10 10 10 10 10 +11 11 11 11 11 +12 12 12 12 12 +13 13 13 13 13 +14 14 14 14 14 +15 15 15 15 15 +16 16 16 16 16 +17 17 17 17 17 +18 18 18 18 18 +19 19 19 19 19 +1A 1A 1A 1A 1A +1B 1B 1B 1B 1B +1C 1C 1C 1C 1C +1D 1D 1D 1D 1D +1E 1E 1E 1E 1E +1F 1F 1F 1F 1F +20 20 20 20 20 +21 21 21 21 21 +22 22 22 22 22 +23 23 23 23 23 +24 24 24 24 24 +25 25 25 25 25 +26 26 26 26 26 +27 27 27 27 27 +28 28 28 28 28 +29 29 29 29 29 +2A 2A 2A 2A 2A +2B 2B 2B 2B 2B +2C 2C 2C 2C 2C +2D 2D 2D 2D 2D +2E 2E 2E 2E 2E +2F 2F 2F 2F 2F +30 30 30 30 30 +31 31 31 31 31 +32 32 32 32 32 +33 33 33 33 33 +34 34 34 34 34 +35 35 35 35 35 +36 36 36 36 36 +37 37 37 37 37 +38 38 38 38 38 +39 39 39 39 39 +3A 3A 3A 3A 3A +3B 3B 3B 3B 3B +3C 3C 3C 3C 3C +3D 3D 3D 3D 3D +3E 3E 3E 3E 3E +3F 3F 3F 3F 3F +40 40 40 40 40 +41 61 61 41 41 +42 62 62 42 42 +43 63 63 43 43 +44 64 64 44 44 +45 65 65 45 45 +46 66 66 46 46 +47 67 67 47 47 +48 68 68 48 48 +49 69 69 49 49 +4A 6A 6A 4A 4A +4B 6B 6B 4B 4B +4C 6C 6C 4C 4C +4D 6D 6D 4D 4D +4E 6E 6E 4E 4E +4F 6F 6F 4F 4F +50 70 70 50 50 +51 71 71 51 51 +52 72 72 52 52 +53 73 73 53 53 +54 74 74 54 54 +55 75 75 55 55 +56 76 76 56 56 +57 77 77 57 57 +58 78 78 58 58 +59 79 79 59 59 +5A 7A 7A 5A 5A +5B 5B 5B 5B 5B +5C 5C 5C 5C 5C +5D 5D 5D 5D 5D +5E 5E 5E 5E 5E +5F 5F 5F 5F 5F +60 60 60 60 60 +61 61 61 61 61 +62 62 62 62 62 +63 63 63 63 63 +64 64 64 64 64 +65 65 65 65 65 +66 66 66 66 66 +67 67 67 67 67 +68 68 68 68 68 +69 69 69 69 69 +6A 6A 6A 6A 6A +6B 6B 6B 6B 6B +6C 6C 6C 6C 6C +6D 6D 6D 6D 6D +6E 6E 6E 6E 6E +6F 6F 6F 6F 6F +70 70 70 70 70 +71 71 71 71 71 +72 72 72 72 72 +73 73 73 73 73 +74 74 74 74 74 +75 75 75 75 75 +76 76 76 76 76 +77 77 77 77 77 +78 78 78 78 78 +79 79 79 79 79 +7A 7A 7A 7A 7A +7B 7B 7B 7B 7B +7C 7C 7C 7C 7C +7D 7D 7D 7D 7D +7E 7E 7E 7E 7E +7F 7F 7F 7F 7F +80 90 90 D082 80 +81 83 83 D083 81 +82 82 82 E2809A 82 +83 83 83 D193 83 +84 84 84 E2809E 84 +85 85 85 E280A6 85 +86 86 86 E280A0 86 +87 87 87 E280A1 87 +88 88 88 E282AC 88 +89 89 89 E280B0 89 +8A 9A 9A D089 8A +8B 8B 8B E280B9 8B +8C 9C 9C D08A 8C +8D 9D 9D D08C 8D +8E 9E 9E D08B 8E +8F 9F 9F D08F 8F +90 90 90 D192 90 +91 91 91 E28098 91 +92 92 92 E28099 92 +93 93 93 E2809C 93 +94 94 94 E2809D 94 +95 95 95 E280A2 95 +96 96 96 E28093 96 +97 97 97 E28094 97 +98 98 98 3F 3F Round trip unsafe +99 99 99 E284A2 99 +9A 9A 9A D199 9A +9B 9B 9B E280BA 9B +9C 9C 9C D19A 9C +9D 9D 9D D19C 9D +9E 9E 9E D19B 9E +9F 9F 9F D19F 9F +A0 A0 A0 C2A0 A0 +A1 A2 A2 D08E A1 +A2 A2 A2 D19E A2 +A3 BC BC D088 A3 +A4 A4 A4 C2A4 A4 +A5 B4 B4 D290 A5 +A6 A6 A6 C2A6 A6 +A7 A7 A7 C2A7 A7 +A8 B8 B8 D081 A8 +A9 A9 A9 C2A9 A9 +AA BA BA D084 AA +AB AB AB C2AB AB +AC AC AC C2AC AC +AD AD AD C2AD AD +AE AE AE C2AE AE +AF BF BF D087 AF +B0 B0 B0 C2B0 B0 +B1 B1 B1 C2B1 B1 +B2 B3 B3 D086 B2 +B3 B3 B3 D196 B3 +B4 B4 B4 D291 B4 +B5 B5 B5 C2B5 B5 +B6 B6 B6 C2B6 B6 +B7 B7 B7 C2B7 B7 +B8 B8 B8 D191 B8 +B9 B9 B9 E28496 B9 +BA BA BA D194 BA +BB BB BB C2BB BB +BC BC BC D198 BC +BD BE BE D085 BD +BE BE BE D195 BE +BF BF BF D197 BF +C0 E0 E0 D090 C0 +C1 E1 E1 D091 C1 +C2 E2 E2 D092 C2 +C3 E3 E3 D093 C3 +C4 E4 E4 D094 C4 +C5 E5 E5 D095 C5 +C6 E6 E6 D096 C6 +C7 E7 E7 D097 C7 +C8 E8 E8 D098 C8 +C9 E9 E9 D099 C9 +CA EA EA D09A CA +CB EB EB D09B CB +CC EC EC D09C CC +CD ED ED D09D CD +CE EE EE D09E CE +CF EF EF D09F CF +D0 F0 F0 D0A0 D0 +D1 F1 F1 D0A1 D1 +D2 F2 F2 D0A2 D2 +D3 F3 F3 D0A3 D3 +D4 F4 F4 D0A4 D4 +D5 F5 F5 D0A5 D5 +D6 F6 F6 D0A6 D6 +D7 F7 F7 D0A7 D7 +D8 F8 F8 D0A8 D8 +D9 F9 F9 D0A9 D9 +DA FA FA D0AA DA +DB FB FB D0AB DB +DC FC FC D0AC DC +DD FD FD D0AD DD +DE FE FE D0AE DE +DF FF FF D0AF DF +E0 E0 E0 D0B0 E0 +E1 E1 E1 D0B1 E1 +E2 E2 E2 D0B2 E2 +E3 E3 E3 D0B3 E3 +E4 E4 E4 D0B4 E4 +E5 E5 E5 D0B5 E5 +E6 E6 E6 D0B6 E6 +E7 E7 E7 D0B7 E7 +E8 E8 E8 D0B8 E8 +E9 E9 E9 D0B9 E9 +EA EA EA D0BA EA +EB EB EB D0BB EB +EC EC EC D0BC EC +ED ED ED D0BD ED +EE EE EE D0BE EE +EF EF EF D0BF EF +F0 F0 F0 D180 F0 +F1 F1 F1 D181 F1 +F2 F2 F2 D182 F2 +F3 F3 F3 D183 F3 +F4 F4 F4 D184 F4 +F5 F5 F5 D185 F5 +F6 F6 F6 D186 F6 +F7 F7 F7 D187 F7 +F8 F8 F8 D188 F8 +F9 F9 F9 D189 F9 +FA FA FA D18A FA +FB FB FB D18B FB +FC FC FC D18C FC +FD FD FD D18D FD +FE FE FE D18E FE +FF FF FF D18F FF +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +set global LC_TIME_NAMES=convert((-8388608) using cp1251); +ERROR HY000: Unknown locale: '-8388608' +# +# End of 5.1 tests +# +# +# Start of 5.5 tests +# +# +# Start of WL#2649 Number-to-string conversions +# +select hex(concat(1)); +hex(concat(1)) +31 +create table t1 as select concat(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +31 +drop table t1; +select hex(concat(18446744073709551615)); +hex(concat(18446744073709551615)) +3138343436373434303733373039353531363135 +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +3138343436373434303733373039353531363135 +drop table t1; +select hex(concat(1.1)); +hex(concat(1.1)) +312E31 +create table t1 as select concat(1.1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +312E31 +drop table t1; +select hex(concat('a', 1+2)), charset(concat(1+2)); +hex(concat('a', 1+2)) charset(concat(1+2)) +6133 cp1251 +create table t1 as select concat(1+2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1-2)); +hex(concat(1-2)) +2D31 +create table t1 as select concat(1-2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1*2)); +hex(concat(1*2)) +32 +create table t1 as select concat(1*2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1/2)); +hex(concat(1/2)) +302E35303030 +create table t1 as select concat(1/2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1 div 2)); +hex(concat(1 div 2)) +30 +create table t1 as select concat(1 div 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1 % 2)); +hex(concat(1 % 2)) +31 +create table t1 as select concat(1 % 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(-1)); +hex(concat(-1)) +2D31 +create table t1 as select concat(-1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(-(1+2))); +hex(concat(-(1+2))) +2D33 +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1|2)); +hex(concat(1|2)) +33 +create table t1 as select concat(1|2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1&2)); +hex(concat(1&2)) +30 +create table t1 as select concat(1&2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(bit_count(12))); +hex(concat(bit_count(12))) +32 +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(2<<1)); +hex(concat(2<<1)) +34 +create table t1 as select concat(2<<1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(2>>1)); +hex(concat(2>>1)) +31 +create table t1 as select concat(2>>1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(~0)); +hex(concat(~0)) +3138343436373434303733373039353531363135 +create table t1 as select concat(~0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(3^2)); +hex(concat(3^2)) +31 +create table t1 as select concat(3^2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(abs(-2))); +hex(concat(abs(-2))) +32 +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(exp(2)),1)); +hex(left(concat(exp(2)),1)) +37 +create table t1 as select concat(exp(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log(2)),1)); +hex(left(concat(log(2)),1)) +30 +create table t1 as select concat(log(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log2(2)),1)); +hex(left(concat(log2(2)),1)) +31 +create table t1 as select concat(log2(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log10(2)),1)); +hex(left(concat(log10(2)),1)) +30 +create table t1 as select concat(log10(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(sqrt(2)),1)); +hex(left(concat(sqrt(2)),1)) +31 +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(pow(2,2)),1)); +hex(left(concat(pow(2,2)),1)) +34 +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(acos(0.5)),1)); +hex(left(concat(acos(0.5)),1)) +31 +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(asin(0.5)),1)); +hex(left(concat(asin(0.5)),1)) +30 +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(atan(0.5)),1)); +hex(left(concat(atan(0.5)),1)) +30 +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(cos(0.5)),1)); +hex(left(concat(cos(0.5)),1)) +30 +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(sin(0.5)),1)); +hex(left(concat(sin(0.5)),1)) +30 +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(tan(0.5)),1)); +hex(left(concat(tan(0.5)),1)) +30 +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(degrees(0))); +hex(concat(degrees(0))) +30 +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(radians(0))); +hex(concat(radians(0))) +30 +create table t1 as select concat(radians(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ceiling(0.5))); +hex(concat(ceiling(0.5))) +31 +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(floor(0.5))); +hex(concat(floor(0.5))) +30 +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(round(0.5))); +hex(concat(round(0.5))) +31 +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sign(0.5))); +hex(concat(sign(0.5))) +31 +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(rand()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(length('a'))); +hex(concat(length('a'))) +31 +create table t1 as select concat(length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(char_length('a'))); +hex(concat(char_length('a'))) +31 +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(bit_length('a'))); +hex(concat(bit_length('a'))) +38 +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(coercibility('a'))); +hex(concat(coercibility('a'))) +34 +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(locate('a','a'))); +hex(concat(locate('a','a'))) +31 +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(field('c','a','b','c'))); +hex(concat(field('c','a','b','c'))) +33 +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ascii(61))); +hex(concat(ascii(61))) +3534 +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ord(61))); +hex(concat(ord(61))) +3534 +create table t1 as select concat(ord(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(find_in_set('b','a,b,c,d'))); +hex(concat(find_in_set('b','a,b,c,d'))) +32 +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select md5('a'), hex(md5('a')); +md5('a') hex(md5('a')) +0cc175b9c0f1b6a831c399e269772661 3063633137356239633066316236613833316333393965323639373732363631 +create table t1 as select md5('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(32) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select sha('a'), hex(sha('a')); +sha('a') hex(sha('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select sha1('a'), hex(sha1('a')); +sha1('a') hex(sha1('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha1('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('-1' as signed))); +hex(concat(cast('-1' as signed))) +2D31 +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('1' as unsigned))); +hex(concat(cast('1' as unsigned))) +31 +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast(1/2 as decimal(5,5)))); +hex(concat(cast(1/2 as decimal(5,5)))) +302E3530303030 +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as date))); +hex(concat(cast('2001-01-02 03:04:05' as date))) +323030312D30312D3032 +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2001-01-02 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as time))); +hex(concat(cast('2001-01-02 03:04:05' as time))) +30333A30343A3035 +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +03:04:05 +drop table t1; +select hex(concat(cast('2001-01-02' as datetime))); +hex(concat(cast('2001-01-02' as datetime))) +323030312D30312D30322030303A30303A3030 +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2001-01-02 00:00:00 +drop table t1; +select hex(concat(least(1,2))); +hex(concat(least(1,2))) +31 +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(greatest(1,2))); +hex(concat(greatest(1,2))) +32 +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(case when 11 then 22 else 33 end)); +hex(concat(case when 11 then 22 else 33 end)) +3232 +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(coalesce(1,2))); +hex(concat(coalesce(1,2))) +31 +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat_ws(1,2,3)); +hex(concat_ws(1,2,3)) +323133 +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(group_concat(1,2,3)); +hex(group_concat(1,2,3)) +313233 +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` text CHARACTER SET cp1251 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1 order by c1; +hex(c1) +31 +61 +drop table t1; +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(benchmark(0,0))); +hex(concat(benchmark(0,0))) +30 +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sleep(0))); +hex(concat(sleep(0))) +30 +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(is_free_lock('xxxx'))); +hex(concat(is_free_lock('xxxx'))) +31 +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(crc32(''))); +hex(concat(crc32(''))) +30 +create table t1 as select concat(crc32('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(uncompressed_length(''))); +hex(concat(uncompressed_length(''))) +30 +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(connection_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(inet_aton('127.1.1.1'))); +hex(concat(inet_aton('127.1.1.1'))) +32313330373732323235 +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(inet_ntoa(2130772225))); +hex(concat(inet_ntoa(2130772225))) +3132372E312E312E31 +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +c1 +127.1.1.1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(31) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select 1; +1 +1 +select hex(concat(row_count())); +hex(concat(row_count())) +2D31 +create table t1 as select concat(row_count()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t2 ( f1 integer ); +insert into t2 values (1),(2),(3),(4); +select sql_calc_found_rows * from t2 limit 2; +f1 +1 +2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select hex(concat(found_rows())); +hex(concat(found_rows())) +34 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +create table t1 as select concat(found_rows()) as c1; +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(uuid()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +coercibility(uuid()) coercibility(cast('a' as char character set latin1)) +4 2 +select charset(concat(uuid(), cast('a' as char character set latin1))); +charset(concat(uuid(), cast('a' as char character set latin1))) +latin1 +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(37) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=1)); +hex(concat(@a1:=1)) +31 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +32 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL, + `c2` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=1; +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL, + `c2` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=sqrt(1))); +hex(concat(@a1:=sqrt(1))) +31 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=sqrt(1); +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=1.1)); +hex(concat(@a1:=1.1)) +312E31 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL, + `c2` decimal(2,1) NOT NULL DEFAULT '0.0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=1.1; +select hex(concat(@a2)); +hex(concat(@a2)) +312E31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(67) CHARACTER SET cp1251 DEFAULT NULL, + `c2` decimal(65,30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@@ft_max_word_len)); +hex(concat(@@ft_max_word_len)) +3834 +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +hex(c1) +3834 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a'='a' IS TRUE)); +hex(concat('a'='a' IS TRUE)) +31 +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a'='a' IS NOT TRUE)); +hex(concat('a'='a' IS NOT TRUE)) +30 +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(NOT 'a'='a')); +hex(concat(NOT 'a'='a')) +30 +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' IS NULL)); +hex(concat('a' IS NULL)) +30 +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' IS NOT NULL)); +hex(concat('a' IS NOT NULL)) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' rlike 'a')); +hex(concat('a' rlike 'a')) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(strcmp('a','b'))); +hex(concat(strcmp('a','b'))) +2D31 +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' like 'a')); +hex(concat('a' like 'a')) +31 +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' between 'b' and 'c')); +hex(concat('a' between 'b' and 'c')) +30 +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' in ('a','b'))); +hex(concat('a' in ('a','b'))) +31 +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +hex(concat(interval(23, 1, 15, 17, 30, 44, 200))) +33 +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +30 +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +select hex(ifnull(1,'a')); +hex(ifnull(1,'a')) +31 +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ifnull(1,1))); +hex(concat(ifnull(1,1))) +31 +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ifnull(1.1,1.1))); +hex(concat(ifnull(1.1,1.1))) +312E31 +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(if(1,'b',1)); +hex(if(1,'b',1)) +62 +create table t1 as select if(1,'b',1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(if(1,1,'b')); +hex(if(1,1,'b')) +31 +create table t1 as select if(1,1,'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(if(1,1,1))); +hex(concat(if(1,1,1))) +31 +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(nullif(1,2))); +hex(concat(nullif(1,2))) +31 +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Dimension(ST_GeomFromText('LINESTRING(0 0,10 10)')))); +hex(concat(ST_Dimension(ST_GeomFromText('LINESTRING(0 0,10 10)')))) +31 +create table t1 as select concat(ST_Dimension(ST_GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +ERROR 22023: Invalid GIS data provided to function st_geomfromtext. +select hex(concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +32 +create table t1 as select concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)')))); +hex(concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)')))) +32 +create table t1 as select concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +30 +create table t1 as select concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +hex(concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))) +31 +create table t1 as select concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsEmpty(ST_GeomFromText('POINT(1 1)')))); +hex(concat(ST_IsEmpty(ST_GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(ST_IsEmpty(ST_GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsSimple(ST_GeomFromText('POINT(1 1)')))); +hex(concat(ST_IsSimple(ST_GeomFromText('POINT(1 1)')))) +31 +create table t1 as select concat(ST_IsSimple(ST_GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)')))); +hex(concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)')))) +30 +create table t1 as select concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)')))); +hex(concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)')))) +31 +create table t1 as select concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)'))) as c1; +drop table t1; +select hex(concat(ST_X(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_X(ST_GeomFromText('Point(1 2)')))) +31 +create table t1 as select concat(ST_X(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Y(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_Y(ST_GeomFromText('Point(1 2)')))) +32 +create table t1 as select concat(ST_X(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Length(ST_GeomFromText('LineString(1 2,2 2)')))); +hex(concat(ST_Length(ST_GeomFromText('LineString(1 2,2 2)')))) +31 +create table t1 as select concat(ST_Length(ST_GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +hex(concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))) +31 +create table t1 as select concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_GeometryType(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_GeometryType(ST_GeomFromText('Point(1 2)')))) +504F494E54 +create table t1 as select concat(ST_GeometryType(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(15) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_AsText(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_AsText(ST_GeomFromText('Point(1 2)')))) +504F494E542831203229 +create table t1 as select concat(ST_AsText(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` longtext CHARACTER SET cp1251 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(period_add(200902, 2))); +hex(concat(period_add(200902, 2))) +323030393034 +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = ''; +select hex(concat(period_diff(200902, 200802))); +hex(concat(period_diff(200902, 200802))) +3132 +create table t1 as select concat(period_add(200902, 200802)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = default; +select hex(concat(to_days(20090224))); +hex(concat(to_days(20090224))) +373333383237 +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofmonth(20090224))); +hex(concat(dayofmonth(20090224))) +3234 +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofyear(20090224))); +hex(concat(dayofyear(20090224))) +3535 +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(hour('10:11:12'))); +hex(concat(hour('10:11:12'))) +3130 +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(minute('10:11:12'))); +hex(concat(minute('10:11:12'))) +3131 +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(second('10:11:12'))); +hex(concat(second('10:11:12'))) +3132 +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(quarter(20090224))); +hex(concat(quarter(20090224))) +31 +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(week(20090224))); +hex(concat(week(20090224))) +38 +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(yearweek(20090224))); +hex(concat(yearweek(20090224))) +323030393038 +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(year(20090224))); +hex(concat(year(20090224))) +32303039 +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(5) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(weekday(20090224))); +hex(concat(weekday(20090224))) +31 +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofweek(20090224))); +hex(concat(dayofweek(20090224))) +33 +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(unix_timestamp(20090224))); +hex(concat(unix_timestamp(20090224))) +31323335343232383030 +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(time_to_sec('10:11:12'))); +hex(concat(time_to_sec('10:11:12'))) +3336363732 +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(extract(year from 20090702))); +hex(concat(extract(year from 20090702))) +32303039 +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(5) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(microsecond('12:00:00.123456'))); +hex(concat(microsecond('12:00:00.123456'))) +313233343536 +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(month(20090224))); +hex(concat(month(20090224))) +32 +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select c1, hex(c1) from t1; +c1 hex(c1) +2003-02-28 323030332D30322D3238 +drop table t1; +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select c1, hex(c1) from t1; +c1 hex(c1) +2000-07-03 323030302D30372D3033 +drop table t1; +create table t1 as select concat(curdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(utc_date()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(curtime()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +c1 hex(c1) +2008-07-18 323030382D30372D3138 +08:42:04 30383A34323A3034 +drop table t1; +create table t1 as select concat(utc_time()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sec_to_time(2378))); +hex(concat(sec_to_time(2378))) +30303A33393A3338 +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))) +32343A30303A3030 +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(maketime(10,11,12))); +hex(concat(maketime(10,11,12))) +31303A31313A3132 +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(get_format(DATE,'USA')); +hex(get_format(DATE,'USA')) +256D2E25642E2559 +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(17) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(from_unixtime(1111885200)),4)); +hex(left(concat(from_unixtime(1111885200)),4)) +32303035 +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))) +323030332D31322D33312032303A30303A3030 +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))) +323030342D30312D30322031323A30303A3030 +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2004-01-02 12:00:00 +drop table t1; +select hex(concat(makedate(2009,1))); +hex(concat(makedate(2009,1))) +323030392D30312D3031 +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2009-01-01 +drop table t1; +create table t1 as select concat(now()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(sysdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(addtime('00:00:00','11:22:33'))); +hex(concat(addtime('00:00:00','11:22:33'))) +31313A32323A3333 +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(subtime('23:59:59','11:22:33'))); +hex(concat(subtime('23:59:59','11:22:33'))) +31323A33373A3236 +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(elt(1,2,3)); +hex(elt(1,2,3)) +32 +create table t1 as select elt(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(export_set(1,2,3,4,2)); +hex(export_set(1,2,3,4,2)) +323433 +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(127) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(insert(1133,3,0,22)); +hex(insert(1133,3,0,22)) +313132323333 +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lcase(123)); +hex(lcase(123)) +313233 +create table t1 as select lcase(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(123,1)); +hex(left(123,1)) +31 +create table t1 as select left(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lower(123)); +hex(lower(123)) +313233 +create table t1 as select lower(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lpad(1,2,0)); +hex(lpad(1,2,0)) +3031 +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(ltrim(1)); +hex(ltrim(1)) +31 +create table t1 as select ltrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(mid(1,1,1)); +hex(mid(1,1,1)) +31 +create table t1 as select mid(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(repeat(1,2)); +hex(repeat(1,2)) +3131 +create table t1 as select repeat(1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(replace(1,1,2)); +hex(replace(1,1,2)) +32 +create table t1 as select replace(1,1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(reverse(12)); +hex(reverse(12)) +3231 +create table t1 as select reverse(12) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(right(123,1)); +hex(right(123,1)) +33 +create table t1 as select right(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(rpad(1,2,0)); +hex(rpad(1,2,0)) +3130 +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(rtrim(1)); +hex(rtrim(1)) +31 +create table t1 as select rtrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(soundex(1)); +hex(soundex(1)) + +create table t1 as select soundex(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(substring(1,1,1)); +hex(substring(1,1,1)) +31 +create table t1 as select substring(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(trim(1)); +hex(trim(1)) +31 +create table t1 as select trim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(ucase(1)); +hex(ucase(1)) +31 +create table t1 as select ucase(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(upper(1)); +hex(upper(1)) +31 +create table t1 as select upper(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +a hex(a) +1.1 312E31 +2.1 322E31 +update t1 set a= a + 0.1; +select a, hex(a) from t1; +a hex(a) +1.2000000000000002 312E32303030303030303030303030303032 +2.2 322E32 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a tinyint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303031 001 +303130 010 +313030 100 +drop table t1; +create table t1 (a tinyint(4) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303031 0001 +30303130 0010 +30313030 0100 +drop table t1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E3435 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(6) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a smallint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303031 00001 +3030303130 00010 +3030313030 00100 +3031303030 01000 +3130303030 10000 +drop table t1; +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(9) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a mediumint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303031 00000001 +3030303030303130 00000010 +3030303030313030 00000100 +3030303031303030 00001000 +3030303130303030 00010000 +drop table t1; +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(11) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a int zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303031 0000000001 +30303030303030303130 0000000010 +30303030303030313030 0000000100 +30303030303031303030 0000001000 +30303030303130303030 0000010000 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(20) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a bigint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303030303030303030303030303031 00000000000000000001 +3030303030303030303030303030303030303130 00000000000000000010 +3030303030303030303030303030303030313030 00000000000000000100 +3030303030303030303030303030303031303030 00000000000000001000 +3030303030303030303030303030303130303030 00000000000000010000 +drop table t1; +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030312E31 0000000001.1 +303030303030303031302E31 0000000010.1 +303030303030303130302E31 0000000100.1 +303030303030313030302E31 0000001000.1 +303030303031303030302E31 0000010000.1 +drop table t1; +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a double zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303030303030303030303030312E31 00000000000000000001.1 +30303030303030303030303030303030303031302E31 00000000000000000010.1 +30303030303030303030303030303030303130302E31 00000000000000000100.1 +30303030303030303030303030303030313030302E31 00000000000000001000.1 +30303030303030303030303030303031303030302E31 00000000000000010000.1 +drop table t1; +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +32303031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a bit(64)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0000000000000001 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +hex(concat(a)) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +select concat(a) from t1; +concat(a) +0000-00-00 00:00:00 +2001-02-03 04:05:06 +1980-02-03 04:05:06 +2001-02-03 04:05:06 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D3033 +323030312D30322D3033 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +hex(concat(a)) +30303A30303A3031 +30313A30323A3033 +select concat(a) from t1; +concat(a) +00:00:01 +01:02:03 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a tinyint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(3) YES NULL +select hex(a) from v1; +hex(a) +303031 +303130 +313030 +drop table t1; +drop view v1; +create table t1 (a tinyint(30) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(30) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030303030303030303030303030303030303030303031 +303030303030303030303030303030303030303030303030303030303130 +303030303030303030303030303030303030303030303030303030313030 +drop table t1; +drop view v1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E3435 +drop table t1; +drop view v1; +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(6) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a smallint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(5) YES NULL +select hex(a) from v1; +hex(a) +3030303031 +3030303130 +3030313030 +3031303030 +3130303030 +drop table t1; +drop view v1; +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(9) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a mediumint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +3030303030303031 +3030303030303130 +3030303030313030 +3030303031303030 +3030303130303030 +drop table t1; +drop view v1; +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(11) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a int zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303031 +30303030303030303130 +30303030303030313030 +30303030303031303030 +30303030303130303030 +drop table t1; +drop view v1; +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a bigint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +3030303030303030303030303030303030303031 +3030303030303030303030303030303030303130 +3030303030303030303030303030303030313030 +3030303030303030303030303030303031303030 +3030303030303030303030303030303130303030 +drop table t1; +drop view v1; +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030312E31 +303030303030303031302E31 +303030303030303130302E31 +303030303030313030302E31 +303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +concat(a) +123.456 +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a double zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303030303030303030303030312E31 +30303030303030303030303030303030303031302E31 +30303030303030303030303030303030303130302E31 +30303030303030303030303030303030313030302E31 +30303030303030303030303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +32303031 +drop table t1; +drop view v1; +create table t1 (a bit(64)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(64) YES NULL +select hex(a) from v1; +hex(a) +0000000000000001 +drop table t1; +drop view v1; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) YES NULL +select hex(a) from v1; +hex(a) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D3033 +323030312D30322D3033 +drop table t1; +drop view v1; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +30303A30303A3031 +30313A30323A3033 +drop table t1; +drop view v1; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +set @a= f1(1); +select hex(@a); +hex(@a) +1 +select hex(concat(f1(1))); +hex(concat(f1(1))) +31 +create table t1 as select f1(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(11) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` decimal(18,2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(20) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` float DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(12) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(12) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +hex(@a) +323030312D30312D3032 +select hex(concat(f1(cast('2001-01-02' as date)))); +hex(concat(f1(cast('2001-01-02' as date)))) +323030312D30312D3032 +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` date DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(10) YES NULL +drop table t1; +drop view v1; +drop function f1; +# +# End of WL#2649 Number-to-string conversions +# +# +# Bug#54668 User variable assignments get wrong type +# +SET @ST_X=md5('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +cp1251 cp1251_general_ci +SET @ST_X=sha('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +cp1251 cp1251_general_ci +SET @ST_X=sha1('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +cp1251 cp1251_general_ci +SET @ST_X=ST_astext(point(1,2)); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +cp1251 cp1251_general_ci +SET @ST_X=ST_AsWKT(point(1,2)); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +cp1251 cp1251_general_ci +# +# WL#5510 Functions to_base64 and from_base64 +# +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(8) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1; +to_base64 LENGTH(to_base64) HEX(to_base64) +dGVzdA== 8 6447567A64413D3D +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2; +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64) +test 4 74657374 +DROP TABLE t2; +DROP TABLE t1; +# +# Bug#58190 BETWEEN no longer uses indexes for date or datetime fields +# +SELECT @@collation_connection; +@@collation_connection +cp1251_general_ci +CREATE TABLE t1 ( +id INT(11) DEFAULT NULL, +date_column DATE DEFAULT NULL, +KEY(date_column)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range date_column date_column 4 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`date_column` AS `date_column` from `test`.`t1` where (`test`.`t1`.`date_column` between '2010-09-01' and '2010-10-01') +ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range date_column date_column 6 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`date_column` AS `date_column` from `test`.`t1` where (`test`.`t1`.`date_column` between '2010-09-01' and '2010-10-01') +DROP TABLE t1; +# +# Bug #31384 DATE_ADD() and DATE_SUB() return binary data +# +SELECT @@collation_connection, @@character_set_results; +@@collation_connection @@character_set_results +cp1251_general_ci cp1251 +CREATE TABLE t1 AS +SELECT +DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1, +DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2, +DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date, +DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `field_str1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL, + `field1_str2` varchar(29) CHARACTER SET cp1251 DEFAULT NULL, + `field_date` date DEFAULT NULL, + `field_datetime` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SELECT +DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1, +DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2, +DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date, +DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def field_str1 254 29 10 Y 0 31 51 +def field1_str2 254 29 19 Y 0 31 51 +def field_date 10 10 10 Y 128 0 63 +def field_datetime 12 19 19 Y 128 0 63 +field_str1 field1_str2 field_date field_datetime +2007-08-02 2007-08-03 17:32:00 2007-08-02 2007-08-03 17:32:00 +SELECT +HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1, +HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2, +HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date, +HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime; +field_str1 field1_str2 field_date field_datetime +323030372D30382D30322032333A35393A3030 323030372D30382D30332031373A33323A3030 323030372D30382D3032 323030372D30382D30332031373A33323A3030 +# +# Bug#11926811 / Bug#60625 Illegal mix of collations +# +SELECT @@collation_connection; +@@collation_connection +cp1251_general_ci +CREATE PROCEDURE p1() +BEGIN +DECLARE v_LastPaymentDate DATETIME DEFAULT NULL; +SELECT v_LastPaymentDate < NOW(); +EXPLAIN SELECT v_LastPaymentDate < NOW(); +SHOW WARNINGS; +EXPLAIN SELECT CONCAT(v_LastPaymentDate, NOW()); +END// +CALL p1; +v_LastPaymentDate < NOW() +NULL +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 /* select#1 */ select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()` +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select concat(v_LastPaymentDate@0,now()) AS `CONCAT(v_LastPaymentDate, NOW())` +DROP PROCEDURE p1; +# +# Bug#52159 returning time type from function and empty left join causes debug assertion +# +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +f1() +00:00:01 +DROP FUNCTION f1; +DROP TABLE t1; +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (); +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +maketime(`a`,`a`,`a`) +00:00:00.000000 +DROP TABLE t1; +SET sql_mode=default; +# +# Bug#60101 COALESCE with cp1251 tables causes [Err] 1267 - Illegal mix of collations +# +CREATE TABLE t1 (test1 INT, test2 VARCHAR(255)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `test1` int DEFAULT NULL, + `test2` varchar(255) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT COALESCE(IF(test1=1, 1, NULL), test2) FROM t1; +COALESCE(IF(test1=1, 1, NULL), test2) +SELECT COALESCE(IF(test1=1, NULL, 1), test2) FROM t1; +COALESCE(IF(test1=1, NULL, 1), test2) +DROP TABLE t1; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +SET NAMES cp1251; +SELECT is_ipv4(inet_ntoa('1')); +is_ipv4(inet_ntoa('1')) +1 +SELECT is_ipv6(inet_ntoa('1')); +is_ipv6(inet_ntoa('1')) +0 +SELECT inet6_aton(inet_ntoa('1')); +inet6_aton(inet_ntoa('1')) + +SELECT inet6_ntoa(inet_ntoa('1')); +inet6_ntoa(inet_ntoa('1')) +NULL +# +# Bug#14040277 UNINITIALIZED VALUE REFERENCED IN STR_TO_IPV6 +# +SELECT inet6_aton(soundex('a')); +inet6_aton(soundex('a')) +NULL +# +# Bug#19047425 UNINITIALISED VALUE IN STR_TO_IPV6 +# +do is_ipv4_mapped(inet6_aton(convert(_ascii "a:" using cp1251))); +# +# End of 5.6 tests +# diff --git a/mysql-test/r/ctype_gb18030.result-pq b/mysql-test/r/ctype_gb18030.result-pq new file mode 100644 index 000000000..94a82a76a --- /dev/null +++ b/mysql-test/r/ctype_gb18030.result-pq @@ -0,0 +1,1751 @@ +SET @test_character_set= 'gb18030'; +SET @test_collation= 'gb18030_chinese_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) gb18030_chinese_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) gb18030_chinese_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=gb18030 +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET collation_connection='gb18030_chinese_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +gb18030_chinese_ci 6109 +gb18030_chinese_ci 61 +gb18030_chinese_ci 6120 +drop table t1; +create table t1 engine=innodb select repeat('a',50) as c1; +alter table t1 add index(c1(5)); +insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111'); +select collation(c1) from t1 limit 1; +collation(c1) +gb18030_chinese_ci +select c1 from t1 where c1 like 'abcdef%' order by c1; +c1 +abcdefg +select c1 from t1 where c1 like 'abcde1%' order by c1; +c1 +abcde100 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde11%' order by c1; +c1 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde111%' order by c1; +c1 +abcde111 +drop table t1; +select @@collation_connection; +@@collation_connection +gb18030_chinese_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +DROP TABLE t1; +drop table if exists t1; +create table t1 select repeat('a',10) as c1; +delete from t1; +insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F); +insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F); +insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F); +insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F); +insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F); +insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F); +SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1; +GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '') GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) + 20 +! 21 +" 22 +# 23 +$ 24 +% 25 +& 26 +' 27 +( 28 +) 29 +* 2A ++ 2B +, 2C +- 2D +. 2E +/ 2F +0 30 +1 31 +2 32 +3 33 +4 34 +5 35 +6 36 +7 37 +8 38 +9 39 +: 3A +; 3B +< 3C += 3D +> 3E +? 3F +@ 40 +Aa 41,61 +Bb 42,62 +Cc 43,63 +Dd 44,64 +Ee 45,65 +Ff 46,66 +Gg 47,67 +Hh 48,68 +Ii 49,69 +Jj 4A,6A +Kk 4B,6B +Ll 4C,6C +Mm 4D,6D +Nn 4E,6E +Oo 4F,6F +Pp 50,70 +Qq 51,71 +Rr 52,72 +Ss 53,73 +Tt 54,74 +Uu 55,75 +Vv 56,76 +Ww 57,77 +Xx 58,78 +Yy 59,79 +Zz 5A,7A +[ 5B +\ 5C +] 5D +^ 5E +_ 5F +` 60 +{ 7B +| 7C +} 7D +~ 7E + 7F +drop table t1; +SET collation_connection='gb18030_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +gb18030_bin 6109 +gb18030_bin 61 +gb18030_bin 6120 +drop table t1; +create table t1 engine=innodb select repeat('a',50) as c1; +alter table t1 add index(c1(5)); +insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111'); +select collation(c1) from t1 limit 1; +collation(c1) +gb18030_bin +select c1 from t1 where c1 like 'abcdef%' order by c1; +c1 +abcdefg +select c1 from t1 where c1 like 'abcde1%' order by c1; +c1 +abcde100 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde11%' order by c1; +c1 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde111%' order by c1; +c1 +abcde111 +drop table t1; +select @@collation_connection; +@@collation_connection +gb18030_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +DROP TABLE t1; +SELECT HEX(CONVERT(_gb18030 0xA14041 USING ucs2)); +HEX(CONVERT(_gb18030 0xA14041 USING ucs2)) +E4C60041 +SELECT HEX(CONVERT(_gb18030 0xA14041 USING utf8)); +HEX(CONVERT(_gb18030 0xA14041 USING utf8)) +EE938641 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT HEX(CONVERT(_gb18030 0xFEFEFEFD814040 USING utf32)); +HEX(CONVERT(_gb18030 0xFEFEFEFD814040 USING utf32)) +0000E4C50000E4C400004E0200000040 +SELECT HEX(CONVERT(_gb18030 0x813081304041A140 USING utf32)); +HEX(CONVERT(_gb18030 0x813081304041A140 USING utf32)) +0000008000000040000000410000E4C6 +SELECT HEX(CONVERT(_gb18030 0xE3329A34 USING utf32)); +HEX(CONVERT(_gb18030 0xE3329A34 USING utf32)) +0010FFFE +SELECT HEX(CONVERT(_gb18030 0xE3329A35 USING utf32)); +HEX(CONVERT(_gb18030 0xE3329A35 USING utf32)) +0010FFFF +SELECT HEX(CONVERT(_gb18030 0xE3329A36 USING utf32)); +HEX(CONVERT(_gb18030 0xE3329A36 USING utf32)) +0000003F +SELECT HEX(CONVERT(_gb18030 0xFE39FE39 USING utf32)); +HEX(CONVERT(_gb18030 0xFE39FE39 USING utf32)) +0000003F +SELECT HEX(CONVERT(_ucs2 0xD800 USING gb18030)); +HEX(CONVERT(_ucs2 0xD800 USING gb18030)) +3F +SELECT HEX(CONVERT(_ucs2 0xDFFF USING gb18030)); +HEX(CONVERT(_ucs2 0xDFFF USING gb18030)) +3F +SELECT HEX(CONVERT(_ucs2 0xE000 USING gb18030)); +HEX(CONVERT(_ucs2 0xE000 USING gb18030)) +AAA1 +SELECT HEX(CONVERT(_ucs2 0xF8FF USING gb18030)); +HEX(CONVERT(_ucs2 0xF8FF USING gb18030)) +84308130 +SELECT HEX(CONVERT(_gb18030 0xA13941 USING ucs2)); +ERROR HY000: Invalid gb18030 character string: 'A13941' +SELECT HEX(CONVERT(_gb18030 0xFFFE USING ucs2)); +ERROR HY000: Invalid gb18030 character string: 'FFFE' +SELECT HEX(CONVERT(_gb18030 0x81308140 USING ucs2)); +ERROR HY000: Invalid gb18030 character string: '813081' +SELECT LOCATE(_gb18030 0x8140, _gb18030 0x814181408142); +LOCATE(_gb18030 0x8140, _gb18030 0x814181408142) +2 +SELECT HEX(REVERSE(_gb18030 0x8140814181428130813081308131FE39FE39)); +HEX(REVERSE(_gb18030 0x8140814181428130813081308131FE39FE39)) +FE39FE398130813181308130814281418140 +SELECT HEX(SUBSTRING(_gb18030 0x81308131813081328130813381308134, 1, 2)); +HEX(SUBSTRING(_gb18030 0x81308131813081328130813381308134, 1, 2)) +8130813181308132 +SELECT HEX(SUBSTRING(_gb18030 0x81308131813081328130813381308134, -3, 2)); +HEX(SUBSTRING(_gb18030 0x81308131813081328130813381308134, -3, 2)) +8130813281308133 +SELECT HEX(TRIM(_gb18030 0x20202081408141208144202020)); +HEX(TRIM(_gb18030 0x20202081408141208144202020)) +81408141208144 +CREATE TABLE t1 (c1 TEXT not null, c2 TEXT not null) CHARACTER SET gb18030; +ALTER TABLE t1 CHANGE c1 c1 MEDIUMTEXT CHARACTER SET gb18030 NOT NULL; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` mediumtext CHARACTER SET gb18030 COLLATE gb18030_chinese_ci NOT NULL, + `c2` text NOT NULL +) ENGINE=default_engine DEFAULT CHARSET=gb18030 +DROP TABLE t1; +CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gb18030, +b MEDIUMTEXT CHARACTER SET big5); +INSERT INTO t1 VALUES +(REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', ''); +SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +DROP TABLES t1; +SET NAMES utf8mb4; +SET collation_connection=gb18030_chinese_ci; +select @@collation_connection; +@@collation_connection +gb18030_chinese_ci +select hex(weight_string('a')); +hex(weight_string('a')) +41 +select hex(weight_string('A')); +hex(weight_string('A')) +41 +select hex(weight_string('abc')); +hex(weight_string('abc')) +414243 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +4142 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +414243 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +4142432020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +41 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +4142 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +414220 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +41422020 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +4142202020 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +41422020202020202020202020202020202020202020202020 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +41 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +4142 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +414243 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +41424320 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +4142432020 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +41424320202020202020202020202020202020202020202020 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +41 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +4142 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +414243 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +41424320 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +4142432020 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +41424320202020202020202020202020202020202020202020 +select collation(cast(0xA1A1 as char)); +collation(cast(0xA1A1 as char)) +gb18030_chinese_ci +select hex(weight_string(cast(0x6141 as char))); +hex(weight_string(cast(0x6141 as char))) +4141 +select hex(weight_string(cast(0xA1A1 as char))); +hex(weight_string(cast(0xA1A1 as char))) +A1A1 +select hex(weight_string(cast(0xA1A1 as char) as char(1))); +hex(weight_string(cast(0xA1A1 as char) as char(1))) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1))); +hex(weight_string(cast(0xA1A1A1A1 as char) as char(1))) +A1A1 +select hex(weight_string(cast(0xA1A1 as char) as char(3))); +hex(weight_string(cast(0xA1A1 as char) as char(3))) +A1A12020 +select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0xA1A1A1A1 as char) as char(3))) +A1A1A1A120 +select hex(weight_string(cast(0x40A1A1 as char) as char(3))); +hex(weight_string(cast(0x40A1A1 as char) as char(3))) +40A1A120 +select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3))) +40A1A1A1A1 +select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3))) +40A1A1A1A1 +select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3))) +4040A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0)) +A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0)) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0)) +A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0)) +A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0)) +A1A1A1A120 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0)) +A1A1A1A1202020202020202020202020202020202020202020 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0)) +A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0)) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0)) +A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0)) +A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0)) +A1A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0)) +A1A1A1A1A1A120202020202020202020202020202020202020 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0)) +A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0)) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0)) +A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0)) +A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0)) +A1A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0)) +A1A1A1A1A1A120202020202020202020202020202020202020 +select collation(cast(0xA2A9 as char)); +collation(cast(0xA2A9 as char)) +gb18030_chinese_ci +select hex(weight_string(cast(0x6141 as char))); +hex(weight_string(cast(0x6141 as char))) +4141 +select hex(weight_string(cast(0xA2A9 as char))); +hex(weight_string(cast(0xA2A9 as char))) +A2F9 +select hex(weight_string(cast(0xA2A9 as char) as char(1))); +hex(weight_string(cast(0xA2A9 as char) as char(1))) +A2F9 +select hex(weight_string(cast(0xA2A9A2A9 as char) as char(1))); +hex(weight_string(cast(0xA2A9A2A9 as char) as char(1))) +A2F9 +select hex(weight_string(cast(0xA2A9 as char) as char(3))); +hex(weight_string(cast(0xA2A9 as char) as char(3))) +A2F92020 +select hex(weight_string(cast(0xA2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0xA2A9A2A9 as char) as char(3))) +A2F9A2F920 +select hex(weight_string(cast(0x40A2A9 as char) as char(3))); +hex(weight_string(cast(0x40A2A9 as char) as char(3))) +40A2F920 +select hex(weight_string(cast(0x40A2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0x40A2A9A2A9 as char) as char(3))) +40A2F9A2F9 +select hex(weight_string(cast(0x40A2A9A2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0x40A2A9A2A9A2A9 as char) as char(3))) +40A2F9A2F9 +select hex(weight_string(cast(0x4040A2A9A2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0x4040A2A9A2A9A2A9 as char) as char(3))) +4040A2F9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 2, 0xC0)) +A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 2, 0xC0)) +A2F9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 2, 0xC0)) +A2F9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 2, 0xC0)) +A2F9A2F9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 2, 0xC0)) +A2F9A2F920 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 2, 0xC0)) +A2F9A2F9202020202020202020202020202020202020202020 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 3, 0xC0)) +A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 3, 0xC0)) +A2F9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 3, 0xC0)) +A2F9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 3, 0xC0)) +A2F9A2F9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 3, 0xC0)) +A2F9A2F9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 3, 0xC0)) +A2F9A2F9A2F920202020202020202020202020202020202020 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 4, 0xC0)) +A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 4, 0xC0)) +A2F9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 4, 0xC0)) +A2F9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 4, 0xC0)) +A2F9A2F9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 4, 0xC0)) +A2F9A2F9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 4, 0xC0)) +A2F9A2F9A2F920202020202020202020202020202020202020 +SELECT collation(CAST(0x81309D30 AS CHAR)); +collation(CAST(0x81309D30 AS CHAR)) +gb18030_chinese_ci +SELECT HEX(WEIGHT_STRING(CAST(0x6141 AS CHAR))); +HEX(WEIGHT_STRING(CAST(0x6141 AS CHAR))) +4141 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR))); +HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR))) +FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(1))); +HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(1))) +FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(1))); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(1))) +FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(3))) +FF0001172020 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(3))) +FF000117FF00011720 +SELECT HEX(WEIGHT_STRING(CAST(0x4081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x4081309D30 AS CHAR) AS CHAR(3))) +40FF00011720 +SELECT HEX(WEIGHT_STRING(CAST(0x4081309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x4081309D3081309D30 AS CHAR) AS CHAR(3))) +40FF000117FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x4081309D3081309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x4081309D3081309D3081309D30 AS CHAR) AS CHAR(3))) +40FF000117FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x404081309D3081309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x404081309D3081309D3081309D30 AS CHAR) AS CHAR(3))) +4040FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 2, 0xC0)) +FF +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 2, 0xC0)) +FF00 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 2, 0xC0)) +FF0001 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 2, 0xC0)) +FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 2, 0xC0)) +FF000117FF +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 2, 0xC0)) +FF000117FF0001172020202020202020202020202020202020 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 3, 0xC0)) +FF +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 3, 0xC0)) +FF00 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 3, 0xC0)) +FF0001 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 3, 0xC0)) +FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 3, 0xC0)) +FF000117FF +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 3, 0xC0)) +FF000117FF000117FF00011720202020202020202020202020 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 4, 0xC0)) +FF +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 4, 0xC0)) +FF00 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 4, 0xC0)) +FF0001 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 4, 0xC0)) +FF000117 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 4, 0xC0)) +FF000117FF +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 4, 0xC0)) +FF000117FF000117FF00011720202020202020202020202020 +SET collation_connection=gb18030_bin; +select @@collation_connection; +@@collation_connection +gb18030_bin +select hex(weight_string('a')); +hex(weight_string('a')) +61 +select hex(weight_string('A')); +hex(weight_string('A')) +41 +select hex(weight_string('abc')); +hex(weight_string('abc')) +616263 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +6162 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +616263 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +6162632020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +61 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +6162 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +616220 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +61622020 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +6162202020 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +61622020202020202020202020202020202020202020202020 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +61 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +6162 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +616263 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +61626320 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +6162632020 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +61626320202020202020202020202020202020202020202020 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +61 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +6162 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +616263 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +61626320 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +6162632020 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +61626320202020202020202020202020202020202020202020 +select collation(cast(0xA1A1 as char)); +collation(cast(0xA1A1 as char)) +gb18030_bin +select hex(weight_string(cast(0x6141 as char))); +hex(weight_string(cast(0x6141 as char))) +6141 +select hex(weight_string(cast(0xA1A1 as char))); +hex(weight_string(cast(0xA1A1 as char))) +A1A1 +select hex(weight_string(cast(0xA1A1 as char) as char(1))); +hex(weight_string(cast(0xA1A1 as char) as char(1))) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1))); +hex(weight_string(cast(0xA1A1A1A1 as char) as char(1))) +A1A1 +select hex(weight_string(cast(0xA1A1 as char) as char(3))); +hex(weight_string(cast(0xA1A1 as char) as char(3))) +A1A12020 +select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0xA1A1A1A1 as char) as char(3))) +A1A1A1A120 +select hex(weight_string(cast(0x40A1A1 as char) as char(3))); +hex(weight_string(cast(0x40A1A1 as char) as char(3))) +40A1A120 +select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3))) +40A1A1A1A1 +select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3))) +40A1A1A1A1 +select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3))); +hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3))) +4040A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0)) +A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0)) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0)) +A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0)) +A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0)) +A1A1A1A120 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0)) +A1A1A1A1202020202020202020202020202020202020202020 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0)) +A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0)) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0)) +A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0)) +A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0)) +A1A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0)) +A1A1A1A1A1A120202020202020202020202020202020202020 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0)) +A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0)) +A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0)) +A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0)) +A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0)) +A1A1A1A1A1 +select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0)); +hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0)) +A1A1A1A1A1A120202020202020202020202020202020202020 +select collation(cast(0xA2A9 as char)); +collation(cast(0xA2A9 as char)) +gb18030_bin +select hex(weight_string(cast(0x6141 as char))); +hex(weight_string(cast(0x6141 as char))) +6141 +select hex(weight_string(cast(0xA2A9 as char))); +hex(weight_string(cast(0xA2A9 as char))) +A2A9 +select hex(weight_string(cast(0xA2A9 as char) as char(1))); +hex(weight_string(cast(0xA2A9 as char) as char(1))) +A2A9 +select hex(weight_string(cast(0xA2A9A2A9 as char) as char(1))); +hex(weight_string(cast(0xA2A9A2A9 as char) as char(1))) +A2A9 +select hex(weight_string(cast(0xA2A9 as char) as char(3))); +hex(weight_string(cast(0xA2A9 as char) as char(3))) +A2A92020 +select hex(weight_string(cast(0xA2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0xA2A9A2A9 as char) as char(3))) +A2A9A2A920 +select hex(weight_string(cast(0x40A2A9 as char) as char(3))); +hex(weight_string(cast(0x40A2A9 as char) as char(3))) +40A2A920 +select hex(weight_string(cast(0x40A2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0x40A2A9A2A9 as char) as char(3))) +40A2A9A2A9 +select hex(weight_string(cast(0x40A2A9A2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0x40A2A9A2A9A2A9 as char) as char(3))) +40A2A9A2A9 +select hex(weight_string(cast(0x4040A2A9A2A9A2A9 as char) as char(3))); +hex(weight_string(cast(0x4040A2A9A2A9A2A9 as char) as char(3))) +4040A2A9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 2, 0xC0)) +A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 2, 0xC0)) +A2A9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 2, 0xC0)) +A2A9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 2, 0xC0)) +A2A9A2A9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 2, 0xC0)) +A2A9A2A920 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 2, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 2, 0xC0)) +A2A9A2A9202020202020202020202020202020202020202020 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 3, 0xC0)) +A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 3, 0xC0)) +A2A9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 3, 0xC0)) +A2A9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 3, 0xC0)) +A2A9A2A9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 3, 0xC0)) +A2A9A2A9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 3, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 3, 0xC0)) +A2A9A2A9A2A920202020202020202020202020202020202020 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 1, 4, 0xC0)) +A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 2, 4, 0xC0)) +A2A9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 3, 4, 0xC0)) +A2A9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 4, 4, 0xC0)) +A2A9A2A9 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char), 5, 4, 0xC0)) +A2A9A2A9A2 +select hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 4, 0xC0)); +hex(weight_string(cast(0xA2A9A2A9A2A9 as char),25, 4, 0xC0)) +A2A9A2A9A2A920202020202020202020202020202020202020 +SELECT collation(CAST(0x81309D30 AS CHAR)); +collation(CAST(0x81309D30 AS CHAR)) +gb18030_bin +SELECT HEX(WEIGHT_STRING(CAST(0x6141 AS CHAR))); +HEX(WEIGHT_STRING(CAST(0x6141 AS CHAR))) +6141 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR))); +HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR))) +81309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(1))); +HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(1))) +81309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(1))); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(1))) +81309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x81309D30 AS CHAR) AS CHAR(3))) +81309D302020 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D30 AS CHAR) AS CHAR(3))) +81309D3081309D3020 +SELECT HEX(WEIGHT_STRING(CAST(0x4081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x4081309D30 AS CHAR) AS CHAR(3))) +4081309D3020 +SELECT HEX(WEIGHT_STRING(CAST(0x4081309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x4081309D3081309D30 AS CHAR) AS CHAR(3))) +4081309D3081309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x4081309D3081309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x4081309D3081309D3081309D30 AS CHAR) AS CHAR(3))) +4081309D3081309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x404081309D3081309D3081309D30 AS CHAR) AS CHAR(3))); +HEX(WEIGHT_STRING(CAST(0x404081309D3081309D3081309D30 AS CHAR) AS CHAR(3))) +404081309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 2, 0xC0)) +81 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 2, 0xC0)) +8130 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 2, 0xC0)) +81309D +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 2, 0xC0)) +81309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 2, 0xC0)) +81309D3081 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 2, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 2, 0xC0)) +81309D3081309D302020202020202020202020202020202020 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 3, 0xC0)) +81 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 3, 0xC0)) +8130 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 3, 0xC0)) +81309D +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 3, 0xC0)) +81309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 3, 0xC0)) +81309D3081 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 3, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 3, 0xC0)) +81309D3081309D3081309D3020202020202020202020202020 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 1, 4, 0xC0)) +81 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 2, 4, 0xC0)) +8130 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 3, 4, 0xC0)) +81309D +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 4, 4, 0xC0)) +81309D30 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 5, 4, 0xC0)) +81309D3081 +SELECT HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 4, 0xC0)); +HEX(WEIGHT_STRING(CAST(0x81309D3081309D3081309D30 AS CHAR), 25, 4, 0xC0)) +81309D3081309D3081309D3020202020202020202020202020 +# +# Bugs#12635232: VALGRIND WARNINGS: IS_IPV6, IS_IPV4, INET6_ATON, +# INETTO_NTOA + MULTIBYTE CHARSET. +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SELECT is_ipv4(inet_ntoa('1')); +is_ipv4(inet_ntoa('1')) +1 +SELECT is_ipv6(inet_ntoa('1')); +is_ipv6(inet_ntoa('1')) +0 +SELECT inet6_aton(inet_ntoa('1')); +inet6_aton(inet_ntoa('1')) + +SELECT inet6_ntoa(inet_ntoa('1')); +inet6_ntoa(inet_ntoa('1')) +NULL +# +# Bug#14040277 UNINITIALIZED VALUE REFERENCED IN STR_TO_IPV6 +# +SELECT inet6_aton(soundex('a')); +inet6_aton(soundex('a')) +NULL +# +# Bug#19047425 UNINITIALISED VALUE IN STR_TO_IPV6 +# +do is_ipv4_mapped(inet6_aton(convert(_ascii "a:" using utf8mb4))); +# +# Test for gb18030_unicode_520_ci collation. +# +SET NAMES utf8mb4; +SET collation_connection=gb18030_unicode_520_ci; +CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) CHARACTER SET gb18030 COLLATE gb18030_unicode_520_ci NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A); +INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C); +INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E); +INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242); +INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244); +INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246); +INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248); +INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A); +INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C); +INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E); +INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B); +INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289); +INSERT INTO t1 VALUES (_utf32 0x028C); +INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C); +INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD); +INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF); +INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF); +INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7); +INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB); +INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD); +INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF); +INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511); +INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513); +INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1); +INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3); +INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5); +INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7); +INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01); +INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03); +INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05); +INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07); +INSERT INTO t1 VALUES (_utf32 0x1D7D); +INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E); +INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184); +INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81); +INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83); +INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85); +INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87); +INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89); +INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B); +INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D); +INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F); +INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61); +INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63); +INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65); +INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67); +INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69); +INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B); +INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75); +INSERT INTO t1 VALUES (_utf32 0x2C76); +INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01); +INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03); +INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05); +INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07); +INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31); +INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33); +INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35); +INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37); +INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401); +INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403); +INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405); +INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407); +INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429); +INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B); +INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D); +INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F); +INSERT INTO t1 VALUES (_utf32 0x0370); +INSERT INTO t1 VALUES (_utf32 0x0371); +INSERT INTO t1 VALUES (_utf32 0x0372); +INSERT INTO t1 VALUES (_utf32 0x0373); +INSERT INTO t1 VALUES (_utf32 0x0514); +INSERT INTO t1 VALUES (_utf32 0x0515); +INSERT INTO t1 VALUES (_utf32 0x0516); +INSERT INTO t1 VALUES (_utf32 0x0517); +INSERT INTO t1 VALUES (_utf32 0xA640); +INSERT INTO t1 VALUES (_utf32 0xA641); +INSERT INTO t1 VALUES (_utf32 0xA642); +INSERT INTO t1 VALUES (_utf32 0xA643); +INSERT INTO t1 VALUES (_utf32 0xA722); +INSERT INTO t1 VALUES (_utf32 0xA723); +INSERT INTO t1 VALUES (_utf32 0xA724); +INSERT INTO t1 VALUES (_utf32 0xA725); +INSERT INTO t1 VALUES (_utf32 0xA726); +INSERT INTO t1 VALUES (_utf32 0xA727); +INSERT INTO t1 VALUES (_utf32 0xA728); +INSERT INTO t1 VALUES (_utf32 0xA729); +INSERT INTO t1 VALUES (_utf32 0xA72A); +INSERT INTO t1 VALUES (_utf32 0xA72B); +INSERT INTO t1 VALUES (_utf32 0x2CEB); +INSERT INTO t1 VALUES (_utf32 0x2CEC); +INSERT INTO t1 VALUES (_utf32 0x2CED); +INSERT INTO t1 VALUES (_utf32 0x2CEE); +SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c +FROM t1 ORDER BY c, BINARY c; +hex(c) hex(lower(c)) hex(upper(c)) hex(weight_string(c)) c +8130A935 8138C739 8130A935 1214 Ⱥ +8138C739 8138C739 8130A935 1214 ⱥ +81309738 81309738 8130AA34 122D ƀ +8130AA34 81309738 8130AA34 122D Ƀ +8130A936 8130A937 8130A936 1242 Ȼ +8130A937 8130A937 8130A936 1242 ȼ +8136C539 8136C630 8136C539 124E Ↄ +8136C630 8136C630 8136C539 124E ↄ +8130AA37 8130AA38 8130AA37 1270 Ɇ +8130AA38 8130AA38 8130AA37 1270 ɇ +8136C030 8136C238 8136C030 12AE Ⅎ +8136C238 8136C238 8136C030 12AE ⅎ +8138C831 8138C832 8138C831 12E3 Ⱨ +8138C832 8138C832 8138C831 12E3 ⱨ +8138C935 8138C936 8138C935 12E4 Ⱶ +8138C936 8138C936 8138C935 12E4 ⱶ +8236D133 8236D134 8236D133 12E5 Ꜧ +8236D134 8236D134 8236D133 12E5 ꜧ +8130AA39 8130AB30 8130AA39 130E Ɉ +8130AB30 8130AB30 8130AA39 130E ɉ +8138C833 8138C834 8138C833 1328 Ⱪ +8138C834 8138C834 8138C833 1328 ⱪ +8130A938 81309A34 8130A938 133B Ƚ +8138C734 8138C735 8138C734 133F Ⱡ +8138C735 8138C735 8138C734 133F ⱡ +8130AE32 8130AE32 8138C736 1340 ɫ +8138C736 8130AE32 8138C736 1340 Ɫ +8135E133 8135E133 8138C737 13B8 ᵽ +8138C737 8135E133 8138C737 13B8 Ᵽ +8130AB31 8130AB32 8130AB31 13D2 Ɋ +8130AB32 8130AB32 8130AB31 13D2 ɋ +8130AB33 8130AB34 8130AB33 13E4 Ɍ +8130AB34 8130AB34 8130AB33 13E4 ɍ +8130B030 8130B030 8138C738 13FC ɽ +8138C738 8130B030 8138C738 13FC Ɽ +8236D135 8236D136 8236D135 143314AD Ꜩ +8236D136 8236D136 8236D135 143314AD ꜩ +8130A939 8138C830 8130A939 143C Ⱦ +8138C830 8138C830 8130A939 143C ⱦ +8130AA35 8130B132 8130AA35 145B Ʉ +8130B132 8130B132 8130AA35 145B ʉ +8130AA36 8130B135 8130AA36 1489 Ʌ +8130B135 8130B135 8130AA36 1489 ʌ +8130AB35 8130AB36 8130AB35 14A4 Ɏ +8130AB36 8130AB36 8130AB35 14A4 ɏ +8138C835 8138C836 8138C835 14C8 Ⱬ +8138C836 8138C836 8138C835 14C8 ⱬ +8236D137 8236D138 8236D137 14F3 Ꜫ +8236D138 8236D138 8236D137 14F3 ꜫ +8130AA32 8130AA33 8130AA32 1506 Ɂ +8130AA33 8130AA33 8130AA32 1506 ɂ +8236D039 8236D130 8236D039 150E Ꜣ +8236D130 8236D130 8236D039 150E ꜣ +8236D131 8236D132 8236D131 1518 Ꜥ +8236D132 8236D132 8236D131 1518 ꜥ +8130C738 8130C739 8130C738 154F Ͱ +8130C739 8130C739 8130C738 154F ͱ +8130C930 8130C930 8130D132 1564 ͼ +8130D132 8130C930 8130D132 1564 Ͼ +8130C839 8130C839 8130D131 1565 ͻ +8130D131 8130C839 8130D131 1565 Ͻ +8130C931 8130C931 8130D133 1566 ͽ +8130D133 8130C931 8130D133 1566 Ͽ +8130C830 8130C831 8130C830 156F Ͳ +8130C831 8130C831 8130C830 156F ͳ +8138CA36 8138CA37 8138CA36 1571 Ⲁ +8138CA37 8138CA37 8138CA36 1571 ⲁ +8138CA38 8138CA39 8138CA38 1572 Ⲃ +8138CA39 8138CA39 8138CA38 1572 ⲃ +8138CB30 8138CB31 8138CB30 1573 Ⲅ +8138CB31 8138CB31 8138CB30 1573 ⲅ +8138CB32 8138CB33 8138CB32 1574 Ⲇ +8138CB33 8138CB33 8138CB32 1574 ⲇ +8138CB34 8138CB35 8138CB34 1575 Ⲉ +8138CB35 8138CB35 8138CB34 1575 ⲉ +8138CB36 8138CB37 8138CB36 1577 Ⲋ +8138CB37 8138CB37 8138CB36 1577 ⲋ +8138CB38 8138CB39 8138CB38 1578 Ⲍ +8138CB39 8138CB39 8138CB38 1578 ⲍ +8138CC30 8138CC31 8138CC30 1579 Ⲏ +8138CC31 8138CC31 8138CC30 1579 ⲏ +8138D533 8138D534 8138D533 1591 Ⳬ +8138D534 8138D534 8138D533 1591 ⳬ +8138D535 8138D536 8138D535 15A0 Ⳮ +8138D536 8138D536 8138D535 15A0 ⳮ +8130E338 8130E339 8130E338 15D4 Ӻ +8130E339 8130E339 8130E338 15D4 ӻ +8130E334 8130E335 8130E334 15DC Ӷ +8130E335 8130E335 8130E334 15DC ӷ +8236BA33 8236BA34 8236BA33 1611 Ꙁ +8236BA34 8236BA34 8236BA33 1611 ꙁ +8130E630 8130E631 8130E630 1613 Ԑ +8130E631 8130E631 8130E630 1613 ԑ +8236BA35 8236BA36 8236BA35 1618 Ꙃ +8236BA36 8236BA36 8236BA35 1618 ꙃ +8130E632 8130E633 8130E632 1666 Ԓ +8130E633 8130E633 8130E632 1666 ԓ +8130E634 8130E635 8130E634 166E Ԕ +8130E635 8130E635 8130E634 166E ԕ +8130E636 8130E637 8130E636 16B7 Ԗ +8130E637 8130E637 8130E636 16B7 ԗ +8130E430 8130E431 8130E430 16F9 Ӽ +8130E431 8130E431 8130E430 16F9 ӽ +8130E432 8130E433 8130E432 16FD Ӿ +8130E433 8130E433 8130E432 16FD ӿ +8130DE30 8130DF35 8130DE30 17B1 Ӏ +8130DF35 8130DF35 8130DE30 17B1 ӏ +8138BD38 8138C236 8138BD38 17B5 Ⰰ +8138C236 8138C236 8138BD38 17B5 ⰰ +8138BD39 8138C237 8138BD39 17B6 Ⰱ +8138C237 8138C237 8138BD39 17B6 ⰱ +8138BE30 8138C238 8138BE30 17B7 Ⰲ +8138C238 8138C238 8138BE30 17B7 ⰲ +8138BE31 8138C239 8138BE31 17B8 Ⰳ +8138C239 8138C239 8138BE31 17B8 ⰳ +8138BE32 8138C330 8138BE32 17B9 Ⰴ +8138C330 8138C330 8138BE32 17B9 ⰴ +8138BE33 8138C331 8138BE33 17BA Ⰵ +8138C331 8138C331 8138BE33 17BA ⰵ +8138BE34 8138C332 8138BE34 17BB Ⰶ +8138C332 8138C332 8138BE34 17BB ⰶ +8138BE35 8138C333 8138BE35 17BC Ⰷ +8138C333 8138C333 8138BE35 17BC ⰷ +81339430 8138D734 81339430 17E5 Ⴀ +8138D734 8138D734 81339430 17E5 ⴀ +81339431 8138D735 81339431 17E7 Ⴁ +8138D735 8138D735 81339431 17E7 ⴁ +81339432 8138D736 81339432 17E9 Ⴂ +8138D736 8138D736 81339432 17E9 ⴂ +81339433 8138D737 81339433 17EB Ⴃ +8138D737 8138D737 81339433 17EB ⴃ +81339434 8138D738 81339434 17ED Ⴄ +8138D738 8138D738 81339434 17ED ⴄ +81339435 8138D739 81339435 17EF Ⴅ +8138D739 8138D739 81339435 17EF ⴅ +81339436 8138D830 81339436 17F1 Ⴆ +8138D830 8138D830 81339436 17F1 ⴆ +81339437 8138D831 81339437 17F5 Ⴇ +8138D831 8138D831 81339437 17F5 ⴇ +9030E734 8130D239 8130D134 30D2 𐐀 +9030EB34 A7EA A7BA 30D2 𐐨 +9030E735 A7D7 A7A7 30D3 𐐁 +9030EB35 A7EB A7BB 30D3 𐐩 +9030E736 8130D330 8130D135 30D4 𐐂 +9030EB36 A7EC A7BC 30D4 𐐪 +9030E737 8130D331 8130D136 30D5 𐐃 +9030EB37 A7ED A7BD 30D5 𐐫 +9030E738 8130D332 8130D137 30D6 𐐄 +9030EB38 A7EE A7BE 30D6 𐐬 +9030E739 8130D333 8130D138 30D7 𐐅 +9030EB39 A7EF A7BF 30D7 𐐭 +9030E830 8130D334 8130D139 30D8 𐐆 +9030EC30 A7F0 A7C0 30D8 𐐮 +9030E831 8130D335 8130D230 30D9 𐐇 +9030EC31 A7F1 A7C1 30D9 𐐯 +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400)); +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 120F +619030E734 120F30D2 +618431A439 120FFBC1FFFF +61E3329A35 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +9030E734 30D2 𐐀 +9030EB34 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +9030E734 30D2 𐐀 +9030EB34 30D2 𐐨 +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 42 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`c`) AS `hex(c)` from `test`.`t1` where (`test`.`t1`.`c` like 'a%') order by `test`.`t1`.`c` +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 120F +619030E734 120F30D2 +618431A439 120FFBC1FFFF +61E3329A35 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +9030E734 30D2 𐐀 +9030EB34 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +9030E734 30D2 𐐀 +9030EB34 30D2 𐐨 +DROP TABLE t1; +SET NAMES gb18030 COLLATE gb18030_unicode_520_ci; +SELECT 1 gb18030_unicode_520_ci; +gb18030_unicode_520_ci +1 +CREATE DATABASE gb18030 CHARSET=GB18030; +SET NAMES utf8mb4; +SET collation_connection='gb18030_chinese_ci'; +CREATE TABLE t1(C VARCHAR(100) CHARACTER SET gb18030, KEY(c(20))); +INSERT INTO t1 VALUES(0xC4EEC5ABBDBFA1A4B3E0B1DABBB3B9C520A1A4CBD5B6ABC6C2); +INSERT INTO t1 VALUES(0xB4F3BDADB6ABC8A5A3ACC0CBCCD4BEA1A1A2C7A7B9C5B7E7C1F7C8CBCEEFA1A3); +INSERT INTO t1 VALUES(0xB9CAC0DDCEF7B1DFA3ACC8CBB5C0CAC7A1A2C8FDB9FAD6DCC0C9B3E0B1DAA1A3); +INSERT INTO t1 VALUES(0xC2D2CAAFB1C0D4C6A3ACBEAACCCEC1D1B0B6A3ACBEEDC6F0C7A7B6D1D1A9A1A3); +INSERT INTO t1 VALUES(0xBDADC9BDC8E7BBADA3ACD2BBCAB1B6E0C9D9BAC0BDDCA3A1); +INSERT INTO t1 VALUES(0xD2A3CFEBB9ABE8AAB5B1C4EAA3ACD0A1C7C7B3F5BCDEC1CBA3ACD0DBD7CBD3A2B7A2A1A3); +INSERT INTO t1 VALUES(0xD3F0C9C8C2DABDEDA3ACCCB8D0A6BCE4A1A2E9C9E9D6BBD2B7C9D1CCC3F0A1A3); +INSERT INTO t1 VALUES(0xB9CAB9FAC9F1D3CEA3ACB6E0C7E9D3A6D0A6CED2A1A2D4E7C9FABBAAB7A2A1A3); +INSERT INTO t1 VALUES(0xC8CBBCE4C8E7C3CEA3ACD2BBE9D7BBB9F5AABDADD4C2A1A3); +SELECT c, HEX(c), CONVERT(c USING utf8mb4) FROM t1; +c HEX(c) CONVERT(c USING utf8mb4) +念奴娇·赤壁怀古 ·苏东坡 C4EEC5ABBDBFA1A4B3E0B1DABBB3B9C520A1A4CBD5B6ABC6C2 念奴娇·赤壁怀古 ·苏东坡 +大江东去,浪淘尽、千古风流人物。 B4F3BDADB6ABC8A5A3ACC0CBCCD4BEA1A1A2C7A7B9C5B7E7C1F7C8CBCEEFA1A3 大江东去,浪淘尽、千古风流人物。 +故垒西边,人道是、三国周郎赤壁。 B9CAC0DDCEF7B1DFA3ACC8CBB5C0CAC7A1A2C8FDB9FAD6DCC0C9B3E0B1DAA1A3 故垒西边,人道是、三国周郎赤壁。 +乱石崩云,惊涛裂岸,卷起千堆雪。 C2D2CAAFB1C0D4C6A3ACBEAACCCEC1D1B0B6A3ACBEEDC6F0C7A7B6D1D1A9A1A3 乱石崩云,惊涛裂岸,卷起千堆雪。 +江山如画,一时多少豪杰! BDADC9BDC8E7BBADA3ACD2BBCAB1B6E0C9D9BAC0BDDCA3A1 江山如画,一时多少豪杰! +遥想公瑾当年,小乔初嫁了,雄姿英发。 D2A3CFEBB9ABE8AAB5B1C4EAA3ACD0A1C7C7B3F5BCDEC1CBA3ACD0DBD7CBD3A2B7A2A1A3 遥想公瑾当年,小乔初嫁了,雄姿英发。 +羽扇纶巾,谈笑间、樯橹灰飞烟灭。 D3F0C9C8C2DABDEDA3ACCCB8D0A6BCE4A1A2E9C9E9D6BBD2B7C9D1CCC3F0A1A3 羽扇纶巾,谈笑间、樯橹灰飞烟灭。 +故国神游,多情应笑我、早生华发。 B9CAB9FAC9F1D3CEA3ACB6E0C7E9D3A6D0A6CED2A1A2D4E7C9FABBAAB7A2A1A3 故国神游,多情应笑我、早生华发。 +人间如梦,一樽还酹江月。 C8CBBCE4C8E7C3CEA3ACD2BBE9D7BBB9F5AABDADD4C2A1A3 人间如梦,一樽还酹江月。 +SELECT HEX(c), CONVERT(c USING utf8mb4) FROM t1 ORDER BY c; +HEX(c) CONVERT(c USING utf8mb4) +B4F3BDADB6ABC8A5A3ACC0CBCCD4BEA1A1A2C7A7B9C5B7E7C1F7C8CBCEEFA1A3 大江东去,浪淘尽、千古风流人物。 +B9CAB9FAC9F1D3CEA3ACB6E0C7E9D3A6D0A6CED2A1A2D4E7C9FABBAAB7A2A1A3 故国神游,多情应笑我、早生华发。 +B9CAC0DDCEF7B1DFA3ACC8CBB5C0CAC7A1A2C8FDB9FAD6DCC0C9B3E0B1DAA1A3 故垒西边,人道是、三国周郎赤壁。 +BDADC9BDC8E7BBADA3ACD2BBCAB1B6E0C9D9BAC0BDDCA3A1 江山如画,一时多少豪杰! +C2D2CAAFB1C0D4C6A3ACBEAACCCEC1D1B0B6A3ACBEEDC6F0C7A7B6D1D1A9A1A3 乱石崩云,惊涛裂岸,卷起千堆雪。 +C4EEC5ABBDBFA1A4B3E0B1DABBB3B9C520A1A4CBD5B6ABC6C2 念奴娇·赤壁怀古 ·苏东坡 +C8CBBCE4C8E7C3CEA3ACD2BBE9D7BBB9F5AABDADD4C2A1A3 人间如梦,一樽还酹江月。 +D2A3CFEBB9ABE8AAB5B1C4EAA3ACD0A1C7C7B3F5BCDEC1CBA3ACD0DBD7CBD3A2B7A2A1A3 遥想公瑾当年,小乔初嫁了,雄姿英发。 +D3F0C9C8C2DABDEDA3ACCCB8D0A6BCE4A1A2E9C9E9D6BBD2B7C9D1CCC3F0A1A3 羽扇纶巾,谈笑间、樯橹灰飞烟灭。 +SELECT HEX(c), CONVERT(c USING utf8mb4) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0xD2BB, '%'); +HEX(c) CONVERT(c USING utf8mb4) +BDADC9BDC8E7BBADA3ACD2BBCAB1B6E0C9D9BAC0BDDCA3A1 江山如画,一时多少豪杰! +C8CBBCE4C8E7C3CEA3ACD2BBE9D7BBB9F5AABDADD4C2A1A3 人间如梦,一樽还酹江月。 +SELECT HEX(c), CONVERT(c USING utf8mb4) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0xC8CB, '%'); +HEX(c) CONVERT(c USING utf8mb4) +B4F3BDADB6ABC8A5A3ACC0CBCCD4BEA1A1A2C7A7B9C5B7E7C1F7C8CBCEEFA1A3 大江东去,浪淘尽、千古风流人物。 +B9CAC0DDCEF7B1DFA3ACC8CBB5C0CAC7A1A2C8FDB9FAD6DCC0C9B3E0B1DAA1A3 故垒西边,人道是、三国周郎赤壁。 +C8CBBCE4C8E7C3CEA3ACD2BBE9D7BBB9F5AABDADD4C2A1A3 人间如梦,一樽还酹江月。 +SELECT HEX(c), CONVERT(c USING utf8mb4) FROM t1 WHERE c > 0xD2A3; +HEX(c) CONVERT(c USING utf8mb4) +D2A3CFEBB9ABE8AAB5B1C4EAA3ACD0A1C7C7B3F5BCDEC1CBA3ACD0DBD7CBD3A2B7A2A1A3 遥想公瑾当年,小乔初嫁了,雄姿英发。 +D3F0C9C8C2DABDEDA3ACCCB8D0A6BCE4A1A2E9C9E9D6BBD2B7C9D1CCC3F0A1A3 羽扇纶巾,谈笑间、樯橹灰飞烟灭。 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES(0x5373547483329330); +INSERT INTO t1 VALUES(0x8239AB318239AB358239AF3583308132833087348335EB39); +INSERT INTO t1 VALUES(0x97339631973396339733A6359831C0359831C536); +INSERT INTO t1 VALUES(0x9835CF329835CE359835F336); +INSERT INTO t1 VALUES(0x833988318339883283398539); +INSERT INTO t1 VALUES(0x823398318233973582339A3882348A32); +INSERT INTO t1 VALUES(0x8134D5318134D6328134D832); +INSERT INTO t1 VALUES(0x4A7320204B82339A35646566); +INSERT INTO t1 VALUES(0x8130883281308833); +INSERT INTO t1 VALUES(0xE05FE06A777682339230); +INSERT INTO t1 VALUES(0x814081418139FE30); +INSERT INTO t1 VALUES(0x81308130FEFE); +INSERT INTO t1 VALUES(0xE3329A35E3329A34); +INSERT INTO t1 VALUES(0xFE39FE39FE38FE38); +INSERT INTO t1 VALUES(0xFE39FE38A976); +SELECT c, HEX(c), CONVERT(c USING utf8mb4) FROM t1; +c HEX(c) CONVERT(c USING utf8mb4) +SsTt숿 5373547483329330 SsTt숿 +둬둰뒘략럳푼 8239AB318239AB358239AF3583308132833087348335EB39 둬둰뒘략럳푼 +𦠟𦠡𦣃𩄧𩅚 97339631973396339733A6359831C0359831C536 𦠟𦠡𦣃𩄧𩅚 +𪕪𪕣𪛖 9835CF329835CE359835F336 𪕪𪕣𪛖 + 833988318339883283398539  +䑠䑚䑻䣈 823398318233973582339A3882348A32 䑠䑚䑻䣈 +᠗ᠢᠶ 8134D5318134D6328134D832 ᠗ᠢᠶ +Js K䑸def 4A7320204B82339A35646566 Js K䑸def +ÎÏ 8130883281308833 ÎÏ +郷鄇wv䐣 E05FE06A777682339230 郷鄇wv䐣 +丂丄㒙 814081418139FE30 丂丄㒙 +€ 81308130FEFE € +􏿿􏿾 E3329A35E3329A34 􏿿􏿾 +?? FE39FE39FE38FE38 ?? +?﹙ FE39FE38A976 ?﹙ +SELECT c, HEX(c), CONVERT(c USING utf8mb4) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0x9835CE35, '%'); +c HEX(c) CONVERT(c USING utf8mb4) +𪕪𪕣𪛖 9835CF329835CE359835F336 𪕪𪕣𪛖 +SELECT c, HEX(c), CONVERT(c USING utf8mb4) FROM t1 WHERE c = 0x8130883281308833; +c HEX(c) CONVERT(c USING utf8mb4) +ÎÏ 8130883281308833 ÎÏ +SELECT c, HEX(c), CONVERT(c USING utf8mb4) FROM t1 WHERE c > 0xE040 AND c < 0x8239AB31; +c HEX(c) CONVERT(c USING utf8mb4) +SELECT c, HEX(c), CONVERT(c USING utf8mb4) FROM t1 ORDER BY c; +c HEX(c) CONVERT(c USING utf8mb4) +Js K䑸def 4A7320204B82339A35646566 Js K䑸def +SsTt숿 5373547483329330 SsTt숿 +€ 81308130FEFE € +ÎÏ 8130883281308833 ÎÏ +᠗ᠢᠶ 8134D5318134D6328134D832 ᠗ᠢᠶ +둬둰뒘략럳푼 8239AB318239AB358239AF3583308132833087348335EB39 둬둰뒘략럳푼 + 833988318339883283398539  +𪕪𪕣𪛖 9835CF329835CE359835F336 𪕪𪕣𪛖 +􏿿􏿾 E3329A35E3329A34 􏿿􏿾 +?﹙ FE39FE38A976 ?﹙ +丂丄㒙 814081418139FE30 丂丄㒙 +䑠䑚䑻䣈 823398318233973582339A3882348A32 䑠䑚䑻䣈 +郷鄇wv䐣 E05FE06A777682339230 郷鄇wv䐣 +𦠟𦠡𦣃𩄧𩅚 97339631973396339733A6359831C0359831C536 𦠟𦠡𦣃𩄧𩅚 +?? FE39FE39FE38FE38 ?? +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES(0x8139818F); +Warnings: +Warning 1366 Incorrect string value: '\x819\x81\x8F' for column 'C' at row 1 +INSERT INTO t1 VALUES(0x8431A530); +INSERT INTO t1 VALUES(0x9030813089398130); +INSERT INTO t1 VALUES(0xE3329A36); +INSERT INTO t1 VALUES(0xA6A78586E3329A38); +INSERT INTO t1 VALUES(0xA69C8041); +Warnings: +Warning 1366 Incorrect string value: '\x80A' for column 'C' at row 1 +INSERT INTO t1 VALUES(0xA9C6FEFF); +Warnings: +Warning 1366 Incorrect string value: '\xFE\xFF' for column 'C' at row 1 +INSERT INTO t1 VALUES(0xFFFF); +Warnings: +Warning 1366 Incorrect string value: '\xFF\xFF' for column 'C' at row 1 +INSERT INTO t1 VALUES(0x81408139); +Warnings: +Warning 1366 Incorrect string value: '\x819' for column 'C' at row 1 +INSERT INTO t1 VALUES(0x962B); +Warnings: +Warning 1366 Incorrect string value: '\x96+' for column 'C' at row 1 +INSERT INTO t1 VALUES(0x9F37823881308156); +Warnings: +Warning 1366 Incorrect string value: '\x810\x81V' for column 'C' at row 1 +INSERT INTO t1 VALUES(0xFE35FF30); +Warnings: +Warning 1366 Incorrect string value: '\xFE5\xFF0' for column 'C' at row 1 +INSERT INTO t1 VALUES(0x814281309CA4); +Warnings: +Warning 1366 Incorrect string value: '\x810\x9C\xA4' for column 'C' at row 1 +INSERT INTO t1 VALUES(0xE3329A36); +INSERT INTO t1 VALUES(0xFE39FE39FE39FE38); +SELECT * FROM t1; +C + +? +𐀀? +? +Η厗? + +┢ + +丂 + +񀓎 + +丅 +? +?? +UPDATE t1 SET c=0x81308130; +SELECT COUNT(*) FROM t1 WHERE c <> 0x81308130; +COUNT(*) +0 +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES(_gb18030 0x9534A337), (_gb18030 0x8959), (_gb18030 0xB0F9), (_gb18030 0xB0F4), (_gb18030 0x95348B39), (_gb18030 0x9794), (_gb18030 0x8231AC35); +INSERT INTO t1 VALUES(_gb18030 0xB0F8), (_gb18030 0xAB67), (_gb18030 0x8232B632), (_gb18030 0x9630ED37), (_gb18030 0x9539F933), (_gb18030 0xB0F6), (_gb18030 0x8233B931); +INSERT INTO t1 VALUES(_gb18030 0xD143), (_gb18030 0xB2A4), (_gb18030 0xC08F), (_gb18030 0xBC9E), (_gb18030 0xB2A6), (_gb18030 0xB2A8), (_gb18030 0xB069); +INSERT INTO t1 VALUES(_gb18030 0x9833A533), (_gb18030 0xE2C4), (_gb18030 0xB2A7), (_gb18030 0x97368632), (_gb18030 0xB2A3), (_gb18030 0x8483), (_gb18030 0xB0FE); +INSERT INTO t1 VALUES(_gb18030 0x865C), (_gb18030 0xD093), (_gb18030 0xB36A), (_gb18030 0xB143); +SELECT c, HEX(c) FROM t1 ORDER BY c; +c HEX(c) +𠬣 9534A337 +𠨵 95348B39 +㭋 8231AC35 +玤 AB67 +䂜 8232B632 +蚌 B0F6 +𢜗 9539F933 +𢮏 9630ED37 +䖫 8233B931 +傍 B0F8 +棒 B0F4 +棓 9794 +谤 B0F9 +塝 8959 +拨 B2A6 +波 B2A8 +癷 B069 +𩧯 9833A533 +玻 B2A3 +剝 8483 +剥 B0FE +哱 865C +盋 B143 +砵 B36A +袚 D093 +𧙄 97368632 +钵 B2A7 +饽 E2C4 +紴 BC9E +缽 C08F +菠 B2A4 +袰 D143 +SELECT c, HEX(c) FROM t1 WHERE c >= 0x8483 and c < 0xE2C4 ORDER BY c; +c HEX(c) +剝 8483 +剥 B0FE +哱 865C +盋 B143 +砵 B36A +袚 D093 +𧙄 97368632 +钵 B2A7 +SELECT c, HEX(c) FROM t1 WHERE c LIKE 0xB0FE; +c HEX(c) +剥 B0FE +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES(_gb18030 0x81308130), (_gb18030 0x81308132); +INSERT INTO t1 VALUES('A'), ('a'), ('1'), ('2'); +INSERT INTO t1 VALUES(_gb18030 0xCDF5), (_gb18030 0xC0EE), (_gb18030 0xD5C5), (_gb18030 0xC1F5), (_gb18030 0xB3C2), (_gb18030 0xD1EE), (_gb18030 0xBBC6); +INSERT INTO t1 VALUES(_gb18030 0xCEE2), (_gb18030 0xD5D4), (_gb18030 0xD6DC), (_gb18030 0xD0EC), (_gb18030 0xCBEF), (_gb18030 0xC2ED), (_gb18030 0xD6EC); +INSERT INTO t1 VALUES(_gb18030 0xBAFA), (_gb18030 0xC1D6), (_gb18030 0xB9F9), (_gb18030 0xBACE), (_gb18030 0xB8DF), (_gb18030 0xC2DE), (_gb18030 0xD6A3); +INSERT INTO t1 VALUES(_gb18030 0xE3329A35), (_gb18030 0xE3329A34); +SELECT c, HEX(c) FROM t1 ORDER BY c; +c HEX(c) +1 31 +2 32 +A 41 +a 61 +€ 81308130 +‚ 81308132 +􏿾 E3329A34 +􏿿 E3329A35 +陈 B3C2 +高 B8DF +郭 B9F9 +何 BACE +胡 BAFA +黄 BBC6 +李 C0EE +林 C1D6 +刘 C1F5 +罗 C2DE +马 C2ED +孙 CBEF +王 CDF5 +吴 CEE2 +徐 D0EC +杨 D1EE +张 D5C5 +赵 D5D4 +郑 D6A3 +周 D6DC +朱 D6EC +DROP TABLE t1; +CREATE TABLE t1 (c CHAR(1) CHARACTER SET gb18030, v VARCHAR(100) CHARACTER SET gb18030); +INSERT INTO t1 VALUES(0x8140, 0x81308132A6C9A6A985328338); +SELECT HEX(c), c, HEX(v), v FROM t1; +HEX(c) c HEX(v) v +8140 丂 81308132A6C9A6A985328338 ‚ιΙ? +ALTER TABLE t1 ADD COLUMN t TEXT CHARACTER SET gb18030; +INSERT INTO t1 VALUES(0xBC81, 0x82358132FE39FE3940414281308135, 0x84678578); +SELECT HEX(c), c, HEX(v), v, HEX(t), t FROM t1; +HEX(c) c HEX(v) v HEX(t) t +8140 丂 81308132A6C9A6A985328338 ‚ιΙ? NULL NULL +BC81 紒 82358132FE39FE3940414281308135 䵲?@AB… 84678578 刧厁 +DROP TABLE t1; +CREATE TABLE t1 (c VARCHAR(10) CHARACTER SET gb18030); +INSERT INTO t1 VALUES(0x81308A3181308A3181308A3181308A3181308732); +INSERT INTO t1 VALUES(0x81308A3181308A318130873281308A31); +INSERT INTO t1 VALUES(0x81308A318130873281309636); +INSERT INTO t1 VALUES(0x81308A318130873281309637); +INSERT INTO t1 VALUES(0x81308A31813087328130963781309636); +INSERT INTO t1 VALUES(0x8130963681308A31); +INSERT INTO t1 VALUES(0xA8A581308D35); +INSERT INTO t1 VALUES(0x81308D35A8A5); +INSERT INTO t1 VALUES(0x81308D35A8A5A8A5); +SELECT HEX(c) FROM t1; +HEX(c) +81308A3181308A3181308A3181308A3181308732 +81308A3181308A318130873281308A31 +81308A318130873281309636 +81308A318130873281309637 +81308A31813087328130963781309636 +8130963681308A31 +A8A581308D35 +81308D35A8A5 +81308D35A8A5A8A5 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0x81308A31); +HEX(c) +81308A3181308A3181308A3181308A3181308732 +81308A3181308A318130873281308A31 +8130963681308A31 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0x8130873281308A31, '%'); +HEX(c) +81308A3181308A3181308A3181308A3181308732 +81308A3181308A318130873281308A31 +81308A318130873281309636 +81308A318130873281309637 +81308A31813087328130963781309636 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0x8130873281309636); +HEX(c) +81308A318130873281309636 +81308A318130873281309637 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0x8130963781309636); +HEX(c) +81308A31813087328130963781309636 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT(_gb18030 0x81309636, '%'); +HEX(c) +8130963681308A31 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0x8130963781309636); +HEX(c) +81308A31813087328130963781309636 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT('%', _gb18030 0x8130963781309636) ESCAPE _gb18030 0x81309637; +HEX(c) +81308A318130873281309636 +81308A318130873281309637 +81308A31813087328130963781309636 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT(_gb18030 0xA8A5, '%'); +HEX(c) +A8A581308D35 +81308D35A8A5 +81308D35A8A5A8A5 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT(_gb18030 0xA8A5, '_'); +HEX(c) +A8A581308D35 +81308D35A8A5 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT(_gb18030 0xA8A5, '_', _gb18030 0x81308D35); +HEX(c) +81308D35A8A5A8A5 +SELECT HEX(c) FROM t1 WHERE c LIKE CONCAT('%_', _gb18030 0xA8A5); +HEX(c) +A8A581308D35 +81308D35A8A5 +81308D35A8A5A8A5 +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 (c VARCHAR(10) CHARACTER SET gb18030); +INSERT INTO t1 VALUES (_gb18030 0x8BF5819AEDC3), (_gb18030 0x99CC), (_gb18030 0x90459958), (_gb18030 0xAA95C0E59E509AED), (_gb18030 0xCCE7), (_gb18030 0x9068), (_gb18030 0x90459958); +SELECT ANY_VALUE(HEX(c)), COUNT(c) FROM t1 GROUP BY c COLLATE gb18030_chinese_ci; +ANY_VALUE(HEX(c)) COUNT(c) +8BF5819AEDC3 1 +90459958 2 +9068 1 +99CC 1 +AA95C0E59E509AED 1 +CCE7 1 +DROP TABLE t1; +CREATE TABLE t1 (a int) ENGINE=InnoDB; +LOAD DATA INFILE '../../std_data/bug21542698.dat' INTO TABLE t1 CHARACTER SET gb18030; +ERROR HY000: Invalid gb18030 character string: 'MZ' +DROP TABLE t1; +DROP DATABASE gb18030; +SET sql_mode = default; +# +# End of 5.7 tests +# diff --git a/mysql-test/r/ctype_uca.result-pq b/mysql-test/r/ctype_uca.result-pq new file mode 100644 index 000000000..4f7ce5a01 --- /dev/null +++ b/mysql-test/r/ctype_uca.result-pq @@ -0,0 +1,7610 @@ +call mtr.add_suppression("Plugin \'InnoDB\'"); +DROP TABLE IF EXISTS t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +set collation_connection=utf8_unicode_ci; +Warnings: +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\t' = 'a' , 'a\t' < 'a' , 'a\t' > 'a'; +'a\t' = 'a' 'a\t' < 'a' 'a\t' > 'a' +0 1 0 +select 'a\t' = 'a ', 'a\t' < 'a ', 'a\t' > 'a '; +'a\t' = 'a ' 'a\t' < 'a ' 'a\t' > 'a ' +0 1 0 +select 'a' = 'a\t', 'a' < 'a\t', 'a' > 'a\t'; +'a' = 'a\t' 'a' < 'a\t' 'a' > 'a\t' +0 0 1 +select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t'; +'a ' = 'a\t' 'a ' < 'a\t' 'a ' > 'a\t' +0 0 1 +select 'a a' > 'a', 'a \t' < 'a'; +'a a' > 'a' 'a \t' < 'a' +1 1 +select 'c' like '\_' as want0; +want0 +0 +create table t1 (c1 char(10) character set utf8 collate utf8_bin); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); +INSERT INTO t1 VALUES (_ucs2 0x1EA0),(_ucs2 0x1EA1),(_ucs2 0x1EA2),(_ucs2 0x1EA3); +INSERT INTO t1 VALUES (_ucs2 0x1EA4),(_ucs2 0x1EA5),(_ucs2 0x1EA6),(_ucs2 0x1EA7); +INSERT INTO t1 VALUES (_ucs2 0x1EA8),(_ucs2 0x1EA9),(_ucs2 0x1EAA),(_ucs2 0x1EAB); +INSERT INTO t1 VALUES (_ucs2 0x1EAC),(_ucs2 0x1EAD),(_ucs2 0x1EAE),(_ucs2 0x1EAF); +INSERT INTO t1 VALUES (_ucs2 0x1EB0),(_ucs2 0x1EB1),(_ucs2 0x1EB2),(_ucs2 0x1EB3); +INSERT INTO t1 VALUES (_ucs2 0x1EB4),(_ucs2 0x1EB5),(_ucs2 0x1EB6),(_ucs2 0x1EB7); +INSERT INTO t1 VALUES (_ucs2 0x1EB8),(_ucs2 0x1EB9),(_ucs2 0x1EBA),(_ucs2 0x1EBB); +INSERT INTO t1 VALUES (_ucs2 0x1EBC),(_ucs2 0x1EBD),(_ucs2 0x1EBE),(_ucs2 0x1EBF); +INSERT INTO t1 VALUES (_ucs2 0x1EC0),(_ucs2 0x1EC1),(_ucs2 0x1EC2),(_ucs2 0x1EC3); +INSERT INTO t1 VALUES (_ucs2 0x1EC4),(_ucs2 0x1EC5),(_ucs2 0x1EC6),(_ucs2 0x1EC7); +INSERT INTO t1 VALUES (_ucs2 0x1EC8),(_ucs2 0x1EC9),(_ucs2 0x1ECA),(_ucs2 0x1ECB); +INSERT INTO t1 VALUES (_ucs2 0x1ECC),(_ucs2 0x1ECD),(_ucs2 0x1ECE),(_ucs2 0x1ECF); +INSERT INTO t1 VALUES (_ucs2 0x1ED0),(_ucs2 0x1ED1),(_ucs2 0x1ED2),(_ucs2 0x1ED3); +INSERT INTO t1 VALUES (_ucs2 0x1ED4),(_ucs2 0x1ED5),(_ucs2 0x1ED6),(_ucs2 0x1ED7); +INSERT INTO t1 VALUES (_ucs2 0x1ED8),(_ucs2 0x1ED9),(_ucs2 0x1EDA),(_ucs2 0x1EDB); +INSERT INTO t1 VALUES (_ucs2 0x1EDC),(_ucs2 0x1EDD),(_ucs2 0x1EDE),(_ucs2 0x1EDF); +INSERT INTO t1 VALUES (_ucs2 0x1EE0),(_ucs2 0x1EE1),(_ucs2 0x1EE2),(_ucs2 0x1EE3); +INSERT INTO t1 VALUES (_ucs2 0x1EE4),(_ucs2 0x1EE5),(_ucs2 0x1EE6),(_ucs2 0x1EE7); +INSERT INTO t1 VALUES (_ucs2 0x1EE8),(_ucs2 0x1EE9),(_ucs2 0x1EEA),(_ucs2 0x1EEB); +INSERT INTO t1 VALUES (_ucs2 0x1EEC),(_ucs2 0x1EED),(_ucs2 0x1EEE),(_ucs2 0x1EEF); +INSERT INTO t1 VALUES (_ucs2 0x1EF0),(_ucs2 0x1EF1); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('AE'),('Ae'),('ae'),('aE'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_unicode_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_icelandic_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Â,Ã,à,â,ã,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Á,á +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Ð,ð +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +E,e,È,Ê,Ë,è,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +É,é +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Î,Ï,ì,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +Í,í +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ô,Õ,ò,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ó,ó +Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Û,Ü,ù,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ú,ú +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,ÿ,Ŷ,ŷ,Ÿ +Ý,ý +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Þ,þ +Ä,Æ,ä,æ +Ö,Ø,ö,ø +Å,å +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_latvian_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +CH,Ch,cH,ch +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ǧ,ǧ,Ǵ,ǵ +Ģ,ģ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +Y,y +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ǩ,ǩ +Ķ,ķ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ļ,ļ +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ņ,ņ +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ř,ř +RR,Rr,rR,rr +Ŗ,ŗ +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_romanian_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Ã,Ä,Å,à,á,ã,ä,å,Ā,ā,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ă,ă +Â,â +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Ï,ì,í,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +Î,î +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Š,š,ſ +SS,Ss,sS,ss,ß +Ş,ş +Ʃ +ƪ +T,t,Ť,ť +ƾ +Ţ,ţ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_slovenian_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +CH,Ch,cH,ch +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_polish_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ą,ą +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ć,ć +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ę,ę +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ń,ń +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ô,Õ,Ö,ò,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ó,ó +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ś,ś +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ž,ž +ƍ +Ź,ź +Ż,ż +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_estonian_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Å,à,á,â,ã,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz +DŽ,Dž,dŽ,dž +DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,ò,ó,ô,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Z,z +Ž,ž +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +Õ,õ +Ä,ä +Ö,ö +Ü,ü +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Ź,ź,Ż,ż +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_spanish_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ñ,ñ +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_swedish_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,à,á,â,ã,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ü,Ý,ü,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Å,å +Ä,Æ,ä,æ +Ö,Ø,ö,ø +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_turkish_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ç,ç +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ğ,ğ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +I,ı +IJ,Ij +ƕ,Ƕ +Ħ,ħ +i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +iJ,ij,IJ,ij +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ö,ö +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Š,š,ſ +SS,Ss,sS,ss,ß +Ş,ş +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ü,ü +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_czech_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +cH +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +CH,Ch,ch +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ +RR,Rr,rR,rr +Ř,ř +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_danish_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,à,á,â,ã,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +aA +AE,Ae,aE,ae +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ü,Ý,ü,ý,ÿ,Ű,ű,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ä,Æ,ä,æ +Ö,Ø,ö,ø,Ő,ő +AA,Aa,aa,Å,å +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_lithuanian_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,CH,Ch,c,ch,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +cH +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,Y,i,y,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_slovak_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Å,à,á,â,ã,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ä,ä +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +cH +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +CH,Ch,ch +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Õ,Ö,ò,ó,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ô,ô +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_spanish2_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +cH +CH,Ch,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +lL +LL,Ll,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ñ,ñ +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,J,i,j,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij +IJ,ij +ı +Ɨ +Ɩ +Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj +LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj +NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +U,V,u,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_esperanto_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ĉ,ĉ +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ĝ,ĝ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h +Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,ǰ +Ĵ,ĵ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ŝ,ŝ +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ŭ,ŭ +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_hungarian_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ö,ö,Ő,ő +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ü,ü,Ű,ű +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_croatian_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ĉ,ĉ,Ċ,ċ +CH,Ch,cH,ch +Č,č +Ć,ć +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DZ,Dz,dz +DŽ,Dž,dŽ,dž,DŽ,Dž,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LL,Ll,lL,ll +LJ,Lj,lJ,lj,LJ,Lj,lj +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_german2_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Å,à,á,â,ã,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae,Ä,Æ,ä,æ +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Ö,ö,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ü,ü +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_unicode_520_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae,Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ð,ð,Ď,ď,Đ,đ +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Ɖ +Ɗ +Ƌ,ƌ +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ,Ħ,ħ +ƕ,Ƕ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ,Ŀ,ŀ,Ł,ł +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,Ø,ò,ó,ô,õ,ö,ø,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ǿ,ǿ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_vietnamese_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Ã,Ä,Å,à,á,ã,ä,å,Ā,ā,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả +AA,Aa,aA,aa +AE,Ae,aE,ae +Ă,ă,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +Â,â,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ë,è,é,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ +Ê,ê,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Õ,Ö,ò,ó,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ +OE,Oe,oE,oe,Œ,œ +Ô,ô,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ +Ơ,ơ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ +Ư,ư,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +ALTER TABLE t1 CONVERT TO CHARACTER SET ucs2 COLLATE ucs2_bin; +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_unicode_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_icelandic_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Â,Ã,à,â,ã,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Á,á +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Ð,ð +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +E,e,È,Ê,Ë,è,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +É,é +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Î,Ï,ì,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +Í,í +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ô,Õ,ò,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ó,ó +Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Û,Ü,ù,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ú,ú +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,ÿ,Ŷ,ŷ,Ÿ +Ý,ý +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Þ,þ +Ä,Æ,ä,æ +Ö,Ø,ö,ø +Å,å +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_latvian_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +CH,Ch,cH,ch +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ǧ,ǧ,Ǵ,ǵ +Ģ,ģ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +Y,y +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ǩ,ǩ +Ķ,ķ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ļ,ļ +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ņ,ņ +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ř,ř +RR,Rr,rR,rr +Ŗ,ŗ +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_romanian_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Ã,Ä,Å,à,á,ã,ä,å,Ā,ā,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ă,ă +Â,â +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Ï,ì,í,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +Î,î +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Š,š,ſ +SS,Ss,sS,ss,ß +Ş,ş +Ʃ +ƪ +T,t,Ť,ť +ƾ +Ţ,ţ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_slovenian_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +CH,Ch,cH,ch +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_polish_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ą,ą +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ć,ć +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ę,ę +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ń,ń +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ô,Õ,Ö,ò,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ó,ó +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ś,ś +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ž,ž +ƍ +Ź,ź +Ż,ż +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_estonian_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Å,à,á,â,ã,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz +DŽ,Dž,dŽ,dž +DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,ò,ó,ô,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Z,z +Ž,ž +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +Õ,õ +Ä,ä +Ö,ö +Ü,ü +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Ź,ź,Ż,ż +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_spanish_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ñ,ñ +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_swedish_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,à,á,â,ã,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ü,Ý,ü,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Å,å +Ä,Æ,ä,æ +Ö,Ø,ö,ø +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_turkish_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ç,ç +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ğ,ğ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +I,ı +IJ,Ij +ƕ,Ƕ +Ħ,ħ +i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +iJ,ij,IJ,ij +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ö,ö +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Š,š,ſ +SS,Ss,sS,ss,ß +Ş,ş +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ü,ü +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_czech_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +cH +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +CH,Ch,ch +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ +RR,Rr,rR,rr +Ř,ř +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_danish_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,à,á,â,ã,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +aA +AE,Ae,aE,ae +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ü,Ý,ü,ý,ÿ,Ű,ű,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ä,Æ,ä,æ +Ö,Ø,ö,ø,Ő,ő +AA,Aa,aa,Å,å +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_lithuanian_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,CH,Ch,c,ch,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +cH +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,Y,i,y,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_slovak_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Å,à,á,â,ã,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Ä,ä +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ +cH +Č,č +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +DŽ,Dž,dŽ,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +CH,Ch,ch +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Õ,Ö,ò,ó,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ô,ô +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_spanish2_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +cH +CH,Ch,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +lL +LL,Ll,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ñ,ñ +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_roman_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,J,i,j,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij +IJ,ij +ı +Ɨ +Ɩ +Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj +LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj +NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +U,V,u,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_esperanto_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ĉ,ĉ +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ĝ,ĝ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h +Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,ǰ +Ĵ,ĵ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ŝ,ŝ +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ŭ,ŭ +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_hungarian_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ö,ö,Ő,ő +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ü,ü,Ű,ű +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_croatian_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ĉ,ĉ,Ċ,ċ +CH,Ch,cH,ch +Č,č +Ć,ć +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DZ,Dz,dz +DŽ,Dž,dŽ,dž,DŽ,Dž,dž +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LL,Ll,lL,ll +LJ,Lj,lJ,lj,LJ,Lj,lj +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,ſ +SS,Ss,sS,ss,ß +Š,š +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż +ƍ +Ž,ž +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_german2_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Å,à,á,â,ã,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae,Ä,Æ,ä,æ +Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Ö,ö,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ü,ü +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_unicode_520_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +AA,Aa,aA,aa +AE,Ae,aE,ae,Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ð,ð,Ď,ď,Đ,đ +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Ɖ +Ɗ +Ƌ,ƌ +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ,Ħ,ħ +ƕ,Ƕ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ,Ŀ,ŀ,Ł,ł +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,Ø,ò,ó,ô,õ,ö,ø,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ǿ,ǿ,Ọ,ọ,Ỏ,ỏ,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +OE,Oe,oE,oe,Œ,œ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +SELECT GROUP_CONCAT(c1 ORDER BY c1) FROM t1 GROUP BY c1 COLLATE ucs2_vietnamese_ci; +GROUP_CONCAT(c1 ORDER BY c1) +÷ +× +A,a,À,Á,Ã,Ä,Å,à,á,ã,ä,å,Ā,ā,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ,Ạ,ạ,Ả,ả +AA,Aa,aA,aa +AE,Ae,aE,ae +Ă,ă,Ắ,ắ,Ằ,ằ,Ẳ,ẳ,Ẵ,ẵ,Ặ,ặ +Â,â,Ấ,ấ,Ầ,ầ,Ẩ,ẩ,Ẫ,ẫ,Ậ,ậ +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,DŽ,Dž,dZ,dz,dŽ,dž,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ë,è,é,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě,Ẹ,ẹ,Ẻ,ẻ,Ẽ,ẽ +Ê,ê,Ế,ế,Ề,ề,Ể,ể,Ễ,ễ,Ệ,ệ +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,i,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ,Ỉ,ỉ,Ị,ị +IJ,Ij,iJ,ij,IJ,ij +ı +Ɨ +Ɩ +J,j,Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj,LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj,NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Õ,Ö,ò,ó,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ,Ọ,ọ,Ỏ,ỏ +OE,Oe,oE,oe,Œ,œ +Ô,ô,Ố,ố,Ồ,ồ,Ổ,ổ,Ỗ,ỗ,Ộ,ộ +Ơ,ơ,Ớ,ớ,Ờ,ờ,Ở,ở,Ỡ,ỡ,Ợ,ợ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,u,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ,Ụ,ụ,Ủ,ủ +Ư,ư,Ứ,ứ,Ừ,ừ,Ử,ử,Ữ,ữ,Ự,ự +Ɯ +Ʊ +V,v +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ +drop table t1; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_general_ci, INDEX (c)); +Warnings: +Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B403B11F770308 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_general_ci; +c +Μωδαί̈ +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_general_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +DROP TABLE t1; +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE ucs2_unicode_ci, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _ucs2 0x039C0025 COLLATE ucs2_unicode_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _ucs2 0x039C0025 +COLLATE ucs2_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_unicode_ci, INDEX (c)); +Warnings: +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B403B11F770308 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) COLLATE utf8_unicode_ci; +c +Μωδαί̈ +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf8) +COLLATE utf8_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +DROP TABLE t1; +CREATE TABLE t1 ( +col1 CHAR(32) CHARACTER SET utf8 NOT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0041004100410627 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0041004100410628 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0041004100410647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0041004100410648 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0633064A0651062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062D06330646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A0642064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06320627062F0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062806310627064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064706450647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F062706460634062C0648064A06270646064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A90647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A06270631064A062E USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062706460642064406270628 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064A0631062706460650 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627062F064806270631062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280631062706480646200C06310627 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062E064806270646062F0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0648 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A062D062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A0623062B064A0631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06220646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0642063106270631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06AF06310641062A0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06270646062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0634062E0635064A0651062A064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0628062706310632 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06270633062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063906A90633 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06270648060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F0631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062D062F0648062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0628064A0633062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0648067E0646062C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06330627064406AF064A060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063306270644 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064606450627064A0646062F0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A06280631064A0632 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0645062C06440633 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280648062F060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0628064A0646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06350641062D0627062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064A0646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A9062A06270628 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x068606340645 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0645064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062E06480631062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0686064706310647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06420648064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06450635064506510645 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06310627 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0646063406270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0645064A200C062F0647062F060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0647063106860646062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06390645064400BB USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A9064806340634 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0628 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064706500646064A064606AF USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627062D063306270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064A062706310634062706370631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06450646062A06340631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0634062F0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F0633062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A064806270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0647064506270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064806510644 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A0634062E064A0635 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F0627062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280627 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A064106270648062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062D06270644062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A064106A906510631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063A064406280647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F06270631062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064A06A9064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06270632 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063106470628063106270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064606470636062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064506340631064806370647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064A063106270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0646064A0632 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064A06A9 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0645062D064206510642 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0637063106270632 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064106310647064606AF USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A0645062F06510646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064A063106270646064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280648062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A90627063106470627064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06270648 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0639063106350647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064506480631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0633064A06270633064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064A063106270646060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062D064806320647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063906440645 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F062706460634 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06450642062706440627062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F064A06AF0631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0648064A06980647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0646062706450647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064506480631062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0628062D062B USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0628063106310633064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064606480634062A0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06450646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A064606470627 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0622064606860647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F064806310647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064206270645062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x067E0631062F062706320645 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0698062706460648064A0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0648064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F06390648062A0650 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063306500631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F0646064A0633064F0646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063106270633 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0647064A0626062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0639064406480645200C063406310642064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280639062F0627064B USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0645062F063106330647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062206410631064A06420627064A064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F06270646063406AF06270647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06440646062F0646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x067E064A06480633062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0647064606AF06270645064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x067E0633 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0622063A06270632 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062C064606AF USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062C064706270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F064806510645 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063406470631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A9064506280631064A062C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06450646062A06420644 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A90631062F0646062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06470645 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06310641062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06220646062C0627 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064506270646062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A0627 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062706A9062A06280631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064606380631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F06480644062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F06480628062706310647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064606330628062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0645063306270639062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0634062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06480632064A0631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0645062E062A06270631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06330641064A0631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627064606AF0644064A0633 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A0642064A200C06320627062F0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280627063206AF0634062A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0647064506330631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06220644064506270646064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06270634 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06220645062F0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A906270631064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x067E0631062F0627062E062A0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063906440645064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0627062F0628064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062D062F0651 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064606280648062F060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06480644064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x063906480636060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06340627064A062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064506470645 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062A0631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06220646060C USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06470645063306310634 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A90627064606480646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062E0627064606480627062F06AF064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06AF06310645064A USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280648062C0648062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062206480631062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F0648 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06A90627064506440627064B USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x064A06A9062F064A06AF0631 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06AF USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x062F064406280633062A0647 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06280648062F0646062F USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x06450647064506270646 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT HEX(CONVERT(col1 USING ucs2)) FROM t1 ORDER BY col1 COLLATE utf8_persian_ci, col1 COLLATE utf8_bin; +HEX(CONVERT(col1 USING ucs2)) +0041004100410627 +0041004100410628 +0041004100410648 +0041004100410647 +0622063A06270632 +062206410631064A06420627064A064A +06220644064506270646064A +06220645062F0647 +06220646 +06220646060C +06220646062C0627 +0622064606860647 +062206480631062F +0627062D063306270646 +0627062F0628064A +0627062F064806270631062F +06270632 +06270633062A +06270634 +0627064206270645062A +062706A9062A06280631 +0627064506480631 +06270646062F +062706460642064406270628 +0627064606AF0644064A0633 +06270648 +06270648060C +0627064806510644 +0627064A +0627064A063106270646 +0627064A063106270646060C +0627064A0631062706460650 +0627064A063106270646064A +0627064A0646 +0628 +06280627 +0628062706310632 +06280627063206AF0634062A +0628062D062B +06280631062706480646200C06310627 +062806310627064A +0628063106310633064A +06280639062F0627064B +06280648062C0648062F +06280648062F +06280648062F060C +06280648062F0646062F +06280647 +0628064A0633062A +0628064A0646 +067E0631062F0627062E062A0647 +067E0631062F062706320645 +067E0633 +067E064A06480633062A +062A0627 +062A06270631064A062E +062A0623062B064A0631 +062A06280631064A0632 +062A062D062A +062A0631 +062A0634062E064A0635 +062A064106270648062A +062A064106A906510631 +062A0642064A +062A0642064A200C06320627062F0647 +062A0645062F06510646 +062A064606470627 +062A064806270646 +062C064606AF +062C064706270646 +068606340645 +0686064706310647 +062D06270644062A +062D062F0651 +062D062F0648062F +062D06330646 +062D064806320647 +062E0627064606480627062F06AF064A +062E064806270646062F0647 +062E06480631062F +062F0627062F +062F06270631062F +062F062706460634 +062F062706460634062C0648064A06270646064A +062F06270646063406AF06270647 +062F0631 +062F0633062A +062F06390648062A0650 +062F064406280633062A0647 +062F0646064A0633064F0646 +062F0648 +062F06480628062706310647 +062F064806310647 +062F06480644062A +062F064806510645 +062F064A06AF0631 +06310627 +063106270633 +06310641062A +063106470628063106270646 +06320627062F0647 +0698062706460648064A0647 +063306500631 +063306270644 +06330627064406AF064A060C +06330641064A0631 +0633064A06270633064A +0633064A0651062F +06340627064A062F +0634062E0635064A0651062A064A +0634062F +0634062F0647 +063406470631 +06350641062D0627062A +0637063106270632 +0639063106350647 +063906A90633 +063906440645 +063906440645064A +0639064406480645200C063406310642064A +06390645064400BB +063906480636060C +063A064406280647 +064106310647064606AF +0642063106270631 +06420648064A +06A90627063106470627064A +06A906270631064A +06A90627064506440627064B +06A90627064606480646 +06A9062A06270628 +06A90631062F0646062F +06A9064506280631064A062C +06A9064806340634 +06A90647 +06AF +06AF06310641062A0647 +06AF06310645064A +06440646062F0646 +064506270646062F +0645062C06440633 +0645062D064206510642 +0645062E062A06270631 +0645062F063106330647 +0645063306270639062F +064506340631064806370647 +06450635064506510645 +06450642062706440627062A +06450646 +06450646062A06340631 +06450646062A06420644 +064506480631062F +064506470645 +06450647064506270646 +0645064A +0645064A200C062F0647062F060C +0646062706450647 +064606280648062F060C +064606330628062A +0646063406270646 +064606380631 +064606450627064A0646062F0647 +064606480634062A0647 +064606470636062A +0646064A0632 +0648 +0648067E0646062C +06480632064A0631 +06480644064A +0648064A +0648064A06980647 +064706500646064A064606AF +0647063106860646062F +06470645 +0647064506270646 +0647064506330631 +06470645063306310634 +064706450647 +0647064606AF06270645064A +0647064A0626062A +064A062706310634062706370631 +064A06A9 +064A06A9062F064A06AF0631 +064A06A9064A +DROP TABLE t1; +CREATE TABLE t1 ( +a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_persian_ci, +offs INT NOT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_persian_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO t1 VALUES +(_ucs2 0x066D, 1),(_ucs2 0x064E, 2),(_ucs2 0xFE76, 3),(_ucs2 0xFE77, 4), +(_ucs2 0x0650, 5),(_ucs2 0xFE7A, 6),(_ucs2 0xFE7B, 7),(_ucs2 0x064F, 8), +(_ucs2 0xFE78, 9),(_ucs2 0xFE79,10),(_ucs2 0x064B,11),(_ucs2 0xFE70,12), +(_ucs2 0xFE71,13),(_ucs2 0x064D,14),(_ucs2 0xFE74,15),(_ucs2 0x064C,16), +(_ucs2 0xFE72,17), +(_ucs2 0xFE7F, 1),(_ucs2 0x0653, 2),(_ucs2 0x0654, 3),(_ucs2 0x0655, 4), +(_ucs2 0x0670, 5), +(_ucs2 0x0669, 1),(_ucs2 0x0622, 2),(_ucs2 0x0627, 3),(_ucs2 0x0671, 4), +(_ucs2 0x0621, 5),(_ucs2 0x0623, 6),(_ucs2 0x0625, 7),(_ucs2 0x0624, 8), +(_ucs2 0x0626, 9), +(_ucs2 0x0642, 1),(_ucs2 0x06A9, 2),(_ucs2 0x0643, 3), +(_ucs2 0x0648, 1),(_ucs2 0x0647, 2),(_ucs2 0x0629, 3),(_ucs2 0x06C0, 4), +(_ucs2 0x06CC, 5),(_ucs2 0x0649, 6),(_ucs2 0x064A, 7), +(_ucs2 0xFE80, 1),(_ucs2 0xFE81, 2),(_ucs2 0xFE82, 3),(_ucs2 0xFE8D, 4), +(_ucs2 0xFE8E, 5),(_ucs2 0xFB50, 6),(_ucs2 0xFB51, 7),(_ucs2 0xFE80, 8), +(_ucs2 0xFE83, 9),(_ucs2 0xFE84,10),(_ucs2 0xFE87,11),(_ucs2 0xFE88,12), +(_ucs2 0xFE85,13),(_ucs2 0xFE86,14),(_ucs2 0x0689,16),(_ucs2 0x068A,17), +(_ucs2 0xFEAE, 1),(_ucs2 0xFDFC, 2), +(_ucs2 0xFED8, 1),(_ucs2 0xFB8E, 2),(_ucs2 0xFB8F, 3),(_ucs2 0xFB90, 4), +(_ucs2 0xFB91, 5),(_ucs2 0xFED9, 6),(_ucs2 0xFEDA, 7),(_ucs2 0xFEDB, 8), +(_ucs2 0xFEDC, 9), +(_ucs2 0xFEEE, 1),(_ucs2 0xFEE9, 2),(_ucs2 0xFEEA, 3),(_ucs2 0xFEEB, 4), +(_ucs2 0xFEEC, 5),(_ucs2 0xFE93, 6),(_ucs2 0xFE94, 7),(_ucs2 0xFBA4, 8), +(_ucs2 0xFBA5, 9),(_ucs2 0xFBFC,10),(_ucs2 0xFBFD,11),(_ucs2 0xFBFE,12), +(_ucs2 0xFBFF,13),(_ucs2 0xFEEF,14),(_ucs2 0xFEF0,15),(_ucs2 0xFEF1,16), +(_ucs2 0xFEF2,17),(_ucs2 0xFEF3,18),(_ucs2 0xFEF4,19),(_ucs2 0xFEF5,20), +(_ucs2 0xFEF6,21),(_ucs2 0xFEF7,22),(_ucs2 0xFEF8,23),(_ucs2 0xFEF9,24), +(_ucs2 0xFEFA,25),(_ucs2 0xFEFB,26),(_ucs2 0xFEFC,27); +SELECT HEX(CONVERT(a USING ucs2)), offs, hex(weight_string(a)), a +FROM t1 ORDER BY a, offs, BINARY a; +HEX(CONVERT(a USING ucs2)) offs hex(weight_string(a)) a +0653 2 0001 ٓ +0654 3 0002 ٔ +0655 4 0003 ٕ +0670 5 0004 ٰ +FE7F 1 ﹿ +066D 1 02CB ٭ +064E 2 02CC َ +FE76 3 02CD ﹶ +FE77 4 02CE ﹷ +0650 5 02CF ِ +FE7A 6 02D0 ﹺ +FE7B 7 02D1 ﹻ +064F 8 02D2 ُ +FE78 9 02D3 ﹸ +FE79 10 02D4 ﹹ +064B 11 02D5 ً +FE70 12 02D6 ﹰ +FE71 13 02D7 ﹱ +064D 14 02D8 ٍ +FE74 15 02D9 ﹴ +064C 16 02DA ٌ +FE72 17 02DB ﹲ +0669 1 0E32 ٩ +0622 2 0E33 آ +0627 3 0E34 ا +0671 4 0E35 ٱ +0621 5 0E36 ء +0623 6 0E37 أ +0625 7 0E38 إ +0624 8 0E39 ؤ +0626 9 0E3A ئ +FE81 2 1348 ﺁ +FE82 3 1349 ﺂ +FE8D 4 134A ﺍ +FE8E 5 134B ﺎ +FB50 6 134C ﭐ +FB51 7 134D ﭑ +FE80 1 134E ﺀ +FE80 8 134E ﺀ +FE83 9 134F ﺃ +FE84 10 1350 ﺄ +FE87 11 1351 ﺇ +FE88 12 1352 ﺈ +FE85 13 1353 ﺅ +FE86 14 1354 ﺆ +0689 16 1355 ډ +068A 17 1356 ڊ +FEAE 1 1375 ﺮ +FDFC 2 1376 ﷼ +0642 1 139B ق +FED8 1 139B ﻘ +06A9 2 139C ک +FB8E 2 139C ﮎ +0643 3 139D ك +FB8F 3 139D ﮏ +FB90 4 139E ﮐ +FB91 5 139F ﮑ +FED9 6 13A0 ﻙ +FEDA 7 13A1 ﻚ +FEDB 8 13A2 ﻛ +FEDC 9 13A3 ﻜ +0648 1 13BD و +FEEE 1 13BD ﻮ +0647 2 13BE ه +FEE9 2 13BE ﻩ +0629 3 13BF ة +FEEA 3 13BF ﻪ +06C0 4 13C0 ۀ +FEEB 4 13C0 ﻫ +06CC 5 13C1 ی +FEEC 5 13C1 ﻬ +0649 6 13C2 ى +FE93 6 13C2 ﺓ +064A 7 13C3 ي +FE94 7 13C3 ﺔ +FBA4 8 13C4 ﮤ +FBA5 9 13C5 ﮥ +FBFC 10 13C6 ﯼ +FBFD 11 13C7 ﯽ +FBFE 12 13C8 ﯾ +FBFF 13 13C9 ﯿ +FEEF 14 13CA ﻯ +FEF0 15 13CB ﻰ +FEF1 16 13CC ﻱ +FEF2 17 13CD ﻲ +FEF3 18 13CE ﻳ +FEF4 19 13CF ﻴ +FEF5 20 13D0 ﻵ +FEF6 21 13D1 ﻶ +FEF7 22 13D2 ﻷ +FEF8 23 13D3 ﻸ +FEF9 24 13D4 ﻹ +FEFA 25 13D5 ﻺ +FEFB 26 13D6 ﻻ +FEFC 27 13D7 ﻼ +DROP TABLE t1; +SET @test_character_set= 'utf8'; +SET @test_collation= 'utf8_swedish_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET collation_server= @test_collation; +Warnings: +Warning 3778 'utf8_swedish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) utf8_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) utf8_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) COLLATE utf8_swedish_ci DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_swedish_ci +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +SET character_set_results= @safe_character_set_results; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +create table t1 (a varchar(1)) character set utf8 collate utf8_estonian_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_estonian_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +insert into t1 values ('A'),('B'),('C'),('a'),('b'),('c'); +select a, a regexp '[a]' from t1 order by binary a; +a a regexp '[a]' +A 1 +B 0 +C 0 +a 1 +b 0 +c 0 +drop table t1; +SET collation_connection='utf8_unicode_ci'; +Warnings: +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf8_unicode_ci 6109 +utf8_unicode_ci 61 +utf8_unicode_ci 6120 +drop table t1; +select @@collation_connection; +@@collation_connection +utf8_unicode_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +"BEGIN ctype_german.inc" +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf8_unicode_ci +delete from t1; +INSERT INTO t1 VALUES ('ud'),('uf'); +INSERT INTO t1 VALUES ('od'),('of'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('ad'),('af'); +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6); +INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 61 +ä C3A4 +ad 6164 +ae 6165 +af 6166 +Æ C386 +æ C3A6 +e 65 +o 6F +ö C3B6 +od 6F64 +oe 6F65 +Œ C592 +œ C593 +of 6F66 +s 73 +ss 7373 +ß C39F +u 75 +ü C3BC +ud 7564 +ue 7565 +uf 7566 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a,ä +ad +ae +af +Æ,æ +e +o,ö +od +oe,Œ,œ +of +s +ss,ß +u,ü +ud +ue +uf +SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1); +s1 hex(s1) hex(weight_string(s1)) +a 61 0E33 +ä C3A4 0E33 +ad 6164 0E330E6D +ae 6165 0E330E8B +af 6166 0E330EB9 +Æ C386 0E38 +æ C3A6 0E38 +e 65 0E8B +o 6F 0F82 +ö C3B6 0F82 +od 6F64 0F820E6D +oe 6F65 0F820E8B +Œ C592 0F820E8B +œ C593 0F820E8B +of 6F66 0F820EB9 +s 73 0FEA +ss 7373 0FEA0FEA +ß C39F 0FEA0FEA +u 75 101F +ü C3BC 101F +ud 7564 101F0E6D +ue 7565 101F0E8B +uf 7566 101F0EB9 +SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1); +s1 hex(s1) +ae 6165 +drop table t1; +"END ctype_german.inc" +CREATE TABLE t1 (id int, a varchar(30) character set utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131); +INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049); +INSERT INTO t1 VALUES (5, _ucs2 0x01300130), (6, _ucs2 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 3 ıi 3 II 2 +ıı 4 ıı 4 II 2 +ii 2 ii 2 II 2 +İI 3 ii 2 İI 3 +İİ 4 ii 2 İİ 4 +II 2 ii 2 II 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf8 collate utf8_turkish_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_turkish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 3 ıi 3 Iİ 3 +ıı 4 ıı 4 II 2 +ii 2 ii 2 İİ 4 +İI 3 iı 3 İI 3 +İİ 4 ii 2 İİ 4 +II 2 ıı 4 II 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +a varchar(255), +key a(a) +) character set utf8 collate utf8_danish_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_danish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +insert into t1 values ('åaaaa'),('ååaaa'),('aaaaa'); +select a as like_a from t1 where a like 'a%'; +like_a +aaaaa +select a as like_aa from t1 where a like 'aa%'; +like_aa +aaaaa +select a as like_aaa from t1 where a like 'aaa%'; +like_aaa +aaaaa +select a as like_aaaa from t1 where a like 'aaaa%'; +like_aaaa +aaaaa +select a as like_aaaaa from t1 where a like 'aaaaa%'; +like_aaaaa +aaaaa +alter table t1 convert to character set ucs2 collate ucs2_danish_ci; +select a as like_a from t1 where a like 'a%'; +like_a +aaaaa +select a as like_aa from t1 where a like 'aa%'; +like_aa +aaaaa +select a as like_aaa from t1 where a like 'aaa%'; +like_aaa +aaaaa +select a as like_aaaa from t1 where a like 'aaaa%'; +like_aaaa +aaaaa +select a as like_aaaaa from t1 where a like 'aaaaa%'; +like_aaaaa +aaaaa +drop table t1; +create table t1 ( +a varchar(255), +key(a) +) character set utf8 collate utf8_spanish2_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_spanish2_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +insert into t1 values ('aaaaa'),('lllll'),('zzzzz'); +select a as like_l from t1 where a like 'l%'; +like_l +lllll +select a as like_ll from t1 where a like 'll%'; +like_ll +lllll +select a as like_lll from t1 where a like 'lll%'; +like_lll +lllll +select a as like_llll from t1 where a like 'llll%'; +like_llll +lllll +select a as like_lllll from t1 where a like 'lllll%'; +like_lllll +lllll +alter table t1 convert to character set ucs2 collate ucs2_spanish2_ci; +select a as like_l from t1 where a like 'l%'; +like_l +lllll +select a as like_ll from t1 where a like 'll%'; +like_ll +lllll +select a as like_lll from t1 where a like 'lll%'; +like_lll +lllll +select a as like_llll from t1 where a like 'llll%'; +like_llll +lllll +select a as like_lllll from t1 where a like 'lllll%'; +like_lllll +lllll +drop table t1; +create table t1 ( +a varchar(255), +key a(a) +) character set utf8 collate utf8_czech_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_czech_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +insert into t1 values +('b'),('c'),('d'),('e'),('f'),('g'),('h'),('ch'),('i'),('j'); +select * from t1 where a like 'c%'; +a +c +ch +alter table t1 convert to character set ucs2 collate ucs2_czech_ci; +select * from t1 where a like 'c%'; +a +c +ch +drop table t1; +set collation_connection=ucs2_unicode_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci DEFAULT NULL, + `s2` varchar(64) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F20025 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +DROP TABLE t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +End for 5.0 tests +End of 5.1 tests +# +# Start of 5.5 tests +# +SET collation_connection=utf8_czech_ci; +Warnings: +Warning 3778 'utf8_czech_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +SELECT @@collation_connection; +@@collation_connection +utf8_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch'); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1)); +SELECT * FROM t1 WHERE s1 LIKE 'ch'; +s1 +ch +DROP TABLE t1; +SELECT @@collation_connection; +@@collation_connection +utf8_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# Part#2 - ignorable characters +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e'); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +61000000000009 +61 +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +61000000000009 +61 +DROP TABLE t1; +SET collation_connection=ucs2_czech_ci; +SELECT @@collation_connection; +@@collation_connection +ucs2_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch'); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1)); +SELECT * FROM t1 WHERE s1 LIKE 'ch'; +s1 +ch +DROP TABLE t1; +SELECT @@collation_connection; +@@collation_connection +ucs2_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# Part#2 - ignorable characters +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e'); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +0061000000000000000000000009 +0061 +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +0061000000000000000000000009 +0061 +DROP TABLE t1; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#3664 WEIGHT_STRING +# +set collation_connection=ucs2_unicode_ci; +select @@collation_connection; +@@collation_connection +ucs2_unicode_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0E33 +select hex(weight_string('A')); +hex(weight_string('A')) +0E33 +select hex(weight_string('abc')); +hex(weight_string('abc')) +0E330E4A0E60 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +0E330E4A +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +0E330E4A0E60 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +0E330E4A0E6002090209 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +0E +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0E330E4A02 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +0E330E4A020902090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +0E +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +0E +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select @@collation_connection; +@@collation_connection +ucs2_unicode_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0E230E230E2302090209 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0E230E2302 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0E230E23020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +set @@collation_connection=utf8_unicode_ci; +Warnings: +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +select @@collation_connection; +@@collation_connection +utf8_unicode_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0E33 +select hex(weight_string('A')); +hex(weight_string('A')) +0E33 +select hex(weight_string('abc')); +hex(weight_string('abc')) +0E330E4A0E60 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +0E330E4A +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +0E330E4A0E60 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +0E330E4A0E6002090209 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +0E +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0E330E4A02 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +0E330E4A020902090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +0E +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +0E +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select @@collation_connection; +@@collation_connection +utf8_unicode_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0E230E230E2302090209 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0E230E2302 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0E230E23020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +set @@collation_connection=utf8_czech_ci; +Warnings: +Warning 3778 'utf8_czech_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +select @@collation_connection; +@@collation_connection +utf8_czech_ci +select collation(cast(_latin1 0xDF as char)); +collation(cast(_latin1 0xDF as char)) +utf8_czech_ci +select hex(weight_string('s')); +hex(weight_string('s')) +0FEA +select hex(weight_string(cast(_latin1 0xDF as char))); +hex(weight_string(cast(_latin1 0xDF as char))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF as char) as char(1))) +0FEA0FEA +select hex(weight_string('c')); +hex(weight_string('c')) +0E60 +select hex(weight_string('h')); +hex(weight_string('h')) +0EE1 +select hex(weight_string('ch')); +hex(weight_string('ch')) +0EE2 +select hex(weight_string('i')); +hex(weight_string('i')) +0EFB +select hex(weight_string(cast(_latin1 0x6368DF as char))); +hex(weight_string(cast(_latin1 0x6368DF as char))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))) +0E60 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))) +0EE20FEA0FEA0209 +select hex(weight_string(cast(_latin1 0xDF6368 as char))); +hex(weight_string(cast(_latin1 0xDF6368 as char))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))) +0FEA0FEA0E60 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))) +0FEA0FEA0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)) +0EE202 +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)) +0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)) +0EE20209020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)) +0FEA0FEA0E6002090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +set @@collation_connection=ucs2_czech_ci; +select @@collation_connection; +@@collation_connection +ucs2_czech_ci +select collation(cast(_latin1 0xDF as char)); +collation(cast(_latin1 0xDF as char)) +ucs2_czech_ci +select hex(weight_string('s')); +hex(weight_string('s')) +0FEA +select hex(weight_string(cast(_latin1 0xDF as char))); +hex(weight_string(cast(_latin1 0xDF as char))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF as char) as char(1))) +0FEA0FEA +select hex(weight_string('c')); +hex(weight_string('c')) +0E60 +select hex(weight_string('h')); +hex(weight_string('h')) +0EE1 +select hex(weight_string('ch')); +hex(weight_string('ch')) +0EE2 +select hex(weight_string('i')); +hex(weight_string('i')) +0EFB +select hex(weight_string(cast(_latin1 0x6368DF as char))); +hex(weight_string(cast(_latin1 0x6368DF as char))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))) +0E60 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))) +0EE20FEA0FEA0209 +select hex(weight_string(cast(_latin1 0xDF6368 as char))); +hex(weight_string(cast(_latin1 0xDF6368 as char))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))) +0FEA0FEA0E60 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))) +0FEA0FEA0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)) +0EE202 +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)) +0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)) +0EE20209020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)) +0FEA0FEA0E6002090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +# +# Bug#33077 weight of supplementary characters is not 0xfffd +# +select hex(weight_string(_utf8mb4 0xF0908080 /* U+10000 */ collate utf8mb4_unicode_ci)); +hex(weight_string(_utf8mb4 0xF0908080 /* U+10000 */ collate utf8mb4_unicode_ci)) +FFFD +# +# Bug#53064 garbled data when using utf8_german2_ci collation +# +CREATE TABLE t1 (s1 VARCHAR(10) COLLATE utf8_german2_ci); +Warnings: +Warning 3778 'utf8_german2_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO t1 VALUES ('a'),('ae'),('af'); +SELECT s1,hex(s1),hex(weight_string(s1)) FROM t1 ORDER BY s1; +s1 hex(s1) hex(weight_string(s1)) +a 61 0E33 +ae 6165 0E330E8B +af 6166 0E330EB9 +DROP TABLE t1; +# +# WL#4013 Unicode german2 collation +# +SET collation_connection=utf8_german2_ci; +Warnings: +Warning 3778 'utf8_german2_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +"BEGIN ctype_german.inc" +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf8_german2_ci +delete from t1; +INSERT INTO t1 VALUES ('ud'),('uf'); +INSERT INTO t1 VALUES ('od'),('of'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('ad'),('af'); +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6); +INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 61 +ad 6164 +ae 6165 +Æ C386 +ä C3A4 +æ C3A6 +af 6166 +e 65 +o 6F +od 6F64 +oe 6F65 +ö C3B6 +Œ C592 +œ C593 +of 6F66 +s 73 +ss 7373 +ß C39F +u 75 +ud 7564 +ue 7565 +ü C3BC +uf 7566 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a +ad +ae,Æ,ä,æ +af +e +o +od +oe,ö,Œ,œ +of +s +ss,ß +u +ud +ue,ü +uf +SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1); +s1 hex(s1) hex(weight_string(s1)) +a 61 0E33 +ad 6164 0E330E6D +ae 6165 0E330E8B +Æ C386 0E330E8B +ä C3A4 0E330E8B +æ C3A6 0E330E8B +af 6166 0E330EB9 +e 65 0E8B +o 6F 0F82 +od 6F64 0F820E6D +oe 6F65 0F820E8B +ö C3B6 0F820E8B +Œ C592 0F820E8B +œ C593 0F820E8B +of 6F66 0F820EB9 +s 73 0FEA +ss 7373 0FEA0FEA +ß C39F 0FEA0FEA +u 75 101F +ud 7564 101F0E6D +ue 7565 101F0E8B +ü C3BC 101F0E8B +uf 7566 101F0EB9 +SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1); +s1 hex(s1) +ae 6165 +Æ C386 +ä C3A4 +æ C3A6 +drop table t1; +"END ctype_german.inc" +# +# WL#2673 Unicode Collation Algorithm new version +# +SET NAMES utf8mb4 COLLATE utf8mb4_unicode_520_ci; +CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A); +INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C); +INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E); +INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242); +INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244); +INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246); +INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248); +INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A); +INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C); +INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E); +INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B); +INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289); +INSERT INTO t1 VALUES (_utf32 0x028C); +INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C); +INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD); +INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF); +INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF); +INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7); +INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB); +INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD); +INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF); +INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511); +INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513); +INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1); +INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3); +INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5); +INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7); +INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01); +INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03); +INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05); +INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07); +INSERT INTO t1 VALUES (_utf32 0x1D7D); +INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E); +INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184); +INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81); +INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83); +INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85); +INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87); +INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89); +INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B); +INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D); +INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F); +INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61); +INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63); +INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65); +INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67); +INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69); +INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B); +INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75); +INSERT INTO t1 VALUES (_utf32 0x2C76); +INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01); +INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03); +INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05); +INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07); +INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31); +INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33); +INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35); +INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37); +INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401); +INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403); +INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405); +INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407); +INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429); +INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B); +INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D); +INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F); +INSERT INTO t1 VALUES (_utf32 0x0370); +INSERT INTO t1 VALUES (_utf32 0x0371); +INSERT INTO t1 VALUES (_utf32 0x0372); +INSERT INTO t1 VALUES (_utf32 0x0373); +INSERT INTO t1 VALUES (_utf32 0x0514); +INSERT INTO t1 VALUES (_utf32 0x0515); +INSERT INTO t1 VALUES (_utf32 0x0516); +INSERT INTO t1 VALUES (_utf32 0x0517); +INSERT INTO t1 VALUES (_utf32 0xA640); +INSERT INTO t1 VALUES (_utf32 0xA641); +INSERT INTO t1 VALUES (_utf32 0xA642); +INSERT INTO t1 VALUES (_utf32 0xA643); +INSERT INTO t1 VALUES (_utf32 0xA722); +INSERT INTO t1 VALUES (_utf32 0xA723); +INSERT INTO t1 VALUES (_utf32 0xA724); +INSERT INTO t1 VALUES (_utf32 0xA725); +INSERT INTO t1 VALUES (_utf32 0xA726); +INSERT INTO t1 VALUES (_utf32 0xA727); +INSERT INTO t1 VALUES (_utf32 0xA728); +INSERT INTO t1 VALUES (_utf32 0xA729); +INSERT INTO t1 VALUES (_utf32 0xA72A); +INSERT INTO t1 VALUES (_utf32 0xA72B); +INSERT INTO t1 VALUES (_utf32 0x2CEB); +INSERT INTO t1 VALUES (_utf32 0x2CEC); +INSERT INTO t1 VALUES (_utf32 0x2CED); +INSERT INTO t1 VALUES (_utf32 0x2CEE); +SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c +FROM t1 ORDER BY c, BINARY c; +hex(c) hex(lower(c)) hex(upper(c)) hex(weight_string(c)) c +C8BA C8BA 1214 Ⱥ +E2B1A5 E2B1A5 C8BA 1214 ⱥ +C680 C680 C983 122D ƀ +C983 C680 C983 122D Ƀ +C8BB C8BC C8BB 1242 Ȼ +C8BC C8BC C8BB 1242 ȼ +E28683 E28684 E28683 124E Ↄ +E28684 E28684 E28683 124E ↄ +C986 C987 C986 1270 Ɇ +C987 C987 C986 1270 ɇ +E284B2 E2858E E284B2 12AE Ⅎ +E2858E E2858E E284B2 12AE ⅎ +E2B1A7 E2B1A8 E2B1A7 12E3 Ⱨ +E2B1A8 E2B1A8 E2B1A7 12E3 ⱨ +E2B1B5 E2B1B6 E2B1B5 12E4 Ⱶ +E2B1B6 E2B1B6 E2B1B5 12E4 ⱶ +EA9CA6 EA9CA7 EA9CA6 12E5 Ꜧ +EA9CA7 EA9CA7 EA9CA6 12E5 ꜧ +C988 C989 C988 130E Ɉ +C989 C989 C988 130E ɉ +E2B1A9 E2B1AA E2B1A9 1328 Ⱪ +E2B1AA E2B1AA E2B1A9 1328 ⱪ +C8BD C69A C8BD 133B Ƚ +E2B1A0 E2B1A1 E2B1A0 133F Ⱡ +E2B1A1 E2B1A1 E2B1A0 133F ⱡ +C9AB C9AB 1340 ɫ +E2B1A2 C9AB E2B1A2 1340 Ɫ +E1B5BD E1B5BD E2B1A3 13B8 ᵽ +E2B1A3 E1B5BD E2B1A3 13B8 Ᵽ +C98A C98B C98A 13D2 Ɋ +C98B C98B C98A 13D2 ɋ +C98C C98D C98C 13E4 Ɍ +C98D C98D C98C 13E4 ɍ +C9BD C9BD 13FC ɽ +E2B1A4 C9BD E2B1A4 13FC Ɽ +EA9CA8 EA9CA9 EA9CA8 143314AD Ꜩ +EA9CA9 EA9CA9 EA9CA8 143314AD ꜩ +C8BE C8BE 143C Ⱦ +E2B1A6 E2B1A6 C8BE 143C ⱦ +C984 CA89 C984 145B Ʉ +CA89 CA89 C984 145B ʉ +C985 CA8C C985 1489 Ʌ +CA8C CA8C C985 1489 ʌ +C98E C98F C98E 14A4 Ɏ +C98F C98F C98E 14A4 ɏ +E2B1AB E2B1AC E2B1AB 14C8 Ⱬ +E2B1AC E2B1AC E2B1AB 14C8 ⱬ +EA9CAA EA9CAB EA9CAA 14F3 Ꜫ +EA9CAB EA9CAB EA9CAA 14F3 ꜫ +C981 C982 C981 1506 Ɂ +C982 C982 C981 1506 ɂ +EA9CA2 EA9CA3 EA9CA2 150E Ꜣ +EA9CA3 EA9CA3 EA9CA2 150E ꜣ +EA9CA4 EA9CA5 EA9CA4 1518 Ꜥ +EA9CA5 EA9CA5 EA9CA4 1518 ꜥ +CDB0 CDB1 CDB0 154F Ͱ +CDB1 CDB1 CDB0 154F ͱ +CDBC CDBC CFBE 1564 ͼ +CFBE CDBC CFBE 1564 Ͼ +CDBB CDBB CFBD 1565 ͻ +CFBD CDBB CFBD 1565 Ͻ +CDBD CDBD CFBF 1566 ͽ +CFBF CDBD CFBF 1566 Ͽ +CDB2 CDB3 CDB2 156F Ͳ +CDB3 CDB3 CDB2 156F ͳ +E2B280 E2B281 E2B280 1571 Ⲁ +E2B281 E2B281 E2B280 1571 ⲁ +E2B282 E2B283 E2B282 1572 Ⲃ +E2B283 E2B283 E2B282 1572 ⲃ +E2B284 E2B285 E2B284 1573 Ⲅ +E2B285 E2B285 E2B284 1573 ⲅ +E2B286 E2B287 E2B286 1574 Ⲇ +E2B287 E2B287 E2B286 1574 ⲇ +E2B288 E2B289 E2B288 1575 Ⲉ +E2B289 E2B289 E2B288 1575 ⲉ +E2B28A E2B28B E2B28A 1577 Ⲋ +E2B28B E2B28B E2B28A 1577 ⲋ +E2B28C E2B28D E2B28C 1578 Ⲍ +E2B28D E2B28D E2B28C 1578 ⲍ +E2B28E E2B28F E2B28E 1579 Ⲏ +E2B28F E2B28F E2B28E 1579 ⲏ +E2B3AB E2B3AC E2B3AB 1591 Ⳬ +E2B3AC E2B3AC E2B3AB 1591 ⳬ +E2B3AD E2B3AE E2B3AD 15A0 Ⳮ +E2B3AE E2B3AE E2B3AD 15A0 ⳮ +D3BA D3BB D3BA 15D4 Ӻ +D3BB D3BB D3BA 15D4 ӻ +D3B6 D3B7 D3B6 15DC Ӷ +D3B7 D3B7 D3B6 15DC ӷ +EA9980 EA9981 EA9980 1611 Ꙁ +EA9981 EA9981 EA9980 1611 ꙁ +D490 D491 D490 1613 Ԑ +D491 D491 D490 1613 ԑ +EA9982 EA9983 EA9982 1618 Ꙃ +EA9983 EA9983 EA9982 1618 ꙃ +D492 D493 D492 1666 Ԓ +D493 D493 D492 1666 ԓ +D494 D495 D494 166E Ԕ +D495 D495 D494 166E ԕ +D496 D497 D496 16B7 Ԗ +D497 D497 D496 16B7 ԗ +D3BC D3BD D3BC 16F9 Ӽ +D3BD D3BD D3BC 16F9 ӽ +D3BE D3BF D3BE 16FD Ӿ +D3BF D3BF D3BE 16FD ӿ +D380 D38F D380 17B1 Ӏ +D38F D38F D380 17B1 ӏ +E2B080 E2B0B0 E2B080 17B5 Ⰰ +E2B0B0 E2B0B0 E2B080 17B5 ⰰ +E2B081 E2B0B1 E2B081 17B6 Ⰱ +E2B0B1 E2B0B1 E2B081 17B6 ⰱ +E2B082 E2B0B2 E2B082 17B7 Ⰲ +E2B0B2 E2B0B2 E2B082 17B7 ⰲ +E2B083 E2B0B3 E2B083 17B8 Ⰳ +E2B0B3 E2B0B3 E2B083 17B8 ⰳ +E2B084 E2B0B4 E2B084 17B9 Ⰴ +E2B0B4 E2B0B4 E2B084 17B9 ⰴ +E2B085 E2B0B5 E2B085 17BA Ⰵ +E2B0B5 E2B0B5 E2B085 17BA ⰵ +E2B086 E2B0B6 E2B086 17BB Ⰶ +E2B0B6 E2B0B6 E2B086 17BB ⰶ +E2B087 E2B0B7 E2B087 17BC Ⰷ +E2B0B7 E2B0B7 E2B087 17BC ⰷ +E182A0 E2B480 E182A0 17E5 Ⴀ +E2B480 E2B480 E182A0 17E5 ⴀ +E182A1 E2B481 E182A1 17E7 Ⴁ +E2B481 E2B481 E182A1 17E7 ⴁ +E182A2 E2B482 E182A2 17E9 Ⴂ +E2B482 E2B482 E182A2 17E9 ⴂ +E182A3 E2B483 E182A3 17EB Ⴃ +E2B483 E2B483 E182A3 17EB ⴃ +E182A4 E2B484 E182A4 17ED Ⴄ +E2B484 E2B484 E182A4 17ED ⴄ +E182A5 E2B485 E182A5 17EF Ⴅ +E2B485 E2B485 E182A5 17EF ⴅ +E182A6 E2B486 E182A6 17F1 Ⴆ +E2B486 E2B486 E182A6 17F1 ⴆ +E182A7 E2B487 E182A7 17F5 Ⴇ +E2B487 E2B487 E182A7 17F5 ⴇ +F0909080 F09090A8 F0909080 30D2 𐐀 +F09090A8 F09090A8 F0909080 30D2 𐐨 +F0909081 F09090A9 F0909081 30D3 𐐁 +F09090A9 F09090A9 F0909081 30D3 𐐩 +F0909082 F09090AA F0909082 30D4 𐐂 +F09090AA F09090AA F0909082 30D4 𐐪 +F0909083 F09090AB F0909083 30D5 𐐃 +F09090AB F09090AB F0909083 30D5 𐐫 +F0909084 F09090AC F0909084 30D6 𐐄 +F09090AC F09090AC F0909084 30D6 𐐬 +F0909085 F09090AD F0909085 30D7 𐐅 +F09090AD F09090AD F0909085 30D7 𐐭 +F0909086 F09090AE F0909086 30D8 𐐆 +F09090AE F09090AE F0909086 30D8 𐐮 +F0909087 F09090AF F0909087 30D9 𐐇 +F09090AF F09090AF F0909087 30D9 𐐯 +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400)); +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 120F +61F0909080 120F30D2 +61EFBFBF 120FFBC1FFFF +61F48FBFBF 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 30D2 𐐀 +F09090A8 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 30D2 𐐀 +F09090A8 30D2 𐐨 +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`c`) AS `hex(c)` from `test`.`t1` where (`test`.`t1`.`c` like 'a%') order by `test`.`t1`.`c` +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 120F +61F0909080 120F30D2 +61EFBFBF 120FFBC1FFFF +61F48FBFBF 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 30D2 𐐀 +F09090A8 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 30D2 𐐀 +F09090A8 30D2 𐐨 +DROP TABLE t1; +# +# Bug #16204175 : COLLATION NAME MISSING FROM LOG MESSAGES +# ABOUT LDML DEFINITION PROBLEMS +# +# +# Restart the server with a collation with invalid grammar rules. +# restart:--character-sets-dir=MYSQL_TEST_DIR/std_data/bug16204175/ +# Check whether the new collation is loaded after restart +SHOW COLLATION LIKE 'utf8_test'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8_test utf8 999 8 PAD SPACE +# Create a table with the unknown collation. +CREATE TABLE t1(id INT PRIMARY KEY, c CHAR(1) COLLATE utf8_test); +ERROR HY000: Unknown collation: 'utf8_test' +# Below error is caused as a result of this test. The error message +# contains collation name which is added as a part of the fix. +call mtr.add_suppression("Shift expected at '' for COLLATION : utf8_test"); +# +# Restart server with original character sets dir: +# restart:--character-sets-dir=MYSQL_CHARSETSDIR +# +# End of 5.6 tests +# +SET NAMES utf8mb4; +CREATE TABLE t1 ( +f1 CHAR(4) NOT NULL +); +INSERT INTO t1 VALUES ('é'); +INSERT INTO t1 VALUES (_utf16 0x00650301); +SELECT DISTINCT f1 FROM t1; +f1 +é +SELECT SQL_BIG_RESULT DISTINCT f1 FROM t1; +f1 +é +DROP TABLE t1; +SET NAMES DEFAULT; +# +# Bug #27578340: INCONSISTENT RESULTS FOR SELECTS FROM TABLE WITH CHAR(N) COLUMN +# AND NO_PAD COLLATION +# +CREATE TABLE t1 ( +f1 CHAR(20) COLLATE utf8mb4_0900_ai_ci # A NO PAD collation. +); +INSERT INTO t1 VALUES ('ABC '); +INSERT INTO t1 VALUES ('XYZ'); +INSERT INTO t1 VALUES ('XYZ '); +INSERT INTO t1 VALUES ('ABC '); +# +# We should get the same results with and without an index. +# The former should match both XYZ values, the latter should match nothing. +# This is because CHAR conceptually never stores trailing spaces (in MySQL). +# +SELECT CONCAT(f1, '|') FROM t1 WHERE f1 = 'XYZ'; +CONCAT(f1, '|') +XYZ| +XYZ| +SELECT CONCAT(f1, '|') FROM t1 WHERE f1 = 'XYZ '; +CONCAT(f1, '|') +CREATE INDEX f1_index ON t1 ( f1 ); +SELECT CONCAT(f1, '|') FROM t1 WHERE f1 = 'XYZ'; +CONCAT(f1, '|') +XYZ| +XYZ| +SELECT CONCAT(f1, '|') FROM t1 WHERE f1 = 'XYZ '; +CONCAT(f1, '|') +DROP TABLE t1; +# +# Bug #28691605 ASSERTION `NUM_CODEPOINTS >= SCANNER.GET_CHAR_INDEX()' FAILED. +# +CREATE TABLE t1(c1 float); +INSERT INTO t1 VALUES +(-9999999999999), +(-99999999999999), +(-999999999999999), +(-9999999999999999); +SELECT GROUP_CONCAT(c1) FROM t1 GROUP BY c1 COLLATE utf8_icelandic_ci; +GROUP_CONCAT(c1) +-1e13 +-1e14 +-1e15 +-1e16 +DROP TABLE t1; +CREATE TABLE t1double(c1 double); +INSERT INTO t1double values(0.00000000000002123456789123456789); +SELECT c1 FROM t1double; +c1 +0.000000000000021234567891234568 +SELECT CONCAT(c1) FROM t1double; +CONCAT(c1) +2.1234567891234568e-14 +SELECT CAST(CONCAT(c1) AS DOUBLE) FROM t1double; +CAST(CONCAT(c1) AS DOUBLE) +0.000000000000021234567891234568 +SELECT GROUP_CONCAT(c1) FROM t1double GROUP BY c1 COLLATE utf8_icelandic_ci; +GROUP_CONCAT(c1) +2.1234567891234568e-14 +DROP TABLE t1double; +# +# Bug #32385934 ASSERTION `NUM_CODEPOINTS >= SCANNER.GET_CHAR_INDEX()' +# FAILED|CTYPE-UCA.CC +# +CREATE TABLE t1 ( +col_real_key double DEFAULT NULL, +col_bigint_key bigint DEFAULT NULL +); +INSERT INTO t1 VALUES (-20162.341,8262411111801246601); +SELECT alias1.col_real_key / alias1.col_bigint_key AS field1, +alias1.col_bigint_key AS field2 +FROM t1 AS alias1 +ORDER BY LEAST(field2, field1 COLLATE utf8mb4_croatian_ci); +field1 field2 +-0.000000000000002440249066183843 8262411111801246601 +DROP TABLE t1; diff --git a/mysql-test/r/ctype_ucs.result-pq b/mysql-test/r/ctype_ucs.result-pq new file mode 100644 index 000000000..964108dce --- /dev/null +++ b/mysql-test/r/ctype_ucs.result-pq @@ -0,0 +1,4459 @@ +DROP TABLE IF EXISTS t1; +SET @test_character_set= 'ucs2'; +SET @test_collation= 'ucs2_general_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) ucs2_general_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) ucs2_general_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=ucs2 +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +SET NAMES latin1; +SET CHARACTER SET koi8r; +SET character_set_connection=ucs2; +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +0 1 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +0 0 1 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +0 1 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +0 0 1 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 1 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +create table t1 (a varchar(2) character set ucs2 collate ucs2_bin, key(a)); +insert into t1 values ('A'),('A'),('B'),('C'),('D'),('A\t'); +insert into t1 values ('A\0'),('A\0'),('A\0'),('A\0'),('AZ'); +select hex(a) from t1 where a like 'A_' order by a; +hex(a) +00410000 +00410000 +00410000 +00410000 +00410009 +0041005A +select hex(a) from t1 ignore key(a) where a like 'A_' order by a; +hex(a) +00410000 +00410000 +00410000 +00410000 +00410009 +0041005A +drop table t1; +CREATE TABLE t1 (word VARCHAR(64) CHARACTER SET ucs2, word2 CHAR(64) CHARACTER SET ucs2); +INSERT INTO t1 VALUES (_koi8r'',_koi8r''), (X'2004',X'2004'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +0420 +2004 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +0420 +2004 +DELETE FROM t1; +INSERT INTO t1 VALUES (X'042000200020',X'042000200020'), (X'200400200020', X'200400200020'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +042000200020 +200400200020 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +0420 +2004 +DROP TABLE t1; +SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'0421'); +LPAD(_ucs2 X'0420',10,_ucs2 X'0421') + +SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'04210422'); +LPAD(_ucs2 X'0420',10,_ucs2 X'04210422') + +SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'042104220423'); +LPAD(_ucs2 X'0420',10,_ucs2 X'042104220423') + +SELECT LPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423'); +LPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423') + +SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'0421'); +RPAD(_ucs2 X'0420',10,_ucs2 X'0421') + +SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'04210422'); +RPAD(_ucs2 X'0420',10,_ucs2 X'04210422') + +SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'042104220423'); +RPAD(_ucs2 X'0420',10,_ucs2 X'042104220423') + +SELECT RPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423'); +RPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423') + +CREATE TABLE t1 SELECT +LPAD(_ucs2 X'0420',10,_ucs2 X'0421') l, +RPAD(_ucs2 X'0420',10,_ucs2 X'0421') r; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `l` varchar(10) CHARACTER SET ucs2 DEFAULT NULL, + `r` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug #51876 : crash/memory underrun when loading data with ucs2 +# and reverse() function +# +# Problem # 1 (original report): wrong parsing of ucs2 data +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +# should return 2 zeroes (as the value is truncated) +SELECT * FROM t1; +a +0 +1 +DROP TABLE t1; +# Problem # 2 : if you write and read ucs2 data to a file they're lost +SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +CREATE TABLE t1(a INT); +LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2 +(@b) SET a=REVERSE(@b); +# should return 0 and 1 (10 reversed) +SELECT * FROM t1; +a +0 +1 +DROP TABLE t1; +create table t2(f1 Char(30)); +insert into t2 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t2; +lpad(f1, 12, "-o-/") +-o-/-o103000 +-o-/22720000 +-o-/-3401200 +-o-/-o-78000 +drop table t2; +SET NAMES koi8r; +SET character_set_connection=ucs2; +select @@collation_connection; +@@collation_connection +ucs2_general_ci +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET ucs2 DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 23 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%') +explain select * from t1 where a like concat('abc','%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 23 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like (concat('abc','%'))) +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +select 'AA' like 'AA'; +'AA' like 'AA' +1 +select 'AA' like 'A%A'; +'AA' like 'A%A' +1 +select 'AA' like 'A%%A'; +'AA' like 'A%%A' +1 +select 'AA' like 'AA%'; +'AA' like 'AA%' +1 +select 'AA' like '%AA%'; +'AA' like '%AA%' +1 +select 'AA' like '%A'; +'AA' like '%A' +1 +select 'AA' like '%AA'; +'AA' like '%AA' +1 +select 'AA' like 'A%A%'; +'AA' like 'A%A%' +1 +select 'AA' like '_%_%'; +'AA' like '_%_%' +1 +select 'AA' like '%A%A'; +'AA' like '%A%A' +1 +select 'AAA'like 'A%A%A'; +'AAA'like 'A%A%A' +1 +select 'AZ' like 'AZ'; +'AZ' like 'AZ' +1 +select 'AZ' like 'A%Z'; +'AZ' like 'A%Z' +1 +select 'AZ' like 'A%%Z'; +'AZ' like 'A%%Z' +1 +select 'AZ' like 'AZ%'; +'AZ' like 'AZ%' +1 +select 'AZ' like '%AZ%'; +'AZ' like '%AZ%' +1 +select 'AZ' like '%Z'; +'AZ' like '%Z' +1 +select 'AZ' like '%AZ'; +'AZ' like '%AZ' +1 +select 'AZ' like 'A%Z%'; +'AZ' like 'A%Z%' +1 +select 'AZ' like '_%_%'; +'AZ' like '_%_%' +1 +select 'AZ' like '%A%Z'; +'AZ' like '%A%Z' +1 +select 'AZ' like 'A_'; +'AZ' like 'A_' +1 +select 'AZ' like '_Z'; +'AZ' like '_Z' +1 +select 'AMZ'like 'A%M%Z'; +'AMZ'like 'A%M%Z' +1 +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2); +INSERT INTO t1 VALUES (''),(''),(''),(''),(''),(''); +INSERT INTO t1 VALUES (''),(''),(''),(''); +INSERT INTO t1 VALUES (''),(''),(''),(''); +INSERT INTO t1 VALUES (''),(''),(''),(''); +SELECT * FROM t1 WHERE a LIKE '%%'; +a + + + + + + + + + + + + + + + + + + +SELECT * FROM t1 WHERE a LIKE '%%'; +a + + + + + + + + + + + + + + + + + + +SELECT * FROM t1 WHERE a LIKE '%'; +a + + + + + + + + + + + + + + + + + + +SELECT * FROM t1 WHERE a LIKE '%' COLLATE ucs2_bin; +a + + +DROP TABLE t1; +select insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066); +insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066) +abc +select insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066); +insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066) +defc +SELECT HEX(_ucs2 0x0); +HEX(_ucs2 0x0) +0000 +SELECT HEX(_ucs2 0x01); +HEX(_ucs2 0x01) +0001 +SELECT HEX(_ucs2 0x012); +HEX(_ucs2 0x012) +0012 +SELECT HEX(_ucs2 0x0123); +HEX(_ucs2 0x0123) +0123 +SELECT HEX(_ucs2 0x01234); +HEX(_ucs2 0x01234) +00001234 +SELECT HEX(_ucs2 0x012345); +HEX(_ucs2 0x012345) +00012345 +SELECT HEX(_ucs2 0x0123456); +HEX(_ucs2 0x0123456) +00123456 +SELECT HEX(_ucs2 0x01234567); +HEX(_ucs2 0x01234567) +01234567 +SELECT HEX(_ucs2 0x012345678); +HEX(_ucs2 0x012345678) +000012345678 +SELECT HEX(_ucs2 0x0123456789); +HEX(_ucs2 0x0123456789) +000123456789 +SELECT HEX(_ucs2 0x0123456789A); +HEX(_ucs2 0x0123456789A) +00123456789A +SELECT HEX(_ucs2 0x0123456789AB); +HEX(_ucs2 0x0123456789AB) +0123456789AB +SELECT HEX(_ucs2 0x0123456789ABC); +HEX(_ucs2 0x0123456789ABC) +0000123456789ABC +SELECT HEX(_ucs2 0x0123456789ABCD); +HEX(_ucs2 0x0123456789ABCD) +000123456789ABCD +SELECT HEX(_ucs2 0x0123456789ABCDE); +HEX(_ucs2 0x0123456789ABCDE) +00123456789ABCDE +SELECT HEX(_ucs2 0x0123456789ABCDEF); +HEX(_ucs2 0x0123456789ABCDEF) +0123456789ABCDEF +SELECT hex(cast(0xAA as char character set ucs2)); +hex(cast(0xAA as char character set ucs2)) +00AA +SELECT hex(convert(0xAA using ucs2)); +hex(convert(0xAA using ucs2)) +00AA +CREATE TABLE t1 (a char(10) character set ucs2); +INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA); +SELECT HEX(a) FROM t1; +HEX(a) +000A +00AA +0AAA +AAAA +000AAAAA +DROP TABLE t1; +CREATE TABLE t1 (a varchar(10) character set ucs2); +INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA); +SELECT HEX(a) FROM t1; +HEX(a) +000A +00AA +0AAA +AAAA +000AAAAA +DROP TABLE t1; +CREATE TABLE t1 (a text character set ucs2); +INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA); +SELECT HEX(a) FROM t1; +HEX(a) +000A +00AA +0AAA +AAAA +000AAAAA +DROP TABLE t1; +CREATE TABLE t1 (a mediumtext character set ucs2); +INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA); +SELECT HEX(a) FROM t1; +HEX(a) +000A +00AA +0AAA +AAAA +000AAAAA +DROP TABLE t1; +CREATE TABLE t1 (a longtext character set ucs2); +INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA); +SELECT HEX(a) FROM t1; +HEX(a) +000A +00AA +0AAA +AAAA +000AAAAA +DROP TABLE t1; +create table t1 (s1 char character set `ucs2` collate `ucs2_czech_ci`); +insert into t1 values ('0'),('1'),('2'),('a'),('b'),('c'); +select s1 from t1 where s1 > 'a' order by s1; +s1 +b +c +drop table t1; +create table t1(a char(1)) default charset = ucs2; +insert into t1 values ('a'),('b'),('c'); +alter table t1 modify a char(5); +select a, hex(a) from t1; +a hex(a) +a 0061 +b 0062 +c 0063 +drop table t1; +set names latin1; +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using ucs2); +prepare stmt1 from @str2; +execute stmt1 using @ivar; +? +1234 +set names latin1; +create table t1 (a enum('x','y','z') character set ucs2); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z') CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +z 007A +alter table t1 change a a enum('x','y','z','d','e','','','') character set ucs2; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z','d','e','','','') CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('D'); +insert into t1 values ('E '); +insert into t1 values (''); +insert into t1 values (''); +insert into t1 values (''); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +z 007A +d 0064 +e 0065 + 00E4 + 00F6 + 00FC +drop table t1; +create table t1 (a set ('x','y','z','','','') character set ucs2); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` set('x','y','z','','','') CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +insert into t1 values ('x,y'); +insert into t1 values ('x,y,z,,,'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +x,y 0078002C0079 +z 007A +x,y,z,,, 0078002C0079002C007A002C00E4002C00F6002C00FC +drop table t1; +create table t1(a enum('a','b','c')) default character set ucs2; +insert into t1 values('a'),('b'),('c'); +alter table t1 add b char(1); +show warnings; +Level Code Message +select * from t1 order by a; +a b +a NULL +b NULL +c NULL +drop table t1; +SET collation_connection='ucs2_general_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +ucs2_general_ci 00610009 +ucs2_general_ci 0061 +ucs2_general_ci 00610020 +drop table t1; +select @@collation_connection; +@@collation_connection +ucs2_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +"BEGIN ctype_german.inc" +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +ucs2_general_ci +delete from t1; +INSERT INTO t1 VALUES ('ud'),('uf'); +INSERT INTO t1 VALUES ('od'),('of'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('ad'),('af'); +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6); +INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 0061 + 00E4 +ad 00610064 +ae 00610065 +af 00610066 +e 0065 +o 006F + 00F6 +od 006F0064 +oe 006F0065 +of 006F0066 +s 0073 + 00DF +ss 00730073 +u 0075 + 00FC +ud 00750064 +ue 00750065 +uf 00750066 + 00C6 + 00E6 + 0152 + 0153 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a, +ad +ae +af +e +o, +od +oe +of +s, +ss +u, +ud +ue +uf +, +, +SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1); +s1 hex(s1) hex(weight_string(s1)) +a 0061 0041 + 00E4 0041 +ad 00610064 00410044 +ae 00610065 00410045 +af 00610066 00410046 +e 0065 0045 +o 006F 004F + 00F6 004F +od 006F0064 004F0044 +oe 006F0065 004F0045 +of 006F0066 004F0046 +s 0073 0053 + 00DF 0053 +ss 00730073 00530053 +u 0075 0055 + 00FC 0055 +ud 00750064 00550044 +ue 00750065 00550045 +uf 00750066 00550046 + 00C6 00C6 + 00E6 00C6 + 0152 0152 + 0153 0152 +SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1); +s1 hex(s1) +ae 00610065 +drop table t1; +"END ctype_german.inc" +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F20025 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +DROP TABLE t1; +SET NAMES latin1; +SET collation_connection='ucs2_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +ucs2_bin 00610009 +ucs2_bin 0061 +ucs2_bin 00610020 +drop table t1; +select @@collation_connection; +@@collation_connection +ucs2_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F20025 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +2 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +3 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +4 F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2 NULL +DROP TABLE t1; +select hex(substr(_ucs2 0x00e400e50068,1)); +hex(substr(_ucs2 0x00e400e50068,1)) +00E400E50068 +select hex(substr(_ucs2 0x00e400e50068,2)); +hex(substr(_ucs2 0x00e400e50068,2)) +00E50068 +select hex(substr(_ucs2 0x00e400e50068,3)); +hex(substr(_ucs2 0x00e400e50068,3)) +0068 +select hex(substr(_ucs2 0x00e400e50068,-1)); +hex(substr(_ucs2 0x00e400e50068,-1)) +0068 +select hex(substr(_ucs2 0x00e400e50068,-2)); +hex(substr(_ucs2 0x00e400e50068,-2)) +00E50068 +select hex(substr(_ucs2 0x00e400e50068,-3)); +hex(substr(_ucs2 0x00e400e50068,-3)) +00E400E50068 +SET NAMES latin1; +SET collation_connection='ucs2_swedish_ci'; +CREATE TABLE t1 (Field1 int(10) default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('-1'); +SELECT * FROM t1; +Field1 +-1 +DROP TABLE t1; +CREATE TABLE t1 (Field1 int(10) unsigned default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES ('-1'); +Warnings: +Warning 1264 Out of range value for column 'Field1' at row 1 +DROP TABLE t1; +SET NAMES latin1; +SELECT CONVERT(103, CHAR(50) UNICODE); +CONVERT(103, CHAR(50) UNICODE) +103 +SELECT CONVERT(103.0, CHAR(50) UNICODE); +CONVERT(103.0, CHAR(50) UNICODE) +103.0 +SELECT CONVERT(-103, CHAR(50) UNICODE); +CONVERT(-103, CHAR(50) UNICODE) +-103 +SELECT CONVERT(-103.0, CHAR(50) UNICODE); +CONVERT(-103.0, CHAR(50) UNICODE) +-103.0 +create table t1(f1 varchar(5) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL) engine=InnoDB; +insert into t1 values('a'); +create index t1f1 on t1(f1); +select f1 from t1 where f1 like 'a%'; +f1 +a +drop table t1; +create table t1 (utext varchar(20) character set ucs2); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci); +INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ'); +SELECT id, MIN(s) FROM t1 GROUP BY id; +id MIN(s) +1 ZZZ +2 ZZZ +DROP TABLE t1; +drop table if exists bug20536; +set names latin1; +create table bug20536 (id bigint not null auto_increment primary key, name +varchar(255) character set ucs2 not null); +insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'"); +select md5(name) from bug20536; +md5(name) +f4b7ce8b45a20e3c4e84bef515d1525c +48d95db0d8305c2fe11548a3635c9385 +select sha1(name) from bug20536; +sha1(name) +e0b52f38deddb9f9e8d5336b153592794cb49baf +677d4d505355eb5b0549b865fcae4b7f0c28aef5 +select make_set(3, name, upper(name)) from bug20536; +make_set(3, name, upper(name)) +test1,TEST1 +'test\_2','TEST\_2' +select export_set(5, name, upper(name)) from bug20536; +export_set(5, name, upper(name)) +test1,TEST1,test1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1 +'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2' +select export_set(5, name, upper(name), ",", 5) from bug20536; +export_set(5, name, upper(name), ",", 5) +test1,TEST1,test1,TEST1,TEST1 +'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2' +CREATE TABLE t1 ( +status enum('active','passive') collate latin1_general_ci +NOT NULL default 'passive' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT 'passive' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +CREATE TABLE t2 ( +status enum('active','passive') collate ucs2_turkish_ci +NOT NULL default 'passive' +); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `status` enum('active','passive') CHARACTER SET ucs2 COLLATE ucs2_turkish_ci NOT NULL DEFAULT 'passive' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t2 ADD a int NOT NULL AFTER status; +DROP TABLE t1,t2; +select quote(name) from bug20536; +quote(name) +'test1' +'\'test\\_2\'' +drop table bug20536; +set names ucs2; +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2' +set names ucs2 collate ucs2_bin; +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2' +set character_set_client= ucs2; +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2' +set character_set_client= concat('ucs', substr('2', 1)); +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2' +End of 4.1 tests +CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +update t1 set b=a; +SELECT * FROM t1; +a b +1.1 1.100 +2.1 2.100 +DROP TABLE t1; +create table t1 (utext varchar(20) character set ucs2); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +set names latin1; +set character_set_connection=ucs2; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb') + H000 H4142 I51231 +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +hex(soundex('')) hex(soundex('he')) hex(soundex('hello all folks')) hex(soundex('#3556 in bugdb')) + 0048003000300030 00480034003100340032 004900350031003200330031 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select hex(soundex(_ucs2 0x041004110412)); +hex(soundex(_ucs2 0x041004110412)) +0410003000300030 +select hex(soundex(_ucs2 0x00BF00C0)); +hex(soundex(_ucs2 0x00BF00C0)) +00C0003000300030 +set names latin1; +create table t1(a blob, b text charset utf8, c text charset ucs2); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select data_type, character_octet_length, character_maximum_length +from information_schema.columns where table_name='t1'; +DATA_TYPE CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH +blob 65535 65535 +text 65535 32767 +text 65535 65535 +drop table t1; +create table t1 (a char(1) character set ucs2); +insert into t1 values ('a'),('b'),('c'); +select hex(group_concat(a)) from t1; +hex(group_concat(a)) +0061002C0062002C0063 +select collation(group_concat(a)) from t1; +collation(group_concat(a)) +ucs2_general_ci +drop table t1; +set names latin1; +create table t1 (a char(1) character set latin1); +insert into t1 values ('a'),('b'),('c'); +set character_set_connection=ucs2; +select hex(group_concat(a separator ',')) from t1; +hex(group_concat(a separator ',')) +612C622C63 +select collation(group_concat(a separator ',')) from t1; +collation(group_concat(a separator ',')) +latin1_swedish_ci +drop table t1; +set names latin1; +create table t1 (s1 char(1) character set ascii, s2 char(1) character set ucs2); +insert into t1 (s1) values (0x7f); +update t1 set s2 = s1; +select hex(s2) from t1; +hex(s2) +007F +select hex(convert(s1 using latin1)) from t1; +hex(convert(s1 using latin1)) +7F +drop table t1; +create table t1 (a varchar(15) character set ascii not null, b int); +insert into t1 values ('a',1); +select concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) from t1; +concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) +aa +select concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) from t1; +concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) +ab +select * from t1 where a=if(b<10,_ucs2 0x0061,_ucs2 0x0062); +a b +a 1 +select * from t1 where a=if(b>10,_ucs2 0x0061,_ucs2 0x0062); +a b +select concat(a,if(b<10,_ucs2 0x00C0,_ucs2 0x0062)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select concat(a,if(b>10,_ucs2 0x00C0,_ucs2 0x0062)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select concat(a,if(b<10,_ucs2 0x0062,_ucs2 0x00C0)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select concat(a,if(b>10,_ucs2 0x0062,_ucs2 0x00C0)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062); +ERROR HY000: Cannot convert string '\x00\xC0' from ucs2 to ascii +select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0); +a b +drop table t1; +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('a'); +SET @@sql_mode=pad_char_to_full_length; +Warnings: +Warning 3090 Changing sql mode 'PAD_CHAR_TO_FULL_LENGTH' is deprecated. It will be removed in a future release. +SELECT HEX(s1) FROM t1; +HEX(s1) +00610020002000200020 +SET @@sql_mode=default; +SELECT HEX(s1) FROM t1; +HEX(s1) +0061 +DROP TABLE t1; +set collation_connection=ucs2_general_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET ucs2 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +set names latin1; +select hex(char(0x41 using ucs2)); +hex(char(0x41 using ucs2)) +0041 +SET character_set_connection=ucs2; +SELECT CHARSET(DAYNAME(19700101)); +CHARSET(DAYNAME(19700101)) +ucs2 +SELECT CHARSET(MONTHNAME(19700101)); +CHARSET(MONTHNAME(19700101)) +ucs2 +SELECT LOWER(DAYNAME(19700101)); +LOWER(DAYNAME(19700101)) +thursday +SELECT LOWER(MONTHNAME(19700101)); +LOWER(MONTHNAME(19700101)) +january +SELECT UPPER(DAYNAME(19700101)); +UPPER(DAYNAME(19700101)) +THURSDAY +SELECT UPPER(MONTHNAME(19700101)); +UPPER(MONTHNAME(19700101)) +JANUARY +SELECT HEX(MONTHNAME(19700101)); +HEX(MONTHNAME(19700101)) +004A0061006E0075006100720079 +SELECT HEX(DAYNAME(19700101)); +HEX(DAYNAME(19700101)) +00540068007500720073006400610079 +SET LC_TIME_NAMES=ru_RU; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET character_set_connection=ucs2; +SELECT CHARSET(DAYNAME(19700101)); +CHARSET(DAYNAME(19700101)) +ucs2 +SELECT CHARSET(MONTHNAME(19700101)); +CHARSET(MONTHNAME(19700101)) +ucs2 +SELECT LOWER(DAYNAME(19700101)); +LOWER(DAYNAME(19700101)) +четверг +SELECT LOWER(MONTHNAME(19700101)); +LOWER(MONTHNAME(19700101)) +января +SELECT UPPER(DAYNAME(19700101)); +UPPER(DAYNAME(19700101)) +ЧЕТВЕРГ +SELECT UPPER(MONTHNAME(19700101)); +UPPER(MONTHNAME(19700101)) +ЯНВАРЯ +SELECT HEX(MONTHNAME(19700101)); +HEX(MONTHNAME(19700101)) +042F043D043204300440044F +SELECT HEX(DAYNAME(19700101)); +HEX(DAYNAME(19700101)) +0427043504420432043504400433 +SET character_set_connection=latin1; +# +# Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817 +# +CREATE TABLE t1 (a CHAR(1) CHARSET ascii, b CHAR(1) CHARSET latin1); +CREATE VIEW v1 AS SELECT 1 from t1 +WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1')); +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed. +# +SELECT HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850)); +HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850)) +00 +SELECT CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED); +CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: ''õ'' +End of 5.0 tests +# +# Start of 5.5 tests +# +SET NAMES latin1; +SET collation_connection=ucs2_general_ci; +# +# Start of WL#2649 Number-to-string conversions +# +select hex(concat(1)); +hex(concat(1)) +0031 +create table t1 as select concat(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +0031 +drop table t1; +select hex(concat(18446744073709551615)); +hex(concat(18446744073709551615)) +00310038003400340036003700340034003000370033003700300039003500350031003600310035 +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +00310038003400340036003700340034003000370033003700300039003500350031003600310035 +drop table t1; +select hex(concat(1.1)); +hex(concat(1.1)) +0031002E0031 +create table t1 as select concat(1.1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1; +hex(c1) +0031002E0031 +drop table t1; +select hex(concat('a', 1+2)), charset(concat(1+2)); +hex(concat('a', 1+2)) charset(concat(1+2)) +00610033 ucs2 +create table t1 as select concat(1+2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1-2)); +hex(concat(1-2)) +002D0031 +create table t1 as select concat(1-2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1*2)); +hex(concat(1*2)) +0032 +create table t1 as select concat(1*2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1/2)); +hex(concat(1/2)) +0030002E0035003000300030 +create table t1 as select concat(1/2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1 div 2)); +hex(concat(1 div 2)) +0030 +create table t1 as select concat(1 div 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1 % 2)); +hex(concat(1 % 2)) +0031 +create table t1 as select concat(1 % 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(-1)); +hex(concat(-1)) +002D0031 +create table t1 as select concat(-1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(-(1+2))); +hex(concat(-(1+2))) +002D0033 +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1|2)); +hex(concat(1|2)) +0033 +create table t1 as select concat(1|2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(1&2)); +hex(concat(1&2)) +0030 +create table t1 as select concat(1&2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(bit_count(12))); +hex(concat(bit_count(12))) +0032 +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(2<<1)); +hex(concat(2<<1)) +0034 +create table t1 as select concat(2<<1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(2>>1)); +hex(concat(2>>1)) +0031 +create table t1 as select concat(2>>1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(~0)); +hex(concat(~0)) +00310038003400340036003700340034003000370033003700300039003500350031003600310035 +create table t1 as select concat(~0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(3^2)); +hex(concat(3^2)) +0031 +create table t1 as select concat(3^2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(abs(-2))); +hex(concat(abs(-2))) +0032 +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(exp(2)),1)); +hex(left(concat(exp(2)),1)) +0037 +create table t1 as select concat(exp(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log(2)),1)); +hex(left(concat(log(2)),1)) +0030 +create table t1 as select concat(log(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log2(2)),1)); +hex(left(concat(log2(2)),1)) +0031 +create table t1 as select concat(log2(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(log10(2)),1)); +hex(left(concat(log10(2)),1)) +0030 +create table t1 as select concat(log10(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(sqrt(2)),1)); +hex(left(concat(sqrt(2)),1)) +0031 +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(pow(2,2)),1)); +hex(left(concat(pow(2,2)),1)) +0034 +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(acos(0.5)),1)); +hex(left(concat(acos(0.5)),1)) +0031 +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(asin(0.5)),1)); +hex(left(concat(asin(0.5)),1)) +0030 +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(atan(0.5)),1)); +hex(left(concat(atan(0.5)),1)) +0030 +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(cos(0.5)),1)); +hex(left(concat(cos(0.5)),1)) +0030 +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(sin(0.5)),1)); +hex(left(concat(sin(0.5)),1)) +0030 +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(tan(0.5)),1)); +hex(left(concat(tan(0.5)),1)) +0030 +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(degrees(0))); +hex(concat(degrees(0))) +0030 +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(radians(0))); +hex(concat(radians(0))) +0030 +create table t1 as select concat(radians(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ceiling(0.5))); +hex(concat(ceiling(0.5))) +0031 +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(floor(0.5))); +hex(concat(floor(0.5))) +0030 +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(round(0.5))); +hex(concat(round(0.5))) +0031 +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sign(0.5))); +hex(concat(sign(0.5))) +0031 +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(rand()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(length('a'))); +hex(concat(length('a'))) +0032 +create table t1 as select concat(length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(char_length('a'))); +hex(concat(char_length('a'))) +0031 +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(bit_length('a'))); +hex(concat(bit_length('a'))) +00310036 +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(coercibility('a'))); +hex(concat(coercibility('a'))) +0034 +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(locate('a','a'))); +hex(concat(locate('a','a'))) +0031 +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(field('c','a','b','c'))); +hex(concat(field('c','a','b','c'))) +0033 +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ascii(61))); +hex(concat(ascii(61))) +00350034 +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ord(61))); +hex(concat(ord(61))) +00350034 +create table t1 as select concat(ord(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(find_in_set('b','a,b,c,d'))); +hex(concat(find_in_set('b','a,b,c,d'))) +0032 +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select md5('a'), hex(md5('a')); +md5('a') hex(md5('a')) +760f753576f2955b0074758acb4d5fa6 00370036003000660037003500330035003700360066003200390035003500620030003000370034003700350038006100630062003400640035006600610036 +create table t1 as select md5('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(32) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select sha('a'), hex(sha('a')); +sha('a') hex(sha('a')) +3106600e0327ca77371f2526df794ed84322585c 0033003100300036003600300030006500300033003200370063006100370037003300370031006600320035003200360064006600370039003400650064003800340033003200320035003800350063 +create table t1 as select sha('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select sha1('a'), hex(sha1('a')); +sha1('a') hex(sha1('a')) +3106600e0327ca77371f2526df794ed84322585c 0033003100300036003600300030006500300033003200370063006100370037003300370031006600320035003200360064006600370039003400650064003800340033003200320035003800350063 +create table t1 as select sha1('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('-1' as signed))); +hex(concat(cast('-1' as signed))) +002D0031 +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('1' as unsigned))); +hex(concat(cast('1' as unsigned))) +0031 +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast(1/2 as decimal(5,5)))); +hex(concat(cast(1/2 as decimal(5,5)))) +0030002E00350030003000300030 +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as date))); +hex(concat(cast('2001-01-02 03:04:05' as date))) +0032003000300031002D00300031002D00300032 +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2001-01-02 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as time))); +hex(concat(cast('2001-01-02 03:04:05' as time))) +00300033003A00300034003A00300035 +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +03:04:05 +drop table t1; +select hex(concat(cast('2001-01-02' as datetime))); +hex(concat(cast('2001-01-02' as datetime))) +0032003000300031002D00300031002D00300032002000300030003A00300030003A00300030 +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2001-01-02 00:00:00 +drop table t1; +select hex(concat(least(1,2))); +hex(concat(least(1,2))) +0031 +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(greatest(1,2))); +hex(concat(greatest(1,2))) +0032 +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(case when 11 then 22 else 33 end)); +hex(concat(case when 11 then 22 else 33 end)) +00320032 +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(coalesce(1,2))); +hex(concat(coalesce(1,2))) +0031 +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat_ws(1,2,3)); +hex(concat_ws(1,2,3)) +003200310033 +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(group_concat(1,2,3)); +hex(group_concat(1,2,3)) +003100320033 +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(512) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(c1) from t1 order by c1; +hex(c1) +0031 +0061 +drop table t1; +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(benchmark(0,0))); +hex(concat(benchmark(0,0))) +0030 +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sleep(0))); +hex(concat(sleep(0))) +0030 +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(is_free_lock('xxxx'))); +hex(concat(is_free_lock('xxxx'))) +0031 +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(crc32(''))); +hex(concat(crc32(''))) +0030 +create table t1 as select concat(crc32('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(uncompressed_length(''))); +hex(concat(uncompressed_length(''))) +0030 +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(connection_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(inet_aton('127.1.1.1'))); +hex(concat(inet_aton('127.1.1.1'))) +0032003100330030003700370032003200320035 +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(inet_ntoa(2130772225))); +hex(concat(inet_ntoa(2130772225))) +003100320037002E0031002E0031002E0031 +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +c1 +127.1.1.1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(31) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select 1; +1 +1 +select hex(concat(row_count())); +hex(concat(row_count())) +002D0031 +create table t1 as select concat(row_count()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t2 ( f1 integer ); +insert into t2 values (1),(2),(3),(4); +select sql_calc_found_rows * from t2 limit 2; +f1 +1 +2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select hex(concat(found_rows())); +hex(concat(found_rows())) +0034 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +create table t1 as select concat(found_rows()) as c1; +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(uuid()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(36) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +coercibility(uuid()) coercibility(cast('a' as char character set latin1)) +4 2 +select charset(concat(uuid(), cast('a' as char character set latin1))); +charset(concat(uuid(), cast('a' as char character set latin1))) +latin1 +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(37) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=1)); +hex(concat(@a1:=1)) +0031 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +0032 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL, + `c2` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=1; +select hex(concat(@a2)); +hex(concat(@a2)) +0031 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL, + `c2` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=sqrt(1))); +hex(concat(@a1:=sqrt(1))) +0031 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=sqrt(1); +select hex(concat(@a2)); +hex(concat(@a2)) +0031 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@a1:=1.1)); +hex(concat(@a1:=1.1)) +0031002E0031 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select hex(c1) from t1; +hex(c1) +0031002E0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL, + `c2` decimal(2,1) NOT NULL DEFAULT '0.0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a2=1.1; +select hex(concat(@a2)); +hex(concat(@a2)) +0031002E0031 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +0031002E0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(67) CHARACTER SET ucs2 DEFAULT NULL, + `c2` decimal(65,30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(@@ft_max_word_len)); +hex(concat(@@ft_max_word_len)) +00380034 +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +hex(c1) +00380034 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a'='a' IS TRUE)); +hex(concat('a'='a' IS TRUE)) +0031 +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a'='a' IS NOT TRUE)); +hex(concat('a'='a' IS NOT TRUE)) +0030 +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(NOT 'a'='a')); +hex(concat(NOT 'a'='a')) +0030 +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' IS NULL)); +hex(concat('a' IS NULL)) +0030 +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' IS NOT NULL)); +hex(concat('a' IS NOT NULL)) +0031 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' rlike 'a')); +hex(concat('a' rlike 'a')) +0031 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(strcmp('a','b'))); +hex(concat(strcmp('a','b'))) +002D0031 +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' like 'a')); +hex(concat('a' like 'a')) +0031 +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' between 'b' and 'c')); +hex(concat('a' between 'b' and 'c')) +0030 +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat('a' in ('a','b'))); +hex(concat('a' in ('a','b'))) +0031 +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +hex(concat(interval(23, 1, 15, 17, 30, 44, 200))) +0033 +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +0030 +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +select hex(ifnull(1,'a')); +hex(ifnull(1,'a')) +0031 +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ifnull(1,1))); +hex(concat(ifnull(1,1))) +0031 +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ifnull(1.1,1.1))); +hex(concat(ifnull(1.1,1.1))) +0031002E0031 +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(if(1,'b',1)); +hex(if(1,'b',1)) +0062 +create table t1 as select if(1,'b',1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(if(1,1,'b')); +hex(if(1,1,'b')) +0031 +create table t1 as select if(1,1,'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(if(1,1,1))); +hex(concat(if(1,1,1))) +0031 +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(nullif(1,2))); +hex(concat(nullif(1,2))) +0031 +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Dimension(ST_GeomFromText('LINESTRING(0 0,10 10)')))); +hex(concat(ST_Dimension(ST_GeomFromText('LINESTRING(0 0,10 10)')))) +0031 +create table t1 as select concat(ST_Dimension(ST_GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +ERROR 22023: Invalid GIS data provided to function st_geomfromtext. +select hex(concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +0032 +create table t1 as select concat(ST_NumGeometries(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)')))); +hex(concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)')))) +0032 +create table t1 as select concat(ST_NumPoints(ST_LineFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +0030 +create table t1 as select concat(ST_SRID(ST_MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +hex(concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))) +0031 +create table t1 as select concat(ST_NumInteriorRings(ST_PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsEmpty(ST_GeomFromText('POINT(1 1)')))); +hex(concat(ST_IsEmpty(ST_GeomFromText('POINT(1 1)')))) +0030 +create table t1 as select concat(ST_IsEmpty(ST_GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsSimple(ST_GeomFromText('POINT(1 1)')))); +hex(concat(ST_IsSimple(ST_GeomFromText('POINT(1 1)')))) +0031 +create table t1 as select concat(ST_IsSimple(ST_GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)')))); +hex(concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)')))) +0030 +create table t1 as select concat(ST_IsClosed(ST_GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)')))); +hex(concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)')))) +0031 +create table t1 as select concat(MBREquals(ST_GeomFromText('Point(1 1)'),ST_GeomFromText('Point(1 1)'))) as c1; +drop table t1; +select hex(concat(ST_X(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_X(ST_GeomFromText('Point(1 2)')))) +0031 +create table t1 as select concat(ST_X(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Y(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_Y(ST_GeomFromText('Point(1 2)')))) +0032 +create table t1 as select concat(ST_X(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Length(ST_GeomFromText('LineString(1 2,2 2)')))); +hex(concat(ST_Length(ST_GeomFromText('LineString(1 2,2 2)')))) +0031 +create table t1 as select concat(ST_Length(ST_GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +hex(concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))) +0031 +create table t1 as select concat(ST_Area(ST_GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_GeometryType(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_GeometryType(ST_GeomFromText('Point(1 2)')))) +0050004F0049004E0054 +create table t1 as select concat(ST_GeometryType(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(15) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(ST_AsText(ST_GeomFromText('Point(1 2)')))); +hex(concat(ST_AsText(ST_GeomFromText('Point(1 2)')))) +0050004F0049004E005400280031002000320029 +create table t1 as select concat(ST_AsText(ST_GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` longtext CHARACTER SET ucs2 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(period_add(200902, 2))); +hex(concat(period_add(200902, 2))) +003200300030003900300034 +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = ''; +select hex(concat(period_diff(200902, 200802))); +hex(concat(period_diff(200902, 200802))) +00310032 +create table t1 as select concat(period_add(200902, 200802)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = default; +select hex(concat(to_days(20090224))); +hex(concat(to_days(20090224))) +003700330033003800320037 +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofmonth(20090224))); +hex(concat(dayofmonth(20090224))) +00320034 +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofyear(20090224))); +hex(concat(dayofyear(20090224))) +00350035 +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(hour('10:11:12'))); +hex(concat(hour('10:11:12'))) +00310030 +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(minute('10:11:12'))); +hex(concat(minute('10:11:12'))) +00310031 +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(second('10:11:12'))); +hex(concat(second('10:11:12'))) +00310032 +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(quarter(20090224))); +hex(concat(quarter(20090224))) +0031 +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(week(20090224))); +hex(concat(week(20090224))) +0038 +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(yearweek(20090224))); +hex(concat(yearweek(20090224))) +003200300030003900300038 +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(year(20090224))); +hex(concat(year(20090224))) +0032003000300039 +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(5) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(weekday(20090224))); +hex(concat(weekday(20090224))) +0031 +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(dayofweek(20090224))); +hex(concat(dayofweek(20090224))) +0033 +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(unix_timestamp(20090224))); +hex(concat(unix_timestamp(20090224))) +0031003200330035003400320032003800300030 +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(time_to_sec('10:11:12'))); +hex(concat(time_to_sec('10:11:12'))) +00330036003600370032 +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(extract(year from 20090702))); +hex(concat(extract(year from 20090702))) +0032003000300039 +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(5) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(microsecond('12:00:00.123456'))); +hex(concat(microsecond('12:00:00.123456'))) +003100320033003400350036 +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(month(20090224))); +hex(concat(month(20090224))) +0032 +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select c1, hex(c1) from t1; +c1 hex(c1) +2003-02-28 0032003000300033002D00300032002D00320038 +drop table t1; +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select c1, hex(c1) from t1; +c1 hex(c1) +2000-07-03 0032003000300030002D00300037002D00300033 +drop table t1; +create table t1 as select concat(curdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(utc_date()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(curtime()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +c1 hex(c1) +2008-07-18 0032003000300038002D00300037002D00310038 +08:42:04 00300038003A00340032003A00300034 +drop table t1; +create table t1 as select concat(utc_time()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(sec_to_time(2378))); +hex(concat(sec_to_time(2378))) +00300030003A00330039003A00330038 +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))) +00320034003A00300030003A00300030 +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(maketime(10,11,12))); +hex(concat(maketime(10,11,12))) +00310030003A00310031003A00310032 +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(get_format(DATE,'USA')); +hex(get_format(DATE,'USA')) +0025006D002E00250064002E00250059 +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(17) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(concat(from_unixtime(1111885200)),4)); +hex(left(concat(from_unixtime(1111885200)),4)) +0032003000300035 +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))) +0032003000300033002D00310032002D00330031002000320030003A00300030003A00300030 +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))) +0032003000300034002D00300031002D00300032002000310032003A00300030003A00300030 +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2004-01-02 12:00:00 +drop table t1; +select hex(concat(makedate(2009,1))); +hex(concat(makedate(2009,1))) +0032003000300039002D00300031002D00300031 +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +c1 +2009-01-01 +drop table t1; +create table t1 as select concat(now()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(sysdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(addtime('00:00:00','11:22:33'))); +hex(concat(addtime('00:00:00','11:22:33'))) +00310031003A00320032003A00330033 +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(concat(subtime('23:59:59','11:22:33'))); +hex(concat(subtime('23:59:59','11:22:33'))) +00310032003A00330037003A00320036 +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(elt(1,2,3)); +hex(elt(1,2,3)) +0032 +create table t1 as select elt(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(export_set(1,2,3,4,2)); +hex(export_set(1,2,3,4,2)) +003200340033 +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(127) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(insert(1133,3,0,22)); +hex(insert(1133,3,0,22)) +003100310032003200330033 +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lcase(123)); +hex(lcase(123)) +003100320033 +create table t1 as select lcase(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(left(123,1)); +hex(left(123,1)) +0031 +create table t1 as select left(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lower(123)); +hex(lower(123)) +003100320033 +create table t1 as select lower(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(lpad(1,2,0)); +hex(lpad(1,2,0)) +00300031 +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(ltrim(1)); +hex(ltrim(1)) +0031 +create table t1 as select ltrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(mid(1,1,1)); +hex(mid(1,1,1)) +0031 +create table t1 as select mid(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(repeat(1,2)); +hex(repeat(1,2)) +00310031 +create table t1 as select repeat(1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(replace(1,1,2)); +hex(replace(1,1,2)) +0032 +create table t1 as select replace(1,1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(reverse(12)); +hex(reverse(12)) +00320031 +create table t1 as select reverse(12) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(right(123,1)); +hex(right(123,1)) +0033 +create table t1 as select right(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(rpad(1,2,0)); +hex(rpad(1,2,0)) +00310030 +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(rtrim(1)); +hex(rtrim(1)) +0031 +create table t1 as select rtrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(soundex(1)); +hex(soundex(1)) + +create table t1 as select soundex(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(substring(1,1,1)); +hex(substring(1,1,1)) +0031 +create table t1 as select substring(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(trim(1)); +hex(trim(1)) +0031 +create table t1 as select trim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(ucase(1)); +hex(ucase(1)) +0031 +create table t1 as select ucase(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select hex(upper(1)); +hex(upper(1)) +0031 +create table t1 as select upper(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +a hex(a) +1.1 0031002E0031 +2.1 0032002E0031 +update t1 set a= a + 0.1; +select a, hex(a) from t1; +a hex(a) +1.2000000000000002 0031002E0032003000300030003000300030003000300030003000300030003000300032 +2.2 0032002E0032 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a tinyint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +003000300031 001 +003000310030 010 +003100300030 100 +drop table t1; +create table t1 (a tinyint(4) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +0030003000300031 0001 +0030003000310030 0010 +0030003100300030 0100 +drop table t1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +hex(concat(a)) +003100320033002E00340035 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(6) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a smallint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300031 00001 +00300030003000310030 00010 +00300030003100300030 00100 +00300031003000300030 01000 +00310030003000300030 10000 +drop table t1; +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(9) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a mediumint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300030003000300031 00000001 +00300030003000300030003000310030 00000010 +00300030003000300030003100300030 00000100 +00300030003000300031003000300030 00001000 +00300030003000310030003000300030 00010000 +drop table t1; +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(11) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a int zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +0030003000300030003000300030003000300031 0000000001 +0030003000300030003000300030003000310030 0000000010 +0030003000300030003000300030003100300030 0000000100 +0030003000300030003000300031003000300030 0000001000 +0030003000300030003000310030003000300030 0000010000 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(20) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a bigint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300030003000300030003000300030003000300030003000300030003000300031 00000000000000000001 +00300030003000300030003000300030003000300030003000300030003000300030003000310030 00000000000000000010 +00300030003000300030003000300030003000300030003000300030003000300030003100300030 00000000000000000100 +00300030003000300030003000300030003000300030003000300030003000300031003000300030 00000000000000001000 +00300030003000300030003000300030003000300030003000300030003000310030003000300030 00000000000000010000 +drop table t1; +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +003100320033002E003400350036 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +0030003000300030003000300030003000300031002E0031 0000000001.1 +0030003000300030003000300030003000310030002E0031 0000000010.1 +0030003000300030003000300030003100300030002E0031 0000000100.1 +0030003000300030003000300031003000300030002E0031 0000001000.1 +0030003000300030003000310030003000300030002E0031 0000010000.1 +drop table t1; +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +003100320033002E003400350036 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a double zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300030003000300030003000300030003000300030003000300030003000300031002E0031 00000000000000000001.1 +00300030003000300030003000300030003000300030003000300030003000300030003000310030002E0031 00000000000000000010.1 +00300030003000300030003000300030003000300030003000300030003000300030003100300030002E0031 00000000000000000100.1 +00300030003000300030003000300030003000300030003000300030003000300031003000300030002E0031 00000000000000001000.1 +00300030003000300030003000300030003000300030003000300030003000310030003000300030002E0031 00000000000000010000.1 +drop table t1; +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0032003000300031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a bit(64)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0000000000000001 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(64) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +hex(concat(a)) +0030003000300030002D00300030002D00300030002000300030003A00300030003A00300030 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0031003900380030002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +select concat(a) from t1; +concat(a) +0000-00-00 00:00:00 +2001-02-03 04:05:06 +1980-02-03 04:05:06 +2001-02-03 04:05:06 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +hex(concat(a)) +0032003000300031002D00300032002D00300033 +0032003000300031002D00300032002D00300033 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +hex(concat(a)) +00300030003A00300030003A00300031 +00300031003A00300032003A00300033 +select concat(a) from t1; +concat(a) +00:00:01 +01:02:03 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +hex(concat(a)) +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a tinyint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(3) YES NULL +select hex(a) from v1; +hex(a) +003000300031 +003000310030 +003100300030 +drop table t1; +drop view v1; +create table t1 (a tinyint(30) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(30) YES NULL +select hex(a) from v1; +hex(a) +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300031 +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000310030 +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003100300030 +drop table t1; +drop view v1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +003100320033002E00340035 +drop table t1; +drop view v1; +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(6) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a smallint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(5) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300031 +00300030003000310030 +00300030003100300030 +00300031003000300030 +00310030003000300030 +drop table t1; +drop view v1; +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(9) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a mediumint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300030003000300031 +00300030003000300030003000310030 +00300030003000300030003100300030 +00300030003000300031003000300030 +00300030003000310030003000300030 +drop table t1; +drop view v1; +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(11) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a int zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +0030003000300030003000300030003000300031 +0030003000300030003000300030003000310030 +0030003000300030003000300030003100300030 +0030003000300030003000300031003000300030 +0030003000300030003000310030003000300030 +drop table t1; +drop view v1; +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a bigint zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300030003000300030003000300030003000300030003000300030003000300031 +00300030003000300030003000300030003000300030003000300030003000300030003000310030 +00300030003000300030003000300030003000300030003000300030003000300030003100300030 +00300030003000300030003000300030003000300030003000300030003000300031003000300030 +00300030003000300030003000300030003000300030003000300030003000310030003000300030 +drop table t1; +drop view v1; +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +003100320033002E003400350036 +drop table t1; +drop view v1; +create table t1 (a float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +0030003000300030003000300030003000300031002E0031 +0030003000300030003000300030003000310030002E0031 +0030003000300030003000300030003100300030002E0031 +0030003000300030003000300031003000300030002E0031 +0030003000300030003000310030003000300030002E0031 +drop table t1; +drop view v1; +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +concat(a) +123.456 +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +003100320033002E003400350036 +drop table t1; +drop view v1; +create table t1 (a double zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300030003000300030003000300030003000300030003000300030003000300031002E0031 +00300030003000300030003000300030003000300030003000300030003000300030003000310030002E0031 +00300030003000300030003000300030003000300030003000300030003000300030003100300030002E0031 +00300030003000300030003000300030003000300030003000300030003000300031003000300030002E0031 +00300030003000300030003000300030003000300030003000300030003000310030003000300030002E0031 +drop table t1; +drop view v1; +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +0032003000300031 +drop table t1; +drop view v1; +create table t1 (a bit(64)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(64) YES NULL +select hex(a) from v1; +hex(a) +0000000000000001 +drop table t1; +drop view v1; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) YES NULL +select hex(a) from v1; +hex(a) +0030003000300030002D00300030002D00300030002000300030003A00300030003A00300030 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0031003900380030002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +drop table t1; +drop view v1; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +0032003000300031002D00300032002D00300033 +0032003000300031002D00300032002D00300033 +drop table t1; +drop view v1; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +00300030003A00300030003A00300031 +00300031003A00300032003A00300033 +drop table t1; +drop view v1; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) YES NULL +select hex(a) from v1; +hex(a) +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +drop table t1; +drop view v1; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +set @a= f1(1); +select hex(@a); +hex(@a) +1 +select hex(concat(f1(1))); +hex(concat(f1(1))) +31 +create table t1 as select f1(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(11) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` decimal(18,2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(20) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` float DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(12) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(12) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +hex(@a) +323030312D30312D3032 +select hex(concat(f1(cast('2001-01-02' as date)))); +hex(concat(f1(cast('2001-01-02' as date)))) +323030312D30312D3032 +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` date DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(10) YES NULL +drop table t1; +drop view v1; +drop function f1; +# +# End of WL#2649 Number-to-string conversions +# +# +# Bug#54668 User variable assignments get wrong type +# +SET @ST_X=md5('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +ucs2 ucs2_general_ci +SET @ST_X=sha('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +ucs2 ucs2_general_ci +SET @ST_X=sha1('a'); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +ucs2 ucs2_general_ci +SET @ST_X=ST_astext(point(1,2)); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +ucs2 ucs2_general_ci +SET @ST_X=ST_AsWKT(point(1,2)); +SELECT charset(@ST_X), collation(@ST_X); +charset(@ST_X) collation(@ST_X) +ucs2 ucs2_general_ci +# +# WL#5510 Functions to_base64 and from_base64 +# +CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(12) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1; +to_base64 LENGTH(to_base64) HEX(to_base64) +AHQAZQBzAHQ= 24 0041004800510041005A00510042007A004100480051003D +CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(18) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2; +CAST(from_base64 AS CHAR) LENGTH(from_base64) HEX(from_base64) +test 8 0074006500730074 +DROP TABLE t2; +DROP TABLE t1; +# +# Bug#58190 BETWEEN no longer uses indexes for date or datetime fields +# +SELECT @@collation_connection; +@@collation_connection +ucs2_general_ci +CREATE TABLE t1 ( +id INT(11) DEFAULT NULL, +date_column DATE DEFAULT NULL, +KEY(date_column)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range date_column date_column 4 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`date_column` AS `date_column` from `test`.`t1` where (`test`.`t1`.`date_column` between '2010-09-01' and '2010-10-01') +ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range date_column date_column 6 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`date_column` AS `date_column` from `test`.`t1` where (`test`.`t1`.`date_column` between '2010-09-01' and '2010-10-01') +DROP TABLE t1; +# +# Bug #31384 DATE_ADD() and DATE_SUB() return binary data +# +SELECT @@collation_connection, @@character_set_results; +@@collation_connection @@character_set_results +ucs2_general_ci latin1 +CREATE TABLE t1 AS +SELECT +DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1, +DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2, +DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date, +DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `field_str1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL, + `field1_str2` varchar(29) CHARACTER SET ucs2 DEFAULT NULL, + `field_date` date DEFAULT NULL, + `field_datetime` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SELECT +DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1, +DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2, +DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date, +DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def field_str1 254 29 10 Y 0 31 8 +def field1_str2 254 29 19 Y 0 31 8 +def field_date 10 10 10 Y 128 0 63 +def field_datetime 12 19 19 Y 128 0 63 +field_str1 field1_str2 field_date field_datetime +2007-08-02 2007-08-03 17:32:00 2007-08-02 2007-08-03 17:32:00 +SELECT +HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1, +HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2, +HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date, +HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime; +field_str1 field1_str2 field_date field_datetime +0032003000300037002D00300038002D00300032002000320033003A00350039003A00300030 0032003000300037002D00300038002D00300033002000310037003A00330032003A00300030 323030372D30382D3032 323030372D30382D30332031373A33323A3030 +# +# Bug#11926811 / Bug#60625 Illegal mix of collations +# +SELECT @@collation_connection; +@@collation_connection +ucs2_general_ci +CREATE PROCEDURE p1() +BEGIN +DECLARE v_LastPaymentDate DATETIME DEFAULT NULL; +SELECT v_LastPaymentDate < NOW(); +EXPLAIN SELECT v_LastPaymentDate < NOW(); +SHOW WARNINGS; +EXPLAIN SELECT CONCAT(v_LastPaymentDate, NOW()); +END// +CALL p1; +v_LastPaymentDate < NOW() +NULL +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Level Code Message +Note 1003 /* select#1 */ select (v_LastPaymentDate@0 < now()) AS `v_LastPaymentDate < NOW()` +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select concat(convert(v_LastPaymentDate@0 using ucs2),convert(now() using ucs2)) AS `CONCAT(v_LastPaymentDate, NOW())` +DROP PROCEDURE p1; +# +# Bug#52159 returning time type from function and empty left join causes debug assertion +# +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +f1() +00:00:01 +DROP FUNCTION f1; +DROP TABLE t1; +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (); +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +maketime(`a`,`a`,`a`) +00:00:00.000000 +DROP TABLE t1; +SET sql_mode=default; +SET NAMES latin1; +# +# Bug #13832953 MY_STRNXFRM_UNICODE: ASSERTION `SRC' FAILED +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (c1 SET('','') CHARACTER SET ucs2); +Warnings: +Note 1291 Column 'c1' has duplicated value '' in SET +INSERT INTO t1 VALUES (''); +SELECT COALESCE(c1) FROM t1 ORDER BY 1; +COALESCE(c1) + +DROP TABLE t1; +SET sql_mode = default; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#3664 WEIGHT_STRING +# +set collation_connection=ucs2_general_ci; +select @@collation_connection; +@@collation_connection +ucs2_general_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0041 +select hex(weight_string('A')); +hex(weight_string('A')) +0041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +004100420043 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +00410042 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +004100420043 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +00410042004300200020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0041 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +004100 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00410042002000200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0041 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +004100 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00410042004300200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0041 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +004100 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00410042004300200020002000200020002000200020002000 +select @@collation_connection; +@@collation_connection +ucs2_general_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +20AC20AC20AC00200020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +20AC20AC00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +20AC20AC002000200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +set collation_connection=ucs2_bin; +select @@collation_connection; +@@collation_connection +ucs2_bin +select hex(weight_string('a')); +hex(weight_string('a')) +0061 +select hex(weight_string('A')); +hex(weight_string('A')) +0041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +006100620063 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +00610062 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +006100620063 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +00610062006300200020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0061 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +006100 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00610062 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0061006200 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00610062002000200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0061 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +006100 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00610062 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0061006200 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00610062006300200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0061 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +006100 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00610062 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0061006200 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00610062006300200020002000200020002000200020002000 +select @@collation_connection; +@@collation_connection +ucs2_bin +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +20AC20AC20AC00200020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +20AC20AC00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +20AC20AC002000200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +# +# Bug #36418 Character sets: crash if char(256 using utf32) +# +select hex(char(0x01 using ucs2)); +hex(char(0x01 using ucs2)) +0001 +select hex(char(0x0102 using ucs2)); +hex(char(0x0102 using ucs2)) +0102 +select hex(char(0x010203 using ucs2)); +hex(char(0x010203 using ucs2)) +00010203 +select hex(char(0x01020304 using ucs2)); +hex(char(0x01020304 using ucs2)) +01020304 +# +# Bug#10094 Displays wrong error message for UNIQUE key index on CHAR(255) Unicode datatype +# +CREATE TABLE t1 (f1 CHAR(255) unicode); +INSERT INTO t1 values ('abc'),('bcd'),('abc'); +ALTER TABLE t1 ADD UNIQUE Index_1 (f1); +ERROR 23000: Duplicate entry 'abc' for key 't1.Index_1' +DROP TABLE t1; +# +# Test how character set works with date/time +# +SET collation_connection=ucs2_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +s1 hex(s1) +2008-07-18 0032003000300038002D00300037002D00310038 +08:42:04 00300038003A00340032003A00300034 +2008-07-18 08:42:04 0032003000300038002D00300037002D00310038002000300038003A00340032003A00300034 +DROP TABLE t1; +SET timestamp=0; +SET NAMES latin1; +# +# WL#4013 Unicode german2 collation +# +SET collation_connection=ucs2_german2_ci; +"BEGIN ctype_german.inc" +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +ucs2_german2_ci +delete from t1; +INSERT INTO t1 VALUES ('ud'),('uf'); +INSERT INTO t1 VALUES ('od'),('of'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('ad'),('af'); +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6); +INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 0061 +ad 00610064 +ae 00610065 + 00C6 + 00E4 + 00E6 +af 00610066 +e 0065 +o 006F +od 006F0064 +oe 006F0065 + 00F6 + 0152 + 0153 +of 006F0066 +s 0073 +ss 00730073 + 00DF +u 0075 +ud 00750064 +ue 00750065 + 00FC +uf 00750066 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a +ad +ae,,, +af +e +o +od +oe,,, +of +s +ss, +u +ud +ue, +uf +SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1); +s1 hex(s1) hex(weight_string(s1)) +a 0061 0E33 +ad 00610064 0E330E6D +ae 00610065 0E330E8B + 00C6 0E330E8B + 00E4 0E330E8B + 00E6 0E330E8B +af 00610066 0E330EB9 +e 0065 0E8B +o 006F 0F82 +od 006F0064 0F820E6D +oe 006F0065 0F820E8B + 00F6 0F820E8B + 0152 0F820E8B + 0153 0F820E8B +of 006F0066 0F820EB9 +s 0073 0FEA +ss 00730073 0FEA0FEA + 00DF 0FEA0FEA +u 0075 101F +ud 00750064 101F0E6D +ue 00750065 101F0E8B + 00FC 101F0E8B +uf 00750066 101F0EB9 +SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1); +s1 hex(s1) +ae 00610065 + 00C6 + 00E4 + 00E6 +drop table t1; +"END ctype_german.inc" +# +# Bug#59145 valgrind warnings for uninitialized values in my_strtoll10_mb2 +# +SET NAMES latin1; +SELECT CONVERT(CHAR(NULL USING ucs2), UNSIGNED); +CONVERT(CHAR(NULL USING ucs2), UNSIGNED) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +DO IFNULL(CHAR(NULL USING ucs2), ''); +DO CAST(CONVERT('' USING ucs2) AS UNSIGNED); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +# +# Test error message for conversion using different charset +# +CREATE TABLE t1 (a DECIMAL(2,0)); +SET sql_mode=default; +INSERT INTO t1 VALUES (CONVERT('9e99999999' USING ucs2)); +ERROR HY000: Incorrect decimal value: '9e99999999' for column 'a' at row 1 +INSERT IGNORE INTO t1 VALUES (CONVERT('aaa' USING ucs2)); +Warnings: +Warning 1366 Incorrect decimal value: 'aaa' for column 'a' at row 1 +DROP TABLE t1; +# +# End of 5.6 tests +# +# +# Bug#27419181 UBSAN: MY_STRNTOLL_MB2_OR_MB4 - NAUGHTY NEGATIVES +# +SELECT CONVERT('-9223372036854775808' USING utf16le) & 0; +CONVERT('-9223372036854775808' USING utf16le) & 0 +0 +SELECT CONVERT('-9223372036854775808' USING utf8mb4) & 0; +CONVERT('-9223372036854775808' USING utf8mb4) & 0 +0 +# +# Bug#29585648: UBSAN NEGATION OF NEGATIVE IN MY_STRTOLL10_MB2 +# +SELECT CAST(CONVERT("-9223372036854775808" USING utf16le) AS SIGNED); +CAST(CONVERT("-9223372036854775808" USING utf16le) AS SIGNED) +-9223372036854775808 +SELECT CAST(CONVERT("-9223372036854775807" USING utf16le) AS SIGNED); +CAST(CONVERT("-9223372036854775807" USING utf16le) AS SIGNED) +-9223372036854775807 +SELECT CAST(CONVERT("-9223372036854775808" USING utf32) AS SIGNED); +CAST(CONVERT("-9223372036854775808" USING utf32) AS SIGNED) +-9223372036854775808 +SELECT CAST(CONVERT("-9223372036854775807" USING utf32) AS SIGNED); +CAST(CONVERT("-9223372036854775807" USING utf32) AS SIGNED) +-9223372036854775807 diff --git a/mysql-test/r/ctype_unicode900.result-pq b/mysql-test/r/ctype_unicode900.result-pq new file mode 100644 index 000000000..3e38d59b0 --- /dev/null +++ b/mysql-test/r/ctype_unicode900.result-pq @@ -0,0 +1,3889 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 8.0 tests +# +# +# WL#9125: Add utf8mb4_0900_ai_ci +# +SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci; +SET @test_character_set= 'utf8mb4'; +SET @test_collation= 'utf8mb4_0900_ai_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) utf8mb4_0900_ai_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) utf8mb4_0900_ai_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf8mb4_0900_ai_ci 61 +utf8mb4_0900_ai_ci 6109 +utf8mb4_0900_ai_ci 6120 +drop table t1; +create table t1 engine=innodb select repeat('a',50) as c1; +alter table t1 add index(c1(5)); +insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111'); +select collation(c1) from t1 limit 1; +collation(c1) +utf8mb4_0900_ai_ci +select c1 from t1 where c1 like 'abcdef%' order by c1; +c1 +abcdefg +select c1 from t1 where c1 like 'abcde1%' order by c1; +c1 +abcde100 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde11%' order by c1; +c1 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde111%' order by c1; +c1 +abcde111 +drop table t1; +select @@collation_connection; +@@collation_connection +utf8mb4_0900_ai_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +drop table if exists t1; +create table t1 select repeat('a',10) as c1; +delete from t1; +insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F); +insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F); +insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F); +insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F); +insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F); +insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F); +SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1; +GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '') GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) + 7F + 20 +_ 5F +- 2D +, 2C +; 3B +: 3A +! 21 +? 3F +. 2E +' 27 +" 22 +( 28 +) 29 +[ 5B +] 5D +{ 7B +} 7D +@ 40 +* 2A +/ 2F +\ 5C +& 26 +# 23 +% 25 +` 60 +^ 5E ++ 2B +< 3C += 3D +> 3E +| 7C +~ 7E +$ 24 +0 30 +1 31 +2 32 +3 33 +4 34 +5 35 +6 36 +7 37 +8 38 +9 39 +Aa 41,61 +Bb 42,62 +Cc 43,63 +Dd 44,64 +Ee 45,65 +Ff 46,66 +Gg 47,67 +Hh 48,68 +Ii 49,69 +Jj 4A,6A +Kk 4B,6B +Ll 4C,6C +Mm 4D,6D +Nn 4E,6E +Oo 4F,6F +Pp 50,70 +Qq 51,71 +Rr 52,72 +Ss 53,73 +Tt 54,74 +Uu 55,75 +Vv 56,76 +Ww 57,77 +Xx 58,78 +Yy 59,79 +Zz 5A,7A +drop table t1; +SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci; +SELECT HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING ucs2)); +HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING ucs2)) +003F0041 +SELECT HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf16)); +HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf16)) +D806DEDB0041 +SELECT HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf32)); +HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf32)) +00011ADB00000041 +SELECT HEX(CONVERT(_ucs2 0xF8FF USING utf8mb4)); +HEX(CONVERT(_ucs2 0xF8FF USING utf8mb4)) +EFA3BF +SELECT HEX(CONVERT(_utf16 0xF8FF USING utf8mb4)); +HEX(CONVERT(_utf16 0xF8FF USING utf8mb4)) +EFA3BF +SELECT HEX(CONVERT(_utf32 0xF8FF USING utf8mb4)); +HEX(CONVERT(_utf32 0xF8FF USING utf8mb4)) +EFA3BF +SELECT HEX(CONVERT(_utf8mb4 0x8F USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: '8F' +SELECT HEX(CONVERT(_utf8mb4 0xC230 USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: 'C230' +SELECT HEX(CONVERT(_utf8mb4 0xE234F1 USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: 'E234F1' +SELECT HEX(CONVERT(_utf8mb4 0xF4E25634 USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: 'F4E256' +SELECT ASCII('ABC'); +ASCII('ABC') +65 +SELECT BIT_LENGTH('a'); +BIT_LENGTH('a') +8 +SELECT BIT_LENGTH('À'); +BIT_LENGTH('À') +16 +SELECT BIT_LENGTH('テ'); +BIT_LENGTH('テ') +24 +SELECT BIT_LENGTH('𝌆'); +BIT_LENGTH('?') +32 +SELECT CHAR_LENGTH('𝌆テÀa'); +CHAR_LENGTH('?テÀa') +4 +SELECT LENGTH('𝌆テÀa'); +LENGTH('?テÀa') +10 +SELECT FIELD('a', '𝌆テÀa'); +FIELD('a', '?テÀa') +0 +SELECT HEX('𝌆テÀa'); +HEX('?テÀa') +F09D8C86E38386C38061 +SELECT INSERT('𝌆テÀa', 2, 2, 'テb'); +INSERT('?テÀa', 2, 2, 'テb') +𝌆テba +SELECT LOWER('𝌆テÀBcd'); +LOWER('?テÀBcd') +𝌆テàbcd +SELECT ORD('𝌆'); +ORD('?') +4036856966 +SELECT UPPER('𝌆テàbCD'); +UPPER('?テàbCD') +𝌆テÀBCD +SELECT LOCATE(_utf8mb4 0xF091AB9B41, _utf8mb4 0xF091AB9B42F091AB9B41F091AB9B43); +LOCATE(_utf8mb4 0xF091AB9B41, _utf8mb4 0xF091AB9B42F091AB9B41F091AB9B43) +3 +SELECT HEX(REVERSE(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43)); +HEX(REVERSE(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43)) +43F091AB9B42F091AB9B41F091AB9B +SELECT HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, 1, 2)); +HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, 1, 2)) +F091AB9B41 +SELECT HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, -3, 2)); +HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, -3, 2)) +42F091AB9B +SELECT HEX(TRIM(_utf8mb4 0x2020F091AB9B4120F091AB9B4120202020)); +HEX(TRIM(_utf8mb4 0x2020F091AB9B4120F091AB9B4120202020)) +F091AB9B4120F091AB9B41 +SELECT HEX(WEIGHT_STRING('aA')); +HEX(WEIGHT_STRING('aA')) +1C471C47 +SELECT HEX(WEIGHT_STRING(CAST(_utf32 x'337F' AS CHAR))); +HEX(WEIGHT_STRING(CAST(_utf32 x'337F' AS CHAR))) +FB40E82AFB40DF0FFB40CF1AFB40F93E +SELECT HEX(WEIGHT_STRING(CAST(_utf32 x'FDFA' AS CHAR))); +HEX(WEIGHT_STRING(CAST(_utf32 x'FDFA' AS CHAR))) +2364239C23C50209230B239C239C23B1 +select @@collation_connection; +@@collation_connection +utf8mb4_0900_ai_ci +select hex(weight_string('a')); +hex(weight_string('a')) +1C47 +select hex(weight_string('A')); +hex(weight_string('A')) +1C47 +select hex(weight_string('abc')); +hex(weight_string('abc')) +1C471C601C7A +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +1C471C60 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +1C471C601C7A +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +1C471C601C7A +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +1C +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +1C471C6000 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +1C471C60000000000000000000000000000000000000000000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +1C +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +1C471C601C +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +1C471C601C7A00000000000000000000000000000000000000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +1C +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +1C471C601C +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +1C471C601C7A00000000000000000000000000000000000000 +select @@collation_connection; +@@collation_connection +utf8mb4_0900_ai_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +1C2A1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +1C2A1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +1C2A1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +1C2A1C2A00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +1C2A1C2A000000000000000000000000000000000000000000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +1C2A1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +1C2A1C2A1C2A00000000000000000000000000000000000000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +1C2A1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +1C2A1C2A1C2A00000000000000000000000000000000000000 +CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A); +INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C); +INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E); +INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242); +INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244); +INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246); +INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248); +INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A); +INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C); +INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E); +INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B); +INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289); +INSERT INTO t1 VALUES (_utf32 0x028C); +INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C); +INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD); +INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF); +INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF); +INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7); +INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB); +INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD); +INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF); +INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511); +INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513); +INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1); +INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3); +INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5); +INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7); +INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01); +INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03); +INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05); +INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07); +INSERT INTO t1 VALUES (_utf32 0x1D7D); +INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E); +INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184); +INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81); +INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83); +INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85); +INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87); +INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89); +INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B); +INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D); +INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F); +INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61); +INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63); +INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65); +INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67); +INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69); +INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B); +INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75); +INSERT INTO t1 VALUES (_utf32 0x2C76); +INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01); +INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03); +INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05); +INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07); +INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31); +INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33); +INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35); +INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37); +INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401); +INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403); +INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405); +INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407); +INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429); +INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B); +INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D); +INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F); +INSERT INTO t1 VALUES (_utf32 0x0370); +INSERT INTO t1 VALUES (_utf32 0x0371); +INSERT INTO t1 VALUES (_utf32 0x0372); +INSERT INTO t1 VALUES (_utf32 0x0373); +INSERT INTO t1 VALUES (_utf32 0x0514); +INSERT INTO t1 VALUES (_utf32 0x0515); +INSERT INTO t1 VALUES (_utf32 0x0516); +INSERT INTO t1 VALUES (_utf32 0x0517); +INSERT INTO t1 VALUES (_utf32 0xA640); +INSERT INTO t1 VALUES (_utf32 0xA641); +INSERT INTO t1 VALUES (_utf32 0xA642); +INSERT INTO t1 VALUES (_utf32 0xA643); +INSERT INTO t1 VALUES (_utf32 0xA722); +INSERT INTO t1 VALUES (_utf32 0xA723); +INSERT INTO t1 VALUES (_utf32 0xA724); +INSERT INTO t1 VALUES (_utf32 0xA725); +INSERT INTO t1 VALUES (_utf32 0xA726); +INSERT INTO t1 VALUES (_utf32 0xA727); +INSERT INTO t1 VALUES (_utf32 0xA728); +INSERT INTO t1 VALUES (_utf32 0xA729); +INSERT INTO t1 VALUES (_utf32 0xA72A); +INSERT INTO t1 VALUES (_utf32 0xA72B); +INSERT INTO t1 VALUES (_utf32 0x2CEB); +INSERT INTO t1 VALUES (_utf32 0x2CEC); +INSERT INTO t1 VALUES (_utf32 0x2CED); +INSERT INTO t1 VALUES (_utf32 0x2CEE); +INSERT INTO t1 VALUES (_utf32 0x1FA01); +INSERT INTO t1 VALUES (_utf32 0x1FB01); +INSERT INTO t1 VALUES (_utf32 0x1FC01); +INSERT INTO t1 VALUES (_utf32 0x1FD01); +INSERT INTO t1 VALUES (_utf32 0x1F603); +INSERT INTO t1 VALUES (_utf32 0x1F604); +INSERT INTO t1 VALUES (_utf32 0x1F648); +INSERT INTO t1 VALUES (_utf32 0x1F64F); +INSERT INTO t1 VALUES (_utf32 0x2B759); +INSERT INTO t1 VALUES (_utf32 0x2B760); +INSERT INTO t1 VALUES (_utf32 0x2B761); +INSERT INTO t1 VALUES (_utf32 0x2B762); +INSERT INTO t1 VALUES (_utf32 0x16F00); +INSERT INTO t1 VALUES (_utf32 0x16F01); +INSERT INTO t1 VALUES (_utf32 0x08A2); +INSERT INTO t1 VALUES (_utf32 0x08A3); +INSERT INTO t1 VALUES (_utf32 0xA794); +INSERT INTO t1 VALUES (_utf32 0xA795); +INSERT INTO t1 VALUES (_utf32 0xA796); +INSERT INTO t1 VALUES (_utf32 0xA797); +INSERT INTO t1 VALUES (_utf32 0xAB37); +INSERT INTO t1 VALUES (_utf32 0xAB38); +INSERT INTO t1 VALUES (_utf32 0x10600); +INSERT INTO t1 VALUES (_utf32 0x10601); +INSERT INTO t1 VALUES (_utf32 0x10602); +INSERT INTO t1 VALUES (_utf32 0x10603); +INSERT INTO t1 VALUES (_utf32 0x1F800); +INSERT INTO t1 VALUES (_utf32 0x1F801); +INSERT INTO t1 VALUES (_utf32 0x1F802); +INSERT INTO t1 VALUES (_utf32 0x1F803); +INSERT INTO t1 VALUES (_utf32 0x10C92); +INSERT INTO t1 VALUES (_utf32 0x10C93); +INSERT INTO t1 VALUES (_utf32 0x10C94); +INSERT INTO t1 VALUES (_utf32 0x10C95); +INSERT INTO t1 VALUES (_utf32 0x2B836); +INSERT INTO t1 VALUES (_utf32 0x2B837); +INSERT INTO t1 VALUES (_utf32 0x2B838); +INSERT INTO t1 VALUES (_utf32 0x2B839); +SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c +FROM t1 ORDER BY c, BINARY c; +hex(c) hex(lower(c)) hex(upper(c)) hex(weight_string(c)) c +F09F9883 F09F9883 F09F9883 15FE 😃 +F09F9884 F09F9884 F09F9884 15FF 😄 +F09F9988 F09F9988 F09F9988 1643 🙈 +F09F998F F09F998F F09F998F 164A 🙏 +F09FA080 F09FA080 F09FA080 17AB 🠀 +F09FA081 F09FA081 F09FA081 17AC 🠁 +F09FA082 F09FA082 F09FA082 17AD 🠂 +F09FA083 F09FA083 F09FA083 17AE 🠃 +C8BA C8BA 1C4C Ⱥ +E2B1A5 E2B1A5 C8BA 1C4C ⱥ +C680 C680 C983 1C68 ƀ +C983 C680 C983 1C68 Ƀ +EA9E96 EA9E97 EA9E96 1C6F Ꞗ +EA9E97 EA9E97 EA9E96 1C6F ꞗ +C8BB C8BC C8BB 1C7F Ȼ +C8BC C8BC C8BB 1C7F ȼ +EA9E94 EA9E94 EA9E94 1C84 ꞔ +E28683 E28684 E28683 1C8D Ↄ +E28684 E28684 E28683 1C8D ↄ +C986 C987 C986 1CB1 Ɇ +C987 C987 C986 1CB1 ɇ +E284B2 E2858E E284B2 1CF2 Ⅎ +E2858E E2858E E284B2 1CF2 ⅎ +EA9E95 EA9E95 EA9E95 1D24 ꞕ +E2B1A7 E2B1A8 E2B1A7 1D29 Ⱨ +E2B1A8 E2B1A8 E2B1A7 1D29 ⱨ +E2B1B5 E2B1B6 E2B1B5 1D2A Ⱶ +E2B1B6 E2B1B6 E2B1B5 1D2A ⱶ +EA9CA6 EA9CA7 EA9CA6 1D2B Ꜧ +EA9CA7 EA9CA7 EA9CA6 1D2B ꜧ +C988 C989 C988 1D55 Ɉ +C989 C989 C988 1D55 ɉ +E2B1A9 E2B1AA E2B1A9 1D6F Ⱪ +E2B1AA E2B1AA E2B1A9 1D6F ⱪ +C8BD C69A C8BD 1D82 Ƚ +E2B1A0 E2B1A1 E2B1A0 1D86 Ⱡ +E2B1A1 E2B1A1 E2B1A0 1D86 ⱡ +C9AB C9AB 1D87 ɫ +E2B1A2 C9AB E2B1A2 1D87 Ɫ +EAACB8 EAACB8 EAACB8 1D8B ꬸ +EAACB7 EAACB7 EAACB7 1D91 ꬷ +E1B5BD E1B5BD E2B1A3 1E11 ᵽ +E2B1A3 E1B5BD E2B1A3 1E11 Ᵽ +C98A C98B C98A 1E2B Ɋ +C98B C98B C98A 1E2B ɋ +C98C C98D C98C 1E3F Ɍ +C98D C98D C98C 1E3F ɍ +C9BD C9BD 1E57 ɽ +E2B1A4 C9BD E2B1A4 1E57 Ɽ +EA9CA8 EA9CA9 EA9CA8 1E951F21 Ꜩ +EA9CA9 EA9CA9 EA9CA8 1E951F21 ꜩ +C8BE C8BE 1E9E Ⱦ +E2B1A6 E2B1A6 C8BE 1E9E ⱦ +C984 CA89 C984 1EC0 Ʉ +CA89 CA89 C984 1EC0 ʉ +C985 CA8C C985 1EF1 Ʌ +CA8C CA8C C985 1EF1 ʌ +C98E C98F C98E 1F13 Ɏ +C98F C98F C98E 1F13 ɏ +E2B1AB E2B1AC E2B1AB 1F3C Ⱬ +E2B1AC E2B1AC E2B1AB 1F3C ⱬ +EA9CAA EA9CAB EA9CAA 1F66 Ꜫ +EA9CAB EA9CAB EA9CAA 1F66 ꜫ +C981 C982 C981 1F79 Ɂ +C982 C982 C981 1F79 ɂ +EA9CA2 EA9CA3 EA9CA2 1F81 Ꜣ +EA9CA3 EA9CA3 EA9CA2 1F81 ꜣ +EA9CA4 EA9CA5 EA9CA4 1F8C Ꜥ +EA9CA5 EA9CA5 EA9CA4 1F8C ꜥ +CDB0 CDB1 CDB0 1FC3 Ͱ +CDB1 CDB1 CDB0 1FC3 ͱ +CDBC CDBC CFBE 1FD8 ͼ +CFBE CDBC CFBE 1FD8 Ͼ +CDBB CDBB CFBD 1FD9 ͻ +CFBD CDBB CFBD 1FD9 Ͻ +CDBD CDBD CFBF 1FDA ͽ +CFBF CDBD CFBF 1FDA Ͽ +CDB2 CDB3 CDB2 1FE4 Ͳ +CDB3 CDB3 CDB2 1FE4 ͳ +E2B280 E2B281 E2B280 1FE6 Ⲁ +E2B281 E2B281 E2B280 1FE6 ⲁ +E2B282 E2B283 E2B282 1FE7 Ⲃ +E2B283 E2B283 E2B282 1FE7 ⲃ +E2B284 E2B285 E2B284 1FE8 Ⲅ +E2B285 E2B285 E2B284 1FE8 ⲅ +E2B286 E2B287 E2B286 1FE9 Ⲇ +E2B287 E2B287 E2B286 1FE9 ⲇ +E2B288 E2B289 E2B288 1FEA Ⲉ +E2B289 E2B289 E2B288 1FEA ⲉ +E2B28A E2B28B E2B28A 1FEC Ⲋ +E2B28B E2B28B E2B28A 1FEC ⲋ +E2B28C E2B28D E2B28C 1FED Ⲍ +E2B28D E2B28D E2B28C 1FED ⲍ +E2B28E E2B28F E2B28E 1FEE Ⲏ +E2B28F E2B28F E2B28E 1FEE ⲏ +E2B3AB E2B3AC E2B3AB 2006 Ⳬ +E2B3AC E2B3AC E2B3AB 2006 ⳬ +E2B3AD E2B3AE E2B3AD 2016 Ⳮ +E2B3AE E2B3AE E2B3AD 2016 ⳮ +D3BA D3BB D3BA 203E Ӻ +D3BB D3BB D3BA 203E ӻ +D3B6 D3B7 D3B6 2046 Ӷ +D3B7 D3B7 D3B6 2046 ӷ +EA9980 EA9981 EA9980 2070 Ꙁ +EA9981 EA9981 EA9980 2070 ꙁ +D490 D491 D490 2072 Ԑ +D491 D491 D490 2072 ԑ +EA9982 EA9983 EA9982 2073 Ꙃ +EA9983 EA9983 EA9982 2073 ꙃ +D492 D493 D492 20BA Ԓ +D493 D493 D492 20BA ԓ +D494 D495 D494 20C2 Ԕ +D495 D495 D494 20C2 ԕ +D496 D497 D496 2104 Ԗ +D497 D497 D496 2104 ԗ +D3BC D3BD D3BC 2136 Ӽ +D3BD D3BD D3BC 2136 ӽ +D3BE D3BF D3BE 213A Ӿ +D3BF D3BF D3BE 213A ӿ +D380 D38F D380 21E1 Ӏ +D38F D38F D380 21E1 ӏ +E2B080 E2B0B0 E2B080 21E5 Ⰰ +E2B0B0 E2B0B0 E2B080 21E5 ⰰ +E2B081 E2B0B1 E2B081 21E6 Ⰱ +E2B0B1 E2B0B1 E2B081 21E6 ⰱ +E2B082 E2B0B2 E2B082 21E7 Ⰲ +E2B0B2 E2B0B2 E2B082 21E7 ⰲ +E2B083 E2B0B3 E2B083 21E8 Ⰳ +E2B0B3 E2B0B3 E2B083 21E8 ⰳ +E2B084 E2B0B4 E2B084 21E9 Ⰴ +E2B0B4 E2B0B4 E2B084 21E9 ⰴ +E2B085 E2B0B5 E2B085 21EA Ⰵ +E2B0B5 E2B0B5 E2B085 21EA ⰵ +E2B086 E2B0B6 E2B086 21EB Ⰶ +E2B0B6 E2B0B6 E2B086 21EB ⰶ +E2B087 E2B0B7 E2B087 21EC Ⰷ +E2B0B7 E2B0B7 E2B087 21EC ⰷ +E182A0 E2B480 E182A0 223B Ⴀ +E2B480 E2B480 E182A0 223B ⴀ +E182A1 E2B481 E182A1 223D Ⴁ +E2B481 E2B481 E182A1 223D ⴁ +E182A2 E2B482 E182A2 223F Ⴂ +E2B482 E2B482 E182A2 223F ⴂ +E182A3 E2B483 E182A3 2241 Ⴃ +E2B483 E2B483 E182A3 2241 ⴃ +E182A4 E2B484 E182A4 2243 Ⴄ +E2B484 E2B484 E182A4 2243 ⴄ +E182A5 E2B485 E182A5 2245 Ⴅ +E2B485 E2B485 E182A5 2245 ⴅ +E182A6 E2B486 E182A6 2247 Ⴆ +E2B486 E2B486 E182A6 2247 ⴆ +E182A7 E2B487 E182A7 224B Ⴇ +E2B487 E2B487 E182A7 224B ⴇ +E0A2A2 E0A2A2 E0A2A2 232B ࢢ +E0A2A3 E0A2A3 E0A2A3 236D ࢣ +F090B292 F090B392 F090B292 3712 𐲒 +F090B293 F090B393 F090B293 3713 𐲓 +F090B294 F090B394 F090B294 3714 𐲔 +F090B295 F090B395 F090B295 3715 𐲕 +F096BC80 F096BC80 F096BC80 427A 𖼀 +F096BC81 F096BC81 F096BC81 427B 𖼁 +F0909080 F09090A8 F0909080 4452 𐐀 +F09090A8 F09090A8 F0909080 4452 𐐨 +F0909081 F09090A9 F0909081 4453 𐐁 +F09090A9 F09090A9 F0909081 4453 𐐩 +F0909082 F09090AA F0909082 4454 𐐂 +F09090AA F09090AA F0909082 4454 𐐪 +F0909083 F09090AB F0909083 4455 𐐃 +F09090AB F09090AB F0909083 4455 𐐫 +F0909084 F09090AC F0909084 4456 𐐄 +F09090AC F09090AC F0909084 4456 𐐬 +F0909085 F09090AD F0909085 4457 𐐅 +F09090AD F09090AD F0909085 4457 𐐭 +F0909086 F09090AE F0909086 4458 𐐆 +F09090AE F09090AE F0909086 4458 𐐮 +F0909087 F09090AF F0909087 4459 𐐇 +F09090AF F09090AF F0909087 4459 𐐯 +F0909880 F0909880 F0909880 46BA 𐘀 +F0909881 F0909881 F0909881 46BB 𐘁 +F0909882 F0909882 F0909882 46BC 𐘂 +F0909883 F0909883 F0909883 46BD 𐘃 +F0AB9D99 F0AB9D99 F0AB9D99 FB85B759 𫝙 +F0AB9DA0 F0AB9DA0 F0AB9DA0 FB85B760 𫝠 +F0AB9DA1 F0AB9DA1 F0AB9DA1 FB85B761 𫝡 +F0AB9DA2 F0AB9DA2 F0AB9DA2 FB85B762 𫝢 +F0ABA0B6 F0ABA0B6 F0ABA0B6 FB85B836 𫠶 +F0ABA0B7 F0ABA0B7 F0ABA0B7 FB85B837 𫠷 +F0ABA0B8 F0ABA0B8 F0ABA0B8 FB85B838 𫠸 +F0ABA0B9 F0ABA0B9 F0ABA0B9 FB85B839 𫠹 +F09FA881 F09FA881 F09FA881 FBC3FA01 🨁 +F09FAC81 F09FAC81 F09FAC81 FBC3FB01 🬁 +F09FB081 F09FB081 F09FB081 FBC3FC01 🰁 +F09FB481 F09FB481 F09FB481 FBC3FD01 🴁 +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400)); +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 1C47 +61F0909080 1C474452 +61EFBFBF 1C47FBC1FFFF +61F48FBFBF 1C47FBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 4452 𐐀 +F09090A8 4452 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 4452 𐐀 +F09090A8 4452 𐐨 +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`c`) AS `hex(c)` from `test`.`t1` where (`test`.`t1`.`c` like 'a%') order by `test`.`t1`.`c` +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 1C47 +61F0909080 1C474452 +61EFBFBF 1C47FBC1FFFF +61F48FBFBF 1C47FBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 4452 𐐀 +F09090A8 4452 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 4452 𐐀 +F09090A8 4452 𐐨 +DROP TABLE t1; +SELECT 'a' = 'a '; +'a' = 'a ' +0 +SELECT 'a\0' < 'a'; +'a\0' < 'a' +0 +SELECT 'a\0' < 'a '; +'a\0' < 'a ' +1 +SELECT 'a\t' < 'a'; +'a\t' < 'a' +0 +SELECT 'a\t' < 'a '; +'a\t' < 'a ' +1 +SELECT 'a' LIKE 'a'; +'a' LIKE 'a' +1 +SELECT 'A' LIKE 'a'; +'A' LIKE 'a' +1 +SELECT _utf8mb4 0xD0B0D0B1D0B2 LIKE CONCAT(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%'); +_utf8mb4 0xD0B0D0B1D0B2 LIKE CONCAT(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%') +1 +SELECT is_ipv4(inet_ntoa('1')); +is_ipv4(inet_ntoa('1')) +1 +SELECT is_ipv6(inet_ntoa('1')); +is_ipv6(inet_ntoa('1')) +0 +SELECT inet6_aton(inet_ntoa('1')); +inet6_aton(inet_ntoa('1')) + +SELECT inet6_ntoa(inet_ntoa('1')); +inet6_ntoa(inet_ntoa('1')) +NULL +# +# Bug#14040277 UNINITIALIZED VALUE REFERENCED IN STR_TO_IPV6 +# +SELECT inet6_aton(soundex('a')); +inet6_aton(soundex('a')) +NULL +# +# Bug#19047425 UNINITIALISED VALUE IN STR_TO_IPV6 +# +do is_ipv4_mapped(inet6_aton(convert(_ascii "a:" using utf8mb4))); +CREATE TABLE t1 (c VARCHAR(10) CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES (_utf8mb4 0xF09090A7), (_utf8mb4 0xEA8B93), (_utf8mb4 0xC4BC), (_utf8mb4 0xC6AD), (_utf8mb4 0xF090918F), (_utf8mb4 0xEAAD8B); +SELECT HEX(ANY_VALUE(c)), COUNT(c) FROM t1 GROUP BY c COLLATE utf8mb4_0900_ai_ci; +HEX(ANY_VALUE(c)) COUNT(c) +C4BC 1 +C6AD 1 +EA8B93 1 +EAAD8B 1 +F09090A7 2 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(10)) COLLATE utf8mb4_0900_ai_ci; +INSERT INTO t1 VALUES(_utf16 0xAC00, _utf16 0x326E), (_utf16 0xAD, _utf16 0xA0), +(_utf16 0xC6, _utf16 0x41), (_utf16 0xC6, _utf16 0xAA), (_utf16 0xA73A, _utf16 0xA738); +SELECT a = b FROM t1; +a = b +1 +0 +0 +0 +1 +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 (c1 CHAR(10) CHARACTER SET utf8mb4); +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); +INSERT INTO t1 VALUES (_ucs2 0x1EA0),(_ucs2 0x1EA1),(_ucs2 0x1EA2),(_ucs2 0x1EA3); +INSERT INTO t1 VALUES (_ucs2 0x1EA4),(_ucs2 0x1EA5),(_ucs2 0x1EA6),(_ucs2 0x1EA7); +INSERT INTO t1 VALUES (_ucs2 0x1EA8),(_ucs2 0x1EA9),(_ucs2 0x1EAA),(_ucs2 0x1EAB); +INSERT INTO t1 VALUES (_ucs2 0x1EAC),(_ucs2 0x1EAD),(_ucs2 0x1EAE),(_ucs2 0x1EAF); +INSERT INTO t1 VALUES (_ucs2 0x1EB0),(_ucs2 0x1EB1),(_ucs2 0x1EB2),(_ucs2 0x1EB3); +INSERT INTO t1 VALUES (_ucs2 0x1EB4),(_ucs2 0x1EB5),(_ucs2 0x1EB6),(_ucs2 0x1EB7); +INSERT INTO t1 VALUES (_ucs2 0x1EB8),(_ucs2 0x1EB9),(_ucs2 0x1EBA),(_ucs2 0x1EBB); +INSERT INTO t1 VALUES (_ucs2 0x1EBC),(_ucs2 0x1EBD),(_ucs2 0x1EBE),(_ucs2 0x1EBF); +INSERT INTO t1 VALUES (_ucs2 0x1EC0),(_ucs2 0x1EC1),(_ucs2 0x1EC2),(_ucs2 0x1EC3); +INSERT INTO t1 VALUES (_ucs2 0x1EC4),(_ucs2 0x1EC5),(_ucs2 0x1EC6),(_ucs2 0x1EC7); +INSERT INTO t1 VALUES (_ucs2 0x1EC8),(_ucs2 0x1EC9),(_ucs2 0x1ECA),(_ucs2 0x1ECB); +INSERT INTO t1 VALUES (_ucs2 0x1ECC),(_ucs2 0x1ECD),(_ucs2 0x1ECE),(_ucs2 0x1ECF); +INSERT INTO t1 VALUES (_ucs2 0x1ED0),(_ucs2 0x1ED1),(_ucs2 0x1ED2),(_ucs2 0x1ED3); +INSERT INTO t1 VALUES (_ucs2 0x1ED4),(_ucs2 0x1ED5),(_ucs2 0x1ED6),(_ucs2 0x1ED7); +INSERT INTO t1 VALUES (_ucs2 0x1ED8),(_ucs2 0x1ED9),(_ucs2 0x1EDA),(_ucs2 0x1EDB); +INSERT INTO t1 VALUES (_ucs2 0x1EDC),(_ucs2 0x1EDD),(_ucs2 0x1EDE),(_ucs2 0x1EDF); +INSERT INTO t1 VALUES (_ucs2 0x1EE0),(_ucs2 0x1EE1),(_ucs2 0x1EE2),(_ucs2 0x1EE3); +INSERT INTO t1 VALUES (_ucs2 0x1EE4),(_ucs2 0x1EE5),(_ucs2 0x1EE6),(_ucs2 0x1EE7); +INSERT INTO t1 VALUES (_ucs2 0x1EE8),(_ucs2 0x1EE9),(_ucs2 0x1EEA),(_ucs2 0x1EEB); +INSERT INTO t1 VALUES (_ucs2 0x1EEC),(_ucs2 0x1EED),(_ucs2 0x1EEE),(_ucs2 0x1EEF); +INSERT INTO t1 VALUES (_ucs2 0x1EF0),(_ucs2 0x1EF1); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('AE'),('Ae'),('ae'),('aE'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +insert into t1 values (_ucs2 0x0218), (_ucs2 0x0219), (_ucs2 0x021a), (_ucs2 0x021b); +insert into t1 values (_ucs2 0x0d96), (_ucs2 0x0da4), (_ucs2 0x0da5); +insert into t1 values (_ucs2 0x0064017e), (_ucs2 0x0044017e), (_ucs2 0x0044017d); +insert into t1 values ('CS'),('Cs'),('cs'),('cS'); +insert into t1 values ('DZS'),('DZs'),('Dzs'),('DzS'); +insert into t1 values ('dZS'),('dZs'),('dzs'),('dzS'); +insert into t1 values ('GY'),('Gy'),('gy'),('gY'); +insert into t1 values ('LY'),('Ly'),('ly'),('lY'); +insert into t1 values ('NY'),('Ny'),('ny'),('nY'); +insert into t1 values ('SZ'),('Sz'),('sz'),('sZ'); +insert into t1 values ('TY'),('Ty'),('ty'),('tY'); +insert into t1 values ('ZS'),('Zs'),('zs'),('zS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +insert into t1 values ('ccs'),('Ccs'),('CCS'),('cCS'); +insert into t1 values ('ddz'),('Ddz'),('DDZ'),('dDZ'); +insert into t1 values ('ddzs'),('Ddzs'),('DDZS'),('dDZS'); +insert into t1 values ('ggy'),('Ggy'),('GGY'),('gGY'); +insert into t1 values ('lly'),('Lly'),('LLY'),('lLY'); +insert into t1 values ('nny'),('Nny'),('NNY'),('nNY'); +insert into t1 values ('ssz'),('Ssz'),('SSZ'),('sSZ'); +insert into t1 values ('tty'),('Tty'),('TTY'),('tTY'); +insert into t1 values ('zzs'),('Zzs'),('ZZS'),('zZS'); +insert into t1 values ('UE'),('Ue'),('ue'),('uE'); +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_de_pb_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C5 00E0 00E1 00E2 00E3 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00C4 00E4 01DE 01DF 00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D8 00F2 00F3 00F4 00F5 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +00D6 00F6 004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00F9 00FA 00FB 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00DC 00FC 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_is_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C2 00C3 00E0 00E2 00E3 0100 0101 0102 0103 0104 0105 01CD 01CE 01E0 01E1 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 +00C1 00E1 +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +00D0 00F0 +0189 +018A +018B 018C +0045 0065 00C8 00CA 00CB 00E8 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +00C9 00E9 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CE 00CF 00EC 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +00CD 00ED +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D4 00D5 00F2 00F4 00F5 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +00D3 00F3 1EDA 1EDB +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DB 00DC 00F9 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +00DA 00FA 1EE8 1EE9 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00FF 0176 0177 0178 +01B3 01B4 +00DD 00FD +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +00C4 00E4 01DE 01DF 00C6 00E6 01E2 01E3 01FC 01FD +00D6 00D8 00F6 00F8 01FE 01FF +00C5 00E5 01FA 01FB +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_lv_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +010C 010D +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0064005A 0064007A 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0044017D 0044017D 0044017E 0044017E 0064017D 0064017E 0064017E +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0122 0123 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB 0059 0079 00DD 00FD 00FF 0176 0177 0178 +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 01E8 01E9 +0198 0199 +0136 0137 +004C 006C 0139 013A 013D 013E 013F 0140 0141 0142 +004C0059 004C0079 006C0059 006C0079 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +019A +019B +013B 013C +004D 006D +004E 006E 00D1 00F1 0143 0144 0147 0148 01F8 01F9 +004E0059 004E0079 006E0059 006E0079 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +019D +019E +014A 014B +0145 0146 +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0156 0157 +0053 0073 015A 015B 015C 015D 015E 015F 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0160 0161 +0054 0074 0162 0163 0164 0165 021A 021B +00540059 00540079 00740059 00740079 +01BE +005400540059 005400740079 007400540059 007400740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +01B3 01B4 +005A 007A 0179 017A 017B 017C +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +017D 017E +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_ro_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C3 00C4 00C5 00E0 00E1 00E3 00E4 00E5 0100 0101 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0102 0103 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00C2 00E2 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CF 00EC 00ED 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +00CE 00EE +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 0160 0161 017F +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +015E 015F 0218 0219 +01A9 +01AA +0054 0074 0164 0165 +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0162 0163 021A 021B +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_sl_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0108 0109 010A 010B +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +010C 010D +0106 0107 +0187 0188 +0044 0064 00D0 00F0 010E 010F +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0064005A 0064007A 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0044017D 0044017D 0044017E 0044017E 0064017D 0064017E 0064017E +0110 0111 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +0160 0161 +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +017D 017E +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_pl_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0104 0105 +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0106 0107 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +0118 0119 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +0141 0142 +019A +019B +004D 006D +004E 006E 00D1 00F1 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +0143 0144 +019D +019E +014A 014B +004F 006F 00D2 00D4 00D5 00D6 00D8 00F2 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +00D3 00F3 1EDA 1EDB +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +015A 015B +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +0179 017A +017B 017C +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_et_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C5 00E0 00E1 00E2 00E3 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0064005A 0064007A +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0044017D 0044017D 0044017E 0044017E 0064017D 0064017E 0064017E +01C4 01C5 01C6 01F1 01F2 01F3 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D8 00F2 00F3 00F4 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0160 0161 +005A 007A 0179 017A 017B 017C +005A0053 005A0073 007A0053 007A0073 +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +017D 017E +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00F9 00FA 00FB 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +00D5 00F5 1EE0 1EE1 +00C4 00E4 01DE 01DF +00D6 00F6 +00DC 00FC 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +018D +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_es_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +00D1 00F1 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_sv_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00E0 00E1 00E2 00E3 0100 0101 0102 0103 0104 0105 01CD 01CE 01E0 01E1 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D5 00F2 00F3 00F5 014C 014D 014E 014F 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 1ECC 1ECD 1ECE 1ECF 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +00DE 00FE +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00F9 00FA 00FB 0168 0169 016A 016B 016C 016D 016E 016F 0172 0173 01AF 01B0 01D3 01D4 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +00DC 00FC 0170 0171 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +00C5 00E5 01FA 01FB +00C4 00E4 01DE 01DF 00C6 00E6 01E2 01E3 01FC 01FD 0118 0119 +00D4 00D6 00D8 00F4 00F6 00F8 0150 0151 01FE 01FF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 0152 0153 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_tr_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +00C7 00E7 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +011E 011F +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 00CC 00CD 00CE 00CF 0128 012A 012C 012E 01CF 1EC8 1ECA 0131 +0049004A 0049006A +0069 00EC 00ED 00EE 00EF 0129 012B 012D 012F 0130 01D0 1EC9 1ECB +0069004A 0069006A 0132 0133 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D8 00F2 00F3 00F4 00F5 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +00D6 00F6 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +015E 015F +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00F9 00FA 00FB 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +00DC 00FC 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_cs_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B +004300430053 004300630073 006300430053 006300630073 +00430053 00430073 00630053 00630073 +010C 010D +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0064005A 0064007A 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0044017D 0044017D 0044017E 0044017E 0064017D 0064017E 0064017E +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +00430048 00430068 00630048 00630068 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +0158 0159 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +0160 0161 +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +017D 017E +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_da_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00E0 00E1 00E2 00E3 0100 0101 0102 0103 0104 0105 01CD 01CE 01E0 01E1 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00610041 +00410045 00410065 00610045 00610065 +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00F2 00F3 00F4 00F5 014C 014D 014E 014F 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +00DE 00FE +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00F9 00FA 00FB 0168 0169 016A 016B 016C 016D 016E 016F 0172 0173 01AF 01B0 01D3 01D4 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +00DC 00FC 0170 0171 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +00C4 00E4 01DE 01DF 00C6 00E6 01E2 01E3 01FC 01FD +00D6 00D8 00F6 00F8 0150 0151 01FE 01FF 0152 0153 +00C5 00E5 01FA 01FB 00410041 00410061 00610061 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_lt_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +010C 010D +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0064005A 0064007A 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0044017D 0044017D 0044017E 0044017E 0064017D 0064017E 0064017E +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB 0059 0079 00DD 00FD 00FF 0176 0177 0178 +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C0059 004C0079 006C0059 006C0079 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E0059 004E0079 006E0059 006E0079 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +0160 0161 +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +00540059 00540079 00740059 00740079 +01BE +005400540059 005400740079 007400540059 007400740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +01B3 01B4 +005A 007A 0179 017A 017B 017C +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +017D 017E +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_sk_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C5 00E0 00E1 00E2 00E3 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +00C4 00E4 01DE 01DF +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B +004300430053 004300630073 006300430053 006300630073 +00430053 00430073 00630053 00630073 +010C 010D +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0064005A 0064007A 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0044017D 0044017D 0044017E 0044017E 0064017D 0064017E 0064017E +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +00430048 00430068 00630048 00630068 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D5 00D6 00D8 00F2 00F3 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +00D4 00F4 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +0158 0159 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +0160 0161 +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +017D 017E +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_es_trad_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00630048 +00430053 00430073 00630053 00630073 +00430048 00430068 00630068 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +006C004C +006C004C0059 +004C0059 004C0079 006C0059 006C0079 +004C004C 004C006C 006C006C +004C004C0059 004C006C0079 006C006C0079 +019A +019B +004D 006D +004E 006E 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +00D1 00F1 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_la_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB 004A 006A 0134 0135 01F0 +0049004A 0049006A 0069004A 0069006A +0132 0133 +0131 +0197 +0196 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A +01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A +01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +019C +01B1 +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 0056 0076 +00550045 00550065 00750045 00750065 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_eo_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0108 0109 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +011C 011D +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0126 0127 +0124 0125 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 01F0 +0134 0135 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +015C 015D +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +016C 016D +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_hu_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +006300430053 +00430048 00430068 00630048 00630068 +00630053 +00430053 00430073 00630073 +004300430053 004300630073 006300630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F 0110 0111 +00640044005A +00640044005A0053 +0044017D 0044017D 0044017E 0044017E 0064005A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0064005A0053 0064005A0073 +0044005A 0044007A 0064007A +00440044005A 00440064007A 00640064007A +0044005A0073 0044007A0053 0064007A0053 +0044005A0053 0044007A0073 0064007A0073 +00440044005A0053 00440064007A0073 00640064007A0073 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +006700470059 +00670059 +00470059 00470079 00670079 +004700470059 004700670079 006700670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +006C004C0059 +006C0059 +004C0059 004C0079 006C0079 +004C004C0059 004C006C0079 006C006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +006E004E0059 +006E0059 +004E0059 004E0079 006E0079 +004E004E0059 004E006E0079 006E006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D8 00F2 00F3 00F4 00F5 00F8 014C 014D 014E 014F 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +00D6 00F6 0150 0151 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00730053005A +0073005A +0053005A 0053007A 0073007A +00530053005A 00530073007A 00730073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +007400540059 +00740059 +00540059 00540079 00740079 +005400540059 005400740079 007400740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00F9 00FA 00FB 0168 0169 016A 016B 016C 016D 016E 016F 0172 0173 01AF 01B0 01D3 01D4 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +00DC 00FC 0170 0171 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +007A0053 +018D +007A005A0053 +005A0053 005A0073 007A0073 +005A005A0053 005A007A0073 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_hr_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C2 00C3 00C4 00C5 00E0 00E1 00E2 00E3 00E4 00E5 0100 0101 0102 0103 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0108 0109 010A 010B +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +010C 010D +0106 0107 +0187 0188 +0044 0064 00D0 00F0 010E 010F +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0064005A 0064007A 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0064017D +0044017D 0044017D 0044017E 0044017E 0064017E 0064017E 01C4 01C5 01C6 +0110 0111 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CA 00CB 00E8 00E9 00EA 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +006C004A +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +004C004A 004C006A 006C006A 01C7 01C8 01C9 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +006E004A +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +004E004A 004E006A 006E006A 01CA 01CB 01CC +019D +019E +014A 014B +004F 006F 00D2 00D3 00D4 00D5 00D6 00D8 00F2 00F3 00F4 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01A0 01A1 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +004F0045 004F0065 006F0045 006F0065 0152 0153 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +0160 0161 +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01AF 01B0 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +00550045 00550065 00750045 00750065 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +017D 017E +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +SELECT GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') FROM t1 GROUP BY c1 COLLATE utf8mb4_vi_0900_ai_ci; +GROUP_CONCAT(HEX(CONVERT(c1 USING utf16)) ORDER BY c1, HEX(c1) SEPARATOR ' ') +00F7 +00D7 +0041 0061 00C0 00C1 00C3 00C4 00C5 00E0 00E1 00E3 00E4 00E5 0100 0101 0104 0105 01CD 01CE 01DE 01DF 01E0 01E1 01FA 01FB 1EA0 1EA1 1EA2 1EA3 +00410041 00410061 00610041 00610061 +00410045 00410065 00610045 00610065 00C6 00E6 01E2 01E3 01FC 01FD +0102 0103 1EAE 1EAF 1EB0 1EB1 1EB2 1EB3 1EB4 1EB5 1EB6 1EB7 +00C2 00E2 1EA4 1EA5 1EA6 1EA7 1EA8 1EA9 1EAA 1EAB 1EAC 1EAD +0042 0062 +0180 +0181 +0182 0183 +0043 0063 00C7 00E7 0106 0107 0108 0109 010A 010B 010C 010D +004300430053 004300630073 006300430053 006300630073 +00430048 00430068 00630048 00630068 +00430053 00430073 00630053 00630073 +0187 0188 +0044 0064 00D0 00F0 010E 010F +00440044005A 00440064007A 00640044005A 00640064007A +00440044005A0053 00440064007A0073 00640044005A0053 00640064007A0073 +0044005A 0044007A 0044017D 0044017D 0044017E 0044017E 0064005A 0064007A 0064017D 0064017E 0064017E 01C4 01C5 01C6 01F1 01F2 01F3 +0044005A0053 0044005A0073 0044007A0053 0044007A0073 0064005A0053 0064005A0073 0064007A0053 0064007A0073 +0110 0111 +0189 +018A +018B 018C +0045 0065 00C8 00C9 00CB 00E8 00E9 00EB 0112 0113 0114 0115 0116 0117 0118 0119 011A 011B 1EB8 1EB9 1EBA 1EBB 1EBC 1EBD +00CA 00EA 1EBE 1EBF 1EC0 1EC1 1EC2 1EC3 1EC4 1EC5 1EC6 1EC7 +018E 01DD +018F +0190 +0046 0066 +0191 0192 +0047 0067 011C 011D 011E 011F 0120 0121 0122 0123 01E6 01E7 01F4 01F5 +004700470059 004700670079 006700470059 006700670079 +00470059 00470079 00670059 00670079 +01E4 01E5 +0193 +0194 +01A2 01A3 +0048 0068 0124 0125 0126 0127 +0195 01F6 +0049 0069 00CC 00CD 00CE 00CF 00EC 00ED 00EE 00EF 0128 0129 012A 012B 012C 012D 012E 012F 0130 01CF 01D0 1EC8 1EC9 1ECA 1ECB +0049004A 0049006A 0069004A 0069006A 0132 0133 +0131 +0197 +0196 +004A 006A 0134 0135 01F0 +004B 006B 0136 0137 01E8 01E9 +0198 0199 +004C 006C 0139 013A 013B 013C 013D 013E 013F 0140 0141 0142 +004C004A 004C006A 006C004A 006C006A 01C7 01C8 01C9 +004C004C 004C006C 006C004C 006C006C +004C004C0059 004C006C0079 006C004C0059 006C006C0079 +004C0059 004C0079 006C0059 006C0079 +019A +019B +004D 006D +004E 006E 00D1 00F1 0143 0144 0145 0146 0147 0148 01F8 01F9 +004E004A 004E006A 006E004A 006E006A 01CA 01CB 01CC +004E004E0059 004E006E0079 006E004E0059 006E006E0079 +004E0059 004E0079 006E0059 006E0079 +019D +019E +014A 014B +004F 006F 00D2 00D3 00D5 00D6 00D8 00F2 00F3 00F5 00F6 00F8 014C 014D 014E 014F 0150 0151 01D1 01D2 01EA 01EB 01EC 01ED 01FE 01FF 1ECC 1ECD 1ECE 1ECF +004F0045 004F0065 006F0045 006F0065 0152 0153 +00D4 00F4 1ED0 1ED1 1ED2 1ED3 1ED4 1ED5 1ED6 1ED7 1ED8 1ED9 +01A0 01A1 1EDA 1EDB 1EDC 1EDD 1EDE 1EDF 1EE0 1EE1 1EE2 1EE3 +0186 +019F +0050 0070 +01A4 01A5 +0051 0071 +0138 +0052 0072 0154 0155 0156 0157 0158 0159 +00520052 00520052 00520072 00520072 00720052 00720052 00720072 00720072 +01A6 +0053 0073 015A 015B 015C 015D 015E 015F 0160 0161 017F 0218 0219 +00530053 00530073 00730053 00730073 00DF +00530053005A 00530073007A 00730053005A 00730073007A +0053005A 0053007A 0073005A 0073007A +01A9 +01AA +0054 0074 0162 0163 0164 0165 021A 021B +01BE +005400540059 005400740079 007400540059 007400740079 +00540059 00540079 00740059 00740079 +0166 0167 +01AB +01AC 01AD +01AE +0055 0075 00D9 00DA 00DB 00DC 00F9 00FA 00FB 00FC 0168 0169 016A 016B 016C 016D 016E 016F 0170 0171 0172 0173 01D3 01D4 01D5 01D6 01D7 01D8 01D9 01DA 01DB 01DC 1EE4 1EE5 1EE6 1EE7 +00550045 00550065 00750045 00750065 +01AF 01B0 1EE8 1EE9 1EEA 1EEB 1EEC 1EED 1EEE 1EEF 1EF0 1EF1 +019C +01B1 +0056 0076 +01B2 +0057 0077 0174 0175 +0058 0078 +0059 0079 00DD 00FD 00FF 0176 0177 0178 +01B3 01B4 +005A 007A 0179 017A 017B 017C 017D 017E +005A0053 005A0073 007A0053 007A0073 +018D +005A005A0053 005A007A0073 007A005A0053 007A007A0073 +01B5 01B6 +01B7 01EE 01EF +01B8 01B9 +01BA +00DE 00FE +01BF 01F7 +01BB +01A7 01A8 +01BC 01BD +0184 0185 +0149 +01C0 +01C1 +01C2 +01C3 +0D96 +0DA4 +0DA5 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(1)) COLLATE utf8mb4_da_0900_ai_ci; +INSERT INTO t1 VALUES('a'), ('b'), ('c'), ('d'), ('e'); +SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +HEX(a) HEX(WEIGHT_STRING(a)) +61 1C47 +62 1C60 +63 1C7A +64 1C8F +65 1CAA +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES(_utf16 0x00C4), (_utf16 0x00C5), (_utf16 0x00C6), (_utf16 0x00D8), (_utf16 0x00D6); +SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, BINARY a; +HEX(a) HEX(WEIGHT_STRING(a)) +C384 1F9854A5 +C386 1F9854A5 +C396 1F9854A6 +C398 1F9854A6 +C385 1F9854A7 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(10)) COLLATE utf8mb4_da_0900_ai_ci; +INSERT INTO t1 VALUES(_utf16 0x015A, _utf16 0x00DF), (_utf16 0x0162, _utf16 0x00DE), (_utf16 0x01CF, _utf16 0x0132), (_utf16 0x01F8, _utf16 0x01CA), (_utf16 0x42, _utf16 0x1d2d); +SELECT HEX(CONVERT(a USING UTF16)) AS U16_a, HEX(CONVERT(b USING UTF16)) AS U16_b, a 3E +| 7C +~ 7E +$ 24 +0 30 +1 31 +2 32 +3 33 +4 34 +5 35 +6 36 +7 37 +8 38 +9 39 +Aa 41,61 +Bb 42,62 +Cc 43,63 +Dd 44,64 +Ee 45,65 +Ff 46,66 +Gg 47,67 +Hh 48,68 +Ii 49,69 +Jj 4A,6A +Kk 4B,6B +Ll 4C,6C +Mm 4D,6D +Nn 4E,6E +Oo 4F,6F +Pp 50,70 +Qq 51,71 +Rr 52,72 +Ss 53,73 +Tt 54,74 +Uu 55,75 +Vv 56,76 +Ww 57,77 +Xx 58,78 +Yy 59,79 +Zz 5A,7A +drop table t1; +SELECT HEX(WEIGHT_STRING('aA')); +HEX(WEIGHT_STRING('aA')) +1C471C47000000200020 +SELECT HEX(WEIGHT_STRING(CAST(_utf32 x'337F' AS CHAR))); +HEX(WEIGHT_STRING(CAST(_utf32 x'337F' AS CHAR))) +FB40E82AFB40DF0FFB40CF1AFB40F93E00000020002000200020 +SELECT HEX(WEIGHT_STRING(CAST(_utf32 x'FDFA' AS CHAR))); +HEX(WEIGHT_STRING(CAST(_utf32 x'FDFA' AS CHAR))) +2364239C23C50209230B239C239C23B1000000200020002000200020002000200020 +select @@collation_connection; +@@collation_connection +utf8mb4_0900_as_ci +select hex(weight_string('a')); +hex(weight_string('a')) +1C4700000020 +select hex(weight_string('A')); +hex(weight_string('A')) +1C4700000020 +select hex(weight_string('abc')); +hex(weight_string('abc')) +1C471C601C7A0000002000200020 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +1C471C60000000200020 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +1C471C601C7A0000002000200020 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +1C471C601C7A0000002000200020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +1C +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +1C471C6000 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +1C471C60000000200020000000000000000000000000000000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +1C +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +1C471C601C +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +1C471C601C7A00000020002000200000000000000000000000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +1C +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +1C471C601C +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +1C471C601C7A00000020002000200000000000000000000000 +select @@collation_connection; +@@collation_connection +utf8mb4_0900_as_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +1C2A00000020 +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +1C2A1C2A1C2A0000002000200020 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +1C2A1C2A000000200020 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +1C2A1C2A1C2A0000002000200020 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +1C2A1C2A1C2A0000002000200020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +1C2A1C2A00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +1C2A1C2A000000200020000000000000000000000000000000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +1C2A1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +1C2A1C2A1C2A00000020002000200000000000000000000000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +1C2A1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +1C2A1C2A1C2A00000020002000200000000000000000000000 +CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A); +INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C); +INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E); +INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242); +INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244); +INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246); +INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248); +INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A); +INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C); +INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E); +INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B); +INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289); +INSERT INTO t1 VALUES (_utf32 0x028C); +INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C); +INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD); +INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF); +INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF); +INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7); +INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB); +INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD); +INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF); +INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511); +INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513); +INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1); +INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3); +INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5); +INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7); +INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01); +INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03); +INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05); +INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07); +INSERT INTO t1 VALUES (_utf32 0x1D7D); +INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E); +INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184); +INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81); +INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83); +INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85); +INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87); +INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89); +INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B); +INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D); +INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F); +INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61); +INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63); +INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65); +INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67); +INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69); +INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B); +INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75); +INSERT INTO t1 VALUES (_utf32 0x2C76); +INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01); +INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03); +INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05); +INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07); +INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31); +INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33); +INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35); +INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37); +INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401); +INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403); +INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405); +INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407); +INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429); +INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B); +INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D); +INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F); +INSERT INTO t1 VALUES (_utf32 0x0370); +INSERT INTO t1 VALUES (_utf32 0x0371); +INSERT INTO t1 VALUES (_utf32 0x0372); +INSERT INTO t1 VALUES (_utf32 0x0373); +INSERT INTO t1 VALUES (_utf32 0x0514); +INSERT INTO t1 VALUES (_utf32 0x0515); +INSERT INTO t1 VALUES (_utf32 0x0516); +INSERT INTO t1 VALUES (_utf32 0x0517); +INSERT INTO t1 VALUES (_utf32 0xA640); +INSERT INTO t1 VALUES (_utf32 0xA641); +INSERT INTO t1 VALUES (_utf32 0xA642); +INSERT INTO t1 VALUES (_utf32 0xA643); +INSERT INTO t1 VALUES (_utf32 0xA722); +INSERT INTO t1 VALUES (_utf32 0xA723); +INSERT INTO t1 VALUES (_utf32 0xA724); +INSERT INTO t1 VALUES (_utf32 0xA725); +INSERT INTO t1 VALUES (_utf32 0xA726); +INSERT INTO t1 VALUES (_utf32 0xA727); +INSERT INTO t1 VALUES (_utf32 0xA728); +INSERT INTO t1 VALUES (_utf32 0xA729); +INSERT INTO t1 VALUES (_utf32 0xA72A); +INSERT INTO t1 VALUES (_utf32 0xA72B); +INSERT INTO t1 VALUES (_utf32 0x2CEB); +INSERT INTO t1 VALUES (_utf32 0x2CEC); +INSERT INTO t1 VALUES (_utf32 0x2CED); +INSERT INTO t1 VALUES (_utf32 0x2CEE); +INSERT INTO t1 VALUES (_utf32 0x1FA01); +INSERT INTO t1 VALUES (_utf32 0x1FB01); +INSERT INTO t1 VALUES (_utf32 0x1FC01); +INSERT INTO t1 VALUES (_utf32 0x1FD01); +INSERT INTO t1 VALUES (_utf32 0x1F603); +INSERT INTO t1 VALUES (_utf32 0x1F604); +INSERT INTO t1 VALUES (_utf32 0x1F648); +INSERT INTO t1 VALUES (_utf32 0x1F64F); +INSERT INTO t1 VALUES (_utf32 0x2B759); +INSERT INTO t1 VALUES (_utf32 0x2B760); +INSERT INTO t1 VALUES (_utf32 0x2B761); +INSERT INTO t1 VALUES (_utf32 0x2B762); +INSERT INTO t1 VALUES (_utf32 0x16F00); +INSERT INTO t1 VALUES (_utf32 0x16F01); +INSERT INTO t1 VALUES (_utf32 0x08A2); +INSERT INTO t1 VALUES (_utf32 0x08A3); +INSERT INTO t1 VALUES (_utf32 0xA794); +INSERT INTO t1 VALUES (_utf32 0xA795); +INSERT INTO t1 VALUES (_utf32 0xA796); +INSERT INTO t1 VALUES (_utf32 0xA797); +INSERT INTO t1 VALUES (_utf32 0xAB37); +INSERT INTO t1 VALUES (_utf32 0xAB38); +INSERT INTO t1 VALUES (_utf32 0x10600); +INSERT INTO t1 VALUES (_utf32 0x10601); +INSERT INTO t1 VALUES (_utf32 0x10602); +INSERT INTO t1 VALUES (_utf32 0x10603); +INSERT INTO t1 VALUES (_utf32 0x1F800); +INSERT INTO t1 VALUES (_utf32 0x1F801); +INSERT INTO t1 VALUES (_utf32 0x1F802); +INSERT INTO t1 VALUES (_utf32 0x1F803); +INSERT INTO t1 VALUES (_utf32 0x10C92); +INSERT INTO t1 VALUES (_utf32 0x10C93); +INSERT INTO t1 VALUES (_utf32 0x10C94); +INSERT INTO t1 VALUES (_utf32 0x10C95); +INSERT INTO t1 VALUES (_utf32 0x2B836); +INSERT INTO t1 VALUES (_utf32 0x2B837); +INSERT INTO t1 VALUES (_utf32 0x2B838); +INSERT INTO t1 VALUES (_utf32 0x2B839); +SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c +FROM t1 ORDER BY c, BINARY c; +hex(c) hex(lower(c)) hex(upper(c)) hex(weight_string(c)) c +F09F9883 F09F9883 F09F9883 15FE00000020 😃 +F09F9884 F09F9884 F09F9884 15FF00000020 😄 +F09F9988 F09F9988 F09F9988 164300000020 🙈 +F09F998F F09F998F F09F998F 164A00000020 🙏 +F09FA080 F09FA080 F09FA080 17AB00000020 🠀 +F09FA081 F09FA081 F09FA081 17AC00000020 🠁 +F09FA082 F09FA082 F09FA082 17AD00000020 🠂 +F09FA083 F09FA083 F09FA083 17AE00000020 🠃 +C8BA C8BA 1C4C00000020 Ⱥ +E2B1A5 E2B1A5 C8BA 1C4C00000020 ⱥ +C680 C680 C983 1C6800000020 ƀ +C983 C680 C983 1C6800000020 Ƀ +EA9E96 EA9E97 EA9E96 1C6F00000020 Ꞗ +EA9E97 EA9E97 EA9E96 1C6F00000020 ꞗ +C8BB C8BC C8BB 1C7F00000020 Ȼ +C8BC C8BC C8BB 1C7F00000020 ȼ +EA9E94 EA9E94 EA9E94 1C8400000020 ꞔ +E28683 E28684 E28683 1C8D00000020 Ↄ +E28684 E28684 E28683 1C8D00000020 ↄ +C986 C987 C986 1CB100000020 Ɇ +C987 C987 C986 1CB100000020 ɇ +E284B2 E2858E E284B2 1CF200000020 Ⅎ +E2858E E2858E E284B2 1CF200000020 ⅎ +EA9E95 EA9E95 EA9E95 1D2400000020 ꞕ +E2B1A7 E2B1A8 E2B1A7 1D2900000020 Ⱨ +E2B1A8 E2B1A8 E2B1A7 1D2900000020 ⱨ +E2B1B5 E2B1B6 E2B1B5 1D2A00000020 Ⱶ +E2B1B6 E2B1B6 E2B1B5 1D2A00000020 ⱶ +EA9CA6 EA9CA7 EA9CA6 1D2B00000020 Ꜧ +EA9CA7 EA9CA7 EA9CA6 1D2B00000020 ꜧ +C988 C989 C988 1D5500000020 Ɉ +C989 C989 C988 1D5500000020 ɉ +E2B1A9 E2B1AA E2B1A9 1D6F00000020 Ⱪ +E2B1AA E2B1AA E2B1A9 1D6F00000020 ⱪ +C8BD C69A C8BD 1D8200000020 Ƚ +E2B1A0 E2B1A1 E2B1A0 1D8600000020 Ⱡ +E2B1A1 E2B1A1 E2B1A0 1D8600000020 ⱡ +C9AB C9AB 1D8700000020 ɫ +E2B1A2 C9AB E2B1A2 1D8700000020 Ɫ +EAACB8 EAACB8 EAACB8 1D8B00000020 ꬸ +EAACB7 EAACB7 EAACB7 1D9100000020 ꬷ +E1B5BD E1B5BD E2B1A3 1E1100000020 ᵽ +E2B1A3 E1B5BD E2B1A3 1E1100000020 Ᵽ +C98A C98B C98A 1E2B00000020 Ɋ +C98B C98B C98A 1E2B00000020 ɋ +C98C C98D C98C 1E3F00000020 Ɍ +C98D C98D C98C 1E3F00000020 ɍ +C9BD C9BD 1E5700000020 ɽ +E2B1A4 C9BD E2B1A4 1E5700000020 Ɽ +EA9CA8 EA9CA9 EA9CA8 1E951F21000000200020 Ꜩ +EA9CA9 EA9CA9 EA9CA8 1E951F21000000200020 ꜩ +C8BE C8BE 1E9E00000020 Ⱦ +E2B1A6 E2B1A6 C8BE 1E9E00000020 ⱦ +C984 CA89 C984 1EC000000020 Ʉ +CA89 CA89 C984 1EC000000020 ʉ +C985 CA8C C985 1EF100000020 Ʌ +CA8C CA8C C985 1EF100000020 ʌ +C98E C98F C98E 1F1300000020 Ɏ +C98F C98F C98E 1F1300000020 ɏ +E2B1AB E2B1AC E2B1AB 1F3C00000020 Ⱬ +E2B1AC E2B1AC E2B1AB 1F3C00000020 ⱬ +EA9CAA EA9CAB EA9CAA 1F6600000020 Ꜫ +EA9CAB EA9CAB EA9CAA 1F6600000020 ꜫ +C981 C982 C981 1F7900000020 Ɂ +C982 C982 C981 1F7900000020 ɂ +EA9CA2 EA9CA3 EA9CA2 1F8100000020 Ꜣ +EA9CA3 EA9CA3 EA9CA2 1F8100000020 ꜣ +EA9CA4 EA9CA5 EA9CA4 1F8C00000020 Ꜥ +EA9CA5 EA9CA5 EA9CA4 1F8C00000020 ꜥ +CDB0 CDB1 CDB0 1FC300000020 Ͱ +CDB1 CDB1 CDB0 1FC300000020 ͱ +CDBC CDBC CFBE 1FD800000020 ͼ +CFBE CDBC CFBE 1FD800000020 Ͼ +CDBB CDBB CFBD 1FD900000020 ͻ +CFBD CDBB CFBD 1FD900000020 Ͻ +CDBD CDBD CFBF 1FDA00000020 ͽ +CFBF CDBD CFBF 1FDA00000020 Ͽ +CDB2 CDB3 CDB2 1FE400000020 Ͳ +CDB3 CDB3 CDB2 1FE400000020 ͳ +E2B280 E2B281 E2B280 1FE600000020 Ⲁ +E2B281 E2B281 E2B280 1FE600000020 ⲁ +E2B282 E2B283 E2B282 1FE700000020 Ⲃ +E2B283 E2B283 E2B282 1FE700000020 ⲃ +E2B284 E2B285 E2B284 1FE800000020 Ⲅ +E2B285 E2B285 E2B284 1FE800000020 ⲅ +E2B286 E2B287 E2B286 1FE900000020 Ⲇ +E2B287 E2B287 E2B286 1FE900000020 ⲇ +E2B288 E2B289 E2B288 1FEA00000020 Ⲉ +E2B289 E2B289 E2B288 1FEA00000020 ⲉ +E2B28A E2B28B E2B28A 1FEC00000020 Ⲋ +E2B28B E2B28B E2B28A 1FEC00000020 ⲋ +E2B28C E2B28D E2B28C 1FED00000020 Ⲍ +E2B28D E2B28D E2B28C 1FED00000020 ⲍ +E2B28E E2B28F E2B28E 1FEE00000020 Ⲏ +E2B28F E2B28F E2B28E 1FEE00000020 ⲏ +E2B3AB E2B3AC E2B3AB 200600000020 Ⳬ +E2B3AC E2B3AC E2B3AB 200600000020 ⳬ +E2B3AD E2B3AE E2B3AD 201600000020 Ⳮ +E2B3AE E2B3AE E2B3AD 201600000020 ⳮ +D3BA D3BB D3BA 203E00000020 Ӻ +D3BB D3BB D3BA 203E00000020 ӻ +D3B6 D3B7 D3B6 204600000020 Ӷ +D3B7 D3B7 D3B6 204600000020 ӷ +EA9980 EA9981 EA9980 207000000020 Ꙁ +EA9981 EA9981 EA9980 207000000020 ꙁ +D490 D491 D490 207200000020 Ԑ +D491 D491 D490 207200000020 ԑ +EA9982 EA9983 EA9982 207300000020 Ꙃ +EA9983 EA9983 EA9982 207300000020 ꙃ +D492 D493 D492 20BA00000020 Ԓ +D493 D493 D492 20BA00000020 ԓ +D494 D495 D494 20C200000020 Ԕ +D495 D495 D494 20C200000020 ԕ +D496 D497 D496 210400000020 Ԗ +D497 D497 D496 210400000020 ԗ +D3BC D3BD D3BC 213600000020 Ӽ +D3BD D3BD D3BC 213600000020 ӽ +D3BE D3BF D3BE 213A00000020 Ӿ +D3BF D3BF D3BE 213A00000020 ӿ +D380 D38F D380 21E100000020 Ӏ +D38F D38F D380 21E100000020 ӏ +E2B080 E2B0B0 E2B080 21E500000020 Ⰰ +E2B0B0 E2B0B0 E2B080 21E500000020 ⰰ +E2B081 E2B0B1 E2B081 21E600000020 Ⰱ +E2B0B1 E2B0B1 E2B081 21E600000020 ⰱ +E2B082 E2B0B2 E2B082 21E700000020 Ⰲ +E2B0B2 E2B0B2 E2B082 21E700000020 ⰲ +E2B083 E2B0B3 E2B083 21E800000020 Ⰳ +E2B0B3 E2B0B3 E2B083 21E800000020 ⰳ +E2B084 E2B0B4 E2B084 21E900000020 Ⰴ +E2B0B4 E2B0B4 E2B084 21E900000020 ⰴ +E2B085 E2B0B5 E2B085 21EA00000020 Ⰵ +E2B0B5 E2B0B5 E2B085 21EA00000020 ⰵ +E2B086 E2B0B6 E2B086 21EB00000020 Ⰶ +E2B0B6 E2B0B6 E2B086 21EB00000020 ⰶ +E2B087 E2B0B7 E2B087 21EC00000020 Ⰷ +E2B0B7 E2B0B7 E2B087 21EC00000020 ⰷ +E182A0 E2B480 E182A0 223B00000020 Ⴀ +E2B480 E2B480 E182A0 223B00000020 ⴀ +E182A1 E2B481 E182A1 223D00000020 Ⴁ +E2B481 E2B481 E182A1 223D00000020 ⴁ +E182A2 E2B482 E182A2 223F00000020 Ⴂ +E2B482 E2B482 E182A2 223F00000020 ⴂ +E182A3 E2B483 E182A3 224100000020 Ⴃ +E2B483 E2B483 E182A3 224100000020 ⴃ +E182A4 E2B484 E182A4 224300000020 Ⴄ +E2B484 E2B484 E182A4 224300000020 ⴄ +E182A5 E2B485 E182A5 224500000020 Ⴅ +E2B485 E2B485 E182A5 224500000020 ⴅ +E182A6 E2B486 E182A6 224700000020 Ⴆ +E2B486 E2B486 E182A6 224700000020 ⴆ +E182A7 E2B487 E182A7 224B00000020 Ⴇ +E2B487 E2B487 E182A7 224B00000020 ⴇ +E0A2A2 E0A2A2 E0A2A2 232B00000020 ࢢ +E0A2A3 E0A2A3 E0A2A3 236D00000020 ࢣ +F090B292 F090B392 F090B292 371200000020 𐲒 +F090B293 F090B393 F090B293 371300000020 𐲓 +F090B294 F090B394 F090B294 371400000020 𐲔 +F090B295 F090B395 F090B295 371500000020 𐲕 +F096BC80 F096BC80 F096BC80 427A00000020 𖼀 +F096BC81 F096BC81 F096BC81 427B00000020 𖼁 +F0909080 F09090A8 F0909080 445200000020 𐐀 +F09090A8 F09090A8 F0909080 445200000020 𐐨 +F0909081 F09090A9 F0909081 445300000020 𐐁 +F09090A9 F09090A9 F0909081 445300000020 𐐩 +F0909082 F09090AA F0909082 445400000020 𐐂 +F09090AA F09090AA F0909082 445400000020 𐐪 +F0909083 F09090AB F0909083 445500000020 𐐃 +F09090AB F09090AB F0909083 445500000020 𐐫 +F0909084 F09090AC F0909084 445600000020 𐐄 +F09090AC F09090AC F0909084 445600000020 𐐬 +F0909085 F09090AD F0909085 445700000020 𐐅 +F09090AD F09090AD F0909085 445700000020 𐐭 +F0909086 F09090AE F0909086 445800000020 𐐆 +F09090AE F09090AE F0909086 445800000020 𐐮 +F0909087 F09090AF F0909087 445900000020 𐐇 +F09090AF F09090AF F0909087 445900000020 𐐯 +F0909880 F0909880 F0909880 46BA00000020 𐘀 +F0909881 F0909881 F0909881 46BB00000020 𐘁 +F0909882 F0909882 F0909882 46BC00000020 𐘂 +F0909883 F0909883 F0909883 46BD00000020 𐘃 +F0AB9D99 F0AB9D99 F0AB9D99 FB85B75900000020 𫝙 +F0AB9DA0 F0AB9DA0 F0AB9DA0 FB85B76000000020 𫝠 +F0AB9DA1 F0AB9DA1 F0AB9DA1 FB85B76100000020 𫝡 +F0AB9DA2 F0AB9DA2 F0AB9DA2 FB85B76200000020 𫝢 +F0ABA0B6 F0ABA0B6 F0ABA0B6 FB85B83600000020 𫠶 +F0ABA0B7 F0ABA0B7 F0ABA0B7 FB85B83700000020 𫠷 +F0ABA0B8 F0ABA0B8 F0ABA0B8 FB85B83800000020 𫠸 +F0ABA0B9 F0ABA0B9 F0ABA0B9 FB85B83900000020 𫠹 +F09FA881 F09FA881 F09FA881 FBC3FA0100000020 🨁 +F09FAC81 F09FAC81 F09FAC81 FBC3FB0100000020 🬁 +F09FB081 F09FB081 F09FB081 FBC3FC0100000020 🰁 +F09FB481 F09FB481 F09FB481 FBC3FD0100000020 🴁 +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400)); +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 1C4700000020 +61F0909080 1C474452000000200020 +61EFBFBF 1C47FBC1FFFF000000200020 +61F48FBFBF 1C47FBE1FFFF000000200020 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 445200000020 𐐀 +F09090A8 445200000020 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 445200000020 𐐀 +F09090A8 445200000020 𐐨 +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`c`) AS `hex(c)` from `test`.`t1` where (`test`.`t1`.`c` like 'a%') order by `test`.`t1`.`c` +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 1C4700000020 +61F0909080 1C474452000000200020 +61EFBFBF 1C47FBC1FFFF000000200020 +61F48FBFBF 1C47FBE1FFFF000000200020 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 445200000020 𐐀 +F09090A8 445200000020 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 445200000020 𐐀 +F09090A8 445200000020 𐐨 +DROP TABLE t1; +SELECT is_ipv4(inet_ntoa('1')); +is_ipv4(inet_ntoa('1')) +1 +SELECT is_ipv6(inet_ntoa('1')); +is_ipv6(inet_ntoa('1')) +0 +SELECT inet6_aton(inet_ntoa('1')); +inet6_aton(inet_ntoa('1')) + +SELECT inet6_ntoa(inet_ntoa('1')); +inet6_ntoa(inet_ntoa('1')) +NULL +# +# Bug#14040277 UNINITIALIZED VALUE REFERENCED IN STR_TO_IPV6 +# +SELECT inet6_aton(soundex('a')); +inet6_aton(soundex('a')) +NULL +# +# Bug#19047425 UNINITIALISED VALUE IN STR_TO_IPV6 +# +do is_ipv4_mapped(inet6_aton(convert(_ascii "a:" using utf8mb4))); +CREATE TABLE t1 (c VARCHAR(10) CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES (_utf8mb4 0xF09090A7), (_utf8mb4 0xEA8B93), (_utf8mb4 0xC4BC), (_utf8mb4 0xC6AD), (_utf8mb4 0xF090918F), (_utf8mb4 0xEAAD8B); +SELECT HEX(ANY_VALUE(c)), COUNT(c) FROM t1 GROUP BY c COLLATE utf8mb4_0900_as_ci; +HEX(ANY_VALUE(c)) COUNT(c) +C4BC 1 +C6AD 1 +EA8B93 1 +EAAD8B 1 +F09090A7 2 +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 (c1 CHAR(10) COLLATE utf8mb4_0900_as_ci); +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); +INSERT INTO t1 VALUES (_ucs2 0x1EA0),(_ucs2 0x1EA1),(_ucs2 0x1EA2),(_ucs2 0x1EA3); +INSERT INTO t1 VALUES (_ucs2 0x1EA4),(_ucs2 0x1EA5),(_ucs2 0x1EA6),(_ucs2 0x1EA7); +INSERT INTO t1 VALUES (_ucs2 0x1EA8),(_ucs2 0x1EA9),(_ucs2 0x1EAA),(_ucs2 0x1EAB); +INSERT INTO t1 VALUES (_ucs2 0x1EAC),(_ucs2 0x1EAD),(_ucs2 0x1EAE),(_ucs2 0x1EAF); +INSERT INTO t1 VALUES (_ucs2 0x1EB0),(_ucs2 0x1EB1),(_ucs2 0x1EB2),(_ucs2 0x1EB3); +INSERT INTO t1 VALUES (_ucs2 0x1EB4),(_ucs2 0x1EB5),(_ucs2 0x1EB6),(_ucs2 0x1EB7); +INSERT INTO t1 VALUES (_ucs2 0x1EB8),(_ucs2 0x1EB9),(_ucs2 0x1EBA),(_ucs2 0x1EBB); +INSERT INTO t1 VALUES (_ucs2 0x1EBC),(_ucs2 0x1EBD),(_ucs2 0x1EBE),(_ucs2 0x1EBF); +INSERT INTO t1 VALUES (_ucs2 0x1EC0),(_ucs2 0x1EC1),(_ucs2 0x1EC2),(_ucs2 0x1EC3); +INSERT INTO t1 VALUES (_ucs2 0x1EC4),(_ucs2 0x1EC5),(_ucs2 0x1EC6),(_ucs2 0x1EC7); +INSERT INTO t1 VALUES (_ucs2 0x1EC8),(_ucs2 0x1EC9),(_ucs2 0x1ECA),(_ucs2 0x1ECB); +INSERT INTO t1 VALUES (_ucs2 0x1ECC),(_ucs2 0x1ECD),(_ucs2 0x1ECE),(_ucs2 0x1ECF); +INSERT INTO t1 VALUES (_ucs2 0x1ED0),(_ucs2 0x1ED1),(_ucs2 0x1ED2),(_ucs2 0x1ED3); +INSERT INTO t1 VALUES (_ucs2 0x1ED4),(_ucs2 0x1ED5),(_ucs2 0x1ED6),(_ucs2 0x1ED7); +INSERT INTO t1 VALUES (_ucs2 0x1ED8),(_ucs2 0x1ED9),(_ucs2 0x1EDA),(_ucs2 0x1EDB); +INSERT INTO t1 VALUES (_ucs2 0x1EDC),(_ucs2 0x1EDD),(_ucs2 0x1EDE),(_ucs2 0x1EDF); +INSERT INTO t1 VALUES (_ucs2 0x1EE0),(_ucs2 0x1EE1),(_ucs2 0x1EE2),(_ucs2 0x1EE3); +INSERT INTO t1 VALUES (_ucs2 0x1EE4),(_ucs2 0x1EE5),(_ucs2 0x1EE6),(_ucs2 0x1EE7); +INSERT INTO t1 VALUES (_ucs2 0x1EE8),(_ucs2 0x1EE9),(_ucs2 0x1EEA),(_ucs2 0x1EEB); +INSERT INTO t1 VALUES (_ucs2 0x1EEC),(_ucs2 0x1EED),(_ucs2 0x1EEE),(_ucs2 0x1EEF); +INSERT INTO t1 VALUES (_ucs2 0x1EF0),(_ucs2 0x1EF1); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('AE'),('Ae'),('ae'),('aE'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +insert into t1 values (_ucs2 0x0218), (_ucs2 0x0219), (_ucs2 0x021a), (_ucs2 0x021b); +insert into t1 values (_ucs2 0x0d96), (_ucs2 0x0da4), (_ucs2 0x0da5); +insert into t1 values (_ucs2 0x0064017e), (_ucs2 0x0044017e), (_ucs2 0x0044017d); +insert into t1 values ('CS'),('Cs'),('cs'),('cS'); +insert into t1 values ('DZS'),('DZs'),('Dzs'),('DzS'); +insert into t1 values ('dZS'),('dZs'),('dzs'),('dzS'); +insert into t1 values ('GY'),('Gy'),('gy'),('gY'); +insert into t1 values ('LY'),('Ly'),('ly'),('lY'); +insert into t1 values ('NY'),('Ny'),('ny'),('nY'); +insert into t1 values ('SZ'),('Sz'),('sz'),('sZ'); +insert into t1 values ('TY'),('Ty'),('ty'),('tY'); +insert into t1 values ('ZS'),('Zs'),('zs'),('zS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +insert into t1 values ('ccs'),('Ccs'),('CCS'),('cCS'); +insert into t1 values ('ddz'),('Ddz'),('DDZ'),('dDZ'); +insert into t1 values ('ddzs'),('Ddzs'),('DDZS'),('dDZS'); +insert into t1 values ('ggy'),('Ggy'),('GGY'),('gGY'); +insert into t1 values ('lly'),('Lly'),('LLY'),('lLY'); +insert into t1 values ('nny'),('Nny'),('NNY'),('nNY'); +insert into t1 values ('ssz'),('Ssz'),('SSZ'),('sSZ'); +insert into t1 values ('tty'),('Tty'),('TTY'),('tTY'); +insert into t1 values ('zzs'),('Zzs'),('ZZS'),('zZS'); +insert into t1 values ('UE'),('Ue'),('ue'),('uE'); +SELECT c1, HEX(WEIGHT_STRING(c1)) FROM t1 ORDER BY c1, HEX(c1) COLLATE utf8mb4_0900_as_ci; +c1 HEX(WEIGHT_STRING(c1)) +÷ 061800000020 +× 061900000020 +A 1C4700000020 +a 1C4700000020 +Á 1C47000000200024 +á 1C47000000200024 +À 1C47000000200025 +à 1C47000000200025 +Ă 1C47000000200026 +ă 1C47000000200026 +Ắ 1C470000002000260024 +ắ 1C470000002000260024 +Ằ 1C470000002000260025 +ằ 1C470000002000260025 +Ẵ 1C47000000200026002D +ẵ 1C47000000200026002D +Ẳ 1C47000000200026003B +ẳ 1C47000000200026003B + 1C47000000200027 +â 1C47000000200027 +Ấ 1C470000002000270024 +ấ 1C470000002000270024 +Ầ 1C470000002000270025 +ầ 1C470000002000270025 +Ẫ 1C47000000200027002D +ẫ 1C47000000200027002D +Ẩ 1C47000000200027003B +ẩ 1C47000000200027003B +Ǎ 1C47000000200028 +ǎ 1C47000000200028 +Å 1C47000000200029 +å 1C47000000200029 +Ǻ 1C470000002000290024 +ǻ 1C470000002000290024 +Ä 1C4700000020002B +ä 1C4700000020002B +Ǟ 1C4700000020002B0032 +ǟ 1C4700000020002B0032 +à 1C4700000020002D +ã 1C4700000020002D +Ǡ 1C4700000020002E0032 +ǡ 1C4700000020002E0032 +Ą 1C47000000200031 +ą 1C47000000200031 +Ā 1C47000000200032 +ā 1C47000000200032 +Ả 1C4700000020003B +ả 1C4700000020003B +Ạ 1C47000000200042 +ạ 1C47000000200042 +Ặ 1C470000002000420026 +ặ 1C470000002000420026 +Ậ 1C470000002000420027 +ậ 1C470000002000420027 +AA 1C471C47000000200020 +Aa 1C471C47000000200020 +aA 1C471C47000000200020 +aa 1C471C47000000200020 +AE 1C471CAA000000200020 +Ae 1C471CAA000000200020 +aE 1C471CAA000000200020 +ae 1C471CAA000000200020 +Æ 1C471CAA0000002001100020 +æ 1C471CAA0000002001100020 +Ǽ 1C471CAA00000020011000200024 +ǽ 1C471CAA00000020011000200024 +Ǣ 1C471CAA00000020011000200032 +ǣ 1C471CAA00000020011000200032 +B 1C6000000020 +b 1C6000000020 +ƀ 1C6800000020 +Ɓ 1C7100000020 +Ƃ 1C7500000020 +ƃ 1C7500000020 +C 1C7A00000020 +c 1C7A00000020 +Ć 1C7A000000200024 +ć 1C7A000000200024 +Ĉ 1C7A000000200027 +ĉ 1C7A000000200027 +Č 1C7A000000200028 +č 1C7A000000200028 +Ċ 1C7A00000020002E +ċ 1C7A00000020002E +Ç 1C7A000000200030 +ç 1C7A000000200030 +CCS 1C7A1C7A1E710000002000200020 +Ccs 1C7A1C7A1E710000002000200020 +cCS 1C7A1C7A1E710000002000200020 +ccs 1C7A1C7A1E710000002000200020 +CH 1C7A1D18000000200020 +Ch 1C7A1D18000000200020 +cH 1C7A1D18000000200020 +ch 1C7A1D18000000200020 +CS 1C7A1E71000000200020 +Cs 1C7A1E71000000200020 +cS 1C7A1E71000000200020 +cs 1C7A1E71000000200020 +Ƈ 1C8500000020 +ƈ 1C8500000020 +D 1C8F00000020 +d 1C8F00000020 +Ď 1C8F000000200028 +ď 1C8F000000200028 +Đ 1C8F000000200039 +đ 1C8F000000200039 +Ð 1C8F000000200110 +ð 1C8F000000200110 +DDZ 1C8F1C8F1F210000002000200020 +Ddz 1C8F1C8F1F210000002000200020 +dDZ 1C8F1C8F1F210000002000200020 +ddz 1C8F1C8F1F210000002000200020 +DDZS 1C8F1C8F1F211E7100000020002000200020 +Ddzs 1C8F1C8F1F211E7100000020002000200020 +dDZS 1C8F1C8F1F211E7100000020002000200020 +ddzs 1C8F1C8F1F211E7100000020002000200020 +DZ 1C8F1F21000000200020 +Dz 1C8F1F21000000200020 +dZ 1C8F1F21000000200020 +dz 1C8F1F21000000200020 +DZ 1C8F1F21000000200020 +Dz 1C8F1F21000000200020 +dz 1C8F1F21000000200020 +DŽ 1C8F1F210000002000200028 +DŽ 1C8F1F210000002000200028 +Dž 1C8F1F210000002000200028 +Dž 1C8F1F210000002000200028 +dŽ 1C8F1F210000002000200028 +dž 1C8F1F210000002000200028 +dž 1C8F1F210000002000200028 +DŽ 1C8F1F210000002000200028 +Dž 1C8F1F210000002000200028 +dž 1C8F1F210000002000200028 +DZS 1C8F1F211E710000002000200020 +DZs 1C8F1F211E710000002000200020 +DzS 1C8F1F211E710000002000200020 +Dzs 1C8F1F211E710000002000200020 +dZS 1C8F1F211E710000002000200020 +dZs 1C8F1F211E710000002000200020 +dzS 1C8F1F211E710000002000200020 +dzs 1C8F1F211E710000002000200020 +Ɖ 1C9700000020 +Ɗ 1C9B00000020 +Ƌ 1CA000000020 +ƌ 1CA000000020 +E 1CAA00000020 +e 1CAA00000020 +É 1CAA000000200024 +é 1CAA000000200024 +È 1CAA000000200025 +è 1CAA000000200025 +Ĕ 1CAA000000200026 +ĕ 1CAA000000200026 +Ê 1CAA000000200027 +ê 1CAA000000200027 +Ế 1CAA0000002000270024 +ế 1CAA0000002000270024 +Ề 1CAA0000002000270025 +ề 1CAA0000002000270025 +Ễ 1CAA000000200027002D +ễ 1CAA000000200027002D +Ể 1CAA000000200027003B +ể 1CAA000000200027003B +Ě 1CAA000000200028 +ě 1CAA000000200028 +Ë 1CAA00000020002B +ë 1CAA00000020002B +Ẽ 1CAA00000020002D +ẽ 1CAA00000020002D +Ė 1CAA00000020002E +ė 1CAA00000020002E +Ę 1CAA000000200031 +ę 1CAA000000200031 +Ē 1CAA000000200032 +ē 1CAA000000200032 +Ẻ 1CAA00000020003B +ẻ 1CAA00000020003B +Ẹ 1CAA000000200042 +ẹ 1CAA000000200042 +Ệ 1CAA0000002000420027 +ệ 1CAA0000002000420027 +Ǝ 1CB800000020 +ǝ 1CB800000020 +Ə 1CBD00000020 +Ɛ 1CC200000020 +F 1CE500000020 +f 1CE500000020 +Ƒ 1CEE00000020 +ƒ 1CEE00000020 +G 1CF400000020 +g 1CF400000020 +Ǵ 1CF4000000200024 +ǵ 1CF4000000200024 +Ğ 1CF4000000200026 +ğ 1CF4000000200026 +Ĝ 1CF4000000200027 +ĝ 1CF4000000200027 +Ǧ 1CF4000000200028 +ǧ 1CF4000000200028 +Ġ 1CF400000020002E +ġ 1CF400000020002E +Ģ 1CF4000000200030 +ģ 1CF4000000200030 +GGY 1CF41CF41F0B0000002000200020 +Ggy 1CF41CF41F0B0000002000200020 +gGY 1CF41CF41F0B0000002000200020 +ggy 1CF41CF41F0B0000002000200020 +GY 1CF41F0B000000200020 +Gy 1CF41F0B000000200020 +gY 1CF41F0B000000200020 +gy 1CF41F0B000000200020 +Ǥ 1D0100000020 +ǥ 1D0100000020 +Ɠ 1D0600000020 +Ɣ 1D1000000020 +Ƣ 1D1400000020 +ƣ 1D1400000020 +H 1D1800000020 +h 1D1800000020 +Ĥ 1D18000000200027 +ĥ 1D18000000200027 +Ħ 1D18000000200039 +ħ 1D18000000200039 +ƕ 1D2000000020 +Ƕ 1D2000000020 +I 1D3200000020 +i 1D3200000020 +Í 1D32000000200024 +í 1D32000000200024 +Ì 1D32000000200025 +ì 1D32000000200025 +Ĭ 1D32000000200026 +ĭ 1D32000000200026 +Î 1D32000000200027 +î 1D32000000200027 +Ǐ 1D32000000200028 +ǐ 1D32000000200028 +Ï 1D3200000020002B +ï 1D3200000020002B +Ĩ 1D3200000020002D +ĩ 1D3200000020002D +İ 1D3200000020002E +Į 1D32000000200031 +į 1D32000000200031 +Ī 1D32000000200032 +ī 1D32000000200032 +Ỉ 1D3200000020003B +ỉ 1D3200000020003B +Ị 1D32000000200042 +ị 1D32000000200042 +IJ 1D321D4C000000200020 +Ij 1D321D4C000000200020 +iJ 1D321D4C000000200020 +ij 1D321D4C000000200020 +IJ 1D321D4C000000200020 +ij 1D321D4C000000200020 +ı 1D3600000020 +Ɨ 1D4100000020 +Ɩ 1D4700000020 +J 1D4C00000020 +j 1D4C00000020 +Ĵ 1D4C000000200027 +ĵ 1D4C000000200027 +ǰ 1D4C000000200028 +K 1D6500000020 +k 1D6500000020 +Ǩ 1D65000000200028 +ǩ 1D65000000200028 +Ķ 1D65000000200030 +ķ 1D65000000200030 +Ƙ 1D6B00000020 +ƙ 1D6B00000020 +L 1D7700000020 +l 1D7700000020 +Ĺ 1D77000000200024 +ĺ 1D77000000200024 +Ľ 1D77000000200028 +ľ 1D77000000200028 +Ļ 1D77000000200030 +ļ 1D77000000200030 +Ł 1D77000000200039 +ł 1D77000000200039 +Ŀ 1D77000000200110 +ŀ 1D77000000200110 +LJ 1D771D4C000000200020 +Lj 1D771D4C000000200020 +lJ 1D771D4C000000200020 +lj 1D771D4C000000200020 +LJ 1D771D4C000000200020 +Lj 1D771D4C000000200020 +lj 1D771D4C000000200020 +LL 1D771D77000000200020 +Ll 1D771D77000000200020 +lL 1D771D77000000200020 +ll 1D771D77000000200020 +LLY 1D771D771F0B0000002000200020 +Lly 1D771D771F0B0000002000200020 +lLY 1D771D771F0B0000002000200020 +lly 1D771D771F0B0000002000200020 +LY 1D771F0B000000200020 +Ly 1D771F0B000000200020 +lY 1D771F0B000000200020 +ly 1D771F0B000000200020 +ƚ 1D8200000020 +ƛ 1DA200000020 +M 1DAA00000020 +m 1DAA00000020 +N 1DB900000020 +n 1DB900000020 +Ń 1DB9000000200024 +ń 1DB9000000200024 +Ǹ 1DB9000000200025 +ǹ 1DB9000000200025 +Ň 1DB9000000200028 +ň 1DB9000000200028 +Ñ 1DB900000020002D +ñ 1DB900000020002D +Ņ 1DB9000000200030 +ņ 1DB9000000200030 +NJ 1DB91D4C000000200020 +Nj 1DB91D4C000000200020 +nJ 1DB91D4C000000200020 +nj 1DB91D4C000000200020 +NJ 1DB91D4C000000200020 +Nj 1DB91D4C000000200020 +nj 1DB91D4C000000200020 +NNY 1DB91DB91F0B0000002000200020 +Nny 1DB91DB91F0B0000002000200020 +nNY 1DB91DB91F0B0000002000200020 +nny 1DB91DB91F0B0000002000200020 +NY 1DB91F0B000000200020 +Ny 1DB91F0B000000200020 +nY 1DB91F0B000000200020 +ny 1DB91F0B000000200020 +Ɲ 1DC400000020 +ƞ 1DC800000020 +Ŋ 1DD800000020 +ŋ 1DD800000020 +O 1DDD00000020 +o 1DDD00000020 +Ó 1DDD000000200024 +ó 1DDD000000200024 +Ò 1DDD000000200025 +ò 1DDD000000200025 +Ŏ 1DDD000000200026 +ŏ 1DDD000000200026 +Ô 1DDD000000200027 +ô 1DDD000000200027 +Ố 1DDD0000002000270024 +ố 1DDD0000002000270024 +Ồ 1DDD0000002000270025 +ồ 1DDD0000002000270025 +Ỗ 1DDD000000200027002D +ỗ 1DDD000000200027002D +Ổ 1DDD000000200027003B +ổ 1DDD000000200027003B +Ǒ 1DDD000000200028 +ǒ 1DDD000000200028 +Ö 1DDD00000020002B +ö 1DDD00000020002B +Ő 1DDD00000020002C +ő 1DDD00000020002C +Õ 1DDD00000020002D +õ 1DDD00000020002D +Ø 1DDD00000020002F +ø 1DDD00000020002F +Ǿ 1DDD00000020002F0024 +ǿ 1DDD00000020002F0024 +Ǫ 1DDD000000200031 +ǫ 1DDD000000200031 +Ǭ 1DDD0000002000310032 +ǭ 1DDD0000002000310032 +Ō 1DDD000000200032 +ō 1DDD000000200032 +Ỏ 1DDD00000020003B +ỏ 1DDD00000020003B +Ơ 1DDD00000020003F +ơ 1DDD00000020003F +Ớ 1DDD00000020003F0024 +ớ 1DDD00000020003F0024 +Ờ 1DDD00000020003F0025 +ờ 1DDD00000020003F0025 +Ỡ 1DDD00000020003F002D +ỡ 1DDD00000020003F002D +Ở 1DDD00000020003F003B +ở 1DDD00000020003F003B +Ợ 1DDD00000020003F0042 +ợ 1DDD00000020003F0042 +Ọ 1DDD000000200042 +ọ 1DDD000000200042 +Ộ 1DDD0000002000420027 +ộ 1DDD0000002000420027 +OE 1DDD1CAA000000200020 +Oe 1DDD1CAA000000200020 +oE 1DDD1CAA000000200020 +oe 1DDD1CAA000000200020 +Œ 1DDD1CAA0000002001100020 +œ 1DDD1CAA0000002001100020 +Ɔ 1DF000000020 +Ɵ 1DFD00000020 +P 1E0C00000020 +p 1E0C00000020 +Ƥ 1E1500000020 +ƥ 1E1500000020 +Q 1E2100000020 +q 1E2100000020 +ĸ 1E2F00000020 +R 1E3300000020 +r 1E3300000020 +Ŕ 1E33000000200024 +ŕ 1E33000000200024 +Ř 1E33000000200028 +ř 1E33000000200028 +Ŗ 1E33000000200030 +ŗ 1E33000000200030 +RR 1E331E33000000200020 +RR 1E331E33000000200020 +Rr 1E331E33000000200020 +Rr 1E331E33000000200020 +rR 1E331E33000000200020 +rR 1E331E33000000200020 +rr 1E331E33000000200020 +rr 1E331E33000000200020 +Ʀ 1E3800000020 +S 1E7100000020 +s 1E7100000020 +Ś 1E71000000200024 +ś 1E71000000200024 +Ŝ 1E71000000200027 +ŝ 1E71000000200027 +Š 1E71000000200028 +š 1E71000000200028 +Ş 1E71000000200030 +ş 1E71000000200030 +Ș 1E71000000200045 +ș 1E71000000200045 +ſ 1E71000000200111 +SS 1E711E71000000200020 +Ss 1E711E71000000200020 +sS 1E711E71000000200020 +ss 1E711E71000000200020 +ß 1E711E710000002001100020 +SSZ 1E711E711F210000002000200020 +Ssz 1E711E711F210000002000200020 +sSZ 1E711E711F210000002000200020 +ssz 1E711E711F210000002000200020 +SZ 1E711F21000000200020 +Sz 1E711F21000000200020 +sZ 1E711F21000000200020 +sz 1E711F21000000200020 +Ʃ 1E8200000020 +ƪ 1E8800000020 +T 1E9500000020 +t 1E9500000020 +Ť 1E95000000200028 +ť 1E95000000200028 +Ţ 1E95000000200030 +ţ 1E95000000200030 +Ț 1E95000000200045 +ț 1E95000000200045 +ƾ 1E951E71000000200020 +TTY 1E951E951F0B0000002000200020 +Tty 1E951E951F0B0000002000200020 +tTY 1E951E951F0B0000002000200020 +tty 1E951E951F0B0000002000200020 +TY 1E951F0B000000200020 +Ty 1E951F0B000000200020 +tY 1E951F0B000000200020 +ty 1E951F0B000000200020 +Ŧ 1E9A00000020 +ŧ 1E9A00000020 +ƫ 1EA000000020 +Ƭ 1EA400000020 +ƭ 1EA400000020 +Ʈ 1EA800000020 +U 1EB500000020 +u 1EB500000020 +Ú 1EB5000000200024 +ú 1EB5000000200024 +Ù 1EB5000000200025 +ù 1EB5000000200025 +Ŭ 1EB5000000200026 +ŭ 1EB5000000200026 +Û 1EB5000000200027 +û 1EB5000000200027 +Ǔ 1EB5000000200028 +ǔ 1EB5000000200028 +Ů 1EB5000000200029 +ů 1EB5000000200029 +Ü 1EB500000020002B +ü 1EB500000020002B +Ǘ 1EB500000020002B0024 +ǘ 1EB500000020002B0024 +Ǜ 1EB500000020002B0025 +ǜ 1EB500000020002B0025 +Ǚ 1EB500000020002B0028 +ǚ 1EB500000020002B0028 +Ǖ 1EB500000020002B0032 +ǖ 1EB500000020002B0032 +Ű 1EB500000020002C +ű 1EB500000020002C +Ũ 1EB500000020002D +ũ 1EB500000020002D +Ų 1EB5000000200031 +ų 1EB5000000200031 +Ū 1EB5000000200032 +ū 1EB5000000200032 +Ủ 1EB500000020003B +ủ 1EB500000020003B +Ư 1EB500000020003F +ư 1EB500000020003F +Ứ 1EB500000020003F0024 +ứ 1EB500000020003F0024 +Ừ 1EB500000020003F0025 +ừ 1EB500000020003F0025 +Ữ 1EB500000020003F002D +ữ 1EB500000020003F002D +Ử 1EB500000020003F003B +ử 1EB500000020003F003B +Ự 1EB500000020003F0042 +ự 1EB500000020003F0042 +Ụ 1EB5000000200042 +ụ 1EB5000000200042 +UE 1EB51CAA000000200020 +Ue 1EB51CAA000000200020 +uE 1EB51CAA000000200020 +ue 1EB51CAA000000200020 +Ɯ 1ED400000020 +Ʊ 1EDE00000020 +V 1EE300000020 +v 1EE300000020 +Ʋ 1EEA00000020 +W 1EF500000020 +w 1EF500000020 +Ŵ 1EF5000000200027 +ŵ 1EF5000000200027 +X 1EFF00000020 +x 1EFF00000020 +Y 1F0B00000020 +y 1F0B00000020 +Ý 1F0B000000200024 +ý 1F0B000000200024 +Ŷ 1F0B000000200027 +ŷ 1F0B000000200027 +ÿ 1F0B00000020002B +Ÿ 1F0B00000020002B +Ƴ 1F1700000020 +ƴ 1F1700000020 +Z 1F2100000020 +z 1F2100000020 +Ź 1F21000000200024 +ź 1F21000000200024 +Ž 1F21000000200028 +ž 1F21000000200028 +Ż 1F2100000020002E +ż 1F2100000020002E +ZS 1F211E71000000200020 +Zs 1F211E71000000200020 +zS 1F211E71000000200020 +zs 1F211E71000000200020 +ƍ 1F211EF5000000200020 +ZZS 1F211F211E710000002000200020 +Zzs 1F211F211E710000002000200020 +zZS 1F211F211E710000002000200020 +zzs 1F211F211E710000002000200020 +Ƶ 1F2600000020 +ƶ 1F2600000020 +Ʒ 1F3E00000020 +Ǯ 1F3E000000200028 +ǯ 1F3E000000200028 +Ƹ 1F4300000020 +ƹ 1F4300000020 +ƺ 1F4800000020 +Þ 1F5000000020 +þ 1F5000000020 +ƿ 1F5600000020 +Ƿ 1F5600000020 +ƻ 1F6200000020 +Ƨ 1F6900000020 +ƨ 1F6900000020 +Ƽ 1F6D00000020 +ƽ 1F6D00000020 +Ƅ 1F7100000020 +ƅ 1F7100000020 +ʼn 1F7E1DB9000000200020 +ǀ 1F9900000020 +ǁ 1F9D00000020 +ǂ 1FA100000020 +ǃ 1FA500000020 +ඖ 28E100000020 +ඤ 28EC00000020 +ඥ 28ED00000020 +DROP TABLE t1; diff --git a/mysql-test/r/ctype_unicode900_as_cs.result-pq b/mysql-test/r/ctype_unicode900_as_cs.result-pq new file mode 100644 index 000000000..c04278e20 --- /dev/null +++ b/mysql-test/r/ctype_unicode900_as_cs.result-pq @@ -0,0 +1,2078 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 5.8 tests +# +SET NAMES utf8mb4 COLLATE utf8mb4_0900_as_cs; +SET @test_character_set= 'utf8mb4'; +SET @test_collation= 'utf8mb4_0900_as_cs'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) utf8mb4_0900_as_cs YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) utf8mb4_0900_as_cs YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) COLLATE utf8mb4_0900_as_cs DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_cs +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +SET NAMES utf8mb4 COLLATE utf8mb4_0900_as_cs; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf8mb4_0900_as_cs 61 +utf8mb4_0900_as_cs 6109 +utf8mb4_0900_as_cs 6120 +drop table t1; +create table t1 engine=innodb select repeat('a',50) as c1; +alter table t1 add index(c1(5)); +insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111'); +select collation(c1) from t1 limit 1; +collation(c1) +utf8mb4_0900_as_cs +select c1 from t1 where c1 like 'abcdef%' order by c1; +c1 +abcdefg +select c1 from t1 where c1 like 'abcde1%' order by c1; +c1 +abcde100 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde11%' order by c1; +c1 +abcde110 +abcde111 +select c1 from t1 where c1 like 'abcde111%' order by c1; +c1 +abcde111 +drop table t1; +select @@collation_connection; +@@collation_connection +utf8mb4_0900_as_cs +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +drop table if exists t1; +create table t1 select repeat('a',10) as c1; +delete from t1; +insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F); +insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F); +insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F); +insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F); +insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F); +insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F); +SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1; +GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '') GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) + 7F + 20 +_ 5F +- 2D +, 2C +; 3B +: 3A +! 21 +? 3F +. 2E +' 27 +" 22 +( 28 +) 29 +[ 5B +] 5D +{ 7B +} 7D +@ 40 +* 2A +/ 2F +\ 5C +& 26 +# 23 +% 25 +` 60 +^ 5E ++ 2B +< 3C += 3D +> 3E +| 7C +~ 7E +$ 24 +0 30 +1 31 +2 32 +3 33 +4 34 +5 35 +6 36 +7 37 +8 38 +9 39 +a 61 +A 41 +b 62 +B 42 +c 63 +C 43 +d 64 +D 44 +e 65 +E 45 +f 66 +F 46 +g 67 +G 47 +h 68 +H 48 +i 69 +I 49 +j 6A +J 4A +k 6B +K 4B +l 6C +L 4C +m 6D +M 4D +n 6E +N 4E +o 6F +O 4F +p 70 +P 50 +q 71 +Q 51 +r 72 +R 52 +s 73 +S 53 +t 74 +T 54 +u 75 +U 55 +v 76 +V 56 +w 77 +W 57 +x 78 +X 58 +y 79 +Y 59 +z 7A +Z 5A +drop table t1; +SET NAMES utf8mb4 COLLATE utf8mb4_0900_as_cs; +SELECT HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING ucs2)); +HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING ucs2)) +003F0041 +SELECT HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf16)); +HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf16)) +D806DEDB0041 +SELECT HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf32)); +HEX(CONVERT(_utf8mb4 0xF091AB9B41 USING utf32)) +00011ADB00000041 +SELECT HEX(CONVERT(_ucs2 0xF8FF USING utf8mb4)); +HEX(CONVERT(_ucs2 0xF8FF USING utf8mb4)) +EFA3BF +SELECT HEX(CONVERT(_utf16 0xF8FF USING utf8mb4)); +HEX(CONVERT(_utf16 0xF8FF USING utf8mb4)) +EFA3BF +SELECT HEX(CONVERT(_utf32 0xF8FF USING utf8mb4)); +HEX(CONVERT(_utf32 0xF8FF USING utf8mb4)) +EFA3BF +SELECT HEX(CONVERT(_utf8mb4 0x8F USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: '8F' +SELECT HEX(CONVERT(_utf8mb4 0xC230 USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: 'C230' +SELECT HEX(CONVERT(_utf8mb4 0xE234F1 USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: 'E234F1' +SELECT HEX(CONVERT(_utf8mb4 0xF4E25634 USING ucs2)); +ERROR HY000: Invalid utf8mb4 character string: 'F4E256' +SELECT ASCII('ABC'); +ASCII('ABC') +65 +SELECT BIT_LENGTH('a'); +BIT_LENGTH('a') +8 +SELECT BIT_LENGTH('À'); +BIT_LENGTH('À') +16 +SELECT BIT_LENGTH('テ'); +BIT_LENGTH('テ') +24 +SELECT BIT_LENGTH('𝌆'); +BIT_LENGTH('?') +32 +SELECT CHAR_LENGTH('𝌆テÀa'); +CHAR_LENGTH('?テÀa') +4 +SELECT LENGTH('𝌆テÀa'); +LENGTH('?テÀa') +10 +SELECT FIELD('a', '𝌆テÀa'); +FIELD('a', '?テÀa') +0 +SELECT HEX('𝌆テÀa'); +HEX('?テÀa') +F09D8C86E38386C38061 +SELECT INSERT('𝌆テÀa', 2, 2, 'テb'); +INSERT('?テÀa', 2, 2, 'テb') +𝌆テba +SELECT LOWER('𝌆テÀBcd'); +LOWER('?テÀBcd') +𝌆テàbcd +SELECT ORD('𝌆'); +ORD('?') +4036856966 +SELECT UPPER('𝌆テàbCD'); +UPPER('?テàbCD') +𝌆テÀBCD +SELECT LOCATE(_utf8mb4 0xF091AB9B41, _utf8mb4 0xF091AB9B42F091AB9B41F091AB9B43); +LOCATE(_utf8mb4 0xF091AB9B41, _utf8mb4 0xF091AB9B42F091AB9B41F091AB9B43) +3 +SELECT HEX(REVERSE(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43)); +HEX(REVERSE(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43)) +43F091AB9B42F091AB9B41F091AB9B +SELECT HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, 1, 2)); +HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, 1, 2)) +F091AB9B41 +SELECT HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, -3, 2)); +HEX(SUBSTRING(_utf8mb4 0xF091AB9B41F091AB9B42F091AB9B43, -3, 2)) +42F091AB9B +SELECT HEX(TRIM(_utf8mb4 0x2020F091AB9B4120F091AB9B4120202020)); +HEX(TRIM(_utf8mb4 0x2020F091AB9B4120F091AB9B4120202020)) +F091AB9B4120F091AB9B41 +SELECT HEX(WEIGHT_STRING('aA')); +HEX(WEIGHT_STRING('aA')) +1C471C47000000200020000000020008 +SELECT HEX(WEIGHT_STRING(CAST(_utf32 x'337F' AS CHAR))); +HEX(WEIGHT_STRING(CAST(_utf32 x'337F' AS CHAR))) +FB40E82AFB40DF0FFB40CF1AFB40F93E000000200020002000200000001C001C001C001C +SELECT HEX(WEIGHT_STRING(CAST(_utf32 x'FDFA' AS CHAR))); +HEX(WEIGHT_STRING(CAST(_utf32 x'FDFA' AS CHAR))) +2364239C23C50209230B239C239C23B10000002000200020002000200020002000200000001A001A001A001A001A001A001A001A +select @@collation_connection; +@@collation_connection +utf8mb4_0900_as_cs +select hex(weight_string('a')); +hex(weight_string('a')) +1C470000002000000002 +select hex(weight_string('A')); +hex(weight_string('A')) +1C470000002000000008 +select hex(weight_string('abc')); +hex(weight_string('abc')) +1C471C601C7A00000020002000200000000200020002 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +1C471C60000000200020000000020002 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +1C471C601C7A00000020002000200000000200020002 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +1C471C601C7A00000020002000200000000200020002 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +1C +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +1C471C6000 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +1C471C60000000200020000000020002000000000000000000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +1C +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +1C471C601C +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +1C471C601C7A00000020002000200000000200020002000000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +1C +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +1C47 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +1C471C +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +1C471C60 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +1C471C601C +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +1C471C601C7A00000020002000200000000200020002000000 +select @@collation_connection; +@@collation_connection +utf8mb4_0900_as_cs +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +1C2A0000002000000002 +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +1C2A1C2A1C2A00000020002000200000000200020002 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +1C2A1C2A000000200020000000020002 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +1C2A1C2A1C2A00000020002000200000000200020002 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +1C2A1C2A1C2A00000020002000200000000200020002 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +1C2A1C2A00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +1C2A1C2A000000200020000000020002000000000000000000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +1C2A1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +1C2A1C2A1C2A00000020002000200000000200020002000000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +1C +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +1C2A1C2A +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +1C2A1C2A1C +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +1C2A1C2A1C2A00000020002000200000000200020002000000 +CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A); +INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C); +INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E); +INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242); +INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244); +INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246); +INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248); +INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A); +INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C); +INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E); +INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B); +INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289); +INSERT INTO t1 VALUES (_utf32 0x028C); +INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C); +INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD); +INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF); +INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF); +INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7); +INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB); +INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD); +INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF); +INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511); +INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513); +INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1); +INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3); +INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5); +INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7); +INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01); +INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03); +INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05); +INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07); +INSERT INTO t1 VALUES (_utf32 0x1D7D); +INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E); +INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184); +INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81); +INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83); +INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85); +INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87); +INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89); +INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B); +INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D); +INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F); +INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61); +INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63); +INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65); +INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67); +INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69); +INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B); +INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75); +INSERT INTO t1 VALUES (_utf32 0x2C76); +INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01); +INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03); +INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05); +INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07); +INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31); +INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33); +INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35); +INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37); +INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401); +INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403); +INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405); +INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407); +INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429); +INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B); +INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D); +INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F); +INSERT INTO t1 VALUES (_utf32 0x0370); +INSERT INTO t1 VALUES (_utf32 0x0371); +INSERT INTO t1 VALUES (_utf32 0x0372); +INSERT INTO t1 VALUES (_utf32 0x0373); +INSERT INTO t1 VALUES (_utf32 0x0514); +INSERT INTO t1 VALUES (_utf32 0x0515); +INSERT INTO t1 VALUES (_utf32 0x0516); +INSERT INTO t1 VALUES (_utf32 0x0517); +INSERT INTO t1 VALUES (_utf32 0xA640); +INSERT INTO t1 VALUES (_utf32 0xA641); +INSERT INTO t1 VALUES (_utf32 0xA642); +INSERT INTO t1 VALUES (_utf32 0xA643); +INSERT INTO t1 VALUES (_utf32 0xA722); +INSERT INTO t1 VALUES (_utf32 0xA723); +INSERT INTO t1 VALUES (_utf32 0xA724); +INSERT INTO t1 VALUES (_utf32 0xA725); +INSERT INTO t1 VALUES (_utf32 0xA726); +INSERT INTO t1 VALUES (_utf32 0xA727); +INSERT INTO t1 VALUES (_utf32 0xA728); +INSERT INTO t1 VALUES (_utf32 0xA729); +INSERT INTO t1 VALUES (_utf32 0xA72A); +INSERT INTO t1 VALUES (_utf32 0xA72B); +INSERT INTO t1 VALUES (_utf32 0x2CEB); +INSERT INTO t1 VALUES (_utf32 0x2CEC); +INSERT INTO t1 VALUES (_utf32 0x2CED); +INSERT INTO t1 VALUES (_utf32 0x2CEE); +INSERT INTO t1 VALUES (_utf32 0x1FA01); +INSERT INTO t1 VALUES (_utf32 0x1FB01); +INSERT INTO t1 VALUES (_utf32 0x1FC01); +INSERT INTO t1 VALUES (_utf32 0x1FD01); +INSERT INTO t1 VALUES (_utf32 0x1F603); +INSERT INTO t1 VALUES (_utf32 0x1F604); +INSERT INTO t1 VALUES (_utf32 0x1F648); +INSERT INTO t1 VALUES (_utf32 0x1F64F); +INSERT INTO t1 VALUES (_utf32 0x2B759); +INSERT INTO t1 VALUES (_utf32 0x2B760); +INSERT INTO t1 VALUES (_utf32 0x2B761); +INSERT INTO t1 VALUES (_utf32 0x2B762); +INSERT INTO t1 VALUES (_utf32 0x16F00); +INSERT INTO t1 VALUES (_utf32 0x16F01); +INSERT INTO t1 VALUES (_utf32 0x08A2); +INSERT INTO t1 VALUES (_utf32 0x08A3); +INSERT INTO t1 VALUES (_utf32 0xA794); +INSERT INTO t1 VALUES (_utf32 0xA795); +INSERT INTO t1 VALUES (_utf32 0xA796); +INSERT INTO t1 VALUES (_utf32 0xA797); +INSERT INTO t1 VALUES (_utf32 0xAB37); +INSERT INTO t1 VALUES (_utf32 0xAB38); +INSERT INTO t1 VALUES (_utf32 0x10600); +INSERT INTO t1 VALUES (_utf32 0x10601); +INSERT INTO t1 VALUES (_utf32 0x10602); +INSERT INTO t1 VALUES (_utf32 0x10603); +INSERT INTO t1 VALUES (_utf32 0x1F800); +INSERT INTO t1 VALUES (_utf32 0x1F801); +INSERT INTO t1 VALUES (_utf32 0x1F802); +INSERT INTO t1 VALUES (_utf32 0x1F803); +INSERT INTO t1 VALUES (_utf32 0x10C92); +INSERT INTO t1 VALUES (_utf32 0x10C93); +INSERT INTO t1 VALUES (_utf32 0x10C94); +INSERT INTO t1 VALUES (_utf32 0x10C95); +INSERT INTO t1 VALUES (_utf32 0x2B836); +INSERT INTO t1 VALUES (_utf32 0x2B837); +INSERT INTO t1 VALUES (_utf32 0x2B838); +INSERT INTO t1 VALUES (_utf32 0x2B839); +SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c +FROM t1 ORDER BY c, BINARY c; +hex(c) hex(lower(c)) hex(upper(c)) hex(weight_string(c)) c +F09F9883 F09F9883 F09F9883 15FE0000002000000002 😃 +F09F9884 F09F9884 F09F9884 15FF0000002000000002 😄 +F09F9988 F09F9988 F09F9988 16430000002000000002 🙈 +F09F998F F09F998F F09F998F 164A0000002000000002 🙏 +F09FA080 F09FA080 F09FA080 17AB0000002000000002 🠀 +F09FA081 F09FA081 F09FA081 17AC0000002000000002 🠁 +F09FA082 F09FA082 F09FA082 17AD0000002000000002 🠂 +F09FA083 F09FA083 F09FA083 17AE0000002000000002 🠃 +E2B1A5 E2B1A5 C8BA 1C4C0000002000000002 ⱥ +C8BA C8BA 1C4C0000002000000008 Ⱥ +C680 C680 C983 1C680000002000000002 ƀ +C983 C680 C983 1C680000002000000008 Ƀ +EA9E97 EA9E97 EA9E96 1C6F0000002000000002 ꞗ +EA9E96 EA9E97 EA9E96 1C6F0000002000000008 Ꞗ +C8BC C8BC C8BB 1C7F0000002000000002 ȼ +C8BB C8BC C8BB 1C7F0000002000000008 Ȼ +EA9E94 EA9E94 EA9E94 1C840000002000000002 ꞔ +E28684 E28684 E28683 1C8D0000002000000002 ↄ +E28683 E28684 E28683 1C8D0000002000000008 Ↄ +C987 C987 C986 1CB10000002000000002 ɇ +C986 C987 C986 1CB10000002000000008 Ɇ +E2858E E2858E E284B2 1CF20000002000000002 ⅎ +E284B2 E2858E E284B2 1CF20000002000000008 Ⅎ +EA9E95 EA9E95 EA9E95 1D240000002000000002 ꞕ +E2B1A8 E2B1A8 E2B1A7 1D290000002000000002 ⱨ +E2B1A7 E2B1A8 E2B1A7 1D290000002000000008 Ⱨ +E2B1B6 E2B1B6 E2B1B5 1D2A0000002000000002 ⱶ +E2B1B5 E2B1B6 E2B1B5 1D2A0000002000000008 Ⱶ +EA9CA7 EA9CA7 EA9CA6 1D2B0000002000000002 ꜧ +EA9CA6 EA9CA7 EA9CA6 1D2B0000002000000008 Ꜧ +C989 C989 C988 1D550000002000000002 ɉ +C988 C989 C988 1D550000002000000008 Ɉ +E2B1AA E2B1AA E2B1A9 1D6F0000002000000002 ⱪ +E2B1A9 E2B1AA E2B1A9 1D6F0000002000000008 Ⱪ +C8BD C69A C8BD 1D820000002000000008 Ƚ +E2B1A1 E2B1A1 E2B1A0 1D860000002000000002 ⱡ +E2B1A0 E2B1A1 E2B1A0 1D860000002000000008 Ⱡ +C9AB C9AB 1D870000002000000002 ɫ +E2B1A2 C9AB E2B1A2 1D870000002000000008 Ɫ +EAACB8 EAACB8 EAACB8 1D8B0000002000000002 ꬸ +EAACB7 EAACB7 EAACB7 1D910000002000000002 ꬷ +E1B5BD E1B5BD E2B1A3 1E110000002000000002 ᵽ +E2B1A3 E1B5BD E2B1A3 1E110000002000000008 Ᵽ +C98B C98B C98A 1E2B0000002000000002 ɋ +C98A C98B C98A 1E2B0000002000000008 Ɋ +C98D C98D C98C 1E3F0000002000000002 ɍ +C98C C98D C98C 1E3F0000002000000008 Ɍ +C9BD C9BD 1E570000002000000002 ɽ +E2B1A4 C9BD E2B1A4 1E570000002000000008 Ɽ +EA9CA9 EA9CA9 EA9CA8 1E951F21000000200020000000040004 ꜩ +EA9CA8 EA9CA9 EA9CA8 1E951F210000002000200000000A0004 Ꜩ +E2B1A6 E2B1A6 C8BE 1E9E0000002000000002 ⱦ +C8BE C8BE 1E9E0000002000000008 Ⱦ +CA89 CA89 C984 1EC00000002000000002 ʉ +C984 CA89 C984 1EC00000002000000008 Ʉ +CA8C CA8C C985 1EF10000002000000002 ʌ +C985 CA8C C985 1EF10000002000000008 Ʌ +C98F C98F C98E 1F130000002000000002 ɏ +C98E C98F C98E 1F130000002000000008 Ɏ +E2B1AC E2B1AC E2B1AB 1F3C0000002000000002 ⱬ +E2B1AB E2B1AC E2B1AB 1F3C0000002000000008 Ⱬ +EA9CAB EA9CAB EA9CAA 1F660000002000000002 ꜫ +EA9CAA EA9CAB EA9CAA 1F660000002000000008 Ꜫ +C982 C982 C981 1F790000002000000002 ɂ +C981 C982 C981 1F790000002000000008 Ɂ +EA9CA3 EA9CA3 EA9CA2 1F810000002000000002 ꜣ +EA9CA2 EA9CA3 EA9CA2 1F810000002000000008 Ꜣ +EA9CA5 EA9CA5 EA9CA4 1F8C0000002000000002 ꜥ +EA9CA4 EA9CA5 EA9CA4 1F8C0000002000000008 Ꜥ +CDB1 CDB1 CDB0 1FC30000002000000002 ͱ +CDB0 CDB1 CDB0 1FC30000002000000008 Ͱ +CDBC CDBC CFBE 1FD80000002000000002 ͼ +CFBE CDBC CFBE 1FD80000002000000008 Ͼ +CDBB CDBB CFBD 1FD90000002000000002 ͻ +CFBD CDBB CFBD 1FD90000002000000008 Ͻ +CDBD CDBD CFBF 1FDA0000002000000002 ͽ +CFBF CDBD CFBF 1FDA0000002000000008 Ͽ +CDB3 CDB3 CDB2 1FE40000002000000002 ͳ +CDB2 CDB3 CDB2 1FE40000002000000008 Ͳ +E2B281 E2B281 E2B280 1FE60000002000000002 ⲁ +E2B280 E2B281 E2B280 1FE60000002000000008 Ⲁ +E2B283 E2B283 E2B282 1FE70000002000000002 ⲃ +E2B282 E2B283 E2B282 1FE70000002000000008 Ⲃ +E2B285 E2B285 E2B284 1FE80000002000000002 ⲅ +E2B284 E2B285 E2B284 1FE80000002000000008 Ⲅ +E2B287 E2B287 E2B286 1FE90000002000000002 ⲇ +E2B286 E2B287 E2B286 1FE90000002000000008 Ⲇ +E2B289 E2B289 E2B288 1FEA0000002000000002 ⲉ +E2B288 E2B289 E2B288 1FEA0000002000000008 Ⲉ +E2B28B E2B28B E2B28A 1FEC0000002000000002 ⲋ +E2B28A E2B28B E2B28A 1FEC0000002000000008 Ⲋ +E2B28D E2B28D E2B28C 1FED0000002000000002 ⲍ +E2B28C E2B28D E2B28C 1FED0000002000000008 Ⲍ +E2B28F E2B28F E2B28E 1FEE0000002000000002 ⲏ +E2B28E E2B28F E2B28E 1FEE0000002000000008 Ⲏ +E2B3AC E2B3AC E2B3AB 20060000002000000002 ⳬ +E2B3AB E2B3AC E2B3AB 20060000002000000008 Ⳬ +E2B3AE E2B3AE E2B3AD 20160000002000000002 ⳮ +E2B3AD E2B3AE E2B3AD 20160000002000000008 Ⳮ +D3BB D3BB D3BA 203E0000002000000002 ӻ +D3BA D3BB D3BA 203E0000002000000008 Ӻ +D3B7 D3B7 D3B6 20460000002000000002 ӷ +D3B6 D3B7 D3B6 20460000002000000008 Ӷ +EA9981 EA9981 EA9980 20700000002000000002 ꙁ +EA9980 EA9981 EA9980 20700000002000000008 Ꙁ +D491 D491 D490 20720000002000000002 ԑ +D490 D491 D490 20720000002000000008 Ԑ +EA9983 EA9983 EA9982 20730000002000000002 ꙃ +EA9982 EA9983 EA9982 20730000002000000008 Ꙃ +D493 D493 D492 20BA0000002000000002 ԓ +D492 D493 D492 20BA0000002000000008 Ԓ +D495 D495 D494 20C20000002000000002 ԕ +D494 D495 D494 20C20000002000000008 Ԕ +D497 D497 D496 21040000002000000002 ԗ +D496 D497 D496 21040000002000000008 Ԗ +D3BD D3BD D3BC 21360000002000000002 ӽ +D3BC D3BD D3BC 21360000002000000008 Ӽ +D3BF D3BF D3BE 213A0000002000000002 ӿ +D3BE D3BF D3BE 213A0000002000000008 Ӿ +D38F D38F D380 21E10000002000000002 ӏ +D380 D38F D380 21E10000002000000008 Ӏ +E2B0B0 E2B0B0 E2B080 21E50000002000000002 ⰰ +E2B080 E2B0B0 E2B080 21E50000002000000008 Ⰰ +E2B0B1 E2B0B1 E2B081 21E60000002000000002 ⰱ +E2B081 E2B0B1 E2B081 21E60000002000000008 Ⰱ +E2B0B2 E2B0B2 E2B082 21E70000002000000002 ⰲ +E2B082 E2B0B2 E2B082 21E70000002000000008 Ⰲ +E2B0B3 E2B0B3 E2B083 21E80000002000000002 ⰳ +E2B083 E2B0B3 E2B083 21E80000002000000008 Ⰳ +E2B0B4 E2B0B4 E2B084 21E90000002000000002 ⰴ +E2B084 E2B0B4 E2B084 21E90000002000000008 Ⰴ +E2B0B5 E2B0B5 E2B085 21EA0000002000000002 ⰵ +E2B085 E2B0B5 E2B085 21EA0000002000000008 Ⰵ +E2B0B6 E2B0B6 E2B086 21EB0000002000000002 ⰶ +E2B086 E2B0B6 E2B086 21EB0000002000000008 Ⰶ +E2B0B7 E2B0B7 E2B087 21EC0000002000000002 ⰷ +E2B087 E2B0B7 E2B087 21EC0000002000000008 Ⰷ +E2B480 E2B480 E182A0 223B0000002000000002 ⴀ +E182A0 E2B480 E182A0 223B0000002000000008 Ⴀ +E2B481 E2B481 E182A1 223D0000002000000002 ⴁ +E182A1 E2B481 E182A1 223D0000002000000008 Ⴁ +E2B482 E2B482 E182A2 223F0000002000000002 ⴂ +E182A2 E2B482 E182A2 223F0000002000000008 Ⴂ +E2B483 E2B483 E182A3 22410000002000000002 ⴃ +E182A3 E2B483 E182A3 22410000002000000008 Ⴃ +E2B484 E2B484 E182A4 22430000002000000002 ⴄ +E182A4 E2B484 E182A4 22430000002000000008 Ⴄ +E2B485 E2B485 E182A5 22450000002000000002 ⴅ +E182A5 E2B485 E182A5 22450000002000000008 Ⴅ +E2B486 E2B486 E182A6 22470000002000000002 ⴆ +E182A6 E2B486 E182A6 22470000002000000008 Ⴆ +E2B487 E2B487 E182A7 224B0000002000000002 ⴇ +E182A7 E2B487 E182A7 224B0000002000000008 Ⴇ +E0A2A2 E0A2A2 E0A2A2 232B0000002000000002 ࢢ +E0A2A3 E0A2A3 E0A2A3 236D0000002000000002 ࢣ +F090B292 F090B392 F090B292 37120000002000000008 𐲒 +F090B293 F090B393 F090B293 37130000002000000008 𐲓 +F090B294 F090B394 F090B294 37140000002000000008 𐲔 +F090B295 F090B395 F090B295 37150000002000000008 𐲕 +F096BC80 F096BC80 F096BC80 427A0000002000000002 𖼀 +F096BC81 F096BC81 F096BC81 427B0000002000000002 𖼁 +F09090A8 F09090A8 F0909080 44520000002000000002 𐐨 +F0909080 F09090A8 F0909080 44520000002000000008 𐐀 +F09090A9 F09090A9 F0909081 44530000002000000002 𐐩 +F0909081 F09090A9 F0909081 44530000002000000008 𐐁 +F09090AA F09090AA F0909082 44540000002000000002 𐐪 +F0909082 F09090AA F0909082 44540000002000000008 𐐂 +F09090AB F09090AB F0909083 44550000002000000002 𐐫 +F0909083 F09090AB F0909083 44550000002000000008 𐐃 +F09090AC F09090AC F0909084 44560000002000000002 𐐬 +F0909084 F09090AC F0909084 44560000002000000008 𐐄 +F09090AD F09090AD F0909085 44570000002000000002 𐐭 +F0909085 F09090AD F0909085 44570000002000000008 𐐅 +F09090AE F09090AE F0909086 44580000002000000002 𐐮 +F0909086 F09090AE F0909086 44580000002000000008 𐐆 +F09090AF F09090AF F0909087 44590000002000000002 𐐯 +F0909087 F09090AF F0909087 44590000002000000008 𐐇 +F0909880 F0909880 F0909880 46BA0000002000000002 𐘀 +F0909881 F0909881 F0909881 46BB0000002000000002 𐘁 +F0909882 F0909882 F0909882 46BC0000002000000002 𐘂 +F0909883 F0909883 F0909883 46BD0000002000000002 𐘃 +F0AB9D99 F0AB9D99 F0AB9D99 FB85B7590000002000000002 𫝙 +F0AB9DA0 F0AB9DA0 F0AB9DA0 FB85B7600000002000000002 𫝠 +F0AB9DA1 F0AB9DA1 F0AB9DA1 FB85B7610000002000000002 𫝡 +F0AB9DA2 F0AB9DA2 F0AB9DA2 FB85B7620000002000000002 𫝢 +F0ABA0B6 F0ABA0B6 F0ABA0B6 FB85B8360000002000000002 𫠶 +F0ABA0B7 F0ABA0B7 F0ABA0B7 FB85B8370000002000000002 𫠷 +F0ABA0B8 F0ABA0B8 F0ABA0B8 FB85B8380000002000000002 𫠸 +F0ABA0B9 F0ABA0B9 F0ABA0B9 FB85B8390000002000000002 𫠹 +F09FA881 F09FA881 F09FA881 FBC3FA010000002000000002 🨁 +F09FAC81 F09FAC81 F09FAC81 FBC3FB010000002000000002 🬁 +F09FB081 F09FB081 F09FB081 FBC3FC010000002000000002 🰁 +F09FB481 F09FB481 F09FB481 FBC3FD010000002000000002 🴁 +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400)); +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 1C470000002000000002 +61F0909080 1C474452000000200020000000020008 +61EFBFBF 1C47FBC1FFFF000000200020000000020002 +61F48FBFBF 1C47FBE1FFFF000000200020000000020002 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 44520000002000000008 𐐀 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F09090A8 44520000002000000002 𐐨 +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`c`) AS `hex(c)` from `test`.`t1` where (`test`.`t1`.`c` like 'a%') order by `test`.`t1`.`c` +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +61 1C470000002000000002 +61F0909080 1C474452000000200020000000020008 +61EFBFBF 1C47FBC1FFFF000000200020000000020002 +61F48FBFBF 1C47FBE1FFFF000000200020000000020002 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F0909080 44520000002000000008 𐐀 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +F09090A8 44520000002000000002 𐐨 +DROP TABLE t1; +SELECT 'a' = 'a '; +'a' = 'a ' +0 +SELECT 'a\0' < 'a'; +'a\0' < 'a' +0 +SELECT 'a\0' < 'a '; +'a\0' < 'a ' +1 +SELECT 'a\t' < 'a'; +'a\t' < 'a' +0 +SELECT 'a\t' < 'a '; +'a\t' < 'a ' +1 +SELECT 'a' LIKE 'a'; +'a' LIKE 'a' +1 +SELECT 'A' LIKE 'a'; +'A' LIKE 'a' +0 +SELECT _utf8mb4 0xD0B0D0B1D0B2 LIKE CONCAT(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%'); +_utf8mb4 0xD0B0D0B1D0B2 LIKE CONCAT(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%') +1 +SELECT is_ipv4(inet_ntoa('1')); +is_ipv4(inet_ntoa('1')) +1 +SELECT is_ipv6(inet_ntoa('1')); +is_ipv6(inet_ntoa('1')) +0 +SELECT inet6_aton(inet_ntoa('1')); +inet6_aton(inet_ntoa('1')) + +SELECT inet6_ntoa(inet_ntoa('1')); +inet6_ntoa(inet_ntoa('1')) +NULL +# +# Bug#14040277 UNINITIALIZED VALUE REFERENCED IN STR_TO_IPV6 +# +SELECT inet6_aton(soundex('a')); +inet6_aton(soundex('a')) +NULL +# +# Bug#19047425 UNINITIALISED VALUE IN STR_TO_IPV6 +# +do is_ipv4_mapped(inet6_aton(convert(_ascii "a:" using utf8mb4))); +CREATE TABLE t1 (c VARCHAR(10) CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES (_utf8mb4 0xF09090A7), (_utf8mb4 0xEA8B93), (_utf8mb4 0xC4BC), (_utf8mb4 0xC6AD), (_utf8mb4 0xF090918F), (_utf8mb4 0xEAAD8B); +SELECT HEX(ANY_VALUE(c)), COUNT(c) FROM t1 GROUP BY c COLLATE utf8mb4_0900_as_cs; +HEX(ANY_VALUE(c)) COUNT(c) +C4BC 1 +C6AD 1 +EA8B93 1 +EAAD8B 1 +F09090A7 1 +F090918F 1 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(10)) COLLATE utf8mb4_0900_as_cs; +INSERT INTO t1 VALUES(_utf16 0xAC00, _utf16 0x326E), (_utf16 0xAD, _utf16 0xA0), +(_utf16 0xC6, _utf16 0x41), (_utf16 0xC6, _utf16 0xAA), (_utf16 0xA73A, _utf16 0xA738); +SELECT a = b FROM t1; +a = b +0 +0 +0 +0 +0 +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 (c1 CHAR(10) COLLATE utf8mb4_0900_as_cs); +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); +INSERT INTO t1 VALUES (_ucs2 0x1EA0),(_ucs2 0x1EA1),(_ucs2 0x1EA2),(_ucs2 0x1EA3); +INSERT INTO t1 VALUES (_ucs2 0x1EA4),(_ucs2 0x1EA5),(_ucs2 0x1EA6),(_ucs2 0x1EA7); +INSERT INTO t1 VALUES (_ucs2 0x1EA8),(_ucs2 0x1EA9),(_ucs2 0x1EAA),(_ucs2 0x1EAB); +INSERT INTO t1 VALUES (_ucs2 0x1EAC),(_ucs2 0x1EAD),(_ucs2 0x1EAE),(_ucs2 0x1EAF); +INSERT INTO t1 VALUES (_ucs2 0x1EB0),(_ucs2 0x1EB1),(_ucs2 0x1EB2),(_ucs2 0x1EB3); +INSERT INTO t1 VALUES (_ucs2 0x1EB4),(_ucs2 0x1EB5),(_ucs2 0x1EB6),(_ucs2 0x1EB7); +INSERT INTO t1 VALUES (_ucs2 0x1EB8),(_ucs2 0x1EB9),(_ucs2 0x1EBA),(_ucs2 0x1EBB); +INSERT INTO t1 VALUES (_ucs2 0x1EBC),(_ucs2 0x1EBD),(_ucs2 0x1EBE),(_ucs2 0x1EBF); +INSERT INTO t1 VALUES (_ucs2 0x1EC0),(_ucs2 0x1EC1),(_ucs2 0x1EC2),(_ucs2 0x1EC3); +INSERT INTO t1 VALUES (_ucs2 0x1EC4),(_ucs2 0x1EC5),(_ucs2 0x1EC6),(_ucs2 0x1EC7); +INSERT INTO t1 VALUES (_ucs2 0x1EC8),(_ucs2 0x1EC9),(_ucs2 0x1ECA),(_ucs2 0x1ECB); +INSERT INTO t1 VALUES (_ucs2 0x1ECC),(_ucs2 0x1ECD),(_ucs2 0x1ECE),(_ucs2 0x1ECF); +INSERT INTO t1 VALUES (_ucs2 0x1ED0),(_ucs2 0x1ED1),(_ucs2 0x1ED2),(_ucs2 0x1ED3); +INSERT INTO t1 VALUES (_ucs2 0x1ED4),(_ucs2 0x1ED5),(_ucs2 0x1ED6),(_ucs2 0x1ED7); +INSERT INTO t1 VALUES (_ucs2 0x1ED8),(_ucs2 0x1ED9),(_ucs2 0x1EDA),(_ucs2 0x1EDB); +INSERT INTO t1 VALUES (_ucs2 0x1EDC),(_ucs2 0x1EDD),(_ucs2 0x1EDE),(_ucs2 0x1EDF); +INSERT INTO t1 VALUES (_ucs2 0x1EE0),(_ucs2 0x1EE1),(_ucs2 0x1EE2),(_ucs2 0x1EE3); +INSERT INTO t1 VALUES (_ucs2 0x1EE4),(_ucs2 0x1EE5),(_ucs2 0x1EE6),(_ucs2 0x1EE7); +INSERT INTO t1 VALUES (_ucs2 0x1EE8),(_ucs2 0x1EE9),(_ucs2 0x1EEA),(_ucs2 0x1EEB); +INSERT INTO t1 VALUES (_ucs2 0x1EEC),(_ucs2 0x1EED),(_ucs2 0x1EEE),(_ucs2 0x1EEF); +INSERT INTO t1 VALUES (_ucs2 0x1EF0),(_ucs2 0x1EF1); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('AE'),('Ae'),('ae'),('aE'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +insert into t1 values (_ucs2 0x0218), (_ucs2 0x0219), (_ucs2 0x021a), (_ucs2 0x021b); +insert into t1 values (_ucs2 0x0d96), (_ucs2 0x0da4), (_ucs2 0x0da5); +insert into t1 values (_ucs2 0x0064017e), (_ucs2 0x0044017e), (_ucs2 0x0044017d); +insert into t1 values ('CS'),('Cs'),('cs'),('cS'); +insert into t1 values ('DZS'),('DZs'),('Dzs'),('DzS'); +insert into t1 values ('dZS'),('dZs'),('dzs'),('dzS'); +insert into t1 values ('GY'),('Gy'),('gy'),('gY'); +insert into t1 values ('LY'),('Ly'),('ly'),('lY'); +insert into t1 values ('NY'),('Ny'),('ny'),('nY'); +insert into t1 values ('SZ'),('Sz'),('sz'),('sZ'); +insert into t1 values ('TY'),('Ty'),('ty'),('tY'); +insert into t1 values ('ZS'),('Zs'),('zs'),('zS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +insert into t1 values ('ccs'),('Ccs'),('CCS'),('cCS'); +insert into t1 values ('ddz'),('Ddz'),('DDZ'),('dDZ'); +insert into t1 values ('ddzs'),('Ddzs'),('DDZS'),('dDZS'); +insert into t1 values ('ggy'),('Ggy'),('GGY'),('gGY'); +insert into t1 values ('lly'),('Lly'),('LLY'),('lLY'); +insert into t1 values ('nny'),('Nny'),('NNY'),('nNY'); +insert into t1 values ('ssz'),('Ssz'),('SSZ'),('sSZ'); +insert into t1 values ('tty'),('Tty'),('TTY'),('tTY'); +insert into t1 values ('zzs'),('Zzs'),('ZZS'),('zZS'); +insert into t1 values ('UE'),('Ue'),('ue'),('uE'); +SELECT c1, hex(weight_string(c1)) FROM t1 ORDER BY c1 COLLATE utf8mb4_0900_as_cs; +c1 hex(weight_string(c1)) +÷ 06180000002000000002 +× 06190000002000000002 +a 1C470000002000000002 +A 1C470000002000000008 +á 1C47000000200024000000020002 +Á 1C47000000200024000000080002 +à 1C47000000200025000000020002 +À 1C47000000200025000000080002 +ă 1C47000000200026000000020002 +Ă 1C47000000200026000000080002 +ắ 1C4700000020002600240000000200020002 +Ắ 1C4700000020002600240000000800020002 +ằ 1C4700000020002600250000000200020002 +Ằ 1C4700000020002600250000000800020002 +ẵ 1C47000000200026002D0000000200020002 +Ẵ 1C47000000200026002D0000000800020002 +ẳ 1C47000000200026003B0000000200020002 +Ẳ 1C47000000200026003B0000000800020002 +â 1C47000000200027000000020002 + 1C47000000200027000000080002 +ấ 1C4700000020002700240000000200020002 +Ấ 1C4700000020002700240000000800020002 +ầ 1C4700000020002700250000000200020002 +Ầ 1C4700000020002700250000000800020002 +ẫ 1C47000000200027002D0000000200020002 +Ẫ 1C47000000200027002D0000000800020002 +ẩ 1C47000000200027003B0000000200020002 +Ẩ 1C47000000200027003B0000000800020002 +ǎ 1C47000000200028000000020002 +Ǎ 1C47000000200028000000080002 +å 1C47000000200029000000020002 +Å 1C47000000200029000000080002 +ǻ 1C4700000020002900240000000200020002 +Ǻ 1C4700000020002900240000000800020002 +ä 1C4700000020002B000000020002 +Ä 1C4700000020002B000000080002 +ǟ 1C4700000020002B00320000000200020002 +Ǟ 1C4700000020002B00320000000800020002 +ã 1C4700000020002D000000020002 +à 1C4700000020002D000000080002 +ǡ 1C4700000020002E00320000000200020002 +Ǡ 1C4700000020002E00320000000800020002 +ą 1C47000000200031000000020002 +Ą 1C47000000200031000000080002 +ā 1C47000000200032000000020002 +Ā 1C47000000200032000000080002 +ả 1C4700000020003B000000020002 +Ả 1C4700000020003B000000080002 +ạ 1C47000000200042000000020002 +Ạ 1C47000000200042000000080002 +ặ 1C4700000020004200260000000200020002 +Ặ 1C4700000020004200260000000800020002 +ậ 1C4700000020004200270000000200020002 +Ậ 1C4700000020004200270000000800020002 +aa 1C471C47000000200020000000020002 +aA 1C471C47000000200020000000020008 +Aa 1C471C47000000200020000000080002 +AA 1C471C47000000200020000000080008 +ae 1C471CAA000000200020000000020002 +aE 1C471CAA000000200020000000020008 +Ae 1C471CAA000000200020000000080002 +AE 1C471CAA000000200020000000080008 +æ 1C471CAA00000020011000200000000400040004 +Æ 1C471CAA00000020011000200000000A0004000A +ǽ 1C471CAA0000002001100020002400000004000400040002 +Ǽ 1C471CAA000000200110002000240000000A0004000A0002 +ǣ 1C471CAA0000002001100020003200000004000400040002 +Ǣ 1C471CAA000000200110002000320000000A0004000A0002 +b 1C600000002000000002 +B 1C600000002000000008 +ƀ 1C680000002000000002 +Ɓ 1C710000002000000008 +ƃ 1C750000002000000002 +Ƃ 1C750000002000000008 +c 1C7A0000002000000002 +C 1C7A0000002000000008 +ć 1C7A000000200024000000020002 +Ć 1C7A000000200024000000080002 +ĉ 1C7A000000200027000000020002 +Ĉ 1C7A000000200027000000080002 +č 1C7A000000200028000000020002 +Č 1C7A000000200028000000080002 +ċ 1C7A00000020002E000000020002 +Ċ 1C7A00000020002E000000080002 +ç 1C7A000000200030000000020002 +Ç 1C7A000000200030000000080002 +ccs 1C7A1C7A1E7100000020002000200000000200020002 +cCS 1C7A1C7A1E7100000020002000200000000200080008 +Ccs 1C7A1C7A1E7100000020002000200000000800020002 +CCS 1C7A1C7A1E7100000020002000200000000800080008 +ch 1C7A1D18000000200020000000020002 +cH 1C7A1D18000000200020000000020008 +Ch 1C7A1D18000000200020000000080002 +CH 1C7A1D18000000200020000000080008 +cs 1C7A1E71000000200020000000020002 +cS 1C7A1E71000000200020000000020008 +Cs 1C7A1E71000000200020000000080002 +CS 1C7A1E71000000200020000000080008 +ƈ 1C850000002000000002 +Ƈ 1C850000002000000008 +d 1C8F0000002000000002 +D 1C8F0000002000000008 +ď 1C8F000000200028000000020002 +Ď 1C8F000000200028000000080002 +đ 1C8F000000200039000000020002 +Đ 1C8F000000200039000000080002 +ð 1C8F000000200110000000040004 +Ð 1C8F0000002001100000000A0004 +ddz 1C8F1C8F1F2100000020002000200000000200020002 +dDZ 1C8F1C8F1F2100000020002000200000000200080008 +Ddz 1C8F1C8F1F2100000020002000200000000800020002 +DDZ 1C8F1C8F1F2100000020002000200000000800080008 +ddzs 1C8F1C8F1F211E710000002000200020002000000002000200020002 +dDZS 1C8F1C8F1F211E710000002000200020002000000002000800080008 +Ddzs 1C8F1C8F1F211E710000002000200020002000000008000200020002 +DDZS 1C8F1C8F1F211E710000002000200020002000000008000800080008 +dz 1C8F1F21000000200020000000020002 +dZ 1C8F1F21000000200020000000020008 +dz 1C8F1F21000000200020000000040004 +Dz 1C8F1F21000000200020000000080002 +DZ 1C8F1F21000000200020000000080008 +Dz 1C8F1F210000002000200000000A0004 +DZ 1C8F1F210000002000200000000A000A +dž 1C8F1F2100000020002000280000000200020002 +dž 1C8F1F2100000020002000280000000200020002 +dŽ 1C8F1F2100000020002000280000000200080002 +dž 1C8F1F2100000020002000280000000400040004 +Dž 1C8F1F2100000020002000280000000800020002 +Dž 1C8F1F2100000020002000280000000800020002 +DŽ 1C8F1F2100000020002000280000000800080002 +DŽ 1C8F1F2100000020002000280000000800080002 +Dž 1C8F1F2100000020002000280000000A00040004 +DŽ 1C8F1F2100000020002000280000000A000A0004 +dzs 1C8F1F211E7100000020002000200000000200020002 +dzS 1C8F1F211E7100000020002000200000000200020008 +dZs 1C8F1F211E7100000020002000200000000200080002 +dZS 1C8F1F211E7100000020002000200000000200080008 +Dzs 1C8F1F211E7100000020002000200000000800020002 +DzS 1C8F1F211E7100000020002000200000000800020008 +DZs 1C8F1F211E7100000020002000200000000800080002 +DZS 1C8F1F211E7100000020002000200000000800080008 +Ɖ 1C970000002000000008 +Ɗ 1C9B0000002000000008 +ƌ 1CA00000002000000002 +Ƌ 1CA00000002000000008 +e 1CAA0000002000000002 +E 1CAA0000002000000008 +é 1CAA000000200024000000020002 +É 1CAA000000200024000000080002 +è 1CAA000000200025000000020002 +È 1CAA000000200025000000080002 +ĕ 1CAA000000200026000000020002 +Ĕ 1CAA000000200026000000080002 +ê 1CAA000000200027000000020002 +Ê 1CAA000000200027000000080002 +ế 1CAA00000020002700240000000200020002 +Ế 1CAA00000020002700240000000800020002 +ề 1CAA00000020002700250000000200020002 +Ề 1CAA00000020002700250000000800020002 +ễ 1CAA000000200027002D0000000200020002 +Ễ 1CAA000000200027002D0000000800020002 +ể 1CAA000000200027003B0000000200020002 +Ể 1CAA000000200027003B0000000800020002 +ě 1CAA000000200028000000020002 +Ě 1CAA000000200028000000080002 +ë 1CAA00000020002B000000020002 +Ë 1CAA00000020002B000000080002 +ẽ 1CAA00000020002D000000020002 +Ẽ 1CAA00000020002D000000080002 +ė 1CAA00000020002E000000020002 +Ė 1CAA00000020002E000000080002 +ę 1CAA000000200031000000020002 +Ę 1CAA000000200031000000080002 +ē 1CAA000000200032000000020002 +Ē 1CAA000000200032000000080002 +ẻ 1CAA00000020003B000000020002 +Ẻ 1CAA00000020003B000000080002 +ẹ 1CAA000000200042000000020002 +Ẹ 1CAA000000200042000000080002 +ệ 1CAA00000020004200270000000200020002 +Ệ 1CAA00000020004200270000000800020002 +ǝ 1CB80000002000000002 +Ǝ 1CB80000002000000008 +Ə 1CBD0000002000000008 +Ɛ 1CC20000002000000008 +f 1CE50000002000000002 +F 1CE50000002000000008 +ƒ 1CEE0000002000000002 +Ƒ 1CEE0000002000000008 +g 1CF40000002000000002 +G 1CF40000002000000008 +ǵ 1CF4000000200024000000020002 +Ǵ 1CF4000000200024000000080002 +ğ 1CF4000000200026000000020002 +Ğ 1CF4000000200026000000080002 +ĝ 1CF4000000200027000000020002 +Ĝ 1CF4000000200027000000080002 +ǧ 1CF4000000200028000000020002 +Ǧ 1CF4000000200028000000080002 +ġ 1CF400000020002E000000020002 +Ġ 1CF400000020002E000000080002 +ģ 1CF4000000200030000000020002 +Ģ 1CF4000000200030000000080002 +ggy 1CF41CF41F0B00000020002000200000000200020002 +gGY 1CF41CF41F0B00000020002000200000000200080008 +Ggy 1CF41CF41F0B00000020002000200000000800020002 +GGY 1CF41CF41F0B00000020002000200000000800080008 +gy 1CF41F0B000000200020000000020002 +gY 1CF41F0B000000200020000000020008 +Gy 1CF41F0B000000200020000000080002 +GY 1CF41F0B000000200020000000080008 +ǥ 1D010000002000000002 +Ǥ 1D010000002000000008 +Ɠ 1D060000002000000008 +Ɣ 1D100000002000000008 +ƣ 1D140000002000000002 +Ƣ 1D140000002000000008 +h 1D180000002000000002 +H 1D180000002000000008 +ĥ 1D18000000200027000000020002 +Ĥ 1D18000000200027000000080002 +ħ 1D18000000200039000000020002 +Ħ 1D18000000200039000000080002 +ƕ 1D200000002000000002 +Ƕ 1D200000002000000008 +i 1D320000002000000002 +I 1D320000002000000008 +í 1D32000000200024000000020002 +Í 1D32000000200024000000080002 +ì 1D32000000200025000000020002 +Ì 1D32000000200025000000080002 +ĭ 1D32000000200026000000020002 +Ĭ 1D32000000200026000000080002 +î 1D32000000200027000000020002 +Î 1D32000000200027000000080002 +ǐ 1D32000000200028000000020002 +Ǐ 1D32000000200028000000080002 +ï 1D3200000020002B000000020002 +Ï 1D3200000020002B000000080002 +ĩ 1D3200000020002D000000020002 +Ĩ 1D3200000020002D000000080002 +İ 1D3200000020002E000000080002 +į 1D32000000200031000000020002 +Į 1D32000000200031000000080002 +ī 1D32000000200032000000020002 +Ī 1D32000000200032000000080002 +ỉ 1D3200000020003B000000020002 +Ỉ 1D3200000020003B000000080002 +ị 1D32000000200042000000020002 +Ị 1D32000000200042000000080002 +ij 1D321D4C000000200020000000020002 +iJ 1D321D4C000000200020000000020008 +ij 1D321D4C000000200020000000040004 +Ij 1D321D4C000000200020000000080002 +IJ 1D321D4C000000200020000000080008 +IJ 1D321D4C0000002000200000000A000A +ı 1D360000002000000002 +Ɨ 1D410000002000000008 +Ɩ 1D470000002000000008 +j 1D4C0000002000000002 +J 1D4C0000002000000008 +ĵ 1D4C000000200027000000020002 +Ĵ 1D4C000000200027000000080002 +ǰ 1D4C000000200028000000020002 +k 1D650000002000000002 +K 1D650000002000000008 +ǩ 1D65000000200028000000020002 +Ǩ 1D65000000200028000000080002 +ķ 1D65000000200030000000020002 +Ķ 1D65000000200030000000080002 +ƙ 1D6B0000002000000002 +Ƙ 1D6B0000002000000008 +l 1D770000002000000002 +L 1D770000002000000008 +ĺ 1D77000000200024000000020002 +Ĺ 1D77000000200024000000080002 +ľ 1D77000000200028000000020002 +Ľ 1D77000000200028000000080002 +ļ 1D77000000200030000000020002 +Ļ 1D77000000200030000000080002 +ł 1D77000000200039000000020002 +Ł 1D77000000200039000000080002 +ŀ 1D77000000200110000000020002 +Ŀ 1D77000000200110000000080002 +lj 1D771D4C000000200020000000020002 +lJ 1D771D4C000000200020000000020008 +lj 1D771D4C000000200020000000040004 +Lj 1D771D4C000000200020000000080002 +LJ 1D771D4C000000200020000000080008 +Lj 1D771D4C0000002000200000000A0004 +LJ 1D771D4C0000002000200000000A000A +ll 1D771D77000000200020000000020002 +lL 1D771D77000000200020000000020008 +Ll 1D771D77000000200020000000080002 +LL 1D771D77000000200020000000080008 +lly 1D771D771F0B00000020002000200000000200020002 +lLY 1D771D771F0B00000020002000200000000200080008 +Lly 1D771D771F0B00000020002000200000000800020002 +LLY 1D771D771F0B00000020002000200000000800080008 +ly 1D771F0B000000200020000000020002 +lY 1D771F0B000000200020000000020008 +Ly 1D771F0B000000200020000000080002 +LY 1D771F0B000000200020000000080008 +ƚ 1D820000002000000002 +ƛ 1DA20000002000000002 +m 1DAA0000002000000002 +M 1DAA0000002000000008 +n 1DB90000002000000002 +N 1DB90000002000000008 +ń 1DB9000000200024000000020002 +Ń 1DB9000000200024000000080002 +ǹ 1DB9000000200025000000020002 +Ǹ 1DB9000000200025000000080002 +ň 1DB9000000200028000000020002 +Ň 1DB9000000200028000000080002 +ñ 1DB900000020002D000000020002 +Ñ 1DB900000020002D000000080002 +ņ 1DB9000000200030000000020002 +Ņ 1DB9000000200030000000080002 +nj 1DB91D4C000000200020000000020002 +nJ 1DB91D4C000000200020000000020008 +nj 1DB91D4C000000200020000000040004 +Nj 1DB91D4C000000200020000000080002 +NJ 1DB91D4C000000200020000000080008 +Nj 1DB91D4C0000002000200000000A0004 +NJ 1DB91D4C0000002000200000000A000A +nny 1DB91DB91F0B00000020002000200000000200020002 +nNY 1DB91DB91F0B00000020002000200000000200080008 +Nny 1DB91DB91F0B00000020002000200000000800020002 +NNY 1DB91DB91F0B00000020002000200000000800080008 +ny 1DB91F0B000000200020000000020002 +nY 1DB91F0B000000200020000000020008 +Ny 1DB91F0B000000200020000000080002 +NY 1DB91F0B000000200020000000080008 +Ɲ 1DC40000002000000008 +ƞ 1DC80000002000000002 +ŋ 1DD80000002000000002 +Ŋ 1DD80000002000000008 +o 1DDD0000002000000002 +O 1DDD0000002000000008 +ó 1DDD000000200024000000020002 +Ó 1DDD000000200024000000080002 +ò 1DDD000000200025000000020002 +Ò 1DDD000000200025000000080002 +ŏ 1DDD000000200026000000020002 +Ŏ 1DDD000000200026000000080002 +ô 1DDD000000200027000000020002 +Ô 1DDD000000200027000000080002 +ố 1DDD00000020002700240000000200020002 +Ố 1DDD00000020002700240000000800020002 +ồ 1DDD00000020002700250000000200020002 +Ồ 1DDD00000020002700250000000800020002 +ỗ 1DDD000000200027002D0000000200020002 +Ỗ 1DDD000000200027002D0000000800020002 +ổ 1DDD000000200027003B0000000200020002 +Ổ 1DDD000000200027003B0000000800020002 +ǒ 1DDD000000200028000000020002 +Ǒ 1DDD000000200028000000080002 +ö 1DDD00000020002B000000020002 +Ö 1DDD00000020002B000000080002 +ő 1DDD00000020002C000000020002 +Ő 1DDD00000020002C000000080002 +õ 1DDD00000020002D000000020002 +Õ 1DDD00000020002D000000080002 +ø 1DDD00000020002F000000020002 +Ø 1DDD00000020002F000000080002 +ǿ 1DDD00000020002F00240000000200020002 +Ǿ 1DDD00000020002F00240000000800020002 +ǫ 1DDD000000200031000000020002 +Ǫ 1DDD000000200031000000080002 +ǭ 1DDD00000020003100320000000200020002 +Ǭ 1DDD00000020003100320000000800020002 +ō 1DDD000000200032000000020002 +Ō 1DDD000000200032000000080002 +ỏ 1DDD00000020003B000000020002 +Ỏ 1DDD00000020003B000000080002 +ơ 1DDD00000020003F000000020002 +Ơ 1DDD00000020003F000000080002 +ớ 1DDD00000020003F00240000000200020002 +Ớ 1DDD00000020003F00240000000800020002 +ờ 1DDD00000020003F00250000000200020002 +Ờ 1DDD00000020003F00250000000800020002 +ỡ 1DDD00000020003F002D0000000200020002 +Ỡ 1DDD00000020003F002D0000000800020002 +ở 1DDD00000020003F003B0000000200020002 +Ở 1DDD00000020003F003B0000000800020002 +ợ 1DDD00000020003F00420000000200020002 +Ợ 1DDD00000020003F00420000000800020002 +ọ 1DDD000000200042000000020002 +Ọ 1DDD000000200042000000080002 +ộ 1DDD00000020004200270000000200020002 +Ộ 1DDD00000020004200270000000800020002 +oe 1DDD1CAA000000200020000000020002 +oE 1DDD1CAA000000200020000000020008 +Oe 1DDD1CAA000000200020000000080002 +OE 1DDD1CAA000000200020000000080008 +œ 1DDD1CAA00000020011000200000000400040004 +Œ 1DDD1CAA00000020011000200000000A0004000A +Ɔ 1DF00000002000000008 +Ɵ 1DFD0000002000000008 +p 1E0C0000002000000002 +P 1E0C0000002000000008 +ƥ 1E150000002000000002 +Ƥ 1E150000002000000008 +q 1E210000002000000002 +Q 1E210000002000000008 +ĸ 1E2F0000002000000002 +r 1E330000002000000002 +R 1E330000002000000008 +ŕ 1E33000000200024000000020002 +Ŕ 1E33000000200024000000080002 +ř 1E33000000200028000000020002 +Ř 1E33000000200028000000080002 +ŗ 1E33000000200030000000020002 +Ŗ 1E33000000200030000000080002 +rr 1E331E33000000200020000000020002 +rr 1E331E33000000200020000000020002 +rR 1E331E33000000200020000000020008 +rR 1E331E33000000200020000000020008 +Rr 1E331E33000000200020000000080002 +Rr 1E331E33000000200020000000080002 +RR 1E331E33000000200020000000080008 +RR 1E331E33000000200020000000080008 +Ʀ 1E380000002000000008 +s 1E710000002000000002 +S 1E710000002000000008 +ś 1E71000000200024000000020002 +Ś 1E71000000200024000000080002 +ŝ 1E71000000200027000000020002 +Ŝ 1E71000000200027000000080002 +š 1E71000000200028000000020002 +Š 1E71000000200028000000080002 +ş 1E71000000200030000000020002 +Ş 1E71000000200030000000080002 +ș 1E71000000200045000000020002 +Ș 1E71000000200045000000080002 +ſ 1E71000000200111000000040004 +ss 1E711E71000000200020000000020002 +sS 1E711E71000000200020000000020008 +Ss 1E711E71000000200020000000080002 +SS 1E711E71000000200020000000080008 +ß 1E711E7100000020011000200000000400040004 +ssz 1E711E711F2100000020002000200000000200020002 +sSZ 1E711E711F2100000020002000200000000200080008 +Ssz 1E711E711F2100000020002000200000000800020002 +SSZ 1E711E711F2100000020002000200000000800080008 +sz 1E711F21000000200020000000020002 +sZ 1E711F21000000200020000000020008 +Sz 1E711F21000000200020000000080002 +SZ 1E711F21000000200020000000080008 +Ʃ 1E820000002000000008 +ƪ 1E880000002000000002 +t 1E950000002000000002 +T 1E950000002000000008 +ť 1E95000000200028000000020002 +Ť 1E95000000200028000000080002 +ţ 1E95000000200030000000020002 +Ţ 1E95000000200030000000080002 +ț 1E95000000200045000000020002 +Ț 1E95000000200045000000080002 +ƾ 1E951E71000000200020000000040004 +tty 1E951E951F0B00000020002000200000000200020002 +tTY 1E951E951F0B00000020002000200000000200080008 +Tty 1E951E951F0B00000020002000200000000800020002 +TTY 1E951E951F0B00000020002000200000000800080008 +ty 1E951F0B000000200020000000020002 +tY 1E951F0B000000200020000000020008 +Ty 1E951F0B000000200020000000080002 +TY 1E951F0B000000200020000000080008 +ŧ 1E9A0000002000000002 +Ŧ 1E9A0000002000000008 +ƫ 1EA00000002000000002 +ƭ 1EA40000002000000002 +Ƭ 1EA40000002000000008 +Ʈ 1EA80000002000000008 +u 1EB50000002000000002 +U 1EB50000002000000008 +ú 1EB5000000200024000000020002 +Ú 1EB5000000200024000000080002 +ù 1EB5000000200025000000020002 +Ù 1EB5000000200025000000080002 +ŭ 1EB5000000200026000000020002 +Ŭ 1EB5000000200026000000080002 +û 1EB5000000200027000000020002 +Û 1EB5000000200027000000080002 +ǔ 1EB5000000200028000000020002 +Ǔ 1EB5000000200028000000080002 +ů 1EB5000000200029000000020002 +Ů 1EB5000000200029000000080002 +ü 1EB500000020002B000000020002 +Ü 1EB500000020002B000000080002 +ǘ 1EB500000020002B00240000000200020002 +Ǘ 1EB500000020002B00240000000800020002 +ǜ 1EB500000020002B00250000000200020002 +Ǜ 1EB500000020002B00250000000800020002 +ǚ 1EB500000020002B00280000000200020002 +Ǚ 1EB500000020002B00280000000800020002 +ǖ 1EB500000020002B00320000000200020002 +Ǖ 1EB500000020002B00320000000800020002 +ű 1EB500000020002C000000020002 +Ű 1EB500000020002C000000080002 +ũ 1EB500000020002D000000020002 +Ũ 1EB500000020002D000000080002 +ų 1EB5000000200031000000020002 +Ų 1EB5000000200031000000080002 +ū 1EB5000000200032000000020002 +Ū 1EB5000000200032000000080002 +ủ 1EB500000020003B000000020002 +Ủ 1EB500000020003B000000080002 +ư 1EB500000020003F000000020002 +Ư 1EB500000020003F000000080002 +ứ 1EB500000020003F00240000000200020002 +Ứ 1EB500000020003F00240000000800020002 +ừ 1EB500000020003F00250000000200020002 +Ừ 1EB500000020003F00250000000800020002 +ữ 1EB500000020003F002D0000000200020002 +Ữ 1EB500000020003F002D0000000800020002 +ử 1EB500000020003F003B0000000200020002 +Ử 1EB500000020003F003B0000000800020002 +ự 1EB500000020003F00420000000200020002 +Ự 1EB500000020003F00420000000800020002 +ụ 1EB5000000200042000000020002 +Ụ 1EB5000000200042000000080002 +ue 1EB51CAA000000200020000000020002 +uE 1EB51CAA000000200020000000020008 +Ue 1EB51CAA000000200020000000080002 +UE 1EB51CAA000000200020000000080008 +Ɯ 1ED40000002000000008 +Ʊ 1EDE0000002000000008 +v 1EE30000002000000002 +V 1EE30000002000000008 +Ʋ 1EEA0000002000000008 +w 1EF50000002000000002 +W 1EF50000002000000008 +ŵ 1EF5000000200027000000020002 +Ŵ 1EF5000000200027000000080002 +x 1EFF0000002000000002 +X 1EFF0000002000000008 +y 1F0B0000002000000002 +Y 1F0B0000002000000008 +ý 1F0B000000200024000000020002 +Ý 1F0B000000200024000000080002 +ŷ 1F0B000000200027000000020002 +Ŷ 1F0B000000200027000000080002 +ÿ 1F0B00000020002B000000020002 +Ÿ 1F0B00000020002B000000080002 +ƴ 1F170000002000000002 +Ƴ 1F170000002000000008 +z 1F210000002000000002 +Z 1F210000002000000008 +ź 1F21000000200024000000020002 +Ź 1F21000000200024000000080002 +ž 1F21000000200028000000020002 +Ž 1F21000000200028000000080002 +ż 1F2100000020002E000000020002 +Ż 1F2100000020002E000000080002 +zs 1F211E71000000200020000000020002 +zS 1F211E71000000200020000000020008 +Zs 1F211E71000000200020000000080002 +ZS 1F211E71000000200020000000080008 +ƍ 1F211EF5000000200020000000040004 +zzs 1F211F211E7100000020002000200000000200020002 +zZS 1F211F211E7100000020002000200000000200080008 +Zzs 1F211F211E7100000020002000200000000800020002 +ZZS 1F211F211E7100000020002000200000000800080008 +ƶ 1F260000002000000002 +Ƶ 1F260000002000000008 +Ʒ 1F3E0000002000000008 +ǯ 1F3E000000200028000000020002 +Ǯ 1F3E000000200028000000080002 +ƹ 1F430000002000000002 +Ƹ 1F430000002000000008 +ƺ 1F480000002000000002 +þ 1F500000002000000002 +Þ 1F500000002000000008 +ƿ 1F560000002000000002 +Ƿ 1F560000002000000008 +ƻ 1F620000002000000002 +ƨ 1F690000002000000002 +Ƨ 1F690000002000000008 +ƽ 1F6D0000002000000002 +Ƽ 1F6D0000002000000008 +ƅ 1F710000002000000002 +Ƅ 1F710000002000000008 +ʼn 1F7E1DB9000000200020000000040004 +ǀ 1F990000002000000002 +ǁ 1F9D0000002000000002 +ǂ 1FA10000002000000002 +ǃ 1FA50000002000000002 +ඖ 28E10000002000000002 +ඤ 28EC0000002000000002 +ඥ 28ED0000002000000002 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(10)) COLLATE utf8mb4_da_0900_as_cs; +INSERT INTO t1 VALUES('z'), (_utf16 0x00C50053), (_utf16 0x00C50073), (_utf16 0x00E50053), (_utf16 0x00E50073), (_utf16 0x00C10053), (_utf16 0x00C10073), (_utf16 0x00E10073), (_utf16 0x00E10053), ('aAS'), ('aAs'), ('AS'), ('As'), ('as'), ('aS'), ('aas'), ('AAS'), ('Aas'), ('AAs'), ('aaS'), ('AaS'); +SELECT HEX(CONVERT(a USING utf16)), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, BINARY a; +HEX(CONVERT(a USING utf16)) HEX(WEIGHT_STRING(a)) +006100410053 1C471C471E7100000020002000200000030201080108 +006100410073 1C471C471E7100000020002000200000030201080302 +00410053 1C471E71000000200020000001080108 +00410073 1C471E71000000200020000001080302 +00610053 1C471E71000000200020000003020108 +00610073 1C471E71000000200020000003020302 +00C10053 1C471E7100000020002400200000010803020108 +00C10073 1C471E7100000020002400200000010803020302 +00E10053 1C471E7100000020002400200000030203020108 +00E10073 1C471E7100000020002400200000030203020302 +007A 1F210000002000000302 +00C50053 1F9854A71E710000002000200000010201210108 +00C50073 1F9854A71E710000002000200000010201210302 +004100410053 1F9854A71E710000002000200000010201240108 +004100410073 1F9854A71E710000002000200000010201240302 +004100610053 1F9854A71E710000002000200000020202230108 +004100610073 1F9854A71E710000002000200000020202230302 +00E50053 1F9854A71E71000000200020000003020108 +00E50073 1F9854A71E71000000200020000003020302 +006100610053 1F9854A71E710000002000200000030203220108 +006100610073 1F9854A71E710000002000200000030203220302 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(10)) COLLATE utf8mb4_da_0900_as_cs; +INSERT INTO t1 VALUES (_utf16 0x00DE, _utf16 0x0074), (_utf16 0x0162, _utf16 0x00DE), (_utf16 0x0162, _utf16 0x00FE), +(_utf16 0x0163, _utf16 0x00DE), (_utf16 0x0163, _utf16 0x00FE), (_utf16 0x0164, _utf16 0x00DE), +(_utf16 0x0164, _utf16 0x00FE), (_utf16 0x0165, _utf16 0x00DE), (_utf16 0x0165, _utf16 0x00FE), +(_utf16 0x01D5, _utf16 0x00DC), (_utf16 0x01D5, _utf16 0x00FC), (_utf16 0x01D7, _utf16 0x00DC), +(_utf16 0x01D7, _utf16 0x00FC), (_utf16 0x01D8, _utf16 0x01D5), (_utf16 0x01D9, _utf16 0x00DC), +(_utf16 0x01D9, _utf16 0x00FC), (_utf16 0x01D9, _utf16 0x01D7), (_utf16 0x01D9, _utf16 0x01D8), +(_utf16 0x01DA, _utf16 0x01D5), (_utf16 0x01DA, _utf16 0x01D8), (_utf16 0x01DB, _utf16 0x00DC), +(_utf16 0x01DB, _utf16 0x00FC), (_utf16 0x01DB, _utf16 0x01D7), (_utf16 0x01DB, _utf16 0x01D8), +(_utf16 0x01DC, _utf16 0x01D5), (_utf16 0x01DC, _utf16 0x01D8), (_utf16 0x01DC, _utf16 0x01D9), +(_utf16 0x01DE, _utf16 0x00C4), (_utf16 0x01DE, _utf16 0x00E4), (_utf16 0x01E2, _utf16 0x00C6), +(_utf16 0x01E2, _utf16 0x00E6), (_utf16 0x01FA, _utf16 0x00C5), (_utf16 0x01FA, _utf16 0x00E5), +(_utf16 0x01FC, _utf16 0x00C6), (_utf16 0x01FC, _utf16 0x00E6), (_utf16 0x01FD, _utf16 0x01E2), +(_utf16 0x01FE, _utf16 0x00D8), (_utf16 0x01FE, _utf16 0x00F8), (_utf16 0x021A, _utf16 0x00DE), +(_utf16 0x021A, _utf16 0x00FE), (_utf16 0x021B, _utf16 0x00DE), (_utf16 0x021B, _utf16 0x00FE), +(_utf16 0x022A, _utf16 0x00D6), (_utf16 0x022A, _utf16 0x00F6), (_utf16 0x02A8, _utf16 0x00DE), +(_utf16 0x02A8, _utf16 0x00FE); +SELECT a > b FROM t1; +a > b +1 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +1 +1 +0 +1 +1 +1 +1 +0 +1 +1 +1 +1 +1 +0 +1 +0 +1 +1 +1 +1 +1 +1 +1 +1 +0 +1 +1 +0 +0 +0 +0 +1 +1 +0 +0 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(10), c integer) COLLATE utf8mb4_vi_0900_as_cs; +INSERT INTO t1 VALUES (_utf16 0x00C1, _utf16 0x00C0, 1), +(_utf16 0x00C3, _utf16 0x00C1, 0), (_utf16 0x00C4, _utf16 0x00C3, 1), +(_utf16 0x00C5, _utf16 0x00C3, 1), (_utf16 0x00C9, _utf16 0x00C8, 1), +(_utf16 0x00CD, _utf16 0x00CC, 1), (_utf16 0x00D3, _utf16 0x00D2, 1), +(_utf16 0x00D5, _utf16 0x00D3, 0), (_utf16 0x00D6, _utf16 0x00D5, 1), +(_utf16 0x00DA, _utf16 0x00D9, 1), (_utf16 0x00E0, _utf16 0x00C1, 0), +(_utf16 0x00E1, _utf16 0x00C0, 1), (_utf16 0x00E3, _utf16 0x00C1, 0), +(_utf16 0x00E4, _utf16 0x00C3, 1), (_utf16 0x00E5, _utf16 0x00C3, 1), +(_utf16 0x00E8, _utf16 0x00C9, 0), (_utf16 0x00E9, _utf16 0x00C8, 1), +(_utf16 0x00EC, _utf16 0x00CD, 0), (_utf16 0x00ED, _utf16 0x00CC, 1), +(_utf16 0x00F2, _utf16 0x00D3, 0), (_utf16 0x00F3, _utf16 0x00D2, 1), +(_utf16 0x00F5, _utf16 0x00D3, 0), (_utf16 0x00F6, _utf16 0x00D5, 1), +(_utf16 0x00F9, _utf16 0x00DA, 0), (_utf16 0x00FA, _utf16 0x00D9, 1), +(_utf16 0x0128, _utf16 0x00CD, 0), (_utf16 0x0129, _utf16 0x00CD, 0), +(_utf16 0x012C, _utf16 0x0128, 1), (_utf16 0x012D, _utf16 0x0128, 1), +(_utf16 0x0143, _utf16 0x00D1, 1), (_utf16 0x0144, _utf16 0x00D1, 1), +(_utf16 0x0147, _utf16 0x00D1, 1), (_utf16 0x0148, _utf16 0x00D1, 1), +(_utf16 0x014E, _utf16 0x00D5, 1), (_utf16 0x014F, _utf16 0x00D5, 1), +(_utf16 0x0150, _utf16 0x00D5, 1), (_utf16 0x0151, _utf16 0x00D5, 1), +(_utf16 0x0168, _utf16 0x00DA, 0), (_utf16 0x0169, _utf16 0x00DA, 0), +(_utf16 0x016C, _utf16 0x0168, 1), (_utf16 0x016D, _utf16 0x0168, 1), +(_utf16 0x016E, _utf16 0x0168, 1), (_utf16 0x016F, _utf16 0x0168, 1), +(_utf16 0x0170, _utf16 0x0168, 1), (_utf16 0x0171, _utf16 0x0168, 1), +(_utf16 0x01CD, _utf16 0x00C3, 1), (_utf16 0x01CE, _utf16 0x00C3, 1), +(_utf16 0x01CF, _utf16 0x0128, 1), (_utf16 0x01D0, _utf16 0x0128, 1), +(_utf16 0x01D1, _utf16 0x00D5, 1), (_utf16 0x01D2, _utf16 0x00D5, 1), +(_utf16 0x01D3, _utf16 0x0168, 1), (_utf16 0x01D4, _utf16 0x0168, 1), +(_utf16 0x01D5, _utf16 0x0168, 1), (_utf16 0x01D6, _utf16 0x0168, 1), +(_utf16 0x01D7, _utf16 0x0168, 1), (_utf16 0x01D8, _utf16 0x0168, 1), +(_utf16 0x01D9, _utf16 0x0168, 1), (_utf16 0x01DA, _utf16 0x0168, 1), +(_utf16 0x01DB, _utf16 0x0168, 1), (_utf16 0x01DC, _utf16 0x0168, 1), +(_utf16 0x01DE, _utf16 0x00C3, 1), (_utf16 0x01DF, _utf16 0x00C3, 1), +(_utf16 0x01F8, _utf16 0x0143, 0), (_utf16 0x01F9, _utf16 0x0143, 0), +(_utf16 0x01FA, _utf16 0x00C3, 1), (_utf16 0x01FB, _utf16 0x00C3, 1), +(_utf16 0x022A, _utf16 0x00D5, 1), (_utf16 0x022B, _utf16 0x00D5, 1), +(_utf16 0x022C, _utf16 0x00D3, 0), (_utf16 0x022D, _utf16 0x00D3, 0); +SELECT a, b, c FROM t1 where (a > b) <> c; +a b c +DROP TABLE t1; +# +# Bug 24480513: ANGSTROM SIGN NOT CORRECTLY HANDLED IN +# UTF8MB4_DA_0900_AS_CS +# +SET NAMES utf8mb4; +SELECT CONVERT(_utf16 0x212B USING utf8mb4) = CONVERT(_utf16 0x00C5 USING +utf8mb4) COLLATE utf8mb4_da_0900_as_cs AS result; +result +1 +SET NAMES default; +# +# Bug 24579093: WL#9109: SOME CHARACTERS DEVIATE FROM ICU FOR VIETNAMESE +# +CREATE TABLE t1(a CHAR, b CHAR, c INTEGER) COLLATE utf8mb4_vi_0900_as_cs; +INSERT INTO t1 VALUES (_utf16 0x1F8C , _utf16 0x1F02, 1), +(_utf16 0x1F8D , _utf16 0x1F03, 1), (_utf16 0x1F9C , _utf16 0x1F22, 1), +(_utf16 0x1F9D , _utf16 0x1F23, 1), (_utf16 0x1FAC , _utf16 0x1F62, 1), +(_utf16 0x1FAD , _utf16 0x1F63, 1), (_utf16 0x1FCE , _utf16 0x1FCD, 1), +(_utf16 0x1FDE , _utf16 0x1FDD, 1), (_utf16 0x1FED , _utf16 0x0385, 0), +(_utf16 0x1FEE , _utf16 0x1FED, 1); +SELECT a, b, c FROM t1 where (a > b) <> c; +a b c +DROP TABLE t1; +CREATE TABLE t1(a CHAR, description VARCHAR(30)) COLLATE utf8mb4_ja_0900_as_cs; +INSERT INTO t1 VALUES('a', 'Latin'), ('A', 'Latin'), (_utf16 0x02AC, 'Latin'), +(_utf16 0x02AD, 'Latin'), (_utf16 0x03B1, 'Greak'), (_utf16 0x2C81, 'Coptic'), +(_utf16 0x0430, 'Cyrillic'), (_utf16 0xD7FB, 'Hangul'), +(_utf16 0x3041, 'Hiragana'), (_utf16 0x3105, 'Bopomofo'), +(_utf16 0x2F00, 'Other Han'), (_utf16 0x4E00, 'Japanese Han'), +(_utf16 0x9FFF, 'Other'), (_utf16 0xA000, 'Other'), +(_utf16 0x9FD5, 'Other Han'), (_utf16 0xFA0E, 'Other Han'), +(_utf16 0x3400, 'Other Han'), (_utf16 0x4E9C, 'Japanese Han'), +(_utf16 0x7199, 'Japanese Han'), (_utf16 0x6190, 'Japanese Han'), +(_utf16 0x30F3, 'Katakana'), (_utf16 0x306F, 'Hiragana HA'), +(_utf16 0x3070, 'Hiragana BA'), (_utf16 0x3071, 'Hiragana PA'); +SELECT HEX(CONVERT(a USING utf16)), description FROM t1 ORDER BY a; +HEX(CONVERT(a USING utf16)) description +0061 Latin +0041 Latin +02AC Latin +02AD Latin +3041 Hiragana +306F Hiragana HA +3070 Hiragana BA +3071 Hiragana PA +30F3 Katakana +4E9C Japanese Han +4E00 Japanese Han +6190 Japanese Han +7199 Japanese Han +2F00 Other Han +9FD5 Other Han +FA0E Other Han +3400 Other Han +03B1 Greak +2C81 Coptic +0430 Cyrillic +D7FB Hangul +3105 Bopomofo +A000 Other +9FFF Other +DROP TABLE t1; +CREATE TABLE t1(a CHAR, description VARCHAR(30)) COLLATE utf8mb4_ja_0900_as_cs_ks; +INSERT INTO t1 VALUES('a', 'Latin'), ('A', 'Latin'), (_utf16 0x02AC, 'Latin'), +(_utf16 0x02AD, 'Latin'), (_utf16 0x03B1, 'Greak'), (_utf16 0x2C81, 'Coptic'), +(_utf16 0x0430, 'Cyrillic'), (_utf16 0xD7FB, 'Hangul'), +(_utf16 0x3041, 'Hiragana'), (_utf16 0x3105, 'Bopomofo'), +(_utf16 0x2F00, 'Other Han'), (_utf16 0x4E00, 'Japanese Han'), +(_utf16 0x9FFF, 'Other'), (_utf16 0xA000, 'Other'), +(_utf16 0x9FD5, 'Other Han'), (_utf16 0xFA0E, 'Other Han'), +(_utf16 0x3400, 'Other Han'), (_utf16 0x4E9C, 'Japanese Han'), +(_utf16 0x7199, 'Japanese Han'), (_utf16 0x6190, 'Japanese Han'), +(_utf16 0x30F3, 'Katakana'), (_utf16 0x306F, 'Hiragana HA'), +(_utf16 0x3070, 'Hiragana BA'), (_utf16 0x3071, 'Hiragana PA'); +SELECT HEX(CONVERT(a USING utf16)), description FROM t1 ORDER BY a; +HEX(CONVERT(a USING utf16)) description +0061 Latin +0041 Latin +02AC Latin +02AD Latin +3041 Hiragana +306F Hiragana HA +3070 Hiragana BA +3071 Hiragana PA +30F3 Katakana +4E9C Japanese Han +4E00 Japanese Han +6190 Japanese Han +7199 Japanese Han +2F00 Other Han +9FD5 Other Han +FA0E Other Han +3400 Other Han +03B1 Greak +2C81 Coptic +0430 Cyrillic +D7FB Hangul +3105 Bopomofo +A000 Other +9FFF Other +DROP TABLE t1; +SET @s1 = CONVERT(_utf16 0x304D30853046 USING utf8mb4); +SET @s2 = CONVERT(_utf16 0x30AD30E530A6 USING utf8mb4); +SET @s3 = CONVERT(_utf16 0x304D30863046 USING utf8mb4); +SET @s4 = CONVERT(_utf16 0x30AD30E630A6 USING utf8mb4); +SELECT STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs, @s2 COLLATE utf8mb4_ja_0900_as_cs); +STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs, @s2 COLLATE utf8mb4_ja_0900_as_cs) +0 +SELECT STRCMP(@s2 COLLATE utf8mb4_ja_0900_as_cs, @s3 COLLATE utf8mb4_ja_0900_as_cs); +STRCMP(@s2 COLLATE utf8mb4_ja_0900_as_cs, @s3 COLLATE utf8mb4_ja_0900_as_cs) +-1 +SELECT STRCMP(@s3 COLLATE utf8mb4_ja_0900_as_cs, @s4 COLLATE utf8mb4_ja_0900_as_cs); +STRCMP(@s3 COLLATE utf8mb4_ja_0900_as_cs, @s4 COLLATE utf8mb4_ja_0900_as_cs) +0 +SELECT STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs_ks, @s2 COLLATE utf8mb4_ja_0900_as_cs_ks); +STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs_ks, @s2 COLLATE utf8mb4_ja_0900_as_cs_ks) +-1 +SELECT STRCMP(@s2 COLLATE utf8mb4_ja_0900_as_cs_ks, @s3 COLLATE utf8mb4_ja_0900_as_cs_ks); +STRCMP(@s2 COLLATE utf8mb4_ja_0900_as_cs_ks, @s3 COLLATE utf8mb4_ja_0900_as_cs_ks) +-1 +SELECT STRCMP(@s3 COLLATE utf8mb4_ja_0900_as_cs_ks, @s4 COLLATE utf8mb4_ja_0900_as_cs_ks); +STRCMP(@s3 COLLATE utf8mb4_ja_0900_as_cs_ks, @s4 COLLATE utf8mb4_ja_0900_as_cs_ks) +-1 +SET @s1 = CONVERT(_utf16 0x309D USING utf8mb4); +SET @s2 = CONVERT(_utf16 0x30FD USING utf8mb4); +SELECT STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs, @s2 COLLATE utf8mb4_ja_0900_as_cs); +STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs, @s2 COLLATE utf8mb4_ja_0900_as_cs) +0 +SELECT STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs_ks, @s2 COLLATE utf8mb4_ja_0900_as_cs_ks); +STRCMP(@s1 COLLATE utf8mb4_ja_0900_as_cs_ks, @s2 COLLATE utf8mb4_ja_0900_as_cs_ks) +-1 +CREATE TABLE t1(a VARCHAR(20)) COLLATE utf8mb4_ja_0900_as_cs_ks; +INSERT INTO t1 VALUES(_utf16 0x30FC), (_utf16 0x30A230FC), (_utf16 0x304230FC), +(_utf16 0x65E5672C8A9E), (_utf16 0x30443059309E), (_utf16 0x30443059305A), +(_utf16 0x30A430B930FE), (_utf16 0x30A430B930BA), +(_utf16 0x65E5672C8A9E30CB30DB30F330B4); +SELECT HEX(CONVERT(a USING utf16)), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +HEX(CONVERT(a USING utf16)) HEX(WEIGHT_STRING(a)) +30FC 1C0E000000200000000200000008 +304230FC 1FB61FB60000002000200000000E000C0021000000020002 +30A230FC 1FB61FB60000002000200000000E000C0021000000080008 +30443059309E 1FB71FC31FC3000000200020002000370000000E000E000E000100210000000200020002 +30A430B930FE 1FB71FC31FC3000000200020002000370000000E000E000E000100210000000800080008 +30443059305A 1FB71FC31FC3000000200020002000370000000E000E000E00020000000200020002 +30A430B930BA 1FB71FC31FC3000000200020002000370000000E000E000E00020000000800080008 +65E5672C8A9E 5D135EC957DF00000020002000200000000200020002 +65E5672C8A9E30CB30DB30F330B4 5D135EC957DF1FCC1FD41FE71FC00000002000200020002000200020002000370000000200020002000E000E000E000E000200000008000800080008 +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(20), KEY a (a)) COLLATE utf8mb4_ja_0900_as_cs_ks +PARTITION BY KEY (a) PARTITIONS 3; +INSERT INTO t1 VALUES(_utf16 0x30FC), (_utf16 0x30A230FC), (_utf16 0x304230FC), +(_utf16 0x65E5672C8A9E), (_utf16 0x30443059309E), (_utf16 0x30443059305A), +(_utf16 0x30A430B930FE), (_utf16 0x30A430B930BA), +(_utf16 0x65E5672C8A9E30CB30DB30F330B4); +SELECT HEX(CONVERT(a USING utf16)) FROM t1 WHERE a = _utf16 0x30443059305A; +HEX(CONVERT(a USING utf16)) +30443059305A +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) COLLATE utf8mb4_ru_0900_as_cs; +INSERT INTO t1 VALUES(_utf16 0x0452), (_utf16 0x0453), (_utf16 0x0403), +(_utf16 0x0439), (_utf16 0x048B), (_utf16 0x048A), (_utf16 0x043B), +(_utf16 0x1D2B), (_utf16 0x045B), (_utf16 0x045C), (_utf16 0x040C); +SELECT HEX(CONVERT(a USING utf16)) AS codepoint FROM t1 ORDER BY a, HEX(a); +codepoint +0453 +0403 +0452 +048B +048A +0439 +045C +040C +043B +1D2B +045B +DROP TABLE t1; +# +# End of 5.8 tests +# +CREATE TABLE t1(a VARCHAR(10)) COLLATE utf8mb4_zh_0900_as_cs; +INSERT INTO t1 VALUES(_utf16 0x2E87), (_utf16 0x2E8D), (_utf16 0x2F17), +(_utf16 0x3038), (_utf16 0x24B6), (_utf32 0x1F150), (_utf16 0x4E2D), +(_utf16 0x3197), (_utf32 0x1F22D), ('A'), ('a'), ('Z'), ('z'), +(_utf16 0x3082), (_utf16 0x30E2), (_utf16 0x2E31), (_utf16 0x33E8), +(_utf32 0x1F229), (_utf32 0x1F241), (_utf16 0xFA56); +SELECT HEX(CONVERT(a USING utf32)), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, HEX(a); +HEX(CONVERT(a USING utf32)) HEX(WEIGHT_STRING(a)) +00002E31 028C0000002000000002 +0001F241 0379815D037A000000200020002000000002000200020021 +000033E8 1C467F7E0000002000200000000200020021 +00002E87 4CDF000000200110000000040004 +0000FA56 51CD0000002000000002 +00002F17 857A00000020000000020021 +00003038 857A00000020000000020022 +00002E8D 9C310000002000000002 +0001F229 A63E00000020000000020024 +00004E2D B8200000002000000002 +00003197 B82000000020000000020021 +0001F22D B82000000020000000020023 +00000061 BDC40000002000000002 +00000041 BDC40000002000000008 +000024B6 BDC4000000200000000C +0001F150 BDC4000000200000000C +0000007A C09E0000002000000002 +0000005A C09E0000002000000008 +00003082 DEFA000000200000000E +000030E2 DEFA0000002000000011 +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(10)) COLLATE utf8mb4_zh_0900_as_cs; +INSERT INTO t1 VALUES(_utf16 0x6C88), (_utf16 0x5F1E), (_utf16 0x9633), +(_utf16 0x6C889633), (_utf16 0x5F1E9633); +SELECT HEX(CONVERT(a USING utf32)), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, HEX(a); +HEX(CONVERT(a USING utf32)) HEX(WEIGHT_STRING(a)) +00006C88 289C0000002000000002 +00005F1E 848C0000002000000002 +00005F1E00009633 848CA41B000000200020000000020002 +00006C8800009633 848CA41BF645000000200020000000020002 +00009633 A41B0000002000000002 +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(10), b VARCHAR(10)) COLLATE utf8mb4_zh_0900_as_cs; +INSERT INTO t1 VALUES(_utf16 0xF902, _utf16 0x2F9E), (_utf16 0xF907, _utf16 0x2FD4), +(_utf16 0xF908, _utf16 0x2FD4), (_utf16 0xF9D1, _utf16 0x3285); +SELECT HEX(CONVERT(a USING utf16)) AS a_u16, HEX(CONVERT(b USING utf16)) AS b_u16, a = b FROM t1; +a_u16 b_u16 a = b +F902 2F9E 0 +F907 2FD4 0 +F908 2FD4 0 +F9D1 3285 0 +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(10)) COLLATE utf8mb4_zh_0900_as_cs; +INSERT INTO t1 VALUES(_utf16 0x1EC2), (_utf16 0x1EC3), (_utf16 0x1EC5), (_utf16 0x1EC0), (_utf16 0x1EC7), (_Utf16 0x1EBF); +SELECT HEX(CONVERT(a USING utf16)) FROM t1 ORDER BY a; +HEX(CONVERT(a USING utf16)) +1EC5 +1EC3 +1EC2 +1EC7 +1EBF +1EC0 +DROP TABLE t1; diff --git a/mysql-test/r/ctype_utf16.result-pq b/mysql-test/r/ctype_utf16.result-pq new file mode 100644 index 000000000..ca1c9f150 --- /dev/null +++ b/mysql-test/r/ctype_utf16.result-pq @@ -0,0 +1,1380 @@ +# +# Start of 5.5 tests +# +SET NAMES latin1; +SET character_set_connection=utf16; +select hex('a'), hex('a '); +hex('a') hex('a ') +0061 00610020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +0 1 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +0 0 1 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +0 1 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +0 0 1 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 1 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select hex(_utf16 0x44); +hex(_utf16 0x44) +0044 +select hex(_utf16 0x3344); +hex(_utf16 0x3344) +3344 +select hex(_utf16 0x113344); +hex(_utf16 0x113344) +00113344 +CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf16; +INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +0420 +2004 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +0420 +2004 +DELETE FROM t1; +INSERT INTO t1 VALUES (X'042000200020',X'042000200020'), (X'200400200020', X'200400200020'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +042000200020 +200400200020 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +0420 +2004 +DROP TABLE t1; +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'0421')); +hex(LPAD(_utf16 X'0420',10,_utf16 X'0421')) +0421042104210421042104210421042104210420 +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'04210422')); +hex(LPAD(_utf16 X'0420',10,_utf16 X'04210422')) +0421042204210422042104220421042204210420 +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'042104220423')); +hex(LPAD(_utf16 X'0420',10,_utf16 X'042104220423')) +0421042204230421042204230421042204230420 +SELECT hex(LPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')); +hex(LPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')) +0420042104220423042404250426042704280429 +SELECT hex(LPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')); +hex(LPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')) +042104210421042104210421042104210421D800DC00 +SELECT hex(LPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')); +hex(LPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')) +D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC000421 +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'0421')); +hex(RPAD(_utf16 X'0420',10,_utf16 X'0421')) +0420042104210421042104210421042104210421 +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'04210422')); +hex(RPAD(_utf16 X'0420',10,_utf16 X'04210422')) +0420042104220421042204210422042104220421 +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'042104220423')); +hex(RPAD(_utf16 X'0420',10,_utf16 X'042104220423')) +0420042104220423042104220423042104220423 +SELECT hex(RPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')); +hex(RPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')) +0420042104220423042404250426042704280429 +SELECT hex(RPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')); +hex(RPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')) +D800DC00042104210421042104210421042104210421 +SELECT hex(RPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')); +hex(RPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')) +0421D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00 +CREATE TABLE t1 SELECT +LPAD(_utf16 X'0420',10,_utf16 X'0421') l, +RPAD(_utf16 X'0420',10,_utf16 X'0421') r; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `l` varchar(10) CHARACTER SET utf16 DEFAULT NULL, + `r` varchar(10) CHARACTER SET utf16 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(l), hex(r) from t1; +hex(l) hex(r) +0421042104210421042104210421042104210420 0420042104210421042104210421042104210421 +DROP TABLE t1; +create table t1 (f1 char(30)); +insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t1; +lpad(f1, 12, "-o-/") +-o-/-o103000 +-o-/22720000 +-o-/-3401200 +-o-/-o-78000 +drop table t1; +SET NAMES latin1; +SET character_set_connection=utf16; +select @@collation_connection; +@@collation_connection +utf16_general_ci +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf16 DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%') +explain select * from t1 where a like concat('abc','%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like (concat('abc','%'))) +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +select 'AA' like 'AA'; +'AA' like 'AA' +1 +select 'AA' like 'A%A'; +'AA' like 'A%A' +1 +select 'AA' like 'A%%A'; +'AA' like 'A%%A' +1 +select 'AA' like 'AA%'; +'AA' like 'AA%' +1 +select 'AA' like '%AA%'; +'AA' like '%AA%' +1 +select 'AA' like '%A'; +'AA' like '%A' +1 +select 'AA' like '%AA'; +'AA' like '%AA' +1 +select 'AA' like 'A%A%'; +'AA' like 'A%A%' +1 +select 'AA' like '_%_%'; +'AA' like '_%_%' +1 +select 'AA' like '%A%A'; +'AA' like '%A%A' +1 +select 'AAA'like 'A%A%A'; +'AAA'like 'A%A%A' +1 +select 'AZ' like 'AZ'; +'AZ' like 'AZ' +1 +select 'AZ' like 'A%Z'; +'AZ' like 'A%Z' +1 +select 'AZ' like 'A%%Z'; +'AZ' like 'A%%Z' +1 +select 'AZ' like 'AZ%'; +'AZ' like 'AZ%' +1 +select 'AZ' like '%AZ%'; +'AZ' like '%AZ%' +1 +select 'AZ' like '%Z'; +'AZ' like '%Z' +1 +select 'AZ' like '%AZ'; +'AZ' like '%AZ' +1 +select 'AZ' like 'A%Z%'; +'AZ' like 'A%Z%' +1 +select 'AZ' like '_%_%'; +'AZ' like '_%_%' +1 +select 'AZ' like '%A%Z'; +'AZ' like '%A%Z' +1 +select 'AZ' like 'A_'; +'AZ' like 'A_' +1 +select 'AZ' like '_Z'; +'AZ' like '_Z' +1 +select 'AMZ'like 'A%M%Z'; +'AMZ'like 'A%M%Z' +1 +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET character_set_connection=utf16; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16); +INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывА'),('ФЫВА'); +INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж'); +INSERT INTO t1 VALUES ('фывАпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж'); +INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВАПРОЛДЖ'); +SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf16_bin ORDER BY BINARY a; +a +фЫва +фЫвапролдж +DROP TABLE t1; +CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word)) +CHARACTER SET utf16; +INSERT INTO t1 (word) VALUES ("cat"); +SELECT * FROM t1 WHERE word LIKE "c%"; +word +cat +SELECT * FROM t1 WHERE word LIKE "ca_"; +word +cat +SELECT * FROM t1 WHERE word LIKE "cat"; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf16 x'00630025'; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf16 x'00630061005F'; +word +cat +DROP TABLE t1; +select insert(_utf16 0x006100620063,10,2,_utf16 0x006400650066); +insert(_utf16 0x006100620063,10,2,_utf16 0x006400650066) +abc +select insert(_utf16 0x006100620063,1,2,_utf16 0x006400650066); +insert(_utf16 0x006100620063,1,2,_utf16 0x006400650066) +defc +SELECT hex(cast(0xAA as char character set utf16)); +hex(cast(0xAA as char character set utf16)) +00AA +SELECT hex(convert(0xAA using utf16)); +hex(convert(0xAA using utf16)) +00AA +CREATE TABLE t1 (a char(10) character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a varchar(10) character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a text character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a mediumtext character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a longtext character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +create table t1(a char(1)) default charset utf16; +insert into t1 values ('a'),('b'),('c'); +alter table t1 modify a char(5); +select a, hex(a) from t1; +a hex(a) +a 0061 +b 0062 +c 0063 +drop table t1; +set names latin1; +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using utf16); +prepare stmt1 from @str2; +execute stmt1 using @ivar; +? +1234 +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a enum('x','y','z') character set utf16); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z') CHARACTER SET utf16 COLLATE utf16_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +z 007A +alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set utf16; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z','d','e','ä','ö','ü') CHARACTER SET utf16 COLLATE utf16_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('D'); +insert into t1 values ('E '); +insert into t1 values ('ä'); +insert into t1 values ('ö'); +insert into t1 values ('ü'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +z 007A +d 0064 +e 0065 +ä 00E4 +ö 00F6 +ü 00FC +drop table t1; +create table t1 (a set ('x','y','z','ä','ö','ü') character set utf16); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` set('x','y','z','ä','ö','ü') CHARACTER SET utf16 COLLATE utf16_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +insert into t1 values ('x,y'); +insert into t1 values ('x,y,z,ä,ö,ü'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +x,y 0078002C0079 +z 007A +x,y,z,ä,ö,ü 0078002C0079002C007A002C00E4002C00F6002C00FC +drop table t1; +create table t1(a enum('a','b','c')) default character set utf16; +insert into t1 values('a'),('b'),('c'); +alter table t1 add b char(1); +show warnings; +Level Code Message +select * from t1 order by a; +a b +a NULL +b NULL +c NULL +drop table t1; +SET NAMES latin1; +SET collation_connection='utf16_general_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16_general_ci 00610009 +utf16_general_ci 0061 +utf16_general_ci 00610020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf16_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +SET NAMES latin1; +SET collation_connection='utf16_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16_bin 00610009 +utf16_bin 0061 +utf16_bin 00610020 +drop table t1; +# +# Bug#55980 Character sets: supplementary character _bin ordering is wrong +# +CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16 COLLATE utf16_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84); +INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +0385 CE85 +FF9D EFBE9D +D800DF84 F0908E84 +DBC0DC00 F4808080 +ALTER TABLE t1 ADD KEY(a); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +0385 CE85 +FF9D EFBE9D +D800DF84 F0908E84 +DBC0DC00 F4808080 +# Additional test for bug#37244 Character sets: short utf8_bin weight_string value +SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +HEX(a) HEX(WEIGHT_STRING(a)) +0385 000385 +FF9D 00FF9D +D800DF84 010384 +DBC0DC00 100000 +DROP TABLE IF EXISTS t1; +# +# BUG#16691598 - ORDER BY LOWER(COLUMN) PRODUCES +# OUT-OF-ORDER RESULTS +# +CREATE TABLE t1 SELECT ('a a') as n; +INSERT INTO t1 VALUES('a b'); +SELECT * FROM t1 ORDER BY LOWER(n) ASC; +n +a a +a b +SELECT * FROM t1 ORDER BY LOWER(n) DESC; +n +a b +a a +DROP TABLE t1; +select @@collation_connection; +@@collation_connection +utf16_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +select hex(substr(_utf16 0x00e400e50068,1)); +hex(substr(_utf16 0x00e400e50068,1)) +00E400E50068 +select hex(substr(_utf16 0x00e400e50068,2)); +hex(substr(_utf16 0x00e400e50068,2)) +00E50068 +select hex(substr(_utf16 0x00e400e50068,3)); +hex(substr(_utf16 0x00e400e50068,3)) +0068 +select hex(substr(_utf16 0x00e400e50068,-1)); +hex(substr(_utf16 0x00e400e50068,-1)) +0068 +select hex(substr(_utf16 0x00e400e50068,-2)); +hex(substr(_utf16 0x00e400e50068,-2)) +00E50068 +select hex(substr(_utf16 0x00e400e50068,-3)); +hex(substr(_utf16 0x00e400e50068,-3)) +00E400E50068 +select hex(substr(_utf16 0x00e400e5D800DC00,1)); +hex(substr(_utf16 0x00e400e5D800DC00,1)) +00E400E5D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,2)); +hex(substr(_utf16 0x00e400e5D800DC00,2)) +00E5D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,3)); +hex(substr(_utf16 0x00e400e5D800DC00,3)) +D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,-1)); +hex(substr(_utf16 0x00e400e5D800DC00,-1)) +D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,-2)); +hex(substr(_utf16 0x00e400e5D800DC00,-2)) +00E5D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,-3)); +hex(substr(_utf16 0x00e400e5D800DC00,-3)) +00E400E5D800DC00 +SET NAMES latin1; +create table t1 (utext varchar(20) character set utf16); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +CREATE TABLE t1 ( +status enum('active','passive') character set utf16 collate utf16_general_ci +NOT NULL default 'passive' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL DEFAULT 'passive' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL DEFAULT 'passive', + `a` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a varchar(64) character set utf16, b decimal(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +update t1 set b=a; +SELECT *, hex(a) FROM t1; +a b hex(a) +1.1 1.100 0031002E0031 +2.1 2.100 0032002E0031 +DROP TABLE t1; +create table t1 (utext varchar(20) character set utf16); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +set names latin1; +set character_set_connection=utf16; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb') + H000 H4142 I51231 +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +hex(soundex('')) hex(soundex('he')) hex(soundex('hello all folks')) hex(soundex('#3556 in bugdb')) + 0048003000300030 00480034003100340032 004900350031003200330031 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select hex(soundex(_utf16 0x041004110412)); +hex(soundex(_utf16 0x041004110412)) +0410003000300030 +select hex(soundex(_utf16 0x00BF00C0)); +hex(soundex(_utf16 0x00BF00C0)) +00C0003000300030 +set names latin1; +create table t1(a blob, b text charset utf16); +select data_type, character_octet_length, character_maximum_length +from information_schema.columns where table_name='t1'; +DATA_TYPE CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH +blob 65535 65535 +text 65535 32767 +drop table t1; +set names latin1; +set collation_connection=utf16_general_ci; +select position('bb' in 'abba'); +position('bb' in 'abba') +2 +create table t1 (a varchar(10) character set utf16) engine=heap; +insert into t1 values ('a'),('A'),('b'),('B'); +select * from t1 where a='a' order by binary a; +a +A +a +select hex(min(binary a)),count(*) from t1 group by a; +hex(min(binary a)) count(*) +0041 2 +0042 2 +drop table t1; +select char_length('abcd'), octet_length('abcd'); +char_length('abcd') octet_length('abcd') +4 8 +select char_length(_utf16 0xD800DC00), octet_length(_utf16 0xD800DC00); +char_length(_utf16 0xD800DC00) octet_length(_utf16 0xD800DC00) +1 4 +select char_length(_utf16 0xD87FDFFF), octet_length(_utf16 0xD87FDFFF); +char_length(_utf16 0xD87FDFFF) octet_length(_utf16 0xD87FDFFF) +1 4 +select left('abcd',2); +left('abcd',2) +ab +select hex(left(_utf16 0xD800DC00D87FDFFF, 1)); +hex(left(_utf16 0xD800DC00D87FDFFF, 1)) +D800DC00 +select hex(right(_utf16 0xD800DC00D87FDFFF, 1)); +hex(right(_utf16 0xD800DC00D87FDFFF, 1)) +D87FDFFF +create table t1 (a varchar(10) character set utf16); +insert into t1 values (_utf16 0xD800); +ERROR HY000: Invalid utf16 character string: 'D800' +insert into t1 values (_utf16 0xDC00); +ERROR HY000: Invalid utf16 character string: 'DC00' +insert into t1 values (_utf16 0xD800D800); +ERROR HY000: Invalid utf16 character string: 'D800D8' +insert into t1 values (_utf16 0xD800E800); +ERROR HY000: Invalid utf16 character string: 'D800E8' +insert into t1 values (_utf16 0xD8000800); +ERROR HY000: Invalid utf16 character string: 'D80008' +insert into t1 values (_utf16 0xD800DC00); +insert into t1 values (_utf16 0xD800DCFF); +insert into t1 values (_utf16 0xDBFFDC00); +insert into t1 values (_utf16 0xDBFFDCFF); +select hex(a) from t1; +hex(a) +D800DC00 +D800DCFF +DBFFDC00 +DBFFDCFF +drop table t1; +SET sql_mode = ''; +create table t1 (s1 varchar(50) character set ucs2); +insert into t1 values (0xdf84); +alter table t1 modify column s1 varchar(50) character set utf16; +Warnings: +Warning 1366 Incorrect string value: '\xDF\x84' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +003F +drop table t1; +SET sql_mode = default; +create table t1 (s1 varchar(5) character set ucs2, s2 varchar(5) character set utf16); +insert into t1 (s1) values (0xdf84); +update ignore t1 set s2 = s1; +Warnings: +Warning 1366 Incorrect string value: '\xDF\x84' for column 's2' at row 1 +select hex(s2) from t1; +hex(s2) +003F +drop table t1; +create table t1 (a char(10)) character set utf16; +insert into t1 values ('a '); +select hex(a) from t1; +hex(a) +0061 +drop table t1; +select upper('abcd'), lower('ABCD'); +upper('abcd') lower('ABCD') +ABCD abcd +create table t1 (a varchar(10) character set utf16); +insert into t1 values (123456); +select a, hex(a) from t1; +a hex(a) +123456 003100320033003400350036 +drop table t1; +select hex(soundex('a')); +hex(soundex('a')) +0041003000300030 +create table t1 (a enum ('a','b','c')) character set utf16; +insert into t1 values ('1'); +select * from t1; +a +a +drop table t1; +set names latin1; +select hex(conv(convert('123' using utf16), -10, 16)); +hex(conv(convert('123' using utf16), -10, 16)) +3742 +select hex(conv(convert('123' using utf16), 10, 16)); +hex(conv(convert('123' using utf16), 10, 16)) +3742 +set names latin1; +set character_set_connection=utf16; +select 1.1 + '1.2'; +1.1 + '1.2' +2.3 +select 1.1 + '1.2xxx'; +1.1 + '1.2xxx' +2.3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1.2xxx' +select left('aaa','1'); +left('aaa','1') +a +create table t1 (a int); +insert into t1 values ('-1234.1e2'); +insert ignore into t1 values ('-1234.1e2xxxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +insert into t1 values ('-1234.1e2 '); +select * from t1; +a +-123410 +-123410 +-123410 +drop table t1; +create table t1 (a int); +insert into t1 values ('1 '); +insert ignore into t1 values ('1 x'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +1 +1 +drop table t1; +SET sql_mode = ''; +create table t1 (a varchar(17000) character set utf16); +Warnings: +Note 1246 Converting column 'a' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext CHARACTER SET utf16 COLLATE utf16_general_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = default; +create table t1 (a varchar(150) character set utf16 primary key); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(150) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a varchar(334) character set utf16 primary key) ROW_FORMAT=COMPACT; +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table t1 (a char(1) character set utf16); +insert into t1 values (0xD800DC00),(0xD800DCFF),(0xDB7FDC00),(0xDB7FDCFF); +insert into t1 values (0x00C0), (0x00FF),(0xE000), (0xFFFF); +select hex(a), hex(@a:=convert(a using utf8mb4)), hex(convert(@a using utf16)) from t1; +hex(a) hex(@a:=convert(a using utf8mb4)) hex(convert(@a using utf16)) +00C0 C380 00C0 +00FF C3BF 00FF +D800DC00 F0908080 D800DC00 +D800DCFF F09083BF D800DCFF +DB7FDC00 F3AFB080 DB7FDC00 +DB7FDCFF F3AFB3BF DB7FDCFF +E000 EE8080 E000 +FFFF EFBFBF FFFF +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warnings: +drop table t1; +set collation_connection=utf16_general_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf16 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf16 DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +set names latin1; +SET collation_connection=utf16_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +s1 hex(s1) +2008-07-18 0032003000300038002D00300037002D00310038 +08:42:04 00300038003A00340032003A00300034 +2008-07-18 08:42:04 0032003000300038002D00300037002D00310038002000300038003A00340032003A00300034 +DROP TABLE t1; +SET timestamp=0; +SET NAMES latin1; +SET collation_connection=utf16_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(2) CHARACTER SET utf16 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE'); +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +SET max_sort_length=4; +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +DROP TABLE t1; +SET max_sort_length=DEFAULT; +SET NAMES latin1; +# +# Bug#52520 Difference in tinytext utf column metadata +# +CREATE TABLE t1 ( +s1 TINYTEXT CHARACTER SET utf16, +s2 TEXT CHARACTER SET utf16, +s3 MEDIUMTEXT CHARACTER SET utf16, +s4 LONGTEXT CHARACTER SET utf16 +); +SET NAMES utf8, @@character_set_results=NULL; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 255 0 Y 16 0 54 +def test t1 t1 s2 s2 252 65535 0 Y 16 0 54 +def test t1 t1 s3 s3 252 16777215 0 Y 16 0 54 +def test t1 t1 s4 s4 252 4294967295 0 Y 16 0 54 +def HEX(s1) 253 6120 0 Y 0 31 33 +s1 s2 s3 s4 HEX(s1) +SET NAMES latin1; +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 127 0 Y 16 0 8 +def test t1 t1 s2 s2 252 32767 0 Y 16 0 8 +def test t1 t1 s3 s3 252 8388607 0 Y 16 0 8 +def test t1 t1 s4 s4 252 2147483647 0 Y 16 0 8 +def HEX(s1) 253 2040 0 Y 0 31 8 +s1 s2 s3 s4 HEX(s1) +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 381 0 Y 16 0 33 +def test t1 t1 s2 s2 252 98301 0 Y 16 0 33 +def test t1 t1 s3 s3 252 25165821 0 Y 16 0 33 +def test t1 t1 s4 s4 252 4294967295 0 Y 16 0 33 +def HEX(s1) 253 6120 0 Y 0 31 33 +s1 s2 s3 s4 HEX(s1) +CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CONCAT(s1)` varchar(255) CHARACTER SET utf16 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Bug#11753363 (Bug#44793) Character sets: case clause, ucs2 or utf32, failure +# +SELECT CASE _latin1'a' WHEN _utf16'a' THEN 'A' END; +CASE _latin1'a' WHEN _utf16'a' THEN 'A' END +A +SELECT CASE _utf16'a' WHEN _latin1'a' THEN 'A' END; +CASE _utf16'a' WHEN _latin1'a' THEN 'A' END +A +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf16); +INSERT INTO t1 VALUES ('a'); +SELECT CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END FROM t1; +CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END +b +DROP TABLE t1; +# +# Bug#12340997 +# DATE_ADD/DATE_SUB WITH INTERVAL CRASHES IN GET_INTERVAL_VALUE() +# +SELECT space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)); +space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)) +NULL +Warnings: +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +# +# Bug#11750518 41090: ORDER BY TRUNCATES GROUP_CONCAT RESULT +# +SET NAMES utf8, @@character_set_connection=utf16; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l +FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body +UNION ALL +SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1 +GROUP BY id +ORDER BY l DESC; +id l +a 512 +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#3664 WEIGHT_STRING +# +set collation_connection=utf16_general_ci; +select @@collation_connection; +@@collation_connection +utf16_general_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0041 +select hex(weight_string('A')); +hex(weight_string('A')) +0041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +004100420043 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +00410042 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +004100420043 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +00410042004300200020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0041 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +004100 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00410042002000200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0041 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +004100 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00410042004300200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0041 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +004100 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00410042004300200020002000200020002000200020002000 +select @@collation_connection; +@@collation_connection +utf16_general_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +20AC20AC20AC00200020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +20AC20AC00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +20AC20AC002000200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(_utf16 0xD800DC00)); +hex(weight_string(_utf16 0xD800DC00)) +FFFD +select hex(weight_string(_utf16 0xD800DC01)); +hex(weight_string(_utf16 0xD800DC01)) +FFFD +set collation_connection=utf16_bin; +select @@collation_connection; +@@collation_connection +utf16_bin +select hex(weight_string('a')); +hex(weight_string('a')) +000061 +select hex(weight_string('A')); +hex(weight_string('A')) +000041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +000061000062000063 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +000061000062 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +000061000062000063 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +000061000062000063000020000020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0000 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +000061 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00006100006200002000002000002000002000002000002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0000 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +000061 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00006100006200006300002000002000002000002000002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0000 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +000061 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00006100006200006300002000002000002000002000002000 +select @@collation_connection; +@@collation_connection +utf16_bin +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0020AC0020AC0020AC000020000020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0020AC0020AC00002000002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +# +# End of 5.6 tests +# diff --git a/mysql-test/r/ctype_utf16_uca.result-pq b/mysql-test/r/ctype_utf16_uca.result-pq new file mode 100644 index 000000000..81db27e59 --- /dev/null +++ b/mysql-test/r/ctype_utf16_uca.result-pq @@ -0,0 +1,3597 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 5.5 tests +# +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +set collation_connection=utf16_unicode_ci; +select hex('a'), hex('a '); +hex('a') hex('a ') +0061 00610020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +1 0 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +1 0 0 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +1 0 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +1 0 0 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 0 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select 'c' like '\_' as want0; +want0 +0 +create table t1 (c1 char(10) character set utf16 collate utf16_bin); +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); +INSERT INTO t1 VALUES (_ucs2 0x1EA0),(_ucs2 0x1EA1),(_ucs2 0x1EA2),(_ucs2 0x1EA3); +INSERT INTO t1 VALUES (_ucs2 0x1EA4),(_ucs2 0x1EA5),(_ucs2 0x1EA6),(_ucs2 0x1EA7); +INSERT INTO t1 VALUES (_ucs2 0x1EA8),(_ucs2 0x1EA9),(_ucs2 0x1EAA),(_ucs2 0x1EAB); +INSERT INTO t1 VALUES (_ucs2 0x1EAC),(_ucs2 0x1EAD),(_ucs2 0x1EAE),(_ucs2 0x1EAF); +INSERT INTO t1 VALUES (_ucs2 0x1EB0),(_ucs2 0x1EB1),(_ucs2 0x1EB2),(_ucs2 0x1EB3); +INSERT INTO t1 VALUES (_ucs2 0x1EB4),(_ucs2 0x1EB5),(_ucs2 0x1EB6),(_ucs2 0x1EB7); +INSERT INTO t1 VALUES (_ucs2 0x1EB8),(_ucs2 0x1EB9),(_ucs2 0x1EBA),(_ucs2 0x1EBB); +INSERT INTO t1 VALUES (_ucs2 0x1EBC),(_ucs2 0x1EBD),(_ucs2 0x1EBE),(_ucs2 0x1EBF); +INSERT INTO t1 VALUES (_ucs2 0x1EC0),(_ucs2 0x1EC1),(_ucs2 0x1EC2),(_ucs2 0x1EC3); +INSERT INTO t1 VALUES (_ucs2 0x1EC4),(_ucs2 0x1EC5),(_ucs2 0x1EC6),(_ucs2 0x1EC7); +INSERT INTO t1 VALUES (_ucs2 0x1EC8),(_ucs2 0x1EC9),(_ucs2 0x1ECA),(_ucs2 0x1ECB); +INSERT INTO t1 VALUES (_ucs2 0x1ECC),(_ucs2 0x1ECD),(_ucs2 0x1ECE),(_ucs2 0x1ECF); +INSERT INTO t1 VALUES (_ucs2 0x1ED0),(_ucs2 0x1ED1),(_ucs2 0x1ED2),(_ucs2 0x1ED3); +INSERT INTO t1 VALUES (_ucs2 0x1ED4),(_ucs2 0x1ED5),(_ucs2 0x1ED6),(_ucs2 0x1ED7); +INSERT INTO t1 VALUES (_ucs2 0x1ED8),(_ucs2 0x1ED9),(_ucs2 0x1EDA),(_ucs2 0x1EDB); +INSERT INTO t1 VALUES (_ucs2 0x1EDC),(_ucs2 0x1EDD),(_ucs2 0x1EDE),(_ucs2 0x1EDF); +INSERT INTO t1 VALUES (_ucs2 0x1EE0),(_ucs2 0x1EE1),(_ucs2 0x1EE2),(_ucs2 0x1EE3); +INSERT INTO t1 VALUES (_ucs2 0x1EE4),(_ucs2 0x1EE5),(_ucs2 0x1EE6),(_ucs2 0x1EE7); +INSERT INTO t1 VALUES (_ucs2 0x1EE8),(_ucs2 0x1EE9),(_ucs2 0x1EEA),(_ucs2 0x1EEB); +INSERT INTO t1 VALUES (_ucs2 0x1EEC),(_ucs2 0x1EED),(_ucs2 0x1EEE),(_ucs2 0x1EEF); +INSERT INTO t1 VALUES (_ucs2 0x1EF0),(_ucs2 0x1EF1); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('AE'),('Ae'),('ae'),('aE'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_unicode_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_icelandic_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÂÃàâãĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Áá +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Ðð +Đđ +Ɖ +Ɗ +Ƌƌ +EeÈÊËèêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Éé +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÎÏìîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +Íí +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÔÕòôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Óó +Ǿǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÛÜùûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Úú +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÿŶŷŸ +Ýý +Ƴƴ +ZzŹźŻżŽž +ƍ +Þþ +ÄÆäæ +ÖØöø +Åå +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_latvian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +CHChcHch +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġǦǧǴǵ +Ģģ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +Yy +ı +Ɨ +Ɩ +JjĴĵǰ +KkǨǩ +Ķķ +Ƙƙ +LlĹ弾 +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Ļļ +Łł +ƚ +ƛ +Mm +NnÑñŃńŇňǸǹ +NJNjnJnjNJNjnj +Ņņ +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŘř +RRRrrRrr +Ŗŗ +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_romanian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÃÄÅàáãäåĀāĄąǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Ăă +Ââ +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÏìíïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +Îî +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssß +Şş +Ʃ +ƪ +TtŤť +ƾ +Ţţ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovenian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +CHChcHch +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_polish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂăǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Ąą +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĈĉĊċČč +CHChcHch +Ćć +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ęę +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŅņŇňǸǹ +NJNjnJnjNJNjnj +Ńń +Ɲ +ƞ +Ŋŋ +OoÒÔÕÖòôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Óó +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŜŝŞşŠšſ +SSSssSssß +Śś +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŽž +ƍ +Źź +Żż +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_estonian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÅàáâãåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzdZdz +DŽDždŽdž +DŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔòóôŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Zz +Žž +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Õõ +Ää +Öö +Üü +Xx +YyÝýÿŶŷŸ +Ƴƴ +ŹźŻż +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ññ +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_swedish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃàáâãĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ǿǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Åå +ÄÆäæ +ÖØöø +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_turkish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcĆćĈĉĊċČč +CHChcHch +Çç +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĠġĢģǦǧǴǵ +Ğğ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +Iı +IJIj +ƕǶ +Ħħ +iÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +iJijIJij +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Öö +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssß +Şş +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Üü +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_czech_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +cH +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗ +RRRrrRrr +Řř +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_danish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃàáâãĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +aA +AEAeaEae +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ǿǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŰűŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +ÄÆäæ +ÖØöøŐő +AAAaaaÅå +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_lithuanian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CCHChcchÇçĆćĈĉĊċ +cH +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IYiyÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovak_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÅàáâãåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Ää +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +cH +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÕÖòóõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ôô +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish2_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +cH +CHChch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +lL +LLLlll +Łł +ƚ +ƛ +Mm +NnŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ññ +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_roman_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IJijÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJij +IJij +ı +Ɨ +Ɩ +Ĵĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJlj +LJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnj +NJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +ÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +UVuv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_esperanto_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĊċČč +CHChcHch +Ĉĉ +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĞğĠġĢģǦǧǴǵ +Ĝĝ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +Hh +Ĥĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +Jjǰ +Ĵĵ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŞşŠšſ +SSSssSssß +Ŝŝ +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ŭŭ +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_hungarian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ÖöŐő +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +ÜüŰű +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_croatian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĈĉĊċ +CHChcHch +Čč +Ćć +Ƈƈ +DdĎď +DZDzdZdzDZDzdz +DŽDždŽdžDŽDždž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LLLllLll +LJLjlJljLJLjlj +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_german2_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÅàáâãåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEaeÄÆäæ +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeÖöŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Üü +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_unicode_520_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEaeÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdÐðĎďĐđ +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Ɖ +Ɗ +Ƌƌ +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥĦħ +ƕǶ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľĿŀŁł +LJLjlJljLJLjlj +LLLllLll +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖØòóôõöøŌōŎŏŐőƠơǑǒǪǫǬǭǾǿỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_vietnamese_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÃÄÅàáãäåĀāĄąǍǎǞǟǠǡǺǻẠạẢả +AAAaaAaa +AEAeaEae +ĂăẮắẰằẲẳẴẵẶặ +ÂâẤấẦầẨẩẪẫẬậ +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉËèéëĒēĔĕĖėĘęĚěẸẹẺẻẼẽ +ÊêẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÕÖòóõöŌōŎŏŐőǑǒǪǫǬǭỌọỎỏ +OEOeoEoeŒœ +ÔôỐốỒồỔổỖỗỘộ +ƠơỚớỜờỞởỠỡỢợ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųǓǔǕǖǗǘǙǚǛǜỤụỦủ +ƯưỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +drop table t1; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (c varchar(150) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_general_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_general_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +CREATE TABLE t1 (c varchar(150) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +CREATE TABLE t1 (c varchar(150) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET @test_character_set='utf16'; +SET @test_collation='utf16_swedish_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) utf16_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) utf16_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) COLLATE utf16_swedish_ci DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_swedish_ci +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +SET character_set_results= @safe_character_set_results; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +SET collation_connection='utf16_unicode_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16_unicode_ci 00610009 +utf16_unicode_ci 0061 +utf16_unicode_ci 00610020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf16_unicode_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (id int, a varchar(30) character set utf16); +INSERT INTO t1 VALUES (1, 0x01310069), (2, 0x01310131); +INSERT INTO t1 VALUES (3, 0x00690069), (4, 0x01300049); +INSERT INTO t1 VALUES (5, 0x01300130), (6, 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 4 ıi 4 II 4 +ıı 4 ıı 4 II 4 +ii 4 ii 4 II 4 +İI 4 ii 4 İI 4 +İİ 4 ii 4 İİ 4 +II 4 ii 4 II 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf16 collate utf16_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 4 ıi 4 Iİ 4 +ıı 4 ıı 4 II 4 +ii 4 ii 4 İİ 4 +İI 4 iı 4 İI 4 +İİ 4 ii 4 İİ 4 +II 4 ıı 4 II 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +set collation_connection=utf16_unicode_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf16 COLLATE utf16_unicode_ci DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf16 COLLATE utf16_unicode_ci DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +SET collation_connection=utf16_czech_ci; +SELECT @@collation_connection; +@@collation_connection +utf16_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch'); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1)); +SELECT * FROM t1 WHERE s1 LIKE 'ch'; +s1 +ch +DROP TABLE t1; +SELECT @@collation_connection; +@@collation_connection +utf16_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# Part#2 - ignorable characters +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e'); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +0061000000000000000000000009 +0061 +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +0061000000000000000000000009 +0061 +DROP TABLE t1; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#3664 WEIGHT_STRING +# +set collation_connection=utf16_unicode_ci; +select @@collation_connection; +@@collation_connection +utf16_unicode_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0E33 +select hex(weight_string('A')); +hex(weight_string('A')) +0E33 +select hex(weight_string('abc')); +hex(weight_string('abc')) +0E330E4A0E60 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +0E330E4A +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +0E330E4A0E60 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +0E330E4A0E6002090209 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +0E +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0E330E4A02 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +0E330E4A020902090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +0E +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +0E +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select @@collation_connection; +@@collation_connection +utf16_unicode_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0E230E230E2302090209 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0E230E2302 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0E230E23020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +select hex(weight_string(_utf16 0xD800DC00 collate utf16_unicode_ci)); +hex(weight_string(_utf16 0xD800DC00 collate utf16_unicode_ci)) +FFFD +select hex(weight_string(_utf16 0xD800DC01 collate utf16_unicode_ci)); +hex(weight_string(_utf16 0xD800DC01 collate utf16_unicode_ci)) +FFFD +set @@collation_connection=utf16_czech_ci; +select @@collation_connection; +@@collation_connection +utf16_czech_ci +select collation(cast(_latin1 0xDF as char)); +collation(cast(_latin1 0xDF as char)) +utf16_czech_ci +select hex(weight_string('s')); +hex(weight_string('s')) +0FEA +select hex(weight_string(cast(_latin1 0xDF as char))); +hex(weight_string(cast(_latin1 0xDF as char))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF as char) as char(1))) +0FEA0FEA +select hex(weight_string('c')); +hex(weight_string('c')) +0E60 +select hex(weight_string('h')); +hex(weight_string('h')) +0EE1 +select hex(weight_string('ch')); +hex(weight_string('ch')) +0EE2 +select hex(weight_string('i')); +hex(weight_string('i')) +0EFB +select hex(weight_string(cast(_latin1 0x6368DF as char))); +hex(weight_string(cast(_latin1 0x6368DF as char))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))) +0E60 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))) +0EE20FEA0FEA0209 +select hex(weight_string(cast(_latin1 0xDF6368 as char))); +hex(weight_string(cast(_latin1 0xDF6368 as char))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))) +0FEA0FEA0E60 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))) +0FEA0FEA0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)) +0EE202 +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)) +0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)) +0EE20209020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)) +0FEA0FEA0E6002090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET collation_connection=utf16_german2_ci; +"BEGIN ctype_german.inc" +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf16_german2_ci +delete from t1; +INSERT INTO t1 VALUES ('ud'),('uf'); +INSERT INTO t1 VALUES ('od'),('of'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('ad'),('af'); +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6); +INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 0061 +ad 00610064 +ae 00610065 +Æ 00C6 +ä 00E4 +æ 00E6 +af 00610066 +e 0065 +o 006F +od 006F0064 +oe 006F0065 +ö 00F6 +Œ 0152 +œ 0153 +of 006F0066 +s 0073 +ss 00730073 +ß 00DF +u 0075 +ud 00750064 +ue 00750065 +ü 00FC +uf 00750066 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a +ad +ae,Æ,ä,æ +af +e +o +od +oe,ö,Œ,œ +of +s +ss,ß +u +ud +ue,ü +uf +SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1); +s1 hex(s1) hex(weight_string(s1)) +a 0061 0E33 +ad 00610064 0E330E6D +ae 00610065 0E330E8B +Æ 00C6 0E330E8B +ä 00E4 0E330E8B +æ 00E6 0E330E8B +af 00610066 0E330EB9 +e 0065 0E8B +o 006F 0F82 +od 006F0064 0F820E6D +oe 006F0065 0F820E8B +ö 00F6 0F820E8B +Œ 0152 0F820E8B +œ 0153 0F820E8B +of 006F0066 0F820EB9 +s 0073 0FEA +ss 00730073 0FEA0FEA +ß 00DF 0FEA0FEA +u 0075 101F +ud 00750064 101F0E6D +ue 00750065 101F0E8B +ü 00FC 101F0E8B +uf 00750066 101F0EB9 +SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1); +s1 hex(s1) +ae 00610065 +Æ 00C6 +ä 00E4 +æ 00E6 +drop table t1; +"END ctype_german.inc" +# +# WL#2673 Unicode Collation Algorithm new version +# +SET NAMES utf8mb4; +SET collation_connection=utf16_unicode_520_ci; +CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) CHARACTER SET utf16 COLLATE utf16_unicode_520_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A); +INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C); +INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E); +INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242); +INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244); +INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246); +INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248); +INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A); +INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C); +INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E); +INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B); +INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289); +INSERT INTO t1 VALUES (_utf32 0x028C); +INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C); +INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD); +INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF); +INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF); +INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7); +INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB); +INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD); +INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF); +INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511); +INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513); +INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1); +INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3); +INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5); +INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7); +INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01); +INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03); +INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05); +INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07); +INSERT INTO t1 VALUES (_utf32 0x1D7D); +INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E); +INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184); +INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81); +INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83); +INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85); +INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87); +INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89); +INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B); +INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D); +INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F); +INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61); +INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63); +INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65); +INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67); +INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69); +INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B); +INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75); +INSERT INTO t1 VALUES (_utf32 0x2C76); +INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01); +INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03); +INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05); +INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07); +INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31); +INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33); +INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35); +INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37); +INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401); +INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403); +INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405); +INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407); +INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429); +INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B); +INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D); +INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F); +INSERT INTO t1 VALUES (_utf32 0x0370); +INSERT INTO t1 VALUES (_utf32 0x0371); +INSERT INTO t1 VALUES (_utf32 0x0372); +INSERT INTO t1 VALUES (_utf32 0x0373); +INSERT INTO t1 VALUES (_utf32 0x0514); +INSERT INTO t1 VALUES (_utf32 0x0515); +INSERT INTO t1 VALUES (_utf32 0x0516); +INSERT INTO t1 VALUES (_utf32 0x0517); +INSERT INTO t1 VALUES (_utf32 0xA640); +INSERT INTO t1 VALUES (_utf32 0xA641); +INSERT INTO t1 VALUES (_utf32 0xA642); +INSERT INTO t1 VALUES (_utf32 0xA643); +INSERT INTO t1 VALUES (_utf32 0xA722); +INSERT INTO t1 VALUES (_utf32 0xA723); +INSERT INTO t1 VALUES (_utf32 0xA724); +INSERT INTO t1 VALUES (_utf32 0xA725); +INSERT INTO t1 VALUES (_utf32 0xA726); +INSERT INTO t1 VALUES (_utf32 0xA727); +INSERT INTO t1 VALUES (_utf32 0xA728); +INSERT INTO t1 VALUES (_utf32 0xA729); +INSERT INTO t1 VALUES (_utf32 0xA72A); +INSERT INTO t1 VALUES (_utf32 0xA72B); +INSERT INTO t1 VALUES (_utf32 0x2CEB); +INSERT INTO t1 VALUES (_utf32 0x2CEC); +INSERT INTO t1 VALUES (_utf32 0x2CED); +INSERT INTO t1 VALUES (_utf32 0x2CEE); +SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c +FROM t1 ORDER BY c, BINARY c; +hex(c) hex(lower(c)) hex(upper(c)) hex(weight_string(c)) c +023A 2C65 023A 1214 Ⱥ +2C65 2C65 023A 1214 ⱥ +0180 0180 0243 122D ƀ +0243 0180 0243 122D Ƀ +023B 023C 023B 1242 Ȼ +023C 023C 023B 1242 ȼ +2183 2184 2183 124E Ↄ +2184 2184 2183 124E ↄ +0246 0247 0246 1270 Ɇ +0247 0247 0246 1270 ɇ +2132 214E 2132 12AE Ⅎ +214E 214E 2132 12AE ⅎ +2C67 2C68 2C67 12E3 Ⱨ +2C68 2C68 2C67 12E3 ⱨ +2C75 2C76 2C75 12E4 Ⱶ +2C76 2C76 2C75 12E4 ⱶ +A726 A727 A726 12E5 Ꜧ +A727 A727 A726 12E5 ꜧ +0248 0249 0248 130E Ɉ +0249 0249 0248 130E ɉ +2C69 2C6A 2C69 1328 Ⱪ +2C6A 2C6A 2C69 1328 ⱪ +023D 019A 023D 133B Ƚ +2C60 2C61 2C60 133F Ⱡ +2C61 2C61 2C60 133F ⱡ +026B 026B 2C62 1340 ɫ +2C62 026B 2C62 1340 Ɫ +1D7D 1D7D 2C63 13B8 ᵽ +2C63 1D7D 2C63 13B8 Ᵽ +024A 024B 024A 13D2 Ɋ +024B 024B 024A 13D2 ɋ +024C 024D 024C 13E4 Ɍ +024D 024D 024C 13E4 ɍ +027D 027D 2C64 13FC ɽ +2C64 027D 2C64 13FC Ɽ +A728 A729 A728 143314AD Ꜩ +A729 A729 A728 143314AD ꜩ +023E 2C66 023E 143C Ⱦ +2C66 2C66 023E 143C ⱦ +0244 0289 0244 145B Ʉ +0289 0289 0244 145B ʉ +0245 028C 0245 1489 Ʌ +028C 028C 0245 1489 ʌ +024E 024F 024E 14A4 Ɏ +024F 024F 024E 14A4 ɏ +2C6B 2C6C 2C6B 14C8 Ⱬ +2C6C 2C6C 2C6B 14C8 ⱬ +A72A A72B A72A 14F3 Ꜫ +A72B A72B A72A 14F3 ꜫ +0241 0242 0241 1506 Ɂ +0242 0242 0241 1506 ɂ +A722 A723 A722 150E Ꜣ +A723 A723 A722 150E ꜣ +A724 A725 A724 1518 Ꜥ +A725 A725 A724 1518 ꜥ +0370 0371 0370 154F Ͱ +0371 0371 0370 154F ͱ +037C 037C 03FE 1564 ͼ +03FE 037C 03FE 1564 Ͼ +037B 037B 03FD 1565 ͻ +03FD 037B 03FD 1565 Ͻ +037D 037D 03FF 1566 ͽ +03FF 037D 03FF 1566 Ͽ +0372 0373 0372 156F Ͳ +0373 0373 0372 156F ͳ +2C80 2C81 2C80 1571 Ⲁ +2C81 2C81 2C80 1571 ⲁ +2C82 2C83 2C82 1572 Ⲃ +2C83 2C83 2C82 1572 ⲃ +2C84 2C85 2C84 1573 Ⲅ +2C85 2C85 2C84 1573 ⲅ +2C86 2C87 2C86 1574 Ⲇ +2C87 2C87 2C86 1574 ⲇ +2C88 2C89 2C88 1575 Ⲉ +2C89 2C89 2C88 1575 ⲉ +2C8A 2C8B 2C8A 1577 Ⲋ +2C8B 2C8B 2C8A 1577 ⲋ +2C8C 2C8D 2C8C 1578 Ⲍ +2C8D 2C8D 2C8C 1578 ⲍ +2C8E 2C8F 2C8E 1579 Ⲏ +2C8F 2C8F 2C8E 1579 ⲏ +2CEB 2CEC 2CEB 1591 Ⳬ +2CEC 2CEC 2CEB 1591 ⳬ +2CED 2CEE 2CED 15A0 Ⳮ +2CEE 2CEE 2CED 15A0 ⳮ +04FA 04FB 04FA 15D4 Ӻ +04FB 04FB 04FA 15D4 ӻ +04F6 04F7 04F6 15DC Ӷ +04F7 04F7 04F6 15DC ӷ +A640 A641 A640 1611 Ꙁ +A641 A641 A640 1611 ꙁ +0510 0511 0510 1613 Ԑ +0511 0511 0510 1613 ԑ +A642 A643 A642 1618 Ꙃ +A643 A643 A642 1618 ꙃ +0512 0513 0512 1666 Ԓ +0513 0513 0512 1666 ԓ +0514 0515 0514 166E Ԕ +0515 0515 0514 166E ԕ +0516 0517 0516 16B7 Ԗ +0517 0517 0516 16B7 ԗ +04FC 04FD 04FC 16F9 Ӽ +04FD 04FD 04FC 16F9 ӽ +04FE 04FF 04FE 16FD Ӿ +04FF 04FF 04FE 16FD ӿ +04C0 04CF 04C0 17B1 Ӏ +04CF 04CF 04C0 17B1 ӏ +2C00 2C30 2C00 17B5 Ⰰ +2C30 2C30 2C00 17B5 ⰰ +2C01 2C31 2C01 17B6 Ⰱ +2C31 2C31 2C01 17B6 ⰱ +2C02 2C32 2C02 17B7 Ⰲ +2C32 2C32 2C02 17B7 ⰲ +2C03 2C33 2C03 17B8 Ⰳ +2C33 2C33 2C03 17B8 ⰳ +2C04 2C34 2C04 17B9 Ⰴ +2C34 2C34 2C04 17B9 ⰴ +2C05 2C35 2C05 17BA Ⰵ +2C35 2C35 2C05 17BA ⰵ +2C06 2C36 2C06 17BB Ⰶ +2C36 2C36 2C06 17BB ⰶ +2C07 2C37 2C07 17BC Ⰷ +2C37 2C37 2C07 17BC ⰷ +10A0 2D00 10A0 17E5 Ⴀ +2D00 2D00 10A0 17E5 ⴀ +10A1 2D01 10A1 17E7 Ⴁ +2D01 2D01 10A1 17E7 ⴁ +10A2 2D02 10A2 17E9 Ⴂ +2D02 2D02 10A2 17E9 ⴂ +10A3 2D03 10A3 17EB Ⴃ +2D03 2D03 10A3 17EB ⴃ +10A4 2D04 10A4 17ED Ⴄ +2D04 2D04 10A4 17ED ⴄ +10A5 2D05 10A5 17EF Ⴅ +2D05 2D05 10A5 17EF ⴅ +10A6 2D06 10A6 17F1 Ⴆ +2D06 2D06 10A6 17F1 ⴆ +10A7 2D07 10A7 17F5 Ⴇ +2D07 2D07 10A7 17F5 ⴇ +D801DC00 D801DC28 D801DC00 30D2 𐐀 +D801DC28 D801DC28 D801DC00 30D2 𐐨 +D801DC01 D801DC29 D801DC01 30D3 𐐁 +D801DC29 D801DC29 D801DC01 30D3 𐐩 +D801DC02 D801DC2A D801DC02 30D4 𐐂 +D801DC2A D801DC2A D801DC02 30D4 𐐪 +D801DC03 D801DC2B D801DC03 30D5 𐐃 +D801DC2B D801DC2B D801DC03 30D5 𐐫 +D801DC04 D801DC2C D801DC04 30D6 𐐄 +D801DC2C D801DC2C D801DC04 30D6 𐐬 +D801DC05 D801DC2D D801DC05 30D7 𐐅 +D801DC2D D801DC2D D801DC05 30D7 𐐭 +D801DC06 D801DC2E D801DC06 30D8 𐐆 +D801DC2E D801DC2E D801DC06 30D8 𐐮 +D801DC07 D801DC2F D801DC07 30D9 𐐇 +D801DC2F D801DC2F D801DC07 30D9 𐐯 +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400)); +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +0061 120F +0061D801DC00 120F30D2 +0061FFFF 120FFBC1FFFF +0061DBFFDFFF 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +D801DC00 30D2 𐐀 +D801DC28 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +D801DC00 30D2 𐐀 +D801DC28 30D2 𐐨 +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`c`) AS `hex(c)` from `test`.`t1` where (`test`.`t1`.`c` like 'a%') order by `test`.`t1`.`c` +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +0061 120F +0061D801DC00 120F30D2 +0061FFFF 120FFBC1FFFF +0061DBFFDFFF 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +D801DC00 30D2 𐐀 +D801DC28 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +D801DC00 30D2 𐐀 +D801DC28 30D2 𐐨 +DROP TABLE t1; +# +# End of 5.6 tests +# diff --git a/mysql-test/r/ctype_utf16le.result-pq b/mysql-test/r/ctype_utf16le.result-pq new file mode 100644 index 000000000..d1938024f --- /dev/null +++ b/mysql-test/r/ctype_utf16le.result-pq @@ -0,0 +1,1631 @@ +# +# Start of 5.6 tests +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT HEX('a'), HEX('a '); +HEX('a') HEX('a ') +6100 61002000 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +0 1 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +0 0 1 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +0 1 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +0 0 1 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 1 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +# +# Check that incomplete utf16le characters in HEX notation +# are left-padded with zeros +# +SELECT HEX(_utf16le 0x44); +HEX(_utf16le 0x44) +0044 +SELECT HEX(_utf16le 0x3344); +HEX(_utf16le 0x3344) +3344 +SELECT HEX(_utf16le 0x113344); +HEX(_utf16le 0x113344) +00113344 +# +# Check that 0x20 is only trimmed when it is +# a part of real SPACE character, not just a part +# of a multibyte sequence. +# Note, CYRILLIC LETTER ER is used as an example, which +# is stored as 0x0420 in utf16le, thus contains 0x20 in the +# low byte. The second character is THREE-PER-M, U+2004, +# which contains 0x20 in the high byte. +# +CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf16le; +INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (_ucs2 X'2004',_ucs2 X'2004'); +SELECT HEX(word) FROM t1 ORDER BY word; +HEX(word) +2004 +0420 +SELECT HEX(word2) FROM t1 ORDER BY word2; +HEX(word2) +2004 +0420 +DELETE FROM t1; +# +# Check that real spaces are correctly trimmed. +# +INSERT INTO t1 VALUES (_ucs2 X'042000200020', _ucs2 X'042000200020'); +INSERT INTO t1 VALUES (_ucs2 X'200400200020', _ucs2 X'200400200020'); +SELECT HEX(word) FROM t1 ORDER BY word; +HEX(word) +200420002000 +042020002000 +SELECT HEX(word2) FROM t1 ORDER BY word2; +HEX(word2) +2004 +0420 +DROP TABLE t1; +# +# Check LPAD/RPAD +# +CREATE TABLE t1 (a VARCHAR(10), pad INT, b VARCHAR(10)) CHARACTER SET utf16le; +INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'0421'); +INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'04210422'); +INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'042104220423'); +INSERT IGNORE INTO t1 VALUES (_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (_utf32 X'010000', 10, _ucs2 X'0421'); +INSERT INTO t1 VALUES (_ucs2 X'0421', 10, _utf32 X'010000'); +SELECT a, pad, b, LPAD(a, pad, b), HEX(LPAD(a, pad, b)) FROM t1; +a pad b LPAD(a, pad, b) HEX(LPAD(a, pad, b)) +Р 10 С СССССССССР 2104210421042104210421042104210421042004 +Р 10 СТ СТСТСТСТСР 2104220421042204210422042104220421042004 +Р 10 СТУ СТУСТУСТУР 2104220423042104220423042104220423042004 +РСТУФХЦЧШЩ 10 СТУ РСТУФХЦЧШЩ 2004210422042304240425042604270428042904 +? 10 С ССССССССС? 21042104210421042104210421042104210400D800DC +С 10 ? ?????????С 00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC2104 +DROP TABLE t1; +CREATE TABLE t1 SELECT +LPAD(_utf16le X'2004',10,_utf16le X'2104') l, +RPAD(_utf16le X'2004',10,_utf16le X'2104') r; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `l` varchar(10) CHARACTER SET utf16le DEFAULT NULL, + `r` varchar(10) CHARACTER SET utf16le DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT HEX(l), HEX(r) FROM t1; +HEX(l) HEX(r) +2104210421042104210421042104210421042004 2004210421042104210421042104210421042104 +DROP TABLE t1; +CREATE TABLE t1 (f1 CHAR(30)); +INSERT INTO t1 VALUES ("103000"), ("22720000"), ("3401200"), ("78000"); +SELECT LPAD(f1, 12, "-o-/") FROM t1; +LPAD(f1, 12, "-o-/") +-o-/-o103000 +-o-/22720000 +-o-/-3401200 +-o-/-o-78000 +DROP TABLE t1; +# +# Testing LIKE +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @@collation_connection; +@@collation_connection +utf16le_general_ci +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf16le DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%') +explain select * from t1 where a like concat('abc','%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like (concat('abc','%'))) +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +select 'AA' like 'AA'; +'AA' like 'AA' +1 +select 'AA' like 'A%A'; +'AA' like 'A%A' +1 +select 'AA' like 'A%%A'; +'AA' like 'A%%A' +1 +select 'AA' like 'AA%'; +'AA' like 'AA%' +1 +select 'AA' like '%AA%'; +'AA' like '%AA%' +1 +select 'AA' like '%A'; +'AA' like '%A' +1 +select 'AA' like '%AA'; +'AA' like '%AA' +1 +select 'AA' like 'A%A%'; +'AA' like 'A%A%' +1 +select 'AA' like '_%_%'; +'AA' like '_%_%' +1 +select 'AA' like '%A%A'; +'AA' like '%A%A' +1 +select 'AAA'like 'A%A%A'; +'AAA'like 'A%A%A' +1 +select 'AZ' like 'AZ'; +'AZ' like 'AZ' +1 +select 'AZ' like 'A%Z'; +'AZ' like 'A%Z' +1 +select 'AZ' like 'A%%Z'; +'AZ' like 'A%%Z' +1 +select 'AZ' like 'AZ%'; +'AZ' like 'AZ%' +1 +select 'AZ' like '%AZ%'; +'AZ' like '%AZ%' +1 +select 'AZ' like '%Z'; +'AZ' like '%Z' +1 +select 'AZ' like '%AZ'; +'AZ' like '%AZ' +1 +select 'AZ' like 'A%Z%'; +'AZ' like 'A%Z%' +1 +select 'AZ' like '_%_%'; +'AZ' like '_%_%' +1 +select 'AZ' like '%A%Z'; +'AZ' like '%A%Z' +1 +select 'AZ' like 'A_'; +'AZ' like 'A_' +1 +select 'AZ' like '_Z'; +'AZ' like '_Z' +1 +select 'AMZ'like 'A%M%Z'; +'AMZ'like 'A%M%Z' +1 +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); +INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывА'),('ФЫВА'); +INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж'); +INSERT INTO t1 VALUES ('фывАпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж'); +INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВАПРОЛДЖ'); +SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf16le_bin ORDER BY BINARY a; +a +фЫва +фЫвапролдж +DROP TABLE t1; +CREATE TABLE t1 (word VARCHAR(64) NOT NULL, PRIMARY KEY (word)) +CHARACTER SET utf16le; +INSERT INTO t1 (word) VALUES ("cat"); +SELECT * FROM t1 WHERE word LIKE "c%"; +word +cat +SELECT * FROM t1 WHERE word LIKE "ca_"; +word +cat +SELECT * FROM t1 WHERE word LIKE "cat"; +word +cat +SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025'; +word +cat +SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F'; +word +cat +DROP TABLE t1; +# +# Check that INSERT() works fine. +# This invokes charpos() function. +# +CREATE TABLE t1 ( +a VARCHAR(10) CHARACTER SET utf16le, +b VARCHAR(10) CHARACTER SET utf16le); +INSERT INTO t1 VALUES ('abc', 'def'); +SELECT INSERT(a, 10, 2, b) FROM t1; +INSERT(a, 10, 2, b) +abc +SELECT INSERT(a, 1, 2, b) FROM t1; +INSERT(a, 1, 2, b) +defc +DROP TABLE t1; +# +# Check alignment for from-binary-conversion with CAST and CONVERT +# +SELECT HEX(CAST(0xAA as char CHARACTER SET utf16le)); +HEX(CAST(0xAA as char CHARACTER SET utf16le)) +00AA +SELECT HEX(CONVERT(0xAA USING utf16le)); +HEX(CONVERT(0xAA USING utf16le)) +00AA +# +# Check alignment for string types +# +CREATE TABLE t1 (a CHAR(10) CHARACTER SET utf16le); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a TEXT CHARACTER SET utf16le); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a MEDIUMTEXT CHARACTER SET utf16le); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a LONGTEXT CHARACTER SET utf16le); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +# +# Bug#5081 : UCS2 fields are filled with '0x2020' +# after extending field length +# +CREATE TABLE t1(a CHAR(1)) DEFAULT CHARSET utf16le; +INSERT INTO t1 VALUES ('a'),('b'),('c'); +ALTER TABLE t1 MODIFY a CHAR(5); +SELECT a, HEX(a) FROM t1; +a HEX(a) +a 6100 +b 6200 +c 6300 +DROP TABLE t1; +# +# Check prepare statement from an UTF16 string +# +SET NAMES latin1; +SET @ivar= 1234; +SET @str1 = 'SELECT ?'; +SET @str2 = CONVERT(@str1 USING utf16le); +PREPARE stmt1 FROM @str2; +EXECUTE stmt1 USING @ivar; +? +1234 +# +# Check that utf16le works with ENUM and SET type +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (a ENUM('x','y','z') CHARACTER SET utf16le); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z') CHARACTER SET utf16le COLLATE utf16le_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES ('x'); +INSERT INTO t1 VALUES ('y'); +INSERT INTO t1 VALUES ('z'); +SELECT a, HEX(a) FROM t1 ORDER BY a; +a HEX(a) +x 7800 +y 7900 +z 7A00 +ALTER TABLE t1 CHANGE a a ENUM('x','y','z','d','e','ä','ö','ü') CHARACTER SET utf16le; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z','d','e','ä','ö','ü') CHARACTER SET utf16le COLLATE utf16le_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES ('D'); +INSERT INTO t1 VALUES ('E '); +INSERT INTO t1 VALUES ('ä'); +INSERT INTO t1 VALUES ('ö'); +INSERT INTO t1 VALUES ('ü'); +SELECT a, HEX(a) FROM t1 ORDER BY a; +a HEX(a) +x 7800 +y 7900 +z 7A00 +d 6400 +e 6500 +ä E400 +ö F600 +ü FC00 +DROP TABLE t1; +CREATE TABLE t1 (a set ('x','y','z','ä','ö','ü') CHARACTER SET utf16le); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` set('x','y','z','ä','ö','ü') CHARACTER SET utf16le COLLATE utf16le_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES ('x'); +INSERT INTO t1 VALUES ('y'); +INSERT INTO t1 VALUES ('z'); +INSERT INTO t1 VALUES ('x,y'); +INSERT INTO t1 VALUES ('x,y,z,ä,ö,ü'); +SELECT a, HEX(a) FROM t1 ORDER BY a; +a HEX(a) +x 7800 +y 7900 +x,y 78002C007900 +z 7A00 +x,y,z,ä,ö,ü 78002C0079002C007A002C00E4002C00F6002C00FC00 +DROP TABLE t1; +# +# Bug#7302 UCS2 data in ENUM fields get truncated when new column is added +# +CREATE TABLE t1(a ENUM('a','b','c')) DEFAULT CHARACTER SET utf16le; +INSERT INTO t1 VALUES('a'),('b'),('c'); +ALTER TABLE t1 ADD b CHAR(1); +SHOW WARNINGS; +Level Code Message +SELECT * FROM t1 ORDER BY a; +a b +a NULL +b NULL +c NULL +DROP TABLE t1; +SET NAMES utf8, collation_connection='utf16le_general_ci'; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16le_general_ci 61000900 +utf16le_general_ci 6100 +utf16le_general_ci 61002000 +drop table t1; +select @@collation_connection; +@@collation_connection +utf16le_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +SET NAMES utf8, collation_connection='utf16le_bin'; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16le_bin 61000900 +utf16le_bin 6100 +utf16le_bin 61002000 +drop table t1; +# +# Bug#55980 Character sets: supplementary character _bin ordering is wrong +# +CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16le COLLATE utf16le_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84); +INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +8503 CE85 +9DFF EFBE9D +00D884DF F0908E84 +C0DB00DC F4808080 +ALTER TABLE t1 ADD KEY(a); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +8503 CE85 +9DFF EFBE9D +00D884DF F0908E84 +C0DB00DC F4808080 +# Additional test for bug#37244 Character sets: short utf8_bin weight_string value +SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +HEX(a) HEX(WEIGHT_STRING(a)) +8503 000385 +9DFF 00FF9D +00D884DF 010384 +C0DB00DC 100000 +DROP TABLE IF EXISTS t1; +# +# BUG#16691598 - ORDER BY LOWER(COLUMN) PRODUCES +# OUT-OF-ORDER RESULTS +# +CREATE TABLE t1 SELECT ('a a') as n; +INSERT INTO t1 VALUES('a b'); +SELECT * FROM t1 ORDER BY LOWER(n) ASC; +n +a a +a b +SELECT * FROM t1 ORDER BY LOWER(n) DESC; +n +a b +a a +DROP TABLE t1; +select @@collation_connection; +@@collation_connection +utf16le_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +# +# Bug#10344 Some string functions fail for UCS2 +# +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le, pos INT); +INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,1); +INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,2); +INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,3); +INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-1); +INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-2); +INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-3); +INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 1); +INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 2); +INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 3); +INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -1); +INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -2); +INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -3); +SELECT HEX(SUBSTR(a, pos)), SUBSTR(a, pos) FROM t1; +HEX(SUBSTR(a, pos)) SUBSTR(a, pos) +E400E5006800 äåh +E5006800 åh +6800 h +6800 h +E5006800 åh +E400E5006800 äåh +E400E50000D800DC äå? +E50000D800DC å? +00D800DC ? +00D800DC ? +E50000D800DC å? +E400E50000D800DC äå? +DROP TABLE t1; +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +# +# Bug#9442 Set parameter make query fail if column CHARACTER SET is UCS2 +# +CREATE TABLE t1 (utext VARCHAR(20) CHARACTER SET utf16le); +INSERT INTO t1 VALUES ("lily"); +INSERT INTO t1 VALUES ("river"); +PREPARE stmt FROM 'SELECT utext FROM t1 where utext like ?'; +SET @param1='%%'; +EXECUTE stmt USING @param1; +utext +lily +river +EXECUTE stmt USING @param1; +utext +lily +river +SELECT utext FROM t1 where utext like '%%'; +utext +lily +river +DROP TABLE t1; +DEALLOCATE PREPARE stmt; +# +# Bug #20108: corrupted default enum value for a ucs2 field +# +CREATE TABLE t1 ( +status ENUM('active','passive') CHARACTER SET utf16le COLLATE utf16le_general_ci +NOT NULL DEFAULT 'passive' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf16le COLLATE utf16le_general_ci NOT NULL DEFAULT 'passive' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf16le COLLATE utf16le_general_ci NOT NULL DEFAULT 'passive', + `a` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Conversion FROM an UTF16LE string to a decimal column +# +CREATE TABLE t1 (a VARCHAR(64) CHARACTER SET utf16le, b DECIMAL(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +UPDATE t1 set b=a; +SELECT *, HEX(a) FROM t1; +a b HEX(a) +1.1 1.100 31002E003100 +2.1 2.100 32002E003100 +DROP TABLE t1; +# +# Bug#9442 Set parameter make query fail if column CHARACTER SET is UCS2 +# +CREATE TABLE t1 (utext VARCHAR(20) CHARACTER SET utf16le); +INSERT INTO t1 VALUES ("lily"); +INSERT INTO t1 VALUES ("river"); +PREPARE stmt FROM 'SELECT utext FROM t1 where utext like ?'; +SET @param1='%%'; +EXECUTE stmt USING @param1; +utext +lily +river +EXECUTE stmt USING @param1; +utext +lily +river +SELECT utext FROM t1 where utext like '%%'; +utext +lily +river +DROP TABLE t1; +DEALLOCATE PREPARE stmt; +# +# Bug#22638 SOUNDEX broken for international characters +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT SOUNDEX(''),SOUNDEX('he'),SOUNDEX('hello all folks'),SOUNDEX('#3556 in bugdb'); +SOUNDEX('') SOUNDEX('he') SOUNDEX('hello all folks') SOUNDEX('#3556 in bugdb') + H000 H4142 I51231 +SELECT HEX(SOUNDEX('')),HEX(SOUNDEX('he')),HEX(SOUNDEX('hello all folks')),HEX(SOUNDEX('#3556 in bugdb')); +HEX(SOUNDEX('')) HEX(SOUNDEX('he')) HEX(SOUNDEX('hello all folks')) HEX(SOUNDEX('#3556 in bugdb')) + 4800300030003000 48003400310034003200 490035003100320033003100 +SELECT 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +# Cyrillic A, BE, VE +SELECT HEX(SOUNDEX(_utf16le 0x041004110412)); +HEX(SOUNDEX(_utf16le 0x041004110412)) +0410300030003000 +# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter +SELECT HEX(SOUNDEX(_utf16le 0x00BF00C0)); +HEX(SOUNDEX(_utf16le 0x00BF00C0)) +00BF300030003000 +# +# Bug#14290: character_maximum_length for text fields +# +CREATE TABLE t1(a BLOB, b TEXT CHARSET utf16le); +SELECT data_type, character_octet_length, character_maximum_length +FROM information_schema.columns where table_name='t1'; +DATA_TYPE CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH +blob 65535 65535 +text 65535 32767 +DROP TABLE t1; +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +# +# Testing cs->coll->instr() +# +SELECT POSITION('bb' IN 'abba'); +POSITION('bb' IN 'abba') +2 +# +# Testing cs->coll->hash_sort() +# +SET NAMES utf8, collation_connection=utf16le_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT @@collation_connection; +@@collation_connection +utf16le_bin +CREATE TABLE t1 ENGINE=HEAP AS SELECT REPEAT (' ', 10) AS a LIMIT 0; +ALTER TABLE t1 ADD KEY (a); +CREATE TABLE t2 (a VARCHAR(10)); +INSERT INTO t2 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'); +INSERT INTO t2 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F'); +INSERT INTO t1 SELECT CONCAT('a',t21.a,t22.a) FROM t2 t21, t2 t22 ORDER BY 1; +DROP TABLE t2; +INSERT INTO t1 VALUES ('a '); +SELECT a, HEX(a) FROM t1 WHERE a='a'; +a HEX(a) +a 61002000 +DROP TABLE t1; +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT @@collation_connection; +@@collation_connection +utf16le_general_ci +CREATE TABLE t1 ENGINE=HEAP AS SELECT REPEAT (' ', 10) AS a LIMIT 0; +ALTER TABLE t1 ADD KEY (a); +CREATE TABLE t2 (a VARCHAR(10)); +INSERT INTO t2 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'); +INSERT INTO t2 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F'); +INSERT INTO t1 SELECT CONCAT('a',t21.a,t22.a) FROM t2 t21, t2 t22 ORDER BY 1; +DROP TABLE t2; +INSERT INTO t1 VALUES ('a '); +SELECT a, HEX(a) FROM t1 WHERE a='a'; +a HEX(a) +a 61002000 +DROP TABLE t1; +# +# Testing cs->cset->numchars() +# +SELECT CHAR_LENGTH('abcd'), OCTET_LENGTH('abcd'); +CHAR_LENGTH('abcd') OCTET_LENGTH('abcd') +4 8 +SELECT CHAR_LENGTH(_utf16le 0x00D800DC), OCTET_LENGTH(_utf16le 0x00D800DC); +CHAR_LENGTH(_utf16le 0x00D800DC) OCTET_LENGTH(_utf16le 0x00D800DC) +1 4 +SELECT CHAR_LENGTH(_utf16le 0x7DD8FFDF), OCTET_LENGTH(_utf16le 0x7FD8DDDF); +CHAR_LENGTH(_utf16le 0x7DD8FFDF) OCTET_LENGTH(_utf16le 0x7FD8DDDF) +1 4 +# +# Testing cs->cset->charpos() +# +SELECT LEFT('abcd',2); +LEFT('abcd',2) +ab +SELECT HEX(LEFT(_utf16le 0x00D800DC7FD8FFDF, 1)); +HEX(LEFT(_utf16le 0x00D800DC7FD8FFDF, 1)) +00D800DC +SELECT HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)); +HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1)) +7FD8FFDF +# +# Testing cs->cset->well_formed_length() +# +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); +# Bad sequences +INSERT INTO t1 VALUES (_utf16le 0x00D8); +ERROR HY000: Invalid utf16le character string: '00D8' +INSERT INTO t1 VALUES (_utf16le 0x00DC); +ERROR HY000: Invalid utf16le character string: '00DC' +INSERT INTO t1 VALUES (_utf16le 0x00D800D8); +ERROR HY000: Invalid utf16le character string: '00D800' +INSERT INTO t1 VALUES (_utf16le 0x00D800E8); +ERROR HY000: Invalid utf16le character string: '00D800' +INSERT INTO t1 VALUES (_utf16le 0x00D80008); +ERROR HY000: Invalid utf16le character string: '00D800' +# Good sequences +INSERT INTO t1 VALUES (_utf16le 0x00D800DC); +INSERT INTO t1 VALUES (_utf16le 0x00D8FFDC); +INSERT INTO t1 VALUES (_utf16le 0xFFDB00DC); +INSERT INTO t1 VALUES (_utf16le 0xFFDBFFDC); +SELECT HEX(a) FROM t1; +HEX(a) +00D800DC +00D8FFDC +FFDB00DC +FFDBFFDC +DROP TABLE t1; +# +# Bug#32393 Character sets: illegal characters in utf16le columns +# +# Tests that cs->cset->wc_mb() doesn't accept surrogate parts +# +# via ALTER +# +SET sql_mode = ''; +CREATE TABLE t1 (s1 VARCHAR(50) CHARACTER SET ucs2); +INSERT INTO t1 VALUES (0xDF84); +ALTER TABLE t1 MODIFY column s1 VARCHAR(50) CHARACTER SET utf16le; +Warnings: +Warning 1366 Incorrect string value: '\xDF\x84' for column 's1' at row 1 +SELECT HEX(s1) FROM t1; +HEX(s1) +3F00 +DROP TABLE t1; +# +# via UPDATE +# +CREATE TABLE t1 (s1 VARCHAR(5) CHARACTER SET ucs2, s2 VARCHAR(5) CHARACTER SET utf16le); +INSERT INTO t1 (s1) VALUES (0xdf84); +UPDATE t1 set s2 = s1; +Warnings: +Warning 1366 Incorrect string value: '\xDF\x84' for column 's2' at row 1 +SELECT HEX(s2) FROM t1; +HEX(s2) +3F00 +DROP TABLE t1; +SET sql_mode = default; +# +# Testing cs->cset->lengthsp() +# +CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf16le; +INSERT INTO t1 VALUES ('a '); +SELECT HEX(a) FROM t1; +HEX(a) +6100 +DROP TABLE t1; +# +# Testing cs->cset->caseup() and cs->cset->casedn() +# +SELECT UPPER('abcd'), LOWER('ABCD'); +UPPER('abcd') LOWER('ABCD') +ABCD abcd +# +# Checking str_to_datetime() +# +select @@collation_connection; +@@collation_connection +utf16le_general_ci +CREATE TABLE t1 (a date); +INSERT INTO t1 VALUES ('2007-09-16'); +SELECT * FROM t1; +a +2007-09-16 +DROP TABLE t1; +# +# Testing cs->cset->ll10tostr +# +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le); +INSERT INTO t1 VALUES (123456); +SELECT a, HEX(a) FROM t1; +a HEX(a) +123456 310032003300340035003600 +DROP TABLE t1; +# +# Testing cs->cset->fill +# SOUNDEX fills strings with DIGIT ZERO up to four characters +# +SELECT SOUNDEX('a'), HEX(SOUNDEX('a')); +SOUNDEX('a') HEX(SOUNDEX('a')) +A000 4100300030003000 +# +# Testing cs->cset->strntoul +# +CREATE TABLE t1 (a enum ('a','b','c')) CHARACTER SET utf16le; +INSERT INTO t1 VALUES ('1'); +SELECT * FROM t1; +a +a +DROP TABLE t1; +# +# Testing cs->cset->strntoll and cs->cset->strntoull +# +SET NAMES latin1; +SELECT HEX(CONV(CONVERT('123' USING utf16le), -10, 16)); +HEX(CONV(CONVERT('123' USING utf16le), -10, 16)) +3742 +SELECT HEX(CONV(CONVERT('123' USING utf16le), 10, 16)); +HEX(CONV(CONVERT('123' USING utf16le), 10, 16)) +3742 +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +# +# Testing cs->cset->strntod +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT 1.1 + '1.2'; +1.1 + '1.2' +2.3 +SELECT 1.1 + '1.2xxx'; +1.1 + '1.2xxx' +2.3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1.2xxx' +# +# Testing cs->cset->strtoll10 +# +SELECT LEFT('aaa','1'); +LEFT('aaa','1') +a +CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a; +SELECT LEFT(a, '2') FROM t1; +LEFT(a, '2') +ab +SELECT LEFT(a, ' \t \t 2') FROM t1; +LEFT(a, ' \t \t 2') +ab +SELECT LEFT(a, ' \t \t +2') FROM t1; +LEFT(a, ' \t \t +2') +ab +SELECT SUBSTR(a, '-2') FROM t1; +SUBSTR(a, '-2') +cd +SELECT SUBSTR(a, ' \t \t -2') FROM t1; +SUBSTR(a, ' \t \t -2') +cd +SELECT LEFT(a, '00002') FROM t1; +LEFT(a, '00002') +ab +SELECT LEFT(a, ' \t \t 00002') FROM t1; +LEFT(a, ' \t \t 00002') +ab +SELECT LEFT(a, ' \t \t +00002') FROM t1; +LEFT(a, ' \t \t +00002') +ab +SELECT SUBSTR(a, '-00002') FROM t1; +SUBSTR(a, '-00002') +cd +SELECT SUBSTR(a, ' \t \t -00002') FROM t1; +SUBSTR(a, ' \t \t -00002') +cd +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a LIMIT 0; +INSERT INTO t1 VALUES ('255'), ('65535'),('16777215'),('4294967295'), +('1099511627775'),('281474976710655'),('72057594037927935'), +('1844674407370955161'),('18446744073709551614'), ('18446744073709551615'); +SELECT a, CAST(a AS SIGNED), CAST(a AS UNSIGNED) FROM t1; +a CAST(a AS SIGNED) CAST(a AS UNSIGNED) +255 255 255 +65535 65535 65535 +16777215 16777215 16777215 +4294967295 4294967295 4294967295 +1099511627775 1099511627775 1099511627775 +281474976710655 281474976710655 281474976710655 +72057594037927935 72057594037927935 72057594037927935 +1844674407370955161 1844674407370955161 1844674407370955161 +18446744073709551614 -2 18446744073709551614 +18446744073709551615 -1 18446744073709551615 +Warnings: +Warning 1105 Cast to signed converted positive out-of-range integer to its negative complement +Warning 1105 Cast to signed converted positive out-of-range integer to its negative complement +UPDATE t1 SET a=CONCAT('-', a); +SELECT a, CAST(a AS SIGNED) FROM t1; +a CAST(a AS SIGNED) +-255 -255 +-65535 -65535 +-16777215 -16777215 +-4294967295 -4294967295 +-1099511627775 -1099511627775 +-281474976710655 -281474976710655 +-72057594037927935 -72057594037927935 +-1844674407370955161 -1844674407370955161 +-18446744073709551614 -9223372036854775808 +-18446744073709551615 -9223372036854775808 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '-18446744073709551614' +Warning 1292 Truncated incorrect INTEGER value: '-18446744073709551615' +DROP TABLE t1; +# +# Testing cs->cset->strntoull10rnd +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES ('-1234.1e2'); +INSERT IGNORE INTO t1 VALUES ('-1234.1e2xxxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('-1234.1e2 '); +INSERT INTO t1 VALUES ('123'); +INSERT INTO t1 VALUES ('-124'); +INSERT INTO t1 VALUES ('+125'); +INSERT INTO t1 VALUES (' \t \t 123'); +INSERT INTO t1 VALUES (' \t \t -124'); +INSERT INTO t1 VALUES (' \t \t +125'); +INSERT INTO t1 VALUES (' \t \t 000123'); +INSERT INTO t1 VALUES (' \t \t -000124'); +INSERT INTO t1 VALUES (' \t \t +000125'); +SELECT * FROM t1; +a +-123410 +-123410 +-123410 +123 +-124 +125 +123 +-124 +125 +123 +-124 +125 +DROP TABLE t1; +CREATE TABLE t1 (a BIGINT UNSIGNED); +INSERT INTO t1 VALUES ('255'), ('65535'),('16777215'),('4294967295'), +('1099511627775'),('281474976710655'),('72057594037927935'), +('1844674407370955161'),('18446744073709551614'), ('18446744073709551615'); +SELECT * FROM t1; +a +255 +65535 +16777215 +4294967295 +1099511627775 +281474976710655 +72057594037927935 +1844674407370955161 +18446744073709551614 +18446744073709551615 +DROP TABLE t1; +# +# Testing cs->cset->scan +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES ('1 '); +INSERT IGNORE INTO t1 VALUES ('1 x'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +1 +1 +DROP TABLE t1; +# +# Testing auto-conversion to TEXT +# +SET sql_mode = ''; +CREATE TABLE t1 (a VARCHAR(17000) CHARACTER SET utf16le); +Warnings: +Note 1246 Converting column 'a' from VARCHAR to TEXT +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext CHARACTER SET utf16le COLLATE utf16le_general_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SET sql_mode = default; +# +# Testing that maximim possible key length is 767 bytes for InnoDB +# +CREATE TABLE t1 (a VARCHAR(150) CHARACTER SET utf16le PRIMARY KEY); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(150) CHARACTER SET utf16le COLLATE utf16le_general_ci NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(334) CHARACTER SET utf16le PRIMARY KEY) ROW_FORMAT=COMPACT; +ERROR 42000: Specified key was too long; max key length is 767 bytes +# +# Conversion to utf8 +# +CREATE TABLE t1 (a CHAR(1) CHARACTER SET utf16le); +INSERT INTO t1 VALUES (0x00D800DC),(0x00D8FFDC),(0x7FDB00DC),(0x7FDBFFDC); +INSERT INTO t1 VALUES (0xC000), (0xFF00),(0x00E0), (0xFFFF); +SELECT HEX(a), HEX(@a:=CONVERT(a USING utf8mb4)), HEX(CONVERT(@a USING utf16le)) FROM t1; +HEX(a) HEX(@a:=CONVERT(a USING utf8mb4)) HEX(CONVERT(@a USING utf16le)) +00D800DC F0908080 00D800DC +00D8FFDC F09083BF 00D8FFDC +7FDB00DC F3AFB080 7FDB00DC +7FDBFFDC F3AFB3BF 7FDBFFDC +C000 C380 C000 +FF00 C3BF FF00 +00E0 EE8080 00E0 +FFFF EFBFBF FFFF +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +# +# Test basic regex functionality +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf16le DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf16le DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +# +# Test how CHARACTER SET works with date/time +# +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +s1 hex(s1) +2008-07-18 32003000300038002D00300037002D0031003800 +08:42:04 300038003A00340032003A0030003400 +2008-07-18 08:42:04 32003000300038002D00300037002D00310038002000300038003A00340032003A0030003400 +DROP TABLE t1; +SET timestamp=0; +# +# Bug#33073 Character sets: ordering fails with utf32 +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 AS SELECT REPEAT('a',2) as s1 LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(2) CHARACTER SET utf16le DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE'); +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +SET max_sort_length=4; +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +DROP TABLE t1; +SET max_sort_length=DEFAULT; +# +# Bug#52520 Difference in tinytext utf column metadata +# +CREATE TABLE t1 ( +s1 TINYTEXT CHARACTER SET utf16le, +s2 TEXT CHARACTER SET utf16le, +s3 MEDIUMTEXT CHARACTER SET utf16le, +s4 LONGTEXT CHARACTER SET utf16le +); +SET NAMES utf8, @@character_set_results=NULL; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 255 0 Y 16 0 56 +def test t1 t1 s2 s2 252 65535 0 Y 16 0 56 +def test t1 t1 s3 s3 252 16777215 0 Y 16 0 56 +def test t1 t1 s4 s4 252 4294967295 0 Y 16 0 56 +def HEX(s1) 253 6120 0 Y 0 31 33 +s1 s2 s3 s4 HEX(s1) +SET NAMES latin1; +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 127 0 Y 16 0 8 +def test t1 t1 s2 s2 252 32767 0 Y 16 0 8 +def test t1 t1 s3 s3 252 8388607 0 Y 16 0 8 +def test t1 t1 s4 s4 252 2147483647 0 Y 16 0 8 +def HEX(s1) 253 2040 0 Y 0 31 8 +s1 s2 s3 s4 HEX(s1) +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 381 0 Y 16 0 33 +def test t1 t1 s2 s2 252 98301 0 Y 16 0 33 +def test t1 t1 s3 s3 252 25165821 0 Y 16 0 33 +def test t1 t1 s4 s4 252 4294967295 0 Y 16 0 33 +def HEX(s1) 253 6120 0 Y 0 31 33 +s1 s2 s3 s4 HEX(s1) +CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CONCAT(s1)` varchar(255) CHARACTER SET utf16le DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Problem found by Roy during review +# MY_CS_BINSORT was not set for utf16le_bin, +# so filesort did not work well +# +SET NAMES utf8, @@collation_connection=utf16le_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) as c LIMIT 0; +ALTER TABLE t1 ADD PRIMARY KEY(c); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) CHARACTER SET utf16le COLLATE utf16le_bin NOT NULL, + PRIMARY KEY (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES ('abc'),('zyx'),('acb'); +SELECT UPPER(c) FROM t1 ORDER BY 1 DESC; +UPPER(c) +ZYX +ACB +ABC +DROP TABLE t1; +# +# WL#3664 WEIGHT_STRING +# +SET NAMES utf8, collation_connection=utf16le_general_ci; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @@collation_connection; +@@collation_connection +utf16le_general_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0041 +select hex(weight_string('A')); +hex(weight_string('A')) +0041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +004100420043 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +00410042 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +004100420043 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +00410042004300200020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0041 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +004100 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00410042002000200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0041 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +004100 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00410042004300200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0041 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +004100 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00410042004300200020002000200020002000200020002000 +select @@collation_connection; +@@collation_connection +utf16le_general_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +20AC20AC20AC00200020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +20AC20AC00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +20AC20AC002000200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +SELECT HEX(WEIGHT_STRING(_utf16le 0x00D800DC)); +HEX(WEIGHT_STRING(_utf16le 0x00D800DC)) +FFFD +SELECT HEX(WEIGHT_STRING(_utf16le 0x00D801DC)); +HEX(WEIGHT_STRING(_utf16le 0x00D801DC)) +FFFD +SET NAMES utf8, collation_connection=utf16le_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @@collation_connection; +@@collation_connection +utf16le_bin +select hex(weight_string('a')); +hex(weight_string('a')) +000061 +select hex(weight_string('A')); +hex(weight_string('A')) +000041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +000061000062000063 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +000061000062 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +000061000062000063 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +000061000062000063000020000020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0000 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +000061 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00006100006200002000002000002000002000002000002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0000 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +000061 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00006100006200006300002000002000002000002000002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0000 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +000061 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00006100006200006300002000002000002000002000002000 +select @@collation_connection; +@@collation_connection +utf16le_bin +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0020AC0020AC0020AC000020000020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0020AC0020AC00002000002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +# +# End of 5.6 tests +# diff --git a/mysql-test/r/ctype_utf32.result-pq b/mysql-test/r/ctype_utf32.result-pq new file mode 100644 index 000000000..475d46cc9 --- /dev/null +++ b/mysql-test/r/ctype_utf32.result-pq @@ -0,0 +1,1431 @@ +# +# Start of 5.5 tests +# +SET NAMES latin1; +SET character_set_connection=utf32; +select hex('a'), hex('a '); +hex('a') hex('a ') +00000061 0000006100000020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +0 1 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +0 0 1 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +0 1 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +0 0 1 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 1 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select hex(_utf32 0x44); +hex(_utf32 0x44) +00000044 +select hex(_utf32 0x3344); +hex(_utf32 0x3344) +00003344 +select hex(_utf32 0x103344); +hex(_utf32 0x103344) +00103344 +select hex(_utf32 X'44'); +hex(_utf32 X'44') +00000044 +select hex(_utf32 X'3344'); +hex(_utf32 X'3344') +00003344 +select hex(_utf32 X'103344'); +hex(_utf32 X'103344') +00103344 +CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf32; +INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +00000420 +00002004 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +00000420 +00002004 +DELETE FROM t1; +INSERT INTO t1 VALUES +(X'000004200000002000000020',X'000004200000002000000020'), +(X'000020040000002000000020',X'000020040000002000000020'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +000004200000002000000020 +000020040000002000000020 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +00000420 +00002004 +DROP TABLE t1; +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0421')); +hex(LPAD(_utf32 X'0420',10,_utf32 X'0421')) +00000421000004210000042100000421000004210000042100000421000004210000042100000420 +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')); +hex(LPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')) +00000421000004220000042100000422000004210000042200000421000004220000042100000420 +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')); +hex(LPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')) +00000421000004220000042300000421000004220000042300000421000004220000042300000420 +SELECT hex(LPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')); +hex(LPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')) +00000420000004210000042200000423000004240000042500000426000004270000042800000429 +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0421')); +hex(RPAD(_utf32 X'0420',10,_utf32 X'0421')) +00000420000004210000042100000421000004210000042100000421000004210000042100000421 +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')); +hex(RPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')) +00000420000004210000042200000421000004220000042100000422000004210000042200000421 +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')); +hex(RPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')) +00000420000004210000042200000423000004210000042200000423000004210000042200000423 +SELECT hex(RPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')); +hex(RPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')) +00000420000004210000042200000423000004240000042500000426000004270000042800000429 +CREATE TABLE t1 SELECT +LPAD(_utf32 X'0420',10,_utf32 X'0421') l, +RPAD(_utf32 X'0420',10,_utf32 X'0421') r; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `l` varchar(10) CHARACTER SET utf32 DEFAULT NULL, + `r` varchar(10) CHARACTER SET utf32 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select hex(l), hex(r) from t1; +hex(l) hex(r) +00000421000004210000042100000421000004210000042100000421000004210000042100000420 00000420000004210000042100000421000004210000042100000421000004210000042100000421 +DROP TABLE t1; +create table t1 (f1 char(30)); +insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t1; +lpad(f1, 12, "-o-/") +-o-/-o103000 +-o-/22720000 +-o-/-3401200 +-o-/-o-78000 +drop table t1; +SET NAMES latin1; +SET character_set_connection=utf32; +select @@collation_connection; +@@collation_connection +utf32_general_ci +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf32 DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%') +explain select * from t1 where a like concat('abc','%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like (concat('abc','%'))) +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +select 'AA' like 'AA'; +'AA' like 'AA' +1 +select 'AA' like 'A%A'; +'AA' like 'A%A' +1 +select 'AA' like 'A%%A'; +'AA' like 'A%%A' +1 +select 'AA' like 'AA%'; +'AA' like 'AA%' +1 +select 'AA' like '%AA%'; +'AA' like '%AA%' +1 +select 'AA' like '%A'; +'AA' like '%A' +1 +select 'AA' like '%AA'; +'AA' like '%AA' +1 +select 'AA' like 'A%A%'; +'AA' like 'A%A%' +1 +select 'AA' like '_%_%'; +'AA' like '_%_%' +1 +select 'AA' like '%A%A'; +'AA' like '%A%A' +1 +select 'AAA'like 'A%A%A'; +'AAA'like 'A%A%A' +1 +select 'AZ' like 'AZ'; +'AZ' like 'AZ' +1 +select 'AZ' like 'A%Z'; +'AZ' like 'A%Z' +1 +select 'AZ' like 'A%%Z'; +'AZ' like 'A%%Z' +1 +select 'AZ' like 'AZ%'; +'AZ' like 'AZ%' +1 +select 'AZ' like '%AZ%'; +'AZ' like '%AZ%' +1 +select 'AZ' like '%Z'; +'AZ' like '%Z' +1 +select 'AZ' like '%AZ'; +'AZ' like '%AZ' +1 +select 'AZ' like 'A%Z%'; +'AZ' like 'A%Z%' +1 +select 'AZ' like '_%_%'; +'AZ' like '_%_%' +1 +select 'AZ' like '%A%Z'; +'AZ' like '%A%Z' +1 +select 'AZ' like 'A_'; +'AZ' like 'A_' +1 +select 'AZ' like '_Z'; +'AZ' like '_Z' +1 +select 'AMZ'like 'A%M%Z'; +'AMZ'like 'A%M%Z' +1 +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET character_set_connection=utf32; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32); +INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывА'),('ФЫВА'); +INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж'); +INSERT INTO t1 VALUES ('фывАпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж'); +INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВАПРОЛДЖ'); +SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a; +a +ФЫВА +ФЫВАПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывА +фывАпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf32_bin ORDER BY BINARY a; +a +фЫва +фЫвапролдж +DROP TABLE t1; +CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word)) +CHARACTER SET utf32; +INSERT INTO t1 (word) VALUES ("cat"); +SELECT * FROM t1 WHERE word LIKE "c%"; +word +cat +SELECT * FROM t1 WHERE word LIKE "ca_"; +word +cat +SELECT * FROM t1 WHERE word LIKE "cat"; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf32 x'0000006300000025'; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf32 x'00000063000000610000005F'; +word +cat +DROP TABLE t1; +select insert(_utf32 0x000000610000006200000063,10,2,_utf32 0x000000640000006500000066); +insert(_utf32 0x000000610000006200000063,10,2,_utf32 0x000000640000006500000066) +abc +select insert(_utf32 0x000000610000006200000063,1,2,_utf32 0x000000640000006500000066); +insert(_utf32 0x000000610000006200000063,1,2,_utf32 0x000000640000006500000066) +defc +SELECT hex(cast(0xAA as char character set utf32)); +hex(cast(0xAA as char character set utf32)) +000000AA +SELECT hex(convert(0xAA using utf32)); +hex(convert(0xAA using utf32)) +000000AA +CREATE TABLE t1 (a char(10) character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a varchar(10) character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a text character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a mediumtext character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a longtext character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +create table t1(a char(1)) default charset utf32; +insert into t1 values ('a'),('b'),('c'); +alter table t1 modify a char(5); +select a, hex(a) from t1; +a hex(a) +a 00000061 +b 00000062 +c 00000063 +drop table t1; +set names latin1; +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using utf32); +prepare stmt1 from @str2; +execute stmt1 using @ivar; +? +1234 +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a enum('x','y','z') character set utf32); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z') CHARACTER SET utf32 COLLATE utf32_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +select a, hex(a) from t1 order by a; +a hex(a) +x 00000078 +y 00000079 +z 0000007A +alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set utf32; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z','d','e','ä','ö','ü') CHARACTER SET utf32 COLLATE utf32_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('D'); +insert into t1 values ('E '); +insert into t1 values ('ä'); +insert into t1 values ('ö'); +insert into t1 values ('ü'); +select a, hex(a) from t1 order by a; +a hex(a) +x 00000078 +y 00000079 +z 0000007A +d 00000064 +e 00000065 +ä 000000E4 +ö 000000F6 +ü 000000FC +drop table t1; +create table t1 (a set ('x','y','z','ä','ö','ü') character set utf32); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` set('x','y','z','ä','ö','ü') CHARACTER SET utf32 COLLATE utf32_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +insert into t1 values ('x,y'); +insert into t1 values ('x,y,z,ä,ö,ü'); +select a, hex(a) from t1 order by a; +a hex(a) +x 00000078 +y 00000079 +x,y 000000780000002C00000079 +z 0000007A +x,y,z,ä,ö,ü 000000780000002C000000790000002C0000007A0000002C000000E40000002C000000F60000002C000000FC +drop table t1; +create table t1(a enum('a','b','c')) default character set utf32; +insert into t1 values('a'),('b'),('c'); +alter table t1 add b char(1); +show warnings; +Level Code Message +select * from t1 order by a; +a b +a NULL +b NULL +c NULL +drop table t1; +SET NAMES latin1; +SET collation_connection='utf32_general_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf32_general_ci 0000006100000009 +utf32_general_ci 00000061 +utf32_general_ci 0000006100000020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf32_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +SET NAMES latin1; +SET collation_connection='utf32_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf32_bin 0000006100000009 +utf32_bin 00000061 +utf32_bin 0000006100000020 +drop table t1; +# +# Bug#55980 Character sets: supplementary character _bin ordering is wrong +# +CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf32 COLLATE utf32_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84); +INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +00000385 CE85 +0000FF9D EFBE9D +00010384 F0908E84 +00100000 F4808080 +ALTER TABLE t1 ADD KEY(a); +SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a; +HEX(a) HEX(CONVERT(a USING utf8mb4)) +00000385 CE85 +0000FF9D EFBE9D +00010384 F0908E84 +00100000 F4808080 +# Additional test for bug#37244 Character sets: short utf8_bin weight_string value +SELECT HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +HEX(a) HEX(WEIGHT_STRING(a)) +00000385 000385 +0000FF9D 00FF9D +00010384 010384 +00100000 100000 +DROP TABLE IF EXISTS t1; +# +# BUG#16691598 - ORDER BY LOWER(COLUMN) PRODUCES +# OUT-OF-ORDER RESULTS +# +CREATE TABLE t1 SELECT ('a a') as n; +INSERT INTO t1 VALUES('a b'); +SELECT * FROM t1 ORDER BY LOWER(n) ASC; +n +a a +a b +SELECT * FROM t1 ORDER BY LOWER(n) DESC; +n +a b +a a +DROP TABLE t1; +select @@collation_connection; +@@collation_connection +utf32_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +select hex(substr(_utf32 0x000000e4000000e500000068,1)); +hex(substr(_utf32 0x000000e4000000e500000068,1)) +000000E4000000E500000068 +select hex(substr(_utf32 0x000000e4000000e500000068,2)); +hex(substr(_utf32 0x000000e4000000e500000068,2)) +000000E500000068 +select hex(substr(_utf32 0x000000e4000000e500000068,3)); +hex(substr(_utf32 0x000000e4000000e500000068,3)) +00000068 +select hex(substr(_utf32 0x000000e4000000e500000068,-1)); +hex(substr(_utf32 0x000000e4000000e500000068,-1)) +00000068 +select hex(substr(_utf32 0x000000e4000000e500000068,-2)); +hex(substr(_utf32 0x000000e4000000e500000068,-2)) +000000E500000068 +select hex(substr(_utf32 0x000000e4000000e500000068,-3)); +hex(substr(_utf32 0x000000e4000000e500000068,-3)) +000000E4000000E500000068 +create table t1 (utext varchar(20) character set utf32); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +CREATE TABLE t1 ( +status enum('active','passive') character set utf32 collate utf32_general_ci +NOT NULL default 'passive' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL DEFAULT 'passive' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL DEFAULT 'passive', + `a` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a varchar(64) character set utf32, b decimal(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +update t1 set b=a; +SELECT *, hex(a) FROM t1; +a b hex(a) +1.1 1.100 000000310000002E00000031 +2.1 2.100 000000320000002E00000031 +DROP TABLE t1; +create table t1 (utext varchar(20) character set utf32); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +set names latin1; +set character_set_connection=utf32; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb') + H000 H4142 I51231 +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +hex(soundex('')) hex(soundex('he')) hex(soundex('hello all folks')) hex(soundex('#3556 in bugdb')) + 00000048000000300000003000000030 0000004800000034000000310000003400000032 000000490000003500000031000000320000003300000031 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select hex(soundex(_utf32 0x000004100000041100000412)); +hex(soundex(_utf32 0x000004100000041100000412)) +00000410000000300000003000000030 +select hex(soundex(_utf32 0x000000BF000000C0)); +hex(soundex(_utf32 0x000000BF000000C0)) +000000C0000000300000003000000030 +set names latin1; +create table t1(a blob, b text charset utf32); +select data_type, character_octet_length, character_maximum_length +from information_schema.columns where table_name='t1'; +DATA_TYPE CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH +blob 65535 65535 +text 65535 16383 +drop table t1; +set names latin1; +set collation_connection=utf32_general_ci; +select position('bb' in 'abba'); +position('bb' in 'abba') +2 +create table t1 (a varchar(10) character set utf32) engine=heap; +insert into t1 values ('a'),('A'),('b'),('B'); +select * from t1 where a='a' order by binary a; +a +A +a +select hex(min(binary a)),count(*) from t1 group by a; +hex(min(binary a)) count(*) +00000041 2 +00000042 2 +drop table t1; +select char_length('abcd'), octet_length('abcd'); +char_length('abcd') octet_length('abcd') +4 16 +select left('abcd',2); +left('abcd',2) +ab +create table t1 (a varchar(10) character set utf32); +insert into t1 values (_utf32 0x0010FFFF); +insert into t1 values (_utf32 0x00110000); +ERROR HY000: Invalid utf32 character string: '001100' +insert into t1 values (_utf32 0x00110101); +ERROR HY000: Invalid utf32 character string: '001101' +insert into t1 values (_utf32 0x01000101); +ERROR HY000: Invalid utf32 character string: '010001' +insert into t1 values (_utf32 0x11000101); +ERROR HY000: Invalid utf32 character string: '110001' +select hex(a) from t1; +hex(a) +0010FFFF +drop table t1; +SET sql_mode = ''; +create table t1 (utf32 varchar(2) character set utf32); +Wrong character with pad +insert into t1 values (0x110000); +Warnings: +Warning 1366 Incorrect string value: '\x11\x00\x00' for column 'utf32' at row 1 +Wrong chsaracter without pad +insert into t1 values (0x00110000); +Warnings: +Warning 1366 Incorrect string value: '\x00\x11\x00\x00' for column 'utf32' at row 1 +Wrong character with pad followed by another wrong character +insert into t1 values (0x11000000110000); +Warnings: +Warning 1366 Incorrect string value: '\x11\x00\x00\x00\x11\x00...' for column 'utf32' at row 1 +Good character with pad followed by bad character +insert into t1 values (0x10000000110000); +Warnings: +Warning 1366 Incorrect string value: '\x00\x11\x00\x00' for column 'utf32' at row 1 +Good character without pad followed by bad character +insert into t1 values (0x0010000000110000); +Warnings: +Warning 1366 Incorrect string value: '\x00\x11\x00\x00' for column 'utf32' at row 1 +Wrong character with the second byte higher than 0x10 +insert into t1 values (0x00800037); +Warnings: +Warning 1366 Incorrect string value: '\x00\x80\x007' for column 'utf32' at row 1 +Wrong character with pad with the second byte higher than 0x10 +insert into t1 values (0x00800037); +Warnings: +Warning 1366 Incorrect string value: '\x00\x80\x007' for column 'utf32' at row 1 +drop table t1; +SET sql_mode = default; +select _utf32'a' collate utf32_general_ci = 0xfffd; +_utf32'a' collate utf32_general_ci = 0xfffd +0 +select hex(concat(_utf32 0x0410 collate utf32_general_ci, 0x61)); +hex(concat(_utf32 0x0410 collate utf32_general_ci, 0x61)) +0000041000000061 +create table t1 (s1 varchar(5) character set utf32); +insert into t1 values (0xfffd); +select case when s1 = 0xfffd then 1 else 0 end from t1; +case when s1 = 0xfffd then 1 else 0 end +1 +select hex(s1) from t1 where s1 = 0xfffd; +hex(s1) +0000FFFD +drop table t1; +create table t1 (a char(10)) character set utf32; +insert into t1 values ('a '); +select hex(a) from t1; +hex(a) +00000061 +drop table t1; +select upper('abcd'), lower('ABCD'); +upper('abcd') lower('ABCD') +ABCD abcd +create table t1 (a varchar(10) character set utf32); +insert into t1 values (123456); +select a, hex(a) from t1; +a hex(a) +123456 000000310000003200000033000000340000003500000036 +drop table t1; +select hex(soundex('a')); +hex(soundex('a')) +00000041000000300000003000000030 +create table t1 (a enum ('a','b','c')) character set utf32; +insert into t1 values ('1'); +select * from t1; +a +a +drop table t1; +set names latin1; +select hex(conv(convert('123' using utf32), -10, 16)); +hex(conv(convert('123' using utf32), -10, 16)) +3742 +select hex(conv(convert('123' using utf32), 10, 16)); +hex(conv(convert('123' using utf32), 10, 16)) +3742 +set names latin1; +set character_set_connection=utf32; +select 1.1 + '1.2'; +1.1 + '1.2' +2.3 +select 1.1 + '1.2xxx'; +1.1 + '1.2xxx' +2.3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1.2xxx' +select left('aaa','1'); +left('aaa','1') +a +create table t1 (a int); +insert into t1 values ('-1234.1e2'); +insert ignore into t1 values ('-1234.1e2xxxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +insert into t1 values ('-1234.1e2 '); +select * from t1; +a +-123410 +-123410 +-123410 +drop table t1; +create table t1 (a int); +insert into t1 values ('1 '); +insert ignore into t1 values ('1 x'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +1 +1 +drop table t1; +SET sql_mode = ''; +create table t1 (a varchar(17000) character set utf32); +Warnings: +Note 1246 Converting column 'a' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext CHARACTER SET utf32 COLLATE utf32_general_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = default; +create table t1 (a varchar(150) character set utf32 primary key); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(150) CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a varchar(334) character set utf32 primary key) ROW_FORMAT=COMPACT; +ERROR 42000: Specified key was too long; max key length is 767 bytes +SET sql_mode = ''; +create table t1 (a varchar(333) character set utf32, key(a)) +row_format=dynamic; +insert into t1 values (repeat('a',333)), (repeat('b',333)); +flush tables; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +SET sql_mode = default; +SET collation_connection=utf32_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +s1 hex(s1) +2008-07-18 000000320000003000000030000000380000002D00000030000000370000002D0000003100000038 +08:42:04 00000030000000380000003A00000034000000320000003A0000003000000034 +2008-07-18 08:42:04 000000320000003000000030000000380000002D00000030000000370000002D00000031000000380000002000000030000000380000003A00000034000000320000003A0000003000000034 +DROP TABLE t1; +SET timestamp=0; +SET NAMES latin1; +set collation_connection=utf32_general_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf32 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf32 DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +set names latin1; +select hex(char(0x01 using utf32)); +hex(char(0x01 using utf32)) +00000001 +select hex(char(0x0102 using utf32)); +hex(char(0x0102 using utf32)) +00000102 +select hex(char(0x010203 using utf32)); +hex(char(0x010203 using utf32)) +00010203 +select hex(char(0x01020304 using utf32)); +hex(char(0x01020304 using utf32)) +NULL +Warnings: +Warning 1300 Invalid utf32 character string: '010203' +create table t1 (s1 varchar(1) character set utf32, s2 text character set utf32); +create index i on t1 (s1); +insert into t1 values (char(256 using utf32), char(256 using utf32)); +select hex(s1), hex(s2) from t1; +hex(s1) hex(s2) +00000100 00000100 +drop table t1; +SET collation_connection=utf32_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(2) CHARACTER SET utf32 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE'); +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +SET max_sort_length=4; +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +DROP TABLE t1; +SET max_sort_length=DEFAULT; +SET NAMES latin1; +# +# Bug#52520 Difference in tinytext utf column metadata +# +CREATE TABLE t1 ( +s1 TINYTEXT CHARACTER SET utf32, +s2 TEXT CHARACTER SET utf32, +s3 MEDIUMTEXT CHARACTER SET utf32, +s4 LONGTEXT CHARACTER SET utf32 +); +SET NAMES utf8mb4, @@character_set_results=NULL; +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 255 0 Y 16 0 60 +def test t1 t1 s2 s2 252 65535 0 Y 16 0 60 +def test t1 t1 s3 s3 252 16777215 0 Y 16 0 60 +def test t1 t1 s4 s4 252 4294967295 0 Y 16 0 60 +def HEX(s1) 253 8160 0 Y 0 31 255 +s1 s2 s3 s4 HEX(s1) +SET NAMES latin1; +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 63 0 Y 16 0 8 +def test t1 t1 s2 s2 252 16383 0 Y 16 0 8 +def test t1 t1 s3 s3 252 4194303 0 Y 16 0 8 +def test t1 t1 s4 s4 252 1073741823 0 Y 16 0 8 +def HEX(s1) 253 2040 0 Y 0 31 8 +s1 s2 s3 s4 HEX(s1) +SET NAMES utf8mb4; +SELECT *, HEX(s1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 s1 s1 252 252 0 Y 16 0 255 +def test t1 t1 s2 s2 252 65532 0 Y 16 0 255 +def test t1 t1 s3 s3 252 16777212 0 Y 16 0 255 +def test t1 t1 s4 s4 252 4294967292 0 Y 16 0 255 +def HEX(s1) 253 8160 0 Y 0 31 255 +s1 s2 s3 s4 HEX(s1) +CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CONCAT(s1)` varchar(255) CHARACTER SET utf32 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Bug#45263 utf32_general_ci, bad effects around CREATE TABLE AS SELECT +# +SET collation_connection=utf32_general_ci; +CREATE TABLE t1 AS SELECT HEX(0x00) AS my_col; +SELECT * FROM t1; +my_col +00 +DROP TABLE t1; +# +# Bug#32859 Character sets: no warning with non-fitting chariot wheel +# +CREATE TABLE t1 (utf32 CHAR(5) CHARACTER SET utf32, latin1 CHAR(5) CHARACTER SET latin1); +INSERT INTO t1 (utf32) VALUES (0xc581); +UPDATE IGNORE t1 SET latin1 = utf32; +Warnings: +Warning 1366 Incorrect string value: '\x00\x00\xC5\x81' for column 'latin1' at row 1 +DELETE FROM t1; +INSERT INTO t1 (utf32) VALUES (0x100cc); +UPDATE IGNORE t1 SET latin1 = utf32; +Warnings: +Warning 1366 Incorrect string value: '\x00\x01\x00\xCC' for column 'latin1' at row 1 +DROP TABLE t1; +# +# Bug#55912 FORMAT with locale set fails for numbers < 1000 +# +SET collation_connection=utf32_general_ci; +CREATE TABLE t1 AS SELECT format(123,2,'no_NO'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `format(123,2,'no_NO')` varchar(36) CHARACTER SET utf32 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +format(123,2,'no_NO') +123,00 +DROP TABLE t1; +# +# Bug#11753363 (Bug#44793) Character sets: case clause, ucs2 or utf32, failure +# +SELECT CASE _latin1'a' WHEN _utf32'a' THEN 'A' END; +CASE _latin1'a' WHEN _utf32'a' THEN 'A' END +A +SELECT CASE _utf32'a' WHEN _latin1'a' THEN 'A' END; +CASE _utf32'a' WHEN _latin1'a' THEN 'A' END +A +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf32); +INSERT INTO t1 VALUES ('a'); +SELECT CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END FROM t1; +CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END +b +DROP TABLE t1; +# +# Bug#11750518 41090: ORDER BY TRUNCATES GROUP_CONCAT RESULT +# +SET NAMES utf8, @@character_set_connection=utf32; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT id, CHAR_LENGTH(GROUP_CONCAT(body)) AS l +FROM (SELECT 'a' AS id, REPEAT('foo bar', 100) AS body +UNION ALL +SELECT 'a' AS id, REPEAT('bla bla', 100) AS body) t1 +GROUP BY id +ORDER BY l DESC; +id l +a 256 +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#3664 WEIGHT_STRING +# +set collation_connection=utf32_general_ci; +select @@collation_connection; +@@collation_connection +utf32_general_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0041 +select hex(weight_string('A')); +hex(weight_string('A')) +0041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +004100420043 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +00410042 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +004100420043 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +00410042004300200020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0041 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +004100 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00410042002000200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0041 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +004100 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00410042004300200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0041 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +004100 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00410042004300200020002000200020002000200020002000 +select @@collation_connection; +@@collation_connection +utf32_general_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +20AC20AC20AC00200020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +20AC20AC00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +20AC20AC002000200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(_utf32 0x10000)); +hex(weight_string(_utf32 0x10000)) +FFFD +select hex(weight_string(_utf32 0x10001)); +hex(weight_string(_utf32 0x10001)) +FFFD +set collation_connection=utf32_bin; +select @@collation_connection; +@@collation_connection +utf32_bin +select hex(weight_string('a')); +hex(weight_string('a')) +000061 +select hex(weight_string('A')); +hex(weight_string('A')) +000041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +000061000062000063 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +000061000062 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +000061000062000063 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +000061000062000063000020000020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0000 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +000061 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00006100006200002000002000002000002000002000002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0000 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +000061 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00006100006200006300002000002000002000002000002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0000 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +000061 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00006100006200006300002000002000002000002000002000 +select @@collation_connection; +@@collation_connection +utf32_bin +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0020AC0020AC0020AC000020000020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0020AC0020AC00002000002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +# +# End of 5.6 tests +# +# +# Start of 8.0 tests +# +# +# Bug#28275881: ASSERT `RC == TYPE_OK' IN CREATE TABLE WITH CHARSET UTF32 +# +CREATE TABLE table425 (b1 +SET('wgrpqu','Oklahoma','grpquarwkazzjeiwvdmdivjqsxmhjwagewclcfykywlcnemiuaabr +rifnhuufzasunkrcpvasdqkxbwptigbpnesqigwegcnfeuvrgnecpthmhffqbythjwpukqubzpomnt +rddrwhzjtqvbjiklcekxqyoxsolbxthdcprswpjxixmvfwmsyseblwcvumvyvbitxqjxdzdytunqvv +rmpyxrencqhuyrfluezqekmqpwutxnzddrbjycyoyqbzsoxvillooqxuvoxcgohdbytybwcqxdwtqr +ebgjzbycekyjgbpmqadutrqluyxhrdodxqqjwasfkvetfobocgpftrhvxugmmszwpoglvarsfiljrz +imqeplevleqdhepkhcfrahcpjj') NULL ) DEFAULT CHARACTER SET = utf32; +ERROR HY000: Too long enumeration/set value for column b1. +CREATE FUNCTION hello (s SET('wgrpqu','Oklahoma','grpquarwkazzjeiwvdmdivjqsxmh +jwagewclcfykywlcnemiuaabrrifnhuufzasunkrcpvasdqkxbwptigbpnesqigwegcnfeuvrgnecp +thmhffqbythjwpukqubzpomntrddrwhzjtqvbjiklcekxqyoxsolbxthdcprswpjxixmvfwmsysebl +wcvumvyvbitxqjxdzdytunqvvrmpyxrencqhuyrfluezqekmqpwutxnzddrbjycyoyqbzsoxvilloo +qxuvoxcgohdbytybwcqxdwtqrebgjzbycekyjgbpmqadutrqluyxhrdodxqqjwasfkvetfobocgpft +rhvxugmmszwpoglvarsfiljrzimqeplevleqdhepkhcfrahcpjj') CHARACTER SET utf32) +RETURNS CHAR(50) DETERMINISTIC RETURN CONCAT('Hello, ',s,'!'); +ERROR HY000: Too long enumeration/set value for column s. +# +# End of 8.0 tests +# diff --git a/mysql-test/r/ctype_utf32_uca.result-pq b/mysql-test/r/ctype_utf32_uca.result-pq new file mode 100644 index 000000000..572dca702 --- /dev/null +++ b/mysql-test/r/ctype_utf32_uca.result-pq @@ -0,0 +1,3621 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 5.5 tests +# +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +set collation_connection=utf32_unicode_ci; +select hex('a'), hex('a '); +hex('a') hex('a ') +00000061 0000006100000020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +1 0 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +1 0 0 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +1 0 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +1 0 0 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 0 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select 'c' like '\_' as want0; +want0 +0 +create table t1 (c1 char(10) character set utf32 collate utf32_bin); +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); +INSERT INTO t1 VALUES (_ucs2 0x1EA0),(_ucs2 0x1EA1),(_ucs2 0x1EA2),(_ucs2 0x1EA3); +INSERT INTO t1 VALUES (_ucs2 0x1EA4),(_ucs2 0x1EA5),(_ucs2 0x1EA6),(_ucs2 0x1EA7); +INSERT INTO t1 VALUES (_ucs2 0x1EA8),(_ucs2 0x1EA9),(_ucs2 0x1EAA),(_ucs2 0x1EAB); +INSERT INTO t1 VALUES (_ucs2 0x1EAC),(_ucs2 0x1EAD),(_ucs2 0x1EAE),(_ucs2 0x1EAF); +INSERT INTO t1 VALUES (_ucs2 0x1EB0),(_ucs2 0x1EB1),(_ucs2 0x1EB2),(_ucs2 0x1EB3); +INSERT INTO t1 VALUES (_ucs2 0x1EB4),(_ucs2 0x1EB5),(_ucs2 0x1EB6),(_ucs2 0x1EB7); +INSERT INTO t1 VALUES (_ucs2 0x1EB8),(_ucs2 0x1EB9),(_ucs2 0x1EBA),(_ucs2 0x1EBB); +INSERT INTO t1 VALUES (_ucs2 0x1EBC),(_ucs2 0x1EBD),(_ucs2 0x1EBE),(_ucs2 0x1EBF); +INSERT INTO t1 VALUES (_ucs2 0x1EC0),(_ucs2 0x1EC1),(_ucs2 0x1EC2),(_ucs2 0x1EC3); +INSERT INTO t1 VALUES (_ucs2 0x1EC4),(_ucs2 0x1EC5),(_ucs2 0x1EC6),(_ucs2 0x1EC7); +INSERT INTO t1 VALUES (_ucs2 0x1EC8),(_ucs2 0x1EC9),(_ucs2 0x1ECA),(_ucs2 0x1ECB); +INSERT INTO t1 VALUES (_ucs2 0x1ECC),(_ucs2 0x1ECD),(_ucs2 0x1ECE),(_ucs2 0x1ECF); +INSERT INTO t1 VALUES (_ucs2 0x1ED0),(_ucs2 0x1ED1),(_ucs2 0x1ED2),(_ucs2 0x1ED3); +INSERT INTO t1 VALUES (_ucs2 0x1ED4),(_ucs2 0x1ED5),(_ucs2 0x1ED6),(_ucs2 0x1ED7); +INSERT INTO t1 VALUES (_ucs2 0x1ED8),(_ucs2 0x1ED9),(_ucs2 0x1EDA),(_ucs2 0x1EDB); +INSERT INTO t1 VALUES (_ucs2 0x1EDC),(_ucs2 0x1EDD),(_ucs2 0x1EDE),(_ucs2 0x1EDF); +INSERT INTO t1 VALUES (_ucs2 0x1EE0),(_ucs2 0x1EE1),(_ucs2 0x1EE2),(_ucs2 0x1EE3); +INSERT INTO t1 VALUES (_ucs2 0x1EE4),(_ucs2 0x1EE5),(_ucs2 0x1EE6),(_ucs2 0x1EE7); +INSERT INTO t1 VALUES (_ucs2 0x1EE8),(_ucs2 0x1EE9),(_ucs2 0x1EEA),(_ucs2 0x1EEB); +INSERT INTO t1 VALUES (_ucs2 0x1EEC),(_ucs2 0x1EED),(_ucs2 0x1EEE),(_ucs2 0x1EEF); +INSERT INTO t1 VALUES (_ucs2 0x1EF0),(_ucs2 0x1EF1); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('AE'),('Ae'),('ae'),('aE'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_unicode_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_icelandic_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÂÃàâãĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Áá +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Ðð +Đđ +Ɖ +Ɗ +Ƌƌ +EeÈÊËèêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Éé +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÎÏìîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +Íí +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÔÕòôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Óó +Ǿǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÛÜùûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Úú +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÿŶŷŸ +Ýý +Ƴƴ +ZzŹźŻżŽž +ƍ +Þþ +ÄÆäæ +ÖØöø +Åå +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_latvian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +CHChcHch +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġǦǧǴǵ +Ģģ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +Yy +ı +Ɨ +Ɩ +JjĴĵǰ +KkǨǩ +Ķķ +Ƙƙ +LlĹ弾 +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Ļļ +Łł +ƚ +ƛ +Mm +NnÑñŃńŇňǸǹ +NJNjnJnjNJNjnj +Ņņ +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŘř +RRRrrRrr +Ŗŗ +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_romanian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÃÄÅàáãäåĀāĄąǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Ăă +Ââ +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÏìíïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +Îî +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssß +Şş +Ʃ +ƪ +TtŤť +ƾ +Ţţ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovenian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +CHChcHch +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_polish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂăǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Ąą +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĈĉĊċČč +CHChcHch +Ćć +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ęę +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŅņŇňǸǹ +NJNjnJnjNJNjnj +Ńń +Ɲ +ƞ +Ŋŋ +OoÒÔÕÖòôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Óó +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŜŝŞşŠšſ +SSSssSssß +Śś +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŽž +ƍ +Źź +Żż +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_estonian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÅàáâãåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzdZdz +DŽDždŽdž +DŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔòóôŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Zz +Žž +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Õõ +Ää +Öö +Üü +Xx +YyÝýÿŶŷŸ +Ƴƴ +ŹźŻż +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ññ +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_swedish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃàáâãĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ǿǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Åå +ÄÆäæ +ÖØöø +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_turkish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcĆćĈĉĊċČč +CHChcHch +Çç +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĠġĢģǦǧǴǵ +Ğğ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +Iı +IJIj +ƕǶ +Ħħ +iÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +iJijIJij +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Öö +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssß +Şş +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Üü +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_czech_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +cH +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗ +RRRrrRrr +Řř +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_danish_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃàáâãĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +aA +AEAeaEae +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ǿǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŰűŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +ÄÆäæ +ÖØöøŐő +AAAaaaÅå +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_lithuanian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CCHChcchÇçĆćĈĉĊċ +cH +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IYiyÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovak_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÅàáâãåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +Ää +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċ +cH +Čč +Ƈƈ +DdĎď +DZDzdZdzDŽDždžDZDzdz +DŽDždŽdž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÕÖòóõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ôô +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish2_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +cH +CHChch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +lL +LLLlll +Łł +ƚ +ƛ +Mm +NnŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ññ +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_roman_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IJijÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJij +IJij +ı +Ɨ +Ɩ +Ĵĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJlj +LJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnj +NJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +ÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +UVuv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_esperanto_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĊċČč +CHChcHch +Ĉĉ +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĞğĠġĢģǦǧǴǵ +Ĝĝ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +Hh +Ĥĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +Jjǰ +Ĵĵ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŞşŠšſ +SSSssSssß +Ŝŝ +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ŭŭ +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_hungarian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ÖöŐő +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +ÜüŰű +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_croatian_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEae +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĈĉĊċ +CHChcHch +Čč +Ćć +Ƈƈ +DdĎď +DZDzdZdzDZDzdz +DŽDždŽdžDŽDždž +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LLLllLll +LJLjlJljLJLjlj +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖòóôõöŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssß +Šš +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ƍ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_german2_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÅàáâãåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEaeÄÆäæ +ǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕòóôõŌōŎŏŐőƠơǑǒǪǫǬǭỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeÖöŒœ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Üü +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_unicode_520_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ +AAAaaAaa +AEAeaEaeÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdÐðĎďĐđ +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Ɖ +Ɗ +Ƌƌ +EeÈÉÊËèéêëĒēĔĕĖėĘęĚěẸẹẺẻẼẽẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥĦħ +ƕǶ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľĿŀŁł +LJLjlJljLJLjlj +LLLllLll +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÔÕÖØòóôõöøŌōŎŏŐőƠơǑǒǪǫǬǭǾǿỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợ +OEOeoEoeŒœ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜỤụỦủỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_vietnamese_ci; +group_concat(c1 order by binary c1 separator '') +÷ +× +AaÀÁÃÄÅàáãäåĀāĄąǍǎǞǟǠǡǺǻẠạẢả +AAAaaAaa +AEAeaEae +ĂăẮắẰằẲẳẴẵẶặ +ÂâẤấẦầẨẩẪẫẬậ +ÆæǢǣǼǽ +Bb +ƀ +Ɓ +Ƃƃ +CcÇçĆćĈĉĊċČč +CHChcHch +Ƈƈ +DdĎď +DZDzDŽDždZdzdŽdžDŽDždžDZDzdz +Đđ +Ɖ +Ɗ +Ƌƌ +Ðð +EeÈÉËèéëĒēĔĕĖėĘęĚěẸẹẺẻẼẽ +ÊêẾếỀềỂểỄễỆệ +Ǝǝ +Ə +Ɛ +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ɠ +Ɣ +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiÌÍÎÏìíîïĨĩĪīĬĭĮįİǏǐỈỉỊị +IJIjiJijIJij +ı +Ɨ +Ɩ +JjĴĵǰ +KkĶķǨǩ +Ƙƙ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJLjlj +LLLllLll +Łł +ƚ +ƛ +Mm +NnÑñŃńŅņŇňǸǹ +NJNjnJnjNJNjnj +Ɲ +ƞ +Ŋŋ +OoÒÓÕÖòóõöŌōŎŏŐőǑǒǪǫǬǭỌọỎỏ +OEOeoEoeŒœ +ÔôỐốỒồỔổỖỗỘộ +ƠơỚớỜờỞởỠỡỢợ +ØøǾǿ +Ɔ +Ɵ +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗŘř +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssß +Ʃ +ƪ +TtŢţŤť +ƾ +Ŧŧ +ƫ +Ƭƭ +Ʈ +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųǓǔǕǖǗǘǙǚǛǜỤụỦủ +ƯưỨứỪừỬửỮữỰự +Ɯ +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ƍ +Ƶƶ +ƷǮǯ +Ƹƹ +ƺ +Þþ +ƿǷ +ƻ +Ƨƨ +Ƽƽ +Ƅƅ +ʼn +ǀ +ǁ +ǂ +ǃ +drop table t1; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (c varchar(150) CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_general_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 +COLLATE utf32_general_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +CREATE TABLE t1 (c varchar(150) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_unicode_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 +COLLATE utf32_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +CREATE TABLE t1 (c varchar(150) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32) COLLATE utf32_unicode_ci; +c +Μωδαί̈ +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32) +COLLATE utf32_unicode_ci ORDER BY c; +c +Μωδ +Μωδαί̈ +DROP TABLE t1; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET @test_character_set='utf32'; +SET @test_collation='utf32_swedish_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) utf32_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) utf32_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) COLLATE utf32_swedish_ci DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf32 COLLATE=utf32_swedish_ci +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +SET character_set_results= @safe_character_set_results; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +SET collation_connection='utf32_unicode_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf32_unicode_ci 0000006100000009 +utf32_unicode_ci 00000061 +utf32_unicode_ci 0000006100000020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf32_unicode_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (id int, a varchar(30) character set utf32); +INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131); +INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049); +INSERT INTO t1 VALUES (5, _ucs2 0x01300130), (6, _ucs2 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 8 ıi 8 II 8 +ıı 8 ıı 8 II 8 +ii 8 ii 8 II 8 +İI 8 ii 8 İI 8 +İİ 8 ii 8 İİ 8 +II 8 ii 8 II 8 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf32 collate utf32_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 8 ıi 8 Iİ 8 +ıı 8 ıı 8 II 8 +ii 8 ii 8 İİ 8 +İI 8 iı 8 İI 8 +İİ 8 ii 8 İİ 8 +II 8 ıı 8 II 8 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +set collation_connection=utf32_unicode_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf32 COLLATE utf32_unicode_ci DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf32 COLLATE utf32_unicode_ci DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +SET collation_connection=utf32_czech_ci; +SELECT @@collation_connection; +@@collation_connection +utf32_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('c'),('ce'),('cé'),('ch'); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT * FROM t1 WHERE s1 LIKE 'c%'; +s1 +c +ce +cé +ch +ALTER TABLE t1 DROP KEY s1, ADD KEY(s1(1)); +SELECT * FROM t1 WHERE s1 LIKE 'ch'; +s1 +ch +DROP TABLE t1; +SELECT @@collation_connection; +@@collation_connection +utf32_czech_ci +# +# Bug#57737 Character sets: search fails with like, contraction, index +# Part#2 - ignorable characters +# +CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS s1 LIMIT 0; +INSERT INTO t1 VALUES ('a\0\0\0\0\0\t'),('a'),('b'),('c'),('d'),('e'); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +00000061000000000000000000000000000000000000000000000009 +00000061 +ALTER TABLE t1 ADD KEY s1 (s1); +SELECT HEX(s1) FROM t1 WHERE s1 LIKE 'a%'; +HEX(s1) +00000061000000000000000000000000000000000000000000000009 +00000061 +DROP TABLE t1; +# +# Bug #12319710 : INVALID MEMORY READ AND/OR CRASH IN +# MY_UCA_CHARCMP WITH UTF32 +# +SET collation_connection=utf32_unicode_ci; +CREATE TABLE t1 (a TEXT CHARACTER SET utf32 COLLATE utf32_turkish_ci NOT NULL); +INSERT INTO t1 VALUES ('a'), ('b'); +CREATE TABLE t2 (b VARBINARY(5) NOT NULL); +#insert chars outside of BMP +INSERT INTO t2 VALUEs (0x082837),(0x082837); +#test for read-out-of-bounds with non-BMP chars as a LIKE pattern +SELECT * FROM t1,t2 WHERE a LIKE b; +a b +#test the original statement +SELECT 1 FROM t1 AS t1_0 NATURAL LEFT OUTER JOIN t2 AS t2_0 +RIGHT JOIN t1 AS t1_1 ON t1_0.a LIKE t2_0.b; +1 +1 +1 +DROP TABLE t1,t2; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#3664 WEIGHT_STRING +# +set collation_connection=utf32_unicode_ci; +select @@collation_connection; +@@collation_connection +utf32_unicode_ci +select hex(weight_string('a')); +hex(weight_string('a')) +0E33 +select hex(weight_string('A')); +hex(weight_string('A')) +0E33 +select hex(weight_string('abc')); +hex(weight_string('abc')) +0E330E4A0E60 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +0E330E4A +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +0E330E4A0E60 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +0E330E4A0E6002090209 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +0E +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0E330E4A02 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +0E330E4A020902090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +0E +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +0E +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0E33 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +0E330E +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +0E330E4A +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0E330E4A0E +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +0E330E4A0E6002090209020902090209020902090209020902 +select @@collation_connection; +@@collation_connection +utf32_unicode_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0E230E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0E230E230E2302090209 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0E230E2302 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0E230E23020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0E230E +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0E230E23 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0E230E230E +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0E230E230E2302090209020902090209020902090209020902 +select hex(weight_string(_utf32 0x10000 collate utf32_unicode_ci)); +hex(weight_string(_utf32 0x10000 collate utf32_unicode_ci)) +FFFD +select hex(weight_string(_utf32 0x10001 collate utf32_unicode_ci)); +hex(weight_string(_utf32 0x10001 collate utf32_unicode_ci)) +FFFD +set @@collation_connection=utf32_czech_ci; +select @@collation_connection; +@@collation_connection +utf32_czech_ci +select collation(cast(_latin1 0xDF as char)); +collation(cast(_latin1 0xDF as char)) +utf32_czech_ci +select hex(weight_string('s')); +hex(weight_string('s')) +0FEA +select hex(weight_string(cast(_latin1 0xDF as char))); +hex(weight_string(cast(_latin1 0xDF as char))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF as char) as char(1))) +0FEA0FEA +select hex(weight_string('c')); +hex(weight_string('c')) +0E60 +select hex(weight_string('h')); +hex(weight_string('h')) +0EE1 +select hex(weight_string('ch')); +hex(weight_string('ch')) +0EE2 +select hex(weight_string('i')); +hex(weight_string('i')) +0EFB +select hex(weight_string(cast(_latin1 0x6368DF as char))); +hex(weight_string(cast(_latin1 0x6368DF as char))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(1))) +0E60 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(2))) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(3))) +0EE20FEA0FEA +select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))); +hex(weight_string(cast(_latin1 0x6368DF as char) as char(4))) +0EE20FEA0FEA0209 +select hex(weight_string(cast(_latin1 0xDF6368 as char))); +hex(weight_string(cast(_latin1 0xDF6368 as char))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1))) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2))) +0FEA0FEA0E60 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3))) +0FEA0FEA0EE2 +select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))); +hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4))) +0FEA0FEA0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0)) +0EE202 +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0)) +0EE20209 +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0)) +0EE20209020902090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0)) +0E +select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0)) +0EE2 +select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0)) +0EE20F +select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0)) +0EE20FEA +select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0)) +0EE20FEA0FEA02090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0)) +0FEA0FEA0E6002090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0)) +0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0)) +0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0)) +0FEA0F +select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0)) +0FEA0FEA +select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)); +hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0)) +0FEA0FEA0EE202090209020902090209020902090209020902 +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET collation_connection=utf32_german2_ci; +"BEGIN ctype_german.inc" +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf32_german2_ci +delete from t1; +INSERT INTO t1 VALUES ('ud'),('uf'); +INSERT INTO t1 VALUES ('od'),('of'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('ad'),('af'); +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6); +INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 00000061 +ad 0000006100000064 +ae 0000006100000065 +Æ 000000C6 +ä 000000E4 +æ 000000E6 +af 0000006100000066 +e 00000065 +o 0000006F +od 0000006F00000064 +oe 0000006F00000065 +ö 000000F6 +Œ 00000152 +œ 00000153 +of 0000006F00000066 +s 00000073 +ss 0000007300000073 +ß 000000DF +u 00000075 +ud 0000007500000064 +ue 0000007500000065 +ü 000000FC +uf 0000007500000066 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a +ad +ae,Æ,ä,æ +af +e +o +od +oe,ö,Œ,œ +of +s +ss,ß +u +ud +ue,ü +uf +SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1); +s1 hex(s1) hex(weight_string(s1)) +a 00000061 0E33 +ad 0000006100000064 0E330E6D +ae 0000006100000065 0E330E8B +Æ 000000C6 0E330E8B +ä 000000E4 0E330E8B +æ 000000E6 0E330E8B +af 0000006100000066 0E330EB9 +e 00000065 0E8B +o 0000006F 0F82 +od 0000006F00000064 0F820E6D +oe 0000006F00000065 0F820E8B +ö 000000F6 0F820E8B +Œ 00000152 0F820E8B +œ 00000153 0F820E8B +of 0000006F00000066 0F820EB9 +s 00000073 0FEA +ss 0000007300000073 0FEA0FEA +ß 000000DF 0FEA0FEA +u 00000075 101F +ud 0000007500000064 101F0E6D +ue 0000007500000065 101F0E8B +ü 000000FC 101F0E8B +uf 0000007500000066 101F0EB9 +SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1); +s1 hex(s1) +ae 0000006100000065 +Æ 000000C6 +ä 000000E4 +æ 000000E6 +drop table t1; +"END ctype_german.inc" +# +# WL#2673 Unicode Collation Algorithm new version +# +SET NAMES utf8mb4; +SET collation_connection=utf32_unicode_520_ci; +CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` varchar(10) CHARACTER SET utf32 COLLATE utf32_unicode_520_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A); +INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C); +INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E); +INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242); +INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244); +INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246); +INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248); +INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A); +INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C); +INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E); +INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B); +INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289); +INSERT INTO t1 VALUES (_utf32 0x028C); +INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C); +INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD); +INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF); +INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF); +INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7); +INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB); +INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD); +INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF); +INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511); +INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513); +INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1); +INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3); +INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5); +INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7); +INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01); +INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03); +INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05); +INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07); +INSERT INTO t1 VALUES (_utf32 0x1D7D); +INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E); +INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184); +INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81); +INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83); +INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85); +INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87); +INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89); +INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B); +INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D); +INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F); +INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61); +INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63); +INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65); +INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67); +INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69); +INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B); +INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75); +INSERT INTO t1 VALUES (_utf32 0x2C76); +INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01); +INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03); +INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05); +INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07); +INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31); +INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33); +INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35); +INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37); +INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401); +INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403); +INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405); +INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407); +INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429); +INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B); +INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D); +INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F); +INSERT INTO t1 VALUES (_utf32 0x0370); +INSERT INTO t1 VALUES (_utf32 0x0371); +INSERT INTO t1 VALUES (_utf32 0x0372); +INSERT INTO t1 VALUES (_utf32 0x0373); +INSERT INTO t1 VALUES (_utf32 0x0514); +INSERT INTO t1 VALUES (_utf32 0x0515); +INSERT INTO t1 VALUES (_utf32 0x0516); +INSERT INTO t1 VALUES (_utf32 0x0517); +INSERT INTO t1 VALUES (_utf32 0xA640); +INSERT INTO t1 VALUES (_utf32 0xA641); +INSERT INTO t1 VALUES (_utf32 0xA642); +INSERT INTO t1 VALUES (_utf32 0xA643); +INSERT INTO t1 VALUES (_utf32 0xA722); +INSERT INTO t1 VALUES (_utf32 0xA723); +INSERT INTO t1 VALUES (_utf32 0xA724); +INSERT INTO t1 VALUES (_utf32 0xA725); +INSERT INTO t1 VALUES (_utf32 0xA726); +INSERT INTO t1 VALUES (_utf32 0xA727); +INSERT INTO t1 VALUES (_utf32 0xA728); +INSERT INTO t1 VALUES (_utf32 0xA729); +INSERT INTO t1 VALUES (_utf32 0xA72A); +INSERT INTO t1 VALUES (_utf32 0xA72B); +INSERT INTO t1 VALUES (_utf32 0x2CEB); +INSERT INTO t1 VALUES (_utf32 0x2CEC); +INSERT INTO t1 VALUES (_utf32 0x2CED); +INSERT INTO t1 VALUES (_utf32 0x2CEE); +SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c +FROM t1 ORDER BY c, BINARY c; +hex(c) hex(lower(c)) hex(upper(c)) hex(weight_string(c)) c +0000023A 00002C65 0000023A 1214 Ⱥ +00002C65 00002C65 0000023A 1214 ⱥ +00000180 00000180 00000243 122D ƀ +00000243 00000180 00000243 122D Ƀ +0000023B 0000023C 0000023B 1242 Ȼ +0000023C 0000023C 0000023B 1242 ȼ +00002183 00002184 00002183 124E Ↄ +00002184 00002184 00002183 124E ↄ +00000246 00000247 00000246 1270 Ɇ +00000247 00000247 00000246 1270 ɇ +00002132 0000214E 00002132 12AE Ⅎ +0000214E 0000214E 00002132 12AE ⅎ +00002C67 00002C68 00002C67 12E3 Ⱨ +00002C68 00002C68 00002C67 12E3 ⱨ +00002C75 00002C76 00002C75 12E4 Ⱶ +00002C76 00002C76 00002C75 12E4 ⱶ +0000A726 0000A727 0000A726 12E5 Ꜧ +0000A727 0000A727 0000A726 12E5 ꜧ +00000248 00000249 00000248 130E Ɉ +00000249 00000249 00000248 130E ɉ +00002C69 00002C6A 00002C69 1328 Ⱪ +00002C6A 00002C6A 00002C69 1328 ⱪ +0000023D 0000019A 0000023D 133B Ƚ +00002C60 00002C61 00002C60 133F Ⱡ +00002C61 00002C61 00002C60 133F ⱡ +0000026B 0000026B 00002C62 1340 ɫ +00002C62 0000026B 00002C62 1340 Ɫ +00001D7D 00001D7D 00002C63 13B8 ᵽ +00002C63 00001D7D 00002C63 13B8 Ᵽ +0000024A 0000024B 0000024A 13D2 Ɋ +0000024B 0000024B 0000024A 13D2 ɋ +0000024C 0000024D 0000024C 13E4 Ɍ +0000024D 0000024D 0000024C 13E4 ɍ +0000027D 0000027D 00002C64 13FC ɽ +00002C64 0000027D 00002C64 13FC Ɽ +0000A728 0000A729 0000A728 143314AD Ꜩ +0000A729 0000A729 0000A728 143314AD ꜩ +0000023E 00002C66 0000023E 143C Ⱦ +00002C66 00002C66 0000023E 143C ⱦ +00000244 00000289 00000244 145B Ʉ +00000289 00000289 00000244 145B ʉ +00000245 0000028C 00000245 1489 Ʌ +0000028C 0000028C 00000245 1489 ʌ +0000024E 0000024F 0000024E 14A4 Ɏ +0000024F 0000024F 0000024E 14A4 ɏ +00002C6B 00002C6C 00002C6B 14C8 Ⱬ +00002C6C 00002C6C 00002C6B 14C8 ⱬ +0000A72A 0000A72B 0000A72A 14F3 Ꜫ +0000A72B 0000A72B 0000A72A 14F3 ꜫ +00000241 00000242 00000241 1506 Ɂ +00000242 00000242 00000241 1506 ɂ +0000A722 0000A723 0000A722 150E Ꜣ +0000A723 0000A723 0000A722 150E ꜣ +0000A724 0000A725 0000A724 1518 Ꜥ +0000A725 0000A725 0000A724 1518 ꜥ +00000370 00000371 00000370 154F Ͱ +00000371 00000371 00000370 154F ͱ +0000037C 0000037C 000003FE 1564 ͼ +000003FE 0000037C 000003FE 1564 Ͼ +0000037B 0000037B 000003FD 1565 ͻ +000003FD 0000037B 000003FD 1565 Ͻ +0000037D 0000037D 000003FF 1566 ͽ +000003FF 0000037D 000003FF 1566 Ͽ +00000372 00000373 00000372 156F Ͳ +00000373 00000373 00000372 156F ͳ +00002C80 00002C81 00002C80 1571 Ⲁ +00002C81 00002C81 00002C80 1571 ⲁ +00002C82 00002C83 00002C82 1572 Ⲃ +00002C83 00002C83 00002C82 1572 ⲃ +00002C84 00002C85 00002C84 1573 Ⲅ +00002C85 00002C85 00002C84 1573 ⲅ +00002C86 00002C87 00002C86 1574 Ⲇ +00002C87 00002C87 00002C86 1574 ⲇ +00002C88 00002C89 00002C88 1575 Ⲉ +00002C89 00002C89 00002C88 1575 ⲉ +00002C8A 00002C8B 00002C8A 1577 Ⲋ +00002C8B 00002C8B 00002C8A 1577 ⲋ +00002C8C 00002C8D 00002C8C 1578 Ⲍ +00002C8D 00002C8D 00002C8C 1578 ⲍ +00002C8E 00002C8F 00002C8E 1579 Ⲏ +00002C8F 00002C8F 00002C8E 1579 ⲏ +00002CEB 00002CEC 00002CEB 1591 Ⳬ +00002CEC 00002CEC 00002CEB 1591 ⳬ +00002CED 00002CEE 00002CED 15A0 Ⳮ +00002CEE 00002CEE 00002CED 15A0 ⳮ +000004FA 000004FB 000004FA 15D4 Ӻ +000004FB 000004FB 000004FA 15D4 ӻ +000004F6 000004F7 000004F6 15DC Ӷ +000004F7 000004F7 000004F6 15DC ӷ +0000A640 0000A641 0000A640 1611 Ꙁ +0000A641 0000A641 0000A640 1611 ꙁ +00000510 00000511 00000510 1613 Ԑ +00000511 00000511 00000510 1613 ԑ +0000A642 0000A643 0000A642 1618 Ꙃ +0000A643 0000A643 0000A642 1618 ꙃ +00000512 00000513 00000512 1666 Ԓ +00000513 00000513 00000512 1666 ԓ +00000514 00000515 00000514 166E Ԕ +00000515 00000515 00000514 166E ԕ +00000516 00000517 00000516 16B7 Ԗ +00000517 00000517 00000516 16B7 ԗ +000004FC 000004FD 000004FC 16F9 Ӽ +000004FD 000004FD 000004FC 16F9 ӽ +000004FE 000004FF 000004FE 16FD Ӿ +000004FF 000004FF 000004FE 16FD ӿ +000004C0 000004CF 000004C0 17B1 Ӏ +000004CF 000004CF 000004C0 17B1 ӏ +00002C00 00002C30 00002C00 17B5 Ⰰ +00002C30 00002C30 00002C00 17B5 ⰰ +00002C01 00002C31 00002C01 17B6 Ⰱ +00002C31 00002C31 00002C01 17B6 ⰱ +00002C02 00002C32 00002C02 17B7 Ⰲ +00002C32 00002C32 00002C02 17B7 ⰲ +00002C03 00002C33 00002C03 17B8 Ⰳ +00002C33 00002C33 00002C03 17B8 ⰳ +00002C04 00002C34 00002C04 17B9 Ⰴ +00002C34 00002C34 00002C04 17B9 ⰴ +00002C05 00002C35 00002C05 17BA Ⰵ +00002C35 00002C35 00002C05 17BA ⰵ +00002C06 00002C36 00002C06 17BB Ⰶ +00002C36 00002C36 00002C06 17BB ⰶ +00002C07 00002C37 00002C07 17BC Ⰷ +00002C37 00002C37 00002C07 17BC ⰷ +000010A0 00002D00 000010A0 17E5 Ⴀ +00002D00 00002D00 000010A0 17E5 ⴀ +000010A1 00002D01 000010A1 17E7 Ⴁ +00002D01 00002D01 000010A1 17E7 ⴁ +000010A2 00002D02 000010A2 17E9 Ⴂ +00002D02 00002D02 000010A2 17E9 ⴂ +000010A3 00002D03 000010A3 17EB Ⴃ +00002D03 00002D03 000010A3 17EB ⴃ +000010A4 00002D04 000010A4 17ED Ⴄ +00002D04 00002D04 000010A4 17ED ⴄ +000010A5 00002D05 000010A5 17EF Ⴅ +00002D05 00002D05 000010A5 17EF ⴅ +000010A6 00002D06 000010A6 17F1 Ⴆ +00002D06 00002D06 000010A6 17F1 ⴆ +000010A7 00002D07 000010A7 17F5 Ⴇ +00002D07 00002D07 000010A7 17F5 ⴇ +00010400 00010428 00010400 30D2 𐐀 +00010428 00010428 00010400 30D2 𐐨 +00010401 00010429 00010401 30D3 𐐁 +00010429 00010429 00010401 30D3 𐐩 +00010402 0001042A 00010402 30D4 𐐂 +0001042A 0001042A 00010402 30D4 𐐪 +00010403 0001042B 00010403 30D5 𐐃 +0001042B 0001042B 00010403 30D5 𐐫 +00010404 0001042C 00010404 30D6 𐐄 +0001042C 0001042C 00010404 30D6 𐐬 +00010405 0001042D 00010405 30D7 𐐅 +0001042D 0001042D 00010405 30D7 𐐭 +00010406 0001042E 00010406 30D8 𐐆 +0001042E 0001042E 00010406 30D8 𐐮 +00010407 0001042F 00010407 30D9 𐐇 +0001042F 0001042F 00010407 30D9 𐐯 +INSERT INTO t1 VALUES ('a'); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF)); +INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400)); +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +00000061 120F +0000006100010400 120F30D2 +000000610000FFFF 120FFBC1FFFF +000000610010FFFF 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +00010400 30D2 𐐀 +00010428 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +00010400 30D2 𐐀 +00010428 30D2 𐐨 +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select hex(`test`.`t1`.`c`) AS `hex(c)` from `test`.`t1` where (`test`.`t1`.`c` like 'a%') order by `test`.`t1`.`c` +SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c; +hex(c) hex(weight_string(c)) +00000061 120F +0000006100010400 120F30D2 +000000610000FFFF 120FFBC1FFFF +000000610010FFFF 120FFBE1FFFF +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +00010400 30D2 𐐀 +00010428 30D2 𐐨 +SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c; +hex(c) hex(weight_string(c)) c +00010400 30D2 𐐀 +00010428 30D2 𐐨 +DROP TABLE t1; +# +# End of 5.6 tests +# diff --git a/mysql-test/r/ctype_utf8mb4_innodb.result-pq b/mysql-test/r/ctype_utf8mb4_innodb.result-pq new file mode 100644 index 000000000..1eb644e87 --- /dev/null +++ b/mysql-test/r/ctype_utf8mb4_innodb.result-pq @@ -0,0 +1,2747 @@ +drop table if exists t1,t2; +# +# Start of 5.5 tests +# +set names utf8mb4; +select left(_utf8mb4 0xD0B0D0B1D0B2,1); +left(_utf8mb4 0xD0B0D0B1D0B2,1) +а +select right(_utf8mb4 0xD0B0D0B2D0B2,1); +right(_utf8mb4 0xD0B0D0B2D0B2,1) +в +select locate('he','hello'); +locate('he','hello') +1 +select locate('he','hello',2); +locate('he','hello',2) +0 +select locate('lo','hello',2); +locate('lo','hello',2) +4 +select locate('HE','hello'); +locate('HE','hello') +1 +select locate('HE','hello',2); +locate('HE','hello',2) +0 +select locate('LO','hello',2); +locate('LO','hello',2) +4 +select locate('HE','hello' collate utf8mb4_bin); +locate('HE','hello' collate utf8mb4_bin) +0 +select locate('HE','hello' collate utf8mb4_bin,2); +locate('HE','hello' collate utf8mb4_bin,2) +0 +select locate('LO','hello' collate utf8mb4_bin,2); +locate('LO','hello' collate utf8mb4_bin,2) +0 +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2); +locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2) +2 +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2); +locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2) +2 +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2); +locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2) +2 +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin); +locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin) +0 +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin); +locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin) +0 +select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1); +length(_utf8mb4 0xD0B1) bit_length(_utf8mb4 0xD0B1) char_length(_utf8mb4 0xD0B1) +2 16 1 +select 'a' like 'a'; +'a' like 'a' +1 +select 'A' like 'a'; +'A' like 'a' +1 +select 'A' like 'a' collate utf8mb4_bin; +'A' like 'a' collate utf8mb4_bin +0 +select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%'); +_utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%') +1 +select convert(_latin1'Gnter Andr' using utf8mb4) like CONVERT(_latin1'GNTER%' USING utf8mb4); +convert(_latin1'G?nter Andr?' using utf8mb4) like CONVERT(_latin1'G?NTER%' USING utf8mb4) +1 +select CONVERT(_koi8r'' USING utf8mb4) LIKE CONVERT(_koi8r'' USING utf8mb4); +CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4) +1 +select CONVERT(_koi8r'' USING utf8mb4) LIKE CONVERT(_koi8r'' USING utf8mb4); +CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4) +1 +SELECT 'a' = 'a '; +'a' = 'a ' +0 +SELECT 'a\0' < 'a'; +'a\0' < 'a' +0 +SELECT 'a\0' < 'a '; +'a\0' < 'a ' +1 +SELECT 'a\t' < 'a'; +'a\t' < 'a' +0 +SELECT 'a\t' < 'a '; +'a\t' < 'a ' +1 +SELECT 'a' = 'a ' collate utf8mb4_bin; +'a' = 'a ' collate utf8mb4_bin +1 +SELECT 'a\0' < 'a' collate utf8mb4_bin; +'a\0' < 'a' collate utf8mb4_bin +1 +SELECT 'a\0' < 'a ' collate utf8mb4_bin; +'a\0' < 'a ' collate utf8mb4_bin +1 +SELECT 'a\t' < 'a' collate utf8mb4_bin; +'a\t' < 'a' collate utf8mb4_bin +1 +SELECT 'a\t' < 'a ' collate utf8mb4_bin; +'a\t' < 'a ' collate utf8mb4_bin +1 +CREATE TABLE t1 (a char(10) character set utf8mb4 not null) ENGINE InnoDB; +INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); +SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; +hex(a) STRCMP(a,'a') STRCMP(a,'a ') +61 0 -1 +61 0 -1 +6100 0 -1 +6109 1 -1 +DROP TABLE t1; +select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); +insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es') +this is test +select insert("aa",100,1,"b"),insert("aa",1,3,"b"); +insert("aa",100,1,"b") insert("aa",1,3,"b") +aa b +select char_length(left(@a:='тест',5)), length(@a), @a; +char_length(left(@a:='тест',5)) length(@a) @a +4 8 тест +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 ENGINE InnoDB select date_format("2004-01-19 10:10:10", "%Y-%m-%d"); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +date_format("2004-01-19 10:10:10", "%Y-%m-%d") +2004-01-19 +drop table t1; +set names utf8mb4; +set LC_TIME_NAMES='fr_FR'; +create table t1 (s1 char(20) character set latin1) engine InnoDB; +insert into t1 values (date_format('2004-02-02','%M')); +select hex(s1) from t1; +hex(s1) +66E97672696572 +drop table t1; +create table t1 (s1 char(20) character set koi8r) engine InnoDB; +set LC_TIME_NAMES='ru_RU'; +insert into t1 values (date_format('2004-02-02','%M')); +insert into t1 values (date_format('2004-02-02','%b')); +insert into t1 values (date_format('2004-02-02','%W')); +insert into t1 values (date_format('2004-02-02','%a')); +select hex(s1), s1 from t1; +hex(s1) s1 +E6C5D7 Фев +E6C5D7D2C1CCD1 Февраля +F0CEC4 Пнд +F0CFCEC5C4C5CCD8CEC9CB Понедельник +drop table t1; +set LC_TIME_NAMES='en_US'; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +set names koi8r; +create table t1 (s1 char(1) character set utf8mb4) engine InnoDB; +insert into t1 values (_koi8r''); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select s1,hex(s1),char_length(s1),octet_length(s1) from t1; +s1 hex(s1) char_length(s1) octet_length(s1) + D0B0 1 2 +drop table t1; +create table t1 (s1 tinytext character set utf8mb4) engine InnoDB; +insert into t1 select repeat('a',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('a',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('a',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 +61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F +D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61 +D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F +D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F +select length(s1),char_length(s1) from t1; +length(s1) char_length(s1) +254 127 +254 127 +255 170 +255 170 +255 255 +drop table t1; +create table t1 (s1 text character set utf8mb4) engine InnoDB; +insert into t1 select repeat('a',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('a',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('a',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select length(s1),char_length(s1) from t1; +length(s1) char_length(s1) +65534 32767 +65534 32767 +65535 43690 +65535 43690 +65535 65535 +drop table t1; +SET sql_mode = default; +create table t1 (s1 char(10) character set utf8mb4) engine InnoDB; +insert ignore into t1 values (0x41FF); +Warnings: +Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +41 +drop table t1; +create table t1 (s1 varchar(10) character set utf8mb4) engine InnoDB; +insert ignore into t1 values (0x41FF); +Warnings: +Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +41 +drop table t1; +create table t1 (s1 text character set utf8mb4) engine InnoDB; +insert ignore into t1 values (0x41FF); +Warnings: +Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +41 +drop table t1; +create table t1 (a text character set utf8mb4, primary key(a(371))) engine InnoDB ROW_FORMAT=COMPACT; +Got one of the listed errors +CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4 ENGINE InnoDB; +INSERT INTO t1 VALUES ( 'test' ); +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a; +a a +test test +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test'; +a a +test test +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test'; +a a +test test +DROP TABLE t1; +create table t1 (a char(255) character set utf8mb4) engine InnoDB; +insert into t1 values('b'),('b'); +select * from t1 where a = 'b'; +a +b +b +select * from t1 where a = 'b' and a = 'b'; +a +b +b +select * from t1 where a = 'b' and a != 'b'; +a +drop table t1; +set collation_connection=utf8mb4_general_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +set names utf8mb4; +set names utf8mb4; +# Not supported by ICU +select 'вася' rlike '[[:<:]]вася[[:>:]]'; +ERROR HY000: Illegal argument to a regular expression. +# Not supported by ICU +select 'вася ' rlike '[[:<:]]вася[[:>:]]'; +ERROR HY000: Illegal argument to a regular expression. +# Not supported by ICU +select ' вася' rlike '[[:<:]]вася[[:>:]]'; +ERROR HY000: Illegal argument to a regular expression. +# Not supported by ICU +select ' вася ' rlike '[[:<:]]вася[[:>:]]'; +ERROR HY000: Illegal argument to a regular expression. +# Not supported by ICU +select 'васяz' rlike '[[:<:]]вася[[:>:]]'; +ERROR HY000: Illegal argument to a regular expression. +# Not supported by ICU +select 'zвася' rlike '[[:<:]]вася[[:>:]]'; +ERROR HY000: Illegal argument to a regular expression. +# Not supported by ICU +select 'zвасяz' rlike '[[:<:]]вася[[:>:]]'; +ERROR HY000: Illegal argument to a regular expression. +CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci) ENGINE InnoDB; +ALTER TABLE t1 ADD COLUMN b CHAR(20); +DROP TABLE t1; +set names utf8mb4; +create table t1 (a enum('aaaa','проба') character set utf8mb4) engine InnoDB; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('aaaa','проба') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('проба'); +select * from t1; +a +проба +create table t2 engine InnoDB select ifnull(a,a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ifnull(a,a)` varchar(5) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t2; +ifnull(a,a) +проба +drop table t1; +drop table t2; +create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine InnoDB; +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +insert into t1 values ('aaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values ('aaaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +c1 +1 +select c c2 from t1 where c='2'; +c2 +2 +select c c3 from t1 where c='3'; +c3 +3 +select c cx from t1 where c='x'; +cx +x +select c cy from t1 where c='y'; +cy +y +select c cz from t1 where c='z'; +cz +z +select c ca10 from t1 where c='aaaaaaaaaa'; +ca10 +aaaaaaaaaa +select c cb20 from t1 where c=repeat('b',20); +cb20 +bbbbbbbbbbbbbbbbbbbb +drop table t1; +create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=InnoDB; +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +insert into t1 values ('aaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values ('aaaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +c1 +1 +select c c2 from t1 where c='2'; +c2 +2 +select c c3 from t1 where c='3'; +c3 +3 +select c cx from t1 where c='x'; +cx +x +select c cy from t1 where c='y'; +cy +y +select c cz from t1 where c='z'; +cz +z +select c ca10 from t1 where c='aaaaaaaaaa'; +ca10 +aaaaaaaaaa +select c cb20 from t1 where c=repeat('b',20); +cb20 +bbbbbbbbbbbbbbbbbbbb +drop table t1; +create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine InnoDB; +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'aa' for key 't1.c' +insert into t1 values ('b'); +insert into t1 values ('bb'); +insert into t1 values ('bbb'); +ERROR 23000: Duplicate entry 'bb' for key 't1.c' +insert into t1 values ('а'); +insert into t1 values ('аа'); +insert into t1 values ('ааа'); +ERROR 23000: Duplicate entry 'аа' for key 't1.c' +insert into t1 values ('б'); +insert into t1 values ('бб'); +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'бб' for key 't1.c' +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +insert into t1 values ('ꪪꪪꪪ'); +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 't1.c' +drop table t1; +create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=InnoDB; +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'aa' for key 't1.c' +insert into t1 values ('b'); +insert into t1 values ('bb'); +insert into t1 values ('bbb'); +ERROR 23000: Duplicate entry 'bb' for key 't1.c' +insert into t1 values ('а'); +insert into t1 values ('аа'); +insert into t1 values ('ааа'); +ERROR 23000: Duplicate entry 'аа' for key 't1.c' +insert into t1 values ('б'); +insert into t1 values ('бб'); +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'бб' for key 't1.c' +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +insert into t1 values ('ꪪꪪꪪ'); +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 't1.c' +drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a using hash (c(1)) +) engine=InnoDB; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a using btree (c(1)) +) engine=InnoDB; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a (c(1)) +) engine=InnoDB; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))) engine InnoDB; +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +insert into t1 values ('aaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values ('aaaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +c1 +1 +select c c2 from t1 where c='2'; +c2 +2 +select c c3 from t1 where c='3'; +c3 +3 +select c cx from t1 where c='x'; +cx +x +select c cy from t1 where c='y'; +cy +y +select c cz from t1 where c='z'; +cz +z +select c ca10 from t1 where c='aaaaaaaaaa'; +ca10 +aaaaaaaaaa +select c cb20 from t1 where c=repeat('b',20); +cb20 +bbbbbbbbbbbbbbbbbbbb +drop table t1; +create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))) engine InnoDB; +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'aa' for key 't1.c' +insert into t1 values ('b'); +insert into t1 values ('bb'); +insert into t1 values ('bbb'); +ERROR 23000: Duplicate entry 'bb' for key 't1.c' +insert into t1 values ('а'); +insert into t1 values ('аа'); +insert into t1 values ('ааа'); +ERROR 23000: Duplicate entry 'аа' for key 't1.c' +insert into t1 values ('б'); +insert into t1 values ('бб'); +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'бб' for key 't1.c' +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +insert into t1 values ('ꪪꪪꪪ'); +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 't1.c' +drop table t1; +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using hash (c(1)) +) engine=InnoDB; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using btree (c(1)) +) engine=InnoDB; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a (c(1)) +) engine=InnoDB; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine=InnoDB; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine=InnoDB; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str using btree (str(2)) +) engine=InnoDB; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str using hash (str(2)) +) engine=InnoDB; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine= InnoDB; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4 ENGINE InnoDB; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES ('test'); +SELECT a FROM t1 WHERE a LIKE '%te'; +a +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 ( +subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci, +p varchar(15) character set utf8mb4 +) ENGINE= InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネット予約の会員登録をしましたところ、メールアドレスを間違えてしまい会員IDが受け取ることが出来ませんでした。間違えアドレスはtani-shun@n.vodafone.ne.jpを書き込みました。どうすればよいですか? その他、住所等は間違えありません。連絡ください。よろしくお願いします。m(__)m','040312-000057'); +INSERT INTO t1 VALUES ('aaa','bbb'); +SELECT length(subject) FROM t1; +length(subject) +3 +432 +SELECT length(subject) FROM t1 ORDER BY 1; +length(subject) +3 +432 +DROP TABLE t1; +CREATE TABLE t1 ( +id int unsigned NOT NULL auto_increment, +list_id smallint unsigned NOT NULL, +term TEXT NOT NULL, +PRIMARY KEY(id), +INDEX(list_id, term(4)) +) ENGINE=InnoDB CHARSET=utf8mb4; +INSERT INTO t1 SET list_id = 1, term = "letterc"; +INSERT INTO t1 SET list_id = 1, term = "letterb"; +INSERT INTO t1 SET list_id = 1, term = "lettera"; +INSERT INTO t1 SET list_id = 1, term = "letterd"; +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc"); +id +1 +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb"); +id +2 +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera"); +id +3 +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd"); +id +4 +DROP TABLE t1; +SET NAMES latin1; +CREATE TABLE t1 ( +id int unsigned NOT NULL auto_increment, +list_id smallint unsigned NOT NULL, +term text NOT NULL, +PRIMARY KEY(id), +INDEX(list_id, term(19)) +) ENGINE=InnoDB CHARSET=utf8mb4; +INSERT INTO t1 set list_id = 1, term = "testtest"; +INSERT INTO t1 set list_id = 1, term = "testetest"; +INSERT INTO t1 set list_id = 1, term = "testtest"; +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testtest"); +id term +1 testtest +2 testetest +3 testtest +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest"); +id term +1 testtest +2 testetest +3 testtest +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testtest"); +id term +1 testtest +2 testetest +3 testtest +DROP TABLE t1; +set names utf8mb4; +create table t1 ( +a int primary key, +b varchar(6), +index b3(b(3)) +) engine=InnoDB character set=utf8mb4; +insert into t1 values(1,'foo'),(2,'foobar'); +select * from t1 where b like 'foob%'; +a b +2 foobar +alter table t1 engine=innodb; +select * from t1 where b like 'foob%'; +a b +2 foobar +drop table t1; +create table t1 ( +a enum('петя','вася','анюта') character set utf8mb4 not null default 'анюта', +b set('петя','вася','анюта') character set utf8mb4 not null default 'анюта' +) engine InnoDB; +create table t2 engine InnoDB select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(5) DEFAULT NULL, + `b` varchar(15) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +drop table t1; +select 'c' like '\_' as want0; +want0 +0 +SELECT SUBSTR('вася',-2); +SUBSTR('вася',-2) +ся +create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci) engine InnoDB; +insert into t1 values (1, 'Test'); +select * from t1 where soundex(a) = soundex('Test'); +id a +1 Test +select * from t1 where soundex(a) = soundex('TEST'); +id a +1 Test +select * from t1 where soundex(a) = soundex('test'); +id a +1 Test +drop table t1; +select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB); +soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB) +阅000 +select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)); +hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)) +E99885303030 +select soundex(_utf8mb4 0xD091D092D093); +soundex(_utf8mb4 0xD091D092D093) +Б000 +select hex(soundex(_utf8mb4 0xD091D092D093)); +hex(soundex(_utf8mb4 0xD091D092D093)) +D091303030 +SET collation_connection='utf8mb4_general_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf8mb4_general_ci 6109 +utf8mb4_general_ci 61 +utf8mb4_general_ci 6120 +drop table t1; +select @@collation_connection; +@@collation_connection +utf8mb4_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +"BEGIN ctype_german.inc" +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf8mb4_general_ci +delete from t1; +INSERT INTO t1 VALUES ('ud'),('uf'); +INSERT INTO t1 VALUES ('od'),('of'); +INSERT INTO t1 VALUES ('e'); +INSERT INTO t1 VALUES ('ad'),('af'); +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6); +INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 61 +ä C3A4 +ad 6164 +ae 6165 +af 6166 +e 65 +o 6F +ö C3B6 +od 6F64 +oe 6F65 +of 6F66 +s 73 +ß C39F +ss 7373 +u 75 +ü C3BC +ud 7564 +ue 7565 +uf 7566 +Æ C386 +æ C3A6 +Œ C592 +œ C593 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a,ä +ad +ae +af +e +o,ö +od +oe +of +s,ß +ss +u,ü +ud +ue +uf +Æ,æ +Œ,œ +SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1); +s1 hex(s1) hex(weight_string(s1)) +a 61 0041 +ä C3A4 0041 +ad 6164 00410044 +ae 6165 00410045 +af 6166 00410046 +e 65 0045 +o 6F 004F +ö C3B6 004F +od 6F64 004F0044 +oe 6F65 004F0045 +of 6F66 004F0046 +s 73 0053 +ß C39F 0053 +ss 7373 00530053 +u 75 0055 +ü C3BC 0055 +ud 7564 00550044 +ue 7565 00550045 +uf 7566 00550046 +Æ C386 00C6 +æ C3A6 00C6 +Œ C592 0152 +œ C593 0152 +SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1); +s1 hex(s1) +ae 6165 +drop table t1; +"END ctype_german.inc" +SET collation_connection='utf8mb4_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf8mb4_bin 6109 +utf8mb4_bin 61 +utf8mb4_bin 6120 +drop table t1; +select @@collation_connection; +@@collation_connection +utf8mb4_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +CREATE TABLE t1 ( +user varchar(255) NOT NULL default '' +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('one'),('two'); +SELECT CHARSET('a'); +CHARSET('a') +utf8mb4 +SELECT user, CONCAT('<', user, '>') AS c FROM t1; +user c +one +two +DROP TABLE t1; +create table t1 (f1 varchar(1) not null) default charset utf8mb4 engine InnoDB; +insert into t1 values (''), (''); +select concat(concat(_latin1'->',f1),_latin1'<-') from t1; +concat(concat(_latin1'->',f1),_latin1'<-') +-><- +-><- +drop table t1; +select convert(_koi8r'' using utf8mb4) < convert(_koi8r'' using utf8mb4); +convert(_koi8r'?' using utf8mb4) < convert(_koi8r'?' using utf8mb4) +1 +set names latin1; +create table t1 (a varchar(10)) character set utf8mb4 engine InnoDB; +insert into t1 values ('test'); +select ifnull(a,'') from t1; +ifnull(a,'') +test +drop table t1; +select repeat(_utf8mb4'+',3) as h union select NULL; +h ++++ +NULL +select ifnull(NULL, _utf8mb4'string'); +ifnull(NULL, _utf8mb4'string') +string +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci) engine InnoDB; +insert into t1 values ('I'),('K'),('Y'); +select * from t1 where s1 < 'K' and s1 = 'Y'; +s1 +I +Y +select * from t1 where 'K' > s1 and s1 = 'Y'; +s1 +I +Y +drop table t1; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci) engine InnoDB; +insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i'); +select * from t1 where s1 > 'd' and s1 = 'CH'; +s1 +CH +Ch +ch +select * from t1 where 'd' < s1 and s1 = 'CH'; +s1 +CH +Ch +ch +select * from t1 where s1 = 'cH' and s1 <> 'ch'; +s1 +cH +select * from t1 where 'cH' = s1 and s1 <> 'ch'; +s1 +cH +drop table t1; +create table t1 (a varchar(255)) default character set utf8mb4 engine InnoDB; +insert into t1 values (1.0); +drop table t1; +create table t1 ( +id int not null, +city varchar(20) not null, +key (city(7),id) +) character set=utf8mb4 engine InnoDB; +insert into t1 values (1,'Durban North'); +insert into t1 values (2,'Durban'); +select * from t1 where city = 'Durban'; +id city +2 Durban +select * from t1 where city = 'Durban '; +id city +drop table t1; +create table t1 (x set('A', 'B') default 0) character set utf8mb4 engine InnoDB; +ERROR 42000: Invalid default value for 'x' +create table t1 (x enum('A', 'B') default 0) character set utf8mb4 engine InnoDB; +ERROR 42000: Invalid default value for 'x' +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SET NAMES UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 ( +`id` int(20) NOT NULL auto_increment, +`country` varchar(100) NOT NULL default '', +`shortcode` varchar(100) NOT NULL default '', +`operator` varchar(100) NOT NULL default '', +`momid` varchar(30) NOT NULL default '', +`keyword` varchar(160) NOT NULL default '', +`content` varchar(160) NOT NULL default '', +`second_token` varchar(160) default NULL, +`gateway_id` int(11) NOT NULL default '0', +`created` datetime NOT NULL default '0000-00-00 00:00:00', +`msisdn` varchar(15) NOT NULL default '', +PRIMARY KEY (`id`), +UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`), +KEY `IX_mobile_originated_message_keyword` (`keyword`), +KEY `IX_mobile_originated_message_created` (`created`), +KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми','ИМРИ.АФИМИМ.АЕИМИМРИМДМРИМРМРИРОР',3,'2005-06-01 17:30:43','1234567890'), +(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890'); +CREATE TABLE t2 ( +`msisdn` varchar(15) NOT NULL default '', +`operator_id` int(11) NOT NULL default '0', +`created` datetime NOT NULL default '0000-00-00 00:00:00', +UNIQUE KEY `PK_user` (`msisdn`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25'); +SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890'; +content msisdn +ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми 1234567890 +11 g 1234567890 +DROP TABLE t1,t2; +SET sql_mode = default; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (a char(20) character set utf8mb4) engine InnoDB; +insert into t1 values ('123456'),('андрей'); +alter table t1 modify a char(2) character set utf8mb4; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +select char_length(a), length(a), a from t1 order by a; +char_length(a) length(a) a +2 2 12 +2 4 ан +drop table t1; +SET sql_mode = default; +set names utf8mb4; +select 'andre%' like 'andreñ%' escape 'ñ'; +'andre%' like 'andreñ%' escape 'ñ' +1 +set names utf8mb4; +select 'a\\' like 'a\\'; +'a\\' like 'a\\' +1 +select 'aa\\' like 'a%\\'; +'aa\\' like 'a%\\' +1 +create table t1 (a char(10), key(a)) character set utf8mb4 engine InnoDB; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +a varchar(255) NOT NULL default '', +KEY a (a) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC +DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; +insert into t1 values (_utf8mb4 0xe880bd); +insert into t1 values (_utf8mb4 0x5b); +select hex(a) from t1; +hex(a) +5B +E880BD +drop table t1; +SET sql_mode = default; +set names 'latin1'; +create table t1 (a varchar(255)) default charset=utf8mb4 engine InnoDB; +select * from t1 where find_in_set('-1', a); +a +drop table t1; +create table t1 (a int) engine InnoDB; +insert into t1 values (48),(49),(50); +set names utf8mb4; +select distinct char(a) from t1; +char(a) +0 +1 +2 +drop table t1; +CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4) ENGINE InnoDB; +INSERT INTO t1 VALUES(REPEAT('a', 100)); +CREATE TEMPORARY TABLE t2 ENGINE InnoDB SELECT COALESCE(t) AS bug FROM t1; +SELECT LENGTH(bug) FROM t2; +LENGTH(bug) +100 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (item varchar(255)) default character set utf8mb4 ENGINE InnoDB; +INSERT INTO t1 VALUES (N'\\'); +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (_utf8mb4'\\'); +INSERT INTO t1 VALUES (N'Cote d\'Ivoire'); +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire'); +SELECT item FROM t1 ORDER BY item; +item +\ +\ +Cote d'Ivoire +Cote d'Ivoire +DROP TABLE t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SET NAMES utf8mb4; +CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC DEFAULT CHARSET=utf8mb4; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t1 VALUES('uu'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uU'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uu'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uuABC'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('UuABC'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uuABC'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +alter table t1 add b int; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2); +delete from t1 where b=1; +INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4); +delete from t1 where b=3; +INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +SET sql_mode = default; +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4) engine InnoDB; +insert into t1 values +('a'),('b'),(null),('ペテルグル'),('ü'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_general_ci from t1 where s1 like 'ペテ%'; +before_delete_general_ci +ペテルグル +delete from t1 where s1 = 'Y'; +select s1 as after_delete_general_ci from t1 where s1 like 'ペテ%'; +after_delete_general_ci +ペテルグル +drop table t1; +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci) engine InnoDB; +insert into t1 values +('a'),('b'),(null),('ペテルグル'),('ü'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_unicode_ci from t1 where s1 like 'ペテ%'; +before_delete_unicode_ci +ペテルグル +delete from t1 where s1 = 'Y'; +select s1 as after_delete_unicode_ci from t1 where s1 like 'ペテ%'; +after_delete_unicode_ci +ペテルグル +drop table t1; +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin) engine InnoDB; +insert into t1 values +('a'),('b'),(null),('ペテルグル'),('ü'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_bin from t1 where s1 like 'ペテ%'; +before_delete_bin +ペテルグル +delete from t1 where s1 = 'Y'; +select s1 as after_delete_bin from t1 where s1 like 'ペテ%'; +after_delete_bin +ペテルグル +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=InnoDB default character set utf8mb4 collate utf8mb4_general_ci; +insert into t1 values ('あいうえおかきくけこさしすせそ'); +insert into t1 values ('さしすせそかきくけこあいうえお'); +select a as gci1 from t1 where a like 'さしすせそかきくけこあいうえお%'; +gci1 +さしすせそかきくけこあいうえお +select a as gci2 from t1 where a like 'あいうえおかきくけこさしすせそ'; +gci2 +あいうえおかきくけこさしすせそ +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=InnoDB default character set utf8mb4 collate utf8mb4_unicode_ci; +insert into t1 values ('あいうえおかきくけこさしすせそ'); +insert into t1 values ('さしすせそかきくけこあいうえお'); +select a as uci1 from t1 where a like 'さしすせそかきくけこあいうえお%'; +uci1 +さしすせそかきくけこあいうえお +select a as uci2 from t1 where a like 'あいうえおかきくけこさしすせそ'; +uci2 +あいうえおかきくけこさしすせそ +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=InnoDB default character set utf8mb4 collate utf8mb4_bin; +insert into t1 values ('あいうえおかきくけこさしすせそ'); +insert into t1 values ('さしすせそかきくけこあいうえお'); +select a as bin1 from t1 where a like 'さしすせそかきくけこあいうえお%'; +bin1 +さしすせそかきくけこあいうえお +select a as bin2 from t1 where a like 'あいうえおかきくけこさしすせそ'; +bin2 +あいうえおかきくけこさしすせそ +drop table t1; +SET NAMES utf8mb4; +CREATE TABLE t1 (id int PRIMARY KEY, +a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '', +b int, +f varchar(128) default 'XXX', +INDEX (a(4)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +INSERT INTO t1(id, a, b) VALUES +(1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30), +(4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40), +(7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50), +(10, 'eeeee', 40), (11, 'bbbbbb', 60); +SELECT id, a, b FROM t1; +id a b +1 cccc 50 +10 eeeee 40 +11 bbbbbb 60 +2 cccc 70 +3 cccc 30 +4 cccc 30 +5 cccc 20 +6 bbbbbb 40 +7 dddd 30 +8 aaaa 10 +9 aaaa 50 +SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb'; +id a b +11 bbbbbb 60 +6 bbbbbb 40 +8 aaaa 10 +9 aaaa 50 +SELECT id, a FROM t1 WHERE a='bbbbbb'; +id a +11 bbbbbb +6 bbbbbb +SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b; +id a +6 bbbbbb +11 bbbbbb +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 ( +a CHAR(13) DEFAULT '', +INDEX(a) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES +('Käli Käli 2-4'), ('Käli Käli 2-4'), +('Käli Käli 2+4'), ('Käli Käli 2+4'), +('Käli Käli 2-6'), ('Käli Käli 2-6'); +INSERT INTO t1 SELECT * FROM t1; +CREATE TABLE t2 ( +a CHAR(13) DEFAULT '', +INDEX(a) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +INSERT INTO t2 VALUES +('Kali Kali 2-4'), ('Kali Kali 2-4'), +('Kali Kali 2+4'), ('Kali Kali 2+4'), +('Kali Kali 2-6'), ('Kali Kali 2-6'); +INSERT INTO t2 SELECT * FROM t2; +SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +a +Käli Käli 2+4 +Käli Käli 2+4 +Käli Käli 2+4 +Käli Käli 2+4 +SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +a +Kali Kali 2+4 +Kali Kali 2+4 +Kali Kali 2+4 +Kali Kali 2+4 +EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 53 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'Käli Käli 2+4') +EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 53 const 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'Käli Käli 2+4') +EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range a a 14 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` like 'Kali Kali 2+4') +EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 14 const 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` = 'Kali Kali 2+4') +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a char(255) DEFAULT '', +KEY(a(10)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +DROP TABLE t1; +CREATE TABLE t1 ( +a char(255) DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +ALTER TABLE t1 ADD KEY (a(10)); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +DROP TABLE t1; +SET NAMES latin2; +CREATE TABLE t1 ( +id int(11) NOT NULL default '0', +tid int(11) NOT NULL default '0', +val text NOT NULL, +INDEX idx(tid, val(10)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(40988,72,'VOLN ADSL'),(41009,72,'VOLN ADSL'), +(41032,72,'VOLN ADSL'),(41038,72,'VOLN ADSL'), +(41063,72,'VOLN ADSL'),(41537,72,'VOLN ADSL Office'), +(42141,72,'VOLN ADSL'),(42565,72,'VOLN ADSL Combi'), +(42749,72,'VOLN ADSL'),(44205,72,'VOLN ADSL'); +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL'; +id tid val +40988 72 VOLN ADSL +41009 72 VOLN ADSL +41032 72 VOLN ADSL +41038 72 VOLN ADSL +41063 72 VOLN ADSL +42141 72 VOLN ADSL +42749 72 VOLN ADSL +44205 72 VOLN ADSL +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN ADSL'; +id tid val +40988 72 VOLN ADSL +41009 72 VOLN ADSL +41032 72 VOLN ADSL +41038 72 VOLN ADSL +41063 72 VOLN ADSL +42141 72 VOLN ADSL +42749 72 VOLN ADSL +44205 72 VOLN ADSL +SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLN ADSL'; +id tid val +40988 72 VOLN ADSL +41009 72 VOLN ADSL +41032 72 VOLN ADSL +41038 72 VOLN ADSL +41063 72 VOLN ADSL +42141 72 VOLN ADSL +42749 72 VOLN ADSL +44205 72 VOLN ADSL +ALTER TABLE t1 DROP KEY idx; +ALTER TABLE t1 ADD KEY idx (tid,val(11)); +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLN ADSL'; +id tid val +40988 72 VOLN ADSL +41009 72 VOLN ADSL +41032 72 VOLN ADSL +41038 72 VOLN ADSL +41063 72 VOLN ADSL +42141 72 VOLN ADSL +42749 72 VOLN ADSL +44205 72 VOLN ADSL +DROP TABLE t1; +create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '') +default charset=utf8mb4 collate=utf8mb4_unicode_ci engine InnoDB; +insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65')); +explain select distinct a from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t1) AS t2; +COUNT(*) +1 +explain select a from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +SELECT COUNT(*) FROM (SELECT a FROM t1 GROUP BY a) AS t2; +COUNT(*) +1 +drop table t1; +create table t1(a char(10)) default charset utf8mb4 engine InnoDB; +insert into t1 values ('123'), ('456'); +explain +select substr(z.a,-1), z.a from t1 as y join t1 as z on y.a=z.a order by 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE y NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select substr(`test`.`z`.`a`,-(1)) AS `substr(z.a,-1)`,`test`.`z`.`a` AS `a` from `test`.`t1` `y` join `test`.`t1` `z` where (`test`.`z`.`a` = `test`.`y`.`a`) order by `substr(z.a,-1)` +select substr(z.a,-1), z.a from t1 as y join t1 as z on y.a=z.a order by 1; +substr(z.a,-1) a +3 123 +6 456 +drop table t1; +SET CHARACTER SET utf8mb4; +CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; +USE crashtest; +CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE InnoDB; +INSERT INTO crashtest VALUES ('35'), ('36'), ('37'); +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +crash +35 +37 +36 +INSERT INTO crashtest VALUES ('-1000'); +EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE crashtest NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `crashtest`.`crashtest`.`crash` AS `crash` from `crashtest`.`crashtest` order by `char(crashtest.crash)` +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +crash +-1000 +35 +37 +36 +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FFFFFC' +Warning 1300 Invalid utf8mb4 character string: 'FFFFFC' +DROP TABLE crashtest; +DROP DATABASE crashtest; +USE test; +SET CHARACTER SET default; +CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4 ENGINE InnoDB; +INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa'); +SELECT id FROM t1; +id +aa +aa +xxx +yyy +SELECT DISTINCT id FROM t1; +id +aa +xxx +yyy +SELECT DISTINCT id FROM t1 ORDER BY id; +id +aa +xxx +yyy +DROP TABLE t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 ( +a varchar(26) not null +) default character set utf8mb4 ENGINE InnoDB; +insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz'); +select * from t1; +a +abcdefghijklmnopqrstuvwxyz +alter table t1 change a a varchar(20) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcdefghijklmnopqrst +alter table t1 change a a char(15) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcdefghijklmno +alter table t1 change a a char(10) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcdefghij +alter table t1 change a a varchar(5) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcde +drop table t1; +create table t1 ( +a varchar(4000) not null +) default character set utf8mb4 engine InnoDB; +insert into t1 values (repeat('a',4000)); +alter table t1 change a a varchar(3000) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select length(a) from t1; +length(a) +3000 +drop table t1; +SET sql_mode = default; +set names utf8mb4; +select hex(char(1 using utf8mb4)); +hex(char(1 using utf8mb4)) +01 +select char(0xd1,0x8f using utf8mb4); +char(0xd1,0x8f using utf8mb4) +я +select char(0xd18f using utf8mb4); +char(0xd18f using utf8mb4) +я +select char(53647 using utf8mb4); +char(53647 using utf8mb4) +я +select char(0xff,0x8f using utf8mb4); +char(0xff,0x8f using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +select convert(char(0xff,0x8f) using utf8mb4); +convert(char(0xff,0x8f) using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +set sql_mode=traditional; +select char(0xff,0x8f using utf8mb4); +char(0xff,0x8f using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +select char(195 using utf8mb4); +char(195 using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'C3' +select char(196 using utf8mb4); +char(196 using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'C4' +select char(2557 using utf8mb4); +char(2557 using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FD' +select convert(char(0xff,0x8f) using utf8mb4); +convert(char(0xff,0x8f) using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +select hex(convert(char(2557 using latin1) using utf8mb4)); +hex(convert(char(2557 using latin1) using utf8mb4)) +09C3BD +select hex(char(195)); +hex(char(195)) +C3 +select hex(char(196)); +hex(char(196)) +C4 +select hex(char(2557)); +hex(char(2557)) +09FD +set names utf8mb4; +create table t1 (a char(1)) default character set utf8mb4 engine InnoDB; +create table t2 (a char(1)) default character set utf8mb4 engine InnoDB; +insert into t1 values('a'),('a'),(0xE38182),(0xE38182); +insert into t1 values('i'),('i'),(0xE38184),(0xE38184); +select * from t1 union distinct select * from t2; +a +a +i +あ +い +drop table t1,t2; +set names utf8mb4; +create table t1 (a char(10), b varchar(10)) engine InnoDB; +insert into t1 values ('bar','kostja'); +insert into t1 values ('kostja','bar'); +prepare my_stmt from "select * from t1 where a=?"; +set @a:='bar'; +execute my_stmt using @a; +a b +bar kostja +set @a:='kostja'; +execute my_stmt using @a; +a b +kostja bar +set @a:=null; +execute my_stmt using @a; +a b +drop table if exists t1; +drop table if exists t1; +drop view if exists v1, v2; +set names utf8mb4; +create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci) engine InnoDB; +insert into t1 values('t1_val'); +create view v1 as select 'v1_val' as col1; +select coercibility(col1), collation(col1) from v1; +coercibility(col1) collation(col1) +4 utf8mb4_0900_ai_ci +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1)from v2; +coercibility(col1) collation(col1) +2 utf8mb4_unicode_ci +2 utf8mb4_unicode_ci +drop view v1, v2; +create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1; +select coercibility(col1), collation(col1) from v1; +coercibility(col1) collation(col1) +0 utf8mb4_swedish_ci +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1) from v2; +coercibility(col1) collation(col1) +0 utf8mb4_swedish_ci +0 utf8mb4_swedish_ci +drop view v1, v2; +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int) engine InnoDB; +insert into t1 values ('a',1); +select concat(a, if(b>10, N'x', N'y')) from t1; +concat(a, if(b>10, N'x', N'y')) +ay +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +select concat(a, if(b>10, N'æ', N'ß')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int) engine InnoDB; +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1; +concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) +ay +select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'ß')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int) engine InnoDB; +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1; +concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) +ay +select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int) engine InnoDB; +insert into t1 values ('a',1); +select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1; +concat(a, if(b>10, 'x' 'x', 'y' 'y')) +ayy +select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,COERCIBLE) for operation 'concat' +drop table t1; +CREATE TABLE t1 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8mb4 NOT NULL, +PRIMARY KEY (colA) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar'); +CREATE TABLE t2 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8mb4 NOT NULL, +KEY bad (colA,colB(3)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); +SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB +WHERE t1.colA < 3; +colA colB colA colB +1 foo 1 foo +2 foo bar 2 foo bar +DROP TABLE t1, t2; +SELECT 'н1234567890' UNION SELECT _binary '1'; +н1234567890 +н1234567890 +1 +SELECT 'н1234567890' UNION SELECT 1; +н1234567890 +н1234567890 +1 +SELECT '1' UNION SELECT 'н1234567890'; +1 +1 +н1234567890 +SELECT 1 UNION SELECT 'н1234567890'; +1 +1 +н1234567890 +CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4 ENGINE InnoDB; +CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT) ENGINE InnoDB; +INSERT INTO t1 (c) VALUES ('н1234567890'); +INSERT INTO t2 (b, i) VALUES ('1', 1); +SELECT c FROM t1 UNION SELECT b FROM t2; +c +н1234567890 +1 +SELECT c FROM t1 UNION SELECT i FROM t2; +c +н1234567890 +1 +SELECT b FROM t2 UNION SELECT c FROM t1; +b +1 +н1234567890 +SELECT i FROM t2 UNION SELECT c FROM t1; +i +1 +н1234567890 +DROP TABLE t1, t2; +set sql_mode=traditional; +select hex(char(0xFF using utf8mb4)); +hex(char(0xFF using utf8mb4)) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(convert(0xFF using utf8mb4)); +hex(convert(0xFF using utf8mb4)) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 0x616263FF); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 B'001111111111'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select (_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +set sql_mode=default; +select hex(char(0xFF using utf8mb4)); +hex(char(0xFF using utf8mb4)) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(convert(0xFF using utf8mb4)); +hex(convert(0xFF using utf8mb4)) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 0x616263FF); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 B'001111111111'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select (_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE InnoDB; +INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70000 1092 +70001 1085 +70002 1065 +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70000 1092 +70001 1085 +70002 1065 +ALTER TABLE t1 ADD UNIQUE (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70000 1092 +70001 1085 +70002 1065 +DROP INDEX b ON t1; +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70000 1092 +70001 1085 +70002 1065 +ALTER TABLE t1 ADD INDEX (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70000 1092 +70001 1085 +70002 1065 +DROP TABLE t1; +# +# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +predicted_order int NOT NULL, +utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4 ENGINE InnoDB; +INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682'); +SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci; +predicted_order hex(utf8mb4_encoding) +1 E0B7B4 +2 E0B685 +3 E0B686 +4 E0B687 +5 E0B688 +6 E0B689 +7 E0B68A +8 E0B68B +9 E0B68C +10 E0B68D +11 E0B68E +12 E0B68F +13 E0B690 +14 E0B691 +15 E0B692 +16 E0B693 +17 E0B694 +18 E0B695 +19 E0B696 +20 E0B682 +21 E0B683 +22 E0B69A +23 E0B69AE0B78F +24 E0B69AE0B790 +25 E0B69AE0B791 +26 E0B69AE0B792 +27 E0B69AE0B793 +28 E0B69AE0B794 +29 E0B69AE0B796 +30 E0B69AE0B798 +31 E0B69AE0B7B2 +32 E0B69AE0B79F +33 E0B69AE0B7B3 +34 E0B69AE0B799 +35 E0B69AE0B79A +36 E0B69AE0B79B +37 E0B69AE0B79C +38 E0B69AE0B79D +39 E0B69AE0B79E +40 E0B69AE0B78A +41 E0B69B +42 E0B69C +43 E0B69D +44 E0B69E +45 E0B69F +46 E0B6A0 +47 E0B6A1 +48 E0B6A2 +49 E0B6A3 +50 E0B6A5 +51 E0B6A4 +52 E0B6A6 +53 E0B6A7 +54 E0B6A8 +55 E0B6A9 +56 E0B6AA +57 E0B6AB +58 E0B6AC +59 E0B6AD +60 E0B6AE +61 E0B6AF +62 E0B6B0 +63 E0B6B1 +64 E0B6B3 +65 E0B6B4 +66 E0B6B5 +67 E0B6B6 +68 E0B6B7 +69 E0B6B8 +70 E0B6B9 +71 E0B6BA +72 E0B6BB +73 E0B6BBE0B78AE2808D +74 E0B6BD +75 E0B780 +76 E0B781 +77 E0B782 +78 E0B783 +79 E0B784 +80 E0B785 +81 E0B786 +82 E0B78F +83 E0B790 +84 E0B791 +85 E0B792 +86 E0B793 +87 E0B794 +88 E0B796 +89 E0B798 +90 E0B7B2 +91 E0B79F +92 E0B7B3 +93 E0B799 +94 E0B79A +95 E0B79B +96 E0B79C +97 E0B79D +98 E0B79E +99 E0B78A +100 E0B78AE2808DE0B6BA +101 E0B78AE2808DE0B6BB +DROP TABLE t1; +# +# Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns +# +create table t1 (utf8mb4 char(1) character set utf8mb4) engine InnoDB; +Testing [F0][90..BF][80..BF][80..BF] +insert into t1 values (0xF0908080); +insert into t1 values (0xF0BFBFBF); +insert ignore into t1 values (0xF08F8080); +Warnings: +Warning 1366 Incorrect string value: '\xF0\x8F\x80\x80' for column 'utf8mb4' at row 1 +select hex(utf8mb4) from t1; +hex(utf8mb4) + +F0908080 +F0BFBFBF +delete from t1; +Testing [F2..F3][80..BF][80..BF][80..BF] +insert into t1 values (0xF2808080); +insert into t1 values (0xF2BFBFBF); +select hex(utf8mb4) from t1; +hex(utf8mb4) +F2808080 +F2BFBFBF +delete from t1; +Testing [F4][80..8F][80..BF][80..BF] +insert into t1 values (0xF4808080); +insert into t1 values (0xF48F8080); +insert ignore into t1 values (0xF4908080); +Warnings: +Warning 1366 Incorrect string value: '\xF4\x90\x80\x80' for column 'utf8mb4' at row 1 +select hex(utf8mb4) from t1; +hex(utf8mb4) + +F4808080 +F48F8080 +drop table t1; +# +# Check strnxfrm() with odd length +# +set max_sort_length=5; +select @@max_sort_length; +@@max_sort_length +5 +create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine InnoDB; +insert into t1 values ('a'),('b'),('c'); +select * from t1 order by a; +a +a +b +c +alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin; +select * from t1 order by a; +a +a +b +c +drop table t1; +set max_sort_length=default; +# +# Bug#26180: Can't add columns to tables created with utf8mb4 text indexes +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +clipid INT NOT NULL, +Tape TINYTEXT, +PRIMARY KEY (clipid), +KEY tape(Tape(255)) +) CHARACTER SET=utf8mb4 ROW_FORMAT=DYNAMIC ENGINE=InnoDB; +Warnings: +Warning 1071 Specified key was too long; max key length is 255 bytes +ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `clipid` int NOT NULL, + `mos` tinyint DEFAULT '0', + `Tape` tinytext, + PRIMARY KEY (`clipid`), + KEY `tape` (`Tape`(63)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +SET sql_mode = default; +# +# Testing 4-byte values. +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +u_decimal int NOT NULL, +utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4 ENGINE InnoDB; +INSERT INTO t1 VALUES (119040, x'f09d8480'), +# G CLEF +(119070, x'f09d849e'), +# HALF NOTE +(119134, x'f09d859e'), +# MUSICAL SYMBOL CROIX +(119247, x'f09d878f'), +# MATHEMATICAL BOLD ITALIC CAPITAL DELTA +(120607, x'f09d9c9f'), +# SANS-SERIF BOLD ITALIC CAPITAL PI +(120735, x'f09d9e9f'), +# (last 4 byte character) +(1114111, x'f48fbfbf'), +# VARIATION SELECTOR-256 +(917999, x'f3a087af'); +INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480'); +INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab'); +INSERT IGNORE INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0'); +Warnings: +Warning 1265 Data truncated for column 'utf8mb4_encoding' at row 1 +SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding; +u_decimal hex(utf8mb4_encoding) +1114111 F48FBFBF +119040 F09D8480 +119070 F09D849E +119070 F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480 +119070 F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480 +119134 F09D859E +119247 F09D878F +120607 F09D9C9F +120735 F09D9E9F +65131 EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB +917999 F3A087AF +INSERT IGNORE INTO t1 VALUES (1114111, x'f5808080'); +Warnings: +Warning 1366 Incorrect string value: '\xF5\x80\x80\x80' for column 'utf8mb4_encoding' at row 1 +SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE +table_name= 't1' AND column_name= 'utf8mb4_encoding'; +CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH +10 40 +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 ( +u_decimal int NOT NULL, +utf8mb3_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb3 ENGINE InnoDB; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +INSERT INTO t2 VALUES (42856, x'ea9da8'); +INSERT INTO t2 VALUES (65131, x'efb9ab'); +INSERT IGNORE INTO t2 VALUES (1114111, x'f48fbfbf'); +Warnings: +Warning 1366 Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb3_encoding' at row 1 +SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE +table_name= 't2' AND column_name= 'utf8mb3_encoding'; +CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH +10 30 +UPDATE IGNORE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856; +Warnings: +Warning 1366 Incorrect string value: '\xF4\x8F\xBF\xBD' for column 'utf8mb3_encoding' at row 1 +UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856; +SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1; +HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) +EA9DA8 +EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8 +F09D8480EA9DA8 +F09D849EEA9DA8 +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8 +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8 +F09D859EEA9DA8 +F09D878FEA9DA8 +F09D9C9FEA9DA8 +F09D9E9FEA9DA8 +F3A087AFEA9DA8 +F48FBFBFEA9DA8 +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warnings: +SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2; +HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) + +EA9DA8 +EFB9AB +EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB +EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEA9DA8 +EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9ABEFB9AB +F09D8480 +F09D8480EA9DA8 +F09D8480EFB9AB +F09D849E +F09D849EEA9DA8 +F09D849EEFB9AB +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480 +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480 +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8 +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EA9DA8 +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB +F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480EFB9AB +F09D859E +F09D859EEA9DA8 +F09D859EEFB9AB +F09D878F +F09D878FEA9DA8 +F09D878FEFB9AB +F09D9C9F +F09D9C9FEA9DA8 +F09D9C9FEFB9AB +F09D9E9F +F09D9E9FEA9DA8 +F09D9E9FEFB9AB +F3A087AF +F3A087AFEA9DA8 +F3A087AFEFB9AB +F48FBFBF +F48FBFBFEA9DA8 +F48FBFBFEFB9AB +SELECT count(*) FROM t1, t2 +WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding; +count(*) +23 +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +ALTER TABLE t1 CONVERT TO CHARACTER SET utf8; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `u_decimal` int NOT NULL, + `utf8mb4_encoding` varchar(10) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1; +u_decimal hex(utf8mb4_encoding) utf8mb4_encoding +1114111 +1114111 3F ? +119040 3F ? +119070 3F ? +119070 3F3F3F3F3F3F3F3F3F3F ?????????? +119070 3F3F3F3F3F3F3F3F3F3F ?????????? +119134 3F ? +119247 3F ? +120607 3F ? +120735 3F ? +65131 EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB ﹫?????﹫﹫?﹫ +917999 3F ? +SET sql_mode = default; +ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `u_decimal` int NOT NULL, + `utf8mb3_encoding` varchar(10) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT u_decimal,hex(utf8mb3_encoding) FROM t2; +u_decimal hex(utf8mb3_encoding) +1114111 +42856 EA9DA8 +65131 EFB9AB +ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `u_decimal` int NOT NULL, + `utf8mb3_encoding` varchar(10) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +SELECT u_decimal,hex(utf8mb3_encoding) FROM t2; +u_decimal hex(utf8mb3_encoding) +1114111 +42856 EA9DA8 +65131 EFB9AB +ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `u_decimal` int NOT NULL, + `utf8mb4_encoding` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +SELECT u_decimal,hex(utf8mb4_encoding) FROM t1; +u_decimal hex(utf8mb4_encoding) +1114111 +1114111 3F +119040 3F +119070 3F +119070 3F3F3F3F3F3F3F3F3F3F +119070 3F3F3F3F3F3F3F3F3F3F +119134 3F +119247 3F +120607 3F +120735 3F +65131 EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB +917999 3F +ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `u_decimal` int NOT NULL, + `utf8mb4_encoding` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +SELECT u_decimal,hex(utf8mb4_encoding) FROM t1; +u_decimal hex(utf8mb4_encoding) +1114111 +1114111 3F +119040 3F +119070 3F +119070 3F3F3F3F3F3F3F3F3F3F +119070 3F3F3F3F3F3F3F3F3F3F +119134 3F +119247 3F +120607 3F +120735 3F +65131 EFB9AB3F3F3F3F3FEFB9ABEFB9AB3FEFB9AB +917999 3F +ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `u_decimal` int NOT NULL, + `utf8mb3_encoding` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +SELECT u_decimal,hex(utf8mb3_encoding) FROM t2; +u_decimal hex(utf8mb3_encoding) +1114111 +42856 EA9DA8 +65131 EFB9AB +DROP TABLE IF EXISTS t3; +CREATE TABLE t3 ( +u_decimal int NOT NULL, +utf8mb3_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8 ENGINE InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 SELECT * FROM t1; +DROP TABLE IF EXISTS t4; +CREATE TABLE t4 ( +u_decimal int NOT NULL, +utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4 ENGINE InnoDB; +INSERT INTO t3 SELECT * FROM t2; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE t4; +# +# Testing that mixing utf8 and utf8mb4 collations returns utf8mb4 +# +SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b')); +CHARSET(CONCAT(_utf8mb4'a',_utf8'b')) +utf8mb4 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL) ENGINE InnoDB; +INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf'); +SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0; +CONCAT(utf8mb4, _utf8 x'ea9da8') +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL) ENGINE InnoDB; +Warnings: +Warning 1287 'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead +INSERT INTO t2 VALUES (x'ea9da8'); +SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1; +HEX(CONCAT(utf8mb4, utf8mb3)) +EA9DA8EA9DA8 +F48FBFBFEA9DA8 +SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1; +CHARSET(CONCAT(utf8mb4, utf8mb3)) +utf8mb4 +CREATE TEMPORARY TABLE t3 ENGINE InnoDB AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `utf8mb4` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `utf8mb3` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `concat(utf8mb4,utf8mb3)` varchar(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TEMPORARY TABLE t3; +SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3; +utf8mb4 utf8mb3 +􏿿 Ꝩ +SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3; +utf8mb4 utf8mb3 +Ꝩ Ꝩ +SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3; +utf8mb4 utf8mb3 +DROP TABLE t1; +DROP TABLE t2; +# +# Check that mixing utf8mb4 with an invalid utf8 constant returns error +# +CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4) ENGINE InnoDB; +INSERT INTO t1 VALUES (x'f48fbfbf'); +SELECT CONCAT(utf8mb4, _utf8 '') FROM t1; +ERROR HY000: Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +SELECT CONCAT('a', _utf8 '') FROM t1; +ERROR HY000: Illegal mix of collations (utf8mb4_0900_ai_ci,COERCIBLE) and (utf8_general_ci,COERCIBLE) for operation 'concat' +DROP TABLE t1; +# +# End of 5.5 tests +# +# +# End of tests +# +create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=innodb; +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +insert into t1 values ('aaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values ('aaaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 't1.c' +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +c1 +1 +select c c2 from t1 where c='2'; +c2 +2 +select c c3 from t1 where c='3'; +c3 +3 +select c cx from t1 where c='x'; +cx +x +select c cy from t1 where c='y'; +cy +y +select c cz from t1 where c='z'; +cz +z +select c ca10 from t1 where c='aaaaaaaaaa'; +ca10 +aaaaaaaaaa +select c cb20 from t1 where c=repeat('b',20); +cb20 +bbbbbbbbbbbbbbbbbbbb +drop table t1; +create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=innodb; +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'aa' for key 't1.c' +insert into t1 values ('b'); +insert into t1 values ('bb'); +insert into t1 values ('bbb'); +ERROR 23000: Duplicate entry 'bb' for key 't1.c' +insert into t1 values ('а'); +insert into t1 values ('аа'); +insert into t1 values ('ааа'); +ERROR 23000: Duplicate entry 'аа' for key 't1.c' +insert into t1 values ('б'); +insert into t1 values ('бб'); +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'бб' for key 't1.c' +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +insert into t1 values ('ꪪꪪꪪ'); +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 't1.c' +drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a (c(1)) +) engine=innodb; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a (c(1)) +) engine=innodb; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('ñ'); +insert into t1 values ('ññ'); +ERROR 23000: Duplicate entry 'Ã' for key 't1.a' +insert into t1 values ('ñññ'); +ERROR 23000: Duplicate entry 'Ã' for key 't1.a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +ñ +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='ñ'; +c_a +ñ +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine=innodb; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine=innodb; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +SET NAMES utf8mb4; +CREATE TABLE t1 ( +subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci, +p varchar(15) character set utf8mb4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('谷川俊二と申しますが、インターネット予約の会員登録をしましたところ、メールアドレスを間違えてしまい会員IDが受け取ることが出来ませんでした。間違えアドレスはtani-shun@n.vodafone.ne.jpを書き込みました。どうすればよいですか? その他、住所等は間違えありません。連絡ください。よろしくお願いします。m(__)m','040312-000057'); +INSERT INTO t1 VALUES ('aaa','bbb'); +SELECT length(subject) FROM t1; +length(subject) +432 +3 +SELECT length(subject) FROM t1 ORDER BY 1; +length(subject) +3 +432 +DROP TABLE t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_general_ci; +insert into t1 values ('あいうえおかきくけこさしすせそ'); +insert into t1 values ('さしすせそかきくけこあいうえお'); +select a as gci1 from t1 where a like 'さしすせそかきくけこあいうえお%'; +gci1 +さしすせそかきくけこあいうえお +select a as gci2 from t1 where a like 'あいうえおかきくけこさしすせそ'; +gci2 +あいうえおかきくけこさしすせそ +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_unicode_ci; +insert into t1 values ('あいうえおかきくけこさしすせそ'); +insert into t1 values ('さしすせそかきくけこあいうえお'); +select a as uci1 from t1 where a like 'さしすせそかきくけこあいうえお%'; +uci1 +さしすせそかきくけこあいうえお +select a as uci2 from t1 where a like 'あいうえおかきくけこさしすせそ'; +uci2 +あいうえおかきくけこさしすせそ +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_bin; +insert into t1 values ('あいうえおかきくけこさしすせそ'); +insert into t1 values ('さしすせそかきくけこあいうえお'); +select a as bin1 from t1 where a like 'さしすせそかきくけこあいうえお%'; +bin1 +さしすせそかきくけこあいうえお +select a as bin2 from t1 where a like 'あいうえおかきくけこさしすせそ'; +bin2 +あいうえおかきくけこさしすせそ +drop table t1; +set names utf8mb4; +create table t1 ( +a int primary key, +b varchar(6), +index b3(b(3)) +) engine=innodb character set=utf8mb4; +insert into t1 values(1,'foo'),(2,'foobar'); +select * from t1 where b like 'foob%'; +a b +2 foobar +alter table t1 engine=innodb; +select * from t1 where b like 'foob%'; +a b +2 foobar +drop table t1; +CREATE TABLE t1 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8mb4 NOT NULL, +PRIMARY KEY (colA) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar'); +CREATE TABLE t2 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8mb4 NOT NULL, +KEY bad (colA,colB(3)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); +SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB +WHERE t1.colA < 3; +colA colB colA colB +1 foo 1 foo +2 foo bar 2 foo bar +DROP TABLE t1, t2; diff --git a/mysql-test/r/delete.result-pq b/mysql-test/r/delete.result-pq new file mode 100644 index 000000000..b46cf17a2 --- /dev/null +++ b/mysql-test/r/delete.result-pq @@ -0,0 +1,868 @@ +drop table if exists t1,t2,t3,t11,t12; +CREATE TABLE t1 (a tinyint(3), b tinyint(5)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1); +INSERT LOW_PRIORITY INTO t1 VALUES (1,2); +INSERT INTO t1 VALUES (1,3); +DELETE from t1 where a=1 limit 1; +DELETE LOW_PRIORITY from t1 where a=1; +INSERT INTO t1 VALUES (1,1); +DELETE from t1; +LOCK TABLE t1 write; +INSERT INTO t1 VALUES (1,2); +DELETE from t1; +UNLOCK TABLES; +INSERT INTO t1 VALUES (1,2); +SET AUTOCOMMIT=0; +DELETE from t1; +SET AUTOCOMMIT=1; +drop table t1; +create table t1 ( +a bigint not null, +b bigint not null default 0, +c bigint not null default 0, +d bigint not null default 0, +e bigint not null default 0, +f bigint not null default 0, +g bigint not null default 0, +h bigint not null default 0, +i bigint not null default 0, +j bigint not null default 0, +primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23); +delete from t1 where a=26; +drop table t1; +create table t1 ( +a bigint not null, +b bigint not null default 0, +c bigint not null default 0, +d bigint not null default 0, +e bigint not null default 0, +f bigint not null default 0, +g bigint not null default 0, +h bigint not null default 0, +i bigint not null default 0, +j bigint not null default 0, +primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); +delete from t1 where a=27; +drop table t1; +CREATE TABLE `t1` ( +`i` int(10) NOT NULL default '0', +`i2` int(10) NOT NULL default '0', +PRIMARY KEY (`i`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DELETE FROM t1 USING t1 WHERE post='1'; +ERROR 42S22: Unknown column 'post' in 'where clause' +drop table t1; +CREATE TABLE t1 ( +bool char(0) default NULL, +not_null varchar(20) binary NOT NULL default '', +misc integer not null, +PRIMARY KEY (not_null) +) ; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7); +select * from t1 where misc > 5 and bool is null; +bool not_null misc +NULL c 6 +NULL d 7 +delete from t1 where misc > 5 and bool is null; +select * from t1 where misc > 5 and bool is null; +bool not_null misc +select count(*) from t1; +count(*) +2 +delete from t1 where 1 > 2; +select count(*) from t1; +count(*) +2 +delete from t1 where 3 > 2; +select count(*) from t1; +count(*) +0 +drop table t1; +create table t1 (a int not null auto_increment primary key, b char(32)); +insert into t1 (b) values ('apple'), ('apple'); +select * from t1; +a b +1 apple +2 apple +delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a; +select * from t1; +a b +1 apple +drop table t1; +create table t11 (a int NOT NULL, b int, primary key (a)); +create table t12 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t11 values (0, 10),(1, 11),(2, 12); +insert into t12 values (33, 10),(0, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +select * from t11; +a b +0 10 +1 11 +2 12 +select * from t12; +a b +0 11 +2 12 +33 10 +select * from t2; +a b +1 21 +2 12 +3 23 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +ERROR 21000: Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +2 12 +select * from t12; +a b +0 11 +2 12 +33 10 +delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +Warnings: +Warning 1242 Subquery returns more than 1 row +Warning 1242 Subquery returns more than 1 row +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +select * from t11; +a b +0 10 +1 11 +select * from t12; +a b +0 11 +33 10 +insert into t11 values (2, 12); +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +ERROR 21000: Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +2 12 +delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +Warnings: +Warning 1242 Subquery returns more than 1 row +Warning 1242 Subquery returns more than 1 row +analyze table t11,t12,t2; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +test.t2 analyze status OK +select * from t11; +a b +0 10 +1 11 +drop table t11, t12, t2; +# sql_safe_updates mode with multi-table DELETE +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES(10),(20); +CREATE TABLE t2(b INTEGER); +INSERT INTO t2 VALUES(10),(20); +SET SESSION sql_safe_updates=1; +EXPLAIN DELETE t2 FROM t1 JOIN t2 WHERE t1.a = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 DELETE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 delete `test`.`t2` from `test`.`t1` join `test`.`t2` where true +DELETE t2 FROM t1 JOIN t2 WHERE t1.a = 10; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates=default; +DROP TABLE t1, t2; +create table t1 (a int, b int, unique key (a), key (b)); +insert into t1 values (3, 3), (7, 7); +delete t1 from t1 where a = 3; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +a b +7 7 +drop table t1; +CREATE TABLE t1 ( a int PRIMARY KEY ); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +INSERT INTO t1 VALUES (0),(1),(2); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; +SELECT * FROM t1; +a +0 +2 +DROP TABLE t1; +create table t1 (a int); +delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5; +delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5; +drop table t1; +create table t1(f1 int primary key); +insert into t1 values (4),(3),(1),(2); +delete from t1 where (@a:= f1) order by f1 limit 1; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a; +@a +1 +drop table t1; +CREATE TABLE t1 ( +`date` date , +`time` time , +`seq` int(10) unsigned NOT NULL auto_increment, +PRIMARY KEY (`seq`), +KEY `seq` (`seq`), +KEY `time` (`time`), +KEY `date` (`date`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1; +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (a int not null,b int not null); +CREATE TABLE t2 (a int not null, b int not null, primary key (a,b)); +CREATE TABLE t3 (a int not null, b int not null, primary key (a,b)); +insert into t1 values (1,1),(2,1),(1,3); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(1,3); +select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b order by t1.a,t1.b; +a b a b a b +1 1 1 1 1 1 +1 3 1 1 1 3 +2 1 2 2 2 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +select * from t3; +a b +drop table t1,t2,t3; +create table t1(a date not null); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +select * from t1 where a is null; +a +0000-00-00 +delete from t1 where a is null; +select count(*) from t1; +count(*) +0 +drop table t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +DELETE FROM t1 ORDER BY x; +ERROR 42S22: Unknown column 'x' in 'order clause' +DELETE FROM t1 ORDER BY t2.x; +ERROR 42S22: Unknown column 't2.x' in 'order clause' +DELETE FROM t1 ORDER BY (SELECT x); +ERROR 42S22: Unknown column 'x' in 'field list' +DROP TABLE t1; +CREATE TABLE t1 ( +a INT +); +CREATE TABLE t2 ( +a INT +); +CREATE DATABASE db1; +CREATE TABLE db1.t1 ( +a INT +); +INSERT INTO db1.t1 (a) SELECT * FROM t1; +CREATE DATABASE db2; +CREATE TABLE db2.t1 ( +a INT +); +INSERT INTO db2.t1 (a) SELECT * FROM t2; +DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING t1, t2 alias WHERE t1.a = alias.a' at line 1 +DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a; +DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a; +DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a; +ERROR 42S02: Unknown table 't2' in MULTI DELETE +DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1 +DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +ERROR 42S02: Unknown table 'alias' in MULTI DELETE +DELETE FROM t1 USING t1 WHERE a = 1; +SELECT * FROM t1; +a +DELETE FROM t1 alias USING t1 alias WHERE a = 2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING t1 alias WHERE a = 2' at line 1 +SELECT * FROM t1; +a +DROP TABLE t1, t2; +DROP DATABASE db1; +DROP DATABASE db2; +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; +ERROR 42000: Incorrect number of arguments for FUNCTION test.f1; expected 0, got 1 +DROP TABLE t1; +DROP FUNCTION f1; +# +# Bug #49552 : sql_buffer_result cause crash + not found records +# in multitable delete/subquery +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SET SESSION SQL_BUFFER_RESULT=1; +DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1; +SET SESSION SQL_BUFFER_RESULT=DEFAULT; +SELECT * FROM t1; +a +DROP TABLE t1; +End of 5.0 tests +DROP DATABASE IF EXISTS db1; +DROP DATABASE IF EXISTS db2; +DROP DATABASE IF EXISTS db3; +DROP DATABASE IF EXISTS db4; +DROP TABLE IF EXISTS t1, t2; +DROP PROCEDURE IF EXISTS count; +USE test; +CREATE DATABASE db1; +CREATE DATABASE db2; +CREATE TABLE db1.t1 (a INT, b INT); +INSERT INTO db1.t1 VALUES (1,1),(2,2),(3,3); +CREATE TABLE db1.t2 AS SELECT * FROM db1.t1; +CREATE TABLE db2.t1 AS SELECT * FROM db1.t2; +CREATE TABLE db2.t2 AS SELECT * FROM db2.t1; +CREATE TABLE t1 AS SELECT * FROM db2.t2; +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE PROCEDURE count_rows() +BEGIN +SELECT COUNT(*) AS "COUNT(db1.t1)" FROM db1.t1; +SELECT COUNT(*) AS "COUNT(db1.t2)" FROM db1.t2; +SELECT COUNT(*) AS "COUNT(db2.t1)" FROM db2.t1; +SELECT COUNT(*) AS "COUNT(db2.t2)" FROM db2.t2; +SELECT COUNT(*) AS "COUNT(test.t1)" FROM test.t1; +SELECT COUNT(*) AS "COUNT(test.t2)" FROM test.t2; +END| +CREATE DATABASE db3; +USE db3; +DROP DATABASE db3; +SELECT * FROM t1; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1 AS a1, db2.t2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db1.t1, db2.t2 AS a2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 3D000: No database selected +DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1; +ERROR 3D000: No database selected +DELETE a1 FROM db1.a1, db2.t2 AS a1; +ERROR 3D000: No database selected +DELETE a1 FROM a1, db1.t1 AS a1; +ERROR 3D000: No database selected +DELETE t1 FROM db1.t1, db2.t1 AS a1; +ERROR 3D000: No database selected +DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2; +ERROR 3D000: No database selected +DELETE t1 FROM db1.t1, db2.t1; +ERROR 3D000: No database selected +USE test; +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE a1,a2 FROM db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE a1,a2 FROM db1.t1 AS a1, db2.t2; +ERROR 42S02: Unknown table 'a2' in MULTI DELETE +DELETE a1,a2 FROM db1.t1, db2.t2 AS a2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE FROM a1,a2 USING db1.t1, db2.t2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2; +ERROR 42S02: Unknown table 'a2' in MULTI DELETE +DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2; +ERROR 42S02: Unknown table 'a1' in MULTI DELETE +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2; +ERROR 42000: Unknown database 'db3' +DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1; +ERROR 42000: Not unique table/alias: 'a1' +DELETE a1 FROM db1.a1, db2.t2 AS a1; +ERROR 42S02: Table 'db1.a1' doesn't exist +DELETE a1 FROM a1, db1.t1 AS a1; +ERROR 42000: Not unique table/alias: 'a1' +DELETE t1 FROM db1.t1, db2.t1 AS a1; +ERROR 42S02: Unknown table 't1' in MULTI DELETE +DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2; +ERROR 42S02: Unknown table 't1' in MULTI DELETE +DELETE t1 FROM db1.t1, db2.t1; +ERROR 42S02: Unknown table 't1' in MULTI DELETE +DELETE t1 FROM db1.t2 AS t1, db2.t2 AS t2 WHERE t2.a = 1 AND t1.a = t2.a; +SELECT ROW_COUNT(); +ROW_COUNT() +1 +CALL count_rows(); +COUNT(db1.t1) +3 +COUNT(db1.t2) +2 +COUNT(db2.t1) +3 +COUNT(db2.t2) +3 +COUNT(test.t1) +3 +COUNT(test.t2) +3 +DELETE a1, a2 FROM db2.t1 AS a1, t2 AS a2 WHERE a1.a = 2 AND a2.a = 2; +SELECT ROW_COUNT(); +ROW_COUNT() +2 +CALL count_rows(); +COUNT(db1.t1) +3 +COUNT(db1.t2) +2 +COUNT(db2.t1) +2 +COUNT(db2.t2) +3 +COUNT(test.t1) +3 +COUNT(test.t2) +2 +DROP DATABASE db1; +DROP DATABASE db2; +DROP PROCEDURE count_rows; +DROP TABLE t1, t2; +# +# Bug#46958: Assertion in Diagnostics_area::set_ok_status, trigger, +# merge table +# +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +CREATE TRIGGER tr1 BEFORE DELETE ON t2 +FOR EACH ROW INSERT INTO no_such_table VALUES (1); +DELETE t1, t2, t3 FROM t1, t2, t3; +ERROR 42S02: Table 'test.no_such_table' doesn't exist +SELECT * FROM t1; +a +1 +2 +SELECT * FROM t2; +a +1 +2 +SELECT * FROM t3; +a +1 +2 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +CREATE TRIGGER tr1 AFTER DELETE ON t2 +FOR EACH ROW INSERT INTO no_such_table VALUES (1); +DELETE t1, t2, t3 FROM t1, t2, t3; +ERROR 42S02: Table 'test.no_such_table' doesn't exist +SELECT * FROM t1; +a +1 +2 +SELECT * FROM t2; +a +1 +2 +SELECT * FROM t3; +a +1 +2 +DROP TABLE t1, t2, t3; +# +# Bug #46425 crash in Diagnostics_area::set_ok_status, +# empty statement, DELETE IGNORE +# +CREATE table t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW +BEGIN +INSERT INTO t1 SELECT * FROM t1 AS A; +END | +DELETE IGNORE FROM t1; +ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. +DROP TABLE t1; +# +# Bug #53034: Multiple-table DELETE statements not accepting +# "Access compatibility" syntax +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +DELETE FROM t1.*, test.t2.*, a.* USING t1, t2, t3 AS a; +DROP TABLE t1, t2, t3; +End of 5.1 tests +# +# Bug#51099 Assertion in mysql_multi_delete_prepare() +# +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1, v2; +CREATE TABLE t1(a INT); +CREATE TABLE t2(b INT); +CREATE VIEW v1 AS SELECT a, b FROM t1, t2; +CREATE VIEW v2 AS SELECT a FROM v1; +DELETE FROM v2; +ERROR HY000: Can not delete from join view 'test.v2' +DELETE v2 FROM v2; +ERROR HY000: Can not delete from join view 'test.v2' +DROP VIEW v2, v1; +DROP TABLE t1, t2; +# +# Bug#58709 assert in mysql_execute_command +# +DROP TABLE IF EXISTS t2, t1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (i INT PRIMARY KEY) engine=InnoDB; +CREATE TABLE t2 (i INT, FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION) engine=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +DELETE IGNORE FROM t1 WHERE i = 1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +CREATE PROCEDURE p1() DELETE IGNORE FROM t1 WHERE i = 1; +CALL p1(); +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +PREPARE stm FROM 'CALL p1()'; +EXECUTE stm; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +DEALLOCATE PREPARE stm; +DROP TABLE t2, t1; +DROP PROCEDURE p1; +# +# Bug#18345346 Assertion failed: table_ref->view && table_ref->table == 0 +# +CREATE TABLE b(a INTEGER); +CREATE VIEW y AS SELECT 1 FROM b, b AS e; +CREATE VIEW x AS SELECT 1 FROM y; +CREATE VIEW z AS SELECT 1 FROM x LIMIT 1; +DELETE z FROM (SELECT 1) AS x, z; +ERROR HY000: The target table z of the DELETE is not updatable +DROP VIEW z, x, y; +DROP TABLE b; +# Bug#11752648 : MULTI-DELETE IGNORE DOES NOT REPORT WARNINGS +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 (a) VALUES (1); +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 (a) VALUES (1); +CREATE TABLE t3 (a INT, b INT, CONSTRAINT c_a FOREIGN KEY (a) +REFERENCES t1 (a), CONSTRAINT c_b FOREIGN KEY (b) REFERENCES t2 (a)) ENGINE=InnoDB; +INSERT INTO t3 (a, b) VALUES (1, 1); +DELETE IGNORE FROM t1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +DELETE IGNORE t1,t2 FROM t1,t2; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_b` FOREIGN KEY (`b`) REFERENCES `t2` (`a`)) +SELECT * FROM t1; +a +1 +SELECT * FROM t2; +a +1 +DROP TABLE t3,t2,t1; +# +# Bug#17550423 : DELETE IGNORE GIVES INCORRECT RESULT WITH FOREIGN KEY +# FOR PARENT TABLE +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (5); +INSERT INTO t2 VALUES (1), (5); +ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(b) REFERENCES t1(a); +SELECT * FROM t2; +b +1 +5 +DELETE IGNORE FROM t1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`)) +SELECT * FROM t1; +a +1 +5 +DROP TABLE t2,t1; +# +# Bug#20460208: !table || (!table->read_set || bitmap_is_set) +# +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(a BLOB) engine=innodb; +INSERT INTO t1 SET z=1; +ERROR 42S22: Unknown column 'z' in 'field list' +INSERT INTO t2 VALUES('a'); +DELETE FROM t2 WHERE 1 = a; +DROP TABLE t1, t2; +# +# Bug#20086791 ASSERT `! IS_SET()` IN DIAGNOSTICS_AREA::SET_OK_STATUS +# ON DELETE (ER_SUBQUERY..) +# +SET sql_mode=''; +CREATE TABLE t1 ( +col_int_key int, +pk integer auto_increment, +col_datetime_key datetime, +/*Indices*/ +key (col_int_key ), +primary key (pk), +key (col_datetime_key ) +) ENGINE=memory; +CREATE TABLE t2 ( +col_varchar_key varchar (1), +col_date_key date, +pk integer auto_increment, +/*Indices*/ +key (col_varchar_key ), +key (col_date_key ), +primary key (pk) +) ENGINE=memory; +INSERT INTO t2 VALUES +('v', '2002-05-01', NULL) , +('d', '2001-01-01', NULL) +; +CREATE TABLE t3 ( +pk integer auto_increment, +col_int_key int, +col_varchar_key varchar (1), +/*Indices*/ +primary key (pk), +key (col_int_key ), +key (col_varchar_key )) +ENGINE=memory; +INSERT INTO t3 VALUES +(NULL, 3, 'n') , +(NULL, 1, 'r') +; +CREATE TABLE t4 ( +pk integer auto_increment, +col_varchar_key varchar (1), +col_int_key int, +/*Indices*/ +primary key (pk), +key (col_varchar_key ), +key (col_int_key ) +) ENGINE=memory; +CREATE TABLE t5 ( +col_datetime_key datetime, +pk integer auto_increment, +col_int_key int, +/*Indices*/ +key (col_datetime_key ), +primary key (pk), +key (col_int_key )) +ENGINE=memory; +INSERT INTO t5 VALUES +('2007-10-01', NULL, 8) , +('2002-10-01', NULL, 3) +; +DELETE OUTR1.* FROM t2 AS OUTR1 +JOIN t3 AS OUTR2 +ON ( OUTR1 . col_varchar_key = OUTR2 . col_varchar_key ) +WHERE OUTR1 . col_varchar_key NOT IN +( SELECT INNR1 . col_varchar_key AS y FROM t5 AS INNR2 +RIGHT JOIN t4 AS INNR1 ON ( INNR2 . pk < INNR1 . col_int_key ) +WHERE INNR1 . col_int_key <= INNR1 . col_int_key +AND OUTR2 . col_int_key >= 3 ); +DELETE QUICK +FROM OUTR1.* USING t2 AS OUTR1 +LEFT OUTER JOIN t1 AS OUTR2 +ON ( OUTR1 . col_date_key = OUTR2 . col_datetime_key ) +WHERE OUTR1 . pk NOT IN ( SELECT 2 UNION SELECT 7 ); +DELETE OUTR1.* +FROM t2 AS OUTR1 +LEFT JOIN t1 AS OUTR2 +ON ( OUTR1 . pk = OUTR2 . col_int_key ) +WHERE OUTR1 . pk <> ( +SELECT DISTINCT INNR1 . col_int_key AS y +FROM t5 AS INNR1 WHERE OUTR1 . pk <= 5 +ORDER BY INNR1 . col_datetime_key +); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, t2, t3, t4, t5; +SET sql_mode=default; +# Bug#20450013 assertion 'select_lex::having_cond() == __null ... +CREATE TABLE t1(a TEXT, FULLTEXT (a)); +CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a; +explain DELETE FROM t1 USING v1,t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t1` +DELETE FROM t1 USING v1,t1; +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#25320909 ASSERTION `THD->LEX->CURRENT_SELECT() == UNIT->FIRST_SELECT()' WITH DELETE +# +CREATE TABLE t1 (a INT, b CHAR(8), pk INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 (a,b) VALUES +(10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'); +INSERT INTO t1 (a,b) SELECT a, b FROM t1; +CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY, c CHAR(8), d INT); +INSERT INTO t2 (c,d) SELECT b, a FROM t1; +DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1; +SELECT a,b FROM t1; +a b +1 a +10000 foobar +10000 foobar +2 b +2 b +3 c +3 c +4 d +4 d +5 e +5 e +DELETE IGNORE t1.*, t2.* FROM t1, t2 +WHERE c < b OR +a != ( SELECT 1 UNION SELECT 2 ); +Warnings: +Warning 1242 Subquery returns more than 1 row +DROP TABLE t1, t2; +# +# Bug#29153485: ASSERTION IN JOIN_READ_CONST_TABLE() +# +CREATE TABLE d3 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO d3 VALUES (96,9,'t'),(97,0,'x'); +CREATE TABLE e3 ( +col_varchar varchar(1) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO e3 VALUES ('v',986); +DELETE OUTR1.* FROM e3 AS OUTR1 INNER JOIN d3 AS OUTR2 ON +( OUTR1.col_varchar = OUTR2.col_varchar ) +LEFT JOIN d3 AS OUTR3 ON ( OUTR1. pk = OUTR3.pk ) +WHERE OUTR1.pk = +( SELECT DISTINCT INNR1.col_int FROM d3 AS INNR1 WHERE INNR1.pk <> 8) ; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE d3,e3; +# +# Bug#27455809; DELETE FROM ...WHERE NOT EXISTS WITH TABLE ALIAS CREATES AN ERROR 1064 (42000 +# +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (2); +SELECT * FROM t1; +c1 +1 +2 +DELETE FROM t1 AS a1 WHERE a1.c1 = 2; +SELECT * FROM t1; +c1 +1 +CREATE TABLE t2 (c2 INT); +INSERT INTO t2 VALUES (1), (2); +SELECT * FROM t2; +c2 +1 +2 +DELETE FROM t2 a2 WHERE NOT EXISTS (SELECT * FROM t1 WHERE t1.c1 = a2.c2); +SELECT * FROM t2; +c2 +1 +DROP TABLE t1, t2; +# Bug#31640267: Assertion `trans_safe || updated_rows == 0 || thd->get_transaction() +CREATE TABLE t1(pk INTEGER PRIMARY KEY, a INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +PREPARE s FROM 'DELETE t1 FROM t1, (SELECT 1 FROM DUAL) AS dt'; +EXECUTE s; +SELECT ROW_COUNT(); +ROW_COUNT() +2 +INSERT INTO t1 VALUES(1, 10), (2, 20); +EXECUTE s; +SELECT ROW_COUNT(); +ROW_COUNT() +2 +DEALLOCATE PREPARE s; +DROP TABLE t1; diff --git a/mysql-test/r/derived.result-pq b/mysql-test/r/derived.result-pq new file mode 100644 index 000000000..63f6fb1f8 --- /dev/null +++ b/mysql-test/r/derived.result-pq @@ -0,0 +1,4613 @@ +drop table if exists t1,t2,t3; +select * from (select 2 from DUAL) b; +2 +2 +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +ERROR 42S22: Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +ERROR 42S22: Unknown column 'a' in 'field list' +CREATE TABLE t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +CREATE TABLE t2 (a int not null, b char (10) not null); +insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e'); +select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y; +a y +3 3 +3 3 +select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a; +a a +3 3 +3 3 +CREATE TABLE t3 (a int not null, b char (10) not null); +insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c'); +select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y; +a y +3 3 +3 3 +SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b; +ERROR 42S22: Unknown column 'a' in 'having clause' +SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1; +ERROR 23000: Column 'a' in having clause is ambiguous +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2; +a a +1 2 +SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1; +a a +SELECT 1 FROM (SELECT 1) a WHERE a=2; +ERROR 42S22: Unknown column 'a' in 'where clause' +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a; +ERROR 42S22: Unknown column 'a' in 'having clause' +select * from t1 as x1, (select * from t1) as x2; +a b a b +1 a 1 a +1 a 2 b +1 a 3 c +1 a 3 c +2 b 1 a +2 b 2 b +2 b 3 c +2 b 3 c +3 c 1 a +3 c 1 a +3 c 2 b +3 c 2 b +3 c 3 c +3 c 3 c +3 c 3 c +3 c 3 c +explain select * from t1 as x1, (select * from t1) as x2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x1`.`a` AS `a`,`test`.`x1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` `x1` join `test`.`t1` +drop table if exists t2,t3; +select * from (select 1) as a; +1 +1 +select a from (select 1 as a) as b; +a +1 +select 1 from (select 1) as a; +1 +1 +select * from (select * from t1 union select * from t1) a; +a b +1 a +2 b +3 c +select * from (select * from t1 union all select * from t1) a; +a b +1 a +2 b +3 c +3 c +1 a +2 b +3 c +3 c +select * from (select * from t1 union all select * from t1 limit 2) a; +a b +1 a +2 b +explain select * from (select * from t1 union select * from t1) a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 UNION t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `a` +explain select * from (select * from t1 union all select * from t1) a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 UNION t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `a` +CREATE TABLE t2 (a int not null); +insert into t2 values(1); +select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a; +a b +1 a +select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a; +a b +1 a +2 b +3 c +explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `t2a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +drop table t1, t2; +create table t1(a int not null, t char(8), index(a)); +SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20; +a t +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +explain select count(*) from t1 as tt1, (select * from t1) as tt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` `tt1` join `test`.`t1` +drop table t1; +SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b; +(SELECT * FROM (SELECT 1 as a) as a ) +1 +select * from (select 1 as a) b left join (select 2 as a) c using(a); +a +1 +SELECT * FROM (SELECT 1 UNION SELECT a) b; +ERROR 42S22: Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT a UNION SELECT 1) b; +ERROR 42S22: Unknown column 'a' in 'field list' +SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b; +ERROR 42S22: Unknown column 'a' in 'field list' +select 1 from (select 2) a order by 0; +ERROR 42S22: Unknown column '0' in 'order clause' +create table t1 (id int); +insert into t1 values (1),(2),(3); +describe select * from (select * from t1 group by id) bar; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `bar`.`id` AS `id` from (/* select#2 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` group by `test`.`t1`.`id`) `bar` +drop table t1; +create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL) charset utf8mb4; +create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL); +insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9); +insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105); +analyze table t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +pla_id mat_id +100 1 +101 1 +102 1 +103 2 +104 2 +105 3 +SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +pla_id test +100 1 +101 1 +102 1 +103 2 +104 2 +105 3 +explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY m2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 PRIMARY NULL ref 25 test.m2.matintnum 2 100.00 NULL +2 DERIVED mp NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +2 DERIVED m1 NULL eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `d`.`pla_id` AS `pla_id`,`test`.`m2`.`mat_id` AS `mat_id` from `test`.`t1` `m2` join (/* select#2 */ select `test`.`mp`.`pla_id` AS `pla_id`,min(`test`.`m1`.`matintnum`) AS `matintnum` from `test`.`t2` `mp` join `test`.`t1` `m1` where (`test`.`m1`.`mat_id` = `test`.`mp`.`mat_id`) group by `test`.`mp`.`pla_id`) `d` where (`d`.`matintnum` = `test`.`m2`.`matintnum`) +explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY m2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 PRIMARY NULL ref 25 test.m2.matintnum 2 100.00 NULL +2 DERIVED mp NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +2 DERIVED m1 NULL eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `d`.`pla_id` AS `pla_id`,`test`.`m2`.`test` AS `test` from `test`.`t1` `m2` join (/* select#2 */ select `test`.`mp`.`pla_id` AS `pla_id`,min(`test`.`m1`.`matintnum`) AS `matintnum` from `test`.`t2` `mp` join `test`.`t1` `m1` where (`test`.`m1`.`mat_id` = `test`.`mp`.`mat_id`) group by `test`.`mp`.`pla_id`) `d` where (`d`.`matintnum` = `test`.`m2`.`matintnum`) +drop table t1,t2; +SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1; +x +1 +create user mysqltest_1; +create table t1 select 1 as a; +select 2 as a from (select * from t1) b; +ERROR 3D000: No database selected +use test; +select 2 as a from (select * from t1) b; +a +2 +drop table t1; +select mail_id, if(folder.f_description!='', folder.f_description, folder.f_name) as folder_name, date, address_id, phrase, address, subject from folder, (select mail.mail_id as mail_id, date_format(mail.h_date, '%b %e, %Y %h:%i') as date, mail.folder_id, sender.address_id as address_id, sender.phrase as phrase, sender.address as address, mail.h_subject as subject from mail left join mxa as mxa_sender on mail.mail_id=mxa_sender.mail_id and mxa_sender.type='from' left join address as sender on mxa_sender.address_id=sender.address_id mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_recipient.mail_id and mxa_recipient.address_id=recipient.address_id and mxa_recipient.type='to' and match(sender.phrase, sender.address, sender.comment) against ('jeremy' in boolean mode) and match(recipient.phrase, recipient.address, recipient.comment) against ('monty' in boolean mode) order by mail.h_date desc limit 0, 25 ) as query where query.folder_id=folder.folder_id; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_r' at line 1 +create table t1 (a int); +insert into t1 values (1),(2),(3); +update (select * from t1) as t1 set a = 5; +ERROR HY000: The target table t1 of the UPDATE is not updatable +update (select * from t1) as t1, t1 as t2 set t1.a = 5; +ERROR HY000: The target table t1 of the UPDATE is not updatable +delete from (select * from t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1)' at line 1 +delete from (select * from t1) as t1, t1 as t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1) as t1, t1 as t2' at line 1 +insert into (select * from t1) values (5); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1) values (5)' at line 1 +drop table t1; +create table t1 (E1 INTEGER UNSIGNED NOT NULL, E2 INTEGER UNSIGNED NOT NULL, E3 INTEGER UNSIGNED NOT NULL, PRIMARY KEY(E1) +); +insert into t1 VALUES(1,1,1), (2,2,1); +select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS themax ON t1.E1 = themax.E2 AND t1.E1 = t1.E2; +count(*) +2 +explain select count(*) from t1 INNER JOIN (SELECT a.E1, a.E2, a.E3 FROM t1 AS a WHERE a.E3 = (SELECT max(b.E3) FROM t1 AS b WHERE a.E2 = b.E2)) AS themax ON t1.E1 = themax.E2 AND t1.E1 = t1.E2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.a.E2 1 50.00 Using where +3 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.a.E2' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` join `test`.`t1` `a` where ((`test`.`t1`.`E1` = `test`.`a`.`E2`) and (`test`.`t1`.`E2` = `test`.`a`.`E2`) and (`test`.`a`.`E3` = (/* select#3 */ select max(`test`.`b`.`E3`) from `test`.`t1` `b` where (`test`.`a`.`E2` = `test`.`b`.`E2`)))) +drop table t1; +create table t1 (a int); +insert into t1 values (1),(2); +select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +a a +1 1 +1 2 +2 1 +2 2 +explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +4 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 UNION t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 UNION t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `a`.`a` AS `a`,`b`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `a` join (/* select#4 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#5 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `b` +drop table t1; +CREATE TABLE `t1` ( +`N` int(11) unsigned NOT NULL default '0', +`M` tinyint(1) default '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0); +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; +select * from t1; +N M +1 2 +1 2 +1 2 +2 2 +2 2 +3 0 +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2; +ERROR HY000: The target table P2 of the UPDATE is not updatable +UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; +ERROR 42S22: Unknown column 'aaaa' in 'field list' +delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +select * from t1; +N M +3 0 +delete P1.*,p2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS p2 ON P1.N = p2.N; +ERROR HY000: The target table p2 of the DELETE is not updatable +delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +ERROR 42S22: Unknown column 'aaa' in 'field list' +drop table t1; +CREATE TABLE t1 ( +OBJECTID int(11) NOT NULL default '0', +SORTORDER int(11) NOT NULL auto_increment, +KEY t1_SortIndex (SORTORDER), +KEY t1_IdIndex (OBJECTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) default NULL, +PARID int(11) default NULL, +UNIQUE KEY t2_ID_IDX (ID), +KEY t2_PARID_IDX (PARID) +) engine=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2); +CREATE TABLE t3 ( +ID int(11) default NULL, +DATA decimal(10,2) default NULL, +UNIQUE KEY t3_ID_IDX (ID) +) engine=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75); +select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; +497 ID NULL +drop table t1, t2, t3; +CREATE TABLE t1 (name char(1) default NULL, val int(5) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1), ('a',2), ('a',2), ('a',2), ('a',3), ('a',6), ('a',7), ('a',11), ('a',11), ('a',12), ('a',13), ('a',13), ('a',20), ('b',2), ('b',3), ('b',4), ('b',5); +SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name; +name median +a 7.0000 +b 3.5000 +explain SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 28 100.00 Using temporary +2 DERIVED x NULL ALL NULL NULL NULL NULL 17 100.00 Using temporary +2 DERIVED y NULL ALL NULL NULL NULL NULL 17 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `s`.`name` AS `name`,avg(`s`.`val`) AS `median` from (/* select#2 */ select `test`.`x`.`name` AS `name`,`test`.`x`.`val` AS `val` from `test`.`t1` `x` join `test`.`t1` `y` where (`test`.`y`.`name` = `test`.`x`.`name`) group by `test`.`x`.`name`,`test`.`x`.`val` having ((sum((`test`.`y`.`val` <= `test`.`x`.`val`)) >= (count(0) / 2)) and (sum((`test`.`y`.`val` >= `test`.`x`.`val`)) >= (count(0) / 2)))) `s` group by `s`.`name` +drop table t1; +create table t2 (a int, b int, primary key (a)); +insert into t2 values (1,7),(2,7); +explain select a from t2 where a>1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1) +explain select a from (select a from t2 where a>1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1) +drop table t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (128, 'rozn', 2, curdate(), 10), +(128, 'rozn', 1, curdate(), 10); +SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices; +min max avg +10.00 10.00 10 +DROP TABLE t1; +SET sql_mode = default; +create table t1 (a integer, b integer); +insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1); +select distinct sum(b) from t1 group by a; +sum(b) +4 +select distinct sum(b) from (select a,b from t1) y group by a; +sum(b) +4 +drop table t1; +CREATE TABLE t1 (a char(10), b char(10)); +INSERT INTO t1 VALUES ('root','localhost'), ('root','%'); +SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +create table t1(a int); +create table t2(a int); +create table t3(a int); +insert into t1 values(1),(1); +insert into t2 values(2),(2); +insert into t3 values(3),(3); +select * from t1 union distinct select * from t2 union all select * from t3; +a +1 +2 +3 +3 +select * from (select * from t1 union distinct select * from t2 union all select * from t3) X; +a +1 +2 +3 +3 +drop table t1, t2, t3; +create table t1 (a int); +create table t2 (a int); +select * from (select * from t1,t2) foo; +ERROR 42S21: Duplicate column name 'a' +drop table t1,t2; +create table t1 (ID int unsigned not null auto_increment, +DATA varchar(5) not null, primary key (ID)); +create table t2 (ID int unsigned not null auto_increment, +DATA varchar(5) not null, FID int unsigned not null, +primary key (ID)); +select A.* from (t1 inner join (select * from t2) as A on t1.ID = A.FID); +ID DATA FID +select t2.* from ((select * from t1) as A inner join t2 on A.ID = t2.FID); +ID DATA FID +select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID; +ID DATA FID +drop table t1, t2; +drop user mysqltest_1; +# End of 4.1 tests +SELECT 0 FROM +(SELECT 0) t01, (SELECT 0) t02, (SELECT 0) t03, (SELECT 0) t04, (SELECT 0) t05, +(SELECT 0) t06, (SELECT 0) t07, (SELECT 0) t08, (SELECT 0) t09, (SELECT 0) t10, +(SELECT 0) t11, (SELECT 0) t12, (SELECT 0) t13, (SELECT 0) t14, (SELECT 0) t15, +(SELECT 0) t16, (SELECT 0) t17, (SELECT 0) t18, (SELECT 0) t19, (SELECT 0) t20, +(SELECT 0) t21, (SELECT 0) t22, (SELECT 0) t23, (SELECT 0) t24, (SELECT 0) t25, +(SELECT 0) t26, (SELECT 0) t27, (SELECT 0) t28, (SELECT 0) t29, (SELECT 0) t30, +(SELECT 0) t31, (SELECT 0) t32, (SELECT 0) t33, (SELECT 0) t34, (SELECT 0) t35, +(SELECT 0) t36, (SELECT 0) t37, (SELECT 0) t38, (SELECT 0) t39, (SELECT 0) t40, +(SELECT 0) t41, (SELECT 0) t42, (SELECT 0) t43, (SELECT 0) t44, (SELECT 0) t45, +(SELECT 0) t46, (SELECT 0) t47, (SELECT 0) t48, (SELECT 0) t49, (SELECT 0) t50, +(SELECT 0) t51, (SELECT 0) t52, (SELECT 0) t53, (SELECT 0) t54, (SELECT 0) t55, +(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60, +(SELECT 0) t61; +0 +0 +# +# A nested materialized derived table is used before being populated. +# (addon for bug#19077) +# +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; +MIN(i) +1 +DROP TABLE t1; +# End of 5.0 tests +# +# Bug#55586: Crash JOIN of two subqueries in FROM + ORDER BY and GROUP BY +# +CREATE TABLE C ( +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO C VALUES (2,'w','w'); +INSERT INTO C VALUES (2,'d','d'); +SELECT SUM(DISTINCT table2.col_int_key) field1, +table1.col_varchar_key field2 +FROM +(SELECT * FROM C ) table1 +JOIN (SELECT * FROM C ) table2 +ON table2 .`col_varchar_key` = table1 .`col_varchar_nokey` +GROUP BY field2 +ORDER BY field1; +field1 field2 +2 d +2 w +DROP TABLE C; +# End of test for bug#55586 +# +# Bug#55561: Crash on JOIN with 2 FROM subqueries +# +CREATE TABLE C ( +col_int int DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL +); +INSERT INTO `C` VALUES (0,NULL); +INSERT INTO `C` VALUES (5,'y'); +SELECT table1.col_varchar +FROM +( SELECT * FROM C ) table1 +JOIN ( SELECT * FROM C ) table2 ON table2.col_varchar = table1.col_varchar +WHERE +table2.col_varchar < table2.col_varchar +AND table1.col_varchar != 'k' +LIMIT 1; +col_varchar +DROP TABLE C; +# End on bug#55561 +# +# Bug#56233: Hang during key generation for derived tables +# +CREATE TABLE C ( +col_varchar_10_key varchar(10) DEFAULT NULL, +col_int_key int DEFAULT NULL, +pk int NOT NULL AUTO_INCREMENT, +col_date_key date DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `col_varchar_10_key` (`col_varchar_10_key`), +KEY `col_int_key` (`col_int_key`), +KEY `col_date_key` (`col_date_key`) +); +INSERT INTO C VALUES ('ok',3,1,'2003-04-02'); +CREATE ALGORITHM=TEMPTABLE VIEW viewC AS SELECT * FROM C; +SELECT table1.col_date_key AS field1 +FROM +C AS table1 +WHERE +(table1.col_int_key <=ANY +( SELECT SUBQUERY1_t1.col_int_key +FROM viewC AS SUBQUERY1_t1 +WHERE SUBQUERY1_t1.col_varchar_10_key <= table1.col_varchar_10_key +) +) +; +field1 +2003-04-02 +DROP TABLE C; +DROP VIEW viewC; +# +# +# Bug#55950: FROM Subquery joined by 2 varchar fields returns empty +# set +# +CREATE TABLE `cc` ( +`i1` varchar(1) DEFAULT NULL, +`i2` varchar(1) DEFAULT NULL +) charset utf8mb4; +INSERT INTO `cc` VALUES ('m','m'); +INSERT INTO `cc` VALUES ('c','c'); +CREATE TABLE `C` ( +`o1` varchar(1) DEFAULT NULL +) charset utf8mb4; +INSERT INTO `C` VALUES ('m'); +SELECT table1 . o1 +FROM C table1 +JOIN ( C table2 +JOIN ( SELECT * FROM cc ) table3 +ON table3 .`i1` = table2 .o1 +) ON table3 .`i2` = table2 .o1 +; +o1 +m +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +# Ref access to the derived table should be used. +EXPLAIN SELECT table1 . o1 +FROM C table1 +JOIN ( C table2 +JOIN ( SELECT * FROM cc ) table3 +ON table3 .`i1` = table2 .o1 +) ON table3 .`i2` = table2 .o1 +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY table2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ref 14 const,const 1 100.00 Using index +2 DERIVED cc NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'm' AS `o1` from (/* select#2 */ select `test`.`cc`.`i1` AS `i1`,`test`.`cc`.`i2` AS `i2` from `test`.`cc`) `table3` where ((`table3`.`i2` = 'm') and (`table3`.`i1` = 'm')) +EXPLAIN FORMAT=tree SELECT table1 . o1 +FROM C table1 +JOIN ( C table2 +JOIN ( SELECT * FROM cc ) table3 +ON table3 .`i1` = table2 .o1 +) ON table3 .`i2` = table2 .o1 +; +EXPLAIN +-> Index lookup on table3 using (i1='m', i2='m') + -> Materialize (cost=0.90..0.90 rows=2) + -> Table scan on cc (cost=0.70 rows=2) + +SET @@optimizer_switch=@optimizer_switch_saved; +DROP TABLE cc; +DROP TABLE C; +# End of test for bug#55950 +# +# Bug#56592: Subquery with DISTINCT in FROM clause returns only partial +# result +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL, +`col_int_key` int(11) DEFAULT NULL, +`col_datetime_key` datetime DEFAULT NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2, 9, NULL), (3, 3, '1900-01-01 00:00:00'), +(8, 8, '1900-01-01 00:00:00'), (15, 0, '2007-12-15 12:39:34'); +SELECT * FROM ( +SELECT DISTINCT tableb.col_datetime_key +FROM t1 tablea LEFT JOIN t1 tableb ON tablea.pk < tableb.col_int_key +) AS from_subquery; +col_datetime_key +1900-01-01 00:00:00 +NULL +EXPLAIN SELECT * FROM ( +SELECT DISTINCT tableb.col_datetime_key +FROM t1 tablea LEFT JOIN t1 tableb ON tablea.pk < tableb.col_int_key +) AS from_subquery; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 DERIVED tablea NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DERIVED tableb NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `from_subquery`.`col_datetime_key` AS `col_datetime_key` from (/* select#2 */ select distinct `test`.`tableb`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `tablea` left join `test`.`t1` `tableb` on((`test`.`tablea`.`pk` < `test`.`tableb`.`col_int_key`)) where true) `from_subquery` +EXPLAIN SELECT * FROM ( +SELECT DISTINCT tablea.col_datetime_key +FROM t1 tablea LEFT JOIN t1 tableb ON tablea.pk < tableb.col_int_key +) AS from_subquery; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 DERIVED tablea NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DERIVED tableb NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Distinct; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `from_subquery`.`col_datetime_key` AS `col_datetime_key` from (/* select#2 */ select distinct `test`.`tablea`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `tablea` left join `test`.`t1` `tableb` on((`test`.`tablea`.`pk` < `test`.`tableb`.`col_int_key`)) where true) `from_subquery` +DROP TABLE t1; +# +# Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table, +# temptable views +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT, KEY (b)); +INSERT INTO t1 VALUES (1),(1); +INSERT INTO t2 VALUES (1),(1); +CREATE algorithm=temptable VIEW v1 AS +SELECT 1 FROM t1 LEFT JOIN t1 t3 ON 1 > (SELECT 1 FROM t1); +CREATE algorithm=temptable VIEW v2 AS SELECT 1 FROM t2; +EXPLAIN SELECT 1 FROM t1 JOIN v1 ON 1 > (SELECT 1 FROM v2); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, t2; +DROP VIEW v1, v2; +# +# WL#5274: Postpone materialization of views/subqueries in FROM clause. +# Additional tests. +# +CREATE TABLE t1(f1 int, f11 int); +CREATE TABLE t2(f2 int, f22 int); +INSERT INTO t1 VALUES(1,1),(2,2),(3,3),(5,5),(9,9),(7,7); +INSERT INTO t2 VALUES(1,1),(3,3),(2,2),(4,4),(8,8),(6,6); +for merged derived tables +explain for simple derived +EXPLAIN SELECT * FROM (SELECT * FROM t1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` +SELECT * FROM (SELECT * FROM t1) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +9 9 +7 7 +explain for multitable derived +EXPLAIN SELECT * FROM (SELECT * FROM t1 JOIN t2 ON f1=f2) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM (SELECT * FROM t1 JOIN t2 ON f1=f2) tt; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +explain for derived with where +FLUSH STATUS; +EXPLAIN +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt WHERE f11=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f11` = 2) and (`test`.`t1`.`f1` in (2,3))) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt WHERE f11=2; +f1 f11 +2 2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +join of derived +EXPLAIN +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt JOIN +(SELECT * FROM t1 WHERE f1 IN (1,2)) aa ON tt.f1=aa.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`f1` = `test`.`t1`.`f1`) and (`test`.`t1`.`f1` in (1,2)) and (`test`.`t1`.`f1` in (2,3))) +SELECT * FROM (SELECT * FROM t1 WHERE f1 IN (2,3)) tt JOIN +(SELECT * FROM t1 WHERE f1 IN (1,2)) aa ON tt.f1=aa.f1; +f1 f11 f1 f11 +2 2 2 2 +for merged views +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t1 JOIN t2 ON f1=f2; +CREATE VIEW v3 AS SELECT * FROM t1 WHERE f1 IN (2,3); +CREATE VIEW v4 AS SELECT * FROM t2 WHERE f2 IN (2,3); +explain for simple views +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` +SELECT * FROM v1; +f1 f11 +1 1 +2 2 +3 3 +5 5 +7 7 +9 9 +explain for multitable views +EXPLAIN SELECT * FROM v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM v2; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +explain for views with where +EXPLAIN SELECT * FROM v3 WHERE f11 IN (1,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f11` in (1,3)) and (`test`.`t1`.`f1` in (2,3))) +SELECT * FROM v3 WHERE f11 IN (1,3); +f1 f11 +3 3 +explain for joined views +EXPLAIN +SELECT * FROM v3 JOIN v4 ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f1` in (2,3)) and (`test`.`t1`.`f1` in (2,3))) +SELECT * FROM v3 JOIN v4 ON f1=f2; +f1 f11 f2 f22 +2 2 2 2 +3 3 3 3 +FLUSH STATUS; +EXPLAIN SELECT * FROM v4 WHERE f2 IN (1,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where ((`test`.`t2`.`f2` in (1,3)) and (`test`.`t2`.`f2` in (2,3))) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM v4 WHERE f2 IN (1,3); +f2 f22 +3 3 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +for materialized derived tables +explain for simple derived +EXPLAIN SELECT * FROM (SELECT * FROM t1 GROUP BY f1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` group by `test`.`t1`.`f1`) `tt` +SELECT * FROM (SELECT * FROM t1 HAVING f1=f1) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +9 9 +7 7 +explain showing created indexes and late materialization +FLUSH STATUS; +EXPLAIN +SELECT * FROM t1 JOIN (SELECT * FROM t2 GROUP BY f2) tt ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.f1 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`tt`.`f2` AS `f2`,`tt`.`f22` AS `f22` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` group by `test`.`t2`.`f2`) `tt` where (`tt`.`f2` = `test`.`t1`.`f1`) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM t1 JOIN (SELECT * FROM t2 GROUP BY f2) tt ON f1=f2; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 3 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 21 +for materialized views +DROP VIEW v1,v2,v3; +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY f1; +CREATE VIEW v2 AS SELECT * FROM t2 GROUP BY f2; +CREATE VIEW v3 AS SELECT t1.f1,t1.f11 FROM t1 JOIN t1 AS t11 HAVING t1.f1<100; +ensure that view definitions are cached in the data-dictionary cache. +explain for simple derived +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`v1` +SELECT * FROM v1; +f1 f11 +1 1 +2 2 +3 3 +5 5 +7 7 +9 9 +explain showing created indexes and late materialization for views +FLUSH STATUS; +EXPLAIN SELECT * FROM t1 JOIN v2 ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.f1 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`v2`.`f2` AS `f2`,`test`.`v2`.`f22` AS `f22` from `test`.`t1` join `test`.`v2` where (`test`.`v2`.`f2` = `test`.`t1`.`f1`) +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +FLUSH STATUS; +SELECT * FROM t1 JOIN v2 ON f1=f2; +f1 f11 f2 f22 +1 1 1 1 +2 2 2 2 +3 3 3 3 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 3 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 21 +EXPLAIN +SELECT * FROM t1,v3 AS v31,v3 WHERE t1.f1=v31.f1 and t1.f1=v3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.f1 3 100.00 NULL +1 PRIMARY NULL ref 5 test.t1.f1 3 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +3 DERIVED t11 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED t11 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`v31`.`f1` AS `f1`,`test`.`v31`.`f11` AS `f11`,`test`.`v3`.`f1` AS `f1`,`test`.`v3`.`f11` AS `f11` from `test`.`t1` join `test`.`v3` `v31` join `test`.`v3` where ((`test`.`v31`.`f1` = `test`.`t1`.`f1`) and (`test`.`v3`.`f1` = `test`.`t1`.`f1`)) +FLUSH STATUS; +SELECT * FROM t1,v3 AS v31,v3 WHERE t1.f1=v31.f1 and t1.f1=v3.f1; +f1 f11 f1 f11 f1 f11 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +1 1 1 1 1 1 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +2 2 2 2 2 2 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +3 3 3 3 3 3 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +5 5 5 5 5 5 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +9 9 9 9 9 9 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +7 7 7 7 7 7 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 42 +Handler_read_last 0 +Handler_read_next 252 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 35 +explain showing late materialization for views +EXPLAIN SELECT * FROM v1 JOIN v4 ON f1=f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +1 PRIMARY NULL ref 5 test.t2.f2 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`v1` join `test`.`t2` where ((`test`.`v1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f2` in (2,3))) +SELECT * FROM v1 JOIN v4 ON f1=f2; +f1 f11 f2 f22 +2 2 2 2 +3 3 3 3 +merged derived in merged derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7)) +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2) zz; +f1 f11 +3 3 +5 5 +materialized derived in merged derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) zz; +f1 f11 +3 3 +5 5 +merged derived in materialized derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2 GROUP BY f1) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `zz`.`f1` AS `f1`,`zz`.`f11` AS `f11` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7)) group by `test`.`t1`.`f1`) `zz` +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7) tt WHERE f1 > 2 GROUP BY f1) zz; +f1 f11 +3 3 +5 5 +materialized derived in materialized derived +EXPLAIN SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) zz; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `zz`.`f1` AS `f1`,`zz`.`f11` AS `f11` from (/* select#2 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` group by `tt`.`f1`) `zz` +SELECT * FROM (SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) zz; +f1 f11 +3 3 +5 5 +mat in merged derived join mat in merged derived +EXPLAIN SELECT * FROM +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) x +JOIN +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) z +ON x.f1 = z.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 tt.f1 2 100.00 NULL +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11`,`tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` join (/* select#5 */ select `t1`.`f1` AS `f1`,`t1`.`f11` AS `f11` from `test`.`t1` where ((`t1`.`f1` < 7) and (`t1`.`f1` > 2)) group by `t1`.`f1`) `tt` where (`tt`.`f1` = `tt`.`f1`) +FLUSH STATUS; +SELECT * FROM +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) x +JOIN +(SELECT * FROM (SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2) z +ON x.f1 = z.f1; +f1 f11 f1 f11 +3 3 3 3 +5 5 5 5 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 23 +FLUSH STATUS; +merged in merged derived join merged in merged derived +EXPLAIN SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) z +ON x.f1 = z.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`t1`.`f1` AS `f1`,`t1`.`f11` AS `f11` from `test`.`t1` join `test`.`t1` where ((`t1`.`f1` = `test`.`t1`.`f1`) and (`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7)) +SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 ) tt WHERE f1 > 2 ) z +ON x.f1 = z.f1; +f1 f11 f1 f11 +3 3 3 3 +5 5 5 5 +materialized in materialized derived join +materialized in materialized derived +EXPLAIN SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) z +ON x.f1 = z.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 x.f1 2 100.00 NULL +4 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +2 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `x`.`f1` AS `f1`,`x`.`f11` AS `f11`,`z`.`f1` AS `f1`,`z`.`f11` AS `f11` from (/* select#2 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#3 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2)) group by `test`.`t1`.`f1`) `tt` group by `tt`.`f1`) `x` join (/* select#4 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#5 */ select `t1`.`f1` AS `f1`,`t1`.`f11` AS `f11` from `test`.`t1` where ((`t1`.`f1` < 7) and (`t1`.`f1` > 2)) group by `t1`.`f1`) `tt` group by `tt`.`f1`) `z` where (`z`.`f1` = `x`.`f1`) +SELECT * FROM +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) x +JOIN +(SELECT * FROM +(SELECT * FROM t1 WHERE f1 < 7 GROUP BY f1) tt WHERE f1 > 2 GROUP BY f1) z +ON x.f1 = z.f1; +f1 f11 f1 f11 +3 3 3 3 +5 5 5 5 +merged view in materialized derived +EXPLAIN +SELECT * FROM (SELECT * FROM v4 GROUP BY 1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 6 33.33 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f2` AS `f2`,`tt`.`f22` AS `f22` from (/* select#2 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where (`test`.`t2`.`f2` in (2,3)) group by `test`.`t2`.`f2`) `tt` +SELECT * FROM (SELECT * FROM v4 GROUP BY 1) tt; +f2 f22 +2 2 +3 3 +materialized view in merged derived +EXPLAIN +SELECT * FROM ( SELECT * FROM v1 WHERE f1 < 7) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`v1` +SELECT * FROM ( SELECT * FROM v1 WHERE f1 < 7) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +merged view in a merged view in a merged derived +CREATE VIEW v6 AS SELECT * FROM v4 WHERE f2 < 7; +EXPLAIN SELECT * FROM (SELECT * FROM v6) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where ((`test`.`t2`.`f2` < 7) and (`test`.`t2`.`f2` in (2,3))) +SELECT * FROM (SELECT * FROM v6) tt; +f2 f22 +3 3 +2 2 +materialized view in a merged view in a materialized derived +CREATE VIEW v7 AS SELECT * FROM v1; +EXPLAIN SELECT * FROM (SELECT * FROM v7 GROUP BY 1) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +4 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (/* select#2 */ select `test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`v1` group by `test`.`v1`.`f1`) `tt` +SELECT * FROM (SELECT * FROM v7 GROUP BY 1) tt; +f1 f11 +1 1 +2 2 +3 3 +5 5 +7 7 +9 9 +JOIN of above two +EXPLAIN SELECT * FROM v6 JOIN v7 ON f2=f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 PRIMARY NULL ref 5 test.t2.f2 2 100.00 NULL +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22`,`test`.`v1`.`f1` AS `f1`,`test`.`v1`.`f11` AS `f11` from `test`.`t2` join `test`.`v1` where ((`test`.`v1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f2` < 7) and (`test`.`t2`.`f2` in (2,3))) +SELECT * FROM v6 JOIN v7 ON f2=f1; +f2 f22 f1 f11 +2 2 2 2 +3 3 3 3 +test two keys +CREATE TABLE t3(f3 INT, f33 INT); +INSERT INTO t1 VALUES(6,6),(8,8); +INSERT INTO t3 VALUES(1,1),(2,2),(3,3),(5,5); +EXPLAIN SELECT * FROM t1 JOIN (SELECT * FROM t2) tt ON t1.f1=tt.f2 +JOIN t3 ON tt.f22=t3.f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22`,`test`.`t3`.`f3` AS `f3`,`test`.`t3`.`f33` AS `f33` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f22` = `test`.`t3`.`f3`)) +SELECT * FROM t1 JOIN (SELECT * FROM t2) tt ON t1.f1=tt.f2 +JOIN t3 ON tt.f22=t3.f3; +f1 f11 f2 f22 f3 f33 +1 1 1 1 1 1 +2 2 2 2 2 2 +3 3 3 3 3 3 +DROP TABLE t1,t2,t3; +DROP VIEW v1,v2,v3,v4,v6,v7; +# +# +# BUG#11783262: CRASH IN ITEM_FIELD::ITEM_FIELD IN ITEM.CC ON SUBQUERY +# IN FROM WITH WL5274 +# +CREATE TABLE t1 ( +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=INNODB; +SELECT alias1.col_time_key AS field1 +FROM ( ( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1 ) AS alias1 +INNER JOIN t1 AS alias2 +ON (alias2.col_int_key = alias1.col_int_key) +) +WHERE alias1.col_int_key = 207 +ORDER BY alias1.col_varchar_key, field1; +field1 +DROP TABLE t1; +# +# Bug#11807437: VALGRIND WARNING IN MYSQL_DERIVED_OPTIMIZE() LINE 293 +# +CREATE TABLE t1 ( +f1 int(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT 1 +FROM ( +SELECT 1, 2 FROM DUAL +WHERE EXISTS ( +SELECT f1 +FROM t1 +)) AS tt +; +1 +DROP TABLE t1; +# +# +# Bug#11808582: VALGRIND ON WL#5274: INVALID WRITE IN MC_REPLACE_STRMEM.C:493) +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=InnoDB; +SELECT tt.col_time_key +FROM ( ( SELECT * FROM t1 ) AS tt +INNER JOIN t1 +ON (t1.col_int_key = tt.col_int_key) +) +WHERE tt.col_int_key = 207 +ORDER BY tt.col_varchar_key, tt.pk ASC, 1; +col_time_key +DROP TABLE t1; +# +# Bug#11791677 - ASSERTION FAILED IN JOIN_MATERIALIZE_TABLE IN +# SQL_SELECT.CC ON NESTED SUBQUERY +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,8,'v'), (29,4,'c'); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (16,1,'c'), (20,4,'d'); +CREATE TABLE t3 ( +`field1` varchar(1) DEFAULT NULL, +`field2` int(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES ('m',6),('c',4); +SELECT * +FROM t3 +WHERE (field1, field2) IN ( +SELECT t1.col_varchar_key AS field1, +t1.col_int_key AS field2 +FROM ( t1 INNER JOIN ( +SELECT t2.* +FROM t2 +WHERE t2.col_int_nokey < t2.pk ) AS alias2 +ON (alias2.col_varchar_key = t1.col_varchar_key ) ) +GROUP BY field1, field2 +ORDER BY t1.col_int_key, t1 .pk DESC ) +; +field1 field2 +c 4 +DROP TABLE t1,t2,t3; +# +# +# Bug#11791705 - CRASH IN JOIN_MATERIALIZE_TABLE OR ASSERTION FAIL: +# !TAB->SAVE_READ_FIRST_RECORD +# +CREATE TABLE t1 (a INTEGER); +INSERT INTO t1 VALUES (NULL),(NULL); +SELECT * FROM t1 +WHERE (a, a) NOT IN +(SELECT * FROM (SELECT 8, 4 UNION SELECT 2, 3) tt) ; +a +DROP TABLE t1; +# +# Bug#11791649 - ASSERT: FIXED == 0, IN ITEM.CC ON EXPLAIN WITH VIEW +# IN SUBQUERY +# +CREATE TABLE t1 (pk int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES ('m'), ('f'); +EXPLAIN SELECT pk +FROM t1 +WHERE (2) IN +( SELECT * +FROM (SELECT COUNT(col_varchar_nokey) FROM t2) d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk` from semi join ((/* select#3 */ select count(`test`.`t2`.`col_varchar_nokey`) AS `COUNT(col_varchar_nokey)` from `test`.`t2` having (2 = count(`test`.`t2`.`col_varchar_nokey`))) `d`) +DROP TABLE t1,t2; +# +# +# Bug#12735934 - Lost LIMIT clause caused wrong result. +# +CREATE TABLE t1 (f1 VARCHAR(1), key(f1)); +INSERT INTO t1 VALUES ('a'); +CREATE VIEW v1 AS SELECT f1 FROM t1 ORDER BY 1 LIMIT 0; +SELECT * FROM v1; +f1 +DROP VIEW v1; +DROP TABLE t1; +# +# +# Bug#12726927: An outdated assertion caused server failure. +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,1,'v'), (24,18,'h'); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_date_key date NOT NULL, +col_date_nokey date NOT NULL, +col_time_nokey time NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'1900-01-01','1900-01-01','00:00:00','k','k'); +SELECT OUTR.col_date_key +FROM t2 AS OUTR2 +LEFT JOIN t2 AS OUTR ON OUTR2.pk < OUTR.pk +WHERE ( OUTR.col_varchar_nokey , OUTR.col_varchar_key ) +IN ( +SELECT DISTINCT col_varchar_key , col_varchar_key +FROM t1 +WHERE col_int_nokey XOR OUTR.col_time_nokey +) +XOR OUTR.col_date_nokey IS NULL +; +col_date_key +NULL +DROP TABLE t1,t2; +# +# +# Bug#12799731 - CRASH IN END_READ_RECORD. +# +create table t1(f1 char(255) charset utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0'); +set @save_internal_tmp_mem_storage_engine= @@internal_tmp_mem_storage_engine; +set session internal_tmp_mem_storage_engine='memory'; +set @save_heap_size= @@max_heap_table_size; +set @@max_heap_table_size= 1; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '1' +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +flush status; +select count(*) from t1 join ( +select t1.f1 from t1 join t1 as t2 join t1 as t3) tt on t1.f1 = tt.f1; +count(*) +1000 +show status like 'Handler_write'; +Variable_name Value +Handler_write 1021 +set @@max_heap_table_size= @save_heap_size; +set session internal_tmp_mem_storage_engine= @save_internal_tmp_mem_storage_engine; +SET @@optimizer_switch= @optimizer_switch_saved; +drop table t1; +# +# +# Bug#12896124: Crash on rqg_mdl_stability test +# +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE FUNCTION func1 (param1 INTEGER) RETURNS INT NOT DETERMINISTIC +return param1; +CREATE FUNCTION func2 (param1 INTEGER) RETURNS INT +return param1; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func1(f1); +f1 +1 +2 +3 +EXPLAIN SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func1(f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` = `func1`(`test`.`t1`.`f1`))) `tt` +SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func2(f1); +f1 +1 +2 +3 +EXPLAIN SELECT * FROM (SELECT * FROM t1) tt WHERE f1 = func2(f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `tt`.`f1` AS `f1` from (/* select#2 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` = `func2`(`test`.`t1`.`f1`))) `tt` +SET @@optimizer_switch= @optimizer_switch_saved; +DROP FUNCTION func1; +DROP FUNCTION func2; +DROP TABLE t1; +# +# +# Bug#12909844: Missing type cast caused false assertion +# +CREATE TABLE t1 ( fk INT) ENGINE=INNODB; +CREATE TABLE t2 ( +f1 INT, f2 INT, f3 INT, f4 INT, f5 INT, f6 INT, +f7 INT, f8 INT, f9 INT, f10 INT, f11 INT, f12 INT, +f13 INT, f14 INT, f15 INT, f16 INT, f17 INT, f18 INT, +f19 INT, f20 INT, f21 INT, f22 INT, f23 INT, f24 INT, +f25 INT, f26 INT, f27 INT, f28 INT, f29 INT, f30 INT, +f31 INT, f32 TEXT, fk INT) ENGINE=INNODB; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT alias2.fk AS field1 FROM t1 AS alias1 JOIN +(SELECT * FROM t2 ) AS alias2 ON alias1.fk = alias2.fk; +field1 +EXPLAIN +SELECT alias2.fk AS field1 FROM t1 AS alias1 JOIN +(SELECT * FROM t2 ) AS alias2 ON alias1.fk = alias2.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 PRIMARY NULL ref 5 test.alias1.fk 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `alias2`.`fk` AS `field1` from `test`.`t1` `alias1` join (/* select#2 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3`,`test`.`t2`.`f4` AS `f4`,`test`.`t2`.`f5` AS `f5`,`test`.`t2`.`f6` AS `f6`,`test`.`t2`.`f7` AS `f7`,`test`.`t2`.`f8` AS `f8`,`test`.`t2`.`f9` AS `f9`,`test`.`t2`.`f10` AS `f10`,`test`.`t2`.`f11` AS `f11`,`test`.`t2`.`f12` AS `f12`,`test`.`t2`.`f13` AS `f13`,`test`.`t2`.`f14` AS `f14`,`test`.`t2`.`f15` AS `f15`,`test`.`t2`.`f16` AS `f16`,`test`.`t2`.`f17` AS `f17`,`test`.`t2`.`f18` AS `f18`,`test`.`t2`.`f19` AS `f19`,`test`.`t2`.`f20` AS `f20`,`test`.`t2`.`f21` AS `f21`,`test`.`t2`.`f22` AS `f22`,`test`.`t2`.`f23` AS `f23`,`test`.`t2`.`f24` AS `f24`,`test`.`t2`.`f25` AS `f25`,`test`.`t2`.`f26` AS `f26`,`test`.`t2`.`f27` AS `f27`,`test`.`t2`.`f28` AS `f28`,`test`.`t2`.`f29` AS `f29`,`test`.`t2`.`f30` AS `f30`,`test`.`t2`.`f31` AS `f31`,`test`.`t2`.`f32` AS `f32`,`test`.`t2`.`fk` AS `fk` from `test`.`t2`) `alias2` where (`alias2`.`fk` = `test`.`alias1`.`fk`) +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +# +# +# Bug#12910039: Incorrect merge caused segmentation fault. +# +CREATE TABLE t1 (f1 int) ENGINE=myisam; +CREATE TABLE t2 (f1 text) ENGINE=innodb; +SELECT 1 FROM ( +( SELECT * FROM ( SELECT * FROM t2 ) AS alias1 ) AS alias1, +( SELECT * FROM t1 ) AS alias2 ); +1 +DROP TABLE t1,t2; +# +# +# Bug#12910006: MRR initialization on a derived table caused crash. +# +SET @save_switch= @@SESSION.optimizer_switch; +SET @@SESSION.optimizer_switch="batched_key_access=on,derived_merge=off"; +CREATE TABLE t1 ( pk integer auto_increment, +col_blob_key blob, primary key (pk)) ENGINE=innodb; +CREATE TABLE t2 (col_tinytext tinytext null, +pk integer auto_increment, col_text text, +col_blob blob, primary key (pk)) ENGINE=innodb; +SELECT alias1.col_text AS field1 , +alias1.col_tinytext AS field2 +FROM t2 AS alias1 +LEFT OUTER JOIN ( SELECT * FROM t1 ) AS alias2 ON alias1.pk = alias2.pk +WHERE alias2.pk >=1 AND alias2.pk < 3 +ORDER BY field1,field2 ASC; +field1 field2 +SET @@SESSION.optimizer_switch= @save_switch; +DROP TABLE t1, t2; +# +# Bug#13106350: MRR initialization on a derived table caused crash. +# +SET @save_switch= @@optimizer_switch; +SET @@optimizer_switch="materialization=off,derived_merge=off"; +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, vc VARCHAR(20)) charset utf8mb4; +INSERT INTO t1 VALUES(7, 'seven'), (13, 'thirteen'); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, vc1 VARCHAR(20), vc2 VARCHAR(20)) charset utf8mb4; +INSERT INTO t2 VALUES(7, 'seven', 's'), (14, 'fourteen', 'f'); +CREATE TABLE t3 (pk INTEGER PRIMARY KEY, vc VARCHAR(20)) charset utf8mb4; +INSERT INTO t3 VALUES(5, 'f'), (6, 's'), (7, 's'); +explain SELECT derived.vc +FROM (SELECT * FROM t1) AS derived +WHERE derived.vc IN ( +SELECT t2.vc1 +FROM t2 JOIN t3 ON t2.vc2=t3.vc); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 83 test.t2.vc1 2 100.00 End temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `derived`.`vc` AS `vc` from (/* select#2 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`vc` AS `vc` from `test`.`t1`) `derived` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`vc` = `test`.`t2`.`vc2`) and (`derived`.`vc` = `test`.`t2`.`vc1`)) +SELECT derived.vc +FROM (SELECT * FROM t1) AS derived +WHERE derived.vc IN ( +SELECT t2.vc1 +FROM t2 JOIN t3 ON t2.vc2=t3.vc); +vc +seven +SET @@optimizer_switch= @save_switch; +DROP TABLE t1, t2, t3; +# +# +# Bug#13107577: Derived table in a semi-join caused failed assertion. +# +SET @save_switch= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +CREATE TABLE t1 ( +`col_int_key` int(11) NOT NULL, +`col_varchar_nokey` varchar(1) NOT NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (8,'m'), (4,'b'), (4,'x'), (7,'g'), (4,'p'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT col_int_key +FROM t1 +WHERE ( NOT EXISTS ( +SELECT col_varchar_nokey +FROM t1 +WHERE ( 7 ) IN ( +SELECT v1.col_int_key +FROM ( v1 JOIN ( SELECT * FROM t1 ) AS d1 +ON ( d1.col_varchar_nokey = v1.col_varchar_nokey ) ) +) +) ) +; +col_int_key +DROP VIEW v1; +DROP TABLE t1; +SET @@optimizer_switch= @save_switch; +# +# Bug#13105833: Crash when using LooseScan sj-strategy for a view. +# +CREATE TABLE t1 (pk int(11)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (pk int(11)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 AS SELECT DISTINCT pk FROM t1; +SELECT pk +FROM t2 +WHERE pk IN ( SELECT * FROM v1 ) ; +pk +1 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# +# Bug#13261277: Unchecked key length caused missing records. +# +CREATE TABLE t1 ( +col_varchar varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +stub1 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +stub2 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +stub3 varchar(1024) CHARACTER SET utf8 DEFAULT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('d','d','l','ther'), +(NULL,'s','NJBIQ','trzetuchv'), +(-715390976,'coul','MYWFB','cfhtrzetu'), +(1696792576,'f','i\'s','c'), + (1,'i','ltpemcfhtr','gsltpemcf'), + (-663027712,'mgsltpemcf','sa','amgsltpem'), + (-1686700032,'JPRVK','i','vamgsltpe'), + (NULL,'STUNB','UNVJV','u'), + (5,'oka','qyihvamgsl','AXSMD'), + (NULL,'tqwmqyihva','h','yntqwmqyi'), + (3,'EGMJN','e','e'); +CREATE TABLE t2 ( +col_varchar varchar(10) DEFAULT NULL, +col_int INT DEFAULT NULL +) charset utf8mb4; +INSERT INTO t2 VALUES ('d',9); +SET @save_heap_size= @@max_heap_table_size; +SET @@max_heap_table_size= 16384; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT t2.col_int +FROM t2 +RIGHT JOIN ( SELECT * FROM t1 ) AS dt +ON t2.col_varchar = dt.col_varchar +WHERE t2.col_int IS NOT NULL ; +col_int +9 +# Shouldn't use auto_key0 for derived table +EXPLAIN +SELECT t2.col_int +FROM t2 +RIGHT JOIN ( SELECT * FROM t1 ) AS dt +ON t2.col_varchar = dt.col_varchar +WHERE t2.col_int IS NOT NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 11 10.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '9' AS `col_int` from (/* select#2 */ select `test`.`t1`.`col_varchar` AS `col_varchar`,`test`.`t1`.`stub1` AS `stub1`,`test`.`t1`.`stub2` AS `stub2`,`test`.`t1`.`stub3` AS `stub3` from `test`.`t1`) `dt` where (('9' is not null) and ('d' = `dt`.`col_varchar`)) +SET @@max_heap_table_size= @save_heap_size; +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1,t2; +# +# +# Bug#13383857: Another crash in memcpy from +# join_cache::write_record_data with semijoin +# +CREATE TABLE t1 ( +col_int_key INT DEFAULT NULL, +col_time_nokey TIME DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset latin1; +INSERT INTO t1 VALUES +(8,'22:55:23','x','x'), +(7,'10:19:31','d','d'), +(1,'14:40:36','r','r'), +(7,'04:37:47','f','f'), +(9,'19:34:06','y','y'), +(NULL,'20:35:33','u','u'), +(1,NULL,'m','m'), +(9,'14:43:37',NULL,NULL), +(2,'02:23:09','o','o'), +(9,'01:22:45','w','w'), +(2,'00:00:00','m','m'), +(4,'00:13:25','q','q'), +(0,'03:47:16',NULL,NULL), +(4,'01:41:48','d','d'), +(8,'00:00:00','g','g'), +(NULL,'22:32:04','x','x'), +(NULL,'16:44:14','f','f'), +(0,'17:38:37','p','p'), +(NULL,'08:46:48','j','j'), +(8,'14:11:27','c','c'); +CREATE TABLE t2 ( +col_int_key INT DEFAULT NULL, +col_time_nokey TIME DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset latin1; +INSERT INTO t2 VALUES +(4,'22:34:09','v','v'), +(62,'14:26:02','v','v'), +(7,'14:03:03','c','c'), +(1,'01:46:09',NULL,NULL), +(0,'16:21:18','x','x'), +(7,'18:56:33','i','i'), +(7,NULL,'e','e'), +(1,'09:29:08','p','p'), +(7,'19:11:10','s','s'), +(1,'11:57:26','j','j'), +(5,'00:39:46','z','z'), +(2,'03:28:15','c','c'), +(0,'06:44:18','a','a'), +(1,'14:36:39','q','q'), +(8,'18:42:45','y','y'), +(1,'02:57:29',NULL,NULL), +(1,'16:46:13','r','r'), +(9,'19:39:02','v','v'), +(1,NULL,NULL,NULL), +(5,'20:58:33','r','r'); +CREATE TABLE t3 ( +col_int_key INT DEFAULT NULL, +col_time_nokey TIME DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset latin1; +INSERT INTO t3 VALUES (8,'04:07:22','g','g'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT col_time_nokey AS x +FROM (SELECT * FROM t2) AS outr +WHERE col_varchar_nokey IN ( +SELECT innr.col_varchar_key +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t1) AS innr +ON innr2.col_varchar_key >= innr.col_varchar_key +WHERE outr.col_varchar_nokey = 'e' + ) +AND outr.col_varchar_key <> 'r' +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 4 outr.col_varchar_nokey 2 100.00 End temporary +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +4 DERIVED t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED t2 NULL ALL col_varchar_key NULL NULL NULL 20 7.50 Using where +Warnings: +Note 1276 Field or reference 'outr.col_varchar_nokey' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `outr`.`col_time_nokey` AS `x` from (/* select#2 */ select `test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_time_nokey` AS `col_time_nokey`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` where ((`test`.`t2`.`col_varchar_nokey` = 'e') and (`test`.`t2`.`col_varchar_key` <> 'r'))) `outr` semi join ((/* select#4 */ select '8' AS `col_int_key`,'04:07:22' AS `col_time_nokey`,'g' AS `col_varchar_key`,'g' AS `col_varchar_nokey` from dual) `innr2` join (/* select#5 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_time_nokey` AS `col_time_nokey`,`test`.`t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1`) `innr`) where ((`innr`.`col_varchar_key` = `outr`.`col_varchar_nokey`) and (`innr2`.`col_varchar_key` >= `outr`.`col_varchar_nokey`)) +SELECT col_time_nokey AS x +FROM (SELECT * FROM t2) AS outr +WHERE col_varchar_nokey IN ( +SELECT innr.col_varchar_key +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t1) AS innr +ON innr2.col_varchar_key >= innr.col_varchar_key +WHERE outr.col_varchar_nokey = 'e' + ) +AND outr.col_varchar_key <> 'r' +; +x +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# +# Bug#13354889: Crash on a derived table with more than 64 fields. +# +create table t1 ( +field00 int, field01 int, field02 int, field03 int, +field04 int, field05 int, field06 int, field07 int, +field10 int, field11 int, field12 int, field13 int, +field14 int, field15 int, field16 int, field17 int, +field20 int, field21 int, field22 int, field23 int, +field24 int, field25 int, field26 int, field27 int, +field30 int, field31 int, field32 int, field33 int, +field34 int, field35 int, field36 int, field37 int, +field40 int, field41 int, field42 int, field43 int, +field44 int, field45 int, field46 int, field47 int, +field50 int, field51 int, field52 int, field53 int, +field54 int, field55 int, field56 int, field57 int, +field60 int, field61 int, field62 int, field63 int, +field64 int, field65 int, field66 int, field67 int, +field70 int, field71 int, field72 int, field73 int, +field74 int, field75 int, field76 int, field77 int, +field100 int +); +insert into t1(field100) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +select tt.field100 from t1 join (select * from t1) tt where t1.field100=tt.field100 +limit 1; +field100 +1 +Should use auto_key0 and ref access. +explain +select tt.field100 from t1 join (select * from t1) tt where t1.field100=tt.field100 +limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 80 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.field100 8 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 80 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `tt`.`field100` AS `field100` from `test`.`t1` join (/* select#2 */ select `test`.`t1`.`field00` AS `field00`,`test`.`t1`.`field01` AS `field01`,`test`.`t1`.`field02` AS `field02`,`test`.`t1`.`field03` AS `field03`,`test`.`t1`.`field04` AS `field04`,`test`.`t1`.`field05` AS `field05`,`test`.`t1`.`field06` AS `field06`,`test`.`t1`.`field07` AS `field07`,`test`.`t1`.`field10` AS `field10`,`test`.`t1`.`field11` AS `field11`,`test`.`t1`.`field12` AS `field12`,`test`.`t1`.`field13` AS `field13`,`test`.`t1`.`field14` AS `field14`,`test`.`t1`.`field15` AS `field15`,`test`.`t1`.`field16` AS `field16`,`test`.`t1`.`field17` AS `field17`,`test`.`t1`.`field20` AS `field20`,`test`.`t1`.`field21` AS `field21`,`test`.`t1`.`field22` AS `field22`,`test`.`t1`.`field23` AS `field23`,`test`.`t1`.`field24` AS `field24`,`test`.`t1`.`field25` AS `field25`,`test`.`t1`.`field26` AS `field26`,`test`.`t1`.`field27` AS `field27`,`test`.`t1`.`field30` AS `field30`,`test`.`t1`.`field31` AS `field31`,`test`.`t1`.`field32` AS `field32`,`test`.`t1`.`field33` AS `field33`,`test`.`t1`.`field34` AS `field34`,`test`.`t1`.`field35` AS `field35`,`test`.`t1`.`field36` AS `field36`,`test`.`t1`.`field37` AS `field37`,`test`.`t1`.`field40` AS `field40`,`test`.`t1`.`field41` AS `field41`,`test`.`t1`.`field42` AS `field42`,`test`.`t1`.`field43` AS `field43`,`test`.`t1`.`field44` AS `field44`,`test`.`t1`.`field45` AS `field45`,`test`.`t1`.`field46` AS `field46`,`test`.`t1`.`field47` AS `field47`,`test`.`t1`.`field50` AS `field50`,`test`.`t1`.`field51` AS `field51`,`test`.`t1`.`field52` AS `field52`,`test`.`t1`.`field53` AS `field53`,`test`.`t1`.`field54` AS `field54`,`test`.`t1`.`field55` AS `field55`,`test`.`t1`.`field56` AS `field56`,`test`.`t1`.`field57` AS `field57`,`test`.`t1`.`field60` AS `field60`,`test`.`t1`.`field61` AS `field61`,`test`.`t1`.`field62` AS `field62`,`test`.`t1`.`field63` AS `field63`,`test`.`t1`.`field64` AS `field64`,`test`.`t1`.`field65` AS `field65`,`test`.`t1`.`field66` AS `field66`,`test`.`t1`.`field67` AS `field67`,`test`.`t1`.`field70` AS `field70`,`test`.`t1`.`field71` AS `field71`,`test`.`t1`.`field72` AS `field72`,`test`.`t1`.`field73` AS `field73`,`test`.`t1`.`field74` AS `field74`,`test`.`t1`.`field75` AS `field75`,`test`.`t1`.`field76` AS `field76`,`test`.`t1`.`field77` AS `field77`,`test`.`t1`.`field100` AS `field100` from `test`.`t1`) `tt` where (`tt`.`field100` = `test`.`t1`.`field100`) limit 1 +SET @@optimizer_switch= @optimizer_switch_saved; +drop table t1; +# +# +# Bug#13390138: crash in memcpy from join_cache::write_record_data +# +CREATE TABLE t1 ( +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES ('r','r'); +CREATE TABLE t2 ( +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(NULL,NULL), +('r','r'); +CREATE TABLE t3 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t3 VALUES +(9,'f','f'), +(4,'y','y'), +(3,'u','u'), +(2,'m','m'), +(NULL,NULL,NULL), +(2,'o','o'), +(NULL,'r','r'), +(6,'m','m'), +(7,'q','q'), +(6,'c','c'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT grandparent.col_varchar_nokey AS g1 +FROM (SELECT * FROM t3) AS grandparent +WHERE grandparent.col_varchar_nokey IN +(SELECT parent.col_varchar_key AS p1 +FROM (SELECT * FROM t2) AS parent +WHERE grandparent.col_varchar_key IN ( +SELECT child1.col_varchar_key AS c1 +FROM (SELECT * FROM t1) AS child1 +LEFT JOIN (SELECT * FROM t2) AS child2 +ON child1.col_varchar_nokey <> child2.col_varchar_key +) +AND grandparent.col_int_key IS UNKNOWN +) +ORDER BY grandparent.col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using temporary; Using filesort; Start temporary +1 PRIMARY NULL ref 7 child1.col_varchar_key 2 100.00 Using where +1 PRIMARY NULL ref 7 grandparent.col_varchar_nokey 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +7 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +6 DERIVED t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t3 NULL ref col_int_key col_int_key 5 const 2 100.00 Using index condition +Warnings: +Note 1276 Field or reference 'grandparent.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'grandparent.col_int_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `grandparent`.`col_varchar_nokey` AS `g1` from (/* select#2 */ select `test`.`t3`.`col_int_key` AS `col_int_key`,`test`.`t3`.`col_varchar_key` AS `col_varchar_key`,`test`.`t3`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t3` where (`test`.`t3`.`col_int_key` is null)) `grandparent` semi join ((/* select#4 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `parent` join (/* select#6 */ select 'r' AS `col_varchar_key`,'r' AS `col_varchar_nokey` from dual) `child1` left join (/* select#7 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `child2` on((`child1`.`col_varchar_nokey` <> `child2`.`col_varchar_key`))) where ((`grandparent`.`col_varchar_key` = `child1`.`col_varchar_key`) and (`parent`.`col_varchar_key` = `grandparent`.`col_varchar_nokey`)) order by `grandparent`.`col_varchar_nokey` +SELECT grandparent.col_varchar_nokey AS g1 +FROM (SELECT * FROM t3) AS grandparent +WHERE grandparent.col_varchar_nokey IN +(SELECT parent.col_varchar_key AS p1 +FROM (SELECT * FROM t2) AS parent +WHERE grandparent.col_varchar_key IN ( +SELECT child1.col_varchar_key AS c1 +FROM (SELECT * FROM t1) AS child1 +LEFT JOIN (SELECT * FROM t2) AS child2 +ON child1.col_varchar_nokey <> child2.col_varchar_key +) +AND grandparent.col_int_key IS UNKNOWN +) +ORDER BY grandparent.col_varchar_nokey; +g1 +r +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# +# Bug#13457552: Crash on instantiating a derived table in a query with +# empty result. +# +CREATE TABLE t1 ( pk INT, col_blob BLOB ) ENGINE = MyISAM; +CREATE TABLE t2 ( pk INT, col_blob BLOB ) ENGINE = InnoDB; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +FLUSH STATUS; +SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS A NATURAL JOIN t1; +pk +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +EXPLAIN SELECT pk FROM ( SELECT col_blob, pk FROM t2 ) AS a NATURAL JOIN t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `a`.`pk` AS `pk` from (/* select#2 */ select `test`.`t2`.`col_blob` AS `col_blob`,`test`.`t2`.`pk` AS `pk` from `test`.`t2`) `a` join `test`.`t1` where (multiple equal(`a`.`col_blob`, NULL) and multiple equal(`a`.`pk`, NULL)) +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1,t2; +# +# Bug #13801019 ASSERTION `0' FAILED IN CREATE_MYISAM_TMP_TABLE +# +CREATE TABLE t1 (a INT, b BLOB) ENGINE=InnoDB; +CREATE TABLE t2 (c INT); +CREATE TABLE t3 (d INT); +INSERT INTO t3 VALUES (0); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * FROM (SELECT * FROM t1) AS a1 RIGHT JOIN t3 LEFT JOIN t2 ON d=c ON a=c; +a b d c +NULL NULL 0 NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# +# Bug #17814492 - INVALID RESULTS FROM SUBQUERY WITH IN CLAUSE +# +CREATE TABLE t1 ( +a INTEGER NOT NULL, +b VARCHAR(1000) NOT NULL, +c TEXT NOT NULL +)ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'xxx', 'abc'); +INSERT INTO t1 VALUES (2, 'yyy', 'abc'); +INSERT INTO t1 SELECT a, b, c FROM t1 WHERE b='yyy'; +INSERT INTO t1 SELECT a, b, c FROM t1 WHERE b='yyy'; +INSERT INTO t1 SELECT a, b, c FROM t1 WHERE b='yyy'; +CREATE TABLE t2 ( +a INTEGER NOT NULL +)ENGINE=InnoDB; +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @save_optimizer_switch= @@optimizer_switch; +SET @@SESSION.optimizer_switch="index_condition_pushdown=on"; +EXPLAIN SELECT a1.a, a1.b, a1.c FROM (SELECT a, b, c FROM t1 ) a1 +JOIN t2 ON a1.a=t2.a WHERE a1.b='xxx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = 'xxx')) +SELECT a1.a, a1.b, a1.c FROM (SELECT a, b, c FROM t1 ) a1 +JOIN t2 ON a1.a=t2.a WHERE a1.b='xxx'; +a b c +1 xxx abc +SET @@SESSION.optimizer_switch= @save_optimizer_switch; +DROP TABLE t2, t1; +# End of test for Bug #17814492 +# +# WL#5275 Process subqueries in FROM clause in the same way as view +# +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +INSERT INTO t2 VALUES(1, 100), (2, 200); +SELECT * +FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1, (SELECT * FROM t2) AS dt WHERE t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1, (SELECT * FROM t2) AS dt WHERE t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b a b +1 10 1 100 1 100 +2 20 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t1.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt2 +ON dt1.a=dt2.a; +a b b a b a b +1 10 100 1 100 1 100 +2 20 200 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN +(SELECT t1.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN +(SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt2 +ON dt1.a=dt2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a) +WHERE t1.b > 15) AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a) +WHERE t1.b > 15) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` > 15)) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 +WHERE a IN (SELECT a FROM t1)) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 +WHERE a IN (SELECT a FROM t1)) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` union /* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION ALL SELECT * FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +1 10 1 100 +2 20 2 200 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 UNION ALL SELECT * FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` union all /* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT DISTINCT a, b FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT DISTINCT a, b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT SUM(a) AS a, SUM(b) AS b FROM t2) AS dt ON t1.a=dt.a; +a b a b +explain SELECT * +FROM t1 JOIN (SELECT SUM(a) AS a, SUM(b) AS b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'3' AS `a`,'300' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '3') +SELECT * +FROM t1 JOIN (SELECT a, SUM(b) AS b FROM t2 GROUP BY a) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT a, SUM(b) AS b FROM t2 GROUP BY a) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `b` from `test`.`t2` group by `test`.`t2`.`a`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT 1 AS a FROM t2 HAVING COUNT(*) > 1) AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN (SELECT 1 AS a FROM t2 HAVING COUNT(*) > 1) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,NULL AS `a` from `test`.`t1` join (/* select#2 */ select 1 AS `a` from `test`.`t2` having (count(0) > 1)) `dt` where multiple equal(`test`.`t1`.`a`, NULL) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 1) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 1) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a`,'100' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 2 OFFSET 1) AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 LIMIT 2 OFFSET 1) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` limit 1,2) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT 1 AS a) AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN (SELECT 1 AS a) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN (SELECT a, b, @c:= a+b FROM t2) AS dt ON t1.a=dt.a; +a b a b @c:= a+b +1 10 1 100 101 +2 20 2 200 202 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +explain SELECT * +FROM t1 JOIN (SELECT a, b, @c:= a+b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b`,`dt`.`@c:= a+b` AS `@c:= a+b` from `test`.`t1` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,(@c:=(`test`.`t2`.`a` + `test`.`t2`.`b`)) AS `@c:= a+b` from `test`.`t2`) `dt` where (`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +a b +1 100 +2 200 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +a b +2 200 +1 100 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` desc +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +WHERE dt.a > 0; +a b +1 100 +2 200 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` +SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +WHERE dt.a > 0; +a b +2 200 +1 100 +explain SELECT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` desc +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a) AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT * FROM t2 ORDER BY t2.a DESC) AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN (SELECT a, (SELECT COUNT(*) FROM t1) AS b FROM t2) AS dt +ON t1.a=dt.a; +a b a b +1 10 1 2 +2 20 2 2 +explain SELECT * +FROM t1 JOIN (SELECT a, (SELECT COUNT(*) FROM t1) AS b FROM t2) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,(/* select#3 */ select count(0) from `test`.`t1`) AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN (SELECT a, (SELECT b) AS b FROM t2) AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN (SELECT a, (SELECT b) AS b FROM t2) AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a`,`dt`.`b` AS `b` from `test`.`t1` join `test`.`t2` join (/* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) `dt` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`dt`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch="derived_merge=on"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN (SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a)) AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch= @optimizer_switch_saved; +INSERT INTO (SELECT * FROM t1) AS dt VALUES(9, 99); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT * FROM t1) AS dt VALUES(9, 99)' at line 1 +INSERT INTO (SELECT * FROM t1) AS dt SELECT 9, 99; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT * FROM t1) AS dt SELECT 9, 99' at line 1 +UPDATE (SELECT * FROM t1) AS dt SET b=b+1; +ERROR HY000: The target table dt of the UPDATE is not updatable +UPDATE t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a SET dt.b=dt.b+1; +ERROR HY000: The target table t2 of the UPDATE is not updatable +DELETE FROM (SELECT * FROM t1) AS dt WHERE a=1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT * FROM t1) AS dt WHERE a=1' at line 1 +DELETE dt FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a WHERE t1.a=1; +ERROR HY000: The target table dt of the DELETE is not updatable +UPDATE t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a SET t1.b=t1.b+1; +DELETE t1 FROM t1 JOIN (SELECT * FROM t2) AS dt ON t1.a=dt.a WHERE t1.a=1; +SELECT * FROM t1; +a b +2 21 +SELECT * FROM t2; +a b +1 100 +2 200 +DROP TABLE t1, t2; +# Bug#19791944: Assert fail in subselect_hash_sj_engine::exec +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,4,'j'), (2,6,'v'), (3,3,'c'), (4,5,'m'), (5,3,'d'), (6,246,'d'), (7,2,'y'), (8,9,'t'), +(9,3,'d'), (10,8,'s'), (11,1,'r'), (12,8,'m'), (13,8,'b'), (14,5,'x'), (15,7,'g'), (16,5,'p'), +(17,1,'q'), (18,6,'w'), (19,2,'d'), (20,9,'e'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_date_key date NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,1,7,'1900-01-01','k'); +CREATE TABLE t3 ( +pk int NOT NULL , +col_date_nokey date NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t3 VALUES (10,'1900-01-01','b'); +EXPLAIN SELECT outr.col_date_key AS x +FROM (SELECT * FROM t1) AS outr2 LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_varchar_key = outr.col_varchar_nokey +WHERE (outr.col_int_key, outr.col_int_key) IN +(SELECT innr.pk AS x, innr.pk AS y +FROM (SELECT * FROM t3) AS innr +WHERE innr.col_date_nokey IS NOT NULL XOR +innr.col_varchar_nokey > 'p' + ORDER BY innr.col_date_nokey) XOR +(outr.col_int_nokey < 2 OR +NOT outr.col_int_key IS NULL) +ORDER BY outr.col_int_key, +outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_varchar_key 10 NULL 20 100.00 Using index; Using temporary; Using filesort +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +4 DEPENDENT SUBQUERY t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_date_key` AS `x` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`)) where (((`test`.`t2`.`col_int_key`,`test`.`t2`.`col_int_key`),(/* select#4 */ select '10' AS `x`,'10' AS `y` from dual where ((true xor ('b' > 'p')) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_key`) = '10') or ('10' is null)), true) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_key`) = '10') or ('10' is null)), true)) having ((outer_field_is_not_null, ('10'), true) and (outer_field_is_not_null, ('10'), true)))) xor ((`test`.`t2`.`col_int_nokey` < 2) or (`test`.`t2`.`col_int_key` is not null))) order by `test`.`t2`.`col_int_key`,`test`.`t2`.`pk` +SELECT outr.col_date_key AS x +FROM (SELECT * FROM t1) AS outr2 LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_varchar_key = outr.col_varchar_nokey +WHERE (outr.col_int_key, outr.col_int_key) IN +(SELECT innr.pk AS x, innr.pk AS y +FROM (SELECT * FROM t3) AS innr +WHERE innr.col_date_nokey IS NOT NULL XOR +innr.col_varchar_nokey > 'p' + ORDER BY innr.col_date_nokey) XOR +(outr.col_int_nokey < 2 OR +NOT outr.col_int_key IS NULL) +ORDER BY outr.col_int_key, +outr.pk; +x +DROP TABLE t1, t2, t3; +# Bug#20087645: Assert fail in subselect_hash_sj_engine::exec +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,1,'v'), (11,7,'s'), (12,4,'l'), (13,7,'y'), (14,0,'c'), (15,2,'i'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'k','k'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'j'), (2,'v'), (3,'c'), (4,'m'), (5,'d'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT table1.pk +FROM (SELECT * FROM t1) AS table1 +LEFT JOIN +(SELECT * FROM t1) AS table2 +RIGHT OUTER JOIN +(SELECT * FROM t2) AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.pk = table2.col_int_nokey +WHERE table3.col_varchar_key <> ALL +(SELECT sq1_t1.col_varchar_nokey AS sq1_field1 +FROM (SELECT * FROM t3) AS sq1_t1 +LEFT OUTER JOIN +(SELECT * FROM t1) AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar_nokey +) OR +table1.pk = 96; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index PRIMARY col_varchar_key 6 NULL 6 100.00 Using index +1 PRIMARY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +1 PRIMARY t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 Using where +5 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +5 SUBQUERY t1 NULL ref col_varchar_key col_varchar_key 6 test.t3.col_varchar_nokey 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` left join (`test`.`t2` join `test`.`t1`) on(((`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) and (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`pk`))) where ((`test`.`t2`.`col_varchar_key`,`test`.`t2`.`col_varchar_key` in ( (/* select#5 */ select `test`.`t3`.`col_varchar_nokey` AS `sq1_field1` from `test`.`t3` left join (`test`.`t1`) on((`test`.`t1`.`col_varchar_key` = `test`.`t3`.`col_varchar_nokey`)) where true ), (`test`.`t2`.`col_varchar_key` in on where ((`test`.`t2`.`col_varchar_key` = ``.`sq1_field1`)))) is false) or (`test`.`t1`.`pk` = 96)) +SELECT table1.pk +FROM (SELECT * FROM t1) AS table1 +LEFT JOIN +(SELECT * FROM t1) AS table2 +RIGHT OUTER JOIN +(SELECT * FROM t2) AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.pk = table2.col_int_nokey +WHERE table3.col_varchar_key <> ALL +(SELECT sq1_t1.col_varchar_nokey AS sq1_field1 +FROM (SELECT * FROM t3) AS sq1_t1 +LEFT OUTER JOIN +(SELECT * FROM t1) AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar_nokey +) OR +table1.pk = 96; +pk +DROP TABLE t1, t2, t3; +# Bug#19812352: Assert fail in subselect_hash_sj_engine::setup +CREATE TABLE t1 ( +col_time_nokey time NOT NULL +); +INSERT INTO t1 VALUES ('00:00:00'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_date_nokey date NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,4,0,'0001-01-01','j','j'), (2,6,8,'2004-09-18','v','v'), +(3,3,1,'2009-12-01','c','c'), (4,5,8,'2004-12-17','m','m'), +(5,3,9,'2000-03-14','d','d'), (6,246,24,'2000-10-08','d','d'), +(7,2,6,'2006-05-25','y','y'), (8,9,1,'2008-01-23','t','t'), +(9,3,6,'2007-06-18','d','d'), (10,8,2,'2002-10-13','s','s'), +(11,1,4,'1900-01-01','r','r'), (12,8,8,'0001-01-01','m','m'), +(13,8,4,'2006-03-09','b','b'), (14,5,4,'2001-06-05','x','x'), +(15,7,7,'2006-05-28','g','g'), (16,5,4,'2001-04-19','p','p'), +(17,1,1,'1900-01-01','q','q'), (18,6,9,'2004-08-20','w','w'), +(19,2,4,'2004-10-10','d','d'), (20,9,8,'2000-04-02','e','e'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +INSERT INTO t3 VALUES +(10,1,'v'), (11,7,'s'), (12,4,'l'), (13,7,'y'), (14,0,'c'), +(15,2,'i'), (16,9,'h'), (17,4,'q'), (18,0,'a'), (19,9,'v'), +(20,1,'u'), (21,3,'s'), (22,8,'y'), (23,8,'z'), (24,18,'h'), +(25,84,'p'), (26,6,'e'), (27,3,'i'), (28,6,'y'), (29,6,'w'); +CREATE TABLE t4 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t4 VALUES (10,8,7,'b'); +EXPLAIN SELECT outr.pk AS x +FROM (SELECT * FROM t1) AS outr2 +LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_time_nokey >= outr.col_date_nokey +WHERE (outr.col_int_nokey, outr.col_int_key) IN +(SELECT innr.col_int_key AS x, +innr.col_int_nokey AS y +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t4) AS innr +ON innr2.col_varchar_key <> innr.col_varchar_nokey +WHERE innr.col_int_key <> innr.pk OR innr.pk = 9 +) AND +outr.pk < 7 XOR outr.col_varchar_nokey <> 'i' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 Using filesort +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 20 21.11 Using where +4 DEPENDENT SUBQUERY t4 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +4 DEPENDENT SUBQUERY t3 NULL index NULL col_varchar_key 10 NULL 20 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `x` from `test`.`t2` where (((((`test`.`t2`.`col_int_nokey`,`test`.`t2`.`col_int_key`),(/* select#4 */ select '7' AS `x`,'8' AS `y` from `test`.`t3` where ((('7' <> '10') or false) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_nokey`) = '7') or ('7' is null)), true) and (outer_field_is_not_null, (((`test`.`t2`.`col_int_key`) = '8') or ('8' is null)), true) and (`test`.`t3`.`col_varchar_key` <> 'b')) having ((outer_field_is_not_null, ('7'), true) and (outer_field_is_not_null, ('8'), true)))) and (`test`.`t2`.`pk` < 7)) xor (`test`.`t2`.`col_varchar_nokey` <> 'i')) and ('00:00:00' >= `test`.`t2`.`col_date_nokey`)) order by `test`.`t2`.`col_varchar_key`,`test`.`t2`.`pk` +SELECT outr.pk AS x +FROM (SELECT * FROM t1) AS outr2 +LEFT JOIN (SELECT * FROM t2) AS outr +ON outr2.col_time_nokey >= outr.col_date_nokey +WHERE (outr.col_int_nokey, outr.col_int_key) IN +(SELECT innr.col_int_key AS x, +innr.col_int_nokey AS y +FROM (SELECT * FROM t3) AS innr2 +LEFT JOIN (SELECT * FROM t4) AS innr +ON innr2.col_varchar_key <> innr.col_varchar_nokey +WHERE innr.col_int_key <> innr.pk OR innr.pk = 9 +) AND +outr.pk < 7 XOR outr.col_varchar_nokey <> 'i' +ORDER BY outr.col_varchar_key, outr.pk; +x +13 +3 +5 +6 +9 +19 +20 +15 +1 +4 +12 +16 +17 +11 +10 +8 +2 +18 +14 +7 +DROP TABLE t1, t2, t3, t4; +# Bug#19811762: Assert fail in JOIN::propagate_dependencies +CREATE TABLE t1 ( +pk int NOT NULL +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_nokey int DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +EXPLAIN SELECT table1.pk +FROM t1 AS table1 +RIGHT JOIN +t2 AS table2 +LEFT OUTER JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 INNER JOIN t3 AS sq2_t2 +ON sq2_t2.col_int_nokey = sq2_t1.col_int_key +WHERE sq2_t2.col_varchar_nokey <= sq2_t1.col_varchar_key OR +sq2_t2.col_int_nokey <> 2 +) AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_key +WHERE table3.pk >= 6 OR +table1.pk > 68 AND +table1.pk < ( 68 + 76 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `pk` from `test`.`t2` `table2` left join (`test`.`t2` `sq2_t1` join `test`.`t3` `sq2_t2`) on((((`test`.`sq2_t2`.`col_varchar_nokey` <= `test`.`sq2_t1`.`col_varchar_key`) or (`test`.`sq2_t2`.`col_int_nokey` <> 2)) and multiple equal(`test`.`sq2_t1`.`col_int_key`, NULL, `test`.`sq2_t2`.`col_int_nokey`))) where ((`test`.`sq2_t1`.`pk` >= 6) or ((NULL > 68) and (NULL < (68 + 76)))) +SELECT table1.pk +FROM t1 AS table1 +RIGHT JOIN +t2 AS table2 +LEFT OUTER JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 INNER JOIN t3 AS sq2_t2 +ON sq2_t2.col_int_nokey = sq2_t1.col_int_key +WHERE sq2_t2.col_varchar_nokey <= sq2_t1.col_varchar_key OR +sq2_t2.col_int_nokey <> 2 +) AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_key +WHERE table3.pk >= 6 OR +table1.pk > 68 AND +table1.pk < ( 68 + 76 ); +pk +DROP TABLE t1, t2, t3; +# +# Bug#19793998 ASSERTION FAILED: ROWS >= 0.0 IN +# HANDLER::INDEX_SCAN_COST() +# +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY +); +INSERT INTO t1 VALUES (0),(1),(2); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY +); +INSERT INTO t2 VALUES (0),(1),(2); +explain SELECT SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SUBQUERY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (sha(`test`.`t1`.`pk`),sha(`test`.`t1`.`pk`) in ( (/* select#2 */ select `` from (/* select#3 */ select '' AS `` from `test`.`t2`) `a` where true ), (sha(`test`.`t1`.`pk`) in on where ((sha(`test`.`t1`.`pk`) = ``))))) AS `SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a)` from `test`.`t1` +SELECT SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a) FROM t1; +SHA(pk) IN (SELECT * FROM (SELECT '' FROM t2) a) +0 +0 +0 +DROP TABLE t1, t2; +SET @@optimizer_switch= @optimizer_switch_saved; +# Bug#20073930 Assert fail in store_top_level_join_columns +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +) engine=innodb; +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) engine=innodb; +CREATE TABLE t3 ( +pk int NOT NULL, +PRIMARY KEY (pk) +) engine=innodb; +CREATE TABLE t4 ( +pk int NOT NULL , +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +) engine=innodb; +explain SELECT table2.pk AS field2 +FROM (SELECT sq1_t2.pk +FROM t1 AS sq1_t1 +JOIN +(t1 AS sq1_t2 RIGHT JOIN t2 AS sq1_t3 +ON sq1_t3.pk = sq1_t2.pk +) +ON sq1_t3.col_int_key = sq1_t2.pk AND +sq1_t1.col_varchar_key IN +(SELECT child_sq1_t2.col_varchar_key AS child_sq1_field1 +FROM t1 AS child_sq1_t2 +) +) AS table1 +LEFT JOIN +t1 AS table2 +JOIN +(SELECT sq2_t1.* FROM t1 AS sq2_t1) AS table3 +ON table3.col_varchar_key = table2.col_varchar_key +ON table3.col_varchar_key = table2.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE sq1_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE sq1_t3 NULL index PRIMARY,col_int_key col_int_key 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE sq1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.sq1_t3.col_int_key 1 100.00 Using index +2 SIMPLE child_sq1_t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(sq1_t2); Using join buffer (hash join) +2 SIMPLE table2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE sq2_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `field2` from `test`.`t1` `sq1_t1` join `test`.`t2` `sq1_t3` join `test`.`t1` `sq1_t2` semi join (`test`.`t1` `child_sq1_t2`) left join (`test`.`t1` `table2` join `test`.`t1` `sq2_t1`) on(((`test`.`sq2_t1`.`col_varchar_key` = `test`.`table2`.`col_varchar_key`))) where ((`test`.`child_sq1_t2`.`col_varchar_key` = `test`.`sq1_t1`.`col_varchar_key`) and (`test`.`sq1_t3`.`pk` = `test`.`sq1_t3`.`col_int_key`) and (`test`.`sq1_t2`.`pk` = `test`.`sq1_t3`.`col_int_key`)) +SELECT table2.pk AS field2 +FROM (SELECT sq1_t2.pk +FROM t1 AS sq1_t1 +JOIN +(t1 AS sq1_t2 RIGHT JOIN t2 AS sq1_t3 +ON sq1_t3.pk = sq1_t2.pk +) +ON sq1_t3.col_int_key = sq1_t2.pk AND +sq1_t1.col_varchar_key IN +(SELECT child_sq1_t2.col_varchar_key AS child_sq1_field1 +FROM t1 AS child_sq1_t2 +) +) AS table1 +LEFT JOIN +t1 AS table2 +JOIN +(SELECT sq2_t1.* FROM t1 AS sq2_t1) AS table3 +ON table3.col_varchar_key = table2.col_varchar_key +ON table3.col_varchar_key = table2.col_varchar_key; +field2 +DROP TABLE t1, t2, t3, t4; +# Bug#20118755 Assert fail in JOIN::propagate_dependencies +CREATE TABLE t1 ( +pk int NOT NULL , +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +explain SELECT table1.pk AS field1, +table2.pk field2 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 +) AS table1 +RIGHT JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 +WHERE sq2_t1.col_int_key NOT IN +(SELECT child_sq1_t1.col_int_key AS child_sq2_field1 +FROM t2 AS child_sq1_t1 +) +) AS table2 +RIGHT JOIN t2 AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.col_varchar_nokey = table2.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1003 /* select#1 */ select `test`.`sq1_t1`.`pk` AS `field1`,`test`.`sq2_t1`.`pk` AS `field2` from `test`.`t2` `table3` left join (`test`.`t2` `sq2_t1`) on(((`test`.`sq2_t1`.`col_int_key`,(/* select#3 */ select `test`.`child_sq1_t1`.`col_int_key` AS `child_sq2_field1` from `test`.`t2` `child_sq1_t1` where (outer_field_is_not_null, (((`test`.`sq2_t1`.`col_int_key`) = `test`.`child_sq1_t1`.`col_int_key`) or (`test`.`child_sq1_t1`.`col_int_key` is null)), true) having (outer_field_is_not_null, (`test`.`child_sq1_t1`.`col_int_key`), true)) is false) and multiple equal(NULL, `test`.`sq2_t1`.`col_varchar_key`))) left join (`test`.`t1` `sq1_t1`) on(multiple equal(NULL, `test`.`sq2_t1`.`col_varchar_key`)) +SELECT table1.pk AS field1, +table2.pk field2 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 +) AS table1 +RIGHT JOIN +(SELECT sq2_t1.* +FROM t2 AS sq2_t1 +WHERE sq2_t1.col_int_key NOT IN +(SELECT child_sq1_t1.col_int_key AS child_sq2_field1 +FROM t2 AS child_sq1_t1 +) +) AS table2 +RIGHT JOIN t2 AS table3 +ON table3.col_varchar_nokey = table2.col_varchar_key +ON table3.col_varchar_nokey = table2.col_varchar_key; +field1 field2 +DROP TABLE t1, t2; +# Bug#20073366 Assert fail in +# Optimize_table_order::Optimize_straight_join +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +explain SELECT STRAIGHT_JOIN alias1.col_date_key AS field1 +FROM t1 AS alias1 +INNER JOIN +((SELECT sq1_alias1.col_varchar_key +FROM t1 AS sq1_alias1 RIGHT OUTER JOIN t2 AS sq1_alias2 +ON sq1_alias2.pk = sq1_alias1.col_int_key +WHERE ('n', 'l') IN +(SELECT +c_sq1_alias1.col_varchar_nokey AS c_sq1_field1, +c_sq1_alias1.col_varchar_key AS c_sq1_field2 +FROM t3 AS c_sq1_alias1 +INNER JOIN +(t1 AS c_sq1_alias2 +INNER JOIN t1 AS c_sq1_alias3 +ON c_sq1_alias3.col_varchar_key = c_sq1_alias2.col_varchar_key +) +ON c_sq1_alias3.pk = c_sq1_alias2.pk +WHERE c_sq1_alias3.col_int_nokey <> c_sq1_alias2.col_int_nokey +) AND +sq1_alias2.col_varchar_key = 't' + ) AS alias2 +INNER JOIN t3 AS alias3 +ON alias3.col_varchar_nokey = alias2.col_varchar_key +) +ON alias3.col_varchar_key = alias2.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `field1` from `test`.`t1` `alias1` join (/* select#2 */ select NULL AS `col_varchar_key` from `test`.`t2` `sq1_alias2` semi join (`test`.`t3` `c_sq1_alias1` join `test`.`t1` `c_sq1_alias2` join `test`.`t1` `c_sq1_alias3`) where ((`test`.`c_sq1_alias3`.`col_int_nokey` <> `test`.`c_sq1_alias2`.`col_int_nokey`) and multiple equal('t', NULL) and multiple equal('n', `test`.`c_sq1_alias1`.`col_varchar_nokey`) and multiple equal('l', `test`.`c_sq1_alias1`.`col_varchar_key`) and multiple equal(`test`.`c_sq1_alias3`.`pk`, `test`.`c_sq1_alias2`.`pk`) and multiple equal(`test`.`c_sq1_alias3`.`col_varchar_key`, `test`.`c_sq1_alias2`.`col_varchar_key`))) `alias2` join `test`.`t3` `alias3` where multiple equal(`test`.`alias3`.`col_varchar_key`, `alias2`.`col_varchar_key`, `test`.`alias3`.`col_varchar_nokey`) +SELECT STRAIGHT_JOIN alias1.col_date_key AS field1 +FROM t1 AS alias1 +INNER JOIN +((SELECT sq1_alias1.col_varchar_key +FROM t1 AS sq1_alias1 RIGHT OUTER JOIN t2 AS sq1_alias2 +ON sq1_alias2.pk = sq1_alias1.col_int_key +WHERE ('n', 'l') IN +(SELECT +c_sq1_alias1.col_varchar_nokey AS c_sq1_field1, +c_sq1_alias1.col_varchar_key AS c_sq1_field2 +FROM t3 AS c_sq1_alias1 +INNER JOIN +(t1 AS c_sq1_alias2 +INNER JOIN t1 AS c_sq1_alias3 +ON c_sq1_alias3.col_varchar_key = c_sq1_alias2.col_varchar_key +) +ON c_sq1_alias3.pk = c_sq1_alias2.pk +WHERE c_sq1_alias3.col_int_nokey <> c_sq1_alias2.col_int_nokey +) AND +sq1_alias2.col_varchar_key = 't' + ) AS alias2 +INNER JOIN t3 AS alias3 +ON alias3.col_varchar_nokey = alias2.col_varchar_key +) +ON alias3.col_varchar_key = alias2.col_varchar_key; +field1 +DROP TABLE t1, t2, t3; +# Bug#20204415 Assertion failure in TABLE_LIST::set_merged() +CREATE TABLE t(a INTEGER); +CREATE VIEW v AS SELECT * FROM t; +SET optimizer_switch='derived_merge=off'; +PREPARE s1 FROM 'SELECT * FROM v'; +PREPARE s2 FROM 'SELECT * FROM (SELECT * FROM t) AS dt'; +SET optimizer_switch='derived_merge=on'; +EXECUTE s1; +a +EXECUTE s2; +a +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DROP VIEW v; +DROP TABLE t; +# Bug#20487336 Assert length > 0 && keyparts != 0 in calc_length_and_key +CREATE TABLE t1 +(pk INTEGER PRIMARY KEY, +col_int_nokey INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 (pk) VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9), (10), +(11), (12), (13), (14), (15), (16), (17), (18), (19), (20); +CREATE TABLE t2 +(pk INTEGER PRIMARY KEY, +col_varchar_key VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2 (pk) VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9), (10), +(11), (12), (13), (14), (15), (16), (17), (18), (19), (20); +CREATE TABLE t3 +(pk INTEGER PRIMARY KEY, +col_varchar_key VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t3 (pk) VALUES +(1), (2); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain SELECT MIN(alias1.col_varchar_nokey) AS field1 +FROM (SELECT sq1_alias1.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +WHERE sq1_alias1.col_varchar_nokey IN +(SELECT c_sq1_alias2.col_varchar_key AS c_sq1_field1 +FROM t1 AS c_sq1_alias1 INNER JOIN +t1 AS c_sq1_alias2 +ON c_sq1_alias2.col_varchar_nokey = c_sq1_alias1.col_varchar_key +WHERE c_sq1_alias1.col_int_nokey <> c_sq1_alias1.col_int_nokey +) AND +sq1_alias2.pk = sq1_alias1.pk +) AS alias1, +(SELECT sq2_alias1.* +FROM t2 AS sq2_alias1 RIGHT JOIN +t3 AS sq2_alias2 +ON sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key +) AS alias2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select min(`test`.`sq1_alias1`.`col_varchar_nokey`) AS `field1` from `test`.`t1` `sq1_alias1` join `test`.`t1` `sq1_alias2` semi join (`test`.`t1` `c_sq1_alias1` join `test`.`t1` `c_sq1_alias2`) join `test`.`t3` `sq2_alias2` left join `test`.`t2` `sq2_alias1` on(multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`sq2_alias1`.`col_varchar_key`)) where false +SELECT MIN(alias1.col_varchar_nokey) AS field1 +FROM (SELECT sq1_alias1.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +WHERE sq1_alias1.col_varchar_nokey IN +(SELECT c_sq1_alias2.col_varchar_key AS c_sq1_field1 +FROM t1 AS c_sq1_alias1 INNER JOIN +t1 AS c_sq1_alias2 +ON c_sq1_alias2.col_varchar_nokey = c_sq1_alias1.col_varchar_key +WHERE c_sq1_alias1.col_int_nokey <> c_sq1_alias1.col_int_nokey +) AND +sq1_alias2.pk = sq1_alias1.pk +) AS alias1, +(SELECT sq2_alias1.* +FROM t2 AS sq2_alias1 RIGHT JOIN +t3 AS sq2_alias2 +ON sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key +) AS alias2; +field1 +NULL +DROP TABLE t1, t2, t3; +# +# Bug #18607971 : 5.5 TO 5.6 REGRESSION WITH A SUBQUERY IN THE FROM +# CLAUSE. +# +CREATE TABLE t(id INT PRIMARY KEY, +c1 INT, c2 INT, key(c2)) engine=InnoDB; +INSERT INTO t(id, c1, c2) VALUES(1, 2, 3), (2, 3, 4), (3, 3, 4), (4, 3, 4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 +GROUP BY t1.c1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t1.id, t2.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 AND t2.c2= 3 +GROUP BY t1.c1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t2 NULL ref c2 c2 5 const 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 AND t2.c2= 3 +GROUP BY t1.c1, t2.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t2 NULL ref c2 c2 5 const 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 AND t2.c2= 3 +GROUP BY t1.c1, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t2 NULL ref c2 c2 5 const 1 100.00 Using index; Using temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `a`.`c1` AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from (/* select#2 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t` `t1` join `test`.`t` `t2` where ((`test`.`t2`.`c2` = 3) and (`test`.`t1`.`c1` = 3)) group by `test`.`t1`.`c1`,`test`.`t1`.`id`) `a` join `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.c1 +GROUP BY t2.c1, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t2.c1, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t2.c2, t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON t1.id=1 AND t1.c1=t2.id +GROUP BY t1.id, t2.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 INNER JOIN t t3 ON t1.id=1 AND t1.c1=t2.id AND t2.c1=t3.id +GROUP BY t1.id, t2.c2, t3.c2) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 DERIVED t3 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT DISTINCT t1.id +FROM t t1 +WHERE t1.id= 1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id + 1 +FROM t t1 INNER JOIN t t2 ON t1.id= 1 +GROUP BY t1.id + 1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '2' AS `t1.id + 1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.c1 +FROM t t1 INNER JOIN t t2 ON t1.c1= 3 +GROUP BY 1.5) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '3' AS `c1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id +FROM t t1 INNER JOIN t t2 ON mod(t1.id,1000)= 1 +GROUP BY t1.id) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +1 PRIMARY NULL ALL NULL NULL NULL NULL 16 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL index PRIMARY,c2 c2 5 NULL 4 100.00 Using where; Using index; Using temporary +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `a`.`id` AS `id`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from (/* select#2 */ select `test`.`t1`.`id` AS `id` from `test`.`t` `t1` join `test`.`t` `t2` where ((`test`.`t1`.`id` % 1000) = 1) group by `test`.`t1`.`id`) `a` join `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +EXPLAIN SELECT * FROM +(SELECT t1.id + 1 +FROM t t1 INNER JOIN t t2 ON t1.id + 1= 2 +GROUP BY t1.id + 1) a, t b +WHERE b.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY b NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t1 NULL index PRIMARY,c2 c2 5 NULL 4 100.00 Using where; Using index +2 DERIVED t2 NULL index NULL c2 5 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `t1.id + 1`,`test`.`b`.`id` AS `id`,`test`.`b`.`c1` AS `c1`,`test`.`b`.`c2` AS `c2` from `test`.`t` `b` where (`test`.`b`.`id` between 1 and 10) +CREATE VIEW v1 AS SELECT c1 a FROM t WHERE c1 = 3; +CREATE VIEW v2 AS SELECT c2 b FROM t WHERE c2 > 3; +EXPLAIN SELECT * FROM (SELECT v1.a +FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b +GROUP BY v1.a) p, t q +WHERE q.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY q NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t NULL ref c2 c2 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10) +DROP VIEW v1; +CREATE VIEW v1 AS SELECT c1 a FROM t; +EXPLAIN SELECT * FROM (SELECT v1.a +FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b AND v1.a = 10 +GROUP BY v1.a) p, t q +WHERE q.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY q NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +1 PRIMARY NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +2 DERIVED t NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DERIVED t NULL ref c2 c2 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `p`.`a` AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from (/* select#2 */ select `test`.`t`.`c1` AS `a` from `test`.`t` left join (`test`.`t`) on(((`test`.`t`.`c1` = 10) and (`test`.`t`.`c2` = 10) and (10 > 3))) where true group by `test`.`t`.`c1`) `p` join `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10) +EXPLAIN SELECT * FROM (SELECT v1.a +FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b +WHERE v1.a = 3 +GROUP BY v1.a) p, t q +WHERE q.id BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY q NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +2 DERIVED t NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 DERIVED t NULL ref c2 c2 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10) +DROP VIEW v1, v2; +DROP TABLE t; +# Bug #20443457 : Assert fail in calc_length_and_keyparts +CREATE TABLE t1( +pk INTEGER PRIMARY KEY, +k INTEGER, +KEY k(k), +nk INTEGER); +INSERT INTO t1 VALUES(1, 10, 100), (2, 20, 200); +set @optimizer_switch_saved=@@optimizer_switch; +set @@optimizer_switch='firstmatch=off'; +explain SELECT t1.k +FROM t1 RIGHT JOIN +(SELECT t2.* +FROM t1 AS t2 JOIN t1 AS t3 +ON TRUE +WHERE t3.k IN (SELECT k FROM t1 AS t4 WHERE k>1) +) AS dt +ON t1.pk = dt.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +1 SIMPLE t4 NULL index k k 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL index k k 5 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`k` AS `k` from `test`.`t1` `t2` join `test`.`t1` `t3` semi join (`test`.`t1` `t4`) left join `test`.`t1` on((`test`.`t1`.`pk` = `test`.`t2`.`pk`)) where ((`test`.`t3`.`k` = `test`.`t4`.`k`) and (`test`.`t4`.`k` > 1)) +SELECT t1.k +FROM t1 RIGHT JOIN +(SELECT t2.* +FROM t1 AS t2 JOIN t1 AS t3 +ON TRUE +WHERE t3.k IN (SELECT k FROM t1 AS t4 WHERE k>1) +) AS dt +ON t1.pk = dt.pk; +k +10 +10 +20 +20 +SET @@optimizer_switch=@optimizer_switch_saved; +DROP TABLE t1; +# Bug#20733540: Assertion failed: !table || (!table->read_set ...) +CREATE TABLE t1(a INTEGER, b VARCHAR(10)); +INSERT INTO t1 VALUES (1,'a'); +CREATE TABLE t2(c INTEGER); +INSERT INTO t2 VALUES(0); +SELECT 1 +FROM (SELECT b FROM t1 WHERE a) AS dt1 +RIGHT JOIN t2 +ON c NOT BETWEEN 1 AND 2 +NATURAL JOIN t1 AS t3; +1 +1 +DROP TABLE t1, t2; +# Bug#21512842: Sig 11 in check_column_grant_in_table_ref +CREATE TABLE t1 ( +pk INTEGER, +col_varchar JSON NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk INTEGER, +col_date_key DATE NOT NULL, +PRIMARY KEY (pk) +); +set sql_mode=''; +SELECT * +FROM (SELECT alias2.pk AS field1 +FROM t1 AS alias1 +LEFT OUTER JOIN t2 AS alias2 +ON JSON_UNQUOTE(JSON_EXTRACT(alias1.col_varchar,'$.varc')) +COLLATE utf8mb4_general_ci = alias2.col_date_key +GROUP BY JSON_QUOTE(JSON_EXTRACT(field1,'$.intc')) +) AS dt; +field1 +set sql_mode=default; +DROP TABLE t1, t2; +# Bug#21350125: Wrong results when ORDER BY is removed +CREATE TABLE t1 ( +c1n varchar(1) NOT NULL, +c1k varchar(2) DEFAULT NULL, +KEY c1k (c1k) +); +INSERT INTO t1 VALUES ('j','jj'),('r','rr'); +CREATE TABLE t2 ( +c2k varchar(1) NOT NULL, +c2n varchar(2) DEFAULT NULL, +KEY c2k (c2k) +); +INSERT INTO t2 VALUES +('f','ff'),('t','tt'),('c','cc'),('c','cc'),('r','rr'),('k','kk'); +CREATE TABLE `empty` (dummy INTEGER); +CREATE VIEW vr AS +SELECT t2.c2n AS v_field +FROM t1 RIGHT JOIN t2 +ON t2.c2k = t1.c1k; +CREATE VIEW vl AS +SELECT t2.c2n AS v_field +FROM t2 LEFT JOIN t1 +ON t2.c2k = t1.c1k; +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN t2 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +prepare s from 'SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN t2 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field'; +execute s; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +deallocate prepare s; +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t2 LEFT JOIN t1 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +prepare s from 'SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t2 LEFT JOIN t1 +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field'; +execute s; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +deallocate prepare s; +SELECT alias1.v_field AS field1 +FROM vl AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.v_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +SELECT alias1.v_field AS field1 +FROM vr AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.v_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN +(`empty` RIGHT JOIN t2 +ON TRUE) +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +SELECT alias1.dt_field AS field1 +FROM (SELECT t2.c2n AS dt_field +FROM t1 RIGHT JOIN +(t2 LEFT JOIN `empty` + ON TRUE) +ON t2.c2k = t1.c1k +) AS alias1 +RIGHT JOIN t2 AS alias2 +ON alias2.c2n = alias1.dt_field; +field1 +ff +tt +cc +cc +cc +cc +rr +kk +DROP VIEW vl, vr; +DROP TABLE t1, t2, `empty`; +# Bug#22239474: Unexpected error 1093 on nested subquery for update +CREATE TABLE t1 (id INTEGER PRIMARY KEY, d INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +explain DELETE FROM t1 +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ref 4 test.t1.id 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 delete from `test`.`t1` where (`dt`.`id` = `test`.`t1`.`id`) +DELETE FROM t1 +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +INSERT INTO t1 VALUES(1, 10), (2, 20); +explain UPDATE t1 SET d= NULL +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ref 4 test.t1.id 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`d` = NULL where (`dt`.`id` = `test`.`t1`.`id`) +UPDATE t1 SET d= NULL +WHERE id IN (SELECT * FROM (SELECT id FROM t1) AS dt); +explain INSERT INTO t1 SELECT id+10, d FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select sql_buffer_result (`test`.`t1`.`id` + 10) AS `id+10`,`test`.`t1`.`d` AS `d` from `test`.`t1` +INSERT INTO t1 SELECT id+10, d FROM t1; +explain INSERT INTO t1 SELECT id+20, d FROM (SELECT * FROM t1) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select sql_buffer_result (`test`.`t1`.`id` + 20) AS `id+20`,`test`.`t1`.`d` AS `d` from `test`.`t1` +INSERT INTO t1 SELECT id+20, d FROM (SELECT * FROM t1) AS dt; +DROP TABLE t1; +# Bug#22223202: Query with double nested subquery much slower in 5.7 +CREATE TABLE t1 ( +t1_rowid bigint unsigned NOT NULL, +t1_co varchar(1) NOT NULL, +t1_inv_date char(3) NOT NULL, +UNIQUE KEY rowid (t1_rowid), +KEY invdate (t1_co, t1_inv_date) +) charset latin1; +INSERT INTO t1 VALUES (505975,'D','s:1'),(505981,'D','s:1'),(505869,'D','s:3'); +CREATE TABLE t2 ( +t2_rowid bigint unsigned NOT NULL, +t2_end_date char(3) NOT NULL, +UNIQUE KEY rowid (t2_rowid), +KEY end_date (t2_end_date) +) charset latin1; +INSERT INTO t2 VALUES (9,'_:L'), (10,'_<2'), (11,'_= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL invdate 6 NULL 3 100.00 Using index +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 DERIVED curr NULL index end_date end_date 3 NULL 3 100.00 Using where; Using index +3 DEPENDENT SUBQUERY prev NULL index end_date end_date 3 NULL 1 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1276 Field or reference 'test.curr.t2_end_date' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1`.`t1_inv_date` AS `t1_inv_date` from `test`.`t1` left join (/* select#2 */ select `test`.`curr`.`t2_end_date` AS `end_date`,(/* select#3 */ select `test`.`prev`.`t2_end_date` from `test`.`t2` `prev` where (`test`.`prev`.`t2_end_date` < `test`.`curr`.`t2_end_date`) order by `test`.`prev`.`t2_end_date` desc limit 1) AS `prev_end_date` from `test`.`t2` `curr` where (`test`.`curr`.`t2_end_date` >= 's:1')) `periods` on(((`periods`.`prev_end_date` < `test`.`t1`.`t1_inv_date`) and (`periods`.`end_date` >= `test`.`t1`.`t1_inv_date`))) where true +SELECT t1_inv_date +FROM t1 LEFT JOIN +(SELECT curr.t2_end_date As end_date, +(SELECT prev.t2_end_date +FROM t2 AS prev +WHERE prev.t2_end_date < curr.t2_end_date +ORDER BY prev.t2_end_date DESC LIMIT 1) AS prev_end_date +FROM t2 AS curr +WHERE curr.t2_end_date >= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +t1_inv_date +s:1 +s:1 +s:3 +explain SELECT /*+ MERGE(periods) */ t1_inv_date +FROM t1 LEFT JOIN +(SELECT curr.t2_end_date As end_date, +(SELECT prev.t2_end_date +FROM t2 AS prev +WHERE prev.t2_end_date < curr.t2_end_date +ORDER BY prev.t2_end_date DESC LIMIT 1) AS prev_end_date +FROM t2 AS curr +WHERE curr.t2_end_date >= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL invdate 6 NULL 3 100.00 Using index +1 PRIMARY curr NULL index end_date end_date 3 NULL 3 100.00 Using where; Using index; Using join buffer (hash join) +3 DEPENDENT SUBQUERY prev NULL index end_date end_date 3 NULL 1 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1276 Field or reference 'test.curr.t2_end_date' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select /*+ MERGE(`periods`@`select#1`) */ `test`.`t1`.`t1_inv_date` AS `t1_inv_date` from `test`.`t1` left join (`test`.`t2` `curr`) on((((/* select#3 */ select `test`.`prev`.`t2_end_date` from `test`.`t2` `prev` where (`test`.`prev`.`t2_end_date` < `test`.`curr`.`t2_end_date`) order by `test`.`prev`.`t2_end_date` desc limit 1) < `test`.`t1`.`t1_inv_date`) and (`test`.`curr`.`t2_end_date` >= `test`.`t1`.`t1_inv_date`) and (`test`.`curr`.`t2_end_date` >= 's:1'))) where true +SELECT /*+ MERGE(periods) */ t1_inv_date +FROM t1 LEFT JOIN +(SELECT curr.t2_end_date As end_date, +(SELECT prev.t2_end_date +FROM t2 AS prev +WHERE prev.t2_end_date < curr.t2_end_date +ORDER BY prev.t2_end_date DESC LIMIT 1) AS prev_end_date +FROM t2 AS curr +WHERE curr.t2_end_date >= 's:1' + ) AS periods +ON periods.prev_end_date < t1_inv_date AND +periods.end_date >= t1_inv_date; +t1_inv_date +s:1 +s:1 +s:3 +DROP TABLE t1, t2; +# Bug#22176604: Wrong result on outer join with uncorrelated subquery +CREATE TABLE t1 (a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +CREATE TABLE t2 (b INT, KEY(b)); +INSERT INTO t2 VALUES (7), (NULL), (1), (5), (8), (6), (4), (0), (3), (NULL); +CREATE TABLE t3 (c INT); +INSERT INTO t3 VALUES (NULL), (1), (5); +explain SELECT * FROM t1 LEFT JOIN ( +SELECT t3.* FROM t2 INNER JOIN t3 ON b = c +) AS sq ON a <= sq.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL a 5 NULL 2 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 test.t3.c 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t1`.`a` <= `test`.`t3`.`c`))) where true +SELECT * FROM t1 LEFT JOIN ( +SELECT t3.* FROM t2 INNER JOIN t3 ON b = c +) AS sq ON a <= sq.c; +a c +1 1 +1 5 +NULL NULL +DROP TABLE t1, t2, t3; +# Bug#22343301: Error 1093 (HY000): You can't specify target table'.' +# for update in FROM clause +CREATE TABLE users ( +id int unsigned AUTO_INCREMENT, +name varchar(255), +position int DEFAULT NULL, +PRIMARY KEY (id)); +INSERT INTO users (name, position) VALUES +('user1','1'), ('user2','2'), ('user3','3'), ('user4','4'), ('user5','5'); +# Single-table update with non-mergeable derived table +UPDATE users +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT DISTINCT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +# Single-table update with mergeable derived table +# (but not merged due to being used in a subquery of an UPDATE statement) +UPDATE users +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +# Multi-table update with non-mergeable derived table +UPDATE users, (SELECT 1) AS dummy +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT DISTINCT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +# Multi-table update with mergeable derived table +UPDATE users, (SELECT 1) AS dummy +SET position = (SELECT COUNT(pos) + 1 +FROM (SELECT position AS pos FROM users) AS t2 +WHERE t2.pos < users.position) +WHERE id = 3; +UPDATE users +SET position = (SELECT COUNT(t2.position) + 1 +FROM users AS t2 +WHERE t2.position < users.position) +WHERE id = 3; +ERROR HY000: You can't specify target table 'users' for update in FROM clause +UPDATE users, (SELECT 1) AS dummy +SET position = (SELECT COUNT(t2.position) + 1 +FROM users AS t2 +WHERE t2.position < users.position) +WHERE id = 3; +ERROR HY000: You can't specify target table 'users' for update in FROM clause +DROP TABLE users; +# Bug#22783011 assertion failed: base_select != removed_select && +# aggr_select != removed_select +CREATE TABLE t(a INTEGER) engine=innodb; +INSERT INTO t VALUES(1); +# Per MySQL rules, SUM(1) is aggregated in top query +# (can't be in WHERE, in FROM) +SELECT (SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(1)) AS t); +(SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(1)) AS t) +1 +SELECT (SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(0)) AS t); +(SELECT 1 FROM (SELECT 1 FROM t WHERE SUM(0)) AS t) +NULL +DROP TABLE t; +# Bug#23074801: Delete from joined tables with where using derived table +# fails with error 1093 +CREATE TABLE t1 (id INTEGER, d1 INTEGER); +CREATE TABLE t2 (id INTEGER, d2 INTEGER); +DELETE t1, t2 +FROM t1 LEFT JOIN t2 ON t1.id = t2.id +WHERE t1.id IN (SELECT * FROM (SELECT id FROM t1) AS t1sub); +DROP TABLE t1, t2; +# Bug#22967439: Mysql 5.7 vs 5.6 incorrect SELECT statement result +CREATE TABLE t1 +(integer1 INTEGER NULL, +integer2 INTEGER NULL, +varchar1 VARCHAR(255) NULL); +CREATE TABLE t2 +(integer1 INTEGER NULL, +integer2 INTEGER NULL, +varchar1 VARCHAR(255) NULL, +varchar2 VARCHAR(255) NULL); +INSERT INTO t1 VALUES +(11,12,'test1'), (21,22,'test2'), (31,32,'test3'); +INSERT INTO t2 VALUES +(11,12,'test1','test12'), (21,22,'test2','test22'), (31,32,'test3','test32'); +SELECT g_t3.g_f1, g_t3.g_f2, g_t3.g_f3 +FROM (SELECT g_t0.integer1 AS g_f1, +g_t0.integer2 AS g_f2, +g_t0.varchar1 AS g_f3 +FROM t1 g_t0 +) g_t3 +GROUP BY g_t3.g_f1, g_t3.g_f2, g_t3.g_f3 +HAVING g_t3.g_f3 = (select varchar1 +from t2 +where integer1 = g_t3.g_f1 +); +g_f1 g_f2 g_f3 +11 12 test1 +21 22 test2 +31 32 test3 +DROP TABLE t1, t2; +# Bug#24364448: Assert m_opr_handle != null in +# ha_innobase_inmem::keys_to_use_for_scanning +CREATE TABLE K (col_int int(11), col_varchar varchar(255)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO K VALUES (NULL,'m'), (NULL,'z'); +CREATE TABLE H (col_varchar varchar(255)) charset latin1; +INSERT INTO H VALUES ('m'), ('z'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +FLUSH STATUS; +SELECT t1.col_int +FROM (SELECT * FROM K) t1 JOIN (SELECT * FROM H) t2 USING(col_varchar) +WHERE t1.col_int IS NULL +ORDER BY t1.col_int; +col_int +NULL +NULL +SHOW STATUS LIKE 'Created_tmp%'; +Variable_name Value +Created_tmp_disk_tables 0 +Created_tmp_files 0 +Created_tmp_tables 2 +SET @@optimizer_switch=@optimizer_switch_saved; +DROP TABLE K, H; +# +# Bug #25343335: DERIVED TABLE SELECT LIST'S REFERENCE TO ALIAS CAUSES +# INCORRECT BEHAVIOR +# +CREATE TABLE t1 (c11 int); +INSERT INTO t1 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select 1 AS `alias1`,`alias1` AS `alias2` from dual +SELECT * +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +alias1 alias2 +1 1 +PREPARE xx FROM 'SELECT * +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X '; +EXECUTE xx; +alias1 alias2 +1 1 +EXECUTE xx; +alias1 alias2 +1 1 +EXECUTE xx; +alias1 alias2 +1 1 +EXPLAIN SELECT alias2 +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `alias1` AS `alias2` from dual +SELECT alias2 +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X ; +alias2 +1 +PREPARE yy FROM 'SELECT alias2 +FROM (SELECT (1) alias1, +(SELECT alias1) alias2 +FROM t1) X '; +EXECUTE yy; +alias2 +1 +EXECUTE yy; +alias2 +1 +EXECUTE yy; +alias2 +1 +DROP TABLE t1; +# +# Bug#26596977: ASSERT `!(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE))' +# FAILED IN ITEM_FUNC +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +col_int int(11) , +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar varchar(1) , +col_varchar_key varchar(1) , +PRIMARY KEY (pk) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (4,1,'s','r'), (9,19,'p','a'); +CREATE TABLE t3 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) , +col_varchar_key varchar(1) , +col_varchar varchar(1) , +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (100,2,'g',NULL); +EXPLAIN SELECT table1.col_int +FROM t3 AS table1 +LEFT JOIN ( +SELECT subquery1_t1.* +FROM t1 AS subquery1_t1 +RIGHT JOIN t2 AS subquery1_t2 +ON (subquery1_t2.col_varchar_key = subquery1_t1.col_varchar_key) +) AS table3 +ON (table3.col_varchar_key = table1.col_varchar_key) +WHERE table3.col_varchar_key IN ( +SELECT subquery2_t3.col_varchar +FROM t3 AS subquery2_t3 +WHERE subquery2_t3.pk < table3.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'table3.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `col_int` from `test`.`t2` `subquery1_t2` join `test`.`t1` `subquery1_t1` semi join (`test`.`t3` `subquery2_t3`) where ((`test`.`subquery2_t3`.`pk` < NULL) and multiple equal('g', NULL, `test`.`subquery2_t3`.`col_varchar`, `test`.`subquery1_t2`.`col_varchar_key`)) +SELECT table1.col_int +FROM t3 AS table1 +LEFT JOIN ( +SELECT subquery1_t1.* +FROM t1 AS subquery1_t1 +RIGHT JOIN t2 AS subquery1_t2 +ON (subquery1_t2.col_varchar_key = subquery1_t1.col_varchar_key) +) AS table3 +ON (table3.col_varchar_key = table1.col_varchar_key) +WHERE table3.col_varchar_key IN ( +SELECT subquery2_t3.col_varchar +FROM t3 AS subquery2_t3 +WHERE subquery2_t3.pk < table3.pk +); +col_int +DROP TABLE t1, t2, t3; +# +# Bug #26618455: ASSERT 'KEYPARTS > 0' IN CALC_LENGTH_AND_KEYPARTS() +# WITHOUT FIRSTMATCH +# +CREATE TABLE t1 ( +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,1,'i','n',125); +INSERT INTO t1 VALUES (3,20,'b','o',0); +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,'y','p',4,1); +CREATE TABLE t3 ( +col_int int(11) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( col_int int(11) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=MyISAM +; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (7,'k',9,'z',20); +SET optimizer_switch = 'firstmatch=off'; +EXPLAIN SELECT +table2.col_int_key AS field3 +FROM +( +SELECT subquery2_t2.* +FROM t1 AS subquery2_t1 +INNER JOIN t2 AS subquery2_t2 +ON (subquery2_t2.pk = subquery2_t1.col_int) +) AS table1 +RIGHT OUTER JOIN ( +SELECT subquery3_t1.* +FROM t2 AS subquery3_t1 +) AS table2 +ON (table1.col_varchar_key = table2.col_varchar_key) +WHERE table1.col_varchar_key IN ( +SELECT subquery4_t1.col_varchar AS subquery4_field1 +FROM t3 AS subquery4_t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery3_t1 NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE subquery2_t2 NULL system PRIMARY,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 7 const 1 100.00 Using where +1 SIMPLE subquery2_t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +4 MATERIALIZED subquery4_t1 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '3' AS `field3` from `test`.`t1` `subquery2_t1` semi join (`test`.`t3` `subquery4_t1`) where ((`test`.`subquery2_t1`.`col_int` = '1') and (``.`subquery4_field1` = 'y') and (`test`.`subquery4_t1`.`col_varchar` = 'y')) +SELECT +table2.col_int_key AS field3 +FROM +( +SELECT subquery2_t2.* +FROM t1 AS subquery2_t1 +INNER JOIN t2 AS subquery2_t2 +ON (subquery2_t2.pk = subquery2_t1.col_int) +) AS table1 +RIGHT OUTER JOIN ( +SELECT subquery3_t1.* +FROM t2 AS subquery3_t1 +) AS table2 +ON (table1.col_varchar_key = table2.col_varchar_key) +WHERE table1.col_varchar_key IN ( +SELECT subquery4_t1.col_varchar AS subquery4_field1 +FROM t3 AS subquery4_t1); +field3 +SET optimizer_switch = default; +DROP TABLE t1, t2, t3, t4; +# Bug#26798989: Sig 11 in find_table_in_global_list +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +UPDATE t1 +SET a=5 +WHERE a IN (SELECT a FROM t2 +ORDER BY (SELECT a FROM (SELECT SUM(a) FROM t1) AS dt)); +DROP TABLE t1, t2; +# +# Bug#30381092 WRONG BEHAVIOR OF '=' CONDITION WHEN WORKING WITH COMPLEX SUBQUERIES +# +CREATE TABLE t1 (t1_id INT PRIMARY KEY); +CREATE TABLE t2 (t2_id INT, t1_id INT); +INSERT INTO t1 VALUES (-1), (1); +INSERT INTO t2 SELECT t1_id, t1_id FROM t1; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ot NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY it2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index +4 DEPENDENT SUBQUERY it3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.ot.t2_id' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`t2_id` AS `t2_id`,`test`.`ot`.`t1_id` AS `t1_id` from `test`.`t2` `ot` where ((/* select#2 */ select `test`.`it2`.`t1_id` AS `it1` from `test`.`t1` `it2` where (`test`.`it2`.`t1_id` = (/* select#4 */ select `test`.`it3`.`t1_id` from `test`.`t2` `it3` where (`test`.`it3`.`t2_id` = `test`.`ot`.`t2_id`)))) is not null) +SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +t2_id t1_id +-1 -1 +1 1 +EXPLAIN SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT /*+ NO_MERGE() */ t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ot NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY it2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 DEPENDENT DERIVED it3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.ot.t2_id' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#4`) */ `test`.`ot`.`t2_id` AS `t2_id`,`test`.`ot`.`t1_id` AS `t1_id` from `test`.`t2` `ot` where ((/* select#2 */ select `test`.`it2`.`t1_id` AS `it1` from `test`.`t1` `it2` where (`test`.`it2`.`t1_id` = (/* select#4 */ select `dt1`.`t1_id` from (/* select#5 */ select `test`.`it3`.`t2_id` AS `t2_id`,`test`.`it3`.`t1_id` AS `t1_id` from `test`.`t2` `it3` where (`test`.`it3`.`t2_id` = `test`.`ot`.`t2_id`)) `dt1`))) is not null) +SELECT * FROM t2 AS ot +WHERE +( SELECT t1_id AS it1 +FROM ( SELECT * FROM t1 AS it2 +WHERE t1_id = ( SELECT /*+ NO_MERGE() */ t1_id +FROM ( SELECT * FROM t2 AS it3 +WHERE t2_id=ot.t2_id +) AS dt1 +) +) AS dt2 +) IS NOT NULL; +t2_id t1_id +-1 -1 +1 1 +DROP TABLE t1,t2; +# Bug#30488700: Mysql chooses different execution plan in 5.7 +CREATE TABLE tbl1 ( +id BIGINT NOT NULL, +rec_id INTEGER NOT NULL, +id_value2 BIGINT DEFAULT NULL, +PRIMARY KEY (id, rec_id) +) ENGINE=INNODB; +CREATE TABLE tbl2 ( +t_id BIGINT NOT NULL, +s_date DATETIME DEFAULT NULL, +PRIMARY KEY (t_id) +) ENGINE=INNODB; +SET @ROWNUM = 0; +SELECT t1.rec_id +FROM tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id,s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id; +rec_id +UPDATE tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id, b.s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id +SET t1.rec_id = @ROWNUM:= @ROWNUM+1; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +explain SELECT t1.rec_id +FROM tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id,s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 8 const 1 100.00 Using index +2 SIMPLE a NULL eq_ref PRIMARY PRIMARY 12 const,test.t1.rec_id 1 100.00 Using where +2 SIMPLE b NULL eq_ref PRIMARY PRIMARY 8 test.a.id_value2 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`rec_id` AS `rec_id` from `test`.`tbl1` `t1` join `test`.`tbl2` `b` join `test`.`tbl1` `a` where ((`test`.`b`.`t_id` = `test`.`a`.`id_value2`) and (`test`.`a`.`rec_id` = `test`.`t1`.`rec_id`) and (`test`.`t1`.`id` = 6889877970355107670) and (`test`.`a`.`id` = 6889877970355107670)) +explain UPDATE tbl1 AS t1 INNER JOIN +(SELECT a.id, a.rec_id, b.s_date +FROM tbl2 AS b, tbl1 AS a +WHERE a.id_value2 = b.t_id AND a.id = 6889877970355107670 +ORDER BY s_date DESC) t2 +ON t1.id = t2.id AND t1.rec_id = t2.rec_id +SET t1.rec_id = @ROWNUM:= @ROWNUM+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ref 12 test.t1.id,test.t1.rec_id 2 100.00 NULL +2 DERIVED a NULL ref PRIMARY PRIMARY 8 const 1 100.00 Using where; Using temporary; Using filesort +2 DERIVED b NULL eq_ref PRIMARY PRIMARY 8 test.a.id_value2 1 100.00 NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 update `test`.`tbl1` `t1` join (/* select#2 */ select `test`.`a`.`id` AS `id`,`test`.`a`.`rec_id` AS `rec_id`,`test`.`b`.`s_date` AS `s_date` from `test`.`tbl2` `b` join `test`.`tbl1` `a` where ((`test`.`a`.`id` = 6889877970355107670) and (`test`.`b`.`t_id` = `test`.`a`.`id_value2`)) order by `test`.`b`.`s_date` desc) `t2` set `test`.`t1`.`rec_id` = (@ROWNUM:=((@`ROWNUM`) + 1)) where ((`t2`.`rec_id` = `test`.`t1`.`rec_id`) and (`t2`.`id` = `test`.`t1`.`id`)) +DROP TABLE tbl1, tbl2; +# Bug#26542829: Assertion !(check_datetime_range(ltime)) failed +CREATE TABLE t1 ( +c1 varchar(10) DEFAULT NULL, +c2 datetime DEFAULT NULL, +c3 varchar(255) DEFAULT NULL, +c4 varchar(255) DEFAULT NULL, +pk int NOT NULL, +c5 varchar(255) DEFAULT NULL, +c6 date DEFAULT NULL, +c7 int DEFAULT NULL, +c8 date DEFAULT NULL, +c9 varchar(255) DEFAULT NULL, +c10 int DEFAULT NULL, +c11 varchar(10) DEFAULT NULL, +c12 varchar(10) DEFAULT NULL, +c13 datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY k5 (c5) +) engine=innodb; +INSERT INTO t1 VALUES +('gjnhugwevl','1000-01-01 00:00:00','m','UJVFB',2,'j','1000-01-01',208797696,'1000-01-01','LRNWI',NULL,'look','ISVAL','2001-03-02 00:00:00'), +('nhugwevltb','1000-01-01 00:00:00','m','h',3,'can\'t','2004-06-07',2052784128,'2000-12-19','r',NULL,'ugwevltbgy','something','1000-01-01 00:00:00'); +CREATE TABLE t2 ( +c1 varchar(255) DEFAULT NULL, +c2 varchar(10) DEFAULT NULL, +c3 int DEFAULT NULL, +c4 datetime DEFAULT NULL, +c5 varchar(10) DEFAULT NULL, +c6 varchar(255) DEFAULT NULL, +c7 varchar(255) DEFAULT NULL, +c8 varchar(255) DEFAULT NULL, +c9 varchar(10) DEFAULT NULL, +c10 datetime DEFAULT NULL, +pk int NOT NULL, +c11 date DEFAULT NULL, +c12 int DEFAULT NULL, +PRIMARY KEY (pk) +) engine=innodb; +INSERT INTO t2 VALUES +('be','njhqcbglns',NULL,'2002-07-20 19:40:02','YHBGN','go','NSPET','j','MKFNT','2007-08-25 14:41:26',1,'2002-04-21',6), +('b','glnspcqnog',2,'1000-01-01 00:00:00','YEJTV','on','z','PPPCH','YRXFT','1000-01-01 00:00:00',4,'2003-07-25',0), +('c','qnogpabsxs',6,'1000-01-01 00:00:00','nogpabsxsr','b','we','og','e','2000-11-01 15:48:07',7,'1000-01-01',3), +('OFZJT','was',6,'2007-01-14 21:01:33','as','was','r','a','but','2009-01-20 17:58:56',9,'2005-02-14',7), +('d','bsxsrumtna',9,'1000-01-01 00:00:00','would','he','o','VESLR','sxsrumtnab','2007-09-25 12:13:37',10,'2005-02-11',772472832); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT field1 +FROM (SELECT alias1.c5 AS field1, +alias1.c13 AS field2, +alias1.c1 AS field4 +FROM t1 AS alias1 RIGHT JOIN t2 AS alias2 +ON alias1.pk = alias2.c12 +ORDER BY field2 +) as dt; +field1 +NULL +NULL +NULL +NULL +can't +SELECT field1 +FROM (SELECT * +FROM (SELECT alias1.c5 AS field1, +alias1.c13 AS field2, +alias1.c1 AS field4 +FROM t1 AS alias1 RIGHT JOIN t2 AS alias2 +ON alias1.pk = alias2.c12 +ORDER BY field2 +) AS dt_inner +) AS dt_outer; +field1 +NULL +NULL +NULL +NULL +can't +DROP TABLE t1, t2; +# Bug#26808862: Execution of prepared statement with ORDER BY +# in derived table may fail +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER DEFAULT NULL, +c2 INTEGER DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 integer DEFAULT NULL +); +prepare s from " +SELECT field1 +FROM (SELECT alias1.c1 AS field1, + alias1.c2 AS field2 + FROM t1 AS alias1 RIGHT JOIN t2 AS alias2 + ON alias1.pk = alias2.c1 + ORDER BY field2) as dt"; +execute s; +field1 +execute s; +field1 +DROP TABLE t1, t2; +# Bug#31565009: Simplification of condition when seeing false and +# leaks tmp tables opened +CREATE TABLE t1 (i int); +SELECT t1.i +FROM t1 +WHERE FALSE AND +t1.i > (SELECT MAX(a) +FROM (SELECT 8 AS a UNION SELECT 3) AS tt); +i +DROP TABLE t1; +# Bug#31401637: Asan heap-buffer-overflow Handler::index_only_read_time +CREATE TABLE t( +w INTEGER NOT NULL, +h INTEGER NOT NULL, +u SMALLINT NOT NULL, +PRIMARY KEY (u) +); +INSERT INTO t VALUES(1,2,3),(3,4,5),(6,6,7); +PREPARE s FROM " +SELECT dtaa.c AS c +FROM (SELECT 1 AS c + FROM (SELECT 1 AS c + FROM t AS ta RIGHT JOIN t AS tb ON ta.u <= ? + WHERE 1 OR ? + GROUP BY ta.u + ) AS dta + INNER JOIN t AS tbb + ON dta.c = tbb.h + ) AS dtaa + RIGHT JOIN t AS tbbb + ON dtaa.c or w"; +SET @a:='77777'; +EXECUTE s USING @a,@a; +c +NULL +NULL +NULL +SET @a:='-77777'; +EXECUTE s USING @a,@a; +c +NULL +NULL +NULL +DEALLOCATE PREPARE s; +DROP TABLE t; +# +# Bug #32162862: ORDER BY SUB-SELECT COLUMN SETS ALL VALUES TO NULL +# +CREATE TABLE t1 ( a INTEGER ) Engine=InnoDB; +INSERT INTO t1 VALUES (123); +SELECT * FROM t1 LEFT JOIN ( SELECT 1 FROM t1 ) d1 ON TRUE ORDER BY a; +a 1 +123 1 +DROP TABLE t1; +# +# Bug #32164724: HYPERGRAPH: ASSERTION `PATH->COST >= PATH->INIT_COST' FAILED. +# +CREATE TABLE t1 (a INTEGER); +INSERT INTO t1 VALUES (1); +SET sql_mode=""; +SELECT ( +SELECT 1 FROM ( +SELECT avg(1) FROM t1 +WHERE dayofyear(1) AND max(1) +) d1 +GROUP BY a +) FROM t1; +( +SELECT 1 FROM ( +SELECT avg(1) FROM t1 +WHERE dayofyear(1) AND max(1) +) d1 +GROUP BY a +) +1 +Warnings: +Warning 1292 Incorrect datetime value: '1' +SET sql_mode=DEFAULT; +DROP TABLE t1; +# +# Bug #32169846: HYPERGRAPH: ASSERTION `M_OPENED_TABLE != NULLPTR' FAILED. +# +CREATE TABLE t1 (a LONGTEXT); +INSERT INTO t1 VALUES (''); +CREATE TABLE t2 (b INTEGER); +INSERT INTO t2 VALUES (0); +SELECT 1 FROM t2, ( +SELECT a, rand() FROM t1 GROUP BY a +) d1 +GROUP BY b; +1 +1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/derived_correlated.result-pq b/mysql-test/r/derived_correlated.result-pq new file mode 100644 index 000000000..fe04c1a0f --- /dev/null +++ b/mysql-test/r/derived_correlated.result-pq @@ -0,0 +1,3447 @@ +set optimizer_trace_max_mem_size=10000000,@@session.optimizer_trace="enabled=on"; +# WL#461: allow outer references in derived tables and CTEs +create table t1(a int, b int); +insert into t1 (a) values(1),(2); +create table t2 select * from t1; +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +set optimizer_switch='derived_merge=on'; +# Deep nesting: all intermediate subqueries are marked DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +5 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +6 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #6 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (0 <> (/* select#2 */ select count(0) from `test`.`t1` `t2` where (2 = (/* select#5 */ select 2 from (/* select#6 */ select `test`.`t1`.`a` AS `a`) `dt1`)))) +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# If reference is removed, not DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 NULL +6 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# Outer ref is in SELECT list of derived table's definition +explain select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t1`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `subq` from `test`.`t1` +select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +subq +1 +2 +# In WHERE +explain select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +subq +1 +2 +# In GROUP BY +explain select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` group by `test`.`t1`.`a`) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +subq +3 +3 +# In HAVING +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 1))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +subq +NULL +3 +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 2))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +subq +3 +NULL +# In ORDER BY +explain select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `b` from `test`.`t2` order by if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) limit 1) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +subq +1 +2 +# In window functions +explain select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `a`,sum(((`test`.`t1`.`a` * 10) + `test`.`t2`.`a`)) OVER (ORDER BY if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) ) AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = 1)) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +subq +11 +43 +# CTE referenced twice +explain select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t1`.`a` from `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) AS `subq` from `test`.`t1` +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +Recursive CTE +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select dt1.a from dt dt1 where dt1.a=t1.a +) as subq +from t1; +subq +1 +2 +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with recursive dt as +(select t1.a as a union all select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +# Two references to same CTE at different levels of nesting. +explain select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +explain format=tree select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Filter: (dt1.a = (select #4)) (cost=0.62..0.70 rows=2) + -> Index lookup on dt1 using (a=(select #4)) + -> Materialize CTE dt if needed (cost=0.55..0.55 rows=1) + -> Limit: 1 row(s) (cost=0.45 rows=1) + -> Table scan on t2 (cost=0.45 rows=2) + -> Select #4 (subquery in condition; dependent) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize CTE dt if needed (query plan printed elsewhere) (cost=3.06..3.06 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +explain select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 't1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` having (`test`.`t1`.`a` = `test`.`t2`.`a`) limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +# Scope of outer ref in CTE +select (select * from (select t1.a) cte) from t1; +(select * from (select t1.a) cte) +1 +2 +select (with cte as (select t1.a) select * from cte) from t1; +(with cte as (select t1.a) select * from cte) +1 +2 +with cte as (select t1.a) select (select * from cte) from t1; +ERROR 42S02: Unknown table 't1' in field list +# NOT IN(subquery using derived), handled with subquery materialization +explain select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select (`test`.`t2`.`a` + 1) from `test`.`t2` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = (`test`.`t2`.`a` + 1)) or ((`test`.`t2`.`a` + 1) is null)), true) having (outer_field_is_not_null, ((`test`.`t2`.`a` + 1)), true)) is false) +select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +a b +1 NULL +# Now put an outer reference inside derived table: +# subquery is properly seen as correlated and subquery +# materialization is thus not used. +explain select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select (((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1) from `test`.`t2` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = (((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1)) or ((((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1) is null)), true) having (outer_field_is_not_null, ((((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) + 1)), true)) is false) +select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +a b +1 NULL +# Verify that a non-lateral derived table with an outer +# reference makes the semijoin be correlated and thus blocks +# semijoin-materialization-scan. +create table t11 (a int); +insert into t11 +with recursive cte as (select 1 as a union all select a+1 from cte where a<124) +select * from cte; +alter table t11 add index(a); +create table t12 like t11; +analyze table t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +# No outer ref: mat-scan chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 PRIMARY t11 NULL ref a a 5 .a 1 100.00 Using index +2 MATERIALIZED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join ((/* select#3 */ select `test`.`t12`.`a` AS `a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = ``.`a`) +# outer ref: mat-scan not chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a+0*t11.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL index a a 5 NULL 124 100.00 Using where; Using index; Rematerialize () +1 PRIMARY NULL ref 9 test.t11.a 2 100.00 Using where; Using index; Start temporary; End temporary +3 DEPENDENT DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t11.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join (lateral (/* select#3 */ select (`test`.`t12`.`a` + (0 * `test`.`t11`.`a`)) AS `t12.a+0*t11.a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = `dt`.`t12.a+0*t11.a`) +DROP TABLE t11,t12; +LATERAL +# prevents join buffer if materialized (but not if merged) +explain select dt.a from t1, lateral (select t1.a from t2) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` +# no right join +explain select dt.a from t1 right join lateral (select t1.a from t2) dt on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# no bad left join either +explain select dt.a from lateral (select t1.a from t2) dt left join t1 on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# more complex case +explain SELECT * FROM t1 +LEFT JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +RIGHT JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +ERROR 42S22: Unknown column 'dt.a' in 'field list' +# LATERAL DT depending on LATERAL DT +explain SELECT * FROM t1 +JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'dt.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt1`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `dt`.`a` AS `a`) `dt1` where ((`dt`.`a` = `test`.`t1`.`a`) and (`dt1`.`a` = `test`.`t1`.`a`)) +# Placing lateral outer ref in SELECT list then HAVING +select t1.a, dt.a from t1, lateral (select t1.a+t2.a as a from t2) dt; +a a +1 2 +1 3 +2 3 +2 4 +select t1.a, dt.a from t1, lateral (select t2.a as a from t2 having t1.a) dt; +a a +1 1 +1 2 +2 1 +2 2 +# Inside view +create view v1 as +select t1.a as f1, dt.a as f2 +from t1, lateral (select t1.a+t2.a as a from t2) dt; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `f1`,`dt`.`a` AS `f2` from (`t1` join lateral (select (`t1`.`a` + `t2`.`a`) AS `a` from `t2`) `dt`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +f1 f2 +1 2 +1 3 +2 3 +2 4 +drop view v1; +# Coverage for various branches in Item_ref::fix_fields +SELECT COUNT(*) FROM t1 GROUP BY t1.a HAVING t1.a IN (SELECT t3.a +FROM t1 AS t3 WHERE t3.b IN (SELECT b FROM t2, lateral (select t1.a) dt)); +COUNT(*) +create view v1 as select a, b from t1; +select vq1.b,dt.b from v1 vq1, lateral (select vq1.b) dt; +b b +NULL NULL +NULL NULL +select b from v1 vq1, lateral (select count(*) from v1 vq2 having vq1.b = 3) dt; +b +drop view v1; +SELECT +/*+ SET_VAR(optimizer_switch = 'materialization=off,semijoin=off') */ +* FROM t1 AS ta, lateral (select 1 WHERE ta.a IN (SELECT b FROM t2 AS tb WHERE tb.b >= SOME(SELECT SUM(tc.a) as sg FROM t1 as tc GROUP BY tc.b HAVING ta.a=tc.b))) dt; +a b 1 +select (select dt.a from (select 1 as a, t2.a as b from t2 having +t1.a) dt where dt.b=t1.a) as subq from t1; +subq +1 +1 +select (select dt.a from (select 1 as a, 3 as b from t2 having t1.a) +dt where dt.b=t1.a) as subq from t1; +subq +NULL +NULL +# Aggregation in outer context +select (select f from (select max(t1.a) as f) as dt) as g from t1; +g +2 +select (select f from lateral (select max(t1.a) as f) as dt) as g from t1; +g +2 +# LATERAL doesn't allow an aggregate to resolve to the +# immediate parent (because reading of FROM tables happens +# before aggregation). So it resolves in the derived table, so +# the outer query doesn't produce a single-row result. +select t1.a, f from t1, lateral (select max(t1.a) as f) as dt; +a f +1 1 +2 2 +# We support CTE inside derived table +select * from t1, +lateral (with qn as (select t1.a) select (select max(a) from qn)) as dt; +a b (select max(a) from qn) +1 NULL 1 +2 NULL 2 +# Coverage for crash in Item_ident::fix_after_pullout: +# when we merge a derived table contained in a derived table, +# and the merged one contains an outer ref to the top query. +select (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) from t1; +(select * from (select * from (select t1.a from t2) as dt limit 1) dt2) +1 +2 +# Semijoin containing a correlated derived table, DT must +# become LATERAL +explain select a from t1 where a in (select a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (lateral (/* select#3 */ select `test`.`t1`.`a` AS `a`) `dt`) where (`dt`.`a` = `test`.`t1`.`a`) +select a from t1 where a in (select a from (select t1.a) dt); +a +1 +2 +create table t3 as with recursive cte as (select 1 as a union select a+1 from cte where a<20) select * from cte; +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 9 test.t3.a 2 100.00 Using index; FirstMatch(t3) +3 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#2`) */ min(`test`.`t3`.`a`) AS `min(a)`,max(`test`.`t3`.`a`) AS `max(a)` from `test`.`t3` semi join (lateral (/* select#3 */ select `test`.`t3`.`a` AS `a` from `test`.`t1`) `dt`) where (`dt`.`a` = `test`.`t3`.`a`) +select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +min(a) max(a) +1 20 +drop table t3; +# DT containing a correlated DT which must become LATERAL +explain format=tree select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +EXPLAIN +-> Nested loop inner join (cost=6.35 rows=2) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t1) (cost=3.06..3.06 rows=1) + -> Limit: 1 row(s) (cost=0.45 rows=1) + -> Table scan on t2 (cost=0.45 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +explain select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt2`.`a` AS `a` from `test`.`t1` join lateral (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` limit 1) `dt2` +select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +a b a +1 NULL 1 +2 NULL 2 +explain select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt2`.`a` AS `a` from `test`.`t1` `t0` join `test`.`t1` join lateral (/* select#4 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` limit 1) `dt2` +select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#1`) */ `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt4`.`a` AS `a` from `test`.`t1` `t0` join lateral (/* select#2 */ select `dt2`.`a` AS `a` from `test`.`t1` join (/* select#4 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` limit 1) `dt2`) `dt4` +select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'42' AS `42`,`dt2`.`a` AS `a` from `test`.`t1` join lateral (/* select#4 */ select `test`.`t1`.`a` AS `a`) `dt2` +select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +a b 42 a +1 NULL 42 1 +2 NULL 42 2 +without semijoin: index_subquery needs to re-materialize +explain select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in dt on ))) +select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +a +1 +2 +select a from t1 where a in (with cte as (select t1.a) +select /*+ no_semijoin() */ a from cte); +a +1 +2 +# Count rematerializations +# In all three plans, handler_write is 2, showing that we +# rematerialize only when necessary (when row of t1 changes) +explain select straight_join * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select straight_join * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +# Due to join buffer, order t2-t1 produces rows as a +# non-buffered t1-t2 plan: t1 buffers all rows of t2, then for +# each row of t1 it's joined to all rows of t2 and passed to t2; +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Let the planner find the best plan. +# It doesn't work so well, because of +# optimizer_prune_level=1 (see bug#28629788): order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt)); then it is the first +# explored plan so it's explored in full, and later t1-dt is rejected as +# more expensive than t1-t2. Whereas if t1-dt had been explored +# deeper, we'd see t1-dt-t2 is actually the cheapest, because +# it reads dt the least number of times (and dt has a high read +# cost because Temptable::scan_time() is incredibly high but +# that's another issue; see bug#28631100). +# t2 cannot use join buffering as between "dt" and its +# dependency t1: join buffering would interlace rows of t1 +# thus cause more rematerializations. +explain select * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one finds the best plan. Yes we simply swapped tables in the query, +# and it yields a different plan. This is because the order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt), then it is the first +# explored plan so it's explored in full and so is never pruned by +# prune_level=1, and it is the best plan. Best as: it reads +# "dt" less, and t2 uses join buffering (which is ok as it's +# after "dt"). +# If prune_level=0, all 3 variants here produce this plan. +explain select * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one is intermediate: t1 uses join buffer (good), but +# "dt" is last (bad, as it has high scan cost). +explain select * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Show the trace of planning of lateral derived tables +explain select * from t1, lateral (select t1.a from t2 as t3, t2 as t4) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` `t3` join `test`.`t2` `t4` join `test`.`t2` +select trace from information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` AS `a` from `t2` `t3` join `t2` `t4`" + } + ] + } + }, + { + "derived": { + "table": "`` `dt`", + "select#": 2, + "merged": true + } + }, + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`a` AS `a`,`t2`.`a` AS `a`,`t2`.`b` AS `b` from `t1` join (`t2` `t3` join `t2` `t4`) join `t2`" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "parenthesis_removal" + ], + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`a` AS `a`,`t2`.`a` AS `a`,`t2`.`b` AS `b` from `t1` join `t2` `t3` join `t2` `t4` join `t2`" + } + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2` `t3`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2` `t4`", + "row_may_be_null": false, + "map_bit": 2, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 3, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2` `t3`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2` `t4`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.650017, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.10002, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`" + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 1.05003, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.15005, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`", + "`t2` `t4`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 1.85007, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 16, + "cost_for_plan": 4.00012, + "chosen": true + } + ] + }, + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 1.05003, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.15005, + "pruned_by_heuristic": true + } + ] + }, + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.650017, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.10002, + "pruned_by_heuristic": true + }, + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.650017, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.10002, + "pruned_by_heuristic": true + } + ] + }, + { + "plan_prefix": [ + ], + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + }, + { + "plan_prefix": [ + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + }, + { + "plan_prefix": [ + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2` `t3`", + "attached": null + }, + { + "table": "`t2` `t4`", + "attached": null + }, + { + "table": "`t2`", + "attached": null + } + ] + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2` `t3`" + }, + { + "table": "`t2` `t4`" + }, + { + "table": "`t2`" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} +# LDT depending on const table only +create table t3(a int) engine=innodb; +insert into t3 values(3); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select * from t3, lateral (select t3.a+1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`dt`.`t3.a+1` AS `t3.a+1` from `test`.`t3` join lateral (/* select#2 */ select (`test`.`t3`.`a` + 1) AS `t3.a+1`) `dt` +select * from t3, lateral (select t3.a+1) as dt; +a t3.a+1 +3 4 +drop table t3; +# Two LDTs depending on different tables +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `test`.`t2`.`a` AS `a`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +a b a b a a +1 NULL 1 NULL 1 1 +1 NULL 2 NULL 2 1 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 2 +# Two LDTs depending on one same table +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (,); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +explain format=json select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "34.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt,dt2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.10", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.20", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + }, + { + "table": { + "table_name": "dt2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "20.30", + "eval_cost": "1.60", + "prefix_cost": "34.10", + "data_read_per_join": "256" + }, + "used_columns": [ + "t1.a+1" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 3, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +a b a b a t1.a+1 +1 NULL 1 NULL 1 2 +1 NULL 2 NULL 2 3 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 3 +# One LDT depending on two tables. The "rematerialize" tag is +# properly added to the 2nd dependency only. +explain select * from t2, t1, lateral (select t1.a+t2.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +explain format=json select * from t2, t1, lateral (select t1.a+t2.a) as dt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.45" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "1.35", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.45", + "data_read_per_join": "128" + }, + "used_columns": [ + "t1.a+t2.a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +select * from t2, t1, lateral (select t1.a+t2.a) as dt; +a b a b t1.a+t2.a +1 NULL 1 NULL 2 +1 NULL 2 NULL 3 +2 NULL 1 NULL 3 +2 NULL 2 NULL 4 +select json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") from information_schema.optimizer_trace; +json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") +[[{"table": "`t2`"}, {"table": "`t1`"}, {"table": " `dt`", "rematerialized_for_each_row_of": "t1"}]] +# Test when a dependency of LDT uses BKA: BKA code must +# refresh LDT's content when it provides a row. +set @old_opt_switch=@@optimizer_switch; +set @@optimizer_switch="batched_key_access=on,mrr_cost_based=off"; +CREATE TABLE t11 (t11a int, t11b int); +INSERT INTO t11 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t12 (t12a int, t12b int, KEY idx (t12b)); +INSERT INTO t12 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +explain SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY t12 NULL ref idx idx 5 test.t11.t11b 1 100.00 Rematerialize (); Using join buffer (Batched Key Access) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t12.t12a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t11`.`t11a` AS `t11a`,`test`.`t11`.`t11b` AS `t11b`,`test`.`t12`.`t12a` AS `t12a`,`test`.`t12`.`t12b` AS `t12b`,`dt`.`t12a` AS `t12a` from `test`.`t11` left join `test`.`t12` FORCE INDEX (`idx`) on((`test`.`t12`.`t12b` = `test`.`t11`.`t11b`)) join lateral (/* select#2 */ select `test`.`t12`.`t12a` AS `t12a`) `dt` where true +flush status; +SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +t11a t11b t12a t12b t12a +99 0 100 0 100 +99 0 999 0 999 +99 NULL NULL NULL NULL +99 3 NULL NULL NULL +show status like "handler_write"; +Variable_name Value +Handler_write 4 +DROP TABLE t11,t12; +set @@optimizer_switch=@old_opt_switch; +# Test that with an auto_key on the lateral DT, the index is +# properly emptied and re-filled when re-materializing. +# If index weren't emptied, we'd see too many "11" matches for 2nd +# row of t1; and if not re-filled, we'd see no matches for that. +create table t3 (a int, b int); +insert into t3 values(1, 10), (1, 11), (2, 10), (2, 11); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +# Note the auto_key with "Using index", to test the index as +# much as possible. +explain select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b` = (`test`.`t1`.`a` + 9))) +select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +a b b +1 NULL 10 +2 NULL 11 +drop table t3; +set optimizer_switch='derived_merge=off'; +# Deep nesting: all intermediate subqueries are marked DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +5 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +6 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #6 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (0 <> (/* select#2 */ select count(0) from (/* select#3 */ select `dt3`.`a` AS `a`,`dt3`.`b` AS `b` from (/* select#4 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t2` where (2 = (/* select#5 */ select 2 from (/* select#6 */ select `test`.`t1`.`a` AS `a`) `dt1`))) `dt3`) `dt4`)) +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select t1.a) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# If reference is removed, not DEPENDENT +explain select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 NULL +6 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +select * from t1 where +(select count(*) from (select * from (select * from t1 t2 +where 2=(select 2 from (select 42) dt1))dt3)dt4); +a b +1 NULL +2 NULL +# Outer ref is in SELECT list of derived table's definition +explain select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 test.t1.a 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`a` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t2`) `dt` where (`dt`.`b` = `test`.`t1`.`a`)) AS `subq` from `test`.`t1` +select +(select dt.a from +(select t1.a as a, t2.a as b from t2) dt where dt.b=t1.a) +as subq +from t1; +subq +1 +2 +# In WHERE +explain select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `b` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 where t1.a=t2.a) dt) +as subq +from t1; +subq +1 +2 +# In GROUP BY +explain select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` group by `test`.`t1`.`a`) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 group by t1.a) dt) +as subq +from t1; +subq +3 +3 +# In HAVING +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 1))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-1) dt) +as subq +from t1; +subq +NULL +3 +explain select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select sum(`test`.`t2`.`a`) AS `b` from `test`.`t2` having (`test`.`t1`.`a` = (sum(`test`.`t2`.`a`) - 2))) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select sum(t2.a) as b from t2 having t1.a=sum(t2.a)-2) dt) +as subq +from t1; +subq +3 +NULL +# In ORDER BY +explain select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `b` from `test`.`t2` order by if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) limit 1) `dt`) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a as b from t2 order by if(t1.a=1,t2.a,-t2.a) limit 1) dt) +as subq +from t1; +subq +1 +2 +# In window functions +explain select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select (/* select#2 */ select `dt`.`b` from (/* select#3 */ select `test`.`t2`.`a` AS `a`,sum(((`test`.`t1`.`a` * 10) + `test`.`t2`.`a`)) OVER (ORDER BY if((`test`.`t1`.`a` = 1),`test`.`t2`.`a`,-(`test`.`t2`.`a`)) ) AS `b` from `test`.`t2`) `dt` where (`dt`.`a` = 1)) AS `subq` from `test`.`t1` +select +(select dt.b from +(select t2.a, sum(t1.a*10+t2.a) over (order by if(t1.a=1,t2.a,-t2.a)) as b +from t2) dt where dt.a=1) +as subq +from t1; +subq +11 +43 +# CTE referenced twice +explain select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 test.t1.a 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 test.t1.a 2 100.00 Using where +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t2`) /* select#2 */ select `dt2`.`a` from `dt` `dt1` join `dt` `dt2` where ((`dt2`.`b` = `dt1`.`b`) and (`dt1`.`b` = `test`.`t1`.`a`))) AS `subq` from `test`.`t1` +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +Recursive CTE +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select dt1.a from dt dt1 where dt1.a=t1.a +) as subq +from t1; +subq +1 +2 +select +(with recursive dt as +(select t1.a as a union select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with recursive dt as +(select t1.a as a union all select a+1 from dt where a<10) +select concat(count(*), ' - ', avg(dt.a)) from dt +) as subq +from t1; +subq +10 - 5.5000 +9 - 6.0000 +select +(with dt as (select t1.a as a, t2.a as b from t2) +select dt2.a from dt dt1, dt dt2 where dt1.b=t1.a and dt2.b=dt1.b) +as subq +from t1; +subq +1 +2 +# Two references to same CTE at different levels of nesting. +explain select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +explain format=tree select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Filter: (dt1.a = (select #4)) (cost=0.62..0.70 rows=2) + -> Index lookup on dt1 using (a=(select #4)) + -> Materialize CTE dt if needed (cost=0.55..0.55 rows=1) + -> Limit: 1 row(s) (cost=0.45 rows=1) + -> Table scan on t2 (cost=0.45 rows=2) + -> Select #4 (subquery in condition; dependent) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize CTE dt if needed (query plan printed elsewhere) (cost=3.06..3.06 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #1 +select (with dt as (select t1.a as a from t2 limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +explain select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ref 5 func 2 100.00 Using where; Using index +4 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 't1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 't1.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (with `dt` as (/* select#3 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` having (`test`.`t1`.`a` = `test`.`t2`.`a`) limit 1) /* select#2 */ select `dt1`.`a` from `dt` `dt1` where (`dt1`.`a` = (/* select#4 */ select `dt2`.`a` from `dt` `dt2`))) AS `subq` from `test`.`t1` +select (with dt as (select t2.a as a from t2 having t1.a=t2.a limit 1) select * from dt dt1 where dt1.a=(select * from dt as dt2)) as subq from t1; +subq +1 +2 +# Scope of outer ref in CTE +select (select * from (select t1.a) cte) from t1; +(select * from (select t1.a) cte) +1 +2 +select (with cte as (select t1.a) select * from cte) from t1; +(with cte as (select t1.a) select * from cte) +1 +2 +with cte as (select t1.a) select (select * from cte) from t1; +ERROR 42S02: Unknown table 't1' in field list +# NOT IN(subquery using derived), handled with subquery materialization +explain select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select (`dt`.`f` + 1) from (/* select#3 */ select `test`.`t2`.`a` AS `f` from `test`.`t2`) `dt` where true having true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`dt.f+1`)))) is false) +select * from t1 +where a not in (select dt.f+1 from (select t2.a as f from t2) dt); +a b +1 NULL +# Now put an outer reference inside derived table: +# subquery is properly seen as correlated and subquery +# materialization is thus not used. +explain select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select (`dt`.`f` + 1) from (/* select#3 */ select ((0 * `test`.`t1`.`a`) + `test`.`t2`.`a`) AS `f` from `test`.`t2`) `dt` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = (`dt`.`f` + 1)) or ((`dt`.`f` + 1) is null)), true) having (outer_field_is_not_null, ((`dt`.`f` + 1)), true)) is false) +select * from t1 +where a not in (select dt.f+1 from (select 0*t1.a+t2.a as f from t2) dt); +a b +1 NULL +# Verify that a non-lateral derived table with an outer +# reference makes the semijoin be correlated and thus blocks +# semijoin-materialization-scan. +create table t11 (a int); +insert into t11 +with recursive cte as (select 1 as a union all select a+1 from cte where a<124) +select * from cte; +alter table t11 add index(a); +create table t12 like t11; +analyze table t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +# No outer ref: mat-scan chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 PRIMARY t11 NULL ref a a 5 .a 1 100.00 Using index +2 MATERIALIZED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join ((/* select#3 */ select `test`.`t12`.`a` AS `a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = ``.`a`) +# outer ref: mat-scan not chosen +explain select +/*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ +* from t11 where a in (select /*+ QB_NAME(subq1) NO_MERGE(dt) */ * +from (select t12.a+0*t11.a from t12) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL index a a 5 NULL 124 100.00 Using where; Using index; Rematerialize () +1 PRIMARY NULL ref 9 test.t11.a 2 100.00 Using where; Using index; Start temporary; End temporary +3 DEPENDENT DERIVED t12 NULL index NULL a 5 NULL 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t11.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_MERGE(`dt`@`subq1`) */ `test`.`t11`.`a` AS `a` from `test`.`t11` semi join (lateral (/* select#3 */ select (`test`.`t12`.`a` + (0 * `test`.`t11`.`a`)) AS `t12.a+0*t11.a` from `test`.`t12`) `dt`) where (`test`.`t11`.`a` = `dt`.`t12.a+0*t11.a`) +DROP TABLE t11,t12; +LATERAL +# prevents join buffer if materialized (but not if merged) +explain select dt.a from t1, lateral (select t1.a from t2) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t2`) `dt` +# no right join +explain select dt.a from t1 right join lateral (select t1.a from t2) dt on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# no bad left join either +explain select dt.a from lateral (select t1.a from t2) dt left join t1 on 1; +ERROR 42S22: Unknown column 't1.a' in 'field list' +# more complex case +explain SELECT * FROM t1 +LEFT JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +RIGHT JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +ERROR 42S22: Unknown column 'dt.a' in 'field list' +# LATERAL DT depending on LATERAL DT +explain SELECT * FROM t1 +JOIN +lateral (select t1.a) as dt ON t1.a=dt.a +JOIN +lateral (select dt.a) as dt1 ON dt.a=dt1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'dt.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt1`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `dt`.`a` AS `a`) `dt1` where ((`dt`.`a` = `test`.`t1`.`a`) and (`dt1`.`a` = `test`.`t1`.`a`)) +# Placing lateral outer ref in SELECT list then HAVING +select t1.a, dt.a from t1, lateral (select t1.a+t2.a as a from t2) dt; +a a +1 2 +1 3 +2 3 +2 4 +select t1.a, dt.a from t1, lateral (select t2.a as a from t2 having t1.a) dt; +a a +1 1 +1 2 +2 1 +2 2 +# Inside view +create view v1 as +select t1.a as f1, dt.a as f2 +from t1, lateral (select t1.a+t2.a as a from t2) dt; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `f1`,`dt`.`a` AS `f2` from (`t1` join lateral (select (`t1`.`a` + `t2`.`a`) AS `a` from `t2`) `dt`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +f1 f2 +1 2 +1 3 +2 3 +2 4 +drop view v1; +# Coverage for various branches in Item_ref::fix_fields +SELECT COUNT(*) FROM t1 GROUP BY t1.a HAVING t1.a IN (SELECT t3.a +FROM t1 AS t3 WHERE t3.b IN (SELECT b FROM t2, lateral (select t1.a) dt)); +COUNT(*) +create view v1 as select a, b from t1; +select vq1.b,dt.b from v1 vq1, lateral (select vq1.b) dt; +b b +NULL NULL +NULL NULL +select b from v1 vq1, lateral (select count(*) from v1 vq2 having vq1.b = 3) dt; +b +drop view v1; +SELECT +/*+ SET_VAR(optimizer_switch = 'materialization=off,semijoin=off') */ +* FROM t1 AS ta, lateral (select 1 WHERE ta.a IN (SELECT b FROM t2 AS tb WHERE tb.b >= SOME(SELECT SUM(tc.a) as sg FROM t1 as tc GROUP BY tc.b HAVING ta.a=tc.b))) dt; +a b 1 +select (select dt.a from (select 1 as a, t2.a as b from t2 having +t1.a) dt where dt.b=t1.a) as subq from t1; +subq +1 +1 +select (select dt.a from (select 1 as a, 3 as b from t2 having t1.a) +dt where dt.b=t1.a) as subq from t1; +subq +NULL +NULL +# Aggregation in outer context +select (select f from (select max(t1.a) as f) as dt) as g from t1; +g +2 +select (select f from lateral (select max(t1.a) as f) as dt) as g from t1; +g +2 +# LATERAL doesn't allow an aggregate to resolve to the +# immediate parent (because reading of FROM tables happens +# before aggregation). So it resolves in the derived table, so +# the outer query doesn't produce a single-row result. +select t1.a, f from t1, lateral (select max(t1.a) as f) as dt; +a f +1 1 +2 2 +# We support CTE inside derived table +select * from t1, +lateral (with qn as (select t1.a) select (select max(a) from qn)) as dt; +a b (select max(a) from qn) +1 NULL 1 +2 NULL 2 +# Coverage for crash in Item_ident::fix_after_pullout: +# when we merge a derived table contained in a derived table, +# and the merged one contains an outer ref to the top query. +select (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) from t1; +(select * from (select * from (select t1.a from t2) as dt limit 1) dt2) +1 +2 +# Semijoin containing a correlated derived table, DT must +# become LATERAL +explain select a from t1 where a in (select a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (lateral (/* select#3 */ select `test`.`t1`.`a` AS `a`) `dt`) where (`dt`.`a` = `test`.`t1`.`a`) +select a from t1 where a in (select a from (select t1.a) dt); +a +1 +2 +create table t3 as with recursive cte as (select 1 as a union select a+1 from cte where a<20) select * from cte; +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Rematerialize () +1 PRIMARY NULL ref 9 test.t3.a 2 100.00 Using index; FirstMatch(t3) +3 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#2`) */ min(`test`.`t3`.`a`) AS `min(a)`,max(`test`.`t3`.`a`) AS `max(a)` from `test`.`t3` semi join (lateral (/* select#3 */ select `test`.`t3`.`a` AS `a` from `test`.`t1`) `dt`) where (`dt`.`a` = `test`.`t3`.`a`) +select min(a),max(a) from t3 where a in (select /*+ no_merge() */ a from (select t3.a from t1) dt); +min(a) max(a) +1 20 +drop table t3; +# DT containing a correlated DT which must become LATERAL +explain format=tree select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +EXPLAIN +-> Nested loop inner join (cost=8.62 rows=2) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt3 (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t1) (cost=7.14..7.14 rows=1) + -> Table scan on dt2 (cost=2.51..2.51 rows=1) + -> Materialize (cost=4.53..4.53 rows=1) + -> Limit: 1 row(s) (cost=1.91..1.91 rows=1) + -> Table scan on dt (cost=1.26..2.52 rows=2) + -> Materialize (cost=1.91..3.17 rows=2) + -> Table scan on t2 (cost=0.45 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +explain select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt3`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select `dt2`.`a` AS `a` from (/* select#3 */ select `dt`.`a` AS `a` from (/* select#4 */ select `test`.`t1`.`a` AS `a` from `test`.`t2`) `dt` limit 1) `dt2`) `dt3` +select * from t1, lateral (select * from (select * from (select t1.a from t2) as dt limit 1) dt2) dt3; +a b a +1 NULL 1 +2 NULL 2 +explain select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt4`.`a` AS `a` from `test`.`t1` `t0` join lateral (/* select#2 */ select `dt3`.`a` AS `a` from `test`.`t1` join (/* select#3 */ select `dt2`.`a` AS `a` from (/* select#4 */ select `dt`.`a` AS `a` from (/* select#5 */ select `test`.`t0`.`a` AS `a` from `test`.`t2`) `dt` limit 1) `dt2`) `dt3`) `dt4` +select * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t0 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +5 DEPENDENT DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#1`) */ `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`dt4`.`a` AS `a` from `test`.`t1` `t0` join lateral (/* select#2 */ select `dt3`.`a` AS `a` from `test`.`t1` join (/* select#3 */ select `dt2`.`a` AS `a` from (/* select#4 */ select `dt`.`a` AS `a` from (/* select#5 */ select `test`.`t0`.`a` AS `a` from `test`.`t2`) `dt` limit 1) `dt2`) `dt3`) `dt4` +select /*+ no_merge() */ * from t1 as t0, +lateral +(select dt3.* from t1, lateral (select * from (select * from (select t0.a +from t2) as dt limit 1) dt2) dt3) dt4; +a b a +1 NULL 1 +1 NULL 1 +2 NULL 2 +2 NULL 2 +explain select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT DERIVED NULL ALL NULL NULL NULL NULL 2 100.00 NULL +4 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt3`.`42` AS `42`,`dt3`.`a` AS `a` from `test`.`t1` join lateral (/* select#2 */ select '42' AS `42`,`dt2`.`a` AS `a` from (/* select#4 */ select `test`.`t1`.`a` AS `a`) `dt2`) `dt3` +select * from t1, lateral (select * from (select 42) t1, (select t1.a) dt2) dt3; +a b 42 a +1 NULL 42 1 +2 NULL 42 2 +without semijoin: index_subquery needs to re-materialize +explain select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in dt on ))) +select a from t1 where a in (select /*+ no_semijoin() */ a from (select t1.a) dt); +a +1 +2 +select a from t1 where a in (with cte as (select t1.a) +select /*+ no_semijoin() */ a from cte); +a +1 +2 +# Count rematerializations +# In all three plans, handler_write is 2, showing that we +# rematerialize only when necessary (when row of t1 changes) +explain select straight_join * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select straight_join * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +explain select straight_join * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select straight_join * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +# Due to join buffer, order t2-t1 produces rows as a +# non-buffered t1-t2 plan: t1 buffers all rows of t2, then for +# each row of t1 it's joined to all rows of t2 and passed to t2; +# when a row of t1 produces two rows of t2 passed to "dt", +# it still makes one materialization. +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Let the planner find the best plan. +# It doesn't work so well, because of +# optimizer_prune_level=1 (see bug#28629788): order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt)); then it is the first +# explored plan so it's explored in full, and later t1-dt is rejected as +# more expensive than t1-t2. Whereas if t1-dt had been explored +# deeper, we'd see t1-dt-t2 is actually the cheapest, because +# it reads dt the least number of times (and dt has a high read +# cost because Temptable::scan_time() is incredibly high but +# that's another issue; see bug#28631100). +# t2 cannot use join buffering as between "dt" and its +# dependency t1: join buffering would interlace rows of t1 +# thus cause more rematerializations. +explain select * from t1, t2, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t1` join `test`.`t2` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t1, t2, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 1 +2 NULL 1 NULL 2 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one finds the best plan. Yes we simply swapped tables in the query, +# and it yields a different plan. This is because the order specified by +# the user is sorted by number of rows, which leaves it +# unchanged (Card(t1)=Card(t2)=Card(dt), then it is the first +# explored plan so it's explored in full and so is never pruned by +# prune_level=1, and it is the best plan. Best as: it reads +# "dt" less, and t2 uses join buffering (which is ok as it's +# after "dt"). +# If prune_level=0, all 3 variants here produce this plan. +explain select * from t1, lateral (select t1.a) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join `test`.`t2` +flush status; +select * from t1, lateral (select t1.a) as dt, t2; +a b a a b +1 NULL 1 1 NULL +1 NULL 1 2 NULL +2 NULL 2 1 NULL +2 NULL 2 2 NULL +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# This one is intermediate: t1 uses join buffer (good), but +# "dt" is last (bad, as it has high scan cost). +explain select * from t2, t1, lateral (select t1.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` +flush status; +select * from t2, t1, lateral (select t1.a) as dt; +a b a b a +1 NULL 1 NULL 1 +1 NULL 2 NULL 2 +2 NULL 1 NULL 1 +2 NULL 2 NULL 2 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +# Show the trace of planning of lateral derived tables +explain select * from t1, lateral (select t1.a from t2 as t3, t2 as t4) as dt, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT DERIVED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t2` `t3` join `test`.`t2` `t4`) `dt` join `test`.`t2` +select trace from information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` AS `a` from `t2` `t3` join `t2` `t4`" + } + ] + } + }, + { + "derived": { + "table": " `dt`", + "select#": 2, + "materialized": true + } + }, + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`dt`.`a` AS `a`,`t2`.`a` AS `a`,`t2`.`b` AS `b` from `t1` join lateral (/* select#2 */ select `t1`.`a` AS `a` from `t2` `t3` join `t2` `t4`) `dt` join `t2`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2` `t3`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + }, + { + "table": "`t2` `t4`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t2` `t3`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": "`t2` `t4`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`" + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.65, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.1, + "chosen": true + } + ] + }, + { + "plan_prefix": [ + ], + "table": "`t2` `t4`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t2` `t3`", + "attached": null + }, + { + "table": "`t2` `t4`", + "attached": null + } + ] + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t2` `t3`" + }, + { + "table": "`t2` `t4`" + } + ] + } + ] + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + }, + { + "table": " `dt`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + 0 + ] + }, + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 2, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + }, + { + "table": " `dt`", + "table_scan": { + "rows": 4, + "cost": 2.55 + } + }, + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`" + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.9, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.35, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2`" + ], + "table": " `dt`", + "best_access_path": { + "considered_access_paths": [ + { + "lateral_materialization": { + "cost_for_one_run_of_inner_query": 1.099, + "cost_for_writing_to_tmp_table": 0.4, + "count_of_runs": 2, + "total_cost": 2.998, + "cost_per_read": 0.7495 + } + }, + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 11.8, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 16, + "cost_for_plan": 13.8995, + "chosen": true + } + ] + }, + { + "plan_prefix": [ + "`t1`" + ], + "table": " `dt`", + "best_access_path": { + "considered_access_paths": [ + { + "lateral_materialization": { + "cost_for_one_run_of_inner_query": 1.099, + "cost_for_writing_to_tmp_table": 0.4, + "count_of_runs": 2, + "total_cost": 2.998, + "cost_per_read": 1.499 + } + }, + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 5.9, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 7.849, + "pruned_by_heuristic": true + } + ] + }, + { + "plan_prefix": [ + ], + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "pruned_by_heuristic": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2`", + "attached": null + }, + { + "table": " `dt`", + "attached": null + } + ] + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2`" + }, + { + "table": " `dt`", + "rematerialized_for_each_row_of": "t1" + } + ] + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + { + "join_explain": { + "select#": 2, + "steps": [ + ] + } + } + ] + } + } + ] +} +# LDT depending on const table only +create table t3(a int) engine=innodb; +insert into t3 values(3); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +explain select * from t3, lateral (select t3.a+1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`dt`.`t3.a+1` AS `t3.a+1` from `test`.`t3` join lateral (/* select#2 */ select (`test`.`t3`.`a` + 1) AS `t3.a+1`) `dt` +select * from t3, lateral (select t3.a+1) as dt; +a t3.a+1 +3 4 +drop table t3; +# Two LDTs depending on different tables +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`a` AS `a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select `test`.`t2`.`a` AS `a`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t2.a) as dt2; +a b a b a a +1 NULL 1 NULL 1 1 +1 NULL 2 NULL 2 1 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 2 +# Two LDTs depending on one same table +explain select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize (,); Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +explain format=json select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "34.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt,dt2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.10", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.20", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + }, + { + "table": { + "table_name": "dt2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "20.30", + "eval_cost": "1.60", + "prefix_cost": "34.10", + "data_read_per_join": "256" + }, + "used_columns": [ + "t1.a+1" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 3, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`a` AS `a`,`dt2`.`t1.a+1` AS `t1.a+1` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select `test`.`t1`.`a` AS `a`) `dt` join lateral (/* select#3 */ select (`test`.`t1`.`a` + 1) AS `t1.a+1`) `dt2` +select * from t2, t1, lateral (select t1.a) as dt, +lateral (select t1.a+1) as dt2; +a b a b a t1.a+1 +1 NULL 1 NULL 1 2 +1 NULL 2 NULL 2 3 +2 NULL 1 NULL 1 2 +2 NULL 2 NULL 2 3 +# One LDT depending on two tables. The "rematerialize" tag is +# properly added to the 2nd dependency only. +explain select * from t2, t1, lateral (select t1.a+t2.a) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +explain format=json select * from t2, t1, lateral (select t1.a+t2.a) as dt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.45" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "rematerialize": "dt", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "1.35", + "data_read_per_join": "64" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "dt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.30", + "eval_cost": "0.80", + "prefix_cost": "12.45", + "data_read_per_join": "128" + }, + "used_columns": [ + "t1.a+t2.a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": true, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`t1.a+t2.a` AS `t1.a+t2.a` from `test`.`t2` join `test`.`t1` join lateral (/* select#2 */ select (`test`.`t1`.`a` + `test`.`t2`.`a`) AS `t1.a+t2.a`) `dt` +select * from t2, t1, lateral (select t1.a+t2.a) as dt; +a b a b t1.a+t2.a +1 NULL 1 NULL 2 +1 NULL 2 NULL 3 +2 NULL 1 NULL 3 +2 NULL 2 NULL 4 +select json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") from information_schema.optimizer_trace; +json_extract(trace,"$.steps[*].join_optimization.steps[*].refine_plan") +[[{"table": "`t2`"}, {"table": "`t1`"}, {"table": " `dt`", "rematerialized_for_each_row_of": "t1"}]] +# Test when a dependency of LDT uses BKA: BKA code must +# refresh LDT's content when it provides a row. +set @old_opt_switch=@@optimizer_switch; +set @@optimizer_switch="batched_key_access=on,mrr_cost_based=off"; +CREATE TABLE t11 (t11a int, t11b int); +INSERT INTO t11 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t12 (t12a int, t12b int, KEY idx (t12b)); +INSERT INTO t12 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t11,t12; +Table Op Msg_type Msg_text +test.t11 analyze status OK +test.t12 analyze status OK +explain SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY t12 NULL ref idx idx 5 test.t11.t11b 1 100.00 Rematerialize (); Using join buffer (Batched Key Access) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t12.t12a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t11`.`t11a` AS `t11a`,`test`.`t11`.`t11b` AS `t11b`,`test`.`t12`.`t12a` AS `t12a`,`test`.`t12`.`t12b` AS `t12b`,`dt`.`t12a` AS `t12a` from `test`.`t11` left join `test`.`t12` FORCE INDEX (`idx`) on((`test`.`t12`.`t12b` = `test`.`t11`.`t11b`)) join lateral (/* select#2 */ select `test`.`t12`.`t12a` AS `t12a`) `dt` where true +flush status; +SELECT * FROM t11 LEFT JOIN t12 force index (idx) ON t12.t12b = t11.t11b +JOIN LATERAL (SELECT t12a) dt; +t11a t11b t12a t12b t12a +99 0 100 0 100 +99 0 999 0 999 +99 NULL NULL NULL NULL +99 3 NULL NULL NULL +show status like "handler_write"; +Variable_name Value +Handler_write 4 +DROP TABLE t11,t12; +set @@optimizer_switch=@old_opt_switch; +# Test that with an auto_key on the lateral DT, the index is +# properly emptied and re-filled when re-materializing. +# If index weren't emptied, we'd see too many "11" matches for 2nd +# row of t1; and if not re-filled, we'd see no matches for that. +create table t3 (a int, b int); +insert into t3 values(1, 10), (1, 11), (2, 10), (2, 11); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +# Note the auto_key with "Using index", to test the index as +# much as possible. +explain select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Rematerialize () +1 PRIMARY NULL ref 5 func 2 100.00 Using where; Using index +2 DEPENDENT DERIVED t3 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`dt`.`b` AS `b` from `test`.`t1` join lateral (/* select#2 */ select `test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a` = `test`.`t1`.`a`)) `dt` where (`dt`.`b` = (`test`.`t1`.`a` + 9)) +select * from t1, lateral (select t3.b from t3 where t3.a=t1.a) dt +where dt.b=t1.a+9; +a b b +1 NULL 10 +2 NULL 11 +drop table t3; +set optimizer_switch='derived_merge=off'; +# Reserved word +create table lateral(a int); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lateral(a int)' at line 1 +drop table t1,t2; +# +# Bug#28723670 RECENT REGRESSION: CRASH/ASSERTION IN FIND_FIELD_IN_TABLE_REF +# +CREATE TABLE t(x INT); +# Don't search for 'y' in top SELECT +SELECT 1 FROM +(SELECT 1 FROM (SELECT (SELECT y FROM t) FROM t) AS a) AS b; +ERROR 42S22: Unknown column 'y' in 'field list' +DROP TABLE t; +# +# Bug#28976533 ASSERTION `JOIN->BEST_READ < DOUBLE(1.79769313486231570814527423731704357E+308L) +# +CREATE TABLE bb ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER , +col_int_key INTEGER , +col_time_key TIME , +col_time TIME , +col_datetime_key DATETIME , +col_datetime DATETIME , +col_varchar_key VARCHAR(20) , +col_varchar VARCHAR(20) , +PRIMARY KEY (pk DESC), +KEY (col_time_key), +KEY (col_time_key DESC) +); +SET SQL_MODE=''; +EXPLAIN SELECT +grandparent1.col_varchar_key AS g1 FROM bb AS grandparent1 +LEFT JOIN bb AS grandparent2 USING ( col_time ) +WHERE grandparent1.col_int_key IN +( +WITH qn AS ( +SELECT parent1.col_int AS p1 +FROM bb AS parent1 LEFT JOIN bb AS parent2 USING ( col_varchar ) +WHERE parent1.col_varchar_key IN +( +WITH qn1 AS ( +SELECT DISTINCT child1.col_varchar_key AS C1 +FROM bb AS child1 LEFT JOIN bb AS child2 +ON child1.col_varchar_key <= child2.col_varchar +WHERE child1.col_time > grandparent1.col_datetime +) +SELECT * FROM qn1 +) +AND parent1.col_time_key BETWEEN '2008-03-18' AND +'2004-11-14' + ) +SELECT /*+ MERGE(qn) */ * FROM qn +) +GROUP BY grandparent1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +5 DEPENDENT DERIVED child1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using temporary +5 DEPENDENT DERIVED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Distinct; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.grandparent1.col_datetime' of SELECT #5 was resolved in SELECT #1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Note 1003 /* select#1 */ select /*+ MERGE(`qn`@`select#2`) */ `test`.`grandparent1`.`col_varchar_key` AS `g1` from `test`.`bb` `grandparent1` left join `test`.`bb` `grandparent2` on(multiple equal(`test`.`grandparent1`.`col_time`, `test`.`grandparent2`.`col_time`)) semi join (`test`.`bb` `parent1` left join `test`.`bb` `parent2` on((`test`.`parent1`.`col_varchar` = `test`.`parent2`.`col_varchar`)) join `qn1`) where ((`test`.`parent1`.`col_time_key` between '2008-03-18' and '2004-11-14') and multiple equal(`test`.`grandparent1`.`col_int_key`, `test`.`parent1`.`col_int`) and multiple equal(`test`.`parent1`.`col_varchar_key`, `qn1`.`C1`)) group by `test`.`grandparent1`.`col_int` +SELECT +grandparent1.col_varchar_key AS g1 FROM bb AS grandparent1 +LEFT JOIN bb AS grandparent2 USING ( col_time ) +WHERE grandparent1.col_int_key IN +( +WITH qn AS ( +SELECT parent1.col_int AS p1 +FROM bb AS parent1 LEFT JOIN bb AS parent2 USING ( col_varchar ) +WHERE parent1.col_varchar_key IN +( +WITH qn1 AS ( +SELECT DISTINCT child1.col_varchar_key AS C1 +FROM bb AS child1 LEFT JOIN bb AS child2 +ON child1.col_varchar_key <= child2.col_varchar +WHERE child1.col_time > grandparent1.col_datetime +) +SELECT * FROM qn1 +) +AND parent1.col_time_key BETWEEN '2008-03-18' AND +'2004-11-14' + ) +SELECT /*+ MERGE(qn) */ * FROM qn +) +GROUP BY grandparent1.col_int; +g1 +Warnings: +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2008-03-18' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +Warning 1292 Incorrect time value: '2004-11-14' for column 'col_time_key' at row 1 +DROP TABLE bb; +SET SQL_MODE=DEFAULT; +# +# Bug #29268512: ASSERTION FAILED: INITED == NONE INTERMITTENTLY +# +CREATE TABLE t1 ( +f1 integer +); +INSERT INTO t1 VALUES (0),(1); +CREATE TABLE t2 ( +f2 integer +); +SELECT * FROM t1, LATERAL ( SELECT MAX(1) FROM t2 GROUP BY t1.f1 ) AS l1; +f1 MAX(1) +DROP TABLE t1, t2; +# +# Bug #29334082: Still crashing in actual_key_parts() / assert inited == INDEX +# +CREATE TABLE t1 ( f1 INTEGER ); +CREATE TABLE t2 ( f2 LONGBLOB ); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES ('abc'),('def'); +SELECT STD(0) FROM t2, LATERAL ( SELECT f1 FROM t1 GROUP BY f2,f1 ) AS d1; +STD(0) +0 +DROP TABLE t1, t2; +# +# Bug#28954838 ASSERTION `(REMAINING_TABLES_AFTER != 0) || ((CUR_EMBEDDING_MAP == 0) && (JOIN-> +# +CREATE TABLE t1 ( +pk INTEGER, +col_int INT not null, +col_int_key INT not null, +col_time_gckey TIME, +col_varchar VARCHAR(20) not null, +col_varchar_key VARCHAR(15) not null +); +CREATE TABLE t2 ( +pk INTEGER, +col_int INT not null, +col_varchar VARCHAR(20) not null, +col_varchar_key VARCHAR(15) not null +); +SET OPTIMIZER_SWITCH='derived_merge=off'; +SELECT table1.col_varchar_key AS field1, +table2.col_time_gckey AS field2 +FROM t2 AS table1 STRAIGHT_JOIN t1 AS table2 +ON table2.col_varchar_key = table1.col_varchar_key +WHERE table2.col_int_key IN +(WITH qn AS +(SELECT sq1_t1.col_int AS sq1_field1 +FROM t2 AS sq1_t1 +WHERE sq1_t1.col_varchar_key = table2.col_varchar OR +EXISTS (WITH qn1 AS +(SELECT c_sq1_t1.col_int_key AS c_sq1_field1 +FROM t1 AS c_sq1_t1 +WHERE c_sq1_t1.col_varchar_key > sq1_t1.col_varchar OR +c_sq1_t1.col_int <> c_sq1_t1.pk +) +SELECT * FROM qn1 +) +) +SELECT * FROM qn +) AND +EXISTS (WITH qn AS +(SELECT sq2_t1.col_varchar AS sq2_field1 +FROM t1 AS sq2_t1 STRAIGHT_JOIN +t2 AS sq2_t2 INNER JOIN t1 AS sq2_t3 +ON sq2_t3.col_varchar = sq2_t2.col_varchar_key +ON sq2_t3.col_int = sq2_t2.pk +) +SELECT * FROM qn +) AND +table2.col_varchar_key <> 'j'; +field1 field2 +SET OPTIMIZER_SWITCH=DEFAULT; +DROP TABLE t1,t2; +# +# Bug#28955358 VIRTUAL LONGLONG FIELD_NEWDATE::VAL_DATE_TEMPORAL(): ASSERTION `!TABLE || (!TAB +# +CREATE TABLE t1 ( +pk INTEGER, col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, col_datetime DATETIME NOT NULL +); +INSERT INTO t1 VALUES (0, 0, '2006-07-18', '2001-09-06 02:13:59.021506'); +SELECT /*+ no_merge() */ outr.pk AS x +FROM ( SELECT * FROM t1 ) AS outr +WHERE outr.col_int_key IN +( SELECT /*+ no_merge() no_semijoin() */ 2 +FROM (SELECT 1 AS x FROM t1 AS innr WHERE outr.col_date_key ) AS +qn ) +ORDER BY outr.col_datetime; +x +SELECT /*+ no_merge() */ outr.pk AS x +FROM ( SELECT * FROM t1 ) AS outr +WHERE outr.col_int_key IN +( SELECT /*+ no_merge() no_semijoin() */ id +FROM JSON_TABLE( IF(outr.col_date_key<>NOW(), +'[{"a":"3"},{"a":2},{"b":1},{"a":0}]', +'') , +'$[*]' columns (id for ordinality, +jpath varchar(100) path '$.a', +jexst int exists path '$.b') ) AS +qn ) +ORDER BY outr.col_datetime; +x +DROP TABLE t1; +CREATE TABLE t1(pk INT PRIMARY KEY, a INT); +EXPLAIN SELECT pk FROM t1 GROUP BY a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.pk' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT (SELECT pk FROM (SELECT t1.pk) dt) FROM t1 GROUP BY a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.pk' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +# +# Bug#28960857 ASSERTION FAILED: !TR->DERIVED_WHERE_COND || TR->DERIVED_WHERE_COND->FIXED +# Bug#28960789 ASSERTION FAILED: TRANSL->ITEM->FIXED, +# +CREATE TABLE t0007 ( +c0008 date NOT NULL, +c0009 char(234) NOT NULL +); +CREATE TABLE t0008 ( +c0005 tinytext NOT NULL +); +CREATE TABLE t0009 ( +c0000 time NOT NULL +); +SET SQL_MODE=0; +SELECT (SELECT t0007.c0009 FROM (SELECT t0007.c0008 AS c0003 +FROM t0009 ) AS t0005 ) FROM t0007 +GROUP BY -23; +(SELECT t0007.c0009 FROM (SELECT t0007.c0008 AS c0003 +FROM t0009 ) AS t0005 ) +SELECT (SELECT c0009 +FROM (SELECT 1 AS c0003 +FROM t0009 INNER JOIN t0008 +ON t0008.c0005 +WHERE t0007.c0008 +) AS t0005 +GROUP BY c0008 +), +COUNT(c0009) +FROM t0007 +GROUP BY 1, 1; +(SELECT c0009 +FROM (SELECT 1 AS c0003 +FROM t0009 INNER JOIN t0008 +ON t0008.c0005 +WHERE t0007.c0008 +) AS t0005 +GROUP BY c0008 +) COUNT(c0009) +DROP TABLE t0007, t0008, t0009; +SET SQL_MODE=DEFAULT; +# +# Bug #29514504: WRONG RESULT WITH CORRELATED LATERAL JOIN +# +CREATE TABLE t1 (id INTEGER); +CREATE TABLE t2 (id INTEGER); +INSERT INTO t1 VALUES (10), (20), (30); +INSERT INTO t2 VALUES (20), (20); +SELECT * FROM t1 JOIN LATERAL ( +SELECT GROUP_CONCAT(t.id) AS c FROM t2 t WHERE (t.id = t1.id) +) d0 ON (1); +id c +10 NULL +20 20,20 +30 NULL +DROP TABLE t1, t2; +# +# Bug #30110851: SUBQUERY INVOLVES COUNT() AGGREGATE FUNCTION PERFORMANCE REGRESSION +# +CREATE TABLE t1 ( f1 INTEGER NOT NULL, f2 INTEGER NOT NULL ); +CREATE TABLE t2 ( f1 INTEGER NOT NULL, f2 INTEGER NOT NULL ); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT ( SELECT f2 FROM v1 WHERE v1.f1 = t2.f1 ) AS f3 FROM t2; +EXPLAIN FORMAT=TREE SELECT * FROM v2 WHERE f3 = 3; +EXPLAIN +-> Index lookup on v2 using (f3=3) + -> Materialize (cost=0.45..0.45 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Select #3 (subquery in projection; dependent) + -> Index lookup on v1 using (f1=t2.f1) + -> Materialize (cost=0.45..0.45 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t2.f1' of SELECT #3 was resolved in SELECT #2 +DROP TABLE t1, t2; +DROP VIEW v1, v2; +# +# Bug#30627575 ASSERT: `INITED == NONE' IN HANDLER::HA_INDEX_INIT() AT SQL/HANDLER.CC +# +CREATE TABLE t1( +a INT, +b INT NOT NULL, +c INT NOT NULL, +d INT, +UNIQUE KEY (c,b) +); +INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); +CREATE TABLE t2( +a INT, +b INT, +UNIQUE KEY(a,b) +); +INSERT INTO t2 VALUES (NULL, NULL), (NULL, NULL), (NULL, 1), (1, NULL), (1, 1), (1,2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 JOIN LATERAL (SELECT a+t1.a from t2 GROUP BY a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Rematerialize () +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT DERIVED t2 NULL range a a 5 NULL 3 100.00 Using index for group-by +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`dt`.`a+t1.a` AS `a+t1.a` from `test`.`t1` join lateral (/* select#2 */ select (`test`.`t2`.`a` + `test`.`t1`.`a`) AS `a+t1.a` from `test`.`t2` group by `test`.`t2`.`a`) `dt` +SELECT * FROM t1 JOIN LATERAL (SELECT a+t1.a from t2 GROUP BY a) AS dt; +a b c d a+t1.a +1 1 1 50 NULL +1 1 1 50 2 +2 1 3 4 NULL +2 1 3 4 3 +1 2 3 40 NULL +1 2 3 40 2 +DROP TABLE t1, t2; +# +# Bug#30887665 ASSERT: `SELECT_LEX->IS_RECURSIVE()' IN JOIN::MAKE_JOIN_PLAN() +# +CREATE TABLE t1 (c1 VARCHAR(1)); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT 1 FROM +v1 AS table1 RIGHT OUTER JOIN LATERAL +(SELECT 1 FROM v1 AS table2 RIGHT OUTER JOIN LATERAL +( SELECT 1 FROM v1 AS table3 ) AS table4 +ON table1.c1 = 1) AS table5 +ON 1; +ERROR 42S22: Unknown column 'table1.c1' in 'on clause' +DROP VIEW v1; +DROP TABLE t1; +# +# Bug #32113029: WRONG RESULT PRODUCED WHEN LEFT JOINING INFORMATION_SCHEMA TABLES +# +CREATE TABLE t1 ( id INTEGER ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( table_id integer ); +INSERT INTO t2 VALUES (363); +CREATE TABLE t3 ( id integer ); +INSERT INTO t3 VALUES (362); +INSERT INTO t3 VALUES (363); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +set optimizer_switch='derived_merge=off'; +SELECT * +FROM t1 +LEFT JOIN ( +t3, LATERAL ( +SELECT * FROM t2 WHERE table_id = t3.id +) l1 +) ON TRUE; +id id table_id +1 363 363 +SELECT * +FROM t1 +LEFT JOIN ( +t3, LATERAL ( +SELECT * FROM t2 WHERE table_id = t3.id +) l1 +) ON TRUE and t3.id=363; +id id table_id +1 363 363 +set optimizer_switch=DEFAULT; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/r/desc_index_innodb.result-pq b/mysql-test/r/desc_index_innodb.result-pq new file mode 100644 index 000000000..cce5553cf --- /dev/null +++ b/mysql-test/r/desc_index_innodb.result-pq @@ -0,0 +1,1718 @@ +create table t1(f1 int, key f1_idx(f1 desc)) engine=heap; +ERROR 42000: The storage engine for the table doesn't support descending indexes +create table +t1(a int, b int, key a_desc_b_asc (a desc, b), key a_asc_b_desc (a, b desc)) +engine= innodb; +flush tables; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int DEFAULT NULL, + KEY `a_desc_b_asc` (`a` DESC,`b`), + KEY `a_asc_b_desc` (`a`,`b` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values(1,6),(1,5),(2,5),(2,4),(3,4),(3,3), +(4,3),(4,2),(5,2),(5,1),(6,1),(NULL,NULL); +analyze table t1; +# Should use index +explain select * from t1 order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc +select * from t1 order by a desc; +a b +6 1 +5 1 +5 2 +4 2 +4 3 +3 3 +3 4 +2 4 +2 5 +1 5 +1 6 +NULL NULL +explain select * from t1 order by a desc, b asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` +select * from t1 order by a desc, b asc; +a b +6 1 +5 1 +5 2 +4 2 +4 3 +3 3 +3 4 +2 4 +2 5 +1 5 +1 6 +NULL NULL +explain select * from t1 order by a asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +explain select * from t1 order by a asc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +explain select * from t1 group by a,b order by a, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` desc order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +select * from t1 group by a,b order by a, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +# For GROUP BY optimizer can pick any order for column, +explain select * from t1 group by a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` +explain select * from t1 group by a, b order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` order by `test`.`t1`.`a` +explain select * from t1 group by a , b order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a` desc,`test`.`t1`.`b` order by `test`.`t1`.`a` desc +explain select * from t1 group by a, b order by a desc, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_desc_b_asc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a` desc,`test`.`t1`.`b` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` +explain select * from t1 group by a, b order by a asc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc,a_asc_b_desc a_asc_b_desc 10 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` desc order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +alter table t1 drop index a_asc_b_desc; +explain select * from t1 group by a, b order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a_desc_b_asc a_desc_b_asc 10 NULL # # Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` order by `test`.`t1`.`a` +explain select distinct a from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a_desc_b_asc a_desc_b_asc 5 NULL # # Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` +select distinct a from t1; +a +1 +2 +3 +4 +5 +6 +NULL +explain select a from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a_desc_b_asc a_desc_b_asc 5 NULL # # Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +select a from t1 group by a; +a +1 +2 +3 +4 +5 +6 +NULL +# Should use index backward +explain select * from t1 order by a asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +explain select * from t1 order by a asc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` desc +select * from t1 order by a asc, b desc; +a b +NULL NULL +1 6 +1 5 +2 5 +2 4 +3 4 +3 3 +4 3 +4 2 +5 2 +5 1 +6 1 +# Should use filesort +explain select * from t1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 order by a desc, b desc; +a b +6 1 +5 2 +5 1 +4 3 +4 2 +3 4 +3 3 +2 5 +2 4 +1 6 +1 5 +NULL NULL +explain select * from t1 order by a asc, b asc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a_desc_b_asc 10 NULL # # Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` +select * from t1 order by a asc, b asc; +a b +NULL NULL +1 5 +1 6 +2 4 +2 5 +3 3 +3 4 +4 2 +4 3 +5 1 +5 2 +6 1 +create index i1 on t1 (a desc, a asc); +ERROR 42S21: Duplicate column name 'a' +create index i1 on t1 (a desc, b desc); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int DEFAULT NULL, + KEY `a_desc_b_asc` (`a` DESC,`b`), + KEY `i1` (`a` DESC,`b` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 (a int auto_increment, primary key (a desc)) engine= innodb; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`a` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert ignore into t2 select a from t1; +Warnings: +Warning 1062 Duplicate entry '5' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '4' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '2' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '1' for key 't2.PRIMARY' +select * from t2; +a +7 +6 +5 +4 +3 +2 +1 +create table t3 (a varchar(10), key i1(a(5) desc)) engine= innodb; +flush tables; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` varchar(10) DEFAULT NULL, + KEY `i1` (`a`(5) DESC) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create index i2 on t3(a(6)); +flush tables; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` varchar(10) DEFAULT NULL, + KEY `i1` (`a`(5) DESC), + KEY `i2` (`a`(6)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t3 add fulltext index fts_idx(a desc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +alter table t3 add fulltext index fts_idx(a asc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +alter table t3 add column b point not null, add spatial index gis_idx(b desc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +alter table t3 add column b point not null, add spatial index gis_idx(b asc); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a text, fulltext key fts(a desc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a point not null, spatial key gis(a desc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a text, fulltext key fts(a asc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t4 (a point not null, spatial key gis(a asc)); +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t5 (f1 int, key h(f1 asc) using hash) engine= heap; +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t5 (f1 int, key h(f1 desc) using hash) engine= heap; +ERROR HY000: Incorrect usage of spatial/fulltext/hash index and explicit index order +create table t5 (f1 int, key h(f1) using hash) engine= heap; +drop table t1,t2,t3,t5; +CREATE TABLE t0 (i INTEGER); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 (i1 INTEGER NOT NULL, i2 INTEGER NOT NULL, +i3 INTEGER NOT NULL, KEY k1 (i1 desc, i2) +) ENGINE= innodb; +INSERT INTO t1 +SELECT a.i*10 + b.i + 1, a.i*100 + b.i*10 + c.i, a.i +FROM t0 AS a, t0 AS b, t0 AS c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 30 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 50 and 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +EXPLAIN SELECT * FROM t1 +WHERE (i1 BETWEEN 50 AND 52 OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 60 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where (((`test`.`t1`.`i1` between 50 and 52) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE (i1 BETWEEN 50 AND 52 OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +i1 i2 i3 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +71 701 7 +71 703 7 +71 705 7 +71 707 7 +71 709 7 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +EXPLAIN SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495) OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 31 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL 31 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i2` = 495) and (`test`.`t1`.`i1` = 50)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495) OR i1 BETWEEN 70 AND 72) AND MOD(i2,2)=1 +ORDER BY i1 DESC; +i1 i2 i3 +50 495 4 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +71 701 7 +71 703 7 +71 705 7 +71 707 7 +71 709 7 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +EXPLAIN SELECT * FROM t1 WHERE i1 >= 50 AND i1 < 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` >= 50) and (`test`.`t1`.`i1` < 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 WHERE i1 >= 50 AND i1 < 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +EXPLAIN SELECT * FROM t1 WHERE i1 > 50 AND i1 <= 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` > 50) and (`test`.`t1`.`i1` <= 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 WHERE i1 > 50 AND i1 <= 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 4 NULL 30 100.00 Using index condition; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 50 and 52) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND MOD(i2,2)=1 ORDER BY i1 DESC; +i1 i2 i3 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +51 501 5 +51 503 5 +51 505 5 +51 507 5 +51 509 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND i2 BETWEEN 495 AND 515 ORDER BY i1, i2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL 30 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 50 and 52) and (`test`.`t1`.`i2` between 495 and 515)) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 50 AND 52 AND i2 BETWEEN 495 AND 515 ORDER BY i1, i2 DESC; +i1 i2 i3 +50 499 4 +50 498 4 +50 497 4 +50 496 4 +50 495 4 +51 509 5 +51 508 5 +51 507 5 +51 506 5 +51 505 5 +51 504 5 +51 503 5 +51 502 5 +51 501 5 +51 500 5 +52 515 5 +52 514 5 +52 513 5 +52 512 5 +52 511 5 +52 510 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 150 1.23 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 150 1.23 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +i1 i2 i3 +48 479 4 +48 477 4 +48 475 4 +48 473 4 +48 471 4 +50 499 4 +50 497 4 +50 495 4 +50 493 4 +50 491 4 +52 519 5 +52 517 5 +52 515 5 +52 513 5 +52 511 5 +54 539 5 +54 537 5 +54 535 5 +54 533 5 +54 531 5 +56 559 5 +56 557 5 +56 555 5 +56 553 5 +56 551 5 +58 579 5 +58 577 5 +58 575 5 +58 573 5 +58 571 5 +60 599 5 +60 597 5 +60 595 5 +60 593 5 +60 591 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC, i3 DESC); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 150 1.23 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 150 1.23 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` desc +SELECT * FROM t1 +WHERE i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1, i2 DESC; +i1 i2 i3 +48 479 4 +48 477 4 +48 475 4 +48 473 4 +48 471 4 +50 499 4 +50 497 4 +50 495 4 +50 493 4 +50 491 4 +52 519 5 +52 517 5 +52 515 5 +52 513 5 +52 511 5 +54 539 5 +54 537 5 +54 535 5 +54 533 5 +54 531 5 +56 559 5 +56 557 5 +56 555 5 +56 553 5 +56 551 5 +58 579 5 +58 577 5 +58 575 5 +58 573 5 +58 571 5 +60 599 5 +60 597 5 +60 595 5 +60 593 5 +60 591 5 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1, i2 DESC, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 180 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 180 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc,`test`.`t1`.`i2` +SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +i1 i2 i3 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +60 591 5 +60 593 5 +60 595 5 +60 597 5 +60 599 5 +58 571 5 +58 573 5 +58 575 5 +58 577 5 +58 579 5 +56 551 5 +56 553 5 +56 555 5 +56 557 5 +56 559 5 +54 531 5 +54 533 5 +54 535 5 +54 537 5 +54 539 5 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +48 471 4 +48 473 4 +48 475 4 +48 477 4 +48 479 4 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1 DESC, i2, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 180 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 180 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc,`test`.`t1`.`i2` +SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5) or i1 between 70 and 72) AND +MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +i1 i2 i3 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +60 591 5 +60 593 5 +60 595 5 +60 597 5 +60 599 5 +58 571 5 +58 573 5 +58 575 5 +58 577 5 +58 579 5 +56 551 5 +56 553 5 +56 555 5 +56 557 5 +56 559 5 +54 531 5 +54 533 5 +54 535 5 +54 537 5 +54 539 5 +52 511 5 +52 513 5 +52 515 5 +52 517 5 +52 519 5 +50 491 4 +50 493 4 +50 495 4 +50 497 4 +50 499 4 +48 471 4 +48 473 4 +48 475 4 +48 477 4 +48 479 4 +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1 DESC, i2, i3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495 and i3=4) OR i1 BETWEEN 70 AND 72) AND +MOD(i2,2)=1 +ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 31 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 12 NULL 31 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((((`test`.`t1`.`i3` = 4) and (`test`.`t1`.`i2` = 495) and (`test`.`t1`.`i1` = 50)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc +SELECT * FROM t1 +WHERE ( (i1=50 AND i2=495 and i3=4) OR i1 BETWEEN 70 AND 72) AND +MOD(i2,2)=1 +ORDER BY i1 DESC; +i1 i2 i3 +72 711 7 +72 713 7 +72 715 7 +72 717 7 +72 719 7 +71 701 7 +71 703 7 +71 705 7 +71 707 7 +71 709 7 +70 691 6 +70 693 6 +70 695 6 +70 697 6 +70 699 6 +50 495 4 +ALTER TABLE t1 ADD COLUMN (i4 INTEGER NOT NULL); +UPDATE t1 SET i4=i3; +ALTER TABLE t1 DROP INDEX k1, ADD INDEX k1(i1 DESC, i2, i3 DESC, i4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND i4 BETWEEN 5 AND 6) OR +i1 between 70 and 72) AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 180 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 16 NULL 180 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`i3` AS `i3`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where ((((`test`.`t1`.`i1` between 48 and 62) and (`test`.`t1`.`i2` between 395 and 615) and (`test`.`t1`.`i3` between 4 and 5) and (`test`.`t1`.`i4` between 5 and 6)) or (`test`.`t1`.`i1` between 70 and 72)) and ((`test`.`t1`.`i1` % 2) = 0) and ((`test`.`t1`.`i2` % 2) = 1)) order by `test`.`t1`.`i1` desc,`test`.`t1`.`i2` +SELECT * FROM t1 WHERE +((i1 BETWEEN 48 AND 62 AND i2 BETWEEN 395 AND 615 AND +i3 BETWEEN 4 AND 5 AND i4 BETWEEN 5 AND 6) OR +i1 between 70 and 72) AND MOD(i1,2)=0 AND MOD(i2,2)=1 +ORDER BY i1 desc, i2 ; +i1 i2 i3 i4 +72 711 7 7 +72 713 7 7 +72 715 7 7 +72 717 7 7 +72 719 7 7 +70 691 6 6 +70 693 6 6 +70 695 6 6 +70 697 6 6 +70 699 6 6 +60 591 5 5 +60 593 5 5 +60 595 5 5 +60 597 5 5 +60 599 5 5 +58 571 5 5 +58 573 5 5 +58 575 5 5 +58 577 5 5 +58 579 5 5 +56 551 5 5 +56 553 5 5 +56 555 5 5 +56 557 5 5 +56 559 5 5 +54 531 5 5 +54 533 5 5 +54 535 5 5 +54 537 5 5 +54 539 5 5 +52 511 5 5 +52 513 5 5 +52 515 5 5 +52 517 5 5 +52 519 5 5 +DROP TABLE t0, t1; +CREATE TABLE t1 (a INT, b INT, KEY i1 (a DESC, b DESC)); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3); +INSERT INTO t1 SELECT a + 1, b FROM t1; +INSERT INTO t1 SELECT a + 2, b FROM t1; +INSERT INTO t1 SELECT a + 4, b FROM t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i1 i1 10 NULL 9 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) +8 1 3 +7 1 3 +6 1 3 +5 1 3 +4 1 3 +3 1 3 +2 1 3 +1 1 3 +DROP TABLE t1; +create table t1 (a int not null, b int, c varchar(10), +key (a desc, b desc, c desc)); +insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b'); +insert into t1 values (0, NULL, NULL), (0, NULL, 'b'), (0, 0, NULL), (0, 0, 'b'), (0, 0, 'b'), (0, 0, 'a'), (0, 0, 'b'), (0, 0, 'a'), (0, 0, 'b'), (0, 0, 'c'),(0,0,'b'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 9 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +flush status; +select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 NULL +1 1 b +1 1 b +1 3 b +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 10 +drop table t1; +create table t1 (a1 int, a2 char(3), key k1(a1 desc)); +insert into t1 values(10,'aaa'), (10,null), (10,'bbb'), (20,'zzz'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Shouldn't optimize tables away on DESC index +explain select min(a1) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 5 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` +select min(a1) from t1; +min(a1) +10 +drop table t1; +CREATE TABLE t1 +(a VARCHAR(10), +b VARCHAR(10), +KEY ab_asc (a ASC, b ASC), +KEY a_asc_b_desc (a ASC, b DESC), +key a_desc_b_asc (a DESC, b ASC)) +ENGINE = InnoDB +PARTITION BY KEY (a, b) PARTITIONS 3; +INSERT INTO t1 VALUES ("0", "0"), ("1", "1"), ("2", "2"), ("3", "3"), +("4", "4"), ("55", "55"), ("54", "54"), ("1", "2"), ("1", "4"), ("1", "3"), +("55", "54"), ("0", "1"), (NULL,NULL),(0, NULL), (1,NULL); +SELECT * FROM t1 ORDER BY a, b DESC; +a b +NULL NULL +0 1 +0 0 +0 NULL +1 4 +1 3 +1 2 +1 1 +1 NULL +2 2 +3 3 +4 4 +54 54 +55 55 +55 54 +DROP TABLE t1; +# +# Bug#23036049: WL1074:ASSERTION `CTX->CUR <= CTX->LAST' FAILED. +# +CREATE TABLE c ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER NOT NULL, +col_varchar VARCHAR(5) NOT NULL, +unique KEY (pk,col_int DESC) +) ENGINE= innodb; +INSERT IGNORE INTO c (col_int,col_varchar) VALUES +(7, 'm'),(0, 'alukq'),(8, 'lu'),(6, 'uk'), (5, 'kquk'),(9, 'qukko'),(0, 'u'), +(181, 'kkoei'),(3, 'ko'),(86, 'oei'); +CREATE TABLE cc ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER NOT NULL, +col_varchar VARCHAR(5) NOT NULL, +unique KEY (pk,col_int DESC) +) ENGINE= innodb; +INSERT IGNORE INTO cc (col_int,col_varchar) VALUES +(9, 'gktbk'),(0, 'k'),(4, 'tbkj'),(8, 'bk'),(9, 'kjrk'),(2,'j'),(7, 'r'), +(4, 'kmqmk'),(0, 'm'),(4, 'qmkn'); +SELECT DISTINCT t2.col_int +FROM ( c AS t1 INNER JOIN cc AS t2 ON (t2.col_varchar = t1.col_varchar)) +WHERE ( t1.col_int IN ( 167, 9)) +AND t1.pk = 122; +col_int +DROP TABLE c,cc; +# +CREATE TABLE b ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER /*! NULL */, +col_varchar_key VARCHAR(10) /*! NULL */, +PRIMARY KEY (pk DESC), +KEY (col_varchar_key DESC, col_int_key DESC) +) ENGINE= innodb; +INSERT /*! IGNORE */ INTO b (col_int_key,col_varchar_key) VALUES +(3, 'ceksatef'),(3, 'eks'),(3, 'ksatefqs'),(6, 'sate'),(3, 'a'); +CREATE TABLE cc ( +pk INTEGER , +col_int_key INTEGER /*! NULL */, +col_varchar_key VARCHAR(10) /*! NULL */ +) ENGINE= innodb; +INSERT /*! IGNORE */ INTO cc (col_int_key, col_varchar_key) VALUES +(NULL, 'koeiwsgpmf'),(8, 'oeiwsgpm'),(8, 'eiwsg'),(0,'iwsg'),(5, 'wsgpmfy'), +(1, 'sgpmfyvvu'),(7, 'gpmfyvvu'),(7, 'pmfyvvu'),(147, 'mfyv'),(2, NULL); +# Shouldn't crash +SELECT +DISTINCT OUTR . col_varchar_key +FROM b AS OUTR WHERE ( OUTR . col_int_key , OUTR . pk ) IN +( +SELECT DISTINCT +INNR . pk AS x , +INNR . pk AS y +FROM cc AS INNR WHERE OUTR . col_varchar_key = 'v' +) +AND OUTR . pk >= 3 ; +col_varchar_key +DROP TABLE b; +CREATE TABLE b ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER /*! NULL */, +col_varchar_key VARCHAR(10) /*! NULL */, +PRIMARY KEY (pk DESC), +KEY (col_varchar_key, col_int_key) +) ENGINE= innodb; +INSERT /*! IGNORE */ INTO b (col_int_key,col_varchar_key) +VALUES (3, 'ceksatef'),(3, 'eks'),(3, 'ksatefqs'),(6, 'sate'),(3, 'a'); +# Shouldn't crash +SELECT +DISTINCT OUTR . col_varchar_key +FROM b AS OUTR WHERE ( OUTR . col_int_key , OUTR . pk ) IN +( +SELECT DISTINCT +INNR . pk AS x , +INNR . pk AS y +FROM cc AS INNR WHERE OUTR . col_varchar_key = 'v' +) +AND OUTR . pk >= 3 ; +col_varchar_key +DROP TABLE b,cc; +# +# +# Bug#23212656:JOIN QUERY WITH RANGE PREDICATES GIVES INCORRECT RESULTS +# +CREATE TABLE ee ( +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk DESC), +KEY 1col_int_key (col_int_key DESC) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ee VALUES +(NULL,NULL,1), (NULL,NULL,2), (NULL,286720000,3), (NULL,1,4), +(2084831232,8,5), (NULL,0,6), (4,763953152,7), (5,NULL,8), (7,9,9); +SELECT DISTINCT alias1 . col_int_key AS field1 , alias1 . col_int AS field2 +FROM ee AS alias1 JOIN ee AS alias2 ON alias1 . pk = alias2 . col_int_key +WHERE ( alias1 . pk BETWEEN 8 AND ( 8 + 4 ) AND alias2 . pk <> 2 ); +field1 field2 +9 7 +NULL 5 +DROP TABLE ee; +# +# +# Bug#23217803:QUERY USING INDEX_MERGE_SORT_UNION GIVES INCORRECT +# RESULTS WITH DESC KEY +# +CREATE TABLE t ( +pk INTEGER AUTO_INCREMENT, +col_int INTEGER , +col_int_key INTEGER , +col_varchar_key VARCHAR(10) , +col_varchar VARCHAR(10) , +PRIMARY KEY (pk DESC), +KEY (col_varchar_key DESC), +UNIQUE KEY (col_int_key DESC, pk) +) ENGINE=innodb; +INSERT INTO t (col_int_key, col_int, col_varchar_key) +VALUES (1, 2, NULL),(NULL, 3, 'dks'), (7, 0, 'ksjijcsz'),(172, 84, 'sj'); +SELECT col_int FROM t AS table1 WHERE table1 .pk > 166 OR table1 +.col_varchar_key = 'c' OR table1 .col_int_key > 166 LIMIT 1; +col_int +84 +DROP TABLE t; +# +# +# BUG#22973383:INNODB ASSERTION IN ROW_SEL_CONVERT_MYSQL_KEY_TO_INNOBASE +# +CREATE TABLE c ( +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +unique key k5 (col_varchar_10_utf8_key(7) DESC) +) ENGINE=innodb; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE e ( +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +unique key k5 (col_varchar_10_utf8_key(7) DESC, +col_varchar_10_latin1_key(5) DESC, col_varchar_255_utf8_key(50) DESC) +) ENGINE=innodb; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +EXPLAIN SELECT table2 . col_varchar_10_utf8_key AS field1 +FROM e AS table1 LEFT JOIN c AS table2 +ON table1 . col_varchar_10_utf8_key = table2 . col_varchar_10_utf8_key +WHERE table1 . col_varchar_255_utf8_key != 'LPGIV' +AND table1 . col_varchar_10_latin1_key >= 'w' +AND table1 . col_varchar_10_utf8_key < 'zzzz'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL range k5 k5 24 NULL 1 100.00 Using where +2 SIMPLE table2 NULL eq_ref k5 k5 24 test.table1.col_varchar_10_utf8_key 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`col_varchar_10_utf8_key` AS `field1` from `test`.`e` `table1` left join `test`.`c` `table2` on((`test`.`table2`.`col_varchar_10_utf8_key` = `test`.`table1`.`col_varchar_10_utf8_key`)) where ((`test`.`table1`.`col_varchar_255_utf8_key` <> 'LPGIV') and (`test`.`table1`.`col_varchar_10_latin1_key` >= 'w') and (`test`.`table1`.`col_varchar_10_utf8_key` < 'zzzz')) +SELECT table2 . col_varchar_10_utf8_key AS field1 +FROM e AS table1 LEFT JOIN c AS table2 +ON table1 . col_varchar_10_utf8_key = table2 . col_varchar_10_utf8_key +WHERE table1 . col_varchar_255_utf8_key != 'LPGIV' +AND table1 . col_varchar_10_latin1_key >= 'w' +AND table1 . col_varchar_10_utf8_key < 'zzzz'; +field1 +DROP TABLE c,e; +CREATE TABLE t1 ( +i int(11) NOT NULL, +j int(11) DEFAULT NULL, +k int(11) DEFAULT NULL, +l int(11) DEFAULT NULL, +PRIMARY KEY (i), +KEY j (j,k DESC,l), +KEY i (i,j,k,l) +)ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(11,1,6,3),(4,1,2,3),(8,1,2,3),(10,1,2,3),(1,1,1,1),(2,1,1,1),(3,1,1,1), +(5,3,2,3),(6,4,2,3),(7,6,2,3),(12,7,6,3),(13,7,6,8),(14,7,6,9),(16,8,7,9), +(15,8,6,9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE i < 10 AND j >=1 AND k >=2 AND l <=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,j,i PRIMARY 4 NULL 8 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j`,`test`.`t1`.`k` AS `k`,`test`.`t1`.`l` AS `l` from `test`.`t1` where ((`test`.`t1`.`i` < 10) and (`test`.`t1`.`j` >= 1) and (`test`.`t1`.`k` >= 2) and (`test`.`t1`.`l` <= 5)) +SELECT * FROM t1 WHERE i < 10 AND j >=1 AND k >=2 AND l <=5; +i j k l +4 1 2 3 +5 3 2 3 +6 4 2 3 +7 6 2 3 +8 1 2 3 +DROP TABLE t1; +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +col_int_key INTEGER , +col_varchar_key BLOB NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key, col_varchar_key(25) DESC) +); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_int INTEGER , +col_int_key INTEGER , +col_varchar_key BLOB , +PRIMARY KEY (pk), +KEY (col_int_key, col_varchar_key(25) DESC) +); +EXPLAIN SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key >= 'y') ) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 100.00 NULL +1 SIMPLE alias1 NULL const PRIMARY,col_int_key PRIMARY 4 const 1 100.00 Using where +1 SIMPLE alias2 NULL ref col_int_key col_int_key 5 test.alias1.pk 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` semi join (`test`.`t1` `alias1` left join `test`.`t2` `alias2` on((`test`.`alias1`.`pk` = `test`.`alias2`.`col_int_key`))) where ((`test`.`t1`.`col_int_key` = `test`.`t2`.`col_int`) and (`test`.`alias1`.`pk` = 5) and (`test`.`alias1`.`col_int_key` = 1) and (`test`.`alias1`.`col_varchar_key` >= 'y')) +SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key >= 'y') ) ); +col_varchar_key +EXPLAIN SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key <= 'y') ) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 100.00 NULL +1 SIMPLE alias1 NULL const PRIMARY,col_int_key PRIMARY 4 const 1 100.00 Using where +1 SIMPLE alias2 NULL ref col_int_key col_int_key 5 test.alias1.pk 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` semi join (`test`.`t1` `alias1` left join `test`.`t2` `alias2` on((`test`.`alias1`.`pk` = `test`.`alias2`.`col_int_key`))) where ((`test`.`t1`.`col_int_key` = `test`.`t2`.`col_int`) and (`test`.`alias1`.`pk` = 5) and (`test`.`alias1`.`col_int_key` = 1) and (`test`.`alias1`.`col_varchar_key` <= 'y')) +SELECT t1.col_varchar_key +FROM ( t2 INNER JOIN t1 +ON (t1.col_int_key = t2.col_int AND (1,5) IN +( SELECT alias1.col_int_key, alias1. pk +FROM ( t2 AS alias2 RIGHT JOIN t1 AS alias1 +ON (alias1.pk = alias2.col_int_key ) +) WHERE alias1.col_varchar_key <= 'y') ) ); +col_varchar_key +DROP TABLE t1,t2; +#End of test case for Bug#22973383 +# +# Bug #23576305:WL1074:STRAIGHT_JOIN QUERY WITH RANGE +# CHECKED (MYISAM) GIVES WRONG RESULTS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL , +col_varchar_key varchar(10) DEFAULT NULL, +UNIQUE KEY pk_2 (pk,col_varchar_key DESC) +); +INSERT INTO t1 VALUES (3,'ksatefqs'), +(4,'sate'),(5,'a'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_int_key INTEGER DEFAULT NULL, +col_varchar_key varchar(10) DEFAULT NULL +); +INSERT INTO t2 VALUES +(10,80,'ukqukkoe'), +(11,2,'kqukkoe'), +(12,5,'qukkoeiws'), +(13,9,'ukko'), +(14,3,'kkoeiwsgp'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key +FROM t2 JOIN t1 ON ( t1.pk >= t2.col_int_key +AND t1.col_varchar_key != t2.col_varchar_key ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index pk_2 pk_2 47 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`pk` >= `test`.`t2`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` <> `test`.`t2`.`col_varchar_key`)) +SELECT t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key +FROM t2 JOIN t1 ON ( t1.pk >= t2.col_int_key +AND t1.col_varchar_key != t2.col_varchar_key ); +pk col_int_key col_varchar_key col_varchar_key +3 2 ksatefqs kqukkoe +3 3 ksatefqs kkoeiwsgp +4 2 sate kqukkoe +4 3 sate kkoeiwsgp +5 2 a kqukkoe +5 3 a kkoeiwsgp +5 5 a qukkoeiws +EXPLAIN SELECT STRAIGHT_JOIN t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key FROM +t2 JOIN t1 ON ( t1.pk >= t2.col_int_key AND +t1.col_varchar_key != t2.col_varchar_key ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t1 NULL ALL pk_2 NULL NULL NULL # # Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`pk` >= `test`.`t2`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` <> `test`.`t2`.`col_varchar_key`)) +SELECT STRAIGHT_JOIN t1.pk, t2.col_int_key, +t1.col_varchar_key, t2.col_varchar_key FROM +t2 JOIN t1 ON ( t1.pk >= t2.col_int_key AND +t1.col_varchar_key != t2.col_varchar_key ); +pk col_int_key col_varchar_key col_varchar_key +3 2 ksatefqs kqukkoe +3 3 ksatefqs kkoeiwsgp +4 2 sate kqukkoe +4 3 sate kkoeiwsgp +5 2 a kqukkoe +5 3 a kkoeiwsgp +5 5 a qukkoeiws +DROP TABLE t1,t2; +#End of test for Bug#23576305 +# +# Bug#23730559: ASSERTION `TAB->QUICK() == SAVE_QUICK || +# TAB->QUICK() == __NULL' FAILED. +# +# +CREATE TABLE b ( +col_int INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_varchar_key VARCHAR(20) NOT NULL, +col_varchar VARCHAR(20) NOT NULL, +KEY (col_varchar_key DESC), +KEY (col_varchar_key(5) DESC), +KEY (col_varchar_key, col_int_key) +) ENGINE=InnoDB; +INSERT INTO b ( col_int_key, col_int, col_varchar_key, col_varchar) VALUES +(1, 3, 'xceksatefqsdksjijc', 'xceksatefqsdksjijc'), +(7, 6, 'ce', 'ce'), +(2, 3, 'eksatefqsdksjij', 'eksatefqsdksjij'), +(5, 7, 'satefqsd', 'satefqsd'); +CREATE TABLE bb ( +col_int INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_varchar_key VARCHAR(20) NOT NULL, +col_varchar VARCHAR(20) NOT NULL, +KEY (col_varchar_key(10) DESC, col_int_key DESC) +) ENGINE=InnoDB; +INSERT INTO bb ( col_int_key, col_int, col_varchar_key, col_varchar) VALUES +(181, 88, 'kkoeiwsgpmfyvvuqvtjn', 'kkoeiwsgpmfyvvuqvtjn'), +(3, 4, 'koeiwsgpmfyv', 'koeiwsgpmfyv'), +(86, 113, 'oeiwsgpm', 'oeiwsgpm'), +(6, 1, 'eiwsgpmfyvvuqvtjncds', 'eiwsgpmfyvvuqvtjncds'), +(8, 5, 'iwsgpmfyvvuqv', 'iwsgpmfyvvuqv'); +ANALYZE TABLE b,bb; +Table Op Msg_type Msg_text +test.b analyze status OK +test.bb analyze status OK +EXPLAIN SELECT gp1 . col_varchar AS g1 +FROM b AS gp1 LEFT JOIN bb AS gp2 USING ( col_varchar_key ) +WHERE gp1 . col_int IN ( +SELECT p1 . col_int AS p1 +FROM bb AS p1 LEFT JOIN bb AS p2 +ON ( p1 . col_int >= p2 . col_int_key ) +WHERE ( p1 . col_int , gp1 . col_int ) IN ( +SELECT c1 . col_int AS C1 +, c1 . col_int AS C2 +FROM b AS c1 LEFT JOIN bb AS c2 USING ( col_varchar ) +WHERE ( gp1 . col_varchar_key >= 'n' ) +) +AND ( gp1 . col_varchar < 'e' ) +) +AND ( gp1 . col_varchar_key <> 'y' ) +ORDER BY gp1 . col_varchar_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE gp1 NULL range col_varchar_key,col_varchar_key_2,col_varchar_key_3 col_varchar_key_3 82 NULL 3 33.33 Using index condition; Using where +2 SIMPLE gp2 NULL ref col_varchar_key col_varchar_key 42 test.gp1.col_varchar_key 1 100.00 Using where +2 SIMPLE c1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 SIMPLE p1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 SIMPLE p2 NULL index NULL col_varchar_key 46 NULL 5 100.00 Using where; Using index +2 SIMPLE c2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch(gp2) +Warnings: +Note 1276 Field or reference 'test.gp1.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.gp1.col_int' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.gp1.col_varchar' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`gp1`.`col_varchar` AS `g1` from `test`.`b` `gp1` left join `test`.`bb` `gp2` on((`test`.`gp2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_key`)) semi join (`test`.`bb` `p1` left join `test`.`bb` `p2` on((`test`.`p1`.`col_int` >= `test`.`p2`.`col_int_key`)) join `test`.`b` `c1` left join `test`.`bb` `c2` on((`test`.`c1`.`col_varchar` = `test`.`c2`.`col_varchar`))) where ((`test`.`c1`.`col_int` = `test`.`gp1`.`col_int`) and (`test`.`p1`.`col_int` = `test`.`gp1`.`col_int`) and (`test`.`gp1`.`col_varchar_key` <> 'y') and (`test`.`gp1`.`col_varchar` < 'e') and (`test`.`gp1`.`col_varchar_key` >= 'n')) order by `test`.`gp1`.`col_varchar_key` limit 4 +SELECT gp1 . col_varchar AS g1 +FROM b AS gp1 LEFT JOIN bb AS gp2 USING ( col_varchar_key ) +WHERE gp1 . col_int IN ( +SELECT p1 . col_int AS p1 +FROM bb AS p1 LEFT JOIN bb AS p2 +ON ( p1 . col_int >= p2 . col_int_key ) +WHERE ( p1 . col_int , gp1 . col_int ) IN ( +SELECT c1 . col_int AS C1 +, c1 . col_int AS C2 +FROM b AS c1 LEFT JOIN bb AS c2 USING ( col_varchar ) +WHERE ( gp1 . col_varchar_key >= 'n' ) +) +AND ( gp1 . col_varchar < 'e' ) +) +AND ( gp1 . col_varchar_key <> 'y' ) +ORDER BY gp1 . col_varchar_key LIMIT 4; +g1 +DROP TABLE b,bb; +# +# Bug#23759797: DESC INDEX BACKWARD SCAN SHOWS WRONG RESULTS +# +CREATE TABLE t1 ( +col_varchar_255_latin1_key varchar(255) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +KEY (pk DESC), +KEY k3 (col_varchar_255_latin1_key DESC) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(col_varchar_255_latin1_key, pk) VALUES +('l',4), ('something',3), ('ycyoybhug',2), ('l',5), ('my',1), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4), +('l',4),('l',4),('l',4),('l',4),('l',4),('l',4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT +t1 . pk AS field1, +t1 . pk AS field2 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . col_varchar_255_latin1_key = t2 . col_varchar_255_latin1_key +WHERE t1 . pk <> 4 +ORDER BY field1, field2 DESC; +field1 field2 +1 1 +2 2 +3 3 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +EXPLAIN SELECT +t1 . pk AS field1, +t1 . pk AS field2 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . col_varchar_255_latin1_key = t2 . col_varchar_255_latin1_key +WHERE t1 . pk <> 4 +ORDER BY field1, field2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL range pk pk 4 NULL # # Using index condition; Backward index scan +2 SIMPLE t2 NULL ref k3 k3 1023 test.t1.col_varchar_255_latin1_key # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `field1`,`test`.`t1`.`pk` AS `field2` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`col_varchar_255_latin1_key` = `test`.`t1`.`col_varchar_255_latin1_key`)) where (`test`.`t1`.`pk` <> 4) order by `field1` +DROP TABLE t1; +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk DESC), +KEY k3 (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (25,9), (24,1), (23,-74383360), (22,-855900160), +(21,NULL), (20,1596522496), (19,9), (18,1), (17,NULL), (16,NULL), +(15,1808465920), (14,NULL), (13,588644352), (12,3), (11,6), (10,NULL), +(9,NULL), (8,8), (7,NULL), (6,NULL), (5,-1018232832), (4,5), (3,NULL), +(2,NULL), (1,NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT DISTINCT +t1 . pk AS field1 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . pk = t2 . pk +WHERE ( t1 . col_int_key IS NULL AND t1 . pk != 4 ) +GROUP BY field1 +HAVING field1 != 6 +ORDER BY field1 ASC; +field1 +1 +2 +3 +7 +9 +10 +14 +16 +17 +21 +EXPLAIN SELECT DISTINCT +t1 . pk AS field1 +FROM t1 LEFT JOIN t1 AS t2 +ON t1 . pk = t2 . pk +WHERE ( t1 . col_int_key IS NULL AND t1 . pk != 4 ) +GROUP BY field1 +HAVING field1 != 6 +ORDER BY field1 ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY,k3 k3 9 NULL 11 100.00 Using where; Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `field1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`pk` = `test`.`t1`.`pk`)) where ((`test`.`t1`.`col_int_key` is null) and (`test`.`t1`.`pk` <> 4)) group by `field1` having (`field1` <> 6) order by `field1` +EXPLAIN UPDATE t1 +SET t1.pk = pk + 1000 +WHERE ( t1 . col_int_key IS NULL AND t1 . pk != 4 ) +ORDER BY pk ASC LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY,k3 PRIMARY 4 const 24 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`pk` = (`test`.`t1`.`pk` + 1000) where ((`test`.`t1`.`col_int_key` is null) and (`test`.`t1`.`pk` <> 4)) order by `test`.`t1`.`pk` limit 3 +DROP TABLE t1; +# +# +# Bug #23738137: WL1074:RESULT DIFFERENCE SEEN FOR +# QUERY WITH OR IN JOIN CONDITION +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +col_int_key INTEGER DEFAULT NULL, +col_varchar_key varchar(20) DEFAULT NULL, +col_varchar varchar(20) DEFAULT NULL, +PRIMARY KEY (pk DESC), +KEY col_int_key (col_int_key DESC), +KEY col_varchar_key (col_varchar_key DESC) +) charset latin1; +INSERT INTO t1 VALUES (20,8,'eiw','eiw'),(19,8,'oeiws','oeiws'), +(18,NULL,'koeiw','koeiw'),(17,3,'kkoei','kkoei'), +(16,9,'ukkoe','ukkoe'),(15,5,'qukko','qukko'), +(14,2,'kqukk','kqukk'),(13,80,'ukquk','ukquk'), +(12,5,'lukqu','lukqu'),(10,NULL,'alukq','alukq'), +(9,3,'maluk','maluk'),(8,NULL,NULL,NULL), +(7,9,'ymalu','ymalu'),(6,3,'kymal','kymal'), +(5,6,'vkyma','vkyma'),(4,8,'vvkym','vvkym'), +(3,3,'jjvvk','jjvvk'),(1,5,'bjjvv','bjjvv'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON +(t2.pk = t1.col_int_key) OR (t2.col_varchar_key = t1.col_varchar_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 18 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 18 19.00 Range checked for each record (index map: 0x5) +Warnings: +Note 1003 /* select#1 */ select straight_join count(`test`.`t1`.`col_varchar`) AS `count(t1.col_varchar)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk` = `test`.`t1`.`col_int_key`) or (`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) +SELECT STRAIGHT_JOIN count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON +(t2.pk = t1.col_int_key) OR (t2.col_varchar_key = t1.col_varchar_key); +count(t1.col_varchar) +29 +EXPLAIN SELECT count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON (t2.pk = t1.col_int_key) +OR (t2.col_varchar_key = t1.col_varchar_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 18 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 18 19.00 Range checked for each record (index map: 0x5) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`col_varchar`) AS `count(t1.col_varchar)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk` = `test`.`t1`.`col_int_key`) or (`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) +SELECT count(t1.col_varchar) FROM t1 JOIN t1 AS t2 ON (t2.pk = t1.col_int_key) +OR (t2.col_varchar_key = t1.col_varchar_key); +count(t1.col_varchar) +29 +DROP TABLE t1; +# End of test for Bug#23738137 +# +# Bug#24294552:MULTI KEY DESC INDEX ON GCOL GIVES INCORRECT RESULTS +# +CREATE TABLE t2 ( +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11), +PRIMARY KEY (pk DESC), +KEY k2 (col_int_key, col_int DESC) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO +t2(col_int,col_int_key) VALUES (1,2), (2,4), (3,6), (4,8), (5,10), (6,12), +(7,14), (8,16), (9,18); +CREATE TABLE t1 ( +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL, +col_int_key int(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(pk, col_int, col_int_key) VALUES (4,3,6), (5,4,8), (6,2,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN +t1 . col_int_key AS field1 , +t2 . col_int AS field2 +FROM t1 LEFT JOIN t2 FORCE INDEX(k2) +ON t1 . col_int = t2 . col_int +WHERE ( t2 . col_int_key <= t1 . col_int_key AND t1 . pk >= t2 . pk ) +ORDER BY field1, field2 DESC; +field1 field2 +4 2 +6 3 +8 4 +EXPLAIN SELECT STRAIGHT_JOIN +t1 . col_int_key AS field1 , +t2 . col_int AS field2 +FROM t1 LEFT JOIN t2 force index(k2) +ON t1 . col_int = t2 . col_int +WHERE ( t2 . col_int_key <= t1 . col_int_key AND t1 . pk >= t2 . pk ) +ORDER BY field1, field2 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +2 SIMPLE t2 NULL ALL k2 NULL NULL NULL # # Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`col_int_key` AS `field1`,`test`.`t2`.`col_int` AS `field2` from `test`.`t1` join `test`.`t2` FORCE INDEX (`k2`) where ((`test`.`t2`.`col_int` = `test`.`t1`.`col_int`) and (`test`.`t2`.`col_int_key` <= `test`.`t1`.`col_int_key`) and (`test`.`t1`.`pk` >= `test`.`t2`.`pk`)) order by `field1`,`field2` desc +DROP TABLE t1,t2; +# +# +# Bug#24300848:WL1074: INNODB: ASSERTION FAILURE: +# BTR0PCUR.CC:268:CURSOR->OLD_REC +# +CREATE TABLE t1(col1 int , col2 int, PRIMARY KEY (col1 DESC)) +PARTITION BY RANGE (col1) (PARTITION p0 VALUES LESS THAN (5)); +INSERT INTO t1 VALUES(1, 10); +SELECT * FROM t1 WHERE col1 IN (1, 2); +col1 col2 +1 10 +DROP TABLE t1; +# End of test for Bug#24300848 +# +# Bug#24431177: WL1074:LEFT JOIN QUERY USING INDEX SHOWS +# WRONG QEP AND RESULTS ON 2ND EXECUTION +# +CREATE TABLE t1( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_int_key INTEGER DEFAULT NULL, +PRIMARY KEY (pk DESC), +KEY col_int_key (col_int_key DESC) +); +INSERT INTO t1 VALUES (3,15),(6,8),(20,6),(15,6),(18,5),(17,5), +(16,5),(13,5),(12,5),(9,5),(8,5),(7,5),(5,5),(11,4),(4,4), +(19,3),(10,2),(1,2),(14,1),(2,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 28.89 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,col_int_key col_int_key 5 NULL 20 28.89 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` where ((`test`.`t1`.`pk` in (6,2)) or ((`test`.`t1`.`col_int_key` >= 7) and (`test`.`t1`.`col_int_key` < 13))) +SELECT * FROM t1 WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +pk col_int_key +2 1 +6 8 +ALTER TABLE t1 ADD INDEX key1 (pk); +ALTER TABLE t1 ADD INDEX key2 (col_int_key); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 FORCE INDEX (key1,col_int_key) WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge col_int_key,key1 key1,col_int_key 4,5 NULL 2 100.00 Using sort_union(key1,col_int_key); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` FORCE INDEX (`col_int_key`) FORCE INDEX (`key1`) where ((`test`.`t1`.`pk` in (6,2)) or ((`test`.`t1`.`col_int_key` >= 7) and (`test`.`t1`.`col_int_key` < 13))) +SELECT * FROM t1 FORCE INDEX (key1,col_int_key) WHERE pk IN (6,2) +OR (col_int_key >= 7 AND col_int_key < 13); +pk col_int_key +2 1 +6 8 +DROP TABLE t1; +# End of test for Bug#24431777 +CREATE TABLE t1( +a INTEGER NOT NULL, +b INTEGER NOT NULL, +KEY ab (a DESC,b DESC) +); +INSERT INTO t1 VALUES (78,7),(78,6),(70,1),(47,1),(15,4),(15,1), +(10,6),(3,6),(2,56),(2,6),(1,56); +SELECT * FROM t1 WHERE ( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) ); +a b +47 1 +15 1 +DROP TABLE t1; +# +# Bug #25899921: INCORRECT BEHAVIOR WITH DESC INDEX AND +# IMPOSSIBLE CONDITION +# +CREATE TABLE t1 (a INT, b DATE, KEY(b,a DESC)); +SET @g:='1'; +DELETE FROM t1 WHERE b=@g ORDER BY b, a LIMIT 1; +ERROR 22007: Incorrect date value: '1' for column 'b' at row 1 +DROP TABLE t1; +# End of test for Bug#25899921 diff --git a/mysql-test/r/distinct_innodb.result-pq b/mysql-test/r/distinct_innodb.result-pq new file mode 100644 index 000000000..99e696935 --- /dev/null +++ b/mysql-test/r/distinct_innodb.result-pq @@ -0,0 +1,965 @@ +# +# Bug#13335170 - ASSERT IN +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() ON SELECT DISTINCT +# +CREATE TABLE t1 ( +col_int_key int(11) NOT NULL, +col_time_key time NOT NULL, +col_datetime_key datetime NOT NULL, +KEY col_int_key (col_int_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,'06:17:39','2003-08-21 00:00:00'); +SELECT DISTINCT col_int_key +FROM t1 +WHERE col_int_key IN ( 18, 6, 84, 4, 0, 2, 8, 3, 7, 9, 1 ) +AND col_datetime_key BETWEEN '2001-08-04' AND '2003-06-13' +ORDER BY col_time_key +LIMIT 3; +col_int_key +DROP TABLE t1; + +# BUG#13581713 ONLY_FULL_GROUP_BY DOES NOT BLOCK "SELECT +# DISTINCT A ORDER BY B" + +create table t1(a int, b int, c int) engine=InnoDB; +create table t2(a int, b int, c int) engine=InnoDB; +insert into t2 values(); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +# Test when selecting from base table +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from t1 order by c; +b +2 +1 +select distinct min(b) from t1 group by a order by min(c); +min(b) +1 +2 +explain select distinct min(b) from t1 group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +Note 1003 /* select#1 */ select distinct min(`test`.`t1`.`b`) AS `min(b)` from `test`.`t1` group by `test`.`t1`.`a` order by min(`test`.`t1`.`c`) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from t1 order by c; +b +1 +2 +Random order too (same reason): +select distinct min(b) from t1 group by a order by min(c); +min(b) +1 +2 +This query gives random order: +select distinct b from t1 order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from t1 order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'test.t1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from t1 group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from t1 group by a order by min(b); +min(b) +1 +2 +select distinct min(b) from t1 group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from t1 group by a order by max(b-2)-min(c*5); +a min(b) +100 1 +400 2 +200 1 +300 2 +This one is standard: +select distinct min(b) as z from t1 group by a order by z; +z +1 +2 +Other queries: +select distinct b from t1 where b<0 order by rand(); +b +select distinct b from t1 order by 45.0+3; +b +1 +2 +select (select distinct b from t1 as S2 where b=7 order by S3.a) from t1 as S3; +(select distinct b from t1 as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from t1 order by abs(b); +b +1 +2 +select distinct b as z from t1 order by abs(z); +z +1 +2 +select distinct b from t1 order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from t1 order by z; +z +1 +2 +select distinct abs(b) as z from t1 order by abs(b); +z +1 +2 +select distinct abs(b) from t1 order by abs(b); +abs(b) +1 +2 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from t1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from t1 order by z+1; +z +1 +2 +select distinct abs(b) from t1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from t1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from t1 order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +(select floor(10*S2.b) from t1 as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from t1 as S2 order by +(select floor(10*S2.b) from t1 as S3 limit 1); +abs(b) b +1 1 +2 2 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from t1 as S2 order by +(select floor(10*S3.b) from t1 as S3 limit 1); +abs(b) +1 +2 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from t1 as S3 limit 1) as subq +from t1 as S2 order by subq; +abs(b) subq +1 10 +2 10 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from t1 as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +floor(10*10) IN (select floor(10*S2.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from t1 as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from t1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM t1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM t1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +100 +200 +300 +400 +DELETE FROM t1; +# Test when selecting from view +create view v1 as select t1.* from t1 left join t2 on 1; +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from v1 order by c; +b +2 +1 +select distinct min(b) from v1 group by a order by min(c); +min(b) +1 +2 +explain select distinct min(b) from v1 group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL # 1 100.00 Using where; Using join buffer (hash join) +Note 1003 /* select#1 */ select distinct min(`test`.`t1`.`b`) AS `min(b)` from `test`.`t1` left join `test`.`t2` on(true) where true group by `test`.`t1`.`a` order by min(`test`.`t1`.`c`) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from v1 order by c; +b +1 +2 +Random order too (same reason): +select distinct min(b) from v1 group by a order by min(c); +min(b) +1 +2 +This query gives random order: +select distinct b from v1 order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from v1 order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from v1 group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from v1 group by a order by min(b); +min(b) +1 +2 +select distinct min(b) from v1 group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from v1 group by a order by max(b-2)-min(c*5); +a min(b) +100 1 +400 2 +200 1 +300 2 +This one is standard: +select distinct min(b) as z from v1 group by a order by z; +z +1 +2 +Other queries: +select distinct b from v1 where b<0 order by rand(); +b +select distinct b from v1 order by 45.0+3; +b +1 +2 +select (select distinct b from v1 as S2 where b=7 order by S3.a) from v1 as S3; +(select distinct b from v1 as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from v1 order by abs(b); +b +1 +2 +select distinct b as z from v1 order by abs(z); +z +1 +2 +select distinct b from v1 order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z; +z +1 +2 +select distinct abs(b) as z from v1 order by abs(b); +z +1 +2 +select distinct abs(b) from v1 order by abs(b); +abs(b) +1 +2 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z+1; +z +1 +2 +select distinct abs(b) from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from v1 order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +abs(b) b +1 1 +2 2 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from v1 as S2 order by +(select floor(10*S3.b) from v1 as S3 limit 1); +abs(b) +1 +2 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from v1 as S3 limit 1) as subq +from v1 as S2 order by subq; +abs(b) subq +1 10 +2 10 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) IN (select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +100 +200 +300 +400 +DELETE FROM t1; +drop view v1; +# Test when selecting from view, again +create view v1 as select t1.a*2 as a, t1.b*2 as b, t1.c*2 as c from t1; +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from v1 order by c; +b +4 +2 +select distinct min(b) from v1 group by a order by min(c); +min(b) +2 +4 +explain select distinct min(b) from v1 group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +Note 1003 /* select#1 */ select distinct min((`test`.`t1`.`b` * 2)) AS `min(b)` from `test`.`t1` group by (`test`.`t1`.`a` * 2) order by min((`test`.`t1`.`c` * 2)) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from v1 order by c; +b +2 +4 +Random order too (same reason): +select distinct min(b) from v1 group by a order by min(c); +min(b) +2 +4 +This query gives random order: +select distinct b from v1 order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from v1 order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'test.v1.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from v1 group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from v1 group by a order by min(b); +min(b) +2 +4 +select distinct min(b) from v1 group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from v1 group by a order by max(b-2)-min(c*5); +a min(b) +200 2 +800 4 +400 2 +600 4 +This one is standard: +select distinct min(b) as z from v1 group by a order by z; +z +2 +4 +Other queries: +select distinct b from v1 where b<0 order by rand(); +b +select distinct b from v1 order by 45.0+3; +b +2 +4 +select (select distinct b from v1 as S2 where b=7 order by S3.a) from v1 as S3; +(select distinct b from v1 as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from v1 order by abs(b); +b +2 +4 +select distinct b as z from v1 order by abs(z); +z +2 +4 +select distinct b from v1 order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z; +z +2 +4 +select distinct abs(b) as z from v1 order by abs(b); +z +2 +4 +select distinct abs(b) from v1 order by abs(b); +abs(b) +2 +4 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by z+1; +z +2 +4 +select distinct abs(b) from v1 order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from v1 order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.v1.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from v1 as S2 order by +(select floor(10*S2.b) from v1 as S3 limit 1); +abs(b) b +2 2 +4 4 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from v1 as S2 order by +(select floor(10*S3.b) from v1 as S3 limit 1); +abs(b) +2 +4 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from v1 as S3 limit 1) as subq +from v1 as S2 order by subq; +abs(b) subq +2 20 +4 20 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) IN (select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from v1 as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from v1 as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM v1 AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +200 +400 +600 +800 +DELETE FROM t1; +drop view v1; +# Test when selecting from derived table +insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by c; +b +2 +1 +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +min(b) +1 +2 +explain select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL # 4 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL # 1 100.00 Using where; Using join buffer (hash join) +Note 1003 /* select#1 */ select distinct min(`test`.`t1`.`b`) AS `min(b)` from `test`.`t1` left join `test`.`t2` on(true) where true group by `test`.`t1`.`a` order by min(`test`.`t1`.`c`) +Warnings: +Insert rows in different order: +delete from t1; +insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +And get a different order. Query is executed like this: +- First, DISTINCT, using a tmp MEMORY table with a unique +index, thus if two rows have the same 'b' but a different 'c', +the second row is rejected, so the first value of 'c' wins +(=> randomness of 'c') +- Second, ORDER BY on the random 'c'. +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by c; +b +1 +2 +Random order too (same reason): +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +min(b) +1 +2 +This query gives random order: +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by c; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by b-1,b+1,c; +ERROR HY000: Expression #3 of ORDER BY clause is not in SELECT list, references column 'derived.c' which is not in SELECT list; this is incompatible with DISTINCT +and this one too: +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(c); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Not random (though Standard bans aggregates from ORDER BY): +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by min(b); +min(b) +1 +2 +select distinct min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by -min(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +All group exprs are in select list => DISTINCT is removed => no error +select distinct a, min(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by max(b-2)-min(c*5); +a min(b) +100 1 +400 2 +200 1 +300 2 +This one is standard: +select distinct min(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived group by a order by z; +z +1 +2 +Other queries: +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived where b<0 order by rand(); +b +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by 45.0+3; +b +1 +2 +select (select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) as S2 where b=7 order by S3.a) from (SELECT t1.* FROM t1 left join t2 on 1) as S3; +(select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) as S2 where b=7 order by S3.a) +NULL +NULL +NULL +NULL +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b); +b +1 +2 +select distinct b as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(z); +z +1 +2 +select distinct b from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b+a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.a' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by z; +z +1 +2 +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b); +z +1 +2 +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b); +abs(b) +1 +2 +Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias +to one, and mentions a column of FROM tables. +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by z+1; +z +1 +2 +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by abs(b)+1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) as z from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by floor(10*b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +Two offending columns; error message needs to report only one +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) AS derived order by floor(10*b),floor(10*a); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'derived.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +(select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Ok as S2.b in SELECT list +select distinct abs(b),b from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +(select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1); +abs(b) b +1 1 +2 2 +Ok as subq does not use columns of FROM clause of ordered Q. +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +(select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1); +abs(b) +1 +2 +Subq as alias => ok +select distinct abs(b), +(select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3 limit 1) as subq +from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by subq; +abs(b) subq +1 10 +2 10 +Bad field in left or right argument of ALL/ANY(subq): +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*S2.b) IN (select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*S2.b) > ALL(select floor(10*S3.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*10) IN (select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct abs(b) from (SELECT t1.* FROM t1 left join t2 on 1) as S2 order by +floor(10*10) > ALL(select floor(10*S2.b) from (SELECT t1.* FROM t1 left join t2 on 1) as S3); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'S2.b' which is not in SELECT list; this is incompatible with DISTINCT +Aggregates: +SELECT distinct 1 FROM t1 group by a order by count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +SELECT distinct 1 FROM t1 group by a order by count(*)-count(*); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +Test ANY_VALUE +SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b)); +1 +1 +SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b)); +1 +1 +All group exprs are in select list => DISTINCT is removed => no error +SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); +a min(b) +100 1 +200 1 +300 2 +400 2 +SELECT distinct 1 FROM t1 group by a order by count(*)-count(b); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, contains aggregate function; this is incompatible with DISTINCT +aggregation in outer Q => constant in inner Q +select * from t1 as t2 where t2.a in +(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a)); +a b c +ORDER BY expressions are in SELECT list => ok +SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b); +1 count(*)-count(b) +1 0 +Without GROUP BY, aggregates yield a single row, no random order +SELECT distinct sum(a) FROM t1 order by count(*)-count(*); +sum(a) +1000 +SELECT distinct sum(a) FROM t1 order by count(*)-count(b); +sum(a) +1000 +Verify that DISTINCT is optimized away even if the aggregate +function is hidden in a subquery +EXPLAIN SELECT DISTINCT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +but if the subquery is the aggregation query, DISTINCT must stay: +EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct (/* select#2 */ select max((`test`.`t1`.`b` + (0 * `test`.`t2`.`a`))) from `test`.`t1` `t2` limit 1) AS `(SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1)` from `test`.`t1` +QA's query is properly rejected: +SELECT DISTINCT GP1.a AS g1 FROM (SELECT t1.* FROM t1 left join t2 on 1) AS GP1 +WHERE GP1.a >= 0 +ORDER BY GP1.b LIMIT 8; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'GP1.b' which is not in SELECT list; this is incompatible with DISTINCT +result order does change depending on chosen plan. +SELECT DISTINCT GP1.a AS g1 FROM (SELECT t1.* FROM t1 left join t2 on 1) AS GP1 +WHERE GP1.a >= 0 +ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8; +g1 +100 +200 +300 +400 +DELETE FROM t1; +select distinct t1_outer.a from t1 t1_outer +order by t1_outer.b; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1_outer.b' which is not in SELECT list; this is incompatible with DISTINCT +select distinct t1_outer.a from t1 t1_outer +order by (select max(t1_outer.b+t1_inner.b) from t1 t1_inner); +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1_outer.b' which is not in SELECT list; this is incompatible with DISTINCT +select +(select distinct 1 from t1 t1_inner +group by t1_inner.a order by max(t1_outer.b)) +from t1 t1_outer; +(select distinct 1 from t1 t1_inner +group by t1_inner.a order by max(t1_outer.b)) +NULL +drop table t1, t2; diff --git a/mysql-test/r/endspace.result-pq b/mysql-test/r/endspace.result-pq new file mode 100644 index 000000000..ab75a7d41 --- /dev/null +++ b/mysql-test/r/endspace.result-pq @@ -0,0 +1,243 @@ +drop table if exists t1; +set names utf8mb4 collate utf8mb4_unicode_ci; +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +1 0 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +1 0 0 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +1 0 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +1 0 0 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 0 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +set names default; +create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) charset latin1; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +analyze table t1; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1 ignore key (key1) where text1='teststring' or +text1 like 'teststring_%' ORDER BY text1; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 > 'teststring\t'; +text1 +teststring +select * from t1 order by text1; +text1 +nothing +teststring +teststring +explain select * from t1 order by text1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL key1 34 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`text1` AS `text1` from `test`.`t1` order by `test`.`t1`.`text1` +alter table t1 modify text1 char(32) binary not null; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1 ignore key (key1) where text1='teststring' or +text1 like 'teststring_%' ORDER BY text1; +text1 +teststring +teststring +select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c; +c +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring| +select text1, length(text1) from t1 order by text1; +text1 length(text1) +nothing 7 +teststring 11 +teststring 10 +select text1, length(text1) from t1 order by binary text1; +text1 length(text1) +nothing 7 +teststring 10 +teststring 11 +alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20)); +insert into t1 values ('teststring '); +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring| +|teststring | +|teststring | +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring'; +concat('|', text1, '|') +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring '; +concat('|', text1, '|') +|teststring | +alter table t1 modify text1 text not null, pack_keys=1; +analyze table t1; +select concat('|', text1, '|') from t1 where text1='teststring'; +concat('|', text1, '|') +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring '; +concat('|', text1, '|') +|teststring | +|teststring| +explain select concat('|', text1, '|') from t1 where text1='teststring '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref key1 key1 22 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select concat('|',`test`.`t1`.`text1`,'|') AS `concat('|', text1, '|')` from `test`.`t1` where (`test`.`t1`.`text1` = 'teststring ') +select concat('|', text1, '|') from t1 where text1 like 'teststring_%'; +concat('|', text1, '|') +|teststring | +|teststring | +select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c; +c +|teststring | +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; +concat('|', text1, '|') +|teststring | +|teststring| +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring | +|teststring| +|teststring | +drop table t1; +create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) charset latin1 pack_keys=0; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c; +c +|teststring | +|teststring| +select concat('|', text1, '|') from t1 where text1='teststring' or text1 >= 'teststring\t'; +concat('|', text1, '|') +|teststring | +|teststring| +drop table t1; +create table t1 (text1 varchar(32) not NULL, KEY key1 using BTREE (text1)) +charset latin1 engine=heap; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +select * from t1 ignore key (key1) where text1='teststring' or +text1 like 'teststring_%' ORDER BY text1; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 >= 'teststring\t'; +text1 +teststring +teststring +select * from t1 order by text1; +text1 +nothing +teststring +teststring +explain select * from t1 order by text1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`text1` AS `text1` from `test`.`t1` order by `test`.`t1`.`text1` +alter table t1 modify text1 char(32) binary not null; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +select * from t1 order by text1; +text1 +nothing +teststring +teststring +drop table t1; +create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) +charset latin1 engine=innodb; +insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); +analyze table t1; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 +teststring +teststring +select * from t1 where text1='teststring' or text1 > 'teststring\t'; +text1 +teststring +select * from t1 order by text1; +text1 +nothing +teststring +teststring +explain select * from t1 order by text1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL key1 34 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`text1` AS `text1` from `test`.`t1` order by `test`.`t1`.`text1` +alter table t1 modify text1 char(32) binary not null; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +select * from t1 order by text1; +text1 +nothing +teststring +teststring +alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20)); +insert into t1 values ('teststring '); +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring | +|teststring | +|teststring| +alter table t1 modify text1 text not null, pack_keys=1; +select * from t1 where text1 like 'teststring_%'; +text1 +teststring +teststring +select text1, length(text1) from t1 where text1='teststring' or text1 like 'teststring_%'; +text1 length(text1) +teststring 11 +teststring 10 +teststring 11 +select text1, length(text1) from t1 where text1='teststring' or text1 >= 'teststring\t'; +text1 length(text1) +teststring 11 +teststring 10 +teststring 11 +select concat('|', text1, '|') from t1 order by text1; +concat('|', text1, '|') +|nothing| +|teststring | +|teststring| +|teststring | +drop table t1; diff --git a/mysql-test/r/error_simulation.result-pq b/mysql-test/r/error_simulation.result-pq new file mode 100644 index 000000000..cf11793a3 --- /dev/null +++ b/mysql-test/r/error_simulation.result-pq @@ -0,0 +1,119 @@ +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 ( +a varchar(32) character set utf8 collate utf8_bin NOT NULL, +b varchar(32) character set utf8 collate utf8_bin NOT NULL ) +DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('AAAAAAAAAA','AAAAAAAAAA'), ('AAAAAAAAAB','AAAAAAAAAB '), +('AAAAAAAAAB','AAAAAAAAAB'), ('AAAAAAAAAC','AAAAAAAAAC'), +('AAAAAAAAAD','AAAAAAAAAD'), ('AAAAAAAAAE','AAAAAAAAAE'), +('AAAAAAAAAF','AAAAAAAAAF'), ('AAAAAAAAAG','AAAAAAAAAG'), +('AAAAAAAAAH','AAAAAAAAAH'), ('AAAAAAAAAI','AAAAAAAAAI'), +('AAAAAAAAAJ','AAAAAAAAAJ'), ('AAAAAAAAAK','AAAAAAAAAK'); +set session internal_tmp_mem_storage_engine='memory'; +set tmp_table_size=1024; +set session debug="d,raise_error"; +SELECT MAX(a) FROM t1 GROUP BY a,b; +ERROR 23000: Can't write; duplicate key in table 'tmp_table' +WITH qn (z) AS +( +SELECT 1 FROM t1, t1 t2, t1 t3, t1 t4 LIMIT 100000000 +) +SELECT * FROM qn qn0 WHERE z = (SELECT z FROM qn qn1 LIMIT 1); +ERROR 23000: Can't write; duplicate key in table 'tmp_table' +set tmp_table_size=default; +set session internal_tmp_mem_storage_engine=default; +DROP TABLE t1; +# +# Bug #50946: fast index creation still seems to copy the table +# +CREATE TABLE t1 (a INT(100) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1), (0), (2); +SET SESSION debug='+d,alter_table_only_index_change'; +ALTER TABLE t1 ADD INDEX a(a); +SET SESSION debug=DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +a +0 +1 +2 +DROP TABLE t1; +# +# Bug#42064: low memory crash when importing hex strings, in Item_hex_string::Item_hex_string +# +CREATE TABLE t1(a BLOB); +call mtr.add_suppression(".*Out of memory *"); +SET SESSION debug="+d,bug42064_simulate_oom"; +INSERT INTO t1 VALUES(""); +Got one of the listed errors +SET SESSION debug=DEFAULT; +DROP TABLE t1; +# +# Bug#41660: Sort-index_merge for non-first join table may require +# O(#scans) memory +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); +CREATE TABLE t2 (a INT, b INT, filler CHAR(100), KEY(a), KEY(b)); +INSERT INTO t2 SELECT 1000, 1000, 'filler' FROM t1 A, t1 B, t1 C; +INSERT INTO t2 VALUES (1, 1, 'data'); +# the example query uses LEFT JOIN only for the sake of being able to +# demonstrate the issue with a very small dataset. (left outer join +# disables the use of join buffering, so we get the second table +# re-scanned for every record in the outer table. if we used inner join, +# we would need to have thousands of records and/or more columns in both +# tables so that the join buffer is filled and re-scans are triggered). +SET SESSION debug = '+d,only_one_Unique_may_be_created'; +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON ( t2.a < 10 OR t2.b < 10 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x 100.00 Parallel execute (1 workers) +x x x NULL x x x x x x 100.00 NULL +x x x NULL x x x x x x 100.00 Using sort_union(a,b); Using where; Using join buffer (hash join) +Warnings: +x x x +SELECT * FROM t1 LEFT JOIN t2 ON ( t2.a < 10 OR t2.b < 10 ); +a a b filler +0 1 1 data +1 1 1 data +2 1 1 data +3 1 1 data +4 1 1 data +5 1 1 data +6 1 1 data +7 1 1 data +8 1 1 data +9 1 1 data +SET SESSION debug = DEFAULT; +DROP TABLE t1, t2; +# +# End of 5.1 tests +# +# +# Bug#19656296 FIND_ALL_KEYS SPAMS SERVER ERROR LOG WITH +# DEADLOCK/LOCK WAIT ERRORS +# +create table t1(a int) ; +insert into t1 values(1),(2),(3); +set session debug=""; +set session debug='+d,ha_pq_next_deadlock'; +select * from t1 order by a; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +drop table t1; +SET debug= DEFAULT; diff --git a/mysql-test/r/explain_for_connection_small_json_innodb.result-pq b/mysql-test/r/explain_for_connection_small_json_innodb.result-pq new file mode 100644 index 000000000..377971e15 --- /dev/null +++ b/mysql-test/r/explain_for_connection_small_json_innodb.result-pq @@ -0,0 +1,95 @@ +"WL6369 Explain for Connection" +QUERY: UPDATE t1 SET b = CONCAT(b, ', max(a) in t2: ', (SELECT MAX(a) FROM t2)) WHERE a = 5 +STATUS:NOT_EQUAL +SYNC_POINT:planned_single_update +Diff: EXPLAIN NORMAL vs OTHER +@@ -24,3 +24,3 @@ + "filtered": "100.00", +- "attached_condition": "(`test`.`t1`.`a` = 5)" ++ "using_where": true + }, +@@ -32,3 +32,3 @@ + "select_id": 2, +- "message": "Select tables optimized away" ++ "message": "Plan isn't ready yet" + } +QUERY: UPDATE t1, t2 SET t1.b = CONCAT(t1.b, ', t2.b:', t2.b), t2.b = CONCAT(t2.b, ', t1.b:', t1.b) WHERE t2.b = t1.b and t2.a = 4 +STATUS: EQUAL +QUERY: SELECT (SELECT rs.t2_id FROM t2 rs WHERE rs.t1_id= (SELECT lt.t1_id FROM t1 lt WHERE lt.t3_id=a.t3_id) ORDER BY b DESC LIMIT 1) from t3 AS a +STATUS:NOT_EQUAL +SYNC_POINT:before_reset_query_plan +Diff: EXPLAIN NORMAL vs OTHER +@@ -51,2 +51,3 @@ + "filtered": "100.00", ++ "using_where": true, + "using_index": true, +@@ -63,3 +64,2 @@ + ], +- "attached_condition": "(`test`.`rs`.`t1_id` = (/* select#3 */ select `test`.`lt`.`t1_id` from `test`.`t1` `lt` where (`test`.`lt`.`t3_id` = `test`.`a`.`t3_id`)))", + "attached_subqueries": [ +@@ -79,2 +79,3 @@ + "filtered": "100.00", ++ "using_where": true, + "cost_info": { +@@ -88,4 +89,3 @@ + "t1_id" +- ], +- "attached_condition": "(`test`.`lt`.`t3_id` = `test`.`a`.`t3_id`)" ++ ] + } +QUERY: SELECT DISTINCT alias2.col_int AS field1 , alias2.col_int AS field2 FROM a1 AS alias1 LEFT JOIN aa1 AS alias2 ON alias1.pk = alias2.pk WHERE ( alias1.col_int = 8 OR alias1 .pk <= alias1.col_int ) GROUP BY field1, field2 ORDER BY field1, field2 DESC +STATUS:NOT_EQUAL +SYNC_POINT:before_reset_query_plan +Diff: EXPLAIN NORMAL vs OTHER +@@ -46,2 +46,3 @@ + "filtered": "100.00", ++ "using_where": true, + "cost_info": { +@@ -55,4 +56,3 @@ + "pk" +- ], +- "attached_condition": "((`test`.`alias1`.`col_int` = 8) or (`test`.`alias1`.`pk` <= `test`.`alias1`.`col_int`))" ++ ] + } +QUERY: SELECT alias1.pk AS field1 FROM h2 AS alias1 LEFT JOIN aa3 AS alias2 ON alias1.pk = alias2.col_int_key WHERE alias1.pk <> 9 GROUP BY field1 ORDER BY field1 LIMIT 1 OFFSET 3 +STATUS:NOT_EQUAL +SYNC_POINT:before_reset_query_plan +Diff: EXPLAIN NORMAL vs OTHER +@@ -48,2 +48,3 @@ + "filtered": "100.00", ++ "using_where": true, + "using_index": true, +@@ -57,4 +58,3 @@ + "pk" +- ], +- "attached_condition": "(`test`.`alias1`.`pk` <> 9)" ++ ] + } +QUERY: SELECT alias1.pk AS field1 FROM e1 AS alias1 RIGHT JOIN cc2 AS alias2 ON alias1.col_int = alias2.col_int WHERE alias1.col_int_key IN (8) +STATUS:NOT_EQUAL +SYNC_POINT:before_reset_query_plan +Diff: EXPLAIN NORMAL vs OTHER +@@ -66,4 +66,5 @@ + "rows_examined_per_scan": 2, +- "rows_produced_per_join": 1, +- "filtered": "50.00", ++ "rows_produced_per_join": 2, ++ "filtered": "100.00", ++ "using_where": true, + "using_join_buffer": "hash join", +@@ -71,5 +72,5 @@ + "read_cost": "0.25", +- "eval_cost": "0.10", ++ "eval_cost": "0.20", + "prefix_cost": "0.80", +- "data_read_per_join": "8" ++ "data_read_per_join": "16" + }, +@@ -77,4 +78,3 @@ + "col_int" +- ], +- "attached_condition": "(`test`.`alias2`.`col_int` = `test`.`alias1`.`col_int`)" ++ ] + } +QUERY: SELECT DISTINCT alias2.pk AS field1, alias2.pk AS field2, alias2.pk AS field3 FROM t1 AS alias1 RIGHT JOIN t2 AS alias2 ON alias1.col_varchar_key = alias2.col_varchar_key WHERE alias1.col_int >alias1.col_int HAVING field3 = 7 ORDER BY field1, field2, field3 LIMIT 10 OFFSET 1 +STATUS: EQUAL diff --git a/mysql-test/r/explain_other.result-pq b/mysql-test/r/explain_other.result-pq new file mode 100644 index 000000000..3772acd28 --- /dev/null +++ b/mysql-test/r/explain_other.result-pq @@ -0,0 +1,1526 @@ +# WL#6369: EXPLAIN for other query +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 (f1 int); +INSERT INTO t1 VALUES (1),(2); +ERROR HY000: This command is not supported in the prepared statement protocol yet +Test error throwing +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'EXPLAIN SELECT f1 FROM t1' +ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SHOW FIELDS IN t1' +ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE +PREPARE stmt FROM 'EXPLAIN FOR CONNECTION 1'; +ERROR HY000: This command is not supported in the prepared statement protocol yet +PREPARE stmt FROM 'SELECT * FROM t1'; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'EXECUTE stmt' +ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE +CREATE PROCEDURE proc6369() +EXPLAIN FOR CONNECTION 1; +ERROR 42000: This version of MySQL doesn't yet support 'non-standalone EXPLAIN FOR CONNECTION' +CREATE PROCEDURE proc6369() +SELECT * FROM t1; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'CALL proc6369()' +ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE +DROP PROCEDURE proc6369; +ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE +EXPLAIN FOR CONNECTION 11111111; +ERROR HY000: Unknown thread id: 11111111 +Explain queries with ready plan +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT f1 FROM t1' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary; Using filesort +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT f1 FROM t1' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "f1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + } + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "f1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + } + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "f1" + ], + "query_block": { + "cost_info": { + "query_cost": "1.10" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_where": true, + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + } + ] + } + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1' +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": true, + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + } + } + ] + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE 1=0' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 +GROUP BY f1 NOT IN +(SELECT f1+10 AS f2 FROM t1 AS t2 +GROUP BY f2 NOT IN +(SELECT f1+100 AS f3 FROM t1 AS t3))' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + }, + "group_by_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_where": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "f1" + ] + } + } + } + ] + } + } +} +Explain for non-select queries +EXPLAIN FORMAT=JSON FOR QUERY 'INSERT INTO t1 VALUES (3)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'INSERT INTO t1 SELECT 4' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'INSERT INTO t1 SELECT f1 + 4 FROM t1' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + }, + "table": { + "insert": true, + "select_id": 1, + "table_name": "t1", + "access_type": "ALL" + }, + "insert_from": { + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + }, + "used_columns": [ + "f1" + ] + } + } + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE t1 SET f1=4 WHERE f1=4' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Plan isn't ready yet" + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE t1 SET f1=4 WHERE f1=4' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "filtered": "100.00", + "using_where": true + } + } +} +CREATE TABLE t2 (f2 int); +EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE t1 SET f1=f1+0 +ORDER BY f1 NOT IN +(SELECT f1+10 AS f2 FROM t2 +GROUP BY f2 NOT IN +(SELECT f1+100 AS f3 FROM t2 AS t3))' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "filtered": "100.00" + }, + "order_by_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "Plan isn't ready yet" + } + } + ] + } + } +} +CREATE VIEW v1 AS SELECT t1.f1 FROM t1 JOIN t1 tt on t1.f1=tt.f1; +EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE v1 SET f1=5 WHERE f1=5' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.10" + }, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 1, + "filtered": "12.50", + "using_where": true, + "cost_info": { + "read_cost": "0.95", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "8" + }, + "used_columns": [ + "f1" + ] + } + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 1, + "filtered": "12.50", + "using_where": true, + "cost_info": { + "read_cost": "0.95", + "eval_cost": "0.10", + "prefix_cost": "2.10", + "data_read_per_join": "8" + }, + "used_columns": [ + "f1" + ] + } + } + ] + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'DELETE FROM t1 WHERE f1=4' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "filtered": "100.00", + "using_where": true + } + } +} +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO t1 VALUES (3)' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO t1 SELECT 4' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO t1 SELECT f1 + 4 FROM t1' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'UPDATE t1 SET f1=4 WHERE f1=4' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 18 100.00 Using where +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'UPDATE v1 SET f1=5 WHERE f1=5' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 18 10.00 Using where +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 18 10.00 Using where +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'DELETE FROM t1 WHERE f1=4' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 18 100.00 Using where +Explain queries with plan only partially ready +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1 GROUP BY 1) tt' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Plan isn't ready yet +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 17 100.00 Using temporary +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY +(SELECT * FROM t1 LIMIT 1)' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 17 100.00 NULL +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL Plan isn't ready yet +NULL UNION RESULT NULL NULL NULL NULL NULL NULL NULL NULL NULL Plan isn't ready yet +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Plan isn't ready yet +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM (SELECT * FROM t1 GROUP BY 1) tt' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Plan isn't ready yet", + "table": { + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.95" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ] + } + } + } + } + } + } +} +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY +(SELECT * FROM t1 LIMIT 1)' +EXPLAIN +{ + "query_block": { + "ordering_operation": { + "using_filesort": true, + "union_result": { + "using_temporary_table": true, + "message": "Plan isn't ready yet", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "Plan isn't ready yet" + } + } + ] + }, + "order_by_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "message": "Plan isn't ready yet" + } + } + ] + } + } +} +Ensure materialized derived still has plans after materialization +set @optimizer_switch_saved= @@optimizer_switch; +set optimizer_switch='derived_merge=off'; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 17 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 17 100.00 NULL +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.41" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.71", + "eval_cost": "1.70", + "prefix_cost": "4.41", + "data_read_per_join": "272" + }, + "used_columns": [ + "f1" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ] + } + } + } + } + } +} +set optimizer_switch= @optimizer_switch_saved; +WHERE subqueries, neither parent query nor subquery has plan +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2 +WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Plan isn't ready yet", + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "Plan isn't ready yet" + } + } + ] + } +} +the same, parent query has a plan +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2 +WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.83" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 5, + "filtered": "33.33", + "using_where": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.57", + "prefix_cost": "1.95", + "data_read_per_join": "45" + }, + "used_columns": [ + "f1" + ], + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "Plan isn't ready yet" + } + } + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 96, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "9.63", + "prefix_cost": "11.83", + "data_read_per_join": "770" + }, + "used_columns": [ + "f1" + ] + } + } + ] + } +} +the same, both have a plan +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2 +WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.83" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 5, + "filtered": "33.33", + "using_where": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.57", + "prefix_cost": "1.95", + "data_read_per_join": "45" + }, + "used_columns": [ + "f1" + ], + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ] + } + } + } + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 96, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "9.63", + "prefix_cost": "11.83", + "data_read_per_join": "770" + }, + "used_columns": [ + "f1" + ] + } + } + ] + } +} +To be compared with regular EXPLAIN: +EXPLAIN FORMAT=JSON SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2 +WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.83" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 5, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.57", + "prefix_cost": "1.95", + "data_read_per_join": "45" + }, + "used_columns": [ + "f1" + ], + "attached_condition": "(`mysqltest1`.`t1`.`f1` > (/* select#2 */ select `mysqltest1`.`t3`.`f1` from `mysqltest1`.`t1` `t3` limit 1))", + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ] + } + } + } + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 96, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "9.63", + "prefix_cost": "11.83", + "data_read_per_join": "770" + }, + "used_columns": [ + "f1" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `t2`.`f1` AS `f1` from `mysqltest1`.`t1` straight_join `mysqltest1`.`t1` `t2` where (`mysqltest1`.`t1`.`f1` > (/* select#2 */ select `mysqltest1`.`t3`.`f1` from `mysqltest1`.`t1` `t3` limit 1)) +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT 1 FROM t1 WHERE +ROW(f1,f1) >= ROW('1', (SELECT 1 FROM t1 WHERE f1 > 1234))' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "using_where": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ] + }, + "optimized_away_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 5, + "filtered": "33.33", + "using_where": true, + "cost_info": { + "read_cost": "1.38", + "eval_cost": "0.57", + "prefix_cost": "1.95", + "data_read_per_join": "45" + }, + "used_columns": [ + "f1" + ] + } + } + } + ] + } +} +EXPLAIN FORMAT=JSON SELECT 1 FROM t1 WHERE +ROW(f1,f1) >= ROW('1', (SELECT 1 FROM t1 WHERE f1 > 1234)); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ], + "attached_condition": "((`mysqltest1`.`t1`.`f1`,`mysqltest1`.`t1`.`f1`) >= ('1',(/* select#2 */ select 1 from `mysqltest1`.`t1` where (`t1`.`f1` > 1234))))" + }, + "optimized_away_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 5, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.38", + "eval_cost": "0.57", + "prefix_cost": "1.95", + "data_read_per_join": "45" + }, + "used_columns": [ + "f1" + ], + "attached_condition": "(`t1`.`f1` > 1234)" + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `mysqltest1`.`t1` where ((`mysqltest1`.`t1`.`f1`,`mysqltest1`.`t1`.`f1`) >= ('1',(/* select#2 */ select 1 from `mysqltest1`.`t1` where (`t1`.`f1` > 1234)))) +CREATE TABLE t3 (pk INT PRIMARY KEY); +INSERT INTO t3 SELECT DISTINCT * FROM t1; +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t3 WHERE pk=(SELECT f1 FROM t1 limit 1)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + }, + "table": { + "table_name": "t3", + "access_type": "const", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "pk" + ] + }, + "optimized_away_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 17, + "rows_produced_per_join": 17, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.70", + "prefix_cost": "1.95", + "data_read_per_join": "136" + }, + "used_columns": [ + "f1" + ] + } + } + } + ] + } +} +# Check access rights checking +CREATE USER 'privtest'@'localhost'; +GRANT SUPER ON *.* TO 'privtest'@'localhost'; +Warnings: +Warning 1287 The SUPER privilege identifier is deprecated +GRANT SELECT ON mysqltest1.t2 TO 'privtest'@'localhost'; +CREATE VIEW v2 AS SELECT * FROM t2; +GRANT SELECT,INSERT,UPDATE ON mysqltest1.v2 TO 'privtest'@'localhost'; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT f1 FROM t1' +ERROR 28000: Access denied for user 'privtest'@'localhost' (using password: NO) +SELECT f2 FROM v2; +f2 +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT f2 FROM v2' +ERROR 28000: Access denied for user 'privtest'@'localhost' (using password: NO) +UPDATE v2 SET f2=1; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'UPDATE v2 SET f2=1' +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +INSERT INTO v2 VALUES(1); +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO v2 VALUES(1)' +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +INSERT INTO v2 SELECT 3 FROM t2; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO v2 SELECT 3 FROM t2' +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +SELECT f2 FROM v2; +f2 +1 +1 +3 +3 +3 +3 +3 +3 +EXPLAIN SELECT f2 FROM v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +DROP USER 'privtest'@localhost; +DROP VIEW v1, v2; +DROP TABLE t1, t2, t3; +# +# Bug#14586538: EXPLAIN OTHER RESULT NOT MATCHING WITH EXPLAIN +# +CREATE TABLE h2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into h2 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +ANALYZE TABLE h2; +Table Op Msg_type Msg_text +mysqltest1.h2 analyze status OK +CREATE TABLE aa3 ( +col_int_key int(11) DEFAULT NULL, +KEY col_int_key (col_int_key) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT alias1.pk AS field1 FROM h2 AS alias1 LEFT JOIN aa3 AS alias2 ON alias1.pk = alias2.col_int_key WHERE alias1.pk <> 9 GROUP BY field1 ORDER BY field1 LIMIT 1 OFFSET 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +2 SIMPLE alias2 NULL ref col_int_key col_int_key 5 mysqltest1.alias1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`alias1`.`pk` AS `field1` from `mysqltest1`.`h2` `alias1` left join `mysqltest1`.`aa3` `alias2` on((`mysqltest1`.`alias2`.`col_int_key` = `mysqltest1`.`alias1`.`pk`)) where (`mysqltest1`.`alias1`.`pk` <> 9) group by `field1` order by `field1` limit 3,1 +Should show same # of rows as above +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT alias1.pk AS field1 FROM h2 AS alias1 LEFT JOIN aa3 AS alias2 ON alias1.pk = alias2.col_int_key WHERE alias1.pk <> 9 GROUP BY field1 ORDER BY field1 LIMIT 1 OFFSET 3' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (4 workers) +2 SIMPLE alias1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +2 SIMPLE alias2 NULL ref col_int_key col_int_key 5 mysqltest1.alias1.pk 1 100.00 Using index +DROP TABLE h2, aa3; +# +# Bug#14591376: EXPLAIN OTHER RESULT NOT MATCHING WITH EXPLAIN - REF +# +CREATE TABLE t1 ( +pk int(11), +col_int_key int(11) DEFAULT NULL, +KEY col_int_key (col_int_key) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (8,-1131610112); +INSERT INTO t1 VALUES (2,-1009057792); +INSERT INTO t1 VALUES (-1220345856,1); +INSERT INTO t1 VALUES (NULL,-185204736); +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT pk FROM t1 WHERE col_int_key= 8' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 const 1 100.00 NULL +DROP TABLE t1; +# From Bug#14463247 MYSQL CRASHES ON THE QUERY +# +CREATE TABLE tbl1 ( +login int(11) NOT NULL, +numb decimal(15,2) NOT NULL DEFAULT '0.00', +PRIMARY KEY (login), +KEY numb (numb) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE tbl2 ( +login int(11) NOT NULL, +cmd tinyint(4) NOT NULL, +nump decimal(15,2) NOT NULL DEFAULT '0.00', +KEY cmd (cmd), +KEY login (login) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into tbl1 (login) values(1),(2); +insert ignore into tbl2 (login) values(1),(2); +Warnings: +Warning 1364 Field 'cmd' doesn't have a default value +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT +t1.login AS tlogin, +numb - +IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) - +IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) as sp +FROM tbl1 t1, tbl2 t2 +WHERE t1.login=t2.login +GROUP BY t1.login +ORDER BY numb - IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) +- IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) +' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index PRIMARY,numb PRIMARY 4 NULL 2 100.00 Using temporary; Using filesort +1 PRIMARY t2 NULL ref login login 4 mysqltest1.t1.login 1 100.00 Using index +3 DEPENDENT SUBQUERY tbl2 NULL ref login login 4 func 1 100.00 NULL +2 DEPENDENT SUBQUERY tbl2 NULL ref login login 4 func 1 100.00 NULL +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT +t1.login AS tlogin, +numb - +IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) - +IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) as sp +FROM tbl1 t1, tbl2 t2 +WHERE t1.login=t2.login +GROUP BY t1.login +ORDER BY numb - IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) +- IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) +' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY", + "numb" + ], + "key": "PRIMARY", + "used_key_parts": [ + "login" + ], + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "login", + "numb" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "login" + ], + "key": "login", + "used_key_parts": [ + "login" + ], + "key_length": "4", + "ref": [ + "mysqltest1.t1.login" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.15", + "data_read_per_join": "32" + }, + "used_columns": [ + "login" + ] + } + } + ], + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "tbl2", + "access_type": "ref", + "possible_keys": [ + "login" + ], + "key": "login", + "used_key_parts": [ + "login" + ], + "key_length": "4", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "login", + "nump" + ] + } + } + }, + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "tbl2", + "access_type": "ref", + "possible_keys": [ + "login" + ], + "key": "login", + "used_key_parts": [ + "login" + ], + "key_length": "4", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "login", + "nump" + ] + } + } + } + ] + } + } + } +} +DROP TABLE tbl1, tbl2; +# End of tests for WL#6369 +# +# Bug#19822146 EXPLAIN FOR CONNECTION CRASHES IN +# EXPLAIN_JOIN::EXPLAIN_QEP_TAB +# +create table t1(a char(10) charset latin1, key(a)) engine=innodb; +create table t2(a binary(10), key(a)) engine=innodb; +insert into t1 values('1'),('2'),('3'),('4'); +insert into t2 values('1'),('2'),('s'); +analyze table t1,t2; +Table Op Msg_type Msg_text +mysqltest1.t1 analyze status OK +mysqltest1.t2 analyze status OK +# Connection cq +# Let thread1 to suspend itself right before creating Quick object. +SET DEBUG_SYNC= 'quick_not_created SIGNAL ready_for_explain WAIT_FOR explained'; +select 1 from t1 inner join t2 using(a); ; +# Connection ce +SET DEBUG_SYNC= 'now WAIT_FOR ready_for_explain'; +SET DEBUG_SYNC= 'after_explain_other SIGNAL explained'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 11 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL a NULL NULL NULL 4 100.00 Range checked for each record (index map: 0x1) +connection: cq +1 +SET DEBUG_SYNC= 'RESET'; +# Connection cq +# Let thread1 to suspend itself right before the mutex section. +SET DEBUG_SYNC= 'quick_created_before_mutex SIGNAL ready_for_explain WAIT_FOR explained'; +select 1 from t1 inner join t2 using(a);; +# Connection ce +SET DEBUG_SYNC= 'now WAIT_FOR ready_for_explain'; +SET DEBUG_SYNC= 'after_explain_other SIGNAL explained'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 11 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL a NULL NULL NULL 4 100.00 Range checked for each record (index map: 0x1) +connection: cq +1 +SET DEBUG_SYNC= 'RESET'; +# Connection cq +# Let thread1 to suspend itself right after quick object is droped. +SET DEBUG_SYNC= 'quick_droped_after_mutex SIGNAL ready_for_explain WAIT_FOR explained'; +select 1 from t1 inner join t2 using(a);; +# Connection ce +SET DEBUG_SYNC= 'now WAIT_FOR ready_for_explain'; +SET DEBUG_SYNC= 'after_explain_other SIGNAL explained'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 11 NULL 3 100.00 Using index +1 SIMPLE t1 NULL range a a 11 NULL 4 100.00 Range checked for each record (index map: 0x1) +connection: cq +1 +# Connection default +DROP TABLE t1, t2; +# End of test Bug#19822146 +# +# Bug#25422034 CRASH IN TABLE_LIST::QUERY_BLOCK_ID_FOR_EXPLAIN DURING EXPLAIN FOR CONNECTION +# +create table t1(a int); +insert into t1 values(1),(2); +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'select * from (select * from t1) dt' +ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE +DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; +USE test; +DROP DATABASE mysqltest1; +# End of test diff --git a/mysql-test/r/explain_tree.result-pq b/mysql-test/r/explain_tree.result-pq new file mode 100644 index 000000000..8e8f8d6a1 --- /dev/null +++ b/mysql-test/r/explain_tree.result-pq @@ -0,0 +1,861 @@ +set optimizer_switch='batched_key_access=off,block_nested_loop=off,mrr_cost_based=off'; +CREATE TABLE t1 ( f1 INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1; +EXPLAIN +-> Parallel scan on + -> PQblock scan on t1 (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f1 INT ); +EXPLAIN FORMAT=tree INSERT INTO t2 SELECT * FROM t1; +EXPLAIN +-> Insert into t2 + -> Table scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f2 INT ); +EXPLAIN FORMAT=tree UPDATE t1, t2 SET f1=f1+2, f2=f2+1 WHERE f1 = f2; +EXPLAIN +-> Update t1 (buffered), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.f2 = t1.f1) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f2 INT ); +EXPLAIN FORMAT=tree DELETE t1, t2 FROM t1, t2; +EXPLAIN +-> Delete from t1 (immediate), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT f1, (SELECT MIN(f1) FROM t1 i WHERE i.f1 > t1.f1) < 3 FROM t1; +EXPLAIN +-> Table scan on t1 (cost=0.55 rows=3) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: min(i.f1) + -> Filter: (i.f1 > t1.f1) (cost=0.35 rows=1) + -> Table scan on i (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 ORDER BY f1 DESC; +EXPLAIN +-> Parallel scan on + -> PQblock scan on t1 using PRIMARY (reverse) (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT, INDEX ( f1 ) ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT SUM(f1) FROM t1; +EXPLAIN +-> Aggregate: sum(`SUM(f1)`) + -> Parallel scan on + -> Aggregate: + -> PQblock scan on t1 using f1 (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT f1 FROM t1 GROUP BY f1; +EXPLAIN +-> Group (no aggregates) + -> Parallel scan on + -> Group (no aggregates) + -> PQblock scan on t1 using f1 (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT f1,COUNT(*) FROM t1 GROUP BY f1; +EXPLAIN +-> Group aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Group (no aggregates) + -> PQblock scan on t1 using f1 (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT f1,COUNT(*) FROM t1 GROUP BY f1 WITH ROLLUP; +EXPLAIN +-> Group aggregate with rollup: count(0) + -> Index scan on t1 using f1 (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1=2; +EXPLAIN +-> Rows fetched before execution (cost=0.00..0.00 rows=1) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +CREATE TABLE t2 ( f1 INT PRIMARY KEY ); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.f1 = t2.f1 + 2 AND t2.f1 = 3; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=1.10 rows=3) + -> PQblock scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Filter: (t1.f1 = ((3 + 2))) (cost=0.12..0.12 rows=1) + -> Constant row from t2 (cost=0.12..0.12 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t1.f1=2; +EXPLAIN +-> Nested loop left join (cost=0.55 rows=3) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + -> Filter: (t2.f1 = 2) (cost=0.55 rows=3) + -> Table scan on t2 (cost=0.55 rows=3) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT, b INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t2 VALUES ( 3 ); +INSERT INTO t3 VALUES ( 2, 0 ); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 USING (a) ) ON t3.b IS NULL; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Filter: (t3.b is null) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t3.a = t2.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t2.f1 IS NULL; +EXPLAIN +-> Parallel scan on + -> Filter: (t2.f1 is null) (cost=2.80 rows=3) + -> Nested loop antijoin (cost=2.80 rows=3) + -> PQblock scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Filter: (t2.f1 = t1.f1) (cost=0.48 rows=1) + -> Table scan on t2 (cost=0.48 rows=3) + +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +FLUSH STATUS; +EXPLAIN FORMAT=tree SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +EXPLAIN +-> Table scan on (cost=1.26..2.51 rows=2) + -> Temporary table with deduplication (cost=3.51..4.76 rows=2) + -> Nested loop inner join (cost=2.05 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Limit: 1 row(s) (cost=0.58 rows=1) + -> Filter: (t2.c <= 3) (cost=0.58 rows=2) + -> Index lookup on t2 using a (a=t1.a) (cost=0.58 rows=5) + +DROP TABLE t1, t2; +CREATE TABLE t1 ( f1 INT ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 ORDER BY f1 DESC; +EXPLAIN +-> Parallel scan on + -> Sort: t1.f1 DESC (cost=0.55 rows=3) + -> PQblock scan on t1 + +DROP TABLE t1; +CREATE TABLE t1 ( a LONGBLOB, b INT ); +INSERT INTO t1 VALUES ('a', 0); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT 0 AS foo FROM t1 WHERE 0 = (SELECT group_concat(b) FROM t1 t GROUP BY t1.a) ; +EXPLAIN +-> Filter: (0 = (select #2)) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Select #2 (subquery in condition; dependent) + -> Group aggregate: group_concat(t1.b separator ',') + -> Sort row IDs: t1.a + -> Table scan on (cost=2.51..2.51 rows=1) + -> Temporary table (cost=2.96..2.96 rows=1) + -> Table scan on t (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +EXPLAIN +-> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 VARCHAR(100) ); +INSERT INTO t1 VALUES ('abc'); +INSERT INTO t1 VALUES ('abc'); +INSERT INTO t1 VALUES ('def'); +INSERT INTO t1 VALUES ('def'); +INSERT INTO t1 VALUES ('ghi'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT DISTINCT f1 FROM t1 LIMIT 2; +EXPLAIN +-> Limit: 2 row(s) (cost=1.76..2.28 rows=2) + -> Table scan on (cost=0.51..2.56 rows=5) + -> Temporary table with deduplication (cost=1.76..3.81 rows=5) + -> Limit table size: 2 unique row(s) + -> Table scan on t1 (cost=0.75 rows=5) + +DROP TABLE t1; +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 values (1), (2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1; +EXPLAIN +-> Insert into t1 + -> Limit: 1 row(s) (cost=1.91..1.91 rows=1) + -> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table (cost=1.91..3.17 rows=2) + -> Limit table size: 1 row(s) + -> Index scan on t1 using PRIMARY (cost=0.45 rows=2) + +DROP TABLE t1; +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 VALUES (1,3), (2,4), (1,5), +(1,3), (2,1), (1,5), (1,7), (3,1), +(3,2), (3,1), (2,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT DISTINCT (COUNT(DISTINCT b) + 1) AS c FROM t1 GROUP BY a; +EXPLAIN +-> Table scan on (cost=2.50..2.50 rows=0) + -> Temporary table with deduplication (cost=5.00..5.00 rows=0) + -> Table scan on (cost=2.50..2.50 rows=0) + -> Temporary table (cost=2.50..2.50 rows=0) + -> Group aggregate: count(distinct t1.b) + -> Sort: t1.a (cost=1.35 rows=11) + -> Table scan on t1 (cost=1.35 rows=11) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1 = ( SELECT MIN(f1) FROM t1 AS i WHERE i.f1 > t1.f1 ); +EXPLAIN +-> Filter: (t1.f1 = (select #2)) (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Select #2 (subquery in condition; dependent) + -> Aggregate: min(i.f1) + -> Filter: (i.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on i (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1 > ( SELECT f1 FROM t1 LIMIT 1 ); +EXPLAIN +-> Filter: (t1.f1 > (select #2)) (cost=0.55 rows=2) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Select #2 (subquery in condition; run only once) + -> Limit: 1 row(s) (cost=0.55 rows=1) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE f1 = ( SELECT ( SELECT MIN(f1) FROM t1 AS ii WHERE ii.f1 > t1.f1 ) > i.f1 FROM t1 AS i ) ; +EXPLAIN +-> Filter: (t1.f1 = (select #2)) (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Select #2 (subquery in condition; dependent) + -> Index scan on i using PRIMARY (cost=0.55 rows=3) + -> Select #3 (subquery in projection; dependent) + -> Aggregate: min(ii.f1) + -> Filter: (ii.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on ii (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #3 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT ( SELECT ( SELECT ( SELECT MIN(f1) FROM t1 i WHERE i.f1 > t1.f1 ) + 1 ) + 1 ) FROM t1; +EXPLAIN +-> Index scan on t1 using PRIMARY (cost=0.55 rows=3) +-> Select #4 (subquery in projection; dependent) + -> Aggregate: min(i.f1) + -> Filter: (i.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on i (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #4 was resolved in SELECT #1 +Note 1249 Select 3 was reduced during optimization +Note 1249 Select 2 was reduced during optimization +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT ( SELECT f1 FROM t1 AS inner_t1 WHERE inner_t1.f1 > t1.f1 LIMIT 1 ) AS tmp1 FROM t1 ORDER BY tmp1; +EXPLAIN +-> Sort: tmp1 + -> Stream results (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) +-> Select #2 (subquery in projection; dependent) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (inner_t1.f1 > t1.f1) (cost=0.35 rows=1) + -> Index range scan on inner_t1 (re-planned for each iteration) (cost=0.35 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 VALUES (1,3), (2,4), (1,5), +(1,3), (2,1), (1,5), (1,7), (3,1), +(3,2), (3,1), (2,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE a > 3 ORDER BY b; +EXPLAIN +-> Parallel scan on + -> Sort: t1.b (cost=1.35 rows=11) + -> Filter: (t1.a > 3) + -> PQblock scan on t1 + +DROP TABLE t1; +CREATE TABLE t1 (i INT); +EXPLAIN INSERT INTO t1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +EXPLAIN FORMAT=tree INSERT INTO t1 VALUES (10); +EXPLAIN + + +DROP TABLE t1; +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 VALUES (1,3), (2,4), (1,5), +(1,3), (2,1), (1,5), (1,7), (3,1), +(3,2), (3,1), (2,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 ORDER BY b LIMIT 3; +EXPLAIN +-> Limit: 3 row(s) + -> Parallel scan on + -> Limit: 3 row(s) (cost=1.35 rows=3) + -> Sort: t1.b, limit input to 3 row(s) per chunk (cost=1.35 rows=11) + -> PQblock scan on t1 + +DROP TABLE t1; +CREATE TABLE t1 ( a INTEGER ); +CREATE TABLE t2 ( a INTEGER ); +CREATE TABLE t3 ( a INTEGER ); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING ( a ), +LATERAL ( SELECT * FROM t3 WHERE t3.a = t2.a LIMIT 1 ) t3d, +LATERAL ( SELECT * FROM t3 WHERE t3.a > t1.a LIMIT 1 ) t4d; +EXPLAIN +-> Nested loop inner join (cost=9.30 rows=1) + -> Nested loop inner join (cost=3.87 rows=1) + -> Invalidate materialized tables (row from t2) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Invalidate materialized tables (row from t1) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.a = t1.a) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Table scan on t3d (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t2) (cost=2.96..2.96 rows=1) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t3.a = t2.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Table scan on t4d (cost=2.51..2.51 rows=1) + -> Materialize (invalidate on row from t1) (cost=2.96..2.96 rows=1) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t3.a > t1.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( a INTEGER ); +CREATE TABLE t2 ( a INTEGER ); +CREATE TABLE t3 ( a INTEGER ); +CREATE TABLE t4 ( a INTEGER ); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN ( +t2 LEFT JOIN t3 USING ( a ) CROSS JOIN +LATERAL ( SELECT * FROM t4 WHERE t4.a = t3.a LIMIT 1 ) t4d +) ON t1.a = t4d.a; +EXPLAIN +-> Nested loop left join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Nested loop inner join (cost=1.85 rows=1) + -> Invalidate materialized tables (row from t3) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t3.a = t2.a) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Index lookup on t4d using (a=t1.a) + -> Materialize (invalidate on row from t3) (cost=0.45..0.45 rows=1) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t4.a = t3.a) (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t3.a' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 ( f1 INTEGER ); +EXPLAIN FORMAT=TREE SELECT * FROM ( SELECT * FROM t1 LIMIT 2 OFFSET 1 ) AS alias1 +WHERE f1 <= ANY ( SELECT f1 FROM t1 ) ORDER BY f1; +EXPLAIN +-> Sort: alias1.f1 + -> Filter: ((alias1.f1 <= (select #3))) (cost=2.62 rows=2) [other sub-iterators not shown] + -> Table scan on alias1 (cost=2.62 rows=2) + -> Materialize (cost=0.35..0.35 rows=0) + -> Limit/Offset: 2/1 row(s) (cost=0.35 rows=0) + -> Table scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1; +CREATE TABLE t1 ( f1 INT ); +CREATE TABLE t2 ( f1 INT ); +EXPLAIN format=tree WITH my_cte AS ( SELECT * FROM t1 LIMIT 3 ) SELECT * FROM my_cte, t2; +EXPLAIN +-> Nested loop inner join (cost=2.98 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Table scan on my_cte (cost=2.51..2.51 rows=1) + -> Materialize CTE my_cte (cost=2.96..2.96 rows=1) + -> Limit: 3 row(s) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.i = t1.i) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER); +CREATE TABLE t3 (i INTEGER); +CREATE TABLE t4 (i INTEGER); +INSERT INTO t1 VALUES (2, 3); +INSERT INTO t2 VALUES (4, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE (t1.i) IN (SELECT t3.i FROM t3,t4) AND t1.pk = 2 AND t2.pk = 4; +EXPLAIN +-> Limit: 1 row(s) (cost=0.70 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.i = '3') (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER, j INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE t1.i IN ( SELECT i FROM t2 LEFT JOIN t3 USING (i) WHERE t3.j = 1234 OR t3.j IS NULL ); +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Filter: ((t3.j = 1234) or (t3.j is null)) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.i = t1.i) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t2.i = t3.i) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off'; +CREATE TABLE t1 ( a INTEGER, b INTEGER ); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT a FROM t1 WHERE a = ANY ( SELECT a FROM t1 WHERE b = 2 ); +EXPLAIN +-> Nested loop inner join (cost=3.71 rows=1) + -> Table scan on (cost=2.51..2.51 rows=1) + -> Materialize with deduplication (cost=3.16..3.16 rows=1) + -> Filter: (t1.a is not null) (cost=0.55 rows=1) + -> Filter: (t1.b = 2) (cost=0.55 rows=1) + -> Table scan on t1 (cost=0.55 rows=3) + -> Filter: (t1.a = ``.a) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=3) + +DROP TABLE t1; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off'; +CREATE TABLE t1 ( a INTEGER NOT NULL, b INTEGER NOT NULL ); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT a FROM t1 WHERE a NOT IN ( SELECT b FROM t1 WHERE b > 2 ); +EXPLAIN +-> Nested loop antijoin (cost=1.75 rows=9) + -> Table scan on t1 (cost=0.55 rows=3) + -> Single-row index lookup on using (b=t1.a) + -> Materialize with deduplication (cost=0.85..0.85 rows=3) + -> Filter: (t1.b is not null) (cost=0.55 rows=3) + -> Filter: (t1.b > 2) (cost=0.55 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +DROP TABLE t1; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off'; +CREATE TABLE t1 ( a INTEGER, b INTEGER ); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT a FROM t1 WHERE a = ANY ( SELECT MAX(a) FROM t1 WHERE b = 2 ); +EXPLAIN +-> Filter: (t1.a,(select #2)) (cost=0.55 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) + -> Filter: ((t1.a) = (max(t1.a))) + -> Aggregate: max(t1.a) + -> Filter: (t1.b = 2) (cost=0.55 rows=1) + -> Table scan on t1 (cost=0.55 rows=3) + +DROP TABLE t1; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off,materialization=off,loosescan=off'; +CREATE TABLE t1 ( i INTEGER ); +CREATE TABLE t2 ( i INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=0.90 rows=1) + -> Nested loop inner join (cost=0.90 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: (t1.i = t2.i) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=3) + +DROP TABLE t1; +DROP TABLE t2; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off,materialization=off,loosescan=off'; +CREATE TABLE t1 ( i INTEGER ); +CREATE TABLE t2 ( i INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2), (3), (4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=2.50 rows=3) + -> PQblock scan on t1 (cost=0.55 rows=3) + -> Limit: 1 row(s) (cost=0.28 rows=1) + -> Filter: (t2.i = t1.i) (cost=0.28 rows=1) + -> Table scan on t2 (cost=0.28 rows=4) + +DROP TABLE t1; +DROP TABLE t2; +set @@optimizer_switch=@old_opt_switch; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='firstmatch=off,materialization=off,duplicateweedout=off,loosescan=on'; +CREATE TABLE t1 ( i INTEGER, PRIMARY KEY (i) ); +CREATE TABLE t2 ( i INTEGER, INDEX i1 (i) ); +INSERT INTO t1 VALUES (2), (3), (4), (5); +INSERT INTO t2 VALUES (1), (2), (3), (4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i FROM t2); +EXPLAIN +-> Nested loop inner join (cost=2.05 rows=4) + -> Remove duplicates from input sorted on i1 (cost=0.65 rows=4) + -> Filter: (t2.i is not null) (cost=0.65 rows=4) + -> Index scan on t2 using i1 (cost=0.65 rows=4) + -> Single-row index lookup on t1 using PRIMARY (i=t2.i) (cost=1.10 rows=1) + +DROP TABLE t1; +DROP TABLE t2; +set @@optimizer_switch=@old_opt_switch; +# +# Bug#29904996 EXPLAIN FORMAT=TREE PRINTS OUT HIDDEN COLUMN NAME INSTEAD +# OF INDEXED EXPRESSION +# +CREATE TABLE t1 ( +col_int_key INTEGER, +col_json JSON, +KEY mv_idx ((CAST(col_json->'$[*]' AS CHAR(40) ARRAY))) +); +CREATE TABLE t2 (col_int INTEGER); +# See that we print the indexed expression, and not the hidden column +# name. +EXPLAIN FORMAT=tree SELECT /*+ NO_BNL(t1, t2) */ * FROM t2 +JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]')); +EXPLAIN +-> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Filter: json'"1"' member of (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)) (cost=0.35 rows=1) + -> Index lookup on t1 using mv_idx (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)=json'"1"') (cost=0.35 rows=1) + +DROP TABLE t1, t2; +CREATE TABLE t1 (a INTEGER, b INTEGER, PRIMARY KEY ( a )); +INSERT INTO t1 VALUES (1,3), (2,4), (3,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN ANALYZE SELECT * FROM t1 AS a JOIN t1 AS b ON a.a=b.b ORDER BY a.b+b.a LIMIT 3; +EXPLAIN +-> Limit: 3 row(s) (cost=0.00..0.00 rows=0) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Table scan on (cost=2.50..2.50 rows=0) (never executed) + -> Temporary table (cost=2.50..2.50 rows=0) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Parallel scan on (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Limit: 3 row(s) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Sort: `(a.b + b.a)`, limit input to 3 row(s) per chunk (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Stream results (cost=1.60 rows=3) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Nested loop inner join (cost=1.60 rows=3) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Filter: (b.b is not null) (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + -> PQblock scan on b (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + -> Single-row index lookup on a using PRIMARY (a=b.b) (cost=0.28 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=3) + +EXPLAIN ANALYZE SELECT * FROM t1 AS a, t1 AS b WHERE a.b=500; +EXPLAIN +-> Parallel scan on (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Nested loop inner join (cost=1.10 rows=3) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Filter: (a.b = 500) (cost=0.55 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> PQblock scan on a (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + -> Table scan on b (cost=0.55 rows=3) (never executed) + +DROP TABLE t1; +EXPLAIN ANALYZE FOR CONNECTION 1; +ERROR 42000: This version of MySQL doesn't yet support 'EXPLAIN ANALYZE FOR CONNECTION' +EXPLAIN ANALYZE FORMAT=TRADITIONAL SELECT 1; +ERROR 42000: This version of MySQL doesn't yet support 'FORMAT=TRADITIONAL with EXPLAIN ANALYZE' +EXPLAIN ANALYZE FORMAT=JSON SELECT 1; +ERROR 42000: This version of MySQL doesn't yet support 'FORMAT=JSON with EXPLAIN ANALYZE' +EXPLAIN ANALYZE FORMAT=TREE SELECT 1; +EXPLAIN +-> Rows fetched before execution (cost=0.00..0.00 rows=1) (actual time=N.NNN..N.NNN rows=1 loops=1) + +EXPLAIN FORMAT=tree SELECT * FROM INFORMATION_SCHEMA.ENGINES; +EXPLAIN +-> Table scan on ENGINES (cost=0.00 rows=0) + -> Fill information schema table ENGINES + +CREATE TABLE t1 ( f1 INT PRIMARY KEY ); +INSERT INTO t1 VALUES (1), (2), (3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, ( SELECT f1 FROM t1 UNION SELECT f1 + 10 FROM t1 ) d1; +EXPLAIN +-> Nested loop inner join (cost=10.08 rows=18) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Table scan on d1 (cost=0.43..2.58 rows=6) + -> Union materialize with deduplication (cost=2.13..4.28 rows=6) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + +EXPLAIN FORMAT=tree SELECT * FROM t1, ( SELECT f1 FROM t1 UNION ALL SELECT f1 + 10 FROM t1 ) d1; +EXPLAIN +-> Nested loop inner join (cost=10.08 rows=18) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Table scan on d1 (cost=0.43..2.58 rows=6) + -> Union materialize (cost=2.13..4.28 rows=6) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Index scan on t1 using PRIMARY (cost=0.55 rows=3) + +DROP TABLE t1; +# +# Bug #30444266: EXPLAIN ANALYZE DOES NOT EXECUTE THE SUBQUERIES IN THE SELECT LIST +# +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN ANALYZE SELECT f1, ( SELECT COUNT(*) FROM t1 AS inner_t1 WHERE inner_t1.f1 < t1.f1 ) FROM t1; +EXPLAIN +-> Table scan on t1 (cost=1.25 rows=10) (actual time=N.NNN..N.NNN rows=10 loops=1) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) (actual time=N.NNN..N.NNN rows=1 loops=10) + -> Filter: (inner_t1.f1 < t1.f1) (cost=0.58 rows=3) (actual time=N.NNN..N.NNN rows=4 loops=10) + -> Table scan on inner_t1 (cost=0.58 rows=10) (actual time=N.NNN..N.NNN rows=10 loops=10) + +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1; +# +# Bug#17978975 EXPLAIN FOR MULTI-TABLE UPDATE/DELETE DOES NOT MENTION TEMPORARY TABLE +# +CREATE TABLE t1(a INT, b INT); +CREATE TABLE t2(a INT, b INT); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=TREE UPDATE t1,t2 SET t1.a=1,t2.b=1; +EXPLAIN +-> Update t1 (immediate), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +EXPLAIN FORMAT=TREE UPDATE t1,t2 SET t1.a=1,t2.b=1 WHERE t2.a=t1.a; +EXPLAIN +-> Update t1 (buffered), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Filter: (t2.a = t1.a) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +EXPLAIN FORMAT=TREE DELETE t1.*,t2.* FROM t1,t2; +EXPLAIN +-> Delete from t1 (immediate), t2 (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +EXPLAIN FORMAT=TREE DELETE t1.*,t1bis.* FROM t1, t1 AS t1bis; +EXPLAIN +-> Delete from t1 (buffered), t1bis (buffered) + -> Nested loop inner join (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Table scan on t1bis (cost=0.35 rows=1) + +DROP TABLE t1,t2; +# +# Bug #30941336: EXPLAIN ANAYLZE SELECT COUNT(*) FROM MYSQL.USER COREDUMP UNDER DEBUG VERSION +# +CREATE TABLE t1 ( a INTEGER ); +EXPLAIN ANALYZE SELECT COUNT(*) FROM t1; +EXPLAIN +-> Count rows in t1 (actual time=N.NNN..N.NNN rows=1 loops=1) + +DROP TABLE t1; +# +# Bug #31559245: REGRESSION: CRASH/ASSERT IN SUBSELECT_HASH_SJ_ENGINE::ROOT_ACCESS_PATH +# +CREATE TABLE t1 (a INTEGER); +EXPLAIN FORMAT=tree SELECT (1 IN (SELECT 1 FROM t1)) WHERE FALSE; +EXPLAIN +-> Zero rows (Impossible WHERE) (cost=0.00..0.00 rows=0) + +DROP TABLE t1; diff --git a/mysql-test/r/filesort.result-pq b/mysql-test/r/filesort.result-pq new file mode 100644 index 000000000..03e048304 --- /dev/null +++ b/mysql-test/r/filesort.result-pq @@ -0,0 +1,153 @@ +# +# Bug#24709595 WL#8741: ASSERTION `SORTORDER->NEED_STRXNFRM == 0' FAILED +# +CREATE TABLE t1( +c VARCHAR(10) CHARACTER SET utf8 DEFAULT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2( +c1 VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL, +c2 VARCHAR(10) CHARACTER SET utf8 DEFAULT NULL +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES('x'); +INSERT INTO t2 VALUES('g','if'), ('not','ojgygqcgqi'); +SELECT * FROM t2 WHERE (c2) <> (SELECT MAX(c) FROM t1 GROUP BY c1); +c1 c2 +g if +not ojgygqcgqi +DROP TABLE t1, t2; +# +# Bug#29660945: SIG 6 AT TEMPTABLE::HANDLER::POSITION | SRC/HANDLER.CC +# +SET optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( +f1 varchar(255), +f2 varchar(255) +); +INSERT INTO t1 VALUES (NULL,'A'); +INSERT INTO t1 VALUES ('A',NULL); +SELECT * FROM t1 AS alias1 JOIN t1 AS alias2 ON alias1.f1=alias2.f2 ORDER BY alias2.f1 LIMIT 50; +f1 f2 f1 f2 +A NULL NULL A +DROP TABLE t1; +SET optimizer_switch=DEFAULT; +SET sort_buffer_size=32768; +CREATE TABLE t1 ( +f1 INTEGER, +f2 LONGBLOB +); +INSERT INTO t1 VALUES ( 2, REPEAT('-', 1048576) ); +INSERT INTO t1 VALUES ( 1, REPEAT('x', 1048576) ); +SELECT * FROM t1 ORDER BY f1; +f1 f2 +1 x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024}x{1024} +2 -{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024}-{1024} +DROP TABLE t1; +SET sort_buffer_size=DEFAULT; +# +# Bug #30687020: ORDER BY DOES NOT WORK FOR A COLUMN WITH A STRING FUNCTION AND UTF8MB4_0900_AI_C +# +CREATE TABLE t1 ( f1 VARCHAR(100) ); +INSERT INTO t1 VALUES (''), (NULL), (''), (NULL); +SELECT CONCAT(f1, '') AS dummy FROM t1 ORDER BY dummy; +dummy +NULL +NULL + + +DROP TABLE t1; +# +# Bug #30791074: WEIGHT_STRING: ASSERTION `0' FAILED. IN TIME_ZONE_UTC::TIME_TO_GMT_SEC +# +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (0), (1), (101); +SELECT * FROM t1 ORDER BY UNIX_TIMESTAMP(f1); +f1 +0 +1 +101 +Warnings: +Warning 1292 Incorrect datetime value: '1' +Warning 1292 Incorrect datetime value: '1' +DROP TABLE t1; +# +# Bug #31397840: Wrong result of SELECT DISTINCT JSON_ARRAYAGG +# +SET sql_mode=''; +CREATE TABLE t1 +( +id INT PRIMARY KEY, +char_field CHAR(10) +); +INSERT INTO t1 VALUES (580801, '580801'); +INSERT INTO t1 VALUES (580901, '580901'); +INSERT INTO t1 VALUES (581001, '581001'); +INSERT INTO t1 VALUES (581101, '581101'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT DISTINCT JSON_ARRAYAGG(char_field), JSON_ARRAYAGG(2) FROM t1 GROUP BY id ORDER BY id; +JSON_ARRAYAGG(char_field) JSON_ARRAYAGG(2) +["580801"] [2] +["580901"] [2] +["581001"] [2] +["581101"] [2] +Warnings: +Warning 1235 This version of MySQL doesn't yet support 'sorting of non-scalar JSON values' +EXPLAIN FORMAT=tree SELECT DISTINCT JSON_ARRAYAGG(char_field), JSON_ARRAYAGG(2) FROM t1 GROUP BY id ORDER BY id; +EXPLAIN +-> Sort: t1.id + -> Sort with duplicate removal: `JSON_ARRAYAGG(char_field)`, `JSON_ARRAYAGG(2)` + -> Stream results + -> Group aggregate: json_arrayagg(t1.char_field), json_arrayagg(2) + -> Sort: t1.id + -> Table scan on t1 + +DROP TABLE t1; +SET sql_mode=DEFAULT; +# +# Bug #31588831: ASSERTION FAILURE IN NEWWEEDOUTACCESSPATHFORTABLES() AT SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 (pk INTEGER, f2 INTEGER, PRIMARY KEY (pk)); +CREATE TABLE t2 (pk INTEGER, f2 INTEGER, PRIMARY KEY (pk)); +INSERT INTO t1 VALUES (1,1), (2,2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM +t1 +LEFT JOIN t1 AS table2 ON 119 IN ( +SELECT SUBQUERY1_t2.pk +FROM t1 AS SUBQUERY1_t1, (t2 AS SUBQUERY1_t2 STRAIGHT_JOIN t1 ON TRUE) +) +ORDER BY t1.f2; +EXPLAIN +-> Parallel scan on + -> Remove duplicate (t1, table2) rows using temporary table (weedout) + -> Nested loop left join + -> Sort row IDs: t1.f2 + -> PQblock scan on t1 + -> Nested loop inner join + -> Nested loop inner join + -> Nested loop inner join + -> Constant row from SUBQUERY1_t2 (cost=0.17..0.17 rows=1) + -> Table scan on table2 + -> Index scan on SUBQUERY1_t1 using PRIMARY + -> Index scan on t1 using PRIMARY + +DROP TABLE t1, t2; +# +# Bug #32169770: HYPERGRAPH: ASSERTION `M_PART_INFO->IS_PARTITION_USED(M_LAST_PART)' FAILED. +# +CREATE TABLE t1 (a LONGTEXT); +INSERT INTO t1 VALUES ('a'); +CREATE TABLE t2 (a INTEGER PRIMARY KEY) PARTITION BY key() PARTITIONS 2; +SELECT 1 AS a FROM t1 LEFT JOIN t2 ON FALSE GROUP BY a; +a +1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/filesort_pack.result-pq b/mysql-test/r/filesort_pack.result-pq new file mode 100644 index 000000000..13668ef9e --- /dev/null +++ b/mysql-test/r/filesort_pack.result-pq @@ -0,0 +1,31 @@ +CREATE TABLE t1 ( +id int(10) unsigned NOT NULL auto_increment, +k int(10) unsigned NOT NULL default '0', +c char(120) NOT NULL default '', +pad char(60) NOT NULL default '', +PRIMARY KEY (id), +KEY k (k) +) charset latin1 engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET @@session.sort_buffer_size=32768; +FLUSH STATUS; +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 0 +Sort_scan 0 +SELECT c FROM t1 WHERE id between 2 and 1002 ORDER BY c; +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 139 +Sort_scan 3 +SET @@session.sort_buffer_size=DEFAULT; +DROP TABLE t1; diff --git a/mysql-test/r/filter_single_col_idx_small.result-pq b/mysql-test/r/filter_single_col_idx_small.result-pq new file mode 100644 index 000000000..b4ef167bb --- /dev/null +++ b/mysql-test/r/filter_single_col_idx_small.result-pq @@ -0,0 +1,148 @@ +# +# Test that on a tiny table, the computed filtering effect is not +# less than one row for the basic condition filter constants +# +CREATE TABLE t1( +col1_pk INTEGER PRIMARY KEY, +col2 INTEGER +); +INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7); +# Filtered column should be 1 / (size of table) and larger than +# COND_FILTER_EQUALITY +EXPLAIN SELECT * FROM t1 WHERE col2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` = 2) +# Filtered column should be (size of table - 1) / (size of table) +# and less than COND_FILTER_EQUALITY +EXPLAIN SELECT * FROM t1 WHERE col2 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` <> 2) +# Filtered column should be 1 / (size of table) and larger than +# COND_FILTER_BETWEEN +EXPLAIN SELECT * FROM t1 WHERE col2 BETWEEN 2 AND 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` between 2 and 4) +# Filtered column should be (size of table - 1) / (size of table) +# and less than COND_FILTER_BETWEEN +EXPLAIN SELECT * FROM t1 WHERE col2 NOT BETWEEN 2 AND 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 87.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 87.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` not between 2 and 4) +TRUNCATE TABLE t1; +INSERT INTO t1 VALUES (0,0),(1,1); +# Filtered column should be 1 / (size of table) and larger than +# COND_FILTER_INEQUALITY +EXPLAIN SELECT * FROM t1 WHERE col2 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1_pk` AS `col1_pk`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` > 1) +DROP TABLE t1; +# +# Bug#18438671: MAKE USE OF DATATYPE CONSTRAINTS WHEN CALCULATING +# FILTERING EFFECT +# +CREATE TABLE t1( +day_of_week enum('0','1','2','3','4','5','6'), +bit1 bit(1), +bit3 bit(3) +); +INSERT INTO t1 VALUES (1+RAND()*7, RAND()*2, RAND()*8), +(1+RAND()*7, RAND()*2, RAND()*8); +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +INSERT INTO t1 SELECT 1+RAND()*7, RAND()*2, RAND()*8 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE bit1 = b'1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` = 0x01) +EXPLAIN SELECT * FROM t1 WHERE bit1 <=>b'1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` <=> 0x01) +EXPLAIN SELECT * FROM t1 WHERE bit1 > b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` > 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit1 >= b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` >= 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit1 < b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` < 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit1 <= b'0'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit1` <= 0x00) +EXPLAIN SELECT * FROM t1 WHERE bit3 = b'1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 12.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`bit3` = 0x01) +EXPLAIN SELECT * FROM t1 WHERE day_of_week; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 85.71 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (0 <> `test`.`t1`.`day_of_week`) +EXPLAIN SELECT * FROM t1 WHERE day_of_week = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 14.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` = 1) +EXPLAIN SELECT * FROM t1 WHERE day_of_week IN (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 14.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` = 1) +EXPLAIN SELECT * FROM t1 WHERE day_of_week IN (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 28.57 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 28.57 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE day_of_week LIKE 'foo'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 14.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` like 'foo') +EXPLAIN SELECT * FROM t1 WHERE NOT day_of_week = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 85.71 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 85.71 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`day_of_week` AS `day_of_week`,`test`.`t1`.`bit1` AS `bit1`,`test`.`t1`.`bit3` AS `bit3` from `test`.`t1` where (`test`.`t1`.`day_of_week` <> 1) +DROP TABLE t1; diff --git a/mysql-test/r/func_comparison.result-pq b/mysql-test/r/func_comparison.result-pq new file mode 100644 index 000000000..f33295ab4 --- /dev/null +++ b/mysql-test/r/func_comparison.result-pq @@ -0,0 +1,18145 @@ +CREATE TABLE t1 +(pk INTEGER PRIMARY KEY, +i1 TINYINT, +u1 TINYINT UNSIGNED, +i2 SMALLINT, +u2 SMALLINT UNSIGNED, +i3 MEDIUMINT, +u3 MEDIUMINT UNSIGNED, +i4 INTEGER, +u4 INTEGER UNSIGNED, +i8 BIGINT, +u8 BIGINT UNSIGNED); +INSERT INTO t1 VALUES +(0, -128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0), +(1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0), +(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), +(3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), +(4, 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, +9223372036854775807, 18446744073709551615); +set @iv= -9223372036854775809; +set @dv= -9223372036854775809.0; +set @fv= -9223372036854775809.0e0; +set @sv= "-9223372036854775809"; +SELECT i1 = -9223372036854775809 AS a, +u1 = -9223372036854775809 AS au, +i2 = -9223372036854775809 AS b, +u2 = -9223372036854775809 AS bu, +i3 = -9223372036854775809 AS c, +u3 = -9223372036854775809 AS cu, +i4 = -9223372036854775809 AS d, +u4 = -9223372036854775809 AS du, +i8 = -9223372036854775809 AS e, +u8 = -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775809.0 AS a, +u1 = -9223372036854775809.0 AS au, +i2 = -9223372036854775809.0 AS b, +u2 = -9223372036854775809.0 AS bu, +i3 = -9223372036854775809.0 AS c, +u3 = -9223372036854775809.0 AS cu, +i4 = -9223372036854775809.0 AS d, +u4 = -9223372036854775809.0 AS du, +i8 = -9223372036854775809.0 AS e, +u8 = -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775809.0e0 AS a, +u1 = -9223372036854775809.0e0 AS au, +i2 = -9223372036854775809.0e0 AS b, +u2 = -9223372036854775809.0e0 AS bu, +i3 = -9223372036854775809.0e0 AS c, +u3 = -9223372036854775809.0e0 AS cu, +i4 = -9223372036854775809.0e0 AS d, +u4 = -9223372036854775809.0e0 AS du, +i8 = -9223372036854775809.0e0 AS e, +u8 = -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-9223372036854775809' AS a, +u1 = '-9223372036854775809' AS au, +i2 = '-9223372036854775809' AS b, +u2 = '-9223372036854775809' AS bu, +i3 = '-9223372036854775809' AS c, +u3 = '-9223372036854775809' AS cu, +i4 = '-9223372036854775809' AS d, +u4 = '-9223372036854775809' AS du, +i8 = '-9223372036854775809' AS e, +u8 = '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -9223372036854775809 AS a, +u1 <> -9223372036854775809 AS au, +i2 <> -9223372036854775809 AS b, +u2 <> -9223372036854775809 AS bu, +i3 <> -9223372036854775809 AS c, +u3 <> -9223372036854775809 AS cu, +i4 <> -9223372036854775809 AS d, +u4 <> -9223372036854775809 AS du, +i8 <> -9223372036854775809 AS e, +u8 <> -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775809.0 AS a, +u1 <> -9223372036854775809.0 AS au, +i2 <> -9223372036854775809.0 AS b, +u2 <> -9223372036854775809.0 AS bu, +i3 <> -9223372036854775809.0 AS c, +u3 <> -9223372036854775809.0 AS cu, +i4 <> -9223372036854775809.0 AS d, +u4 <> -9223372036854775809.0 AS du, +i8 <> -9223372036854775809.0 AS e, +u8 <> -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775809.0e0 AS a, +u1 <> -9223372036854775809.0e0 AS au, +i2 <> -9223372036854775809.0e0 AS b, +u2 <> -9223372036854775809.0e0 AS bu, +i3 <> -9223372036854775809.0e0 AS c, +u3 <> -9223372036854775809.0e0 AS cu, +i4 <> -9223372036854775809.0e0 AS d, +u4 <> -9223372036854775809.0e0 AS du, +i8 <> -9223372036854775809.0e0 AS e, +u8 <> -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-9223372036854775809' AS a, +u1 <> '-9223372036854775809' AS au, +i2 <> '-9223372036854775809' AS b, +u2 <> '-9223372036854775809' AS bu, +i3 <> '-9223372036854775809' AS c, +u3 <> '-9223372036854775809' AS cu, +i4 <> '-9223372036854775809' AS d, +u4 <> '-9223372036854775809' AS du, +i8 <> '-9223372036854775809' AS e, +u8 <> '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -9223372036854775809 AS a, +u1 < -9223372036854775809 AS au, +i2 < -9223372036854775809 AS b, +u2 < -9223372036854775809 AS bu, +i3 < -9223372036854775809 AS c, +u3 < -9223372036854775809 AS cu, +i4 < -9223372036854775809 AS d, +u4 < -9223372036854775809 AS du, +i8 < -9223372036854775809 AS e, +u8 < -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775809.0 AS a, +u1 < -9223372036854775809.0 AS au, +i2 < -9223372036854775809.0 AS b, +u2 < -9223372036854775809.0 AS bu, +i3 < -9223372036854775809.0 AS c, +u3 < -9223372036854775809.0 AS cu, +i4 < -9223372036854775809.0 AS d, +u4 < -9223372036854775809.0 AS du, +i8 < -9223372036854775809.0 AS e, +u8 < -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775809.0e0 AS a, +u1 < -9223372036854775809.0e0 AS au, +i2 < -9223372036854775809.0e0 AS b, +u2 < -9223372036854775809.0e0 AS bu, +i3 < -9223372036854775809.0e0 AS c, +u3 < -9223372036854775809.0e0 AS cu, +i4 < -9223372036854775809.0e0 AS d, +u4 < -9223372036854775809.0e0 AS du, +i8 < -9223372036854775809.0e0 AS e, +u8 < -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-9223372036854775809' AS a, +u1 < '-9223372036854775809' AS au, +i2 < '-9223372036854775809' AS b, +u2 < '-9223372036854775809' AS bu, +i3 < '-9223372036854775809' AS c, +u3 < '-9223372036854775809' AS cu, +i4 < '-9223372036854775809' AS d, +u4 < '-9223372036854775809' AS du, +i8 < '-9223372036854775809' AS e, +u8 < '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -9223372036854775809 AS a, +u1 >= -9223372036854775809 AS au, +i2 >= -9223372036854775809 AS b, +u2 >= -9223372036854775809 AS bu, +i3 >= -9223372036854775809 AS c, +u3 >= -9223372036854775809 AS cu, +i4 >= -9223372036854775809 AS d, +u4 >= -9223372036854775809 AS du, +i8 >= -9223372036854775809 AS e, +u8 >= -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775809.0 AS a, +u1 >= -9223372036854775809.0 AS au, +i2 >= -9223372036854775809.0 AS b, +u2 >= -9223372036854775809.0 AS bu, +i3 >= -9223372036854775809.0 AS c, +u3 >= -9223372036854775809.0 AS cu, +i4 >= -9223372036854775809.0 AS d, +u4 >= -9223372036854775809.0 AS du, +i8 >= -9223372036854775809.0 AS e, +u8 >= -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775809.0e0 AS a, +u1 >= -9223372036854775809.0e0 AS au, +i2 >= -9223372036854775809.0e0 AS b, +u2 >= -9223372036854775809.0e0 AS bu, +i3 >= -9223372036854775809.0e0 AS c, +u3 >= -9223372036854775809.0e0 AS cu, +i4 >= -9223372036854775809.0e0 AS d, +u4 >= -9223372036854775809.0e0 AS du, +i8 >= -9223372036854775809.0e0 AS e, +u8 >= -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-9223372036854775809' AS a, +u1 >= '-9223372036854775809' AS au, +i2 >= '-9223372036854775809' AS b, +u2 >= '-9223372036854775809' AS bu, +i3 >= '-9223372036854775809' AS c, +u3 >= '-9223372036854775809' AS cu, +i4 >= '-9223372036854775809' AS d, +u4 >= '-9223372036854775809' AS du, +i8 >= '-9223372036854775809' AS e, +u8 >= '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -9223372036854775809 AS a, +u1 <= -9223372036854775809 AS au, +i2 <= -9223372036854775809 AS b, +u2 <= -9223372036854775809 AS bu, +i3 <= -9223372036854775809 AS c, +u3 <= -9223372036854775809 AS cu, +i4 <= -9223372036854775809 AS d, +u4 <= -9223372036854775809 AS du, +i8 <= -9223372036854775809 AS e, +u8 <= -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775809.0 AS a, +u1 <= -9223372036854775809.0 AS au, +i2 <= -9223372036854775809.0 AS b, +u2 <= -9223372036854775809.0 AS bu, +i3 <= -9223372036854775809.0 AS c, +u3 <= -9223372036854775809.0 AS cu, +i4 <= -9223372036854775809.0 AS d, +u4 <= -9223372036854775809.0 AS du, +i8 <= -9223372036854775809.0 AS e, +u8 <= -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775809.0e0 AS a, +u1 <= -9223372036854775809.0e0 AS au, +i2 <= -9223372036854775809.0e0 AS b, +u2 <= -9223372036854775809.0e0 AS bu, +i3 <= -9223372036854775809.0e0 AS c, +u3 <= -9223372036854775809.0e0 AS cu, +i4 <= -9223372036854775809.0e0 AS d, +u4 <= -9223372036854775809.0e0 AS du, +i8 <= -9223372036854775809.0e0 AS e, +u8 <= -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-9223372036854775809' AS a, +u1 <= '-9223372036854775809' AS au, +i2 <= '-9223372036854775809' AS b, +u2 <= '-9223372036854775809' AS bu, +i3 <= '-9223372036854775809' AS c, +u3 <= '-9223372036854775809' AS cu, +i4 <= '-9223372036854775809' AS d, +u4 <= '-9223372036854775809' AS du, +i8 <= '-9223372036854775809' AS e, +u8 <= '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -9223372036854775809 AS a, +u1 > -9223372036854775809 AS au, +i2 > -9223372036854775809 AS b, +u2 > -9223372036854775809 AS bu, +i3 > -9223372036854775809 AS c, +u3 > -9223372036854775809 AS cu, +i4 > -9223372036854775809 AS d, +u4 > -9223372036854775809 AS du, +i8 > -9223372036854775809 AS e, +u8 > -9223372036854775809 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775809.0 AS a, +u1 > -9223372036854775809.0 AS au, +i2 > -9223372036854775809.0 AS b, +u2 > -9223372036854775809.0 AS bu, +i3 > -9223372036854775809.0 AS c, +u3 > -9223372036854775809.0 AS cu, +i4 > -9223372036854775809.0 AS d, +u4 > -9223372036854775809.0 AS du, +i8 > -9223372036854775809.0 AS e, +u8 > -9223372036854775809.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775809.0e0 AS a, +u1 > -9223372036854775809.0e0 AS au, +i2 > -9223372036854775809.0e0 AS b, +u2 > -9223372036854775809.0e0 AS bu, +i3 > -9223372036854775809.0e0 AS c, +u3 > -9223372036854775809.0e0 AS cu, +i4 > -9223372036854775809.0e0 AS d, +u4 > -9223372036854775809.0e0 AS du, +i8 > -9223372036854775809.0e0 AS e, +u8 > -9223372036854775809.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-9223372036854775809' AS a, +u1 > '-9223372036854775809' AS au, +i2 > '-9223372036854775809' AS b, +u2 > '-9223372036854775809' AS bu, +i3 > '-9223372036854775809' AS c, +u3 > '-9223372036854775809' AS cu, +i4 > '-9223372036854775809' AS d, +u4 > '-9223372036854775809' AS du, +i8 > '-9223372036854775809' AS e, +u8 > '-9223372036854775809' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -9223372036854775808; +set @dv= -9223372036854775808.0; +set @fv= -9223372036854775808.0e0; +set @sv= "-9223372036854775808"; +SELECT i1 = -9223372036854775808 AS a, +u1 = -9223372036854775808 AS au, +i2 = -9223372036854775808 AS b, +u2 = -9223372036854775808 AS bu, +i3 = -9223372036854775808 AS c, +u3 = -9223372036854775808 AS cu, +i4 = -9223372036854775808 AS d, +u4 = -9223372036854775808 AS du, +i8 = -9223372036854775808 AS e, +u8 = -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775808.0 AS a, +u1 = -9223372036854775808.0 AS au, +i2 = -9223372036854775808.0 AS b, +u2 = -9223372036854775808.0 AS bu, +i3 = -9223372036854775808.0 AS c, +u3 = -9223372036854775808.0 AS cu, +i4 = -9223372036854775808.0 AS d, +u4 = -9223372036854775808.0 AS du, +i8 = -9223372036854775808.0 AS e, +u8 = -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -9223372036854775808.0e0 AS a, +u1 = -9223372036854775808.0e0 AS au, +i2 = -9223372036854775808.0e0 AS b, +u2 = -9223372036854775808.0e0 AS bu, +i3 = -9223372036854775808.0e0 AS c, +u3 = -9223372036854775808.0e0 AS cu, +i4 = -9223372036854775808.0e0 AS d, +u4 = -9223372036854775808.0e0 AS du, +i8 = -9223372036854775808.0e0 AS e, +u8 = -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-9223372036854775808' AS a, +u1 = '-9223372036854775808' AS au, +i2 = '-9223372036854775808' AS b, +u2 = '-9223372036854775808' AS bu, +i3 = '-9223372036854775808' AS c, +u3 = '-9223372036854775808' AS cu, +i4 = '-9223372036854775808' AS d, +u4 = '-9223372036854775808' AS du, +i8 = '-9223372036854775808' AS e, +u8 = '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -9223372036854775808 AS a, +u1 <> -9223372036854775808 AS au, +i2 <> -9223372036854775808 AS b, +u2 <> -9223372036854775808 AS bu, +i3 <> -9223372036854775808 AS c, +u3 <> -9223372036854775808 AS cu, +i4 <> -9223372036854775808 AS d, +u4 <> -9223372036854775808 AS du, +i8 <> -9223372036854775808 AS e, +u8 <> -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775808.0 AS a, +u1 <> -9223372036854775808.0 AS au, +i2 <> -9223372036854775808.0 AS b, +u2 <> -9223372036854775808.0 AS bu, +i3 <> -9223372036854775808.0 AS c, +u3 <> -9223372036854775808.0 AS cu, +i4 <> -9223372036854775808.0 AS d, +u4 <> -9223372036854775808.0 AS du, +i8 <> -9223372036854775808.0 AS e, +u8 <> -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -9223372036854775808.0e0 AS a, +u1 <> -9223372036854775808.0e0 AS au, +i2 <> -9223372036854775808.0e0 AS b, +u2 <> -9223372036854775808.0e0 AS bu, +i3 <> -9223372036854775808.0e0 AS c, +u3 <> -9223372036854775808.0e0 AS cu, +i4 <> -9223372036854775808.0e0 AS d, +u4 <> -9223372036854775808.0e0 AS du, +i8 <> -9223372036854775808.0e0 AS e, +u8 <> -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-9223372036854775808' AS a, +u1 <> '-9223372036854775808' AS au, +i2 <> '-9223372036854775808' AS b, +u2 <> '-9223372036854775808' AS bu, +i3 <> '-9223372036854775808' AS c, +u3 <> '-9223372036854775808' AS cu, +i4 <> '-9223372036854775808' AS d, +u4 <> '-9223372036854775808' AS du, +i8 <> '-9223372036854775808' AS e, +u8 <> '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -9223372036854775808 AS a, +u1 < -9223372036854775808 AS au, +i2 < -9223372036854775808 AS b, +u2 < -9223372036854775808 AS bu, +i3 < -9223372036854775808 AS c, +u3 < -9223372036854775808 AS cu, +i4 < -9223372036854775808 AS d, +u4 < -9223372036854775808 AS du, +i8 < -9223372036854775808 AS e, +u8 < -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775808.0 AS a, +u1 < -9223372036854775808.0 AS au, +i2 < -9223372036854775808.0 AS b, +u2 < -9223372036854775808.0 AS bu, +i3 < -9223372036854775808.0 AS c, +u3 < -9223372036854775808.0 AS cu, +i4 < -9223372036854775808.0 AS d, +u4 < -9223372036854775808.0 AS du, +i8 < -9223372036854775808.0 AS e, +u8 < -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -9223372036854775808.0e0 AS a, +u1 < -9223372036854775808.0e0 AS au, +i2 < -9223372036854775808.0e0 AS b, +u2 < -9223372036854775808.0e0 AS bu, +i3 < -9223372036854775808.0e0 AS c, +u3 < -9223372036854775808.0e0 AS cu, +i4 < -9223372036854775808.0e0 AS d, +u4 < -9223372036854775808.0e0 AS du, +i8 < -9223372036854775808.0e0 AS e, +u8 < -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-9223372036854775808' AS a, +u1 < '-9223372036854775808' AS au, +i2 < '-9223372036854775808' AS b, +u2 < '-9223372036854775808' AS bu, +i3 < '-9223372036854775808' AS c, +u3 < '-9223372036854775808' AS cu, +i4 < '-9223372036854775808' AS d, +u4 < '-9223372036854775808' AS du, +i8 < '-9223372036854775808' AS e, +u8 < '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -9223372036854775808 AS a, +u1 >= -9223372036854775808 AS au, +i2 >= -9223372036854775808 AS b, +u2 >= -9223372036854775808 AS bu, +i3 >= -9223372036854775808 AS c, +u3 >= -9223372036854775808 AS cu, +i4 >= -9223372036854775808 AS d, +u4 >= -9223372036854775808 AS du, +i8 >= -9223372036854775808 AS e, +u8 >= -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775808.0 AS a, +u1 >= -9223372036854775808.0 AS au, +i2 >= -9223372036854775808.0 AS b, +u2 >= -9223372036854775808.0 AS bu, +i3 >= -9223372036854775808.0 AS c, +u3 >= -9223372036854775808.0 AS cu, +i4 >= -9223372036854775808.0 AS d, +u4 >= -9223372036854775808.0 AS du, +i8 >= -9223372036854775808.0 AS e, +u8 >= -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -9223372036854775808.0e0 AS a, +u1 >= -9223372036854775808.0e0 AS au, +i2 >= -9223372036854775808.0e0 AS b, +u2 >= -9223372036854775808.0e0 AS bu, +i3 >= -9223372036854775808.0e0 AS c, +u3 >= -9223372036854775808.0e0 AS cu, +i4 >= -9223372036854775808.0e0 AS d, +u4 >= -9223372036854775808.0e0 AS du, +i8 >= -9223372036854775808.0e0 AS e, +u8 >= -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-9223372036854775808' AS a, +u1 >= '-9223372036854775808' AS au, +i2 >= '-9223372036854775808' AS b, +u2 >= '-9223372036854775808' AS bu, +i3 >= '-9223372036854775808' AS c, +u3 >= '-9223372036854775808' AS cu, +i4 >= '-9223372036854775808' AS d, +u4 >= '-9223372036854775808' AS du, +i8 >= '-9223372036854775808' AS e, +u8 >= '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -9223372036854775808 AS a, +u1 <= -9223372036854775808 AS au, +i2 <= -9223372036854775808 AS b, +u2 <= -9223372036854775808 AS bu, +i3 <= -9223372036854775808 AS c, +u3 <= -9223372036854775808 AS cu, +i4 <= -9223372036854775808 AS d, +u4 <= -9223372036854775808 AS du, +i8 <= -9223372036854775808 AS e, +u8 <= -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775808.0 AS a, +u1 <= -9223372036854775808.0 AS au, +i2 <= -9223372036854775808.0 AS b, +u2 <= -9223372036854775808.0 AS bu, +i3 <= -9223372036854775808.0 AS c, +u3 <= -9223372036854775808.0 AS cu, +i4 <= -9223372036854775808.0 AS d, +u4 <= -9223372036854775808.0 AS du, +i8 <= -9223372036854775808.0 AS e, +u8 <= -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -9223372036854775808.0e0 AS a, +u1 <= -9223372036854775808.0e0 AS au, +i2 <= -9223372036854775808.0e0 AS b, +u2 <= -9223372036854775808.0e0 AS bu, +i3 <= -9223372036854775808.0e0 AS c, +u3 <= -9223372036854775808.0e0 AS cu, +i4 <= -9223372036854775808.0e0 AS d, +u4 <= -9223372036854775808.0e0 AS du, +i8 <= -9223372036854775808.0e0 AS e, +u8 <= -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-9223372036854775808' AS a, +u1 <= '-9223372036854775808' AS au, +i2 <= '-9223372036854775808' AS b, +u2 <= '-9223372036854775808' AS bu, +i3 <= '-9223372036854775808' AS c, +u3 <= '-9223372036854775808' AS cu, +i4 <= '-9223372036854775808' AS d, +u4 <= '-9223372036854775808' AS du, +i8 <= '-9223372036854775808' AS e, +u8 <= '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -9223372036854775808 AS a, +u1 > -9223372036854775808 AS au, +i2 > -9223372036854775808 AS b, +u2 > -9223372036854775808 AS bu, +i3 > -9223372036854775808 AS c, +u3 > -9223372036854775808 AS cu, +i4 > -9223372036854775808 AS d, +u4 > -9223372036854775808 AS du, +i8 > -9223372036854775808 AS e, +u8 > -9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775808.0 AS a, +u1 > -9223372036854775808.0 AS au, +i2 > -9223372036854775808.0 AS b, +u2 > -9223372036854775808.0 AS bu, +i3 > -9223372036854775808.0 AS c, +u3 > -9223372036854775808.0 AS cu, +i4 > -9223372036854775808.0 AS d, +u4 > -9223372036854775808.0 AS du, +i8 > -9223372036854775808.0 AS e, +u8 > -9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -9223372036854775808.0e0 AS a, +u1 > -9223372036854775808.0e0 AS au, +i2 > -9223372036854775808.0e0 AS b, +u2 > -9223372036854775808.0e0 AS bu, +i3 > -9223372036854775808.0e0 AS c, +u3 > -9223372036854775808.0e0 AS cu, +i4 > -9223372036854775808.0e0 AS d, +u4 > -9223372036854775808.0e0 AS du, +i8 > -9223372036854775808.0e0 AS e, +u8 > -9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-9223372036854775808' AS a, +u1 > '-9223372036854775808' AS au, +i2 > '-9223372036854775808' AS b, +u2 > '-9223372036854775808' AS bu, +i3 > '-9223372036854775808' AS c, +u3 > '-9223372036854775808' AS cu, +i4 > '-9223372036854775808' AS d, +u4 > '-9223372036854775808' AS du, +i8 > '-9223372036854775808' AS e, +u8 > '-9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -2147483648; +set @dv= -2147483648.0; +set @fv= -2147483648.0e0; +set @sv= "-2147483648"; +SELECT i1 = -2147483648 AS a, +u1 = -2147483648 AS au, +i2 = -2147483648 AS b, +u2 = -2147483648 AS bu, +i3 = -2147483648 AS c, +u3 = -2147483648 AS cu, +i4 = -2147483648 AS d, +u4 = -2147483648 AS du, +i8 = -2147483648 AS e, +u8 = -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -2147483648.0 AS a, +u1 = -2147483648.0 AS au, +i2 = -2147483648.0 AS b, +u2 = -2147483648.0 AS bu, +i3 = -2147483648.0 AS c, +u3 = -2147483648.0 AS cu, +i4 = -2147483648.0 AS d, +u4 = -2147483648.0 AS du, +i8 = -2147483648.0 AS e, +u8 = -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -2147483648.0e0 AS a, +u1 = -2147483648.0e0 AS au, +i2 = -2147483648.0e0 AS b, +u2 = -2147483648.0e0 AS bu, +i3 = -2147483648.0e0 AS c, +u3 = -2147483648.0e0 AS cu, +i4 = -2147483648.0e0 AS d, +u4 = -2147483648.0e0 AS du, +i8 = -2147483648.0e0 AS e, +u8 = -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-2147483648' AS a, +u1 = '-2147483648' AS au, +i2 = '-2147483648' AS b, +u2 = '-2147483648' AS bu, +i3 = '-2147483648' AS c, +u3 = '-2147483648' AS cu, +i4 = '-2147483648' AS d, +u4 = '-2147483648' AS du, +i8 = '-2147483648' AS e, +u8 = '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -2147483648 AS a, +u1 <> -2147483648 AS au, +i2 <> -2147483648 AS b, +u2 <> -2147483648 AS bu, +i3 <> -2147483648 AS c, +u3 <> -2147483648 AS cu, +i4 <> -2147483648 AS d, +u4 <> -2147483648 AS du, +i8 <> -2147483648 AS e, +u8 <> -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -2147483648.0 AS a, +u1 <> -2147483648.0 AS au, +i2 <> -2147483648.0 AS b, +u2 <> -2147483648.0 AS bu, +i3 <> -2147483648.0 AS c, +u3 <> -2147483648.0 AS cu, +i4 <> -2147483648.0 AS d, +u4 <> -2147483648.0 AS du, +i8 <> -2147483648.0 AS e, +u8 <> -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -2147483648.0e0 AS a, +u1 <> -2147483648.0e0 AS au, +i2 <> -2147483648.0e0 AS b, +u2 <> -2147483648.0e0 AS bu, +i3 <> -2147483648.0e0 AS c, +u3 <> -2147483648.0e0 AS cu, +i4 <> -2147483648.0e0 AS d, +u4 <> -2147483648.0e0 AS du, +i8 <> -2147483648.0e0 AS e, +u8 <> -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-2147483648' AS a, +u1 <> '-2147483648' AS au, +i2 <> '-2147483648' AS b, +u2 <> '-2147483648' AS bu, +i3 <> '-2147483648' AS c, +u3 <> '-2147483648' AS cu, +i4 <> '-2147483648' AS d, +u4 <> '-2147483648' AS du, +i8 <> '-2147483648' AS e, +u8 <> '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -2147483648 AS a, +u1 < -2147483648 AS au, +i2 < -2147483648 AS b, +u2 < -2147483648 AS bu, +i3 < -2147483648 AS c, +u3 < -2147483648 AS cu, +i4 < -2147483648 AS d, +u4 < -2147483648 AS du, +i8 < -2147483648 AS e, +u8 < -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -2147483648.0 AS a, +u1 < -2147483648.0 AS au, +i2 < -2147483648.0 AS b, +u2 < -2147483648.0 AS bu, +i3 < -2147483648.0 AS c, +u3 < -2147483648.0 AS cu, +i4 < -2147483648.0 AS d, +u4 < -2147483648.0 AS du, +i8 < -2147483648.0 AS e, +u8 < -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -2147483648.0e0 AS a, +u1 < -2147483648.0e0 AS au, +i2 < -2147483648.0e0 AS b, +u2 < -2147483648.0e0 AS bu, +i3 < -2147483648.0e0 AS c, +u3 < -2147483648.0e0 AS cu, +i4 < -2147483648.0e0 AS d, +u4 < -2147483648.0e0 AS du, +i8 < -2147483648.0e0 AS e, +u8 < -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-2147483648' AS a, +u1 < '-2147483648' AS au, +i2 < '-2147483648' AS b, +u2 < '-2147483648' AS bu, +i3 < '-2147483648' AS c, +u3 < '-2147483648' AS cu, +i4 < '-2147483648' AS d, +u4 < '-2147483648' AS du, +i8 < '-2147483648' AS e, +u8 < '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -2147483648 AS a, +u1 >= -2147483648 AS au, +i2 >= -2147483648 AS b, +u2 >= -2147483648 AS bu, +i3 >= -2147483648 AS c, +u3 >= -2147483648 AS cu, +i4 >= -2147483648 AS d, +u4 >= -2147483648 AS du, +i8 >= -2147483648 AS e, +u8 >= -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -2147483648.0 AS a, +u1 >= -2147483648.0 AS au, +i2 >= -2147483648.0 AS b, +u2 >= -2147483648.0 AS bu, +i3 >= -2147483648.0 AS c, +u3 >= -2147483648.0 AS cu, +i4 >= -2147483648.0 AS d, +u4 >= -2147483648.0 AS du, +i8 >= -2147483648.0 AS e, +u8 >= -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -2147483648.0e0 AS a, +u1 >= -2147483648.0e0 AS au, +i2 >= -2147483648.0e0 AS b, +u2 >= -2147483648.0e0 AS bu, +i3 >= -2147483648.0e0 AS c, +u3 >= -2147483648.0e0 AS cu, +i4 >= -2147483648.0e0 AS d, +u4 >= -2147483648.0e0 AS du, +i8 >= -2147483648.0e0 AS e, +u8 >= -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-2147483648' AS a, +u1 >= '-2147483648' AS au, +i2 >= '-2147483648' AS b, +u2 >= '-2147483648' AS bu, +i3 >= '-2147483648' AS c, +u3 >= '-2147483648' AS cu, +i4 >= '-2147483648' AS d, +u4 >= '-2147483648' AS du, +i8 >= '-2147483648' AS e, +u8 >= '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -2147483648 AS a, +u1 <= -2147483648 AS au, +i2 <= -2147483648 AS b, +u2 <= -2147483648 AS bu, +i3 <= -2147483648 AS c, +u3 <= -2147483648 AS cu, +i4 <= -2147483648 AS d, +u4 <= -2147483648 AS du, +i8 <= -2147483648 AS e, +u8 <= -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -2147483648.0 AS a, +u1 <= -2147483648.0 AS au, +i2 <= -2147483648.0 AS b, +u2 <= -2147483648.0 AS bu, +i3 <= -2147483648.0 AS c, +u3 <= -2147483648.0 AS cu, +i4 <= -2147483648.0 AS d, +u4 <= -2147483648.0 AS du, +i8 <= -2147483648.0 AS e, +u8 <= -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -2147483648.0e0 AS a, +u1 <= -2147483648.0e0 AS au, +i2 <= -2147483648.0e0 AS b, +u2 <= -2147483648.0e0 AS bu, +i3 <= -2147483648.0e0 AS c, +u3 <= -2147483648.0e0 AS cu, +i4 <= -2147483648.0e0 AS d, +u4 <= -2147483648.0e0 AS du, +i8 <= -2147483648.0e0 AS e, +u8 <= -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-2147483648' AS a, +u1 <= '-2147483648' AS au, +i2 <= '-2147483648' AS b, +u2 <= '-2147483648' AS bu, +i3 <= '-2147483648' AS c, +u3 <= '-2147483648' AS cu, +i4 <= '-2147483648' AS d, +u4 <= '-2147483648' AS du, +i8 <= '-2147483648' AS e, +u8 <= '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -2147483648 AS a, +u1 > -2147483648 AS au, +i2 > -2147483648 AS b, +u2 > -2147483648 AS bu, +i3 > -2147483648 AS c, +u3 > -2147483648 AS cu, +i4 > -2147483648 AS d, +u4 > -2147483648 AS du, +i8 > -2147483648 AS e, +u8 > -2147483648 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -2147483648.0 AS a, +u1 > -2147483648.0 AS au, +i2 > -2147483648.0 AS b, +u2 > -2147483648.0 AS bu, +i3 > -2147483648.0 AS c, +u3 > -2147483648.0 AS cu, +i4 > -2147483648.0 AS d, +u4 > -2147483648.0 AS du, +i8 > -2147483648.0 AS e, +u8 > -2147483648.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -2147483648.0e0 AS a, +u1 > -2147483648.0e0 AS au, +i2 > -2147483648.0e0 AS b, +u2 > -2147483648.0e0 AS bu, +i3 > -2147483648.0e0 AS c, +u3 > -2147483648.0e0 AS cu, +i4 > -2147483648.0e0 AS d, +u4 > -2147483648.0e0 AS du, +i8 > -2147483648.0e0 AS e, +u8 > -2147483648.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-2147483648' AS a, +u1 > '-2147483648' AS au, +i2 > '-2147483648' AS b, +u2 > '-2147483648' AS bu, +i3 > '-2147483648' AS c, +u3 > '-2147483648' AS cu, +i4 > '-2147483648' AS d, +u4 > '-2147483648' AS du, +i8 > '-2147483648' AS e, +u8 > '-2147483648' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -8388608; +set @dv= -8388608.0; +set @fv= -8388608.0e0; +set @sv= "-8388608"; +SELECT i1 = -8388608 AS a, +u1 = -8388608 AS au, +i2 = -8388608 AS b, +u2 = -8388608 AS bu, +i3 = -8388608 AS c, +u3 = -8388608 AS cu, +i4 = -8388608 AS d, +u4 = -8388608 AS du, +i8 = -8388608 AS e, +u8 = -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -8388608.0 AS a, +u1 = -8388608.0 AS au, +i2 = -8388608.0 AS b, +u2 = -8388608.0 AS bu, +i3 = -8388608.0 AS c, +u3 = -8388608.0 AS cu, +i4 = -8388608.0 AS d, +u4 = -8388608.0 AS du, +i8 = -8388608.0 AS e, +u8 = -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -8388608.0e0 AS a, +u1 = -8388608.0e0 AS au, +i2 = -8388608.0e0 AS b, +u2 = -8388608.0e0 AS bu, +i3 = -8388608.0e0 AS c, +u3 = -8388608.0e0 AS cu, +i4 = -8388608.0e0 AS d, +u4 = -8388608.0e0 AS du, +i8 = -8388608.0e0 AS e, +u8 = -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-8388608' AS a, +u1 = '-8388608' AS au, +i2 = '-8388608' AS b, +u2 = '-8388608' AS bu, +i3 = '-8388608' AS c, +u3 = '-8388608' AS cu, +i4 = '-8388608' AS d, +u4 = '-8388608' AS du, +i8 = '-8388608' AS e, +u8 = '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 1 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -8388608 AS a, +u1 <> -8388608 AS au, +i2 <> -8388608 AS b, +u2 <> -8388608 AS bu, +i3 <> -8388608 AS c, +u3 <> -8388608 AS cu, +i4 <> -8388608 AS d, +u4 <> -8388608 AS du, +i8 <> -8388608 AS e, +u8 <> -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -8388608.0 AS a, +u1 <> -8388608.0 AS au, +i2 <> -8388608.0 AS b, +u2 <> -8388608.0 AS bu, +i3 <> -8388608.0 AS c, +u3 <> -8388608.0 AS cu, +i4 <> -8388608.0 AS d, +u4 <> -8388608.0 AS du, +i8 <> -8388608.0 AS e, +u8 <> -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -8388608.0e0 AS a, +u1 <> -8388608.0e0 AS au, +i2 <> -8388608.0e0 AS b, +u2 <> -8388608.0e0 AS bu, +i3 <> -8388608.0e0 AS c, +u3 <> -8388608.0e0 AS cu, +i4 <> -8388608.0e0 AS d, +u4 <> -8388608.0e0 AS du, +i8 <> -8388608.0e0 AS e, +u8 <> -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-8388608' AS a, +u1 <> '-8388608' AS au, +i2 <> '-8388608' AS b, +u2 <> '-8388608' AS bu, +i3 <> '-8388608' AS c, +u3 <> '-8388608' AS cu, +i4 <> '-8388608' AS d, +u4 <> '-8388608' AS du, +i8 <> '-8388608' AS e, +u8 <> '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 0 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -8388608 AS a, +u1 < -8388608 AS au, +i2 < -8388608 AS b, +u2 < -8388608 AS bu, +i3 < -8388608 AS c, +u3 < -8388608 AS cu, +i4 < -8388608 AS d, +u4 < -8388608 AS du, +i8 < -8388608 AS e, +u8 < -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -8388608.0 AS a, +u1 < -8388608.0 AS au, +i2 < -8388608.0 AS b, +u2 < -8388608.0 AS bu, +i3 < -8388608.0 AS c, +u3 < -8388608.0 AS cu, +i4 < -8388608.0 AS d, +u4 < -8388608.0 AS du, +i8 < -8388608.0 AS e, +u8 < -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -8388608.0e0 AS a, +u1 < -8388608.0e0 AS au, +i2 < -8388608.0e0 AS b, +u2 < -8388608.0e0 AS bu, +i3 < -8388608.0e0 AS c, +u3 < -8388608.0e0 AS cu, +i4 < -8388608.0e0 AS d, +u4 < -8388608.0e0 AS du, +i8 < -8388608.0e0 AS e, +u8 < -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-8388608' AS a, +u1 < '-8388608' AS au, +i2 < '-8388608' AS b, +u2 < '-8388608' AS bu, +i3 < '-8388608' AS c, +u3 < '-8388608' AS cu, +i4 < '-8388608' AS d, +u4 < '-8388608' AS du, +i8 < '-8388608' AS e, +u8 < '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -8388608 AS a, +u1 >= -8388608 AS au, +i2 >= -8388608 AS b, +u2 >= -8388608 AS bu, +i3 >= -8388608 AS c, +u3 >= -8388608 AS cu, +i4 >= -8388608 AS d, +u4 >= -8388608 AS du, +i8 >= -8388608 AS e, +u8 >= -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -8388608.0 AS a, +u1 >= -8388608.0 AS au, +i2 >= -8388608.0 AS b, +u2 >= -8388608.0 AS bu, +i3 >= -8388608.0 AS c, +u3 >= -8388608.0 AS cu, +i4 >= -8388608.0 AS d, +u4 >= -8388608.0 AS du, +i8 >= -8388608.0 AS e, +u8 >= -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -8388608.0e0 AS a, +u1 >= -8388608.0e0 AS au, +i2 >= -8388608.0e0 AS b, +u2 >= -8388608.0e0 AS bu, +i3 >= -8388608.0e0 AS c, +u3 >= -8388608.0e0 AS cu, +i4 >= -8388608.0e0 AS d, +u4 >= -8388608.0e0 AS du, +i8 >= -8388608.0e0 AS e, +u8 >= -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-8388608' AS a, +u1 >= '-8388608' AS au, +i2 >= '-8388608' AS b, +u2 >= '-8388608' AS bu, +i3 >= '-8388608' AS c, +u3 >= '-8388608' AS cu, +i4 >= '-8388608' AS d, +u4 >= '-8388608' AS du, +i8 >= '-8388608' AS e, +u8 >= '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -8388608 AS a, +u1 <= -8388608 AS au, +i2 <= -8388608 AS b, +u2 <= -8388608 AS bu, +i3 <= -8388608 AS c, +u3 <= -8388608 AS cu, +i4 <= -8388608 AS d, +u4 <= -8388608 AS du, +i8 <= -8388608 AS e, +u8 <= -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -8388608.0 AS a, +u1 <= -8388608.0 AS au, +i2 <= -8388608.0 AS b, +u2 <= -8388608.0 AS bu, +i3 <= -8388608.0 AS c, +u3 <= -8388608.0 AS cu, +i4 <= -8388608.0 AS d, +u4 <= -8388608.0 AS du, +i8 <= -8388608.0 AS e, +u8 <= -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -8388608.0e0 AS a, +u1 <= -8388608.0e0 AS au, +i2 <= -8388608.0e0 AS b, +u2 <= -8388608.0e0 AS bu, +i3 <= -8388608.0e0 AS c, +u3 <= -8388608.0e0 AS cu, +i4 <= -8388608.0e0 AS d, +u4 <= -8388608.0e0 AS du, +i8 <= -8388608.0e0 AS e, +u8 <= -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-8388608' AS a, +u1 <= '-8388608' AS au, +i2 <= '-8388608' AS b, +u2 <= '-8388608' AS bu, +i3 <= '-8388608' AS c, +u3 <= '-8388608' AS cu, +i4 <= '-8388608' AS d, +u4 <= '-8388608' AS du, +i8 <= '-8388608' AS e, +u8 <= '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -8388608 AS a, +u1 > -8388608 AS au, +i2 > -8388608 AS b, +u2 > -8388608 AS bu, +i3 > -8388608 AS c, +u3 > -8388608 AS cu, +i4 > -8388608 AS d, +u4 > -8388608 AS du, +i8 > -8388608 AS e, +u8 > -8388608 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -8388608.0 AS a, +u1 > -8388608.0 AS au, +i2 > -8388608.0 AS b, +u2 > -8388608.0 AS bu, +i3 > -8388608.0 AS c, +u3 > -8388608.0 AS cu, +i4 > -8388608.0 AS d, +u4 > -8388608.0 AS du, +i8 > -8388608.0 AS e, +u8 > -8388608.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -8388608.0e0 AS a, +u1 > -8388608.0e0 AS au, +i2 > -8388608.0e0 AS b, +u2 > -8388608.0e0 AS bu, +i3 > -8388608.0e0 AS c, +u3 > -8388608.0e0 AS cu, +i4 > -8388608.0e0 AS d, +u4 > -8388608.0e0 AS du, +i8 > -8388608.0e0 AS e, +u8 > -8388608.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-8388608' AS a, +u1 > '-8388608' AS au, +i2 > '-8388608' AS b, +u2 > '-8388608' AS bu, +i3 > '-8388608' AS c, +u3 > '-8388608' AS cu, +i4 > '-8388608' AS d, +u4 > '-8388608' AS du, +i8 > '-8388608' AS e, +u8 > '-8388608' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -32768; +set @dv= -32768.0; +set @fv= -32768.0e0; +set @sv= "-32768"; +SELECT i1 = -32768 AS a, +u1 = -32768 AS au, +i2 = -32768 AS b, +u2 = -32768 AS bu, +i3 = -32768 AS c, +u3 = -32768 AS cu, +i4 = -32768 AS d, +u4 = -32768 AS du, +i8 = -32768 AS e, +u8 = -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -32768.0 AS a, +u1 = -32768.0 AS au, +i2 = -32768.0 AS b, +u2 = -32768.0 AS bu, +i3 = -32768.0 AS c, +u3 = -32768.0 AS cu, +i4 = -32768.0 AS d, +u4 = -32768.0 AS du, +i8 = -32768.0 AS e, +u8 = -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -32768.0e0 AS a, +u1 = -32768.0e0 AS au, +i2 = -32768.0e0 AS b, +u2 = -32768.0e0 AS bu, +i3 = -32768.0e0 AS c, +u3 = -32768.0e0 AS cu, +i4 = -32768.0e0 AS d, +u4 = -32768.0e0 AS du, +i8 = -32768.0e0 AS e, +u8 = -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-32768' AS a, +u1 = '-32768' AS au, +i2 = '-32768' AS b, +u2 = '-32768' AS bu, +i3 = '-32768' AS c, +u3 = '-32768' AS cu, +i4 = '-32768' AS d, +u4 = '-32768' AS du, +i8 = '-32768' AS e, +u8 = '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 1 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -32768 AS a, +u1 <> -32768 AS au, +i2 <> -32768 AS b, +u2 <> -32768 AS bu, +i3 <> -32768 AS c, +u3 <> -32768 AS cu, +i4 <> -32768 AS d, +u4 <> -32768 AS du, +i8 <> -32768 AS e, +u8 <> -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -32768.0 AS a, +u1 <> -32768.0 AS au, +i2 <> -32768.0 AS b, +u2 <> -32768.0 AS bu, +i3 <> -32768.0 AS c, +u3 <> -32768.0 AS cu, +i4 <> -32768.0 AS d, +u4 <> -32768.0 AS du, +i8 <> -32768.0 AS e, +u8 <> -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -32768.0e0 AS a, +u1 <> -32768.0e0 AS au, +i2 <> -32768.0e0 AS b, +u2 <> -32768.0e0 AS bu, +i3 <> -32768.0e0 AS c, +u3 <> -32768.0e0 AS cu, +i4 <> -32768.0e0 AS d, +u4 <> -32768.0e0 AS du, +i8 <> -32768.0e0 AS e, +u8 <> -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-32768' AS a, +u1 <> '-32768' AS au, +i2 <> '-32768' AS b, +u2 <> '-32768' AS bu, +i3 <> '-32768' AS c, +u3 <> '-32768' AS cu, +i4 <> '-32768' AS d, +u4 <> '-32768' AS du, +i8 <> '-32768' AS e, +u8 <> '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 0 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -32768 AS a, +u1 < -32768 AS au, +i2 < -32768 AS b, +u2 < -32768 AS bu, +i3 < -32768 AS c, +u3 < -32768 AS cu, +i4 < -32768 AS d, +u4 < -32768 AS du, +i8 < -32768 AS e, +u8 < -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -32768.0 AS a, +u1 < -32768.0 AS au, +i2 < -32768.0 AS b, +u2 < -32768.0 AS bu, +i3 < -32768.0 AS c, +u3 < -32768.0 AS cu, +i4 < -32768.0 AS d, +u4 < -32768.0 AS du, +i8 < -32768.0 AS e, +u8 < -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -32768.0e0 AS a, +u1 < -32768.0e0 AS au, +i2 < -32768.0e0 AS b, +u2 < -32768.0e0 AS bu, +i3 < -32768.0e0 AS c, +u3 < -32768.0e0 AS cu, +i4 < -32768.0e0 AS d, +u4 < -32768.0e0 AS du, +i8 < -32768.0e0 AS e, +u8 < -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-32768' AS a, +u1 < '-32768' AS au, +i2 < '-32768' AS b, +u2 < '-32768' AS bu, +i3 < '-32768' AS c, +u3 < '-32768' AS cu, +i4 < '-32768' AS d, +u4 < '-32768' AS du, +i8 < '-32768' AS e, +u8 < '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -32768 AS a, +u1 >= -32768 AS au, +i2 >= -32768 AS b, +u2 >= -32768 AS bu, +i3 >= -32768 AS c, +u3 >= -32768 AS cu, +i4 >= -32768 AS d, +u4 >= -32768 AS du, +i8 >= -32768 AS e, +u8 >= -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -32768.0 AS a, +u1 >= -32768.0 AS au, +i2 >= -32768.0 AS b, +u2 >= -32768.0 AS bu, +i3 >= -32768.0 AS c, +u3 >= -32768.0 AS cu, +i4 >= -32768.0 AS d, +u4 >= -32768.0 AS du, +i8 >= -32768.0 AS e, +u8 >= -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -32768.0e0 AS a, +u1 >= -32768.0e0 AS au, +i2 >= -32768.0e0 AS b, +u2 >= -32768.0e0 AS bu, +i3 >= -32768.0e0 AS c, +u3 >= -32768.0e0 AS cu, +i4 >= -32768.0e0 AS d, +u4 >= -32768.0e0 AS du, +i8 >= -32768.0e0 AS e, +u8 >= -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-32768' AS a, +u1 >= '-32768' AS au, +i2 >= '-32768' AS b, +u2 >= '-32768' AS bu, +i3 >= '-32768' AS c, +u3 >= '-32768' AS cu, +i4 >= '-32768' AS d, +u4 >= '-32768' AS du, +i8 >= '-32768' AS e, +u8 >= '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -32768 AS a, +u1 <= -32768 AS au, +i2 <= -32768 AS b, +u2 <= -32768 AS bu, +i3 <= -32768 AS c, +u3 <= -32768 AS cu, +i4 <= -32768 AS d, +u4 <= -32768 AS du, +i8 <= -32768 AS e, +u8 <= -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -32768.0 AS a, +u1 <= -32768.0 AS au, +i2 <= -32768.0 AS b, +u2 <= -32768.0 AS bu, +i3 <= -32768.0 AS c, +u3 <= -32768.0 AS cu, +i4 <= -32768.0 AS d, +u4 <= -32768.0 AS du, +i8 <= -32768.0 AS e, +u8 <= -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -32768.0e0 AS a, +u1 <= -32768.0e0 AS au, +i2 <= -32768.0e0 AS b, +u2 <= -32768.0e0 AS bu, +i3 <= -32768.0e0 AS c, +u3 <= -32768.0e0 AS cu, +i4 <= -32768.0e0 AS d, +u4 <= -32768.0e0 AS du, +i8 <= -32768.0e0 AS e, +u8 <= -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-32768' AS a, +u1 <= '-32768' AS au, +i2 <= '-32768' AS b, +u2 <= '-32768' AS bu, +i3 <= '-32768' AS c, +u3 <= '-32768' AS cu, +i4 <= '-32768' AS d, +u4 <= '-32768' AS du, +i8 <= '-32768' AS e, +u8 <= '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -32768 AS a, +u1 > -32768 AS au, +i2 > -32768 AS b, +u2 > -32768 AS bu, +i3 > -32768 AS c, +u3 > -32768 AS cu, +i4 > -32768 AS d, +u4 > -32768 AS du, +i8 > -32768 AS e, +u8 > -32768 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -32768.0 AS a, +u1 > -32768.0 AS au, +i2 > -32768.0 AS b, +u2 > -32768.0 AS bu, +i3 > -32768.0 AS c, +u3 > -32768.0 AS cu, +i4 > -32768.0 AS d, +u4 > -32768.0 AS du, +i8 > -32768.0 AS e, +u8 > -32768.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -32768.0e0 AS a, +u1 > -32768.0e0 AS au, +i2 > -32768.0e0 AS b, +u2 > -32768.0e0 AS bu, +i3 > -32768.0e0 AS c, +u3 > -32768.0e0 AS cu, +i4 > -32768.0e0 AS d, +u4 > -32768.0e0 AS du, +i8 > -32768.0e0 AS e, +u8 > -32768.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-32768' AS a, +u1 > '-32768' AS au, +i2 > '-32768' AS b, +u2 > '-32768' AS bu, +i3 > '-32768' AS c, +u3 > '-32768' AS cu, +i4 > '-32768' AS d, +u4 > '-32768' AS du, +i8 > '-32768' AS e, +u8 > '-32768' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= -128; +set @dv= -128.0; +set @fv= -128.0e0; +set @sv= "-128"; +SELECT i1 = -128 AS a, +u1 = -128 AS au, +i2 = -128 AS b, +u2 = -128 AS bu, +i3 = -128 AS c, +u3 = -128 AS cu, +i4 = -128 AS d, +u4 = -128 AS du, +i8 = -128 AS e, +u8 = -128 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -128.0 AS a, +u1 = -128.0 AS au, +i2 = -128.0 AS b, +u2 = -128.0 AS bu, +i3 = -128.0 AS c, +u3 = -128.0 AS cu, +i4 = -128.0 AS d, +u4 = -128.0 AS du, +i8 = -128.0 AS e, +u8 = -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = -128.0e0 AS a, +u1 = -128.0e0 AS au, +i2 = -128.0e0 AS b, +u2 = -128.0e0 AS bu, +i3 = -128.0e0 AS c, +u3 = -128.0e0 AS cu, +i4 = -128.0e0 AS d, +u4 = -128.0e0 AS du, +i8 = -128.0e0 AS e, +u8 = -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '-128' AS a, +u1 = '-128' AS au, +i2 = '-128' AS b, +u2 = '-128' AS bu, +i3 = '-128' AS c, +u3 = '-128' AS cu, +i4 = '-128' AS d, +u4 = '-128' AS du, +i8 = '-128' AS e, +u8 = '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> -128 AS a, +u1 <> -128 AS au, +i2 <> -128 AS b, +u2 <> -128 AS bu, +i3 <> -128 AS c, +u3 <> -128 AS cu, +i4 <> -128 AS d, +u4 <> -128 AS du, +i8 <> -128 AS e, +u8 <> -128 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -128.0 AS a, +u1 <> -128.0 AS au, +i2 <> -128.0 AS b, +u2 <> -128.0 AS bu, +i3 <> -128.0 AS c, +u3 <> -128.0 AS cu, +i4 <> -128.0 AS d, +u4 <> -128.0 AS du, +i8 <> -128.0 AS e, +u8 <> -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> -128.0e0 AS a, +u1 <> -128.0e0 AS au, +i2 <> -128.0e0 AS b, +u2 <> -128.0e0 AS bu, +i3 <> -128.0e0 AS c, +u3 <> -128.0e0 AS cu, +i4 <> -128.0e0 AS d, +u4 <> -128.0e0 AS du, +i8 <> -128.0e0 AS e, +u8 <> -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '-128' AS a, +u1 <> '-128' AS au, +i2 <> '-128' AS b, +u2 <> '-128' AS bu, +i3 <> '-128' AS c, +u3 <> '-128' AS cu, +i4 <> '-128' AS d, +u4 <> '-128' AS du, +i8 <> '-128' AS e, +u8 <> '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < -128 AS a, +u1 < -128 AS au, +i2 < -128 AS b, +u2 < -128 AS bu, +i3 < -128 AS c, +u3 < -128 AS cu, +i4 < -128 AS d, +u4 < -128 AS du, +i8 < -128 AS e, +u8 < -128 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -128.0 AS a, +u1 < -128.0 AS au, +i2 < -128.0 AS b, +u2 < -128.0 AS bu, +i3 < -128.0 AS c, +u3 < -128.0 AS cu, +i4 < -128.0 AS d, +u4 < -128.0 AS du, +i8 < -128.0 AS e, +u8 < -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < -128.0e0 AS a, +u1 < -128.0e0 AS au, +i2 < -128.0e0 AS b, +u2 < -128.0e0 AS bu, +i3 < -128.0e0 AS c, +u3 < -128.0e0 AS cu, +i4 < -128.0e0 AS d, +u4 < -128.0e0 AS du, +i8 < -128.0e0 AS e, +u8 < -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '-128' AS a, +u1 < '-128' AS au, +i2 < '-128' AS b, +u2 < '-128' AS bu, +i3 < '-128' AS c, +u3 < '-128' AS cu, +i4 < '-128' AS d, +u4 < '-128' AS du, +i8 < '-128' AS e, +u8 < '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= -128 AS a, +u1 >= -128 AS au, +i2 >= -128 AS b, +u2 >= -128 AS bu, +i3 >= -128 AS c, +u3 >= -128 AS cu, +i4 >= -128 AS d, +u4 >= -128 AS du, +i8 >= -128 AS e, +u8 >= -128 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -128.0 AS a, +u1 >= -128.0 AS au, +i2 >= -128.0 AS b, +u2 >= -128.0 AS bu, +i3 >= -128.0 AS c, +u3 >= -128.0 AS cu, +i4 >= -128.0 AS d, +u4 >= -128.0 AS du, +i8 >= -128.0 AS e, +u8 >= -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= -128.0e0 AS a, +u1 >= -128.0e0 AS au, +i2 >= -128.0e0 AS b, +u2 >= -128.0e0 AS bu, +i3 >= -128.0e0 AS c, +u3 >= -128.0e0 AS cu, +i4 >= -128.0e0 AS d, +u4 >= -128.0e0 AS du, +i8 >= -128.0e0 AS e, +u8 >= -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '-128' AS a, +u1 >= '-128' AS au, +i2 >= '-128' AS b, +u2 >= '-128' AS bu, +i3 >= '-128' AS c, +u3 >= '-128' AS cu, +i4 >= '-128' AS d, +u4 >= '-128' AS du, +i8 >= '-128' AS e, +u8 >= '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= -128 AS a, +u1 <= -128 AS au, +i2 <= -128 AS b, +u2 <= -128 AS bu, +i3 <= -128 AS c, +u3 <= -128 AS cu, +i4 <= -128 AS d, +u4 <= -128 AS du, +i8 <= -128 AS e, +u8 <= -128 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -128.0 AS a, +u1 <= -128.0 AS au, +i2 <= -128.0 AS b, +u2 <= -128.0 AS bu, +i3 <= -128.0 AS c, +u3 <= -128.0 AS cu, +i4 <= -128.0 AS d, +u4 <= -128.0 AS du, +i8 <= -128.0 AS e, +u8 <= -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= -128.0e0 AS a, +u1 <= -128.0e0 AS au, +i2 <= -128.0e0 AS b, +u2 <= -128.0e0 AS bu, +i3 <= -128.0e0 AS c, +u3 <= -128.0e0 AS cu, +i4 <= -128.0e0 AS d, +u4 <= -128.0e0 AS du, +i8 <= -128.0e0 AS e, +u8 <= -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '-128' AS a, +u1 <= '-128' AS au, +i2 <= '-128' AS b, +u2 <= '-128' AS bu, +i3 <= '-128' AS c, +u3 <= '-128' AS cu, +i4 <= '-128' AS d, +u4 <= '-128' AS du, +i8 <= '-128' AS e, +u8 <= '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > -128 AS a, +u1 > -128 AS au, +i2 > -128 AS b, +u2 > -128 AS bu, +i3 > -128 AS c, +u3 > -128 AS cu, +i4 > -128 AS d, +u4 > -128 AS du, +i8 > -128 AS e, +u8 > -128 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -128.0 AS a, +u1 > -128.0 AS au, +i2 > -128.0 AS b, +u2 > -128.0 AS bu, +i3 > -128.0 AS c, +u3 > -128.0 AS cu, +i4 > -128.0 AS d, +u4 > -128.0 AS du, +i8 > -128.0 AS e, +u8 > -128.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > -128.0e0 AS a, +u1 > -128.0e0 AS au, +i2 > -128.0e0 AS b, +u2 > -128.0e0 AS bu, +i3 > -128.0e0 AS c, +u3 > -128.0e0 AS cu, +i4 > -128.0e0 AS d, +u4 > -128.0e0 AS du, +i8 > -128.0e0 AS e, +u8 > -128.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '-128' AS a, +u1 > '-128' AS au, +i2 > '-128' AS b, +u2 > '-128' AS bu, +i3 > '-128' AS c, +u3 > '-128' AS cu, +i4 > '-128' AS d, +u4 > '-128' AS du, +i8 > '-128' AS e, +u8 > '-128' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= 0; +set @dv= 0.0; +set @fv= 0.0e0; +set @sv= "0"; +SELECT i1 = 0 AS a, +u1 = 0 AS au, +i2 = 0 AS b, +u2 = 0 AS bu, +i3 = 0 AS c, +u3 = 0 AS cu, +i4 = 0 AS d, +u4 = 0 AS du, +i8 = 0 AS e, +u8 = 0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 0.0 AS a, +u1 = 0.0 AS au, +i2 = 0.0 AS b, +u2 = 0.0 AS bu, +i3 = 0.0 AS c, +u3 = 0.0 AS cu, +i4 = 0.0 AS d, +u4 = 0.0 AS du, +i8 = 0.0 AS e, +u8 = 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 0.0e0 AS a, +u1 = 0.0e0 AS au, +i2 = 0.0e0 AS b, +u2 = 0.0e0 AS bu, +i3 = 0.0e0 AS c, +u3 = 0.0e0 AS cu, +i4 = 0.0e0 AS d, +u4 = 0.0e0 AS du, +i8 = 0.0e0 AS e, +u8 = 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = '0' AS a, +u1 = '0' AS au, +i2 = '0' AS b, +u2 = '0' AS bu, +i3 = '0' AS c, +u3 = '0' AS cu, +i4 = '0' AS d, +u4 = '0' AS du, +i8 = '0' AS e, +u8 = '0' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <> 0 AS a, +u1 <> 0 AS au, +i2 <> 0 AS b, +u2 <> 0 AS bu, +i3 <> 0 AS c, +u3 <> 0 AS cu, +i4 <> 0 AS d, +u4 <> 0 AS du, +i8 <> 0 AS e, +u8 <> 0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 0.0 AS a, +u1 <> 0.0 AS au, +i2 <> 0.0 AS b, +u2 <> 0.0 AS bu, +i3 <> 0.0 AS c, +u3 <> 0.0 AS cu, +i4 <> 0.0 AS d, +u4 <> 0.0 AS du, +i8 <> 0.0 AS e, +u8 <> 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 0.0e0 AS a, +u1 <> 0.0e0 AS au, +i2 <> 0.0e0 AS b, +u2 <> 0.0e0 AS bu, +i3 <> 0.0e0 AS c, +u3 <> 0.0e0 AS cu, +i4 <> 0.0e0 AS d, +u4 <> 0.0e0 AS du, +i8 <> 0.0e0 AS e, +u8 <> 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '0' AS a, +u1 <> '0' AS au, +i2 <> '0' AS b, +u2 <> '0' AS bu, +i3 <> '0' AS c, +u3 <> '0' AS cu, +i4 <> '0' AS d, +u4 <> '0' AS du, +i8 <> '0' AS e, +u8 <> '0' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < 0 AS a, +u1 < 0 AS au, +i2 < 0 AS b, +u2 < 0 AS bu, +i3 < 0 AS c, +u3 < 0 AS cu, +i4 < 0 AS d, +u4 < 0 AS du, +i8 < 0 AS e, +u8 < 0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 0.0 AS a, +u1 < 0.0 AS au, +i2 < 0.0 AS b, +u2 < 0.0 AS bu, +i3 < 0.0 AS c, +u3 < 0.0 AS cu, +i4 < 0.0 AS d, +u4 < 0.0 AS du, +i8 < 0.0 AS e, +u8 < 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 0.0e0 AS a, +u1 < 0.0e0 AS au, +i2 < 0.0e0 AS b, +u2 < 0.0e0 AS bu, +i3 < 0.0e0 AS c, +u3 < 0.0e0 AS cu, +i4 < 0.0e0 AS d, +u4 < 0.0e0 AS du, +i8 < 0.0e0 AS e, +u8 < 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '0' AS a, +u1 < '0' AS au, +i2 < '0' AS b, +u2 < '0' AS bu, +i3 < '0' AS c, +u3 < '0' AS cu, +i4 < '0' AS d, +u4 < '0' AS du, +i8 < '0' AS e, +u8 < '0' AS eu +FROM t1; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 0 1 0 1 0 1 0 1 0 +1 0 1 0 1 0 1 0 1 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 0 AS a, +u1 >= 0 AS au, +i2 >= 0 AS b, +u2 >= 0 AS bu, +i3 >= 0 AS c, +u3 >= 0 AS cu, +i4 >= 0 AS d, +u4 >= 0 AS du, +i8 >= 0 AS e, +u8 >= 0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 0.0 AS a, +u1 >= 0.0 AS au, +i2 >= 0.0 AS b, +u2 >= 0.0 AS bu, +i3 >= 0.0 AS c, +u3 >= 0.0 AS cu, +i4 >= 0.0 AS d, +u4 >= 0.0 AS du, +i8 >= 0.0 AS e, +u8 >= 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 0.0e0 AS a, +u1 >= 0.0e0 AS au, +i2 >= 0.0e0 AS b, +u2 >= 0.0e0 AS bu, +i3 >= 0.0e0 AS c, +u3 >= 0.0e0 AS cu, +i4 >= 0.0e0 AS d, +u4 >= 0.0e0 AS du, +i8 >= 0.0e0 AS e, +u8 >= 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '0' AS a, +u1 >= '0' AS au, +i2 >= '0' AS b, +u2 >= '0' AS bu, +i3 >= '0' AS c, +u3 >= '0' AS cu, +i4 >= '0' AS d, +u4 >= '0' AS du, +i8 >= '0' AS e, +u8 >= '0' AS eu +FROM t1; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 1 0 1 0 1 0 1 0 1 +0 1 0 1 0 1 0 1 0 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 0 AS a, +u1 <= 0 AS au, +i2 <= 0 AS b, +u2 <= 0 AS bu, +i3 <= 0 AS c, +u3 <= 0 AS cu, +i4 <= 0 AS d, +u4 <= 0 AS du, +i8 <= 0 AS e, +u8 <= 0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 0.0 AS a, +u1 <= 0.0 AS au, +i2 <= 0.0 AS b, +u2 <= 0.0 AS bu, +i3 <= 0.0 AS c, +u3 <= 0.0 AS cu, +i4 <= 0.0 AS d, +u4 <= 0.0 AS du, +i8 <= 0.0 AS e, +u8 <= 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 0.0e0 AS a, +u1 <= 0.0e0 AS au, +i2 <= 0.0e0 AS b, +u2 <= 0.0e0 AS bu, +i3 <= 0.0e0 AS c, +u3 <= 0.0e0 AS cu, +i4 <= 0.0e0 AS d, +u4 <= 0.0e0 AS du, +i8 <= 0.0e0 AS e, +u8 <= 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '0' AS a, +u1 <= '0' AS au, +i2 <= '0' AS b, +u2 <= '0' AS bu, +i3 <= '0' AS c, +u3 <= '0' AS cu, +i4 <= '0' AS d, +u4 <= '0' AS du, +i8 <= '0' AS e, +u8 <= '0' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 0 AS a, +u1 > 0 AS au, +i2 > 0 AS b, +u2 > 0 AS bu, +i3 > 0 AS c, +u3 > 0 AS cu, +i4 > 0 AS d, +u4 > 0 AS du, +i8 > 0 AS e, +u8 > 0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 0.0 AS a, +u1 > 0.0 AS au, +i2 > 0.0 AS b, +u2 > 0.0 AS bu, +i3 > 0.0 AS c, +u3 > 0.0 AS cu, +i4 > 0.0 AS d, +u4 > 0.0 AS du, +i8 > 0.0 AS e, +u8 > 0.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 0.0e0 AS a, +u1 > 0.0e0 AS au, +i2 > 0.0e0 AS b, +u2 > 0.0e0 AS bu, +i3 > 0.0e0 AS c, +u3 > 0.0e0 AS cu, +i4 > 0.0e0 AS d, +u4 > 0.0e0 AS du, +i8 > 0.0e0 AS e, +u8 > 0.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > '0' AS a, +u1 > '0' AS au, +i2 > '0' AS b, +u2 > '0' AS bu, +i3 > '0' AS c, +u3 > '0' AS cu, +i4 > '0' AS d, +u4 > '0' AS du, +i8 > '0' AS e, +u8 > '0' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +set @iv= 127; +set @dv= 127.0; +set @fv= 127.0e0; +set @sv= "127"; +SELECT i1 = 127 AS a, +u1 = 127 AS au, +i2 = 127 AS b, +u2 = 127 AS bu, +i3 = 127 AS c, +u3 = 127 AS cu, +i4 = 127 AS d, +u4 = 127 AS du, +i8 = 127 AS e, +u8 = 127 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 = 127.0 AS a, +u1 = 127.0 AS au, +i2 = 127.0 AS b, +u2 = 127.0 AS bu, +i3 = 127.0 AS c, +u3 = 127.0 AS cu, +i4 = 127.0 AS d, +u4 = 127.0 AS du, +i8 = 127.0 AS e, +u8 = 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 = 127.0e0 AS a, +u1 = 127.0e0 AS au, +i2 = 127.0e0 AS b, +u2 = 127.0e0 AS bu, +i3 = 127.0e0 AS c, +u3 = 127.0e0 AS cu, +i4 = 127.0e0 AS d, +u4 = 127.0e0 AS du, +i8 = 127.0e0 AS e, +u8 = 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 = '127' AS a, +u1 = '127' AS au, +i2 = '127' AS b, +u2 = '127' AS bu, +i3 = '127' AS c, +u3 = '127' AS cu, +i4 = '127' AS d, +u4 = '127' AS du, +i8 = '127' AS e, +u8 = '127' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <> 127 AS a, +u1 <> 127 AS au, +i2 <> 127 AS b, +u2 <> 127 AS bu, +i3 <> 127 AS c, +u3 <> 127 AS cu, +i4 <> 127 AS d, +u4 <> 127 AS du, +i8 <> 127 AS e, +u8 <> 127 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 127.0 AS a, +u1 <> 127.0 AS au, +i2 <> 127.0 AS b, +u2 <> 127.0 AS bu, +i3 <> 127.0 AS c, +u3 <> 127.0 AS cu, +i4 <> 127.0 AS d, +u4 <> 127.0 AS du, +i8 <> 127.0 AS e, +u8 <> 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 127.0e0 AS a, +u1 <> 127.0e0 AS au, +i2 <> 127.0e0 AS b, +u2 <> 127.0e0 AS bu, +i3 <> 127.0e0 AS c, +u3 <> 127.0e0 AS cu, +i4 <> 127.0e0 AS d, +u4 <> 127.0e0 AS du, +i8 <> 127.0e0 AS e, +u8 <> 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <> '127' AS a, +u1 <> '127' AS au, +i2 <> '127' AS b, +u2 <> '127' AS bu, +i3 <> '127' AS c, +u3 <> '127' AS cu, +i4 <> '127' AS d, +u4 <> '127' AS du, +i8 <> '127' AS e, +u8 <> '127' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 < 127 AS a, +u1 < 127 AS au, +i2 < 127 AS b, +u2 < 127 AS bu, +i3 < 127 AS c, +u3 < 127 AS cu, +i4 < 127 AS d, +u4 < 127 AS du, +i8 < 127 AS e, +u8 < 127 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 127.0 AS a, +u1 < 127.0 AS au, +i2 < 127.0 AS b, +u2 < 127.0 AS bu, +i3 < 127.0 AS c, +u3 < 127.0 AS cu, +i4 < 127.0 AS d, +u4 < 127.0 AS du, +i8 < 127.0 AS e, +u8 < 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < 127.0e0 AS a, +u1 < 127.0e0 AS au, +i2 < 127.0e0 AS b, +u2 < 127.0e0 AS bu, +i3 < 127.0e0 AS c, +u3 < 127.0e0 AS cu, +i4 < 127.0e0 AS d, +u4 < 127.0e0 AS du, +i8 < 127.0e0 AS e, +u8 < 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 < '127' AS a, +u1 < '127' AS au, +i2 < '127' AS b, +u2 < '127' AS bu, +i3 < '127' AS c, +u3 < '127' AS cu, +i4 < '127' AS d, +u4 < '127' AS du, +i8 < '127' AS e, +u8 < '127' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 127 AS a, +u1 >= 127 AS au, +i2 >= 127 AS b, +u2 >= 127 AS bu, +i3 >= 127 AS c, +u3 >= 127 AS cu, +i4 >= 127 AS d, +u4 >= 127 AS du, +i8 >= 127 AS e, +u8 >= 127 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 127.0 AS a, +u1 >= 127.0 AS au, +i2 >= 127.0 AS b, +u2 >= 127.0 AS bu, +i3 >= 127.0 AS c, +u3 >= 127.0 AS cu, +i4 >= 127.0 AS d, +u4 >= 127.0 AS du, +i8 >= 127.0 AS e, +u8 >= 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 127.0e0 AS a, +u1 >= 127.0e0 AS au, +i2 >= 127.0e0 AS b, +u2 >= 127.0e0 AS bu, +i3 >= 127.0e0 AS c, +u3 >= 127.0e0 AS cu, +i4 >= 127.0e0 AS d, +u4 >= 127.0e0 AS du, +i8 >= 127.0e0 AS e, +u8 >= 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '127' AS a, +u1 >= '127' AS au, +i2 >= '127' AS b, +u2 >= '127' AS bu, +i3 >= '127' AS c, +u3 >= '127' AS cu, +i4 >= '127' AS d, +u4 >= '127' AS du, +i8 >= '127' AS e, +u8 >= '127' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 127 AS a, +u1 <= 127 AS au, +i2 <= 127 AS b, +u2 <= 127 AS bu, +i3 <= 127 AS c, +u3 <= 127 AS cu, +i4 <= 127 AS d, +u4 <= 127 AS du, +i8 <= 127 AS e, +u8 <= 127 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 127.0 AS a, +u1 <= 127.0 AS au, +i2 <= 127.0 AS b, +u2 <= 127.0 AS bu, +i3 <= 127.0 AS c, +u3 <= 127.0 AS cu, +i4 <= 127.0 AS d, +u4 <= 127.0 AS du, +i8 <= 127.0 AS e, +u8 <= 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <= 127.0e0 AS a, +u1 <= 127.0e0 AS au, +i2 <= 127.0e0 AS b, +u2 <= 127.0e0 AS bu, +i3 <= 127.0e0 AS c, +u3 <= 127.0e0 AS cu, +i4 <= 127.0e0 AS d, +u4 <= 127.0e0 AS du, +i8 <= 127.0e0 AS e, +u8 <= 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 <= '127' AS a, +u1 <= '127' AS au, +i2 <= '127' AS b, +u2 <= '127' AS bu, +i3 <= '127' AS c, +u3 <= '127' AS cu, +i4 <= '127' AS d, +u4 <= '127' AS du, +i8 <= '127' AS e, +u8 <= '127' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 > 127 AS a, +u1 > 127 AS au, +i2 > 127 AS b, +u2 > 127 AS bu, +i3 > 127 AS c, +u3 > 127 AS cu, +i4 > 127 AS d, +u4 > 127 AS du, +i8 > 127 AS e, +u8 > 127 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 > 127.0 AS a, +u1 > 127.0 AS au, +i2 > 127.0 AS b, +u2 > 127.0 AS bu, +i3 > 127.0 AS c, +u3 > 127.0 AS cu, +i4 > 127.0 AS d, +u4 > 127.0 AS du, +i8 > 127.0 AS e, +u8 > 127.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 > 127.0e0 AS a, +u1 > 127.0e0 AS au, +i2 > 127.0e0 AS b, +u2 > 127.0e0 AS bu, +i3 > 127.0e0 AS c, +u3 > 127.0e0 AS cu, +i4 > 127.0e0 AS d, +u4 > 127.0e0 AS du, +i8 > 127.0e0 AS e, +u8 > 127.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 > '127' AS a, +u1 > '127' AS au, +i2 > '127' AS b, +u2 > '127' AS bu, +i3 > '127' AS c, +u3 > '127' AS cu, +i4 > '127' AS d, +u4 > '127' AS du, +i8 > '127' AS e, +u8 > '127' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +set @iv= 255; +set @dv= 255.0; +set @fv= 255.0e0; +set @sv= "255"; +SELECT i1 = 255 AS a, +u1 = 255 AS au, +i2 = 255 AS b, +u2 = 255 AS bu, +i3 = 255 AS c, +u3 = 255 AS cu, +i4 = 255 AS d, +u4 = 255 AS du, +i8 = 255 AS e, +u8 = 255 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 = 255.0 AS a, +u1 = 255.0 AS au, +i2 = 255.0 AS b, +u2 = 255.0 AS bu, +i3 = 255.0 AS c, +u3 = 255.0 AS cu, +i4 = 255.0 AS d, +u4 = 255.0 AS du, +i8 = 255.0 AS e, +u8 = 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 = 255.0e0 AS a, +u1 = 255.0e0 AS au, +i2 = 255.0e0 AS b, +u2 = 255.0e0 AS bu, +i3 = 255.0e0 AS c, +u3 = 255.0e0 AS cu, +i4 = 255.0e0 AS d, +u4 = 255.0e0 AS du, +i8 = 255.0e0 AS e, +u8 = 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 = '255' AS a, +u1 = '255' AS au, +i2 = '255' AS b, +u2 = '255' AS bu, +i3 = '255' AS c, +u3 = '255' AS cu, +i4 = '255' AS d, +u4 = '255' AS du, +i8 = '255' AS e, +u8 = '255' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 0 0 0 0 0 0 0 0 +SELECT i1 <> 255 AS a, +u1 <> 255 AS au, +i2 <> 255 AS b, +u2 <> 255 AS bu, +i3 <> 255 AS c, +u3 <> 255 AS cu, +i4 <> 255 AS d, +u4 <> 255 AS du, +i8 <> 255 AS e, +u8 <> 255 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 <> 255.0 AS a, +u1 <> 255.0 AS au, +i2 <> 255.0 AS b, +u2 <> 255.0 AS bu, +i3 <> 255.0 AS c, +u3 <> 255.0 AS cu, +i4 <> 255.0 AS d, +u4 <> 255.0 AS du, +i8 <> 255.0 AS e, +u8 <> 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 <> 255.0e0 AS a, +u1 <> 255.0e0 AS au, +i2 <> 255.0e0 AS b, +u2 <> 255.0e0 AS bu, +i3 <> 255.0e0 AS c, +u3 <> 255.0e0 AS cu, +i4 <> 255.0e0 AS d, +u4 <> 255.0e0 AS du, +i8 <> 255.0e0 AS e, +u8 <> 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 <> '255' AS a, +u1 <> '255' AS au, +i2 <> '255' AS b, +u2 <> '255' AS bu, +i3 <> '255' AS c, +u3 <> '255' AS cu, +i4 <> '255' AS d, +u4 <> '255' AS du, +i8 <> '255' AS e, +u8 <> '255' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 1 1 1 1 1 1 1 1 +SELECT i1 < 255 AS a, +u1 < 255 AS au, +i2 < 255 AS b, +u2 < 255 AS bu, +i3 < 255 AS c, +u3 < 255 AS cu, +i4 < 255 AS d, +u4 < 255 AS du, +i8 < 255 AS e, +u8 < 255 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 < 255.0 AS a, +u1 < 255.0 AS au, +i2 < 255.0 AS b, +u2 < 255.0 AS bu, +i3 < 255.0 AS c, +u3 < 255.0 AS cu, +i4 < 255.0 AS d, +u4 < 255.0 AS du, +i8 < 255.0 AS e, +u8 < 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 < 255.0e0 AS a, +u1 < 255.0e0 AS au, +i2 < 255.0e0 AS b, +u2 < 255.0e0 AS bu, +i3 < 255.0e0 AS c, +u3 < 255.0e0 AS cu, +i4 < 255.0e0 AS d, +u4 < 255.0e0 AS du, +i8 < 255.0e0 AS e, +u8 < 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 < '255' AS a, +u1 < '255' AS au, +i2 < '255' AS b, +u2 < '255' AS bu, +i3 < '255' AS c, +u3 < '255' AS cu, +i4 < '255' AS d, +u4 < '255' AS du, +i8 < '255' AS e, +u8 < '255' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 255 AS a, +u1 >= 255 AS au, +i2 >= 255 AS b, +u2 >= 255 AS bu, +i3 >= 255 AS c, +u3 >= 255 AS cu, +i4 >= 255 AS d, +u4 >= 255 AS du, +i8 >= 255 AS e, +u8 >= 255 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 255.0 AS a, +u1 >= 255.0 AS au, +i2 >= 255.0 AS b, +u2 >= 255.0 AS bu, +i3 >= 255.0 AS c, +u3 >= 255.0 AS cu, +i4 >= 255.0 AS d, +u4 >= 255.0 AS du, +i8 >= 255.0 AS e, +u8 >= 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 >= 255.0e0 AS a, +u1 >= 255.0e0 AS au, +i2 >= 255.0e0 AS b, +u2 >= 255.0e0 AS bu, +i3 >= 255.0e0 AS c, +u3 >= 255.0e0 AS cu, +i4 >= 255.0e0 AS d, +u4 >= 255.0e0 AS du, +i8 >= 255.0e0 AS e, +u8 >= 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 >= '255' AS a, +u1 >= '255' AS au, +i2 >= '255' AS b, +u2 >= '255' AS bu, +i3 >= '255' AS c, +u3 >= '255' AS cu, +i4 >= '255' AS d, +u4 >= '255' AS du, +i8 >= '255' AS e, +u8 >= '255' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 255 AS a, +u1 <= 255 AS au, +i2 <= 255 AS b, +u2 <= 255 AS bu, +i3 <= 255 AS c, +u3 <= 255 AS cu, +i4 <= 255 AS d, +u4 <= 255 AS du, +i8 <= 255 AS e, +u8 <= 255 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 <= 255.0 AS a, +u1 <= 255.0 AS au, +i2 <= 255.0 AS b, +u2 <= 255.0 AS bu, +i3 <= 255.0 AS c, +u3 <= 255.0 AS cu, +i4 <= 255.0 AS d, +u4 <= 255.0 AS du, +i8 <= 255.0 AS e, +u8 <= 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 <= 255.0e0 AS a, +u1 <= 255.0e0 AS au, +i2 <= 255.0e0 AS b, +u2 <= 255.0e0 AS bu, +i3 <= 255.0e0 AS c, +u3 <= 255.0e0 AS cu, +i4 <= 255.0e0 AS d, +u4 <= 255.0e0 AS du, +i8 <= 255.0e0 AS e, +u8 <= 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 <= '255' AS a, +u1 <= '255' AS au, +i2 <= '255' AS b, +u2 <= '255' AS bu, +i3 <= '255' AS c, +u3 <= '255' AS cu, +i4 <= '255' AS d, +u4 <= '255' AS du, +i8 <= '255' AS e, +u8 <= '255' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 > 255 AS a, +u1 > 255 AS au, +i2 > 255 AS b, +u2 > 255 AS bu, +i3 > 255 AS c, +u3 > 255 AS cu, +i4 > 255 AS d, +u4 > 255 AS du, +i8 > 255 AS e, +u8 > 255 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 > 255.0 AS a, +u1 > 255.0 AS au, +i2 > 255.0 AS b, +u2 > 255.0 AS bu, +i3 > 255.0 AS c, +u3 > 255.0 AS cu, +i4 > 255.0 AS d, +u4 > 255.0 AS du, +i8 > 255.0 AS e, +u8 > 255.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 > 255.0e0 AS a, +u1 > 255.0e0 AS au, +i2 > 255.0e0 AS b, +u2 > 255.0e0 AS bu, +i3 > 255.0e0 AS c, +u3 > 255.0e0 AS cu, +i4 > 255.0e0 AS d, +u4 > 255.0e0 AS du, +i8 > 255.0e0 AS e, +u8 > 255.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 > '255' AS a, +u1 > '255' AS au, +i2 > '255' AS b, +u2 > '255' AS bu, +i3 > '255' AS c, +u3 > '255' AS cu, +i4 > '255' AS d, +u4 > '255' AS du, +i8 > '255' AS e, +u8 > '255' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +set @iv= 32767; +set @dv= 32767.0; +set @fv= 32767.0e0; +set @sv= "32767"; +SELECT i1 = 32767 AS a, +u1 = 32767 AS au, +i2 = 32767 AS b, +u2 = 32767 AS bu, +i3 = 32767 AS c, +u3 = 32767 AS cu, +i4 = 32767 AS d, +u4 = 32767 AS du, +i8 = 32767 AS e, +u8 = 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 = 32767.0 AS a, +u1 = 32767.0 AS au, +i2 = 32767.0 AS b, +u2 = 32767.0 AS bu, +i3 = 32767.0 AS c, +u3 = 32767.0 AS cu, +i4 = 32767.0 AS d, +u4 = 32767.0 AS du, +i8 = 32767.0 AS e, +u8 = 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 = 32767.0e0 AS a, +u1 = 32767.0e0 AS au, +i2 = 32767.0e0 AS b, +u2 = 32767.0e0 AS bu, +i3 = 32767.0e0 AS c, +u3 = 32767.0e0 AS cu, +i4 = 32767.0e0 AS d, +u4 = 32767.0e0 AS du, +i8 = 32767.0e0 AS e, +u8 = 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 = '32767' AS a, +u1 = '32767' AS au, +i2 = '32767' AS b, +u2 = '32767' AS bu, +i3 = '32767' AS c, +u3 = '32767' AS cu, +i4 = '32767' AS d, +u4 = '32767' AS du, +i8 = '32767' AS e, +u8 = '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 0 0 0 0 0 0 0 +SELECT i1 <> 32767 AS a, +u1 <> 32767 AS au, +i2 <> 32767 AS b, +u2 <> 32767 AS bu, +i3 <> 32767 AS c, +u3 <> 32767 AS cu, +i4 <> 32767 AS d, +u4 <> 32767 AS du, +i8 <> 32767 AS e, +u8 <> 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 <> 32767.0 AS a, +u1 <> 32767.0 AS au, +i2 <> 32767.0 AS b, +u2 <> 32767.0 AS bu, +i3 <> 32767.0 AS c, +u3 <> 32767.0 AS cu, +i4 <> 32767.0 AS d, +u4 <> 32767.0 AS du, +i8 <> 32767.0 AS e, +u8 <> 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 <> 32767.0e0 AS a, +u1 <> 32767.0e0 AS au, +i2 <> 32767.0e0 AS b, +u2 <> 32767.0e0 AS bu, +i3 <> 32767.0e0 AS c, +u3 <> 32767.0e0 AS cu, +i4 <> 32767.0e0 AS d, +u4 <> 32767.0e0 AS du, +i8 <> 32767.0e0 AS e, +u8 <> 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 <> '32767' AS a, +u1 <> '32767' AS au, +i2 <> '32767' AS b, +u2 <> '32767' AS bu, +i3 <> '32767' AS c, +u3 <> '32767' AS cu, +i4 <> '32767' AS d, +u4 <> '32767' AS du, +i8 <> '32767' AS e, +u8 <> '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 1 1 1 1 1 1 1 +SELECT i1 < 32767 AS a, +u1 < 32767 AS au, +i2 < 32767 AS b, +u2 < 32767 AS bu, +i3 < 32767 AS c, +u3 < 32767 AS cu, +i4 < 32767 AS d, +u4 < 32767 AS du, +i8 < 32767 AS e, +u8 < 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 < 32767.0 AS a, +u1 < 32767.0 AS au, +i2 < 32767.0 AS b, +u2 < 32767.0 AS bu, +i3 < 32767.0 AS c, +u3 < 32767.0 AS cu, +i4 < 32767.0 AS d, +u4 < 32767.0 AS du, +i8 < 32767.0 AS e, +u8 < 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 < 32767.0e0 AS a, +u1 < 32767.0e0 AS au, +i2 < 32767.0e0 AS b, +u2 < 32767.0e0 AS bu, +i3 < 32767.0e0 AS c, +u3 < 32767.0e0 AS cu, +i4 < 32767.0e0 AS d, +u4 < 32767.0e0 AS du, +i8 < 32767.0e0 AS e, +u8 < 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 < '32767' AS a, +u1 < '32767' AS au, +i2 < '32767' AS b, +u2 < '32767' AS bu, +i3 < '32767' AS c, +u3 < '32767' AS cu, +i4 < '32767' AS d, +u4 < '32767' AS du, +i8 < '32767' AS e, +u8 < '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0 0 0 0 0 +SELECT i1 >= 32767 AS a, +u1 >= 32767 AS au, +i2 >= 32767 AS b, +u2 >= 32767 AS bu, +i3 >= 32767 AS c, +u3 >= 32767 AS cu, +i4 >= 32767 AS d, +u4 >= 32767 AS du, +i8 >= 32767 AS e, +u8 >= 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 >= 32767.0 AS a, +u1 >= 32767.0 AS au, +i2 >= 32767.0 AS b, +u2 >= 32767.0 AS bu, +i3 >= 32767.0 AS c, +u3 >= 32767.0 AS cu, +i4 >= 32767.0 AS d, +u4 >= 32767.0 AS du, +i8 >= 32767.0 AS e, +u8 >= 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 >= 32767.0e0 AS a, +u1 >= 32767.0e0 AS au, +i2 >= 32767.0e0 AS b, +u2 >= 32767.0e0 AS bu, +i3 >= 32767.0e0 AS c, +u3 >= 32767.0e0 AS cu, +i4 >= 32767.0e0 AS d, +u4 >= 32767.0e0 AS du, +i8 >= 32767.0e0 AS e, +u8 >= 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 >= '32767' AS a, +u1 >= '32767' AS au, +i2 >= '32767' AS b, +u2 >= '32767' AS bu, +i3 >= '32767' AS c, +u3 >= '32767' AS cu, +i4 >= '32767' AS d, +u4 >= '32767' AS du, +i8 >= '32767' AS e, +u8 >= '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 1 1 1 1 1 1 1 1 +SELECT i1 <= 32767 AS a, +u1 <= 32767 AS au, +i2 <= 32767 AS b, +u2 <= 32767 AS bu, +i3 <= 32767 AS c, +u3 <= 32767 AS cu, +i4 <= 32767 AS d, +u4 <= 32767 AS du, +i8 <= 32767 AS e, +u8 <= 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 <= 32767.0 AS a, +u1 <= 32767.0 AS au, +i2 <= 32767.0 AS b, +u2 <= 32767.0 AS bu, +i3 <= 32767.0 AS c, +u3 <= 32767.0 AS cu, +i4 <= 32767.0 AS d, +u4 <= 32767.0 AS du, +i8 <= 32767.0 AS e, +u8 <= 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 <= 32767.0e0 AS a, +u1 <= 32767.0e0 AS au, +i2 <= 32767.0e0 AS b, +u2 <= 32767.0e0 AS bu, +i3 <= 32767.0e0 AS c, +u3 <= 32767.0e0 AS cu, +i4 <= 32767.0e0 AS d, +u4 <= 32767.0e0 AS du, +i8 <= 32767.0e0 AS e, +u8 <= 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 <= '32767' AS a, +u1 <= '32767' AS au, +i2 <= '32767' AS b, +u2 <= '32767' AS bu, +i3 <= '32767' AS c, +u3 <= '32767' AS cu, +i4 <= '32767' AS d, +u4 <= '32767' AS du, +i8 <= '32767' AS e, +u8 <= '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 > 32767 AS a, +u1 > 32767 AS au, +i2 > 32767 AS b, +u2 > 32767 AS bu, +i3 > 32767 AS c, +u3 > 32767 AS cu, +i4 > 32767 AS d, +u4 > 32767 AS du, +i8 > 32767 AS e, +u8 > 32767 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 > 32767.0 AS a, +u1 > 32767.0 AS au, +i2 > 32767.0 AS b, +u2 > 32767.0 AS bu, +i3 > 32767.0 AS c, +u3 > 32767.0 AS cu, +i4 > 32767.0 AS d, +u4 > 32767.0 AS du, +i8 > 32767.0 AS e, +u8 > 32767.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 > 32767.0e0 AS a, +u1 > 32767.0e0 AS au, +i2 > 32767.0e0 AS b, +u2 > 32767.0e0 AS bu, +i3 > 32767.0e0 AS c, +u3 > 32767.0e0 AS cu, +i4 > 32767.0e0 AS d, +u4 > 32767.0e0 AS du, +i8 > 32767.0e0 AS e, +u8 > 32767.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 > '32767' AS a, +u1 > '32767' AS au, +i2 > '32767' AS b, +u2 > '32767' AS bu, +i3 > '32767' AS c, +u3 > '32767' AS cu, +i4 > '32767' AS d, +u4 > '32767' AS du, +i8 > '32767' AS e, +u8 > '32767' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +set @iv= 65535; +set @dv= 65535.0; +set @fv= 65535.0e0; +set @sv= "65535"; +SELECT i1 = 65535 AS a, +u1 = 65535 AS au, +i2 = 65535 AS b, +u2 = 65535 AS bu, +i3 = 65535 AS c, +u3 = 65535 AS cu, +i4 = 65535 AS d, +u4 = 65535 AS du, +i8 = 65535 AS e, +u8 = 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 = 65535.0 AS a, +u1 = 65535.0 AS au, +i2 = 65535.0 AS b, +u2 = 65535.0 AS bu, +i3 = 65535.0 AS c, +u3 = 65535.0 AS cu, +i4 = 65535.0 AS d, +u4 = 65535.0 AS du, +i8 = 65535.0 AS e, +u8 = 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 = 65535.0e0 AS a, +u1 = 65535.0e0 AS au, +i2 = 65535.0e0 AS b, +u2 = 65535.0e0 AS bu, +i3 = 65535.0e0 AS c, +u3 = 65535.0e0 AS cu, +i4 = 65535.0e0 AS d, +u4 = 65535.0e0 AS du, +i8 = 65535.0e0 AS e, +u8 = 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 = '65535' AS a, +u1 = '65535' AS au, +i2 = '65535' AS b, +u2 = '65535' AS bu, +i3 = '65535' AS c, +u3 = '65535' AS cu, +i4 = '65535' AS d, +u4 = '65535' AS du, +i8 = '65535' AS e, +u8 = '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 0 0 0 0 0 0 +SELECT i1 <> 65535 AS a, +u1 <> 65535 AS au, +i2 <> 65535 AS b, +u2 <> 65535 AS bu, +i3 <> 65535 AS c, +u3 <> 65535 AS cu, +i4 <> 65535 AS d, +u4 <> 65535 AS du, +i8 <> 65535 AS e, +u8 <> 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 <> 65535.0 AS a, +u1 <> 65535.0 AS au, +i2 <> 65535.0 AS b, +u2 <> 65535.0 AS bu, +i3 <> 65535.0 AS c, +u3 <> 65535.0 AS cu, +i4 <> 65535.0 AS d, +u4 <> 65535.0 AS du, +i8 <> 65535.0 AS e, +u8 <> 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 <> 65535.0e0 AS a, +u1 <> 65535.0e0 AS au, +i2 <> 65535.0e0 AS b, +u2 <> 65535.0e0 AS bu, +i3 <> 65535.0e0 AS c, +u3 <> 65535.0e0 AS cu, +i4 <> 65535.0e0 AS d, +u4 <> 65535.0e0 AS du, +i8 <> 65535.0e0 AS e, +u8 <> 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 <> '65535' AS a, +u1 <> '65535' AS au, +i2 <> '65535' AS b, +u2 <> '65535' AS bu, +i3 <> '65535' AS c, +u3 <> '65535' AS cu, +i4 <> '65535' AS d, +u4 <> '65535' AS du, +i8 <> '65535' AS e, +u8 <> '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 1 1 1 1 1 1 +SELECT i1 < 65535 AS a, +u1 < 65535 AS au, +i2 < 65535 AS b, +u2 < 65535 AS bu, +i3 < 65535 AS c, +u3 < 65535 AS cu, +i4 < 65535 AS d, +u4 < 65535 AS du, +i8 < 65535 AS e, +u8 < 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 < 65535.0 AS a, +u1 < 65535.0 AS au, +i2 < 65535.0 AS b, +u2 < 65535.0 AS bu, +i3 < 65535.0 AS c, +u3 < 65535.0 AS cu, +i4 < 65535.0 AS d, +u4 < 65535.0 AS du, +i8 < 65535.0 AS e, +u8 < 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 < 65535.0e0 AS a, +u1 < 65535.0e0 AS au, +i2 < 65535.0e0 AS b, +u2 < 65535.0e0 AS bu, +i3 < 65535.0e0 AS c, +u3 < 65535.0e0 AS cu, +i4 < 65535.0e0 AS d, +u4 < 65535.0e0 AS du, +i8 < 65535.0e0 AS e, +u8 < 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 < '65535' AS a, +u1 < '65535' AS au, +i2 < '65535' AS b, +u2 < '65535' AS bu, +i3 < '65535' AS c, +u3 < '65535' AS cu, +i4 < '65535' AS d, +u4 < '65535' AS du, +i8 < '65535' AS e, +u8 < '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 0 0 0 0 0 0 0 +SELECT i1 >= 65535 AS a, +u1 >= 65535 AS au, +i2 >= 65535 AS b, +u2 >= 65535 AS bu, +i3 >= 65535 AS c, +u3 >= 65535 AS cu, +i4 >= 65535 AS d, +u4 >= 65535 AS du, +i8 >= 65535 AS e, +u8 >= 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 >= 65535.0 AS a, +u1 >= 65535.0 AS au, +i2 >= 65535.0 AS b, +u2 >= 65535.0 AS bu, +i3 >= 65535.0 AS c, +u3 >= 65535.0 AS cu, +i4 >= 65535.0 AS d, +u4 >= 65535.0 AS du, +i8 >= 65535.0 AS e, +u8 >= 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 >= 65535.0e0 AS a, +u1 >= 65535.0e0 AS au, +i2 >= 65535.0e0 AS b, +u2 >= 65535.0e0 AS bu, +i3 >= 65535.0e0 AS c, +u3 >= 65535.0e0 AS cu, +i4 >= 65535.0e0 AS d, +u4 >= 65535.0e0 AS du, +i8 >= 65535.0e0 AS e, +u8 >= 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 >= '65535' AS a, +u1 >= '65535' AS au, +i2 >= '65535' AS b, +u2 >= '65535' AS bu, +i3 >= '65535' AS c, +u3 >= '65535' AS cu, +i4 >= '65535' AS d, +u4 >= '65535' AS du, +i8 >= '65535' AS e, +u8 >= '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 1 1 1 1 1 1 1 +SELECT i1 <= 65535 AS a, +u1 <= 65535 AS au, +i2 <= 65535 AS b, +u2 <= 65535 AS bu, +i3 <= 65535 AS c, +u3 <= 65535 AS cu, +i4 <= 65535 AS d, +u4 <= 65535 AS du, +i8 <= 65535 AS e, +u8 <= 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 <= 65535.0 AS a, +u1 <= 65535.0 AS au, +i2 <= 65535.0 AS b, +u2 <= 65535.0 AS bu, +i3 <= 65535.0 AS c, +u3 <= 65535.0 AS cu, +i4 <= 65535.0 AS d, +u4 <= 65535.0 AS du, +i8 <= 65535.0 AS e, +u8 <= 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 <= 65535.0e0 AS a, +u1 <= 65535.0e0 AS au, +i2 <= 65535.0e0 AS b, +u2 <= 65535.0e0 AS bu, +i3 <= 65535.0e0 AS c, +u3 <= 65535.0e0 AS cu, +i4 <= 65535.0e0 AS d, +u4 <= 65535.0e0 AS du, +i8 <= 65535.0e0 AS e, +u8 <= 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 <= '65535' AS a, +u1 <= '65535' AS au, +i2 <= '65535' AS b, +u2 <= '65535' AS bu, +i3 <= '65535' AS c, +u3 <= '65535' AS cu, +i4 <= '65535' AS d, +u4 <= '65535' AS du, +i8 <= '65535' AS e, +u8 <= '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 > 65535 AS a, +u1 > 65535 AS au, +i2 > 65535 AS b, +u2 > 65535 AS bu, +i3 > 65535 AS c, +u3 > 65535 AS cu, +i4 > 65535 AS d, +u4 > 65535 AS du, +i8 > 65535 AS e, +u8 > 65535 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 > 65535.0 AS a, +u1 > 65535.0 AS au, +i2 > 65535.0 AS b, +u2 > 65535.0 AS bu, +i3 > 65535.0 AS c, +u3 > 65535.0 AS cu, +i4 > 65535.0 AS d, +u4 > 65535.0 AS du, +i8 > 65535.0 AS e, +u8 > 65535.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 > 65535.0e0 AS a, +u1 > 65535.0e0 AS au, +i2 > 65535.0e0 AS b, +u2 > 65535.0e0 AS bu, +i3 > 65535.0e0 AS c, +u3 > 65535.0e0 AS cu, +i4 > 65535.0e0 AS d, +u4 > 65535.0e0 AS du, +i8 > 65535.0e0 AS e, +u8 > 65535.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 > '65535' AS a, +u1 > '65535' AS au, +i2 > '65535' AS b, +u2 > '65535' AS bu, +i3 > '65535' AS c, +u3 > '65535' AS cu, +i4 > '65535' AS d, +u4 > '65535' AS du, +i8 > '65535' AS e, +u8 > '65535' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +set @iv= 8388607; +set @dv= 8388607.0; +set @fv= 8388607.0e0; +set @sv= "8388607"; +SELECT i1 = 8388607 AS a, +u1 = 8388607 AS au, +i2 = 8388607 AS b, +u2 = 8388607 AS bu, +i3 = 8388607 AS c, +u3 = 8388607 AS cu, +i4 = 8388607 AS d, +u4 = 8388607 AS du, +i8 = 8388607 AS e, +u8 = 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 = 8388607.0 AS a, +u1 = 8388607.0 AS au, +i2 = 8388607.0 AS b, +u2 = 8388607.0 AS bu, +i3 = 8388607.0 AS c, +u3 = 8388607.0 AS cu, +i4 = 8388607.0 AS d, +u4 = 8388607.0 AS du, +i8 = 8388607.0 AS e, +u8 = 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 = 8388607.0e0 AS a, +u1 = 8388607.0e0 AS au, +i2 = 8388607.0e0 AS b, +u2 = 8388607.0e0 AS bu, +i3 = 8388607.0e0 AS c, +u3 = 8388607.0e0 AS cu, +i4 = 8388607.0e0 AS d, +u4 = 8388607.0e0 AS du, +i8 = 8388607.0e0 AS e, +u8 = 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 = '8388607' AS a, +u1 = '8388607' AS au, +i2 = '8388607' AS b, +u2 = '8388607' AS bu, +i3 = '8388607' AS c, +u3 = '8388607' AS cu, +i4 = '8388607' AS d, +u4 = '8388607' AS du, +i8 = '8388607' AS e, +u8 = '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 0 0 0 0 0 +SELECT i1 <> 8388607 AS a, +u1 <> 8388607 AS au, +i2 <> 8388607 AS b, +u2 <> 8388607 AS bu, +i3 <> 8388607 AS c, +u3 <> 8388607 AS cu, +i4 <> 8388607 AS d, +u4 <> 8388607 AS du, +i8 <> 8388607 AS e, +u8 <> 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 <> 8388607.0 AS a, +u1 <> 8388607.0 AS au, +i2 <> 8388607.0 AS b, +u2 <> 8388607.0 AS bu, +i3 <> 8388607.0 AS c, +u3 <> 8388607.0 AS cu, +i4 <> 8388607.0 AS d, +u4 <> 8388607.0 AS du, +i8 <> 8388607.0 AS e, +u8 <> 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 <> 8388607.0e0 AS a, +u1 <> 8388607.0e0 AS au, +i2 <> 8388607.0e0 AS b, +u2 <> 8388607.0e0 AS bu, +i3 <> 8388607.0e0 AS c, +u3 <> 8388607.0e0 AS cu, +i4 <> 8388607.0e0 AS d, +u4 <> 8388607.0e0 AS du, +i8 <> 8388607.0e0 AS e, +u8 <> 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 <> '8388607' AS a, +u1 <> '8388607' AS au, +i2 <> '8388607' AS b, +u2 <> '8388607' AS bu, +i3 <> '8388607' AS c, +u3 <> '8388607' AS cu, +i4 <> '8388607' AS d, +u4 <> '8388607' AS du, +i8 <> '8388607' AS e, +u8 <> '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 1 1 1 1 1 +SELECT i1 < 8388607 AS a, +u1 < 8388607 AS au, +i2 < 8388607 AS b, +u2 < 8388607 AS bu, +i3 < 8388607 AS c, +u3 < 8388607 AS cu, +i4 < 8388607 AS d, +u4 < 8388607 AS du, +i8 < 8388607 AS e, +u8 < 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 < 8388607.0 AS a, +u1 < 8388607.0 AS au, +i2 < 8388607.0 AS b, +u2 < 8388607.0 AS bu, +i3 < 8388607.0 AS c, +u3 < 8388607.0 AS cu, +i4 < 8388607.0 AS d, +u4 < 8388607.0 AS du, +i8 < 8388607.0 AS e, +u8 < 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 < 8388607.0e0 AS a, +u1 < 8388607.0e0 AS au, +i2 < 8388607.0e0 AS b, +u2 < 8388607.0e0 AS bu, +i3 < 8388607.0e0 AS c, +u3 < 8388607.0e0 AS cu, +i4 < 8388607.0e0 AS d, +u4 < 8388607.0e0 AS du, +i8 < 8388607.0e0 AS e, +u8 < 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 < '8388607' AS a, +u1 < '8388607' AS au, +i2 < '8388607' AS b, +u2 < '8388607' AS bu, +i3 < '8388607' AS c, +u3 < '8388607' AS cu, +i4 < '8388607' AS d, +u4 < '8388607' AS du, +i8 < '8388607' AS e, +u8 < '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 0 0 0 0 0 0 +SELECT i1 >= 8388607 AS a, +u1 >= 8388607 AS au, +i2 >= 8388607 AS b, +u2 >= 8388607 AS bu, +i3 >= 8388607 AS c, +u3 >= 8388607 AS cu, +i4 >= 8388607 AS d, +u4 >= 8388607 AS du, +i8 >= 8388607 AS e, +u8 >= 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 >= 8388607.0 AS a, +u1 >= 8388607.0 AS au, +i2 >= 8388607.0 AS b, +u2 >= 8388607.0 AS bu, +i3 >= 8388607.0 AS c, +u3 >= 8388607.0 AS cu, +i4 >= 8388607.0 AS d, +u4 >= 8388607.0 AS du, +i8 >= 8388607.0 AS e, +u8 >= 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 >= 8388607.0e0 AS a, +u1 >= 8388607.0e0 AS au, +i2 >= 8388607.0e0 AS b, +u2 >= 8388607.0e0 AS bu, +i3 >= 8388607.0e0 AS c, +u3 >= 8388607.0e0 AS cu, +i4 >= 8388607.0e0 AS d, +u4 >= 8388607.0e0 AS du, +i8 >= 8388607.0e0 AS e, +u8 >= 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 >= '8388607' AS a, +u1 >= '8388607' AS au, +i2 >= '8388607' AS b, +u2 >= '8388607' AS bu, +i3 >= '8388607' AS c, +u3 >= '8388607' AS cu, +i4 >= '8388607' AS d, +u4 >= '8388607' AS du, +i8 >= '8388607' AS e, +u8 >= '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 1 1 1 1 1 1 +SELECT i1 <= 8388607 AS a, +u1 <= 8388607 AS au, +i2 <= 8388607 AS b, +u2 <= 8388607 AS bu, +i3 <= 8388607 AS c, +u3 <= 8388607 AS cu, +i4 <= 8388607 AS d, +u4 <= 8388607 AS du, +i8 <= 8388607 AS e, +u8 <= 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 <= 8388607.0 AS a, +u1 <= 8388607.0 AS au, +i2 <= 8388607.0 AS b, +u2 <= 8388607.0 AS bu, +i3 <= 8388607.0 AS c, +u3 <= 8388607.0 AS cu, +i4 <= 8388607.0 AS d, +u4 <= 8388607.0 AS du, +i8 <= 8388607.0 AS e, +u8 <= 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 <= 8388607.0e0 AS a, +u1 <= 8388607.0e0 AS au, +i2 <= 8388607.0e0 AS b, +u2 <= 8388607.0e0 AS bu, +i3 <= 8388607.0e0 AS c, +u3 <= 8388607.0e0 AS cu, +i4 <= 8388607.0e0 AS d, +u4 <= 8388607.0e0 AS du, +i8 <= 8388607.0e0 AS e, +u8 <= 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 <= '8388607' AS a, +u1 <= '8388607' AS au, +i2 <= '8388607' AS b, +u2 <= '8388607' AS bu, +i3 <= '8388607' AS c, +u3 <= '8388607' AS cu, +i4 <= '8388607' AS d, +u4 <= '8388607' AS du, +i8 <= '8388607' AS e, +u8 <= '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 > 8388607 AS a, +u1 > 8388607 AS au, +i2 > 8388607 AS b, +u2 > 8388607 AS bu, +i3 > 8388607 AS c, +u3 > 8388607 AS cu, +i4 > 8388607 AS d, +u4 > 8388607 AS du, +i8 > 8388607 AS e, +u8 > 8388607 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 > 8388607.0 AS a, +u1 > 8388607.0 AS au, +i2 > 8388607.0 AS b, +u2 > 8388607.0 AS bu, +i3 > 8388607.0 AS c, +u3 > 8388607.0 AS cu, +i4 > 8388607.0 AS d, +u4 > 8388607.0 AS du, +i8 > 8388607.0 AS e, +u8 > 8388607.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 > 8388607.0e0 AS a, +u1 > 8388607.0e0 AS au, +i2 > 8388607.0e0 AS b, +u2 > 8388607.0e0 AS bu, +i3 > 8388607.0e0 AS c, +u3 > 8388607.0e0 AS cu, +i4 > 8388607.0e0 AS d, +u4 > 8388607.0e0 AS du, +i8 > 8388607.0e0 AS e, +u8 > 8388607.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 > '8388607' AS a, +u1 > '8388607' AS au, +i2 > '8388607' AS b, +u2 > '8388607' AS bu, +i3 > '8388607' AS c, +u3 > '8388607' AS cu, +i4 > '8388607' AS d, +u4 > '8388607' AS du, +i8 > '8388607' AS e, +u8 > '8388607' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +set @iv= 16777215; +set @dv= 16777215.0; +set @fv= 16777215.0e0; +set @sv= "16777215"; +SELECT i1 = 16777215 AS a, +u1 = 16777215 AS au, +i2 = 16777215 AS b, +u2 = 16777215 AS bu, +i3 = 16777215 AS c, +u3 = 16777215 AS cu, +i4 = 16777215 AS d, +u4 = 16777215 AS du, +i8 = 16777215 AS e, +u8 = 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 = 16777215.0 AS a, +u1 = 16777215.0 AS au, +i2 = 16777215.0 AS b, +u2 = 16777215.0 AS bu, +i3 = 16777215.0 AS c, +u3 = 16777215.0 AS cu, +i4 = 16777215.0 AS d, +u4 = 16777215.0 AS du, +i8 = 16777215.0 AS e, +u8 = 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 = 16777215.0e0 AS a, +u1 = 16777215.0e0 AS au, +i2 = 16777215.0e0 AS b, +u2 = 16777215.0e0 AS bu, +i3 = 16777215.0e0 AS c, +u3 = 16777215.0e0 AS cu, +i4 = 16777215.0e0 AS d, +u4 = 16777215.0e0 AS du, +i8 = 16777215.0e0 AS e, +u8 = 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 = '16777215' AS a, +u1 = '16777215' AS au, +i2 = '16777215' AS b, +u2 = '16777215' AS bu, +i3 = '16777215' AS c, +u3 = '16777215' AS cu, +i4 = '16777215' AS d, +u4 = '16777215' AS du, +i8 = '16777215' AS e, +u8 = '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 0 0 0 0 +SELECT i1 <> 16777215 AS a, +u1 <> 16777215 AS au, +i2 <> 16777215 AS b, +u2 <> 16777215 AS bu, +i3 <> 16777215 AS c, +u3 <> 16777215 AS cu, +i4 <> 16777215 AS d, +u4 <> 16777215 AS du, +i8 <> 16777215 AS e, +u8 <> 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 <> 16777215.0 AS a, +u1 <> 16777215.0 AS au, +i2 <> 16777215.0 AS b, +u2 <> 16777215.0 AS bu, +i3 <> 16777215.0 AS c, +u3 <> 16777215.0 AS cu, +i4 <> 16777215.0 AS d, +u4 <> 16777215.0 AS du, +i8 <> 16777215.0 AS e, +u8 <> 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 <> 16777215.0e0 AS a, +u1 <> 16777215.0e0 AS au, +i2 <> 16777215.0e0 AS b, +u2 <> 16777215.0e0 AS bu, +i3 <> 16777215.0e0 AS c, +u3 <> 16777215.0e0 AS cu, +i4 <> 16777215.0e0 AS d, +u4 <> 16777215.0e0 AS du, +i8 <> 16777215.0e0 AS e, +u8 <> 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 <> '16777215' AS a, +u1 <> '16777215' AS au, +i2 <> '16777215' AS b, +u2 <> '16777215' AS bu, +i3 <> '16777215' AS c, +u3 <> '16777215' AS cu, +i4 <> '16777215' AS d, +u4 <> '16777215' AS du, +i8 <> '16777215' AS e, +u8 <> '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 1 1 1 1 +SELECT i1 < 16777215 AS a, +u1 < 16777215 AS au, +i2 < 16777215 AS b, +u2 < 16777215 AS bu, +i3 < 16777215 AS c, +u3 < 16777215 AS cu, +i4 < 16777215 AS d, +u4 < 16777215 AS du, +i8 < 16777215 AS e, +u8 < 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 < 16777215.0 AS a, +u1 < 16777215.0 AS au, +i2 < 16777215.0 AS b, +u2 < 16777215.0 AS bu, +i3 < 16777215.0 AS c, +u3 < 16777215.0 AS cu, +i4 < 16777215.0 AS d, +u4 < 16777215.0 AS du, +i8 < 16777215.0 AS e, +u8 < 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 < 16777215.0e0 AS a, +u1 < 16777215.0e0 AS au, +i2 < 16777215.0e0 AS b, +u2 < 16777215.0e0 AS bu, +i3 < 16777215.0e0 AS c, +u3 < 16777215.0e0 AS cu, +i4 < 16777215.0e0 AS d, +u4 < 16777215.0e0 AS du, +i8 < 16777215.0e0 AS e, +u8 < 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 < '16777215' AS a, +u1 < '16777215' AS au, +i2 < '16777215' AS b, +u2 < '16777215' AS bu, +i3 < '16777215' AS c, +u3 < '16777215' AS cu, +i4 < '16777215' AS d, +u4 < '16777215' AS du, +i8 < '16777215' AS e, +u8 < '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 0 0 0 0 0 +SELECT i1 >= 16777215 AS a, +u1 >= 16777215 AS au, +i2 >= 16777215 AS b, +u2 >= 16777215 AS bu, +i3 >= 16777215 AS c, +u3 >= 16777215 AS cu, +i4 >= 16777215 AS d, +u4 >= 16777215 AS du, +i8 >= 16777215 AS e, +u8 >= 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 >= 16777215.0 AS a, +u1 >= 16777215.0 AS au, +i2 >= 16777215.0 AS b, +u2 >= 16777215.0 AS bu, +i3 >= 16777215.0 AS c, +u3 >= 16777215.0 AS cu, +i4 >= 16777215.0 AS d, +u4 >= 16777215.0 AS du, +i8 >= 16777215.0 AS e, +u8 >= 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 >= 16777215.0e0 AS a, +u1 >= 16777215.0e0 AS au, +i2 >= 16777215.0e0 AS b, +u2 >= 16777215.0e0 AS bu, +i3 >= 16777215.0e0 AS c, +u3 >= 16777215.0e0 AS cu, +i4 >= 16777215.0e0 AS d, +u4 >= 16777215.0e0 AS du, +i8 >= 16777215.0e0 AS e, +u8 >= 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 >= '16777215' AS a, +u1 >= '16777215' AS au, +i2 >= '16777215' AS b, +u2 >= '16777215' AS bu, +i3 >= '16777215' AS c, +u3 >= '16777215' AS cu, +i4 >= '16777215' AS d, +u4 >= '16777215' AS du, +i8 >= '16777215' AS e, +u8 >= '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 1 1 1 1 1 +SELECT i1 <= 16777215 AS a, +u1 <= 16777215 AS au, +i2 <= 16777215 AS b, +u2 <= 16777215 AS bu, +i3 <= 16777215 AS c, +u3 <= 16777215 AS cu, +i4 <= 16777215 AS d, +u4 <= 16777215 AS du, +i8 <= 16777215 AS e, +u8 <= 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 <= 16777215.0 AS a, +u1 <= 16777215.0 AS au, +i2 <= 16777215.0 AS b, +u2 <= 16777215.0 AS bu, +i3 <= 16777215.0 AS c, +u3 <= 16777215.0 AS cu, +i4 <= 16777215.0 AS d, +u4 <= 16777215.0 AS du, +i8 <= 16777215.0 AS e, +u8 <= 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 <= 16777215.0e0 AS a, +u1 <= 16777215.0e0 AS au, +i2 <= 16777215.0e0 AS b, +u2 <= 16777215.0e0 AS bu, +i3 <= 16777215.0e0 AS c, +u3 <= 16777215.0e0 AS cu, +i4 <= 16777215.0e0 AS d, +u4 <= 16777215.0e0 AS du, +i8 <= 16777215.0e0 AS e, +u8 <= 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 <= '16777215' AS a, +u1 <= '16777215' AS au, +i2 <= '16777215' AS b, +u2 <= '16777215' AS bu, +i3 <= '16777215' AS c, +u3 <= '16777215' AS cu, +i4 <= '16777215' AS d, +u4 <= '16777215' AS du, +i8 <= '16777215' AS e, +u8 <= '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 > 16777215 AS a, +u1 > 16777215 AS au, +i2 > 16777215 AS b, +u2 > 16777215 AS bu, +i3 > 16777215 AS c, +u3 > 16777215 AS cu, +i4 > 16777215 AS d, +u4 > 16777215 AS du, +i8 > 16777215 AS e, +u8 > 16777215 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 > 16777215.0 AS a, +u1 > 16777215.0 AS au, +i2 > 16777215.0 AS b, +u2 > 16777215.0 AS bu, +i3 > 16777215.0 AS c, +u3 > 16777215.0 AS cu, +i4 > 16777215.0 AS d, +u4 > 16777215.0 AS du, +i8 > 16777215.0 AS e, +u8 > 16777215.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 > 16777215.0e0 AS a, +u1 > 16777215.0e0 AS au, +i2 > 16777215.0e0 AS b, +u2 > 16777215.0e0 AS bu, +i3 > 16777215.0e0 AS c, +u3 > 16777215.0e0 AS cu, +i4 > 16777215.0e0 AS d, +u4 > 16777215.0e0 AS du, +i8 > 16777215.0e0 AS e, +u8 > 16777215.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 > '16777215' AS a, +u1 > '16777215' AS au, +i2 > '16777215' AS b, +u2 > '16777215' AS bu, +i3 > '16777215' AS c, +u3 > '16777215' AS cu, +i4 > '16777215' AS d, +u4 > '16777215' AS du, +i8 > '16777215' AS e, +u8 > '16777215' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +set @iv= 2147483647; +set @dv= 2147483647.0; +set @fv= 2147483647.0e0; +set @sv= "2147483647"; +SELECT i1 = 2147483647 AS a, +u1 = 2147483647 AS au, +i2 = 2147483647 AS b, +u2 = 2147483647 AS bu, +i3 = 2147483647 AS c, +u3 = 2147483647 AS cu, +i4 = 2147483647 AS d, +u4 = 2147483647 AS du, +i8 = 2147483647 AS e, +u8 = 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 = 2147483647.0 AS a, +u1 = 2147483647.0 AS au, +i2 = 2147483647.0 AS b, +u2 = 2147483647.0 AS bu, +i3 = 2147483647.0 AS c, +u3 = 2147483647.0 AS cu, +i4 = 2147483647.0 AS d, +u4 = 2147483647.0 AS du, +i8 = 2147483647.0 AS e, +u8 = 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 = 2147483647.0e0 AS a, +u1 = 2147483647.0e0 AS au, +i2 = 2147483647.0e0 AS b, +u2 = 2147483647.0e0 AS bu, +i3 = 2147483647.0e0 AS c, +u3 = 2147483647.0e0 AS cu, +i4 = 2147483647.0e0 AS d, +u4 = 2147483647.0e0 AS du, +i8 = 2147483647.0e0 AS e, +u8 = 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 = '2147483647' AS a, +u1 = '2147483647' AS au, +i2 = '2147483647' AS b, +u2 = '2147483647' AS bu, +i3 = '2147483647' AS c, +u3 = '2147483647' AS cu, +i4 = '2147483647' AS d, +u4 = '2147483647' AS du, +i8 = '2147483647' AS e, +u8 = '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 0 0 0 +SELECT i1 <> 2147483647 AS a, +u1 <> 2147483647 AS au, +i2 <> 2147483647 AS b, +u2 <> 2147483647 AS bu, +i3 <> 2147483647 AS c, +u3 <> 2147483647 AS cu, +i4 <> 2147483647 AS d, +u4 <> 2147483647 AS du, +i8 <> 2147483647 AS e, +u8 <> 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 <> 2147483647.0 AS a, +u1 <> 2147483647.0 AS au, +i2 <> 2147483647.0 AS b, +u2 <> 2147483647.0 AS bu, +i3 <> 2147483647.0 AS c, +u3 <> 2147483647.0 AS cu, +i4 <> 2147483647.0 AS d, +u4 <> 2147483647.0 AS du, +i8 <> 2147483647.0 AS e, +u8 <> 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 <> 2147483647.0e0 AS a, +u1 <> 2147483647.0e0 AS au, +i2 <> 2147483647.0e0 AS b, +u2 <> 2147483647.0e0 AS bu, +i3 <> 2147483647.0e0 AS c, +u3 <> 2147483647.0e0 AS cu, +i4 <> 2147483647.0e0 AS d, +u4 <> 2147483647.0e0 AS du, +i8 <> 2147483647.0e0 AS e, +u8 <> 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 <> '2147483647' AS a, +u1 <> '2147483647' AS au, +i2 <> '2147483647' AS b, +u2 <> '2147483647' AS bu, +i3 <> '2147483647' AS c, +u3 <> '2147483647' AS cu, +i4 <> '2147483647' AS d, +u4 <> '2147483647' AS du, +i8 <> '2147483647' AS e, +u8 <> '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 1 1 1 +SELECT i1 < 2147483647 AS a, +u1 < 2147483647 AS au, +i2 < 2147483647 AS b, +u2 < 2147483647 AS bu, +i3 < 2147483647 AS c, +u3 < 2147483647 AS cu, +i4 < 2147483647 AS d, +u4 < 2147483647 AS du, +i8 < 2147483647 AS e, +u8 < 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 < 2147483647.0 AS a, +u1 < 2147483647.0 AS au, +i2 < 2147483647.0 AS b, +u2 < 2147483647.0 AS bu, +i3 < 2147483647.0 AS c, +u3 < 2147483647.0 AS cu, +i4 < 2147483647.0 AS d, +u4 < 2147483647.0 AS du, +i8 < 2147483647.0 AS e, +u8 < 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 < 2147483647.0e0 AS a, +u1 < 2147483647.0e0 AS au, +i2 < 2147483647.0e0 AS b, +u2 < 2147483647.0e0 AS bu, +i3 < 2147483647.0e0 AS c, +u3 < 2147483647.0e0 AS cu, +i4 < 2147483647.0e0 AS d, +u4 < 2147483647.0e0 AS du, +i8 < 2147483647.0e0 AS e, +u8 < 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 < '2147483647' AS a, +u1 < '2147483647' AS au, +i2 < '2147483647' AS b, +u2 < '2147483647' AS bu, +i3 < '2147483647' AS c, +u3 < '2147483647' AS cu, +i4 < '2147483647' AS d, +u4 < '2147483647' AS du, +i8 < '2147483647' AS e, +u8 < '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 0 0 0 0 +SELECT i1 >= 2147483647 AS a, +u1 >= 2147483647 AS au, +i2 >= 2147483647 AS b, +u2 >= 2147483647 AS bu, +i3 >= 2147483647 AS c, +u3 >= 2147483647 AS cu, +i4 >= 2147483647 AS d, +u4 >= 2147483647 AS du, +i8 >= 2147483647 AS e, +u8 >= 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 >= 2147483647.0 AS a, +u1 >= 2147483647.0 AS au, +i2 >= 2147483647.0 AS b, +u2 >= 2147483647.0 AS bu, +i3 >= 2147483647.0 AS c, +u3 >= 2147483647.0 AS cu, +i4 >= 2147483647.0 AS d, +u4 >= 2147483647.0 AS du, +i8 >= 2147483647.0 AS e, +u8 >= 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 >= 2147483647.0e0 AS a, +u1 >= 2147483647.0e0 AS au, +i2 >= 2147483647.0e0 AS b, +u2 >= 2147483647.0e0 AS bu, +i3 >= 2147483647.0e0 AS c, +u3 >= 2147483647.0e0 AS cu, +i4 >= 2147483647.0e0 AS d, +u4 >= 2147483647.0e0 AS du, +i8 >= 2147483647.0e0 AS e, +u8 >= 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 >= '2147483647' AS a, +u1 >= '2147483647' AS au, +i2 >= '2147483647' AS b, +u2 >= '2147483647' AS bu, +i3 >= '2147483647' AS c, +u3 >= '2147483647' AS cu, +i4 >= '2147483647' AS d, +u4 >= '2147483647' AS du, +i8 >= '2147483647' AS e, +u8 >= '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 1 1 1 1 +SELECT i1 <= 2147483647 AS a, +u1 <= 2147483647 AS au, +i2 <= 2147483647 AS b, +u2 <= 2147483647 AS bu, +i3 <= 2147483647 AS c, +u3 <= 2147483647 AS cu, +i4 <= 2147483647 AS d, +u4 <= 2147483647 AS du, +i8 <= 2147483647 AS e, +u8 <= 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 <= 2147483647.0 AS a, +u1 <= 2147483647.0 AS au, +i2 <= 2147483647.0 AS b, +u2 <= 2147483647.0 AS bu, +i3 <= 2147483647.0 AS c, +u3 <= 2147483647.0 AS cu, +i4 <= 2147483647.0 AS d, +u4 <= 2147483647.0 AS du, +i8 <= 2147483647.0 AS e, +u8 <= 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 <= 2147483647.0e0 AS a, +u1 <= 2147483647.0e0 AS au, +i2 <= 2147483647.0e0 AS b, +u2 <= 2147483647.0e0 AS bu, +i3 <= 2147483647.0e0 AS c, +u3 <= 2147483647.0e0 AS cu, +i4 <= 2147483647.0e0 AS d, +u4 <= 2147483647.0e0 AS du, +i8 <= 2147483647.0e0 AS e, +u8 <= 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 <= '2147483647' AS a, +u1 <= '2147483647' AS au, +i2 <= '2147483647' AS b, +u2 <= '2147483647' AS bu, +i3 <= '2147483647' AS c, +u3 <= '2147483647' AS cu, +i4 <= '2147483647' AS d, +u4 <= '2147483647' AS du, +i8 <= '2147483647' AS e, +u8 <= '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 > 2147483647 AS a, +u1 > 2147483647 AS au, +i2 > 2147483647 AS b, +u2 > 2147483647 AS bu, +i3 > 2147483647 AS c, +u3 > 2147483647 AS cu, +i4 > 2147483647 AS d, +u4 > 2147483647 AS du, +i8 > 2147483647 AS e, +u8 > 2147483647 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 > 2147483647.0 AS a, +u1 > 2147483647.0 AS au, +i2 > 2147483647.0 AS b, +u2 > 2147483647.0 AS bu, +i3 > 2147483647.0 AS c, +u3 > 2147483647.0 AS cu, +i4 > 2147483647.0 AS d, +u4 > 2147483647.0 AS du, +i8 > 2147483647.0 AS e, +u8 > 2147483647.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 > 2147483647.0e0 AS a, +u1 > 2147483647.0e0 AS au, +i2 > 2147483647.0e0 AS b, +u2 > 2147483647.0e0 AS bu, +i3 > 2147483647.0e0 AS c, +u3 > 2147483647.0e0 AS cu, +i4 > 2147483647.0e0 AS d, +u4 > 2147483647.0e0 AS du, +i8 > 2147483647.0e0 AS e, +u8 > 2147483647.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 > '2147483647' AS a, +u1 > '2147483647' AS au, +i2 > '2147483647' AS b, +u2 > '2147483647' AS bu, +i3 > '2147483647' AS c, +u3 > '2147483647' AS cu, +i4 > '2147483647' AS d, +u4 > '2147483647' AS du, +i8 > '2147483647' AS e, +u8 > '2147483647' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +set @iv= 4294967295; +set @dv= 4294967295.0; +set @fv= 4294967295.0e0; +set @sv= "4294967295"; +SELECT i1 = 4294967295 AS a, +u1 = 4294967295 AS au, +i2 = 4294967295 AS b, +u2 = 4294967295 AS bu, +i3 = 4294967295 AS c, +u3 = 4294967295 AS cu, +i4 = 4294967295 AS d, +u4 = 4294967295 AS du, +i8 = 4294967295 AS e, +u8 = 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 = 4294967295.0 AS a, +u1 = 4294967295.0 AS au, +i2 = 4294967295.0 AS b, +u2 = 4294967295.0 AS bu, +i3 = 4294967295.0 AS c, +u3 = 4294967295.0 AS cu, +i4 = 4294967295.0 AS d, +u4 = 4294967295.0 AS du, +i8 = 4294967295.0 AS e, +u8 = 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 = 4294967295.0e0 AS a, +u1 = 4294967295.0e0 AS au, +i2 = 4294967295.0e0 AS b, +u2 = 4294967295.0e0 AS bu, +i3 = 4294967295.0e0 AS c, +u3 = 4294967295.0e0 AS cu, +i4 = 4294967295.0e0 AS d, +u4 = 4294967295.0e0 AS du, +i8 = 4294967295.0e0 AS e, +u8 = 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 = '4294967295' AS a, +u1 = '4294967295' AS au, +i2 = '4294967295' AS b, +u2 = '4294967295' AS bu, +i3 = '4294967295' AS c, +u3 = '4294967295' AS cu, +i4 = '4294967295' AS d, +u4 = '4294967295' AS du, +i8 = '4294967295' AS e, +u8 = '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 0 0 +SELECT i1 <> 4294967295 AS a, +u1 <> 4294967295 AS au, +i2 <> 4294967295 AS b, +u2 <> 4294967295 AS bu, +i3 <> 4294967295 AS c, +u3 <> 4294967295 AS cu, +i4 <> 4294967295 AS d, +u4 <> 4294967295 AS du, +i8 <> 4294967295 AS e, +u8 <> 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 <> 4294967295.0 AS a, +u1 <> 4294967295.0 AS au, +i2 <> 4294967295.0 AS b, +u2 <> 4294967295.0 AS bu, +i3 <> 4294967295.0 AS c, +u3 <> 4294967295.0 AS cu, +i4 <> 4294967295.0 AS d, +u4 <> 4294967295.0 AS du, +i8 <> 4294967295.0 AS e, +u8 <> 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 <> 4294967295.0e0 AS a, +u1 <> 4294967295.0e0 AS au, +i2 <> 4294967295.0e0 AS b, +u2 <> 4294967295.0e0 AS bu, +i3 <> 4294967295.0e0 AS c, +u3 <> 4294967295.0e0 AS cu, +i4 <> 4294967295.0e0 AS d, +u4 <> 4294967295.0e0 AS du, +i8 <> 4294967295.0e0 AS e, +u8 <> 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 <> '4294967295' AS a, +u1 <> '4294967295' AS au, +i2 <> '4294967295' AS b, +u2 <> '4294967295' AS bu, +i3 <> '4294967295' AS c, +u3 <> '4294967295' AS cu, +i4 <> '4294967295' AS d, +u4 <> '4294967295' AS du, +i8 <> '4294967295' AS e, +u8 <> '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 1 1 +SELECT i1 < 4294967295 AS a, +u1 < 4294967295 AS au, +i2 < 4294967295 AS b, +u2 < 4294967295 AS bu, +i3 < 4294967295 AS c, +u3 < 4294967295 AS cu, +i4 < 4294967295 AS d, +u4 < 4294967295 AS du, +i8 < 4294967295 AS e, +u8 < 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 < 4294967295.0 AS a, +u1 < 4294967295.0 AS au, +i2 < 4294967295.0 AS b, +u2 < 4294967295.0 AS bu, +i3 < 4294967295.0 AS c, +u3 < 4294967295.0 AS cu, +i4 < 4294967295.0 AS d, +u4 < 4294967295.0 AS du, +i8 < 4294967295.0 AS e, +u8 < 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 < 4294967295.0e0 AS a, +u1 < 4294967295.0e0 AS au, +i2 < 4294967295.0e0 AS b, +u2 < 4294967295.0e0 AS bu, +i3 < 4294967295.0e0 AS c, +u3 < 4294967295.0e0 AS cu, +i4 < 4294967295.0e0 AS d, +u4 < 4294967295.0e0 AS du, +i8 < 4294967295.0e0 AS e, +u8 < 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 < '4294967295' AS a, +u1 < '4294967295' AS au, +i2 < '4294967295' AS b, +u2 < '4294967295' AS bu, +i3 < '4294967295' AS c, +u3 < '4294967295' AS cu, +i4 < '4294967295' AS d, +u4 < '4294967295' AS du, +i8 < '4294967295' AS e, +u8 < '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 0 0 0 +SELECT i1 >= 4294967295 AS a, +u1 >= 4294967295 AS au, +i2 >= 4294967295 AS b, +u2 >= 4294967295 AS bu, +i3 >= 4294967295 AS c, +u3 >= 4294967295 AS cu, +i4 >= 4294967295 AS d, +u4 >= 4294967295 AS du, +i8 >= 4294967295 AS e, +u8 >= 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 >= 4294967295.0 AS a, +u1 >= 4294967295.0 AS au, +i2 >= 4294967295.0 AS b, +u2 >= 4294967295.0 AS bu, +i3 >= 4294967295.0 AS c, +u3 >= 4294967295.0 AS cu, +i4 >= 4294967295.0 AS d, +u4 >= 4294967295.0 AS du, +i8 >= 4294967295.0 AS e, +u8 >= 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 >= 4294967295.0e0 AS a, +u1 >= 4294967295.0e0 AS au, +i2 >= 4294967295.0e0 AS b, +u2 >= 4294967295.0e0 AS bu, +i3 >= 4294967295.0e0 AS c, +u3 >= 4294967295.0e0 AS cu, +i4 >= 4294967295.0e0 AS d, +u4 >= 4294967295.0e0 AS du, +i8 >= 4294967295.0e0 AS e, +u8 >= 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 >= '4294967295' AS a, +u1 >= '4294967295' AS au, +i2 >= '4294967295' AS b, +u2 >= '4294967295' AS bu, +i3 >= '4294967295' AS c, +u3 >= '4294967295' AS cu, +i4 >= '4294967295' AS d, +u4 >= '4294967295' AS du, +i8 >= '4294967295' AS e, +u8 >= '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 1 1 1 +SELECT i1 <= 4294967295 AS a, +u1 <= 4294967295 AS au, +i2 <= 4294967295 AS b, +u2 <= 4294967295 AS bu, +i3 <= 4294967295 AS c, +u3 <= 4294967295 AS cu, +i4 <= 4294967295 AS d, +u4 <= 4294967295 AS du, +i8 <= 4294967295 AS e, +u8 <= 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 <= 4294967295.0 AS a, +u1 <= 4294967295.0 AS au, +i2 <= 4294967295.0 AS b, +u2 <= 4294967295.0 AS bu, +i3 <= 4294967295.0 AS c, +u3 <= 4294967295.0 AS cu, +i4 <= 4294967295.0 AS d, +u4 <= 4294967295.0 AS du, +i8 <= 4294967295.0 AS e, +u8 <= 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 <= 4294967295.0e0 AS a, +u1 <= 4294967295.0e0 AS au, +i2 <= 4294967295.0e0 AS b, +u2 <= 4294967295.0e0 AS bu, +i3 <= 4294967295.0e0 AS c, +u3 <= 4294967295.0e0 AS cu, +i4 <= 4294967295.0e0 AS d, +u4 <= 4294967295.0e0 AS du, +i8 <= 4294967295.0e0 AS e, +u8 <= 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 <= '4294967295' AS a, +u1 <= '4294967295' AS au, +i2 <= '4294967295' AS b, +u2 <= '4294967295' AS bu, +i3 <= '4294967295' AS c, +u3 <= '4294967295' AS cu, +i4 <= '4294967295' AS d, +u4 <= '4294967295' AS du, +i8 <= '4294967295' AS e, +u8 <= '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 > 4294967295 AS a, +u1 > 4294967295 AS au, +i2 > 4294967295 AS b, +u2 > 4294967295 AS bu, +i3 > 4294967295 AS c, +u3 > 4294967295 AS cu, +i4 > 4294967295 AS d, +u4 > 4294967295 AS du, +i8 > 4294967295 AS e, +u8 > 4294967295 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 > 4294967295.0 AS a, +u1 > 4294967295.0 AS au, +i2 > 4294967295.0 AS b, +u2 > 4294967295.0 AS bu, +i3 > 4294967295.0 AS c, +u3 > 4294967295.0 AS cu, +i4 > 4294967295.0 AS d, +u4 > 4294967295.0 AS du, +i8 > 4294967295.0 AS e, +u8 > 4294967295.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 > 4294967295.0e0 AS a, +u1 > 4294967295.0e0 AS au, +i2 > 4294967295.0e0 AS b, +u2 > 4294967295.0e0 AS bu, +i3 > 4294967295.0e0 AS c, +u3 > 4294967295.0e0 AS cu, +i4 > 4294967295.0e0 AS d, +u4 > 4294967295.0e0 AS du, +i8 > 4294967295.0e0 AS e, +u8 > 4294967295.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 > '4294967295' AS a, +u1 > '4294967295' AS au, +i2 > '4294967295' AS b, +u2 > '4294967295' AS bu, +i3 > '4294967295' AS c, +u3 > '4294967295' AS cu, +i4 > '4294967295' AS d, +u4 > '4294967295' AS du, +i8 > '4294967295' AS e, +u8 > '4294967295' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +set @iv= 9223372036854775807; +set @dv= 9223372036854775807.0; +set @fv= 9223372036854775807.0e0; +set @sv= "9223372036854775807"; +SELECT i1 = 9223372036854775807 AS a, +u1 = 9223372036854775807 AS au, +i2 = 9223372036854775807 AS b, +u2 = 9223372036854775807 AS bu, +i3 = 9223372036854775807 AS c, +u3 = 9223372036854775807 AS cu, +i4 = 9223372036854775807 AS d, +u4 = 9223372036854775807 AS du, +i8 = 9223372036854775807 AS e, +u8 = 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = 9223372036854775807.0 AS a, +u1 = 9223372036854775807.0 AS au, +i2 = 9223372036854775807.0 AS b, +u2 = 9223372036854775807.0 AS bu, +i3 = 9223372036854775807.0 AS c, +u3 = 9223372036854775807.0 AS cu, +i4 = 9223372036854775807.0 AS d, +u4 = 9223372036854775807.0 AS du, +i8 = 9223372036854775807.0 AS e, +u8 = 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = 9223372036854775807.0e0 AS a, +u1 = 9223372036854775807.0e0 AS au, +i2 = 9223372036854775807.0e0 AS b, +u2 = 9223372036854775807.0e0 AS bu, +i3 = 9223372036854775807.0e0 AS c, +u3 = 9223372036854775807.0e0 AS cu, +i4 = 9223372036854775807.0e0 AS d, +u4 = 9223372036854775807.0e0 AS du, +i8 = 9223372036854775807.0e0 AS e, +u8 = 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = '9223372036854775807' AS a, +u1 = '9223372036854775807' AS au, +i2 = '9223372036854775807' AS b, +u2 = '9223372036854775807' AS bu, +i3 = '9223372036854775807' AS c, +u3 = '9223372036854775807' AS cu, +i4 = '9223372036854775807' AS d, +u4 = '9223372036854775807' AS du, +i8 = '9223372036854775807' AS e, +u8 = '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 <> 9223372036854775807 AS a, +u1 <> 9223372036854775807 AS au, +i2 <> 9223372036854775807 AS b, +u2 <> 9223372036854775807 AS bu, +i3 <> 9223372036854775807 AS c, +u3 <> 9223372036854775807 AS cu, +i4 <> 9223372036854775807 AS d, +u4 <> 9223372036854775807 AS du, +i8 <> 9223372036854775807 AS e, +u8 <> 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> 9223372036854775807.0 AS a, +u1 <> 9223372036854775807.0 AS au, +i2 <> 9223372036854775807.0 AS b, +u2 <> 9223372036854775807.0 AS bu, +i3 <> 9223372036854775807.0 AS c, +u3 <> 9223372036854775807.0 AS cu, +i4 <> 9223372036854775807.0 AS d, +u4 <> 9223372036854775807.0 AS du, +i8 <> 9223372036854775807.0 AS e, +u8 <> 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> 9223372036854775807.0e0 AS a, +u1 <> 9223372036854775807.0e0 AS au, +i2 <> 9223372036854775807.0e0 AS b, +u2 <> 9223372036854775807.0e0 AS bu, +i3 <> 9223372036854775807.0e0 AS c, +u3 <> 9223372036854775807.0e0 AS cu, +i4 <> 9223372036854775807.0e0 AS d, +u4 <> 9223372036854775807.0e0 AS du, +i8 <> 9223372036854775807.0e0 AS e, +u8 <> 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> '9223372036854775807' AS a, +u1 <> '9223372036854775807' AS au, +i2 <> '9223372036854775807' AS b, +u2 <> '9223372036854775807' AS bu, +i3 <> '9223372036854775807' AS c, +u3 <> '9223372036854775807' AS cu, +i4 <> '9223372036854775807' AS d, +u4 <> '9223372036854775807' AS du, +i8 <> '9223372036854775807' AS e, +u8 <> '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 < 9223372036854775807 AS a, +u1 < 9223372036854775807 AS au, +i2 < 9223372036854775807 AS b, +u2 < 9223372036854775807 AS bu, +i3 < 9223372036854775807 AS c, +u3 < 9223372036854775807 AS cu, +i4 < 9223372036854775807 AS d, +u4 < 9223372036854775807 AS du, +i8 < 9223372036854775807 AS e, +u8 < 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < 9223372036854775807.0 AS a, +u1 < 9223372036854775807.0 AS au, +i2 < 9223372036854775807.0 AS b, +u2 < 9223372036854775807.0 AS bu, +i3 < 9223372036854775807.0 AS c, +u3 < 9223372036854775807.0 AS cu, +i4 < 9223372036854775807.0 AS d, +u4 < 9223372036854775807.0 AS du, +i8 < 9223372036854775807.0 AS e, +u8 < 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < 9223372036854775807.0e0 AS a, +u1 < 9223372036854775807.0e0 AS au, +i2 < 9223372036854775807.0e0 AS b, +u2 < 9223372036854775807.0e0 AS bu, +i3 < 9223372036854775807.0e0 AS c, +u3 < 9223372036854775807.0e0 AS cu, +i4 < 9223372036854775807.0e0 AS d, +u4 < 9223372036854775807.0e0 AS du, +i8 < 9223372036854775807.0e0 AS e, +u8 < 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < '9223372036854775807' AS a, +u1 < '9223372036854775807' AS au, +i2 < '9223372036854775807' AS b, +u2 < '9223372036854775807' AS bu, +i3 < '9223372036854775807' AS c, +u3 < '9223372036854775807' AS cu, +i4 < '9223372036854775807' AS d, +u4 < '9223372036854775807' AS du, +i8 < '9223372036854775807' AS e, +u8 < '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 >= 9223372036854775807 AS a, +u1 >= 9223372036854775807 AS au, +i2 >= 9223372036854775807 AS b, +u2 >= 9223372036854775807 AS bu, +i3 >= 9223372036854775807 AS c, +u3 >= 9223372036854775807 AS cu, +i4 >= 9223372036854775807 AS d, +u4 >= 9223372036854775807 AS du, +i8 >= 9223372036854775807 AS e, +u8 >= 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= 9223372036854775807.0 AS a, +u1 >= 9223372036854775807.0 AS au, +i2 >= 9223372036854775807.0 AS b, +u2 >= 9223372036854775807.0 AS bu, +i3 >= 9223372036854775807.0 AS c, +u3 >= 9223372036854775807.0 AS cu, +i4 >= 9223372036854775807.0 AS d, +u4 >= 9223372036854775807.0 AS du, +i8 >= 9223372036854775807.0 AS e, +u8 >= 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= 9223372036854775807.0e0 AS a, +u1 >= 9223372036854775807.0e0 AS au, +i2 >= 9223372036854775807.0e0 AS b, +u2 >= 9223372036854775807.0e0 AS bu, +i3 >= 9223372036854775807.0e0 AS c, +u3 >= 9223372036854775807.0e0 AS cu, +i4 >= 9223372036854775807.0e0 AS d, +u4 >= 9223372036854775807.0e0 AS du, +i8 >= 9223372036854775807.0e0 AS e, +u8 >= 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= '9223372036854775807' AS a, +u1 >= '9223372036854775807' AS au, +i2 >= '9223372036854775807' AS b, +u2 >= '9223372036854775807' AS bu, +i3 >= '9223372036854775807' AS c, +u3 >= '9223372036854775807' AS cu, +i4 >= '9223372036854775807' AS d, +u4 >= '9223372036854775807' AS du, +i8 >= '9223372036854775807' AS e, +u8 >= '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 <= 9223372036854775807 AS a, +u1 <= 9223372036854775807 AS au, +i2 <= 9223372036854775807 AS b, +u2 <= 9223372036854775807 AS bu, +i3 <= 9223372036854775807 AS c, +u3 <= 9223372036854775807 AS cu, +i4 <= 9223372036854775807 AS d, +u4 <= 9223372036854775807 AS du, +i8 <= 9223372036854775807 AS e, +u8 <= 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775807.0 AS a, +u1 <= 9223372036854775807.0 AS au, +i2 <= 9223372036854775807.0 AS b, +u2 <= 9223372036854775807.0 AS bu, +i3 <= 9223372036854775807.0 AS c, +u3 <= 9223372036854775807.0 AS cu, +i4 <= 9223372036854775807.0 AS d, +u4 <= 9223372036854775807.0 AS du, +i8 <= 9223372036854775807.0 AS e, +u8 <= 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775807.0e0 AS a, +u1 <= 9223372036854775807.0e0 AS au, +i2 <= 9223372036854775807.0e0 AS b, +u2 <= 9223372036854775807.0e0 AS bu, +i3 <= 9223372036854775807.0e0 AS c, +u3 <= 9223372036854775807.0e0 AS cu, +i4 <= 9223372036854775807.0e0 AS d, +u4 <= 9223372036854775807.0e0 AS du, +i8 <= 9223372036854775807.0e0 AS e, +u8 <= 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= '9223372036854775807' AS a, +u1 <= '9223372036854775807' AS au, +i2 <= '9223372036854775807' AS b, +u2 <= '9223372036854775807' AS bu, +i3 <= '9223372036854775807' AS c, +u3 <= '9223372036854775807' AS cu, +i4 <= '9223372036854775807' AS d, +u4 <= '9223372036854775807' AS du, +i8 <= '9223372036854775807' AS e, +u8 <= '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 > 9223372036854775807 AS a, +u1 > 9223372036854775807 AS au, +i2 > 9223372036854775807 AS b, +u2 > 9223372036854775807 AS bu, +i3 > 9223372036854775807 AS c, +u3 > 9223372036854775807 AS cu, +i4 > 9223372036854775807 AS d, +u4 > 9223372036854775807 AS du, +i8 > 9223372036854775807 AS e, +u8 > 9223372036854775807 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775807.0 AS a, +u1 > 9223372036854775807.0 AS au, +i2 > 9223372036854775807.0 AS b, +u2 > 9223372036854775807.0 AS bu, +i3 > 9223372036854775807.0 AS c, +u3 > 9223372036854775807.0 AS cu, +i4 > 9223372036854775807.0 AS d, +u4 > 9223372036854775807.0 AS du, +i8 > 9223372036854775807.0 AS e, +u8 > 9223372036854775807.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775807.0e0 AS a, +u1 > 9223372036854775807.0e0 AS au, +i2 > 9223372036854775807.0e0 AS b, +u2 > 9223372036854775807.0e0 AS bu, +i3 > 9223372036854775807.0e0 AS c, +u3 > 9223372036854775807.0e0 AS cu, +i4 > 9223372036854775807.0e0 AS d, +u4 > 9223372036854775807.0e0 AS du, +i8 > 9223372036854775807.0e0 AS e, +u8 > 9223372036854775807.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > '9223372036854775807' AS a, +u1 > '9223372036854775807' AS au, +i2 > '9223372036854775807' AS b, +u2 > '9223372036854775807' AS bu, +i3 > '9223372036854775807' AS c, +u3 > '9223372036854775807' AS cu, +i4 > '9223372036854775807' AS d, +u4 > '9223372036854775807' AS du, +i8 > '9223372036854775807' AS e, +u8 > '9223372036854775807' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +set @iv= 9223372036854775808; +set @dv= 9223372036854775808.0; +set @fv= 9223372036854775808.0e0; +set @sv= "9223372036854775808"; +SELECT i1 = 9223372036854775808 AS a, +u1 = 9223372036854775808 AS au, +i2 = 9223372036854775808 AS b, +u2 = 9223372036854775808 AS bu, +i3 = 9223372036854775808 AS c, +u3 = 9223372036854775808 AS cu, +i4 = 9223372036854775808 AS d, +u4 = 9223372036854775808 AS du, +i8 = 9223372036854775808 AS e, +u8 = 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 9223372036854775808.0 AS a, +u1 = 9223372036854775808.0 AS au, +i2 = 9223372036854775808.0 AS b, +u2 = 9223372036854775808.0 AS bu, +i3 = 9223372036854775808.0 AS c, +u3 = 9223372036854775808.0 AS cu, +i4 = 9223372036854775808.0 AS d, +u4 = 9223372036854775808.0 AS du, +i8 = 9223372036854775808.0 AS e, +u8 = 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 9223372036854775808.0e0 AS a, +u1 = 9223372036854775808.0e0 AS au, +i2 = 9223372036854775808.0e0 AS b, +u2 = 9223372036854775808.0e0 AS bu, +i3 = 9223372036854775808.0e0 AS c, +u3 = 9223372036854775808.0e0 AS cu, +i4 = 9223372036854775808.0e0 AS d, +u4 = 9223372036854775808.0e0 AS du, +i8 = 9223372036854775808.0e0 AS e, +u8 = 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 = '9223372036854775808' AS a, +u1 = '9223372036854775808' AS au, +i2 = '9223372036854775808' AS b, +u2 = '9223372036854775808' AS bu, +i3 = '9223372036854775808' AS c, +u3 = '9223372036854775808' AS cu, +i4 = '9223372036854775808' AS d, +u4 = '9223372036854775808' AS du, +i8 = '9223372036854775808' AS e, +u8 = '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 +SELECT i1 <> 9223372036854775808 AS a, +u1 <> 9223372036854775808 AS au, +i2 <> 9223372036854775808 AS b, +u2 <> 9223372036854775808 AS bu, +i3 <> 9223372036854775808 AS c, +u3 <> 9223372036854775808 AS cu, +i4 <> 9223372036854775808 AS d, +u4 <> 9223372036854775808 AS du, +i8 <> 9223372036854775808 AS e, +u8 <> 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 9223372036854775808.0 AS a, +u1 <> 9223372036854775808.0 AS au, +i2 <> 9223372036854775808.0 AS b, +u2 <> 9223372036854775808.0 AS bu, +i3 <> 9223372036854775808.0 AS c, +u3 <> 9223372036854775808.0 AS cu, +i4 <> 9223372036854775808.0 AS d, +u4 <> 9223372036854775808.0 AS du, +i8 <> 9223372036854775808.0 AS e, +u8 <> 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 9223372036854775808.0e0 AS a, +u1 <> 9223372036854775808.0e0 AS au, +i2 <> 9223372036854775808.0e0 AS b, +u2 <> 9223372036854775808.0e0 AS bu, +i3 <> 9223372036854775808.0e0 AS c, +u3 <> 9223372036854775808.0e0 AS cu, +i4 <> 9223372036854775808.0e0 AS d, +u4 <> 9223372036854775808.0e0 AS du, +i8 <> 9223372036854775808.0e0 AS e, +u8 <> 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 <> '9223372036854775808' AS a, +u1 <> '9223372036854775808' AS au, +i2 <> '9223372036854775808' AS b, +u2 <> '9223372036854775808' AS bu, +i3 <> '9223372036854775808' AS c, +u3 <> '9223372036854775808' AS cu, +i4 <> '9223372036854775808' AS d, +u4 <> '9223372036854775808' AS du, +i8 <> '9223372036854775808' AS e, +u8 <> '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 1 +SELECT i1 < 9223372036854775808 AS a, +u1 < 9223372036854775808 AS au, +i2 < 9223372036854775808 AS b, +u2 < 9223372036854775808 AS bu, +i3 < 9223372036854775808 AS c, +u3 < 9223372036854775808 AS cu, +i4 < 9223372036854775808 AS d, +u4 < 9223372036854775808 AS du, +i8 < 9223372036854775808 AS e, +u8 < 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 9223372036854775808.0 AS a, +u1 < 9223372036854775808.0 AS au, +i2 < 9223372036854775808.0 AS b, +u2 < 9223372036854775808.0 AS bu, +i3 < 9223372036854775808.0 AS c, +u3 < 9223372036854775808.0 AS cu, +i4 < 9223372036854775808.0 AS d, +u4 < 9223372036854775808.0 AS du, +i8 < 9223372036854775808.0 AS e, +u8 < 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 9223372036854775808.0e0 AS a, +u1 < 9223372036854775808.0e0 AS au, +i2 < 9223372036854775808.0e0 AS b, +u2 < 9223372036854775808.0e0 AS bu, +i3 < 9223372036854775808.0e0 AS c, +u3 < 9223372036854775808.0e0 AS cu, +i4 < 9223372036854775808.0e0 AS d, +u4 < 9223372036854775808.0e0 AS du, +i8 < 9223372036854775808.0e0 AS e, +u8 < 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 < '9223372036854775808' AS a, +u1 < '9223372036854775808' AS au, +i2 < '9223372036854775808' AS b, +u2 < '9223372036854775808' AS bu, +i3 < '9223372036854775808' AS c, +u3 < '9223372036854775808' AS cu, +i4 < '9223372036854775808' AS d, +u4 < '9223372036854775808' AS du, +i8 < '9223372036854775808' AS e, +u8 < '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 0 0 +SELECT i1 >= 9223372036854775808 AS a, +u1 >= 9223372036854775808 AS au, +i2 >= 9223372036854775808 AS b, +u2 >= 9223372036854775808 AS bu, +i3 >= 9223372036854775808 AS c, +u3 >= 9223372036854775808 AS cu, +i4 >= 9223372036854775808 AS d, +u4 >= 9223372036854775808 AS du, +i8 >= 9223372036854775808 AS e, +u8 >= 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 9223372036854775808.0 AS a, +u1 >= 9223372036854775808.0 AS au, +i2 >= 9223372036854775808.0 AS b, +u2 >= 9223372036854775808.0 AS bu, +i3 >= 9223372036854775808.0 AS c, +u3 >= 9223372036854775808.0 AS cu, +i4 >= 9223372036854775808.0 AS d, +u4 >= 9223372036854775808.0 AS du, +i8 >= 9223372036854775808.0 AS e, +u8 >= 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 9223372036854775808.0e0 AS a, +u1 >= 9223372036854775808.0e0 AS au, +i2 >= 9223372036854775808.0e0 AS b, +u2 >= 9223372036854775808.0e0 AS bu, +i3 >= 9223372036854775808.0e0 AS c, +u3 >= 9223372036854775808.0e0 AS cu, +i4 >= 9223372036854775808.0e0 AS d, +u4 >= 9223372036854775808.0e0 AS du, +i8 >= 9223372036854775808.0e0 AS e, +u8 >= 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 >= '9223372036854775808' AS a, +u1 >= '9223372036854775808' AS au, +i2 >= '9223372036854775808' AS b, +u2 >= '9223372036854775808' AS bu, +i3 >= '9223372036854775808' AS c, +u3 >= '9223372036854775808' AS cu, +i4 >= '9223372036854775808' AS d, +u4 >= '9223372036854775808' AS du, +i8 >= '9223372036854775808' AS e, +u8 >= '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 1 +SELECT i1 <= 9223372036854775808 AS a, +u1 <= 9223372036854775808 AS au, +i2 <= 9223372036854775808 AS b, +u2 <= 9223372036854775808 AS bu, +i3 <= 9223372036854775808 AS c, +u3 <= 9223372036854775808 AS cu, +i4 <= 9223372036854775808 AS d, +u4 <= 9223372036854775808 AS du, +i8 <= 9223372036854775808 AS e, +u8 <= 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775808.0 AS a, +u1 <= 9223372036854775808.0 AS au, +i2 <= 9223372036854775808.0 AS b, +u2 <= 9223372036854775808.0 AS bu, +i3 <= 9223372036854775808.0 AS c, +u3 <= 9223372036854775808.0 AS cu, +i4 <= 9223372036854775808.0 AS d, +u4 <= 9223372036854775808.0 AS du, +i8 <= 9223372036854775808.0 AS e, +u8 <= 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= 9223372036854775808.0e0 AS a, +u1 <= 9223372036854775808.0e0 AS au, +i2 <= 9223372036854775808.0e0 AS b, +u2 <= 9223372036854775808.0e0 AS bu, +i3 <= 9223372036854775808.0e0 AS c, +u3 <= 9223372036854775808.0e0 AS cu, +i4 <= 9223372036854775808.0e0 AS d, +u4 <= 9223372036854775808.0e0 AS du, +i8 <= 9223372036854775808.0e0 AS e, +u8 <= 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <= '9223372036854775808' AS a, +u1 <= '9223372036854775808' AS au, +i2 <= '9223372036854775808' AS b, +u2 <= '9223372036854775808' AS bu, +i3 <= '9223372036854775808' AS c, +u3 <= '9223372036854775808' AS cu, +i4 <= '9223372036854775808' AS d, +u4 <= '9223372036854775808' AS du, +i8 <= '9223372036854775808' AS e, +u8 <= '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 > 9223372036854775808 AS a, +u1 > 9223372036854775808 AS au, +i2 > 9223372036854775808 AS b, +u2 > 9223372036854775808 AS bu, +i3 > 9223372036854775808 AS c, +u3 > 9223372036854775808 AS cu, +i4 > 9223372036854775808 AS d, +u4 > 9223372036854775808 AS du, +i8 > 9223372036854775808 AS e, +u8 > 9223372036854775808 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775808.0 AS a, +u1 > 9223372036854775808.0 AS au, +i2 > 9223372036854775808.0 AS b, +u2 > 9223372036854775808.0 AS bu, +i3 > 9223372036854775808.0 AS c, +u3 > 9223372036854775808.0 AS cu, +i4 > 9223372036854775808.0 AS d, +u4 > 9223372036854775808.0 AS du, +i8 > 9223372036854775808.0 AS e, +u8 > 9223372036854775808.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > 9223372036854775808.0e0 AS a, +u1 > 9223372036854775808.0e0 AS au, +i2 > 9223372036854775808.0e0 AS b, +u2 > 9223372036854775808.0e0 AS bu, +i3 > 9223372036854775808.0e0 AS c, +u3 > 9223372036854775808.0e0 AS cu, +i4 > 9223372036854775808.0e0 AS d, +u4 > 9223372036854775808.0e0 AS du, +i8 > 9223372036854775808.0e0 AS e, +u8 > 9223372036854775808.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 > '9223372036854775808' AS a, +u1 > '9223372036854775808' AS au, +i2 > '9223372036854775808' AS b, +u2 > '9223372036854775808' AS bu, +i3 > '9223372036854775808' AS c, +u3 > '9223372036854775808' AS cu, +i4 > '9223372036854775808' AS d, +u4 > '9223372036854775808' AS du, +i8 > '9223372036854775808' AS e, +u8 > '9223372036854775808' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +set @iv= 18446744073709551615; +set @dv= 18446744073709551615.0; +set @fv= 18446744073709551615.0e0; +set @sv= "18446744073709551615"; +SELECT i1 = 18446744073709551615 AS a, +u1 = 18446744073709551615 AS au, +i2 = 18446744073709551615 AS b, +u2 = 18446744073709551615 AS bu, +i3 = 18446744073709551615 AS c, +u3 = 18446744073709551615 AS cu, +i4 = 18446744073709551615 AS d, +u4 = 18446744073709551615 AS du, +i8 = 18446744073709551615 AS e, +u8 = 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = 18446744073709551615.0 AS a, +u1 = 18446744073709551615.0 AS au, +i2 = 18446744073709551615.0 AS b, +u2 = 18446744073709551615.0 AS bu, +i3 = 18446744073709551615.0 AS c, +u3 = 18446744073709551615.0 AS cu, +i4 = 18446744073709551615.0 AS d, +u4 = 18446744073709551615.0 AS du, +i8 = 18446744073709551615.0 AS e, +u8 = 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = 18446744073709551615.0e0 AS a, +u1 = 18446744073709551615.0e0 AS au, +i2 = 18446744073709551615.0e0 AS b, +u2 = 18446744073709551615.0e0 AS bu, +i3 = 18446744073709551615.0e0 AS c, +u3 = 18446744073709551615.0e0 AS cu, +i4 = 18446744073709551615.0e0 AS d, +u4 = 18446744073709551615.0e0 AS du, +i8 = 18446744073709551615.0e0 AS e, +u8 = 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = '18446744073709551615' AS a, +u1 = '18446744073709551615' AS au, +i2 = '18446744073709551615' AS b, +u2 = '18446744073709551615' AS bu, +i3 = '18446744073709551615' AS c, +u3 = '18446744073709551615' AS cu, +i4 = '18446744073709551615' AS d, +u4 = '18446744073709551615' AS du, +i8 = '18446744073709551615' AS e, +u8 = '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <> 18446744073709551615 AS a, +u1 <> 18446744073709551615 AS au, +i2 <> 18446744073709551615 AS b, +u2 <> 18446744073709551615 AS bu, +i3 <> 18446744073709551615 AS c, +u3 <> 18446744073709551615 AS cu, +i4 <> 18446744073709551615 AS d, +u4 <> 18446744073709551615 AS du, +i8 <> 18446744073709551615 AS e, +u8 <> 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> 18446744073709551615.0 AS a, +u1 <> 18446744073709551615.0 AS au, +i2 <> 18446744073709551615.0 AS b, +u2 <> 18446744073709551615.0 AS bu, +i3 <> 18446744073709551615.0 AS c, +u3 <> 18446744073709551615.0 AS cu, +i4 <> 18446744073709551615.0 AS d, +u4 <> 18446744073709551615.0 AS du, +i8 <> 18446744073709551615.0 AS e, +u8 <> 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> 18446744073709551615.0e0 AS a, +u1 <> 18446744073709551615.0e0 AS au, +i2 <> 18446744073709551615.0e0 AS b, +u2 <> 18446744073709551615.0e0 AS bu, +i3 <> 18446744073709551615.0e0 AS c, +u3 <> 18446744073709551615.0e0 AS cu, +i4 <> 18446744073709551615.0e0 AS d, +u4 <> 18446744073709551615.0e0 AS du, +i8 <> 18446744073709551615.0e0 AS e, +u8 <> 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> '18446744073709551615' AS a, +u1 <> '18446744073709551615' AS au, +i2 <> '18446744073709551615' AS b, +u2 <> '18446744073709551615' AS bu, +i3 <> '18446744073709551615' AS c, +u3 <> '18446744073709551615' AS cu, +i4 <> '18446744073709551615' AS d, +u4 <> '18446744073709551615' AS du, +i8 <> '18446744073709551615' AS e, +u8 <> '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551615 AS a, +u1 < 18446744073709551615 AS au, +i2 < 18446744073709551615 AS b, +u2 < 18446744073709551615 AS bu, +i3 < 18446744073709551615 AS c, +u3 < 18446744073709551615 AS cu, +i4 < 18446744073709551615 AS d, +u4 < 18446744073709551615 AS du, +i8 < 18446744073709551615 AS e, +u8 < 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551615.0 AS a, +u1 < 18446744073709551615.0 AS au, +i2 < 18446744073709551615.0 AS b, +u2 < 18446744073709551615.0 AS bu, +i3 < 18446744073709551615.0 AS c, +u3 < 18446744073709551615.0 AS cu, +i4 < 18446744073709551615.0 AS d, +u4 < 18446744073709551615.0 AS du, +i8 < 18446744073709551615.0 AS e, +u8 < 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551615.0e0 AS a, +u1 < 18446744073709551615.0e0 AS au, +i2 < 18446744073709551615.0e0 AS b, +u2 < 18446744073709551615.0e0 AS bu, +i3 < 18446744073709551615.0e0 AS c, +u3 < 18446744073709551615.0e0 AS cu, +i4 < 18446744073709551615.0e0 AS d, +u4 < 18446744073709551615.0e0 AS du, +i8 < 18446744073709551615.0e0 AS e, +u8 < 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < '18446744073709551615' AS a, +u1 < '18446744073709551615' AS au, +i2 < '18446744073709551615' AS b, +u2 < '18446744073709551615' AS bu, +i3 < '18446744073709551615' AS c, +u3 < '18446744073709551615' AS cu, +i4 < '18446744073709551615' AS d, +u4 < '18446744073709551615' AS du, +i8 < '18446744073709551615' AS e, +u8 < '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 >= 18446744073709551615 AS a, +u1 >= 18446744073709551615 AS au, +i2 >= 18446744073709551615 AS b, +u2 >= 18446744073709551615 AS bu, +i3 >= 18446744073709551615 AS c, +u3 >= 18446744073709551615 AS cu, +i4 >= 18446744073709551615 AS d, +u4 >= 18446744073709551615 AS du, +i8 >= 18446744073709551615 AS e, +u8 >= 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 18446744073709551615.0 AS a, +u1 >= 18446744073709551615.0 AS au, +i2 >= 18446744073709551615.0 AS b, +u2 >= 18446744073709551615.0 AS bu, +i3 >= 18446744073709551615.0 AS c, +u3 >= 18446744073709551615.0 AS cu, +i4 >= 18446744073709551615.0 AS d, +u4 >= 18446744073709551615.0 AS du, +i8 >= 18446744073709551615.0 AS e, +u8 >= 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= 18446744073709551615.0e0 AS a, +u1 >= 18446744073709551615.0e0 AS au, +i2 >= 18446744073709551615.0e0 AS b, +u2 >= 18446744073709551615.0e0 AS bu, +i3 >= 18446744073709551615.0e0 AS c, +u3 >= 18446744073709551615.0e0 AS cu, +i4 >= 18446744073709551615.0e0 AS d, +u4 >= 18446744073709551615.0e0 AS du, +i8 >= 18446744073709551615.0e0 AS e, +u8 >= 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= '18446744073709551615' AS a, +u1 >= '18446744073709551615' AS au, +i2 >= '18446744073709551615' AS b, +u2 >= '18446744073709551615' AS bu, +i3 >= '18446744073709551615' AS c, +u3 >= '18446744073709551615' AS cu, +i4 >= '18446744073709551615' AS d, +u4 >= '18446744073709551615' AS du, +i8 >= '18446744073709551615' AS e, +u8 >= '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <= 18446744073709551615 AS a, +u1 <= 18446744073709551615 AS au, +i2 <= 18446744073709551615 AS b, +u2 <= 18446744073709551615 AS bu, +i3 <= 18446744073709551615 AS c, +u3 <= 18446744073709551615 AS cu, +i4 <= 18446744073709551615 AS d, +u4 <= 18446744073709551615 AS du, +i8 <= 18446744073709551615 AS e, +u8 <= 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551615.0 AS a, +u1 <= 18446744073709551615.0 AS au, +i2 <= 18446744073709551615.0 AS b, +u2 <= 18446744073709551615.0 AS bu, +i3 <= 18446744073709551615.0 AS c, +u3 <= 18446744073709551615.0 AS cu, +i4 <= 18446744073709551615.0 AS d, +u4 <= 18446744073709551615.0 AS du, +i8 <= 18446744073709551615.0 AS e, +u8 <= 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551615.0e0 AS a, +u1 <= 18446744073709551615.0e0 AS au, +i2 <= 18446744073709551615.0e0 AS b, +u2 <= 18446744073709551615.0e0 AS bu, +i3 <= 18446744073709551615.0e0 AS c, +u3 <= 18446744073709551615.0e0 AS cu, +i4 <= 18446744073709551615.0e0 AS d, +u4 <= 18446744073709551615.0e0 AS du, +i8 <= 18446744073709551615.0e0 AS e, +u8 <= 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= '18446744073709551615' AS a, +u1 <= '18446744073709551615' AS au, +i2 <= '18446744073709551615' AS b, +u2 <= '18446744073709551615' AS bu, +i3 <= '18446744073709551615' AS c, +u3 <= '18446744073709551615' AS cu, +i4 <= '18446744073709551615' AS d, +u4 <= '18446744073709551615' AS du, +i8 <= '18446744073709551615' AS e, +u8 <= '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 18446744073709551615 AS a, +u1 > 18446744073709551615 AS au, +i2 > 18446744073709551615 AS b, +u2 > 18446744073709551615 AS bu, +i3 > 18446744073709551615 AS c, +u3 > 18446744073709551615 AS cu, +i4 > 18446744073709551615 AS d, +u4 > 18446744073709551615 AS du, +i8 > 18446744073709551615 AS e, +u8 > 18446744073709551615 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551615.0 AS a, +u1 > 18446744073709551615.0 AS au, +i2 > 18446744073709551615.0 AS b, +u2 > 18446744073709551615.0 AS bu, +i3 > 18446744073709551615.0 AS c, +u3 > 18446744073709551615.0 AS cu, +i4 > 18446744073709551615.0 AS d, +u4 > 18446744073709551615.0 AS du, +i8 > 18446744073709551615.0 AS e, +u8 > 18446744073709551615.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551615.0e0 AS a, +u1 > 18446744073709551615.0e0 AS au, +i2 > 18446744073709551615.0e0 AS b, +u2 > 18446744073709551615.0e0 AS bu, +i3 > 18446744073709551615.0e0 AS c, +u3 > 18446744073709551615.0e0 AS cu, +i4 > 18446744073709551615.0e0 AS d, +u4 > 18446744073709551615.0e0 AS du, +i8 > 18446744073709551615.0e0 AS e, +u8 > 18446744073709551615.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > '18446744073709551615' AS a, +u1 > '18446744073709551615' AS au, +i2 > '18446744073709551615' AS b, +u2 > '18446744073709551615' AS bu, +i3 > '18446744073709551615' AS c, +u3 > '18446744073709551615' AS cu, +i4 > '18446744073709551615' AS d, +u4 > '18446744073709551615' AS du, +i8 > '18446744073709551615' AS e, +u8 > '18446744073709551615' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +set @iv= 18446744073709551616; +set @dv= 18446744073709551616.0; +set @fv= 18446744073709551616.0e0; +set @sv= "18446744073709551616"; +SELECT i1 = 18446744073709551616 AS a, +u1 = 18446744073709551616 AS au, +i2 = 18446744073709551616 AS b, +u2 = 18446744073709551616 AS bu, +i3 = 18446744073709551616 AS c, +u3 = 18446744073709551616 AS cu, +i4 = 18446744073709551616 AS d, +u4 = 18446744073709551616 AS du, +i8 = 18446744073709551616 AS e, +u8 = 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 18446744073709551616.0 AS a, +u1 = 18446744073709551616.0 AS au, +i2 = 18446744073709551616.0 AS b, +u2 = 18446744073709551616.0 AS bu, +i3 = 18446744073709551616.0 AS c, +u3 = 18446744073709551616.0 AS cu, +i4 = 18446744073709551616.0 AS d, +u4 = 18446744073709551616.0 AS du, +i8 = 18446744073709551616.0 AS e, +u8 = 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 = 18446744073709551616.0e0 AS a, +u1 = 18446744073709551616.0e0 AS au, +i2 = 18446744073709551616.0e0 AS b, +u2 = 18446744073709551616.0e0 AS bu, +i3 = 18446744073709551616.0e0 AS c, +u3 = 18446744073709551616.0e0 AS cu, +i4 = 18446744073709551616.0e0 AS d, +u4 = 18446744073709551616.0e0 AS du, +i8 = 18446744073709551616.0e0 AS e, +u8 = 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 = '18446744073709551616' AS a, +u1 = '18446744073709551616' AS au, +i2 = '18446744073709551616' AS b, +u2 = '18446744073709551616' AS bu, +i3 = '18446744073709551616' AS c, +u3 = '18446744073709551616' AS cu, +i4 = '18446744073709551616' AS d, +u4 = '18446744073709551616' AS du, +i8 = '18446744073709551616' AS e, +u8 = '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s1 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <> 18446744073709551616 AS a, +u1 <> 18446744073709551616 AS au, +i2 <> 18446744073709551616 AS b, +u2 <> 18446744073709551616 AS bu, +i3 <> 18446744073709551616 AS c, +u3 <> 18446744073709551616 AS cu, +i4 <> 18446744073709551616 AS d, +u4 <> 18446744073709551616 AS du, +i8 <> 18446744073709551616 AS e, +u8 <> 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 18446744073709551616.0 AS a, +u1 <> 18446744073709551616.0 AS au, +i2 <> 18446744073709551616.0 AS b, +u2 <> 18446744073709551616.0 AS bu, +i3 <> 18446744073709551616.0 AS c, +u3 <> 18446744073709551616.0 AS cu, +i4 <> 18446744073709551616.0 AS d, +u4 <> 18446744073709551616.0 AS du, +i8 <> 18446744073709551616.0 AS e, +u8 <> 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <> 18446744073709551616.0e0 AS a, +u1 <> 18446744073709551616.0e0 AS au, +i2 <> 18446744073709551616.0e0 AS b, +u2 <> 18446744073709551616.0e0 AS bu, +i3 <> 18446744073709551616.0e0 AS c, +u3 <> 18446744073709551616.0e0 AS cu, +i4 <> 18446744073709551616.0e0 AS d, +u4 <> 18446744073709551616.0e0 AS du, +i8 <> 18446744073709551616.0e0 AS e, +u8 <> 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 <> '18446744073709551616' AS a, +u1 <> '18446744073709551616' AS au, +i2 <> '18446744073709551616' AS b, +u2 <> '18446744073709551616' AS bu, +i3 <> '18446744073709551616' AS c, +u3 <> '18446744073709551616' AS cu, +i4 <> '18446744073709551616' AS d, +u4 <> '18446744073709551616' AS du, +i8 <> '18446744073709551616' AS e, +u8 <> '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s2 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < 18446744073709551616 AS a, +u1 < 18446744073709551616 AS au, +i2 < 18446744073709551616 AS b, +u2 < 18446744073709551616 AS bu, +i3 < 18446744073709551616 AS c, +u3 < 18446744073709551616 AS cu, +i4 < 18446744073709551616 AS d, +u4 < 18446744073709551616 AS du, +i8 < 18446744073709551616 AS e, +u8 < 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s3 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < 18446744073709551616.0 AS a, +u1 < 18446744073709551616.0 AS au, +i2 < 18446744073709551616.0 AS b, +u2 < 18446744073709551616.0 AS bu, +i3 < 18446744073709551616.0 AS c, +u3 < 18446744073709551616.0 AS cu, +i4 < 18446744073709551616.0 AS d, +u4 < 18446744073709551616.0 AS du, +i8 < 18446744073709551616.0 AS e, +u8 < 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s3 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 < 18446744073709551616.0e0 AS a, +u1 < 18446744073709551616.0e0 AS au, +i2 < 18446744073709551616.0e0 AS b, +u2 < 18446744073709551616.0e0 AS bu, +i3 < 18446744073709551616.0e0 AS c, +u3 < 18446744073709551616.0e0 AS cu, +i4 < 18446744073709551616.0e0 AS d, +u4 < 18446744073709551616.0e0 AS du, +i8 < 18446744073709551616.0e0 AS e, +u8 < 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 < '18446744073709551616' AS a, +u1 < '18446744073709551616' AS au, +i2 < '18446744073709551616' AS b, +u2 < '18446744073709551616' AS bu, +i3 < '18446744073709551616' AS c, +u3 < '18446744073709551616' AS cu, +i4 < '18446744073709551616' AS d, +u4 < '18446744073709551616' AS du, +i8 < '18446744073709551616' AS e, +u8 < '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +execute s3 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 0 +SELECT i1 >= 18446744073709551616 AS a, +u1 >= 18446744073709551616 AS au, +i2 >= 18446744073709551616 AS b, +u2 >= 18446744073709551616 AS bu, +i3 >= 18446744073709551616 AS c, +u3 >= 18446744073709551616 AS cu, +i4 >= 18446744073709551616 AS d, +u4 >= 18446744073709551616 AS du, +i8 >= 18446744073709551616 AS e, +u8 >= 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s4 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 18446744073709551616.0 AS a, +u1 >= 18446744073709551616.0 AS au, +i2 >= 18446744073709551616.0 AS b, +u2 >= 18446744073709551616.0 AS bu, +i3 >= 18446744073709551616.0 AS c, +u3 >= 18446744073709551616.0 AS cu, +i4 >= 18446744073709551616.0 AS d, +u4 >= 18446744073709551616.0 AS du, +i8 >= 18446744073709551616.0 AS e, +u8 >= 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s4 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 >= 18446744073709551616.0e0 AS a, +u1 >= 18446744073709551616.0e0 AS au, +i2 >= 18446744073709551616.0e0 AS b, +u2 >= 18446744073709551616.0e0 AS bu, +i3 >= 18446744073709551616.0e0 AS c, +u3 >= 18446744073709551616.0e0 AS cu, +i4 >= 18446744073709551616.0e0 AS d, +u4 >= 18446744073709551616.0e0 AS du, +i8 >= 18446744073709551616.0e0 AS e, +u8 >= 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 >= '18446744073709551616' AS a, +u1 >= '18446744073709551616' AS au, +i2 >= '18446744073709551616' AS b, +u2 >= '18446744073709551616' AS bu, +i3 >= '18446744073709551616' AS c, +u3 >= '18446744073709551616' AS cu, +i4 >= '18446744073709551616' AS d, +u4 >= '18446744073709551616' AS du, +i8 >= '18446744073709551616' AS e, +u8 >= '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +execute s4 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 1 +SELECT i1 <= 18446744073709551616 AS a, +u1 <= 18446744073709551616 AS au, +i2 <= 18446744073709551616 AS b, +u2 <= 18446744073709551616 AS bu, +i3 <= 18446744073709551616 AS c, +u3 <= 18446744073709551616 AS cu, +i4 <= 18446744073709551616 AS d, +u4 <= 18446744073709551616 AS du, +i8 <= 18446744073709551616 AS e, +u8 <= 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551616.0 AS a, +u1 <= 18446744073709551616.0 AS au, +i2 <= 18446744073709551616.0 AS b, +u2 <= 18446744073709551616.0 AS bu, +i3 <= 18446744073709551616.0 AS c, +u3 <= 18446744073709551616.0 AS cu, +i4 <= 18446744073709551616.0 AS d, +u4 <= 18446744073709551616.0 AS du, +i8 <= 18446744073709551616.0 AS e, +u8 <= 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= 18446744073709551616.0e0 AS a, +u1 <= 18446744073709551616.0e0 AS au, +i2 <= 18446744073709551616.0e0 AS b, +u2 <= 18446744073709551616.0e0 AS bu, +i3 <= 18446744073709551616.0e0 AS c, +u3 <= 18446744073709551616.0e0 AS cu, +i4 <= 18446744073709551616.0e0 AS d, +u4 <= 18446744073709551616.0e0 AS du, +i8 <= 18446744073709551616.0e0 AS e, +u8 <= 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 <= '18446744073709551616' AS a, +u1 <= '18446744073709551616' AS au, +i2 <= '18446744073709551616' AS b, +u2 <= '18446744073709551616' AS bu, +i3 <= '18446744073709551616' AS c, +u3 <= '18446744073709551616' AS cu, +i4 <= '18446744073709551616' AS d, +u4 <= '18446744073709551616' AS du, +i8 <= '18446744073709551616' AS e, +u8 <= '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +SELECT i1 > 18446744073709551616 AS a, +u1 > 18446744073709551616 AS au, +i2 > 18446744073709551616 AS b, +u2 > 18446744073709551616 AS bu, +i3 > 18446744073709551616 AS c, +u3 > 18446744073709551616 AS cu, +i4 > 18446744073709551616 AS d, +u4 > 18446744073709551616 AS du, +i8 > 18446744073709551616 AS e, +u8 > 18446744073709551616 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv, @iv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551616.0 AS a, +u1 > 18446744073709551616.0 AS au, +i2 > 18446744073709551616.0 AS b, +u2 > 18446744073709551616.0 AS bu, +i3 > 18446744073709551616.0 AS c, +u3 > 18446744073709551616.0 AS cu, +i4 > 18446744073709551616.0 AS d, +u4 > 18446744073709551616.0 AS du, +i8 > 18446744073709551616.0 AS e, +u8 > 18446744073709551616.0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv, @dv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > 18446744073709551616.0e0 AS a, +u1 > 18446744073709551616.0e0 AS au, +i2 > 18446744073709551616.0e0 AS b, +u2 > 18446744073709551616.0e0 AS bu, +i3 > 18446744073709551616.0e0 AS c, +u3 > 18446744073709551616.0e0 AS cu, +i4 > 18446744073709551616.0e0 AS d, +u4 > 18446744073709551616.0e0 AS du, +i8 > 18446744073709551616.0e0 AS e, +u8 > 18446744073709551616.0e0 AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv, @fv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +SELECT i1 > '18446744073709551616' AS a, +u1 > '18446744073709551616' AS au, +i2 > '18446744073709551616' AS b, +u2 > '18446744073709551616' AS bu, +i3 > '18446744073709551616' AS c, +u3 > '18446744073709551616' AS cu, +i4 > '18446744073709551616' AS d, +u4 > '18446744073709551616' AS du, +i8 > '18446744073709551616' AS e, +u8 > '18446744073709551616' AS eu +FROM t1; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv, @sv; +a au b bu c cu d du e eu +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t1; +CREATE TABLE t2 +(pk INTEGER PRIMARY KEY, +f4 REAL, +f8 DOUBLE); +INSERT INTO t2 VALUES +(0, -3.402823e+38, -1.797693134862315708e+308), +(1, -1.175494e-38, -2.225073858507201383e-308), +(2, 0, 0), +(3, 1.175494e-38, 2.225073858507201383e-308), +(4, 3.402823e+38, 1.797693134862315708e+308); +set @fv= -1.797693134862315708e+308; +set @sv= "-1.797693134862315708e+308"; +SELECT f4 = -1.797693134862315708e+308 AS a, +f8 = -1.797693134862315708e+308 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '-1.797693134862315708e+308' AS a, +f8 = '-1.797693134862315708e+308' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> -1.797693134862315708e+308 AS a, +f8 <> -1.797693134862315708e+308 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '-1.797693134862315708e+308' AS a, +f8 <> '-1.797693134862315708e+308' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < -1.797693134862315708e+308 AS a, +f8 < -1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 < '-1.797693134862315708e+308' AS a, +f8 < '-1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 >= -1.797693134862315708e+308 AS a, +f8 >= -1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-1.797693134862315708e+308' AS a, +f8 >= '-1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= -1.797693134862315708e+308 AS a, +f8 <= -1.797693134862315708e+308 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <= '-1.797693134862315708e+308' AS a, +f8 <= '-1.797693134862315708e+308' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > -1.797693134862315708e+308 AS a, +f8 > -1.797693134862315708e+308 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > '-1.797693134862315708e+308' AS a, +f8 > '-1.797693134862315708e+308' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +set @fv= -3.40282347e+38; +set @sv= "-3.40282347e+38"; +SELECT f4 = -3.40282347e+38 AS a, +f8 = -3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '-3.40282347e+38' AS a, +f8 = '-3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> -3.40282347e+38 AS a, +f8 <> -3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '-3.40282347e+38' AS a, +f8 <> '-3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < -3.40282347e+38 AS a, +f8 < -3.40282347e+38 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 < '-3.40282347e+38' AS a, +f8 < '-3.40282347e+38' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 >= -3.40282347e+38 AS a, +f8 >= -3.40282347e+38 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-3.40282347e+38' AS a, +f8 >= '-3.40282347e+38' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= -3.40282347e+38 AS a, +f8 <= -3.40282347e+38 AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <= '-3.40282347e+38' AS a, +f8 <= '-3.40282347e+38' AS b +FROM t2; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +0 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > -3.40282347e+38 AS a, +f8 > -3.40282347e+38 AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > '-3.40282347e+38' AS a, +f8 > '-3.40282347e+38' AS b +FROM t2; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +1 0 +1 1 +1 1 +1 1 +1 1 +set @fv= -1.17549435e-38; +set @sv= "-1.17549435e-38"; +SELECT f4 = -1.17549435e-38 AS a, +f8 = -1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '-1.17549435e-38' AS a, +f8 = '-1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> -1.17549435e-38 AS a, +f8 <> -1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '-1.17549435e-38' AS a, +f8 <> '-1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < -1.17549435e-38 AS a, +f8 < -1.17549435e-38 AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 < '-1.17549435e-38' AS a, +f8 < '-1.17549435e-38' AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 >= -1.17549435e-38 AS a, +f8 >= -1.17549435e-38 AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-1.17549435e-38' AS a, +f8 >= '-1.17549435e-38' AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= -1.17549435e-38 AS a, +f8 <= -1.17549435e-38 AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <= '-1.17549435e-38' AS a, +f8 <= '-1.17549435e-38' AS b +FROM t2; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > -1.17549435e-38 AS a, +f8 > -1.17549435e-38 AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > '-1.17549435e-38' AS a, +f8 > '-1.17549435e-38' AS b +FROM t2; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +set @fv= -2.225073858507201383e-308; +set @sv= "-2.225073858507201383e-308"; +SELECT f4 = -2.225073858507201383e-308 AS a, +f8 = -2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT f4 = '-2.225073858507201383e-308' AS a, +f8 = '-2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT f4 <> -2.225073858507201383e-308 AS a, +f8 <> -2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT f4 <> '-2.225073858507201383e-308' AS a, +f8 <> '-2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT f4 < -2.225073858507201383e-308 AS a, +f8 < -2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +SELECT f4 < '-2.225073858507201383e-308' AS a, +f8 < '-2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 0 +0 0 +0 0 +0 0 +SELECT f4 >= -2.225073858507201383e-308 AS a, +f8 >= -2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +SELECT f4 >= '-2.225073858507201383e-308' AS a, +f8 >= '-2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 1 +1 1 +1 1 +1 1 +SELECT f4 <= -2.225073858507201383e-308 AS a, +f8 <= -2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 <= '-2.225073858507201383e-308' AS a, +f8 <= '-2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 > -2.225073858507201383e-308 AS a, +f8 > -2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT f4 > '-2.225073858507201383e-308' AS a, +f8 > '-2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +set @fv= 0; +set @sv= "0"; +SELECT f4 = 0 AS a, +f8 = 0 AS b +FROM t2; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT f4 = '0' AS a, +f8 = '0' AS b +FROM t2; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT f4 <> 0 AS a, +f8 <> 0 AS b +FROM t2; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT f4 <> '0' AS a, +f8 <> '0' AS b +FROM t2; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT f4 < 0 AS a, +f8 < 0 AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 < '0' AS a, +f8 < '0' AS b +FROM t2; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT f4 >= 0 AS a, +f8 >= 0 AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT f4 >= '0' AS a, +f8 >= '0' AS b +FROM t2; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT f4 <= 0 AS a, +f8 <= 0 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 <= '0' AS a, +f8 <= '0' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 > 0 AS a, +f8 > 0 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT f4 > '0' AS a, +f8 > '0' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +set @fv= 2.225073858507201383e-308; +set @sv= "2.225073858507201383e-308"; +SELECT f4 = 2.225073858507201383e-308 AS a, +f8 = 2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT f4 = '2.225073858507201383e-308' AS a, +f8 = '2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT f4 <> 2.225073858507201383e-308 AS a, +f8 <> 2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT f4 <> '2.225073858507201383e-308' AS a, +f8 <> '2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT f4 < 2.225073858507201383e-308 AS a, +f8 < 2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 < '2.225073858507201383e-308' AS a, +f8 < '2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT f4 >= 2.225073858507201383e-308 AS a, +f8 >= 2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT f4 >= '2.225073858507201383e-308' AS a, +f8 >= '2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT f4 <= 2.225073858507201383e-308 AS a, +f8 <= 2.225073858507201383e-308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +SELECT f4 <= '2.225073858507201383e-308' AS a, +f8 <= '2.225073858507201383e-308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +0 1 +0 0 +SELECT f4 > 2.225073858507201383e-308 AS a, +f8 > 2.225073858507201383e-308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +SELECT f4 > '2.225073858507201383e-308' AS a, +f8 > '2.225073858507201383e-308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +1 0 +1 1 +set @fv= 1.17549435e-38; +set @sv= "1.17549435e-38"; +SELECT f4 = 1.17549435e-38 AS a, +f8 = 1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '1.17549435e-38' AS a, +f8 = '1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> 1.17549435e-38 AS a, +f8 <> 1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '1.17549435e-38' AS a, +f8 <> '1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < 1.17549435e-38 AS a, +f8 < 1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 < '1.17549435e-38' AS a, +f8 < '1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 >= 1.17549435e-38 AS a, +f8 >= 1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT f4 >= '1.17549435e-38' AS a, +f8 >= '1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT f4 <= 1.17549435e-38 AS a, +f8 <= 1.17549435e-38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 <= '1.17549435e-38' AS a, +f8 <= '1.17549435e-38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT f4 > 1.17549435e-38 AS a, +f8 > 1.17549435e-38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT f4 > '1.17549435e-38' AS a, +f8 > '1.17549435e-38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +set @fv= 3.40282347e+38; +set @sv= "3.40282347e+38"; +SELECT f4 = 3.40282347e+38 AS a, +f8 = 3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 = '3.40282347e+38' AS a, +f8 = '3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 <> 3.40282347e+38 AS a, +f8 <> 3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <> '3.40282347e+38' AS a, +f8 <> '3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 < 3.40282347e+38 AS a, +f8 < 3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 < '3.40282347e+38' AS a, +f8 < '3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 >= 3.40282347e+38 AS a, +f8 >= 3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 >= '3.40282347e+38' AS a, +f8 >= '3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 <= 3.40282347e+38 AS a, +f8 <= 3.40282347e+38 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 <= '3.40282347e+38' AS a, +f8 <= '3.40282347e+38' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 > 3.40282347e+38 AS a, +f8 > 3.40282347e+38 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 > '3.40282347e+38' AS a, +f8 > '3.40282347e+38' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +set @fv= 1.797693134862315708e+308; +set @sv= "1.797693134862315708e+308"; +SELECT f4 = 1.797693134862315708e+308 AS a, +f8 = 1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s1 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 = '1.797693134862315708e+308' AS a, +f8 = '1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s1 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 <> 1.797693134862315708e+308 AS a, +f8 <> 1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s2 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 <> '1.797693134862315708e+308' AS a, +f8 <> '1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s2 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 < 1.797693134862315708e+308 AS a, +f8 < 1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 < '1.797693134862315708e+308' AS a, +f8 < '1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +execute s3 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 0 +SELECT f4 >= 1.797693134862315708e+308 AS a, +f8 >= 1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 >= '1.797693134862315708e+308' AS a, +f8 >= '1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +execute s4 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 1 +SELECT f4 <= 1.797693134862315708e+308 AS a, +f8 <= 1.797693134862315708e+308 AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @fv, @fv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 <= '1.797693134862315708e+308' AS a, +f8 <= '1.797693134862315708e+308' AS b +FROM t2; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @sv, @sv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT f4 > 1.797693134862315708e+308 AS a, +f8 > 1.797693134862315708e+308 AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @fv, @fv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT f4 > '1.797693134862315708e+308' AS a, +f8 > '1.797693134862315708e+308' AS b +FROM t2; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @sv, @sv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t2; +CREATE TABLE t3 +(pk INTEGER PRIMARY KEY, +dc1 DECIMAL(12, 4), +dc2 DECIMAL(30, 30), +dc3 DECIMAL(65, 0), +dc4 DECIMAL(65, 30)); +INSERT INTO t3 VALUES +(0, -99999999.9999, -.999999999999999999999999999999, +-99999999999999999999999999999999999999999999999999999999999999999, +-99999999999999999999999999999999999.999999999999999999999999999999), +(1, 0, 0, 0, 0), +(2, 99999999.9999, .999999999999999999999999999999, +99999999999999999999999999999999999999999999999999999999999999999, +99999999999999999999999999999999999.999999999999999999999999999999); +set @dv= -100000000000000000000000000000000000000000000000000000000000000000; +set @sv= "-100000000000000000000000000000000000000000000000000000000000000000"; +SELECT dc1 = -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 = -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 = -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 = -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 = '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 = '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 = '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <> -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <> -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <> -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <> '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 < -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 < -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 < -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 < '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 < '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 < '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 >= -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 >= -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 >= -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 >= '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <= -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <= -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <= -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <= '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 > -100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 > -100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 > -100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 > '-100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 > '-100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 > '-100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +set @dv= -99999999999999999999999999999999999999999999999999999999999999999; +set @sv= "-99999999999999999999999999999999999999999999999999999999999999999"; +SELECT dc1 = -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 = -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 = -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 = -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 = '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 = '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 = '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <> -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <> -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <> -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <> '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 < -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 < -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 < -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 < '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 < '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 < '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 >= -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 >= -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 >= -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 >= '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <= -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <= -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <= -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <= '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 > -99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 > -99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 > -99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 > '-99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 > '-99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 > '-99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +set @dv= -99999999999999999999999999999999999.999999999999999999999999999999; +set @sv= "-99999999999999999999999999999999999.999999999999999999999999999999"; +SELECT dc1 = -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 = -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 = -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 = -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 = '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <> -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <> '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 < -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 < -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 < -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 < '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 >= -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 >= '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <= -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <= '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 > -99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 > -99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 > -99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 > '-99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +set @dv= -99999999.9999; +set @sv= "-99999999.9999"; +SELECT dc1 = -99999999.9999 AS a, +dc2 = -99999999.9999 AS b, +dc3 = -99999999.9999 AS c, +dc4 = -99999999.9999 AS d +FROM t3; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-99999999.9999' AS a, +dc2 = '-99999999.9999' AS b, +dc3 = '-99999999.9999' AS c, +dc4 = '-99999999.9999' AS d +FROM t3; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +1 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -99999999.9999 AS a, +dc2 <> -99999999.9999 AS b, +dc3 <> -99999999.9999 AS c, +dc4 <> -99999999.9999 AS d +FROM t3; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-99999999.9999' AS a, +dc2 <> '-99999999.9999' AS b, +dc3 <> '-99999999.9999' AS c, +dc4 <> '-99999999.9999' AS d +FROM t3; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +0 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -99999999.9999 AS a, +dc2 < -99999999.9999 AS b, +dc3 < -99999999.9999 AS c, +dc4 < -99999999.9999 AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-99999999.9999' AS a, +dc2 < '-99999999.9999' AS b, +dc3 < '-99999999.9999' AS c, +dc4 < '-99999999.9999' AS d +FROM t3; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +0 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -99999999.9999 AS a, +dc2 >= -99999999.9999 AS b, +dc3 >= -99999999.9999 AS c, +dc4 >= -99999999.9999 AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-99999999.9999' AS a, +dc2 >= '-99999999.9999' AS b, +dc3 >= '-99999999.9999' AS c, +dc4 >= '-99999999.9999' AS d +FROM t3; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +1 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -99999999.9999 AS a, +dc2 <= -99999999.9999 AS b, +dc3 <= -99999999.9999 AS c, +dc4 <= -99999999.9999 AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-99999999.9999' AS a, +dc2 <= '-99999999.9999' AS b, +dc3 <= '-99999999.9999' AS c, +dc4 <= '-99999999.9999' AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -99999999.9999 AS a, +dc2 > -99999999.9999 AS b, +dc3 > -99999999.9999 AS c, +dc4 > -99999999.9999 AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-99999999.9999' AS a, +dc2 > '-99999999.9999' AS b, +dc3 > '-99999999.9999' AS c, +dc4 > '-99999999.9999' AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +set @dv= -.999999999999999999999999999999; +set @sv= "-.999999999999999999999999999999"; +SELECT dc1 = -.999999999999999999999999999999 AS a, +dc2 = -.999999999999999999999999999999 AS b, +dc3 = -.999999999999999999999999999999 AS c, +dc4 = -.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '-.999999999999999999999999999999' AS a, +dc2 = '-.999999999999999999999999999999' AS b, +dc3 = '-.999999999999999999999999999999' AS c, +dc4 = '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 1 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> -.999999999999999999999999999999 AS a, +dc2 <> -.999999999999999999999999999999 AS b, +dc3 <> -.999999999999999999999999999999 AS c, +dc4 <> -.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '-.999999999999999999999999999999' AS a, +dc2 <> '-.999999999999999999999999999999' AS b, +dc3 <> '-.999999999999999999999999999999' AS c, +dc4 <> '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 0 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < -.999999999999999999999999999999 AS a, +dc2 < -.999999999999999999999999999999 AS b, +dc3 < -.999999999999999999999999999999 AS c, +dc4 < -.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '-.999999999999999999999999999999' AS a, +dc2 < '-.999999999999999999999999999999' AS b, +dc3 < '-.999999999999999999999999999999' AS c, +dc4 < '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 0 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= -.999999999999999999999999999999 AS a, +dc2 >= -.999999999999999999999999999999 AS b, +dc3 >= -.999999999999999999999999999999 AS c, +dc4 >= -.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '-.999999999999999999999999999999' AS a, +dc2 >= '-.999999999999999999999999999999' AS b, +dc3 >= '-.999999999999999999999999999999' AS c, +dc4 >= '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 1 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= -.999999999999999999999999999999 AS a, +dc2 <= -.999999999999999999999999999999 AS b, +dc3 <= -.999999999999999999999999999999 AS c, +dc4 <= -.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= '-.999999999999999999999999999999' AS a, +dc2 <= '-.999999999999999999999999999999' AS b, +dc3 <= '-.999999999999999999999999999999' AS c, +dc4 <= '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 > -.999999999999999999999999999999 AS a, +dc2 > -.999999999999999999999999999999 AS b, +dc3 > -.999999999999999999999999999999 AS c, +dc4 > -.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 > '-.999999999999999999999999999999' AS a, +dc2 > '-.999999999999999999999999999999' AS b, +dc3 > '-.999999999999999999999999999999' AS c, +dc4 > '-.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +set @dv= 0; +set @sv= "0"; +SELECT dc1 = 0 AS a, +dc2 = 0 AS b, +dc3 = 0 AS c, +dc4 = 0 AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +SELECT dc1 = '0' AS a, +dc2 = '0' AS b, +dc3 = '0' AS c, +dc4 = '0' AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +1 1 1 1 +0 0 0 0 +SELECT dc1 <> 0 AS a, +dc2 <> 0 AS b, +dc3 <> 0 AS c, +dc4 <> 0 AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +SELECT dc1 <> '0' AS a, +dc2 <> '0' AS b, +dc3 <> '0' AS c, +dc4 <> '0' AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +0 0 0 0 +1 1 1 1 +SELECT dc1 < 0 AS a, +dc2 < 0 AS b, +dc3 < 0 AS c, +dc4 < 0 AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 < '0' AS a, +dc2 < '0' AS b, +dc3 < '0' AS c, +dc4 < '0' AS d +FROM t3; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= 0 AS a, +dc2 >= 0 AS b, +dc3 >= 0 AS c, +dc4 >= 0 AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= '0' AS a, +dc2 >= '0' AS b, +dc3 >= '0' AS c, +dc4 >= '0' AS d +FROM t3; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= 0 AS a, +dc2 <= 0 AS b, +dc3 <= 0 AS c, +dc4 <= 0 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 <= '0' AS a, +dc2 <= '0' AS b, +dc3 <= '0' AS c, +dc4 <= '0' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 > 0 AS a, +dc2 > 0 AS b, +dc3 > 0 AS c, +dc4 > 0 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +SELECT dc1 > '0' AS a, +dc2 > '0' AS b, +dc3 > '0' AS c, +dc4 > '0' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +set @dv= .999999999999999999999999999999; +set @sv= ".999999999999999999999999999999"; +SELECT dc1 = .999999999999999999999999999999 AS a, +dc2 = .999999999999999999999999999999 AS b, +dc3 = .999999999999999999999999999999 AS c, +dc4 = .999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +SELECT dc1 = '.999999999999999999999999999999' AS a, +dc2 = '.999999999999999999999999999999' AS b, +dc3 = '.999999999999999999999999999999' AS c, +dc4 = '.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 1 0 0 +SELECT dc1 <> .999999999999999999999999999999 AS a, +dc2 <> .999999999999999999999999999999 AS b, +dc3 <> .999999999999999999999999999999 AS c, +dc4 <> .999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +SELECT dc1 <> '.999999999999999999999999999999' AS a, +dc2 <> '.999999999999999999999999999999' AS b, +dc3 <> '.999999999999999999999999999999' AS c, +dc4 <> '.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 0 1 1 +SELECT dc1 < .999999999999999999999999999999 AS a, +dc2 < .999999999999999999999999999999 AS b, +dc3 < .999999999999999999999999999999 AS c, +dc4 < .999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 < '.999999999999999999999999999999' AS a, +dc2 < '.999999999999999999999999999999' AS b, +dc3 < '.999999999999999999999999999999' AS c, +dc4 < '.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 0 0 0 +SELECT dc1 >= .999999999999999999999999999999 AS a, +dc2 >= .999999999999999999999999999999 AS b, +dc3 >= .999999999999999999999999999999 AS c, +dc4 >= .999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +SELECT dc1 >= '.999999999999999999999999999999' AS a, +dc2 >= '.999999999999999999999999999999' AS b, +dc3 >= '.999999999999999999999999999999' AS c, +dc4 >= '.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 1 1 1 +SELECT dc1 <= .999999999999999999999999999999 AS a, +dc2 <= .999999999999999999999999999999 AS b, +dc3 <= .999999999999999999999999999999 AS c, +dc4 <= .999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 <= '.999999999999999999999999999999' AS a, +dc2 <= '.999999999999999999999999999999' AS b, +dc3 <= '.999999999999999999999999999999' AS c, +dc4 <= '.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 > .999999999999999999999999999999 AS a, +dc2 > .999999999999999999999999999999 AS b, +dc3 > .999999999999999999999999999999 AS c, +dc4 > .999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +SELECT dc1 > '.999999999999999999999999999999' AS a, +dc2 > '.999999999999999999999999999999' AS b, +dc3 > '.999999999999999999999999999999' AS c, +dc4 > '.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +set @dv= 99999999.9999; +set @sv= "99999999.9999"; +SELECT dc1 = 99999999.9999 AS a, +dc2 = 99999999.9999 AS b, +dc3 = 99999999.9999 AS c, +dc4 = 99999999.9999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +SELECT dc1 = '99999999.9999' AS a, +dc2 = '99999999.9999' AS b, +dc3 = '99999999.9999' AS c, +dc4 = '99999999.9999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 0 0 +SELECT dc1 <> 99999999.9999 AS a, +dc2 <> 99999999.9999 AS b, +dc3 <> 99999999.9999 AS c, +dc4 <> 99999999.9999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +SELECT dc1 <> '99999999.9999' AS a, +dc2 <> '99999999.9999' AS b, +dc3 <> '99999999.9999' AS c, +dc4 <> '99999999.9999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 1 1 +SELECT dc1 < 99999999.9999 AS a, +dc2 < 99999999.9999 AS b, +dc3 < 99999999.9999 AS c, +dc4 < 99999999.9999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 < '99999999.9999' AS a, +dc2 < '99999999.9999' AS b, +dc3 < '99999999.9999' AS c, +dc4 < '99999999.9999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +0 1 0 0 +SELECT dc1 >= 99999999.9999 AS a, +dc2 >= 99999999.9999 AS b, +dc3 >= 99999999.9999 AS c, +dc4 >= 99999999.9999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +SELECT dc1 >= '99999999.9999' AS a, +dc2 >= '99999999.9999' AS b, +dc3 >= '99999999.9999' AS c, +dc4 >= '99999999.9999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +1 0 1 1 +SELECT dc1 <= 99999999.9999 AS a, +dc2 <= 99999999.9999 AS b, +dc3 <= 99999999.9999 AS c, +dc4 <= 99999999.9999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 <= '99999999.9999' AS a, +dc2 <= '99999999.9999' AS b, +dc3 <= '99999999.9999' AS c, +dc4 <= '99999999.9999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 > 99999999.9999 AS a, +dc2 > 99999999.9999 AS b, +dc3 > 99999999.9999 AS c, +dc4 > 99999999.9999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +SELECT dc1 > '99999999.9999' AS a, +dc2 > '99999999.9999' AS b, +dc3 > '99999999.9999' AS c, +dc4 > '99999999.9999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +set @dv= 99999999999999999999999999999999999.999999999999999999999999999999; +set @sv= "99999999999999999999999999999999999.999999999999999999999999999999"; +SELECT dc1 = 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 = 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 = 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 = 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +SELECT dc1 = '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 = '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 = '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 = '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 1 +SELECT dc1 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <> 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +SELECT dc1 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <> '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 0 +SELECT dc1 < 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 < 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 < 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 < 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 < '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 < '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 < '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 < '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 0 +SELECT dc1 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 >= 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +SELECT dc1 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 >= '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 1 +SELECT dc1 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 <= 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 <= '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 > 99999999999999999999999999999999999.999999999999999999999999999999 AS a, +dc2 > 99999999999999999999999999999999999.999999999999999999999999999999 AS b, +dc3 > 99999999999999999999999999999999999.999999999999999999999999999999 AS c, +dc4 > 99999999999999999999999999999999999.999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 > '99999999999999999999999999999999999.999999999999999999999999999999' AS a, +dc2 > '99999999999999999999999999999999999.999999999999999999999999999999' AS b, +dc3 > '99999999999999999999999999999999999.999999999999999999999999999999' AS c, +dc4 > '99999999999999999999999999999999999.999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +set @dv= 99999999999999999999999999999999999999999999999999999999999999999; +set @sv= "99999999999999999999999999999999999999999999999999999999999999999"; +SELECT dc1 = 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 = 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 = 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 = 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 = '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 = '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 = '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 = '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 <> 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <> 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <> 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <> 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 <> '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <> '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <> '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <> '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 < 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 < 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 < 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 < 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 < '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 < '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 < '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 < '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 0 1 +SELECT dc1 >= 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 >= 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 >= 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 >= 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 >= '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 >= '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 >= '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 >= '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 1 0 +SELECT dc1 <= 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 <= 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 <= 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 <= 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 <= '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 <= '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 <= '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > 99999999999999999999999999999999999999999999999999999999999999999 AS a, +dc2 > 99999999999999999999999999999999999999999999999999999999999999999 AS b, +dc3 > 99999999999999999999999999999999999999999999999999999999999999999 AS c, +dc4 > 99999999999999999999999999999999999999999999999999999999999999999 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > '99999999999999999999999999999999999999999999999999999999999999999' AS a, +dc2 > '99999999999999999999999999999999999999999999999999999999999999999' AS b, +dc3 > '99999999999999999999999999999999999999999999999999999999999999999' AS c, +dc4 > '99999999999999999999999999999999999999999999999999999999999999999' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +set @dv= 100000000000000000000000000000000000000000000000000000000000000000; +set @sv= "100000000000000000000000000000000000000000000000000000000000000000"; +SELECT dc1 = 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 = 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 = 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 = 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 = '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 = '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 = '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 = '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s1 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <> 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <> 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <> 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <> 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <> '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <> '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <> '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <> '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s2 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 < 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 < 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 < 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s3 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 < '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 < '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 < '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 < '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s3 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 >= 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 >= 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 >= 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 >= 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s4 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 >= '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 >= '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 >= '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 >= '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s4 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 <= 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 <= 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 <= 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 <= 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @dv, @dv, @dv, @dv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 <= '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 <= '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 <= '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 <= '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +execute s5 using @sv, @sv, @sv, @sv; +a b c d +1 1 1 1 +1 1 1 1 +1 1 1 1 +SELECT dc1 > 100000000000000000000000000000000000000000000000000000000000000000 AS a, +dc2 > 100000000000000000000000000000000000000000000000000000000000000000 AS b, +dc3 > 100000000000000000000000000000000000000000000000000000000000000000 AS c, +dc4 > 100000000000000000000000000000000000000000000000000000000000000000 AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @dv, @dv, @dv, @dv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +SELECT dc1 > '100000000000000000000000000000000000000000000000000000000000000000' AS a, +dc2 > '100000000000000000000000000000000000000000000000000000000000000000' AS b, +dc3 > '100000000000000000000000000000000000000000000000000000000000000000' AS c, +dc4 > '100000000000000000000000000000000000000000000000000000000000000000' AS d +FROM t3; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +execute s6 using @sv, @sv, @sv, @sv; +a b c d +0 0 0 0 +0 0 0 0 +0 0 0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t3; +CREATE TABLE t4 +(pk INTEGER PRIMARY KEY, +fc CHAR(12), +vc VARCHAR(12)); +INSERT INTO t4 VALUES +(0, "", ""); +set @sv= """"; +SELECT fc = "" AS a, +vc = "" AS b +FROM t4; +a b +1 1 +execute s1 using @sv, @sv; +a b +0 0 +SELECT fc <> "" AS a, +vc <> "" AS b +FROM t4; +a b +0 0 +execute s2 using @sv, @sv; +a b +1 1 +SELECT fc < "" AS a, +vc < "" AS b +FROM t4; +a b +0 0 +execute s3 using @sv, @sv; +a b +1 1 +SELECT fc >= "" AS a, +vc >= "" AS b +FROM t4; +a b +1 1 +execute s4 using @sv, @sv; +a b +0 0 +SELECT fc <= "" AS a, +vc <= "" AS b +FROM t4; +a b +1 1 +execute s5 using @sv, @sv; +a b +1 1 +SELECT fc > "" AS a, +vc > "" AS b +FROM t4; +a b +0 0 +execute s6 using @sv, @sv; +a b +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t4; +CREATE TABLE t5 +(pk INTEGER PRIMARY KEY, +d DATE); +INSERT INTO t5 VALUES +(0, '0001-01-01'), (1, '2017-01-01'), (2, '9999-12-31'); +set @sv= "0001-01-01"; +set @iv= 00010101; +set @tsv= "0001-01-01 00:00:00.000000"; +set @tsn= 00010101000000.0; +SELECT d = '0001-01-01' AS a +FROM t5; +a +1 +0 +0 +execute s1 using @sv; +a +1 +0 +0 +SELECT d = 00010101 AS a +FROM t5; +a +0 +0 +0 +execute s1 using @iv; +a +0 +0 +0 +SELECT d = '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +0 +execute s1 using @tsv; +a +1 +0 +0 +SELECT d = 00010101000000.0 AS a +FROM t5; +a +0 +0 +0 +execute s1 using @tsn; +a +0 +0 +0 +SELECT d <> '0001-01-01' AS a +FROM t5; +a +0 +1 +1 +execute s2 using @sv; +a +0 +1 +1 +SELECT d <> 00010101 AS a +FROM t5; +a +1 +1 +1 +execute s2 using @iv; +a +1 +1 +1 +SELECT d <> '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +1 +execute s2 using @tsv; +a +0 +1 +1 +SELECT d <> 00010101000000.0 AS a +FROM t5; +a +1 +1 +1 +execute s2 using @tsn; +a +1 +1 +1 +SELECT d < '0001-01-01' AS a +FROM t5; +a +0 +0 +0 +execute s3 using @sv; +a +0 +0 +0 +SELECT d < 00010101 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @iv; +a +1 +0 +0 +SELECT d < '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +0 +0 +execute s3 using @tsv; +a +0 +0 +0 +SELECT d < 00010101000000.0 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @tsn; +a +1 +0 +0 +SELECT d >= '0001-01-01' AS a +FROM t5; +a +1 +1 +1 +execute s4 using @sv; +a +1 +1 +1 +SELECT d >= 00010101 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @iv; +a +0 +1 +1 +SELECT d >= '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +1 +1 +execute s4 using @tsv; +a +1 +1 +1 +SELECT d >= 00010101000000.0 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @tsn; +a +0 +1 +1 +SELECT d <= '0001-01-01' AS a +FROM t5; +a +1 +0 +0 +execute s5 using @sv; +a +1 +0 +0 +SELECT d <= 00010101 AS a +FROM t5; +a +1 +0 +0 +execute s5 using @iv; +a +1 +0 +0 +SELECT d <= '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +0 +execute s5 using @tsv; +a +1 +0 +0 +SELECT d <= 00010101000000.0 AS a +FROM t5; +a +1 +0 +0 +execute s5 using @tsn; +a +1 +0 +0 +SELECT d > '0001-01-01' AS a +FROM t5; +a +0 +1 +1 +execute s6 using @sv; +a +0 +1 +1 +SELECT d > 00010101 AS a +FROM t5; +a +0 +1 +1 +execute s6 using @iv; +a +0 +1 +1 +SELECT d > '0001-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +1 +execute s6 using @tsv; +a +0 +1 +1 +SELECT d > 00010101000000.0 AS a +FROM t5; +a +0 +1 +1 +execute s6 using @tsn; +a +0 +1 +1 +set @sv= "2017-01-01"; +set @iv= 20170101; +set @tsv= "2017-01-01 00:00:00.000000"; +set @tsn= 20170101000000.0; +SELECT d = '2017-01-01' AS a +FROM t5; +a +0 +1 +0 +execute s1 using @sv; +a +0 +1 +0 +SELECT d = 20170101 AS a +FROM t5; +a +0 +1 +0 +execute s1 using @iv; +a +0 +1 +0 +SELECT d = '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +0 +execute s1 using @tsv; +a +0 +1 +0 +SELECT d = 20170101000000.0 AS a +FROM t5; +a +0 +1 +0 +execute s1 using @tsn; +a +0 +1 +0 +SELECT d <> '2017-01-01' AS a +FROM t5; +a +1 +0 +1 +execute s2 using @sv; +a +1 +0 +1 +SELECT d <> 20170101 AS a +FROM t5; +a +1 +0 +1 +execute s2 using @iv; +a +1 +0 +1 +SELECT d <> '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +1 +execute s2 using @tsv; +a +1 +0 +1 +SELECT d <> 20170101000000.0 AS a +FROM t5; +a +1 +0 +1 +execute s2 using @tsn; +a +1 +0 +1 +SELECT d < '2017-01-01' AS a +FROM t5; +a +1 +0 +0 +execute s3 using @sv; +a +1 +0 +0 +SELECT d < 20170101 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @iv; +a +1 +0 +0 +SELECT d < '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +0 +0 +execute s3 using @tsv; +a +1 +0 +0 +SELECT d < 20170101000000.0 AS a +FROM t5; +a +1 +0 +0 +execute s3 using @tsn; +a +1 +0 +0 +SELECT d >= '2017-01-01' AS a +FROM t5; +a +0 +1 +1 +execute s4 using @sv; +a +0 +1 +1 +SELECT d >= 20170101 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @iv; +a +0 +1 +1 +SELECT d >= '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +1 +1 +execute s4 using @tsv; +a +0 +1 +1 +SELECT d >= 20170101000000.0 AS a +FROM t5; +a +0 +1 +1 +execute s4 using @tsn; +a +0 +1 +1 +SELECT d <= '2017-01-01' AS a +FROM t5; +a +1 +1 +0 +execute s5 using @sv; +a +1 +1 +0 +SELECT d <= 20170101 AS a +FROM t5; +a +1 +1 +0 +execute s5 using @iv; +a +1 +1 +0 +SELECT d <= '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +1 +1 +0 +execute s5 using @tsv; +a +1 +1 +0 +SELECT d <= 20170101000000.0 AS a +FROM t5; +a +1 +1 +0 +execute s5 using @tsn; +a +1 +1 +0 +SELECT d > '2017-01-01' AS a +FROM t5; +a +0 +0 +1 +execute s6 using @sv; +a +0 +0 +1 +SELECT d > 20170101 AS a +FROM t5; +a +0 +0 +1 +execute s6 using @iv; +a +0 +0 +1 +SELECT d > '2017-01-01 00:00:00.000000' AS a +FROM t5; +a +0 +0 +1 +execute s6 using @tsv; +a +0 +0 +1 +SELECT d > 20170101000000.0 AS a +FROM t5; +a +0 +0 +1 +execute s6 using @tsn; +a +0 +0 +1 +set @sv= "9999-12-31"; +set @iv= 99991231; +set @tsv= "9999-12-31 00:00:00.000000"; +set @tsn= 99991231000000.0; +SELECT d = '9999-12-31' AS a +FROM t5; +a +0 +0 +1 +execute s1 using @sv; +a +0 +0 +1 +SELECT d = 99991231 AS a +FROM t5; +a +0 +0 +1 +execute s1 using @iv; +a +0 +0 +1 +SELECT d = '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +0 +0 +1 +execute s1 using @tsv; +a +0 +0 +1 +SELECT d = 99991231000000.0 AS a +FROM t5; +a +0 +0 +1 +execute s1 using @tsn; +a +0 +0 +1 +SELECT d <> '9999-12-31' AS a +FROM t5; +a +1 +1 +0 +execute s2 using @sv; +a +1 +1 +0 +SELECT d <> 99991231 AS a +FROM t5; +a +1 +1 +0 +execute s2 using @iv; +a +1 +1 +0 +SELECT d <> '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +1 +1 +0 +execute s2 using @tsv; +a +1 +1 +0 +SELECT d <> 99991231000000.0 AS a +FROM t5; +a +1 +1 +0 +execute s2 using @tsn; +a +1 +1 +0 +SELECT d < '9999-12-31' AS a +FROM t5; +a +1 +1 +0 +execute s3 using @sv; +a +1 +1 +0 +SELECT d < 99991231 AS a +FROM t5; +a +1 +1 +0 +execute s3 using @iv; +a +1 +1 +0 +SELECT d < '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +1 +1 +0 +execute s3 using @tsv; +a +1 +1 +0 +SELECT d < 99991231000000.0 AS a +FROM t5; +a +1 +1 +0 +execute s3 using @tsn; +a +1 +1 +0 +SELECT d >= '9999-12-31' AS a +FROM t5; +a +0 +0 +1 +execute s4 using @sv; +a +0 +0 +1 +SELECT d >= 99991231 AS a +FROM t5; +a +0 +0 +1 +execute s4 using @iv; +a +0 +0 +1 +SELECT d >= '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +0 +0 +1 +execute s4 using @tsv; +a +0 +0 +1 +SELECT d >= 99991231000000.0 AS a +FROM t5; +a +0 +0 +1 +execute s4 using @tsn; +a +0 +0 +1 +SELECT d <= '9999-12-31' AS a +FROM t5; +a +1 +1 +1 +execute s5 using @sv; +a +1 +1 +1 +SELECT d <= 99991231 AS a +FROM t5; +a +1 +1 +1 +execute s5 using @iv; +a +1 +1 +1 +SELECT d <= '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +1 +1 +1 +execute s5 using @tsv; +a +1 +1 +1 +SELECT d <= 99991231000000.0 AS a +FROM t5; +a +1 +1 +1 +execute s5 using @tsn; +a +1 +1 +1 +SELECT d > '9999-12-31' AS a +FROM t5; +a +0 +0 +0 +execute s6 using @sv; +a +0 +0 +0 +SELECT d > 99991231 AS a +FROM t5; +a +0 +0 +0 +execute s6 using @iv; +a +0 +0 +0 +SELECT d > '9999-12-31 00:00:00.000000' AS a +FROM t5; +a +0 +0 +0 +execute s6 using @tsv; +a +0 +0 +0 +SELECT d > 99991231000000.0 AS a +FROM t5; +a +0 +0 +0 +execute s6 using @tsn; +a +0 +0 +0 +set @iv=-20010101; +select @iv; +@iv +-20010101 +execute s1 using @iv; +a +NULL +NULL +NULL +Warnings: +Warning 1292 Incorrect datetime value: '-20010101' +set @sv="abc"; +execute s1 using @sv; +a +NULL +NULL +NULL +Warnings: +Warning 1292 Incorrect datetime value: 'abc' +Warning 1292 Incorrect datetime value: 'abc' +Warning 1292 Incorrect datetime value: 'abc' +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t5; +CREATE TABLE t6 +(pk INTEGER PRIMARY KEY, +t1 TIME(0), +t2 TIME(6)); +INSERT INTO t6 VALUES +(0, '-838:59:59', '-838:59:59.000000'), +(1, '-23:59:59', '-23:59:59.999999'), +(2, '00:00:00', '00:00:00.000000'), +(3, '23:59:59', '23:59:59.999999'), +(4, '838:59:59', '838:59:59.000000'); +set @tv= "-838:59:59.000000"; +set @dcv= -8385959.000000; +SELECT t1 = '-838:59:59.000000' AS a, +t2 = '-838:59:59.000000' AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @tv, @tv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 = -8385959.000000 AS a, +t2 = -8385959.000000 AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 <> '-838:59:59.000000' AS a, +t2 <> '-838:59:59.000000' AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @tv, @tv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <> -8385959.000000 AS a, +t2 <> -8385959.000000 AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 < '-838:59:59.000000' AS a, +t2 < '-838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT t1 < -8385959.000000 AS a, +t2 < -8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT t1 >= '-838:59:59.000000' AS a, +t2 >= '-838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 >= -8385959.000000 AS a, +t2 >= -8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <= '-838:59:59.000000' AS a, +t2 <= '-838:59:59.000000' AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 <= -8385959.000000 AS a, +t2 <= -8385959.000000 AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 > '-838:59:59.000000' AS a, +t2 > '-838:59:59.000000' AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 > -8385959.000000 AS a, +t2 > -8385959.000000 AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +set @tv= "-23:59:59.999999"; +set @dcv= -235959.999999; +SELECT t1 = '-23:59:59.999999' AS a, +t2 = '-23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @tv, @tv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT t1 = -235959.999999 AS a, +t2 = -235959.999999 AS b +FROM t6; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 1 +0 0 +0 0 +0 0 +SELECT t1 <> '-23:59:59.999999' AS a, +t2 <> '-23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @tv, @tv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT t1 <> -235959.999999 AS a, +t2 <> -235959.999999 AS b +FROM t6; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 0 +1 1 +1 1 +1 1 +SELECT t1 < '-23:59:59.999999' AS a, +t2 < '-23:59:59.999999' AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 < -235959.999999 AS a, +t2 < -235959.999999 AS b +FROM t6; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +0 0 +0 0 +SELECT t1 >= '-23:59:59.999999' AS a, +t2 >= '-23:59:59.999999' AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 >= -235959.999999 AS a, +t2 >= -235959.999999 AS b +FROM t6; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <= '-23:59:59.999999' AS a, +t2 <= '-23:59:59.999999' AS b +FROM t6; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +SELECT t1 <= -235959.999999 AS a, +t2 <= -235959.999999 AS b +FROM t6; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +0 1 +0 0 +0 0 +0 0 +SELECT t1 > '-23:59:59.999999' AS a, +t2 > '-23:59:59.999999' AS b +FROM t6; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +SELECT t1 > -235959.999999 AS a, +t2 > -235959.999999 AS b +FROM t6; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +1 0 +1 1 +1 1 +1 1 +set @tv= "00:00:00.000000"; +set @dcv= 000000.000000; +SELECT t1 = '00:00:00.000000' AS a, +t2 = '00:00:00.000000' AS b +FROM t6; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @tv, @tv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT t1 = 000000.000000 AS a, +t2 = 000000.000000 AS b +FROM t6; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +1 1 +0 0 +0 0 +SELECT t1 <> '00:00:00.000000' AS a, +t2 <> '00:00:00.000000' AS b +FROM t6; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @tv, @tv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT t1 <> 000000.000000 AS a, +t2 <> 000000.000000 AS b +FROM t6; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +0 0 +1 1 +1 1 +SELECT t1 < '00:00:00.000000' AS a, +t2 < '00:00:00.000000' AS b +FROM t6; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT t1 < 000000.000000 AS a, +t2 < 000000.000000 AS b +FROM t6; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +0 0 +0 0 +0 0 +SELECT t1 >= '00:00:00.000000' AS a, +t2 >= '00:00:00.000000' AS b +FROM t6; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT t1 >= 000000.000000 AS a, +t2 >= 000000.000000 AS b +FROM t6; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +1 1 +1 1 +1 1 +SELECT t1 <= '00:00:00.000000' AS a, +t2 <= '00:00:00.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT t1 <= 000000.000000 AS a, +t2 <= 000000.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +0 0 +0 0 +SELECT t1 > '00:00:00.000000' AS a, +t2 > '00:00:00.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +SELECT t1 > 000000.000000 AS a, +t2 > 000000.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +1 1 +1 1 +set @tv= "23:59:59.999999"; +set @dcv= 235959.999999; +SELECT t1 = '23:59:59.999999' AS a, +t2 = '23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT t1 = 235959.999999 AS a, +t2 = 235959.999999 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 1 +0 0 +SELECT t1 <> '23:59:59.999999' AS a, +t2 <> '23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT t1 <> 235959.999999 AS a, +t2 <> 235959.999999 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 0 +1 1 +SELECT t1 < '23:59:59.999999' AS a, +t2 < '23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +SELECT t1 < 235959.999999 AS a, +t2 < 235959.999999 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 0 +0 0 +SELECT t1 >= '23:59:59.999999' AS a, +t2 >= '23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +SELECT t1 >= 235959.999999 AS a, +t2 >= 235959.999999 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 1 +1 1 +SELECT t1 <= '23:59:59.999999' AS a, +t2 <= '23:59:59.999999' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 <= 235959.999999 AS a, +t2 <= 235959.999999 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 > '23:59:59.999999' AS a, +t2 > '23:59:59.999999' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 > 235959.999999 AS a, +t2 > 235959.999999 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +set @tv= "838:59:59.000000"; +set @dcv= 8385959.000000; +SELECT t1 = '838:59:59.000000' AS a, +t2 = '838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s1 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 = 8385959.000000 AS a, +t2 = 8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 <> '838:59:59.000000' AS a, +t2 <> '838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s2 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 <> 8385959.000000 AS a, +t2 <> 8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 < '838:59:59.000000' AS a, +t2 < '838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 < 8385959.000000 AS a, +t2 < 8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +0 0 +SELECT t1 >= '838:59:59.000000' AS a, +t2 >= '838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 >= 8385959.000000 AS a, +t2 >= 8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +1 1 +SELECT t1 <= '838:59:59.000000' AS a, +t2 <= '838:59:59.000000' AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @tv, @tv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 <= 8385959.000000 AS a, +t2 <= 8385959.000000 AS b +FROM t6; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +1 1 +1 1 +SELECT t1 > '838:59:59.000000' AS a, +t2 > '838:59:59.000000' AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @tv, @tv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +SELECT t1 > 8385959.000000 AS a, +t2 > 8385959.000000 AS b +FROM t6; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t6; +CREATE TABLE t7 +(pk INTEGER PRIMARY KEY, +dt1 DATETIME(0), +dt2 DATETIME(6)); +INSERT INTO t7 VALUES +(0, '0001-01-01 00:00:00', '0001-01-01 00:00:00.000000'), +(1, '2017-01-01 11:59.59', '2017-01-01 11:59.59.555555'), +(2, '9999-12-31 23:59.59', '9999-12-31 23:59.59.999999'); +set @dsv= "0001-01-01"; +set @tssv= "0001-01-01 00:00:00.000000"; +set @iv= 00010101; +set @dcv= 00010101000000.000000; +SELECT dt1 = '0001-01-01' AS a, +dt2 = '0001-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 = 00010101 AS a, +dt2 = 00010101 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '0001-01-01 00:00:00.000000' AS a, +dt2 = '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s1 using @tssv, @tssv; +a b +1 1 +0 0 +0 0 +SELECT dt1 = 00010101000000.000000 AS a, +dt2 = 00010101000000.000000 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +SELECT dt1 <> '0001-01-01' AS a, +dt2 <> '0001-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <> 00010101 AS a, +dt2 <> 00010101 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '0001-01-01 00:00:00.000000' AS a, +dt2 <> '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s2 using @tssv, @tssv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <> 00010101000000.000000 AS a, +dt2 <> 00010101000000.000000 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +SELECT dt1 < '0001-01-01' AS a, +dt2 < '0001-01-01' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s3 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 < 00010101 AS a, +dt2 < 00010101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < '0001-01-01 00:00:00.000000' AS a, +dt2 < '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s3 using @tssv, @tssv; +a b +0 0 +0 0 +0 0 +SELECT dt1 < 00010101000000.000000 AS a, +dt2 < 00010101000000.000000 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +SELECT dt1 >= '0001-01-01' AS a, +dt2 >= '0001-01-01' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s4 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 >= 00010101 AS a, +dt2 >= 00010101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= '0001-01-01 00:00:00.000000' AS a, +dt2 >= '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s4 using @tssv, @tssv; +a b +1 1 +1 1 +1 1 +SELECT dt1 >= 00010101000000.000000 AS a, +dt2 >= 00010101000000.000000 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <= '0001-01-01' AS a, +dt2 <= '0001-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 00010101 AS a, +dt2 <= 00010101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= '0001-01-01 00:00:00.000000' AS a, +dt2 <= '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @tssv, @tssv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 00010101000000.000000 AS a, +dt2 <= 00010101000000.000000 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +SELECT dt1 > '0001-01-01' AS a, +dt2 > '0001-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 00010101 AS a, +dt2 > 00010101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > '0001-01-01 00:00:00.000000' AS a, +dt2 > '0001-01-01 00:00:00.000000' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @tssv, @tssv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 00010101000000.000000 AS a, +dt2 > 00010101000000.000000 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +set @dsv= "2017-01-01"; +set @tssv= "2017-01-01 11:59:59"; +set @iv= 20170101; +set @dcv= 20170101115959; +SELECT dt1 = '2017-01-01' AS a, +dt2 = '2017-01-01' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 20170101 AS a, +dt2 = 20170101 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '2017-01-01 11:59:59' AS a, +dt2 = '2017-01-01 11:59:59' AS b +FROM t7; +a b +0 0 +1 0 +0 0 +execute s1 using @tssv, @tssv; +a b +0 0 +1 0 +0 0 +SELECT dt1 = 20170101115959 AS a, +dt2 = 20170101115959 AS b +FROM t7; +a b +0 0 +1 0 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +1 0 +0 0 +SELECT dt1 <> '2017-01-01' AS a, +dt2 <> '2017-01-01' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 20170101 AS a, +dt2 <> 20170101 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '2017-01-01 11:59:59' AS a, +dt2 <> '2017-01-01 11:59:59' AS b +FROM t7; +a b +1 1 +0 1 +1 1 +execute s2 using @tssv, @tssv; +a b +1 1 +0 1 +1 1 +SELECT dt1 <> 20170101115959 AS a, +dt2 <> 20170101115959 AS b +FROM t7; +a b +1 1 +0 1 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +0 1 +1 1 +SELECT dt1 < '2017-01-01' AS a, +dt2 < '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < 20170101 AS a, +dt2 < 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < '2017-01-01 11:59:59' AS a, +dt2 < '2017-01-01 11:59:59' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @tssv, @tssv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < 20170101115959 AS a, +dt2 < 20170101115959 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +0 0 +0 0 +SELECT dt1 >= '2017-01-01' AS a, +dt2 >= '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= 20170101 AS a, +dt2 >= 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= '2017-01-01 11:59:59' AS a, +dt2 >= '2017-01-01 11:59:59' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @tssv, @tssv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= 20170101115959 AS a, +dt2 >= 20170101115959 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +1 1 +1 1 +SELECT dt1 <= '2017-01-01' AS a, +dt2 <= '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 20170101 AS a, +dt2 <= 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= '2017-01-01 11:59:59' AS a, +dt2 <= '2017-01-01 11:59:59' AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s5 using @tssv, @tssv; +a b +1 1 +1 0 +0 0 +SELECT dt1 <= 20170101115959 AS a, +dt2 <= 20170101115959 AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 0 +0 0 +SELECT dt1 > '2017-01-01' AS a, +dt2 > '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 20170101 AS a, +dt2 > 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > '2017-01-01 11:59:59' AS a, +dt2 > '2017-01-01 11:59:59' AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s6 using @tssv, @tssv; +a b +0 0 +0 1 +1 1 +SELECT dt1 > 20170101115959 AS a, +dt2 > 20170101115959 AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 1 +1 1 +set @dsv= "2017-01-01"; +set @tssv= "2017-01-01 11:59:59.555555"; +set @iv= 20170101; +set @dcv= 20170101115959.555555; +SELECT dt1 = '2017-01-01' AS a, +dt2 = '2017-01-01' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 20170101 AS a, +dt2 = 20170101 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '2017-01-01 11:59:59.555555' AS a, +dt2 = '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +0 0 +0 1 +0 0 +execute s1 using @tssv, @tssv; +a b +0 0 +0 1 +0 0 +SELECT dt1 = 20170101115959.555555 AS a, +dt2 = 20170101115959.555555 AS b +FROM t7; +a b +0 0 +0 1 +0 0 +execute s1 using @dcv, @dcv; +a b +0 0 +0 1 +0 0 +SELECT dt1 <> '2017-01-01' AS a, +dt2 <> '2017-01-01' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 20170101 AS a, +dt2 <> 20170101 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '2017-01-01 11:59:59.555555' AS a, +dt2 <> '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +1 1 +1 0 +1 1 +execute s2 using @tssv, @tssv; +a b +1 1 +1 0 +1 1 +SELECT dt1 <> 20170101115959.555555 AS a, +dt2 <> 20170101115959.555555 AS b +FROM t7; +a b +1 1 +1 0 +1 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 0 +1 1 +SELECT dt1 < '2017-01-01' AS a, +dt2 < '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < 20170101 AS a, +dt2 < 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 < '2017-01-01 11:59:59.555555' AS a, +dt2 < '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s3 using @tssv, @tssv; +a b +1 1 +1 0 +0 0 +SELECT dt1 < 20170101115959.555555 AS a, +dt2 < 20170101115959.555555 AS b +FROM t7; +a b +1 1 +1 0 +0 0 +execute s3 using @dcv, @dcv; +a b +1 1 +1 0 +0 0 +SELECT dt1 >= '2017-01-01' AS a, +dt2 >= '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= 20170101 AS a, +dt2 >= 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 >= '2017-01-01 11:59:59.555555' AS a, +dt2 >= '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s4 using @tssv, @tssv; +a b +0 0 +0 1 +1 1 +SELECT dt1 >= 20170101115959.555555 AS a, +dt2 >= 20170101115959.555555 AS b +FROM t7; +a b +0 0 +0 1 +1 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 1 +1 1 +SELECT dt1 <= '2017-01-01' AS a, +dt2 <= '2017-01-01' AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= 20170101 AS a, +dt2 <= 20170101 AS b +FROM t7; +a b +1 1 +0 0 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +0 0 +0 0 +SELECT dt1 <= '2017-01-01 11:59:59.555555' AS a, +dt2 <= '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @tssv, @tssv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= 20170101115959.555555 AS a, +dt2 <= 20170101115959.555555 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +0 0 +SELECT dt1 > '2017-01-01' AS a, +dt2 > '2017-01-01' AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > 20170101 AS a, +dt2 > 20170101 AS b +FROM t7; +a b +0 0 +1 1 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +1 1 +1 1 +SELECT dt1 > '2017-01-01 11:59:59.555555' AS a, +dt2 > '2017-01-01 11:59:59.555555' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @tssv, @tssv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > 20170101115959.555555 AS a, +dt2 > 20170101115959.555555 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +1 1 +set @dsv= "9999-12-31"; +set @tssv= "9999-12-31 23:59:59.999999"; +set @iv= 99991231; +set @dcv= 99991231235959.999999; +SELECT dt1 = '9999-12-31' AS a, +dt2 = '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 99991231 AS a, +dt2 = 99991231 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '9999-12-31 23:59:59.999999' AS a, +dt2 = '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s1 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 = 99991231235959.999999 AS a, +dt2 = 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <> '9999-12-31' AS a, +dt2 <> '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 99991231 AS a, +dt2 <> 99991231 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '9999-12-31 23:59:59.999999' AS a, +dt2 <> '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s2 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 <> 99991231235959.999999 AS a, +dt2 <> 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < '9999-12-31' AS a, +dt2 < '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < 99991231 AS a, +dt2 < 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < '9999-12-31 23:59:59.999999' AS a, +dt2 < '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s3 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < 99991231235959.999999 AS a, +dt2 < 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 >= '9999-12-31' AS a, +dt2 >= '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= 99991231 AS a, +dt2 >= 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= '9999-12-31 23:59:59.999999' AS a, +dt2 >= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s4 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 >= 99991231235959.999999 AS a, +dt2 >= 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <= '9999-12-31' AS a, +dt2 <= '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= 99991231 AS a, +dt2 <= 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= '9999-12-31 23:59:59.999999' AS a, +dt2 <= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s5 using @tssv, @tssv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <= 99991231235959.999999 AS a, +dt2 <= 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +SELECT dt1 > '9999-12-31' AS a, +dt2 > '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > 99991231 AS a, +dt2 > 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > '9999-12-31 23:59:59.999999' AS a, +dt2 > '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s6 using @tssv, @tssv; +a b +0 0 +0 0 +0 0 +SELECT dt1 > 99991231235959.999999 AS a, +dt2 > 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +set @dsv= "9999-12-31"; +set @tssv= "9999-12-31 23:59:59.999999"; +set @iv= 99991231; +set @dcv= 99991231235959.999999; +SELECT dt1 = '9999-12-31' AS a, +dt2 = '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @dsv, @dsv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = 99991231 AS a, +dt2 = 99991231 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s1 using @iv, @iv; +a b +0 0 +0 0 +0 0 +SELECT dt1 = '9999-12-31 23:59:59.999999' AS a, +dt2 = '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s1 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 = 99991231235959.999999 AS a, +dt2 = 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s1 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <> '9999-12-31' AS a, +dt2 <> '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @dsv, @dsv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> 99991231 AS a, +dt2 <> 99991231 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s2 using @iv, @iv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <> '9999-12-31 23:59:59.999999' AS a, +dt2 <> '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s2 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 <> 99991231235959.999999 AS a, +dt2 <> 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s2 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < '9999-12-31' AS a, +dt2 < '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < 99991231 AS a, +dt2 < 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s3 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 < '9999-12-31 23:59:59.999999' AS a, +dt2 < '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 0 +execute s3 using @tssv, @tssv; +a b +1 1 +1 1 +1 0 +SELECT dt1 < 99991231235959.999999 AS a, +dt2 < 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s3 using @dcv, @dcv; +a b +1 1 +1 1 +1 0 +SELECT dt1 >= '9999-12-31' AS a, +dt2 >= '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= 99991231 AS a, +dt2 >= 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s4 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 >= '9999-12-31 23:59:59.999999' AS a, +dt2 >= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 1 +execute s4 using @tssv, @tssv; +a b +0 0 +0 0 +0 1 +SELECT dt1 >= 99991231235959.999999 AS a, +dt2 >= 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s4 using @dcv, @dcv; +a b +0 0 +0 0 +0 1 +SELECT dt1 <= '9999-12-31' AS a, +dt2 <= '9999-12-31' AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @dsv, @dsv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= 99991231 AS a, +dt2 <= 99991231 AS b +FROM t7; +a b +1 1 +1 1 +0 0 +execute s5 using @iv, @iv; +a b +1 1 +1 1 +0 0 +SELECT dt1 <= '9999-12-31 23:59:59.999999' AS a, +dt2 <= '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +1 1 +1 1 +1 1 +execute s5 using @tssv, @tssv; +a b +1 1 +1 1 +1 1 +SELECT dt1 <= 99991231235959.999999 AS a, +dt2 <= 99991231235959.999999 AS b +FROM t7; +a b +1 1 +1 1 +1 1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s5 using @dcv, @dcv; +a b +1 1 +1 1 +1 1 +SELECT dt1 > '9999-12-31' AS a, +dt2 > '9999-12-31' AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @dsv, @dsv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > 99991231 AS a, +dt2 > 99991231 AS b +FROM t7; +a b +0 0 +0 0 +1 1 +execute s6 using @iv, @iv; +a b +0 0 +0 0 +1 1 +SELECT dt1 > '9999-12-31 23:59:59.999999' AS a, +dt2 > '9999-12-31 23:59:59.999999' AS b +FROM t7; +a b +0 0 +0 0 +0 0 +execute s6 using @tssv, @tssv; +a b +0 0 +0 0 +0 0 +SELECT dt1 > 99991231235959.999999 AS a, +dt2 > 99991231235959.999999 AS b +FROM t7; +a b +0 0 +0 0 +0 0 +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '99991231235959.999999' for column 'dt1' at row 1 +execute s6 using @dcv, @dcv; +a b +0 0 +0 0 +0 0 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DEALLOCATE PREPARE s6; +DROP TABLE t7; diff --git a/mysql-test/r/func_default.result-pq b/mysql-test/r/func_default.result-pq new file mode 100644 index 000000000..62065bdd7 --- /dev/null +++ b/mysql-test/r/func_default.result-pq @@ -0,0 +1,31 @@ +drop table if exists t1,t2; +create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14'); +insert into t1 values ('','',0,0.0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select default(str), default(strnull), default(intg), default(rel) from t1; +default(str) default(strnull) default(intg) default(rel) +def NULL 10 3.14 +explain select default(str), default(strnull), default(intg), default(rel) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from `test`.`t1` +select * from t1 where str <> default(str); +str strnull intg rel + 0 0 +explain select * from t1 where str <> default(str); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`str` AS `str`,`test`.`t1`.`strnull` AS `strnull`,`test`.`t1`.`intg` AS `intg`,`test`.`t1`.`rel` AS `rel` from `test`.`t1` where (`test`.`t1`.`str` <> (default(`test`.`t1`.`str`))) +drop table t1; +CREATE TABLE t1 (id int(11), s varchar(20)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three'); +SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL; +ERROR HY000: Field 'mi' doesn't have a default value +DROP TABLE t1; diff --git a/mysql-test/r/func_group.result-pq b/mysql-test/r/func_group.result-pq new file mode 100644 index 000000000..b6d203e0d --- /dev/null +++ b/mysql-test/r/func_group.result-pq @@ -0,0 +1,2150 @@ +drop table if exists t1,t2; +set @sav_dpi= @@div_precision_increment; +set div_precision_increment= 5; +show variables like 'div_precision_increment'; +Variable_name Value +div_precision_increment 5 +create table t1 (grp int, a bigint unsigned, c char(10) not null); +insert into t1 values (1,1,"a"); +insert into t1 values (2,2,"b"); +insert into t1 values (2,3,"c"); +insert into t1 values (3,4,"E"); +insert into t1 values (3,5,"C"); +insert into t1 values (3,6,"D"); +select a,c,sum(a) from t1 group by a; +a c sum(a) +1 a 1 +2 b 2 +3 c 3 +4 E 4 +5 C 5 +6 D 6 +select a,c,sum(a) from t1 where a > 10 group by a; +a c sum(a) +select sum(a) from t1 where a > 10; +sum(a) +NULL +select a from t1 order by rand(10); +a +2 +6 +1 +3 +5 +4 +select distinct a from t1 order by rand(10); +a +2 +6 +1 +3 +5 +4 +select count(distinct a),count(distinct grp) from t1; +count(distinct a) count(distinct grp) +6 3 +insert into t1 values (null,null,''); +select count(distinct a),count(distinct grp) from t1; +count(distinct a) count(distinct grp) +6 3 +select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; +sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c) +21 6 3.50000 1.707825127659933 2.9166666666666665 7 0 1 6 E +select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; +grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) +1 1 1 1.00000 0 0 1 1 1 1 a a +2 5 2 2.50000 0.5 0.25 3 2 2 3 b c +3 15 3 5.00000 0.816496580927726 0.6666666666666666 7 4 4 6 C E +NULL NULL 0 NULL NULL NULL 0 18446744073709551615 NULL NULL +select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp; +grp sum +1 7 +2 20.25 +3 45.48316324759439 +NULL NULL +create table t2 (grp int, a bigint unsigned, c char(10)); +insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp; +replace into t2 select grp, a, c from t1 limit 2,1; +select * from t2; +grp a c +1 2 a +2 5 c +3 9 E +NULL NULL +2 3 c +drop table t1,t2; +CREATE TABLE t1 (id int(11),value1 float(10,2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00); +CREATE TABLE t2 (id int(11),name char(20)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two'); +select id, avg(value1), std(value1), variance(value1) from t1 group by id; +id avg(value1) std(value1) variance(value1) +1 1.0000000 0.816496580927726 0.6666666666666666 +2 11.0000000 0.816496580927726 0.6666666666666666 +select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id; +name avg(value1) std(value1) variance(value1) +Set One 1.0000000 0.816496580927726 0.6666666666666666 +Set Two 11.0000000 0.816496580927726 0.6666666666666666 +drop table t1,t2; +create table t1 (id int not null); +create table t2 (id int not null,rating int null); +insert into t1 values(1),(2),(3); +insert into t2 values(1, 3),(2, NULL),(2, NULL),(3, 2),(3, NULL); +select t1.id, avg(rating) from t1 left join t2 on ( t1.id = t2.id ) group by t1.id; +id avg(rating) +1 3.00000 +2 NULL +3 2.00000 +select sql_small_result t2.id, avg(rating) from t2 group by t2.id; +id avg(rating) +1 3.00000 +2 NULL +3 2.00000 +select sql_big_result t2.id, avg(rating) from t2 group by t2.id; +id avg(rating) +1 3.00000 +2 NULL +3 2.00000 +select sql_small_result t2.id, avg(rating+0.0e0) from t2 group by t2.id; +id avg(rating+0.0e0) +1 3 +2 NULL +3 2 +select sql_big_result t2.id, avg(rating+0.0e0) from t2 group by t2.id; +id avg(rating+0.0e0) +1 3 +2 NULL +3 2 +drop table t1,t2; +create table t1 (a smallint(6) primary key, c char(10), b text); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1','1'); +INSERT INTO t1 VALUES (2,'2','2'); +INSERT INTO t1 VALUES (4,'4','4'); +select count(*) from t1; +count(*) +3 +select count(*) from t1 where a = 1; +count(*) +1 +select count(*) from t1 where a = 100; +count(*) +0 +select count(*) from t1 where a >= 10; +count(*) +0 +select count(a) from t1 where a = 1; +count(a) +1 +select count(a) from t1 where a = 100; +count(a) +0 +select count(a) from t1 where a >= 10; +count(a) +0 +select count(b) from t1 where b >= 2; +count(b) +2 +select count(b) from t1 where b >= 10; +count(b) +0 +select count(c) from t1 where c = 10; +count(c) +0 +drop table t1; +CREATE TABLE t1 (d DATETIME, i INT); +INSERT INTO t1 VALUES (NOW(), 1); +SELECT COUNT(i), i, COUNT(i)*i FROM t1 GROUP BY i; +COUNT(i) i COUNT(i)*i +1 1 1 +SELECT COUNT(i), (i+0), COUNT(i)*(i+0) FROM t1 GROUP BY i; +COUNT(i) (i+0) COUNT(i)*(i+0) +1 1 1 +DROP TABLE t1; +create table t1 ( +num float(5,2), +user char(20) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (10.3,'nem'),(20.53,'monty'),(30.23,'sinisa'); +insert into t1 values (30.13,'nem'),(20.98,'monty'),(10.45,'sinisa'); +insert into t1 values (5.2,'nem'),(8.64,'monty'),(11.12,'sinisa'); +select sum(num) from t1; +sum(num) +147.58 +select sum(num) from t1 group by user; +sum(num) +45.63 +50.15 +51.80 +drop table t1; +create table t1 (a1 int, a2 char(3), key k1(a1), key k2(a2)); +insert into t1 values(10,'aaa'), (10,null), (10,'bbb'), (20,'zzz'); +create table t2(a1 char(3), a2 int, a3 real, key k1(a1), key k2(a2, a1)); +analyze table t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select * from t1; +a1 a2 +10 aaa +10 NULL +10 bbb +20 zzz +select min(a2) from t1; +min(a2) +aaa +select max(t1.a1), max(t2.a2) from t1, t2; +max(t1.a1) max(t2.a2) +NULL NULL +select max(t1.a1) from t1, t2; +max(t1.a1) +NULL +select max(t2.a2), max(t1.a1) from t1, t2; +max(t2.a2) max(t1.a1) +NULL NULL +explain select min(a2) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a2`) AS `min(a2)` from `test`.`t1` +explain select max(t1.a1), max(t2.a2) from t1, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No matching min/max row +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a1`) AS `max(t1.a1)`,max(`test`.`t2`.`a2`) AS `max(t2.a2)` from `test`.`t1` join `test`.`t2` +insert into t2 values('AAA', 10, 0.5); +insert into t2 values('BBB', 20, 1.0); +select t1.a1, t1.a2, t2.a1, t2.a2 from t1,t2; +a1 a2 a1 a2 +10 NULL AAA 10 +10 NULL BBB 20 +10 aaa AAA 10 +10 aaa BBB 20 +10 bbb AAA 10 +10 bbb BBB 20 +20 zzz AAA 10 +20 zzz BBB 20 +select max(t1.a1), max(t2.a1) from t1, t2 where t2.a2=9; +max(t1.a1) max(t2.a1) +NULL NULL +select max(t2.a1), max(t1.a1) from t1, t2 where t2.a2=9; +max(t2.a1) max(t1.a1) +NULL NULL +select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10; +a1 a2 a1 a2 +10 NULL AAA 10 +10 NULL BBB 20 +10 aaa AAA 10 +10 aaa BBB 20 +10 bbb AAA 10 +10 bbb BBB 20 +20 zzz NULL NULL +select max(t1.a2) from t1 left outer join t2 on t1.a1=10; +max(t1.a2) +zzz +select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=20; +max(t2.a1) +BBB +select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=10; +max(t2.a1) +AAA +select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA'; +max(t2.a1) +NULL +select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10; +max(t1.a2) max(t2.a1) +zzz BBB +drop table t1,t2; +CREATE TABLE t1 (a int, b int); +select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1; +count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +0 NULL NULL NULL NULL NULL 18446744073709551615 0 +select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +insert into t1 values (1,null); +select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +insert into t1 values (1,null); +insert into t1 values (2,null); +select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +2 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +2 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +insert into t1 values (2,1); +select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +2 1 1 1.00000 0 1 1 1 1 +select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +2 1 1 1.00000 0 1 1 1 1 +insert into t1 values (3,1); +select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +2 1 1 1.00000 0 1 1 1 1 +3 1 1 1.00000 0 1 1 1 1 +select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a; +a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) bit_xor(b) +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 0 +2 1 1 1.00000 0 1 1 1 1 1 +3 1 1 1.00000 0 1 1 1 1 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`a` AS `a`,count(`test`.`t1`.`b`) AS `count(b)`,sum(`test`.`t1`.`b`) AS `sum(b)`,avg(`test`.`t1`.`b`) AS `avg(b)`,std(`test`.`t1`.`b`) AS `std(b)`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)`,bit_and(`test`.`t1`.`b`) AS `bit_and(b)`,bit_or(`test`.`t1`.`b`) AS `bit_or(b)`,bit_xor(`test`.`t1`.`b`) AS `bit_xor(b)` from `test`.`t1` group by `test`.`t1`.`a` +drop table t1; +create table t1 (col int); +insert into t1 values (-1), (-2), (-3); +select bit_and(col), bit_or(col) from t1; +bit_and(col) bit_or(col) +18446744073709551612 18446744073709551615 +select SQL_BIG_RESULT bit_and(col), bit_or(col) from t1 group by col; +bit_and(col) bit_or(col) +18446744073709551613 18446744073709551613 +18446744073709551614 18446744073709551614 +18446744073709551615 18446744073709551615 +drop table t1; +create table t1 (a int); +select avg(2) from t1; +avg(2) +NULL +drop table t1; +create table t1( +a1 char(3) primary key, +a2 smallint, +a3 char(3), +a4 real, +a5 date, +key k1(a2,a3), +key k2(a4,a1), +key k3(a5,a1) +); +create table t2( +a1 char(3) primary key, +a2 char(17), +a3 char(2), +a4 char(3), +key k1(a3, a2), +key k2(a4) +); +insert into t1 values('AME',0,'SEA',0.100,date'1942-02-19'); +insert into t1 values('HBR',1,'SEA',0.085,date'1948-03-05'); +insert into t1 values('BOT',2,'SEA',0.085,date'1951-11-29'); +insert into t1 values('BMC',3,'SEA',0.085,date'1958-09-08'); +insert into t1 values('TWU',0,'LAX',0.080,date'1969-10-05'); +insert into t1 values('BDL',0,'DEN',0.080,date'1960-11-27'); +insert into t1 values('DTX',1,'NYC',0.080,date'1961-05-04'); +insert into t1 values('PLS',1,'WDC',0.075,date'1949-01-02'); +insert into t1 values('ZAJ',2,'CHI',0.075,date'1960-06-15'); +insert into t1 values('VVV',2,'MIN',0.075,date'1959-06-28'); +insert into t1 values('GTM',3,'DAL',0.070,date'1977-09-23'); +insert into t1 values('SSJ',null,'CHI',null,date'1974-03-19'); +insert into t1 values('KKK',3,'ATL',null,null); +insert into t1 values('XXX',null,'MIN',null,null); +insert into t1 values('WWW',1,'LED',null,null); +insert into t2 values('TKF','Seattle','WA','AME'); +insert into t2 values('LCC','Los Angeles','CA','TWU'); +insert into t2 values('DEN','Denver','CO','BDL'); +insert into t2 values('SDC','San Diego','CA','TWU'); +insert into t2 values('NOL','New Orleans','LA','GTM'); +insert into t2 values('LAK','Los Angeles','CA','TWU'); +insert into t2 values('AAA','AAA','AA','AME'); +analyze table t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select * from t1; +a1 a2 a3 a4 a5 +AME 0 SEA 0.1 1942-02-19 +BDL 0 DEN 0.08 1960-11-27 +BMC 3 SEA 0.085 1958-09-08 +BOT 2 SEA 0.085 1951-11-29 +DTX 1 NYC 0.08 1961-05-04 +GTM 3 DAL 0.07 1977-09-23 +HBR 1 SEA 0.085 1948-03-05 +KKK 3 ATL NULL NULL +PLS 1 WDC 0.075 1949-01-02 +SSJ NULL CHI NULL 1974-03-19 +TWU 0 LAX 0.08 1969-10-05 +VVV 2 MIN 0.075 1959-06-28 +WWW 1 LED NULL NULL +XXX NULL MIN NULL NULL +ZAJ 2 CHI 0.075 1960-06-15 +select * from t2; +a1 a2 a3 a4 +AAA AAA AA AME +DEN Denver CO BDL +LAK Los Angeles CA TWU +LCC Los Angeles CA TWU +NOL New Orleans LA GTM +SDC San Diego CA TWU +TKF Seattle WA AME +explain +select min(a1) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` +select min(a1) from t1; +min(a1) +AME +explain +select max(a4) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a4`) AS `max(a4)` from `test`.`t1` +select max(a4) from t1; +max(a4) +0.1 +explain +select min(a5), max(a5) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a5`) AS `min(a5)`,max(`test`.`t1`.`a5`) AS `max(a5)` from `test`.`t1` +select min(a5), max(a5) from t1; +min(a5) max(a5) +1942-02-19 1977-09-23 +explain +select min(a3) from t1 where a2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where multiple equal(2, `test`.`t1`.`a2`) +select min(a3) from t1 where a2 = 2; +min(a3) +CHI +explain +select min(a1), max(a1) from t1 where a4 = 0.080; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)`,max(`test`.`t1`.`a1`) AS `max(a1)` from `test`.`t1` where (`test`.`t1`.`a4` = 0.08) +select min(a1), max(a1) from t1 where a4 = 0.080; +min(a1) max(a1) +BDL TWU +explain +select min(t1.a5), max(t2.a3) from t1, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a5`) AS `min(t1.a5)`,max(`test`.`t2`.`a3`) AS `max(t2.a3)` from `test`.`t1` join `test`.`t2` +select min(t1.a5), max(t2.a3) from t1, t2; +min(t1.a5) max(t2.a3) +1942-02-19 WA +explain +select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(t1.a3)`,max(`test`.`t2`.`a2`) AS `max(t2.a2)` from `test`.`t1` join `test`.`t2` where (multiple equal(0, `test`.`t1`.`a2`) and multiple equal('CA', `test`.`t2`.`a3`)) +select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA'; +min(t1.a3) max(t2.a2) +DEN San Diego +explain +select min(a1) from t1 where a1 > 'KKK'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` where (`test`.`t1`.`a1` > 'KKK') +select min(a1) from t1 where a1 > 'KKK'; +min(a1) +PLS +explain +select min(a1) from t1 where a1 >= 'KKK'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` where (`test`.`t1`.`a1` >= 'KKK') +select min(a1) from t1 where a1 >= 'KKK'; +min(a1) +KKK +explain +select max(a3) from t1 where a2 = 2 and a3 < 'SEA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where ((`test`.`t1`.`a3` < 'SEA') and multiple equal(2, `test`.`t1`.`a2`)) +select max(a3) from t1 where a2 = 2 and a3 < 'SEA'; +max(a3) +MIN +explain +select max(a5) from t1 where a5 < date'1970-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a5`) AS `max(a5)` from `test`.`t1` where (`test`.`t1`.`a5` < DATE'1970-01-01') +select max(a5) from t1 where a5 < date'1970-01-01'; +max(a5) +1969-10-05 +explain +select max(a3) from t1 where a2 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where (`test`.`t1`.`a2` is null) +select max(a3) from t1 where a2 is null; +max(a3) +MIN +explain +select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where ((`test`.`t1`.`a3` between 'K' and 'Q') and multiple equal(0, `test`.`t1`.`a2`)) +select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q'; +max(a3) +LAX +explain +select min(a1), max(a1) from t1 where a1 between 'A' and 'P'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)`,max(`test`.`t1`.`a1`) AS `max(a1)` from `test`.`t1` where (`test`.`t1`.`a1` between 'A' and 'P') +select min(a1), max(a1) from t1 where a1 between 'A' and 'P'; +min(a1) max(a1) +AME KKK +explain +select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where ((`test`.`t1`.`a3` < 'SEA') and (`test`.`t1`.`a3` <= 'MIN') and multiple equal(2, `test`.`t1`.`a2`)) +select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN'; +max(a3) +MIN +explain +select max(a3) from t1 where a3 = 'MIN' and a2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where (multiple equal('MIN', `test`.`t1`.`a3`) and multiple equal(2, `test`.`t1`.`a2`)) +select max(a3) from t1 where a3 = 'MIN' and a2 = 2; +max(a3) +MIN +explain +select max(a3) from t1 where a3 = 'DEN' and a2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No matching min/max row +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where (multiple equal('DEN', `test`.`t1`.`a3`) and multiple equal(2, `test`.`t1`.`a2`)) +select max(a3) from t1 where a3 = 'DEN' and a2 = 2; +max(a3) +NULL +explain +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(t1.a3)`,min(`test`.`t2`.`a2`) AS `min(t2.a2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a3` < 'MIN') and multiple equal(2, `test`.`t1`.`a2`) and multiple equal('CA', `test`.`t2`.`a3`)) +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA'; +max(t1.a3) min(t2.a2) +CHI Los Angeles +explain +select max(a3) from t1 where a2 is null and a2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where false +select max(a3) from t1 where a2 is null and a2 = 2; +max(a3) +NULL +explain +select max(a2) from t1 where a2 >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a2`) AS `max(a2)` from `test`.`t1` where (`test`.`t1`.`a2` >= 1) +select max(a2) from t1 where a2 >= 1; +max(a2) +3 +explain +select min(a3) from t1 where a2 = 2 and a3 < 'SEA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where ((`test`.`t1`.`a3` < 'SEA') and multiple equal(2, `test`.`t1`.`a2`)) +select min(a3) from t1 where a2 = 2 and a3 < 'SEA'; +min(a3) +CHI +explain +select min(a3) from t1 where a2 = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No matching min/max row +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where multiple equal(4, `test`.`t1`.`a2`) +select min(a3) from t1 where a2 = 4; +min(a3) +NULL +explain +select min(a3) from t1 where a2 = 2 and a3 > 'SEA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No matching min/max row +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where ((`test`.`t1`.`a3` > 'SEA') and multiple equal(2, `test`.`t1`.`a2`)) +select min(a3) from t1 where a2 = 2 and a3 > 'SEA'; +min(a3) +NULL +explain +select (min(a4)+max(a4))/2 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select ((min(`test`.`t1`.`a4`) + max(`test`.`t1`.`a4`)) / 2) AS `(min(a4)+max(a4))/2` from `test`.`t1` +select (min(a4)+max(a4))/2 from t1; +(min(a4)+max(a4))/2 +0.085 +explain +select min(a3) from t1 where 2 = a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where multiple equal(2, `test`.`t1`.`a2`) +select min(a3) from t1 where 2 = a2; +min(a3) +CHI +explain +select max(a3) from t1 where a2 = 2 and 'SEA' > a3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where (('SEA' > `test`.`t1`.`a3`) and multiple equal(2, `test`.`t1`.`a2`)) +select max(a3) from t1 where a2 = 2 and 'SEA' > a3; +max(a3) +MIN +explain +select max(a3) from t1 where a2 = 2 and 'SEA' < a3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No matching min/max row +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where (('SEA' < `test`.`t1`.`a3`) and multiple equal(2, `test`.`t1`.`a2`)) +select max(a3) from t1 where a2 = 2 and 'SEA' < a3; +max(a3) +NULL +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where ((`test`.`t1`.`a3` >= 'CHI') and multiple equal(2, `test`.`t1`.`a2`)) +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI'; +min(a3) +CHI +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where ((`test`.`t1`.`a3` >= 'CHI') and (`test`.`t1`.`a3` < 'SEA') and multiple equal(2, `test`.`t1`.`a2`)) +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA'; +min(a3) +CHI +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where (multiple equal(2, `test`.`t1`.`a2`) and multiple equal('MIN', `test`.`t1`.`a3`)) +select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN'; +min(a3) +MIN +explain +select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where false +select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN'; +min(a3) +NULL +explain +select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(t1.a1)`,min(`test`.`t2`.`a4`) AS `min(t2.a4)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` < 'KKK') and (`test`.`t2`.`a4` < 'KKK')) +select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK'; +min(t1.a1) min(t2.a4) +AME AME +explain +select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 55.55 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY k1 16 NULL 15 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` where ((`test`.`t1`.`a1` > 'KKK') or (`test`.`t1`.`a1` < 'XXX')) +explain +select min(a1) from t1 where a1 != 'KKK'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 93.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY k1 16 NULL 15 93.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` where (`test`.`t1`.`a1` <> 'KKK') +explain +select max(a3) from t1 where a2 < 2 and a3 < 'SEA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 3 NULL 7 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(a3)` from `test`.`t1` where ((`test`.`t1`.`a2` < 2) and (`test`.`t1`.`a3` < 'SEA')) +explain +select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k1 k1 16 NULL 1 100.00 Using where; Using index +2 SIMPLE t2 NULL range k1 k1 9 NULL 3 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a3`) AS `max(t1.a3)`,min(`test`.`t2`.`a2`) AS `min(t2.a2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a2` = 2) and (`test`.`t1`.`a3` < 'MIN') and (`test`.`t2`.`a3` > 'CA')) +explain +select min(a4 - 0.01) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 21 NULL 15 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min((`test`.`t1`.`a4` - 0.01)) AS `min(a4 - 0.01)` from `test`.`t1` +explain +select max(a4 + 0.01) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 21 NULL 15 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max((`test`.`t1`.`a4` + 0.01)) AS `max(a4 + 0.01)` from `test`.`t1` +explain +select min(a3) from t1 where (a2 +1 ) is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 16 NULL 15 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where ((`test`.`t1`.`a2` + 1) is null) +explain +select min(a3) from t1 where (a2 + 1) = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 16 NULL 15 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where ((`test`.`t1`.`a2` + 1) = 2) +explain +select min(a3) from t1 where 2 = (a2 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 16 NULL 15 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a3`) AS `min(a3)` from `test`.`t1` where (2 = (`test`.`t1`.`a2` + 1)) +explain +select min(a2) from t1 where a2 < 2 * a2 - 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 16 NULL 15 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a2`) AS `min(a2)` from `test`.`t1` where (`test`.`t1`.`a2` < ((2 * `test`.`t1`.`a2`) - 8)) +explain +select min(a1) from t1 where a1 between a3 and 'KKK'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY k1 16 NULL 15 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a1`) AS `min(a1)` from `test`.`t1` where (`test`.`t1`.`a1` between `test`.`t1`.`a3` and 'KKK') +explain +select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 21 NULL 15 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a4`) AS `min(a4)` from `test`.`t1` where ((`test`.`t1`.`a4` + 0.01) between 0.07 and 0.08) +explain +select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range k2 k2 13 NULL 6 100.00 Using where; Using index +2 SIMPLE t1 NULL index NULL k1 16 NULL 15 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select concat(min(`test`.`t1`.`a1`),min(`min(t2.a4)`)) AS `concat(min(t1.a1),min(t2.a4))` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a4` <> 'AME') +drop table t1, t2; +create table t1 (a char(10)); +insert into t1 values ('a'),('b'),('c'); +select coercibility(max(a)) from t1; +coercibility(max(a)) +2 +drop table t1; +create table t1 (a char character set latin2); +insert into t1 values ('a'),('b'); +select charset(max(a)), coercibility(max(a)), +charset(min(a)), coercibility(min(a)) from t1; +charset(max(a)) coercibility(max(a)) charset(min(a)) coercibility(min(a)) +latin2 2 latin2 2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) CHARACTER SET latin2 COLLATE latin2_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 select max(a),min(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `max(a)` char(1) CHARACTER SET latin2 DEFAULT NULL, + `min(a)` char(1) CHARACTER SET latin2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(1) CHARACTER SET latin2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2,t1; +create table t1 (a int); +insert into t1 values (1); +select max(a) as b from t1 having b=1; +b +1 +select a from t1 having a=1; +a +1 +drop table t1; +create table t1 (a int); +select variance(2) from t1; +variance(2) +NULL +select stddev(2) from t1; +stddev(2) +NULL +drop table t1; +create table t1 (a int); +insert into t1 values (1),(2); +prepare stmt1 from 'SELECT COUNT(*) FROM t1'; +execute stmt1; +COUNT(*) +2 +execute stmt1; +COUNT(*) +2 +execute stmt1; +COUNT(*) +2 +deallocate prepare stmt1; +drop table t1; +create table t1 (a int, primary key(a)); +insert into t1 values (1),(2); +prepare stmt1 from 'SELECT max(a) FROM t1'; +execute stmt1; +max(a) +2 +execute stmt1; +max(a) +2 +execute stmt1; +max(a) +2 +deallocate prepare stmt1; +drop table t1; +CREATE TABLE t1 (a int primary key); +INSERT INTO t1 VALUES (1),(2),(3),(4); +SELECT MAX(a) FROM t1 WHERE a > 5; +MAX(a) +NULL +SELECT MIN(a) FROM t1 WHERE a < 0; +MIN(a) +NULL +DROP TABLE t1; +CREATE TABLE t1 ( +id int(10) unsigned NOT NULL auto_increment, +val enum('one','two','three') NOT NULL default 'one', +PRIMARY KEY (id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,'one'),(2,'two'),(3,'three'),(4,'one'),(5,'two'); +select val, count(*) from t1 group by val; +val count(*) +one 2 +two 2 +three 1 +drop table t1; +CREATE TABLE t1 ( +id int(10) unsigned NOT NULL auto_increment, +val set('one','two','three') NOT NULL default 'one', +PRIMARY KEY (id) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,'one'),(2,'two'),(3,'three'),(4,'one'),(5,'two'); +select val, count(*) from t1 group by val; +val count(*) +one 2 +two 2 +three 1 +drop table t1; +create table t1(a int, b datetime); +insert into t1 values (1, NOW()), (2, NOW()); +create table t2 select MAX(b) from t1 group by a; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MAX(b)` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1(f1 datetime); +insert into t1 values (now()); +create table t2 select f2 from (select max(now()) f2 from t1) a; +show columns from t2; +Field Type Null Key Default Extra +f2 datetime YES NULL +drop table t2; +create table t2 select f2 from (select now() f2 from t1) a; +show columns from t2; +Field Type Null Key Default Extra +f2 datetime NO 0000-00-00 00:00:00 +drop table t2, t1; +SET sql_mode = default; +CREATE TABLE t1( +id int PRIMARY KEY, +a int, +b int, +INDEX i_b_id(a,b,id), +INDEX i_id(a,id) +); +INSERT INTO t1 VALUES +(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1); +SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; +MAX(id) +NULL +DROP TABLE t1; +CREATE TABLE t1( +id int PRIMARY KEY, +a int, +b int, +INDEX i_id(a,id), +INDEX i_b_id(a,b,id) +); +INSERT INTO t1 VALUES +(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1); +SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; +MAX(id) +NULL +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY, b char(3), INDEX(b)); +INSERT INTO t1 VALUES (1,'xx'), (2,'aa'); +SELECT * FROM t1; +id b +1 xx +2 aa +SELECT MAX(b) FROM t1 WHERE b < 'ppppp'; +MAX(b) +aa +SHOW WARNINGS; +Level Code Message +SELECT MAX(b) FROM t1 WHERE b < 'pp'; +MAX(b) +aa +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY, b char(16), INDEX(b(4))); +INSERT INTO t1 VALUES (1, 'xxxxbbbb'), (2, 'xxxxaaaa'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT MAX(b) FROM t1; +MAX(b) +xxxxbbbb +EXPLAIN SELECT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +DROP TABLE t1; +CREATE TABLE t1 (id int , b varchar(512), INDEX(b(250))) COLLATE latin1_bin; +INSERT INTO t1 VALUES +(1,CONCAT(REPEAT('_', 250), "qq")), (1,CONCAT(REPEAT('_', 250), "zz")), +(1,CONCAT(REPEAT('_', 250), "aa")), (1,CONCAT(REPEAT('_', 250), "ff")); +SELECT MAX(b) FROM t1; +MAX(b) +__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________zz +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT MAX(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(1,2),(2,3); +SELECT (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a; +(SELECT COUNT(DISTINCT t1.b)) +2 +1 +SELECT (SELECT COUNT(DISTINCT 12)) FROM t1 GROUP BY t1.a; +(SELECT COUNT(DISTINCT 12)) +1 +1 +SELECT AVG(2), BIT_AND(2), BIT_OR(2), BIT_XOR(2), COUNT(*), COUNT(12), +COUNT(DISTINCT 12), MIN(2),MAX(2),STD(2), VARIANCE(2),SUM(2), +GROUP_CONCAT(2),GROUP_CONCAT(DISTINCT 2); +AVG(2) BIT_AND(2) BIT_OR(2) BIT_XOR(2) COUNT(*) COUNT(12) COUNT(DISTINCT 12) MIN(2) MAX(2) STD(2) VARIANCE(2) SUM(2) GROUP_CONCAT(2) GROUP_CONCAT(DISTINCT 2) +2.00000 2 2 2 1 1 1 2 2 0 0 2 2 2 +DROP TABLE t1; +create table t2 (ff double); +insert into t2 values (2.2); +select cast(sum(distinct ff) as decimal(5,2)) from t2; +cast(sum(distinct ff) as decimal(5,2)) +2.20 +select cast(sum(distinct ff) as signed) from t2; +cast(sum(distinct ff) as signed) +2 +select cast(variance(ff) as decimal(10,3)) from t2; +cast(variance(ff) as decimal(10,3)) +0.000 +select cast(min(ff) as decimal(5,2)) from t2; +cast(min(ff) as decimal(5,2)) +2.20 +create table t1 (df decimal(5,1)); +insert into t1 values(1.1); +insert into t1 values(2.2); +select cast(sum(distinct df) as signed) from t1; +cast(sum(distinct df) as signed) +3 +select cast(min(df) as signed) from t1; +cast(min(df) as signed) +1 +select 1e8 * sum(distinct df) from t1; +1e8 * sum(distinct df) +330000000 +select 1e8 * min(df) from t1; +1e8 * min(df) +110000000.00000001 +create table t3 (ifl int); +insert into t3 values(1), (2); +select cast(min(ifl) as decimal(5,2)) from t3; +cast(min(ifl) as decimal(5,2)) +1.00 +drop table t1, t2, t3; +CREATE TABLE t1 (id int(11),value1 float(10,2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00), (2,13.00); +select id, stddev_pop(value1), var_pop(value1), stddev_samp(value1), var_samp(value1) from t1 group by id; +id stddev_pop(value1) var_pop(value1) stddev_samp(value1) var_samp(value1) +1 0.816496580927726 0.6666666666666666 1 1 +2 1.118033988749895 1.25 1.2909944487358056 1.6666666666666667 +DROP TABLE t1; +CREATE TABLE t1 (col1 decimal(16,12)); +INSERT INTO t1 VALUES (-5.00000000001),(-5.00000000002),(-5.00000000003),(-5.00000000000),(-5.00000000001),(-5.00000000002); +insert into t1 select * from t1; +select col1,count(col1),sum(col1),avg(col1) from t1 group by col1; +col1 count(col1) sum(col1) avg(col1) +-5.000000000000 2 -10.000000000000 -5.00000000000000000 +-5.000000000010 4 -20.000000000040 -5.00000000001000000 +-5.000000000020 4 -20.000000000080 -5.00000000002000000 +-5.000000000030 2 -10.000000000060 -5.00000000003000000 +DROP TABLE t1; +create table t1 (col1 decimal(16,12)); +insert into t1 values (-5.00000000001); +insert into t1 values (-5.00000000001); +select col1,sum(col1),max(col1),min(col1) from t1 group by col1; +col1 sum(col1) max(col1) min(col1) +-5.000000000010 -10.000000000020 -5.000000000010 -5.000000000010 +delete from t1; +insert into t1 values (5.00000000001); +insert into t1 values (5.00000000001); +select col1,sum(col1),max(col1),min(col1) from t1 group by col1; +col1 sum(col1) max(col1) min(col1) +5.000000000010 10.000000000020 5.000000000010 5.000000000010 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(400)) charset latin1; +INSERT INTO t1 (a) VALUES ("A"), ("a"), ("a "), ("a "), +("B"), ("b"), ("b "), ("b "); +SELECT COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +2 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 (a, b, c) VALUES +(1,1,1), (1,1,2), (1,1,3), +(1,2,1), (1,2,2), (1,2,3), +(1,3,1), (1,3,2), (1,3,3), +(2,1,1), (2,1,2), (2,1,3), +(2,2,1), (2,2,2), (2,2,3), +(2,3,1), (2,3,2), (2,3,3), +(3,1,1), (3,1,2), (3,1,3), +(3,2,1), (3,2,2), (3,2,3), +(3,3,1), (3,3,2), (3,3,3); +SELECT b/c as v, a FROM t1 ORDER BY v, a; +v a +0.33333 1 +0.33333 2 +0.33333 3 +0.50000 1 +0.50000 2 +0.50000 3 +0.66667 1 +0.66667 2 +0.66667 3 +1.00000 1 +1.00000 1 +1.00000 1 +1.00000 2 +1.00000 2 +1.00000 2 +1.00000 3 +1.00000 3 +1.00000 3 +1.50000 1 +1.50000 2 +1.50000 3 +2.00000 1 +2.00000 2 +2.00000 3 +3.00000 1 +3.00000 2 +3.00000 3 +SELECT b/c as v, SUM(a) FROM t1 GROUP BY v; +v SUM(a) +0.33333 6 +0.50000 6 +0.66667 6 +1.00000 18 +1.50000 6 +2.00000 6 +3.00000 6 +SELECT SUM(a) FROM t1 GROUP BY b/c; +SUM(a) +18 +6 +6 +6 +6 +6 +6 +DROP TABLE t1; +set div_precision_increment= @sav_dpi; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +CREATE TABLE t2 (a INT PRIMARY KEY, b INT); +INSERT INTO t2 VALUES (1,1), (3,3); +SELECT +(SELECT SUM(c.a) FROM t1 ttt, t2 ccc +WHERE ttt.a = ccc.b AND ttt.a = t.a GROUP BY ttt.a) AS minid +FROM t1 t, t2 c WHERE t.a = c.b; +minid +1 +DROP TABLE t1,t2; +create table t1 select variance(0); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `variance(0)` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 select stddev(0); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `stddev(0)` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table bug22555 (i smallint primary key auto_increment, s1 smallint, s2 smallint, e decimal(30,10), o double); +insert into bug22555 (s1, s2, e, o) values (53, 78, 11.4276528, 6.828112), (17, 78, 5.916793, 1.8502951), (18, 76, 2.679231, 9.17975591), (31, 62, 6.07831, 0.1), (19, 41, 5.37463, 15.1), (83, 73, 14.567426, 7.959222), (92, 53, 6.10151, 13.1856852), (7, 12, 13.92272, 3.442007), (92, 35, 11.95358909, 6.01376678), (38, 84, 2.572, 7.904571); +select std(s1/s2) from bug22555 group by i; +std(s1/s2) +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +select std(e) from bug22555 group by i; +std(e) +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +select std(o) from bug22555 group by i; +std(o) +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +drop table bug22555; +create table bug22555 (i smallint, s1 smallint, s2 smallint, o1 double, o2 double, e1 decimal, e2 decimal); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +select i, count(*) from bug22555 group by i; +i count(*) +1 1 +2 1 +3 1 +select std(s1/s2) from bug22555 where i=1; +std(s1/s2) +0 +select std(s1/s2) from bug22555 where i=2; +std(s1/s2) +0 +select std(s1/s2) from bug22555 where i=3; +std(s1/s2) +0 +select std(s1/s2) from bug22555 where i=1 group by i; +std(s1/s2) +0 +select std(s1/s2) from bug22555 where i=2 group by i; +std(s1/s2) +0 +select std(s1/s2) from bug22555 where i=3 group by i; +std(s1/s2) +0 +select std(s1/s2) from bug22555 group by i order by i; +std(s1/s2) +0 +0 +0 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 1 0 +2 1 0 +3 1 0 +set @saved_div_precision_increment=@@div_precision_increment; +set div_precision_increment=19; +select i, count(*), variance(s1/s2) from bug22555 group by i order by i; +i count(*) variance(s1/s2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), variance(o1/o2) from bug22555 group by i order by i; +i count(*) variance(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), variance(e1/e2) from bug22555 group by i order by i; +i count(*) variance(e1/e2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 1 0 +2 1 0 +3 1 0 +set div_precision_increment=20; +select i, count(*), variance(s1/s2) from bug22555 group by i order by i; +i count(*) variance(s1/s2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), variance(o1/o2) from bug22555 group by i order by i; +i count(*) variance(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), variance(e1/e2) from bug22555 group by i order by i; +i count(*) variance(e1/e2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 1 0 +2 1 0 +3 1 0 +set @@div_precision_increment=@saved_div_precision_increment; +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), round(std(o1/o2), 16) from bug22555 group by i order by i; +i count(*) round(std(o1/o2), 16) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 4 0 +2 4 0 +3 4 0 +select std(s1/s2) from bug22555; +std(s1/s2) +0.21325763593256278 +select std(o1/o2) from bug22555; +std(o1/o2) +0.2132576358664934 +select std(e1/e2) from bug22555; +std(e1/e2) +0.21325763593256278 +set @saved_div_precision_increment=@@div_precision_increment; +set div_precision_increment=19; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), round(std(o1/o2), 16) from bug22555 group by i order by i; +i count(*) round(std(o1/o2), 16) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 4 0 +2 4 0 +3 4 0 +select round(std(s1/s2), 17) from bug22555; +round(std(s1/s2), 17) +0.2132576358664934 +select std(o1/o2) from bug22555; +std(o1/o2) +0.2132576358664934 +select round(std(e1/e2), 17) from bug22555; +round(std(e1/e2), 17) +0.2132576358664934 +set div_precision_increment=20; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), round(std(o1/o2), 16) from bug22555 group by i order by i; +i count(*) round(std(o1/o2), 16) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 4 0 +2 4 0 +3 4 0 +select round(std(s1/s2), 17) from bug22555; +round(std(s1/s2), 17) +0.2132576358664934 +select std(o1/o2) from bug22555; +std(o1/o2) +0.2132576358664934 +select round(std(e1/e2), 17) from bug22555; +round(std(e1/e2), 17) +0.2132576358664934 +set @@div_precision_increment=@saved_div_precision_increment; +drop table bug22555; +create table bug22555 (s smallint, o double, e decimal); +insert into bug22555 values (1,1,1),(2,2,2),(3,3,3),(6,6,6),(7,7,7); +select var_samp(s), var_pop(s) from bug22555; +var_samp(s) var_pop(s) +6.7 5.36 +select var_samp(o), var_pop(o) from bug22555; +var_samp(o) var_pop(o) +6.7 5.36 +select var_samp(e), var_pop(e) from bug22555; +var_samp(e) var_pop(e) +6.7 5.36 +drop table bug22555; +create table bug22555 (s smallint, o double, e decimal); +insert into bug22555 values (null,null,null),(null,null,null); +select var_samp(s) as 'null', var_pop(s) as 'null' from bug22555; +null null +NULL NULL +select var_samp(o) as 'null', var_pop(o) as 'null' from bug22555; +null null +NULL NULL +select var_samp(e) as 'null', var_pop(e) as 'null' from bug22555; +null null +NULL NULL +insert into bug22555 values (1,1,1); +select var_samp(s) as 'null', var_pop(s) as '0' from bug22555; +null 0 +NULL 0 +select var_samp(o) as 'null', var_pop(o) as '0' from bug22555; +null 0 +NULL 0 +select var_samp(e) as 'null', var_pop(e) as '0' from bug22555; +null 0 +NULL 0 +insert into bug22555 values (2,2,2); +select var_samp(s) as '0.5', var_pop(s) as '0.25' from bug22555; +0.5 0.25 +0.5 0.25 +select var_samp(o) as '0.5', var_pop(o) as '0.25' from bug22555; +0.5 0.25 +0.5 0.25 +select var_samp(e) as '0.5', var_pop(e) as '0.25' from bug22555; +0.5 0.25 +0.5 0.25 +drop table bug22555; +create table t1 (a decimal(20)); +insert into t1 values (12345678901234567890); +select count(a) from t1; +count(a) +1 +select count(distinct a) from t1; +count(distinct a) +1 +drop table t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8); +INSERT INTO t1 SELECT a, b+8 FROM t1; +INSERT INTO t1 SELECT a, b+16 FROM t1; +INSERT INTO t1 SELECT a, b+32 FROM t1; +INSERT INTO t1 SELECT a, b+64 FROM t1; +INSERT INTO t1 SELECT a, b+128 FROM t1; +INSERT INTO t1 SELECT a, b+256 FROM t1; +INSERT INTO t1 SELECT a, b+512 FROM t1; +INSERT INTO t1 SELECT a, b+1024 FROM t1; +INSERT INTO t1 SELECT a, b+2048 FROM t1; +INSERT INTO t1 SELECT a, b+4096 FROM t1; +INSERT INTO t1 SELECT a, b+8192 FROM t1; +INSERT INTO t1 SELECT a, b+16384 FROM t1; +INSERT INTO t1 SELECT a, b+32768 FROM t1; +SELECT a,COUNT(DISTINCT b) AS cnt FROM t1 GROUP BY a HAVING cnt > 50; +a cnt +1 65536 +SELECT a,SUM(DISTINCT b) AS sumation FROM t1 GROUP BY a HAVING sumation > 50; +a sumation +1 2147516416 +SELECT a,AVG(DISTINCT b) AS average FROM t1 GROUP BY a HAVING average > 50; +a average +1 32768.5000 +DROP TABLE t1; +CREATE TABLE t1 ( a INT, b INT, KEY(a) ); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT MIN(a), MIN(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a`) AS `MIN(a)`,min(`test`.`t1`.`b`) AS `MIN(b)` from `test`.`t1` +SELECT MIN(a), MIN(b) FROM t1; +MIN(a) MIN(b) +NULL 1 +CREATE TABLE t2( a INT, b INT, c INT, KEY(a, b) ); +INSERT INTO t2 ( a, b, c ) VALUES ( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 ); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 5 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`b`) AS `MIN(b)`,min(`test`.`t2`.`c`) AS `MIN(c)` from `test`.`t2` where (`test`.`t2`.`a` = 1) +SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; +MIN(b) MIN(c) +3 2 +CREATE TABLE t3 (a INT, b INT, c int, KEY(a, b)); +INSERT INTO t3 VALUES (1, NULL, 1), (2, NULL, 2), (2, NULL, 2), (3, NULL, 3); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT MIN(a), MIN(b) FROM t3 where a = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t3`.`a`) AS `MIN(a)`,min(`test`.`t3`.`b`) AS `MIN(b)` from `test`.`t3` where multiple equal(2, `test`.`t3`.`a`) +SELECT MIN(a), MIN(b) FROM t3 where a = 2; +MIN(a) MIN(b) +2 NULL +CREATE TABLE t4 (a INT, b INT, c int, KEY(a, b)); +INSERT INTO t4 VALUES (1, 1, 1), (2, NULL, 2), (2, NULL, 2), (3, 1, 3); +ANALYZE TABLE t4; +Table Op Msg_type Msg_text +test.t4 analyze status OK +EXPLAIN SELECT MIN(a), MIN(b) FROM t4 where a = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t4`.`a`) AS `MIN(a)`,min(`test`.`t4`.`b`) AS `MIN(b)` from `test`.`t4` where multiple equal(2, `test`.`t4`.`a`) +SELECT MIN(a), MIN(b) FROM t4 where a = 2; +MIN(a) MIN(b) +2 NULL +SELECT MIN(b), min(c) FROM t4 where a = 2; +MIN(b) min(c) +NULL 2 +CREATE TABLE t5( a INT, b INT, KEY( a, b) ); +INSERT INTO t5 VALUES( 1, 1 ), ( 1, 2 ); +ANALYZE TABLE t5; +Table Op Msg_type Msg_text +test.t5 analyze status OK +EXPLAIN SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t5`.`a`) AS `MIN(a)`,min(`test`.`t5`.`b`) AS `MIN(b)` from `test`.`t5` where multiple equal(1, `test`.`t5`.`a`) +SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1; +MIN(a) MIN(b) +1 1 +SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1 and b > 1; +MIN(a) MIN(b) +1 2 +DROP TABLE t1, t2, t3, t4, t5; +CREATE TABLE t1 (a INT); +INSERT INTO t1 values (),(),(); +SELECT (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ) as x FROM t1 +GROUP BY x; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +DROP TABLE t1; +CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b)); +SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01'; +MIN(b) +NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +SELECT a FROM t1 HAVING COUNT(*)>2; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.a'; this is incompatible with sql_mode=only_full_group_by +SELECT COUNT(*), a FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.a'; this is incompatible with sql_mode=only_full_group_by +SELECT a FROM t1 HAVING COUNT(*)>2; +a +1 +SELECT COUNT(*), a FROM t1; +COUNT(*) a +4 1 +DROP TABLE t1; +set SQL_MODE=ONLY_FULL_GROUP_BY; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +CREATE VIEW v1 AS SELECT a,(a + 1) AS y FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT y FROM v1 GROUP BY v1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 1) AS `y` from `test`.`t1` group by (`test`.`t1`.`a` + 1) +DROP VIEW v1; +DROP TABLE t1; +SET SQL_MODE=DEFAULT; +CREATE TABLE t1(a DOUBLE); +INSERT INTO t1 VALUES (10), (20); +SELECT AVG(a), CAST(AVG(a) AS DECIMAL) FROM t1; +AVG(a) CAST(AVG(a) AS DECIMAL) +15 15 +DROP TABLE t1; +CREATE TABLE derived1 (a bigint(21)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO derived1 VALUES (2); +CREATE TABLE D ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) DEFAULT NULL, +int_key int(11) DEFAULT NULL, +filler blob, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO D VALUES +(39,40,4,repeat(' X', 42)), +(43,56,4,repeat(' X', 42)), +(47,12,4,repeat(' X', 42)), +(71,28,4,repeat(' X', 42)), +(76,54,4,repeat(' X', 42)), +(83,45,4,repeat(' X', 42)), +(105,53,12,NULL); +SELECT +(SELECT COUNT( int_nokey ) +FROM derived1 AS X +WHERE +X.int_nokey < 61 +GROUP BY pk +LIMIT 1) +FROM D AS X +WHERE X.int_key < 13 +GROUP BY int_nokey LIMIT 1; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.X.pk' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE derived1; +DROP TABLE D; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3); +SET SQL_MODE='ONLY_FULL_GROUP_BY'; +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SELECT COUNT(*) FROM t1 where a=1; +COUNT(*) +3 +SELECT COUNT(*),a FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.a'; this is incompatible with sql_mode=only_full_group_by +SELECT COUNT(*) FROM t1 a JOIN t1 b ON a.a= b.a; +COUNT(*) +9 +SELECT COUNT(*), (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a) +FROM t1 outr; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.outr.a'; this is incompatible with sql_mode=only_full_group_by +SELECT COUNT(*) FROM t1 a JOIN t1 outr +ON a.a= (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a); +COUNT(*) +0 +SET SQL_MODE=default; +DROP TABLE t1; +End of 5.0 tests +# +# BUG#47280 - strange results from count(*) with order by multiple +# columns without where/group +# +# +# Initialize test +# +CREATE TABLE t1 ( +pk INT NOT NULL, +i INT, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,11),(2,12),(3,13); +# +# Start test +# All the following queries shall return 1 record +# + +# Masking all correct values {11...13} for column i in this result. +SELECT MAX(pk) as max, i +FROM t1 +ORDER BY max; +max i +3 # + +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT MAX(pk) as max, i +FROM t1 +ORDER BY max; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk`) AS `max`,`test`.`t1`.`i` AS `i` from `test`.`t1` + +# Only 11 is correct for collumn i in this result +SELECT MAX(pk) as max, i +FROM t1 +WHERE pk<2 +ORDER BY max; +max i +1 11 +# +# Cleanup +# +DROP TABLE t1; +# +# Bug#43668: Wrong comparison and MIN/MAX for YEAR(2) +# WL#6263: Remove year(2) +# +create table t1 (f1 year, f2 year, f3 date, f4 datetime); +insert into t1 values +(98,1998,19980101,"1998-01-01 00:00:00"), +('00',2000,20000101,"2000-01-01 00:00:01"), +(02,2002,20020101,"2002-01-01 23:59:59"), +(60,2060,20600101,"2060-01-01 11:11:11"), +(70,1970,19700101,"1970-11-11 22:22:22"), +(NULL,NULL,NULL,NULL); +select min(f1),max(f1) from t1; +min(f1) max(f1) +1970 2060 +select min(f2),max(f2) from t1; +min(f2) max(f2) +1970 2060 +select min(f3),max(f3) from t1; +min(f3) max(f3) +1970-01-01 2060-01-01 +select min(f4),max(f4) from t1; +min(f4) max(f4) +1970-11-11 22:22:22 2060-01-01 11:11:11 +select a.f1 as a, b.f1 as b, a.f1 > b.f1 as gt, +a.f1 < b.f1 as lt, a.f1<=>b.f1 as eq +from t1 a, t1 b; +a b gt lt eq +1970 1970 0 0 1 +1970 1998 0 1 0 +1970 2000 0 1 0 +1970 2002 0 1 0 +1970 2060 0 1 0 +1970 NULL NULL NULL 0 +1998 1970 1 0 0 +1998 1998 0 0 1 +1998 2000 0 1 0 +1998 2002 0 1 0 +1998 2060 0 1 0 +1998 NULL NULL NULL 0 +2000 1970 1 0 0 +2000 1998 1 0 0 +2000 2000 0 0 1 +2000 2002 0 1 0 +2000 2060 0 1 0 +2000 NULL NULL NULL 0 +2002 1970 1 0 0 +2002 1998 1 0 0 +2002 2000 1 0 0 +2002 2002 0 0 1 +2002 2060 0 1 0 +2002 NULL NULL NULL 0 +2060 1970 1 0 0 +2060 1998 1 0 0 +2060 2000 1 0 0 +2060 2002 1 0 0 +2060 2060 0 0 1 +2060 NULL NULL NULL 0 +NULL 1970 NULL NULL 0 +NULL 1998 NULL NULL 0 +NULL 2000 NULL NULL 0 +NULL 2002 NULL NULL 0 +NULL 2060 NULL NULL 0 +NULL NULL NULL NULL 1 +select a.f1 as a, b.f2 as b, a.f1 > b.f2 as gt, +a.f1 < b.f2 as lt, a.f1<=>b.f2 as eq +from t1 a, t1 b; +a b gt lt eq +1970 1970 0 0 1 +1970 1998 0 1 0 +1970 2000 0 1 0 +1970 2002 0 1 0 +1970 2060 0 1 0 +1970 NULL NULL NULL 0 +1998 1970 1 0 0 +1998 1998 0 0 1 +1998 2000 0 1 0 +1998 2002 0 1 0 +1998 2060 0 1 0 +1998 NULL NULL NULL 0 +2000 1970 1 0 0 +2000 1998 1 0 0 +2000 2000 0 0 1 +2000 2002 0 1 0 +2000 2060 0 1 0 +2000 NULL NULL NULL 0 +2002 1970 1 0 0 +2002 1998 1 0 0 +2002 2000 1 0 0 +2002 2002 0 0 1 +2002 2060 0 1 0 +2002 NULL NULL NULL 0 +2060 1970 1 0 0 +2060 1998 1 0 0 +2060 2000 1 0 0 +2060 2002 1 0 0 +2060 2060 0 0 1 +2060 NULL NULL NULL 0 +NULL 1970 NULL NULL 0 +NULL 1998 NULL NULL 0 +NULL 2000 NULL NULL 0 +NULL 2002 NULL NULL 0 +NULL 2060 NULL NULL 0 +NULL NULL NULL NULL 1 +select a.f1 as a, b.f3 as b, a.f1 > b.f3 as gt, +a.f1 < b.f3 as lt, a.f1<=>b.f3 as eq +from t1 a, t1 b; +a b gt lt eq +1970 1970-01-01 0 1 0 +1970 1998-01-01 0 1 0 +1970 2000-01-01 0 1 0 +1970 2002-01-01 0 1 0 +1970 2060-01-01 0 1 0 +1970 NULL NULL NULL 0 +1998 1970-01-01 1 0 0 +1998 1998-01-01 0 1 0 +1998 2000-01-01 0 1 0 +1998 2002-01-01 0 1 0 +1998 2060-01-01 0 1 0 +1998 NULL NULL NULL 0 +2000 1970-01-01 1 0 0 +2000 1998-01-01 1 0 0 +2000 2000-01-01 0 1 0 +2000 2002-01-01 0 1 0 +2000 2060-01-01 0 1 0 +2000 NULL NULL NULL 0 +2002 1970-01-01 1 0 0 +2002 1998-01-01 1 0 0 +2002 2000-01-01 1 0 0 +2002 2002-01-01 0 1 0 +2002 2060-01-01 0 1 0 +2002 NULL NULL NULL 0 +2060 1970-01-01 1 0 0 +2060 1998-01-01 1 0 0 +2060 2000-01-01 1 0 0 +2060 2002-01-01 1 0 0 +2060 2060-01-01 0 1 0 +2060 NULL NULL NULL 0 +NULL 1970-01-01 NULL NULL 0 +NULL 1998-01-01 NULL NULL 0 +NULL 2000-01-01 NULL NULL 0 +NULL 2002-01-01 NULL NULL 0 +NULL 2060-01-01 NULL NULL 0 +NULL NULL NULL NULL 1 +select a.f1 as a, b.f4 as b, a.f1 > b.f4 as gt, +a.f1 < b.f4 as lt, a.f1<=>b.f4 as eq +from t1 a, t1 b; +a b gt lt eq +1970 1970-11-11 22:22:22 0 1 0 +1970 1998-01-01 00:00:00 0 1 0 +1970 2000-01-01 00:00:01 0 1 0 +1970 2002-01-01 23:59:59 0 1 0 +1970 2060-01-01 11:11:11 0 1 0 +1970 NULL NULL NULL 0 +1998 1970-11-11 22:22:22 1 0 0 +1998 1998-01-01 00:00:00 0 1 0 +1998 2000-01-01 00:00:01 0 1 0 +1998 2002-01-01 23:59:59 0 1 0 +1998 2060-01-01 11:11:11 0 1 0 +1998 NULL NULL NULL 0 +2000 1970-11-11 22:22:22 1 0 0 +2000 1998-01-01 00:00:00 1 0 0 +2000 2000-01-01 00:00:01 0 1 0 +2000 2002-01-01 23:59:59 0 1 0 +2000 2060-01-01 11:11:11 0 1 0 +2000 NULL NULL NULL 0 +2002 1970-11-11 22:22:22 1 0 0 +2002 1998-01-01 00:00:00 1 0 0 +2002 2000-01-01 00:00:01 1 0 0 +2002 2002-01-01 23:59:59 0 1 0 +2002 2060-01-01 11:11:11 0 1 0 +2002 NULL NULL NULL 0 +2060 1970-11-11 22:22:22 1 0 0 +2060 1998-01-01 00:00:00 1 0 0 +2060 2000-01-01 00:00:01 1 0 0 +2060 2002-01-01 23:59:59 1 0 0 +2060 2060-01-01 11:11:11 0 1 0 +2060 NULL NULL NULL 0 +NULL 1970-11-11 22:22:22 NULL NULL 0 +NULL 1998-01-01 00:00:00 NULL NULL 0 +NULL 2000-01-01 00:00:01 NULL NULL 0 +NULL 2002-01-01 23:59:59 NULL NULL 0 +NULL 2060-01-01 11:11:11 NULL NULL 0 +NULL NULL NULL NULL 1 +select *, f1 = f2 from t1; +f1 f2 f3 f4 f1 = f2 +1998 1998 1998-01-01 1998-01-01 00:00:00 1 +2000 2000 2000-01-01 2000-01-01 00:00:01 1 +2002 2002 2002-01-01 2002-01-01 23:59:59 1 +2060 2060 2060-01-01 2060-01-01 11:11:11 1 +1970 1970 1970-01-01 1970-11-11 22:22:22 1 +NULL NULL NULL NULL NULL +drop table t1; +# +# Bug #54465: assert: field_types == 0 || field_types[field_pos] == +# MYSQL_TYPE_LONGLONG +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT MAX((SELECT 1 FROM t1 ORDER BY @var LIMIT 1)) m FROM t1 t2, t1 +ORDER BY t1.a; +m +1 +DROP TABLE t1; +# +# Bug#58030 crash in Item_func_geometry_from_text::val_str +# +SELECT MAX(TIMESTAMP(RAND(0))); +SELECT MIN(TIMESTAMP(RAND(0))); +# +# Bug#58177 crash and valgrind warnings in decimal and protocol sending functions... +# +SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',0) / '0b1111111111111111111111111111111111111111111111111111111111111111111111111' ^ (RAND())); +SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',0) / '0b1111111111111111111111111111111111111111111111111111111111111111111111111' ^ (RAND())); +SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',0) / '0b1111111111111111111111111111111111111111111111111111111111111111111111111' ^ (RAND())); +SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',0) / '0b1111111111111111111111111111111111111111111111111111111111111111111111111' ^ (RAND())); +SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa'); +# +# Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS +# +CREATE TABLE t1 (a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (18446668621106209655); +SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1; +MAX(LENGTH(a)) LENGTH(MAX(a)) MIN(a) MAX(a) CONCAT(MIN(a)) CONCAT(MAX(a)) +20 20 18446668621106209655 18446668621106209655 18446668621106209655 18446668621106209655 +DROP TABLE t1; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +End of 5.1 tests +# +# Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(), +# file .\item_sum.cc, line 587 +# +CREATE TABLE t1(a int, KEY(a)); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 FROM t1 ORDER BY AVG(DISTINCT a); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +DROP TABLE t1; +# +# Bug#55648: Server crash on MIN/MAX on maximum time value +# +CREATE TABLE t1(c1 TIME NOT NULL); +INSERT INTO t1 VALUES('837:59:59'); +INSERT INTO t1 VALUES('838:59:59'); +SELECT MAX(c1) FROM t1; +MAX(c1) +838:59:59 +DROP TABLE t1; +# End of the bug#55648 +# +# Bug#56120: Failed assertion on MIN/MAX on negative time value +# +CREATE TABLE t1(c1 TIME NOT NULL); +INSERT INTO t1 VALUES('-00:00:01'); +SELECT MAX(c1),MIN(c1) FROM t1; +MAX(c1) MIN(c1) +-00:00:01 -00:00:01 +DROP TABLE t1; +# End of the bug#56120 +# +# Bug#57932 "query with AVG(DISTINCT) returns NULL if last +# aggregated value was NULL" +# +CREATE TABLE t1 (col_int_nokey int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7),(8),(NULL); +SELECT AVG(DISTINCT col_int_nokey) FROM t1; +AVG(DISTINCT col_int_nokey) +7.5000 +SELECT AVG(DISTINCT outr.col_int_nokey) FROM t1 AS outr LEFT JOIN t1 AS outr2 ON +outr.col_int_nokey = outr2.col_int_nokey; +AVG(DISTINCT outr.col_int_nokey) +7.5000 +DROP TABLE t1; +# End of the bug#57932 +# +# BUG#12773464 - 61925: WRONG RESULT WITH AGGREGATE + NOT BETWEEN + KEY +# +CREATE TABLE t1 (a int, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT MAX(a) FROM t1 WHERE a NOT BETWEEN 3 AND 9; +MAX(a) +10 +DROP TABLE t1; +# +# Bug#13724099 1032 BYTE MEMORY LEAK NEW_CACHED_ITEM IN +# SUBQUERY WITH GROUPING OF OUTER COLUMN +# +CREATE TABLE t1 ( +a BLOB, +b INT) +engine=innodb; +INSERT INTO t1 VALUES ('a', 0); +SELECT 0 FROM t1 +WHERE 0 = (SELECT group_concat(b) +FROM t1 t GROUP BY t1.a) +; +0 +0 +DROP TABLE t1; +# +# Bug#25738624: ASSERTION `FALSE' FAILED IN SQL/SQL_EXECUTOR.CC +# +CREATE TABLE e1(pk INT, col_date DATE); +CREATE TABLE b1(i INT); +CREATE TABLE bb4(col_int_key INT, KEY(col_int_key)) ENGINE=MYISAM; +INSERT INTO bb4 VALUES(4); +UPDATE IGNORE e1 AS outr1, b1 AS outr2 SET outr1.col_date = +JSON_SET(outr1.col_date, CONCAT('$','[',1,']','.','cdate'), '2007-07-12') +WHERE outr1.pk <= ANY ( SELECT DISTINCT innr1.col_int_key AS y FROM bb4 +AS innr2 LEFT JOIN bb4 AS innr1 ON (innr2.col_int_key <> innr1.col_int_key) +WHERE innr1.col_int_key= 4); +DROP TABLE e1, b1, bb4; +CREATE TABLE t1(pk INT, KEY(pk)) ENGINE=MYISAM; +INSERT INTO t1 VALUES(1); +SELECT MIN(i2.pk) FROM t1 i1 LEFT JOIN t1 i2 ON (i1.pk != i2.pk) +WHERE i2.pk = 1; +MIN(i2.pk) +NULL +DROP TABLE t1; +# End of test for bug#25738624 +# +# Bug#25541454: ASSERT `FALSE' FAILED IN READ_SYSTEM / JOIN_READ_CONST_TABLE AT SQL_EXECUTOR.CC +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (4,1,2); +CREATE TABLE t3 ( +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (3,9,1); +CREATE TABLE t4 ( +col_int_key int(11) DEFAULT NULL, +col_int int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT ( +SELECT MIN(subquery1_t1.col_int_key) +FROM t3 AS subquery1_t1 +RIGHT JOIN t1 AS subquery1_t2 +STRAIGHT_JOIN t4 AS subquery1_t3 +ON (subquery1_t3.pk = subquery1_t2.col_int_key) +ON (subquery1_t3.col_int_key = subquery1_t2.col_int) +WHERE subquery1_t1.col_int_key >= table1.col_int +AND subquery1_t3.pk > table1.pk +) +FROM t2 AS table1; +( +SELECT MIN(subquery1_t1.col_int_key) +FROM t3 AS subquery1_t1 +RIGHT JOIN t1 AS subquery1_t2 +STRAIGHT_JOIN t4 AS subquery1_t3 +ON (subquery1_t3.pk = subquery1_t2.col_int_key) +ON (subquery1_t3.col_int_key = subquery1_t2.col_int) +WHERE subquery1_t1.col_int_k +NULL +DROP TABLE t1, t2, t3, t4; +# End of test for bug#25541454 +# +# Bug#29596977 MYSQL OPTIMIZER SCAN FULL INDEX FOR MAX() ON INDEXED COLUMN. +# +CREATE TABLE t1 ( +id BIGINT NOT NULL AUTO_INCREMENT, +f1 BIGINT, +PRIMARY KEY(id), +INDEX ix_fd2 (f1) +); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (NULL, 3); +CREATE FUNCTION f1 (par INT) RETURNS INT +DETERMINISTIC +SQL SECURITY INVOKER +BEGIN +RETURN par + 1; +END| +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT f1(MAX(f1)) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `f1`(max(`test`.`t1`.`f1`)) AS `f1(MAX(f1))` from `test`.`t1` +SELECT f1(MAX(f1)) FROM t1; +f1(MAX(f1)) +4 +DROP TABLE t1; +DROP FUNCTION f1; +# +# Bug#31848191: ITEM_SUM_STD AND _VARIANCE HAS INCORRECT IS_NULL() +# +CREATE TABLE t1 (f1 INTEGER,f2 INTEGER); +INSERT INTO t1 VALUES (1,10),(1,20),(2,NULL),(2,NULL),(3,50); +SELECT f1, STD(f2) FROM t1 GROUP BY f1 WITH ROLLUP HAVING STD(f2) IS NULL; +f1 STD(f2) +2 NULL +SELECT f1, STD(f2) FROM t1 GROUP BY f1 WITH ROLLUP HAVING STD(f2) IS NOT NULL; +f1 STD(f2) +1 5 +3 0 +NULL 16.99673171197595 +DROP TABLE t1; diff --git a/mysql-test/r/func_group_innodb.result-pq b/mysql-test/r/func_group_innodb.result-pq new file mode 100644 index 000000000..dcd5084bd --- /dev/null +++ b/mysql-test/r/func_group_innodb.result-pq @@ -0,0 +1,217 @@ +create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB; +insert into t1 values (1, 3); +select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ; +count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ +1 +select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ; +Case When Count(*) < MAX_REQ Then 1 Else 0 End +1 +drop table t1; +create table t1m (a int) engine=innodb; +create table t1i (a int) engine=innodb; +create table t2m (a int) engine=innodb; +create table t2i (a int) engine=innodb; +insert into t2m values (5); +insert into t2i values (5); +select min(a) from t1m; +min(a) +NULL +select min(7) from t1m; +min(7) +NULL +select min(7) from DUAL; +min(7) +7 +explain select min(7) from t2m join t1m; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select min(7) AS `min(7)` from `test`.`t2m` join `test`.`t1m` +select min(7) from t2m join t1m; +min(7) +NULL +select max(a) from t1m; +max(a) +NULL +select max(7) from t1m; +max(7) +NULL +select max(7) from DUAL; +max(7) +7 +explain select max(7) from t2m join t1m; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(7) AS `max(7)` from `test`.`t2m` join `test`.`t1m` +select max(7) from t2m join t1m; +max(7) +NULL +select 1, min(a) from t1m where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1m where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1m where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1m where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1m where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1m where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1m where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1m where 1=99; +1 max(1) +1 NULL +select min(a) from t1i; +min(a) +NULL +select min(7) from t1i; +min(7) +NULL +select min(7) from DUAL; +min(7) +7 +explain select min(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select min(7) AS `min(7)` from `test`.`t2i` join `test`.`t1i` +select min(7) from t2i join t1i; +min(7) +NULL +select max(a) from t1i; +max(a) +NULL +select max(7) from t1i; +max(7) +NULL +select max(7) from DUAL; +max(7) +7 +explain select max(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(7) AS `max(7)` from `test`.`t2i` join `test`.`t1i` +select max(7) from t2i join t1i; +max(7) +NULL +select 1, min(a) from t1i where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1i where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1i where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1i where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1i where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1i where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1i where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1i where 1=99; +1 max(1) +1 NULL +explain select count(*), min(7), max(7) from t1m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t1i` +select count(*), min(7), max(7) from t1m, t1i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t1m, t2i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t2i` +select count(*), min(7), max(7) from t1m, t2i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t2m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2m NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t2m` join `test`.`t1i` +select count(*), min(7), max(7) from t2m, t1i; +count(*) min(7) max(7) +0 NULL NULL +drop table t1m, t1i, t2m, t2i; +# +# Bug #57954: BIT_AND function returns incorrect results when +# semijoin=on +CREATE TABLE c ( +pk INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO c VALUES (11,NULL); +INSERT INTO c VALUES (16,'c'); +CREATE TABLE bb ( +pk INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO bb VALUES (10,NULL); +SELECT straight_join BIT_AND(c.pk) +FROM +bb, c +WHERE c.col_varchar_key='ABC' +ORDER BY c.pk; +BIT_AND(c.pk) +18446744073709551615 +DROP TABLE c,bb; +# +# Bug #58050: BIT_OR and BIT_XOR return incorrect results when +# semijoin=on +# +CREATE TABLE t1 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 1, 1); +CREATE TABLE t2 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 1, NULL); +SELECT t1.* FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +pk b c +SELECT BIT_OR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_OR(t1.b) +0 +SELECT BIT_AND(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_AND(t1.b) +18446744073709551615 +SELECT BIT_XOR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_XOR(t1.b) +0 +DROP TABLE t1, t2; +End of 5.5 tests diff --git a/mysql-test/r/func_if.result-pq b/mysql-test/r/func_if.result-pq new file mode 100644 index 000000000..d883595d4 --- /dev/null +++ b/mysql-test/r/func_if.result-pq @@ -0,0 +1,324 @@ +drop table if exists t1; +select IF(0,"ERROR","this"),IF(1,"is","ERROR"),IF(NULL,"ERROR","a"),IF(1,2,3)|0,IF(1,2.0,3.0)+0 ; +IF(0,"ERROR","this") IF(1,"is","ERROR") IF(NULL,"ERROR","a") IF(1,2,3)|0 IF(1,2.0,3.0)+0 +this is a 2 2.0 +CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0); +select if(1,st,st) s from t1 order by s; +s +a +A +a +aa +AA +aaa +BBB +select if(u=1,st,st) s from t1 order by s; +s +a +A +a +aa +AA +aaa +BBB +select if(u=1,binary st,st) s from t1 order by s; +s +A +AA +BBB +a +a +aa +aaa +select if(u=1,st,binary st) s from t1 where st like "%a%" order by s; +s +A +AA +a +a +aa +aaa +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select if(u=1,st,binary st) s from t1 where st like "%a%" order by s; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 14.29 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like '%a%') order by `s` +select nullif(u, 1) from t1; +nullif(u, 1) +NULL +NULL +NULL +NULL +NULL +0 +0 +explain select nullif(u, 1) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select nullif(`test`.`t1`.`u`,1) AS `nullif(u, 1)` from `test`.`t1` +drop table t1; +select nullif(1,'test'); +nullif(1,'test') +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'test' +select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test"); +NULLIF(NULL,NULL) NULLIF(NULL,1) NULLIF(NULL,1.0) NULLIF(NULL,"test") +NULL NULL NULL NULL +select NULLIF(1,NULL), NULLIF(1.0, NULL), NULLIF("test", NULL); +NULLIF(1,NULL) NULLIF(1.0, NULL) NULLIF("test", NULL) +1 1.0 test +create table t1 (num double(12,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (144.54); +select sum(if(num is null,0.00,num)) from t1; +sum(if(num is null,0.00,num)) +144.54 +drop table t1; +create table t1 (x int, y int); +insert into t1 values (0,6),(10,16),(20,26),(30,10),(40,46),(50,56); +select min(if(y -x > 5,y,NULL)), max(if(y - x > 5,y,NULL)) from t1; +min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL)) +6 56 +drop table t1; +create table t1 (a int); +insert t1 values (1),(2); +select if(1>2,a,avg(a)) from t1; +if(1>2,a,avg(a)) +1.5000 +drop table t1; +SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL; +NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL +1 0 +CREATE TABLE `t1` ( +`id` int(11) NOT NULL , +`date` int(10) default NULL, +`text` varchar(32) NOT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3'); +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC; +id date_ord text +1 05-03-2005 Day 1 +2 16-03-2005 Day 2 +3 28-03-2005 Day 3 +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC; +id date_ord text +3 28-03-2005 Day 3 +2 16-03-2005 Day 2 +1 05-03-2005 Day 1 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(10)); +INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb'); +SELECT a, NULLIF(a,'') FROM t1; +a NULLIF(a,'') +aaa aaa +NULL NULL + NULL +bbb bbb +SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL; +a NULLIF(a,'') +NULL NULL + NULL +DROP TABLE t1; +create table t1 (f1 int, f2 int); +insert into t1 values(1,1),(0,0); +select f1, f2, if(f1, 40.0, 5.00) from t1 group by f1 order by f2; +f1 f2 if(f1, 40.0, 5.00) +0 0 5.00 +1 1 40.00 +drop table t1; +select if(0, 18446744073709551610, 18446744073709551610); +if(0, 18446744073709551610, 18446744073709551610) +18446744073709551610 +CREATE TABLE t1(a DECIMAL(10,3)); +SELECT t1.a, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2,0)))))))))))))))))))))))))))))) + 1 +FROM t1; +a IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((ROUND(t1.a,2)=1), 2, +IF((R +DROP TABLE t1; +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IF(1, CAST(c AS UNSIGNED), 0)) +12345678901234567890 +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IFNULL(CAST(c AS UNSIGNED), 0)) +12345678901234567890 +DROP TABLE t1; +End of 5.0 tests +# +# Bug#55077: Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c +# +CREATE TABLE t1 (a LONGBLOB, b DOUBLE); +INSERT INTO t1 VALUES (NULL, 0), (NULL, 1); +SELECT IF(b, (SELECT a FROM t1 LIMIT 1), b) c FROM t1 GROUP BY c; +c +0 +NULL +DROP TABLE t1; +# +# Bug#12620084 +# ASSERTION WHEN CHECKING FIELD_TYPES[FIELD_POS] AND IT'S MYSQL_TYPE_NULL +# +SELECT if(0, (SELECT min('hello')), NULL); +if(0, (SELECT min('hello')), NULL) +NULL +SELECT if(1, (SELECT min('hello')), NULL); +if(1, (SELECT min('hello')), NULL) +hello +SELECT if(0, NULL, (SELECT min('hello'))); +if(0, NULL, (SELECT min('hello'))) +hello +SELECT if(1, NULL, (SELECT min('hello'))); +if(1, NULL, (SELECT min('hello'))) +NULL +# +# Bug#12532830 +# SIGFPE OR ASSERTION (PRECISION <= ((9 * 9) - 8*2)) && (DEC <= 30) +# +select +sum(distinct(if('a', +(select adddate(elt(convert(9999999999999999999999999999999999999,decimal(64,0)),count(*)), +interval 1 day)) +, .1))) as foo; +foo +0.1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +# +# Bug#22148586 IF(BOOL, DATE STR, DATE STR) THROWS ERROR IN UPDATE +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1); +UPDATE t1 SET c1 = 2 WHERE IF(true, '2015-01-01', '2015-01-01') IS NOT NULL; +DROP TABLE t1; +# +# Bug#24492965 ERROR RESULTS FROM CALCULATION +# +CREATE TABLE test_grids_1 ( +unq_id int(11) NOT NULL DEFAULT '0', +var_fld int(11) DEFAULT '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO test_grids_1 VALUES +(1,4500), +(2,6000); +CREATE TABLE test_grid_dtl_1 ( +dtl_id int(11) NOT NULL DEFAULT '0', +unq_id int(11) DEFAULT '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO test_grid_dtl_1 VALUES +(1,1), +(2,1), +(3,2); +SELECT g.calc_var, g.if_var, g.case_var +FROM +( +SELECT unq_id, +IF ( var_fld > 5000, ( 1 / var_fld ) , 5000 ) calc_var, +IF ( var_fld > 5000, ( 00001 / var_fld ) , 5000 ) if_var, +CASE var_fld > 5000 WHEN TRUE THEN ( 1 / var_fld ) ELSE 5000 END case_var +FROM +test_grids_1 +) g +JOIN +test_grid_dtl_1 d USING (unq_id) +ORDER BY 1 +; +calc_var if_var case_var +0.0002 0.0002 0.0002 +5000.0000 5000.0000 5000.0000 +5000.0000 5000.0000 5000.0000 +DROP TABLE test_grids_1, test_grid_dtl_1; +# Bug#25669606: regression: assertion failed: !is_temporal() +DO NULLIF(CAST(DATABASE() AS TIME), 1); +Warnings: +Warning 1292 Truncated incorrect time value: 'test' +Warning 1292 Truncated incorrect time value: 'test' +DO NULLIF(CAST(DATABASE() AS DATE), 1); +Warnings: +Warning 1292 Incorrect datetime value: 'test' +Warning 1292 Incorrect datetime value: 'test' +DO NULLIF(CAST(DATABASE() AS DATETIME), 1); +Warnings: +Warning 1292 Incorrect datetime value: 'test' +Warning 1292 Incorrect datetime value: 'test' +# +# Bug#28007237 NULLIF returns boolean in context of JSON_ARRAYAGG and JSON_OBJECTAGG's value +# +SELECT NULLIF(1,2); +NULLIF(1,2) +1 +SELECT JSON_ARRAYAGG(NULLIF(1,2)); +JSON_ARRAYAGG(NULLIF(1,2)) +[1] +SELECT JSON_ARRAYAGG(CASE WHEN 1 = 2 THEN NULL ELSE 1 END); +JSON_ARRAYAGG(CASE WHEN 1 = 2 THEN NULL ELSE 1 END) +[1] +SELECT NULLIF(true,false); +NULLIF(true,false) +1 +SELECT JSON_ARRAYAGG(NULLIF(true,false)); +JSON_ARRAYAGG(NULLIF(true,false)) +[1] +SELECT JSON_ARRAYAGG(CASE WHEN true = false THEN NULL ELSE true END); +JSON_ARRAYAGG(CASE WHEN true = false THEN NULL ELSE true END) +[1] +# Bug#32231557: Field_blob::store_to_mem: assertion `field_charset == cs' failed. +DO GROUP_CONCAT(NULLIF(ELT(1, @e), POINT(250,41)) ORDER BY 1); diff --git a/mysql-test/r/func_in_all.result-pq b/mysql-test/r/func_in_all.result-pq new file mode 100644 index 000000000..c5662c639 --- /dev/null +++ b/mysql-test/r/func_in_all.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_icp.result-pq b/mysql-test/r/func_in_icp.result-pq new file mode 100644 index 000000000..e2c503aa9 --- /dev/null +++ b/mysql-test/r/func_in_icp.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='index_condition_pushdown=on'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_icp_mrr.result-pq b/mysql-test/r/func_in_icp_mrr.result-pq new file mode 100644 index 000000000..08115d529 --- /dev/null +++ b/mysql-test/r/func_in_icp_mrr.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_mrr.result-pq b/mysql-test/r/func_in_mrr.result-pq new file mode 100644 index 000000000..8d49d3d92 --- /dev/null +++ b/mysql-test/r/func_in_mrr.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_mrr_cost.result-pq b/mysql-test/r/func_in_mrr_cost.result-pq new file mode 100644 index 000000000..74227662a --- /dev/null +++ b/mysql-test/r/func_in_mrr_cost.result-pq @@ -0,0 +1,998 @@ +set optimizer_switch='mrr=on,mrr_cost_based=on'; +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_in_none.result-pq b/mysql-test/r/func_in_none.result-pq new file mode 100644 index 000000000..f4033ac2a --- /dev/null +++ b/mysql-test/r/func_in_none.result-pq @@ -0,0 +1,997 @@ +drop table if exists t1, t2; +select 1 in (1,2,3); +1 in (1,2,3) +1 +select 10 in (1,2,3); +10 in (1,2,3) +0 +select NULL in (1,2,3); +NULL in (1,2,3) +NULL +select 1 in (1,NULL,3); +1 in (1,NULL,3) +1 +select 3 in (1,NULL,3); +3 in (1,NULL,3) +1 +select 10 in (1,NULL,3); +10 in (1,NULL,3) +NULL +select 1.5 in (1.5,2.5,3.5); +1.5 in (1.5,2.5,3.5) +1 +select 10.5 in (1.5,2.5,3.5); +10.5 in (1.5,2.5,3.5) +0 +select NULL in (1.5,2.5,3.5); +NULL in (1.5,2.5,3.5) +NULL +select 1.5 in (1.5,NULL,3.5); +1.5 in (1.5,NULL,3.5) +1 +select 3.5 in (1.5,NULL,3.5); +3.5 in (1.5,NULL,3.5) +1 +select 10.5 in (1.5,NULL,3.5); +10.5 in (1.5,NULL,3.5) +NULL +CREATE TABLE t1 (a int, b int, c int); +insert into t1 values (1,2,3), (1,NULL,3); +select 1 in (a,b,c) from t1; +1 in (a,b,c) +1 +1 +select 3 in (a,b,c) from t1; +3 in (a,b,c) +1 +1 +select 10 in (a,b,c) from t1; +10 in (a,b,c) +0 +NULL +select NULL in (a,b,c) from t1; +NULL in (a,b,c) +NULL +NULL +drop table t1; +CREATE TABLE t1 (a float, b float, c float); +insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5); +select 1.5 in (a,b,c) from t1; +1.5 in (a,b,c) +1 +1 +select 3.5 in (a,b,c) from t1; +3.5 in (a,b,c) +1 +1 +select 10.5 in (a,b,c) from t1; +10.5 in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10)); +insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD'); +select 'A' in (a,b,c) from t1; +'A' in (a,b,c) +1 +1 +select 'EFD' in (a,b,c) from t1; +'EFD' in (a,b,c) +1 +1 +select 'XSFGGHF' in (a,b,c) from t1; +'XSFGGHF' in (a,b,c) +0 +NULL +drop table t1; +CREATE TABLE t1 (field char(1)); +INSERT INTO t1 VALUES ('A'),(NULL); +SELECT * from t1 WHERE field IN (NULL); +field +SELECT * from t1 WHERE field NOT IN (NULL); +field +SELECT * from t1 where field = field; +field +A +SELECT * from t1 where field <=> field; +field +A +NULL +DELETE FROM t1 WHERE field NOT IN (NULL); +SELECT * FROM t1; +field +A +NULL +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select * from t1 where id in (2,5,9); +id +2 +5 +9 +drop table t1; +create table t1 ( +a char(1) character set latin1 collate latin1_general_ci, +b char(1) character set latin1 collate latin1_swedish_ci, +c char(1) character set latin1 collate latin1_danish_ci +); +insert into t1 values ('A','B','C'); +insert into t1 values ('a','c','c'); +select * from t1 where a in (b); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +select * from t1 where a in (b,c); +ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN ' +select * from t1 where 'a' in (a,b,c); +ERROR HY000: Illegal mix of collations for operation ' IN ' +select * from t1 where 'a' in (a); +a b c +A B C +a c c +select * from t1 where a in ('a'); +a b c +A B C +a c c +set names latin1; +select * from t1 where 'a' collate latin1_general_ci in (a,b,c); +a b c +A B C +a c c +select * from t1 where 'a' collate latin1_bin in (a,b,c); +a b c +a c c +select * from t1 where 'a' in (a,b,c collate latin1_bin); +a b c +a c c +explain select * from t1 where 'a' in (a,b,c collate latin1_bin); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin))) +drop table t1; +set names utf8mb4; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 (a char(10) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('bbbb'),(_koi8r x'C3C3C3C3'),(_latin1 x'C4C4C4C4'); +select a from t1 where a in ('bbbb',_koi8r x'C3C3C3C3',_latin1 x'C4C4C4C4') order by a; +a +ÄÄÄÄ +bbbb +цццц +drop table t1; +create table t1 (a char(10) character set latin1 not null); +insert into t1 values ('a'),('b'),('c'); +select a from t1 where a IN ('a','b','c') order by a; +a +a +b +c +drop table t1; +set names latin1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 +create table t1 (a char(2) character set binary); +insert into t1 values ('aa'), ('bb'); +select * from t1 where a in (NULL, 'aa'); +a +aa +drop table t1; +create table t1 (id int, key(id)); +insert into t1 values (1),(2),(3); +select count(*) from t1 where id not in (1); +count(*) +2 +select count(*) from t1 where id not in (1,2); +count(*) +1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); +SELECT * FROM t1 WHERE a IN (45); +a +45 +SELECT * FROM t1 WHERE a NOT IN (0, 45); +a +44 +46 +SELECT * FROM t1 WHERE a NOT IN (45); +a +44 +46 +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci +SELECT * FROM v1; +a +44 +46 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(200), key(a)); +insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C; +insert into t2 select C.a*2+1, 'yes' from t1 C; +explain +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 5 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (0,2,4,6,8,10,12,14,16,18)) +select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18); +a filler +1 yes +3 yes +5 yes +7 yes +9 yes +11 yes +13 yes +15 yes +17 yes +19 yes +explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (2,2,2,2,2,2)) +explain select * from t2 force index(a) where a <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 910 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 5 NULL 910 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` <> 2) +drop table t2; +create table t2 (a datetime, filler char(200), key(a)); +insert into t2 select '2006-04-25 10:00:00' + interval C.a minute, +'no' from t1 A, t1 B, t1 C where C.a % 2 = 0; +insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute, +'yes' from t1 C; +explain +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 6 NULL 11 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00','2006-04-25 10:06:00','2006-04-25 10:08:00')) +select * from t2 where a NOT IN ( +'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', +'2006-04-25 10:06:00', '2006-04-25 10:08:00'); +a filler +2006-04-25 10:01:00 yes +2006-04-25 10:03:00 yes +2006-04-25 10:05:00 yes +2006-04-25 10:07:00 yes +2006-04-25 10:09:00 yes +2006-04-25 10:11:00 yes +2006-04-25 10:13:00 yes +2006-04-25 10:15:00 yes +2006-04-25 10:17:00 yes +2006-04-25 10:19:00 yes +drop table t2; +create table t2 (a varchar(10), filler char(200), key(a)); +insert into t2 select 'foo', 'no' from t1 A, t1 B; +insert into t2 select 'barbar', 'no' from t1 A, t1 B; +insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B; +insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), +('barbas','1'), ('bazbazbay', '1'),('zz','1'); +explain select * from t2 where a not in('foo','barbar', 'bazbazbaz'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 13 NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 13 NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in ('foo','barbar','bazbazbaz')) +drop table t2; +create table t2 (a decimal(10,5), filler char(200), key(a)); +insert into t2 select 345.67890, 'no' from t1 A, t1 B; +insert into t2 select 43245.34, 'no' from t1 A, t1 B; +insert into t2 select 64224.56344, 'no' from t1 A, t1 B; +insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), +(55555,'1'), (77777, '1'); +explain +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 7 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` not in (345.67890,43245.34,64224.56344)) +select * from t2 where a not in (345.67890, 43245.34, 64224.56344); +a filler +0.00000 1 +22334.12300 1 +33333.00000 1 +55555.00000 1 +77777.00000 1 +drop table t2; +create table t2 (a int, key(a), b int); +insert into t2 values (1,1),(2,2); +set @cnt= 1; +set @str="update t2 set b=1 where a not in ("; +select count(*) from ( +select @str:=concat(@str, @cnt:=@cnt+1, ",") +from t1 A, t1 B, t1 C, t1 D) Z; +count(*) +10000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @str:=concat(@str, "10000)"); +select substr(@str, 1, 50); +substr(@str, 1, 50) +update t2 set b=1 where a not in (2,3,4,5,6,7,8,9, +prepare s from @str; +execute s; +deallocate prepare s; +set @str=NULL; +drop table t2; +drop table t1; +create table t1 ( +some_id smallint(5) unsigned, +key (some_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +select some_id from t1 where some_id not in(2,-1); +some_id +1 +select some_id from t1 where some_id not in(-4,-1,-4); +some_id +1 +2 +select some_id from t1 where some_id not in(-4,-1,3423534,2342342); +some_id +1 +2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 +drop table t1; +# +# BUG#20420: optimizer reports wrong keys on left join with IN +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +CREATE TABLE t3 (a int PRIMARY KEY); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), +(1003,1003),(1004,1004); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 SIMPLE t4 NULL ALL PRIMARY NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t1` join `test`.`t2` join `test`.`t4` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) +SELECT STRAIGHT_JOIN * FROM t3 +JOIN t1 ON t3.a=t1.a +JOIN t2 ON t3.a=t2.a +JOIN t4 WHERE t4.a IN (t1.b, t2.b); +a a b a b a b +3 3 1 3 2 1 1 +3 3 1 3 2 2 2 +4 4 1 4 2 1 1 +4 4 1 4 2 2 2 +EXPLAIN SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 PRIMARY t2 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +2 DEPENDENT SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 7 28.57 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select straight_join (/* select#2 */ select sum(`test`.`t4`.`a`) from `test`.`t4` where (`test`.`t4`.`a` in (`test`.`t1`.`b`,`test`.`t2`.`b`))) AS `(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))` from `test`.`t3` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`a`)) +SELECT STRAIGHT_JOIN +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +FROM t3, t1, t2 +WHERE t3.a=t1.a AND t3.a=t2.a; +(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +3 +3 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a BIGINT UNSIGNED); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 WHERE a=-1 OR a=-2 ; +a +SELECT * FROM t1 WHERE a IN (-1, -2); +a +CREATE TABLE t2 (a BIGINT UNSIGNED); +insert into t2 values(13491727406643098568), +(0x7fffffefffffffff), +(0x7ffffffeffffffff), +(0x7fffffffefffffff), +(0x7ffffffffeffffff), +(0x7fffffffffefffff), +(0x7ffffffffffeffff), +(0x7fffffffffffefff), +(0x7ffffffffffffeff), +(0x7fffffffffffffef), +(0x7ffffffffffffffe), +(0x7fffffffffffffff), +(0x8000000000000000), +(0x8000000000000001), +(0x8000000000000002), +(0x8000000000000300), +(0x8000000000000400), +(0x8000000000000401), +(0x8000000000004001), +(0x8000000000040001), +(0x8000000000400001), +(0x8000000004000001), +(0x8000000040000001), +(0x8000000400000001), +(0x8000004000000001), +(0x8000040000000001); +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0xBB3C3E98175D33C8 AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000000 AS UNSIGNED), +CAST(0x8000000000000400 AS UNSIGNED), +CAST(0x8000000000000401 AS UNSIGNED), +42); +HEX(a) +BB3C3E98175D33C8 +7FFFFFFFFFFFFFFF +8000000000000000 +8000000000000400 +8000000000000401 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7fffffffffffffff AS UNSIGNED), +CAST(0x8000000000000001 AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFF +8000000000000001 +SELECT HEX(a) FROM t2 WHERE a IN +(CAST(0x7ffffffffffffffe AS UNSIGNED), +CAST(0x7fffffffffffffff AS UNSIGNED)); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +SELECT HEX(a) FROM t2 WHERE a IN +(0x7ffffffffffffffe, +0x7fffffffffffffff, +'abc'); +HEX(a) +7FFFFFFFFFFFFFFE +7FFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'abc' +CREATE TABLE t3 (a BIGINT UNSIGNED); +INSERT INTO t3 VALUES (9223372036854775551); +SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42); +HEX(a) +CREATE TABLE t4 (a DATE); +INSERT INTO t4 VALUES ('1972-02-06'), ('1972-07-29'); +SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29'); +a +1972-02-06 +Warnings: +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (id int not null); +INSERT INTO t1 VALUES (1),(2); +SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); +id +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1; +End of 5.0 tests +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +f1 case f1 when 'a' then '+' when 1 then '-' end +a + +b NULL +1 - +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +f1 +1 +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warnings: +a +explain select f1 from t1 where f1 in ('a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a',1)) +select f1 from t1 where f1 in ('a','b'); +f1 +a +b +explain select f1 from t1 where f1 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range t1f1_idx t1f1_idx 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in ('a','b')) +select f1 from t1 where f1 in (2,1); +f1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f1 from t1 where f1 in (2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL 2 NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1f1_idx t1f1_idx 2 NULL 3 50.00 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 't1f1_idx' due to type or collation conversion on field 'f1' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (`test`.`t1`.`f1` in (2,1)) +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +f2 +0 +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +explain select f2 from t2 where f2 in ('a',2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a',2)) +select f2 from t2 where f2 in ('a','b'); +f2 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in ('a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 1 100.00 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in ('a','b')) +select f2 from t2 where f2 in (1,'b'); +f2 +0 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'b' +explain select f2 from t2 where f2 in (1,'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range t2f2 t2f2 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f2` AS `f2` from `test`.`t2` where (`test`.`t2`.`f2` in (1,'b')) +drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +id +select * from t1 where NOT id in (null, 1); +id +drop table t1; +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +CASE AVG (c0) WHEN c1 * c2 THEN 1 END +1 +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END +2 +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; +CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) +NULL 1.0000 +DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; +# +# Bug #44139: Table scan when NULL appears in IN clause +# +CREATE TABLE t1 ( +c_int INT NOT NULL, +c_decimal DECIMAL(5,2) NOT NULL, +c_float FLOAT(5, 2) NOT NULL, +c_bit BIT(10) NOT NULL, +c_date DATE NOT NULL, +c_datetime DATETIME NOT NULL, +c_timestamp TIMESTAMP NOT NULL, +c_time TIME NOT NULL, +c_year YEAR NOT NULL, +c_char CHAR(10) character set utf8mb4 NOT NULL, +INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), +INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), +INDEX(c_char)); +INSERT IGNORE INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +INSERT IGNORE INTO t1 (c_int) SELECT 0 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range c_int c_int 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (1,NULL,2,NULL,3,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_int` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_decimal c_decimal 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_decimal` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_float c_float 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_float` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_bit c_bit 2 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_bit` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN ('2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in ('2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date +IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_date c_date 3 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,'2009-09-01','2009-09-02','2009-09-03')) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_date`) +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_date` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in ('2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime +IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_datetime c_datetime 5 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,'2009-09-01 00:00:01','2009-09-02 00:00:01','2009-09-03 00:00:01')) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_datetime`) +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_datetime` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in ('2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp +IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_timestamp c_timestamp 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,'2009-09-01 00:00:01','2009-09-01 00:00:02','2009-09-01 00:00:03')) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_timestamp`) +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_timestamp` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_year c_year 1 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,1,2,3)) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` = NULL) +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_year` in (NULL,NULL)) +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in ('1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c_char c_char 40 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,'1','2','3')) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where multiple equal(NULL, `test`.`t1`.`c_char`) +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_int` AS `c_int`,`test`.`t1`.`c_decimal` AS `c_decimal`,`test`.`t1`.`c_float` AS `c_float`,`test`.`t1`.`c_bit` AS `c_bit`,`test`.`t1`.`c_date` AS `c_date`,`test`.`t1`.`c_datetime` AS `c_datetime`,`test`.`t1`.`c_timestamp` AS `c_timestamp`,`test`.`t1`.`c_time` AS `c_time`,`test`.`t1`.`c_year` AS `c_year`,`test`.`t1`.`c_char` AS `c_char` from `test`.`t1` where (`test`.`t1`.`c_char` in (NULL,NULL)) +DROP TABLE t1; +# +# Bug#54477: Crash on IN / CASE with NULL arguments +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2); +SELECT 1 IN (NULL, a) FROM t1; +1 IN (NULL, a) +1 +NULL +SELECT a IN (a, a) FROM t1 GROUP BY a WITH ROLLUP; +a IN (a, a) +1 +1 +NULL +SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP; +CASE a WHEN a THEN a END +1 +2 +NULL +DROP TABLE t1; +# +# Bug#58628: Incorrect result for 'WHERE NULL NOT IN () +# +CREATE TABLE t1 (pk INT NOT NULL, i INT); +INSERT INTO t1 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL); +CREATE TABLE subq (pk INT NOT NULL, i INT NOT NULL, PRIMARY KEY(i,pk)); +INSERT INTO subq VALUES (0,0), (1,1), (2,2), (3,3); +SELECT * FROM t1 +WHERE t1.i NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE t1.i IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +SELECT * FROM t1 +WHERE NULL IN +(SELECT i FROM subq WHERE subq.pk = t1.pk) IS UNKNOWN; +pk i +0 NULL +1 NULL +2 NULL +3 NULL +SELECT * FROM t1 +WHERE 1+NULL NOT IN +(SELECT i FROM subq WHERE subq.pk = t1.pk); +pk i +DROP TABLE t1,subq; +# +# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION +# +CREATE TABLE t1(f1 YEAR); +INSERT INTO t1 VALUES (0000),(2001); +(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63 +MAX(f1) +2001 +DROP TABLE t1; +# +# Bug #11764651-57510: IN(string,real,string) causes invalid read in sort function +# +SELECT LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,""); +LEFT(ST_GEOMFROMTEXT("POINT(0 0)"),1) IN (@@global.max_allowed_packet,1,"") +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '\x00' +# End of test BUG#11764651-57510 +End of 5.1 tests +set optimizer_switch=default; diff --git a/mysql-test/r/func_like.result-pq b/mysql-test/r/func_like.result-pq new file mode 100644 index 000000000..47dbe43c1 --- /dev/null +++ b/mysql-test/r/func_like.result-pq @@ -0,0 +1,482 @@ +drop table if exists t1; +create table t1 (a varchar(10), key(a)) charset utf8mb4; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where a like 'abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%') +explain select * from t1 where a like concat('abc','%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 43 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like (concat('abc','%'))) +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +create table t1 (a varchar(10), key(a)); +insert into t1 values ('a'), ('a\\b'); +select * from t1 where a like 'a\\%' escape '#'; +a +a\b +select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b'; +a +a\b +prepare stmt1 from 'select * from t1 where a like \'a\\%\' escape ?'; +set @esc='#'; +execute stmt1 using @esc; +a +a\b +deallocate prepare stmt1; +drop table t1; +create table t1 (a datetime); +insert into t1 values ('2004-03-11 12:00:21'); +select * from t1 where a like '2004-03-11 12:00:21'; +a +2004-03-11 12:00:21 +drop table t1; +SET NAMES koi8r; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r); +INSERT INTO t1 VALUES (''),(''),(''),(''),(''),(''); +INSERT INTO t1 VALUES (''),(''),(''),(''); +INSERT INTO t1 VALUES (''),(''),(''),(''); +INSERT INTO t1 VALUES (''),(''),(''),(''); +SELECT * FROM t1 WHERE a LIKE '%%'; +a + + + + + + + + + + + + + + + + + + +SELECT * FROM t1 WHERE a LIKE '%%'; +a + + + + + + + + + + + + + + + + + + +SELECT * FROM t1 WHERE a LIKE '%'; +a + + + + + + + + + + + + + + + + + + +DROP TABLE t1; +SET NAMES cp1250; +CREATE TABLE t1 (a varchar(250) NOT NULL) DEFAULT CHARACTER SET=cp1250; +INSERT INTO t1 VALUES +('Techni Tapes Sp. z o.o.'), +('Pojazdy Szynowe PESA Bydgoszcz SA Holding'), +('AKAPESTER 1 P.P.H.U.'), +('Pojazdy Szynowe PESA Bydgoszcz S A Holding'), +('PPUH PESKA-I Maria Struniarska'); +select * from t1 where a like '%PESA%'; +a +Pojazdy Szynowe PESA Bydgoszcz SA Holding +Pojazdy Szynowe PESA Bydgoszcz S A Holding +select * from t1 where a like '%PESA %'; +a +Pojazdy Szynowe PESA Bydgoszcz SA Holding +Pojazdy Szynowe PESA Bydgoszcz S A Holding +select * from t1 where a like '%PES%'; +a +Techni Tapes Sp. z o.o. +Pojazdy Szynowe PESA Bydgoszcz SA Holding +AKAPESTER 1 P.P.H.U. +Pojazdy Szynowe PESA Bydgoszcz S A Holding +PPUH PESKA-I Maria Struniarska +select * from t1 where a like '%PESKA%'; +a +PPUH PESKA-I Maria Struniarska +select * from t1 where a like '%ESKA%'; +a +PPUH PESKA-I Maria Struniarska +DROP TABLE t1; +select _cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin; +_cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin +1 +set names koi8r; +select 'andre%' like 'andre%' escape ''; +'andre%' like 'andre%' escape '' +1 +select _cp1251'andre%' like convert('andre%' using cp1251) escape ''; +_cp1251'andre%' like convert('andre%' using cp1251) escape '' +1 +End of 4.1 tests +# +# Bug #54575: crash when joining tables with unique set column +# +CREATE TABLE t1(a SET('a') NOT NULL, UNIQUE KEY(a)); +CREATE TABLE t2(b INT PRIMARY KEY); +INSERT IGNORE INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +INSERT INTO t2 VALUES (1), (2), (3); +SELECT 1 FROM t2 JOIN t1 ON 1 LIKE a GROUP BY a; +1 +DROP TABLE t1, t2; +# +# Bug#59149 valgrind warnings with "like .. escape .." function +# +SELECT '' LIKE '1' ESCAPE COUNT(1); +'' LIKE '1' ESCAPE COUNT(1) +0 +End of 5.1 tests +# +# Bug #18114294 CRASH IN ITEM_FUNC_LIKE::BM_MATCHES +# +select 0x0000000001020003F03F40408484040ADDE40 like 0x256F3B38312A7725; +0x0000000001020003F03F40408484040ADDE40 like 0x256F3B38312A7725 +0 +select 0x003c8793403032 like '%-112%'; +0x003c8793403032 like '%-112%' +0 +select 0x903f645a8c507dd79178 like '%-128%'; +0x903f645a8c507dd79178 like '%-128%' +0 +select 0xac14aa84f000d276d66ed9 like '%-107%'; +0xac14aa84f000d276d66ed9 like '%-107%' +0 +select 0xf0be117400d02a20b8e049da3e74 like '%-123%'; +0xf0be117400d02a20b8e049da3e74 like '%-123%' +0 +select 0x961838f6fc3c7f9ec17b5d900410d8aa like '%-113%'; +0x961838f6fc3c7f9ec17b5d900410d8aa like '%-113%' +0 +select 0x6a8473fc1c64ce4f2684c05a400c5e7ca4a01a like '%emailin%'; +0x6a8473fc1c64ce4f2684c05a400c5e7ca4a01a like '%emailin%' +0 +select 0x00b25278956e0044683dfc180cd886aeff2f5bc3fc18 like '%-122%'; +0x00b25278956e0044683dfc180cd886aeff2f5bc3fc18 like '%-122%' +0 +select 0xbc24421ce6194ab5c260e80af647ae58fdbfca18a19dc8411424 like '%-106%'; +0xbc24421ce6194ab5c260e80af647ae58fdbfca18a19dc8411424 like '%-106%' +0 +# +# Bug#19931126 VALGRIND REPORTS USE OF UNINITIALIZED VALUE IN +# MY_WILDCMP_BIN_IMPL +# +CREATE TABLE t1(x CHAR(1)) ENGINE=InnoDB; +SELECT ('a%b' LIKE 'a\%b' ESCAPE (SELECT x FROM t1)); +('a%b' LIKE 'a\%b' ESCAPE (SELECT x FROM t1)) +1 +SELECT ('a%b' LIKE 'ax%b' ESCAPE (SELECT x FROM t1)); +('a%b' LIKE 'ax%b' ESCAPE (SELECT x FROM t1)) +0 +INSERT INTO t1 VALUES ('x'); +SELECT ('a%b' LIKE 'a\%b' ESCAPE (SELECT x FROM t1)); +('a%b' LIKE 'a\%b' ESCAPE (SELECT x FROM t1)) +0 +SELECT ('a%b' LIKE 'ax%b' ESCAPE (SELECT x FROM t1)); +('a%b' LIKE 'ax%b' ESCAPE (SELECT x FROM t1)) +1 +SELECT ('a%b' LIKE 'ax%b' ESCAPE (SELECT 'xy' FROM t1)); +ERROR HY000: Incorrect arguments to ESCAPE +INSERT INTO t1 VALUES ('y'); +SELECT ('a%b' LIKE 'ax%b' ESCAPE (SELECT x FROM t1)); +ERROR 21000: Subquery returns more than 1 row +DELETE FROM t1 WHERE x = 'y'; +SELECT ('a%b' LIKE 'ax%b' ESCAPE (SELECT x, x FROM t1)); +ERROR 21000: Operand should contain 1 column(s) +SELECT ('a%b' LIKE 'ax%b' ESCAPE ('x', 'y')); +ERROR 21000: Operand should contain 1 column(s) +SELECT ('a%b' LIKE 'ax%b' ESCAPE x) FROM t1; +ERROR HY000: Incorrect arguments to ESCAPE +CREATE TABLE t2(x int, y varchar(100)) ENGINE=InnoDB; +CREATE INDEX idx ON t2(y); +INSERT INTO t2 VALUES (1, 'abcd'), (2, 'ab%cde'); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t2 WHERE y LIKE 'abc%%' ESCAPE (SELECT 'c' FROM t1) ORDER BY y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL idx NULL NULL NULL 2 50.00 Using where; Using filesort +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t2` where (`test`.`t2`.`y` like 'abc%%' escape (/* select#2 */ select 'c' from `test`.`t1`)) order by `test`.`t2`.`y` +SELECT * FROM t2 WHERE y LIKE 'abc%%' ESCAPE (SELECT 'c' FROM t1) ORDER BY y; +x y +2 ab%cde +DROP TABLE t1, t2; +# Bug#20035071: Out of range error in subselect lead to assertion failed +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES(1); +SELECT 1 FROM t1 HAVING (SELECT 1 FROM t1) LIKE EXP(NOW()); +ERROR 22003: DOUBLE value is out of range in 'exp(now())' +DROP TABLE t1; +# +# Bug #25140629: WRONG RESULT WHEN USING LIKE FUNCTION WITH UCA +# COLLATIONS +# +CREATE TABLE t1(wildstr VARCHAR(10), str VARCHAR(10), like_result INTEGER) +COLLATE utf8mb4_0900_ai_ci; +INSERT INTO t1 VALUES('abc', 'abc', 1), ('AbC', 'aBc', 1), ('_bc', 'abc', 1), +('a_c', 'abc', 1), ('ab_', 'abc', 1), ('%c', 'abc', 1), ('a%c', 'abc', 1), +('a%', 'abc', 1), ('a%d_f', 'abcdef', 1), ('a%d%g', 'abcdefg', 1), +('a_c_e', 'abcde', 1), ('a%%de', 'abcde', 1), ('a__de', 'abcde', 1), +(_utf16 0x65700025636E005F5E93, _utf16 0x65706C49636E5B575E93, 1), +('a\\', 'a\\', 1); +SELECT wildstr, str, like_result FROM t1 WHERE (str LIKE wildstr) <> +like_result; +wildstr str like_result +DROP TABLE t1; +# +# Bug #12635103: VALGRIND WARNINGS IN MY_WILDCMP_MB AND +# MY_WILDCMP_8BIT WITH LIKE AND CONVERT +# +SELECT 'aa' LIKE CONVERT('%a' USING big5); +'aa' LIKE CONVERT('%a' USING big5) +1 +SELECT 'aa' LIKE CONVERT('%a' USING utf8mb4); +'aa' LIKE CONVERT('%a' USING utf8mb4) +1 +SELECT 'aa' LIKE CONVERT('%a' USING gb18030); +'aa' LIKE CONVERT('%a' USING gb18030) +1 +SELECT 'aa' LIKE CONVERT('%a' USING binary); +'aa' LIKE CONVERT('%a' USING binary) +1 +SELECT 'aa' LIKE CONVERT('%a' USING latin1); +'aa' LIKE CONVERT('%a' USING latin1) +1 +SET NAMES gb2312; +SELECT 'aa' LIKE '%a' COLLATE gb2312_bin; +'aa' LIKE '%a' COLLATE gb2312_bin +1 +SET NAMES DEFAULT; +SELECT 'aa' LIKE CONVERT('%a' USING utf8); +'aa' LIKE CONVERT('%a' USING utf8) +1 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +# +# Bug#29175461: LIKE RESULT ERROR IF ESCAPE IS % OF WILDCARD CHARACTERS +# +SET NAMES big5; +select 1 where 'b%a' like '%%a' escape '%'; +1 +select 1 where 'b_a' like '__a' escape '_'; +1 +select 1 where 'b%a' like '#%a' escape '#'; +1 +select 1 where 'b_a' like '#_a' escape '#'; +1 +SET NAMES utf8mb4; +select 1 where 'b%a' like '%%a' escape '%'; +1 +select 1 where 'b_a' like '__a' escape '_'; +1 +select 1 where 'b%a' like '#%a' escape '#'; +1 +select 1 where 'b_a' like '#_a' escape '#'; +1 +SET NAMES gb18030; +select 1 where 'b%a' like '%%a' escape '%'; +1 +select 1 where 'b_a' like '__a' escape '_'; +1 +select 1 where 'b%a' like '#%a' escape '#'; +1 +select 1 where 'b_a' like '#_a' escape '#'; +1 +SET NAMES binary; +select 1 where 'b%a' like '%%a' escape '%'; +1 +select 1 where 'b_a' like '__a' escape '_'; +1 +select 1 where 'b%a' like '#%a' escape '#'; +1 +select 1 where 'b_a' like '#_a' escape '#'; +1 +SET NAMES latin1; +select 1 where 'b%a' like '%%a' escape '%'; +1 +select 1 where 'b_a' like '__a' escape '_'; +1 +select 1 where 'b%a' like '#%a' escape '#'; +1 +select 1 where 'b_a' like '#_a' escape '#'; +1 +SET NAMES gb2312; +select 1 where 'b%a' like '%%a' escape '%'; +1 +select 1 where 'b_a' like '__a' escape '_'; +1 +select 1 where 'b%a' like '#%a' escape '#'; +1 +select 1 where 'b_a' like '#_a' escape '#'; +1 +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select 1 where 'b%a' like '%%a' escape '%'; +1 +select 1 where 'b_a' like '__a' escape '_'; +1 +select 1 where 'b%a' like '#%a' escape '#'; +1 +select 1 where 'b_a' like '#_a' escape '#'; +1 +SET NAMES default; +# +# Bug#29368521: ASSERTION `!THD->IS_ERROR()' FAILED +# +SELECT 'a' LIKE '%' ESCAPE CAST('' AS JSON); +ERROR 22032: Invalid JSON text in argument 1 to function cast_as_json: "The document is empty." at position 0. +# +# Bug#29590129 UBSAN: MEMBER CALL ON NULL POINTER OF TYPE +# 'STRUCT STRING' IN ITEM_FUNC_LIKE::VA +# +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (42); +DELETE FROM t1 WHERE +( EXISTS +(SELECT * WHERE '520:33:32.77' < (c1 - INTERVAL(1) MONTH)) +) LIKE (c1); +ERROR 22007: Incorrect datetime value: '42' +DROP TABLE t1; +# +# Bug#29904751: LIKE CONDITION FOR DATE COLUMN RETURNS ERROR +# +CREATE TABLE t(col1 DATE); +INSERT INTO t(col1) VALUES('2019-06-13'), ('2019-07-13'); +SELECT * FROM t WHERE col1 LIKE '2019%'; +col1 +2019-06-13 +2019-07-13 +SELECT * FROM t WHERE col1 LIKE '2019-06-1%'; +col1 +2019-06-13 +DROP TABLE t; +# +# Bug#31249687 WL9384: RESULTSET MISMATCH WITH LIKE KEYWORD USING PREPARE STATEMENT +# +create table t1(a int); +insert into t1 values(0); +set @pattern="%1%"; +select 1 from t1 where a like @pattern; +1 +prepare s from 'select 1 from t1 where a like ?'; +execute s using @pattern; +1 +drop table t1; +# +# Bug#26086751: LIKE LOSES ESCAPE CLAUSE WHEN USED IN VIEW +# Bug#29224931: LIKE ... ESCAPE IS NOT WRITTEN TO DICTIONARY +# Bug#30211596: `EXPLAIN ... LIKE ... ESCAPE` DOESN'T OUTPUT `ESCAPE` +# CLAUSE IN THE WARNING +# +EXPLAIN SELECT 'abba' LIKE 'abba' ESCAPE 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ('abba' like 'abba' escape 'b') AS `'abba' LIKE 'abba' ESCAPE 'b'` +CREATE TABLE t(x VARCHAR(10), +gc INTEGER GENERATED ALWAYS AS (x LIKE 'abba' ESCAPE 'b')); +INSERT INTO t(x) VALUES ('abba'), ('aba'), ('abbbba'); +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `x` varchar(10) DEFAULT NULL, + `gc` int GENERATED ALWAYS AS ((`x` like _utf8mb4'abba' escape _utf8mb4'b')) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT x FROM t WHERE gc <> 0; +x +aba +CREATE VIEW v AS SELECT x, 'abba' LIKE x ESCAPE 'b' AS y FROM t; +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t`.`x` AS `x`,('abba' like `t`.`x` escape 'b') AS `y` from `t` utf8mb4 utf8mb4_0900_ai_ci +SELECT x FROM v WHERE y <> 0; +x +abbbba +DROP VIEW v; +DROP TABLE t; +# +# Bug#32446508: INCONSISTENT HANDLING OF LIKE WITH AN EMPTY ESCAPE SEQUENCE +# +# Used to return (0, 1, 1), should return (0, 0, 0). +SELECT _latin1'abc' LIKE _latin1'a\\bc' ESCAPE _latin1'' AS col1, +_utf8mb4'abc' LIKE _utf8mb4'a\\bc' ESCAPE _utf8mb4'' AS col2, +_latin1'abc' LIKE _latin1'a\\bc' ESCAPE _ascii'' AS col3; +col1 col2 col3 +0 0 0 +SET sql_mode = CONCAT(@@sql_mode, ',NO_BACKSLASH_ESCAPES'); +# Used to return (1, 0), should return (1, 1). +SELECT _latin1'a\bc' LIKE _latin1'a\%' AS col1, +_utf8mb4'a\bc' LIKE _utf8mb4'a\%' AS col2; +col1 col2 +1 1 +SET sql_mode = DEFAULT; diff --git a/mysql-test/r/func_math.result-pq b/mysql-test/r/func_math.result-pq new file mode 100644 index 000000000..0d6e60101 --- /dev/null +++ b/mysql-test/r/func_math.result-pq @@ -0,0 +1,2066 @@ +drop table if exists t1; +select floor(5.5),floor(-5.5); +floor(5.5) floor(-5.5) +5 -6 +explain select floor(5.5),floor(-5.5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)` +select ceiling(5.5),ceiling(-5.5); +ceiling(5.5) ceiling(-5.5) +6 -5 +explain select ceiling(5.5),ceiling(-5.5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)` +select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1); +truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1) +52.6 52.64 50 0 -52.6 -50 +explain select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-(1)) AS `truncate(52.64,-1)`,truncate(52.64,-(2)) AS `truncate(52.64,-2)`,truncate(-(52.64),1) AS `truncate(-52.64,1)`,truncate(-(52.64),-(1)) AS `truncate(-52.64,-1)` +select round(5.5),round(-5.5); +round(5.5) round(-5.5) +6 -6 +explain select round(5.5),round(-5.5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)` +select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2); +round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2) +5.6 5.64 10 0 +select abs(-10), sign(-5), sign(5), sign(0); +abs(-10) sign(-5) sign(5) sign(0) +10 -1 1 0 +explain select abs(-10), sign(-5), sign(5), sign(0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)` +select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); +log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2) +10 10.000000000000002 NULL NULL NULL 2 NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)` +select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); +ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL) +10 10.000000000000002 NULL NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)` +select log2(8),log2(15),log2(-2),log2(0),log2(NULL); +log2(8) log2(15) log2(-2) log2(0) log2(NULL) +3 3.9068905956085187 NULL NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select log2(8),log2(15),log2(-2),log2(0),log2(NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)` +select log10(100),log10(18),log10(-4),log10(0),log10(NULL); +log10(100) log10(18) log10(-4) log10(0) log10(NULL) +2 1.255272505103306 NULL NULL NULL +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +explain select log10(100),log10(18),log10(-4),log10(0),log10(NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)` +select pow(10,log10(10)),power(2,4); +pow(10,log10(10)) power(2,4) +10 16 +explain select pow(10,log10(10)),power(2,4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4)` +set @@rand_seed1=10000000,@@rand_seed2=1000000; +select rand(999999),rand(); +rand(999999) rand() +0.014231365187309091 0.028870999839968048 +explain select rand(999999),rand(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select rand(999999) AS `rand(999999)`,rand() AS `rand()` +select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6); +pi() format(sin(pi()/2),6) format(cos(pi()/2),6) format(abs(tan(pi())),6) format(cot(1),6) format(asin(1),6) format(acos(0),6) format(atan(1),6) +3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398 +explain select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format(cot(1),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)` +select degrees(pi()),radians(360); +degrees(pi()) radians(360) +180 6.283185307179586 +select format(atan(-2, 2), 6); +format(atan(-2, 2), 6) +-0.785398 +select format(atan(pi(), 0), 6); +format(atan(pi(), 0), 6) +1.570796 +select format(atan2(-2, 2), 6); +format(atan2(-2, 2), 6) +-0.785398 +select format(atan2(pi(), 0), 6); +format(atan2(pi(), 0), 6) +1.570796 +SELECT ACOS(1.0); +ACOS(1.0) +0 +SELECT ASIN(1.0); +ASIN(1.0) +1.5707963267948966 +SELECT ACOS(0.2*5.0); +ACOS(0.2*5.0) +0 +SELECT ACOS(0.5*2.0); +ACOS(0.5*2.0) +0 +SELECT ASIN(0.8+0.2); +ASIN(0.8+0.2) +1.5707963267948966 +SELECT ASIN(1.2-0.2); +ASIN(1.2-0.2) +1.5707963267948966 +select format(4.55, 1), format(4.551, 1); +format(4.55, 1) format(4.551, 1) +4.6 4.6 +explain select degrees(pi()),radians(360); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)` +select rand(rand); +ERROR 42S22: Unknown column 'rand' in 'field list' +create table t1 (col1 int, col2 decimal(60,30)); +insert into t1 values(1,1234567890.12345); +select format(col2,7) from t1; +format(col2,7) +1,234,567,890.1234500 +select format(col2,8) from t1; +format(col2,8) +1,234,567,890.12345000 +insert into t1 values(7,1234567890123456.12345); +select format(col2,6) from t1 where col1=7; +format(col2,6) +1,234,567,890,123,456.123450 +drop table t1; +select ceil(0.09); +ceil(0.09) +1 +select ceil(0.000000000000000009); +ceil(0.000000000000000009) +1 +create table t1 select round(1, 6); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `round(1, 6)` bigint NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t1; +round(1, 6) +1 +drop table t1; +select abs(-2) * -2; +abs(-2) * -2 +-4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(1),(1),(2); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +858 656 +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1 WHERE a = 1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +INSERT INTO t1 VALUES (3); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +858 656 +354 906 +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) +FROM t1 WHERE a = 1; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED) +656 405 +122 405 +645 405 +PREPARE stmt FROM +"SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1"; +set @var=2; +EXECUTE stmt USING @var; +CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(?) * 1000 AS UNSIGNED) +656 656 +122 122 +645 645 +DROP TABLE t1; +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8; +insert into t1 values ('http://www.foo.com/', now()); +select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0)); +a +http://www.foo.com/ +Warnings: +Warning 1292 Truncated incorrect time value: '17540424:00:00' +Warning 1292 Truncated incorrect time value: '17540424:00:00' +drop table t1; +SET timestamp=DEFAULT; +set sql_mode='traditional'; +select ln(-1); +ln(-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log10(-1); +log10(-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log2(-1); +log2(-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log(2,-1); +log(2,-1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +select log(-2,1); +log(-2,1) +NULL +Warnings: +Warning 3020 Invalid argument for logarithm +set sql_mode=''; +select round(111,-10); +round(111,-10) +0 +select round(-5000111000111000155,-1); +round(-5000111000111000155,-1) +-5000111000111000160 +select round(15000111000111000155,-1); +round(15000111000111000155,-1) +15000111000111000160 +select truncate(-5000111000111000155,-1); +truncate(-5000111000111000155,-1) +-5000111000111000150 +select truncate(15000111000111000155,-1); +truncate(15000111000111000155,-1) +15000111000111000150 +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 +(f1 varchar(32) not null, +f2 smallint(5) unsigned not null, +f3 int(10) unsigned not null default '0') +default charset=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000); +create table t2 +(f1 int(10) unsigned not null, +f2 int(10) unsigned not null, +f3 smallint(5) unsigned not null) +default charset=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values (16777216,16787215,1),(33554432,33564431,2); +select format(t2.f2-t2.f1+1,0) from t1,t2 +where t1.f2 = t2.f3 order by t1.f1; +format(t2.f2-t2.f1+1,0) +10,000 +10,000 +drop table t1, t2; +set names default; +select cast(-2 as unsigned), 18446744073709551614, -2; +cast(-2 as unsigned) 18446744073709551614 -2 +18446744073709551614 18446744073709551614 -2 +select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2); +abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2) +18446744073709551614 18446744073709551614 2 +select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2); +ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2) +18446744073709551614 18446744073709551614 -2 +select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2); +floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2) +18446744073709551614 18446744073709551614 -2 +select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2); +format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2) +18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00 +select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2); +sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2) +4294967296 4294967296 NULL +select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1); +round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1) +18446744073709551614 18446744073709551614 -2 +select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2); +round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2) +4 4 0 +select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1); +truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1) +18446744073709551614 18446744073709551614 -2 +select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2); +truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2) +4 4 0 +select round(10000000000000000000, -19), truncate(10000000000000000000, -19); +round(10000000000000000000, -19) truncate(10000000000000000000, -19) +10000000000000000000 10000000000000000000 +select round(1e0, -309), truncate(1e0, -309); +round(1e0, -309) truncate(1e0, -309) +0 0 +select round(1e1,308), truncate(1e1, 308); +round(1e1,308) truncate(1e1, 308) +10 10 +select round(1e1, 2147483648), truncate(1e1, 2147483648); +round(1e1, 2147483648) truncate(1e1, 2147483648) +10 10 +select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295); +round(1.1e1, 4294967295) truncate(1.1e1, 4294967295) +11 11 +select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296); +round(1.12e1, 4294967296) truncate(1.12e1, 4294967296) +11.2 11.2 +select round(1.5, 2147483640), truncate(1.5, 2147483640); +round(1.5, 2147483640) truncate(1.5, 2147483640) +1.5 1.5 +select round(1.5, -2147483649), round(1.5, 2147483648); +round(1.5, -2147483649) round(1.5, 2147483648) +0 1.5 +select truncate(1.5, -2147483649), truncate(1.5, 2147483648); +truncate(1.5, -2147483649) truncate(1.5, 2147483648) +0 1.5 +select round(1.5, -4294967296), round(1.5, 4294967296); +round(1.5, -4294967296) round(1.5, 4294967296) +0 1.5 +select truncate(1.5, -4294967296), truncate(1.5, 4294967296); +truncate(1.5, -4294967296) truncate(1.5, 4294967296) +0 1.5 +select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808); +round(1.5, -9223372036854775808) round(1.5, 9223372036854775808) +0 1.5 +select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808); +truncate(1.5, -9223372036854775808) truncate(1.5, 9223372036854775808) +0 1.5 +select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615); +round(1.5, 18446744073709551615) truncate(1.5, 18446744073709551615) +1.5 1.5 +select round(18446744073709551614, -1), truncate(18446744073709551614, -1); +round(18446744073709551614, -1) truncate(18446744073709551614, -1) +18446744073709551610 18446744073709551610 +select round(4, -4294967200), truncate(4, -4294967200); +round(4, -4294967200) truncate(4, -4294967200) +0 0 +select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3); +mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3) +2 2 -2 +select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2); +mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2) +5 5 1 +select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); +pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5) +2.13598703592091e96 2.13598703592091e96 -32 +CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); +INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); +SELECT a DIV 900 y FROM t1 GROUP BY y; +y +22201025555 +22255916666 +SELECT DISTINCT a DIV 900 y FROM t1; +y +22201025555 +22255916666 +SELECT b DIV 900 y FROM t1 GROUP BY y; +y +0 +Warnings: +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1292 Truncated incorrect DECIMAL value: 'str1' +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1292 Truncated incorrect DECIMAL value: 'str2' +SELECT c DIV 900 y FROM t1 GROUP BY y; +y +0 +DROP TABLE t1; +CREATE TABLE t1(a LONGBLOB); +INSERT INTO t1 VALUES('1'),('2'),('3'); +SELECT DISTINCT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +SELECT (a DIV 254576881) FROM t1 UNION ALL +SELECT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +0 +0 +0 +0 +0 +DROP TABLE t1; +CREATE TABLE t1(a SET('a','b','c')); +INSERT INTO t1 VALUES ('a'); +SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; +a DIV 2 +0 +DROP TABLE t1; +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (-1.1), (1.1), +(-1.5), (1.5), +(-1.9), (1.9), +(-2.1), (2.1), +(-2.5), (2.5), +(-2.9), (2.9), +# Check numbers with absolute values > 2^53 - 1 +# (see comments for MAX_EXACT_INTEGER) +(-1e16 - 0.5), (1e16 + 0.5), +(-1e16 - 1.5), (1e16 + 1.5); +SELECT a, ROUND(a) FROM t1; +a ROUND(a) +-1.1 -1 +1.1 1 +-1.5 -2 +1.5 2 +-1.9 -2 +1.9 2 +-2.1 -2 +2.1 2 +-2.5 -2 +2.5 2 +-2.9 -3 +2.9 3 +-1e16 -1e16 +1e16 1e16 +-1.0000000000000002e16 -1.0000000000000002e16 +1.0000000000000002e16 1.0000000000000002e16 +DROP TABLE t1; +CREATE TABLE t1(f1 LONGTEXT); +INSERT INTO t1 VALUES ('a'); +SELECT 1 FROM (SELECT ROUND(f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +1 +SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +1 +DROP TABLE t1; +End of 5.0 tests +SELECT 1e308 + 1e308; +ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)' +SELECT -1e308 - 1e308; +ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)' +SELECT 1e300 * 1e300; +ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)' +SELECT 1e300 / 1e-300; +ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)' +SELECT EXP(750); +ERROR 22003: DOUBLE value is out of range in 'exp(750)' +SELECT POW(10, 309); +ERROR 22003: DOUBLE value is out of range in 'pow(10,309)' +# +# Bug #44768: SIGFPE crash when selecting rand from a view +# containing null +# +CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a; +SELECT RAND(a) FROM v1; +RAND(a) +0.15522042769493574 +DROP VIEW v1; +SELECT RAND(a) FROM (SELECT NULL AS a) b; +RAND(a) +0.15522042769493574 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (NULL); +SELECT RAND(i) FROM t1; +RAND(i) +0.15522042769493574 +DROP TABLE t1; +# +# Bug#57477 SIGFPE when dividing a huge number a negative number +# +SELECT -9999999999999999991 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9999999999999999991) DIV -(1))' +SELECT -9223372036854775808 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))' +SELECT -9223372036854775808 MOD -1; +-9223372036854775808 MOD -1 +0 +SELECT -9223372036854775808999 MOD -1; +-9223372036854775808999 MOD -1 +0 +select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x; +ERROR 22003: BIGINT value is out of range in '(123456789012345678901234567890.123456789012345678901234567890 DIV 1)' +select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x; +ERROR 22003: BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)' +SHOW WARNINGS; +Level Code Message +Warning 1292 Truncated incorrect DECIMAL value: '123456789012345678901234567890' +Error 1690 BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)' +# +# Bug#57810 case/when/then : Assertion failed: length || !scale +# +SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END; +CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END +NULL +CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END) AS CHAR) as C; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `C` varchar(22) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR +# +CREATE TABLE t1 SELECT CEIL(ST_LINESTRINGFROMWKB(1) DIV NULL); +ERROR HY000: Incorrect arguments to DIV +CREATE TABLE t1 SELECT FLOOR(ST_LINESTRINGFROMWKB(1) DIV NULL); +ERROR HY000: Incorrect arguments to DIV +# +# Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION +# +CREATE TABLE t1(f1 DECIMAL(22,1)); +INSERT INTO t1 VALUES (0),(1); +SELECT ROUND(f1, f1) FROM t1; +ROUND(f1, f1) +0.0 +1.0 +SELECT ROUND(f1, f1) FROM t1 GROUP BY 1; +ROUND(f1, f1) +0.0 +1.0 +DROP TABLE t1; +# +# Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA +# +SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a')); +ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a')) +-4939092.0000 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +# +# Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION +# +SELECT SUM(DISTINCT (TRUNCATE((.1), NULL))); +SUM(DISTINCT (TRUNCATE((.1), NULL))) +NULL +End of 5.1 tests +# +# Bug #8433: Overflow must be an error +# +SELECT 1e308 + 1e308; +ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)' +SELECT -1e308 - 1e308; +ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)' +SELECT 1e300 * 1e300; +ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)' +SELECT 1e300 / 1e-300; +ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)' +SELECT EXP(750); +ERROR 22003: DOUBLE value is out of range in 'exp(750)' +SELECT POW(10, 309); +ERROR 22003: DOUBLE value is out of range in 'pow(10,309)' +SELECT COT(0); +ERROR 22003: DOUBLE value is out of range in 'cot(0)' +SELECT DEGREES(1e307); +ERROR 22003: DOUBLE value is out of range in 'degrees(1e307)' +SELECT 9223372036854775808 + 9223372036854775808; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 + 9223372036854775808)' +SELECT 18446744073709551615 + 1; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1)' +SELECT 1 + 18446744073709551615; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(1 + 18446744073709551615)' +SELECT -2 + CAST(1 AS UNSIGNED); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(2) + cast(1 as unsigned))' +SELECT CAST(1 AS UNSIGNED) + -2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -(2))' +SELECT -9223372036854775808 + -9223372036854775808; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) + -(9223372036854775808))' +SELECT 9223372036854775807 + 9223372036854775807; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 + 9223372036854775807)' +SELECT CAST(0 AS UNSIGNED) - 9223372036854775809; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(0 as unsigned) - 9223372036854775809)' +SELECT 9223372036854775808 - 9223372036854775809; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 - 9223372036854775809)' +SELECT CAST(1 AS UNSIGNED) - 2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) - 2)' +SELECT 18446744073709551615 - (-1); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -(1))' +SELECT -1 - 9223372036854775808; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - 9223372036854775808)' +SELECT -1 - CAST(1 AS UNSIGNED); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - cast(1 as unsigned))' +SELECT -9223372036854775808 - 1; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) - 1)' +SELECT 9223372036854775807 - -9223372036854775808; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(9223372036854775808))' +set SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +SELECT 18446744073709551615 - 1; +ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - 1)' +SELECT 18446744073709551615 - CAST(1 AS UNSIGNED); +ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - cast(1 as unsigned))' +SELECT 18446744073709551614 - (-1); +ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -(1))' +SELECT 9223372036854775807 - -1; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(1))' +set SQL_MODE=default; +SELECT 4294967296 * 4294967296; +ERROR 22003: BIGINT value is out of range in '(4294967296 * 4294967296)' +SELECT 9223372036854775808 * 2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)' +SELECT 9223372036854775808 * 2; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)' +SELECT 7158278827 * 3221225472; +ERROR 22003: BIGINT value is out of range in '(7158278827 * 3221225472)' +SELECT 9223372036854775807 * (-2); +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -(2))' +SELECT CAST(1 as UNSIGNED) * (-1); +ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -(1))' +SELECT 9223372036854775807 * 2; +ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * 2)' +SELECT ABS(-9223372036854775808); +ERROR 22003: BIGINT value is out of range in 'abs(-(9223372036854775808))' +SELECT -9223372036854775808 DIV -1; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))' +SELECT 18446744073709551615 DIV -1; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -(1))' +CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED); +INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809); +SELECT -a FROM t1; +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`a`)' +SELECT -b FROM t1; +ERROR 22003: BIGINT value is out of range in '-(`test`.`t1`.`b`)' +DROP TABLE t1; +SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999; +SELECT @a + @a; +ERROR 22003: DECIMAL value is out of range in '((@`a`) + (@`a`))' +SELECT @a * @a; +ERROR 22003: DECIMAL value is out of range in '((@`a`) * (@`a`))' +SELECT -@a - @a; +ERROR 22003: DECIMAL value is out of range in '(-((@`a`)) - (@`a`))' +SELECT @a / 0.5; +ERROR 22003: DECIMAL value is out of range in '((@`a`) / 0.5)' +SELECT COT(1/0); +COT(1/0) +NULL +Warnings: +Warning 1365 Division by 0 +SELECT -1 + 9223372036854775808; +-1 + 9223372036854775808 +9223372036854775807 +SELECT 2 DIV -2; +2 DIV -2 +-1 +SELECT -(1 DIV 0); +-(1 DIV 0) +NULL +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +SELECT -9223372036854775808 MOD -1; +-9223372036854775808 MOD -1 +0 +# +# Bug #57209 valgrind + Assertion failed: dst > buf +# +SELECT floor(log10(format(concat_ws(5445796E25, 5306463, 30837), -358821))) +as foo; +foo +2 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '53064635.445796e3130837' +Warning 1292 Truncated incorrect DOUBLE value: '179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,' +# +# Bug #58137 char(0) column cause: +# my_gcvt: Assertion `width > 0 && to != ((void *)0)' failed +# +CREATE TABLE t1(a char(0)); +INSERT IGNORE INTO t1 (SELECT -pi()); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +DROP TABLE t1; +# +# Bug #59241 invalid memory read +# in do_div_mod with doubly assigned variables +# +SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa'))); +((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa'))) +NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1365 Division by 0 +# +# Bug #59498 div function broken in mysql-trunk +# +SELECT 1 div null; +1 div null +NULL +# +# Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONS +# +select (1.175494351E-37 div 1.7976931348623157E+308); +(1.175494351E-37 div 1.7976931348623157E+308) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '1.7976931348623157' +# +# Bug#12744991 - DECIMAL_ROUND(X,D) GIVES WRONG RESULTS WHEN D == N*(-9) +# +select round(999999999, -9); +round(999999999, -9) +1000000000 +select round(999999999.0, -9); +round(999999999.0, -9) +1000000000 +select round(999999999999999999, -18); +round(999999999999999999, -18) +1000000000000000000 +select round(999999999999999999.0, -18); +round(999999999999999999.0, -18) +1000000000000000000 +# +# Bug#12537160 ASSERTION FAILED: +# STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER. +# +select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.1 as foo; +foo +0.0 +select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.0 as foo; +foo +NULL +Warnings: +Warning 1365 Division by 0 +# +# Bug#12711164 - 61676: +# RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE +# +select 5 div 2; +5 div 2 +2 +select 5.0 div 2.0; +5.0 div 2.0 +2 +select 5.0 div 2; +5.0 div 2 +2 +select 5 div 2.0; +5 div 2.0 +2 +select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2; +5.9 div 2 1.23456789e3 DIV 2 1.23456789e9 DIV 2 1.23456789e19 DIV 2 +2 617 617283945 6172839450000000000 +# +# Bug#11758319 BEHAVIOR OF LOGARITHMIC FUNCTIONS DEPENDS ON +# ERROR_FOR_DIVISION_BY_ZERO +# Bug#50507 Behavior of logarithmic functions depends on +# ERROR_FOR_DIVISION_BY_ZERO +CREATE TABLE t1(a DOUBLE); +SET sql_mode=''; +INSERT INTO t1 VALUES (ln(1)); +INSERT INTO t1 VALUES (ln(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (ln(-1)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log(1,0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log2(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +INSERT INTO t1 VALUES (log10(0)); +Warnings: +Warning 3020 Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +0 +SET sql_mode=default; +INSERT INTO t1 VALUES (ln(1)); +INSERT INTO t1 VALUES (ln(0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (ln(-1)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log(0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log(1,0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log2(0)); +ERROR 2201E: Invalid argument for logarithm +INSERT INTO t1 VALUES (log10(0)); +ERROR 2201E: Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +0 +0 +UPDATE t1 SET a = ln(0); +ERROR 2201E: Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +0 +0 +SET sql_mode=''; +UPDATE t1 SET a = ln(0); +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SET sql_mode=default; +DELETE FROM t1 WHERE a <=> ln(0); +ERROR 2201E: Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SET sql_mode=''; +DELETE FROM t1 WHERE a <=> ln(0); +Warnings: +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +Warning 3020 Invalid argument for logarithm +SELECT * FROM t1 ORDER BY a; +a +DROP TABLE t1; +SET sql_mode=default; +# +# Bug#19047527 SQRT() : UNINITIALISED VALUE IN MY_STRTOD +# +do sqrt(weight_string(_eucjpms "0E+")); +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '0E+' +# +# Bug#21279005 - ROUND FUNCTION INCORRECT IN WHERE-CLAUSE +# USING LOCAL VARIABLE +CREATE PROCEDURE test_round_fn() +BEGIN +DECLARE num_digits int; +SET num_digits := 3; +CREATE TEMPORARY TABLE tmp_test ( +number double +); +INSERT INTO tmp_test +VALUES (1),(0); +SELECT +number, +Round(number, num_digits) > 0, +Round(number, 3) > 0 +FROM +tmp_test; +SELECT +number, +Round(number, num_digits) > 0, +Round(number, 3) > 0 +FROM +tmp_test +WHERE +Round(number, 3) >= 0; +SELECT +number, +Round(number, num_digits) > 0, +Round(number, 3) > 0 +FROM +tmp_test +WHERE +Round(number, num_digits) >= 0; +END| +CALL test_round_fn(); +number Round(number, num_digits) > 0 Round(number, 3) > 0 +1 1 1 +0 0 0 +number Round(number, num_digits) > 0 Round(number, 3) > 0 +1 1 1 +0 0 0 +number Round(number, num_digits) > 0 Round(number, 3) > 0 +1 1 1 +0 0 0 +DROP PROCEDURE test_round_fn; +# +# Bug#23013359 FUNCTION FLOOR(CEIL()) TRUNCATES BIGINT UNSIGNED +# +SELECT floor(ceil(12345678901234567890)); +floor(ceil(12345678901234567890)) +12345678901234567890 +SELECT floor(18446744073709551616); +floor(18446744073709551616) +18446744073709551616 +SELECT floor(floor(18446744073709551616)); +floor(floor(18446744073709551616)) +18446744073709551616 +SELECT floor(floor(floor(18446744073709551616))); +floor(floor(floor(18446744073709551616))) +18446744073709551616 +# Bug#25669580: regression: assertion failed: 0 in Item_num_func1::str_op +DO ROUND(0xe9b1, NULL); +# Bug#25688504: regression: scale >= 0 && precision >= 0 && ... +DO COUNT(DISTINCT ROUND(CAST(SLEEP(0) AS DECIMAL), NULL)); +# +# Bug#26495791 - EXPAND TEST SUITE TO INCLUDE CRC32 TESTS +# +SELECT CRC32(NULL), CRC32(''), CRC32('MySQL'), CRC32('mysql'); +CRC32(NULL) CRC32('') CRC32('MySQL') CRC32('mysql') +NULL 0 3259397556 2501908538 +SELECT CRC32('01234567'), CRC32('012345678'); +CRC32('01234567') CRC32('012345678') +763378421 939184570 +SELECT CRC32('~!@$%^*'), CRC32('-0.0001'); +CRC32('~!@$%^*') CRC32('-0.0001') +1533935548 324352530 +SELECT CRC32(99999999999999999999999999999999); +CRC32(99999999999999999999999999999999) +3035957051 +SELECT CRC32(-99999999999999999999999999999999); +CRC32(-99999999999999999999999999999999) +1052326872 +DROP TABLE IF EXISTS t; +Warnings: +Note 1051 Unknown table 'test.t' +CREATE TABLE t(a INT, b VARCHAR(2)); +INSERT INTO t VALUES (1,'a'), (2,'qw'), (1,'t'), (3,'t'); +SELECT crc32(SUM(a)) FROM t; +crc32(SUM(a)) +1790921346 +SELECT crc32(AVG(a)) FROM t GROUP BY b; +crc32(AVG(a)) +768278432 +2875100430 +2875100430 +SELECT crc32(MAX(b)) FROM t GROUP BY a; +crc32(MAX(b)) +2238339752 +3114057431 +2238339752 +SELECT a, b, crc32(a) FROM t GROUP BY a,b HAVING crc32(MAX(a))=450215437; +a b crc32(a) +2 qw 450215437 +SELECT a,b,concat(a,b),crc32(concat(a,b)) FROM t ORDER BY crc32(concat(a,b)); +a b concat(a,b) crc32(concat(a,b)) +2 qw 2qw 552289476 +1 a 1a 3174122627 +1 t 1t 3505168488 +3 t 3t 3805987562 +DROP TABLE t; +SELECT CRC32(4+2); +CRC32(4+2) +498629140 +SELECT CRC32(4/2); +CRC32(4/2) +2875100430 +SELECT CRC32(4-2); +CRC32(4-2) +450215437 +SELECT CRC32(4*2); +CRC32(4*2) +4194326291 +SELECT CRC32(ABS(-6)); +CRC32(ABS(-6)) +498629140 +SELECT CRC32(CEILING(1.23)); +CRC32(CEILING(1.23)) +450215437 +SELECT CRC32(FLOOR(1.23)); +CRC32(FLOOR(1.23)) +2212294583 +SELECT CRC32(LOG(10,100)); +CRC32(LOG(10,100)) +450215437 +SELECT CRC32(PI()); +CRC32(PI()) +2969982827 +SELECT CRC32(POWER(2,2)); +CRC32(POWER(2,2)) +4088798008 +SELECT CRC32(ROUND(1.58)); +CRC32(ROUND(1.58)) +450215437 +SELECT CRC32(SIGN(0)); +CRC32(SIGN(0)) +4108050209 +SELECT CRC32(SQRT(4)); +CRC32(SQRT(4)) +450215437 +SELECT CRC32(2 > 4); +CRC32(2 > 4) +4108050209 +SELECT CRC32(2 < 4); +CRC32(2 < 4) +2212294583 +SELECT CRC32(2 >= 4); +CRC32(2 >= 4) +4108050209 +SELECT CRC32(2 <= 4); +CRC32(2 <= 4) +2212294583 +SELECT CRC32(2 != 4); +CRC32(2 != 4) +2212294583 +SELECT CRC32(NOT 1); +CRC32(NOT 1) +4108050209 +SELECT CRC32(1 AND 1); +CRC32(1 AND 1) +2212294583 +SELECT CRC32(1 OR 1); +CRC32(1 OR 1) +2212294583 +SELECT CRC32(1 XOR 1); +CRC32(1 XOR 1) +4108050209 +SELECT CRC32(ASCII('2')); +CRC32(ASCII('2')) +3308380389 +SELECT CRC32(BIT_LENGTH('text')); +CRC32(BIT_LENGTH('text')) +2103780943 +SELECT CRC32(CHAR('77','121','83','81','76')); +CRC32(CHAR('77','121','83','81','76')) +3259397556 +SELECT CRC32(CONCAT('good','year')); +CRC32(CONCAT('good','year')) +3441724142 +SELECT CRC32(INSERT('foodyear', 1, 4, 'good')); +CRC32(INSERT('foodyear', 1, 4, 'good')) +3441724142 +SELECT CRC32(LEFT('goodyear', 4)); +CRC32(LEFT('goodyear', 4)) +1820610194 +SELECT CRC32(LENGTH('text')); +CRC32(LENGTH('text')) +4088798008 +SELECT CRC32(LOWER('GOODYEAR')); +CRC32(LOWER('GOODYEAR')) +3441724142 +SELECT CRC32(UPPER('goodyear')); +CRC32(UPPER('goodyear')) +186062498 +SELECT CRC32(LTRIM(' goodyear')); +CRC32(LTRIM(' goodyear')) +3441724142 +SELECT CRC32(RTRIM('goodyear ')); +CRC32(RTRIM('goodyear ')) +3441724142 +SELECT CRC32(REPLACE('godyear','o','oo')); +CRC32(REPLACE('godyear','o','oo')) +3441724142 +SELECT CRC32(REVERSE('goodyear')); +CRC32(REVERSE('goodyear')) +3423698264 +SELECT CRC32(true); +CRC32(true) +2212294583 +SELECT CRC32(false); +CRC32(false) +4108050209 +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (c1 BIT(5), +c2 TINYINT, +c3 MEDIUMINT, +c4 INTEGER, +c5 BIGINT, +c6 DECIMAL(7,5), +c7 FLOAT(7,5), +c8 DOUBLE(7,5)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (B'10101', 127, 8388607, 2147483647, +9223372036854775807, 10.5, 11.5, 12.5); +SELECT CRC32(c1) FROM t1; +CRC32(c1) +3219065702 +SELECT CRC32(c2) FROM t1; +CRC32(c2) +2401609675 +SELECT CRC32(c3) FROM t1; +CRC32(c3) +1742563487 +SELECT CRC32(c4) FROM t1; +CRC32(c4) +365954768 +SELECT CRC32(c5) FROM t1; +CRC32(c5) +1122634462 +SELECT CRC32(c6) FROM t1; +CRC32(c6) +4255015174 +SELECT CRC32(c7) FROM t1; +CRC32(c7) +1542023858 +SELECT CRC32(c8) FROM t1; +CRC32(c8) +1778479151 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 DATE, +c2 DATETIME, +c3 TIMESTAMP, +c4 TIME, +c5 YEAR); +INSERT INTO t1 VALUES ('2007-01-01', '2007-01-01 12:00:01', +'2007-01-01 00:00:01.000000', +'12:00:01.000000', '2007'); +SELECT CRC32(c1) FROM t1; +CRC32(c1) +2772295888 +SELECT CRC32(c2) FROM t1; +CRC32(c2) +1449026401 +SELECT CRC32(c3) FROM t1; +CRC32(c3) +225145558 +SELECT CRC32(c4) FROM t1; +CRC32(c4) +1077283474 +SELECT CRC32(c5) FROM t1; +CRC32(c5) +955685210 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 CHAR, +c2 VARCHAR(10), +c3 BINARY(1), +c4 VARBINARY(10), +c5 TINYBLOB, +c6 TINYTEXT, +c7 BLOB, +c8 TEXT, +c9 MEDIUMBLOB, +c10 MEDIUMTEXT, +c11 LONGBLOB, +c12 LONGTEXT); +INSERT INTO t1 VALUES ('a', 'a', 0x61, 0x61, 'a', 'a', +'a', 'a', 'a', 'a', 'a', 'a'); +SELECT CRC32(c1) FROM t1; +CRC32(c1) +3904355907 +SELECT CRC32(c2) FROM t1; +CRC32(c2) +3904355907 +SELECT CRC32(c3) FROM t1; +CRC32(c3) +3904355907 +SELECT CRC32(c4) FROM t1; +CRC32(c4) +3904355907 +SELECT CRC32(c5) FROM t1; +CRC32(c5) +3904355907 +SELECT CRC32(c6) FROM t1; +CRC32(c6) +3904355907 +SELECT CRC32(c7) FROM t1; +CRC32(c7) +3904355907 +SELECT CRC32(c8) FROM t1; +CRC32(c8) +3904355907 +SELECT CRC32(c9) FROM t1; +CRC32(c9) +3904355907 +SELECT CRC32(c10) FROM t1; +CRC32(c10) +3904355907 +SELECT CRC32(c11) FROM t1; +CRC32(c11) +3904355907 +SELECT CRC32(c12) FROM t1; +CRC32(c12) +3904355907 +SELECT CRC32(ST_GeomFromText('POINT(1 1)')); +CRC32(ST_GeomFromText('POINT(1 1)')) +1349318989 +CREATE TABLE geom_data(id INT, +pt POINT NOT NULL, +lnstr LINESTRING NOT NULL, +mlnstr MULTILINESTRING NOT NULL, +poly POLYGON NOT NULL, +mpoly MULTIPOLYGON NOT NULL); +INSERT INTO geom_data VALUES (10, +ST_GEOMFROMTEXT('POINT(10 20)'), +ST_GEOMFROMTEXT('LINESTRING(0 0,5 5,6 6)'), +ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 3,4 5),(6 6,8 8,9 9,10 10))'), +ST_GEOMFROMTEXT('POLYGON((0 0,6 7,8 8,3 9,0 0),(3 6,4 6,4 7,3 6))'), +ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)), + ((2 2,4 5,6 2,2 2)))')); +SELECT CRC32(ST_X(pt)) FROM geom_data; +CRC32(ST_X(pt)) +2707236321 +SELECT CRC32(ST_NumPoints((lnstr))) FROM geom_data; +CRC32(ST_NumPoints((lnstr))) +1842515611 +SELECT CRC32(ST_Length((mlnstr))) FROM geom_data; +CRC32(ST_Length((mlnstr))) +2090153432 +SELECT CRC32(ST_Area((poly))) FROM geom_data; +CRC32(ST_Area((poly))) +534598600 +SELECT CRC32(ST_Area((mpoly))) FROM geom_data; +CRC32(ST_Area((mpoly))) +3832313845 +DROP TABLE geom_data; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (e1 ENUM ('a','b'), s1 SET('a','b')); +INSERT INTO t1 VALUES(2,'a,b'),('a','b,a'); +SELECT e1, CRC32(e1) FROM t1; +e1 CRC32(e1) +b 1908338681 +a 3904355907 +SELECT s1, CRC32(s1) FROM t1; +s1 CRC32(s1) +a,b 752423903 +a,b 752423903 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a JSON); +INSERT INTO t1 VALUES ('{"name" : "goodyear"}'), +('{"name" : "verygood-year"}'); +SELECT a->>'$.name', CRC32(a) FROM t1; +a->>'$.name' CRC32(a) +goodyear 3664432072 +verygood-year 922278888 +SELECT CRC32(a->>'$.name') FROM t1 WHERE a->>'$.name' = 'goodyear'; +CRC32(a->>'$.name') +3441724142 +SELECT CRC32(REPLACE(JSON_EXTRACT(a, "$.name"),'\"','')) +FROM t1 WHERE JSON_EXTRACT(a, "$.name") = 'goodyear'; +CRC32(REPLACE(JSON_EXTRACT(a, "$.name"),'\"','')) +3441724142 +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES(10); +CREATE VIEW v1 AS SELECT CRC32(a) AS my_crc FROM t1; +SELECT * FROM v1; +my_crc +2707236321 +SELECT CRC32(CRC32(my_crc)) FROM v1; +CRC32(CRC32(my_crc)) +3114155452 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a CHAR); +CREATE TABLE t2 (b BIGINT); +CREATE TRIGGER trg1 +BEFORE INSERT ON t1 +FOR EACH ROW +INSERT INTO t2 VALUES(CRC32(NEW.a)); +INSERT INTO t1 VALUES('a'); +SELECT * FROM t2; +b +3904355907 +DROP TRIGGER trg1; +DROP TABLE t2; +DROP TABLE t1; +CREATE PROCEDURE crc32_proc (IN a CHAR, OUT b BIGINT) +SELECT CRC32(a) INTO b; +CALL crc32_proc('a',@val); +SELECT @val; +@val +3904355907 +DROP PROCEDURE crc32_proc; +CREATE FUNCTION crc32_func(inputvar CHAR) +RETURNS BIGINT +BEGIN +DECLARE crcval BIGINT; +SELECT CRC32(inputvar) INTO crcval; +RETURN crcval; +END| +SELECT crc32_func('a'); +crc32_func('a') +3904355907 +DROP FUNCTION crc32_func; +PREPARE stmt1 FROM 'SELECT CRC32(?)'; +SET @val = 'a'; +EXECUTE stmt1 USING @val; +CRC32(?) +3904355907 +DEALLOCATE PREPARE stmt; +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (a TEXT) CHARACTER SET = utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +LOAD DATA INFILE '../../std_data/loaddata_utf8.dat' INTO TABLE t1 CHARACTER SET utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT HEX(a), CRC32(a) from t1; +HEX(a) CRC32(a) +E4B880E4BA8CE4B889 1785250883 +E59B9BE4BA94E585AD 2914501801 +E4B883E585ABE4B99D 2374586519 +E4B880E4BA8CE4B889 1785250883 +E59B9BE4BA94E585AD 2914501801 +E4B883E585ABE4B99D0A 1546750244 +DROP TABLE t1; +SET NAMES default; +# +# Bug#27134168 UBSAN: MY_DOUBLE_ROUND - NEGATION OF BLAH +# +SELECT truncate( +0x123, +-9223372036854775808 +); +truncate( +0x123, +-9223372036854775808 +) +0 +# +# Bug#28401869 ARM BUILD ALLOWS NUMERIC VALUES OUT OF BOUNDS +# +select cast(pow(2,63) as signed) as pp; +ERROR 22003: BIGINT value is out of range in 'pow(2,63)' +select cast(pow(2,63)-1024 as signed) as pp; +pp +9223372036854774784 +select cast(1-pow(2,63) as signed) as qq; +qq +-9223372036854775808 +# +# Bug#17081376 ITEM_FUNC_MUL::INT_OP() MISHANDLES 9223372036854775809*-1 +# +SELECT 9223372036854775809 * -1; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775809 * -(1))' +SELECT -1 * 9223372036854775809; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) * 9223372036854775809)' +# +# Bug#28505423 UBSAN: SIGNED INTEGER OVERFLOW IN MY_STRNTOULL10RND_8BIT +# +CREATE TABLE t(a int); +INSERT INTO t VALUES(hex(rtrim(1.040739e+308))); +ERROR 22003: Out of range value for column 'a' at row 1 +DROP TABLE t; +# +# Bug#28706832 WINDOWS ALLOWS NUMERIC VALUES OUT OF BOUNDS +# +SELECT 1-CAST(POW(2,100) AS SIGNED); +ERROR 22003: BIGINT value is out of range in 'pow(2,100)' +SELECT 1-CAST(POW(2,1000) AS SIGNED); +ERROR 22003: BIGINT value is out of range in 'pow(2,1000)' +# +# Bug#29581610 UBSAN ERROR IN ITEM_FUNC_MUL::INT_OP() +# +do ((3273059463432352943 )* (-9223372036854775808 )) ; +ERROR 22003: BIGINT value is out of range in '(3273059463432352943 * -(9223372036854775808))' +do ((-9223372036854775808)* ( 3273059463432352943)) ; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) * 3273059463432352943)' +select -9223372036854775808 * 0 as result; +result +0 +select 0 * -9223372036854775808 as result; +result +0 +select -9223372036854775808 * 1 as result; +result +-9223372036854775808 +select 1 * -9223372036854775808 as result; +result +-9223372036854775808 +select -9223372036854775808 * -1 as result; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) * -(1))' +select -1 * -9223372036854775808 as result; +ERROR 22003: BIGINT value is out of range in '(-(1) * -(9223372036854775808))' +select -9223372036854775808 * 2 as result; +ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) * 2)' +select 2 * -9223372036854775808 as result; +ERROR 22003: BIGINT value is out of range in '(2 * -(9223372036854775808))' +# +# Bug#30139913 CEILING AND FLOOR HAVE INCORRECT RESOLVED TYPES FOR BIGINT +# ARGUMENTS +# +CREATE TABLE t1(a BIGINT UNSIGNED); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES(18446744073709551615); +CREATE TABLE t2 AS +SELECT CEILING(a) AS c, FLOOR(a) AS f FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +c bigint unsigned YES NULL +f bigint unsigned YES NULL +SELECT * FROM t2; +c f +18446744073709551615 18446744073709551615 +DROP TABLE t1, t2; +# BIGINT should resolve to BIGINT. +CREATE TABLE t AS +SELECT CEILING(18446744073709551615) AS c, +FLOOR(18446744073709551615) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint unsigned NO 0 +f bigint unsigned NO 0 +DROP TABLE t; +# DECIMAL should resolve to DECIMAL when too big for BIGINT. +CREATE TABLE t AS +SELECT CEILING(18446744073709551616) AS c, +FLOOR(18446744073709551616) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(20,0) NO 0 +f decimal(20,0) NO 0 +DROP TABLE t; +# CEILING/FLOOR has to always assume a signed DECIMAL, making this too +# big for BIGINT. +CREATE TABLE t AS +SELECT CEILING(CAST(1844674407370955161 AS DECIMAL(19, 0))) AS c, +FLOOR(CAST(1844674407370955161 AS DECIMAL(19, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(19,0) NO 0 +f decimal(19,0) NO 0 +SELECT * FROM t; +c f +1844674407370955161 1844674407370955161 +DROP TABLE t; +CREATE TABLE t AS +SELECT CEILING(CAST(-9223372036854775808 AS DECIMAL(19, 0))) AS c, +FLOOR(CAST(-9223372036854775808 AS DECIMAL(19, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(19,0) NO 0 +f decimal(19,0) NO 0 +SELECT * FROM t; +c f +-9223372036854775808 -9223372036854775808 +DROP TABLE t; +# DECIMAL should resolve to BIGINT when it fits. +CREATE TABLE t AS +SELECT CEILING(CAST(184467440737095516 AS DECIMAL(18, 0))) AS c, +FLOOR(CAST(184467440737095516 AS DECIMAL(18, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint NO 0 +f bigint NO 0 +SELECT * FROM t; +c f +184467440737095516 184467440737095516 +DROP TABLE t; +CREATE TABLE t AS +SELECT CEILING(CAST(-922337203685477580 AS DECIMAL(18, 0))) AS c, +FLOOR(CAST(-922337203685477580 AS DECIMAL(18, 0))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint NO 0 +f bigint NO 0 +SELECT * FROM t; +c f +-922337203685477580 -922337203685477580 +DROP TABLE t; +# Account for possible increase of order of magnitude when rounding. +CREATE TABLE t AS +SELECT CEILING(CAST(99999999999999999.9 AS DECIMAL(18, 1))) AS c, +FLOOR(CAST(-99999999999999999.9 AS DECIMAL(18, 1))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c bigint NO 0 +f bigint NO 0 +SELECT * FROM t; +c f +100000000000000000 -100000000000000000 +DROP TABLE t; +CREATE TABLE t AS +SELECT CEILING(CAST(999999999999999999.9 AS DECIMAL(19, 1))) AS c, +FLOOR(CAST(-999999999999999999.9 AS DECIMAL(19, 1))) AS f; +DESCRIBE t; +Field Type Null Key Default Extra +c decimal(19,0) NO 0 +f decimal(19,0) NO 0 +SELECT * FROM t; +c f +1000000000000000000 -1000000000000000000 +DROP TABLE t; +# +# Bug #29952066 CAST OF NEGATIVE FUNCTION RETURN VALUE TO +# UNSIGNED MALFUNCTIONS WITH BIGINT +# +CREATE TABLE t0(c0 BIGINT UNSIGNED); +INSERT INTO t0(c0) VALUES(NULL); +SELECT * FROM t0 WHERE CAST(COALESCE(t0.c0, -1) AS UNSIGNED); +c0 +NULL +SELECT * FROM t0 WHERE CAST(IFNULL(t0.c0, -1) AS UNSIGNED); +c0 +NULL +SELECT CAST(COALESCE(t0.c0, -1) AS UNSIGNED) IS TRUE FROM t0; +CAST(COALESCE(t0.c0, -1) AS UNSIGNED) IS TRUE +1 +SELECT CAST(COALESCE(t0.c0, -1) AS UNSIGNED) FROM t0; +CAST(COALESCE(t0.c0, -1) AS UNSIGNED) +18446744073709551615 +DROP TABLE t0; +SELECT CAST(-1.1 AS UNSIGNED); +CAST(-1.1 AS UNSIGNED) +18446744073709551615 +# +# +# Bug #30680384 UBSAN: RUNTIME ERROR: NEGATION +# OF -9223372036854775808 IN ITEM_FUNC_ROUND::INT_OP() +# +select (round(-9223372036854775808, -4)); +ERROR 22003: BIGINT value is out of range in 'round(-(9223372036854775808),-(4))' +CREATE PROCEDURE test_round(in arg bigint) +BEGIN +DECLARE i int; +SET i = 0; +WHILE (i >= -20) DO +BEGIN +# Ignore SQLSTATE 22003 numeric value out of range +DECLARE CONTINUE HANDLER FOR SQLSTATE '22003' SHOW ERRORS; +SELECT arg, i, round(arg, i); +END; +SET i = i - 1; +END WHILE; +END// +CREATE PROCEDURE test_round_unsigned(in arg bigint unsigned) +BEGIN +DECLARE i int; +SET i = 0; +WHILE (i >= -20) DO +BEGIN +# Ignore SQLSTATE 22003 numeric value out of range +DECLARE CONTINUE HANDLER FOR SQLSTATE '22003' SHOW ERRORS; +SELECT arg, i, round(arg, i); +END; +SET i = i - 1; +END WHILE; +END// +CALL test_round(-123456); +arg i round(arg, i) +-123456 0 -123456 +arg i round(arg, i) +-123456 -1 -123460 +arg i round(arg, i) +-123456 -2 -123500 +arg i round(arg, i) +-123456 -3 -123000 +arg i round(arg, i) +-123456 -4 -120000 +arg i round(arg, i) +-123456 -5 -100000 +arg i round(arg, i) +-123456 -6 0 +arg i round(arg, i) +-123456 -7 0 +arg i round(arg, i) +-123456 -8 0 +arg i round(arg, i) +-123456 -9 0 +arg i round(arg, i) +-123456 -10 0 +arg i round(arg, i) +-123456 -11 0 +arg i round(arg, i) +-123456 -12 0 +arg i round(arg, i) +-123456 -13 0 +arg i round(arg, i) +-123456 -14 0 +arg i round(arg, i) +-123456 -15 0 +arg i round(arg, i) +-123456 -16 0 +arg i round(arg, i) +-123456 -17 0 +arg i round(arg, i) +-123456 -18 0 +arg i round(arg, i) +-123456 -19 0 +arg i round(arg, i) +-123456 -20 0 +CALL test_round(-9223372036854775807); +arg i round(arg, i) +-9223372036854775807 0 -9223372036854775807 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -2 -9223372036854775800 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -7 -9223372036850000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -11 -9223372000000000000 +arg i round(arg, i) +-9223372036854775807 -12 -9223372000000000000 +arg i round(arg, i) +-9223372036854775807 -13 -9223370000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -15 -9223000000000000000 +arg i round(arg, i) +-9223372036854775807 -16 -9220000000000000000 +arg i round(arg, i) +-9223372036854775807 -17 -9200000000000000000 +arg i round(arg, i) +-9223372036854775807 -18 -9000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775807 -20 0 +CALL test_round(-9223372036854775808); +arg i round(arg, i) +-9223372036854775808 0 -9223372036854775808 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -2 -9223372036854775800 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -7 -9223372036850000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -11 -9223372000000000000 +arg i round(arg, i) +-9223372036854775808 -12 -9223372000000000000 +arg i round(arg, i) +-9223372036854775808 -13 -9223370000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -15 -9223000000000000000 +arg i round(arg, i) +-9223372036854775808 -16 -9220000000000000000 +arg i round(arg, i) +-9223372036854775808 -17 -9200000000000000000 +arg i round(arg, i) +-9223372036854775808 -18 -9000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +-9223372036854775808 -20 0 +CALL test_round(9223372036854775807); +arg i round(arg, i) +9223372036854775807 0 9223372036854775807 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -2 9223372036854775800 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -7 9223372036850000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -11 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -12 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -13 9223370000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -15 9223000000000000000 +arg i round(arg, i) +9223372036854775807 -16 9220000000000000000 +arg i round(arg, i) +9223372036854775807 -17 9200000000000000000 +arg i round(arg, i) +9223372036854775807 -18 9000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +9223372036854775807 -20 0 +CALL test_round(9223372036854775808); +ERROR 22003: Out of range value for column 'arg' at row 1 +CALL test_round_unsigned(9223372036854775807); +arg i round(arg, i) +9223372036854775807 0 9223372036854775807 +arg i round(arg, i) +9223372036854775807 -1 9223372036854775810 +arg i round(arg, i) +9223372036854775807 -2 9223372036854775800 +arg i round(arg, i) +9223372036854775807 -3 9223372036854776000 +arg i round(arg, i) +9223372036854775807 -4 9223372036854780000 +arg i round(arg, i) +9223372036854775807 -5 9223372036854800000 +arg i round(arg, i) +9223372036854775807 -6 9223372036855000000 +arg i round(arg, i) +9223372036854775807 -7 9223372036850000000 +arg i round(arg, i) +9223372036854775807 -8 9223372036900000000 +arg i round(arg, i) +9223372036854775807 -9 9223372037000000000 +arg i round(arg, i) +9223372036854775807 -10 9223372040000000000 +arg i round(arg, i) +9223372036854775807 -11 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -12 9223372000000000000 +arg i round(arg, i) +9223372036854775807 -13 9223370000000000000 +arg i round(arg, i) +9223372036854775807 -14 9223400000000000000 +arg i round(arg, i) +9223372036854775807 -15 9223000000000000000 +arg i round(arg, i) +9223372036854775807 -16 9220000000000000000 +arg i round(arg, i) +9223372036854775807 -17 9200000000000000000 +arg i round(arg, i) +9223372036854775807 -18 9000000000000000000 +arg i round(arg, i) +9223372036854775807 -19 10000000000000000000 +arg i round(arg, i) +9223372036854775807 -20 0 +CALL test_round_unsigned(9223372036854775808); +arg i round(arg, i) +9223372036854775808 0 9223372036854775808 +arg i round(arg, i) +9223372036854775808 -1 9223372036854775810 +arg i round(arg, i) +9223372036854775808 -2 9223372036854775800 +arg i round(arg, i) +9223372036854775808 -3 9223372036854776000 +arg i round(arg, i) +9223372036854775808 -4 9223372036854780000 +arg i round(arg, i) +9223372036854775808 -5 9223372036854800000 +arg i round(arg, i) +9223372036854775808 -6 9223372036855000000 +arg i round(arg, i) +9223372036854775808 -7 9223372036850000000 +arg i round(arg, i) +9223372036854775808 -8 9223372036900000000 +arg i round(arg, i) +9223372036854775808 -9 9223372037000000000 +arg i round(arg, i) +9223372036854775808 -10 9223372040000000000 +arg i round(arg, i) +9223372036854775808 -11 9223372000000000000 +arg i round(arg, i) +9223372036854775808 -12 9223372000000000000 +arg i round(arg, i) +9223372036854775808 -13 9223370000000000000 +arg i round(arg, i) +9223372036854775808 -14 9223400000000000000 +arg i round(arg, i) +9223372036854775808 -15 9223000000000000000 +arg i round(arg, i) +9223372036854775808 -16 9220000000000000000 +arg i round(arg, i) +9223372036854775808 -17 9200000000000000000 +arg i round(arg, i) +9223372036854775808 -18 9000000000000000000 +arg i round(arg, i) +9223372036854775808 -19 10000000000000000000 +arg i round(arg, i) +9223372036854775808 -20 0 +CALL test_round_unsigned(18446744073709551614); +arg i round(arg, i) +18446744073709551614 0 18446744073709551614 +arg i round(arg, i) +18446744073709551614 -1 18446744073709551610 +arg i round(arg, i) +18446744073709551614 -2 18446744073709551600 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -4 18446744073709550000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -8 18446744073700000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -10 18446744070000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -12 18446744000000000000 +arg i round(arg, i) +18446744073709551614 -13 18446740000000000000 +arg i round(arg, i) +18446744073709551614 -14 18446700000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -17 18400000000000000000 +arg i round(arg, i) +18446744073709551614 -18 18000000000000000000 +arg i round(arg, i) +Level Code Message +Error 1690 BIGINT UNSIGNED value is out of range in 'round(arg@0,i@1)' +arg i round(arg, i) +18446744073709551614 -20 0 +DROP PROCEDURE test_round; +DROP PROCEDURE test_round_unsigned; +# Bug#31128028 ROUND and TRUNCATE sometimes produce wrong result types +CREATE TABLE t1(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(11, -1); +CREATE TABLE t2 AS SELECT a, ROUND(a, b) AS c FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +a int YES NULL +c bigint YES NULL +DROP TABLE t1, t2; +# Bug#29602947: The behavior between INSERT stmt and "PREPARE stmt and +# EXECUTE stmt" different +CREATE TABLE t (a INTEGER); +INSERT INTO t VALUES (1.0E+01+'a'); +ERROR 22007: Truncated incorrect DOUBLE value: 'a' +PREPARE st1 FROM "INSERT INTO t VALUES (? + ?)"; +SET @a=1.0E+01; +SET @b='a'; +EXECUTE st1 USING @a,@b; +ERROR 22007: Truncated incorrect DOUBLE value: 'a' +DROP TABLE t; +# +# Bug #19186271 MANY, MANY CLASSES OF STRING-TO-INTEGER CONVERSION BUG +# +SET sql_mode = ''; +CREATE TABLE t1 (i INT, iu INT UNSIGNED, +b BIGINT, bu BIGINT UNSIGNED); +DELETE FROM t1; +INSERT INTO t1 (i,iu,b,bu) +# The second '.' and anything after it should be ignored. +VALUES ('1.2.3.4', '1.2.3.4', '1.2.3.4', '1.2.3.4'); +Warnings: +Warning 1265 Data truncated for column 'i' at row 1 +Warning 1265 Data truncated for column 'iu' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'bu' at row 1 +SELECT i,iu,b,bu FROM t1; +i iu b bu +1 1 1 1 +DELETE FROM t1; +INSERT INTO t1 (b,bu) VALUES ('92233720368547758000e+', '92233720368547758000e+'); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +SELECT b,bu FROM t1; +b bu +9223372036854775807 18446744073709551615 +DELETE FROM t1; +INSERT INTO t1 (b,bu) VALUES ('92233720368547758000', '92233720368547758000'); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +SELECT b,bu FROM t1; +b bu +9223372036854775807 18446744073709551615 +DELETE FROM t1; +INSERT INTO t1 (i,b) VALUES ('0.9223372036854775807', '0.9223372036854775807'); +INSERT INTO t1 (i,b) VALUES ('0.9223372036854775808', '0.9223372036854775808'); +SELECT i,b FROM t1; +i b +1 1 +1 1 +DELETE FROM t1; +INSERT INTO t1 (iu,bu) VALUES ('-1e19', '-1e19'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +INSERT INTO t1 (iu,bu) VALUES ('-2e19', '-2e19'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +INSERT INTO t1 (iu,bu) VALUES ('-18446744073709551615','-18446744073709551615'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +INSERT INTO t1 (iu,bu) VALUES ('-18446744073709551616','-18446744073709551616'); +Warnings: +Warning 1264 Out of range value for column 'iu' at row 1 +Warning 1264 Out of range value for column 'bu' at row 1 +SELECT iu,bu FROM t1; +iu bu +0 0 +0 0 +0 0 +0 0 +DROP TABLE t1; +SET sql_mode = DEFAULT; +# +# Bug #30156563 TYPE RESOLUTION OF DIV OPERATOR +# PRODUCES ONE LESS PRECISION. +# +SELECT 5.0 + 96 DIV 1; +5.0 + 96 DIV 1 +101.0 +CREATE TABLE t1 SELECT +5.0 + 96 DIV 1, # Dividend is integer +5.0 + 96.1234 DIV 1, # Dividend is decimal +5.0 + '96' DIV 1, # Dividend is string +5.0 + CAST('96' AS SIGNED) DIV 1, # Dividend is function +5.0 + CAST('96' AS UNSIGNED) DIV 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `5.0 + 96 DIV 1` decimal(4,1) DEFAULT NULL, + `5.0 + 96.1234 DIV 1` decimal(8,1) DEFAULT NULL, + `5.0 + '96' DIV 1` decimal(4,1) DEFAULT NULL, + `5.0 + CAST('96' AS SIGNED) DIV 1` decimal(22,1) DEFAULT NULL, + `5.0 + CAST('96' AS UNSIGNED) DIV 1` decimal(23,1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; diff --git a/mysql-test/r/func_prefix_key.result-pq b/mysql-test/r/func_prefix_key.result-pq new file mode 100644 index 000000000..53ae142f8 --- /dev/null +++ b/mysql-test/r/func_prefix_key.result-pq @@ -0,0 +1,943 @@ +CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde'); +ALTER TABLE t1 ADD KEY k2 (b(4)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 19 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 19 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 19 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%') +EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 36.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k2 NULL NULL NULL 5 36.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a')) +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# 'Using index' method is not used since 'b' field is used in select output. +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# Index k2 shouldn't be used. +EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%') +DROP TABLE t1; +CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde'); +ALTER TABLE t1 ADD KEY k2 (b(4)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 7 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 7 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 7 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 7 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%') +EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 7 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 36.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k2 NULL NULL NULL 5 36.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a')) +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# 'Using index' method is not used since 'b' field is used in select output. +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 7 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# Index k2 shouldn't be used. +EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%') +DROP TABLE t1; +CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB DEFAULT CHARSET=utf32; +INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde'); +ALTER TABLE t1 ADD KEY k2 (b(4)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%') +EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a')) +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# 'Using index' method is not used since 'b' field is used in select output. +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# Index k2 shouldn't be used. +EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%') +DROP TABLE t1; +CREATE TABLE t1(a int, b TEXT, PRIMARY KEY(a))ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde'); +ALTER TABLE t1 ADD KEY k2 (b(4)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL k2 19 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL k2 19 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL k2 19 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%') +EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index k2 k2 19 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%') +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\') +# 'Using index' method is not used since wild string is not suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL k2 NULL NULL NULL 5 36.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a')) +# 'Using index' method is used since wild string is suitable for the use with prefix key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# 'Using index' method is not used since 'b' field is used in select output. +EXPLAIN SELECT b FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +# Index k2 shouldn't be used. +EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%') +DROP TABLE t1; +CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB DEFAULT CHARSET=utf32; +INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde'), (6, 'abcdf'); +ALTER TABLE t1 ADD KEY k2 (b(4)); +ALTER TABLE t1 ADD KEY k3 (b(2)); +ALTER TABLE t1 ADD KEY k4 (a, b(3)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# k2 index used since it's covering. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2,k3 k2 19 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%') +SELECT COUNT(*) FROM t1 WHERE b like 'abc%'; +COUNT(*) +4 +# k4 index used since it's covering. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ INDEX(t1 k4) */ COUNT(*) FROM t1 WHERE a > 4 AND b like 'abc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k4 k4 4 NULL 2 16.67 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `k4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abc%')) +SELECT /*+ INDEX(t1 k4) */ COUNT(*) FROM t1 WHERE a > 4 AND b like 'abc%'; +COUNT(*) +2 +# k3 index is used since it's shorters key. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range k2,k3 k3 11 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%') +SELECT COUNT(*) FROM t1 WHERE b like 'ab%'; +COUNT(*) +5 +# Index access is not used, no covering keys. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcde%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k2,k3,k4 PRIMARY 4 NULL 2 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abcde%')) +SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcde%'; +COUNT(*) +1 +# k2 index used since it's covering. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcd%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k2,k3,k4 k2 23 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abcd%')) +SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcd%'; +COUNT(*) +2 +# Index access is not used, no covering keys. +EXPLAIN SELECT b like 'abcdf%' FROM t1 WHERE a > 4 AND b like 'abcd%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k2,k3,k4 PRIMARY 4 NULL 2 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'abcdf%') AS `b like 'abcdf%'` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abcd%')) +SELECT b like 'abcdf%' FROM t1 WHERE a > 4 AND b like 'abcd%'; +b like 'abcdf%' +0 +1 +# Index access is used since k4 is covering. +EXPLAIN SELECT b like 'ab%' FROM t1 WHERE a > 4 AND b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k2,k3,k4 k4 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'ab%') AS `b like 'ab%'` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'a%')) +SELECT b like 'ab%' FROM t1 WHERE a > 4 AND b like 'a%'; +b like 'ab%' +1 +1 +# Index access is used since k3 is forced and covering. +EXPLAIN SELECT b like 'ab%' FROM t1 FORCE INDEX(k3) WHERE a > 4 AND b like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k3 k3 11 NULL 6 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` like 'ab%') AS `b like 'ab%'` from `test`.`t1` FORCE INDEX (`k3`) where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'a%')) +SELECT b like 'ab%' FROM t1 FORCE INDEX(k3) WHERE a > 4 AND b like 'a%'; +b like 'ab%' +1 +1 +# No index access is used since second argument is not const. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like `test`.`t1`.`a`) +SELECT COUNT(*) FROM t1 WHERE b like a; +COUNT(*) +0 +DROP TABLE t1; +CREATE TABLE t1(a int, b TEXT, c TEXT, PRIMARY KEY(a))ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'a', 'a'), (2, 'ab', 'ab'), (3, 'abc', 'abc'), (4, 'abcd', 'abcd'), (5, 'abcde', 'abcde'); +ALTER TABLE t1 ADD KEY k2 (b(4), c(3)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Index access is used since key is covering. +EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 19 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa') +DROP TABLE t1; +# +# Bug#27660560 RECENT REGRESSION: CRASH IN CHECK_COVERING_PREFIX_KEYS. +# +CREATE TABLE t1(f1 BLOB, KEY(f1(1))) ENGINE=INNODB; +INSERT INTO t1 VALUES ('ccc'), ('aa'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT (f1 LIKE null) from t1; +(f1 LIKE null) +NULL +NULL +SELECT 1 FROM t1 WHERE f1 NOT LIKE json_merge('' ,'+' ); +ERROR 22032: Invalid JSON text in argument 1 to function json_merge_preserve: "The document is empty." at position 0. +SELECT 1 FROM t1 WHERE f1 LIKE json_contains('key2' ,'key4' ); +ERROR 22032: Invalid JSON text in argument 1 to function json_contains: "Invalid value." at position 0. +SELECT 1 FROM t1 WHERE f1 LIKE json_depth(null); +1 +EXPLAIN SELECT (f1 LIKE null) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL f1 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`f1` like NULL) AS `(f1 LIKE null)` from `test`.`t1` +EXPLAIN SELECT (f1 LIKE null) from t1 WHERE f1 LIKE 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range f1 f1 4 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`f1` like NULL) AS `(f1 LIKE null)` from `test`.`t1` where (`test`.`t1`.`f1` like 'a%') +DROP TABLE t1; +# +# Bug#28934315 CASE STATEMENT USE IN CONDITIONAL WITH SUB_PART INDEX REGRESSION IN 8.0. +# +CREATE TABLE t1 ( +id INT(11) NOT NULL AUTO_INCREMENT, +example VARCHAR(100) NOT NULL DEFAULT '', +PRIMARY KEY (id), +KEY example_key (example(9)) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id INT(11) NOT NULL AUTO_INCREMENT, +example VARCHAR(100) NOT NULL DEFAULT '', +PRIMARY KEY (id) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (example) VALUES ('1234567890'); +INSERT INTO t2 (example) VALUES ('1234567890'); +EXPLAIN SELECT t2.example, t2.id FROM t2, t1 WHERE t1.example = LOWER(t2.example); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ref example_key example_key 38 func 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`example` AS `example`,`test`.`t2`.`id` AS `id` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`example` = lower(`test`.`t2`.`example`)) +SELECT t2.example, t2.id FROM t2, t1 WHERE t1.example = LOWER(t2.example); +example id +1234567890 1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/func_regexp.result-pq b/mysql-test/r/func_regexp.result-pq new file mode 100644 index 000000000..769eb4046 --- /dev/null +++ b/mysql-test/r/func_regexp.result-pq @@ -0,0 +1,173 @@ +drop table if exists t1; +set names latin1; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET latin1 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=default_engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +SELECT 'ghi' REGEXP 'ghi['; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +create table t1 (xxx char(128)); +insert into t1 (xxx) values('this is a test of some long text to see what happens'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where xxx regexp('is a test of some long text to'); +xxx +this is a test of some long text to see what happens +explain select * from t1 where xxx regexp('is a test of some long text to'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`xxx` AS `xxx` from `test`.`t1` where regexp_like(`test`.`t1`.`xxx`,'is a test of some long text to') +select * from t1 where xxx regexp('is a test of some long text to '); +xxx +this is a test of some long text to see what happens +select * from t1 where xxx regexp('is a test of some long text to s'); +xxx +this is a test of some long text to see what happens +select * from t1 where xxx regexp('is a test of some long text to se'); +xxx +this is a test of some long text to see what happens +drop table t1; +create table t1 (xxx char(128)); +insert into t1 (xxx) values('this is some text: to test - out.reg exp (22/45)'); +select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [[(][0-9]+[/\\][0-9]+[])][ ]*$'; +ERROR HY000: The regular expression contains an unclosed bracket expression. +drop table t1; +# The Henry Spencer library used prior to ICU was inonsistent +# here. When the regular expression search is performed in a +# case-insensitive manner, both '[[:lower:]]' and '[[:upper:]]' +# will match. +select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin; +_latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin +1 +select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin; +_koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin +0 +select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin; +_latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin +0 +select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin; +_koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin +1 +select _latin1 0xF7 regexp _latin1 '[[:alpha:]]'; +_latin1 0xF7 regexp _latin1 '[[:alpha:]]' +0 +select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]'; +_koi8r 0xF7 regexp _koi8r '[[:alpha:]]' +1 +select _latin1'a' regexp _latin1'A' collate latin1_general_ci; +_latin1'a' regexp _latin1'A' collate latin1_general_ci +1 +select _latin1'a' regexp _latin1'A' collate latin1_bin; +_latin1'a' regexp _latin1'A' collate latin1_bin +0 +create table t1 (a varchar(40)); +insert into t1 values ('C1'),('C2'),('R1'),('C3'),('R2'),('R3'); +prepare stmt1 from 'select a from t1 where a rlike ? order by a'; +set @a="^C.*"; +execute stmt1 using @a; +a +C1 +C2 +C3 +set @a="^R.*"; +execute stmt1 using @a; +a +R1 +R2 +R3 +deallocate prepare stmt1; +drop table t1; +End of 4.1 tests +SELECT 1 REGEXP NULL; +1 REGEXP NULL +NULL +SELECT '' REGEXP BINARY NULL; +ERROR HY000: Character set 'latin1_swedish_ci' cannot be used in conjunction with 'binary' in call to regexp_like. +SELECT NULL REGEXP BINARY NULL; +NULL REGEXP BINARY NULL +NULL +SELECT 'A' REGEXP BINARY NULL; +ERROR HY000: Character set 'latin1_swedish_ci' cannot be used in conjunction with 'binary' in call to regexp_like. +SELECT "ABC" REGEXP BINARY NULL; +ERROR HY000: Character set 'latin1_swedish_ci' cannot be used in conjunction with 'binary' in call to regexp_like. +End of 5.0 tests +CREATE TABLE t1(a INT, b CHAR(4)); +INSERT INTO t1 VALUES (1, '6.1'), (1, '7.0'), (1, '8.0'); +PREPARE stmt1 FROM "SELECT a FROM t1 WHERE a=1 AND '7.0' REGEXP b LIMIT 1"; +EXECUTE stmt1; +a +1 +EXECUTE stmt1; +a +1 +EXECUTE stmt1; +a +1 +EXECUTE stmt1; +a +1 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1; +End of 5.1 tests +SELECT ' ' REGEXP '[[:blank:]]'; +' ' REGEXP '[[:blank:]]' +1 +SELECT '\t' REGEXP '[[:blank:]]'; +'\t' REGEXP '[[:blank:]]' +1 +SELECT ' ' REGEXP '[[:space:]]'; +' ' REGEXP '[[:space:]]' +1 +SELECT '\t' REGEXP '[[:space:]]'; +'\t' REGEXP '[[:space:]]' +1 +# +# Bug#22836180: REGEXP, ASSERTION FAILED: !THD->IS_ERROR() +# IN SETUP_FIELDS() +# +DO 1 regexp (multilinestring(point(1,1))); +ERROR HY000: Incorrect arguments to multilinestring +# +# Bug#58026: massive recursion and crash in regular expression handling +# +SELECT '1' RLIKE RPAD('1', 10000, '('); diff --git a/mysql-test/r/func_str.result-pq b/mysql-test/r/func_str.result-pq new file mode 100644 index 000000000..cf96fc71d --- /dev/null +++ b/mysql-test/r/func_str.result-pq @@ -0,0 +1,5312 @@ +drop table if exists t1,t2; +set names latin1; +select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo'; +hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo +hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo +select 'hello' 'monty'; +hello +hellomonty +select length('\n\t\r\b\0\_\%\\'); +length('\n\t\r\b\0\_\%\\') +10 +select bit_length('\n\t\r\b\0\_\%\\'); +bit_length('\n\t\r\b\0\_\%\\') +80 +select char_length('\n\t\r\b\0\_\%\\'); +char_length('\n\t\r\b\0\_\%\\') +10 +select length(_latin1'\n\t\n\b\0\\_\\%\\'); +length(_latin1'\n\t\n\b\0\\_\\%\\') +10 +select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'); +concat('monty',' was here ','again') length('hello') char(ascii('h')) ord('h') +monty was here again 5 h 104 +select hex(char(256)); +hex(char(256)) +0100 +select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ; +locate('he','hello') locate('he','hello',2) locate('lo','hello',2) +1 0 4 +select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE'); +instr('hello','HE') instr('hello',binary 'HE') instr(binary 'hello','HE') +1 0 0 +select position(binary 'll' in 'hello'),position('a' in binary 'hello'); +position(binary 'll' in 'hello') position('a' in binary 'hello') +3 0 +select left('hello',null), right('hello',null); +left('hello',null) right('hello',null) +NULL NULL +select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ; +left('hello',2) right('hello',2) substring('hello',2,2) mid('hello',1,5) +he lo el hello +select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ; +concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) +happy +select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1); +substring_index('www.tcx.se','.',-2) substring_index('www.tcx.se','.',1) +tcx.se www +select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1); +substring_index('www.tcx.se','tcx',1) substring_index('www.tcx.se','tcx',-1) +www. .se +select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1); +substring_index('.tcx.se','.',-2) substring_index('.tcx.se','.tcx',-1) +tcx.se .se +select substring_index('aaaaaaaaa1','a',1); +substring_index('aaaaaaaaa1','a',1) + +select substring_index('aaaaaaaaa1','aa',1); +substring_index('aaaaaaaaa1','aa',1) + +select substring_index('aaaaaaaaa1','aa',2); +substring_index('aaaaaaaaa1','aa',2) +aa +select substring_index('aaaaaaaaa1','aa',3); +substring_index('aaaaaaaaa1','aa',3) +aaaa +select substring_index('aaaaaaaaa1','aa',4); +substring_index('aaaaaaaaa1','aa',4) +aaaaaa +select substring_index('aaaaaaaaa1','aa',5); +substring_index('aaaaaaaaa1','aa',5) +aaaaaaaaa1 +select substring_index('aaaaaaaaa1','aaa',1); +substring_index('aaaaaaaaa1','aaa',1) + +select substring_index('aaaaaaaaa1','aaa',2); +substring_index('aaaaaaaaa1','aaa',2) +aaa +select substring_index('aaaaaaaaa1','aaa',3); +substring_index('aaaaaaaaa1','aaa',3) +aaaaaa +select substring_index('aaaaaaaaa1','aaa',4); +substring_index('aaaaaaaaa1','aaa',4) +aaaaaaaaa1 +select substring_index('aaaaaaaaa1','aaaa',1); +substring_index('aaaaaaaaa1','aaaa',1) + +select substring_index('aaaaaaaaa1','aaaa',2); +substring_index('aaaaaaaaa1','aaaa',2) +aaaa +select substring_index('aaaaaaaaa1','1',1); +substring_index('aaaaaaaaa1','1',1) +aaaaaaaaa +select substring_index('aaaaaaaaa1','a',-1); +substring_index('aaaaaaaaa1','a',-1) +1 +select substring_index('aaaaaaaaa1','aa',-1); +substring_index('aaaaaaaaa1','aa',-1) +1 +select substring_index('aaaaaaaaa1','aa',-2); +substring_index('aaaaaaaaa1','aa',-2) +aa1 +select substring_index('aaaaaaaaa1','aa',-3); +substring_index('aaaaaaaaa1','aa',-3) +aaaa1 +select substring_index('aaaaaaaaa1','aa',-4); +substring_index('aaaaaaaaa1','aa',-4) +aaaaaa1 +select substring_index('aaaaaaaaa1','aa',-5); +substring_index('aaaaaaaaa1','aa',-5) +aaaaaaaaa1 +select substring_index('aaaaaaaaa1','aaa',-1); +substring_index('aaaaaaaaa1','aaa',-1) +1 +select substring_index('aaaaaaaaa1','aaa',-2); +substring_index('aaaaaaaaa1','aaa',-2) +aaa1 +select substring_index('aaaaaaaaa1','aaa',-3); +substring_index('aaaaaaaaa1','aaa',-3) +aaaaaa1 +select substring_index('aaaaaaaaa1','aaa',-4); +substring_index('aaaaaaaaa1','aaa',-4) +aaaaaaaaa1 +select substring_index('the king of thethe hill','the',-2); +substring_index('the king of thethe hill','the',-2) +the hill +select substring_index('the king of the the hill','the',-2); +substring_index('the king of the the hill','the',-2) + the hill +select substring_index('the king of the the hill','the',-2); +substring_index('the king of the the hill','the',-2) + the hill +select substring_index('the king of the the hill',' the ',-1); +substring_index('the king of the the hill',' the ',-1) +hill +select substring_index('the king of the the hill',' the ',-2); +substring_index('the king of the the hill',' the ',-2) + the hill +select substring_index('the king of the the hill',' ',-1); +substring_index('the king of the the hill',' ',-1) +hill +select substring_index('the king of the the hill',' ',-2); +substring_index('the king of the the hill',' ',-2) +the hill +select substring_index('the king of the the hill',' ',-3); +substring_index('the king of the the hill',' ',-3) + the hill +select substring_index('the king of the the hill',' ',-4); +substring_index('the king of the the hill',' ',-4) +the the hill +select substring_index('the king of the the hill',' ',-5); +substring_index('the king of the the hill',' ',-5) +of the the hill +select substring_index('the king of the.the hill','the',-2); +substring_index('the king of the.the hill','the',-2) +.the hill +select substring_index('the king of thethethe.the hill','the',-3); +substring_index('the king of thethethe.the hill','the',-3) +the.the hill +select substring_index('the king of thethethe.the hill','the',-1); +substring_index('the king of thethethe.the hill','the',-1) + hill +select substring_index('the king of the the hill','the',1); +substring_index('the king of the the hill','the',1) + +select substring_index('the king of the the hill','the',2); +substring_index('the king of the the hill','the',2) +the king of +select substring_index('the king of the the hill','the',3); +substring_index('the king of the the hill','the',3) +the king of the +select concat(':',ltrim(' left '),':',rtrim(' right '),':'); +concat(':',ltrim(' left '),':',rtrim(' right '),':') +:left : right: +select concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':'); +concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':') +:left : right: +select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':'); +concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':') +:left: right: +select concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':'); +concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':') +:m:y:s: +select concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':'); +concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':') +:my:sql: +select concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':'); +concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':') +:my:sql: +select TRIM("foo" FROM "foo"), TRIM("foo" FROM "foook"), TRIM("foo" FROM "okfoo"); +TRIM("foo" FROM "foo") TRIM("foo" FROM "foook") TRIM("foo" FROM "okfoo") + ok ok +select concat_ws(', ','monty','was here','again'); +concat_ws(', ','monty','was here','again') +monty, was here, again +select concat_ws(NULL,'a'),concat_ws(',',NULL,''); +concat_ws(NULL,'a') concat_ws(',',NULL,'') +NULL +select concat_ws(',','',NULL,'a'); +concat_ws(',','',NULL,'a') +,a +SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"'); +CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"') +"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc";"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); +insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es') +this is test +select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c'); +replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c') +bbbb bb bbbbbbbb aaaa bbbb +select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ; +replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') +this is a REAL test +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb') + H000 H4142 I51231 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select 'Glazgo' sounds like 'Liverpool'; +'Glazgo' sounds like 'Liverpool' +0 +select null sounds like 'null'; +null sounds like 'null' +NULL +select 'null' sounds like null; +'null' sounds like null +NULL +select null sounds like null; +null sounds like null +NULL +select md5('hello'); +md5('hello') +5d41402abc4b2a76b9719d911017c592 +select crc32("123"); +crc32("123") +2286445522 +select sha('abc'); +sha('abc') +a9993e364706816aba3e25717850c26c9cd0d89d +select sha1('abc'); +sha1('abc') +a9993e364706816aba3e25717850c26c9cd0d89d +select aes_decrypt(aes_encrypt('abc','1'),'1'); +aes_decrypt(aes_encrypt('abc','1'),'1') +abc +select aes_decrypt(aes_encrypt('abc','1'),1); +aes_decrypt(aes_encrypt('abc','1'),1) +abc +select aes_encrypt(NULL,"a"); +aes_encrypt(NULL,"a") +NULL +select aes_encrypt("a",NULL); +aes_encrypt("a",NULL) +NULL +select aes_decrypt(NULL,"a"); +aes_decrypt(NULL,"a") +NULL +select aes_decrypt("a",NULL); +aes_decrypt("a",NULL) +NULL +select aes_decrypt("a","a"); +aes_decrypt("a","a") +NULL +select aes_decrypt(aes_encrypt("","a"),"a"); +aes_decrypt(aes_encrypt("","a"),"a") + +select repeat('monty',5),concat('*',space(5),'*'); +repeat('monty',5) concat('*',space(5),'*') +montymontymontymontymonty * * +select reverse('abc'),reverse('abcd'); +reverse('abc') reverse('abcd') +cba dcba +select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22); +rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12') rpad(11, 10 , 22) rpad("ab", 10, 22) +a111 a121 abc 1122222222 ab22222222 +select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22); +lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12') lpad(11, 10 , 22) +111a 121a abc 2222222211 +select rpad(741653838,17,'0'),lpad(741653838,17,'0'); +rpad(741653838,17,'0') lpad(741653838,17,'0') +74165383800000000 00000000741653838 +select rpad('abcd',7,'ab'),lpad('abcd',7,'ab'); +rpad('abcd',7,'ab') lpad('abcd',7,'ab') +abcdaba abaabcd +select rpad('abcd',1,'ab'),lpad('abcd',1,'ab'); +rpad('abcd',1,'ab') lpad('abcd',1,'ab') +a a +select rpad('STRING', 20, CONCAT('p','a','d') ); +rpad('STRING', 20, CONCAT('p','a','d') ) +STRINGpadpadpadpadpa +select lpad('STRING', 20, CONCAT('p','a','d') ); +lpad('STRING', 20, CONCAT('p','a','d') ) +padpadpadpadpaSTRING +select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'); +LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') +NULL NULL +select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0"); +least(1,2,3) | greatest(16,32,8) least(5,4)*1 greatest(-1.0,1.0)*1 least(3,2,1)*1.0 greatest(1,1.1,1.0) least("10",9) greatest("A","B","0") +33 4 1.0 1.0 1.1 10 B +select quote('\'\"\\test'); +quote('\'\"\\test') +'\'"\\test' +select quote(concat('abc\'', '\\cba')); +quote(concat('abc\'', '\\cba')) +'abc\'\\cba' +select quote(1/0), quote('\0\Z'); +quote(1/0) quote('\0\Z') +NULL '\0\Z' +Warnings: +Warning 1365 Division by 0 +select length(quote(concat(char(0),"test"))); +length(quote(concat(char(0),"test"))) +8 +select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))); +hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))) +27E0E3E6E7E8EAEB27 +select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL); +unhex(hex("foobar")) hex(unhex("1234567890ABCDEF")) unhex("345678") unhex(NULL) +foobar 1234567890ABCDEF 4Vx NULL +select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456")); +hex(unhex("1")) hex(unhex("12")) hex(unhex("123")) hex(unhex("1234")) hex(unhex("12345")) hex(unhex("123456")) +01 12 0123 1234 012345 123456 +select length(unhex(md5("abrakadabra"))); +length(unhex(md5("abrakadabra"))) +16 +select concat('a', quote(NULL)); +concat('a', quote(NULL)) +aNULL +select reverse(""); +reverse("") + +select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2); +insert("aa",100,1,"b") insert("aa",1,3,"b") left("aa",-1) substring("a",1,2) +aa b a +select elt(2,1),field(NULL,"a","b","c"),reverse(""); +elt(2,1) field(NULL,"a","b","c") reverse("") +NULL 0 +select locate("a","b",2),locate("","a",1); +locate("a","b",2) locate("","a",1) +0 1 +select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a"); +ltrim("a") rtrim("a") trim(BOTH "" from "a") trim(BOTH " " from "a") +a a a a +select concat("1","2")|0,concat("1",".5")+0.0; +concat("1","2")|0 concat("1",".5")+0.0 +12 1.5 +select substring_index("www.tcx.se","",3); +substring_index("www.tcx.se","",3) + +select length(repeat("a",100000000)),length(repeat("a",1000*64)); +length(repeat("a",100000000)) length(repeat("a",1000*64)) +NULL 64000 +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql")); +position("0" in "baaa" in (1)) position("0" in "1" in (1,2,3)) position("sql" in ("mysql")) +1 0 3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'baaa' +select position(("1" in (1,2,3)) in "01"); +position(("1" in (1,2,3)) in "01") +2 +select length(repeat("a",65500)),length(concat(repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",10000)))),length(insert(repeat("a",40000),1,30000,repeat("b",50000))); +length(repeat("a",65500)) length(concat(repeat("a",32000),repeat("a",32000))) length(replace("aaaaa","a",concat(repeat("a",10000)))) length(insert(repeat("a",40000),1,30000,repeat("b",50000))) +65500 64000 50000 60000 +select length(repeat("a",1000000)),length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",32000)))),length(insert(repeat("a",48000),1,1000,repeat("a",48000))); +length(repeat("a",1000000)) length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000))) length(replace("aaaaa","a",concat(repeat("a",32000)))) length(insert(repeat("a",48000),1,1000,repeat("a",48000))) +1000000 96000 160000 95000 +create table t1 ( domain char(50) ); +insert into t1 VALUES ("hello.de" ), ("test.de" ); +select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@hello.de'; +domain +hello.de +select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de'; +domain +test.de +drop table t1; +CREATE TABLE t1 (i int, j int); +INSERT INTO t1 VALUES (1,1),(2,2); +SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; +i ELT(j, '345', '34') +1 345 +2 34 +DROP TABLE t1; +create table t1(a char(4)); +insert into t1 values ('one'),(NULL),('two'),('four'); +select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1; +a quote(a) isnull(quote(a)) quote(a) is null ifnull(quote(a), 'n') +one 'one' 0 0 'one' +NULL NULL 0 0 NULL +two 'two' 0 0 'two' +four 'four' 0 0 'four' +drop table t1; +select trim(trailing 'foo' from 'foo'); +trim(trailing 'foo' from 'foo') + +select trim(leading 'foo' from 'foo'); +trim(leading 'foo' from 'foo') + +select quote(ltrim(concat(' ', 'a'))); +quote(ltrim(concat(' ', 'a'))) +'a' +select quote(trim(concat(' ', 'a'))); +quote(trim(concat(' ', 'a'))) +'a' +CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3; +SELECT QUOTE('A') FROM t1; +QUOTE('A') +'A' +'A' +'A' +DROP TABLE t1; +select 1=_latin1'1'; +1=_latin1'1' +1 +select _latin1'1'=1; +_latin1'1'=1 +1 +select _latin2'1'=1; +_latin2'1'=1 +1 +select 1=_latin2'1'; +1=_latin2'1' +1 +select _latin1'1'=_latin2'1'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '=' +select row('a','b','c') = row('a','b','c'); +row('a','b','c') = row('a','b','c') +1 +select row('A','b','c') = row('a','b','c'); +row('A','b','c') = row('a','b','c') +1 +select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c'); +row('A' COLLATE latin1_bin,'b','c') = row('a','b','c') +0 +select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c'); +row('A','b','c') = row('a' COLLATE latin1_bin,'b','c') +0 +select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c'); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '=' +select concat(_latin1'a',_latin2'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat' +select concat(_latin1'a',_latin2'a',_latin5'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat' +select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a'); +ERROR HY000: Illegal mix of collations for operation 'concat' +select concat_ws(_latin1'a',_latin2'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_ws' +select FIELD('b','A','B'); +FIELD('b','A','B') +2 +select FIELD('B','A','B'); +FIELD('B','A','B') +2 +select FIELD('b' COLLATE latin1_bin,'A','B'); +FIELD('b' COLLATE latin1_bin,'A','B') +0 +select FIELD('b','A' COLLATE latin1_bin,'B'); +FIELD('b','A' COLLATE latin1_bin,'B') +0 +select FIELD(_latin2'b','A','B'); +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field' +select FIELD('b',_latin2'A','B'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field' +select FIELD('1',_latin2'3','2',1); +FIELD('1',_latin2'3','2',1) +3 +select POSITION(_latin1'B' IN _latin1'abcd'); +POSITION(_latin1'B' IN _latin1'abcd') +2 +select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin); +POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin) +0 +select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd'); +POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd') +0 +select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_bin,EXPLICIT) and (latin1_general_ci,EXPLICIT) for operation 'locate' +select POSITION(_latin1'B' IN _latin2'abcd'); +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'locate' +select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'); +FIND_IN_SET(_latin1'B',_latin1'a,b,c,d') +2 +select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'find_in_set' +select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'find_in_set' +select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2); +SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2) +abcdabc +select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_bin,_latin1'd',2); +SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_bin,_latin1'd',2) +abcdabc +select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd' COLLATE latin1_bin,2); +SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd' COLLATE latin1_bin,2) +abcdabc +select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2); +SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2) +abcdabc +select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2 0xa3, 2); +ERROR HY000: Cannot convert string '\xA3' from latin2 to latin1 +select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2); +SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2) +abcdabc +select _latin1'B' between _latin1'a' and _latin1'c'; +_latin1'B' between _latin1'a' and _latin1'c' +1 +select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c'; +_latin1'B' collate latin1_bin between _latin1'a' and _latin1'c' +0 +select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c'; +_latin1'B' between _latin1'a' collate latin1_bin and _latin1'c' +0 +select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin; +_latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin +0 +select _latin2'B' between _latin1'a' and _latin1'b'; +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between' +select _latin1'B' between _latin2'a' and _latin1'b'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between' +select _latin1'B' between _latin1'a' and _latin2'b'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation 'between' +select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b'; +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation 'between' +select _latin1'B' in (_latin1'a',_latin1'b'); +_latin1'B' in (_latin1'a',_latin1'b') +1 +select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b'); +_latin1'B' collate latin1_bin in (_latin1'a',_latin1'b') +0 +select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b'); +_latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b') +0 +select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin); +_latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin) +0 +select _latin2'B' in (_latin1'a',_latin1'b'); +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' in (_latin2'a',_latin1'b'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' in (_latin1'a',_latin2'b'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b'); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_swedish_ci,COERCIBLE), (latin1_bin,EXPLICIT) for operation ' IN ' +select collation(bin(130)), coercibility(bin(130)); +collation(bin(130)) coercibility(bin(130)) +latin1_swedish_ci 4 +select collation(oct(130)), coercibility(oct(130)); +collation(oct(130)) coercibility(oct(130)) +latin1_swedish_ci 4 +select collation(conv(130,16,10)), coercibility(conv(130,16,10)); +collation(conv(130,16,10)) coercibility(conv(130,16,10)) +latin1_swedish_ci 4 +select collation(hex(130)), coercibility(hex(130)); +collation(hex(130)) coercibility(hex(130)) +latin1_swedish_ci 4 +select collation(char(130)), coercibility(hex(130)); +collation(char(130)) coercibility(hex(130)) +binary 4 +select collation(format(130,10)), coercibility(format(130,10)); +collation(format(130,10)) coercibility(format(130,10)) +latin1_swedish_ci 4 +select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a')); +collation(lcase(_latin2'a')) coercibility(lcase(_latin2'a')) +latin2_general_ci 4 +select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a')); +collation(ucase(_latin2'a')) coercibility(ucase(_latin2'a')) +latin2_general_ci 4 +select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1)); +collation(left(_latin2'a',1)) coercibility(left(_latin2'a',1)) +latin2_general_ci 4 +select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1)); +collation(right(_latin2'a',1)) coercibility(right(_latin2'a',1)) +latin2_general_ci 4 +select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1)); +collation(substring(_latin2'a',1,1)) coercibility(substring(_latin2'a',1,1)) +latin2_general_ci 4 +select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b')); +collation(concat(_latin2'a',_latin2'b')) coercibility(concat(_latin2'a',_latin2'b')) +latin2_general_ci 4 +select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b')); +collation(lpad(_latin2'a',4,_latin2'b')) coercibility(lpad(_latin2'a',4,_latin2'b')) +latin2_general_ci 4 +select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b')); +collation(rpad(_latin2'a',4,_latin2'b')) coercibility(rpad(_latin2'a',4,_latin2'b')) +latin2_general_ci 4 +select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b')); +collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b')) +latin2_general_ci 4 +select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c')); +collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')) coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c')) +latin2_general_ci 4 +select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' ')); +collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')) coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' ')) +latin2_general_ci 4 +select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a ')); +collation(trim(_latin2' a ')) coercibility(trim(_latin2' a ')) +latin2_general_ci 4 +select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a ')); +collation(ltrim(_latin2' a ')) coercibility(ltrim(_latin2' a ')) +latin2_general_ci 4 +select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a ')); +collation(rtrim(_latin2' a ')) coercibility(rtrim(_latin2' a ')) +latin2_general_ci 4 +select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a')); +collation(trim(LEADING _latin2' ' FROM _latin2'a')) coercibility(trim(LEADING _latin2'a' FROM _latin2'a')) +latin2_general_ci 4 +select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a')); +collation(trim(TRAILING _latin2' ' FROM _latin2'a')) coercibility(trim(TRAILING _latin2'a' FROM _latin2'a')) +latin2_general_ci 4 +select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a')); +collation(trim(BOTH _latin2' ' FROM _latin2'a')) coercibility(trim(BOTH _latin2'a' FROM _latin2'a')) +latin2_general_ci 4 +select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10)); +collation(repeat(_latin2'a',10)) coercibility(repeat(_latin2'a',10)) +latin2_general_ci 4 +select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab')); +collation(reverse(_latin2'ab')) coercibility(reverse(_latin2'ab')) +latin2_general_ci 4 +select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab')); +collation(quote(_latin2'ab')) coercibility(quote(_latin2'ab')) +latin2_general_ci 4 +select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab')); +collation(soundex(_latin2'ab')) coercibility(soundex(_latin2'ab')) +latin2_general_ci 4 +select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1)); +collation(substring(_latin2'ab',1)) coercibility(substring(_latin2'ab',1)) +latin2_general_ci 4 +select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef')); +collation(insert(_latin2'abcd',2,3,_latin2'ef')) coercibility(insert(_latin2'abcd',2,3,_latin2'ef')) +latin2_general_ci 4 +select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B')); +collation(replace(_latin2'abcd',_latin2'b',_latin2'B')) coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B')) +latin2_general_ci 4 +create table t1 charset latin1 +select +bin(130), +oct(130), +conv(130,16,10), +hex(130), +char(130), +format(130,10), +left(_latin2'a',1), +right(_latin2'a',1), +lcase(_latin2'a'), +ucase(_latin2'a'), +substring(_latin2'a',1,1), +concat(_latin2'a',_latin2'b'), +lpad(_latin2'a',4,_latin2'b'), +rpad(_latin2'a',4,_latin2'b'), +concat_ws(_latin2'a',_latin2'b'), +make_set(255,_latin2'a',_latin2'b',_latin2'c'), +export_set(255,_latin2'y',_latin2'n',_latin2' '), +trim(_latin2' a '), +ltrim(_latin2' a '), +rtrim(_latin2' a '), +trim(LEADING _latin2' ' FROM _latin2' a '), +trim(TRAILING _latin2' ' FROM _latin2' a '), +trim(BOTH _latin2' ' FROM _latin2' a '), +repeat(_latin2'a',10), +reverse(_latin2'ab'), +quote(_latin2'ab'), +soundex(_latin2'ab'), +substring(_latin2'ab',1), +insert(_latin2'abcd',2,3,_latin2'ef'), +replace(_latin2'abcd',_latin2'b',_latin2'B') +; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `bin(130)` varchar(65) DEFAULT NULL, + `oct(130)` varchar(65) DEFAULT NULL, + `conv(130,16,10)` varchar(65) DEFAULT NULL, + `hex(130)` varchar(6) DEFAULT NULL, + `char(130)` varbinary(4) DEFAULT NULL, + `format(130,10)` varchar(36) DEFAULT NULL, + `left(_latin2'a',1)` varchar(1) CHARACTER SET latin2 DEFAULT NULL, + `right(_latin2'a',1)` varchar(1) CHARACTER SET latin2 DEFAULT NULL, + `lcase(_latin2'a')` varchar(1) CHARACTER SET latin2 DEFAULT NULL, + `ucase(_latin2'a')` varchar(1) CHARACTER SET latin2 DEFAULT NULL, + `substring(_latin2'a',1,1)` varchar(1) CHARACTER SET latin2 DEFAULT NULL, + `concat(_latin2'a',_latin2'b')` varchar(2) CHARACTER SET latin2 DEFAULT NULL, + `lpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 DEFAULT NULL, + `rpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 DEFAULT NULL, + `concat_ws(_latin2'a',_latin2'b')` varchar(1) CHARACTER SET latin2 DEFAULT NULL, + `make_set(255,_latin2'a',_latin2'b',_latin2'c')` varchar(5) CHARACTER SET latin2 NOT NULL DEFAULT '', + `export_set(255,_latin2'y',_latin2'n',_latin2' ')` varchar(127) CHARACTER SET latin2 DEFAULT NULL, + `trim(_latin2' a ')` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `ltrim(_latin2' a ')` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `rtrim(_latin2' a ')` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `trim(LEADING _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `trim(TRAILING _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `trim(BOTH _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `repeat(_latin2'a',10)` varchar(10) CHARACTER SET latin2 DEFAULT NULL, + `reverse(_latin2'ab')` varchar(2) CHARACTER SET latin2 DEFAULT NULL, + `quote(_latin2'ab')` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `soundex(_latin2'ab')` varchar(4) CHARACTER SET latin2 DEFAULT NULL, + `substring(_latin2'ab',1)` varchar(2) CHARACTER SET latin2 DEFAULT NULL, + `insert(_latin2'abcd',2,3,_latin2'ef')` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `replace(_latin2'abcd',_latin2'b',_latin2'B')` varchar(4) CHARACTER SET latin2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a char character set latin2); +insert into t1 values (null); +select charset(a), collation(a), coercibility(a) from t1; +charset(a) collation(a) coercibility(a) +latin2 latin2_general_ci 2 +drop table t1; +select charset(null), collation(null), coercibility(null); +charset(null) collation(null) coercibility(null) +binary binary 6 +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (a int, b int); +INSERT INTO t1 VALUES (1,1),(2,2); +INSERT INTO t2 VALUES (2,2),(3,3); +select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b) +where collation(t2.a) = _utf8'binary' order by t1.a,t2.a; +a b a b +1 1 NULL NULL +2 2 2 2 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b) +where charset(t2.a) = _utf8'binary' order by t1.a,t2.a; +a b a b +1 1 NULL NULL +2 2 2 2 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b) +where coercibility(t2.a) = 5 order by t1.a,t2.a; +a b a b +1 1 NULL NULL +2 2 2 2 +DROP TABLE t1, t2; +select SUBSTR('abcdefg',3,2); +SUBSTR('abcdefg',3,2) +cd +select SUBSTRING('abcdefg',3,2); +SUBSTRING('abcdefg',3,2) +cd +select SUBSTR('abcdefg',-3,2) FROM DUAL; +SUBSTR('abcdefg',-3,2) +ef +select SUBSTR('abcdefg',-1,5) FROM DUAL; +SUBSTR('abcdefg',-1,5) +g +select SUBSTR('abcdefg',0,0) FROM DUAL; +SUBSTR('abcdefg',0,0) + +select SUBSTR('abcdefg',-1,-1) FROM DUAL; +SUBSTR('abcdefg',-1,-1) + +select SUBSTR('abcdefg',1,-1) FROM DUAL; +SUBSTR('abcdefg',1,-1) + +create table t7 (s1 char) charset latin1; +select * from t7 +where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA'; +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat' +drop table t7; +select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2); +substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2) substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2) +1abcd;2abcd 3abcd;4abcd +explain select md5('hello'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select md5('hello') AS `md5('hello')` +explain select sha('abc'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select sha('abc') AS `sha('abc')` +explain select sha1('abc'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select sha('abc') AS `sha1('abc')` +explain select soundex(''); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select soundex('') AS `soundex('')` +explain select 'mood' sounds like 'mud'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (soundex('mood') = soundex('mud')) AS `'mood' sounds like 'mud'` +explain select aes_decrypt(aes_encrypt('abc','1'),'1'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select aes_decrypt(aes_encrypt('abc','1'),'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')` +explain select concat('*',space(5),'*'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select concat('*',space(5),'*') AS `concat('*',space(5),'*')` +explain select reverse('abc'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select reverse('abc') AS `reverse('abc')` +explain select rpad('a',4,'1'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select rpad('a',4,'1') AS `rpad('a',4,'1')` +explain select lpad('a',4,'1'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select lpad('a',4,'1') AS `lpad('a',4,'1')` +explain select concat_ws(',','',NULL,'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select concat_ws(',','',NULL,'a') AS `concat_ws(',','',NULL,'a')` +explain select make_set(255,_latin2'a', _latin2'b', _latin2'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a', _latin2'b', _latin2'c')` +explain select elt(2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select elt(2,1) AS `elt(2,1)` +explain select locate("a","b",2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select locate('a','b',2) AS `locate("a","b",2)` +explain select format(130,10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select format(130,10) AS `format(130,10)` +explain select char(0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select char(0) AS `char(0)` +explain select conv(130,16,10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select conv(130,16,10) AS `conv(130,16,10)` +explain select hex(130); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select hex(130) AS `hex(130)` +explain select binary 'HE'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('HE' as char charset binary) AS `binary 'HE'` +explain select export_set(255,_latin2'y', _latin2'n', _latin2' '); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y', _latin2'n', _latin2' ')` +explain select FIELD('b' COLLATE latin1_bin,'A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select field(('b' collate latin1_bin),'A','B') AS `FIELD('b' COLLATE latin1_bin,'A','B')` +explain select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B', _latin1'a,b,c,d')` +explain select collation(conv(130,16,10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select collation(conv(130,16,10)) AS `collation(conv(130,16,10))` +explain select coercibility(conv(130,16,10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))` +explain select length('\n\t\r\b\0\_\%\\'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select length('\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')` +explain select bit_length('\n\t\r\b\0\_\%\\'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` +explain select bit_length('\n\t\r\b\0\_\%\\'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')` +explain select concat('monty',' was here ','again'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select concat('monty',' was here ','again') AS `concat('monty',' was here ','again')` +explain select length('hello'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select length('hello') AS `length('hello')` +explain select char(ascii('h')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select char(ascii('h')) AS `char(ascii('h'))` +explain select ord('h'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ord('h') AS `ord('h')` +explain select quote(1/0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select quote((1 / 0)) AS `quote(1/0)` +explain select crc32("123"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select crc32('123') AS `crc32("123")` +explain select replace('aaaa','a','b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select replace('aaaa','a','b') AS `replace('aaaa','a','b')` +explain select insert('txs',2,1,'hi'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select insert('txs',2,1,'hi') AS `insert('txs',2,1,'hi')` +explain select left(_latin2'a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select left(_latin2'a',1) AS `left(_latin2'a',1)` +explain select right(_latin2'a',1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select right(_latin2'a',1) AS `right(_latin2'a',1)` +explain select lcase(_latin2'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select lower(_latin2'a') AS `lcase(_latin2'a')` +explain select ucase(_latin2'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select upper(_latin2'a') AS `ucase(_latin2'a')` +explain select SUBSTR('abcdefg',3,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select substr('abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)` +explain select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select substring_index('1abcd;2abcd;3abcd;4abcd',';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)` +explain select trim(_latin2' a '); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select trim(_latin2' a ') AS `trim(_latin2' a ')` +explain select ltrim(_latin2' a '); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ltrim(_latin2' a ') AS `ltrim(_latin2' a ')` +explain select rtrim(_latin2' a '); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select rtrim(_latin2' a ') AS `rtrim(_latin2' a ')` +SELECT lpad(12345, 5, "#"); +lpad(12345, 5, "#") +12345 +SELECT conv(71, 10, 36), conv('1Z', 36, 10); +conv(71, 10, 36) conv('1Z', 36, 10) +1Z 71 +SELECT conv(71, 10, 37), conv('1Z', 37, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10); +conv(71, 10, 37) conv('1Z', 37, 10) conv(0,1,10) conv(0,0,10) conv(0,-1,10) +NULL NULL NULL NULL NULL +create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb'); +create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values (1,'cccccccccc'), (2,'dddddddddd'); +select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2 +where t2.id=t1.id order by name; +name +aaaaaaaaaaccccc +bbbbbbbbbbddddd +drop table t1, t2; +create table t1 (c1 INT, c2 INT UNSIGNED); +insert ignore into t1 values ('21474836461','21474836461'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +insert ignore into t1 values ('-21474836461','-21474836461'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +show warnings; +Level Code Message +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +select * from t1; +c1 c2 +2147483647 4294967295 +-2147483648 0 +drop table t1; +select left(1234, 3) + 0; +left(1234, 3) + 0 +123 +create table t1 (a int not null primary key, b varchar(40), c datetime); +insert into t1 (a,b,c) values (1,'Tom','2004-12-10 12:13:14'),(2,'ball games','2004-12-10 12:13:14'), (3,'Basil','2004-12-10 12:13:14'), (4,'Dean','2004-12-10 12:13:14'),(5,'Ellis','2004-12-10 12:13:14'), (6,'Serg','2004-12-10 12:13:14'), (7,'Sergei','2004-12-10 12:13:14'),(8,'Georg','2004-12-10 12:13:14'),(9,'Salle','2004-12-10 12:13:14'),(10,'Sinisa','2004-12-10 12:13:14'); +select count(*) as total, left(c,10) as reg from t1 group by reg order by reg desc limit 0,12; +total reg +10 2004-12-10 +drop table t1; +select trim(null from 'kate') as "must_be_null"; +must_be_null +NULL +select trim('xyz' from null) as "must_be_null"; +must_be_null +NULL +select trim(leading NULL from 'kate') as "must_be_null"; +must_be_null +NULL +select trim(trailing NULL from 'xyz') as "must_be_null"; +must_be_null +NULL +SELECT CHAR(NULL,121,83,81,'76') as my_column; +my_column +ySQL +SELECT CHAR_LENGTH(CHAR(NULL,121,83,81,'76')) as my_column; +my_column +4 +CREATE TABLE t1 (id int PRIMARY KEY, str char(255) NOT NULL) charset latin1; +CREATE TABLE t2 (id int NOT NULL UNIQUE); +INSERT INTO t2 VALUES (1),(2); +INSERT INTO t1 VALUES (1, aes_encrypt('foo', 'bar')); +INSERT INTO t1 VALUES (2, 'not valid'); +SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id; +id aes_decrypt(str, 'bar') +1 foo +2 NULL +SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id +ORDER BY t1.id; +id aes_decrypt(str, 'bar') +1 foo +2 NULL +DROP TABLE t1, t2; +select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); +field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0) +3 3 3 +select field(NULL,1,2,NULL), field(NULL,1,2,0); +field(NULL,1,2,NULL) field(NULL,1,2,0) +0 0 +CREATE TABLE t1 (str varchar(20) PRIMARY KEY); +CREATE TABLE t2 (num int primary key); +INSERT INTO t1 VALUES ('notnumber'); +INSERT INTO t2 VALUES (0), (1); +SELECT * FROM t1, t2 WHERE num=str; +str num +notnumber 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'notnumber' +SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6); +str num +notnumber 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'notnum' +DROP TABLE t1,t2; +CREATE TABLE t1( +id int(11) NOT NULL auto_increment, +pc int(11) NOT NULL default '0', +title varchar(20) default NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1, 0, 'Main'), +(2, 1, 'Toys'), +(3, 1, 'Games'); +SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1 +FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id +LEFT JOIN t1 AS t3 ON t2.pc=t3.id; +id col1 +1 Main +2 Main->Toys +3 Main->Games +SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1 +FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id +LEFT JOIN t1 AS t3 ON t2.pc=t3.id +WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%'; +id col1 +2 Main->Toys +DROP TABLE t1; +CREATE TABLE t1( +trackid int(10) unsigned NOT NULL auto_increment, +trackname varchar(100) NOT NULL default '', +PRIMARY KEY (trackid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2( +artistid int(10) unsigned NOT NULL auto_increment, +artistname varchar(100) NOT NULL default '', +PRIMARY KEY (artistid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3( +trackid int(10) unsigned NOT NULL, +artistid int(10) unsigned NOT NULL, +PRIMARY KEY (trackid,artistid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York'); +INSERT INTO t2 VALUES (1, 'Vernon Duke'); +INSERT INTO t3 VALUES (1,1); +SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname +FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid +LEFT JOIN t2 ON t2.artistid=t3.artistid +WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%'; +trackname artistname +April In Paris Vernon Duke Vernon Duke +Autumn In New York NULL +DROP TABLE t1,t2,t3; +create table t1 (b varchar(5)); +insert t1 values ('ab'), ('abc'), ('abcd'), ('abcde'); +select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1; +b substring(b,1) substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5) +ab ab b ab +abc abc c bc abc +abcd abcd d cd bcd abcd +abcde abcde e de cde bcde abcde +select * from (select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1) t; +b substring(b,1) substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5) +ab ab b ab +abc abc c bc abc +abcd abcd d cd bcd abcd +abcde abcde e de cde bcde abcde +drop table t1; +select hex(29223372036854775809) as hex_signed, +hex(cast(29223372036854775809 as unsigned)) as hex_unsigned; +hex_signed hex_unsigned +7FFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '29223372036854775809' +Warning 1292 Truncated incorrect DECIMAL value: '29223372036854775809' +select conv(29223372036854775809, -10, 16) as conv_signed, +conv(29223372036854775809, 10, 16) as conv_unsigned; +conv_signed conv_unsigned +7FFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '29223372036854775809' +Warning 1292 Truncated incorrect DECIMAL value: '29223372036854775809' +select hex(-29223372036854775809) as hex_signed, +hex(cast(-29223372036854775809 as unsigned)) as hex_unsigned; +hex_signed hex_unsigned +8000000000000000 8000000000000000 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-29223372036854775809' +Warning 1292 Truncated incorrect DECIMAL value: '-29223372036854775809' +select conv(-29223372036854775809, -10, 16) as conv_signed, +conv(-29223372036854775809, 10, 16) as conv_unsigned; +conv_signed conv_unsigned +8000000000000000 0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-29223372036854775809' +Warning 1292 Truncated incorrect DECIMAL value: '-29223372036854775809' +create table t1 (i int); +insert into t1 values (1000000000),(1); +select lpad(i, 7, ' ') as t from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t t 253 7 7 Y 0 0 8 +t +1000000 + 1 +select rpad(i, 7, ' ') as t from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t t 253 7 7 Y 0 0 8 +t +1000000 +1 +drop table t1; +select load_file("lkjlkj"); +load_file("lkjlkj") +NULL +select ifnull(load_file("lkjlkj"),"it is null"); +ifnull(load_file("lkjlkj"),"it is null") +it is null +create table t1 (f1 varchar(4), f2 varchar(64), unique key k1 (f1,f2)); +insert into t1 values ( 'test',md5('test')), ('test', sha('test')); +select * from t1 where f1='test' and (f2= md5("test") or f2= md5("TEST")); +f1 f2 +test 098f6bcd4621d373cade4e832627b4f6 +select * from t1 where f1='test' and (f2= md5("TEST") or f2= md5("test")); +f1 f2 +test 098f6bcd4621d373cade4e832627b4f6 +select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST")); +f1 f2 +test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 +select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test")); +f1 f2 +test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 +drop table t1; +CREATE TABLE t1 (a varchar(10)); +INSERT INTO t1 VALUES ('abc'), ('xyz'); +SELECT a, CONCAT(a,' ',a) AS c FROM t1 +HAVING LEFT(c,LENGTH(c)-INSTR(REVERSE(c)," ")) = a; +a c +abc abc abc +xyz xyz xyz +SELECT a, CONCAT(a,' ',a) AS c FROM t1 +HAVING LEFT(CONCAT(a,' ',a), +LENGTH(CONCAT(a,' ',a))- +INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a; +a c +abc abc abc +xyz xyz xyz +DROP TABLE t1; +CREATE TABLE t1 (s varchar(10)); +INSERT INTO t1 VALUES ('yadda'), ('yaddy'); +EXPLAIN SELECT s FROM t1 WHERE TRIM(s) > 'ab'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > 'ab') +EXPLAIN SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim('y' from `test`.`t1`.`s`) > 'ab') +EXPLAIN SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading 'y' from `test`.`t1`.`s`) > 'ab') +EXPLAIN SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing 'y' from `test`.`t1`.`s`) > 'ab') +EXPLAIN SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab') +DROP TABLE t1; +create table t1 (d decimal default null); +insert into t1 values (null); +select format(d, 2) from t1; +format(d, 2) +NULL +drop table t1; +create table t1 (c varchar(40)); +insert into t1 values ('y,abc'),('y,abc'); +select c, substring_index(lcase(c), @q:=',', -1) as res from t1; +c res +y,abc abc +y,abc abc +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +select cast(rtrim(' 20.06 ') as decimal(19,2)); +cast(rtrim(' 20.06 ') as decimal(19,2)) +20.06 +select cast(ltrim(' 20.06 ') as decimal(19,2)); +cast(ltrim(' 20.06 ') as decimal(19,2)) +20.06 +select cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2)); +cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2)) +20.06 +select conv("18383815659218730760",10,10) + 0; +conv("18383815659218730760",10,10) + 0 +1.838381565921873e19 +select "18383815659218730760" + 0; +"18383815659218730760" + 0 +1.838381565921873e19 +CREATE TABLE t1 (code varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13'); +SELECT ASCII(code), code FROM t1 WHERE code='A12'; +ASCII(code) code +97 a12 +65 A12 +SELECT ASCII(code), code FROM t1 WHERE code='A12' AND ASCII(code)=65; +ASCII(code) code +65 A12 +INSERT INTO t1 VALUES (_utf16 0x0061003100320007), (_utf16 0x00410031003200070007); +SELECT LENGTH(code), code FROM t1 WHERE code='A12'; +LENGTH(code) code +3 a12 +3 A12 +4 a12 +5 A12 +SELECT LENGTH(code), code FROM t1 WHERE code='A12' AND LENGTH(code)=5; +LENGTH(code) code +5 A12 +ALTER TABLE t1 ADD INDEX (code); +CREATE TABLE t2 (id varchar(10) PRIMARY KEY) charset utf8mb4; +INSERT INTO t2 VALUES ('a11'), ('a12'), ('a13'), ('a14'); +SELECT * FROM t1 INNER JOIN t2 ON t1.code=t2.id +WHERE t2.id='a12' AND (LENGTH(code)=5 OR code < 'a00'); +code id +A12 a12 +EXPLAIN +SELECT * FROM t1 INNER JOIN t2 ON code=id +WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 42 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 42 const 1 100.00 Using index +2 SIMPLE t1 NULL ref code code 43 const 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = 'a12') and (length(`test`.`t1`.`code`) = 5)) +DROP TABLE t1,t2; +select format(NULL, NULL); +format(NULL, NULL) +NULL +select format(pi(), NULL); +format(pi(), NULL) +NULL +select format(NULL, 2); +format(NULL, 2) +NULL +select benchmark(NULL, NULL); +benchmark(NULL, NULL) +NULL +select benchmark(0, NULL); +benchmark(0, NULL) +0 +select benchmark(100, NULL); +benchmark(100, NULL) +0 +select benchmark(NULL, 1+1); +benchmark(NULL, 1+1) +NULL +select benchmark(-1, 1); +benchmark(-1, 1) +NULL +Warnings: +Warning 1411 Incorrect count value: '-1' for function benchmark +set @dec=5; +select format(pi(), (1+1)); +format(pi(), (1+1)) +3.14 +select format(pi(), (select 3 from dual)); +format(pi(), (select 3 from dual)) +3.142 +select format(pi(), @dec); +format(pi(), @dec) +3.14159 +set @bench_count=10; +select benchmark(10, pi()); +benchmark(10, pi()) +0 +select benchmark(5+5, pi()); +benchmark(5+5, pi()) +0 +select benchmark((select 10 from dual), pi()); +benchmark((select 10 from dual), pi()) +0 +select benchmark(@bench_count, pi()); +benchmark(@bench_count, pi()) +0 +select locate('he','hello',-2); +locate('he','hello',-2) +0 +select locate('lo','hello',-4294967295); +locate('lo','hello',-4294967295) +0 +select locate('lo','hello',4294967295); +locate('lo','hello',4294967295) +0 +select locate('lo','hello',-4294967296); +locate('lo','hello',-4294967296) +0 +select locate('lo','hello',4294967296); +locate('lo','hello',4294967296) +0 +select locate('lo','hello',-4294967297); +locate('lo','hello',-4294967297) +0 +select locate('lo','hello',4294967297); +locate('lo','hello',4294967297) +0 +select locate('lo','hello',-18446744073709551615); +locate('lo','hello',-18446744073709551615) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select locate('lo','hello',18446744073709551615); +locate('lo','hello',18446744073709551615) +0 +select locate('lo','hello',-18446744073709551616); +locate('lo','hello',-18446744073709551616) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select locate('lo','hello',18446744073709551616); +locate('lo','hello',18446744073709551616) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select locate('lo','hello',-18446744073709551617); +locate('lo','hello',-18446744073709551617) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select locate('lo','hello',18446744073709551617); +locate('lo','hello',18446744073709551617) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select left('hello', 10); +left('hello', 10) +hello +select left('hello', 0); +left('hello', 0) + +select left('hello', -1); +left('hello', -1) + +select left('hello', -4294967295); +left('hello', -4294967295) + +select left('hello', 4294967295); +left('hello', 4294967295) +hello +select left('hello', -4294967296); +left('hello', -4294967296) + +select left('hello', 4294967296); +left('hello', 4294967296) +hello +select left('hello', -4294967297); +left('hello', -4294967297) + +select left('hello', 4294967297); +left('hello', 4294967297) +hello +select left('hello', -18446744073709551615); +left('hello', -18446744073709551615) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select left('hello', 18446744073709551615); +left('hello', 18446744073709551615) +hello +select left('hello', -18446744073709551616); +left('hello', -18446744073709551616) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select left('hello', 18446744073709551616); +left('hello', 18446744073709551616) +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select left('hello', -18446744073709551617); +left('hello', -18446744073709551617) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select left('hello', 18446744073709551617); +left('hello', 18446744073709551617) +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select right('hello', 10); +right('hello', 10) +hello +select right('hello', 0); +right('hello', 0) + +select right('hello', -1); +right('hello', -1) + +select right('hello', -4294967295); +right('hello', -4294967295) + +select right('hello', 4294967295); +right('hello', 4294967295) +hello +select right('hello', -4294967296); +right('hello', -4294967296) + +select right('hello', 4294967296); +right('hello', 4294967296) +hello +select right('hello', -4294967297); +right('hello', -4294967297) + +select right('hello', 4294967297); +right('hello', 4294967297) +hello +select right('hello', -18446744073709551615); +right('hello', -18446744073709551615) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select right('hello', 18446744073709551615); +right('hello', 18446744073709551615) +hello +select right('hello', -18446744073709551616); +right('hello', -18446744073709551616) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select right('hello', 18446744073709551616); +right('hello', 18446744073709551616) +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select right('hello', -18446744073709551617); +right('hello', -18446744073709551617) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select right('hello', 18446744073709551617); +right('hello', 18446744073709551617) +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select substring('hello', 2, -1); +substring('hello', 2, -1) + +select substring('hello', -1, 1); +substring('hello', -1, 1) +o +select substring('hello', -2, 1); +substring('hello', -2, 1) +l +select substring('hello', -4294967295, 1); +substring('hello', -4294967295, 1) + +select substring('hello', 4294967295, 1); +substring('hello', 4294967295, 1) + +select substring('hello', -4294967296, 1); +substring('hello', -4294967296, 1) + +select substring('hello', 4294967296, 1); +substring('hello', 4294967296, 1) + +select substring('hello', -4294967297, 1); +substring('hello', -4294967297, 1) + +select substring('hello', 4294967297, 1); +substring('hello', 4294967297, 1) + +select substring('hello', -18446744073709551615, 1); +substring('hello', -18446744073709551615, 1) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select substring('hello', 18446744073709551615, 1); +substring('hello', 18446744073709551615, 1) + +select substring('hello', -18446744073709551616, 1); +substring('hello', -18446744073709551616, 1) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select substring('hello', 18446744073709551616, 1); +substring('hello', 18446744073709551616, 1) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select substring('hello', -18446744073709551617, 1); +substring('hello', -18446744073709551617, 1) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select substring('hello', 18446744073709551617, 1); +substring('hello', 18446744073709551617, 1) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select substring('hello', 1, -1); +substring('hello', 1, -1) + +select substring('hello', 1, -4294967295); +substring('hello', 1, -4294967295) + +select substring('hello', 1, 4294967295); +substring('hello', 1, 4294967295) +hello +select substring('hello', 1, -4294967296); +substring('hello', 1, -4294967296) + +select substring('hello', 1, 4294967296); +substring('hello', 1, 4294967296) +hello +select substring('hello', 1, -4294967297); +substring('hello', 1, -4294967297) + +select substring('hello', 1, 4294967297); +substring('hello', 1, 4294967297) +hello +select substring('hello', 1, -18446744073709551615); +substring('hello', 1, -18446744073709551615) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select substring('hello', 1, 18446744073709551615); +substring('hello', 1, 18446744073709551615) +hello +select substring('hello', 1, -18446744073709551616); +substring('hello', 1, -18446744073709551616) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select substring('hello', 1, 18446744073709551616); +substring('hello', 1, 18446744073709551616) +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select substring('hello', 1, -18446744073709551617); +substring('hello', 1, -18446744073709551617) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select substring('hello', 1, 18446744073709551617); +substring('hello', 1, 18446744073709551617) +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select substring('hello', -1, -1); +substring('hello', -1, -1) + +select substring('hello', -4294967295, -4294967295); +substring('hello', -4294967295, -4294967295) + +select substring('hello', 4294967295, 4294967295); +substring('hello', 4294967295, 4294967295) + +select substring('hello', -4294967296, -4294967296); +substring('hello', -4294967296, -4294967296) + +select substring('hello', 4294967296, 4294967296); +substring('hello', 4294967296, 4294967296) + +select substring('hello', -4294967297, -4294967297); +substring('hello', -4294967297, -4294967297) + +select substring('hello', 4294967297, 4294967297); +substring('hello', 4294967297, 4294967297) + +select substring('hello', -18446744073709551615, -18446744073709551615); +substring('hello', -18446744073709551615, -18446744073709551615) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select substring('hello', 18446744073709551615, 18446744073709551615); +substring('hello', 18446744073709551615, 18446744073709551615) + +select substring('hello', -18446744073709551616, -18446744073709551616); +substring('hello', -18446744073709551616, -18446744073709551616) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select substring('hello', 18446744073709551616, 18446744073709551616); +substring('hello', 18446744073709551616, 18446744073709551616) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select substring('hello', -18446744073709551617, -18446744073709551617); +substring('hello', -18446744073709551617, -18446744073709551617) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select substring('hello', 18446744073709551617, 18446744073709551617); +substring('hello', 18446744073709551617, 18446744073709551617) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select insert('hello', -1, 1, 'hi'); +insert('hello', -1, 1, 'hi') +hello +select insert('hello', -4294967295, 1, 'hi'); +insert('hello', -4294967295, 1, 'hi') +hello +select insert('hello', 4294967295, 1, 'hi'); +insert('hello', 4294967295, 1, 'hi') +hello +select insert('hello', -4294967296, 1, 'hi'); +insert('hello', -4294967296, 1, 'hi') +hello +select insert('hello', 4294967296, 1, 'hi'); +insert('hello', 4294967296, 1, 'hi') +hello +select insert('hello', -4294967297, 1, 'hi'); +insert('hello', -4294967297, 1, 'hi') +hello +select insert('hello', 4294967297, 1, 'hi'); +insert('hello', 4294967297, 1, 'hi') +hello +select insert('hello', -18446744073709551615, 1, 'hi'); +insert('hello', -18446744073709551615, 1, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select insert('hello', 18446744073709551615, 1, 'hi'); +insert('hello', 18446744073709551615, 1, 'hi') +hello +select insert('hello', -18446744073709551616, 1, 'hi'); +insert('hello', -18446744073709551616, 1, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select insert('hello', 18446744073709551616, 1, 'hi'); +insert('hello', 18446744073709551616, 1, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select insert('hello', -18446744073709551617, 1, 'hi'); +insert('hello', -18446744073709551617, 1, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select insert('hello', 18446744073709551617, 1, 'hi'); +insert('hello', 18446744073709551617, 1, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select insert('hello', 1, -1, 'hi'); +insert('hello', 1, -1, 'hi') +hi +select insert('hello', 1, -4294967295, 'hi'); +insert('hello', 1, -4294967295, 'hi') +hi +select insert('hello', 1, 4294967295, 'hi'); +insert('hello', 1, 4294967295, 'hi') +hi +select insert('hello', 1, -4294967296, 'hi'); +insert('hello', 1, -4294967296, 'hi') +hi +select insert('hello', 1, 4294967296, 'hi'); +insert('hello', 1, 4294967296, 'hi') +hi +select insert('hello', 1, -4294967297, 'hi'); +insert('hello', 1, -4294967297, 'hi') +hi +select insert('hello', 1, 4294967297, 'hi'); +insert('hello', 1, 4294967297, 'hi') +hi +select insert('hello', 1, -18446744073709551615, 'hi'); +insert('hello', 1, -18446744073709551615, 'hi') +hi +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select insert('hello', 1, 18446744073709551615, 'hi'); +insert('hello', 1, 18446744073709551615, 'hi') +hi +select insert('hello', 1, -18446744073709551616, 'hi'); +insert('hello', 1, -18446744073709551616, 'hi') +hi +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select insert('hello', 1, 18446744073709551616, 'hi'); +insert('hello', 1, 18446744073709551616, 'hi') +hi +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select insert('hello', 1, -18446744073709551617, 'hi'); +insert('hello', 1, -18446744073709551617, 'hi') +hi +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select insert('hello', 1, 18446744073709551617, 'hi'); +insert('hello', 1, 18446744073709551617, 'hi') +hi +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select insert('hello', -1, -1, 'hi'); +insert('hello', -1, -1, 'hi') +hello +select insert('hello', -4294967295, -4294967295, 'hi'); +insert('hello', -4294967295, -4294967295, 'hi') +hello +select insert('hello', 4294967295, 4294967295, 'hi'); +insert('hello', 4294967295, 4294967295, 'hi') +hello +select insert('hello', -4294967296, -4294967296, 'hi'); +insert('hello', -4294967296, -4294967296, 'hi') +hello +select insert('hello', 4294967296, 4294967296, 'hi'); +insert('hello', 4294967296, 4294967296, 'hi') +hello +select insert('hello', -4294967297, -4294967297, 'hi'); +insert('hello', -4294967297, -4294967297, 'hi') +hello +select insert('hello', 4294967297, 4294967297, 'hi'); +insert('hello', 4294967297, 4294967297, 'hi') +hello +select insert('hello', -18446744073709551615, -18446744073709551615, 'hi'); +insert('hello', -18446744073709551615, -18446744073709551615, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select insert('hello', 18446744073709551615, 18446744073709551615, 'hi'); +insert('hello', 18446744073709551615, 18446744073709551615, 'hi') +hello +select insert('hello', -18446744073709551616, -18446744073709551616, 'hi'); +insert('hello', -18446744073709551616, -18446744073709551616, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select insert('hello', 18446744073709551616, 18446744073709551616, 'hi'); +insert('hello', 18446744073709551616, 18446744073709551616, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +select insert('hello', -18446744073709551617, -18446744073709551617, 'hi'); +insert('hello', -18446744073709551617, -18446744073709551617, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select insert('hello', 18446744073709551617, 18446744073709551617, 'hi'); +insert('hello', 18446744073709551617, 18446744073709551617, 'hi') +hello +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +select repeat('hello', -1); +repeat('hello', -1) + +select repeat('hello', -4294967295); +repeat('hello', -4294967295) + +select repeat('hello', 4294967295); +repeat('hello', 4294967295) +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +select repeat('hello', -4294967296); +repeat('hello', -4294967296) + +select repeat('hello', 4294967296); +repeat('hello', 4294967296) +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +select repeat('hello', -4294967297); +repeat('hello', -4294967297) + +select repeat('hello', 4294967297); +repeat('hello', 4294967297) +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +select repeat('hello', -18446744073709551615); +repeat('hello', -18446744073709551615) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select repeat('hello', 18446744073709551615); +repeat('hello', 18446744073709551615) +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +select repeat('hello', -18446744073709551616); +repeat('hello', -18446744073709551616) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select repeat('hello', 18446744073709551616); +repeat('hello', 18446744073709551616) +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +select repeat('hello', -18446744073709551617); +repeat('hello', -18446744073709551617) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select repeat('hello', 18446744073709551617); +repeat('hello', 18446744073709551617) +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +select space(-1); +space(-1) + +select space(-4294967295); +space(-4294967295) + +select space(4294967295); +space(4294967295) +NULL +Warnings: +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +select space(-4294967296); +space(-4294967296) + +select space(4294967296); +space(4294967296) +NULL +Warnings: +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +select space(-4294967297); +space(-4294967297) + +select space(4294967297); +space(4294967297) +NULL +Warnings: +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +select space(-18446744073709551615); +space(-18446744073709551615) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select space(18446744073709551615); +space(18446744073709551615) +NULL +Warnings: +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +select space(-18446744073709551616); +space(-18446744073709551616) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select space(18446744073709551616); +space(18446744073709551616) +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +select space(-18446744073709551617); +space(-18446744073709551617) + +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select space(18446744073709551617); +space(18446744073709551617) +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +select rpad('hello', -1, '1'); +rpad('hello', -1, '1') +NULL +select rpad('hello', -4294967295, '1'); +rpad('hello', -4294967295, '1') +NULL +select rpad('hello', 4294967295, '1'); +rpad('hello', 4294967295, '1') +NULL +Warnings: +Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated +select rpad('hello', -4294967296, '1'); +rpad('hello', -4294967296, '1') +NULL +select rpad('hello', 4294967296, '1'); +rpad('hello', 4294967296, '1') +NULL +Warnings: +Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated +select rpad('hello', -4294967297, '1'); +rpad('hello', -4294967297, '1') +NULL +select rpad('hello', 4294967297, '1'); +rpad('hello', 4294967297, '1') +NULL +Warnings: +Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated +select rpad('hello', -18446744073709551615, '1'); +rpad('hello', -18446744073709551615, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select rpad('hello', 18446744073709551615, '1'); +rpad('hello', 18446744073709551615, '1') +NULL +Warnings: +Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated +select rpad('hello', -18446744073709551616, '1'); +rpad('hello', -18446744073709551616, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select rpad('hello', 18446744073709551616, '1'); +rpad('hello', 18446744073709551616, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated +select rpad('hello', -18446744073709551617, '1'); +rpad('hello', -18446744073709551617, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select rpad('hello', 18446744073709551617, '1'); +rpad('hello', 18446744073709551617, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated +select lpad('hello', -1, '1'); +lpad('hello', -1, '1') +NULL +select lpad('hello', -4294967295, '1'); +lpad('hello', -4294967295, '1') +NULL +select lpad('hello', 4294967295, '1'); +lpad('hello', 4294967295, '1') +NULL +Warnings: +Warning 1301 Result of lpad() was larger than max_allowed_packet (67108864) - truncated +select lpad('hello', -4294967296, '1'); +lpad('hello', -4294967296, '1') +NULL +select lpad('hello', 4294967296, '1'); +lpad('hello', 4294967296, '1') +NULL +Warnings: +Warning 1301 Result of lpad() was larger than max_allowed_packet (67108864) - truncated +select lpad('hello', -4294967297, '1'); +lpad('hello', -4294967297, '1') +NULL +select lpad('hello', 4294967297, '1'); +lpad('hello', 4294967297, '1') +NULL +Warnings: +Warning 1301 Result of lpad() was larger than max_allowed_packet (67108864) - truncated +select lpad('hello', -18446744073709551615, '1'); +lpad('hello', -18446744073709551615, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551615' +select lpad('hello', 18446744073709551615, '1'); +lpad('hello', 18446744073709551615, '1') +NULL +Warnings: +Warning 1301 Result of lpad() was larger than max_allowed_packet (67108864) - truncated +select lpad('hello', -18446744073709551616, '1'); +lpad('hello', -18446744073709551616, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551616' +select lpad('hello', 18446744073709551616, '1'); +lpad('hello', 18446744073709551616, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551616' +Warning 1301 Result of lpad() was larger than max_allowed_packet (67108864) - truncated +select lpad('hello', -18446744073709551617, '1'); +lpad('hello', -18446744073709551617, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '-18446744073709551617' +select lpad('hello', 18446744073709551617, '1'); +lpad('hello', 18446744073709551617, '1') +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1292 Truncated incorrect DECIMAL value: '18446744073709551617' +Warning 1301 Result of lpad() was larger than max_allowed_packet (67108864) - truncated +SET @orig_sql_mode = @@SQL_MODE; +SET SQL_MODE=traditional; +SELECT CHAR(0xff,0x8f USING utf8); +CHAR(0xff,0x8f USING utf8) +NULL +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1300 Invalid utf8 character string: 'FF8F' +SELECT CHAR(0xff,0x8f USING utf8) IS NULL; +CHAR(0xff,0x8f USING utf8) IS NULL +1 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1300 Invalid utf8 character string: 'FF8F' +SET SQL_MODE=@orig_sql_mode; +select substring('abc', cast(2 as unsigned int)); +substring('abc', cast(2 as unsigned int)) +bc +select repeat('a', cast(2 as unsigned int)); +repeat('a', cast(2 as unsigned int)) +aa +select rpad('abc', cast(5 as unsigned integer), 'x'); +rpad('abc', cast(5 as unsigned integer), 'x') +abcxx +select lpad('abc', cast(5 as unsigned integer), 'x'); +lpad('abc', cast(5 as unsigned integer), 'x') +xxabc +create table t1(f1 longtext); +insert into t1 values ("123"),("456"); +select substring(f1,1,1) from t1 group by 1; +substring(f1,1,1) +1 +4 +create table t2(f1 varchar(3)); +insert into t1 values ("123"),("456"); +select substring(f1,4,1), substring(f1,-4,1) from t2; +substring(f1,4,1) substring(f1,-4,1) +drop table t1,t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE `t1` ( +`id` varchar(20) NOT NULL, +`tire` tinyint(3) unsigned NOT NULL, +PRIMARY KEY (`id`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` (`id`, `tire`) VALUES ('A', 0), ('B', 1),('C', 2); +SELECT REPEAT( '#', tire ) AS A, +REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`; +A B tire + 0 +# # 1 +## ## 2 +SELECT REPEAT('0', CAST(0 AS UNSIGNED)); +REPEAT('0', CAST(0 AS UNSIGNED)) + +SELECT REPEAT('0', -2); +REPEAT('0', -2) + +SELECT REPEAT('0', 2); +REPEAT('0', 2) +00 +DROP TABLE t1; +SELECT UNHEX('G'); +UNHEX('G') +NULL +Warnings: +Warning 1411 Incorrect string value: ''G'' for function unhex +SELECT UNHEX('G') IS NULL; +UNHEX('G') IS NULL +1 +Warnings: +Warning 1411 Incorrect string value: ''G'' for function unhex +DO UNHEX(-1); +Warnings: +Warning 1411 Incorrect string value: '-(1)' for function unhex +SHOW warnings; +Level Code Message +Warning 1411 Incorrect string value: '-(1)' for function unhex +DO UNHEX(-182680438); +Warnings: +Warning 1411 Incorrect string value: '-(182680438)' for function unhex +SHOW warnings; +Level Code Message +Warning 1411 Incorrect string value: '-(182680438)' for function unhex +DO UNHEX(-2251799813685249); +Warnings: +Warning 1411 Incorrect string value: '-(2251799813685249)' for function unhex +SHOW warnings; +Level Code Message +Warning 1411 Incorrect string value: '-(2251799813685249)' for function unhex +select unhex('5078-04-25'); +unhex('5078-04-25') +NULL +Warnings: +Warning 1411 Incorrect string value: ''5078-04-25'' for function unhex +SELECT INSERT('abc', 3, 3, '1234'); +INSERT('abc', 3, 3, '1234') +ab1234 +SELECT INSERT('abc', 4, 3, '1234'); +INSERT('abc', 4, 3, '1234') +abc +SELECT INSERT('abc', 5, 3, '1234'); +INSERT('abc', 5, 3, '1234') +abc +SELECT INSERT('abc', 6, 3, '1234'); +INSERT('abc', 6, 3, '1234') +abc +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1; +CRC32(a) COUNT(*) +1790921346 1 +1842515611 1 +2212294583 1 +2226203566 1 +2366072709 1 +2707236321 1 +4088798008 1 +4194326291 1 +450215437 1 +498629140 1 +SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1; +CRC32(a) COUNT(*) +450215437 1 +498629140 1 +1790921346 1 +1842515611 1 +2212294583 1 +2226203566 1 +2366072709 1 +2707236321 1 +4088798008 1 +4194326291 1 +SELECT * FROM (SELECT CRC32(a) FROM t1) t2; +CRC32(a) +1790921346 +1842515611 +2212294583 +2226203566 +2366072709 +2707236321 +4088798008 +4194326291 +450215437 +498629140 +CREATE TABLE t2 SELECT CRC32(a) FROM t1; +desc t2; +Field Type Null Key Default Extra +CRC32(a) int unsigned YES NULL +SELECT * FROM v1; +C +1790921346 +1842515611 +2212294583 +2226203566 +2366072709 +2707236321 +4088798008 +4194326291 +450215437 +498629140 +SELECT * FROM (SELECT * FROM v1) x; +C +1790921346 +1842515611 +2212294583 +2226203566 +2366072709 +2707236321 +4088798008 +4194326291 +450215437 +498629140 +DROP TABLE t1, t2; +DROP VIEW v1; +SELECT LOCATE('foo', NULL) FROM DUAL; +LOCATE('foo', NULL) +NULL +SELECT LOCATE(NULL, 'o') FROM DUAL; +LOCATE(NULL, 'o') +NULL +SELECT LOCATE(NULL, NULL) FROM DUAL; +LOCATE(NULL, NULL) +NULL +SELECT LOCATE('foo', NULL) IS NULL FROM DUAL; +LOCATE('foo', NULL) IS NULL +1 +SELECT LOCATE(NULL, 'o') IS NULL FROM DUAL; +LOCATE(NULL, 'o') IS NULL +1 +SELECT LOCATE(NULL, NULL) IS NULL FROM DUAL; +LOCATE(NULL, NULL) IS NULL +1 +SELECT ISNULL(LOCATE('foo', NULL)) FROM DUAL; +ISNULL(LOCATE('foo', NULL)) +1 +SELECT ISNULL(LOCATE(NULL, 'o')) FROM DUAL; +ISNULL(LOCATE(NULL, 'o')) +1 +SELECT ISNULL(LOCATE(NULL, NULL)) FROM DUAL; +ISNULL(LOCATE(NULL, NULL)) +1 +SELECT LOCATE('foo', NULL) <=> NULL FROM DUAL; +LOCATE('foo', NULL) <=> NULL +1 +SELECT LOCATE(NULL, 'o') <=> NULL FROM DUAL; +LOCATE(NULL, 'o') <=> NULL +1 +SELECT LOCATE(NULL, NULL) <=> NULL FROM DUAL; +LOCATE(NULL, NULL) <=> NULL +1 +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a varchar(10), p varchar(10)); +INSERT INTO t1 VALUES (1, 'foo', 'o'); +INSERT INTO t1 VALUES (2, 'foo', NULL); +INSERT INTO t1 VALUES (3, NULL, 'o'); +INSERT INTO t1 VALUES (4, NULL, NULL); +SELECT id, LOCATE(a,p) FROM t1; +id LOCATE(a,p) +1 0 +2 NULL +3 NULL +4 NULL +SELECT id, LOCATE(a,p) IS NULL FROM t1; +id LOCATE(a,p) IS NULL +1 0 +2 1 +3 1 +4 1 +SELECT id, ISNULL(LOCATE(a,p)) FROM t1; +id ISNULL(LOCATE(a,p)) +1 0 +2 1 +3 1 +4 1 +SELECT id, LOCATE(a,p) <=> NULL FROM t1; +id LOCATE(a,p) <=> NULL +1 0 +2 1 +3 1 +4 1 +SELECT id FROM t1 WHERE LOCATE(a,p) IS NULL; +id +2 +3 +4 +SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL; +id +2 +3 +4 +DROP TABLE t1; +SELECT SUBSTR('foo',1,0) FROM DUAL; +SUBSTR('foo',1,0) + +SELECT SUBSTR('foo',1,CAST(0 AS SIGNED)) FROM DUAL; +SUBSTR('foo',1,CAST(0 AS SIGNED)) + +SELECT SUBSTR('foo',1,CAST(0 AS UNSIGNED)) FROM DUAL; +SUBSTR('foo',1,CAST(0 AS UNSIGNED)) + +CREATE TABLE t1 (a varchar(10), len int unsigned); +INSERT INTO t1 VALUES ('bar', 2), ('foo', 0); +SELECT SUBSTR(a,1,len) FROM t1; +SUBSTR(a,1,len) +ba + +DROP TABLE t1; +CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1; +SELECT HEX(c1) from t1; +HEX(c1) +414243 +DROP TABLE t1; +CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1; +SELECT HEX(c1) from v1; +HEX(c1) +414243 +DROP VIEW v1; +create table t1(a float); +insert into t1 values (1.33); +select format(a, 2) from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def format(a, 2) format(a, 2) 253 48 4 Y 0 0 8 +format(a, 2) +1.33 +drop table t1; +CREATE TABLE t1 (c DATE, aa VARCHAR(30)); +INSERT INTO t1 VALUES ('2008-12-31','aaaaaa'); +SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i FROM t1; +h i +31.12.2008 AAAAAA, aaaaaa +DROP TABLE t1; +# +# BUG#44774: load_file function produces valgrind warnings +# +CREATE TABLE t1 (a TINYBLOB); +INSERT INTO t1 VALUES ('aaaaaaaa'); +SELECT LOAD_FILE(a) FROM t1; +LOAD_FILE(a) +NULL +DROP TABLE t1; +CREATE TABLE t1 (f2 VARCHAR(20)); +CREATE TABLE t2 (f2 VARCHAR(20)); +INSERT INTO t1 VALUES ('MIN'),('MAX'); +INSERT INTO t2 VALUES ('LOAD'); +SELECT CONCAT_WS('_', (SELECT t2.f2 FROM t2), t1.f2) AS concat_name FROM t1; +concat_name +LOAD_MIN +LOAD_MAX +DROP TABLE t1, t2; +End of 5.0 tests +# +# Bug#52164 Assertion failed: param.sort_length, file .\filesort.cc, line 149 +# +CREATE TABLE t1 (a LONGBLOB NOT NULL); +INSERT INTO t1 VALUES (''),(''); +SELECT 1 FROM t1, t1 t2 +ORDER BY QUOTE(t1.a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug#57913 large negative number to string conversion functions crash +# Bug#57810 case/when/then : Assertion failed: length || !scale +# +SELECT '1' IN ('1', SUBSTRING(-9223372036854775809, 1)); +'1' IN ('1', SUBSTRING(-9223372036854775809, 1)) +1 +SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3)); +CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3)) +1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '' +# +# Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail +# and other crashes +# +CREATE TABLE t1 ( a TEXT ); +SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug58165.txt';; +SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' ); +insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' ) + +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'b' +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug58165.txt' INTO TABLE t1;; +SELECT * FROM t1; +a +aaaaaaaaaaaaaa +DROP TABLE t1; +# +# Bug#12634989 VALGRIND WARNING ABOUT UNINITIALIZED VALUES CREATED IN ITEM_FUNC_DAYOFMONTH +# +SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1))); +SUBSTRING('1', DAY(FROM_UNIXTIME(-1))) +NULL +SELECT LEFT('1', DAY(FROM_UNIXTIME(-1))); +LEFT('1', DAY(FROM_UNIXTIME(-1))) +NULL +SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1))); +RIGHT('1', DAY(FROM_UNIXTIME(-1))) +NULL +SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1))); +REPEAT('1', DAY(FROM_UNIXTIME(-1))) +NULL +SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?'); +RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') +NULL +SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?'); +LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') +NULL +CREATE TABLE t1 charset utf8mb4 +SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1))) AS f1, +LEFT('1', DAY(FROM_UNIXTIME(-1))) AS f2, +RIGHT('1', DAY(FROM_UNIXTIME(-1))) AS f3, +REPEAT('1', DAY(FROM_UNIXTIME(-1))) AS f4, +RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f5, +LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f6; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(1) CHARACTER SET latin1 DEFAULT NULL, + `f2` varchar(1) CHARACTER SET latin1 DEFAULT NULL, + `f3` varchar(1) CHARACTER SET latin1 DEFAULT NULL, + `f4` longtext CHARACTER SET latin1, + `f5` longtext CHARACTER SET latin1, + `f6` longtext CHARACTER SET latin1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug#11766684 59851: UNINITIALISED VALUE IN ITEM_FUNC_LIKE::SELECT_OPTIMIZE WITH SUBQUERY AND +# +CREATE TABLE t2(a INT, KEY(a)); +INSERT INTO t2 VALUES (1),(2); +CREATE TABLE t1(b INT, PRIMARY KEY(b)); +INSERT INTO t1 VALUES (0),(254); +SELECT 1 FROM t2 WHERE a LIKE +(SELECT EXPORT_SET(1, b, b, b, b) FROM t1 LIMIT 1); +1 +DROP TABLE t1, t2; +End of 5.1 tests +Start of 5.4 tests +SELECT format(12345678901234567890.123, 3); +format(12345678901234567890.123, 3) +12,345,678,901,234,567,890.123 +SELECT format(12345678901234567890.123, 3, NULL); +format(12345678901234567890.123, 3, NULL) +12,345,678,901,234,567,890.123 +Warnings: +Warning 1649 Unknown locale: 'NULL' +SELECT format(12345678901234567890.123, 3, 'ar_AE'); +format(12345678901234567890.123, 3, 'ar_AE') +12,345,678,901,234,567,890.123 +SELECT format(12345678901234567890.123, 3, 'ar_SA'); +format(12345678901234567890.123, 3, 'ar_SA') +12345678901234567890.123 +SELECT format(12345678901234567890.123, 3, 'be_BY'); +format(12345678901234567890.123, 3, 'be_BY') +12.345.678.901.234.567.890,123 +SELECT format(12345678901234567890.123, 3, 'de_DE'); +format(12345678901234567890.123, 3, 'de_DE') +12.345.678.901.234.567.890,123 +SELECT format(12345678901234567890.123, 3, 'en_IN'); +format(12345678901234567890.123, 3, 'en_IN') +1,23,45,67,89,01,23,45,67,890.123 +SELECT format(12345678901234567890.123, 3, 'en_US'); +format(12345678901234567890.123, 3, 'en_US') +12,345,678,901,234,567,890.123 +SELECT format(12345678901234567890.123, 3, 'it_CH'); +format(12345678901234567890.123, 3, 'it_CH') +12'345'678'901'234'567'890,123 +SELECT format(12345678901234567890.123, 3, 'ru_RU'); +format(12345678901234567890.123, 3, 'ru_RU') +12 345 678 901 234 567 890,123 +SELECT format(12345678901234567890.123, 3, 'ta_IN'); +format(12345678901234567890.123, 3, 'ta_IN') +1,23,45,67,89,01,23,45,67,890.123 +CREATE TABLE t1 (fmt CHAR(5) NOT NULL); +INSERT INTO t1 VALUES ('ar_AE'); +INSERT INTO t1 VALUES ('ar_SA'); +INSERT INTO t1 VALUES ('be_BY'); +INSERT INTO t1 VALUES ('de_DE'); +INSERT INTO t1 VALUES ('en_IN'); +INSERT INTO t1 VALUES ('en_US'); +INSERT INTO t1 VALUES ('it_CH'); +INSERT INTO t1 VALUES ('ru_RU'); +INSERT INTO t1 VALUES ('ta_IN'); +SELECT fmt, format(12345678901234567890.123, 3, fmt) FROM t1 ORDER BY fmt; +fmt format(12345678901234567890.123, 3, fmt) +ar_AE 12,345,678,901,234,567,890.123 +ar_SA 12345678901234567890.123 +be_BY 12.345.678.901.234.567.890,123 +de_DE 12.345.678.901.234.567.890,123 +en_IN 1,23,45,67,89,01,23,45,67,890.123 +en_US 12,345,678,901,234,567,890.123 +it_CH 12'345'678'901'234'567'890,123 +ru_RU 12 345 678 901 234 567 890,123 +ta_IN 1,23,45,67,89,01,23,45,67,890.123 +SELECT fmt, format(12345678901234567890.123, 0, fmt) FROM t1 ORDER BY fmt; +fmt format(12345678901234567890.123, 0, fmt) +ar_AE 12,345,678,901,234,567,890 +ar_SA 12345678901234567890 +be_BY 12.345.678.901.234.567.890 +de_DE 12.345.678.901.234.567.890 +en_IN 1,23,45,67,89,01,23,45,67,890 +en_US 12,345,678,901,234,567,890 +it_CH 12'345'678'901'234'567'890 +ru_RU 12 345 678 901 234 567 890 +ta_IN 1,23,45,67,89,01,23,45,67,890 +SELECT fmt, format(12345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; +fmt format(12345678901234567890, 3, fmt) +ar_AE 12,345,678,901,234,567,890.000 +ar_SA 12345678901234567890.000 +be_BY 12.345.678.901.234.567.890,000 +de_DE 12.345.678.901.234.567.890,000 +en_IN 1,23,45,67,89,01,23,45,67,890.000 +en_US 12,345,678,901,234,567,890.000 +it_CH 12'345'678'901'234'567'890,000 +ru_RU 12 345 678 901 234 567 890,000 +ta_IN 1,23,45,67,89,01,23,45,67,890.000 +SELECT fmt, format(-12345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; +fmt format(-12345678901234567890, 3, fmt) +ar_AE -12,345,678,901,234,567,890.000 +ar_SA -12345678901234567890.000 +be_BY -12.345.678.901.234.567.890,000 +de_DE -12.345.678.901.234.567.890,000 +en_IN -1,23,45,67,89,01,23,45,67,890.000 +en_US -12,345,678,901,234,567,890.000 +it_CH -12'345'678'901'234'567'890,000 +ru_RU -12 345 678 901 234 567 890,000 +ta_IN -1,23,45,67,89,01,23,45,67,890.000 +SELECT fmt, format(-02345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; +fmt format(-02345678901234567890, 3, fmt) +ar_AE -2,345,678,901,234,567,890.000 +ar_SA -2345678901234567890.000 +be_BY -2.345.678.901.234.567.890,000 +de_DE -2.345.678.901.234.567.890,000 +en_IN -23,45,67,89,01,23,45,67,890.000 +en_US -2,345,678,901,234,567,890.000 +it_CH -2'345'678'901'234'567'890,000 +ru_RU -2 345 678 901 234 567 890,000 +ta_IN -23,45,67,89,01,23,45,67,890.000 +SELECT fmt, format(-00345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; +fmt format(-00345678901234567890, 3, fmt) +ar_AE -345,678,901,234,567,890.000 +ar_SA -345678901234567890.000 +be_BY -345.678.901.234.567.890,000 +de_DE -345.678.901.234.567.890,000 +en_IN -3,45,67,89,01,23,45,67,890.000 +en_US -345,678,901,234,567,890.000 +it_CH -345'678'901'234'567'890,000 +ru_RU -345 678 901 234 567 890,000 +ta_IN -3,45,67,89,01,23,45,67,890.000 +SELECT fmt, format(-00045678901234567890, 3, fmt) FROM t1 ORDER BY fmt; +fmt format(-00045678901234567890, 3, fmt) +ar_AE -45,678,901,234,567,890.000 +ar_SA -45678901234567890.000 +be_BY -45.678.901.234.567.890,000 +de_DE -45.678.901.234.567.890,000 +en_IN -45,67,89,01,23,45,67,890.000 +en_US -45,678,901,234,567,890.000 +it_CH -45'678'901'234'567'890,000 +ru_RU -45 678 901 234 567 890,000 +ta_IN -45,67,89,01,23,45,67,890.000 +DROP TABLE t1; +SELECT format(123, 1, 'Non-existent-locale'); +format(123, 1, 'Non-existent-locale') +123.0 +Warnings: +Warning 1649 Unknown locale: 'Non-existent-locale' +End of 5.4 tests +# +# Start of 5.5 tests +# +# +# Bug#55912 FORMAT with locale set fails for numbers < 1000 +# +SELECT FORMAT(123.33, 2, 'no_NO'), FORMAT(1123.33, 2, 'no_NO'); +FORMAT(123.33, 2, 'no_NO') FORMAT(1123.33, 2, 'no_NO') +123,33 1.123,33 +SELECT FORMAT(12333e-2, 2, 'no_NO'), FORMAT(112333e-2, 2, 'no_NO'); +FORMAT(12333e-2, 2, 'no_NO') FORMAT(112333e-2, 2, 'no_NO') +123,33 1.123,33 +CREATE TABLE t1 charset utf8mb4 AS SELECT format(123,2,'no_NO'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `format(123,2,'no_NO')` varchar(36) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +format(123,2,'no_NO') +123,00 +DROP TABLE t1; +# +# Bug#11764310 conv function crashes, negative argument to memcpy +# +SELECT CONV(1,-2147483648,-2147483648); +CONV(1,-2147483648,-2147483648) +NULL +# +# Bug#12985030 SIMPLE QUERY WITH DECIMAL NUMBERS LEAKS MEMORY +# +SELECT (rpad(1.0,2048,1)) IS NOT FALSE; +(rpad(1.0,2048,1)) IS NOT FALSE +1 +SELECT ((+0) IN +((0b111111111111111111111111111111111111111111111111111),(rpad(1.0,2048,1)), +(32767.1))); +((+0) IN +((0b111111111111111111111111111111111111111111111111111),(rpad(1.0,2048,1)), +(32767.1))) +0 +SELECT ((rpad(1.0,2048,1)) = ('4(') ^ (0.1)); +((rpad(1.0,2048,1)) = ('4(') ^ (0.1)) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '4(' +SELECT +pow((rpad(10.0,2048,1)),(b'1111111111111111111111111111111111111111111')); +ERROR 22003: DOUBLE value is out of range in 'pow(rpad(10.0,2048,1),0x07ffffffffff)' +SELECT ((rpad(1.0,2048,1)) + (0) ^ ('../')); +((rpad(1.0,2048,1)) + (0) ^ ('../')) +1.011111111111111 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '../' +SELECT stddev_samp(rpad(1.0,2048,1)); +stddev_samp(rpad(1.0,2048,1)) +NULL +SELECT ((127.1) not in ((rpad(1.0,2048,1)),(''),(-1.1))); +((127.1) not in ((rpad(1.0,2048,1)),(''),(-1.1))) +1 +SELECT ((0xf3) * (rpad(1.0,2048,1)) << (0xcc)); +((0xf3) * (rpad(1.0,2048,1)) << (0xcc)) +0 +# +# Bug#13359121 LARGE NUMBERS, /STRINGS/DTOA.C:662: +# BALLOC: ASSERTION `K <= 15' FAILED. +# Bug#12985021 SIMPLE QUERY WITH DECIMAL NUMBERS TAKE AN +# EXTRAORDINARY LONG TIME TO EXECUTE +SELECT @tmp_max:= @@global.max_allowed_packet; +@tmp_max:= @@global.max_allowed_packet +67108864 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SET @@global.max_allowed_packet=1024*1024*1024; +SELECT @@global.max_allowed_packet; +@@global.max_allowed_packet +1073741824 +do +format(rpad('111111111.1', +1111111, +'999999999999999999999999999999999999999999'),0,'be_BY') +; +DO +round( +concat( ( +coalesce( ( +ST_linefromwkb('2147483648', +-b'1111111111111111111111111111111111111111111')), +( convert('[.DC2.]',decimal(30,30)) ), +bit_count('') +) ), +( lpad( ( elt('01','}:K5')), +sha1('P'), +( ( select '-9223372036854775808.1' > all (select ''))) +) +) +) +); +ERROR 22003: SRID value is out of range in 'st_linefromwkb' +SET @@global.max_allowed_packet:= @tmp_max; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#5510 Functions to_base64 and from_base64 +# +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',63)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(85) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh +YWFhYWFh 85 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(63) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 63 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',62)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(85) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh +YWFhYWE= 85 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(63) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 62 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',61)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(85) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh +YWFhYQ== 85 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(63) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 61 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',60)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(81) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh +YWFh 81 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(60) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 60 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',59)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(81) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh +YWE= 81 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(60) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 59 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',58)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(81) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh +YQ== 81 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(60) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 58 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',57)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(76) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 76 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(57) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 57 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',56)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(76) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 76 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(57) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 56 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',55)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(76) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 76 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(57) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 55 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',54)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(72) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 72 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(54) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 54 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',53)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(72) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 72 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(54) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 53 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',52)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(72) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 72 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(54) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 52 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',51)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(68) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 68 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(51) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 51 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',50)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(68) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 68 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(51) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 50 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',49)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(68) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 68 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(51) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 49 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',48)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(64) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 64 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(48) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 48 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',47)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(64) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 64 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(48) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 47 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',46)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(64) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 64 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(48) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 46 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',45)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(60) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 60 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(45) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 45 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',44)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(60) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 60 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(45) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 44 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',43)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(60) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 60 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(45) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 43 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',42)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(56) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 56 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(42) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 42 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',41)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(56) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 56 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(42) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 41 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',40)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(56) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 56 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(42) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 40 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',39)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(52) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 52 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(39) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 39 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',38)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(52) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 52 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(39) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 38 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',37)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(52) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 52 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(39) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 37 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',36)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(48) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 48 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(36) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 36 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',35)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(48) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 48 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(36) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 35 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',34)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(48) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 48 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(36) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 34 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',33)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(44) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 44 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(33) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 33 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',32)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(44) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 44 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(33) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 32 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',31)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(44) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 44 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(33) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 31 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',30)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(40) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 40 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 30 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',29)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(40) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 40 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaa 29 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',28)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(40) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 40 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaaa 28 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',27)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(36) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 36 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(27) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaaa 27 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',26)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(36) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 36 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(27) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaaa 26 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',25)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(36) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 36 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(27) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaaa 25 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',24)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(32) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh 32 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(24) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaaa 24 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',23)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(32) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE= 32 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(24) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaaa 23 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',22)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(32) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ== 32 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(24) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaaa 22 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',21)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(28) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWFh 28 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaaa 21 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',20)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(28) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYWE= 28 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaaa 20 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',19)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(28) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFhYQ== 28 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(21) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaaa 19 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',18)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(24) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWFh 24 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(18) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaaa 18 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',17)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(24) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYWE= 24 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(18) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaaa 17 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',16)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(24) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFhYQ== 24 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(18) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaaa 16 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',15)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(20) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWFh 20 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(15) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaaa 15 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',14)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(20) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYWE= 20 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(15) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaaa 14 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',13)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(20) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFhYQ== 20 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(15) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaaa 13 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',12)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(16) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWFh 16 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(12) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaaa 12 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',11)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(16) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYWE= 16 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(12) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaaa 11 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',10)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(16) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFhYQ== 16 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(12) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaaa 10 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',9)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(12) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWFh 12 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(9) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaaa 9 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',8)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(12) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYWE= 12 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(9) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaaa 8 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',7)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(12) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFhYQ== 12 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(9) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaaa 7 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',6)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(8) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWFh 8 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaaa 6 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',5)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(8) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYWE= 8 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaaa 5 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',4)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(8) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFhYQ== 8 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaaa 4 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',3)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(4) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWFh 4 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aaa 3 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',2)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(4) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YWE= 4 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +aa 2 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',1)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` varchar(4) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) +YQ== 4 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` varbinary(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) +a 1 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 charset utf8mb4 AS SELECT TO_BASE64(REPEAT('a',0)) AS to_base64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `to_base64` char(0) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT to_base64, LENGTH(to_base64) FROM t1; +to_base64 LENGTH(to_base64) + 0 +CREATE TABLE t2 charset utf8mb4 AS SELECT from_base64(to_base64) AS from_base64 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `from_base64` binary(0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT from_base64, LENGTH(from_base64) FROM t2; +from_base64 LENGTH(from_base64) + 0 +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 (a VARBINARY(64)); +INSERT INTO t1 VALUES (0x00), (0x0000), (0x000000), (0x00000000); +INSERT INTO t1 VALUES (0x00010203040506070809); +SELECT TO_BASE64(a), hex(a) FROM t1 ORDER BY a; +TO_BASE64(a) hex(a) +AA== 00 +AAA= 0000 +AAAA 000000 +AAAAAA== 00000000 +AAECAwQFBgcICQ== 00010203040506070809 +DROP TABLE t1; +# +# Test NULL output for NULL input +# +SELECT TO_BASE64(NULL); +TO_BASE64(NULL) +NULL +SELECT FROM_BASE64(NULL); +FROM_BASE64(NULL) +NULL +# +# RFC4648 test vectors +# +SELECT @b:= TO_BASE64(''), FROM_BASE64(@b); +@b:= TO_BASE64('') FROM_BASE64(@b) + +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @b:= TO_BASE64('f'), FROM_BASE64(@b); +@b:= TO_BASE64('f') FROM_BASE64(@b) +Zg== f +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @b:= TO_BASE64('fo'), FROM_BASE64(@b); +@b:= TO_BASE64('fo') FROM_BASE64(@b) +Zm8= fo +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @b:= TO_BASE64('foo'), FROM_BASE64(@b); +@b:= TO_BASE64('foo') FROM_BASE64(@b) +Zm9v foo +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @b:= TO_BASE64('foob'), FROM_BASE64(@b); +@b:= TO_BASE64('foob') FROM_BASE64(@b) +Zm9vYg== foob +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @b:= TO_BASE64('fooba'), FROM_BASE64(@b); +@b:= TO_BASE64('fooba') FROM_BASE64(@b) +Zm9vYmE= fooba +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @b:= TO_BASE64('foobar'), FROM_BASE64(@b); +@b:= TO_BASE64('foobar') FROM_BASE64(@b) +Zm9vYmFy foobar +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Invalid characters - return NULL +# +SELECT hex(FROM_BASE64('#')); +hex(FROM_BASE64('#')) +NULL +SELECT hex(FROM_BASE64('A#')); +hex(FROM_BASE64('A#')) +NULL +SELECT hex(FROM_BASE64('AB#')); +hex(FROM_BASE64('AB#')) +NULL +SELECT hex(FROM_BASE64('ABC#')); +hex(FROM_BASE64('ABC#')) +NULL +SELECT hex(FROM_BASE64('ABCD#')); +hex(FROM_BASE64('ABCD#')) +NULL +# +# "=" is not valid on the first and second positions of a quadruple +# +SELECT hex(FROM_BASE64('=')); +hex(FROM_BASE64('=')) +NULL +SELECT hex(FROM_BASE64('A=')); +hex(FROM_BASE64('A=')) +NULL +SELECT hex(FROM_BASE64('ABCD=')); +hex(FROM_BASE64('ABCD=')) +NULL +SELECT hex(FROM_BASE64('ABCDE=')); +hex(FROM_BASE64('ABCDE=')) +NULL +# +# Incomplete sequences - return NULL +# +SELECT hex(FROM_BASE64('A')); +hex(FROM_BASE64('A')) +NULL +SELECT hex(FROM_BASE64('AB')); +hex(FROM_BASE64('AB')) +NULL +SELECT hex(FROM_BASE64('ABC')); +hex(FROM_BASE64('ABC')) +NULL +# +# Unexpected input after pad characters - return NULL +# +SELECT hex(FROM_BASE64('AAA=x')); +hex(FROM_BASE64('AAA=x')) +NULL +SELECT hex(FROM_BASE64('AA==x')); +hex(FROM_BASE64('AA==x')) +NULL +# +# Delimiters are allowed at any position +# +SELECT hex(FROM_BASE64(' A B C D ')); +hex(FROM_BASE64(' A B C D ')) +001083 +SELECT hex(FROM_BASE64(' A A = = ')); +hex(FROM_BASE64(' A A = = ')) +00 +SELECT hex(FROM_BASE64(' A A A = ')); +hex(FROM_BASE64(' A A A = ')) +0000 +SELECT hex(FROM_BASE64(' A \n B \r C \t D ')); +hex(FROM_BASE64(' A \n B \r C \t D ')) +001083 +# +# Testing that to_base64 respects max_allowed_packet +# +SELECT LENGTH(TO_BASE64(REPEAT('a', @@max_allowed_packet-10))); +LENGTH(TO_BASE64(REPEAT('a', @@max_allowed_packet-10))) +NULL +Warnings: +Warning 1301 Result of to_base64() was larger than max_allowed_packet (67108864) - truncated +# +# Testing base64 with various data types +# +CREATE TABLE t1 ( +i1 INT, +f1 FLOAT, +dc1 DECIMAL(10,5), +e1 ENUM('enum11','enum12','enum13'), +s1 SET('set1','set2','set3'), +t1 TIME, +d1 DATE, +dt1 DATETIME +); +INSERT INTO t1 VALUES +(-12345, -456.789, 123.45, 'enum13', 'set1,set3', +'01:02:03', '2010-01-01', '2011-01-01 02:03:04'); +SELECT FROM_BASE64(TO_BASE64(i1)) FROM t1; +FROM_BASE64(TO_BASE64(i1)) +-12345 +SELECT FROM_BASE64(TO_BASE64(f1)) FROM t1; +FROM_BASE64(TO_BASE64(f1)) +-456.789 +SELECT FROM_BASE64(TO_BASE64(dc1)) FROM t1; +FROM_BASE64(TO_BASE64(dc1)) +123.45000 +SELECT FROM_BASE64(TO_BASE64(e1)) FROM t1; +FROM_BASE64(TO_BASE64(e1)) +enum13 +SELECT FROM_BASE64(TO_BASE64(s1)) FROM t1; +FROM_BASE64(TO_BASE64(s1)) +set1,set3 +SELECT FROM_BASE64(TO_BASE64(t1)) FROM t1; +FROM_BASE64(TO_BASE64(t1)) +01:02:03 +SELECT FROM_BASE64(TO_BASE64(d1)) FROM t1; +FROM_BASE64(TO_BASE64(d1)) +2010-01-01 +SELECT FROM_BASE64(TO_BASE64(dt1)) FROM t1; +FROM_BASE64(TO_BASE64(dt1)) +2011-01-01 02:03:04 +DROP TABLE t1; +# +# Bug#11765562 58545: +# EXPORT_SET() CAN BE USED TO MAKE ENTIRE SERVER COMPLETELY UNRESPONSIVE +# +SELECT @tmp_max:= @@global.max_allowed_packet; +@tmp_max:= @@global.max_allowed_packet +67108864 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SET @@global.max_allowed_packet=1024*1024*1024; +SELECT @@global.max_allowed_packet; +@@global.max_allowed_packet +1073741824 +SELECT CHAR_LENGTH(EXPORT_SET(1,1,1,REPEAT(1,100000000))); +CHAR_LENGTH(EXPORT_SET(1,1,1,REPEAT(1,100000000))) +NULL +Warnings: +Warning 1301 Result of export_set() was larger than max_allowed_packet (1073741824) - truncated +SET @@global.max_allowed_packet:= @tmp_max; +SELECT SPACE(@@global.max_allowed_packet*2); +SPACE(@@global.max_allowed_packet*2) +NULL +Warnings: +Warning 1301 Result of space() was larger than max_allowed_packet (67108864) - truncated +SET NAMES latin1; +PREPARE stmt FROM "SELECT COLLATION(space(2))"; +EXECUTE stmt; +COLLATION(space(2)) +latin1_swedish_ci +SET NAMES latin2; +EXECUTE stmt; +COLLATION(space(2)) +latin1_swedish_ci +# +# Bug#11829861: SUBSTRING_INDEX() RESULTS IN MISSING CHARACTERS WHEN USED +# INSIDE LOWER() +# +SET @user_at_host = 'root@mytinyhost-PC.local'; +SELECT LOWER(SUBSTRING_INDEX(@user_at_host, '@', -1)); +LOWER(SUBSTRING_INDEX(@user_at_host, '@', -1)) +mytinyhost-pc.local +# End of test BUG#11829861 +# +# Bug#42404: SUBSTRING_INDEX() RESULTS ARE INCONSISTENT +# +CREATE TABLE t (i INT NOT NULL, c CHAR(255) NOT NULL); +INSERT INTO t VALUES (0,'.www.mysql.com'),(1,'.wwwmysqlcom'); +SELECT i, SUBSTRING_INDEX(c, '.', -2) FROM t WHERE i = 1; +i SUBSTRING_INDEX(c, '.', -2) +1 .wwwmysqlcom +SELECT i, SUBSTRING_INDEX(c, '.', -2) FROM t; +i SUBSTRING_INDEX(c, '.', -2) +0 mysql.com +1 .wwwmysqlcom +DROP TABLE t; +# End of test BUG#42404 +# +# Bug#13812875 ILLEGAL MIX OF COLLATIONS WITH FUNCTIONS THAT USED TO WORK +# +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 (a varchar(1)); +SELECT * FROM t1 WHERE a=md5('a'); +a +SELECT * FROM t1 WHERE a=hex('a'); +a +SELECT * FROM t1 WHERE a=to_base64('a'); +a +DROP TABLE t1; +SET NAMES latin1; +# +# Bug #11765149 DUPLICATE ENTRY ERROR WHEN DOING GROUP BY +# +create table t1(a varchar(20)); +insert into t1 values(''), (' '), ('xxxxxxxxxxxxxxx'); +create table t2(a int); +insert into t2 values(0),(0),(1),(0),(10),(-2),(30),(NULL); +select t1.a as str, length(t1.a) as str_length, t2.a as pos, t2.a + 10 as length, insert(t1.a, t2.a, t2.a + 10, '1234567') as 'insert' from t1, t2; +str str_length pos length insert + 0 -2 8 + 0 0 10 + 0 0 10 + 0 0 10 + 0 1 11 + 0 10 20 + 0 30 40 + 0 NULL NULL NULL + 1 -2 8 + 1 0 10 + 1 0 10 + 1 0 10 + 1 1 11 1234567 + 1 10 20 + 1 30 40 + 1 NULL NULL NULL +xxxxxxxxxxxxxxx 15 -2 8 xxxxxxxxxxxxxxx +xxxxxxxxxxxxxxx 15 0 10 xxxxxxxxxxxxxxx +xxxxxxxxxxxxxxx 15 0 10 xxxxxxxxxxxxxxx +xxxxxxxxxxxxxxx 15 0 10 xxxxxxxxxxxxxxx +xxxxxxxxxxxxxxx 15 1 11 1234567xxxx +xxxxxxxxxxxxxxx 15 10 20 xxxxxxxxx1234567 +xxxxxxxxxxxxxxx 15 30 40 xxxxxxxxxxxxxxx +xxxxxxxxxxxxxxx 15 NULL NULL NULL +drop table t1,t2; +# +# Bug #19174480: INSERT STRING FUNCTIONS RECENTLY CRASHING +# +CREATE TABLE t1(a TIMESTAMP(5)) ENGINE=INNODB; +INSERT INTO t1 VALUES('1978-01-03 00:00:00'),('2000-001-02 00:00:00'); +SELECT 1 FROM t1 GROUP BY insert(a,'1','11','1'); +1 +1 +SELECT insert(a,1,1,1) FROM t1; +insert(a,1,1,1) +1978-01-03 00:00:00.00000 +1000-01-02 00:00:00.00000 +DROP TABLE t1; +# +# Bug#22888420 CONCAT_WS: ASSERTION FAILED: !S.USES_BUFFER_OWNED_BY(THIS) +# +do concat('a',concat_ws('a', 0x2859, 'a' , +trim(period_add('a',1) from (1&'')) +) +); +ERROR HY000: Incorrect arguments to period_add +# +# End of 5.6 tests +# +# +# Bug#19646643 REPEAT() WASTES CPU TIME ON LARGE INPUT VALUES +# THAT GAURANTEE EMPTY RESULT +# +SET @@global.max_allowed_packet=1024*1024; +connect newconn, localhost, root,,; +select length(repeat("",1)) as a; +a +0 +select length(repeat("",1024*1024*1024)) as a; +a +0 +select length(repeat("1",1024*1024)) as a; +a +1048576 +select length(repeat("1",1024*1024*1024)) as a; +a +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated +disconnect newconn; +connection default; +SET @@global.max_allowed_packet:= DEFAULT; +# +# Bug#20316028 RPAD + UTF16 ON X86 BUILD RUNNING ON WIN64 STACK +# EXPLOITABLE +do rpad(_utf16"33",1073741826,_latin1"44"); +Warnings: +Warning 1301 Result of rpad() was larger than max_allowed_packet (67108864) - truncated +# +# Bug#13740934 ASSERTION FAILED: ARGS[0]->FIXED ITEM_FUNC_CONV_CHARSET::ITEM_FUNC_CONV_CHARSET +# +CREATE TABLE t1(a TIME); +INSERT INTO t1 VALUES (); +SELECT (SELECT (SELECT 1 FROM t1 a WHERE t1.a <_ucs2'a')) AS d5 FROM t1 GROUP BY 1; +d5 +NULL +Warnings: +Warning 1292 Incorrect time value: 'a' for column 'a' at row 1 +DROP TABLE t1; +# +# Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +# +SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data; +data +131072 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT length(data) AS len FROM ( +SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data +) AS sub; +len +131072 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data; +data +131070 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT length(data) AS len FROM ( +SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data +) AS sub; +len +131070 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data; +data +65532 +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub; +len +65532 +SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data; +data +65538 +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub; +len +65538 +# +# Bug #22884187 RTRIM GETS EXPONENTIALLY SLOWER ON LARGE STRINGS +# +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT TRIM(BOTH 'å' FROM 'aæaå'); +TRIM(BOTH 'å' FROM 'aæaå') +aæa +set names default; +SELECT HEX(TRIM(CONVERT(_gb18030 0x20202081408141208144202020 USING utf32))); +HEX(TRIM(CONVERT(_gb18030 0x20202081408141208144202020 USING utf32))) +00004E0200004E040000002000004E0F +# +# Bug#21447969 FILTER USING TRIM RESULTS IN CORRECT +# +CREATE TABLE t1 (COUNTRY char(100)); +INSERT INTO t1 VALUES ("Norway"), ("Australia"); +SELECT COUNTRY FROM t1 +WHERE trim(leading 'A' FROM COUNTRY) = 'ustralia'; +COUNTRY +Australia +SELECT COUNTRY FROM t1 +WHERE trim(trailing 'a' FROM COUNTRY)= 'Australi'; +COUNTRY +Australia +SELECT COUNTRY FROM t1 +WHERE trim(leading 'A' FROM COUNTRY) = 'ustralia' +AND trim(trailing 'a' FROM COUNTRY) = 'Australi'; +COUNTRY +Australia +DROP TABLE t1; +# +# Bug#22391186 TRUE WHERE CLAUSE DOESN'T RETURN EXPECTED ROW, +# BUT EMPTY SET +# +CREATE DATABASE testt CHARACTER SET utf8mb4; +USE testt; +SET NAMES 'utf8mb4'; +CREATE TABLE t1(c1 CHAR(20)); +INSERT INTO t1 VALUES('11'); +SELECT c1 <= REPEAT( SUBSTR( UPPER('Rdlpikti') , 1 , 2 ), 8 ) FROM t1; +c1 <= REPEAT( SUBSTR( UPPER('Rdlpikti') , 1 , 2 ), 8 ) +1 +SELECT * FROM t1 WHERE c1 <= REPEAT( SUBSTR( UPPER('Rdlpikti') , 1 , 2 ), 8); +c1 +11 +SELECT * FROM t1 WHERE c1 <= REPEAT( SUBSTR( UPPER('Rdlpikti') , 1 , 2 ), 8); +c1 +11 +DROP TABLE t1; +DROP DATABASE testt; +SET NAMES DEFAULT; +USE test; +# +# Bug#22297983 HEX() FUNCTION CONVERTS DECIMAL TO DOUBLE AND +# THUS RETURNS WRONG RESULT +# +select hex(cast(9007199254740992 as decimal(30,0))); +hex(cast(9007199254740992 as decimal(30,0))) +20000000000000 +select hex(cast(9007199254740993 as decimal(30,0))); +hex(cast(9007199254740993 as decimal(30,0))) +20000000000001 +select hex(cast(9007199254740994 as decimal(30,0))); +hex(cast(9007199254740994 as decimal(30,0))) +20000000000002 +select hex(cast(0x20000000000000 as unsigned) + 1); +hex(cast(0x20000000000000 as unsigned) + 1) +20000000000001 +select hex(cast(0x20000000000000 as decimal(30,0)) + 1); +hex(cast(0x20000000000000 as decimal(30,0)) + 1) +20000000000001 +select hex(cast(0x20000000000000 as decimal(30,0)) + 2); +hex(cast(0x20000000000000 as decimal(30,0)) + 2) +20000000000002 +# +# Bug#22523836 FUNCTION REPLACE WITH BINARY OP DOESNT RETURN EXPECTED +# NULL, WITH PARAM AS NULL +# +SELECT REPLACE( 'a', binary 'b', NULL ) as xxx; +xxx +NULL +SELECT REPLACE( 'a', binary '', NULL ) as xxx; +xxx +NULL +SELECT REPLACE( 'a', 'b', NULL ) as xxx; +xxx +NULL +SELECT REPLACE( 'a', '', NULL ) as xxx; +xxx +NULL +SELECT REPLACE( NULL, 'b', 'bravo' ) as xxx; +xxx +NULL +SELECT REPLACE( NULL, '', 'bravo' ) as xxx; +xxx +NULL +SELECT REPLACE( 'a', NULL, 'bravo' ) as xxx; +xxx +NULL +SELECT REPLACE( 'a', binary NULL, 'bravo' ) as xxx; +xxx +NULL +# +# Bug#22565155 DATA ROWS LOST AFTER ADDING DISTINCT WITH +# SUBSTR() IN SELECT LIST +# +CREATE TABLE t1(c1 CHAR(30)); +INSERT INTO t1 VALUES('111'),('222'); +SELECT DISTINCT substr(c1, 1, 2147483647) FROM t1; +substr(c1, 1, 2147483647) +111 +222 +SELECT DISTINCT substr(c1, 1, 2147483648) FROM t1; +substr(c1, 1, 2147483648) +111 +222 +SELECT DISTINCT substr(c1, -1, 2147483648) FROM t1; +substr(c1, -1, 2147483648) +1 +2 +SELECT DISTINCT substr(c1, -2147483647, 2147483648) FROM t1; +substr(c1, -2147483647, 2147483648) + +SELECT DISTINCT substr(c1, 9223372036854775807, 23) FROM t1; +substr(c1, 9223372036854775807, 23) + +SELECT DISTINCT left(c1, 3) FROM t1; +left(c1, 3) +111 +222 +SELECT DISTINCT left(c1, 2147483647) FROM t1; +left(c1, 2147483647) +111 +222 +SELECT DISTINCT left(c1, 2147483648) FROM t1; +left(c1, 2147483648) +111 +222 +SELECT DISTINCT right(c1, 3) FROM t1; +right(c1, 3) +111 +222 +SELECT DISTINCT right(c1, 2147483647) FROM t1; +right(c1, 2147483647) +111 +222 +SELECT DISTINCT right(c1, 2147483648) FROM t1; +right(c1, 2147483648) +111 +222 +DROP TABLE t1; +# +# Bug#22545429 FUNC SUBSTRING_INDEX WORKS INCORRECTLY +# WHEN THE COUNT PARAM IS A BIGINT UNSIGNED +# +SELECT SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775807 ); +SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775807 ) +xyz +SELECT SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775808 ); +SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775808 ) +xyz +SELECT SUBSTRING_INDEX( 'xyz', 'abc', 18446744073709551615 ); +SUBSTRING_INDEX( 'xyz', 'abc', 18446744073709551615 ) +xyz +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775807 ); +SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775807 ) +xyz +SELECT SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775808 ); +SUBSTRING_INDEX( 'xyz', 'abc', 9223372036854775808 ) +xyz +SELECT SUBSTRING_INDEX( 'xyz', 'abc', 18446744073709551615 ); +SUBSTRING_INDEX( 'xyz', 'abc', 18446744073709551615 ) +xyz +SELECT SUBSTRING_INDEX('www.mysql.com', '.', 1); +SUBSTRING_INDEX('www.mysql.com', '.', 1) +www +SELECT SUBSTRING_INDEX('www.mysql.com', '.', -1); +SUBSTRING_INDEX('www.mysql.com', '.', -1) +com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', 100); +SUBSTRING_INDEX('www.mysql.com', '.', 100) +www.mysql.com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', -100); +SUBSTRING_INDEX('www.mysql.com', '.', -100) +www.mysql.com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2147483647); +SUBSTRING_INDEX('www.mysql.com', '.', 2147483647) +www.mysql.com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2147483647); +SUBSTRING_INDEX('www.mysql.com', '.', -2147483647) +www.mysql.com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2147483648); +SUBSTRING_INDEX('www.mysql.com', '.', 2147483648) +www.mysql.com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2147483648); +SUBSTRING_INDEX('www.mysql.com', '.', -2147483648) +www.mysql.com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2147483649); +SUBSTRING_INDEX('www.mysql.com', '.', 2147483649) +www.mysql.com +SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2147483649); +SUBSTRING_INDEX('www.mysql.com', '.', -2147483649) +www.mysql.com +set names default; +# +# Bug#22882717 "BIN", "OCT" FUNCTION LEADS TO MANY VALGRIND ERRORS +# +SELECT BIN(MID(REPEAT('b',64),21,229)); +BIN(MID(REPEAT('b',64),21,229)) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' +SELECT BIN(MID(1.051098E+308,9,99)); +BIN(MID(1.051098E+308,9,99)) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'e308' +SELECT BIN(RIGHT(REPEAT('b',64),30)); +BIN(RIGHT(REPEAT('b',64),30)) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' +SELECT BIN(SUBSTRING(REPEAT('b',64),9)); +BIN(SUBSTRING(REPEAT('b',64),9)) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' +SELECT OCT(LEFT(REPEAT('b',64),15)); +OCT(LEFT(REPEAT('b',64),15)) +0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'bbbbbbbbbbbbbbb' +# +# Bug#22900560 CAST .. AS BINARY.. HEAP-USE-AFTER-FREE FROM ASAN +# +do +from_base64(aes_encrypt(right(cast((0x5d44f4d736397d92c8267c12)as decimal),1), +rand(to_days('2028-12-04 15:50:01.284969')))); +Warnings: +Warning 1292 Truncated incorrect BINARY value: 'x'5d44f4d736397d92c8267c12'' +Warning 1264 Out of range value for column '(null)' at row 1 +do from_base64(cast(right(11,1)as binary(24))); +do convert(inet_aton(cast(left(-1,1)as binary(30))) using utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1411 Incorrect string value: 'cast(left(-(1),1) as char(30) charset binary)' for function inet_aton +do from_base64(cast((left(collation(4097),((repeat('1',32))or((-18772))))) +as binary(40))); +do from_base64(cast((mid(17653,row('-688:20:12.162697',(null)) >= +row(('*.)$'),(0xc254b6)),1))as binary(34))); +do from_base64(cast((mid(uuid(),20,64)) as binary(55))); +set @e:=_latin1'77'; +do inet_aton(aes_encrypt(left(@e,1),5)); +Warnings: +Warning 1411 Incorrect string value: 'aes_encrypt(left((@`e`),1),5)' for function inet_aton +# +# Bug#23194118 WEIGHT_STRING: ASSERTION FAILED: +# SRC, FILE .\STRINGS\CTYPE-UTF8.CC, LINE 8686 +# +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t(a INT) engine=innodb; +INSERT INTO t VALUES(1); +SELECT 1 FROM t WHERE WEIGHT_STRING(CONCAT_WS('1','')); +1 +SELECT 1 FROM t WHERE WEIGHT_STRING(CONCAT('','')); +1 +SET NAMES DEFAULT; +DROP TABLE t; +# +# Bug#24376444 USING COLLATE IN WHERE CLAUSE PREVENTS OPTIMIZER FROM +# CONSIDERING INDEXES +CREATE TABLE dd_table (name VARCHAR(64) COLLATE utf8_tolower_ci, UNIQUE KEY(name)); +Warnings: +Warning 3778 'utf8_tolower_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO dd_table VALUES('t1'), ('t2'); +CREATE VIEW view1 AS SELECT name AS table_name FROM dd_table; +CREATE VIEW view2 AS SELECT name COLLATE utf8_tolower_ci AS table_name FROM dd_table; +CREATE PROCEDURE sub1(id CHAR(10) CHARACTER SET utf8) +BEGIN +SELECT * FROM view1 WHERE table_name=id COLLATE utf8_tolower_ci; +EXPLAIN SELECT * FROM view1 WHERE table_name=id COLLATE utf8_tolower_ci; +SELECT * FROM view2 WHERE table_name=id; +EXPLAIN SELECT * FROM view2 WHERE table_name=id; +SELECT * FROM dd_table WHERE name COLLATE utf8_tolower_ci = id; +EXPLAIN SELECT * FROM dd_table WHERE name COLLATE utf8_tolower_ci = id; +SELECT * FROM view1 WHERE id COLLATE utf8_tolower_ci=table_name; +EXPLAIN SELECT * FROM view1 WHERE id COLLATE utf8_tolower_ci=table_name; +SELECT * FROM view2 WHERE id=table_name; +EXPLAIN SELECT * FROM view2 WHERE id=table_name; +SELECT * FROM dd_table WHERE id = name COLLATE utf8_tolower_ci; +EXPLAIN SELECT * FROM dd_table WHERE id = name COLLATE utf8_tolower_ci; +SELECT * FROM view1 WHERE table_name COLLATE utf8_tolower_ci = id; +EXPLAIN SELECT * FROM view1 WHERE table_name COLLATE utf8_tolower_ci = id; +END | +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CALL sub1('t1'); +table_name +t1 +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dd_table NULL const name name 195 const 1 100.00 Using index +table_name +t1 +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dd_table NULL const name name 195 const 1 100.00 Using index +name +t1 +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dd_table NULL const name name 195 const 1 100.00 Using index +table_name +t1 +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dd_table NULL const name name 195 const 1 100.00 Using index +table_name +t1 +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dd_table NULL const name name 195 const 1 100.00 Using index +name +t1 +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dd_table NULL const name name 195 const 1 100.00 Using index +table_name +t1 +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE dd_table NULL index NULL name 195 NULL 2 100.00 Using where; Using index +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Note 1003 /* select#1 */ select `test`.`dd_table`.`name` AS `table_name` from `test`.`dd_table` where ((`test`.`dd_table`.`name` collate utf8_tolower_ci) = (id@0)) +DROP PROCEDURE sub1; +DROP VIEW view1; +DROP VIEW view2; +DROP TABLE dd_table; +# +# Bug#24911350 LOCATE('HE','HELLO',NULL) SHOULD RETURN NULL INSTEAD OF 0 +# +select locate('he','hello',null),locate('he',null,2),locate(null,'hello',2); +locate('he','hello',null) locate('he',null,2) locate(null,'hello',2) +NULL NULL NULL +select locate(null,'hello',null),locate('he',null,null); +locate(null,'hello',null) locate('he',null,null) +NULL NULL +select left('hello',null),left(null,1),left(null,null); +left('hello',null) left(null,1) left(null,null) +NULL NULL NULL +select right('hello',null),right(null,1),right(null,null); +right('hello',null) right(null,1) right(null,null) +NULL NULL NULL +select mid('hello',1,null),mid('hello',null,1),mid(null,1,1); +mid('hello',1,null) mid('hello',null,1) mid(null,1,1) +NULL NULL NULL +select substr('hello',null,2),substr('hello',2,null),substr(null,1,2); +substr('hello',null,2) substr('hello',2,null) substr(null,1,2) +NULL NULL NULL +select substr(null,null,null),mid(null,null,null); +substr(null,null,null) mid(null,null,null) +NULL NULL +select substring_index('the king of the the null','the',null); +substring_index('the king of the the null','the',null) +NULL +select substring_index('the king of the the null',null,3); +substring_index('the king of the the null',null,3) +NULL +select substring_index(null,'the',3); +substring_index(null,'the',3) +NULL +select substring_index(null,null,3); +substring_index(null,null,3) +NULL +select substring_index(null,null,null); +substring_index(null,null,null) +NULL +select insert(null,2,1,'hi'),insert('txs',null,1,'hi'); +insert(null,2,1,'hi') insert('txs',null,1,'hi') +NULL NULL +select insert('txs',2,null,'hi'),insert('txs',2,1,null); +insert('txs',2,null,'hi') insert('txs',2,1,null) +NULL NULL +select insert('txs',null,null,'hi'),insert(null,null,null,null); +insert('txs',null,null,'hi') insert(null,null,null,null) +NULL NULL +# +# Bug #24930038 BITWISE SHIFT: ASSERTION FAILED: NULL_VALUE OR LOST CONNECTION TO SERVER ERROR +# +SET @orig_sql_mode = @@SQL_MODE; +SET SQL_MODE=''; +SELECT REPEAT(0x1111, 40000000) >> 1; +REPEAT(0x1111, 40000000) >> 1 +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +SELECT (~(REPEAT(0xb822, 0x5C9C380))); +(~(REPEAT(0xb822, 0x5C9C380))) +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +SET SQL_MODE=@orig_sql_mode; +# +# Bug#25688192 ASSERTION FAILED: MAYBE_NULL IN ITEM_FUNC_CONCAT::VAL_STR +# +set @max_allowed_packet=@@global.max_allowed_packet; +set global max_allowed_packet=2048; +Warnings: +Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length' +connect con1,localhost,root,,; +set sql_mode=""; +do concat(export_set(1,1,repeat('a',31),' $',213)); +Warnings: +Warning 1301 Result of export_set() was larger than max_allowed_packet (2048) - truncated +disconnect con1; +connection default; +set global max_allowed_packet=@max_allowed_packet; +# +# Bug#26524721 ASSERTION MAYBE_NULL FAILED IN ITEM_FUNC_CONCAT::VAL_STR +# +CREATE TABLE t(x VARCHAR(10) NOT NULL); +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +SELECT COUNT(*), CONCAT(x, 'x') FROM (SELECT * FROM t) AS tt; +COUNT(*) CONCAT(x, 'x') +0 NULL +DROP TABLE t; +# Bug#26049942 create table .. as select .. quote() give wrong length +SET NAMES latin1; +CREATE TABLE t1 AS SELECT quote('a'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `quote('a')` varchar(4) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 AS SELECT quote('a'); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `quote('a')` varchar(4) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET NAMES utf8mb4; +CREATE TABLE t3 AS SELECT quote('a'); +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `quote('a')` varchar(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET NAMES DEFAULT; +DROP TABLE t1, t2, t3; +# +# Bug #27410088: LOWER(CHAR(51386)) NOT EVALUATED CONSISTENTLY IN +# STORED PROCEDURE +# +CREATE PROCEDURE proc (ofs INT, count INT) +BEGIN +DECLARE i INT DEFAULT ofs; +WHILE i < count DO +SELECT i AS i; +IF LOWER(CHAR(i USING utf8) COLLATE utf8_tolower_ci) != +LOWER(CHAR(i USING utf8mb4) COLLATE utf8mb4_0900_as_ci) THEN +SELECT i AS 'found funny character'; +END IF; +SET i = i + 1; +END WHILE; +END| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CALL proc(51390, 51394); +i +51390 +found funny character +51390 +i +51391 +i +51392 +i +51393 +CALL proc(51390, 51394); +i +51390 +found funny character +51390 +i +51391 +i +51392 +i +51393 +DROP PROCEDURE proc; +# +# Bug#29133127 ASSERTION `MAYBE_NULL' FAILED +# |ITEM_FUNC_CONCAT::VAL_STR(STRING*) +# +SET GLOBAL max_allowed_packet=1024; +Warnings: +Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length' +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +SET collation_connection=utf32_unicode_ci; +SELECT +CONCAT('"',CONCAT('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"'); +CONCAT('"',CONCAT('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"') +NULL +Warnings: +Warning 1301 Result of concat() was larger than max_allowed_packet (1024) - truncated +SELECT +CONCAT('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"'); +CONCAT('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"') +NULL +Warnings: +Warning 1301 Result of concat_ws() was larger than max_allowed_packet (1024) - truncated +SELECT +CONCAT_WS('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"'); +CONCAT_WS('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"') +" +Warnings: +Warning 1301 Result of concat_ws() was larger than max_allowed_packet (1024) - truncated +SELECT +CONCAT('"',CONCAT('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"'); +CONCAT('"',CONCAT('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"') +NULL +Warnings: +Warning 1301 Result of concat() was larger than max_allowed_packet (1024) - truncated +SELECT +CONCAT('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"'); +CONCAT('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"') +NULL +Warnings: +Warning 1301 Result of concat_ws() was larger than max_allowed_packet (1024) - truncated +SELECT +CONCAT_WS('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"'); +CONCAT_WS('"',CONCAT_WS('";"',repeat('a',60), +repeat('b',60), +repeat('c',60), +repeat ('d',100)),'"') +" +Warnings: +Warning 1301 Result of concat_ws() was larger than max_allowed_packet (1024) - truncated +SET GLOBAL max_allowed_packet=default; +# +# Bug#29739778 ASSERTION FAILED: MAYBE_NULL, +# IN ITEM_STR_FUNC::PUSH_PACKET_OVERFLOW_WARNING +# +set sql_mode=''; +do repeat(row_count() ,((-9223372036854775808 )<<('{ }' )) ); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '{ }' +Warning 1292 Truncated incorrect INTEGER value: '{ }' +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +do ((repeat(1,9223372036854775808))or(convert((0x6d5b5d8d)using dec8))); +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (67108864) - truncated +Warning 1292 Truncated incorrect DOUBLE value: 'm[]' +set sql_mode=default; +# +# Bug #30114420 ASSERTION `CURRENT_THD->IS_ERROR()' +# FAILED|SQL/ITEM_STRFUNC.CC +# +CREATE TABLE t1(c1 VARCHAR(10)); +INSERT INTO t1 VALUES ('Alaska'); +SELECT HEX(LPAD('', 42, REPLACE(COMPRESS(42),c1,''))) FROM t1; +HEX(LPAD('', 42, REPLACE(COMPRESS(42),c1,''))) +02000000789C33310200009C006702000000789C33310200009C006702000000789C33310200009C0067 +SELECT HEX(LPAD('', 42, SUBSTRING_INDEX(COMPRESS(42),c1,1))) FROM t1; +HEX(LPAD('', 42, SUBSTRING_INDEX(COMPRESS(42),c1,1))) +02000000789C33310200009C006702000000789C33310200009C006702000000789C33310200009C0067 +SELECT LPAD('', 42, REPLACE(RANDOM_BYTES(42),c1,'')) FROM t1; +SELECT LPAD('', 42, REPLACE(AES_ENCRYPT(c1, 'key'),c1,'')) FROM t1; +SELECT LPAD('', 42, REPLACE(MD5(c1),c1,'')) FROM t1; +LPAD('', 42, REPLACE(MD5(c1),c1,'')) +e15997c74a71c5d9263df6f7a21bc191e15997c74a +SELECT HEX(LPAD('', 42, TRIM(BOTH c1 FROM x'ff'))) FROM t1; +HEX(LPAD('', 42, TRIM(BOTH c1 FROM x'ff'))) +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +SELECT HEX(LPAD('', 42, REPLACE(x'ffff',c1,''))) FROM t1; +HEX(LPAD('', 42, REPLACE(x'ffff',c1,''))) +FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +SELECT HEX(LPAD('', 42, TRIM(x'ffff' FROM c1))) FROM t1; +ERROR HY000: Cannot convert string '\xFF\xFF' from binary to utf8mb4 +SELECT LPAD('', 42, REPLACE(c1, 'las', x'ff')) FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +SELECT LPAD('', 42, REPLACE(c1, x'ff', 'las')) FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +SELECT HEX(SUBSTRING_INDEX(_utf8mb4 x'41F09F8DA3F09F8DA3' , x'f0', 2)) FROM t1; +ERROR HY000: Cannot convert string '\xF0' from binary to utf8mb4 +DROP TABLE t1; +SELECT TRIM(BOTH x'f0' FROM _utf8mb4 x'F09F8DA3F09F8DA3'); +ERROR HY000: Cannot convert string '\xF0' from binary to utf8mb4 +SELECT TRIM(BOTH x'F09F8DA3' FROM _utf8mb4 x'F09F8DA3F09F8DA3'); +TRIM(BOTH x'F09F8DA3' FROM _utf8mb4 x'F09F8DA3F09F8DA3') + +SELECT TRIM(_latin2 x'a3' from _latin1 "hello"); +ERROR HY000: Cannot convert string '\xA3' from latin2 to latin1 +SELECT REPLACE(_latin1 "hello", _latin2 x'a3', "hei"); +ERROR HY000: Cannot convert string '\xA3' from latin2 to latin1 +SELECT REPLACE(_latin1 "hello", "hei", _latin2 x'a3'); +ERROR HY000: Cannot convert string '\xA3' from latin2 to latin1 +SELECT SUBSTRING_INDEX(_latin1 "hello", _latin2 x'a3', 42); +ERROR HY000: Cannot convert string '\xA3' from latin2 to latin1 +SELECT TRIM(leading _utf8mb4 x'F09F8DA3' from _gb18030 x'9439B9376181308B33'); +TRIM(leading _utf8mb4 x'F09F8DA3' from _gb18030 x'9439B9376181308B33') +aø +SELECT SUBSTRING_INDEX(_utf8mb4 x'C3A6C3B8F09F8DA361C3A6C3B8F09F8DA362', +_gb18030 x'81308B339439B937', 2); +SUBSTRING_INDEX(_utf8mb4 x'C3A6C3B8F09F8DA361C3A6C3B8F09F8DA362', +_gb18030 x'81308B339439B937', 2) +æø🍣aæ +SELECT REPLACE('æøåæøå',_utf16 x'00e5', _gb18030 x'9439B937'); +REPLACE('æøåæøå',_utf16 x'00e5', _gb18030 x'9439B937') +æø🍣æø🍣 +SELECT REPLACE(_latin1 x'E6F8E5E6F8E5',_utf16 x'00e5', _utf32 x'00000061'); +REPLACE(_latin1 x'E6F8E5E6F8E5',_utf16 x'00e5', _utf32 x'00000061') +æøaæøa +# Bug#31358389: Crash in Item::add_accum_properties() +DO INSERT(1, 1, 1, CAST(1 AS DECIMAL(1,3))); +ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column ''). +# +# Bug #31798093 RECENT REGRESSION: +# ARG_COMPARATOR::COMPARE JUMPING TO INVALID CODE IN MEMORY +DO CONVERT( NULLIF( @a , 'c' ) USING BINARY); +# +# Bug #31887870 +# QUERY WITH RPAD FUNCTION USING CHINESE STRING LEADS TO MESSY CODE +# +CREATE TABLE t1 ( +id INT NOT NULL, +c1 VARCHAR(10) +); +INSERT INTO t1 VALUES (111,'111'); +SELECT +RPAD(id, 11, _utf8mb4 x'E4B8ADE69687') as rpad_id, +LPAD(id, 11, _utf8mb4 x'E4B8ADE69687') as lpad_id, +RPAD(c1, 11, _utf8mb4 x'E4B8ADE69687') as rpad_c1, +LPAD(c1, 11, _utf8mb4 x'E4B8ADE69687') as lpad_c1 +FROM t1; +rpad_id lpad_id rpad_c1 lpad_c1 +111中文中文中文中文 中文中文中文中文111 111中文中文中文中文 中文中文中文中文111 +DROP TABLE t1; +# +# Bug #22523946 GET MESS CODE FOR FUNC INSERT() +# WITH STR AS INT CONST AND NEWSTR AS MULTI-BYTE +# +SELECT INSERT(1, 1, 2, _utf8mb4 x'E4B8ADE69687'); +INSERT(1, 1, 2, _utf8mb4 x'E4B8ADE69687') +中文 +# +# Bug #21943299 FAILED CAST OF STRING-RETURNING FUNCTION TO DOUBLE +# EMITS NO WARNING +SELECT 'a' + 0; +'a' + 0 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT CAST('a' as DOUBLE); +CAST('a' as DOUBLE) +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT CAST(CONCAT('a') as DOUBLE); +CAST(CONCAT('a') as DOUBLE) +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +# Bug #22538859 "CONCAT( '2005' , '-01-01') - 100" +# DOESN'T THROW ANY WARNING +# +SELECT '2005-01-01' - 100; +'2005-01-01' - 100 +1905 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2005-01-01' +SELECT CONCAT('2005' , '-01-01') - 100; +CONCAT('2005' , '-01-01') - 100 +1905 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '2005-01-01' +# Bug#32096341: ISNULL continuously returns the same value for LOAD_FILE +CREATE TABLE t1(id INTEGER NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES(0); +CALL p1(); +is null +1 +CALL p1(); +is null +0 +DROP PROCEDURE p1; +DROP TABLE t1; +# +# Bug #32163391 ASSERTION `CRC32_Z(CRC, POS, LENGTH) +# < STD::NUMERIC_LIMITS::MAX()' FAILED. +do crc32(char(1.134475e+308)); +# +# Bug#32192454: WL14340: RPDSERVER SIG11 AT +# RPDMPR_BVFLT_RPDMPR_DTYPE_SB8_RPDOQC_OPT_TYPE_GT_TRUE +# +CREATE TABLE t(x LONGTEXT); +SELECT UNHEX(x) FROM t; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def UNHEX(x) 251 2147483648 0 Y 128 31 63 +UNHEX(x) +DROP TABLE t; +Bug#32501472: Concatenation may create invalid UTF8 strings +CREATE TABLE t1(a CHAR(1) CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES('a'); +SELECT CONCAT(a, x'ff') FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +SELECT CONCAT_WS(',', a, x'ff') FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +SELECT CONCAT_WS(x'ff', a, a) FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +SELECT INSERT(a, 1, 1, x'ff') FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(3), b VARCHAR(3)); +INSERT INTO t1 VALUES('on','off'); +SELECT EXPORT_SET(7, a, b, x'ff', 4) FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +SELECT EXPORT_SET(7, a, x'ff', b, 4) FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +SELECT MAKE_SET(7, a, b, x'ff') FROM t1; +ERROR HY000: Cannot convert string '\xFF' from binary to utf8mb4 +DROP TABLE t1; +Bug#30746908: Assertion `(tlen % 4) == 0' in my_strnncollsp_utf32 +CREATE TABLE t(a INTEGER); +INSERT INTO t VALUES (1),(2); +SELECT (SELECT 1 +FROM t +WHERE CONVERT(1 USING utf32) <> GROUP_CONCAT(1) +); +(SELECT 1 +FROM t +WHERE CONVERT(1 USING utf32) <> GROUP_CONCAT(1) +) +NULL +SELECT (SELECT 1 +FROM t +WHERE CONVERT(1 USING gb18030) <> GROUP_CONCAT(x'a3') +); +ERROR HY000: Cannot convert string '\xA3' from binary to gb18030 +DROP TABLE t; diff --git a/mysql-test/r/func_test.result-pq b/mysql-test/r/func_test.result-pq new file mode 100644 index 000000000..7c8e5e276 --- /dev/null +++ b/mysql-test/r/func_test.result-pq @@ -0,0 +1,740 @@ +drop table if exists t1,t2; +select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ; +0=0 1>0 1>=1 1<0 1<=0 1!=0 strcmp("abc","abcd") strcmp("b","a") strcmp("a","a") +1 1 1 0 0 1 -1 1 0 +select "a"<"b","a"<="b","b">="a","b">"a","a"="A","a"<>"b"; +"a"<"b" "a"<="b" "b">="a" "b">"a" "a"="A" "a"<>"b" +1 1 1 1 1 1 +select "a "="A", "A "="a", "a " <= "A b"; +"a "="A" "A "="a" "a " <= "A b" +0 0 1 +select "abc" like "a%", "abc" not like "%d%", "a%" like "a\%","abc%" like "a%\%","abcd" like "a%b_%d", "a" like "%%a","abcde" like "a%_e","abc" like "abc%"; +"abc" like "a%" "abc" not like "%d%" "a%" like "a\%" "abc%" like "a%\%" "abcd" like "a%b_%d" "a" like "%%a" "abcde" like "a%_e" "abc" like "abc%" +1 1 1 1 1 1 1 1 +select "a" like "%%b","a" like "%%ab","ab" like "a\%", "ab" like "_", "ab" like "ab_", "abc" like "%_d", "abc" like "abc%d"; +"a" like "%%b" "a" like "%%ab" "ab" like "a\%" "ab" like "_" "ab" like "ab_" "abc" like "%_d" "abc" like "abc%d" +0 0 0 0 0 0 0 +select '?' like '|%', '?' like '|%' ESCAPE '|', '%' like '|%', '%' like '|%' ESCAPE '|', '%' like '%'; +'?' like '|%' '?' like '|%' ESCAPE '|' '%' like '|%' '%' like '|%' ESCAPE '|' '%' like '%' +0 0 0 1 1 +select 'abc' like '%c','abcabc' like '%c', "ab" like "", "ab" like "a", "ab" like "ab"; +'abc' like '%c' 'abcabc' like '%c' "ab" like "" "ab" like "a" "ab" like "ab" +1 1 0 0 1 +select "Det här är svenska" regexp "h[[:alpha:]]+r", "aba" regexp "^(a|b)*$"; +"Det här är svenska" regexp "h[[:alpha:]]+r" "aba" regexp "^(a|b)*$" +1 1 +select "aba" regexp concat("^","a"); +"aba" regexp concat("^","a") +1 +select !0,NOT 0=1,!(0=0),1 AND 1,1 && 0,0 OR 1,1 || NULL, 1=1 or 1=1 and 1=0; +!0 NOT 0=1 !(0=0) 1 AND 1 1 && 0 0 OR 1 1 || NULL 1=1 or 1=1 and 1=0 +1 1 0 1 0 1 1 1 +Warnings: +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +Warning 1287 '&&' is deprecated and will be removed in a future release. Please use AND instead +Warning 1287 '|| as a synonym for OR' is deprecated and will be removed in a future release. Please use OR instead +select 2 between 1 and 3, "monty" between "max" and "my",2=2 and "monty" between "max" and "my" and 3=3; +2 between 1 and 3 "monty" between "max" and "my" 2=2 and "monty" between "max" and "my" and 3=3 +1 1 1 +select 'b' between 'a' and 'c', 'B' between 'a' and 'c'; +'b' between 'a' and 'c' 'B' between 'a' and 'c' +1 1 +select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,1.0); +2 in (3,2,5,9,5,1) "monty" in ("david","monty","allan") 1.2 in (1.4,1.2,1.0) +1 1 1 +select -1.49 or -1.49,0.6 or 0.6; +-1.49 or -1.49 0.6 or 0.6 +1 1 +select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1; +3 ^ 11 1 ^ 1 1 ^ 0 1 ^ NULL NULL ^ 1 +8 0 1 NULL NULL +explain select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (3 ^ 11) AS `3 ^ 11`,(1 ^ 1) AS `1 ^ 1`,(1 ^ 0) AS `1 ^ 0`,(1 ^ NULL) AS `1 ^ NULL`,(NULL ^ 1) AS `NULL ^ 1` +select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL; +1 XOR 1 1 XOR 0 0 XOR 1 0 XOR 0 NULL XOR 1 1 XOR NULL 0 XOR NULL +0 1 1 0 NULL NULL NULL +select 1 like 2 xor 2 like 1; +1 like 2 xor 2 like 1 +0 +select 10 % 7, 10 mod 7, 10 div 3; +10 % 7 10 mod 7 10 div 3 +3 3 3 +explain select 10 % 7, 10 mod 7, 10 div 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (10 % 7) AS `10 % 7`,(10 % 7) AS `10 mod 7`,(10 DIV 3) AS `10 div 3` +select 18446744073709551615, 18446744073709551615 DIV 1, 18446744073709551615 DIV 2; +18446744073709551615 18446744073709551615 DIV 1 18446744073709551615 DIV 2 +18446744073709551615 18446744073709551615 9223372036854775807 +explain select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ((1 << 64) - 1) AS `(1 << 64)-1`,(((1 << 64) - 1) DIV 1) AS `((1 << 64)-1) DIV 1`,(((1 << 64) - 1) DIV 2) AS `((1 << 64)-1) DIV 2` +create table t1 (a int); +insert t1 values (1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where 1 xor 1; +a +explain select * from t1 where 1 xor 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select - a from t1; +- a +-1 +explain select - a from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select -(`test`.`t1`.`a`) AS `- a` from `test`.`t1` +drop table t1; +select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1; +5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1 +0 1 +select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1; +1 and 2 between 2 and 10 2 between 2 and 10 and 1 +1 1 +select 1 and 0 or 2, 2 or 1 and 0; +1 and 0 or 2 2 or 1 and 0 +1 1 +select _koi8r'a' = _koi8r'A'; +_koi8r'a' = _koi8r'A' +1 +select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci; +_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci +1 +explain select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select (_koi8r'a' = (_koi8r'A' collate koi8r_general_ci)) AS `_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci` +select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin; +_koi8r'a' = _koi8r'A' COLLATE koi8r_bin +0 +select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A'; +_koi8r'a' COLLATE koi8r_general_ci = _koi8r'A' +1 +select _koi8r'a' COLLATE koi8r_bin = _koi8r'A'; +_koi8r'a' COLLATE koi8r_bin = _koi8r'A' +0 +select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci; +ERROR HY000: Illegal mix of collations (koi8r_bin,EXPLICIT) and (koi8r_general_ci,EXPLICIT) for operation '=' +select _koi8r'a' = _latin1'A'; +ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation '=' +select strcmp(_koi8r'a', _koi8r'A'); +strcmp(_koi8r'a', _koi8r'A') +0 +select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci); +strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci) +0 +select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin); +strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin) +1 +select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A'); +strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A') +0 +select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A'); +strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A') +1 +select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin); +ERROR HY000: Illegal mix of collations (koi8r_general_ci,EXPLICIT) and (koi8r_bin,EXPLICIT) for operation 'strcmp' +select strcmp(_koi8r'a', _latin1'A'); +ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'strcmp' +select _koi8r'a' LIKE _koi8r'A'; +_koi8r'a' LIKE _koi8r'A' +1 +select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci; +_koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci +1 +select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin; +_koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin +0 +select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A'; +_koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' +1 +select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A'; +_koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A' +0 +select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin; +ERROR HY000: Illegal mix of collations (koi8r_general_ci,EXPLICIT) and (koi8r_bin,EXPLICIT) for operation 'like' +select _koi8r'a' LIKE _latin1'A'; +ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'like' +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','\r\n\r\n \r\n \r\n \r\n \r\n
 \r\n

How \r\n To: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected.

\r\n
','\r\n \r\n \r\n \r\n \r\n\r\n \r\n
  \r\n \r\n

1. Select \r\n the On/Setup button to access the DynaVox Setup Menu.
\r\n 2. Select Button Features.
\r\n 3. Below the OK button is the Usage Counts button.
\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.
\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.
\r\n c. Select the Usage Counts Option Ring once and it will toggle \r\n to the alternative option.
\r\n 4. Once the correct setting has been chosen, select OK to leave the Button \r\n Features menu.
\r\n 5. Select OK out of the Setup menu and return to the communication \r\n page.

\r\n

For \r\n further information on Usage Counts, see the Button Features \r\n Menu Entry in the DynaVox/DynaMyte Reference Manual.

\r\n
',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL); +CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, `rank` smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Customer Support',1); +SELECT f_acc.`rank`, a1.`rank`, a2.`rank` FROM t1 LEFT JOIN t1 f1 ON (f1.access_id=1 AND f1.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a1 ON (a1.access_id = f1.access_id) LEFT JOIN t1 f2 ON (f2.access_id=3 AND f2.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a2 ON (a2.access_id = f2.access_id), t2 f_acc WHERE LEAST(a1.`rank`,a2.`rank`) = f_acc.`rank`; +rank rank rank +DROP TABLE t1,t2; +SET sql_mode = default; +CREATE TABLE t1 (d varchar(6), k int); +INSERT INTO t1 VALUES (NULL, 2); +SELECT GREATEST(d,d) FROM t1 WHERE k=2; +GREATEST(d,d) +NULL +DROP TABLE t1; +select 1197.90 mod 50; +1197.90 mod 50 +47.90 +select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3; +5.1 mod 3 5.1 mod -3 -5.1 mod 3 -5.1 mod -3 +2.1 2.1 -2.1 -2.1 +select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3; +5 mod 3 5 mod -3 -5 mod 3 -5 mod -3 +2 2 -2 -2 +select (12%0) <=> null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select (12%0) is null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select 12%0 as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select 12%2 as '0'; +0 +0 +select 12%NULL as 'NULL'; +NULL +NULL +select 12 % null as 'NULL'; +NULL +NULL +select null % 12 as 'NULL'; +NULL +NULL +select null % 0 as 'NULL'; +NULL +NULL +select 0 % null as 'NULL'; +NULL +NULL +select null % null as 'NULL'; +NULL +NULL +select (12 mod 0) <=> null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select (12 mod 0) is null as '1'; +1 +1 +Warnings: +Warning 1365 Division by 0 +select 12 mod 0 as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select 12 mod 2 as '0'; +0 +0 +select 12 mod null as 'NULL'; +NULL +NULL +select null mod 12 as 'NULL'; +NULL +NULL +select null mod 0 as 'NULL'; +NULL +NULL +select 0 mod null as 'NULL'; +NULL +NULL +select null mod null as 'NULL'; +NULL +NULL +select mod(12.0, 0) as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select mod(12, 0.0) as 'NULL'; +NULL +NULL +Warnings: +Warning 1365 Division by 0 +select mod(12, NULL) as 'NULL'; +NULL +NULL +select mod(12.0, NULL) as 'NULL'; +NULL +NULL +select mod(NULL, 2) as 'NULL'; +NULL +NULL +select mod(NULL, 2.0) as 'NULL'; +NULL +NULL +create table t1 (a int, b int); +insert into t1 values (1,2), (2,3), (3,4), (4,5); +select * from t1 where a not between 1 and 2; +a b +3 4 +4 5 +select * from t1 where a not between 1 and 2 and b not between 3 and 4; +a b +4 5 +drop table t1; +SELECT GREATEST(1,NULL) FROM DUAL; +GREATEST(1,NULL) +NULL +SELECT LEAST('xxx','aaa',NULL,'yyy') FROM DUAL; +LEAST('xxx','aaa',NULL,'yyy') +NULL +SELECT LEAST(1.1,1.2,NULL,1.0) FROM DUAL; +LEAST(1.1,1.2,NULL,1.0) +NULL +SELECT GREATEST(1.5E+2,1.3E+2,NULL) FROM DUAL; +GREATEST(1.5E+2,1.3E+2,NULL) +NULL +# +# Bug#22523685 FUNCTION GREATEST AND LEAST WORKS INCORRECTLY +# WITH BIGINT UNSIGNED VALUE +# +SELECT greatest( 9223372036854775807 , 9223372036854775808 ) as g; +g +9223372036854775808 +SELECT least ( 9223372036854775807 , 9223372036854775808 ) as l; +l +9223372036854775807 +SELECT greatest (9223372036854775808, -1, 18446744073709551615 ) as g; +g +18446744073709551615 +SELECT least (9223372036854775808, -1, 18446744073709551615 ) as l; +l +-1 +SELECT greatest (9223372036854775808, 18446744073709551615) as g; +g +18446744073709551615 +SELECT least (9223372036854775808, 18446744073709551615) as l; +l +9223372036854775808 +CREATE TABLE t1 AS SELECT greatest(-1, 9223372036854775808); +CREATE TABLE t2 AS SELECT greatest(9223372036854775808, 9223372036854775808); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `greatest(-1, 9223372036854775808)` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `greatest(9223372036854775808, 9223372036854775808)` bigint unsigned NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Bug#22839888 UNINITIALIZED VALUE WHEN CONVERTING +# MULTIBYTE STRINGS TO NUMBERS +# +select greatest(1,_utf16'.',_utf8''); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,NUMERIC), (utf16_general_ci,COERCIBLE), (utf8_general_ci,COERCIBLE) for operation 'greatest' +# +# Bug#25123839: LEAST AND GREATEST MAKES INCONSISTENT DATA TYPES, +# COMPARED TO UNION AND COALESCE +# +SET sql_mode=''; +CREATE TABLE t1 AS +SELECT 5 AS c1, 5 AS c2, 5 AS c3, 5 AS c4, 20010101 AS c5, 010101 AS c6, +010101 AS c7, 20010101 AS c8, 5.55 AS c11, 5.5 AS c12, 5.5 AS c13, +010101.5 AS c14, 5.5 AS c15, 010101.5 as c16, 5.5e5 as c21, +2004041e1 as c22, 150505.0e5 AS c23, 2004041e1 AS c24, '010101' AS c31, +'5' AS c32, '010101' AS c33, date '2005-05-05' AS c41, +date '2005-05-05' AS c42, time '05:05:05.555555' AS c51, +x'c3a5' AS c61, x'c3a5' AS c62, _utf8mb4 x'c3a5' AS c63, +_utf8mb4 x'c3a5' AS c64, JSON_OBJECT('a', 1) as c71 +UNION +SELECT -5, 5.5, 5.5e5, '5', date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', NOW(0), 88.8, +5.5e5, '5', date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', +'5', date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', +date '2005-05-05', time '05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', +time '05:05:05.555555', timestamp '2005-05-05 05:05:05.555555', +timestamp '2005-05-05 05:05:05.555555', '1', _binary '1', '1', +_binary '1', NULL; +SET sql_mode=default; +CREATE TABLE t2 AS +SELECT COALESCE(5, -5) AS c1, +COALESCE(5, 5.5) AS c2, +COALESCE(5, 5.5e5) AS c3, +COALESCE(5, '5') AS c4, +COALESCE(20010101, date '2005-05-05') AS c5, +COALESCE(010101, time '05:05:05.555555') AS c6, +COALESCE(010101, timestamp '2005-05-05 05:05:05.555555') AS c7, +COALESCE(20010101, NOW(0)) AS c8, +COALESCE(5.55, 88.8) AS c11, +COALESCE(5.5, 5.5e5) AS c12, +COALESCE(5.5, '5') AS c13, +COALESCE(010101.5, date '2005-05-05') AS c14, +COALESCE(5.5, time '05:05:05.555555') AS c15, +COALESCE(010101.5, timestamp '2005-05-05 05:05:05.555555') AS c16, +COALESCE(5.5e5, '5') AS c21, +COALESCE(2004041e1, date '2005-05-05') AS c22, +COALESCE(150505.0e5, time '05:05:05.555555') AS c23, +COALESCE(2004041e1, timestamp '2005-05-05 05:05:05.555555') AS c24, +COALESCE('010101', date '2005-05-05') AS c31, +COALESCE('5', time '05:05:05.555555') AS c32, +COALESCE('010101', timestamp '2005-05-05 05:05:05.555555') AS c33, +COALESCE(date '2005-05-05', time '05:05:05.555555') AS c41, +COALESCE(date '2005-05-05', timestamp '2005-05-05 05:05:05.555555') AS +c42, +COALESCE(time '05:05:05.555555', timestamp '2005-05-05 +05:05:05.555555') AS c51, +COALESCE(x'c3a5', '1') AS c61, +COALESCE(x'c3a5', _binary '1') AS c62, +COALESCE(_utf8mb4 x'c3a5', '1') AS c63, +COALESCE(_utf8mb4 x'c3a5', _binary '1') AS c64, +COALESCE(JSON_OBJECT('a', 1), NULL) AS c71; +CREATE TABLE t3 AS +SELECT GREATEST(5, -5) AS c1, +GREATEST(5, 5.5) AS c2, +GREATEST(5, 5.5e5) AS c3, +GREATEST(5, '5') AS c4, +GREATEST(20010101, date '2005-05-05') AS c5, +GREATEST(010101, time '05:05:05.555555') AS c6, +GREATEST(010101, timestamp '2005-05-05 05:05:05.555555') AS c7, +GREATEST(20010101, NOW(0)) AS c8, +GREATEST(5.55, 88.8) AS c11, +GREATEST(5.5, 5.5e5) AS c12, +GREATEST(5.5, '5') AS c13, +GREATEST(010101.5, date '2005-05-05') AS c14, +GREATEST(5.5, time '05:05:05.555555') AS c15, +GREATEST(010101.5, timestamp '2005-05-05 05:05:05.555555') AS c16, +GREATEST(5.5e5, '5') AS c21, +GREATEST(2004041e1, date '2005-05-05') AS c22, +GREATEST(150505.0e5, time '05:05:05.555555') AS c23, +GREATEST(2004041e1, timestamp '2005-05-05 05:05:05.555555') AS c24, +GREATEST('010101', date '2005-05-05') AS c31, +GREATEST('5', time '05:05:05.555555') AS c32, +GREATEST('010101', timestamp '2005-05-05 05:05:05.555555') AS c33, +GREATEST(date '2005-05-05', time '05:05:05.555555') AS c41, +GREATEST(date '2005-05-05', timestamp '2005-05-05 05:05:05.555555') AS +c42, +GREATEST(time '05:05:05.555555', timestamp '2005-05-05 +05:05:05.555555') AS c51, +GREATEST(x'c3a5', '1') AS c61, +GREATEST(x'c3a5', _binary '1') AS c62, +GREATEST(_utf8mb4 x'c3a5', '1') AS c63, +GREATEST(_utf8mb4 x'c3a5', _binary '1') AS c64; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL DEFAULT '0', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0', + `c3` double NOT NULL DEFAULT '0', + `c4` varchar(1) NOT NULL DEFAULT '', + `c5` varchar(10) NOT NULL DEFAULT '', + `c6` varchar(17) NOT NULL DEFAULT '', + `c7` varchar(26) NOT NULL DEFAULT '', + `c8` varchar(19) NOT NULL DEFAULT '', + `c11` decimal(4,2) NOT NULL DEFAULT '0.00', + `c12` double NOT NULL DEFAULT '0', + `c13` varchar(4) NOT NULL DEFAULT '', + `c14` varchar(10) NOT NULL DEFAULT '', + `c15` varchar(17) NOT NULL DEFAULT '', + `c16` varchar(26) NOT NULL DEFAULT '', + `c21` varchar(22) NOT NULL DEFAULT '', + `c22` varchar(22) NOT NULL DEFAULT '', + `c23` varchar(22) NOT NULL DEFAULT '', + `c24` varchar(26) NOT NULL DEFAULT '', + `c31` varchar(10) NOT NULL DEFAULT '', + `c32` varchar(17) NOT NULL DEFAULT '', + `c33` varchar(26) NOT NULL DEFAULT '', + `c41` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `c42` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `c51` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `c61` varbinary(4) NOT NULL DEFAULT '', + `c62` varbinary(2) NOT NULL DEFAULT '', + `c63` varchar(1) NOT NULL DEFAULT '', + `c64` varbinary(4) NOT NULL DEFAULT '', + `c71` json DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` int NOT NULL DEFAULT '0', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0', + `c3` double NOT NULL DEFAULT '0', + `c4` varchar(1) NOT NULL DEFAULT '', + `c5` varchar(10) NOT NULL DEFAULT '', + `c6` varchar(17) NOT NULL DEFAULT '', + `c7` varchar(26) NOT NULL DEFAULT '', + `c8` varchar(19) NOT NULL DEFAULT '', + `c11` decimal(4,2) NOT NULL DEFAULT '0.00', + `c12` double NOT NULL DEFAULT '0', + `c13` varchar(4) NOT NULL DEFAULT '', + `c14` varchar(10) NOT NULL DEFAULT '', + `c15` varchar(17) NOT NULL DEFAULT '', + `c16` varchar(26) NOT NULL DEFAULT '', + `c21` varchar(22) NOT NULL DEFAULT '', + `c22` varchar(22) NOT NULL DEFAULT '', + `c23` varchar(22) NOT NULL DEFAULT '', + `c24` varchar(26) NOT NULL DEFAULT '', + `c31` varchar(10) NOT NULL DEFAULT '', + `c32` varchar(17) NOT NULL DEFAULT '', + `c33` varchar(26) NOT NULL DEFAULT '', + `c41` datetime(6) NOT NULL, + `c42` datetime(6) NOT NULL, + `c51` datetime(6) NOT NULL, + `c61` varbinary(4) NOT NULL DEFAULT '', + `c62` varbinary(2) NOT NULL DEFAULT '', + `c63` varchar(1) NOT NULL DEFAULT '', + `c64` varbinary(4) NOT NULL DEFAULT '', + `c71` json DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `c1` int NOT NULL DEFAULT '0', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0', + `c3` double NOT NULL DEFAULT '0', + `c4` varchar(1) NOT NULL DEFAULT '', + `c5` varchar(10) NOT NULL DEFAULT '', + `c6` varchar(17) NOT NULL DEFAULT '', + `c7` varchar(26) NOT NULL DEFAULT '', + `c8` varchar(19) NOT NULL DEFAULT '', + `c11` decimal(4,2) NOT NULL DEFAULT '0.00', + `c12` double NOT NULL DEFAULT '0', + `c13` varchar(4) NOT NULL DEFAULT '', + `c14` varchar(10) NOT NULL DEFAULT '', + `c15` varchar(17) NOT NULL DEFAULT '', + `c16` varchar(26) NOT NULL DEFAULT '', + `c21` varchar(22) NOT NULL DEFAULT '', + `c22` varchar(22) NOT NULL DEFAULT '', + `c23` varchar(22) NOT NULL DEFAULT '', + `c24` varchar(26) NOT NULL DEFAULT '', + `c31` varchar(10) NOT NULL DEFAULT '', + `c32` varchar(17) NOT NULL DEFAULT '', + `c33` varchar(26) NOT NULL DEFAULT '', + `c41` datetime(6) NOT NULL, + `c42` datetime(6) NOT NULL, + `c51` datetime(6) NOT NULL, + `c61` varbinary(4) NOT NULL DEFAULT '', + `c62` varbinary(2) NOT NULL DEFAULT '', + `c63` varchar(1) NOT NULL DEFAULT '', + `c64` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2, t3; +SELECT GREATEST('11', '5', '2'); +GREATEST('11', '5', '2') +5 +SELECT GREATEST('11', 5, 2); +GREATEST('11', 5, 2) +5 +SELECT GREATEST(11, 5, 2); +GREATEST(11, 5, 2) +11 +SELECT LEAST('11', '5', '2'); +LEAST('11', '5', '2') +11 +SELECT LEAST('11', 5, 2); +LEAST('11', 5, 2) +11 +SELECT LEAST(11, 5, 2); +LEAST(11, 5, 2) +2 +SELECT GREATEST(date '2005-05-05', 20010101, 20040404, 20030303); +GREATEST(date '2005-05-05', 20010101, 20040404, 20030303) +2005-05-05 +SELECT LEAST(date '2005-05-05', 20030303, 20010101, 20040404); +LEAST(date '2005-05-05', 20030303, 20010101, 20040404) +2001-01-01 +SELECT GREATEST(date '2005-05-05', '20010101', '20040404', '20030303'); +GREATEST(date '2005-05-05', '20010101', '20040404', '20030303') +2005-05-05 +SELECT LEAST(date '2005-05-05', '20030303', '20010101', '20040404'); +LEAST(date '2005-05-05', '20030303', '20010101', '20040404') +2001-01-01 +SELECT GREATEST(time '00:00:00', 120000); +GREATEST(time '00:00:00', 120000) +120000 +SELECT LEAST(time '00:00:00', 120000); +LEAST(time '00:00:00', 120000) +00:00:00 +SELECT GREATEST(time '20:00:00', 120000); +GREATEST(time '20:00:00', 120000) +20:00:00 +SELECT LEAST(time '20:00:00', 120000); +LEAST(time '20:00:00', 120000) +120000 +SELECT GREATEST('95-05-05', date '10-10-10'); +GREATEST('95-05-05', date '10-10-10') +2010-10-10 +SELECT GREATEST(date '1995-05-05', '10-10-10'); +GREATEST(date '1995-05-05', '10-10-10') +2010-10-10 +SELECT LEAST(date '1995-05-05', '10-10-10'); +LEAST(date '1995-05-05', '10-10-10') +1995-05-05 +SELECT LEAST('95-05-05', date '10-10-10'); +LEAST('95-05-05', date '10-10-10') +1995-05-05 +SELECT GREATEST('11', '5', '2') + 0; +GREATEST('11', '5', '2') + 0 +5 +SELECT GREATEST('11', 5, 2) + 0; +GREATEST('11', 5, 2) + 0 +5 +SELECT GREATEST(11, 5, 2) + 0; +GREATEST(11, 5, 2) + 0 +11 +SELECT GREATEST(date '2005-05-05', 20010101, 20040404, 20030303) + 0; +GREATEST(date '2005-05-05', 20010101, 20040404, 20030303) + 0 +20050505 +SELECT GREATEST(time '00:00:00', 120000) + 0; +GREATEST(time '00:00:00', 120000) + 0 +120000 +SELECT GREATEST(time '20:00:00', 120000) + 0; +GREATEST(time '20:00:00', 120000) + 0 +200000 +SELECT GREATEST('95-05-05', date '10-10-10') + 0; +GREATEST('95-05-05', date '10-10-10') + 0 +20101010 +SELECT GREATEST(date '1995-05-05', '10-10-10') + 0; +GREATEST(date '1995-05-05', '10-10-10') + 0 +20101010 +SELECT GREATEST('11', '5', '2') + 0.00; +GREATEST('11', '5', '2') + 0.00 +5 +SELECT GREATEST('11', 5, 2) + 0.00; +GREATEST('11', 5, 2) + 0.00 +5 +SELECT GREATEST(11, 5, 2) + 0.00; +GREATEST(11, 5, 2) + 0.00 +11.00 +SELECT GREATEST(date '1995-05-05', 19910101, 20050505, 19930303) + 0.00; +GREATEST(date '1995-05-05', 19910101, 20050505, 19930303) + 0.00 +20050505.00 +SELECT GREATEST(time '00:00:00', 120000) + 0.00; +GREATEST(time '00:00:00', 120000) + 0.00 +120000.00 +SELECT GREATEST(time '20:00:00', 120000) + 0.00; +GREATEST(time '20:00:00', 120000) + 0.00 +200000.00 +SELECT GREATEST('95-05-05', date '10-10-10') + 0.00; +GREATEST('95-05-05', date '10-10-10') + 0.00 +20101010.00 +SELECT GREATEST(date '1995-05-05', '10-10-10') + 0.00; +GREATEST(date '1995-05-05', '10-10-10') + 0.00 +20101010.00 +# End of test for Bug#25123839 +# +# Bug#26975864: ASSERTION FAILED: DEC <= 6, MY_DATETIME_TO_STR, LEAST, +# GREATEST, ETC +# +CREATE TABLE t1 (a DATETIME, b BLOB, c TEXT, d CHAR(10), e BINARY(10), +f VARBINARY(10)); +SET @a='2017-01-01'; +INSERT INTO t1 VALUES ('2017-02-02 12:00:00', @a, @a, @a, @a, @a); +SELECT GREATEST(a, b), GREATEST(a, c), GREATEST(a, d), GREATEST(a, e), +GREATEST(a, f) FROM t1; +GREATEST(a, b) GREATEST(a, c) GREATEST(a, d) GREATEST(a, e) GREATEST(a, f) +2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 2017-02-02 12:00:00.000000 +SET @a=NULL; +DROP TABLE t1; +# +# Bug#13364839: GREATEST() DOES NOT ALWAYS RETURN SAME SIGNNESS OF ARGUMENT TYPES +# +CREATE TABLE t1 (a INT PRIMARY KEY, b BIGINT(20) UNSIGNED); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, 13836376518955650385); +INSERT INTO t1 VALUES (1, 13836376518955650385) ON DUPLICATE KEY UPDATE b=GREATEST(b, VALUES(b)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +1 13836376518955650385 +DROP TABLE t1; +# +# Bug#27312703 ASAN: HEAP-USE-AFTER-FREE: GREATEST/LEAST FUNCTIONS +# +SET @a:='11'; +DO GREATEST(RIGHT(@a,1),1); +DO LEAST(RIGHT(@a,1),1); +# +# Bug#29275835 ASSERTION FAILED: +# !UNSIGNED_FLAG || (UNSIGNED_FLAG && ARGS[I]->UNSIGNED_FLAG) +# +SET sql_mode=''; +CREATE TABLE t0017 ( +c0002 bigint(20) NOT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0017 (c0002) +VALUES (0); +SELECT greatest(18446744073709551615, NULL) +FROM t0017; +greatest(18446744073709551615, NULL) +NULL +SELECT +count(greatest(18446744073709551615, NULL)) +FROM t0017; +count(greatest(18446744073709551615, NULL)) +0 +DROP TABLE t0017; +SET sql_mode = default; +# +# Bug#29467577 ASSERTION `!UNSIGNED_FLAG || +# (UNSIGNED_FLAG && ARGS[I]->UNSIGNED_FLAG)' FAILED. +# +CREATE TABLE t1 (c1 INT UNSIGNED, c2 INT UNSIGNED); +INSERT INTO t1 VALUES (202, 1); +SELECT * FROM t1 WHERE (GREATEST(c1, c2) = 42) AND (c2 = 1); +c1 c2 +DROP TABLE t1; +# +# Bug#30326848 ASSERTION FAILED: (SLEN % 4) == 0 IN MY_STRNNCOLLSP_UTF32 +# +DO NULLIF((GREATEST(FROM_UNIXTIME(1537024679) , _utf32 "*b!" )), +(FROM_UNIXTIME(1537013301) ) +); +Warnings: +Warning 1300 Invalid utf32 character string: '002A62' +Warning 1292 Incorrect datetime value: '?' for column 'FROM_UNIXTIME(1537024679)' at row 1 +Warning 1292 Incorrect datetime value: '?' for column 'FROM_UNIXTIME(1537024679)' at row 1 diff --git a/mysql-test/r/functional_index.result-pq b/mysql-test/r/functional_index.result-pq new file mode 100644 index 000000000..4936036b5 --- /dev/null +++ b/mysql-test/r/functional_index.result-pq @@ -0,0 +1,641 @@ +CREATE TABLE t1 (int_col INTEGER, string_col VARCHAR(255)); +INSERT INTO t1 (int_col, string_col) VALUES (-1, "foo"), (1, "bar"); +CREATE INDEX int_func_index ON t1 ((ABS(int_col))); +CREATE INDEX string_func_index ON t1 ((SUBSTRING(string_col, 1, 2))); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# We should see the functional index syntax in SHOW CREATE TABLE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `int_col` int DEFAULT NULL, + `string_col` varchar(255) DEFAULT NULL, + KEY `int_func_index` ((abs(`int_col`))), + KEY `string_func_index` ((substr(`string_col`,1,2))) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# INFORMATION_SCHEMA.STATISTICS should show the expression and no column +# name +SELECT * FROM INFORMATION_SCHEMA.STATISTICS +WHERE INDEX_NAME IN ('int_func_index', 'string_func_index'); +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE EXPRESSION +def test t1 1 test int_func_index 1 NULL A 1 NULL NULL YES BTREE YES abs(`int_col`) +def test t1 1 test string_func_index 1 NULL A 2 NULL NULL YES BTREE YES substr(`string_col`,1,2) +# INFORMATION_SCHEMA.COLUMNS should not show the hidden generated +# columns. +SELECT COUNT(*) AS should_be_2 FROM INFORMATION_SCHEMA.COLUMNS +WHERE TABLE_NAME = "t1"; +should_be_2 +2 +# INFORMATION_SCHEMA.INNODB_COLUMNS should not show the hidden generated +# columns. +SELECT COUNT(*) AS should_be_2 FROM INFORMATION_SCHEMA.INNODB_COLUMNS c +JOIN INFORMATION_SCHEMA.INNODB_TABLES t ON (c.TABLE_ID = t.TABLE_ID) +WHERE t.NAME = "test/t1"; +should_be_2 +2 +# The optimizer should be able to make use of the functional index. +# Also, the query printed as a warning from EXPLAIN should display the +# expression and not the name of the hidden generated column. +EXPLAIN SELECT * FROM t1 WHERE SUBSTRING(string_col, 1, 2) = "fo"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref string_func_index string_func_index 11 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`int_col` AS `int_col`,`test`.`t1`.`string_col` AS `string_col` from `test`.`t1` where (substr(`string_col`,1,2) = 'fo') +EXPLAIN SELECT * FROM t1 WHERE ABS(int_col) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref int_func_index int_func_index 5 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`int_col` AS `int_col`,`test`.`t1`.`string_col` AS `string_col` from `test`.`t1` where (abs(`int_col`) = 1) +# Creating multiple nameless functional indexes should automatically +# generate new names that doesn't collide. +CREATE TABLE t2 ( +col1 INT, +INDEX ((col1 * 2)), +INDEX ((col1 * 4)), +INDEX ((col1 * 6))); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `col1` int DEFAULT NULL, + KEY `functional_index` (((`col1` * 2))), + KEY `functional_index_2` (((`col1` * 4))), + KEY `functional_index_3` (((`col1` * 6))) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +# Adding a multi-column index with both a functional part and a +# non-functional part should work just fine. +CREATE INDEX combined_index ON t1 ((int_col + int_col), string_col); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `int_col` int DEFAULT NULL, + `string_col` varchar(255) DEFAULT NULL, + KEY `int_func_index` ((abs(`int_col`))), + KEY `string_func_index` ((substr(`string_col`,1,2))), + KEY `combined_index` (((`int_col` + `int_col`)),`string_col`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# ...and, the optimizer should be able to use this multi-column index +EXPLAIN SELECT * FROM t1 WHERE int_col + int_col = 2 AND string_col = "bar"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref combined_index combined_index 1032 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`int_col` AS `int_col`,`test`.`t1`.`string_col` AS `string_col` from `test`.`t1` where ((`test`.`t1`.`string_col` = 'bar') and ((`int_col` + `int_col`) = 2)) +# Test that if we have a string column with the same name as a function, +# we will pick the function. To pick the column, skip the enclosing +# parentheses around the expression. +ALTER TABLE t1 ADD COLUMN rand VARCHAR(255); +CREATE INDEX name_collision ON t1 ((rand(2))); +ERROR HY000: Expression of functional index 'name_collision' contains a disallowed function. +CREATE INDEX name_collision ON t1 ((`rand`(2))); +ERROR HY000: Expression of functional index 'name_collision' contains a disallowed function. +DROP TABLE t1; +# Check that in case of errors when saving data to the generated column, +# the functional index name is printed and not the auto generated name +# of the generated column. +CREATE TABLE t1 (f1 JSON, f2 VARCHAR(255)); +CREATE INDEX my_functional_index ON t1 ((CAST(f1 AS DECIMAL(2, 1)))); +CREATE INDEX my_functional_index_2 ON t1 ((CAST(f2 AS CHAR(1)))); +CREATE INDEX idx1 ON t1 ((CAST(f2 AS JSON))); +ERROR 42000: Cannot create a functional index on a function that returns a JSON or GEOMETRY value. +INSERT INTO t1 (f1) VALUES (CAST(1000 AS JSON)); +ERROR 22003: Value is out of range for functional index 'my_functional_index' at row 1 +INSERT INTO t1 (f2) VALUES ("lorem ipsum"); +ERROR 01000: Data truncated for functional index 'my_functional_index_2' at row 1 +# In non-strict mode, a warning should be printed. +SET @@sql_mode=''; +INSERT INTO t1 (f1) VALUES (CAST(1000 AS JSON)); +Warnings: +Warning 3752 Value is out of range for functional index 'my_functional_index' at row 1 +INSERT INTO t1 (f2) VALUES ("lorem ipsum"); +Warnings: +Warning 3751 Data truncated for functional index 'my_functional_index_2' at row 1 +DROP TABLE t1; +SET @@sql_mode=DEFAULT; +CREATE TABLE t1 (t1_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE INDEX idx1 ON t1 ((t1_id + t1_id)); +ERROR HY000: Functional index 'idx1' cannot refer to an auto-increment column. +DROP TABLE t1; +# Check that "SHOW KEYS" prints out the expression for generated columns +# (Column_name should be NULL, and Expression should contain the +# expression). +CREATE TABLE t1 (col1 INT, col2 INT); +CREATE INDEX idx1 ON t1 (col1, (col1 + col2)); +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 idx1 1 col1 A 0 NULL NULL YES BTREE YES NULL +t1 1 idx1 2 NULL A 0 NULL NULL YES BTREE YES (`col1` + `col2`) +# Create a funtional index with many functional key parts +# Check that if we try to add a column with the same name as a hidden +# column, we get an internal error. The column name of the generated +# column is calculated as MD5(index_name + key_part_number). +SELECT MD5(CONCAT("idx1", "1")); +MD5(CONCAT("idx1", "1")) +56fb28970273a50c6f31dec0fe3b175b +ALTER TABLE t1 ADD COLUMN `56fb28970273a50c6f31dec0fe3b175b` INT NOT NULL; +ERROR HY000: Internal error: The column name '56fb28970273a50c6f31dec0fe3b175b' is already in use by a hidden column +DROP TABLE t1; +# Creating a functional index on already existing columns using +# ALTER TABLE should work just fine. +CREATE TABLE t1 (col1 INT, col2 INT); +ALTER TABLE t1 ADD INDEX ((ABS(col1))), ADD INDEX ((ABS(col2))); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `col1` int DEFAULT NULL, + `col2` int DEFAULT NULL, + KEY `functional_index` ((abs(`col1`))), + KEY `functional_index_2` ((abs(`col2`))) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# Adding a functional index to a column that is created in the same +# ALTER TABLE statement should work. +ALTER TABLE t1 ADD COLUMN col3 INT, ADD INDEX ((col1 - col3)); +DROP TABLE t1; +# Adding a functional index using CREATE TABLE should work +CREATE TABLE t1 (col1 INT, INDEX ((ABS(col1)))); +DROP TABLE t1; +# Print out functional indexes on a temporary table. Note that +# "Column_name" should be empty (NULL), and Expression should contain the +# expression for the functional index. +CREATE TEMPORARY TABLE t1(a INT); +CREATE INDEX idx ON t1 ((ABS(a))); +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 idx 1 A 0 NULL NULL YES BTREE YES abs(`a`) +DROP TABLE t1; +CREATE TABLE t1 (col1 INT, INDEX ((CONCAT('')))); +ERROR HY000: The used storage engine cannot index the expression 'concat(_utf8mb4'')'. +# Check that a functional index cannot be a part of the primary key +CREATE TABLE t1 (col1 INT, PRIMARY KEY ((ABS(col1)))); +ERROR HY000: The primary key cannot be a functional index +CREATE TABLE t1 (col1 INT, PRIMARY KEY (col1, (ABS(col1)))); +ERROR HY000: The primary key cannot be a functional index +CREATE TABLE t1 (col1 INT, col2 INT, PRIMARY KEY (col1, (ABS(col1)), col2)); +ERROR HY000: The primary key cannot be a functional index +CREATE TABLE t1 (col1 INT, col2 INT); +ALTER TABLE t1 ADD PRIMARY KEY ((ABS(col1))); +ERROR HY000: The primary key cannot be a functional index +ALTER TABLE t1 ADD PRIMARY KEY (col2, (ABS(col1))); +ERROR HY000: The primary key cannot be a functional index +ALTER TABLE t1 ADD PRIMARY KEY (col1, col2, (ABS(col1))); +ERROR HY000: The primary key cannot be a functional index +DROP TABLE t1; +# Check that descending functional index works +CREATE TABLE t1 (col1 INT, INDEX ((ABS(col1)) DESC)); +EXPLAIN SELECT col1 FROM t1 WHERE ABS(col1) < 1 ORDER BY ABS(col1) DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range functional_index functional_index 5 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (abs(`col1`) < 1) order by abs(`test`.`t1`.`col1`) desc +DROP TABLE t1; +# Test integer index over a JSON key +CREATE TABLE t1(f1 JSON, INDEX idx1 ((CAST(f1->"$.id" AS UNSIGNED)))); +INSERT INTO t1 VALUES(CAST('{"id":1}' AS JSON)), (CAST('{"id":2}' AS JSON)), +(CAST('{"id":3}' AS JSON)), (CAST('{"id":4}' AS JSON)), +(CAST('{"id":5}' AS JSON)), (CAST('{"id":6}' AS JSON)), +(CAST('{"id":7}' AS JSON)), (CAST('{"id":8}' AS JSON)), +(CAST('{"id":9}' AS JSON)), (CAST('{"id":10}' AS JSON)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE f1->"$.id"= 5; +f1 +{"id": 5} +EXPLAIN SELECT * FROM t1 WHERE f1->"$.id"= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref idx1 idx1 9 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (cast(json_extract(`f1`,_utf8mb4'$.id') as unsigned) = 5) +SELECT * FROM t1 WHERE f1->"$.id" IN (1,2,3); +f1 +{"id": 1} +{"id": 2} +{"id": 3} +EXPLAIN SELECT * FROM t1 WHERE f1->"$.id" IN (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx1 idx1 9 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (cast(json_extract(`f1`,_utf8mb4'$.id') as unsigned) in (1,2,3)) +DROP TABLE t1; +Test string index over a JSON key +CREATE TABLE t1(f1 JSON, INDEX idx1 ((CAST(f1->>"$.id" AS CHAR(10))))); +INSERT INTO t1 VALUES +(CAST('{"id":"a"}' AS JSON)), (CAST('{"id":"b"}' AS JSON)), +(CAST('{"id":"v"}' AS JSON)), (CAST('{"id":"c"}' AS JSON)), +(CAST('{"id":"x"}' AS JSON)), (CAST('{"id":"\'z"}' AS JSON)), + (JSON_OBJECT("id",JSON_QUOTE("n"))), (CAST('{"id":"w"}' AS JSON)), + (CAST('{"id":"m"}' AS JSON)), (CAST('{"id":"q"}' AS JSON)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE CAST(f1->>"$.id" AS CHAR(10)) = "\"n\""; +f1 +{"id": "\"n\""} +EXPLAIN SELECT * FROM t1 WHERE CAST(f1->>"$.id" AS CHAR(10)) = "\"n\""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref idx1 idx1 43 const 1 100.00 NULL +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (cast(json_unquote(json_extract(`f1`,_utf8mb4'$.id')) as char(10) charset utf8mb4) = '"n"') +Warnings: +SELECT * FROM t1 WHERE CAST(f1->>"$.id" AS CHAR(10)) IN ("'z", "\"n\"","a"); +f1 +{"id": "'z"} +{"id": "\"n\""} +{"id": "a"} +EXPLAIN SELECT * FROM t1 WHERE CAST(f1->>"$.id" AS CHAR(10)) IN ("'z", "\"n\"","a"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx1 idx1 43 NULL 3 100.00 Using where +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (cast(json_unquote(json_extract(`f1`,_utf8mb4'$.id')) as char(10) charset utf8mb4) in ('\'z','"n"','a')) +Warnings: +DROP TABLE t1; +CREATE TABLE t1(f1 JSON, INDEX idx1 ((CAST(f1->>"$.name" AS CHAR(30)) COLLATE utf8mb4_bin))); +INSERT INTO t1 VALUES +('{"name": "james"}'), +('{"name": "JAMES"}'), +('{"name": "Peter"}'), +('{"name": "parker"}'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Should not return any rows, and should use the index +SELECT * FROM t1 WHERE f1->>"$.name" = "James"; +f1 +EXPLAIN SELECT * FROM t1 WHERE f1->>"$.name" = "James"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref idx1 idx1 123 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((cast(json_unquote(json_extract(`f1`,_utf8mb4'$.name')) as char(30) charset utf8mb4) collate utf8mb4_bin) = 'James') +# Should return one row, and should use the index +SELECT * FROM t1 WHERE f1->>"$.name" = "james"; +f1 +{"name": "james"} +EXPLAIN SELECT * FROM t1 WHERE f1->>"$.name" = "james"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref idx1 idx1 123 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((cast(json_unquote(json_extract(`f1`,_utf8mb4'$.name')) as char(30) charset utf8mb4) collate utf8mb4_bin) = 'james') +# Should return one row, and should use the index +SELECT * FROM t1 WHERE CAST(f1->>"$.name" AS CHAR(30)) COLLATE utf8mb4_bin = "james"; +f1 +{"name": "james"} +EXPLAIN SELECT * FROM t1 WHERE CAST(f1->>"$.name" AS CHAR(30)) COLLATE utf8mb4_bin = "james"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref idx1 idx1 123 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((cast(json_unquote(json_extract(`f1`,_utf8mb4'$.name')) as char(30) charset utf8mb4) collate utf8mb4_bin) = 'james') +DROP TABLE t1; +# Test that doing an UPDATE on a hidden generated column returns "column +# not found". +CREATE TABLE t1 (col1 INT, INDEX idx1 ((col1 + col1))); +# Get the expected name of the hidden generated column. +SELECT MD5(CONCAT("idx1", "0")); +MD5(CONCAT("idx1", "0")) +45197ac678c1210c4a64bf22351853e7 +UPDATE t1 SET 45197ac678c1210c4a64bf22351853e7 = 123; +ERROR 42S22: Unknown column '45197ac678c1210c4a64bf22351853e7' in 'field list' +DROP TABLE t1; +# +# Bug#28037245 VIRTUAL COLUMN IS ALLOWED IN THE WHERE CLAUSE FOR SQL +# QUERY +# +CREATE TABLE t3 (c1 INT); +CREATE INDEX int_func_index ON t3 ((ABS(c1))); +# Get the expected column name of the functional index +SELECT MD5(CONCAT('int_func_index', '0')); +MD5(CONCAT('int_func_index', '0')) +7cf759b4f03e729c90aa40cc68dd8780 +SELECT * FROM t3 WHERE 7cf759b4f03e729c90aa40cc68dd8780=1; +ERROR 42S22: Unknown column '7cf759b4f03e729c90aa40cc68dd8780' in 'where clause' +DROP TABLE t3; +# +# Bug#28037375 ALTER TABLE DROP OF A NORMAL COLUMN RAISES ERROR +# +CREATE TABLE t6 (c1 INT, c2 INT); +CREATE INDEX int_func_index ON t6 ((ABS(c1))); +ALTER TABLE t6 DROP COLUMN c2; +DROP TABLE t6; +# Check that a functional index on a function that returns geometry data +# isn't allowed. +CREATE TABLE t1(x VARCHAR(100), KEY ((ST_GeomFromText(x)))); +ERROR HY000: Spatial functional index is not supported. +# See that we don't print out the names of the hidden generated columns, +# but rather the expression that they represent. +CREATE TABLE t1(x VARCHAR(30), INDEX idx ((CAST(x->>'$.name' AS CHAR(30))))); +INSERT INTO t1 VALUES ('{"name":"knut"}'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE CAST(x->>'$.name' AS CHAR(30)) = 'knut'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "idx" + ], + "key": "idx", + "used_key_parts": [ + "cast(json_unquote(json_extract(`x`,_utf8mb4'$.name')) as char(30) charset utf8mb4)" + ], + "key_length": "123", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "248" + }, + "used_columns": [ + "x", + "cast(json_unquote(json_extract(`x`,_utf8mb4'$.name')) as char(30) charset utf8mb4)" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x` from `test`.`t1` where (cast(json_unquote(json_extract(`x`,_utf8mb4'$.name')) as char(30) charset utf8mb4) = 'knut') +DROP TABLE t1; +# Check that we cannot drop the last visible column when we have hidden +# generated columns. +CREATE TABLE t(x INT, KEY((1+1))); +ALTER TABLE t DROP COLUMN x; +ERROR HY000: A table must have at least one visible column. +DROP TABLE t; +# See that we print out the correct error message in case of duplicate +# index names. +CREATE TABLE t (x INT); +CREATE INDEX idx ON t ((x+1)); +CREATE INDEX idx ON t ((x+2)); +ERROR 42000: Duplicate key name 'idx' +DROP TABLE t; +# +# Bug#28206859 SERVER CRASHED WHEN NORMAL INDEX WAS CREATED USING NEW +# FUNCTIONAL INDEX SYNTAX +# +CREATE TABLE t2(a INT, b INT, INDEX id2 ((a))); +ERROR HY000: Functional index on a column is not supported. Consider using a regular index instead. +# +# Bug#28206912 ASSERTION `TABLE_LIST->TABLE' FAILED. +# +CREATE TABLE t2(a INT, b INT, INDEX id2 ((a+b+c))); +ERROR 42S22: Unknown column 'c' in 'functional index' +# +# Bug#28216475 SIG 11 IN ITEM_FIELD::REPLACE_FIELD_PROCESSOR DURING +# CREATE TABLE +# +CREATE TABLE IF NOT EXISTS table470 ( pk INTEGER AUTO_INCREMENT, a1 +VARCHAR(3) NOT NULL, b1 DATETIME NOT NULL, c1 TEXT NOT NULL, d1 TEXT NULL, +PRIMARY KEY (a1), KEY ((VALUES(d1)))); +ERROR HY000: Expression of functional index 'functional_index' contains a disallowed function. +CREATE TABLE table44 ( pk INTEGER AUTO_INCREMENT, a1 TEXT NOT NULL, b1 +DATETIME NOT NULL, c1 TIME NOT NULL, d1 BLOB NOT NULL, PRIMARY KEY (a1), KEY +((VALUES(d1)))); +ERROR HY000: Expression of functional index 'functional_index' contains a disallowed function. +# +# Bug #28222789 SIG 11 IN BITMAP<64U>::INTERSECT DURING CREATE INDEX +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_time_nokey time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_datetime_nokey datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key), +KEY ind25 ((dayofmonth(col_time_nokey))), +KEY ind211 ((cast(col_date_nokey as date))), +KEY ind602 ((is_uuid(col_time_nokey))) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 +COLLATE=utf8mb4_0900_ai_ci; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE INDEX ind320 ON t1 ((pk >= col_time_nokey LIKE +ST_GeomFromGeoJSON(col_varchar_key) )); +ERROR HY000: Incorrect arguments to like +DROP TABLE t1; +# +# Bug#28218591 WRONG ERROR MESSAGE WHILE CREATING FUNCTIONAL INDEX +# +CREATE TABLE t(a INT, b INT, INDEX c((null))); +ERROR HY000: The used storage engine cannot index the expression 'NULL'. +# Blank functional index name should give a "Incorrect index name" error +CREATE TABLE t1(x INT, KEY `` ((x + 1))); +ERROR 42000: Incorrect index name '' +# Check that we don't use the functional index in case of a collation +# mismatch +CREATE TABLE t(x VARCHAR(10), KEY k ((CAST(CONCAT(x,x) AS BINARY)))); +INSERT INTO t VALUES ('x'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * FROM t WHERE CONCAT(x,x) = 'XX'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`x` AS `x` from `test`.`t` where (concat(`test`.`t`.`x`,`test`.`t`.`x`) = 'XX') +DROP TABLE t; +# +# Bug#28244585 ERROR WHILE CREATING TABLE WITH FUNCTIONAL INDEXES INSIDE +# PROCEDURES. +CREATE PROCEDURE p1() BEGIN +CREATE TABLE t(a INT,b INT,UNIQUE INDEX i((a+b))); +END// +CALL p1(); +CALL p1(); +ERROR 42S01: Table 't' already exists +DROP TABLE t; +CALL p1(); +DROP TABLE t; +DROP PROCEDURE p1; +# Code coverage tests +CREATE TABLE t1 ( +col1 FLOAT +, col2 TIMESTAMP +, col3 YEAR +, INDEX ((ABS(col1))) +, INDEX ((ADDDATE(col2, INTERVAL 2 DAY))) +, INDEX ((ABS(col3))) +); +DROP TABLE t1; +CREATE TABLE t1 ( +col4 TEXT NOT NULL +, INDEX ((ST_AsBinary(col4))) +); +ERROR HY000: Cannot create a functional index on an expression that returns a BLOB or TEXT. Please consider using CAST. +# See that we get a reasonable error message when trying to remove a +# column that is a part of a functional index. +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, INDEX idx ((col1 + col2 + col3))); +ALTER TABLE t1 DROP COLUMN col2; +ERROR HY000: Column 'col2' has a functional index dependency and cannot be dropped or renamed. +ALTER TABLE t1 DROP COLUMN col3; +ERROR HY000: Column 'col3' has a functional index dependency and cannot be dropped or renamed. +ALTER TABLE t1 DROP INDEX idx; +ALTER TABLE t1 DROP COLUMN col3; +DROP TABLE t1; +# Check that INFORMATION_SCHEMA.KEY_COLUMN_USAGE doesn't reveal any +# functional indexes, since this view provides information about columns +# and a functional index does not represent a column per se. +CREATE TABLE t ( +col1 INT +, UNIQUE INDEX regular_index (col1) +, UNIQUE INDEX functional_index ((ABS(col1)))); +SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name = "t"; +CONSTRAINT_NAME +regular_index +DROP TABLE t; +# +# Bug#28526493 ASSERTION WHEN CREATING A FUNCTIONAL INDEX ON A SUBQUERY +# +CREATE TABLE t1 (x INT); +CREATE TABLE t2 (y INT, KEY (((SELECT * FROM t1)))); +ERROR HY000: Expression of functional index 'functional_index' contains a disallowed function. +CREATE TABLE t2 (y INT, KEY (((SELECT x FROM t1)))); +ERROR HY000: Expression of functional index 'functional_index' contains a disallowed function. +CREATE TABLE t2 (y INT, KEY (((SELECT 1 FROM t1)))); +ERROR HY000: Expression of functional index 'functional_index' contains a disallowed function. +DROP TABLE t1; +# +# Bug#28643252 ASSERT FAILURE WHEN FUNCTIONAL INDEX EXPRESSION IS A LIST +# +CREATE TABLE t (j JSON, KEY k (((j,j)))); +ERROR HY000: Expression of functional index 'k' cannot refer to a row value. +# +# Bug#29360763 WL#1075: FUNCTIONAL INDEX: INCORRECT ERROR MESSAGE REVEALS +# HIDDEN COLUMN NAME +# +CREATE TABLE t1 ( +j1 JSON, +j3 JSON, +KEY my_idx ((CAST(j1->'$[0]' as SIGNED))), +KEY my_idx_char ((CAST(j3->'$[0]' as CHAR(10)))) +); +ALTER TABLE t1 RENAME KEY my_idx_char TO my_idx; +ERROR 42000: Duplicate key name 'my_idx' +DROP TABLE t1; +# +# Bug#29317684 REPLICATION IS SENSITIVE TO ORDER OF HIDDEN COLUMNS FOR +# FUNCTIONAL INDEXES +# +CREATE TABLE t1 (col1 INT, INDEX ((col1 + col1))); +SELECT COLUMN_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS +WHERE TABLE_NAME = "t1"; +COLUMN_NAME ORDINAL_POSITION +col1 1 +ALTER TABLE t1 ADD COLUMN col2 INT; +SELECT COLUMN_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS +WHERE TABLE_NAME = "t1"; +COLUMN_NAME ORDINAL_POSITION +col1 1 +col2 2 +DROP TABLE t1; +# See that INSTANT ADD COLUMN still works with this bugfix. +CREATE TABLE t1 (col1 INT, col2 INT AS (col1 + col1), INDEX (col2)); +ALTER TABLE t1 ADD COLUMN new_col INT AFTER col1, ALGORITHM=INSTANT; +DROP TABLE t1; +# +# Bug#29934661 FUNCTIONAL INDEX SEEMS TO MALFUNCTION WITH UNSIGNED COLUMN +# +# The hidden column that is added should have a data type that can store +# the absolute value of an unsigned data type. +CREATE TABLE t0(c0 INT UNSIGNED, INDEX idx ((ABS(c0)))); +INSERT INTO t0 (c0) VALUES (4294967294); +DROP TABLE t0; +# +# Bug#29723353: ADDING FUNCTIONAL INDEX ON JSON EXPRESSION CHANGES RESULT +# +CREATE TABLE t(j JSON); +INSERT INTO t VALUES ('{"x":"abc"}'), ('{"x":"ABC"}'); +SELECT * FROM t WHERE j->>'$.x' = 'abc'; +j +{"x": "abc"} +SELECT * FROM t WHERE j->'$.x' = 'abc'; +j +{"x": "abc"} +CREATE INDEX idx ON t((CAST(j->>'$.x' AS CHAR(100)))); +SELECT * FROM t WHERE j->>'$.x' = 'abc'; +j +{"x": "abc"} +SELECT * FROM t WHERE j->'$.x' = 'abc'; +j +{"x": "abc"} +ALTER TABLE t DROP INDEX idx; +CREATE INDEX idx ON t((CAST(j->'$.x' AS CHAR(100)))); +SELECT * FROM t WHERE j->>'$.x' = 'abc'; +j +{"x": "abc"} +SELECT * FROM t WHERE j->'$.x' = 'abc'; +j +{"x": "abc"} +DROP TABLE t; +## +## Bug #31017765 CREATE TABLE ... SELECT FAILS IF THERE IS A FUNCTIONAL INDEX +## +## +CREATE TEMPORARY TABLE issue_functional_key_part ( +sold_on DATETIME NOT NULL DEFAULT NOW(), +INDEX sold_on_date ((DATE(sold_on))) +) +SELECT NOW() `sold_on`; +# +# Bug#30838749: PERFORMANCE DROP WHEN CREATING A FUNCTIONAL INDEX +# +CREATE TABLE t1(x INT, KEY k ((x+1))); +CREATE TABLE t2(j JSON); +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug30838749' INTO TABLE t2 +LINES STARTING BY 'EXPLAIN' TERMINATED BY 'EOL'; +SELECT j->'$**.used_columns' FROM t2; +j->'$**.used_columns' +[["x"], ["x"]] +DROP TABLE t1, t2; +# +# Bug#32287186: FAILED TO CREATE FUNCTION INDEX, +# COLUMN NAME IS UPPERCASE CHARACTER +# +# Verify that normal index creation is case-insensitive on +# column name +CREATE TABLE t1 (id INT, name VARCHAR(50), INDEX (NAME)); +CREATE TABLE t2 (id INT, name VARCHAR(50), INDEX (name)); +CREATE TABLE t3 (id INT, NAME VARCHAR(50), INDEX (name)); +CREATE TABLE t4 (id INT, NAME VARCHAR(50), INDEX (NAME)); +# Now verify that functional index creation is case-insensitive +# on column name as well +CREATE TABLE t5 (id INT, name VARCHAR(50), +INDEX ((SUBSTR(name, 1, 2)))); +CREATE TABLE t6 (id INT, name VARCHAR(50), +INDEX ((SUBSTR(NAME, 1, 2)))); +CREATE TABLE t7 (id INT, NAME VARCHAR(50), +INDEX ((SUBSTR(name, 1, 2)))); +CREATE TABLE t8 (id INT, NAME VARCHAR(50), +INDEX ((SUBSTR(NAME, 1, 2)))); +# Cleanup +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE t4; +DROP TABLE t5; +DROP TABLE t6; +DROP TABLE t7; +DROP TABLE t8; diff --git a/mysql-test/r/greedy_search.result-pq b/mysql-test/r/greedy_search.result-pq new file mode 100644 index 000000000..de716d4bb --- /dev/null +++ b/mysql-test/r/greedy_search.result-pq @@ -0,0 +1,220 @@ +UPDATE mysql.engine_cost +SET cost_value = 1.0 +WHERE cost_name = 'memory_block_read_cost'; +FLUSH OPTIMIZER_COSTS; +# +# TEST 1 +# Greedy search iteration test for 16-way join: star schema +# +# Creation of 16 tables hidden +# +SET SESSION optimizer_search_depth = 25; +FLUSH STATUS; +# +# 16-way join - all 15 fact tables joined on column with key +# +EXPLAIN SELECT * +FROM vehicles +JOIN models ON vehicles.model_id = models.id_pk +JOIN subtypes ON vehicles.subtype_id = subtypes.id_pk +JOIN colors ON vehicles.color_id = colors.id_pk +JOIN heating ON vehicles.heating_id = heating.id_pk +JOIN windows ON vehicles.window_id = windows.id_pk +JOIN fuels ON vehicles.fuel_id = fuels.id_pk +JOIN transmissions ON vehicles.transmission_id = transmissions.id_pk +JOIN steerings ON vehicles.steering_id = steerings.id_pk +JOIN interiors ON vehicles.interior_id = interiors.id_pk +JOIN drives ON vehicles.drive_id = drives.id_pk +JOIN wheels ON vehicles.wheels_id = wheels.id_pk +JOIN engine ON vehicles.engine_id = engine.id_pk +JOIN price_ranges ON vehicles.price_range_id = price_ranges.id_pk +JOIN countries ON vehicles.assembled_in = countries.id_pk +JOIN brands ON models.brand_id = brands.id_pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE subtypes NULL ALL PRIMARY NULL NULL NULL 10 100.00 NULL +2 SIMPLE vehicles NULL ALL NULL NULL NULL NULL 80 10.00 Using where; Using join buffer (hash join) +2 SIMPLE heating NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.heating_id 1 100.00 NULL +2 SIMPLE windows NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.window_id 1 100.00 NULL +2 SIMPLE fuels NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.fuel_id 1 100.00 NULL +2 SIMPLE transmissions NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.transmission_id 1 100.00 NULL +2 SIMPLE steerings NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.steering_id 1 100.00 NULL +2 SIMPLE drives NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.drive_id 1 100.00 NULL +2 SIMPLE wheels NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.wheels_id 1 100.00 NULL +2 SIMPLE engine NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.engine_id 1 100.00 NULL +2 SIMPLE price_ranges NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.price_range_id 1 100.00 NULL +2 SIMPLE colors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.color_id 1 100.00 NULL +2 SIMPLE interiors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.interior_id 1 100.00 NULL +2 SIMPLE countries NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.assembled_in 1 100.00 NULL +2 SIMPLE models NULL eq_ref PRIMARY,brand_id PRIMARY 4 test.vehicles.model_id 1 100.00 Using where +2 SIMPLE brands NULL eq_ref PRIMARY PRIMARY 4 test.models.brand_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`vehicles`.`id` AS `id`,`test`.`vehicles`.`model_id` AS `model_id`,`test`.`vehicles`.`subtype_id` AS `subtype_id`,`test`.`vehicles`.`color_id` AS `color_id`,`test`.`vehicles`.`heating_id` AS `heating_id`,`test`.`vehicles`.`window_id` AS `window_id`,`test`.`vehicles`.`fuel_id` AS `fuel_id`,`test`.`vehicles`.`transmission_id` AS `transmission_id`,`test`.`vehicles`.`steering_id` AS `steering_id`,`test`.`vehicles`.`interior_id` AS `interior_id`,`test`.`vehicles`.`drive_id` AS `drive_id`,`test`.`vehicles`.`price_range_id` AS `price_range_id`,`test`.`vehicles`.`assembled_in` AS `assembled_in`,`test`.`vehicles`.`engine_id` AS `engine_id`,`test`.`vehicles`.`wheels_id` AS `wheels_id`,`test`.`models`.`id_pk` AS `id_pk`,`test`.`models`.`id_nokey` AS `id_nokey`,`test`.`models`.`brand_id` AS `brand_id`,`test`.`models`.`name` AS `name`,`test`.`subtypes`.`id_pk` AS `id_pk`,`test`.`subtypes`.`id_nokey` AS `id_nokey`,`test`.`subtypes`.`name` AS `name`,`test`.`colors`.`id_pk` AS `id_pk`,`test`.`colors`.`id_nokey` AS `id_nokey`,`test`.`colors`.`name` AS `name`,`test`.`heating`.`id_pk` AS `id_pk`,`test`.`heating`.`id_nokey` AS `id_nokey`,`test`.`heating`.`name` AS `name`,`test`.`windows`.`id_pk` AS `id_pk`,`test`.`windows`.`id_nokey` AS `id_nokey`,`test`.`windows`.`name` AS `name`,`test`.`fuels`.`id_pk` AS `id_pk`,`test`.`fuels`.`id_nokey` AS `id_nokey`,`test`.`fuels`.`name` AS `name`,`test`.`transmissions`.`id_pk` AS `id_pk`,`test`.`transmissions`.`id_nokey` AS `id_nokey`,`test`.`transmissions`.`name` AS `name`,`test`.`steerings`.`id_pk` AS `id_pk`,`test`.`steerings`.`id_nokey` AS `id_nokey`,`test`.`steerings`.`name` AS `name`,`test`.`interiors`.`id_pk` AS `id_pk`,`test`.`interiors`.`id_nokey` AS `id_nokey`,`test`.`interiors`.`name` AS `name`,`test`.`drives`.`id_pk` AS `id_pk`,`test`.`drives`.`id_nokey` AS `id_nokey`,`test`.`drives`.`name` AS `name`,`test`.`wheels`.`id_pk` AS `id_pk`,`test`.`wheels`.`id_nokey` AS `id_nokey`,`test`.`wheels`.`name` AS `name`,`test`.`engine`.`id_pk` AS `id_pk`,`test`.`engine`.`id_nokey` AS `id_nokey`,`test`.`engine`.`name` AS `name`,`test`.`price_ranges`.`id_pk` AS `id_pk`,`test`.`price_ranges`.`id_nokey` AS `id_nokey`,`test`.`price_ranges`.`name` AS `name`,`test`.`countries`.`id_pk` AS `id_pk`,`test`.`countries`.`id_nokey` AS `id_nokey`,`test`.`countries`.`name` AS `name`,`test`.`brands`.`id_pk` AS `id_pk`,`test`.`brands`.`id_nokey` AS `id_nokey`,`test`.`brands`.`name` AS `name` from `test`.`vehicles` join `test`.`models` join `test`.`subtypes` join `test`.`colors` join `test`.`heating` join `test`.`windows` join `test`.`fuels` join `test`.`transmissions` join `test`.`steerings` join `test`.`interiors` join `test`.`drives` join `test`.`wheels` join `test`.`engine` join `test`.`price_ranges` join `test`.`countries` join `test`.`brands` where ((`test`.`models`.`id_pk` = `test`.`vehicles`.`model_id`) and (`test`.`vehicles`.`subtype_id` = `test`.`subtypes`.`id_pk`) and (`test`.`colors`.`id_pk` = `test`.`vehicles`.`color_id`) and (`test`.`heating`.`id_pk` = `test`.`vehicles`.`heating_id`) and (`test`.`windows`.`id_pk` = `test`.`vehicles`.`window_id`) and (`test`.`fuels`.`id_pk` = `test`.`vehicles`.`fuel_id`) and (`test`.`transmissions`.`id_pk` = `test`.`vehicles`.`transmission_id`) and (`test`.`steerings`.`id_pk` = `test`.`vehicles`.`steering_id`) and (`test`.`interiors`.`id_pk` = `test`.`vehicles`.`interior_id`) and (`test`.`drives`.`id_pk` = `test`.`vehicles`.`drive_id`) and (`test`.`wheels`.`id_pk` = `test`.`vehicles`.`wheels_id`) and (`test`.`engine`.`id_pk` = `test`.`vehicles`.`engine_id`) and (`test`.`price_ranges`.`id_pk` = `test`.`vehicles`.`price_range_id`) and (`test`.`countries`.`id_pk` = `test`.`vehicles`.`assembled_in`) and (`test`.`brands`.`id_pk` = `test`.`models`.`brand_id`)) +### Partial_plans: 338288 +FLUSH STATUS; +# +# 16-way join - 10 fact tables joined on column with key and +# 5 fact tables joined on column without key +# +EXPLAIN SELECT * +FROM vehicles +JOIN models ON vehicles.model_id = models.id_nokey +JOIN subtypes ON vehicles.subtype_id = subtypes.id_pk +JOIN colors ON vehicles.color_id = colors.id_pk +JOIN heating ON vehicles.heating_id = heating.id_nokey +JOIN windows ON vehicles.window_id = windows.id_pk +JOIN fuels ON vehicles.fuel_id = fuels.id_pk +JOIN transmissions ON vehicles.transmission_id = transmissions.id_nokey +JOIN steerings ON vehicles.steering_id = steerings.id_pk +JOIN interiors ON vehicles.interior_id = interiors.id_pk +JOIN drives ON vehicles.drive_id = drives.id_pk +JOIN wheels ON vehicles.wheels_id = wheels.id_nokey +JOIN engine ON vehicles.engine_id = engine.id_pk +JOIN price_ranges ON vehicles.price_range_id = price_ranges.id_pk +JOIN countries ON vehicles.assembled_in = countries.id_pk +JOIN brands ON models.brand_id = brands.id_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE brands NULL ALL NULL NULL NULL NULL 7 100.00 Using where +2 SIMPLE models NULL ref brand_id brand_id 5 test.brands.id_nokey 5 100.00 NULL +2 SIMPLE vehicles NULL ALL NULL NULL NULL NULL 80 10.00 Using where; Using join buffer (hash join) +2 SIMPLE heating NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE windows NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.window_id 1 100.00 NULL +2 SIMPLE fuels NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.fuel_id 1 100.00 NULL +2 SIMPLE steerings NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.steering_id 1 100.00 NULL +2 SIMPLE drives NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.drive_id 1 100.00 NULL +2 SIMPLE engine NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.engine_id 1 100.00 NULL +2 SIMPLE price_ranges NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.price_range_id 1 100.00 NULL +2 SIMPLE interiors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.interior_id 1 100.00 NULL +2 SIMPLE countries NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.assembled_in 1 100.00 NULL +2 SIMPLE subtypes NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.subtype_id 1 100.00 NULL +2 SIMPLE colors NULL eq_ref PRIMARY PRIMARY 4 test.vehicles.color_id 1 100.00 NULL +2 SIMPLE transmissions NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE wheels NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`vehicles`.`id` AS `id`,`test`.`vehicles`.`model_id` AS `model_id`,`test`.`vehicles`.`subtype_id` AS `subtype_id`,`test`.`vehicles`.`color_id` AS `color_id`,`test`.`vehicles`.`heating_id` AS `heating_id`,`test`.`vehicles`.`window_id` AS `window_id`,`test`.`vehicles`.`fuel_id` AS `fuel_id`,`test`.`vehicles`.`transmission_id` AS `transmission_id`,`test`.`vehicles`.`steering_id` AS `steering_id`,`test`.`vehicles`.`interior_id` AS `interior_id`,`test`.`vehicles`.`drive_id` AS `drive_id`,`test`.`vehicles`.`price_range_id` AS `price_range_id`,`test`.`vehicles`.`assembled_in` AS `assembled_in`,`test`.`vehicles`.`engine_id` AS `engine_id`,`test`.`vehicles`.`wheels_id` AS `wheels_id`,`test`.`models`.`id_pk` AS `id_pk`,`test`.`models`.`id_nokey` AS `id_nokey`,`test`.`models`.`brand_id` AS `brand_id`,`test`.`models`.`name` AS `name`,`test`.`subtypes`.`id_pk` AS `id_pk`,`test`.`subtypes`.`id_nokey` AS `id_nokey`,`test`.`subtypes`.`name` AS `name`,`test`.`colors`.`id_pk` AS `id_pk`,`test`.`colors`.`id_nokey` AS `id_nokey`,`test`.`colors`.`name` AS `name`,`test`.`heating`.`id_pk` AS `id_pk`,`test`.`heating`.`id_nokey` AS `id_nokey`,`test`.`heating`.`name` AS `name`,`test`.`windows`.`id_pk` AS `id_pk`,`test`.`windows`.`id_nokey` AS `id_nokey`,`test`.`windows`.`name` AS `name`,`test`.`fuels`.`id_pk` AS `id_pk`,`test`.`fuels`.`id_nokey` AS `id_nokey`,`test`.`fuels`.`name` AS `name`,`test`.`transmissions`.`id_pk` AS `id_pk`,`test`.`transmissions`.`id_nokey` AS `id_nokey`,`test`.`transmissions`.`name` AS `name`,`test`.`steerings`.`id_pk` AS `id_pk`,`test`.`steerings`.`id_nokey` AS `id_nokey`,`test`.`steerings`.`name` AS `name`,`test`.`interiors`.`id_pk` AS `id_pk`,`test`.`interiors`.`id_nokey` AS `id_nokey`,`test`.`interiors`.`name` AS `name`,`test`.`drives`.`id_pk` AS `id_pk`,`test`.`drives`.`id_nokey` AS `id_nokey`,`test`.`drives`.`name` AS `name`,`test`.`wheels`.`id_pk` AS `id_pk`,`test`.`wheels`.`id_nokey` AS `id_nokey`,`test`.`wheels`.`name` AS `name`,`test`.`engine`.`id_pk` AS `id_pk`,`test`.`engine`.`id_nokey` AS `id_nokey`,`test`.`engine`.`name` AS `name`,`test`.`price_ranges`.`id_pk` AS `id_pk`,`test`.`price_ranges`.`id_nokey` AS `id_nokey`,`test`.`price_ranges`.`name` AS `name`,`test`.`countries`.`id_pk` AS `id_pk`,`test`.`countries`.`id_nokey` AS `id_nokey`,`test`.`countries`.`name` AS `name`,`test`.`brands`.`id_pk` AS `id_pk`,`test`.`brands`.`id_nokey` AS `id_nokey`,`test`.`brands`.`name` AS `name` from `test`.`vehicles` join `test`.`models` join `test`.`subtypes` join `test`.`colors` join `test`.`heating` join `test`.`windows` join `test`.`fuels` join `test`.`transmissions` join `test`.`steerings` join `test`.`interiors` join `test`.`drives` join `test`.`wheels` join `test`.`engine` join `test`.`price_ranges` join `test`.`countries` join `test`.`brands` where ((`test`.`vehicles`.`model_id` = `test`.`models`.`id_nokey`) and (`test`.`subtypes`.`id_pk` = `test`.`vehicles`.`subtype_id`) and (`test`.`colors`.`id_pk` = `test`.`vehicles`.`color_id`) and (`test`.`heating`.`id_nokey` = `test`.`vehicles`.`heating_id`) and (`test`.`windows`.`id_pk` = `test`.`vehicles`.`window_id`) and (`test`.`fuels`.`id_pk` = `test`.`vehicles`.`fuel_id`) and (`test`.`transmissions`.`id_nokey` = `test`.`vehicles`.`transmission_id`) and (`test`.`steerings`.`id_pk` = `test`.`vehicles`.`steering_id`) and (`test`.`interiors`.`id_pk` = `test`.`vehicles`.`interior_id`) and (`test`.`drives`.`id_pk` = `test`.`vehicles`.`drive_id`) and (`test`.`wheels`.`id_nokey` = `test`.`vehicles`.`wheels_id`) and (`test`.`engine`.`id_pk` = `test`.`vehicles`.`engine_id`) and (`test`.`price_ranges`.`id_pk` = `test`.`vehicles`.`price_range_id`) and (`test`.`countries`.`id_pk` = `test`.`vehicles`.`assembled_in`) and (`test`.`models`.`brand_id` = `test`.`brands`.`id_nokey`)) +### Partial_plans: 3296 +FLUSH STATUS; +select @@optimizer_search_depth; +@@optimizer_search_depth +25 +select @@optimizer_prune_level; +@@optimizer_prune_level +1 +DROP TABLE vehicles, models, subtypes, colors, heating, windows, +fuels, transmissions, steerings, interiors, drives, +price_ranges, countries, brands, wheels, engine; +# +# TEST 2 +# Greedy search iteration test for chain of tables +# +# +# Chain test a: colidx):(pk,colidx):(pk,colidx) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.colidx = t100_1.pk JOIN t10_2 ON t100_1.colidx = t10_2.pk JOIN t100_2 ON t10_2.colidx = t100_2.pk JOIN t10_3 ON t100_2.colidx = t10_3.pk JOIN t100_3 ON t10_3.colidx = t100_3.pk JOIN t10_4 ON t100_3.colidx = t10_4.pk JOIN t100_4 ON t10_4.colidx = t100_4.pk JOIN t10_5 ON t100_4.colidx = t10_5.pk JOIN t100_5 ON t10_5.colidx = t100_5.pk JOIN t10_6 ON t100_5.colidx = t10_6.pk JOIN t100_6 ON t10_6.colidx = t100_6.pk JOIN t10_7 ON t100_6.colidx = t10_7.pk JOIN t100_7 ON t10_7.colidx = t100_7.pk JOIN t10_8 ON t100_7.colidx = t10_8.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_1 NULL ALL colidx NULL NULL NULL 10 100.00 Using where +2 SIMPLE t10_2 NULL ALL PRIMARY,colidx NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_1 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_1.colidx 1 10.00 Using where +2 SIMPLE t100_2 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_2.colidx 1 100.00 Using where +2 SIMPLE t10_3 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_2.colidx 1 100.00 Using where +2 SIMPLE t100_3 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_3.colidx 1 100.00 Using where +2 SIMPLE t10_4 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_3.colidx 1 100.00 Using where +2 SIMPLE t100_4 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_4.colidx 1 100.00 Using where +2 SIMPLE t10_5 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_4.colidx 1 100.00 Using where +2 SIMPLE t100_5 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_5.colidx 1 100.00 Using where +2 SIMPLE t10_6 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_5.colidx 1 100.00 Using where +2 SIMPLE t100_6 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_6.colidx 1 100.00 Using where +2 SIMPLE t10_7 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_6.colidx 1 100.00 Using where +2 SIMPLE t100_7 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t10_7.colidx 1 100.00 Using where +2 SIMPLE t10_8 NULL eq_ref PRIMARY PRIMARY 4 test.t100_7.colidx 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t100_1`.`pk` = `test`.`t10_1`.`colidx`) and (`test`.`t100_1`.`colidx` = `test`.`t10_2`.`pk`) and (`test`.`t100_2`.`pk` = `test`.`t10_2`.`colidx`) and (`test`.`t10_3`.`pk` = `test`.`t100_2`.`colidx`) and (`test`.`t100_3`.`pk` = `test`.`t10_3`.`colidx`) and (`test`.`t10_4`.`pk` = `test`.`t100_3`.`colidx`) and (`test`.`t100_4`.`pk` = `test`.`t10_4`.`colidx`) and (`test`.`t10_5`.`pk` = `test`.`t100_4`.`colidx`) and (`test`.`t100_5`.`pk` = `test`.`t10_5`.`colidx`) and (`test`.`t10_6`.`pk` = `test`.`t100_5`.`colidx`) and (`test`.`t100_6`.`pk` = `test`.`t10_6`.`colidx`) and (`test`.`t10_7`.`pk` = `test`.`t100_6`.`colidx`) and (`test`.`t100_7`.`pk` = `test`.`t10_7`.`colidx`) and (`test`.`t10_8`.`pk` = `test`.`t100_7`.`colidx`)) +### Partial_plans: 9123 +FLUSH STATUS; +# +# Chain test b: (...,col):(colidx, col):(pk,col):(colidx,col):(pk,...) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.col = t100_1.colidx JOIN t10_2 ON t100_1.col = t10_2.pk JOIN t100_2 ON t10_2.col = t100_2.colidx JOIN t10_3 ON t100_2.col = t10_3.pk JOIN t100_3 ON t10_3.col = t100_3.colidx JOIN t10_4 ON t100_3.col = t10_4.pk JOIN t100_4 ON t10_4.col = t100_4.colidx JOIN t10_5 ON t100_4.col = t10_5.pk JOIN t100_5 ON t10_5.col = t100_5.colidx JOIN t10_6 ON t100_5.col = t10_6.pk JOIN t100_6 ON t10_6.col = t100_6.colidx JOIN t10_7 ON t100_6.col = t10_7.pk JOIN t100_7 ON t10_7.col = t100_7.colidx JOIN t10_8 ON t100_7.col = t10_8.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SIMPLE t100_1 NULL ref colidx colidx 5 test.t10_1.col 10 100.00 NULL +2 SIMPLE t10_2 NULL ALL PRIMARY NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_2 NULL ref colidx colidx 5 test.t10_2.col 10 100.00 Using where +2 SIMPLE t10_3 NULL eq_ref PRIMARY PRIMARY 4 test.t100_2.col 1 100.00 Using where +2 SIMPLE t10_4 NULL ALL PRIMARY NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_3 NULL ref colidx colidx 5 test.t10_3.col 10 10.00 Using where +2 SIMPLE t100_4 NULL ref colidx colidx 5 test.t10_4.col 10 100.00 Using where +2 SIMPLE t10_5 NULL eq_ref PRIMARY PRIMARY 4 test.t100_4.col 1 100.00 Using where +2 SIMPLE t100_5 NULL ref colidx colidx 5 test.t10_5.col 10 100.00 Using where +2 SIMPLE t10_6 NULL eq_ref PRIMARY PRIMARY 4 test.t100_5.col 1 100.00 Using where +2 SIMPLE t100_6 NULL ref colidx colidx 5 test.t10_6.col 10 100.00 Using where +2 SIMPLE t10_7 NULL eq_ref PRIMARY PRIMARY 4 test.t100_6.col 1 100.00 Using where +2 SIMPLE t100_7 NULL ref colidx colidx 5 test.t10_7.col 10 100.00 Using where +2 SIMPLE t10_8 NULL eq_ref PRIMARY PRIMARY 4 test.t100_7.col 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t100_1`.`colidx` = `test`.`t10_1`.`col`) and (`test`.`t10_2`.`pk` = `test`.`t100_1`.`col`) and (`test`.`t100_2`.`colidx` = `test`.`t10_2`.`col`) and (`test`.`t10_3`.`pk` = `test`.`t100_2`.`col`) and (`test`.`t100_3`.`colidx` = `test`.`t10_3`.`col`) and (`test`.`t100_3`.`col` = `test`.`t10_4`.`pk`) and (`test`.`t100_4`.`colidx` = `test`.`t10_4`.`col`) and (`test`.`t10_5`.`pk` = `test`.`t100_4`.`col`) and (`test`.`t100_5`.`colidx` = `test`.`t10_5`.`col`) and (`test`.`t10_6`.`pk` = `test`.`t100_5`.`col`) and (`test`.`t100_6`.`colidx` = `test`.`t10_6`.`col`) and (`test`.`t10_7`.`pk` = `test`.`t100_6`.`col`) and (`test`.`t100_7`.`colidx` = `test`.`t10_7`.`col`) and (`test`.`t10_8`.`pk` = `test`.`t100_7`.`col`)) +### Partial_plans: 5799059 +FLUSH STATUS; +# +# Chain test c: (...,colidx):(col, pk):(col,colidx):(col,...) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.colidx = t100_1.col JOIN t10_2 ON t100_1.pk = t10_2.col JOIN t100_2 ON t10_2.colidx = t100_2.col JOIN t10_3 ON t100_2.pk = t10_3.col JOIN t100_3 ON t10_3.colidx = t100_3.col JOIN t10_4 ON t100_3.pk = t10_4.col JOIN t100_4 ON t10_4.colidx = t100_4.col JOIN t10_5 ON t100_4.pk = t10_5.col JOIN t100_5 ON t10_5.colidx = t100_5.col JOIN t10_6 ON t100_5.pk = t10_6.col JOIN t100_6 ON t10_6.colidx = t100_6.col JOIN t10_7 ON t100_6.pk = t10_7.col JOIN t100_7 ON t10_7.colidx = t100_7.col JOIN t10_8 ON t100_7.pk = t10_8.col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_7 NULL ALL colidx NULL NULL NULL 10 100.00 Using where +2 SIMPLE t10_8 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_6 NULL eq_ref PRIMARY PRIMARY 4 test.t10_7.col 1 100.00 Using where +2 SIMPLE t100_7 NULL eq_ref PRIMARY PRIMARY 4 test.t10_8.col 1 10.00 Using where +2 SIMPLE t10_6 NULL ref colidx colidx 5 test.t100_6.col 1 100.00 Using where +2 SIMPLE t100_5 NULL eq_ref PRIMARY PRIMARY 4 test.t10_6.col 1 100.00 Using where +2 SIMPLE t10_5 NULL ref colidx colidx 5 test.t100_5.col 1 100.00 Using where +2 SIMPLE t100_4 NULL eq_ref PRIMARY PRIMARY 4 test.t10_5.col 1 100.00 Using where +2 SIMPLE t10_4 NULL ref colidx colidx 5 test.t100_4.col 1 100.00 Using where +2 SIMPLE t100_3 NULL eq_ref PRIMARY PRIMARY 4 test.t10_4.col 1 100.00 Using where +2 SIMPLE t10_3 NULL ref colidx colidx 5 test.t100_3.col 1 100.00 Using where +2 SIMPLE t100_2 NULL eq_ref PRIMARY PRIMARY 4 test.t10_3.col 1 100.00 Using where +2 SIMPLE t10_2 NULL ref colidx colidx 5 test.t100_2.col 1 100.00 Using where +2 SIMPLE t100_1 NULL eq_ref PRIMARY PRIMARY 4 test.t10_2.col 1 100.00 Using where +2 SIMPLE t10_1 NULL ref colidx colidx 5 test.t100_1.col 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t10_1`.`colidx` = `test`.`t100_1`.`col`) and (`test`.`t100_1`.`pk` = `test`.`t10_2`.`col`) and (`test`.`t10_2`.`colidx` = `test`.`t100_2`.`col`) and (`test`.`t100_2`.`pk` = `test`.`t10_3`.`col`) and (`test`.`t10_3`.`colidx` = `test`.`t100_3`.`col`) and (`test`.`t100_3`.`pk` = `test`.`t10_4`.`col`) and (`test`.`t10_4`.`colidx` = `test`.`t100_4`.`col`) and (`test`.`t100_4`.`pk` = `test`.`t10_5`.`col`) and (`test`.`t10_5`.`colidx` = `test`.`t100_5`.`col`) and (`test`.`t100_5`.`pk` = `test`.`t10_6`.`col`) and (`test`.`t10_6`.`colidx` = `test`.`t100_6`.`col`) and (`test`.`t100_6`.`pk` = `test`.`t10_7`.`col`) and (`test`.`t100_7`.`col` = `test`.`t10_7`.`colidx`) and (`test`.`t100_7`.`pk` = `test`.`t10_8`.`col`)) +### Partial_plans: 13248 +FLUSH STATUS; +# +# Chain test d: (...,colidx):(pk, col):(pk,colidx):(pk,col):(pk,...) +# +EXPLAIN SELECT * FROM t10_1 JOIN t100_1 ON t10_1.colidx = t100_1.pk JOIN t10_2 ON t100_1.col = t10_2.pk JOIN t100_2 ON t10_2.colidx = t100_2.pk JOIN t10_3 ON t100_2.col = t10_3.pk JOIN t100_3 ON t10_3.colidx = t100_3.pk JOIN t10_4 ON t100_3.col = t10_4.pk JOIN t100_4 ON t10_4.colidx = t100_4.pk JOIN t10_5 ON t100_4.col = t10_5.pk JOIN t100_5 ON t10_5.colidx = t100_5.pk JOIN t10_6 ON t100_5.col = t10_6.pk JOIN t100_6 ON t10_6.colidx = t100_6.pk JOIN t10_7 ON t100_6.col = t10_7.pk JOIN t100_7 ON t10_7.colidx = t100_7.pk JOIN t10_8 ON t100_7.col = t10_8.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t10_2 NULL ALL PRIMARY,colidx NULL NULL NULL 10 100.00 Using where +2 SIMPLE t10_1 NULL ALL colidx NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t100_1 NULL eq_ref PRIMARY PRIMARY 4 test.t10_1.colidx 1 10.00 Using where +2 SIMPLE t100_2 NULL eq_ref PRIMARY PRIMARY 4 test.t10_2.colidx 1 100.00 Using where +2 SIMPLE t10_3 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_2.col 1 100.00 Using where +2 SIMPLE t100_3 NULL eq_ref PRIMARY PRIMARY 4 test.t10_3.colidx 1 100.00 Using where +2 SIMPLE t10_4 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_3.col 1 100.00 Using where +2 SIMPLE t100_4 NULL eq_ref PRIMARY PRIMARY 4 test.t10_4.colidx 1 100.00 Using where +2 SIMPLE t10_5 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_4.col 1 100.00 Using where +2 SIMPLE t100_5 NULL eq_ref PRIMARY PRIMARY 4 test.t10_5.colidx 1 100.00 Using where +2 SIMPLE t10_6 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_5.col 1 100.00 Using where +2 SIMPLE t100_6 NULL eq_ref PRIMARY PRIMARY 4 test.t10_6.colidx 1 100.00 Using where +2 SIMPLE t10_7 NULL eq_ref PRIMARY,colidx PRIMARY 4 test.t100_6.col 1 100.00 Using where +2 SIMPLE t100_7 NULL eq_ref PRIMARY PRIMARY 4 test.t10_7.colidx 1 100.00 Using where +2 SIMPLE t10_8 NULL eq_ref PRIMARY PRIMARY 4 test.t100_7.col 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t10_1`.`pk` AS `pk`,`test`.`t10_1`.`colidx` AS `colidx`,`test`.`t10_1`.`col` AS `col`,`test`.`t100_1`.`pk` AS `pk`,`test`.`t100_1`.`colidx` AS `colidx`,`test`.`t100_1`.`col` AS `col`,`test`.`t10_2`.`pk` AS `pk`,`test`.`t10_2`.`colidx` AS `colidx`,`test`.`t10_2`.`col` AS `col`,`test`.`t100_2`.`pk` AS `pk`,`test`.`t100_2`.`colidx` AS `colidx`,`test`.`t100_2`.`col` AS `col`,`test`.`t10_3`.`pk` AS `pk`,`test`.`t10_3`.`colidx` AS `colidx`,`test`.`t10_3`.`col` AS `col`,`test`.`t100_3`.`pk` AS `pk`,`test`.`t100_3`.`colidx` AS `colidx`,`test`.`t100_3`.`col` AS `col`,`test`.`t10_4`.`pk` AS `pk`,`test`.`t10_4`.`colidx` AS `colidx`,`test`.`t10_4`.`col` AS `col`,`test`.`t100_4`.`pk` AS `pk`,`test`.`t100_4`.`colidx` AS `colidx`,`test`.`t100_4`.`col` AS `col`,`test`.`t10_5`.`pk` AS `pk`,`test`.`t10_5`.`colidx` AS `colidx`,`test`.`t10_5`.`col` AS `col`,`test`.`t100_5`.`pk` AS `pk`,`test`.`t100_5`.`colidx` AS `colidx`,`test`.`t100_5`.`col` AS `col`,`test`.`t10_6`.`pk` AS `pk`,`test`.`t10_6`.`colidx` AS `colidx`,`test`.`t10_6`.`col` AS `col`,`test`.`t100_6`.`pk` AS `pk`,`test`.`t100_6`.`colidx` AS `colidx`,`test`.`t100_6`.`col` AS `col`,`test`.`t10_7`.`pk` AS `pk`,`test`.`t10_7`.`colidx` AS `colidx`,`test`.`t10_7`.`col` AS `col`,`test`.`t100_7`.`pk` AS `pk`,`test`.`t100_7`.`colidx` AS `colidx`,`test`.`t100_7`.`col` AS `col`,`test`.`t10_8`.`pk` AS `pk`,`test`.`t10_8`.`colidx` AS `colidx`,`test`.`t10_8`.`col` AS `col` from `test`.`t10_1` join `test`.`t100_1` join `test`.`t10_2` join `test`.`t100_2` join `test`.`t10_3` join `test`.`t100_3` join `test`.`t10_4` join `test`.`t100_4` join `test`.`t10_5` join `test`.`t100_5` join `test`.`t10_6` join `test`.`t100_6` join `test`.`t10_7` join `test`.`t100_7` join `test`.`t10_8` where ((`test`.`t100_1`.`pk` = `test`.`t10_1`.`colidx`) and (`test`.`t100_1`.`col` = `test`.`t10_2`.`pk`) and (`test`.`t100_2`.`pk` = `test`.`t10_2`.`colidx`) and (`test`.`t10_3`.`pk` = `test`.`t100_2`.`col`) and (`test`.`t100_3`.`pk` = `test`.`t10_3`.`colidx`) and (`test`.`t10_4`.`pk` = `test`.`t100_3`.`col`) and (`test`.`t100_4`.`pk` = `test`.`t10_4`.`colidx`) and (`test`.`t10_5`.`pk` = `test`.`t100_4`.`col`) and (`test`.`t100_5`.`pk` = `test`.`t10_5`.`colidx`) and (`test`.`t10_6`.`pk` = `test`.`t100_5`.`col`) and (`test`.`t100_6`.`pk` = `test`.`t10_6`.`colidx`) and (`test`.`t10_7`.`pk` = `test`.`t100_6`.`col`) and (`test`.`t100_7`.`pk` = `test`.`t10_7`.`colidx`) and (`test`.`t10_8`.`pk` = `test`.`t100_7`.`col`)) +### Partial_plans: 1795 +FLUSH STATUS; +# +# Cleanup after TEST 2 +# +DROP TABLE tbl10, tbl100; +DROP TABLE t10_1,t10_2,t10_3,t10_4,t10_5,t10_6,t10_7,t10_8,t10_9; +DROP TABLE t100_1,t100_2,t100_3,t100_4,t100_5,t100_6,t100_7,t100_8,t100_9; +UPDATE mysql.engine_cost +SET cost_value = DEFAULT +WHERE cost_name = 'memory_block_read_cost'; +FLUSH OPTIMIZER_COSTS; diff --git a/mysql-test/r/group_by.result-pq b/mysql-test/r/group_by.result-pq new file mode 100644 index 000000000..2c76dfba6 --- /dev/null +++ b/mysql-test/r/group_by.result-pq @@ -0,0 +1,4285 @@ +drop table if exists t1,t2,t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1); +ERROR HY000: Invalid use of group function +CREATE TABLE t1 ( +spID int(10) unsigned, +userID int(10) unsigned, +score smallint(5) unsigned, +lsg char(40), +date date +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,1,'','0000-00-00'); +INSERT INTO t1 VALUES (2,2,2,'','0000-00-00'); +INSERT INTO t1 VALUES (2,1,1,'','0000-00-00'); +INSERT INTO t1 VALUES (3,3,3,'','0000-00-00'); +CREATE TABLE t2 ( +userID int(10) unsigned NOT NULL auto_increment, +niName char(15), +passwd char(8), +mail char(50), +isAukt enum('N','Y') DEFAULT 'N', +vName char(30), +nName char(40), +adr char(60), +plz char(5), +ort char(35), +land char(20), +PRIMARY KEY (userID) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (4,'name','pass','mail','Y','v','n','adr','1','1','1'); +INSERT INTO t2 VALUES (5,'name','pass','mail','Y','v','n','adr','1','1','1'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid; +EXPLAIN +-> Table scan on + -> Aggregate using temporary table + -> Parallel scan on + -> Table scan on + -> Aggregate using temporary table + -> Nested loop inner join (cost=2.05 rows=4) + -> Filter: (t1.userID is not null) (cost=0.65 rows=4) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Single-row index lookup on t2 using PRIMARY (userID=t1.userID) (cost=0.28 rows=1) + +SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid; +userid MIN(t1.score) +1 1 +2 2 +3 3 +SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid ORDER BY NULL; +userid MIN(t1.score) +1 1 +2 2 +3 3 +SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; +userid MIN(t1.score) +1 1 +2 2 +SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; +userid MIN(t1.score+0.0) +1 1.0 +2 2.0 +SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL; +userid MIN(t1.score+0.0) +1 1.0 +2 2.0 +EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.userID 1 100.00 Using index +Note 1003 /* select#1 */ select `test`.`t2`.`userID` AS `userid`,min((`test`.`t1`.`score` + 0.0)) AS `MIN(t1.score+0.0)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`spID` = 2) and (`test`.`t2`.`userID` = `test`.`t1`.`userID`)) group by `test`.`t2`.`userID` order by NULL +Warnings: +drop table t1,t2; +CREATE TABLE t1 ( +PID int(10) unsigned NOT NULL auto_increment, +payDate date DEFAULT '0000-00-00' NOT NULL, +recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +URID int(10) unsigned DEFAULT '0' NOT NULL, +CRID int(10) unsigned DEFAULT '0' NOT NULL, +amount int(10) unsigned DEFAULT '0' NOT NULL, +operator int(10) unsigned, +method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL, +DIID int(10) unsigned, +reason char(1) binary DEFAULT '' NOT NULL, +code_id int(10) unsigned, +qty mediumint(8) unsigned DEFAULT '0' NOT NULL, +PRIMARY KEY (PID), +KEY URID (URID), +KEY reason (reason), +KEY method (method), +KEY payDate (payDate) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6); +SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew; +ERROR 42000: Can't group on 'IsNew' +drop table t1; +CREATE TABLE t1 ( +cid mediumint(9) NOT NULL auto_increment, +firstname varchar(32) DEFAULT '' NOT NULL, +surname varchar(32) DEFAULT '' NOT NULL, +PRIMARY KEY (cid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'That','Guy'); +INSERT INTO t1 VALUES (2,'Another','Gent'); +CREATE TABLE t2 ( +call_id mediumint(8) NOT NULL auto_increment, +contact_id mediumint(8) DEFAULT '0' NOT NULL, +PRIMARY KEY (call_id), +KEY contact_id (contact_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +lock tables t1 read,t2 write; +INSERT INTO t2 VALUES (10,2); +INSERT INTO t2 VALUES (18,2); +INSERT INTO t2 VALUES (62,2); +INSERT INTO t2 VALUES (91,2); +INSERT INTO t2 VALUES (92,2); +SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid; +cid CONCAT(firstname, ' ', surname) COUNT(call_id) +SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL; +cid CONCAT(firstname, ' ', surname) COUNT(call_id) +SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname; +cid CONCAT(firstname, ' ', surname) COUNT(call_id) +drop table t2; +unlock tables; +drop table t1; +CREATE TABLE t1 ( +bug_id mediumint(9) NOT NULL auto_increment, +groupset bigint(20) DEFAULT '0' NOT NULL, +assigned_to mediumint(9) DEFAULT '0' NOT NULL, +bug_file_loc text, +bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL, +bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL, +creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +delta_ts timestamp, +short_desc mediumtext, +long_desc mediumtext, +op_sys enum('All','Windows 3.1','Windows 95','Windows 98','Windows NT','Windows 2000','Linux','other') DEFAULT 'All' NOT NULL, +priority enum('P1','P2','P3','P4','P5') DEFAULT 'P1' NOT NULL, +product varchar(64) DEFAULT '' NOT NULL, +rep_platform enum('All','PC','VTD-8','Other'), +reporter mediumint(9) DEFAULT '0' NOT NULL, +version varchar(16) DEFAULT '' NOT NULL, +component varchar(50) DEFAULT '' NOT NULL, +resolution enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME') DEFAULT '' NOT NULL, +target_milestone varchar(20) DEFAULT '' NOT NULL, +qa_contact mediumint(9) DEFAULT '0' NOT NULL, +status_whiteboard mediumtext NOT NULL, +votes mediumint(9) DEFAULT '0' NOT NULL, +PRIMARY KEY (bug_id), +KEY assigned_to (assigned_to), +KEY creation_ts (creation_ts), +KEY delta_ts (delta_ts), +KEY bug_severity (bug_severity), +KEY bug_status (bug_status), +KEY op_sys (op_sys), +KEY priority (priority), +KEY product (product), +KEY reporter (reporter), +KEY version (version), +KEY component (component), +KEY resolution (resolution), +KEY target_milestone (target_milestone), +KEY qa_contact (qa_contact), +KEY votes (votes) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0); +INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0); +INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0); +INSERT INTO t1 VALUES (7,0,0,'','critical','','2000-03-09 10:50:21',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0); +INSERT INTO t1 VALUES (6,0,0,'','normal','','2000-03-09 10:42:44',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0); +INSERT INTO t1 VALUES (8,0,0,'','major','','2000-03-09 11:32:14',20000321114747,'','','All','P3','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0); +INSERT INTO t1 VALUES (5,0,0,'','enhancement','','2000-03-09 10:38:59',20000321114747,'','','All','P5','CCC/CCCCCC','PC',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (4,0,0,'','normal','','2000-03-08 18:32:14',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent2','','',0,'',0); +INSERT INTO t1 VALUES (3,0,0,'','normal','','2000-03-08 18:30:52',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0); +INSERT INTO t1 VALUES (2,0,0,'','enhancement','','2000-03-08 18:24:51',20000321114747,'','','All','P2','TestProduct','Other',4,'other','TestComponent2','','',0,'',0); +INSERT INTO t1 VALUES (11,0,0,'','blocker','','2000-03-13 09:43:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (12,0,0,'','normal','','2000-03-13 16:14:31',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0); +INSERT INTO t1 VALUES (13,0,0,'','normal','','2000-03-15 16:20:44',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0); +INSERT INTO t1 VALUES (14,0,0,'','blocker','','2000-03-15 18:13:47',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0); +INSERT INTO t1 VALUES (15,0,0,'','minor','','2000-03-16 18:03:28',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (16,0,0,'','normal','','2000-03-16 18:33:41',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (17,0,0,'','normal','','2000-03-16 18:34:18',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (18,0,0,'','normal','','2000-03-16 18:34:56',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (19,0,0,'','enhancement','','2000-03-16 18:35:34',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (20,0,0,'','enhancement','','2000-03-16 18:36:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (21,0,0,'','enhancement','','2000-03-16 18:37:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (22,0,0,'','enhancement','','2000-03-16 18:38:16',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0); +INSERT INTO t1 VALUES (23,0,0,'','normal','','2000-03-16 18:58:12',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (24,0,0,'','normal','','2000-03-17 11:08:10',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +INSERT INTO t1 VALUES (25,0,0,'','normal','','2000-03-17 11:10:45',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +INSERT INTO t1 VALUES (26,0,0,'','normal','','2000-03-17 11:15:47',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +INSERT INTO t1 VALUES (27,0,0,'','normal','','2000-03-17 17:45:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0); +INSERT INTO t1 VALUES (28,0,0,'','normal','','2000-03-20 09:51:45',20000321114747,'','','Windows NT','P2','TestProduct','PC',8,'other','TestComponent','','',0,'',0); +INSERT INTO t1 VALUES (29,0,0,'','normal','','2000-03-20 11:15:09',20000321114747,'','','All','P5','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0); +CREATE TABLE t2 ( +value tinytext, +program varchar(64), +initialowner tinytext NOT NULL, +initialqacontact tinytext NOT NULL, +description mediumtext NOT NULL +); +INSERT INTO t2 VALUES ('TestComponent','TestProduct','id0001','',''); +INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - conversion','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - generic','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('TestComponent2','TestProduct','id0001','',''); +INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - eeeeeeeee','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('kkkkkkkkkkk lllllllllll','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('Test Procedures','AAAAA','id0001','',''); +INSERT INTO t2 VALUES ('Documentation','AAAAA','id0003','',''); +INSERT INTO t2 VALUES ('DDDDDDDDD','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Eeeeeeee Lite','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Eeeeeeee Full','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Administration','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Distribution','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Setup','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Unspecified','CCC/CCCCCC','id0002','',''); +INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','',''); +INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','',''); +select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA"; +value description bug_id +BBBBBBBBBBBBB - conversion 10 +BBBBBBBBBBBBB - conversion 9 +BBBBBBBBBBBBB - eeeeeeeee NULL +BBBBBBBBBBBBB - generic 14 +BBBBBBBBBBBBB - generic 7 +Documentation NULL +Host communication NULL +Test Procedures NULL +kkkkkkkkkkk lllllllllll 12 +kkkkkkkkkkk lllllllllll 6 +kkkkkkkkkkk lllllllllll 8 +select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value; +value description COUNT(bug_id) +BBBBBBBBBBBBB - conversion 2 +BBBBBBBBBBBBB - eeeeeeeee 0 +BBBBBBBBBBBBB - generic 2 +Documentation 0 +Host communication 0 +Test Procedures 0 +kkkkkkkkkkk lllllllllll 3 +select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2); +value description COUNT(bug_id) +BBBBBBBBBBBBB - conversion 2 +BBBBBBBBBBBBB - eeeeeeeee 0 +BBBBBBBBBBBBB - generic 2 +Documentation 0 +Host communication 0 +Test Procedures 0 +select row_number() over (), value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2); +row_number() over () value description COUNT(bug_id) +1 BBBBBBBBBBBBB - conversion 2 +2 BBBBBBBBBBBBB - generic 2 +3 BBBBBBBBBBBBB - eeeeeeeee 0 +4 Test Procedures 0 +5 Documentation 0 +6 Host communication 0 +drop table t1,t2; +create table t1 (foo int); +insert into t1 values (1); +select 1+1, "a",count(*) from t1 where foo in (2); +1+1 a count(*) +2 a 0 +insert into t1 values (1); +select 1+1,"a",count(*) from t1 where foo in (2); +1+1 a count(*) +2 a 0 +drop table t1; +CREATE TABLE t1 ( +spID int(10) unsigned, +userID int(10) unsigned, +score smallint(5) unsigned, +key (spid), +key (score) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select userid,count(*) from t1 group by userid order by userid desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`userID` AS `userid`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`userID` desc order by `test`.`t1`.`userID` desc +explain select userid,count(*) from t1 group by userid order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`userID` AS `userid`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`userID` order by NULL +select userid,count(*) from t1 group by userid order by userid desc; +userid count(*) +3 5 +2 1 +1 2 +select userid,count(*) from t1 group by userid having (count(*)+1) IN (4,3) order by userid desc; +userid count(*) +1 2 +select userid,count(*) from t1 group by userid having 3 IN (1,COUNT(*)) order by userid desc; +userid count(*) +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by spid desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range spID spID 5 NULL 3 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spid`,count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`spID` between 1 and 2) group by `test`.`t1`.`spID` desc order by `test`.`t1`.`spID` desc +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range spID spID 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spid`,count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`spID` between 1 and 2) group by `test`.`t1`.`spID` +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range spID spID 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`spID` AS `spid`,count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`spID` between 1 and 2) group by `test`.`t1`.`spID` order by NULL +select spid,count(*) from t1 where spid between 1 and 2 group by spid; +spid count(*) +1 1 +2 2 +select spid,count(*) from t1 where spid between 1 and 2 group by spid order by spid desc; +spid count(*) +2 2 +1 1 +explain select sql_big_result spid,sum(userid) from t1 group by spid order by spid desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL spID NULL NULL NULL 8 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`spID` AS `spid`,sum(`test`.`t1`.`userID`) AS `sum(userid)` from `test`.`t1` group by `test`.`t1`.`spID` desc order by `test`.`t1`.`spID` desc +explain select sql_big_result spid,sum(userid) from t1 group by spid order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL spID NULL NULL NULL 8 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`spID` AS `spid`,sum(`test`.`t1`.`userID`) AS `sum(userid)` from `test`.`t1` group by `test`.`t1`.`spID` order by NULL +select sql_big_result spid,sum(userid) from t1 group by spid order by spid desc; +spid sum(userid) +7 3 +6 3 +5 3 +4 3 +3 3 +2 3 +1 1 +explain select sql_big_result score,count(*) from t1 group by score order by score desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index score score 3 NULL 8 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`score` AS `score`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`score` desc order by `test`.`t1`.`score` desc +explain select sql_big_result score,count(*) from t1 group by score order by null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index score score 3 NULL 8 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`score` AS `score`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`score` order by NULL +select sql_big_result score,count(*) from t1 group by score order by score desc; +score count(*) +3 5 +2 1 +1 2 +drop table t1; +create table t1 (a date default null, b date default null); +insert t1 values ('1999-10-01','2000-01-10'), ('1997-01-01','1998-10-01'); +select a,min(b) c,count(distinct rand()) from t1 group by a having c NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL a NULL NULL NULL # # Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) group by `test`.`t1`.`a`,`test`.`t2`.`b` +explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL a NULL NULL NULL # # Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) group by `test`.`t1`.`a`,`test`.`t2`.`b` order by NULL +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1, 4),(10, 40),(1, 4),(10, 43),(1, 4),(10, 41),(1, 4),(10, 43),(1, 4); +select a, MAX(b), INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) from t1 group by a; +a MAX(b) INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) +1 4 2 +10 43 6 +select a, MAX(b), CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end from t1 group by a; +a MAX(b) CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end +1 4 4 +10 43 43 +select a, MAX(b), FIELD(MAX(b), '43', '4', '5') from t1 group by a; +a MAX(b) FIELD(MAX(b), '43', '4', '5') +1 4 2 +10 43 1 +select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a; +a MAX(b) CONCAT_WS(MAX(b), '43', '4', '5') +1 4 434445 +10 43 43434435 +select a, MAX(b), ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') from t1 group by a; +a MAX(b) ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') +1 4 d +10 43 NULL +select a, MAX(b), MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') from t1 group by a; +a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') +1 4 c +10 43 a,b,d,f +drop table t1; +create table t1 (id int not null, qty int not null); +insert into t1 values (1,2),(1,3),(2,4),(2,5); +select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and cqty>1; +id sqty cqty +1 5 2 +2 9 2 +select id, sum(qty) as sqty from t1 group by id having sqty>2 and count(qty)>1; +id sqty +1 5 +2 9 +select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sqty>2 and cqty>1; +id sqty cqty +1 5 2 +2 9 2 +select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and count(qty)>1; +id sqty cqty +1 5 2 +2 9 2 +select count(*), case interval(qty,2,3,4,5,6,7,8) when -1 then NULL when 0 then "zero" when 1 then "one" when 2 then "two" end as category from t1 group by category; +count(*) category +2 NULL +1 one +1 two +select count(*), interval(qty,2,3,4,5,6,7,8) as category from t1 group by category; +count(*) category +1 1 +1 2 +1 3 +1 4 +drop table t1; +CREATE TABLE t1 ( +userid int(10) unsigned, +score smallint(5) unsigned, +key (score) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT userid,count(*) FROM t1 GROUP BY userid ORDER BY userid DESC; +userid count(*) +3 5 +2 1 +1 2 +EXPLAIN SELECT userid,count(*) FROM t1 GROUP BY userid ORDER BY userid DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`userid` AS `userid`,count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`userid` desc order by `test`.`t1`.`userid` desc +DROP TABLE t1; +CREATE TABLE t1 ( +i int(11) default NULL, +j int(11) default NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; +i COUNT(DISTINCT(i)) +1 1 +2 1 +4 4 +explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,count(distinct `test`.`t1`.`i`) AS `COUNT(DISTINCT(i))` from `test`.`t1` group by `test`.`t1`.`j` order by NULL +DROP TABLE t1; +create table t1 (a int); +insert into t1 values(null); +select min(a) is null from t1; +min(a) is null +1 +select min(a) is null or null from t1; +min(a) is null or null +1 +select 1 and min(a) is null from t1; +1 and min(a) is null +1 +drop table t1; +create table t1 ( col1 int, col2 int ); +insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2); +select group_concat( distinct col1 ) as alias from t1 +group by col2 having alias like '%'; +alias +1,2 +1,2 +1 +drop table t1; +CREATE TABLE t1 (a INTEGER, b INTEGER, c INTEGER); +INSERT INTO t1 (a,b) VALUES (1,2),(1,3),(2,5); +SELECT a, 0.1*0+1 r2, SUM(1) r1 FROM t1 WHERE a = 1 GROUP BY a HAVING r1>1 AND r2=1; +a r2 r1 +1 1.0 2 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 GROUP BY a; +a r2 r1 +1 2 2 +2 7 1 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 GROUP BY a +HAVING r1>=1 AND r2<=7 AND r2 > 0; +a r2 r1 +1 2 2 +2 7 1 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 GROUP BY a +HAVING r1>=1 AND (SELECT r2<=7 AND r2 > 0 FROM t1 AS t2 LIMIT 1); +a r2 r1 +1 2 2 +2 7 1 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 WHERE a = 1 +GROUP BY a HAVING r1>1 AND r2<=2; +a r2 r1 +1 7 2 +SELECT a, ROUND(RAND(100)*10) r2, SUM(1) r1 FROM t1 WHERE a = 1 +GROUP BY a HAVING r1>1 AND r2<=2 ORDER BY a+r2+r1; +a r2 r1 +1 7 2 +SELECT a,SUM(b) FROM t1 WHERE a=1 GROUP BY c; +a SUM(b) +1 5 +SELECT a*SUM(b) FROM t1 WHERE a=1 GROUP BY c; +a*SUM(b) +5 +SELECT SUM(a)*SUM(b) FROM t1 WHERE a=1 GROUP BY c; +SUM(a)*SUM(b) +10 +SELECT a,SUM(b) FROM t1 WHERE a=1 GROUP BY c HAVING a=1; +a SUM(b) +1 5 +SELECT a AS d,SUM(b) FROM t1 WHERE a=1 GROUP BY c HAVING d=1; +d SUM(b) +1 5 +SELECT SUM(a)*SUM(b) AS d FROM t1 WHERE a=1 GROUP BY c HAVING d > 0; +d +10 +SELECT a, ROUND(RAND(100)*10) r2 FROM t1; +a r2 +1 2 +1 7 +2 10 +SELECT ROUND(RAND(100)*10) r2 FROM t1 GROUP BY r2; +r2 +2 +7 +10 +DROP TABLE t1; +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (NULL),(1); +SELECT DISTINCT STD(i)+0 as splus0, i+0 as plain FROM t1 GROUP BY i ; +splus0 plain +NULL NULL +0 1 +DROP TABLE t1; +create table t1(a int) engine=myisam; +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(8),(9); +create table t2 ( +a int, +b varchar(200) NOT NULL, +c varchar(50) NOT NULL, +d varchar(100) NOT NULL, +primary key (a,b(132),c,d), +key a (a,b) +) engine=myisam charset=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 select +x3.a, -- 3 +concat('val-', x3.a + 3*x4.a), -- 12 +concat('val-', @a:=x3.a + 3*x4.a + 12*C.a), -- 120 +concat('val-', @a + 120*D.a) +from t1 x3, t1 x4, t1 C, t1 D where x3.a < 3 and x4.a < 4 and D.a < 4 +order by x3.a, x4.a, C.a, D.a; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +delete from t2 where a = 2 and b = 'val-2' order by a,b,c,d limit 30; +explain select c from t2 where a = 2 and b = 'val-2' group by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref PRIMARY,a PRIMARY 402 const,const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 2) and (`test`.`t2`.`b` = 'val-2')) group by `test`.`t2`.`c` +select c from t2 where a = 2 and b = 'val-2' group by c; +c +val-74 +val-98 +drop table t1,t2; +create table t1 (b int4 unsigned not null); +insert into t1 values(3000000000); +select * from t1; +b +3000000000 +select min(b) from t1; +min(b) +3000000000 +drop table t1; +CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext); +INSERT INTO t1 VALUES +(1, 7, 'cache-dtc-af05.proxy.aol.com'), +(2, 3, 'what.ever.com'), +(3, 7, 'cache-dtc-af05.proxy.aol.com'), +(4, 7, 'cache-dtc-af05.proxy.aol.com'); +SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 +WHERE hostname LIKE '%aol%' + GROUP BY hostname; +hostname no +cache-dtc-af05.proxy.aol.com 1 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,2), (1,3); +SELECT a, b FROM t1 GROUP BY 'const'; +a b +1 2 +SELECT DISTINCT a, b FROM t1 GROUP BY 'const'; +a b +1 2 +DROP TABLE t1; +CREATE TABLE t1 (id INT, dt DATETIME); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; +f id +20050501123000 1 +DROP TABLE t1; +CREATE TABLE t1 (id varchar(20) NOT NULL); +INSERT INTO t1 VALUES ('trans1'), ('trans2'); +CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL); +INSERT INTO t2 VALUES ('trans1', 'a problem'); +SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment +FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment; +COUNT(DISTINCT(t1.id)) comment +1 NULL +1 a problem +DROP TABLE t1, t2; +create table t1 (f1 date); +insert into t1 values('2005-06-06'); +insert into t1 values('2005-06-06'); +select date(left(f1+0,8)) from t1 group by 1; +date(left(f1+0,8)) +2005-06-06 +drop table t1; +CREATE TABLE t1 (n int); +INSERT INTO t1 VALUES (1); +SELECT n+1 AS n FROM t1 GROUP BY n; +n +2 +Warnings: +Warning 1052 Column 'n' in group statement is ambiguous +DROP TABLE t1; +create table t1(f1 varchar(5) key); +insert into t1 values (1),(2); +select sql_buffer_result max(f1) is null from t1; +max(f1) is null +0 +select sql_buffer_result max(f1)+1 from t1; +max(f1)+1 +3 +drop table t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT a FROM t1 GROUP BY 'a'; +a +1 +SELECT a FROM t1 GROUP BY "a"; +a +1 +SELECT a FROM t1 GROUP BY `a`; +a +1 +2 +set sql_mode=ANSI_QUOTES; +SELECT a FROM t1 GROUP BY "a"; +a +1 +2 +SELECT a FROM t1 GROUP BY 'a'; +a +1 +SELECT a FROM t1 GROUP BY `a`; +a +1 +2 +set sql_mode=DEFAULT; +SELECT a FROM t1 HAVING 'a' > 1; +a +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT a FROM t1 HAVING "a" > 1; +a +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +SELECT a FROM t1 HAVING `a` > 1; +a +2 +SELECT a FROM t1 ORDER BY 'a' DESC; +a +1 +2 +SELECT a FROM t1 ORDER BY "a" DESC; +a +1 +2 +SELECT a FROM t1 ORDER BY `a` DESC; +a +2 +1 +DROP TABLE t1; +CREATE TABLE t1 ( +f1 int(10) unsigned NOT NULL auto_increment primary key, +f2 varchar(100) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 varchar(10) NOT NULL default '', +f2 char(3) NOT NULL default '', +PRIMARY KEY (`f1`), +KEY `k1` (`f2`,`f1`) +); +INSERT INTO t1 values(NULL, ''); +INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT'); +SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1; +avg(t2.f1) +SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1; +avg(t2.f1) +DROP TABLE t1, t2; +create table t1 (c1 char(3), c2 char(3)); +create table t2 (c3 char(3), c4 char(3)); +insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2'); +insert into t2 values ('aaa', 'bb1'), ('aaa', 'bb2'); +select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 +group by c2; +c2 +aaa +aaa +Warnings: +Warning 1052 Column 'c2' in group statement is ambiguous +select t1.c1 as c2 from t1, t2 where t1.c2 = t2.c4 +group by t1.c1; +c2 +aaa +drop table t1, t2; +CREATE TABLE t1 (a tinyint(3), b varchar(255), PRIMARY KEY (a)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'-----'), (6,'Allemagne'), (17,'Autriche'), +(25,'Belgique'), (54,'Danemark'), (62,'Espagne'), (68,'France'); +CREATE TABLE t2 (a tinyint(3), b tinyint(3), PRIMARY KEY (a), KEY b (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1), (2,1), (6,6), (18,17), (15,25), (16,25), +(17,25), (10,54), (5,62),(3,68); +CREATE VIEW v1 AS select t1.a, concat(t1.b,'') AS b, t1.b as real_b from t1; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +SELECT straight_join v1.a, v1.b, v1.real_b from t2, v1 +where t2.b=v1.a GROUP BY t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index b b 2 NULL # 100.00 Using where; Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 1 test.t2.b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,concat(`test`.`t1`.`b`,'') AS `b`,`test`.`t1`.`b` AS `real_b` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`b`) group by `test`.`t2`.`b` +SELECT straight_join v1.a, v1.b, v1.real_b from t2, v1 +where t2.b=v1.a GROUP BY t2.b; +a b real_b +1 ----- ----- +6 Allemagne Allemagne +17 Autriche Autriche +25 Belgique Belgique +54 Danemark Danemark +62 Espagne Espagne +68 France France +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, key (b)); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20) FROM t1; +INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20) FROM t1; +INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20) FROM t1; +INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20) FROM t1; +INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20) FROM t1; +INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20) FROM t1; +INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20) FROM t1; +SELECT MIN(b), MAX(b) from t1; +MIN(b) MAX(b) +0 19 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT b, sum(1) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index b b 5 NULL 128 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,sum(1) AS `sum(1)` from `test`.`t1` group by `test`.`t1`.`b` +EXPLAIN SELECT SQL_BIG_RESULT b, sum(1) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index b b 5 NULL 128 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b`,sum(1) AS `sum(1)` from `test`.`t1` group by `test`.`t1`.`b` +SELECT b, sum(1) FROM t1 GROUP BY b; +b sum(1) +0 6 +1 7 +2 7 +3 7 +4 7 +5 7 +6 7 +7 7 +8 7 +9 6 +10 6 +11 6 +12 6 +13 6 +14 6 +15 6 +16 6 +17 6 +18 6 +19 6 +SELECT SQL_BIG_RESULT b, sum(1) FROM t1 GROUP BY b; +b sum(1) +0 6 +1 7 +2 7 +3 7 +4 7 +5 7 +6 7 +7 7 +8 7 +9 6 +10 6 +11 6 +12 6 +13 6 +14 6 +15 6 +16 6 +17 6 +18 6 +19 6 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3); +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +SELECT MAX(a)-MIN(a) FROM t1 GROUP BY b; +MAX(a)-MIN(a) +1 +1 +1 +SELECT CEILING(MIN(a)) FROM t1 GROUP BY b; +CEILING(MIN(a)) +1 +3 +5 +SELECT CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END FROM t1 +GROUP BY b; +CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END +Positive +Positive +Positive +SELECT a + 1 FROM t1 GROUP BY a; +a + 1 +2 +3 +4 +5 +6 +7 +SELECT a + b FROM t1 GROUP BY b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) +FROM t1 AS t1_outer; +(SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) +1 +2 +3 +4 +5 +6 +SELECT 1 FROM t1 as t1_outer GROUP BY a +HAVING (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1); +1 +1 +1 +1 +1 +1 +1 +SELECT (SELECT t1_outer.a FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1_outer.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT 1 FROM t1 as t1_outer GROUP BY a +HAVING (SELECT t1_outer.b FROM t1 AS t1_inner LIMIT 1); +ERROR 42S22: Unknown column 'test.t1_outer.b' in 'field list' +SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +21 +21 +21 +SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) +FROM t1 AS t1_outer; +(SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) +3 +3 +3 +3 +3 +3 +SELECT (SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +3 +7 +11 +SET SQL_MODE = ''; +SELECT (SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) +3 +7 +11 +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +SELECT (SELECT SUM(t1_outer.a+0*t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1_outer.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SET SQL_MODE = ''; +SELECT (SELECT SUM(t1_outer.a+0*t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +FROM t1 AS t1_outer GROUP BY t1_outer.b; +(SELECT SUM(t1_outer.a+0*t1_inner.a) FROM t1 AS t1_inner LIMIT 1) +6 +18 +30 +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +SELECT 1 FROM t1 as t1_outer +WHERE (SELECT t1_outer.b FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1); +1 +1 +1 +1 +1 +1 +1 +SELECT b FROM t1 GROUP BY b HAVING CEILING(b) > 0; +b +1 +2 +3 +SELECT 1 FROM t1 GROUP BY b HAVING b = 2 OR b = 3 OR SUM(a) > 12; +1 +1 +1 +SELECT 1 FROM t1 GROUP BY b HAVING ROW (b,b) = ROW (1,1); +1 +1 +SELECT 1 FROM t1 GROUP BY b HAVING a = 2; +ERROR 42S22: Unknown column 'a' in 'having clause' +SELECT 1 FROM t1 GROUP BY SUM(b); +ERROR HY000: Invalid use of group function +SELECT b FROM t1 AS t1_outer GROUP BY a HAVING t1_outer.a IN +(SELECT SUM(t1_inner.b)+t1_outer.b FROM t1 AS t1_inner GROUP BY t1_inner.a +HAVING SUM(t1_inner.b)+t1_outer.b > 5); +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1_outer.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +SET SQL_MODE = ''; +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +create table t1(f1 int, f2 int); +select * from t1 group by f1; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.f2' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select * from t1 group by f2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.f1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select * from t1 group by f1, f2; +f1 f2 +select t1.f1,t.* from t1, t1 t group by 1; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.f1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table t1; +SET SQL_MODE = DEFAULT; +CREATE TABLE t1( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +c2 INT NOT NULL, +UNIQUE KEY (c2,c1)); +INSERT INTO t1(c1,c2) VALUES (5,1), (4,1), (3,5), (2,3), (1,3); +SELECT * FROM t1 ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY id DESC; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY c2 ,c1, id ORDER BY c2, c1; +id c1 c2 +2 4 1 +1 5 1 +5 1 3 +4 2 3 +3 3 5 +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1; +id c1 c2 +3 3 5 +5 1 3 +4 2 3 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY c2, c1, id ORDER BY c2 DESC, c1 DESC; +id c1 c2 +3 3 5 +4 2 3 +5 1 3 +1 5 1 +2 4 1 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2, c1; +id c1 c2 +2 4 1 +5 1 3 +3 3 5 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1; +id c1 c2 +3 3 5 +5 1 3 +2 4 1 +SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC; +id c1 c2 +3 3 5 +5 1 3 +2 4 1 +DROP TABLE t1; +# +# Bug#27219: Aggregate functions in ORDER BY. +# +SET @save_sql_mode=@@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1 (a INT, b INT, c INT DEFAULT 0); +INSERT INTO t1 (a, b) VALUES (3,3), (2,2), (3,3), (2,2), (3,3), (4,4); +CREATE TABLE t2 SELECT * FROM t1; +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*) + 1; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*) + a; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*), 1; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*), a; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a + 1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a) + 1; +COUNT(*) +6 +SELECT COUNT(*) FROM t1 ORDER BY SUM(a), b; +COUNT(*) +6 +SELECT SUM(a) FROM t1 ORDER BY COUNT(b); +SUM(a) +17 +SELECT t1.a FROM t1 ORDER BY (SELECT SUM(t2.a) FROM t2); +a +3 +2 +3 +2 +3 +4 +SELECT t1.a FROM t1 ORDER BY (SELECT SUM(t2.a), t2.a FROM t2); +ERROR 21000: Operand should contain 1 column(s) +SELECT t1.a FROM t1 ORDER BY (SELECT SUM(t2.a) FROM t2 ORDER BY t2.a); +a +3 +2 +3 +2 +3 +4 +SELECT t1.a FROM t1 ORDER BY (SELECT t2.a FROM t2 ORDER BY SUM(t2.b) LIMIT 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 +WHERE t1.a = (SELECT t2.a FROM t2 ORDER BY SUM(t2.b) LIMIT 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a = (SELECT t2.a FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a IN (SELECT t2.a FROM t2 ORDER BY SUM(t1.b)); +a +2 +3 +4 +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a IN (SELECT t2.a FROM t2 ORDER BY t2.a, SUM(t2.b)); +ERROR HY000: Expression #2 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING t1.a > ANY (SELECT t2.a FROM t2 ORDER BY t2.a, SUM(t2.b)); +ERROR HY000: Expression #2 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT t1.a FROM t1 +WHERE t1.a = (SELECT t2.a FROM t2 ORDER BY SUM(t1.b)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + 1) FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + t2.b) FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(t1.b + t2.b) FROM t2 ORDER BY SUM(t2.a) LIMIT 1); +ERROR 42000: Expression #1 of HAVING clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + 1) FROM t2 ORDER BY t2.a LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(SUM(t1.b) + t2.b) FROM t2 ORDER BY t2.a LIMIT 1); +1 +1 +1 +1 +SELECT 1 FROM t1 GROUP BY t1.a +HAVING (SELECT AVG(t1.b + t2.b) FROM t2 ORDER BY t2.a LIMIT 1); +ERROR 42000: Expression #1 of HAVING clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t1.a FROM t1 +WHERE t1.a = (SELECT t2.a FROM t2 GROUP BY t2.a +ORDER BY SUM(t2.b), SUM(t1.b) LIMIT 1); +a +4 +SELECT t1.a, SUM(t1.b) FROM t1 +WHERE t1.a = (SELECT SUM(t2.b) FROM t2 GROUP BY t2.a +ORDER BY SUM(t2.b), SUM(t1.b) LIMIT 1) +GROUP BY t1.a; +a SUM(t1.b) +4 4 +SELECT t1.a, SUM(t1.b) FROM t1 +WHERE t1.a = (SELECT SUM(t2.b) FROM t2 +ORDER BY SUM(t2.b) + SUM(t1.b) LIMIT 1) +GROUP BY t1.a; +a SUM(t1.b) +SELECT t1.a, SUM(t1.b) FROM t1 +WHERE t1.a = (SELECT SUM(t2.b) FROM t2 +ORDER BY SUM(t2.b + t1.a) LIMIT 1) +GROUP BY t1.a; +a SUM(t1.b) +SELECT t1.a FROM t1 GROUP BY t1.a +HAVING (1, 1) = (SELECT SUM(t1.a), t1.a FROM t2 LIMIT 1); +a +select avg ( +(select +(select sum(outr.a + innr.a) from t1 as innr limit 1) as tt +from t1 as outr order by outr.a limit 1)) +from t1 as most_outer; +avg ( +(select +(select sum(outr.a + innr.a) from t1 as innr limit 1) as tt +from t1 as outr order by outr.a limit 1)) +29.0000 +select avg ( +(select ( +(select sum(outr.a + innr.a) from t1 as innr limit 1)) as tt +from t1 as outr order by count(outr.a) limit 1)) as tt +from t1 as most_outer; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +select (select sum(outr.a + t1.a) from t1 limit 1) as tt from t1 as outr order by outr.a; +tt +29 +29 +35 +35 +35 +41 +SET sql_mode=@save_sql_mode; +DROP TABLE t1, t2; +# +# BUG#38072: Wrong result: HAVING not observed in a query with aggregate +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,5,5, 'h','h'), +(2,1,1, '{','{'), +(3,1,1, 'z','z'), +(4,8,8, 'x','x'), +(5,7,7, 'o','o'), +(6,3,3, 'p','p'), +(7,9,9, 'c','c'), +(8,0,0, 'k','k'), +(9,6,6, 't','t'), +(10,0,0,'c','c'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT COUNT(varchar_key) AS x FROM t1 WHERE pk = 8 having 'foo'='bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`varchar_key`) AS `x` from `test`.`t1` where multiple equal(8, `test`.`t1`.`pk`) having false +SELECT COUNT(varchar_key) AS x FROM t1 WHERE pk = 8 having 'foo'='bar'; +x +drop table t1; +End of 5.0 tests +CREATE TABLE t1 (a INT, b INT, +PRIMARY KEY (a), +KEY i2(a,b)); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +INSERT INTO t1 SELECT a + 8,b FROM t1; +INSERT INTO t1 SELECT a + 16,b FROM t1; +INSERT INTO t1 SELECT a + 32,b FROM t1; +INSERT INTO t1 SELECT a + 64,b FROM t1; +INSERT INTO t1 SELECT a + 128,b FROM t1 limit 16; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i2 PRIMARY 4 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a FROM t1 WHERE a < 2 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i2 PRIMARY 4 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 WHERE a < 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i2 PRIMARY 4 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 2) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`i2`) IGNORE INDEX (PRIMARY) +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR JOIN (`i2`) IGNORE INDEX FOR JOIN (PRIMARY) +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR GROUP BY (`i2`) IGNORE INDEX FOR GROUP BY (PRIMARY) group by `test`.`t1`.`a` +FLUSH STATUS; +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +SHOW SESSION STATUS LIKE 'Sort_scan%'; +Variable_name Value +Sort_scan 0 +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 144 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR ORDER BY (`i2`) IGNORE INDEX FOR ORDER BY (PRIMARY) order by `test`.`t1`.`a` +FLUSH STATUS; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +SHOW SESSION STATUS LIKE 'Sort_scan%'; +Variable_name Value +Sort_scan 1 +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) +IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR GROUP BY (`i2`) IGNORE INDEX FOR ORDER BY (PRIMARY) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY) IGNORE INDEX FOR ORDER BY (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR ORDER BY (`i2`) IGNORE INDEX (PRIMARY) +EXPLAIN SELECT a FROM t1 FORCE INDEX (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` FORCE INDEX (`i2`) +EXPLAIN SELECT a FROM t1 USE INDEX (); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX () +EXPLAIN SELECT a FROM t1 USE INDEX () USE INDEX (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX (`i2`) USE INDEX () +EXPLAIN SELECT a FROM t1 +FORCE INDEX (PRIMARY) +IGNORE INDEX FOR GROUP BY (i2) +IGNORE INDEX FOR ORDER BY (i2) +USE INDEX (i2); +ERROR HY000: Incorrect usage of USE INDEX and FORCE INDEX +EXPLAIN SELECT a FROM t1 USE INDEX (i2) USE INDEX (); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX () USE INDEX (`i2`) +EXPLAIN SELECT a FROM t1 FORCE INDEX (); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +EXPLAIN SELECT a FROM t1 IGNORE INDEX (); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +EXPLAIN SELECT a FROM t1 USE INDEX FOR JOIN (i2) +USE INDEX FOR GROUP BY (i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i2 i2 9 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX FOR GROUP BY (`i2`) USE INDEX FOR JOIN (`i2`) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 FORCE INDEX FOR JOIN (i2) +FORCE INDEX FOR GROUP BY (i2) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i2 i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` FORCE INDEX FOR GROUP BY (`i2`) FORCE INDEX FOR JOIN (`i2`) group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 USE INDEX () IGNORE INDEX (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`i2`) USE INDEX () +EXPLAIN SELECT a FROM t1 IGNORE INDEX (i2) USE INDEX (); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX () IGNORE INDEX (`i2`) +EXPLAIN SELECT a FROM t1 +USE INDEX FOR GROUP BY (i2) +USE INDEX FOR ORDER BY (i2) +USE INDEX FOR JOIN (i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX FOR JOIN (`i2`) USE INDEX FOR ORDER BY (`i2`) USE INDEX FOR GROUP BY (`i2`) +EXPLAIN SELECT a FROM t1 +USE INDEX FOR JOIN (i2) +USE INDEX FOR JOIN (i2) +USE INDEX FOR JOIN (i2,i2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 144 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i2 9 NULL 144 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDEX FOR JOIN (`i2`) USE INDEX FOR JOIN (`i2`) USE INDEX FOR JOIN (`i2`) USE INDEX FOR JOIN (`i2`) +EXPLAIN SELECT 1 FROM t1 WHERE a IN +(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1` IGNORE INDEX (`i2`) USE INDEX (`i2`)) where (``.`a` = `test`.`t1`.`a`) +CREATE TABLE t2 (a INT, b INT, KEY(a)); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); +EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 5 NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` group by `test`.`t2`.`a` limit 2 +EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,sum(`test`.`t2`.`b`) AS `SUM(b)` from `test`.`t2` IGNORE INDEX (`a`) group by `test`.`t2`.`a` limit 2 +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT 1 FROM t2 WHERE a IN +(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` semi join (`test`.`t1` IGNORE INDEX (`i2`) USE INDEX (`i2`)) where (``.`a` = `test`.`t2`.`a`) +SHOW VARIABLES LIKE 'old'; +Variable_name Value +old OFF +SET @@old = off; +ERROR HY000: Variable 'old' is a read only variable +DROP TABLE t1, t2; +CREATE TABLE t1( +a INT, +b INT NOT NULL, +c INT NOT NULL, +d INT, +UNIQUE KEY (c,b) +); +INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); +CREATE TABLE t2( +a INT, +b INT, +UNIQUE KEY(a,b) +); +INSERT INTO t2 VALUES (NULL, NULL), (NULL, NULL), (NULL, 1), (1, NULL), (1, 1), (1,2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 GROUP BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` order by NULL +SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 ORDER BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b,d FROM t1 GROUP BY c,b; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index c c 8 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b FROM t1 GROUP BY c,b; +c b +1 1 +3 1 +3 2 +EXPLAIN SELECT a,b from t2 ORDER BY a,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL a 10 NULL 6 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` +SELECT a,b from t2 ORDER BY a,b; +a b +NULL NULL +NULL NULL +NULL 1 +1 NULL +1 1 +1 2 +EXPLAIN SELECT a,b from t2 GROUP BY a,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 10 NULL 6 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` group by `test`.`t2`.`a`,`test`.`t2`.`b` +SELECT a,b from t2 GROUP BY a,b; +a b +NULL NULL +NULL 1 +1 NULL +1 1 +1 2 +EXPLAIN SELECT a from t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 5 NULL 3 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` group by `test`.`t2`.`a` +SELECT a from t2 GROUP BY a; +a +NULL +1 +EXPLAIN SELECT b from t2 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 10 NULL 6 100.00 Using index; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` group by `test`.`t2`.`b` +SELECT b from t2 GROUP BY b; +b +NULL +1 +2 +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 ( a INT, b INT ); +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +c (SELECT a FROM t1 WHERE b = c) +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +c (SELECT a FROM t1 WHERE b = c) +SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +ERROR 42S22: Reference 'c' not supported (reference to group function) +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +c (SELECT a FROM t1 WHERE b = c) +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +c (SELECT a FROM t1 WHERE b = c) +SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; +ERROR 42S22: Reference 'c' not supported (reference to group function) +INSERT INTO t1 VALUES (1, 1); +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +c (SELECT a FROM t1 WHERE b = c) +1 1 +INSERT INTO t1 VALUES (2, 1); +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (10); +SELECT COUNT(i) FROM t1; +COUNT(i) +2 +SELECT COUNT(i) FROM t1 WHERE i > 1; +COUNT(i) +1 +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; +# +# Bug #45640: optimizer bug produces wrong results +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (4, 40), (1, 10), (2, 20), (2, 20), (3, 30); +# should return 4 ordered records: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +SELECT (SELECT (SELECT t1.a)) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +# should return the same result in a reverse order: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; +aa COUNT(DISTINCT b) +4 1 +3 1 +2 1 +1 1 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# execution plan should not use temporary table: +EXPLAIN +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by (`a` + 0) +EXPLAIN +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by -(`a`) +# should return only one record +SELECT (SELECT tt.a FROM t1 tt LIMIT 1) aa, COUNT(DISTINCT b) FROM t1 +GROUP BY aa; +aa COUNT(DISTINCT b) +4 4 +CREATE TABLE t2 SELECT DISTINCT a FROM t1; +# originally reported queries (1st two columns of next two query +# results should be same): +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) +FROM t1 GROUP BY aa, b; +aa b COUNT(DISTINCT b) +1 10 1 +2 20 1 +3 30 1 +4 40 1 +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) +FROM t1 GROUP BY aa, b; +aa b COUNT( b) +1 10 1 +2 20 2 +3 30 1 +4 40 1 +# ORDER BY for sure: +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) +FROM t1 GROUP BY aa, b ORDER BY -aa, -b; +aa b COUNT(DISTINCT b) +4 40 1 +3 30 1 +2 20 1 +1 10 1 +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) +FROM t1 GROUP BY aa, b ORDER BY -aa, -b; +aa b COUNT( b) +4 40 1 +3 30 1 +2 20 2 +1 10 1 +DROP TABLE t1, t2; +# +# Bug#52051: Aggregate functions incorrectly returns NULL from outer +# join query +# +CREATE TABLE t1 (a INT PRIMARY KEY); +CREATE TABLE t2 (a INT PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`a`) AS `MIN(t2.a)` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`a`, `test`.`t1`.`a`)) +SELECT MIN(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +MIN(t2.a) +1 +EXPLAIN SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`a`) AS `MAX(t2.a)` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`a`, `test`.`t1`.`a`)) +SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; +MAX(t2.a) +2 +DROP TABLE t1, t2; +# +# Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results +# +CREATE TABLE t1 (a text, b varchar(10)); +INSERT INTO t1 VALUES (repeat('1', 1300),'one'), (repeat('1', 1300),'two'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select substr(`test`.`t1`.`a`,1,10) AS `SUBSTRING(a,1,10)`,length(`test`.`t1`.`a`) AS `LENGTH(a)`,group_concat(`test`.`t1`.`b` separator ',') AS `GROUP_CONCAT(b)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT SUBSTRING(a,1,10), LENGTH(a), GROUP_CONCAT(b) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) GROUP_CONCAT(b) +1111111111 1300 one,two +EXPLAIN +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Using temporary +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select substr(`test`.`t1`.`a`,1,10) AS `SUBSTRING(a,1,10)`,length(`test`.`t1`.`a`) AS `LENGTH(a)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; +SUBSTRING(a,1,10) LENGTH(a) +1111111111 1300 +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1(f1 INT NOT NULL); +INSERT INTO t1 VALUES (16777214),(0); +SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2 +ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1; +COUNT(*) +2 +DROP TABLE t1; +# +# Bug#12798270: ASSERTION `!TAB->SORTED' FAILED IN JOIN_READ_KEY2 +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (pk int PRIMARY KEY); +INSERT INTO t2 VALUES (10); +CREATE VIEW v1 AS SELECT t2.pk FROM t2; +SELECT v1.pk +FROM t1 LEFT JOIN v1 ON t1.i = v1.pk +GROUP BY v1.pk; +pk +NULL +DROP VIEW v1; +DROP TABLE t1,t2; +# End of Bug#12798270 +# +# Bug#59839: Aggregation followed by subquery yields wrong result +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +KEY (a, b) +); +INSERT INTO t1 VALUES +( 1, 1, 1 ), +( 1, 2, 2 ), +( 1, 3, 3 ), +( 1, 4, 6 ), +( 1, 5, 5 ), +( 1, 9, 13 ), +( 2, 1, 6 ), +( 2, 2, 7 ), +( 2, 3, 8 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT a, AVG(t1.b), +(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c, +(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c +FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index a a 10 NULL 9 100.00 Using index +3 DEPENDENT SUBQUERY t12 NULL ref a a 10 func,func 1 100.00 Using where +2 DEPENDENT SUBQUERY t11 NULL ref a a 10 func,func 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,avg(`test`.`t1`.`b`) AS `AVG(t1.b)`,(/* select#2 */ select `test`.`t11`.`c` from `test`.`t1` `t11` where ((`test`.`t11`.`a` = `test`.`t1`.`a`) and (`test`.`t11`.`b` = avg(`test`.`t1`.`b`)))) AS `t11c`,(/* select#3 */ select `test`.`t12`.`c` from `test`.`t1` `t12` where ((`test`.`t12`.`a` = `test`.`t1`.`a`) and (`test`.`t12`.`b` = avg(`test`.`t1`.`b`)))) AS `t12c` from `test`.`t1` group by `test`.`t1`.`a` +SELECT a, AVG(t1.b), +(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c, +(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c +FROM t1 GROUP BY a; +a AVG(t1.b) t11c t12c +1 4.0000 6 6 +2 2.0000 7 7 +DROP TABLE t1; +# +# Bug#11765254 (58200): Assertion failed: param.sort_length when grouping +# by functions +# +SET BIG_TABLES=1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +SELECT 1 FROM t1 GROUP BY IF(`a`,'',''); +ERROR 42000: The used storage engine can't index column '`if(t1.a,'','')`' +SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND() FROM ''); +1 +1 +SELECT 1 FROM t1 GROUP BY SUBSTRING('',SLEEP(0),''); +1 +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect INTEGER value: '' +SELECT 1 FROM t1 GROUP BY SUBSTRING(SYSDATE() FROM 'K' FOR 'jxW<'); +1 +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +DROP TABLE t1; +SET BIG_TABLES=0; +# End of 5.1 tests +# +# Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00 +# +SET @save_sql_mode=@@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1 (f1 int, f2 DATE); +INSERT INTO t1 VALUES (1,'2004-04-19'), (1,'0000-00-00'), (1,'2004-04-18'), +(2,'2004-05-19'), (2,'0001-01-01'), (3,'2004-04-10'); +SELECT MIN(f2),MAX(f2) FROM t1; +MIN(f2) MAX(f2) +0000-00-00 2004-05-19 +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; +f1 MIN(f2) MAX(f2) +1 0000-00-00 2004-04-19 +2 0001-01-01 2004-05-19 +3 2004-04-10 2004-04-10 +DROP TABLE t1; +CREATE TABLE t1 ( f1 int, f2 time); +INSERT INTO t1 VALUES (1,'01:27:35'), (1,'06:11:01'), (2,'19:53:05'), +(2,'21:44:25'), (3,'10:55:12'), (3,'05:45:11'), (4,'00:25:00'); +SELECT MIN(f2),MAX(f2) FROM t1; +MIN(f2) MAX(f2) +00:25:00 21:44:25 +SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; +f1 MIN(f2) MAX(f2) +1 01:27:35 06:11:01 +2 19:53:05 21:44:25 +3 05:45:11 10:55:12 +4 00:25:00 00:25:00 +DROP TABLE t1; +SET sql_mode=@save_sql_mode; +#End of test#49771 +# +# Bug #58782 +# Missing rows with SELECT .. WHERE .. IN subquery +# with full GROUP BY and no aggr +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (10,7); +INSERT INTO t1 VALUES (11,1); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (13,3); +SELECT pk AS field1, col_int_nokey AS field2 +FROM t1 +WHERE col_int_nokey > 0 +GROUP BY field1, field2; +field1 field2 +10 7 +11 1 +12 5 +13 3 +CREATE TABLE where_subselect +SELECT pk AS field1, col_int_nokey AS field2 +FROM t1 +WHERE col_int_nokey > 0 +GROUP BY field1, field2 +; +SELECT * +FROM where_subselect +WHERE (field1, field2) IN ( +SELECT pk AS field1, col_int_nokey AS field2 +FROM t1 +WHERE col_int_nokey > 0 +GROUP BY field1, field2 +); +field1 field2 +10 7 +11 1 +12 5 +13 3 +DROP TABLE t1; +DROP TABLE where_subselect; +# End of Bug #58782 +# +# Bug #11766429 +# RE-EXECUTE OF PREPARED STATEMENT CRASHES IN ITEM_REF::FIX_FIELDS WITH +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (0); +CREATE TABLE t2(b INT, KEY(b)); +INSERT INTO t2 VALUES (0),(0); +PREPARE stmt FROM ' +SELECT 1 FROM t2 +LEFT JOIN t1 ON NULL +GROUP BY t2.b, t1.a +HAVING a <> 2'; +EXECUTE stmt; +1 +EXECUTE stmt; +1 +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; +# End of Bug #11766429 +# +# Bug#12699645 SELECT SUM() + STRAIGHT_JOIN QUERY MISSES ROWS +# +CREATE TABLE t1 ( +pk INT, col_int_key INT, +col_varchar_key VARCHAR(1), col_varchar_nokey VARCHAR(1) +); +INSERT INTO t1 VALUES +(10,7,'v','v'),(11,0,'s','s'),(12,9,'l','l'),(13,3,'y','y'),(14,4,'c','c'), +(15,2,'i','i'),(16,5,'h','h'),(17,3,'q','q'),(18,1,'a','a'),(19,3,'v','v'), +(20,6,'u','u'),(21,7,'s','s'),(22,5,'y','y'),(23,1,'z','z'),(24,204,'h','h'), +(25,224,'p','p'),(26,9,'e','e'),(27,5,'i','i'),(28,0,'y','y'),(29,3,'w','w'); +CREATE TABLE t2 ( +pk INT, col_int_key INT, +col_varchar_key VARCHAR(1), col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,4,'b','b'),(2,8,'y','y'),(3,0,'p','p'),(4,0,'f','f'),(5,0,'p','p'), +(6,7,'d','d'),(7,7,'f','f'),(8,5,'j','j'),(9,3,'e','e'),(10,188,'u','u'), +(11,4,'v','v'),(12,9,'u','u'),(13,6,'i','i'),(14,1,'x','x'),(15,5,'l','l'), +(16,6,'q','q'),(17,2,'n','n'),(18,4,'r','r'),(19,231,'c','c'),(20,4,'h','h'), +(21,3,'k','k'),(22,3,'t','t'),(23,7,'t','t'),(24,6,'k','k'),(25,7,'g','g'), +(26,9,'z','z'),(27,4,'n','n'),(28,4,'j','j'),(29,2,'l','l'),(30,1,'d','d'), +(31,2,'t','t'),(32,194,'y','y'),(33,2,'i','i'),(34,3,'j','j'),(35,8,'r','r'), +(36,4,'b','b'),(37,9,'o','o'),(38,4,'k','k'),(39,5,'a','a'),(40,5,'f','f'), +(41,9,'t','t'),(42,3,'c','c'),(43,8,'c','c'),(44,0,'r','r'),(45,98,'k','k'), +(46,3,'l','l'),(47,1,'o','o'),(48,0,'t','t'),(49,189,'v','v'),(50,8,'x','x'), +(51,3,'j','j'),(52,3,'x','x'),(53,9,'k','k'),(54,6,'o','o'),(55,8,'z','z'), +(56,3,'n','n'),(57,9,'c','c'),(58,5,'d','d'),(59,9,'s','s'),(60,2,'j','j'), +(61,2,'w','w'),(62,5,'f','f'),(63,8,'p','p'),(64,6,'o','o'),(65,9,'f','f'), +(66,0,'x','x'),(67,3,'q','q'),(68,6,'g','g'),(69,5,'x','x'),(70,8,'p','p'), +(71,2,'q','q'),(72,120,'q','q'),(73,25,'v','v'),(74,1,'g','g'),(75,3,'l','l'), +(76,1,'w','w'),(77,3,'h','h'),(78,153,'c','c'),(79,5,'o','o'),(80,9,'o','o'), +(81,1,'v','v'),(82,8,'y','y'),(83,7,'d','d'),(84,6,'p','p'),(85,2,'z','z'), +(86,4,'t','t'),(87,7,'b','b'),(88,3,'y','y'),(89,8,'k','k'),(90,4,'c','c'), +(91,6,'z','z'),(92,1,'t','t'),(93,7,'o','o'),(94,1,'u','u'),(95,0,'t','t'), +(96,2,'k','k'),(97,7,'u','u'),(98,2,'b','b'),(99,1,'m','m'),(100,5,'o','o'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1 +STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk +GROUP BY field2 ORDER BY alias1.col_int_key,alias2.pk ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 90.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL # 90.00 Using where; Using temporary; Using filesort +2 SIMPLE alias2 NULL eq_ref PRIMARY PRIMARY 4 test.alias1.col_int_key # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias2`.`col_varchar_nokey`) AS `SUM(alias2.col_varchar_nokey)`,`test`.`alias2`.`pk` AS `field2` from `test`.`t1` `alias1` straight_join `test`.`t2` `alias2` where ((`test`.`alias2`.`pk` = `test`.`alias1`.`col_int_key`) and (0 <> `test`.`alias1`.`pk`)) group by `field2` order by `test`.`alias1`.`col_int_key` +SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1 +STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk +GROUP BY field2 ORDER BY alias1.col_int_key,alias2.pk ; +SUM(alias2.col_varchar_nokey) field2 +0 1 +0 2 +0 3 +0 4 +0 5 +0 6 +0 7 +0 9 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'y' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'd' +Warning 1292 Truncated incorrect DOUBLE value: 'f' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'b' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +Warning 1292 Truncated incorrect DOUBLE value: 'p' +DROP TABLE t1,t2; +# +# Bug#12798270: ASSERTION `!TAB->SORTED' FAILED IN JOIN_READ_KEY2 +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (pk int PRIMARY KEY); +INSERT INTO t2 VALUES (10); +CREATE VIEW v1 AS SELECT t2.pk FROM t2; +SELECT v1.pk +FROM t1 LEFT JOIN v1 ON t1.i = v1.pk +GROUP BY v1.pk; +pk +NULL +DROP VIEW v1; +DROP TABLE t1,t2; +# End of Bug#12798270 +# +# Bug#12837714: ADDITIONAL NULL IN 5.6 ON GROUPED SELECT +# +CREATE TABLE t1 (vc varchar(1), INDEX vc_idx (vc)) ; +INSERT INTO t1 VALUES (NULL), ('o'), (NULL), ('p'), ('c'); +FLUSH TABLE t1; +SELECT vc FROM t1 GROUP BY vc; +vc +NULL +c +o +p +DROP TABLE t1; +# End of Bug#12837714 +# +# Bug#12578908: SELECT SQL_BUFFER_RESULT OUTPUTS TOO MANY +# ROWS WHEN GROUP IS OPTIMIZED AWAY +# +CREATE TABLE t1 (col1 int, col2 int) ; +INSERT INTO t1 VALUES (10,1),(11,7); +CREATE TABLE t2 (col1 int, col2 int) ; +INSERT INTO t2 VALUES (10,8); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +EXPLAIN SELECT SQL_BUFFER_RESULT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t2`.`col2` AS `col2` from `test`.`t2` join `test`.`t1` where (0 <> `test`.`t1`.`col1`) group by `test`.`t2`.`col2` +SELECT SQL_BUFFER_RESULT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +col2 +8 + +EXPLAIN SELECT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col2` AS `col2` from `test`.`t2` join `test`.`t1` where (0 <> `test`.`t1`.`col1`) group by `test`.`t2`.`col2` +SELECT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2; +col2 +8 + +DROP TABLE t1,t2; +# +# Bug#11761078: 53534: INCORRECT 'SELECT SQL_BIG_RESULT...' +# WITH GROUP BY ON DUPLICATED FIELDS +# +CREATE TABLE t1( +col1 int, +INDEX idx (col1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2 +FROM t1 GROUP BY field1, field2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx idx 5 NULL 20 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`col1` AS `field1`,`test`.`t1`.`col1` AS `field2` from `test`.`t1` group by `field1` +FLUSH STATUS; +SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2 +FROM t1 GROUP BY field1, field2;; +field1 field2 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +SHOW SESSION STATUS LIKE 'Sort_scan%'; +Variable_name Value +Sort_scan 1 +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2 +FROM v1 +GROUP BY field1, field2; +field1 field2 +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +SELECT SQL_BIG_RESULT tbl1.col1 AS field1, tbl2.col1 AS field2 +FROM t1 as tbl1, t1 as tbl2 +GROUP BY field1, field2 +ORDER BY field1, field2 +LIMIT 3; +field1 field2 +1 1 +1 2 +1 3 +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#13422961: WRONG RESULTS FROM SELECT WITH AGGREGATES AND +# IMPLICIT GROUPING + MYISAM OR MEM +# +CREATE TABLE it ( +pk INT NOT NULL, +col_int_nokey INT NOT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE ot ( +pk int(11) NOT NULL, +col_int_nokey int(11) NOT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot VALUES (10,8); + +SELECT col_int_nokey, MAX( pk ) +FROM ot +WHERE (8, 1) IN ( SELECT pk, COUNT( col_int_nokey ) FROM it ); +col_int_nokey MAX( pk ) +NULL NULL + +DROP TABLE it,ot; +# +# Bug#13430588: WRONG RESULT FROM IMPLICITLY GROUPED QUERY WITH +# CONST TABLE AND NO MATCHING ROWS +# +CREATE TABLE t1 (i INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (j INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(2); + +SELECT i, j, COUNT(i) FROM t1 JOIN t2 WHERE j=3; +i j COUNT(i) +NULL NULL 0 + +DROP TABLE t1,t2; +# +# BUG#13541761: WRONG RESULTS ON CORRELATED SUBQUERY + +# AGGREGATE FUNCTION + MYISAM OR MEMORY +# +CREATE TABLE t1 ( +a varchar(1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('a'), ('b'); +CREATE TABLE t2 ( +a varchar(1), +b int(11) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('a',1); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +EXPLAIN SELECT (SELECT MAX(b) FROM t2 WHERE t2.a != t1.a) as MAX +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max('1') from dual where ('a' <> `test`.`t1`.`a`)) AS `MAX` from `test`.`t1` +SELECT (SELECT MAX(b) FROM t2 WHERE t2.a != t1.a) as MAX +FROM t1; +MAX +NULL +1 +DROP TABLE t1,t2; +# Bug 11923239 - ERROR WITH CORRELATED SUBQUERY IN VIEW WITH +# ONLY_FULL_GROUP_BY SQL MODE +SET @old_sql_mode = @@sql_mode; +SET sql_mode=''; +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_int_nokey INT, +col_varchar_key VARCHAR(10), +col_varchar_nokey VARCHAR(10), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# In GROUP BY, aliases are printed as aliases. +EXPLAIN SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, field2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 DEPENDENT SUBQUERY alias2 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int_nokey` AS `field1`,(/* select#2 */ select `test`.`alias2`.`col_int_key` from `test`.`t1` `alias2` where (`test`.`alias1`.`col_varchar_key` <= `test`.`alias1`.`col_varchar_nokey`)) AS `field2` from `test`.`t1` `alias1` group by `field1`,`field2` +# In GROUP BY, expressions are printed as expressions. +EXPLAIN SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +3 DEPENDENT SUBQUERY alias2 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY alias2 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias1.col_varchar_nokey' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int_nokey` AS `field1`,(/* select#2 */ select `test`.`alias2`.`col_int_key` from `test`.`t1` `alias2` where (`test`.`alias1`.`col_varchar_key` <= `test`.`alias1`.`col_varchar_nokey`)) AS `field2` from `test`.`t1` `alias1` group by `field1`,(/* select#3 */ select `test`.`alias2`.`col_int_key` from `test`.`t1` `alias2` where (`test`.`alias1`.`col_varchar_key` <= `test`.`alias1`.`col_varchar_nokey`)) +# Aliased expression in GROUP BY in a view. +CREATE VIEW v1 AS SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, field2; +# In GROUP BY, aliases are printed as aliases. +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `alias1`.`col_int_nokey` AS `field1`,(select `alias2`.`col_int_key` from `t1` `alias2` where (`alias1`.`col_varchar_key` <= `alias1`.`col_varchar_nokey`)) AS `field2` from `t1` `alias1` group by `field1`,`field2` utf8mb4 utf8mb4_0900_ai_ci +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, field2; +field1 field2 +NULL NULL +# The SELECT above has been accepted, and v1 was created +# using the same SELECT as above, so SELECTing from v1 +# should be accepted. +SELECT * FROM v1; +field1 field2 +NULL NULL +# Here is why in GROUP BY we print aliases of subqueries as +# aliases: below, "GROUP BY (subquery)" confuses +# ONLY_FULL_GROUP_BY, it causes an error though the subquery of +# GROUP BY and of SELECT list are the same. Fixing this would +# require implementing Item_subselect::eq(). It's not worth +# the effort because: +# a) GROUP BY (subquery) is non-SQL-standard so is likely of +# very little interest to users of ONLY_FULL_GROUP_BY +# b) as the user uses ONLY_FULL_GROUP_BY, he wants to have the +# same subquery in GROUP BY and SELECT list, so can give the +# subquery an alias in the SELECT list and use this alias in +# GROUP BY, thus avoiding the problem. +SELECT alias1.col_int_nokey AS field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +) AS field2 +FROM t1 AS alias1 +GROUP BY field1, +(SELECT alias2.col_int_key +FROM t1 AS alias2 +WHERE alias1.col_varchar_key <= alias1.col_varchar_nokey +); +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.alias1.col_varchar_key' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v1; +SET @@sql_mode = @old_sql_mode; +# Verify that if an alias is used in GROUP BY/ORDER BY it +# is printed as an alias, not as the expression. +CREATE TABLE t2(a INT); +INSERT INTO t2 VALUES(3),(4); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT +pk AS foo, col_int_key AS bar, (SELECT a FROM t2 WHERE a=t1.pk) AS baz +FROM t1 +GROUP BY foo, col_int_key, baz ORDER BY pk, bar, (SELECT a FROM t2 WHERE a=t1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `foo`,`test`.`t1`.`col_int_key` AS `bar`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) AS `baz` from `test`.`t1` group by `foo`,`test`.`t1`.`col_int_key`,`baz` order by `test`.`t1`.`pk`,`bar`,(/* select#3 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) +EXPLAIN SELECT +pk AS foo, col_int_key AS foo, (SELECT a FROM t2 WHERE a=t1.pk) AS foo +FROM t1 +GROUP BY pk, col_int_key, (SELECT a FROM t2 WHERE a=t1.pk) +ORDER BY pk, col_int_key, (SELECT a FROM t2 WHERE a=t1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.pk' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.pk' of SELECT #4 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `foo`,`test`.`t1`.`col_int_key` AS `foo`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) AS `foo` from `test`.`t1` group by `test`.`t1`.`pk`,`test`.`t1`.`col_int_key`,(/* select#3 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) order by `test`.`t1`.`pk`,`test`.`t1`.`col_int_key`,(/* select#4 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`pk`)) +DROP TABLE t1,t2; +# +# Bug#13591138 - ASSERTION NAME && !IS_AUTOGENERATED_NAME IN +# ITEM::PRINT_FOR_ORDER ON EXPLAIN EXT +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_datetime_key datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW view1 AS SELECT * FROM t1; +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT +alias1.col_datetime_key AS field1 +FROM ( +view1 AS alias1, +t3 AS alias2 +) +WHERE ( +(SELECT MIN(sq1_alias1.pk) +FROM t2 AS sq1_alias1 +) +) OR (alias1.col_varchar_key = alias2.col_varchar_key +AND alias1.col_varchar_key = 'j' +) AND alias1.pk IS NULL +GROUP BY +field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No matching min/max row +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_datetime_key` AS `field1` from `test`.`t1` join `test`.`t3` `alias2` where false group by `field1` +DROP TABLE t1,t2,t3; +DROP VIEW view1; +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE ALGORITHM=MERGE VIEW view1 AS +SELECT CONCAT( table1.col_varchar_nokey , table2.col_varchar_key ) AS +field1 +FROM +t2 AS table1 JOIN t1 AS table2 +ON table2.col_varchar_nokey = table1.col_varchar_key +AND +table2.col_varchar_key >= table1.col_varchar_nokey +ORDER BY field1 +; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM view1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE table2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`table1`.`col_varchar_nokey`,`test`.`table2`.`col_varchar_key`) AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` where ((`test`.`table2`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_key`) and (`test`.`table2`.`col_varchar_key` >= `test`.`table1`.`col_varchar_nokey`)) order by concat(`test`.`table1`.`col_varchar_nokey`,`test`.`table2`.`col_varchar_key`) +DROP TABLE t1,t2; +DROP VIEW view1; +CREATE TABLE t1 (col_varchar_nokey varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('v'),('c'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT (SELECT 150) AS field5 +FROM (SELECT * FROM t1) AS alias1 +GROUP BY field5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select 150 AS `field5` from `test`.`t1` group by `field5` +DROP TABLE t1; +# +# BUG#12626418 "only_full_group_by wrongly allows column in order by" +# +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +create table t1(a int, b int); +select a from t1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select 1 from t1 group by b; +1 +select 1 from t1 group by b order by a; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a from t1 group by b order by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table t1; +CREATE TABLE t1 (pk int, i1 int, v1 varchar(1), primary key (pk)); +INSERT INTO t1 VALUES (0,2,'b'),(1,4,'a'),(2,0,'a'),(3,7,'b'),(4,7,'c'); +SELECT a1.v1,a2.v1 FROM t1 AS a1 JOIN t1 AS a2 ON a2.pk = a1.i1 group by +a1.v1,a2.v1 ORDER BY a1.i1,a2.pk,a2.v1 ASC; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.a1.i1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a1.v1,a2.v1 FROM t1 AS a1 JOIN t1 AS a2 ON a2.pk = a1.i1 group by +a1.v1,a2.v1 ORDER BY a2.v1 ASC; +v1 v1 +b a +a b +a c +DROP TABLE t1; +CREATE TABLE t1 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_varchar_key varchar(1) NOT NULL, col_varchar_nokey varchar(1) NOT +NULL, PRIMARY KEY (pk), KEY col_int_key (col_int_key), KEY col_varchar_key +(col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_varchar_key varchar(1) NOT NULL, col_varchar_nokey varchar(1) NOT +NULL, PRIMARY KEY (pk), KEY col_int_key (col_int_key), KEY col_varchar_key +(col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT SUM(alias2.col_varchar_nokey) , alias2.pk AS field2 FROM t1 AS alias1 +STRAIGHT_JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key WHERE alias1.pk +group by field2 ORDER BY alias1.col_int_key,alias2.pk ; +SUM(alias2.col_varchar_nokey) field2 +DROP TABLE t1,t2; +CREATE TABLE t1 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_datetime_key datetime NOT NULL, col_varchar_key varchar(1) NOT +NULL, col_varchar_nokey varchar(1) NOT NULL, PRIMARY KEY (pk), KEY +col_int_key (col_int_key), KEY col_datetime_key (col_datetime_key), KEY +col_varchar_key (col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT +NULL, col_datetime_key datetime NOT NULL, col_varchar_key varchar(1) NOT +NULL, col_varchar_nokey varchar(1) NOT NULL, PRIMARY KEY (pk), KEY +col_int_key (col_int_key), KEY col_datetime_key (col_datetime_key), KEY +col_varchar_key (col_varchar_key,col_int_key)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT alias2.col_varchar_key AS field1 , +COUNT(DISTINCT alias1.col_varchar_nokey), alias2.pk AS field4 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 ON alias2.pk = alias1.col_int_key +GROUP BY field1 , field4 +ORDER BY alias1.col_datetime_key ; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.alias1.col_datetime_key' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1,t2; +create table t1 (a int, b int); +select count(*) > 3 from t1 group by a order by b; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +create table t2 (a int, b int); +select a from t2 group by a +order by (select a from t1 order by t2.b limit 1); +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SET @@sql_mode = @old_sql_mode; +DROP TABLE t1,t2; +create table t1 (branch varchar(40), id int); +select count(*) from t1 group by branch having +branch<>'mumbai' order by id desc,branch desc limit 100; +count(*) +select branch, count(*)/max(id) from t1 group by branch +having (branch<>'mumbai' OR count(*)<2) +order by id desc,branch desc limit 100; +branch count(*)/max(id) +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +select count(*) from t1 group by branch having +branch<>'mumbai' order by id desc,branch desc limit 100; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select branch, count(*)/max(id) from t1 group by branch +having (branch<>'mumbai' OR count(*)<2) +order by id desc,branch desc limit 100; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.t1.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +create table t1 (a int, b int); +insert into t1 values (1, 2), (1, 3), (null, null); +select sum(a), count(*) from t1 group by a; +sum(a) count(*) +2 2 +NULL 1 +select round(sum(a)), count(*) from t1 group by a; +round(sum(a)) count(*) +2 2 +NULL 1 +select ifnull(a, 'xyz') from t1 group by a; +ifnull(a, 'xyz') +1 +xyz +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; +# +# BUG#12640437: USING SQL_BUFFER_RESULT RESULTS IN A +# DIFFERENT QUERY OUTPUT +# +CREATE TABLE t1 ( +a int, +b varchar(1), +KEY (b,a) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,NULL),(0,'a'),(1,NULL),(0,'a'); +INSERT INTO t1 VALUES (1,'a'),(0,'a'),(1,'a'),(0,'a'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK + +EXPLAIN SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 12 NULL 2 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result min(`test`.`t1`.`a`) AS `MIN(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 'a') group by `test`.`t1`.`b` + +SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +MIN(a) b +0 a + +EXPLAIN SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 12 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a`) AS `MIN(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 'a') group by `test`.`t1`.`b` + +SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +MIN(a) b +0 a + +DROP TABLE t1; +# +# Bug #12888306 MISSING ROWS FOR SELECT >ALL (SUBQUERY WITHOUT ROWS) +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0); +SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a); +1 +1 +DROP TABLE t1; +# +# Bug#18035906: TEST_IF_SKIP_SORT_ORDER INCORRECTLY CHOSES NON-COVERING +# INDEX FOR ORDERING +# +CREATE TABLE t1 ( +i INT PRIMARY KEY AUTO_INCREMENT, +kp1 INT, +kp2 INT, +INDEX idx_noncov(kp1), +INDEX idx_cov(kp1,kp2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1, 1); +INSERT INTO t1 SELECT NULL, kp1, kp2+1 from t1; +INSERT INTO t1 SELECT NULL, kp1, kp2+2 from t1; +INSERT INTO t1 SELECT NULL, kp1, kp2+4 from t1; +INSERT INTO t1 SELECT NULL, kp1, kp2 from t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT kp1, SUM(kp2) FROM t1 GROUP BY kp1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx_noncov,idx_cov idx_cov 10 NULL 16 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`kp1` AS `kp1`,sum(`test`.`t1`.`kp2`) AS `SUM(kp2)` from `test`.`t1` group by `test`.`t1`.`kp1` +DROP TABLE t1; +# Bug#72512/18694751: Non-aggregated query with set function in +# ORDER BY should be rejected +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES (1), (2); +# Non-aggregated queries +SELECT a FROM t1 ORDER BY COUNT(*); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 WHERE a > 0 ORDER BY COUNT(*); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +# Implicitly grouped query +SELECT SUM(a) FROM t1 ORDER BY COUNT(*); +SUM(a) +3 +SELECT COUNT(*) FROM t1 ORDER BY COUNT(*); +COUNT(*) +2 +SELECT COUNT(*) AS c FROM t1 ORDER BY COUNT(*); +c +2 +SELECT COUNT(*) AS c FROM t1 ORDER BY c; +c +2 +# Explicitly grouped query +SELECT a, COUNT(*) FROM t1 GROUP BY a ORDER BY COUNT(*); +a COUNT(*) +1 1 +2 1 +SELECT a, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY COUNT(*); +a c +1 1 +2 1 +SELECT a, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY c; +a c +1 1 +2 1 +SELECT a AS c FROM t1 GROUP BY a ORDER BY COUNT(*); +c +1 +2 +# Query with HAVING, +SELECT 1 FROM t1 HAVING COUNT(*) > 1 ORDER BY COUNT(*); +1 +1 +# Subquery, ORDER BY contains outer reference +SELECT (SELECT 1 AS foo ORDER BY a) AS x +FROM t1; +x +1 +1 +SELECT (SELECT 1 AS foo ORDER BY t1.a) AS x +FROM t1; +x +1 +1 +# Subquery, ORDER BY contains set function with outer reference +SELECT (SELECT 1 AS foo ORDER BY COUNT(a)) AS x +FROM t1; +x +1 +SELECT (SELECT 1 AS foo ORDER BY COUNT(t1.a)) AS x +FROM t1; +x +1 +# Subquery, ORDER BY contains set function with local reference +SELECT (SELECT 1 AS foo ORDER BY COUNT(*)) AS x +FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +# Subquery in ORDER BY with outer reference +SELECT a FROM t1 ORDER BY (SELECT COUNT(t1.a) FROM t1 AS t2); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT SUM(a) FROM t1 ORDER BY (SELECT COUNT(t1.a) FROM t1 AS t2); +SUM(a) +3 +# Query with ORDER BY inside UNION +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION ALL +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION ALL +SELECT a FROM t1; +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT a FROM t1 +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*)) +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1) +UNION ALL +(SELECT a FROM t1 ORDER BY COUNT(*) LIMIT 1 OFFSET 1); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +(SELECT COUNT(*) FROM t1 ORDER BY a) ORDER BY COUNT(*); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +DROP TABLE t1; +# +# Bug#18487060: ASSERTION FAILED: !TABLE || (!TABLE->READ_SET || +# BITMAP_IS_SET(TABLE->READ_SET, +# +CREATE TABLE r(c BLOB) ENGINE=INNODB; +INSERT INTO r VALUES(''); +SELECT 1 FROM r GROUP BY MAKE_SET(1,c) WITH ROLLUP; +1 +1 +1 +DROP TABLE r; +# +# Bug #18921626 DEBUG CRASH IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG AT SQL_OPTIMIZER.CC +# +SET @old_sql_mode = @@sql_mode; +set sql_mode=''; +CREATE TABLE AA ( +col_varchar_1024_latin1 varchar(1024) CHARACTER SET latin1, +pk integer auto_increment, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8, +col_varchar_1024_latin1_key varchar(1024) CHARACTER SET latin1, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1, +col_int int, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8, +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8, +col_int_key int, +primary key (pk), +key (col_varchar_1024_utf8_key ), +key (col_varchar_1024_latin1_key ), +key (col_varchar_10_utf8_key ), +key (col_varchar_10_latin1_key ), +key (col_int_key )) ENGINE=innodb ROW_FORMAT=DYNAMIC; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE OR REPLACE VIEW view_AA AS SELECT * FROM AA; +CREATE TABLE B ( +col_varchar_1024_latin1_key varchar(1024) CHARACTER SET latin1, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +col_int_key int, +col_varchar_1024_latin1 varchar(1024) CHARACTER SET latin1, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8, +col_int int, +pk integer auto_increment, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1, +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8, +key (col_varchar_1024_latin1_key ), +key (col_varchar_10_utf8_key ), +key (col_int_key ), +key (col_varchar_1024_utf8_key ), +primary key (pk), +key (col_varchar_10_latin1_key )) ENGINE=myisam; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1071 Specified key was too long; max key length is 1000 bytes +Warning 1071 Specified key was too long; max key length is 1000 bytes +INSERT INTO B VALUES ('at', repeat('a',1000), 'the', +-1622540288, 'as', repeat('a',1000), 'want', 1810890752, NULL, 'v', 'just'); +Warnings: +Warning 1265 Data truncated for column 'col_varchar_10_latin1' at row 1 +SELECT +DISTINCT table1 . pk AS field1 +FROM view_AA AS table1 LEFT JOIN B AS table2 +ON table1 . col_varchar_10_latin1_key = table2 . +col_varchar_1024_latin1_key +WHERE ( ( table2 . pk > table1 . col_int_key AND table1 . pk NOT +BETWEEN 3 AND ( 3 + 3 ) ) AND table2 . pk <> 6 ) +GROUP BY table1 . pk; +field1 +DROP TABLE AA,B; +DROP VIEW view_AA; +SET @@sql_mode = @old_sql_mode; +SET sql_mode = default; +# +# Bug#20262196 ASSERTION FAILED: !IMPLICIT_GROUPING || TMP_TABLE_PARAM.SUM_FUNC_COUNT +# +CREATE TABLE t1(a INT, b INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (1,2), (3,4); +SELECT +EXISTS +( +SELECT 1 +FROM (SELECT a FROM t1) t_inner +GROUP BY t_inner.a +ORDER BY MIN(t_outer.b) +) +FROM t1 t_outer; +EXISTS +( +SELECT 1 +FROM (SELECT a FROM t1) t_inner +GROUP BY t_inner.a +ORDER BY MIN(t_outer.b) +) +1 +DROP TABLE t1; +# +# Bug#20210742 GROUP BY ON MERGE VIEW WITH ORDER BY DOES NOT WORK WITH ONLY_FULL_GROUP_BY +# +CREATE TABLE t1(cc CHAR(1), n CHAR(1), d CHAR(1)); +CREATE OR REPLACE ALGORITHM = MERGE VIEW v1 AS +SELECT * FROM t1 WHERE cc = 'AUS' ORDER BY n; +SELECT d, COUNT(*) FROM v1 GROUP BY d; +d COUNT(*) +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#20819199 ASSERTION FAILED IN TEST_IF_SKIP_SORT_ORDER +# +CREATE TABLE t0 ( a INT ); +INSERT INTO t0 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +a INT, +b INT, +PRIMARY KEY (pk), +KEY idx1 (a), +KEY idx2 (b, a), +KEY idx3 (a, b) +) ENGINE = InnoDB; +INSERT INTO t1 (a, b) SELECT t01.a, t02.a FROM t0 t01, t0 t02; +ANALYZE TABLE t0,t1; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT a, MAX(b) FROM t1 WHERE a >= 0 GROUP BY a,a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx1,idx2,idx3 idx1 5 NULL 100 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where (`test`.`t1`.`a` >= 0) group by `test`.`t1`.`a` +SELECT DISTINCT a, MAX(b) FROM t1 WHERE a >= 0 GROUP BY a,a; +a MAX(b) +1 10 +2 10 +3 10 +4 10 +5 10 +6 10 +7 10 +8 10 +9 10 +10 10 +DROP TABLE t0, t1; +# Bug#21753180: handle_fatal_signal (sig=11) in my_strtod_int +CREATE TABLE t1( +a INTEGER, +b BLOB(1), +c BLOB(1), +PRIMARY KEY(a,b(1)), +UNIQUE KEY (a,c(1)) +); +INSERT INTO t1 VALUES(1,2,1),(2,4,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT a, (SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL a 8 NULL 2 100.00 Using index +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,(/* select#2 */ select sum((`test`.`t1`.`a` + `test`.`t1`.`b`)) from `test`.`t1`) AS `(SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1)` from `test`.`t1` +SELECT a, (SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1) FROM t1; +a (SELECT SUM(a + c) FROM (SELECT b as c FROM t1) AS v1) +1 8 +2 10 +DROP TABLE t1; +# +# Bug#21761044 CONDITIONAL JUMP AT TEST_IF_ORDER_BY_KEY IN SQL_OPTIMIZER.CC +# +# Used to give ASAN error on the SELECT: addressing beyond allocated memory +# +CREATE TABLE cc (pk int, i int, c varchar(1), +PRIMARY KEY (pk, i), KEY c_key(c)) ENGINE=InnoDB; +SELECT c, i, pk FROM cc WHERE (cc.pk = 1) GROUP BY c, i, pk; +c i pk +DROP TABLE cc; +# +# Bug#22132822 CRASH IN GROUP_CHECK::IS_FD_ON_SOURCE +# +CREATE TABLE t1 +( +a INT GENERATED ALWAYS AS (1) VIRTUAL, +b INT GENERATED ALWAYS AS (a) VIRTUAL, +c INT GENERATED ALWAYS AS (1) VIRTUAL +); +DROP TABLE t1; +# +# Bug #22186926 CONVERT_CONSTANT_ITEM(THD*, ITEM_FIELD*, ITEM**): ASSERTION `!RESULT' FAILED. +# +CREATE TABLE t1 +( +f1 INTEGER NOT NULL, +f2 DATETIME NOT NULL, +f3 VARCHAR(1) NOT NULL, +KEY (f3) +); +INSERT INTO t1(f1, f2, f3) VALUES +(5, '2001-07-25 08:40:24.058646', 'j'), +(2, '1900-01-01 00:00:00', 's'), +(4, '2001-01-20 12:47:23.022022', 'x'); +CREATE TABLE t2 (f1 VARCHAR(1) NOT NULL); +FLUSH TABLES; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.f3 ) FROM t1 +WHERE t1.f3 IN (SELECT t2.f1 FROM t2 WHERE NOT t1.f2 IS NOT NULL) AND t1.f1 IS NULL OR +NOT t1 . f3 < 'q'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.f2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select min(`test`.`t1`.`f3`) AS `MIN(t1.f3 )` from `test`.`t1` where (`test`.`t1`.`f3` >= 'q') +DROP TABLE t1,t2; +# +# Bug#22275357 ORDER BY DOES NOT WORK CORRECTLY WITH GROUPED AVG() +# VALUES EXTRACTED FROM JSON +# +CREATE TABLE t(txt TEXT, i INT); +INSERT INTO t VALUES ('a', 2), ('b', 8), ('b', 0), ('c', 2); +SELECT txt, AVG(i) a FROM t GROUP BY txt ORDER BY a, txt; +txt a +a 2.0000 +c 2.0000 +b 4.0000 +SELECT txt, VAR_POP(i) v FROM t GROUP BY txt ORDER BY v, txt; +txt v +a 0 +c 0 +b 16 +SELECT txt, STDDEV_POP(i) s FROM t GROUP BY txt ORDER BY s, txt; +txt s +a 0 +c 0 +b 4 +SELECT SQL_BUFFER_RESULT txt, AVG(i) a FROM t GROUP BY txt ORDER BY a, txt; +txt a +a 2.0000 +c 2.0000 +b 4.0000 +SELECT SQL_BUFFER_RESULT txt, VAR_POP(i) v FROM t GROUP BY txt ORDER BY v, txt; +txt v +a 0 +c 0 +b 16 +SELECT SQL_BUFFER_RESULT txt, STDDEV_POP(i) s FROM t +GROUP BY txt ORDER BY s, txt; +txt s +a 0 +c 0 +b 4 +DROP TABLE t; +# +# Bug#26162009: INCORRECT RESULT WITH EXPRESSION IN HAVING CLAUSE +# +CREATE TABLE t1 (col_varchar VARCHAR(10), col_int_key INT); +INSERT INTO t1 VALUES('r',83); +SELECT col_varchar as field1, MAX(col_int_key) AS field3 FROM t1 +GROUP BY col_varchar HAVING (field1 >= 'i' OR field3 <= 9); +field1 field3 +r 83 +SELECT CONCAT(col_varchar) as field1, MAX(col_int_key) AS field3 +FROM t1 GROUP BY col_varchar HAVING (field1 >= 'i' OR field3 <= 9); +field1 field3 +r 83 +DROP TABLE t1; +# +# Bug#21974346: GROUPING ON AGGREGATED RESULTS NOT ALWAYS REJECTED +# +CREATE TABLE t (a INT); +INSERT INTO t VALUES (0), (1), (1), (2); +# These queries did not raise the expected error before the fix. +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT 1 HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT SUM(a) AS s FROM t GROUP BY (SELECT 1 HAVING s); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT SUM(a) + 1 AS s FROM t GROUP BY (SELECT 1 HAVING s); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT (SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 HAVING c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT (SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 HAVING c) LIMIT 1); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT (SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT 1 HAVING c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c1, (SELECT 1 HAVING c1) AS c2 +FROM t GROUP BY (SELECT 1 WHERE c2); +ERROR 42S22: Reference 'c2' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c1, (SELECT 1 HAVING c1) + 1 AS c2 +FROM t GROUP BY (SELECT 1 WHERE c2); +ERROR 42S22: Reference 'c2' not supported (reference to group function) +# These queries were accepted before the fix, and they still are. +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT 1 HAVING c); +c +4 +SELECT COUNT(*) AS c FROM t ORDER BY c; +c +4 +SELECT COUNT(*) AS c FROM t ORDER BY c+1; +c +4 +SELECT COUNT(*) AS c FROM t ORDER BY c+c; +c +4 +SELECT COUNT(*) AS c FROM t HAVING (SELECT 1 HAVING c); +c +4 +SELECT COUNT(*) AS c FROM t HAVING c; +c +4 +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT 1 HAVING c); +a c +0 1 +1 2 +2 1 +NULL 4 +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP HAVING c; +a c +0 1 +1 2 +2 1 +NULL 4 +SELECT (SELECT COUNT(*) AS c FROM t HAVING c <> 0); +(SELECT COUNT(*) AS c FROM t HAVING c <> 0) +4 +SELECT (SELECT COUNT(*) FROM t HAVING COUNT(*) <> 0); +(SELECT COUNT(*) FROM t HAVING COUNT(*) <> 0) +4 +SELECT (SELECT COUNT(*) AS c FROM t ORDER BY c); +(SELECT COUNT(*) AS c FROM t ORDER BY c) +4 +SELECT (SELECT COUNT(*) FROM t ORDER BY COUNT(*)); +(SELECT COUNT(*) FROM t ORDER BY COUNT(*)) +4 +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 +GROUP BY (SELECT 1 HAVING s > 0)) > 0; +1 +1 +SELECT (SELECT SUM(a)) FROM t; +(SELECT SUM(a)) +4 +SELECT SUM(a) AS s, (SELECT SUM(a)) FROM t; +s (SELECT SUM(a)) +4 4 +SELECT a, (SELECT SUM(a)) s FROM t GROUP BY a; +a s +0 0 +1 2 +2 2 +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 HAVING s > 5); +1 +SELECT (SELECT SUM(t1.a) s FROM t t2 WHERE t2.a = 0 HAVING s > 3) FROM t t1; +(SELECT SUM(t1.a) s FROM t t2 WHERE t2.a = 0 HAVING s > 3) +4 +SELECT 1 FROM t HAVING (SELECT SUM(a)) > 0; +1 +1 +SELECT (SELECT SUM(a)) FROM t; +(SELECT SUM(a)) +4 +# Bug #22588319: OUTER REFERENCE TO AGGREGATE INCORRECTLY 0 OR NULL IN SUBQUERY +SELECT SUM(a) AS s, (SELECT 1 HAVING s) FROM t; +s (SELECT 1 HAVING s) +4 1 +SELECT SUM(a) AS s, (SELECT 1 HAVING s IS NULL) FROM t; +s (SELECT 1 HAVING s IS NULL) +4 NULL +SELECT COUNT(a) AS c, (SELECT 1 HAVING c) FROM t; +c (SELECT 1 HAVING c) +4 1 +SELECT COUNT(a) AS c, (SELECT 1 HAVING c = 0) FROM t; +c (SELECT 1 HAVING c = 0) +4 NULL +# Shows that #22588319 isn't fixed for ORDER BY. +# Should have ordered ascending on -a, but comes out in random order +# because the ORDER BY clause always evaluates to NULL. Have to use +# the --sorted_result directive to produce stable test results. +SELECT a, COUNT(*) c FROM t GROUP BY a ORDER BY (SELECT -a HAVING c > 0); +a c +0 1 +1 2 +2 1 +# These queries were accepted in the default sql_mode before the fix, +# and rejected in the ANSI sql_mode. Expect no change after the fix. +SELECT * FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 HAVING s = 0); +a +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s); +1 +1 +1 +1 +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s + 1); +1 +1 +1 +1 +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s); +1 +1 +1 +1 +SELECT 1 FROM t WHERE (SELECT SUM(a)) > 0; +1 +1 +1 +1 +SELECT 1 FROM t GROUP BY (SELECT SUM(a)); +1 +1 +1 +1 +SET sql_mode = ANSI; +SELECT * FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 HAVING s = 0); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s FROM t t2 ORDER BY s + 1); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t t1 GROUP BY (SELECT SUM(t1.a) s); +ERROR HY000: Invalid use of group function +SELECT 1 FROM t WHERE (SELECT SUM(a)) > 0; +ERROR HY000: Invalid use of group function +SELECT 1 FROM t GROUP BY (SELECT SUM(a)); +ERROR HY000: Invalid use of group function +SET sql_mode = DEFAULT; +# These queries were rejected before the fix, and they still are. +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 WHERE c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT 1 WHERE c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT c HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) + 1 AS c FROM t GROUP BY (SELECT c HAVING c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t GROUP BY (SELECT c WHERE c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT c FROM (SELECT COUNT(*) AS c FROM t GROUP BY (SELECT 1 ORDER BY c)) tt; +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +GROUP BY (SELECT COUNT(*) FROM t HAVING (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +GROUP BY (SELECT COUNT(*) FROM t ORDER BY (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT (SELECT COUNT(*) AS c FROM t GROUP BY c); +ERROR 42000: Can't group on 'c' +SELECT (SELECT COUNT(*) FROM t GROUP BY COUNT(*)); +ERROR 42000: Can't group on 'COUNT(*)' +SELECT 1 FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 GROUP BY s); +ERROR 42000: Can't group on 's' +SELECT 1 FROM t t1 WHERE (SELECT SUM(t1.a) s FROM t t2 GROUP BY s+1); +ERROR 42000: Can't group on '???' +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 GROUP BY s) > 0; +ERROR 42000: Can't group on 's' +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 GROUP BY s+1) > 0; +ERROR 42000: Can't group on '???' +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 +GROUP BY (SELECT s)) > 0; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 ORDER BY (SELECT SUM(t1.a) s FROM t t2 +GROUP BY (SELECT s+1)) > 0; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t ORDER BY (SELECT SUM(a)); +ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 WHERE s > 5); +ERROR 42S22: Unknown column 's' in 'where clause' +SELECT a, (SELECT SUM(a)) s FROM t GROUP BY a, s; +ERROR 42000: Can't group on 's' +SELECT EXISTS (SELECT SUM(t1.a) s FROM t t2 GROUP BY s) FROM t t1; +ERROR 42000: Can't group on 's' +SELECT SUM(a) s, s FROM t; +ERROR 42S22: Unknown column 's' in 'field list' +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY s) > 0; +ERROR 42000: Can't group on 's' +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY s+1) > 0; +ERROR 42000: Can't group on '???' +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 +HAVING (SELECT 1 GROUP BY s+1)) > 0; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT 1 ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT c ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t HAVING (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t HAVING (SELECT 1 ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t HAVING (SELECT c ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT 1 ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT a, COUNT(*) AS c FROM t GROUP BY a WITH ROLLUP +HAVING (SELECT c ORDER BY c); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t ORDER BY (SELECT COUNT(*) FROM t HAVING (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT c FROM (SELECT COUNT(*) AS c FROM t ORDER BY (SELECT 1 ORDER BY c)) tt; +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +ORDER BY (SELECT COUNT(*) FROM t GROUP BY (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT COUNT(*) AS c FROM t +HAVING (SELECT COUNT(*) FROM t GROUP BY (SELECT c)); +ERROR 42S22: Reference 'c' not supported (reference to group function) +SELECT SUM(a) AS s, (SELECT s) FROM t; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT EXISTS (SELECT SUM(t1.a) s FROM t t2 GROUP BY (SELECT s)) FROM t t1; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT (SELECT SUM(t1.a) s FROM t t2 HAVING (SELECT s > 5)) FROM t t1; +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 HAVING (SELECT s) < 0); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY (SELECT s)); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 HAVING (SELECT -s) > 0); +ERROR 42S22: Reference 's' not supported (reference to group function) +SELECT 1 FROM t t1 HAVING (SELECT SUM(t1.a) s FROM t t2 GROUP BY (SELECT -s)); +ERROR 42S22: Reference 's' not supported (reference to group function) +DROP TABLE t; +# +# Bug#25407964 GROUP BY DESC GIVES WRONG RESULT WHEN GROUPS ON DECIMAL AND SEES A NULL +# +CREATE TABLE t(d DATE, i INT); +INSERT INTO t VALUES(NULL,1),('2017-01-14',3); +SELECT WEEK(d)/10, GROUP_CONCAT(i) FROM t GROUP BY WEEK(d)/10; +WEEK(d)/10 GROUP_CONCAT(i) +NULL 1 +0.2000 3 +SELECT WEEK(d)/10, GROUP_CONCAT(i) FROM t GROUP BY WEEK(d)/10 ORDER BY WEEK(d)/10 DESC; +WEEK(d)/10 GROUP_CONCAT(i) +0.2000 3 +NULL 1 +DROP TABLE t; +# +# Bug#21974696 WRONG RESULT WHEN GROUPING ON VALUE FROM SUBQUERY +# AND USING COUNT DISTINCT +# +CREATE TABLE t(a TEXT, b INT); +INSERT INTO t VALUES ('1', 10), ('1', 11), ('2', 20), ('2', 20), ('3', 30); +EXPLAIN FORMAT=tree SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +EXPLAIN +-> Group aggregate: count(distinct t.b) + -> Sort: `-(a)` + -> Stream results (cost=*** rows=***) + -> Table scan on t (cost=*** rows=***) + +Warnings: +Note 1276 Field or reference 'test.t.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +col1 COUNT(DISTINCT b) +1 2 +2 1 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT SQL_BIG_RESULT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1 WITH ROLLUP; +col1 COUNT(b) +1 2 +1 5 +2 2 +3 1 +DROP TABLE t; +CREATE TABLE t(a JSON, b INT); +INSERT INTO t VALUES ('1', 10), ('1', 11), ('2', 20), ('2', 20), ('3', 30); +EXPLAIN FORMAT=tree SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +EXPLAIN +-> Group aggregate: count(distinct t.b) + -> Sort: `-(a)` + -> Stream results (cost=*** rows=***) + -> Table scan on t (cost=*** rows=***) + +Warnings: +Note 1276 Field or reference 'test.t.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +SELECT (SELECT a) AS col1, COUNT(DISTINCT b) FROM t GROUP BY -col1; +col1 COUNT(DISTINCT b) +1 2 +2 1 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT SQL_BIG_RESULT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1; +col1 COUNT(b) +1 2 +2 2 +3 1 +SELECT (SELECT a) AS col1, COUNT(b) FROM t GROUP BY -col1 WITH ROLLUP; +col1 COUNT(b) +1 2 +1 5 +2 2 +3 1 +DROP TABLE t; +# +# WL#8963: REMOVAL OF NON STANDARD GROUP BY ASC/DESC +# +CREATE TABLE t1 (i INTEGER NOT NULL, j INTEGER NOT NULL, key(i,j)); +INSERT INTO t1 VALUES (1,2),(1,4),(1,3),(2,5),(5,3),(2,6),(6,2); +SELECT i, SUM(j) FROM t1 GROUP BY i ASC; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC' at line 1 +SELECT i, SUM(j) FROM t1 GROUP BY i DESC; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC' at line 1 +EXPLAIN SELECT i, SUM(j) FROM t1 GROUP BY i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index i i 8 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,sum(`test`.`t1`.`j`) AS `SUM(j)` from `test`.`t1` group by `test`.`t1`.`i` +SELECT i, SUM(j) FROM t1 GROUP BY i; +i SUM(j) +1 9 +2 11 +5 3 +6 2 +EXPLAIN SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index i i 8 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,sum(`test`.`t1`.`j`) AS `SUM(j)` from `test`.`t1` group by `test`.`t1`.`i` order by `test`.`t1`.`i` +SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY i; +i SUM(j) +1 9 +2 11 +5 3 +6 2 +EXPLAIN SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY SUM(j); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index i i 8 NULL # # Using index; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,sum(`test`.`t1`.`j`) AS `SUM(j)` from `test`.`t1` group by `test`.`t1`.`i` order by sum(`SUM(j)`) +SELECT i, SUM(j) FROM t1 GROUP BY i ORDER BY SUM(j); +i SUM(j) +6 2 +5 3 +1 9 +2 11 +ALTER TABLE t1 ADD UNIQUE INDEX (i,j); +EXPLAIN SELECT i FROM t1 GROUP BY j,i ORDER BY i,j; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i_2,i i_2 8 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` group by `test`.`t1`.`j`,`test`.`t1`.`i` order by `test`.`t1`.`i`,`test`.`t1`.`j` +SELECT i, SUM(j) FROM t1 GROUP BY j,i ORDER BY i,j; +i SUM(j) +1 2 +1 3 +1 4 +2 5 +2 6 +5 3 +6 2 +DROP TABLE t1; +# End of tests for WL#8693 +# +# Bug #29214970: WRONG RESULTS FOR GROUP EXPRESSIONS WITH THE ITERATOR EXECUTOR +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +KEY k1 ( f1 ) +); +INSERT INTO t1 VALUES ( 1, 1 ); +INSERT INTO t1 VALUES ( 1, 2 ); +INSERT INTO t1 VALUES ( 1, 3 ); +INSERT INTO t1 VALUES ( 2, 1 ); +INSERT INTO t1 VALUES ( 2, 2 ); +INSERT INTO t1 VALUES ( 3, 5 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT f1, f1 + 1, COUNT(DISTINCT f2) AS x FROM t1 GROUP BY f1 ORDER BY x; +EXPLAIN +-> Sort: x + -> Stream results + -> Group aggregate: count(distinct t1.f2) + -> Index scan on t1 using k1 (cost=0.85 rows=6) + +SELECT f1, f1 + 1, COUNT(DISTINCT f2) AS x FROM t1 GROUP BY f1 ORDER BY x; +f1 f1 + 1 x +3 4 1 +2 3 2 +1 2 3 +DROP TABLE t1; +# Bug#29240516: Count on nullable expression may return wrong result +CREATE TABLE t1 ( +vc varchar(255) DEFAULT NULL, +b tinyint DEFAULT NULL +); +INSERT INTO t1 (vc, b) VALUES (1, true), (2, false), (3, true), (4, false); +INSERT INTO t1 (vc) VALUES (5), (6), (7), (8), (9), (10); +SELECT COUNT(b), COUNT(*) +FROM t1; +COUNT(b) COUNT(*) +4 10 +SELECT COUNT(b) +FROM t1 +HAVING COUNT(1) > 0; +COUNT(b) +4 +DROP TABLE t1; +# Bug#28857990: Different result for COUNT with EXISTS subquery +CREATE TABLE d (pk INT PRIMARY KEY); +INSERT INTO d VALUES (1),(2),(3),(4),(5); +CREATE TABLE c (col_varchar VARCHAR(1)); +INSERT INTO c VALUES ('a'),('b'),('c'),('d'),('e'); +SELECT COUNT(pk) FROM d WHERE EXISTS (SELECT col_varchar FROM c); +COUNT(pk) +5 +DROP TABLE c, d; +# +# Bug #29396628: SIG 6 AT LIST::END | SQL_LIST.H +# +CREATE TABLE t1 ( +f1 integer, +f2 integer, +f3 integer +); +SELECT * FROM t1 GROUP BY f3,f2,f1 WITH ROLLUP; +f1 f2 f3 +DROP TABLE t1; +# Bug#23599127 Unexpected unknown column error without ONLY_FULL_GROUP_BY +SET SQL_MODE = ''; +CREATE TABLE t1 ( +id_aams int NOT NULL , +PRIMARY KEY (id_aams) +); +CREATE TABLE t2 ( +id int NOT NULL, +id_game int DEFAULT NULL, +code_id char(11) DEFAULT NULL, +PRIMARY KEY (id), +UNIQUE KEY codeid (code_id,id_game) +); +select count(distinct x.id_aams) +from (select * +from (select t1.id_aams, t2.* +from t1 left join t2 +on t2.code_id='G0000000012' and +t1.id_aams=t2.id_game +where t1.id_aams=1715000360 +order by t2.id desc +) as g +group by g.id_aams +having g.id is null +) as x; +count(distinct x.id_aams) +0 +CREATE FUNCTION f1(vlt_code_id CHAR(11)) RETURNS tinyint DETERMINISTIC +BEGIN +DECLARE not_installed TINYINT DEFAULT 0; +select count(distinct x.id_aams) +into not_installed +from (select * +from (select t1.id_aams, t2.* +from t1 left join t2 +on t2.code_id = vlt_code_id and +t1.id_aams = t2.id_game +where t1.id_aams = 1715000360 +order by t2.id desc +) as g +group by g.id_aams +having g.id is null +) as x; +RETURN TRUE; +END // +SELECT f1('G0000000012'); +f1('G0000000012') +1 +SELECT f1('G0000000012'); +f1('G0000000012') +1 +PREPARE stmt from " +select count(distinct x.id_aams) +from (select g.id_aams, g.id + from (select t1.id_aams, t2.* + from t1 left join t2 + on t2.code_id='G0000000012' and + t1.id_aams=t2.id_game + where t1.id_aams=1715000360 + order by t2.id desc + ) as g + group by g.id_aams + having g.id is null + ) as x"; +EXECUTE stmt; +count(distinct x.id_aams) +0 +EXECUTE stmt; +count(distinct x.id_aams) +0 +DEALLOCATE PREPARE stmt; +DROP FUNCTION f1; +DROP TABLE t1, t2; +SET SQL_MODE = DEFAULT; +# Bug#31562881: Crash in change_to_use_tmp_fields_except_sums +CREATE TABLE w(a INTEGER); +INSERT INTO w VALUES (1),(2),(3),(4); +SELECT MAX(FROM_UNIXTIME(1536999161)), +GROUP_CONCAT(ST_LATFROMGEOHASH(ST_GEOHASH(POINT(115,155),201))) +FROM w RIGHT JOIN w AS e ON TRUE +GROUP BY w.a +LIMIT 39; +ERROR 22003: latitude value is out of range in 'st_geohash' +DROP TABLE w; +# +# Bug #32179240: ADDING ROLLUP BREAKS GROUP LABELS +# +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 ( a ) VALUES ( 0.1 ); +SELECT TRUNCATE(a, 1) FROM t1 GROUP BY TRUNCATE(a, 1) WITH ROLLUP; +TRUNCATE(a, 1) +0.1 +NULL +DROP TABLE t1; +# +# Bug#32193123: DIFFERENT RESULTSET WITH HYPERGRAPH_OPTIMIZER SWITCH ENABLED +# +CREATE TABLE t1 (a INTEGER, b VARCHAR(1)); +INSERT INTO t1 VALUES (1, 'x'); +SELECT SUM(t1.a) AS field1, CONCAT(d1.b) AS field2 +FROM (SELECT * FROM t1) AS d1, t1 +GROUP BY field2 HAVING field2 > '' AND field1 < 4; +field1 field2 +1 x +DROP TABLE t1; +# +# Bug #32234709: TEMPTABLEAGGREGATEITERATOR::INIT(): ASSERTION `!THD()->IS_ERROR()' FAILED. +# +CREATE TABLE t1 ( +a INTEGER, +e INTEGER +); +INSERT INTO t1 VALUES (1,0); +INSERT INTO t1 VALUES (1,8388607); +SELECT COUNT(*) FROM +t1 +LEFT JOIN json_table( +'{}','$[0][1]' + COLUMNS(a FOR ORDINALITY) +) AS t2 ON TRUE +GROUP BY e*from_unixtime(0); +ERROR 22003: BIGINT value is out of range in '(`test`.`t1`.`e` * from_unixtime(0))' +DROP TABLE t1; +# +# Bug #32244407: ASSERTION FAILURE IN `!THD()->IS_ERROR()' AT AGGREGATEITERATOR::READ() +# +CREATE TABLE t1 ( +a INTEGER, +b VARCHAR(1) +); +CREATE INDEX i1 ON t1 (b); +INSERT INTO t1 VALUES (1,'0'); +INSERT INTO t1 VALUES (1,'y'); +INSERT INTO t1 VALUES (1,'Q'); +INSERT INTO t1 VALUES (1,'H'); +INSERT INTO t1 VALUES (1,'j'); +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (1,'b'); +INSERT INTO t1 VALUES (1,'j'); +INSERT INTO t1 VALUES (1,'q'); +INSERT INTO t1 VALUES (1,'e'); +SELECT AVG(a2.a) +FROM t1 AS a1 +LEFT JOIN t1 AS a2 ON a2.b = ( SELECT a1.b FROM t1 ); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #32335256: COUNT(*) RETURNS NULL IN NESTED QUERY +# +CREATE TABLE t1 ( +f1 INTEGER +); +SELECT +( +SELECT COUNT(*) + +( +SELECT COUNT(*) +FROM t1 +WHERE f1 = c.f2 +) +FROM t1 +) +FROM (SELECT 555 AS f2) AS c; +( +SELECT COUNT(*) + +( +SELECT COUNT(*) +FROM t1 +WHERE f1 = c.f2 +) +FROM t1 +) +0 +DROP TABLE t1; +# Bug#32717969: Wrong result of execute prepare on 'smallint' +CREATE TABLE t1( +c1 smallint NOT NULL +); +INSERT INTO t1 VALUES(32767),(14742),(14743); +SELECT COUNT(*), SUM(c1), AVG(c1), MIN(c1), MAX(c1) FROM t1 WHERE c1 > 32767; +COUNT(*) SUM(c1) AVG(c1) MIN(c1) MAX(c1) +0 NULL NULL NULL NULL +PREPARE stmt from +'SELECT COUNT(*), SUM(c1), AVG(c1), MIN(c1), MAX(c1) FROM t1 WHERE c1 > ?'; +SET @a=14742; +EXECUTE stmt USING @a; +COUNT(*) SUM(c1) AVG(c1) MIN(c1) MAX(c1) +2 47510 23755.0000 14743 32767 +set @a=32767; +EXECUTE stmt USING @a; +COUNT(*) SUM(c1) AVG(c1) MIN(c1) MAX(c1) +0 NULL NULL NULL NULL +SELECT BIT_AND(c1), BIT_OR(c1), BIT_XOR(c1) FROM t1 WHERE c1 > 32767; +BIT_AND(c1) BIT_OR(c1) BIT_XOR(c1) +18446744073709551615 0 0 +PREPARE stmt from +'SELECT BIT_AND(c1), BIT_OR(c1), BIT_XOR(c1) FROM t1 WHERE c1 > ?'; +SET @a=14742; +EXECUTE stmt USING @a; +BIT_AND(c1) BIT_OR(c1) BIT_XOR(c1) +14743 32767 18024 +set @a=32767; +EXECUTE stmt USING @a; +BIT_AND(c1) BIT_OR(c1) BIT_XOR(c1) +18446744073709551615 0 0 +SELECT GROUP_CONCAT(c1), JSON_ARRAYAGG(c1), JSON_OBJECTAGG('key', c1) +FROM t1 +WHERE c1 > 32767; +GROUP_CONCAT(c1) JSON_ARRAYAGG(c1) JSON_OBJECTAGG('key', c1) +NULL NULL NULL +PREPARE stmt from +"SELECT GROUP_CONCAT(c1), JSON_ARRAYAGG(c1), JSON_OBJECTAGG('key', c1) + FROM t1 + WHERE c1 > ?"; +SET @a=14742; +EXECUTE stmt USING @a; +GROUP_CONCAT(c1) JSON_ARRAYAGG(c1) JSON_OBJECTAGG('key', c1) +32767,14743 [32767, 14743] {"key": 14743} +set @a=32767; +EXECUTE stmt USING @a; +GROUP_CONCAT(c1) JSON_ARRAYAGG(c1) JSON_OBJECTAGG('key', c1) +NULL NULL NULL +SELECT STDDEV_POP(c1), STDDEV_SAMP(c1), VAR_POP(c1), VAR_SAMP(c1) +FROM t1 +WHERE c1 > 32767; +STDDEV_POP(c1) STDDEV_SAMP(c1) VAR_POP(c1) VAR_SAMP(c1) +NULL NULL NULL NULL +PREPARE stmt from +'SELECT STDDEV_POP(c1), STDDEV_SAMP(c1), VAR_POP(c1), VAR_SAMP(c1) + FROM t1 + WHERE c1 > ?'; +SET @a=14742; +EXECUTE stmt USING @a; +STDDEV_POP(c1) STDDEV_SAMP(c1) VAR_POP(c1) VAR_SAMP(c1) +9012 12744.892624106333 81216144 162432288 +set @a=32767; +EXECUTE stmt USING @a; +STDDEV_POP(c1) STDDEV_SAMP(c1) VAR_POP(c1) VAR_SAMP(c1) +NULL NULL NULL NULL +DROP TABLE t1; diff --git a/mysql-test/r/group_by_fd_no_prot.result-pq b/mysql-test/r/group_by_fd_no_prot.result-pq new file mode 100644 index 000000000..fd7fedea6 --- /dev/null +++ b/mysql-test/r/group_by_fd_no_prot.result-pq @@ -0,0 +1,2295 @@ +set optimizer_trace_max_mem_size=1048576; +set end_markers_in_json=on; +set optimizer_trace="enabled=on"; +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +# +# Bug#16021396 ONLY_FULL_GROUP_BY REJECTS VALID QUERY USING VIEW +# +create table t1(a int, b int, c int) engine=InnoDB; +create algorithm=merge view v1 as select t1.a*2 as a, t1.b*2 as b, t1.c*2 as c from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,(`t1`.`b` * 2) AS `b`,(`t1`.`c` * 2) AS `c` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(b) as z from t1 group by sin(b); +z +select sin(b) as z from v1 group by sin(b); +z +select sin(b) as z from t1 group by b; +z +select sin(b) as z from v1 group by b; +z +select sin(b) as z from v1 group by z; +z +drop view v1; +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b*2 as b, t1.c*2 as c from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,(`t1`.`b` * 2) AS `b`,(`t1`.`c` * 2) AS `c` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(b) as z from t1 group by sin(b); +z +select sin(b) as z from v1 group by sin(b); +z +select sin(b) as z from t1 group by b; +z +select sin(b) as z from v1 group by b; +z +select sin(b) as z from v1 group by z; +z +drop view v1; +drop table t1; +# From testcase of Bug#16903135: +CREATE TABLE group_by_test2 ( +id int unsigned primary key, +cat int unsigned not null, +name varchar(10), +num int unsigned +); +INSERT INTO group_by_test2 (id,cat,name,num) VALUES +(1,10,'foo',2), +(2,11,'foo',1), +(3,22,'bar',3), +(4,23,'bar',7), +(5,34,'test',7); +SELECT +cat, +name, +SUM(num) +FROM +group_by_test2 +GROUP BY +cat; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.group_by_test2.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +ALTER TABLE group_by_test2 ADD UNIQUE INDEX (cat); +SELECT +cat, +name, +SUM(num) +FROM +group_by_test2 +GROUP BY +cat; +cat name SUM(num) +10 foo 2 +11 foo 1 +22 bar 3 +23 bar 7 +34 test 7 +SELECT +cat, +name, +SUM(num) +FROM +group_by_test2 +GROUP BY +cat WITH ROLLUP; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.group_by_test2.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Expressions of group columns are ok: +SELECT +cat, +length(cat), +SUM(num) +FROM +group_by_test2 +GROUP BY +cat +WITH ROLLUP; +cat length(cat) SUM(num) +10 2 2 +11 2 1 +22 2 3 +23 2 7 +34 2 7 +NULL NULL 20 +DROP TABLE group_by_test2; +# Test from Bug #18993257 SELECT AGGR + NON-AGGR FROM JOIN WITH VIEW IS NOT REJECTED BY ONLY_FULL_GROUP_BY +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1) +); +CREATE TABLE t2 ( +pk INTEGER, +col_int_key INTEGER +); +CREATE VIEW view_b AS SELECT * FROM t2; +SELECT MIN( alias2.col_int_key ), +alias2.col_int_key +FROM t1 AS alias1, t2 AS alias2 +WHERE alias1.col_int_key IS NULL; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.alias2.col_int_key'; this is incompatible with sql_mode=only_full_group_by +# Same with view: +SELECT MIN( alias2.col_int_key ), +alias2.col_int_key +FROM t1 AS alias1, view_b AS alias2 +WHERE alias1.col_int_key IS NULL; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.alias2.col_int_key'; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1, t2; +DROP VIEW view_b; +# +# WL#2489; Recognizing some functional dependencies +# +create table t1( +a int, +b int not null, +c int not null, +d int, +unique key(b,c), +unique key(b,d) +); +select sin(a) as z from t1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from t1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# {b,c} UNIQUE NOT NULL => {c,b}->a +select sin(a) as z from t1 group by c,b; +z +select sin(a+b*c) as z from t1 group by c,b; +z +# In PS mode, we see nothing below, because only_full_group_by +# checks are done at PREPARE, whereas trace below is from EXECUTE. +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } +# With outer references: +select (select sin(a)) as z from t1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from t1 group by c,b; +z +# If key columns are in function, functional dependency disappears +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# FDs are recognized, like in SQL standard: +# b=2 => c->{b,c} => c->a as (b,c) is unique not null. +select sin(a) as z from t1 where b=2 group by c; +z +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } +# t2.a=t1.a => {t1.b,t1.c}->t2.a +select sin(t2.a) as z from t1, t1 as t2 +where t2.a=t1.a group by t1.b,t1.c; +z +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c", + "test.t2.a" + ] /* columns */ + } +# t2.b=t1.b and t2.c=t1.c => {t1.b,t1.c}->{all cols of t2} +select sin(t2.a) as z from t1, t1 as t2 +where t2.b=t1.b and t2.c=t1.c group by t1.b,t1.c; +z +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c", + "test.t2.b", + "test.t2.c" + ] /* columns */ + } +# t2.b=t1.b and t2.c=t1.c => {t1.b,t1.c}->{all cols of t2} +# Moreover, {t1.b,t1.c}->{t1.d}. +# So t3.b=t2.b and t3.c=t1.d => {t1.b,t1.c}->{all cols of t3}. +select t3.a from t1, t1 as t2, t1 as t3 +where +t3.b=t2.b and t3.c=t1.d and +t2.b=t1.b and t2.c=t1.c +group by t1.b,t1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1, + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c", + "test.t3.c", + "test.t2.b", + "test.t2.c", + "test.t3.b" + ] /* columns */ + } +# 3 tables: +# {t1.b,t1.c}->{t1.*}->{t2.b,t2.c}->{t2.*}->{t3.pk}->{t3.b} +create table t3(pk int primary key, b int); +select t3.b from t1,t1 as t2,t3 +where t3.pk=t2.d and t2.b=t1.b and t2.c=t1.a +group by t1.b,t1.c; +b +drop table t3; +# With subq +select (select t1.b from t1 +where t2.b=t1.b +group by t1.a) from t1 as t2; +(select t1.b from t1 +where t2.b=t1.b +group by t1.a) +# Outer join. +create table t2 like t1; +delete from t1; +insert into t1 (a,b) values(1,10),(2,20); +Warnings: +Warning 1364 Field 'c' doesn't have a default value +insert into t2 (a,b) values(1,-10); +Warnings: +Warning 1364 Field 'c' doesn't have a default value +# In result, t2.a is NULL for both rows, values of t1.a are 1 and 2 +select t1.a,t2.a from t1 left join t2 on t2.a=t1.a and t2.b=t1.b; +a a +1 NULL +2 NULL +# So this query would choose one arbitrary value of t1.a - wrong: +select t1.a from t1 left join t2 on t2.a=t1.a and t2.b=t1.b group by t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Also problem for FD with constant: +select t1.a,t2.a from t1 left join t2 on 42=t1.a and t2.b=t1.b; +a a +1 NULL +2 NULL +select t1.a from t1 left join t2 on 42=t1.a and t2.b=t1.b group by t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a from t1 left join t2 on t2.b=t1.a group by t2.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a from t1 left join t2 on 42=t1.a group by t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.c from t1 left join t2 on t1.a=t1.c group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.b from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+t2.b)>0.5 and sin(t1.a+t2.d)<0.9 group by t1.a; +a c +1 NULL +2 NULL +# with keys: +select t1.a,t2.d from t1 left join t2 on t1.a=t2.c and t1.d=t2.b +and cos(t2.c+t2.b)>0.5 and sin(t1.a+t2.d)<0.9 group by t1.a,t1.d; +a d +1 NULL +2 NULL +# with non-determinism: +select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+rand())>0.5 group by t1.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t1.a, ANY_VALUE(t2.c) from t1 left join t2 on t1.a=t2.c +and cos(t2.c+rand())>0.5 group by t1.a; +a ANY_VALUE(t2.c) +1 NULL +2 NULL +# with parameter: +prepare s from 'select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+ ? )>0.5 group by t1.a'; +execute s using @dummy; +a c +1 NULL +2 NULL +# No OR +select t1.a,t2.c from t1 left join t2 on t1.a=t2.c +and cos(t2.c+t2.b)>0.5 OR sin(t2.d)<0.9 group by t1.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# With subq +select t2.b from t1 left join t1 as t2 on t1.a=t2.b and t1.b group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t2.b from t1 left join t1 as t2 on t1.a=t2.b and (select t1.b) group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Test ANY_VALUE: +select ANY_VALUE(t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +ANY_VALUE(t1.b) +10 +20 +select 3+(5*t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select 3+(5*ANY_VALUE(t1.b)) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a; +3+(5*ANY_VALUE(t1.b)) +53 +103 +delete from t1; +insert into t1 (a,b) values(1,10),(1,20),(2,30),(2,40); +Warnings: +Warning 1364 Field 'c' doesn't have a default value +select a, sum(b) from t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.a'; this is incompatible with sql_mode=only_full_group_by +select any_value(a), sum(b) from t1; +any_value(a) sum(b) +1 100 +# different order of input rows, different "any_value": +select any_value(a), sum(b) from (select * from t1 order by a desc) as d; +any_value(a) sum(b) +1 100 +select a,b,sum(c) from t1 group by a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a,any_value(b),sum(c) from t1 group by a; +a any_value(b) sum(c) +1 10 0 +2 30 0 +select a,any_value(b),sum(c) +from (select * from t1 order by a desc, b desc) as d +group by a; +a any_value(b) sum(c) +1 10 0 +2 30 0 +# With view. +set @optimizer_switch_saved=@@optimizer_switch; +# Merged view +create algorithm=merge view v1 as select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c`,`t1`.`d` AS `d`,`t1`.`a` AS `e` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(a) as z from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select (select sin(a)) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a+b*c) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.c", + "test.v1.b" + ] /* columns */ + } +select sin(a) as z from v1 where b=2 group by c; +z +# {v1.b,v1.c}->v1.a->t2.a +select sin(t2.a) as z from v1, v1 as t2 +where t2.a=v1.a group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b", + "test.v1.c", + "test.t2.a" + ] /* columns */ + } +select sin(t2.a) as z from v1, v1 as t2 +where t2.b=v1.b and t2.c=v1.c group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +# With materialized view we get more dependencies than needed, due to implementation. +select t3.a from v1, v1 as t2, v1 as t3 +where +t3.b=t2.b and t3.c=v1.d and +t2.b=v1.b and t2.c=v1.c +group by v1.b,v1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1, + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b", + "test.v1.c", + "test.t3.c", + "test.t2.b", + "test.t2.c", + "test.t3.b" + ] /* columns */ + } +# If we simply went to real_item(), we would have WHERE 2*a=b, or +# GROUP BY 2*t1.a, so we would not find FDs. The original item +# (direct_view_ref here) must also be considered! +select a from v1 where a=b group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */ + } +select b from v1 where a=b group by a; +b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.b" + ] /* columns */ + } +select v1.c from v1 where v1.c=v1.a group by v1.a; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.c" + ] /* columns */ + } +select v1.a from v1 group by v1.e; +a +2 +4 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a" + ] /* columns */ + } +select v1.c from v1 where v1.c=v1.a group by v1.e; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a", + "test.v1.c" + ] /* columns */ + } +# View appears only in WHERE +select t2.d from v1, t1 as t2 where v1.a=t2.d and v1.e=t2.a group by t2.a; +d +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.t2.a", + "test.v1.e", + "test.v1.a", + "test.t2.d" + ] /* columns */ + } +drop view if exists v1; +# FD due to view's WHERE: +create algorithm=merge view v1 as select t1.a*2 as a, t1.b as b from t1; +select a from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view if exists v1; +# Merged view +create algorithm=merge view v1 as select t1.a*2 as a, t1.b as b from t1 where t1.a=t1.b; +select a from v1 group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.t1.a", + "test.v1.a" + ] /* columns */ + } +drop view if exists v1; +# Aggregates in view +# Aggregates => skipping Merged view +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Aggregates + GROUP BY in view +# We group by b*5, to show that it works with GROUP expressions, not only fields. +# Aggregates => skipping Merged view +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +set optimizer_switch=@optimizer_switch_saved; +set @optimizer_switch_saved=@@optimizer_switch; +# Materialized view +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` * 2) AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c`,`t1`.`d` AS `d`,`t1`.`a` AS `e` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select sin(a) as z from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select (select sin(a)) as z from v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a+b*c) as z from v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.c", + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select sin(a) as z from v1 where b=2 group by c; +z +# {v1.b,v1.c}->v1.a->t2.a +select sin(t2.a) as z from v1, v1 as t2 +where t2.a=v1.a group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.c", + "test.v1.a", + "test.t2.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": "`v1` `t2`" + } + ] /* searched_in_materialized_tables */ + } +select sin(t2.a) as z from v1, v1 as t2 +where t2.b=v1.b and t2.c=v1.c group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +# With materialized view we get more dependencies than needed, due to implementation. +select t3.a from v1, v1 as t2, v1 as t3 +where +t3.b=t2.b and t3.c=v1.d and +t2.b=v1.b and t2.c=v1.c +group by v1.b,v1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.c", + "test.t2.b", + "test.t2.c", + "test.t3.b", + "test.v1.d", + "test.t3.c", + "test.t3.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": "`v1` `t2`", + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": "`v1` `t3`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# If we simply went to real_item(), we would have WHERE 2*a=b, or +# GROUP BY 2*t1.a, so we would not find FDs. The original item +# (direct_view_ref here) must also be considered! +select a from v1 where a=b group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select b from v1 where a=b group by a; +b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from v1 where v1.c=v1.a group by v1.a; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.a from v1 group by v1.e; +a +2 +4 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from v1 where v1.c=v1.a group by v1.e; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.e", + "test.v1.a", + "test.v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# View appears only in WHERE +select t2.d from v1, t1 as t2 where v1.a=t2.d and v1.e=t2.a group by t2.a; +d +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.t2.a", + "test.v1.e", + "test.v1.a", + "test.t2.d" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +# FD due to view's WHERE: +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b as b from t1; +select a from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view if exists v1; +# Materialized view +create algorithm=temptable view v1 as select t1.a*2 as a, t1.b as b from t1 where t1.a=t1.b; +select a from v1 group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.b", + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +# Aggregates in view +# Materialized view +create algorithm=temptable view v1 as select sum(t1.a) as a, sum(t1.b) as b from t1; +select a from v1 group by b; +a +6 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`" + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +# Aggregates + GROUP BY in view +# We group by b*5, to show that it works with GROUP expressions, not only fields. +# Materialized view +create algorithm=temptable view v1 as select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5; +select a from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from v1 group by b,d; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a,c from v1 group by a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select d,c from v1 group by b,a; +d c +NULL 0 +NULL 0 +NULL 0 +NULL 0 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.v1.b", + "test.v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v1`", + "columns": [ + "test.t1.a" + ] /* columns */, + "all_group_expressions": true + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +set optimizer_switch=@optimizer_switch_saved; +set @optimizer_switch_saved=@@optimizer_switch; +# Materialized derived table +set optimizer_switch='derived_merge=off'; +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select (select sin(a)) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by d,b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select (select sin(a)) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +select sin(a) as z from t1 group by c*2,b*2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select sin(a+b*c) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by c,b; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.c", + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.c", + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select sin(a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where b=2 group by c; +z +# {v1.b,v1.c}->v1.a->t2.a +select sin(t2.a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t2 +where t2.a=v1.a group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.c", + "v1.a", + "t2.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": " `t2`" + } + ] /* searched_in_materialized_tables */ + } +select sin(t2.a) as z from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t2 +where t2.b=v1.b and t2.c=v1.c group by v1.b,v1.c; +z +0.9092974268256817 +0.9092974268256817 +-0.7568024953079282 +-0.7568024953079282 +# With materialized view we get more dependencies than needed, due to implementation. +select t3.a from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t2, (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as t3 +where +t3.b=t2.b and t3.c=v1.d and +t2.b=v1.b and t2.c=v1.c +group by v1.b,v1.c; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.c", + "t2.b", + "t2.c", + "t3.b", + "v1.d", + "t3.c", + "t3.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": " `t2`", + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + }, + { + "table": " `t3`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# If we simply went to real_item(), we would have WHERE 2*a=b, or +# GROUP BY 2*t1.a, so we would not find FDs. The original item +# (direct_view_ref here) must also be considered! +select a from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where a=b group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select b from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where a=b group by a; +b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.a", + "v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where v1.c=v1.a group by v1.a; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.a", + "v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.a from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 group by v1.e; +a +2 +4 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.e", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select v1.c from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1 where v1.c=v1.a group by v1.e; +c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.e", + "v1.a", + "v1.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a", + "test.t1.c" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# View appears only in WHERE +select t2.d from (select t1.a*2 as a, t1.b as b, t1.c as c, t1.d as d, t1.a as e from t1) as v1, t1 as t2 where v1.a=t2.d and v1.e=t2.a group by t2.a; +d +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.t2.a", + "v1.e", + "v1.a", + "test.t2.d" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# FD due to view's WHERE: +select a from (select t1.a*2 as a, t1.b as b from t1) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Derived table +select a from (select t1.a*2 as a, t1.b as b from t1 where t1.a=t1.b) as v1 group by b; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.b", + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Aggregates in view +# Derived table +select a from (select sum(t1.a) as a, sum(t1.b) as b from t1) as v1 group by b; +a +6 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`" + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +# Aggregates + GROUP BY in view +# We group by b*5, to show that it works with GROUP expressions, not only fields. +# Derived table +select a from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b,d; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select a,c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select d,c from (select a, b*5 as b, sum(t1.c) as c, sum(t1.d) as d from t1 group by a,b*5) as v1 group by b,a; +d c +NULL 0 +NULL 0 +NULL 0 +NULL 0 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "v1.b", + "v1.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `v1`", + "columns": [ + "test.t1.a" + ] /* columns */, + "all_group_expressions": true + } + ] /* searched_in_materialized_tables */ + } +drop view if exists v1; +Warnings: +Note 1051 Unknown table 'test.v1' +set optimizer_switch=@optimizer_switch_saved; +# Derived table in merged view +create algorithm=temptable view v2 +as select a as a, 2*a as b from t1; +create algorithm=merge view v1 +as select v2.a as a, 3*v2.b as b from v2; +select v1.b from v1 group by v1.a; +b +6 +12 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v2.b", + "test.v1.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v2`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +select t2.a from t1 as t2, v1 where t2.a=v1.b group by v1.a; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.v1.a", + "test.v2.b", + "test.v1.b", + "test.t2.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`v2`", + "columns": [ + "test.t1.a" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# FDs in a view are those of the underlying query expression. +# FDs in a query expression: expressions in the SELECT list must be +# deterministic. +drop view v1; +create algorithm=merge view v1 +as select v2.a as a, rand()*v2.b as b from v2; +select v1.b from v1 group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1; +create algorithm=temptable view v1 +as select v2.a as a, rand()*v2.b as b from v2; +select v1.b from v1 group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1,v2; +# Item_direct_view_ref pointing to Item_direct_view_ref pointing to +# Item_field (a rare case!) +create algorithm=merge view v2 as select 2*a as a, 2*b as b from t1; +create algorithm=merge view v1 as select a, 3*b as b from v2 where a=b; +select 1 from (select a,b+0 from v1 group by a) as d; +1 +drop view v1,v2; +# Some fun cases with aggregates in derived table. +# Inner query is valid: t1.a -> t1.b (equality in WHERE). Outer query: +# d.b -> t1.b (underlying column of d.b) -> t1.a (equality) +# -> sum(1) (because t1.a is all group columns so determines +# sum()) -> d.s (because sum() is underlying of d.s) +select d.s from +(select b, sum(1) as s from t1 where a=b group by a) as d +group by d.b; +s +alter table t1 add column pk int primary key auto_increment; +# Inner query: t1.pk -> t1.* (pk). Outer query: +# d.b,d.c -> t1.b,t1.c (their underlying columns) -> t1.pk (because +# t1.b,t1.c is unique) -> sum(1) (because t1.pk is all group columns so +# determines sum()) -> d.s (because sum() is underlying of d.s) +select d.s from +(select b, c, sum(d) as s from t1 group by pk) as d +group by d.b,d.c; +s +NULL +NULL +NULL +NULL +# Outer query: +# d.c -> t1.b*3 (underlying column of d.c) -> sum(a) (because t1.b*3 +# is all group expressions) -> d.s +select d.s from +(select b*3 as c, sum(a) as s from t1 group by b*3) as d +group by d.c; +s +1 +1 +2 +2 +drop table t1,t2; +# Testcase from Reviewers +create table customer1(pk int primary key, a int); +create table customer2(pk int primary key, b int); +CREATE algorithm=merge VIEW customer as SELECT pk,a,b +FROM customer1 JOIN customer2 USING (pk); +select customer.pk, customer.b +from customer +group by customer.pk; +pk b +# View is merged. Show FDs. Note that in --ps-protocol, the trace +# is that of execution, so contains no group-by checks. +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.customer.pk", + "test.customer2.pk" + ] /* columns */ + } +drop view customer; +CREATE algorithm=temptable VIEW customer as SELECT pk,a,b +FROM customer1 JOIN customer2 USING (pk); +select customer.pk, customer.b +from customer +group by customer.pk; +pk b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "test.customer.pk", + "test.customer.b" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": "`customer`", + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.customer1.pk", + "test.customer2.pk" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +# Benefit from outer-join-to-inner conversion. +insert into customer1 values(0,10),(1,20); +insert into customer2 values(0,10),(1,20); +# 1) no conversion, no FD from customer2.b to customer1.a. +explain select customer1.a, count(*) +from customer1 left join customer2 on customer1.a=customer2.b +where customer1.pk in (7,9) +group by customer2.b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.customer1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# 2) null-complemented row can't pass WHERE => conversion +# => FD from customer2.b to customer1.a. +explain select customer1.a, count(*) +from customer1 left join customer2 on customer1.a=customer2.b +where customer2.pk in (7,9) +group by customer2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE customer1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE customer2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`customer1`.`a` AS `a`,count(0) AS `count(*)` from `test`.`customer1` join `test`.`customer2` where ((`test`.`customer2`.`b` = `test`.`customer1`.`a`) and (`test`.`customer2`.`pk` in (7,9))) group by `test`.`customer2`.`b` +drop table customer1,customer2; +drop view customer; +# FDs of JOIN...USING and NATURAL JOIN +create table t1(pk int primary key, a int); +create table t2(pk int primary key, b int); +select t1.pk, t1.a from t1 join t2 on t1.pk=t2.pk group by t1.pk; +pk a +select t1.pk, t1.a from t1 join t2 using(pk) group by t1.pk; +pk a +select t1.pk, t1.a from t1 natural join t2 group by t1.pk; +pk a +select t1.pk, t1.a from t1 left join t2 using(pk) group by t1.pk; +pk a +select t1.pk, t1.a from t1 natural left join t2 group by t1.pk; +pk a +select t1.pk, t2.b from t1 join t2 on t1.pk=t2.pk group by t1.pk; +pk b +select t1.pk, t2.b from t1 join t2 using(pk) group by t1.pk; +pk b +select t1.pk, t2.b from t1 natural join t2 group by t1.pk; +pk b +select t1.pk, t2.b from t1 left join t2 using(pk) group by t1.pk; +pk b +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0, + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.pk", + "test.t2.pk" + ] /* columns */ + } +select t1.pk, t2.b from t1 natural left join t2 group by t1.pk; +pk b +# Equivalent queries, with RIGHT JOIN +select t1.pk, t2.b from t2 right join t1 using(pk) group by t1.pk; +pk b +select t1.pk, t2.b from t2 natural right join t1 group by t1.pk; +pk b +select t1.pk, t2.b from t1 left join t2 on t1.pk>t2.pk group by t1.pk; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Even in --ps-protocol we see the group-by checks in trace because +# there has been no execution (due to error). +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.pk" + ] /* columns */ + } +select t1.pk, t2.b from t2 right join t1 on t1.pk>t2.pk group by t1.pk; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t2.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table t1,t2; +# Cases where FDs from weak side do not propagate +create table t1(a int, b int); +insert into t1 values(null,0),(null,1); +select d.a,d.c +from t1 left join (select a, coalesce(a,3) as c from t1) as d +on t1.b>0; +a c +NULL 3 +NULL 3 +NULL NULL +# Now group it by d.a: +select d.a,d.c +from t1 left join (select a, coalesce(a,3) as c from t1) as d +on t1.b>0 group by d.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'd.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "d.a" + ] /* columns */ + } +select d.a,d.c +from t1 left join (select a, count(a) as c from t1 group by a) as d +on t1.b+d.c>0; +a c +NULL 0 +NULL NULL +# Now group it by d.a: +select d.a,d.c +from t1 left join (select a, count(a) as c from t1 group by a) as d +on t1.b+d.c>0 group by d.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'd.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "d.a" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `d`", + "columns": [ + "test.t1.a" + ] /* columns */, + "all_group_expressions": true + } + ] /* searched_in_materialized_tables */ + } +select d.m,d.c +from t1 left join (select max(a) as m, count(a) as c from t1) as d +on t1.b+d.c>0; +m c +NULL 0 +NULL NULL +# Now group it by d.m: +select d.m,d.c +from t1 left join (select max(a) as m, count(a) as c from t1) as d +on t1.b+d.c>0 group by d.m; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'd.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "d.m" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `d`" + } + ] /* searched_in_materialized_tables */ + } +# Now group it by d.c which is non-nullable: +select d.m,d.c +from t1 left join (select max(a) as m, count(a) as c from t1) as d +on t1.b+d.c>0 group by d.c; +m c +NULL 0 +NULL NULL +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 1 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "d.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `d`" + } + ] /* searched_in_materialized_tables */ + } +drop table t1; +create table t1(pk int primary key, a int); +# Not valid per the standard, because: +# 1) In t3, t3.pk->t3.a holds. +# 2) In R1 the result of "(t2 left join t3 on 1)", t3.pk->t3.a +# holds, by application of: there is a functional dependency in the +# weak side t3, and t3.pk is not nullable in t3. +# 3) In R2 the result of "t1 left join (t2 left join t3 on 1) on 1", +# t3.pk->t3.a doesn't hold anymore, because: it's a dependency in the +# weak side (weak side is R1), and t3.pk is nullable _when +# seen as a column of R1_ (in R1 t3.pk can be NULL, if the row of t3 +# is actually a null-complemented one). +# But for us it is valid, because we have refined the logic: the +# pk-based FD satisfies the requirement that a NULL value of t3.pk +# implies a NULL value of t3.a (indeed, the NULL value of t3.pk can +# only come from null-complementing of the row of t3 in R1, in which +# case t3.a is also NULL). +select t3.a +from t1 left join (t1 as t2 left join t1 as t3 on 1) on 1 +group by t3.pk; +a +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t3.pk" + ] /* columns */ + } +# Outer reference - why we use resolved_used_tables(): +select (select t1.a from t1 as t2 limit 1) from t1 group by pk; +(select t1.a from t1 as t2 limit 1) +# We don't build the FD list if not needed +select t1.a*3 from t1 group by t1.a; +t1.a*3 +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +NOT FOUND +drop table t1; +# Tricky cases with "ON col=literal" propagating. +create table t1(a int, b int); +insert into t1 values(); +insert into t1 values(10,11); +create table t2(c int, d int); +insert into t2 values(2,3); +select t4.d +from t1 left join (t2 as t3 join t2 as t4 on t4.d=3) on t1.a=10; +d +3 +NULL +# Equivalent to T1 LJ (T2, T3) ON T4.D=3 AND T1.A=10 +# (this is what simplify_joins() does). +# For T4.D=3, DJS is {T1.A} which is not group column. +select t4.d +from t1 left join (t2 as t3 join t2 as t4 on t4.d=3) on t1.a=10 group by ""; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t4.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t4.d +from t1 left join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10; +d +3 +NULL +# For T4.D=3, DJS={}, not NULL-friendly, and embedding is on weak side +# so FD cannot propagate. +select t4.d +from t1 left join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10 group by ""; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t4.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +select t4.d +from t1 join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10; +d +3 +# For T4.D=3, DJS={}, not NULL-friendly, but embedding is on weak side +# so FD can propagate. +select t4.d +from t1 join (t2 as t3 left join t2 as t4 on t4.d=3) on t1.a=10 group by ""; +d +3 +# With a view +create view v1 as select a as a, 2*a as b, coalesce(a,3) as c from t1; +select v1.b from t1 left join v1 on 1; +b +20 +20 +NULL +NULL +# If v1.a is NULL then v1.b is NULL: a->b is NULL-friendly +select v1.b from t1 left join v1 on 1 group by v1.a; +b +20 +NULL +select v1.c from t1 left join v1 on 1; +c +10 +10 +3 +3 +# If v1.a is NULL then v1.c may not be NULL: a->c is not NULL-friendly +select v1.c from t1 left join v1 on 1 group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.v1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1; +# Constant view item +create view v1 as select a as a, 2 as b from t1; +# Because of BUG#17023060, the result is wrong, should be +# [10,2 ; 10,2 ; NULL,NULL], which would show that {}->{v1.b} does not +# hold in the result, even though v1.b is constant (=2) in v1. +select t1.a, v1.b from t1 left join v1 on t1.a is not null; +a b +10 2 +10 2 +NULL NULL +# We correctly reject this: +select t1.a, v1.b from t1 left join v1 on t1.a is not null group by v1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view v1; +drop table t1,t2; +create table emp(empno int, ename char(1), deptno int); +create table dept(deptno int primary key, dname char(1)); +CREATE algorithm=merge VIEW empdept AS +SELECT emp.empno, emp.ename, dept.deptno, dept.dname +FROM emp LEFT OUTER JOIN dept ON (emp.deptno = dept.deptno); +EXPLAIN SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE emp NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +1 SIMPLE dept NULL eq_ref PRIMARY PRIMARY 4 test.emp.deptno 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`dept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`emp` left join `test`.`dept` on((`test`.`dept`.`deptno` = `test`.`emp`.`deptno`)) where true group by `test`.`dept`.`deptno` +# There is pk-based FD dept.Depno->dept.dname in dept +# and it propagates in the view-which-became-nest because it is +# NULL-friendly. +SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +dname COUNT(*) +drop view empdept; +CREATE algorithm=temptable VIEW empdept AS +SELECT emp.empno, emp.ename, dept.deptno, dept.dname +FROM emp LEFT OUTER JOIN dept ON (emp.deptno = dept.deptno); +EXPLAIN SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 DERIVED emp NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED dept NULL eq_ref PRIMARY PRIMARY 4 test.emp.deptno 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`empdept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`empdept` group by `test`.`empdept`.`deptno` +# There is pk-based FD dept.Depno->dept.dname in dept +# and it propagates in the materialized view because it is +# NULL-friendly, and then in the top query because the view is not in +# the weak side of an outer join. +SELECT dname, COUNT(*) +FROM empdept +GROUP BY deptno; +dname COUNT(*) +# More tests, for code coverage. +# UNION in derived table +select emp.ename +from +(select 1 as empno union select 2) deriv, +emp +where emp.empno=deriv.empno +group by emp.empno; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.emp.ename' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop view empdept; +# Make the key-searching loop meet view columns which don't wrap a +# column (CONCAT). +CREATE VIEW empdept AS +SELECT emp.empno, emp.ename, dept.deptno, concat("",dept.dname) as dname +FROM emp LEFT JOIN dept ON (emp.deptno = dept.deptno); +SELECT ename, COUNT(*) FROM empdept WHERE empno=dname and empno=deptno GROUP BY empno; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.empdept.ename' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +drop table emp,dept; +drop view empdept; +# +# Bug#19636980 ASSERT `TABLE->OUTER_JOIN' FAILED IN GROUP_CHECK::FIND_FD_IN_JOINED_TABLE +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c4 DATE, +c5 VARCHAR(1) +); +CREATE TABLE t2 ( +c1 INT, +c2 INT, +c3 INT, +c5 VARCHAR(1) +); +# alias1.c5 is not FD, the error is detected at SELECT time +CREATE VIEW v1 AS +SELECT alias1.c4 AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON 1 +GROUP BY field1 +ORDER BY alias1.c5; +SELECT * FROM v1; +ERROR 42000: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'test.alias1.c5' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v1; +# alias1.c5 is FD (WHERE contains: alias1.c5='d') +CREATE VIEW v1 AS +SELECT alias1.c4 AS field1, alias1.c4 AS field2 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias2.c1 = alias1.c2) +WHERE ( NOT EXISTS ( +SELECT SQ1_alias1.c5 AS SQ1_field1 +FROM t2 AS SQ1_alias1 +WHERE SQ1_alias1.c3 < alias1.c1 +)) +AND (alias1.c5 = alias1.c5 +AND alias1.c5 = 'd' + ) +GROUP BY field1, field2 +ORDER BY alias1.c5, field1, field2 +; +SELECT * FROM v1; +field1 field2 +DROP VIEW v1; +DROP TABLE t1,t2; +# +# Bug#19636409 ASSERT `(MAP_OF_NEW_EQ_FDS...` IN GROUP_CHECK::IS_FD_ON_SOURCE ON SELECT +# +CREATE TABLE t1 ( +pk int NOT NULL, +c1 datetime, +c2 varchar(1), +c3 date, +c4 date, +c5 varchar(1), +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS +SELECT c3 AS subfield11, +pk AS subfield12, +c2 AS subfield13 +FROM t1 +GROUP BY subfield11, subfield12 +; +# This query is valid. Indeed: field3 i.e. t1.c2 is part of GROUP BY, +# so, in a group: +# - all rows have the same value of t1.c2, noted val_c2, +# - so all rows, which necessarily match WHERE, matched with a row of +# v1 having subfield11=val_c2 and subfield12=val_c2 (due to IN +# predicate), +# - thus both grouping columns of v1's query expression are constant +# (to val_c2) +# - thus v1.subfield13 is constant too (grouping columns determine the +# SELECT list) +# - so, due to IN, this determines the value of t1.pk (t1 is the top +# query's table). +# - so t1.pk is constant, so all columns of t1 are constant. +# Which proves that it makes sense to search FDs in semijoin +# equalities. +# In other words: a semijoin is like a join except that it eliminates +# duplicates, but duplicates are irrelevant to the decision whether a +# column is functionally dependent on a set of columns. +SELECT c5 AS field1, +c4 AS field2, +c2 AS field3, +c1 AS field4 +FROM t1 +WHERE ( c2, c2, pk ) IN ( +SELECT * FROM v1 +) +GROUP BY field1, field3, field3; +field1 field2 field3 field4 +# +# Bug#19687724 FUNCTIONAL DEPENDENCIES ARE NOT RECOGNIZED IN EQUALITIES BETWEEN ROWS +# +# Inspired by query above, but with a join: +SELECT c5 AS field1, +c4 AS field2, +c2 AS field3, +c1 AS field4 +FROM t1, v1 +WHERE ( c2, c2, pk ) = (subfield11, subfield12, subfield13) +GROUP BY field1, field3, field3; +field1 field2 field3 field4 +# With constants: +SELECT c5 AS field1, +c4 AS field2, +c2 AS field3, +c1 AS field4 +FROM t1 +WHERE ( c2, c2, pk ) = (1, 2, 3) +GROUP BY field1, field3, field3; +field1 field2 field3 field4 +DROP TABLE t1; +CREATE TABLE t1(a INT, b INT, c INT, d INT); +SELECT a,b,c,d FROM t1 WHERE a=c AND b=d GROUP by a,b; +a b c d +SELECT a,b,c,d FROM t1 WHERE (a,b)=(c,d) GROUP BY a,b; +a b c d +SELECT a,b,c,d FROM t1 WHERE (a,b)=(c,d+1) GROUP BY a,b; +ERROR 42000: Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1; +DROP VIEW v1; +# +# Bug #20031708 ASSERT ON GROUP_CHECK::IS_FD_ON_SOURCE +# +CREATE TABLE t1 ( +col_varchar_10_utf8 VARCHAR(10) CHARACTER SET utf8, +col_int_key INT, +pk INT PRIMARY KEY +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +col_varchar_10_utf8 VARCHAR(10) CHARACTER SET utf8 DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT PRIMARY KEY +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v2 AS SELECT * FROM t2; +# The reporter's testcase: +SELECT COUNT(*), t1.col_int_key +FROM v2 LEFT OUTER JOIN t1 +ON v2.col_varchar_10_utf8 = t1.col_varchar_10_utf8 +WHERE v2.pk = 4; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.col_int_key'; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v2; +# A variant: one column is an expression: +CREATE VIEW v2 AS SELECT +CONCAT(col_varchar_10_utf8,' ') AS col_varchar_10_utf8, +col_int_key, +pk +FROM t2; +SELECT COUNT(*), t1.col_int_key +FROM v2 LEFT OUTER JOIN t1 +ON v2.col_varchar_10_utf8 = t1.col_varchar_10_utf8 +WHERE v2.pk = 4; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.col_int_key'; this is incompatible with sql_mode=only_full_group_by +DROP VIEW v2; +# Query used in the commit comment: view column involving two tables +CREATE VIEW v2 AS +SELECT t1.pk, t2.col_int_key+1 as c, t1.pk+t2.col_int_key as p +FROM t1, t2; +# FDs will be discovered in this order: {}->v2.pk, v2.pk->v2.c, +# v2.c->v2.p +SELECT COUNT(*), v2.p +FROM v2 +WHERE v2.c=v2.p and v2.c=v2.pk AND v2.pk = 4; +COUNT(*) p +0 NULL +DROP VIEW v2; +# If in the query specification defining a view, a base table's pk is +# determined, +# and the view's column is a function of this base table's columns, +# then the view's column is also determined. +# So, in this view's result, {v2.pk}->{v2.coa}: +CREATE ALGORITHM=MERGE VIEW v2 AS +SELECT t2.pk, COALESCE(t2.pk, 3) AS coa +FROM t1 LEFT JOIN t2 ON 0; +# And thus {pk}->{coa} holds in the result of this query using the view; +# if there is NULL-complementing in the LEFT JOIN below then (pk,coa) +# will be (NULL,NULL) and if there is not it will be (non-NULL,3): +# v2.coa is determined by v2.pk. The key fact is that v2.pk is not +# NULLable so this is a NFFD. +SELECT v2.pk, v2.coa +FROM t1 LEFT JOIN v2 AS v2 ON 0 +GROUP BY v2.pk; +pk coa +DROP VIEW v2; +DROP TABLE t1,t2; +# +# Bug#21807579 FUNCTIONAL DEPENDENCIES ARE NOT RECOGNIZED IN GENERATED COLUMNS +# +CREATE TABLE t ( a INT, c INT GENERATED ALWAYS AS (a+2), d INT GENERATED ALWAYS AS (c+2) ); +# {a}->{c}, {c}->{d} and {a}->{d} hold. +SELECT c FROM t GROUP BY a; +c +SELECT d FROM t GROUP BY c; +d +SELECT d FROM t GROUP BY a; +d +SELECT 1+c FROM t GROUP BY a; +1+c +SELECT 1+d FROM t GROUP BY c; +1+d +SELECT 1+d FROM t GROUP BY a; +1+d +# {t2.a}->{t2.d}->{t1.c}->{t1.d} +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d=t1.c GROUP BY t2.a; +d +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d>t1.c GROUP BY t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t; +# A non-NULL-friendly dependency. +CREATE TABLE t ( a INT, +c INT GENERATED ALWAYS AS (COALESCE(a,3)) ); +INSERT INTO t (a) VALUES(NULL); +CREATE TABLE u ( a INT ); +INSERT INTO u VALUES(0),(1); +# Even though {a}->{c} holds in 't', it doesn't propagate to the left +# join's result +SELECT t.a,t.c FROM u LEFT JOIN t ON u.a>0; +a c +NULL 3 +NULL NULL +SELECT t.a,t.c FROM u LEFT JOIN t ON u.a>0 GROUP BY t.a; +ERROR 42000: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t,u; +# +# Bug #22924183 GROUP BY ON DERIVED TABLE, EXPRESSION OF AGGREGATE AND GROUP COLUMN: ERROR +# +CREATE TABLE coll ( +doc text +) ENGINE=InnoDB; +SELECT (je+1)+count(*) FROM (SELECT doc+1 AS je FROM coll) AS dt GROUP BY je; +(je+1)+count(*) +SELECT je+(1+count(*)) FROM (SELECT doc+1 AS je FROM coll) AS dt GROUP BY je; +je+(1+count(*)) +DROP TABLE coll; +# +# Bug#27114719 FUNCTIONAL DEPENDENCY CHECK FAILS ON FIRST CALL, SUCCEEDS ON NEXT +# +CREATE TABLE t ( a INT, c INT GENERATED ALWAYS AS (a+2), d INT GENERATED +ALWAYS AS (c+2) ); +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d>t1.c GROUP BY t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t1.d FROM t as t1, t as t2 WHERE t2.d>t1.c GROUP BY t2.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.d' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +FLUSH TABLES; +SELECT (SELECT t1.c FROM t as t1 GROUP BY -3) FROM t as t2; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT DISTINCT t1.a FROM t as t1 ORDER BY t1.d LIMIT 1; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.d' which is not in SELECT list; this is incompatible with DISTINCT +SELECT (SELECT DISTINCT t1.a FROM t as t1 ORDER BY t1.d LIMIT 1) FROM t as t2; +ERROR HY000: Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t1.d' which is not in SELECT list; this is incompatible with DISTINCT +DROP TABLE t; +# +# Bug#22279903 ISSUE WITH ONLY_FULL_GROUP_BY AND UNIQUE KEY WITH NULL VALUES +# +CREATE TABLE t(a INT NULL, b INT NOT NULL, c INT, UNIQUE(a,b)); +INSERT INTO t VALUES (NULL, 1, 4); +INSERT INTO t VALUES (NULL, 1, 5); +SELECT a,b,c FROM t GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE a IS NOT NULL GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE NOT (a IS NULL) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a > 3 GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a = 3 GROUP BY b; +a b c +SELECT a,b,c FROM t WHERE a BETWEEN 3 AND 6 GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a <> 3 GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IN (3,4) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IN (SELECT b FROM t) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IS TRUE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE (a <> 3) IS TRUE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IS FALSE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE (a <> 3) IS FALSE GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE NOT(a IN (3,4)) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a NOT IN (3,4) GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a LIKE "%abc%" GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a NOT LIKE "%abc%" GROUP BY a,b; +a b c +SELECT a,b,c FROM t WHERE a IS TRUE GROUP BY b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE a<=>NULL GROUP BY b; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE a IS NOT TRUE GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM +(SELECT * FROM t WHERE a IS NOT NULL) AS dt GROUP BY a,b; +a b c +SELECT /*+ NO_MERGE() */ a,b,c FROM +(SELECT * FROM t WHERE a IS NOT NULL) AS dt GROUP BY a,b; +a b c +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "columns": [ + "dt.a", + "dt.b", + "dt.c" + ] /* columns */, + "searched_in_materialized_tables": [ + { + "table": " `dt`", + "all_columns_of_table_map_bits": [ + 0 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t.a", + "test.t.b" + ] /* columns */ + } + ] /* searched_in_materialized_tables */ + } +SELECT a,b,c FROM t WHERE a IS NULL GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT a,b,c FROM t WHERE NOT(a IS NOT NULL) GROUP BY a,b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t.* FROM t LEFT JOIN t AS t1 ON t.a IS NOT NULL +GROUP BY t.a,t.b; +ERROR 42000: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT t.* FROM t RIGHT JOIN t AS t1 ON t.a IS NOT NULL +GROUP BY t.a,t.b; +a b c +NULL NULL NULL +DROP TABLE t; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (b INT); +CREATE TABLE t3 ( +b INT NULL, +c INT NULL, +d INT NULL, +e INT NULL, +UNIQUE KEY (b,d,e)); +SELECT * FROM t1, t2, t3 +WHERE t2.b = t1.b AND t2.b = t3.b +AND t3.d = 1 AND t3.e = 1 AND t3.d IS NOT NULL AND t1.a = 2 +GROUP BY t1.b; +a b b b c d e +SELECT * FROM t1, t2, t3 +WHERE t2.b = t1.b AND t2.b = t3.b +AND t3.d = 1 AND t3.e = 1 AND t1.a = 2 +GROUP BY t1.b; +a b b b c d e +SELECT show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"functional_dependencies_of_GROUP_columns": {', TRACE) +"functional_dependencies_of_GROUP_columns": { + "all_columns_of_table_map_bits": [ + 2 + ] /* all_columns_of_table_map_bits */, + "columns": [ + "test.t1.b", + "test.t2.b", + "test.t3.b", + "test.t3.d", + "test.t3.e", + "test.t1.a" + ] /* columns */ + } +SELECT * FROM t1, t2, t3 +WHERE t2.b = t1.b AND t2.b = t3.b +AND t3.e = 1 AND t3.d IS NOT NULL AND t1.a = 2 +GROUP BY t1.b; +ERROR 42000: Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t3.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +# Verify that for semijoin and antijoin we catch the FD issues. +explain select (select 2 from t2 where 1=(select t1.b from t3)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where exists(select t1.b from t3)) as col from t1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t3 NULL index NULL b 15 NULL 1 100.00 Using index; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select 2 from `test`.`t2` semi join (`test`.`t3`) where true) AS `col` from `test`.`t1` group by `test`.`t1`.`a` +explain select (select 2 from t2 where not exists(select t1.b from t3)) as col from t1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t3 NULL index NULL b 15 NULL 1 100.00 Using where; Not exists; Using index; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select 2 from `test`.`t2` anti join (`test`.`t3`) on((1 = 1)) where true) AS `col` from `test`.`t1` group by `test`.`t1`.`a` +explain select (select 2 from t2 where exists(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where not exists(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where 1 in(select t1.b from t3)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +alter table t1 modify b int not null; +explain select (select 2 from t2 where 1 not in(select t1.b from t3)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where 1 in(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +explain select (select 2 from t2 where 1 not in(select 1 from t3 where t1.b)) as col from t1 group by t1.a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1, t2, t3; +DROP FUNCTION show_json_object; +# +# Bug#29006668 UNEXPECTED ERROR: "ORDER BY CLAUSE IS NOT IN GROUP BY CLAUSE" WITH ROLLUP +# +CREATE TABLE t(i INT); +INSERT INTO t VALUES (-1),(2),(1); +SELECT ABS(i) AS a FROM t GROUP BY abs(i) ORDER BY a + 1; +a +1 +2 +SELECT ABS(i) AS a FROM t GROUP BY abs(i) WITH ROLLUP ORDER BY a + 1; +a +NULL +1 +2 +SELECT ABS(i) AS a FROM t GROUP BY a ORDER BY a + 1; +a +1 +2 +SELECT ABS(i) AS a FROM t GROUP BY a WITH ROLLUP ORDER BY a + 1; +a +NULL +1 +2 +DROP TABLE t; +# +# Bug#30753524 DBUG_ASSERT((MAP_OF_NEW_FDS & PSEUDO_TABLE_BITS) == 0) +# +CREATE TABLE t (a INT,b INT); +SELECT 1 FROM t AS ot +WHERE 1 <= +( +SELECT it2.a +FROM +( +SELECT ot.b FROM t AS it1 +) AS dt +JOIN t AS it2 ON dt.b=it2.b +GROUP BY it2.b +) +; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.it2.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +SELECT 1 FROM t AS ot +WHERE 1 <= +( +SELECT dt.b +FROM +( +SELECT ot.b FROM t AS it1 +) AS dt +JOIN t AS it2 ON dt.b=it2.b +GROUP BY it2.b +) +; +1 +DROP TABLE t; diff --git a/mysql-test/r/group_min_max.result-pq b/mysql-test/r/group_min_max.result-pq new file mode 100644 index 000000000..e927c86ec --- /dev/null +++ b/mysql-test/r/group_min_max.result-pq @@ -0,0 +1,4501 @@ +drop table if exists t1; +create table t1 ( +a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(248) default ' ' +) charset latin1; +insert into t1 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +create index idx_t1_0 on t1 (a1); +create index idx_t1_1 on t1 (a1,a2,b,c); +create index idx_t1_2 on t1 (a1,a2,b); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +drop table if exists t2; +create table t2 ( +a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(248) default ' ' +) charset latin1; +insert into t2 select * from t1; +insert into t2 (a1, a2, b, c, d) values +('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'), +('a','a','a',NULL,'xyz'), +('a','a','b',NULL,'xyz'), +('a','b','a',NULL,'xyz'), +('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'), +('d','b','b',NULL,'xyz'), +('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'), +('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'), +('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'), +('a','a','a',NULL,'xyz'), +('a','a','b',NULL,'xyz'), +('a','b','a',NULL,'xyz'), +('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'), +('d','b','b',NULL,'xyz'), +('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'), +('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'); +create index idx_t2_0 on t2 (a1); +create index idx_t2_1 on t2 (a1,a2,b,c); +create index idx_t2_2 on t2 (a1,a2,b); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status Table is already up to date +drop table if exists t3; +create table t3 ( +a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' ' +) charset latin1; +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +create index idx_t3_0 on t3 (a1); +create index idx_t3_1 on t3 (a1,a2,b,c); +create index idx_t3_2 on t3 (a1,a2,b); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status Table is already up to date +explain select a1, min(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,min(`test`.`t1`.`a2`) AS `min(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain format=tree select a1, min(a2) from t1 group by a1; +EXPLAIN +-> Index range scan on t1 using index_for_group_by(idx_t1_1) (cost=3.25 rows=5) + +explain select a1, max(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 65 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`a2`) AS `max(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a1, min(a2), max(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,min(`test`.`t1`.`a2`) AS `min(a2)`,max(`test`.`t1`.`a2`) AS `max(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 # NULL # 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a2`) AS `min(a2)`,`test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`a2`) AS `max(a2)`,min(`test`.`t1`.`a2`) AS `min(a2)`,`test`.`t1`.`a1` AS `a1` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,`test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`a2` AS `a2`,max(`test`.`t1`.`c`) AS `max(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select min(a2) from t1 group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a2`) AS `min(a2)` from `test`.`t1` group by `test`.`t1`.`a1` +explain select a2, min(c), max(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +select a1, min(a2) from t1 group by a1; +a1 min(a2) +a a +b a +c a +d a +select a1, max(a2) from t1 group by a1; +a1 max(a2) +a b +b b +c b +d b +select a1, min(a2), max(a2) from t1 group by a1; +a1 min(a2) max(a2) +a a b +b a b +c a b +d a b +select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,max(c),min(c) from t1 group by a1,a2,b; +a1 a2 b max(c) min(c) +a a a d111 a111 +a a b h112 e112 +a b a l121 i121 +a b b p122 m122 +b a a d211 a211 +b a b h212 e212 +b b a l221 i221 +b b b p222 m222 +c a a d311 a311 +c a b h312 e312 +c b a l321 i321 +c b b p322 m322 +d a a d411 a411 +d a b h412 e412 +d b a l421 i421 +d b b p422 m422 +select a1,a2,b,max(c),min(c) from t2 group by a1,a2,b; +a1 a2 b max(c) min(c) +a a NULL a999 a777 +a a a d111 a111 +a a b h112 e112 +a b a l121 i121 +a b b p122 m122 +b a a d211 a211 +b a b h212 e212 +b b a l221 i221 +b b b p222 m222 +c a NULL c999 c777 +c a a d311 a311 +c a b h312 e312 +c b a l321 i321 +c b b p322 m322 +d a a d411 a411 +d a b h412 e412 +d b a l421 i421 +d b b p422 m422 +e a a NULL NULL +e a b NULL NULL +select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1; +min(a2) a1 max(a2) min(a2) a1 +a a b a a +a b b a b +a c b a c +a d b a d +select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b; +a1 b min(c) a1 max(c) b a2 max(c) max(c) +a a a111 a d111 a a d111 d111 +a b e112 a h112 b a h112 h112 +a a i121 a l121 a b l121 l121 +a b m122 a p122 b b p122 p122 +b a a211 b d211 a a d211 d211 +b b e212 b h212 b a h212 h212 +b a i221 b l221 a b l221 l221 +b b m222 b p222 b b p222 p222 +c a a311 c d311 a a d311 d311 +c b e312 c h312 b a h312 h312 +c a i321 c l321 a b l321 l321 +c b m322 c p322 b b p322 p322 +d a a411 d d411 a a d411 d411 +d b e412 d h412 b a h412 h412 +d a i421 d l421 a b l421 l421 +d b m422 d p422 b b p422 p422 +select min(a2) from t1 group by a1; +min(a2) +a +a +a +a +select a2, min(c), max(c) from t1 group by a1,a2,b; +a2 min(c) max(c) +a a111 d111 +a e112 h112 +b i121 l121 +b m122 p122 +a a211 d211 +a e212 h212 +b i221 l221 +b m222 p222 +a a311 d311 +a e312 h312 +b i321 l321 +b m322 p322 +a a411 d411 +a e412 h412 +b i421 l421 +b m422 p422 +explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` >= 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a1` < 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a1` < 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` = 'z') or (`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`a1` = 'z') or (`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` >= 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` in ('a','b','d')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` < 'd') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` < 'd') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` >= 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a1` < 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a1` < 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` = 'z') or (`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a1` = 'z') or (`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd') or (`test`.`t2`.`a1` = 'a') or (`test`.`t2`.`a1` = 'c')) and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` = 'b') or (`test`.`t2`.`a1` = 'd') or (`test`.`t2`.`a1` = 'a') or (`test`.`t2`.`a1` = 'c')) and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` >= 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`a1` in ('a','b','d')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 max(c) +a d111 +a h112 +a l121 +a p122 +c d311 +c h312 +c l321 +c p322 +d d411 +d h412 +d l421 +d p422 +select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +b a a a211 d211 +b a b e212 h212 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b max(c) +b a a d211 +b a b h212 +b b a l221 +b b b p222 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b max(c) +a b a l121 +a b b p122 +b b a l221 +b b b p222 +c b a l321 +c b b p322 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +a b b m122 p122 +b b a i221 l221 +b b b m222 p222 +c b a i321 l321 +c b b m322 p322 +d b a i421 l421 +d b b m422 p422 +select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b; +a1 min(c) max(c) +b a211 d211 +b e212 h212 +b i221 l221 +b m222 p222 +c a311 d311 +c e312 h312 +c i321 l321 +c m322 p322 +d a411 d411 +d e412 h412 +d i421 l421 +d m422 p422 +select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b; +a1 max(c) +a d111 +a h112 +a l121 +a p122 +b d211 +b h212 +b l221 +b p222 +d d411 +d h412 +d l421 +d p422 +select a1,a2,b, max(c) from t2 where a1 < 'd' group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +select a1,a2,b,min(c),max(c) from t2 where a1 < 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +select a1,a2,b,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +e a a NULL NULL +e a b NULL NULL +select a1,a2,b, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a l121 +a b b p122 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +e a a NULL +e a b NULL +select a1, max(c) from t2 where a1 >= 'c' or a1 < 'b' group by a1,a2,b; +a1 max(c) +a a999 +a d111 +a h112 +a l121 +a p122 +c c999 +c d311 +c h312 +c l321 +c p322 +d d411 +d h412 +d l421 +d p422 +e NULL +e NULL +select a1,a2,b,min(c),max(c) from t2 where a1 >= 'c' or a2 < 'b' group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +b a a a211 d211 +b a b e212 h212 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +e a a NULL NULL +e a b NULL NULL +select a1,a2,b, max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b max(c) +b a a d211 +b a b h212 +b b a l221 +b b b p222 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b; +a1 a2 b min(c) max(c) +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b max(c) +a b a l121 +a b b p122 +b b a l221 +b b b p222 +c b a l321 +c b b p322 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +a b b m122 p122 +b b a i221 l221 +b b b m222 p222 +c b a i321 l321 +c b b m322 p322 +d b a i421 l421 +d b b m422 p422 +select a1,min(c),max(c) from t2 where a1 >= 'b' group by a1,a2,b; +a1 min(c) max(c) +b a211 d211 +b e212 h212 +b i221 l221 +b m222 p222 +c c777 c999 +c a311 d311 +c e312 h312 +c i321 l321 +c m322 p322 +d a411 d411 +d e412 h412 +d i421 l421 +d m422 p422 +e NULL NULL +e NULL NULL +select a1, max(c) from t2 where a1 in ('a','b','d') group by a1,a2,b; +a1 max(c) +a a999 +a d111 +a h112 +a l121 +a p122 +b d211 +b h212 +b l221 +b p222 +d d411 +d h412 +d l421 +d p422 +explain select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'b') and (`test`.`t1`.`a2` = 'a')) group by `test`.`t1`.`a1` +explain select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,max(`test`.`t1`.`c`) AS `max(c)`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'b') and (`test`.`t1`.`a2` = 'a')) group by `test`.`t1`.`a1` +explain select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) group by `test`.`t2`.`a1` +explain select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) group by `test`.`t2`.`a1` +explain select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` = 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` = 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` = 'b') group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range idx_t3_0,idx_t3_1,idx_t3_2 idx_t3_1 6 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a1` AS `a1`,`test`.`t3`.`a2` AS `a2`,`test`.`t3`.`b` AS `b`,max(`test`.`t3`.`c`) AS `max(c)`,min(`test`.`t3`.`c`) AS `min(c)` from `test`.`t3` where ((`test`.`t3`.`b` = 'b') and (`test`.`t3`.`a2` = 'a')) group by `test`.`t3`.`a1` +explain select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range idx_t3_0,idx_t3_1,idx_t3_2 idx_t3_1 6 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a1` AS `a1`,max(`test`.`t3`.`c`) AS `max(c)`,min(`test`.`t3`.`c`) AS `min(c)` from `test`.`t3` where ((`test`.`t3`.`b` = 'b') and (`test`.`t3`.`a2` = 'a')) group by `test`.`t3`.`a1` +select a1,a2,b,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +a1 a2 b max(c) min(c) +a a b h112 e112 +b a b h212 e212 +c a b h312 e312 +d a b h412 e412 +select a1,max(c),min(c) from t1 where (a2 = 'a') and (b = 'b') group by a1; +a1 max(c) min(c) +a h112 e112 +b h212 e212 +c h312 e312 +d h412 e412 +select a1,a2,b, max(c) from t1 where (b = 'b') group by a1,a2; +a1 a2 b max(c) +a a b h112 +a b b p122 +b a b h212 +b b b p222 +c a b h312 +c b b p322 +d a b h412 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (b = 'b') group by a1,a2; +a1 a2 b min(c) max(c) +a a b e112 h112 +a b b m122 p122 +b a b e212 h212 +b b b m222 p222 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +select a1,a2, max(c) from t1 where (b = 'b') group by a1,a2; +a1 a2 max(c) +a a h112 +a b p122 +b a h212 +b b p222 +c a h312 +c b p322 +d a h412 +d b p422 +select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +a1 a2 b max(c) min(c) +a a b h112 e112 +b a b h212 e212 +c a b h312 e312 +d a b h412 e412 +e a b NULL NULL +select a1,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') group by a1; +a1 max(c) min(c) +a h112 e112 +b h212 e212 +c h312 e312 +d h412 e412 +e NULL NULL +select a1,a2,b, max(c) from t2 where (b = 'b') group by a1,a2; +a1 a2 b max(c) +a a b h112 +a b b p122 +b a b h212 +b b b p222 +c a b h312 +c b b p322 +d a b h412 +d b b p422 +e a b NULL +select a1,a2,b,min(c),max(c) from t2 where (b = 'b') group by a1,a2; +a1 a2 b min(c) max(c) +a a b e112 h112 +a b b m122 p122 +b a b e212 h212 +b b b m222 p222 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +e a b NULL NULL +select a1,a2, max(c) from t2 where (b = 'b') group by a1,a2; +a1 a2 max(c) +a a h112 +a b p122 +b a h212 +b b p222 +c a h312 +c b p322 +d a h412 +d b p422 +e a NULL +select a1,a2,b,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +a1 a2 b max(c) min(c) +a a b h112 e112 +b a b h212 e212 +c a b h312 e312 +select a1,max(c),min(c) from t3 where (a2 = 'a') and (b = 'b') group by a1; +a1 max(c) min(c) +a h112 e112 +b h212 e212 +c h312 e312 +explain select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`a2` = 'a') and (`test`.`t2`.`b` is null)) group by `test`.`t2`.`a1` +explain select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`a2` = 'a') and (`test`.`t2`.`b` is null)) group by `test`.`t2`.`a1` +explain select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`b` is null) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select a1,a2,b,min(c) from t2 where (a2 = 'a') and b is NULL group by a1; +a1 a2 b min(c) +a a NULL a777 +c a NULL c777 +select a1,a2,b,max(c) from t2 where (a2 = 'a') and b is NULL group by a1; +a1 a2 b max(c) +a a NULL a999 +c a NULL c999 +select a1,a2,b,min(c) from t2 where b is NULL group by a1,a2; +a1 a2 b min(c) +a a NULL a777 +c a NULL c777 +select a1,a2,b,max(c) from t2 where b is NULL group by a1,a2; +a1 a2 b max(c) +a a NULL a999 +c a NULL c999 +select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +c a NULL c777 c999 +select a1,a2,b,min(c),max(c) from t2 where b is NULL group by a1,a2; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +c a NULL c777 c999 +explain select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL # 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'b1') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'b1') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'f123') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` > 'f123') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'a0') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'a0') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'k321') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`c` < 'k321') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` < 'a0') or (`test`.`t1`.`c` > 'b1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` < 'a0') or (`test`.`t1`.`c` > 'b1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 55.55 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` > 'b1') or (`test`.`t1`.`c` <= 'g1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 55.55 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` > 'b1') or (`test`.`t1`.`c` <= 'g1')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` > 'b111') and (`test`.`t1`.`c` <= 'g112')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` < 'c5') or (`test`.`t1`.`c` = 'g412') or (`test`.`t1`.`c` = 'k421')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`c` > 'b111') and (`test`.`t1`.`c` <= 'g112')) or ((`test`.`t1`.`c` > 'd000') and (`test`.`t1`.`c` <= 'i110'))) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`c` between 'b111' and 'g112') or (`test`.`t1`.`c` between 'd000' and 'i110')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'b1') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'b1') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 33.33 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'f123') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` > 'f123') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'a0') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'a0') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'k321') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (`test`.`t2`.`c` < 'k321') group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` < 'a0') or (`test`.`t2`.`c` > 'b1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` < 'a0') or (`test`.`t2`.`c` > 'b1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 55.55 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'b1') or (`test`.`t2`.`c` <= 'g1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'b1') or (`test`.`t2`.`c` <= 'g1')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'b111') and (`test`.`t2`.`c` <= 'g112')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` < 'c5') or (`test`.`t2`.`c` = 'g412') or (`test`.`t2`.`c` = 'k421')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`c` > 'b111') and (`test`.`t2`.`c` <= 'g112')) or ((`test`.`t2`.`c` > 'd000') and (`test`.`t2`.`c` <= 'i110'))) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +select a1,a2,b, max(c) from t1 where (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (c > 'f123') group by a1,a2,b; +a1 a2 b max(c) +a a b h112 +a b a l121 +a b b p122 +b a b h212 +b b a l221 +b b b p222 +c a b h312 +c b a l321 +c b b p322 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b g112 h112 +a b a i121 l121 +a b b m122 p122 +b a b f212 h212 +b b a i221 l221 +b b b m222 p222 +c a b f312 h312 +c b a i321 l321 +c b b m322 p322 +d a b f412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (c < 'a0') group by a1,a2,b; +a1 a2 b max(c) +select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b; +a1 a2 b min(c) max(c) +select a1,a2,b, max(c) from t1 where (c < 'k321') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a k121 +b a a d211 +b a b h212 +b b a k221 +c a a d311 +c a b h312 +c b a j321 +d a a d411 +d a b h412 +d b a j421 +select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 k121 +b a a a211 d211 +b a b e212 h212 +b b a i221 k221 +c a a a311 d311 +c a b e312 h312 +c b a i321 j321 +d a a a411 d411 +d a b e412 h412 +d b a i421 j421 +select a1,a2,b, max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 g112 +b a a b211 d211 +b a b e212 f212 +c a a b311 d311 +c a b e312 f312 +d a a b411 d411 +d a b e412 f412 +select a1,a2,b,min(c),max(c) from t1 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a a111 c111 +b a a a211 c211 +c a a a311 c311 +d a a a411 c411 +d a b g412 g412 +d b a k421 k421 +select a1,a2,b,min(c),max(c) from t1 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a a b311 d311 +c a b e312 h312 +d a a b411 d411 +d a b e412 h412 +select a1,a2,b,min(c),max(c) from t1 where (c between 'b111' and 'g112') or (c between 'd000' and 'i110') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a a b311 d311 +c a b e312 h312 +d a a b411 d411 +d a b e412 h412 +select a1,a2,b, max(c) from t2 where (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (c > 'f123') group by a1,a2,b; +a1 a2 b max(c) +a a b h112 +a b a l121 +a b b p122 +b a b h212 +b b a l221 +b b b p222 +c a b h312 +c b a l321 +c b b p322 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'f123') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b g112 h112 +a b a i121 l121 +a b b m122 p122 +b a b f212 h212 +b b a i221 l221 +b b b m222 p222 +c a b f312 h312 +c b a i321 l321 +c b b m322 p322 +d a b f412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (c < 'a0') group by a1,a2,b; +a1 a2 b max(c) +select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') group by a1,a2,b; +a1 a2 b min(c) max(c) +select a1,a2,b, max(c) from t2 where (c < 'k321') group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a k121 +b a a d211 +b a b h212 +b b a k221 +c a NULL c999 +c a a d311 +c a b h312 +c b a j321 +d a a d411 +d a b h412 +d b a j421 +select a1,a2,b,min(c),max(c) from t2 where (c < 'k321') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +a b a i121 k121 +b a a a211 d211 +b a b e212 h212 +b b a i221 k221 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 j321 +d a a a411 d411 +d a b e412 h412 +d b a i421 j421 +select a1,a2,b, max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b max(c) +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c < 'a0') or (c > 'b1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a b111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a b211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b max(c) +a a NULL a999 +a a a d111 +a a b h112 +a b a l121 +a b b p122 +b a a d211 +b a b h212 +b b a l221 +b b b p222 +c a NULL c999 +c a a d311 +c a b h312 +c b a l321 +c b b p322 +d a a d411 +d a b h412 +d b a l421 +d b b p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 d111 +a a b e112 h112 +a b a i121 l121 +a b b m122 p122 +b a a a211 d211 +b a b e212 h212 +b b a i221 l221 +b b b m222 p222 +c a NULL c777 c999 +c a a a311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a a411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t2 where (c > 'b111') and (c <= 'g112') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 g112 +b a a b211 d211 +b a b e212 f212 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 f312 +d a a b411 d411 +d a b e412 f412 +select a1,a2,b,min(c),max(c) from t2 where (c < 'c5') or (c = 'g412') or (c = 'k421') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a NULL a777 a999 +a a a a111 c111 +b a a a211 c211 +c a a a311 c311 +d a a a411 c411 +d a b g412 g412 +d b a k421 k421 +select a1,a2,b,min(c),max(c) from t2 where ((c > 'b111') and (c <= 'g112')) or ((c > 'd000') and (c <= 'i110')) group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +d a a b411 d411 +d a b e412 h412 +explain select a1,a2,b,min(c),max(c) from t1 +where exists ( select * from t2 where t2.c = t1.c ) +group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using index +1 SIMPLE NULL eq_ref 17 test.t1.c 1 100.00 NULL +2 MATERIALIZED t2 NULL index NULL idx_t2_1 163 NULL 164 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` semi join (`test`.`t2`) where (``.`c` = `test`.`t1`.`c`) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 +where exists ( select * from t2 where t2.c > 'b1' ) +group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL idx_t2_1 163 NULL 164 33.33 Using where; Using index; Using temporary; FirstMatch +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`c` > 'b1') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) and (`test`.`t1`.`b` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) and (`test`.`t1`.`c` > 'b111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b') and (`test`.`t1`.`c` > 'b111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and ((`test`.`t1`.`a1` > 'a') or (`test`.`t1`.`a1` < '9')) and (`test`.`t1`.`a2` >= 'b') and (`test`.`t1`.`a2` < 'z') and ((`test`.`t1`.`c` < 'h112') or (`test`.`t1`.`c` = 'j121') or ((`test`.`t1`.`c` > 'k121') and (`test`.`t1`.`c` < 'm122')) or (`test`.`t1`.`c` > 'o122'))) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and ((`test`.`t1`.`a1` > 'a') or (`test`.`t1`.`a1` < '9')) and (`test`.`t1`.`a2` >= 'b') and (`test`.`t1`.`a2` < 'z') and ((`test`.`t1`.`c` = 'j121') or ((`test`.`t1`.`c` > 'k121') and (`test`.`t1`.`c` < 'm122')) or (`test`.`t1`.`c` > 'o122') or (`test`.`t1`.`c` < 'h112') or (`test`.`t1`.`c` = 'c111'))) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (ord(`test`.`t1`.`a1`) > 97) and ((ord(`test`.`t1`.`a2`) + ord(`test`.`t1`.`a1`)) > 194)) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) and (`test`.`t2`.`b` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where (((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) and (`test`.`t2`.`c` > 'b111')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b') and (`test`.`t2`.`c` > 'b111')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and ((`test`.`t2`.`a1` > 'a') or (`test`.`t2`.`a1` < '9')) and (`test`.`t2`.`a2` >= 'b') and (`test`.`t2`.`a2` < 'z') and ((`test`.`t2`.`c` < 'h112') or (`test`.`t2`.`c` = 'j121') or ((`test`.`t2`.`c` > 'k121') and (`test`.`t2`.`c` < 'm122')) or (`test`.`t2`.`c` > 'o122'))) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and ((`test`.`t2`.`a1` > 'a') or (`test`.`t2`.`a1` < '9')) and (`test`.`t2`.`a2` >= 'b') and (`test`.`t2`.`a2` < 'z') and ((`test`.`t2`.`c` = 'j121') or ((`test`.`t2`.`c` > 'k121') and (`test`.`t2`.`c` < 'm122')) or (`test`.`t2`.`c` > 'o122') or (`test`.`t2`.`c` < 'h112') or (`test`.`t2`.`c` = 'c111'))) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b e112 h112 +b a b e212 h212 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +b b a i221 l221 +c b a i321 l321 +d b a i421 l421 +select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b min(c) +select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b; +a1 a2 b min(c) +select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a b e112 h112 +b a b e212 h212 +c a b e312 h312 +c b b m322 p322 +d a b e412 h412 +d b b m422 p422 +e a b NULL NULL +select a1,a2,b,min(c),max(c) from t2 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a a a c111 d111 +a a b e112 h112 +b a a b211 d211 +b a b e212 h212 +c a NULL c777 c999 +c a a b311 d311 +c a b e312 h312 +c b a i321 l321 +c b b m322 p322 +d a a b411 d411 +d a b e412 h412 +d b a i421 l421 +d b b m422 p422 +select a1,a2,b,min(c),max(c) from t2 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b; +a1 a2 b min(c) max(c) +a b a i121 l121 +b b a i221 l221 +c b a i321 l321 +d b a i421 l421 +select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t2 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b; +a1 a2 b min(c) +b b a k221 +c b a k321 +d b a k421 +select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b min(c) +explain select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a1` >= 'c') or (`test`.`t1`.`a2` < 'b')) and (`test`.`t1`.`b` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain format=tree select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +EXPLAIN +-> Filter: (((t1.a1 >= 'c') or (t1.a2 < 'b')) and (t1.b > 'a')) (cost=11.05 rows=17) + -> Index range scan on t1 using index_for_group_by(idx_t1_1) (cost=11.05 rows=17) + +explain select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`a1` >= 'c') or (`test`.`t2`.`a2` < 'b')) and (`test`.`t2`.`b` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select a1,a2,b from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b +a a b +b a b +c a b +c b b +d a b +d b b +select a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; +a1 a2 b +a a b +b a b +c a b +c b b +d a b +d b b +e a b +select a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +explain select distinct a1,a2,b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1 idx_t1_1 163 NULL 128 0.78 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) +explain select distinct b from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select distinct a1,a2,b from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` +explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) +explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_1 idx_t2_1 163 NULL 164 0.61 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) +explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) +explain select distinct b from t2 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_1,idx_t2_2 idx_t2_2 146 NULL 164 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) +select distinct a1,a2,b from t1; +a1 a2 b +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a'); +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +a1 a2 b +select distinct b from t1 where (a2 >= 'b') and (b = 'a'); +b +a +select distinct a1,a2,b from t2; +a1 a2 b +a a NULL +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a NULL +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +e a a +e a b +select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a'); +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +a1 a2 b +select distinct b from t2 where (a2 >= 'b') and (b = 'a'); +b +a +select distinct t_00.a1 +from t1 t_00 +where exists ( select * from t2 where a1 = t_00.a1 ); +a1 +a +b +c +d +select distinct a1,a1 from t1; +a1 a1 +a a +b b +c c +d d +select distinct a2,a1,a2,a1 from t1; +a2 a1 a2 a1 +a a a a +a b a b +a c a c +a d a d +b a b a +b b b b +b c b c +b d b d +select distinct t1.a1,t2.a1 from t1,t2; +a1 a1 +a a +a b +a c +a d +a e +b a +b b +b c +b d +b e +c a +c b +c c +c d +c e +d a +d b +d c +d d +d e +explain select distinct a1,a2,b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select distinct a1,a2,b from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` +explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'i121') and (`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'c') and (`test`.`t2`.`a1` > 'a') and (`test`.`t2`.`a2` > 'a')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +explain select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b` = 'a') and (`test`.`t2`.`a2` >= 'b')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +select distinct a1,a2,b from t1; +a1 a2 b +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +b +a +select distinct a1,a2,b from t2; +a1 a2 b +a a NULL +a a a +a a b +a b a +a b b +b a a +b a b +b b a +b b b +c a NULL +c a a +c a b +c b a +c b b +d a a +d a b +d b a +d b b +e a a +e a b +select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +a1 a2 b +a b a +b b a +c b a +d b a +select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121') group by a1,a2,b; +a1 a2 b c +a b a i121 +select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; +a1 a2 b +select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; +b +a +explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1 idx_t1_1 163 NULL 65 100.00 Using where; Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`) AS `count(distinct a1,a2,b,c)` from `test`.`t1` where ((`test`.`t1`.`c` = 'i121') and (`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'c') and (`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) +explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`) AS `count(distinct b)` from `test`.`t1` where ((`test`.`t1`.`b` = 'a') and (`test`.`t1`.`a2` >= 'b')) +explain select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`)) AS `98 + count(distinct a1,a2,b)` from `test`.`t1` where ((`test`.`t1`.`a1` > 'a') and (`test`.`t1`.`a2` > 'a')) +select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); +count(distinct a1,a2,b) +4 +select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +count(distinct a1,a2,b,c) +1 +select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +count(distinct a1,a2,b) +0 +select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); +count(distinct b) +1 +select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); +98 + count(distinct a1,a2,b) +104 +explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,concat(min(`test`.`t1`.`c`),max(`test`.`t1`.`c`)) AS `concat(min(c), max(c))` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`t1`.`a1`,min(`test`.`t1`.`c`)) AS `concat(a1,min(c))`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`t1`.`a1`,min(`test`.`t1`.`c`)) AS `concat(a1,min(c))`,`test`.`t1`.`b` AS `b`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(`test`.`t1`.`a1`,`test`.`t1`.`a2`) AS `concat(a1,a2)`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` < 'd') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select concat(ord(min(`test`.`t1`.`b`)),ord(max(`test`.`t1`.`b`))) AS `concat(ord(min(b)),ord(max(b)))`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; +a1 a2 b concat(min(c), max(c)) +a a a a111d111 +a a b e112h112 +a b a i121l121 +a b b m122p122 +b a a a211d211 +b a b e212h212 +b b a i221l221 +b b b m222p222 +c a a a311d311 +c a b e312h312 +c b a i321l321 +c b b m322p322 +select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b; +concat(a1,min(c)) b +aa111 a +ae112 b +ai121 a +am122 b +ba211 a +be212 b +bi221 a +bm222 b +ca311 a +ce312 b +ci321 a +cm322 b +select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b; +concat(a1,min(c)) b max(c) +aa111 a d111 +ae112 b h112 +ai121 a l121 +am122 b p122 +ba211 a d211 +be212 b h212 +bi221 a l221 +bm222 b p222 +ca311 a d311 +ce312 b h312 +ci321 a l321 +cm322 b p322 +select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b; +concat(a1,a2) b min(c) max(c) +aa a a111 d111 +aa b e112 h112 +ab a i121 l121 +ab b m122 p122 +ba a a211 d211 +ba b e212 h212 +bb a i221 l221 +bb b m222 p222 +ca a a311 d311 +ca b e312 h312 +cb a i321 l321 +cb b m322 p322 +select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; +concat(ord(min(b)),ord(max(b))) min(b) max(b) +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +9798 a b +explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,d from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,min(b),max(b) from t1 +where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2` +explain select a1,a2,b,min(c),max(c) from t1 +where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 11.02 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,b,c from t1 +where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 11.02 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`d` > 'xy2')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` +explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 34.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where (((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) or (`test`.`t2`.`b` < 'b')) group by `test`.`t2`.`a1` +explain select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 76 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a1` = 'b') or (`test`.`t1`.`a1` = 'd') or (`test`.`t1`.`a1` = 'a') or (`test`.`t1`.`a1` = 'c')) and (`test`.`t1`.`a2` > 'a') and (`test`.`t1`.`c` > 'a111')) group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,min(`test`.`t2`.`b`) AS `min(b)`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 'a111') and (`test`.`t2`.`a2` = 'a')) group by `test`.`t2`.`a1` +select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1; +a1 a2 min(b) c +a a a a111 +explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 10.90 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,max(`test`.`t2`.`c`) AS `max(c)`,min(`test`.`t2`.`c`) AS `min(c)` from `test`.`t2` where (((`test`.`t2`.`b` = 'b') and (`test`.`t2`.`a2` = 'a')) or (`test`.`t2`.`b` = 'a')) group by `test`.`t2`.`a1` +explain select a1,a2,b,min(c),max(c) from t2 +where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index idx_t2_1,idx_t2_2 idx_t2_1 163 NULL 164 1.23 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,min(`test`.`t2`.`c`) AS `min(c)`,max(`test`.`t2`.`c`) AS `max(c)` from `test`.`t2` where ((`test`.`t2`.`c` > 'a000') and (`test`.`t2`.`c` <= 'd999') and (`test`.`t2`.`c` like '_8__')) group by `test`.`t2`.`a1`,`test`.`t2`.`a2`,`test`.`t2`.`b` +explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1 idx_t1_1 163 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,min(`test`.`t1`.`d`) AS `min(d)`,max(`test`.`t1`.`d`) AS `max(d)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c` +explain select a1,a2,count(a2) from t1 group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` +explain select distinct(a1) from t1 where ord(a2) = 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (ord(`test`.`t1`.`a2`) = 98) +select distinct(a1) from t1 where ord(a2) = 98; +a1 +a +b +c +d +explain select a1 from t1 where a2 = 'b' group by a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a2` = 'b') group by `test`.`t1`.`a1` +select a1 from t1 where a2 = 'b' group by a1; +a1 +a +b +c +d +explain select distinct a1 from t1 where a2 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a2` = 'b') +select distinct a1 from t1 where a2 = 'b'; +a1 +a +b +c +d +drop table t1,t2,t3; +create table t1 (c1 int not null,c2 int not null, primary key(c1,c2)); +insert into t1 (c1,c2) values +(10,1),(10,2),(10,3),(20,4),(20,5),(20,6),(30,7),(30,8),(30,9); +select distinct c1, c2 from t1 order by c2; +c1 c2 +10 1 +10 2 +10 3 +20 4 +20 5 +20 6 +30 7 +30 8 +30 9 +select c1,min(c2) as c2 from t1 group by c1 order by c2; +c1 c2 +10 1 +20 4 +30 7 +select c1,c2 from t1 group by c1,c2 order by c2; +c1 c2 +10 1 +10 2 +10 3 +20 4 +20 5 +20 6 +30 7 +30 8 +30 9 +drop table t1; +CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b)) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SELECT a FROM t1 WHERE a='AA' GROUP BY a; +a +AA +SELECT a FROM t1 WHERE a='BB' GROUP BY a; +a +BB +EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 22 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'AA') group by `test`.`t1`.`a` +EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'BB') group by `test`.`t1`.`a` +SELECT DISTINCT a FROM t1 WHERE a='BB'; +a +BB +SELECT DISTINCT a FROM t1 WHERE a LIKE 'B%'; +a +BB +SELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a; +a +BB +DROP TABLE t1; +CREATE TABLE t1 ( +a int(11) NOT NULL DEFAULT '0', +b varchar(16) COLLATE latin1_general_ci NOT NULL DEFAULT '', +PRIMARY KEY (a,b) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE PROCEDURE a(x INT) +BEGIN +DECLARE rnd INT; +DECLARE cnt INT; +WHILE x > 0 DO +SET rnd= x % 100; +SET cnt = (SELECT COUNT(*) FROM t1 WHERE a = rnd); +INSERT INTO t1(a,b) VALUES (rnd, CAST(cnt AS CHAR)); +SET x= x - 1; +END WHILE; +END| +CALL a(1000); +SELECT a FROM t1 WHERE a=0; +a +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +SELECT DISTINCT a FROM t1 WHERE a=0; +a +0 +SELECT COUNT(DISTINCT a) FROM t1 WHERE a=0; +COUNT(DISTINCT a) +1 +DROP TABLE t1; +DROP PROCEDURE a; +CREATE TABLE t1 (a varchar(64) NOT NULL default '', PRIMARY KEY(a)) charset utf8mb4; +INSERT INTO t1 (a) VALUES +(''), ('CENTRAL'), ('EASTERN'), ('GREATER LONDON'), +('NORTH CENTRAL'), ('NORTH EAST'), ('NORTH WEST'), ('SCOTLAND'), +('SOUTH EAST'), ('SOUTH WEST'), ('WESTERN'); +EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 258 NULL 11 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a`,`test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT DISTINCT a,a FROM t1 ORDER BY a; +a a + +CENTRAL CENTRAL +EASTERN EASTERN +GREATER LONDON GREATER LONDON +NORTH CENTRAL NORTH CENTRAL +NORTH EAST NORTH EAST +NORTH WEST NORTH WEST +SCOTLAND SCOTLAND +SOUTH EAST SOUTH EAST +SOUTH WEST SOUTH WEST +WESTERN WESTERN +DROP TABLE t1; +CREATE TABLE t1 (id1 INT, id2 INT); +CREATE TABLE t2 (id2 INT, id3 INT, id5 INT); +CREATE TABLE t3 (id3 INT, id4 INT); +CREATE TABLE t4 (id4 INT); +CREATE TABLE t5 (id5 INT, id6 INT); +CREATE TABLE t6 (id6 INT); +INSERT INTO t1 VALUES(1,1); +INSERT INTO t2 VALUES(1,1,1); +INSERT INTO t3 VALUES(1,1); +INSERT INTO t4 VALUES(1); +INSERT INTO t5 VALUES(1,1); +INSERT INTO t6 VALUES(1); +SELECT * FROM +t1 +NATURAL JOIN +(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6) +ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5)); +id2 id1 id3 id5 id4 id3 id6 id5 +1 1 1 1 1 1 1 1 +SELECT * FROM +t1 +NATURAL JOIN +(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2 +ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5)); +id2 id1 id4 id3 id6 id5 id3 id5 +1 1 1 1 1 1 1 1 +SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2); +id2 id1 id3 id4 id6 id5 id3 id5 +1 1 1 1 1 1 1 1 +SELECT * FROM +(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6) +ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5)) +NATURAL JOIN +t1; +id2 id3 id5 id4 id3 id6 id5 id1 +1 1 1 1 1 1 1 1 +SELECT * FROM +(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6))) +NATURAL JOIN +t1; +id2 id3 id5 id4 id3 id6 id5 id1 +1 1 1 1 1 1 1 1 +DROP TABLE t1,t2,t3,t4,t5,t6; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)); +INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3); +INSERT INTO t1 VALUES (2,1),(2,2),(2,0),(2,3); +INSERT INTO t1 VALUES (3,1),(3,2),(3,0),(3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,b PRIMARY 8 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2)) group by `test`.`t1`.`a` +SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; +MAX(b) a +1 1 +SELECT MIN(b), a FROM t1 WHERE b > 1 AND a = 1 GROUP BY a; +MIN(b) a +2 1 +CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)); +INSERT INTO t2 SELECT a,b,b FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 12 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`c`) AS `MIN(c)` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`c` > 1)) group by `test`.`t2`.`a` +SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; +MIN(c) +2 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, INDEX (a,b)); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5), +(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6), +(5,1), (5,2), (5,3), (5,4), (5,5); +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +FLUSH STATUS; +SELECT max(b), a FROM t1 GROUP BY a; +max(b) a +5 1 +3 2 +1 3 +6 4 +5 5 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +FLUSH STATUS; +CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 24 +Handler_read_next 2 +FLUSH STATUS; +SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b; +max(b) a +5 1 +3 2 +1 3 +6 4 +5 5 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +FLUSH STATUS; +(SELECT max(b), a FROM t1 GROUP BY a) UNION +(SELECT max(b), a FROM t1 GROUP BY a); +max(b) a +5 1 +3 2 +1 3 +6 4 +5 5 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 20 +Handler_read_next 0 +EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION +(SELECT max(b), a FROM t1 GROUP BY a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +2 UNION t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` union /* select#2 */ select max(`test`.`t1`.`b`) AS `max(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` +EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1 AS t1_outer; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL index NULL a 10 NULL 20 100.00 Using index +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2)) AS `x` from `test`.`t1` `t1_outer` +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL index NULL a 10 NULL 20 100.00 Using index +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` where true +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` where false +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE +a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL index NULL a 10 NULL 20 100.00 Using where; Using index +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` where (`test`.`t1_outer`.`a`,`test`.`t1_outer`.`a` in ( (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2) ), (`test`.`t1_outer`.`a` in on where ((`test`.`t1_outer`.`a` = ``.`max(b)`))))) +EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING +a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer NULL range a a 5 NULL 11 100.00 Using index for group-by +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer` group by `test`.`t1_outer`.`a` having (`test`.`t1_outer`.`a` > (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2))) +EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 +ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) +AND t1_outer1.b = t1_outer2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer1 NULL ref a a 5 const 5 100.00 Using where; Using index +1 PRIMARY t1_outer2 NULL index NULL a 10 NULL 20 10.00 Using where; Using index; Using join buffer (hash join) +2 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `t1_outer1` join `test`.`t1` `t1_outer2` where ((`test`.`t1_outer2`.`b` = `test`.`t1_outer1`.`b`) and (`test`.`t1_outer1`.`a` = (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2)))) +EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_outer2 NULL index NULL a 10 NULL 20 100.00 Using index +2 SUBQUERY t1_outer NULL index NULL a 10 NULL 20 100.00 Using index +3 SUBQUERY t1 NULL range a a 5 NULL 11 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (/* select#2 */ select (/* select#3 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a` having (`test`.`t1`.`a` < 2)) AS `x` from `test`.`t1` `t1_outer`) AS `x2` from `test`.`t1` `t1_outer2` +CREATE TABLE t3 LIKE t1; +# Warm-up data-dictionary cache. +FLUSH STATUS; +INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +DELETE FROM t3; +FLUSH STATUS; +INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) +FROM t1 LIMIT 1; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 0 +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1) > 10000; +ERROR 21000: Subquery returns more than 1 row +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 10 +Handler_read_next 1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES +(4), (2), (1), (2), (4), (2), (1), (4), +(4), (2), (1), (2), (2), (4), (1), (4), +(4), (2), (1), (2), (2), (4), (1), (4); +EXPLAIN SELECT DISTINCT(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx idx 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT DISTINCT(a) FROM t1; +a +1 +2 +4 +EXPLAIN SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx idx 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1; +a +1 +2 +4 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3); +INSERT INTO t1 SELECT a + 1, b FROM t1; +INSERT INTO t1 SELECT a + 2, b FROM t1; +INSERT INTO t1 SELECT a + 4, b FROM t1; +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) +8 1 3 +7 1 3 +6 1 3 +5 1 3 +4 1 3 +3 1 3 +2 1 3 +1 1 3 +CREATE INDEX break_it ON t1 (a, b); +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range break_it break_it 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a` +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a; +a MIN(b) MAX(b) +1 1 3 +2 1 3 +3 1 3 +4 1 3 +5 1 3 +6 1 3 +7 1 3 +8 1 3 +EXPLAIN +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range break_it break_it 10 NULL 10 100.00 Using index for group-by; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) +8 1 3 +7 1 3 +6 1 3 +5 1 3 +4 1 3 +3 1 3 +2 1 3 +1 1 3 +EXPLAIN +SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index break_it break_it 10 NULL 24 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)`,max(`test`.`t1`.`b`) AS `MAX(b)`,avg(`test`.`t1`.`b`) AS `AVG(b)` from `test`.`t1` group by `test`.`t1`.`a` desc order by `test`.`t1`.`a` desc +SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; +a MIN(b) MAX(b) AVG(b) +8 1 3 2.0000 +7 1 3 2.0000 +6 1 3 2.0000 +5 1 3 2.0000 +4 1 3 2.0000 +3 1 3 2.0000 +2 1 3 2.0000 +1 1 3 2.0000 +DROP TABLE t1; +create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM; +insert into t1 (a,b) values +(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6), +(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(0,13), +(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6), +(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13), +(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6), +(2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13), +(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6), +(3,7),(3,8),(3,9),(3,10),(3,11),(3,12),(3,13); +insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a; +select * from t1; +a b +0 0 +0 1 +0 10 +0 11 +0 12 +0 13 +0 14 +0 2 +0 3 +0 4 +0 5 +0 6 +0 7 +0 8 +0 9 +1 0 +1 1 +1 10 +1 11 +1 12 +1 13 +1 2 +1 3 +1 4 +1 5 +1 6 +1 7 +1 8 +1 9 +2 0 +2 1 +2 10 +2 11 +2 12 +2 13 +2 2 +2 3 +2 4 +2 5 +2 6 +2 7 +2 8 +2 9 +3 0 +3 1 +3 10 +3 11 +3 12 +3 13 +3 2 +3 3 +3 4 +3 5 +3 6 +3 7 +3 8 +3 9 +explain select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,index index 4 NULL 3 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t1`.`a` AS `a`,(max(`test`.`t1`.`b`) + 1) AS `max(b)+1` from `test`.`t1` where (`test`.`t1`.`a` = 0) group by `test`.`t1`.`a` +drop table t1; +CREATE TABLE t1 (a int, b int, c int, d int, +KEY foo (c,d,a,b), KEY bar (c,a,b,d)); +INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT a,b,c+1,d FROM t1; +EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range foo,bar foo 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`d` = 4) +SELECT DISTINCT c FROM t1 WHERE d=4; +c +1 +2 +DROP TABLE t1; +# +# Bug #45386: Wrong query result with MIN function in field list, +# WHERE and GROUP BY clause +# +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; +INSERT INTO t SELECT * FROM t; +INSERT INTO t SELECT * FROM t; +# test MIN +#should use range with index for group by +EXPLAIN +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range a a 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)` from `test`.`t` where (`test`.`t`.`b` <> 0) group by `test`.`t`.`a` +#should return 1 row +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; +a MIN(b) +2 1 +# test MAX +#should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range a a 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`b` <> 1) group by `test`.`t`.`a` +#should return 1 row +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; +a MAX(b) +2 0 +# test 3 ranges and use the middle one +INSERT INTO t SELECT a, 2 FROM t; +#should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range a a 10 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where ((`test`.`t`.`b` > 0) and (`test`.`t`.`b` < 2)) group by `test`.`t`.`a` +#should return 1 row +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; +a MAX(b) +2 1 +DROP TABLE t; +# +# Bug #48472: Loose index scan inappropriately chosen for some WHERE +# conditions +# +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; +SELECT a, MAX(b) FROM t WHERE 0=b+0 GROUP BY a; +a MAX(b) +2 0 +DROP TABLE t; +End of 5.0 tests +# +# Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in +# server crash +# +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; +SELECT a, MAX(b) FROM t WHERE b GROUP BY a; +a MAX(b) +2 1 +DROP TABLE t; +CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)); +INSERT INTO t1 VALUES(1,1),(2,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b; +c b +1 1 +SELECT a FROM t1 WHERE b=1; +a +1 +2 +DROP TABLE t1; +# +# Bug#47762: Incorrect result from MIN() when WHERE tests NOT NULL column +# for NULL +# +## Test for NULLs allowed +CREATE TABLE t1 ( a INT, KEY (a) ); +INSERT INTO t1 VALUES (1), (2), (3); +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a > NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a > NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a < NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a < NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL No matching min/max row +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +x x x NULL x x x x x x 100.00 Using where; Using index +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL No matching min/max row +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +MIN( a ) +NULL +INSERT INTO t1 VALUES (NULL), (NULL); +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a > NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a > NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a < NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a < NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL Select tables optimized away +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <=> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +x x x NULL x x x x x x 100.00 Using where; Using index +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL Select tables optimized away +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +MIN( a ) +NULL +DROP TABLE t1; +## Test for NOT NULLs +CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2), (3); +# +# NULL-safe operator test disabled for non-NULL indexed columns. +# +# See bugs +# +# - Bug#52174: Sometimes wrong plan when reading a MAX value from +# non-NULL index +# +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a <> NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a > NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a > NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a < NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a < NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND 10; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN NULL AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a BETWEEN 10 AND NULL; +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL no matching row in const table +x x x NULL x x x x x x 100.00 Using where; Using index +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); +MIN( a ) +NULL +EXPLAIN +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL x x x x x x NULL Impossible WHERE +Warnings: +x x x +SELECT MIN( a ) FROM t1 WHERE a IS NULL; +MIN( a ) +NULL +DROP TABLE t1; +# +# Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List&, Item*) at +# opt_sum.cc:305 +# +CREATE TABLE t1 ( a INT, KEY (a) ); +INSERT INTO t1 VALUES (1), (2), (3); +SELECT MIN( a ) AS min_a +FROM t1 +WHERE a > 1 AND a IS NULL +ORDER BY min_a; +min_a +NULL +DROP TABLE t1; +End of 5.1 tests +# +# WL#3220 (Loose index scan for COUNT DISTINCT) +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY (a,b)); +INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1), (1,4,1); +INSERT INTO t1 SELECT a, b + 4, 1 FROM t1; +INSERT INTO t1 SELECT a + 1, b, 1 FROM t1; +INSERT INTO t1 SELECT a + 2, b + 8, 1 FROM t1; +CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c)); +INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1), +(1,4,1,1,1,1); +INSERT INTO t2 SELECT a, b + 4, c,d,e,f FROM t2; +INSERT INTO t2 SELECT a + 1, b, c,d,e,f FROM t2; +INSERT INTO t2 SELECT a + 2, b + 8, c,d,e,f FROM t2; +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` +SELECT COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`,`test`.`t1`.`b`) AS `COUNT(DISTINCT a,b)` from `test`.`t1` +SELECT COUNT(DISTINCT a,b) FROM t1; +COUNT(DISTINCT a,b) +32 +EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`,`test`.`t1`.`a`) AS `COUNT(DISTINCT b,a)` from `test`.`t1` +SELECT COUNT(DISTINCT b,a) FROM t1; +COUNT(DISTINCT b,a) +32 +EXPLAIN SELECT COUNT(DISTINCT b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` +SELECT COUNT(DISTINCT b) FROM t1; +COUNT(DISTINCT b) +16 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a; +COUNT(DISTINCT a) +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by `test`.`t1`.`a` +SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a; +COUNT(DISTINCT b) +8 +8 +8 +8 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 32 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` group by `test`.`t1`.`b` +SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b; +COUNT(DISTINCT a) +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` +SELECT DISTINCT COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL a 10 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`,(`test`.`t1`.`b` + 0)) AS `COUNT(DISTINCT a, b + 0)` from `test`.`t1` +SELECT COUNT(DISTINCT a, b + 0) FROM t1; +COUNT(DISTINCT a, b + 0) +32 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL a 10 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` having (count(distinct `test`.`t1`.`b`) < 20) +SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 20; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` having (count(distinct `test`.`t1`.`c`) < 10) +SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10; +COUNT(DISTINCT a) +4 +EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` having (count(distinct `test`.`t1`.`a`) < 10) +SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10; +1 +1 +EXPLAIN SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` group by `test`.`t1`.`a` having (count(distinct `test`.`t1`.`b`) > 1) +SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1; +1 +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index a a 10 NULL 32 100.00 Using index; Using temporary; Using filesort +1 SIMPLE t1_2 NULL index NULL a 10 NULL 32 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1_1.a)` from `test`.`t1` `t1_1` join `test`.`t1` `t1_2` group by `test`.`t1_1`.`a` +SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a; +COUNT(DISTINCT t1_1.a) +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)`,12 AS `12` from `test`.`t1` +SELECT COUNT(DISTINCT a), 12 FROM t1; +COUNT(DISTINCT a) 12 +4 12 +EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) AS `COUNT(DISTINCT a, b, c)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b, c) FROM t2; +COUNT(DISTINCT a, b, c) +32 +EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 5 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`) AS `COUNT(DISTINCT a)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t2`.`a`) AS `AVG(DISTINCT a)` from `test`.`t2` +SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2; +COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT a) +4 10 2.5000 +EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`) AS `COUNT(DISTINCT a)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t2`.`f`) AS `AVG(DISTINCT f)` from `test`.`t2` +SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2; +COUNT(DISTINCT a) SUM(DISTINCT a) AVG(DISTINCT f) +4 10 1.0000 +EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,count(distinct `test`.`t2`.`b`,`test`.`t2`.`a`) AS `COUNT(DISTINCT b, a)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2; +COUNT(DISTINCT a, b) COUNT(DISTINCT b, a) +32 32 +EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,count(distinct `test`.`t2`.`b`,`test`.`t2`.`f`) AS `COUNT(DISTINCT b, f)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2; +COUNT(DISTINCT a, b) COUNT(DISTINCT b, f) +32 16 +EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,count(distinct `test`.`t2`.`b`,`test`.`t2`.`d`) AS `COUNT(DISTINCT b, d)` from `test`.`t2` +SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2; +COUNT(DISTINCT a, b) COUNT(DISTINCT b, d) +32 16 +EXPLAIN SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,count(distinct `test`.`t2`.`c`,`test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT c, a, b)` from `test`.`t2` group by `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c` +SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c; +a c COUNT(DISTINCT c, a, b) +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +1 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +3 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +4 1 1 +EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2 +WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 5 NULL 1 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`c`,`test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT c, a, b)` from `test`.`t2` where ((`test`.`t2`.`a` > 5) and (`test`.`t2`.`b` between 10 and 20)) group by `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c` +SELECT COUNT(DISTINCT c, a, b) FROM t2 +WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c; +COUNT(DISTINCT c, a, b) +EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5 +GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref a a 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`b`) AS `COUNT(DISTINCT b)`,sum(distinct `test`.`t2`.`b`) AS `SUM(DISTINCT b)` from `test`.`t2` where (`test`.`t2`.`a` = 5) group by `test`.`t2`.`b` +SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5 +GROUP BY b; +COUNT(DISTINCT b) SUM(DISTINCT b) +EXPLAIN SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(distinct `test`.`t2`.`b`) AS `COUNT(DISTINCT b)`,sum(distinct `test`.`t2`.`b`) AS `SUM(DISTINCT b)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +a COUNT(DISTINCT b) SUM(DISTINCT b) +1 8 36 +2 8 36 +3 8 100 +4 8 100 +EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`b`) AS `COUNT(DISTINCT b)`,sum(distinct `test`.`t2`.`b`) AS `SUM(DISTINCT b)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a; +COUNT(DISTINCT b) SUM(DISTINCT b) +8 36 +8 36 +8 100 +8 100 +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL a NULL NULL NULL 32 3.12 Using where +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t2` where ((`test`.`t2`.`d` = 42) and (`test`.`t2`.`c` = 13)) +SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42; +COUNT(DISTINCT a, b) +0 +EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 +WHERE b = 13 AND c = 42 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(distinct `test`.`t2`.`a`) AS `COUNT(DISTINCT a)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)` from `test`.`t2` where ((`test`.`t2`.`c` = 42) and (`test`.`t2`.`b` = 13)) group by `test`.`t2`.`a` +SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 +WHERE b = 13 AND c = 42 GROUP BY a; +a COUNT(DISTINCT a) SUM(DISTINCT a) +# This query could have been resolved using loose index scan since +# the second part of count(..) is defined by a constant predicate +EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL a 15 NULL 32 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a`,`test`.`t2`.`b`) AS `COUNT(DISTINCT a, b)`,sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)` from `test`.`t2` where (`test`.`t2`.`b` = 42) +SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; +COUNT(DISTINCT a, b) SUM(DISTINCT a) +0 NULL +EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 15 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t2`.`a`) AS `SUM(DISTINCT a)`,max(`test`.`t2`.`b`) AS `MAX(b)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a; +SUM(DISTINCT a) MAX(b) +1 8 +2 8 +3 16 +4 16 +EXPLAIN SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 15 NULL 10 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select (42 * ((`test`.`t2`.`a` + `test`.`t2`.`c`) + count(distinct `test`.`t2`.`c`,`test`.`t2`.`a`,`test`.`t2`.`b`))) AS `42 * (a + c + COUNT(DISTINCT c, a, b))` from `test`.`t2` group by `test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c` +SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c; +42 * (a + c + COUNT(DISTINCT c, a, b)) +126 +126 +126 +126 +126 +126 +126 +126 +168 +168 +168 +168 +168 +168 +168 +168 +210 +210 +210 +210 +210 +210 +210 +210 +252 +252 +252 +252 +252 +252 +252 +252 +EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 15 NULL 32 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (sum(distinct `test`.`t2`.`a`) + max(`test`.`t2`.`b`)) AS `(SUM(DISTINCT a) + MAX(b))` from `test`.`t2` group by `test`.`t2`.`a` +SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a; +(SUM(DISTINCT a) + MAX(b)) +9 +10 +19 +20 +DROP TABLE t1,t2; +# end of WL#3220 tests +# +# Bug#50539: Wrong result when loose index scan is used for an aggregate +# function with distinct +# +CREATE TABLE t1 ( +f1 int(11) NOT NULL DEFAULT '0', +f2 char(1) NOT NULL DEFAULT '', +PRIMARY KEY (f1,f2) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'), +(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D'); +SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; +f1 COUNT(DISTINCT f2) +1 3 +2 1 +3 4 +explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL 9 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,count(distinct `test`.`t1`.`f2`) AS `COUNT(DISTINCT f2)` from `test`.`t1` group by `test`.`t1`.`f1` +drop table t1; +# End of test#50539. +# +# Bug#18497308 WRONG COST ESTIMATE FOR LOOSE INDEX SCAN WHEN +# INDEX STATISTICS IS MISSING +# +CREATE TABLE t1 ( +a INTEGER, +b INTEGER, +c INTEGER, +d INTEGER, +KEY foo (a,b,c,d) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 2, 1, 2), (1, 3, 1, 3), (1, 4, 1, 4); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +EXPLAIN SELECT DISTINCT a FROM t1 WHERE b=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range foo foo 10 NULL 101 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 4) +SELECT DISTINCT a FROM t1 WHERE b=4; +a +1 +DROP TABLE t1; +# +# Bug#17217128 - BAD INTERACTION BETWEEN MIN/MAX AND +# "HAVING SUM(DISTINCT)": WRONG RESULTS. +# +CREATE TABLE t (a INT, b INT, KEY(a,b)); +INSERT INTO t VALUES (1,1), (2,2), (3,3), (4,4), (1,0), (3,2), (4,5); +set optimizer_trace_max_mem_size=1048576; +set @@session.optimizer_trace='enabled=on'; +set end_markers_in_json=on; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a; +a SUM(DISTINCT a) MIN(b) +1 1 0 +2 2 2 +3 3 2 +4 4 4 +EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b) FROM t GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,min(`test`.`t`.`b`) AS `MIN(b)` from `test`.`t` group by `test`.`t`.`a` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a; +a SUM(DISTINCT a) MAX(b) +1 1 1 +2 2 2 +3 3 3 +4 4 5 +EXPLAIN SELECT a, SUM(DISTINCT a), MAX(b) FROM t GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` group by `test`.`t`.`a` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a); +a MAX(b) +1 1 +2 2 +3 3 +4 5 +EXPLAIN SELECT a, MAX(b) FROM t GROUP BY a HAVING SUM(DISTINCT a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` group by `test`.`t`.`a` having (0 <> sum(distinct `test`.`t`.`a`)) +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t; +SUM(DISTINCT a) MIN(b) MAX(b) +10 0 5 +EXPLAIN SELECT SUM(DISTINCT a), MIN(b), MAX(b) FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a; +a SUM(DISTINCT a) MIN(b) MAX(b) +1 1 0 1 +2 2 2 2 +3 3 2 3 +4 4 4 5 +EXPLAIN SELECT a, SUM(DISTINCT a), MIN(b), MAX(b) FROM t GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index a a 10 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` group by `test`.`t`.`a` +SELECT TRACE RLIKE 'have_both_agg_distinct_and_min_max' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace_max_mem_size=DEFAULT; +SET optimizer_trace=DEFAULT; +SET end_markers_in_json=DEFAULT; +DROP TABLE t; +# +# Bug #18066518: THE COST VALUE IS A NEGATIVE NUMBER FOR MERGE ENGINE +# TABLE +# +CREATE TABLE t(a INT PRIMARY KEY) +ENGINE = MERGE; +EXPLAIN SELECT DISTINCT(a) FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index PRIMARY PRIMARY 4 NULL 0 0.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` +SELECT DISTINCT(a) FROM t; +a +DROP TABLE t; +# End of test#18066518. +# +# Bug #18486293: ASSERTION FAILED: KEYS >= 0.0 IN +# COST_MODEL_TABLE::KEY_COMPARE_COST +# +CREATE TABLE t (b INT, KEY b_key (b)) ENGINE=INNODB +PARTITION BY RANGE COLUMNS(b) (PARTITION p_part VALUES LESS THAN (0)); +SELECT 1 FROM t WHERE b IN ('') GROUP BY b ; +1 +DROP TABLE t; +# End of test#18486293. +# +# Bug#18109609: LOOSE INDEX SCAN IS NOT USED WHEN IT SHOULD +# +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT, +c2 INT, +KEY(c1,c2)); +INSERT INTO t1(c1,c2) VALUES +(1, 1), (1,2), (2,1), (2,2), (3,1), (3,2), (3,3), (4,1), (4,2), (4,3), +(4,4), (4,5), (4,6), (4,7), (4,8), (4,9), (4,10), (4,11), (4,12), (4,13), +(4,14), (4,15), (4,16), (4,17), (4,18), (4,19), (4,20),(5,5); +EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range c1 c1 5 NULL 7 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`c2`) AS `MAX(c2)`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = 4) group by `test`.`t1`.`c1` +FLUSH STATUS; +SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; +MAX(c2) c1 +20 4 +SHOW SESSION STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1; +# End of test for Bug#18109609 +# +# Bug#22661012 - "USING INDEX FOR GROUP-BY" QUERIES CAN RETURN +# NO DATA WITH LE/LEQ AND ROUNDING +# +CREATE TABLE t1 (a INT, b INT, KEY(a,b)); +INSERT INTO t1 VALUES (1,1000), (1,1001), (1,2000), +(1,2001), (1,3000), (1,3002); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b < 1999.5 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2000)) group by `test`.`t1`.`a` +SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b < 1999.5 GROUP BY a; +a MAX(b) +1 1001 +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b <= 1999.5 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2000)) group by `test`.`t1`.`a` +SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b <= 1999.5 GROUP BY a; +a MAX(b) +1 1001 +EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b between 0 and 1999.5 +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `MAX(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` between 0 and 1999.5)) group by `test`.`t1`.`a` +SELECT a, MAX(b) FROM t1 WHERE a = 1 AND b between 0 and 1999.5 +GROUP BY a; +a MAX(b) +1 1001 +EXPLAIN SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b > 2000.1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` > 2000)) group by `test`.`t1`.`a` +SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b > 2000.1 GROUP BY a; +a MIN(b) +1 2001 +EXPLAIN SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b >= 2000.1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,min(`test`.`t1`.`b`) AS `MIN(b)` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` > 2000)) group by `test`.`t1`.`a` +SELECT a, MIN(b) FROM t1 WHERE a = 1 AND b >= 2000.1 GROUP BY a; +a MIN(b) +1 2001 +DROP TABLE t1; +# End of test for Bug#22661012 +# +# Bug#24484060 INCORRECT EVALUATION OF MIN/MAX REFERRING +# TO AN OUTER QUERY BLOCK +# +CREATE TABLE t1 (pk INT PRIMARY KEY, nk INT, k INT UNIQUE); +INSERT INTO t1 VALUES (1,1,1),(2,2,2),(4,4,4); +CREATE TABLE t2 (k INT); +INSERT INTO t2 VALUES (1),(2),(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk<>3 AND out1.nk = (SELECT MAX(out1.k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref PRIMARY,k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` <> 3) and (`test`.`out1`.`nk` = (/* select#2 */ select max(`test`.`out1`.`k`) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk<>3 AND out1.nk = (SELECT MAX(out1.k) FROM t1); +k +1 +2 +4 +# Repeat the test with PRIMARY KEY instead of the non-indexed column. +ALTER TABLE t1 DROP COLUMN nk; +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(out1.k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select max(`test`.`out1`.`k`) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(out1.k) FROM t1); +k +1 +2 +4 +# Inner reference should be optimized. +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY out1 NULL const PRIMARY,k PRIMARY 4 const 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`t2`.`k` = '4')) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MAX(k) FROM t1); +k +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT 2*MIN(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY out1 NULL const PRIMARY,k PRIMARY 4 const 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`t2`.`k` = '2')) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT 2*MIN(k) FROM t1); +k +2 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(k) - COUNT(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY out1 NULL const PRIMARY,k PRIMARY 4 const 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`t2`.`k` = '4') and ('4' = (/* select#2 */ select (sum(`test`.`t1`.`k`) - count(`test`.`t1`.`k`)) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(k) - COUNT(k) FROM t1); +k +4 +# Combinations of outer and inner references should not be optimized. +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k + k) - 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select (min((`test`.`out1`.`k` + `test`.`t1`.`k`)) - 1) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k + k) - 1 FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT out1.k + MIN(k) - 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select ((`test`.`out1`.`k` + min(`test`.`t1`.`k`)) - 1) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT out1.k + MIN(k) - 1 FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k) + MIN(k) - 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select ((min(`test`.`out1`.`k`) + min(`test`.`t1`.`k`)) - 1) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT MIN(out1.k) + MIN(k) - 1 FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL k 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select (sum(`test`.`out1`.`k`) / count(`test`.`t1`.`k`)) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(k) FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(*) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select (sum(`test`.`out1`.`k`) / count(0)) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT SUM(out1.k) / COUNT(*) FROM t1); +k +1 +2 +4 +explain SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT AVG(out1.k) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY out1 NULL eq_ref k k 5 test.t2.k 1 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.out1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`k` AS `k` from `test`.`t1` `out1` join `test`.`t2` where ((`test`.`out1`.`k` = `test`.`t2`.`k`) and (`test`.`out1`.`pk` = (/* select#2 */ select avg(`test`.`out1`.`k`) from `test`.`t1`))) +SELECT t2.k FROM t1 out1, t2 WHERE t2.k = out1.k +AND out1.pk = (SELECT AVG(out1.k) FROM t1); +k +1 +2 +4 +DROP TABLE t1, t2; +# End of test for Bug#24484060 +# +# Bug#24657798 HANDLER::HA_INDEX_INIT() TRIES TO USE +# AN UNLOCKED CONST TABLE IN OPT_SUM_QUERY() +# +CREATE TABLE t1 (k INT, KEY(k)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (h INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (3); +explain SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `k` from dual where true +SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +k +1 +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +k +1 +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +k +1 +UPDATE t1 SET k=0; +explain SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `k` from dual where (0 <> (/* select#2 */ select min('0') from dual)) +SELECT * FROM t1 WHERE (SELECT MIN(t1.k) FROM t2); +k +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t1 s1); +k +0 +explain SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `k` from dual where true +SELECT * FROM t1 WHERE EXISTS (SELECT MIN(t1.k) FROM t2); +k +0 +DROP TABLE t1; +CREATE TABLE t1 (nk INT, k INT, KEY(k)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1); +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `nk`,'1' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +nk k +1 1 +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '1' AS `nk`,'1' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +nk k +1 1 +UPDATE t1 SET nk=0, k=0; +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY s1 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `nk`,'0' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t1 s1); +nk k +0 0 +explain SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '0' AS `nk`,'0' AS `k` from dual where true +SELECT * FROM t1 WHERE nk = (SELECT MIN(t1.k) FROM t2); +nk k +0 0 +DROP TABLE t1; +DROP TABLE t2; +# End of test for Bug#24657798 +# +# Bug#24423143 - WRONG RESULTS FOR AGGREGATE QUERY +# +# Test index merge tree scenario +CREATE TABLE a ( +aggr_col int, +group_by_col int, +KEY aggr_col_key (aggr_col), +KEY group_by_col_key (group_by_col, aggr_col) +) ENGINE=InnoDB; +set optimizer_trace_max_mem_size=1048576; +set @@session.optimizer_trace='enabled=on'; +set end_markers_in_json=on; +INSERT INTO a VALUES (2,3),(5,6),(6,3),(7,NULL),(9,NULL),(10,6); +ANALYZE TABLE a; +Table Op Msg_type Msg_text +test.a analyze status OK +SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col > 2) GROUP BY group_by_col; +group_by_col MIN(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70 ,9)) OR (aggr_col > 2) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index aggr_col_key,group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` > 2)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'disjuntive_predicate_present' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col < 9) GROUP BY group_by_col; +group_by_col MAX(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70 , 9)) OR (aggr_col < 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index aggr_col_key,group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` < 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'disjuntive_predicate_present' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Test IMPOSSIBLE TREE scenario +ALTER TABLE a DROP KEY aggr_col_key; +SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70 ,9)) OR (aggr_col > 2) GROUP BY group_by_col; +group_by_col MIN(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MIN(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col > 2) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` > 2)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col < 9) GROUP BY group_by_col; +group_by_col MAX(aggr_col) +NULL 7 +3 6 +6 5 +EXPLAIN SELECT group_by_col, MAX(aggr_col) FROM a +WHERE (group_by_col IN (70, 9)) OR (aggr_col < 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (70,9)) or (`test`.`a`.`aggr_col` < 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 3: aggregate field used as equal expression. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col IN (3, 9)) OR (aggr_col = 9) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 9 9 +3 2 6 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col IN (3, 9)) OR (aggr_col = 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 44.44 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 44.44 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` in (3,9)) or (`test`.`a`.`aggr_col` = 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 4: non aggregate field used as equal expression. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col = 3) OR (aggr_col > 8) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 9 9 +3 2 6 +6 10 10 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col = 3) OR (aggr_col > 8) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 55.55 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 6 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` = 3) or (`test`.`a`.`aggr_col` > 8)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 5: aggregate field used as non-zero expression. +INSERT INTO a VALUES(0, 3); +INSERT INTO a VALUES(0, 9); +INSERT INTO a VALUES(8, 0); +ANALYZE TABLE a; +Table Op Msg_type Msg_text +test.a analyze status OK +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE (group_by_col = 9) OR aggr_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 7 9 +0 8 8 +3 2 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col = 9 OR aggr_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 91.11 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 9 91.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`group_by_col` = 9) or (0 <> `test`.`a`.`aggr_col`)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 6: non aggregate field used as non-zero expression. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (aggr_col < 9) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 7 7 +0 8 8 +3 0 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (aggr_col < 9) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 92.59 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 9 92.59 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`group_by_col`) or (`test`.`a`.`aggr_col` < 9)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 7: aggregate field used in equal exp without a CONST +INSERT INTO a VALUES(1,1),(1,2),(2,1); +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col = group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +1 1 1 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col = group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 12 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where (`test`.`a`.`group_by_col` = `test`.`a`.`aggr_col`) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 8: aggregate field used in a non-eq exp without a CONST +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col < group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +2 1 1 +3 0 2 +6 5 5 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col < group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 33.33 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 12 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where (`test`.`a`.`aggr_col` < `test`.`a`.`group_by_col`) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 8 +INSERT INTO a VALUES(0,1),(1,0),(0,0); +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col OR group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +NULL 7 9 +0 1 8 +1 0 2 +2 1 1 +3 0 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col OR group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 99.00 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 15 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`aggr_col`) or (0 <> `test`.`a`.`group_by_col`)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +# Scenario 9 +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col AND group_by_col GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +1 1 2 +2 1 1 +3 2 6 +6 5 10 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col AND group_by_col GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL range group_by_col_key group_by_col_key 10 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`aggr_col`) and (0 <> `test`.`a`.`group_by_col`)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +# Scenario 10: Added for completion. This fix does not have an impact. +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col<>0 AND group_by_col<>0 GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +1 1 2 +2 1 1 +3 2 6 +6 5 10 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE aggr_col<>0 AND group_by_col<>0 GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL range group_by_col_key group_by_col_key 10 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((`test`.`a`.`aggr_col` <> 0) and (`test`.`a`.`group_by_col` <> 0)) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +# Scenario 11: ITEM_FUNC as an argument of ITEM_FUNC +SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (group_by_col < (aggr_col = 1)) GROUP BY group_by_col; +group_by_col MIN(aggr_col) MAX(aggr_col) +0 1 1 +1 0 2 +2 1 1 +3 0 6 +6 5 10 +9 0 0 +EXPLAIN SELECT group_by_col, MIN(aggr_col), MAX(aggr_col) FROM a +WHERE group_by_col OR (group_by_col < (aggr_col = 1)) GROUP BY group_by_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 93.33 Parallel execute (1 workers) +2 SIMPLE a NULL index group_by_col_key group_by_col_key 10 NULL 15 93.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`group_by_col` AS `group_by_col`,min(`test`.`a`.`aggr_col`) AS `MIN(aggr_col)`,max(`test`.`a`.`aggr_col`) AS `MAX(aggr_col)` from `test`.`a` where ((0 <> `test`.`a`.`group_by_col`) or (`test`.`a`.`group_by_col` < (`test`.`a`.`aggr_col` = 1))) group by `test`.`a`.`group_by_col` +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' AS OK +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace_max_mem_size=DEFAULT; +SET optimizer_trace=DEFAULT; +SET end_markers_in_json=DEFAULT; +DROP TABLE a; +# End of test for Bug#24423143 +# +# Bug #31475700 REGRESSION: MEMORY LEAK AFTER +# ITEM_SUM_HYBRID::MIN_MAX_UPDATE_STR_FIELD +# +CREATE TABLE t(a TEXT); +INSERT t VALUES('a'),('a'); +SELECT a, MAX(TRIM('1' FROM ~1)) FROM t GROUP BY a; +a MAX(TRIM('1' FROM ~1)) +a 8446744073709551614 +DROP TABLE t; +# +# Bug#30242457 ASSERTION "!TABLE->CONST_TABLE" +# +CREATE TABLE t2(id1 INT, id2 CHAR (1), id3 INT, value INT, +KEY (id1,id2,id3)) COLLATE LATIN1_BIN; +CREATE TABLE t1(a INT,b INT, PRIMARY KEY(a)) ENGINE=MEMORY; +# One row in an in-memory table: row will be read before +# optimizing MAX in subquery. No result set, either when t2 is +# empty or not, since t1.a <> t1.b +INSERT INTO t1 VALUES(1,0); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +INSERT INTO t2 VALUES (0, 'a', 3, 4); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +EXPLAIN FORMAT=TREE SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +EXPLAIN +-> Zero rows (Impossible WHERE noticed after reading const tables) (cost=0.00..0.00 rows=0) + +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +DELETE FROM t1; +DELETE FROM t2; +# Now t1.a = t1.b, still not result if t2 is empty +INSERT INTO t1 VALUES(1,1); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +# If t2 has at least one row, we will get a result row +INSERT INTO t2 VALUES (0, 'a', 3, 4); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +1 1 +EXPLAIN FORMAT=TREE SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +EXPLAIN +-> Rows fetched before execution (cost=0.00..0.00 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +# If we have two rows in t1, t1 will not be read before +# optimization of the subquery, so this didn't use to fail +# before this patch. +INSERT INTO t1 VALUES(0,0); +SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +a b +1 1 +0 0 +EXPLAIN FORMAT=TREE SELECT * FROM t1 WHERE t1.a IN (SELECT MAX(t1.b) FROM t2); +EXPLAIN +-> Filter: (t1.a,(select #2)) (cost=2.73 rows=2) + -> Table scan on t1 (cost=2.73 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) + -> Filter: ((t1.a) = (max(t1.b))) + -> Aggregate: max(t1.b) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1, t2; +# End of test for Bug#30242457 diff --git a/mysql-test/r/group_min_max_ext.result-pq b/mysql-test/r/group_min_max_ext.result-pq new file mode 100644 index 000000000..0a758e998 --- /dev/null +++ b/mysql-test/r/group_min_max_ext.result-pq @@ -0,0 +1,4112 @@ +CREATE TABLE t (a INT, b INT, c INT, d INT, KEY k1(a, b, c, d)) ENGINE=innodb; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 113 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 65 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 34 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 28 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 31 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 6.53 Parallel execute (1 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 4 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 283 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 398 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 155 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 186 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 81 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 86 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 47 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 75 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 9 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +ALTER TABLE t ADD KEY k2(a DESC, b, c DESC, d); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT a, b, MIN(d) FROM t +WHERE (a > 4) AND (c = 3 or c = 40) AND (d > 7) GROUP BY a, b; +a b MIN(d) +10 1 8 +10 2 8 +10 3 8 +10 4 8 +10 5 8 +11 3 20 +11 NULL 30 +5 1 8 +5 2 8 +5 3 8 +5 4 8 +5 5 8 +6 1 8 +6 2 8 +6 3 8 +6 4 8 +6 5 8 +7 1 8 +7 2 8 +7 3 8 +7 4 8 +7 5 8 +8 1 8 +8 2 8 +8 3 8 +8 4 8 +8 5 8 +9 1 8 +9 2 8 +9 3 8 +9 4 8 +9 5 8 +SELECT a, b, MIN(d) FROM t +WHERE (a > 4) AND (c = 3 or c = 40) AND (d > 7) GROUP BY a, b; +a b MIN(d) +10 1 8 +10 2 8 +10 3 8 +10 4 8 +10 5 8 +11 3 20 +11 NULL 30 +5 1 8 +5 2 8 +5 3 8 +5 4 8 +5 5 8 +6 1 8 +6 2 8 +6 3 8 +6 4 8 +6 5 8 +7 1 8 +7 2 8 +7 3 8 +7 4 8 +7 5 8 +8 1 8 +8 2 8 +8 3 8 +8 4 8 +8 5 8 +9 1 8 +9 2 8 +9 3 8 +9 4 8 +9 5 8 +ALTER TABLE t DROP KEY k2; +EXPLAIN SELECT a, b FROM t WHERE (a > 4) AND (c = 3 OR c > 6) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1508 40.00 Parallel execute (4 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 1508 40.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where ((`test`.`t`.`a` > 4) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` > 6))) group by `test`.`t`.`a`,`test`.`t`.`b` +EXPLAIN SELECT a, b FROM t WHERE (a > 4) AND (c = 3 OR c = 40) AND +(d = -1 OR d = -2 OR d > 7) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1508 8.74 Parallel execute (4 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 1508 8.74 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where ((`test`.`t`.`a` > 4) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = (-(1))) or (`test`.`t`.`d` = (-(2))) or (`test`.`t`.`d` > 7))) group by `test`.`t`.`a`,`test`.`t`.`b` +ALTER TABLE t DROP KEY k1; +ALTER TABLE t ADD KEY k1(a, b, c, d DESC); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 6 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` > 9)) group by `test`.`t`.`a`,`test`.`t`.`b` +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +12 2 NULL +12 15 -15 +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 6 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` > 9)) group by `test`.`t`.`a`,`test`.`t`.`b` +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3) GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 10 +10 2 1 10 +10 3 1 10 +10 4 1 10 +10 5 1 10 +11 2 -10 -10 +11 3 20 20 +12 2 NULL NULL +12 15 -15 -15 +ALTER TABLE t DROP KEY k1; +ALTER TABLE t ADD KEY k1(a DESC, b, c DESC, d); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 113 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 64 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 37 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 34 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 28 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 31 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 37 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 37 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 6.53 Parallel execute (1 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 4 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 284 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 399 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 156 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 186 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 82 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 87 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 82 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 47 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +ALTER TABLE t DROP KEY k1; +ALTER TABLE t ADD KEY k1(a, b DESC, c, d DESC); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 113 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 78 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 65 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 77 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 48 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 5 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 34 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 8 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 28 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 31 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 48 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 48 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 6.53 Parallel execute (1 workers) +2 SIMPLE t NULL range k1 k1 5 NULL 4 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 228 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 114 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 287 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 156 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 58 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 186 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 85 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 47 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 9 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +DROP TABLE t; +CREATE TABLE t (a INT, b INT, c INT, d INT, KEY k1(a, b, c, d)) ENGINE=myisam; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 20 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 111 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` is null))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c IS NULL) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -20 +12 -15 -15 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 75 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 15) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +11 30 30 +12 -15 -20 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 63 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` is null) or (`test`.`t`.`b` = 2)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (b IS NULL OR b = 2) AND (c = 3 OR c = 40) GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 30 -10 +12 -23 -23 +2 10 1 +3 10 1 +4 10 1 +5 10 1 +6 10 1 +7 10 1 +8 10 1 +9 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 75 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 78 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) GROUP BY a; +a +1 +10 +11 +12 +2 +3 +4 +5 +6 +7 +8 +9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 24 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40) GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +10 2 10 1 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +3 2 10 1 +4 2 10 1 +5 2 10 1 +6 2 10 1 +7 2 10 1 +8 2 10 1 +9 2 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 226 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15) or (`test`.`t`.`b` = 3)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (b = 2 OR b = 15 OR b = 3) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +1 3 10 1 +10 2 10 1 +10 3 10 1 +11 2 -10 -10 +11 3 20 20 +12 15 -15 -20 +12 2 -23 -23 +2 2 10 1 +2 3 10 1 +3 2 10 1 +3 3 10 1 +4 2 10 1 +4 3 10 1 +5 2 10 1 +5 3 10 1 +6 2 10 1 +6 3 10 1 +7 2 10 1 +7 3 10 1 +8 2 10 1 +8 3 10 1 +9 2 10 1 +9 3 10 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 226 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE a = 1 AND (b = 2 OR b = 15); +a +1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` = 1) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE a = 1 AND (c = 3 OR c = 40) AND (d = 1 OR d = 9) +GROUP BY a, b; +a MAX(d) MIN(d) +1 9 1 +1 9 1 +1 9 1 +1 9 1 +1 9 1 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 26 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 19 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` < 2) or (`test`.`t`.`a` > 11)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a < 2 OR a > 11) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 2 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 33 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT DISTINCT a, b FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +a b +1 2 +12 15 +12 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 10 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`a` AS `a` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15))) +FLUSH STATUS; +SELECT DISTINCT a FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15); +a +1 +12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` < 4) or (`test`.`t`.`b` > 10)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a = 12) AND (b < 4 OR b > 10) AND (c = 3 OR c = 40) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 1 +1 2 10 1 +1 3 10 1 +12 15 -15 -20 +12 2 -23 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 27 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 8 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` > 9)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a = 1 OR a > 9) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40) +GROUP BY a; +a MAX(d) MIN(d) +1 10 1 +10 10 1 +11 -10 -10 +12 -15 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 30 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 2 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a, b)` from `test`.`t` where (((`test`.`t`.`a` = 1) or (`test`.`t`.`a` = 12)) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT COUNT(DISTINCT a, b) FROM t WHERE (a = 1 OR a = 12) AND (b = 2 OR b = 15) AND (c = 3 OR c = 40); +COUNT(DISTINCT a, b) +3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 10 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) +78 6.5000 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 24 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 15 NULL 52 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t`.`a`) AS `SUM(DISTINCT a)`,avg(distinct `test`.`t`.`a`) AS `AVG(DISTINCT a)`,count(distinct `test`.`t`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t` where (((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40))) +FLUSH STATUS; +SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t WHERE (b = 2 OR b = 15) AND (c = 3 OR c = 40); +SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a) +78 6.5000 12 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 24 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 5 NULL 13 6.53 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 11) and ((`test`.`t`.`b` = 2) or (`test`.`t`.`b` = 15)) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 1) or (`test`.`t`.`c` = 2) or (`test`.`t`.`c` = 4))) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MAX(d), MIN(d) FROM t WHERE (a > 11) AND (b = 2 OR b = 15) AND +(c = 3 OR c = 1 OR c = 2 OR c = 4) +GROUP BY a; +a MAX(d) MIN(d) +12 -15 -15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 4 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2) GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 281 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 112 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where (((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` > 7) or (`test`.`t`.`d` = 2) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (c = 3 OR c = 40) AND (d > 7 OR d =2 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +1 1 10 2 +1 2 10 2 +1 3 10 2 +1 4 10 2 +1 5 10 2 +10 1 10 2 +10 2 10 2 +10 3 10 2 +10 4 10 2 +10 5 10 2 +11 3 20 20 +11 NULL 30 30 +12 2 NULL NULL +2 1 10 2 +2 2 10 2 +2 3 10 2 +2 4 10 2 +2 5 10 2 +3 1 10 2 +3 2 10 2 +3 3 10 2 +3 4 10 2 +3 5 10 2 +4 1 10 2 +4 2 10 2 +4 3 10 2 +4 4 10 2 +4 5 10 2 +5 1 10 2 +5 2 10 2 +5 3 10 2 +5 4 10 2 +5 5 10 2 +6 1 10 2 +6 2 10 2 +6 3 10 2 +6 4 10 2 +6 5 10 2 +7 1 10 2 +7 2 10 2 +7 3 10 2 +7 4 10 2 +7 5 10 2 +8 1 10 2 +8 2 10 2 +8 3 10 2 +8 4 10 2 +8 5 10 2 +9 1 10 2 +9 2 10 2 +9 3 10 2 +9 4 10 2 +9 5 10 2 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 396 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 56 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < (-(24))) or (`test`.`t`.`d` = 3) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND +(d < -24 OR d = 3 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 3 +10 2 3 +10 3 3 +10 4 3 +10 5 3 +12 2 NULL +6 1 3 +6 2 3 +6 3 3 +6 4 3 +6 5 3 +7 1 3 +7 2 3 +7 3 3 +7 4 3 +7 5 3 +8 1 3 +8 2 3 +8 3 3 +8 4 3 +8 5 3 +9 1 3 +9 2 3 +9 3 3 +9 4 3 +9 5 3 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 154 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 56 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 5) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 1) or (`test`.`t`.`d` = 9))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 5) AND (c = 3 OR c = 40) AND (d < 1 OR d = 9) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +11 2 -10 -10 +12 15 -15 -20 +12 2 -23 -23 +6 1 9 9 +6 2 9 9 +6 3 9 9 +6 4 9 9 +6 5 9 9 +7 1 9 9 +7 2 9 9 +7 3 9 9 +7 4 9 9 +7 5 9 9 +8 1 9 9 +8 2 9 9 +8 3 9 9 +8 4 9 9 +8 5 9 9 +9 1 9 9 +9 2 9 9 +9 3 9 9 +9 4 9 9 +9 5 9 9 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 185 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `MAX(d)`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 1) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MAX(d), MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 1 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MAX(d) MIN(d) +10 1 9 1 +10 2 9 1 +10 3 9 1 +10 4 9 1 +10 5 9 1 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 80 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` = 0) or (`test`.`t`.`d` = 9) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d = 0 OR d = 9 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 9 9 +10 2 9 9 +10 3 9 9 +10 4 9 9 +10 5 9 9 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 85 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)`,max(`test`.`t`.`d`) AS `MAX(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and (((`test`.`t`.`d` > 0) and (`test`.`t`.`d` < 2)) or ((`test`.`t`.`d` > 3) and (`test`.`t`.`d` < 5)) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d), MAX(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d > 0 AND d < 2 OR d > 3 AND d < 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) MAX(d) +10 1 1 4 +10 2 1 4 +10 3 1 4 +10 4 1 4 +10 5 1 4 +12 2 NULL NULL + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 79 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `MIN(d)` from `test`.`t` where ((`test`.`t`.`a` > 9) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` < 2) or (`test`.`t`.`d` > 5) or (`test`.`t`.`d` is null))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b, MIN(d) FROM t WHERE (a > 9) AND (c = 3 OR c = 40) AND +(d < 2 OR d > 5 OR d IS NULL) +GROUP BY a, b; +a b MIN(d) +10 1 1 +10 2 1 +10 3 1 +10 4 1 +10 5 1 +11 2 -10 +11 3 20 +11 NULL 30 +12 15 -20 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 46 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,max(`test`.`t`.`d`) AS `max(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , max(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b max(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 74 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 20 NULL 12 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,min(`test`.`t`.`d`) AS `min(d)` from `test`.`t` where ((`test`.`t`.`a` >= 10) and ((`test`.`t`.`c` = 3) or (`test`.`t`.`c` = 40)) and ((`test`.`t`.`d` is null) or (`test`.`t`.`d` = (-(10))) or (`test`.`t`.`d` = (-(23))))) group by `test`.`t`.`a`,`test`.`t`.`b` +FLUSH STATUS; +SELECT a, b , min(d) FROM t WHERE (a >= 10) AND (c = 3 or c=40) AND +(d is NULL or d = -10 or d = -23) +GROUP BY a, b; +a b min(d) +11 2 -10 +12 2 -23 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 76 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +EXPLAIN SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k1 k1 10 NULL 1 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,min(`test`.`t`.`b`) AS `MIN(b)`,max(`test`.`t`.`b`) AS `MAX(b)` from `test`.`t` where (`test`.`t`.`a` > 9) group by `test`.`t`.`a` +FLUSH STATUS; +SELECT a, MIN(b), MAX(b) FROM t WHERE a > 9 GROUP BY a; +a MIN(b) MAX(b) +10 1 5 +11 2 15 +12 2 15 + +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 8 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.group_query, test.no_group_query] +drop tables test.group_query, test.no_group_query; +DROP TABLE t; diff --git a/mysql-test/r/group_min_max_innodb.result-pq b/mysql-test/r/group_min_max_innodb.result-pq new file mode 100644 index 000000000..0ffbe6c7e --- /dev/null +++ b/mysql-test/r/group_min_max_innodb.result-pq @@ -0,0 +1,693 @@ +drop view if exists v1; +drop table if exists t1,t4; +create table t4 ( +pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +) engine=innodb; +insert into t4 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +create index idx12672_0 on t4 (a1); +create index idx12672_1 on t4 (a1,a2,b,c); +create index idx12672_2 on t4 (a1,a2,b); +analyze table t4; +Table Op Msg_type Msg_text +test.t4 analyze status OK +select distinct a1 from t4 where pk_col not in (1,2,3,4); +a1 +a +b +c +d +drop table t4; +create table t1 ( +a varchar(30), b varchar(30), primary key(a), key(b) +) engine=innodb; +select distinct a from t1; +a +drop table t1; +create table t1(a int, key(a)) engine=innodb; +insert into t1 values(1); +select a, count(a) from t1 group by a with rollup; +a count(a) +1 1 +NULL 1 +drop table t1; +create table t1 (f1 int, f2 char(1), primary key(f1,f2)) charset utf8mb4 engine=innodb +stats_persistent=0; +insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); +alter table t1 drop primary key, add primary key (f2, f1); +explain select distinct f1 a, f1 b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `a`,`test`.`t1`.`f1` AS `b` from `test`.`t1` +explain select distinct f1, f2 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` +drop table t1; +create table t1(pk int primary key) engine=innodb; +create view v1 as select pk from t1 where pk < 20; +insert into t1 values (1), (2), (3), (4); +select distinct pk from v1; +pk +1 +2 +3 +4 +insert into t1 values (5), (6), (7); +select distinct pk from v1; +pk +1 +2 +3 +4 +5 +6 +7 +drop view v1; +drop table t1; +End of 5.1 tests +# +# Bug#12540545 61101: ASSERTION FAILURE IN THREAD 1256741184 IN +# FILE /BUILDDIR/BUILD/BUILD/MYSQ +# +CREATE TABLE t1 (a CHAR(1), b CHAR(1), PRIMARY KEY (a,b)) +charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('a', 'b'), ('c', 'd'); +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') +SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +COUNT(DISTINCT a) +1 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1) NOT NULL, b CHAR(1) NOT NULL, UNIQUE KEY (a,b)) +charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('a', 'b'), ('c', 'd'); +EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 8 NULL 2 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT a)` from `test`.`t1` where (`test`.`t1`.`b` = 'b') +SELECT COUNT(DISTINCT a) FROM t1 WHERE b = 'b'; +COUNT(DISTINCT a) +1 +DROP TABLE t1; +End of 5.5 tests +# +# Bug#17909656 - WRONG RESULTS FOR A SIMPLE QUERY WITH GROUP BY +# +CREATE TABLE t0 ( +i1 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30); +CREATE TABLE t1 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +UNIQUE KEY k1 (c1,i2) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 SELECT 'A',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'B',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'C',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'D',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'E',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'F',i1,i1 FROM t0; +CREATE TABLE t2 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +UNIQUE KEY k2 (c1,i1,i2) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 SELECT 'A',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'B',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'C',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'D',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'E',i1,i1 FROM t0; +INSERT INTO t2 SELECT 'F',i1,i1 FROM t0; +ANALYZE TABLE t1; +ANALYZE TABLE t2; +set optimizer_trace_max_mem_size=1048576; +set @@session.optimizer_trace='enabled=on'; +set end_markers_in_json=on; +EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' AND i2 = 17) OR ( c1 = 'F') +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where (((`test`.`t1`.`i2` = 17) and (`test`.`t1`.`c1` = 'C')) or (`test`.`t1`.`c1` = 'F')) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' AND i2 = 17) OR ( c1 = 'F') +GROUP BY c1; +c1 max(i2) +C 17 +F 30 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR ( c1 = 'F' AND i2 = 17)) +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where ((`test`.`t1`.`c1` = 'C') or ((`test`.`t1`.`i2` = 17) and (`test`.`t1`.`c1` = 'F'))) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR ( c1 = 'F' AND i2 = 17)) +GROUP BY c1; +c1 max(i2) +C 30 +F 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +EXPLAIN SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR c1 = 'F' ) AND ( i2 = 17 ) +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where ((`test`.`t1`.`i2` = 17) and ((`test`.`t1`.`c1` = 'C') or (`test`.`t1`.`c1` = 'F'))) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 WHERE (c1 = 'C' OR c1 = 'F' ) AND ( i2 = 17 ) +GROUP BY c1; +c1 max(i2) +C 17 +F 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +EXPLAIN SELECT c1, max(i2) FROM t1 +WHERE ((c1 = 'C' AND (i2 = 40 OR i2 = 30)) OR ( c1 = 'F' AND (i2 = 40 ))) +GROUP BY c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k1 k1 8 NULL ROWS 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,max(`test`.`t1`.`i2`) AS `max(i2)` from `test`.`t1` where (((`test`.`t1`.`c1` = 'C') and ((`test`.`t1`.`i2` = 40) or (`test`.`t1`.`i2` = 30))) or ((`test`.`t1`.`i2` = 40) and (`test`.`t1`.`c1` = 'F'))) group by `test`.`t1`.`c1` +SELECT c1, max(i2) FROM t1 +WHERE ((c1 = 'C' AND (i2 = 40 OR i2 = 30)) OR ( c1 = 'F' AND (i2 = 40 ))) +GROUP BY c1; +c1 max(i2) +C 30 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +EXPLAIN SELECT c1, i1, max(i2) FROM t2 +WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ) +GROUP BY c1,i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 10.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range k2 k2 8 NULL ROWS 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`i1` AS `i1`,max(`test`.`t2`.`i2`) AS `max(i2)` from `test`.`t2` where ((`test`.`t2`.`i2` = 17) and ((`test`.`t2`.`c1` = 'C') or ((`test`.`t2`.`c1` = 'F') and (`test`.`t2`.`i1` < 35)))) group by `test`.`t2`.`c1`,`test`.`t2`.`i1` +SELECT c1, i1, max(i2) FROM t2 +WHERE (c1 = 'C' OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 ) +GROUP BY c1,i1; +c1 i1 max(i2) +C 17 17 +F 17 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +EXPLAIN SELECT c1, i1, max(i2) FROM t2 +WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )) +GROUP BY c1,i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 10.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range k2 k2 8 NULL ROWS 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`i1` AS `i1`,max(`test`.`t2`.`i2`) AS `max(i2)` from `test`.`t2` where ((`test`.`t2`.`i2` = 17) and (((`test`.`t2`.`c1` = 'C') and (`test`.`t2`.`i1` < 40)) or ((`test`.`t2`.`c1` = 'F') and (`test`.`t2`.`i1` < 35)))) group by `test`.`t2`.`c1`,`test`.`t2`.`i1` +SELECT c1, i1, max(i2) FROM t2 +WHERE (((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35)) AND ( i2 = 17 )) +GROUP BY c1,i1; +c1 i1 max(i2) +C 17 17 +F 17 17 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +0 +EXPLAIN SELECT c1, i1, max(i2) FROM t2 +WHERE ((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35) OR ( i2 = 17 )) +GROUP BY c1,i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 19.72 Parallel execute (1 workers) +2 SIMPLE t2 NULL index k2 k2 12 NULL ROWS 19.72 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`i1` AS `i1`,max(`test`.`t2`.`i2`) AS `max(i2)` from `test`.`t2` where (((`test`.`t2`.`c1` = 'C') and (`test`.`t2`.`i1` < 40)) or ((`test`.`t2`.`c1` = 'F') and (`test`.`t2`.`i1` < 35)) or (`test`.`t2`.`i2` = 17)) group by `test`.`t2`.`c1`,`test`.`t2`.`i1` +SELECT c1, i1, max(i2) FROM t2 +WHERE ((c1 = 'C' AND i1 < 40) OR ( c1 = 'F' AND i1 < 35) OR ( i2 = 17 )) +GROUP BY c1,i1; +c1 i1 max(i2) +A 17 17 +B 17 17 +C 1 1 +C 2 2 +C 3 3 +C 4 4 +C 5 5 +C 6 6 +C 7 7 +C 8 8 +C 9 9 +C 10 10 +C 11 11 +C 12 12 +C 13 13 +C 14 14 +C 15 15 +C 16 16 +C 17 17 +C 18 18 +C 19 19 +C 20 20 +C 21 21 +C 22 22 +C 23 23 +C 24 24 +C 25 25 +C 26 26 +C 27 27 +C 28 28 +C 29 29 +C 30 30 +D 17 17 +E 17 17 +F 1 1 +F 2 2 +F 3 3 +F 4 4 +F 5 5 +F 6 6 +F 7 7 +F 8 8 +F 9 9 +F 10 10 +F 11 11 +F 12 12 +F 13 13 +F 14 14 +F 15 15 +F 16 16 +F 17 17 +F 18 18 +F 19 19 +F 20 20 +F 21 21 +F 22 22 +F 23 23 +F 24 24 +F 25 25 +F 26 26 +F 27 27 +F 28 28 +F 29 29 +F 30 30 +SELECT TRACE RLIKE 'minmax_keypart_in_disjunctive_query' +AS OK FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +OK +1 +SET optimizer_trace_max_mem_size=DEFAULT; +SET optimizer_trace=DEFAULT; +SET end_markers_in_json=DEFAULT; +DROP TABLE t0,t1,t2; +# +# Bug #21749123: SELECT DISTINCT, WRONG RESULTS COMBINED WITH +# USE_INDEX_EXTENSIONS=OFF +# +CREATE TABLE t1 ( +pk_col INT AUTO_INCREMENT PRIMARY KEY, +a1 CHAR(64), +KEY a1_idx (a1) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 (a1) VALUES ('a'),('a'),('a'),('a'), ('a'); +CREATE TABLE t2 ( +pk_col1 INT NOT NULL, +pk_col2 INT NOT NULL, +a1 CHAR(64), +a2 CHAR(64), +PRIMARY KEY(pk_col1, pk_col2), +KEY a1_idx (a1), +KEY a1_a2_idx (a1, a2) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t2 (pk_col1, pk_col2, a1, a2) VALUES (1,1,'a','b'),(1,2,'a','b'), +(1,3,'a','c'),(1,4,'a','c'), +(2,1,'a','d'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,a1_idx a1_idx 261 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where ((`test`.`t1`.`a1` = 'a') and ((`test`.`t1`.`pk_col` = 2) or (`test`.`t1`.`pk_col` = 22))) +SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +a1 +a +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a1_idx a1_idx 261 NULL 6 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`pk_col` +SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +COUNT(DISTINCT a1) +1 +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a1_idx,a1_a2_idx a1_idx 261 NULL 3 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`pk_col1` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +COUNT(DISTINCT a1) +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a1_a2_idx a1_a2_idx 514 NULL 4 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +COUNT(DISTINCT a1) +1 +1 +1 +SET @optimizer_switch_save=@@optimizer_switch; +SET @@optimizer_switch= "use_index_extensions=off"; +EXPLAIN SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref PRIMARY,a1_idx a1_idx 257 const 5 40.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a1` AS `a1` from `test`.`t1` where ((`test`.`t1`.`a1` = 'a') and ((`test`.`t1`.`pk_col` = 2) or (`test`.`t1`.`pk_col` = 22))) +SELECT DISTINCT a1 +FROM t1 +WHERE (pk_col = 2 OR pk_col = 22) AND a1 = 'a'; +a1 +a +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a1_idx a1_idx 257 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t1` group by `test`.`t1`.`a1`,`test`.`t1`.`pk_col` +SELECT COUNT(DISTINCT a1) +FROM t1 +GROUP BY a1,pk_col; +COUNT(DISTINCT a1) +1 +1 +1 +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a1_idx,a1_a2_idx a1_idx 257 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`pk_col1` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,pk_col1; +COUNT(DISTINCT a1) +1 +1 +EXPLAIN SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a1_a2_idx a1_a2_idx 514 NULL 4 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t2`.`a1`) AS `COUNT(DISTINCT a1)` from `test`.`t2` group by `test`.`t2`.`a1`,`test`.`t2`.`a2` +SELECT COUNT(DISTINCT a1) +FROM t2 +GROUP BY a1,a2; +COUNT(DISTINCT a1) +1 +1 +1 +SET @@optimizer_switch= @optimizer_switch_save; +DROP TABLE t1, t2; +# +# Bug #24671968: WHEN THE OPTIMISER IS USING INDEX FOR GROUP-BY IT OFTEN +# OFTEN GIVES WRONG RESULTS +# +CREATE TABLE t1 ( +id int NOT NULL, +c1 int NOT NULL, +c2 int, +PRIMARY KEY(id), +INDEX c1_c2_idx(c1, c2)); +INSERT INTO t1 (id, c1, c2) VALUES (1,1,1), (2,2,2), (10,10,1), (11,10,8), +(12,10,1), (13,10,2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT c1 +FROM t1 +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index c1_c2_idx c1_c2_idx 9 NULL 6 100.00 Using where; Using index +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` where exists(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index c1_c2_idx c1_c2_idx 9 NULL 6 100.00 Using where; Using index +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (1 in (2,(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)),3)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 +WHERE c2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range c1_c2_idx c1_c2_idx 9 NULL 4 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c2` = 2) +EXPLAIN SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` IGNORE INDEX (`c1_c2_idx`) where exists(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` IGNORE INDEX (`c1_c2_idx`) where (1 in (2,(/* select#2 */ select 1 from DUAL where (`test`.`t1`.`c2` = 2)),3)) +SET optimizer_trace="enabled=on"; +SELECT DISTINCT c1 +FROM t1 +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +c1 +2 +10 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "keypart_reference_from_where_clause"; +@trace RLIKE "keypart_reference_from_where_clause" +1 +SET optimizer_trace="enabled=off"; +SELECT DISTINCT c1 +FROM t1 +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +c1 +2 +10 +SELECT DISTINCT c1 +FROM t1 +WHERE c2 = 2; +c1 +2 +10 +SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE EXISTS (SELECT * +FROM DUAL +WHERE (c2 = 2)); +c1 +2 +10 +SELECT DISTINCT c1 +FROM t1 IGNORE INDEX (c1_c2_idx) +WHERE 1 IN (2, +(SELECT 1 +FROM DUAL +WHERE (c2 = 2)), +3); +c1 +2 +10 +DROP TABLE t1; +# +# Bug #26532061: SELECT DISTINCT WITH SECONDARY KEY FOR +# 'USING INDEX FOR GROUP-BY' BAD RESULTS +# +CREATE TABLE t1( +pk INT NOT NULL, +c1 CHAR(2), +c2 INT, +PRIMARY KEY(pk), +UNIQUE KEY ukey(c1, c2) +); +INSERT INTO t1(pk, c1, c2) VALUES (1,1,1),(2,2,2),(3,3,3),(4,5,4); +SET @a:=5; +INSERT IGNORE INTo t1(pk, c1, c2) +SELECT (@a:=@a+1),@a,@a FROM t1, t1 t2,t1 t3, t1 t4; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE pk = 1 OR pk = 231; +pk c1 c2 +1 1 1 +231 23 231 +EXPLAIN SELECT DISTINCT c1 +FROM t1 FORCE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index ukey ukey 14 NULL 260 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` FORCE INDEX (`ukey`) where ((`test`.`t1`.`pk` in (1,231)) and (`test`.`t1`.`c1` is not null)) +EXPLAIN SELECT DISTINCT c1 +FROM t1 IGNORE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 90.00 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`c1` AS `c1` from `test`.`t1` IGNORE INDEX (`ukey`) where ((`test`.`t1`.`pk` in (1,231)) and (`test`.`t1`.`c1` is not null)) +SELECT DISTINCT c1 +FROM t1 FORCE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +c1 +1 +23 +SELECT DISTINCT c1 +FROM t1 IGNORE INDEX(ukey) +WHERE pk IN (1,231) and c1 IS NOT NULL; +c1 +1 +23 +DROP TABLE t1; +# +# Bug #25989915: LOOSE INDEX SCANS RETURNING WRONG RESULT +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1 varchar(100) DEFAULT NULL, +c2 INT NOT NULL, +PRIMARY KEY (pk), +UNIQUE KEY ukey (c2,c1) +); +INSERT INTO t1(pk, c2) VALUES (100, 0), (101, 0), (102, 0), (103, 0); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 101); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY,ukey ukey 407 NULL 4 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`c2`) AS `COUNT(DISTINCT(c2))` from `test`.`t1` where (`test`.`t1`.`pk` in (102,101)) +EXPLAIN SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 100); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY,ukey ukey 407 NULL 4 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`c2`) AS `COUNT(DISTINCT(c2))` from `test`.`t1` where (`test`.`t1`.`pk` in (102,100)) +SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 101); +COUNT(DISTINCT(c2)) +1 +SELECT COUNT(DISTINCT(c2)) FROM t1 WHERE pk IN (102, 100); +COUNT(DISTINCT(c2)) +1 +DROP TABLE t1; diff --git a/mysql-test/r/handler_read_last.result-pq b/mysql-test/r/handler_read_last.result-pq new file mode 100644 index 000000000..e46af11dc --- /dev/null +++ b/mysql-test/r/handler_read_last.result-pq @@ -0,0 +1,60 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT, INDEX (a)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(); +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a LIMIT 1; +a +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a DESC LIMIT 1; +a +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a LIMIT 3; +a +NULL +NULL +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +FLUSH STATUS; +SELECT a FROM t1 ORDER BY a DESC LIMIT 3; +a +NULL +NULL +NULL +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +DROP TABLE t1; diff --git a/mysql-test/r/hash_join.result-pq b/mysql-test/r/hash_join.result-pq new file mode 100644 index 000000000..cf8b6b855 --- /dev/null +++ b/mysql-test/r/hash_join.result-pq @@ -0,0 +1,4019 @@ +# +# Start out by testing some simple in-memory inner hash joins. +# +# Join on two integer columns. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (3), (5), (7); +INSERT INTO t2 VALUES (1), (2), (5), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +EXPLAIN +-> Sort: t1.col1 + -> Stream results + -> Parallel scan on + -> Sort: t1.col1 + -> Stream results (cost=2.50 rows=4) + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1 1 +5 5 +DROP TABLE t1, t2; +# Join on a integer column and a string column. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES (1), (3), (5), (7); +INSERT INTO t2 VALUES (1), (2), (5), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +EXPLAIN +-> Sort: t1.col1 + -> Stream results + -> Parallel scan on + -> Sort: t1.col1 + -> Stream results (cost=2.50 rows=4) + -> Inner hash join (cast(t1.col1 as double) = cast(t2.col1 as double)) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1 1 +5 5 +DROP TABLE t1, t2; +# Join on two datetime columns. +CREATE TABLE t1 (col1 DATETIME(6)); +CREATE TABLE t2 (col1 DATETIME(6)); +INSERT INTO t1 VALUES ('2018-01-01 00:00:00.000000'), +('2018-01-01 00:00:00.000001'), +('2018-01-02 00:00:00.000000'), +('2018-01-02 00:00:00.000001'); +INSERT INTO t2 VALUES ('2018-01-01 00:00:00.000000'), +('2018-01-01 00:00:00.000002'), +('2018-01-02 00:00:00.000001'), +('2019-01-02 00:00:00.000001'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +2018-01-01 00:00:00.000000 2018-01-01 00:00:00.000000 +2018-01-02 00:00:00.000001 2018-01-02 00:00:00.000001 +DROP TABLE t1, t2; +# Join on a string and datetime column, where datetime comparison is +# picked. +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +CREATE TABLE t2 (b VARCHAR(64)); +INSERT INTO t2 VALUES ('2001#01#01'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE a=b; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.a = t2.b) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1, t2 WHERE a=b; +a b +2001-01-01 00:00:00 2001#01#01 +DROP TABLE t1, t2; +# Join on two double columns. +CREATE TABLE t1 (col1 DOUBLE); +CREATE TABLE t2 (col1 DOUBLE); +INSERT INTO t1 VALUES (1.1), (3.3), (5.5), (7.7); +INSERT INTO t2 VALUES (1.1), (1.11), (5.5), (6.6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1.1 1.1 +5.5 5.5 +DROP TABLE t1, t2; +# Join on two decimal columns. +CREATE TABLE t1 (col1 DECIMAL(6, 2)); +CREATE TABLE t2 (col1 DECIMAL(6, 2)); +INSERT INTO t1 VALUES (1.1), (3.3), (5.5), (7.7); +INSERT INTO t2 VALUES (1.1), (1.10), (5.5), (6.6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.col1 = t1.col1) (cost=2.50 rows=4) + -> Table scan on t2 (cost=0.09 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.65 rows=4) + +SELECT t1.col1, t2.col1 FROM t1 JOIN t2 ON t1.col1 = t2.col1 ORDER BY t1.col1; +col1 col1 +1.10 1.10 +1.10 1.10 +5.50 5.50 +DROP TABLE t1, t2; +# See that comparison between decimal and bigint works well. The main +# challenge is that decimals with different amount of leading/trailing +# zeroes should compare equally. +CREATE TABLE t1 (col1 BIGINT); +CREATE TABLE t2 (col1 DECIMAL(64,30)); +INSERT INTO t1 VALUES (5); +INSERT INTO t2 VALUES (5.000000000000000000000000000000); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1,t2 WHERE t1.col1 = t2.col1; +col1 col1 +5 5.000000000000000000000000000000 +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 DECIMAL(5)); +CREATE TABLE t2 (col1 BIGINT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 where t1.col1=t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1,t2 where t1.col1=t2.col1; +col1 col1 +1 1 +DROP TABLE t1, t2; +# Bit fields, which is a bit different depending on the storage engine. +create table t1 (id1 int, b1 bit(1)) engine = myisam; +create table t2 (id2 int, b2 bit(1)) engine = myisam; +insert into t1 values (2, 0), (3, 1); +insert into t2 values (2, 1), (3, 0); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE id1 = id2; +EXPLAIN +-> Inner hash join (t2.id2 = t1.id1) (cost=1.60 rows=2) + -> Table scan on t2 (cost=0.30 rows=2) + -> Hash + -> Table scan on t1 (cost=0.70 rows=2) + +SELECT id1, HEX(b1), id2, HEX(b2) FROM t1, t2 WHERE id1 = id2; +id1 HEX(b1) id2 HEX(b2) +2 0 2 1 +3 1 3 0 +DROP TABLE t1, t2; +create table t1 (id1 int, b1 bit(64)) engine = innodb; +create table t2 (id2 int, b2 bit(64)) engine = innodb; +insert into t1 values (2, 0), (3, 2); +insert into t2 values (2, 2), (3, 0); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE id1 = id2; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.id2 = t1.id1) (cost=1.10 rows=2) + -> Table scan on t2 (cost=0.18 rows=2) + -> Hash + -> PQblock scan on t1 (cost=0.45 rows=2) + +SELECT id1, HEX(b1), id2, HEX(b2) FROM t1, t2 WHERE id1 = id2; +id1 HEX(b1) id2 HEX(b2) +2 0 2 2 +3 2 3 0 +DROP TABLE t1, t2; +# See that we handle NULL values properly. +CREATE TABLE t1 (col1 VARCHAR(255)); +CREATE TABLE t2 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t2 VALUES (""); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Filter: (t2.col1 = t1.col1) (cost=0.70 rows=1) + -> Inner hash join ((t2.col1)=(t1.col1)) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1; +col1 col1 +DROP TABLE t1,t2; +# +# Now, do some queries where we end up with a GRACE hash join. That is, +# the right table of the join is bigger than the join_buffer_size. +# +CREATE TABLE t1 (col1 BIGINT); +CREATE TABLE t2 (col1 BIGINT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +INSERT INTO t1 SELECT col1 + 256 FROM t1; +INSERT INTO t1 SELECT col1 + 512 FROM t1; +INSERT INTO t2 SELECT col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 2048; +EXPLAIN FORMAT=tree +SELECT SUM(t1.col1), SUM(t2.col1) FROM t1, t2 WHERE t1.col1 = t2.col1; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t2.col1)`) + -> Parallel scan on + -> Aggregate: + -> Inner hash join (t2.col1 = t1.col1) (cost=*** rows=104858) + -> Table scan on t2 (cost=*** rows=1024) + -> Hash + -> PQblock scan on t1 (cost=*** rows=1024) + +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +SELECT SUM(t1.col1), SUM(t2.col1) FROM t1, t2 WHERE t1.col1 = t2.col1; +SUM(t1.col1) SUM(t2.col1) +524800 524800 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +SET join_buffer_size = DEFAULT; +DROP TABLE t1,t2; +# See that spill to disk (GRACE hash join) works with all kind of +# data types. +CREATE TABLE t1 ( +str_col VARCHAR(255), +blob_col LONGBLOB, +text_col LONGTEXT, +bit_col BIT(64), +tinyint_col TINYINT, +smallint_col SMALLINT, +mediumint_col MEDIUMINT, +int_col INTEGER, +bigint_col BIGINT, +float_col FLOAT, +double_col DOUBLE, +decimal_col DECIMAL(65, 30), +year_col YEAR, +date_col DATE, +time_col TIME(6), +datetime_col DATETIME(6), +timestamp_col TIMESTAMP(6), +json_col JSON, +geometry_col GEOMETRY +); +SET time_zone = '+00:00'; +INSERT INTO t1 VALUES ( +'', +'', +'', +b'0000000000000000000000000000000000000000000000000000000000000000', +-128, +-32768, +-8388608, +-2147483648, +-9223372036854775808, +-3.402823466E+38, +-1.7976931348623157E+308, +'-99999999999999999999999999999999999.999999999999999999999999999999', +1901, +'1000-01-01', +'-838:59:59.000000', +'1000-01-01 00:00:00.000000', +'1970-01-01 00:00:01.000000', +'{}', +ST_GeomFromText('GEOMETRYCOLLECTION()') +); +INSERT INTO t1 VALUES ( +'a very long and interesting string', +'a very long and interesting blob', +'a very long and interesting text', +b'1111111111111111111111111111111111111111111111111111111111111111', +127, +32767, +8388607, +2147483647, +9223372036854775807, +3.402823466E+38, +1.7976931348623157E+308, +'99999999999999999999999999999999999.999999999999999999999999999999', +2155, +'9999-12-31', +'838:59:59.000000', +'9999-12-31 23:59:59.999999', +'2038-01-19 03:14:07.999999', +'{"key": [1, 2, 3]}', +ST_GeomFromText('GEOMETRYCOLLECTION(POINT(1 2), POINT(3 4))') +); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET join_buffer_size = 99968; +# Just do a few aggregations for sanity checking. We don't want to +# pollute the result log with thousands of lines with binary data. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT +COUNT(*), +SUM(LENGTH(t1.text_col)), +SUM(t2.bigint_col) +FROM +t1, +t1 AS t2 +WHERE +t1.int_col = t2.int_col +ORDER BY +t1.int_col; +EXPLAIN +-> Aggregate: count(0), sum(length(t1.text_col)), sum(t2.bigint_col) + -> Inner hash join (t2.int_col = t1.int_col) (cost=*** rows=1638) + -> Table scan on t2 (cost=*** rows=128) + -> Hash + -> Table scan on t1 (cost=*** rows=128) + +SELECT +COUNT(*), +SUM(LENGTH(t1.text_col)), +SUM(t2.bigint_col) +FROM +t1, +t1 AS t2 +WHERE +t1.int_col = t2.int_col +ORDER BY +t1.int_col; +COUNT(*) SUM(LENGTH(t1.text_col)) SUM(t2.bigint_col) +8192 131072 -4096 +DROP TABLE t1; +SET join_buffer_size = DEFAULT; +SET time_zone = DEFAULT; +# +# A query where we end up with a weedout + hash join. This forces hash +# join to keep the row ID for each row, so that the duplicate removal +# works. +# +SET optimizer_switch="materialization=off,firstmatch=off"; +CREATE TABLE t1 (i BIGINT); +CREATE TABLE t2 (i BIGINT); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +EXPLAIN +-> Parallel scan on + -> Remove duplicate t2 rows using temporary table (weedout) (cost=1.30 rows=2) + -> Inner hash join (t1.i = t2.i) (cost=1.30 rows=2) + -> Table scan on t1 (cost=0.18 rows=3) + -> Hash + -> PQblock scan on t2 (cost=0.45 rows=2) + +SELECT * FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +i +2 +3 +# Increase the data volume, and reduce the join_buffer_size, in order to +# test that we can keep the row ID in case of GRACE hash join as well. +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 SELECT * FROM t2; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 2048; +EXPLAIN FORMAT=tree +SELECT COUNT(*) FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +EXPLAIN +-> Aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Aggregate: + -> Remove duplicate t2 rows using temporary table (weedout) (cost=*** rows=157286) + -> Inner hash join (t1.i = t2.i) (cost=*** rows=157286) + -> Table scan on t1 (cost=*** rows=1536) + -> Hash + -> PQblock scan on t2 (cost=*** rows=1024) + +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +SELECT COUNT(*) FROM t2 WHERE (t2.i) IN (SELECT t1.i FROM t1); +COUNT(*) +1024 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +DROP TABLE t1, t2; +SET join_buffer_size = DEFAULT; +SET optimizer_switch = DEFAULT; +# Test a case where the RAND() function is pushed as late as possible in +# the join. The optimizer ends up rewriting t1.col1 = FLOOR(...) to +# t2.col1 = FLOOR(...), so this test case ensures that the executor is +# able to put the condition after the join. FLOOR and division/addition +# make this query deterministic. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT +t1.col1, +t2.col1 +FROM +t1, +t2 +WHERE +t1.col1 = t2.col1 +AND t1.col1 = FLOOR(RAND() / 2 + 2); +EXPLAIN +-> Parallel scan on + -> Filter: (t1.col1 = floor(((rand() / 2) + 2))) (cost=1.00 rows=2) + -> Inner hash join (t2.col1 = t1.col1) (cost=1.00 rows=2) + -> Table scan on t2 (cost=0.35 rows=2) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=2) + +SELECT +t1.col1, +t2.col1 +FROM +t1, +t2 +WHERE +t1.col1 = t2.col1 +AND t1.col1 = FLOOR(RAND() / 2 + 2); +col1 col1 +2 2 +DROP TABLE t1, t2; +# Ensure that the hash join picks the correct fields and tables when both +# sides of the join condition are from the same source table. +CREATE TABLE c ( +col1 varchar(1) +) ENGINE = myisam; +INSERT INTO c VALUES ('w'); +INSERT INTO c VALUES ('d'); +ANALYZE TABLE c; +Table Op Msg_type Msg_text +test.c analyze status OK +EXPLAIN format=tree SELECT * +FROM +(SELECT * FROM c) AS table1 +JOIN (SELECT * FROM c) AS table2 +ON table2.col1 = table1.col1; +EXPLAIN +-> Inner hash join (c.col1 = c.col1) (cost=1.60 rows=2) + -> Table scan on c (cost=0.30 rows=2) + -> Hash + -> Table scan on c (cost=0.70 rows=2) + +SELECT * +FROM +(SELECT * FROM c) AS table1 +JOIN (SELECT * FROM c) AS table2 +ON table2.col1 = table1.col1; +col1 col1 +w w +d d +DROP TABLE c; +# This query ends up with a BNL between t3 and t2. Ensure that we don't +# end up with a hash join like: +# +# -> Constant row from +# -> Materialize with deduplication +# -> HashJoin inner join (t3.i = '2') +# -> Table scan on t2 +# -> Table scan on t3 +# +# We don't want a join condition on a constant, so it should be pushed as +# a filter. +SET optimizer_switch='firstmatch=off'; +CREATE TABLE t1 (i INTEGER) ENGINE = MyISAM; +CREATE TABLE t2 (i INTEGER) ENGINE = MyISAM; +CREATE TABLE t3 (i INTEGER) ENGINE = MyISAM; +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM t1 WHERE (t1.i) IN (SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +EXPLAIN +-> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=1.10..1.10 rows=0) + -> Filter: (t3.i is not null) (cost=1.10 rows=0) + -> Inner hash join (no condition) (cost=1.10 rows=0) + -> Filter: (t3.i = '2') (cost=0.50 rows=0) + -> Table scan on t3 (cost=0.50 rows=0) + -> Hash + -> Table scan on t2 (cost=0.60 rows=1) + +SELECT * FROM t1 WHERE (t1.i) IN (SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +DROP TABLE t1,t2,t3; +SET optimizer_switch=DEFAULT; +# A bit more complicated join condition where we have multiple join +# conditions, and one of them is an expression. +CREATE TABLE t1 (a INTEGER, b INTEGER); +INSERT INTO t1 (a) VALUES (1),(2); +CREATE TABLE t3 (a INTEGER, b INTEGER); +INSERT INTO t3 VALUES (1, 10), (1, 11), (2, 10), (2, 11); +ANALYZE TABLE t1, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1, t3 WHERE t3.b = t1.a + 9 AND t3.a = t1.a; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t3.a = t1.a), (t3.b = (t1.a + 9)) (cost=1.50 rows=2) + -> Table scan on t3 (cost=0.18 rows=4) + -> Hash + -> PQblock scan on t1 (cost=0.45 rows=2) + +SELECT * FROM t1, t3 WHERE t3.b = t1.a + 9 AND t3.a = t1.a; +a b a b +1 NULL 1 10 +2 NULL 2 11 +DROP TABLE t1,t3; +# Ensure that outer joins doesn't degrade into a nested loop, +# but still uses join buffering. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1) (cost=0.63 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Table scan on t2 (cost=0.18 rows=1) + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col1` = `test`.`t1`.`col1`)) where true +DROP TABLE t1, t2; +# See that we can replace a BNL with hash join, even if we have extra +# join conditions that are not equi-join conditions. The result should be +# that the non-equi-join conditions should be attached as a filter after +# the join. +CREATE TABLE t1 (col1 INTEGER, col2 INTEGER); +CREATE TABLE t2 (col1 INTEGER, col2 INTEGER); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +INSERT INTO t2 VALUES (1, 1), (2, 4), (3, 6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +EXPLAIN +-> Parallel scan on + -> Filter: (t1.col2 < t2.col2) (cost=1.70 rows=3) + -> Inner hash join (t2.col1 = t1.col1) (cost=1.70 rows=3) + -> Table scan on t2 (cost=0.12 rows=3) + -> Hash + -> PQblock scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +col1 col2 col1 col2 +2 2 2 4 +3 3 3 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 BIGINT); +INSERT INTO t1 VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT SUM(t1.col1) +FROM t1, t1 t2, t1 t3, t1 t4, t1 t5, t1 t6; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`) + -> Parallel scan on + -> Aggregate: + -> Inner hash join (no condition) (cost=111113.45 rows=1000000) + -> Table scan on t6 (cost=0.00 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=11112.35 rows=100000) + -> Table scan on t5 (cost=0.00 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=1112.01 rows=10000) + -> Table scan on t4 (cost=0.00 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=111.75 rows=1000) + -> Table scan on t3 (cost=0.01 rows=10) + -> Hash + -> Inner hash join (no condition) (cost=11.50 rows=100) + -> Table scan on t2 (cost=0.13 rows=10) + -> Hash + -> PQblock scan on t1 (cost=1.25 rows=10) + +SELECT SUM(t1.col1) FROM t1, t1 t2, t1 t3, t1 t4, t1 t5, t1 t6; +SUM(t1.col1) +1000000 +DROP TABLE t1; +# Test that comparison between FLOAT and DOUBLE works as expected if +# given an explicit number of decimals. +CREATE TABLE t1 (col1 FLOAT(5,2), col2 DOUBLE(15,2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1.01, 1.01); +SELECT * FROM t1 a, t1 b WHERE a.col1 = b.col2; +col1 col2 col1 col2 +1.01 1.01 1.01 1.01 +DROP TABLE t1; +# The point of the following test is to see that if the innermost hash +# join returns zero rows, the outermost hash join should not scan the +# probe table. +CREATE TABLE t1 (col1 INT); +CREATE TABLE t2 (col1 INT); +CREATE TABLE t3 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2), (3); +INSERT INTO t3 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT STRAIGHT_JOIN * FROM t1 +JOIN t2 ON t1.col1 + 10 = t2.col1 +JOIN t3 ON t2.col1 = t3.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t3.col1 = t2.col1) (cost=2.85 rows=3) + -> Table scan on t3 (cost=0.12 rows=3) + -> Hash + -> Inner hash join ((t1.col1 + 10) = t2.col1) (cost=1.70 rows=3) + -> Table scan on t2 (cost=0.12 rows=3) + -> Hash + -> PQblock scan on t1 (cost=0.55 rows=3) + +SELECT SUM(variable_value) AS Total_handler_reads +FROM performance_schema.session_status +WHERE variable_name LIKE 'Handler_read%'; +Total_handler_reads +12 +DROP TABLE t1, t2, t3; +# +# Bug#29898802 WL#2241: SIG6 IN HASH_JOIN_BUFFER::LOADINTOTABLEBUFFERS() +# AT HASH_JOIN_BUFFER.CC +# +CREATE TABLE t1 ( +pk int NOT NULL AUTO_INCREMENT, +col_varchar varchar(1), +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY idx_CC_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES (1,'n','X'),(2,'Y','8'),(3,'R','l'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT +t1.col_varchar_key AS field1 +FROM +(t1, t1 as alias1) +WHERE +NOT +EXISTS( +SELECT +alias2.col_varchar_key +FROM +t1 AS alias2 +WHERE +alias2.col_varchar_key >= t1.col_varchar +) +GROUP BY +field1; +EXPLAIN +-> Table scan on (cost=2.50..2.50 rows=0) + -> Temporary table with deduplication (cost=2.50..2.50 rows=0) + -> Parallel scan on + -> Table scan on (cost=0.11..2.84 rows=27) + -> Temporary table with deduplication (cost=7.46..10.19 rows=27) + -> Inner hash join (no condition) (cost=4.65 rows=27) + -> Index scan on alias1 using idx_CC_col_varchar_key (cost=0.18 rows=3) + -> Hash + -> Nested loop antijoin (cost=1.70 rows=9) + -> PQblock scan on t1 (cost=0.55 rows=3) + -> Filter: (alias2.col_varchar_key >= t1.col_varchar) (cost=0.55 rows=3) + -> Index range scan on alias2 (re-planned for each iteration) (cost=0.55 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t1.col_varchar' of SELECT #2 was resolved in SELECT #1 +SELECT +t1.col_varchar_key AS field1 +FROM +(t1, t1 as alias1) +WHERE +NOT +EXISTS( +SELECT +alias2.col_varchar_key +FROM +t1 AS alias2 +WHERE +alias2.col_varchar_key >= t1.col_varchar +) +GROUP BY +field1; +field1 +8 +DROP TABLE t1; +# See that typed arrays are handled as blobs. That is, we do not try to +# allocate 4GB of memory during the hash join. +CREATE TABLE t1 ( +col_int_key INTEGER, +col_json JSON, +KEY mv_idx ((CAST(col_json->'$[*]' AS CHAR(40) ARRAY))) +); +INSERT INTO t1 VALUES (NULL, '[1]'), (4, '[1]'), (1, '[2]'); +CREATE TABLE t2(col_int INTEGER); +INSERT INTO t2 VALUES (1), (2), (3), (11), (12); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT t1.col_int_key AS field1, t2.col_int AS field2 FROM t2 +JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]')); +EXPLAIN +-> Inner hash join (no condition) (cost=*** rows=5) + -> Table scan on t2 (cost=*** rows=5) + -> Hash + -> Filter: json'"1"' member of (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)) (cost=*** rows=1) + -> Index lookup on t1 using mv_idx (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)=json'"1"') (cost=*** rows=1) + +SELECT t1.col_int_key AS field1, t2.col_int AS field2 FROM t2 +JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]')); +DROP TABLE t1,t2; +# +# Bug#29906372 WL#2241: SIG6 IN HASH_JOIN_BUFFER::STOREFROMTABLEBUFFERS +# AT HASH_JOIN_BUFFER.CC +# +CREATE TABLE a ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY varchar_key (col_varchar_key) +); +CREATE TABLE b ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY varchar_key (col_varchar_key) +); +INSERT INTO a VALUES (1, 'N', '0'); +INSERT INTO b VALUES (1, '8', 'r'), (2, 'v', 'C'), (3, 'b', 'p'), (4, '7', 'W'); +ANALYZE TABLE a, b; +Table Op Msg_type Msg_text +test.a analyze status OK +test.b analyze status OK +EXPLAIN FORMAT=tree SELECT 1 FROM (b AS table1 +INNER JOIN a AS table2 ON table2.pk = table1.pk OR table1.col_varchar < 'D') +WHERE (NOT EXISTS +(SELECT 1 FROM (b AS alias3 STRAIGHT_JOIN a AS alias4 +ON alias4.col_varchar = alias3.col_varchar_key) +WHERE alias3.pk >= table1.pk)); +EXPLAIN +-> Nested loop antijoin (cost=2.30 rows=8) + -> Filter: ((table1.pk = table2.pk) or (table1.col_varchar < 'D')) (cost=1.00 rows=2) + -> Inner hash join (no condition) (cost=1.00 rows=2) + -> Table scan on table1 (cost=0.45 rows=4) + -> Hash + -> Index scan on table2 using varchar_key (cost=0.35 rows=1) + -> Nested loop inner join (cost=2.85 rows=4) + -> Filter: (alias3.pk >= table1.pk) (cost=0.45 rows=4) + -> Index range scan on alias3 (re-planned for each iteration) (cost=0.45 rows=4) + -> Filter: (alias4.col_varchar = alias3.col_varchar_key) (cost=1.05 rows=1) + -> Table scan on alias4 (cost=1.05 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.pk' of SELECT #2 was resolved in SELECT #1 +SELECT 1 FROM (b AS table1 +INNER JOIN a AS table2 ON table2.pk = table1.pk OR table1.col_varchar < 'D') +WHERE (NOT EXISTS +(SELECT 1 FROM (b AS alias3 STRAIGHT_JOIN a AS alias4 +ON alias4.col_varchar = alias3.col_varchar_key) +WHERE alias3.pk >= table1.pk)); +DROP TABLE a, b; +# +# Bug#29947439 WL#2241: FLOATING POINT EXCEPTION: INITIALIZECHUNKFILES AT +# HASH_JOIN_ITERATOR.CC +# +CREATE TABLE t1 (col1 TEXT); +INSERT INTO t1 VALUES (REPEAT('A', 50000)), (REPEAT('A', 50000)); +EXPLAIN FORMAT=tree SELECT a.col1 FROM t1 AS a, t1 AS b; +EXPLAIN +-> Inner hash join (no condition) (cost=*** rows=4) + -> Table scan on b (cost=*** rows=2) + -> Hash + -> Table scan on a (cost=*** rows=2) + +SET join_buffer_size = 128; +SELECT a.col1 FROM t1 AS a, t1 AS b; +DROP TABLE t1; +# Set up a case where we have very skewed data in the probe input, and we +# degrade into an on-disk hash join. We want to trigger a code path where +# we have empty chunk files from the probe input. +CREATE TABLE t1 (col1 VARCHAR(255)); +CREATE TABLE t2 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES (SHA2(UUID(), 512)); +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t1 SELECT SHA2(UUID(), 512) FROM t1; +INSERT INTO t2 SELECT REPEAT("a", 255) FROM t1; +SET GLOBAL innodb_stats_persistent_sample_pages = 2000; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET GLOBAL innodb_stats_persistent_sample_pages = DEFAULT; +EXPLAIN FORMAT=tree SELECT STRAIGHT_JOIN COUNT(*) FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (t2.col1 = t1.col1) (cost=*** rows=26214) + -> Inner hash join ((t2.col1)=(t1.col1)) (cost=*** rows=26214) + -> Table scan on t2 (cost=*** rows=512) + -> Hash + -> PQblock scan on t1 (cost=*** rows=512) + +SET join_buffer_size = 1024; +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 JOIN t2 ON t1.col1 = t2.col1; +DROP TABLE t1, t2; +SET join_buffer_size = DEFAULT; +# +# Bug#29964536 WL#2241: ASSERTION FAILURE IN +# TEMPTABLE::HANDLER::POSITION() AT SRC/HANDLER.CC +# +CREATE TABLE tc ( +col_int INTEGER, +col_varchar VARCHAR(1) +); +INSERT INTO tc VALUES (0,'x'); +CREATE TABLE tcc ( +col_varchar VARCHAR(1) +); +INSERT INTO tcc VALUES ('r'), ('f'), ('y'), ('u'), ('m'), (NULL); +CREATE TABLE t1 (field1 INTEGER); +INSERT INTO t1 VALUES (0); +SET optimizer_switch="firstmatch=off"; +UPDATE t1 SET field1 = 9999 WHERE field1 NOT IN ( SELECT alias1.col_int AS +field1 FROM ( tcc, ( SELECT * FROM tc WHERE col_int < 1 ) AS alias1 ) WHERE ( +alias1.col_varchar IN ( SELECT col_varchar FROM tcc ) ) GROUP BY field1 +HAVING field1 <> 1 ); +SET optimizer_switch="firstmatch=on"; +DROP TABLE tc,tcc,t1; +# Do a join between DECIMAL and INTEGER to verify that we get a match +# between these two types. +CREATE TABLE t1 (col1 DECIMAL(4, 2)); +INSERT INTO t1 VALUES (0); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t2 VALUES (0); +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +col1 col1 +0.00 0 +DROP TABLE t1, t2; +# See that we get the correct results with a PAD SPACE collation and +# PAD_CHAR_TO_FULL_LENGTH. Note that the latter is deprecated, so this +# test should go away once the SQL mode is removed. +CREATE TABLE t1 ( +col1 CHAR(4) +) DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs; +INSERT INTO t1 VALUES ("foo"); +CREATE TABLE t2 ( +col1 CHAR(40) +) DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs; +INSERT INTO t2 VALUES ("foo"); +SET sql_mode="PAD_CHAR_TO_FULL_LENGTH"; +Warnings: +Warning 3090 Changing sql mode 'PAD_CHAR_TO_FULL_LENGTH' is deprecated. It will be removed in a future release. +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t1.col1 = t2.col1) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1; +col1 col1 +foo foo +SET sql_mode=DEFAULT; +DROP TABLE t1, t2; +# Set up a case where the join planner will set up a BNL with linked +# join buffers, and where the row ID should be kept due to duplicate +# removal. rowid_status will be set on several QEP_TABs to indicate that +# a row ID is needed, even though we should not request the row ID on all +# of them. +CREATE TABLE b1 (col_int INTEGER); +INSERT INTO b1 VALUES (1); +CREATE TABLE c1 ( +col_int INTEGER, +col_timestamp TIMESTAMP NULL, +col_decimal DECIMAL(10, 4) +); +INSERT INTO c1 VALUES +(1741569678,'2004-01-07 20:47:51',-4.7563), +(-1533615975,'2037-10-27 16:40:24',7.7785); +CREATE TABLE cc1 ( +col_int INTEGER, +col_decimal DECIMAL(10, 4), +col_timestamp TIMESTAMP NULL +); +INSERT INTO cc1 VALUES +(-190646953,6.4052,'2007-11-21 09:45:29'), +(-423321712,6.9636,'1988-01-04 13:34:47'); +SELECT +1 +FROM +b1 +LEFT JOIN ( +c1 +RIGHT JOIN (SELECT DISTINCT * FROM cc1) AS alias3 ON +alias3.col_timestamp = c1.col_timestamp +) ON b1.col_int = c1.col_int AND 1 +WHERE +EXISTS( +SELECT +1 +FROM +cc1 JOIN c1 ON c1.col_decimal = cc1.col_decimal AND 1 +WHERE +cc1.col_int <= b1.col_int OR cc1.col_int = c1.col_int +); +1 +DROP TABLE b1, c1, cc1; +# Yet another problematic case involing duplicate weedout. +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +set optimizer_switch='firstmatch=off'; +set optimizer_switch='materialization=off'; +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +set optimizer_switch=DEFAULT; +DROP TABLE t1; +# A case where we have a hash join iterator both above and below a +# WeedoutIterator. +CREATE TABLE t1(f1 INT(11) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10); +CREATE TABLE t2 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1, 7), (2, 1), (4, 7); +CREATE TABLE t4(f1 INT DEFAULT NULL); +INSERT INTO t4 VALUES (2); +ANALYZE TABLE t1, t2, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +EXPLAIN +-> Aggregate: count(0) + -> Inner hash join (no condition) (cost=3.70 rows=4) + -> Table scan on t1 (cost=0.08 rows=1) + -> Hash + -> Remove duplicate (ta3, ta4) rows using temporary table (weedout) (cost=3.00 rows=4) + -> Nested loop inner join (cost=3.00 rows=4) + -> Nested loop inner join (cost=2.30 rows=4) + -> Inner hash join (no condition) (cost=1.10 rows=3) + -> Filter: (t4.f1 is not null) (cost=0.12 rows=1) + -> Table scan on t4 (cost=0.12 rows=1) + -> Hash + -> Filter: (t2.f2 is not null) (cost=0.55 rows=3) + -> Index scan on t2 using f2 (cost=0.55 rows=3) + -> Index lookup on ta3 using f2 (f2=t2.f2) (cost=0.30 rows=2) + -> Single-row index lookup on ta4 using PRIMARY (f1=t4.f1) (cost=0.08 rows=1) + +SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +DROP TABLE t1, t2, t4; +# +# Bug#30035890 SIG 11 IN HASHJOINITERATOR::READJOINEDROW AT +# SQL/HASH_JOIN_ITERATOR.CC +# +# Note that this test case needs ASAN to reproduce. +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (7), (7); +CREATE TABLE t2 (b INT, c DATETIME); +INSERT IGNORE INTO t2 VALUES (7, NULL), (7, '2006'), (7, '2002'); +Warnings: +Warning 1265 Data truncated for column 'c' at row 2 +Warning 1265 Data truncated for column 'c' at row 3 +# Set up a case where the hash join row buffer will be re-inited. +UPDATE t1 +SET a = 42 +WHERE a NOT IN ( +SELECT alias2.b FROM t2 AS alias2 JOIN t2 AS alias1 ON (alias2.c = alias1.c) +); +DROP TABLE t1, t2; +# +# Bug#30060691 ASSERTION `M_INDEX_CURSOR.IS_POSITIONED()' IN +# TEMPTABLE::HANDLER::POSITION() +# +CREATE TABLE c ( +col_int INTEGER, +col_varchar VARCHAR(1) , +col_varchar_key VARCHAR(1)); +CREATE TABLE bb ( +pk INTEGER auto_increment, +col_int_key INTEGER, +col_varchar VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk)); +CREATE TABLE cc ( +col_varchar_key VARCHAR(1), +INDEX idx (col_varchar_key)); +INSERT INTO bb VALUES (DEFAULT, 41509313, 'S', 'W'); +INSERT INTO c VALUES +(-792274908, 'P', 'r'), +(281391051, 'w', 'x'), +(-1381986093, 'l', '2'), +(-78303180, 'f', 'Q'), +(1027797776, 'w', 'G'), +(-1361294690, 'm', 'L'), +(65604698, '7', 'Y'), +(-964881813, 'j', 'F'), +(1831120981, 'q', 'q'), +(-573388832, 'F', 'M'), +(571640392, '1', 'R'), +(857813414, 'y', 'l'), +(555892383, 'x', 'P'), +(601556555, 'z', 'k'), +(-578249624, 'N', 'e'), +(-843749952, '4', 'J'), +(2058477272, '4', 'R'), +(-1732353317, 'C', 'Z'), +(-1639317818, '9', 'f'), +(19700948, 'K', 'V'); +INSERT INTO cc VALUES +('b'), ('E'), ('v'), ('4'), ('L'), ('g'), ('i'), ('D'), ('S'), ('s'), ('4'), +('5'), ('4'), ('y'), ('v'), ('Z'), ('O'), ('2'), ('v'), ('5'); +ANALYZE TABLE c, bb, cc; +Table Op Msg_type Msg_text +test.c analyze status OK +test.bb analyze status OK +test.cc analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM +cc AS alias1 +LEFT JOIN ( +( +bb AS alias2 +INNER JOIN (SELECT DISTINCT sq1_alias1.* FROM bb AS sq1_alias1) +AS alias3 ON alias3.col_int_key = alias2.col_int_key +) +) ON alias3.col_varchar_key = alias2.col_varchar_key +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar AS sq2_field1 +FROM +c AS sq2_alias1 +WHERE +sq2_alias1.col_varchar_key != alias2.col_varchar +AND sq2_alias1.col_int > alias2.pk +); +EXPLAIN +-> Remove duplicate (alias2, alias3, alias1) rows using temporary table (weedout) (cost=5.06 rows=3) + -> Nested loop inner join (cost=5.06 rows=3) + -> Filter: ((sq2_alias1.col_varchar_key <> alias2.col_varchar) and (sq2_alias1.col_int > alias2.pk)) (cost=1.80 rows=2) + -> Inner hash join (no condition) (cost=1.80 rows=2) + -> Filter: (sq2_alias1.col_varchar is not null) (cost=0.43 rows=6) + -> Table scan on sq2_alias1 (cost=0.43 rows=20) + -> Hash + -> Nested loop inner join (cost=0.95 rows=1) + -> Table scan on alias2 (cost=0.35 rows=1) + -> Index lookup on alias3 using (col_int_key=alias2.col_int_key, col_varchar_key=alias2.col_varchar_key) + -> Materialize (cost=0.45..0.45 rows=1) + -> Table scan on sq1_alias1 (cost=0.35 rows=1) + -> Index lookup on alias1 using idx (col_varchar_key=sq2_alias1.col_varchar) (cost=0.26 rows=1) + +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +# We only want to see that the query does not hit an assertion, so ignore +# the results. +SELECT * +FROM +cc AS alias1 +LEFT JOIN ( +( +bb AS alias2 +INNER JOIN (SELECT DISTINCT sq1_alias1.* FROM bb AS sq1_alias1) +AS alias3 ON alias3.col_int_key = alias2.col_int_key +) +) ON alias3.col_varchar_key = alias2.col_varchar_key +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar AS sq2_field1 +FROM +c AS sq2_alias1 +WHERE +sq2_alias1.col_varchar_key != alias2.col_varchar +AND sq2_alias1.col_int > alias2.pk +); +DROP TABLE bb, c, cc; +# +# Bug#30049217 ASSERTION FAILURE AT +# TEMPTABLE::HANDLER::POSITION|SRC/HANDLER.CC +# +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES +(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +CREATE TABLE t2 (c2 INT, c3 INT, KEY (c3)); +INSERT INTO t2 VALUES +(1,-823867270), +(19,1130654803), +(20,1299270309); +CREATE TABLE t3 (c4 INT); +INSERT INTO t3 VALUES (1); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * +FROM ((SELECT DISTINCT * FROM t2) AS alias2 JOIN t3 ON (t3.c4 = alias2.c2)) +WHERE (EXISTS (SELECT * FROM (t1 LEFT JOIN (t3 JOIN t2 ON (t2.c3 = t3.c4)) ON +(1)))) +AND alias2.c3 < 19; +c2 c3 c4 +1 -823867270 1 +DROP TABLE t1, t2, t3; +# +# Bug#30153695 ASSERTION SIG6 TEMPTABLE::HANDLER::POSITION +# SRC/HANDLER.CC:715 +# +CREATE TABLE c ( +col_date date, +col_datetime_key datetime, +col_varchar_key varchar (1), +col_varchar varchar (1), +col_date_key date, +col_int_key int, +col_time time, +col_time_key time, +col_int int, +pk integer auto_increment, +col_datetime datetime, +key (col_datetime_key ), +key (col_varchar_key ), +key (col_date_key ), +key (col_int_key ), +key (col_time_key ), +primary key (pk)) ENGINE=innodb; +INSERT IGNORE INTO c VALUES +('2001-07-23', '2004-12-11', 'k', 's', NULL, 7, '2004-11-12', '2000-03-18', 3, +NULL, NULL), +(NULL, NULL, 's', 'j', NULL, 6, NULL, '2005', 1, NULL, NULL), +('2006-07-02', NULL, 'w', 'y', NULL, 2, '04:35:59.017853', '2002', 7, NULL, +'2004-09-04 21:23:05.023144'), +(NULL, '2009-02-16 21:37:23.010045', 'w', 'o', '2005-05-25', NULL, NULL, +'04:32:06.000870', 9, NULL, '2004'), +(NULL, NULL, 'y', 'k', '2002-12-15', 81, NULL, '2009-03-14', 3, NULL, NULL), +(NULL, '2005', 'x', 's', '2004-07-12', 9, NULL, NULL, 7, NULL, '2009'), +('2003', '2000-11-08', 'd', 'h', '2002-09-25', 8, NULL, '2002', NULL, NULL, +'2004'), +('2000', '2008-01-08 20:49:13.011386', 't', 'w', '2000-12-11', 6, +'18:31:35.007025', '19:28:20.040544', 4, NULL, '2005-03-13'), +('2006-10-04', '2000-12-16', 'i', 'f', NULL, 3, '2008', NULL, 5, NULL, +'2003-12-03 13:55:06.040156'), +('2009-07-26', '2009-11-22 07:59:12.037926', 'o', 'n', '2004-07-23', 4, +'2005', '12:00:51.020344', 5, NULL, '2006'), +('2009-02-25', NULL, 'm', NULL, '2003', NULL, '2000', '2002-07-28', 1, NULL, +'2004-06-26'), +('2008-01-11', '2001-05-27', 'c', 'w', '2001-11-21', 4, '2004-07-23', +'2005-07-19', 3, NULL, '2001'), +('2009', NULL, 'x', NULL, NULL, 6, '2006-10-03', NULL, 1, NULL, '2009-12-03'), +('2008-09-22', '2008-08-09 11:16:52.037869', 'r', 'c', '2008-01-23', 3, NULL, +NULL, 6, NULL, '2008'), +('2007-01-21', NULL, 'u', 'u', '2008', 5, '2003-07-15', '07:04:43.054922', +NULL, NULL, NULL), +('2009-06-15', '2004-01-25', 'x', NULL, NULL, 189, '2008', '2000-06-14', 1, +NULL, NULL), +('2005', '2008-03-22', NULL, 'g', '2008', 1, '20:53:08.022885', '2006', 3, +NULL, '2009-04-06 15:24:52.051014'), +('2002', '2003-07-10 12:29:23.023649', 'g', 'u', '2000-10-16', 9, '2003', +'2006', 9, NULL, NULL), +('2005-10-23', NULL, 's', 'x', '2005', 9, '2008-07-09', '2001-08-12', 8, NULL, +NULL), +('2005', NULL, 'g', 'm', '2000-01-03', 9, '2008', NULL, 1, NULL, +'2001-01-21'); +Warnings: +Warning 1265 Data truncated for column 'col_time' at row 1 +Warning 1265 Data truncated for column 'col_time_key' at row 1 +Warning 1265 Data truncated for column 'col_datetime' at row 4 +Warning 1265 Data truncated for column 'col_time_key' at row 5 +Warning 1265 Data truncated for column 'col_datetime_key' at row 6 +Warning 1265 Data truncated for column 'col_datetime' at row 6 +Warning 1265 Data truncated for column 'col_date' at row 7 +Warning 1265 Data truncated for column 'col_datetime' at row 7 +Warning 1265 Data truncated for column 'col_date' at row 8 +Warning 1265 Data truncated for column 'col_datetime' at row 10 +Warning 1265 Data truncated for column 'col_date_key' at row 11 +Warning 1265 Data truncated for column 'col_time_key' at row 11 +Warning 1265 Data truncated for column 'col_time' at row 12 +Warning 1265 Data truncated for column 'col_time_key' at row 12 +Warning 1265 Data truncated for column 'col_datetime' at row 12 +Warning 1265 Data truncated for column 'col_date' at row 13 +Warning 1265 Data truncated for column 'col_time' at row 13 +Warning 1265 Data truncated for column 'col_datetime' at row 14 +Warning 1265 Data truncated for column 'col_date_key' at row 15 +Warning 1265 Data truncated for column 'col_time' at row 15 +Warning 1265 Data truncated for column 'col_time_key' at row 16 +Warning 1265 Data truncated for column 'col_date' at row 17 +Warning 1265 Data truncated for column 'col_date_key' at row 17 +Warning 1265 Data truncated for column 'col_date' at row 18 +Warning 1265 Data truncated for column 'col_date_key' at row 19 +Warning 1265 Data truncated for column 'col_time' at row 19 +Warning 1265 Data truncated for column 'col_time_key' at row 19 +Warning 1265 Data truncated for column 'col_date' at row 20 +CREATE TABLE cc ( +col_date date, +col_int int, +col_int_key int, +col_varchar_key varchar (1), +col_datetime_key datetime, +col_datetime datetime, +pk integer auto_increment, +col_varchar varchar (1), +col_time_key time, +col_time time, +col_date_key date, +key (col_int_key ), +key (col_varchar_key ), +key (col_datetime_key ), +primary key (pk), +key (col_time_key ), +key (col_date_key )) ENGINE=innodb; +ALTER TABLE cc DISABLE KEYS; +Warnings: +Note 1031 Table storage engine for 'cc' doesn't have this option +INSERT IGNORE INTO cc VALUES +('2006-06-04', 3, 0, 'y', '2006-04-12 00:44:48.055959', NULL, NULL, 'l', +'2005-01-10', '2004', '2004-07-14'), +('2008', 6, 8, NULL, '2006-10-23', NULL, NULL, 'a', NULL, NULL, '2000-04-26'), +('2009-06-11', NULL, 9, 'w', '2008', '2005', NULL, 'q', '04:42:05.061538', +'2004-08-18', NULL), +('2007-03-01', 4, 7, 'f', NULL, '2000-10-06 15:26:40.040137', NULL, 'd', +'2008', '2006-11-17', '2006'), +('2001-02-08', 4, 210, 'j', '2003-11-14 04:26:34.047333', NULL, NULL, 'h', +'06:13:13.012974', '02:20:21.050151', '2006-08-20'), +('2000', 9, 5, 'b', '2006-12-16', NULL, NULL, 'z', '2000-09-09', '2007-06-15', +'2008'), +(NULL, 1, 6, 'z', '2007-12-10 00:57:04.007939', NULL, NULL, 'i', '2002-02-11', +'2004', '2006-08-08'), +('2007', NULL, 1, 'w', '2007-09-03 21:11:14.028959', '2009', NULL, 'n', +'2009-05-03', '2005-06-23', NULL), +(NULL, 4, NULL, 'f', '2007-04-12', NULL, NULL, 'f', '2007-12-01', '2006', +'2000-05-11'), +('2008', 7, 1, 's', NULL, NULL, NULL, 'o', '2002', '2003', '2009-12-03'), +(NULL, 5, 62, 'i', '2009-10-06 12:22:10.055548', '2003', NULL, 'p', NULL, +NULL, '2006-02-03'), +('2006-02-10', 4, 9, 'g', NULL, '2000-07-26 23:20:24.031805', NULL, 'c', +'2007-12-12', '2002', '2003'), +('2000', 5, 0, 'j', '2000-02-23', '2000', NULL, 'a', '2005', '2000-04-15', +'2000-09-19'), +(NULL, 2, 9, 'q', '2003-12-24', NULL, NULL, NULL, NULL, '2000', '2008-05-23'), +(NULL, 9, NULL, 'i', '2003-10-22 02:03:47.003490', '2006-01-03', NULL, 'b', +NULL, '2003', '2008-01-21'), +('2008-06-09', 9, 0, 'a', '2000', NULL, NULL, 'c', '21:15:46.049912', '2001', +NULL), +('2000', 2, 8, NULL, '2009-11-27', NULL, NULL, NULL, '2004-05-08', +'12:30:30.041709', '2005-12-01'), +('2009-03-27', 3, 0, 'l', '2009', '2009', NULL, 'a', NULL, '04:16:53.049190', +NULL), +('2008-08-26', 114, 3, 'o', '2008-03-06', NULL, NULL, 'k', '07:26:47.018798', +'2002-08-17', '2004-09-07'), +(NULL, 8, 7, 'm', '2007-12-28 23:49:04.022501', '2005-04-08', NULL, 't', +'2000-11-12', '22:19:29.060590', '2005-09-20'); +Warnings: +Warning 1265 Data truncated for column 'col_time_key' at row 1 +Warning 1265 Data truncated for column 'col_date' at row 2 +Warning 1265 Data truncated for column 'col_datetime_key' at row 3 +Warning 1265 Data truncated for column 'col_datetime' at row 3 +Warning 1265 Data truncated for column 'col_time' at row 3 +Warning 1265 Data truncated for column 'col_time' at row 4 +Warning 1265 Data truncated for column 'col_date_key' at row 4 +Warning 1265 Data truncated for column 'col_date' at row 6 +Warning 1265 Data truncated for column 'col_time_key' at row 6 +Warning 1265 Data truncated for column 'col_time' at row 6 +Warning 1265 Data truncated for column 'col_date_key' at row 6 +Warning 1265 Data truncated for column 'col_time_key' at row 7 +Warning 1265 Data truncated for column 'col_date' at row 8 +Warning 1265 Data truncated for column 'col_datetime' at row 8 +Warning 1265 Data truncated for column 'col_time_key' at row 8 +Warning 1265 Data truncated for column 'col_time' at row 8 +Warning 1265 Data truncated for column 'col_time_key' at row 9 +Warning 1265 Data truncated for column 'col_date' at row 10 +Warning 1265 Data truncated for column 'col_datetime' at row 11 +Warning 1265 Data truncated for column 'col_time_key' at row 12 +Warning 1265 Data truncated for column 'col_date_key' at row 12 +Warning 1265 Data truncated for column 'col_date' at row 13 +Warning 1265 Data truncated for column 'col_datetime' at row 13 +Warning 1265 Data truncated for column 'col_time' at row 13 +Warning 1265 Data truncated for column 'col_datetime_key' at row 16 +Warning 1265 Data truncated for column 'col_date' at row 17 +Warning 1265 Data truncated for column 'col_time_key' at row 17 +Warning 1265 Data truncated for column 'col_datetime_key' at row 18 +Warning 1265 Data truncated for column 'col_datetime' at row 18 +Warning 1265 Data truncated for column 'col_time' at row 19 +Warning 1265 Data truncated for column 'col_time_key' at row 20 +ALTER TABLE cc ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 'cc' doesn't have this option +ANALYZE TABLE c, cc; +Table Op Msg_type Msg_text +test.c analyze status OK +test.cc analyze status OK +EXPLAIN FORMAT=tree SELECT +alias1.pk AS field1 +FROM +( +SELECT +sq1_alias2.* +FROM +cc AS sq1_alias1 +RIGHT JOIN cc AS sq1_alias2 ON +sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key +LIMIT +100 +) +AS alias1 +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar_key AS sq2_field1 +FROM +(cc AS sq2_alias1, c AS sq2_alias2) +WHERE +sq2_alias1.col_varchar_key != alias1.col_varchar +) +GROUP BY +field1 +HAVING +field1 != 'pg' +ORDER BY +alias1.col_int_key DESC, field1 +LIMIT 2 OFFSET 2; +EXPLAIN +-> Limit/Offset: 2/2 row(s) + -> Sort: alias1.col_int_key DESC, alias1.pk + -> Filter: (field1 <> 0) + -> Table scan on (cost=0.02..14.19 rows=936) + -> Temporary table with deduplication (cost=207.92..222.09 rows=936) + -> Remove duplicate alias1 rows using temporary table (weedout) (cost=114.30 rows=936) + -> Inner hash join (no condition) (cost=114.30 rows=936) + -> Index scan on sq2_alias2 using col_date_key (cost=1.93 rows=20) + -> Hash + -> Nested loop inner join (cost=20.45 rows=47) + -> Filter: (sq2_alias1.col_varchar_key is not null) (cost=2.25 rows=20) + -> Index scan on sq2_alias1 using col_varchar_key (cost=2.25 rows=20) + -> Filter: (sq2_alias1.col_varchar_key <> alias1.col_varchar) (cost=7.49..0.66 rows=2) + -> Index lookup on alias1 using (col_varchar_key=sq2_alias1.col_varchar_key) + -> Materialize (cost=12.59..12.59 rows=27) + -> Limit: 100 row(s) (cost=9.92 rows=27) + -> Nested loop left join (cost=9.92 rows=27) + -> Table scan on sq1_alias2 (cost=2.25 rows=20) + -> Index lookup on sq1_alias1 using col_varchar_key (col_varchar_key=sq1_alias2.col_varchar_key) (cost=0.26 rows=1) + +Warnings: +Note 1276 Field or reference 'alias1.col_varchar' of SELECT #3 was resolved in SELECT #1 +Warning 1292 Truncated incorrect DOUBLE value: 'pg' +SELECT +alias1.pk AS field1 +FROM +( +SELECT +sq1_alias2.* +FROM +cc AS sq1_alias1 +RIGHT JOIN cc AS sq1_alias2 ON +sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key +LIMIT +100 +) +AS alias1 +WHERE +alias1.col_varchar_key +IN ( +SELECT +sq2_alias1.col_varchar_key AS sq2_field1 +FROM +(cc AS sq2_alias1, c AS sq2_alias2) +WHERE +sq2_alias1.col_varchar_key != alias1.col_varchar +) +GROUP BY +field1 +HAVING +field1 != 'pg' +ORDER BY +alias1.col_int_key DESC, field1 +LIMIT 2 OFFSET 2; +field1 +3 +12 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'pg' +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'col_date' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime_key' at row 1 +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'col_datetime' at row 1 +DROP TABLE c, cc; +# +# Bug#30119783 SIG11 IN +# HASH_JOIN_BUFFER::STOREFROMTABLEBUFFERS|SQL/HASH_JOIN_BUFFER.CC +# +CREATE TABLE b(pk INT PRIMARY KEY, col_varchar VARCHAR(1)); +CREATE TABLE cc(pk INT PRIMARY KEY, col_varchar VARCHAR(1)); +INSERT INTO b VALUES (1, '4'); +INSERT INTO cc VALUES (1, 'c'), (2, 'c'); +EXPLAIN FORMAT=tree SELECT +table1.col_varchar +FROM +( +SELECT +subquery1_t1.* +FROM +b AS subquery1_t1 +INNER JOIN cc AS subquery1_t2 ON +subquery1_t1.col_varchar = subquery1_t2.col_varchar +) +AS table1 +LEFT JOIN ( +SELECT +col_varchar +FROM +cc AS subquery2_t1 +GROUP BY +subquery2_t1.col_varchar +) +AS table2 ON +table2.col_varchar = table1.col_varchar +AND table1.col_varchar +IN ( +SELECT +lower(subquery3_t1.pk) AS subquery3_field1 +FROM +b AS subquery3_t1 +); +EXPLAIN +-> Nested loop left join (cost=1.50 rows=2) + -> Inner hash join (subquery1_t2.col_varchar = subquery1_t1.col_varchar) (cost=0.80 rows=1) + -> Table scan on subquery1_t2 (cost=0.35 rows=2) + -> Hash + -> Table scan on subquery1_t1 (cost=0.35 rows=1) + -> Nested loop semijoin (cost=3.83 rows=2) + -> Index lookup on table2 using (col_varchar=subquery1_t1.col_varchar) + -> Materialize (cost=3.38..3.38 rows=2) + -> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on subquery2_t1 (cost=0.45 rows=2) + -> Filter: (subquery1_t1.col_varchar = lower(subquery3_t1.pk)) (cost=0.18 rows=1) + -> Index scan on subquery3_t1 using PRIMARY (cost=0.18 rows=1) + +SELECT +table1.col_varchar +FROM +( +SELECT +subquery1_t1.* +FROM +b AS subquery1_t1 +INNER JOIN cc AS subquery1_t2 ON +subquery1_t1.col_varchar = subquery1_t2.col_varchar +) +AS table1 +LEFT JOIN ( +SELECT +col_varchar +FROM +cc AS subquery2_t1 +GROUP BY +subquery2_t1.col_varchar +) +AS table2 ON +table2.col_varchar = table1.col_varchar +AND table1.col_varchar +IN ( +SELECT +lower(subquery3_t1.pk) AS subquery3_field1 +FROM +b AS subquery3_t1 +); +col_varchar +DROP TABLE b, cc; +# +# Bug#30049083 [REGRESSION]REPLACE/INSERT WITH LIMIT TAKING MORE TIME AND +# SPACE +# +# If the query has a LIMIT, the hash join should not spill to disk. Note +# that if the query contains either grouping or sorting, we allow spill +# to disk even if the query contains a LIMIT. +CREATE TABLE t1 (col1 BIGINT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +INSERT INTO t1 SELECT col1 + 256 FROM t1; +INSERT INTO t1 SELECT col1 + 512 FROM t1; +CREATE TABLE t2 SELECT col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 2048; +# This should spill to disk since we do not have any LIMIT. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +# This should NOT spill to disk since we have a LIMIT. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1 LIMIT 1; +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +0 +# This should spill to disk since we have sorting. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT * FROM t1, t2 WHERE t1.col1 = t2.col1 ORDER BY t1.col1 LIMIT 1; +col1 col1 +1 1 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +# This should spill to disk since we have (implicit) grouping. +TRUNCATE performance_schema.file_summary_by_event_name; +SELECT SUM(t1.col1) FROM t1, t2 WHERE t1.col1 = t2.col1 LIMIT 10; +SUM(t1.col1) +524800 +SELECT COUNT_STAR > 0 FROM performance_schema.file_summary_by_event_name +WHERE event_name LIKE '%hash_join%'; +COUNT_STAR > 0 +1 +SET join_buffer_size = DEFAULT; +DROP TABLE t1,t2; +# +# Bug#30214767 SIG11 AT QUICK_INDEX_MERGE_SELECT::GET_NEXT | +# SQL/OPT_RANGE.CC +# +# Set up a query with hash join, where the build input uses an index +# range scan with index merge sort-union. Also, a LIMIT greater than +# the number of rows satisfying the join condition is needed to +# reproduce the bug. What we want to achieve is to get the hash join +# to call Read() on the build input after it has returned EOF. This can +# be triggered by using LIMIT, as this causes the hash join to go back +# and read from the build input after the probe iterator has returned +# EOF (see comment on HashJoinIterator regarding spill to disk and LIMIT +# for more details around this). +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 ( +col1 INTEGER, +col2 INTEGER, +col3 INTEGER, +INDEX idx_a (col2), +INDEX idx_b (col3)); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1, 1, 1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(t2, t1) INDEX_MERGE(t2) */ t1.col1 +FROM t1 +JOIN t2 ON t1.col1 = t2.col1 +WHERE t2.col2 > 0 OR t2.col3 > 0 LIMIT 10; +EXPLAIN +-> Limit: 10 row(s) (cost=1.86 rows=1) + -> Inner hash join (t1.col1 = t2.col1) (cost=1.86 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Hash + -> Filter: ((t2.col2 > 0) or (t2.col3 > 0)) (cost=1.51 rows=1) + -> Index range scan on t2 using sort_union(idx_a,idx_b) (cost=1.51 rows=1) + +SELECT /*+ JOIN_ORDER(t2, t1) INDEX_MERGE(t2) */ t1.col1 +FROM t1 +JOIN t2 ON t1.col1 = t2.col1 +WHERE t2.col2 > 0 OR t2.col3 > 0 LIMIT 10; +col1 +1 +DROP TABLE t1, t2; +# +# Bug#30224582 ASSERTION `M_INDEX_CURSOR.IS_POSITIONED()' FAILED +# +# Set up a query where the hash join build input consists of a +# materialized table, where we do an index lookup on the materialized +# table. The LIMIT is also needed in order to trigger a second build +# phase in the hash join. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(table1, t2) */ +* +FROM +( +SELECT +DISTINCT t1.* +FROM +t1 +) AS table1 JOIN t2 +WHERE table1.col1 = 1 +LIMIT 50; +EXPLAIN +-> Limit: 50 row(s) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +SELECT /*+ JOIN_ORDER(table1, t2) */ +* +FROM +( +SELECT +DISTINCT t1.* +FROM +t1 +) AS table1 JOIN t2 +WHERE table1.col1 = 1 +LIMIT 50; +col1 col1 +1 1 +DROP TABLE t1, t2; +# +# Bug#30306279 ASAN: MEMCPY-PARAM-OVERLAP NEAR +# EXTRACT_VALUE_FOR_HASH_JOIN +# +# Set up a test where geometry data is written to chunk files on disk. +# Note that the test only fails with ASAN. +CREATE TABLE t1 (col1 GEOMETRY); +INSERT INTO t1 SELECT ST_GeomFromText(CONCAT('GEOMETRYCOLLECTION(POINT(1 1)', +REPEAT(',POINT(1 1)', 100), ')')); +INSERT INTO t1 SELECT ST_GeomFromText(CONCAT('GEOMETRYCOLLECTION(POINT(1 1)', +REPEAT(',POINT(1 1)', 100), ')')) FROM t1; +INSERT INTO t1 SELECT ST_GeomFromText(CONCAT('GEOMETRYCOLLECTION(POINT(1 1)', +REPEAT(',POINT(1 1)', 100), ')')) FROM t1; +SET join_buffer_size = 128; +SELECT * FROM t1 a JOIN t1 b ON a.col1 = b.col1; +SET join_buffer_size = DEFAULT; +DROP TABLE t1; +# +# Bug#30535541 HASH JOIN DOES NOT HANDLE PAD SPACE COLLATIONS CORRECTLY +# +# Test that hash join compares strings that only differs in end spaces +# equally in PAD SPACE collations. +CREATE TABLE t1 (c VARCHAR(255) COLLATE utf8mb4_bin); +CREATE TABLE t2 (c VARCHAR(255) COLLATE utf8mb4_bin); +INSERT INTO t1 VALUES ('foo'); +INSERT INTO t2 VALUES ('foo '); +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.c = t2.c; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.c = t1.c) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +SELECT * FROM t1 JOIN t2 ON t1.c = t2.c; +c c +foo foo +DROP TABLE t1, t2; +# +# Bug#30579922 INCORRECT RESULT IF HASH-JOIN ALGORITHM EXHAUST ITS +# JOIN_BUFFER +# +# Set up a query where the build input is a nested loop, where the inner +# side of the nested loop also has a filter. We want to see that if the +# hash join is not allowed to spill to disk, it will restore the last row +# read from the build iterator before doing a re-fill of the hash table. +CREATE TABLE t1 (i BIGINT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT i + POW(2, 0) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 1) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 2) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 3) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 4) FROM t1; +INSERT INTO t1 SELECT i + POW(2, 5) FROM t1; +CREATE TABLE t2 AS SELECT i FROM t1; +CREATE TABLE t3 AS SELECT i + 60 AS i FROM t1; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET join_buffer_size = 128; +EXPLAIN FORMAT=tree SELECT /*+ NO_BNL(t2) JOIN_ORDER(t1, t2, t3) */ * FROM t1 +JOIN t2 ON t1.i > t2.i +JOIN t3 ON t2.i = t3.i; +EXPLAIN +-> Parallel scan on + -> Inner hash join (t3.i = t2.i) (cost=9217.75 rows=8737) + -> Table scan on t3 (cost=0.04 rows=64) + -> Hash + -> Nested loop inner join (cost=432.25 rows=1365) + -> PQblock scan on t1 (cost=6.65 rows=64) + -> Filter: (t1.i > t2.i) (cost=0.28 rows=21) + -> Table scan on t2 (cost=0.28 rows=64) + +SELECT /*+ NO_BNL(t2) JOIN_ORDER(t1, t2, t3) */ * FROM t1 +JOIN t2 ON t1.i > t2.i +JOIN t3 ON t2.i = t3.i; +i i i +62 61 61 +63 61 61 +63 62 62 +64 61 61 +64 62 62 +64 63 63 +SELECT /*+ NO_BNL(t2) JOIN_ORDER(t1, t2, t3) */ * FROM t1 +JOIN t2 ON t1.i > t2.i +JOIN t3 ON t2.i = t3.i LIMIT 1000; +i i i +62 61 61 +63 61 61 +63 62 62 +64 61 61 +64 62 62 +64 63 63 +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2, t3; +# +# Bug#30282693 SIG6 IN TEMPTABLE::HANDLER::POSITION() AT SRC/HANDLER.CC +# +# Create a query where we get a confluent weedout as the right side of an +# antijoin. Since a confluent weedout returns at most one row, the +# iterator executor will replace it with a LIMIT 1. Note that the test +# case is not easy to understand, but it is the smallest test case I +# could make that reproduces the bug. +CREATE TABLE t1 ( +col1 INTEGER, +KEY idx (col1) +); +CREATE TABLE t2 ( +col1 INTEGER, +KEY idx (col1) +); +INSERT INTO t2 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(const_table, t2, t1, t1_2) */ 1 FROM t2 +RIGHT OUTER JOIN (VALUES ROW(4), ROW(5)) AS const_table ON TRUE +WHERE NOT EXISTS ( +SELECT t1.col1 FROM t1 +INNER JOIN t1 AS t1_2 ON t1_2.col1 = t1.col1 +WHERE t1.col1 <> t2.col1 +) AND t2.col1 < 49; +EXPLAIN +-> Nested loop antijoin (cost=10.03 rows=34) + -> Inner hash join (no condition) (cost=6.38 rows=34) + -> Filter: (t2.col1 < 49) (cost=0.98 rows=17) + -> Index scan on t2 using idx (cost=0.98 rows=17) + -> Hash + -> Table scan on const_table (cost=1.26..2.52 rows=2) + -> Materialize (cost=1.46..2.73 rows=2) + -> Rows fetched before execution (cost=0.00 rows=2) + -> Limit: 1 row(s) (cost=8.61 rows=1) + -> Nested loop inner join (cost=8.61 rows=1) + -> Filter: (t1.col1 <> t2.col1) (cost=0.01 rows=1) + -> Index scan on t1 using idx (cost=0.01 rows=1) + -> Index lookup on t1_2 using idx (col1=t1.col1) (cost=0.25 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t2.col1' of SELECT #3 was resolved in SELECT #1 +SELECT /*+ JOIN_ORDER(const_table, t2, t1, t1_2) */ 1 FROM t2 +RIGHT OUTER JOIN (VALUES ROW(4), ROW(5)) AS const_table ON TRUE +WHERE NOT EXISTS ( +SELECT t1.col1 FROM t1 +INNER JOIN t1 AS t1_2 ON t1_2.col1 = t1.col1 +WHERE t1.col1 <> t2.col1 +) AND t2.col1 < 49; +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug#30626264 ASSERTS IN BASIC_ROW_ITERATORS.H:345: +# FAKESINGLEROWITERATOR::SETNULLROWFLAG +# +CREATE TABLE t1 ( +pk INTEGER +); +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9); +CREATE TABLE t3 ( +pk INTEGER +); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=tree SELECT ( +SELECT t1.pk +FROM t2 +LEFT JOIN t3 USING (pk) +JOIN t3 AS t4 USING (pk) +WHERE t2.pk = 9 +) FROM t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Filter: (t4.pk = 9) (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + -> Hash + -> Nested loop left join (cost=0.35 rows=1) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + -> Filter: (t3.pk = 9) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 +SELECT ( +SELECT t1.pk +FROM t2 +LEFT JOIN t3 USING (pk) +JOIN t3 AS t4 USING (pk) +WHERE t2.pk = 9 +) FROM t1; +( +SELECT t1.pk +FROM t2 +LEFT JOIN t3 USING (pk) +JOIN t3 AS t4 USING (pk) +WHERE t2.pk = 9 +) +NULL +NULL +DROP TABLE t1, t2, t3; +# See that non equi-join BNL are executed using hash join. +CREATE TABLE t1 (col1 INT); +CREATE TABLE t2 (col1 INT); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 < t2.col1; +EXPLAIN +-> Parallel scan on + -> Filter: (t1.col1 < t2.col1) (cost=0.70 rows=1) + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +# Semijoin. +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (t2.i = t1.i) (cost=0.83 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Table scan on t2 (cost=0.18 rows=2) + +SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2); +i +1 +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 INTEGER, col2 INTEGER); +CREATE TABLE t2 (col1 INTEGER, col2 INTEGER); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM t1 WHERE (t1.col1) IN +(SELECT t2.col1 FROM t2 WHERE t2.col2 < 3); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (t2.col1 = t1.col1) (cost=0.78 rows=1) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Filter: (t2.col2 < 3) (cost=0.23 rows=1) + -> Table scan on t2 (cost=0.23 rows=2) + +DROP TABLE t1, t2; +# Test a query where the optimizer will create a semijoin condition that +# is not an equi-join condition. These kind of conditions must be +# attached as "extra" conditions in the hash join iterator in order to +# produce correct results. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (3), (4), (5); +INSERT INTO t2 VALUES (2), (3), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 1 IN (SELECT t1.col1 = t2.col1 FROM t2); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (no condition), extra conditions: (1 = (t1.col1 = t2.col1)) (cost=2.50 rows=16) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Hash + -> Table scan on t2 (cost=0.65 rows=4) + +Warnings: +Note 1276 Field or reference 'test.t1.col1' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 WHERE 1 IN (SELECT t1.col1 = t2.col1 FROM t2); +col1 +3 +4 +DROP TABLE t1, t2; +# Exercise a test where we get multiple tables in the probe input. +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +CREATE TABLE t3(a INTEGER); +INSERT INTO t1 VALUES (0); +INSERT INTO t2 VALUES (0); +INSERT INTO t3 VALUES (0); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET optimizer_switch="materialization=off,duplicateweedout=off"; +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE (t1.a,t2.a) IN (SELECT a, a FROM t3); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (t3.a = t1.a) (cost=0.70 rows=1) + -> Inner hash join (t2.a = t1.a) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t3 (cost=0.35 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE (t1.a,t2.a) IN (SELECT a, a FROM t3); +a a +0 0 +SET optimizer_switch=DEFAULT; +DROP TABLE t1, t2, t3; +# See that semijoin with spill to disk works as expected. +CREATE TABLE t1 (col1 BIGINT, col2 BIGINT); +INSERT INTO t1 SELECT POW(2, 0), POW(2, 0); +INSERT INTO t1 +SELECT col1 + POW(2, 0), col2 + POW(2, 0) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 1), col2 + POW(2, 1) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 2), col2 + POW(2, 2) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 3), col2 + POW(2, 3) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 4), col2 + POW(2, 4) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 5), col2 + POW(2, 5) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 6), col2 + POW(2, 6) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 7), col2 + POW(2, 7) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 8), col2 + POW(2, 8) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 9), col2 + POW(2, 9) FROM t1; +CREATE TABLE t2 AS SELECT * FROM t1; +UPDATE t1 SET col2 = col1 + 1 WHERE MOD(col1, 2) = 0; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 1024; +SET optimizer_switch = "materialization=off"; +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash semijoin (t2.col1 = t1.col1) (cost=104883.37 rows=104858) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=3.27 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2); +SUM(t1.col1) SUM(t1.col2) +524800 525312 +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 <> t2.col2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash semijoin (t2.col1 = t1.col1), extra conditions: (t1.col2 <> t2.col2) (cost=104882.95 rows=94372) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=2.85 rows=1024) + +Warnings: +Note 1276 Field or reference 'test.t1.col2' of SELECT #2 was resolved in SELECT #1 +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 <> t2.col2); +SUM(t1.col1) SUM(t1.col2) +262656 263168 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# Set up a test case where hash join spills to disk, and the chunk files +# for the build input is too big to fit into memory. This causes the +# probe chunk file to be read multiple times. What we want to see is that +# if a row from the probe chunk file finds a match in the first part of +# the build chunk file, the row must not be sent to the client the second +# time the row is read from the probe chunk. Note that it is not trivial +# to set up a test case that is guaranteed to hit this case. +CREATE TABLE build (col1 BIGINT); +CREATE TABLE probe (col1 BIGINT); +INSERT INTO probe SELECT 1; +INSERT INTO probe SELECT col1 + POW(2, 0) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 1) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 2) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 3) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 4) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 5) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 6) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 7) FROM probe; +INSERT INTO build SELECT col1 FROM probe; +INSERT INTO build SELECT col1 * 2 FROM probe; +INSERT INTO build SELECT col1 * 3 FROM probe; +SELECT COUNT(*) AS expected_num_rows FROM probe; +expected_num_rows +256 +SET join_buffer_size = 128; +SET optimizer_switch="materialization=off"; +EXPLAIN FORMAT=tree SELECT COUNT(*) FROM probe WHERE col1 IN (SELECT col1 FROM build); +EXPLAIN +-> Aggregate: count(`COUNT(*)`) + -> Parallel scan on + -> Aggregate: + -> Hash semijoin (build.col1 = probe.col1) (cost=19669.28 rows=19661) + -> PQblock scan on probe (cost=25.85 rows=256) + -> Hash + -> Table scan on build (cost=3.73 rows=768) + +SELECT COUNT(*) FROM probe WHERE col1 IN (SELECT col1 FROM build); +COUNT(*) +256 +SET join_buffer_size = DEFAULT; +SET optimizer_switch = DEFAULT; +DROP TABLE build, probe; +# Using LIMIT in the query rejects hash join from spilling to disk, +# causing the probe input to be read multiple times if the build input +# does not fit in memory. This test case is somewhat similar to the +# above; see that we do not output rows from the probe input multiple +# times even if the probe input is read multiple times. +CREATE TABLE build (col1 BIGINT); +CREATE TABLE probe (col1 BIGINT); +INSERT INTO probe SELECT 1; +INSERT INTO probe SELECT col1 + POW(2, 0) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 1) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 2) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 3) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 4) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 5) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 6) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 7) FROM probe; +INSERT INTO build SELECT col1 FROM probe; +INSERT INTO build SELECT col1 FROM probe ORDER BY col1 DESC; +SET optimizer_switch = "materialization=off"; +SET join_buffer_size = 1024; +EXPLAIN FORMAT=tree SELECT * FROM probe WHERE col1 IN (SELECT * FROM build); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (build.col1 = probe.col1) (cost=13109.20 rows=13107) + -> PQblock scan on probe (cost=25.85 rows=256) + -> Hash + -> Table scan on build (cost=1.19 rows=512) + +SELECT * FROM probe WHERE col1 IN (SELECT * FROM build); +col1 +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +13 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +14 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +15 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +16 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +17 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +18 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +19 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +2 +20 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +21 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +22 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +23 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +24 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +25 +250 +251 +252 +253 +254 +255 +256 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +SELECT * FROM probe WHERE col1 IN (SELECT * FROM build) LIMIT 1000; +col1 +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +13 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +14 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +15 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +16 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +17 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +18 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +19 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +2 +20 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +21 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +22 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +23 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +24 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +25 +250 +251 +252 +253 +254 +255 +256 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE build, probe; +# +# Bug#30512118 WL#13476: ASSERTION FAILURE AT +# HASHJOINITERATOR::INITPROBEITERATOR() +# +# Execute a query that causes the hash join to do everything in memory +# with multiple refills of the hash table. This can be triggered when the +# build input does not fit in memory, and the iterator is not allowed to +# spill to disk due to LIMIT in the query. +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 SELECT UUID(); +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +CREATE TABLE t2 AS SELECT UUID() AS col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 128; +EXPLAIN FORMAT=tree SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +EXPLAIN +-> Limit: 1000 row(s) + -> Parallel scan on + -> Limit: 1000 row(s) (cost=1907.45 rows=1000) + -> Filter: (t1.col1 = t2.col1) (cost=1907.45 rows=1638) + -> Inner hash join ((t1.col1)=(t2.col1)) (cost=1907.45 rows=1638) + -> Table scan on t2 (cost=2.01 rows=128) + -> Hash + -> PQblock scan on t1 (cost=13.05 rows=128) + +SELECT * FROM t1 JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# Antijoin. +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (f1 INTEGER NOT NULL); +INSERT INTO t2 VALUES (1), (2), (3), (4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t2.f1 IS NULL; +EXPLAIN +-> Parallel scan on + -> Filter: (t2.f1 is null) (cost=1.97 rows=3) + -> Hash antijoin (t2.f1 = t1.f1) (cost=1.97 rows=3) + -> PQblock scan on t1 using PRIMARY (cost=0.55 rows=3) + -> Hash + -> Table scan on t2 (cost=0.22 rows=4) + +SELECT * FROM t1 LEFT JOIN t2 USING (f1) WHERE t2.f1 IS NULL; +f1 +DROP TABLE t1,t2; +# Set up a case where we get multiple antijoin conditions AND'ed together +# inside a is_not_null_compl. We want to see that the server is able to +# split these conditions and attach them as antijoin conditions to the +# hash join. +CREATE TABLE t1 ( +aid INTEGER NOT NULL, +bid INTEGER NOT NULL); +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1,1),(1,2),(2,1),(2,2); +INSERT INTO t2 VALUES (1,2),(2,2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 +WHERE t1.aid NOT IN (SELECT aid FROM t2 WHERE bid = t1.bid); +EXPLAIN +-> Parallel scan on + -> Hash antijoin (t2.bid = t1.bid), (t2.aid = t1.aid) (cost=1.28 rows=8) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Hash + -> Table scan on t2 (cost=0.23 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.bid' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 +WHERE t1.aid NOT IN (SELECT aid FROM t2 WHERE bid = t1.bid); +aid bid +1 1 +2 1 +DROP TABLE t1, t2; +# Check that hash antijoin can handle NULL values correctly. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (NULL); +EXPLAIN FORMAT=tree SELECT * FROM t1 +WHERE 1 IN (SELECT 1 FROM t2 WHERE t1.col1 = t2.col1) IS FALSE; +EXPLAIN +-> Parallel scan on + -> Hash antijoin (t2.col1 = t1.col1) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.col1' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 +WHERE 1 IN (SELECT 1 FROM t2 WHERE t1.col1 = t2.col1) IS FALSE; +col1 +NULL +DROP TABLE t1, t2; +# See that antijoin with spill to disk works. +CREATE TABLE t1 (col1 BIGINT NOT NULL, col2 BIGINT NOT NULL); +INSERT INTO t1 SELECT POW(2, 0), POW(2, 0); +INSERT INTO t1 +SELECT col1 + POW(2, 0), col2 + POW(2, 0) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 1), col2 + POW(2, 1) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 2), col2 + POW(2, 2) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 3), col2 + POW(2, 3) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 4), col2 + POW(2, 4) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 5), col2 + POW(2, 5) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 6), col2 + POW(2, 6) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 7), col2 + POW(2, 7) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 8), col2 + POW(2, 8) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 9), col2 + POW(2, 9) FROM t1; +CREATE TABLE t2 AS SELECT * FROM t1; +UPDATE t1 SET col2 = col1 + 1 WHERE MOD(col1, 2) = 0; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 1024; +SET optimizer_switch = "materialization=off"; +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash antijoin (t2.col1 = t1.col1) (cost=105002.50 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=123.65 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2); +SUM(t1.col1) SUM(t1.col2) +NULL NULL +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 < t2.col2); +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Hash antijoin (t2.col1 = t1.col1), extra conditions: (t1.col2 < t2.col2) (cost=105002.50 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=123.65 rows=1024) + +Warnings: +Note 1276 Field or reference 'test.t1.col2' of SELECT #2 was resolved in SELECT #1 +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 WHERE t1.col1 NOT IN +(SELECT t2.col1 FROM t2 WHERE t1.col2 < t2.col2); +SUM(t1.col1) SUM(t1.col2) +524800 525312 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# Set up an antijoin that spills to disk, and the probe chunk files are +# too big to fit in memory. This causes the hash join to read the probe +# chunk files in several smaller chunks, which in turn enables probe row +# saving. So this test tries to verify that on-disk antijoin with probe +# row saving works correctly. This is not the easiest scenario to set up +# correctly, and it is difficult to show that on-disk antijoin with probe +# row saving actually is triggered... +CREATE TABLE build (col1 BIGINT NOT NULL); +CREATE TABLE probe (col1 BIGINT NOT NULL); +INSERT INTO probe SELECT 1; +INSERT INTO probe SELECT col1 + POW(2, 0) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 1) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 2) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 3) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 4) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 5) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 6) FROM probe; +INSERT INTO probe SELECT col1 + POW(2, 7) FROM probe; +INSERT INTO build SELECT col1 FROM probe; +INSERT INTO build SELECT col1 * 2 FROM probe; +INSERT INTO build SELECT col1 * 3 FROM probe; +DELETE FROM build WHERE col1 = 254; +SET join_buffer_size = 128; +SET optimizer_switch="materialization=off"; +EXPLAIN FORMAT=tree SELECT * FROM probe WHERE col1 NOT IN (SELECT col1 FROM build); +EXPLAIN +-> Parallel scan on + -> Hash antijoin (build.col1 = probe.col1) (cost=*** rows=196096) + -> PQblock scan on probe (cost=*** rows=256) + -> Hash + -> Table scan on build (cost=*** rows=766) + +SELECT * FROM probe WHERE col1 NOT IN (SELECT col1 FROM build); +col1 +254 +SET join_buffer_size = DEFAULT; +SET optimizer_switch = DEFAULT; +DROP TABLE build, probe; +# Outer join. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1) (cost=0.63 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Hash + -> Table scan on t2 (cost=0.18 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +col1 col1 +1 1 +2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +CREATE TABLE t3 (col1 INTEGER); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT t1.col1, t2.col1, t3.col1 FROM t1 +LEFT JOIN ( +t2 LEFT JOIN t3 ON t2.col1 = t3.col1) +ON t2.col1 = t1.col1 +ORDER BY t1.col1, t2.col1, t3.col1; +EXPLAIN +-> Sort: t1.col1, t2.col1, t3.col1 + -> Stream results + -> Parallel scan on + -> Sort: t1.col1, t2.col1, t3.col1 + -> Stream results (cost=1.36 rows=6) + -> Left hash join (t2.col1 = t1.col1) (cost=1.36 rows=6) + -> PQblock scan on t1 (cost=0.55 rows=3) + -> Hash + -> Left hash join (t3.col1 = t2.col1) (cost=0.51 rows=2) + -> Table scan on t2 (cost=0.15 rows=2) + -> Hash + -> Table scan on t3 (cost=0.06 rows=1) + +SELECT t1.col1, t2.col1, t3.col1 FROM t1 +LEFT JOIN ( +t2 LEFT JOIN t3 ON t2.col1 = t3.col1) +ON t2.col1 = t1.col1 +ORDER BY t1.col1, t2.col1, t3.col1; +col1 col1 col1 +1 1 1 +2 2 NULL +3 NULL NULL +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (i INTEGER NOT NULL); +INSERT INTO t1 VALUES (0), (2), (3),(4); +CREATE TABLE t2 (i INTEGER NOT NULL); +INSERT INTO t2 VALUES (0), (1), (3),(4); +CREATE TABLE t3 (i INTEGER NOT NULL); +INSERT INTO t3 VALUES (0), (1), (2), (4); +CREATE TABLE t4 (i INTEGER NOT NULL); +INSERT INTO t4 VALUES (0), (1), (2), (3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.i = t1.i) (cost=34.36 rows=256) + -> PQblock scan on t1 (cost=0.65 rows=4) + -> Hash + -> Left hash join (t2.i = t3.i), (t3.i = t2.i) (cost=8.51 rows=64) + -> Table scan on t2 (cost=0.16 rows=4) + -> Hash + -> Left hash join (t4.i = t3.i) (cost=1.86 rows=16) + -> Table scan on t3 (cost=0.04 rows=4) + -> Hash + -> Table scan on t4 (cost=0.01 rows=4) + +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +CREATE TABLE t3 (col1 INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN (t2 INNER JOIN t3 ON t2.col1 = t3.col1) +ON t1.col1 = t2.col1; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1), (t3.col1 = t1.col1) (cost=1.05 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +# Set up a case where the join condition in a left join does not refer +# to any of the tables (degenerate join predicate). It will be attached +# as an "extra" condition on the hash join iterator. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON RAND() < -1; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition), extra conditions: (rand() < (-(1))) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON RAND() < -1; +col1 col1 +1 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER, col2 INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 1; +col1 col1 col2 +1 1 1 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 2; +col1 col1 col2 +1 1 2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 3; +col1 col1 col2 +1 1 3 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 4; +col1 col1 col2 +1 1 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 5; +col1 col1 col2 +1 1 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND t2.col2 = 6; +col1 col1 col2 +1 NULL NULL +DROP TABLE t1, t2; +# Run a query where we get a cached outer join condition (i.e. comparison +# between two constant values. The condition is evaluated once and then +# cached.). This condition must be placed as a condition below the +# hash join iterator, and not as a filter after it. +CREATE TABLE t1 (f1 INTEGER, f2 INTEGER); +INSERT INTO t1 VALUES (1,1), (2,2); +EXPLAIN FORMAT=tree SELECT +tt.t +FROM +(SELECT 'crash1' AS t, f2 FROM t1) AS tt +LEFT JOIN t1 ON tt.t = 'crash2' AND tt.f2 = t1.f2 +WHERE +tt.t = 'crash1'; +EXPLAIN +-> Left hash join (no condition) (cost=0.25 rows=0) + -> Table scan on t1 (cost=0.45 rows=2) + -> Hash + -> Zero rows (Impossible filter) (cost=0.00..0.00 rows=0) + +SELECT +tt.t +FROM +(SELECT 'crash1' AS t, f2 FROM t1) AS tt +LEFT JOIN t1 ON tt.t = 'crash2' AND tt.f2 = t1.f2 +WHERE +tt.t = 'crash1'; +t +crash1 +crash1 +DROP TABLE t1; +# Set up a query where the optimizer will attach an AND condition to ot3, +# where the AND condition is inside a trigger condition guard. +# Additionally, one of the conditions inside the AND condition is a join +# condition while the other is not. What we should see in EXPLAIN is that +# the hash join iterator uses one of these conditions as a join +# condition, while the other condition should be attached as an "extra" +# condition. +CREATE TABLE t1 (col1 INTEGER); +CREATE TABLE t2 (col1 INTEGER); +EXPLAIN FORMAT=tree +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 AND RAND() < RAND(); +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.col1 = t1.col1), extra conditions: (rand() < rand()) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +# See that outer join with spill to disk works. +CREATE TABLE t1 (col1 BIGINT NOT NULL, col2 BIGINT NOT NULL); +INSERT INTO t1 SELECT POW(2, 0), POW(2, 0); +INSERT INTO t1 +SELECT col1 + POW(2, 0), col2 + POW(2, 0) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 1), col2 + POW(2, 1) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 2), col2 + POW(2, 2) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 3), col2 + POW(2, 3) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 4), col2 + POW(2, 4) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 5), col2 + POW(2, 5) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 6), col2 + POW(2, 6) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 7), col2 + POW(2, 7) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 8), col2 + POW(2, 8) FROM t1; +INSERT INTO t1 +SELECT col1 + POW(2, 9), col2 + POW(2, 9) FROM t1; +CREATE TABLE t2 AS SELECT * FROM t1; +UPDATE t1 SET col2 = col1 + 1 WHERE MOD(col1, 2) = 0; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 1024; +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Left hash join (t2.col1 = t1.col1) (cost=104878.97 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=0.12 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1; +SUM(t1.col1) SUM(t1.col2) +524800 525312 +EXPLAIN FORMAT=tree SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 +LEFT JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +EXPLAIN +-> Aggregate: sum(`SUM(t1.col1)`), sum(`SUM(t1.col2)`) + -> Parallel scan on + -> Aggregate: + -> Left hash join (t2.col1 = t1.col1), extra conditions: (t1.col2 < t2.col2) (cost=104878.97 rows=1048576) + -> PQblock scan on t1 (cost=103.65 rows=1024) + -> Hash + -> Table scan on t2 (cost=0.12 rows=1024) + +SELECT SUM(t1.col1), SUM(t1.col2) FROM t1 +LEFT JOIN t2 ON t1.col1 = t2.col1 AND t1.col2 < t2.col2; +SUM(t1.col1) SUM(t1.col2) +524800 525312 +SET optimizer_switch = DEFAULT; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +EXPLAIN FORMAT=tree +SELECT * FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON ABS(t2.i) = t3.i) +ON t2.i = t1.i; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.i = t1.i) (cost=1.05 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Left hash join (abs(t2.i) = t3.i) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Hash + -> Table scan on t3 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +# See that we do not attach conditions that are always 'true' to the hash +# join iterator. +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=1; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2; +# Set up a query where the join condition is an equi-join condition, +# but it refers to only one side of the hash join (degenerate join +# predicate). This condition must be attached as an 'extra' condition +# (proper join conditions must refer to both sides of the join). +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +EXPLAIN FORMAT=tree +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON TRUE) ON t3.i = t2.i; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=1.05 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Hash + -> Filter: (t3.i = t2.i) (cost=0.70 rows=1) + -> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1, t2, t3; +# Execute a query that causes the hash join to do everything in memory +# with multiple refills of the hash table. This can be triggered when the +# build input does not fit in memory, and the iterator is not allowed to +# spill to disk due to LIMIT in the query. +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 SELECT UUID(); +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +INSERT INTO t1 SELECT UUID() FROM t1; +CREATE TABLE t2 AS SELECT UUID() AS col1 FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET join_buffer_size = 128; +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +EXPLAIN +-> Limit: 1000 row(s) + -> Parallel scan on + -> Limit: 1000 row(s) (cost=1896.50 rows=1000) + -> Left hash join ((t1.col1)=(t2.col1)), extra conditions: (t1.col1 = t2.col1) (cost=1896.50 rows=16384) + -> PQblock scan on t1 (cost=13.05 rows=128) + -> Hash + -> Table scan on t2 (cost=2.10 rows=128) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 LIMIT 1000; +SET join_buffer_size = DEFAULT; +DROP TABLE t1, t2; +# +# Bug #30631730: WL#13377: RESULT DIFF WITH LEFT HASH JOIN +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE alias1.pk NOT IN ( 20 ) ); +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=42.50 rows=400) + -> PQblock scan on alias1 using PRIMARY (cost=2.25 rows=20) + -> Hash antijoin (no condition) (cost=2.37 rows=20) + -> Index scan on alias2 using PRIMARY (cost=0.11 rows=20) + -> Hash + -> Limit: 1 row(s) (cost=0.11 rows=1) + -> Filter: (alias1.pk <> 20) (cost=0.11 rows=20) + -> Index scan on t1 using PRIMARY (cost=0.11 rows=20) + +Warnings: +Note 1276 Field or reference 'test.alias1.pk' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE alias1.pk NOT IN ( 20 ) ); +pk pk +1 NULL +10 NULL +11 NULL +12 NULL +13 NULL +14 NULL +15 NULL +16 NULL +17 NULL +18 NULL +19 NULL +2 NULL +20 1 +20 10 +20 11 +20 12 +20 13 +20 14 +20 15 +20 16 +20 17 +20 18 +20 19 +20 2 +20 20 +20 3 +20 4 +20 5 +20 6 +20 7 +20 8 +20 9 +3 NULL +4 NULL +5 NULL +6 NULL +7 NULL +8 NULL +9 NULL +DROP TABLE t1; +# +# Bug #30642968: WL#13377: RESULTSET DIFFERENCE WITH HASH ANTIJOIN +# +CREATE TABLE t1 (f1 INTEGER); +INSERT INTO t1 VALUES ( 100 ), ( 200 ); +EXPLAIN FORMAT=tree SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias2.f1 = alias1.f1 +AND NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE alias1.f1 <= 1 ); +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=1.10 rows=4) + -> PQblock scan on alias1 (cost=0.45 rows=2) + -> Filter: (alias2.f1 = alias1.f1) (cost=0.68 rows=2) + -> Hash antijoin (no condition) (cost=0.68 rows=2) + -> Table scan on alias2 (cost=0.23 rows=2) + -> Hash + -> Limit: 1 row(s) (cost=0.23 rows=1) + -> Filter: (alias1.f1 <= 1) (cost=0.23 rows=2) + -> Table scan on alias3 (cost=0.23 rows=2) + +Warnings: +Note 1276 Field or reference 'test.alias1.f1' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias2.f1 = alias1.f1 +AND NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE alias1.f1 <= 1 ); +f1 f1 +100 100 +200 200 +DROP TABLE t1; +# +# Bug #30650725: WL13476: RESULTSET DIFFERENCE WITH BKA +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_datetime datetime +); +INSERT INTO t1 VALUES (9,'1988-02-06 01:32:15'); +CREATE TABLE t2 ( +col_int_key int, +col_datetime datetime, +KEY idx_N_col_int_key (col_int_key) +); +INSERT INTO t2 VALUES (9,'2025-01-07 03:12:24'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET optimizer_switch='mrr=on,mrr_cost_based=off,batched_key_access=on'; +EXPLAIN FORMAT=tree SELECT * FROM +t1 AS table3 LEFT JOIN (t1 AS table1, t2 AS table2) ON table2.col_int_key=table3.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop left join + -> PQblock scan on table3 (cost=0.35 rows=1) + -> Batched key access inner join + -> Batch input rows + -> Table scan on table1 (cost=0.35 rows=1) + -> Multi-range index lookup on table2 using idx_N_col_int_key (col_int_key=table3.pk) + +SELECT * FROM +t1 AS table3 LEFT JOIN (t1 AS table1, t2 AS table2) ON table2.col_int_key=table3.pk; +pk col_datetime pk col_datetime col_int_key col_datetime +9 1988-02-06 01:32:15 9 1988-02-06 01:32:15 9 2025-01-07 03:12:24 +SET optimizer_switch=DEFAULT; +DROP TABLE t1, t2; +# +# Bug #30665042: WL#13476: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +pk INTEGER, +f1 varchar(1), +KEY i1 (pk) +); +INSERT INTO t1 VALUES (2,'x'); +INSERT INTO t1 VALUES (3,'x'); +INSERT INTO t1 VALUES (4,'x'); +INSERT INTO t1 VALUES (5,'x'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET optimizer_switch='mrr=on,mrr_cost_based=off,batched_key_access=on'; +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS table1 +LEFT JOIN ( +SELECT inner_t3.* FROM +t1 AS inner_t1 +JOIN t1 AS inner_t2 ON inner_t1.pk = inner_t2.pk +JOIN t1 AS inner_t3 ON inner_t1.f1 = inner_t2.f1 +) AS table2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE table2.pk >= 1 OR table1.f1 = 'G' + ); +EXPLAIN +-> Parallel scan on + -> Nested loop left join + -> PQblock scan on table1 (cost=0.65 rows=4) + -> Batched key access inner join + -> Batch input rows + -> Inner hash join (no condition) (cost=8.66 rows=64) + -> Table scan on inner_t1 (cost=0.04 rows=4) + -> Hash + -> Hash antijoin (no condition), extra conditions: ((inner_t3.pk >= 1) or (table1.f1 = 'G')) (cost=2.01 rows=16) + -> Table scan on inner_t3 (cost=0.16 rows=4) + -> Hash + -> Index scan on t1 using i1 (cost=0.16 rows=4) + -> Filter: (inner_t2.f1 = inner_t1.f1) + -> Multi-range index lookup on inner_t2 using i1 (pk=inner_t1.pk) + +Warnings: +Note 1276 Field or reference 'table2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.table1.f1' of SELECT #3 was resolved in SELECT #1 +SELECT * +FROM t1 AS table1 +LEFT JOIN ( +SELECT inner_t3.* FROM +t1 AS inner_t1 +JOIN t1 AS inner_t2 ON inner_t1.pk = inner_t2.pk +JOIN t1 AS inner_t3 ON inner_t1.f1 = inner_t2.f1 +) AS table2 ON NOT EXISTS ( +SELECT * FROM t1 WHERE table2.pk >= 1 OR table1.f1 = 'G' + ); +pk f1 pk f1 +2 x NULL NULL +3 x NULL NULL +4 x NULL NULL +5 x NULL NULL +SET optimizer_switch=DEFAULT; +DROP TABLE t1; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=0.25 rows=0) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Hash + -> Zero rows (Impossible filter) (cost=0.00..0.00 rows=0) + +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 > 3; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=2.90 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Hash + -> Filter: (t2.f1 > 3) (cost=0.15 rows=5) + -> Table scan on t2 (cost=0.15 rows=5) + +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.f1 > 3; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition), extra conditions: (t1.f1 > 3) (cost=2.90 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Hash + -> Table scan on t2 (cost=0.15 rows=5) + +DROP TABLE t1, t2; +# +# Bug #30664671: HASH JOINS : CRASH WITH COMPARING DIFFERENT CHARSET +# Bug #30664831: SEVERE PERFORMANCE REGRESSION JOINING ON MEDIUMTEXT COLUMNS! +# +CREATE TABLE t1 ( +a LONGTEXT COLLATE utf32_sinhala_ci +); +INSERT INTO t1 (a) VALUES ('abc'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT 1 FROM t1 JOIN t1 AS t2 ON t1.a=t2.a; +EXPLAIN +-> Filter: (t2.a = t1.a) (cost=0.72 rows=1) + -> Inner hash join ((t2.a)=(t1.a)) (cost=0.72 rows=1) + -> Table scan on t2 (cost=0.37 rows=1) + -> Hash + -> Table scan on t1 (cost=0.35 rows=1) + +SELECT 1 FROM t1 JOIN t1 AS t2 ON t1.a=t2.a; +1 +1 +EXPLAIN FORMAT=tree SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON t1.a=t2.a; +EXPLAIN +-> Left hash join ((t2.a)=(t1.a)), extra conditions: (t2.a = t1.a) (cost=0.73 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t2 (cost=0.37 rows=1) + +SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON t1.a=t2.a; +1 +1 +DROP TABLE t1; +# +# Bug#30716607 SIG11 IN WELL_FORMED_COPY_NCHARS() AT +# SQL-COMMON/SQL_STRING.CC +# Bug#30648809 HASH_JOIN_BUFFER::LOADINTOTABLEBUFFERS() HITS AN ASSERT +# AND CRASH +CREATE TABLE t1 ( +str_col VARCHAR(1) +); +CREATE TABLE t2 ( +i INTEGER, +str_col VARCHAR(1), +PRIMARY KEY (i), +KEY idx (str_col) +); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES ('r'), ('s'); +INSERT INTO t2 VALUES (9,'s'), (11,'o'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET sql_mode = ''; +EXPLAIN FORMAT=tree SELECT 1 FROM t1 RIGHT JOIN t2 ON t2.str_col = t1.str_col +WHERE (t1.str_col, t1.str_col) NOT IN ( +SELECT c1_1.str_col, MIN(c1_2.str_col) +FROM t2 AS c1_1 INNER JOIN t2 AS c1_2 STRAIGHT_JOIN t3 ON t3.i = c1_2.i +); +EXPLAIN +-> Filter: ((t1.str_col,t1.str_col),(select #2) is false) (cost=0.88 rows=4) + -> Left hash join (t1.str_col = t2.str_col) (cost=0.88 rows=4) + -> Index scan on t2 using idx (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.23 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) + -> Filter: ((outer_field_is_not_null, (((t1.str_col) = c1_1.str_col) or (c1_1.str_col is null)), true) and (outer_field_is_not_null, (((t1.str_col) = min(c1_2.str_col)) or (min(c1_2.str_col) is null)), true) and (outer_field_is_not_null, (c1_1.str_col), true) and (outer_field_is_not_null, (min(c1_2.str_col)), true)) + -> Aggregate: min(c1_2.str_col) + -> Inner hash join (t3.i = c1_2.i) (cost=1.75 rows=4) + -> Table scan on t3 (cost=0.09 rows=1) + -> Hash + -> Inner hash join (no condition) (cost=1.10 rows=4) + -> Index scan on c1_2 using idx (cost=0.23 rows=2) + -> Hash + -> Index scan on c1_1 using idx (cost=0.45 rows=2) + +SELECT 1 FROM t1 RIGHT JOIN t2 ON t2.str_col = t1.str_col +WHERE (t1.str_col, t1.str_col) NOT IN ( +SELECT c1_1.str_col, MIN(c1_2.str_col) +FROM t2 AS c1_1 INNER JOIN t2 AS c1_2 STRAIGHT_JOIN t3 ON t3.i = c1_2.i +); +SET sql_mode = DEFAULT; +DROP TABLE t1, t2, t3; +# +# Bug#30738687 CRASH IN HASHJOINCONDITION::HASHJOINCONDITION +# +CREATE TABLE t ( +c TEXT +); +EXPLAIN FORMAT=tree SELECT c FROM +( +SELECT 1 AS c FROM t AS a +RIGHT JOIN t AS b ON 1 +RIGHT JOIN t AS c ON 1 +RIGHT JOIN t AS d ON 1 +) AS z +NATURAL RIGHT JOIN t; +EXPLAIN +-> Left hash join (t.c = 1) (cost=1.83 rows=1) + -> Table scan on t (cost=0.35 rows=1) + -> Hash + -> Left hash join (no condition) (cost=1.46 rows=1) + -> Table scan on d (cost=0.37 rows=1) + -> Hash + -> Left hash join (no condition) (cost=1.10 rows=1) + -> Table scan on c (cost=0.37 rows=1) + -> Hash + -> Left hash join (no condition) (cost=0.73 rows=1) + -> Table scan on b (cost=0.37 rows=1) + -> Hash + -> Table scan on a (cost=0.37 rows=1) + +DROP TABLE t; +# +# Bug#30741679 ASSERTION `FALSE' IN EXTRACT_VALUE_FOR_HASH_JOIN +# Bug#30769883 HIT ASSERT IN +# ITEM_FUNC_EQ::APPEND_JOIN_KEY_FOR_HASH_JOIN() +# +CREATE TABLE t1 ( +a INTEGER, +b INTEGER +); +INSERT INTO t1 VALUES (1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 as table1 +WHERE (SELECT a, b FROM t1 WHERE table1.a <> 6) IN (SELECT a, b FROM t1); +EXPLAIN +-> Hash semijoin (no condition), extra conditions: ((select #2) = (t1.a,t1.b)) (cost=0.70 rows=1) + -> Table scan on table1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t1 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.a' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 as table1 +WHERE (SELECT a, b FROM t1 WHERE table1.a <> 6) IN (SELECT a, b FROM t1); +a b +1 1 +EXPLAIN FORMAT=tree SELECT * FROM t1 as table1 +WHERE (SELECT a FROM t1 WHERE table1.a <> 6) IN (SELECT a FROM t1); +EXPLAIN +-> Hash semijoin ((select #2) = (t1.a)) (cost=0.70 rows=1) + -> Table scan on table1 (cost=0.35 rows=1) + -> Hash + -> Table scan on t1 (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.a' of SELECT #2 was resolved in SELECT #1 +SELECT * FROM t1 as table1 +WHERE (SELECT a FROM t1 WHERE table1.a <> 6) IN (SELECT a FROM t1); +a b +1 1 +DROP TABLE t1; +# +# Bug#30792727 ERRORS WHEN BUILDING HASH TABLE FOR HASH JOIN NOT +# PROPAGATED +# +CREATE TABLE t (i INTEGER); +INSERT INTO t VALUES (1), (2); +EXPLAIN FORMAT=tree SELECT * FROM t t1, t t2 WHERE JSON_EXTRACT(t1.i, t1.i) = t2.i; +EXPLAIN +-> Inner hash join (json_extract(t1.i,t1.i) = t2.i) (cost=1.10 rows=2) + -> Table scan on t2 (cost=0.18 rows=2) + -> Hash + -> Table scan on t1 (cost=0.45 rows=2) + +SELECT * FROM t t1, t t2 WHERE JSON_EXTRACT(t1.i, t1.i) = t2.i; +ERROR 22032: Invalid data type for JSON data in argument 1 to function json_extract; a JSON string or JSON type is required. +SHOW ERRORS; +Level Code Message +Error 3146 Invalid data type for JSON data in argument 1 to function json_extract; a JSON string or JSON type is required. +DROP TABLE t; +# +# Bug #31102789 A PREDICATE THAT COMPARES 0 WITH -0 +# YIELDS AN INCORRECT RESULT +# +CREATE TABLE t0(c0 INT); +CREATE TABLE t1(c0 DOUBLE); +CREATE TABLE t2(c0 DOUBLE); +INSERT INTO t0 VALUES(0); +INSERT INTO t1 VALUES('-0'); +INSERT INTO t2 VALUES('+0'); +SELECT * FROM t0, t1 WHERE t0.c0 = t1.c0; +c0 c0 +0 -0 +SELECT * FROM t1, t2 WHERE t1.c0 = t2.c0; +c0 c0 +-0 0 +SELECT * FROM t0, t2 WHERE t0.c0 = t2.c0; +c0 c0 +0 0 +DROP TABLE t0, t1, t2; +# +# Bug #31376809: PERFORMANCE REGRESSION FROM 5.7->8.0, DUE TO ANTIJOIN OF NOT EXISTS SUBQUERY +# +CREATE TABLE t1 (a INTEGER NOT NULL, b INTEGER); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN ANALYZE SELECT t1.a FROM t1 LEFT JOIN t1 AS t2 ON TRUE WHERE t2.a IS NULL; +EXPLAIN +-> Parallel scan on (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Filter: (t2.a is null) (cost=1.30 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Hash antijoin (no condition) (cost=1.30 rows=1) (actual time=N.NNN..N.NNN rows=0 loops=1) + -> PQblock scan on t1 (cost=0.75 rows=5) (never executed) + -> Hash + -> Limit: 1 row(s) (cost=0.15 rows=1) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Table scan on t2 (cost=0.15 rows=5) (actual time=N.NNN..N.NNN rows=1 loops=1) + +DROP TABLE t1; +# +# Bug #31563414: REGRESSION: ITEM_FUNC_EQ::APPEND_JOIN_KEY_FOR_HASH_JOIN CONST: ASSERTION `FALSE' FAILED. +# +CREATE TABLE t1 (a INTEGER NOT NULL); +INSERT INTO t1 VALUES (1),(2),(3),(4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS a +LEFT JOIN t1 AS b ON FALSE +LEFT JOIN t1 AS c ON b.a=c.a; +EXPLAIN +-> Parallel scan on + -> Left hash join (no condition) (cost=0.25 rows=0) + -> Left hash join (no condition) (cost=0.25 rows=0) + -> PQblock scan on a (cost=0.65 rows=4) + -> Hash + -> Zero rows (Impossible filter) (cost=0.00..0.00 rows=0) + -> Hash + -> Zero rows (Join condition (c.a = b.a) requires pruned table) (cost=0.00..0.00 rows=0) + +SELECT * +FROM t1 AS a +LEFT JOIN t1 AS b ON FALSE +LEFT JOIN t1 AS c ON b.a=c.a; +a a a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +DROP TABLE t1; +# +# Bug #31940549: NEW MEMORY LEAK ON TRUNK RELATING TO HASHJOINITERATOR::BUILDHASHTABLE , OPEN_CACHED_FILE +# +SET join_buffer_size=32768; +CREATE TABLE t(a DOUBLE NOT NULL, b VARCHAR(15873) NOT NULL); +INSERT INTO t VALUES(1, REPEAT('abs',1000)); +INSERT INTO t VALUES(2, REPEAT('ajs',1000)); +INSERT INTO t VALUES(3, REPEAT('ajj',1000)); +INSERT INTO t VALUES(4, REPEAT('jjs',1000)); +INSERT INTO t SELECT * FROM t; +INSERT INTO t SELECT * FROM t; +SELECT +( +SELECT 1 FROM (SELECT t_outer.a) Z LEFT JOIN t +ON t.a > t.b LIMIT 1 +) FROM t AS t_outer; +( +SELECT 1 FROM (SELECT t_outer.a) Z LEFT JOIN t +ON t.a > t.b LIMIT 1 +) +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t; +SET join_buffer_size=DEFAULT; +# +# Bug #31832001 HASH JOIN MISMATCHES SIGNED AND UNSIGNED +# +CREATE TABLE t2 (c1 BIGINT NOT NULL); +CREATE TABLE t13 (c1 BIGINT UNSIGNED NOT NULL); +INSERT INTO t2 VALUES (-1),(1); +INSERT INTO t13 VALUES (18446744073709551615),(1); +SELECT * FROM t2 JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +1 1 +SELECT /*+ NO_BNL(t2,t13) */ * FROM t2 JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +1 1 +DROP TABLE t2, t13; +# +# Bug #32244974: SIG 6 IN HASHJOINITERATOR::READROWFROMPROBEITERATOR() AT HASH_JOIN_ITERATOR.CC +# +CREATE TABLE t1 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk INTEGER, +col_int INTEGER +); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t2 VALUES (1,6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT 1 +FROM +t1 AS alias1 +JOIN t2 AS alias2 ON alias1.col_int = alias2.col_int +JOIN t1 AS alias3 ON 1 +WHERE +( SELECT 1 UNION SELECT MAX(alias1.pk) ) = alias3.pk; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, t2; +# Bug#32579184: Hash join: my_lengthsp_utf32: assertion (length % 4) +CREATE TABLE t ( +a TEXT CHARACTER SET ucs2 COLLATE ucs2_sinhala_ci, +b TEXT CHARACTER SET utf32 COLLATE utf32_german2_ci +); +INSERT INTO t(a, b) VALUES('h','k'), ('w','e'); +explain SELECT 1 FROM t AS a INNER JOIN t AS b ON a.a=b.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` `a` join `test`.`t` `b` where (`test`.`a`.`a` = `test`.`b`.`b`) +SELECT 1 FROM t AS a INNER JOIN t AS b ON a.a=b.b; +1 +DROP TABLE t; diff --git a/mysql-test/r/having.result-pq b/mysql-test/r/having.result-pq new file mode 100644 index 000000000..3faefb8c0 --- /dev/null +++ b/mysql-test/r/having.result-pq @@ -0,0 +1,936 @@ +drop table if exists t1,t2,t3; +create table t1 (a int); +select count(a) as b from t1 where a=0 having b > 0; +b +insert into t1 values (null); +select count(a) as b from t1 where a=0 having b > 0; +b +select count(a) as b from t1 where a=0 having b >=0; +b +0 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select count(a) as b from t1 where a=0 having b >=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 0) having (`b` >= 0) +drop table t1; +CREATE TABLE t1 ( +raw_id int(10) NOT NULL default '0', +chr_start int(10) NOT NULL default '0', +chr_end int(10) NOT NULL default '0', +raw_start int(10) NOT NULL default '0', +raw_end int(10) NOT NULL default '0', +raw_ori int(2) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (469713,1,164123,1,164123,1),(317330,164124,317193,101,153170,1),(469434,317194,375620,101,58527,1),(591816,375621,484273,1,108653,1),(591807,484274,534671,91,50488,1),(318885,534672,649362,101,114791,1),(318728,649363,775520,102,126259,1),(336829,775521,813997,101,38577,1),(317740,813998,953227,101,139330,1),(1,813998,953227,101,139330,1); +CREATE TABLE t2 ( +id int(10) unsigned NOT NULL default '0', +contig_id int(10) unsigned NOT NULL default '0', +seq_start int(10) NOT NULL default '0', +seq_end int(10) NOT NULL default '0', +strand tinyint(2) NOT NULL default '0', +KEY id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (133195,469713,61327,61384,1),(133196,469713,64113,64387,1),(133197,1,1,1,0),(133197,1,1,1,-2); +SELECT e.id, +MIN( IF(sgp.raw_ori=1, +(e.seq_start+sgp.chr_start-sgp.raw_start), +(sgp.chr_start+sgp.raw_end-e.seq_end))) as start, +MAX( IF(sgp.raw_ori=1, +(e.seq_end+sgp.chr_start-sgp.raw_start), +(sgp.chr_start+sgp.raw_end-e.seq_start))) as end, +AVG(IF (sgp.raw_ori=1,e.strand,(-e.strand))) as chr_strand +FROM t1 sgp, +t2 e +WHERE sgp.raw_id=e.contig_id +GROUP BY e.id +HAVING chr_strand= -1 and end >= 0 +AND start <= 999660; +id start end chr_strand +133197 813898 813898 -1.0000 +drop table t1,t2; +CREATE TABLE t1 (Fld1 int(11) default NULL,Fld2 int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,10),(1,20),(2,NULL),(2,NULL),(3,50); +select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null; +Fld1 q +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null; +Fld1 max(Fld2) +1 20 +3 50 +drop table t1; +create table t1 (id int not null, qty int not null); +insert into t1 values (1,2),(1,3),(2,4),(2,5); +select id, sum(qty) as sqty from t1 group by id having sqty>2; +id sqty +1 5 +2 9 +select sum(qty) as sqty from t1 group by id having count(id) > 0; +sqty +5 +9 +select sum(qty) as sqty from t1 group by id having count(distinct id) > 0; +sqty +5 +9 +drop table t1; +CREATE TABLE t1 ( +`id` bigint(20) NOT NULL default '0', +`description` text +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +`id` bigint(20) NOT NULL default '0', +`description` varchar(20) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, 'test'); +INSERT INTO t2 VALUES (1, 'test'); +CREATE TABLE t3 ( +`id` bigint(20) NOT NULL default '0', +`order_id` bigint(20) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select +a.id, a.description, +count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +select +a.*, +count(b.id) as c +from t2 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +INSERT INTO t1 VALUES (2, 'test2'); +select +a.id, a.description, +count(b.id) as c +from t1 a left join t3 b on a.id=b.order_id +group by a.id, a.description +having (a.description is not null) and (c=0); +id description c +1 test 0 +2 test2 0 +drop table t1,t2,t3; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (4), (1), (3), (1); +SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a)>0; +SUM(a) +2 +4 +6 +SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a); +SUM(a) +2 +4 +6 +DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1); +SELECT a FROM t1 GROUP BY a HAVING a > 1; +a +2 +3 +SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +a +SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; +x a +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having false +EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +Warnings: +Note 1003 /* select#1 */ select 0 AS `x`,`test`.`t1`.`a` AS `a` from `test`.`t1` group by `x`,`test`.`t1`.`a` having false +DROP table t1; +CREATE TABLE t1 (a int PRIMARY KEY); +CREATE TABLE t2 (b int PRIMARY KEY, a int); +CREATE TABLE t3 (b int, flag int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1), (3,1); +INSERT INTO t3(b,flag) VALUES (2, 1); +SELECT t1.a +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0; +a +SELECT DISTINCT t1.a, MAX(t3.flag) +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0; +a MAX(t3.flag) +SELECT DISTINCT t1.a +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0; +a +DROP TABLE t1,t2,t3; +create table t1 (col1 int, col2 varchar(5), col_t1 int); +create table t2 (col1 int, col2 varchar(5), col_t2 int); +create table t3 (col1 int, col2 varchar(5), col_t3 int); +insert into t1 values(10,'hello',10); +insert into t1 values(20,'hello',20); +insert into t1 values(30,'hello',30); +insert into t1 values(10,'bye',10); +insert into t1 values(10,'sam',10); +insert into t1 values(10,'bob',10); +insert into t2 select * from t1; +insert into t3 select * from t1; +select count(*) from t1 group by col1 having col1 = 10; +count(*) +4 +select count(*) as count_col1 from t1 group by col1 having col1 = 10; +count_col1 +4 +select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10; +count_col1 +4 +select count(*) from t1 group by col2 having col2 = 'hello'; +count(*) +3 +select count(*) from t1 group by col2 having col1 = 10; +ERROR 42S22: Unknown column 'col1' in 'having clause' +select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10; +count_col1 +10 +select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10; +count_col1 +10 +select col1 as count_col1 from t1 as tmp1 group by count_col1 having col1 = 10; +count_col1 +10 +select col1 as count_col1 from t1 as tmp1 group by count_col1 having count_col1 = 10; +count_col1 +10 +select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col1 = 10; +count_col1 col2 +10 bob +10 bye +10 hello +10 sam +select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10; +count_col1 col2 +10 bob +10 bye +10 hello +10 sam +select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello'; +count_col1 col2 +10 hello +20 hello +30 hello +select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello'; +count_col1 group_col2 +10 hello +20 hello +30 hello +select sum(col1) as co12 from t1 group by col2 having col2 10; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10' at line 1 +select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10; +co2 cc +40 4 +select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10; +ERROR 42S22: Unknown column 't1.col1' in 'having clause' +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having t2.col1 <= 10); +col1 +10 +20 +30 +10 +10 +10 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 +having t2.col1 <= +(select min(t3.col1) from t3)); +col1 +10 +20 +30 +10 +10 +10 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having t1.col1 <= 10); +col1 +10 +10 +10 +10 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having col_t1 <= 10); +col1 +10 +10 +10 +10 +select sum(col1) from t1 +group by col_t1 +having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1); +sum(col1) +40 +20 +30 +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having col_t1 <= 10) +having col_t1 <= 20; +ERROR 42S22: Unknown column 'col_t1' in 'having clause' +select t1.col1 from t1 +where t1.col2 in +(select t2.col2 from t2 +group by t2.col1, t2.col2 having col_t1 <= 10) +group by col_t1 +having col_t1 <= 20; +col1 +10 +select col_t1, sum(col1) from t1 +group by col_t1 +having col_t1 > 10 and +exists (select sum(t2.col1) from t2 +group by t2.col2 having t2.col2 > 'b'); +col_t1 sum(col1) +20 20 +30 30 +select sum(col1) from t1 +group by col_t1 +having col_t1 in (select sum(t2.col1) from t2 +group by t2.col2, t2.col1 having t2.col1 = t1.col1); +ERROR 42S22: Unknown column 't1.col1' in 'having clause' +select sum(col1) from t1 +group by col_t1 +having col_t1 in (select sum(t2.col1) from t2 +group by t2.col2, t2.col1 having t2.col1 = col_t1); +sum(col1) +40 +20 +30 +select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1 +group by t1.col1, t2.col1 having col1 = 2; +ERROR 23000: Column 'col1' in having clause is ambiguous +select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1 +group by t1.col1, t2.col1 having col1 = 2; +ERROR 23000: Column 'col1' in having clause is ambiguous +drop table t1, t2, t3; +create table t1 (s1 int); +insert into t1 values (1),(2),(3); +select count(*) from t1 group by s1 having s1 is null; +count(*) +select s1*0 as s1 from t1 group by s1 having s1 <> 0; +s1 +0 +0 +0 +Warnings: +Warning 1052 Column 's1' in group statement is ambiguous +Warning 1052 Column 's1' in having clause is ambiguous +Warning 1052 Column 's1' in having clause is ambiguous +Warning 1052 Column 's1' in having clause is ambiguous +select s1*0 from t1 group by s1 having s1 = 0; +s1*0 +select s1 from t1 group by 1 having 1 = 0; +s1 +select count(s1) from t1 group by s1 having count(1+1)=2; +count(s1) +select count(s1) from t1 group by s1 having s1*0=0; +count(s1) +1 +1 +1 +select * from t1 a, t1 b group by a.s1 having s1 is null; +ERROR 23000: Column 's1' in having clause is ambiguous +drop table t1; +set names latin1; +create table t1 (s1 char character set latin1 collate latin1_german1_ci); +insert ignore into t1 values ('ü'),('y'); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select s1,count(s1) from t1 +group by s1 collate latin1_swedish_ci having s1 = 'y'; +s1 count(s1) +y 1 +set names utf8mb4; +drop table t1; +DROP SCHEMA IF EXISTS HU; +CREATE SCHEMA HU ; +USE HU ; +CREATE TABLE STAFF +(EMPNUM CHAR(3) NOT NULL UNIQUE, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE PROJ +(PNUM CHAR(3) NOT NULL UNIQUE, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale'); +INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO STAFF VALUES ('E4','Don',12,'Deale'); +INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron'); +INSERT INTO PROJ VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO PROJ VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO PROJ VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO PROJ VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO PROJ VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO PROJ VALUES ('P6','PAYR','Design',50000,'Deale'); +SELECT EMPNUM, GRADE*1000 +FROM HU.STAFF WHERE GRADE * 1000 > +ANY (SELECT SUM(BUDGET) FROM HU.PROJ +GROUP BY CITY, PTYPE +HAVING HU.PROJ.CITY = HU.STAFF.CITY); +EMPNUM GRADE*1000 +E3 13000 +DROP SCHEMA HU; +USE test; +create table t1(f1 int); +select f1 from t1 having max(f1)=f1; +f1 +select f1 from t1 group by f1 having max(f1)=f1; +f1 +set session sql_mode='ONLY_FULL_GROUP_BY'; +select f1 from t1 having max(f1)=f1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.f1'; this is incompatible with sql_mode=only_full_group_by +select f1 from t1 group by f1 having max(f1)=f1; +f1 +set session sql_mode=''; +drop table t1; +CREATE TABLE t1 ( a INT, b INT); +INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL); +SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL; +b COUNT(DISTINCT a) +NULL 1 +DROP TABLE t1; +# +# Bug#50995 Having clause on subquery result produces incorrect results. +# +CREATE TABLE t1 +( +id1 INT, +id2 INT NOT NULL, +INDEX id1(id2) +); +INSERT INTO t1 SET id1=1, id2=1; +INSERT INTO t1 SET id1=2, id2=1; +INSERT INTO t1 SET id1=3, id2=1; +SELECT t1.id1, +(SELECT 0 FROM DUAL +WHERE t1.id1=t1.id1) AS amount FROM t1 +WHERE t1.id2 = 1 +HAVING amount > 0 +ORDER BY t1.id1; +id1 amount +DROP TABLE t1; +# +# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause +# +CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT, f3 INT); +INSERT INTO t1 VALUES (2,7,9), (4,7,9), (6,2,9), (17,0,9); +SELECT table1.f1, table2.f2 +FROM t1 AS table1 +JOIN t1 AS table2 ON table1.f3 = table2.f3 +WHERE table2.f1 = 2 +GROUP BY table1.f1, table2.f2 +HAVING (table2.f2 = 8 AND table1.f1 >= 6); +f1 f2 +EXPLAIN +SELECT table1.f1, table2.f2 +FROM t1 AS table1 +JOIN t1 AS table2 ON table1.f3 = table2.f3 +WHERE table2.f1 = 2 +GROUP BY table1.f1, table2.f2 +HAVING (table2.f2 = 8 AND table1.f1 >= 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having false +EXPLAIN +SELECT table1.f1, table2.f2 +FROM t1 AS table1 +JOIN t1 AS table2 ON table1.f3 = table2.f3 +WHERE table2.f1 = 2 +GROUP BY table1.f1, table2.f2 +HAVING (table2.f2 = 8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having false +DROP TABLE t1; +# +# Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355 +# +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES (10,8); +CREATE TABLE t2 (f1 INT); +INSERT INTO t2 VALUES (5); +SELECT COUNT(f1) FROM t2 +HAVING (7, 9) IN (SELECT f1, MIN(f2) FROM t1); +COUNT(f1) +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t1 VALUES (16,'f'); +INSERT INTO t1 VALUES (16,'f'); +CREATE TABLE t2 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t2 VALUES (13,'f'); +INSERT INTO t2 VALUES (20,'f'); +CREATE TABLE t3 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t3 VALUES (7,'f'); +SELECT t1.f2 FROM t1 +STRAIGHT_JOIN (t2 JOIN t3 ON t3.f2 = t2.f2 ) ON t3 .f2 = t2 .f2 +HAVING ('v', 'i') NOT IN (SELECT f2, MIN(f2) FROM t1) +ORDER BY f2; +f2 +f +f +f +f +DROP TABLES t1,t2,t3; +# +# Bug#52340 Segfault: read_cached_record (tab=0x94a2634) at sql_select.cc:14411 +# +CREATE TABLE t1 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t1 VALUES (16,'d'); +CREATE TABLE t2 (f1 INT, f2 VARCHAR(1)); +INSERT INTO t2 VALUES (13,'e'); +INSERT INTO t2 VALUES (20,'d'); +SELECT MAX(t2.f2) FROM t2 JOIN t1 ON t1.f2 +HAVING ('e' , 'd') IN +(SELECT ts1.f2, ts2.f2 FROM t2 ts1 JOIN t2 ts2 ON ts1.f1) +ORDER BY t1.f2; +MAX(t2.f2) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'd' +DROP TABLE t1,t2; +End of 5.0 tests +# +# Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set +# +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'f'); +CREATE TABLE t2 (f1 INT(11), f2 VARCHAR(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2,'m'); +INSERT INTO t2 VALUES (3,'m'); +INSERT INTO t2 VALUES (11,NULL); +INSERT INTO t2 VALUES (12,'k'); +SELECT MAX(t1.f1) field1 +FROM t1 JOIN t2 ON t2.f2 LIKE 'x' +HAVING field1 < 7; +field1 +DROP TABLE t1,t2; +# +# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause +# +CREATE TABLE t1 (f1 INT, f2 INT); +INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2); +CREATE TABLE t2 (f1 INT, f2 INT); +SELECT t1.f1 +FROM t1 +HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0 +ORDER BY t1.f1; +f1 +SELECT t1.f1 +FROM t1 +HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0 +ORDER BY t1.f1; +f1 +SELECT t1.f1 +FROM t1 +HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0 +ORDER BY t1.f1; +f1 +DROP TABLE t1,t2; +End of 5.1 tests +# +# Bug#12402590 ASSERT AT PROTOCOL::END_STATEMENT ON MYSQL-TRUNK +# RUNNING RQG_OPT_SUBQUERY TEST +# +CREATE TABLE t2 ( +f1 INT, +PRIMARY KEY (f1) +); +INSERT INTO t2 VALUES (1), (2); +CREATE TABLE t1 ( +f1 INT, +f2 VARCHAR(1), +f3 VARCHAR(1), +PRIMARY KEY (f1), +KEY (f2, f1) +); +INSERT INTO t1 VALUES (8, 'g', 'g'), (11, 'a', 'a'); +SELECT t1.f1 FROM t1 JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f3 AND t1.f2 IN ('f') +HAVING (1 ,6) IN (SELECT 3, 6) +ORDER BY t1.f1; +f1 +DROP TABLE t1, t2; +# +# Bug#11760517: MIN/MAX FAILS TO EVALUATE HAVING CONDITION, +# RETURNS INCORRECT NULL RESULT +# +CREATE TABLE t1 (pk INT PRIMARY KEY, i4 INT); +INSERT INTO t1 VALUES (2,7), (4,7), (6,2), (17,0); + +SELECT MIN(table1.i4), MIN(table2.pk) as min_pk +FROM t1 as table1, t1 as table2 +WHERE table1.pk = 1; +MIN(table1.i4) min_pk +NULL NULL + +SELECT MIN(table1.i4), MIN(table2.pk) as min_pk +FROM t1 as table1, t1 as table2 +WHERE table1.pk = 1 +HAVING min_pk <= 10; +MIN(table1.i4) min_pk + +DROP TABLE t1; +End of 5.6 tests + +ONLY_FULL_GROUP_BY now allows using an alias in HAVING +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1 (a INT, b INT); +insert into t1 values(1,10),(2,20),(3,30); +select a from t1 having a=3; +a +3 +select a as x from t1 having x=3; +x +3 +select avg(a) as x from t1 having x=2; +x +2.0000 +select a as foo, sum(b) as bar from t1 group by a having foo<10; +foo bar +1 10 +2 20 +3 30 +select a as foo, sum(b) as bar from t1 +group by a +having bar>10 +order by foo+10; +foo bar +2 20 +3 30 +select a as foo, +(select t1_inner.b from t1 as t1_inner where +t1_inner.a=t1_outer.a+1) +as bar from t1 as t1_outer +group by a +having bar<30 +order by bar+5; +foo bar +1 20 +select a as foo, +(select t1_inner.b from t1 as t1_inner where +t1_inner.a=t1_outer.a+1) +as bar from t1 as t1_outer +group by foo +having bar<30 +order by bar+5; +foo bar +1 20 +DROP TABLE t1; +set sql_mode=''; +CREATE TABLE t1 (a INT) ENGINE=INNODB; +SELECT a FROM (SELECT 1 FROM t1 AS From1) AS From2 +NATURAL RIGHT OUTER JOIN t1 AS Outjoin3 +GROUP BY 1 HAVING ( +SELECT 1 FROM t1 AS Grouphaving4 GROUP BY 1 HAVING a); +a +SELECT a FROM (SELECT 1 FROM t1 AS From1) AS From2 +NATURAL RIGHT OUTER JOIN t1 AS Outjoin3 +GROUP BY 1 HAVING +sin((SELECT 1 FROM t1 AS Grouphaving4 GROUP BY 1 HAVING a)); +a +CREATE TABLE t2 (a INT) ENGINE=INNODB; +SELECT Outjoin3.a FROM (SELECT 1 FROM t1 AS From1) AS From2 +NATURAL RIGHT OUTER JOIN t2 AS Outjoin3 +GROUP BY 1 HAVING ( +SELECT 1 FROM t1 AS GroupHaving4 GROUP BY 1 HAVING a); +a +DROP TABLE t1, t2; +SET @@sql_mode = @old_sql_mode; +# +# Bug#17055185: WRONG RESULTS WHEN RUNNING A SELECT THAT INCLUDE +# A HAVING BASED ON A FUNCTION. +# +CREATE TABLE series ( +val INT(10) UNSIGNED NOT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO series VALUES(1); +CREATE TABLE seq_calls ( +c INT +); +INSERT INTO seq_calls VALUES(0); +CREATE FUNCTION next_seq_value() RETURNS INT +BEGIN +DECLARE next_val INT; +SELECT val INTO next_val FROM series; +UPDATE series SET val=mod(val + 1, 2); +UPDATE seq_calls SET c=c+1; +RETURN next_val; +END; +| +CREATE TABLE t1 (t INT, u INT, KEY(t)); +INSERT INTO t1 VALUES(10, 10), (11, 11), (12, 12), (12, 13),(14, 15), (15, 16), +(16, 17), (17, 18); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM series, seq_calls; +val c +1 0 +SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t) +GROUP BY t HAVING r = 1 ORDER BY t1.u; +t r +10 1 +12 1 +15 1 +17 1 +SELECT * FROM series, seq_calls; +val c +0 7 +UPDATE series set val=0; +SELECT DISTINCT t1.t, next_seq_value() r FROM t1, t1 P +WHERE P.t = t1.t HAVING r = 1 ORDER BY t1.u; +t r +11 0 +12 0 +14 0 +15 0 +16 0 +17 0 +PREPARE STMT FROM 'SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t) + GROUP BY t HAVING (SELECT 1 FROM t1 WHERE r = 1 LIMIT 1) + ORDER BY t1.u'; +SELECT * FROM series, seq_calls; +val c +1 22 +UPDATE series set val=0; +EXECUTE stmt; +t r +11 1 +14 1 +16 1 +SELECT * FROM series, seq_calls; +val c +1 29 +UPDATE series set val=1; +EXECUTE stmt; +t r +10 1 +12 1 +15 1 +17 1 +DEALLOCATE PREPARE stmt; +INSERT INTO t1 SELECT * FROM t1; +ALTER TABLE t1 ADD KEY(t, u); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM series, seq_calls; +val c +0 36 +UPDATE series set val=0; +SELECT next_seq_value() r, MIN(u) FROM t1 GROUP BY t HAVING r = 1; +r MIN(u) +0 11 +0 12 +0 15 +0 16 +0 17 +0 18 +DROP TABLE t1; +DROP FUNCTION next_seq_value; +DROP TABLE series, seq_calls; +# +# Bug#21243772: NOT IN SUBQUERY RETURNS INCORRECT RESULTS WHEN INNER +# QUERY HAS COUNT DISTINCT. +# +CREATE TABLE t1 (t TEXT NOT NULL, u TEXT); +INSERT INTO t1 VALUES('2', '1'), ('3', '1'), ('4', '1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE (t, u) in (SELECT a.t, COUNT(DISTINCT a.u) +FROM t1 a, t1 b +GROUP BY a.t); +t u +2 1 +3 1 +4 1 +SELECT * FROM t1 WHERE (t, u) not in (SELECT a.t, COUNT(DISTINCT a.u) +FROM t1 a, t1 b +GROUP BY a.t); +t u +DROP TABLE t1; +# +# Bug#21507072: SIG 11 IN TABLE_LIST::MAP AT SQL/TABLE.H:2463. +# +CREATE TABLE t1 (col_varchar_key varchar(1) DEFAULT NULL, +KEY col_varchar_key (col_varchar_key)); +INSERT INTO t1 VALUES ('a'), ('b'), ('c'), ('h'), ('i'), ('i'), ('j'); +SELECT SQL_BUFFER_RESULT col_varchar_key AS field1 +FROM t1 AS table1 +GROUP BY field1 +HAVING field1 = 'a'; +field1 +a +DROP TABLE t1; +# Bug#21613422: Assertion failed: !thd->is_error() in ::prepare() +CREATE TABLE a(f INTEGER, g INTEGER) engine=innodb; +SELECT (SELECT 1 FROM a HAVING g) +FROM (SELECT 1) AS e +JOIN a AS t on TRUE +JOIN a USING (f) +JOIN a AS h on TRUE; +ERROR 23000: Column 'g' in having clause is ambiguous +DROP TABLE a; +# +# Bug #22655856: COLUMN NAME IN HAVING, WHICH IS CONTAINED IN SELECT +# LIST '*', PRODUCES ERROR +# +CREATE TABLE t1(c1 INT) ENGINE=INNODB; +CREATE TABLE t2(c2 INT) ENGINE=INNODB; +EXPLAIN SELECT c1 FROM t1 WHERE EXISTS(SELECT * FROM t2 HAVING c2>0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false +SELECT c1 FROM t1 WHERE EXISTS(SELECT * FROM t2 HAVING c2>0); +c1 +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(2); +SELECT c1 FROM t1 WHERE EXISTS(SELECT * FROM t2 HAVING c2>0); +c1 +1 +DROP TABLE t1, t2; +# +# BUG#26781725 INCORRECT RESULTS FOR QUERY(MAX FUNC+HAVING CLAUSE) WHEN USED INSIDE VIEW +# +CREATE TABLE CC ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) NOT NULL, +col_varchar varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO CC VALUES +(10,'v','v'),(18,'a','a'),(19,'v','v'),(20,'u','u'),(21,'s','s'),(22,'y','y'), +(23,'z','z'),(28,'y','y'); +SELECT MAX(col_varchar_key) AS field1 FROM CC AS alias1 +HAVING field1 <> 5; +field1 +z +CREATE OR REPLACE VIEW v1 AS SELECT MAX(col_varchar_key) AS field1 FROM CC AS alias1 +HAVING field1 <> 5; +SELECT * FROM v1; +field1 +z +DROP TABLE CC; +DROP VIEW v1; +# Bug#28934388: LIMIT is applied before HAVING when you have a subquery +CREATE TABLE t (id INT PRIMARY KEY, value INT); +INSERT INTO t VALUES (1, 99), (2,98), (3, 97); +CREATE TABLE o(c INTEGER); +INSERT INTO o(c) VALUES(1), (2); +SELECT t1.id, (SELECT t2.value FROM t t2 WHERE t1.id = t2.id) AS sub_value +FROM t t1 +HAVING sub_value = 99 +ORDER BY value +LIMIT 1; +id sub_value +1 99 +SELECT t1.id, (SELECT t2.value FROM t t2 WHERE t1.id = t2.id) AS sub_value +FROM t t1 +HAVING sub_value = 99 AND RAND() >= 0.0E0 +ORDER BY value +LIMIT 1; +id sub_value +1 99 +SELECT (SELECT (SELECT t2.value+o.c FROM t t2 WHERE t1.id = t2.id) AS sub_value +FROM t t1 +HAVING sub_value = 99 +ORDER BY value +LIMIT 1) AS sub_value +FROM o; +sub_value +99 +99 +DROP TABLE t, o; +# Bug#31429865: Assertion `table_share->tmp_table != NO_TMP_TABLE || +# m_lock_type == 1' failed. +CREATE TABLE t(a INTEGER); +INSERT INTO t VALUES(1),(2); +CREATE VIEW v AS SELECT a FROM t HAVING 0<>1; +DELETE FROM v LIMIT 1; +ERROR HY000: The target table v of the DELETE is not updatable +DROP VIEW v; +DROP TABLE t; diff --git a/mysql-test/r/heap.result-pq b/mysql-test/r/heap.result-pq new file mode 100644 index 000000000..875e524fd --- /dev/null +++ b/mysql-test/r/heap.result-pq @@ -0,0 +1,850 @@ +drop table if exists t1,t2,t3; +create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a=1 or a=0; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze note The storage engine for the table doesn't support analyze +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH YES NULL +select * from t1; +a b +2 2 +3 3 +4 4 +select * from t1 where a=4; +a b +4 4 +update t1 set b=5 where a=4; +update t1 set b=b+1 where a>=3; +replace t1 values (3,3); +select * from t1; +a b +2 2 +3 3 +4 6 +alter table t1 add c int not null, add key (c,a); +drop table t1; +create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +delete from t1 where a > 0; +select * from t1; +a b +drop table t1; +create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps"; +insert into t1 values(1,1),(2,2),(3,3),(4,4); +alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table"; +select * from t1; +a b +1 1 +2 2 +3 3 +4 4 +drop table t1; +create table t1 (a int not null) engine=heap; +insert into t1 values (869751),(736494),(226312),(802616),(728912); +select * from t1 where a > 736494; +a +869751 +802616 +alter table t1 add unique uniq_id(a); +select * from t1 where a > 736494; +a +869751 +802616 +select * from t1 where a = 736494; +a +736494 +select * from t1 where a=869751 or a=736494; +a +736494 +869751 +select * from t1 where a in (869751,736494,226312,802616); +a +226312 +736494 +802616 +869751 +alter table t1 engine=innodb; +explain select * from t1 where a in (869751,736494,226312,802616); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index uniq_id uniq_id 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` in (869751,736494,226312,802616)) +drop table t1; +create table t1 (x int not null, y int not null, key x (x), unique y (y)) +engine=heap; +insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); +select * from t1 where x=1; +x y +1 1 +1 3 +select * from t1,t1 as t2 where t1.x=t2.y; +x y x y +1 1 1 1 +2 2 2 2 +1 3 1 1 +2 4 2 2 +2 5 2 2 +2 6 2 2 +explain select * from t1,t1 as t2 where t1.x=t2.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 6 100.00 NULL +1 SIMPLE t2 NULL eq_ref y y 4 test.t1.x 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`y` = `test`.`t1`.`x`) +drop table t1; +create table t1 (a int) engine=heap; +insert into t1 values(1); +select max(a) from t1; +max(a) +1 +drop table t1; +CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP; +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 1 +1 2 +1 3 +1 4 +1 5 +1 6 +insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); +select * from t1 where a=1; +a b +1 1 +1 1 +1 2 +1 2 +1 3 +1 3 +1 4 +1 4 +1 5 +1 5 +1 6 +1 6 +drop table t1; +create table t1 (id int unsigned not null, primary key (id)) engine=HEAP; +insert into t1 values(1); +select max(id) from t1; +max(id) +1 +insert into t1 values(2); +select max(id) from t1; +max(id) +2 +replace into t1 values(1); +drop table t1; +create table t1 (n int) engine=heap; +drop table t1; +create table t1 (n int) engine=heap; +drop table if exists t1; +CREATE table t1(f1 int not null,f2 char(20) not +null,index(f2)) engine=heap; +INSERT into t1 set f1=12,f2="bill"; +INSERT into t1 set f1=13,f2="bill"; +INSERT into t1 set f1=14,f2="bill"; +INSERT into t1 set f1=15,f2="bill"; +INSERT into t1 set f1=16,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +INSERT into t1 set f1=12,f2="ted"; +delete from t1 where f2="bill"; +select * from t1; +f1 f2 +16 ted +12 ted +12 ted +12 ted +12 ted +drop table t1; +create table t1 (btn char(10) not null, key(btn)) charset utf8mb4 engine=heap; +insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); +explain select * from t1 where btn like "q%"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL btn NULL NULL NULL 14 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`btn` AS `btn` from `test`.`t1` where (`test`.`t1`.`btn` like 'q%') +select * from t1 where btn like "q%"; +btn +alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn; +update t1 set new_col=left(btn,1); +explain select * from t1 where btn="a"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL btn NULL NULL NULL 14 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`btn` AS `btn`,`test`.`t1`.`new_col` AS `new_col` from `test`.`t1` where (`test`.`t1`.`btn` = 'a') +explain select * from t1 where btn="a" and new_col="a"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref btn btn 44 const,const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`btn` AS `btn`,`test`.`t1`.`new_col` AS `new_col` from `test`.`t1` where ((`test`.`t1`.`new_col` = 'a') and (`test`.`t1`.`btn` = 'a')) +drop table t1; +CREATE TABLE t1 ( +a int default NULL, +b int default NULL, +KEY a (a), +UNIQUE b (b) +) engine=heap; +INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); +SELECT * FROM t1 WHERE a=NULL; +a b +explain SELECT * FROM t1 WHERE a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` is null) +SELECT * FROM t1 WHERE a<=>NULL; +a b +NULL 99 +SELECT * FROM t1 WHERE b=NULL; +a b +explain SELECT * FROM t1 WHERE b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b b 5 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` is null) +SELECT * FROM t1 WHERE b<=>NULL; +a b +99 NULL +INSERT INTO t1 VALUES (1,3); +ERROR 23000: Duplicate entry '3' for key 't1.b' +DROP TABLE t1; +CREATE TABLE t1 ( +a int default NULL, +key a (a) +) ENGINE=HEAP; +INSERT INTO t1 VALUES (10), (10), (10); +EXPLAIN SELECT * FROM t1 WHERE a=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 10) +SELECT * FROM t1 WHERE a=10; +a +10 +10 +10 +DROP TABLE t1; +CREATE TABLE t1 (a int not null, primary key(a)) engine=heap; +INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); +DELETE from t1 where a < 100; +SELECT * from t1; +a +DROP TABLE t1; +CREATE TABLE `job_titles` ( +`job_title_id` int(6) unsigned NOT NULL default '0', +`job_title` char(18) NOT NULL default '', +PRIMARY KEY (`job_title_id`), +UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`) +) ENGINE=HEAP; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT MAX(job_title_id) FROM job_titles; +MAX(job_title_id) +NULL +DROP TABLE job_titles; +CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP; +INSERT INTO t1 VALUES(1,1), (1,NULL); +SELECT * FROM t1 WHERE B is not null; +a B +1 1 +DROP TABLE t1; +CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496); +DELETE FROM t1 WHERE date<1101106546; +SELECT * FROM t1; +pseudo date +ZoomZip 1101106546 +DROP TABLE t1; +create table t1(a char(2)) engine=memory; +insert into t1 values (NULL), (NULL); +delete from t1 where a is null; +insert into t1 values ('2'), ('3'); +select * from t1; +a +3 +2 +drop table t1; +set default_storage_engine=HEAP; +create table t1 (v varchar(10), c char(10), t varchar(50)) charset utf8mb4; +insert into t1 values('+ ', '+ ', '+ '); +set @a=repeat(' ',20); +insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); +Warnings: +Note 1265 Data truncated for column 'v' at row 1 +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+ *+*+ * +*+ *+*+ * +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 like t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t3 charset utf8mb4 select * from t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify c varchar(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify v char(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +alter table t1 modify t varchar(10); +Warnings: +Warning 1265 Data truncated for column 't' at row 2 +SET sql_mode = default; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(10) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+*+*+ * +*+*+*+ * +drop table t1,t2,t3; +create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10))) charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL, + KEY `v` (`v`), + KEY `c` (`c`), + KEY `t` (`t`(10)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +select count(*) from t1; +count(*) +270 +insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where c='a'; +count(*) +10 +select count(*) from t1 where t='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where c='a '; +count(*) +10 +select count(*) from t1 where t='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where c like 'a%'; +count(*) +11 +select count(*) from t1 where t like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where c='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c c 11 const 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`c` = 'a ') +explain select count(*) from t1 where t='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t t 13 const 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`t` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL v NULL NULL NULL 271 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +alter table t1 add unique(v); +ERROR 23000: Duplicate entry '{ ' for key 't1.v_2' +select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); +qq +*a*a*a* +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select v,count(*) from t1 group by v order by v limit 9; +v count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +select v,count(t) from t1 group by v order by v limit 10; +v count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select v,count(c) from t1 group by v order by v limit 10; +v count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result trim(v),count(t) from t1 group by v order by v limit 10; +trim(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result trim(v),count(c) from t1 group by v order by v limit 10; +trim(v) count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(*) from t1 group by c order by c limit 10; +c count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(t) from t1 group by c order by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result c,count(t) from t1 group by c order by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select t,count(*) from t1 group by t order by t limit 10; +t count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select t,count(t) from t1 group by t order by t limit 10; +t count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result trim(t),count(t) from t1 group by t order by t limit 10; +trim(t) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +drop table t1; +create table t1 (a char(10), unique (a)) charset latin1; +insert into t1 values ('a'); +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +alter table t1 modify a varchar(10); +insert into t1 values ('a '),('a '),('a '),('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +update t1 set a='a ' where a like 'a '; +update t1 set a='a ' where a like 'a '; +drop table t1; +create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10))) charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL, + KEY `v` (`v`) USING BTREE, + KEY `c` (`c`) USING BTREE, + KEY `t` (`t`(10)) USING BTREE +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +select count(*) from t1; +count(*) +270 +insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where c='a'; +count(*) +10 +select count(*) from t1 where t='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where c='a '; +count(*) +10 +select count(*) from t1 where t='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where c='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c c 11 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`c` = 'a ') +explain select count(*) from t1 where t='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t t 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`t` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range v v 13 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +alter table t1 add unique(v); +ERROR 23000: Duplicate entry '{ ' for key 't1.v_2' +select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); +qq +*a*a*a* +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 13 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +drop table t1; +create table t1 (a char(10), unique using btree (a)) charset latin1 engine=heap; +insert into t1 values ('a'); +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +alter table t1 modify a varchar(10); +insert into t1 values ('a '),('a '),('a '),('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a ' for key 't1.a' +update t1 set a='a ' where a like 'a '; +update t1 set a='a ' where a like 'a '; +drop table t1; +create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5))) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` varchar(50) DEFAULT NULL, + KEY `v` (`v`(5)), + KEY `c` (`c`(5)), + KEY `t` (`t`(5)) +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v varchar(65530), key(v(10))) charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(65530) DEFAULT NULL, + KEY `v` (`v`(10)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +insert into t1 values(repeat('a',65530)); +select length(v) from t1 where v=repeat('a',65530); +length(v) +65530 +drop table t1; +set default_storage_engine=InnoDB; +create table t1 (a bigint unsigned auto_increment primary key, b int, +key (b, a)) engine=heap; +insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1); +select * from t1; +a b +1 1 +2 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +drop table t1; +create table t1 (a int not null, b int not null auto_increment, +primary key(a, b), key(b)) engine=heap; +insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1); +select * from t1; +a b +1 1 +1 2 +1 3 +1 4 +1 5 +1 6 +1 7 +1 8 +drop table t1; +create table t1 (a int not null, b int not null auto_increment, +primary key(a, b)) engine=heap; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +create table t1 (c char(255), primary key(c(90))); +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 't1.PRIMARY' +drop table t1; +# +# Bug 12796: Record doesn't show when selecting through index +# +CREATE TABLE t1 (a int, key(a)) engine=heap; +insert into t1 values (0); +delete from t1; +select * from t1; +a +insert into t1 values (0), (1); +select * from t1 where a = 0; +a +0 +drop table t1; +create table t1 (c char(10)) charset utf8mb4 engine=memory; +create table t2 (c varchar(10)) charset utf8mb4 engine=memory; +analyze table t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze note The storage engine for the table doesn't support analyze +test.t2 analyze note The storage engine for the table doesn't support analyze +show table status like 't_'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MEMORY 10 Fixed 0 41 0 # 0 0 NULL # NULL NULL utf8mb4_0900_ai_ci NULL +t2 MEMORY 10 Fixed 0 42 0 # 0 0 NULL # NULL NULL utf8mb4_0900_ai_ci NULL +drop table t1, t2; +CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256), +KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY; +INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256)); +SELECT COUNT(*) FROM t1 WHERE a='a'; +COUNT(*) +2 +SELECT COUNT(*) FROM t1 WHERE b='aa'; +COUNT(*) +2 +SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256); +COUNT(*) +2 +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY; +INSERT INTO t1 VALUES('', 0); +ALTER TABLE t1 MODIFY c1 VARCHAR(101); +SELECT c2 FROM t1; +c2 +0 +DROP TABLE t1; +# +# BUG#11825482: Broken key length calculation for btree index +# +CREATE TABLE h1 (f1 VARCHAR(1), f2 INT NOT NULL, +UNIQUE KEY h1i (f1,f2) USING BTREE ) ENGINE=HEAP; +INSERT INTO h1 VALUES(NULL,0),(NULL,1); +SELECT 'wrong' as 'result' FROM dual WHERE ('h', 0) NOT IN (SELECT * FROM h1); +result +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (19,5,'h'),(20,5,'h'); +CREATE TABLE t2 (col_int_nokey INT); +INSERT INTO t2 VALUES (1),(2); +CREATE VIEW v1 AS +SELECT col_varchar_nokey, COUNT( col_varchar_nokey ) +FROM t1 +WHERE col_int_nokey <= 141 AND pk <= 4 +; +SELECT col_int_nokey FROM t2 +WHERE ('h', 0) NOT IN ( SELECT * FROM v1); +col_int_nokey +# shouldn't crash +EXPLAIN SELECT col_int_nokey FROM t2 +WHERE ('h', 0) NOT IN ( SELECT * FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED t1 NULL range PRIMARY PRIMARY 4 NULL 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` where false +DROP TABLE t1,t2,h1; +DROP VIEW v1; +CREATE TABLE t1 ( +c1 VARCHAR(10) NOT NULL, +KEY i1 (c1(3)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('foo1'), ('bar2'), ('baz3'); +SELECT * FROM t1 WHERE c1='bar2'; +c1 +bar2 +#should show one tuple! +SELECT * FROM t1 IGNORE INDEX (i1) WHERE c1='bar2'; +c1 +bar2 +#should show one tuple! +DROP TABLE t1; diff --git a/mysql-test/r/histogram_equi_height.result-pq b/mysql-test/r/histogram_equi_height.result-pq new file mode 100644 index 000000000..deb356c69 --- /dev/null +++ b/mysql-test/r/histogram_equi_height.result-pq @@ -0,0 +1,1718 @@ +# +# Integer column, equi-height histogram +# +CREATE TABLE tbl_int (col1 INT); +INSERT INTO tbl_int VALUES (1), (2), (3), (4), (5), (6), (7), (8), (NULL), (NULL); +ANALYZE TABLE tbl_int; +Table Op Msg_type Msg_text +test.tbl_int analyze status OK +ANALYZE TABLE tbl_int UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_int histogram status Histogram statistics created for column 'col1'. +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 0) +EXPLAIN SELECT * FROM tbl_int WHERE 0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (0 < `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 < `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 10) +EXPLAIN SELECT * FROM tbl_int WHERE 10 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (10 > `test`.`tbl_int`.`col1`) +# Expect "36.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 6) +EXPLAIN SELECT * FROM tbl_int WHERE 6 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (6 <= `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= (-(100))) +EXPLAIN SELECT * FROM tbl_int WHERE -100 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where ((-(100)) <= `test`.`tbl_int`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 != 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_int WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 100) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is not null) +# Expect "36.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 1 and 3) +# Expect "43.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not between 1 and 3) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (1,3,4,5,6,7)) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not in (1,3,4,5,6,7)) +DROP TABLE tbl_int; +# +# String column, equi-height histogram +# +CREATE TABLE tbl_varchar (col1 VARCHAR(255)); +INSERT INTO tbl_varchar VALUES +("abcd"), ("🍣"), ("🍺"), ("eeeeeeeeee"), ("ef"), ("AG"), +("a very long string that is longer than 42 characters"), +("lorem ipsum"), (NULL), (NULL); +ANALYZE TABLE tbl_varchar UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_varchar histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_varchar; +Table Op Msg_type Msg_text +test.tbl_varchar analyze status OK +# Expect "36.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 36.73 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 36.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'b') +EXPLAIN SELECT * FROM tbl_varchar WHERE "b" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 36.73 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 36.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('b' < `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "lp"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'lp') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lp" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lp' < `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('sierra' > `test`.`tbl_varchar`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= "abcd"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= 'abcd') +EXPLAIN SELECT * FROM tbl_varchar WHERE "abcd" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('abcd' <= `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= '') +EXPLAIN SELECT * FROM tbl_varchar WHERE "" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('' <= `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 != "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 <> "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 = "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is not null) +# Expect "10.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` between 'a' and 'b') +# Expect "76.72" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 76.72 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 76.72 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not between 'a' and 'b') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IN ("ag", "ef", "🍣"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` in ('ag','ef','?')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT IN ("ag", "ef", "🍣"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not in ('ag','ef','?')) +DROP TABLE tbl_varchar; +CREATE TABLE tbl_varchar (col1 VARCHAR(255)); +INSERT INTO tbl_varchar VALUES +# |------------ 42 characters -------------| +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnop"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnoq"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnor"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnos"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopp"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnoss"), +("abcdefghijklmnopqrstuvwxyzabcdefghijklmnost"); +ANALYZE TABLE tbl_varchar UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_varchar histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_varchar; +Table Op Msg_type Msg_text +test.tbl_varchar analyze status OK +# Expect "100.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "abcdefghijklmnopqrstuvwxyzabcdefghijklmnos"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnos') +# Expect "12.50" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopr"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 12.50 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopr') +DROP TABLE tbl_varchar; +# +# Double column, equi-height histogram +# +CREATE TABLE tbl_double (col1 DOUBLE); +INSERT INTO tbl_double VALUES (-1.1), (0.0), (1.1), (2.2), (3.3), (4.4), (5.5), (6.6), (NULL), (NULL); +ANALYZE TABLE tbl_double UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_double histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_double; +Table Op Msg_type Msg_text +test.tbl_double analyze status OK +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 < `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 6.6e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 6.6e0) +EXPLAIN SELECT * FROM tbl_double WHERE 6.6e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (6.6e0 < `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 < 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` < 100) +EXPLAIN SELECT * FROM tbl_double WHERE 100.0 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (100 > `test`.`tbl_double`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= 3.3e0) +EXPLAIN SELECT * FROM tbl_double WHERE 3.3e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (3.3e0 <= `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= -2.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= -2) +EXPLAIN SELECT * FROM tbl_double WHERE -2.0e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (-2 <= `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 != 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +EXPLAIN SELECT * FROM tbl_double WHERE col1 <> 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_double WHERE col1 = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_double WHERE 100.0 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (100 = `test`.`tbl_double`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is not null) +# Expect "13.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` between 1.1e0 and 3.3e0) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not between 1.1e0 and 3.3e0) +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +DROP TABLE tbl_double; +# +# Time column, equi-height histogram +# +CREATE TABLE tbl_time (col1 TIME); +INSERT INTO tbl_time VALUES +("-01:00:00"), ("00:00:00"), ("00:00:01"), ("00:01:00"), ("01:00:00"), +("01:01:00"), ("02:00:00"), ("03:00:00"), (NULL), (NULL); +ANALYZE TABLE tbl_time UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_time histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_time; +Table Op Msg_type Msg_text +test.tbl_time analyze status OK +# Expect "40.66" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.66 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.66 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'00:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.66 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.66 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:00' < `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "03:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'03:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "03:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'03:00:00' < `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' > `test`.`tbl_time`.`col1`) +# Expect "40.64" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "00:00:01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.64 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'00:00:01') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.64 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 40.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:01' <= `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "-01:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'-01:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "-01:00:00" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'-01:00:00' <= `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 != "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +EXPLAIN SELECT * FROM tbl_time WHERE col1 <> "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_time WHERE col1 = "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` = TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' = `test`.`tbl_time`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is not null) +# Expect "20.64" in column "filtered" +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_time WHERE col1 BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.64 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 20.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` between '00:00:01' and '02:00:00') +# Expect "59.36" in column "filtered" +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 59.36 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 59.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not between '00:00:01' and '02:00:00') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` in ('-01:00:00','00:00:00','03:00:00')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not in ('-01:00:00','00:00:00','03:00:00')) +DROP TABLE tbl_time; +CREATE TABLE tbl_time (col1 TIME(6)); +INSERT INTO tbl_time VALUES +("00:00:00.000000"), ("00:00:00.000001"), ("00:00:00.000002"), +("00:00:00.000003"), ("00:00:00.000004"), ("00:00:00.000005"); +ANALYZE TABLE tbl_time UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_time histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_time; +Table Op Msg_type Msg_text +test.tbl_time analyze status OK +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "00:00:00.000004"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 75.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 6 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'00:00:00.000004') +DROP TABLE tbl_time; +# +# Date column, equi-height histogram +# +CREATE TABLE tbl_date (col1 DATE); +INSERT INTO tbl_date VALUES +("1000-01-01"), ("9999-12-30"), ("2017-01-01"), ("2017-01-02"), ("2017-02-01"), +("2018-01-01"), ("2019-01-01"), ("3019-01-01"), (NULL), (NULL); +ANALYZE TABLE tbl_date UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_date histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_date; +Table Op Msg_type Msg_text +test.tbl_date analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' < `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' < `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 < "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` < DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' > `test`.`tbl_date`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "2018-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'2018-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "2018-01-01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2018-01-01' <= `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "1000-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "1000-01-01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'1000-01-01' <= `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 != "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +EXPLAIN SELECT * FROM tbl_date WHERE col1 <> "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_date WHERE col1 = "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is not null) +# Expect "10.00" in column "filtered" +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_date WHERE col1 BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` between '2017-01-01' and '3019-01-01') +# Expect "74.98" in column "filtered" +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 74.98 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 74.98 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not between '2017-01-01' and '3019-01-01') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IN ("1000-01-01", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` in ('1000-01-01','2017-01-02','2018-01-01')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT IN ("1000-01-01", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not in ('1000-01-01','2017-01-02','2018-01-01')) +DROP TABLE tbl_date; +# +# Datetime column, equi-height histogram +# +CREATE TABLE tbl_datetime (col1 DATETIME(6)); +INSERT INTO tbl_datetime VALUES +("1000-01-01 00:00:00"), ("9999-12-31 23:59:59.999998"), +("2017-01-01 00:00:00"), ("2017-01-01 00:00:00.000001"), +("2017-02-01 00:00:00"), ("2018-01-01 00:00:00.999999"), +("2018-01-01 00:00:01"), ("3019-01-01 10:10:10.101010"), (NULL), (NULL); +ANALYZE TABLE tbl_datetime UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_datetime histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "2018-01-01 00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'2018-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00' < `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999999' < `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 < "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` < TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999999' > `test`.`tbl_datetime`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "2018-01-01 00:00:00.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'2018-01-01 00:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00.999999" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00.999999' <= `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "1000-01-01 00:00:00.000000"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'1000-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "1000-01-01 00:00:00.000000" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'1000-01-01 00:00:00' <= `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 != "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 <> "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 = "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is not null) +# Expect "10.00" in column "filtered" +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "74.98" in column "filtered" +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 74.98 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 74.98 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IN ("1000-01-01 00:00:00.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` in ('1000-01-01 00:00:00.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT IN ("1000-01-01 00:00:00.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not in ('1000-01-01 00:00:00.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +DROP TABLE tbl_datetime; +# +# Decimal column, equi-height histogram +# +CREATE TABLE tbl_decimal (col1 DECIMAL(65, 30)); +INSERT INTO tbl_decimal VALUES +(00000000000000000000000000000000000.000000000000000000000000000000), +(99999999999999999999999999999999999.999999999999999999999999999998), +(-99999999999999999999999999999999999.999999999999999999999999999999), +(1), (2), (3), (4), (-1), (NULL), (NULL); +ANALYZE TABLE tbl_decimal UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_decimal histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_decimal; +Table Op Msg_type Msg_text +test.tbl_decimal analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` > 1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 1 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (1.000000000000000000000000000000 < `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 100000000000000000000000000000000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +EXPLAIN SELECT * FROM tbl_decimal WHERE 100000000000000000000000000000000000 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 < 99999999999999999999999999999999999.999999999999999999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` < 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE 99999999999999999999999999999999999.999999999999999999999999999999 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 > `test`.`tbl_decimal`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= 4.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 4 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (4.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= -1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE -1 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (-1.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 != 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 <> 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 = "99999999999999999999999999999999999.999999999999999999999999999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` = 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE "99999999999999999999999999999999999.999999999999999999999999999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 = `test`.`tbl_decimal`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is not null) +# This might seem low, but given the uniform distribution assuption in +# each bucket this is actually correct. +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` between (-(1.0)) and 4.0) +# This might seem high, but given the uniform distribution assuption in +# each bucket this is actually correct. +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not between (-(1.0)) and 4.0) +# Expect "10.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IN +(-99999999999999999999999999999999999.999999999999999999999999999999, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` in ((-(99999999999999999999999999999999999.999999999999999999999999999999)),1.0,2.0)) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT IN +(-99999999999999999999999999999999999.999999999999999999999999999999, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not in ((-(99999999999999999999999999999999999.999999999999999999999999999999)),1.0,2.0)) +DROP TABLE tbl_decimal; +# +# ENUM column, equi-height histogram +# Note that we only support equality/inequality operators for ENUM +# columns. +# +CREATE TABLE tbl_enum (col1 ENUM('red', 'black', 'blue', 'green')); +INSERT INTO tbl_enum VALUES ('red'), ('red'), ('black'), ('blue'), ('green'), +('green'), (NULL), (NULL), (NULL); +ANALYZE TABLE tbl_enum UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_enum histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_enum; +Table Op Msg_type Msg_text +test.tbl_enum analyze status OK +# Expect "16.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +EXPLAIN SELECT * FROM tbl_enum WHERE 'red' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN ('black', 'blue', 'green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in ('black','blue','green')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN ('green', 'blue'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in ('green','blue')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is null) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is not null) +# Test that the numerical representation of enum values also gives the +# correct result. +# Expect "16.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 1) +EXPLAIN SELECT * FROM tbl_enum WHERE 1 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 16.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (1 = `test`.`tbl_enum`.`col1`) +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +# Expect "11.11" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_enum WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (100 = `test`.`tbl_enum`.`col1`) +# Expect "50.00" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN (2, 3, 4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in (2,3,4)) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN (4, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in (4,3)) +DROP TABLE tbl_enum; +# +# SET column, equi-height histogram +# Note that we only support equality/inequality operators for SET +# columns. +# +CREATE TABLE tbl_set (col1 SET('red', 'black', 'blue', 'green')); +INSERT INTO tbl_set VALUES ('red'), ('red,black'), ('black,green,blue'), +('black,green,blue'), ('black,green,blue'), +('green'), ('green,red'), ('red,green'), (NULL), +(NULL), (NULL); +ANALYZE TABLE tbl_set UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_set histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_set; +Table Op Msg_type Msg_text +test.tbl_set analyze status OK +# Expect "9.09" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 'red,green'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +EXPLAIN SELECT * FROM tbl_set WHERE 'red,green' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +# Expect "67.68" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "32.32" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 32.32 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 32.32 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in ('green','black,blue,green')) +# Expect "40.40" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 40.40 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 40.40 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in ('green','black,blue,green')) +# Expect "27.27" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 27.27 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 27.27 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is null) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is not null) +# Test that the numerical representation of set values also gives the +# correct result. +# Expect "9.09" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_set WHERE 9 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (9 = `test`.`tbl_set`.`col1`) +# Expect "67.68" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 67.68 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 67.68 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "9.09" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_set WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (100 = `test`.`tbl_set`.`col1`) +# Expect "32.32" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 32.32 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 32.32 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in (8,14)) +# Expect "40.40" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 40.40 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 40.40 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in (8,14)) +DROP TABLE tbl_set; +# +# Tests for covering various corner cases that hasn't already been +# covered. +# +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES ("a"), ("a"), ("a"), ("a"), ("a"), ("a"), ("a"), ("b"), +("c"), ("d"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < "a"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < 'a') +DROP TABLE t1; +CREATE TABLE t1 (col1 DECIMAL); +INSERT INTO t1 VALUES (1.0), (1.0), (1.0), (1.0), (1.0), (1.0), (1.0), (2.0), +(3.0), (4.0); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < 0) +EXPLAIN SELECT * FROM t1 WHERE col1 < 1.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < 1) +DROP TABLE t1; +CREATE TABLE t1 (col1 BIGINT UNSIGNED); +INSERT INTO t1 VALUES (100), (100), (100), (100), (100), (100), (100), (200), +(300), (400); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 <= 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 100) +EXPLAIN SELECT * FROM t1 WHERE col1 <= 150; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 150) +EXPLAIN SELECT * FROM t1 WHERE 150 >= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (150 >= `test`.`t1`.`col1`) +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 0 AND RAND(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 0 and rand()) +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 1 AND NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 1 and NULL) +EXPLAIN SELECT * FROM t1 WHERE col1 IN (1, RAND()); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (1,rand())) +EXPLAIN SELECT * FROM t1 WHERE col1 IN (1, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (1,NULL)) +EXPLAIN SELECT * FROM t1 WHERE col1 IN (100, 100, 100, 100, 100, 100); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (100,100,100,100,100,100)) +EXPLAIN SELECT * FROM t1 WHERE col1 NOT IN (1, NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not in (1,NULL)) +EXPLAIN SELECT * FROM t1 WHERE col1 NOT IN (100, 100, 100, 100, 100, 100); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not in (100,100,100,100,100,100)) +EXPLAIN SELECT * FROM t1 WHERE col1 <= NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= NULL) +EXPLAIN SELECT * FROM t1 WHERE col1 >= NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` >= NULL) +EXPLAIN SELECT * FROM t1 WHERE col1 != NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <> NULL) +DROP TABLE t1; +CREATE TABLE t1 (col1 TIME); +INSERT INTO t1 VALUES ("00:00:00"), ("00:00:00"), ("00:00:00"), ("00:00:00"), +("00:00:00"), ("00:00:00"), ("00:00:00"), ("00:01:00"), +("00:02:00"), ("00:03:00"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < "00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` < TIME'00:00:00') +EXPLAIN SELECT * FROM t1 WHERE col1 NOT BETWEEN "00:00:00" AND ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 88.89 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 88.89 Using where +Warnings: +Warning 1292 Truncated incorrect time value: '' +Warning 1292 Truncated incorrect time value: '' +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not between '00:00:00' and '') +DROP TABLE t1; diff --git a/mysql-test/r/histogram_singleton.result-pq b/mysql-test/r/histogram_singleton.result-pq new file mode 100644 index 000000000..d30afae19 --- /dev/null +++ b/mysql-test/r/histogram_singleton.result-pq @@ -0,0 +1,1591 @@ +# +# Integer column, singleton histogram +# +CREATE TABLE tbl_int (col1 INT); +INSERT INTO tbl_int VALUES (1), (2), (3), (4), (5), (6), (7), (8), (NULL), (NULL); +ANALYZE TABLE tbl_int; +Table Op Msg_type Msg_text +test.tbl_int analyze status OK +ANALYZE TABLE tbl_int UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_int histogram status Histogram statistics created for column 'col1'. +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 0) +EXPLAIN SELECT * FROM tbl_int WHERE 0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (0 < `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 < `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 0) +EXPLAIN SELECT * FROM tbl_int WHERE 0 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (0 > `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 10) +EXPLAIN SELECT * FROM tbl_int WHERE 10 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (10 > `test`.`tbl_int`.`col1`) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 6) +EXPLAIN SELECT * FROM tbl_int WHERE 6 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (6 <= `test`.`tbl_int`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= -100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= (-(100))) +EXPLAIN SELECT * FROM tbl_int WHERE -100 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where ((-(100)) <= `test`.`tbl_int`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 != 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE 8 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (8 <> `test`.`tbl_int`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 10) +EXPLAIN SELECT * FROM tbl_int WHERE 10 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 10) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` is not null) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 1 and 3) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT BETWEEN 1 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not between 1 and 3) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (1,3,4,5,6,7)) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_int WHERE col1 NOT IN (1, 3, 4, 5, 6, 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` not in (1,3,4,5,6,7)) +DROP TABLE tbl_int; +# +# String column, singleton histogram +# +CREATE TABLE tbl_varchar (col1 VARCHAR(255)); +INSERT INTO tbl_varchar VALUES +("abcd"), ("🍣"), ("🍺"), ("eeeeeeeeee"), ("ef"), ("AG"), +("a very long string that is longer than 42 characters"), +("lorem ipsum"), (NULL), (NULL); +ANALYZE TABLE tbl_varchar UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_varchar histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_varchar; +Table Op Msg_type Msg_text +test.tbl_varchar analyze status OK +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'b') +EXPLAIN SELECT * FROM tbl_varchar WHERE "b" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('b' < `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 > "lp"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` > 'lp') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lp" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lp' < `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "🍡"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA1' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < '?') +EXPLAIN SELECT * FROM tbl_varchar WHERE "🍡" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA1' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('?' > `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 < "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` < 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('sierra' > `test`.`tbl_varchar`.`col1`) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= "abcd"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= 'abcd') +EXPLAIN SELECT * FROM tbl_varchar WHERE "abcd" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('abcd' <= `test`.`tbl_varchar`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 >= ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` >= '') +EXPLAIN SELECT * FROM tbl_varchar WHERE "" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('' <= `test`.`tbl_varchar`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 != "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 <> "lorem ipsum"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` <> 'lorem ipsum') +EXPLAIN SELECT * FROM tbl_varchar WHERE "lorem ipsum" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where ('lorem ipsum' <> `test`.`tbl_varchar`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 = "sierra"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +EXPLAIN SELECT * FROM tbl_varchar WHERE "sierra" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` = 'sierra') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` is not null) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` between 'a' and 'b') +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT BETWEEN "a" AND "b"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not between 'a' and 'b') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 IN ("ag", "ef", "🍣"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` in ('ag','ef','?')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_varchar WHERE col1 NOT IN ("ag", "ef", "🍣"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_varchar NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Warning 1300 Cannot convert string '\xF0\x9F\x8D\xA3' from utf8mb4 to utf8 +Note 1003 /* select#1 */ select `test`.`tbl_varchar`.`col1` AS `col1` from `test`.`tbl_varchar` where (`test`.`tbl_varchar`.`col1` not in ('ag','ef','?')) +DROP TABLE tbl_varchar; +# +# Double column, singleton histogram +# +CREATE TABLE tbl_double (col1 DOUBLE); +INSERT INTO tbl_double VALUES (-1.1), (0.0), (1.1), (2.2), (3.3), (4.4), (5.5), (6.6), (NULL), (NULL); +ANALYZE TABLE tbl_double UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_double histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_double; +Table Op Msg_type Msg_text +test.tbl_double analyze status OK +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 < `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_double WHERE col1 > 6.6e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` > 6.6e0) +EXPLAIN SELECT * FROM tbl_double WHERE 6.6e0 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (6.6e0 < `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_double WHERE col1 < -2.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` < -2.2) +EXPLAIN SELECT * FROM tbl_double WHERE -2.2 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (-2.2 > `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 < 10.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` < 10) +EXPLAIN SELECT * FROM tbl_double WHERE 10.0 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (10 > `test`.`tbl_double`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= 3.3e0) +EXPLAIN SELECT * FROM tbl_double WHERE 3.3e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (3.3e0 <= `test`.`tbl_double`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 >= -2.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` >= -2) +EXPLAIN SELECT * FROM tbl_double WHERE -2.0e0 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (-2 <= `test`.`tbl_double`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 != 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +EXPLAIN SELECT * FROM tbl_double WHERE col1 <> 0.0e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` <> 0.0e0) +EXPLAIN SELECT * FROM tbl_double WHERE 0.0e0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (0.0e0 <> `test`.`tbl_double`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_double WHERE col1 = 100.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_double WHERE 100.0 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (100 = `test`.`tbl_double`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` is not null) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` between 1.1e0 and 3.3e0) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT BETWEEN 1.1e0 AND 3.3e0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not between 1.1e0 and 3.3e0) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_double WHERE col1 NOT IN (-1.1e0, 0.0e0, 1.1e0, 2.2e0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_double NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_double`.`col1` AS `col1` from `test`.`tbl_double` where (`test`.`tbl_double`.`col1` not in ((-(1.1e0)),0.0e0,1.1e0,2.2e0)) +DROP TABLE tbl_double; +# +# Time column, singleton histogram +# +CREATE TABLE tbl_time (col1 TIME); +INSERT INTO tbl_time VALUES +("-01:00:00"), ("00:00:00"), ("00:00:01"), ("00:01:00"), ("01:00:00"), +("01:01:00"), ("02:00:00"), ("03:00:00"), (NULL), (NULL); +ANALYZE TABLE tbl_time UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_time histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_time; +Table Op Msg_type Msg_text +test.tbl_time analyze status OK +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'00:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:00' < `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_time WHERE col1 > "03:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` > TIME'03:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "03:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'03:00:00' < `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "-02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'-02:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "-02:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'-02:00:00' > `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 < "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` < TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' > `test`.`tbl_time`.`col1`) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "00:00:01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'00:00:01') +EXPLAIN SELECT * FROM tbl_time WHERE "00:00:01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'00:00:01' <= `test`.`tbl_time`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 >= "-01:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` >= TIME'-01:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "-01:00:00" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'-01:00:00' <= `test`.`tbl_time`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 != "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +EXPLAIN SELECT * FROM tbl_time WHERE col1 <> "01:01:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` <> TIME'01:01:00') +EXPLAIN SELECT * FROM tbl_time WHERE "01:01:00" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'01:01:00' <> `test`.`tbl_time`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_time WHERE col1 = "10:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` = TIME'10:00:00') +EXPLAIN SELECT * FROM tbl_time WHERE "10:00:00" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (TIME'10:00:00' = `test`.`tbl_time`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` is not null) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` between '00:00:01' and '02:00:00') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT BETWEEN "00:00:01" AND "02:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not between '00:00:01' and '02:00:00') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` in ('-01:00:00','00:00:00','03:00:00')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_time WHERE col1 NOT IN ("-01:00:00", "00:00:00", "03:00:00"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_time NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_time`.`col1` AS `col1` from `test`.`tbl_time` where (`test`.`tbl_time`.`col1` not in ('-01:00:00','00:00:00','03:00:00')) +DROP TABLE tbl_time; +# +# Date column, singleton histogram +# +CREATE TABLE tbl_date (col1 DATE); +INSERT INTO tbl_date VALUES +("1000-01-02"), ("9999-12-30"), ("2017-01-01"), ("2017-01-02"), ("2017-02-01"), +("2018-01-01"), ("2019-01-01"), ("3019-01-01"), (NULL), (NULL); +ANALYZE TABLE tbl_date UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_date histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_date; +Table Op Msg_type Msg_text +test.tbl_date analyze status OK +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' < `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_date WHERE col1 > "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` > DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' < `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_date WHERE col1 < "1000-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` < DATE'1000-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "1000-01-01" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'1000-01-01' > `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 < "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` < DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'9999-12-31' > `test`.`tbl_date`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "2018-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'2018-01-01') +EXPLAIN SELECT * FROM tbl_date WHERE "2018-01-01" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2018-01-01' <= `test`.`tbl_date`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 >= "1000-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` >= DATE'1000-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "1000-01-02" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'1000-01-02' <= `test`.`tbl_date`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 != "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +EXPLAIN SELECT * FROM tbl_date WHERE col1 <> "2017-01-02"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` <> DATE'2017-01-02') +EXPLAIN SELECT * FROM tbl_date WHERE "2017-01-02" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (DATE'2017-01-02' <> `test`.`tbl_date`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_date WHERE col1 = "9999-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +EXPLAIN SELECT * FROM tbl_date WHERE "9999-12-31" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` = DATE'9999-12-31') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` is not null) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` between '2017-01-01' and '3019-01-01') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT BETWEEN "2017-01-01" AND "3019-01-01"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not between '2017-01-01' and '3019-01-01') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 IN ("1000-01-02", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` in ('1000-01-02','2017-01-02','2018-01-01')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_date WHERE col1 NOT IN ("1000-01-02", "2017-01-02", "2018-01-01"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_date NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_date`.`col1` AS `col1` from `test`.`tbl_date` where (`test`.`tbl_date`.`col1` not in ('1000-01-02','2017-01-02','2018-01-01')) +DROP TABLE tbl_date; +# +# Datetime column, singleton histogram +# +CREATE TABLE tbl_datetime (col1 DATETIME(6)); +INSERT INTO tbl_datetime VALUES +("1000-01-01 00:00:01"), ("9999-12-31 23:59:59.999998"), +("2017-01-01 00:00:00"), ("2017-01-01 00:00:00.000001"), +("2017-02-01 00:00:00"), ("2018-01-01 00:00:00.999999"), +("2018-01-01 00:00:01"), ("3019-01-01 10:10:10.101010"), (NULL), (NULL); +ANALYZE TABLE tbl_datetime UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_datetime histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_datetime; +Table Op Msg_type Msg_text +test.tbl_datetime analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "2018-01-01 00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'2018-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00' < `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 > "9999-12-31 23:59:59.999998"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` > TIMESTAMP'9999-12-31 23:59:59.999998') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999998" < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999998' < `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 < "1000-01-01 00:00:00"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` < TIMESTAMP'1000-01-01 00:00:00') +EXPLAIN SELECT * FROM tbl_datetime WHERE "1000-01-01 00:00:00" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'1000-01-01 00:00:00' > `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 < "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` < TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'9999-12-31 23:59:59.999999' > `test`.`tbl_datetime`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "2018-01-01 00:00:00.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'2018-01-01 00:00:00.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "2018-01-01 00:00:00.999999" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'2018-01-01 00:00:00.999999' <= `test`.`tbl_datetime`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 >= "1000-01-01 00:00:01.000000"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` >= TIMESTAMP'1000-01-01 00:00:01') +EXPLAIN SELECT * FROM tbl_datetime WHERE "1000-01-01 00:00:01.000000" <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'1000-01-01 00:00:01' <= `test`.`tbl_datetime`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 != "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 <> "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` <> TIMESTAMP'3019-01-01 10:10:10.10101') +EXPLAIN SELECT * FROM tbl_datetime WHERE "3019-01-01 10:10:10.101010" <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (TIMESTAMP'3019-01-01 10:10:10.10101' <> `test`.`tbl_datetime`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 = "9999-12-31 23:59:59.999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +EXPLAIN SELECT * FROM tbl_datetime WHERE "9999-12-31 23:59:59.999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` = TIMESTAMP'9999-12-31 23:59:59.999999') +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` is not null) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT BETWEEN "2017-01-01 00:00:00.000001" AND "3019-01-01 10:10:10.101010"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not between '2017-01-01 00:00:00.000001' and '3019-01-01 10:10:10.101010') +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 IN ("1000-01-01 00:00:01.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` in ('1000-01-01 00:00:01.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_datetime WHERE col1 NOT IN ("1000-01-01 00:00:01.000000", "2018-01-01 00:00:00.999999", "9999-12-31 23:59:59.999998"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_datetime NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_datetime`.`col1` AS `col1` from `test`.`tbl_datetime` where (`test`.`tbl_datetime`.`col1` not in ('1000-01-01 00:00:01.000000','2018-01-01 00:00:00.999999','9999-12-31 23:59:59.999998')) +DROP TABLE tbl_datetime; +# +# Decimal column, singleton histogram +# +CREATE TABLE tbl_decimal (col1 DECIMAL(65, 30)); +INSERT INTO tbl_decimal VALUES +(00000000000000000000000000000000000.000000000000000000000000000000), +(99999999999999999999999999999999999.999999999999999999999999999998), +(-99999999999999999999999999999999999.999999999999999999999999999998), +(1), (2), (3), (4), (-1), (NULL), (NULL); +ANALYZE TABLE tbl_decimal UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_decimal histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_decimal; +Table Op Msg_type Msg_text +test.tbl_decimal analyze status OK +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` > 1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 1 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (1.000000000000000000000000000000 < `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 > 100000000000000000000000000000000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +EXPLAIN SELECT * FROM tbl_decimal WHERE 100000000000000000000000000000000000 < col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where false +# Expect "10.0" in column "filtered" (we never estimate 0%) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 < -99999999999999999999999999999999999.999999999999999999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` < (-(99999999999999999999999999999999999.999999999999999999999999999999))) +EXPLAIN SELECT * FROM tbl_decimal WHERE -99999999999999999999999999999999999.999999999999999999999999999999 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where ((-(99999999999999999999999999999999999.999999999999999999999999999999)) > `test`.`tbl_decimal`.`col1`) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 < 99999999999999999999999999999999999.999999999999999999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` < 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE 99999999999999999999999999999999999.999999999999999999999999999999 > col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 > `test`.`tbl_decimal`.`col1`) +# Expect "40.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= 4.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 4 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (4.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 >= -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` >= -1.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE -1 <= col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (-1.000000000000000000000000000000 <= `test`.`tbl_decimal`.`col1`) +# Expect "70.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 != 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 <> 2.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` <> 2.000000000000000000000000000000) +EXPLAIN SELECT * FROM tbl_decimal WHERE 2.0 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (2.000000000000000000000000000000 <> `test`.`tbl_decimal`.`col1`) +# Expect "10.0" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 = "99999999999999999999999999999999999.999999999999999999999999999999"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` = 99999999999999999999999999999999999.999999999999999999999999999999) +EXPLAIN SELECT * FROM tbl_decimal WHERE "99999999999999999999999999999999999.999999999999999999999999999999" = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (99999999999999999999999999999999999.999999999999999999999999999999 = `test`.`tbl_decimal`.`col1`) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is null) +# Expect "80.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` is not null) +# Expect "60.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` between (-(1.0)) and 4.0) +# Expect "20.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT BETWEEN -1.0 AND 4.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not between (-(1.0)) and 4.0) +# Expect "30.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 IN +(-99999999999999999999999999999999999.999999999999999999999999999998, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` in ((-(99999999999999999999999999999999999.999999999999999999999999999998)),1.0,2.0)) +# Expect "50.0" in column "filtered" +EXPLAIN SELECT * FROM tbl_decimal WHERE col1 NOT IN +(-99999999999999999999999999999999999.999999999999999999999999999998, 1.0, 2.0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 50.00 Parallel execute (1 workers) +2 SIMPLE tbl_decimal NULL ALL NULL NULL NULL NULL 10 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_decimal`.`col1` AS `col1` from `test`.`tbl_decimal` where (`test`.`tbl_decimal`.`col1` not in ((-(99999999999999999999999999999999999.999999999999999999999999999998)),1.0,2.0)) +DROP TABLE tbl_decimal; +# +# ENUM column, singleton histogram +# Note that we only support equality/inequality operators for ENUM +# columns. +# +CREATE TABLE tbl_enum (col1 ENUM('red', 'black', 'blue', 'green')); +INSERT INTO tbl_enum VALUES ('red'), ('red'), ('black'), ('blue'), ('green'), +('green'), (NULL), (NULL), (NULL); +ANALYZE TABLE tbl_enum UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_enum histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_enum; +Table Op Msg_type Msg_text +test.tbl_enum analyze status OK +# Expect "22.22" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +EXPLAIN SELECT * FROM tbl_enum WHERE 'red' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 'red') +# Expect "55.56" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 'black'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 'black') +EXPLAIN SELECT * FROM tbl_enum WHERE 'black' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where ('black' <> `test`.`tbl_enum`.`col1`) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 0) +# Expect "44.44" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN ('black', 'blue', 'green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 44.44 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 44.44 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in ('black','blue','green')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN ('green', 'blue'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in ('green','blue')) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is null) +# Expect "66.67" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` is not null) +# Test that the numerical representation of enum values also gives the +# correct result. +# Expect "22.22" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 1) +EXPLAIN SELECT * FROM tbl_enum WHERE 1 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 22.22 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 22.22 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (1 = `test`.`tbl_enum`.`col1`) +# Expect "55.56" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 != 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +EXPLAIN SELECT * FROM tbl_enum WHERE col1 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_enum WHERE 2 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 55.56 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (2 <> `test`.`tbl_enum`.`col1`) +# Expect "11.11" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_enum WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_enum WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 11.11 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (100 = `test`.`tbl_enum`.`col1`) +# Expect "44.44" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 IN (2, 3, 4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 44.44 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 44.44 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` in (2,3,4)) +# Expect "33.33" in column "filtered" +EXPLAIN SELECT * FROM tbl_enum WHERE col1 NOT IN (4, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_enum NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`col1` AS `col1` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`col1` not in (4,3)) +DROP TABLE tbl_enum; +# +# SET column, singleton histogram +# Note that we only support equality/inequality operators for SET +# columns. +# +CREATE TABLE tbl_set (col1 SET('red', 'black', 'blue', 'green')); +INSERT INTO tbl_set VALUES ('red'), ('red,black'), ('black,green,blue'), +('black,green,blue'), ('black,green,blue'), +('green'), ('green,red'), ('red,green'), (NULL), +(NULL), (NULL); +ANALYZE TABLE tbl_set UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_set histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE tbl_set; +Table Op Msg_type Msg_text +test.tbl_set analyze status OK +# Expect "18.18" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 'red,green'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +EXPLAIN SELECT * FROM tbl_set WHERE 'red,green' = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 'red,green') +# Expect "63.64" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 'red'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 'red') +EXPLAIN SELECT * FROM tbl_set WHERE 'red' <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where ('red' <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in ('green','black,blue,green')) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN ('green', 'black,blue,green'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in ('green','black,blue,green')) +# Expect "27.27" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 27.27 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 27.27 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is null) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` is not null) +# Test that the numerical representation of enum values also gives the +# correct result. +# Expect "18.18" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_set WHERE 9 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 18.18 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 18.18 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (9 = `test`.`tbl_set`.`col1`) +# Expect "63.64" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 != col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_set WHERE 1 <> col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 63.64 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 63.64 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (1 <> `test`.`tbl_set`.`col1`) +# Expect "72.73" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 != ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> '') +EXPLAIN SELECT * FROM tbl_set WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 72.73 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 72.73 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` <> 0) +# Expect "9.09" in column "filtered", due to the fact that the optimizer +# always assumes that at least one row will match. +EXPLAIN SELECT * FROM tbl_set WHERE col1 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` = 100) +EXPLAIN SELECT * FROM tbl_set WHERE 100 = col1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 9.09 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 9.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (100 = `test`.`tbl_set`.`col1`) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` in (8,14)) +# Expect "36.36" in column "filtered" +EXPLAIN SELECT * FROM tbl_set WHERE col1 NOT IN (8, 14); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 36.36 Parallel execute (1 workers) +2 SIMPLE tbl_set NULL ALL NULL NULL NULL NULL 11 36.36 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`col1` AS `col1` from `test`.`tbl_set` where (`test`.`tbl_set`.`col1` not in (8,14)) +DROP TABLE tbl_set; diff --git a/mysql-test/r/histograms.result-pq b/mysql-test/r/histograms.result-pq new file mode 100644 index 000000000..ec805e737 --- /dev/null +++ b/mysql-test/r/histograms.result-pq @@ -0,0 +1,3391 @@ +################## +# UPDATE HISTOGRAM +################## +# +# Verify that we can build and store a histogram for all valid data types. +# +CREATE TABLE all_types ( +col_bool BOOLEAN, +col_bit BIT(64), +col_tinyint TINYINT, +col_smallint SMALLINT, +col_mediumint MEDIUMINT, +col_integer INTEGER, +col_bigint BIGINT, +col_tinyint_unsigned TINYINT UNSIGNED, +col_smallint_unsigned SMALLINT UNSIGNED, +col_mediumint_unsigned MEDIUMINT UNSIGNED, +col_integer_unsigned INTEGER UNSIGNED, +col_bigint_unsigned BIGINT UNSIGNED, +col_float FLOAT, +col_double DOUBLE, +col_decimal DECIMAL(65, 2), +col_date DATE, +col_time TIME, +col_year YEAR, +col_datetime DATETIME, +col_timestamp TIMESTAMP NULL, +col_char CHAR(255), +col_varchar VARCHAR(255), +col_tinytext TINYTEXT, +col_text TEXT, +col_mediumtext MEDIUMTEXT, +col_longtext LONGTEXT, +col_binary BINARY(255), +col_varbinary VARBINARY(255), +col_tinyblob TINYBLOB, +col_blob BLOB, +col_mediumblob MEDIUMBLOB, +col_longblob LONGBLOB, +col_enum ENUM('red', 'black', 'pink', 'white', 'purple'), +col_set SET('one', 'two', 'three')); +INSERT INTO all_types VALUES ( +NULL, # BOOLEAN +NULL, # BIT +NULL, # TINYINT +NULL, # SMALLINT +NULL, # MEDIUMINT +NULL, # INTEGER +NULL, # BIGINT +NULL, # TINYINT_UNSIGNED +NULL, # SMALLINT_UNSIGNED +NULL, # MEDIUMINT_UNSIGNED +NULL, # INTEGER_UNSIGNED +NULL, # BIGINT_UNSIGNED +NULL, # FLOAT +NULL, # DOUBLE +NULL, # DECIMAL(65, 2) +NULL, # DATE +NULL, # TIME +NULL, # YEAR +NULL, # DATETIME +NULL, # TIMESTAMP +NULL, # CHAR +NULL, # VARCHAR +NULL, # TINYTEXT +NULL, # TEXT +NULL, # MEDIUMTEXT +NULL, # LONGTEXT +NULL, # BINARY +NULL, # VARBINARY +NULL, # TINYBLOB +NULL, # BLOB +NULL, # MEDIUMBLOB +NULL, # LONGBLOB +NULL, # ENUM +NULL); +INSERT INTO all_types VALUES ( +FALSE, # BOOLEAN +b'0000000000000000000000000000000000000000000000000000000000000000', # BIT +-128, # TINYINT +-32768, # SMALLINT +-8388608, # MEDIUMINT +-2147483648, # INTEGER +-9223372036854775808, # BIGINT +0, # TINYINT_UNSIGNED +0, # SMALLINT_UNSIGNED +0, # MEDIUMINT_UNSIGNED +0, # INTEGER_UNSIGNED +0, # BIGINT_UNSIGNED +-3.402823466E+38, # FLOAT +-1.7976931348623157E+308, # DOUBLE +-999999999999999999999999999999999999999999999999999999999999999.99, # DECIMAL(65, 2) +'1000-01-01', # DATE +'-838:59:59.000000', # TIME +1901, # YEAR +'1000-01-01 00:00:00', # DATETIME +'1970-01-02 00:00:01', # TIMESTAMP +'', # CHAR +'', # VARCHAR +'', # TINYTEXT +'', # TEXT +'', # MEDIUMTEXT +'', # LONGTEXT +'', # BINARY +'', # VARBINARY +'', # TINYBLOB +'', # BLOB +'', # MEDIUMBLOB +'', # LONGBLOB +'red', # ENUM +''); +INSERT INTO all_types VALUES ( +TRUE, # BOOLEAN +b'1111111111111111111111111111111111111111111111111111111111111111', # BIT +127, # TINYINT +32767, # SMALLINT +8388607, # MEDIUMINT +2147483647, # INTEGER +9223372036854775807, # BIGINT +255, # TINYINT_UNSIGNED +65535, # SMALLINT_UNSIGNED +16777215, # MEDIUMINT_UNSIGNED +4294967295, # INTEGER_UNSIGNED +18446744073709551615, # BIGINT_UNSIGNED +3.402823466E+38, # FLOAT +1.7976931348623157E+308, # DOUBLE +999999999999999999999999999999999999999999999999999999999999999.99, # DECIMAL(65, 2) +'9999-12-31', # DATE +'838:59:59.000000', # TIME +2155, # YEAR +'9999-12-31 23:59:59', # DATETIME +'2038-01-19 03:14:07', # TIMESTAMP +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # CHAR +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # VARCHAR +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # TINYTEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # TEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # MEDIUMTEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # LONGTEXT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # BINARY +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # VARBINARY +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # TINYBLOB +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # BLOB +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # MEDIUMBLOB +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', # LONGBLOB +'purple', # ENUM +'three'); +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# Check that ANALZYE TABLE without the "UPDATE HISTOGRAM"-clause doesn't +# have any effect on histogram statistics. +ANALYZE TABLE all_types; +Table Op Msg_type Msg_text +test.all_types analyze status OK +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +ANALYZE TABLE all_types UPDATE HISTOGRAM ON col_bool, +col_bit, +col_tinyint, +col_smallint, +col_mediumint, +col_integer, +col_bigint, +col_tinyint_unsigned, +col_smallint_unsigned, +col_mediumint_unsigned, +col_integer_unsigned, +col_bigint_unsigned, +col_float, +col_double, +col_decimal, +col_date, +col_time, +col_year, +col_datetime, +col_timestamp, +col_char, +col_varchar, +col_tinytext, +col_text, +col_mediumtext, +col_longtext, +col_binary, +col_varbinary, +col_tinyblob, +col_blob, +col_mediumblob, +col_longblob, +col_enum, +col_set WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.all_types histogram status Histogram statistics created for column 'col_bigint'. +test.all_types histogram status Histogram statistics created for column 'col_bigint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_binary'. +test.all_types histogram status Histogram statistics created for column 'col_bit'. +test.all_types histogram status Histogram statistics created for column 'col_blob'. +test.all_types histogram status Histogram statistics created for column 'col_bool'. +test.all_types histogram status Histogram statistics created for column 'col_char'. +test.all_types histogram status Histogram statistics created for column 'col_date'. +test.all_types histogram status Histogram statistics created for column 'col_datetime'. +test.all_types histogram status Histogram statistics created for column 'col_decimal'. +test.all_types histogram status Histogram statistics created for column 'col_double'. +test.all_types histogram status Histogram statistics created for column 'col_enum'. +test.all_types histogram status Histogram statistics created for column 'col_float'. +test.all_types histogram status Histogram statistics created for column 'col_integer'. +test.all_types histogram status Histogram statistics created for column 'col_integer_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_longblob'. +test.all_types histogram status Histogram statistics created for column 'col_longtext'. +test.all_types histogram status Histogram statistics created for column 'col_mediumblob'. +test.all_types histogram status Histogram statistics created for column 'col_mediumint'. +test.all_types histogram status Histogram statistics created for column 'col_mediumint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_mediumtext'. +test.all_types histogram status Histogram statistics created for column 'col_set'. +test.all_types histogram status Histogram statistics created for column 'col_smallint'. +test.all_types histogram status Histogram statistics created for column 'col_smallint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_text'. +test.all_types histogram status Histogram statistics created for column 'col_time'. +test.all_types histogram status Histogram statistics created for column 'col_timestamp'. +test.all_types histogram status Histogram statistics created for column 'col_tinyblob'. +test.all_types histogram status Histogram statistics created for column 'col_tinyint'. +test.all_types histogram status Histogram statistics created for column 'col_tinyint_unsigned'. +test.all_types histogram status Histogram statistics created for column 'col_tinytext'. +test.all_types histogram status Histogram statistics created for column 'col_varbinary'. +test.all_types histogram status Histogram statistics created for column 'col_varchar'. +test.all_types histogram status Histogram statistics created for column 'col_year'. +# Remove 'last-updated' from the histogram, since it will change on every +# run. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test all_types col_bigint {"buckets": [[-9223372036854775808, 0.3333333333333333], [9223372036854775807, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_bigint_unsigned {"buckets": [[0, 0.3333333333333333], [18446744073709551615, 0.6666666666666666]], "data-type": "uint", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_binary {"buckets": [["base64:type254:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_bit {"buckets": [[-1, 0.3333333333333333], [0, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_blob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_bool {"buckets": [[0, 0.3333333333333333], [1, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_char {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_date {"buckets": [["1000-01-01", 0.3333333333333333], ["9999-12-31", 0.6666666666666666]], "data-type": "date", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_datetime {"buckets": [["1000-01-01 00:00:00.000000", 0.3333333333333333], ["9999-12-31 23:59:59.000000", 0.6666666666666666]], "data-type": "datetime", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_decimal {"buckets": [[-999999999999999999999999999999999999999999999999999999999999999.99, 0.3333333333333333], [999999999999999999999999999999999999999999999999999999999999999.99, 0.6666666666666666]], "data-type": "decimal", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_double {"buckets": [[-1.7976931348623157e308, 0.3333333333333333], [1.7976931348623157e308, 0.6666666666666666]], "data-type": "double", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_enum {"buckets": [[1, 0.3333333333333333], [5, 0.6666666666666666]], "data-type": "enum", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_float {"buckets": [[-3.4028234663852886e38, 0.3333333333333333], [3.4028234663852886e38, 0.6666666666666666]], "data-type": "double", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_integer {"buckets": [[-2147483648, 0.3333333333333333], [2147483647, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_integer_unsigned {"buckets": [[0, 0.3333333333333333], [4294967295, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_longblob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_longtext {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumblob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumint {"buckets": [[-8388608, 0.3333333333333333], [8388607, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumint_unsigned {"buckets": [[0, 0.3333333333333333], [16777215, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_mediumtext {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_set {"buckets": [[0, 0.3333333333333333], [4, 0.6666666666666666]], "data-type": "set", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_smallint {"buckets": [[-32768, 0.3333333333333333], [32767, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_smallint_unsigned {"buckets": [[0, 0.3333333333333333], [65535, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_text {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_time {"buckets": [["-838:59:59.000000", 0.3333333333333333], ["838:59:59.000000", 0.6666666666666666]], "data-type": "time", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_timestamp {"buckets": [["1970-01-02 00:00:01.000000", 0.3333333333333333], ["2038-01-19 03:14:07.000000", 0.6666666666666666]], "data-type": "datetime", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinyblob {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinyint {"buckets": [[-128, 0.3333333333333333], [127, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinyint_unsigned {"buckets": [[0, 0.3333333333333333], [255, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_tinytext {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_varbinary {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 63, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_varchar {"buckets": [["base64:type254:", 0.3333333333333333], ["base64:type254:YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", 0.6666666666666666]], "data-type": "string", "null-values": 0.3333333333333333, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +test all_types col_year {"buckets": [[1901, 0.3333333333333333], [2155, 0.6666666666666666]], "data-type": "int", "null-values": 0.3333333333333333, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 1024} +# When we remove the table, all histograms that belong to this table +# should also dissapear. +DROP TABLE all_types; +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Check that we don't try to build and/or store histogram statistics for +# unsupported data types. +# +CREATE TABLE unsupported_types (col_geometry GEOMETRY, +col_point POINT, +col_linestring LINESTRING, +col_polygon POLYGON, +col_multipoint MULTIPOINT, +col_multilinestring MULTILINESTRING, +col_multipolygon MULTIPOLYGON, +col_geometrycollection GEOMETRYCOLLECTION, +col_json JSON); +ANALYZE TABLE unsupported_types UPDATE HISTOGRAM ON col_geometry, +col_point, +col_linestring, +col_polygon, +col_multipoint, +col_multilinestring, +col_multipolygon, +col_geometrycollection, +col_json WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.unsupported_types histogram Error The column 'col_geometry' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_geometrycollection' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_json' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_linestring' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_multilinestring' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_multipoint' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_multipolygon' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_point' has an unsupported data type. +test.unsupported_types histogram Error The column 'col_polygon' has an unsupported data type. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +DROP TABLE unsupported_types; +CREATE TABLE t1 (col_integer INT); +# +# Non-existing column +# +ANALYZE TABLE t1 UPDATE HISTOGRAM ON foobar WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error The column 'foobar' does not exist. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Non-existing table +# +ANALYZE TABLE foobar UPDATE HISTOGRAM ON foobar WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.foobar histogram Error Table 'test.foobar' doesn't exist +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Temporary table +# +CREATE TEMPORARY TABLE temp_table (col1 INT); +ANALYZE TABLE temp_table UPDATE HISTOGRAM ON col1 WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.temp_table histogram Error Cannot create histogram statistics for a temporary table. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +DROP TABLE temp_table; +# +# View +# +CREATE VIEW my_view AS SELECT * FROM t1; +ANALYZE TABLE my_view UPDATE HISTOGRAM ON col_integer WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.my_view histogram Error Cannot create histogram statistics for a view. +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +DROP VIEW my_view; +# +# Generated column +# +ALTER TABLE t1 ADD COLUMN virtual_generated INT AS (col_integer + 10) VIRTUAL, +ADD COLUMN stored_generated INT AS (col_integer + 20) STORED; +INSERT INTO t1 (col_integer) VALUES (10), (20), (30); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_integer, +virtual_generated, +stored_generated +WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_integer'. +test.t1 histogram status Histogram statistics created for column 'stored_generated'. +test.t1 histogram status Histogram statistics created for column 'virtual_generated'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col_integer {"buckets": [[10, 0.3333333333333333], [20, 0.6666666666666666], [30, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100} +test t1 stored_generated {"buckets": [[30, 0.3333333333333333], [40, 0.6666666666666666], [50, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100} +test t1 virtual_generated {"buckets": [[20, 0.3333333333333333], [30, 0.6666666666666666], [40, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100} +ALTER TABLE t1 DROP COLUMN virtual_generated, DROP COLUMN stored_generated; +# The histogram for 'virtual_generated' and 'stored_generated' should now +# be gone +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col_integer +DELETE FROM t1; +# +# Check that the server switches between singleton and equi-height when +# it should. +# +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_integer WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_integer'. +SELECT schema_name, table_name, column_name, +JSON_EXTRACT(histogram, '$."histogram-type"') AS should_be_singleton +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME should_be_singleton +test t1 col_integer "singleton" +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_integer WITH 9 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_integer'. +SELECT schema_name, table_name, column_name, +JSON_EXTRACT(histogram, '$."histogram-type"') AS should_be_equiheight +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME should_be_equiheight +test t1 col_integer "equi-height" +DROP TABLE t1; +# +# Check that invalid range for the number of buckets is rejected +# (should be in the range [1, 1024]). +# +ANALYZE TABLE foo UPDATE HISTOGRAM ON foo WITH 0 BUCKETS; +ERROR 22003: Number of buckets value is out of range in 'ANALYZE TABLE' +ANALYZE TABLE foo UPDATE HISTOGRAM ON foo WITH 1025 BUCKETS; +ERROR 22003: Number of buckets value is out of range in 'ANALYZE TABLE' +ANALYZE TABLE foo UPDATE HISTOGRAM ON foo WITH -1 BUCKETS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1 BUCKETS' at line 1 +# +# Check that 'tbl.col' and 'db.tbl.col' isn't allowed. +# +ANALYZE TABLE foo UPDATE HISTOGRAM ON tbl.col WITH 100 BUCKETS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.col WITH 100 BUCKETS' at line 1 +ANALYZE TABLE foo UPDATE HISTOGRAM ON db.tbl.col WITH 100 BUCKETS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.tbl.col WITH 100 BUCKETS' at line 1 +# +# Multiple tables in ANALYZE TABLE .. UPDATE HISTOGRAM +# +ANALYZE TABLE foo, foo2 UPDATE HISTOGRAM ON bar WITH 100 BUCKETS; +Table Op Msg_type Msg_text + histogram Error Only one table can be specified while modifying histogram statistics. +# +# Histogram statistics should not be created for columns covered by a +# single-part unique index +# +CREATE TABLE t1 (col1 INT PRIMARY KEY, +col2 INT, +col3 INT, +UNIQUE INDEX index_1 (col2), +UNIQUE INDEX index_2 (col3, col2)); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3 WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error The column 'col1' is covered by a single-part unique index. +test.t1 histogram Error The column 'col2' is covered by a single-part unique index. +test.t1 histogram status Histogram statistics created for column 'col3'. +# We should end up with histogram statistics for 'col3' +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col3 +# If we hide the index however, we should be able to create a histogram +# for 'col2' +ALTER TABLE t1 ALTER INDEX index_1 INVISIBLE; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +test t1 col3 +DROP TABLE t1; +# +# The server should not create a histogram with more buckets than +# specified +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_LENGTH(histogram->'$.buckets') <= 10 +FROM information_schema.COLUMN_STATISTICS +WHERE schema_name = 'test' AND table_name = 't1' AND column_name = 'col1'; +JSON_LENGTH(histogram->'$.buckets') <= 10 +1 +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 57 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_LENGTH(histogram->'$.buckets') <= 57 +FROM information_schema.COLUMN_STATISTICS +WHERE schema_name = 'test' AND table_name = 't1' AND column_name = 'col1'; +JSON_LENGTH(histogram->'$.buckets') <= 57 +1 +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 255 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_LENGTH(histogram->'$.buckets') <= 255 +FROM information_schema.COLUMN_STATISTICS +WHERE schema_name = 'test' AND table_name = 't1' AND column_name = 'col1'; +JSON_LENGTH(histogram->'$.buckets') <= 255 +1 +# +# If the same column is specified more than once, the server should raise +# the error ER_DUP_FIELDNAME +# +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col1 WITH 10 BUCKETS; +ERROR 42S21: Duplicate column name 'col1' +DROP TABLE t1; +################ +# DROP HISTOGRAM +################ +# Check that we don't have any histograms here +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +CREATE TABLE t1 (col1 INT, col2 VARCHAR(255)); +INSERT INTO t1 VALUES (1, "1"), (2, "2"), (3, "3"), (4, "4"), (5, "5"), +(6, "6"), (7, "7"), (8, "8"), (9, "9"), (10, "10"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +# We should now have two histograms. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ANALYZE TABLE t1 DROP HISTOGRAM ON col2; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics removed for column 'col2'. +# We should now have one histogram. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +ANALYZE TABLE t1 DROP HISTOGRAM ON col1; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics removed for column 'col1'. +# All histograms should have been removed. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +# We should now have two histograms. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ANALYZE TABLE t1 DROP HISTOGRAM ON col2, col1; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics removed for column 'col1'. +test.t1 histogram status Histogram statistics removed for column 'col2'. +# All histograms should have been removed. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# Try to drop histogram statistics for a column that does not have any +# histogram +ANALYZE TABLE t1 DROP HISTOGRAM ON col1; +Table Op Msg_type Msg_text +test.t1 histogram Error No histogram statistics found for column 'col1'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +ANALYZE TABLE t1 DROP HISTOGRAM ON col1, col2; +Table Op Msg_type Msg_text +test.t1 histogram Error No histogram statistics found for column 'col1'. +test.t1 histogram status Histogram statistics removed for column 'col2'. +# +# Non-existing column +# +ANALYZE TABLE t1 DROP HISTOGRAM ON foobar; +Table Op Msg_type Msg_text +test.t1 histogram Error No histogram statistics found for column 'foobar'. +# +# Non-existing table +# +ANALYZE TABLE foo DROP HISTOGRAM ON foobar; +Table Op Msg_type Msg_text +test.foo histogram Error No histogram statistics found for column 'foobar'. +# +# The same column specified multiple times +# +ANALYZE TABLE foo DROP HISTOGRAM ON foobar, foobar; +ERROR 42S21: Duplicate column name 'foobar' +# +# Multiple tables specified in ANALYZE TABLE .. DROP HISTOGRAM should not +# be allowed. +# +CREATE TABLE t2 (col1 INT); +ANALYZE TABLE t1, t2 DROP HISTOGRAM ON col1; +Table Op Msg_type Msg_text + histogram Error Only one table can be specified while modifying histogram statistics. +DROP TABLE t1, t2; +##################################### +# HISTOGRAM REMOVAL ON DDL STATEMENTS +##################################### +# Check that we don't have any histograms here +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# DROP TABLE +# +CREATE TABLE t1 (col1 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +DROP TABLE t1; +SELECT COUNT(*) AS should_be_0 FROM information_schema.COLUMN_STATISTICS; +should_be_0 +0 +# +# Rename column +# +CREATE TABLE t1 (col1 INT, col2 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ALTER TABLE t1 CHANGE COLUMN col1 col1_renamed INT; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +# +# Change column definition +# +ALTER TABLE t1 CHANGE COLUMN col2 col2 VARCHAR(255); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# +# Drop column +# +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +ALTER TABLE t1 DROP COLUMN col2; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# +# Rename table +# +INSERT INTO t1 VALUES (1), (2); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1_renamed WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1_renamed'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +RENAME TABLE t1 TO t1_renamed; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1_renamed col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE t1_renamed RENAME TO t1; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE t1 RENAME TO t1_renamed, ALGORITHM = INPLACE; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1_renamed col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE t1_renamed RENAME TO t1, ALGORITHM = COPY; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1_renamed {"buckets": [[1, 0.5], [2, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +DROP TABLE t1; +# +# Do RENAME TABLE on a table with string contents, since they have a more +# complicated memory handling. Test both singleton and equi-height +# +CREATE TABLE t1 (col1 VARCHAR(255), col2 VARCHAR(255)); +INSERT INTO t1 VALUES ('foo', 'foo'), ('bar', 'bar'), ('fo', 'fo'), +('yay', 'yay'); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1 col1 {"buckets": [["base64:type254:YmFy", 0.25], ["base64:type254:Zm8=", 0.5], ["base64:type254:Zm9v", 0.75], ["base64:type254:eWF5", 1.0]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test t1 col2 {"buckets": [["base64:type254:YmFy", "base64:type254:Zm8=", 0.5, 2], ["base64:type254:Zm9v", "base64:type254:eWF5", 1.0, 2]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 2} +RENAME TABLE t1 TO t1_renamed; +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test t1_renamed col1 {"buckets": [["base64:type254:YmFy", 0.25], ["base64:type254:Zm8=", 0.5], ["base64:type254:Zm9v", 0.75], ["base64:type254:eWF5", 1.0]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test t1_renamed col2 {"buckets": [["base64:type254:YmFy", "base64:type254:Zm8=", 0.5, 2], ["base64:type254:Zm9v", "base64:type254:eWF5", 1.0, 2]], "data-type": "string", "null-values": 0.0, "collation-id": 255, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 2} +DROP TABLE t1_renamed; +# +# Drop database +# +CREATE DATABASE histogram_db; +CREATE TABLE histogram_db.t1 (col1 INT); +ANALYZE TABLE histogram_db.t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +histogram_db.t1 histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +histogram_db t1 col1 +DROP DATABASE histogram_db; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# +# Change character set +# +CREATE TABLE t1 (col1 VARCHAR(255), col2 CHAR(10), col3 TEXT, col4 INT, +col5 BLOB) CHARACTER SET latin1; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3, col4, col5 +WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +test.t1 histogram status Histogram statistics created for column 'col4'. +test.t1 histogram status Histogram statistics created for column 'col5'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +ALTER TABLE t1 CONVERT TO CHARACTER SET utf8mb4; +# Only col4 and col5 should remain +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col4 +test t1 col5 +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3, col4, col5 +WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +test.t1 histogram status Histogram statistics created for column 'col4'. +test.t1 histogram status Histogram statistics created for column 'col5'. +ALTER TABLE t1 MODIFY COLUMN col1 VARCHAR(255) CHARACTER SET latin1; +# col2, col3, col4 and col5 should remain +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +DROP TABLE t1; +# +# Adding a column should not affect existing histograms +# +CREATE TABLE t1 (col1 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +ALTER TABLE t1 ADD COLUMN col2 INT; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +# +# Dropping a column without histogram should not affect existing +# histograms +# +ALTER TABLE t1 DROP COLUMN col2; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +DROP TABLE t1; +# +# Column names are always case insensitive, so verify that histogram +# statistics respect this. +# +CREATE TABLE t1 (col1 INT, col2 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON COL1, col2 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +ALTER TABLE t1 DROP COLUMN COL1; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +DROP TABLE t1; +# +# Using ANALYZE TABLE in a prepared statement +# +CREATE TABLE t(x INT); +PREPARE ps FROM 'ANALYZE TABLE t UPDATE HISTOGRAM ON x WITH 10 BUCKETS'; +EXECUTE ps; +Table Op Msg_type Msg_text +test.t histogram status Histogram statistics created for column 'x'. +EXECUTE ps; +Table Op Msg_type Msg_text +test.t histogram status Histogram statistics created for column 'x'. +DROP TABLE t; +# +# Check that any existing histogram is removed if we add a single-part +# unique index to a column +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 INT, col5 INT, col6 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3, col4, col5, col6 +WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +test.t1 histogram status Histogram statistics created for column 'col4'. +test.t1 histogram status Histogram statistics created for column 'col5'. +test.t1 histogram status Histogram statistics created for column 'col6'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD UNIQUE INDEX (col1); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col2 +test t1 col3 +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD UNIQUE INDEX (col2), ALGORITHM = INPLACE; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col3 +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD UNIQUE INDEX (col3), ALGORITHM = COPY; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col4 +test t1 col5 +test t1 col6 +ALTER TABLE t1 ADD PRIMARY KEY (col4); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col5 +test t1 col6 +# Adding a multi-part unique index should NOT remove histograms +ALTER TABLE t1 ADD UNIQUE INDEX (col5, col6); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col5 +test t1 col6 +CREATE UNIQUE INDEX index_col5 ON t1 (col5); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col6 +# Adding a non-unique single part index should NOT remove histograms +CREATE INDEX index_col6 ON t1 (col6); +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col6 +ALTER TABLE t1 MODIFY COLUMN col6 INT UNIQUE; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +# Set the server in read-only mode, and verify that a histogram cannot +# be created. +SET GLOBAL read_only = 1; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1024 BUCKETS; +Table Op Msg_type Msg_text + histogram Error The server is in read-only mode. +SET GLOBAL read_only = 0; +DROP TABLE t1; +# +# Bug#25841057 WL8943: ASSERTION `!TABLE || (!TABLE->READ_SET || +# BITMAP_IS_SET(TABLE->READ_SET, +# +CREATE TABLE t1 ( +c1 int(11) DEFAULT NULL, +c2 int(11) GENERATED ALWAYS AS ((c1 * 2)) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON c2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'c2'. +INSERT into t1(c1) VALUES (1); +ALTER TABLE t1 ADD UNIQUE INDEX i (c2); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON c2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error The column 'c2' is covered by a single-part unique index. +ALTER TABLE t1 DROP KEY i; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON c2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'c2'. +DROP TABLE t1; +# +# Bug#25929588 WL8943:ASSERTION `STORED_OBJECT == NULLPTR' FAILED. +# +CREATE TABLE t1 (col1 INT); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +ALTER TABLE t1 DROP COLUMN foobar, CHANGE COLUMN col1 col2 INT; +ERROR 42000: Can't DROP 'foobar'; check that column/key exists +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test t1 col1 +DROP TABLE t1; +# +# Bug#25950613 WL8943:ASSERTION `!TABLE || (!TABLE->WRITE_SET || +# BITMAP_IS_SET(TABLE->WRITE_SET +# +CREATE TABLE foo (col1 INT, +col2 INT AS (col1 + 1) VIRTUAL, +col3 INT AS (col2 + 1) VIRTUAL); +INSERT INTO foo (col1) VALUES (1); +ANALYZE TABLE foo UPDATE HISTOGRAM ON col3 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.foo histogram status Histogram statistics created for column 'col3'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test foo col3 +DROP TABLE foo; +# +# Bug#25985106 WL8943:ASSERTION `FLOAT_COMPARE::ALMOST_EQUAL( +# CUMULATIVE_FREQUENCY + GET_NULL_V +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 SELECT 1; +INSERT INTO t1 SELECT col1 + 1 FROM t1; +INSERT INTO t1 SELECT col1 + 2 FROM t1; +INSERT INTO t1 SELECT col1 + 4 FROM t1; +INSERT INTO t1 SELECT col1 + 8 FROM t1; +INSERT INTO t1 SELECT col1 + 16 FROM t1; +INSERT INTO t1 SELECT col1 + 32 FROM t1; +INSERT INTO t1 SELECT col1 + 64 FROM t1; +INSERT INTO t1 SELECT col1 + 128 FROM t1; +INSERT INTO t1 SELECT col1 + 256 FROM t1 LIMIT 38; +INSERT INTO t1 SELECT NULL; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +DROP TABLE t1; +# +# Bug#26021907 WL8943:ASSERTION `M_SCAN_VALUE == 1' FAILED. +# +CREATE TABLE p (col1 INT PRIMARY KEY, col2 INT, col3 INT) +PARTITION BY KEY (col1) PARTITIONS 4; +INSERT INTO p VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3); +ANALYZE TABLE p UPDATE HISTOGRAM ON col2, col3 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.p histogram status Histogram statistics created for column 'col2'. +test.p histogram status Histogram statistics created for column 'col3'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test p col2 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test p col3 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +ALTER TABLE p PARTITION BY HASH (col1) PARTITIONS 2; +# Histogram statistics should still be present after a re-partitioning. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test p col2 +test p col3 +# Histogram statistics should remain the same now, even though the +# partitions specification is different. +ANALYZE TABLE p UPDATE HISTOGRAM ON col2, col3 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.p histogram status Histogram statistics created for column 'col2'. +test.p histogram status Histogram statistics created for column 'col3'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test p col2 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +test p col3 {"buckets": [[1, 0.3333333333333333], [2, 0.6666666666666666], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 10} +DROP TABLE p; +# +# Bug#26026996 WL8943:ASSERTION `MDL_CHECKER::IS_WRITE_LOCKED(M_THD, +# NEW_OBJECT)' FAILED. +# +CREATE SCHEMA foo; +CREATE SCHEMA bar; +CREATE TABLE foo.tbl (col1 INT); +ANALYZE TABLE foo.tbl UPDATE HISTOGRAM ON col1 WITH 10 BUCKETS; +Table Op Msg_type Msg_text +foo.tbl histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +foo tbl col1 +RENAME TABLE foo.tbl TO bar.tbl2; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +bar tbl2 col1 +DROP SCHEMA foo; +DROP SCHEMA bar; +# +# Bug#26035995 WL8943:HISTOGRAM NOT CREATED FOR TABLE CREATED WITH +# ENCRYPTION='N' +# +# Restart the server with keyring enabled +CREATE TABLE not_encrypted1 (col1 INT) ENCRYPTION='n'; +CREATE TABLE not_encrypted2 (col1 INT) ENCRYPTION='N'; +CREATE TABLE encrypted1 (col1 INT) ENCRYPTION='y'; +CREATE TABLE encrypted2 (col1 INT) ENCRYPTION='Y'; +INSERT INTO not_encrypted1 VALUES (1); +INSERT INTO not_encrypted2 VALUES (1); +INSERT INTO encrypted1 VALUES (1); +INSERT INTO encrypted2 VALUES (1); +ANALYZE TABLE not_encrypted1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.not_encrypted1 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE not_encrypted2 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.not_encrypted2 histogram status Histogram statistics created for column 'col1'. +ANALYZE TABLE encrypted1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.encrypted1 histogram Error Cannot create histogram statistics for an encrypted table. +ANALYZE TABLE encrypted2 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.encrypted2 histogram Error Cannot create histogram statistics for an encrypted table. +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +test not_encrypted1 col1 +test not_encrypted2 col1 +# Ensure that histogram statistics are removed if we enable encryption +ALTER TABLE not_encrypted1 ENCRYPTION='y'; +ALTER TABLE not_encrypted2 ENCRYPTION='Y'; +SELECT schema_name, table_name, column_name +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME +DROP TABLE encrypted1; +DROP TABLE not_encrypted1; +DROP TABLE encrypted2; +DROP TABLE not_encrypted2; +# +# Bug#26114424 WL8943:SIG11 IN DROP_HISTOGRAMS AT SQL/SQL_TABLE.CC +# +# Create a non-transactional table with a trigger. +CREATE TABLE t1 (i INT, at INT, k INT) ENGINE=InnoDB; +CREATE TRIGGER ai AFTER INSERT ON t1 FOR EACH ROW SET @a:= NEW.at; +ALTER TABLE t1 ADD PRIMARY KEY (i); +DROP TABLE t1; +# +# Bug#26303972 HISTOGRAM.CC:1169: BOOL HISTOGRAMS::DROP_ALL_HISTOGRAMS +# +CREATE TABLE ftidx_encrypted (a VARCHAR(255), FULLTEXT ftidx(a)) +ENGINE=InnoDB ENCRYPTION='N'; +ALTER TABLE ftidx_encrypted RENAME TO ftidx_encrypted_renamed, KEY_BLOCK_SIZE=0; +DROP TABLE ftidx_encrypted_renamed; +# +# Bug#26388098 WL9223: ASSERTION `DISTANCE >= 0.0' FAILED. +# +CREATE TABLE t1 ( +ten int(11) DEFAULT NULL, +twenty int(11) DEFAULT NULL, +forty int(11) DEFAULT NULL, +eighty int(11) DEFAULT NULL, +KEY idx3 (twenty,ten), +KEY idx (ten) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(6,16,36,76), (5,15,35,35), (9,19,39,79), (1,1,1,41), (7,17,17,17), +(3,13,33,73), (7,17,37,37), (1,1,1,1), (9,9,9,9), (0,0,20,60), (5,15,35,75), +(0,10,10,10), (3,3,3,3), (8,8,8,48), (8,18,38,38), (8,8,28,28), (3,13,33,33), +(7,7,7,7), (2,2,22,62), (0,0,0,40), (0,0,0,0), (2,12,12,52), (6,6,6,6), +(9,19,19,19), (5,15,15,15), (5,5,5,5), (5,5,25,65), (4,14,14,14), (3,3,23,23), +(4,4,4,44), (4,14,34,74), (6,6,26,26), (7,17,17,57), (7,17,17,17), (8,18,18,18), +(1,11,11,11), (4,4,4,4), (4,4,24,24), (8,18,18,18), (1,11,11,51), (7,7,27,27), +(8,8,8,8), (9,9,29,29), (7,7,7,47), (1,1,1,1), (5,5,25,25), (4,4,24,64), +(9,9,29,69), (0,10,10,10), (9,9,9,49); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON eighty WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'eighty'. +EXPLAIN SELECT a.forty, b.twenty FROM t1 AS a, t1 AS b +WHERE a.twenty = b.ten AND b.eighty >= (3 + 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 50 60.00 Parallel execute (1 workers) +2 SIMPLE b NULL ALL idx NULL NULL NULL 50 60.00 Using where +2 SIMPLE a NULL ref idx3 idx3 5 test.b.ten 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`forty` AS `forty`,`test`.`b`.`twenty` AS `twenty` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`a`.`twenty` = `test`.`b`.`ten`) and (`test`.`b`.`eighty` >= ((3 + 20)))) +DROP TABLE t1; +# +# Bug#26389682 WL9223: ASSERTION `VALUE_CONVERTED <= UPPER_CONVERTED' +# FAILED. +# +CREATE TABLE `t1` ( +`two` blob, +`ten` blob, +`sixty` text, +`eighty` blob, +`tenPercent` text +) DEFAULT CHARSET=utf8mb4; +INSERT INTO `t1` VALUES +('0','6','16','76','6'), ('1','5','35','35','5'), ('1','9','19','79','9'), +('1','1','41','41','1'), ('1','7','37','17','7'), ('1','3','13','73','3'), +('1','7','37','37','7'), ('1','1','1','1','1'), ('1','9','29','9','9'), +('0','0','0','60','0'), ('1','5','15','75','5'), ('0','0','10','10','0'), +('1','3','3','3','3'), ('0','8','48','48','8'), ('0','8','38','38','8'), +('0','8','28','28','8'), ('1','3','33','33','3'), ('1','7','7','7','7'), +('0','2','2','62','2'), ('0','0','40','40','0'), ('0','0','20','0','0'), +('0','2','52','52','2'), ('0','6','26','6','6'), ('1','9','19','19','9'), +('1','5','15','15','5'), ('1','5','25','5','5'), ('1','5','5','65','5'), +('0','4','14','14','4'), ('1','3','23','23','3'), ('0','4','44','44','4'), +('0','4','14','74','4'), ('0','6','26','26','6'), ('1','7','57','57','7'), +('1','7','17','17','7'), ('0','8','18','18','8'), ('1','1','11','11','1'), +('0','4','24','4','4'), ('0','4','24','24','4'), ('0','8','38','18','8'), +('1','1','51','51','1'), ('1','7','27','27','7'), ('0','8','8','8','8'), +('1','9','29','29','9'), ('1','7','47','47','7'), ('1','1','21','1','1'), +('1','5','25','25','5'), ('0','4','4','64','4'), ('1','9','9','69','9'), +('0','0','30','10','0'), ('1','9','49','49','9'), ('0','6','36','36','6'), +('0','0','20','20','0'), ('0','2','2','2','2'), ('1','1','1','61','1'), +('0','8','28','8','8'), ('0','2','42','42','2'), ('0','2','12','72','2'), +('0','6','6','66','6'), ('1','7','7','67','7'), ('0','8','8','68','8'), +('0','4','34','14','4'), ('0','4','4','4','4'), ('0','6','6','6','6'), +('0','6','16','16','6'), ('1','7','17','77','7'), ('0','8','18','78','8'), +('0','2','22','22','2'), ('0','0','0','0','0'), ('1','9','9','9','9'), +('1','9','39','39','9'), ('1','7','27','7','7'), ('0','2','32','32','2'), +('1','1','31','11','1'), ('0','2','12','12','2'), ('0','4','54','54','4'), +('0','4','34','34','4'), ('1','1','21','21','1'), ('1','3','33','13','3'), +('0','6','56','56','6'), ('1','1','11','71','1'), ('1','3','53','53','3'), +('0','0','10','70','0'), ('0','6','36','16','6'), ('1','5','55','55','5'), +('0','2','22','2','2'), ('1','5','45','45','5'), ('1','3','43','43','3'), +('0','2','32','12','2'), ('1','1','31','31','1'), ('0','0','50','50','0'), +('1','3','13','13','3'), ('1','5','35','15','5'), ('1','9','59','59','9'), +('1','5','5','5','5'), ('0','6','46','46','6'), ('0','0','30','30','0'), +('0','8','58','58','8'), ('1','3','23','3','3'), ('1','3','3','63','3'), +('1','9','39','19','9'), ('1','3','44',NULL,'5'), ('1','7','38',NULL,'6'), +('1','1','52','64','6'), ('1','6','39',NULL,'0'), ('1','7','44','48','6'), +('0','8','42',NULL,'6'), ('0','0','7',NULL,'9'), ('1','0','45',NULL,'1'), +('1','5','40','32','0'), ('0','3','52',NULL,'3'), ('1','1','8','48','2'), +('0','3','20','16','2'), ('0','2','15',NULL,'6'), ('1','6','48','48','8'), +('0','5','31',NULL,'7'), ('0','6','20','0','4'), ('0','2','12','16','6'), +('0','4','20','64','4'), ('0','6','56','48','8'), ('0','2','40','16','4'), +('0','2','52','48','6'), ('1','9','25',NULL,'0'), ('0','0','12',NULL,'1'), +('0','1','0','64','8'), ('1','4','48','32','6'), ('1','2','0','0','4'), +('0','5','52','64','8'), ('0','8','44','48','2'), ('0','8','40','0','2'), +('0','6','8',NULL,'6'), ('1','1','24','16','6'), ('0','6','44','0','4'), +('1','1','36','0','2'), ('1','0','39',NULL,'7'), ('0','0','8','32','8'), +('0','2','16','32','0'), ('0','5','8','64','4'), ('0','9','38',NULL,'9'), +('1','7','32','48','4'), ('0','3','8','48','4'), ('1','8','32',NULL,'5'), +('1','3','12','32','0'), ('0','3','24','16','6'), ('0','3','53',NULL,'3'), +('1','6','44','32','8'), ('1','0','4','32','2'), ('1','4','4','48','8'), +('1','8','8',NULL,'5'), ('1','6','16',NULL,'2'), ('0','7','20','64','8'), +('0','2','55',NULL,'6'), ('0','8','5',NULL,'1'), ('1','9','36','48','8'), +('1','3','20','32','2'), ('0','0','56','0','6'), ('1','4','25',NULL,'2'), +('0','3','0',NULL,'9'), ('1','1','32',NULL,'5'), ('0','4','32',NULL,'0'), +('0','9','4','0','2'), ('1','9','36','64','8'), ('0','3','48','16','4'), +('0','9','12','0','0'), ('1','4','39',NULL,'6'), ('0','5','16','16','6'), +('0','2','17',NULL,'3'), ('1','9','52','0','8'), ('1','2','28',NULL,'3'), +('1','5','28','32','8'), ('1','4','0','48','8'), ('1','4','39',NULL,'7'), +('1','3','16',NULL,'6'), ('0','3','17',NULL,'4'), ('1','2','18',NULL,'9'), +('0','6','52','16','2'), ('1','1','15',NULL,'7'), ('0','5','4','64','6'), +('0','6','48','64','8'), ('0','7','56',NULL,'0'), ('1','0','28',NULL,'9'), +('0','4','40','32','8'), ('1','9','52','0','6'), ('1','4','30',NULL,'3'), +('0','8','8',NULL,'0'), ('0','6','0','64','8'), ('0','6','38',NULL,'9'), +('0','0','52','64','0'), ('0','5','39',NULL,'3'), ('0','0','52','16','0'), +('0','5','8','64','0'), ('1','1','44','16','0'), ('0','4','52',NULL,'2'), +('0','9','0',NULL,'3'), ('0','3','36','64','2'), ('0','3','52','16','8'), +('1','5','4','16','2'), ('0','9','58',NULL,'9'); +UPDATE mysql.innodb_table_stats SET n_rows = 197 +WHERE database_name = "test" AND table_name = "t1"; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON tenPercent WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'tenPercent'. +EXPLAIN SELECT a.two, b.eighty FROM t1 AS a,t1 AS b +WHERE a.ten = b.sixty AND b.tenPercent < (9 + (5*10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE b NULL ALL NULL NULL NULL NULL 197 33.33 Using where +1 SIMPLE a NULL ALL NULL NULL NULL NULL 197 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`two` AS `two`,`test`.`b`.`eighty` AS `eighty` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`a`.`ten` = `test`.`b`.`sixty`) and (`test`.`b`.`tenPercent` < ((9 + (5 * 10))))) +DROP TABLE t1; +# +# Bug#26388066 WL9223:ASSERTION `FILTER >= 0.0F && FILTER <= 1.0F' FAILED +# +CREATE TABLE t1 ( +tenPercent int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (6),(5),(9),(1),(7); +UPDATE mysql.innodb_table_stats SET n_rows = 5 +WHERE database_name = "test" AND table_name = "t1"; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON tenPercent WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'tenPercent'. +EXPLAIN SELECT b.tenPercent FROM t1 AS b WHERE b.tenPercent NOT BETWEEN 3 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`b`.`tenPercent` AS `tenPercent` from `test`.`t1` `b` where (`test`.`b`.`tenPercent` not between 3 and 0) +EXPLAIN SELECT b.tenPercent FROM t1 AS b WHERE b.tenPercent BETWEEN 3 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`b`.`tenPercent` AS `tenPercent` from `test`.`t1` `b` where (`test`.`b`.`tenPercent` between 3 and 0) +DROP TABLE t1; +# +# Bug#26388217 WL9223: SIG 11 IN STRING::NUMCHARS | +# /SQL-COMMON/SQL_STRING.CC:680 +# +CREATE TABLE k ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_255_utf8 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_255_latin1 varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_varchar_255_latin1_key varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_date date DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key), +KEY col_varchar_255_utf8_key (col_varchar_255_utf8_key), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_date_key (col_date_key), +KEY col_varchar_255_latin1_key (col_varchar_255_latin1_key), +KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key) +) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO k VALUES (1, +'wrhhsy', +'rhgpwcrafs', +'hgpwcrafsb', +'i', +NULL, +'gpwcrafsbt', +'1000-01-01 00:00:00', +'1000-01-01', +'n', +'LUWOS', +'1000-01-01', +NULL, +'pwcrafsbtn', +'2002-08-22 03:35:28'); +CREATE TABLE a ( +col_datetime_key datetime DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_latin1 varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_date date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_255_utf8 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_latin1_key varchar(255) CHARACTER SET latin1 DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key), +KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key), +KEY col_varchar_255_utf8_key (col_varchar_255_utf8_key), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_255_latin1_key (col_varchar_255_latin1_key) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO a VALUES (NULL, +'2008-10-25 07:07:49', +'BXLIC', +'GSDDY', +'w', +'crbhsozfbh', +'s', +1, +'the', +'2005-04-01', +104529920, +'1000-01-01', +NULL, +'like', +'CGLFP'); +CREATE TABLE g ( +col_varchar_10_latin1 varchar(10) CHARACTER SET latin1 DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +col_varchar_255_latin1_key varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_255_latin1 varchar(255) CHARACTER SET latin1 DEFAULT NULL, +col_varchar_255_utf8 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_date date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) CHARACTER SET latin1 DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8 DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_255_latin1_key (col_varchar_255_latin1_key), +KEY col_date_key (col_date_key), +KEY col_int_key (col_int_key), +KEY col_varchar_10_utf8_key (col_varchar_10_utf8_key), +KEY col_varchar_10_latin1_key (col_varchar_10_latin1_key), +KEY col_varchar_255_utf8_key (col_varchar_255_utf8_key), +KEY col_datetime_key (col_datetime_key) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO g VALUES ('o', +'2009-05-15 00:00:00', +'PFJGE', +'ASUNU', +'yj', +'if', +'1000-01-01', +'2001-04-06', +4, +-1442512896, +'m', +'his', +1, +'I', +'2007-05-11 00:00:00'); +ANALYZE TABLE g UPDATE HISTOGRAM ON col_varchar_10_utf8 WITH 250 BUCKETS; +Table Op Msg_type Msg_text +test.g histogram status Histogram statistics created for column 'col_varchar_10_utf8'. +EXPLAIN SELECT alias1 . col_date_key AS field1 FROM k AS alias1 +LEFT OUTER JOIN a AS alias2 +RIGHT OUTER JOIN g AS alias3 ON alias2 . col_varchar_255_utf8_key = alias3 . col_varchar_10_utf8 +ON alias1 . col_varchar_10_latin1 = alias3 . col_varchar_255_latin1 +LEFT OUTER JOIN g AS alias4 ON alias1 . col_varchar_255_utf8_key = alias4 . col_varchar_255_utf8_key +WHERE alias2 . pk = 3 ORDER BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_date_key` AS `field1` from `test`.`k` `alias1` join `test`.`g` `alias3` join `test`.`a` `alias2` left join `test`.`g` `alias4` on(multiple equal(`test`.`alias1`.`col_varchar_255_utf8_key`, `test`.`alias4`.`col_varchar_255_utf8_key`)) where ((NULL = `test`.`alias3`.`col_varchar_10_utf8`) and (`test`.`alias1`.`col_varchar_10_latin1` = `test`.`alias3`.`col_varchar_255_latin1`) and multiple equal(3, NULL)) order by `field1` +DROP TABLE a, k, g; +# +# Bug#26495045 WL9223:ASSERTION `FILTER >= 0.0F && FILTER <= 1.0F' FAILED. +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +UPDATE mysql.innodb_table_stats SET n_rows = 3 +WHERE database_name = "test" AND table_name = "t1"; +EXPLAIN SELECT * FROM t1 WHERE col1 <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 3) +DROP TABLE t1; +# +# Bug#26542689 WL9223: VIRTUAL LONGLONG +# ITEM_TIME_WITH_REF::VAL_DATE_TEMPORAL(): ASSERTION `0' +# +CREATE TABLE table1 ( +col_datetime_key datetime DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_date date DEFAULT NULL, +col_time time DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_blob_key blob, +col_time_key time DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_blob blob, +PRIMARY KEY (pk), +KEY col_datetime_key (col_datetime_key), +KEY col_int_key (col_int_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_time_key (col_time_key), +KEY col_varchar_key (col_varchar_key), +KEY col_date_key (col_date_key), +KEY test_idx (col_int_key,col_int) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table1 VALUES ('2000-09-05 00:00:00', +'2003-11-25 11:17:04', +1, +'2006-02-27', +'00:20:06', +'l', +1, +'uajnlnsnzyo', +'23:18:41', +7, +'a', +'2001-02-18', +'jn'); +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_varchar WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_datetime WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_time WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_datetime_key WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_date_key WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_blob WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_int_key WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_date WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_int WITH 1000 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table1 UPDATE HISTOGRAM ON col_blob_key WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table1 histogram status Histogram statistics created for column 'col_blob_key'. +CREATE TABLE table2 ( +col_time_key time DEFAULT NULL, +col_blob_key blob, +col_int int(11) DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_date date DEFAULT NULL, +col_time time DEFAULT NULL, +col_blob blob, +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_varchar_key varchar(1) DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_key (col_time_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_datetime_key (col_datetime_key), +KEY col_date_key (col_date_key), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key), +KEY test_idx (col_int_key,pk) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table2 VALUES ('10:39:59', +'tymjpskqjjap', +9, +'2006-07-17 08:29:28', +'y', +'2002-10-02', +'00:20:00', +'mjpskqjjapldefot', +'2008-11-12', +3, +1, +NULL, +'2009-03-19 00:00:00'); +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_blob_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_blob_key'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_date WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_blob WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_int WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_datetime_key WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_int_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_time WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table2 UPDATE HISTOGRAM ON col_varchar WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table2 histogram status Histogram statistics created for column 'col_varchar'. +CREATE TABLE table3 ( +col_int_key int(11) DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_datetime_key datetime DEFAULT NULL, +col_blob blob, +col_blob_key blob, +col_int int(11) DEFAULT NULL, +col_time time DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_date date DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_varchar_key (col_varchar_key), +KEY col_time_key (col_time_key), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table3 VALUES (6, +'2003-08-27 00:00:00', +1, +'2002-07-10 12:41:35', +NULL, +'xgtmzjkhjqplanraxafy', +5, +'05:20:53', +'q', +'g', +'00:30:27', +'2008-11-18', +'2008-05-26'); +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_date_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_time_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_date WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_datetime_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_blob_key WITH 20 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_blob_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_blob WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_time WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_int WITH 1000 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_varchar WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_varchar_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE table3 UPDATE HISTOGRAM ON col_datetime WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.table3 histogram status Histogram statistics created for column 'col_datetime'. +CREATE TABLE table4 ( +col_datetime datetime DEFAULT NULL, +col_time time DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_date date DEFAULT NULL, +col_int int(11) DEFAULT NULL, +col_blob blob, +col_blob_key blob, +col_varchar_key varchar(1) DEFAULT NULL, +col_date_key date DEFAULT NULL, +pk int(11) NOT NULL AUTO_INCREMENT, +col_datetime_key datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_key (col_time_key), +KEY col_int_key (col_int_key), +KEY col_blob_key (col_blob_key(255)), +KEY col_varchar_key (col_varchar_key), +KEY col_date_key (col_date_key), +KEY col_datetime_key (col_datetime_key), +KEY test_idx (pk,col_int_key) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO table4 VALUES ('2009-05-17 00:00:00', +'00:20:03', +'00:20:04', +'u', +6, +'2008-02-12', +0, +'orecqsomotqciisj', +'recqsomotqciisjzx', +'e', +'2005-03-21', +1, +'2009-11-16 02:30:22'); +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_time_key WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_date WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_datetime_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_int_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_blob WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_blob'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_time WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_varchar_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_int WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_blob_key WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_blob_key'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_varchar WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE table4 UPDATE HISTOGRAM ON col_date_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.table4 histogram status Histogram statistics created for column 'col_date_key'. +CREATE VIEW view_BB AS SELECT * FROM table2; +CREATE VIEW view_A AS SELECT * FROM table1; +WITH cte AS ( +SELECT alias2 . col_time AS field1 +FROM view_BB AS alias1 LEFT JOIN view_A AS alias2 +ON alias1 . col_varchar = alias2 . col_varchar_key +WHERE alias2 . col_int_key > 2 AND alias2 . col_int_key < ( 5 + 1 ) +ORDER BY field1 +LIMIT 1000 OFFSET 35) +UPDATE table3 AS OUTR1, table4 AS OUTR2, cte AS OUTRcte, cte AS OUTRcte1 +SET OUTR1.col_varchar_key = 'hey' +WHERE OUTRcte . field1 <> 3; +DROP VIEW view_BB, view_A; +DROP TABLE table1, table2, table3, table4; +# Inverted BETWEEN predicate (lower bound is higher/greater than the +# upper bound) +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 64 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 4 AND 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 4 and 2) +EXPLAIN SELECT * FROM t1 WHERE col1 NOT BETWEEN 4 AND 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` not between 4 and 2) +DROP TABLE t1; +# +# Bug#26555815 WL9223: ASSERTION `DISTANCE >= 0.0' FAILED. +# +CREATE TABLE t1 (col1 BIGINT); +INSERT INTO t1 VALUES (-8454100925504552960), (-3300857051885862912), (0), (0), +(0), (0), (0), (2), (2), (2), (6), (16), (56), (86), (142), (191), (7294), +(16729), (22243), (23035), (23731), (23807), (39158), (51338), +(762515711909167104), (1976517286462226432), (5793317970658721792), +(6453095316068499456), (7648519542158655488), (8601593813300936704); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 49.57 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 30 49.57 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= 0) +DROP TABLE t1; +# +# Bug#26570230 WL9223: ASSERTION `FILTER >= 0.0F && FILTER <= 1.0F' +# FAILED. +# +CREATE TABLE t1 (col1 VARCHAR(255)); +INSERT INTO t1 VALUES ("c"), ("f"), ("get"), ("going"), ("look"), ("MOZVN"), +("n"), ("NJAOC"), ("o"), ("on"), ("qnqzklkafp"), ("say"), ("sckaeiqnqz"), +("the"), ("there"), ("VXPRU"), ("w"), ("WBQDQ"), ("your"), ("ZHZXW"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 'b' AND 'z'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 99.95 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 99.95 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` between 'b' and 'z') +DROP TABLE t1; +# Test that histogram data is updated in a multi-connection setup +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 128 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +# This should give a very low estimate, since no rows matches this +# condition +EXPLAIN SELECT * FROM t1 WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` > 3) +DELETE FROM t1; +INSERT INTO t1 VALUES (4), (5), (6); +# This should give the same estimate as earlier, since we haven't updated +# the histogram statistics. +EXPLAIN SELECT * FROM t1 WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` > 3) +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 128 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +# Now we should see a very high estimate, since all rows matches this +# condition. +EXPLAIN SELECT * FROM t1 WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` > 3) +DROP TABLE t1; +# +# Bug#26621664 WL9223:ASSERTION `DISTANCE <= 1.0' FAILED. +# +SET @@SESSION.sql_mode=''; +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) NOT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date NOT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) +VIRTUAL, +col_datetime datetime NOT NULL, +col_time time NOT NULL, +col_datetime_key datetime GENERATED ALWAYS AS +(addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) +VIRTUAL, +col_varchar varchar(1) NOT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS +(concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pk, col_int, col_date, col_datetime, col_time, col_varchar) +VALUES (10,8,'2006-08-19','2001-07-04 +14:30:59','23:33:39','v'),(11,8,'2006-08-13','2006-12-15 +06:22:01','11:50:10','j'),(12,9,'2008-05-12','2002-06-19 +14:43:00','07:14:03','h'),(13,0,'2003-07-05','2005-08-19 +04:46:53','18:13:22','q'),(14,1,'2003-10-21','2007-05-14 +06:19:04','00:00:00','g'),(29,1,'2008-12-24','2004-04-02 +07:16:01','16:30:10','e'); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time_key WITH 1024 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_varchar_key WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_int WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_date_key WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime WITH 40 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime'. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) NOT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date NOT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) +VIRTUAL, +col_datetime datetime NOT NULL, +col_time time NOT NULL, +col_datetime_key datetime GENERATED ALWAYS AS +(addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) +VIRTUAL, +col_varchar varchar(1) NOT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS +(concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 (pk, col_int, col_date, col_datetime, col_time, col_varchar) +VALUES (1,2,'2002-10-13','1900-01-01 +00:00:00','00:00:00','s'),(2,4,'1900-01-01','2005-08-15 +00:00:00','15:57:25','r'),(3,8,'0000-00-00','1900-01-01 +00:00:00','07:05:51','m'),(4,4,'2006-03-09','2008-05-16 +08:09:06','19:22:21','b'),(5,4,'2001-06-05','2001-01-20 +12:47:23','03:53:16','x'),(6,7,'2006-05-28','2008-07-02 +00:00:00','09:16:38','g'),(7,4,'2001-04-19','1900-01-01 +00:00:00','15:37:26','p'),(8,1,'1900-01-01','2002-12-08 +11:34:58','00:00:00','q'),(9,9,'2004-08-20','1900-01-01 +00:00:00','05:03:03','w'),(10,4,'2004-10-10','1900-01-01 +00:00:00','02:59:24','d'),(11,8,'2000-04-02','2002-08-25 +20:35:06','00:01:58','e'),(12,4,'2006-11-02','2001-10-22 +11:13:24','00:00:00','b'),(13,8,'2009-01-28','2003-03-12 +02:00:34','02:20:16','y'),(14,0,'2005-04-19','2007-04-10 +12:16:04','04:59:50','p'),(15,0,'2006-08-12','2009-11-07 +00:00:00','21:14:04','f'),(16,0,'2005-03-12','2003-12-04 +11:14:26','00:00:00','p'),(17,7,'1900-01-01','2006-09-11 +18:25:21','12:59:27','d'),(18,7,'1900-01-01','1900-01-01 +00:00:00','16:39:36','f'),(19,5,'0000-00-00','2001-07-25 +08:40:24','00:00:00','j'),(20,3,'2007-09-09','2009-06-07 +13:48:58','00:00:00','e'); +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_int WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time_key WITH 1 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime_key WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_date_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_varchar WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_int_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time'. +SELECT STD( OUTR . pk ) AS x +FROM t2 AS OUTR2 LEFT JOIN t2 AS OUTR +ON ( OUTR2 . col_datetime_key >= OUTR . col_datetime_key ) +WHERE OUTR . col_int IN ( +SELECT DISTINCT INNR . col_int_key AS y +FROM t1 AS INNR2 LEFT JOIN t1 AS INNR +ON ( INNR2 . col_varchar_key > INNR . col_varchar_key ) +WHERE INNR . col_varchar_key IS NOT NULL +AND NOT OUTR . pk <> 7 ) +AND OUTR . col_varchar_key IS NULL +HAVING x <= 3 +ORDER BY OUTR . pk , OUTR . pk; +x +DROP TABLE t1, t2; +SET @@SESSION.sql_mode=DEFAULT; +# +# Bug#26634098 WL9223:ASSERTION `(*REF)->IS_TEMPORAL()' FAILED. +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date DEFAULT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) VIRTUAL, +col_datetime datetime DEFAULT NULL, +col_time time DEFAULT NULL, +col_datetime_key datetime GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS (concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) /*!80000 INVISIBLE */ +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pk, col_int, col_date, col_datetime, col_time, col_varchar) VALUES +(10,3,'2007-02-04','2006-02-10 18:41:38',NULL,'t'), +(11,48,'1900-01-01','2009-02-16 14:58:58',NULL,'d'), +(12,8,'2001-03-14','2007-08-14 00:00:00','23:28:51','h'), +(13,9,NULL,'1900-01-01 00:00:00',NULL,NULL), +(14,2,'2008-10-05',NULL,'20:31:20','f'), +(15,0,'2001-11-25','2008-12-03 06:59:23','21:39:14','l'), +(16,205,'2003-01-27','2008-10-04 00:00:00','02:10:00','g'), +(17,NULL,'2008-08-08','2009-07-07 07:00:21','02:03:54','v'), +(18,3,'2006-07-03','2001-04-15 00:00:00','22:37:33',NULL), +(19,3,'2002-11-21','2007-07-08 04:01:58','12:17:48','m'); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime_key WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_int WITH 1000 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_int'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time_key'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_datetime WITH 1023 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_time WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col_int_key WITH 80 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col_int_key'. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) DEFAULT NULL, +col_int_key int(11) GENERATED ALWAYS AS ((col_int + col_int)) VIRTUAL, +col_date date DEFAULT NULL, +col_date_key date GENERATED ALWAYS AS ((col_date + interval 30 day)) VIRTUAL, +col_datetime datetime DEFAULT NULL, +col_time time DEFAULT NULL, +col_datetime_key datetime GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_time_key time GENERATED ALWAYS AS (addtime(col_datetime,col_time)) VIRTUAL, +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS (concat(col_varchar,col_varchar)) VIRTUAL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 (pk, col_int, col_date, col_datetime, col_time, col_varchar) VALUES +(10,7,'2006-03-07','2008-03-04 06:14:13','13:08:22','b'), +(11,8,'2001-10-15','2001-03-17 00:00:00','12:54:48','m'), +(12,NULL,'1900-01-01','2009-02-21 11:35:50','00:00:00','i'), +(13,0,NULL,'1900-01-01 00:00:00','20:56:23','w'), +(14,1,'2009-04-05','1900-01-01 00:00:00','04:25:03','m'), +(15,NULL,'2001-03-19','2001-04-12 00:00:00','00:00:00','q'), +(16,9,'2009-12-08','2001-12-04 20:21:01','00:00:00','k'), +(17,9,'2005-02-09','2001-05-27 08:41:01','00:58:58','l'), +(18,1,'2004-05-25','2004-09-18 00:00:00','18:39:28','c'), +(19,1,'2005-01-17','2002-09-12 11:18:48','19:47:45','d'), +(20,3,'2003-08-28','1900-01-01 00:00:00','05:20:00','k'), +(21,7,'2006-10-11','2003-10-28 03:31:02','11:43:03','a'), +(22,4,'1900-01-01','2001-08-22 10:20:09','02:38:39','p'), +(23,NULL,'1900-01-01','2008-04-24 00:00:00','05:34:27','o'), +(24,4,'2005-08-18','2006-11-10 10:08:49','11:13:16','e'), +(25,1,'2007-03-12','2007-10-16 00:00:00','00:00:00','n'), +(26,6,'2000-11-18','2009-05-27 12:25:07','08:56:42','t'), +(27,5,'2001-03-03',NULL,'03:20:29','u'), +(28,4,'2003-09-11','2001-09-10 18:10:10',NULL,'f'), +(29,1,'2007-06-17','1900-01-01 00:00:00',NULL,'t'), +(30,5,'2008-09-11','2004-06-07 23:17:09','10:39:48','k'), +(31,NULL,'2008-05-03','2007-06-09 02:05:46','00:00:00','m'), +(32,4,'2009-09-07','2000-07-03 00:00:00','10:52:33','y'), +(33,4,'2005-12-15','2001-04-15 14:12:38','21:41:45','m'), +(34,203,'2005-05-10','2007-04-12 13:29:59',NULL,'x'), +(35,9,'2008-01-22','2002-03-24 01:35:46','08:33:38',NULL), +(36,7,'2005-10-23','2001-12-27 07:56:29','19:27:01','q'), +(37,NULL,'2005-11-01','2002-06-08 09:04:13','09:31:22','f'), +(38,NULL,NULL,'2002-02-05 12:54:23','17:16:58','t'), +(39,0,'2005-06-25','2009-09-19 00:00:00','16:44:24','x'), +(40,1,'2005-12-09','2006-12-18 02:43:37','05:22:56','s'), +(41,5,'2006-06-28','2002-10-18 00:00:00','13:32:21','i'), +(42,NULL,'2002-03-16','2004-08-03 22:46:02','15:59:32','l'), +(43,6,'2006-07-20','1900-01-01 00:00:00','07:19:58','t'), +(44,7,'1900-01-01','2006-11-15 05:00:37','12:50:41','b'), +(45,NULL,'2002-09-13','2005-01-21 07:18:44','04:38:11','h'), +(46,6,'2002-08-17','1900-01-01 00:00:00','20:25:46',NULL), +(47,9,NULL,'2002-09-22 01:36:27','00:00:00',NULL), +(48,5,'2007-12-08','2003-04-22 16:42:22','10:53:24',NULL), +(49,1,'2008-07-05','2000-10-18 08:28:55','06:16:28','x'); +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime_key WITH 100 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_varchar WITH 60 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_varchar'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_date_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_date_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_datetime WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_datetime'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_varchar_key WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_varchar_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_int_key WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_int_key'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_date WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_date'. +ANALYZE TABLE t2 UPDATE HISTOGRAM ON col_time_key WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t2 histogram status Histogram statistics created for column 'col_time_key'. +CREATE OR REPLACE VIEW view_AA AS SELECT * FROM t1; +CREATE OR REPLACE VIEW view_CC AS SELECT * FROM t2; +SELECT LEFT(col_varchar_key, 1) AS field1 FROM view_AA WHERE ( pk, NULL ) IN +( SELECT col_int AS subfield11, pk AS subfield12 FROM view_CC WHERE ( col_datetime, col_date_key, col_varchar_key ) IN +( SELECT col_time_key AS subfield21, pk AS subfield22, col_time_key AS subfield23 FROM t1 WHERE col_varchar != col_varchar_key ) +ORDER BY subfield12 ) OR col_int IS NOT NULL ORDER BY field1 LIMIT 10 OFFSET 25; +field1 +DROP VIEW view_AA, view_CC; +DROP TABLE t1, t2; +# +# Bug#26641404 WL9223:ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED. +# +CREATE TABLE t1 (col1 TIME, col2 DATE); +INSERT INTO t1 VALUES ("00:00:00", "2017-01-01"); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 8 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < ""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1292 Truncated incorrect time value: '' +Warning 1292 Truncated incorrect time value: '' +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` < '') +EXPLAIN SELECT * FROM t1 WHERE col2 < ""; +ERROR HY000: Incorrect DATE value: '' +DROP TABLE t1; +CREATE TABLE tbl_int (col1 INT); +INSERT INTO tbl_int VALUES (1), (2), (2), (2), (3), (6), (8), (8), (NULL), (NULL); +ANALYZE TABLE tbl_int; +Table Op Msg_type Msg_text +test.tbl_int analyze status OK +ANALYZE TABLE tbl_int UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_int histogram status Histogram statistics created for column 'col1'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test tbl_int col1 {"buckets": [[1, 2, 0.4, 2], [3, 8, 0.8, 3]], "data-type": "int", "null-values": 0.2, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 2} +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 > 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` > 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 >= 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` >= 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 46.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 46.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 53.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 53.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <= 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <= 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 46.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 46.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 53.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 53.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 < 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` < 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 <> 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` <> 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 0) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 1) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 2) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 46.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 46.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 3) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 53.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 53.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 4) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 5) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 66.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 6) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 73.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 73.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 7) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 8) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 0 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 0 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 1 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 1 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 2 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 2 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 3 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 3 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 4 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 4 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 5 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 5 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 6 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 6 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 7 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 7 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 8 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 8 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 BETWEEN 9 AND 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` between 9 and 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (0,1,2,3,4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (0,1,2,3,4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (2,3,4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (2,3,4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (3,4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (3,4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (4,5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (4,5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (5,6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 26.67 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 26.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (5,6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (6,7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (6,7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (7,8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 13.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 13.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (7,8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (8,9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (8,9)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` = 9) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (1,3,5,7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (1,3,5,7)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (2,4,6,8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (2,4,6,8)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (2,5,6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (2,5,6)) +EXPLAIN SELECT * FROM tbl_int WHERE col1 IN (9,10,11,12,13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_int NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_int`.`col1` AS `col1` from `test`.`tbl_int` where (`test`.`tbl_int`.`col1` in (9,10,11,12,13)) +DROP TABLE tbl_int; +CREATE TABLE tbl_float (col double); +INSERT INTO tbl_float VALUES (0.1), (0.2), (0.3), (0.3), (0.4), (0.5), (0.5), +(0.8), (NULL), (NULL); +ANALYZE TABLE tbl_float; +Table Op Msg_type Msg_text +test.tbl_float analyze status OK +ANALYZE TABLE tbl_float UPDATE HISTOGRAM ON col WITH 4 BUCKETS; +Table Op Msg_type Msg_text +test.tbl_float histogram status Histogram statistics created for column 'col'. +SELECT schema_name, table_name, column_name, +JSON_REMOVE(histogram, '$."last-updated"') +FROM information_schema.COLUMN_STATISTICS; +SCHEMA_NAME TABLE_NAME COLUMN_NAME JSON_REMOVE(histogram, '$."last-updated"') +test tbl_float col {"buckets": [[0.1, 0.2, 0.2, 2], [0.3, 0.3, 0.4, 1], [0.4, 0.5, 0.7, 2], [0.8, 0.8, 0.8, 1]], "data-type": "double", "null-values": 0.2, "collation-id": 8, "sampling-rate": 1.0, "histogram-type": "equi-height", "number-of-buckets-specified": 4} +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col > 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` > 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col >= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` >= 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col = 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col <= 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <= 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col < 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` < 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col <> 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` <> 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.0) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.1) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.2) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.3) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.4) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.5) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.6) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 70.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.7) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.8) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.0 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.0 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.1 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 80.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 80.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.1 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.2 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.2 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.3 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 60.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.3 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.4 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 40.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.4 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.5 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.5 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.6 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.6 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.7 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.7 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.8 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.8 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col BETWEEN 0.9 AND 0.9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` between 0.9 and 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.3,0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 30.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.3,0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.4,0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.4,0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.5,0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.5,0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.6,0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.6,0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.7,0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.7,0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.8,0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.8,0.9)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` = 0.9) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.1,0.3,0.5,0.7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 20.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.1,0.3,0.5,0.7)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.2,0.4,0.6,0.8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.2,0.4,0.6,0.8)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.2,0.5,0.6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.2,0.5,0.6)) +EXPLAIN SELECT * FROM tbl_float WHERE col IN (0.9,1.0,1.1,1.2,1.3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE tbl_float NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_float`.`col` AS `col` from `test`.`tbl_float` where (`test`.`tbl_float`.`col` in (0.9,1.0,1.1,1.2,1.3)) +DROP TABLE tbl_float; +CREATE TABLE t1 (col1 BIGINT, col2 BIGINT UNSIGNED, col3 DOUBLE); +INSERT INTO t1 VALUES +(-9223372036854775808, 0, -1.7976931348623157E+308), +(9223372036854775806, 18446744073709551614, 1.7976931348623155e+308), +(9223372036854775807, 18446744073709551615, 1.7976931348623157e+308); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2, col3 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +test.t1 histogram status Histogram statistics created for column 'col3'. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE col1 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2`,`test`.`t1`.`col3` AS `col3` from `test`.`t1` where (`test`.`t1`.`col1` < 100) +EXPLAIN SELECT * FROM t1 WHERE col2 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2`,`test`.`t1`.`col3` AS `col3` from `test`.`t1` where (`test`.`t1`.`col2` < 100) +EXPLAIN SELECT * FROM t1 WHERE col3 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2`,`test`.`t1`.`col3` AS `col3` from `test`.`t1` where (`test`.`t1`.`col3` < 100) +DROP TABLE t1; +# +# Bug#27197709 TABLE ROWS ESTIMATE DURING HISTOGRAM CREATION MAY BE WAY +# OFF +# +CREATE TABLE t1 (col1 VARCHAR(255)); +# Insert 10000 rows into the table t1 with random string data +SET cte_max_recursion_depth = 10000; +INSERT INTO t1 (col1) +WITH RECURSIVE cte (n, val) AS +( +SELECT 1, CONCAT(MD5(RAND()), MD5(RAND())) +UNION ALL +SELECT n + 1, CONCAT(MD5(RAND()), MD5(RAND())) FROM cte WHERE n < 10000 +) +SELECT val FROM cte; +# Set the amount of available memory as low as possible, so we are sure +# that sampling will be used. +SET histogram_generation_max_mem_size = 1000000; +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT +histogram->>'$."sampling-rate"' < 1.0 AS should_be_true +FROM +INFORMATION_SCHEMA.COLUMN_STATISTICS; +should_be_true +1 +SET cte_max_recursion_depth = DEFAULT; +SET histogram_generation_max_mem_size = DEFAULT; +DROP TABLE t1; +# +# Bug#27637968 PROVIDE A DEFAULT NUMBER OF BUCKETS FOR HISTOGRAM +# STATISTICS +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (10), (20), (30); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +SELECT JSON_EXTRACT(histogram, '$."number-of-buckets-specified"') +FROM INFORMATION_SCHEMA.column_statistics +WHERE table_name = "t1" AND column_name = "col1"; +JSON_EXTRACT(histogram, '$."number-of-buckets-specified"') +100 +DROP TABLE t1; +# +# Bug#27574375 ANALYZA TABLE DOESN'T RETURN ERROR IN CASE +# LOCK_WAIT_TIMEOUT HAPPENED +# +CREATE TABLE t1 (a INT); +SET lock_wait_timeout= 1; +LOCK INSTANCE FOR BACKUP; +# The error ER_LOCK_WAIT_TIMEOUT is expected here, and when using ANALYZE +# TABLE errors are printed out in the result set from the query. +ANALYZE TABLE t1 UPDATE HISTOGRAM ON a WITH 5 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram Error Lock wait timeout exceeded; try restarting transaction +UNLOCK INSTANCE; +DROP TABLE t1; +# restart: diff --git a/mysql-test/r/index_merge_innodb.result-pq b/mysql-test/r/index_merge_innodb.result-pq new file mode 100644 index 000000000..8a1cbda24 --- /dev/null +++ b/mysql-test/r/index_merge_innodb.result-pq @@ -0,0 +1,2116 @@ +#---------------- Index merge test 1 ------------------------------------------- +# (Start of test file: index_merge1.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t0, t1, t2, t3, t4; +# Create and fill a table with simple keys +create table t0 +( +key1 int not null, +key2 int not null, +key3 int not null, +key4 int not null, +key5 int not null, +key6 int not null, +key7 int not null, +key8 int not null, +INDEX i1(key1), +INDEX i2(key2), +INDEX i3(key3), +INDEX i4(key4), +INDEX i5(key5), +INDEX i6(key6), +INDEX i7(key7), +INDEX i8(key8) +); +analyze table t0; +Table Op Msg_type Msg_text +test.t0 analyze status OK +# 1. One index +explain select * from t0 where key1 < 3 or key1 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (2 workers) +2 SIMPLE t0 NULL range i1 i1 4 NULL 6 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key1` > 1020)) +# 2. Simple cases +explain +select * from t0 where key1 < 3 or key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 6 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` > 1020)) +select * from t0 where key1 < 3 or key2 > 1020; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +1021 1021 1021 1021 1021 1021 1021 3 +1022 1022 1022 1022 1022 1022 1022 2 +1023 1023 1023 1023 1023 1023 1023 1 +1024 1024 1024 1024 1024 1024 1024 0 +explain select * from t0 where key1 < 2 or key2 <3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 3)) +explain +select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` > 30) and (`test`.`t0`.`key1` < 35)) or ((`test`.`t0`.`key2` > 32) and (`test`.`t0`.`key2` < 40))) +# Bug#21277: InnoDB, wrong result set, index_merge strategy, +# second index not evaluated +select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40); +key1 key2 key3 key4 key5 key6 key7 key8 +31 31 31 31 31 31 31 993 +32 32 32 32 32 32 32 992 +33 33 33 33 33 33 33 991 +34 34 34 34 34 34 34 990 +35 35 35 35 35 35 35 989 +36 36 36 36 36 36 36 988 +37 37 37 37 37 37 37 987 +38 38 38 38 38 38 38 986 +39 39 39 39 39 39 39 985 +# 3. Check that index_merge doesn't break "ignore/force/use index" +explain select * from t0 ignore index (i2) where key1 < 3 or key2 <4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1 NULL NULL NULL # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` IGNORE INDEX (`i2`) where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4)) +explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i1,i2,i3 i3 4 const # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key3` = 50) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4))) +explain select * from t0 use index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 1.67 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` USE INDEX (`i2`) USE INDEX (`i1`) where ((`test`.`t0`.`key3` = 50) and ((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 3))) +explain select * from t0 where (key1 > 1 or key2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2 NULL NULL NULL # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` > 1) or (`test`.`t0`.`key2` > 2)) +explain select * from t0 force index (i1,i2) where (key1 > 1 or key2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((`test`.`t0`.`key1` > 1) or (`test`.`t0`.`key2` > 2)) +# 4. Check if conjuncts are grouped by keyuse +explain +select * from t0 where key1<2 or key2<3 or (key1>5 and key1<7) or +(key1>10 and key1<12) or (key2>100 and key2<102); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 3) or ((`test`.`t0`.`key1` > 5) and (`test`.`t0`.`key1` < 7)) or ((`test`.`t0`.`key1` > 10) and (`test`.`t0`.`key1` < 12)) or ((`test`.`t0`.`key2` > 100) and (`test`.`t0`.`key2` < 102))) +# 5. Check index_merge with conjuncts that are always true/false +# verify fallback to "range" if there is only one non-confluent condition +explain select * from t0 where key2 = 45 or key1 <=> null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL range i1,i2 i2 4 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key2` = 45) or (`test`.`t0`.`key1` <=> NULL)) +explain select * from t0 where key2 = 45 or key1 is not null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where true +explain select * from t0 where key2 = 45 or key1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i2 i2 4 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (`test`.`t0`.`key2` = 45) +# the last conj. is always false and will be discarded +explain select * from t0 where key2=10 or key3=3 or key4 <=> null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i2,i3,i4 i2,i3 4,4 NULL # 100.00 Using union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key2` = 10) or (`test`.`t0`.`key3` = 3) or (`test`.`t0`.`key4` <=> NULL)) +# the last conj. is always true and will cause 'all' scan +explain select * from t0 where key2=10 or key3=3 or key4 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i2,i3 i2,i3 4,4 NULL # 100.00 Using union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key2` = 10) or (`test`.`t0`.`key3` = 3)) +# some more complicated cases +explain select key1 from t0 where (key1 <=> null) or (key2 < 2) or +(key3=10) or (key4 <=> null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i4 i2,i3 4,4 NULL # 100.00 Using sort_union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1` from `test`.`t0` where ((`test`.`t0`.`key1` <=> NULL) or (`test`.`t0`.`key2` < 2) or (`test`.`t0`.`key3` = 10) or (`test`.`t0`.`key4` <=> NULL)) +explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or +(key3=10) or (key4 <=> null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i3,i4 i1,i3 4,4 NULL # 100.00 Using sort_union(i1,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1` from `test`.`t0` where ((`test`.`t0`.`key1` <=> NULL) or (`test`.`t0`.`key1` < 5) or (`test`.`t0`.`key3` = 10) or (`test`.`t0`.`key4` <=> NULL)) +# 6.Several ways to do index_merge, (ignored) index_merge vs. range +explain select * from t0 where +(key1 < 2 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 5 or key6 < 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL # 30.86 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 2)) and ((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key4` < 3)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 5))) +explain +select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 4)) and ((`test`.`t0`.`key1` < 5) or (`test`.`t0`.`key3` < 3))) +select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3); +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +3 3 3 3 3 3 3 1021 +explain select * from t0 where +(key1 < 3 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 2 or key6 < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i4,i5,i6 i5,i6 4,4 NULL # 30.86 Using sort_union(i5,i6); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 2)) and ((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key4` < 3)) and ((`test`.`t0`.`key5` < 2) or (`test`.`t0`.`key6` < 2))) +explain select * from t0 where +(key1 < 3 or key2 < 3) and (key3 < 70); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 6.74 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3)) and (`test`.`t0`.`key3` < 70)) +explain select * from t0 where +(key1 < 3 or key2 < 3) and (key3 < 1000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 97.56 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where (((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3)) and (`test`.`t0`.`key3` < 1000)) +# 7. Complex cases +# tree_or(List, range SEL_TREE). +explain select * from t0 where +((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3)) +or +key2 > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 53.90 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2,i3 NULL NULL NULL # 53.90 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3)) and ((`test`.`t0`.`key2` < 4) or (`test`.`t0`.`key3` < 3))) or (`test`.`t0`.`key2` > 4)) +explain select * from t0 where +((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3)) +or +key1 < 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key1` < 4) or (`test`.`t0`.`key2` < 4)) and ((`test`.`t0`.`key2` < 4) or (`test`.`t0`.`key3` < 3))) or (`test`.`t0`.`key1` < 5)) +select * from t0 where +((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3)) +or +key1 < 5; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +3 3 3 3 3 3 3 1021 +4 4 4 4 4 4 4 1020 +# tree_or(List, List). +explain select * from t0 where +((key1 < 2 or key2 < 2) and (key3 <4 or key5 < 3)) +or +((key5 < 3 or key6 < 3) and (key7 <3 or key8 < 3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6,i7,i8 i1,i2,i5,i6 4,4,4,4 NULL # 100.00 Using sort_union(i1,i2,i5,i6); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key1` < 2) or (`test`.`t0`.`key2` < 2)) and ((`test`.`t0`.`key3` < 4) or (`test`.`t0`.`key5` < 3))) or (((`test`.`t0`.`key5` < 3) or (`test`.`t0`.`key6` < 3)) and ((`test`.`t0`.`key7` < 3) or (`test`.`t0`.`key8` < 3)))) +explain select * from t0 where +((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3)) +or +((key7 <5 or key8 < 3) and (key5 < 4 or key6 < 4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL # 100.00 Using sort_union(i3,i5,i7,i8); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3))) or (((`test`.`t0`.`key7` < 5) or (`test`.`t0`.`key8` < 3)) and ((`test`.`t0`.`key5` < 4) or (`test`.`t0`.`key6` < 4)))) +explain select * from t0 where +((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 4)) +or +((key3 <4 or key5 < 2) and (key5 < 5 or key6 < 3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL # 100.00 Using sort_union(i3,i5); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4))) or (((`test`.`t0`.`key3` < 4) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 3)))) +explain select * from t0 where +((key3 <4 or key5 < 3) and (key1 < 3 or key2 < 3)) +or +(((key3 <5 and key7 < 5) or key5 < 2) and (key5 < 4 or key6 < 4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL # 100.00 Using sort_union(i3,i5); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 4) or (`test`.`t0`.`key5` < 3)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3))) or ((((`test`.`t0`.`key3` < 5) and (`test`.`t0`.`key7` < 5)) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 4) or (`test`.`t0`.`key6` < 4)))) +explain select * from t0 where +((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) +or +((key3 >5 or key5 < 2) and (key5 < 5 or key6 < 6)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 52.20 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2,i3,i5,i6 NULL NULL NULL # 52.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((((`test`.`t0`.`key3` < 5) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 4) or (`test`.`t0`.`key2` < 4))) or (((`test`.`t0`.`key3` > 5) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 6)))) +explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where +((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3)) +or +((key3 >4 or key5 < 2) and (key5 < 5 or key6 < 4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL # 100.00 Using sort_union(i3,i5); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` FORCE INDEX (`i6`) FORCE INDEX (`i5`) FORCE INDEX (`i4`) FORCE INDEX (`i3`) FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((((`test`.`t0`.`key3` < 3) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 3))) or (((`test`.`t0`.`key3` > 4) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 4)))) +# Can't merge any indexes here (predicate on key3 is always true) +explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where +((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) +or +((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 52.20 Parallel execute (4 workers) +2 SIMPLE t0 NULL ALL i1,i2,i3,i5,i6 NULL NULL NULL # 52.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` FORCE INDEX (`i6`) FORCE INDEX (`i5`) FORCE INDEX (`i4`) FORCE INDEX (`i3`) FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((((`test`.`t0`.`key3` < 5) or (`test`.`t0`.`key5` < 4)) and ((`test`.`t0`.`key1` < 4) or (`test`.`t0`.`key2` < 4))) or (((`test`.`t0`.`key3` >= 5) or (`test`.`t0`.`key5` < 2)) and ((`test`.`t0`.`key5` < 5) or (`test`.`t0`.`key6` < 6)))) +# 8. Verify that "order by" after index merge uses filesort +select * from t0 where key1 < 3 or key8 < 2 order by key1; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +1023 1023 1023 1023 1023 1023 1023 1 +1024 1024 1024 1024 1024 1024 1024 0 +explain +select * from t0 where key1 < 3 or key8 < 2 order by key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i8 i1,i8 4,4 NULL # 100.00 Using sort_union(i1,i8); Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key8` < 2)) order by `test`.`t0`.`key1` +# 9. Check that index_merge cost is compared to 'index' where possible +create table t2 like t0; +insert into t2 select * from t0; +alter table t2 add index i1_3(key1, key3); +alter table t2 add index i2_3(key2, key3); +alter table t2 drop index i1; +alter table t2 drop index i2; +alter table t2 add index i321(key3, key2, key1); +# index_merge vs 'index', index_merge is better. +explain select key3 from t2 where key1 = 100 or key2 = 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL # 100.00 Using sort_union(i1_3,i2_3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1` = 100) or (`test`.`t2`.`key2` = 100)) +# index_merge vs 'index', 'index' is better. +explain select key3 from t2 where key1 <100 or key2 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (2 workers) +2 SIMPLE t2 NULL index i1_3,i2_3 i321 12 NULL # 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1` < 100) or (`test`.`t2`.`key2` < 100)) +# index_merge vs 'all', index_merge is better. +explain select key7 from t2 where key1 <100 or key2 < 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 55.55 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL i1_3,i2_3 NULL NULL NULL # 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key7` AS `key7` from `test`.`t2` where ((`test`.`t2`.`key1` < 100) or (`test`.`t2`.`key2` < 100)) +# 10. Multipart keys. +create table t4 ( +key1a int not null, +key1b int not null, +key2 int not null, +key2_1 int not null, +key2_2 int not null, +key3 int not null, +index i1a (key1a, key1b), +index i1b (key1b, key1a), +index i2_1(key2, key2_1), +index i2_2(key2, key2_1) +); +Warnings: +Warning 1831 Duplicate index 'i2_2' defined on the table 'test.t4'. This is deprecated and will be disallowed in a future release. +insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0; +# the following will be handled by index_merge: +select * from t4 where key1a = 3 or key1b = 4; +key1a key1b key2 key2_1 key2_2 key3 +3 3 0 3 3 3 +4 4 0 4 4 4 +explain select * from t4 where key1a = 3 or key1b = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index_merge i1a,i1b i1a,i1b 4,4 NULL 2 100.00 Using sort_union(i1a,i1b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key1a` = 3) or (`test`.`t4`.`key1b` = 4)) +# and the following will not +explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 19.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ref i2_1,i2_2 i2_1 4 const 10 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key2` = 1) and ((`test`.`t4`.`key2_1` = 1) or (`test`.`t4`.`key3` = 5))) +explain select * from t4 where key2 = 1 and (key2_1 = 1 or key2_2 = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 19.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ref i2_1,i2_2 i2_1 4 const 10 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key2` = 1) and ((`test`.`t4`.`key2_1` = 1) or (`test`.`t4`.`key2_2` = 5))) +explain select * from t4 where key2_1 = 1 or key2_2 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 19.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL # 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`key1a` AS `key1a`,`test`.`t4`.`key1b` AS `key1b`,`test`.`t4`.`key2` AS `key2`,`test`.`t4`.`key2_1` AS `key2_1`,`test`.`t4`.`key2_2` AS `key2_2`,`test`.`t4`.`key3` AS `key3` from `test`.`t4` where ((`test`.`t4`.`key2_1` = 1) or (`test`.`t4`.`key2_2` = 5)) +# 11. Multitable selects +create table t1 like t0; +insert into t1 select * from t0; +# index_merge on first table in join +explain select * from t0 left join t1 on (t0.key1=t1.key1) +where t0.key1=3 or t0.key2=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 2 100.00 Using union(i1,i2); Using where +1 SIMPLE t1 NULL ref i1 i1 4 test.t0.key1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` left join `test`.`t1` on((`test`.`t1`.`key1` = `test`.`t0`.`key1`)) where ((`test`.`t0`.`key1` = 3) or (`test`.`t0`.`key2` = 4)) +select * from t0 left join t1 on (t0.key1=t1.key1) +where t0.key1=3 or t0.key2=4; +key1 key2 key3 key4 key5 key6 key7 key8 key1 key2 key3 key4 key5 key6 key7 key8 +3 3 3 3 3 3 3 1021 3 3 3 3 3 3 3 1021 +4 4 4 4 4 4 4 1020 4 4 4 4 4 4 4 1020 +explain +select * from t0,t1 where (t0.key1=t1.key1) and ( t0.key1=3 or t0.key2=4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 2 100.00 Using union(i1,i2); Using where +1 SIMPLE t1 NULL ref i1 i1 4 test.t0.key1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t1`.`key1` = `test`.`t0`.`key1`) and ((`test`.`t0`.`key1` = 3) or (`test`.`t0`.`key2` = 4))) +# index_merge vs. ref +# index_merge vs. ref +explain +select * from t0,t1 where (t0.key1=t1.key1) and +(t0.key1=3 or t0.key2<4) and t1.key1=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i1,i2 i1 4 const 1 5.00 Using where +2 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t0`.`key1` = 2) and (`test`.`t1`.`key1` = 2) and (`test`.`t0`.`key2` < 4)) +# index_merge on second table in join +explain select * from t0,t1 where t0.key1 = 5 and +(t1.key1 = t0.key1 or t1.key8 = t0.key1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL ref i1 i1 4 const 1 100.00 NULL +2 SIMPLE t1 NULL index_merge i1,i8 i1,i8 4,4 NULL 2 100.00 Using union(i1,i8); Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t0`.`key1` = 5) and ((`test`.`t1`.`key1` = 5) or (`test`.`t1`.`key8` = 5))) +# Fix for bug#1974 +explain select * from t0,t1 where t0.key1 < 3 and +(t1.key1 = t0.key1 or t1.key8 = t0.key1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL range i1 i1 4 NULL # 100.00 Using index condition +2 SIMPLE t1 NULL ALL i1,i8 NULL NULL NULL # 0.20 Range checked for each record (index map: 0x81) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t0` join `test`.`t1` where ((`test`.`t0`.`key1` < 3) and ((`test`.`t1`.`key1` = `test`.`t0`.`key1`) or (`test`.`t1`.`key8` = `test`.`t0`.`key1`))) +# index_merge inside union +explain select * from t1 where key1=3 or key2=4 +union select * from t1 where key1<4 or key3=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 2 100.00 Using union(i1,i2); Using where +2 UNION t1 NULL index_merge i1,i3 i1,i3 4,4 NULL 4 100.00 Using sort_union(i1,i3); Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` = 3) or (`test`.`t1`.`key2` = 4)) union /* select#2 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` < 4) or (`test`.`t1`.`key3` = 5)) +# index merge in subselect +explain select * from (select * from t1 where key1 = 3 or key2 =3) as z where key8 >5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2,i8 i1,i2 4,4 NULL 2 99.41 Using union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key8` > 5) and ((`test`.`t1`.`key1` = 3) or (`test`.`t1`.`key2` = 3))) +# 12. check for long index_merges. +create table t3 like t0; +insert into t3 select * from t0; +alter table t3 add key9 int not null, add index i9(key9); +alter table t3 add keyA int not null, add index iA(keyA); +alter table t3 add keyB int not null, add index iB(keyB); +alter table t3 add keyC int not null, add index iC(keyC); +update t3 set key9=key1,keyA=key1,keyB=key1,keyC=key1; +explain select * from t3 where +key1=1 or key2=2 or key3=3 or key4=4 or +key5=5 or key6=6 or key7=7 or key8=8 or +key9=9 or keyA=10 or keyB=11 or keyC=12; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index_merge i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC 4,4,4,4,4,4,4,4,4,4,4,4 NULL 12 100.00 Using union(i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`key1` AS `key1`,`test`.`t3`.`key2` AS `key2`,`test`.`t3`.`key3` AS `key3`,`test`.`t3`.`key4` AS `key4`,`test`.`t3`.`key5` AS `key5`,`test`.`t3`.`key6` AS `key6`,`test`.`t3`.`key7` AS `key7`,`test`.`t3`.`key8` AS `key8`,`test`.`t3`.`key9` AS `key9`,`test`.`t3`.`keyA` AS `keyA`,`test`.`t3`.`keyB` AS `keyB`,`test`.`t3`.`keyC` AS `keyC` from `test`.`t3` where ((`test`.`t3`.`key1` = 1) or (`test`.`t3`.`key2` = 2) or (`test`.`t3`.`key3` = 3) or (`test`.`t3`.`key4` = 4) or (`test`.`t3`.`key5` = 5) or (`test`.`t3`.`key6` = 6) or (`test`.`t3`.`key7` = 7) or (`test`.`t3`.`key8` = 8) or (`test`.`t3`.`key9` = 9) or (`test`.`t3`.`keyA` = 10) or (`test`.`t3`.`keyB` = 11) or (`test`.`t3`.`keyC` = 12)) +select * from t3 where +key1=1 or key2=2 or key3=3 or key4=4 or +key5=5 or key6=6 or key7=7 or key8=8 or +key9=9 or keyA=10 or keyB=11 or keyC=12; +key1 key2 key3 key4 key5 key6 key7 key8 key9 keyA keyB keyC +1 1 1 1 1 1 1 1023 1 1 1 1 +2 2 2 2 2 2 2 1022 2 2 2 2 +3 3 3 3 3 3 3 1021 3 3 3 3 +4 4 4 4 4 4 4 1020 4 4 4 4 +5 5 5 5 5 5 5 1019 5 5 5 5 +6 6 6 6 6 6 6 1018 6 6 6 6 +7 7 7 7 7 7 7 1017 7 7 7 7 +9 9 9 9 9 9 9 1015 9 9 9 9 +10 10 10 10 10 10 10 1014 10 10 10 10 +11 11 11 11 11 11 11 1013 11 11 11 11 +12 12 12 12 12 12 12 1012 12 12 12 12 +1016 1016 1016 1016 1016 1016 1016 8 1016 1016 1016 1016 +# Test for Bug#3183 +explain select * from t0 where key1 < 3 or key2 < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL index_merge i1,i2 i1,i2 4,4 NULL 5 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`key1` AS `key1`,`test`.`t0`.`key2` AS `key2`,`test`.`t0`.`key3` AS `key3`,`test`.`t0`.`key4` AS `key4`,`test`.`t0`.`key5` AS `key5`,`test`.`t0`.`key6` AS `key6`,`test`.`t0`.`key7` AS `key7`,`test`.`t0`.`key8` AS `key8` from `test`.`t0` where ((`test`.`t0`.`key1` < 3) or (`test`.`t0`.`key2` < 4)) +# Bug#21277: InnoDB, wrong result set, index_merge strategy, +# second index not evaluated +select * from t0 where key1 < 3 or key2 < 4; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 1023 +2 2 2 2 2 2 2 1022 +3 3 3 3 3 3 3 1021 +update t0 set key8=123 where key1 < 3 or key2 < 4; +# Bug#21277: InnoDB, wrong result set, index_merge strategy, +# second index not evaluated +select * from t0 where key1 < 3 or key2 < 4; +key1 key2 key3 key4 key5 key6 key7 key8 +1 1 1 1 1 1 1 123 +2 2 2 2 2 2 2 123 +3 3 3 3 3 3 3 123 +delete from t0 where key1 < 3 or key2 < 4; +select * from t0 where key1 < 3 or key2 < 4; +key1 key2 key3 key4 key5 key6 key7 key8 +select count(*) from t0; +count(*) +1021 +# Test for BUG#4177 +drop table t4; +create table t4 (a int); +insert into t4 values (1),(4),(3); +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size= 4096; +explain select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 < 500000 or a.key2 < 3) +and (b.key1 < 500000 or b.key2 < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where +1 SIMPLE b NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max((((((((((`test`.`a`.`key1` + `test`.`b`.`key1`) + `test`.`a`.`key2`) + `test`.`b`.`key2`) + `test`.`a`.`key3`) + `test`.`b`.`key3`) + `test`.`a`.`key4`) + `test`.`b`.`key4`) + `test`.`a`.`key5`) + `test`.`b`.`key5`)) AS `max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5)` from `test`.`t0` `a` FORCE INDEX (`i2`) FORCE INDEX (`i1`) join `test`.`t0` `b` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where (((`test`.`a`.`key1` < 500000) or (`test`.`a`.`key2` < 3)) and ((`test`.`b`.`key1` < 500000) or (`test`.`b`.`key2` < 3))) +select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 < 500000 or a.key2 < 3) +and (b.key1 < 500000 or b.key2 < 3); +max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +10240 +update t0 set key1=1; +explain select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 = 1 or a.key2 = 1) +and (b.key1 = 1 or b.key2 = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index_merge i1,i2 i1,i2 4,4 NULL # # Using union(i1,i2); Using where +1 SIMPLE b NULL index_merge i1,i2 i1,i2 4,4 NULL # # Using union(i1,i2); Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max((((((((((`test`.`a`.`key1` + `test`.`b`.`key1`) + `test`.`a`.`key2`) + `test`.`b`.`key2`) + `test`.`a`.`key3`) + `test`.`b`.`key3`) + `test`.`a`.`key4`) + `test`.`b`.`key4`) + `test`.`a`.`key5`) + `test`.`b`.`key5`)) AS `max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5)` from `test`.`t0` `a` FORCE INDEX (`i2`) FORCE INDEX (`i1`) join `test`.`t0` `b` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where (((`test`.`a`.`key1` = 1) or (`test`.`a`.`key2` = 1)) and ((`test`.`b`.`key1` = 1) or (`test`.`b`.`key2` = 1))) +select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a force index(i1,i2), t0 as b force index (i1,i2) +where (a.key1 = 1 or a.key2 = 1) +and (b.key1 = 1 or b.key2 = 1); +max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +8194 +alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200); +update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500; +# The next query will not use index i7 in intersection if the OS doesn't +# support file sizes > 2GB. (ha_myisam::ref_length depends on this and index +# scan cost estimates depend on ha_myisam::ref_length) +select max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +from t0 as a, t0 as b +where (a.key1 = 1 and a.key2 = 1 and a.key3 = 1 and a.key4=1 and a.key5=1 and a.key6=1 and a.key7 = 1 or a.key8=1) +and (b.key1 = 1 and b.key2 = 1 and b.key3 = 1 and b.key4=1 and b.key5=1 and b.key6=1 and b.key7 = 1 or b.key8=1); +max(a.key1 + b.key1 + a.key2 + b.key2 + a.key3 + b.key3 + a.key4 + b.key4 + a.key5 + b.key5) +8186 +set join_buffer_size= @save_join_buffer_size; +# Test for BUG#4177 ends +drop table t0, t1, t2, t3, t4; +# BUG#16166 +CREATE TABLE t1 ( +cola char(3) not null, colb char(3) not null, filler char(200), +key(cola), key(colb) +); +INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ'); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +select count(*) from t1; +count(*) +8704 +explain select * from t1 WHERE cola = 'foo' AND colb = 'bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge cola,colb cola,colb 12,12 NULL # # Using intersect(cola,colb); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`colb` = 'bar') and (`test`.`t1`.`cola` = 'foo')) +explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge cola,colb cola,colb 12,12 NULL # # Using intersect(cola,colb); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` FORCE INDEX (`colb`) FORCE INDEX (`cola`) where ((`test`.`t1`.`colb` = 'bar') and (`test`.`t1`.`cola` = 'foo')) +drop table t1; +# +# BUG#20256 - LOCK WRITE - MyISAM +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)); +INSERT INTO t2(a,b) VALUES +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(1,2); +LOCK TABLES t1 WRITE, t2 WRITE; +INSERT INTO t2(a,b) VALUES(1,2); +SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1; +a +1 +1 +UNLOCK TABLES; +DROP TABLE t1, t2; +# +# BUG#29740: HA_KEY_SCAN_NOT_ROR wasn't set for HEAP engine +# +CREATE TABLE `t1` ( +`a` int(11) DEFAULT NULL, +`filler` char(200) DEFAULT NULL, +`b` int(11) DEFAULT NULL, +KEY `a` (`a`), +KEY `b` (`b`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values +(0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3), +(4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7), +(8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1), +(2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5), +(6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9), +(10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13), +(14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17), +(18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0), +(4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4); +create table t2( +`a` int(11) DEFAULT NULL, +`filler` char(200) DEFAULT NULL, +`b` int(11) DEFAULT NULL, +KEY USING BTREE (`a`), +KEY USING BTREE (`b`) +) ENGINE=MEMORY DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select * from t1; +must use sort-union rather than union: +explain select * from t1 where a=4 or b=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge a,b a,b 5,5 NULL # 100.00 Using sort_union(a,b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 4) or (`test`.`t1`.`b` = 4)) +select * from t1 where a=4 or b=4; +a filler b +4 4 0 +4 5 0 +4 filler 4 +4 filler 4 +4 qq 5 +4 zz 4 +5 qq 4 +select * from t1 ignore index(a,b) where a=4 or b=4; +a filler b +4 4 0 +4 5 0 +4 filler 4 +4 filler 4 +4 qq 5 +4 zz 4 +5 qq 4 +must use union, not sort-union: +explain select * from t2 where a=4 or b=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index_merge a,b a,b 5,5 NULL # 100.00 Using union(a,b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`a` = 4) or (`test`.`t2`.`b` = 4)) +select * from t2 where a=4 or b=4; +a filler b +4 4 0 +4 5 0 +4 filler 4 +4 filler 4 +4 qq 5 +4 zz 4 +5 qq 4 +drop table t1, t2; +# +# Bug #37943: Reproducible mysqld crash/sigsegv in sel_trees_can_be_ored +# +CREATE TABLE t1 (a varchar(8), b set('a','b','c','d','e','f','g','h'), +KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES ('y',''), ('z',''); +SELECT b,a from t1 WHERE (b!='c' AND b!='f' && b!='h') OR +(a='pure-S') OR (a='DE80337a') OR (a='DE80799'); +b a + y + z +Warnings: +Warning 1287 '&&' is deprecated and will be removed in a future release. Please use AND instead +DROP TABLE t1; +# +# BUG#40974: Incorrect query results when using clause +# evaluated using range check +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int); +insert into t1 values (1),(2); +create table t2(a int, b int); +insert into t2 values (1,1), (2, 1000); +create table t3 (a int, b int, filler char(100), key(a), key(b)); +insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C; +insert into t3 values (1,1,'data'); +insert into t3 values (1,1,'data'); +The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3) +explain select * from t1 +where exists (select 1 from t2, t3 +where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t3 NULL ALL a,b NULL NULL NULL # # Range checked for each record (index map: 0x3); FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t3`.`a` = `test`.`t2`.`b`) or (`test`.`t3`.`b` = `test`.`t2`.`b`) or (`test`.`t3`.`b` = (`test`.`t2`.`b` + 1)))) +select * from t1 +where exists (select 1 from t2, t3 +where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); +a +1 +2 +drop table t0, t1, t2, t3; +# +# BUG#44810: index merge and order by with low sort_buffer_size +# crashes server! +# +CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B)) charset latin1; +INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128)); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET SESSION sort_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect sort_buffer_size value: '1' +EXPLAIN +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' +ORDER BY a,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge a,b a,b 131,131 NULL # 100.00 Using sort_union(a,b); Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) FORCE INDEX (`a`) where ((`test`.`t1`.`a` like 'a%') or (`test`.`t1`.`b` like 'b%')) order by `test`.`t1`.`a`,`test`.`t1`.`b` +# we don't actually care about the result : we're checking if it crashes +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' +ORDER BY a,b; +SET SESSION sort_buffer_size=DEFAULT; +DROP TABLE t1; +End of 5.0 tests +#---------------- ROR-index_merge tests ----------------------- +# (Start of test file: index_merge_ror.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t0,t1,t2; +create table t1 +( +/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */ +st_a int not null default 0, +swt1a int not null default 0, +swt2a int not null default 0, +st_b int not null default 0, +swt1b int not null default 0, +swt2b int not null default 0, +/* fields/keys for row retrieval tests */ +key1 int, +key2 int, +key3 int, +key4 int, +/* make rows much bigger then keys */ +filler1 char (200), +filler2 char (200), +filler3 char (200), +filler4 char (200), +filler5 char (200), +filler6 char (200), +/* order of keys is important */ +key sta_swt12a(st_a,swt1a,swt2a), +key sta_swt1a(st_a,swt1a), +key sta_swt2a(st_a,swt2a), +key sta_swt21a(st_a,swt2a,swt1a), +key st_a(st_a), +key stb_swt1a_2b(st_b,swt1b,swt2a), +key stb_swt1b(st_b,swt1b), +key st_b(st_b), +key(key1), +key(key2), +key(key3), +key(key4) +) ; +create table t0 as select * from t1; +# Printing of many insert into t0 values (....) disabled. +alter table t1 disable keys; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +# Printing of many insert into t1 select .... from t0 disabled. +# Printing of many insert into t1 (...) values (....) disabled. +alter table t1 enable keys; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +select count(*) from t1; +count(*) +64801 +# One row results tests for cases where a single row matches all conditions +explain select key1,key2 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2 from t1 where key1=100 and key2=100; +key1 key2 +100 100 +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +explain format=json select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "#" + }, + "table": { + "table_name": "t1", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2", + "key3", + "key4" + ], + "key": "union(intersect(key1,key2),intersect(key3,key4))", + "key_length": "5,5,5,5", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "#", + "eval_cost": "#", + "prefix_cost": "#", + "data_read_per_join": "18K" + }, + "used_columns": [ + "key1", + "key2", + "key3", + "key4", + "filler1" + ], + "attached_condition": "(((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100)))" + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +100 100 100 100 key1-key2-key3-key4 +# Several-rows results +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1-key2'); +insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3'); +# ROR-intersection, not covering +explain select key1,key2,filler1 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2,filler1 from t1 where key1=100 and key2=100; +key1 key2 filler1 +100 100 key1-key2-key3-key4 +100 100 key1-key2 +# ROR-intersection, covering +explain select key1,key2 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2 from t1 where key1=100 and key2=100; +key1 key2 +100 100 +100 100 +# ROR-union of ROR-intersections +explain select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 +100 100 100 100 +100 100 -1 -1 +-1 -1 100 100 +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +100 100 100 100 key1-key2-key3-key4 +100 100 -1 -1 key1-key2 +-1 -1 100 100 key4-key3 +# 3-way ROR-intersection +explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 1 100.00 Using intersect(key1,key2,key3); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3` from `test`.`t1` where ((`test`.`t1`.`key3` = 100) and (`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; +key1 key2 key3 +100 100 100 +# ROR-union(ROR-intersection, ROR-range) +insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101'); +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 3 100.00 Using union(intersect(key1,key2),key3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key3` = 101)) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101; +key1 key2 key3 key4 filler1 +100 100 100 100 key1-key2-key3-key4 +100 100 -1 -1 key1-key2 +101 101 101 101 key1234-101 +# Run some ROR updates/deletes +select key1,key2, filler1 from t1 where key1=100 and key2=100; +key1 key2 filler1 +100 100 key1-key2-key3-key4 +100 100 key1-key2 +update t1 set filler1='to be deleted' where key1=100 and key2=100; +update t1 set key1=200,key2=200 where key1=100 and key2=100; +delete from t1 where key1=200 and key2=200; +select key1,key2,filler1 from t1 where key2=100 and key2=200; +key1 key2 filler1 +# ROR-union(ROR-intersection) with one of ROR-intersection giving empty +# results +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +-1 -1 100 100 key4-key3 +delete from t1 where key3=100 and key4=100; +# ROR-union with all ROR-intersections giving empty results +explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 4 100.00 Using union(intersect(key1,key2),intersect(key3,key4)); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where (((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or ((`test`.`t1`.`key4` = 100) and (`test`.`t1`.`key3` = 100))) +select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; +key1 key2 key3 key4 filler1 +# ROR-intersection with empty result +explain select key1,key2 from t1 where key1=100 and key2=100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL 2 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) +select key1,key2 from t1 where key1=100 and key2=100; +key1 key2 +# ROR-union tests with various cases. +# All scans returning duplicate rows: +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1'); +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-2'); +insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3'); +explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 8 100.00 Using union(key3,intersect(key1,key2),key4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key3` = 200) or ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key4` = 200)) +select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +key1 key2 key3 key4 filler1 +100 100 200 200 key1-key2-key3-key4-1 +100 100 200 200 key1-key2-key3-key4-2 +100 100 200 200 key1-key2-key3-key4-3 +insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4'); +explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 9 100.00 Using union(key3,intersect(key1,key2),key4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key3` = 200) or ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key4` = 200)) +select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +key1 key2 key3 key4 filler1 +100 100 200 200 key1-key2-key3-key4-1 +100 100 200 200 key1-key2-key3-key4-2 +100 100 200 200 key1-key2-key3-key4-3 +-1 -1 -1 200 key4 +insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3'); +explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 10 100.00 Using union(key3,intersect(key1,key2),key4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1` from `test`.`t1` where ((`test`.`t1`.`key3` = 200) or ((`test`.`t1`.`key2` = 100) and (`test`.`t1`.`key1` = 100)) or (`test`.`t1`.`key4` = 200)) +select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; +key1 key2 key3 key4 filler1 +100 100 200 200 key1-key2-key3-key4-1 +100 100 200 200 key1-key2-key3-key4-2 +100 100 200 200 key1-key2-key3-key4-3 +-1 -1 -1 200 key4 +-1 -1 200 -1 key3 +## +## Optimizer tests +## +# Check that the shortest key is used for ROR-intersection, covering and non-covering. +# Do many tests +# Check that keys that don't improve selectivity are skipped. +explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a sta_swt21a 12 const,const,const 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4000 10.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range stb_swt1a_2b,stb_swt1b,st_b stb_swt1b 8 NULL 4000 10.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1)) +explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL # # Using intersect(sta_swt12a,stb_swt1a_2b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b) +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt12a,stb_swt1b 12,8 NULL # # Using intersect(sta_swt12a,stb_swt1b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` IGNORE INDEX (`stb_swt1a_2b`) IGNORE INDEX (`sta_swt21a`) where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b) +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt1a,stb_swt1b,sta_swt2a 8,8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b,sta_swt2a); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` IGNORE INDEX (`stb_swt1a_2b`) IGNORE INDEX (`sta_swt12a`) IGNORE INDEX (`sta_swt21a`) where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b) +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt1a,sta_swt2a,st_a,st_b sta_swt1a,sta_swt2a,st_b 8,8,4 NULL # # Using intersect(sta_swt1a,sta_swt2a,st_b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` IGNORE INDEX (`stb_swt1b`) IGNORE INDEX (`stb_swt1a_2b`) IGNORE INDEX (`sta_swt12a`) IGNORE INDEX (`sta_swt21a`) where ((`test`.`t1`.`swt2b` = 1) and (`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 +where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL # # Using intersect(sta_swt12a,stb_swt1a_2b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt2a` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select * from t1 +where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a`,`test`.`t1`.`swt1a` AS `swt1a`,`test`.`t1`.`swt2a` AS `swt2a`,`test`.`t1`.`st_b` AS `st_b`,`test`.`t1`.`swt1b` AS `swt1b`,`test`.`t1`.`swt2b` AS `swt2b`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2`,`test`.`t1`.`filler3` AS `filler3`,`test`.`t1`.`filler4` AS `filler4`,`test`.`t1`.`filler5` AS `filler5`,`test`.`t1`.`filler6` AS `filler6` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select st_a from t1 +where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +explain select st_a from t1 +where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL # # Using intersect(sta_swt1a,stb_swt1b); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`st_a` AS `st_a` from `test`.`t1` where ((`test`.`t1`.`swt1b` = 1) and (`test`.`t1`.`st_b` = 1) and (`test`.`t1`.`swt1a` = 1) and (`test`.`t1`.`st_a` = 1)) +drop table t0,t1; +# 'Partially' covered fields test +create table t2 ( +a char(10), +b char(10), +filler1 char(255), +filler2 char(255), +key(a(5)), +key(b(5)) +); +select count(a) from t2 where a='BBBBBBBB'; +count(a) +4 +select count(a) from t2 where b='BBBBBBBB'; +count(a) +4 +# BUG#1: +expla_or_bin select count(a_or_b) from t2 where a_or_b='AAAAAAAA' a_or_bnd a_or_b='AAAAAAAA'; +id select_type ta_or_ba_or_ble pa_or_brtitions type possia_or_ble_keys key key_len ref rows filtered Extra_or_b +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 12.50 Pa_or_bra_or_bllel execute (1 workers) +2 SIMPLE t2 NULL ref a_or_b,a_or_b a_or_b 21 const 4 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a_or_b`) AS `count(a_or_b)` from `test`.`t2` where ((`test`.`t2`.`a_or_b` = 'AAAAAAAA') a_or_bnd (`test`.`t2`.`a_or_b` = 'AAAAAAAA')) +select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA'; +count(a) +4 +select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA'; +count(a) +4 +insert into t2 values ('ab', 'ab', 'uh', 'oh'); +explain select a from t2 where a='ab'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 21 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` = 'ab') +drop table t2; +# +# BUG#25048 - ERROR 126 : Incorrect key file for table '.XXXX.MYI'; +# try to repair it +# +CREATE TABLE t1(c1 INT, c2 INT DEFAULT 0, c3 CHAR(255) DEFAULT '', +KEY(c1), KEY(c2), KEY(c3)) charset latin1; +INSERT INTO t1(c1) VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0), +(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0); +INSERT INTO t1 VALUES(0,0,0); +CREATE TABLE t2(c1 int); +INSERT INTO t2 VALUES(1); +DELETE t1 FROM t1,t2 WHERE t1.c1=0 AND t1.c2=0; +SELECT * FROM t1; +c1 c2 c3 +DROP TABLE t1,t2; +#---------------- Index merge test 2 ------------------------------------------- +# (Start of test file: index_merge2.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t1,t2; +create table t1 +( +key1 int not null, +key2 int not null, +INDEX i1(key1), +INDEX i2(key2) +) charset latin1; +# No primary key +explain select * from t1 where key1 < 5 or key2 > 197; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key1` < 5) or (`test`.`t1`.`key2` > 197)) +select * from t1 where key1 < 5 or key2 > 197; +key1 key2 +0 200 +1 199 +2 198 +3 197 +4 196 +explain select * from t1 where key1 < 3 or key2 > 195; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key1` < 3) or (`test`.`t1`.`key2` > 195)) +select * from t1 where key1 < 3 or key2 > 195; +key1 key2 +0 200 +1 199 +2 198 +3 197 +4 196 +# Primary key as case-sensitive string with \0s. +# also make primary key be longer then max. index length of MyISAM. +alter table t1 add str1 char (255) not null, +add zeroval int not null default 0, +add str2 char (255) not null, +add str3 char (255) not null; +update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A')); +alter table t1 add primary key (str1, zeroval, str2, str3); +explain select * from t1 where key1 < 5 or key2 > 197; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`str1` AS `str1`,`test`.`t1`.`zeroval` AS `zeroval`,`test`.`t1`.`str2` AS `str2`,`test`.`t1`.`str3` AS `str3` from `test`.`t1` where ((`test`.`t1`.`key1` < 5) or (`test`.`t1`.`key2` > 197)) +select * from t1 where key1 < 5 or key2 > 197; +key1 key2 str1 zeroval str2 str3 +4 196 aaa 0 bbb 196-2_a +3 197 aaa 0 bbb 197-1_A +2 198 aaa 0 bbb 198-1_a +1 199 aaa 0 bbb 199-0_A +0 200 aaa 0 bbb 200-0_a +explain select * from t1 where key1 < 3 or key2 > 195; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 8 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`str1` AS `str1`,`test`.`t1`.`zeroval` AS `zeroval`,`test`.`t1`.`str2` AS `str2`,`test`.`t1`.`str3` AS `str3` from `test`.`t1` where ((`test`.`t1`.`key1` < 3) or (`test`.`t1`.`key2` > 195)) +select * from t1 where key1 < 3 or key2 > 195; +key1 key2 str1 zeroval str2 str3 +4 196 aaa 0 bbb 196-2_a +3 197 aaa 0 bbb 197-1_A +2 198 aaa 0 bbb 198-1_a +1 199 aaa 0 bbb 199-0_A +0 200 aaa 0 bbb 200-0_a +# Test for BUG#5401 +drop table t1; +create table t1 ( +pk integer not null auto_increment primary key, +key1 integer, +key2 integer not null, +filler char (200), +index (key1), +index (key2) +) charset latin1; +show warnings; +Level Code Message +explain select pk from t1 where key1 = 1 and key2 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,4 NULL 1 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`key2` = 1) and (`test`.`t1`.`key1` = 1)) +select pk from t1 where key2 = 1 and key1 = 1; +pk +26 +27 +select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1; +pk +26 +27 +# More tests for BUG#5401. +drop table t1; +create table t1 ( +pk int primary key auto_increment, +key1a int, +key2a int, +key1b int, +key2b int, +dummy1 int, +dummy2 int, +dummy3 int, +dummy4 int, +key3a int, +key3b int, +filler1 char (200), +index i1(key1a, key1b), +index i2(key2a, key2b), +index i3(key3a, key3b) +); +create table t2 (a int); +insert into t2 values (0),(1),(2),(3),(4),(NULL); +insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) +select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D; +insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) +select key1a, key1b, key2a, key2b, key3a, key3b from t1; +insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) +select key1a, key1b, key2a, key2b, key3a, key3b from t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select count(*) from t1; +count(*) +5184 +explain select count(*) from t1 where +key1a = 2 and key1b is null and key2a = 2 and key2b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 10,10 NULL # 100.00 Using intersect(i1,i2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`key2a` = 2) and (`test`.`t1`.`key1a` = 2) and (`test`.`t1`.`key1b` is null) and (`test`.`t1`.`key2b` is null)) +select count(*) from t1 where +key1a = 2 and key1b is null and key2a = 2 and key2b is null; +count(*) +4 +explain select count(*) from t1 where +key1a = 2 and key1b is null and key3a = 2 and key3b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i3 i1,i3 10,10 NULL # 100.00 Using intersect(i1,i3); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`key3a` = 2) and (`test`.`t1`.`key1a` = 2) and (`test`.`t1`.`key1b` is null) and (`test`.`t1`.`key3b` is null)) +select count(*) from t1 where +key1a = 2 and key1b is null and key3a = 2 and key3b is null; +count(*) +4 +drop table t1,t2; +# Test for BUG#8441 +create table t1 ( +id1 int, +id2 date , +index idx2 (id1,id2), +index idx1 (id2) +); +insert into t1 values(1,'20040101'), (2,'20040102'); +select * from t1 where id1 = 1 and id2= '20040101'; +id1 id2 +1 2004-01-01 +drop table t1; +# Test for BUG#12720 +drop view if exists v1; +CREATE TABLE t1 ( +`oid` int(11) unsigned NOT NULL auto_increment, +`fk_bbk_niederlassung` int(11) unsigned NOT NULL, +`fk_wochentag` int(11) unsigned NOT NULL, +`uhrzeit_von` time NOT NULL COMMENT 'HH:MM', +`uhrzeit_bis` time NOT NULL COMMENT 'HH:MM', +`geloescht` tinyint(4) NOT NULL, +`version` int(5) NOT NULL, +PRIMARY KEY (`oid`), +KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`), +KEY `fk_wochentag` (`fk_wochentag`), +KEY `ix_version` (`version`) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values +(1, 38, 1, '08:00:00', '13:00:00', 0, 1), +(2, 38, 2, '08:00:00', '13:00:00', 0, 1), +(3, 38, 3, '08:00:00', '13:00:00', 0, 1), +(4, 38, 4, '08:00:00', '13:00:00', 0, 1), +(5, 38, 5, '08:00:00', '13:00:00', 0, 1), +(6, 38, 5, '08:00:00', '13:00:00', 1, 2), +(7, 38, 3, '08:00:00', '13:00:00', 1, 2), +(8, 38, 1, '08:00:00', '13:00:00', 1, 2), +(9, 38, 2, '08:00:00', '13:00:00', 1, 2), +(10, 38, 4, '08:00:00', '13:00:00', 1, 2), +(11, 38, 1, '08:00:00', '13:00:00', 0, 3), +(12, 38, 2, '08:00:00', '13:00:00', 0, 3), +(13, 38, 3, '08:00:00', '13:00:00', 0, 3), +(14, 38, 4, '08:00:00', '13:00:00', 0, 3), +(15, 38, 5, '08:00:00', '13:00:00', 0, 3), +(16, 38, 4, '08:00:00', '13:00:00', 0, 4), +(17, 38, 5, '08:00:00', '13:00:00', 0, 4), +(18, 38, 1, '08:00:00', '13:00:00', 0, 4), +(19, 38, 2, '08:00:00', '13:00:00', 0, 4), +(20, 38, 3, '08:00:00', '13:00:00', 0, 4), +(21, 7, 1, '08:00:00', '13:00:00', 0, 1), +(22, 7, 2, '08:00:00', '13:00:00', 0, 1), +(23, 7, 3, '08:00:00', '13:00:00', 0, 1), +(24, 7, 4, '08:00:00', '13:00:00', 0, 1), +(25, 7, 5, '08:00:00', '13:00:00', 0, 1); +create view v1 as +select +zeit1.oid AS oid, +zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung, +zeit1.fk_wochentag AS fk_wochentag, +zeit1.uhrzeit_von AS uhrzeit_von, +zeit1.uhrzeit_bis AS uhrzeit_bis, +zeit1.geloescht AS geloescht, +zeit1.version AS version +from +t1 zeit1 +where +(zeit1.version = +(select max(zeit2.version) AS `max(version)` + from t1 zeit2 +where +((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and +(zeit1.fk_wochentag = zeit2.fk_wochentag) and +(zeit1.uhrzeit_von = zeit2.uhrzeit_von) and +(zeit1.uhrzeit_bis = zeit2.uhrzeit_bis) +) +) +) +and (zeit1.geloescht = 0); +select * from v1 where oid = 21; +oid fk_bbk_niederlassung fk_wochentag uhrzeit_von uhrzeit_bis geloescht version +21 7 1 08:00:00 13:00:00 0 1 +drop view v1; +drop table t1; +CREATE TABLE t1( +t_cpac varchar(2) NOT NULL, +t_vers varchar(4) NOT NULL, +t_rele varchar(2) NOT NULL, +t_cust varchar(4) NOT NULL, +filler1 char(250) default NULL, +filler2 char(250) default NULL, +PRIMARY KEY (t_cpac,t_vers,t_rele,t_cust), +UNIQUE KEY IX_4 (t_cust,t_cpac,t_vers,t_rele), +KEY IX_5 (t_vers,t_rele,t_cust) +) charset latin1; +insert into t1 values +('tm','2.5 ','a ',' ','',''), ('tm','2.5U','a ','stnd','',''), +('da','3.3 ','b ',' ','',''), ('da','3.3U','b ','stnd','',''), +('tl','7.6 ','a ',' ','',''), ('tt','7.6 ','a ',' ','',''), +('bc','B61 ','a ',' ','',''), ('bp','B61 ','a ',' ','',''), +('ca','B61 ','a ',' ','',''), ('ci','B61 ','a ',' ','',''), +('cp','B61 ','a ',' ','',''), ('dm','B61 ','a ',' ','',''), +('ec','B61 ','a ',' ','',''), ('ed','B61 ','a ',' ','',''), +('fm','B61 ','a ',' ','',''), ('nt','B61 ','a ',' ','',''), +('qm','B61 ','a ',' ','',''), ('tc','B61 ','a ',' ','',''), +('td','B61 ','a ',' ','',''), ('tf','B61 ','a ',' ','',''), +('tg','B61 ','a ',' ','',''), ('ti','B61 ','a ',' ','',''), +('tp','B61 ','a ',' ','',''), ('ts','B61 ','a ',' ','',''), +('wh','B61 ','a ',' ','',''), ('bc','B61U','a ','stnd','',''), +('bp','B61U','a ','stnd','',''), ('ca','B61U','a ','stnd','',''), +('ci','B61U','a ','stnd','',''), ('cp','B61U','a ','stnd','',''), +('dm','B61U','a ','stnd','',''), ('ec','B61U','a ','stnd','',''), +('fm','B61U','a ','stnd','',''), ('nt','B61U','a ','stnd','',''), +('qm','B61U','a ','stnd','',''), ('tc','B61U','a ','stnd','',''), +('td','B61U','a ','stnd','',''), ('tf','B61U','a ','stnd','',''), +('tg','B61U','a ','stnd','',''), ('ti','B61U','a ','stnd','',''), +('tp','B61U','a ','stnd','',''), ('ts','B61U','a ','stnd','',''), +('wh','B61U','a ','stnd','',''); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t_cpac` varchar(2) NOT NULL, + `t_vers` varchar(4) NOT NULL, + `t_rele` varchar(2) NOT NULL, + `t_cust` varchar(4) NOT NULL, + `filler1` char(250) DEFAULT NULL, + `filler2` char(250) DEFAULT NULL, + PRIMARY KEY (`t_cpac`,`t_vers`,`t_rele`,`t_cust`), + UNIQUE KEY `IX_4` (`t_cust`,`t_cpac`,`t_vers`,`t_rele`), + KEY `IX_5` (`t_vers`,`t_rele`,`t_cust`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6'; +t_vers t_rele t_cust filler1 +7.6 a +7.6 a +select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6' + and t_rele='a' and t_cust = ' '; +t_vers t_rele t_cust filler1 +7.6 a +7.6 a +drop table t1; +# BUG#19021: Crash in index_merge/ROR-intersection optimizer under +# specific circumstances. +create table t1 ( +pk int(11) not null auto_increment, +a int(11) not null default '0', +b int(11) not null default '0', +c int(11) not null default '0', +filler1 datetime, filler2 varchar(15), +filler3 longtext, +kp1 varchar(4), kp2 varchar(7), +kp3 varchar(2), kp4 varchar(4), +kp5 varchar(7), +filler4 char(1), +primary key (pk), +key idx1(a,b,c), +key idx2(c), +key idx3(kp1,kp2,kp3,kp4,kp5) +) default charset=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set @fill=NULL; +SELECT COUNT(*) FROM t1 WHERE b = 0 AND a = 0 AND c = 13286427 AND +kp1='279' AND kp2='ELM0678' AND kp3='6' AND kp4='10' AND kp5 = 'R '; +COUNT(*) +1 +drop table t1; +# BUG#21277: Index Merge/sort_union: wrong query results +create table t1 +( +key1 int not null, +key2 int not null default 0, +key3 int not null default 0 +); +insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8); +set @d=8; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +insert into t1 (key1) select key1+@d from t1; +set @d=@d*2; +alter table t1 add index i2(key2); +alter table t1 add index i3(key3); +update t1 set key2=key1,key3=key1; +explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i2,i3 i3,i2 4,4 NULL # 100.00 Using sort_union(i3,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3` from `test`.`t1` where (((`test`.`t1`.`key3` > 30) and (`test`.`t1`.`key3` < 35)) or ((`test`.`t1`.`key2` > 32) and (`test`.`t1`.`key2` < 40))) +select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40); +key1 key2 key3 +31 31 31 +32 32 32 +33 33 33 +34 34 34 +35 35 35 +36 36 36 +37 37 37 +38 38 38 +39 39 39 +drop table t1; +# +# Bug#56423: Different count with SELECT and CREATE SELECT queries +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +d INT, +PRIMARY KEY (a), +KEY (c), +KEY bd (b,d) +); +INSERT INTO t1 VALUES +(1, 0, 1, 0), +(2, 1, 1, 1), +(3, 1, 1, 1), +(4, 0, 1, 1); +EXPLAIN +SELECT a +FROM t1 +WHERE c = 1 AND b = 1 AND d = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref c,bd bd 10 const,const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`d` = 1) and (`test`.`t1`.`b` = 1) and (`test`.`t1`.`c` = 1)) +CREATE TABLE t2 ( a INT ) +SELECT a +FROM t1 +WHERE c = 1 AND b = 1 AND d = 1; +SELECT * FROM t2; +a +2 +3 +DROP TABLE t1, t2; +CREATE TABLE t1( a INT, b INT, KEY(a), KEY(b) ); +INSERT INTO t1 VALUES (1, 2), (1, 2), (1, 2), (1, 2); +SELECT * FROM t1 FORCE INDEX(a, b) WHERE a = 1 AND b = 2; +a b +1 2 +1 2 +1 2 +1 2 +DROP TABLE t1; +# Code coverage of fix. +CREATE TABLE t1 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT); +INSERT INTO t1 (b) VALUES (1); +UPDATE t1 SET b = 2 WHERE a = 1; +SELECT * FROM t1; +a b +1 2 +CREATE TABLE t2 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b VARCHAR(1) ); +INSERT INTO t2 (b) VALUES ('a'); +UPDATE t2 SET b = 'b' WHERE a = 1; +SELECT * FROM t2; +a b +1 b +DROP TABLE t1, t2; +# +# BUG#13970015: ASSERT `MIN_ENDP || MAX_ENDP' FAILED IN +# HANDLER::MULTI_RANGE_READ_INFO_CONST +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +INSERT INTO t1 VALUES (1,1,'a'), (2,2,'b'); +EXPLAIN +SELECT col_int_key +FROM t1 +WHERE col_varchar_key >= 'l' OR +(((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l') +AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 78.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,col_int_key,col_varchar_key col_varchar_key 10 NULL 2 78.12 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` where ((`test`.`t1`.`col_varchar_key` >= 'l') or (((`test`.`t1`.`pk` between 141 and 141) or (`test`.`t1`.`col_varchar_key` <> 'l')) and ((`test`.`t1`.`pk` between 141 and 141) or (`test`.`t1`.`col_int_key` > 141)))) +SELECT col_int_key +FROM t1 +WHERE col_varchar_key >= 'l' OR +(((pk BETWEEN 141 AND 141) OR col_varchar_key <> 'l') +AND ((pk BETWEEN 141 AND 141) OR (col_int_key > 141))); +col_int_key +DROP TABLE t1; +#---------------- 2-sweeps read Index merge test 2 ------------------------------- +# (Start of test file: index_merge_2sweeps.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t1; +create table t1 ( +pk int primary key, +key1 int, +key2 int, +filler char(200), +filler2 char(200), +index(key1), +index(key2) +); +select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 ); +pk key1 key2 filler filler2 +10 10 10 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +5 5 5 filler-data filler-data-2 +6 6 6 filler-data filler-data-2 +7 7 7 filler-data filler-data-2 +8 8 8 filler-data filler-data-2 +9 9 9 filler-data filler-data-2 +set @maxv=1000; +select * from t1 where +(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10) +or key1=18 or key1=60; +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +18 18 18 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +60 60 60 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +select * from t1 where +(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10) +or key1 < 3 or key1 > @maxv-11; +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +990 990 990 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +select * from t1 where +(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10) +or +(key1 < 5) or (key1 > 10 and key1 < 15) or (key1 >= 50 and key1 < 55 ) or (key1 > @maxv-10); +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +select * from t1 where +(pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) +or +(key1 < 5) or (key1 > @maxv-10); +pk key1 key2 filler filler2 +1 1 1 filler-data filler-data-2 +1000 1000 1000 filler-data filler-data-2 +11 11 11 filler-data filler-data-2 +12 12 12 filler-data filler-data-2 +13 13 13 filler-data filler-data-2 +14 14 14 filler-data filler-data-2 +2 2 2 filler-data filler-data-2 +3 3 3 filler-data filler-data-2 +4 4 4 filler-data filler-data-2 +50 50 50 filler-data filler-data-2 +51 51 51 filler-data filler-data-2 +52 52 52 filler-data filler-data-2 +53 53 53 filler-data filler-data-2 +54 54 54 filler-data filler-data-2 +991 991 991 filler-data filler-data-2 +992 992 992 filler-data filler-data-2 +993 993 993 filler-data filler-data-2 +994 994 994 filler-data filler-data-2 +995 995 995 filler-data filler-data-2 +996 996 996 filler-data filler-data-2 +997 997 997 filler-data filler-data-2 +998 998 998 filler-data filler-data-2 +999 999 999 filler-data filler-data-2 +drop table t1; +#---------------- Clustered PK ROR-index_merge tests ----------------------------- +# (Start of test file: index_merge_ror_cpk.inc) +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +drop table if exists t1; +create table t1 +( +pk1 int not null, +pk2 int not null, +key1 int not null, +key2 int not null, +pktail1ok int not null, +pktail2ok int not null, +pktail3bad int not null, +pktail4bad int not null, +pktail5bad int not null, +pk2copy int not null, +badkey int not null, +filler1 char (200), +filler2 char (200), +key (key1), +key (key2), +/* keys with tails from CPK members */ +key (pktail1ok, pk1), +key (pktail2ok, pk1, pk2), +key (pktail3bad, pk2, pk1), +key (pktail4bad, pk1, pk2copy), +key (pktail5bad, pk1, pk2, pk2copy), +primary key (pk1, pk2) +); +# Verify that range scan on CPK is ROR +# (use index_intersection because it is impossible to check that for index union) +# Column 9, rows, can change depending on innodb-page-size. +explain select * from t1 where pk1 = 1 and pk2 < 80 and key1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS # Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,key1 PRIMARY 8 NULL ROWS # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 0) and (`test`.`t1`.`pk1` = 1) and (`test`.`t1`.`pk2` < 80)) +# CPK scan + 1 ROR range scan is a special case +select * from t1 where pk1 = 1 and pk2 < 80 and key1=0; +pk1 pk2 key1 key2 pktail1ok pktail2ok pktail3bad pktail4bad pktail5bad pk2copy badkey filler1 filler2 +1 10 0 0 0 0 0 0 0 10 0 filler-data-10 filler2 +1 11 0 0 0 0 0 0 0 11 0 filler-data-11 filler2 +1 12 0 0 0 0 0 0 0 12 0 filler-data-12 filler2 +1 13 0 0 0 0 0 0 0 13 0 filler-data-13 filler2 +1 14 0 0 0 0 0 0 0 14 0 filler-data-14 filler2 +1 15 0 0 0 0 0 0 0 15 0 filler-data-15 filler2 +1 16 0 0 0 0 0 0 0 16 0 filler-data-16 filler2 +1 17 0 0 0 0 0 0 0 17 0 filler-data-17 filler2 +1 18 0 0 0 0 0 0 0 18 0 filler-data-18 filler2 +1 19 0 0 0 0 0 0 0 19 0 filler-data-19 filler2 +# Verify that CPK fields are considered to be covered by index scans +explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 4,4 NULL 1 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) and (`test`.`t1`.`key1` = 10) and (((2 * `test`.`t1`.`pk1`) + 1) < (((2 * 96) + 1)))) +select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1; +pk1 pk2 +95 50 +95 51 +95 52 +95 53 +95 54 +95 55 +95 56 +95 57 +95 58 +95 59 +# Verify that CPK is always used for index intersection scans +# (this is because it is used as a filter, not for retrieval) +# The expected number of rows can vary depending on page size +explain select * from t1 where badkey=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1 key1 4 const ROWS 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`badkey` = 1)) +# The expected number of rows can vary depending on page size +explain select * from t1 where pk1 < 7500 and key1 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,key1 key1,PRIMARY 8,4 NULL ROWS 100.00 Using intersect(key1,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pk1` < 7500)) +# Verify that keys with 'tails' of PK members are ok. +explain select * from t1 where pktail1ok=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,pktail1ok key1,pktail1ok 4,4 NULL 1 100.00 Using intersect(key1,pktail1ok); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail1ok` = 1)) +explain select * from t1 where pktail2ok=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,pktail2ok key1,pktail2ok 4,4 NULL 1 100.00 Using intersect(key1,pktail2ok); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail2ok` = 1)) +# Note: The following is actually a deficiency, it uses sort_union currently. +# This comment refers to InnoDB and is probably not valid for other engines. +explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,key1,pktail2ok pktail2ok,key1 8,4 NULL ROWS 100.00 Using sort_union(pktail2ok,key1); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where (((`test`.`t1`.`pktail2ok` = 1) and (`test`.`t1`.`pk1` < 50000)) or (`test`.`t1`.`key1` = 10)) +explain select * from t1 where pktail3bad=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL EITHER_KEY NULL NULL ROWS 1.03 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1,pktail3bad EITHER_KEY 4 const ROWS 1.03 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail3bad` = 1)) +explain select * from t1 where pktail4bad=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 1.03 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1,pktail4bad key1 4 const ROWS 1.03 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail4bad` = 1)) +explain select * from t1 where pktail5bad=1 and key1=10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 1.03 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref key1,pktail5bad key1 4 const ROWS 1.03 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`pktail1ok` AS `pktail1ok`,`test`.`t1`.`pktail2ok` AS `pktail2ok`,`test`.`t1`.`pktail3bad` AS `pktail3bad`,`test`.`t1`.`pktail4bad` AS `pktail4bad`,`test`.`t1`.`pktail5bad` AS `pktail5bad`,`test`.`t1`.`pk2copy` AS `pk2copy`,`test`.`t1`.`badkey` AS `badkey`,`test`.`t1`.`filler1` AS `filler1`,`test`.`t1`.`filler2` AS `filler2` from `test`.`t1` where ((`test`.`t1`.`key1` = 10) and (`test`.`t1`.`pktail5bad` = 1)) +# Test for problem with innodb key values prefetch buffer: +explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 4,4 NULL 1 100.00 Using intersect(key1,key2); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`pk2` AS `pk2`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) and (`test`.`t1`.`key1` = 10)) limit 10 +select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; +pk1 pk2 key1 key2 +95 50 10 10 +95 51 10 10 +95 52 10 10 +95 53 10 10 +95 54 10 10 +95 55 10 10 +95 56 10 10 +95 57 10 10 +95 58 10 10 +95 59 10 10 +drop table t1; +# Testcase for BUG#4984 +create table t1 +( +RUNID varchar(22), +SUBMITNR varchar(5), +ORDERNR char(1), +PROGRAMM varchar(8), +TESTID varchar(4), +UCCHECK char(1), +ETEXT varchar(80), +ETEXT_TYPE char(1), +INFO char(1), +SEVERITY tinyint(3), +TADIRFLAG char(1), +PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK), +KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`='' +WHERE +`RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND +`TESTID`='' AND `UCCHECK`=''; +drop table t1; +# +# Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB +# +CREATE TABLE t1 (f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (f1 INT, f2 INT, f3 char(1), +PRIMARY KEY (f1), KEY (f2), KEY (f3) ); +INSERT INTO t2 VALUES (1, 1, 'h'), (2, 3, 'h'), (3, 2, ''), (4, 2, ''); +SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; +f1 +2 +EXPLAIN SELECT t1.f1 FROM t1 +WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL index_merge f2,f3 f2,f3 5,5 NULL 1 100.00 Using intersect(f2,f3); Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `f1` from `test`.`t1` where true +DROP TABLE t1,t2; +# +# Bug#19055268 ASSERT `!TABLE || (!TABLE->READ_SET || BITMAP_IS_SET(TABLE->READ_SET,...) FAILED +# +SET sql_mode = ''; +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +col_date_key date NOT NULL, +col_date_nokey date NOT NULL, +col_time_key time NOT NULL, +col_time_nokey time NOT NULL, +col_datetime_key datetime NOT NULL, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,2,1,'0000-00-00','0000-00-00','00:00:07','00:00:25','0000-00-00 00:00:00','0000-00-00 00:00:00','2','2'), +(109,25,1,'0000-00-00','0000-00-00','00:00:07','00:00:25','0000-00-00 00:00:00','0000-00-00 00:00:00','1','7'); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +col_date_key date NOT NULL, +col_date_nokey date NOT NULL, +col_time_key time NOT NULL, +col_time_nokey time NOT NULL, +col_datetime_key datetime NOT NULL, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES +(10,2,4,'2000-04-16','2000-04-16','17:02:34','17:02:34','2009-08-04 02:49:10','2009-08-04 02:49:10','u','u'), +(11,6,5,'1900-01-01','1900-01-01','12:31:32','12:31:32','2004-05-24 22:22:06','2004-05-24 22:22:06','b','b'), +(12,6,0,'2005-05-14','2005-05-14','16:49:31','16:49:31','1900-01-01 00:00:00','1900-01-01 00:00:00','c','c'), +(13,94,140,'2001-05-23','2001-05-23','00:00:00','00:00:00','2003-07-28 07:31:49','2003-07-28 07:31:49','f','f'), +(14,10,230,'2000-06-04','2000-06-04','20:23:27','20:23:27','2000-02-04 21:03:36','2000-02-04 21:03:36','g','g'), +(15,8,2,'1900-01-01','1900-01-01','10:31:09','10:31:09','2005-05-22 11:48:12','2005-05-22 11:48:12','q','q'), +(16,43,110,'2008-03-18','2008-03-18','09:58:35','09:58:35','1900-01-01 00:00:00','1900-01-01 00:00:00','n','n'), +(17,1,8,'2007-02-25','2007-02-25','05:39:28','05:39:28','2005-05-06 00:53:37','2005-05-06 00:53:37','c','c'), +(18,6,5,'2001-11-22','2001-11-22','00:00:00','00:00:00','2002-08-08 23:43:46','2002-08-08 23:43:46','x','x'), +(19,5,8,'0000-00-00','0000-00-00','00:00:00','00:00:00','2009-10-26 04:07:22','2009-10-26 04:07:22','n','n'), +(20,1,5,'2001-08-07','2001-08-07','14:06:09','14:06:09','2005-03-12 22:55:23','2005-03-12 22:55:23','r','r'), +(21,195,70,'2000-08-03','2000-08-03','00:00:00','00:00:00','2008-05-03 22:34:19','2008-05-03 22:34:19','j','j'), +(22,1,0,'2007-04-21','2007-04-21','17:43:27','17:43:27','2001-10-12 13:30:14','2001-10-12 13:30:14','l','l'), +(23,0,9,'2000-06-13','2000-06-13','12:23:15','12:23:15','2007-10-07 03:53:06','2007-10-07 03:53:06','h','h'), +(24,7,3,'0000-00-00','0000-00-00','19:35:06','19:35:06','2005-12-27 20:58:56','2005-12-27 20:58:56','z','z'), +(25,1,9,'2004-07-08','2004-07-08','10:16:08','10:16:08','2009-05-16 18:44:21','2009-05-16 18:44:21','z','z'), +(26,4,3,'2003-06-01','2003-06-01','00:00:00','00:00:00','2008-10-02 00:00:00','2008-10-02 00:00:00','d','d'), +(27,76,22,'0000-00-00','0000-00-00','16:51:15','16:51:15','2001-03-20 00:00:00','2001-03-20 00:00:00','l','l'), +(28,6,1,'1900-01-01','1900-01-01','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','s','s'), +(29,7,3,'2007-01-22','2007-01-22','00:00:00','00:00:00','2000-01-10 23:19:37','2000-01-10 23:19:37','k','k'), +(30,6,3,'2006-10-19','2006-10-19','21:46:20','21:46:20','2008-06-21 16:56:37','2008-06-21 16:56:37','l','l'), +(31,6,8,'2005-02-27','2005-02-27','00:00:00','00:00:00','2002-03-01 00:34:37','2002-03-01 00:34:37','t','t'), +(32,1,4,'2001-09-10','2001-09-10','03:34:16','03:34:16','2003-02-05 18:41:00','2003-02-05 18:41:00','n','n'), +(33,5,1,'2002-09-06','2002-09-06','11:25:31','11:25:31','2004-01-18 13:28:24','2004-01-18 13:28:24','z','z'), +(34,2,3,'2005-01-15','2005-01-15','17:00:53','17:00:53','2002-12-03 01:06:27','2002-12-03 01:06:27','f','f'), +(35,1,3,'1900-01-01','1900-01-01','23:32:47','23:32:47','2006-03-03 02:58:59','2006-03-03 02:58:59','q','q'), +(36,185,63,'2006-12-20','2006-12-20','00:00:00','00:00:00','2002-07-01 10:13:39','2002-07-01 10:13:39','l','l'), +(37,3,4,'2002-04-17','2002-04-17','12:15:05','12:15:05','2009-01-13 20:47:01','2009-01-13 20:47:01','a','a'), +(38,7,8,'2004-01-10','2004-01-10','22:26:38','22:26:38','2008-07-18 13:35:29','2008-07-18 13:35:29','c','c'), +(39,8,6,'2008-03-24','2008-03-24','00:00:00','00:00:00','2001-03-15 02:44:57','2001-03-15 02:44:57','c','c'), +(40,1,4,'2007-08-18','2007-08-18','00:00:00','00:00:00','2000-06-25 14:03:55','2000-06-25 14:03:55','i','i'), +(41,3,9,'2005-07-22','2005-07-22','00:00:00','00:00:00','2005-12-13 21:32:03','2005-12-13 21:32:03','r','r'), +(42,8,2,'2008-07-12','2008-07-12','08:59:37','08:59:37','2009-03-18 19:27:29','2009-03-18 19:27:29','g','g'), +(43,159,118,'2003-08-18','2003-08-18','07:19:50','07:19:50','2004-04-10 02:50:59','2004-04-10 02:50:59','l','l'), +(44,112,10,'2002-02-26','2002-02-26','03:51:46','03:51:46','2008-09-27 06:49:19','2008-09-27 06:49:19','w','w'), +(45,0,9,'2007-07-26','2007-07-26','15:57:32','15:57:32','2006-02-04 15:10:41','2006-02-04 15:10:41','b','b'), +(46,2,9,'1900-01-01','1900-01-01','02:57:08','02:57:08','2004-01-04 18:45:14','2004-01-04 18:45:14','i','i'), +(47,1,1,'2000-07-26','2000-07-26','00:21:15','00:21:15','2009-04-04 02:52:09','2009-04-04 02:52:09','o','o'), +(48,7,6,'2005-03-06','2005-03-06','23:35:02','23:35:02','2001-03-20 12:50:17','2001-03-20 12:50:17','f','f'), +(49,5,2,'2005-04-16','2005-04-16','09:21:51','09:21:51','2001-11-15 10:51:46','2001-11-15 10:51:46','a','a'), +(50,2,2,'2004-04-09','2004-04-09','19:21:02','19:21:02','2007-08-13 00:00:00','2007-08-13 00:00:00','j','j'), +(51,5,3,'2003-05-13','2003-05-13','03:16:22','03:16:22','1900-01-01 00:00:00','1900-01-01 00:00:00','k','k'), +(52,5,0,'0000-00-00','0000-00-00','00:00:00','00:00:00','2008-01-24 08:37:15','2008-01-24 08:37:15','x','x'), +(53,2,8,'2000-05-27','2000-05-27','18:19:51','18:19:51','2003-03-02 10:18:02','2003-03-02 10:18:02','r','r'), +(54,2,5,'2004-07-04','2004-07-04','01:42:17','01:42:17','2003-04-25 07:35:13','2003-04-25 07:35:13','t','t'), +(55,9,0,'2006-03-07','2006-03-07','00:00:00','00:00:00','2006-07-11 23:31:13','2006-07-11 23:31:13','p','p'), +(56,3,1,'2002-08-17','2002-08-17','20:32:51','20:32:51','2009-08-08 16:55:59','2009-08-08 16:55:59','g','g'), +(57,2,9,'2003-06-08','2003-06-08','10:04:19','10:04:19','1900-01-01 00:00:00','1900-01-01 00:00:00','q','q'), +(58,7,4,'1900-01-01','1900-01-01','06:39:26','06:39:26','2000-12-22 10:27:41','2000-12-22 10:27:41','m','m'), +(59,4,7,'2003-10-09','2003-10-09','15:48:26','15:48:26','2002-07-20 00:00:00','2002-07-20 00:00:00','l','l'), +(60,5,6,'2007-08-12','2007-08-12','02:17:23','02:17:23','2007-09-24 00:12:11','2007-09-24 00:12:11','d','d'), +(61,3,3,'2008-12-13','2008-12-13','07:48:47','07:48:47','2009-01-05 06:13:21','2009-01-05 06:13:21','n','n'), +(62,0,8,'0000-00-00','0000-00-00','09:09:14','09:09:14','2008-11-23 18:13:35','2008-11-23 18:13:35','l','l'), +(63,1,2,'2003-07-27','2003-07-27','22:46:23','22:46:23','2002-12-19 00:00:00','2002-12-19 00:00:00','c','c'), +(64,5,5,'2003-04-13','2003-04-13','19:42:42','19:42:42','2003-04-03 16:16:35','2003-04-03 16:16:35','v','v'), +(65,0,3,'2007-04-25','2007-04-25','15:15:32','15:15:32','2009-04-13 13:44:41','2009-04-13 13:44:41','z','z'), +(66,4,4,'2000-03-04','2000-03-04','02:50:26','02:50:26','2007-04-19 20:49:24','2007-04-19 20:49:24','h','h'), +(67,0,9,'2001-08-03','2001-08-03','14:44:31','14:44:31','2002-11-15 23:36:04','2002-11-15 23:36:04','y','y'), +(68,2,0,'2006-04-13','2006-04-13','00:00:00','00:00:00','2000-05-16 00:00:00','2000-05-16 00:00:00','o','o'), +(69,2,1,'2006-04-22','2006-04-22','07:31:27','07:31:27','2002-06-08 06:51:27','2002-06-08 06:51:27','h','h'), +(70,8,5,'2004-08-26','2004-08-26','10:48:57','10:48:57','2006-12-07 01:49:26','2006-12-07 01:49:26','h','h'), +(71,8,6,'2002-11-26','2002-11-26','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','c','c'), +(72,5,2,'2002-01-07','2002-01-07','23:06:00','23:06:00','2000-09-27 16:26:23','2000-09-27 16:26:23','m','m'), +(73,1,0,'2005-05-07','2005-05-07','05:56:02','05:56:02','1900-01-01 00:00:00','1900-01-01 00:00:00','s','s'), +(74,0,0,'2001-04-21','2001-04-21','10:44:22','10:44:22','2008-02-13 04:28:14','2008-02-13 04:28:14','t','t'), +(75,7,9,'2000-09-01','2000-09-01','00:00:00','00:00:00','2000-03-10 06:17:52','2000-03-10 06:17:52','r','r'), +(76,6,8,'2004-07-06','2004-07-06','01:44:26','01:44:26','2003-05-23 00:00:00','2003-05-23 00:00:00','u','u'), +(77,0,6,'0000-00-00','0000-00-00','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','h','h'), +(78,6,0,'2001-02-21','2001-02-21','17:01:49','17:01:49','2003-10-27 12:45:52','2003-10-27 12:45:52','p','p'), +(79,9,0,'2004-01-28','2004-01-28','16:27:14','16:27:14','2004-08-06 00:00:00','2004-08-06 00:00:00','z','z'), +(80,5,3,'2008-10-07','2008-10-07','00:00:00','00:00:00','2001-10-05 05:13:39','2001-10-05 05:13:39','h','h'), +(81,5,5,'0000-00-00','0000-00-00','10:34:22','10:34:22','2001-03-25 04:24:51','2001-03-25 04:24:51','q','q'), +(82,6,0,'2008-03-04','2008-03-04','10:48:51','10:48:51','2006-08-20 11:54:04','2006-08-20 11:54:04','l','l'), +(83,1,0,'2009-05-08','2009-05-08','16:55:06','16:55:06','2003-05-16 18:14:52','2003-05-16 18:14:52','p','p'), +(84,1,1,'2005-03-19','2005-03-19','14:46:32','14:46:32','2009-10-24 13:39:35','2009-10-24 13:39:35','t','t'), +(85,9,8,'2007-09-14','2007-09-14','16:26:50','16:26:50','2001-08-10 00:00:00','2001-08-10 00:00:00','o','o'), +(86,249,190,'2007-02-10','2007-02-10','06:35:32','06:35:32','2001-09-06 10:15:08','2001-09-06 10:15:08','o','o'), +(87,3,0,'2000-06-12','2000-06-12','02:28:38','02:28:38','2006-09-27 00:00:00','2006-09-27 00:00:00','p','p'), +(88,6,4,'2002-07-06','2002-07-06','00:00:00','00:00:00','2002-02-27 20:12:29','2002-02-27 20:12:29','e','e'), +(89,7,2,'2001-02-25','2001-02-25','04:52:29','04:52:29','1900-01-01 00:00:00','1900-01-01 00:00:00','u','u'), +(90,5,8,'2000-04-27','2000-04-27','00:00:00','00:00:00','2005-08-18 00:00:00','2005-08-18 00:00:00','z','z'), +(91,4,0,'2005-08-23','2005-08-23','09:11:04','09:11:04','2000-10-15 15:52:54','2000-10-15 15:52:54','j','j'), +(92,24,137,'2006-01-07','2006-01-07','22:38:18','22:38:18','2007-11-22 13:52:22','2007-11-22 13:52:22','e','e'), +(93,3,7,'2007-07-08','2007-07-08','13:23:13','13:23:13','2005-09-20 09:09:48','2005-09-20 09:09:48','k','k'), +(94,179,153,'2000-01-06','2000-01-06','15:33:10','15:33:10','2008-01-11 17:35:34','2008-01-11 17:35:34','d','d'), +(95,5,7,'0000-00-00','0000-00-00','09:20:10','09:20:10','2002-11-01 00:00:00','2002-11-01 00:00:00','q','q'), +(96,7,9,'2002-02-22','2002-02-22','11:19:10','11:19:10','2009-06-27 00:00:00','2009-06-27 00:00:00','j','j'), +(97,7,2,'2001-04-17','2001-04-17','08:08:41','08:08:41','2000-09-25 14:11:58','2000-09-25 14:11:58','j','j'), +(98,1,0,'2005-06-26','2005-06-26','10:17:36','10:17:36','2004-01-05 04:49:39','2004-01-05 04:49:39','e','e'), +(99,5,6,'2008-09-14','2008-09-14','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','f','f'), +(100,7,6,'0000-00-00','0000-00-00','01:05:02','01:05:02','2001-01-17 23:16:24','2001-01-17 23:16:24','a','a'), +(101,9,2,'2001-12-20','2001-12-20','00:00:00','00:00:00','1900-01-01 00:00:00','1900-01-01 00:00:00','o','o'), +(102,5,9,'2001-11-05','2001-11-05','00:00:00','00:00:00','2008-07-15 00:00:00','2008-07-15 00:00:00','y','y'), +(103,4,4,'1900-01-01','1900-01-01','15:32:04','15:32:04','2001-03-06 10:00:37','2001-03-06 10:00:37','d','d'), +(104,8,7,'2009-02-13','2009-02-13','20:25:36','20:25:36','2004-08-15 00:00:00','2004-08-15 00:00:00','z','z'), +(105,8,6,'2008-03-25','2008-03-25','21:33:53','21:33:53','2006-10-12 06:13:06','2006-10-12 06:13:06','s','s'); +analyze table t1; +analyze table t2; +EXPLAIN UPDATE t1 SET col_time_nokey = 25 +WHERE (col_varchar_key, col_varchar_nokey) IN ( +SELECT col_int_key, col_int_key +FROM t2 +WHERE (col_time_key, col_int_key, col_int_key) IN ( +(0, 'a', 'm'), (0, 'n', 7) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL col_varchar_key NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL index_merge col_int_key,col_time_key col_int_key,col_time_key 4,3 NULL 3 100.00 Using intersect(col_int_key,col_time_key); Using where; Using index; FirstMatch(t1) +UPDATE t1 SET col_time_nokey = 25 +WHERE (col_varchar_key, col_varchar_nokey) IN ( +SELECT col_int_key, col_int_key +FROM t2 +WHERE (col_time_key, col_int_key, col_int_key) IN ( +(0, 'a', 'm'), (0, 'n', 7) +) +); +DROP TABLE t1, t2; +SET sql_mode = default; +# +# Bug#11747423 32254: INDEX MERGE USED UNNECESSARILY +# +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +id2 INT NOT NULL, +id3 INT NOT NULL, +KEY (id2), +KEY (id3), +KEY covering_index (id2,id3) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), (7, 7, 7); +INSERT INTO t1 SELECT id + 8, id2 + 8, id3 +8 FROM t1; +INSERT INTO t1 SELECT id + 16, 7, 0 FROM t1; +EXPLAIN SELECT count(*) FROM t1 WHERE id2=7 AND id3=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref id2,id3,covering_index covering_index 8 const,const 16 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`id3` = 0) and (`test`.`t1`.`id2` = 7)) +DROP TABLE t1; +# +# Bug#21697002 ASSERTION `KEYS >= 0.0' FAILED +# +CREATE TABLE t1 ( +c1 VARCHAR(2), +d1 DATETIME NOT NULL +); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(2), +c2 VARCHAR(2), +PRIMARY KEY (pk), +KEY (c1), +KEY (c2) +) PARTITION BY KEY(pk) PARTITIONS 2; +SELECT c1 +FROM t1 +WHERE c1 IN +( +SELECT t2.c1 +FROM t2 +WHERE t2.c1 = 'f' + OR t2.c2 < 'y' +) +AND t1.d1 IS NULL; +c1 +DROP TABLE t1, t2; diff --git a/mysql-test/r/innodb_explain_json_non_select_all.result-pq b/mysql-test/r/innodb_explain_json_non_select_all.result-pq new file mode 100644 index 000000000..99294737a --- /dev/null +++ b/mysql-test/r/innodb_explain_json_non_select_all.result-pq @@ -0,0 +1,9486 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.10", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.10", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.30", + "prefix_cost": "1.30", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "2.45", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.45" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.30", + "prefix_cost": "1.30", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "2.45", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`a` < 3)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.25" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "96" + } /* cost_info */, + "used_columns": [ + "a1", + "b1", + "a2", + "b2", + "a3", + "b3" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.17" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.50", + "prefix_cost": "2.17", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.17" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.17" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.50", + "prefix_cost": "2.17", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "using_index": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.80", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_explain_json_non_select_none.result-pq b/mysql-test/r/innodb_explain_json_non_select_none.result-pq new file mode 100644 index 000000000..0f4a3613f --- /dev/null +++ b/mysql-test/r/innodb_explain_json_non_select_none.result-pq @@ -0,0 +1,9409 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */, + "optimized_away_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* optimized_away_subqueries */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.10" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.10", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.45", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.71" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.71" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.25" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "96" + } /* cost_info */, + "used_columns": [ + "a1", + "b1", + "a2", + "b2", + "a3", + "b3" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "2.65" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.65", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.55", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.58", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.75" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "1.70", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.74" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "69" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.56", + "eval_cost": "0.29", + "prefix_cost": "2.85", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.45" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.26", + "prefix_cost": "2.85", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.85" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.60", + "prefix_cost": "2.85", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "filtered": "X" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "backward_index_scan": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.91" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.71", + "eval_cost": "0.20", + "prefix_cost": "0.91", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3", + "c1", + "c2" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */, + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`c1` = `test`.`t1`.`c1`), true)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.35", + "eval_cost": "0.10", + "prefix_cost": "0.45", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.90", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "1.10", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "1.75", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": "X", + "filtered": "X", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "X" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": "X", + "rows_produced_per_join": "X", + "filtered": "X", + "using_index": true, + "cost_info": { + "read_cost": "X", + "eval_cost": "X", + "prefix_cost": "X", + "data_read_per_join": "X" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.05" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.05", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.55" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.70", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_explain_non_select_all.result-pq b/mysql-test/r/innodb_explain_non_select_all.result-pq new file mode 100644 index 000000000..8575f1a6d --- /dev/null +++ b/mysql-test/r/innodb_explain_non_select_all.result-pq @@ -0,0 +1,2605 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_explain_non_select_none.result-pq b/mysql-test/r/innodb_explain_non_select_none.result-pq new file mode 100644 index 000000000..da4617818 --- /dev/null +++ b/mysql-test/r/innodb_explain_non_select_none.result-pq @@ -0,0 +1,2602 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = InnoDB; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 7 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 5 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 2 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_first 1 +Handler_read_key 18 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_first 4 +Handler_read_key 6 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 6 +Handler_read_key 8 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 6 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL X 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 5 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL X 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL X 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 16936 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 10 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 5 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 6 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL X 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 13 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL X 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_last 1 +Handler_read_rnd_next 20 +# Status of testing query execution: +Variable_name Value +Handler_read_key 9 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_prev 1 +Handler_read_rnd 2 +Handler_update 2 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_prev 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 2 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_rnd_next 5 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c1` = `test`.`t1`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 7 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 3 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 3 +Handler_read_key 4 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_first 5 +Handler_read_key 8 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const X 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_first 1 +Handler_read_key 12 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_first 2 +Handler_read_key 7 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +3 DERIVED a11 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +3 DERIVED a21 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED a12 NULL eq_ref PRIMARY PRIMARY 4 test.a11.c1 1 100.00 Using index +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(`d1`.`c1`) from (/* select#3 */ select `test`.`a11`.`c1` AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where ((`test`.`a21`.`c2` = `test`.`a11`.`c1`) and (`test`.`a12`.`c1` = `test`.`a11`.`c1`))) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where (`test`.`t2`.`i` = `test`.`t1`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_icp.result-pq b/mysql-test/r/innodb_icp.result-pq new file mode 100644 index 000000000..9600a7f8a --- /dev/null +++ b/mysql-test/r/innodb_icp.result-pq @@ -0,0 +1,1130 @@ +set optimizer_switch='index_condition_pushdown=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +# Bug#36981 - "innodb crash when selecting for update" +# +CREATE TABLE t1 ( +c1 CHAR(1), +c2 CHAR(10), +KEY (c1) +); +INSERT INTO t1 VALUES ('3', null); +SELECT * FROM t1 WHERE c1='3' FOR UPDATE; +c1 c2 +3 NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT) charset latin1; +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT) charset latin1; +INSERT INTO t2 SELECT A.a + 10*(B.a + 10*C.a) FROM t1 A, t1 B, t1 C; +CREATE TABLE t3 ( +c1 CHAR(10) NOT NULL, +c2 CHAR(10) NOT NULL, +c3 CHAR(200) NOT NULL, +KEY (c1) +); +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',1000+ t2.a,'=w'), 'filler' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',2000+t2.a,'=w'), 'filler-1' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',3000+t2.a,'=w'), 'filler-2' + FROM t2; +SELECT c1,c3 FROM t3 WHERE c1 >= 'c-1994=w' and c1 != 'c-1996=w' FOR UPDATE; +c1 c3 +c-1994=w filler +c-1994=w filler-1 +c-1994=w filler-2 +c-1995=w filler +c-1995=w filler-1 +c-1995=w filler-2 +c-1997=w filler +c-1997=w filler-1 +c-1997=w filler-2 +c-1998=w filler +c-1998=w filler-1 +c-1998=w filler-2 +c-1999=w filler +c-1999=w filler-1 +c-1999=w filler-2 +DROP TABLE t1,t2,t3; +# +# Bug#43360 - Server crash with a simple multi-table update +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(20) NOT NULL, +KEY (b) +); +CREATE TABLE t2 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(30) NOT NULL, +KEY (b) +); +INSERT INTO t1 VALUES +('AB','MySQL AB'), +('JA','Sun Microsystems'), +('MS','Microsoft'), +('IB','IBM- Inc.'), +('GO','Google Inc.'); +INSERT INTO t2 VALUES +('AB','Sweden'), +('JA','USA'), +('MS','United States of America'), +('IB','North America'), +('GO','South America'); +UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'United%'; +SELECT * FROM t1 ORDER BY a; +a b +AB MySQL AB +GO Google Inc. +IB IBM- Inc. +JA Sun Microsystems +MS Microsoft +SELECT * FROM t2 ORDER BY a; +a b +AB Sweden +GO South America +IB North America +JA USA +MS United States of America +DROP TABLE t1,t2; +# +# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on +# +CREATE TABLE t ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +); +INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5); +SELECT * FROM t WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +DROP TABLE t; +# +# Bug#35080 - Innodb crash at mem_block_get_len line 72 +# +CREATE TABLE t1 ( +t1_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +PRIMARY KEY (t1_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +date DATETIME DEFAULT NULL, +PRIMARY KEY (t2_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW v1 AS +SELECT t1_autoinc, uuid +FROM t1 +WHERE (ISNULL(uuid) OR (uuid like '%-%')); +CREATE VIEW v2 AS +SELECT t2_autoinc, uuid, date +FROM t2 +WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36)); +CREATE PROCEDURE delete_multi (IN uuid CHAR(36)) +DELETE v1, v2 FROM v1 INNER JOIN v2 +ON v1.uuid = v2.uuid +WHERE v1.uuid = @uuid; +SET @uuid = UUID(); +INSERT INTO v1 (uuid) VALUES (@uuid); +INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09'); +CALL delete_multi(@uuid); +DROP procedure delete_multi; +DROP table t1,t2; +DROP view v1,v2; +# +# Bug#41996 - multi-table delete crashes server (InnoDB table) +# +CREATE TABLE t1 ( +b BIGINT, +i INT, +KEY (b) +); +INSERT INTO t1 VALUES (2, 2); +DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b; +DROP TABLE t1; +# +# Bug#43448 - Server crashes on multi table delete with Innodb +# +CREATE TABLE t1 ( +id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +t CHAR(12) +); +CREATE TABLE t2 ( +id2 INT NOT NULL, +t CHAR(12) +); +CREATE TABLE t3( +id3 INT NOT NULL, +t CHAR(12), +INDEX(id3) +); +CREATE PROCEDURE insert_data () +BEGIN +DECLARE i1 INT DEFAULT 20; +DECLARE i2 INT; +DECLARE i3 INT; +WHILE (i1 > 0) DO +INSERT INTO t1(t) VALUES (i1); +SET i2 = 2; +WHILE (i2 > 0) DO +INSERT INTO t2(id2, t) VALUES (i1, i2); +SET i3 = 2; +WHILE (i3 > 0) DO +INSERT INTO t3(id3, t) VALUES (i1, i2); +SET i3 = i3 -1; +END WHILE; +SET i2 = i2 -1; +END WHILE; +SET i1 = i1 - 1; +END WHILE; +END | +CALL insert_data(); +SELECT COUNT(*) FROM t1 WHERE id1 > 10; +COUNT(*) +10 +SELECT COUNT(*) FROM t2 WHERE id2 > 10; +COUNT(*) +20 +SELECT COUNT(*) FROM t3 WHERE id3 > 10; +COUNT(*) +40 +DELETE t1, t2, t3 +FROM t1, t2, t3 +WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3; +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SELECT COUNT(*) FROM t2; +COUNT(*) +6 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +DROP PROCEDURE insert_data; +DROP TABLE t1, t2, t3; +# +# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for +# null-safe operator <=> NULL +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 DATE NOT NULL, +c2 DATE NULL, +c3 DATETIME, +c4 TIMESTAMP, +PRIMARY KEY(c1), +UNIQUE(c2) +); + +INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05'); +INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26'); +INSERT INTO t1 VALUES('2008-01-01', NULL , '2008-01-02', '2008-01-03'); +INSERT INTO t1 VALUES('2008-01-17', NULL , NULL , '2009-01-29'); +INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43249 - Innodb returns zero time for the time column +# with <=> NULL order by limit +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIME NOT NULL, +c2 TIME NULL, +c3 DATE, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SET sql_mode = ''; +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b +SET sql_mode = default; + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Backward index scan + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +) charset utf8mb4; +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range c1 c1 30 NULL 2 33.33 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1` >= 'c-1004=w') and (`test`.`t3`.`c1` <= 'c-1006=w') and (`test`.`t3`.`i1` > 2)) +EXPLAIN FORMAT=tree SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +EXPLAIN +-> Filter: ((t3.c1 >= 'c-1004=w') and (t3.c1 <= 'c-1006=w')) (cost=1.16 rows=1) + -> Index range scan on t3 using c1, with index condition: (t3.i1 > 2) (cost=1.16 rows=2) + +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +DROP TABLE t1, t2, t3; +# +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +) ENGINE = INNODB; +CREATE TABLE t2 ( +a INT KEY, +b INT +) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 37.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 5 NULL 4 37.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`pk` between 4 and 5) or (`test`.`t1`.`pk` < 2)) and (`test`.`t1`.`c1` < 240)) order by `test`.`t1`.`c1` limit 1 +DROP TABLE t1; +# +# Bug#42991 "invalid memory access and/or crash when using +# index condition pushdown + InnoDB" +# +CREATE TABLE t1 ( +c1 TINYTEXT NOT NULL, +c2 INT NOT NULL, +PRIMARY KEY (c2), +KEY id1 (c1(4)) +) charset utf8mb4; +INSERT INTO t1 VALUES ('Anastasia', 5); +INSERT INTO t1 VALUES ('Karianne', 4); +SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +c1 c2 +EXPLAIN SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,id1 id1 18 NULL 1 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where ((`test`.`t1`.`c1` <= '6566-06-15') and (`test`.`t1`.`c2` <> 3)) +DROP TABLE t1; +# +# Bug#56529 - "Crash due to long semaphore wait in InnoDB +# with ICP and subqueries" +# +CREATE TABLE t1 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +) charset utf8mb4 stats_persistent=0; +INSERT INTO t1 VALUES (NULL,2,'w'); +INSERT INTO t1 VALUES (7,9,'m'); +INSERT INTO t1 VALUES (9,3,'m'); +INSERT INTO t1 VALUES (7,9,'k'); +INSERT INTO t1 VALUES (4,NULL,'r'); +INSERT INTO t1 VALUES (2,9,'t'); +INSERT INTO t1 VALUES (6,3,'j'); +INSERT INTO t1 VALUES (8,8,'u'); +INSERT INTO t1 VALUES (NULL,8,'h'); +INSERT INTO t1 VALUES (5,53,'o'); +INSERT INTO t1 VALUES (NULL,0,NULL); +INSERT INTO t1 VALUES (6,5,'k'); +INSERT INTO t1 VALUES (188,166,'e'); +INSERT INTO t1 VALUES (2,3,'n'); +INSERT INTO t1 VALUES (1,0,'t'); +INSERT INTO t1 VALUES (1,1,'c'); +INSERT INTO t1 VALUES (0,9,'m'); +INSERT INTO t1 VALUES (9,5,'y'); +INSERT INTO t1 VALUES (NULL,6,'f'); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +) stats_persistent=0; +EXPLAIN SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL col_int_key NULL NULL NULL 19 100.00 NULL +1 PRIMARY table3 NULL ALL col_varchar_key NULL NULL NULL 19 10.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ref col_varchar_key col_varchar_key 7 test.table3.col_varchar_key 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table2`.`col_varchar_key` = `test`.`table3`.`col_varchar_key`) and (`test`.`table3`.`col_int_nokey` = `test`.`table1`.`col_int_key`) and ((`test`.`table3`.`col_int_key`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` where (outer_field_is_not_null, ((`test`.`table3`.`col_int_key`) <> `test`.`t2`.`c1`), true))))) +SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +col_int_nokey +DROP TABLE t1, t2; +# +# Bug#58243 "RQG test optimizer_subquery causes server crash +# when running with ICP" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +c2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,6,7); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +); +EXPLAIN SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false order by `test`.`t1`.`c2` +SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +c1 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t1 VALUES (2,'w'); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +c2 VARCHAR(1) NOT NULL, +KEY (c1, i1) +) charset latin1; +INSERT INTO t2 VALUES (8,'d','d'); +INSERT INTO t2 VALUES (4,'v','v'); +CREATE TABLE t3 ( +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t3 VALUES ('v'); +EXPLAIN SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref c1 c1 3 test.t3.c1 1 50.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.c1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where exists(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`))) +SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +i1 +2 +DROP TABLE t1,t2,t3; +# +# Bug#58015 "Assert in row_sel_field_store_in_mysql_format +# when running innodb_mrr_icp test" +# +create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('',1); +select 1 from t1 where b <= 1 and a <> ''; +1 +drop table t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i); +pk i +12 5 +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch_bug58816= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`pk` <> 3) +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch_bug58816; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT IGNORE INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_int' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1a`.`t1_int` AS `t1_int`,`test`.`t1a`.`t1_time` AS `t1_time` from `test`.`t1` `t1a` where false + +DROP TABLE t1,t2; +# +# Bug#59186 Wrong results of join when ICP is enabled +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c2` AS `c2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c1` = `test`.`t1`.`c1`) and (((`test`.`t2`.`pk` <= 4) and (`test`.`t1`.`pk` in (2,1))) or ((`test`.`t1`.`pk` > 1) and (`test`.`t2`.`pk` between 6 and 6)))) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT IGNORE INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t1 VALUES (14,NULL), (18,133); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER, +c1 VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t2 VALUES (1,7,'f'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY subquery_t1 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY subquery_t2 NULL ref col_int_key col_int_key 5 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1`,(/* select#2 */ select straight_join `test`.`subquery_t1`.`pk` from `test`.`t1` `subquery_t1` join `test`.`t2` `subquery_t2` where ((`test`.`subquery_t2`.`i1` = `test`.`subquery_t1`.`pk`) and ((`test`.`subquery_t1`.`i1` > 0) or (`test`.`subquery_t2`.`c1` = 'a')) and (outer_field_is_not_null, ((`test`.`t1`.`i1`) = `test`.`subquery_t1`.`pk`), true))) is false) +SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +i1 +NULL +133 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + +# NULL VALUES AND ICP ENABLED" +# +CREATE TABLE t1 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'), +(5,'m'), (NULL,'c'); +CREATE TABLE t2 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES (8,NULL); +CREATE TABLE t3 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t1 NULL ref_or_null col_varchar_key col_varchar_key 7 func 2 33.33 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`i1` AS `i1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` > `test`.`t2`.`c1`) and (outer_field_is_not_null, (((`test`.`t3`.`c1`) = `test`.`t1`.`c1`) or (`test`.`t1`.`c1` is null)), true) and (`test`.`t2`.`i1` >= `test`.`t1`.`i1`)) having (outer_field_is_not_null, (`test`.`t1`.`c1`), true))) xor (0 <> `test`.`t3`.`i1`)) +SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +i1 +1 +2 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +# +# Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1" +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER NOT NULL, +b CHAR(1), +KEY(b) +) charset utf8mb4; +INSERT INTO t1 VALUES (23,5,'d'); +EXPLAIN SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY a1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a1`.`pk` AS `pk` from `test`.`t1` `a1` where ((`test`.`a1`.`b` = 'd') and (`test`.`a1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and (((/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1) <> '5') or (`test`.`a1`.`b` is null))) +SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`b` = 'd') and (`test`.`t1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and ((`test`.`t1`.`a` <> '5') or (`test`.`t1`.`b` is null))) +SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2" +# BUG#12724899 "SELECT STRAIGHT_JOIN QUERY GIVES 2 DATES VERSUS +# 2 WARNINGS WITH ICP ON" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,3,'j'), (20,8,'e'); +EXPLAIN SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE alias2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias2`.`i1` AS `i1` from `test`.`t1` `alias1` straight_join `test`.`t1` `alias2` where ((`test`.`alias2`.`pk` = 1) and (cast(`test`.`alias2`.`pk` as double) <= cast(`test`.`alias1`.`c1` as double))) +SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +i1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +DROP TABLE t1; +# +# BUG#12822678 - 2 MORE ROWS WHEN ICP=ON W/ STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 9 NULL 3 100.00 Using index +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d1` AS `d1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`pk` = 4) and (`test`.`t2`.`pk` <> `test`.`t1`.`d1`) and (0 <> `test`.`t2`.`i1`)) +SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# +# BUG#12838420 "DUPLICATE VALUES FOR GROUP-BY COLUMN WHEN JOIN +# BUFFERING IS OFF" +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t1 VALUES (2,3),(3,2),(3,5),(4,6); +CREATE TABLE t2 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t2 VALUES (0,9),(3,10),(4,6),(6,1),(100,3),(200,5); +set @old_opt_switch=@@optimizer_switch; +SET optimizer_switch="block_nested_loop=off"; +EXPLAIN SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_int_key col_int_key 5 NULL 6 33.33 Using where; Using index +2 SIMPLE t1 NULL index NULL col_int_key 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_key` AS `field1` from `test`.`t2` USE INDEX (`col_int_key`) straight_join `test`.`t1` where ((`test`.`t2`.`pk` < 7) and (`test`.`t2`.`col_int_key` <> 7) and (0 <> `test`.`t2`.`col_int_key`)) group by `field1` +SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +field1 +4 +6 +100 +200 +SET @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#12976163 "CRASH IN INDEX CONDITION PUSHDOWN CODE AGAINST +# A MYISAM TABLE" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (14,1), (15,2), (16,3); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +c1 TINYTEXT +); +INSERT INTO t2 +SELECT i1, 10 * i2, "MySQL" FROM t1; +CREATE PROCEDURE proc1(id INTEGER) +BEGIN +SELECT i2 +FROM ( +(SELECT i1, i2, NULL AS a1 FROM t1) +UNION +(SELECT i1, i2, c1 AS a1 FROM t2) +) u1 +WHERE i1 = id; +END$$ +CALL proc1(15); +i2 +2 +20 +DROP PROCEDURE proc1; +DROP TABLE t1, t2; +# +# Bug#13655397 "CRASH IN SYNC_THREAD_LEVELS_NONEMPTY_TRX" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i1) +); +INSERT INTO t1 VALUES (4,4), (5,5); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE FUNCTION f1() RETURNS INTEGER +RETURN (SELECT MOD(COUNT(DISTINCT pk), 10) FROM t2); +EXPLAIN SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` where ((`test`.`t1`.`i1` = 5) and (`f1`() = 1)) +SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +i1 i2 +5 5 +DROP FUNCTION f1; +DROP TABLE t1, t2; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_icp_all.result-pq b/mysql-test/r/innodb_icp_all.result-pq new file mode 100644 index 000000000..491744a32 --- /dev/null +++ b/mysql-test/r/innodb_icp_all.result-pq @@ -0,0 +1,1130 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +# Bug#36981 - "innodb crash when selecting for update" +# +CREATE TABLE t1 ( +c1 CHAR(1), +c2 CHAR(10), +KEY (c1) +); +INSERT INTO t1 VALUES ('3', null); +SELECT * FROM t1 WHERE c1='3' FOR UPDATE; +c1 c2 +3 NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT) charset latin1; +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT) charset latin1; +INSERT INTO t2 SELECT A.a + 10*(B.a + 10*C.a) FROM t1 A, t1 B, t1 C; +CREATE TABLE t3 ( +c1 CHAR(10) NOT NULL, +c2 CHAR(10) NOT NULL, +c3 CHAR(200) NOT NULL, +KEY (c1) +); +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',1000+ t2.a,'=w'), 'filler' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',2000+t2.a,'=w'), 'filler-1' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',3000+t2.a,'=w'), 'filler-2' + FROM t2; +SELECT c1,c3 FROM t3 WHERE c1 >= 'c-1994=w' and c1 != 'c-1996=w' FOR UPDATE; +c1 c3 +c-1994=w filler +c-1994=w filler-1 +c-1994=w filler-2 +c-1995=w filler +c-1995=w filler-1 +c-1995=w filler-2 +c-1997=w filler +c-1997=w filler-1 +c-1997=w filler-2 +c-1998=w filler +c-1998=w filler-1 +c-1998=w filler-2 +c-1999=w filler +c-1999=w filler-1 +c-1999=w filler-2 +DROP TABLE t1,t2,t3; +# +# Bug#43360 - Server crash with a simple multi-table update +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(20) NOT NULL, +KEY (b) +); +CREATE TABLE t2 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(30) NOT NULL, +KEY (b) +); +INSERT INTO t1 VALUES +('AB','MySQL AB'), +('JA','Sun Microsystems'), +('MS','Microsoft'), +('IB','IBM- Inc.'), +('GO','Google Inc.'); +INSERT INTO t2 VALUES +('AB','Sweden'), +('JA','USA'), +('MS','United States of America'), +('IB','North America'), +('GO','South America'); +UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'United%'; +SELECT * FROM t1 ORDER BY a; +a b +AB MySQL AB +GO Google Inc. +IB IBM- Inc. +JA Sun Microsystems +MS Microsoft +SELECT * FROM t2 ORDER BY a; +a b +AB Sweden +GO South America +IB North America +JA USA +MS United States of America +DROP TABLE t1,t2; +# +# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on +# +CREATE TABLE t ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +); +INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5); +SELECT * FROM t WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +DROP TABLE t; +# +# Bug#35080 - Innodb crash at mem_block_get_len line 72 +# +CREATE TABLE t1 ( +t1_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +PRIMARY KEY (t1_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +date DATETIME DEFAULT NULL, +PRIMARY KEY (t2_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW v1 AS +SELECT t1_autoinc, uuid +FROM t1 +WHERE (ISNULL(uuid) OR (uuid like '%-%')); +CREATE VIEW v2 AS +SELECT t2_autoinc, uuid, date +FROM t2 +WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36)); +CREATE PROCEDURE delete_multi (IN uuid CHAR(36)) +DELETE v1, v2 FROM v1 INNER JOIN v2 +ON v1.uuid = v2.uuid +WHERE v1.uuid = @uuid; +SET @uuid = UUID(); +INSERT INTO v1 (uuid) VALUES (@uuid); +INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09'); +CALL delete_multi(@uuid); +DROP procedure delete_multi; +DROP table t1,t2; +DROP view v1,v2; +# +# Bug#41996 - multi-table delete crashes server (InnoDB table) +# +CREATE TABLE t1 ( +b BIGINT, +i INT, +KEY (b) +); +INSERT INTO t1 VALUES (2, 2); +DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b; +DROP TABLE t1; +# +# Bug#43448 - Server crashes on multi table delete with Innodb +# +CREATE TABLE t1 ( +id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +t CHAR(12) +); +CREATE TABLE t2 ( +id2 INT NOT NULL, +t CHAR(12) +); +CREATE TABLE t3( +id3 INT NOT NULL, +t CHAR(12), +INDEX(id3) +); +CREATE PROCEDURE insert_data () +BEGIN +DECLARE i1 INT DEFAULT 20; +DECLARE i2 INT; +DECLARE i3 INT; +WHILE (i1 > 0) DO +INSERT INTO t1(t) VALUES (i1); +SET i2 = 2; +WHILE (i2 > 0) DO +INSERT INTO t2(id2, t) VALUES (i1, i2); +SET i3 = 2; +WHILE (i3 > 0) DO +INSERT INTO t3(id3, t) VALUES (i1, i2); +SET i3 = i3 -1; +END WHILE; +SET i2 = i2 -1; +END WHILE; +SET i1 = i1 - 1; +END WHILE; +END | +CALL insert_data(); +SELECT COUNT(*) FROM t1 WHERE id1 > 10; +COUNT(*) +10 +SELECT COUNT(*) FROM t2 WHERE id2 > 10; +COUNT(*) +20 +SELECT COUNT(*) FROM t3 WHERE id3 > 10; +COUNT(*) +40 +DELETE t1, t2, t3 +FROM t1, t2, t3 +WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3; +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SELECT COUNT(*) FROM t2; +COUNT(*) +6 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +DROP PROCEDURE insert_data; +DROP TABLE t1, t2, t3; +# +# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for +# null-safe operator <=> NULL +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 DATE NOT NULL, +c2 DATE NULL, +c3 DATETIME, +c4 TIMESTAMP, +PRIMARY KEY(c1), +UNIQUE(c2) +); + +INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05'); +INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26'); +INSERT INTO t1 VALUES('2008-01-01', NULL , '2008-01-02', '2008-01-03'); +INSERT INTO t1 VALUES('2008-01-17', NULL , NULL , '2009-01-29'); +INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43249 - Innodb returns zero time for the time column +# with <=> NULL order by limit +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIME NOT NULL, +c2 TIME NULL, +c3 DATE, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SET sql_mode = ''; +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b +SET sql_mode = default; + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Backward index scan + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +) charset utf8mb4; +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range c1 c1 30 NULL 2 33.33 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1` >= 'c-1004=w') and (`test`.`t3`.`c1` <= 'c-1006=w') and (`test`.`t3`.`i1` > 2)) +EXPLAIN FORMAT=tree SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +EXPLAIN +-> Filter: ((t3.c1 >= 'c-1004=w') and (t3.c1 <= 'c-1006=w')) (cost=1.16 rows=1) + -> Index range scan on t3 using c1, with index condition: (t3.i1 > 2) (cost=1.16 rows=2) + +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +DROP TABLE t1, t2, t3; +# +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +) ENGINE = INNODB; +CREATE TABLE t2 ( +a INT KEY, +b INT +) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 37.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 5 NULL 4 37.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`pk` between 4 and 5) or (`test`.`t1`.`pk` < 2)) and (`test`.`t1`.`c1` < 240)) order by `test`.`t1`.`c1` limit 1 +DROP TABLE t1; +# +# Bug#42991 "invalid memory access and/or crash when using +# index condition pushdown + InnoDB" +# +CREATE TABLE t1 ( +c1 TINYTEXT NOT NULL, +c2 INT NOT NULL, +PRIMARY KEY (c2), +KEY id1 (c1(4)) +) charset utf8mb4; +INSERT INTO t1 VALUES ('Anastasia', 5); +INSERT INTO t1 VALUES ('Karianne', 4); +SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +c1 c2 +EXPLAIN SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,id1 id1 18 NULL 1 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where ((`test`.`t1`.`c1` <= '6566-06-15') and (`test`.`t1`.`c2` <> 3)) +DROP TABLE t1; +# +# Bug#56529 - "Crash due to long semaphore wait in InnoDB +# with ICP and subqueries" +# +CREATE TABLE t1 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +) charset utf8mb4 stats_persistent=0; +INSERT INTO t1 VALUES (NULL,2,'w'); +INSERT INTO t1 VALUES (7,9,'m'); +INSERT INTO t1 VALUES (9,3,'m'); +INSERT INTO t1 VALUES (7,9,'k'); +INSERT INTO t1 VALUES (4,NULL,'r'); +INSERT INTO t1 VALUES (2,9,'t'); +INSERT INTO t1 VALUES (6,3,'j'); +INSERT INTO t1 VALUES (8,8,'u'); +INSERT INTO t1 VALUES (NULL,8,'h'); +INSERT INTO t1 VALUES (5,53,'o'); +INSERT INTO t1 VALUES (NULL,0,NULL); +INSERT INTO t1 VALUES (6,5,'k'); +INSERT INTO t1 VALUES (188,166,'e'); +INSERT INTO t1 VALUES (2,3,'n'); +INSERT INTO t1 VALUES (1,0,'t'); +INSERT INTO t1 VALUES (1,1,'c'); +INSERT INTO t1 VALUES (0,9,'m'); +INSERT INTO t1 VALUES (9,5,'y'); +INSERT INTO t1 VALUES (NULL,6,'f'); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +) stats_persistent=0; +EXPLAIN SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL col_int_key NULL NULL NULL 19 100.00 NULL +1 PRIMARY table3 NULL ALL col_varchar_key NULL NULL NULL 19 10.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ref col_varchar_key col_varchar_key 7 test.table3.col_varchar_key 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table2`.`col_varchar_key` = `test`.`table3`.`col_varchar_key`) and (`test`.`table3`.`col_int_nokey` = `test`.`table1`.`col_int_key`) and ((`test`.`table3`.`col_int_key`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` where (outer_field_is_not_null, ((`test`.`table3`.`col_int_key`) <> `test`.`t2`.`c1`), true))))) +SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +col_int_nokey +DROP TABLE t1, t2; +# +# Bug#58243 "RQG test optimizer_subquery causes server crash +# when running with ICP" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +c2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,6,7); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +); +EXPLAIN SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false order by `test`.`t1`.`c2` +SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +c1 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t1 VALUES (2,'w'); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +c2 VARCHAR(1) NOT NULL, +KEY (c1, i1) +) charset latin1; +INSERT INTO t2 VALUES (8,'d','d'); +INSERT INTO t2 VALUES (4,'v','v'); +CREATE TABLE t3 ( +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t3 VALUES ('v'); +EXPLAIN SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t2 NULL ref c1 c1 3 test.t3.c1 1 50.00 Using where; FirstMatch(t1) +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.c1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`)) +SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +i1 +2 +DROP TABLE t1,t2,t3; +# +# Bug#58015 "Assert in row_sel_field_store_in_mysql_format +# when running innodb_mrr_icp test" +# +create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('',1); +select 1 from t1 where b <= 1 and a <> ''; +1 +drop table t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i); +pk i +12 5 +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch_bug58816= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`pk` <> 3) +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch_bug58816; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT IGNORE INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_int' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1a`.`t1_int` AS `t1_int`,`test`.`t1a`.`t1_time` AS `t1_time` from `test`.`t1` `t1a` where false + +DROP TABLE t1,t2; +# +# Bug#59186 Wrong results of join when ICP is enabled +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c2` AS `c2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c1` = `test`.`t1`.`c1`) and (((`test`.`t2`.`pk` <= 4) and (`test`.`t1`.`pk` in (2,1))) or ((`test`.`t1`.`pk` > 1) and (`test`.`t2`.`pk` between 6 and 6)))) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT IGNORE INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t1 VALUES (14,NULL), (18,133); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER, +c1 VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t2 VALUES (1,7,'f'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY subquery_t1 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY subquery_t2 NULL ref col_int_key col_int_key 5 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1`,(/* select#2 */ select straight_join `test`.`subquery_t1`.`pk` from `test`.`t1` `subquery_t1` join `test`.`t2` `subquery_t2` where ((`test`.`subquery_t2`.`i1` = `test`.`subquery_t1`.`pk`) and ((`test`.`subquery_t1`.`i1` > 0) or (`test`.`subquery_t2`.`c1` = 'a')) and (outer_field_is_not_null, ((`test`.`t1`.`i1`) = `test`.`subquery_t1`.`pk`), true))) is false) +SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +i1 +NULL +133 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + +# NULL VALUES AND ICP ENABLED" +# +CREATE TABLE t1 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'), +(5,'m'), (NULL,'c'); +CREATE TABLE t2 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES (8,NULL); +CREATE TABLE t3 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t1 NULL ref_or_null col_varchar_key col_varchar_key 7 func 2 33.33 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`i1` AS `i1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` > `test`.`t2`.`c1`) and (outer_field_is_not_null, (((`test`.`t3`.`c1`) = `test`.`t1`.`c1`) or (`test`.`t1`.`c1` is null)), true) and (`test`.`t2`.`i1` >= `test`.`t1`.`i1`)) having (outer_field_is_not_null, (`test`.`t1`.`c1`), true))) xor (0 <> `test`.`t3`.`i1`)) +SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +i1 +1 +2 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +# +# Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1" +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER NOT NULL, +b CHAR(1), +KEY(b) +) charset utf8mb4; +INSERT INTO t1 VALUES (23,5,'d'); +EXPLAIN SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY a1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a1`.`pk` AS `pk` from `test`.`t1` `a1` where ((`test`.`a1`.`b` = 'd') and (`test`.`a1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and (((/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1) <> '5') or (`test`.`a1`.`b` is null))) +SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`b` = 'd') and (`test`.`t1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and ((`test`.`t1`.`a` <> '5') or (`test`.`t1`.`b` is null))) +SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2" +# BUG#12724899 "SELECT STRAIGHT_JOIN QUERY GIVES 2 DATES VERSUS +# 2 WARNINGS WITH ICP ON" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,3,'j'), (20,8,'e'); +EXPLAIN SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE alias2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias2`.`i1` AS `i1` from `test`.`t1` `alias1` straight_join `test`.`t1` `alias2` where ((`test`.`alias2`.`pk` = 1) and (cast(`test`.`alias2`.`pk` as double) <= cast(`test`.`alias1`.`c1` as double))) +SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +i1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +DROP TABLE t1; +# +# BUG#12822678 - 2 MORE ROWS WHEN ICP=ON W/ STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 9 NULL 3 100.00 Using index +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d1` AS `d1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`pk` = 4) and (`test`.`t2`.`pk` <> `test`.`t1`.`d1`) and (0 <> `test`.`t2`.`i1`)) +SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# +# BUG#12838420 "DUPLICATE VALUES FOR GROUP-BY COLUMN WHEN JOIN +# BUFFERING IS OFF" +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t1 VALUES (2,3),(3,2),(3,5),(4,6); +CREATE TABLE t2 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t2 VALUES (0,9),(3,10),(4,6),(6,1),(100,3),(200,5); +set @old_opt_switch=@@optimizer_switch; +SET optimizer_switch="block_nested_loop=off"; +EXPLAIN SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_int_key col_int_key 5 NULL 6 33.33 Using where; Using index +2 SIMPLE t1 NULL index NULL col_int_key 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_key` AS `field1` from `test`.`t2` USE INDEX (`col_int_key`) straight_join `test`.`t1` where ((`test`.`t2`.`pk` < 7) and (`test`.`t2`.`col_int_key` <> 7) and (0 <> `test`.`t2`.`col_int_key`)) group by `field1` +SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +field1 +4 +6 +100 +200 +SET @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#12976163 "CRASH IN INDEX CONDITION PUSHDOWN CODE AGAINST +# A MYISAM TABLE" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (14,1), (15,2), (16,3); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +c1 TINYTEXT +); +INSERT INTO t2 +SELECT i1, 10 * i2, "MySQL" FROM t1; +CREATE PROCEDURE proc1(id INTEGER) +BEGIN +SELECT i2 +FROM ( +(SELECT i1, i2, NULL AS a1 FROM t1) +UNION +(SELECT i1, i2, c1 AS a1 FROM t2) +) u1 +WHERE i1 = id; +END$$ +CALL proc1(15); +i2 +2 +20 +DROP PROCEDURE proc1; +DROP TABLE t1, t2; +# +# Bug#13655397 "CRASH IN SYNC_THREAD_LEVELS_NONEMPTY_TRX" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i1) +); +INSERT INTO t1 VALUES (4,4), (5,5); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE FUNCTION f1() RETURNS INTEGER +RETURN (SELECT MOD(COUNT(DISTINCT pk), 10) FROM t2); +EXPLAIN SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` where ((`test`.`t1`.`i1` = 5) and (`f1`() = 1)) +SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +i1 i2 +5 5 +DROP FUNCTION f1; +DROP TABLE t1, t2; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_icp_none.result-pq b/mysql-test/r/innodb_icp_none.result-pq new file mode 100644 index 000000000..cdf1d558d --- /dev/null +++ b/mysql-test/r/innodb_icp_none.result-pq @@ -0,0 +1,1129 @@ +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +# Bug#36981 - "innodb crash when selecting for update" +# +CREATE TABLE t1 ( +c1 CHAR(1), +c2 CHAR(10), +KEY (c1) +); +INSERT INTO t1 VALUES ('3', null); +SELECT * FROM t1 WHERE c1='3' FOR UPDATE; +c1 c2 +3 NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT) charset latin1; +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT) charset latin1; +INSERT INTO t2 SELECT A.a + 10*(B.a + 10*C.a) FROM t1 A, t1 B, t1 C; +CREATE TABLE t3 ( +c1 CHAR(10) NOT NULL, +c2 CHAR(10) NOT NULL, +c3 CHAR(200) NOT NULL, +KEY (c1) +); +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',1000+ t2.a,'=w'), 'filler' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',2000+t2.a,'=w'), 'filler-1' + FROM t2; +INSERT INTO t3 +SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',3000+t2.a,'=w'), 'filler-2' + FROM t2; +SELECT c1,c3 FROM t3 WHERE c1 >= 'c-1994=w' and c1 != 'c-1996=w' FOR UPDATE; +c1 c3 +c-1994=w filler +c-1994=w filler-1 +c-1994=w filler-2 +c-1995=w filler +c-1995=w filler-1 +c-1995=w filler-2 +c-1997=w filler +c-1997=w filler-1 +c-1997=w filler-2 +c-1998=w filler +c-1998=w filler-1 +c-1998=w filler-2 +c-1999=w filler +c-1999=w filler-1 +c-1999=w filler-2 +DROP TABLE t1,t2,t3; +# +# Bug#43360 - Server crash with a simple multi-table update +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(20) NOT NULL, +KEY (b) +); +CREATE TABLE t2 ( +a CHAR(2) NOT NULL PRIMARY KEY, +b VARCHAR(30) NOT NULL, +KEY (b) +); +INSERT INTO t1 VALUES +('AB','MySQL AB'), +('JA','Sun Microsystems'), +('MS','Microsoft'), +('IB','IBM- Inc.'), +('GO','Google Inc.'); +INSERT INTO t2 VALUES +('AB','Sweden'), +('JA','USA'), +('MS','United States of America'), +('IB','North America'), +('GO','South America'); +UPDATE t1,t2 SET t1.b=UPPER(t1.b) WHERE t1.b LIKE 'United%'; +SELECT * FROM t1 ORDER BY a; +a b +AB MySQL AB +GO Google Inc. +IB IBM- Inc. +JA Sun Microsystems +MS Microsoft +SELECT * FROM t2 ORDER BY a; +a b +AB Sweden +GO South America +IB North America +JA USA +MS United States of America +DROP TABLE t1,t2; +# +# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on +# +CREATE TABLE t ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +); +INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5); +SELECT * FROM t WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +DROP TABLE t; +# +# Bug#35080 - Innodb crash at mem_block_get_len line 72 +# +CREATE TABLE t1 ( +t1_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +PRIMARY KEY (t1_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_autoinc INT(11) NOT NULL AUTO_INCREMENT, +uuid VARCHAR(36) DEFAULT NULL, +date DATETIME DEFAULT NULL, +PRIMARY KEY (t2_autoinc), +KEY k (uuid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE VIEW v1 AS +SELECT t1_autoinc, uuid +FROM t1 +WHERE (ISNULL(uuid) OR (uuid like '%-%')); +CREATE VIEW v2 AS +SELECT t2_autoinc, uuid, date +FROM t2 +WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36)); +CREATE PROCEDURE delete_multi (IN uuid CHAR(36)) +DELETE v1, v2 FROM v1 INNER JOIN v2 +ON v1.uuid = v2.uuid +WHERE v1.uuid = @uuid; +SET @uuid = UUID(); +INSERT INTO v1 (uuid) VALUES (@uuid); +INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09'); +CALL delete_multi(@uuid); +DROP procedure delete_multi; +DROP table t1,t2; +DROP view v1,v2; +# +# Bug#41996 - multi-table delete crashes server (InnoDB table) +# +CREATE TABLE t1 ( +b BIGINT, +i INT, +KEY (b) +); +INSERT INTO t1 VALUES (2, 2); +DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b; +DROP TABLE t1; +# +# Bug#43448 - Server crashes on multi table delete with Innodb +# +CREATE TABLE t1 ( +id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +t CHAR(12) +); +CREATE TABLE t2 ( +id2 INT NOT NULL, +t CHAR(12) +); +CREATE TABLE t3( +id3 INT NOT NULL, +t CHAR(12), +INDEX(id3) +); +CREATE PROCEDURE insert_data () +BEGIN +DECLARE i1 INT DEFAULT 20; +DECLARE i2 INT; +DECLARE i3 INT; +WHILE (i1 > 0) DO +INSERT INTO t1(t) VALUES (i1); +SET i2 = 2; +WHILE (i2 > 0) DO +INSERT INTO t2(id2, t) VALUES (i1, i2); +SET i3 = 2; +WHILE (i3 > 0) DO +INSERT INTO t3(id3, t) VALUES (i1, i2); +SET i3 = i3 -1; +END WHILE; +SET i2 = i2 -1; +END WHILE; +SET i1 = i1 - 1; +END WHILE; +END | +CALL insert_data(); +SELECT COUNT(*) FROM t1 WHERE id1 > 10; +COUNT(*) +10 +SELECT COUNT(*) FROM t2 WHERE id2 > 10; +COUNT(*) +20 +SELECT COUNT(*) FROM t3 WHERE id3 > 10; +COUNT(*) +40 +DELETE t1, t2, t3 +FROM t1, t2, t3 +WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3; +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SELECT COUNT(*) FROM t2; +COUNT(*) +6 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +DROP PROCEDURE insert_data; +DROP TABLE t1, t2, t3; +# +# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for +# null-safe operator <=> NULL +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 DATE NOT NULL, +c2 DATE NULL, +c3 DATETIME, +c4 TIMESTAMP, +PRIMARY KEY(c1), +UNIQUE(c2) +); + +INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05'); +INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26'); +INSERT INTO t1 VALUES('2008-01-01', NULL , '2008-01-02', '2008-01-03'); +INSERT INTO t1 VALUES('2008-01-17', NULL , NULL , '2009-01-29'); +INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2; +c1 c2 c3 c4 +2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00 +2008-01-17 NULL NULL 2009-01-29 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#43249 - Innodb returns zero time for the time column +# with <=> NULL order by limit +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIME NOT NULL, +c2 TIME NULL, +c3 DATE, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 + +SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2; +c1 c2 c3 +08:29:45 NULL 2009-02-01 +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SET sql_mode = ''; +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b +SET sql_mode = default; + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Backward index scan + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +) charset utf8mb4; +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range c1 c1 30 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1` >= 'c-1004=w') and (`test`.`t3`.`c1` <= 'c-1006=w') and (`test`.`t3`.`i1` > 2)) +EXPLAIN FORMAT=tree SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +EXPLAIN +-> Filter: ((t3.c1 >= 'c-1004=w') and (t3.c1 <= 'c-1006=w') and (t3.i1 > 2)) (cost=1.16 rows=1) + -> Index range scan on t3 using c1 (cost=1.16 rows=2) + +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +DROP TABLE t1, t2, t3; +# +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +) ENGINE = INNODB; +CREATE TABLE t2 ( +a INT KEY, +b INT +) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 37.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 5 NULL 4 37.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`pk` between 4 and 5) or (`test`.`t1`.`pk` < 2)) and (`test`.`t1`.`c1` < 240)) order by `test`.`t1`.`c1` limit 1 +DROP TABLE t1; +# +# Bug#42991 "invalid memory access and/or crash when using +# index condition pushdown + InnoDB" +# +CREATE TABLE t1 ( +c1 TINYTEXT NOT NULL, +c2 INT NOT NULL, +PRIMARY KEY (c2), +KEY id1 (c1(4)) +) charset utf8mb4; +INSERT INTO t1 VALUES ('Anastasia', 5); +INSERT INTO t1 VALUES ('Karianne', 4); +SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +c1 c2 +EXPLAIN SELECT * FROM t1 WHERE (c1 <= '6566-06-15' AND c2 <> 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,id1 id1 18 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where ((`test`.`t1`.`c1` <= '6566-06-15') and (`test`.`t1`.`c2` <> 3)) +DROP TABLE t1; +# +# Bug#56529 - "Crash due to long semaphore wait in InnoDB +# with ICP and subqueries" +# +CREATE TABLE t1 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +) charset utf8mb4 stats_persistent=0; +INSERT INTO t1 VALUES (NULL,2,'w'); +INSERT INTO t1 VALUES (7,9,'m'); +INSERT INTO t1 VALUES (9,3,'m'); +INSERT INTO t1 VALUES (7,9,'k'); +INSERT INTO t1 VALUES (4,NULL,'r'); +INSERT INTO t1 VALUES (2,9,'t'); +INSERT INTO t1 VALUES (6,3,'j'); +INSERT INTO t1 VALUES (8,8,'u'); +INSERT INTO t1 VALUES (NULL,8,'h'); +INSERT INTO t1 VALUES (5,53,'o'); +INSERT INTO t1 VALUES (NULL,0,NULL); +INSERT INTO t1 VALUES (6,5,'k'); +INSERT INTO t1 VALUES (188,166,'e'); +INSERT INTO t1 VALUES (2,3,'n'); +INSERT INTO t1 VALUES (1,0,'t'); +INSERT INTO t1 VALUES (1,1,'c'); +INSERT INTO t1 VALUES (0,9,'m'); +INSERT INTO t1 VALUES (9,5,'y'); +INSERT INTO t1 VALUES (NULL,6,'f'); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +) stats_persistent=0; +EXPLAIN SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL col_int_key NULL NULL NULL 19 100.00 NULL +1 PRIMARY table3 NULL ALL col_varchar_key NULL NULL NULL 19 10.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ref col_varchar_key col_varchar_key 7 test.table3.col_varchar_key 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table2`.`col_varchar_key` = `test`.`table3`.`col_varchar_key`) and (`test`.`table3`.`col_int_nokey` = `test`.`table1`.`col_int_key`) and ((`test`.`table3`.`col_int_key`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` where (outer_field_is_not_null, ((`test`.`table3`.`col_int_key`) <> `test`.`t2`.`c1`), true))))) +SELECT table1.col_int_nokey +FROM t1 AS table1 STRAIGHT_JOIN ( +t1 AS table2 INNER JOIN t1 AS table3 +ON table3.col_varchar_key = table2.col_varchar_key) +ON table3.col_int_nokey = table1.col_int_key +WHERE table3.col_int_key != SOME ( SELECT c1 FROM t2 ); +col_int_nokey +DROP TABLE t1, t2; +# +# Bug#58243 "RQG test optimizer_subquery causes server crash +# when running with ICP" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +c2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,6,7); +CREATE TABLE t2 ( +c1 INTEGER NOT NULL +); +EXPLAIN SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where false order by `test`.`t1`.`c2` +SELECT t1.c1 +FROM t1 +WHERE t1.pk < 317 AND 2 IN (SELECT COUNT(t2.c1) +FROM t2) +ORDER BY t1.c2; +c1 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t1 VALUES (2,'w'); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +c2 VARCHAR(1) NOT NULL, +KEY (c1, i1) +) charset latin1; +INSERT INTO t2 VALUES (8,'d','d'); +INSERT INTO t2 VALUES (4,'v','v'); +CREATE TABLE t3 ( +c1 VARCHAR(1) NOT NULL +) charset latin1; +INSERT INTO t3 VALUES ('v'); +EXPLAIN SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref c1 c1 3 test.t3.c1 1 50.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.c1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where exists(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((/* select#3 */ select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`))) +SELECT i1 +FROM t1 +WHERE EXISTS (SELECT t2.c1 +FROM (t2 INNER JOIN t3 ON (t3.c1 = t2.c1)) +WHERE t2.c2 != t1.c1 AND t2.c2 = (SELECT MIN(t3.c1) +FROM t3)); +i1 +2 +DROP TABLE t1,t2,t3; +# +# Bug#58015 "Assert in row_sel_field_store_in_mysql_format +# when running innodb_mrr_icp test" +# +create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b)); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values ('',1); +select 1 from t1 where b <= 1 and a <> ''; +1 +drop table t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE t1.i); +pk i +12 5 +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch_bug58816= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`pk` <> 3) +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch_bug58816; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT IGNORE INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_int' of SELECT #3 was resolved in SELECT #2 +Note 1276 Field or reference 'test.t1b.t1_time' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`t1a`.`t1_int` AS `t1_int`,`test`.`t1a`.`t1_time` AS `t1_time` from `test`.`t1` `t1a` where false + +DROP TABLE t1,t2; +# +# Bug#59186 Wrong results of join when ICP is enabled +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c2` AS `c2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c1` = `test`.`t1`.`c1`) and (((`test`.`t2`.`pk` <= 4) and (`test`.`t1`.`pk` in (2,1))) or ((`test`.`t1`.`pk` > 1) and (`test`.`t2`.`pk` between 6 and 6)))) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT IGNORE INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# Bug#11873324 "WRONG RESULT WITH ICP AND STRAIGHT_JOIN" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t1 VALUES (14,NULL), (18,133); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER, +c1 VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (i1) +); +INSERT INTO t2 VALUES (1,7,'f'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL col_int_key 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY subquery_t1 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY subquery_t2 NULL ref col_int_key col_int_key 5 func 1 100.00 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1`,(/* select#2 */ select straight_join `test`.`subquery_t1`.`pk` from `test`.`t1` `subquery_t1` join `test`.`t2` `subquery_t2` where ((`test`.`subquery_t2`.`i1` = `test`.`subquery_t1`.`pk`) and ((`test`.`subquery_t1`.`i1` > 0) or (`test`.`subquery_t2`.`c1` = 'a')) and (outer_field_is_not_null, ((`test`.`t1`.`i1`) = `test`.`subquery_t1`.`pk`), true))) is false) +SELECT t1.i1 +FROM t1 +WHERE t1.i1 NOT IN +( SELECT STRAIGHT_JOIN subquery_t1.pk +FROM t1 AS subquery_t1 +JOIN t2 AS subquery_t2 +ON subquery_t2.i1 = subquery_t1.pk +WHERE subquery_t1.i1 > 0 +OR subquery_t2.c1 = 'a' +); +i1 +NULL +133 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#11876420 "MISSING ROW IN RESULT WITH SUBQUERY + IN + XOR + +# NULL VALUES AND ICP ENABLED" +# +CREATE TABLE t1 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'j'), (0,'e'), (210,'f'), (8,'v'), (7,'x'), +(5,'m'), (NULL,'c'); +CREATE TABLE t2 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES (8,NULL); +CREATE TABLE t3 ( +i1 INTEGER, +c1 VARCHAR(1), +KEY col_varchar_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL,'w'), (1,NULL), (2,'d'); +set @old_opt_switch=@@optimizer_switch; +EXPLAIN SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t1 NULL ref_or_null col_varchar_key col_varchar_key 7 func 2 33.33 Using where; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`i1` AS `i1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` > `test`.`t2`.`c1`) and (outer_field_is_not_null, (((`test`.`t3`.`c1`) = `test`.`t1`.`c1`) or (`test`.`t1`.`c1` is null)), true) and (`test`.`t2`.`i1` >= `test`.`t1`.`i1`)) having (outer_field_is_not_null, (`test`.`t1`.`c1`), true))) xor (0 <> `test`.`t3`.`i1`)) +SELECT i1 +FROM t3 +WHERE c1 IN +( SELECT t1.c1 +FROM t2 JOIN t1 +ON t2.i1 >= t1.i1 +WHERE t1.c1 > t2.c1 +) +XOR i1; +i1 +1 +2 +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +# +# Bug#12355958 "FAILING ASSERTION: TRX->LOCK.N_ACTIVE_THRS == 1" +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER NOT NULL, +b CHAR(1), +KEY(b) +) charset utf8mb4; +INSERT INTO t1 VALUES (23,5,'d'); +EXPLAIN SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY a1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a1`.`pk` AS `pk` from `test`.`t1` `a1` where ((`test`.`a1`.`b` = 'd') and (`test`.`a1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and (((/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1) <> '5') or (`test`.`a1`.`b` is null))) +SELECT a1.pk +FROM t1 AS a1 JOIN (SELECT * FROM t1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM t1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ref b b 5 const 1 100.00 Using where +3 SUBQUERY t1 NULL index NULL b 5 NULL 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where ((`test`.`t1`.`b` = 'd') and (`test`.`t1`.`a` = (/* select#3 */ select `test`.`t1`.`pk` from `test`.`t1` limit 1)) and ((`test`.`t1`.`a` <> '5') or (`test`.`t1`.`b` is null))) +SELECT a1.pk +FROM v1 AS a1 JOIN (SELECT * FROM v1 LIMIT 1) AS a2 ON a2.b = a1.b +WHERE a1.a = (SELECT pk FROM v1 LIMIT 1) +AND (a1.a != a2.a OR a1.b IS NULL); +pk +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#12601961 "SEGFAULT IN HANDLER::COMPARE_KEY2" +# BUG#12724899 "SELECT STRAIGHT_JOIN QUERY GIVES 2 DATES VERSUS +# 2 WARNINGS WITH ICP ON" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,3,'j'), (20,8,'e'); +EXPLAIN SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE alias2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias2`.`i1` AS `i1` from `test`.`t1` `alias1` straight_join `test`.`t1` `alias2` where ((`test`.`alias2`.`pk` = 1) and (cast(`test`.`alias2`.`pk` as double) <= cast(`test`.`alias1`.`c1` as double))) +SELECT alias2.i1 +FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2 +ON alias2.pk AND alias2.pk <= alias1.c1 +WHERE alias2.pk = 1; +i1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'e' +DROP TABLE t1; +# +# BUG#12822678 - 2 MORE ROWS WHEN ICP=ON W/ STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k1 9 NULL 3 100.00 Using index +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d1` AS `d1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`pk` = 4) and (`test`.`t2`.`pk` <> `test`.`t1`.`d1`) and (0 <> `test`.`t2`.`i1`)) +SELECT t1.d1, t2.pk, t2.i1 +FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# +# BUG#12838420 "DUPLICATE VALUES FOR GROUP-BY COLUMN WHEN JOIN +# BUFFERING IS OFF" +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t1 VALUES (2,3),(3,2),(3,5),(4,6); +CREATE TABLE t2 ( +col_int_key INT, +pk INT, +PRIMARY KEY (pk), +KEY (col_int_key) +); +INSERT INTO t2 VALUES (0,9),(3,10),(4,6),(6,1),(100,3),(200,5); +set @old_opt_switch=@@optimizer_switch; +SET optimizer_switch="block_nested_loop=off"; +EXPLAIN SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_int_key col_int_key 5 NULL 6 33.33 Using where; Using index +2 SIMPLE t1 NULL index NULL col_int_key 5 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_key` AS `field1` from `test`.`t2` USE INDEX (`col_int_key`) straight_join `test`.`t1` where ((`test`.`t2`.`pk` < 7) and (`test`.`t2`.`col_int_key` <> 7) and (0 <> `test`.`t2`.`col_int_key`)) group by `field1` +SELECT t2.col_int_key AS field1 +FROM t2 USE INDEX(col_int_key) STRAIGHT_JOIN t1 ON t2.col_int_key +WHERE t2.pk < 7 AND t2.col_int_key <> 7 +GROUP BY field1; +field1 +4 +6 +100 +200 +SET @@optimizer_switch=@old_opt_switch; +DROP TABLE t1,t2; +# +# Bug#12976163 "CRASH IN INDEX CONDITION PUSHDOWN CODE AGAINST +# A MYISAM TABLE" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (14,1), (15,2), (16,3); +CREATE TABLE t2 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +c1 TINYTEXT +); +INSERT INTO t2 +SELECT i1, 10 * i2, "MySQL" FROM t1; +CREATE PROCEDURE proc1(id INTEGER) +BEGIN +SELECT i2 +FROM ( +(SELECT i1, i2, NULL AS a1 FROM t1) +UNION +(SELECT i1, i2, c1 AS a1 FROM t2) +) u1 +WHERE i1 = id; +END$$ +CALL proc1(15); +i2 +2 +20 +DROP PROCEDURE proc1; +DROP TABLE t1, t2; +# +# Bug#13655397 "CRASH IN SYNC_THREAD_LEVELS_NONEMPTY_TRX" +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i1) +); +INSERT INTO t1 VALUES (4,4), (5,5); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE FUNCTION f1() RETURNS INTEGER +RETURN (SELECT MOD(COUNT(DISTINCT pk), 10) FROM t2); +EXPLAIN SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref i1 i1 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` where ((`test`.`t1`.`i1` = 5) and (`f1`() = 1)) +SELECT i1, i2 FROM t1 WHERE f1() = 1 AND i1 = 5; +i1 i2 +5 5 +DROP FUNCTION f1; +DROP TABLE t1, t2; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr.result-pq b/mysql-test/r/innodb_mrr.result-pq new file mode 100644 index 000000000..8a815a8c8 --- /dev/null +++ b/mysql-test/r/innodb_mrr.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_all.result-pq b/mysql-test/r/innodb_mrr_all.result-pq new file mode 100644 index 000000000..2c5444f5b --- /dev/null +++ b/mysql-test/r/innodb_mrr_all.result-pq @@ -0,0 +1,802 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`int_key` is null) +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index c1 c1 7 NULL 2 100.00 Using index; Using temporary; Using filesort; LooseScan +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` semi join (`test`.`t2`) where (`d1`.`c1` = `test`.`t2`.`c1`) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_cost.result-pq b/mysql-test/r/innodb_mrr_cost.result-pq new file mode 100644 index 000000000..ada1e5f08 --- /dev/null +++ b/mysql-test/r/innodb_mrr_cost.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='mrr=on,mrr_cost_based=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_cost_all.result-pq b/mysql-test/r/innodb_mrr_cost_all.result-pq new file mode 100644 index 000000000..f6b38624e --- /dev/null +++ b/mysql-test/r/innodb_mrr_cost_all.result-pq @@ -0,0 +1,802 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`int_key` is null) +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index c1 c1 7 NULL 2 100.00 Using index; Using temporary; Using filesort; LooseScan +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` semi join (`test`.`t2`) where (`d1`.`c1` = `test`.`t2`.`c1`) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_cost_icp.result-pq b/mysql-test/r/innodb_mrr_cost_icp.result-pq new file mode 100644 index 000000000..c4a585bc8 --- /dev/null +++ b/mysql-test/r/innodb_mrr_cost_icp.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=on'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_icp.result-pq b/mysql-test/r/innodb_mrr_icp.result-pq new file mode 100644 index 000000000..7c7fe469a --- /dev/null +++ b/mysql-test/r/innodb_mrr_icp.result-pq @@ -0,0 +1,801 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_mrr_none.result-pq b/mysql-test/r/innodb_mrr_none.result-pq new file mode 100644 index 000000000..960dd1120 --- /dev/null +++ b/mysql-test/r/innodb_mrr_none.result-pq @@ -0,0 +1,800 @@ +set @save_storage_engine= @@default_storage_engine; +set default_storage_engine=InnoDB; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or +(a>='c-1014=w' and a <= 'c-1015=w'); +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b in ('c-1013=z', 'a-1014=w'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +insert into t3 values ('c-1013=w', 'del-me', 'inserted'); +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or +a='c-1014=w' or a='c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1013=w inserted +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +delete from t3 where b='del-me'; +alter table t3 add primary key(b); +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', +'c-1022=w', 'c-1023=w', 'c-1024=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +c-1024=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or +b IN ('c-1021=w', 'c-1022=w', 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or +b IN ('c-1019=w', 'c-1020=w') or +(b>='c-1021=w' and b<= 'c-1023=w'); +b filler +c-1011=w filler +c-1012=w filler +c-1013=w filler +c-1014=w filler +c-1015=w filler +c-1016=w filler +c-1017=w filler +c-1018=w filler +c-1019=w filler +c-1020=w filler +c-1021=w filler +c-1022=w filler +c-1023=w filler +create table t4 (a varchar(10), b int, c char(10), filler char(200), +key idx1 (a, b, c)) charset utf8mb4; +insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15; +insert into t4 (a,b,c,filler) +select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500; +explain +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 16 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where ((`test`.`t4`.`a` is null) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` is null) or (`test`.`t4`.`c` = 'no-such-row1') or (`test`.`t4`.`c` = 'no-such-row2'))) +select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' + or c='no-such-row2'); +a b c filler +NULL NULL NULL NULL-15 +NULL NULL NULL NULL-14 +NULL NULL NULL NULL-13 +NULL NULL NULL NULL-12 +NULL NULL NULL NULL-11 +NULL NULL NULL NULL-10 +NULL NULL NULL NULL-9 +NULL NULL NULL NULL-8 +NULL NULL NULL NULL-7 +NULL NULL NULL NULL-6 +NULL NULL NULL NULL-5 +NULL NULL NULL NULL-4 +NULL NULL NULL NULL-3 +NULL NULL NULL NULL-2 +NULL NULL NULL NULL-1 +explain +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (4 workers) +2 SIMPLE t4 NULL range idx1 idx1 89 NULL 32 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler` AS `filler` from `test`.`t4` where (((`test`.`t4`.`a` = 'b-1') or (`test`.`t4`.`a` = 'bb-1')) and (`test`.`t4`.`b` is null) and ((`test`.`t4`.`c` = 'c-1') or (`test`.`t4`.`c` = 'cc-2'))) +select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); +a b c filler +b-1 NULL c-1 NULL-15 +b-1 NULL c-1 NULL-14 +b-1 NULL c-1 NULL-13 +b-1 NULL c-1 NULL-12 +b-1 NULL c-1 NULL-11 +b-1 NULL c-1 NULL-10 +b-1 NULL c-1 NULL-9 +b-1 NULL c-1 NULL-8 +b-1 NULL c-1 NULL-7 +b-1 NULL c-1 NULL-6 +b-1 NULL c-1 NULL-5 +b-1 NULL c-1 NULL-4 +b-1 NULL c-1 NULL-3 +b-1 NULL c-1 NULL-2 +b-1 NULL c-1 NULL-1 +bb-1 NULL cc-2 NULL-15 +bb-1 NULL cc-2 NULL-14 +bb-1 NULL cc-2 NULL-13 +bb-1 NULL cc-2 NULL-12 +bb-1 NULL cc-2 NULL-11 +bb-1 NULL cc-2 NULL-10 +bb-1 NULL cc-2 NULL-9 +bb-1 NULL cc-2 NULL-8 +bb-1 NULL cc-2 NULL-7 +bb-1 NULL cc-2 NULL-6 +bb-1 NULL cc-2 NULL-5 +bb-1 NULL cc-2 NULL-4 +bb-1 NULL cc-2 NULL-3 +bb-1 NULL cc-2 NULL-2 +bb-1 NULL cc-2 NULL-1 +drop table t1, t2, t3, t4; +create table t1 (a int, b int not null,unique key (a,b),index(b)); +insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6); +Warnings: +Warning 1062 Duplicate entry '6-6' for key 't1.a' +create table t2 like t1; +insert into t2 select * from t1; +alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10)); +select * from t1 where a is null; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3; +a b c +NULL 9 0 +NULL 9 0 +select * from t1 where a is null and b=9 or a is null and b=7 limit 3; +a b c +NULL 7 0 +NULL 9 0 +NULL 9 0 +drop table t1, t2; +CREATE TABLE t1 ( +ID int(10) unsigned NOT NULL AUTO_INCREMENT, +col1 int(10) unsigned DEFAULT NULL, +key1 int(10) unsigned NOT NULL DEFAULT '0', +key2 int(10) unsigned DEFAULT NULL, +text1 text, +text2 text, +col2 smallint(6) DEFAULT '100', +col3 enum('headers','bodyandsubject') NOT NULL DEFAULT 'bodyandsubject', +col4 tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY (key1), +KEY (key2) +) AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1,NULL,1130,NULL,'Hello',NULL,100,'bodyandsubject',0), +(2,NULL,1130,NULL,'bye',NULL,100,'bodyandsubject',0), +(3,NULL,1130,NULL,'red',NULL,100,'bodyandsubject',0), +(4,NULL,1130,NULL,'yellow',NULL,100,'bodyandsubject',0), +(5,NULL,1130,NULL,'blue',NULL,100,'bodyandsubject',0); +select * FROM t1 WHERE key1=1130 AND col1 IS NULL ORDER BY text1; +ID col1 key1 key2 text1 text2 col2 col3 col4 +5 NULL 1130 NULL blue NULL 100 bodyandsubject 0 +2 NULL 1130 NULL bye NULL 100 bodyandsubject 0 +1 NULL 1130 NULL Hello NULL 100 bodyandsubject 0 +3 NULL 1130 NULL red NULL 100 bodyandsubject 0 +4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0 +drop table t1; + +BUG#37851: Crash in test_if_skip_sort_order tab->select is zero + +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_key int(11) DEFAULT NULL, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1),(2,6),(3,0); +EXPLAIN +SELECT MIN(t1.pk) +FROM t1 WHERE EXISTS ( +SELECT t2.pk +FROM t2 +WHERE t2.int_key IS NULL +GROUP BY t2.pk +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t2 NULL ref int_key int_key 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where false +DROP TABLE t1, t2; +# +# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b char(20), filler char(200), key(a,b(10))); +insert into t1 select A.a + 10*(B.a + 10*C.a), 'bbb','filler' from t0 A, t0 B, t0 C; +update t1 set b=repeat(char(65+a), 20) where a < 25; +This must show range + using index condition: +explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x x Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL x x Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` < 10) and (`test`.`t1`.`b` = repeat(char((65 + `test`.`t1`.`a`)),20))) +select * from t1 where a < 10 and b = repeat(char(65+a), 20); +a b filler +0 AAAAAAAAAAAAAAAAAAAA filler +1 BBBBBBBBBBBBBBBBBBBB filler +2 CCCCCCCCCCCCCCCCCCCC filler +3 DDDDDDDDDDDDDDDDDDDD filler +4 EEEEEEEEEEEEEEEEEEEE filler +5 FFFFFFFFFFFFFFFFFFFF filler +6 GGGGGGGGGGGGGGGGGGGG filler +7 HHHHHHHHHHHHHHHHHHHH filler +8 IIIIIIIIIIIIIIIIIIII filler +9 JJJJJJJJJJJJJJJJJJJJ filler +drop table t0,t1; +# +# BUG#41136: ORDER BY + range access: EXPLAIN shows "Using MRR" while MRR is actually not used +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, key(a)); +insert into t1 select A.a + 10 *(B.a + 10*C.a), A.a + 10 *(B.a + 10*C.a) from t0 A, t0 B, t0 C; +This mustn't show "Using MRR": +explain select * from t1 where a < 20 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 20) order by `test`.`t1`.`a` +drop table t0, t1; +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=64; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a char(8), b char(8), c char(8), filler char(100), key k1(a,b,c) ) charset utf8mb4; +insert into t2 select +concat('a-', 1000 + A.a, '-a'), +concat('b-', 1000 + B.a, '-b'), +concat('c-', 1000 + C.a, '-c'), +'filler' +from t1 A, t1 B, t1 C; +EXPLAIN select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range k1 k1 33 NULL 100 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count((length(`test`.`t2`.`a`) + length(`test`.`t2`.`filler`))) AS `count(length(a) + length(filler))` from `test`.`t2` FORCE INDEX (`k1`) where ((`test`.`t2`.`a` >= 'a-1000-a') and (`test`.`t2`.`a` < 'a-1001-a')) +select count(length(a) + length(filler)) +from t2 force index (k1) +where a>='a-1000-a' and a <'a-1001-a'; +count(length(a) + length(filler)) +100 +drop table t2; +create table t2 (a char(100), b char(100), c char(100), d int, +filler char(10), key(d), primary key (a,b,c)) charset latin1; +insert into t2 select A.a, B.a, B.a, A.a, 'filler' from t1 A, t1 B; +explain select * from t2 force index (d) where d < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range d d 5 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` FORCE INDEX (`d`) where (`test`.`t2`.`d` < 10) +drop table t2; +drop table t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +create table t1 (f1 int not null, f2 int not null,f3 int not null, f4 char(1), primary key (f1,f2), key ix(f3)); +select * from t1 where (f3>=5 and f3<=10) or (f3>=1 and f3<=4); +f1 f2 f3 f4 +1 1 1 A +10 10 10 A +2 2 2 A +3 3 3 A +4 4 4 A +5 5 5 A +6 6 6 A +7 7 7 A +8 8 8 A +9 9 9 A +drop table t1; + +BUG#37977: Wrong result returned on GROUP BY + OR + Innodb + +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +`datetime_key` datetime NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(5) DEFAULT NULL, +`varchar_nokey` varchar(5) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `int_key` (`int_key`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t1 VALUES +(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'), +(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'), +(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'), +(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL), +(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'date_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +select pk from t1 WHERE `varchar_key` > 'kr' group by pk; +pk +1 +5 +select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk; +pk +1 +5 +drop table t1; +# +# BUG#39447: Error with NOT NULL condition and LIMIT 1 +# +CREATE TABLE t1 ( +id int(11) NOT NULL, +parent_id int(11) DEFAULT NULL, +name varchar(10) DEFAULT NULL, +PRIMARY KEY (id), +KEY ind_parent_id (parent_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, parent_id, name) values +(10,NULL,'A'), +(20,10,'B'), +(30,10,'C'), +(40,NULL,'D'), +(50,40,'E'), +(60,40,'F'), +(70,NULL,'J'); +SELECT id FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id +60 +This must show type=index, extra=Using where +explain SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 57.14 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index ind_parent_id PRIMARY 4 NULL 1 57.14 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`parent_id` is not null) order by `test`.`t1`.`id` desc limit 1 +SELECT * FROM t1 WHERE parent_id IS NOT NULL ORDER BY id DESC LIMIT 1; +id parent_id name +60 40 F +drop table t1; +# +# Bug#50381 "Assertion failing in handler.h:1283: +# void COST_VECT::add_io(double, double)" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (c1) +); +INSERT INTO t2 VALUES (10,'v'); +INSERT INTO t2 VALUES (11,'r'); +SELECT t1.c2 +FROM t2 STRAIGHT_JOIN t1 ON t1.c1 < t2.c1; +c2 +DROP TABLE t1, t2; +# +# Bug#12321461: CRASH IN DSMRR_IMPL::DSMRR_INIT ON SELECT STRAIGHT_JOIN +# +set @save_optimizer_switch = @@optimizer_switch; +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +pk INTEGER, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +c1 VARCHAR(1) NOT NULL +); +INSERT INTO t2 VALUES ('v'), ('c'); +EXPLAIN SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`c1` = `test`.`t2`.`c1`) and (`test`.`t1`.`pk` > 176)) +SELECT STRAIGHT_JOIN t1.c1 +FROM t1 RIGHT OUTER JOIN t2 ON t1.c1 = t2.c1 +WHERE t1.pk > 176; +c1 +DROP TABLE t1,t2; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#13249966 MRR: RANDOM ERROR DUE TO UNINITIALIZED RES WITH +# SMALL READ_RND_BUFFER_SIZE +# +set @read_rnd_buffer_size_save= @@read_rnd_buffer_size; +set read_rnd_buffer_size=1; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES (0,1),(1,2),(2,3); +EXPLAIN SELECT i1 +FROM t1 +WHERE i2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i2 i2 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i2` > 2) +SELECT i1 +FROM t1 +WHERE i2 > 2; +i1 +2 +DROP TABLE t1; +set @@read_rnd_buffer_size= @read_rnd_buffer_size_save; +select @@read_rnd_buffer_size; +@@read_rnd_buffer_size +262144 +# +# Bug 12365385 STRAIGHT_JOIN QUERY QUICKLY EXHAUSTS SYSTEM+VIRT. +# MEMORY LEADING TO SYSTEM CRASH +# +CREATE TABLE ten (a INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t1 +SELECT a, 1, 'MySQL' FROM ten; +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +c2 varchar(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t2 +SELECT a, 'MySQL', 'MySQL' FROM ten; +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t3 +SELECT a, 'MySQL' FROM ten; +CREATE TABLE t4 ( +pk int(11) NOT NULL, +c1_key varchar(10) CHARACTER SET utf8 NOT NULL, +c2 varchar(10) NOT NULL, +c3 varchar(10) NOT NULL, +PRIMARY KEY (pk), +KEY k1 (c1_key) +) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t5 ( +pk INTEGER NOT NULL, +c1 VARCHAR(10) NOT NULL, +PRIMARY KEY (pk) +) charset latin1; +INSERT INTO t5 +SELECT a, 'MySQL' FROM ten; +EXPLAIN SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL k1 NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t4`.`pk` AS `pk`,`test`.`t4`.`c1_key` AS `c1_key`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`c3` AS `c3`,`test`.`t5`.`pk` AS `pk`,`test`.`t5`.`c1` AS `c1` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c3` = `test`.`t2`.`c1`) and (`test`.`t4`.`c2` = `test`.`t1`.`c1`) and (`test`.`t1`.`i1` = 1) and (`test`.`t2`.`c2` <= `test`.`t5`.`c1`) and (`test`.`t3`.`c1` <= `test`.`t4`.`c1_key`)) +SELECT STRAIGHT_JOIN * +FROM +(t1 LEFT JOIN +(t2 LEFT JOIN +(t3 LEFT OUTER JOIN t4 ON t3.c1 <= t4.c1_key) +ON t2.c1 = t4.c3) +ON t1.c1 = t4.c2) +RIGHT OUTER JOIN t5 ON t2.c2 <= t5.c1 +WHERE t1.i1 = 1; +pk i1 c1 pk c1 c2 pk c1 pk c1_key c2 c3 pk c1 +DROP TABLE ten, t1, t2, t3, t4, t5; +# +# Bug 18172819 CRASH ON DSMRR_IMPL::CHOOSE_MRR_IMPL IN SQL/HANDLER.CC +# +set @big_tables_save= @@big_tables; +set @optimizer_switch_save=@@optimizer_switch; +set big_tables=ON; +set optimizer_switch='derived_merge=off'; +SELECT @@big_tables; +@@big_tables +1 +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +c1 VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'), (2, NULL); +CREATE TABLE t2 ( +c1 VARCHAR(1), +i1 INTEGER NOT NULL, +KEY (c1) +) charset utf8mb4; +INSERT INTO t2 VALUES ('a', 1), (NULL, 2); +EXPLAIN SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using filesort +3 DEPENDENT SUBQUERY t2 NULL index_subquery c1 c1 7 func 1 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `d1`.`i1` AS `i1`,`d1`.`c1` AS `c1` from (/* select#2 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` is null)) `d1` where (`d1`.`c1`,(((`d1`.`c1`) in t2 on c1))) order by `d1`.`i1` +SELECT * +FROM +( SELECT * FROM t1 ) AS d1 +WHERE d1.c1 IN ( SELECT c1 FROM t2 ) +AND d1.c1 IS NULL +ORDER BY d1.i1; +i1 c1 +DROP TABLE t1, t2; +set big_tables=@big_tables_save; +set optimizer_switch=@optimizer_switch_save; +# +# Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +START TRANSACTION; +EXPLAIN SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`dummy` AS `dummy`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` > 2) +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +dummy a b +3 3 3 +5 5 5 +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t1 VALUES (2,2,2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +# +# Bug#54286 "Server crash at lock timeout with MRR" +# +SET AUTOCOMMIT=0; +CREATE TABLE t1 ( +dummy INT PRIMARY KEY, +a INT UNIQUE, +b INT +) ENGINE=InnoDB; +COMMIT; +INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); +SET AUTOCOMMIT=0; +SELECT * FROM t1 WHERE a > 2 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +COMMIT; +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_pk_extension_off.result-pq b/mysql-test/r/innodb_pk_extension_off.result-pq new file mode 100644 index 000000000..836cb2c97 --- /dev/null +++ b/mysql-test/r/innodb_pk_extension_off.result-pq @@ -0,0 +1,496 @@ +# +# WL#6266 Make use of hidden key parts +# +# +# Optimizer switch use_index_extensions=off +# +set optimizer_switch= "use_index_extensions=off"; +CREATE TABLE t1 +( +pk_1 INT, +pk_2 INT, +f1 DATETIME, +f2 INT, +PRIMARY KEY(pk_1, pk_2), +KEY k1(f1), +KEY k2(f2) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 1, '2000-01-01', 1), (1, 2, '2000-01-02', 2), (1, 3, '2000-01-03', 3), (1, 4, '2000-01-04', 4), (1, 5, '2000-01-05', 5), +(2, 1, '2000-01-01', 6), (2, 2, '2000-01-02', 7), (2, 3, '2000-01-03', 8), (2, 4, '2000-01-04', 9), (2, 5, '2000-01-05', 10), +(3, 1, '2000-01-01', 11), (3, 2, '2000-01-02', 12), (3, 3, '2000-01-03', 13), (3, 4, '2000-01-04', 14), (3, 5, '2000-01-05', 15), +(4, 1, '2000-01-01', 16), (4, 2, '2000-01-02', 17), (4, 3, '2000-01-03', 18), (4, 4, '2000-01-04', 19), (4, 5, '2000-01-05', 20), +(5, 1, '2000-01-01', 21), (5, 2, '2000-01-02', 22), (5, 3, '2000-01-03', 23), (5, 4, '2000-01-04', 24), (5, 5, '2000-01-05', 25), +(6, 1, '2000-01-06', 26), (6, 2, '2000-01-06', 27), (6, 3, '2000-01-03', 28), (6, 4, '2000-01-06', 29), (6, 5, '2000-01-06', 30), +(7, 1, '2000-01-06', 31), (7, 2, '2000-01-06', 32), (7, 3, '2000-01-03', 33), (7, 4, '2000-01-06', 34), (7, 5, '2000-01-06', 35), +(8, 1, '2000-01-06', 36), (8, 2, '2000-01-06', 37), (8, 3, '2000-01-03', 38), (8, 4, '2000-01-06', 39), (8, 5, '2000-01-06', 40), +(9, 1, '2000-01-06', 41), (9, 2, '2000-01-06', 42), (9, 3, '2000-01-03', 43), (9, 4, '2000-01-06', 44), (9, 5, '2000-01-06', 45); +INSERT INTO t1 VALUES +(11, 1, '2000-01-01', 1), (11, 2, '2000-01-02', 2), (11, 3, '2000-01-03', 3), (11, 4, '2000-01-04', 4), (11, 5, '2000-01-05', 5), +(12, 1, '2000-01-01', 6), (12, 2, '2000-01-02', 7), (12, 3, '2000-01-03', 8), (12, 4, '2000-01-04', 9), (12, 5, '2000-01-05', 10), +(13, 1, '2000-01-01', 11), (13, 2, '2000-01-02', 12), (13, 3, '2000-01-03', 13), (13, 4, '2000-01-04', 14), (13, 5, '2000-01-05', 15), +(14, 1, '2000-01-01', 16), (14, 2, '2000-01-02', 17), (14, 3, '2000-01-03', 18), (14, 4, '2000-01-04', 19), (14, 5, '2000-01-05', 20), +(15, 1, '2000-01-01', 1), (15, 2, '2000-01-02', 2), (15, 3, '2000-01-03', 3), (15, 4, '2000-01-04', 4), (15, 5, '2000-01-05', 5), +(16, 1, '2000-01-06', 6), (16, 2, '2000-01-06', 7), (16, 3, '2000-01-03', 8), (16, 4, '2000-01-06', 9), (16, 5, '2000-01-06', 10), +(17, 1, '2000-01-06', 31), (17, 2, '2000-01-06', 32), (17, 3, '2000-01-03', 33), (17, 4, '2000-01-06', 34), (17, 5, '2000-01-06', 35), +(18, 1, '2000-01-06', 36), (18, 2, '2000-01-06', 37), (18, 3, '2000-01-03', 38), (18, 4, '2000-01-06', 39), (18, 5, '2000-01-06', 40), +(19, 1, '2000-01-06', 1), (19, 2, '2000-01-06', 2), (19, 3, '2000-01-03', 3), (19, 4, '2000-01-06', 4), (19, 5, '2000-01-06', 5); +INSERT INTO t1 VALUES +(21, 1, '2000-01-01', 1), (21, 2, '2000-01-02', 2), (31, 3, '2000-01-03', 3), (41, 4, '2000-01-04', 4), (51, 5, '2000-01-05', 5), +(22, 1, '2000-01-01', 6), (22, 2, '2000-01-02', 7), (32, 3, '2000-01-03', 8), (42, 4, '2000-01-04', 9), (52, 5, '2000-01-05', 10), +(23, 1, '2000-01-01', 11), (23, 2, '2000-01-02', 12), (33, 3, '2000-01-03', 13), (43, 4, '2000-01-04', 14), (53, 5, '2000-01-05', 15), +(24, 1, '2000-01-01', 16), (24, 2, '2000-01-02', 17), (34, 3, '2000-01-03', 18), (44, 4, '2000-01-04', 19), (54, 5, '2000-01-05', 20), +(25, 1, '2000-01-01', 1), (25, 2, '2000-01-02', 2), (35, 3, '2000-01-03', 3), (45, 4, '2000-01-04', 4), (55, 5, '2000-01-05', 5), +(26, 1, '2000-01-06', 6), (26, 2, '2000-01-06', 7), (36, 3, '2000-01-03', 8), (46, 4, '2000-01-06', 9), (56, 5, '2000-01-06', 10), +(27, 1, '2000-01-06', 31), (27, 2, '2000-01-06', 32), (37, 3, '2000-01-03', 33), (47, 4, '2000-01-06', 34), (57, 5, '2000-01-06', 35), +(28, 1, '2000-01-06', 36), (28, 2, '2000-01-06', 37), (38, 3, '2000-01-03', 38), (48, 4, '2000-01-06', 39), (58, 5, '2000-01-06', 40), +(29, 1, '2000-01-06', 1), (29, 2, '2000-01-06', 2), (39, 3, '2000-01-03', 3), (49, 4, '2000-01-06', 4), (59, 5, '2000-01-06', 5); +INSERT INTO t1 SELECT pk_1 + 60, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 120, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 240, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1, pk_2 + 10, f1, f2 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# +# REF access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 PRIMARY 4 const # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +count(*) +2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 11 +EXPLAIN SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 PRIMARY 4 const # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +pk_2 +3 +13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 11 +# +# RANGE access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +count(*) +6 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +EXPLAIN SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +pk_1 pk_2 +3 3 +3 13 +4 3 +4 13 +5 3 +5 13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +# +# MAX/MIN optimization +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref k1 k1 6 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MIN(pk_1) +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MIN(pk_1) +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref k1 k1 6 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MAX(pk_1) +459 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MAX(pk_1) +5 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +# +# Loose index scan +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` between 13 and 14) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +MIN(pk_1) +3 +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 98 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` in (1,2)) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +MIN(pk_1) +1 +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 226 +# +# JOIN optimization +# +EXPLAIN SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 6 const # 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY,k1 PRIMARY 4 test.t1.pk_1 # 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk_1` = `test`.`t1`.`pk_1`) and (`test`.`t2`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00')) +FLUSH STATUS; +SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +count(*) +864 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 435 +Handler_read_last 0 +Handler_read_next 3168 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +# +# Optimization of sorting +# Also verifies FORMAT=tree for reverse ref access. +# +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 PRIMARY 4 const # 20.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) order by `test`.`t1`.`pk_2` desc limit 5 +EXPLAIN FORMAT=tree SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +EXPLAIN +-> Limit: 5 row(s) + -> Parallel scan on + -> Limit: 5 row(s) (cost=0.45 rows=2) + -> Filter: (t1.f1 = TIMESTAMP'2000-01-03 00:00:00') (cost=0.45 rows=2) + -> PQblock lookup on t1 using PRIMARY (pk_1=3; iterate backwards) (cost=0.45 rows=10) + +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 3 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 11 +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 PRIMARY 4 NULL # 20.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) order by `test`.`t1`.`pk_2` desc limit 5 +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 4 13 +2000-01-03 00:00:00 5 13 +2000-01-03 00:00:00 3 3 +2000-01-03 00:00:00 4 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 31 +DROP TABLE t1; +# +# Max key part limitation +# +CREATE TABLE t1 +( +f1 INT, f2 INT, f3 INT, f4 INT, f5 INT, f6 INT, f7 INT, f8 INT, f9 INT, f10 INT, +f11 INT, f12 INT, f13 INT, f14 INT, f15 INT, f16 INT, f17 INT, f18 INT, +PRIMARY KEY (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10), +KEY k1 (f11, f12, f13, f14, f15, f16, f17) +) ENGINE = InnoDB; +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND f10 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 35 const,const,const,const,const,const,const # 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f10` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 35 const,const,const,const,const,const,const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +DROP TABLE t1; +# +# Max key length limitation +# +CREATE TABLE t1 +( +f1 VARCHAR(500), f2 VARCHAR(500), f3 VARCHAR(500), +f4 VARCHAR(500), f5 VARCHAR(500), f6 VARCHAR(500), +f7 VARCHAR(500), +PRIMARY KEY (f1, f2, f3, f4), +KEY k1 (f5, f6, f7) +) charset latin1 ENGINE = InnoDB; +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 1509 const,const,const # 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 1509 const,const,const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 1509 const,const,const # 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +DROP TABLE t1; +# +# Unique extended key +# +CREATE TABLE t1 +( +pk INT NOT NULL auto_increment, +f1 INT NOT NULL, +KEY (f1), +PRIMARY KEY (pk) +) ENGINE = INNODB; +CREATE TABLE t2 +( +f1 INT, +f2 INT +) ENGINE = INNODB; +INSERT INTO t1(f1) VALUES (1),(2); +INSERT INTO t1(f1) SELECT f1 + 2 FROM t1; +INSERT INTO t1(f1) SELECT f1 + 4 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t2 VALUES (1,1), (2,2); +EXPLAIN SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t1 NULL ref f1 f1 4 test.t2.f2 1 12.50 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1` from `test`.`t2` join `test`.`t1` IGNORE INDEX (PRIMARY) where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t1`.`pk` = `test`.`t2`.`f1`)) +FLUSH STATUS; +SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +f1 +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +DROP TABLE t1, t2; +# +# Bug#20430526 ADDRESSSANITIZER: HEAP-BUFFER-OVERFLOW IN +# FIELD_BLOB::GET_KEY_IMAGE FLOAT8STORE +# +CREATE TABLE t1 +(a GEOMETRY NOT NULL SRID 0, SPATIAL KEY(a)) ENGINE=INNODB; +INSERT INTO t1 VALUES (point(7, 7)); +SELECT st_astext(a) FROM t1 WHERE st_equals(a, point(7, 7)); +st_astext(a) +POINT(7 7) +DROP TABLE t1; +# +# Bug #31617858 INCORRECT RESULTS WHEN USING INDEX ON LONG CHARACTER COLS. +# +CREATE TABLE t( +a VARCHAR(256) NOT NULL, +i VARCHAR(512) NOT NULL, +PRIMARY KEY (a), +KEY (i)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +INSERT INTO t VALUES +('aaa12345678','aaa'), ('aaa2','aaa'), ('aaa4','aaa'), +('aaa3','aaa'),('aaa1','aaa'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index i i 2050 NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`i` AS `i` from `test`.`t` FORCE INDEX (`i`) where (`test`.`t`.`a` like '%aaa12345678%') +SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +i +aaa +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_pk_extension_on.result-pq b/mysql-test/r/innodb_pk_extension_on.result-pq new file mode 100644 index 000000000..5ea122c5b --- /dev/null +++ b/mysql-test/r/innodb_pk_extension_on.result-pq @@ -0,0 +1,489 @@ +# +# WL#6266 Make use of hidden key parts +# +# +# Optimizer switch use_index_extensions=on +# +set optimizer_switch= "use_index_extensions=on"; +CREATE TABLE t1 +( +pk_1 INT, +pk_2 INT, +f1 DATETIME, +f2 INT, +PRIMARY KEY(pk_1, pk_2), +KEY k1(f1), +KEY k2(f2) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 1, '2000-01-01', 1), (1, 2, '2000-01-02', 2), (1, 3, '2000-01-03', 3), (1, 4, '2000-01-04', 4), (1, 5, '2000-01-05', 5), +(2, 1, '2000-01-01', 6), (2, 2, '2000-01-02', 7), (2, 3, '2000-01-03', 8), (2, 4, '2000-01-04', 9), (2, 5, '2000-01-05', 10), +(3, 1, '2000-01-01', 11), (3, 2, '2000-01-02', 12), (3, 3, '2000-01-03', 13), (3, 4, '2000-01-04', 14), (3, 5, '2000-01-05', 15), +(4, 1, '2000-01-01', 16), (4, 2, '2000-01-02', 17), (4, 3, '2000-01-03', 18), (4, 4, '2000-01-04', 19), (4, 5, '2000-01-05', 20), +(5, 1, '2000-01-01', 21), (5, 2, '2000-01-02', 22), (5, 3, '2000-01-03', 23), (5, 4, '2000-01-04', 24), (5, 5, '2000-01-05', 25), +(6, 1, '2000-01-06', 26), (6, 2, '2000-01-06', 27), (6, 3, '2000-01-03', 28), (6, 4, '2000-01-06', 29), (6, 5, '2000-01-06', 30), +(7, 1, '2000-01-06', 31), (7, 2, '2000-01-06', 32), (7, 3, '2000-01-03', 33), (7, 4, '2000-01-06', 34), (7, 5, '2000-01-06', 35), +(8, 1, '2000-01-06', 36), (8, 2, '2000-01-06', 37), (8, 3, '2000-01-03', 38), (8, 4, '2000-01-06', 39), (8, 5, '2000-01-06', 40), +(9, 1, '2000-01-06', 41), (9, 2, '2000-01-06', 42), (9, 3, '2000-01-03', 43), (9, 4, '2000-01-06', 44), (9, 5, '2000-01-06', 45); +INSERT INTO t1 VALUES +(11, 1, '2000-01-01', 1), (11, 2, '2000-01-02', 2), (11, 3, '2000-01-03', 3), (11, 4, '2000-01-04', 4), (11, 5, '2000-01-05', 5), +(12, 1, '2000-01-01', 6), (12, 2, '2000-01-02', 7), (12, 3, '2000-01-03', 8), (12, 4, '2000-01-04', 9), (12, 5, '2000-01-05', 10), +(13, 1, '2000-01-01', 11), (13, 2, '2000-01-02', 12), (13, 3, '2000-01-03', 13), (13, 4, '2000-01-04', 14), (13, 5, '2000-01-05', 15), +(14, 1, '2000-01-01', 16), (14, 2, '2000-01-02', 17), (14, 3, '2000-01-03', 18), (14, 4, '2000-01-04', 19), (14, 5, '2000-01-05', 20), +(15, 1, '2000-01-01', 1), (15, 2, '2000-01-02', 2), (15, 3, '2000-01-03', 3), (15, 4, '2000-01-04', 4), (15, 5, '2000-01-05', 5), +(16, 1, '2000-01-06', 6), (16, 2, '2000-01-06', 7), (16, 3, '2000-01-03', 8), (16, 4, '2000-01-06', 9), (16, 5, '2000-01-06', 10), +(17, 1, '2000-01-06', 31), (17, 2, '2000-01-06', 32), (17, 3, '2000-01-03', 33), (17, 4, '2000-01-06', 34), (17, 5, '2000-01-06', 35), +(18, 1, '2000-01-06', 36), (18, 2, '2000-01-06', 37), (18, 3, '2000-01-03', 38), (18, 4, '2000-01-06', 39), (18, 5, '2000-01-06', 40), +(19, 1, '2000-01-06', 1), (19, 2, '2000-01-06', 2), (19, 3, '2000-01-03', 3), (19, 4, '2000-01-06', 4), (19, 5, '2000-01-06', 5); +INSERT INTO t1 VALUES +(21, 1, '2000-01-01', 1), (21, 2, '2000-01-02', 2), (31, 3, '2000-01-03', 3), (41, 4, '2000-01-04', 4), (51, 5, '2000-01-05', 5), +(22, 1, '2000-01-01', 6), (22, 2, '2000-01-02', 7), (32, 3, '2000-01-03', 8), (42, 4, '2000-01-04', 9), (52, 5, '2000-01-05', 10), +(23, 1, '2000-01-01', 11), (23, 2, '2000-01-02', 12), (33, 3, '2000-01-03', 13), (43, 4, '2000-01-04', 14), (53, 5, '2000-01-05', 15), +(24, 1, '2000-01-01', 16), (24, 2, '2000-01-02', 17), (34, 3, '2000-01-03', 18), (44, 4, '2000-01-04', 19), (54, 5, '2000-01-05', 20), +(25, 1, '2000-01-01', 1), (25, 2, '2000-01-02', 2), (35, 3, '2000-01-03', 3), (45, 4, '2000-01-04', 4), (55, 5, '2000-01-05', 5), +(26, 1, '2000-01-06', 6), (26, 2, '2000-01-06', 7), (36, 3, '2000-01-03', 8), (46, 4, '2000-01-06', 9), (56, 5, '2000-01-06', 10), +(27, 1, '2000-01-06', 31), (27, 2, '2000-01-06', 32), (37, 3, '2000-01-03', 33), (47, 4, '2000-01-06', 34), (57, 5, '2000-01-06', 35), +(28, 1, '2000-01-06', 36), (28, 2, '2000-01-06', 37), (38, 3, '2000-01-03', 38), (48, 4, '2000-01-06', 39), (58, 5, '2000-01-06', 40), +(29, 1, '2000-01-06', 1), (29, 2, '2000-01-06', 2), (39, 3, '2000-01-03', 3), (49, 4, '2000-01-06', 4), (59, 5, '2000-01-06', 5); +INSERT INTO t1 SELECT pk_1 + 60, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 120, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 240, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1, pk_2 + 10, f1, f2 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# +# REF access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +count(*) +2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +EXPLAIN SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +pk_2 +3 +13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# +# RANGE access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 10 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +count(*) +6 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +EXPLAIN SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 10 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +pk_1 pk_2 +3 3 +3 13 +4 3 +4 13 +5 3 +5 13 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +# +# MAX/MIN optimization +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`) +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MIN(pk_1) +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where ((`test`.`t1`.`pk_1` between 3 and 5) and multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`)) +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MIN(pk_1) +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`) +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE f1 = '2000-01-03'; +MAX(pk_1) +459 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`pk_1`) AS `MAX(pk_1)` from `test`.`t1` where ((`test`.`t1`.`pk_1` between 3 and 5) and multiple equal(TIMESTAMP'2000-01-03 00:00:00', `test`.`t1`.`f1`)) +FLUSH STATUS; +SELECT MAX(pk_1) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +MAX(pk_1) +5 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# +# Loose index scan +# +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` between 13 and 14) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 BETWEEN 13 AND 14 GROUP BY f2; +MIN(pk_1) +3 +3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k2 k2 5 NULL # 100.00 Using where; Using index for group-by +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk_1`) AS `MIN(pk_1)` from `test`.`t1` where (`test`.`t1`.`f2` in (1,2)) group by `test`.`t1`.`f2` +FLUSH STATUS; +SELECT MIN(pk_1) FROM t1 WHERE f2 IN (1, 2) GROUP BY f2; +MIN(pk_1) +1 +1 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 5 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# +# JOIN optimization +# +EXPLAIN SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 6 const # 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY,k1 k1 10 const,test.t1.pk_1 # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t2`.`pk_1` = `test`.`t1`.`pk_1`) and (`test`.`t2`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00')) +FLUSH STATUS; +SELECT count(*) FROM t1 AS t1 JOIN t1 AS t2 +ON t2.pk_1 = t1.pk_1 WHERE t1.f1 = '2000-01-03' AND t2.f1 = '2000-01-03'; +count(*) +864 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 435 +Handler_read_last 0 +Handler_read_next 864 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 434 +# +# Optimization of sorting +# Also verifies FORMAT=tree for reverse ref access. +# +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` = 3)) order by `test`.`t1`.`pk_2` desc limit 5 +EXPLAIN FORMAT=tree SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +EXPLAIN +-> Limit: 5 row(s) + -> Parallel scan on + -> Limit: 5 row(s) (cost=0.45 rows=2) + -> PQblock lookup on t1 using k1 (f1=TIMESTAMP'2000-01-03 00:00:00', pk_1=3; iterate backwards) (cost=0.45 rows=2) + +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 = 3 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 3 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +EXPLAIN SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 10 NULL # 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`pk_1` AS `pk_1`,`test`.`t1`.`pk_2` AS `pk_2` from `test`.`t1` where ((`test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`test`.`t1`.`pk_1` between 3 and 5)) order by `test`.`t1`.`pk_2` desc limit 5 +FLUSH STATUS; +SELECT f1, pk_1, pk_2 FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03' +ORDER BY pk_2 DESC LIMIT 5; +f1 pk_1 pk_2 +2000-01-03 00:00:00 3 13 +2000-01-03 00:00:00 4 13 +2000-01-03 00:00:00 5 13 +2000-01-03 00:00:00 3 3 +2000-01-03 00:00:00 4 3 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 7 +DROP TABLE t1; +# +# Max key part limitation +# +CREATE TABLE t1 +( +f1 INT, f2 INT, f3 INT, f4 INT, f5 INT, f6 INT, f7 INT, f8 INT, f9 INT, f10 INT, +f11 INT, f12 INT, f13 INT, f14 INT, f15 INT, f16 INT, f17 INT, f18 INT, +PRIMARY KEY (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10), +KEY k1 (f11, f12, f13, f14, f15, f16, f17) +) ENGINE = InnoDB; +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND f10 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 71 const,const,const,const,const,const,const,const,const,const,const,const,const,const,const,const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f10` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +EXPLAIN SELECT f17 FROM t1 FORCE INDEX (k1) WHERE +f1 = 0 AND f2 = 0 AND f3 = 0 AND f4 = 0 AND f5 = 0 AND +f6 = 0 AND f7 = 0 AND f8 = 0 AND f9 = 0 AND +f11 = 0 AND f12 = 0 AND f13 = 0 AND f14 = 0 AND +f15 = 0 AND f16 = 0 AND f17 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 71 const,const,const,const,const,const,const,const,const,const,const,const,const,const,const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f17` AS `f17` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f17` = 0) and (`test`.`t1`.`f16` = 0) and (`test`.`t1`.`f15` = 0) and (`test`.`t1`.`f14` = 0) and (`test`.`t1`.`f13` = 0) and (`test`.`t1`.`f12` = 0) and (`test`.`t1`.`f11` = 0) and (`test`.`t1`.`f9` = 0) and (`test`.`t1`.`f8` = 0) and (`test`.`t1`.`f7` = 0) and (`test`.`t1`.`f6` = 0) and (`test`.`t1`.`f5` = 0) and (`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f3` = 0) and (`test`.`t1`.`f2` = 0) and (`test`.`t1`.`f1` = 0)) +DROP TABLE t1; +# +# Max key length limitation +# +CREATE TABLE t1 +( +f1 VARCHAR(500), f2 VARCHAR(500), f3 VARCHAR(500), +f4 VARCHAR(500), f5 VARCHAR(500), f6 VARCHAR(500), +f7 VARCHAR(500), +PRIMARY KEY (f1, f2, f3, f4), +KEY k1 (f5, f6, f7) +) charset latin1 ENGINE = InnoDB; +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 3015 const,const,const,const,const,const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f3 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 3015 const,const,const,const,const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f3` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +EXPLAIN SELECT f5 FROM t1 FORCE INDEX (k1) WHERE +f1 = 'a' AND f2 = 'a' AND f4 = 'a' AND +f5 = 'a' AND f6 = 'a' AND f7 = 'a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k1 k1 2513 const,const,const,const,const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f5` AS `f5` from `test`.`t1` FORCE INDEX (`k1`) where ((`test`.`t1`.`f7` = 'a') and (`test`.`t1`.`f6` = 'a') and (`test`.`t1`.`f5` = 'a') and (`test`.`t1`.`f4` = 'a') and (`test`.`t1`.`f2` = 'a') and (`test`.`t1`.`f1` = 'a')) +DROP TABLE t1; +# +# Unique extended key +# +CREATE TABLE t1 +( +pk INT NOT NULL auto_increment, +f1 INT NOT NULL, +KEY (f1), +PRIMARY KEY (pk) +) ENGINE = INNODB; +CREATE TABLE t2 +( +f1 INT, +f2 INT +) ENGINE = INNODB; +INSERT INTO t1(f1) VALUES (1),(2); +INSERT INTO t1(f1) SELECT f1 + 2 FROM t1; +INSERT INTO t1(f1) SELECT f1 + 4 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t2 VALUES (1,1), (2,2); +EXPLAIN SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t1 NULL eq_ref f1 f1 8 test.t2.f2,test.t2.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1` from `test`.`t2` join `test`.`t1` IGNORE INDEX (PRIMARY) where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t1`.`pk` = `test`.`t2`.`f1`)) +FLUSH STATUS; +SELECT t2.f1 FROM t2 JOIN t1 IGNORE INDEX(primary) ON t2.f1 = t1.pk and t2.f2 = t1.f1; +f1 +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +DROP TABLE t1, t2; +# +# Bug#20430526 ADDRESSSANITIZER: HEAP-BUFFER-OVERFLOW IN +# FIELD_BLOB::GET_KEY_IMAGE FLOAT8STORE +# +CREATE TABLE t1 +(a GEOMETRY NOT NULL SRID 0, SPATIAL KEY(a)) ENGINE=INNODB; +INSERT INTO t1 VALUES (point(7, 7)); +SELECT st_astext(a) FROM t1 WHERE st_equals(a, point(7, 7)); +st_astext(a) +POINT(7 7) +DROP TABLE t1; +# +# Bug #31617858 INCORRECT RESULTS WHEN USING INDEX ON LONG CHARACTER COLS. +# +CREATE TABLE t( +a VARCHAR(256) NOT NULL, +i VARCHAR(512) NOT NULL, +PRIMARY KEY (a), +KEY (i)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +INSERT INTO t VALUES +('aaa12345678','aaa'), ('aaa2','aaa'), ('aaa4','aaa'), +('aaa3','aaa'),('aaa1','aaa'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index i i 2050 NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`i` AS `i` from `test`.`t` FORCE INDEX (`i`) where (`test`.`t`.`a` like '%aaa12345678%') +SELECT DISTINCT(i) FROM t FORCE INDEX(i) WHERE a LIKE '%aaa12345678%'; +i +aaa +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/innodb_tmp_table_heap_to_disk.result-pq b/mysql-test/r/innodb_tmp_table_heap_to_disk.result-pq new file mode 100644 index 000000000..ba15e5102 --- /dev/null +++ b/mysql-test/r/innodb_tmp_table_heap_to_disk.result-pq @@ -0,0 +1,125 @@ +set @old_heap_size= @@max_heap_table_size; +set max_heap_table_size = 16384; +select * from information_schema.collations order by id limit 1; +COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN PAD_ATTRIBUTE +big5_chinese_ci big5 1 Yes Yes 1 PAD SPACE +set optimizer_switch='firstmatch=off'; +set optimizer_switch='loosescan=off'; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +create table t1 ( +a int not null, +b int not null, +c datetime default null +); +insert into t1 values +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,null), +(398341,67,'2006-02-20 04:48:44'), (254,67,null),(1120,67,null), +(406988,67,'2006-02-23 17:07:22'), (255,67,null), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,null),(1,67,'2006-02-23 15:01:35'), +(223456,67,null),(4101,67,null),(1133,67,null), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'); +insert into t1 select a+10, b+10, c from t1; +insert into t1 select a+20, b+20, c from t1; +insert into t1 select a+30, b+30, c from t1; +insert into t1 select a+40, b+40, c from t1; +insert into t1 select a+50, b+50, c from t1; +insert into t1 select a+60, b+60, c from t1; +insert into t1 select a+70, b+70, c from t1; +insert into t1 select a+80, b+80, c from t1; +drop table if exists t11; +Warnings: +Note 1051 Unknown table 'test.t11' +create table t11 select * from t1; +insert into t1 select a+80, b+80, c from t1; +explain select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 100.00 Using filesort +1 SIMPLE NULL eq_ref 4 test.t1.a x 100.00 NULL +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL x 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (``.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 1 +select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +a b c +1 67 2006-02-23 15:01:35 +set optimizer_switch='materialization=off'; +explain select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL x 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 1 +select * from t1 where a in (select a from t11) order by 1, 2, 3 limit 1; +a b c +1 67 2006-02-23 15:01:35 +drop table t11; +set optimizer_switch=default; +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t1 (id INTEGER); +CREATE TABLE t2 (id INTEGER); +INSERT INTO t1 (id) VALUES (1), (1), (1),(1); +INSERT INTO t1 (id) SELECT id FROM t1; +/* 8 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 12 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 16 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 20 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 24 */ +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t2 SELECT id + 2000 FROM t1 limit 4000; +explain select * from t1 union select * from t2 order by 1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL x 100.00 NULL +2 UNION t2 NULL ALL NULL NULL NULL NULL x 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL x NULL Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`id` AS `id` from `test`.`t2` order by `id` limit 1 +select * from t1 union select * from t2 order by 1 limit 1; +id +1 +explain SELECT SUM(id) sm FROM t1 group by id order by sm limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL x 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sm` from `test`.`t1` group by `test`.`t1`.`id` order by `sm` limit 1 +SELECT SUM(id) sm FROM t1 group by id order by sm limit 1; +sm +128 +explain SELECT SUM(DISTINCT t1.id) sm FROM t1 left join t2 on t1.id=t2.id GROUP BY t1.id order by sm limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL x 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL x 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(distinct `test`.`t1`.`id`) AS `sm` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where true group by `test`.`t1`.`id` order by `sm` limit 1 +SELECT SUM(DISTINCT t1.id) sm FROM t1 left join t2 on t1.id=t2.id GROUP BY t1.id order by sm limit 1; +sm +1 +set max_heap_table_size = @old_heap_size; +drop table t1; +drop table t2; +# diff --git a/mysql-test/r/insert_update.result-pq b/mysql-test/r/insert_update.result-pq new file mode 100644 index 000000000..947f239f8 --- /dev/null +++ b/mysql-test/r/insert_update.result-pq @@ -0,0 +1,1080 @@ +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 30 +INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 130 +INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000; +SELECT * FROM t1; +a b c +1 2 10 +3 4 1020 +5 6 130 +INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000; +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4; +ERROR 23000: Duplicate entry '4' for key 't1.b' +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +TRUNCATE TABLE t1; +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 6 30 +8 9 60 +INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 0 30 +8 9 60 +INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT *, VALUES(a) FROM t1; +a b c VALUES(a) +1 2 10 NULL +3 4 127 NULL +5 0 30 NULL +8 9 60 NULL +2 1 11 NULL +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT *, VALUES(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Warning 1#81 'VALUES function' is deprecated and will be removed in a future release. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,NULL AS `VALUES(a)` from `test`.`t1` +explain select * from t1 where values(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where false +DROP TABLE t1; +create table t1(a int primary key, b int); +insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5); +select * from t1; +a b +1 1 +2 2 +3 3 +4 4 +5 5 +insert into t1 values(4,14),(5,15),(6,16),(7,17),(8,18) +on duplicate key update b=b+10; +affected rows: 7 +info: Records: 5 Duplicates: 2 Warnings: 0 +select * from t1; +a b +1 1 +2 2 +3 3 +4 14 +5 15 +6 16 +7 17 +8 18 +replace into t1 values(5,25),(6,26),(7,27),(8,28),(9,29); +affected rows: 9 +info: Records: 5 Duplicates: 4 Warnings: 0 +select * from t1; +a b +1 1 +2 2 +3 3 +4 14 +5 25 +6 26 +7 27 +8 28 +9 29 +drop table t1; +CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); +INSERT t1 VALUES (1,2,10), (3,4,20); +INSERT t1 SELECT 5,6,30 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 30 +INSERT t1 SELECT 5,7,40 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 20 +5 6 130 +INSERT t1 SELECT 8,4,50 FROM DUAL ON DUPLICATE KEY UPDATE c=c+1000; +SELECT * FROM t1; +a b c +1 2 10 +3 4 1020 +5 6 130 +INSERT t1 SELECT 1,4,60 FROM DUAL ON DUPLICATE KEY UPDATE c=c+10000; +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +INSERT t1 SELECT 1,9,70 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100000, b=4; +ERROR 23000: Duplicate entry '4' for key 't1.b' +SELECT * FROM t1; +a b c +1 2 10010 +3 4 1020 +5 6 130 +TRUNCATE TABLE t1; +INSERT t1 VALUES (1,2,10), (3,4,20); +CREATE TABLE t2 (a INT, b INT, c INT, d INT); +INSERT t2 VALUES (5,6,30,1), (7,4,40,1), (8,9,60,1); +INSERT t2 VALUES (2,1,11,2), (7,4,40,2); +INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=t1.c+100; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 6 30 +8 9 60 +INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; +SELECT * FROM t1; +a b c +1 2 10 +3 4 120 +5 0 30 +8 9 60 +INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a); +ERROR 23000: Column 'c' in field list is ambiguous +INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT *, VALUES(a) FROM t1; +a b c VALUES(a) +1 2 10 NULL +3 4 127 NULL +5 0 30 NULL +8 9 60 NULL +2 1 11 NULL +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 +( +a BIGINT UNSIGNED, +b BIGINT UNSIGNED, +PRIMARY KEY (a) +); +INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = +IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +45 1 +INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b = +IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +45 2 +INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = +IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +45 2 +DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +INSERT INTO t1 SELECT 1, j; +ERROR 42S22: Unknown column 'j' in 'field list' +DROP TABLE t1; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, c INT); +INSERT INTO t1 SELECT 1, a FROM t2 NATURAL JOIN t3 +ON DUPLICATE KEY UPDATE j= a; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (i INT PRIMARY KEY, j INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (1), (3); +INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a; +ERROR 42S22: Unknown column 'a' in 'field list' +DROP TABLE t1,t2; +SET SQL_MODE = 'TRADITIONAL'; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL); +INSERT INTO t1 (a) VALUES (1); +ERROR HY000: Field 'b' doesn't have a default value +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE a = b; +ERROR HY000: Field 'b' doesn't have a default value +INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE b = b; +ERROR HY000: Field 'b' doesn't have a default value +SELECT * FROM t1; +a b +DROP TABLE t1; +CREATE TABLE t1 (f1 INT AUTO_INCREMENT PRIMARY KEY, +f2 VARCHAR(5) NOT NULL UNIQUE); +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +DROP TABLE t1; +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` varchar(10) NOT NULL UNIQUE, +tim1 timestamp default '2003-01-01 00:00:00' on update current_timestamp +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (f1) VALUES ("test1"); +SELECT id, f1 FROM t1; +id f1 +1 test1 +REPLACE INTO t1 VALUES (0,"test1",null); +SELECT id, f1 FROM t1; +id f1 +0 test1 +DROP TABLE t1; +SET SQL_MODE=''; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 CHAR(1) UNIQUE KEY, +cnt INT DEFAULT 1 +); +INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C'); +SELECT * FROM t1; +id c1 cnt +1 A 1 +2 B 1 +3 C 1 +INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z') +ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +id c1 cnt +1 A 2 +2 B 1 +3 C 1 +4 X 1 +5 Y 1 +6 Z 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +cnt INT DEFAULT 1 +); +INSERT INTO t1 (id,c1) VALUES (1,10); +SELECT * FROM t1; +id c1 cnt +1 10 1 +CREATE TABLE t2 (id INT, c1 INT); +INSERT INTO t2 VALUES (1,NULL), (2,2); +INSERT INTO t1 (id,c1) SELECT 1,NULL +ON DUPLICATE KEY UPDATE c1=NULL; +ERROR 23000: Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 10 1 +INSERT IGNORE INTO t1 (id,c1) SELECT 1,NULL +ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +Warnings: +Warning 1048 Column 'c1' cannot be null +Warning 1048 Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 0 2 +INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2 +ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +Warnings: +Warning 1048 Column 'c1' cannot be null +Warning 1048 Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 0 3 +2 2 1 +DROP TABLE t1; +DROP TABLE t2; +create table t1(f1 int primary key, +f2 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP); +insert into t1(f1) values(1); +select @stamp1:=f2 from t1; +@stamp1:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t1(f1) values(1) on duplicate key update f1=1; +select @stamp2:=f2 from t1; +@stamp2:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if( @stamp1 = @stamp2, "correct", "wrong"); +if( @stamp1 = @stamp2, "correct", "wrong") +correct +drop table t1; +# Bug 21774967: MYSQL ACCEPTS NON-ASCII IN ASCII COLUMNS +CREATE TABLE t1( +a CHAR(20) CHARACTER SET ascii, +b VARCHAR(20) CHARACTER SET ascii, +c TEXT(20) CHARACTER SET ascii +); +CREATE TABLE t2( +a CHAR(20) CHARACTER SET ascii COLLATE ascii_general_ci, +b VARCHAR(20) CHARACTER SET ascii COLLATE ascii_general_ci, +c TEXT(20) CHARACTER SET ascii COLLATE ascii_general_ci +); +CREATE TABLE t3( +a CHAR(20) CHARACTER SET ascii COLLATE ascii_bin, +b VARCHAR(20) CHARACTER SET ascii COLLATE ascii_bin, +c TEXT(20) CHARACTER SET ascii COLLATE ascii_bin +); +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO t1 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO t1 values(x'6162', x'6162', x'6162'); +UPDATE t1 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 1 +INSERT INTO t2 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO t2 values(x'6162', x'6162', x'6162'); +UPDATE t2 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 1 +INSERT INTO t3 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO t3 values(x'6162', x'6162', x'6162'); +UPDATE t3 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 1 +SET SQL_MODE=""; +INSERT INTO t1 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO t1 values(x'6162', x'6162', x'6162'); +UPDATE t1 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 3 +INSERT INTO t2 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO t2 values(x'6162', x'6162', x'6162'); +UPDATE t2 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 3 +INSERT INTO t3 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO t3 values(x'6162', x'6162', x'6162'); +UPDATE t3 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 3 +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO v1 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO v1 values(x'6162', x'6162', x'6162'); +UPDATE v1 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 4 +INSERT INTO v2 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO v2 values(x'6162', x'6162', x'6162'); +UPDATE v2 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 4 +INSERT INTO v3 values(x'8142', x'8142', x'8142'); +ERROR HY000: Incorrect string value: '\x81B' for column 'a' at row 1 +INSERT INTO v3 values(x'6162', x'6162', x'6162'); +UPDATE v3 SET a=x'8243' where a=x'6162'; +ERROR HY000: Incorrect string value: '\x82C' for column 'a' at row 4 +SET SQL_MODE=""; +INSERT INTO v1 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO v1 values(x'6162', x'6162', x'6162'); +UPDATE v1 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 6 +INSERT INTO v2 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO v2 values(x'6162', x'6162', x'6162'); +UPDATE v2 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 6 +INSERT INTO v3 values(x'8142', x'8142', x'8142'); +Warnings: +Warning 1366 Incorrect string value: '\x81B' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\x81B' for column 'c' at row 1 +INSERT INTO v3 values(x'6162', x'6162', x'6162'); +UPDATE v3 SET a=x'8243' where a=x'6162'; +Warnings: +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\x82C' for column 'a' at row 6 +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +CREATE TABLE t_latin1( +a CHAR(20) CHARACTER SET latin1, +b VARCHAR(20) CHARACTER SET latin1, +c TEXT(20) CHARACTER SET latin1 +); +CREATE TABLE t_gb2312( +a CHAR(20) CHARACTER SET gb2312, +b VARCHAR(20) CHARACTER SET gb2312, +c TEXT(20) CHARACTER SET gb2312 +); +CREATE TABLE t_utf8( +a CHAR(20) CHARACTER SET utf8, +b VARCHAR(20) CHARACTER SET utf8, +c TEXT(20) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO t_latin1 values(x'f242', x'f242', x'f242'); +UPDATE t_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO t_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE t_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO t_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO t_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +ERROR HY000: Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +UPDATE t_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE t_utf8 SET a=x'f69687' where a=x'e69687'; +ERROR HY000: Incorrect string value: '\xF6\x96\x87' for column 'a' at row 1 +SET SQL_MODE=""; +INSERT INTO t_latin1 values(x'f242', x'f242', x'f242'); +UPDATE t_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO t_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE t_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO t_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO t_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +Warnings: +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'c' at row 1 +UPDATE t_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE t_utf8 SET a=x'f69687' where a=x'e69687'; +Warnings: +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 2 +CREATE VIEW v_latin1 AS SELECT * FROM t_latin1; +CREATE VIEW v_gb2312 AS SELECT * FROM t_gb2312; +CREATE VIEW v_utf8 AS SELECT * FROM t_utf8; +SET SQL_MODE="STRICT_TRANS_TABLES"; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO v_latin1 values(x'f242', x'f242', x'f242'); +UPDATE v_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO v_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE v_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO v_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO v_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +ERROR HY000: Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +UPDATE v_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE v_utf8 SET a=x'f69687' where a=x'e69687'; +ERROR HY000: Incorrect string value: '\xF6\x96\x87' for column 'a' at row 4 +SET SQL_MODE=""; +INSERT INTO v_latin1 values(x'f242', x'f242', x'f242'); +UPDATE v_latin1 SET a=x'f343' where a=x'f242'; +INSERT INTO v_gb2312 values(x'e5ac', x'e5ac', x'e5ac'); +UPDATE v_gb2312 SET a=x'e6af' where a=x'e5ac'; +INSERT INTO v_utf8 values(x'e4b8ad', x'e4b8ad', x'e4b8ad'); +INSERT INTO v_utf8 values(x'f4b8ad', x'f4b8ad', x'f4b8ad'); +Warnings: +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'a' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'b' at row 1 +Warning 1366 Incorrect string value: '\xF4\xB8\xAD' for column 'c' at row 1 +UPDATE v_utf8 SET a=x'e69687' where a=x'e4b8ad'; +UPDATE v_utf8 SET a=x'f69687' where a=x'e69687'; +Warnings: +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 4 +Warning 1366 Incorrect string value: '\xF6\x96\x87' for column 'a' at row 5 +DROP VIEW v_latin1; +DROP VIEW v_gb2312; +DROP VIEW v_utf8; +DROP TABLE t_latin1; +DROP TABLE t_gb2312; +DROP TABLE t_utf8; +SET SQL_MODE=DEFAULT; +# WL#5094: Refactor DML statements +# Semantic changes in INSERT ... ON DUPLICATE KEY +CREATE TABLE t0 (k INTEGER PRIMARY KEY); +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (3); +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Allowed: Reference column from a single table +INSERT INTO t0 +SELECT a FROM t1 +ON DUPLICATE KEY UPDATE k= a + t1.a + 10; +SELECT * FROM t0; +k +3 +12 +14 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Allowed: Reference column from a join over multiple tables +INSERT INTO t0 +SELECT t1.a FROM t1 JOIN t2 ON t1.a=t2.a +ON DUPLICATE KEY UPDATE k= t1.a + t2.a + 10; +SELECT * FROM t0; +k +2 +3 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +INSERT INTO t0 +SELECT a FROM t1 JOIN t2 USING (a) +ON DUPLICATE KEY UPDATE k= t1.a + t2.a + 10; +SELECT * FROM t0; +k +2 +3 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +INSERT INTO t0 +SELECT a FROM t1 LEFT JOIN t2 USING (a) +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +INSERT INTO t0 +SELECT DISTINCT a FROM t1 +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Allowed: Wrap a distinct query in a derived table +INSERT INTO t0 +SELECT a FROM (SELECT DISTINCT a FROM t1) AS dt +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Not allowed: Reference column from an explicitly grouped query +INSERT INTO t0 +SELECT a FROM t1 GROUP BY a +ON DUPLICATE KEY UPDATE k= a + 10; +ERROR 42S22: Unknown column 'a' in 'field list' +# Not allowed: Reference column from an implicitly grouped query +INSERT INTO t0 +SELECT SUM(a) FROM t1 +ON DUPLICATE KEY UPDATE k= a + 10; +ERROR 42S22: Unknown column 'a' in 'field list' +# Allowed: Wrap a grouped query in a derived table +INSERT INTO t0 +SELECT a FROM (SELECT a FROM t1 GROUP BY a) AS dt +ON DUPLICATE KEY UPDATE k= a + 10; +SELECT * FROM t0; +k +3 +11 +12 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +# Not allowed: Reference column from a UNION query +INSERT INTO t0 +SELECT a FROM t1 UNION SELECT a FROM t2 +ON DUPLICATE KEY UPDATE k= a + 10; +ERROR 42S22: Unknown column 'a' in 'field list' +# Allowed:: Wrap a UNION query in a derived table +INSERT INTO t0 +SELECT a +FROM (SELECT a, COUNT(*) AS c FROM t1 GROUP BY a +UNION +SELECT a, COUNT(*) AS c FROM t2 GROUP BY a) AS dt +ON DUPLICATE KEY UPDATE k= dt.a + dt.c + 10; +SELECT * FROM t0; +k +12 +13 +14 +DELETE FROM t0; +INSERT INTO t0 SELECT a FROM t1 UNION SELECT a FROM t2; +DROP TABLE t0, t1, t2; +# Bug#25526439: Assertion failed: is_fixed_or_outer_ref(this) +CREATE TABLE t1 ( +a INTEGER NOT NULL +); +INSERT INTO t1 VALUES(0); +CREATE TABLE t2 ( +d INTEGER +); +# Query from bug report +INSERT INTO t1(a) VALUES (1) +ON DUPLICATE KEY UPDATE a= (SELECT d FROM t2 GROUP BY 1); +SELECT * FROM t1; +a +0 +1 +# Similar query with a simple query block +INSERT INTO t1(a) SELECT 1 +ON DUPLICATE KEY UPDATE a= (SELECT d FROM t2 GROUP BY 1); +SELECT * FROM t1; +a +0 +1 +1 +# Similar query with a UNION +INSERT INTO t1(a) SELECT 1 UNION SELECT 2 +ON DUPLICATE KEY UPDATE a= (SELECT d FROM t2 GROUP BY 1); +SELECT * FROM t1; +a +0 +1 +1 +1 +2 +DROP TABLE t1, t2; +# Bug#25071305: Assertion failed: first_execution || +# !tl->is_view_or_derived() || tl->is_merged() +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(b INTEGER); +INSERT INTO t2 VALUES (1),(1); +INSERT INTO t1(a) VALUES (1) +ON DUPLICATE KEY UPDATE a= (SELECT b FROM (SELECT b FROM t2) AS w); +DROP TABLE t1, t2; +# Bug#24716127: Incorrect behavior by insert statement with +# "on duplicate key update" +CREATE TABLE t1(a INTEGER, b INTEGER, PRIMARY KEY(a,b)); +CREATE TABLE t2(c2 INTEGER NOT NULL PRIMARY KEY); +CREATE TABLE t3(c3 INTEGER NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +INSERT INTO t1 VALUES (1,1) +ON DUPLICATE KEY UPDATE a= (SELECT c2 +FROM t2 JOIN t3 ON c3 = c2 +WHERE c2 = 1); +SELECT * FROM t1; +a b +1 1 +INSERT INTO t1 +SELECT 1, 1 FROM t2 +ON DUPLICATE KEY UPDATE a= t2.c2 + 100, b= t2.c2 + 100; +SELECT * FROM t1; +a b +1 1 +101 101 +DROP TABLE t1, t2, t3; +# +# Bug#28995498 INSERT IS FINE BUT "ON DUPLICATE UPDATE" UPDATING WRONG DATA +# +CREATE TABLE t1 (pk VARCHAR(10) PRIMARY KEY, col VARCHAR(10)); +INSERT INTO t1 VALUES (1 , "Carmen" ),(2 , "Martin" ); +INSERT INTO t1 SELECT * FROM t1 AS source +ON DUPLICATE KEY UPDATE t1.col = source.col; +SELECT * FROM t1 ; +pk col +1 Carmen +2 Martin +DROP TABLE t1; +# WL#6312: Referencing new row in INSERT .. VALUES .. ON DUPLICATE KEY UPDATE. +CREATE TABLE t0(a INT PRIMARY KEY, b INT); +CREATE TABLE t1(x INT PRIMARY KEY, y INT); +# Allowed: Referencing VALUES from the update list. +INSERT INTO t0 VALUES (1, 3), (2, 3) AS n(a, b) +ON DUPLICATE KEY UPDATE b= t0.b + n.b; +SELECT * FROM t0; +a b +1 3 +2 3 +INSERT INTO t0 VALUES (1, 3), (2, 3) AS n(a, b) +ON DUPLICATE KEY UPDATE b= t0.b + n.b; +SELECT * FROM t0; +a b +1 6 +2 6 +# Allowed: Not naming columns for VALUES table. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS n +ON DUPLICATE KEY UPDATE b= t0.b + n.b; +SELECT * FROM t0; +a b +1 11 +2 13 +# Not allowed: Naming the VALUES table the same as the table inserted into. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS t0 +ON DUPLICATE KEY UPDATE b= t0.a; +ERROR 42000: Not unique table/alias: 't0' +# Not allowed: Naming multiple VALUES columns the same. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS n(a, a) +ON DUPLICATE KEY UPDATE b= t0.a; +ERROR 42S21: Duplicate column name 'a' +# Not allowed: Unequal number of columns in VALUES table and inserted rows. +INSERT INTO t0 VALUES (1, 5), (2, 7) AS n(a) +ON DUPLICATE KEY UPDATE b= t0.a; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +# Allowed: Referencing VALUES table from within a subquery. +INSERT INTO t1 VALUES (1, 50), (2, 100); +INSERT INTO t0 VALUES (1, 10), (2, 20) AS n +ON DUPLICATE KEY UPDATE b= (SELECT y FROM t1 WHERE x = n.a); +SELECT * FROM t0; +a b +1 50 +2 100 +# Allowed: Overriding the VALUES table name from within a subquery. +INSERT INTO t0 VALUES (1, 10) AS n(a, b) +ON DUPLICATE KEY UPDATE b= 20 + (SELECT n.y FROM t1 AS n WHERE n.x = t0.a); +SELECT * FROM t0; +a b +1 70 +2 100 +# Allowed: VALUES table name overriding table names. +CREATE TABLE n(a INT, b INT); +INSERT INTO t0 VALUES (1, 10) AS n(a, b) +ON DUPLICATE KEY UPDATE b= n.b; +SELECT * FROM t0; +a b +1 10 +2 100 +# Allowed: FROM clause in subquery overriding VALUES table name. +INSERT INTO n VALUES (1, 50); +INSERT INTO t0 VALUES (1, 20) AS n(a, b) +ON DUPLICATE KEY UPDATE b= (SELECT n.b FROM n); +SELECT * FROM t0; +a b +1 50 +2 100 +# Allowed: Discrepancy between specified insert columns and column names of VALUES table. +CREATE TABLE t2(a INT, b INT PRIMARY KEY, c INT); +INSERT INTO t2 VALUES (1, 10, 100); +INSERT INTO t2(b, c) VALUES (10, 20) AS n(a, b) +ON DUPLICATE KEY UPDATE c= n.b; +SELECT * FROM t2; +a b c +1 10 20 +# Allowed: Using the «INSERT .. SET» syntax. +DROP TABLE t0; +CREATE TABLE t0(a INT PRIMARY KEY, b INT); +INSERT INTO t0 VALUES (1, 10); +INSERT INTO t0 SET a=1, b=20 AS n +ON DUPLICATE KEY UPDATE b= n.b; +SELECT * FROM t0; +a b +1 20 +# Allowed: Referring to the VALUES table from inside functions. +DROP TABLE t1; +CREATE TABLE t1(a BIGINT UNSIGNED PRIMARY KEY, b BIGINT UNSIGNED); +INSERT INTO t1 VALUES (45, 1) AS n +ON DUPLICATE KEY UPDATE b= IF(n.b > t1.b, n.b, t1.b); +SELECT * FROM t1; +a b +45 1 +INSERT INTO t1 VALUES (45, 2) AS n +ON DUPLICATE KEY UPDATE b= IF(n.b > t1.b, n.b, t1.b); +SELECT * FROM t1; +a b +45 2 +INSERT INTO t1 VALUES (45, 1) AS n +ON DUPLICATE KEY UPDATE b= IF(n.b > t1.b, n.b, t1.b); +SELECT * FROM t1; +a b +45 2 +# Allowed: Using ODKU when inserting into a view. +DROP TABLE t1; +CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 3, b INT); +CREATE VIEW v AS SELECT b FROM t1; +INSERT INTO t1 VALUES(3, 2); +INSERT INTO v VALUES(3) AS n +ON DUPLICATE KEY UPDATE b= n.b; +SELECT * FROM t1; +a b +3 3 +SELECT * FROM v; +b +3 +# Allowed: Creating a VALUES alias with no ODKU statement. +DROP TABLE t1; +CREATE TABLE t1(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES(1, 10) as n; +SELECT * FROM t1; +a b +1 10 +# Not allowed: Referencing the VALUES table inside the VALUES clause. +INSERT INTO t1 VALUES(n.a, 10) as n +ON DUPLICATE KEY UPDATE b= n.b; +ERROR 42S22: Unknown column 'n.a' in 'field list' +# If a table reference within an update expression does not find the +# column in the VALUES table, it should look further in outer contexts. +DROP TABLE n; +CREATE TABLE n(x INT, y INT); +DROP TABLE t0; +CREATE TABLE t0(a INT PRIMARY KEY, b INT); +DELETE FROM t0; +INSERT INTO t0 VALUES(1, 10); +INSERT INTO n VALUES(1, 11); +INSERT INTO t0 VALUES(1, 19) as n(a, b) +ON DUPLICATE KEY UPDATE b= (SELECT n.y FROM n); +SELECT * FROM t0; +a b +1 11 +# Allowed: Referring to the old row of the insert table from within an +# ODKU update expression. +DELETE FROM t0; +INSERT INTO t0 VALUES(1, 10); +INSERT INTO t0 VALUES(2, 20); +INSERT INTO t0 VALUES(2, 29) as n +ON DUPLICATE KEY UPDATE b= t0.b+1; +SELECT * FROM t0; +a b +1 10 +2 21 +DROP TABLE t0; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE n; +DROP VIEW v; +# WL#6312: Referencing new row in INSERT .. VALUES .. ON DUPLICATE KEY UPDATE. +# Compare old and new syntax (VALUES() vs. AS new) for regressions. +# binlog_unsafe.test. More than one unique key. +# Old syntax. +CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY); +INSERT INTO insert_2_keys values (1, 1); +INSERT INTO insert_2_keys VALUES (1, 2) +ON DUPLICATE KEY UPDATE a= VALUES(a) + 10, b= VALUES(b) + 10; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM insert_2_keys; +a b +11 12 +DROP TABLE insert_2_keys; +# New syntax. +CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY); +INSERT INTO insert_2_keys values (1, 1); +INSERT INTO insert_2_keys VALUES (1, 2) AS n +ON DUPLICATE KEY UPDATE a= n.a + 10, b= n.b + 10; +SELECT * FROM insert_2_keys; +a b +11 12 +DROP TABLE insert_2_keys; +# json_functions.inc. JSON should work with INSERT .. ON DUPLICATE KEY UPDATE. +# Old syntax. +CREATE TABLE t(id INT PRIMARY KEY, j JSON); +INSERT INTO t VALUES (1, '[1]') +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t; +id j +1 [1] +INSERT INTO t VALUES (1, '[1,2]') +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t; +id j +1 {"ab": [1, 2]} +INSERT INTO t VALUES (1, '[1,2,3]') +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t; +id j +1 {"abc": [1, 2, 3]} +DROP TABLE t; +# New syntax. +CREATE TABLE t(id INT PRIMARY KEY, j JSON); +INSERT INTO t VALUES (1, '[1]') AS n +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", n.j); +SELECT * FROM t; +id j +1 [1] +INSERT INTO t VALUES (1, '[1,2]') AS n +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", n.j); +SELECT * FROM t; +id j +1 {"ab": [1, 2]} +INSERT INTO t VALUES (1, '[1,2,3]') AS n +ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", n.j); +SELECT * FROM t; +id j +1 {"abc": [1, 2, 3]} +DROP TABLE t; +# errors.test. Subquery with VALUES table reference. +# Old syntax. +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (10); +INSERT INTO t2(a, b) VALUES (1, 0); +INSERT INTO t2(a, b) VALUES (1, 0) +ON DUPLICATE KEY UPDATE b= (SELECT VALUES(a) + 2 FROM t1); +Warnings: +Warning 1287 The VALUES function is deprecated and will be removed in a future release. It always returns NULL in this context. If you meant to access a value from the VALUES clause of the INSERT statement, consider using an alias (INSERT INTO ... VALUES (...) AS alias) and reference alias.col instead of VALUES(col) in the ON DUPLICATE KEY UPDATE clause. +SELECT * FROM t2; +a b +1 NULL +DROP TABLE t1; +DROP TABLE t2; +# New syntax. +CREATE TABLE t1 (a INT); +CREATE TABLE t2(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (10); +INSERT INTO t2(a, b) VALUES (1, 0); +INSERT INTO t2(a, b) VALUES (1, 0) AS n +ON DUPLICATE KEY UPDATE b= (SELECT n.a + 2 FROM t1); +SELECT * FROM t2; +a b +1 3 +DROP TABLE t1; +DROP TABLE t2; +# func_test.test. New syntax should work inside functions. +# Old syntax. +CREATE TABLE t1(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (1, 3) +ON DUPLICATE KEY UPDATE b= GREATEST(b, VALUES(b)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +1 3 +DROP TABLE t1; +# New syntax. +CREATE TABLE t1(a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (1, 3) AS n +ON DUPLICATE KEY UPDATE b= GREATEST(t1.b, n.b); +SELECT * FROM t1; +a b +1 3 +DROP TABLE t1; +# type_blob-bug13901905_myisam.test. INSERT .. SET syntax should work with blobs. +# Old syntax. +CREATE TABLE t1 (a INT, b BLOB, UNIQUE KEY(a)); +INSERT INTO t1 SET b='11', a=0 +ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +INSERT INTO t1 SET b='11', a=0 +ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +a b +11 0 +DROP TABLE t1; +# New syntax +CREATE TABLE t1 (a INT, b BLOB, UNIQUE KEY(a)); +INSERT INTO t1 SET b='11', a=0 AS n +ON DUPLICATE KEY UPDATE b= n.a, a= n.b; +INSERT INTO t1 SET b='11', a=0 AS n +ON DUPLICATE KEY UPDATE b= n.a, a= n.b; +SELECT * FROM t1; +a b +11 0 +DROP TABLE t1; +# insert-bug25361251.test. Text fields should work. +# Old syntax. +CREATE TABLE t1(id INT NOT NULL, text1 TEXT, text2 TEXT, PRIMARY KEY (id)); +INSERT INTO t1 VALUES (0, "x", "x"), (1, "y", "y"); +INSERT INTO t1 (id, text1, text2) VALUES (0, "x", "y") +ON DUPLICATE KEY UPDATE text1 = VALUES(text1), text2 = VALUES(text2); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +SELECT * FROM t1; +id text1 text2 +0 x y +1 y y +DROP TABLE t1; +# New syntax. +CREATE TABLE t1(id INT NOT NULL, text1 TEXT, text2 TEXT, PRIMARY KEY (id)); +INSERT INTO t1 VALUES (0, "x", "x"), (1, "y", "y"); +INSERT INTO t1 (id, text1, text2) VALUES (0, "x", "y") AS n +ON DUPLICATE KEY UPDATE text1 = n.text1, text2 = n.text2; +SELECT * FROM t1; +id text1 text2 +0 x y +1 y y +DROP TABLE t1; +# Bug#30051303: SERVER CRASHED WHILE RUNNING INSERT ON DUPLICATE KEY +# UPDATE OVER VIEW +CREATE TABLE t0(a INT PRIMARY KEY, b INT, c INT); +CREATE VIEW v AS SELECT t0.a AS va, t0.b AS vb, t0.c AS vc FROM t0; +INSERT INTO v(va, vb, vc) VALUES(1, 10, 100) AS n +ON DUPLICATE KEY UPDATE vc= 199; +SELECT * FROM t0; +a b c +1 10 100 +DROP TABLE t0; +DROP VIEW v; diff --git a/mysql-test/r/invisible_indexes.result-pq b/mysql-test/r/invisible_indexes.result-pq new file mode 100644 index 000000000..d2a20aa74 --- /dev/null +++ b/mysql-test/r/invisible_indexes.result-pq @@ -0,0 +1,600 @@ +# +# WL#8697: Invisible Indexes +# +SET SESSION information_schema_stats_expiry=0; +# Test of ALTER INDEX syntax. +CREATE TABLE t1 ( a INT, KEY (a) ); +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE YES NULL +DROP TABLE t1; +# Test of CREATE INDEX syntax with invisible indexes. +CREATE TABLE t1 ( a INT, b INT ); +CREATE INDEX a_invisible ON t1(a) INVISIBLE; +CREATE INDEX b_visible ON t1(a) VISIBLE; +Warnings: +Warning 1831 Duplicate index 'b_visible' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +CREATE INDEX a_b_invisible ON t1(a, b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a_invisible 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 b_visible 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 a_b_invisible 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 a_b_invisible 2 b A 0 NULL NULL YES BTREE NO NULL +DROP TABLE t1; +# Test that invisible indexes are not used. +CREATE TABLE t1 ( a INT, KEY (a) ); +CREATE TABLE t2 ( a INT, KEY (a) INVISIBLE ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT a FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +ALTER TABLE t2 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL a 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +DROP TABLE t1, t2; +# Test that renaming an index does not change visibility and vice versa. +CREATE TABLE t1 ( +a INT, INDEX (a), +b INT, INDEX (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 b 1 b A 0 NULL NULL YES BTREE NO NULL +ALTER TABLE t1 RENAME INDEX a TO a1; +ALTER TABLE t1 RENAME INDEX b TO b1; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a1 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 b1 1 b A 0 NULL NULL YES BTREE NO NULL +ALTER TABLE t1 ALTER INDEX a1 INVISIBLE; +ALTER TABLE t1 ALTER INDEX b1 VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a1 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 b1 1 b A 0 NULL NULL YES BTREE YES NULL +DROP TABLE t1; +# Test of SHOW CREATE TABLE. +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (a) VISIBLE, +INDEX (b) INVISIBLE, +INDEX (c) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) /*!80000 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# Test that primary key indexes can't be made invisible. +CREATE TABLE t1 ( a INT, PRIMARY KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +ALTER TABLE t1 ALTER INDEX PRIMARY INVISIBLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRIMARY INVISIBLE' at line 1 +ALTER TABLE t1 ADD PRIMARY KEY (a) INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +# +# Currently we allow to name the primary key index, but the name is +# silently changed to PRIMARY. If this behavior changes in the future, +# we need to take some additional measures to rule out invisible primary +# key indexes. The below two tests serve as triggers for such a change. +# +CREATE TABLE t1( a INT ); +ALTER TABLE t1 ADD CONSTRAINT pk PRIMARY KEY (a); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL +DROP TABLE t1; +CREATE TABLE t1( a INT, PRIMARY KEY pk (a) ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, KEY (a), +b INT, KEY (b) INVISIBLE +); +ALTER TABLE t1 RENAME INDEX no_such_index TO x; +ERROR 42000: Key 'no_such_index' doesn't exist in table 't1' +ALTER TABLE t1 ALTER INDEX no_such_index INVISIBLE; +ERROR 42000: Key 'no_such_index' doesn't exist in table 't1' +# +# Repeated alter actions. Should work. +# +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX a VISIBLE; +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX b VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +t1 1 b 1 b A 0 NULL NULL YES BTREE YES NULL +# +# Various combinations of RENAME INDEX and ALTER INDEX ... INVISIBLE. +# +ALTER TABLE t1 RENAME INDEX a TO x, RENAME INDEX x TO a; +ERROR 42000: Key 'x' doesn't exist in table 't1' +ALTER TABLE t1 RENAME INDEX a TO x, ALTER INDEX x INVISIBLE; +ERROR 42000: Key 'x' doesn't exist in table 't1' +ALTER TABLE t1 RENAME INDEX a TO x, ALTER INDEX a VISIBLE; +ERROR 42000: Key 'a' doesn't exist in table 't1' +ALTER TABLE t1 ALTER INDEX a VISIBLE, RENAME INDEX a TO x; +ERROR 42000: Key 'a' doesn't exist in table 't1' +# +# Various algorithms and their effects. +# +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = COPY; +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE NO NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE, ALGORITHM = INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE YES NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = DEFAULT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE NO NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL YES BTREE YES NULL +t1 1 b 1 b A 3 NULL NULL YES BTREE YES NULL +ALTER TABLE t1 ADD INDEX ab(a, b), ALTER INDEX ab INVISIBLE; +ERROR 42000: Key 'ab' doesn't exist in table 't1' +DROP TABLE t1; +# +# Test that constraints implemented by the indexes are still enforced +# while the index is invisible. +# +CREATE TABLE t1 ( a INT, UNIQUE KEY (a) INVISIBLE ); +CREATE TABLE t2 ( a INT UNIQUE ); +CREATE TABLE t3 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT PRIMARY KEY ); +CREATE TABLE t4 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE, +b INT PRIMARY KEY AUTO_INCREMENT ); +CREATE TABLE t5 ( a INT, b INT, c INT, UNIQUE KEY (a, b, c) INVISIBLE ); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 't1.a' +ALTER TABLE t2 ALTER INDEX a INVISIBLE; +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 't2.a' +INSERT INTO t3(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (1); +INSERT INTO t4(a) VALUES (1); +ERROR 23000: Duplicate entry '1' for key 't4.a' +INSERT INTO t5 VALUES (1, 2, 3); +INSERT INTO t5 VALUES (1, 2, 3); +ERROR 23000: Duplicate entry '1-2-3' for key 't5.a' +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#23256900: WL#8697: ASSERTION +# `TABLE_SHARE->IS_MISSING_PRIMARY_KEY() ...` FAILED. +# +# Test for when an index is implicitly promoted to primary key index. +# The first NOT NULL UNIQUE index is candidate for promotion. +# These indexes can't be invisible, either. +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) ); +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +EXPLAIN +SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 4 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT * FROM t1; +a +DROP TABLE t1; +# The first NOT NULL UNIQUE index may of course be invisible if it is +# not promoted. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL PRIMARY KEY, +UNIQUE KEY (a) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 b A 0 NULL NULL BTREE YES NULL +t1 0 a 1 a A 0 NULL NULL BTREE NO NULL +DROP TABLE t1; +# The check above applies only to the first NOT NULL UNIQUE index. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL, +UNIQUE KEY (a), +UNIQUE KEY (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 a 1 a A 0 NULL NULL BTREE YES NULL +t1 0 b 1 b A 0 NULL NULL BTREE NO NULL +DROP TABLE t1; +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +# +# Bug#23264435: WL#8697: FULLTEXT INDEXES CANNOT BE MADE INVISIBLE +# +CREATE TABLE t1 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT NOT NULL UNIQUE ); +CREATE TABLE t2 ( a INT PRIMARY KEY, b INT, INDEX(b) INVISIBLE); +ALTER TABLE t2 ALTER INDEX b VISIBLE; +DROP TABLE t1, t2; +CREATE TEMPORARY TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Invisible spatial indexes. +# +CREATE TABLE t1 ( +fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +g GEOMETRY NOT NULL SRID 0, +SPATIAL KEY(g) +); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# There appears to be a bug causing the cardinality number to fluctuate +# for spatial indexes. +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range g g 34 NULL X 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`fid` AS `fid`,`test`.`t1`.`g` AS `g` from `test`.`t1` where st_within(`test`.`t1`.`g`,(st_geomfromtext('Polygon((140 140,160 140,160 160,140 140))'))) +ALTER TABLE t1 ALTER INDEX g INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 fid A X NULL NULL BTREE YES NULL +t1 1 g 1 g A X 32 NULL SPATIAL NO NULL +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`fid` AS `fid`,`test`.`t1`.`g` AS `g` from `test`.`t1` where st_within(`test`.`t1`.`g`,(st_geomfromtext('Polygon((140 140,160 140,160 160,140 140))'))) +DROP TABLE t1; +# +# Test of invisible fulltext indexes. +# +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)); +INSERT INTO t1 VALUES('Some data', 'for full-text search'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL fulltext a a 0 const 1 100.00 Using where; Ft_hints: sorted +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('collections')) +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL fulltext a a 0 const 1 100.00 Using where; Ft_hints: no_ranking +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('collections' in boolean mode)) +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a NULL 1 NULL NULL YES FULLTEXT NO NULL +t1 1 a 2 b NULL 1 NULL NULL YES FULLTEXT NO NULL +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +DROP TABLE t1; +# +# Invisible indexes on AUTO_INCREMENT columns. +# +CREATE TABLE t1 ( a INT AUTO_INCREMENT, KEY ( a ) ); +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 3 NULL NULL BTREE NO NULL +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Bug#24660093: REMOVING AN INVISIBLE INDEX BREAKS EXPLAIN +# +CREATE TABLE t1 ( a INT, KEY(a) INVISIBLE ); +SELECT * FROM t1 FORCE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +# +# Tests that don't work on MyISAM ( native partitioning, indexes on +# generated columns, etc.) +# +# +# Partitioning on keys with an invisible index, invisible indexes over +# partitioned tables. +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL, +b CHAR(2) NOT NULL, +c INT(10) UNSIGNED NOT NULL, +d VARCHAR(255) DEFAULT NULL, +e VARCHAR(1000) DEFAULT NULL, +KEY (a) INVISIBLE, +KEY (b) +) PARTITION BY KEY (a) PARTITIONS 20; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (a, b, c, d, e) VALUES +('07', '03', 343, '1', '07_03_343'), +('01', '04', 343, '2', '01_04_343'), +('01', '06', 343, '3', '01_06_343'), +('01', '07', 343, '4', '01_07_343'), +('01', '08', 343, '5', '01_08_343'), +('01', '09', 343, '6', '01_09_343'), +('03', '03', 343, '7', '03_03_343'), +('03', '06', 343, '8', '03_06_343'), +('03', '07', 343, '9', '03_07_343'), +('04', '03', 343, '10', '04_03_343'), +('04', '06', 343, '11', '04_06_343'), +('05', '03', 343, '12', '05_03_343'), +('11', '03', 343, '13', '11_03_343'), +('11', '04', 343, '14', '11_04_343'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 ALL NULL NULL NULL NULL 14 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT b FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 index NULL b 8 NULL 14 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` +EXPLAIN SELECT * FROM t1 WHERE a = '04'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` where (`test`.`t1`.`a` = '04') +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 index NULL a 8 NULL 14 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT * FROM t1 WHERE a = '04'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ref a a 8 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` where (`test`.`t1`.`a` = '04') +ALTER TABLE t1 ALTER INDEX b INVISIBLE; +EXPLAIN SELECT b FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19 ALL NULL NULL NULL NULL 14 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` +DROP TABLE t1; +CREATE TABLE t1 ( a INT GENERATED ALWAYS AS (1), KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A 0 NULL NULL YES BTREE NO NULL +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Test that referential constraints implemented by the indexes are still +# enforced while the index is invisible. +# +CREATE TABLE t1p ( a INT KEY ); +CREATE TABLE t1c ( t1p_a INT ); +ALTER TABLE t1c ADD CONSTRAINT FOREIGN KEY ( t1p_a ) REFERENCES t1p( a ); +ALTER TABLE t1c ALTER INDEX t1p_a INVISIBLE; +INSERT INTO t1c VALUES ( 1 ); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1c`, CONSTRAINT `t1c_ibfk_1` FOREIGN KEY (`t1p_a`) REFERENCES `t1p` (`a`)) +SELECT * FROM t1c; +t1p_a +DROP TABLE t1c, t1p; +# +# Bug#25837038: FEATURE REQUEST : USE INVISIBLE INDEXES SPECIFIC QUERY +# +CREATE TABLE t1 ( a INT, KEY( a ) INVISIBLE ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SET @@optimizer_switch='use_invisible_indexes=on'; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL X 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=on,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +SET @@optimizer_switch='use_invisible_indexes=off'; +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; +# +# Bug#31550839 OPTIMIZER SWITCH USE_INVISIBLE_INDEXES=ON DOES NOT ALLOW FORCE INDEX +# +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +b INT NOT NULL, +INDEX (b) INVISIBLE +); +INSERT INTO t1 VALUES (1, 1), (2,2),(3,3),(4,4),(5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET optimizer_switch="use_invisible_indexes=on"; +EXPLAIN SELECT * FROM t1 FORCE INDEX (b) WHERE b = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref b b 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) where (`test`.`t1`.`b` = 3) +SET optimizer_switch="use_invisible_indexes=default"; +EXPLAIN SELECT * FROM t1 FORCE INDEX (b) WHERE b = 3; +ERROR 42000: Key 'b' doesn't exist in table 't1' +DROP TABLE t1; diff --git a/mysql-test/r/join.result-pq b/mysql-test/r/join.result-pq new file mode 100644 index 000000000..2944871c5 --- /dev/null +++ b/mysql-test/r/join.result-pq @@ -0,0 +1,2155 @@ +drop table if exists t1,t2,t3; +CREATE TABLE t1 (S1 INT); +CREATE TABLE t2 (S1 INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 JOIN t2; +S1 S1 +1 2 +SELECT * FROM t1 INNER JOIN t2; +S1 S1 +1 2 +SELECT * from t1 JOIN t2 USING (S1); +S1 +SELECT * FROM t1 INNER JOIN t2 USING (S1); +S1 +SELECT * from t1 CROSS JOIN t2; +S1 S1 +1 2 +SELECT * from t1 LEFT JOIN t2 USING(S1); +S1 +1 +SELECT * from t1 LEFT JOIN t2 ON(t2.S1=2); +S1 S1 +1 2 +SELECT * from t1 RIGHT JOIN t2 USING(S1); +S1 +2 +SELECT * from t1 RIGHT JOIN t2 ON(t1.S1=1); +S1 S1 +1 2 +drop table t1,t2; +create table t1 (id int primary key); +create table t2 (id int); +insert into t1 values (75); +insert into t1 values (79); +insert into t1 values (78); +insert into t1 values (77); +replace into t1 values (76); +replace into t1 values (76); +insert into t1 values (104); +insert into t1 values (103); +insert into t1 values (102); +insert into t1 values (101); +insert into t1 values (105); +insert into t1 values (106); +insert into t1 values (107); +insert into t2 values (107),(75),(1000); +select t1.id, t2.id from t1, t2 where t2.id = t1.id; +id id +107 107 +75 75 +select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t1.id; +id count(t2.id) +107 1 +75 1 +select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t2.id; +id count(t2.id) +107 1 +75 1 +select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null; +id id +NULL 75 +explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id` from `test`.`t2` left join `test`.`t1` on(((`test`.`t1`.`id` >= 74) and (`test`.`t1`.`id` <= 0))) where ((`test`.`t2`.`id` = 75) and (`test`.`t1`.`id` is null)) +explain select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id <0 and t1.id > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`id` < 0) and (`test`.`t1`.`id` > 0) and multiple equal(`test`.`t2`.`id`, `test`.`t1`.`id`)) +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +token varchar(100) DEFAULT '' NOT NULL, +count int(11) DEFAULT '0' NOT NULL, +qty int(11), +phone char(1) DEFAULT '' NOT NULL, +timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, +PRIMARY KEY (id), +KEY token (token(15)), +KEY timestamp (timestamp), +UNIQUE token_2 (token(75),count,phone) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET sql_mode = default; +INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21'); +INSERT INTO t1 VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21'); +INSERT INTO t1 VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04'); +INSERT INTO t1 VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53'); +INSERT INTO t1 VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53'); +INSERT INTO t1 VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24'); +INSERT INTO t1 VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12'); +INSERT INTO t1 VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12'); +INSERT INTO t1 VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24'); +INSERT INTO t1 VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36'); +INSERT INTO t1 VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05'); +CREATE TABLE t2 ( +id int(11) NOT NULL auto_increment, +category int(11) DEFAULT '0' NOT NULL, +county int(11) DEFAULT '0' NOT NULL, +state int(11) DEFAULT '0' NOT NULL, +phones int(11) DEFAULT '0' NOT NULL, +nophones int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY category (category,county,state) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,2,11,12,5400,7800); +INSERT INTO t2 VALUES (4,2,25,12,6500,11200); +INSERT INTO t2 VALUES (5,1,37,6,10000,12000); +select a.id, b.category as catid, b.state as stateid, b.county as countyid from t1 a, t2 b ignore index (primary) where (a.token ='a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id); +id catid stateid countyid +26 1 6 37 +27 2 12 11 +28 2 12 11 +29 2 12 25 +select a.id, b.category as catid, b.state as stateid, b.county as +countyid from t1 a, t2 b where (a.token = +'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id) order by a.id; +id catid stateid countyid +26 1 6 37 +27 2 12 11 +28 2 12 11 +29 2 12 25 +drop table t1, t2; +create table t1 (a int primary key); +insert into t1 values(1),(2); +select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a); +a +1 +2 +select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); +ERROR HY000: Too many tables; MySQL can only use XX tables in a join +select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a); +a +1 +2 +select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); +ERROR HY000: Too many tables; MySQL can only use XX tables in a join +drop table t1; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +PRIMARY KEY (a,b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3); +CREATE TABLE t2 ( +a int(11) default NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2),(3); +SELECT t1.a,t2.a,b FROM t1,t2 WHERE t1.a=t2.a AND (t1.a=1 OR t1.a=2) AND b>=1 AND b<=3; +a a b +2 2 3 +DROP TABLE t1, t2; +CREATE TABLE t1 (d DATE NOT NULL); +CREATE TABLE t2 (d DATE NOT NULL); +INSERT INTO t1 (d) VALUES ('2001-08-01'),('1000-01-01'); +SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL; +d +2001-08-01 +1000-01-01 +SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL; +d +SELECT * from t1 WHERE t1.d IS NULL; +d +SELECT * FROM t1 WHERE 1/0 IS NULL; +d +2001-08-01 +1000-01-01 +Warnings: +Warning 1365 Division by 0 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +Document_ID varchar(50) NOT NULL default '', +Contractor_ID varchar(6) NOT NULL default '', +Language_ID char(3) NOT NULL default '', +Expiration_Date datetime default NULL, +Publishing_Date datetime default NULL, +Title text, +Column_ID varchar(50) NOT NULL default '', +PRIMARY KEY (Language_ID,Document_ID,Contractor_ID) +); +INSERT INTO t1 VALUES ('xep80','1','ger','2001-12-31 20:00:00','2001-11-12 10:58:00','Kartenbestellung - jetzt auch online','anle'),('','999998','',NULL,NULL,NULL,''); +CREATE TABLE t2 ( +Contractor_ID char(6) NOT NULL default '', +Language_ID char(3) NOT NULL default '', +Document_ID char(50) NOT NULL default '', +CanRead char(1) default NULL, +Customer_ID int(11) NOT NULL default '0', +PRIMARY KEY (Contractor_ID,Language_ID,Document_ID,Customer_ID) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('5','ger','xep80','1',999999),('1','ger','xep80','1',999999); +CREATE TABLE t3 ( +Language_ID char(3) NOT NULL default '', +Column_ID char(50) NOT NULL default '', +Contractor_ID char(6) NOT NULL default '', +CanRead char(1) default NULL, +Active char(1) default NULL, +PRIMARY KEY (Language_ID,Column_ID,Contractor_ID) +); +INSERT INTO t3 VALUES ('ger','home','1','1','1'),('ger','Test','1','0','0'),('ger','derclu','1','0','0'),('ger','clubne','1','0','0'),('ger','philos','1','0','0'),('ger','clubko','1','0','0'),('ger','clubim','1','1','1'),('ger','progra','1','0','0'),('ger','progvo','1','0','0'),('ger','progsp','1','0','0'),('ger','progau','1','0','0'),('ger','progku','1','0','0'),('ger','progss','1','0','0'),('ger','nachl','1','0','0'),('ger','mitgli','1','0','0'),('ger','mitsu','1','0','0'),('ger','mitbus','1','0','0'),('ger','ergmar','1','1','1'),('ger','home','4','1','1'),('ger','derclu','4','1','1'),('ger','clubne','4','0','0'),('ger','philos','4','1','1'),('ger','clubko','4','1','1'),('ger','clubim','4','1','1'),('ger','progra','4','1','1'),('ger','progvo','4','1','1'),('ger','progsp','4','1','1'),('ger','progau','4','0','0'),('ger','progku','4','1','1'),('ger','progss','4','1','1'),('ger','nachl','4','1','1'),('ger','mitgli','4','0','0'),('ger','mitsu','4','0','0'),('ger','mitbus','4','0','0'),('ger','ergmar','4','1','1'),('ger','progra2','1','0','0'),('ger','archiv','4','1','1'),('ger','anmeld','4','1','1'),('ger','thema','4','1','1'),('ger','edito','4','1','1'),('ger','madis','4','1','1'),('ger','enma','4','1','1'),('ger','madis','1','1','1'),('ger','enma','1','1','1'),('ger','vorsch','4','0','0'),('ger','veranst','4','0','0'),('ger','anle','4','1','1'),('ger','redak','4','1','1'),('ger','nele','4','1','1'),('ger','aukt','4','1','1'),('ger','callcenter','4','1','1'),('ger','anle','1','0','0'); +delete from t1 where Contractor_ID='999998'; +insert into t1 (Contractor_ID) Values ('999998'); +SELECT DISTINCT COUNT(t1.Title) FROM t1, +t2, t3 WHERE +t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND +t1.Language_ID='ger' AND '2001-12-21 23:14:24' >= +Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND +t1.Document_ID = t2.Document_ID AND +t1.Language_ID = t2.Language_ID AND +t1.Contractor_ID = t2.Contractor_ID AND ( +t2.Customer_ID = '4' OR +t2.Customer_ID = '999999' OR +t2.Customer_ID = '1' )AND t2.CanRead += '1' AND t1.Column_ID=t3.Column_ID AND +t1.Language_ID=t3.Language_ID AND ( +t3.Contractor_ID = '4' OR +t3.Contractor_ID = '999999' OR +t3.Contractor_ID = '1') AND +t3.CanRead='1' AND t3.Active='1'; +COUNT(t1.Title) +1 +SELECT DISTINCT COUNT(t1.Title) FROM t1, +t2, t3 WHERE +t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND +t1.Language_ID='ger' AND '2001-12-21 23:14:24' >= +Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND +t1.Document_ID = t2.Document_ID AND +t1.Language_ID = t2.Language_ID AND +t1.Contractor_ID = t2.Contractor_ID AND ( +t2.Customer_ID = '4' OR +t2.Customer_ID = '999999' OR +t2.Customer_ID = '1' )AND t2.CanRead += '1' AND t1.Column_ID=t3.Column_ID AND +t1.Language_ID=t3.Language_ID AND ( +t3.Contractor_ID = '4' OR +t3.Contractor_ID = '999999' OR +t3.Contractor_ID = '1') AND +t3.CanRead='1' AND t3.Active='1'; +COUNT(t1.Title) +1 +drop table t1,t2,t3; +CREATE TABLE t1 ( +t1_id int(11) default NULL, +t2_id int(11) default NULL, +type enum('Cost','Percent') default NULL, +cost_unit enum('Cost','Unit') default NULL, +min_value double default NULL, +max_value double default NULL, +t3_id int(11) default NULL, +item_id int(11) default NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (12,5,'Percent','Cost',-1,0,-1,-1),(14,4,'Percent','Cost',-1,0,-1,-1),(18,5,'Percent','Cost',-1,0,-1,-1),(19,4,'Percent','Cost',-1,0,-1,-1),(20,5,'Percent','Cost',100,-1,22,291),(21,5,'Percent','Cost',100,-1,18,291),(22,1,'Percent','Cost',100,-1,6,291),(23,1,'Percent','Cost',100,-1,21,291),(24,1,'Percent','Cost',100,-1,9,291),(25,1,'Percent','Cost',100,-1,4,291),(26,1,'Percent','Cost',100,-1,20,291),(27,4,'Percent','Cost',100,-1,7,202),(28,1,'Percent','Cost',50,-1,-1,137),(29,2,'Percent','Cost',100,-1,4,354),(30,2,'Percent','Cost',100,-1,9,137),(93,2,'Cost','Cost',-1,10000000,-1,-1); +CREATE TABLE t2 ( +id int(10) unsigned NOT NULL auto_increment, +name varchar(255) default NULL, +PRIMARY KEY (id) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5'); +select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2; +t1_id t2_id type cost_unit min_value max_value t3_id item_id id name +12 5 Percent Cost -1 0 -1 -1 5 s5 +14 4 Percent Cost -1 0 -1 -1 4 s4 +drop table t1,t2; +CREATE TABLE t1 ( +siteid varchar(25) NOT NULL default '', +emp_id varchar(30) NOT NULL default '', +rate_code varchar(10) default NULL, +UNIQUE KEY site_emp (siteid,emp_id), +KEY siteid (siteid) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust'); +CREATE TABLE t2 ( +siteid varchar(25) NOT NULL default '', +rate_code varchar(10) NOT NULL default '', +base_rate float NOT NULL default '0', +PRIMARY KEY (siteid,rate_code), +FULLTEXT KEY rate_code (rate_code) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('rivercats','cust',20); +SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats'; +rate_code base_rate +cust 20 +SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith'; +rate_code base_rate +cust 20 +SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND siteid = 'rivercats'; +rate_code base_rate +cust 20 +SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE siteid = 'rivercats' AND emp.emp_id = 'psmith'; +rate_code base_rate +cust 20 +drop table t1,t2; +CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, Value1 VARCHAR(255)); +CREATE TABLE t2 (ID INTEGER NOT NULL PRIMARY KEY, Value2 VARCHAR(255)); +INSERT INTO t1 VALUES (1, 'A'); +INSERT INTO t2 VALUES (1, 'B'); +SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND (Value1 = 'A' AND Value2 <> 'B'); +ID Value1 Value2 +SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND Value1 = 'A' AND Value2 <> 'B'; +ID Value1 Value2 +SELECT * FROM t1 NATURAL JOIN t2 WHERE (Value1 = 'A' AND Value2 <> 'B') AND 1; +ID Value1 Value2 +drop table t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +CREATE TABLE t3 (c int); +SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3; +a b c +DROP TABLE t1, t2, t3; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values (2),(4); +select * from t1 natural left join t2; +i +1 +2 +select * from t1 left join t2 on (t1.i=t2.i); +i i +1 NULL +2 2 +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 left join t2 on (t1.i=t2.i) left join t3 on (t2.i=t3.i); +i i i +1 NULL NULL +2 2 2 +select * from t3 natural right join t2; +i +2 +3 +select * from t3 right join t2 on (t3.i=t2.i); +i i +2 2 +NULL 3 +select * from t3 natural right join t2 natural right join t1; +i +1 +2 +select * from t3 right join t2 on (t3.i=t2.i) right join t1 on (t2.i=t1.i); +i i i +2 2 2 +NULL NULL 1 +select * from t1,t2 natural left join t3 order by t1.i,t2.i,t3.i; +i i +1 2 +1 3 +2 2 +2 3 +select * from t1,t2 left join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i; +i i i +1 2 2 +1 3 NULL +2 2 2 +2 3 NULL +select t1.i,t2.i,t3.i from t2 natural left join t3,t1 order by t1.i,t2.i,t3.i; +i i i +1 2 2 +1 3 NULL +2 2 2 +2 3 NULL +select t1.i,t2.i,t3.i from t2 left join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i; +i i i +1 2 2 +1 3 NULL +2 2 2 +2 3 NULL +select * from t1,t2 natural right join t3 order by t1.i,t2.i,t3.i; +i i +1 4 +1 2 +2 4 +2 2 +select * from t1,t2 right join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i; +i i i +1 NULL 4 +1 2 2 +2 NULL 4 +2 2 2 +select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i; +i i i +1 NULL 4 +1 2 2 +2 NULL 4 +2 2 2 +select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i; +i i i +1 NULL 4 +1 2 2 +2 NULL 4 +2 2 2 +drop table t1,t2,t3; +CREATE TABLE t1 (a int, b int default 0, c int default 1); +INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 (a) SELECT a + 8 FROM t1; +INSERT INTO t1 (a) SELECT a + 16 FROM t1; +CREATE TABLE t2 (a int, d int, e int default 0); +INSERT INTO t2 (a, d) VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t2 (a, d) SELECT a+4, a+4 FROM t2; +INSERT INTO t2 (a, d) SELECT a+8, a+8 FROM t2; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e +ORDER BY t1.b, t1.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 32 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 16 6.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t2`.`e` AS `e` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`e` = `test`.`t1`.`b`) and (`test`.`t2`.`d` = 1)) order by `test`.`t1`.`b`,`test`.`t1`.`c` +SELECT STRAIGHT_JOIN t2.e FROM t1,t2 WHERE t2.d=1 AND t1.b=t2.e +ORDER BY t1.b, t1.c; +e +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +DROP TABLE t1,t2; +create table t1 (c int, b int); +create table t2 (a int, b int); +create table t3 (b int, c int); +create table t4 (y int, c int); +create table t5 (y int, z int); +create table t6 (a int, c int); +insert into t1 values (10,1); +insert into t1 values (3 ,1); +insert into t1 values (3 ,2); +insert into t2 values (2, 1); +insert into t3 values (1, 3); +insert into t3 values (1,10); +insert into t4 values (11,3); +insert into t4 values (2, 3); +insert into t5 values (11,4); +insert into t6 values (2, 3); +create algorithm=merge view v1a as +select * from t1 natural join t2; +create algorithm=merge view v1b(a,b,c) as +select * from t1 natural join t2; +create algorithm=merge view v1c as +select b as a, c as b, a as c from t1 natural join t2; +create algorithm=merge view v1d(b, a, c) as +select a as c, c as b, b as a from t1 natural join t2; +create algorithm=merge view v2a as +select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +create algorithm=merge view v2b as +select t1.c as b, t1.b as a, t2.a as c +from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +create algorithm=merge view v3a as +select * from t1 natural join t2 natural join t3; +create algorithm=merge view v3b as +select * from t1 natural join (t2 natural join t3); +create algorithm=merge view v4 as +select * from v2a natural join v3a; +select * from (t1 natural join t2) natural join (t3 natural join t4); +b c a y +1 3 2 11 +1 3 2 2 +select * from (t1 natural join t2) natural left join (t3 natural join t4); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from (t3 natural join t4) natural right join (t1 natural join t2); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from (t1 natural left join t2) natural left join (t3 natural left join t4); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +2 3 NULL NULL +select * from (t4 natural right join t3) natural right join (t2 natural right join t1); +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +2 3 NULL NULL +select * from t1 natural join t2 natural join t3 natural join t4; +c b a y +3 1 2 11 +3 1 2 2 +select * from ((t1 natural join t2) natural join t3) natural join t4; +c b a y +3 1 2 11 +3 1 2 2 +select * from t1 natural join (t2 natural join (t3 natural join t4)); +c b a y +3 1 2 11 +3 1 2 2 +select * from t5 natural right join (t4 natural right join ((t2 natural right join t1) natural right join t3)); +y c b a z +11 3 1 2 4 +2 3 1 2 NULL +NULL 10 1 2 NULL +select * from (t1 natural join t2), (t3 natural join t4); +b c a c b y +1 10 2 3 1 11 +1 10 2 3 1 2 +1 3 2 3 1 11 +1 3 2 3 1 2 +select * from t5 natural join ((t1 natural join t2), (t3 natural join t4)); +y z b c a c b +11 4 1 10 2 3 1 +11 4 1 3 2 3 1 +select * from ((t1 natural join t2), (t3 natural join t4)) natural join t5; +y b c a c b z +11 1 10 2 3 1 4 +11 1 3 2 3 1 4 +select * from t5 natural join ((t1 natural join t2) cross join (t3 natural join t4)); +y z b c a c b +11 4 1 10 2 3 1 +11 4 1 3 2 3 1 +select * from ((t1 natural join t2) cross join (t3 natural join t4)) natural join t5; +y b c a c b z +11 1 10 2 3 1 4 +11 1 3 2 3 1 4 +select * from (t1 join t2 using (b)) join (t3 join t4 using (c)) using (c); +c b a b y +3 1 2 1 11 +3 1 2 1 2 +select * from (t1 join t2 using (b)) natural join (t3 join t4 using (c)); +b c a y +1 3 2 11 +1 3 2 2 +select a,b,c from (t1 natural join t2) natural join (t3 natural join t4) +where b + 1 = y or b + 10 = y group by b,c,a having min(b) < max(y) order by a; +a b c +2 1 3 +select * from (t1 natural join t2) natural left join (t3 natural join t4) +where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y; +b c a y +1 3 2 2 +1 3 2 11 +select * from (t3 natural join t4) natural right join (t1 natural join t2) +where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y; +b c a y +1 3 2 2 +1 3 2 11 +select * from t1 natural join t2 where t1.c > t2.a; +b c a +1 10 2 +1 3 2 +select * from t1 natural join t2 where t1.b > t2.b; +b c a +select * from t1 natural left join (t4 natural join t5) where t5.z is not NULL; +c b y z +3 1 11 4 +3 2 11 4 +select * from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c; +c b a b y c +3 1 2 1 2 3 +3 2 2 1 2 3 +select * from (t2 join t4 on b + 1 = y) join t1 on t1.c = t4.c; +a b y c c b +2 1 2 3 3 1 +2 1 2 3 3 2 +select * from t1 natural join (t2 join t4 on b + 1 = y); +c b a y +3 1 2 2 +select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c); +c b a b b c y c +10 1 2 1 1 10 11 3 +10 1 2 1 1 3 11 3 +3 1 2 1 1 10 11 3 +3 1 2 1 1 3 11 3 +3 2 2 1 1 10 11 3 +3 2 2 1 1 3 11 3 +select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c); +c b a b b c y c +10 1 2 1 1 10 11 3 +10 1 2 1 1 3 11 3 +3 1 2 1 1 10 11 3 +3 1 2 1 1 3 11 3 +3 2 2 1 1 10 11 3 +3 2 2 1 1 3 11 3 +select * from (t1 natural join t2) join (t3 natural join t4) on a = y; +b c a c b y +1 10 2 3 1 2 +1 3 2 3 1 2 +select * from ((t3 join (t1 join t2 on c > a) on t3.b < t2.a) join t4 on y > t1.c) join t5 on z = t1.b + 3; +b c c b a b y c y z +1 10 10 1 2 1 11 3 11 4 +1 10 3 1 2 1 11 3 11 4 +1 3 10 1 2 1 11 3 11 4 +1 3 3 1 2 1 11 3 11 4 +select * from t1 natural join t2 where t1.b > 0; +b c a +1 10 2 +1 3 2 +select * from t1 natural join (t4 natural join t5) where t4.y > 7; +c b y z +3 1 11 4 +3 2 11 4 +select * from (t4 natural join t5) natural join t1 where t4.y > 7; +c y z b +3 11 4 1 +3 11 4 2 +select * from t1 natural left join (t4 natural join t5) where t4.y > 7; +c b y z +3 1 11 4 +3 2 11 4 +select * from (t4 natural join t5) natural right join t1 where t4.y > 7; +c b y z +3 1 11 4 +3 2 11 4 +select * from (t1 natural join t2) join (t3 natural join t4) on t1.b = t3.b; +b c a c b y +1 10 2 3 1 11 +1 10 2 3 1 2 +1 3 2 3 1 11 +1 3 2 3 1 2 +select t1.*, t2.* from t1 natural join t2; +c b a b +10 1 2 1 +3 1 2 1 +select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) natural join (t3 natural join t4); +c b a b b c y c +3 1 2 1 1 3 11 3 +3 1 2 1 1 3 2 3 +select * from (select * from t1 natural join t2) as t12 +natural join +(select * from t3 natural join t4) as t34; +b c a y +1 3 2 11 +1 3 2 2 +select * from (select * from t1 natural join t2) as t12 +natural left join +(select * from t3 natural join t4) as t34; +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from (select * from t3 natural join t4) as t34 +natural right join +(select * from t1 natural join t2) as t12; +b c a y +1 10 2 NULL +1 3 2 11 +1 3 2 2 +select * from v1a; +b c a +1 10 2 +1 3 2 +select * from v1b; +a b c +1 10 2 +1 3 2 +select * from v1c; +a b c +1 10 2 +1 3 2 +select * from v1d; +b a c +2 10 1 +2 3 1 +select * from v2a; +c b a +3 1 2 +3 2 2 +select * from v2b; +b a c +3 1 2 +3 2 2 +select * from v3a; +b c a +1 10 2 +1 3 2 +select * from v3b; +c b a +10 1 2 +3 1 2 +select * from v4; +c b a +3 1 2 +select * from v1a natural join v2a; +b c a +1 3 2 +select v2a.* from v1a natural join v2a; +c b a +3 1 2 +select * from v1b join v2a on v1b.b = v2a.c; +a b c c b a +1 3 2 3 1 2 +1 3 2 3 2 2 +select * from v1c join v2a on v1c.b = v2a.c; +a b c c b a +1 3 2 3 1 2 +1 3 2 3 2 2 +select * from v1d join v2a on v1d.a = v2a.c; +b a c c b a +2 3 1 3 1 2 +2 3 1 3 2 2 +select * from v1a join (t3 natural join t4) on a = y; +b c a c b y +1 10 2 3 1 2 +1 3 2 3 1 2 +select * from t1 natural join (t3 cross join t4); +ERROR 23000: Column 'c' in from clause is ambiguous +select * from (t3 cross join t4) natural join t1; +ERROR 23000: Column 'c' in from clause is ambiguous +select * from t1 join (t2, t3) using (b); +ERROR 23000: Column 'b' in from clause is ambiguous +select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6; +ERROR 23000: Column 'c' in from clause is ambiguous +select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6; +ERROR 23000: Column 'c' in from clause is ambiguous +select * from t6 natural join ((t1 natural join t2), (t3 natural join t4)); +ERROR 23000: Column 'c' in from clause is ambiguous +select * from (t1 join t2 on t1.b=t2.b) natural join (t3 natural join t4); +ERROR 23000: Column 'b' in from clause is ambiguous +select * from (t3 natural join t4) natural join (t1 join t2 on t1.b=t2.b); +ERROR 23000: Column 'b' in from clause is ambiguous +select * from (t3 join (t4 natural join t5) on (b < z)) +natural join +(t1 natural join t2); +ERROR 23000: Column 'c' in from clause is ambiguous +select * from (t1 natural join t2) natural join (t3 join (t4 natural join t5) on (b < z)); +ERROR 23000: Column 'c' in from clause is ambiguous +select t1.b from v1a; +ERROR 42S22: Unknown column 't1.b' in 'field list' +select * from v1a join v1b on t1.b = t2.b; +ERROR 42S22: Unknown column 't1.b' in 'on clause' +ANALYZE TABLE mysql.user; +Table Op Msg_type Msg_text +mysql.user analyze status OK +select +statistics.TABLE_NAME, statistics.COLUMN_NAME, statistics.TABLE_CATALOG, statistics.TABLE_SCHEMA, statistics.NON_UNIQUE, statistics.INDEX_SCHEMA, statistics.INDEX_NAME, statistics.SEQ_IN_INDEX, statistics.COLLATION, statistics.SUB_PART, statistics.PACKED, statistics.NULLABLE, statistics.INDEX_TYPE, statistics.COMMENT, +columns.TABLE_CATALOG, columns.TABLE_SCHEMA, columns.COLUMN_DEFAULT, columns.IS_NULLABLE, columns.DATA_TYPE, columns.CHARACTER_MAXIMUM_LENGTH, columns.CHARACTER_OCTET_LENGTH, columns.NUMERIC_PRECISION, columns.NUMERIC_SCALE, columns.CHARACTER_SET_NAME, columns.COLLATION_NAME, columns.COLUMN_TYPE, columns.COLUMN_KEY, columns.EXTRA, columns.PRIVILEGES, columns.COLUMN_COMMENT +from information_schema.statistics join information_schema.columns using(table_name,column_name) where table_name='user'; +TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT +user Host def mysql 0 mysql PRIMARY 1 A NULL NULL BTREE def mysql NO char 255 255 NULL NULL ascii ascii_general_ci char(255) PRI select,insert,update,references +user User def mysql 0 mysql PRIMARY 2 A NULL NULL BTREE def mysql NO char 32 96 NULL NULL utf8 utf8_bin char(32) PRI select,insert,update,references +drop table t1; +drop table t2; +drop table t3; +drop table t4; +drop table t5; +drop table t6; +drop view v1a; +drop view v1b; +drop view v1c; +drop view v1d; +drop view v2a; +drop view v2b; +drop view v3a; +drop view v3b; +drop view v4; +create table t1 (a1 int, a2 int); +create table t2 (a1 int, b int); +create table t3 (c1 int, c2 int); +create table t4 (c2 int); +insert into t1 values (1,1); +insert into t2 values (1,1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2); +c2 a1 a2 b c1 +1 1 1 1 1 +select * from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2); +c2 c1 a1 a2 b +1 1 1 1 1 +select a2 from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2); +a2 +1 +select a2 from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2); +a2 +1 +select a2 from ((t1 join t2 using (a1)) join t3 on b=c1) join t4 using (c2); +a2 +1 +select a2 from ((t1 natural join t2) join t3 on b=c1) natural join t4; +a2 +1 +drop table t1,t2,t3,t4; +create table t1 (c int, b int); +create table t2 (a int, b int); +create table t3 (b int, c int); +create table t4 (y int, c int); +create table t5 (y int, z int); +insert into t1 values (3,2); +insert into t2 values (1,2); +insert into t3 values (2,3); +insert into t4 values (1,3); +insert into t5 values (1,4); +prepare stmt1 from "select * from ((t3 natural join (t1 natural join t2)) +natural join t4) natural join t5"; +execute stmt1; +y c b a z +1 3 2 1 4 +select * from ((t3 natural join (t1 natural join t2)) natural join t4) +natural join t5; +y c b a z +1 3 2 1 4 +drop table t1, t2, t3, t4, t5; +CREATE TABLE t1 (ID INTEGER, Name VARCHAR(50)); +CREATE TABLE t2 (Test_ID INTEGER); +CREATE VIEW v1 (Test_ID, Description) AS SELECT ID, Name FROM t1; +CREATE TABLE tv1 SELECT Description AS Name FROM v1 JOIN t2 +USING (Test_ID); +DESCRIBE tv1; +Field Type Null Key Default Extra +Name varchar(50) YES NULL +CREATE TABLE tv2 SELECT Description AS Name FROM v1 JOIN t2 +ON v1.Test_ID = t2.Test_ID; +DESCRIBE tv2; +Field Type Null Key Default Extra +Name varchar(50) YES NULL +DROP VIEW v1; +DROP TABLE t1,t2,tv1,tv2; +create table t1 (a int, b int); +insert into t1 values +(NULL, 1), +(NULL, 2), +(NULL, 3), +(NULL, 4); +create table t2 (a int not null, primary key(a)); +insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 (a int not null, primary key(a)); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +flush status; +select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; +a b a a +explain select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +We expect rnd_next=5, and read_key must be 0 because of short-cutting: +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 5 +drop table t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100), key(a), key(b)); +create table t3 (a int, b int, filler char(100), key(a), key(b)); +insert into t2 +select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select * from t2 where a < 800; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t2,t3 where t2.a < 400 and t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 40.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL a,b NULL NULL NULL 1000 40.00 Using where +2 SIMPLE t3 NULL ref b b 5 test.t2.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` < 400)) +drop table t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, primary key(a)); +insert into t2 select @v:=A.a+10*B.a, @v from t1 A, t1 B; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +show status like '%cost%'; +Variable_name Value +Last_query_cost 1.249000 +select 'The cost of accessing t1 (dont care if it changes' '^'; +The cost of accessing t1 (dont care if it changes +The cost of accessing t1 (dont care if it changes^ +select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z; +Z +vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv +explain select * from t1, t2 a, t2 b where a.a = t1.a and b.a=a.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +2 SIMPLE b NULL eq_ref PRIMARY PRIMARY 4 test.a.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b` from `test`.`t1` join `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`a` = `test`.`a`.`b`) and (`test`.`a`.`a` = `test`.`t1`.`a`)) +show status like '%cost%'; +Variable_name Value +Last_query_cost 8.249000 +select '^^: The above should be ~= 8 + cost(select * from t1). Value less than 8 is an error' Z; +Z +^^: The above should be ~= 8 + cost(select * from t1). Value less than 8 is an error +drop table t1, t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +CREATE TABLE t2 (c INT PRIMARY KEY, d INT); +INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL); +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +INSERT INTO t1 SELECT a + 16, b FROM t1; +INSERT INTO t1 SELECT a + 32, b FROM t1; +INSERT INTO t1 SELECT a + 64, b FROM t1; +INSERT INTO t2 SELECT a, b FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`b`) order by `test`.`t1`.`a` limit 2 +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`a`) order by `test`.`t1`.`a` limit 2 +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 128 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`b`) order by `test`.`t1`.`a` +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 128 100.00 NULL +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t1`.`a`) order by `test`.`t1`.`a` +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +3 NULL 3 NULL +4 NULL 4 NULL +5 NULL 5 NULL +6 NULL 6 NULL +7 NULL 7 NULL +8 NULL 8 NULL +9 NULL 9 NULL +10 NULL 10 NULL +11 NULL 11 NULL +12 NULL 12 NULL +13 NULL 13 NULL +14 NULL 14 NULL +15 NULL 15 NULL +16 NULL 16 NULL +17 NULL 17 NULL +18 NULL 18 NULL +19 NULL 19 NULL +20 NULL 20 NULL +21 NULL 21 NULL +22 NULL 22 NULL +23 NULL 23 NULL +24 NULL 24 NULL +25 NULL 25 NULL +26 NULL 26 NULL +27 NULL 27 NULL +28 NULL 28 NULL +29 NULL 29 NULL +30 NULL 30 NULL +31 NULL 31 NULL +32 NULL 32 NULL +33 NULL 33 NULL +34 NULL 34 NULL +35 NULL 35 NULL +36 NULL 36 NULL +37 NULL 37 NULL +38 NULL 38 NULL +39 NULL 39 NULL +40 NULL 40 NULL +41 NULL 41 NULL +42 NULL 42 NULL +43 NULL 43 NULL +44 NULL 44 NULL +45 NULL 45 NULL +46 NULL 46 NULL +47 NULL 47 NULL +48 NULL 48 NULL +49 NULL 49 NULL +50 NULL 50 NULL +51 NULL 51 NULL +52 NULL 52 NULL +53 NULL 53 NULL +54 NULL 54 NULL +55 NULL 55 NULL +56 NULL 56 NULL +57 NULL 57 NULL +58 NULL 58 NULL +59 NULL 59 NULL +60 NULL 60 NULL +61 NULL 61 NULL +62 NULL 62 NULL +63 NULL 63 NULL +64 NULL 64 NULL +65 NULL 65 NULL +66 NULL 66 NULL +67 NULL 67 NULL +68 NULL 68 NULL +69 NULL 69 NULL +70 NULL 70 NULL +71 NULL 71 NULL +72 NULL 72 NULL +73 NULL 73 NULL +74 NULL 74 NULL +75 NULL 75 NULL +76 NULL 76 NULL +77 NULL 77 NULL +78 NULL 78 NULL +79 NULL 79 NULL +80 NULL 80 NULL +81 NULL 81 NULL +82 NULL 82 NULL +83 NULL 83 NULL +84 NULL 84 NULL +85 NULL 85 NULL +86 NULL 86 NULL +87 NULL 87 NULL +88 NULL 88 NULL +89 NULL 89 NULL +90 NULL 90 NULL +91 NULL 91 NULL +92 NULL 92 NULL +93 NULL 93 NULL +94 NULL 94 NULL +95 NULL 95 NULL +96 NULL 96 NULL +97 NULL 97 NULL +98 NULL 98 NULL +99 NULL 99 NULL +100 NULL 100 NULL +101 NULL 101 NULL +102 NULL 102 NULL +103 NULL 103 NULL +104 NULL 104 NULL +105 NULL 105 NULL +106 NULL 106 NULL +107 NULL 107 NULL +108 NULL 108 NULL +109 NULL 109 NULL +110 NULL 110 NULL +111 NULL 111 NULL +112 NULL 112 NULL +113 NULL 113 NULL +114 NULL 114 NULL +115 NULL 115 NULL +116 NULL 116 NULL +117 NULL 117 NULL +118 NULL 118 NULL +119 NULL 119 NULL +120 NULL 120 NULL +121 NULL 121 NULL +122 NULL 122 NULL +123 NULL 123 NULL +124 NULL 124 NULL +125 NULL 125 NULL +126 NULL 126 NULL +127 NULL 127 NULL +128 NULL 128 NULL +DROP TABLE IF EXISTS t1,t2; +# +# Bug #42116: Mysql crash on specific query +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, INDEX (a)); +CREATE TABLE t4 (a INT); +CREATE TABLE t5 (a INT); +CREATE TABLE t6 (a INT); +INSERT INTO t1 VALUES (1), (1), (1); +INSERT INTO t2 VALUES +(2), (2), (2), (2), (2), (2), (2), (2), (2), (2); +INSERT INTO t3 VALUES +(3), (3), (3), (3), (3), (3), (3), (3), (3), (3); +ANALYZE TABLE t1, t2, t3, t4, t5, t6; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +EXPLAIN +SELECT * +FROM +t1 JOIN t2 ON t1.a = t2.a +LEFT JOIN +( +( +t3 LEFT JOIN t4 ON t3.a = t4.a +) +LEFT JOIN +( +t5 LEFT JOIN t6 ON t5.a = t6.a +) +ON t4.a = t5.a +) +ON t1.a = t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref a a 5 test.t1.a 10 100.00 Using where; Using index +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` left join `test`.`t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`)) left join (`test`.`t5` left join `test`.`t6` on((`test`.`t6`.`a` = `test`.`t4`.`a`))) on((`test`.`t5`.`a` = `test`.`t4`.`a`))) on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM +t1 JOIN t2 ON t1.a = t2.a +LEFT JOIN +( +( +t3 LEFT JOIN t4 ON t3.a = t4.a +) +LEFT JOIN +( +t5 LEFT JOIN t6 ON t5.a = t6.a +) +ON t4.a = t5.a +) +ON t1.a = t3.a; +a a a a a a +DROP TABLE t1,t2,t3,t4,t5,t6; +# +# Bug#48483: crash in get_best_combination() +# +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT 1 FROM t1 LEFT JOIN t1 AS t2 on 1=1; +EXPLAIN +SELECT 1 FROM v1 right join v1 AS v2 ON RAND(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on(true) left join (`test`.`t1` left join `test`.`t1` `t2` on(true)) on((0 <> rand())) where true +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#52177 crash with explain, row comparison, join, text field +# +CREATE TABLE t1 (a TINYINT, b TEXT, KEY (a)); +INSERT INTO t1 VALUES (0,''),(0,''); +FLUSH TABLES; +EXPLAIN SELECT 1 FROM t1 LEFT JOIN t1 a ON 1 +WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 1111.11) AND +ROW(t1.b, 1111.11) <=> ROW('',''); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `a` on(true) where false +DROP TABLE t1; +# +# Bug #50335: Assertion `!(order->used & map)' in eq_ref_table +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (0,0), (1,1); +SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; +a b a b +0 0 0 0 +1 1 1 1 +DROP TABLE t1; +End of 5.0 tests. +CREATE TABLE t1 (f1 int); +CREATE TABLE t2 (f1 int); +INSERT INTO t2 VALUES (1); +CREATE VIEW v1 AS SELECT * FROM t2; +PREPARE stmt FROM 'UPDATE t2 AS A NATURAL JOIN v1 B SET B.f1 = 1'; +EXECUTE stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1, t2; +CREATE TABLE t1(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +CREATE TABLE t2(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('1',null),(null,null); +INSERT INTO t2 VALUES ('1',null),(null,null); +CREATE TABLE mm1(a CHAR(9),b INT,KEY(b),KEY(a)) +ENGINE=MERGE UNION=(t1,t2); +SELECT t1.a FROM mm1,t1; +a +1 +1 +1 +1 +NULL +NULL +NULL +NULL +DROP TABLE t1, t2, mm1; +# +# Bug #54468: crash after item's print() function when ordering/grouping +# by subquery +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (), (); +SELECT 1 FROM t1 +GROUP BY +GREATEST(t1.a, +(SELECT 1 FROM +(SELECT t1.b FROM t1,t1 t2 +ORDER BY t1.a, t1.a LIMIT 1) AS d) +); +1 +1 +DROP TABLE t1; +# +# Bug #53544: Server hangs during JOIN query in stored procedure called +# twice in a row +# +CREATE TABLE t1(c INT); +INSERT INTO t1 VALUES (1), (2); +PREPARE stmt FROM "SELECT t2.c AS f1 FROM t1 LEFT JOIN + t1 t2 ON t1.c=t2.c RIGHT JOIN + t1 t3 ON t1.c=t3.c + GROUP BY f1;"; +EXECUTE stmt; +f1 +1 +2 +EXECUTE stmt; +f1 +1 +2 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +End of 5.1 tests +# +# Bug #59696 Optimizer fails to move WHERE condition on JOIN column +# when joining with a view +# +CREATE TABLE t1 ( +c1 INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1,4),(3,5),(2,6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.pk, t2.c1 FROM t2, t1 +WHERE t2.pk = t1.c1 AND t2.pk >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`pk` = `test`.`t1`.`c1`) and (`test`.`t1`.`c1` >= 2)) +SELECT t2.pk, t2.c1 FROM t2, t1 +WHERE t2.pk = t1.c1 AND t2.pk >= 2; +pk c1 +2 6 +3 5 +CREATE VIEW v_t2 AS SELECT * FROM t2; +EXPLAIN SELECT v_t2.pk, v_t2.c1 FROM v_t2, t1 +WHERE v_t2.pk = t1.c1 AND v_t2.pk >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c1 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`pk` = `test`.`t1`.`c1`) and (`test`.`t2`.`pk` >= 2)) +SELECT v_t2.pk, v_t2.c1 FROM v_t2, t1 +WHERE v_t2.pk = t1.c1 AND v_t2.pk >= 2; +pk c1 +2 6 +3 5 +DROP VIEW v_t2; +DROP TABLE t1, t2; +# +# Bug 13102033 - CRASH IN COPY_FUNCS IN SQL_SELECT.CC ON JOIN + +# GROUP BY + ORDER BY +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (7,8,1), (8,2,2); +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN SELECT t1.pk +FROM v1, t1 +WHERE v1.i2 = 211 +AND v1.i2 > 7 +OR t1.i1 < 3 +GROUP BY t1.pk +ORDER BY v1.i2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` join `test`.`t1` where (((`test`.`t1`.`i2` = 211) and (`test`.`t1`.`i2` > 7)) or (`test`.`t1`.`i1` < 3)) group by `test`.`t1`.`pk` order by `test`.`t1`.`i2` +SELECT t1.pk +FROM v1, t1 +WHERE v1.i2 = 211 +AND v1.i2 > 7 +OR t1.i1 < 3 +GROUP BY t1.pk +ORDER BY v1.i2; +pk +8 +EXPLAIN SELECT t1.pk +FROM v1, t1 +WHERE (v1.i2 = 211 AND v1.i2 > 7) +OR (t1.i1 < 3 AND v1.i2 < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 62.50 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` join `test`.`t1` where (((`test`.`t1`.`i2` = 211) and (`test`.`t1`.`i2` > 7)) or ((`test`.`t1`.`i1` < 3) and (`test`.`t1`.`i2` < 10))) +SELECT t1.pk +FROM v1, t1 +WHERE (v1.i2 = 211 AND v1.i2 > 7) +OR (t1.i1 < 3 AND v1.i2 < 10); +pk +8 +8 +DROP VIEW v1; +DROP TABLE t1; +# +# BUG#11752239 - 43368: STRAIGHT_JOIN DOESN'T WORK FOR NESTED JOINS +# +create table t1(c1 int primary key, c2 char(10)) engine=myisam; +create table t2(c1 int primary key, c2 char(10), ref_t1 int) engine=myisam; +create table t3(c1 int primary key, c2 char(10), ref_t1 int) engine=myisam; +create table t4(c1 int primary key, c2 char(10), ref_t1 int) engine=myisam; +insert into t1 values(1,'a'); +insert into t2 values(1,'a', 1); +insert into t3 values(1,'a', 1); +insert into t3 values(2,'b',2); +insert into t4 values(1,'a', 1); +insert into t4 values(2,'a', 2); +insert into t4 values(3,'a', 3); +insert into t4 values(4,'a', 4); +insert into t1 values(2,'b'); +insert into t1 values(3,'c'); +EXPLAIN SELECT * FROM t4 JOIN (t1 join t3 on t3.ref_t1 = +t1.c1 join t2 on t2.ref_t1 = t1.c1) on t4.ref_t1 = t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`c1` AS `c1`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`ref_t1` AS `ref_t1`,'1' AS `c1`,'a' AS `c2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2`,`test`.`t3`.`ref_t1` AS `ref_t1`,'1' AS `c1`,'a' AS `c2`,'1' AS `ref_t1` from `test`.`t4` join `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`ref_t1` = '1') and (`test`.`t4`.`ref_t1` = '1')) +EXPLAIN SELECT STRAIGHT_JOIN * FROM t4 JOIN (t1 join t3 on t3.ref_t1 = +t1.c1 join t2 on t2.ref_t1 = t1.c1) on t4.ref_t1 = t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t4.ref_t1 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t4`.`c1` AS `c1`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`ref_t1` AS `ref_t1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2`,`test`.`t3`.`ref_t1` AS `ref_t1`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`ref_t1` AS `ref_t1` from `test`.`t4` join `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`c1` = `test`.`t4`.`ref_t1`) and (`test`.`t3`.`ref_t1` = `test`.`t4`.`ref_t1`) and (`test`.`t2`.`ref_t1` = `test`.`t4`.`ref_t1`)) +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN (t1 join t3 on t3.ref_t1 = +t1.c1 join t2 on t2.ref_t1 = t1.c1) on t4.ref_t1 = t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t4.ref_t1 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`c1` AS `c1`,`test`.`t4`.`c2` AS `c2`,`test`.`t4`.`ref_t1` AS `ref_t1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2`,`test`.`t3`.`ref_t1` AS `ref_t1`,`test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`ref_t1` AS `ref_t1` from `test`.`t4` join `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`ref_t1` = `test`.`t4`.`ref_t1`) and (`test`.`t3`.`ref_t1` = `test`.`t4`.`ref_t1`) and (`test`.`t1`.`c1` = `test`.`t4`.`ref_t1`)) +drop table t1,t2,t3,t4; +# Bug#20455184: Assertion failed: join_cond in optimizer.cc +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 FROM t1 WHERE a) AS q +NATURAL LEFT JOIN t1 +NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` on(true) left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (0 <> `test`.`t1`.`a`) +SELECT 1 +FROM (SELECT 1 FROM t1 WHERE a) AS q +NATURAL LEFT JOIN t1 +NATURAL LEFT JOIN t1 AS t2; +1 +explain SELECT 1 +FROM t1 +NATURAL RIGHT JOIN t1 AS t2 +NATURAL RIGHT JOIN (SELECT 1 FROM t1 WHERE a) AS q; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join (`test`.`t1` `t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on(true) where (0 <> `test`.`t1`.`a`) +SELECT 1 +FROM t1 +NATURAL RIGHT JOIN t1 AS t2 +NATURAL RIGHT JOIN (SELECT 1 FROM t1 WHERE a) AS q; +1 +DROP TABLE t1; +# Bug#21045724: Assertion '!table || !table->read_set ... +CREATE TABLE t1 +(pk INTEGER, +dummy VARCHAR(64), +col_check TINYINT, +PRIMARY KEY(pk) +) engine=innodb; +INSERT INTO t1 VALUES (13, '13', 13); +CREATE VIEW v1 AS +SELECT * +FROM t1 +WHERE pk BETWEEN 13 AND 14; +PREPARE st1 FROM " +UPDATE v1 AS a NATURAL JOIN v1 AS b +SET a.dummy = '', b.col_check = NULL "; +EXECUTE st1; +EXECUTE st1; +DEALLOCATE PREPARE st1; +DROP VIEW v1; +DROP TABLE t1; +# Bug#25424289: Assert '!table->has_null_row()' failed in join_read_key +CREATE TABLE t1 +(pk INT, +col_int_key INT DEFAULT NULL, +col_varchar_10_latin1_key VARCHAR(10) DEFAULT NULL, +col_varchar_255_utf8 VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL, +col_int INT DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_255_latin1_key VARCHAR(255) DEFAULT NULL, +col_date_key date DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) charset latin1 ENGINE=MyISAM; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(8,9,'h','FDUMQ',-1356726272,'2007-09-02 05:48:23','she','2002-04-02','2002-12-20 17:54:07'); +CREATE TABLE t2 +(pk INT, +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +) charset latin1 ENGINE=MyISAM; +CREATE TABLE t3 +(col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,pk,col_int) +) charset latin1 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(NULL,9, 41), (NULL,-1596719104, 48), (-1068105728,9, 49); +CREATE TABLE t4 +(col_varchar_255_latin1_key VARCHAR(255) DEFAULT NULL, +pk INT, +PRIMARY KEY (pk) +) charset latin1 ENGINE=MyISAM; +INSERT INTO t4 VALUES ('RUXDY',8); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status Table is already up to date +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT alias1.pk AS field5 +FROM t3 AS alias1 +LEFT JOIN t4 AS alias2 +LEFT JOIN t4 AS alias3 +LEFT JOIN t1 AS alias4 +LEFT JOIN t2 AS alias5 +ON alias4.pk = alias5.col_int_key +ON alias3.pk = alias5.col_int +ON alias2.col_varchar_255_latin1_key = alias4.col_varchar_10_latin1_key +RIGHT JOIN t1 AS alias6 +ON alias4.pk = alias6.pk +RIGHT JOIN t4 AS alias7 +ON alias6.pk = alias7.pk +ON alias1.col_int_key = alias6.col_int_key +WHERE alias1.col_int > 5 OR +alias5.col_int > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL index NULL test_idx 14 NULL 3 100.00 Using index +1 SIMPLE alias7 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE alias6 NULL eq_ref PRIMARY PRIMARY 4 test.alias7.pk 1 100.00 Using where +1 SIMPLE alias4 NULL eq_ref PRIMARY PRIMARY 4 test.alias6.pk 1 100.00 Using where +1 SIMPLE alias5 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias5.col_int 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`pk` AS `field5` from `test`.`t3` `alias1` left join (`test`.`t4` `alias7` join `test`.`t1` `alias6` left join (`test`.`t4` `alias2` join `test`.`t4` `alias3` join `test`.`t1` `alias4` join `test`.`t2` `alias5`) on(((`test`.`alias3`.`pk` = `test`.`alias5`.`col_int`) and (`test`.`alias4`.`pk` = `test`.`alias7`.`pk`) and (`test`.`alias5`.`col_int_key` = `test`.`alias7`.`pk`) and (`test`.`alias2`.`col_varchar_255_latin1_key` = `test`.`alias4`.`col_varchar_10_latin1_key`)))) on(((`test`.`alias6`.`pk` = `test`.`alias7`.`pk`) and (`test`.`alias6`.`col_int_key` = `test`.`alias1`.`col_int_key`))) where ((`test`.`alias1`.`col_int` > 5) or (`test`.`alias5`.`col_int` > 5)) +SELECT alias1.pk AS field5 +FROM t3 AS alias1 +LEFT JOIN t4 AS alias2 +LEFT JOIN t4 AS alias3 +LEFT JOIN t1 AS alias4 +LEFT JOIN t2 AS alias5 +ON alias4.pk = alias5.col_int_key +ON alias3.pk = alias5.col_int +ON alias2.col_varchar_255_latin1_key = alias4.col_varchar_10_latin1_key +RIGHT JOIN t1 AS alias6 +ON alias4.pk = alias6.pk +RIGHT JOIN t4 AS alias7 +ON alias6.pk = alias7.pk +ON alias1.col_int_key = alias6.col_int_key +WHERE alias1.col_int > 5 OR +alias5.col_int > 5; +field5 +DROP TABLE t1, t2, t3, t4; +# Bug#28727717: Duplicated 'is not null' predicates +create table parent(a int primary key, b int, c int, d int) engine=innodb; +create table eq_child(a int, b int, c int, d int, primary key(a,b)) engine=innodb; +insert into parent values (1,1,1,1); +insert into eq_child select * from parent; +explain format=json select straight_join count(*) from parent +join eq_child as c1 on c1.a = parent.b and c1.b = parent.b +join eq_child as c2 on c2.a = parent.b and c2.b = parent.b +join eq_child as c3 on c3.a = parent.b and c3.b = parent.b +join eq_child as c4 on c4.a = parent.b and c4.b = parent.b +; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "count(*)" + ], + "query_block": { + "cost_info": { + "query_cost": "1.75" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "parent", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "24" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`parent`.`b` is not null)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "c1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "c2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "c3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.40", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "c4", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a", + "b" + ], + "key_length": "8", + "ref": [ + "test.parent.b", + "test.parent.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.75", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `count(*)` from `test`.`parent` join `test`.`eq_child` `c1` join `test`.`eq_child` `c2` join `test`.`eq_child` `c3` join `test`.`eq_child` `c4` where ((`test`.`c1`.`a` = `test`.`parent`.`b`) and (`test`.`c1`.`b` = `test`.`parent`.`b`) and (`test`.`c2`.`a` = `test`.`parent`.`b`) and (`test`.`c2`.`b` = `test`.`parent`.`b`) and (`test`.`c3`.`a` = `test`.`parent`.`b`) and (`test`.`c3`.`b` = `test`.`parent`.`b`) and (`test`.`c4`.`a` = `test`.`parent`.`b`) and (`test`.`c4`.`b` = `test`.`parent`.`b`)) +drop table parent, eq_child; +# +# Bug #29954680: BACKWARDS REF SCAN DOES NOT PERFORM LATE NULLS FILTERING +# +CREATE TABLE t (i INTEGER PRIMARY KEY AUTO_INCREMENT, j INTEGER, KEY(j)) ENGINE=InnoDB; +INSERT INTO t VALUES (NULL, NULL); +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +INSERT INTO t SELECT NULL, NULL FROM t; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=tree SELECT t1.i AS a, (SELECT t2.i FROM t t2 WHERE t1.j = t2.j ORDER BY j DESC, i DESC LIMIT 1) AS b FROM t t1; +EXPLAIN +-> Index scan on t1 using j (cost=411.60 rows=4096) +-> Select #2 (subquery in projection; dependent) + -> Limit: 1 row(s) (cost=410.97 rows=1) + -> Index lookup on t2 using j (j=t1.j; iterate backwards) (cost=410.97 rows=4096) + +Warnings: +Note 1276 Field or reference 'test.t1.j' of SELECT #2 was resolved in SELECT #1 +FLUSH STATUS; +SELECT t1.i AS a, (SELECT t2.i FROM t t2 WHERE t1.j = t2.j ORDER BY j DESC, i DESC LIMIT 1) AS b FROM t t1; +SHOW STATUS LIKE 'Handler_read_key'; +Variable_name Value +Handler_read_key 1 +DROP TABLE t; +set global default_storage_engine=innodb; +set session default_storage_engine=innodb; +# +# Bug#30350696 REFERENCE FROM DERIVED TABLE JOIN CONDITION TO PRECEDING TABLE COLUMN FAILS +# Bug#11748138 ERROR 1054 (42S22): UNKNOWN COLUMN 'T2.I2' IN 'ON CLAUSE' +# +create table t(a int, b int); +insert into t values(1,10),(2,20); +set optimizer_switch="block_nested_loop=off"; +explain format=tree select t1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1; +a b (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +1 10 3 +2 20 4 +explain format=tree select t1.a, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1 +group by t1.a; +EXPLAIN +-> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.a, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +from t t1 +group by t1.a; +a (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) +1 3 +2 4 +create view v1 as select * from t; +explain format=tree select v1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-v1.a) +from v1; +EXPLAIN +-> Table scan on t (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1 +select v1.*, (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-v1.a) +from v1; +a b (select count(*) +from t t2 +left join t t3 on t3.a>t2.a-v1.a) +1 10 3 +2 20 4 +drop view v1; +explain format=tree select t1.*, (select * from +(select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt) +from t t1; +EXPLAIN +-> Table scan on t1 (cost=0.45 rows=2) +-> Select #2 (subquery in projection; dependent) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +select t1.*, (select * from +(select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt) +from t t1; +a b (select * from +(select count(*) +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt) +1 10 3 +2 20 4 +explain format=tree select t1.*, dt.c +from t t1, +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +ERROR 42S22: Unknown column 't1.a' in 'on clause' +explain format=tree select t1.*, dt.c +from t t1, +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +EXPLAIN +-> Nested loop inner join (cost=7.05 rows=0) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (invalidate on row from t1) (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, dt.c +from t t1, +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +a b c +1 10 3 +2 20 4 +explain format=tree select t1.*, dt.c +from t t1 cross join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +EXPLAIN +-> Nested loop inner join (cost=7.05 rows=0) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (invalidate on row from t1) (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, dt.c +from t t1 cross join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt; +a b c +1 10 3 +2 20 4 +explain format=tree select t1.*, dt.c +from t t1 join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt +on true; +EXPLAIN +-> Nested loop inner join (cost=7.05 rows=0) + -> Invalidate materialized tables (row from t1) (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on dt (cost=2.50..2.50 rows=0) + -> Materialize (invalidate on row from t1) (cost=2.50..2.50 rows=0) + -> Aggregate: count(0) + -> Nested loop left join (cost=1.35 rows=4) + -> Table scan on t2 (cost=0.45 rows=2) + -> Filter: (t3.a > (t2.a - t1.a)) (cost=0.35 rows=2) + -> Table scan on t3 (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +select t1.*, dt.c +from t t1 join +lateral +(select count(*) as c +from t t2 +left join t t3 on t3.a>t2.a-t1.a) as dt +on true; +a b c +1 10 3 +2 20 4 +select t1.* from t t0 cross join (t t1 join t t2 on 100=t0.a); +ERROR 42S22: Unknown column 't0.a' in 'on clause' +select t1.* from t t0 cross join (t t1 join t t2 +on 100=(select count(*) +from t t3 +left join t t4 +on t4.a>t3.a-t0.a)); +ERROR 42S22: Unknown column 't0.a' in 'on clause' +select t1.* from t t0 cross join t t1 join t t2 +on 100=(select count(*) +from t t3 +left join t t4 +on t4.a>t3.a-t0.a); +a b +set optimizer_switch=default; +drop table t; +create table t(a int); +insert into t values(1),(2); +set optimizer_switch="firstmatch=off,block_nested_loop=off"; +explain format=tree select * from t t1 +where t1.a in (select dt.a +from t t2 +left join (select * from t t3 where t3.a>t1.a) dt +on true); +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.75 rows=4) + -> Filter: (t1.a > t1.a) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Limit: 1 row(s) (cost=1.00 rows=2) + -> Nested loop inner join (cost=1.00 rows=2) + -> Filter: (t3.a = t1.a) (cost=0.30 rows=1) + -> Table scan on t3 (cost=0.30 rows=2) + -> Table scan on t2 (cost=0.70 rows=2) + +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +select * from t t1 +where t1.a in (select dt.a +from t t2 +left join (select * from t t3 where t3.a>t1.a) dt +on true); +a +drop table t; +set optimizer_switch=default; +set global default_storage_engine=innodb; +# +# WL#14071: ASSERTION `!(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE))' FAILED +# +CREATE TABLE t1 ( +a INTEGER +); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +a INTEGER +); +SELECT * FROM +( +t2 LEFT JOIN t2 AS t3 ON t2.pk IS NULL +) LEFT JOIN t1 ON t1.a = t3.a; +pk a pk a a +DROP TABLE t1, t2; +# +# Bug #31924828: WL#14071: HYPERGAPH RETURNS DIFFERENT RESULTS WITH ONLY_FULL_GROUP_BY DISABLED +# +CREATE TABLE t1 ( pk INTEGER ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( pk INTEGER ); +SELECT * FROM t1 LEFT JOIN t2 ON TRUE WHERE t2.pk <=> 3; +pk pk +DROP TABLE t1, t2; +# +# Bug #31947917: WL#14071: ASAN LEAKS SEEN DURING SHUTDOWN +# +CREATE TABLE A ( pk INTEGER ); +SELECT t1.pk FROM A t1, A t2, A t3, A t4, A t5 GROUP BY t1.pk; +pk +DROP TABLE A; +# +# Bug #32234666: HASHJOINITERATOR::READROWFROMPROBEITERATOR(): ASSERTION `!THD()->IS_ERROR()' FAILED. +# +CREATE TABLE t ( +a BIT(50), +b VARCHAR(22772) character set ucs2, +c INTEGER, +d TINYBLOB, +PRIMARY KEY (a), +KEY i0001 (c,d(163)) +); +INSERT INTO t VALUES (1,'',1,'1'); +INSERT INTO t VALUES (0x03ffffffffffff,'2',0,'2'); +SELECT t2.b FROM t AS t1 +LEFT JOIN t AS t2 ON t2.c < 70 +WHERE t2.a - from_unixtime(0) > 0; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(`test`.`t2`.`a` - (from_unixtime(0)))' +DROP TABLE t; diff --git a/mysql-test/r/join_cache_bka.result-pq b/mysql-test/r/join_cache_bka.result-pq new file mode 100644 index 000000000..d38b18358 --- /dev/null +++ b/mysql-test/r/join_cache_bka.result-pq @@ -0,0 +1,3245 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +DROP DATABASE IF EXISTS world; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0' +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +SELECT COUNT(*) FROM country; +COUNT(*) +239 +SELECT COUNT(*) FROM city; +COUNT(*) +4079 +SELECT COUNT(*) FROM countrylanguage; +COUNT(*) +984 +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where; Using join buffer (hash join) +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=2048; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 2048 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where; Using join buffer (hash join) +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +DROP DATABASE world; +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +EXPLAIN +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL eq_ref PRIMARY PRIMARY 132 world.country.Code,const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`country`.`Name` AS `Name`,if((`world`.`countrylanguage`.`Country` is null),NULL,`world`.`countrylanguage`.`Percentage`) AS `IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage)` from `world`.`country` left join `world`.`countrylanguage` on(((`world`.`countrylanguage`.`Language` = 'English') and (`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`))) where (`world`.`country`.`Population` > 10000000) +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +Name IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +Afghanistan NULL +Algeria NULL +Angola NULL +Argentina NULL +Australia 81.19999694824219 +Bangladesh NULL +Belarus NULL +Belgium NULL +Brazil NULL +Burkina Faso NULL +Cambodia NULL +Cameroon NULL +Canada 60.400001525878906 +Chile NULL +China NULL +Colombia NULL +Congo, The Democratic Republic of the NULL +Cuba NULL +Czech Republic NULL +Côte d’Ivoire NULL +Ecuador NULL +Egypt NULL +Ethiopia NULL +France NULL +Germany NULL +Ghana NULL +Greece NULL +Guatemala NULL +Hungary NULL +India NULL +Indonesia NULL +Iran NULL +Iraq NULL +Italy NULL +Japan 0.10000000149011612 +Kazakstan NULL +Kenya NULL +Madagascar NULL +Malawi NULL +Malaysia 1.600000023841858 +Mali NULL +Mexico NULL +Morocco NULL +Mozambique NULL +Myanmar NULL +Nepal NULL +Netherlands NULL +Niger NULL +Nigeria NULL +North Korea NULL +Pakistan NULL +Peru NULL +Philippines NULL +Poland NULL +Romania NULL +Russian Federation NULL +Saudi Arabia NULL +Somalia NULL +South Africa 8.5 +South Korea NULL +Spain NULL +Sri Lanka NULL +Sudan NULL +Syria NULL +Taiwan NULL +Tanzania NULL +Thailand NULL +Turkey NULL +Uganda NULL +Ukraine NULL +United Kingdom 97.30000305175781 +United States 86.19999694824219 +Uzbekistan NULL +Venezuela NULL +Vietnam NULL +Yemen NULL +Yugoslavia NULL +Zimbabwe 2.200000047683716 +set join_buffer_size=256; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 256 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=256; +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE city NULL range Population,Country Population 4 NULL # 100.00 Using index condition; Using MRR +2 SIMPLE country NULL eq_ref PRIMARY PRIMARY 12 world.city.Country # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`country`.`Code` = `world`.`city`.`Country`) and (`world`.`city`.`Population` > 3000000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=default; +ALTER TABLE country MODIFY Name varchar(52) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country MODIFY Name varchar(250) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country ADD COLUMN PopulationBar text; +UPDATE country +SET PopulationBar=REPEAT('x', CAST(Population/100000 AS unsigned int)); +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=256; +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=default; +DROP DATABASE world; +use test; +CREATE TABLE t1( +affiliatetometaid int NOT NULL default '0', +uniquekey int NOT NULL default '0', +metaid int NOT NULL default '0', +affiliateid int NOT NULL default '0', +xml text, +isactive char(1) NOT NULL default 'Y', +PRIMARY KEY (affiliatetometaid) +); +CREATE UNIQUE INDEX t1_uniquekey ON t1(uniquekey); +CREATE INDEX t1_affiliateid ON t1(affiliateid); +CREATE INDEX t1_metaid on t1 (metaid); +INSERT INTO t1 VALUES +(1616, 1571693233, 1391, 2, NULL, 'Y'), (1943, 1993216749, 1726, 2, NULL, 'Y'); +CREATE TABLE t2( +metaid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +dateadded timestamp NOT NULL , +xml text, +status int default NULL, +origin int default NULL, +gid int NOT NULL default '1', +formattypeid int default NULL, +PRIMARY KEY (metaid) +); +CREATE INDEX t2_status ON t2(status); +CREATE INDEX t2_gid ON t2(gid); +CREATE INDEX t2_formattypeid ON t2(formattypeid); +INSERT INTO t2 VALUES +(1391, "I Just Died", "2003-10-02 10:07:37", "", 1, NULL, 3, NULL), +(1726, "Me, Myself & I", "2003-12-05 11:24:36", " ", 1, NULL, 3, NULL); +CREATE TABLE t3( +mediaid int NOT NULL , +metaid int NOT NULL default '0', +formatid int NOT NULL default '0', +status int default NULL, +path varchar(100) NOT NULL default '', +datemodified timestamp NOT NULL , +resourcetype int NOT NULL default '1', +parameters text, +signature int default NULL, +quality int NOT NULL default '255', +PRIMARY KEY (mediaid) +); +CREATE INDEX t3_metaid ON t3(metaid); +CREATE INDEX t3_formatid ON t3(formatid); +CREATE INDEX t3_status ON t3(status); +CREATE INDEX t3_metaidformatid ON t3(metaid,formatid); +CREATE INDEX t3_signature ON t3(signature); +CREATE INDEX t3_quality ON t3(quality); +INSERT INTO t3 VALUES +(6, 4, 8, 0, "010101_anastacia_spmidi.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255), +(3343, 3, 8, 1, "010102_4VN4bsPwnxRQUJW5Zp1RhG2IL9vvl_8.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255); +CREATE TABLE t4( +formatid int NOT NULL , +name varchar(60) NOT NULL default '', +formatclassid int NOT NULL default '0', +mime varchar(60) default NULL, +extension varchar(10) default NULL, +priority int NOT NULL default '0', +canaddtocapability char(1) NOT NULL default 'Y', +PRIMARY KEY (formatid) +); +CREATE INDEX t4_formatclassid ON t4(formatclassid); +CREATE INDEX t4_formats_idx ON t4(canaddtocapability); +INSERT INTO t4 VALUES +(19, "XHTML", 11, "text/html", "xhtml", 10, 'Y'), +(54, "AMR (wide band)", 13, "audio/amr-wb", "awb", 0, 'Y'); +CREATE TABLE t5( +formatclassid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int NOT NULL default '0', +formattypeid int NOT NULL default '0', +PRIMARY KEY (formatclassid) +); +CREATE INDEX t5_formattypeid on t5(formattypeid); +INSERT INTO t5 VALUES +(11, "Info", 0, 4), (13, "Digital Audio", 0, 2); +CREATE TABLE t6( +formattypeid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int default NULL, +PRIMARY KEY (formattypeid) +); +INSERT INTO t6 VALUES +(2, "Ringtones", 0); +CREATE TABLE t7( +metaid int NOT NULL default '0', +artistid int NOT NULL default '0', +PRIMARY KEY (metaid,artistid) +); +INSERT INTO t7 VALUES +(4, 5), (3, 4); +CREATE TABLE t8( +artistid int NOT NULL , +name varchar(80) NOT NULL default '', +PRIMARY KEY (artistid) +); +INSERT INTO t8 VALUES +(5, "Anastacia"), (4, "John Mayer"); +CREATE TABLE t9( +subgenreid int NOT NULL default '0', +metaid int NOT NULL default '0', +PRIMARY KEY (subgenreid,metaid) +) ; +CREATE INDEX t9_subgenreid ON t9(subgenreid); +CREATE INDEX t9_metaid ON t9(metaid); +INSERT INTO t9 VALUES +(138, 4), (31, 3); +CREATE TABLE t10( +subgenreid int NOT NULL , +genreid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +PRIMARY KEY (subgenreid) +) ; +CREATE INDEX t10_genreid ON t10(genreid); +INSERT INTO t10 VALUES +(138, 19, ''), (31, 3, ''); +CREATE TABLE t11( +genreid int NOT NULL default '0', +name char(80) NOT NULL default '', +priority int NOT NULL default '0', +masterclip char(1) default NULL, +PRIMARY KEY (genreid) +) ; +CREATE INDEX t11_masterclip ON t11( masterclip); +INSERT INTO t11 VALUES +(19, "Pop & Dance", 95, 'Y'), (3, "Rock & Alternative", 100, 'Y'); +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +EXPLAIN +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t1_affiliateid,t1_metaid t1_metaid 4 test.t7.metaid 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t10 NULL eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 100.00 NULL +1 SIMPLE t11 NULL eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t7.metaid 1 100.00 NULL +1 SIMPLE t3 NULL ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaid 4 test.t7.metaid 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t4 NULL ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formatclassid 4 test.t5.formatclassid 1 100.00 Using index condition; Using where; Using join buffer (Batched Key Access) +1 SIMPLE t5 NULL ref PRIMARY,t5_formattypeid t5_formattypeid 4 const 1 100.00 NULL +1 SIMPLE t6 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t7 NULL index PRIMARY PRIMARY 8 NULL 2 50.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE t8 NULL ALL PRIMARY NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t9 NULL ref PRIMARY,t9_subgenreid,t9_metaid t9_metaid 4 test.t7.metaid 1 100.00 Using index +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +uniquekey affiliateXml artistName artistid genreName genreid genrePriority subgenreid subgenreName metaName metaid metaXml overallPriority path mediaid formatid formatName formatclassid formatclassName formattypeid formattypeName +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +CREATE TABLE t1 (a1 int, filler1 char(64) default ' ' ); +CREATE TABLE t2 ( +a2 int, b2 int, filler2 char(64) default ' ', +PRIMARY KEY idx(a2,b2,filler2) +) ; +CREATE TABLE t3 (b3 int, c3 int, INDEX idx(b3)); +INSERT INTO t1(a1) VALUES +(4), (7), (1), (9), (8), (5), (3), (6), (2); +INSERT INTO t2(a2,b2) VALUES +(1,30), (3,40), (2,61), (6,73), (8,92), (9,27), (4,18), (5,84), (7,56), +(4,14), (6,76), (8,98), (7,55), (1,39), (2,68), (3,45), (9,21), (5,81), +(5,88), (2,65), (6,74), (9,23), (1,37), (3,44), (4,17), (8,99), (7,51), +(9,28), (7,52), (1,33), (4,13), (5,87), (3,43), (8,91), (2,62), (6,79), +(3,49), (8,93), (7,34), (5,82), (6,78), (2,63), (1,32), (9,22), (4,11); +INSERT INTO t3 VALUES +(30,302), (92,923), (18,187), (45,459), (30,309), +(39,393), (68,685), (45,458), (21,210), (81,817), +(40,405), (61,618), (73,738), (92,929), (27,275), +(18,188), (84,846), (56,564), (14,144), (76,763), +(98,982), (55,551), (17,174), (99,998), (51,513), +(28,282), (52,527), (33,336), (13,138), (87,878), +(43,431), (91,916), (62,624), (79,797), (49,494), +(93,933), (34,347), (82,829), (78,780), (63,634), +(32,329), (22,228), (11,114), (74,749), (23,236); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +set join_buffer_size=512; +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, b int, INDEX idx(b)); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); +INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); +INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); +set join_buffer_size=32; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '32' +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 5 NULL 3 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 2 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` >= 30)) +SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +a b a b +7 40 7 10 +7 40 7 10 +7 40 7 20 +8 30 8 10 +8 30 8 20 +DROP TABLE t1,t2; + +BUG#40136: Group by is ignored when join buffer is used for an outer join + +create table t1(a int PRIMARY KEY, b int); +insert into t1 values +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +create table t2 (p int, a int, INDEX i_a(a)); +insert into t2 values +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index; Using temporary +2 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where true group by `test`.`t1`.`a` +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a order by t1.a; +a count +1 1 +2 0 +3 2 +5 0 +6 0 +7 2 +8 0 +9 0 +drop table t1, t2; +# +# Bug #40134: outer join with not exists optimization and join buffer +# +set join_buffer_size=default; +CREATE TABLE t1 (a int NOT NULL); +INSERT INTO t1 VALUES (2), (4), (3), (5), (1); +CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); +INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL i_a NULL NULL NULL 5 20.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`b` is null) +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +a a b +3 NULL NULL +5 NULL NULL +1 NULL NULL +DROP TABLE t1, t2; +# +# BUG#40268: Nested outer join with not null-rejecting where condition +# over an inner table which is not the last in the nest +# +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 LEFT JOIN (t3, t4) ON t2.b=t4.b +WHERE t3.a+2 NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`c` = 102) or (`test`.`t2`.`c` is null)) +select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; +a b a c +2 20 NULL NULL +3 30 3 102 +drop table t1, t2; +# +# Bug #40317: outer join with with constant on expression equal to FALSE +# +create table t1 (a int); +insert into t1 values (30), (40), (20); +create table t2 (b int); +insert into t2 values (200), (100); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select * from t1 left join t2 on (1=0); +a b +30 NULL +40 NULL +20 NULL +explain select * from t1 left join t2 on (1=0) where a=40; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(false) where (`test`.`t1`.`a` = 40) +select * from t1 left join t2 on (1=0) where a=40; +a b +40 NULL +drop table t1, t2; +# +# Bug #41204: small buffer with big rec_per_key for ref access +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0); +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1 VALUES (20000), (10000); +CREATE TABLE t2 (pk int AUTO_INCREMENT PRIMARY KEY, b int, c int, INDEX idx(b)); +INSERT INTO t2(b,c) VALUES (10000, 3), (20000, 7), (20000, 1), (10000, 9), (20000, 5); +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +ANALYZE TABLE t1,t2; +set join_buffer_size=1024; +EXPLAIN SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2050 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2050 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 640 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t2`.`c`) AS `AVG(c)` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +AVG(c) +5.0000 +set join_buffer_size=default; +DROP TABLE t1, t2; +# +# Bug #41894: big join buffer of level 7 used to join records +# with null values in place of varchar strings +# +CREATE TABLE t1 (a int NOT NULL AUTO_INCREMENT PRIMARY KEY, +b varchar(127) DEFAULT NULL); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +CREATE TABLE t2 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t2 SELECT * FROM t1; +CREATE TABLE t3 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t3 SELECT * FROM t1; +set join_buffer_size=1024*1024; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 16400 10.00 Parallel execute (4 workers) +2 SIMPLE # NULL ALL PRIMARY NULL NULL # 16400 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +COUNT(*) +16384 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +# +# Bug #42020: join buffer is used for outer join with fields of +# several outer tables in join buffer +# +CREATE TABLE t1 ( +a bigint NOT NULL, +PRIMARY KEY (a) +); +INSERT INTO t1 VALUES +(2), (1); +CREATE TABLE t2 ( +a bigint NOT NULL, +b bigint NOT NULL, +PRIMARY KEY (a,b) +); +INSERT INTO t2 VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(1,10), (1, 20), (1,30), (1,40), (1,50); +CREATE TABLE t3 ( +pk bigint NOT NULL AUTO_INCREMENT, +a bigint NOT NULL, +b bigint NOT NULL, +val bigint DEFAULT '0', +PRIMARY KEY (pk), +KEY idx (a,b) +); +INSERT INTO t3(a,b) VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(4,30), (4,40), (4,50), (4,60), (4,70), (4,80), +(5,30), (5,40), (5,50), (5,60), (5,70), (5,80), +(7,30), (7,40), (7,50), (7,60), (7,70), (7,80); +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=256; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 16 test.t1.a,test.t2.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +DROP INDEX idx ON t3; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 24 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +create table t1(f1 int, f2 int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2(f1 int not null, f2 int not null, f3 char(200), key(f1,f2)); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +explain select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t2`.`f2`)) +drop table t1,t2; +# +# Bug #42955: join with GROUP BY/ORDER BY and when BKA is enabled +# +create table t1 (d int, id1 int, index idx1 (d, id1)); +insert into t1 values +(3, 20), (2, 40), (3, 10), (1, 10), (3, 20), (1, 40), (2, 30), (3, 30); +create table t2 (id1 int, id2 int, index idx2 (id1)); +insert into t2 values +(20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), +(40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index; Using temporary +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,sum(`test`.`t2`.`id2`) AS `sum(t2.id2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3)) group by `test`.`t1`.`id1` +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id1 sum(t2.id2) +10 900 +20 2000 +30 900 +explain +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL idx2 NULL NULL NULL 12 8.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3) and (`test`.`t2`.`id2` > 200)) order by `test`.`t1`.`id1` +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id1 +10 +10 +20 +20 +20 +20 +30 +30 +drop table t1,t2; +# +# Bug #44019: star-like multi-join query executed optimizer_join_cache_level=6 +# +create table t1 (a int, b int, c int, d int); +create table t2 (b int, e varchar(16), index idx(b)); +create table t3 (d int, f varchar(16), index idx(d)); +create table t4 (c int, g varchar(16), index idx(c)); +insert into t1 values +(5, 50, 500, 5000), (3, 30, 300, 3000), (9, 90, 900, 9000), +(2, 20, 200, 2000), (4, 40, 400, 4000), (8, 80, 800, 800), +(7, 70, 700, 7000); +insert into t2 values +(30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), +(31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), +(32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t3 values +(4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), +(4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), +(4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t4 values +(200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), +(201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), +(202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +analyze table t2,t3,t4; +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref idx idx 5 test.t1.d 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref idx idx 5 test.t1.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t2`.`e` AS `e`,`test`.`t3`.`f` AS `f`,`test`.`t4`.`g` AS `g` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c` = `test`.`t1`.`c`) and (`test`.`t3`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +a b c d e f g +3 30 300 3000 bbb ddd ccc +drop table t1,t2,t3,t4; +# +# Bug #44250: Corruption of linked join buffers when using BKA +# +CREATE TABLE t1 ( +id1 bigint(20) DEFAULT NULL, +id2 bigint(20) DEFAULT NULL, +id3 bigint(20) DEFAULT NULL, +num1 bigint(20) DEFAULT NULL, +num2 int(11) DEFAULT NULL, +num3 bigint(20) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id3 bigint(20) NOT NULL DEFAULT '0', +id4 bigint(20) DEFAULT NULL, +enum1 enum('Enabled','Disabled','Paused') DEFAULT NULL, +PRIMARY KEY (id3) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +id4 bigint(20) NOT NULL DEFAULT '0', +text1 text, +PRIMARY KEY (id4) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +id2 bigint(20) NOT NULL DEFAULT '0', +dummy int(11) DEFAULT '0', +PRIMARY KEY (id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +id1 bigint(20) NOT NULL DEFAULT '0', +id2 bigint(20) NOT NULL DEFAULT '0', +enum2 enum('Active','Deleted','Paused') DEFAULT NULL, +PRIMARY KEY (id1,id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set join_buffer_size=2048; +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id3 # 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.id4 # 33.33 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id2 # 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 16 test.t1.id1,test.t1.id2 # 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`num3` AS `num3`,`test`.`t3`.`text1` AS `text1`,`test`.`t3`.`id4` AS `id4`,`test`.`t2`.`id3` AS `id3`,`test`.`t4`.`dummy` AS `dummy` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` join `test`.`t5` where ((`test`.`t2`.`id3` = `test`.`t1`.`id3`) and (`test`.`t3`.`id4` = `test`.`t2`.`id4`) and (`test`.`t5`.`enum2` = 'Active') and (`test`.`t4`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`text1` < 'D')) +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id1 num3 text1 id4 id3 dummy +228172702 134 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 14 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 15 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 3 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 10 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 14 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 17 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 18 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 19 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 26 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 28 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 50 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 6 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 60 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 61 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 62 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 84 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 89 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 9 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3,t4,t5; +# +# Bug #46328: Use of aggregate function without GROUP BY clause +# returns many rows (vs. one ) +# +CREATE TABLE t1 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(0),(2),(2),(2),(3),(4),(5),(5),(6),(6),(8),(8),(9),(9); +CREATE TABLE t2 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2),(3); + +# The query shall return 1 record with a max value 9 and one of the +# int_key values inserted above (undefined which one, so it's replaced +# with "#"). +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +MAX(t1.int_key) int_key +9 # + +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 14 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL int_key 4 NULL 14 100.00 Using index +2 SIMPLE t2 NULL index NULL int_key 4 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`int_key`) AS `MAX(t1.int_key)`,`test`.`t1`.`int_key` AS `int_key` from `test`.`t1` straight_join `test`.`t2` + +DROP TABLE t1,t2; +# +# Bug #45019: join buffer contains two blob columns one of which is +# used in the key employed to access the joined table +# +CREATE TABLE t1 (c1 int, c2 int, key (c2)); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,2); +CREATE TABLE t2 (c1 text, c2 text); +INSERT INTO t2 VALUES('tt', 'uu'); +INSERT INTO t2 VALUES('zzzz', 'xxxxxxxxx'); +ANALYZE TABLE t1,t2; +SELECT t1.*, t2.*, LENGTH(t2.c1), LENGTH(t2.c2) FROM t1,t2 +WHERE t1.c2=LENGTH(t2.c2) and t1.c1=LENGTH(t2.c1); +c1 c2 c1 c2 LENGTH(t2.c1) LENGTH(t2.c2) +2 2 tt uu 2 2 +DROP TABLE t1,t2; +# +# Regression test for +# Bug#46733 - NULL value not returned for aggregate on empty result +# set w/ semijoin on +CREATE TABLE t1 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,'a'),(11,'b'),(12,'c'),(13,'d'); +CREATE TABLE t2 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'x'),(2,'y'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +MAX(t1.i) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'y' + +EXPLAIN +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`i`) AS `MAX(t1.i)` from `test`.`t1` join `test`.`t2` where (0 <> `test`.`t2`.`v`) + +DROP TABLE t1,t2; +# +# Bug#51092: Linked join buffer gives wrong result +# for 3-way cross join +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,1),(2,2); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t3 VALUES (1,1),(2,2); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +SELECT t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +DROP TABLE t1,t2,t3; +# +# BUG#52394 Segfault in JOIN_CACHE::get_offset () at sql_select.h:445 +# +CREATE TABLE C(a int); +INSERT INTO C VALUES(1),(2),(3),(4),(5); +CREATE TABLE D (a int(11), b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO D VALUES (6,'r'),(27,'o'); +CREATE TABLE E (a int(11) primary key, b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO E VALUES +(14,'d'),(15,'z'),(16,'e'),(17,'h'),(18,'b'),(19,'s'),(20,'e'),(21,'j'),(22,'e'),(23,'f'),(24,'v'),(25,'x'),(26,'m'),(27,'c'); +SELECT 1 FROM C,D,E WHERE D.a = E.a AND D.b = E.b; +1 +DROP TABLE C,D,E; +# +# BUG#52540 Crash in JOIN_CACHE::set_match_flag_if_none () at sql_join_cache.cc:1883 +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (a varchar(10)); +INSERT INTO t2 VALUES ('f'),('x'); +CREATE TABLE t3 (pk int(11) PRIMARY KEY); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (2); +CREATE TABLE t4 (a varchar(10)); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` left join (`test`.`t1` join `test`.`t3` left join `test`.`t4` on(true)) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`))) where true +SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +1 +1 +1 +DROP TABLE t1,t2,t3,t4; +# +# Bug#51084: Batched key access crashes for SELECT with +# derived table and LEFT JOIN +# +CREATE TABLE t1 ( +carrier int, +id int PRIMARY KEY +); +INSERT INTO t1 VALUES (1,11),(1,12),(2,13); +CREATE TABLE t2 ( +scan_date int, +package_id int +); +INSERT INTO t2 VALUES (2008,21),(2008,22); +CREATE TABLE t3 ( +carrier int PRIMARY KEY, +id int +); +INSERT INTO t3 VALUES (1,31); +CREATE TABLE t4 ( +carrier_id int, +INDEX carrier_id(carrier_id) +); +INSERT INTO t4 VALUES (31),(32); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK + +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +COUNT(*) +6 + +EXPLAIN +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref carrier_id carrier_id 5 test.t3.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`carrier_id` = `test`.`t3`.`id`) and (`test`.`t3`.`carrier` = `test`.`t1`.`carrier`))) where true + +DROP TABLE t1,t2,t3,t4; +# +# Bug#45267: Incomplete check caused wrong result. +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15), +(16),(17),(18),(19),(20); +CREATE TABLE t2 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10,9,'22:36:46'),(11,0,'08:46:46'); +SELECT DISTINCT t1.`pk` +FROM t1 RIGHT JOIN t2 STRAIGHT_JOIN t3 ON t2.`int_nokey` ON t2.`time_key` +GROUP BY 1; +pk +NULL +DROP TABLE IF EXISTS t1, t2, t3; +# +# BUG#52636 6.0 allowing JOINs on NULL values w/ optimizer_join_cache_level = 5-8 +# +CREATE TABLE t1 (b int); +INSERT INTO t1 VALUES (NULL),(3); +CREATE TABLE t2 (a int, b int, KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,200); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +delete from t1; +INSERT INTO t1 VALUES (NULL),(NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (b varchar(100)); +INSERT INTO t1 VALUES (NULL),("some varchar"); +CREATE TABLE t2 (a int, b varchar(100), KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 403 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +# +# BUG#54359 "Extra rows with join_cache_level=7,8 and two joins +# --and multi-column index" +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)) +; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,9,'k','k'); +INSERT INTO t1 VALUES (12,5,'k','k'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE table3 NULL ALL col_varchar_key NULL NULL NULL 2 50.00 Using where +2 SIMPLE table2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`col_int_key` AS `col_int_key` from `test`.`t1` `table2` join `test`.`t1` `table3` FORCE INDEX (`col_varchar_key`) where ((`test`.`table2`.`col_varchar_nokey` = `test`.`table3`.`col_varchar_key`) and (0 <> `test`.`table3`.`pk`) and (`test`.`table3`.`col_int_key` >= `test`.`table2`.`pk`)) +SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +col_int_key +9 +9 +drop table t1; +# +# BUG#54481 "GROUP BY loses effect with JOIN + ORDER BY + LIMIT +# and join_cache_level=5-8" +# +CREATE TABLE t1 ( +`col_int_key` int, +`col_datetime` datetime, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t1 VALUES (2,'2003-02-11 21:19:41'); +INSERT INTO t1 VALUES (3,'2009-10-18 02:27:49'); +INSERT INTO t1 VALUES (0,'2000-09-26 07:45:57'); +INSERT INTO t1 VALUES (4,'2000-09-26 07:45:57'); +CREATE TABLE t2 ( +`col_int` int, +`col_int_key` int, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t2 VALUES (14,1); +INSERT INTO t2 VALUES (98,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` FORCE INDEX (`col_int_key`) join `test`.`t2` IGNORE INDEX (`col_int_key`) where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +drop table t1,t2; + +# Bug#11766522 "59651: ASSERTION `TABLE_REF->HAS_RECORD' FAILED +# WITH JOIN_CACHE_LEVEL=3" + +CREATE TABLE t1 ( +b varchar(20) +) ; +INSERT INTO t1 VALUES ('1'),('1'); +CREATE TABLE t4 ( +col253 text +) ; +INSERT INTO t4 VALUES (''),('pf'); +CREATE TABLE t6 ( +col282 timestamp +) ; +INSERT INTO t6 VALUES ('2010-11-07 01:04:45'),('2010-12-13 01:36:32'); +CREATE TABLE t7 ( +col319 timestamp NOT NULL, +UNIQUE KEY idx263 (col319) +) ; +insert into t7 values("2000-01-01"),("2000-01-02"); +CREATE TABLE t3 ( +col582 char(230) CHARACTER SET utf8 DEFAULT NULL +) ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES ('cymej'),('spb'); +CREATE TABLE t5 ( +col712 time +) ; +insert into t5 values(0),(0); +CREATE TABLE t8 ( +col804 char(169), +col805 varchar(51) +) ; +INSERT INTO t8 VALUES ('tmqcb','pwk'); +CREATE TABLE t2 ( +col841 varchar(10) +) ; +INSERT INTO t2 VALUES (''),(''); +set join_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '1' +select @@join_buffer_size; +@@join_buffer_size +128 +select count(*) from +(t1 join t2 join t3) +left join t4 on 1 +left join t5 on 1 like t4.col253 +left join t6 on t5.col712 is null +left join t7 on t1.b <=>t7.col319 +left join t8 on t3.col582 <= 1; +count(*) +32 +drop table t1,t2,t3,t4,t5,t6,t7,t8; +# +# Bug#12616131 - JCL: NULL VS DATE + TWICE AS MANY ROWS +# RETURNED WHEN JCL>=7 +# +CREATE TABLE t1 (t1a int, t1b int); +INSERT INTO t1 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t2 (t2a int, t2b int, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +# t2b is NULL-able + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL 999 NULL + +DROP TABLE t2; +CREATE TABLE t2 (t2a int, t2b int NOT NULL, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK + +# t2b is NOT NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +DROP TABLE t1,t2; +# +# BUG#12619399 - JCL: NO ROWS VS 3X NULL QUERY OUTPUT WHEN JCL>=5 +# +CREATE TABLE t1 ( +c1 INTEGER NOT NULL, +c2_key INTEGER NOT NULL, +KEY col_int_key (c2_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (24,204); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (10); +CREATE TABLE t3 ( +c1 INTEGER, +KEY k1 (c1) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL), (NULL); +set @old_opt_switch=@@optimizer_switch; + +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=tree SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +EXPLAIN +-> Filter: ((t3.c1,(select #2)) xor true) (cost=0.45 rows=2) + -> Index scan on t3 using k1 (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) (cost=0.72 rows=1) + -> Nested loop inner join (cost=0.72 rows=1) + -> Filter: (outer_field_is_not_null, ((t3.c1) = t1.c2_key), true) (cost=0.35 rows=1) + -> Alternative plans for IN subquery: Index lookup unless c2_key IS NULL (cost=0.35 rows=1) + -> Index lookup on t1 using col_int_key (c2_key=(t3.c1)) + -> Table scan on t1 + -> Filter: (t2.pk < t1.c1) (cost=0.37 rows=1) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.37 rows=1) + +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where (`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`))) is false) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +1 SIMPLE t3 NULL ref k1 k1 5 test.t1.c2_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` semi join (`test`.`t2` join `test`.`t1`) where ((`test`.`t3`.`c1` = `test`.`t1`.`c2_key`) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)) +SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 + +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +set @@join_buffer_size=default; + +# BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH +# JCL>=5 AND MRR ENABLED" + +CREATE TABLE t1 ( col_int_key int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'j'),(4,'b'),(4,'d'); +CREATE TABLE t2 ( +col_datetime_key datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) ENGINE=innodb; +INSERT INTO t2 VALUES ('2003-08-21 00:00:00','b'); +explain SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key,col_varchar_key col_varchar_key 10 NULL 3 100.00 Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where true group by `field2` order by `field1` +SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +field1 field2 +2003-08-21 00:00:00 4 +NULL 0 +DROP TABLE t1,t2; + +# BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5" + +CREATE TABLE t1 ( +col_int_key int(11) NOT NULL, +col_datetime_key datetime NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,'2004-06-06 04:22:12','v'); +INSERT INTO t1 VALUES (0,'2005-11-13 01:12:31','s'); +INSERT INTO t1 VALUES (9,'2002-05-04 01:50:00','l'); +INSERT INTO t1 VALUES (3,'2004-10-27 10:28:45','y'); +INSERT INTO t1 VALUES (4,'2006-07-22 05:24:23','c'); +INSERT INTO t1 VALUES (2,'2002-05-16 21:34:03','i'); +INSERT INTO t1 VALUES (5,'2008-04-17 10:45:30','h'); +INSERT INTO t1 VALUES (3,'2009-04-21 02:58:02','q'); +INSERT INTO t1 VALUES (1,'2008-01-11 11:01:51','a'); +INSERT INTO t1 VALUES (3,'1900-01-01 00:00:00','v'); +INSERT INTO t1 VALUES (6,'2007-05-17 18:24:57','u'); +INSERT INTO t1 VALUES (7,'2007-08-07 00:00:00','s'); +INSERT INTO t1 VALUES (5,'2001-08-28 00:00:00','y'); +INSERT INTO t1 VALUES (1,'2004-04-16 00:27:28','z'); +INSERT INTO t1 VALUES (204,'2005-05-03 07:06:22','h'); +INSERT INTO t1 VALUES (224,'2009-03-11 17:09:50','p'); +INSERT INTO t1 VALUES (9,'2007-12-08 01:54:28','e'); +INSERT INTO t1 VALUES (5,'2009-07-28 18:19:54','i'); +INSERT INTO t1 VALUES (0,'2008-06-08 00:00:00','y'); +INSERT INTO t1 VALUES (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES +(1,'j'),(2,'v'),(3,'c'),(4,'m'),(5,'d'),(6,'d'),(7,'y'), +(8,'t'),(9,'d'),(10,'s'),(11,'r'),(12,'m'),(13,'b'),(14,'x'), +(15,'g'),(16,'p'),(17,'q'),(18,'w'),(19,'d'),(20,'e'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where true group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key` +SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +field1 COUNT(DISTINCT t1.col_varchar_nokey) field4 +b 0 13 +c 4 3 +d 0 19 +d 1 6 +d 2 9 +d 3 5 +e 0 20 +g 0 15 +j 2 1 +m 0 12 +m 1 4 +p 0 16 +q 0 17 +r 0 11 +s 0 10 +t 0 8 +v 1 2 +w 0 18 +x 0 14 +y 2 7 +DROP TABLE t1,t2; + +# BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5" + +CREATE TABLE t1 (col_varchar_key varchar(1)); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (5,3,9); +INSERT INTO t2 VALUES (6,246,24); +INSERT INTO t2 VALUES (7,2,6); +INSERT INTO t2 VALUES (8,9,1); +INSERT INTO t2 VALUES (9,3,6); +INSERT INTO t2 VALUES (10,8,2); +INSERT INTO t2 VALUES (11,1,4); +INSERT INTO t2 VALUES (12,8,8); +INSERT INTO t2 VALUES (13,8,4); +INSERT INTO t2 VALUES (14,5,4); +INSERT INTO t2 VALUES (15,7,7); +INSERT INTO t2 VALUES (16,5,4); +INSERT INTO t2 VALUES (17,1,1); +INSERT INTO t2 VALUES (18,6,9); +INSERT INTO t2 VALUES (19,2,4); +INSERT INTO t2 VALUES (20,9,8); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze Error Table 'test.t3' doesn't exist +test.t3 analyze status Operation failed +test.t4 analyze Error Table 'test.t4' doesn't exist +test.t4 analyze status Operation failed +explain SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 16 100.00 Using temporary +2 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias2.col_int_nokey 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `field1`,`test`.`alias2`.`col_int_key` AS `field4` from `test`.`t2` `alias2` straight_join `test`.`t2` `alias3` left join `test`.`t1` on((0 <> `test`.`alias3`.`col_int_nokey`)) where (`test`.`alias3`.`pk` = `test`.`alias2`.`col_int_nokey`) group by `field1`,`field4` limit 15 +SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +field1 field4 +NULL 1 +NULL 2 +NULL 4 +NULL 7 +NULL 8 +NULL 9 +DROP TABLE t1,t2; + +# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT +# JCL=6 ONLY [NULL VERSUS NULL+#INTS] + +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k)); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t1 VALUES (6,NULL,6),(0,1,11); +INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL); +INSERT INTO t3 VALUES (2,3,0),(3,4,4); +INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k 5 NULL 2 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.k 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `t2_pk`,`test`.`t4`.`pk` AS `t4_pk`,`test`.`t4`.`k` AS `t4_k`,`test`.`t4`.`i` AS `t4_i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`pk` = `test`.`t1`.`k`)) left join `test`.`t3` on((0 <> `test`.`t3`.`i`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where true +SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +t2_pk t4_pk t4_k t4_i +1 1 9 -1 +NULL NULL NULL NULL +DROP TABLE t1, t2, t3, t4; + +# BUG#12827509 - BNL/BKA: SELECT LEFT/RIGHT JOIN QUERY GIVES +# DIFFERENT OUTPUT ON BNL=OFF+BKA=ON +# (Duplicate of BUG#12722133) + +CREATE TABLE t1 ( +col_int INTEGER +); +INSERT INTO t1 VALUES (3), (7), (2), (8), (6); +CREATE TABLE t2 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1,5), (2,8), (6,3), (8,7), (9,9); +CREATE TABLE t3 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (3,2), (4,3), (8,2); +CREATE TABLE t4 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (2,3), (6,1), (8,2); +ANALYZE TABLE t2, t3, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int` AS `col_int` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col_int` = `test`.`t1`.`col_int`)) left join `test`.`t3` on((`test`.`t3`.`pk` = `test`.`t2`.`pk`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where ((0 <> `test`.`t1`.`col_int`) or (0 <> `test`.`t3`.`col_int`)) +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +col_int +1 +2 +3 +NULL +NULL +DROP TABLE t1, t2, t3, t4; +# +# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) +# POINTS TO UNINITIALISED BYTE(S) +# +CREATE TABLE t1 ( +col1 varchar(10), +col2 varchar(1024) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('a','a'); +CREATE TABLE t2 (i varchar(10)) ENGINE=innodb; +INSERT INTO t2 VALUES ('a'); +SELECT t1.col1 +FROM t1 JOIN t2 ON t1.col1 = t2.i +GROUP BY t1.col2; +col1 +a +DROP TABLE t1,t2; +# End of Bug#12997905 +# +# Bug 13596330 - EXTRA ROW ON SELECT WITH NESTED IN CLAUSE + IS +# NULL WHEN SEMIJOIN + BNL IS ON +# +CREATE TABLE t1 ( +col_int_nokey int +); +INSERT INTO t1 VALUES(-1),(-1); +CREATE TABLE t2 ( +col_int_nokey int, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t2 VALUES (9, '2002-08-25 20:35:06', 'e'), +(9, '2002-08-25 20:35:06', 'e'); +set @optimizer_switch_saved=@@session.optimizer_switch; +set @@session.optimizer_switch='semijoin=off'; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY parent1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY child1 NULL index_subquery col_varchar_key col_varchar_key 7 func 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.parent1.col_datetime_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`parent1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` `parent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`parent1`.`col_int_nokey`)) where (`test`.`parent1`.`col_varchar_key`,(((`test`.`parent1`.`col_varchar_key`) in t2 on col_varchar_key where ((`test`.`parent1`.`col_datetime_nokey` = TIMESTAMP'0000-00-00 00:00:00') and (`test`.`t1`.`col_int_nokey` is null))))) +SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +col_varchar_key +set @@session.optimizer_switch=@optimizer_switch_saved; +DROP TABLE t1,t2; +# +# Bug#29435133 JOIN_CACHE::JOIN_RECORD() MAY LEAVE A TABLE IN HAS_NULL_ROW-STATE +# +CREATE TABLE t1 ( +col_varchar_10_unique varchar(10) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('nthfyejwxd'); +INSERT INTO t1 VALUES ('drrqahbhai'); +CREATE TABLE t3 ( +col_int int(11) NOT NULL, +col_int_unique int(11) not null, +col_varchar_10 varchar(10) not null +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES(9, 4, ''); +CREATE TABLE t4 ( +col_int_unique int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES(3); +CREATE TABLE t2 ( +col_int int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY table4s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY table3s NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY table2s NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_varchar_10_unique` AS `col_varchar_10_unique` from `test`.`t1` `table1` where ((`test`.`table1`.`col_varchar_10_unique`,(/* select#2 */ select straight_join `test`.`table3s`.`col_varchar_10` AS `field3` from `test`.`t4` `table4s` left join (`test`.`t3` `table3s` join `test`.`t2` `table2s`) on((`test`.`table3s`.`col_int_unique` = `test`.`table4s`.`col_int_unique`)) where (outer_field_is_not_null, (((`test`.`table1`.`col_varchar_10_unique`) <> `test`.`table3s`.`col_varchar_10`) or (`test`.`table3s`.`col_varchar_10` is null)), true) having (outer_field_is_not_null, (`test`.`table3s`.`col_varchar_10`), true)))) +SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +col_varchar_10_unique +DROP TABLE t1,t2,t3,t4; +# +# t2 and t3 are const tables, which makes for a t1-t4 join on a constant, +# where the constant comes from a multi-equality. Verify that we get the expected +# query plan and don't crash (we don't care about the result). +# +CREATE TABLE t1 ( +pk integer NOT NULL, +a integer, +b integer, +PRIMARY KEY (pk), +KEY idx1 (b) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM +t1 +LEFT JOIN t1 AS t2 ON t1.a = t2.pk +LEFT JOIN t1 AS t3 ON t2.pk = t3.pk +LEFT JOIN t1 AS t4 ON t3.b = t4.b +WHERE t2.pk = 1; +EXPLAIN +-> Parallel scan on + -> Batched key access left join + -> Batch input rows + -> Filter: (t1.a = 1) (cost=0.35 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Multi-range index lookup on t4 using idx1 (b='5') + +DROP TABLE t1; +set optimizer_switch = default; diff --git a/mysql-test/r/join_cache_bka_nobnl.result-pq b/mysql-test/r/join_cache_bka_nobnl.result-pq new file mode 100644 index 000000000..e614fc63e --- /dev/null +++ b/mysql-test/r/join_cache_bka_nobnl.result-pq @@ -0,0 +1,3245 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +DROP DATABASE IF EXISTS world; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0' +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +SELECT COUNT(*) FROM country; +COUNT(*) +239 +SELECT COUNT(*) FROM city; +COUNT(*) +4079 +SELECT COUNT(*) FROM countrylanguage; +COUNT(*) +984 +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=2048; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 2048 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +DROP DATABASE world; +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +EXPLAIN +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL eq_ref PRIMARY PRIMARY 132 world.country.Code,const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`country`.`Name` AS `Name`,if((`world`.`countrylanguage`.`Country` is null),NULL,`world`.`countrylanguage`.`Percentage`) AS `IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage)` from `world`.`country` left join `world`.`countrylanguage` on(((`world`.`countrylanguage`.`Language` = 'English') and (`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`))) where (`world`.`country`.`Population` > 10000000) +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +Name IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +Afghanistan NULL +Algeria NULL +Angola NULL +Argentina NULL +Australia 81.19999694824219 +Bangladesh NULL +Belarus NULL +Belgium NULL +Brazil NULL +Burkina Faso NULL +Cambodia NULL +Cameroon NULL +Canada 60.400001525878906 +Chile NULL +China NULL +Colombia NULL +Congo, The Democratic Republic of the NULL +Cuba NULL +Czech Republic NULL +Côte d’Ivoire NULL +Ecuador NULL +Egypt NULL +Ethiopia NULL +France NULL +Germany NULL +Ghana NULL +Greece NULL +Guatemala NULL +Hungary NULL +India NULL +Indonesia NULL +Iran NULL +Iraq NULL +Italy NULL +Japan 0.10000000149011612 +Kazakstan NULL +Kenya NULL +Madagascar NULL +Malawi NULL +Malaysia 1.600000023841858 +Mali NULL +Mexico NULL +Morocco NULL +Mozambique NULL +Myanmar NULL +Nepal NULL +Netherlands NULL +Niger NULL +Nigeria NULL +North Korea NULL +Pakistan NULL +Peru NULL +Philippines NULL +Poland NULL +Romania NULL +Russian Federation NULL +Saudi Arabia NULL +Somalia NULL +South Africa 8.5 +South Korea NULL +Spain NULL +Sri Lanka NULL +Sudan NULL +Syria NULL +Taiwan NULL +Tanzania NULL +Thailand NULL +Turkey NULL +Uganda NULL +Ukraine NULL +United Kingdom 97.30000305175781 +United States 86.19999694824219 +Uzbekistan NULL +Venezuela NULL +Vietnam NULL +Yemen NULL +Yugoslavia NULL +Zimbabwe 2.200000047683716 +set join_buffer_size=256; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 256 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=256; +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE city NULL range Population,Country Population 4 NULL # 100.00 Using index condition; Using MRR +2 SIMPLE country NULL eq_ref PRIMARY PRIMARY 12 world.city.Country # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`country`.`Code` = `world`.`city`.`Country`) and (`world`.`city`.`Population` > 3000000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=default; +ALTER TABLE country MODIFY Name varchar(52) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country MODIFY Name varchar(250) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country ADD COLUMN PopulationBar text; +UPDATE country +SET PopulationBar=REPEAT('x', CAST(Population/100000 AS unsigned int)); +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=256; +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=default; +DROP DATABASE world; +use test; +CREATE TABLE t1( +affiliatetometaid int NOT NULL default '0', +uniquekey int NOT NULL default '0', +metaid int NOT NULL default '0', +affiliateid int NOT NULL default '0', +xml text, +isactive char(1) NOT NULL default 'Y', +PRIMARY KEY (affiliatetometaid) +); +CREATE UNIQUE INDEX t1_uniquekey ON t1(uniquekey); +CREATE INDEX t1_affiliateid ON t1(affiliateid); +CREATE INDEX t1_metaid on t1 (metaid); +INSERT INTO t1 VALUES +(1616, 1571693233, 1391, 2, NULL, 'Y'), (1943, 1993216749, 1726, 2, NULL, 'Y'); +CREATE TABLE t2( +metaid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +dateadded timestamp NOT NULL , +xml text, +status int default NULL, +origin int default NULL, +gid int NOT NULL default '1', +formattypeid int default NULL, +PRIMARY KEY (metaid) +); +CREATE INDEX t2_status ON t2(status); +CREATE INDEX t2_gid ON t2(gid); +CREATE INDEX t2_formattypeid ON t2(formattypeid); +INSERT INTO t2 VALUES +(1391, "I Just Died", "2003-10-02 10:07:37", "", 1, NULL, 3, NULL), +(1726, "Me, Myself & I", "2003-12-05 11:24:36", " ", 1, NULL, 3, NULL); +CREATE TABLE t3( +mediaid int NOT NULL , +metaid int NOT NULL default '0', +formatid int NOT NULL default '0', +status int default NULL, +path varchar(100) NOT NULL default '', +datemodified timestamp NOT NULL , +resourcetype int NOT NULL default '1', +parameters text, +signature int default NULL, +quality int NOT NULL default '255', +PRIMARY KEY (mediaid) +); +CREATE INDEX t3_metaid ON t3(metaid); +CREATE INDEX t3_formatid ON t3(formatid); +CREATE INDEX t3_status ON t3(status); +CREATE INDEX t3_metaidformatid ON t3(metaid,formatid); +CREATE INDEX t3_signature ON t3(signature); +CREATE INDEX t3_quality ON t3(quality); +INSERT INTO t3 VALUES +(6, 4, 8, 0, "010101_anastacia_spmidi.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255), +(3343, 3, 8, 1, "010102_4VN4bsPwnxRQUJW5Zp1RhG2IL9vvl_8.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255); +CREATE TABLE t4( +formatid int NOT NULL , +name varchar(60) NOT NULL default '', +formatclassid int NOT NULL default '0', +mime varchar(60) default NULL, +extension varchar(10) default NULL, +priority int NOT NULL default '0', +canaddtocapability char(1) NOT NULL default 'Y', +PRIMARY KEY (formatid) +); +CREATE INDEX t4_formatclassid ON t4(formatclassid); +CREATE INDEX t4_formats_idx ON t4(canaddtocapability); +INSERT INTO t4 VALUES +(19, "XHTML", 11, "text/html", "xhtml", 10, 'Y'), +(54, "AMR (wide band)", 13, "audio/amr-wb", "awb", 0, 'Y'); +CREATE TABLE t5( +formatclassid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int NOT NULL default '0', +formattypeid int NOT NULL default '0', +PRIMARY KEY (formatclassid) +); +CREATE INDEX t5_formattypeid on t5(formattypeid); +INSERT INTO t5 VALUES +(11, "Info", 0, 4), (13, "Digital Audio", 0, 2); +CREATE TABLE t6( +formattypeid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int default NULL, +PRIMARY KEY (formattypeid) +); +INSERT INTO t6 VALUES +(2, "Ringtones", 0); +CREATE TABLE t7( +metaid int NOT NULL default '0', +artistid int NOT NULL default '0', +PRIMARY KEY (metaid,artistid) +); +INSERT INTO t7 VALUES +(4, 5), (3, 4); +CREATE TABLE t8( +artistid int NOT NULL , +name varchar(80) NOT NULL default '', +PRIMARY KEY (artistid) +); +INSERT INTO t8 VALUES +(5, "Anastacia"), (4, "John Mayer"); +CREATE TABLE t9( +subgenreid int NOT NULL default '0', +metaid int NOT NULL default '0', +PRIMARY KEY (subgenreid,metaid) +) ; +CREATE INDEX t9_subgenreid ON t9(subgenreid); +CREATE INDEX t9_metaid ON t9(metaid); +INSERT INTO t9 VALUES +(138, 4), (31, 3); +CREATE TABLE t10( +subgenreid int NOT NULL , +genreid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +PRIMARY KEY (subgenreid) +) ; +CREATE INDEX t10_genreid ON t10(genreid); +INSERT INTO t10 VALUES +(138, 19, ''), (31, 3, ''); +CREATE TABLE t11( +genreid int NOT NULL default '0', +name char(80) NOT NULL default '', +priority int NOT NULL default '0', +masterclip char(1) default NULL, +PRIMARY KEY (genreid) +) ; +CREATE INDEX t11_masterclip ON t11( masterclip); +INSERT INTO t11 VALUES +(19, "Pop & Dance", 95, 'Y'), (3, "Rock & Alternative", 100, 'Y'); +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +EXPLAIN +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t1_affiliateid,t1_metaid t1_metaid 4 test.t7.metaid 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t10 NULL eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 100.00 NULL +1 SIMPLE t11 NULL eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t7.metaid 1 100.00 NULL +1 SIMPLE t3 NULL ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaid 4 test.t7.metaid 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t4 NULL ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formatclassid 4 test.t5.formatclassid 1 100.00 Using index condition; Using where; Using join buffer (Batched Key Access) +1 SIMPLE t5 NULL ref PRIMARY,t5_formattypeid t5_formattypeid 4 const 1 100.00 NULL +1 SIMPLE t6 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t7 NULL index PRIMARY PRIMARY 8 NULL 2 50.00 Using where; Using index +1 SIMPLE t8 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +1 SIMPLE t9 NULL ref PRIMARY,t9_subgenreid,t9_metaid t9_metaid 4 test.t7.metaid 1 100.00 Using index +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +uniquekey affiliateXml artistName artistid genreName genreid genrePriority subgenreid subgenreName metaName metaid metaXml overallPriority path mediaid formatid formatName formatclassid formatclassName formattypeid formattypeName +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +CREATE TABLE t1 (a1 int, filler1 char(64) default ' ' ); +CREATE TABLE t2 ( +a2 int, b2 int, filler2 char(64) default ' ', +PRIMARY KEY idx(a2,b2,filler2) +) ; +CREATE TABLE t3 (b3 int, c3 int, INDEX idx(b3)); +INSERT INTO t1(a1) VALUES +(4), (7), (1), (9), (8), (5), (3), (6), (2); +INSERT INTO t2(a2,b2) VALUES +(1,30), (3,40), (2,61), (6,73), (8,92), (9,27), (4,18), (5,84), (7,56), +(4,14), (6,76), (8,98), (7,55), (1,39), (2,68), (3,45), (9,21), (5,81), +(5,88), (2,65), (6,74), (9,23), (1,37), (3,44), (4,17), (8,99), (7,51), +(9,28), (7,52), (1,33), (4,13), (5,87), (3,43), (8,91), (2,62), (6,79), +(3,49), (8,93), (7,34), (5,82), (6,78), (2,63), (1,32), (9,22), (4,11); +INSERT INTO t3 VALUES +(30,302), (92,923), (18,187), (45,459), (30,309), +(39,393), (68,685), (45,458), (21,210), (81,817), +(40,405), (61,618), (73,738), (92,929), (27,275), +(18,188), (84,846), (56,564), (14,144), (76,763), +(98,982), (55,551), (17,174), (99,998), (51,513), +(28,282), (52,527), (33,336), (13,138), (87,878), +(43,431), (91,916), (62,624), (79,797), (49,494), +(93,933), (34,347), (82,829), (78,780), (63,634), +(32,329), (22,228), (11,114), (74,749), (23,236); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +set join_buffer_size=512; +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, b int, INDEX idx(b)); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); +INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); +INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); +set join_buffer_size=32; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '32' +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 5 NULL 3 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 2 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` >= 30)) +SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +a b a b +7 40 7 10 +7 40 7 10 +7 40 7 20 +8 30 8 10 +8 30 8 20 +DROP TABLE t1,t2; + +BUG#40136: Group by is ignored when join buffer is used for an outer join + +create table t1(a int PRIMARY KEY, b int); +insert into t1 values +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +create table t2 (p int, a int, INDEX i_a(a)); +insert into t2 values +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index; Using temporary +2 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where true group by `test`.`t1`.`a` +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a order by t1.a; +a count +1 1 +2 0 +3 2 +5 0 +6 0 +7 2 +8 0 +9 0 +drop table t1, t2; +# +# Bug #40134: outer join with not exists optimization and join buffer +# +set join_buffer_size=default; +CREATE TABLE t1 (a int NOT NULL); +INSERT INTO t1 VALUES (2), (4), (3), (5), (1); +CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); +INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref i_a i_a 4 test.t1.a 2 20.00 Using where; Not exists; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`b` is null) +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +a a b +3 NULL NULL +5 NULL NULL +1 NULL NULL +DROP TABLE t1, t2; +# +# BUG#40268: Nested outer join with not null-rejecting where condition +# over an inner table which is not the last in the nest +# +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 LEFT JOIN (t3, t4) ON t2.b=t4.b +WHERE t3.a+2 NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`c` = 102) or (`test`.`t2`.`c` is null)) +select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; +a b a c +2 20 NULL NULL +3 30 3 102 +drop table t1, t2; +# +# Bug #40317: outer join with with constant on expression equal to FALSE +# +create table t1 (a int); +insert into t1 values (30), (40), (20); +create table t2 (b int); +insert into t2 values (200), (100); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select * from t1 left join t2 on (1=0); +a b +30 NULL +40 NULL +20 NULL +explain select * from t1 left join t2 on (1=0) where a=40; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(false) where (`test`.`t1`.`a` = 40) +select * from t1 left join t2 on (1=0) where a=40; +a b +40 NULL +drop table t1, t2; +# +# Bug #41204: small buffer with big rec_per_key for ref access +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0); +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1 VALUES (20000), (10000); +CREATE TABLE t2 (pk int AUTO_INCREMENT PRIMARY KEY, b int, c int, INDEX idx(b)); +INSERT INTO t2(b,c) VALUES (10000, 3), (20000, 7), (20000, 1), (10000, 9), (20000, 5); +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +ANALYZE TABLE t1,t2; +set join_buffer_size=1024; +EXPLAIN SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2050 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2050 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 640 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t2`.`c`) AS `AVG(c)` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +AVG(c) +5.0000 +set join_buffer_size=default; +DROP TABLE t1, t2; +# +# Bug #41894: big join buffer of level 7 used to join records +# with null values in place of varchar strings +# +CREATE TABLE t1 (a int NOT NULL AUTO_INCREMENT PRIMARY KEY, +b varchar(127) DEFAULT NULL); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +CREATE TABLE t2 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t2 SELECT * FROM t1; +CREATE TABLE t3 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t3 SELECT * FROM t1; +set join_buffer_size=1024*1024; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 16400 10.00 Parallel execute (4 workers) +2 SIMPLE # NULL ALL PRIMARY NULL NULL # 16400 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +COUNT(*) +16384 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +# +# Bug #42020: join buffer is used for outer join with fields of +# several outer tables in join buffer +# +CREATE TABLE t1 ( +a bigint NOT NULL, +PRIMARY KEY (a) +); +INSERT INTO t1 VALUES +(2), (1); +CREATE TABLE t2 ( +a bigint NOT NULL, +b bigint NOT NULL, +PRIMARY KEY (a,b) +); +INSERT INTO t2 VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(1,10), (1, 20), (1,30), (1,40), (1,50); +CREATE TABLE t3 ( +pk bigint NOT NULL AUTO_INCREMENT, +a bigint NOT NULL, +b bigint NOT NULL, +val bigint DEFAULT '0', +PRIMARY KEY (pk), +KEY idx (a,b) +); +INSERT INTO t3(a,b) VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(4,30), (4,40), (4,50), (4,60), (4,70), (4,80), +(5,30), (5,40), (5,50), (5,60), (5,70), (5,80), +(7,30), (7,40), (7,50), (7,60), (7,70), (7,80); +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=256; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 16 test.t1.a,test.t2.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +DROP INDEX idx ON t3; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 24 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +create table t1(f1 int, f2 int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2(f1 int not null, f2 int not null, f3 char(200), key(f1,f2)); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +explain select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t2`.`f2`)) +drop table t1,t2; +# +# Bug #42955: join with GROUP BY/ORDER BY and when BKA is enabled +# +create table t1 (d int, id1 int, index idx1 (d, id1)); +insert into t1 values +(3, 20), (2, 40), (3, 10), (1, 10), (3, 20), (1, 40), (2, 30), (3, 30); +create table t2 (id1 int, id2 int, index idx2 (id1)); +insert into t2 values +(20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), +(40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index; Using temporary +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,sum(`test`.`t2`.`id2`) AS `sum(t2.id2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3)) group by `test`.`t1`.`id1` +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id1 sum(t2.id2) +10 900 +20 2000 +30 900 +explain +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 33.33 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3) and (`test`.`t2`.`id2` > 200)) order by `test`.`t1`.`id1` +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id1 +10 +10 +20 +20 +20 +20 +30 +30 +drop table t1,t2; +# +# Bug #44019: star-like multi-join query executed optimizer_join_cache_level=6 +# +create table t1 (a int, b int, c int, d int); +create table t2 (b int, e varchar(16), index idx(b)); +create table t3 (d int, f varchar(16), index idx(d)); +create table t4 (c int, g varchar(16), index idx(c)); +insert into t1 values +(5, 50, 500, 5000), (3, 30, 300, 3000), (9, 90, 900, 9000), +(2, 20, 200, 2000), (4, 40, 400, 4000), (8, 80, 800, 800), +(7, 70, 700, 7000); +insert into t2 values +(30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), +(31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), +(32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t3 values +(4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), +(4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), +(4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t4 values +(200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), +(201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), +(202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +analyze table t2,t3,t4; +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref idx idx 5 test.t1.d 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref idx idx 5 test.t1.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t2`.`e` AS `e`,`test`.`t3`.`f` AS `f`,`test`.`t4`.`g` AS `g` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c` = `test`.`t1`.`c`) and (`test`.`t3`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +a b c d e f g +3 30 300 3000 bbb ddd ccc +drop table t1,t2,t3,t4; +# +# Bug #44250: Corruption of linked join buffers when using BKA +# +CREATE TABLE t1 ( +id1 bigint(20) DEFAULT NULL, +id2 bigint(20) DEFAULT NULL, +id3 bigint(20) DEFAULT NULL, +num1 bigint(20) DEFAULT NULL, +num2 int(11) DEFAULT NULL, +num3 bigint(20) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id3 bigint(20) NOT NULL DEFAULT '0', +id4 bigint(20) DEFAULT NULL, +enum1 enum('Enabled','Disabled','Paused') DEFAULT NULL, +PRIMARY KEY (id3) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +id4 bigint(20) NOT NULL DEFAULT '0', +text1 text, +PRIMARY KEY (id4) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +id2 bigint(20) NOT NULL DEFAULT '0', +dummy int(11) DEFAULT '0', +PRIMARY KEY (id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +id1 bigint(20) NOT NULL DEFAULT '0', +id2 bigint(20) NOT NULL DEFAULT '0', +enum2 enum('Active','Deleted','Paused') DEFAULT NULL, +PRIMARY KEY (id1,id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set join_buffer_size=2048; +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id3 # 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.id4 # 33.33 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id2 # 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 16 test.t1.id1,test.t1.id2 # 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`num3` AS `num3`,`test`.`t3`.`text1` AS `text1`,`test`.`t3`.`id4` AS `id4`,`test`.`t2`.`id3` AS `id3`,`test`.`t4`.`dummy` AS `dummy` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` join `test`.`t5` where ((`test`.`t2`.`id3` = `test`.`t1`.`id3`) and (`test`.`t3`.`id4` = `test`.`t2`.`id4`) and (`test`.`t5`.`enum2` = 'Active') and (`test`.`t4`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`text1` < 'D')) +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id1 num3 text1 id4 id3 dummy +228172702 134 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 14 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 15 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 3 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 10 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 14 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 17 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 18 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 19 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 26 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 28 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 50 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 6 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 60 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 61 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 62 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 84 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 89 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 9 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3,t4,t5; +# +# Bug #46328: Use of aggregate function without GROUP BY clause +# returns many rows (vs. one ) +# +CREATE TABLE t1 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(0),(2),(2),(2),(3),(4),(5),(5),(6),(6),(8),(8),(9),(9); +CREATE TABLE t2 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2),(3); + +# The query shall return 1 record with a max value 9 and one of the +# int_key values inserted above (undefined which one, so it's replaced +# with "#"). +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +MAX(t1.int_key) int_key +9 # + +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 14 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL int_key 4 NULL 14 100.00 Using index +2 SIMPLE t2 NULL index NULL int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`int_key`) AS `MAX(t1.int_key)`,`test`.`t1`.`int_key` AS `int_key` from `test`.`t1` straight_join `test`.`t2` + +DROP TABLE t1,t2; +# +# Bug #45019: join buffer contains two blob columns one of which is +# used in the key employed to access the joined table +# +CREATE TABLE t1 (c1 int, c2 int, key (c2)); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,2); +CREATE TABLE t2 (c1 text, c2 text); +INSERT INTO t2 VALUES('tt', 'uu'); +INSERT INTO t2 VALUES('zzzz', 'xxxxxxxxx'); +ANALYZE TABLE t1,t2; +SELECT t1.*, t2.*, LENGTH(t2.c1), LENGTH(t2.c2) FROM t1,t2 +WHERE t1.c2=LENGTH(t2.c2) and t1.c1=LENGTH(t2.c1); +c1 c2 c1 c2 LENGTH(t2.c1) LENGTH(t2.c2) +2 2 tt uu 2 2 +DROP TABLE t1,t2; +# +# Regression test for +# Bug#46733 - NULL value not returned for aggregate on empty result +# set w/ semijoin on +CREATE TABLE t1 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,'a'),(11,'b'),(12,'c'),(13,'d'); +CREATE TABLE t2 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'x'),(2,'y'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +MAX(t1.i) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'y' + +EXPLAIN +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`i`) AS `MAX(t1.i)` from `test`.`t1` join `test`.`t2` where (0 <> `test`.`t2`.`v`) + +DROP TABLE t1,t2; +# +# Bug#51092: Linked join buffer gives wrong result +# for 3-way cross join +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,1),(2,2); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t3 VALUES (1,1),(2,2); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +SELECT t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +DROP TABLE t1,t2,t3; +# +# BUG#52394 Segfault in JOIN_CACHE::get_offset () at sql_select.h:445 +# +CREATE TABLE C(a int); +INSERT INTO C VALUES(1),(2),(3),(4),(5); +CREATE TABLE D (a int(11), b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO D VALUES (6,'r'),(27,'o'); +CREATE TABLE E (a int(11) primary key, b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO E VALUES +(14,'d'),(15,'z'),(16,'e'),(17,'h'),(18,'b'),(19,'s'),(20,'e'),(21,'j'),(22,'e'),(23,'f'),(24,'v'),(25,'x'),(26,'m'),(27,'c'); +SELECT 1 FROM C,D,E WHERE D.a = E.a AND D.b = E.b; +1 +DROP TABLE C,D,E; +# +# BUG#52540 Crash in JOIN_CACHE::set_match_flag_if_none () at sql_join_cache.cc:1883 +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (a varchar(10)); +INSERT INTO t2 VALUES ('f'),('x'); +CREATE TABLE t3 (pk int(11) PRIMARY KEY); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (2); +CREATE TABLE t4 (a varchar(10)); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` left join (`test`.`t1` join `test`.`t3` left join `test`.`t4` on(true)) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`))) where true +SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +1 +1 +1 +DROP TABLE t1,t2,t3,t4; +# +# Bug#51084: Batched key access crashes for SELECT with +# derived table and LEFT JOIN +# +CREATE TABLE t1 ( +carrier int, +id int PRIMARY KEY +); +INSERT INTO t1 VALUES (1,11),(1,12),(2,13); +CREATE TABLE t2 ( +scan_date int, +package_id int +); +INSERT INTO t2 VALUES (2008,21),(2008,22); +CREATE TABLE t3 ( +carrier int PRIMARY KEY, +id int +); +INSERT INTO t3 VALUES (1,31); +CREATE TABLE t4 ( +carrier_id int, +INDEX carrier_id(carrier_id) +); +INSERT INTO t4 VALUES (31),(32); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK + +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +COUNT(*) +6 + +EXPLAIN +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.carrier 1 100.00 NULL +2 SIMPLE t4 NULL ref carrier_id carrier_id 5 test.t3.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`carrier_id` = `test`.`t3`.`id`) and (`test`.`t3`.`carrier` = `test`.`t1`.`carrier`))) where true + +DROP TABLE t1,t2,t3,t4; +# +# Bug#45267: Incomplete check caused wrong result. +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15), +(16),(17),(18),(19),(20); +CREATE TABLE t2 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10,9,'22:36:46'),(11,0,'08:46:46'); +SELECT DISTINCT t1.`pk` +FROM t1 RIGHT JOIN t2 STRAIGHT_JOIN t3 ON t2.`int_nokey` ON t2.`time_key` +GROUP BY 1; +pk +NULL +DROP TABLE IF EXISTS t1, t2, t3; +# +# BUG#52636 6.0 allowing JOINs on NULL values w/ optimizer_join_cache_level = 5-8 +# +CREATE TABLE t1 (b int); +INSERT INTO t1 VALUES (NULL),(3); +CREATE TABLE t2 (a int, b int, KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,200); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +delete from t1; +INSERT INTO t1 VALUES (NULL),(NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (b varchar(100)); +INSERT INTO t1 VALUES (NULL),("some varchar"); +CREATE TABLE t2 (a int, b varchar(100), KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 403 test.t1.b 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +# +# BUG#54359 "Extra rows with join_cache_level=7,8 and two joins +# --and multi-column index" +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)) +; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,9,'k','k'); +INSERT INTO t1 VALUES (12,5,'k','k'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE table3 NULL ALL col_varchar_key NULL NULL NULL 2 50.00 Using where +2 SIMPLE table2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`col_int_key` AS `col_int_key` from `test`.`t1` `table2` join `test`.`t1` `table3` FORCE INDEX (`col_varchar_key`) where ((`test`.`table2`.`col_varchar_nokey` = `test`.`table3`.`col_varchar_key`) and (0 <> `test`.`table3`.`pk`) and (`test`.`table3`.`col_int_key` >= `test`.`table2`.`pk`)) +SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +col_int_key +9 +9 +drop table t1; +# +# BUG#54481 "GROUP BY loses effect with JOIN + ORDER BY + LIMIT +# and join_cache_level=5-8" +# +CREATE TABLE t1 ( +`col_int_key` int, +`col_datetime` datetime, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t1 VALUES (2,'2003-02-11 21:19:41'); +INSERT INTO t1 VALUES (3,'2009-10-18 02:27:49'); +INSERT INTO t1 VALUES (0,'2000-09-26 07:45:57'); +INSERT INTO t1 VALUES (4,'2000-09-26 07:45:57'); +CREATE TABLE t2 ( +`col_int` int, +`col_int_key` int, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t2 VALUES (14,1); +INSERT INTO t2 VALUES (98,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` FORCE INDEX (`col_int_key`) join `test`.`t2` IGNORE INDEX (`col_int_key`) where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +drop table t1,t2; + +# Bug#11766522 "59651: ASSERTION `TABLE_REF->HAS_RECORD' FAILED +# WITH JOIN_CACHE_LEVEL=3" + +CREATE TABLE t1 ( +b varchar(20) +) ; +INSERT INTO t1 VALUES ('1'),('1'); +CREATE TABLE t4 ( +col253 text +) ; +INSERT INTO t4 VALUES (''),('pf'); +CREATE TABLE t6 ( +col282 timestamp +) ; +INSERT INTO t6 VALUES ('2010-11-07 01:04:45'),('2010-12-13 01:36:32'); +CREATE TABLE t7 ( +col319 timestamp NOT NULL, +UNIQUE KEY idx263 (col319) +) ; +insert into t7 values("2000-01-01"),("2000-01-02"); +CREATE TABLE t3 ( +col582 char(230) CHARACTER SET utf8 DEFAULT NULL +) ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES ('cymej'),('spb'); +CREATE TABLE t5 ( +col712 time +) ; +insert into t5 values(0),(0); +CREATE TABLE t8 ( +col804 char(169), +col805 varchar(51) +) ; +INSERT INTO t8 VALUES ('tmqcb','pwk'); +CREATE TABLE t2 ( +col841 varchar(10) +) ; +INSERT INTO t2 VALUES (''),(''); +set join_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '1' +select @@join_buffer_size; +@@join_buffer_size +128 +select count(*) from +(t1 join t2 join t3) +left join t4 on 1 +left join t5 on 1 like t4.col253 +left join t6 on t5.col712 is null +left join t7 on t1.b <=>t7.col319 +left join t8 on t3.col582 <= 1; +count(*) +32 +drop table t1,t2,t3,t4,t5,t6,t7,t8; +# +# Bug#12616131 - JCL: NULL VS DATE + TWICE AS MANY ROWS +# RETURNED WHEN JCL>=7 +# +CREATE TABLE t1 (t1a int, t1b int); +INSERT INTO t1 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t2 (t2a int, t2b int, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +# t2b is NULL-able + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL 999 NULL + +DROP TABLE t2; +CREATE TABLE t2 (t2a int, t2b int NOT NULL, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK + +# t2b is NOT NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +DROP TABLE t1,t2; +# +# BUG#12619399 - JCL: NO ROWS VS 3X NULL QUERY OUTPUT WHEN JCL>=5 +# +CREATE TABLE t1 ( +c1 INTEGER NOT NULL, +c2_key INTEGER NOT NULL, +KEY col_int_key (c2_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (24,204); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (10); +CREATE TABLE t3 ( +c1 INTEGER, +KEY k1 (c1) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL), (NULL); +set @old_opt_switch=@@optimizer_switch; + +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=tree SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +EXPLAIN +-> Filter: ((t3.c1,(select #2)) xor true) (cost=0.45 rows=2) + -> Index scan on t3 using k1 (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) (cost=0.70 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (outer_field_is_not_null, ((t3.c1) = t1.c2_key), true) (cost=0.35 rows=1) + -> Alternative plans for IN subquery: Index lookup unless c2_key IS NULL (cost=0.35 rows=1) + -> Index lookup on t1 using col_int_key (c2_key=(t3.c1)) + -> Table scan on t1 + -> Filter: (t2.pk < t1.c1) (cost=0.35 rows=1) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.35 rows=1) + +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where (`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`))) is false) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +1 SIMPLE t3 NULL ref k1 k1 5 test.t1.c2_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` semi join (`test`.`t2` join `test`.`t1`) where ((`test`.`t3`.`c1` = `test`.`t1`.`c2_key`) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)) +SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 + +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +set @@join_buffer_size=default; + +# BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH +# JCL>=5 AND MRR ENABLED" + +CREATE TABLE t1 ( col_int_key int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'j'),(4,'b'),(4,'d'); +CREATE TABLE t2 ( +col_datetime_key datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) ENGINE=innodb; +INSERT INTO t2 VALUES ('2003-08-21 00:00:00','b'); +explain SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key,col_varchar_key col_varchar_key 10 NULL 3 100.00 Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where true group by `field2` order by `field1` +SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +field1 field2 +2003-08-21 00:00:00 4 +NULL 0 +DROP TABLE t1,t2; + +# BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5" + +CREATE TABLE t1 ( +col_int_key int(11) NOT NULL, +col_datetime_key datetime NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,'2004-06-06 04:22:12','v'); +INSERT INTO t1 VALUES (0,'2005-11-13 01:12:31','s'); +INSERT INTO t1 VALUES (9,'2002-05-04 01:50:00','l'); +INSERT INTO t1 VALUES (3,'2004-10-27 10:28:45','y'); +INSERT INTO t1 VALUES (4,'2006-07-22 05:24:23','c'); +INSERT INTO t1 VALUES (2,'2002-05-16 21:34:03','i'); +INSERT INTO t1 VALUES (5,'2008-04-17 10:45:30','h'); +INSERT INTO t1 VALUES (3,'2009-04-21 02:58:02','q'); +INSERT INTO t1 VALUES (1,'2008-01-11 11:01:51','a'); +INSERT INTO t1 VALUES (3,'1900-01-01 00:00:00','v'); +INSERT INTO t1 VALUES (6,'2007-05-17 18:24:57','u'); +INSERT INTO t1 VALUES (7,'2007-08-07 00:00:00','s'); +INSERT INTO t1 VALUES (5,'2001-08-28 00:00:00','y'); +INSERT INTO t1 VALUES (1,'2004-04-16 00:27:28','z'); +INSERT INTO t1 VALUES (204,'2005-05-03 07:06:22','h'); +INSERT INTO t1 VALUES (224,'2009-03-11 17:09:50','p'); +INSERT INTO t1 VALUES (9,'2007-12-08 01:54:28','e'); +INSERT INTO t1 VALUES (5,'2009-07-28 18:19:54','i'); +INSERT INTO t1 VALUES (0,'2008-06-08 00:00:00','y'); +INSERT INTO t1 VALUES (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES +(1,'j'),(2,'v'),(3,'c'),(4,'m'),(5,'d'),(6,'d'),(7,'y'), +(8,'t'),(9,'d'),(10,'s'),(11,'r'),(12,'m'),(13,'b'),(14,'x'), +(15,'g'),(16,'p'),(17,'q'),(18,'w'),(19,'d'),(20,'e'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where true group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key` +SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +field1 COUNT(DISTINCT t1.col_varchar_nokey) field4 +b 0 13 +c 4 3 +d 0 19 +d 1 6 +d 2 9 +d 3 5 +e 0 20 +g 0 15 +j 2 1 +m 0 12 +m 1 4 +p 0 16 +q 0 17 +r 0 11 +s 0 10 +t 0 8 +v 1 2 +w 0 18 +x 0 14 +y 2 7 +DROP TABLE t1,t2; + +# BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5" + +CREATE TABLE t1 (col_varchar_key varchar(1)); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (5,3,9); +INSERT INTO t2 VALUES (6,246,24); +INSERT INTO t2 VALUES (7,2,6); +INSERT INTO t2 VALUES (8,9,1); +INSERT INTO t2 VALUES (9,3,6); +INSERT INTO t2 VALUES (10,8,2); +INSERT INTO t2 VALUES (11,1,4); +INSERT INTO t2 VALUES (12,8,8); +INSERT INTO t2 VALUES (13,8,4); +INSERT INTO t2 VALUES (14,5,4); +INSERT INTO t2 VALUES (15,7,7); +INSERT INTO t2 VALUES (16,5,4); +INSERT INTO t2 VALUES (17,1,1); +INSERT INTO t2 VALUES (18,6,9); +INSERT INTO t2 VALUES (19,2,4); +INSERT INTO t2 VALUES (20,9,8); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze Error Table 'test.t3' doesn't exist +test.t3 analyze status Operation failed +test.t4 analyze Error Table 'test.t4' doesn't exist +test.t4 analyze status Operation failed +explain SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 16 100.00 Using temporary +2 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias2.col_int_nokey 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `field1`,`test`.`alias2`.`col_int_key` AS `field4` from `test`.`t2` `alias2` straight_join `test`.`t2` `alias3` left join `test`.`t1` on((0 <> `test`.`alias3`.`col_int_nokey`)) where (`test`.`alias3`.`pk` = `test`.`alias2`.`col_int_nokey`) group by `field1`,`field4` limit 15 +SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +field1 field4 +NULL 1 +NULL 2 +NULL 4 +NULL 7 +NULL 8 +NULL 9 +DROP TABLE t1,t2; + +# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT +# JCL=6 ONLY [NULL VERSUS NULL+#INTS] + +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k)); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t1 VALUES (6,NULL,6),(0,1,11); +INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL); +INSERT INTO t3 VALUES (2,3,0),(3,4,4); +INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k 5 NULL 2 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.k 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `t2_pk`,`test`.`t4`.`pk` AS `t4_pk`,`test`.`t4`.`k` AS `t4_k`,`test`.`t4`.`i` AS `t4_i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`pk` = `test`.`t1`.`k`)) left join `test`.`t3` on((0 <> `test`.`t3`.`i`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where true +SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +t2_pk t4_pk t4_k t4_i +1 1 9 -1 +NULL NULL NULL NULL +DROP TABLE t1, t2, t3, t4; + +# BUG#12827509 - BNL/BKA: SELECT LEFT/RIGHT JOIN QUERY GIVES +# DIFFERENT OUTPUT ON BNL=OFF+BKA=ON +# (Duplicate of BUG#12722133) + +CREATE TABLE t1 ( +col_int INTEGER +); +INSERT INTO t1 VALUES (3), (7), (2), (8), (6); +CREATE TABLE t2 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1,5), (2,8), (6,3), (8,7), (9,9); +CREATE TABLE t3 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (3,2), (4,3), (8,2); +CREATE TABLE t4 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (2,3), (6,1), (8,2); +ANALYZE TABLE t2, t3, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int` AS `col_int` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col_int` = `test`.`t1`.`col_int`)) left join `test`.`t3` on((`test`.`t3`.`pk` = `test`.`t2`.`pk`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where ((0 <> `test`.`t1`.`col_int`) or (0 <> `test`.`t3`.`col_int`)) +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +col_int +1 +2 +3 +NULL +NULL +DROP TABLE t1, t2, t3, t4; +# +# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) +# POINTS TO UNINITIALISED BYTE(S) +# +CREATE TABLE t1 ( +col1 varchar(10), +col2 varchar(1024) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('a','a'); +CREATE TABLE t2 (i varchar(10)) ENGINE=innodb; +INSERT INTO t2 VALUES ('a'); +SELECT t1.col1 +FROM t1 JOIN t2 ON t1.col1 = t2.i +GROUP BY t1.col2; +col1 +a +DROP TABLE t1,t2; +# End of Bug#12997905 +# +# Bug 13596330 - EXTRA ROW ON SELECT WITH NESTED IN CLAUSE + IS +# NULL WHEN SEMIJOIN + BNL IS ON +# +CREATE TABLE t1 ( +col_int_nokey int +); +INSERT INTO t1 VALUES(-1),(-1); +CREATE TABLE t2 ( +col_int_nokey int, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t2 VALUES (9, '2002-08-25 20:35:06', 'e'), +(9, '2002-08-25 20:35:06', 'e'); +set @optimizer_switch_saved=@@session.optimizer_switch; +set @@session.optimizer_switch='semijoin=off'; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY parent1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY child1 NULL index_subquery col_varchar_key col_varchar_key 7 func 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.parent1.col_datetime_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`parent1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` `parent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`parent1`.`col_int_nokey`)) where (`test`.`parent1`.`col_varchar_key`,(((`test`.`parent1`.`col_varchar_key`) in t2 on col_varchar_key where ((`test`.`parent1`.`col_datetime_nokey` = TIMESTAMP'0000-00-00 00:00:00') and (`test`.`t1`.`col_int_nokey` is null))))) +SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +col_varchar_key +set @@session.optimizer_switch=@optimizer_switch_saved; +DROP TABLE t1,t2; +# +# Bug#29435133 JOIN_CACHE::JOIN_RECORD() MAY LEAVE A TABLE IN HAS_NULL_ROW-STATE +# +CREATE TABLE t1 ( +col_varchar_10_unique varchar(10) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('nthfyejwxd'); +INSERT INTO t1 VALUES ('drrqahbhai'); +CREATE TABLE t3 ( +col_int int(11) NOT NULL, +col_int_unique int(11) not null, +col_varchar_10 varchar(10) not null +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES(9, 4, ''); +CREATE TABLE t4 ( +col_int_unique int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES(3); +CREATE TABLE t2 ( +col_int int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY table4s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY table3s NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY table2s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_varchar_10_unique` AS `col_varchar_10_unique` from `test`.`t1` `table1` where ((`test`.`table1`.`col_varchar_10_unique`,(/* select#2 */ select straight_join `test`.`table3s`.`col_varchar_10` AS `field3` from `test`.`t4` `table4s` left join (`test`.`t3` `table3s` join `test`.`t2` `table2s`) on((`test`.`table3s`.`col_int_unique` = `test`.`table4s`.`col_int_unique`)) where (outer_field_is_not_null, (((`test`.`table1`.`col_varchar_10_unique`) <> `test`.`table3s`.`col_varchar_10`) or (`test`.`table3s`.`col_varchar_10` is null)), true) having (outer_field_is_not_null, (`test`.`table3s`.`col_varchar_10`), true)))) +SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +col_varchar_10_unique +DROP TABLE t1,t2,t3,t4; +# +# t2 and t3 are const tables, which makes for a t1-t4 join on a constant, +# where the constant comes from a multi-equality. Verify that we get the expected +# query plan and don't crash (we don't care about the result). +# +CREATE TABLE t1 ( +pk integer NOT NULL, +a integer, +b integer, +PRIMARY KEY (pk), +KEY idx1 (b) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM +t1 +LEFT JOIN t1 AS t2 ON t1.a = t2.pk +LEFT JOIN t1 AS t3 ON t2.pk = t3.pk +LEFT JOIN t1 AS t4 ON t3.b = t4.b +WHERE t2.pk = 1; +EXPLAIN +-> Parallel scan on + -> Batched key access left join + -> Batch input rows + -> Filter: (t1.a = 1) (cost=0.35 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Multi-range index lookup on t4 using idx1 (b='5') + +DROP TABLE t1; +set optimizer_switch = default; diff --git a/mysql-test/r/join_cache_bnl.result-pq b/mysql-test/r/join_cache_bnl.result-pq new file mode 100644 index 000000000..c0c478961 --- /dev/null +++ b/mysql-test/r/join_cache_bnl.result-pq @@ -0,0 +1,3245 @@ +set optimizer_switch='block_nested_loop=on'; +set optimizer_switch='mrr_cost_based=off'; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +DROP DATABASE IF EXISTS world; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0' +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +SELECT COUNT(*) FROM country; +COUNT(*) +239 +SELECT COUNT(*) FROM city; +COUNT(*) +4079 +SELECT COUNT(*) FROM countrylanguage; +COUNT(*) +984 +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where; Using join buffer (hash join) +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=2048; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 2048 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where; Using join buffer (hash join) +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +DROP DATABASE world; +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +EXPLAIN +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL eq_ref PRIMARY PRIMARY 132 world.country.Code,const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`country`.`Name` AS `Name`,if((`world`.`countrylanguage`.`Country` is null),NULL,`world`.`countrylanguage`.`Percentage`) AS `IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage)` from `world`.`country` left join `world`.`countrylanguage` on(((`world`.`countrylanguage`.`Language` = 'English') and (`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`))) where (`world`.`country`.`Population` > 10000000) +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +Name IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +Afghanistan NULL +Algeria NULL +Angola NULL +Argentina NULL +Australia 81.19999694824219 +Bangladesh NULL +Belarus NULL +Belgium NULL +Brazil NULL +Burkina Faso NULL +Cambodia NULL +Cameroon NULL +Canada 60.400001525878906 +Chile NULL +China NULL +Colombia NULL +Congo, The Democratic Republic of the NULL +Cuba NULL +Czech Republic NULL +Côte d’Ivoire NULL +Ecuador NULL +Egypt NULL +Ethiopia NULL +France NULL +Germany NULL +Ghana NULL +Greece NULL +Guatemala NULL +Hungary NULL +India NULL +Indonesia NULL +Iran NULL +Iraq NULL +Italy NULL +Japan 0.10000000149011612 +Kazakstan NULL +Kenya NULL +Madagascar NULL +Malawi NULL +Malaysia 1.600000023841858 +Mali NULL +Mexico NULL +Morocco NULL +Mozambique NULL +Myanmar NULL +Nepal NULL +Netherlands NULL +Niger NULL +Nigeria NULL +North Korea NULL +Pakistan NULL +Peru NULL +Philippines NULL +Poland NULL +Romania NULL +Russian Federation NULL +Saudi Arabia NULL +Somalia NULL +South Africa 8.5 +South Korea NULL +Spain NULL +Sri Lanka NULL +Sudan NULL +Syria NULL +Taiwan NULL +Tanzania NULL +Thailand NULL +Turkey NULL +Uganda NULL +Ukraine NULL +United Kingdom 97.30000305175781 +United States 86.19999694824219 +Uzbekistan NULL +Venezuela NULL +Vietnam NULL +Yemen NULL +Yugoslavia NULL +Zimbabwe 2.200000047683716 +set join_buffer_size=256; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 256 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=256; +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE city NULL range Population,Country Population 4 NULL # 100.00 Using index condition; Using MRR +2 SIMPLE country NULL eq_ref PRIMARY PRIMARY 12 world.city.Country # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`country`.`Code` = `world`.`city`.`Country`) and (`world`.`city`.`Population` > 3000000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=default; +ALTER TABLE country MODIFY Name varchar(52) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country MODIFY Name varchar(250) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country ADD COLUMN PopulationBar text; +UPDATE country +SET PopulationBar=REPEAT('x', CAST(Population/100000 AS unsigned int)); +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=256; +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=default; +DROP DATABASE world; +use test; +CREATE TABLE t1( +affiliatetometaid int NOT NULL default '0', +uniquekey int NOT NULL default '0', +metaid int NOT NULL default '0', +affiliateid int NOT NULL default '0', +xml text, +isactive char(1) NOT NULL default 'Y', +PRIMARY KEY (affiliatetometaid) +); +CREATE UNIQUE INDEX t1_uniquekey ON t1(uniquekey); +CREATE INDEX t1_affiliateid ON t1(affiliateid); +CREATE INDEX t1_metaid on t1 (metaid); +INSERT INTO t1 VALUES +(1616, 1571693233, 1391, 2, NULL, 'Y'), (1943, 1993216749, 1726, 2, NULL, 'Y'); +CREATE TABLE t2( +metaid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +dateadded timestamp NOT NULL , +xml text, +status int default NULL, +origin int default NULL, +gid int NOT NULL default '1', +formattypeid int default NULL, +PRIMARY KEY (metaid) +); +CREATE INDEX t2_status ON t2(status); +CREATE INDEX t2_gid ON t2(gid); +CREATE INDEX t2_formattypeid ON t2(formattypeid); +INSERT INTO t2 VALUES +(1391, "I Just Died", "2003-10-02 10:07:37", "", 1, NULL, 3, NULL), +(1726, "Me, Myself & I", "2003-12-05 11:24:36", " ", 1, NULL, 3, NULL); +CREATE TABLE t3( +mediaid int NOT NULL , +metaid int NOT NULL default '0', +formatid int NOT NULL default '0', +status int default NULL, +path varchar(100) NOT NULL default '', +datemodified timestamp NOT NULL , +resourcetype int NOT NULL default '1', +parameters text, +signature int default NULL, +quality int NOT NULL default '255', +PRIMARY KEY (mediaid) +); +CREATE INDEX t3_metaid ON t3(metaid); +CREATE INDEX t3_formatid ON t3(formatid); +CREATE INDEX t3_status ON t3(status); +CREATE INDEX t3_metaidformatid ON t3(metaid,formatid); +CREATE INDEX t3_signature ON t3(signature); +CREATE INDEX t3_quality ON t3(quality); +INSERT INTO t3 VALUES +(6, 4, 8, 0, "010101_anastacia_spmidi.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255), +(3343, 3, 8, 1, "010102_4VN4bsPwnxRQUJW5Zp1RhG2IL9vvl_8.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255); +CREATE TABLE t4( +formatid int NOT NULL , +name varchar(60) NOT NULL default '', +formatclassid int NOT NULL default '0', +mime varchar(60) default NULL, +extension varchar(10) default NULL, +priority int NOT NULL default '0', +canaddtocapability char(1) NOT NULL default 'Y', +PRIMARY KEY (formatid) +); +CREATE INDEX t4_formatclassid ON t4(formatclassid); +CREATE INDEX t4_formats_idx ON t4(canaddtocapability); +INSERT INTO t4 VALUES +(19, "XHTML", 11, "text/html", "xhtml", 10, 'Y'), +(54, "AMR (wide band)", 13, "audio/amr-wb", "awb", 0, 'Y'); +CREATE TABLE t5( +formatclassid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int NOT NULL default '0', +formattypeid int NOT NULL default '0', +PRIMARY KEY (formatclassid) +); +CREATE INDEX t5_formattypeid on t5(formattypeid); +INSERT INTO t5 VALUES +(11, "Info", 0, 4), (13, "Digital Audio", 0, 2); +CREATE TABLE t6( +formattypeid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int default NULL, +PRIMARY KEY (formattypeid) +); +INSERT INTO t6 VALUES +(2, "Ringtones", 0); +CREATE TABLE t7( +metaid int NOT NULL default '0', +artistid int NOT NULL default '0', +PRIMARY KEY (metaid,artistid) +); +INSERT INTO t7 VALUES +(4, 5), (3, 4); +CREATE TABLE t8( +artistid int NOT NULL , +name varchar(80) NOT NULL default '', +PRIMARY KEY (artistid) +); +INSERT INTO t8 VALUES +(5, "Anastacia"), (4, "John Mayer"); +CREATE TABLE t9( +subgenreid int NOT NULL default '0', +metaid int NOT NULL default '0', +PRIMARY KEY (subgenreid,metaid) +) ; +CREATE INDEX t9_subgenreid ON t9(subgenreid); +CREATE INDEX t9_metaid ON t9(metaid); +INSERT INTO t9 VALUES +(138, 4), (31, 3); +CREATE TABLE t10( +subgenreid int NOT NULL , +genreid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +PRIMARY KEY (subgenreid) +) ; +CREATE INDEX t10_genreid ON t10(genreid); +INSERT INTO t10 VALUES +(138, 19, ''), (31, 3, ''); +CREATE TABLE t11( +genreid int NOT NULL default '0', +name char(80) NOT NULL default '', +priority int NOT NULL default '0', +masterclip char(1) default NULL, +PRIMARY KEY (genreid) +) ; +CREATE INDEX t11_masterclip ON t11( masterclip); +INSERT INTO t11 VALUES +(19, "Pop & Dance", 95, 'Y'), (3, "Rock & Alternative", 100, 'Y'); +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +EXPLAIN +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t1_affiliateid,t1_metaid t1_metaid 4 test.t7.metaid 1 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 100.00 NULL +1 SIMPLE t11 NULL eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t7.metaid 1 100.00 NULL +1 SIMPLE t3 NULL ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaid 4 test.t7.metaid 1 100.00 Using where +1 SIMPLE t4 NULL ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formatclassid 4 test.t5.formatclassid 1 100.00 Using index condition; Using where +1 SIMPLE t5 NULL ref PRIMARY,t5_formattypeid t5_formattypeid 4 const 1 100.00 NULL +1 SIMPLE t6 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t7 NULL index PRIMARY PRIMARY 8 NULL 2 50.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE t8 NULL ALL PRIMARY NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t9 NULL ref PRIMARY,t9_subgenreid,t9_metaid t9_metaid 4 test.t7.metaid 1 100.00 Using index +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +uniquekey affiliateXml artistName artistid genreName genreid genrePriority subgenreid subgenreName metaName metaid metaXml overallPriority path mediaid formatid formatName formatclassid formatclassName formattypeid formattypeName +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +CREATE TABLE t1 (a1 int, filler1 char(64) default ' ' ); +CREATE TABLE t2 ( +a2 int, b2 int, filler2 char(64) default ' ', +PRIMARY KEY idx(a2,b2,filler2) +) ; +CREATE TABLE t3 (b3 int, c3 int, INDEX idx(b3)); +INSERT INTO t1(a1) VALUES +(4), (7), (1), (9), (8), (5), (3), (6), (2); +INSERT INTO t2(a2,b2) VALUES +(1,30), (3,40), (2,61), (6,73), (8,92), (9,27), (4,18), (5,84), (7,56), +(4,14), (6,76), (8,98), (7,55), (1,39), (2,68), (3,45), (9,21), (5,81), +(5,88), (2,65), (6,74), (9,23), (1,37), (3,44), (4,17), (8,99), (7,51), +(9,28), (7,52), (1,33), (4,13), (5,87), (3,43), (8,91), (2,62), (6,79), +(3,49), (8,93), (7,34), (5,82), (6,78), (2,63), (1,32), (9,22), (4,11); +INSERT INTO t3 VALUES +(30,302), (92,923), (18,187), (45,459), (30,309), +(39,393), (68,685), (45,458), (21,210), (81,817), +(40,405), (61,618), (73,738), (92,929), (27,275), +(18,188), (84,846), (56,564), (14,144), (76,763), +(98,982), (55,551), (17,174), (99,998), (51,513), +(28,282), (52,527), (33,336), (13,138), (87,878), +(43,431), (91,916), (62,624), (79,797), (49,494), +(93,933), (34,347), (82,829), (78,780), (63,634), +(32,329), (22,228), (11,114), (74,749), (23,236); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +set join_buffer_size=512; +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, b int, INDEX idx(b)); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); +INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); +INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); +set join_buffer_size=32; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '32' +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 5 NULL 3 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` >= 30)) +SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +a b a b +7 40 7 10 +7 40 7 10 +7 40 7 20 +8 30 8 10 +8 30 8 20 +DROP TABLE t1,t2; + +BUG#40136: Group by is ignored when join buffer is used for an outer join + +create table t1(a int PRIMARY KEY, b int); +insert into t1 values +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +create table t2 (p int, a int, INDEX i_a(a)); +insert into t2 values +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index +2 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where true group by `test`.`t1`.`a` +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a order by t1.a; +a count +1 1 +2 0 +3 2 +5 0 +6 0 +7 2 +8 0 +9 0 +drop table t1, t2; +# +# Bug #40134: outer join with not exists optimization and join buffer +# +set join_buffer_size=default; +CREATE TABLE t1 (a int NOT NULL); +INSERT INTO t1 VALUES (2), (4), (3), (5), (1); +CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); +INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL i_a NULL NULL NULL 5 20.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`b` is null) +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +a a b +3 NULL NULL +5 NULL NULL +1 NULL NULL +DROP TABLE t1, t2; +# +# BUG#40268: Nested outer join with not null-rejecting where condition +# over an inner table which is not the last in the nest +# +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 LEFT JOIN (t3, t4) ON t2.b=t4.b +WHERE t3.a+2 NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`c` = 102) or (`test`.`t2`.`c` is null)) +select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; +a b a c +2 20 NULL NULL +3 30 3 102 +drop table t1, t2; +# +# Bug #40317: outer join with with constant on expression equal to FALSE +# +create table t1 (a int); +insert into t1 values (30), (40), (20); +create table t2 (b int); +insert into t2 values (200), (100); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select * from t1 left join t2 on (1=0); +a b +30 NULL +40 NULL +20 NULL +explain select * from t1 left join t2 on (1=0) where a=40; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(false) where (`test`.`t1`.`a` = 40) +select * from t1 left join t2 on (1=0) where a=40; +a b +40 NULL +drop table t1, t2; +# +# Bug #41204: small buffer with big rec_per_key for ref access +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0); +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1 VALUES (20000), (10000); +CREATE TABLE t2 (pk int AUTO_INCREMENT PRIMARY KEY, b int, c int, INDEX idx(b)); +INSERT INTO t2(b,c) VALUES (10000, 3), (20000, 7), (20000, 1), (10000, 9), (20000, 5); +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +ANALYZE TABLE t1,t2; +set join_buffer_size=1024; +EXPLAIN SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2050 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2050 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 640 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t2`.`c`) AS `AVG(c)` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +AVG(c) +5.0000 +set join_buffer_size=default; +DROP TABLE t1, t2; +# +# Bug #41894: big join buffer of level 7 used to join records +# with null values in place of varchar strings +# +CREATE TABLE t1 (a int NOT NULL AUTO_INCREMENT PRIMARY KEY, +b varchar(127) DEFAULT NULL); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +CREATE TABLE t2 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t2 SELECT * FROM t1; +CREATE TABLE t3 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t3 SELECT * FROM t1; +set join_buffer_size=1024*1024; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 16400 10.00 Parallel execute (4 workers) +2 SIMPLE # NULL ALL PRIMARY NULL NULL # 16400 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +COUNT(*) +16384 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +# +# Bug #42020: join buffer is used for outer join with fields of +# several outer tables in join buffer +# +CREATE TABLE t1 ( +a bigint NOT NULL, +PRIMARY KEY (a) +); +INSERT INTO t1 VALUES +(2), (1); +CREATE TABLE t2 ( +a bigint NOT NULL, +b bigint NOT NULL, +PRIMARY KEY (a,b) +); +INSERT INTO t2 VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(1,10), (1, 20), (1,30), (1,40), (1,50); +CREATE TABLE t3 ( +pk bigint NOT NULL AUTO_INCREMENT, +a bigint NOT NULL, +b bigint NOT NULL, +val bigint DEFAULT '0', +PRIMARY KEY (pk), +KEY idx (a,b) +); +INSERT INTO t3(a,b) VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(4,30), (4,40), (4,50), (4,60), (4,70), (4,80), +(5,30), (5,40), (5,50), (5,60), (5,70), (5,80), +(7,30), (7,40), (7,50), (7,60), (7,70), (7,80); +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=256; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 16 test.t1.a,test.t2.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +DROP INDEX idx ON t3; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 24 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +create table t1(f1 int, f2 int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2(f1 int not null, f2 int not null, f3 char(200), key(f1,f2)); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +explain select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t2`.`f2`)) +drop table t1,t2; +# +# Bug #42955: join with GROUP BY/ORDER BY and when BKA is enabled +# +create table t1 (d int, id1 int, index idx1 (d, id1)); +insert into t1 values +(3, 20), (2, 40), (3, 10), (1, 10), (3, 20), (1, 40), (2, 30), (3, 30); +create table t2 (id1 int, id2 int, index idx2 (id1)); +insert into t2 values +(20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), +(40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,sum(`test`.`t2`.`id2`) AS `sum(t2.id2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3)) group by `test`.`t1`.`id1` +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id1 sum(t2.id2) +10 900 +20 2000 +30 900 +explain +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL idx2 NULL NULL NULL 12 8.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3) and (`test`.`t2`.`id2` > 200)) order by `test`.`t1`.`id1` +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id1 +10 +10 +20 +20 +20 +20 +30 +30 +drop table t1,t2; +# +# Bug #44019: star-like multi-join query executed optimizer_join_cache_level=6 +# +create table t1 (a int, b int, c int, d int); +create table t2 (b int, e varchar(16), index idx(b)); +create table t3 (d int, f varchar(16), index idx(d)); +create table t4 (c int, g varchar(16), index idx(c)); +insert into t1 values +(5, 50, 500, 5000), (3, 30, 300, 3000), (9, 90, 900, 9000), +(2, 20, 200, 2000), (4, 40, 400, 4000), (8, 80, 800, 800), +(7, 70, 700, 7000); +insert into t2 values +(30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), +(31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), +(32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t3 values +(4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), +(4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), +(4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t4 values +(200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), +(201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), +(202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +analyze table t2,t3,t4; +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.b 1 100.00 NULL +2 SIMPLE t3 NULL ref idx idx 5 test.t1.d 1 100.00 NULL +2 SIMPLE t4 NULL ref idx idx 5 test.t1.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t2`.`e` AS `e`,`test`.`t3`.`f` AS `f`,`test`.`t4`.`g` AS `g` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c` = `test`.`t1`.`c`) and (`test`.`t3`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +a b c d e f g +3 30 300 3000 bbb ddd ccc +drop table t1,t2,t3,t4; +# +# Bug #44250: Corruption of linked join buffers when using BKA +# +CREATE TABLE t1 ( +id1 bigint(20) DEFAULT NULL, +id2 bigint(20) DEFAULT NULL, +id3 bigint(20) DEFAULT NULL, +num1 bigint(20) DEFAULT NULL, +num2 int(11) DEFAULT NULL, +num3 bigint(20) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id3 bigint(20) NOT NULL DEFAULT '0', +id4 bigint(20) DEFAULT NULL, +enum1 enum('Enabled','Disabled','Paused') DEFAULT NULL, +PRIMARY KEY (id3) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +id4 bigint(20) NOT NULL DEFAULT '0', +text1 text, +PRIMARY KEY (id4) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +id2 bigint(20) NOT NULL DEFAULT '0', +dummy int(11) DEFAULT '0', +PRIMARY KEY (id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +id1 bigint(20) NOT NULL DEFAULT '0', +id2 bigint(20) NOT NULL DEFAULT '0', +enum2 enum('Active','Deleted','Paused') DEFAULT NULL, +PRIMARY KEY (id1,id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set join_buffer_size=2048; +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id3 # 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.id4 # 33.33 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id2 # 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 16 test.t1.id1,test.t1.id2 # 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`num3` AS `num3`,`test`.`t3`.`text1` AS `text1`,`test`.`t3`.`id4` AS `id4`,`test`.`t2`.`id3` AS `id3`,`test`.`t4`.`dummy` AS `dummy` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` join `test`.`t5` where ((`test`.`t2`.`id3` = `test`.`t1`.`id3`) and (`test`.`t3`.`id4` = `test`.`t2`.`id4`) and (`test`.`t5`.`enum2` = 'Active') and (`test`.`t4`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`text1` < 'D')) +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id1 num3 text1 id4 id3 dummy +228172702 134 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 14 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 15 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 3 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 10 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 14 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 17 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 18 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 19 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 26 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 28 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 50 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 6 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 60 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 61 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 62 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 84 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 89 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 9 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3,t4,t5; +# +# Bug #46328: Use of aggregate function without GROUP BY clause +# returns many rows (vs. one ) +# +CREATE TABLE t1 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(0),(2),(2),(2),(3),(4),(5),(5),(6),(6),(8),(8),(9),(9); +CREATE TABLE t2 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2),(3); + +# The query shall return 1 record with a max value 9 and one of the +# int_key values inserted above (undefined which one, so it's replaced +# with "#"). +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +MAX(t1.int_key) int_key +9 # + +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 14 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL int_key 4 NULL 14 100.00 Using index +2 SIMPLE t2 NULL index NULL int_key 4 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`int_key`) AS `MAX(t1.int_key)`,`test`.`t1`.`int_key` AS `int_key` from `test`.`t1` straight_join `test`.`t2` + +DROP TABLE t1,t2; +# +# Bug #45019: join buffer contains two blob columns one of which is +# used in the key employed to access the joined table +# +CREATE TABLE t1 (c1 int, c2 int, key (c2)); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,2); +CREATE TABLE t2 (c1 text, c2 text); +INSERT INTO t2 VALUES('tt', 'uu'); +INSERT INTO t2 VALUES('zzzz', 'xxxxxxxxx'); +ANALYZE TABLE t1,t2; +SELECT t1.*, t2.*, LENGTH(t2.c1), LENGTH(t2.c2) FROM t1,t2 +WHERE t1.c2=LENGTH(t2.c2) and t1.c1=LENGTH(t2.c1); +c1 c2 c1 c2 LENGTH(t2.c1) LENGTH(t2.c2) +2 2 tt uu 2 2 +DROP TABLE t1,t2; +# +# Regression test for +# Bug#46733 - NULL value not returned for aggregate on empty result +# set w/ semijoin on +CREATE TABLE t1 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,'a'),(11,'b'),(12,'c'),(13,'d'); +CREATE TABLE t2 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'x'),(2,'y'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +MAX(t1.i) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'y' + +EXPLAIN +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`i`) AS `MAX(t1.i)` from `test`.`t1` join `test`.`t2` where (0 <> `test`.`t2`.`v`) + +DROP TABLE t1,t2; +# +# Bug#51092: Linked join buffer gives wrong result +# for 3-way cross join +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,1),(2,2); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t3 VALUES (1,1),(2,2); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +SELECT t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +DROP TABLE t1,t2,t3; +# +# BUG#52394 Segfault in JOIN_CACHE::get_offset () at sql_select.h:445 +# +CREATE TABLE C(a int); +INSERT INTO C VALUES(1),(2),(3),(4),(5); +CREATE TABLE D (a int(11), b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO D VALUES (6,'r'),(27,'o'); +CREATE TABLE E (a int(11) primary key, b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO E VALUES +(14,'d'),(15,'z'),(16,'e'),(17,'h'),(18,'b'),(19,'s'),(20,'e'),(21,'j'),(22,'e'),(23,'f'),(24,'v'),(25,'x'),(26,'m'),(27,'c'); +SELECT 1 FROM C,D,E WHERE D.a = E.a AND D.b = E.b; +1 +DROP TABLE C,D,E; +# +# BUG#52540 Crash in JOIN_CACHE::set_match_flag_if_none () at sql_join_cache.cc:1883 +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (a varchar(10)); +INSERT INTO t2 VALUES ('f'),('x'); +CREATE TABLE t3 (pk int(11) PRIMARY KEY); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (2); +CREATE TABLE t4 (a varchar(10)); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` left join (`test`.`t1` join `test`.`t3` left join `test`.`t4` on(true)) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`))) where true +SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +1 +1 +1 +DROP TABLE t1,t2,t3,t4; +# +# Bug#51084: Batched key access crashes for SELECT with +# derived table and LEFT JOIN +# +CREATE TABLE t1 ( +carrier int, +id int PRIMARY KEY +); +INSERT INTO t1 VALUES (1,11),(1,12),(2,13); +CREATE TABLE t2 ( +scan_date int, +package_id int +); +INSERT INTO t2 VALUES (2008,21),(2008,22); +CREATE TABLE t3 ( +carrier int PRIMARY KEY, +id int +); +INSERT INTO t3 VALUES (1,31); +CREATE TABLE t4 ( +carrier_id int, +INDEX carrier_id(carrier_id) +); +INSERT INTO t4 VALUES (31),(32); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK + +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +COUNT(*) +6 + +EXPLAIN +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref carrier_id carrier_id 5 test.t3.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`carrier_id` = `test`.`t3`.`id`) and (`test`.`t3`.`carrier` = `test`.`t1`.`carrier`))) where true + +DROP TABLE t1,t2,t3,t4; +# +# Bug#45267: Incomplete check caused wrong result. +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15), +(16),(17),(18),(19),(20); +CREATE TABLE t2 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10,9,'22:36:46'),(11,0,'08:46:46'); +SELECT DISTINCT t1.`pk` +FROM t1 RIGHT JOIN t2 STRAIGHT_JOIN t3 ON t2.`int_nokey` ON t2.`time_key` +GROUP BY 1; +pk +NULL +DROP TABLE IF EXISTS t1, t2, t3; +# +# BUG#52636 6.0 allowing JOINs on NULL values w/ optimizer_join_cache_level = 5-8 +# +CREATE TABLE t1 (b int); +INSERT INTO t1 VALUES (NULL),(3); +CREATE TABLE t2 (a int, b int, KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,200); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +delete from t1; +INSERT INTO t1 VALUES (NULL),(NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (b varchar(100)); +INSERT INTO t1 VALUES (NULL),("some varchar"); +CREATE TABLE t2 (a int, b varchar(100), KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 403 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +# +# BUG#54359 "Extra rows with join_cache_level=7,8 and two joins +# --and multi-column index" +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)) +; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,9,'k','k'); +INSERT INTO t1 VALUES (12,5,'k','k'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE table3 NULL ALL col_varchar_key NULL NULL NULL 2 50.00 Using where +2 SIMPLE table2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`col_int_key` AS `col_int_key` from `test`.`t1` `table2` join `test`.`t1` `table3` FORCE INDEX (`col_varchar_key`) where ((`test`.`table2`.`col_varchar_nokey` = `test`.`table3`.`col_varchar_key`) and (0 <> `test`.`table3`.`pk`) and (`test`.`table3`.`col_int_key` >= `test`.`table2`.`pk`)) +SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +col_int_key +9 +9 +drop table t1; +# +# BUG#54481 "GROUP BY loses effect with JOIN + ORDER BY + LIMIT +# and join_cache_level=5-8" +# +CREATE TABLE t1 ( +`col_int_key` int, +`col_datetime` datetime, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t1 VALUES (2,'2003-02-11 21:19:41'); +INSERT INTO t1 VALUES (3,'2009-10-18 02:27:49'); +INSERT INTO t1 VALUES (0,'2000-09-26 07:45:57'); +INSERT INTO t1 VALUES (4,'2000-09-26 07:45:57'); +CREATE TABLE t2 ( +`col_int` int, +`col_int_key` int, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t2 VALUES (14,1); +INSERT INTO t2 VALUES (98,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` FORCE INDEX (`col_int_key`) join `test`.`t2` IGNORE INDEX (`col_int_key`) where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +drop table t1,t2; + +# Bug#11766522 "59651: ASSERTION `TABLE_REF->HAS_RECORD' FAILED +# WITH JOIN_CACHE_LEVEL=3" + +CREATE TABLE t1 ( +b varchar(20) +) ; +INSERT INTO t1 VALUES ('1'),('1'); +CREATE TABLE t4 ( +col253 text +) ; +INSERT INTO t4 VALUES (''),('pf'); +CREATE TABLE t6 ( +col282 timestamp +) ; +INSERT INTO t6 VALUES ('2010-11-07 01:04:45'),('2010-12-13 01:36:32'); +CREATE TABLE t7 ( +col319 timestamp NOT NULL, +UNIQUE KEY idx263 (col319) +) ; +insert into t7 values("2000-01-01"),("2000-01-02"); +CREATE TABLE t3 ( +col582 char(230) CHARACTER SET utf8 DEFAULT NULL +) ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES ('cymej'),('spb'); +CREATE TABLE t5 ( +col712 time +) ; +insert into t5 values(0),(0); +CREATE TABLE t8 ( +col804 char(169), +col805 varchar(51) +) ; +INSERT INTO t8 VALUES ('tmqcb','pwk'); +CREATE TABLE t2 ( +col841 varchar(10) +) ; +INSERT INTO t2 VALUES (''),(''); +set join_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '1' +select @@join_buffer_size; +@@join_buffer_size +128 +select count(*) from +(t1 join t2 join t3) +left join t4 on 1 +left join t5 on 1 like t4.col253 +left join t6 on t5.col712 is null +left join t7 on t1.b <=>t7.col319 +left join t8 on t3.col582 <= 1; +count(*) +32 +drop table t1,t2,t3,t4,t5,t6,t7,t8; +# +# Bug#12616131 - JCL: NULL VS DATE + TWICE AS MANY ROWS +# RETURNED WHEN JCL>=7 +# +CREATE TABLE t1 (t1a int, t1b int); +INSERT INTO t1 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t2 (t2a int, t2b int, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +# t2b is NULL-able + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL 999 NULL + +DROP TABLE t2; +CREATE TABLE t2 (t2a int, t2b int NOT NULL, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK + +# t2b is NOT NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +DROP TABLE t1,t2; +# +# BUG#12619399 - JCL: NO ROWS VS 3X NULL QUERY OUTPUT WHEN JCL>=5 +# +CREATE TABLE t1 ( +c1 INTEGER NOT NULL, +c2_key INTEGER NOT NULL, +KEY col_int_key (c2_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (24,204); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (10); +CREATE TABLE t3 ( +c1 INTEGER, +KEY k1 (c1) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL), (NULL); +set @old_opt_switch=@@optimizer_switch; + +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=tree SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +EXPLAIN +-> Filter: ((t3.c1,(select #2)) xor true) (cost=0.45 rows=2) + -> Index scan on t3 using k1 (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) (cost=0.72 rows=1) + -> Nested loop inner join (cost=0.72 rows=1) + -> Filter: (outer_field_is_not_null, ((t3.c1) = t1.c2_key), true) (cost=0.35 rows=1) + -> Alternative plans for IN subquery: Index lookup unless c2_key IS NULL (cost=0.35 rows=1) + -> Index lookup on t1 using col_int_key (c2_key=(t3.c1)) + -> Table scan on t1 + -> Filter: (t2.pk < t1.c1) (cost=0.37 rows=1) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.37 rows=1) + +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where (`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`))) is false) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +1 SIMPLE t3 NULL ref k1 k1 5 test.t1.c2_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` semi join (`test`.`t2` join `test`.`t1`) where ((`test`.`t3`.`c1` = `test`.`t1`.`c2_key`) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)) +SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 + +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +set @@join_buffer_size=default; + +# BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH +# JCL>=5 AND MRR ENABLED" + +CREATE TABLE t1 ( col_int_key int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'j'),(4,'b'),(4,'d'); +CREATE TABLE t2 ( +col_datetime_key datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) ENGINE=innodb; +INSERT INTO t2 VALUES ('2003-08-21 00:00:00','b'); +explain SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key,col_varchar_key col_int_key 4 NULL 3 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where true group by `field2` order by `field1` +SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +field1 field2 +2003-08-21 00:00:00 4 +NULL 0 +DROP TABLE t1,t2; + +# BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5" + +CREATE TABLE t1 ( +col_int_key int(11) NOT NULL, +col_datetime_key datetime NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,'2004-06-06 04:22:12','v'); +INSERT INTO t1 VALUES (0,'2005-11-13 01:12:31','s'); +INSERT INTO t1 VALUES (9,'2002-05-04 01:50:00','l'); +INSERT INTO t1 VALUES (3,'2004-10-27 10:28:45','y'); +INSERT INTO t1 VALUES (4,'2006-07-22 05:24:23','c'); +INSERT INTO t1 VALUES (2,'2002-05-16 21:34:03','i'); +INSERT INTO t1 VALUES (5,'2008-04-17 10:45:30','h'); +INSERT INTO t1 VALUES (3,'2009-04-21 02:58:02','q'); +INSERT INTO t1 VALUES (1,'2008-01-11 11:01:51','a'); +INSERT INTO t1 VALUES (3,'1900-01-01 00:00:00','v'); +INSERT INTO t1 VALUES (6,'2007-05-17 18:24:57','u'); +INSERT INTO t1 VALUES (7,'2007-08-07 00:00:00','s'); +INSERT INTO t1 VALUES (5,'2001-08-28 00:00:00','y'); +INSERT INTO t1 VALUES (1,'2004-04-16 00:27:28','z'); +INSERT INTO t1 VALUES (204,'2005-05-03 07:06:22','h'); +INSERT INTO t1 VALUES (224,'2009-03-11 17:09:50','p'); +INSERT INTO t1 VALUES (9,'2007-12-08 01:54:28','e'); +INSERT INTO t1 VALUES (5,'2009-07-28 18:19:54','i'); +INSERT INTO t1 VALUES (0,'2008-06-08 00:00:00','y'); +INSERT INTO t1 VALUES (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES +(1,'j'),(2,'v'),(3,'c'),(4,'m'),(5,'d'),(6,'d'),(7,'y'), +(8,'t'),(9,'d'),(10,'s'),(11,'r'),(12,'m'),(13,'b'),(14,'x'), +(15,'g'),(16,'p'),(17,'q'),(18,'w'),(19,'d'),(20,'e'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where true group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key` +SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +field1 COUNT(DISTINCT t1.col_varchar_nokey) field4 +b 0 13 +c 4 3 +d 0 19 +d 1 6 +d 2 9 +d 3 5 +e 0 20 +g 0 15 +j 2 1 +m 0 12 +m 1 4 +p 0 16 +q 0 17 +r 0 11 +s 0 10 +t 0 8 +v 1 2 +w 0 18 +x 0 14 +y 2 7 +DROP TABLE t1,t2; + +# BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5" + +CREATE TABLE t1 (col_varchar_key varchar(1)); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (5,3,9); +INSERT INTO t2 VALUES (6,246,24); +INSERT INTO t2 VALUES (7,2,6); +INSERT INTO t2 VALUES (8,9,1); +INSERT INTO t2 VALUES (9,3,6); +INSERT INTO t2 VALUES (10,8,2); +INSERT INTO t2 VALUES (11,1,4); +INSERT INTO t2 VALUES (12,8,8); +INSERT INTO t2 VALUES (13,8,4); +INSERT INTO t2 VALUES (14,5,4); +INSERT INTO t2 VALUES (15,7,7); +INSERT INTO t2 VALUES (16,5,4); +INSERT INTO t2 VALUES (17,1,1); +INSERT INTO t2 VALUES (18,6,9); +INSERT INTO t2 VALUES (19,2,4); +INSERT INTO t2 VALUES (20,9,8); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze Error Table 'test.t3' doesn't exist +test.t3 analyze status Operation failed +test.t4 analyze Error Table 'test.t4' doesn't exist +test.t4 analyze status Operation failed +explain SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 16 100.00 Using temporary +2 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias2.col_int_nokey 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `field1`,`test`.`alias2`.`col_int_key` AS `field4` from `test`.`t2` `alias2` straight_join `test`.`t2` `alias3` left join `test`.`t1` on((0 <> `test`.`alias3`.`col_int_nokey`)) where (`test`.`alias3`.`pk` = `test`.`alias2`.`col_int_nokey`) group by `field1`,`field4` limit 15 +SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +field1 field4 +NULL 1 +NULL 2 +NULL 4 +NULL 7 +NULL 8 +NULL 9 +DROP TABLE t1,t2; + +# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT +# JCL=6 ONLY [NULL VERSUS NULL+#INTS] + +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k)); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t1 VALUES (6,NULL,6),(0,1,11); +INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL); +INSERT INTO t3 VALUES (2,3,0),(3,4,4); +INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k 5 NULL 2 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.k 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `t2_pk`,`test`.`t4`.`pk` AS `t4_pk`,`test`.`t4`.`k` AS `t4_k`,`test`.`t4`.`i` AS `t4_i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`pk` = `test`.`t1`.`k`)) left join `test`.`t3` on((0 <> `test`.`t3`.`i`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where true +SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +t2_pk t4_pk t4_k t4_i +1 1 9 -1 +NULL NULL NULL NULL +DROP TABLE t1, t2, t3, t4; + +# BUG#12827509 - BNL/BKA: SELECT LEFT/RIGHT JOIN QUERY GIVES +# DIFFERENT OUTPUT ON BNL=OFF+BKA=ON +# (Duplicate of BUG#12722133) + +CREATE TABLE t1 ( +col_int INTEGER +); +INSERT INTO t1 VALUES (3), (7), (2), (8), (6); +CREATE TABLE t2 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1,5), (2,8), (6,3), (8,7), (9,9); +CREATE TABLE t3 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (3,2), (4,3), (8,2); +CREATE TABLE t4 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (2,3), (6,1), (8,2); +ANALYZE TABLE t2, t3, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int` AS `col_int` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col_int` = `test`.`t1`.`col_int`)) left join `test`.`t3` on((`test`.`t3`.`pk` = `test`.`t2`.`pk`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where ((0 <> `test`.`t1`.`col_int`) or (0 <> `test`.`t3`.`col_int`)) +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +col_int +1 +2 +3 +NULL +NULL +DROP TABLE t1, t2, t3, t4; +# +# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) +# POINTS TO UNINITIALISED BYTE(S) +# +CREATE TABLE t1 ( +col1 varchar(10), +col2 varchar(1024) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('a','a'); +CREATE TABLE t2 (i varchar(10)) ENGINE=innodb; +INSERT INTO t2 VALUES ('a'); +SELECT t1.col1 +FROM t1 JOIN t2 ON t1.col1 = t2.i +GROUP BY t1.col2; +col1 +a +DROP TABLE t1,t2; +# End of Bug#12997905 +# +# Bug 13596330 - EXTRA ROW ON SELECT WITH NESTED IN CLAUSE + IS +# NULL WHEN SEMIJOIN + BNL IS ON +# +CREATE TABLE t1 ( +col_int_nokey int +); +INSERT INTO t1 VALUES(-1),(-1); +CREATE TABLE t2 ( +col_int_nokey int, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t2 VALUES (9, '2002-08-25 20:35:06', 'e'), +(9, '2002-08-25 20:35:06', 'e'); +set @optimizer_switch_saved=@@session.optimizer_switch; +set @@session.optimizer_switch='semijoin=off'; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY parent1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY child1 NULL index_subquery col_varchar_key col_varchar_key 7 func 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.parent1.col_datetime_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`parent1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` `parent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`parent1`.`col_int_nokey`)) where (`test`.`parent1`.`col_varchar_key`,(((`test`.`parent1`.`col_varchar_key`) in t2 on col_varchar_key where ((`test`.`parent1`.`col_datetime_nokey` = TIMESTAMP'0000-00-00 00:00:00') and (`test`.`t1`.`col_int_nokey` is null))))) +SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +col_varchar_key +set @@session.optimizer_switch=@optimizer_switch_saved; +DROP TABLE t1,t2; +# +# Bug#29435133 JOIN_CACHE::JOIN_RECORD() MAY LEAVE A TABLE IN HAS_NULL_ROW-STATE +# +CREATE TABLE t1 ( +col_varchar_10_unique varchar(10) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('nthfyejwxd'); +INSERT INTO t1 VALUES ('drrqahbhai'); +CREATE TABLE t3 ( +col_int int(11) NOT NULL, +col_int_unique int(11) not null, +col_varchar_10 varchar(10) not null +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES(9, 4, ''); +CREATE TABLE t4 ( +col_int_unique int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES(3); +CREATE TABLE t2 ( +col_int int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY table4s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY table3s NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY table2s NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_varchar_10_unique` AS `col_varchar_10_unique` from `test`.`t1` `table1` where ((`test`.`table1`.`col_varchar_10_unique`,(/* select#2 */ select straight_join `test`.`table3s`.`col_varchar_10` AS `field3` from `test`.`t4` `table4s` left join (`test`.`t3` `table3s` join `test`.`t2` `table2s`) on((`test`.`table3s`.`col_int_unique` = `test`.`table4s`.`col_int_unique`)) where (outer_field_is_not_null, (((`test`.`table1`.`col_varchar_10_unique`) <> `test`.`table3s`.`col_varchar_10`) or (`test`.`table3s`.`col_varchar_10` is null)), true) having (outer_field_is_not_null, (`test`.`table3s`.`col_varchar_10`), true)))) +SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +col_varchar_10_unique +DROP TABLE t1,t2,t3,t4; +# +# t2 and t3 are const tables, which makes for a t1-t4 join on a constant, +# where the constant comes from a multi-equality. Verify that we get the expected +# query plan and don't crash (we don't care about the result). +# +CREATE TABLE t1 ( +pk integer NOT NULL, +a integer, +b integer, +PRIMARY KEY (pk), +KEY idx1 (b) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM +t1 +LEFT JOIN t1 AS t2 ON t1.a = t2.pk +LEFT JOIN t1 AS t3 ON t2.pk = t3.pk +LEFT JOIN t1 AS t4 ON t3.b = t4.b +WHERE t2.pk = 1; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t1.a = 1) (cost=0.35 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Index lookup on t4 using idx1 (b='5') (cost=0.35 rows=1) + +DROP TABLE t1; +set optimizer_switch = default; diff --git a/mysql-test/r/join_cache_nojb.result-pq b/mysql-test/r/join_cache_nojb.result-pq new file mode 100644 index 000000000..c8351a8c8 --- /dev/null +++ b/mysql-test/r/join_cache_nojb.result-pq @@ -0,0 +1,3245 @@ +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +set optimizer_switch='mrr_cost_based=off'; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +DROP DATABASE IF EXISTS world; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0' +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +SELECT COUNT(*) FROM country; +COUNT(*) +239 +SELECT COUNT(*) FROM city; +COUNT(*) +4079 +SELECT COUNT(*) FROM countrylanguage; +COUNT(*) +984 +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=2048; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 2048 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 11.11 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 11.11 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.Country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ALL NULL NULL NULL NULL 984 3.33 Using where +2 SIMPLE city NULL ALL NULL NULL NULL NULL 4059 1.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.Country=country.Code AND +countrylanguage.Country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +DROP DATABASE world; +CREATE DATABASE world; +use world; +CREATE TABLE country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE city ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE countrylanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +ANALYZE TABLE city, country, countrylanguage; +Table Op Msg_type Msg_text +world.city analyze status OK +world.country analyze status OK +world.countrylanguage analyze status OK +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +EXPLAIN +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL NULL NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL eq_ref PRIMARY PRIMARY 132 world.country.Code,const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`country`.`Name` AS `Name`,if((`world`.`countrylanguage`.`Country` is null),NULL,`world`.`countrylanguage`.`Percentage`) AS `IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage)` from `world`.`country` left join `world`.`countrylanguage` on(((`world`.`countrylanguage`.`Language` = 'English') and (`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`))) where (`world`.`country`.`Population` > 10000000) +SELECT country.Name, IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +FROM country LEFT JOIN countrylanguage ON +(countrylanguage.country=country.Code AND Language='English') +WHERE +country.Population > 10000000; +Name IF(ISNULL(countrylanguage.country), NULL, countrylanguage.Percentage) +Afghanistan NULL +Algeria NULL +Angola NULL +Argentina NULL +Australia 81.19999694824219 +Bangladesh NULL +Belarus NULL +Belgium NULL +Brazil NULL +Burkina Faso NULL +Cambodia NULL +Cameroon NULL +Canada 60.400001525878906 +Chile NULL +China NULL +Colombia NULL +Congo, The Democratic Republic of the NULL +Cuba NULL +Czech Republic NULL +Côte d’Ivoire NULL +Ecuador NULL +Egypt NULL +Ethiopia NULL +France NULL +Germany NULL +Ghana NULL +Greece NULL +Guatemala NULL +Hungary NULL +India NULL +Indonesia NULL +Iran NULL +Iraq NULL +Italy NULL +Japan 0.10000000149011612 +Kazakstan NULL +Kenya NULL +Madagascar NULL +Malawi NULL +Malaysia 1.600000023841858 +Mali NULL +Mexico NULL +Morocco NULL +Mozambique NULL +Myanmar NULL +Nepal NULL +Netherlands NULL +Niger NULL +Nigeria NULL +North Korea NULL +Pakistan NULL +Peru NULL +Philippines NULL +Poland NULL +Romania NULL +Russian Federation NULL +Saudi Arabia NULL +Somalia NULL +South Africa 8.5 +South Korea NULL +Spain NULL +Sri Lanka NULL +Sudan NULL +Syria NULL +Taiwan NULL +Tanzania NULL +Thailand NULL +Turkey NULL +Uganda NULL +Ukraine NULL +United Kingdom 97.30000305175781 +United States 86.19999694824219 +Uzbekistan NULL +Venezuela NULL +Vietnam NULL +Yemen NULL +Yugoslavia NULL +Zimbabwe 2.200000047683716 +set join_buffer_size=256; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 256 +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`country`.`Name` like 'L%') and (`world`.`city`.`Population` > 100000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +EXPLAIN +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 239 33.33 Parallel execute (2 workers) +2 SIMPLE country NULL ALL PRIMARY NULL NULL NULL 239 33.33 Using where +2 SIMPLE countrylanguage NULL ref PRIMARY,Percentage PRIMARY 12 world.country.Code 4 17.07 Using where +2 SIMPLE city NULL ref Country Country 12 world.country.Code 17 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name`,`world`.`countrylanguage`.`Language` AS `Language` from `world`.`city` join `world`.`country` join `world`.`countrylanguage` where ((`world`.`countrylanguage`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Name` like 'L%') and (`world`.`country`.`Population` > 3000000) and (`world`.`countrylanguage`.`Percentage` > 50)) +SELECT city.Name, country.Name, countrylanguage.Language +FROM city,country,countrylanguage +WHERE city.country=country.Code AND +countrylanguage.country=country.Code AND +city.Name LIKE 'L%' AND country.Population > 3000000 AND +countrylanguage.Percentage > 50; +Name Name Language +La Ceiba Honduras Spanish +La Habana Cuba Spanish +La Matanza Argentina Spanish +La Paz Bolivia Spanish +La Paz Mexico Spanish +La Paz Mexico Spanish +La Plata Argentina Spanish +La Rioja Argentina Spanish +La Romana Dominican Republic Spanish +La Serena Chile Spanish +La Spezia Italy Italian +Lafayette United States English +Lages Brazil Portuguese +Lagos de Moreno Mexico Spanish +Lahti Finland Finnish +Laiwu China Chinese +Laiyang China Chinese +Laizhou China Chinese +Lakewood United States English +Lalitapur Nepal Nepali +Lambaré Paraguay Spanish +Lancaster United States English +Langfang China Chinese +Lansing United States English +Lanzhou China Chinese +Lanús Argentina Spanish +Laohekou China Chinese +Laredo United States English +Larisa Greece Greek +Las Heras Argentina Spanish +Las Margaritas Mexico Spanish +Las Palmas de Gran Canaria Spain Spanish +Las Vegas United States English +Lashio (Lasho) Myanmar Burmese +Latakia Syria Arabic +Latina Italy Italian +Lauro de Freitas Brazil Portuguese +Lausanne Switzerland German +Laval Canada English +Le Havre France French +Le Mans France French +Le-Cap-Haïtien Haiti Haiti Creole +Lecce Italy Italian +Leeds United Kingdom English +Leganés Spain Spanish +Legnica Poland Polish +Leicester United Kingdom English +Leiden Netherlands Dutch +Leipzig Germany German +Leiyang China Chinese +Lengshuijiang China Chinese +Leninsk-Kuznetski Russian Federation Russian +Lerdo Mexico Spanish +Lerma Mexico Spanish +Leshan China Chinese +Leverkusen Germany German +Lexington-Fayette United States English +León Mexico Spanish +León Nicaragua Spanish +León Spain Spanish +Lhasa China Chinese +Liangcheng China Chinese +Lianyuan China Chinese +Lianyungang China Chinese +Liaocheng China Chinese +Liaoyang China Chinese +Liaoyuan China Chinese +Liberec Czech Republic Czech +Lida Belarus Belorussian +Liling China Chinese +Lille France French +Lilongwe Malawi Chichewa +Lima Peru Spanish +Limeira Brazil Portuguese +Limoges France French +Linchuan China Chinese +Lincoln United States English +Linfen China Chinese +Linhai China Chinese +Linhares Brazil Portuguese +Linhe China Chinese +Linköping Sweden Swedish +Linqing China Chinese +Linyi China Chinese +Linz Austria German +Lipetsk Russian Federation Russian +Lisboa Portugal Portuguese +Little Rock United States English +Liupanshui China Chinese +Liuzhou China Chinese +Liu´an China Chinese +Liverpool United Kingdom English +Livonia United States English +Livorno Italy Italian +Liyang China Chinese +Liège Belgium Dutch +Ljubertsy Russian Federation Russian +Lleida (Lérida) Spain Spanish +Logroño Spain Spanish +Loja Ecuador Spanish +Lomas de Zamora Argentina Spanish +London Canada English +London United Kingdom English +Londrina Brazil Portuguese +Long Beach United States English +Long Xuyen Vietnam Vietnamese +Longjing China Chinese +Longkou China Chinese +Longueuil Canada English +Longyan China Chinese +Los Angeles Chile Spanish +Los Angeles United States English +Los Cabos Mexico Spanish +Los Teques Venezuela Spanish +Loudi China Chinese +Louisville United States English +Lowell United States English +Lower Hutt New Zealand English +Lubbock United States English +Lublin Poland Polish +Luchou Taiwan Min +Ludwigshafen am Rhein Germany German +Lugansk Ukraine Ukrainian +Lund Sweden Swedish +Lungtan Taiwan Min +Luohe China Chinese +Luoyang China Chinese +Luton United Kingdom English +Lutsk Ukraine Ukrainian +Luxor Egypt Arabic +Luzhou China Chinese +Luziânia Brazil Portuguese +Lviv Ukraine Ukrainian +Lyon France French +Lysytšansk Ukraine Ukrainian +L´Hospitalet de Llobregat Spain Spanish +Lázaro Cárdenas Mexico Spanish +Lódz Poland Polish +Lübeck Germany German +Lünen Germany German +EXPLAIN +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE country NULL range PRIMARY,Name Name 208 NULL 9 100.00 Using where; Using index +2 SIMPLE city NULL ref Population,Country Country 12 world.country.Code 17 87.23 Using where +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name` from `world`.`country` join `world`.`city` where ((`world`.`city`.`Country` = `world`.`country`.`Code`) and (`world`.`city`.`Population` > 100000) and (`world`.`country`.`Name` like 'L%')) +SELECT Name FROM city +WHERE city.country IN (SELECT Code FROM country WHERE country.Name LIKE 'L%') AND +city.Population > 100000; +Name +Beirut +Bengasi +Daugavpils +Kaunas +Klaipeda +Maseru +Misrata +Monrovia +Panevezys +Riga +Tripoli +Tripoli +Vientiane +Vilnius +Šiauliai +set join_buffer_size=default; +show variables like 'join_buffer_size'; +Variable_name Value +join_buffer_size 262144 +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=256; +EXPLAIN +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE city NULL range Population,Country Population 4 NULL # 100.00 Using index condition; Using MRR +2 SIMPLE country NULL eq_ref PRIMARY PRIMARY 12 world.city.Country # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `world`.`city`.`Name` AS `Name`,`world`.`country`.`Name` AS `Name` from `world`.`city` join `world`.`country` where ((`world`.`country`.`Code` = `world`.`city`.`Country`) and (`world`.`city`.`Population` > 3000000)) +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND city.Population > 3000000; +Name Name +Alexandria Egypt +Ankara Turkey +Baghdad Iraq +Bangkok Thailand +Berlin Germany +Cairo Egypt +Calcutta [Kolkata] India +Chengdu China +Chennai (Madras) India +Chongqing China +Ciudad de México Mexico +Delhi India +Dhaka Bangladesh +Harbin China +Ho Chi Minh City Vietnam +Istanbul Turkey +Jakarta Indonesia +Jokohama [Yokohama] Japan +Kanton [Guangzhou] China +Karachi Pakistan +Kinshasa Congo, The Democratic Republic of the +Lahore Pakistan +Lima Peru +London United Kingdom +Los Angeles United States +Moscow Russian Federation +Mumbai (Bombay) India +New York United States +Peking China +Pusan South Korea +Rangoon (Yangon) Myanmar +Rio de Janeiro Brazil +Riyadh Saudi Arabia +Santafé de Bogotá Colombia +Santiago de Chile Chile +Seoul South Korea +Shanghai China +Shenyang China +Singapore Singapore +St Petersburg Russian Federation +Sydney Australia +São Paulo Brazil +Teheran Iran +Tianjin China +Tokyo Japan +Wuhan China +set join_buffer_size=default; +ALTER TABLE country MODIFY Name varchar(52) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country MODIFY Name varchar(250) NOT NULL default ''; +SELECT city.Name, country.Name FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name +Beirut Lebanon +Bengasi Libyan Arab Jamahiriya +Daugavpils Latvia +Kaunas Lithuania +Klaipeda Lithuania +Maseru Lesotho +Misrata Libyan Arab Jamahiriya +Monrovia Liberia +Panevezys Lithuania +Riga Latvia +Tripoli Lebanon +Tripoli Libyan Arab Jamahiriya +Vientiane Laos +Vilnius Lithuania +Šiauliai Lithuania +ALTER TABLE country ADD COLUMN PopulationBar text; +UPDATE country +SET PopulationBar=REPEAT('x', CAST(Population/100000 AS unsigned int)); +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=256; +SELECT city.Name, country.Name, country.PopulationBar FROM city,country +WHERE city.country=country.Code AND +country.Name LIKE 'L%' AND city.Population > 100000; +Name Name PopulationBar +Beirut Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Bengasi Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Daugavpils Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Maseru Lesotho xxxxxxxxxxxxxxxxxxxxxx +Misrata Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Monrovia Liberia xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Riga Latvia xxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Lebanon xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Tripoli Libyan Arab Jamahiriya xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vientiane Laos xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Vilnius Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +Šiauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +set join_buffer_size=default; +DROP DATABASE world; +use test; +CREATE TABLE t1( +affiliatetometaid int NOT NULL default '0', +uniquekey int NOT NULL default '0', +metaid int NOT NULL default '0', +affiliateid int NOT NULL default '0', +xml text, +isactive char(1) NOT NULL default 'Y', +PRIMARY KEY (affiliatetometaid) +); +CREATE UNIQUE INDEX t1_uniquekey ON t1(uniquekey); +CREATE INDEX t1_affiliateid ON t1(affiliateid); +CREATE INDEX t1_metaid on t1 (metaid); +INSERT INTO t1 VALUES +(1616, 1571693233, 1391, 2, NULL, 'Y'), (1943, 1993216749, 1726, 2, NULL, 'Y'); +CREATE TABLE t2( +metaid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +dateadded timestamp NOT NULL , +xml text, +status int default NULL, +origin int default NULL, +gid int NOT NULL default '1', +formattypeid int default NULL, +PRIMARY KEY (metaid) +); +CREATE INDEX t2_status ON t2(status); +CREATE INDEX t2_gid ON t2(gid); +CREATE INDEX t2_formattypeid ON t2(formattypeid); +INSERT INTO t2 VALUES +(1391, "I Just Died", "2003-10-02 10:07:37", "", 1, NULL, 3, NULL), +(1726, "Me, Myself & I", "2003-12-05 11:24:36", " ", 1, NULL, 3, NULL); +CREATE TABLE t3( +mediaid int NOT NULL , +metaid int NOT NULL default '0', +formatid int NOT NULL default '0', +status int default NULL, +path varchar(100) NOT NULL default '', +datemodified timestamp NOT NULL , +resourcetype int NOT NULL default '1', +parameters text, +signature int default NULL, +quality int NOT NULL default '255', +PRIMARY KEY (mediaid) +); +CREATE INDEX t3_metaid ON t3(metaid); +CREATE INDEX t3_formatid ON t3(formatid); +CREATE INDEX t3_status ON t3(status); +CREATE INDEX t3_metaidformatid ON t3(metaid,formatid); +CREATE INDEX t3_signature ON t3(signature); +CREATE INDEX t3_quality ON t3(quality); +INSERT INTO t3 VALUES +(6, 4, 8, 0, "010101_anastacia_spmidi.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255), +(3343, 3, 8, 1, "010102_4VN4bsPwnxRQUJW5Zp1RhG2IL9vvl_8.mid", "2004-03-16 13:40:00", 1, NULL, NULL, 255); +CREATE TABLE t4( +formatid int NOT NULL , +name varchar(60) NOT NULL default '', +formatclassid int NOT NULL default '0', +mime varchar(60) default NULL, +extension varchar(10) default NULL, +priority int NOT NULL default '0', +canaddtocapability char(1) NOT NULL default 'Y', +PRIMARY KEY (formatid) +); +CREATE INDEX t4_formatclassid ON t4(formatclassid); +CREATE INDEX t4_formats_idx ON t4(canaddtocapability); +INSERT INTO t4 VALUES +(19, "XHTML", 11, "text/html", "xhtml", 10, 'Y'), +(54, "AMR (wide band)", 13, "audio/amr-wb", "awb", 0, 'Y'); +CREATE TABLE t5( +formatclassid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int NOT NULL default '0', +formattypeid int NOT NULL default '0', +PRIMARY KEY (formatclassid) +); +CREATE INDEX t5_formattypeid on t5(formattypeid); +INSERT INTO t5 VALUES +(11, "Info", 0, 4), (13, "Digital Audio", 0, 2); +CREATE TABLE t6( +formattypeid int NOT NULL , +name varchar(60) NOT NULL default '', +priority int default NULL, +PRIMARY KEY (formattypeid) +); +INSERT INTO t6 VALUES +(2, "Ringtones", 0); +CREATE TABLE t7( +metaid int NOT NULL default '0', +artistid int NOT NULL default '0', +PRIMARY KEY (metaid,artistid) +); +INSERT INTO t7 VALUES +(4, 5), (3, 4); +CREATE TABLE t8( +artistid int NOT NULL , +name varchar(80) NOT NULL default '', +PRIMARY KEY (artistid) +); +INSERT INTO t8 VALUES +(5, "Anastacia"), (4, "John Mayer"); +CREATE TABLE t9( +subgenreid int NOT NULL default '0', +metaid int NOT NULL default '0', +PRIMARY KEY (subgenreid,metaid) +) ; +CREATE INDEX t9_subgenreid ON t9(subgenreid); +CREATE INDEX t9_metaid ON t9(metaid); +INSERT INTO t9 VALUES +(138, 4), (31, 3); +CREATE TABLE t10( +subgenreid int NOT NULL , +genreid int NOT NULL default '0', +name varchar(80) NOT NULL default '', +PRIMARY KEY (subgenreid) +) ; +CREATE INDEX t10_genreid ON t10(genreid); +INSERT INTO t10 VALUES +(138, 19, ''), (31, 3, ''); +CREATE TABLE t11( +genreid int NOT NULL default '0', +name char(80) NOT NULL default '', +priority int NOT NULL default '0', +masterclip char(1) default NULL, +PRIMARY KEY (genreid) +) ; +CREATE INDEX t11_masterclip ON t11( masterclip); +INSERT INTO t11 VALUES +(19, "Pop & Dance", 95, 'Y'), (3, "Rock & Alternative", 100, 'Y'); +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +EXPLAIN +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t1_affiliateid,t1_metaid t1_metaid 4 test.t7.metaid 1 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 100.00 NULL +1 SIMPLE t11 NULL eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t7.metaid 1 100.00 NULL +1 SIMPLE t3 NULL ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaid 4 test.t7.metaid 1 100.00 Using where +1 SIMPLE t4 NULL ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formatclassid 4 test.t5.formatclassid 1 100.00 Using index condition; Using where +1 SIMPLE t5 NULL ref PRIMARY,t5_formattypeid t5_formattypeid 4 const 1 100.00 NULL +1 SIMPLE t6 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t7 NULL index PRIMARY PRIMARY 8 NULL 2 50.00 Using where; Using index +1 SIMPLE t8 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +1 SIMPLE t9 NULL ref PRIMARY,t9_subgenreid,t9_metaid t9_metaid 4 test.t7.metaid 1 100.00 Using index +SELECT t1.uniquekey, t1.xml AS affiliateXml, +t8.name AS artistName, t8.artistid, +t11.name AS genreName, t11.genreid, t11.priority AS genrePriority, +t10.subgenreid, t10.name AS subgenreName, +t2.name AS metaName, t2.metaid, t2.xml AS metaXml, +t4.priority + t5.priority + t6.priority AS overallPriority, +t3.path AS path, t3.mediaid, +t4.formatid, t4.name AS formatName, +t5.formatclassid, t5.name AS formatclassName, +t6.formattypeid, t6.name AS formattypeName +FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 +WHERE t7.metaid = t2.metaid AND t7.artistid = t8.artistid AND +t9.metaid = t2.metaid AND t9.subgenreid = t10.subgenreid AND +t10.genreid = t11.genreid AND t3.metaid = t2.metaid AND +t3.formatid = t4.formatid AND t4.formatclassid = t5.formatclassid AND +t4.canaddtocapability = 'Y' AND t5.formattypeid = t6.formattypeid AND +t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND +t1.metaid = t2.metaid AND t1.affiliateid = '2'; +uniquekey affiliateXml artistName artistid genreName genreid genrePriority subgenreid subgenreName metaName metaid metaXml overallPriority path mediaid formatid formatName formatclassid formatclassName formattypeid formattypeName +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; +CREATE TABLE t1 (a1 int, filler1 char(64) default ' ' ); +CREATE TABLE t2 ( +a2 int, b2 int, filler2 char(64) default ' ', +PRIMARY KEY idx(a2,b2,filler2) +) ; +CREATE TABLE t3 (b3 int, c3 int, INDEX idx(b3)); +INSERT INTO t1(a1) VALUES +(4), (7), (1), (9), (8), (5), (3), (6), (2); +INSERT INTO t2(a2,b2) VALUES +(1,30), (3,40), (2,61), (6,73), (8,92), (9,27), (4,18), (5,84), (7,56), +(4,14), (6,76), (8,98), (7,55), (1,39), (2,68), (3,45), (9,21), (5,81), +(5,88), (2,65), (6,74), (9,23), (1,37), (3,44), (4,17), (8,99), (7,51), +(9,28), (7,52), (1,33), (4,13), (5,87), (3,43), (8,91), (2,62), (6,79), +(3,49), (8,93), (7,34), (5,82), (6,78), (2,63), (1,32), (9,22), (4,11); +INSERT INTO t3 VALUES +(30,302), (92,923), (18,187), (45,459), (30,309), +(39,393), (68,685), (45,458), (21,210), (81,817), +(40,405), (61,618), (73,738), (92,929), (27,275), +(18,188), (84,846), (56,564), (14,144), (76,763), +(98,982), (55,551), (17,174), (99,998), (51,513), +(28,282), (52,527), (33,336), (13,138), (87,878), +(43,431), (91,916), (62,624), (79,797), (49,494), +(93,933), (34,347), (82,829), (78,780), (63,634), +(32,329), (22,228), (11,114), (74,749), (23,236); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +set join_buffer_size=512; +EXPLAIN +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 # 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b2 # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a1` <> `test`.`t2`.`a2`) AS `a1<>a2`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`b3` AS `b3`,`test`.`t3`.`c3` AS `c3`,substr(`test`.`t1`.`filler1`,1,1) AS `s1`,substr(`test`.`t2`.`filler2`,1,1) AS `s2` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`) and ((`test`.`t3`.`c3` % 10) > 7)) +SELECT a1<>a2, a1, a2, b2, b3, c3, +SUBSTR(filler1,1,1) AS s1, SUBSTR(filler2,1,1) AS s2 +FROM t1,t2,t3 WHERE a1=a2 AND b2=b3 AND MOD(c3,10)>7; +a1<>a2 a1 a2 b2 b3 c3 s1 s2 +0 1 1 30 30 309 +0 1 1 32 32 329 +0 2 2 61 61 618 +0 3 3 45 45 458 +0 3 3 45 45 459 +0 4 4 13 13 138 +0 4 4 18 18 188 +0 5 5 82 82 829 +0 5 5 87 87 878 +0 6 6 73 73 738 +0 6 6 74 74 749 +0 8 8 92 92 929 +0 8 8 99 99 998 +0 9 9 22 22 228 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, b int, INDEX idx(b)); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); +INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); +INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); +set join_buffer_size=32; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '32' +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 5 NULL 3 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` >= 30)) +SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b >= 30; +a b a b +7 40 7 10 +7 40 7 10 +7 40 7 20 +8 30 8 10 +8 30 8 20 +DROP TABLE t1,t2; + +BUG#40136: Group by is ignored when join buffer is used for an outer join + +create table t1(a int PRIMARY KEY, b int); +insert into t1 values +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +create table t2 (p int, a int, INDEX i_a(a)); +insert into t2 values +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index +2 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where true group by `test`.`t1`.`a` +select t1.a, count(t2.p) as count +from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a order by t1.a; +a count +1 1 +2 0 +3 2 +5 0 +6 0 +7 2 +8 0 +9 0 +drop table t1, t2; +# +# Bug #40134: outer join with not exists optimization and join buffer +# +set join_buffer_size=default; +CREATE TABLE t1 (a int NOT NULL); +INSERT INTO t1 VALUES (2), (4), (3), (5), (1); +CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); +INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref i_a i_a 4 test.t1.a 2 20.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`b` is null) +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; +a a b +3 NULL NULL +5 NULL NULL +1 NULL NULL +DROP TABLE t1, t2; +# +# BUG#40268: Nested outer join with not null-rejecting where condition +# over an inner table which is not the last in the nest +# +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 LEFT JOIN (t3, t4) ON t2.b=t4.b +WHERE t3.a+2 NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`c` = 102) or (`test`.`t2`.`c` is null)) +select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; +a b a c +2 20 NULL NULL +3 30 3 102 +drop table t1, t2; +# +# Bug #40317: outer join with with constant on expression equal to FALSE +# +create table t1 (a int); +insert into t1 values (30), (40), (20); +create table t2 (b int); +insert into t2 values (200), (100); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select * from t1 left join t2 on (1=0); +a b +30 NULL +40 NULL +20 NULL +explain select * from t1 left join t2 on (1=0) where a=40; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(false) where (`test`.`t1`.`a` = 40) +select * from t1 left join t2 on (1=0) where a=40; +a b +40 NULL +drop table t1, t2; +# +# Bug #41204: small buffer with big rec_per_key for ref access +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0); +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1(a) SELECT a FROM t1; +INSERT INTO t1 VALUES (20000), (10000); +CREATE TABLE t2 (pk int AUTO_INCREMENT PRIMARY KEY, b int, c int, INDEX idx(b)); +INSERT INTO t2(b,c) VALUES (10000, 3), (20000, 7), (20000, 1), (10000, 9), (20000, 5); +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +INSERT INTO t2(b,c) SELECT b,c FROM t2; +ANALYZE TABLE t1,t2; +set join_buffer_size=1024; +EXPLAIN SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2050 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2050 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.a 640 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t2`.`c`) AS `AVG(c)` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; +AVG(c) +5.0000 +set join_buffer_size=default; +DROP TABLE t1, t2; +# +# Bug #41894: big join buffer of level 7 used to join records +# with null values in place of varchar strings +# +CREATE TABLE t1 (a int NOT NULL AUTO_INCREMENT PRIMARY KEY, +b varchar(127) DEFAULT NULL); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +INSERT INTO t1(b) SELECT b FROM t1; +CREATE TABLE t2 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t2 SELECT * FROM t1; +CREATE TABLE t3 (a int NOT NULL PRIMARY KEY, b varchar(127) DEFAULT NULL); +INSERT INTO t3 SELECT * FROM t1; +set join_buffer_size=1024*1024; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 16400 10.00 Parallel execute (4 workers) +2 SIMPLE # NULL ALL PRIMARY NULL NULL # 16400 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +2 SIMPLE # NULL eq_ref PRIMARY PRIMARY 4 # 1 10.00 Using where +SELECT COUNT(*) FROM t1,t2,t3 +WHERE t1.a=t2.a AND t2.a=t3.a AND +t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; +COUNT(*) +16384 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +# +# Bug #42020: join buffer is used for outer join with fields of +# several outer tables in join buffer +# +CREATE TABLE t1 ( +a bigint NOT NULL, +PRIMARY KEY (a) +); +INSERT INTO t1 VALUES +(2), (1); +CREATE TABLE t2 ( +a bigint NOT NULL, +b bigint NOT NULL, +PRIMARY KEY (a,b) +); +INSERT INTO t2 VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(1,10), (1, 20), (1,30), (1,40), (1,50); +CREATE TABLE t3 ( +pk bigint NOT NULL AUTO_INCREMENT, +a bigint NOT NULL, +b bigint NOT NULL, +val bigint DEFAULT '0', +PRIMARY KEY (pk), +KEY idx (a,b) +); +INSERT INTO t3(a,b) VALUES +(2,30), (2,40), (2,50), (2,60), (2,70), (2,80), +(4,30), (4,40), (4,50), (4,60), (4,70), (4,80), +(5,30), (5,40), (5,50), (5,60), (5,70), (5,80), +(7,30), (7,40), (7,50), (7,60), (7,70), (7,80); +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=256; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ref idx idx 16 test.t1.a,test.t2.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +DROP INDEX idx ON t3; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 test.t1.a 5 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 24 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`val` AS `val` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(((`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val +FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) +WHERE t1.a=t2.a; +a a a b b val +1 1 NULL 10 NULL NULL +1 1 NULL 20 NULL NULL +1 1 NULL 30 NULL NULL +1 1 NULL 40 NULL NULL +1 1 NULL 50 NULL NULL +2 2 2 30 30 0 +2 2 2 40 40 0 +2 2 2 50 50 0 +2 2 2 60 60 0 +2 2 2 70 70 0 +2 2 2 80 80 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3; +create table t1(f1 int, f2 int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2(f1 int not null, f2 int not null, f3 char(200), key(f1,f2)); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +insert into t2 values (1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'); +insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), +(2,4, 'qwerty'),(2,5, 'qwerty'); +insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty'); +insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), +(4,4, 'qwerty'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +explain select t2.f1, t2.f2, t2.f3 from t1,t2 +where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t2`.`f2`)) +drop table t1,t2; +# +# Bug #42955: join with GROUP BY/ORDER BY and when BKA is enabled +# +create table t1 (d int, id1 int, index idx1 (d, id1)); +insert into t1 values +(3, 20), (2, 40), (3, 10), (1, 10), (3, 20), (1, 40), (2, 30), (3, 30); +create table t2 (id1 int, id2 int, index idx2 (id1)); +insert into t2 values +(20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), +(40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,sum(`test`.`t2`.`id2`) AS `sum(t2.id2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3)) group by `test`.`t1`.`id1` +select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 group by t1.id1; +id1 sum(t2.id2) +10 900 +20 2000 +30 900 +explain +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1 idx1 5 const 4 100.00 Using where; Using index +2 SIMPLE t2 NULL ref idx2 idx2 5 test.t1.id1 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t1`.`d` = 3) and (`test`.`t2`.`id2` > 200)) order by `test`.`t1`.`id1` +select t1.id1 from t1 join t2 on t1.id1=t2.id1 +where t1.d=3 and t2.id2 > 200 order by t1.id1; +id1 +10 +10 +20 +20 +20 +20 +30 +30 +drop table t1,t2; +# +# Bug #44019: star-like multi-join query executed optimizer_join_cache_level=6 +# +create table t1 (a int, b int, c int, d int); +create table t2 (b int, e varchar(16), index idx(b)); +create table t3 (d int, f varchar(16), index idx(d)); +create table t4 (c int, g varchar(16), index idx(c)); +insert into t1 values +(5, 50, 500, 5000), (3, 30, 300, 3000), (9, 90, 900, 9000), +(2, 20, 200, 2000), (4, 40, 400, 4000), (8, 80, 800, 800), +(7, 70, 700, 7000); +insert into t2 values +(30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), +(31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), +(32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t3 values +(4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), +(4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), +(4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t4 values +(200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), +(201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), +(202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +analyze table t2,t3,t4; +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using where +2 SIMPLE t2 NULL ref idx idx 5 test.t1.b 1 100.00 NULL +2 SIMPLE t3 NULL ref idx idx 5 test.t1.d 1 100.00 NULL +2 SIMPLE t4 NULL ref idx idx 5 test.t1.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t2`.`e` AS `e`,`test`.`t3`.`f` AS `f`,`test`.`t4`.`g` AS `g` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`c` = `test`.`t1`.`c`) and (`test`.`t3`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 +where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; +a b c d e f g +3 30 300 3000 bbb ddd ccc +drop table t1,t2,t3,t4; +# +# Bug #44250: Corruption of linked join buffers when using BKA +# +CREATE TABLE t1 ( +id1 bigint(20) DEFAULT NULL, +id2 bigint(20) DEFAULT NULL, +id3 bigint(20) DEFAULT NULL, +num1 bigint(20) DEFAULT NULL, +num2 int(11) DEFAULT NULL, +num3 bigint(20) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id3 bigint(20) NOT NULL DEFAULT '0', +id4 bigint(20) DEFAULT NULL, +enum1 enum('Enabled','Disabled','Paused') DEFAULT NULL, +PRIMARY KEY (id3) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +id4 bigint(20) NOT NULL DEFAULT '0', +text1 text, +PRIMARY KEY (id4) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +id2 bigint(20) NOT NULL DEFAULT '0', +dummy int(11) DEFAULT '0', +PRIMARY KEY (id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +id1 bigint(20) NOT NULL DEFAULT '0', +id2 bigint(20) NOT NULL DEFAULT '0', +enum2 enum('Active','Deleted','Paused') DEFAULT NULL, +PRIMARY KEY (id1,id2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set join_buffer_size=2048; +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id3 # 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.id4 # 33.33 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 8 test.t1.id2 # 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 16 test.t1.id1,test.t1.id2 # 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`num3` AS `num3`,`test`.`t3`.`text1` AS `text1`,`test`.`t3`.`id4` AS `id4`,`test`.`t2`.`id3` AS `id3`,`test`.`t4`.`dummy` AS `dummy` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` join `test`.`t5` where ((`test`.`t2`.`id3` = `test`.`t1`.`id3`) and (`test`.`t3`.`id4` = `test`.`t2`.`id4`) and (`test`.`t5`.`enum2` = 'Active') and (`test`.`t4`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id2` = `test`.`t1`.`id2`) and (`test`.`t5`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`text1` < 'D')) +SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy +FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 +WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND +t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; +id1 num3 text1 id4 id3 dummy +228172702 134 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 14 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 15 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228172702 3 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2567095402 2667134182 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 10 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 13 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 14 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 17 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 18 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 19 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 26 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 28 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 4 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 50 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 6 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 60 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 61 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 826928662 935693782 0 +228808822 62 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 84 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 89 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +228808822 9 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 +set join_buffer_size=default; +DROP TABLE t1,t2,t3,t4,t5; +# +# Bug #46328: Use of aggregate function without GROUP BY clause +# returns many rows (vs. one ) +# +CREATE TABLE t1 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(0),(2),(2),(2),(3),(4),(5),(5),(6),(6),(8),(8),(9),(9); +CREATE TABLE t2 ( +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2),(3); + +# The query shall return 1 record with a max value 9 and one of the +# int_key values inserted above (undefined which one, so it's replaced +# with "#"). +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +MAX(t1.int_key) int_key +9 # + +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain +SELECT MAX(t1.int_key), t1.int_key +FROM t1 STRAIGHT_JOIN t2 +ORDER BY t1.int_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 14 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL int_key 4 NULL 14 100.00 Using index +2 SIMPLE t2 NULL index NULL int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`int_key`) AS `MAX(t1.int_key)`,`test`.`t1`.`int_key` AS `int_key` from `test`.`t1` straight_join `test`.`t2` + +DROP TABLE t1,t2; +# +# Bug #45019: join buffer contains two blob columns one of which is +# used in the key employed to access the joined table +# +CREATE TABLE t1 (c1 int, c2 int, key (c2)); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,2); +CREATE TABLE t2 (c1 text, c2 text); +INSERT INTO t2 VALUES('tt', 'uu'); +INSERT INTO t2 VALUES('zzzz', 'xxxxxxxxx'); +ANALYZE TABLE t1,t2; +SELECT t1.*, t2.*, LENGTH(t2.c1), LENGTH(t2.c2) FROM t1,t2 +WHERE t1.c2=LENGTH(t2.c2) and t1.c1=LENGTH(t2.c1); +c1 c2 c1 c2 LENGTH(t2.c1) LENGTH(t2.c2) +2 2 tt uu 2 2 +DROP TABLE t1,t2; +# +# Regression test for +# Bug#46733 - NULL value not returned for aggregate on empty result +# set w/ semijoin on +CREATE TABLE t1 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10,'a'),(11,'b'),(12,'c'),(13,'d'); +CREATE TABLE t2 ( +i int(11) NOT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (i) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'x'),(2,'y'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +MAX(t1.i) +NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'y' + +EXPLAIN +SELECT MAX(t1.i) +FROM t1 JOIN t2 ON t2.v +ORDER BY t2.v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`i`) AS `MAX(t1.i)` from `test`.`t1` join `test`.`t2` where (0 <> `test`.`t2`.`v`) + +DROP TABLE t1,t2; +# +# Bug#51092: Linked join buffer gives wrong result +# for 3-way cross join +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,1),(2,2); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t3 VALUES (1,1),(2,2); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +SELECT t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +DROP TABLE t1,t2,t3; +# +# BUG#52394 Segfault in JOIN_CACHE::get_offset () at sql_select.h:445 +# +CREATE TABLE C(a int); +INSERT INTO C VALUES(1),(2),(3),(4),(5); +CREATE TABLE D (a int(11), b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO D VALUES (6,'r'),(27,'o'); +CREATE TABLE E (a int(11) primary key, b varchar(1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO E VALUES +(14,'d'),(15,'z'),(16,'e'),(17,'h'),(18,'b'),(19,'s'),(20,'e'),(21,'j'),(22,'e'),(23,'f'),(24,'v'),(25,'x'),(26,'m'),(27,'c'); +SELECT 1 FROM C,D,E WHERE D.a = E.a AND D.b = E.b; +1 +DROP TABLE C,D,E; +# +# BUG#52540 Crash in JOIN_CACHE::set_match_flag_if_none () at sql_join_cache.cc:1883 +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (a varchar(10)); +INSERT INTO t2 VALUES ('f'),('x'); +CREATE TABLE t3 (pk int(11) PRIMARY KEY); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (2); +CREATE TABLE t4 (a varchar(10)); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` left join (`test`.`t1` join `test`.`t3` left join `test`.`t4` on(true)) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`))) where true +SELECT 1 +FROM t2 LEFT JOIN +((t1 JOIN t3 ON t1.a = t3.pk) +LEFT JOIN t4 ON 1 ) +ON 1 ; +1 +1 +1 +DROP TABLE t1,t2,t3,t4; +# +# Bug#51084: Batched key access crashes for SELECT with +# derived table and LEFT JOIN +# +CREATE TABLE t1 ( +carrier int, +id int PRIMARY KEY +); +INSERT INTO t1 VALUES (1,11),(1,12),(2,13); +CREATE TABLE t2 ( +scan_date int, +package_id int +); +INSERT INTO t2 VALUES (2008,21),(2008,22); +CREATE TABLE t3 ( +carrier int PRIMARY KEY, +id int +); +INSERT INTO t3 VALUES (1,31); +CREATE TABLE t4 ( +carrier_id int, +INDEX carrier_id(carrier_id) +); +INSERT INTO t4 VALUES (31),(32); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK + +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +COUNT(*) +6 + +EXPLAIN +SELECT COUNT(*) +FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) +ON t3.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.carrier 1 100.00 NULL +2 SIMPLE t4 NULL ref carrier_id carrier_id 5 test.t3.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`carrier_id` = `test`.`t3`.`id`) and (`test`.`t3`.`carrier` = `test`.`t1`.`carrier`))) where true + +DROP TABLE t1,t2,t3,t4; +# +# Bug#45267: Incomplete check caused wrong result. +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +`pk` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES +(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15), +(16),(17),(18),(19),(20); +CREATE TABLE t2 ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10,9,'22:36:46'),(11,0,'08:46:46'); +SELECT DISTINCT t1.`pk` +FROM t1 RIGHT JOIN t2 STRAIGHT_JOIN t3 ON t2.`int_nokey` ON t2.`time_key` +GROUP BY 1; +pk +NULL +DROP TABLE IF EXISTS t1, t2, t3; +# +# BUG#52636 6.0 allowing JOINs on NULL values w/ optimizer_join_cache_level = 5-8 +# +CREATE TABLE t1 (b int); +INSERT INTO t1 VALUES (NULL),(3); +CREATE TABLE t2 (a int, b int, KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,200); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +delete from t1; +INSERT INTO t1 VALUES (NULL),(NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 5 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`b`) on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 FORCE INDEX (b) ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (b varchar(100)); +INSERT INTO t1 VALUES (NULL),("some varchar"); +CREATE TABLE t2 (a int, b varchar(100), KEY (b)); +INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref b b 403 test.t1.b 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true +SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; +a +NULL +NULL +DROP TABLE t1,t2; +# +# BUG#54359 "Extra rows with join_cache_level=7,8 and two joins +# --and multi-column index" +# +CREATE TABLE t1 ( +`pk` int(11) NOT NULL, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)) +; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,9,'k','k'); +INSERT INTO t1 VALUES (12,5,'k','k'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE table3 NULL ALL col_varchar_key NULL NULL NULL 2 50.00 Using where +2 SIMPLE table2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`col_int_key` AS `col_int_key` from `test`.`t1` `table2` join `test`.`t1` `table3` FORCE INDEX (`col_varchar_key`) where ((`test`.`table2`.`col_varchar_nokey` = `test`.`table3`.`col_varchar_key`) and (0 <> `test`.`table3`.`pk`) and (`test`.`table3`.`col_int_key` >= `test`.`table2`.`pk`)) +SELECT table2 .`col_int_key` FROM t1 table2, +t1 table3 force index (`col_varchar_key`) +where table3 .`pk` and table3 .`col_int_key` >= table2 .`pk` +and table3 .`col_varchar_key` = table2 .`col_varchar_nokey`; +col_int_key +9 +9 +drop table t1; +# +# BUG#54481 "GROUP BY loses effect with JOIN + ORDER BY + LIMIT +# and join_cache_level=5-8" +# +CREATE TABLE t1 ( +`col_int_key` int, +`col_datetime` datetime, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t1 VALUES (2,'2003-02-11 21:19:41'); +INSERT INTO t1 VALUES (3,'2009-10-18 02:27:49'); +INSERT INTO t1 VALUES (0,'2000-09-26 07:45:57'); +INSERT INTO t1 VALUES (4,'2000-09-26 07:45:57'); +CREATE TABLE t2 ( +`col_int` int, +`col_int_key` int, +KEY `col_int_key` (`col_int_key`) +); +INSERT INTO t2 VALUES (14,1); +INSERT INTO t2 VALUES (98,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1,t2 +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 4 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key`,`test`.`t1`.`col_datetime` AS `col_datetime` from `test`.`t1` FORCE INDEX (`col_int_key`) join `test`.`t2` IGNORE INDEX (`col_int_key`) where ((`test`.`t2`.`col_int_key` = 1) and (`test`.`t2`.`col_int` >= 3)) group by `test`.`t1`.`col_int_key` order by `test`.`t1`.`col_int_key`,`test`.`t1`.`col_datetime` limit 2 +SELECT t1.col_int_key, t1.col_datetime +FROM t1 force index (col_int_key), t2 ignore index (col_int_key) +WHERE t2.col_int_key = 1 AND t2.col_int >= 3 +GROUP BY t1.col_int_key +ORDER BY t1.col_int_key, t1.col_datetime +LIMIT 2; +col_int_key col_datetime +0 2000-09-26 07:45:57 +2 2003-02-11 21:19:41 +drop table t1,t2; + +# Bug#11766522 "59651: ASSERTION `TABLE_REF->HAS_RECORD' FAILED +# WITH JOIN_CACHE_LEVEL=3" + +CREATE TABLE t1 ( +b varchar(20) +) ; +INSERT INTO t1 VALUES ('1'),('1'); +CREATE TABLE t4 ( +col253 text +) ; +INSERT INTO t4 VALUES (''),('pf'); +CREATE TABLE t6 ( +col282 timestamp +) ; +INSERT INTO t6 VALUES ('2010-11-07 01:04:45'),('2010-12-13 01:36:32'); +CREATE TABLE t7 ( +col319 timestamp NOT NULL, +UNIQUE KEY idx263 (col319) +) ; +insert into t7 values("2000-01-01"),("2000-01-02"); +CREATE TABLE t3 ( +col582 char(230) CHARACTER SET utf8 DEFAULT NULL +) ; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES ('cymej'),('spb'); +CREATE TABLE t5 ( +col712 time +) ; +insert into t5 values(0),(0); +CREATE TABLE t8 ( +col804 char(169), +col805 varchar(51) +) ; +INSERT INTO t8 VALUES ('tmqcb','pwk'); +CREATE TABLE t2 ( +col841 varchar(10) +) ; +INSERT INTO t2 VALUES (''),(''); +set join_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '1' +select @@join_buffer_size; +@@join_buffer_size +128 +select count(*) from +(t1 join t2 join t3) +left join t4 on 1 +left join t5 on 1 like t4.col253 +left join t6 on t5.col712 is null +left join t7 on t1.b <=>t7.col319 +left join t8 on t3.col582 <= 1; +count(*) +32 +drop table t1,t2,t3,t4,t5,t6,t7,t8; +# +# Bug#12616131 - JCL: NULL VS DATE + TWICE AS MANY ROWS +# RETURNED WHEN JCL>=7 +# +CREATE TABLE t1 (t1a int, t1b int); +INSERT INTO t1 VALUES (99, NULL),(99, 3),(99,0); +CREATE TABLE t2 (t2a int, t2b int, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0),(999, NULL); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK + +# t2b is NULL-able + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 5 test.t1.t1b # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL 999 NULL + +DROP TABLE t2; +CREATE TABLE t2 (t2a int, t2b int NOT NULL, KEY idx (t2b)); +INSERT INTO t2 VALUES (100,0),(150,200),(999, 0); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK + +# t2b is NOT NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` = `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b = t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.t1b # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1a` AS `t1a`,`test`.`t1`.`t1b` AS `t1b`,`test`.`t2`.`t2a` AS `t2a`,`test`.`t2`.`t2b` AS `t2b` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`idx`) on((`test`.`t2`.`t2b` <=> `test`.`t1`.`t1b`)) where true +SELECT * FROM t1 LEFT JOIN t2 force index (idx) ON t2.t2b <=> t1.t1b; +t1a t1b t2a t2b +99 0 100 0 +99 0 999 0 +99 3 NULL NULL +99 NULL NULL NULL + +DROP TABLE t1,t2; +# +# BUG#12619399 - JCL: NO ROWS VS 3X NULL QUERY OUTPUT WHEN JCL>=5 +# +CREATE TABLE t1 ( +c1 INTEGER NOT NULL, +c2_key INTEGER NOT NULL, +KEY col_int_key (c2_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (24,204); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (10); +CREATE TABLE t3 ( +c1 INTEGER, +KEY k1 (c1) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (NULL), (NULL); +set @old_opt_switch=@@optimizer_switch; + +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=tree SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +EXPLAIN +-> Filter: ((t3.c1,(select #2)) xor true) (cost=0.45 rows=2) + -> Index scan on t3 using k1 (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) (cost=0.70 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (outer_field_is_not_null, ((t3.c1) = t1.c2_key), true) (cost=0.35 rows=1) + -> Alternative plans for IN subquery: Index lookup unless c2_key IS NULL (cost=0.35 rows=1) + -> Index lookup on t1 using col_int_key (c2_key=(t3.c1)) + -> Table scan on t1 + -> Filter: (t2.pk < t1.c1) (cost=0.35 rows=1) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.35 rows=1) + +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where ((`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)))) xor true) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL index NULL k1 5 NULL 2 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref col_int_key col_int_key 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where (`test`.`t3`.`c1`,(/* select#2 */ select `test`.`t1`.`c2_key` from `test`.`t2` join `test`.`t1` where ((outer_field_is_not_null, ((`test`.`t3`.`c1`) = `test`.`t1`.`c2_key`), true) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`))) is false) +explain SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_int_key NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x1) +1 SIMPLE t3 NULL ref k1 k1 5 test.t1.c2_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1` from `test`.`t3` semi join (`test`.`t2` join `test`.`t1`) where ((`test`.`t3`.`c1` = `test`.`t1`.`c2_key`) and (`test`.`t2`.`pk` < `test`.`t1`.`c1`)) +SELECT t3.c1 FROM t3 +WHERE t3.c1 = SOME (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 = ANY (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1) +XOR TRUE; +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 NOT IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 +SELECT t3.c1 FROM t3 +WHERE t3.c1 IN (SELECT t1.c2_key FROM t2 JOIN t1 ON t2.pk < t1.c1); +c1 + +set @@optimizer_switch=@old_opt_switch; +DROP TABLE t1, t2, t3; +set @@join_buffer_size=default; + +# BUG#12586926 "EXTRA ROW WITH JOIN + GROUP BY + ORDER BY WITH +# JCL>=5 AND MRR ENABLED" + +CREATE TABLE t1 ( col_int_key int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'j'),(4,'b'),(4,'d'); +CREATE TABLE t2 ( +col_datetime_key datetime NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) ENGINE=innodb; +INSERT INTO t2 VALUES ('2003-08-21 00:00:00','b'); +explain SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_int_key,col_varchar_key col_int_key 4 NULL 3 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 6 test.t1.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where true group by `field2` order by `field1` +SELECT MIN(t2.col_datetime_key) AS field1, +t1.col_int_key AS field2 +FROM t1 +LEFT JOIN t2 force index (col_varchar_key) +ON t1.col_varchar_key = t2.col_varchar_key +GROUP BY field2 +ORDER BY field1; +field1 field2 +2003-08-21 00:00:00 4 +NULL 0 +DROP TABLE t1,t2; + +# BUG#12619510 "JCL: MORE ROWS AND DIFFERENT OUTPUT WITH JCL>=5" + +CREATE TABLE t1 ( +col_int_key int(11) NOT NULL, +col_datetime_key datetime NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,'2004-06-06 04:22:12','v'); +INSERT INTO t1 VALUES (0,'2005-11-13 01:12:31','s'); +INSERT INTO t1 VALUES (9,'2002-05-04 01:50:00','l'); +INSERT INTO t1 VALUES (3,'2004-10-27 10:28:45','y'); +INSERT INTO t1 VALUES (4,'2006-07-22 05:24:23','c'); +INSERT INTO t1 VALUES (2,'2002-05-16 21:34:03','i'); +INSERT INTO t1 VALUES (5,'2008-04-17 10:45:30','h'); +INSERT INTO t1 VALUES (3,'2009-04-21 02:58:02','q'); +INSERT INTO t1 VALUES (1,'2008-01-11 11:01:51','a'); +INSERT INTO t1 VALUES (3,'1900-01-01 00:00:00','v'); +INSERT INTO t1 VALUES (6,'2007-05-17 18:24:57','u'); +INSERT INTO t1 VALUES (7,'2007-08-07 00:00:00','s'); +INSERT INTO t1 VALUES (5,'2001-08-28 00:00:00','y'); +INSERT INTO t1 VALUES (1,'2004-04-16 00:27:28','z'); +INSERT INTO t1 VALUES (204,'2005-05-03 07:06:22','h'); +INSERT INTO t1 VALUES (224,'2009-03-11 17:09:50','p'); +INSERT INTO t1 VALUES (9,'2007-12-08 01:54:28','e'); +INSERT INTO t1 VALUES (5,'2009-07-28 18:19:54','i'); +INSERT INTO t1 VALUES (0,'2008-06-08 00:00:00','y'); +INSERT INTO t1 VALUES (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES +(1,'j'),(2,'v'),(3,'c'),(4,'m'),(5,'d'),(6,'d'),(7,'y'), +(8,'t'),(9,'d'),(10,'s'),(11,'r'),(12,'m'),(13,'b'),(14,'x'), +(15,'g'),(16,'p'),(17,'q'),(18,'w'),(19,'d'),(20,'e'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where true group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key` +SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4 +FROM t1 +RIGHT JOIN t2 ON t2.pk = t1.col_int_key +GROUP BY field1 , field4 +ORDER BY t1.col_datetime_key ; +field1 COUNT(DISTINCT t1.col_varchar_nokey) field4 +b 0 13 +c 4 3 +d 0 19 +d 1 6 +d 2 9 +d 3 5 +e 0 20 +g 0 15 +j 2 1 +m 0 12 +m 1 4 +p 0 16 +q 0 17 +r 0 11 +s 0 10 +t 0 8 +v 1 2 +w 0 18 +x 0 14 +y 2 7 +DROP TABLE t1,t2; + +# BUG#12619868 "JCL: MORE ROWS OF OUTPUT WHEN JCL>=5" + +CREATE TABLE t1 (col_varchar_key varchar(1)); +CREATE TABLE t2 ( +pk int(11) NOT NULL, +col_int_nokey int(11) NOT NULL, +col_int_key int(11) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (5,3,9); +INSERT INTO t2 VALUES (6,246,24); +INSERT INTO t2 VALUES (7,2,6); +INSERT INTO t2 VALUES (8,9,1); +INSERT INTO t2 VALUES (9,3,6); +INSERT INTO t2 VALUES (10,8,2); +INSERT INTO t2 VALUES (11,1,4); +INSERT INTO t2 VALUES (12,8,8); +INSERT INTO t2 VALUES (13,8,4); +INSERT INTO t2 VALUES (14,5,4); +INSERT INTO t2 VALUES (15,7,7); +INSERT INTO t2 VALUES (16,5,4); +INSERT INTO t2 VALUES (17,1,1); +INSERT INTO t2 VALUES (18,6,9); +INSERT INTO t2 VALUES (19,2,4); +INSERT INTO t2 VALUES (20,9,8); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze Error Table 'test.t3' doesn't exist +test.t3 analyze status Operation failed +test.t4 analyze Error Table 'test.t4' doesn't exist +test.t4 analyze status Operation failed +explain SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 16 100.00 Using temporary +2 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias2.col_int_nokey 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `field1`,`test`.`alias2`.`col_int_key` AS `field4` from `test`.`t2` `alias2` straight_join `test`.`t2` `alias3` left join `test`.`t1` on((0 <> `test`.`alias3`.`col_int_nokey`)) where (`test`.`alias3`.`pk` = `test`.`alias2`.`col_int_nokey`) group by `field1`,`field4` limit 15 +SELECT t1.col_varchar_key AS field1, alias2.col_int_key AS field4 +FROM t2 AS alias2 STRAIGHT_JOIN t2 AS alias3 ON alias3.pk = +alias2.col_int_nokey +left join t1 +ON alias3.col_int_nokey +GROUP BY field1, field4 +LIMIT 15; +field1 field4 +NULL 1 +NULL 2 +NULL 4 +NULL 7 +NULL 8 +NULL 9 +DROP TABLE t1,t2; + +# BUG#12722133 - JCL: JOIN QUERY GIVES DIFFERENT RESULTS AT +# JCL=6 ONLY [NULL VERSUS NULL+#INTS] + +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, k INTEGER, i INTEGER, KEY k(k)); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t1 VALUES (6,NULL,6),(0,1,11); +INSERT INTO t2 VALUES (1,NULL,NULL),(4,7,NULL); +INSERT INTO t3 VALUES (2,3,0),(3,4,4); +INSERT INTO t4 VALUES (1,9,-1),(4,7,NULL); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k 5 NULL 2 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.k 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `t2_pk`,`test`.`t4`.`pk` AS `t4_pk`,`test`.`t4`.`k` AS `t4_k`,`test`.`t4`.`i` AS `t4_i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`pk` = `test`.`t1`.`k`)) left join `test`.`t3` on((0 <> `test`.`t3`.`i`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where true +SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i +as t4_i FROM t1 +LEFT JOIN t2 ON t1.k = t2.pk +LEFT JOIN t3 ON t3.i +LEFT JOIN t4 ON t4.pk = t2.pk; +t2_pk t4_pk t4_k t4_i +1 1 9 -1 +NULL NULL NULL NULL +DROP TABLE t1, t2, t3, t4; + +# BUG#12827509 - BNL/BKA: SELECT LEFT/RIGHT JOIN QUERY GIVES +# DIFFERENT OUTPUT ON BNL=OFF+BKA=ON +# (Duplicate of BUG#12722133) + +CREATE TABLE t1 ( +col_int INTEGER +); +INSERT INTO t1 VALUES (3), (7), (2), (8), (6); +CREATE TABLE t2 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1,5), (2,8), (6,3), (8,7), (9,9); +CREATE TABLE t3 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (3,2), (4,3), (8,2); +CREATE TABLE t4 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (2,3), (6,1), (8,2); +ANALYZE TABLE t2, t3, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int` AS `col_int` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col_int` = `test`.`t1`.`col_int`)) left join `test`.`t3` on((`test`.`t3`.`pk` = `test`.`t2`.`pk`)) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where ((0 <> `test`.`t1`.`col_int`) or (0 <> `test`.`t3`.`col_int`)) +SELECT t4.col_int +FROM t1 +LEFT JOIN t2 ON t1.col_int = t2.col_int +LEFT JOIN t3 ON t2.pk = t3.pk +LEFT JOIN t4 ON t4.pk = t2.pk +WHERE t1.col_int OR t3.col_int; +col_int +1 +2 +3 +NULL +NULL +DROP TABLE t1, t2, t3, t4; +# +# Bug#12997905: VALGRIND: SYSCALL PARAM PWRITE64(BUF) +# POINTS TO UNINITIALISED BYTE(S) +# +CREATE TABLE t1 ( +col1 varchar(10), +col2 varchar(1024) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('a','a'); +CREATE TABLE t2 (i varchar(10)) ENGINE=innodb; +INSERT INTO t2 VALUES ('a'); +SELECT t1.col1 +FROM t1 JOIN t2 ON t1.col1 = t2.i +GROUP BY t1.col2; +col1 +a +DROP TABLE t1,t2; +# End of Bug#12997905 +# +# Bug 13596330 - EXTRA ROW ON SELECT WITH NESTED IN CLAUSE + IS +# NULL WHEN SEMIJOIN + BNL IS ON +# +CREATE TABLE t1 ( +col_int_nokey int +); +INSERT INTO t1 VALUES(-1),(-1); +CREATE TABLE t2 ( +col_int_nokey int, +col_datetime_nokey datetime NOT NULL, +col_varchar_key varchar(1), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t2 VALUES (9, '2002-08-25 20:35:06', 'e'), +(9, '2002-08-25 20:35:06', 'e'); +set @optimizer_switch_saved=@@session.optimizer_switch; +set @@session.optimizer_switch='semijoin=off'; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY parent1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY child1 NULL index_subquery col_varchar_key col_varchar_key 7 func 2 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.parent1.col_datetime_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`parent1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t2` `parent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`parent1`.`col_int_nokey`)) where (`test`.`parent1`.`col_varchar_key`,(((`test`.`parent1`.`col_varchar_key`) in t2 on col_varchar_key where ((`test`.`parent1`.`col_datetime_nokey` = TIMESTAMP'0000-00-00 00:00:00') and (`test`.`t1`.`col_int_nokey` is null))))) +SELECT parent1.col_varchar_key +FROM t2 AS parent1 LEFT JOIN t1 USING (col_int_nokey) +WHERE parent1.col_varchar_key IN +( SELECT col_varchar_key FROM t2 AS child1 +WHERE parent1.col_datetime_nokey IS NULL +AND t1.col_int_nokey IS NULL ) +; +col_varchar_key +set @@session.optimizer_switch=@optimizer_switch_saved; +DROP TABLE t1,t2; +# +# Bug#29435133 JOIN_CACHE::JOIN_RECORD() MAY LEAVE A TABLE IN HAS_NULL_ROW-STATE +# +CREATE TABLE t1 ( +col_varchar_10_unique varchar(10) +) ENGINE=innodb; +INSERT INTO t1 VALUES ('nthfyejwxd'); +INSERT INTO t1 VALUES ('drrqahbhai'); +CREATE TABLE t3 ( +col_int int(11) NOT NULL, +col_int_unique int(11) not null, +col_varchar_10 varchar(10) not null +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES(9, 4, ''); +CREATE TABLE t4 ( +col_int_unique int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES(3); +CREATE TABLE t2 ( +col_int int(11) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY table4s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY table3s NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY table2s NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`col_varchar_10_unique` AS `col_varchar_10_unique` from `test`.`t1` `table1` where ((`test`.`table1`.`col_varchar_10_unique`,(/* select#2 */ select straight_join `test`.`table3s`.`col_varchar_10` AS `field3` from `test`.`t4` `table4s` left join (`test`.`t3` `table3s` join `test`.`t2` `table2s`) on((`test`.`table3s`.`col_int_unique` = `test`.`table4s`.`col_int_unique`)) where (outer_field_is_not_null, (((`test`.`table1`.`col_varchar_10_unique`) <> `test`.`table3s`.`col_varchar_10`) or (`test`.`table3s`.`col_varchar_10` is null)), true) having (outer_field_is_not_null, (`test`.`table3s`.`col_varchar_10`), true)))) +SELECT * FROM t1 AS table1 +WHERE +table1.col_varchar_10_unique = ALL ( +SELECT STRAIGHT_JOIN table3s.col_varchar_10 AS field3 FROM +t4 AS table4s LEFT JOIN +(t3 AS table3s JOIN t2 AS table2s) +ON table3s.col_int_unique = table4s.col_int_unique); +col_varchar_10_unique +DROP TABLE t1,t2,t3,t4; +# +# t2 and t3 are const tables, which makes for a t1-t4 join on a constant, +# where the constant comes from a multi-equality. Verify that we get the expected +# query plan and don't crash (we don't care about the result). +# +CREATE TABLE t1 ( +pk integer NOT NULL, +a integer, +b integer, +PRIMARY KEY (pk), +KEY idx1 (b) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,5,5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM +t1 +LEFT JOIN t1 AS t2 ON t1.a = t2.pk +LEFT JOIN t1 AS t3 ON t2.pk = t3.pk +LEFT JOIN t1 AS t4 ON t3.b = t4.b +WHERE t2.pk = 1; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t1.a = 1) (cost=0.35 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Index lookup on t4 using idx1 (b='5') (cost=0.35 rows=1) + +DROP TABLE t1; +set optimizer_switch = default; diff --git a/mysql-test/r/join_nested.result-pq b/mysql-test/r/join_nested.result-pq new file mode 100644 index 000000000..4f6687409 --- /dev/null +++ b/mysql-test/r/join_nested.result-pq @@ -0,0 +1,2649 @@ +DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +CREATE TABLE t0 (a int, b int, c int); +CREATE TABLE t1 (a int, b int, c int); +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +CREATE TABLE t5 (a int, b int, c int); +CREATE TABLE t6 (a int, b int, c int); +CREATE TABLE t7 (a int, b int, c int); +CREATE TABLE t8 (a int, b int, c int); +CREATE TABLE t9 (a int, b int, c int); +INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0); +INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0); +CREATE TABLE t34 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int); +INSERT INTO t34 +SELECT t3.*, t4.* +FROM t3 CROSS JOIN t4; +CREATE TABLE t345 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int, +a5 int, b5 int, c5 int); +INSERT INTO t345 +SELECT t3.*, t4.*, t5.* +FROM t3 CROSS JOIN t4 CROSS JOIN t5; +CREATE TABLE t67 (a6 int, b6 int, c6 int, a7 int, b7 int, c7 int); +INSERT INTO t67 +SELECT t6.*, t7.* +FROM t6 CROSS JOIN t7; +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t4.a,t4.b +FROM t4; +a b +3 2 +4 2 +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` = 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3=1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3>1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t3,t4,t5; +a b a b a b +1 2 3 2 2 2 +1 2 3 2 3 1 +1 2 3 2 3 3 +1 2 4 2 2 2 +1 2 4 2 3 1 +1 2 4 2 3 3 +2 2 3 2 2 2 +2 2 3 2 3 1 +2 2 3 2 3 3 +2 2 4 2 2 2 +2 2 4 2 3 1 +2 2 4 2 3 3 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE t345.a3>1 OR t345.c3 IS NULL; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where (((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) and ((`test`.`t5`.`a` < 3) or (`test`.`t5`.`c` is null))) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE (t345.a3>1 OR t345.c3 IS NULL) AND +(t345.a5<3 OR t345.c5 IS NULL); +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +SELECT t6.a,t6.b +FROM t6; +a b +3 2 +6 2 +6 1 +SELECT t7.a,t7.b +FROM t7; +a b +1 1 +2 2 +SELECT t6.a,t6.b,t7.a,t7.b +FROM t6,t7; +a b a b +3 2 1 1 +3 2 2 2 +6 1 1 1 +6 1 2 2 +6 2 1 1 +6 2 2 2 +SELECT t8.a,t8.b +FROM t8; +a b +0 2 +1 2 +ANALYZE TABLE t6, t7, t8; +Table Op Msg_type Msg_text +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10))) where true +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +a b a b a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +"Standard compliant copy of above query" +SELECT t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10; +a6 b6 a7 b7 a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a < 1 OR t8.c IS NULL); +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 AND +(t8.a < 1 OR t8.c IS NULL); +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b a b a b a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +WHERE t2.a > 3 AND +(t6.a < 6 OR t6.c IS NULL); +a b a b a b a b a b a b a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +WHERE t2.a > 3 AND +(t67.a6 < 6 OR t67.c6 IS NULL); +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2); +a b a b a b a b a b a b a b a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t0.a,t0.b +FROM t0; +a b +1 1 +1 2 +2 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t9.a,t9.b +FROM t9; +a b +1 1 +1 2 +3 3 +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 +LEFT JOIN +t3 +ON t2.b=t3.b; +a b a b +3 3 NULL NULL +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 +CROSS JOIN t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 CROSS JOIN +( +t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +) +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +EXPLAIN +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2) +CREATE INDEX idx_b ON t2(b); +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = 1))) where true +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3 CROSS JOIN t4) +LEFT JOIN +(t1 CROSS JOIN t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t4(b); +CREATE INDEX idx_b ON t5(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t8(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t1(b); +CREATE INDEX idx_a ON t0(a); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL idx_b NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t0 NULL ref idx_a idx_a 5 const 2 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t1`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t0`.`b` = `test`.`t1`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN +t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +CROSS JOIN t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN (t3) ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +ALTER TABLE t3 +CHANGE COLUMN a a1 int, +CHANGE COLUMN c c1 int; +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 NATURAL LEFT JOIN t3 +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +DROP TABLE t34, t345, t67; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DELETE FROM t2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1(a int, key (a)); +CREATE TABLE t2(b int, key (b)); +CREATE TABLE t3(c int, key (c)); +INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 0 0 +0 1 1 +0 2 2 +1 0 0 +1 1 1 +1 2 2 +10 0 0 +10 1 1 +10 2 2 +11 0 0 +11 1 1 +11 2 2 +12 0 0 +12 1 1 +12 2 2 +13 0 0 +13 1 1 +13 2 2 +14 0 0 +14 1 1 +14 2 2 +15 0 0 +15 1 1 +15 2 2 +16 0 0 +16 1 1 +16 2 2 +17 0 0 +17 1 1 +17 2 2 +18 0 0 +18 1 1 +18 2 2 +19 0 0 +19 1 1 +19 2 2 +2 0 0 +2 1 1 +2 2 2 +3 0 0 +3 1 1 +3 2 2 +4 0 0 +4 1 1 +4 2 2 +5 0 0 +5 1 1 +5 2 2 +6 0 0 +6 1 1 +6 2 2 +7 0 0 +7 1 1 +7 2 2 +8 0 0 +8 1 1 +8 2 2 +9 0 0 +9 1 1 +9 2 2 +NULL 0 0 +NULL 1 1 +NULL 2 2 +DELETE FROM t3; +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 NULL NULL +1 NULL NULL +10 NULL NULL +11 NULL NULL +12 NULL NULL +13 NULL NULL +14 NULL NULL +15 NULL NULL +16 NULL NULL +17 NULL NULL +18 NULL NULL +19 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 NULL NULL +7 NULL NULL +8 NULL NULL +9 NULL NULL +NULL NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +CREATE TABLE t3 (c31 int); +INSERT INTO t1 VALUES (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +c11 c21 +4 NULL +5 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +c11 c21 c31 +4 NULL NULL +5 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21`,`test`.`t3`.`c31` AS `c31` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`c31` = `test`.`t2`.`c21`))) on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (23, 2340), (26, 9900); +CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr'); +create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (3,23), (6,26); +CREATE TABLE t4 (groupid int(12)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6); +SELECT * FROM +(SELECT DISTINCT gl.groupid, gp.price +FROM t4 gl +LEFT JOIN +(t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp ON p.goods = gp.goods) +ON gl.groupid = g.groupid and p.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +CREATE VIEW v1 AS +SELECT g.groupid groupid, p.goods goods, +p.name name, p.shop shop, +gp.price price +FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp on p.goods = gp.goods; +CREATE VIEW v2 AS +SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr'; +SELECT * FROM v2; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +SELECT * FROM +(SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a int); +CREATE TABLE t2(b int); +CREATE TABLE t3(c int, d int); +CREATE TABLE t4(d int); +CREATE TABLE t5(e int, f int); +CREATE TABLE t6(f int); +CREATE VIEW v1 AS +SELECT e FROM t5 JOIN t6 ON t5.e=t6.f; +CREATE VIEW v2 AS +SELECT e FROM t5 NATURAL JOIN t6; +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v1.x' in 'field list' +SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v2.x' in 'field list' +DROP VIEW v1, v2; +DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1 (id1 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +create table t2 (id2 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values (1),(2),(3),(4); +create table t3 (id3 char(16) not null); +insert into t3 values ('100'); +create table t4 (id2 int(11) not null, id3 char(16)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 (id1 int(11) not null, key (id1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t5 values (1),(2),(1); +create view v1 as +select t4.id3 from t4 join t2 on t4.id2 = t2.id2; +select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3); +id1 +1 +2 +drop view v1; +drop table t1, t2, t3, t4, t5; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3); +create table t1(a int); +insert into t1 select A.a + 10*(B.a) from t0 A, t0 B; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2), (3,3); +create table t3(a int, b int, filler char(200), key(a)); +insert into t3 select a,a,'filler' from t1; +insert into t3 select a,a,'filler' from t1; +create table t4 like t3; +insert into t4 select * from t3; +insert into t4 select * from t3; +create table t5 like t4; +insert into t5 select * from t4; +insert into t5 select * from t4; +create table t6 like t5; +insert into t6 select * from t5; +insert into t6 select * from t5; +create table t7 like t6; +insert into t7 select * from t6; +insert into t7 select * from t6; +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +explain select * from t4 join +t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 NULL +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 NULL +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t4` join `test`.`t2` left join (`test`.`t3` join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where (`test`.`t4`.`a` <=> `test`.`t3`.`b`) +explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b +join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using index condition +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 NULL +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 NULL +2 SIMPLE t5 NULL ref a a 5 test.t2.b X 100.00 NULL +2 SIMPLE t7 NULL ref a a 5 test.t5.b X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t7`.`filler` AS `filler` from `test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t2` left join (`test`.`t5` join `test`.`t7`) on(((`test`.`t7`.`a` = `test`.`t5`.`b`) and (`test`.`t5`.`a` = `test`.`t2`.`b`))) where (`test`.`t3`.`a` <=> `test`.`t2`.`b`) +explain select * from t2 left join +(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b +join t5 on t5.a=t3.b) on t3.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 NULL +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 NULL +2 SIMPLE t4 NULL ref a a 5 test.t5.a X 100.00 Using where +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t2` left join (`test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where true +drop table t0, t1, t2, t3, t4, t5, t6, t7; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(100), key(a)); +insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B; +create table t3 like t2; +insert into t3 select * from t2; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t1 left join +(t2 left join t3 on (t2.a = t3.a)) +on (t1.a = t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t2 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t3 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t4 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t5 (id1 int PRIMARY KEY, id2 int); +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +PREPARE stmt FROM +"SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa + FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 + LEFT OUTER JOIN + (t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) + ON t3.id2 IS NOT NULL + WHERE t1.id1=2"; +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +INSERT INTO t1 VALUES (1,1), (2,1), (3,2); +INSERT INTO t2 VALUES (2,1), (3,2), (4,3); +INSERT INTO t3 VALUES (1,1), (3,2), (2,NULL); +INSERT INTO t4 VALUES (1,1), (2,1), (3,3); +INSERT INTO t5 VALUES (1,1), (2,2), (3,3), (4,3); +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +2 1 +2 1 +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +id int NOT NULL PRIMARY KEY, +ct int DEFAULT NULL, +pc int DEFAULT NULL, +INDEX idx_ct (ct), +INDEX idx_pc (pc) +); +INSERT INTO t1 VALUES +(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +sr int NOT NULL, +nm varchar(255) NOT NULL, +INDEX idx_sr (sr) +); +INSERT INTO t2 VALUES +(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand'); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +ct int NOT NULL, +ln int NOT NULL, +INDEX idx_ct (ct), +INDEX idx_ln (ln) +); +CREATE TABLE t4 ( +id int NOT NULL PRIMARY KEY, +nm varchar(255) NOT NULL +); +INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique'); +SELECT t1.* +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +WHERE t1.id='5'; +id ct pc +5 NULL NULL +SELECT t1.*, t4.nm +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +LEFT JOIN t4 ON t2.sr=t4.id +WHERE t1.id='5'; +id ct pc nm +5 NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, c INT); +CREATE TABLE t4 (a INT, c INT); +CREATE TABLE t5 (a INT, c INT); +SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t2 VALUES (1,1); +INSERT INTO t3 VALUES (1,1); +SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +carrier char(2) default NULL, +id int NOT NULL auto_increment PRIMARY KEY +) CHARSET utf8mb4; +INSERT INTO t1 VALUES +('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874), +('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484), +('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594), +('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424), +('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464), +('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864), +('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014), +('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534), +('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974); +CREATE TABLE t2 ( +scan_date date default NULL, +package_id int default NULL, +INDEX scan_date(scan_date), +INDEX package_id(package_id) +); +INSERT INTO t2 VALUES +('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124), +('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644), +('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774), +('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004), +('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884), +('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144), +('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414), +('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614), +('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614), +('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094), +('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804), +('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344), +('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594), +('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914), +('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904); +CREATE TABLE t3 ( +package_id int default NULL, +INDEX package_id(package_id) +); +INSERT INTO t3 VALUES +(231058294),(231058324),(231058354),(231058384),(231058414),(231058444), +(231058474),(231058504),(231058534),(231058564),(231058594),(231058624), +(231058684),(231058744),(231058804),(231058864),(231058924),(231058954), +(231059014),(231059074),(231059104),(231059134),(231059164),(231059194), +(231059224),(231059254),(231059284),(231059314),(231059344),(231059374), +(231059404),(231059434),(231059464),(231059494),(231059524),(231059554), +(231059584),(231059614),(231059644),(231059674),(231059704),(231059734), +(231059764),(231059794),(231059824),(231059854),(231059884),(231059914), +(231059944),(231059974),(231060004),(231060034),(231060064),(231060094), +(231060124),(231060154),(231060184),(231060214),(231060244),(231060274), +(231060304),(231060334),(231060364),(231060394),(231060424),(231060454), +(231060484),(231060514),(231060544),(231060574),(231060604),(231060634), +(231060664),(231060694),(231060724),(231060754),(231060784),(231060814), +(231060844),(231060874),(231060904),(231060934),(231060964),(231060994), +(231061024),(231061054),(231061084),(231061144),(231061174),(231061204), +(231061234),(231061294),(231061354),(231061384),(231061414),(231061474), +(231061564),(231061594),(231061624),(231061684),(231061714),(231061774), +(231061804),(231061894),(231061984),(231062074),(231062134),(231062224), +(231062254),(231062314),(231062374),(231062434),(231062494),(231062554), +(231062584),(231062614),(231062644),(231062704),(231062734),(231062794), +(231062854),(231062884),(231062944),(231063004),(231063034),(231063064), +(231063124),(231063154),(231063184),(231063214),(231063274),(231063334), +(231063394),(231063424),(231063454),(231063514),(231063574),(231063664); +CREATE TABLE t4 ( +carrier char(2) NOT NULL default '' PRIMARY KEY, +id int(11) default NULL, +INDEX id(id) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES +('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510); +CREATE TABLE t5 ( +carrier_id int default NULL, +INDEX carrier_id(carrier_id) +); +INSERT INTO t5 VALUES +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456), +(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456), +(456),(486),(1081),(1111),(1111),(1111),(1111),(1510); +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +SELECT COUNT(*) +FROM((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id); +COUNT(*) +6 +EXPLAIN +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 45 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index package_id package_id 5 NULL 45 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY,id PRIMARY 8 test.t1.carrier 1 100.00 NULL +2 SIMPLE t5 NULL ref carrier_id carrier_id 5 test.t4.id 22 100.00 Using index +2 SIMPLE t3 NULL ref package_id package_id 5 test.t2.package_id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` join `test`.`t3` left join (`test`.`t5` join `test`.`t4`) on(((`test`.`t5`.`carrier_id` = `test`.`t4`.`id`) and (`test`.`t4`.`carrier` = `test`.`t1`.`carrier`))) where ((`test`.`t1`.`id` = `test`.`t2`.`package_id`) and (`test`.`t3`.`package_id` = `test`.`t2`.`package_id`)) +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +COUNT(*) +6 +DROP TABLE t1,t2,t3,t4,t5; +End of 5.0 tests +# +# Bug#24909223: EXCESSIVE MEMORY USAGE BY QUERY +# +CREATE TABLE t ( +a INT, +b CHAR(255), +c CHAR(255), +d INT, +e INT, +PRIMARY KEY (e), +KEY (d) +) ENGINE=InnoDB; +INSERT INTO t VALUES +(1, '14effca2', 'cffa3819', 98927, 8767), +(1, '2f7cbd33', '421aff88', 87613, 70956), +(1, '5c44507d', '05fd27d3', 36002, 5146), +(1, '6542ee43', 'c09ee30f', 3673, 91467), +(1, '786737dd', '6ac95ccb', 46890, 62953), +(1, '8929d195', '64102e63', 50531, 9712), +(1, '8cc0c106', '17283316', 16399, 26119), +(1, '8f3063de', 'ce5d0f35', 21769, 76667), +(1, 'c32c9202', 'c9525fe8', 12704, 43998), +(1, 'c5567e1c', 'bc2e97e6', 85805, 84174), +(1, 'c7acb4d4', '6d67fea7', 58347, 51235), +(1, 'dbd66341', '03b59a03', 46577, 52495), +(1, 'f8e0354e', '41a6e523', 36055, 32646), +(1, 'fb66b513', '10f3de43', 41297, 74334), +(1, 'ffec6d1b', '2fca4073', 12896, 95807), +(1, 'aa3fcff8', 'f4981ed8', 99211, 18778); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL d NULL NULL NULL 16 33.33 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `c` from `test`.`t` `a` join `test`.`t` `b` join `test`.`t` `b` join `test`.`t` `b` where ((`test`.`a`.`a` >= `test`.`b`.`d`) and (`test`.`a`.`a` >= `test`.`b`.`a`) and (`test`.`a`.`b` > `test`.`b`.`b`)) +TRUNCATE TABLE performance_schema.memory_summary_by_thread_by_event_name; +SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +c +SELECT * FROM performance_schema.memory_summary_by_thread_by_event_name +WHERE event_name = 'memory/sql/thd::main_mem_root' +AND thread_id = ps_thread_id(connection_id()) +AND sum_number_of_bytes_alloc > 1000000 +DROP TABLE t; diff --git a/mysql-test/r/join_nested_bka.result-pq b/mysql-test/r/join_nested_bka.result-pq new file mode 100644 index 000000000..b671bf1d8 --- /dev/null +++ b/mysql-test/r/join_nested_bka.result-pq @@ -0,0 +1,2777 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +CREATE TABLE t0 (a int, b int, c int); +CREATE TABLE t1 (a int, b int, c int); +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +CREATE TABLE t5 (a int, b int, c int); +CREATE TABLE t6 (a int, b int, c int); +CREATE TABLE t7 (a int, b int, c int); +CREATE TABLE t8 (a int, b int, c int); +CREATE TABLE t9 (a int, b int, c int); +INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0); +INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0); +CREATE TABLE t34 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int); +INSERT INTO t34 +SELECT t3.*, t4.* +FROM t3 CROSS JOIN t4; +CREATE TABLE t345 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int, +a5 int, b5 int, c5 int); +INSERT INTO t345 +SELECT t3.*, t4.*, t5.* +FROM t3 CROSS JOIN t4 CROSS JOIN t5; +CREATE TABLE t67 (a6 int, b6 int, c6 int, a7 int, b7 int, c7 int); +INSERT INTO t67 +SELECT t6.*, t7.* +FROM t6 CROSS JOIN t7; +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t4.a,t4.b +FROM t4; +a b +3 2 +4 2 +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` = 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3=1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3>1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t3,t4,t5; +a b a b a b +1 2 3 2 2 2 +1 2 3 2 3 1 +1 2 3 2 3 3 +1 2 4 2 2 2 +1 2 4 2 3 1 +1 2 4 2 3 3 +2 2 3 2 2 2 +2 2 3 2 3 1 +2 2 3 2 3 3 +2 2 4 2 2 2 +2 2 4 2 3 1 +2 2 4 2 3 3 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE t345.a3>1 OR t345.c3 IS NULL; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where (((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) and ((`test`.`t5`.`a` < 3) or (`test`.`t5`.`c` is null))) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE (t345.a3>1 OR t345.c3 IS NULL) AND +(t345.a5<3 OR t345.c5 IS NULL); +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +SELECT t6.a,t6.b +FROM t6; +a b +3 2 +6 2 +6 1 +SELECT t7.a,t7.b +FROM t7; +a b +1 1 +2 2 +SELECT t6.a,t6.b,t7.a,t7.b +FROM t6,t7; +a b a b +3 2 1 1 +3 2 2 2 +6 1 1 1 +6 1 2 2 +6 2 1 1 +6 2 2 2 +SELECT t8.a,t8.b +FROM t8; +a b +0 2 +1 2 +ANALYZE TABLE t6, t7, t8; +Table Op Msg_type Msg_text +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10))) where true +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +a b a b a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +"Standard compliant copy of above query" +SELECT t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10; +a6 b6 a7 b7 a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a < 1 OR t8.c IS NULL); +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 AND +(t8.a < 1 OR t8.c IS NULL); +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b a b a b a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +WHERE t2.a > 3 AND +(t6.a < 6 OR t6.c IS NULL); +a b a b a b a b a b a b a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +WHERE t2.a > 3 AND +(t67.a6 < 6 OR t67.c6 IS NULL); +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2); +a b a b a b a b a b a b a b a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t0.a,t0.b +FROM t0; +a b +1 1 +1 2 +2 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t9.a,t9.b +FROM t9; +a b +1 1 +1 2 +3 3 +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 +LEFT JOIN +t3 +ON t2.b=t3.b; +a b a b +3 3 NULL NULL +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 +CROSS JOIN t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 CROSS JOIN +( +t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +) +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +EXPLAIN +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2) +CREATE INDEX idx_b ON t2(b); +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = 1))) where true +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3 CROSS JOIN t4) +LEFT JOIN +(t1 CROSS JOIN t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t4(b); +CREATE INDEX idx_b ON t5(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t8(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t1(b); +CREATE INDEX idx_a ON t0(a); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL idx_b NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SIMPLE t0 NULL ref idx_a idx_a 5 const 2 33.33 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where; Using join buffer (hash join) +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t1`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t0`.`b` = `test`.`t1`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN +t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +CROSS JOIN t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN (t3) ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +ALTER TABLE t3 +CHANGE COLUMN a a1 int, +CHANGE COLUMN c c1 int; +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 NATURAL LEFT JOIN t3 +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +DROP TABLE t34, t345, t67; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DELETE FROM t2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1(a int, key (a)); +CREATE TABLE t2(b int, key (b)); +CREATE TABLE t3(c int, key (c)); +INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 0 0 +0 1 1 +0 2 2 +1 0 0 +1 1 1 +1 2 2 +10 0 0 +10 1 1 +10 2 2 +11 0 0 +11 1 1 +11 2 2 +12 0 0 +12 1 1 +12 2 2 +13 0 0 +13 1 1 +13 2 2 +14 0 0 +14 1 1 +14 2 2 +15 0 0 +15 1 1 +15 2 2 +16 0 0 +16 1 1 +16 2 2 +17 0 0 +17 1 1 +17 2 2 +18 0 0 +18 1 1 +18 2 2 +19 0 0 +19 1 1 +19 2 2 +2 0 0 +2 1 1 +2 2 2 +3 0 0 +3 1 1 +3 2 2 +4 0 0 +4 1 1 +4 2 2 +5 0 0 +5 1 1 +5 2 2 +6 0 0 +6 1 1 +6 2 2 +7 0 0 +7 1 1 +7 2 2 +8 0 0 +8 1 1 +8 2 2 +9 0 0 +9 1 1 +9 2 2 +NULL 0 0 +NULL 1 1 +NULL 2 2 +DELETE FROM t3; +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 NULL NULL +1 NULL NULL +10 NULL NULL +11 NULL NULL +12 NULL NULL +13 NULL NULL +14 NULL NULL +15 NULL NULL +16 NULL NULL +17 NULL NULL +18 NULL NULL +19 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 NULL NULL +7 NULL NULL +8 NULL NULL +9 NULL NULL +NULL NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +CREATE TABLE t3 (c31 int); +INSERT INTO t1 VALUES (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +c11 c21 +4 NULL +5 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +c11 c21 c31 +4 NULL NULL +5 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21`,`test`.`t3`.`c31` AS `c31` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`c31` = `test`.`t2`.`c21`))) on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (23, 2340), (26, 9900); +CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr'); +create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (3,23), (6,26); +CREATE TABLE t4 (groupid int(12)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6); +SELECT * FROM +(SELECT DISTINCT gl.groupid, gp.price +FROM t4 gl +LEFT JOIN +(t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp ON p.goods = gp.goods) +ON gl.groupid = g.groupid and p.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +CREATE VIEW v1 AS +SELECT g.groupid groupid, p.goods goods, +p.name name, p.shop shop, +gp.price price +FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp on p.goods = gp.goods; +CREATE VIEW v2 AS +SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr'; +SELECT * FROM v2; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +SELECT * FROM +(SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a int); +CREATE TABLE t2(b int); +CREATE TABLE t3(c int, d int); +CREATE TABLE t4(d int); +CREATE TABLE t5(e int, f int); +CREATE TABLE t6(f int); +CREATE VIEW v1 AS +SELECT e FROM t5 JOIN t6 ON t5.e=t6.f; +CREATE VIEW v2 AS +SELECT e FROM t5 NATURAL JOIN t6; +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v1.x' in 'field list' +SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v2.x' in 'field list' +DROP VIEW v1, v2; +DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1 (id1 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +create table t2 (id2 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values (1),(2),(3),(4); +create table t3 (id3 char(16) not null); +insert into t3 values ('100'); +create table t4 (id2 int(11) not null, id3 char(16)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 (id1 int(11) not null, key (id1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t5 values (1),(2),(1); +create view v1 as +select t4.id3 from t4 join t2 on t4.id2 = t2.id2; +select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3); +id1 +1 +2 +drop view v1; +drop table t1, t2, t3, t4, t5; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3); +create table t1(a int); +insert into t1 select A.a + 10*(B.a) from t0 A, t0 B; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2), (3,3); +create table t3(a int, b int, filler char(200), key(a)); +insert into t3 select a,a,'filler' from t1; +insert into t3 select a,a,'filler' from t1; +create table t4 like t3; +insert into t4 select * from t3; +insert into t4 select * from t3; +create table t5 like t4; +insert into t5 select * from t4; +insert into t5 select * from t4; +create table t6 like t5; +insert into t6 select * from t5; +insert into t6 select * from t5; +create table t7 like t6; +insert into t7 select * from t6; +insert into t7 select * from t6; +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +explain select * from t4 join +t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t4` join `test`.`t2` left join (`test`.`t3` join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where (`test`.`t4`.`a` <=> `test`.`t3`.`b`) +explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b +join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t7 NULL ref a a 5 test.t5.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t7`.`filler` AS `filler` from `test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t2` left join (`test`.`t5` join `test`.`t7`) on(((`test`.`t7`.`a` = `test`.`t5`.`b`) and (`test`.`t5`.`a` = `test`.`t2`.`b`))) where (`test`.`t3`.`a` <=> `test`.`t2`.`b`) +explain select * from t2 left join +(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b +join t5 on t5.a=t3.b) on t3.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t5.a X 100.00 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t2` left join (`test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where true +drop table t0, t1, t2, t3, t4, t5, t6, t7; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(100), key(a)); +insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B; +create table t3 like t2; +insert into t3 select * from t2; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t1 left join +(t2 left join t3 on (t2.a = t3.a)) +on (t1.a = t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t2 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t3 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t4 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t5 (id1 int PRIMARY KEY, id2 int); +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +PREPARE stmt FROM +"SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa + FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 + LEFT OUTER JOIN + (t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) + ON t3.id2 IS NOT NULL + WHERE t1.id1=2"; +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +INSERT INTO t1 VALUES (1,1), (2,1), (3,2); +INSERT INTO t2 VALUES (2,1), (3,2), (4,3); +INSERT INTO t3 VALUES (1,1), (3,2), (2,NULL); +INSERT INTO t4 VALUES (1,1), (2,1), (3,3); +INSERT INTO t5 VALUES (1,1), (2,2), (3,3), (4,3); +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +2 1 +2 1 +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +id int NOT NULL PRIMARY KEY, +ct int DEFAULT NULL, +pc int DEFAULT NULL, +INDEX idx_ct (ct), +INDEX idx_pc (pc) +); +INSERT INTO t1 VALUES +(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +sr int NOT NULL, +nm varchar(255) NOT NULL, +INDEX idx_sr (sr) +); +INSERT INTO t2 VALUES +(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand'); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +ct int NOT NULL, +ln int NOT NULL, +INDEX idx_ct (ct), +INDEX idx_ln (ln) +); +CREATE TABLE t4 ( +id int NOT NULL PRIMARY KEY, +nm varchar(255) NOT NULL +); +INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique'); +SELECT t1.* +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +WHERE t1.id='5'; +id ct pc +5 NULL NULL +SELECT t1.*, t4.nm +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +LEFT JOIN t4 ON t2.sr=t4.id +WHERE t1.id='5'; +id ct pc nm +5 NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, c INT); +CREATE TABLE t4 (a INT, c INT); +CREATE TABLE t5 (a INT, c INT); +SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t2 VALUES (1,1); +INSERT INTO t3 VALUES (1,1); +SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +carrier char(2) default NULL, +id int NOT NULL auto_increment PRIMARY KEY +) CHARSET utf8mb4; +INSERT INTO t1 VALUES +('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874), +('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484), +('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594), +('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424), +('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464), +('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864), +('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014), +('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534), +('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974); +CREATE TABLE t2 ( +scan_date date default NULL, +package_id int default NULL, +INDEX scan_date(scan_date), +INDEX package_id(package_id) +); +INSERT INTO t2 VALUES +('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124), +('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644), +('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774), +('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004), +('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884), +('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144), +('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414), +('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614), +('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614), +('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094), +('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804), +('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344), +('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594), +('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914), +('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904); +CREATE TABLE t3 ( +package_id int default NULL, +INDEX package_id(package_id) +); +INSERT INTO t3 VALUES +(231058294),(231058324),(231058354),(231058384),(231058414),(231058444), +(231058474),(231058504),(231058534),(231058564),(231058594),(231058624), +(231058684),(231058744),(231058804),(231058864),(231058924),(231058954), +(231059014),(231059074),(231059104),(231059134),(231059164),(231059194), +(231059224),(231059254),(231059284),(231059314),(231059344),(231059374), +(231059404),(231059434),(231059464),(231059494),(231059524),(231059554), +(231059584),(231059614),(231059644),(231059674),(231059704),(231059734), +(231059764),(231059794),(231059824),(231059854),(231059884),(231059914), +(231059944),(231059974),(231060004),(231060034),(231060064),(231060094), +(231060124),(231060154),(231060184),(231060214),(231060244),(231060274), +(231060304),(231060334),(231060364),(231060394),(231060424),(231060454), +(231060484),(231060514),(231060544),(231060574),(231060604),(231060634), +(231060664),(231060694),(231060724),(231060754),(231060784),(231060814), +(231060844),(231060874),(231060904),(231060934),(231060964),(231060994), +(231061024),(231061054),(231061084),(231061144),(231061174),(231061204), +(231061234),(231061294),(231061354),(231061384),(231061414),(231061474), +(231061564),(231061594),(231061624),(231061684),(231061714),(231061774), +(231061804),(231061894),(231061984),(231062074),(231062134),(231062224), +(231062254),(231062314),(231062374),(231062434),(231062494),(231062554), +(231062584),(231062614),(231062644),(231062704),(231062734),(231062794), +(231062854),(231062884),(231062944),(231063004),(231063034),(231063064), +(231063124),(231063154),(231063184),(231063214),(231063274),(231063334), +(231063394),(231063424),(231063454),(231063514),(231063574),(231063664); +CREATE TABLE t4 ( +carrier char(2) NOT NULL default '' PRIMARY KEY, +id int(11) default NULL, +INDEX id(id) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES +('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510); +CREATE TABLE t5 ( +carrier_id int default NULL, +INDEX carrier_id(carrier_id) +); +INSERT INTO t5 VALUES +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456), +(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456), +(456),(486),(1081),(1111),(1111),(1111),(1111),(1510); +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +SELECT COUNT(*) +FROM((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id); +COUNT(*) +6 +EXPLAIN +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 45 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index package_id package_id 5 NULL 45 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY,id PRIMARY 8 test.t1.carrier 1 100.00 NULL +2 SIMPLE t5 NULL ref carrier_id carrier_id 5 test.t4.id 22 100.00 Using index +2 SIMPLE t3 NULL ref package_id package_id 5 test.t2.package_id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` join `test`.`t3` left join (`test`.`t5` join `test`.`t4`) on(((`test`.`t5`.`carrier_id` = `test`.`t4`.`id`) and (`test`.`t4`.`carrier` = `test`.`t1`.`carrier`))) where ((`test`.`t1`.`id` = `test`.`t2`.`package_id`) and (`test`.`t3`.`package_id` = `test`.`t2`.`package_id`)) +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +COUNT(*) +6 +DROP TABLE t1,t2,t3,t4,t5; +End of 5.0 tests +# +# Bug#24909223: EXCESSIVE MEMORY USAGE BY QUERY +# +CREATE TABLE t ( +a INT, +b CHAR(255), +c CHAR(255), +d INT, +e INT, +PRIMARY KEY (e), +KEY (d) +) ENGINE=InnoDB; +INSERT INTO t VALUES +(1, '14effca2', 'cffa3819', 98927, 8767), +(1, '2f7cbd33', '421aff88', 87613, 70956), +(1, '5c44507d', '05fd27d3', 36002, 5146), +(1, '6542ee43', 'c09ee30f', 3673, 91467), +(1, '786737dd', '6ac95ccb', 46890, 62953), +(1, '8929d195', '64102e63', 50531, 9712), +(1, '8cc0c106', '17283316', 16399, 26119), +(1, '8f3063de', 'ce5d0f35', 21769, 76667), +(1, 'c32c9202', 'c9525fe8', 12704, 43998), +(1, 'c5567e1c', 'bc2e97e6', 85805, 84174), +(1, 'c7acb4d4', '6d67fea7', 58347, 51235), +(1, 'dbd66341', '03b59a03', 46577, 52495), +(1, 'f8e0354e', '41a6e523', 36055, 32646), +(1, 'fb66b513', '10f3de43', 41297, 74334), +(1, 'ffec6d1b', '2fca4073', 12896, 95807), +(1, 'aa3fcff8', 'f4981ed8', 99211, 18778); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where; Using join buffer (hash join) +2 SIMPLE b NULL ALL d NULL NULL NULL 16 33.33 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `c` from `test`.`t` `a` join `test`.`t` `b` join `test`.`t` `b` join `test`.`t` `b` where ((`test`.`a`.`a` >= `test`.`b`.`d`) and (`test`.`a`.`a` >= `test`.`b`.`a`) and (`test`.`a`.`b` > `test`.`b`.`b`)) +TRUNCATE TABLE performance_schema.memory_summary_by_thread_by_event_name; +SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +c +SELECT * FROM performance_schema.memory_summary_by_thread_by_event_name +WHERE event_name = 'memory/sql/thd::main_mem_root' +AND thread_id = ps_thread_id(connection_id()) +AND sum_number_of_bytes_alloc > 1000000 +DROP TABLE t; +CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t7 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t8 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +INSERT INTO t5 VALUES (1,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (1,2,0), (3,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 3 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index b_i b_i 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t8 NULL ALL b_i NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and ((`test`.`t8`.`a` > 0) or (`test`.`t8`.`c` is null)))) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +a b a b a b a b +1 1 1 2 1 1 NULL NULL +1 1 3 2 1 1 NULL NULL +2 2 1 2 2 2 1 2 +2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL NULL NULL +DELETE FROM t5; +DELETE FROM t6; +DELETE FROM t7; +DELETE FROM t8; +INSERT INTO t5 VALUES (1,3,0), (3,2,0); +INSERT INTO t6 VALUES (3,3,0); +INSERT INTO t7 VALUES (1,2,0); +INSERT INTO t8 VALUES (1,1,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 const 1 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`b` = 2)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t8` join `test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1))) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +DROP TABLE t5,t6,t7,t8; +set optimizer_switch=default; diff --git a/mysql-test/r/join_nested_bka_nobnl.result-pq b/mysql-test/r/join_nested_bka_nobnl.result-pq new file mode 100644 index 000000000..0e8024075 --- /dev/null +++ b/mysql-test/r/join_nested_bka_nobnl.result-pq @@ -0,0 +1,2777 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +CREATE TABLE t0 (a int, b int, c int); +CREATE TABLE t1 (a int, b int, c int); +CREATE TABLE t2 (a int, b int, c int); +CREATE TABLE t3 (a int, b int, c int); +CREATE TABLE t4 (a int, b int, c int); +CREATE TABLE t5 (a int, b int, c int); +CREATE TABLE t6 (a int, b int, c int); +CREATE TABLE t7 (a int, b int, c int); +CREATE TABLE t8 (a int, b int, c int); +CREATE TABLE t9 (a int, b int, c int); +INSERT INTO t0 VALUES (1,1,0), (1,2,0), (2,2,0); +INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0); +INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0); +INSERT INTO t3 VALUES (1,2,0), (2,2,0); +INSERT INTO t4 VALUES (3,2,0), (4,2,0); +INSERT INTO t5 VALUES (3,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (3,2,0), (6,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t9 VALUES (1,1,0), (1,2,0), (3,3,0); +CREATE TABLE t34 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int); +INSERT INTO t34 +SELECT t3.*, t4.* +FROM t3 CROSS JOIN t4; +CREATE TABLE t345 (a3 int, b3 int, c3 int, a4 int, b4 int, c4 int, +a5 int, b5 int, c5 int); +INSERT INTO t345 +SELECT t3.*, t4.*, t5.* +FROM t3 CROSS JOIN t4 CROSS JOIN t5; +CREATE TABLE t67 (a6 int, b6 int, c6 int, a7 int, b7 int, c7 int); +INSERT INTO t67 +SELECT t6.*, t7.* +FROM t6 CROSS JOIN t7; +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t4.a,t4.b +FROM t4; +a b +3 2 +4 2 +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` = 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a=1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3=1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t2.b=t34.b4 +WHERE t34.a3>1 OR t34.c3 IS NULL; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 2 2 3 2 +4 2 2 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t3,t4,t5; +a b a b a b +1 2 3 2 2 2 +1 2 3 2 3 1 +1 2 3 2 3 3 +1 2 4 2 2 2 +1 2 4 2 3 1 +1 2 4 2 3 3 +2 2 3 2 2 2 +2 2 3 2 3 1 +2 2 3 2 3 3 +2 2 4 2 2 2 +2 2 4 2 3 1 +2 2 4 2 3 3 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 +4 2 1 2 3 2 3 1 +4 2 1 2 3 2 3 3 +4 2 1 2 4 2 2 2 +4 2 1 2 4 2 3 1 +4 2 1 2 4 2 3 3 +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where ((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE t3.a>1 OR t3.c IS NULL; +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE t345.a3>1 OR t345.c3 IS NULL; +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 3 2 3 1 +4 2 2 2 3 2 3 3 +4 2 2 2 4 2 2 2 +4 2 2 2 4 2 3 1 +4 2 2 2 4 2 3 3 +5 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on((`test`.`t4`.`b` = `test`.`t2`.`b`)) where (((`test`.`t3`.`a` > 1) or (`test`.`t3`.`c` is null)) and ((`test`.`t5`.`a` < 3) or (`test`.`t5`.`c` is null))) +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,t5.a,t5.b +FROM t2 +LEFT JOIN +(t3, t4, t5) +ON t2.b=t4.b +WHERE (t3.a>1 OR t3.c IS NULL) AND +(t5.a<3 OR t5.c IS NULL); +a b a b a b a b +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t345.a3,t345.b3,t345.a4,t345.b4,t345.a5,t345.b5 +FROM t2 +LEFT JOIN t345 +ON t2.b=t345.b4 +WHERE (t345.a3>1 OR t345.c3 IS NULL) AND +(t345.a5<3 OR t345.c5 IS NULL); +a b a3 b3 a4 b4 a5 b5 +3 3 NULL NULL NULL NULL NULL NULL +4 2 2 2 3 2 2 2 +4 2 2 2 4 2 2 2 +5 3 NULL NULL NULL NULL NULL NULL +SELECT t6.a,t6.b +FROM t6; +a b +3 2 +6 2 +6 1 +SELECT t7.a,t7.b +FROM t7; +a b +1 1 +2 2 +SELECT t6.a,t6.b,t7.a,t7.b +FROM t6,t7; +a b a b +3 2 1 1 +3 2 2 2 +6 1 1 1 +6 1 2 2 +6 2 1 1 +6 2 2 2 +SELECT t8.a,t8.b +FROM t8; +a b +0 2 +1 2 +ANALYZE TABLE t6, t7, t8; +Table Op Msg_type Msg_text +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t6`.`b` < 10))) where true +SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM (t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10; +a b a b a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +"Standard compliant copy of above query" +SELECT t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10; +a6 b6 a7 b7 a b +3 2 1 1 NULL NULL +3 2 2 2 0 2 +3 2 2 2 1 2 +6 1 1 1 NULL NULL +6 1 2 2 0 2 +6 1 2 2 1 2 +6 2 1 1 NULL NULL +6 2 2 2 0 2 +6 2 2 2 1 2 +SELECT t5.a,t5.b +FROM t5; +a b +3 1 +2 2 +3 3 +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 3 2 2 2 1 2 +2 2 6 2 2 2 0 2 +2 2 6 2 2 2 1 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a < 1 OR t8.c IS NULL); +a b a b a b a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 AND +(t8.a < 1 OR t8.c IS NULL); +a b a6 b6 a7 b7 a b +2 2 3 2 2 2 0 2 +2 2 6 2 2 2 0 2 +3 1 3 2 1 1 NULL NULL +3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4 +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4; +a b a3 b3 a4 b4 +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b; +a b a b a b a b a b a b a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7; +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 2 2 6 2 2 2 0 2 +4 2 1 2 3 2 2 2 6 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 2 2 6 2 2 2 0 2 +4 2 1 2 4 2 2 2 6 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +WHERE t2.a > 3 AND +(t6.a < 6 OR t6.c IS NULL); +a b a b a b a b a b a b a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +WHERE t2.a > 3 AND +(t67.a6 < 6 OR t67.c6 IS NULL); +a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +4 2 1 2 3 2 2 2 3 2 2 2 0 2 +4 2 1 2 3 2 2 2 3 2 2 2 1 2 +4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +4 2 1 2 4 2 2 2 3 2 2 2 0 2 +4 2 1 2 4 2 2 2 3 2 2 2 1 2 +4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2); +a b a b a b a b a b a b a b a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 3 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 3 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 3 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE (t2.a >= 4 OR t2.c IS NULL); +a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 3 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 3 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 3 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 3 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 3 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +SELECT t0.a,t0.b +FROM t0; +a b +1 1 +1 2 +2 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 3 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 3 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 3 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 3 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t9.a,t9.b +FROM t9; +a b +1 1 +1 2 +3 3 +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t1.a,t1.b +FROM t1; +a b +1 3 +2 2 +3 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 +LEFT JOIN +t3 +ON t2.b=t3.b; +a b a b +3 3 NULL NULL +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 +CROSS JOIN t2 +LEFT JOIN +t3 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1, t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b +FROM t1 CROSS JOIN +( +t3 +RIGHT JOIN +t2 +ON t2.b=t3.b +) +WHERE t1.a <= 2; +a b a b a b +1 3 3 3 NULL NULL +1 3 4 2 1 2 +1 3 4 2 2 2 +1 3 5 3 NULL NULL +2 2 3 3 NULL NULL +2 2 4 2 1 2 +2 2 4 2 2 2 +2 2 5 3 NULL NULL +SELECT t3.a,t3.b,t4.a,t4.b +FROM t3,t4; +a b a b +1 2 3 2 +1 2 4 2 +2 2 3 2 +2 2 4 2 +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b; +a b a b a b +3 3 NULL NULL NULL NULL +4 2 1 2 3 2 +4 2 1 2 4 2 +5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +t2 +LEFT JOIN +(t3 CROSS JOIN t4) +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +"Standard compliant copy of above query" +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1 CROSS JOIN +( +(t3 CROSS JOIN t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +) +WHERE t1.a <= 2; +a b a b a b a b +1 3 3 3 NULL NULL NULL NULL +1 3 4 2 1 2 3 2 +1 3 4 2 1 2 4 2 +1 3 5 3 NULL NULL NULL NULL +2 2 3 3 NULL NULL NULL NULL +2 2 4 2 1 2 3 2 +2 2 4 2 1 2 4 2 +2 2 5 3 NULL NULL NULL NULL +EXPLAIN +SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM t1, (t3, t4) +RIGHT JOIN +t2 +ON t3.a=1 AND t2.b=t4.b +WHERE t1.a <= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2) +CREATE INDEX idx_b ON t2(b); +EXPLAIN +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ref idx_b idx_b 5 test.t3.b 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = 1))) where true +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3,t4) +LEFT JOIN +(t1,t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +"Standard compliant copy of above query" +SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b +FROM (t3 CROSS JOIN t4) +LEFT JOIN +(t1 CROSS JOIN t2) +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +a b a b a b +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 3 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +4 2 1 2 4 2 +NULL NULL 2 2 3 2 +NULL NULL 2 2 4 2 +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t4(b); +CREATE INDEX idx_b ON t5(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL NULL NULL NULL NULL 2 56.25 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t8(b); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t0`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +CREATE INDEX idx_b ON t1(b); +CREATE INDEX idx_a ON t0(a); +ANALYZE TABLE t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +EXPLAIN +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t9 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 SIMPLE t1 NULL ALL idx_b NULL NULL NULL 3 100.00 NULL +2 SIMPLE t0 NULL ref idx_a idx_a 5 const 2 33.33 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t4 NULL ALL idx_b NULL NULL NULL 2 100.00 Using where +2 SIMPLE t5 NULL ALL idx_b NULL NULL NULL 3 55.56 Using where +2 SIMPLE t7 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 3 55.56 Using where +2 SIMPLE t8 NULL ALL idx_b NULL NULL NULL 2 75.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2)))) on((((`test`.`t3`.`b` = 2) or (`test`.`t3`.`c` is null)) and ((`test`.`t6`.`b` = 2) or (`test`.`t6`.`c` is null)) and ((`test`.`t5`.`b` = `test`.`t1`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t6`.`c` is null) or (`test`.`t8`.`c` is null)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t0`.`b` = `test`.`t1`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or (`test`.`t2`.`c` is null)) and ((`test`.`t3`.`a` < 5) or (`test`.`t3`.`c` is null)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or (`test`.`t3`.`c` is null) or (`test`.`t4`.`c` is null)) and ((`test`.`t5`.`a` >= 2) or (`test`.`t5`.`c` is null)) and ((`test`.`t6`.`a` >= 4) or (`test`.`t6`.`c` is null)) and ((`test`.`t7`.`a` <= 2) or (`test`.`t7`.`c` is null)) and ((`test`.`t8`.`a` < 1) or (`test`.`t8`.`c` is null)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or (`test`.`t8`.`c` is null))) +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, +t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b +FROM t0,t1 +LEFT JOIN +( +t2 +LEFT JOIN +(t3, t4) +ON t3.a=1 AND t2.b=t4.b, +t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b +) +ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND +(t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND +(t1.a != 2), +t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t3.a < 5 OR t3.c IS NULL) AND +(t3.b=t4.b OR t3.c IS NULL OR t4.c IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t6.a >=4 OR t6.c IS NULL) AND +(t7.a <= 2 OR t7.c IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a b a b a b a b a b a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +"Standard compliant copy of above query" +SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t34.a3,t34.b3,t34.a4,t34.b4, +t5.a,t5.b,t67.a6,t67.b6,t67.a7,t67.b7,t8.a,t8.b,t9.a,t9.b +FROM t0 +CROSS JOIN t1 +LEFT JOIN +( +t2 +LEFT JOIN +t34 +ON t34.a3=1 AND t2.b=t34.b4 +CROSS JOIN t5 +LEFT JOIN +( +t67 +LEFT JOIN +t8 +ON t67.b7=t8.b AND t67.b6 < 10 +) +ON t67.b6 >= 2 AND t5.b=t67.b7 +) +ON (t34.b3=2 OR t34.c3 IS NULL) AND (t67.b6=2 OR t67.c6 IS NULL) AND +(t1.b=t5.b OR t34.c3 IS NULL OR t67.c6 IS NULL or t8.c IS NULL) AND +(t1.a <> 2) +CROSS JOIN t9 +WHERE t0.a=1 AND +t0.b=t1.b AND +(t2.a >= 4 OR t2.c IS NULL) AND +(t34.a3 < 5 OR t34.c3 IS NULL) AND +(t34.b3=t34.b4 OR t34.c3 IS NULL OR t34.c4 IS NULL) AND +(t5.a >=2 OR t5.c IS NULL) AND +(t67.a6 >=4 OR t67.c6 IS NULL) AND +(t67.a7 <= 2 OR t67.c7 IS NULL) AND +(t8.a < 1 OR t8.c IS NULL) AND +(t8.b=t9.b OR t8.c IS NULL) AND +(t9.a=1); +a b a b a b a3 b3 a4 b4 a b a6 b6 a7 b7 a b a b +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 1 +1 2 2 2 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 1 +1 2 3 2 5 3 NULL NULL NULL NULL 3 3 NULL NULL NULL NULL NULL NULL 1 2 +SELECT t2.a,t2.b +FROM t2; +a b +3 3 +4 2 +5 3 +SELECT t3.a,t3.b +FROM t3; +a b +1 2 +2 2 +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a,t3.b +FROM t2 LEFT JOIN (t3) ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a IS NULL); +a b a b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +ALTER TABLE t3 +CHANGE COLUMN a a1 int, +CHANGE COLUMN c c1 int; +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 LEFT JOIN t3 ON t2.b=t3.b +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +SELECT t2.a,t2.b,t3.a1,t3.b +FROM t2 NATURAL LEFT JOIN t3 +WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL); +a b a1 b +4 2 1 2 +4 2 2 2 +5 3 NULL NULL +DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +DROP TABLE t34, t345, t67; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t1 VALUES (2); +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +2 2 2 +DELETE FROM t1 WHERE a=2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DELETE FROM t2; +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.a=t3.a; +a a a +1 NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1(a int, key (a)); +CREATE TABLE t2(b int, key (b)); +CREATE TABLE t3(c int, key (c)); +INSERT INTO t1 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t2 VALUES (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +INSERT INTO t3 VALUES (0), (1), (2), (3), (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON c < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 6 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 0 0 +0 1 1 +0 2 2 +1 0 0 +1 1 1 +1 2 2 +10 0 0 +10 1 1 +10 2 2 +11 0 0 +11 1 1 +11 2 2 +12 0 0 +12 1 1 +12 2 2 +13 0 0 +13 1 1 +13 2 2 +14 0 0 +14 1 1 +14 2 2 +15 0 0 +15 1 1 +15 2 2 +16 0 0 +16 1 1 +16 2 2 +17 0 0 +17 1 1 +17 2 2 +18 0 0 +18 1 1 +18 2 2 +19 0 0 +19 1 1 +19 2 2 +2 0 0 +2 1 1 +2 2 2 +3 0 0 +3 1 1 +3 2 2 +4 0 0 +4 1 1 +4 2 2 +5 0 0 +5 1 1 +5 2 2 +6 0 0 +6 1 1 +6 2 2 +7 0 0 +7 1 1 +7 2 2 +8 0 0 +8 1 1 +8 2 2 +9 0 0 +9 1 1 +9 2 2 +NULL 0 0 +NULL 1 1 +NULL 2 2 +DELETE FROM t3; +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 100.00 Using index +2 SIMPLE t3 NULL index c c 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t2 NULL ref b b 5 test.t3.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`b` = `test`.`t3`.`c`) and (`test`.`t3`.`c` < 3))) where true +SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c; +a b c +0 NULL NULL +1 NULL NULL +10 NULL NULL +11 NULL NULL +12 NULL NULL +13 NULL NULL +14 NULL NULL +15 NULL NULL +16 NULL NULL +17 NULL NULL +18 NULL NULL +19 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 NULL NULL +7 NULL NULL +8 NULL NULL +9 NULL NULL +NULL NULL NULL +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +CREATE TABLE t3 (c31 int); +INSERT INTO t1 VALUES (4), (5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +c11 c21 +4 NULL +5 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +c11 c21 c31 +4 NULL NULL +5 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c11` AS `c11`,`test`.`t2`.`c21` AS `c21`,`test`.`t3`.`c31` AS `c31` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`c31` = `test`.`t1`.`c11`))) on((`test`.`t2`.`c21` = `test`.`t1`.`c11`)) where true +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (23, 2340), (26, 9900); +CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr'); +create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (3,23), (6,26); +CREATE TABLE t4 (groupid int(12)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6); +SELECT * FROM +(SELECT DISTINCT gl.groupid, gp.price +FROM t4 gl +LEFT JOIN +(t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp ON p.goods = gp.goods) +ON gl.groupid = g.groupid and p.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +CREATE VIEW v1 AS +SELECT g.groupid groupid, p.goods goods, +p.name name, p.shop shop, +gp.price price +FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods +INNER JOIN t1 gp on p.goods = gp.goods; +CREATE VIEW v2 AS +SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr'; +SELECT * FROM v2; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +SELECT * FROM +(SELECT DISTINCT g.groupid, fr.price +FROM t4 g +LEFT JOIN +v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t; +groupid price +1 NULL +2 NULL +3 2340 +4 NULL +5 NULL +6 9900 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a int); +CREATE TABLE t2(b int); +CREATE TABLE t3(c int, d int); +CREATE TABLE t4(d int); +CREATE TABLE t5(e int, f int); +CREATE TABLE t6(f int); +CREATE VIEW v1 AS +SELECT e FROM t5 JOIN t6 ON t5.e=t6.f; +CREATE VIEW v2 AS +SELECT e FROM t5 NATURAL JOIN t6; +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +a +SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4; +ERROR 42S22: Unknown column 't1.x' in 'field list' +SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v1.x' in 'field list' +SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +e +SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d); +ERROR 42S22: Unknown column 'v2.x' in 'field list' +DROP VIEW v1, v2; +DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1 (id1 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2); +create table t2 (id2 int(11) not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values (1),(2),(3),(4); +create table t3 (id3 char(16) not null); +insert into t3 values ('100'); +create table t4 (id2 int(11) not null, id3 char(16)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 (id1 int(11) not null, key (id1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t5 values (1),(2),(1); +create view v1 as +select t4.id3 from t4 join t2 on t4.id2 = t2.id2; +select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3); +id1 +1 +2 +drop view v1; +drop table t1, t2, t3, t4, t5; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3); +create table t1(a int); +insert into t1 select A.a + 10*(B.a) from t0 A, t0 B; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2), (3,3); +create table t3(a int, b int, filler char(200), key(a)); +insert into t3 select a,a,'filler' from t1; +insert into t3 select a,a,'filler' from t1; +create table t4 like t3; +insert into t4 select * from t3; +insert into t4 select * from t3; +create table t5 like t4; +insert into t5 select * from t4; +insert into t5 select * from t4; +create table t6 like t5; +insert into t6 select * from t5; +insert into t6 select * from t5; +create table t7 like t6; +insert into t7 select * from t6; +insert into t7 select * from t6; +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +explain select * from t4 join +t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t4` join `test`.`t2` left join (`test`.`t3` join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where (`test`.`t4`.`a` <=> `test`.`t3`.`b`) +explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b +join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using index condition; Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t7 NULL ref a a 5 test.t5.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t7`.`filler` AS `filler` from `test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t2` left join (`test`.`t5` join `test`.`t7`) on(((`test`.`t7`.`a` = `test`.`t5`.`b`) and (`test`.`t5`.`a` = `test`.`t2`.`b`))) where (`test`.`t3`.`a` <=> `test`.`t2`.`b`) +explain select * from t2 left join +(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b +join t5 on t5.a=t3.b) on t3.a=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL X 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL X 100.00 NULL +2 SIMPLE t3 NULL ref a a 5 test.t2.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t5 NULL ref a a 5 test.t3.b X 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref a a 5 test.t5.a X 100.00 Using where; Using join buffer (Batched Key Access) +2 SIMPLE t6 NULL ref a a 5 test.t4.b X 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`filler` AS `filler`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`filler` AS `filler`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t5`.`filler` AS `filler` from `test`.`t2` left join (`test`.`t3` left join (`test`.`t4` join `test`.`t6`) on(((`test`.`t6`.`a` = `test`.`t4`.`b`) and (`test`.`t4`.`a` = `test`.`t3`.`b`))) join `test`.`t5`) on(((`test`.`t5`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`))) where true +drop table t0, t1, t2, t3, t4, t5, t6, t7; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler char(100), key(a)); +insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B; +create table t3 like t2; +insert into t3 select * from t2; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain select * from t1 left join +(t2 left join t3 on (t2.a = t3.a)) +on (t1.a = t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t2 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t3 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t4 (id1 int PRIMARY KEY, id2 int); +CREATE TABLE t5 (id1 int PRIMARY KEY, id2 int); +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +PREPARE stmt FROM +"SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa + FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 + LEFT OUTER JOIN + (t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) + ON t3.id2 IS NOT NULL + WHERE t1.id1=2"; +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +EXECUTE stmt; +id ngroupbynsa +INSERT INTO t1 VALUES (1,1), (2,1), (3,2); +INSERT INTO t2 VALUES (2,1), (3,2), (4,3); +INSERT INTO t3 VALUES (1,1), (3,2), (2,NULL); +INSERT INTO t4 VALUES (1,1), (2,1), (3,3); +INSERT INTO t5 VALUES (1,1), (2,2), (3,3), (4,3); +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +EXECUTE stmt; +id ngroupbynsa +2 1 +2 1 +SELECT t1.id1 AS id, t5.id1 AS ngroupbynsa +FROM t1 INNER JOIN t2 ON t2.id2 = t1.id1 +LEFT OUTER JOIN +(t3 INNER JOIN t4 ON t4.id1 = t3.id2 INNER JOIN t5 ON t4.id2 = t5.id1) +ON t3.id2 IS NOT NULL +WHERE t1.id1=2; +id ngroupbynsa +2 1 +2 1 +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +id int NOT NULL PRIMARY KEY, +ct int DEFAULT NULL, +pc int DEFAULT NULL, +INDEX idx_ct (ct), +INDEX idx_pc (pc) +); +INSERT INTO t1 VALUES +(1,NULL,NULL),(2,NULL,NULL),(3,NULL,NULL),(4,NULL,NULL),(5,NULL,NULL); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +sr int NOT NULL, +nm varchar(255) NOT NULL, +INDEX idx_sr (sr) +); +INSERT INTO t2 VALUES +(2441905,4308,'LesAbymes'),(2441906,4308,'Anse-Bertrand'); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +ct int NOT NULL, +ln int NOT NULL, +INDEX idx_ct (ct), +INDEX idx_ln (ln) +); +CREATE TABLE t4 ( +id int NOT NULL PRIMARY KEY, +nm varchar(255) NOT NULL +); +INSERT INTO t4 VALUES (4308,'Guadeloupe'),(4309,'Martinique'); +SELECT t1.* +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +WHERE t1.id='5'; +id ct pc +5 NULL NULL +SELECT t1.*, t4.nm +FROM t1 LEFT JOIN +(t2 LEFT JOIN t3 ON t3.ct=t2.id AND t3.ln='5') ON t1.ct=t2.id +LEFT JOIN t4 ON t2.sr=t4.id +WHERE t1.id='5'; +id ct pc nm +5 NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT, c INT); +CREATE TABLE t4 (a INT, c INT); +CREATE TABLE t5 (a INT, c INT); +SELECT b FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a) +LEFT JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +SELECT b FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +b +SELECT c FROM t1 JOIN (t2 JOIN t3 USING (a) JOIN t4 USING (a) +JOIN t5 USING (a)) USING (a); +ERROR 23000: Column 'c' in field list is ambiguous +DROP TABLE t1,t2,t3,t4,t5; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t2 VALUES (1,1); +INSERT INTO t3 VALUES (1,1); +SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +carrier char(2) default NULL, +id int NOT NULL auto_increment PRIMARY KEY +) CHARSET utf8mb4; +INSERT INTO t1 VALUES +('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874), +('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484), +('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594), +('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424), +('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464), +('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864), +('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014), +('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534), +('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974); +CREATE TABLE t2 ( +scan_date date default NULL, +package_id int default NULL, +INDEX scan_date(scan_date), +INDEX package_id(package_id) +); +INSERT INTO t2 VALUES +('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124), +('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644), +('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774), +('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004), +('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884), +('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144), +('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414), +('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614), +('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614), +('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094), +('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804), +('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344), +('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594), +('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914), +('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904); +CREATE TABLE t3 ( +package_id int default NULL, +INDEX package_id(package_id) +); +INSERT INTO t3 VALUES +(231058294),(231058324),(231058354),(231058384),(231058414),(231058444), +(231058474),(231058504),(231058534),(231058564),(231058594),(231058624), +(231058684),(231058744),(231058804),(231058864),(231058924),(231058954), +(231059014),(231059074),(231059104),(231059134),(231059164),(231059194), +(231059224),(231059254),(231059284),(231059314),(231059344),(231059374), +(231059404),(231059434),(231059464),(231059494),(231059524),(231059554), +(231059584),(231059614),(231059644),(231059674),(231059704),(231059734), +(231059764),(231059794),(231059824),(231059854),(231059884),(231059914), +(231059944),(231059974),(231060004),(231060034),(231060064),(231060094), +(231060124),(231060154),(231060184),(231060214),(231060244),(231060274), +(231060304),(231060334),(231060364),(231060394),(231060424),(231060454), +(231060484),(231060514),(231060544),(231060574),(231060604),(231060634), +(231060664),(231060694),(231060724),(231060754),(231060784),(231060814), +(231060844),(231060874),(231060904),(231060934),(231060964),(231060994), +(231061024),(231061054),(231061084),(231061144),(231061174),(231061204), +(231061234),(231061294),(231061354),(231061384),(231061414),(231061474), +(231061564),(231061594),(231061624),(231061684),(231061714),(231061774), +(231061804),(231061894),(231061984),(231062074),(231062134),(231062224), +(231062254),(231062314),(231062374),(231062434),(231062494),(231062554), +(231062584),(231062614),(231062644),(231062704),(231062734),(231062794), +(231062854),(231062884),(231062944),(231063004),(231063034),(231063064), +(231063124),(231063154),(231063184),(231063214),(231063274),(231063334), +(231063394),(231063424),(231063454),(231063514),(231063574),(231063664); +CREATE TABLE t4 ( +carrier char(2) NOT NULL default '' PRIMARY KEY, +id int(11) default NULL, +INDEX id(id) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES +('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510); +CREATE TABLE t5 ( +carrier_id int default NULL, +INDEX carrier_id(carrier_id) +); +INSERT INTO t5 VALUES +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6), +(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456), +(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456), +(456),(486),(1081),(1111),(1111),(1111),(1111),(1510); +ANALYZE TABLE t1, t2, t3, t4, t5; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +SELECT COUNT(*) +FROM((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id); +COUNT(*) +6 +EXPLAIN +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 45 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index package_id package_id 5 NULL 45 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY,id PRIMARY 8 test.t1.carrier 1 100.00 NULL +2 SIMPLE t5 NULL ref carrier_id carrier_id 5 test.t4.id 22 100.00 Using index +2 SIMPLE t3 NULL ref package_id package_id 5 test.t2.package_id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` join `test`.`t3` left join (`test`.`t5` join `test`.`t4`) on(((`test`.`t5`.`carrier_id` = `test`.`t4`.`id`) and (`test`.`t4`.`carrier` = `test`.`t1`.`carrier`))) where ((`test`.`t1`.`id` = `test`.`t2`.`package_id`) and (`test`.`t3`.`package_id` = `test`.`t2`.`package_id`)) +SELECT COUNT(*) +FROM ((t2 JOIN t1 ON t2.package_id = t1.id) +JOIN t3 ON t3.package_id = t1.id) +LEFT JOIN +(t5 JOIN t4 ON t5.carrier_id = t4.id) +ON t4.carrier = t1.carrier; +COUNT(*) +6 +DROP TABLE t1,t2,t3,t4,t5; +End of 5.0 tests +# +# Bug#24909223: EXCESSIVE MEMORY USAGE BY QUERY +# +CREATE TABLE t ( +a INT, +b CHAR(255), +c CHAR(255), +d INT, +e INT, +PRIMARY KEY (e), +KEY (d) +) ENGINE=InnoDB; +INSERT INTO t VALUES +(1, '14effca2', 'cffa3819', 98927, 8767), +(1, '2f7cbd33', '421aff88', 87613, 70956), +(1, '5c44507d', '05fd27d3', 36002, 5146), +(1, '6542ee43', 'c09ee30f', 3673, 91467), +(1, '786737dd', '6ac95ccb', 46890, 62953), +(1, '8929d195', '64102e63', 50531, 9712), +(1, '8cc0c106', '17283316', 16399, 26119), +(1, '8f3063de', 'ce5d0f35', 21769, 76667), +(1, 'c32c9202', 'c9525fe8', 12704, 43998), +(1, 'c5567e1c', 'bc2e97e6', 85805, 84174), +(1, 'c7acb4d4', '6d67fea7', 58347, 51235), +(1, 'dbd66341', '03b59a03', 46577, 52495), +(1, 'f8e0354e', '41a6e523', 36055, 32646), +(1, 'fb66b513', '10f3de43', 41297, 74334), +(1, 'ffec6d1b', '2fca4073', 12896, 95807), +(1, 'aa3fcff8', 'f4981ed8', 99211, 18778); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE a NULL ALL NULL NULL NULL NULL 16 100.00 NULL +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where +2 SIMPLE b NULL ALL NULL NULL NULL NULL 16 33.33 Using where +2 SIMPLE b NULL ALL d NULL NULL NULL 16 33.33 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `c` from `test`.`t` `a` join `test`.`t` `b` join `test`.`t` `b` join `test`.`t` `b` where ((`test`.`a`.`a` >= `test`.`b`.`d`) and (`test`.`a`.`a` >= `test`.`b`.`a`) and (`test`.`a`.`b` > `test`.`b`.`b`)) +TRUNCATE TABLE performance_schema.memory_summary_by_thread_by_event_name; +SELECT a.c AS c FROM ( +SELECT a.c AS c FROM ( +SELECT a.a AS c FROM t AS a +INNER JOIN t AS b ON a.b > b.b +) AS a +INNER JOIN t AS b ON a.c >= b.a +) AS a +INNER JOIN t AS b ON a.c >= b.d; +c +SELECT * FROM performance_schema.memory_summary_by_thread_by_event_name +WHERE event_name = 'memory/sql/thd::main_mem_root' +AND thread_id = ps_thread_id(connection_id()) +AND sum_number_of_bytes_alloc > 1000000 +DROP TABLE t; +CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t7 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +CREATE TABLE t8 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); +INSERT INTO t5 VALUES (1,1,0), (2,2,0), (3,3,0); +INSERT INTO t6 VALUES (1,2,0), (3,2,0), (6,1,0); +INSERT INTO t7 VALUES (1,1,0), (2,2,0); +INSERT INTO t8 VALUES (0,2,0), (1,2,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 3 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index b_i b_i 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t8 NULL ALL b_i NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` < 10)))) on(((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t6`.`b` >= 2) and ((`test`.`t8`.`a` > 0) or (`test`.`t8`.`c` is null)))) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 +LEFT JOIN +( +(t6, t7) +LEFT JOIN +t8 +ON t7.b=t8.b AND t6.b < 10 +) +ON t6.b >= 2 AND t5.b=t7.b AND +(t8.a > 0 OR t8.c IS NULL); +a b a b a b a b +1 1 1 2 1 1 NULL NULL +1 1 3 2 1 1 NULL NULL +2 2 1 2 2 2 1 2 +2 2 3 2 2 2 1 2 +3 3 NULL NULL NULL NULL NULL NULL +DELETE FROM t5; +DELETE FROM t6; +DELETE FROM t7; +DELETE FROM t8; +INSERT INTO t5 VALUES (1,3,0), (3,2,0); +INSERT INTO t6 VALUES (3,3,0); +INSERT INTO t7 VALUES (1,2,0); +INSERT INTO t8 VALUES (1,1,0); +ANALYZE TABLE t5, t6, t7, t8; +Table Op Msg_type Msg_text +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.a=1, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL ref b_i b_i 5 const 1 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t6` left join `test`.`t7` on((`test`.`t7`.`b` = 2)) join `test`.`t8`) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t6 LEFT JOIN t7 ON t7.b=2, t8) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +EXPLAIN +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index NULL b_i 5 NULL 2 100.00 Using index +2 SIMPLE t8 NULL ref b_i b_i 5 test.t5.b 1 100.00 Using index +2 SIMPLE t6 NULL index NULL b_i 5 NULL 1 100.00 Using index +2 SIMPLE t7 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t5` left join (`test`.`t8` join `test`.`t6` left join `test`.`t7` on((`test`.`t7`.`a` = 1))) on((`test`.`t8`.`b` = `test`.`t5`.`b`)) where true +SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b +FROM t5 LEFT JOIN +(t8, t6 LEFT JOIN t7 ON t7.a=1) +ON (t5.b=t8.b); +a b a b a b a b +1 3 NULL NULL NULL NULL NULL NULL +3 2 NULL NULL NULL NULL NULL NULL +DROP TABLE t5,t6,t7,t8; +set optimizer_switch=default; diff --git a/mysql-test/r/join_outer.result-pq b/mysql-test/r/join_outer.result-pq new file mode 100644 index 000000000..8e26ca3e2 --- /dev/null +++ b/mysql-test/r/join_outer.result-pq @@ -0,0 +1,3834 @@ +drop table if exists t0,t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +grp int(11) default NULL, +a bigint(20) unsigned default NULL, +c char(10) NOT NULL default '' +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,''); +create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a)); +insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7); +select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +EXPLAIN FORMAT=tree select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +EXPLAIN +-> Sort: t1.grp, t1.a, t2.c + -> Stream results (cost=3.67 rows=7) + -> Nested loop left join (cost=3.67 rows=7) + -> Table scan on t1 (cost=1.22 rows=7) + -> Single-row index lookup on t2 using PRIMARY (a=t1.a) (cost=0.26 rows=1) + +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +grp a c id a c d +NULL NULL NULL NULL NULL NULL +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) }; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 left join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 using (a,c); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (c); +grp a c id a c d +1 1 a 1 1 a 1 +1 1 a 3 4 A 4 +2 2 b 3 5 B 5 +2 3 c 3 6 C 6 +3 4 E NULL NULL NULL NULL +3 5 C 3 6 C 6 +3 6 D 4 7 D 7 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 natural left outer join t2; +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3; +grp a c id a c d +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null; +grp a c id a c d +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where false +explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`a` is null) = 1) +select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +grp a c id a c d a +1 1 a 1 1 a 1 1 +2 2 b NULL NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL NULL +3 4 E 3 4 A 4 4 +3 5 C 3 5 B 5 5 +3 6 D 3 6 C 6 6 +NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.* from t1 inner join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 natural join t2; +grp a c id a c d +1 1 a 1 1 a 1 +drop table t1,t2; +CREATE TABLE t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id) +); +CREATE TABLE t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id) +); +INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t1 +LEFT JOIN t2 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t2 +RIGHT JOIN t1 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +ERROR 23000: Duplicate entry '2-3' for key 't2.PRIMARY' +INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +drop table t1,t2; +CREATE TABLE t1 ( +cod_asig int(11) DEFAULT '0' NOT NULL, +desc_larga_cat varchar(80) DEFAULT '' NOT NULL, +desc_larga_cas varchar(80) DEFAULT '' NOT NULL, +desc_corta_cat varchar(40) DEFAULT '' NOT NULL, +desc_corta_cas varchar(40) DEFAULT '' NOT NULL, +cred_total double(3,1) DEFAULT '0.0' NOT NULL, +pre_requisit int(11), +co_requisit int(11), +preco_requisit int(11), +PRIMARY KEY (cod_asig) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL); +CREATE TABLE t2 ( +idAssignatura int(11) DEFAULT '0' NOT NULL, +Grup int(11) DEFAULT '0' NOT NULL, +Places smallint(6) DEFAULT '0' NOT NULL, +PlacesOcupades int(11) DEFAULT '0', +PRIMARY KEY (idAssignatura,Grup) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10360,12,333,0); +INSERT INTO t2 VALUES (10361,30,2,0); +INSERT INTO t2 VALUES (10361,40,3,0); +INSERT INTO t2 VALUES (10360,45,10,0); +INSERT INTO t2 VALUES (10362,10,12,0); +INSERT INTO t2 VALUES (10360,55,2,0); +INSERT INTO t2 VALUES (10360,70,0,0); +INSERT INTO t2 VALUES (10360,565656,0,0); +INSERT INTO t2 VALUES (10360,32767,7,0); +INSERT INTO t2 VALUES (10360,33,8,0); +INSERT INTO t2 VALUES (10360,7887,85,0); +INSERT INTO t2 VALUES (11405,88,8,0); +INSERT INTO t2 VALUES (10360,0,55,0); +INSERT INTO t2 VALUES (10360,99,0,0); +INSERT INTO t2 VALUES (11411,30,10,0); +INSERT INTO t2 VALUES (11404,0,0,0); +INSERT INTO t2 VALUES (10362,11,111,0); +INSERT INTO t2 VALUES (10363,33,333,0); +INSERT INTO t2 VALUES (11412,55,0,0); +INSERT INTO t2 VALUES (50003,66,6,0); +INSERT INTO t2 VALUES (11403,5,0,0); +INSERT INTO t2 VALUES (11406,11,11,0); +INSERT INTO t2 VALUES (11410,11410,131,0); +INSERT INTO t2 VALUES (11416,11416,32767,0); +INSERT INTO t2 VALUES (11409,0,0,0); +CREATE TABLE t3 ( +id int(11) NOT NULL auto_increment, +dni_pasaporte char(16) DEFAULT '' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +cod_asig int(11) DEFAULT '0' NOT NULL, +any smallint(6) DEFAULT '0' NOT NULL, +quatrimestre smallint(6) DEFAULT '0' NOT NULL, +estat char(1) DEFAULT 'M' NOT NULL, +PRIMARY KEY (id), +UNIQUE dni_pasaporte (dni_pasaporte,idPla), +UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M'); +CREATE TABLE t4 ( +id int(11) NOT NULL auto_increment, +papa int(11) DEFAULT '0' NOT NULL, +fill int(11) DEFAULT '0' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY papa (idPla,papa), +UNIQUE papa_2 (idPla,papa,fill) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,-1,10360,1); +INSERT INTO t4 VALUES (2,-1,10361,1); +INSERT INTO t4 VALUES (3,-1,10362,1); +SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1; +fill desc_larga_cat cred_total Grup Places PlacesOcupades +10360 asdfggfg 6.0 0 55 0 +10360 asdfggfg 6.0 12 333 0 +10360 asdfggfg 6.0 33 8 0 +10360 asdfggfg 6.0 45 10 0 +10360 asdfggfg 6.0 55 2 0 +10360 asdfggfg 6.0 7887 85 0 +10360 asdfggfg 6.0 32767 7 0 +10361 Components i Circuits Electronics I 6.0 30 2 0 +10361 Components i Circuits Electronics I 6.0 40 3 0 +10362 Laboratori d`Ordinadors 4.5 10 12 0 +10362 Laboratori d`Ordinadors 4.5 11 111 0 +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 NULL +10361 NULL +10362 NULL +INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S'); +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 1 +10361 NULL +10362 NULL +drop table t1,t2,t3,test.t4; +CREATE TABLE t1 ( +id smallint(5) unsigned NOT NULL auto_increment, +name char(60) DEFAULT '' NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'Antonio Paz'); +INSERT INTO t1 VALUES (2,'Lilliana Angelovska'); +INSERT INTO t1 VALUES (3,'Thimble Smith'); +CREATE TABLE t2 ( +id smallint(5) unsigned NOT NULL auto_increment, +owner smallint(5) unsigned DEFAULT '0' NOT NULL, +name char(60), +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1,'El Gato'); +INSERT INTO t2 VALUES (2,1,'Perrito'); +INSERT INTO t2 VALUES (3,3,'Happy'); +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t1 left join t2 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t2 right join t1 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +Lilliana Angelovska NULL NULL NULL +Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +NULL NULL NULL 2 +Thimble Smith Happy 3 3 +explain format=tree select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.20 rows=9) + -> PQblock scan on t3 using PRIMARY (cost=0.55 rows=3) + -> Nested loop inner join (cost=0.83 rows=3) + -> Single-row index lookup on t1 using PRIMARY (id=t3.id) (cost=0.28 rows=1) + -> Filter: (t2.`owner` = t3.id) (cost=0.18 rows=3) + -> Table scan on t2 (cost=0.18 rows=3) + +select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id owner id +Antonio Paz El Gato 1 1 1 +Antonio Paz Perrito 2 1 1 +NULL NULL NULL NULL 2 +Thimble Smith Happy 3 3 3 +drop table t1,t2; +create table t1 (id int not null, str char(10), index(str)); +insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar"); +select * from t1 where str is not null order by id; +id str +3 foo +4 bar +select * from t1 where str is null; +id str +1 NULL +2 NULL +explain select * from t1 where str is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref str str 41 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`str` AS `str` from `test`.`t1` where (`test`.`t1`.`str` is null) +explain format=tree select * from t1 where str is null; +EXPLAIN +-> Parallel scan on + -> PQblock lookup on t1 using str (str=NULL), with index condition: (t1.str is null) (cost=0.70 rows=2) + +drop table t1; +CREATE TABLE t1 ( +t1_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t2_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +t3_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t3_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_0_id (seq_0_id), +KEY seq_1_id (seq_1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_1_id (seq_1_id), +KEY seq_0_id (seq_0_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1); +insert into t2 values (1); +insert into t3 values (1); +insert into t4 values (1,1); +insert into t5 values (1,1); +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +ERROR 42S22: Unknown column 't2.t2_id' in 'on clause' +drop table t1,t2,t3,t4,t5; +create table t1 (n int, m int, o int, key(n)); +create table t2 (n int not null, m int, o int, primary key(n)); +insert into t1 values (1, 2, 11), (1, 2, 7), (2, 2, 8), (1,2,9),(1,3,9); +insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10); +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1; +n m o n m o +1 2 11 1 2 3 +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1 order by t1.o,t1.m; +n m o n m o +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +1 2 11 1 2 3 +drop table t1,t2; +CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT); +INSERT INTO t1 VALUES (1,'a',1); +INSERT INTO t1 VALUES (2,'b',1); +INSERT INTO t1 VALUES (3,'c',2); +CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1)); +INSERT INTO t2 VALUES (1,'x'); +INSERT INTO t2 VALUES (2,'y'); +INSERT INTO t2 VALUES (3,'z'); +SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL; +id2 +3 +SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL; +id2 +3 +drop table t1,t2; +create table t1 ( color varchar(20), name varchar(20) ); +insert into t1 values ( 'red', 'apple' ); +insert into t1 values ( 'yellow', 'banana' ); +insert into t1 values ( 'green', 'lime' ); +insert into t1 values ( 'black', 'grape' ); +insert into t1 values ( 'blue', 'blueberry' ); +create table t2 ( count int, color varchar(20) ); +insert into t2 values (10, 'green'); +insert into t2 values (5, 'black'); +insert into t2 values (15, 'white'); +insert into t2 values (7, 'green'); +select * from t1; +color name +red apple +yellow banana +green lime +black grape +blue blueberry +select * from t2; +count color +10 green +5 black +15 white +7 green +select * from t2 natural join t1; +color count name +black 5 grape +green 10 lime +green 7 lime +select t2.count, t1.name from t2 natural join t1; +count name +10 lime +5 grape +7 lime +select t2.count, t1.name from t2 inner join t1 using (color); +count name +10 lime +5 grape +7 lime +drop table t1; +drop table t2; +CREATE TABLE t1 ( +pcode varchar(8) DEFAULT '' NOT NULL +); +INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200'); +CREATE TABLE t2 ( +pcode varchar(8) DEFAULT '' NOT NULL, +KEY pcode (pcode) +); +INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000'); +SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 +LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11), +pid int(11), +rep_del tinyint(4), +KEY id (id), +KEY pid (pid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,NULL,NULL); +INSERT INTO t1 VALUES (2,1,NULL); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +create index rep_del ON t1(rep_del); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +drop table t1; +CREATE TABLE t1 ( +id int(11) DEFAULT '0' NOT NULL, +name tinytext DEFAULT '' NOT NULL, +UNIQUE id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'name' can't have a default value +INSERT INTO t1 VALUES (1,'yes'),(2,'no'); +CREATE TABLE t2 ( +id int(11) DEFAULT '0' NOT NULL, +idx int(11) DEFAULT '0' NOT NULL, +UNIQUE id (id,idx) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1); +explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ref id id 4 test.t1.id 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`idx` AS `idx` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id name id idx +2 no NULL NULL +drop table t1,t2; +SET sql_mode = default; +create table t1 (bug_id mediumint, reporter mediumint); +create table t2 (bug_id mediumint, who mediumint, index(who)); +insert into t2 values (1,1),(1,2); +insert into t1 values (1,1),(2,1); +SELECT * FROM t1 LEFT JOIN t2 ON (t1.bug_id = t2.bug_id AND t2.who = 2) WHERE (t1.reporter = 2 OR t2.who = 2); +bug_id reporter bug_id who +1 1 1 2 +drop table t1,t2; +create table t1 (fooID smallint unsigned auto_increment, primary key (fooID)); +create table t2 (fooID smallint unsigned not null, barID smallint unsigned not null, primary key (fooID,barID)); +insert into t1 (fooID) values (10),(20),(30); +insert into t2 values (10,1),(20,2),(30,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY PRIMARY 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fooID` AS `fooID`,`test`.`t2`.`barID` AS `barID`,`test`.`t1`.`fooID` AS `fooID` from `test`.`t2` left join `test`.`t1` on(((`test`.`t2`.`fooID` = 30) and (`test`.`t1`.`fooID` = 30))) where true +select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +drop table t1,t2; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values(2),(4); +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 natural left join t2 where (t2.i is not null)=0; +i +1 +select * from t1 natural left join t2 where (t2.i is not null) is not null; +i +1 +2 +select * from t1 natural left join t2 where (i is not null)=0; +i +select * from t1 natural left join t2 where (i is not null) is not null; +i +1 +2 +drop table t1,t2,t3; +create table t1 (f1 integer,f2 integer,f3 integer); +create table t2 (f2 integer,f4 integer); +create table t3 (f3 integer,f5 integer); +select * from t1 +left outer join t2 using (f2) +left outer join t3 using (f3); +f3 f2 f1 f4 f5 +drop table t1,t2,t3; +create table t1 (a1 int, a2 int); +create table t2 (b1 int not null, b2 int); +create table t3 (c1 int, c2 int); +insert into t1 values (1,2), (2,2), (3,2); +insert into t2 values (1,3), (2,3); +insert into t3 values (2,4), (3,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +a1 a2 b1 b2 c1 c2 +1 2 1 3 NULL NULL +2 2 2 3 NULL NULL +3 2 NULL NULL 3 4 +explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b1` = `test`.`t1`.`a1`)) left join `test`.`t3` on(((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` is null))) where true +drop table t1, t2, t3; +create table t1 ( +a int(11), +b char(10), +key (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (a) values (1),(2),(3),(4); +create table t2 (a int); +select * from t1 left join t2 on t1.a=t2.a where not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +select * from t1 left join t2 on t1.a=t2.a having not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +drop table t1,t2; +create table t1 ( +match_id tinyint(3) unsigned not null auto_increment, +home tinyint(3) unsigned default '0', +unique key match_id (match_id), +key match_id_2 (match_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values("1", "2"); +create table t2 ( +player_id tinyint(3) unsigned default '0', +match_1_h tinyint(3) unsigned default '0', +key player_id (player_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values("1", "5"); +insert into t2 values("2", "9"); +insert into t2 values("3", "3"); +insert into t2 values("4", "7"); +insert into t2 values("5", "6"); +insert into t2 values("6", "8"); +insert into t2 values("7", "4"); +insert into t2 values("8", "12"); +insert into t2 values("9", "11"); +insert into t2 values("10", "10"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by m.match_id desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `test`.`m`.`match_id` desc +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` straight_join `test`.`t1` `m` where (`test`.`m`.`match_id` = 1) order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +drop table t1, t2; +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); +select t1.a, t1.b, t2.c from t1 left join t2 +on t1.a=t2.a and t1.b=t2.b and t2.c=3 +where t1.a=1 and t2.c is null; +a b c +1 11 NULL +drop table t1, t2; +CREATE TABLE t1 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(111056548820001, 0, 'flag1', NULL), +(111056548820001, 0, 'flag2', NULL), +(2, 0, 'other_flag', NULL); +INSERT INTO t2 VALUES +(111056548820001, 3, 'flag1', 'sss'); +SELECT t1.flag_name,t2.flag_value +FROM t1 LEFT JOIN t2 +ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND +t2.inst_id = 3) +WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND +t2.flag_value IS NULL; +flag_name flag_value +flag2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int(11) unsigned NOT NULL auto_increment, +text_id int(10) unsigned default NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("1", "0"); +INSERT INTO t1 VALUES("2", "10"); +CREATE TABLE t2 ( +text_id char(3) NOT NULL default '', +language_id char(3) NOT NULL default '', +text_data text, +PRIMARY KEY (text_id,language_id) +); +INSERT INTO t2 VALUES("0", "EN", "0-EN"); +INSERT INTO t2 VALUES("0", "SV", "0-SV"); +INSERT INTO t2 VALUES("10", "EN", "10-EN"); +INSERT INTO t2 VALUES("10", "SV", "10-SV"); +SELECT t1.id, t1.text_id, t2.text_data +FROM t1 LEFT JOIN t2 +ON t1.text_id = t2.text_id +AND t2.language_id = 'SV' + WHERE (t1.id LIKE '%' OR t2.text_data LIKE '%'); +id text_id text_data +1 0 0-SV +2 10 10-SV +DROP TABLE t1, t2; +CREATE TABLE t0 (a0 int PRIMARY KEY); +CREATE TABLE t1 (a1 int PRIMARY KEY); +CREATE TABLE t2 (a2 int); +CREATE TABLE t3 (a3 int); +INSERT INTO t0 VALUES (1); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +a1 a2 +1 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +a1 a2 a3 +1 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a0 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a0` AS `a0`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t0`.`a0` = 0) and (`test`.`t1`.`a1` = 0))) where (`test`.`t1`.`a1` = `test`.`t0`.`a0`) +INSERT INTO t0 VALUES (0); +INSERT INTO t1 VALUES (0); +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a0`,'1' AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(false) where true +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +select straight_join * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +DROP TABLE t0,t1,t2,t3; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,2); +INSERT INTO t2 VALUES (1,2), (2,2); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t1.b=1; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE t1.b=1 XOR (NOT ISNULL(t2.a) AND t2.b=1); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +DROP TABLE t1,t2; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; +create table t1 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, art int(11) not null, primary key (gid,x,y)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t1 values (1, -5, -8, 2), (1, 2, 2, 1), (1, 1, 1, 1); +create table t2 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, id int(11) not null, primary key (gid,id,x,y), key id (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t2 values (1, -5, -8, 1), (1, 1, 1, 1), (1, 2, 2, 1); +create table t3 ( set_id smallint(5) unsigned not null, id tinyint(4) unsigned not null, name char(12) not null, primary key (id,set_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t3 values (0, 1, 'a'), (1, 1, 'b'), (0, 2, 'c'), (1, 2, 'd'), (1, 3, 'e'), (1, 4, 'f'), (1, 5, 'g'), (1, 6, 'h'); +explain select name from t1 left join t2 on t1.x = t2.x and t1.y = t2.y +left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8 +and t1.gid =1 and t2.gid =1 and t3.set_id =1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 10 const,const,const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY,id PRIMARY 14 const,const,const,const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 3 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'd' AS `name` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +drop tables t1,t2,t3; +CREATE TABLE t1 (EMPNUM INT, GRP INT); +INSERT INTO t1 VALUES (0, 10); +INSERT INTO t1 VALUES (2, 30); +CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5)); +INSERT INTO t2 VALUES (0, 'KERI'); +INSERT INTO t2 VALUES (9, 'BARRY'); +CREATE VIEW v1 AS +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP +FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM; +SELECT * FROM v1; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +SELECT * FROM v1 WHERE EMPNUM < 10; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +INSERT INTO t1 VALUES (30), (40), (50); +INSERT INTO t2 VALUES (300), (400), (500); +SELECT * FROM t1 LEFT JOIN t2 ON (c11=c21 AND c21=30) WHERE c11=40; +c11 c21 +40 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,2), (2,1), (3,2), (4,3), (5,6), (6,5), (7,8), (8,7), (9,10); +INSERT INTO t2 VALUES (3,0), (4,1), (6,4), (7,5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b <= t1.a AND t1.a <= t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a BETWEEN t2.b AND t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT BETWEEN t2.b AND t1.b); +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT BETWEEN t2.b AND t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a AND t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a AND (t2.b > t1.a OR t1.a > t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a OR t1.a BETWEEN t2.b AND t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT IN(t1.b, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b OR (t1.a != t2.a AND t1.a != t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b AND t1.a IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b AND t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b OR t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` in (`test`.`t2`.`a`,`test`.`t2`.`b`))) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b-2, t2.b, t2.b-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` > if((`test`.`t2`.`a` = (`test`.`t2`.`b` - 2)),`test`.`t2`.`b`,(`test`.`t2`.`b` - 1)))) +DROP TABLE t1,t2; +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; +SELECT v1.a, v2. b +FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) +GROUP BY v1.a; +a b +2 NULL +3 3 +SELECT v1.a, v2. b +FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } +GROUP BY v1.a; +a b +2 NULL +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); +a b +1 NULL +2 2 +3 3 +4 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f2 varchar(16) collate latin1_swedish_ci +); +CREATE TABLE t2 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f3 varchar(16) collate latin1_swedish_ci +); +INSERT INTO t1 VALUES ('bla','blah'); +INSERT INTO t2 VALUES ('bla','sheep'); +SELECT * FROM t1 JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8)); +CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id)); +INSERT INTO t1 VALUES +(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc'); +INSERT INTO t2 VALUES +(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL 9 11.11 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`b` is null) +flush status; +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id a +1 aaaaaaa +4 ddddddd +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 16 +DROP TABLE t1,t2; +CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL); +INSERT INTO t1 VALUES (1,0), (2,1); +CREATE TABLE t2 (d int PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 33.33 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `c`,'0' AS `e`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on(('0' <> 0)) where ((`test`.`t2`.`d` is null)) +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +c e d +1 0 NULL +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL; +c e d +1 0 NULL +DROP TABLE t1,t2; +# +# Bug#47650: using group by with rollup without indexes returns incorrect +# results with where +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( a INT, b INT ); +INSERT INTO t2 VALUES (1, 1),(1, 2),(1, 3),(2, 4),(2, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +DROP TABLE t1, t2; +# +# Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison +# +CREATE TABLE t1(f1 INT, f2 INT, f3 INT); +INSERT INTO t1 VALUES (1, NULL, 3); +CREATE TABLE t2(f1 INT, f2 INT); +INSERT INTO t2 VALUES (2, 1); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f2` = `test`.`t1`.`f2`)) where ((coalesce(`test`.`t1`.`f1`,`test`.`t2`.`f1`),`test`.`t1`.`f3`) in ((1,3),(2,2))) +SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +f1 f2 f3 f1 f2 +1 NULL 3 NULL NULL +DROP TABLE t1, t2; +# +# Bug#52357: Assertion failed: join->best_read in greedy_search +# optimizer_search_depth=0 +# +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1),(2); +SET optimizer_search_depth = 0; +# Should not core dump on query preparation +EXPLAIN +SELECT 1 +FROM t1 tt3 LEFT OUTER JOIN t1 tt4 ON 1 +LEFT OUTER JOIN t1 tt5 ON 1 +LEFT OUTER JOIN t1 tt6 ON 1 +LEFT OUTER JOIN t1 tt7 ON 1 +LEFT OUTER JOIN t1 tt8 ON 1 +RIGHT OUTER JOIN t1 tt2 ON 1 +RIGHT OUTER JOIN t1 tt1 ON 1 +STRAIGHT_JOIN t1 tt9 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tt1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE tt2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt5 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt6 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt9 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `tt1` left join (`test`.`t1` `tt2` left join (`test`.`t1` `tt3` left join `test`.`t1` `tt4` on(true) left join `test`.`t1` `tt5` on(true) left join `test`.`t1` `tt6` on(true) left join `test`.`t1` `tt7` on(true) left join `test`.`t1` `tt8` on(true)) on(true)) on(true) straight_join `test`.`t1` `tt9` where true +SET optimizer_search_depth = DEFAULT; +DROP TABLE t1; +# +# Bug#46091 STRAIGHT_JOIN + RIGHT JOIN returns different result +# +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +COUNT(*) +476 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 90.00 Parallel execute (1 workers) +2 SIMPLE ta2 NULL ALL NULL NULL NULL NULL 20 90.00 Using where +2 SIMPLE ta3 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE ta1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` `ta2` join `test`.`t2` `ta3` left join `test`.`t1` `ta1` on((0 <> `test`.`ta3`.`f1`)) where (0 <> `test`.`ta2`.`f1`) +DROP TABLE t1, t2; +# +# Bug#48971 Segfault in add_found_match_trig_cond () at sql_select.cc:5990 +# +CREATE TABLE t1(f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +LEFT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`)))) on(true) where true +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +RIGHT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`))) left join `test`.`t1` `jt1` on(true) where true +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = 4)) where true group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +4 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = 4) and (`test`.`t2`.`f2` is not null)) group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +DROP TABLE t1,t2; +# +# Bug#57034 incorrect OUTER JOIN result when joined on unique key +# +CREATE TABLE t1 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t1 VALUES (1,NULL,2), (2,0,0); +CREATE TABLE t2 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t2 VALUES (1,0,1), (2,0,2); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,NULL AS `col_int`,'2' AS `col_int_unique`,NULL AS `pk`,NULL AS `col_int`,NULL AS `col_int_unique` from `test`.`t1` left join `test`.`t2` on((multiple equal('2', NULL) and multiple equal(NULL, NULL))) where true +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +pk col_int col_int_unique pk col_int col_int_unique +1 NULL 2 NULL NULL NULL +DROP TABLE t1,t2; +# +# Bug#48046 Server incorrectly processing JOINs on NULL values +# +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_key` time DEFAULT NULL, +`varchar_key` varchar(1) DEFAULT NULL, +`varchar_nokey` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL); +SELECT table1.time_key AS field1, table2.pk +FROM BB table1 LEFT JOIN BB table2 +ON table2.varchar_nokey = table1.varchar_key +HAVING field1; +field1 pk +18:27:58 NULL +DROP TABLE BB; +# +# Bug#49600 Server incorrectly processing RIGHT JOIN with +# constant WHERE clause and no index +# +CREATE TABLE `BB` ( +`col_datetime_key` datetime DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_datetime_key` (`col_datetime_key`), +KEY `col_varchar_key` (`col_varchar_key`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL); +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +ALTER TABLE BB DISABLE KEYS; +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +DROP TABLE BB; +# +# Bug#58490: Incorrect result in multi level OUTER JOIN +# in combination with IS NULL +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0), (2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1), (3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2), (4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3) ; +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +WHERE t4.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i +2 NULL NULL +3 3 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN t4 +ON t4.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL 3 +4 NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 3 +4 NULL NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a, t4 AS t4b) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 0 +3 3 NULL 3 1 +3 3 NULL 3 2 +3 3 NULL 3 3 +4 NULL NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +# +# Bug#49322(Duplicate): Server is adding extra NULL row +# on processing a WHERE clause +# +CREATE TABLE h (pk INT NOT NULL, col_int_key INT); +INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8); +CREATE TABLE m (pk INT NOT NULL, col_int_key INT); +INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9); +CREATE TABLE k (pk INT NOT NULL, col_int_key INT); +INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5); +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key; +pk +2 +2 +4 +4 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key +WHERE TABLE1.pk IS NULL; +pk +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE h,m,k; +# +# Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY +# IS EXECUTED TWICE FROM P +# +CREATE TABLE t1 ( a INT ) ENGINE = MYISAM; +INSERT INTO t1 VALUES (1); +PREPARE prep_stmt FROM ' + SELECT 1 AS f FROM t1 + LEFT JOIN t1 t2 + RIGHT JOIN t1 t3 + JOIN t1 t4 + ON 1 + ON 1 + ON 1 + GROUP BY f'; +EXECUTE prep_stmt; +f +1 +EXECUTE prep_stmt; +f +1 +DROP TABLE t1; +End of 5.1 tests +# +# Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t1 VALUES (null),(null); +explain SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t3`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +a +explain SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` left join `test`.`t4` on(true)) on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t4`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +a +DROP TABLE t1,t2,t3,t4; +# +# Bug#56254 Assertion tab->ref.use_count fails in +# join_read_key_unlock_row() on 4-way JOIN +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_int INT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (6, -448724992, NULL); +CREATE TABLE t2 ( +col_int INT, +col_varchar_10 VARCHAR(10) +); +INSERT INTO t2 VALUES (6,'afasdkiyum'); +CREATE TABLE t3 ( +col_varchar_10 VARCHAR(10), +col_int INT +); +CREATE TABLE t4 ( +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1); +INSERT INTO t4 VALUES (2); +SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +col_int +EXPLAIN FORMAT=tree SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +EXPLAIN +-> Parallel scan on + -> Filter: (found_match(t3..t4), ((t1.col_int_key is null) or (t4.pk < t3.col_int)), true) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.col_int = t1.pk) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_varchar_10 = t2.col_varchar_10) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t3.col_int) (cost=0.35 rows=1) + +DROP TABLE t1,t2,t3,t4; + +# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN +# USED IN GROUP BY + +CREATE TABLE t1 (pk int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +PREPARE prep_stmt_9846 FROM ' +SELECT alias1.pk AS field1 FROM +t1 AS alias1 +LEFT JOIN +( + t1 AS alias2 + RIGHT JOIN + ( + t1 AS alias3 + JOIN t1 AS alias4 + ON 1 + ) + ON 1 +) +ON 1 +GROUP BY field1'; +execute prep_stmt_9846; +field1 +execute prep_stmt_9846; +field1 +deallocate prepare prep_stmt_9846; +drop table t1; +# +# Bug#13040136 - ASSERT IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +col_int_key INTEGER, +col_varchar_10_key VARCHAR(10), +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_10_key) +); +INSERT INTO t1 VALUES ('q',NULL,'o',1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar_10_key VARCHAR(10), +col_int_key INTEGER, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY (col_varchar_10_key), +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(1,'r',NULL,'would'),(2,'tell',-655032320,'t'), +(3,'d',9,'a'),(4,'gvafasdkiy',6,'ugvafasdki'), +(5,'that\'s',NULL,'she'),(6,'bwftwugvaf',7,'cbwftwugva'), +(7,'f',-700055552,'mkacbwftwu'),(8,'a',9,'be'), +(9,'d',NULL,'u'),(10,'ckiixcsxmk',NULL,'o'); +SELECT DISTINCT t2.col_int_key +FROM +t1 +LEFT JOIN t2 +ON t1.col_varchar_10 = t2.col_varchar_10_key +WHERE t2.pk +ORDER BY t2.col_int_key; +col_int_key +DROP TABLE t1,t2; +# +# Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS WRONG RESULT +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); +CREATE TABLE t3 (i4 int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(2); + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1;; +field1 +20 +20 + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1 GROUP BY field1;; +field1 +20 + +drop table t1,t2,t3; +# Bug#11766384 - 59487: WRONG RESULT WITH STRAIGHT_JOIN AND RIGHT JOIN +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1'); +CREATE TABLE t2 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 ( +pk int(11) NOT NULL, +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,1,1,'1'); +CREATE TABLE t5 ( +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t5 VALUES (1,'1'); +CREATE TABLE t6 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t6 VALUES (1,'1',1); +SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` join `test`.`t6` where ((`test`.`t5`.`col_int` = 1000) and ((0 <> `test`.`t6`.`col_int_key`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` left join `test`.`t6` on((`test`.`t5`.`col_int` = 1000)) where ((0 <> `test`.`t6`.`col_int_key`) is not true) +drop table t1,t2,t3,t4,t5,t6; +# +# Verify that the "not exists" optimization works. +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`a` is null) +FLUSH STATUS; +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +a a +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; +# +# Bug#13980954 Missing data on left join + null value + where..in +# +CREATE TABLE t1 (ik INT, vc varchar(1)) charset utf8mb4 ENGINE=Innodb; +explain format=json SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc", + "ik" + ], + "query_block": { + "cost_info": { + "query_cost": "1.05" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t1`.`vc`)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(is_not_null_compl(t3), (`test`.`t3`.`vc` = `test`.`t1`.`vc`), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`vc` AS `vc`,`test`.`t1`.`ik` AS `ik` from `test`.`t1` join `test`.`t1` `t2` left join `test`.`t1` `t3` on((`test`.`t3`.`vc` = `test`.`t1`.`vc`)) where (`test`.`t2`.`vc` = `test`.`t1`.`vc`) +SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +vc ik +DROP TABLE t1; +# +# Bug #18345786 CRASH AROUND ST_JOIN_TABLE::AND_WITH_CONDITION +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1), 1)); +DROP TABLE t1; +# +# Coverage for "unique row not found" +# +create table t1(a int, unique key(a)) engine=innodb; +insert into t1 values(1); +explain select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const a a 5 const 1 100.00 Using index +1 SIMPLE t2 NULL const a a 5 const 0 0.00 unique row not found +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,NULL AS `a` from `test`.`t1` left join `test`.`t1` `t2` on(multiple equal(12, NULL)) where true +select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +a a +1 NULL +drop table t1; +# +# Bug#18717059 MISSING ROWS ON NESTED JOIN WITH SUBQUERY +# WITH MYISAM OR MEMORY +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (23,4,'d'); +INSERT INTO t1 VALUES (24,8,'g'); +INSERT INTO t1 VALUES (25,NULL,'x'); +INSERT INTO t1 VALUES (26,NULL,'f'); +INSERT INTO t1 VALUES (27,0,'p'); +INSERT INTO t1 VALUES (28,NULL,'j'); +INSERT INTO t1 VALUES (29,8,'c'); +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +) ENGINE=MyISAM; +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +9 +9 +9 +9 +9 +9 +9 +9 +CREATE TABLE where_subselect_table AS +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +set optimizer_switch='condition_fanout_filter=on'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +set optimizer_switch='condition_fanout_filter=off'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +DROP TABLE t1, t2, where_subselect_table; +# Bug#14358878 Wrong results on table left join view +CREATE TABLE a (id INTEGER); +CREATE TABLE b (id INTEGER); +CREATE ALGORITHM=MERGE VIEW vmerge AS SELECT 1 AS id, id AS b_id FROM b; +CREATE ALGORITHM=TEMPTABLE VIEW vmat AS SELECT 1 AS id, id AS b_id FROM b; +INSERT INTO a(id) VALUES (1); +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmat AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT DISTINCT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION DISTINCT +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION ALL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +1 NULL NULL +DROP VIEW vmerge, vmat; +DROP TABLE a, b; +# Bug#15936817 Table left join view, unmatched rows problem where +# view contains an IF +CREATE TABLE small ( +id INTEGER not null, +PRIMARY KEY (id) +); +CREATE TABLE big ( +id INTEGER not null, +PRIMARY KEY (id) +); +INSERT INTO small VALUES (1), (2); +INSERT INTO big VALUES (1), (2), (3), (4); +CREATE VIEW small_view AS +SELECT *, IF (id % 2 = 1, 1, 0) AS is_odd +FROM small; +CREATE VIEW big_view AS +SELECT big.*, small_view.id AS small_id, small_view.is_odd +FROM big LEFT JOIN small_view ON small_view.id = big.id; +SELECT * FROM big_view; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +SELECT big.*, small.id AS small_id, small.is_odd +FROM big LEFT JOIN +(SELECT id, IF (id % 2 = 1, 1, 0) AS is_odd FROM small) AS small +ON big.id = small.id; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +# Check the IS NULL and thruth predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id IS NULL AS nul, +id IS NOT NULL AS nnul, +id IS TRUE AS t, +id IS NOT TRUE AS nt, +id IS FALSE AS f, +id IS NOT FALSE AS nf, +id IS UNKNOWN AS u, +id IS NOT UNKNOWN AS nu +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id nul nnul t nt f nf u nu +1 1 0 1 1 0 0 1 0 1 +2 2 0 1 1 0 0 1 0 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL NULL +# Check comparison predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id = 1 AS eq, +id <> 1 AS ne, +id > 1 AS gt, +id >= 1 AS ge, +id < 1 AS lt, +id <= 1 AS le, +id <=> 1 AS equal +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id eq ne gt ge lt le equal +1 1 1 0 0 1 0 1 1 +2 2 0 1 1 1 0 0 0 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +# Check CASE, NULLIF and COALESCE +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +CASE id WHEN 0 THEN 0 ELSE 1 END AS simple, +CASE WHEN id=0 THEN NULL ELSE 1 END AS cond, +NULLIF(1, NULL) AS nullif, +IFNULL(1, NULL) AS ifnull, +COALESCE(id) AS coal, +INTERVAL(NULL, 1, 2, 3) as intv, +IF (id % 2 = 1, NULL, 1) AS iff +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id simple cond nullif ifnull coal intv iff +1 1 1 1 1 1 1 -1 NULL +2 2 1 1 1 1 2 -1 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +DROP VIEW small_view, big_view; +DROP TABLE small, big; +# +# Bug#16893426 OPTIMIZER FAILS TO OPTIMIZE EXPRESSION OF THE +# FORM 'FOO' IS NULL +# +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +name varchar(20), +INDEX (name) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL PRIMARY KEY, +f_id int(11), +FOREIGN KEY (f_id) REFERENCES t2(id) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE "; +EXECUTE stmt; +id f_id id name +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' "; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DROP TABLE t1,t2; +# +# Bug#22103398 BUG#16893426:SIG11 IN +# ST_SELECT_LEX::FLATTEN_SUBQUERIES | SQL_RESOLVER.CC +# +CREATE TABLE t1(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +CREATE TABLE t2(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +SELECT b.c2 AS f1 FROM (t2 AS a JOIN +((t2 AS b JOIN t2 AS c ON (c.c3=b.c3))) +ON (c.c1=b.c2)) +WHERE (c.c3 IN (SELECT subquery1_b.c3 AS subquery1_f1 +FROM (t1 AS subquery1_a JOIN t2 AS subquery1_b ON +(subquery1_b.c1=subquery1_a.c1)))) AND +(a.c1=a.c1 AND (SELECT''FROM DUAL) IS NULL); +f1 +DROP TABLE t1, t2; +# End of Bug#16893426 +# Bug#22561937 Wrong result on outer join with multiple join conditions +# and derived table +CREATE TABLE t1 ( +col_int INT, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES +(2,1), (2,2), (6,3), (4,4), (7,5), +(188,6), (0,7), (6,8), (0,9), (9,10); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,0), (2,0), (3,2), (4,NULL), (5,2), +(6,3), (7,3), (8,100), (9,3), (10,6); +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join `test`.`t1` `table2` on(((`test`.`table2`.`pk` = `test`.`table1`.`col_int`) and (`test`.`table1`.`col_int` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join (`test`.`t1`) on(((`test`.`t1`.`pk` = `test`.`table1`.`col_int`) and (`test`.`t1`.`pk` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +DROP TABLE t1, t2; +# Bug#22671557: Wrong results on JOIN when composite index is present +CREATE TABLE t1 ( +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,col_int) +); +INSERT INTO t1 VALUES (0, -7, 1), (9, NULL, 15), (182, NULL, 25); +CREATE TABLE t2 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (NULL, 4), (-208, 5), (5, 6), (NULL, 75); +CREATE TABLE t3 ( +col_datetime_key DATETIME DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES ('1970-01-01 00:00:00', 5); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t4 VALUES (0, 15, 6), (9, 16, 6); +SELECT alias2.col_datetime_key +FROM +t1 AS alias1 +LEFT JOIN t3 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t4 AS alias4 +ON alias3.pk = alias4.col_int_key +ON alias2.pk = alias3.col_int +ON alias1.col_int = alias4.col_int +; +col_datetime_key +1970-01-01 00:00:00 +1970-01-01 00:00:00 +NULL +DROP TABLE t1, t2, t3, t4; +# Bug#22833364: Left join returns incorrect results on the outer side +CREATE TABLE ta ( +a1 varchar(1024) NOT NULL, +a2 int NOT NULL, +KEY user_id(a2) +); +INSERT INTO ta (a1, a2) VALUES ('row1', 4), ('row2', 4); +CREATE TABLE tb ( +b1 int NOT NULL, +b2 varchar(1024) NOT NULL, +b3 int NOT NULL, +PRIMARY KEY (b1) +); +INSERT INTO tb (b1, b2, b3) VALUES +(1, 'text1', 0), (2, 'text2', 0), (3, 'text3', 1), (4, 'text4', 1); +explain SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE ta NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tb NULL eq_ref PRIMARY PRIMARY 4 test.ta.a2 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ta`.`a1` AS `a1`,`test`.`tb`.`b1` AS `b1`,`test`.`tb`.`b2` AS `b2` from `test`.`ta` left join `test`.`tb` on(((`test`.`tb`.`b3` = 0) and (`test`.`tb`.`b1` = `test`.`ta`.`a2`))) where true +SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +a1 b1 b2 +row1 NULL NULL +row2 NULL NULL +DROP TABLE ta, tb; +# Bug#23079533: Left join on PK + extra condition doesn't return match +CREATE TABLE m ( +machineid VARCHAR(32) NOT NULL, +orderid bigint unsigned DEFAULT NULL, +extra bigint unsigned DEFAULT NULL, +PRIMARY KEY (machineid) +); +INSERT INTO m (machineid, orderid) +VALUES ('m1', NULL), ('m2', 2), ('m3', NULL), ('m4', NULL); +CREATE TABLE o ( +orderid bigint unsigned NOT NULL, +machineid VARCHAR(32) DEFAULT NULL, +PRIMARY KEY (orderid) +); +INSERT INTO o (orderid, machineid) +VALUES (1, 'm2'), (2, 'm2'); +SELECT o.*,'|' as sep, m.* +FROM o LEFT JOIN m +ON m.machineid = o.machineid AND +m.orderid = o.orderid; +orderid machineid sep machineid orderid extra +1 m2 | NULL NULL NULL +2 m2 | m2 2 NULL +DROP TABLE m, o; +# Bug#23086825: Incorrect query results using left join against derived +CREATE TABLE t1 ( +adslot varchar(5) NOT NULL +); +INSERT INTO t1(adslot) VALUES ('1'), ('2'), ('3'); +CREATE TABLE t2 ( +ionumber varchar(20) NOT NULL, +adslot varchar(5) NOT NULL +); +INSERT INTO t2 (ionumber, adslot) VALUES ('01602', 1), ('01602', 3); +CREATE TABLE t3 ( +ionumber varchar(20) NOT NULL, +ioattribute varchar(5) NOT NULL, +PRIMARY KEY (ionumber) +); +INSERT INTO t3 VALUES ('01602', 'BOB'), ('01603', 'SALLY'); +SELECT s.adslot, lid.ionumber1, lid.ionumber2, lid.ioattribute +FROM t1 s LEFT JOIN +(SELECT lid.adslot, +i.ionumber as ionumber1, +lid.ionumber as ionumber2, +i.ioattribute +FROM t2 lid JOIN t3 i +USING (ionumber) +) AS lid +USING (adslot); +adslot ionumber1 ionumber2 ioattribute +1 01602 01602 BOB +2 NULL NULL NULL +3 01602 01602 BOB +DROP TABLE t1, t2, t3; +# +# Bug #26432173: INCORRECT SUBQUERY OPTIMIZATION WITH +# LEFT JOIN(SUBQUERY) AND ORDER BY +# +CREATE TABLE t1 (a INT); +INSERT t1 values (1),(2),(15),(24),(5); +CREATE TABLE t2 (t1_a INT, b VARCHAR(10)); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +EXPLAIN SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`t1_a`)) where true order by `test`.`t1`.`a` +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +a st_value +1 NULL +2 NULL +15 NULL +24 NULL +5 NULL +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +1 NULL +2 NULL +5 NULL +15 NULL +24 NULL +SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +DROP TABLE t1, t2; +# Bug #18898433: EXTREMELY SLOW PERFORMANCE WITH OUTER JOINS AND JOIN +# BUFFER. +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0),(2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1),(3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2),(4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`))) on((`test`.`t2`.`i` = `test`.`t1`.`i`)) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` join `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t2`.`i`))) on(((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`))) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t1`.`i`)) left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`)) where true +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 NULL NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t1, t2, t3, t4; +# +# Bug #26627181: WRONG RESULT WITH LEFT JOIN + DERIVED TABLES +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id`,2 AS `tall` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (2 is not null) +SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id id tall +1 1 2 +DROP TABLE t1, t2; +# +# Bug #23169204: Left join + merged derived table + group by = bad result +# +CREATE TABLE t1(doc text); +CREATE TABLE t2(a INTEGER DEFAULT NULL); +INSERT INTO t2 VALUES(1); +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE +GROUP BY je; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE +GROUP BY je; +je +NULL +DROP TABLE t1, t2; +# +# Bug#22489105 WL#9571 : SIG11 IN ITEM_SUBSELECT::EXEC | SQL/ITEM_SUBSELECT.CC +# +SELECT (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +a +SELECT (SELECT * FROM (SELECT 'a') t) + 1 AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +SELECT 1 + (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +# +# Bug#28237111: WL#9571: TABLE FULL ERROR +# +CREATE TABLE t1 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t2 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t3 (pk INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1); +INSERT INTO t2 VALUES (1,1),(2,1),(3,1); +INSERT INTO t3 VALUES (1); +SELECT * FROM (t1 RIGHT JOIN +(SELECT * FROM t3 WHERE (DAYNAME('1995'))) AS table2 ON +(( t1.f1 ,t1.pk) IN (SELECT 7,4 UNION SELECT 9,2))) WHERE +(NOT EXISTS (SELECT t1.f1 FROM (t1 INNER JOIN t2 ON (t1.pk=t2.f1)) +WHERE 0 IS NOT NULL)) AND t1.f1 > 50; +pk f1 pk +Warnings: +Warning 1292 Incorrect datetime value: '1995' +DROP TABLE t3,t1,t2; +# +# Bug#28341790: WL#9571: SIG11 IN ITEM_COND::FIX_FIELDS() AT SQL/ITEM_CMPFUNC.CC +# +CREATE TABLE t1 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " SELECT 1 FROM ( ( SELECT * FROM t1 WHERE col_varchar +>= 1 ) AS table1 RIGHT JOIN t2 ON ( ( NULL < NULL ) IS NULL OR 1 = 0 ) ) " ; +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +DROP TABLE t1,t2; +# +# More coverage for IS TRUE in LEFT JOIN conditions +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2(c2 INT); +INSERT INTO t2 VALUES(1); +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2; +c1 c2 +1 1 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NULL; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NOT NULL; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 1; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS TRUE; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 0; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS FALSE; +c1 c2 +2 NULL +DROP TABLE t1,t2; +# +# Bug#29402481: INCORRECT RESULT FROM OUTER JOIN QUERIES +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_unique int unique +) ENGINE=InnoDB; +INSERT INTO t1(col_int_unique) values (6),(7); +CREATE TABLE t2 ( +pk int primary key auto_increment, +col_int_key int(11) DEFAULT NULL, +col_int_unique int(11) DEFAULT NULL, +UNIQUE KEY `ix2` (col_int_key,col_int_unique), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int NOT NULL +) ENGINE=InnoDB; +INSERT INTO t3(pk) values (6),(7); +SELECT STRAIGHT_JOIN t1.col_int_unique, t2.col_int_key, t3.pk +FROM +(t1 LEFT JOIN t2 ON t1.col_int_unique = t2.col_int_key) +LEFT JOIN t3 ON t3.pk = t1.col_int_unique AND +t1.col_int_unique = t2.col_int_key; +col_int_unique col_int_key pk +6 NULL NULL +7 NULL NULL +DROP TABLE t1,t2,t3; +# +# Bug#29493830 CONST'IFIED OUTER JOIN RETURN INCORRECT RESULTS +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,0); +CREATE TABLE t2 ( +col_char_16_unique char(16) DEFAULT NULL, +col_int_key INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES ("just",21,5); +CREATE TABLE t3 ( +col_int INT DEFAULT NULL, +col_char_16_unique CHAR(16) DEFAULT NULL, +UNIQUE KEY col_char_16_unique (col_char_16_unique) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (9,"foo"); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (9,5); +explain SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const col_int_unique col_int_unique 5 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +1 SIMPLE t3 NULL const col_char_16_unique NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE t4 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `col_int`,NULL AS `col_int`,((NULL = NULL) or (NULL is null)) AS `t3.col_int = t4.col_int or t4.col_int IS NULL` from `test`.`t1` left join `test`.`t2` on((multiple equal('0', NULL) and multiple equal(5, NULL))) left join `test`.`t3` on(multiple equal(NULL, NULL)) left join `test`.`t4` on((multiple equal(NULL, NULL) and multiple equal(5, NULL))) where true +SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +col_int col_int t3.col_int = t4.col_int or t4.col_int IS NULL +NULL NULL 1 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30659532: WL#13476: DIFFERENT NUMBER OF ROWS WITH NESTED LOOP JOINS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t2 VALUES (3); +CREATE TABLE t3 ( +f1 INTEGER, +f2 INTEGER, +KEY k2 (f2) +); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,295010100); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,-1762438755); +INSERT INTO t3 VALUES (NULL,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.02 rows=2) + -> Nested loop inner join (cost=1.15 rows=2) + -> Filter: (t1.pk < 5) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.30 rows=1) + -> Index lookup on t3 using k2 (f2=t1.pk) (cost=0.38 rows=1) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +pk pk f1 f2 +1 1 NULL NULL +2 2 NULL NULL +DROP TABLE t1, t2, t3; +# +# Bug #30654713: WL#13476: DIFFERENT ROWS WITH BATCHED KEY ACCESS LEFT JOIN +# +CREATE TABLE t1 ( +col_int INTEGER, +a INTEGER, +b varchar(10), +KEY key_a (a) +); +INSERT INTO t1 VALUES (5,NULL,'p'); +INSERT INTO t1 VALUES (6,NULL,''); +INSERT INTO t1 VALUES (7,NULL,''); +INSERT INTO t1 VALUES (8,NULL,'Z'); +INSERT INTO t1 VALUES (9,4,'g'); +INSERT INTO t1 VALUES (10,NULL,'if'); +INSERT INTO t1 VALUES (11,NULL,'j'); +INSERT INTO t1 VALUES (12,9,''); +CREATE TABLE t2 ( +a INTEGER, +b varchar(10), +KEY key_b (b) +); +INSERT INTO t2 VALUES (1,'j'); +INSERT INTO t2 VALUES (2,'o'); +INSERT INTO t2 VALUES (3,'z'); +INSERT INTO t2 VALUES (4,'really'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.b = t1.b) (cost=23.25 rows=144) + -> PQblock scan on t1 (cost=1.05 rows=8) + -> Hash + -> Left hash join (t3.a = t2.a) (cost=3.70 rows=24) + -> Table scan on t2 (cost=0.08 rows=4) + -> Hash + -> Table scan on t3 (cost=0.04 rows=8) + +SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +t1_ci t1_a t1_b t2_a t2_b t3_ci t3_a t3_b +10 NULL if NULL NULL NULL NULL NULL +11 NULL j 1 j NULL NULL NULL +12 9 NULL NULL NULL NULL NULL +5 NULL p NULL NULL NULL NULL NULL +6 NULL NULL NULL NULL NULL NULL +7 NULL NULL NULL NULL NULL NULL +8 NULL Z 3 z NULL NULL NULL +9 4 g NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=4.50 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Zero rows (Impossible filter) (cost=0.07..0.35 rows=5) + +DROP TABLE t1, t2; +set optimizer_switch='block_nested_loop=on'; +# +# Bug #31252625: DATA IN WRONG ROW ON LEFT JOIN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER, +PRIMARY KEY (id) +); +INSERT INTO t1 VALUES (17,NULL); +INSERT INTO t1 VALUES (136,564); +INSERT INTO t1 VALUES (137,NULL); +CREATE TABLE t2 ( +id INTEGER NOT NULL, +PRIMARY KEY (id) +); +INSERT INTO t2 VALUES (564); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.id GROUP BY t1.id; +id b id +17 NULL NULL +136 564 564 +137 NULL NULL +DROP TABLE t1, t2; diff --git a/mysql-test/r/join_outer_bka.result-pq b/mysql-test/r/join_outer_bka.result-pq new file mode 100644 index 000000000..9cbbc7716 --- /dev/null +++ b/mysql-test/r/join_outer_bka.result-pq @@ -0,0 +1,3837 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +drop table if exists t0,t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +grp int(11) default NULL, +a bigint(20) unsigned default NULL, +c char(10) NOT NULL default '' +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,''); +create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a)); +insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7); +select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +EXPLAIN FORMAT=tree select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +EXPLAIN +-> Sort: t1.grp, t1.a, t2.c + -> Stream results (cost=3.67 rows=7) + -> Nested loop left join (cost=3.67 rows=7) + -> Table scan on t1 (cost=1.22 rows=7) + -> Single-row index lookup on t2 using PRIMARY (a=t1.a) (cost=0.26 rows=1) + +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +grp a c id a c d +NULL NULL NULL NULL NULL NULL +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) }; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 left join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 using (a,c); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (c); +grp a c id a c d +1 1 a 1 1 a 1 +1 1 a 3 4 A 4 +2 2 b 3 5 B 5 +2 3 c 3 6 C 6 +3 4 E NULL NULL NULL NULL +3 5 C 3 6 C 6 +3 6 D 4 7 D 7 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 natural left outer join t2; +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3; +grp a c id a c d +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null; +grp a c id a c d +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where false +explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`a` is null) = 1) +select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +grp a c id a c d a +1 1 a 1 1 a 1 1 +2 2 b NULL NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL NULL +3 4 E 3 4 A 4 4 +3 5 C 3 5 B 5 5 +3 6 D 3 6 C 6 6 +NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.* from t1 inner join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 natural join t2; +grp a c id a c d +1 1 a 1 1 a 1 +drop table t1,t2; +CREATE TABLE t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id) +); +CREATE TABLE t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id) +); +INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t1 +LEFT JOIN t2 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t2 +RIGHT JOIN t1 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +ERROR 23000: Duplicate entry '2-3' for key 't2.PRIMARY' +INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +drop table t1,t2; +CREATE TABLE t1 ( +cod_asig int(11) DEFAULT '0' NOT NULL, +desc_larga_cat varchar(80) DEFAULT '' NOT NULL, +desc_larga_cas varchar(80) DEFAULT '' NOT NULL, +desc_corta_cat varchar(40) DEFAULT '' NOT NULL, +desc_corta_cas varchar(40) DEFAULT '' NOT NULL, +cred_total double(3,1) DEFAULT '0.0' NOT NULL, +pre_requisit int(11), +co_requisit int(11), +preco_requisit int(11), +PRIMARY KEY (cod_asig) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL); +CREATE TABLE t2 ( +idAssignatura int(11) DEFAULT '0' NOT NULL, +Grup int(11) DEFAULT '0' NOT NULL, +Places smallint(6) DEFAULT '0' NOT NULL, +PlacesOcupades int(11) DEFAULT '0', +PRIMARY KEY (idAssignatura,Grup) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10360,12,333,0); +INSERT INTO t2 VALUES (10361,30,2,0); +INSERT INTO t2 VALUES (10361,40,3,0); +INSERT INTO t2 VALUES (10360,45,10,0); +INSERT INTO t2 VALUES (10362,10,12,0); +INSERT INTO t2 VALUES (10360,55,2,0); +INSERT INTO t2 VALUES (10360,70,0,0); +INSERT INTO t2 VALUES (10360,565656,0,0); +INSERT INTO t2 VALUES (10360,32767,7,0); +INSERT INTO t2 VALUES (10360,33,8,0); +INSERT INTO t2 VALUES (10360,7887,85,0); +INSERT INTO t2 VALUES (11405,88,8,0); +INSERT INTO t2 VALUES (10360,0,55,0); +INSERT INTO t2 VALUES (10360,99,0,0); +INSERT INTO t2 VALUES (11411,30,10,0); +INSERT INTO t2 VALUES (11404,0,0,0); +INSERT INTO t2 VALUES (10362,11,111,0); +INSERT INTO t2 VALUES (10363,33,333,0); +INSERT INTO t2 VALUES (11412,55,0,0); +INSERT INTO t2 VALUES (50003,66,6,0); +INSERT INTO t2 VALUES (11403,5,0,0); +INSERT INTO t2 VALUES (11406,11,11,0); +INSERT INTO t2 VALUES (11410,11410,131,0); +INSERT INTO t2 VALUES (11416,11416,32767,0); +INSERT INTO t2 VALUES (11409,0,0,0); +CREATE TABLE t3 ( +id int(11) NOT NULL auto_increment, +dni_pasaporte char(16) DEFAULT '' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +cod_asig int(11) DEFAULT '0' NOT NULL, +any smallint(6) DEFAULT '0' NOT NULL, +quatrimestre smallint(6) DEFAULT '0' NOT NULL, +estat char(1) DEFAULT 'M' NOT NULL, +PRIMARY KEY (id), +UNIQUE dni_pasaporte (dni_pasaporte,idPla), +UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M'); +CREATE TABLE t4 ( +id int(11) NOT NULL auto_increment, +papa int(11) DEFAULT '0' NOT NULL, +fill int(11) DEFAULT '0' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY papa (idPla,papa), +UNIQUE papa_2 (idPla,papa,fill) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,-1,10360,1); +INSERT INTO t4 VALUES (2,-1,10361,1); +INSERT INTO t4 VALUES (3,-1,10362,1); +SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1; +fill desc_larga_cat cred_total Grup Places PlacesOcupades +10360 asdfggfg 6.0 0 55 0 +10360 asdfggfg 6.0 12 333 0 +10360 asdfggfg 6.0 33 8 0 +10360 asdfggfg 6.0 45 10 0 +10360 asdfggfg 6.0 55 2 0 +10360 asdfggfg 6.0 7887 85 0 +10360 asdfggfg 6.0 32767 7 0 +10361 Components i Circuits Electronics I 6.0 30 2 0 +10361 Components i Circuits Electronics I 6.0 40 3 0 +10362 Laboratori d`Ordinadors 4.5 10 12 0 +10362 Laboratori d`Ordinadors 4.5 11 111 0 +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 NULL +10361 NULL +10362 NULL +INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S'); +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 1 +10361 NULL +10362 NULL +drop table t1,t2,t3,test.t4; +CREATE TABLE t1 ( +id smallint(5) unsigned NOT NULL auto_increment, +name char(60) DEFAULT '' NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'Antonio Paz'); +INSERT INTO t1 VALUES (2,'Lilliana Angelovska'); +INSERT INTO t1 VALUES (3,'Thimble Smith'); +CREATE TABLE t2 ( +id smallint(5) unsigned NOT NULL auto_increment, +owner smallint(5) unsigned DEFAULT '0' NOT NULL, +name char(60), +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1,'El Gato'); +INSERT INTO t2 VALUES (2,1,'Perrito'); +INSERT INTO t2 VALUES (3,3,'Happy'); +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t1 left join t2 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t2 right join t1 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +Lilliana Angelovska NULL NULL NULL +Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +NULL NULL NULL 2 +Thimble Smith Happy 3 3 +explain format=tree select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.20 rows=9) + -> PQblock scan on t3 using PRIMARY (cost=0.55 rows=3) + -> Nested loop inner join (cost=0.83 rows=3) + -> Single-row index lookup on t1 using PRIMARY (id=t3.id) (cost=0.28 rows=1) + -> Filter: (t2.`owner` = t3.id) (cost=0.18 rows=3) + -> Table scan on t2 (cost=0.18 rows=3) + +select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id owner id +Antonio Paz El Gato 1 1 1 +Antonio Paz Perrito 2 1 1 +NULL NULL NULL NULL 2 +Thimble Smith Happy 3 3 3 +drop table t1,t2; +create table t1 (id int not null, str char(10), index(str)); +insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar"); +select * from t1 where str is not null order by id; +id str +3 foo +4 bar +select * from t1 where str is null; +id str +1 NULL +2 NULL +explain select * from t1 where str is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref str str 41 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`str` AS `str` from `test`.`t1` where (`test`.`t1`.`str` is null) +explain format=tree select * from t1 where str is null; +EXPLAIN +-> Parallel scan on + -> PQblock lookup on t1 using str (str=NULL), with index condition: (t1.str is null) (cost=0.70 rows=2) + +drop table t1; +CREATE TABLE t1 ( +t1_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t2_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +t3_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t3_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_0_id (seq_0_id), +KEY seq_1_id (seq_1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_1_id (seq_1_id), +KEY seq_0_id (seq_0_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1); +insert into t2 values (1); +insert into t3 values (1); +insert into t4 values (1,1); +insert into t5 values (1,1); +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +ERROR 42S22: Unknown column 't2.t2_id' in 'on clause' +drop table t1,t2,t3,t4,t5; +create table t1 (n int, m int, o int, key(n)); +create table t2 (n int not null, m int, o int, primary key(n)); +insert into t1 values (1, 2, 11), (1, 2, 7), (2, 2, 8), (1,2,9),(1,3,9); +insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10); +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1; +n m o n m o +1 2 11 1 2 3 +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1 order by t1.o,t1.m; +n m o n m o +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +1 2 11 1 2 3 +drop table t1,t2; +CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT); +INSERT INTO t1 VALUES (1,'a',1); +INSERT INTO t1 VALUES (2,'b',1); +INSERT INTO t1 VALUES (3,'c',2); +CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1)); +INSERT INTO t2 VALUES (1,'x'); +INSERT INTO t2 VALUES (2,'y'); +INSERT INTO t2 VALUES (3,'z'); +SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL; +id2 +3 +SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL; +id2 +3 +drop table t1,t2; +create table t1 ( color varchar(20), name varchar(20) ); +insert into t1 values ( 'red', 'apple' ); +insert into t1 values ( 'yellow', 'banana' ); +insert into t1 values ( 'green', 'lime' ); +insert into t1 values ( 'black', 'grape' ); +insert into t1 values ( 'blue', 'blueberry' ); +create table t2 ( count int, color varchar(20) ); +insert into t2 values (10, 'green'); +insert into t2 values (5, 'black'); +insert into t2 values (15, 'white'); +insert into t2 values (7, 'green'); +select * from t1; +color name +red apple +yellow banana +green lime +black grape +blue blueberry +select * from t2; +count color +10 green +5 black +15 white +7 green +select * from t2 natural join t1; +color count name +black 5 grape +green 10 lime +green 7 lime +select t2.count, t1.name from t2 natural join t1; +count name +10 lime +5 grape +7 lime +select t2.count, t1.name from t2 inner join t1 using (color); +count name +10 lime +5 grape +7 lime +drop table t1; +drop table t2; +CREATE TABLE t1 ( +pcode varchar(8) DEFAULT '' NOT NULL +); +INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200'); +CREATE TABLE t2 ( +pcode varchar(8) DEFAULT '' NOT NULL, +KEY pcode (pcode) +); +INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000'); +SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 +LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11), +pid int(11), +rep_del tinyint(4), +KEY id (id), +KEY pid (pid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,NULL,NULL); +INSERT INTO t1 VALUES (2,1,NULL); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +create index rep_del ON t1(rep_del); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +drop table t1; +CREATE TABLE t1 ( +id int(11) DEFAULT '0' NOT NULL, +name tinytext DEFAULT '' NOT NULL, +UNIQUE id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'name' can't have a default value +INSERT INTO t1 VALUES (1,'yes'),(2,'no'); +CREATE TABLE t2 ( +id int(11) DEFAULT '0' NOT NULL, +idx int(11) DEFAULT '0' NOT NULL, +UNIQUE id (id,idx) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1); +explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ref id id 4 test.t1.id 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`idx` AS `idx` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id name id idx +2 no NULL NULL +drop table t1,t2; +SET sql_mode = default; +create table t1 (bug_id mediumint, reporter mediumint); +create table t2 (bug_id mediumint, who mediumint, index(who)); +insert into t2 values (1,1),(1,2); +insert into t1 values (1,1),(2,1); +SELECT * FROM t1 LEFT JOIN t2 ON (t1.bug_id = t2.bug_id AND t2.who = 2) WHERE (t1.reporter = 2 OR t2.who = 2); +bug_id reporter bug_id who +1 1 1 2 +drop table t1,t2; +create table t1 (fooID smallint unsigned auto_increment, primary key (fooID)); +create table t2 (fooID smallint unsigned not null, barID smallint unsigned not null, primary key (fooID,barID)); +insert into t1 (fooID) values (10),(20),(30); +insert into t2 values (10,1),(20,2),(30,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY PRIMARY 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fooID` AS `fooID`,`test`.`t2`.`barID` AS `barID`,`test`.`t1`.`fooID` AS `fooID` from `test`.`t2` left join `test`.`t1` on(((`test`.`t2`.`fooID` = 30) and (`test`.`t1`.`fooID` = 30))) where true +select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +drop table t1,t2; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values(2),(4); +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 natural left join t2 where (t2.i is not null)=0; +i +1 +select * from t1 natural left join t2 where (t2.i is not null) is not null; +i +1 +2 +select * from t1 natural left join t2 where (i is not null)=0; +i +select * from t1 natural left join t2 where (i is not null) is not null; +i +1 +2 +drop table t1,t2,t3; +create table t1 (f1 integer,f2 integer,f3 integer); +create table t2 (f2 integer,f4 integer); +create table t3 (f3 integer,f5 integer); +select * from t1 +left outer join t2 using (f2) +left outer join t3 using (f3); +f3 f2 f1 f4 f5 +drop table t1,t2,t3; +create table t1 (a1 int, a2 int); +create table t2 (b1 int not null, b2 int); +create table t3 (c1 int, c2 int); +insert into t1 values (1,2), (2,2), (3,2); +insert into t2 values (1,3), (2,3); +insert into t3 values (2,4), (3,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +a1 a2 b1 b2 c1 c2 +1 2 1 3 NULL NULL +2 2 2 3 NULL NULL +3 2 NULL NULL 3 4 +explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b1` = `test`.`t1`.`a1`)) left join `test`.`t3` on(((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` is null))) where true +drop table t1, t2, t3; +create table t1 ( +a int(11), +b char(10), +key (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (a) values (1),(2),(3),(4); +create table t2 (a int); +select * from t1 left join t2 on t1.a=t2.a where not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +select * from t1 left join t2 on t1.a=t2.a having not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +drop table t1,t2; +create table t1 ( +match_id tinyint(3) unsigned not null auto_increment, +home tinyint(3) unsigned default '0', +unique key match_id (match_id), +key match_id_2 (match_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values("1", "2"); +create table t2 ( +player_id tinyint(3) unsigned default '0', +match_1_h tinyint(3) unsigned default '0', +key player_id (player_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values("1", "5"); +insert into t2 values("2", "9"); +insert into t2 values("3", "3"); +insert into t2 values("4", "7"); +insert into t2 values("5", "6"); +insert into t2 values("6", "8"); +insert into t2 values("7", "4"); +insert into t2 values("8", "12"); +insert into t2 values("9", "11"); +insert into t2 values("10", "10"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by m.match_id desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `test`.`m`.`match_id` desc +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` straight_join `test`.`t1` `m` where (`test`.`m`.`match_id` = 1) order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +drop table t1, t2; +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); +select t1.a, t1.b, t2.c from t1 left join t2 +on t1.a=t2.a and t1.b=t2.b and t2.c=3 +where t1.a=1 and t2.c is null; +a b c +1 11 NULL +drop table t1, t2; +CREATE TABLE t1 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(111056548820001, 0, 'flag1', NULL), +(111056548820001, 0, 'flag2', NULL), +(2, 0, 'other_flag', NULL); +INSERT INTO t2 VALUES +(111056548820001, 3, 'flag1', 'sss'); +SELECT t1.flag_name,t2.flag_value +FROM t1 LEFT JOIN t2 +ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND +t2.inst_id = 3) +WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND +t2.flag_value IS NULL; +flag_name flag_value +flag2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int(11) unsigned NOT NULL auto_increment, +text_id int(10) unsigned default NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("1", "0"); +INSERT INTO t1 VALUES("2", "10"); +CREATE TABLE t2 ( +text_id char(3) NOT NULL default '', +language_id char(3) NOT NULL default '', +text_data text, +PRIMARY KEY (text_id,language_id) +); +INSERT INTO t2 VALUES("0", "EN", "0-EN"); +INSERT INTO t2 VALUES("0", "SV", "0-SV"); +INSERT INTO t2 VALUES("10", "EN", "10-EN"); +INSERT INTO t2 VALUES("10", "SV", "10-SV"); +SELECT t1.id, t1.text_id, t2.text_data +FROM t1 LEFT JOIN t2 +ON t1.text_id = t2.text_id +AND t2.language_id = 'SV' + WHERE (t1.id LIKE '%' OR t2.text_data LIKE '%'); +id text_id text_data +1 0 0-SV +2 10 10-SV +DROP TABLE t1, t2; +CREATE TABLE t0 (a0 int PRIMARY KEY); +CREATE TABLE t1 (a1 int PRIMARY KEY); +CREATE TABLE t2 (a2 int); +CREATE TABLE t3 (a3 int); +INSERT INTO t0 VALUES (1); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +a1 a2 +1 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +a1 a2 a3 +1 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a0 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a0` AS `a0`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t0`.`a0` = 0) and (`test`.`t1`.`a1` = 0))) where (`test`.`t1`.`a1` = `test`.`t0`.`a0`) +INSERT INTO t0 VALUES (0); +INSERT INTO t1 VALUES (0); +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a0`,'1' AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(false) where true +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +select straight_join * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +DROP TABLE t0,t1,t2,t3; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,2); +INSERT INTO t2 VALUES (1,2), (2,2); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t1.b=1; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE t1.b=1 XOR (NOT ISNULL(t2.a) AND t2.b=1); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +DROP TABLE t1,t2; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; +create table t1 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, art int(11) not null, primary key (gid,x,y)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t1 values (1, -5, -8, 2), (1, 2, 2, 1), (1, 1, 1, 1); +create table t2 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, id int(11) not null, primary key (gid,id,x,y), key id (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t2 values (1, -5, -8, 1), (1, 1, 1, 1), (1, 2, 2, 1); +create table t3 ( set_id smallint(5) unsigned not null, id tinyint(4) unsigned not null, name char(12) not null, primary key (id,set_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t3 values (0, 1, 'a'), (1, 1, 'b'), (0, 2, 'c'), (1, 2, 'd'), (1, 3, 'e'), (1, 4, 'f'), (1, 5, 'g'), (1, 6, 'h'); +explain select name from t1 left join t2 on t1.x = t2.x and t1.y = t2.y +left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8 +and t1.gid =1 and t2.gid =1 and t3.set_id =1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 10 const,const,const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY,id PRIMARY 14 const,const,const,const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 3 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'd' AS `name` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +drop tables t1,t2,t3; +CREATE TABLE t1 (EMPNUM INT, GRP INT); +INSERT INTO t1 VALUES (0, 10); +INSERT INTO t1 VALUES (2, 30); +CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5)); +INSERT INTO t2 VALUES (0, 'KERI'); +INSERT INTO t2 VALUES (9, 'BARRY'); +CREATE VIEW v1 AS +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP +FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM; +SELECT * FROM v1; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +SELECT * FROM v1 WHERE EMPNUM < 10; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +INSERT INTO t1 VALUES (30), (40), (50); +INSERT INTO t2 VALUES (300), (400), (500); +SELECT * FROM t1 LEFT JOIN t2 ON (c11=c21 AND c21=30) WHERE c11=40; +c11 c21 +40 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,2), (2,1), (3,2), (4,3), (5,6), (6,5), (7,8), (8,7), (9,10); +INSERT INTO t2 VALUES (3,0), (4,1), (6,4), (7,5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b <= t1.a AND t1.a <= t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a BETWEEN t2.b AND t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT BETWEEN t2.b AND t1.b); +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT BETWEEN t2.b AND t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a AND t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a AND (t2.b > t1.a OR t1.a > t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a OR t1.a BETWEEN t2.b AND t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT IN(t1.b, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b OR (t1.a != t2.a AND t1.a != t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b AND t1.a IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b AND t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b OR t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` in (`test`.`t2`.`a`,`test`.`t2`.`b`))) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b-2, t2.b, t2.b-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` > if((`test`.`t2`.`a` = (`test`.`t2`.`b` - 2)),`test`.`t2`.`b`,(`test`.`t2`.`b` - 1)))) +DROP TABLE t1,t2; +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; +SELECT v1.a, v2. b +FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) +GROUP BY v1.a; +a b +2 NULL +3 3 +SELECT v1.a, v2. b +FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } +GROUP BY v1.a; +a b +2 NULL +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); +a b +1 NULL +2 2 +3 3 +4 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f2 varchar(16) collate latin1_swedish_ci +); +CREATE TABLE t2 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f3 varchar(16) collate latin1_swedish_ci +); +INSERT INTO t1 VALUES ('bla','blah'); +INSERT INTO t2 VALUES ('bla','sheep'); +SELECT * FROM t1 JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8)); +CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id)); +INSERT INTO t1 VALUES +(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc'); +INSERT INTO t2 VALUES +(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL 9 11.11 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`b` is null) +flush status; +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id a +1 aaaaaaa +4 ddddddd +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 16 +DROP TABLE t1,t2; +CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL); +INSERT INTO t1 VALUES (1,0), (2,1); +CREATE TABLE t2 (d int PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 33.33 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `c`,'0' AS `e`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on(('0' <> 0)) where ((`test`.`t2`.`d` is null)) +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +c e d +1 0 NULL +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL; +c e d +1 0 NULL +DROP TABLE t1,t2; +# +# Bug#47650: using group by with rollup without indexes returns incorrect +# results with where +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( a INT, b INT ); +INSERT INTO t2 VALUES (1, 1),(1, 2),(1, 3),(2, 4),(2, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +DROP TABLE t1, t2; +# +# Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison +# +CREATE TABLE t1(f1 INT, f2 INT, f3 INT); +INSERT INTO t1 VALUES (1, NULL, 3); +CREATE TABLE t2(f1 INT, f2 INT); +INSERT INTO t2 VALUES (2, 1); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f2` = `test`.`t1`.`f2`)) where ((coalesce(`test`.`t1`.`f1`,`test`.`t2`.`f1`),`test`.`t1`.`f3`) in ((1,3),(2,2))) +SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +f1 f2 f3 f1 f2 +1 NULL 3 NULL NULL +DROP TABLE t1, t2; +# +# Bug#52357: Assertion failed: join->best_read in greedy_search +# optimizer_search_depth=0 +# +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1),(2); +SET optimizer_search_depth = 0; +# Should not core dump on query preparation +EXPLAIN +SELECT 1 +FROM t1 tt3 LEFT OUTER JOIN t1 tt4 ON 1 +LEFT OUTER JOIN t1 tt5 ON 1 +LEFT OUTER JOIN t1 tt6 ON 1 +LEFT OUTER JOIN t1 tt7 ON 1 +LEFT OUTER JOIN t1 tt8 ON 1 +RIGHT OUTER JOIN t1 tt2 ON 1 +RIGHT OUTER JOIN t1 tt1 ON 1 +STRAIGHT_JOIN t1 tt9 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tt1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE tt2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt5 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt6 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE tt9 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `tt1` left join (`test`.`t1` `tt2` left join (`test`.`t1` `tt3` left join `test`.`t1` `tt4` on(true) left join `test`.`t1` `tt5` on(true) left join `test`.`t1` `tt6` on(true) left join `test`.`t1` `tt7` on(true) left join `test`.`t1` `tt8` on(true)) on(true)) on(true) straight_join `test`.`t1` `tt9` where true +SET optimizer_search_depth = DEFAULT; +DROP TABLE t1; +# +# Bug#46091 STRAIGHT_JOIN + RIGHT JOIN returns different result +# +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +COUNT(*) +476 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 90.00 Parallel execute (1 workers) +2 SIMPLE ta2 NULL ALL NULL NULL NULL NULL 20 90.00 Using where +2 SIMPLE ta3 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE ta1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` `ta2` join `test`.`t2` `ta3` left join `test`.`t1` `ta1` on((0 <> `test`.`ta3`.`f1`)) where (0 <> `test`.`ta2`.`f1`) +DROP TABLE t1, t2; +# +# Bug#48971 Segfault in add_found_match_trig_cond () at sql_select.cc:5990 +# +CREATE TABLE t1(f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +LEFT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`)))) on(true) where true +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +RIGHT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`))) left join `test`.`t1` `jt1` on(true) where true +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = 4)) where true group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +4 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = 4) and (`test`.`t2`.`f2` is not null)) group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +DROP TABLE t1,t2; +# +# Bug#57034 incorrect OUTER JOIN result when joined on unique key +# +CREATE TABLE t1 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t1 VALUES (1,NULL,2), (2,0,0); +CREATE TABLE t2 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t2 VALUES (1,0,1), (2,0,2); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,NULL AS `col_int`,'2' AS `col_int_unique`,NULL AS `pk`,NULL AS `col_int`,NULL AS `col_int_unique` from `test`.`t1` left join `test`.`t2` on((multiple equal('2', NULL) and multiple equal(NULL, NULL))) where true +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +pk col_int col_int_unique pk col_int col_int_unique +1 NULL 2 NULL NULL NULL +DROP TABLE t1,t2; +# +# Bug#48046 Server incorrectly processing JOINs on NULL values +# +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_key` time DEFAULT NULL, +`varchar_key` varchar(1) DEFAULT NULL, +`varchar_nokey` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL); +SELECT table1.time_key AS field1, table2.pk +FROM BB table1 LEFT JOIN BB table2 +ON table2.varchar_nokey = table1.varchar_key +HAVING field1; +field1 pk +18:27:58 NULL +DROP TABLE BB; +# +# Bug#49600 Server incorrectly processing RIGHT JOIN with +# constant WHERE clause and no index +# +CREATE TABLE `BB` ( +`col_datetime_key` datetime DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_datetime_key` (`col_datetime_key`), +KEY `col_varchar_key` (`col_varchar_key`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL); +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +ALTER TABLE BB DISABLE KEYS; +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +DROP TABLE BB; +# +# Bug#58490: Incorrect result in multi level OUTER JOIN +# in combination with IS NULL +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0), (2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1), (3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2), (4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3) ; +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +WHERE t4.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i +2 NULL NULL +3 3 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN t4 +ON t4.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL 3 +4 NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 3 +4 NULL NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a, t4 AS t4b) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 0 +3 3 NULL 3 1 +3 3 NULL 3 2 +3 3 NULL 3 3 +4 NULL NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +# +# Bug#49322(Duplicate): Server is adding extra NULL row +# on processing a WHERE clause +# +CREATE TABLE h (pk INT NOT NULL, col_int_key INT); +INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8); +CREATE TABLE m (pk INT NOT NULL, col_int_key INT); +INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9); +CREATE TABLE k (pk INT NOT NULL, col_int_key INT); +INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5); +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key; +pk +2 +2 +4 +4 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key +WHERE TABLE1.pk IS NULL; +pk +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE h,m,k; +# +# Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY +# IS EXECUTED TWICE FROM P +# +CREATE TABLE t1 ( a INT ) ENGINE = MYISAM; +INSERT INTO t1 VALUES (1); +PREPARE prep_stmt FROM ' + SELECT 1 AS f FROM t1 + LEFT JOIN t1 t2 + RIGHT JOIN t1 t3 + JOIN t1 t4 + ON 1 + ON 1 + ON 1 + GROUP BY f'; +EXECUTE prep_stmt; +f +1 +EXECUTE prep_stmt; +f +1 +DROP TABLE t1; +End of 5.1 tests +# +# Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t1 VALUES (null),(null); +explain SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t3`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +a +explain SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` left join `test`.`t4` on(true)) on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t4`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +a +DROP TABLE t1,t2,t3,t4; +# +# Bug#56254 Assertion tab->ref.use_count fails in +# join_read_key_unlock_row() on 4-way JOIN +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_int INT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (6, -448724992, NULL); +CREATE TABLE t2 ( +col_int INT, +col_varchar_10 VARCHAR(10) +); +INSERT INTO t2 VALUES (6,'afasdkiyum'); +CREATE TABLE t3 ( +col_varchar_10 VARCHAR(10), +col_int INT +); +CREATE TABLE t4 ( +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1); +INSERT INTO t4 VALUES (2); +SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +col_int +EXPLAIN FORMAT=tree SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +EXPLAIN +-> Parallel scan on + -> Filter: (found_match(t3..t4), ((t1.col_int_key is null) or (t4.pk < t3.col_int)), true) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.col_int = t1.pk) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_varchar_10 = t2.col_varchar_10) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t3.col_int) (cost=0.35 rows=1) + +DROP TABLE t1,t2,t3,t4; + +# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN +# USED IN GROUP BY + +CREATE TABLE t1 (pk int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +PREPARE prep_stmt_9846 FROM ' +SELECT alias1.pk AS field1 FROM +t1 AS alias1 +LEFT JOIN +( + t1 AS alias2 + RIGHT JOIN + ( + t1 AS alias3 + JOIN t1 AS alias4 + ON 1 + ) + ON 1 +) +ON 1 +GROUP BY field1'; +execute prep_stmt_9846; +field1 +execute prep_stmt_9846; +field1 +deallocate prepare prep_stmt_9846; +drop table t1; +# +# Bug#13040136 - ASSERT IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +col_int_key INTEGER, +col_varchar_10_key VARCHAR(10), +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_10_key) +); +INSERT INTO t1 VALUES ('q',NULL,'o',1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar_10_key VARCHAR(10), +col_int_key INTEGER, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY (col_varchar_10_key), +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(1,'r',NULL,'would'),(2,'tell',-655032320,'t'), +(3,'d',9,'a'),(4,'gvafasdkiy',6,'ugvafasdki'), +(5,'that\'s',NULL,'she'),(6,'bwftwugvaf',7,'cbwftwugva'), +(7,'f',-700055552,'mkacbwftwu'),(8,'a',9,'be'), +(9,'d',NULL,'u'),(10,'ckiixcsxmk',NULL,'o'); +SELECT DISTINCT t2.col_int_key +FROM +t1 +LEFT JOIN t2 +ON t1.col_varchar_10 = t2.col_varchar_10_key +WHERE t2.pk +ORDER BY t2.col_int_key; +col_int_key +DROP TABLE t1,t2; +# +# Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS WRONG RESULT +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); +CREATE TABLE t3 (i4 int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(2); + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1;; +field1 +20 +20 + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1 GROUP BY field1;; +field1 +20 + +drop table t1,t2,t3; +# Bug#11766384 - 59487: WRONG RESULT WITH STRAIGHT_JOIN AND RIGHT JOIN +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1'); +CREATE TABLE t2 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 ( +pk int(11) NOT NULL, +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,1,1,'1'); +CREATE TABLE t5 ( +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t5 VALUES (1,'1'); +CREATE TABLE t6 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t6 VALUES (1,'1',1); +SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` join `test`.`t6` where ((`test`.`t5`.`col_int` = 1000) and ((0 <> `test`.`t6`.`col_int_key`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` left join `test`.`t6` on((`test`.`t5`.`col_int` = 1000)) where ((0 <> `test`.`t6`.`col_int_key`) is not true) +drop table t1,t2,t3,t4,t5,t6; +# +# Verify that the "not exists" optimization works. +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`a` is null) +FLUSH STATUS; +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +a a +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; +# +# Bug#13980954 Missing data on left join + null value + where..in +# +CREATE TABLE t1 (ik INT, vc varchar(1)) charset utf8mb4 ENGINE=Innodb; +explain format=json SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc", + "ik" + ], + "query_block": { + "cost_info": { + "query_cost": "1.05" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t1`.`vc`)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(is_not_null_compl(t3), (`test`.`t3`.`vc` = `test`.`t1`.`vc`), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`vc` AS `vc`,`test`.`t1`.`ik` AS `ik` from `test`.`t1` join `test`.`t1` `t2` left join `test`.`t1` `t3` on((`test`.`t3`.`vc` = `test`.`t1`.`vc`)) where (`test`.`t2`.`vc` = `test`.`t1`.`vc`) +SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +vc ik +DROP TABLE t1; +# +# Bug #18345786 CRASH AROUND ST_JOIN_TABLE::AND_WITH_CONDITION +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1), 1)); +DROP TABLE t1; +# +# Coverage for "unique row not found" +# +create table t1(a int, unique key(a)) engine=innodb; +insert into t1 values(1); +explain select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const a a 5 const 1 100.00 Using index +1 SIMPLE t2 NULL const a a 5 const 0 0.00 unique row not found +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,NULL AS `a` from `test`.`t1` left join `test`.`t1` `t2` on(multiple equal(12, NULL)) where true +select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +a a +1 NULL +drop table t1; +# +# Bug#18717059 MISSING ROWS ON NESTED JOIN WITH SUBQUERY +# WITH MYISAM OR MEMORY +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (23,4,'d'); +INSERT INTO t1 VALUES (24,8,'g'); +INSERT INTO t1 VALUES (25,NULL,'x'); +INSERT INTO t1 VALUES (26,NULL,'f'); +INSERT INTO t1 VALUES (27,0,'p'); +INSERT INTO t1 VALUES (28,NULL,'j'); +INSERT INTO t1 VALUES (29,8,'c'); +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +) ENGINE=MyISAM; +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +9 +9 +9 +9 +9 +9 +9 +9 +CREATE TABLE where_subselect_table AS +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +set optimizer_switch='condition_fanout_filter=on'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +set optimizer_switch='condition_fanout_filter=off'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +DROP TABLE t1, t2, where_subselect_table; +# Bug#14358878 Wrong results on table left join view +CREATE TABLE a (id INTEGER); +CREATE TABLE b (id INTEGER); +CREATE ALGORITHM=MERGE VIEW vmerge AS SELECT 1 AS id, id AS b_id FROM b; +CREATE ALGORITHM=TEMPTABLE VIEW vmat AS SELECT 1 AS id, id AS b_id FROM b; +INSERT INTO a(id) VALUES (1); +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmat AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT DISTINCT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION DISTINCT +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION ALL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +1 NULL NULL +DROP VIEW vmerge, vmat; +DROP TABLE a, b; +# Bug#15936817 Table left join view, unmatched rows problem where +# view contains an IF +CREATE TABLE small ( +id INTEGER not null, +PRIMARY KEY (id) +); +CREATE TABLE big ( +id INTEGER not null, +PRIMARY KEY (id) +); +INSERT INTO small VALUES (1), (2); +INSERT INTO big VALUES (1), (2), (3), (4); +CREATE VIEW small_view AS +SELECT *, IF (id % 2 = 1, 1, 0) AS is_odd +FROM small; +CREATE VIEW big_view AS +SELECT big.*, small_view.id AS small_id, small_view.is_odd +FROM big LEFT JOIN small_view ON small_view.id = big.id; +SELECT * FROM big_view; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +SELECT big.*, small.id AS small_id, small.is_odd +FROM big LEFT JOIN +(SELECT id, IF (id % 2 = 1, 1, 0) AS is_odd FROM small) AS small +ON big.id = small.id; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +# Check the IS NULL and thruth predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id IS NULL AS nul, +id IS NOT NULL AS nnul, +id IS TRUE AS t, +id IS NOT TRUE AS nt, +id IS FALSE AS f, +id IS NOT FALSE AS nf, +id IS UNKNOWN AS u, +id IS NOT UNKNOWN AS nu +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id nul nnul t nt f nf u nu +1 1 0 1 1 0 0 1 0 1 +2 2 0 1 1 0 0 1 0 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL NULL +# Check comparison predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id = 1 AS eq, +id <> 1 AS ne, +id > 1 AS gt, +id >= 1 AS ge, +id < 1 AS lt, +id <= 1 AS le, +id <=> 1 AS equal +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id eq ne gt ge lt le equal +1 1 1 0 0 1 0 1 1 +2 2 0 1 1 1 0 0 0 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +# Check CASE, NULLIF and COALESCE +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +CASE id WHEN 0 THEN 0 ELSE 1 END AS simple, +CASE WHEN id=0 THEN NULL ELSE 1 END AS cond, +NULLIF(1, NULL) AS nullif, +IFNULL(1, NULL) AS ifnull, +COALESCE(id) AS coal, +INTERVAL(NULL, 1, 2, 3) as intv, +IF (id % 2 = 1, NULL, 1) AS iff +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id simple cond nullif ifnull coal intv iff +1 1 1 1 1 1 1 -1 NULL +2 2 1 1 1 1 2 -1 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +DROP VIEW small_view, big_view; +DROP TABLE small, big; +# +# Bug#16893426 OPTIMIZER FAILS TO OPTIMIZE EXPRESSION OF THE +# FORM 'FOO' IS NULL +# +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +name varchar(20), +INDEX (name) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL PRIMARY KEY, +f_id int(11), +FOREIGN KEY (f_id) REFERENCES t2(id) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE "; +EXECUTE stmt; +id f_id id name +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' "; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DROP TABLE t1,t2; +# +# Bug#22103398 BUG#16893426:SIG11 IN +# ST_SELECT_LEX::FLATTEN_SUBQUERIES | SQL_RESOLVER.CC +# +CREATE TABLE t1(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +CREATE TABLE t2(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +SELECT b.c2 AS f1 FROM (t2 AS a JOIN +((t2 AS b JOIN t2 AS c ON (c.c3=b.c3))) +ON (c.c1=b.c2)) +WHERE (c.c3 IN (SELECT subquery1_b.c3 AS subquery1_f1 +FROM (t1 AS subquery1_a JOIN t2 AS subquery1_b ON +(subquery1_b.c1=subquery1_a.c1)))) AND +(a.c1=a.c1 AND (SELECT''FROM DUAL) IS NULL); +f1 +DROP TABLE t1, t2; +# End of Bug#16893426 +# Bug#22561937 Wrong result on outer join with multiple join conditions +# and derived table +CREATE TABLE t1 ( +col_int INT, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES +(2,1), (2,2), (6,3), (4,4), (7,5), +(188,6), (0,7), (6,8), (0,9), (9,10); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,0), (2,0), (3,2), (4,NULL), (5,2), +(6,3), (7,3), (8,100), (9,3), (10,6); +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join `test`.`t1` `table2` on(((`test`.`table2`.`pk` = `test`.`table1`.`col_int`) and (`test`.`table1`.`col_int` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join (`test`.`t1`) on(((`test`.`t1`.`pk` = `test`.`table1`.`col_int`) and (`test`.`t1`.`pk` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +DROP TABLE t1, t2; +# Bug#22671557: Wrong results on JOIN when composite index is present +CREATE TABLE t1 ( +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,col_int) +); +INSERT INTO t1 VALUES (0, -7, 1), (9, NULL, 15), (182, NULL, 25); +CREATE TABLE t2 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (NULL, 4), (-208, 5), (5, 6), (NULL, 75); +CREATE TABLE t3 ( +col_datetime_key DATETIME DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES ('1970-01-01 00:00:00', 5); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t4 VALUES (0, 15, 6), (9, 16, 6); +SELECT alias2.col_datetime_key +FROM +t1 AS alias1 +LEFT JOIN t3 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t4 AS alias4 +ON alias3.pk = alias4.col_int_key +ON alias2.pk = alias3.col_int +ON alias1.col_int = alias4.col_int +; +col_datetime_key +1970-01-01 00:00:00 +1970-01-01 00:00:00 +NULL +DROP TABLE t1, t2, t3, t4; +# Bug#22833364: Left join returns incorrect results on the outer side +CREATE TABLE ta ( +a1 varchar(1024) NOT NULL, +a2 int NOT NULL, +KEY user_id(a2) +); +INSERT INTO ta (a1, a2) VALUES ('row1', 4), ('row2', 4); +CREATE TABLE tb ( +b1 int NOT NULL, +b2 varchar(1024) NOT NULL, +b3 int NOT NULL, +PRIMARY KEY (b1) +); +INSERT INTO tb (b1, b2, b3) VALUES +(1, 'text1', 0), (2, 'text2', 0), (3, 'text3', 1), (4, 'text4', 1); +explain SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE ta NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tb NULL eq_ref PRIMARY PRIMARY 4 test.ta.a2 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ta`.`a1` AS `a1`,`test`.`tb`.`b1` AS `b1`,`test`.`tb`.`b2` AS `b2` from `test`.`ta` left join `test`.`tb` on(((`test`.`tb`.`b3` = 0) and (`test`.`tb`.`b1` = `test`.`ta`.`a2`))) where true +SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +a1 b1 b2 +row1 NULL NULL +row2 NULL NULL +DROP TABLE ta, tb; +# Bug#23079533: Left join on PK + extra condition doesn't return match +CREATE TABLE m ( +machineid VARCHAR(32) NOT NULL, +orderid bigint unsigned DEFAULT NULL, +extra bigint unsigned DEFAULT NULL, +PRIMARY KEY (machineid) +); +INSERT INTO m (machineid, orderid) +VALUES ('m1', NULL), ('m2', 2), ('m3', NULL), ('m4', NULL); +CREATE TABLE o ( +orderid bigint unsigned NOT NULL, +machineid VARCHAR(32) DEFAULT NULL, +PRIMARY KEY (orderid) +); +INSERT INTO o (orderid, machineid) +VALUES (1, 'm2'), (2, 'm2'); +SELECT o.*,'|' as sep, m.* +FROM o LEFT JOIN m +ON m.machineid = o.machineid AND +m.orderid = o.orderid; +orderid machineid sep machineid orderid extra +1 m2 | NULL NULL NULL +2 m2 | m2 2 NULL +DROP TABLE m, o; +# Bug#23086825: Incorrect query results using left join against derived +CREATE TABLE t1 ( +adslot varchar(5) NOT NULL +); +INSERT INTO t1(adslot) VALUES ('1'), ('2'), ('3'); +CREATE TABLE t2 ( +ionumber varchar(20) NOT NULL, +adslot varchar(5) NOT NULL +); +INSERT INTO t2 (ionumber, adslot) VALUES ('01602', 1), ('01602', 3); +CREATE TABLE t3 ( +ionumber varchar(20) NOT NULL, +ioattribute varchar(5) NOT NULL, +PRIMARY KEY (ionumber) +); +INSERT INTO t3 VALUES ('01602', 'BOB'), ('01603', 'SALLY'); +SELECT s.adslot, lid.ionumber1, lid.ionumber2, lid.ioattribute +FROM t1 s LEFT JOIN +(SELECT lid.adslot, +i.ionumber as ionumber1, +lid.ionumber as ionumber2, +i.ioattribute +FROM t2 lid JOIN t3 i +USING (ionumber) +) AS lid +USING (adslot); +adslot ionumber1 ionumber2 ioattribute +1 01602 01602 BOB +2 NULL NULL NULL +3 01602 01602 BOB +DROP TABLE t1, t2, t3; +# +# Bug #26432173: INCORRECT SUBQUERY OPTIMIZATION WITH +# LEFT JOIN(SUBQUERY) AND ORDER BY +# +CREATE TABLE t1 (a INT); +INSERT t1 values (1),(2),(15),(24),(5); +CREATE TABLE t2 (t1_a INT, b VARCHAR(10)); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +EXPLAIN SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`t1_a`)) where true order by `test`.`t1`.`a` +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +a st_value +1 NULL +2 NULL +15 NULL +24 NULL +5 NULL +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +1 NULL +2 NULL +5 NULL +15 NULL +24 NULL +SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +DROP TABLE t1, t2; +# Bug #18898433: EXTREMELY SLOW PERFORMANCE WITH OUTER JOINS AND JOIN +# BUFFER. +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0),(2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1),(3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2),(4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`))) on((`test`.`t2`.`i` = `test`.`t1`.`i`)) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` join `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t2`.`i`))) on(((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`))) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t1`.`i`)) left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`)) where true +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 NULL NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 4 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 20 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t1, t2, t3, t4; +# +# Bug #26627181: WRONG RESULT WITH LEFT JOIN + DERIVED TABLES +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id`,2 AS `tall` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (2 is not null) +SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id id tall +1 1 2 +DROP TABLE t1, t2; +# +# Bug #23169204: Left join + merged derived table + group by = bad result +# +CREATE TABLE t1(doc text); +CREATE TABLE t2(a INTEGER DEFAULT NULL); +INSERT INTO t2 VALUES(1); +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE +GROUP BY je; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE +GROUP BY je; +je +NULL +DROP TABLE t1, t2; +# +# Bug#22489105 WL#9571 : SIG11 IN ITEM_SUBSELECT::EXEC | SQL/ITEM_SUBSELECT.CC +# +SELECT (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +a +SELECT (SELECT * FROM (SELECT 'a') t) + 1 AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +SELECT 1 + (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +# +# Bug#28237111: WL#9571: TABLE FULL ERROR +# +CREATE TABLE t1 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t2 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t3 (pk INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1); +INSERT INTO t2 VALUES (1,1),(2,1),(3,1); +INSERT INTO t3 VALUES (1); +SELECT * FROM (t1 RIGHT JOIN +(SELECT * FROM t3 WHERE (DAYNAME('1995'))) AS table2 ON +(( t1.f1 ,t1.pk) IN (SELECT 7,4 UNION SELECT 9,2))) WHERE +(NOT EXISTS (SELECT t1.f1 FROM (t1 INNER JOIN t2 ON (t1.pk=t2.f1)) +WHERE 0 IS NOT NULL)) AND t1.f1 > 50; +pk f1 pk +Warnings: +Warning 1292 Incorrect datetime value: '1995' +DROP TABLE t3,t1,t2; +# +# Bug#28341790: WL#9571: SIG11 IN ITEM_COND::FIX_FIELDS() AT SQL/ITEM_CMPFUNC.CC +# +CREATE TABLE t1 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " SELECT 1 FROM ( ( SELECT * FROM t1 WHERE col_varchar +>= 1 ) AS table1 RIGHT JOIN t2 ON ( ( NULL < NULL ) IS NULL OR 1 = 0 ) ) " ; +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +DROP TABLE t1,t2; +# +# More coverage for IS TRUE in LEFT JOIN conditions +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2(c2 INT); +INSERT INTO t2 VALUES(1); +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2; +c1 c2 +1 1 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NULL; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NOT NULL; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 1; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS TRUE; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 0; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS FALSE; +c1 c2 +2 NULL +DROP TABLE t1,t2; +# +# Bug#29402481: INCORRECT RESULT FROM OUTER JOIN QUERIES +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_unique int unique +) ENGINE=InnoDB; +INSERT INTO t1(col_int_unique) values (6),(7); +CREATE TABLE t2 ( +pk int primary key auto_increment, +col_int_key int(11) DEFAULT NULL, +col_int_unique int(11) DEFAULT NULL, +UNIQUE KEY `ix2` (col_int_key,col_int_unique), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int NOT NULL +) ENGINE=InnoDB; +INSERT INTO t3(pk) values (6),(7); +SELECT STRAIGHT_JOIN t1.col_int_unique, t2.col_int_key, t3.pk +FROM +(t1 LEFT JOIN t2 ON t1.col_int_unique = t2.col_int_key) +LEFT JOIN t3 ON t3.pk = t1.col_int_unique AND +t1.col_int_unique = t2.col_int_key; +col_int_unique col_int_key pk +6 NULL NULL +7 NULL NULL +DROP TABLE t1,t2,t3; +# +# Bug#29493830 CONST'IFIED OUTER JOIN RETURN INCORRECT RESULTS +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,0); +CREATE TABLE t2 ( +col_char_16_unique char(16) DEFAULT NULL, +col_int_key INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES ("just",21,5); +CREATE TABLE t3 ( +col_int INT DEFAULT NULL, +col_char_16_unique CHAR(16) DEFAULT NULL, +UNIQUE KEY col_char_16_unique (col_char_16_unique) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (9,"foo"); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (9,5); +explain SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const col_int_unique col_int_unique 5 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +1 SIMPLE t3 NULL const col_char_16_unique NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE t4 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `col_int`,NULL AS `col_int`,((NULL = NULL) or (NULL is null)) AS `t3.col_int = t4.col_int or t4.col_int IS NULL` from `test`.`t1` left join `test`.`t2` on((multiple equal('0', NULL) and multiple equal(5, NULL))) left join `test`.`t3` on(multiple equal(NULL, NULL)) left join `test`.`t4` on((multiple equal(NULL, NULL) and multiple equal(5, NULL))) where true +SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +col_int col_int t3.col_int = t4.col_int or t4.col_int IS NULL +NULL NULL 1 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30659532: WL#13476: DIFFERENT NUMBER OF ROWS WITH NESTED LOOP JOINS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t2 VALUES (3); +CREATE TABLE t3 ( +f1 INTEGER, +f2 INTEGER, +KEY k2 (f2) +); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,295010100); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,-1762438755); +INSERT INTO t3 VALUES (NULL,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +EXPLAIN +-> Parallel scan on + -> Batched key access left join + -> Batch input rows + -> Nested loop inner join (cost=1.15 rows=2) + -> Filter: (t1.pk < 5) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.30 rows=1) + -> Multi-range index lookup on t3 using k2 (f2=t1.pk) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +pk pk f1 f2 +1 1 NULL NULL +2 2 NULL NULL +DROP TABLE t1, t2, t3; +# +# Bug #30654713: WL#13476: DIFFERENT ROWS WITH BATCHED KEY ACCESS LEFT JOIN +# +CREATE TABLE t1 ( +col_int INTEGER, +a INTEGER, +b varchar(10), +KEY key_a (a) +); +INSERT INTO t1 VALUES (5,NULL,'p'); +INSERT INTO t1 VALUES (6,NULL,''); +INSERT INTO t1 VALUES (7,NULL,''); +INSERT INTO t1 VALUES (8,NULL,'Z'); +INSERT INTO t1 VALUES (9,4,'g'); +INSERT INTO t1 VALUES (10,NULL,'if'); +INSERT INTO t1 VALUES (11,NULL,'j'); +INSERT INTO t1 VALUES (12,9,''); +CREATE TABLE t2 ( +a INTEGER, +b varchar(10), +KEY key_b (b) +); +INSERT INTO t2 VALUES (1,'j'); +INSERT INTO t2 VALUES (2,'o'); +INSERT INTO t2 VALUES (3,'z'); +INSERT INTO t2 VALUES (4,'really'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +EXPLAIN +-> Parallel scan on + -> Left hash join (t2.b = t1.b) (cost=23.25 rows=144) + -> PQblock scan on t1 (cost=1.05 rows=8) + -> Hash + -> Left hash join (t3.a = t2.a) (cost=3.70 rows=24) + -> Table scan on t2 (cost=0.08 rows=4) + -> Hash + -> Table scan on t3 (cost=0.04 rows=8) + +SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +t1_ci t1_a t1_b t2_a t2_b t3_ci t3_a t3_b +10 NULL if NULL NULL NULL NULL NULL +11 NULL j 1 j NULL NULL NULL +12 9 NULL NULL NULL NULL NULL +5 NULL p NULL NULL NULL NULL NULL +6 NULL NULL NULL NULL NULL NULL +7 NULL NULL NULL NULL NULL NULL +8 NULL Z 3 z NULL NULL NULL +9 4 g NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=4.50 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Zero rows (Impossible filter) (cost=0.07..0.35 rows=5) + +DROP TABLE t1, t2; +set optimizer_switch='block_nested_loop=on'; +# +# Bug #31252625: DATA IN WRONG ROW ON LEFT JOIN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER, +PRIMARY KEY (id) +); +INSERT INTO t1 VALUES (17,NULL); +INSERT INTO t1 VALUES (136,564); +INSERT INTO t1 VALUES (137,NULL); +CREATE TABLE t2 ( +id INTEGER NOT NULL, +PRIMARY KEY (id) +); +INSERT INTO t2 VALUES (564); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.id GROUP BY t1.id; +id b id +17 NULL NULL +136 564 564 +137 NULL NULL +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/join_outer_bka_nobnl.result-pq b/mysql-test/r/join_outer_bka_nobnl.result-pq new file mode 100644 index 000000000..71ea7d3b7 --- /dev/null +++ b/mysql-test/r/join_outer_bka_nobnl.result-pq @@ -0,0 +1,3834 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +drop table if exists t0,t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +grp int(11) default NULL, +a bigint(20) unsigned default NULL, +c char(10) NOT NULL default '' +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,''); +create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a)); +insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7); +select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +EXPLAIN FORMAT=tree select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +EXPLAIN +-> Sort: t1.grp, t1.a, t2.c + -> Stream results (cost=3.67 rows=7) + -> Nested loop left join (cost=3.67 rows=7) + -> Table scan on t1 (cost=1.22 rows=7) + -> Single-row index lookup on t2 using PRIMARY (a=t1.a) (cost=0.26 rows=1) + +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; +grp a c id a c d +NULL NULL NULL NULL NULL NULL +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) }; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 left join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a; +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 using (a,c); +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (c); +grp a c id a c d +1 1 a 1 1 a 1 +1 1 a 3 4 A 4 +2 2 b 3 5 B 5 +2 3 c 3 6 C 6 +3 4 E NULL NULL NULL NULL +3 5 C 3 6 C 6 +3 6 D 4 7 D 7 +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 natural left outer join t2; +grp a c id a c d +1 1 a 1 1 a 1 +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +3 4 E NULL NULL NULL NULL +3 5 C NULL NULL NULL NULL +3 6 D NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3; +grp a c id a c d +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null; +grp a c id a c d +2 2 b NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL +NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where false +explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 8 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`grp` AS `grp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where ((`test`.`t2`.`a` is null) = 1) +select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +grp a c id a c d a +1 1 a 1 1 a 1 1 +2 2 b NULL NULL NULL NULL NULL +2 3 c NULL NULL NULL NULL NULL +3 4 E 3 4 A 4 4 +3 5 C 3 5 B 5 5 +3 6 D 3 6 C 6 6 +NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +ERROR 42S22: Unknown column 't3.a' in 'on clause' +select t1.*,t2.* from t1 inner join t2 using (a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a); +grp a c id a c d +1 1 a 1 1 a 1 +3 4 E 3 4 A 4 +3 5 C 3 5 B 5 +3 6 D 3 6 C 6 +select t1.*,t2.* from t1 natural join t2; +grp a c id a c d +1 1 a 1 1 a 1 +drop table t1,t2; +CREATE TABLE t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id) +); +CREATE TABLE t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id) +); +INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t1 +LEFT JOIN t2 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t2 +RIGHT JOIN t1 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +ERROR 23000: Duplicate entry '2-3' for key 't2.PRIMARY' +INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +drop table t1,t2; +CREATE TABLE t1 ( +cod_asig int(11) DEFAULT '0' NOT NULL, +desc_larga_cat varchar(80) DEFAULT '' NOT NULL, +desc_larga_cas varchar(80) DEFAULT '' NOT NULL, +desc_corta_cat varchar(40) DEFAULT '' NOT NULL, +desc_corta_cas varchar(40) DEFAULT '' NOT NULL, +cred_total double(3,1) DEFAULT '0.0' NOT NULL, +pre_requisit int(11), +co_requisit int(11), +preco_requisit int(11), +PRIMARY KEY (cod_asig) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL); +CREATE TABLE t2 ( +idAssignatura int(11) DEFAULT '0' NOT NULL, +Grup int(11) DEFAULT '0' NOT NULL, +Places smallint(6) DEFAULT '0' NOT NULL, +PlacesOcupades int(11) DEFAULT '0', +PRIMARY KEY (idAssignatura,Grup) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (10360,12,333,0); +INSERT INTO t2 VALUES (10361,30,2,0); +INSERT INTO t2 VALUES (10361,40,3,0); +INSERT INTO t2 VALUES (10360,45,10,0); +INSERT INTO t2 VALUES (10362,10,12,0); +INSERT INTO t2 VALUES (10360,55,2,0); +INSERT INTO t2 VALUES (10360,70,0,0); +INSERT INTO t2 VALUES (10360,565656,0,0); +INSERT INTO t2 VALUES (10360,32767,7,0); +INSERT INTO t2 VALUES (10360,33,8,0); +INSERT INTO t2 VALUES (10360,7887,85,0); +INSERT INTO t2 VALUES (11405,88,8,0); +INSERT INTO t2 VALUES (10360,0,55,0); +INSERT INTO t2 VALUES (10360,99,0,0); +INSERT INTO t2 VALUES (11411,30,10,0); +INSERT INTO t2 VALUES (11404,0,0,0); +INSERT INTO t2 VALUES (10362,11,111,0); +INSERT INTO t2 VALUES (10363,33,333,0); +INSERT INTO t2 VALUES (11412,55,0,0); +INSERT INTO t2 VALUES (50003,66,6,0); +INSERT INTO t2 VALUES (11403,5,0,0); +INSERT INTO t2 VALUES (11406,11,11,0); +INSERT INTO t2 VALUES (11410,11410,131,0); +INSERT INTO t2 VALUES (11416,11416,32767,0); +INSERT INTO t2 VALUES (11409,0,0,0); +CREATE TABLE t3 ( +id int(11) NOT NULL auto_increment, +dni_pasaporte char(16) DEFAULT '' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +cod_asig int(11) DEFAULT '0' NOT NULL, +any smallint(6) DEFAULT '0' NOT NULL, +quatrimestre smallint(6) DEFAULT '0' NOT NULL, +estat char(1) DEFAULT 'M' NOT NULL, +PRIMARY KEY (id), +UNIQUE dni_pasaporte (dni_pasaporte,idPla), +UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M'); +CREATE TABLE t4 ( +id int(11) NOT NULL auto_increment, +papa int(11) DEFAULT '0' NOT NULL, +fill int(11) DEFAULT '0' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY papa (idPla,papa), +UNIQUE papa_2 (idPla,papa,fill) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,-1,10360,1); +INSERT INTO t4 VALUES (2,-1,10361,1); +INSERT INTO t4 VALUES (3,-1,10362,1); +SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1; +fill desc_larga_cat cred_total Grup Places PlacesOcupades +10360 asdfggfg 6.0 0 55 0 +10360 asdfggfg 6.0 12 333 0 +10360 asdfggfg 6.0 33 8 0 +10360 asdfggfg 6.0 45 10 0 +10360 asdfggfg 6.0 55 2 0 +10360 asdfggfg 6.0 7887 85 0 +10360 asdfggfg 6.0 32767 7 0 +10361 Components i Circuits Electronics I 6.0 30 2 0 +10361 Components i Circuits Electronics I 6.0 40 3 0 +10362 Laboratori d`Ordinadors 4.5 10 12 0 +10362 Laboratori d`Ordinadors 4.5 11 111 0 +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 NULL +10361 NULL +10362 NULL +INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S'); +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; +fill idPla +10360 1 +10361 NULL +10362 NULL +drop table t1,t2,t3,test.t4; +CREATE TABLE t1 ( +id smallint(5) unsigned NOT NULL auto_increment, +name char(60) DEFAULT '' NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'Antonio Paz'); +INSERT INTO t1 VALUES (2,'Lilliana Angelovska'); +INSERT INTO t1 VALUES (3,'Thimble Smith'); +CREATE TABLE t2 ( +id smallint(5) unsigned NOT NULL auto_increment, +owner smallint(5) unsigned DEFAULT '0' NOT NULL, +name char(60), +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1,'El Gato'); +INSERT INTO t2 VALUES (2,1,'Perrito'); +INSERT INTO t2 VALUES (3,3,'Happy'); +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t1 left join t2 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner); +name name id +Antonio Paz El Gato 1 +Antonio Paz Perrito 2 +Lilliana Angelovska NULL NULL +Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +name name id +Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`id` AS `id` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`owner` = `test`.`t1`.`id`)) where (`test`.`t2`.`name` is null) +select count(*) from t2 right join t1 on (t1.id = t2.owner); +count(*) +4 +select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +Lilliana Angelovska NULL NULL NULL +Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id id +Antonio Paz El Gato 1 1 +Antonio Paz Perrito 2 1 +NULL NULL NULL 2 +Thimble Smith Happy 3 3 +explain format=tree select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=2.20 rows=9) + -> PQblock scan on t3 using PRIMARY (cost=0.55 rows=3) + -> Nested loop inner join (cost=1.33 rows=3) + -> Single-row index lookup on t1 using PRIMARY (id=t3.id) (cost=0.28 rows=1) + -> Filter: (t2.`owner` = t3.id) (cost=0.35 rows=3) + -> Table scan on t2 (cost=0.35 rows=3) + +select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; +name name id owner id +Antonio Paz El Gato 1 1 1 +Antonio Paz Perrito 2 1 1 +NULL NULL NULL NULL 2 +Thimble Smith Happy 3 3 3 +drop table t1,t2; +create table t1 (id int not null, str char(10), index(str)); +insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar"); +select * from t1 where str is not null order by id; +id str +3 foo +4 bar +select * from t1 where str is null; +id str +1 NULL +2 NULL +explain select * from t1 where str is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref str str 41 const 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`str` AS `str` from `test`.`t1` where (`test`.`t1`.`str` is null) +explain format=tree select * from t1 where str is null; +EXPLAIN +-> Parallel scan on + -> PQblock lookup on t1 using str (str=NULL), with index condition: (t1.str is null) (cost=0.70 rows=2) + +drop table t1; +CREATE TABLE t1 ( +t1_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +t2_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t2_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +t3_id bigint(21) NOT NULL auto_increment, +PRIMARY KEY (t3_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_0_id (seq_0_id), +KEY seq_1_id (seq_1_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_1_id (seq_1_id), +KEY seq_0_id (seq_0_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1); +insert into t2 values (1); +insert into t3 values (1); +insert into t4 values (1,1); +insert into t5 values (1,1); +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +ERROR 42S22: Unknown column 't2.t2_id' in 'on clause' +drop table t1,t2,t3,t4,t5; +create table t1 (n int, m int, o int, key(n)); +create table t2 (n int not null, m int, o int, primary key(n)); +insert into t1 values (1, 2, 11), (1, 2, 7), (2, 2, 8), (1,2,9),(1,3,9); +insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10); +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1; +n m o n m o +1 2 11 1 2 3 +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1 order by t1.o,t1.m; +n m o n m o +1 2 7 1 2 3 +1 2 9 1 2 3 +1 3 9 NULL NULL NULL +1 2 11 1 2 3 +drop table t1,t2; +CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT); +INSERT INTO t1 VALUES (1,'a',1); +INSERT INTO t1 VALUES (2,'b',1); +INSERT INTO t1 VALUES (3,'c',2); +CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1)); +INSERT INTO t2 VALUES (1,'x'); +INSERT INTO t2 VALUES (2,'y'); +INSERT INTO t2 VALUES (3,'z'); +SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL; +id2 +3 +SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL; +id2 +3 +drop table t1,t2; +create table t1 ( color varchar(20), name varchar(20) ); +insert into t1 values ( 'red', 'apple' ); +insert into t1 values ( 'yellow', 'banana' ); +insert into t1 values ( 'green', 'lime' ); +insert into t1 values ( 'black', 'grape' ); +insert into t1 values ( 'blue', 'blueberry' ); +create table t2 ( count int, color varchar(20) ); +insert into t2 values (10, 'green'); +insert into t2 values (5, 'black'); +insert into t2 values (15, 'white'); +insert into t2 values (7, 'green'); +select * from t1; +color name +red apple +yellow banana +green lime +black grape +blue blueberry +select * from t2; +count color +10 green +5 black +15 white +7 green +select * from t2 natural join t1; +color count name +black 5 grape +green 10 lime +green 7 lime +select t2.count, t1.name from t2 natural join t1; +count name +10 lime +5 grape +7 lime +select t2.count, t1.name from t2 inner join t1 using (color); +count name +10 lime +5 grape +7 lime +drop table t1; +drop table t2; +CREATE TABLE t1 ( +pcode varchar(8) DEFAULT '' NOT NULL +); +INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200'); +CREATE TABLE t2 ( +pcode varchar(8) DEFAULT '' NOT NULL, +KEY pcode (pcode) +); +INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000'); +SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 +LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; +pcode count +kld2000 1 +klw1000 0 +klw1020 0 +klw1500 0 +klw2000 0 +klw2001 0 +klw2002 0 +klw2500 0 +kmw1000 0 +kmw1500 0 +kmw2000 0 +kmw2001 0 +kmw2100 0 +kmw3000 0 +kmw3200 0 +kvw2000 26 +kvw2001 0 +kvw3000 36 +kvw3001 0 +kvw3002 0 +kvw3500 26 +kvw3501 0 +kvw3502 0 +kvw3800 0 +kvw3801 0 +kvw3802 0 +kvw3900 0 +kvw3901 0 +kvw3902 0 +kvw4000 0 +kvw4001 0 +kvw4002 0 +kvw4200 0 +kvw4500 0 +kvw5000 0 +kvw5001 0 +kvw5500 0 +kvw5510 0 +kvw5600 0 +kvw5601 0 +kvw6000 2 +drop table t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(11), +pid int(11), +rep_del tinyint(4), +KEY id (id), +KEY pid (pid) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,NULL,NULL); +INSERT INTO t1 VALUES (2,1,NULL); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +create index rep_del ON t1(rep_del); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; +id pid rep_del id pid rep_del +1 NULL NULL 2 1 NULL +2 1 NULL NULL NULL NULL +drop table t1; +CREATE TABLE t1 ( +id int(11) DEFAULT '0' NOT NULL, +name tinytext DEFAULT '' NOT NULL, +UNIQUE id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'name' can't have a default value +INSERT INTO t1 VALUES (1,'yes'),(2,'no'); +CREATE TABLE t2 ( +id int(11) DEFAULT '0' NOT NULL, +idx int(11) DEFAULT '0' NOT NULL, +UNIQUE id (id,idx) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,1); +explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ref id id 4 test.t1.id 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name`,`test`.`t2`.`id` AS `id`,`test`.`t2`.`idx` AS `idx` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`id` is null) +SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; +id name id idx +2 no NULL NULL +drop table t1,t2; +SET sql_mode = default; +create table t1 (bug_id mediumint, reporter mediumint); +create table t2 (bug_id mediumint, who mediumint, index(who)); +insert into t2 values (1,1),(1,2); +insert into t1 values (1,1),(2,1); +SELECT * FROM t1 LEFT JOIN t2 ON (t1.bug_id = t2.bug_id AND t2.who = 2) WHERE (t1.reporter = 2 OR t2.who = 2); +bug_id reporter bug_id who +1 1 1 2 +drop table t1,t2; +create table t1 (fooID smallint unsigned auto_increment, primary key (fooID)); +create table t2 (fooID smallint unsigned not null, barID smallint unsigned not null, primary key (fooID,barID)); +insert into t1 (fooID) values (10),(20),(30); +insert into t2 values (10,1),(20,2),(30,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY PRIMARY 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fooID` AS `fooID`,`test`.`t2`.`barID` AS `barID`,`test`.`t1`.`fooID` AS `fooID` from `test`.`t2` left join `test`.`t1` on(((`test`.`t2`.`fooID` = 30) and (`test`.`t1`.`fooID` = 30))) where true +select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30; +fooID barID fooID +10 1 NULL +20 2 NULL +30 3 30 +drop table t1,t2; +create table t1 (i int); +create table t2 (i int); +create table t3 (i int); +insert into t1 values(1),(2); +insert into t2 values(2),(3); +insert into t3 values(2),(4); +select * from t1 natural left join t2 natural left join t3; +i +1 +2 +select * from t1 natural left join t2 where (t2.i is not null)=0; +i +1 +select * from t1 natural left join t2 where (t2.i is not null) is not null; +i +1 +2 +select * from t1 natural left join t2 where (i is not null)=0; +i +select * from t1 natural left join t2 where (i is not null) is not null; +i +1 +2 +drop table t1,t2,t3; +create table t1 (f1 integer,f2 integer,f3 integer); +create table t2 (f2 integer,f4 integer); +create table t3 (f3 integer,f5 integer); +select * from t1 +left outer join t2 using (f2) +left outer join t3 using (f3); +f3 f2 f1 f4 f5 +drop table t1,t2,t3; +create table t1 (a1 int, a2 int); +create table t2 (b1 int not null, b2 int); +create table t3 (c1 int, c2 int); +insert into t1 values (1,2), (2,2), (3,2); +insert into t2 values (1,3), (2,3); +insert into t3 values (2,4), (3,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +a1 a2 b1 b2 c1 c2 +1 2 1 3 NULL NULL +2 2 2 3 NULL NULL +3 2 NULL NULL 3 4 +explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b1` = `test`.`t1`.`a1`)) left join `test`.`t3` on(((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` is null))) where true +drop table t1, t2, t3; +create table t1 ( +a int(11), +b char(10), +key (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (a) values (1),(2),(3),(4); +create table t2 (a int); +select * from t1 left join t2 on t1.a=t2.a where not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +select * from t1 left join t2 on t1.a=t2.a having not (t2.a <=> t1.a); +a b a +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +drop table t1,t2; +create table t1 ( +match_id tinyint(3) unsigned not null auto_increment, +home tinyint(3) unsigned default '0', +unique key match_id (match_id), +key match_id_2 (match_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values("1", "2"); +create table t2 ( +player_id tinyint(3) unsigned default '0', +match_1_h tinyint(3) unsigned default '0', +key player_id (player_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values("1", "5"); +insert into t2 values("2", "9"); +insert into t2 values("3", "3"); +insert into t2 values("4", "7"); +insert into t2 values("5", "6"); +insert into t2 values("6", "8"); +insert into t2 values("7", "4"); +insert into t2 values("8", "12"); +insert into t2 values("9", "11"); +insert into t2 values("10", "10"); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by m.match_id desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `test`.`m`.`match_id` desc +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` left join `test`.`t1` `m` on((`test`.`m`.`match_id` = 1)) where true order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +(t2 s left join t1 m on m.match_id = 1) +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE s NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary; Using filesort +2 SIMPLE m NULL const match_id,match_id_2 match_id 1 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`player_id` AS `player_id`,`test`.`s`.`match_1_h` AS `match_1_h`,'*' AS `*`,`test`.`m`.`match_id` AS `match_id`,`test`.`m`.`home` AS `home`,(`test`.`s`.`match_1_h` - `test`.`m`.`home`) AS `UUX` from `test`.`t2` `s` straight_join `test`.`t1` `m` where (`test`.`m`.`match_id` = 1) order by `UUX` desc +select s.*, '*', m.*, (s.match_1_h - m.home) UUX from +t2 s straight_join t1 m where m.match_id = 1 +order by UUX desc; +player_id match_1_h * match_id home UUX +8 12 * 1 2 10 +9 11 * 1 2 9 +10 10 * 1 2 8 +2 9 * 1 2 7 +6 8 * 1 2 6 +4 7 * 1 2 5 +5 6 * 1 2 4 +1 5 * 1 2 3 +7 4 * 1 2 2 +3 3 * 1 2 1 +drop table t1, t2; +create table t1 (a int, b int, unique index idx (a, b)); +create table t2 (a int, b int, c int, unique index idx (a, b)); +insert into t1 values (1, 10), (1,11), (2,10), (2,11); +insert into t2 values (1,10,3); +select t1.a, t1.b, t2.c from t1 left join t2 +on t1.a=t2.a and t1.b=t2.b and t2.c=3 +where t1.a=1 and t2.c is null; +a b c +1 11 NULL +drop table t1, t2; +CREATE TABLE t1 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +ts_id bigint(20) default NULL, +inst_id tinyint(4) default NULL, +flag_name varchar(64) default NULL, +flag_value text, +UNIQUE KEY ts_id (ts_id,inst_id,flag_name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(111056548820001, 0, 'flag1', NULL), +(111056548820001, 0, 'flag2', NULL), +(2, 0, 'other_flag', NULL); +INSERT INTO t2 VALUES +(111056548820001, 3, 'flag1', 'sss'); +SELECT t1.flag_name,t2.flag_value +FROM t1 LEFT JOIN t2 +ON (t1.ts_id = t2.ts_id AND t1.flag_name = t2.flag_name AND +t2.inst_id = 3) +WHERE t1.inst_id = 0 AND t1.ts_id=111056548820001 AND +t2.flag_value IS NULL; +flag_name flag_value +flag2 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int(11) unsigned NOT NULL auto_increment, +text_id int(10) unsigned default NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("1", "0"); +INSERT INTO t1 VALUES("2", "10"); +CREATE TABLE t2 ( +text_id char(3) NOT NULL default '', +language_id char(3) NOT NULL default '', +text_data text, +PRIMARY KEY (text_id,language_id) +); +INSERT INTO t2 VALUES("0", "EN", "0-EN"); +INSERT INTO t2 VALUES("0", "SV", "0-SV"); +INSERT INTO t2 VALUES("10", "EN", "10-EN"); +INSERT INTO t2 VALUES("10", "SV", "10-SV"); +SELECT t1.id, t1.text_id, t2.text_data +FROM t1 LEFT JOIN t2 +ON t1.text_id = t2.text_id +AND t2.language_id = 'SV' + WHERE (t1.id LIKE '%' OR t2.text_data LIKE '%'); +id text_id text_data +1 0 0-SV +2 10 10-SV +DROP TABLE t1, t2; +CREATE TABLE t0 (a0 int PRIMARY KEY); +CREATE TABLE t1 (a1 int PRIMARY KEY); +CREATE TABLE t2 (a2 int); +CREATE TABLE t3 (a3 int); +INSERT INTO t0 VALUES (1); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); +SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +a1 a2 +1 NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +a1 a2 a3 +1 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN (t2,t3) ON a1=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on((`test`.`t1`.`a1` = 0)) where true +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=0 WHERE a0=a1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t0 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a0 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a0` AS `a0`,`test`.`t1`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t0`.`a0` = 0) and (`test`.`t1`.`a1` = 0))) where (`test`.`t1`.`a1` = `test`.`t0`.`a0`) +INSERT INTO t0 VALUES (0); +INSERT INTO t1 VALUES (0); +SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +a0 a1 a2 a3 +1 1 NULL NULL +EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a0`,'1' AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t3`.`a3` AS `a3` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(false) where true +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +select straight_join * from t2 right join t1 on t2.a=t1.a; +a b a b +1 1 1 1 +2 2 2 2 +NULL NULL 3 3 +DROP TABLE t0,t1,t2,t3; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,2); +INSERT INTO t2 VALUES (1,2), (2,2); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t1.b=1; +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +WHERE t1.b=1 XOR (NOT ISNULL(t2.a) AND t2.b=1); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); +a b a b +1 1 1 2 +2 1 2 2 +3 1 NULL NULL +4 2 NULL NULL +DROP TABLE t1,t2; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; +create table t1 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, art int(11) not null, primary key (gid,x,y)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t1 values (1, -5, -8, 2), (1, 2, 2, 1), (1, 1, 1, 1); +create table t2 (gid smallint(5) unsigned not null, x int(11) not null, y int(11) not null, id int(11) not null, primary key (gid,id,x,y), key id (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t2 values (1, -5, -8, 1), (1, 1, 1, 1), (1, 2, 2, 1); +create table t3 ( set_id smallint(5) unsigned not null, id tinyint(4) unsigned not null, name char(12) not null, primary key (id,set_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert t3 values (0, 1, 'a'), (1, 1, 'b'), (0, 2, 'c'), (1, 2, 'd'), (1, 3, 'e'), (1, 4, 'f'), (1, 5, 'g'), (1, 6, 'h'); +explain select name from t1 left join t2 on t1.x = t2.x and t1.y = t2.y +left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8 +and t1.gid =1 and t2.gid =1 and t3.set_id =1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 10 const,const,const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY,id PRIMARY 14 const,const,const,const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 3 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'd' AS `name` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +drop tables t1,t2,t3; +CREATE TABLE t1 (EMPNUM INT, GRP INT); +INSERT INTO t1 VALUES (0, 10); +INSERT INTO t1 VALUES (2, 30); +CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5)); +INSERT INTO t2 VALUES (0, 'KERI'); +INSERT INTO t2 VALUES (9, 'BARRY'); +CREATE VIEW v1 AS +SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP +FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM; +SELECT * FROM v1; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +SELECT * FROM v1 WHERE EMPNUM < 10; +EMPNUM NAME GRP +0 KERI 10 +9 BARRY NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (c11 int); +CREATE TABLE t2 (c21 int); +INSERT INTO t1 VALUES (30), (40), (50); +INSERT INTO t2 VALUES (300), (400), (500); +SELECT * FROM t1 LEFT JOIN t2 ON (c11=c21 AND c21=30) WHERE c11=40; +c11 c21 +40 NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +CREATE TABLE t2 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (1,2), (2,1), (3,2), (4,3), (5,6), (6,5), (7,8), (8,7), (9,10); +INSERT INTO t2 VALUES (3,0), (4,1), (6,4), (7,5); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b <= t1.a AND t1.a <= t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a BETWEEN t2.b AND t1.b; +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT BETWEEN t2.b AND t1.b); +a b a b +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT BETWEEN t2.b AND t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t2.b > t1.a OR t1.a > t1.b; +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a AND t1.a BETWEEN t2.b AND t1.b); +a b a b +2 1 NULL NULL +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +8 7 NULL NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a AND (t2.b > t1.a OR t1.a > t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a != t2.a OR t1.a BETWEEN t2.b AND t1.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a NOT IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a NOT IN(t1.b, t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b OR (t1.a != t2.a AND t1.a != t2.b); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b AND t1.a IN(t2.a, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t2.a != t2.b AND t1.a != t1.b AND t1.a != t2.b; +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE NOT(t2.a = t2.b OR t1.a IN(t1.b, t2.b)); +a b a b +3 2 3 0 +4 3 4 1 +6 5 6 4 +7 8 7 5 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` in (`test`.`t2`.`a`,`test`.`t2`.`b`))) +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b-2, t2.b, t2.b-1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` > if((`test`.`t2`.`a` = (`test`.`t2`.`b` - 2)),`test`.`t2`.`b`,(`test`.`t2`.`b` - 1)))) +DROP TABLE t1,t2; +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (a int); +CREATE table t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (1), (1), (3); +INSERT INTO t2 VALUES (2), (3); +CREATE VIEW v1 AS SELECT a FROM t1 JOIN t2 ON t1.a=t2.b; +CREATE VIEW v2 AS SELECT b FROM t2 JOIN t1 ON t2.b=t1.a; +SELECT v1.a, v2. b +FROM v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) +GROUP BY v1.a; +a b +2 NULL +3 3 +SELECT v1.a, v2. b +FROM { OJ v1 LEFT OUTER JOIN v2 ON (v1.a=v2.b) AND (v1.a >= 3) } +GROUP BY v1.a; +a b +2 NULL +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (2), (3); +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2); +a b +1 NULL +2 2 +3 3 +4 NULL +SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0); +a b +1 NULL +2 2 +3 3 +4 NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f2 varchar(16) collate latin1_swedish_ci +); +CREATE TABLE t2 ( +f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY, +f3 varchar(16) collate latin1_swedish_ci +); +INSERT INTO t1 VALUES ('bla','blah'); +INSERT INTO t2 VALUES ('bla','sheep'); +SELECT * FROM t1 JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='bla'; +f1 f2 f3 +bla blah sheep +SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla'; +f1 f2 f3 +bla blah sheep +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8)); +CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id)); +INSERT INTO t1 VALUES +(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc'); +INSERT INTO t2 VALUES +(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref idx idx 4 test.t1.id 3 11.11 Using where; Not exists; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (`test`.`t2`.`b` is null) +flush status; +SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +id a +1 aaaaaaa +4 ddddddd +show status like 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 9 +Handler_read_last 0 +Handler_read_next 9 +Handler_read_prev 0 +Handler_read_rnd 3 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +CREATE TABLE t1 (c int PRIMARY KEY, e int NOT NULL); +INSERT INTO t1 VALUES (1,0), (2,1); +CREATE TABLE t2 (d int PRIMARY KEY); +INSERT INTO t2 VALUES (1), (2), (3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 33.33 Using where; Not exists; Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `c`,'0' AS `e`,`test`.`t2`.`d` AS `d` from `test`.`t1` left join `test`.`t2` on(('0' <> 0)) where ((`test`.`t2`.`d` is null)) +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d IS NULL; +c e d +1 0 NULL +SELECT * FROM t1 LEFT JOIN t2 ON e<>0 WHERE c=1 AND d<=>NULL; +c e d +1 0 NULL +DROP TABLE t1,t2; +# +# Bug#47650: using group by with rollup without indexes returns incorrect +# results with where +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( a INT, b INT ); +INSERT INTO t2 VALUES (1, 1),(1, 2),(1, 3),(2, 4),(2, 5); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 LEFT JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +EXPLAIN +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select rollup_group_item(`test`.`t1`.`a`,0) AS `a`,rollup_sum_switcher(count(`test`.`t2`.`b`)) AS `COUNT( t2.b )`,rollup_sum_switcher(sum(`test`.`t2`.`b`)) AS `SUM( t2.b )`,rollup_sum_switcher(max(`test`.`t2`.`b`)) AS `MAX( t2.b )` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` with rollup +SELECT t1.a, COUNT( t2.b ), SUM( t2.b ), MAX( t2.b ) +FROM t1 JOIN t2 USING( a ) +GROUP BY t1.a WITH ROLLUP; +a COUNT( t2.b ) SUM( t2.b ) MAX( t2.b ) +1 3 6 3 +NULL 3 6 3 +DROP TABLE t1, t2; +# +# Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison +# +CREATE TABLE t1(f1 INT, f2 INT, f3 INT); +INSERT INTO t1 VALUES (1, NULL, 3); +CREATE TABLE t2(f1 INT, f2 INT); +INSERT INTO t2 VALUES (2, 1); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f2` = `test`.`t1`.`f2`)) where ((coalesce(`test`.`t1`.`f1`,`test`.`t2`.`f1`),`test`.`t1`.`f3`) in ((1,3),(2,2))) +SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 +WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); +f1 f2 f3 f1 f2 +1 NULL 3 NULL NULL +DROP TABLE t1, t2; +# +# Bug#52357: Assertion failed: join->best_read in greedy_search +# optimizer_search_depth=0 +# +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1),(2); +SET optimizer_search_depth = 0; +# Should not core dump on query preparation +EXPLAIN +SELECT 1 +FROM t1 tt3 LEFT OUTER JOIN t1 tt4 ON 1 +LEFT OUTER JOIN t1 tt5 ON 1 +LEFT OUTER JOIN t1 tt6 ON 1 +LEFT OUTER JOIN t1 tt7 ON 1 +LEFT OUTER JOIN t1 tt8 ON 1 +RIGHT OUTER JOIN t1 tt2 ON 1 +RIGHT OUTER JOIN t1 tt1 ON 1 +STRAIGHT_JOIN t1 tt9 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tt1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE tt2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE tt3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE tt4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE tt5 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE tt6 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE tt7 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE tt8 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE tt9 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `tt1` left join (`test`.`t1` `tt2` left join (`test`.`t1` `tt3` left join `test`.`t1` `tt4` on(true) left join `test`.`t1` `tt5` on(true) left join `test`.`t1` `tt6` on(true) left join `test`.`t1` `tt7` on(true) left join `test`.`t1` `tt8` on(true)) on(true)) on(true) straight_join `test`.`t1` `tt9` where true +SET optimizer_search_depth = DEFAULT; +DROP TABLE t1; +# +# Bug#46091 STRAIGHT_JOIN + RIGHT JOIN returns different result +# +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +COUNT(*) +476 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t1 ta1 +RIGHT JOIN t2 ta2 JOIN t2 ta3 ON ta2.f1 ON ta3.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 90.00 Parallel execute (1 workers) +2 SIMPLE ta2 NULL ALL NULL NULL NULL NULL 20 90.00 Using where +2 SIMPLE ta3 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE ta1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` `ta2` join `test`.`t2` `ta3` left join `test`.`t1` `ta1` on((0 <> `test`.`ta3`.`f1`)) where (0 <> `test`.`ta2`.`f1`) +DROP TABLE t1, t2; +# +# Bug#48971 Segfault in add_found_match_trig_cond () at sql_select.cc:5990 +# +CREATE TABLE t1(f1 INT, PRIMARY KEY (f1)); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +LEFT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`)))) on(true) where true +EXPLAIN SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 +RIGHT JOIN t1 AS jt2 +RIGHT JOIN t1 AS jt3 +JOIN t1 AS jt4 ON 1 +LEFT JOIN t1 AS jt5 ON 1 +ON 1 +RIGHT JOIN t1 AS jt6 ON jt6.f1 +ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE jt6 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt3 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt4 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +2 SIMPLE jt5 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +2 SIMPLE jt1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(true) left join `test`.`t1` `jt2` on(true)) on(((0 <> `test`.`jt6`.`f1`))) left join `test`.`t1` `jt1` on(true) where true +DROP TABLE t1; +# +# Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +# +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = 4)) where true group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +4 NULL NULL +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 const 1 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `f1`,`test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = 4) and (`test`.`t2`.`f2` is not null)) group by `test`.`t2`.`f1`,`test`.`t2`.`f2` +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; +f1 f1 f2 +DROP TABLE t1,t2; +# +# Bug#57034 incorrect OUTER JOIN result when joined on unique key +# +CREATE TABLE t1 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t1 VALUES (1,NULL,2), (2,0,0); +CREATE TABLE t2 (pk INT PRIMARY KEY, +col_int INT, +col_int_unique INT UNIQUE KEY); +INSERT INTO t2 VALUES (1,0,1), (2,0,2); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,NULL AS `col_int`,'2' AS `col_int_unique`,NULL AS `pk`,NULL AS `col_int`,NULL AS `col_int_unique` from `test`.`t1` left join `test`.`t2` on((multiple equal('2', NULL) and multiple equal(NULL, NULL))) where true +SELECT * FROM t1 LEFT JOIN t2 +ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int +WHERE t1.pk=1; +pk col_int col_int_unique pk col_int col_int_unique +1 NULL 2 NULL NULL NULL +DROP TABLE t1,t2; +# +# Bug#48046 Server incorrectly processing JOINs on NULL values +# +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_key` time DEFAULT NULL, +`varchar_key` varchar(1) DEFAULT NULL, +`varchar_nokey` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL); +SELECT table1.time_key AS field1, table2.pk +FROM BB table1 LEFT JOIN BB table2 +ON table2.varchar_nokey = table1.varchar_key +HAVING field1; +field1 pk +18:27:58 NULL +DROP TABLE BB; +# +# Bug#49600 Server incorrectly processing RIGHT JOIN with +# constant WHERE clause and no index +# +CREATE TABLE `BB` ( +`col_datetime_key` datetime DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +`col_varchar_nokey` varchar(1) DEFAULT NULL, +KEY `col_datetime_key` (`col_datetime_key`), +KEY `col_varchar_key` (`col_varchar_key`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL); +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +ALTER TABLE BB DISABLE KEYS; +SELECT table1.col_datetime_key +FROM BB table1 RIGHT JOIN BB table2 +ON table2 .col_varchar_nokey = table1.col_varchar_key +WHERE 7; +col_datetime_key +NULL +DROP TABLE BB; +# +# Bug#58490: Incorrect result in multi level OUTER JOIN +# in combination with IS NULL +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0), (2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1), (3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2), (4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3) ; +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( t2 LEFT JOIN +( t3 LEFT JOIN +t4 +ON t4.i = t3.i +) +ON t3.i = t2.i +) +ON t2.i = t1.i +WHERE t4.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i +2 NULL NULL +3 3 NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN t4 +ON t4.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i +2 NULL NULL NULL +3 3 NULL 3 +4 NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 3 +4 NULL NULL NULL NULL +SELECT * FROM +t1 LEFT JOIN +( ( t2 LEFT JOIN +t3 +ON t3.i = t2.i +) +JOIN (t4 AS t4a, t4 AS t4b) +ON t4a.i=t2.i +) +ON t2.i = t1.i +WHERE t3.i IS NULL; +i i i i i +2 NULL NULL NULL NULL +3 3 NULL 3 0 +3 3 NULL 3 1 +3 3 NULL 3 2 +3 3 NULL 3 3 +4 NULL NULL NULL NULL +DROP TABLE t1,t2,t3,t4; +# +# Bug#49322(Duplicate): Server is adding extra NULL row +# on processing a WHERE clause +# +CREATE TABLE h (pk INT NOT NULL, col_int_key INT); +INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8); +CREATE TABLE m (pk INT NOT NULL, col_int_key INT); +INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9); +CREATE TABLE k (pk INT NOT NULL, col_int_key INT); +INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5); +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key; +pk +2 +2 +4 +4 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT TABLE1.pk FROM k TABLE1 +RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key +RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key +WHERE TABLE1.pk IS NULL; +pk +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE h,m,k; +# +# Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY +# IS EXECUTED TWICE FROM P +# +CREATE TABLE t1 ( a INT ) ENGINE = MYISAM; +INSERT INTO t1 VALUES (1); +PREPARE prep_stmt FROM ' + SELECT 1 AS f FROM t1 + LEFT JOIN t1 t2 + RIGHT JOIN t1 t3 + JOIN t1 t4 + ON 1 + ON 1 + ON 1 + GROUP BY f'; +EXECUTE prep_stmt; +f +1 +EXECUTE prep_stmt; +f +1 +DROP TABLE t1; +End of 5.1 tests +# +# Bug#54235 Extra rows with join_cache_level=4,6,8 and two LEFT JOIN +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t1 VALUES (null),(null); +explain SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t3`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.a) +ON 0 WHERE t1.a OR t3.a; +a +explain SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` left join `test`.`t4` on(true)) on((0 <> `test`.`t2`.`a`))) on(false) where ((0 <> `test`.`t1`.`a`) or (0 <> `test`.`t4`.`a`)) +SELECT t1.a FROM t1 LEFT JOIN +(t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) +ON 0 WHERE t1.a OR t4.a; +a +DROP TABLE t1,t2,t3,t4; +# +# Bug#56254 Assertion tab->ref.use_count fails in +# join_read_key_unlock_row() on 4-way JOIN +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_int INT, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (6, -448724992, NULL); +CREATE TABLE t2 ( +col_int INT, +col_varchar_10 VARCHAR(10) +); +INSERT INTO t2 VALUES (6,'afasdkiyum'); +CREATE TABLE t3 ( +col_varchar_10 VARCHAR(10), +col_int INT +); +CREATE TABLE t4 ( +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1); +INSERT INTO t4 VALUES (2); +SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +col_int +EXPLAIN FORMAT=tree SELECT t1.col_int +FROM t1 +LEFT JOIN t2 +LEFT JOIN t3 +JOIN t4 +ON t3.col_int = t4.pk +ON t2.col_varchar_10 = t3.col_varchar_10 +ON t2.col_int = t1.pk +WHERE t1.col_int_key IS NULL OR t4.pk < t3.col_int; +EXPLAIN +-> Parallel scan on + -> Filter: (found_match(t3..t4), ((t1.col_int_key is null) or (t4.pk < t3.col_int)), true) (cost=0.70 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> PQblock scan on t1 (cost=0.35 rows=1) + -> Nested loop left join (cost=0.70 rows=1) + -> Filter: (t2.col_int = t1.pk) (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_varchar_10 = t2.col_varchar_10) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t3.col_int) (cost=0.35 rows=1) + +DROP TABLE t1,t2,t3,t4; + +# BUG#12567331 - INFINITE LOOP WHEN RESOLVING AN ALIASED COLUMN +# USED IN GROUP BY + +CREATE TABLE t1 (pk int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +PREPARE prep_stmt_9846 FROM ' +SELECT alias1.pk AS field1 FROM +t1 AS alias1 +LEFT JOIN +( + t1 AS alias2 + RIGHT JOIN + ( + t1 AS alias3 + JOIN t1 AS alias4 + ON 1 + ) + ON 1 +) +ON 1 +GROUP BY field1'; +execute prep_stmt_9846; +field1 +execute prep_stmt_9846; +field1 +deallocate prepare prep_stmt_9846; +drop table t1; +# +# Bug#13040136 - ASSERT IN PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG() +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +col_int_key INTEGER, +col_varchar_10_key VARCHAR(10), +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_10_key) +); +INSERT INTO t1 VALUES ('q',NULL,'o',1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL AUTO_INCREMENT, +col_varchar_10_key VARCHAR(10), +col_int_key INTEGER, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY (col_varchar_10_key), +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(1,'r',NULL,'would'),(2,'tell',-655032320,'t'), +(3,'d',9,'a'),(4,'gvafasdkiy',6,'ugvafasdki'), +(5,'that\'s',NULL,'she'),(6,'bwftwugvaf',7,'cbwftwugva'), +(7,'f',-700055552,'mkacbwftwu'),(8,'a',9,'be'), +(9,'d',NULL,'u'),(10,'ckiixcsxmk',NULL,'o'); +SELECT DISTINCT t2.col_int_key +FROM +t1 +LEFT JOIN t2 +ON t1.col_varchar_10 = t2.col_varchar_10_key +WHERE t2.pk +ORDER BY t2.col_int_key; +col_int_key +DROP TABLE t1,t2; +# +# Bug#13068506 - QUERY WITH GROUP BY ON NON-AGGR COLUMN RETURNS WRONG RESULT +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (100), (101); +CREATE TABLE t2 (i2 int, i3 int); +INSERT INTO t2 VALUES (20,1),(10,2); +CREATE TABLE t3 (i4 int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(2); + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1;; +field1 +20 +20 + +SELECT ( +SELECT MAX( t2.i2 ) +FROM t3 RIGHT JOIN t2 ON ( t2.i3 = 2 ) +WHERE t2.i3 <> t1.i1 +) AS field1 +FROM t1 GROUP BY field1;; +field1 +20 + +drop table t1,t2,t3; +# Bug#11766384 - 59487: WRONG RESULT WITH STRAIGHT_JOIN AND RIGHT JOIN +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'1'); +CREATE TABLE t2 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 ( +pk int(11) NOT NULL, +col_int int(11) DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t4 VALUES (1,1,1,'1'); +CREATE TABLE t5 ( +col_int int(11) DEFAULT NULL, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t5 VALUES (1,'1'); +CREATE TABLE t6 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +pk int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t6 VALUES (1,'1',1); +SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT STRAIGHT_JOIN t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +pk pk +1 NULL +EXPLAIN SELECT t6a.pk, t2.pk +FROM +t6 AS t6a +LEFT JOIN +( +t2 +RIGHT JOIN +( +( +t1 +LEFT JOIN +( +t4 +JOIN +t3 +ON t4.col_int +) +ON t4.col_int_key = t1.pk +) +LEFT JOIN +( +t5 +JOIN +t6 AS t6b +ON t5.col_varchar_10_utf8_key = t6b.col_varchar_10_latin1_key +) +ON t1.pk = t5.col_int +) +ON t4.col_varchar_10_latin1_key = t1.col_varchar_10_latin1_key +AND t5.col_varchar_10_utf8_key = 0 +) +ON t6a.pk IS TRUE +WHERE t6b.col_int_key IS TRUE +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t6a NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6b NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t6a`.`pk` AS `pk`,`test`.`t2`.`pk` AS `pk` from `test`.`t6` `t6a` join `test`.`t1` left join (`test`.`t4` join `test`.`t3`) on(((`test`.`t4`.`col_int_key` = `test`.`t1`.`pk`) and (0 <> `test`.`t4`.`col_int`))) join `test`.`t5` join `test`.`t6` `t6b` left join `test`.`t2` on(((`test`.`t4`.`col_varchar_10_latin1_key` = `test`.`t1`.`col_varchar_10_latin1_key`) and (`test`.`t5`.`col_varchar_10_utf8_key` = 0))) where ((`test`.`t5`.`col_int` = `test`.`t1`.`pk`) and ((0 <> `test`.`t6b`.`col_int_key`) is true) and (`test`.`t5`.`col_varchar_10_utf8_key` = `test`.`t6b`.`col_varchar_10_latin1_key`) and ((0 <> `test`.`t6a`.`pk`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` join `test`.`t6` where ((`test`.`t5`.`col_int` = 1000) and ((0 <> `test`.`t6`.`col_int_key`) is true)) +EXPLAIN SELECT * FROM t5 LEFT JOIN t6 ON t5.col_int=1000 +WHERE t6.col_int_key IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t6 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`col_int` AS `col_int`,`test`.`t5`.`col_varchar_10_utf8_key` AS `col_varchar_10_utf8_key`,`test`.`t6`.`col_int_key` AS `col_int_key`,`test`.`t6`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key`,`test`.`t6`.`pk` AS `pk` from `test`.`t5` left join `test`.`t6` on((`test`.`t5`.`col_int` = 1000)) where ((0 <> `test`.`t6`.`col_int_key`) is not true) +drop table t1,t2,t3,t4,t5,t6; +# +# Verify that the "not exists" optimization works. +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where (`test`.`t2`.`a` is null) +FLUSH STATUS; +SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.a IS NULL; +a a +SHOW STATUS LIKE 'HANDLER_READ%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1,t2; +# +# Bug#13464334 SAME QUERY PRODUCES DIFFERENT RESULTS WHEN USED WITH AND +# WITHOUT UNION ALL +# +CREATE TABLE t1 (p1 INT PRIMARY KEY, a CHAR(1)); +CREATE TABLE t2 (p2 INT PRIMARY KEY, b CHAR(1)); +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'h'),(2,'i'),(3,'j'),(4,'k'); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE VIEW v2 AS SELECT * FROM t2; +(SELECT p1 FROM v2 LEFT JOIN v1 ON b = a WHERE p2 = 1 GROUP BY p1 ORDER BY p1) +UNION (SELECT NULL LIMIT 0); +p1 +NULL +DROP VIEW v1, v2; +DROP TABLE t1, t2; +# +# Bug#13980954 Missing data on left join + null value + where..in +# +CREATE TABLE t1 (ik INT, vc varchar(1)) charset utf8mb4 ENGINE=Innodb; +explain format=json SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc", + "ik" + ], + "query_block": { + "cost_info": { + "query_cost": "1.05" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t1`.`vc`)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "1.05", + "data_read_per_join": "16" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(is_not_null_compl(t3), (`test`.`t3`.`vc` = `test`.`t1`.`vc`), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`vc` AS `vc`,`test`.`t1`.`ik` AS `ik` from `test`.`t1` join `test`.`t1` `t2` left join `test`.`t1` `t3` on((`test`.`t3`.`vc` = `test`.`t1`.`vc`)) where (`test`.`t2`.`vc` = `test`.`t1`.`vc`) +SELECT straight_join t1.vc, t1.ik +FROM t1 JOIN t1 AS t2 ON t1.vc=t2.vc LEFT JOIN t1 AS t3 ON t1.vc=t3.vc; +vc ik +DROP TABLE t1; +# +# Bug #18345786 CRASH AROUND ST_JOIN_TABLE::AND_WITH_CONDITION +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1), 1)); +DROP TABLE t1; +# +# Coverage for "unique row not found" +# +create table t1(a int, unique key(a)) engine=innodb; +insert into t1 values(1); +explain select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const a a 5 const 1 100.00 Using index +1 SIMPLE t2 NULL const a a 5 const 0 0.00 unique row not found +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,NULL AS `a` from `test`.`t1` left join `test`.`t1` `t2` on(multiple equal(12, NULL)) where true +select * from t1 left join t1 as t2 +on t2.a=12 +where t1.a=1; +a a +1 NULL +drop table t1; +# +# Bug#18717059 MISSING ROWS ON NESTED JOIN WITH SUBQUERY +# WITH MYISAM OR MEMORY +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key, col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (23,4,'d'); +INSERT INTO t1 VALUES (24,8,'g'); +INSERT INTO t1 VALUES (25,NULL,'x'); +INSERT INTO t1 VALUES (26,NULL,'f'); +INSERT INTO t1 VALUES (27,0,'p'); +INSERT INTO t1 VALUES (28,NULL,'j'); +INSERT INTO t1 VALUES (29,8,'c'); +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +) ENGINE=MyISAM; +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +9 +9 +9 +9 +9 +9 +9 +9 +CREATE TABLE where_subselect_table AS +SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +); +set optimizer_switch='condition_fanout_filter=on'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +set optimizer_switch='condition_fanout_filter=off'; +SELECT * +FROM where_subselect_table +WHERE (9) IN ( SELECT 9 +FROM t1 AS table1 +RIGHT JOIN t1 AS table2 +ON table2.col_int_key = table1.col_int_key +AND table1.col_varchar_key = ( +SELECT subquery2_t2.col_varchar_key +FROM t2 +STRAIGHT_JOIN ( t2 AS subquery2_t2 +JOIN t1 AS subquery2_t3 +) ON ( subquery2_t3.col_int_key = subquery2_t2.pk ) +) ) +/* TRANSFORM_OUTCOME_UNORDERED_MATCH */; +9 +9 +9 +9 +9 +9 +9 +9 +DROP TABLE t1, t2, where_subselect_table; +# Bug#14358878 Wrong results on table left join view +CREATE TABLE a (id INTEGER); +CREATE TABLE b (id INTEGER); +CREATE ALGORITHM=MERGE VIEW vmerge AS SELECT 1 AS id, id AS b_id FROM b; +CREATE ALGORITHM=TEMPTABLE VIEW vmat AS SELECT 1 AS id, id AS b_id FROM b; +INSERT INTO a(id) VALUES (1); +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmat AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN (SELECT DISTINCT 1 AS one, id FROM b) AS v ON a.id = v.id; +id one id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION DISTINCT +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id +UNION ALL +SELECT * +FROM a LEFT JOIN vmerge AS v ON a.id = v.id; +id id b_id +1 NULL NULL +1 NULL NULL +DROP VIEW vmerge, vmat; +DROP TABLE a, b; +# Bug#15936817 Table left join view, unmatched rows problem where +# view contains an IF +CREATE TABLE small ( +id INTEGER not null, +PRIMARY KEY (id) +); +CREATE TABLE big ( +id INTEGER not null, +PRIMARY KEY (id) +); +INSERT INTO small VALUES (1), (2); +INSERT INTO big VALUES (1), (2), (3), (4); +CREATE VIEW small_view AS +SELECT *, IF (id % 2 = 1, 1, 0) AS is_odd +FROM small; +CREATE VIEW big_view AS +SELECT big.*, small_view.id AS small_id, small_view.is_odd +FROM big LEFT JOIN small_view ON small_view.id = big.id; +SELECT * FROM big_view; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +SELECT big.*, small.id AS small_id, small.is_odd +FROM big LEFT JOIN +(SELECT id, IF (id % 2 = 1, 1, 0) AS is_odd FROM small) AS small +ON big.id = small.id; +id small_id is_odd +1 1 1 +2 2 0 +3 NULL NULL +4 NULL NULL +# Check the IS NULL and thruth predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id IS NULL AS nul, +id IS NOT NULL AS nnul, +id IS TRUE AS t, +id IS NOT TRUE AS nt, +id IS FALSE AS f, +id IS NOT FALSE AS nf, +id IS UNKNOWN AS u, +id IS NOT UNKNOWN AS nu +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id nul nnul t nt f nf u nu +1 1 0 1 1 0 0 1 0 1 +2 2 0 1 1 0 0 1 0 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL NULL +# Check comparison predicates +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +id = 1 AS eq, +id <> 1 AS ne, +id > 1 AS gt, +id >= 1 AS ge, +id < 1 AS lt, +id <= 1 AS le, +id <=> 1 AS equal +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id eq ne gt ge lt le equal +1 1 1 0 0 1 0 1 1 +2 2 0 1 1 1 0 0 0 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +# Check CASE, NULLIF and COALESCE +SELECT big.*, dt.* +FROM big LEFT JOIN (SELECT id as dt_id, +CASE id WHEN 0 THEN 0 ELSE 1 END AS simple, +CASE WHEN id=0 THEN NULL ELSE 1 END AS cond, +NULLIF(1, NULL) AS nullif, +IFNULL(1, NULL) AS ifnull, +COALESCE(id) AS coal, +INTERVAL(NULL, 1, 2, 3) as intv, +IF (id % 2 = 1, NULL, 1) AS iff +FROM small) AS dt +ON big.id=dt.dt_id; +id dt_id simple cond nullif ifnull coal intv iff +1 1 1 1 1 1 1 -1 NULL +2 2 1 1 1 1 2 -1 1 +3 NULL NULL NULL NULL NULL NULL NULL NULL +4 NULL NULL NULL NULL NULL NULL NULL NULL +DROP VIEW small_view, big_view; +DROP TABLE small, big; +# +# Bug#16893426 OPTIMIZER FAILS TO OPTIMIZE EXPRESSION OF THE +# FORM 'FOO' IS NULL +# +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +name varchar(20), +INDEX (name) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL PRIMARY KEY, +f_id int(11), +FOREIGN KEY (f_id) REFERENCES t2(id) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%'"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref f_id f_id 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`f_id` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE t1.name LIKE 'A%' OR 'ASDFGH' IS NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 0 OR 0"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 OR 0"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 1"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE NOT(NOT (0)) OR 0 = 1"; +EXECUTE stmt; +id f_id id name +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`f_id`, `test`.`t1`.`id`)) where false +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE ; +id f_id id name +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT TRUE AND 0 IS TRUE "; +EXECUTE stmt; +id f_id id name +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' ; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 'a' LIKE 1 OR 2 LIKE '2%' "; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE 1 IS NOT NULL"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<2 AND 2<3) OR (1>1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1>=1 AND 2<=2) OR (1=1 AND 2<3)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL f_id 5 NULL 5 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f_id 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`f_id` AS `f_id`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`id` = `test`.`t2`.`f_id`)) where true +SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2); +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +PREPARE stmt FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.f_id = t1.id +WHERE (1<>1 AND 2=2) OR (1 BETWEEN 0 AND 2)"; +EXECUTE stmt; +id f_id id name +1 1 1 A1 +2 2 2 A2 +3 2 2 A2 +4 3 3 B +5 3 3 B +DROP TABLE t1,t2; +# +# Bug#22103398 BUG#16893426:SIG11 IN +# ST_SELECT_LEX::FLATTEN_SUBQUERIES | SQL_RESOLVER.CC +# +CREATE TABLE t1(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +CREATE TABLE t2(c1 INT, c2 INT, c3 CHAR(1), KEY(c3))ENGINE=InnoDB; +SELECT b.c2 AS f1 FROM (t2 AS a JOIN +((t2 AS b JOIN t2 AS c ON (c.c3=b.c3))) +ON (c.c1=b.c2)) +WHERE (c.c3 IN (SELECT subquery1_b.c3 AS subquery1_f1 +FROM (t1 AS subquery1_a JOIN t2 AS subquery1_b ON +(subquery1_b.c1=subquery1_a.c1)))) AND +(a.c1=a.c1 AND (SELECT''FROM DUAL) IS NULL); +f1 +DROP TABLE t1, t2; +# End of Bug#16893426 +# Bug#22561937 Wrong result on outer join with multiple join conditions +# and derived table +CREATE TABLE t1 ( +col_int INT, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES +(2,1), (2,2), (6,3), (4,4), (7,5), +(188,6), (0,7), (6,8), (0,9), (9,10); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES +(1,0), (2,0), (3,2), (4,NULL), (5,2), +(6,3), (7,3), (8,100), (9,3), (10,6); +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`table2`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join `test`.`t1` `table2` on(((`test`.`table2`.`pk` = `test`.`table1`.`col_int`) and (`test`.`table1`.`col_int` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +explain SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.table1.col_int 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`table1`.`col_int` AS `col_int` from `test`.`t2` `table1` left join (`test`.`t1`) on(((`test`.`t1`.`pk` = `test`.`table1`.`col_int`) and (`test`.`t1`.`pk` < `test`.`table1`.`col_int`))) where true +SELECT table2.pk, table1.col_int +FROM t2 AS table1 +LEFT JOIN (SELECT * FROM t1) AS table2 +ON table2.pk < table1.col_int AND +table2.pk = table1.col_int; +pk col_int +NULL 0 +NULL 0 +NULL 2 +NULL NULL +NULL 2 +NULL 3 +NULL 3 +NULL 100 +NULL 3 +NULL 6 +DROP TABLE t1, t2; +# Bug#22671557: Wrong results on JOIN when composite index is present +CREATE TABLE t1 ( +col_int INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY test_idx (col_int_key,col_int) +); +INSERT INTO t1 VALUES (0, -7, 1), (9, NULL, 15), (182, NULL, 25); +CREATE TABLE t2 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (NULL, 4), (-208, 5), (5, 6), (NULL, 75); +CREATE TABLE t3 ( +col_datetime_key DATETIME DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES ('1970-01-01 00:00:00', 5); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +pk INT NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t4 VALUES (0, 15, 6), (9, 16, 6); +SELECT alias2.col_datetime_key +FROM +t1 AS alias1 +LEFT JOIN t3 AS alias2 +LEFT JOIN t2 AS alias3 +LEFT JOIN t4 AS alias4 +ON alias3.pk = alias4.col_int_key +ON alias2.pk = alias3.col_int +ON alias1.col_int = alias4.col_int +; +col_datetime_key +1970-01-01 00:00:00 +1970-01-01 00:00:00 +NULL +DROP TABLE t1, t2, t3, t4; +# Bug#22833364: Left join returns incorrect results on the outer side +CREATE TABLE ta ( +a1 varchar(1024) NOT NULL, +a2 int NOT NULL, +KEY user_id(a2) +); +INSERT INTO ta (a1, a2) VALUES ('row1', 4), ('row2', 4); +CREATE TABLE tb ( +b1 int NOT NULL, +b2 varchar(1024) NOT NULL, +b3 int NOT NULL, +PRIMARY KEY (b1) +); +INSERT INTO tb (b1, b2, b3) VALUES +(1, 'text1', 0), (2, 'text2', 0), (3, 'text3', 1), (4, 'text4', 1); +explain SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE ta NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE tb NULL eq_ref PRIMARY PRIMARY 4 test.ta.a2 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ta`.`a1` AS `a1`,`test`.`tb`.`b1` AS `b1`,`test`.`tb`.`b2` AS `b2` from `test`.`ta` left join `test`.`tb` on(((`test`.`tb`.`b3` = 0) and (`test`.`tb`.`b1` = `test`.`ta`.`a2`))) where true +SELECT ta.a1, tb.b1, tb.b2 +FROM ta LEFT OUTER JOIN tb +ON ta.a2 = tb.b1 AND tb.b3 = 0; +a1 b1 b2 +row1 NULL NULL +row2 NULL NULL +DROP TABLE ta, tb; +# Bug#23079533: Left join on PK + extra condition doesn't return match +CREATE TABLE m ( +machineid VARCHAR(32) NOT NULL, +orderid bigint unsigned DEFAULT NULL, +extra bigint unsigned DEFAULT NULL, +PRIMARY KEY (machineid) +); +INSERT INTO m (machineid, orderid) +VALUES ('m1', NULL), ('m2', 2), ('m3', NULL), ('m4', NULL); +CREATE TABLE o ( +orderid bigint unsigned NOT NULL, +machineid VARCHAR(32) DEFAULT NULL, +PRIMARY KEY (orderid) +); +INSERT INTO o (orderid, machineid) +VALUES (1, 'm2'), (2, 'm2'); +SELECT o.*,'|' as sep, m.* +FROM o LEFT JOIN m +ON m.machineid = o.machineid AND +m.orderid = o.orderid; +orderid machineid sep machineid orderid extra +1 m2 | NULL NULL NULL +2 m2 | m2 2 NULL +DROP TABLE m, o; +# Bug#23086825: Incorrect query results using left join against derived +CREATE TABLE t1 ( +adslot varchar(5) NOT NULL +); +INSERT INTO t1(adslot) VALUES ('1'), ('2'), ('3'); +CREATE TABLE t2 ( +ionumber varchar(20) NOT NULL, +adslot varchar(5) NOT NULL +); +INSERT INTO t2 (ionumber, adslot) VALUES ('01602', 1), ('01602', 3); +CREATE TABLE t3 ( +ionumber varchar(20) NOT NULL, +ioattribute varchar(5) NOT NULL, +PRIMARY KEY (ionumber) +); +INSERT INTO t3 VALUES ('01602', 'BOB'), ('01603', 'SALLY'); +SELECT s.adslot, lid.ionumber1, lid.ionumber2, lid.ioattribute +FROM t1 s LEFT JOIN +(SELECT lid.adslot, +i.ionumber as ionumber1, +lid.ionumber as ionumber2, +i.ioattribute +FROM t2 lid JOIN t3 i +USING (ionumber) +) AS lid +USING (adslot); +adslot ionumber1 ionumber2 ioattribute +1 01602 01602 BOB +2 NULL NULL NULL +3 01602 01602 BOB +DROP TABLE t1, t2, t3; +# +# Bug #26432173: INCORRECT SUBQUERY OPTIMIZATION WITH +# LEFT JOIN(SUBQUERY) AND ORDER BY +# +CREATE TABLE t1 (a INT); +INSERT t1 values (1),(2),(15),(24),(5); +CREATE TABLE t2 (t1_a INT, b VARCHAR(10)); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`t1_a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +EXPLAIN SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'red' AS `st_value` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = `test`.`t2`.`t1_a`)) where true order by `test`.`t1`.`a` +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a; +a st_value +1 NULL +2 NULL +15 NULL +24 NULL +5 NULL +SELECT t1.a, subq.st_value +FROM t1 +LEFT JOIN (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +1 NULL +2 NULL +5 NULL +15 NULL +24 NULL +SELECT t1.a, subq.st_value +FROM (SELECT t2.t1_a, 'red' AS st_value +FROM t2) AS subq +LEFT JOIN t1 +ON subq.t1_a = t1.a +ORDER BY t1.a; +a st_value +DROP TABLE t1, t2; +# Bug #18898433: EXTREMELY SLOW PERFORMANCE WITH OUTER JOINS AND JOIN +# BUFFER. +# +CREATE TABLE t1 (i INT NOT NULL); +INSERT INTO t1 VALUES (0),(2),(3),(4); +CREATE TABLE t2 (i INT NOT NULL); +INSERT INTO t2 VALUES (0),(1),(3),(4); +CREATE TABLE t3 (i INT NOT NULL); +INSERT INTO t3 VALUES (0),(1),(2),(4); +CREATE TABLE t4 (i INT NOT NULL); +INSERT INTO t4 VALUES (0),(1),(2),(3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t1`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`))) on((`test`.`t2`.`i` = `test`.`t1`.`i`)) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join (`test`.`t2` join `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t1`.`i`))) on(((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`))) where true +EXPLAIN SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t2`.`i` AS `i`,`test`.`t3`.`i` AS `i`,`test`.`t4`.`i` AS `i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t1`.`i`)) left join `test`.`t3` on((`test`.`t3`.`i` = `test`.`t2`.`i`)) left join `test`.`t4` on((`test`.`t4`.`i` = `test`.`t3`.`i`)) where true +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 LEFT JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 11 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 55 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN +( +(t2 INNER JOIN t3 ON t3.i= t2.i) +LEFT JOIN t4 ON t3.i= t4.i +)ON t2.i= t1.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 NULL NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 10 +Handler_read_key 10 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 50 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +flush status; +SELECT * +FROM t1 LEFT JOIN t2 ON t2.i= t1.i +LEFT JOIN t3 ON t3.i= t2.i +LEFT JOIN t4 ON t3.i= t4.i; +i i i i +0 0 0 0 +2 NULL NULL NULL +3 3 NULL NULL +4 4 4 NULL +SHOW STATUS LIKE 'HANDLER_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 8 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 13 +Handler_read_key 13 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 65 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t1, t2, t3, t4; +# +# Bug #26627181: WRONG RESULT WITH LEFT JOIN + DERIVED TABLES +# +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id`,2 AS `tall` from `test`.`t1` left join (`test`.`t2`) on((`test`.`t2`.`id` = `test`.`t1`.`id`)) where (2 is not null) +SELECT * +FROM (SELECT id +FROM t1) AS a +LEFT JOIN +(SELECT id, 2 AS tall +FROM t2) AS b +ON a.id = b.id +WHERE b.tall IS NOT NULL; +id id tall +1 1 2 +DROP TABLE t1, t2; +# +# Bug #23169204: Left join + merged derived table + group by = bad result +# +CREATE TABLE t1(doc text); +CREATE TABLE t2(a INTEGER DEFAULT NULL); +INSERT INTO t2 VALUES(1); +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1 LIMIT 1) AS dt ON FALSE +GROUP BY je; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE; +je +NULL +SELECT je +FROM t2 LEFT JOIN (SELECT 1 AS je FROM t1) AS dt ON FALSE +GROUP BY je; +je +NULL +DROP TABLE t1, t2; +# +# Bug#22489105 WL#9571 : SIG11 IN ITEM_SUBSELECT::EXEC | SQL/ITEM_SUBSELECT.CC +# +SELECT (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +a +SELECT (SELECT * FROM (SELECT 'a') t) + 1 AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +SELECT 1 + (SELECT * FROM (SELECT 'a') t) AS f1 HAVING (f1 = 'a' OR TRUE); +f1 +1 +# +# Bug#28237111: WL#9571: TABLE FULL ERROR +# +CREATE TABLE t1 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t2 (pk INTEGER, f1 INTEGER, primary key(pk)); +CREATE TABLE t3 (pk INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1); +INSERT INTO t2 VALUES (1,1),(2,1),(3,1); +INSERT INTO t3 VALUES (1); +SELECT * FROM (t1 RIGHT JOIN +(SELECT * FROM t3 WHERE (DAYNAME('1995'))) AS table2 ON +(( t1.f1 ,t1.pk) IN (SELECT 7,4 UNION SELECT 9,2))) WHERE +(NOT EXISTS (SELECT t1.f1 FROM (t1 INNER JOIN t2 ON (t1.pk=t2.f1)) +WHERE 0 IS NOT NULL)) AND t1.f1 > 50; +pk f1 pk +Warnings: +Warning 1292 Incorrect datetime value: '1995' +DROP TABLE t3,t1,t2; +# +# Bug#28341790: WL#9571: SIG11 IN ITEM_COND::FIX_FIELDS() AT SQL/ITEM_CMPFUNC.CC +# +CREATE TABLE t1 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (col_varchar varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " SELECT 1 FROM ( ( SELECT * FROM t1 WHERE col_varchar +>= 1 ) AS table1 RIGHT JOIN t2 ON ( ( NULL < NULL ) IS NULL OR 1 = 0 ) ) " ; +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +EXECUTE prep_stmt ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Z' +DROP TABLE t1,t2; +# +# More coverage for IS TRUE in LEFT JOIN conditions +# +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2(c2 INT); +INSERT INTO t2 VALUES(1); +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2; +c1 c2 +1 1 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NULL; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE c2 IS NOT NULL; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 1; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS TRUE; +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) = 0; +c1 c2 +2 NULL +SELECT * FROM t1 LEFT JOIN t2 ON c1=c2 WHERE (c2 IS NOT NULL) IS FALSE; +c1 c2 +2 NULL +DROP TABLE t1,t2; +# +# Bug#29402481: INCORRECT RESULT FROM OUTER JOIN QUERIES +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_unique int unique +) ENGINE=InnoDB; +INSERT INTO t1(col_int_unique) values (6),(7); +CREATE TABLE t2 ( +pk int primary key auto_increment, +col_int_key int(11) DEFAULT NULL, +col_int_unique int(11) DEFAULT NULL, +UNIQUE KEY `ix2` (col_int_key,col_int_unique), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +pk int NOT NULL +) ENGINE=InnoDB; +INSERT INTO t3(pk) values (6),(7); +SELECT STRAIGHT_JOIN t1.col_int_unique, t2.col_int_key, t3.pk +FROM +(t1 LEFT JOIN t2 ON t1.col_int_unique = t2.col_int_key) +LEFT JOIN t3 ON t3.pk = t1.col_int_unique AND +t1.col_int_unique = t2.col_int_key; +col_int_unique col_int_key pk +6 NULL NULL +7 NULL NULL +DROP TABLE t1,t2,t3; +# +# Bug#29493830 CONST'IFIED OUTER JOIN RETURN INCORRECT RESULTS +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,0); +CREATE TABLE t2 ( +col_char_16_unique char(16) DEFAULT NULL, +col_int_key INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES ("just",21,5); +CREATE TABLE t3 ( +col_int INT DEFAULT NULL, +col_char_16_unique CHAR(16) DEFAULT NULL, +UNIQUE KEY col_char_16_unique (col_char_16_unique) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (9,"foo"); +CREATE TABLE t4 ( +col_int INT DEFAULT NULL, +col_int_unique INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique) +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (9,5); +explain SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const col_int_unique col_int_unique 5 const 1 100.00 NULL +1 SIMPLE t2 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +1 SIMPLE t3 NULL const col_char_16_unique NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE t4 NULL const col_int_unique col_int_unique 5 const 1 100.00 Impossible ON condition +Warnings: +Note 1003 /* select#1 */ select straight_join NULL AS `col_int`,NULL AS `col_int`,((NULL = NULL) or (NULL is null)) AS `t3.col_int = t4.col_int or t4.col_int IS NULL` from `test`.`t1` left join `test`.`t2` on((multiple equal('0', NULL) and multiple equal(5, NULL))) left join `test`.`t3` on(multiple equal(NULL, NULL)) left join `test`.`t4` on((multiple equal(NULL, NULL) and multiple equal(5, NULL))) where true +SELECT STRAIGHT_JOIN +t3.col_int, t4.col_int, +t3.col_int = t4.col_int or t4.col_int IS NULL +FROM (t1 +LEFT JOIN t2 +ON t1.col_int_key = t2.col_int_key AND +t1.col_int_unique = t2.col_int_unique +LEFT JOIN t3 +ON t3.col_char_16_unique = t2.col_char_16_unique +LEFT JOIN t4 +ON t4.col_int = t3.col_int AND #Note, this pred term +t4.col_int_unique = t1.col_int_unique +) WHERE t1.col_int_unique = 5; +col_int col_int t3.col_int = t4.col_int or t4.col_int IS NULL +NULL NULL 1 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30659532: WL#13476: DIFFERENT NUMBER OF ROWS WITH NESTED LOOP JOINS +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t2 VALUES (3); +CREATE TABLE t3 ( +f1 INTEGER, +f2 INTEGER, +KEY k2 (f2) +); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,295010100); +INSERT INTO t3 VALUES (NULL,NULL); +INSERT INTO t3 VALUES (NULL,-1762438755); +INSERT INTO t3 VALUES (NULL,4); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +EXPLAIN +-> Parallel scan on + -> Batched key access left join + -> Batch input rows + -> Nested loop inner join (cost=1.15 rows=2) + -> Filter: (t1.pk < 5) (cost=0.45 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.30 rows=1) + -> Multi-range index lookup on t3 using k2 (f2=t1.pk) + +SELECT * FROM t1 LEFT JOIN t2 ON t1.pk = t2.pk LEFT JOIN t3 ON t2.pk = t3.f2 WHERE t2.pk < 5; +pk pk f1 f2 +1 1 NULL NULL +2 2 NULL NULL +DROP TABLE t1, t2, t3; +# +# Bug #30654713: WL#13476: DIFFERENT ROWS WITH BATCHED KEY ACCESS LEFT JOIN +# +CREATE TABLE t1 ( +col_int INTEGER, +a INTEGER, +b varchar(10), +KEY key_a (a) +); +INSERT INTO t1 VALUES (5,NULL,'p'); +INSERT INTO t1 VALUES (6,NULL,''); +INSERT INTO t1 VALUES (7,NULL,''); +INSERT INTO t1 VALUES (8,NULL,'Z'); +INSERT INTO t1 VALUES (9,4,'g'); +INSERT INTO t1 VALUES (10,NULL,'if'); +INSERT INTO t1 VALUES (11,NULL,'j'); +INSERT INTO t1 VALUES (12,9,''); +CREATE TABLE t2 ( +a INTEGER, +b varchar(10), +KEY key_b (b) +); +INSERT INTO t2 VALUES (1,'j'); +INSERT INTO t2 VALUES (2,'o'); +INSERT INTO t2 VALUES (3,'z'); +INSERT INTO t2 VALUES (4,'really'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN format=tree SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +EXPLAIN +-> Parallel scan on + -> Nested loop left join + -> PQblock scan on t1 (cost=1.05 rows=8) + -> Batched key access left join + -> Batch input rows + -> Index lookup on t2 using key_b (b=t1.b) (cost=0.26 rows=1) + -> Multi-range index lookup on t3 using key_a (a=t2.a) + +SELECT t1.col_int as t1_ci, t1.a as t1_a, t1.b as t1_b, t2.a as t2_a, t2.b as t2_b, t3.col_int as t3_ci, t3.a as t3_a, t3.b as t3_b +FROM t1 +LEFT JOIN ( t2 LEFT JOIN t1 AS t3 ON t2.a=t3.a ) +ON t1.b = t2.b; +t1_ci t1_a t1_b t2_a t2_b t3_ci t3_a t3_b +10 NULL if NULL NULL NULL NULL NULL +11 NULL j 1 j NULL NULL NULL +12 9 NULL NULL NULL NULL NULL +5 NULL p NULL NULL NULL NULL NULL +6 NULL NULL NULL NULL NULL NULL +7 NULL NULL NULL NULL NULL NULL +8 NULL Z 3 z NULL NULL NULL +9 4 g NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# Bug#30520749 - REGRESSION: LEFT JOIN WITH IMPOSSIBLE ON CONDITION PERFORMS SLOWLY +# +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( f1 INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 AS SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t2 ON 1=2; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=4.50 rows=25) + -> PQblock scan on t1 (cost=0.75 rows=5) + -> Zero rows (Impossible filter) (cost=0.07..0.35 rows=5) + +DROP TABLE t1, t2; +set optimizer_switch='block_nested_loop=on'; +# +# Bug #31252625: DATA IN WRONG ROW ON LEFT JOIN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER, +PRIMARY KEY (id) +); +INSERT INTO t1 VALUES (17,NULL); +INSERT INTO t1 VALUES (136,564); +INSERT INTO t1 VALUES (137,NULL); +CREATE TABLE t2 ( +id INTEGER NOT NULL, +PRIMARY KEY (id) +); +INSERT INTO t2 VALUES (564); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.id GROUP BY t1.id; +id b id +17 NULL NULL +136 564 564 +137 NULL NULL +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/join_outer_innodb.result-pq b/mysql-test/r/join_outer_innodb.result-pq new file mode 100644 index 000000000..f1600d3ce --- /dev/null +++ b/mysql-test/r/join_outer_innodb.result-pq @@ -0,0 +1,90 @@ +CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20), +INDEX (name)) charset utf8mb4 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11), +FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%' OR FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +DROP TABLE t1,t2; +# +# BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# in opt_range.h +# +CREATE TABLE t1 ( +col_int INT, +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL,1,1), (6,2,2), (5,3,3), (NULL,4,4); +INSERT INTO t1 VALUES (1,NULL,6), (8,5,7), (NULL,8,8), (8,NULL,5); +ANALYZE TABLE t1; +CREATE TABLE t2 ( +pk INT PRIMARY KEY +) ENGINE=InnoDB; + +EXPLAIN SELECT t1.pk +FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int +WHERE t1.col_int_key BETWEEN 5 AND 6 +AND t1.pk IS NULL OR t1.pk IN (5) +ORDER BY pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 SIMPLE t1 NULL const PRIMARY,col_int_key PRIMARY 4 const 1 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`col_int` = `test`.`t2`.`pk`) and (((`test`.`t1`.`col_int_key` between 5 and 6) and (`test`.`t1`.`pk` is null)) or (`test`.`t1`.`pk` = 5))) order by `test`.`t1`.`pk` + +SELECT t1.pk +FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int +WHERE t1.col_int_key BETWEEN 5 AND 6 +AND t1.pk IS NULL OR t1.pk IN (5) +ORDER BY pk; +pk + +DROP TABLE t1,t2; +# End BUG#58456 +# +# Bug #20939184:INNODB: UNLOCK ROW COULD NOT FIND A 2 MODE LOCK ON THE +# RECORD +# +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,c2) ); +CREATE TABLE t2 (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1), KEY (c2)); +INSERT INTO t1 VALUES (1,2,3),(2,3,4),(3,4,5); +INSERT INTO t2 SELECT * FROM t1; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +START TRANSACTION; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c2=t2.c2 AND t2.c1=1 FOR UPDATE; +c1 c2 c3 c1 c2 c3 +1 2 3 1 2 3 +2 3 4 NULL NULL NULL +3 4 5 NULL NULL NULL +UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c2 AND t2.c1 = 3 SET t1.c3 = RAND()*10; +COMMIT; +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +DROP TABLE t1,t2; diff --git a/mysql-test/r/key_diff.result-pq b/mysql-test/r/key_diff.result-pq new file mode 100644 index 000000000..e7c402f3b --- /dev/null +++ b/mysql-test/r/key_diff.result-pq @@ -0,0 +1,58 @@ +drop table if exists t1; +CREATE TABLE t1 ( +a char(5) NOT NULL, +b char(4) NOT NULL, +KEY (a), +KEY (b) +) charset utf8mb4; +INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a'); +select * from t1,t1 as t2; +a b a b +A B A B +A B C c +A B D E +A B a a +A B b A +C c A B +C c C c +C c D E +C c a a +C c b A +D E A B +D E C c +D E D E +D E a a +D E b A +a a A B +a a C c +a a D E +a a a a +a a b A +b A A B +b A C c +b A D E +b A a a +b A b A +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref b b 16 test.t1.a 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`a` = `test`.`t2`.`b`) +select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; +a b a b +A B a a +A B b A +C c C c +a a a a +a a b A +b A A B +select * from t1 where a='a'; +a b +A B +a a +drop table t1; diff --git a/mysql-test/r/kill_explain_analyze.result-pq b/mysql-test/r/kill_explain_analyze.result-pq new file mode 100644 index 000000000..9b112854b --- /dev/null +++ b/mysql-test/r/kill_explain_analyze.result-pq @@ -0,0 +1,30 @@ +CREATE TABLE t1 ( pk INTEGER ); +INSERT INTO t1 VALUES (1), (2), (3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET SESSION debug="+d,bug13820776_1"; +EXPLAIN ANALYZE SELECT * FROM t1, t1 AS t2; +ERROR 70100: Query execution was interrupted +SET SESSION debug="-d,bug13820776_1"; +SET SESSION debug="+d,bug13822652_1"; +EXPLAIN ANALYZE SELECT * FROM t1, t1 AS t2; +EXPLAIN +-> Parallel scan on (actual time=N.NNN..N.NNN rows=0 loops=1) + -> Inner hash join (no condition) (cost=1.70 rows=9) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Table scan on t2 (cost=0.18 rows=3) (actual time=N.NNN..N.NNN rows=1 loops=1) + -> Hash + -> PQblock scan on t1 (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + +Warnings: +Warning 1317 Query execution was interrupted +SET SESSION debug="-d,bug13822652_1"; +EXPLAIN ANALYZE SELECT * from t1, t1 AS t2; +EXPLAIN +-> Parallel scan on (actual time=N.NNN..N.NNN rows=9 loops=1) + -> Inner hash join (no condition) (cost=1.70 rows=9) (actual time=N.NNN..N.NNN rows=9 loops=1) + -> Table scan on t2 (cost=0.18 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + -> Hash + -> PQblock scan on t1 (cost=0.55 rows=3) (actual time=N.NNN..N.NNN rows=3 loops=1) + +DROP TABLE t1; diff --git a/mysql-test/r/limit.result-pq b/mysql-test/r/limit.result-pq new file mode 100644 index 000000000..07e70d589 --- /dev/null +++ b/mysql-test/r/limit.result-pq @@ -0,0 +1,780 @@ +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(11),(12),(13),(14),(15),(16),(17),(18),(19); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(21),(22),(23),(24),(25),(26),(27); +SELECT * FROM t1 LIMIT 6; +a +11 +12 +13 +14 +15 +16 +SELECT * FROM t1 LIMIT 5 OFFSET 1; +a +12 +13 +14 +15 +16 +EXPLAIN FORMAT=TREE SELECT * FROM t1 LIMIT 5 OFFSET 1; +EXPLAIN +-> Limit/Offset: 5/1 row(s) + -> Parallel scan on + -> Limit: 6 row(s) (cost=1.15 rows=6) + -> PQblock scan on t1 (cost=1.15 rows=9) + +(SELECT * FROM t1 LIMIT 7) ORDER BY a DESC LIMIT 4; +a +17 +16 +15 +14 +(SELECT * FROM t1 LIMIT 7 OFFSET 1) ORDER BY a DESC LIMIT 4 OFFSET 2; +a +16 +15 +14 +13 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 7) ORDER BY a LIMIT 4; +a +13 +14 +15 +16 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 7 OFFSET 1) ORDER BY a LIMIT 4 OFFSET 2; +a +14 +15 +16 +17 +SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION SELECT * FROM t2 LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5; +a +11 +12 +13 +14 +15 +SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a LIMIT 5 OFFSET 6; +a +17 +18 +19 +21 +22 +(SELECT * FROM t1 LIMIT 5) UNION +SELECT * FROM t2 +LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +SELECT * FROM t2 +LIMIT 8; +a +19 +18 +17 +16 +15 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +14 +13 +12 +11 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +15 +16 +17 +18 +19 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +12 +13 +14 +15 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION ALL +SELECT * FROM t2 +LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +SELECT * FROM t2 +LIMIT 8; +a +19 +18 +17 +16 +15 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +LIMIT 8 OFFSET 1; +a +14 +13 +12 +11 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +11 +12 +13 +14 +15 +21 +22 +23 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +16 +17 +18 +19 +21 +22 +23 +24 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8; +a +15 +16 +17 +18 +19 +21 +22 +23 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +SELECT * FROM t2 +ORDER BY a LIMIT 8 OFFSET 1; +a +12 +13 +14 +15 +21 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION +(SELECT * FROM t2 LIMIT 4) +LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +LIMIT 7; +a +19 +18 +17 +16 +15 +27 +26 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +14 +13 +12 +11 +25 +24 +23 +(SELECT * FROM t1 LIMIT 5) UNION +(SELECT * FROM t2 LIMIT 4) +ORDER BY a LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +ORDER BY a LIMIT 7; +a +15 +16 +17 +18 +19 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +12 +13 +14 +15 +22 +23 +24 +(SELECT * FROM t1 LIMIT 5) UNION ALL +(SELECT * FROM t2 LIMIT 4) +LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +LIMIT 7; +a +19 +18 +17 +16 +15 +27 +26 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +LIMIT 7 OFFSET 1; +a +14 +13 +12 +11 +25 +24 +23 +(SELECT * FROM t1 LIMIT 5) UNION ALL +(SELECT * FROM t2 LIMIT 4) +ORDER BY a LIMIT 7; +a +11 +12 +13 +14 +15 +21 +22 +(SELECT * FROM t1 LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +16 +17 +18 +19 +23 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4) +ORDER BY a LIMIT 7; +a +15 +16 +17 +18 +19 +24 +25 +(SELECT * FROM t1 ORDER BY a DESC LIMIT 5 OFFSET 4) UNION ALL +(SELECT * FROM t2 ORDER BY a DESC LIMIT 4 OFFSET 2) +ORDER BY a LIMIT 7 OFFSET 1; +a +12 +13 +14 +15 +22 +23 +24 +DROP TABLE t1, t2; +create table t1 (a int not null default 0 primary key, b int not null default 0); +insert into t1 () values (); +insert into t1 values (1,1),(2,1),(3,1); +update t1 set a=4 where b=1 limit 1; +select * from t1; +a b +0 0 +2 1 +3 1 +4 1 +update t1 set b=2 where b=1 limit 2; +select * from t1; +a b +0 0 +2 2 +3 2 +4 1 +update t1 set b=4 where b=1; +select * from t1; +a b +0 0 +2 2 +3 2 +4 4 +delete from t1 where b=2 limit 1; +select * from t1; +a b +0 0 +3 2 +4 4 +delete from t1 limit 1; +select * from t1; +a b +3 2 +4 4 +drop table t1; +create table t1 (i int); +insert into t1 (i) values(1),(1),(1); +delete from t1 limit 1; +update t1 set i=2 limit 1; +delete from t1 limit 0; +update t1 set i=3 limit 0; +select * from t1; +i +2 +1 +drop table t1; +select 0 limit 0; +0 +CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2)); +INSERT INTO t1 (id2) values (0),(0),(0); +DELETE FROM t1 WHERE id=1; +INSERT INTO t1 SET id2=0; +SELECT * FROM t1; +id id2 +2 0 +3 0 +4 0 +DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1; +SELECT * FROM t1; +id id2 +3 0 +4 0 +DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1; +SELECT * FROM t1; +id id2 +3 0 +DROP TABLE t1; +create table t1 (a integer); +insert into t1 values (1); +select 1 as a from t1 union all select 1 from dual limit 1; +a +1 +(select 1 as a from t1) union all (select 1 from dual) limit 1; +a +1 +drop table t1; +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `c` from `test`.`t1` where (`test`.`t1`.`a` > 0) limit 3 +select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +c +7 +explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`a`) AS `c` from `test`.`t1` where (`test`.`t1`.`a` > 0) limit 3 +select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; +c +28 +drop table t1; +prepare s from "select 1 limit ?"; +set @a='qwe'; +execute s using @a; +ERROR HY000: Incorrect arguments to EXECUTE +set @a=-1; +execute s using @a; +ERROR 22003: unsigned integer value is out of range in 'EXECUTE' +prepare s from "select 1 limit 1, ?"; +execute s using @a; +ERROR 22003: unsigned integer value is out of range in 'EXECUTE' +prepare s from "select 1 limit ?, ?"; +execute s using @a, @a; +ERROR 22003: unsigned integer value is out of range in 'EXECUTE' +set @a=14632475938453979136; +execute s using @a, @a; +1 +set @a=-14632475938453979136; +execute s using @a, @a; +ERROR HY000: Incorrect arguments to EXECUTE +End of 5.0 tests +select 1 as a limit 4294967296,10; +a +End of 5.1 tests +# Bug #28961843: COUNT() WITH LIMIT AND OFFSET RETURNS WRONG RESULT +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +SELECT COUNT(*) FROM t1 LIMIT 1 OFFSET 3; +COUNT(*) +DROP TABLE t1; +# +# Bug #29148115: SIG 6 IN TEMPTABLE::RESULT TEMPTABLE::HANDLER::INDEX_NEXT_CONDITIONAL +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (1); +SELECT t1.pk FROM (SELECT DISTINCT * FROM t1) AS t1 WHERE t1.pk=1 LIMIT 1 OFFSET 2; +pk +DROP TABLE t1; +# +# Bug #29373972: SIG 6 AT HANDLER::START_PSI_BATCH_MODE() +# +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='block_nested_loop=off'; +CREATE TABLE t1 ( pk INTEGER ); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN FORMAT=tree SELECT JSON_OBJECTAGG(NULL, '') FROM t1, t1 AS t2 GROUP BY t1.pk LIMIT 2 OFFSET 5; +EXPLAIN +-> Limit/Offset: 2/5 row(s) + -> Group aggregate: json_objectagg(NULL,'') + -> Nested loop inner join (cost=1.35 rows=4) + -> Sort: t1.pk (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Table scan on t2 (cost=0.35 rows=2) + +SELECT JSON_OBJECTAGG(NULL, '') FROM t1, t1 AS t2 GROUP BY t1.pk LIMIT 2 OFFSET 5; +ERROR 22032: JSON documents may not contain NULL member names. +FLUSH TABLES; +DROP TABLE t1; +set optimizer_switch=@old_opt_switch; +# +# Bug#29531472: SIG 6 AT JOIN::TEST_SKIP_SORT | SQL_OPTIMIZER.CC +# +CREATE TABLE t1 ( +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +KEY idx_CC_col_int_key (col_int_key), +KEY idx_CC_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES(1,'A'); +SELECT col_varchar_key AS f1 +FROM t1 +WHERE (col_int_key NOT BETWEEN 10 AND 15 OR col_varchar_key < '2') AND col_int_key IS NULL +GROUP BY f1 LIMIT 100; +f1 +EXPLAIN +SELECT col_varchar_key AS f1 +FROM t1 +WHERE (col_int_key NOT BETWEEN 10 AND 15 OR col_varchar_key < '2') AND col_int_key IS NULL +GROUP BY f1 LIMIT 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index idx_CC_col_int_key,idx_CC_col_varchar_key idx_CC_col_varchar_key 7 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `f1` from `test`.`t1` where (((`test`.`t1`.`col_int_key` not between 10 and 15) or (`test`.`t1`.`col_varchar_key` < '2')) and (`test`.`t1`.`col_int_key` is null)) group by `f1` limit 100 +DROP TABLE t1; +# +# Bug#30521803: LIMIT CLAUSE OUTSIDE PARENTHESES CAN SUPPRESS ORDERING +# CLAUSES INSIDE +# +CREATE TEMPORARY TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# All 3 queries below should return the same result: +SELECT * FROM (SELECT * FROM t1 ORDER BY i DESC LIMIT 3) AS alias LIMIT 2; +i +5 +4 +(SELECT * FROM t1 ORDER BY i DESC LIMIT 3) LIMIT 2; +i +5 +4 +WITH cte AS (SELECT 1) (SELECT * FROM t1 ORDER BY i DESC LIMIT 3) LIMIT 2; +i +5 +4 +DROP TABLE t1; +# +# Bug#30204811 ASSERTION `SELECT_LIMIT > 0' FAILED AT +# TEST_IF_SKIP_SORT_ORDER +# +CREATE TABLE a ( +col_int int, +col_varchar_255 varchar(255), +pk integer auto_increment primary key +) ENGINE=myisam; +CREATE TABLE b ( +col_varchar_10 varchar(10), +pk integer primary key +) ENGINE=myisam; +INSERT INTO a(col_int,col_varchar_255) VALUES (0,""),(1,""); +explain format=tree SELECT STRAIGHT_JOIN a.pk +FROM a +JOIN b ON a.col_varchar_255 = b.col_varchar_10 +WHERE b.pk <= a.col_int +ORDER BY a.pk LIMIT 10; +EXPLAIN +-> Limit: 10 row(s) (cost=1.21 rows=0) + -> Nested loop inner join (cost=1.21 rows=0) + -> Sort: a.pk (cost=0.70 rows=2) + -> Table scan on a (cost=0.70 rows=2) + -> Filter: ((b.pk <= a.col_int) and (a.col_varchar_255 = b.col_varchar_10)) (cost=0.50 rows=0) + -> Index range scan on b (re-planned for each iteration) (cost=0.50 rows=0) + +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +INSERT INTO a(col_int,col_varchar_255) SELECT col_int,col_varchar_255 FROM a; +explain format=tree SELECT STRAIGHT_JOIN a.pk +FROM a +JOIN b ON a.col_varchar_255 = b.col_varchar_10 +WHERE b.pk <= a.col_int +ORDER BY a.pk LIMIT 10; +EXPLAIN +-> Limit: 10 row(s) (cost=423.65 rows=0) + -> Nested loop inner join (cost=423.65 rows=0) + -> Sort: a.pk (cost=415.10 rows=4096) + -> Table scan on a (cost=415.10 rows=4096) + -> Filter: ((b.pk <= a.col_int) and (a.col_varchar_255 = b.col_varchar_10)) (cost=8.55 rows=0) + -> Index range scan on b (re-planned for each iteration) (cost=8.55 rows=0) + +DROP TABLE a; +DROP TABLE b; +# Bug#31667061: Inconsistent behavior of @@SQL_SELECT_LIMIT +# with prepared statements +CREATE TABLE t1(id INTEGER); +INSERT INTO t1 (id) VALUES (1), (2), (3); +SET @@sql_select_limit=1; +PREPARE stmt FROM "SELECT * FROM t1 WHERE id > ?"; +SET @a = 0; +EXECUTE stmt using @a; +id +1 +set @@sql_select_limit=2; +EXECUTE stmt using @a; +id +1 +2 +set @@sql_select_limit=DEFAULT; +EXECUTE stmt USING @a; +id +1 +2 +3 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +CREATE TABLE t1(id INTEGER, c1 INTEGER, c2 INTEGER, c3 INTEGER); +INSERT INTO t1 VALUES(1,1,1,1),(2,2,2,2),(3,9,9,9),(4,10,10,10),(6,1,2,888); +PREPARE stmt FROM +"(SELECT * FROM t1 LIMIT 2) UNION ALL (SELECT * FROM t1 ORDER BY 1)"; +SET @@sql_select_limit=2; +EXECUTE stmt; +id c1 c2 c3 +1 1 1 1 +2 2 2 2 +SET @@sql_select_limit=DEFAULT; +EXECUTE stmt; +id c1 c2 c3 +1 1 1 1 +2 2 2 2 +1 1 1 1 +2 2 2 2 +3 9 9 9 +4 10 10 10 +6 1 2 888 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; diff --git a/mysql-test/r/loose_scan.result-pq b/mysql-test/r/loose_scan.result-pq new file mode 100644 index 000000000..954da2b1c --- /dev/null +++ b/mysql-test/r/loose_scan.result-pq @@ -0,0 +1,212 @@ +# +# Bug#13464493 "19 X HIGHER THAN EXPECTED EXEC. TIME FOR +# MYSQL_BENCH/COUNT_DISTINCT_KEY_PREFIX" +# +CREATE TABLE t1 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +PRIMARY KEY (c1,i1), +UNIQUE KEY k1 (c1,i2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('A',0,999),('A',6,993),('A',12,987), +('A',18,981),('A',24,975),('A',30,969),('A',36,963),('A',42,957), +('A',48,951),('A',54,945),('A',60,939),('A',66,933),('A',72,927), +('A',78,921),('A',84,915),('A',90,909),('A',96,903),('A',102,897), +('A',108,891),('A',114,885),('A',120,879),('A',126,873),('A',132,867), +('A',138,861),('A',144,855),('A',150,849),('A',156,843),('A',162,837), +('A',168,831),('A',174,825),('A',180,819),('A',186,813),('A',192,807), +('A',198,801),('A',204,795),('B',210,789),('B',216,783),('B',222,777), +('B',228,771),('B',234,765),('B',240,759),('B',246,753),('B',252,747), +('B',258,741),('B',264,735),('B',270,729),('B',276,723),('B',282,717), +('B',288,711),('B',294,705),('B',300,699),('B',306,693),('B',312,687), +('B',318,681),('B',324,675),('B',330,669),('B',336,663),('B',342,657), +('B',348,651),('B',354,645),('B',360,639),('B',366,633),('B',372,627), +('B',378,621),('C',384,615),('C',390,609),('C',396,603),('C',402,597), +('C',408,591),('C',414,585),('C',420,579),('C',426,573),('C',432,567), +('C',438,561),('C',444,555),('C',450,549),('C',456,543),('C',462,537), +('C',468,531),('C',474,525),('C',480,519),('C',486,513),('C',492,507), +('C',498,501),('C',504,495),('C',510,489),('C',516,483),('C',522,477), +('C',528,471),('C',534,465),('C',540,459),('C',546,453),('C',552,447), +('C',558,441),('C',564,435),('C',570,429),('C',576,423),('C',582,417), +('C',588,411),('C',594,405); +ANALYZE TABLE t1; +EXPLAIN SELECT COUNT(DISTINCT c1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,k1 k1 4 NULL 4 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` +SELECT COUNT(DISTINCT c1) FROM t1; +COUNT(DISTINCT c1) +3 +DROP TABLE t1; +# +# Bug#11757108 "CHANGE IN EXECUTION PLAN FOR COUNT_DISTINCT_GROUP_ON_KEY +# CAUSES PEFORMANCE REGRESSIONS" +# +CREATE TABLE t0 ( +i1 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30); +CREATE TABLE t1 ( +c1 CHAR(1) NOT NULL, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +PRIMARY KEY (c1,i1), +UNIQUE KEY k1 (c1,i2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 SELECT 'A',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'B',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'C',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'D',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'E',i1,i1 FROM t0; +INSERT INTO t1 SELECT 'F',i1,i1 FROM t0; +ANALYZE TABLE t1; +EXPLAIN select c1,count(distinct i2) from t1 group by c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY,k1 k1 8 NULL 181 100.00 Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,count(distinct `test`.`t1`.`i2`) AS `count(distinct i2)` from `test`.`t1` group by `test`.`t1`.`c1` +FLUSH STATUS; +select c1,count(distinct i2) from t1 group by c1; +c1 count(distinct i2) +A 30 +B 30 +C 30 +D 30 +E 30 +F 30 +SHOW STATUS LIKE 'Handler_read_key'; +Variable_name Value +Handler_read_key 2 +SHOW STATUS LIKE 'Handler_read_next'; +Variable_name Value +Handler_read_next 180 +DROP TABLE t0, t1; +# +# Bug#17222452 SELECT COUNT(DISTINCT A,B) INCORRECTLY COUNTS +# ROWS CONTAINING NULL +# +CREATE TABLE t (a INT, b INT,KEY k(a,b)); +INSERT INTO t VALUES (1,2), +(NULL,3),(3,3),(1,NULL), +(NULL,2), (NULL,NULL); +EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range k k 10 NULL # # Using index for group-by (scanning) +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a,b)` from `test`.`t` +SELECT COUNT(DISTINCT a,b) FROM t; +COUNT(DISTINCT a,b) +2 +EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t IGNORE INDEX (k); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t`.`a`,`test`.`t`.`b`) AS `COUNT(DISTINCT a,b)` from `test`.`t` IGNORE INDEX (`k`) +SELECT COUNT(DISTINCT a,b) FROM t IGNORE INDEX (k); +COUNT(DISTINCT a,b) +2 +DROP TABLE t; +# +# Bug#16982071: ASSERT `TAB->KEYS.IS_SET(KEYNO)' FAILED IN +# SETUP_SEMIJOIN_DUPS_ELIMINATION +# +CREATE TABLE t1 ( +pk INTEGER, +col_int INTEGER, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) CHARSET utf8mb4; +INSERT INTO t2 VALUES (1, 'g'); +CREATE TABLE t3 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) CHARSET utf8mb4; +INSERT INTO t3 VALUES (1, 'v'),(2, NULL); +EXPLAIN SELECT t1.col_int +FROM t1, t3 +WHERE t3.col_varchar_key IN ( +SELECT t2.col_varchar_key FROM t2 WHERE t2.pk > t1.col_int +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL # 100.00 Using where; Using index; LooseScan +2 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key # 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1.col_int' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (`test`.`t2`.`pk` > `test`.`t1`.`col_int`)) +SELECT t1.col_int +FROM t1, t3 +WHERE t3.col_varchar_key IN ( +SELECT t2.col_varchar_key FROM t2 WHERE t2.pk > t1.col_int +); +col_int +DROP TABLE t1, t2, t3; +# +# Bug #30659810: INCORRECT QUERY RESULTS +# +CREATE TABLE t1 ( +a INTEGER NOT NULL +); +INSERT INTO t1 VALUES (2),(2); +CREATE TABLE t2 ( +b INTEGER +); +INSERT INTO t2 VALUES (2),(11),(11); +CREATE TABLE t3 ( +b INTEGER, +pk INTEGER, +KEY b_key (b) +); +INSERT INTO t3 VALUES (2,5); +CREATE TABLE t4 ( +pk INTEGER NOT NULL +); +INSERT INTO t4 VALUES (5),(7); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=TREE SELECT * +FROM t1 +JOIN t2 ON t1.a = t2.b +WHERE t2.b IN ( +SELECT t3.b +FROM t3 JOIN t4 ON t3.pk = t4.pk +); +EXPLAIN +-> Parallel scan on + -> Inner hash join (t2.b = t1.a) (cost=2.00 rows=2) + -> Table scan on t2 (cost=0.18 rows=3) + -> Hash + -> Nested loop inner join (cost=1.15 rows=2) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Nested loop semijoin with duplicate removal on b_key (cost=1.00 rows=1) + -> Index lookup on t3 using b_key (b=t1.a) (cost=0.30 rows=1) + -> Filter: (t4.pk = t3.pk) (cost=0.30 rows=1) + -> Table scan on t4 (cost=0.30 rows=2) + +SELECT * +FROM t1 +JOIN t2 ON t1.a = t2.b +WHERE t2.b IN ( +SELECT t3.b +FROM t3 JOIN t4 ON t3.pk = t4.pk +); +a b +2 2 +2 2 +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/r/metadata.result-pq b/mysql-test/r/metadata.result-pq new file mode 100644 index 000000000..b9465e148 --- /dev/null +++ b/mysql-test/r/metadata.result-pq @@ -0,0 +1,454 @@ +select 1, 1.0, -1, "hello", NULL; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def 1 8 1 1 N 32897 0 63 +def 1.0 246 4 3 N 32897 1 63 +def -1 8 2 2 N 32897 0 63 +def hello 253 20 5 N 1 31 255 +def NULL 6 0 0 Y 32896 0 63 +1 1.0 -1 hello NULL +1 1.0 -1 hello NULL +create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +select * from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a 1 4 0 Y 32768 0 63 +def test t1 t1 b b 2 6 0 Y 32768 0 63 +def test t1 t1 c c 9 9 0 Y 32768 0 63 +def test t1 t1 d d 3 11 0 Y 32768 0 63 +def test t1 t1 e e 8 20 0 Y 32768 0 63 +def test t1 t1 f f 4 3 0 Y 32768 2 63 +def test t1 t1 g g 5 4 0 Y 32768 3 63 +def test t1 t1 h h 246 7 0 Y 32768 4 63 +def test t1 t1 i i 13 4 0 Y 32864 0 63 +def test t1 t1 j j 10 10 0 Y 128 0 63 +def test t1 t1 k k 7 19 0 N 129 0 63 +def test t1 t1 l l 12 19 0 Y 128 0 63 +def test t1 t1 m m 254 4 0 Y 256 0 255 +def test t1 t1 n n 254 12 0 Y 2048 0 255 +def test t1 t1 o o 254 40 0 Y 0 0 255 +a b c d e f g h i j k l m n o +select a b, b c from t1 as t2; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t2 a b 1 4 0 Y 32768 0 63 +def test t1 t2 b c 2 6 0 Y 32768 0 63 +b c +drop table t1; +CREATE TABLE t1 (id tinyint(3) default NULL, data varchar(255) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'male'),(2,'female'); +CREATE TABLE t2 (id tinyint(3) unsigned default NULL, data char(3) default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'yes'),(2,'no'); +select t1.id, t1.data, t2.data from t1, t2 where t1.id = t2.id; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 id id 1 3 1 Y 32768 0 63 +def test t1 t1 data data 253 1020 6 Y 0 0 255 +def test t2 t2 data data 254 12 3 Y 0 0 255 +id data data +1 male yes +2 female no +select t1.id, t1.data, t2.data from t1, t2 where t1.id = t2.id order by t1.id; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 id id 1 3 1 Y 32768 0 63 +def test t1 t1 data data 253 1020 6 Y 0 0 255 +def test t2 t2 data data 254 12 3 Y 0 0 255 +id data data +1 male yes +2 female no +select t1.id from t1 union select t2.id from t2; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def id id 2 4 1 Y 32768 0 63 +id +1 +2 +drop table t1,t2; +create table t1 ( a int, b varchar(30), primary key(a)); +insert into t1 values (1,'one'); +insert into t1 values (2,'two'); +set @arg00=1 ; +select @arg00 FROM t1 where a=1 union distinct select 1 FROM t1 where a=1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg00 @arg00 8 21 1 Y 32768 0 63 +@arg00 +1 +select * from (select @arg00) aaa; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def aaa @arg00 @arg00 8 21 1 Y 32768 0 63 +@arg00 +1 +select 1 union select 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def 1 1 8 1 1 N 32769 0 63 +1 +1 +select * from (select 1 union select 1) aaa; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def aaa 1 1 8 1 1 N 32769 0 63 +1 +1 +drop table t1; +create table t1 (i int); +insert into t1 values (1),(2),(3); +select * from t1 where i = 2; +drop table t1;// +affected rows: 0 +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +i +2 +affected rows: 1 +affected rows: 0 +select a.* from (select 2147483648 as v_large) a; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def a v_large v_large 8 10 10 N 32769 0 63 +v_large +2147483648 +select a.* from (select 214748364 as v_small) a; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def a v_small v_small 3 9 9 N 32769 0 63 +v_small +214748364 +CREATE TABLE t1 (c1 CHAR(1)); +CREATE TABLE t2 (c2 CHAR(1)); +CREATE VIEW v1 AS SELECT t1.c1 FROM t1; +CREATE VIEW v2 AS SELECT t2.c2 FROM t2; +INSERT INTO t1 VALUES ('1'), ('2'), ('3'); +INSERT INTO t2 VALUES ('1'), ('2'), ('3'), ('2'); +SELECT v1.c1 FROM v1 JOIN t2 ON c1=c2 ORDER BY 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 v1 c1 c1 254 4 1 Y 0 0 255 +c1 +1 +2 +2 +3 +SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +1 1 +2 2 +2 2 +3 3 +c1 c2 +def test v1 v1 c1 c1 254 4 1 Y 0 0 255 +def test v2 v2 c2 c2 254 4 1 Y 0 0 255 +SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2 GROUP BY v1.c1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 v1 c1 c1 254 4 1 Y 32768 0 255 +def test t2 v2 c2 c2 254 4 1 Y 0 0 255 +c1 c2 +1 1 +2 2 +3 3 +SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2 GROUP BY v1.c1 ORDER BY v2.c2; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 v1 c1 c1 254 4 1 Y 32768 0 255 +def test t2 v2 c2 c2 254 4 1 Y 0 0 255 +c1 c2 +1 1 +2 2 +3 3 +DROP VIEW v1,v2; +DROP TABLE t1,t2; +CREATE TABLE t1 (i INT, d DATE); +INSERT INTO t1 VALUES (1, '2008-01-01'), (2, '2008-01-02'), (3, '2008-01-03'); +SELECT COALESCE(d, d), IFNULL(d, d), IF(i, d, d), +CASE i WHEN i THEN d ELSE d END, GREATEST(d, d), LEAST(d, d) +FROM t1 ORDER BY RAND(); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +2008-01-01 2008-01-01 2008-01-01 2008-01-01 2008-01-01 2008-01-01 +2008-01-02 2008-01-02 2008-01-02 2008-01-02 2008-01-02 2008-01-02 +2008-01-03 2008-01-03 2008-01-03 2008-01-03 2008-01-03 2008-01-03 +COALESCE(d, d) IFNULL(d, d) IF(i, d, d) CASE i WHEN i THEN d ELSE d END GREATEST(d, d) LEAST(d, d) +def CASE i WHEN i THEN d ELSE d END CASE i WHEN i THEN d ELSE d END 10 10 10 Y 128 0 63 +def COALESCE(d, d) COALESCE(d, d) 10 10 10 Y 128 0 63 +def GREATEST(d, d) GREATEST(d, d) 10 10 10 Y 128 0 63 +def IF(i, d, d) IF(i, d, d) 10 10 10 Y 128 0 63 +def IFNULL(d, d) IFNULL(d, d) 10 10 10 Y 128 0 63 +def LEAST(d, d) LEAST(d, d) 10 10 10 Y 128 0 63 +DROP TABLE t1; +# +# Bug#41788 mysql_fetch_field returns org_table == table by a view +# +CREATE TABLE t1 (f1 INT); +CREATE VIEW v1 AS SELECT f1 FROM t1; +SELECT f1 FROM v1 va; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v1 va f1 f1 3 11 0 Y 32768 0 63 +f1 +DROP VIEW v1; +DROP TABLE t1; +End of 5.0 tests +create table t1( +# numeric types +bool_col bool, +boolean_col boolean, +bit_col bit(5), +tiny tinyint, +tiny_uns tinyint unsigned, +small smallint, +small_uns smallint unsigned, +medium mediumint, +medium_uns mediumint unsigned, +int_col int, +int_col_uns int unsigned, +big bigint, +big_uns bigint unsigned, +decimal_col decimal(10,5), +# synonyms of DECIMAL +numeric_col numeric(10), +fixed_col fixed(10), +dec_col dec(10), +decimal_col_uns decimal(10,5) unsigned, +fcol float, +fcol_uns float unsigned, +dcol double, +double_precision_col double precision, +dcol_uns double unsigned, +# date/time types +date_col date, +time_col time, +timestamp_col timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +year_col year, +datetime_col datetime, +# string types +char_col char(5), +varchar_col varchar(10), +binary_col binary(10), +varbinary_col varbinary(10), +tinyblob_col tinyblob, +blob_col blob, +mediumblob_col mediumblob, +longblob_col longblob, +text_col text, +mediumtext_col mediumtext, +longtext_col longtext, +enum_col enum("A","B","C"), +set_col set("F","E","D") +); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +select * from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 bool_col bool_col 1 1 0 Y 32768 0 63 +def test t1 t1 boolean_col boolean_col 1 1 0 Y 32768 0 63 +def test t1 t1 bit_col bit_col 16 5 0 Y 32 0 63 +def test t1 t1 tiny tiny 1 4 0 Y 32768 0 63 +def test t1 t1 tiny_uns tiny_uns 1 3 0 Y 32800 0 63 +def test t1 t1 small small 2 6 0 Y 32768 0 63 +def test t1 t1 small_uns small_uns 2 5 0 Y 32800 0 63 +def test t1 t1 medium medium 9 9 0 Y 32768 0 63 +def test t1 t1 medium_uns medium_uns 9 8 0 Y 32800 0 63 +def test t1 t1 int_col int_col 3 11 0 Y 32768 0 63 +def test t1 t1 int_col_uns int_col_uns 3 10 0 Y 32800 0 63 +def test t1 t1 big big 8 20 0 Y 32768 0 63 +def test t1 t1 big_uns big_uns 8 20 0 Y 32800 0 63 +def test t1 t1 decimal_col decimal_col 246 12 0 Y 32768 5 63 +def test t1 t1 numeric_col numeric_col 246 11 0 Y 32768 0 63 +def test t1 t1 fixed_col fixed_col 246 11 0 Y 32768 0 63 +def test t1 t1 dec_col dec_col 246 11 0 Y 32768 0 63 +def test t1 t1 decimal_col_uns decimal_col_uns 246 11 0 Y 32800 5 63 +def test t1 t1 fcol fcol 4 12 0 Y 32768 31 63 +def test t1 t1 fcol_uns fcol_uns 4 12 0 Y 32800 31 63 +def test t1 t1 dcol dcol 5 22 0 Y 32768 31 63 +def test t1 t1 double_precision_col double_precision_col 5 22 0 Y 32768 31 63 +def test t1 t1 dcol_uns dcol_uns 5 22 0 Y 32800 31 63 +def test t1 t1 date_col date_col 10 10 0 Y 128 0 63 +def test t1 t1 time_col time_col 11 10 0 Y 128 0 63 +def test t1 t1 timestamp_col timestamp_col 7 19 0 N 9345 0 63 +def test t1 t1 year_col year_col 13 4 0 Y 32864 0 63 +def test t1 t1 datetime_col datetime_col 12 19 0 Y 128 0 63 +def test t1 t1 char_col char_col 254 20 0 Y 0 0 255 +def test t1 t1 varchar_col varchar_col 253 40 0 Y 0 0 255 +def test t1 t1 binary_col binary_col 254 10 0 Y 128 0 63 +def test t1 t1 varbinary_col varbinary_col 253 10 0 Y 128 0 63 +def test t1 t1 tinyblob_col tinyblob_col 252 255 0 Y 144 0 63 +def test t1 t1 blob_col blob_col 252 65535 0 Y 144 0 63 +def test t1 t1 mediumblob_col mediumblob_col 252 16777215 0 Y 144 0 63 +def test t1 t1 longblob_col longblob_col 252 4294967295 0 Y 144 0 63 +def test t1 t1 text_col text_col 252 262140 0 Y 16 0 255 +def test t1 t1 mediumtext_col mediumtext_col 252 67108860 0 Y 16 0 255 +def test t1 t1 longtext_col longtext_col 252 4294967295 0 Y 16 0 255 +def test t1 t1 enum_col enum_col 254 4 0 Y 256 0 255 +def test t1 t1 set_col set_col 254 20 0 Y 2048 0 255 +bool_col boolean_col bit_col tiny tiny_uns small small_uns medium medium_uns int_col int_col_uns big big_uns decimal_col numeric_col fixed_col dec_col decimal_col_uns fcol fcol_uns dcol double_precision_col dcol_uns date_col time_col timestamp_col year_col datetime_col char_col varchar_col binary_col varbinary_col tinyblob_col blob_col mediumblob_col longblob_col text_col mediumtext_col longtext_col enum_col set_col +drop table t1; +# +# WL#946 TIME/DATETIME/TIMESTAMP with fractional precision +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +t6 TIME(6), t5 TIME(5), t4 TIME(4), +t3 TIME(3), t2 TIME(2), t1 TIME(1), +t0 TIME, +dt6 DATETIME(6), dt5 DATETIME(5), dt4 DATETIME(4), +dt3 DATETIME(3), dt2 DATETIME(2), dt1 DATETIME(1), +dt0 DATETIME, +ts6 TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), +ts5 TIMESTAMP(5) NOT NULL DEFAULT '0000-00-00 00:00:00', +ts4 TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00', +ts3 TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00', +ts2 TIMESTAMP(2) NOT NULL DEFAULT '0000-00-00 00:00:00', +ts1 TIMESTAMP(1) NOT NULL DEFAULT '0000-00-00 00:00:00', +ts0 TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' +); +SELECT * FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 t6 t6 11 17 0 Y 128 6 63 +def test t1 t1 t5 t5 11 16 0 Y 128 5 63 +def test t1 t1 t4 t4 11 15 0 Y 128 4 63 +def test t1 t1 t3 t3 11 14 0 Y 128 3 63 +def test t1 t1 t2 t2 11 13 0 Y 128 2 63 +def test t1 t1 t1 t1 11 12 0 Y 128 1 63 +def test t1 t1 t0 t0 11 10 0 Y 128 0 63 +def test t1 t1 dt6 dt6 12 26 0 Y 128 6 63 +def test t1 t1 dt5 dt5 12 25 0 Y 128 5 63 +def test t1 t1 dt4 dt4 12 24 0 Y 128 4 63 +def test t1 t1 dt3 dt3 12 23 0 Y 128 3 63 +def test t1 t1 dt2 dt2 12 22 0 Y 128 2 63 +def test t1 t1 dt1 dt1 12 21 0 Y 128 1 63 +def test t1 t1 dt0 dt0 12 19 0 Y 128 0 63 +def test t1 t1 ts6 ts6 7 26 0 N 129 6 63 +def test t1 t1 ts5 ts5 7 25 0 N 129 5 63 +def test t1 t1 ts4 ts4 7 24 0 N 129 4 63 +def test t1 t1 ts3 ts3 7 23 0 N 129 3 63 +def test t1 t1 ts2 ts2 7 22 0 N 129 2 63 +def test t1 t1 ts1 ts1 7 21 0 N 129 1 63 +def test t1 t1 ts0 ts0 7 19 0 N 129 0 63 +t6 t5 t4 t3 t2 t1 t0 dt6 dt5 dt4 dt3 dt2 dt1 dt0 ts6 ts5 ts4 ts3 ts2 ts1 ts0 +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#22364401: COM_QUERY RESPONSE METADATA WITH '*' IN FIELD ORG_TABLE +# +CREATE TABLE t1 (f1 INTEGER, f2 CHAR(1)); +INSERT INTO t1 VALUES (10, 'A'); +CREATE VIEW v1 AS SELECT f1, f2 FROM t1; +CREATE VIEW v2 AS SELECT DISTINCT f1 FROM t1; +SELECT * FROM (SELECT f1 FROM t1) AS dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t1 dt f1 f1 3 11 2 Y 32768 0 63 +f1 +10 +SELECT * FROM (SELECT f1 FROM (SELECT f1 FROM t1) AS dt1) AS dt2; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t1 dt2 f1 f1 3 11 2 Y 32768 0 63 +f1 +10 +SELECT * +FROM (SELECT t1.f1 AS a, t2.f1 AS b, t1.f1+t2.f1 AS d FROM t1 JOIN t1 AS t2) AS dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t1 dt a a 3 11 2 Y 32768 0 63 +def t1 dt b b 3 11 2 Y 32768 0 63 +def dt d d 8 12 2 Y 32896 0 63 +a b d +10 10 20 +SELECT * FROM (SELECT DISTINCT f1 FROM t1) AS dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 dt f1 f1 3 11 2 Y 32768 0 63 +f1 +10 +SELECT * FROM (SELECT DISTINCT t1.f1+t2.f1 AS d FROM t1 JOIN t1 AS t2) AS dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def dt d d 8 12 2 Y 32768 0 63 +d +20 +SELECT * FROM v1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v1 v1 f1 f1 3 11 2 Y 32768 0 63 +def test v1 v1 f2 f2 254 4 1 Y 0 0 255 +f1 f2 +10 A +SELECT * FROM v2; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 v2 f1 f1 3 11 2 Y 32768 0 63 +f1 +10 +SELECT * FROM (SELECT * FROM v1) AS dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 dt f1 f1 3 11 2 Y 32768 0 63 +def test t1 dt f2 f2 254 4 1 Y 0 0 255 +f1 f2 +10 A +SELECT * FROM (SELECT * FROM v2) AS dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v2 dt f1 f1 3 11 2 Y 32768 0 63 +f1 +10 +DROP VIEW v1,v2; +DROP TABLE t1; +# End of test for Bug#22364401 +# Testing Org_table/Table/DB returned to client for derived tables +create table t(a int); +create view v as select a as d, 2*a as two from t; +select a as d from t limit 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t t a d 3 11 0 Y 32768 0 63 +d +select * from (select a as d, 2*a as two from t) dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t dt d d 3 11 0 Y 32768 0 63 +def dt two two 8 12 0 Y 32896 0 63 +d two +select d, two from (select a as d, 2*a as two from t) dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t dt d d 3 11 0 Y 32768 0 63 +def dt two two 8 12 0 Y 32896 0 63 +d two +select d as e, two as f from (select a as d, 2*a as two from t) dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def t dt e e 3 11 0 Y 32768 0 63 +def dt f f 8 12 0 Y 32896 0 63 +e f +select * from v; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v v d d 3 11 0 Y 32768 0 63 +def v v two two 8 12 0 Y 32896 0 63 +d two +select d, two from v; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v v d d 3 11 0 Y 32768 0 63 +def v v two two 8 12 0 Y 32896 0 63 +d two +select d as e, two as f from v; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v v d e 3 11 0 Y 32768 0 63 +def v v two f 8 12 0 Y 32896 0 63 +e f +set optimizer_switch="derived_merge=off"; +select * from (select a as d, 2*a as two from t) dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t dt d d 3 11 0 Y 32768 0 63 +def dt two two 8 12 0 Y 32768 0 63 +d two +select d from (select a as d, 2*a as two from t) dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t dt d d 3 11 0 Y 32768 0 63 +d +select d as e from (select a as d, 2*a as two from t) dt; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t dt d e 3 11 0 Y 32768 0 63 +e +select * from v; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t v d d 3 11 0 Y 32768 0 63 +def test v v two two 8 12 0 Y 32768 0 63 +d two +select d, two from v; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v v d d 3 11 0 Y 32768 0 63 +def test v v two two 8 12 0 Y 32768 0 63 +d two +select d as e, two as f from v; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test v v d e 3 11 0 Y 32768 0 63 +def test v v two f 8 12 0 Y 32768 0 63 +e f +set optimizer_switch=default; +drop view v; +drop table t; diff --git a/mysql-test/r/myisam_explain_json_non_select_all.result-pq b/mysql-test/r/myisam_explain_json_non_select_all.result-pq new file mode 100644 index 000000000..17a8b536a --- /dev/null +++ b/mysql-test/r/myisam_explain_json_non_select_all.result-pq @@ -0,0 +1,8249 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": true, + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "1.60", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "1.60", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.30", + "prefix_cost": "1.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "3.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.30", + "prefix_cost": "1.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "3.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`a` < 3)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` where (NULL > 0) order by NULL +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.51" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.00", + "prefix_cost": "1.51", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.67" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.50", + "prefix_cost": "2.67", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.67" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.50", + "prefix_cost": "2.67", + "data_read_per_join": "240" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double)))" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))", + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))", + "backward_index_scan": true, + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))", + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "index_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))", + "backward_index_scan": true, + "cost_info": { + "read_cost": "1.46", + "eval_cost": "0.80", + "prefix_cost": "2.26", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`c1_idx` = 'y')", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`c1_idx` = 'y')", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "x", + "access_type": "ref", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.a" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "first_match": "t1", + "cost_info": { + "read_cost": "1.50", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "4.30", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where (`x`.`b` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/myisam_explain_json_non_select_none.result-pq b/mysql-test/r/myisam_explain_json_non_select_none.result-pq new file mode 100644 index 000000000..1bf175c17 --- /dev/null +++ b/mysql-test/r/myisam_explain_json_non_select_none.result-pq @@ -0,0 +1,8270 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE t1.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` = 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */, + "optimized_away_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` < 3)" + } /* table */ + } /* query_block */ + } + ] /* optimized_away_subqueries */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t12", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "1" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "message": "No tables used" + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,'1' AS `1` from `test`.`t1` `t11` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.60" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 1)" + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "1.60", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` where (`test`.`t11`.`a` > 1) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 1 LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.70", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 1)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 USING t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "Impossible WHERE" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` = 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "const", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'3' AS `b` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a < 3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.71" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "a" + ] /* possible_keys */, + "key": "a", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "5", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 3)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 3) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` where (NULL > 0) order by NULL +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 0)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 4, + "filtered": "100.00", + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "index", + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(0 <> (@a:=`test`.`t1`.`a`))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.51" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.00", + "prefix_cost": "1.51", + "data_read_per_join": "160" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.90" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a1", + "b1" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a2" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t1.a1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "1.85", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2", + "b2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a3", + "b3" + ] /* used_key_parts */, + "key_length": "8", + "ref": [ + "test.t2.b2", + "test.t1.b1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.30", + "prefix_cost": "2.90", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a3", + "b3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2`,`test`.`t3`.`a3` AS `a3`,`test`.`t3`.`b3` AS `b3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT a FROM t2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`)))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 1, + "filtered": "33.33", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.80", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`a`) = `test`.`t2`.`a`)" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "40" + } /* cost_info */, + "used_columns": [ + "a1" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.01" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.84", + "eval_cost": "0.10", + "prefix_cost": "1.01", + "data_read_per_join": "48" + } /* cost_info */, + "used_columns": [ + "a2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`))" + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1` from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "filtered": "100.00", + "message": "Deleting all rows" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "80" + } /* cost_info */, + "used_columns": [ + "i", + "j" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "table": { + "insert": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t1 AS tt USING(i);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "33.33", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "2.20", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */, + "attached_condition": "(`test`.`tt`.`i` = `test`.`t1`.`i`)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t2 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "replace": true, + "table_name": "t2", + "access_type": "ALL" + } /* table */, + "insert_from": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* insert_from */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "i" + ] /* used_columns */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON REPLACE INTO t1 SET i = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "replace": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": false, + "table": { + "delete": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.01" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.89" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "i" + ] /* possible_keys */, + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "11.11", + "cost_info": { + "read_cost": "2.83", + "eval_cost": "0.29", + "prefix_cost": "3.12", + "data_read_per_join": "46" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.13" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.87", + "eval_cost": "0.26", + "prefix_cost": "3.13", + "data_read_per_join": "62" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 17602, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1778.96" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ] /* used_key_parts */, + "key_length": "15", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1760, + "filtered": "10.00", + "cost_info": { + "read_cost": "1602.94", + "eval_cost": "176.02", + "prefix_cost": "1778.96", + "data_read_per_join": "41K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "2.89", + "eval_cost": "0.26", + "prefix_cost": "3.15", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00", + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.02" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "2.60" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.16", + "eval_cost": "0.26", + "prefix_cost": "5.42", + "data_read_per_join": "104" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c", + "d" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`b` = 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "filtered": "100.00", + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.73" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "index_merge", + "possible_keys": [ + "key1", + "key2" + ] /* possible_keys */, + "key": "sort_union(key1,key2)", + "key_length": "5,5", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.03", + "eval_cost": "0.70", + "prefix_cost": "3.73", + "data_read_per_join": "112" + } /* cost_info */, + "used_columns": [ + "i", + "key1", + "key2" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`key1` AS `key1`,`test`.`t2`.`key2` AS `key2` from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 8, + "filtered": "100.00", + "backward_index_scan": true, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.86" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "i" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "3.06", + "eval_cost": "0.80", + "prefix_cost": "3.86", + "data_read_per_join": "128" + } /* cost_info */, + "used_columns": [ + "a", + "i" + ] /* used_columns */, + "attached_condition": "((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18))" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.14" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 26, + "rows_produced_per_join": 26, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.54", + "eval_cost": "2.60", + "prefix_cost": "3.14", + "data_read_per_join": "832" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "update": true, + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "filtered": "100.00" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1783.26" + } /* cost_info */, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "t2", + "access_type": "index", + "key": "a", + "used_key_parts": [ + "a", + "b" + ] /* used_key_parts */, + "key_length": "18", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 17602, + "filtered": "100.00", + "backward_index_scan": true, + "cost_info": { + "read_cost": "23.06", + "eval_cost": "1760.20", + "prefix_cost": "1783.26", + "data_read_per_join": "412K" + } /* cost_info */, + "used_columns": [ + "a", + "b", + "c" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "c1_idx" + ] /* possible_keys */, + "key": "c1_idx", + "used_key_parts": [ + "c1_idx" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "pk", + "c1_idx", + "c2" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c1_idx` = 'y')" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1_idx` AS `c1_idx`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+10 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a > 34;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 34)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 34) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where true +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "system", + "rows_examined_per_scan": 0, + "rows_produced_per_join": 1, + "filtered": "0.00", + "const_row_not_found": true, + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "c1", + "c2", + "c3" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`c3` = 10)" + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,NULL AS `c1`,NULL AS `c2` from `test`.`t1` where (`test`.`t1`.`c3` = 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "filtered": "100.00" + } /* table */, + "update_value_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* update_value_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "f1" + ] /* used_columns */ + } /* table */, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "IDX" + ] /* possible_keys */, + "key": "IDX", + "used_key_parts": [ + "f3" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "test.t1.f1" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "f3", + "f4" + ] /* used_columns */ + } /* table */ + } /* query_block */ + } + ] /* select_list_subqueries */ + } /* query_block */ +} +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) AS `(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE v1 SET a = 1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a > 0;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.40" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` > 0)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.40", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` > 0) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "update": true, + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, v1 WHERE t1.a = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.50" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "50.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "1.60", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } /* table */ + }, + { + "table": { + "table_name": "t12", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 4, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "2.50", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t11`.`a` AS `a`,`test`.`t12`.`a` AS `b` from `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` where (`test`.`t11`.`a` = `test`.`t1`.`a`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "delete": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE a < 4;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.87" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.57", + "eval_cost": "0.30", + "prefix_cost": "0.87", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` < 4)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 4) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON DELETE v1 FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "delete": true, + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t2, v1 WHERE t2.x = v1.a;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.30" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "x" + ] /* used_columns */, + "attached_condition": "(`test`.`t2`.`x` is not null)" + } /* table */ + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "test.t2.x" + ] /* ref */, + "rows_examined_per_scan": 1, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.40", + "prefix_cost": "2.30", + "data_read_per_join": "64" + } /* cost_info */, + "used_columns": [ + "a", + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`x` AS `x`,`test`.`t1`.`a` AS `a`,(`test`.`t1`.`b` + 1) AS `c` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 VALUES (10);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "insert": true, + "table_name": "t1", + "access_type": "ALL" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT NULL;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `NULL` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON INSERT INTO v1 SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "no matching row in const table" + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select NULL AS `a` from `test`.`t1` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.80" + } /* cost_info */, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.20" + } /* cost_info */, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on )))", + "attached_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.70" + } /* cost_info */, + "table": { + "table_name": "x", + "access_type": "index_subquery", + "possible_keys": [ + "" + ] /* possible_keys */, + "key": "", + "used_key_parts": [ + "b" + ] /* used_key_parts */, + "key_length": "5", + "ref": [ + "func" + ] /* ref */, + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */, + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "3.80" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "3.00" + } /* cost_info */, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.30", + "prefix_cost": "0.80", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ + } /* materialized_from_subquery */ + } /* table */ + } /* query_block */ + } + ] /* attached_subqueries */ + } /* table */ + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.90", + "prefix_cost": "2.20", + "data_read_per_join": "72" + } /* cost_info */, + "used_columns": [ + "b" + ] /* used_columns */ + } /* table */ + } + ] /* nested_loop */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "using_temporary_table": "for update", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "16" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "query_block": { + "cost_info": { + "query_cost": "0.46" + } /* cost_info */, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* query_block */ + } /* table */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "ordering_operation": { + "using_filesort": true, + "table": { + "update": true, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "ref": [ + "const" + ] /* ref */, + "rows_examined_per_scan": 1, + "filtered": "100.00", + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +EXPLAIN FORMAT=JSON SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.46" + } /* cost_info */, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + } /* cost_info */, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "24" + } /* cost_info */, + "used_columns": [ + "(t1.a + 20)", + "a" + ] /* used_columns */, + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ] /* possible_keys */, + "key": "PRIMARY", + "used_key_parts": [ + "a" + ] /* used_key_parts */, + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "8" + } /* cost_info */, + "used_columns": [ + "a" + ] /* used_columns */, + "attached_condition": "(`test`.`t1`.`a` > 10)" + } /* table */ + } /* ordering_operation */ + } /* table */ + } /* ordering_operation */ + } /* query_block */ +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `t1` from `test`.`t1` where (`test`.`t1`.`a` > 10) order by `(t1.a + 20)` +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/myisam_explain_non_select_all.result-pq b/mysql-test/r/myisam_explain_non_select_all.result-pq new file mode 100644 index 000000000..fb59d5ba2 --- /dev/null +++ b/mysql-test/r/myisam_explain_non_select_all.result-pq @@ -0,0 +1,2520 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`b` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 7 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t2`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t2`.`a2` > 2) and (cast(`test`.`t1`.`a1` as double) = cast(`test`.`t2`.`a2` as double))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a 2 100.00 Using index; FirstMatch(t1) +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) set `test`.`t1`.`a` = 10 where (`x`.`b` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/myisam_explain_non_select_none.result-pq b/mysql-test/r/myisam_explain_non_select_none.result-pq new file mode 100644 index 000000000..c1af85a2d --- /dev/null +++ b/mysql-test/r/myisam_explain_non_select_none.result-pq @@ -0,0 +1,2517 @@ +set @save_storage_engine= @@session.default_storage_engine; +set session default_storage_engine = MyISAM; +set end_markers_in_json=on; +#1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +Handler_update 3 + +DROP TABLE t1; +#2 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a < 10 +# select: SELECT * FROM t1 WHERE a < 10 +# +EXPLAIN DELETE FROM t1 WHERE a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#3 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE a = 1 +# select: SELECT * FROM t1 WHERE a = 1 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 4 + +DROP TABLE t1; +#4 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1 +# select: SELECT * FROM t1, t2 WHERE t1.a = 1 +# +EXPLAIN UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#5 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` = 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_update 1 + +DROP TABLE t1, t2; +#6 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (1,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 5 +Handler_update 3 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# select: SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t1`.`a` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 11 +Handler_update 2 + +DROP TABLE t1, t2; +#7 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` where ((`test`.`t2`.`b` < 3) and ((`test`.`t1`.`a`) = `test`.`t2`.`b`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 15 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 19 +Handler_update 2 + +DROP TABLE t1, t2; +#8 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 16 +Handler_update 3 + +DROP TABLE t1, t2; +#9 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10 +# select: SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12 +# +EXPLAIN UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 update `test`.`t1` `t11` join (/* select#2 */ select 1 AS `1`) `t12` set `test`.`t11`.`a` = (`test`.`t11`.`a` + 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 5 +Handler_write 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 3 +Handler_read_rnd_next 9 +Handler_update 3 +Handler_write 4 + +DROP TABLE t1, t2; +#10 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1 +# select: SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1 +# +EXPLAIN UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t2` set `test`.`t11`.`a` = 10 where (`test`.`t11`.`a` > 1) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 12 +Handler_update 2 + +DROP TABLE t1, t2; +#11 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE a > 1 LIMIT 1 +# select: SELECT * FROM t1 WHERE a > 1 LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE a > 1 LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 1) limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 2 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 1 +Handler_read_rnd_next 2 + +DROP TABLE t1; +#12 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#13 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 USING t1 WHERE 0 +# select: SELECT * FROM t1 WHERE 0 +# +EXPLAIN DELETE FROM t1 USING t1 WHERE 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` where false +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 + +DROP TABLE t1; +#14 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a = 3 +# select: SELECT * FROM t1 WHERE a = 3 +# +EXPLAIN DELETE FROM t1 WHERE a = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` = 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#15 +CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b)); +INSERT INTO t1 VALUES (3, 3), (7, 7); +# +# query: DELETE FROM t1 WHERE a < 3 +# select: SELECT * FROM t1 WHERE a < 3 +# +EXPLAIN DELETE FROM t1 WHERE a < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range a a 5 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` < 3) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 + +DROP TABLE t1; +#16 +CREATE TABLE t1 ( a int PRIMARY KEY ); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +INSERT INTO t1 VALUES (1), (2), (3); +# +# query: DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# select: SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a +# +EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a` > 0) order by `test`.`t1`.`a` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_next 3 + +DROP TABLE t1; +#17 +CREATE TABLE t1(a INT PRIMARY KEY); +INSERT INTO t1 VALUES (4),(3),(1),(2); +# +# query: DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# select: SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1 +# +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +EXPLAIN DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL index NULL PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) order by `test`.`t1`.`a` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_first 1 +Handler_read_key 1 + +DROP TABLE t1; +#18 +CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a)); +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), (); +UPDATE t1 SET a = c, b = c; +# +# query: DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# select: SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1 +# +EXPLAIN DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 11 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 +Handler_read_rnd 1 +Handler_read_rnd_next 11 +Sort_rows 10 +Sort_scan 1 + +DROP TABLE t1; +#19 +CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL); +CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2)); +CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3)); +INSERT INTO t1 VALUES (1,1), (2,1), (1,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +INSERT INTO t3 VALUES (1,1), (2,1), (1,3); +# +# query: DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# select: SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3 +# +EXPLAIN DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 DELETE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 NULL +1 DELETE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1`, `test`.`t2`, `test`.`t3` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b3` = `test`.`t1`.`b1`) and (`test`.`t3`.`a3` = `test`.`t2`.`b2`) and (`test`.`t2`.`a2` = `test`.`t1`.`a1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 8 +Handler_read_key 12 +Handler_read_next 3 +Handler_read_rnd 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2, t3; +#20 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2) +# select: SELECT * FROM t1 WHERE a IN (SELECT a FROM t2) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`t1`.`a`) = `test`.`t2`.`a`))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 10 +Handler_update 3 + +DROP TABLE t1, t2; +#21 +CREATE TABLE t1 (a1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (a2 VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 VALUES (1), (2), (3), (4), (5); +SET @save_optimizer_switch= @@optimizer_switch; +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +SET @@optimizer_switch= @save_optimizer_switch; +TRUNCATE t1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# +# query: DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# select: SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2) +# +EXPLAIN DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`a1`,(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where ((`test`.`t2`.`a2` > 2) and ((`test`.`t1`.`a1`) = `test`.`t2`.`a2`)))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 30 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_key 2 +Handler_read_rnd_next 30 + +DROP TABLE t1, t2; +#22 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: UPDATE t1 SET i = 10 +# select: SELECT * FROM t1 +# +EXPLAIN UPDATE t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +Handler_update 5 + +DROP TABLE t1; +#23 +CREATE TABLE t1 (i INT, j INT); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +# +# query: DELETE FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN DELETE FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +DROP TABLE t1; +#24 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#25 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: INSERT INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +# +# query: INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i) +# select: SELECT * FROM t1 JOIN t1 AS tt USING(i) +# +EXPLAIN INSERT INTO t2 SELECT * FROM t1 JOIN t1 AS tt USING(i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE tt NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` join `test`.`t1` `tt` where (`test`.`tt`.`i` = `test`.`t1`.`i`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 8 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 8 +Handler_write 3 + +DROP TABLE t1, t2; +#26 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (i INT); +# +# query: REPLACE INTO t2 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN REPLACE INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t2 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 4 +Handler_write 3 + +DROP TABLE t1, t2; +#27 +CREATE TABLE t1 (i INT); +# +# query: INSERT INTO t1 SET i = 10 +# select: +# +EXPLAIN INSERT INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#28 +CREATE TABLE t1 (i INT); +# +# query: REPLACE INTO t1 SET i = 10 +# select: +# +EXPLAIN REPLACE INTO t1 SET i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` (`test`.`t1`.`i`) values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +#29 +CREATE TABLE t1 (a INT, i INT PRIMARY KEY); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1; +#30 +CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +# +# query: DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 delete from `test`.`t1` where ((`test`.`t1`.`i` > 10) and (`test`.`t1`.`i` <= 18)) order by `test`.`t1`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 8 +Sort_scan 1 + +DROP TABLE t1; +#31 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#32 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 15 NULL 17602 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 + +DROP TABLE t1, t2; +#33 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#34 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 delete from `test`.`t2` where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#35 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#36 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan +Warnings: +Note 1003 delete from `test`.`t2` where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 1 +Handler_read_key 3 + +DROP TABLE t1, t2; +#37 +CREATE TABLE t1 (i INT); +INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: DELETE FROM t2 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Sort_rows 26 +Sort_scan 1 + +DROP TABLE t1, t2; +#38 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t2 NULL index NULL a 18 NULL 5 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t2` order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_delete 5 +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 + +DROP TABLE t1, t2; +#39 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#40 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1))) charset utf8mb4; +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Warning 1739 Cannot use range access on index 'i' due to type or collation conversion on field 'i' +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 5 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#41 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 26 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Handler_update 1 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#42 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c)); +INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1; +INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 15 NULL 17602 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_next 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#43 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c)) +charset utf8mb4; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#44 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) +charset utf8mb4 ENGINE=HEAP; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +# +# query: UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5 +# select: SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5 +# +EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'b' +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where (`test`.`t2`.`b` = 10) order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_read_rnd_next 27 +Sort_rows 1 +Sort_scan 1 + +DROP TABLE t1, t2; +#45 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35),(36),(37),(38),(39), +(40),(41),(42),(43),(44); +CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2)); +INSERT INTO t2 (key1, key2) SELECT i, i FROM t1; +# +# query: UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# select: SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1 +# +EXPLAIN UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where ((`test`.`t2`.`key1` < 13) or (`test`.`t2`.`key2` < 14)) order by `test`.`t2`.`key1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 4 +Sort_rows 4 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_next 7 +Handler_read_rnd 8 +Handler_update 4 +Sort_rows 4 +Sort_scan 1 + +DROP TABLE t1, t2; +#46 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2(a INT, i INT PRIMARY KEY); +INSERT INTO t2 (i) SELECT i FROM t1; +# +# query: UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# select: SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1 +# +EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL range PRIMARY PRIMARY 4 const 8 100.00 Using where; Backward index scan; Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where ((`test`.`t2`.`i` > 10) and (`test`.`t2`.`i` <= 18)) order by `test`.`t2`.`i` desc limit 1 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 1 +Handler_update 1 + +DROP TABLE t1, t2; +#47 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 SELECT i, i, i FROM t1; +# +# query: UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd_next 27 +Sort_rows 5 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_rnd 5 +Handler_read_rnd_next 27 +Handler_update 4 +Sort_rows 5 +Sort_scan 1 + +DROP TABLE t1, t2; +#48 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b)) charset utf8mb4; +INSERT INTO t2 (a, b) SELECT i, i FROM t1; +INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2; +# +# query: UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5 +# select: SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5 +# +EXPLAIN UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL index NULL a 18 NULL 5 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 3 +Handler_read_last 1 +Handler_read_prev 4 +Handler_read_rnd 5 +Handler_update 5 + +DROP TABLE t1, t2; +#49 +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4); +# +# query: UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 +Sort_rows 2 +Sort_scan 1 + +# +# query: DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# select: SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2 +# +EXPLAIN DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range c1_idx c1_idx 5 const 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`c1_idx` = 'y') order by `test`.`t1`.`pk` desc limit 2 +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_next 2 +Sort_rows 2 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_delete 2 +Handler_read_key 4 +Handler_read_next 2 +Handler_read_rnd 2 +Sort_rows 2 +Sort_scan 1 + +DROP TABLE t1; +#50 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +# +# query: UPDATE t1 SET a=a+10 WHERE a > 34 +# select: SELECT * FROM t1 WHERE a > 34 +# +EXPLAIN UPDATE t1 SET a=a+10 WHERE a > 34; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 10) where (`test`.`t1`.`a` > 34) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_next 2 +Handler_read_rnd 2 +Handler_update 2 + +DROP TABLE t1; +#51 +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT); +CREATE TABLE t2 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20); +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where true +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +# +# query: UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10 +# select: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10 +# +EXPLAIN UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` left join `test`.`t2` on(multiple equal(`test`.`t1`.`c1`, `test`.`t2`.`c1`)) set `test`.`t2`.`c2` = 10 where (`test`.`t1`.`c3` = 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 4 + +DROP TABLE t1, t2; +#52 +CREATE TABLE t1(f1 INT, f2 INT); +CREATE TABLE t2(f3 INT, f4 INT); +CREATE INDEX IDX ON t2(f3); +INSERT INTO t1 VALUES(1,0),(2,0); +INSERT INTO t2 VALUES(1,1),(2,2); +# +# query: UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) +# select: SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1 +# +EXPLAIN UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ref IDX IDX 5 test.t1.f1 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where (`test`.`t2`.`f3` = `test`.`t1`.`f1`)) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +# Status of testing query execution: +Variable_name Value +Handler_read_key 6 +Handler_read_next 2 +Handler_read_rnd_next 3 +Handler_update 2 + +DROP TABLE t1, t2; +#55 +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1); +SET @a = NULL; +EXPLAIN DELETE FROM t1 WHERE (@a:= a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 delete from `test`.`t1` where (0 <> (@a:=`test`.`t1`.`a`)) +DROP TABLE t1; +#56 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +EXPLAIN DELETE FROM t1 USING t1 WHERE uknown_column = 12345; +ERROR 42S22: Unknown column 'uknown_column' in 'where clause' +DROP TABLE t1; +#57 +CREATE TABLE t1(f1 INT); +EXPLAIN UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +UPDATE t1 SET f2=1 ORDER BY f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +DROP TABLE t1; +#59 +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +EXPLAIN UPDATE IGNORE v1 SET a = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t12 NULL index NULL a 5 NULL 2 100.00 Using index +Warnings: +Note 1003 update ignore (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +#62 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +# +# query: UPDATE v1 SET a = 1 WHERE a > 0 +# select: SELECT * FROM v1 WHERE a > 0 +# +EXPLAIN UPDATE v1 SET a = 1 WHERE a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update (`test`.`t1` `t11` join `test`.`t1` `t12`) set `t11`.`a` = 1 where (`t11`.`a` > 0) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 6 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +Handler_write 2 + +# +# query: UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a +# select: SELECT * FROM t1, v1 WHERE t1.a = v1.a +# +EXPLAIN UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 UPDATE t11 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where (`test`.`t11`.`a` = `test`.`t1`.`a`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 9 +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd 2 +Handler_read_rnd_next 18 +Handler_update 1 +Handler_write 4 + +DROP TABLE t1; +DROP VIEW v1; +#63 +CREATE TABLE t1 (a INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 (a) AS SELECT a FROM t1; +# +# query: DELETE FROM v1 WHERE a < 4 +# select: SELECT * FROM v1 WHERE a < 4 +# +EXPLAIN DELETE FROM v1 WHERE a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range PRIMARY PRIMARY 4 const 3 100.00 Using where +Warnings: +Note 1003 delete from (`test`.`t1`) where (`test`.`t1`.`a` < 4) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 +# Status of testing query execution: +Variable_name Value +Handler_delete 3 +Handler_read_first 1 +Handler_read_key 1 +Handler_read_next 3 + +DROP TABLE t1; +DROP VIEW v1; +#64 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#65 +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10); +CREATE TABLE t2 (x INT); +INSERT INTO t2 VALUES (1), (2), (3), (4); +CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1; +# +# query: DELETE v1 FROM t2, v1 WHERE t2.x = v1.a +# select: SELECT * FROM t2, v1 WHERE t2.x = v1.a +# +EXPLAIN DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 DELETE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 NULL +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`x`) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd_next 5 +# Status of testing query execution: +Variable_name Value +Handler_delete 4 +Handler_read_key 7 +Handler_read_rnd 4 +Handler_read_rnd_next 5 + +DROP TABLE t1,t2; +DROP VIEW v1; +#66 +CREATE TABLE t1 (a INT); +CREATE VIEW v1 (x) AS SELECT a FROM t1; +# +# query: INSERT INTO v1 VALUES (10) +# select: SELECT NULL +# +EXPLAIN INSERT INTO v1 VALUES (10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +# Status of testing query execution: +Variable_name Value +Handler_read_key 1 +Handler_write 1 + +DROP TABLE t1; +DROP VIEW v1; +#67 +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1 (x) AS SELECT b FROM t2; +# +# query: INSERT INTO v1 SELECT * FROM t1 +# select: SELECT * FROM t1 +# +EXPLAIN INSERT INTO v1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 1 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 + +DROP TABLE t1, t2; +DROP VIEW v1; +#69 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1), (2), (3); +# +# query: UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_update 1 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +# +# query: UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# select: SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x) +# +EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +3 DEPENDENT SUBQUERY NULL index_subquery 5 func 2 100.00 Using index +4 DERIVED t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in x on ))) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 5 +Handler_read_rnd_next 8 +Handler_write 1 +Sort_rows 3 +Sort_scan 1 + +DROP TABLE t1,t2; +#70 +CREATE TABLE t1 (c1 INT KEY); +CREATE TABLE t2 (c2 INT); +CREATE TABLE t3 (c3 INT); +EXPLAIN UPDATE t3 SET c3 = ( +SELECT COUNT(d1.c1) +FROM ( +SELECT a11.c1 FROM t1 AS a11 +STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 +JOIN t1 AS a12 ON a12.c1 = a11.c1 +) d1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from (/* select#3 */ select NULL AS `c1` from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where multiple equal(NULL, NULL, NULL)) `d1`) +DROP TABLE t1, t2, t3; +#71 +CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1)); +INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0); +CREATE TABLE t2 LIKE t1; +EXPLAIN INSERT INTO t2 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t2 NULL ALL NULL NULL NULL NULL X NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL X 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1; +DROP TABLE t1, t2; +#73 +CREATE TABLE t1 (id INT); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (1), (2); +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where true group by `test`.`t1`.`id` +DROP TABLE t1,t2; +#74 +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +# used key is modified & Using temporary +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 +# select: SELECT a t1 FROM t1 WHERE a>10 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 + +# used key is modified & Using filesort +# +# query: UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20 +# select: SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20 +# +EXPLAIN UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range PRIMARY PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 1) where (`test`.`t1`.`a` > 10) order by (`test`.`t1`.`a` + 20) +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +FLUSH STATUS; +FLUSH TABLES; +Variable_name Value +# +# Status of "equivalent" SELECT query execution: +Variable_name Value +Handler_read_key 2 +Handler_read_rnd_next 1 +Sort_scan 1 +# Status of testing query execution: +Variable_name Value +Handler_read_key 2 +Sort_scan 1 + +DROP TABLE t1; +# +# Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH +# EXPLAIN UPDATE/DEL/INS +# +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); +CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END| +CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END| +CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END| +CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END| +CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END| +CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END| +CREATE PROCEDURE p13() BEGIN +# Disabling binary logging temporarily as optimized delete is not used when log-bin is enabled in row mode +SET @save_log_bin= @@sql_log_bin;SET SQL_LOG_BIN=0; +EXPLAIN DELETE FROM t1; +SET SQL_LOG_BIN=@save_log_bin; END| +CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END| +CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END| +CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END| +CALL p16(); +DROP PROCEDURE p16; +CALL p15(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` +DROP PROCEDURE p15; +CALL p14(); +DROP PROCEDURE p14; +CALL p13(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 0 100.00 Deleting all rows +DROP PROCEDURE p13; +CALL p12(); +DROP PROCEDURE p12; +CALL p11(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`i` = 10 where multiple equal(`test`.`t1`.`i`, `test`.`t2`.`i`) +DROP PROCEDURE p11; +CALL p10(); +DROP PROCEDURE p10; +CALL p9(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 0 100.00 NULL +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 +DROP PROCEDURE p9; +CALL p8(); +DROP PROCEDURE p8; +CALL p7(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p7; +CALL p6(); +DROP PROCEDURE p6; +CALL p5(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 replace into `test`.`t1` values (1) +DROP PROCEDURE p5; +CALL p4(); +DROP PROCEDURE p4; +CALL p3(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select 1 AS `1` from dual +DROP PROCEDURE p3; +CALL p2(); +DROP PROCEDURE p2; +CALL p1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 insert into `test`.`t1` values (1) +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +set default_storage_engine= @save_storage_engine; +set optimizer_switch=default; diff --git a/mysql-test/r/mysqld--help-notwin.result-pq b/mysql-test/r/mysqld--help-notwin.result-pq new file mode 100644 index 000000000..0bed47307 --- /dev/null +++ b/mysql-test/r/mysqld--help-notwin.result-pq @@ -0,0 +1,1876 @@ +The following options may be given as the first argument: +--print-defaults Print the program argument list and exit. +--no-defaults Don't read default options from any option file, + except for login file. +--defaults-file=# Only read default options from the given file #. +--defaults-extra-file=# Read this file after the global files are read. +--defaults-group-suffix=# + Also read groups with concat(group, suffix) +--login-path=# Read this path from the login file. + + --abort-slave-event-count=# + Option used by mysql-test for debugging and testing of + replication. + --activate-all-roles-on-login + Automatically set all granted roles as active after the + user has authenticated successfully. + --admin-address=name + IP address to bind to for service connection. Address can + be an IPv4 address, IPv6 address, or host name. Wildcard + values *, ::, 0.0.0.0 are not allowed. Address value can + have following optional network namespace separated by + the delimiter / from the address value. E.g., the + following value 192.168.1.1/red specifies IP addresses to + listen for incoming TCP connections that have to be + placed into the namespace 'red'. Using of network + namespace requires its support from underlying Operating + System. Attempt to specify a network namespace for a + platform that doesn't support it results in error during + socket creation. + --admin-port=# Port number to use for service connection, built-in + default (33062) + --admin-ssl Enable SSL for admin interface (automatically enabled + with other flags). + (Defaults to on; use --skip-admin-ssl to disable.) + --admin-ssl-capath=name + --admin-ssl-cert=name + --admin-ssl-cipher=name + --admin-ssl-crl=name + CRL file in PEM format (check OpenSSL docs, implies + --admin-ssl-crlpath=name + --admin-ssl-key=name + --admin-tls-ciphersuites=name + --admin-tls-version=name + TLS version for --admin-port, permitted values are TLSv1, + TLSv1.1, TLSv1.2, TLSv1.3 + --allow-suspicious-udfs + Allows use of UDFs consisting of only one symbol xxx() + without corresponding xxx_init() or xxx_deinit(). That + also means that one can load any function from any + library, for example exit() from libc.so + -a, --ansi Use ANSI SQL syntax instead of MySQL syntax. This mode + will also set transaction isolation level 'serializable'. + --auto-increment-increment[=#] + Auto-increment columns are incremented by this + --auto-increment-offset[=#] + Offset added to Auto-increment columns. Used when + auto-increment-increment != 1 + --autocommit Set default value for autocommit (0 or 1) + (Defaults to on; use --skip-autocommit to disable.) + --automatic-sp-privileges + Creating and dropping stored procedures alters ACLs + (Defaults to on; use --skip-automatic-sp-privileges to disable.) + --avoid-temporal-upgrade + When this option is enabled, the pre-5.6.4 temporal types + are not upgraded to the new format for ALTER TABLE + requests ADD/CHANGE/MODIFY COLUMN, ADD INDEX or FORCE + operation. This variable is deprecated and will be + removed in a future release. + --back-log=# The number of outstanding connection requests MySQL can + have. This comes into play when the main MySQL thread + gets very many connection requests in a very short time + -b, --basedir=name Path to installation directory. All paths are usually + resolved relative to this + --big-tables Allow big result sets by saving all temporary sets on + file (Solves most 'table full' errors) + --bind-address=name IP address(es) to bind to. Syntax: address[,address]..., + where address can be an IPv4 address, IPv6 address, host + name or one of the wildcard values *, ::, 0.0.0.0. In + case more than one address is specified in a + comma-separated list, wildcard values are not allowed. + Every address can have optional network namespace + separated by the delimiter / from the address value. + E.g., the following value + 192.168.1.1/red,172.16.1.1/green,193.168.1.1 specifies + three IP addresses to listen for incoming TCP connections + two of that have to be placed in corresponding + namespaces: the address 192.168.1.1 must be placed into + the namespace red and the address 172.16.1.1 must be + placed into the namespace green. Using of network + namespace requires its support from underlying Operating + System. Attempt to specify a network namespace for a + platform that doesn't support it results in error during + socket creation. + --binlog-cache-size=# + The size of the transactional cache for updates to + transactional engines for the binary log. If you often + use transactions containing many statements, you can + increase this to get more performance + --binlog-checksum=name + Type of BINLOG_CHECKSUM_ALG. Include checksum for log + events in the binary log. Possible values are NONE and + CRC32; default is CRC32. + --binlog-direct-non-transactional-updates + Causes updates to non-transactional engines using + statement format to be written directly to binary log. + Before using this option make sure that there are no + dependencies between transactional and non-transactional + tables such as in the statement INSERT INTO t_myisam + SELECT * FROM t_innodb; otherwise, slaves may diverge + from the master. + --binlog-do-db=name Tells the master it should log updates for the specified + database, and exclude all others not explicitly + mentioned. + --binlog-encryption Enable/disable binary and relay logs encryption. + --binlog-error-action=name + When statements cannot be written to the binary log due + to a fatal error, the server can either ignore the error + and let the master continue, or abort. + --binlog-expire-logs-seconds=# + If non-zero, binary logs will be purged after + binlog_expire_logs_seconds seconds; If both this option + and expire_logs_days are set to non-zero values, this + option takes priority. Purges happen at startup and at + binary log rotation. + --binlog-format=name + What form of binary logging the master will use: either + ROW for row-based binary logging, STATEMENT for + statement-based binary logging, or MIXED. MIXED is + statement-based binary logging except for those + statements where only row-based is correct: those which + involve user-defined functions (i.e. UDFs) or the UUID() + function; for those, row-based binary logging is + automatically used. If NDBCLUSTER is enabled and + binlog-format is MIXED, the format switches to row-based + and back implicitly per each query accessing an + NDBCLUSTER table + --binlog-group-commit-sync-delay=# + The number of microseconds the server waits for the + binary log group commit sync queue to fill before + continuing. Default: 0. Min: 0. Max: 1000000. + --binlog-group-commit-sync-no-delay-count=# + If there are this many transactions in the commit sync + queue and the server is waiting for more transactions to + be enqueued (as set using + --binlog-group-commit-sync-delay), the commit procedure + resumes. + --binlog-gtid-simple-recovery + If this option is enabled, the server does not open more + than two binary logs when initializing GTID_PURGED and + GTID_EXECUTED, either during server restart or when + binary logs are being purged. Enabling this option is + useful when the server has already generated many binary + logs without GTID events (e.g., having GTID_MODE = OFF). + Note: If this option is enabled, GLOBAL.GTID_EXECUTED and + GLOBAL.GTID_PURGED may be initialized wrongly in two + cases: (1) All binary logs were generated by MySQL 5.7.5 + or older, and GTID_MODE was ON for some binary logs but + OFF for the newest binary log. (2) The oldest existing + binary log was generated by MySQL 5.7.5 or older, and SET + GTID_PURGED was issued after the oldest binary log was + generated. If a wrong set is computed in one of case (1) + or case (2), it will remain wrong even if the server is + later restarted with this option disabled. + (Defaults to on; use --skip-binlog-gtid-simple-recovery to disable.) + --binlog-ignore-db=name + Tells the master that updates to the given database + should not be logged to the binary log. + --binlog-max-flush-queue-time=# + The maximum time that the binary log group commit will + keep reading transactions before it flush the + transactions to the binary log (and optionally sync, + depending on the value of sync_binlog). + --binlog-order-commits + Issue internal commit calls in the same order as + transactions are written to the binary log. Default is to + order commits. + (Defaults to on; use --skip-binlog-order-commits to disable.) + --binlog-rotate-encryption-master-key-at-startup + Force binlog encryption master key rotation at startup + --binlog-row-event-max-size=# + The maximum size of a row-based binary log event in + bytes. Rows will be grouped into events smaller than this + size if possible. The value has to be a multiple of 256. + --binlog-row-image=name + Controls whether rows should be logged in 'FULL', + 'NOBLOB' or 'MINIMAL' formats. 'FULL', means that all + columns in the before and after image are logged. + 'NOBLOB', means that mysqld avoids logging blob columns + whenever possible (e.g. blob column was not changed or is + not part of primary key). 'MINIMAL', means that a PK + equivalent (PK columns or full row if there is no PK in + the table) is logged in the before image, and only + changed columns are logged in the after image. (Default: + FULL). + --binlog-row-metadata=name + Controls whether metadata is logged using FULL or MINIMAL + format. FULL causes all metadata to be logged; MINIMAL + means that only metadata actually required by slave is + logged. Default: MINIMAL. + --binlog-row-value-options=name + When set to PARTIAL_JSON, this option enables a + space-efficient row-based binary log format for UPDATE + statements that modify a JSON value using only the + functions JSON_SET, JSON_REPLACE, and JSON_REMOVE. For + such updates, only the modified parts of the JSON + document are included in the binary log, so small changes + of big documents may need significantly less space. + --binlog-rows-query-log-events + Allow writing of Rows_query_log events into binary log. + --binlog-stmt-cache-size=# + The size of the statement cache for updates to + non-transactional engines for the binary log. If you + often use statements updating a great number of rows, you + can increase this to get more performance + --binlog-transaction-compression + Whether to compress transactions or not. Transactions are + compressed using the ZSTD compression algorythm. + --binlog-transaction-compression-level-zstd=# + Specifies the transaction compression level for ZSTD + transaction compression in the binary log. + --binlog-transaction-dependency-history-size=# + Maximum number of rows to keep in the writeset history. + --binlog-transaction-dependency-tracking=name + Selects the source of dependency information from which + to assess which transactions can be executed in parallel + by the slave's multi-threaded applier. Possible values + are COMMIT_ORDER, WRITESET and WRITESET_SESSION. + --block-encryption-mode=name + mode for AES_ENCRYPT/AES_DECRYPT + --bulk-insert-buffer-size=# + Size of tree cache used in bulk insert optimisation. Note + that this is a limit per thread! + --caching-sha2-password-digest-rounds=# + Number of SHA2 rounds to be done when storing a password + hash onto disk. + --caching-sha2-password-private-key-path=name + A fully qualified path to the private RSA key used for + authentication. + --caching-sha2-password-public-key-path=name + A fully qualified path to the public RSA key used for + authentication. + --character-set-client-handshake + Don't ignore client side character set value sent during + handshake. + (Defaults to on; use --skip-character-set-client-handshake to disable.) + --character-set-filesystem=name + Set the filesystem character set. + -C, --character-set-server=name + Set the default character set. + --character-sets-dir=name + Directory where character sets are + --check-proxy-users If set to FALSE (the default), then proxy user identity + will not be mapped for authentication plugins which + support mapping from grant tables. When set to TRUE, + users associated with authentication plugins which signal + proxy user mapping should be done according to GRANT + PROXY privilege definition. + -r, --chroot=name Chroot mysqld daemon during startup. + --collation-server=name + Set the default collation. + --completion-type=name + The transaction completion type, one of NO_CHAIN, CHAIN, + RELEASE + --concurrent-insert[=name] + Use concurrent insert with MyISAM. Possible values are + NEVER, AUTO, ALWAYS + --connect-timeout=# The number of seconds the mysqld server is waiting for a + connect packet before responding with 'Bad handshake' + --console Write error output on screen; don't remove the console + window on windows. + --core-file Write core on errors. + --create-admin-listener-thread + Use a dedicated thread for listening incoming connections + on admin interface + --cte-max-recursion-depth=# + Abort a recursive common table expression if it does more + than this number of iterations. + -D, --daemonize Run mysqld as sysv daemon + -h, --datadir=name Path to the database root directory + --default-authentication-plugin=name + The default authentication plugin used by the server to + hash the password. + --default-password-lifetime=# + The number of days after which the password will expire. + --default-storage-engine=name + The default storage engine for new tables + --default-table-encryption + Database and tablespace are created with this default + encryption property unless the user specifies an explicit + encryption property. + --default-time-zone=name + Set the default time zone. + --default-tmp-storage-engine=name + The default storage engine for new explicit temporary + tables + --default-week-format=# + The default week format used by WEEK() functions + --delay-key-write[=name] + Type of DELAY_KEY_WRITE + --delayed-insert-limit=# + After inserting delayed_insert_limit rows, the INSERT + DELAYED handler will check if there are any SELECT + statements pending. If so, it allows these to execute + before continuing. This variable is deprecated along with + INSERT DELAYED. + --delayed-insert-timeout=# + How long a INSERT DELAYED thread should wait for INSERT + statements before terminating. This variable is + deprecated along with INSERT DELAYED. + --delayed-queue-size=# + What size queue (in rows) should be allocated for + handling INSERT DELAYED. If the queue becomes full, any + client that does INSERT DELAYED will wait until there is + room in the queue again. This variable is deprecated + along with INSERT DELAYED. + --disabled-storage-engines=name + Limit CREATE TABLE for the storage engines listed + --disconnect-on-expired-password + Give clients that don't signal password expiration + support execution time error(s) instead of connection + error + (Defaults to on; use --skip-disconnect-on-expired-password to disable.) + --disconnect-slave-event-count=# + Option used by mysql-test for debugging and testing of + replication. + --div-precision-increment=# + Precision of the result of '/' operator will be increased + on that value + --early-plugin-load=name + Optional semicolon-separated list of plugins to load + before storage engine initialization, where each plugin + is identified as name=library, where name is the plugin + name and library is the plugin library in plugin_dir. + --end-markers-in-json + In JSON output ("EXPLAIN FORMAT=JSON" and optimizer + trace), if variable is set to 1, repeats the structure's + key (if it has one) near the closing bracket + --enforce-gtid-consistency[=name] + Prevents execution of statements that would be impossible + to log in a transactionally safe manner. Currently, the + disallowed statements include CREATE TEMPORARY TABLE + inside transactions, all updates to non-transactional + tables, and CREATE TABLE ... SELECT. + --eq-range-index-dive-limit=# + The optimizer will use existing index statistics instead + of doing index dives for equality ranges if the number of + equality ranges for the index is larger than or equal to + this number. If set to 0, index dives are always used. + --event-scheduler[=name] + Enable the event scheduler. Possible values are ON, OFF, + and DISABLED (keep the event scheduler completely + deactivated, it cannot be activated run-time) + -T, --exit-info[=#] Used for debugging. Use at your own risk. + --expire-logs-days=# + If non-zero, binary logs will be purged after + expire_logs_days days; If this option alone is set on the + command line or in a configuration file, it overrides the + default value for binlog-expire-logs-seconds. If both + options are set to nonzero values, + binlog-expire-logs-seconds takes priority. Possible + purges happen at startup and at binary log rotation. + --explicit-defaults-for-timestamp + This option causes CREATE TABLE to create all TIMESTAMP + columns as NULL with DEFAULT NULL attribute, Without this + option, TIMESTAMP columns are NOT NULL and have implicit + DEFAULT clauses. The old behavior is deprecated. The + variable can only be set by users having the SUPER + privilege. + (Defaults to on; use --skip-explicit-defaults-for-timestamp to disable.) + --external-locking Use system (external) locking (disabled by default). + With this option enabled you can run myisamchk to test + (not repair) tables while the MySQL server is running. + Disable with --skip-external-locking. + --flush Flush MyISAM tables to disk between SQL commands + --flush-time=# A dedicated thread is created to flush all tables at the + given interval + --force-parallel-execute + force parallel execute in session + --ft-boolean-syntax=name + List of operators for MATCH ... AGAINST ( ... IN BOOLEAN + MODE) + --ft-max-word-len=# The maximum length of the word to be included in a + FULLTEXT index. Note: FULLTEXT indexes must be rebuilt + after changing this variable + --ft-min-word-len=# The minimum length of the word to be included in a + FULLTEXT index. Note: FULLTEXT indexes must be rebuilt + after changing this variable + --ft-query-expansion-limit=# + Number of best matches to use for query expansion + --ft-stopword-file=name + Use stopwords from this file instead of built-in list + --gdb Set up signals usable for debugging. + --general-log Log connections and queries to a table or log file. + Defaults to logging to a file hostname.log, or if + --log-output=TABLE is used, to a table mysql.general_log. + --general-log-file=name + Log connections and queries to given file + --generated-random-password-length=# + Determines the length randomly generated passwords in + CREATE USER-,SET PASSWORD- or ALTER USER statements + --group-concat-max-len=# + The maximum length of the result of function + GROUP_CONCAT() + --group-replication-consistency[=name] + Transaction consistency guarantee, possible values: + EVENTUAL, BEFORE_ON_PRIMARY_FAILOVER, BEFORE, AFTER, + BEFORE_AND_AFTER + --gtid-executed-compression-period[=#] + Compress the mysql.gtid_executed table whenever this + number of transactions have been added, by waking up a + foreground thread (compress_gtid_table). This compression + method only operates when binary logging is disabled on + the replica; if binary logging is enabled, the table is + compressed every time the binary log is rotated, and this + value is ignored. Before MySQL 8.0.23, the default is + 1000, and from MySQL 8.0.23, the default is zero, which + disables this compression method. This is because in + releases from MySQL 8.0.17, InnoDB transactions are + written to the mysql.gtid_executed table by a separate + process to non-InnoDB transactions. If the server has a + mix of InnoDB and non-InnoDB transactions, attempting to + compress the table with the compress_gtid_table thread + can slow this process, so from MySQL 8.0.17 it is + recommended that you set gtid_executed_compression_period + to 0. + --gtid-mode=name Controls whether Global Transaction Identifiers (GTIDs) + are enabled. Can be OFF, OFF_PERMISSIVE, ON_PERMISSIVE, + or ON. OFF means that no transaction has a GTID. + OFF_PERMISSIVE means that new transactions (committed in + a client session using GTID_NEXT='AUTOMATIC') are not + assigned any GTID, and replicated transactions are + allowed to have or not have a GTID. ON_PERMISSIVE means + that new transactions are assigned a GTID, and replicated + transactions are allowed to have or not have a GTID. ON + means that all transactions have a GTID. ON is required + on a master before any slave can use + MASTER_AUTO_POSITION=1. To safely switch from OFF to ON, + first set all servers to OFF_PERMISSIVE, then set all + servers to ON_PERMISSIVE, then wait for all transactions + without a GTID to be replicated and executed on all + servers, and finally set all servers to GTID_MODE = ON. + -?, --help Display this help and exit. + --histogram-generation-max-mem-size=# + Maximum amount of memory available for generating + histograms + --host-cache-size=# How many host names should be cached to avoid resolving. + --information-schema-stats-expiry=# + The number of seconds after which mysqld server will + fetch data from storage engine and replace the data in + cache. + --init-connect=name Command(s) that are executed for each new connection + --init-file=name Read SQL commands from this file at startup + --init-slave=name Command(s) that are executed by a slave server each time + the SQL thread starts + -I, --initialize Create the default database and exit. Create a super user + with a random expired password and store it into the log. + --initialize-insecure + Create the default database and exit. Create a super user + with empty password. + --interactive-timeout=# + The number of seconds the server waits for activity on an + interactive connection before closing it + --internal-tmp-mem-storage-engine=name + The default storage engine for in-memory internal + temporary tables. + --join-buffer-size=# + The size of the buffer that is used for full joins + --keep-files-on-create + Don't overwrite stale .MYD and .MYI even if no directory + is specified + --key-buffer-size=# The size of the buffer used for index blocks for MyISAM + tables. Increase this to get better index handling (for + all reads and multiple writes) to as much as you can + afford + --key-cache-age-threshold=# + This characterizes the number of hits a hot block has to + be untouched until it is considered aged enough to be + downgraded to a warm block. This specifies the percentage + ratio of that number of hits to the total number of + blocks in key cache + --key-cache-block-size=# + The default size of key cache blocks + --key-cache-division-limit=# + The minimum percentage of warm blocks in key cache + --keyring-migration-destination=name + Keyring plugin or component to which the keys are + migrated to. + --keyring-migration-host=name + Connect to host. + -p, --keyring-migration-password[=name] + Password to use when connecting to server during keyring + migration. If password value is not specified then it + will be asked from the tty. + --keyring-migration-port=# + Port number to use for connection. + --keyring-migration-source=name + Keyring plugin from where the keys needs to be migrated + to. This option must be specified along with + --keyring-migration-destination. + --keyring-migration-to-component + Migrate from keyring plugin to keyring component. + --keyring-migration-user=name + User to login to server. + -L, --language=name Client error messages in given language. May be given as + a full path. Deprecated. Use --lc-messages-dir instead. + --large-pages Enable support for large pages + --lc-messages=name Set the language used for the error messages. + --lc-messages-dir=name + Directory where error messages are + --lc-time-names=name + Set the language used for the month names and the days of + the week. + --local-infile Enable LOAD DATA LOCAL INFILE + --lock-wait-timeout=# + Timeout in seconds to wait for a lock before returning an + error. + --log-bin[=name] Configures the name prefix to use for binary log files. + If the --log-bin option is not supplied, the name prefix + defaults to "binlog". If the --log-bin option is supplied + without argument, the name prefix defaults to + "HOSTNAME-bin", where HOSTNAME is the machine's hostname. + To set a different name prefix for binary log files, use + --log-bin=name. To disable binary logging, use the + --skip-log-bin or --disable-log-bin option. + --log-bin-index=name + File that holds the names for binary log files. + --log-bin-trust-function-creators + If set to FALSE (the default), then when --log-bin is + used, creation of a stored function (or trigger) is + allowed only to users having the SUPER privilege and only + if this stored function (trigger) may not break binary + logging. Note that if ALL connections to this server + ALWAYS use row-based binary logging, the security issues + do not exist and the binary logging cannot break, so you + can safely set this to TRUE + --log-bin-use-v1-row-events + If equal to 1 then version 1 row events are written to a + row based binary log. If equal to 0, then the latest + version of events are written. This option is useful + during some upgrades. + --log-error[=name] Error log file + --log-error-services=name + Services that should be called when an error event is + received + --log-error-suppression-list=name + Comma-separated list of error-codes. Error messages + corresponding to these codes will not be included in the + error log. Only events with a severity of Warning or + Information can be suppressed; events with System or + Error severity will always be included. Requires the + filter 'log_filter_internal' to be set in + @@global.log_error_services, which is the default. + --log-error-verbosity=# + How detailed the error log should be. 1, log errors only. + 2, log errors and warnings. 3, log errors, warnings, and + notes. Messages sent to the client are unaffected by this + setting. + --log-isam[=name] Log all MyISAM changes to file. + --log-output=name Syntax: log-output=value[,value...], where "value" could + be TABLE, FILE or NONE + --log-queries-not-using-indexes + Log queries that are executed without benefit of any + index to the slow log if it is open + --log-raw Log to general log before any rewriting of the query. For + use in debugging, not production as sensitive information + may be logged. + --log-short-format Don't log extra information to update and slow-query + logs. + --log-slave-updates Tells the slave to log the updates from the slave thread + to the binary log. + (Defaults to on; use --skip-log-slave-updates to disable.) + --log-slow-admin-statements + Log slow OPTIMIZE, ANALYZE, ALTER and other + administrative statements to the slow log if it is open. + --log-slow-extra Print more attributes to the slow query log file. Has no + effect on logging to table. + --log-slow-slave-statements + Log slow statements executed by slave thread to the slow + log if it is open. + --log-statements-unsafe-for-binlog + Log statements considered unsafe when using statement + based binary logging. + (Defaults to on; use --skip-log-statements-unsafe-for-binlog to disable.) + --log-tc=name Path to transaction coordinator log (used for + transactions that affect more than one storage engine, + when binary log is disabled). + --log-tc-size=# Size of transaction coordinator log. + --log-throttle-queries-not-using-indexes=# + Log at most this many 'not using index' warnings per + minute to the slow log. Any further warnings will be + condensed into a single summary line. A value of 0 + disables throttling. Option has no effect unless + --log_queries_not_using_indexes is set. + --log-timestamps=name + UTC to timestamp log files in zulu time, for more concise + timestamps and easier correlation of logs from servers + from multiple time zones, or SYSTEM to use the system's + local time. This affects only log files, not log tables, + as the timestamp columns of the latter can be converted + at will. + --long-query-time=# Log all queries that have taken more than long_query_time + seconds to execute to file. The argument will be treated + as a decimal value with microsecond precision + --low-priority-updates + INSERT/DELETE/UPDATE has lower priority than selects + --lower-case-table-names[=#] + If set to 1 table names are stored in lowercase on disk + and table names will be case-insensitive. Should be set + to 2 if you are using a case insensitive file system + --mandatory-roles=name + All the specified roles are always considered granted to + every user and they can't be revoked. Mandatory roles + still require activation unless they are made into + default roles. The granted roles will not be visible in + the mysql.role_edges table. + --master-info-file=name + The location and name of the file that remembers the + master and where the I/O replication thread is in the + master's binlogs. Deprecated option that shall be removed + eventually without a replacement. + --master-info-repository=name + Defines the type of the repository for the master + information. + --master-retry-count=# + The number of tries the slave will make to connect to the + master before giving up. Deprecated option, use 'CHANGE + MASTER TO master_retry_count = ' instead. + --master-verify-checksum + Force checksum verification of logged events in binary + log before sending them to slaves or printing them in + output of SHOW BINLOG EVENTS. Disabled by default. + --max-allowed-packet=# + Max packet length to send to or receive from the server + --max-binlog-cache-size=# + Sets the total size of the transactional cache + --max-binlog-dump-events=# + Option used by mysql-test for debugging and testing of + replication. + --max-binlog-size=# Binary log will be rotated automatically when the size + exceeds this value. Will also apply to relay logs if + max_relay_log_size is 0 + --max-binlog-stmt-cache-size=# + Sets the total size of the statement cache + --max-connect-errors=# + If there is more than this number of interrupted + connections from a host this host will be blocked from + further connections + --max-connections=# The number of simultaneous clients allowed + --max-delayed-threads=# + Don't start more than this number of threads to handle + INSERT DELAYED statements. If set to zero INSERT DELAYED + will be not used. This variable is deprecated along with + INSERT DELAYED. + --max-digest-length=# + Maximum length considered for digest text. + --max-error-count=# Max number of errors/warnings to store for a statement + --max-execution-time=# + Kill SELECT statement that takes over the specified + number of milliseconds + --max-heap-table-size=# + Don't allow creation of heap tables bigger than this + --max-join-size=# Joins that are probably going to read more than + max_join_size records return an error + --max-length-for-sort-data=# + This variable is deprecated and will be removed in a + future release. + --max-points-in-geometry[=#] + Maximum number of points in a geometry + --max-prepared-stmt-count=# + Maximum number of prepared statements in the server + --max-relay-log-size=# + If non-zero: relay log will be rotated automatically when + the size exceeds this value; if zero: when the size + exceeds max_binlog_size + --max-seeks-for-key=# + Limit assumed max number of seeks when looking up rows + based on a key + --max-sort-length=# The number of bytes to use when sorting long values with + PAD SPACE collations (only the first max_sort_length + bytes of each value are used; the rest are ignored) + --max-sp-recursion-depth[=#] + Maximum stored procedure recursion depth + --max-user-connections=# + The maximum number of active connections for a single + user (0 = no limit) + --max-write-lock-count=# + After this many write locks, allow some read locks to run + in between + --memlock Lock mysqld in memory. + --min-examined-row-limit=# + Don't write queries to slow log that examine fewer rows + than that + --myisam-block-size=# + Block size to be used for MyISAM index pages + --myisam-data-pointer-size=# + Default pointer size to be used for MyISAM tables + --myisam-max-sort-file-size=# + Don't use the fast sort index method to created index if + the temporary file would get bigger than this + --myisam-mmap-size=# + Restricts the total memory used for memory mapping of + MySQL tables + --myisam-recover-options[=name] + Syntax: myisam-recover-options[=option[,option...]], + where option can be DEFAULT, BACKUP, FORCE, QUICK, or OFF + --myisam-repair-threads=# + If larger than 1, when repairing a MyISAM table all + indexes will be created in parallel, with one thread per + index. The value of 1 disables parallel repair + --myisam-sort-buffer-size=# + The buffer that is allocated when sorting the index when + doing a REPAIR or when creating indexes with CREATE INDEX + or ALTER TABLE + --myisam-stats-method=name + Specifies how MyISAM index statistics collection code + should treat NULLs. Possible values of name are + NULLS_UNEQUAL (default behavior for 4.1 and later), + NULLS_EQUAL (emulate 4.0 behavior), and NULLS_IGNORED + --myisam-use-mmap Use memory mapping for reading and writing MyISAM tables + --mysql-native-password-proxy-users + If set to FALSE (the default), then the + mysql_native_password plugin will not signal for + authenticated users to be checked for mapping to proxy + users. When set to TRUE, the plugin will flag associated + authenticated accounts to be mapped to proxy users when + the server option check_proxy_users is enabled. + --net-buffer-length=# + Buffer length for TCP/IP and socket communication + --net-read-timeout=# + Number of seconds to wait for more data from a connection + before aborting the read + --net-retry-count=# If a read on a communication port is interrupted, retry + this many times before giving up + --net-write-timeout=# + Number of seconds to wait for a block to be written to a + connection before aborting the write + -n, --new Use very new possible "unsafe" functions + --no-dd-upgrade Abort restart if automatic upgrade or downgrade of the + data dictionary is needed. Deprecated option. Use + --upgrade=NONE instead. + --offline-mode Make the server into offline mode + --old Use compatible behavior + --old-alter-table Use old, non-optimized alter table + --old-style-user-limits + Enable old-style user limits (before 5.0.3, user + resources were counted per each user+host vs. per + account). + --open-files-limit=# + If this is not 0, then mysqld will use this value to + reserve file descriptors to use with setrlimit(). If this + value is 0 then mysqld will reserve max_connections*5 or + max_connections + table_open_cache*2 (whichever is + larger) number of file descriptors + --optimizer-prune-level=# + Controls the heuristic(s) applied during query + optimization to prune less-promising partial plans from + the optimizer search space. Meaning: 0 - do not apply any + heuristic, thus perform exhaustive search; 1 - prune + plans based on number of retrieved rows + --optimizer-search-depth=# + Maximum depth of search performed by the query optimizer. + Values larger than the number of relations in a query + result in better query plans, but take longer to compile + a query. Values smaller than the number of tables in a + relation result in faster optimization, but may produce + very bad query plans. If set to 0, the system will + automatically pick a reasonable value + --optimizer-switch=name + optimizer_switch=option=val[,option=val...], where option + is one of {index_merge, index_merge_union, + index_merge_sort_union, index_merge_intersection, + engine_condition_pushdown, index_condition_pushdown, mrr, + mrr_cost_based, materialization, semijoin, loosescan, + firstmatch, duplicateweedout, + subquery_materialization_cost_based, skip_scan, + block_nested_loop, batched_key_access, + use_index_extensions, condition_fanout_filter, + derived_merge, hash_join, subquery_to_derived, + prefer_ordering_index, derived_condition_pushdown} and + val is one of {on, off, default} + --optimizer-trace=name + Controls tracing of the Optimizer: + optimizer_trace=option=val[,option=val...], where option + is one of {enabled, one_line} and val is one of {on, + default} + --optimizer-trace-features=name + Enables/disables tracing of selected features of the + Optimizer: + optimizer_trace_features=option=val[,option=val...], + where option is one of {greedy_search, range_optimizer, + dynamic_range, repeated_subselect} and val is one of {on, + off, default} + --optimizer-trace-limit=# + Maximum number of shown optimizer traces + --optimizer-trace-max-mem-size=# + Maximum allowed cumulated size of stored optimizer traces + --optimizer-trace-offset=# + Offset of first optimizer trace to show; see manual + --parallel-cost-threshold=# + Cost threshold for parallel query. + --parallel-default-dop=# + default degree of parallel query. + --parallel-max-threads=# + max running threads of parallel query. + --parallel-memory-limit=# + upper limit memory size that parallel query can use + --parallel-queue-timeout=# + queue timeout for parallel query when resource is not + enough .the unit is microseconds + --parser-max-mem-size=# + Maximum amount of memory available to the parser + --partial-revokes Access of database objects can be restricted, even if + user has global privileges granted. + --password-history=# + The number of old passwords to check in the history. Set + to 0 (the default) to turn the checks off + --password-require-current + Current password is needed to be specified in order to + change it + --password-reuse-interval=# + The minimum number of days that need to pass before a + password can be reused. Set to 0 (the default) to turn + the checks off + --performance-schema + Enable the performance schema. + (Defaults to on; use --skip-performance-schema to disable.) + --performance-schema-accounts-size=# + Maximum number of instrumented user@host accounts. Use 0 + to disable, -1 for automated scaling. + --performance-schema-consumer-events-stages-current + Default startup value for the events_stages_current + consumer. + --performance-schema-consumer-events-stages-history + Default startup value for the events_stages_history + consumer. + --performance-schema-consumer-events-stages-history-long + Default startup value for the events_stages_history_long + consumer. + --performance-schema-consumer-events-statements-current + Default startup value for the events_statements_current + consumer. + (Defaults to on; use --skip-performance-schema-consumer-events-statements-current to disable.) + --performance-schema-consumer-events-statements-history + Default startup value for the events_statements_history + consumer. + (Defaults to on; use --skip-performance-schema-consumer-events-statements-history to disable.) + --performance-schema-consumer-events-statements-history-long + Default startup value for the + events_statements_history_long consumer. + --performance-schema-consumer-events-transactions-current + Default startup value for the events_transactions_current + consumer. + (Defaults to on; use --skip-performance-schema-consumer-events-transactions-current to disable.) + --performance-schema-consumer-events-transactions-history + Default startup value for the events_transactions_history + consumer. + (Defaults to on; use --skip-performance-schema-consumer-events-transactions-history to disable.) + --performance-schema-consumer-events-transactions-history-long + Default startup value for the + events_transactions_history_long consumer. + --performance-schema-consumer-events-waits-current + Default startup value for the events_waits_current + consumer. + --performance-schema-consumer-events-waits-history + Default startup value for the events_waits_history + consumer. + --performance-schema-consumer-events-waits-history-long + Default startup value for the events_waits_history_long + consumer. + --performance-schema-consumer-global-instrumentation + Default startup value for the global_instrumentation + consumer. + (Defaults to on; use --skip-performance-schema-consumer-global-instrumentation to disable.) + --performance-schema-consumer-statements-digest + Default startup value for the statements_digest consumer. + (Defaults to on; use --skip-performance-schema-consumer-statements-digest to disable.) + --performance-schema-consumer-thread-instrumentation + Default startup value for the thread_instrumentation + consumer. + (Defaults to on; use --skip-performance-schema-consumer-thread-instrumentation to disable.) + --performance-schema-digests-size=# + Size of the statement digest. Use 0 to disable, -1 for + automated sizing. + --performance-schema-error-size=# + Number of server errors instrumented. + --performance-schema-events-stages-history-long-size=# + Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to + disable, -1 for automated sizing. + --performance-schema-events-stages-history-size=# + Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0 + to disable, -1 for automated sizing. + --performance-schema-events-statements-history-long-size=# + Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0 + to disable, -1 for automated sizing. + --performance-schema-events-statements-history-size=# + Number of rows per thread in EVENTS_STATEMENTS_HISTORY. + Use 0 to disable, -1 for automated sizing. + --performance-schema-events-transactions-history-long-size=# + Number of rows in EVENTS_TRANSACTIONS_HISTORY_LONG. Use 0 + to disable, -1 for automated sizing. + --performance-schema-events-transactions-history-size=# + Number of rows per thread in EVENTS_TRANSACTIONS_HISTORY. + Use 0 to disable, -1 for automated sizing. + --performance-schema-events-waits-history-long-size=# + Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to + disable, -1 for automated sizing. + --performance-schema-events-waits-history-size=# + Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0 + to disable, -1 for automated sizing. + --performance-schema-hosts-size=# + Maximum number of instrumented hosts. Use 0 to disable, + -1 for automated scaling. + --performance-schema-instrument[=name] + Default startup value for a performance schema + instrument. + --performance-schema-max-cond-classes=# + Maximum number of condition instruments. + --performance-schema-max-cond-instances=# + Maximum number of instrumented condition objects. Use 0 + to disable, -1 for automated scaling. + --performance-schema-max-digest-length=# + Maximum length considered for digest text, when stored in + performance_schema tables. + --performance-schema-max-digest-sample-age=# + The time in seconds after which a previous query sample + is considered old. When the value is 0, queries are + sampled once. When the value is greater than zero, + queries are re sampled if the last sample is more than + performance_schema_max_digest_sample_age seconds old. + --performance-schema-max-file-classes=# + Maximum number of file instruments. + --performance-schema-max-file-handles=# + Maximum number of opened instrumented files. + --performance-schema-max-file-instances=# + Maximum number of instrumented files. Use 0 to disable, + -1 for automated scaling. + --performance-schema-max-index-stat=# + Maximum number of index statistics for instrumented + tables. Use 0 to disable, -1 for automated scaling. + --performance-schema-max-memory-classes=# + Maximum number of memory pool instruments. + --performance-schema-max-metadata-locks=# + Maximum number of metadata locks. Use 0 to disable, -1 + for automated scaling. + --performance-schema-max-mutex-classes=# + Maximum number of mutex instruments. + --performance-schema-max-mutex-instances=# + Maximum number of instrumented MUTEX objects. Use 0 to + disable, -1 for automated scaling. + --performance-schema-max-prepared-statements-instances=# + Maximum number of instrumented prepared statements. Use 0 + to disable, -1 for automated scaling. + --performance-schema-max-program-instances=# + Maximum number of instrumented programs. Use 0 to + disable, -1 for automated scaling. + --performance-schema-max-rwlock-classes=# + Maximum number of rwlock instruments. + --performance-schema-max-rwlock-instances=# + Maximum number of instrumented RWLOCK objects. Use 0 to + disable, -1 for automated scaling. + --performance-schema-max-socket-classes=# + Maximum number of socket instruments. + --performance-schema-max-socket-instances=# + Maximum number of opened instrumented sockets. Use 0 to + disable, -1 for automated scaling. + --performance-schema-max-sql-text-length=# + Maximum length of displayed sql text. + --performance-schema-max-stage-classes=# + Maximum number of stage instruments. + --performance-schema-max-statement-classes=# + Maximum number of statement instruments. + --performance-schema-max-statement-stack=# + Number of rows per thread in EVENTS_STATEMENTS_CURRENT. + --performance-schema-max-table-handles=# + Maximum number of opened instrumented tables. Use 0 to + disable, -1 for automated scaling. + --performance-schema-max-table-instances=# + Maximum number of instrumented tables. Use 0 to disable, + -1 for automated scaling. + --performance-schema-max-table-lock-stat=# + Maximum number of lock statistics for instrumented + tables. Use 0 to disable, -1 for automated scaling. + --performance-schema-max-thread-classes=# + Maximum number of thread instruments. + --performance-schema-max-thread-instances=# + Maximum number of instrumented threads. Use 0 to disable, + -1 for automated scaling. + --performance-schema-session-connect-attrs-size=# + Size of session attribute string buffer per thread. Use 0 + to disable, -1 for automated sizing. + --performance-schema-setup-actors-size=# + Maximum number of rows in SETUP_ACTORS. Use 0 to disable, + -1 for automated scaling. + --performance-schema-setup-objects-size=# + Maximum number of rows in SETUP_OBJECTS. Use 0 to + disable, -1 for automated scaling. + --performance-schema-show-processlist + Default startup value to enable SHOW PROCESSLIST in the + performance schema. + --performance-schema-users-size=# + Maximum number of instrumented users. Use 0 to disable, + -1 for automated scaling. + --persist-only-admin-x509-subject[=name] + The client peer certificate name required to enable + setting all system variables via SET PERSIST[_ONLY] + --persisted-globals-load + When this option is enabled, config file mysqld-auto.cnf + is read and applied to server, else this file is ignored + even if present. + (Defaults to on; use --skip-persisted-globals-load to disable.) + --pid-file=name Pid file used by safe_mysqld + --plugin-dir=name Directory for plugins + --plugin-load=name Optional semicolon-separated list of plugins to load, + where each plugin is identified as name=library, where + name is the plugin name and library is the plugin library + in plugin_dir. + --plugin-load-add=name + Optional semicolon-separated list of plugins to load, + where each plugin is identified as name=library, where + name is the plugin name and library is the plugin library + in plugin_dir. This option adds to the list specified by + --plugin-load in an incremental way. Multiple + --plugin-load-add are supported. + -P, --port=# Port number to use for connection or 0 to default to, + my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default + (3306), whatever comes first + --port-open-timeout=# + Maximum time in seconds to wait for the port to become + free. (Default: No wait). + --preload-buffer-size=# + The size of the buffer that is allocated when preloading + indexes + --print-identified-with-as-hex + SHOW CREATE USER will print the AS clause as HEX if it + contains non-prinable characters + --profiling-history-size=# + Limit of query profiling memory + --protocol-compression-algorithms=name + List of compression algorithms supported by server. + Supported values are any combination of zlib, zstd, + uncompressed. Command line clients may use the + --compression-algorithms flag to specify a set of + algorithms, and the connection will use an algorithm + supported by both client and server. It picks zlib if + both client and server support it; otherwise it picks + zstd if both support it; otherwise it picks uncompressed + if both support it; otherwise it fails. + --query-alloc-block-size=# + Allocation block size for query parsing and execution + --query-prealloc-size=# + Persistent buffer for query parsing and execution + --range-alloc-block-size=# + Allocation block size for storing ranges during + optimization + --range-optimizer-max-mem-size=# + Maximum amount of memory used by the range optimizer to + allocate predicates during range analysis. The larger the + number, more memory may be consumed during range + analysis. If the value is too low to completed range + optimization of a query, index range scan will not be + considered for this query. A value of 0 means range + optimizer does not have any cap on memory. + --read-buffer-size=# + Each thread that does a sequential scan allocates a + buffer of this size for each table it scans. If you do + many sequential scans, you may want to increase this + value + --read-only Make all non-temporary tables read-only, with the + exception for replication (slave) threads and users with + the SUPER privilege + --read-rnd-buffer-size=# + When reading rows in sorted order after a sort, the rows + are read through this buffer to avoid a disk seeks + --regexp-stack-limit=# + Stack size limit for regular expressions matches + --regexp-time-limit=# + Timeout for regular expressions matches, in steps of the + match engine, typically on the order of milliseconds. + --relay-log=name The location and name to use for relay logs + --relay-log-index=name + File that holds the names for relay log files. + --relay-log-info-file=name + The location and name of the file that remembers where + the SQL replication thread is in the relay logs + --relay-log-info-repository=name + Defines the type of the repository for the relay log + information and associated workers. + --relay-log-purge if disabled - do not purge relay logs. if enabled - purge + them as soon as they are no more needed + (Defaults to on; use --skip-relay-log-purge to disable.) + --relay-log-recovery + Enables automatic relay log recovery right after the + database startup, which means that the IO Thread starts + re-fetching from the master right after the last + transaction processed + --relay-log-space-limit=# + Maximum space to use for all relay logs + --replicate-do-db=name + Tells the slave thread to restrict replication to the + specified database. To specify more than one database, + use the directive multiple times, once for each database. + Note that this will only work if you do not use + cross-database queries such as UPDATE some_db.some_table + SET foo='bar' while having selected a different or no + database. If you need cross database updates to work, + make sure you have 3.23.28 or later, and use + replicate-wild-do-table=db_name.%. + --replicate-do-table=name + Tells the slave thread to restrict replication to the + specified table. To specify more than one table, use the + directive multiple times, once for each table. This will + work for cross-database updates, in contrast to + replicate-do-db. + --replicate-ignore-db=name + Tells the slave thread to not replicate to the specified + database. To specify more than one database to ignore, + use the directive multiple times, once for each database. + This option will not work if you use cross database + updates. If you need cross database updates to work, make + sure you have 3.23.28 or later, and use + replicate-wild-ignore-table=db_name.%. + --replicate-ignore-table=name + Tells the slave thread to not replicate to the specified + table. To specify more than one table to ignore, use the + directive multiple times, once for each table. This will + work for cross-database updates, in contrast to + replicate-ignore-db. + --replicate-rewrite-db=name + Updates to a database with a different name than the + original. Example: + replicate-rewrite-db=master_db_name->slave_db_name. + --replicate-same-server-id + In replication, if set to 1, do not skip events having + our server id. Default value is 0 (to break infinite + loops in circular replication). Can't be set to 1 if + --log-slave-updates is used. + --replicate-wild-do-table=name + Tells the slave thread to restrict replication to the + tables that match the specified wildcard pattern. To + specify more than one table, use the directive multiple + times, once for each table. This will work for + cross-database updates. Example: + replicate-wild-do-table=foo%.bar% will replicate only + updates to tables in all databases that start with foo + and whose table names start with bar. + --replicate-wild-ignore-table=name + Tells the slave thread to not replicate to the tables + that match the given wildcard pattern. To specify more + than one table to ignore, use the directive multiple + times, once for each table. This will work for + cross-database updates. Example: + replicate-wild-ignore-table=foo%.bar% will not do updates + to tables in databases that start with foo and whose + table names start with bar. + --replication-optimize-for-static-plugin-config + Optional flag that blocks plugin install/uninstall and + allows skipping the acquisition of the lock to read from + the plugin list and the usage of read-optimized + spin-locks. Use only when plugin hook callback needs + optimization (a lot of semi-sync slaves, for instance). + --replication-sender-observe-commit-only + Optional flag that allows for only calling back observer + hooks at commit. + --report-host=name Hostname or IP of the slave to be reported to the master + during slave registration. Will appear in the output of + SHOW SLAVE HOSTS. Leave unset if you do not want the + slave to register itself with the master. Note that it is + not sufficient for the master to simply read the IP of + the slave off the socket once the slave connects. Due to + NAT and other routing issues, that IP may not be valid + for connecting to the slave from the master or other + hosts + --report-password=name + The account password of the slave to be reported to the + master during slave registration + --report-port=# Port for connecting to slave reported to the master + during slave registration. Set it only if the slave is + listening on a non-default port or if you have a special + tunnel from the master or other clients to the slave. If + not sure, leave this option unset + --report-user=name The account user name of the slave to be reported to the + master during slave registration + --require-secure-transport + When this option is enabled, connections attempted using + insecure transport will be rejected. Secure transports + are SSL/TLS, Unix socket or Shared Memory (on Windows). + --rpl-read-size=# The size for reads done from the binlog and relay log. It + must be a multiple of 4kb. Making it larger might help + with IO stalls while reading these files when they are + not in the OS buffer cache + --rpl-stop-slave-timeout=# + Timeout in seconds to wait for slave to stop before + returning a warning. + --safe-user-create Don't allow new user creation by the user who has no + write privileges to the mysql.user table. + --schema-definition-cache=# + The number of cached schema definitions + --secondary-engine-cost-threshold[=#] + Controls which statements to consider for execution in a + secondary storage engine. Only statements that have a + cost estimate higher than this value will be attempted + executed in a secondary storage engine. + --secure-file-priv=name + Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to + files within specified directory + --select-into-buffer-size[=#] + Buffer size for SELECT INTO OUTFILE/DUMPFILE. + --select-into-disk-sync + Synchronize flushed buffer with disk for SELECT INTO + OUTFILE/DUMPFILE. + --select-into-disk-sync-delay[=#] + The delay in milliseconds after each buffer sync for + SELECT INTO OUTFILE/DUMPFILE. Requires + select_into_sync_disk = ON. + --server-id=# Uniquely identifies the server instance in the community + of replication partners + --server-id-bits=# Set number of significant bits in server-id + --session-track-gtids=name + Controls the amount of global transaction ids to be + included in the response packet sent by the + server.(Default: OFF). + --session-track-schema + Track changes to the 'default schema'. + (Defaults to on; use --skip-session-track-schema to disable.) + --session-track-state-change + Track changes to the 'session state'. + --session-track-system-variables=name + Track changes in registered system variables. + --session-track-transaction-info=name + Track changes to the transaction attributes. OFF to + disable; STATE to track just transaction state (Is there + an active transaction? Does it have any data? etc.); + CHARACTERISTICS to track transaction state and report all + statements needed to start a transaction with the same + characteristics (isolation level, read only/read write, + snapshot - but not any work done / data modified within + the transaction). + --sha256-password-proxy-users + If set to FALSE (the default), then the sha256_password + authentication plugin will not signal for authenticated + users to be checked for mapping to proxy users. When set + to TRUE, the plugin will flag associated authenticated + accounts to be mapped to proxy users when the server + option check_proxy_users is enabled. + --show-create-table-verbosity + When this option is enabled, it increases the verbosity + of 'SHOW CREATE TABLE'. + --show-old-temporals + When this option is enabled, the pre-5.6.4 temporal types + will be marked in the 'SHOW CREATE TABLE' and + 'INFORMATION_SCHEMA.COLUMNS' table as a comment in + COLUMN_TYPE field. This variable is deprecated and will + be removed in a future release. + --show-slave-auth-info + Show user and password in SHOW SLAVE HOSTS on this + master. + --skip-grant-tables Start without grant tables. This gives all users FULL + ACCESS to all tables. + --skip-host-cache Don't cache host names. + --skip-name-resolve Don't resolve hostnames. All hostnames are IP's or + 'localhost'. + --skip-networking Don't allow connection with TCP/IP + --skip-new Don't use new, possibly wrong routines. + --skip-show-database + Don't allow 'SHOW DATABASE' commands + --skip-slave-start If set, slave is not autostarted. + --skip-stack-trace Don't print a stack trace on failure. + --slave-allow-batching + Allow slave to batch requests + --slave-checkpoint-group=# + Maximum number of processed transactions by + Multi-threaded slave before a checkpoint operation is + called to update progress status. + --slave-checkpoint-period=# + Gather workers' activities to Update progress status of + Multi-threaded slave and flush the relay log info to disk + after every #th milli-seconds. + --slave-compressed-protocol + Use compression on master/slave protocol + --slave-exec-mode=name + Modes for how replication events should be executed. + Legal values are STRICT (default) and IDEMPOTENT. In + IDEMPOTENT mode, replication will not stop for operations + that are idempotent. In STRICT mode, replication will + stop on any unexpected difference between the master and + the slave + --slave-load-tmpdir=name + The location where the slave should put its temporary + files when replicating a LOAD DATA INFILE command + --slave-max-allowed-packet=# + The maximum packet length to sent successfully from the + master to slave. + --slave-net-timeout=# + Number of seconds to wait for more data from a + master/slave connection before aborting the read + --slave-parallel-type=name + Specifies if the slave will use database partitioning or + information from master to parallelize + transactions.(Default: DATABASE). + --slave-parallel-workers=# + Number of worker threads for executing events in parallel + --slave-pending-jobs-size-max=# + Max size of Slave Worker queues holding not yet applied + events. The least possible value must be not less than + the master side max_allowed_packet. + --slave-preserve-commit-order + Force slave workers to make commits in the same order as + on the master. Disabled by default. + --slave-rows-search-algorithms=name + Set of searching algorithms that the slave will use while + searching for records from the storage engine to either + updated or deleted them. Possible values are: INDEX_SCAN, + TABLE_SCAN and HASH_SCAN. Any combination is allowed, and + the slave will always pick the most suitable algorithm + for any given scenario. (Default: INDEX_SCAN, HASH_SCAN). + --slave-skip-errors=name + Tells the slave thread to continue replication when a + query event returns an error from the provided list + --slave-sql-verify-checksum + Force checksum verification of replication events after + reading them from relay log. Note: Events are always + checksum-verified by slave on receiving them from the + network before writing them to the relay log. Enabled by + default. + (Defaults to on; use --skip-slave-sql-verify-checksum to disable.) + --slave-transaction-retries=# + Number of times the slave SQL thread will retry a + transaction in case it failed with a deadlock or elapsed + lock wait timeout, before giving up and stopping + --slave-type-conversions=name + Set of slave type conversions that are enabled. Legal + values are: ALL_LOSSY to enable lossy conversions, + ALL_NON_LOSSY to enable non-lossy conversions, + ALL_UNSIGNED to treat all integer column type data to be + unsigned values, and ALL_SIGNED to treat all integer + column type data to be signed values. Default treatment + is ALL_SIGNED. If ALL_SIGNED and ALL_UNSIGNED both are + specified, ALL_SIGNED will take higher priority than + ALL_UNSIGNED. If the variable is assigned the empty set, + no conversions are allowed and it is expected that the + types match exactly. + --slow-launch-time=# + If creating the thread takes longer than this value (in + seconds), the Slow_launch_threads counter will be + incremented + --slow-query-log Log slow queries to a table or log file. Defaults logging + to a file hostname-slow.log or a table mysql.slow_log if + --log-output=TABLE is used. Must be enabled to activate + other slow log options + --slow-query-log-file=name + Log slow queries to given log file. Defaults logging to + hostname-slow.log. Must be enabled to activate other slow + log options + --socket=name Socket file to use for connection + --sort-buffer-size=# + Each thread that needs to do a sort allocates a buffer of + this size + --sporadic-binlog-dump-fail + Option used by mysql-test for debugging and testing of + replication. + --sql-mode=name Syntax: sql-mode=mode[,mode[,mode...]]. See the manual + for the complete list of valid sql modes + --sql-require-primary-key + When set, tables must be created with a primary key, and + an existing primary key cannot be removed with 'ALTER + TABLE'. Attempts to do so will result in an error. + --stored-program-cache=# + The soft upper limit for number of cached stored routines + for one connection. + --stored-program-definition-cache=# + The number of cached stored program definitions + --super-read-only Make all non-temporary tables read-only, with the + exception for replication (slave) threads. Users with + the SUPER privilege are affected, unlike read_only. + Setting super_read_only to ON also sets read_only to ON. + -s, --symbolic-links + Enable symbolic link support (deprecated and will be + removed in a future release). + --sync-binlog=# Synchronously flush binary log to disk after every #th + write to the file. Use 0 to disable synchronous flushing + --sync-master-info=# + Synchronously flush master info to disk after every #th + event. Use 0 to disable synchronous flushing + --sync-relay-log=# Synchronously flush relay log to disk after every #th + event. Use 0 to disable synchronous flushing + --sync-relay-log-info=# + Synchronously flush relay log info to disk after every + #th transaction. Use 0 to disable synchronous flushing + --sysdate-is-now Non-default option to alias SYSDATE() to NOW() to make it + safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' + value different for different invocations, even within + the same statement. + --table-definition-cache=# + The number of cached table definitions + --table-encryption-privilege-check + Indicates if server enables privilege check when user + tries to use non-default value for CREATE DATABASE or + CREATE TABLESPACE or when user tries to do CREATE TABLE + with ENCRYPTION option which deviates from per-database + default. + --table-open-cache=# + The number of cached open tables (total for all table + cache instances) + --table-open-cache-instances=# + The number of table cache instances + --tablespace-definition-cache=# + The number of cached tablespace definitions + --tc-heuristic-recover=name + Decision to use in heuristic recover process. Possible + values are OFF, COMMIT or ROLLBACK. + --temptable-max-mmap=# + Maximum amount of memory (in bytes) the TempTable storage + engine is allowed to allocate from MMAP-backed files + before starting to store data on disk. + --temptable-max-ram=# + Maximum amount of memory (in bytes) the TempTable storage + engine is allowed to allocate from the main memory (RAM) + before starting to store data on disk. + --temptable-use-mmap + Use mmap files for temptables + (Defaults to on; use --skip-temptable-use-mmap to disable.) + --thread-cache-size=# + How many threads we should keep in a cache for reuse + --thread-handling=name + Define threads usage for handling queries, one of + one-thread-per-connection, no-threads, loaded-dynamically + --thread-stack=# The stack size for each thread + --tls-ciphersuites=name + --tls-version=name TLS version, permitted values are TLSv1, TLSv1.1, + TLSv1.2, TLSv1.3 + --tmp-table-size=# If an internal in-memory temporary table in the MEMORY + storage engine exceeds this size, MySQL will + automatically convert it to an on-disk table + -t, --tmpdir=name Path for temporary files. Several paths may be specified, + separated by a colon (:), in this case they are used in a + round-robin fashion + --transaction-alloc-block-size=# + Allocation block size for transactions to be stored in + binary log + --transaction-isolation=name + Default transaction isolation level. + --transaction-prealloc-size=# + Persistent buffer for transactions to be stored in binary + log + --transaction-read-only + Default transaction access mode. True if transactions are + read-only. + --transaction-write-set-extraction[=name] + This option is used to let the server know when to + extract the write set which will be used for various + purposes. + --updatable-views-with-limit=name + YES = Don't issue an error message (warning only) if a + VIEW without presence of a key of the underlying table is + used in queries with a LIMIT clause for updating. NO = + Prohibit update of a VIEW, which does not contain a key + of the underlying table and the query uses a LIMIT clause + (usually get from GUI tools) + --upgrade=name Set server upgrade mode. NONE to abort server if + automatic upgrade of the server is needed; MINIMAL to + start the server, but skip upgrade steps that are not + absolutely necessary; AUTO (default) to upgrade the + server if required; FORCE to force upgrade server. + -u, --user=name Run mysqld daemon as user. + --validate-config Validate the server configuration specified by the user. + --validate-user-plugins + Turns on additional validation of authentication plugins + assigned to user accounts. + (Defaults to on; use --skip-validate-user-plugins to disable.) + -v, --verbose Used with --help option for detailed help. + -V, --version Output version information and exit. + --wait-timeout=# The number of seconds the server waits for activity on a + connection before closing it + --windowing-use-high-precision + For SQL window functions, determines whether to enable + inversion optimization for moving window frames also for + floating values. + (Defaults to on; use --skip-windowing-use-high-precision to disable.) + +Variables (--variable-name=value) +abort-slave-event-count 0 +activate-all-roles-on-login FALSE +admin-address (No default value) +admin-port 33062 +admin-ssl TRUE +admin-ssl-ca (No default value) +admin-ssl-capath (No default value) +admin-ssl-cert (No default value) +admin-ssl-cipher (No default value) +admin-ssl-crl (No default value) +admin-ssl-crlpath (No default value) +admin-ssl-key (No default value) +admin-tls-ciphersuites (No default value) +allow-suspicious-udfs FALSE +auto-increment-increment 1 +auto-increment-offset 1 +autocommit TRUE +automatic-sp-privileges TRUE +avoid-temporal-upgrade FALSE +back-log 151 +big-tables FALSE +bind-address * +binlog-cache-size 32768 +binlog-checksum CRC32 +binlog-direct-non-transactional-updates FALSE +binlog-encryption FALSE +binlog-error-action ABORT_SERVER +binlog-expire-logs-seconds 2592000 +binlog-format ROW +binlog-group-commit-sync-delay 0 +binlog-group-commit-sync-no-delay-count 0 +binlog-gtid-simple-recovery TRUE +binlog-max-flush-queue-time 0 +binlog-order-commits TRUE +binlog-rotate-encryption-master-key-at-startup FALSE +binlog-row-event-max-size 8192 +binlog-row-image FULL +binlog-row-metadata MINIMAL +binlog-row-value-options +binlog-rows-query-log-events FALSE +binlog-stmt-cache-size 32768 +binlog-transaction-compression FALSE +binlog-transaction-compression-level-zstd 3 +binlog-transaction-dependency-history-size 25000 +binlog-transaction-dependency-tracking COMMIT_ORDER +block-encryption-mode aes-128-ecb +bulk-insert-buffer-size 8388608 +caching-sha2-password-digest-rounds 5000 +caching-sha2-password-private-key-path private_key.pem +caching-sha2-password-public-key-path public_key.pem +character-set-client-handshake TRUE +character-set-filesystem binary +character-set-server utf8mb4 +character-sets-dir MYSQL_CHARSETSDIR/ +check-proxy-users FALSE +chroot (No default value) +collation-server utf8mb4_0900_ai_ci +completion-type NO_CHAIN +concurrent-insert AUTO +connect-timeout 10 +console FALSE +create-admin-listener-thread FALSE +cte-max-recursion-depth 1000 +daemonize FALSE +default-authentication-plugin caching_sha2_password +default-password-lifetime 0 +default-storage-engine InnoDB +default-table-encryption FALSE +default-time-zone (No default value) +default-tmp-storage-engine InnoDB +default-week-format 0 +delay-key-write ON +delayed-insert-limit 100 +delayed-insert-timeout 300 +delayed-queue-size 1000 +disabled-storage-engines +disconnect-on-expired-password TRUE +disconnect-slave-event-count 0 +div-precision-increment 4 +end-markers-in-json FALSE +enforce-gtid-consistency FALSE +eq-range-index-dive-limit 200 +event-scheduler ON +expire-logs-days 0 +explicit-defaults-for-timestamp TRUE +external-locking FALSE +flush FALSE +flush-time 0 +force-parallel-execute FALSE +ft-boolean-syntax + -><()~*:""&| +ft-max-word-len 84 +ft-min-word-len 4 +ft-query-expansion-limit 20 +ft-stopword-file (No default value) +gdb FALSE +general-log FALSE +generated-random-password-length 20 +group-concat-max-len 1024 +group-replication-consistency EVENTUAL +gtid-executed-compression-period 0 +gtid-mode OFF +help TRUE +histogram-generation-max-mem-size 20000000 +host-cache-size 279 +information-schema-stats-expiry 86400 +init-connect +init-file (No default value) +init-slave +initialize TRUE +initialize-insecure TRUE +interactive-timeout 28800 +internal-tmp-mem-storage-engine TempTable +join-buffer-size 262144 +keep-files-on-create FALSE +key-buffer-size 8388608 +key-cache-age-threshold 300 +key-cache-block-size 1024 +key-cache-division-limit 100 +keyring-migration-destination (No default value) +keyring-migration-host (No default value) +keyring-migration-port 0 +keyring-migration-source (No default value) +keyring-migration-to-component FALSE +keyring-migration-user (No default value) +large-pages FALSE +lc-messages en_US +lc-time-names en_US +local-infile FALSE +lock-wait-timeout 31536000 +log-bin (No default value) +log-bin-index (No default value) +log-bin-trust-function-creators FALSE +log-bin-use-v1-row-events FALSE +log-error stderr +log-error-services log_filter_internal; log_sink_internal +log-error-suppression-list +log-error-verbosity 2 +log-isam myisam.log +log-output FILE +log-queries-not-using-indexes FALSE +log-raw FALSE +log-short-format FALSE +log-slave-updates FALSE +log-slow-admin-statements FALSE +log-slow-extra FALSE +log-slow-slave-statements FALSE +log-statements-unsafe-for-binlog TRUE +log-tc tc.log +log-tc-size ##### +log-throttle-queries-not-using-indexes 0 +log-timestamps UTC +long-query-time 10 +low-priority-updates FALSE +lower-case-table-names 1 +mandatory-roles +master-info-file master.info +master-info-repository TABLE +master-retry-count 86400 +master-verify-checksum FALSE +max-allowed-packet 67108864 +max-binlog-cache-size 18446744073709547520 +max-binlog-dump-events 0 +max-binlog-size 1073741824 +max-binlog-stmt-cache-size 18446744073709547520 +max-connect-errors 100 +max-connections 151 +max-delayed-threads 20 +max-digest-length 1024 +max-error-count 1024 +max-execution-time 0 +max-heap-table-size 16777216 +max-join-size 18446744073709551615 +max-length-for-sort-data 4096 +max-points-in-geometry 65536 +max-prepared-stmt-count 16382 +max-relay-log-size 0 +max-seeks-for-key 18446744073709551615 +max-sort-length 1024 +max-sp-recursion-depth 0 +max-user-connections 0 +max-write-lock-count 18446744073709551615 +memlock FALSE +min-examined-row-limit 0 +myisam-block-size 1024 +myisam-data-pointer-size 6 +myisam-max-sort-file-size 9223372036853727232 +myisam-mmap-size 18446744073709551615 +myisam-recover-options OFF +myisam-repair-threads 1 +myisam-sort-buffer-size 8388608 +myisam-stats-method nulls_unequal +myisam-use-mmap FALSE +mysql-native-password-proxy-users FALSE +net-buffer-length 16384 +net-read-timeout 30 +net-retry-count 10 +net-write-timeout 60 +new FALSE +no-dd-upgrade FALSE +offline-mode FALSE +old FALSE +old-alter-table FALSE +old-style-user-limits FALSE +optimizer-prune-level 1 +optimizer-search-depth 62 +optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +optimizer-trace +optimizer-trace-features greedy_search=on,range_optimizer=on,dynamic_range=on,repeated_subselect=on +optimizer-trace-limit 1 +optimizer-trace-max-mem-size 1048576 +optimizer-trace-offset -1 +parallel-cost-threshold 1000 +parallel-default-dop 4 +parallel-max-threads 64 +parallel-memory-limit 104857600 +parallel-queue-timeout 0 +parser-max-mem-size 18446744073709551615 +partial-revokes #### +password-history 0 +password-require-current FALSE +password-reuse-interval 0 +performance-schema TRUE +performance-schema-accounts-size -1 +performance-schema-consumer-events-stages-current FALSE +performance-schema-consumer-events-stages-history FALSE +performance-schema-consumer-events-stages-history-long FALSE +performance-schema-consumer-events-statements-current TRUE +performance-schema-consumer-events-statements-history TRUE +performance-schema-consumer-events-statements-history-long FALSE +performance-schema-consumer-events-transactions-current TRUE +performance-schema-consumer-events-transactions-history TRUE +performance-schema-consumer-events-transactions-history-long FALSE +performance-schema-consumer-events-waits-current FALSE +performance-schema-consumer-events-waits-history FALSE +performance-schema-consumer-events-waits-history-long FALSE +performance-schema-consumer-global-instrumentation TRUE +performance-schema-consumer-statements-digest TRUE +performance-schema-consumer-thread-instrumentation TRUE +performance-schema-digests-size -1 +performance-schema-error-size #### +performance-schema-events-stages-history-long-size -1 +performance-schema-events-stages-history-size -1 +performance-schema-events-statements-history-long-size -1 +performance-schema-events-statements-history-size -1 +performance-schema-events-transactions-history-long-size -1 +performance-schema-events-transactions-history-size -1 +performance-schema-events-waits-history-long-size -1 +performance-schema-events-waits-history-size -1 +performance-schema-hosts-size -1 +performance-schema-instrument +performance-schema-max-cond-classes 100 +performance-schema-max-cond-instances -1 +performance-schema-max-digest-length 1024 +performance-schema-max-digest-sample-age 60 +performance-schema-max-file-classes 80 +performance-schema-max-file-handles 32768 +performance-schema-max-file-instances -1 +performance-schema-max-index-stat -1 +performance-schema-max-memory-classes 450 +performance-schema-max-metadata-locks -1 +performance-schema-max-mutex-classes 300 +performance-schema-max-mutex-instances -1 +performance-schema-max-prepared-statements-instances -1 +performance-schema-max-program-instances -1 +performance-schema-max-rwlock-classes 60 +performance-schema-max-rwlock-instances -1 +performance-schema-max-socket-classes 10 +performance-schema-max-socket-instances -1 +performance-schema-max-sql-text-length 1024 +performance-schema-max-stage-classes 175 +performance-schema-max-statement-classes 218 +performance-schema-max-statement-stack 10 +performance-schema-max-table-handles -1 +performance-schema-max-table-instances -1 +performance-schema-max-table-lock-stat -1 +performance-schema-max-thread-classes 100 +performance-schema-max-thread-instances -1 +performance-schema-session-connect-attrs-size -1 +performance-schema-setup-actors-size -1 +performance-schema-setup-objects-size -1 +performance-schema-show-processlist FALSE +performance-schema-users-size -1 +persist-only-admin-x509-subject +persisted-globals-load TRUE +port #### +port-open-timeout 0 +preload-buffer-size 32768 +print-identified-with-as-hex FALSE +profiling-history-size 15 +protocol-compression-algorithms zlib,zstd,uncompressed +query-alloc-block-size 8192 +query-prealloc-size 8192 +range-alloc-block-size 4096 +range-optimizer-max-mem-size 8388608 +read-buffer-size 131072 +read-only FALSE +read-rnd-buffer-size 262144 +regexp-stack-limit 8000000 +regexp-time-limit 32 +relay-log relaylog +relay-log-index relaylog.index +relay-log-info-file relay-log.info +relay-log-info-repository TABLE +relay-log-purge TRUE +relay-log-recovery FALSE +relay-log-space-limit 0 +replicate-same-server-id FALSE +replication-optimize-for-static-plugin-config FALSE +replication-sender-observe-commit-only FALSE +report-host (No default value) +report-password (No default value) +report-port 0 +report-user (No default value) +require-secure-transport FALSE +rpl-read-size 8192 +rpl-stop-slave-timeout 31536000 +safe-user-create FALSE +schema-definition-cache 256 +secondary-engine-cost-threshold 100000 +select-into-buffer-size 131072 +select-into-disk-sync FALSE +select-into-disk-sync-delay 0 +server-id 1 +server-id-bits 32 +session-track-gtids OFF +session-track-schema TRUE +session-track-state-change FALSE +session-track-system-variables time_zone,autocommit,character_set_client,character_set_results,character_set_connection +session-track-transaction-info OFF +sha256-password-proxy-users FALSE +show-create-table-verbosity FALSE +show-old-temporals FALSE +show-slave-auth-info FALSE +skip-grant-tables TRUE +skip-name-resolve FALSE +skip-networking FALSE +skip-show-database FALSE +skip-slave-start FALSE +slave-allow-batching FALSE +slave-checkpoint-group 512 +slave-checkpoint-period 300 +slave-compressed-protocol FALSE +slave-exec-mode STRICT +slave-max-allowed-packet 1073741824 +slave-net-timeout 60 +slave-parallel-type DATABASE +slave-parallel-workers 0 +slave-pending-jobs-size-max 134217728 +slave-preserve-commit-order FALSE +slave-rows-search-algorithms INDEX_SCAN,HASH_SCAN +slave-skip-errors (No default value) +slave-sql-verify-checksum TRUE +slave-transaction-retries 10 +slave-type-conversions +slow-launch-time 2 +slow-query-log FALSE +sort-buffer-size 262144 +sporadic-binlog-dump-fail FALSE +sql-mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION +sql-require-primary-key FALSE +stored-program-cache 256 +stored-program-definition-cache 256 +super-read-only FALSE +symbolic-links FALSE +sync-binlog 1 +sync-master-info 10000 +sync-relay-log 10000 +sync-relay-log-info 10000 +sysdate-is-now FALSE +table-encryption-privilege-check FALSE +table-open-cache-instances 16 +tablespace-definition-cache 256 +tc-heuristic-recover OFF +temptable-max-mmap 1073741824 +temptable-max-ram 1073741824 +temptable-use-mmap TRUE +thread-cache-size 9 +thread-handling one-thread-per-connection +thread-stack 262144 +tls-ciphersuites (No default value) +tmp-table-size 16777216 +transaction-alloc-block-size 8192 +transaction-isolation REPEATABLE-READ +transaction-prealloc-size 4096 +transaction-read-only FALSE +transaction-write-set-extraction XXHASH64 +updatable-views-with-limit YES +upgrade AUTO +validate-config FALSE +validate-user-plugins TRUE +verbose TRUE +wait-timeout 28800 +windowing-use-high-precision TRUE + +To see what values a running MySQL server is using, type +'mysqladmin variables' instead of 'mysqld --verbose --help'. diff --git a/mysql-test/r/negation_elimination.result-pq b/mysql-test/r/negation_elimination.result-pq new file mode 100644 index 000000000..f7806d3cd --- /dev/null +++ b/mysql-test/r/negation_elimination.result-pq @@ -0,0 +1,589 @@ +drop table if exists t1; +create table t1 (a int, key (a)); +insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where not(not(a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL # NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL # a a 5 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (0 <> `test`.`t1`.`a`) +select * from t1 where not(not(a)); +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(not(not(a > 10))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <= 10) +select * from t1 where not(not(not(a > 10))); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +explain select * from t1 where not(not(not(a < 5) and not(a > 10))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` <= 10)) +select * from t1 where not(not(not(a < 5) and not(a > 10))); +a +5 +6 +7 +8 +9 +10 +explain select * from t1 where not(a = 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 19 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 19 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <> 10) +select * from t1 where not(a = 10); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a != 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 10) +select * from t1 where not(a != 1); +a +1 +explain select * from t1 where not(a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` >= 10) +select * from t1 where not(a < 10); +a +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a >= 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` < 10) +select * from t1 where not(a >= 10); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t1 where not(a > 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <= 10) +select * from t1 where not(a > 10); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +explain select * from t1 where not(a <= 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 10) +select * from t1 where not(a <= 10); +a +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a is null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 20 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where not(a is null); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not(a is not null); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is null) +select * from t1 where not(a is not null); +a +NULL +explain select * from t1 where not(a < 5 or a > 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` <= 15)) +select * from t1 where not(a < 5 or a > 15); +a +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +explain select * from t1 where not(a < 15 and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 15) or (`test`.`t1`.`a` <= 5)) +select * from t1 where not(a < 15 and a > 5); +a +0 +1 +2 +3 +4 +5 +15 +16 +17 +18 +19 +explain select * from t1 where a = 2 or not(a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 2) or (`test`.`t1`.`a` >= 10)) +select * from t1 where a = 2 or not(a < 10); +a +2 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where a > 5 and not(a > 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` > 5) and (`test`.`t1`.`a` <= 10)) +select * from t1 where a > 5 and not(a > 10); +a +6 +7 +8 +9 +10 +explain select * from t1 where a > 5 xor a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 44.44 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 44.44 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` > 5) xor (`test`.`t1`.`a` < 10)) +select * from t1 where a > 5 xor a < 10; +a +0 +1 +2 +3 +4 +5 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where a = 2 or not(a < 5 or a > 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 12 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 2) or ((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` <= 15))) +select * from t1 where a = 2 or not(a < 5 or a > 15); +a +2 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +explain select * from t1 where a = 7 or not(a < 15 and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range a a 5 NULL 12 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 7) or (`test`.`t1`.`a` >= 15) or (`test`.`t1`.`a` <= 5)) +select * from t1 where a = 7 or not(a < 15 and a > 5); +a +0 +1 +2 +3 +4 +5 +7 +15 +16 +17 +18 +19 +explain select * from t1 where NULL or not(a < 15 and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 15) or (`test`.`t1`.`a` <= 5)) +select * from t1 where NULL or not(a < 15 and a > 5); +a +0 +1 +2 +3 +4 +5 +15 +16 +17 +18 +19 +explain select * from t1 where not(NULL and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 6 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <= 5) +select * from t1 where not(NULL and a > 5); +a +0 +1 +2 +3 +4 +5 +explain select * from t1 where not(NULL or a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where not(NULL or a); +a +explain select * from t1 where not(NULL and a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 0) +select * from t1 where not(NULL and a); +a +0 +explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (((`test`.`t1`.`a` >= 5) and (`test`.`t1`.`a` >= 10)) or ((`test`.`t1`.`a` > 16) and (`test`.`t1`.`a` <= 17))) +select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17)); +a +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 15 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 15 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` >= 5) or (`test`.`t1`.`a` >= 10) or ((`test`.`t1`.`a` > 16) and (`test`.`t1`.`a` <= 17))) +select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17)); +a +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where ((a between 5 and 15) and (not(a like 10))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` between 5 and 15) and (not((`test`.`t1`.`a` like 10)))) +select * from t1 where ((a between 5 and 15) and (not(a like 10))); +a +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +# XOR (Note: XOR is negated by negating one of the operands) +# Should return 6,7 +SELECT * FROM t1 WHERE ((a > 5) XOR (a > 7)); +a +6 +7 +# Should return 0..5,8..19 +SELECT * FROM t1 WHERE ((NOT (a > 5)) XOR (a > 7)); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +SELECT * FROM t1 WHERE ((a > 5) XOR (NOT (a > 7))); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +SELECT * FROM t1 WHERE NOT ((a > 5) XOR (a > 7)); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +# Should return 6,7 +SELECT * FROM t1 WHERE NOT ((NOT (a > 5)) XOR (a > 7)); +a +6 +7 +SELECT * FROM t1 WHERE NOT ((a > 5) XOR (NOT (a > 7))); +a +6 +7 +# Should return 0..5,8..19 +SELECT * FROM t1 WHERE NOT ((NOT (a > 5)) XOR (NOT (a > 7))); +a +0 +1 +2 +3 +4 +5 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +# Should have empty result +SELECT * FROM t1 WHERE (NULL XOR (a > 7)); +a +SELECT * FROM t1 WHERE NOT (NULL XOR (a > 7)); +a +# Should be simplified to "...WHERE (a XOR a) +EXPLAIN SELECT * FROM t1 WHERE NOT ((NOT a) XOR (a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 18.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 18.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((0 <> `test`.`t1`.`a`) xor (0 <> `test`.`t1`.`a`)) +# Should be simplified to "...WHERE (a XOR a) +EXPLAIN SELECT * FROM t1 WHERE NOT (a XOR (NOT a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 21 18.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 21 18.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((0 = `test`.`t1`.`a`) xor (0 = `test`.`t1`.`a`)) +# End XOR +delete from t1 where a > 3; +select a, not(not(a)) from t1; +a not(not(a)) +NULL NULL +0 0 +1 1 +2 1 +3 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL # NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL # a a 5 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,(0 <> `test`.`t1`.`a`) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or (0 <> `test`.`t1`.`a`)) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where (0 <> `test`.`t1`.`a`) having (0 <> `test`.`t1`.`a`) +drop table t1; diff --git a/mysql-test/r/null.result-pq b/mysql-test/r/null.result-pq new file mode 100644 index 000000000..2ef3cde91 --- /dev/null +++ b/mysql-test/r/null.result-pq @@ -0,0 +1,440 @@ +drop table if exists t1, t2; +select null,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null; +NULL isnull(null) isnull(1/0) isnull(1/0 = null) ifnull(null,1) ifnull(null,"TRUE") ifnull("TRUE","ERROR") 1/0 is null 1 is not null +NULL 1 1 1 1 TRUE TRUE 1 1 +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +Warning 1365 Division by 0 +explain select null,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +Warning 1365 Division by 0 +Note 1003 /* select#1 */ select NULL AS `NULL`,(NULL is null) AS `isnull(null)`,((1 / 0) is null) AS `isnull(1/0)`,(((1 / 0) = NULL) is null) AS `isnull(1/0 = null)`,ifnull(NULL,1) AS `ifnull(null,1)`,ifnull(NULL,'TRUE') AS `ifnull(null,"TRUE")`,ifnull('TRUE','ERROR') AS `ifnull("TRUE","ERROR")`,((1 / 0) is null) AS `1/0 is null`,(1 is not null) AS `1 is not null` +select 1 | NULL,1 & NULL,1+NULL,1-NULL; +1 | NULL 1 & NULL 1+NULL 1-NULL +NULL NULL NULL NULL +select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0; +NULL=NULL NULL<>NULL IFNULL(NULL,1.1)+0 IFNULL(NULL,1) | 0 +NULL NULL 1.1 1 +select strcmp("a",NULL),(1NULL; +indexed_field +NULL +NULL +DROP TABLE t1; +create table t1 (a int, b int); +insert into t1 values(20,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a; +b ifnull(t2.b,"this is null") +NULL this is null +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +insert into t1 values(10,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +NULL this is null +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; +Warnings: +Warning 1265 Data truncated for column 'd' at row 1 +UPDATE t1 SET d=1/NULL; +Warnings: +Warning 1048 Column 'd' cannot be null +UPDATE t1 SET d=NULL; +Warnings: +Warning 1048 Column 'd' cannot be null +INSERT INTO t1 (a) values (null); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t1 (a) values (1/null); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t1 (a) values (null),(null); +Warnings: +Warning 1048 Column 'a' cannot be null +INSERT INTO t1 (b) values (null); +ERROR 23000: Column 'b' cannot be null +INSERT INTO t1 (b) values (1/null); +ERROR 23000: Column 'b' cannot be null +INSERT INTO t1 (b) values (null),(null); +Warnings: +Warning 1048 Column 'b' cannot be null +INSERT INTO t1 (c) values (null); +ERROR 23000: Column 'c' cannot be null +INSERT INTO t1 (c) values (1/null); +ERROR 23000: Column 'c' cannot be null +INSERT INTO t1 (c) values (null),(null); +Warnings: +Warning 1048 Column 'c' cannot be null +INSERT INTO t1 (d) values (null); +ERROR 23000: Column 'd' cannot be null +INSERT INTO t1 (d) values (1/null); +ERROR 23000: Column 'd' cannot be null +INSERT INTO t1 (d) values (null),(null); +Warnings: +Warning 1048 Column 'd' cannot be null +select * from t1; +a b c d + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 + 0 0000-00-00 00:00:00 0 +drop table t1; +SET sql_mode = default; +create table t1 (a int not null, b int not null, index idx(a)); +insert into t1 values +(1,1), (2,2), (3,3), (4,4), (5,5), (6,6), +(7,7), (8,8), (9,9), (10,10), (11,11), (12,12); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where a between 2 and 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 4 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` between 2 and 3) +explain select * from t1 where a between 2 and 3 or b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx idx 4 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` between 2 and 3) +drop table t1; +select cast(NULL as signed); +cast(NULL as signed) +NULL +create table t1(i int, key(i)); +insert into t1 values(1); +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 select i*2 from t1; +insert into t1 values(null); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where i=2 or i is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null i i 5 const 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` = 2) or (`test`.`t1`.`i` is null)) +select count(*) from t1 where i=2 or i is null; +count(*) +10 +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +alter table t1 change i i int not null; +Warnings: +Warning 1265 Data truncated for column 'i' at row 513 +SET sql_mode = default; +explain select * from t1 where i=2 or i is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i i 4 const 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`i` = 2) +select count(*) from t1 where i=2 or i is null; +count(*) +9 +drop table t1; +set names latin2; +create table t1 select +null as c00, +if(1, null, 'string') as c01, +if(0, null, 'string') as c02, +ifnull(null, 'string') as c03, +ifnull('string', null) as c04, +case when 0 then null else 'string' end as c05, +case when 1 then null else 'string' end as c06, +coalesce(null, 'string') as c07, +coalesce('string', null) as c08, +least('string',null) as c09, +least(null, 'string') as c10, +greatest('string',null) as c11, +greatest(null, 'string') as c12, +nullif('string', null) as c13, +nullif(null, 'string') as c14, +trim('string' from null) as c15, +trim(null from 'string') as c16, +substring_index('string', null, 1) as c17, +substring_index(null, 'string', 1) as c18, +elt(1, null, 'string') as c19, +elt(1, 'string', null) as c20, +concat('string', null) as c21, +concat(null, 'string') as c22, +concat_ws('sep', 'string', null) as c23, +concat_ws('sep', null, 'string') as c24, +concat_ws(null, 'string', 'string') as c25, +make_set(3, 'string', null) as c26, +make_set(3, null, 'string') as c27, +export_set(3, null, 'off', 'sep') as c29, +export_set(3, 'on', null, 'sep') as c30, +export_set(3, 'on', 'off', null) as c31, +replace(null, 'from', 'to') as c32, +replace('str', null, 'to') as c33, +replace('str', 'from', null) as c34, +insert('str', 1, 2, null) as c35, +insert(null, 1, 2, 'str') as c36, +lpad('str', 10, null) as c37, +rpad(null, 10, 'str') as c38; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c00` binary(0) DEFAULT NULL, + `c01` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c02` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c03` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c04` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c05` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c06` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c07` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c08` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', + `c09` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c10` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c11` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c12` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c13` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c14` binary(0) DEFAULT NULL, + `c15` binary(0) DEFAULT NULL, + `c16` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c17` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c18` binary(0) DEFAULT NULL, + `c19` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c20` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c21` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c22` varchar(6) CHARACTER SET latin2 DEFAULT NULL, + `c23` varchar(9) CHARACTER SET latin2 DEFAULT NULL, + `c24` varchar(9) CHARACTER SET latin2 DEFAULT NULL, + `c25` varchar(12) CHARACTER SET latin2 DEFAULT NULL, + `c26` varchar(7) CHARACTER SET latin2 DEFAULT NULL, + `c27` varchar(7) CHARACTER SET latin2 DEFAULT NULL, + `c29` varchar(381) CHARACTER SET latin2 DEFAULT NULL, + `c30` varchar(317) CHARACTER SET latin2 DEFAULT NULL, + `c31` varchar(192) CHARACTER SET latin2 DEFAULT NULL, + `c32` binary(0) DEFAULT NULL, + `c33` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c34` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c35` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c36` varchar(3) CHARACTER SET latin2 DEFAULT NULL, + `c37` varchar(10) CHARACTER SET latin2 DEFAULT NULL, + `c38` varchar(10) CHARACTER SET latin2 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +case 'str' when 'STR' then 'str' when null then 'null' end as c01, +case 'str' when null then 'null' when 'STR' then 'str' end as c02, +field(null, 'str1', 'str2') as c03, +field('str1','STR1', null) as c04, +field('str1', null, 'STR1') as c05, +'string' in ('STRING', null) as c08, +'string' in (null, 'STRING') as c09; +c01 c02 c03 c04 c05 c08 c09 +str str 0 1 2 1 1 +set names latin1; +create table bug19145a (e enum('a','b','c') default 'b' , s set('x', 'y', 'z') default 'y' ); +create table bug19145b (e enum('a','b','c') default null, s set('x', 'y', 'z') default null); +create table bug19145c (e enum('a','b','c') not null default 'b' , s set('x', 'y', 'z') not null default 'y' ); +create table bug19145setnotnulldefaultnull (e enum('a','b','c') default null, s set('x', 'y', 'z') not null default null); +ERROR 42000: Invalid default value for 's' +create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z') default null); +ERROR 42000: Invalid default value for 'e' +alter table bug19145a alter column e set default null; +alter table bug19145a alter column s set default null; +alter table bug19145a add column (i int); +alter table bug19145b alter column e set default null; +alter table bug19145b alter column s set default null; +alter table bug19145b add column (i int); +alter table bug19145c alter column e set default null; +ERROR 42000: Invalid default value for 'e' +alter table bug19145c alter column s set default null; +ERROR 42000: Invalid default value for 's' +alter table bug19145c add column (i int); +show create table bug19145a; +Table Create Table +bug19145a CREATE TABLE `bug19145a` ( + `e` enum('a','b','c') DEFAULT NULL, + `s` set('x','y','z') DEFAULT NULL, + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table bug19145b; +Table Create Table +bug19145b CREATE TABLE `bug19145b` ( + `e` enum('a','b','c') DEFAULT NULL, + `s` set('x','y','z') DEFAULT NULL, + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table bug19145c; +Table Create Table +bug19145c CREATE TABLE `bug19145c` ( + `e` enum('a','b','c') NOT NULL DEFAULT 'b', + `s` set('x','y','z') NOT NULL DEFAULT 'y', + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table bug19145a; +drop table bug19145b; +drop table bug19145c; +# End of 4.1 tests +# +# Bug #31471: decimal_bin_size: Assertion `scale >= 0 && +# precision > 0 && scale <= precision' +# +CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +INSERT INTO t1 (a, b) VALUES (0, 0); +CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, b) decimal(1,0) unsigned YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, NULL) decimal(1,0) unsigned YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(NULL, b) decimal(1,0) unsigned YES NULL +DROP TABLE t1, t2; +# End of 5.0 tests +# +# WL#7247: Removal of \N +# +SELECT \N; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\N' at line 1 +# +# Bug#29337233 'LATE NULLS FILTERING' NEEDED EVEN FOR EQ_REF JOINS KEYS +# +create table t1 ( +pk int primary key, +col_int_unique int, +c char(255) not null default 'xxxx' +) engine = innoDb; +create unique index ix1 ON t1(col_int_unique); +insert into t1(pk,col_int_unique) values (1,1), (2,NULL); +insert into t1(pk,col_int_unique) values (3,3), (4,4), (5,5), (6,6), (7,7), (8,8); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN * +FROM t1 LEFT OUTER JOIN t1 AS t2 +ON t1.col_int_unique = t2.col_int_unique; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 SIMPLE t2 NULL eq_ref ix1 ix1 5 test.t1.col_int_unique 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_unique` AS `col_int_unique`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_int_unique` AS `col_int_unique`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`col_int_unique` = `test`.`t1`.`col_int_unique`)) where true +SELECT STRAIGHT_JOIN * +FROM t1 LEFT OUTER JOIN t1 AS t2 +ON t1.col_int_unique = t2.col_int_unique; +pk col_int_unique c pk col_int_unique c +1 1 xxxx 1 1 xxxx +2 NULL xxxx NULL NULL NULL +3 3 xxxx 3 3 xxxx +4 4 xxxx 4 4 xxxx +5 5 xxxx 5 5 xxxx +6 6 xxxx 6 6 xxxx +7 7 xxxx 7 7 xxxx +8 8 xxxx 8 8 xxxx +flush status; +SELECT STRAIGHT_JOIN * +FROM t1 JOIN t1 AS t2 +ON t1.col_int_unique = t2.col_int_unique +WHERE t1.pk = 2; +pk col_int_unique c pk col_int_unique c +show status like 'handler_read_key'; +Variable_name Value +Handler_read_key 1 +drop table t1; diff --git a/mysql-test/r/null_key_all_innodb.result-pq b/mysql-test/r/null_key_all_innodb.result-pq new file mode 100644 index 000000000..0cc14ae48 --- /dev/null +++ b/mysql-test/r/null_key_all_innodb.result-pq @@ -0,0 +1,163 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on'; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (id int); +insert into t1 values (null), (0); +create table t2 (id int); +insert into t2 values (null); +select * from t1, t2 where t1.id = t2.id; +id id +alter table t1 add key id (id); +select * from t1, t2 where t1.id = t2.id; +id id +drop table t1,t2; +create table t1 ( +id integer, +id2 integer not null, +index (id), +index (id2) +); +insert into t1 values(null,null),(1,1); +Warnings: +Warning 1048 Column 'id2' cannot be null +select * from t1; +id id2 +NULL 0 +1 1 +select * from t1 where id <=> null; +id id2 +NULL 0 +select * from t1 where id <=> null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id is null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id2 <=> null or id2 > 0; +id id2 +1 1 +select * from t1 where id2 is null or id2 > 0; +id id2 +1 1 +delete from t1 where id <=> NULL; +select * from t1; +id id2 +1 1 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES +(NULL), (NULL), (NULL), (NULL), (NULL), +(NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); +ANALYZE table t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT COUNT(*) FROM t3; +COUNT(*) +15972 +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b # 100.00 Using index +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Note 1003 /* select#1 */ select sql_calc_found_rows `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) where true +FLUSH STATUS ; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +a a b b +1 1 1 NULL +2 NULL NULL NULL +3 3 1 NULL +4 NULL NULL NULL +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warnings: +SELECT FOUND_ROWS(); +FOUND_ROWS() +4 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 8 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a,b) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,10),(0,11),(0,12); +CREATE TABLE t2 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12); +SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b; +a b a b +3 11 0 11 +3 12 0 12 +drop table t1, t2; +End of 5.0 tests +# +# Bug#54608 Query using IN + OR + IS TRUE and IS NULL returns +# NULL when should be empty +# +CREATE TABLE t1 (a INT, KEY (a)); +INSERT INTO t1 VALUES (1), (2), (NULL); +explain SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (((0 <> `test`.`t1`.`a`) is true) and (`test`.`t1`.`a` is null))) +SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +a +explain SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (`test`.`t1`.`a` = NULL)) +SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +a +drop table t1; +SET sql_mode = default; +set optimizer_switch=default; diff --git a/mysql-test/r/null_key_icp_innodb.result-pq b/mysql-test/r/null_key_icp_innodb.result-pq new file mode 100644 index 000000000..f7f8c5348 --- /dev/null +++ b/mysql-test/r/null_key_icp_innodb.result-pq @@ -0,0 +1,163 @@ +set optimizer_switch='index_condition_pushdown=on'; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (id int); +insert into t1 values (null), (0); +create table t2 (id int); +insert into t2 values (null); +select * from t1, t2 where t1.id = t2.id; +id id +alter table t1 add key id (id); +select * from t1, t2 where t1.id = t2.id; +id id +drop table t1,t2; +create table t1 ( +id integer, +id2 integer not null, +index (id), +index (id2) +); +insert into t1 values(null,null),(1,1); +Warnings: +Warning 1048 Column 'id2' cannot be null +select * from t1; +id id2 +NULL 0 +1 1 +select * from t1 where id <=> null; +id id2 +NULL 0 +select * from t1 where id <=> null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id is null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id2 <=> null or id2 > 0; +id id2 +1 1 +select * from t1 where id2 is null or id2 > 0; +id id2 +1 1 +delete from t1 where id <=> NULL; +select * from t1; +id id2 +1 1 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES +(NULL), (NULL), (NULL), (NULL), (NULL), +(NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); +ANALYZE table t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT COUNT(*) FROM t3; +COUNT(*) +15972 +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b # 100.00 Using index +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Note 1003 /* select#1 */ select sql_calc_found_rows `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) where true +FLUSH STATUS ; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +a a b b +1 1 1 NULL +2 NULL NULL NULL +3 3 1 NULL +4 NULL NULL NULL +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warnings: +SELECT FOUND_ROWS(); +FOUND_ROWS() +4 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 8 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a,b) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,10),(0,11),(0,12); +CREATE TABLE t2 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12); +SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b; +a b a b +3 11 0 11 +3 12 0 12 +drop table t1, t2; +End of 5.0 tests +# +# Bug#54608 Query using IN + OR + IS TRUE and IS NULL returns +# NULL when should be empty +# +CREATE TABLE t1 (a INT, KEY (a)); +INSERT INTO t1 VALUES (1), (2), (NULL); +explain SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (((0 <> `test`.`t1`.`a`) is true) and (`test`.`t1`.`a` is null))) +SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +a +explain SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (`test`.`t1`.`a` = NULL)) +SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +a +drop table t1; +SET sql_mode = default; +set optimizer_switch=default; diff --git a/mysql-test/r/null_key_none_innodb.result-pq b/mysql-test/r/null_key_none_innodb.result-pq new file mode 100644 index 000000000..c6e84d796 --- /dev/null +++ b/mysql-test/r/null_key_none_innodb.result-pq @@ -0,0 +1,162 @@ +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (id int); +insert into t1 values (null), (0); +create table t2 (id int); +insert into t2 values (null); +select * from t1, t2 where t1.id = t2.id; +id id +alter table t1 add key id (id); +select * from t1, t2 where t1.id = t2.id; +id id +drop table t1,t2; +create table t1 ( +id integer, +id2 integer not null, +index (id), +index (id2) +); +insert into t1 values(null,null),(1,1); +Warnings: +Warning 1048 Column 'id2' cannot be null +select * from t1; +id id2 +NULL 0 +1 1 +select * from t1 where id <=> null; +id id2 +NULL 0 +select * from t1 where id <=> null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id is null or id > 0; +id id2 +NULL 0 +1 1 +select * from t1 where id2 <=> null or id2 > 0; +id id2 +1 1 +select * from t1 where id2 is null or id2 > 0; +id id2 +1 1 +delete from t1 where id <=> NULL; +select * from t1; +id id2 +1 1 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES +(NULL), (NULL), (NULL), (NULL), (NULL), +(NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); +ANALYZE table t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SELECT COUNT(*) FROM t3; +COUNT(*) +15972 +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t2 NULL ALL idx NULL NULL NULL # 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ref idx idx 5 test.t2.b # 100.00 Using index +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Note 1003 /* select#1 */ select sql_calc_found_rows `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) where true +FLUSH STATUS ; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +a a b b +1 1 1 NULL +2 NULL NULL NULL +3 3 1 NULL +4 NULL NULL NULL +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warnings: +SELECT FOUND_ROWS(); +FOUND_ROWS() +4 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 8 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a,b) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,10),(0,11),(0,12); +CREATE TABLE t2 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12); +SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b; +a b a b +3 11 0 11 +3 12 0 12 +drop table t1, t2; +End of 5.0 tests +# +# Bug#54608 Query using IN + OR + IS TRUE and IS NULL returns +# NULL when should be empty +# +CREATE TABLE t1 (a INT, KEY (a)); +INSERT INTO t1 VALUES (1), (2), (NULL); +explain SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (((0 <> `test`.`t1`.`a`) is true) and (`test`.`t1`.`a` is null))) +SELECT a FROM t1 WHERE a IN (42) OR (a IS TRUE AND a IS NULL); +a +explain SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null a a 5 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 42) or (`test`.`t1`.`a` = NULL)) +SELECT a FROM t1 WHERE a IN (42) OR (a=NULL); +a +drop table t1; +SET sql_mode = default; +set optimizer_switch=default; diff --git a/mysql-test/r/opt_costmodel.result-pq b/mysql-test/r/opt_costmodel.result-pq new file mode 100644 index 000000000..26877e620 --- /dev/null +++ b/mysql-test/r/opt_costmodel.result-pq @@ -0,0 +1,597 @@ +# +# Bug#20443863 USE OF WORST_SEEKS IN FIND_BEST_REF() CAN LEAD TO +# WRONG QUERY PLAN +# +CREATE TABLE t1 ( +i1 INTEGER, +i2 INTEGER, +i3 INTEGER, +KEY(i1,i2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 1),(1, 1, 1),(1, 1, 1), +(2, 2, 1), (2, 2, 1),(2, 2, 1),(2, 2, 1), +(3, 3, 1), (3, 3, 1),(3, 3, 1),(3, 3, 1); +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i2 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "64" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1", + "i2" + ], + "key_length": "10", + "ref": [ + "const", + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.40", + "prefix_cost": "0.90", + "data_read_per_join": "64" + }, + "used_columns": [ + "i1", + "i2", + "i3" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i2` = 1) and (`test`.`t1`.`i1` = 1)) +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i3 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.04", + "prefix_cost": "0.90", + "data_read_per_join": "6" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "0.90" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.04", + "prefix_cost": "0.90", + "data_read_per_join": "6" + }, + "used_columns": [ + "i1", + "i3" + ], + "attached_condition": "(`test`.`t1`.`i3` = 1)" + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i3` = 1) and (`test`.`t1`.`i1` = 1)) +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="row_evaluate_cost"; +UPDATE mysql.server_cost +SET cost_value=0.05 +WHERE cost_name="key_compare_cost"; +UPDATE mysql.server_cost +SET cost_value=1.0 +WHERE cost_name="memory_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="memory_temptable_row_cost"; +UPDATE mysql.server_cost +SET cost_value=20 +WHERE cost_name="disk_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.5 +WHERE cost_name="disk_temptable_row_cost"; +UPDATE mysql.engine_cost +SET cost_value=0.25 +WHERE cost_name="memory_block_read_cost"; +UPDATE mysql.engine_cost +SET cost_value=1.0 +WHERE cost_name="io_block_read_cost"; +UPDATE mysql.server_cost +SET cost_value = 2 * cost_value; +UPDATE mysql.engine_cost +SET cost_value = 2 * cost_value; +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost 40 +disk_temptable_row_cost 1 +key_compare_cost 0.1 +memory_temptable_create_cost 2 +memory_temptable_row_cost 0.2 +row_evaluate_cost 0.2 +SELECT cost_name, cost_value FROM mysql.engine_cost; +cost_name cost_value +io_block_read_cost 2 +memory_block_read_cost 0.5 +FLUSH OPTIMIZER_COSTS; +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i2 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.80", + "prefix_cost": "1.80", + "data_read_per_join": "64" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1", + "i2" + ], + "key_length": "10", + "ref": [ + "const", + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.80", + "prefix_cost": "1.80", + "data_read_per_join": "64" + }, + "used_columns": [ + "i1", + "i2", + "i3" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i2` = 1) and (`test`.`t1`.`i1` = 1)) +EXPLAIN FORMAT=JSON SELECT i3 FROM t1 WHERE i1 = 1 AND i3 = 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.08", + "prefix_cost": "1.80", + "data_read_per_join": "6" + }, + "used_columns": [ + "i3" + ], + "query_block": { + "cost_info": { + "query_cost": "1.80" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "i1" + ], + "key": "i1", + "used_key_parts": [ + "i1" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 4, + "rows_produced_per_join": 0, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.00", + "eval_cost": "0.08", + "prefix_cost": "1.80", + "data_read_per_join": "6" + }, + "used_columns": [ + "i1", + "i3" + ], + "attached_condition": "(`test`.`t1`.`i3` = 1)" + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i3` AS `i3` from `test`.`t1` where ((`test`.`t1`.`i3` = 1) and (`test`.`t1`.`i1` = 1)) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +FLUSH OPTIMIZER_COSTS; +DROP TABLE t1; +# +# Bug#20947871 INDEX SCAN COST IN TEST_IF_CHEAPER_ORDERING() DOES +# NOT USE COST CONSTANTS +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER, +b INTEGER, +c CHAR(255), +UNIQUE KEY k1 (a) +); +INSERT INTO t1 VALUES (1, 1, NULL, "Abc"), (2, 2, NULL, "Abc"), +(3, 3, NULL, "Abc"), (4, 4, NULL, "Abc"); +INSERT INTO t1 SELECT a + 4, a + 4, b, c FROM t1; +INSERT INTO t1 SELECT a + 8, a + 8, b, c FROM t1; +INSERT INTO t1 SELECT a + 16, a + 16, b, c FROM t1; +INSERT INTO t1 SELECT a + 32, a + 32, b, c FROM t1; +INSERT INTO t1 SELECT a + 64, a + 64, b, c FROM t1; +INSERT INTO t1 SELECT a + 128, a + 128, b, c FROM t1; +CREATE TABLE t2 ( +d INTEGER PRIMARY KEY, +e INTEGER +); +INSERT INTO t2 SELECT a, b FROM t1; +# Query should be optimized for the LIMIT. Query plan should +# use index without filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t2 ON b=d ORDER BY a LIMIT 4; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "116.95" + }, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "1.75", + "eval_cost": "25.60", + "prefix_cost": "27.35", + "data_read_per_join": "262K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c", + "d", + "e" + ], + "ordering_operation": { + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "key": "k1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.75", + "eval_cost": "25.60", + "prefix_cost": "27.35", + "data_read_per_join": "260K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c" + ], + "attached_condition": "(`test`.`t1`.`b` is not null)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "d" + ], + "key_length": "4", + "ref": [ + "test.t1.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "64.00", + "eval_cost": "25.60", + "prefix_cost": "116.95", + "data_read_per_join": "4K" + }, + "used_columns": [ + "d", + "e" + ] + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`e` AS `e` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`d` = `test`.`t1`.`b`) order by `test`.`t1`.`a` limit 4 +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="row_evaluate_cost"; +UPDATE mysql.server_cost +SET cost_value=0.05 +WHERE cost_name="key_compare_cost"; +UPDATE mysql.server_cost +SET cost_value=1.0 +WHERE cost_name="memory_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="memory_temptable_row_cost"; +UPDATE mysql.server_cost +SET cost_value=20 +WHERE cost_name="disk_temptable_create_cost"; +UPDATE mysql.server_cost +SET cost_value=0.5 +WHERE cost_name="disk_temptable_row_cost"; +UPDATE mysql.engine_cost +SET cost_value=0.25 +WHERE cost_name="memory_block_read_cost"; +UPDATE mysql.engine_cost +SET cost_value=1.0 +WHERE cost_name="io_block_read_cost"; +UPDATE mysql.server_cost +SET cost_value = 0.5 * cost_value; +UPDATE mysql.engine_cost +SET cost_value = 0.5 * cost_value; +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost 10 +disk_temptable_row_cost 0.25 +key_compare_cost 0.025 +memory_temptable_create_cost 0.5 +memory_temptable_row_cost 0.05 +row_evaluate_cost 0.05 +SELECT cost_name, cost_value FROM mysql.engine_cost; +cost_name cost_value +io_block_read_cost 0.5 +memory_block_read_cost 0.125 +FLUSH OPTIMIZER_COSTS; +# This should be optimized for the LIMIT. Query plan should +# use index without filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t2 ON b=d ORDER BY a LIMIT 4; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "58.47" + }, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.88", + "eval_cost": "12.80", + "prefix_cost": "13.68", + "data_read_per_join": "262K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c", + "d", + "e" + ], + "ordering_operation": { + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "key": "k1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.88", + "eval_cost": "12.80", + "prefix_cost": "13.68", + "data_read_per_join": "260K" + }, + "used_columns": [ + "pk", + "a", + "b", + "c" + ], + "attached_condition": "(`test`.`t1`.`b` is not null)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "d" + ], + "key_length": "4", + "ref": [ + "test.t1.b" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 256, + "filtered": "100.00", + "cost_info": { + "read_cost": "32.00", + "eval_cost": "12.80", + "prefix_cost": "58.48", + "data_read_per_join": "4K" + }, + "used_columns": [ + "d", + "e" + ] + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`e` AS `e` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`d` = `test`.`t1`.`b`) order by `test`.`t1`.`a` limit 4 +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +FLUSH OPTIMIZER_COSTS; +DROP TABLE t1, t2; diff --git a/mysql-test/r/opt_costmodel_flush.result-pq b/mysql-test/r/opt_costmodel_flush.result-pq new file mode 100644 index 000000000..94b25b9f2 --- /dev/null +++ b/mysql-test/r/opt_costmodel_flush.result-pq @@ -0,0 +1,1163 @@ +CREATE TABLE t0 ( +i1 INTEGER +); +INSERT INTO t0 VALUE (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +c1 CHAR(250), +c2 CHAR(250), +c3 CHAR(250), +c4 CHAR(250), +INDEX i1_key (i1) +) ENGINE=InnoDB; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +INSERT INTO t1 +SELECT a0.i1 + 10 * a1.i1, a0.i1, 'abc', 'def', 'ghi', 'jkl' +FROM t0 AS a0, t0 AS a1 ORDER BY a0.i1, a1.i1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +# +# Test that updating the cost constants does not influence on an +# existing connection +# +UPDATE mysql.server_cost +SET cost_value=0.4 +WHERE cost_name="row_evaluate_cost"; +FLUSH OPTIMIZER_COSTS; +# +# The cost estimates should not have changed +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "40.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing the row_evalute_cost +# +UPDATE mysql.server_cost +SET cost_value=0.2 +WHERE cost_name="row_evaluate_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for evalution cost has doubled +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "20.00", + "prefix_cost": "22.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "22.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "20.00", + "prefix_cost": "22.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing key_compare_cost +# +# Use a query that will use loose index scan since loose index scan +# is comparing keys in order to determine group boundaries. +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT DISTINCT(i1) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.00" + }, + "duplicates_removal": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index_for_group_by": true, + "cost_info": { + "read_cost": "1.90", + "eval_cost": "1.10", + "prefix_cost": "3.00", + "data_read_per_join": "43K" + }, + "used_columns": [ + "pk", + "i1" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`i1` AS `i1` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=0.1 +WHERE cost_name="key_compare_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for read cost is increased +# +EXPLAIN FORMAT=JSON SELECT DISTINCT(i1) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.55" + }, + "duplicates_removal": { + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index_for_group_by": true, + "cost_info": { + "read_cost": "2.45", + "eval_cost": "1.10", + "prefix_cost": "3.55", + "data_read_per_join": "43K" + }, + "used_columns": [ + "pk", + "i1" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`i1` AS `i1` from `test`.`t1` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing memory_temptable_create_cost +# +# Use a query that creates a temporary table for a subquery. +# Run query with default cost constants. +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "46.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=10.0 +WHERE cost_name="memory_temptable_create_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for the query is incrased (by 9.0) +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "55.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing memory_temptable_row_cost +# +# Use a query that creates a temporary table for a subquery. +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "46.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=0.2 +WHERE cost_name="memory_temptable_row_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for the query is incrased by: +# 100 rows that needs to be inserted and read from the temporary table. +# The cost of each insert and read is increased by 0.1, ie cost should +# be increased by 100 * 2 * 0.1 = 20. +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE i1 IN (SELECT i1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "66.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "i1_key" + ], + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "4", + "ref": [ + "test.t1.i1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "i1_key" + ], + "key": "i1_key", + "used_key_parts": [ + "i1" + ], + "key_length": "4", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "i1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`i1` = `test`.`t1`.`i1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +set global internal_tmp_mem_storage_engine='memory'; +set session internal_tmp_mem_storage_engine='memory'; +set @max_heap_table_size_save= @@max_heap_table_size; +set max_heap_table_size= 16384; +# +# Test effect of changing disk_temptable_create_cost +# +# Use a query that creates a temporary table for a subquery. +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "145.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=40.0 +WHERE cost_name="disk_temptable_create_cost"; +FLUSH OPTIMIZER_COSTS; +set max_heap_table_size= 16384; +# +# Verify that the cost estimate for the query is incrased (by 20.0) +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "165.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +# +# Test effect of changing disk_temptable_row_cost +# +# Use a query that creates a temporary table for a subquery +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "145.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=1.0 +WHERE cost_name="disk_temptable_row_cost"; +FLUSH OPTIMIZER_COSTS; +set max_heap_table_size= 16384; +# +# Verify that the cost estimate for the query is incrased by: +# 100 rows that needs to be inserted and read from the temporary table. +# The cost of each insert and read is increased by 0.5, ie cost should +# be increased by 100 * 2 * 0.5 = 100. +# +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE c1 IN (SELECT c1 FROM t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "245.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "attached_condition": "(`test`.`t1`.`c1` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "1001", + "ref": [ + "test.t1.c1" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "c1" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` semi join (`test`.`t1`) where (``.`c1` = `test`.`t1`.`c1`) +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +set max_heap_table_size= @max_heap_table_size_save; +set session internal_tmp_mem_storage_engine=default; +set global internal_tmp_mem_storage_engine=default; +# +# Test effect of changing the memory_block_read_cost +# +# Result from running query with default cost constants: +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.engine_cost +SET cost_value=0.5 +WHERE cost_name="memory_block_read_cost"; +FLUSH OPTIMIZER_COSTS; +# +# Verify that the cost estimate for read cost has doubled +# +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "15.50" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "10.00", + "prefix_cost": "15.50", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "15.50" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "10.00", + "prefix_cost": "15.50", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +FLUSH OPTIMIZER_COSTS; +DROP TABLE t0,t1; diff --git a/mysql-test/r/opt_costmodel_restart.result-pq b/mysql-test/r/opt_costmodel_restart.result-pq new file mode 100644 index 000000000..e45c6c029 --- /dev/null +++ b/mysql-test/r/opt_costmodel_restart.result-pq @@ -0,0 +1,276 @@ +SELECT cost_name,cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost NULL +disk_temptable_row_cost NULL +key_compare_cost NULL +memory_temptable_create_cost NULL +memory_temptable_row_cost NULL +row_evaluate_cost NULL +SELECT engine_name,cost_name,cost_value FROM mysql.engine_cost; +engine_name cost_name cost_value +default io_block_read_cost NULL +default memory_block_read_cost NULL +CREATE TABLE t0 ( +i1 INTEGER +); +INSERT INTO t0 VALUE (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1_innodb ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +c1 CHAR(250), +c2 CHAR(250), +c3 CHAR(250), +c4 CHAR(250), +INDEX i1_key (i1) +) ENGINE=InnoDB; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +INSERT INTO t1_innodb +SELECT a0.i1 + 10 * a1.i1, a0.i1, 'abc', 'def', 'ghi', 'jkl' +FROM t0 AS a0, t0 AS a1 ORDER BY a0.i1, a1.i1; +ANALYZE TABLE t1_innodb; +Table Op Msg_type Msg_text +test.t1_innodb analyze status OK +"Explain with cost estimate against InnoDB" +EXPLAIN FORMAT=JSON SELECT * FROM t1_innodb; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "12.75" + }, + "table": { + "select_id": 2, + "table_name": "t1_innodb", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.75", + "eval_cost": "10.00", + "prefix_cost": "12.75", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1_innodb`.`pk` AS `pk`,`test`.`t1_innodb`.`i1` AS `i1`,`test`.`t1_innodb`.`c1` AS `c1`,`test`.`t1_innodb`.`c2` AS `c2`,`test`.`t1_innodb`.`c3` AS `c3`,`test`.`t1_innodb`.`c4` AS `c4` from `test`.`t1_innodb` +UPDATE mysql.server_cost +SET cost_value=0.4 +WHERE cost_name="row_evaluate_cost"; +UPDATE mysql.engine_cost +SET cost_value=2.0 +WHERE cost_name="memory_block_read_cost"; +UPDATE mysql.engine_cost +SET cost_value=2.0 +WHERE cost_name="io_block_read_cost"; +"Restarting MySQL server" +# restart +"MySQL restarted" +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost NULL +disk_temptable_row_cost NULL +key_compare_cost NULL +memory_temptable_create_cost NULL +memory_temptable_row_cost NULL +row_evaluate_cost 0.4 +SELECT engine_name, cost_name, cost_value FROM mysql.engine_cost; +engine_name cost_name cost_value +default io_block_read_cost 2 +default memory_block_read_cost 2 +"Explain with cost estimate against MyISAM" +EXPLAIN FORMAT=JSON SELECT * FROM t1_innodb; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "22.00", + "eval_cost": "40.00", + "prefix_cost": "62.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "62.00" + }, + "table": { + "select_id": 2, + "table_name": "t1_innodb", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "22.00", + "eval_cost": "40.00", + "prefix_cost": "62.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1_innodb`.`pk` AS `pk`,`test`.`t1_innodb`.`i1` AS `i1`,`test`.`t1_innodb`.`c1` AS `c1`,`test`.`t1_innodb`.`c2` AS `c2`,`test`.`t1_innodb`.`c3` AS `c3`,`test`.`t1_innodb`.`c4` AS `c4` from `test`.`t1_innodb` +UPDATE mysql.server_cost +SET cost_value=DEFAULT; +UPDATE mysql.engine_cost +SET cost_value=DEFAULT; +INSERT INTO mysql.engine_cost VALUES +("InnoDB", 0, "memory_block_read_cost", 4.0, CURRENT_TIMESTAMP, DEFAULT, DEFAULT); +INSERT INTO mysql.engine_cost VALUES +("InnoDB", 0, "io_block_read_cost", 4.0, CURRENT_TIMESTAMP, DEFAULT, DEFAULT); +"Restarting MySQL server" +# restart +"MySQL restarted" +SELECT cost_name, cost_value FROM mysql.server_cost; +cost_name cost_value +disk_temptable_create_cost NULL +disk_temptable_row_cost NULL +key_compare_cost NULL +memory_temptable_create_cost NULL +memory_temptable_row_cost NULL +row_evaluate_cost NULL +SELECT engine_name, cost_name, cost_value FROM mysql.engine_cost; +engine_name cost_name cost_value +default io_block_read_cost NULL +InnoDB io_block_read_cost 4 +default memory_block_read_cost NULL +InnoDB memory_block_read_cost 4 +"Explain with cost estimate against InnoDB" +EXPLAIN FORMAT=JSON SELECT * FROM t1_innodb; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "54.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "44.00", + "eval_cost": "10.00", + "prefix_cost": "54.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ], + "query_block": { + "cost_info": { + "query_cost": "54.00" + }, + "table": { + "select_id": 2, + "table_name": "t1_innodb", + "access_type": "ALL", + "rows_examined_per_scan": 100, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "44.00", + "eval_cost": "10.00", + "prefix_cost": "54.00", + "data_read_per_join": "392K" + }, + "used_columns": [ + "pk", + "i1", + "c1", + "c2", + "c3", + "c4" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1_innodb`.`pk` AS `pk`,`test`.`t1_innodb`.`i1` AS `i1`,`test`.`t1_innodb`.`c1` AS `c1`,`test`.`t1_innodb`.`c2` AS `c2`,`test`.`t1_innodb`.`c3` AS `c3`,`test`.`t1_innodb`.`c4` AS `c4` from `test`.`t1_innodb` +DELETE FROM mysql.engine_cost +WHERE engine_name NOT LIKE "default"; +"Restarting MySQL server" +# restart +DROP TABLE t0, t1_innodb; diff --git a/mysql-test/r/opt_hint_timeout.result-pq b/mysql-test/r/opt_hint_timeout.result-pq new file mode 100644 index 000000000..98d1d117b --- /dev/null +++ b/mysql-test/r/opt_hint_timeout.result-pq @@ -0,0 +1,74 @@ +# WL#8017 Infrastructure for Optimizer Hints +# MAX_EXECUTION_TIME hint testing +# MAX_EXECUTION_TIME hint testing +CREATE TABLE t1 (a INT, b VARCHAR(300)); +INSERT INTO t1 VALUES (1, 'string'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SELECT /*+ MAX_EXECUTION_TIME(1) */ * FROM t1 a, t1 b; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +EXPLAIN SELECT /*+ MAX_EXECUTION_TIME(10) MAX_EXECUTION_TIME(100) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2048 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2048 100.00 NULL +Warnings: +Warning 3126 Hint MAX_EXECUTION_TIME(100) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ MAX_EXECUTION_TIME(10) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +DROP TABLE t1; + +# test the MAX_EXECUTION_TIME hint for SELECT statements: + +CREATE TABLE t1 (i INT, j INT); +CREATE INDEX i1 ON t1(i); +CREATE INDEX i2 ON t1(j); +INSERT INTO t1 VALUES (1, 1), (2, 2); +SELECT /*+ MAX_EXECUTION_TIME(4294967296) */ 1 FROM t1; +1 +1 +1 +Warnings: +Warning 1064 Unsupported MAX_EXECUTION_TIME near ') */ 1 FROM t1' at line 1 +SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1 UNION SELECT 1, 2, 3; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +(SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1) UNION (SELECT 1, 2, 3); +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +((SELECT /*+ MAX_EXECUTION_TIME(1) */ *, SLEEP(1000) FROM t1)); +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded + +# only SELECT statements supports the MAX_EXECUTION_TIME hint (warning): + +CREATE TABLE t2 (i INT); +INSERT /*+ MAX_EXECUTION_TIME(1) */ INTO t2 SELECT 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +REPLACE /*+ MAX_EXECUTION_TIME(1) */ INTO t2 SELECT 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +UPDATE /*+ MAX_EXECUTION_TIME(1) */ t2 SET i = 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +DELETE /*+ MAX_EXECUTION_TIME(1) */ FROM t2 WHERE i = 1; +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +DROP TABLE t1, t2; +SELECT 1 FROM (SELECT /*+ MAX_EXECUTION_TIME(10) */ 1) a; +1 +1 +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +CREATE FUNCTION f1() RETURNS INT BEGIN SELECT /*+ MAX_EXECUTION_TIME(10) */ 1 +INTO @a; RETURN 1; END| +Warnings: +Warning 3125 MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only +DROP FUNCTION f1; diff --git a/mysql-test/r/opt_hints.result-pq b/mysql-test/r/opt_hints.result-pq new file mode 100644 index 000000000..eae45cc0e --- /dev/null +++ b/mysql-test/r/opt_hints.result-pq @@ -0,0 +1,2300 @@ +# WL#8017 Infrastructure for Optimizer Hints +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES +(1,1),(2,2),(3,3); +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, f3 CHAR(200), KEY(f1, f2)); +INSERT INTO t2 VALUES +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'), +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'); +CREATE TABLE t3 (f1 INT NOT NULL, f2 INT, f3 VARCHAR(32), +PRIMARY KEY(f1), KEY f2_idx(f1), KEY f3_idx(f3)); +INSERT INTO t3 VALUES +(1, 1, 'qwerty'), (2, 1, 'ytrewq'), +(3, 2, 'uiop'), (4, 2, 'poiu'), (5, 2, 'lkjh'), +(6, 2, 'uiop'), (7, 2, 'poiu'), (8, 2, 'lkjh'), +(9, 2, 'uiop'), (10, 2, 'poiu'), (11, 2, 'lkjh'), +(12, 2, 'uiop'), (13, 2, 'poiu'), (14, 2, 'lkjh'); +INSERT INTO t3 SELECT f1 + 20, f2, f3 FROM t3; +INSERT INTO t3 SELECT f1 + 40, f2, f3 FROM t3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +# NO_RANGE_OPTIMIZATION hint testing +set optimizer_switch=default; +# Check statistics with no hint +FLUSH STATUS; +SELECT f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +f1 +31 +32 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ NO_RANGE_OPTIMIZATION(t3) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +f1 +31 +32 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 57 +EXPLAIN SELECT f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f2_idx 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for PRIMARY key +# Should use range access by f2_idx key +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f2_idx 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for PRIMARY & f2_idx keys +# Should use skip scan for f3_idx index +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY, f2_idx) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 6 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `f2_idx`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for all keys +# Should use index access +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 56 11.11 Parallel execute (1 workers) +2 SIMPLE t3 NULL index PRIMARY,f2_idx f2_idx 4 NULL 56 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# Turn off range access for PRIMARY & f2_idx keys +# Should use index access +EXPLAIN SELECT /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY) NO_RANGE_OPTIMIZATION(t3 f2_idx) */ f1 FROM t3 WHERE f1 > 30 AND f1 < 33; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 6 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `f2_idx`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33)) +# NO_ICP hint testing +set optimizer_switch='index_condition_pushdown=on'; +EXPLAIN SELECT f2 FROM +(SELECT f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +EXPLAIN SELECT /*+ NO_ICP(t3@qb1 f3_idx) */ f2 FROM +(SELECT /*+ QB_NAME(QB1) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`QB1` `f3_idx`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +EXPLAIN SELECT /*+ NO_ICP(t3@qb1) */ f2 FROM +(SELECT /*+ QB_NAME(QB1) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`QB1`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +# Expected warning for f1_idx key, unresolved name. +EXPLAIN SELECT f2 FROM +(SELECT /*+ NO_ICP(t3 f3_idx, f1_idx, f2_idx) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using where +Warnings: +Warning 3128 Unresolved name `t3`@`select#2` `f1_idx` for NO_ICP hint +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`select#2` `f3_idx`) NO_ICP(`t3`@`select#2` `f2_idx`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +# ICP should still be used. +EXPLAIN SELECT f2 FROM +(SELECT /*+ NO_ICP(t3 f1_idx, f2_idx) */ f2, f3, f1 FROM t3 WHERE f1 > 27 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 27 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 10 100.00 Using index condition +Warnings: +Warning 3128 Unresolved name `t3`@`select#2` `f1_idx` for NO_ICP hint +Note 1003 /* select#1 */ select /*+ NO_ICP(`t3`@`select#2` `f2_idx`) */ `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 27) and (`test`.`t3`.`f1` > 27)) +# BKA & NO_BKA hint testing +set optimizer_switch=default; +set optimizer_switch='batched_key_access=off,mrr_cost_based=off'; +# Check statistics without hint +FLUSH STATUS; +SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 4 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +1 1 qwerty +2 2 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t1, t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ QB_NAME(QB1) BKA(t2@QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`QB1`) BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='batched_key_access=off,mrr_cost_based=on'; +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ BKA(t1, t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ QB_NAME(QB1) BKA(t2@QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`QB1`) BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='mrr=off'; +EXPLAIN SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# MRR switch should not affect BKA. +# BKA should be used for table t2. +EXPLAIN SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +set optimizer_switch='mrr=on'; +EXPLAIN SELECT /*+ NO_BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ NO_BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ NO_BKA(t1, t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t1`@`select#1`) NO_BKA(`t2`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN SELECT /*+ QB_NAME(QB1) NO_BKA(t2@QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`QB1`) NO_BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# UPDATE|DELETE|INSERT|REPLACE hint testing +set optimizer_switch='batched_key_access=off,mrr_cost_based=off,semijoin=off,materialization=off'; +EXPLAIN UPDATE t3 +SET f3 = 'mnbv' WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL range PRIMARY,f2_idx PRIMARY 4 const 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`f3` = 'mnbv' where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +# Turn off range access for PRIMARY key. +# Range access should be used for f2_idx key. +EXPLAIN UPDATE /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY) */ t3 +SET f3 = 'mnbv' WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT /*+ BKA(t2) NO_BNL(t1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL range f2_idx f2_idx 4 const 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 update /*+ BKA(`t2`@`select#2`) NO_BNL(`t1`@`select#2`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) */ `test`.`t3` set `test`.`t3`.`f3` = 'mnbv' where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +EXPLAIN DELETE FROM t3 +WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t3 NULL range PRIMARY,f2_idx PRIMARY 4 const 2 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 delete from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +# Turn off range access. Range access should not be used. +# Turn off BNL. BNL should not be used. +EXPLAIN DELETE /*+ NO_RANGE_OPTIMIZATION(t3 PRIMARY, f2_idx) NO_BNL(t1@QB1) */ FROM t3 +WHERE f1 > 30 AND f1 < 33 AND (t3.f1, t3.f2, t3.f3) IN +(SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t3 NULL ALL NULL NULL NULL NULL 56 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref f1 f1 8 func,func 2 10.00 Using index condition; Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 delete /*+ NO_BNL(`t1`@`qb1`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `PRIMARY`) NO_RANGE_OPTIMIZATION(`t3`@`select#1` `f2_idx`) */ from `test`.`t3` where ((`test`.`t3`.`f1` > 30) and (`test`.`t3`.`f1` < 33) and ((`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`),(/* select#2 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1`,`test`.`t2`.`f2`,`test`.`t2`.`f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f1`) and (`test`.`t2`.`f2` between `test`.`t2`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t2`.`f1` + 1)) and ((`test`.`t3`.`f1`) = `test`.`t2`.`f1`) and ((`test`.`t3`.`f2`) = `test`.`t2`.`f2`) and ((`test`.`t3`.`f3`) = `test`.`t2`.`f3`))))) +EXPLAIN INSERT INTO t3(f1, f2, f3) +(SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 insert into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN INSERT INTO t3(f1, f2, f3) +(SELECT /*+ NO_ICP(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 insert /*+ NO_ICP(`t2`@`select#1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN INSERT /*+ NO_ICP(t2@QB1 f1) */ INTO t3(f1, f2, f3) +(SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 insert /*+ NO_ICP(`t2`@`qb1` `f1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +EXPLAIN REPLACE INTO t3(f1, f2, f3) +(SELECT t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Note 1003 replace into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN REPLACE INTO t3(f1, f2, f3) +(SELECT /*+ NO_ICP(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 replace /*+ NO_ICP(`t2`@`select#1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP for nonexistent table. ICP should be used. +EXPLAIN REPLACE /*+ NO_ICP(t2@qb1) */ INTO t3(f1, f2, f3) +SELECT /*+ QB_NAME(qb2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Warning 3127 Query block name `qb1` is not found for NO_ICP hint +Note 1003 replace into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select /*+ QB_NAME(`qb2`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Turn off ICP. ICP should not be used. +EXPLAIN REPLACE /*+ NO_ICP(t2@qb1) */ INTO t3(f1, f2, f3) +SELECT /*+ QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t3 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using where +Warnings: +Note 1003 replace /*+ NO_ICP(`t2`@`qb1`) */ into `test`.`t3` (`test`.`t3`.`f1`,`test`.`t3`.`f2`,`test`.`t3`.`f3`) /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Misc tests +# Should issue warning +EXPLAIN SELECT /*+ QB_NAME(qb1) QB_NAME(qb1 ) */ * FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 28 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 28 100.00 NULL +Warnings: +Warning 3126 Hint QB_NAME(`qb1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t2` +# Should issue warning +EXPLAIN SELECT /*+ BKA(@qb1) QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition +Warnings: +Warning 3127 Query block name `qb1` is not found for BKA hint +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Should not crash +PREPARE stmt1 FROM "SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1"; +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +DEALLOCATE PREPARE stmt1; +# Check use of alias +EXPLAIN SELECT tbl2.f1, tbl2.f2, tbl2.f3 FROM t1 tbl1,t2 tbl2 +WHERE tbl1.f1=tbl2.f1 AND tbl2.f2 BETWEEN tbl1.f1 and tbl1.f2 and tbl2.f2 + 1 >= tbl1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tbl1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tbl2 NULL ref f1 f1 4 test.tbl1.f1 7 11.11 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl2`.`f1` AS `f1`,`test`.`tbl2`.`f2` AS `f2`,`test`.`tbl2`.`f3` AS `f3` from `test`.`t1` `tbl1` join `test`.`t2` `tbl2` where ((`test`.`tbl2`.`f1` = `test`.`tbl1`.`f1`) and (`test`.`tbl2`.`f2` between `test`.`tbl1`.`f1` and `test`.`tbl1`.`f2`) and ((`test`.`tbl2`.`f2` + 1) >= (`test`.`tbl1`.`f1` + 1))) +# Turn on BKA for multiple tables. BKA should be used for tbl2. +EXPLAIN SELECT /*+ BKA(tbl1, tbl2) */ tbl2.f1, tbl2.f2, tbl2.f3 FROM t1 tbl1,t2 tbl2 +WHERE tbl1.f1=tbl2.f1 AND tbl2.f2 BETWEEN tbl1.f1 and tbl1.f2 and tbl2.f2 + 1 >= tbl1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tbl1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tbl2 NULL ref f1 f1 4 test.tbl1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`tbl1`@`select#1`) BKA(`tbl2`@`select#1`) */ `test`.`tbl2`.`f1` AS `f1`,`test`.`tbl2`.`f2` AS `f2`,`test`.`tbl2`.`f3` AS `f3` from `test`.`t1` `tbl1` join `test`.`t2` `tbl2` where ((`test`.`tbl2`.`f1` = `test`.`tbl1`.`f1`) and (`test`.`tbl2`.`f2` between `test`.`tbl1`.`f1` and `test`.`tbl1`.`f2`) and ((`test`.`tbl2`.`f2` + 1) >= (`test`.`tbl1`.`f1` + 1))) +# Print warnings for nonexistent names +EXPLAIN +SELECT /*+ BKA(t2) NO_BNL(t1) BKA(t3) NO_RANGE_OPTIMIZATION(t3 idx1) NO_RANGE_OPTIMIZATION(t3) */ +t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND +t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Warning 3128 Unresolved name `t3`@`select#1` for BKA hint +Warning 3128 Unresolved name `t3`@`select#1` for NO_RANGE_OPTIMIZATION hint +Warning 3128 Unresolved name `t3`@`select#1` `idx1` for NO_RANGE_OPTIMIZATION hint +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) NO_BNL(`t1`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Check illegal syntax +EXPLAIN SELECT /*+ BKA(qb1 t3@qb1) */ f2 FROM +(SELECT /*+ QB_NAME(qb1) */ f2, f3, f1 FROM t3 WHERE f1 > 2 AND f3 = 'poiu') AS TD +WHERE TD.f1 > 2 AND TD.f3 = 'poiu'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL range PRIMARY,f2_idx,f3_idx f3_idx 135 NULL 16 100.00 Using index condition; Using MRR +Warnings: +Warning 1064 Optimizer hint syntax error near 't3@qb1) */ f2 FROM +(SELECT /*+ QB_NAME(qb1) */ f2, f3, f1 FROM t3 WHERE f1 > 2 A' at line 1 +Note 1003 /* select#1 */ select `test`.`t3`.`f2` AS `f2` from `test`.`t3` where ((`test`.`t3`.`f3` = 'poiu') and (`test`.`t3`.`f1` > 2) and (`test`.`t3`.`f1` > 2)) +# Check illegal syntax +EXPLAIN SELECT * FROM +(SELECT /*+ QB_NAME(qb1) BKA(@qb1 t1@qb1, t2@qb1, t3) */ t2.f1, t2.f2, t2.f3 FROM t1,t2,t3) tt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 28 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL index NULL f2_idx 4 NULL 56 100.00 Using index; Using join buffer (hash join) +Warnings: +Warning 1064 Optimizer hint syntax error near 'qb1, t2@qb1, t3) */ t2.f1, t2.f2, t2.f3 FROM t1,t2,t3) tt' at line 2 +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` join `test`.`t3` +# Check '@qb_name table_name' syntax. BKA should be used for t2. +EXPLAIN SELECT /*+ BKA(@qb1 t2) */ * FROM (SELECT /*+ QB_NAME(QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1) AS s1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`QB1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2`) and ((`test`.`t2`.`f2` + 1) >= (`test`.`t1`.`f1` + 1))) +# Check that original table name is not recognized if alias is used. +EXPLAIN SELECT * FROM (SELECT /*+ BKA(t2) */ tb2.f1, tb2.f2, tb2.f3 FROM t1 tb1,t2 tb2 +WHERE tb1.f1=tb2.f1 AND tb2.f2 BETWEEN tb1.f1 and tb1.f2 and tb2.f2 + 1 >= tb1.f1 + 1) AS s1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tb1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tb2 NULL ref f1 f1 4 test.tb1.f1 7 11.11 Using index condition +Warnings: +Warning 3128 Unresolved name `t2`@`select#2` for BKA hint +Note 1003 /* select#1 */ select `test`.`tb2`.`f1` AS `f1`,`test`.`tb2`.`f2` AS `f2`,`test`.`tb2`.`f3` AS `f3` from `test`.`t1` `tb1` join `test`.`t2` `tb2` where ((`test`.`tb2`.`f1` = `test`.`tb1`.`f1`) and (`test`.`tb2`.`f2` between `test`.`tb1`.`f1` and `test`.`tb1`.`f2`) and ((`test`.`tb2`.`f2` + 1) >= (`test`.`tb1`.`f1` + 1))) +# Table t2 should use BKA. +EXPLAIN SELECT * FROM (SELECT /*+ BKA(tb2) */ tb2.f1, tb2.f2, tb2.f3 FROM t1 tb1,t2 tb2 +WHERE tb1.f1=tb2.f1 AND tb2.f2 BETWEEN tb1.f1 and tb1.f2 and tb2.f2 + 1 >= tb1.f1 + 1) AS s1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE tb1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE tb2 NULL ref f1 f1 4 test.tb1.f1 7 11.11 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`tb2`@`select#2`) */ `test`.`tb2`.`f1` AS `f1`,`test`.`tb2`.`f2` AS `f2`,`test`.`tb2`.`f3` AS `f3` from `test`.`t1` `tb1` join `test`.`t2` `tb2` where ((`test`.`tb2`.`f1` = `test`.`tb1`.`f1`) and (`test`.`tb2`.`f2` between `test`.`tb1`.`f1` and `test`.`tb1`.`f2`) and ((`test`.`tb2`.`f2` + 1) >= (`test`.`tb1`.`f1` + 1))) +# Check that PS and conventional statements give the same result. +FLUSH STATUS; +SELECT /*+ BKA(@qb1 t2) */ * FROM (SELECT /*+ QB_NAME(QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1) AS s1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +PREPARE stmt1 FROM "SELECT /*+ BKA(@qb1 t2) */ * FROM (SELECT /*+ QB_NAME(QB1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1) AS s1"; +FLUSH STATUS; +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +FLUSH STATUS; +EXECUTE stmt1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 20 +Handler_read_prev 0 +Handler_read_rnd 4 +Handler_read_rnd_next 4 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1, t2, t3; +# BNL & NO_BNL hint testing +set optimizer_switch=default; +set optimizer_switch='block_nested_loop=on'; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,1),(2,2); +CREATE TABLE t3 (a INT, b INT); +INSERT INTO t3 VALUES (1,1),(2,2); +# Check statistics without hint +FLUSH STATUS; +SELECT t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 9 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ NO_BNL() */t1.* FROM t1,t2,t3; +a b +1 1 +1 1 +1 1 +1 1 +2 2 +2 2 +2 2 +2 2 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 7 +Handler_read_key 7 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 21 +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ NO_BNL() */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ NO_BNL(t2, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t2`@`select#1`) NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ NO_BNL(t1, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t1`@`select#1`) NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +set optimizer_switch='block_nested_loop=off'; +EXPLAIN SELECT t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL() */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL(t2, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL(t1, t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t1`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT /*+ BNL(t2) BNL(t3) */t1.* FROM t1,t2,t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` +DROP TABLE t1, t2, t3; +# BNL in subquery +set optimizer_switch = DEFAULT; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INT, INDEX a (a)); +CREATE TABLE t3 (a INT, b INT, INDEX a (a,b)); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10,3), (20,4), (30,5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET optimizer_prune_level = 0; +EXPLAIN SELECT /*+ QB_NAME(q) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL() */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(@`q`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(t1, t2) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t1`@`q`) NO_BNL(`t2`@`q`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(@subq1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(t4@subq1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t3`.`b` = `test`.`t4`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(t3@subq1,t4@subq1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t3`@`subq1`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) NO_BNL(@subq1 t3, t4) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t3`@`subq1`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ QB_NAME(q) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT /*+ QB_NAME(subq1) NO_BNL(t3, t4) */ t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q`) NO_BNL(`t3`@`subq1`) NO_BNL(`t4`@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +SET optimizer_prune_level = DEFAULT; +DROP TABLE t1, t2, t3; +# MRR & NO_MRR hint testing +set optimizer_switch=default; +CREATE TABLE t1 +( +f1 int NOT NULL DEFAULT '0', +f2 int NOT NULL DEFAULT '0', +f3 int NOT NULL DEFAULT '0', +INDEX idx1(f2, f3), INDEX idx2(f3) +); +INSERT INTO t1(f1) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(f2, f3) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch='mrr=on,mrr_cost_based=off'; +# Check statistics without hint +FLUSH STATUS; +SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ NO_MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +EXPLAIN SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn off MRR. MRR should not be used. +EXPLAIN SELECT /*+ NO_MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MRR(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn off MRR. MRR should not be used. +EXPLAIN SELECT /*+ NO_MRR(t1 idx2) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MRR(`t1`@`select#1` `idx2`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn off MRR for unused key. MRR should be used. +EXPLAIN SELECT /*+ NO_MRR(t1 idx1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MRR(`t1`@`select#1` `idx1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +set optimizer_switch='mrr=off,mrr_cost_based=off'; +EXPLAIN SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1 IDX2) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `IDX2`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR for unused key. MRR should not be used. +EXPLAIN SELECT /*+ MRR(t1 idx1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `idx1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +set optimizer_switch='mrr=off,mrr_cost_based=on'; +EXPLAIN SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR. MRR should be used. +EXPLAIN SELECT /*+ MRR(t1 idx2) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `idx2`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +# Turn on MRR for unused key. MRR should not be used. +EXPLAIN SELECT /*+ MRR(t1 IDX1) */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ MRR(`t1`@`select#1` `IDX1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` <= 3) and (3 <= `test`.`t1`.`f3`)) +DROP TABLE t1; +# +# Bug#21205282 CRASH/ASSERTION IN JOIN_CACHE::SET_MATCH_FLAG_IF_NONE WITH NO_BNL HINT +# +CREATE TABLE t(a INT); +INSERT INTO t VALUES (1); +SET optimizer_switch='block_nested_loop=on'; +EXPLAIN SELECT 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t1) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t1`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t2) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t2`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t3) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t4) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join `test`.`t` `t2` on(true) left join (`test`.`t` `t3` left join `test`.`t` `t4` on(true)) on(true) where true +EXPLAIN SELECT /*+ NO_BNL(t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 LEFT JOIN t t4 ON 1) ON 1 WHERE 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) left join `test`.`t` `t4` on(true)) on(true) where true +SELECT /*+ NO_BNL(t4) */ 1 FROM t t1 LEFT JOIN t t2 ON 1 LEFT JOIN (t t3 LEFT JOIN t t4 ON 1) ON 1; +1 +1 +SELECT /*+ NO_BNL(t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 LEFT JOIN t t4 ON 1) ON 1 WHERE 1; +1 +1 +SET optimizer_switch='block_nested_loop=off'; +EXPLAIN SELECT 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t1) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t1`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t2) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t4) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t2, t3) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t3, t4) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +EXPLAIN SELECT /*+ BNL(t2, t3, t4) */ 1 FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON 1 INNER JOIN t t4 ON 1) ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) BNL(`t4`@`select#1`) */ 1 AS `1` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on(true) join `test`.`t` `t4`) on((true)) where true +DROP TABLE t; +CREATE TABLE t(a INT, b INT, KEY k(a)); +INSERT INTO t VALUES (1,1); +EXPLAIN SELECT * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t1) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2, t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) BKA(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT /*+ BKA(t2, t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 USING(a) LEFT JOIN t t4 USING(a)) USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t3 NULL ref k k 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE t4 NULL ref k k 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t2`@`select#1`) BKA(`t3`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) left join `test`.`t` `t4` on((`test`.`t4`.`a` = `test`.`t1`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SET optimizer_switch='block_nested_loop=on,batched_key_access=on,mrr_cost_based=off'; +EXPLAIN SELECT * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t1) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t2) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BNL(t3) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BNL(t4) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t2) NO_BNL(t3) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) NO_BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BNL(t3) NO_BKA(t4) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t3`@`select#1`) NO_BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT /*+ NO_BKA(t2) NO_BNL(t3) NO_BKA(t4) */ * FROM t t1 INNER JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b LEFT JOIN t t4 ON t3.b=t4.b) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref k k 5 test.t1.a 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BKA(`t2`@`select#1`) NO_BNL(`t3`@`select#1`) NO_BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` join `test`.`t` `t2` left join `test`.`t` `t3` on((`test`.`t3`.`b` = `test`.`t2`.`b`)) left join `test`.`t` `t4` on((`test`.`t4`.`b` = `test`.`t3`.`b`)) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SET optimizer_switch='batched_key_access=off'; +EXPLAIN SELECT * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t1) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ NO_BNL(t2) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2, t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t3`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +SET optimizer_switch='block_nested_loop=off'; +EXPLAIN SELECT * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t1) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2, t3) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BKA(t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BKA(`t3`@`select#1`) BKA(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +EXPLAIN SELECT /*+ BNL(t2, t3, t4) */ * FROM t t1 LEFT JOIN (t t2 LEFT JOIN t t3 ON t2.b=t3.b INNER JOIN t t4 ON t3.a=t4.a) ON t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL k NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref k k 5 test.t3.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ BNL(`t2`@`select#1`) BNL(`t3`@`select#1`) BNL(`t4`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t` `t1` left join (`test`.`t` `t2` join `test`.`t` `t3` join `test`.`t` `t4`) on(((`test`.`t4`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`b` = `test`.`t1`.`b`))) where true +DROP TABLE t; +set optimizer_switch=default; +# +# Duplicate hints +# +CREATE TABLE t1 (i INT PRIMARY KEY); +SELECT /*+ BKA() BKA() */ 1; +1 +1 +Warnings: +Warning 3126 Hint BKA( ) is ignored as conflicting/duplicated +SELECT /*+ BKA(t1) BKA(t1) */ * FROM t1; +i +Warnings: +Warning 3126 Hint BKA(`t1` ) is ignored as conflicting/duplicated +SELECT /*+ QB_NAME(q1) BKA(t1@q1) BKA(t1@q1) */ * FROM t1; +i +Warnings: +Warning 3126 Hint BKA(`t1`@`q1` ) is ignored as conflicting/duplicated +SELECT /*+ QB_NAME(q1) NO_ICP(@q1 t1 PRIMARY) NO_ICP(@q1 t1 PRIMARY) */ * FROM t1; +i +Warnings: +Warning 3126 Hint NO_ICP(`t1`@`q1` `PRIMARY` ) is ignored as conflicting/duplicated +DROP TABLE t1; +# +# Bug#21192857 ASSERTION FAILED: KEYINFO_ARRAY.SIZE() == 0, FILE OPT_HINTS.CC:280 +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1(a) SELECT /*+ NO_RANGE_OPTIMIZATION(t1 a)*/ 1 FROM t1; +DROP TABLE t1; +# WL#8016 Parser for optimizer hints +CREATE TABLE t1 (i INT, j INT); +CREATE INDEX i1 ON t1(i); +CREATE INDEX i2 ON t1(j); + +# empty hint comment is ok: + +SELECT /*+*/ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ * ** / // /* */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '* ** / // /* */ 1' at line 1 +SELECT /*+ @ */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '@ */ 1' at line 1 +SELECT /*+ @foo */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '@foo */ 1' at line 1 +SELECT /*+ foo@bar */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'foo@bar */ 1' at line 1 +SELECT /*+ foo @bar */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'foo @bar */ 1' at line 1 +SELECT /*+ `@` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`@` */ 1' at line 1 +SELECT /*+ `@foo` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`@foo` */ 1' at line 1 +SELECT /*+ `foo@bar` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`foo@bar` */ 1' at line 1 +SELECT /*+ `foo @bar` */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`foo @bar` */ 1' at line 1 +SELECT /*+ BKA( @) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ BKA( @) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ BKA(t1 @) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '@) */ 1' at line 1 + +# We don't support "*/" inside quoted identifiers (syntax error): + +SELECT /*+ BKA(`test*/`) */ 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`) */ 1' at line 1 + +# valid hint sequences: + +SELECT /*+ NO_ICP() */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+NO_ICP()*/ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ')*/ 1' at line 1 +SELECT /*+ NO_ICP () */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP ( ) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP() */ 1 UNION SELECT 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1 UNION SELECT 1' at line 1 +(SELECT /*+ NO_ICP() */ 1) UNION (SELECT 1); +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1) UNION (SELECT 1)' at line 1 +((SELECT /* + NO_ICP() */ 1)); +1 +1 +EXPLAIN SELECT /*+ QB_NAME(qb1) */ 1 UNION SELECT /*+ QB_NAME(qb2) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ 1 AS `1` union /* select#2 */ select /*+ QB_NAME(`qb2`) */ 1 AS `1` +EXPLAIN (SELECT /*+ QB_NAME(qb1) */ 1) UNION (SELECT /*+ QB_NAME(qb2) */ 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`qb1`) */ 1 AS `1` union /* select#2 */ select /*+ QB_NAME(`qb2`) */ 1 AS `1` +UPDATE /*+ NO_ICP() */ t1 SET i = 10; +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ t1 SET i = 10' at line 1 +INSERT /*+ NO_ICP() */ INTO t1 VALUES (); +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ INTO t1 VALUES ()' at line 1 +REPLACE /*+ NO_ICP() */ INTO t1 VALUES (); +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ INTO t1 VALUES ()' at line 1 +DELETE /*+ NO_ICP() */ FROM t1 WHERE 1; +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ FROM t1 WHERE 1' at line 1 +SELECT /*+ BKA(t1) */ 1 FROM t1; +1 +SELECT /*+ BKA(a b) */ 1 FROM t1 a, t1 b; +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'b) */ 1 FROM t1 a, t1 b' at line 1 +SELECT /*+ NO_ICP(i1) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `i1`@`select#1` for NO_ICP hint +SELECT /*+ NO_ICP(i1 i2) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `i1`@`select#1` `i2` for NO_ICP hint +SELECT /*+ NO_ICP(@qb ident) */ 1 FROM t1; +1 +Warnings: +Warning 3127 Query block name `qb` is not found for NO_ICP hint +# +# test explainable statements for hint support: +# they should warn with a hint syntax error near "test */" +# +EXPLAIN SELECT /*+ test */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ 1' at line 1 +Note 1003 /* select#1 */ select 1 AS `1` +EXPLAIN INSERT /*+ test */ INTO t1 VALUES (10, 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ INTO t1 VALUES (10, 10)' at line 1 +Note 1003 insert into `test`.`t1` values (10,10) +EXPLAIN REPLACE /*+ test */ INTO t1 VALUES (10, 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 REPLACE t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ INTO t1 VALUES (10, 10)' at line 1 +Note 1003 replace into `test`.`t1` values (10,10) +EXPLAIN UPDATE /*+ test */ t1 SET i = 10 WHERE j = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range i2 i2 5 const 1 100.00 Using where +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ t1 SET i = 10 WHERE j = 10' at line 1 +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 where (`test`.`t1`.`j` = 10) +EXPLAIN DELETE /*+ test */ FROM t1 WHERE i = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range i1 i1 5 const 1 100.00 Using where +Warnings: +Warning 1064 Optimizer hint syntax error near 'test */ FROM t1 WHERE i = 10' at line 1 +Note 1003 delete from `test`.`t1` where (`test`.`t1`.`i` = 10) + +# non-alphabetic and non-ASCII identifiers: + +CREATE INDEX 3rd_index ON t1(i, j); +SELECT /*+ NO_ICP(3rd_index) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `3rd_index`@`select#1` for NO_ICP hint +CREATE INDEX $index ON t1(j, i); +SELECT /*+ NO_ICP($index) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `$index`@`select#1` for NO_ICP hint +CREATE TABLE ` quoted name тест` (i INT); +SELECT /*+ BKA(` quoted name тест`) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name ` quoted name тест`@`select#1` for BKA hint +SELECT /*+ BKA(` quoted name тест`@`select#1`) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name ` quoted name тест`@`select#1` for BKA hint +DROP TABLE ` quoted name тест`; +SET SQL_MODE = 'ANSI_QUOTES'; +CREATE TABLE " quoted name тест" (i INT); +SELECT /*+ BKA(" quoted name тест") */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name " quoted name тест"@"select#1" for BKA hint +SELECT /*+ BKA(" quoted name тест"@"select#1") */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name " quoted name тест"@"select#1" for BKA hint +CREATE TABLE `test1``test2``` (i INT); +SELECT /*+ BKA(`test1``test2```) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name "test1`test2`"@"select#1" for BKA hint +SELECT /*+ BKA("test1""test2""") */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name "test1""test2"""@"select#1" for BKA hint +SET SQL_MODE = ''; +# should warn: +SELECT /*+ BKA(" quoted name тест") */ 1 FROM t1; +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '" quoted name тест") */ 1 FROM t1' at line 1 +DROP TABLE ` quoted name тест`; +DROP TABLE `test1``test2```; +EXPLAIN SELECT /*+ QB_NAME(`*`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`*`) */ 1 AS `1` +EXPLAIN SELECT /*+ QB_NAME(`a*`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`a*`) */ 1 AS `1` +EXPLAIN SELECT /*+ QB_NAME(`*b`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`*b`) */ 1 AS `1` +EXPLAIN SELECT /*+ QB_NAME(`a +b`) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`a +b`) */ 1 AS `1` +# hint syntax error: empty quoted identifier +EXPLAIN SELECT /*+ QB_NAME(``) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1064 Optimizer hint syntax error near '``) */ 1' at line 1 +Note 1003 /* select#1 */ select 1 AS `1` +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +EXPLAIN SELECT /*+ QB_NAME(````) */ 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(````) */ 1 AS `1` +CREATE TABLE tableТ (i INT); +SELECT /*+ BKA(tableТ) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `tableТ`@`select#1` for BKA hint +SELECT /*+ BKA(test@tableТ) */ 1 FROM t1; +1 +Warnings: +Warning 3127 Query block name `tableТ` is not found for BKA hint +DROP TABLE tableТ; +CREATE TABLE таблица (i INT); +SELECT /*+ BKA(`таблица`) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `таблица`@`select#1` for BKA hint +SELECT /*+ BKA(таблица) */ 1 FROM t1; +1 +Warnings: +Warning 3128 Unresolved name `таблица`@`select#1` for BKA hint +SELECT /*+ BKA(test@таблица) */ 1 FROM t1; +1 +Warnings: +Warning 3127 Query block name `таблица` is not found for BKA hint +# broken multibyte char, should warn: +SELECT /*+ NO_ICP(``) */ 1 FROM t1; +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '`?`) */ 1 FROM t1' at line 1 +DROP TABLE таблица; +SET NAMES DEFAULT; + +# derived tables and other subqueries: + +SELECT * FROM (SELECT /*+ DEBUG_HINT3 */ 1) a; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'DEBUG_HINT3 */ 1) a' at line 1 +SELECT (SELECT /*+ DEBUG_HINT3 */ 1); +(SELECT /*+ DEBUG_HINT3 */ 1) +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'DEBUG_HINT3 */ 1)' at line 1 +SELECT 1 FROM DUAL WHERE 1 IN (SELECT /*+ DEBUG_HINT3 */ 1); +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'DEBUG_HINT3 */ 1)' at line 1 + +# invalid hint sequences (should warn): + +SELECT /*+ 10 */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '10 */ 1' at line 1 +SELECT /*+ NO_ICP() */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP(10) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '10) */ 1' at line 1 +SELECT /*+ NO_ICP( */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ NO_ICP) */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1' at line 1 +SELECT /*+ NO_ICP(t1 */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '*/' at line 1 +SELECT /*+ NO_ICP(t1 ( */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '( */ 1' at line 1 +(SELECT 1) UNION (SELECT /*+ NO_ICP() */ 1); +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1)' at line 1 +INSERT INTO t1 VALUES (1, 1), (2, 2); + +# wrong place for hint, so recognize that stuff as a regular commentary: + +SELECT 1 FROM /*+ regular commentary, not a hint! */ t1; +1 +1 +1 +SELECT 1 FROM /*+ #1 */ t1 WHERE /*+ #2 */ 1 /*+ #3 */; +1 +1 +1 +SELECT /*+ NO_ICP() */ 1 +FROM /*+ regular commentary, not a hint! */ t1; +1 +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near ') */ 1 +FROM /*+ regular commentary, not a hint! */ t1' at line 1 +SELECT /*+ NO_ICP(t1) bad_hint */ 1 FROM t1; +1 +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near 'bad_hint */ 1 FROM t1' at line 1 +SELECT /*+ +NO_ICP(@qb ident) +*/ 1 FROM t1; +1 +1 +1 +Warnings: +Warning 3127 Query block name `qb` is not found for NO_ICP hint +SELECT /*+ +? bad syntax +*/ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '? bad syntax +*/ 1' at line 2 +SELECT +/*+ ? bad syntax */ 1; +1 +1 +Warnings: +Warning 1064 Optimizer hint syntax error near '? bad syntax */ 1' at line 2 +DROP TABLE t1; +# +# Bug #21095608: OPTIMIZER HINT PARSER DOESN'T ACCEPT NUMBER-PREFIXED +# QUERY BLOCK NAMES AFTER @ +# +CREATE TABLE t1 (i INT); +EXPLAIN SELECT /*+ QB_NAME(1a) BKA(t1@1a) */ 1 FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`1a`) BKA(`t1`@`1a`) */ 1 AS `1` from `test`.`t1` +DROP TABLE t1; +# +# Bug #21148405: OPTIMIZER HINTS: READ OF FREE MEMORY FOR INVALID HINTS +# +CREATE PROCEDURE p1() +BEGIN +DECLARE cur1 CURSOR FOR SELECT /*+ NO_MRR(q w)*/1; +OPEN cur1; +END| +CALL p1(); +Warnings: +Warning 3128 Unresolved name `q`@`select#1` `w` for NO_MRR hint +CALL p1(); +DROP PROCEDURE p1; +# +# WL#9307 MERGE/NO_MERGE hint for derived table, view +# +create table t1(a int); +explain select * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`dt`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) */ `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +# Also testing that case of letters is irrelevant. +explain select /*+ no_mERge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) */ `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +create view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +# hint is OVERRIDDEN by algorithm= +create algorithm=merge view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +drop view v1; +create algorithm=temptable view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +# hint OVERRIDES optimizer_switch +set optimizer_switch="derived_merge=off"; +explain select * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +explain select /*+ merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`dt`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(dt) */ * from (select * from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) */ `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +create view v1 as (select * from t1); +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain select /*+ merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`v1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select /*+ no_merge(v1) */ * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +set optimizer_switch=default; +# Can apply to certain derived tables +create table t2(a int, b int); +create table t3 like t2; +explain select /*+ no_merge(dt) merge(dt2) */ * +from (select * from t1) as dt, (select * from t2) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`select#1`) MERGE(`dt2`@`select#1`) */ `dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2` +# Or to all: +explain select /*+ no_merge() */ * +from (select * from t1) as dt, (select * from t2) as dt2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#1`) */ `dt`.`a` AS `a`,`dt2`.`a` AS `a`,`dt2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join (/* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `dt2` +# And be specified in outer blocks, with naming: +explain select /*+ no_merge(dt@qb1) merge(dt2@qb1) */ * from t1 where a = +(select /*+ qb_name(qb1) */ 3 +from (select * from t1) as dt, (select * from t2) as dt2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`qb1`) MERGE(`dt2`@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select /*+ QB_NAME(`qb1`) */ 3 from (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2`)) +# with another syntax: +explain select /*+ no_merge(@qb1 dt) merge(@qb1 dt2) */ * from t1 where a = +(select /*+ qb_name(qb1) */ 3 +from (select * from t1) as dt, (select * from t2) as dt2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`dt`@`qb1`) MERGE(`dt2`@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select /*+ QB_NAME(`qb1`) */ 3 from (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2`)) +# A hint can list more than one table +explain select /*+ merge(dt2) no_merge(dt,dt3) */ * +from (select * from t1) as dt, (select * from t2) as dt2, +(select * from t3) as dt3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +4 DERIVED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ MERGE(`dt2`@`select#1`) NO_MERGE(`dt`@`select#1`) NO_MERGE(`dt3`@`select#1`) */ `dt`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`dt3`.`a` AS `a`,`dt3`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` join `test`.`t2` join (/* select#4 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3`) `dt3` +# Merge hint OVERRIDES heuristics, for example the one which +# materializes when user variables are set. +explain select * from +( +select * from t1 +where (1,a,2) = ( +select @n:=@n+1, t2.a, sum(t2.b) +from (select @n:=1) as dt, t2 +group by t2.a +) +) as dt2 +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 UNCACHEABLE SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 Using temporary +3 UNCACHEABLE SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `dt2`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((1,`test`.`t1`.`a`,2) = (/* select#3 */ select (@n:=((@`n`) + 1)),`test`.`t2`.`a`,sum(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`))) `dt2` +explain select /*+ merge(dt2) */ * from +( +select * from t1 +where (1,a,2) = ( +select @n:=@n+1, t2.a, sum(t2.b) +from (select @n:=1) as dt, t2 +group by t2.a +) +) as dt2 +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 UNCACHEABLE SUBQUERY NULL system NULL NULL NULL NULL 1 100.00 Using temporary +3 UNCACHEABLE SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select /*+ MERGE(`dt2`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where ((1,`test`.`t1`.`a`,2) = (/* select#3 */ select (@n:=((@`n`) + 1)),`test`.`t2`.`a`,sum(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`)) +# ALGORITHM clause overrides heuristics too +create view v1 as select (select t1.a from t1 where t1.a=t2.a) from t2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`(select t1.a from t1 where t1.a=t2.a)` AS `(select t1.a from t1 where t1.a=t2.a)` from `test`.`v1` +drop view v1; +create algorithm=merge view v1 as select (select t1.a from t1 where t1.a=t2.a) from t2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) AS `(select t1.a from t1 where t1.a=t2.a)` from `test`.`t2` +drop view v1; +# Hint for index is useless and should be ignored +select /*+ no_mrr(dt idx1) */ * from (select 1 from t1 limit 1) dt; +1 +Warnings: +Warning 3128 Unresolved name `dt`@`select#1` `idx1` for NO_MRR hint +select /*+ no_mrr(dt idx1) */ * from (select 1 from t1) dt; +1 +Warnings: +Warning 3128 Unresolved name `dt`@`select#1` `idx1` for NO_MRR hint +# Hint for UPDATE +insert into t1 values(1),(2); +create view v1 as +select * from t1 where a <> 0; +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t3` join `test`.`t1` set `test`.`t3`.`a` = (`test`.`t1`.`a` + 10) where (((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) and (`test`.`t1`.`a` <> 0)) +update t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +select * from t3; +a b +11 1 +12 2 +delete from t3; +insert into t3 values(1,1),(2,2); +explain update /*+ no_merge(v1) */ t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`t3` join `test`.`v1` set `test`.`t3`.`a` = (`test`.`v1`.`a` + 10) where ((`test`.`t3`.`a` - `test`.`v1`.`a`) = 0) +update /*+ no_merge(v1) */ t3, v1 set t3.a=v1.a+10 where t3.a-v1.a=0; +select * from t3; +a b +11 1 +12 2 +# Update v1 +delete from t3; +insert into t3 values(1,1),(2,2); +delete from t1; +insert into t1 values(1),(2); +explain update t3, v1 set v1.a=t3.a+10 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t3` join `test`.`t1` set `test`.`t1`.`a` = (`test`.`t3`.`a` + 10) where (((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) and (`test`.`t1`.`a` <> 0)) +update t3, v1 set v1.a=t3.a+10 where t3.a-v1.a=0; +select * from t1; +a +11 +12 +delete from t1; +insert into t1 values(1),(2); +update /*+ no_merge(v1) */ t3, v1 set v1.a=t3.a+10 where t3.a-v1.a=0; +ERROR HY000: The target table v1 of the UPDATE is not updatable +select * from t1; +a +1 +2 +# A derived table in UPDATE +delete from t1; +insert into t1 values(1),(2); +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t3` join `test`.`t1` set `test`.`t3`.`a` = (`test`.`t1`.`a` + 10) where ((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) +update t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +select * from t3; +a b +11 1 +12 2 +delete from t3; +insert into t3 values(1,1),(2,2); +explain update /*+ no_merge(dt) */ t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 update /*+ NO_MERGE(`dt`@`select#1`) */ `test`.`t3` join (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` set `test`.`t3`.`a` = (`dt`.`a` + 10) where ((`test`.`t3`.`a` - `dt`.`a`) = 0) +update /*+ no_merge(dt) */ t3, (select * from t1) dt set t3.a=dt.a+10 where t3.a-dt.a=0; +select * from t3; +a b +11 1 +12 2 +# A derived table in first-level subquery of UPDATE, the update +# target not being in the derived table. Before the WL, the +# derived table would always be materialized; now it's only +# heuristic and can be overridden. +delete from t1; +insert into t1 values(1),(2); +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t3.a 2 100.00 Using index; FirstMatch(t3) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`b` = NULL where (`dt`.`a` = `test`.`t3`.`a`) +update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +select * from t3; +a b +1 1 +2 NULL +delete from t3; +insert into t3 values(1,1),(2,2); +explain update /*+ merge(dt@sub) */ t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 update /*+ MERGE(`dt`@`sub`) */ `test`.`t3` set `test`.`t3`.`b` = NULL where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`a` > 1)) +update /*+ merge(dt@sub) */ t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t1 where a>1) dt); +select * from t3; +a b +1 1 +2 NULL +# A derived table in UPDATE, the update target being in the +# derived table. +delete from t3; +insert into t3 values(1,1),(2,2); +explain update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t3 where b>1) dt); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY NULL ref 5 test.t3.a 2 100.00 FirstMatch(t3) +3 DERIVED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t3` set `test`.`t3`.`b` = NULL where (`dt`.`a` = `test`.`t3`.`a`) +update t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t3 where b>1) dt); +select * from t3; +a b +1 1 +2 NULL +delete from t3; +insert into t3 values(1,1),(2,2); +# The heuristic which materializes, intends to allow the query; +# if you disable it, the query cannot run: +update /*+ merge(dt@sub) */ t3 set b=NULL +where a in (select /*+ qb_name(sub) */ a +from (select * from t3 where b>1) dt); +ERROR HY000: You can't specify target table 't3' for update in FROM clause +select * from t3; +a b +1 1 +2 2 +# DELETE. +delete from t3; +insert into t3 values(1,1),(2,2); +explain delete t3.* from t3, v1 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 DELETE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t3` from `test`.`t3` join `test`.`t1` where (((`test`.`t3`.`a` - `test`.`t1`.`a`) = 0) and (`test`.`t1`.`a` <> 0)) +delete t3.* from t3, v1 where t3.a-v1.a=0; +select * from t3; +a b +delete from t3; +insert into t3 values(1,1),(2,2); +explain delete /*+ no_merge(v1) */ t3.* from t3, v1 where t3.a-v1.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 delete /*+ NO_MERGE(`v1`@`select#1`) */ `test`.`t3` from `test`.`t3` join `test`.`v1` where ((`test`.`t3`.`a` - `test`.`v1`.`a`) = 0) +delete /*+ no_merge(v1) */ t3.* from t3, v1 where t3.a-v1.a=0; +select * from t3; +a b +drop view v1; +drop table t1,t2,t3; +# +# Non-terminated comment test +# +PREPARE stmt FROM 'SELECT /*+ 10'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*+ 10' at line 1 diff --git a/mysql-test/r/opt_hints_index.result-pq b/mysql-test/r/opt_hints_index.result-pq new file mode 100644 index 000000000..9a3d11935 --- /dev/null +++ b/mysql-test/r/opt_hints_index.result-pq @@ -0,0 +1,230 @@ +CREATE TABLE t1 (a INT, b INT, c INT, d INT, +KEY i_a(a), KEY i_b(b), +KEY i_ab(a,b), KEY i_c(c), KEY i_d(d)); +INSERT INTO t1 VALUES +(1,1,1,1),(2,2,2,1),(3,3,3,1),(4,4,4,1), +(5,5,5,1),(6,6,6,1),(7,7,7,1),(8,8,8,1); +INSERT INTO t1 SELECT a,b, c + 10, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 20, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 40, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 80, d FROM t1; +INSERT INTO t1 SELECT a,b, c + 160, d FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ INDEX(t1) JOIN_INDEX(t1) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_b, i_c) INDEX(t1 i_d) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint INDEX(`t1` `i_d`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_b`, `i_c`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) JOIN_INDEX(t1 i_a, i_b) JOIN_INDEX(t1 i_b) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_INDEX(`t1` `i_a`, `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) JOIN_INDEX(`t1`@`select#1` `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) GROUP_INDEX(t1 i_a, i_b) GROUP_INDEX(t1 i_b) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint GROUP_INDEX(`t1` `i_a`, `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) GROUP_INDEX(`t1`@`select#1` `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) GROUP_INDEX(t1) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint GROUP_INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) ORDER_INDEX(t1 i_a, i_b) ORDER_INDEX(t1 i_b) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint ORDER_INDEX(`t1` `i_a`, `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) ORDER_INDEX(`t1`@`select#1` `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a) ORDER_INDEX(t1) */ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint ORDER_INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a, i_b) ORDER_INDEX(t1 i_b) INDEX(t1 i_c)*/ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint ORDER_INDEX(`t1` `i_b`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_c`) ORDER_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a, i_b) GROUP_INDEX(t1 i_b) INDEX(t1)*/ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t1`@`select#1` `i_b`) ORDER_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ ORDER_INDEX(t1) GROUP_INDEX(t1) INDEX(t1)*/ a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Warning 3126 Hint INDEX(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t1`@`select#1`) ORDER_INDEX(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_b) */ a FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i_a,i_b i_a,i_b 5,5 NULL 4 1.25 Using intersect(i_a,i_b); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_b`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_ab) */ a FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_ab i_ab 10 const,const 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_ab`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ INDEX(t1 i_a, i_b) JOIN_INDEX(t1 i_c) */ * FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_b,i_c i_c 5 const 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`, `i_b`) JOIN_INDEX(`t1`@`select#1` `i_c`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ NO_INDEX(t1 i_ab) */ a, max(b) FROM t1 WHERE b = 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_b i_b 5 const 32 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`b` = 2) group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_JOIN_INDEX(t1 i_ab) */ a, max(b) FROM t1 WHERE b = 2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a,i_b,i_ab i_b 5 const 32 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_JOIN_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`b` = 2) group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ GROUP_INDEX(t1 i_ab) */ a, max(b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i_ab i_ab 10 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ JOIN_INDEX(t1 i_ab) */ a, max(b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_ab i_ab 5 NULL 9 100.00 Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` group by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_ORDER_INDEX(t1 i_ab) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ORDER_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_ORDER_INDEX(t1 i_a) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ NO_ORDER_INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_ab) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t1`@`select#1` `i_ab`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a) */ a FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ ORDER_INDEX(t1 i_a) */ * FROM t1 +ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i_a 5 NULL 256 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ NO_INDEX(t1) */ * FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 256 0.39 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 256 0.39 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ * FROM t1 IGNORE INDEX (i_a) +WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i_b,i_ab,i_c i_ab,i_c 10,5 NULL 1 100.00 Using intersect(i_ab,i_c); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` IGNORE INDEX (`i_a`) where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN UPDATE /*+ INDEX(t1 i_a) */ t1 SET d = 1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range i_a i_a 5 const 32 100.00 Using where +Warnings: +Note 1003 update /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1` set `test`.`t1`.`d` = 1 where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +EXPLAIN DELETE /*+ INDEX(t1 i_a) */ FROM t1 WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL range i_a i_a 5 const 32 100.00 Using where +Warnings: +Note 1003 delete /*+ INDEX(`t1`@`select#1` `i_a`) */ from `test`.`t1` where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +CREATE VIEW v1 AS SELECT /*+ NO_INDEX(t1 i_a,i_b) */ a FROM t1 WHERE +b IN (SELECT /*+ NO_INDEX(t1 i_ab,i_b) */ a FROM t1 WHERE a > 3) +ORDER BY a; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ `t1`.`a` AS `a` from `t1` where `t1`.`b` in (select `t1`.`a` from `t1` where (`t1`.`a` > 3)) order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 3)) order by `test`.`t1`.`a` +EXPLAIN SELECT /*+ INDEX(ta i_a) */ ta.a FROM v1, t1 ta WHERE ta.a > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +1 SIMPLE ta NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`ta`@`select#1` `i_a`) */ `test`.`ta`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) join `test`.`t1` `ta` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`ta`.`a` > 3) and (`test`.`t1`.`a` > 3)) +CREATE VIEW v2 AS SELECT /*+ INDEX(ta i_a) */ ta.a FROM v1, t1 ta WHERE ta.a > 3; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select /*+ INDEX(`ta`@`select#1` `i_a`) */ `ta`.`a` AS `a` from (`v1` join `t1` `ta`) where (`ta`.`a` > 3) utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT a FROM v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +1 SIMPLE ta NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `ta`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) join `test`.`t1` `ta` /*+ INDEX(`ta`@`select#1` `i_a`) */ where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`ta`.`a` > 3) and (`test`.`t1`.`a` > 3)) +EXPLAIN SELECT /*+ INDEX(tb i_a) */ tb.a FROM v2, t1 tb WHERE tb.a > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i_a i_a 5 NULL 160 5.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL index NULL i_ab 10 NULL 256 12.50 Using where; Using index; Using join buffer (hash join) +1 SIMPLE ta NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE tb NULL range i_a i_a 5 NULL 160 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`tb`@`select#1` `i_a`) */ `test`.`tb`.`a` AS `a` from `test`.`t1` /*+ NO_INDEX(`t1`@`select#1` `i_a`, `i_b`) */ semi join (`test`.`t1` /*+ NO_INDEX(`t1`@`select#2` `i_ab`, `i_b`) */ ) join `test`.`t1` `ta` /*+ INDEX(`ta`@`select#1` `i_a`) */ join `test`.`t1` `tb` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`tb`.`a` > 3) and (`ta`.`a` > 3) and (`test`.`t1`.`a` > 3)) +EXPLAIN SELECT /*+ INDEX(t1 i_a) */ * FROM t1 IGNORE INDEX(i_a) +WHERE a = 1 AND b = 2 AND c = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 0.39 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i_a i_a 5 const 32 0.39 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX(`t1`@`select#1` `i_a`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` IGNORE INDEX (`i_a`) where ((`test`.`t1`.`c` = 3) and (`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` = 1)) +CREATE VIEW v3 AS SELECT /*+ INDEX_MERGE(t1) */a FROM t1 +WHERE a = 1 AND b = 2 AND c = 3; +DROP VIEW v1, v2, v3; +DROP TABLE t1; diff --git a/mysql-test/r/opt_hints_index_merge.result-pq b/mysql-test/r/opt_hints_index_merge.result-pq new file mode 100644 index 000000000..567f8b657 --- /dev/null +++ b/mysql-test/r/opt_hints_index_merge.result-pq @@ -0,0 +1,560 @@ +CREATE TABLE t1 (f1 INT, f2 INT, f3 CHAR(1), f4 CHAR(1), f5 CHAR(1), f6 CHAR(1), f7 CHAR(1), +PRIMARY KEY (f5, f1), KEY (f2), KEY (f3), KEY (f4), KEY(f7) ); +INSERT INTO t1 VALUES (1, 1, 'a', 'h', 'i', '', ''), (2, 3, 'a', 'h', 'i', '', ''), +(3, 2, 'b', '', 'j', '', ''), (4, 2, 'b', '', 'j', '', ''); +INSERT INTO t1 VALUES (5, 1, 'a', 'h', 'i', '', ''), (6, 3, 'a', 'h', 'i', '', ''), +(7, 2, 'b', '', 'j', '', ''), (8, 2, 'b', '', 'j', '', ''); +INSERT INTO t1 SELECT f1 + 8, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 SELECT f1 + 16, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 VALUES (33, 3, 'c', 'g', '', '', ''), (34, 4, 'c', 'g', '', '', ''), +(35, 5, 'd', 'f', '', '', ''), (36, 6, 'd', 'f', '', '', ''); +INSERT INTO t1 SELECT f1 + 36, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 SELECT f1 + 72, f2, f3, f4, f5, f6, f7 FROM t1; +INSERT INTO t1 SELECT f1 + 144, f2, f3, f4, f5, f6, f7 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f4 f2,f4 5,5 NULL 56 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f3,f4 f3,f4 5,5 NULL 56 100.00 Using intersect(f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT * FROM t1 WHERE f2 BETWEEN 5 AND 6 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 48 100.00 Using sort_union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 32 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 40 100.00 Using union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` `f2`, `f3`, `f4`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) INDEX_MERGE(t1) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) NO_INDEX_MERGE(t1) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3126 Hint NO_INDEX_MERGE(`t1` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1) INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` `f2`, `f3`, `f4`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f4) INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Warning 3126 Hint INDEX_MERGE(`t1` `f2`, `f3`, `f4`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t5) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t5`@`select#1` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f5) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f5` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f6, f5, primary) */ f2 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f6` for INDEX_MERGE hint +Warning 3128 Unresolved name `t1`@`select#1` `f5` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t2 f9, f10) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t2`@`select#1` for INDEX_MERGE hint +Warning 3128 Unresolved name `t2`@`select#1` `f9` for INDEX_MERGE hint +Warning 3128 Unresolved name `t2`@`select#1` `f10` for INDEX_MERGE hint +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f9, f10) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f9` for INDEX_MERGE hint +Warning 3128 Unresolved name `t1`@`select#1` `f10` for INDEX_MERGE hint +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +SET optimizer_switch='index_merge_intersection=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f2) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f4 f2,f4 5,5 NULL 56 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f2`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 56 44.44 Using intersect(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f3 = 'b' AND f5 = 'i'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f3,f4 f3,f4 9,9 NULL 1 100.00 Using intersect(f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f5` = 'i') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 PRIMARY, f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f3 = 'b' AND f5 = 'i'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f3,f4 f3,f4 9,9 NULL 1 100.00 Using intersect(f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `PRIMARY`, `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f5` = 'i') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f3 f3 9 NULL 1 16.67 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, PRIMARY) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,PRIMARY 9,4 NULL 1 16.67 Using intersect(f3,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `PRIMARY`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, PRIMARY) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f2,PRIMARY 9,4 NULL 56 25.00 Using intersect(f2,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `PRIMARY`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4, f5) */ f3 FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Warning 3128 Unresolved name `t1`@`select#1` `f5` for INDEX_MERGE hint +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'd' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f4,f3 5,5 NULL 1 44.44 Using intersect(f4,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'd')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4, f7) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b' AND f7 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f3,f4,f7 5,5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4,f7); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`, `f7`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f7` = '') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'd' AND f2 = 2 AND f3 = 'b' AND f7 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f4,f3 5,5 NULL 1 44.44 Using intersect(f4,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f7` = '') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'd')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = '' AND f2 = 2 AND f3 = 'b' AND f7 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f3 5,5 NULL 56 44.44 Using intersect(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f7` = '') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = '')) +SET optimizer_switch='index_merge=off'; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +SET optimizer_switch='index_merge=on'; +SET optimizer_switch='index_merge_intersection=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 44.44 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f4 f2 5 const 128 44.44 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f4 f2,f4 5,5 NULL 56 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,PRIMARY 9,4 NULL 1 16.67 Using intersect(f3,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 PRIMARY) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f3 f3 9 NULL 1 16.67 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `PRIMARY`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,PRIMARY 9,4 NULL 1 16.67 Using intersect(f3,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ count(*) FROM t1 WHERE f2 = 3 AND f5 > '' AND f3 = 'c'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 64 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f3 f2 9 NULL 64 25.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'c') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 5.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f3 5 const 1 5.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 1 5.00 Using intersect(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f2) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f4,f2 5,5 NULL 1 5.00 Using intersect(f4,f2); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f2`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f2) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f2 5,5 NULL 1 5.00 Using intersect(f3,f2); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f2`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f4, f3) */ COUNT(*) FROM t1 WHERE f4 = 'x' AND f2 = 5 AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 1 5.00 Using intersect(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f4`, `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` = 5) and (`test`.`t1`.`f4` = 'x')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f4 f4 5 const 128 33.33 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f4` = 'h') and (`test`.`t1`.`f2` > 2)) +SET optimizer_switch='index_merge_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 40 100.00 Using union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 53.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 53.12 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f1 = 4 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 24 32.50 Using union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 PRIMARY, f4) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f5 = 'i' OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3,f4 PRIMARY,f4 4,5 NULL 144 37.50 Using union(PRIMARY,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `PRIMARY`, `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f5` = 'i') or (`test`.`t1`.`f4` = 'f'))) +SET optimizer_switch='index_merge_union=on,index_merge=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f3, f4) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 53.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 53.12 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f1 = 4 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 12.19 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 12.19 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c') AND (f1 = 4 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 24 32.50 Using union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT * FROM t1 WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 43.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 1 43.75 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f4) */ * FROM t1 WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f3,f4 5,5 NULL 2 2.50 Using union(f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +SET optimizer_switch='index_merge_sort_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 32 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 32 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Warning 3614 Invalid number of arguments for hint INDEX_MERGE(`t1` `f3`) +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 +WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f') AND f3 = 'n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 32 0.35 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where ((`test`.`t1`.`f3` = 'n') and (`test`.`t1`.`f2` between 5 and 6) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +SET optimizer_switch='index_merge_sort_union=on,index_merge=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f4) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f2, f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f4) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 32 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ * FROM t1 WHERE (f2 BETWEEN 5 AND 6 OR f3 = 'c') AND (f2 BETWEEN 5 AND 6 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 32 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 5 and 6) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT * FROM t1 WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ * FROM t1 WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 288 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 288 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c' OR f4 = 'f') AND (f2 BETWEEN 1 AND 200 OR f3 = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3,f4 5,5,5 NULL 40 100.00 Using union(f2,f3,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE (f2 = 5 OR f3 = 'c' OR f4 = 'f') AND (f2 BETWEEN 1 AND 200 OR f3 = 'c'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 288 100.00 Using sort_union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c'))) +SET optimizer_switch=default; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f4 = 'h' AND f2 = 2 AND f3 = 'b') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f7 5,5 NULL 129 15.62 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ COUNT(*) FROM t1 WHERE (f4 = 'h' AND f2 = 2 AND f3 = 'b') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f7 5,5 NULL 129 15.62 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2,f3,f7) */ COUNT(*) FROM t1 WHERE (f4 = 'h' AND f2 = 2 AND f3 = 'b') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,f7 f2,f3,f7 5,5,5 NULL 57 32.50 Using union(intersect(f2,f3),f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f7`) */ count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT f3 FROM t1 WHERE f4 = 'f' AND f2 = 3 AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f4,PRIMARY 9,4 NULL 1 16.67 Using intersect(f4,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f4` = 'f') and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE f4 = 'f' AND f2 = 3 AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f4,PRIMARY 9,4 NULL 1 16.67 Using intersect(f4,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f4` = 'f') and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT f3 FROM t1 WHERE f2 = 3 AND f4 = 'g' AND f5 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,f4 9,9 NULL 1 100.00 Using intersect(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f5` = '') and (`test`.`t1`.`f4` = 'g') and (`test`.`t1`.`f2` = 3)) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE f2 = 3 AND f4 = 'g' AND f5 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,f4 9,9 NULL 1 100.00 Using intersect(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f5` = '') and (`test`.`t1`.`f4` = 'g') and (`test`.`t1`.`f2` = 3)) +EXPLAIN SELECT f3 FROM t1 WHERE f2 = 3 AND f4 = '' AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 64 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,f2,f4 f2 9 NULL 64 25.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE f2 = 3 AND f4 = '' AND f5 > ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,PRIMARY 9,4 NULL 56 25.00 Using intersect(f2,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where ((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) +EXPLAIN SELECT f3 FROM t1 WHERE (f2 = 3 AND f4 = '' AND f5 > '') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4,f7 f2,f7 9,5 NULL 65 32.50 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f3` AS `f3` from `test`.`t1` where (((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f3 FROM t1 WHERE (f2 = 3 AND f4 = '' AND f5 > '') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4,f7 f2,f7 9,5 NULL 65 32.50 Using union(f2,f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where (((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, PRIMARY, f7) */ f3 FROM t1 WHERE (f2 = 3 AND f4 = '' AND f5 > '') OR (f7 = 'd' AND f6 = 'e'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4,f7 f2,PRIMARY,f7 9,4,5 NULL 57 32.50 Using union(intersect(f2,PRIMARY),f7); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `PRIMARY`, `f7`) */ `test`.`t1`.`f3` AS `f3` from `test`.`t1` where (((`test`.`t1`.`f4` = '') and (`test`.`t1`.`f2` = 3) and (`test`.`t1`.`f5` > '')) or ((`test`.`t1`.`f6` = 'e') and (`test`.`t1`.`f7` = 'd'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f2 FROM t1 WHERE f2 = 2 AND f4 = 'g' AND f5 = ''; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f4 f2,f4 9,9 NULL 1 100.00 Using intersect(f2,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f5` = '') and (`test`.`t1`.`f4` = 'g') and (`test`.`t1`.`f2` = 2)) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f4) */ * FROM t1 IGNORE INDEX (f3) WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 43.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f4 f2 5 const 1 43.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` IGNORE INDEX (`f3`) where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f3, f4) */ * FROM t1 FORCE INDEX (f3) WHERE f2 = 400 AND (f3 = 'x' OR f4 = 'n'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 7.29 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f3 NULL NULL NULL 288 7.29 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` FORCE INDEX (`f3`) where ((`test`.`t1`.`f2` = 400) and ((`test`.`t1`.`f3` = 'x') or (`test`.`t1`.`f4` = 'n'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 IGNORE INDEX (f4) +WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` IGNORE INDEX (`f4`) where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f4) */ * FROM t1 FORCE INDEX (f4) +WHERE (f2 BETWEEN 1 AND 200 OR f3 = 'c') AND (f2 BETWEEN 1 AND 200 OR f4 = 'f'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f4 NULL NULL NULL 288 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6`,`test`.`t1`.`f7` AS `f7` from `test`.`t1` FORCE INDEX (`f4`) where (((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f3` = 'c')) and ((`test`.`t1`.`f2` between 1 and 200) or (`test`.`t1`.`f4` = 'f'))) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 IGNORE INDEX (f2, f3) WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 4.17 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f4 f4 5 const 128 4.17 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` IGNORE INDEX (`f3`) IGNORE INDEX (`f2`) where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 FORCE INDEX (f2, f3) WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3 f2,f3 5,5 NULL 56 25.00 Using intersect(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` FORCE INDEX (`f3`) FORCE INDEX (`f2`) where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 USE INDEX (f2, f3) WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3 f2,f3 5,5 NULL 56 25.00 Using intersect(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` USE INDEX (`f3`) USE INDEX (`f2`) where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +ALTER TABLE t1 ADD KEY idx(f3, f4); +# Original query +EXPLAIN SELECT f2 FROM t1 WHERE f2 = 2 AND f3 = 'b' AND f4 = 'h'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 44.44 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4,idx idx 10 const,const 1 44.44 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f4` = 'h') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2)) +# Index merge intersection(f2, f3, f4) should be used. +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ f2 FROM t1 WHERE f2 = 2 AND f3 = 'b' AND f4 = 'h'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4,idx f2,f3,f4 5,5,5 NULL 25 100.00 Using intersect(f2,f3,f4); Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f2` AS `f2` from `test`.`t1` where ((`test`.`t1`.`f4` = 'h') and (`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2)) +SET optimizer_switch= default; +DROP TABLE t1; +# +# Bug#24788119 GET_BEST_DISJUNCT_QUICK() - MYSQLD GOT SIGNAL 11 +# +CREATE TABLE t1(f1 INT NOT NULL, f2 INT, f3 INT, PRIMARY KEY(f1), KEY(f2), KEY(f3)); +EXPLAIN SELECT /*+ INDEX_MERGE(t1) */ f1 FROM t1 WHERE f1 < 2 AND (f3 = 3 or f2 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,f2,f3 f3,f2 5,5 NULL 1 100.00 Using union(f3,f2); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` < 2) and ((`test`.`t1`.`f3` = 3) or (`test`.`t1`.`f2` = 3))) +DROP TABLE t1; +# +# Bug#24834724 QUICK_ROR_INTERSECT_SELECT::GET_NEXT() - MYSQLD GOT SIGNAL 11 +# +CREATE TABLE t1 ( +f1 VARCHAR(10) DEFAULT NULL, +f2 INT(11) NOT NULL, +f3 INT(11) DEFAULT NULL, +PRIMARY KEY (f2), +KEY f1 (f1), +KEY f3 (f3) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('b',1,NULL), ('h',5,NULL); +SELECT /*+ INDEX_MERGE(t1 f3, primary) */ f2 FROM t1 +WHERE f1 = 'o' AND f2 = f3 AND f3 <= 4; +f2 +DROP TABLE t1; diff --git a/mysql-test/r/opt_hints_join_order.result-pq b/mysql-test/r/opt_hints_join_order.result-pq new file mode 100644 index 000000000..f5cc6ada8 --- /dev/null +++ b/mysql-test/r/opt_hints_join_order.result-pq @@ -0,0 +1,1150 @@ +CREATE TABLE t1 (f1 INT NOT NULL); +INSERT INTO t1 VALUES (9),(0), (7); +CREATE TABLE t2 (f1 INT NOT NULL); +INSERT INTO t2 VALUES +(5),(3),(0),(3),(1),(0),(1),(7),(1),(0),(0),(8),(4),(9),(0),(2),(0),(8),(5),(1); +CREATE TABLE t3 (f1 INT NOT NULL); +INSERT INTO t3 VALUES (9),(0), (7), (4), (5); +CREATE TABLE t4 (f1 INT NOT NULL); +INSERT INTO t4 VALUES (0), (7); +CREATE TABLE t5 (f1 INT NOT NULL, PRIMARY KEY(f1)); +INSERT INTO t5 VALUES (7); +CREATE TABLE t6(f1 INT NOT NULL, PRIMARY KEY(f1)); +INSERT INTO t6 VALUES (7); +ANALYZE TABLE t1, t2, t3, t4, t5, t6; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +SELECT count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +explain SELECT /*+ QB_NAME(q1) JOIN_PREFIX(t3, t2, t2@subq2) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t2) AND +t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t2.f1 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +3 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_PREFIX(@`q1` `t3`,`t2`,`t2`@`subq2`) */ count(0) AS `count(*)` from `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t2`) semi join (`test`.`t2`) where ((``.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +# Second JOIN_PREFIX is conflicting +SELECT /*+ JOIN_PREFIX(t3, t2, t1) JOIN_PREFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +Warnings: +Warning 3126 Hint JOIN_PREFIX( `t2`,`t1`) is ignored as conflicting/duplicated +explain SELECT /*+ JOIN_PREFIX(t3, t2, t1) JOIN_PREFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Warning 3126 Hint JOIN_PREFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t3`,`t2`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +# Second JOIN_SUFFIX is conflicting +SELECT /*+ JOIN_SUFFIX(t3, t2) JOIN_SUFFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +Warnings: +Warning 3126 Hint JOIN_SUFFIX( `t2`,`t1`) is ignored as conflicting/duplicated +explain SELECT /*+ JOIN_SUFFIX(t3, t2) JOIN_SUFFIX(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Warning 3126 Hint JOIN_SUFFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# Both JOIN_ORDERs applicable +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t1, t2, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t1, t2, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) JOIN_ORDER(@`select#1` `t1`,`t2`,`t5`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# Unresoled table name t7 in JOIN_ORDER hint, hint ignored +SELECT /*+ JOIN_ORDER(t1, t7, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +Warnings: +Warning 3128 Unresolved name `t7` for JOIN_ORDER hint +explain SELECT /*+ JOIN_ORDER(t1, t7, t5) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Warning 3128 Unresolved name `t7` for JOIN_ORDER hint +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# All hints are applicable +SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1) JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1) JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`) JOIN_ORDER(@`select#1` `t4`@`subq1`,`t3`) JOIN_SUFFIX(@`select#1` `t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +# Second JOIN_ORDER is silently ignored +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t2, t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_ORDER(t2, t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# JOIN_SUFFIX is silently ignored +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_SUFFIX(t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_SUFFIX(t3) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# JOIN_PREFIX is silently ignored +SELECT /*+ JOIN_ORDER(t3, t2) JOIN_PREFIX(t2) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t3, t2) JOIN_PREFIX(t2) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t2`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# All hints are applicable +SELECT /*+ JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) JOIN_PREFIX(t2, t5@subq2, t4@subq1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t4@subq1, t3) JOIN_SUFFIX(t1) JOIN_PREFIX(t2, t5@subq2, t4@subq1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t4`@`subq1`,`t3`) JOIN_SUFFIX(@`select#1` `t1`) JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_SUFFIX(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_ORDER(t2, t5@subq2, t4@subq1, t3, t1) +JOIN_PREFIX(t2, t5@subq2, t4@subq1, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) JOIN_ORDER(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) JOIN_PREFIX(@`select#1` `t2`,`t5`@`subq2`,`t4`@`subq1`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +# JOIN_ORDER is ignored due to STRAIGHT_JOIN. +SELECT STRAIGHT_JOIN /*+ QB_NAME(q1) JOIN_ORDER(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT STRAIGHT_JOIN /*+ QB_NAME(q1) JOIN_ORDER(t2, t1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +3 SUBQUERY t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t4 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `count(*)` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`f1`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t4`.`f1` from `test`.`t4` where ((`test`.`t1`.`f1`) = `test`.`t4`.`f1`))) and (`test`.`t2`.`f1`,`test`.`t2`.`f1` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`t5`.`f1` from `test`.`t5` where true ), (`test`.`t2`.`f1` in on where ((`test`.`t2`.`f1` = ``.`f1`)))))) +SELECT /*+ QB_NAME(q1) JOIN_FIXED_ORDER(@q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_FIXED_ORDER(@q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +3 SUBQUERY t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t4 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_FIXED_ORDER(@`q1`) */ straight_join count(0) AS `count(*)` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`f1`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t4`.`f1` from `test`.`t4` where ((`test`.`t1`.`f1`) = `test`.`t4`.`f1`))) and (`test`.`t2`.`f1`,`test`.`t2`.`f1` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`t5`.`f1` from `test`.`t5` where true ), (`test`.`t2`.`f1` in on where ((`test`.`t2`.`f1` = ``.`f1`)))))) +SELECT /*+ QB_NAME(q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) */ count(*) FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +SELECT count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# t3 can not be first +SELECT /*+ JOIN_PREFIX(t3, t1) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t3, t1) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index; Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = `test`.`t4`.`f1`)) +# hint is applicable +SELECT /*+ JOIN_PREFIX(t1, t2, t3) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_PREFIX(t1, t2, t3) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`,`t3`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +# hint is applicable +SELECT /*+ JOIN_SUFFIX(t4, t5) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +count(*) +10 +explain SELECT /*+ JOIN_SUFFIX(t4, t5) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3 +WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t4`,`t5`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` straight_join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +SELECT /*+ QB_NAME(q1) JOIN_ORDER(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_ORDER(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_ORDER(@`q1` `t2`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT /*+ QB_NAME(q1) JOIN_PREFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_PREFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t1.f1 1 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_PREFIX(@`q1` `t2`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t5`.`f1` = `test`.`t2`.`f1`) and (``.`f1` = `test`.`t1`.`f1`)) +SELECT /*+ QB_NAME(q1) JOIN_SUFFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +count(*) +10 +explain SELECT /*+ QB_NAME(q1) JOIN_SUFFIX(@q1 t2, t3, t1) */ count(*) +FROM t1 JOIN t2 JOIN t3 +WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t4) +AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t5 NULL index PRIMARY PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ QB_NAME(`q1`) JOIN_SUFFIX(@`q1` `t2`,`t3`,`t1`) */ count(0) AS `count(*)` from `test`.`t5` join `test`.`t1` join `test`.`t2` join `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t2`.`f1` = `test`.`t5`.`f1`) and (`test`.`t1`.`f1` = ``.`f1`)) +DROP TABLE t1, t2, t3, t4 ,t5, t6; +CREATE TABLE t1 (f1 INT); +CREATE TABLE t2 (f1 INT); +CREATE TABLE t3 (f1 INT); +CREATE TABLE t4 (f1 INT); +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t4, t1) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t1, t4) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t1`,`t4`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t4, t1, t2) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t3, t4) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t4`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_ORDER(t4, t3) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t4`,`t3`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_SUFFIX(t1) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t1`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +EXPLAIN SELECT /*+ JOIN_SUFFIX(t2, t1) */ 1 FROM t1 +JOIN t2 ON 1 +RIGHT JOIN t3 ON 1 +JOIN t4 ON 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_SUFFIX(@`select#1` `t2`,`t1`) */ 1 AS `1` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on((true)) join `test`.`t4` where true +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 INT(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 +( +f1 INT(11) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN DELETE +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(ta2) +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Applicable hint +EXPLAIN DELETE /*+ JOIN_PREFIX(t2, t3, ta2) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t2) +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +Warnings: +Note 1003 delete /*+ JOIN_PREFIX(@`select#1` `t2`,`t3`,`ta2`) */ `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Applicable hint +EXPLAIN DELETE /*+ JOIN_PREFIX(t2, t3, ta1, ta2) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t2) +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1003 delete /*+ JOIN_PREFIX(@`select#1` `t2`,`t3`,`ta1`,`ta2`) */ `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Applicable hint +EXPLAIN DELETE /*+ JOIN_PREFIX(t2, t3, ta2, ta1) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t2) +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +Warnings: +Note 1003 delete /*+ JOIN_PREFIX(@`select#1` `t2`,`t3`,`ta2`,`ta1`) */ `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Hint should be ignored +EXPLAIN DELETE /*+ JOIN_SUFFIX(ta2, t3, ta1) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(ta2) +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +# Both hints are ignored +EXPLAIN DELETE /*+ JOIN_PREFIX(ta1, t2, t3) JOIN_SUFFIX(t3, ta2) */ +FROM ta1.* USING t1 AS ta1 JOIN t1 AS ta2 ON 1 +RIGHT OUTER JOIN t2 ON (ta1.f1 = t2.f1) +WHERE (9) IN (SELECT f1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 DELETE ta1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 NULL +1 SIMPLE ta2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(ta2) +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on(((`test`.`ta1`.`f1` = `test`.`t2`.`f1`))) semi join (`test`.`t3`) where (`test`.`t3`.`f1` = 9) +DROP TABLE t1, t2, t3; +CREATE TABLE t1(f1 INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2(f1 INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1); +EXPLAIN SELECT /*+ JOIN_PREFIX(t1, t2) */ 1 FROM t1 JOIN t2 ON t1.f1 = t2.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ 1 AS `1` from `test`.`t2` where (`test`.`t2`.`f1` = '1') +EXPLAIN SELECT /*+ JOIN_PREFIX(t2, t1) */ 1 FROM t1 JOIN t2 ON t1.f1 = t2.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t1`) */ 1 AS `1` from `test`.`t2` where (`test`.`t2`.`f1` = '1') +DROP TABLE t1, t2; +# +# Bug#23144274 WL9158:ASSERTION `JOIN->BEST_READ < DOUBLE(1.79769313486231570815E+308L)' FAILED +# +CREATE TABLE t1 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 varchar(255) DEFAULT NULL, +PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +f3 varchar(10) DEFAULT NULL, +PRIMARY KEY (f1), +KEY f3(f3)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +EXPLAIN SELECT /*+ JOIN_SUFFIX(t1, t2) */ t2.f3 FROM t2 LEFT JOIN t1 +ON t2.f1 = t1.f1 WHERE t1.f2 NOT LIKE ('FMGAU') OR t2.f2 > 't'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f3` AS `f3` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`f1` = `test`.`t2`.`f1`)) where ((not((`test`.`t1`.`f2` like 'FMGAU'))) or (`test`.`t2`.`f2` > 't')) +DROP TABLE t1, t2; +CREATE TABLE t1 +( +f1 int(11) DEFAULT NULL, +KEY f1 (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 int(11) DEFAULT NULL, +f2 varchar(255) CHARACTER SET utf8 DEFAULT NULL, +KEY f2 (f2), +KEY f1 (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t3 ( +f1 int(11) DEFAULT NULL, +f2 varchar(255) CHARACTER SET cp932 DEFAULT NULL, +KEY f1 (f1), +KEY f2 (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t3) JOIN_ORDER(t1, t2) */ t3.f1 +FROM ( t2 INNER JOIN t3 ON t3.f2 = t2.f2 LEFT JOIN t1 ON t1.f1 = t3.f1 ) +WHERE NOT (t2.f1 >= 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range f2,f1 f1 5 NULL 1 100.00 Using index condition +2 SIMPLE t3 NULL ALL f2 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ref f1 f1 5 test.t3.f1 1 100.00 Using index +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Warning 1739 Cannot use range access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t3`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t2` join `test`.`t3` left join `test`.`t1` on((`test`.`t1`.`f1` = `test`.`t3`.`f1`)) where ((`test`.`t2`.`f1` < 7) and (`test`.`t3`.`f2` = `test`.`t2`.`f2`)) +EXPLAIN SELECT /*+ JOIN_ORDER(t1, t2) JOIN_ORDER(t2, t3) */ t3.f1 +FROM ( t2 INNER JOIN t3 ON t3.f2 = t2.f2 LEFT JOIN t1 ON t1.f1 = t3.f1 ) +WHERE NOT (t2.f1 >= 7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL f2 NULL NULL NULL 1 100.00 Using where +2 SIMPLE t1 NULL ref f1 f1 5 test.t3.f1 1 100.00 Using index +2 SIMPLE t2 NULL ref f2,f1 f2 768 test.t3.f2 1 100.00 Using index condition; Using where +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`) */ `test`.`t3`.`f1` AS `f1` from `test`.`t2` join `test`.`t3` left join `test`.`t1` on((`test`.`t1`.`f1` = `test`.`t3`.`f1`)) where ((`test`.`t2`.`f1` < 7) and (`test`.`t3`.`f2` = `test`.`t2`.`f2`)) +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +f1 INT(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 INT(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_PREFIX(t1, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f2 = t2.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.f2 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f1` = `test`.`t1`.`f2`) +DROP TABLE t1, t2; +CREATE TABLE t1 +( +f1 DATETIME, +f2 DATE, +f3 VARCHAR(1), +KEY (f1) +) ENGINE=myisam; +CREATE TABLE t2 +( +f1 VARCHAR(1), +f2 INT, +f3 VARCHAR(1), +KEY (f1) +) ENGINE=innodb; +CREATE TABLE t3 +( +f1 VARCHAR(1), +f2 DATE, +f3 DATETIME, +f4 INT +) ENGINE=myisam; +EXPLAIN +UPDATE /*+ JOIN_ORDER(t2, als1, als3) JOIN_FIXED_ORDER() */ t3 AS als1 +JOIN t1 AS als2 ON (als1.f3 = als2 .f1) +JOIN t1 AS als3 ON (als1.f1 = als3.f3) +RIGHT OUTER JOIN t3 AS als4 ON (als1.f3 = als4.f2) +SET als1.f4 = 'eogqjvbhzodzimqahyzlktkbexkhdwxwgifikhcgblhgswxyutepc' +WHERE ('i','b') IN (SELECT f3, f1 FROM t2 WHERE f2 <> f2 AND als2.f2 IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 3126 Hint JOIN_FIXED_ORDER( ) is ignored as conflicting/duplicated +Note 1276 Field or reference 'test.als2.f2' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ JOIN_ORDER(@`select#1` `t2`,`als1`,`als3`) */ `test`.`t3` `als4` left join (`test`.`t3` `als1` join `test`.`t1` `als2` join `test`.`t1` `als3`) on(((`test`.`als1`.`f3` = `test`.`als4`.`f2`) and multiple equal(`test`.`als1`.`f1`, `test`.`als3`.`f3`) and multiple equal(`test`.`als1`.`f3`, `test`.`als2`.`f1`))) semi join (`test`.`t2`) set `test`.`als1`.`f4` = 'eogqjvbhzodzimqahyzlktkbexkhdwxwgifikhcgblhgswxyutepc' where false +DROP TABLE t1, t2, t3; +CREATE TABLE t1( +f1 VARCHAR(1)) ENGINE=myisam; +CREATE TABLE t2( +f1 VARCHAR(1), +f2 VARCHAR(1), +f3 DATETIME, +KEY(f2)) ENGINE=innodb; +CREATE TABLE t3( +f1 INT, +f2 DATE, +f3 VARCHAR(1), +KEY(f3)) ENGINE=myisam; +CREATE TABLE t4( +f1 VARCHAR(1), +KEY(f1)) ENGINE=innodb; +ALTER TABLE t4 DISABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't4' doesn't have this option +INSERT INTO t4 VALUES ('x'), (NULL), ('d'), ('x'), ('u'); +ALTER TABLE t4 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't4' doesn't have this option +CREATE TABLE t5( +f1 VARCHAR(1), +KEY(f1) ) ENGINE=myisam; +INSERT INTO t5 VALUES (NULL), ('s'), ('c'), ('x'), ('z'); +EXPLAIN UPDATE /*+ JOIN_ORDER(t4, alias1, alias3) */ t3 AS alias1 +JOIN t5 ON (alias1.f3 = t5.f1) +JOIN t3 AS alias3 ON (alias1.f2 = alias3.f2 ) +RIGHT OUTER JOIN t1 ON (alias1.f3 = t1.f1) +SET alias1.f1 = -1 +WHERE ( 'v', 'o' ) IN +(SELECT DISTINCT t2.f1, t2.f2 FROM t4 RIGHT OUTER JOIN t2 ON (t4.f1 = t2.f1) +WHERE t2.f3 BETWEEN '2001-10-04' AND '2003-05-15'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 update /*+ JOIN_ORDER(@`select#1` `t4`,`alias1`,`alias3`) */ `test`.`t1` left join (`test`.`t3` `alias1` join `test`.`t5` join `test`.`t3` `alias3`) on((multiple equal(`test`.`alias1`.`f3`, `test`.`t1`.`f1`, `test`.`t5`.`f1`) and multiple equal(`test`.`alias1`.`f2`, `test`.`alias3`.`f2`))) semi join (`test`.`t2` left join `test`.`t4` on((`test`.`t4`.`f1` = `test`.`t2`.`f1`))) set `test`.`alias1`.`f1` = -(1) where ((`test`.`t2`.`f3` between '2001-10-04' and '2003-05-15') and multiple equal('v', `test`.`t2`.`f1`) and multiple equal('o', `test`.`t2`.`f2`)) +DROP TABLE t1, t2, t3, t4, t5; +CREATE TABLE t1 ( +f1 INT(11) DEFAULT NULL, +f3 VARCHAR(1) DEFAULT NULL, +f2 INT(11) DEFAULT NULL, +KEY (f1) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2( +f1 INT(11) DEFAULT NULL +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +f1 VARCHAR(1) DEFAULT NULL, +f2 VARCHAR(1) DEFAULT NULL, +KEY (f2) +) ENGINE=InnoDB; +EXPLAIN UPDATE /*+ JOIN_SUFFIX(ta1, t2) */ +t1 AS ta1 JOIN t1 AS ta2 ON ta1.f1 = ta2.f1 RIGHT JOIN t2 ON (ta1.f1 = t2.f1) +SET ta1.f2 = '', ta2.f3 = '' +WHERE ('n', 'r') IN (SELECT f2, f1 FROM t3 WHERE f1 <> f2 XOR ta2.f3 IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.ta2.f3' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ JOIN_SUFFIX(@`select#1` `ta1`,`t2`) */ `test`.`t2` left join (`test`.`t1` `ta1` join `test`.`t1` `ta2`) on((multiple equal(`test`.`ta1`.`f1`, `test`.`t2`.`f1`, `test`.`ta2`.`f1`))) semi join (`test`.`t3`) set `test`.`ta1`.`f2` = '',`test`.`ta2`.`f3` = '' where (((`test`.`t3`.`f1` <> `test`.`t3`.`f2`) xor (`test`.`ta2`.`f3` is null)) and multiple equal('n', `test`.`t3`.`f2`) and multiple equal('r', `test`.`t3`.`f1`)) +DROP TABLE t1, t2, t3; +CREATE TABLE t2(f1 VARCHAR(255) DEFAULT NULL, f2 INT(11) DEFAULT NULL, +KEY (f1), KEY (f2)) charset latin1 ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4(f1 INT(11) DEFAULT NULL, f2 INT(11) DEFAULT NULL, KEY (f1)) +charset latin1 ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t5(f1 INT(11) NOT NULL AUTO_INCREMENT, f2 INT(11) DEFAULT NULL, PRIMARY KEY (f1)) +charset latin1 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t6(f1 INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (f1)) +charset latin1 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t7 (f1 VARCHAR(255) DEFAULT NULL) +charset latin1 ENGINE=InnoDB; +CREATE TABLE t10(f1 INT(11) NOT NULL AUTO_INCREMENT,f2 INT(11) DEFAULT NULL,f3 VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (f1),KEY (f2),KEY (f3)) charset latin1 ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t11(f1 INT(11) DEFAULT NULL,f2 VARCHAR(10) DEFAULT NULL, +KEY (f1),KEY (f2)) charset latin1 ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN +SELECT /*+ JOIN_ORDER(alias11, alias8) */ 1 +FROM t4 AS alias4 +LEFT JOIN t5 AS alias5 JOIN t6 AS alias6 ON alias5.f2 = alias6.f1 +LEFT JOIN t7 AS alias7 JOIN t2 AS alias8 ON alias7.f1 = alias8.f1 +ON alias5.f1 = alias8.f2 ON alias4.f2 = alias6.f1 +JOIN t10 AS alias10 JOIN t11 AS alias11 ON alias10.f1 = alias11.f1 +ON alias4.f2 = alias11.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `alias11`,`alias8`) */ 1 AS `1` from `test`.`t4` `alias4` left join (`test`.`t5` `alias5` join `test`.`t6` `alias6` left join (`test`.`t7` `alias7` join `test`.`t2` `alias8`) on((multiple equal(`test`.`alias5`.`f1`, `test`.`alias8`.`f2`) and multiple equal(`test`.`alias7`.`f1`, `test`.`alias8`.`f1`)))) on((multiple equal(NULL, `test`.`alias6`.`f1`, `test`.`alias5`.`f2`))) join `test`.`t10` `alias10` join `test`.`t11` `alias11` where ((NULL = `test`.`alias11`.`f2`) and multiple equal(NULL, `test`.`alias11`.`f1`)) +EXPLAIN +SELECT /*+ JOIN_ORDER(alias11, alias10, alias8, alias7) */ 1 +FROM t4 AS alias4 +LEFT JOIN t5 AS alias5 JOIN t6 AS alias6 ON alias5.f2 = alias6.f1 +LEFT JOIN t7 AS alias7 JOIN t2 AS alias8 ON alias7.f1 = alias8.f1 +ON alias5.f1 = alias8.f2 ON alias4.f2 = alias6.f1 +JOIN t10 AS alias10 JOIN t11 AS alias11 ON alias10.f1 = alias11.f1 +ON alias4.f2 = alias11.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Warning 1739 Cannot use ref access on index 'f2' due to type or collation conversion on field 'f2' +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `alias11`,`alias10`,`alias8`,`alias7`) */ 1 AS `1` from `test`.`t4` `alias4` left join (`test`.`t5` `alias5` join `test`.`t6` `alias6` left join (`test`.`t7` `alias7` join `test`.`t2` `alias8`) on((multiple equal(`test`.`alias5`.`f1`, `test`.`alias8`.`f2`) and multiple equal(`test`.`alias7`.`f1`, `test`.`alias8`.`f1`)))) on((multiple equal(NULL, `test`.`alias6`.`f1`, `test`.`alias5`.`f2`))) join `test`.`t10` `alias10` join `test`.`t11` `alias11` where ((NULL = `test`.`alias11`.`f2`) and multiple equal(NULL, `test`.`alias11`.`f1`)) +DROP TABLES t2, t4, t5, t6, t7, t10, t11; +CREATE TABLE t1 (f1 VARCHAR(255) DEFAULT NULL, f2 VARCHAR(255) DEFAULT NULL, +KEY (f1), KEY (f2)) ENGINE=InnoDB; +CREATE TABLE t2(f1 VARCHAR(255) DEFAULT NULL, f2 INT(11) DEFAULT NULL, +KEY (f1), KEY (f2)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3( +f1 INT(11) NOT NULL AUTO_INCREMENT, f2 VARCHAR(255) DEFAULT NULL, +PRIMARY KEY (f1), KEY (f2)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t4(f1 INT(11) DEFAULT NULL, f2 INT(11) DEFAULT NULL, KEY (f1)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t6(f1 INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (f1)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t7 (f1 VARCHAR(255) DEFAULT NULL) ENGINE=InnoDB; +CREATE TABLE t10(f1 INT(11) NOT NULL AUTO_INCREMENT,f2 INT(11) DEFAULT NULL,f3 VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (f1),KEY (f2),KEY (f3)) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_ORDER(alias8, alias6) */ 1 +FROM t1 AS alias1 +LEFT JOIN t7 alias7 +JOIN t2 AS alias2 +LEFT JOIN t3 AS alias3 JOIN t4 AS alias4 ON alias4.f2 = alias3.f1 +ON alias4.f1 = alias2.f1 +ON alias2.f2 = alias7.f1 +JOIN t10 AS alias5 +LEFT JOIN t6 AS alias6 JOIN t2 AS alias8 ON alias6.f1 = alias8.f2 +ON alias6.f1 = alias5.f1 +ON alias5.f3 = alias7.f1 +ON alias1.f2 = alias7.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL index NULL f2 1023 NULL 1 100.00 Using index +1 SIMPLE alias7 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE alias2 NULL ref f2 f2 5 test.alias7.f1 1 100.00 Using where +1 SIMPLE alias4 NULL ref f1 f1 5 test.alias2.f1 1 100.00 Using where +1 SIMPLE alias3 NULL eq_ref PRIMARY PRIMARY 4 test.alias4.f2 1 100.00 Using index +1 SIMPLE alias5 NULL ref f3 f3 43 test.alias7.f1 1 100.00 Using where; Using index +1 SIMPLE alias8 NULL ref f2 f2 5 test.alias5.f1 1 100.00 Using index +1 SIMPLE alias6 NULL eq_ref PRIMARY PRIMARY 4 test.alias5.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `alias8`,`alias6`) */ 1 AS `1` from `test`.`t1` `alias1` left join (`test`.`t7` `alias7` join `test`.`t2` `alias2` left join (`test`.`t3` `alias3` join `test`.`t4` `alias4`) on(((`test`.`alias3`.`f1` = `test`.`alias4`.`f2`) and (cast(`test`.`alias4`.`f1` as double) = cast(`test`.`alias2`.`f1` as double)))) join `test`.`t10` `alias5` left join (`test`.`t6` `alias6` join `test`.`t2` `alias8`) on(((`test`.`alias8`.`f2` = `test`.`alias5`.`f1`) and (`test`.`alias6`.`f1` = `test`.`alias5`.`f1`)))) on(((`test`.`alias7`.`f1` = `test`.`alias1`.`f2`) and (`test`.`alias5`.`f3` = `test`.`alias1`.`f2`) and (cast(`test`.`alias2`.`f2` as double) = cast(`test`.`alias1`.`f2` as double)))) where true +DROP TABLES t1, t2, t3, t4, t6, t7, t10; +# +# Bug#23144230 WL#9158 : OPT_HINTS_QB::APPLY_JOIN_ORDER_HINTS - MYSQLD GOT SIGNAL 11 +# +CREATE TABLE t1 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 int(11) DEFAULT NULL, +f3 int(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY f2 (f2)) +ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 int(11) DEFAULT NULL, +f3 int(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY f2 (f2)) +ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_PREFIX(alias1) */ alias2.f3 AS field1 +FROM ( SELECT * FROM t1 ) AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 +ON alias1.f2 = alias2.f3 +WHERE alias2.f2 IS NULL HAVING (field1 != 3 AND field1 >= 8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref f2 f2 5 const 1 100.00 Using index condition; Using where +2 SIMPLE t1 NULL ref f2 f2 5 test.t2.f3 1 100.00 Using index +Warnings: +Warning 3128 Unresolved name `alias1` for JOIN_PREFIX hint +Note 1003 /* select#1 */ select `test`.`t2`.`f3` AS `field1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f2` = `test`.`t2`.`f3`) and (`test`.`t2`.`f2` is null)) having ((`field1` <> 3) and (`field1` >= 8)) +DROP TABLE t1, t2; +CREATE TABLE t1 +( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 int(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +EXPLAIN SELECT /*+ JOIN_ORDER(t2, t1) JOIN_FIXED_ORDER() */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index f2 f2 5 NULL 1 100.00 Using where; Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f2 1 100.00 Using where +Warnings: +Warning 3126 Hint JOIN_FIXED_ORDER( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t2`,`t1`) */ `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t1`.`f2` > 5) and (`test`.`t2`.`f2` <= 5)) +EXPLAIN SELECT /*+ JOIN_FIXED_ORDER() JOIN_ORDER(t2, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref f2 f2 5 test.t1.f1 1 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_ORDER( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_FIXED_ORDER(@`select#1`) */ straight_join `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f2` > 5) and (`test`.`t1`.`f1` <= 5)) +EXPLAIN SELECT /*+ JOIN_FIXED_ORDER() JOIN_PREFIX(t2, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref f2 f2 5 test.t1.f1 1 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_PREFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_FIXED_ORDER(@`select#1`) */ straight_join `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f2` > 5) and (`test`.`t1`.`f1` <= 5)) +EXPLAIN SELECT /*+ JOIN_FIXED_ORDER() JOIN_SUFFIX(t2, t1) */ t2.f1 FROM t1 JOIN t2 ON t1.f1 = t2.f2 +WHERE (t1.f2 > 5 AND t1.f1 <= 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 1 100.00 Using where +2 SIMPLE t2 NULL ref f2 f2 5 test.t1.f1 1 100.00 Using index +Warnings: +Warning 3126 Hint JOIN_SUFFIX( `t2`,`t1`) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ JOIN_FIXED_ORDER(@`select#1`) */ straight_join `test`.`t2`.`f1` AS `f1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f2` > 5) and (`test`.`t1`.`f1` <= 5)) +DROP TABLE t1, t2; +# +# Bug#23651098 WL#9158 : ASSERTION `!(SJ_NEST->SJ_INNER_TABLES & JOIN->CONST_TABLE_MAP)' FAILED +# +CREATE TABLE t1 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +PRIMARY KEY (f1) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 +( +f1 VARCHAR(1) DEFAULT NULL +) ENGINE=MyISAM; +CREATE TABLE t3 +( +f1 VARCHAR(1) DEFAULT NULL +) ENGINE=MyISAM; +EXPLAIN SELECT /*+ JOIN_PREFIX(t2, t1) */ t1.f1 FROM t1, t2 +WHERE t2.f1 IN (SELECT t3.f1 FROM t3) AND t1.f1 = 183; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`,`t1`) */ NULL AS `f1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where (multiple equal(183, NULL) and multiple equal(NULL, `test`.`t3`.`f1`)) +DROP TABLE t1, t2, t3; +# +# Bug23715779 SELECT QUERY WITH JOIN_PREFIX() HINT RETURNS INCORRECT RESULT +# +CREATE TABLE t1(f1 INT(11) NOT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10); +CREATE TABLE t2 +( +f1 INT(11) NOT NULL AUTO_INCREMENT, +f2 INT(11) DEFAULT NULL, +PRIMARY KEY (f1), +KEY (f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1, 7), (2, 1), (4, 7); +CREATE TABLE t4(f1 INT DEFAULT NULL); +INSERT INTO t4 VALUES (2); +ANALYZE TABLE t1, t2, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t4 analyze status OK +SELECT +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +EXPLAIN SELECT +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE ta4 NULL eq_ref PRIMARY PRIMARY 4 test.t4.f1 1 100.00 Using index; End temporary +2 SIMPLE t2 NULL index f2 f2 5 NULL 3 66.67 Using where; Using index; LooseScan +2 SIMPLE ta3 NULL ref f2 f2 5 test.t2.f2 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` join `test`.`t2` `ta3` join `test`.`t2` `ta4` semi join (`test`.`t4`) semi join (`test`.`t2`) where ((`test`.`ta3`.`f2` = `test`.`t2`.`f2`) and (`test`.`ta4`.`f1` = `test`.`t4`.`f1`)) +SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +COUNT(*) +3 +EXPLAIN SELECT /*+ JOIN_PREFIX(t2@qb2, t4@qb1, ta3, ta4) */ +COUNT(*) FROM t1 JOIN t2 AS ta3 JOIN t2 AS ta4 +WHERE ta4.f1 IN (SELECT /*+ QB_NAME(qb1) */ f1 FROM t4) AND +ta3.f2 IN (SELECT /*+ QB_NAME(qb2) */ f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index f2 f2 5 NULL 3 100.00 Using where; Using index; Start temporary +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ta3 NULL ref f2 f2 5 test.t2.f2 1 100.00 Using index +1 SIMPLE ta4 NULL eq_ref PRIMARY PRIMARY 4 test.t4.f1 1 100.00 Using index; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_PREFIX(@`select#1` `t2`@`qb2`,`t4`@`qb1`,`ta3`,`ta4`) */ count(0) AS `COUNT(*)` from `test`.`t1` join `test`.`t2` `ta3` join `test`.`t2` `ta4` semi join (`test`.`t4`) semi join (`test`.`t2`) where ((`test`.`ta3`.`f2` = `test`.`t2`.`f2`) and (`test`.`ta4`.`f1` = `test`.`t4`.`f1`)) +DROP TABLE t1, t2, t4; diff --git a/mysql-test/r/opt_hints_lowercase.result-pq b/mysql-test/r/opt_hints_lowercase.result-pq new file mode 100644 index 000000000..6205c820b --- /dev/null +++ b/mysql-test/r/opt_hints_lowercase.result-pq @@ -0,0 +1,36 @@ +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES +(1,1),(2,2),(3,3); +CREATE TABLE T1 (f1 INT NOT NULL, f2 INT, f3 VARCHAR(32), +PRIMARY KEY(f1), KEY f2_idx(f1), KEY f3_idx(f3)); +INSERT INTO T1 VALUES +(1, 1, 'qwerty'), (2, 1, 'ytrewq'), +(3, 2, 'uiop'), (4, 2, 'poiu'), (5, 2, 'lkjh'), +(6, 2, 'uiop'), (7, 2, 'poiu'), (8, 2, 'lkjh'), +(9, 2, 'uiop'), (10, 2, 'poiu'), (11, 2, 'lkjh'), +(12, 2, 'uiop'), (13, 2, 'poiu'), (14, 2, 'lkjh'); +INSERT INTO T1 SELECT f1 + 20, f2, f3 FROM T1; +INSERT INTO T1 SELECT f1 + 40, f2, f3 FROM T1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE T1; +Table Op Msg_type Msg_text +test.T1 analyze status OK +EXPLAIN SELECT /*+ NO_BNL(t1) */ * FROM t1 t1, T1 T1 WHERE T1.f1 between 1 and 3 +AND t1.f2 = T1.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE T1 NULL range PRIMARY,f2_idx PRIMARY 4 NULL 3 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`t1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`T1`.`f1` AS `f1`,`test`.`T1`.`f2` AS `f2`,`test`.`T1`.`f3` AS `f3` from `test`.`t1` join `test`.`T1` where ((`test`.`T1`.`f2` = `test`.`t1`.`f2`) and (`test`.`T1`.`f1` between 1 and 3)) +EXPLAIN SELECT /*+ NO_BNL(T1) */ * FROM t1 t1, T1 T1 WHERE T1.f1 between 1 and 3 +AND t1.f2 = T1.f2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE T1 NULL range PRIMARY,f2_idx PRIMARY 4 NULL 3 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_BNL(`T1`@`select#1`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`T1`.`f1` AS `f1`,`test`.`T1`.`f2` AS `f2`,`test`.`T1`.`f3` AS `f3` from `test`.`t1` join `test`.`T1` where ((`test`.`T1`.`f2` = `test`.`t1`.`f2`) and (`test`.`T1`.`f1` between 1 and 3)) +DROP TABLE t1, T1; diff --git a/mysql-test/r/opt_hints_set_var.result-pq b/mysql-test/r/opt_hints_set_var.result-pq new file mode 100644 index 000000000..87a328ccf --- /dev/null +++ b/mysql-test/r/opt_hints_set_var.result-pq @@ -0,0 +1,925 @@ +CREATE TABLE t1(f1 INT); +SELECT /*+ SET_VAR(foo = 10) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 1K) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 21M) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 321G) */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 9000100500G) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '9000100500G) */ 1' at line 1 +SELECT /*+ SET_VAR(foo = 'test') */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = "test""test") */ 1; +1 +1 +Warnings: +Warning 3128 Unresolved name 'foo' for SET_VAR hint +SELECT /*+ SET_VAR(foo = 900010050018247362846826482468) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '900010050018247362846826482468) */ 1' at line 1 +SELECT /*+ QB_NAME(1KLMN) */ 1; +1 +1 +SELECT /*+ SET_VAR(foo = 900010050018247362846826482468000) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '900010050018247362846826482468000) */ 1' at line 1 +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_access=on') SET_VAR(optimizer_switch = 'batched_key_access=off')*/ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3126 Hint SET_VAR(optimizer_switch='batched_key_access=off') is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_switch='batched_key_access=on') */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(max_join_size=1) SET_VAR(max_join_size=1) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3126 Hint SET_VAR(max_join_size=1) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SET_VAR(max_join_size=1) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_access=on') +SET_VAR(big_tables=on) +SET_VAR(big_tables=off) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3126 Hint SET_VAR(big_tables='off') is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_switch='batched_key_access=on') SET_VAR(big_tables='on') */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switc = 'batched_key_access=off') */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3128 Unresolved name 'optimizer_switc' for SET_VAR hint +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_access=yes') */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1231 Variable 'optimizer_switch' can't be set to the value of 'batched_key_access=yes' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_acces=off') */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1231 Variable 'optimizer_switch' can't be set to the value of 'batched_key_acces=off' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(max_allowed_packet = 1M) */ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 3637 Variable 'max_allowed_packet' cannot be set using SET_VAR hint. +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +explain SELECT /*+ SET_VAR(optimizer_switch = 'batched_key_acces=off') SET_VAR(range_alloc_block_size=amba)*/ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Warning 1231 Variable 'optimizer_switch' can't be set to the value of 'batched_key_acces=off' +Warning 1232 Incorrect argument type to variable 'range_alloc_block_size' +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +SELECT /*+ SET_VAR(range_alloc_block_size=7000) */ 1; +1 +1 +SHOW WARNINGS LIMIT 1; +Level Code Message +Warning 1292 Truncated incorrect range_alloc_block_size value: '7000' +DROP TABLE t1; +PREPARE stmt FROM "SELECT /*+ SET_VAR(big_tables=on) */ VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'"; +SELECT VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'; +VARIABLE_VALUE +OFF +EXECUTE stmt; +VARIABLE_VALUE +ON +SELECT VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'; +VARIABLE_VALUE +OFF +EXECUTE stmt; +VARIABLE_VALUE +ON +SELECT VARIABLE_VALUE FROM performance_schema.session_variables where VARIABLE_NAME = 'big_tables'; +VARIABLE_VALUE +OFF +DEALLOCATE PREPARE stmt; +CREATE PROCEDURE test_hint (hint_str VARCHAR(255), var_str VARCHAR(64)) +BEGIN +SET @orig_q= CONCAT("SELECT + VARIABLE_VALUE + FROM performance_schema.session_variables where VARIABLE_NAME = '", var_str, "'"); +SET @hint_q= CONCAT("SELECT /*+ ", hint_str, +"*/ VARIABLE_VALUE" , +" FROM performance_schema.session_variables where VARIABLE_NAME = '", var_str, "'"); +PREPARE orig_stmt FROM @orig_q; +PREPARE hint_stmt FROM @hint_q; +EXECUTE orig_stmt; +EXECUTE hint_stmt; +EXECUTE orig_stmt; +DEALLOCATE PREPARE orig_stmt; +DEALLOCATE PREPARE hint_stmt; +END\\ +CREATE TABLE t1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT /*+ SET_VAR(auto_increment_increment=10) */ INTO t1 VALUES (NULL), (NULL), (NULL), (NULL); +SELECT * FROM t1; +col +1 +11 +21 +31 +DROP TABLE t1; +CALL test_hint("SET_VAR(auto_increment_increment=10)", "auto_increment_increment"); +VARIABLE_VALUE +1 +VARIABLE_VALUE +10 +VARIABLE_VALUE +1 +CREATE TABLE t1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT /*+ SET_VAR(auto_increment_increment=10) SET_VAR(auto_increment_offset=5) */ INTO t1 VALUES (NULL), (NULL), (NULL), (NULL); +SELECT * FROM t1; +col +5 +15 +25 +35 +DROP TABLE t1; +CALL test_hint("SET_VAR(auto_increment_offset=5)", "auto_increment_offset"); +VARIABLE_VALUE +1 +VARIABLE_VALUE +5 +VARIABLE_VALUE +1 +CREATE TABLE t1 (a CHAR PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2); +FLUSH STATUS; +SELECT COUNT(DISTINCT t1.a) FROM t1,t1 t2 WHERE t1.a = 1; +COUNT(DISTINCT t1.a) +1 +SHOW STATUS LIKE '%tmp_disk_tables%'; +Variable_name Value +Created_tmp_disk_tables 0 +FLUSH STATUS; +SELECT /*+ SET_VAR(big_tables=on) */ COUNT(DISTINCT t1.a) FROM t1,t1 t2 WHERE t1.a = 1; +COUNT(DISTINCT t1.a) +1 +SHOW STATUS LIKE '%tmp_disk_tables%'; +Variable_name Value +Created_tmp_disk_tables 1 +DROP TABLE t1; +CALL test_hint("SET_VAR(big_tables=on)", "big_tables"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CALL test_hint("SET_VAR(bulk_insert_buffer_size=0)", "bulk_insert_buffer_size"); +VARIABLE_VALUE +8388608 +VARIABLE_VALUE +0 +VARIABLE_VALUE +8388608 +CREATE TEMPORARY TABLE t1 SELECT 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `1` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TEMPORARY TABLE t2 SELECT /*+ SET_VAR(default_tmp_storage_engine=InnoDB)*/ 1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `1` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +CALL test_hint("SET_VAR(default_tmp_storage_engine=InnoDB)", "default_tmp_storage_engine"); +VARIABLE_VALUE +InnoDB +VARIABLE_VALUE +InnoDB +VARIABLE_VALUE +InnoDB +SELECT /*+ SET_VAR(div_precision_increment=12) */ 1/2; +1/2 +0.500000000000 +CALL test_hint("SET_VAR(div_precision_increment=12)", "div_precision_increment"); +VARIABLE_VALUE +4 +VARIABLE_VALUE +12 +VARIABLE_VALUE +4 +CALL test_hint("SET_VAR(end_markers_in_json=ON)", "end_markers_in_json"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CALL test_hint("SET_VAR(eq_range_index_dive_limit=0)", "eq_range_index_dive_limit"); +VARIABLE_VALUE +200 +VARIABLE_VALUE +0 +VARIABLE_VALUE +200 +CREATE TABLE t1 +( +id INT PRIMARY KEY +) ENGINE=InnoDB; +CREATE TABLE t2 +( +v INT, +CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id) +) ENGINE=InnoDB; +INSERT /*+ SET_VAR(foreign_key_checks=0) */INTO t2 VALUES(2); +DROP TABLE t2, t1; +CALL test_hint("SET_VAR(foreign_key_checks=0)", "foreign_key_checks"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +CREATE TABLE t1( a VARCHAR( 10 ), b INT ); +INSERT INTO t1 VALUES ( repeat( 'a', 10 ), 1), +( repeat( 'b', 10 ), 2); +SELECT /*+ SET_VAR(group_concat_max_len=20) */ GROUP_CONCAT(a) FROM t1; +GROUP_CONCAT(a) +aaaaaaaaaa,bbbbbbbbb +Warnings: +Warning 1260 Row 2 was cut by GROUP_CONCAT() +DROP TABLE t1; +CALL test_hint("SET_VAR(group_concat_max_len=20)", "group_concat_max_len"); +VARIABLE_VALUE +1024 +VARIABLE_VALUE +20 +VARIABLE_VALUE +1024 +CREATE TABLE t1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT /*+ SET_VAR(insert_id=10) */ INTO t1 VALUES (NULL), (NULL), (NULL), (NULL); +SELECT * FROM t1; +col +10 +11 +12 +13 +DROP TABLE t1; +CALL test_hint("SET_VAR(insert_id=10)", "insert_id"); +VARIABLE_VALUE +0 +VARIABLE_VALUE +10 +VARIABLE_VALUE +0 +CALL test_hint("SET_VAR(join_buffer_size=128)", "join_buffer_size"); +VARIABLE_VALUE +262144 +VARIABLE_VALUE +128 +VARIABLE_VALUE +262144 +CREATE TABLE t1(i INT) ENGINE InnoDB; +LOCK TABLES t1 WRITE; +INSERT /*+ SET_VAR(lock_wait_timeout=1) */INTO t1 VALUES (1); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +UNLOCK TABLES; +DROP TABLE t1; +CALL test_hint("SET_VAR(lock_wait_timeout=1)", "lock_wait_timeout"); +VARIABLE_VALUE +31536000 +VARIABLE_VALUE +1 +VARIABLE_VALUE +31536000 +CREATE TABLE t1(f1 INT); +EXPLAIN SELECT /*+ SET_VAR(max_error_count=0) SET_VAR(optimizer_switch = 'batched_key_acces=off') SET_VAR(range_alloc_block_size=amba)*/ * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +DROP TABLE t1; +CALL test_hint("SET_VAR(max_error_count=0)", "max_error_count"); +VARIABLE_VALUE +1024 +VARIABLE_VALUE +0 +VARIABLE_VALUE +1024 +CREATE TABLE t1 (a INT, b VARCHAR(300)); +INSERT INTO t1 VALUES (1, 'string'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SELECT /*+ SET_VAR(max_execution_time=1) */ * FROM t1 a, t1 b; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +DROP TABLE t1; +CALL test_hint("SET_VAR(max_execution_time=1)", "max_execution_time"); +VARIABLE_VALUE +0 +VARIABLE_VALUE +1 +VARIABLE_VALUE +0 +CREATE TABLE t1(f1 CHAR(255) CHARSET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +FLUSH STATUS; +SELECT /*+ SET_VAR(max_heap_table_size=16384) SET_VAR(internal_tmp_mem_storage_engine=MEMORY)*/ count(*) +FROM t1 JOIN ( +SELECT t1.f1 FROM t1 JOIN t1 AS t2 JOIN t1 AS t3) tt ON t1.f1 = tt.f1; +count(*) +1000 +SHOW STATUS LIKE 'Handler_write'; +Variable_name Value +Handler_write 1021 +FLUSH STATUS; +SELECT count(*) +FROM t1 JOIN ( +SELECT t1.f1 FROM t1 JOIN t1 AS t2 JOIN t1 AS t3) tt ON t1.f1 = tt.f1; +count(*) +1000 +SHOW STATUS LIKE 'Handler_write'; +Variable_name Value +Handler_write 1000 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1; +CALL test_hint("SET_VAR(max_heap_table_size=16384)", "max_heap_table_size"); +VARIABLE_VALUE +16777216 +VARIABLE_VALUE +16384 +VARIABLE_VALUE +16777216 +CALL test_hint("SET_VAR(internal_tmp_mem_storage_engine=MEMORY)", "internal_tmp_mem_storage_engine"); +VARIABLE_VALUE +TempTable +VARIABLE_VALUE +MEMORY +VARIABLE_VALUE +TempTable +SELECT /*+ SET_VAR(max_points_in_geometry=1048576) */ +st_astext(st_buffer(point(-5,0),8772, st_buffer_strategy( 'point_circle',1024*1024*1024))) as result; +ERROR HY000: Parameter points_per_circle exceeds the maximum number of points in a geometry (1048576) in function st_buffer_strategy. +CALL test_hint("SET_VAR(max_points_in_geometry=1048576)", "max_points_in_geometry"); +VARIABLE_VALUE +65536 +VARIABLE_VALUE +1048576 +VARIABLE_VALUE +65536 +CALL test_hint("SET_VAR(max_seeks_for_key=1)", "max_seeks_for_key"); +VARIABLE_VALUE +DEFAULT +VARIABLE_VALUE +1 +VARIABLE_VALUE +DEFAULT +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INT, INDEX a (a)); +CREATE TABLE t3 (a INT, b INT, INDEX a (a,b)); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10,3), (20,4), (30,5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 test.t1.b 1 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ SET_VAR(optimizer_search_depth=1) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index NULL a 10 NULL 3 100.00 Using where; Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t3.b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_search_depth=1) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t1`.`b` = `test`.`t3`.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +EXPLAIN SELECT /*+ SET_VAR(optimizer_prune_level=0) */ * FROM t1 JOIN t2 ON t1.b = t2.a WHERE +t2.a IN (SELECT t3.b FROM t3 JOIN t1 t4 ON t3.b = t4.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref a a 5 .b 1 100.00 Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL index NULL a 10 NULL 3 100.00 Using index +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(optimizer_prune_level=0) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3` join `test`.`t1` `t4`) where ((`test`.`t2`.`a` = ``.`b`) and (`test`.`t1`.`b` = ``.`b`) and (`test`.`t4`.`b` = `test`.`t3`.`b`)) +CALL test_hint("SET_VAR(optimizer_search_depth=1)", "optimizer_search_depth"); +VARIABLE_VALUE +62 +VARIABLE_VALUE +1 +VARIABLE_VALUE +62 +CALL test_hint("SET_VAR(optimizer_prune_level=0)", "optimizer_prune_level"); +VARIABLE_VALUE +1 +VARIABLE_VALUE +0 +VARIABLE_VALUE +1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 +( +f1 int NOT NULL DEFAULT '0', +f2 int NOT NULL DEFAULT '0', +f3 int NOT NULL DEFAULT '0', +INDEX idx1(f2, f3), INDEX idx2(f3) +); +INSERT INTO t1(f1) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(f2, f3) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch='mrr=on,mrr_cost_based=off'; +# Check statistics without hint +FLUSH STATUS; +SELECT * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +# Check statistics with hint +FLUSH STATUS; +SELECT /*+ SET_VAR(optimizer_switch='mrr=off') */ * FROM t1 WHERE f2 <= 3 AND 3 <= f3; +f1 f2 f3 +0 3 4 +0 3 4 +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +set optimizer_switch=default; +DROP TABLE t1; +CALL test_hint("SET_VAR(optimizer_switch='mrr=off')", "optimizer_switch"); +VARIABLE_VALUE +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +VARIABLE_VALUE +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=off,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +VARIABLE_VALUE +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +CALL test_hint("SET_VAR(range_alloc_block_size=8192)", "range_alloc_block_size"); +VARIABLE_VALUE +4096 +VARIABLE_VALUE +8192 +VARIABLE_VALUE +4096 +CREATE TABLE t1 (f1 INT, KEY(f1)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7); +SELECT /*+ SET_VAR(range_optimizer_max_mem_size=1) */ f1 FROM t1 WHERE f1 = 1 OR f1 = 2 OR f1 = 6; +f1 +1 +2 +6 +Warnings: +Warning 3170 Memory capacity of 1 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +DROP TABLE t1; +CALL test_hint("SET_VAR(range_optimizer_max_mem_size=1)", "range_optimizer_max_mem_size"); +VARIABLE_VALUE +8388608 +VARIABLE_VALUE +1 +VARIABLE_VALUE +8388608 +CALL test_hint("SET_VAR(read_buffer_size=8200)", "read_buffer_size"); +VARIABLE_VALUE +131072 +VARIABLE_VALUE +8192 +VARIABLE_VALUE +131072 +CALL test_hint("SET_VAR(read_rnd_buffer_size=1)", "read_rnd_buffer_size"); +VARIABLE_VALUE +262144 +VARIABLE_VALUE +1 +VARIABLE_VALUE +262144 +CREATE TABLE t1 (f1 CHAR(255)); +INSERT INTO t1 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'), ('eee'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +FLUSH STATUS; +SELECT /*+ SET_VAR(sort_buffer_size=32768) */f1 FROM t1 ORDER BY f1; +SHOW STATUS LIKE 'Sort_merge_passes'; +Variable_name Value +Sort_merge_passes 0 +FLUSH STATUS; +SELECT f1 FROM t1 ORDER BY f1; +SHOW STATUS LIKE 'Sort_merge_passes'; +Variable_name Value +Sort_merge_passes 0 +DROP TABLE t1; +CALL test_hint("SET_VAR(sort_buffer_size=32768)", "sort_buffer_size"); +VARIABLE_VALUE +262144 +VARIABLE_VALUE +32768 +VARIABLE_VALUE +262144 +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY); +SET insert_id = 1; +INSERT INTO t1 VALUES (NULL); +SET insert_id = 0; +SELECT /*+ SET_VAR(sql_auto_is_null=1) */ a FROM t1 WHERE a IS NULL; +a +1 +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_auto_is_null=1)", "sql_auto_is_null"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CREATE TABLE t1 (a INT, b VARCHAR(300)); +INSERT INTO t1 VALUES (1, 'string'); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SELECT /*+ SET_VAR(sql_big_selects=0) SET_VAR(max_join_size=1) */ * FROM t1 a, t1 b; +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_big_selects=0)", "sql_big_selects"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +CALL test_hint("SET_VAR(max_join_size=1)", "max_join_size"); +VARIABLE_VALUE +18446744073709551615 +VARIABLE_VALUE +1 +VARIABLE_VALUE +18446744073709551615 +CREATE TABLE t1 ( +a int, +b varchar(1), +KEY (b,a) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,NULL),(0,'a'),(1,NULL),(0,'a'); +INSERT INTO t1 VALUES (1,'a'),(0,'a'),(1,'a'),(0,'a'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ SET_VAR(sql_buffer_result=1) */ MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 12 NULL 2 100.00 Using where; Using index for group-by; Using temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(sql_buffer_result=1) */ sql_buffer_result min(`test`.`t1`.`a`) AS `MIN(a)`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 'a') group by `test`.`t1`.`b` +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_buffer_result=1)", "sql_buffer_result"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CREATE TABLE t1 (f1 DATE); +INSERT /*+ SET_VAR(sql_mode='ALLOW_INVALID_DATES') */ INTO t1 VALUES ('00-00-00'); +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_mode='ALLOW_INVALID_DATES')", "sql_mode"); +VARIABLE_VALUE +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION +VARIABLE_VALUE +ALLOW_INVALID_DATES +VARIABLE_VALUE +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +UPDATE /*+ SET_VAR(sql_safe_updates=1) */ IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +DROP TABLE t1; +DROP VIEW v1; +CALL test_hint("SET_VAR(sql_safe_updates=1)", "sql_safe_updates"); +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (1), (2); +SELECT /*+ SET_VAR(sql_select_limit=1) */* FROM t1; +f1 +1 +DROP TABLE t1; +CALL test_hint("SET_VAR(sql_select_limit=1)", "sql_select_limit"); +VARIABLE_VALUE +18446744073709551615 +VARIABLE_VALUE +1 +VARIABLE_VALUE +18446744073709551615 +SELECT /*+ SET_VAR(timestamp=1322115328) */ CAST(UNIX_TIMESTAMP() AS TIME); +CAST(UNIX_TIMESTAMP() AS TIME) +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '1322115328' +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 SELECT a+8 FROM t1; +INSERT INTO t1 SELECT a+16 FROM t1; +INSERT INTO t1 SELECT a+32 FROM t1; +INSERT INTO t1 SELECT a+64 FROM t1; +INSERT INTO t1 VALUE(NULL); +FLUSH STATUS; +SELECT /*+ SET_VAR(tmp_table_size=1024) */ COUNT(DISTINCT a) FROM t1; +COUNT(DISTINCT a) +128 +SHOW STATUS LIKE 'Created_tmp_files'; +Variable_name Value +Created_tmp_files 1 +DROP TABLE t1; +CALL test_hint("SET_VAR(tmp_table_size=1024)", "tmp_table_size"); +VARIABLE_VALUE +16777216 +VARIABLE_VALUE +1024 +VARIABLE_VALUE +16777216 +CALL test_hint("SET_VAR(updatable_views_with_limit=NO)", "updatable_views_with_limit"); +VARIABLE_VALUE +YES +VARIABLE_VALUE +NO +VARIABLE_VALUE +YES +CALL test_hint("SET_VAR(unique_checks=OFF)", "unique_checks"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +CREATE TABLE t1 (d DOUBLE, id INT, sex CHAR(1), n INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(n)); +INSERT INTO t1(d, id, sex) VALUES (1.0, 1, 'M'), +(2.0, 2, 'F'), +(3.0, 3, 'F'), +(4.0, 4, 'F'), +(5.0, 5, 'M'), +(NULL, NULL, 'M'), +(10.0, 10, NULL), +(10.0, 10, NULL), +(11.0, 11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT +id, AVG(id) over w `avg`, SUM(id) OVER w `sum`, COUNT(*) OVER w cnt +FROM t1 WINDOW w as (ORDER BY id RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "id", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `avg`,sum(`test`.`t1`.`id`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT /*+ SET_VAR(windowing_use_high_precision=OFF)*/ +d, AVG(d) over w `avg`, SUM(d) OVER w `sum`, COUNT(*) OVER w cnt +FROM t1 WINDOW w as (ORDER BY d RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "d", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select /*+ SET_VAR(windowing_use_high_precision='OFF') */ `test`.`t1`.`d` AS `d`,avg(`test`.`t1`.`d`) OVER `w` AS `avg`,sum(`test`.`t1`.`d`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`d` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +DROP TABLE t1; +CALL test_hint("SET_VAR(windowing_use_high_precision=OFF)", "windowing_use_high_precision"); +VARIABLE_VALUE +ON +VARIABLE_VALUE +OFF +VARIABLE_VALUE +ON +WITH RECURSIVE qn AS ( +SELECT 1 AS a UNION ALL +SELECT 1+a FROM qn WHERE a<=10) +SELECT /*+ SET_VAR(cte_max_recursion_depth=5) */ COUNT(*) FROM qn; +ERROR HY000: Recursive query aborted after 6 iterations. Try increasing @@cte_max_recursion_depth to a larger value. +CALL test_hint("SET_VAR(cte_max_recursion_depth=5)", "cte_max_recursion_depth"); +VARIABLE_VALUE +1000 +VARIABLE_VALUE +5 +VARIABLE_VALUE +1000 +DROP PROCEDURE test_hint; +# +# Bug#26482684 WL681: RESULT DIFF SEEN FOR SQL_SELECT_LIMIT HINT. +# +SELECT /*+ SET_VAR(sql_select_limit = 18446744073709551616) */ 1; +1 +1 +Warnings: +Warning 1064 A size parameter was incorrectly specified, either number or on the form 10M near '18446744073709551616) */ 1' at line 1 +SELECT /*+ SET_VAR(sql_select_limit = 18446744073709551615) */ 1; +1 +1 +# +# Bug#29776464 MAKE 'TIME_ZONE' VARIABLE OPTIMIZER HINT SETTABLE. +# +SET time_zone = '-01:00'; +SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP); +TIMEDIFF(NOW(), UTC_TIMESTAMP) +-01:00:00 +SELECT /*+ SET_VAR(time_zone = '+04:00') */ TIMEDIFF(NOW(), UTC_TIMESTAMP); +TIMEDIFF(NOW(), UTC_TIMESTAMP) +04:00:00 +SELECT @@time_zone; +@@time_zone +-01:00 +SELECT /*+ SET_VAR(time_zone = 'UTC') */ TIMEDIFF(NOW(), UTC_TIMESTAMP); +TIMEDIFF(NOW(), UTC_TIMESTAMP) +00:00:00 +SELECT @@time_zone; +@@time_zone +-01:00 +CREATE TABLE t1(f1 VARCHAR(10)); +INSERT INTO t1 VALUES (@@time_zone); +SELECT * FROM t1; +f1 +-01:00 +UPDATE /*+ SET_VAR(time_zone = 'UTC') */ t1 SET f1 = TIMEDIFF(NOW(), UTC_TIMESTAMP); +SELECT * FROM t1; +f1 +00:00:00 +INSERT /*+ SET_VAR(time_zone = 'UTC') */ t1 VALUES (TIMEDIFF(NOW(), UTC_TIMESTAMP)); +SELECT * FROM t1; +f1 +00:00:00 +00:00:00 +DELETE /*+ SET_VAR(time_zone = 'UTC') */ FROM t1 WHERE f1 = TIMEDIFF(NOW(), UTC_TIMESTAMP); +SELECT * FROM t1; +f1 +SELECT @@time_zone; +@@time_zone +-01:00 +DROP TABLE t1; +SET time_zone = default; diff --git a/mysql-test/r/opt_hints_subquery.result-pq b/mysql-test/r/opt_hints_subquery.result-pq new file mode 100644 index 000000000..fefd66164 --- /dev/null +++ b/mysql-test/r/opt_hints_subquery.result-pq @@ -0,0 +1,1885 @@ +# WL#8244 Hints for subquery execution +CREATE TABLE t1 (a INTEGER NOT NULL, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INTEGER NOT NULL, KEY (a)); +CREATE TABLE t3 (a INTEGER NOT NULL, b INT, KEY (a)); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40); +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (10,3), (20,4), (30,5); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +This query will normally use Table Pull-out +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Check that we can disable SEMIJOIN transformation +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Same with hint in outer query +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Query with two sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT a FROM t1 tx) +AND t3.b IN (SELECT a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +No SEMIJOIN transformation for first subquery +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 tx) +AND t3.b IN (SELECT a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY)))) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(`subq1`) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY)))) +No SEMIJOIN transformation for latter subquery +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT a FROM t1 tx) +AND t3.b IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#3`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@`subq2`) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +No SEMIJOIN transformation for any subquery +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ NO_SEMIJOIN() */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) NO_SEMIJOIN(@`select#3`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) NO_SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +Query with nested sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`ty`.`a` = `test`.`tx`.`b`)) +No SEMIJOIN transformation for outer subquery +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where +2 DEPENDENT SUBQUERY ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`tx`.`a` from `test`.`t1` `ty` join `test`.`t1` `tx` where ((`test`.`ty`.`a` = `test`.`tx`.`b`) and ((`test`.`t3`.`a`) = `test`.`tx`.`a`)))) +No SEMIJOIN transformation for inner-most subquery +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))) +No SEMIJOIN transformation at all +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY where (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))))) +This query does not support SEMIJOIN. SEMIJOIN hint is ignored +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`min(a)`))))) +This query will get LooseScan by default +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Let's turn off LooseScan, FirstMatch is then SELECTed +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Let's also turn off FirstMatch, MatLookup is then used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +Let's also turn off Materialization, DuplicateWeedout should then be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +If we turn off all strategies, DuplicateWeedout should still be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, MATERIALIZATION, +DUPSWEEDOUT) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Turn off non-used strategies, nothing should change. Still Loosescan +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Test same query with SEMIJOIN hint +Forcing LooseScan, should not change anything +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Force FirstMatch +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Force Materialization +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +Force DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +If LooseScan is among candidates, it will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, MATERIALIZATION, +DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Drop LooseScan from list of strategies, FirstMatch will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Drop FirstMatch, MatLookup is next +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +For this query LooseScan and Materialization is not applicable +EXPLAIN +SELECT * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +Turn off all applicable strategies. DuplicateWeedout should be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Similar with SEMIJOIN hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Test multiple subqueries. +Default for this query is Loosecan for first and FirstMatch for latter +EXPLAIN +SELECT * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Forcing the default strategy should not change anything +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Forcing a strategy for one, may change the other due to cost changes +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Forcing same strategy for both +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +2 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Loosescan for both is not possible, ends up with DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Swap strategies compared to default +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Different subsets of strategies for different subqueries +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) +SEMIJOIN(@subq2 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) SEMIJOIN(@`subq2` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Vice versa +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT) +SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION, DUPSWEEDOUT) SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Another combination +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, FIRSTMATCH) +SEMIJOIN(@subq2 LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) SEMIJOIN(@`subq2` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Turn off default +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) +NO_SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Also turn off 2nd choice. Gives DuplicateWeedout over both +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) +NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Also turn off DuplicateWeedout. Materialization is only one left. +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, DUPSWEEDOUT) +NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Force materialization with SEMIJOIN hints instead +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +This query gives DuplicateWeedout over both since combining +DuplicateWeedout with another strategy does not seem possible. +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +More alternatives for 2nd subquery gives Materialization for first +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 LOOSESCAN, FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +A query with nested subqueries which by default will use FirstMatch +EXPLAIN +SELECT * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Let's turn off FirstMatch, Materialization is then selected +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED t2 NULL ref a a 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = ``.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Let's also turn off Materialization, DuplicateWeedout is then used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Also turn off DuplicateWeedout. LooseScan not usable; so still DuplicateWeedout +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +If we turn off all strategies, DuplicateWeedout should still be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, MATERIALIZATION, +DUPSWEEDOUT) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Test same query with SEMIJOIN hint +Force FirstMatch, should not change anything +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Force LooseScan, will use DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Force Materialization +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED t2 NULL ref a a 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = ``.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Force DuplicateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +If FirstMatch is among candidates, it will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, LOOSESCAN, +DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Drop FirstMatch. Materialization will be used +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED t2 NULL ref a a 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = ``.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Drop Materialization, DuplicateWeedout next +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Strategy hints on inner-most query is ignored since sj-nests are merged +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Ditto +EXPLAIN +SELECT /*+ SEMIJOIN(@subq2 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using where +2 SIMPLE t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t3`.`b`)) +Turn off semijoin for outer subquery. FirstMatch is used for inner +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ref a a 4 func 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`b`) and ((`test`.`t1`.`a`) = `test`.`t3`.`a`)))) +Do not use FirstMatch for inner +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SUBQUERY NULL eq_ref 4 test.t3.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (``.`a` = `test`.`t3`.`b`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Do not use FirstMatch nor Materialization for inner +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) +NO_SEMIJOIN(@subq2 FIRSTMATCH, MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL ref a a 4 test.t3.b 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH, MATERIALIZATION) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t3`.`b`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +LooseScan is last resort +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) +NO_SEMIJOIN(@subq2 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Allow all stragies except default +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) +SEMIJOIN(@subq2 MATERIALIZATION, DUPSWEEDOUT, LOOSESCAN) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SUBQUERY NULL eq_ref 4 test.t3.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (``.`a` = `test`.`t3`.`b`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Force a particular strategy +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +Turn off semijoin for inner-most subquery. FirstMatch is used for outer +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 PRIMARY t3 NULL ref a a 4 test.t1.a 1 100.00 Using where; FirstMatch(t1) +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Do not use FirstMatch for outer +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 PRIMARY NULL eq_ref 4 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Do not use FirstMatch nor Materialization for outer +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) +NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 End temporary +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +LooseScan can not be used since index scan would not be "covering" +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) +NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 End temporary +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Allow all stragies except default +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT, LOOSESCAN) +NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 PRIMARY NULL eq_ref 4 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Force a particular strategy +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 DUPSWEEDOUT) NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 PRIMARY t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 End temporary +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))) +Turn off semijoin for both subqueries +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) NO_SEMIJOIN(@subq2) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 +WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL index_subquery a a 4 func 1 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2`) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(((`test`.`t1`.`a`) in t3 on a where (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t2 on a)))))) +Test hints with prepared statements +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) + NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) + AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +DEALLOCATE PREPARE stmt1; +Another Prepared Statement test +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 + WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2))"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 SUBQUERY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +2 SUBQUERY t3 NULL ALL a NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2` LOOSESCAN) NO_SEMIJOIN(@`subq1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` semi join (`test`.`t2`) where (`test`.`t3`.`b` = `test`.`t2`.`a`) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +DEALLOCATE PREPARE stmt1; +SET optimizer_switch = default; +Tests with non-default optimizer_switch settings +SET optimizer_switch = 'semijoin=off'; +No table pull-out for this query +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +This should not change anything +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Force semijoin +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Setting strategy should still force semijoin +Strategy is ignored since table pull-out is done +EXPLAIN +SELECT /*+ SEMIJOIN(@subq FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq` FIRSTMATCH) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Query with two sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT a FROM t1 tx) +AND t3.b IN (SELECT a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +SEMIJOIN transformation for first subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`t3`.`b`,(((`test`.`t3`.`b`) in t1 on PRIMARY)))) +SEMIJOIN transformation for latter subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY)))) +SEMIJOIN transformation for both subqueries +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1`) SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +Query with nested sub-queries +EXPLAIN +SELECT * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY where (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))))) +SEMIJOIN transformation for outer subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +1 PRIMARY tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY)))) +SEMIJOIN transformation for inner-most subquery +EXPLAIN +SELECT /*+ SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where +2 DEPENDENT SUBQUERY ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`tx`.`a` from `test`.`t1` `ty` join `test`.`t1` `tx` where ((`test`.`ty`.`a` = `test`.`tx`.`b`) and ((`test`.`t3`.`a`) = `test`.`tx`.`a`)))) +SEMIJOIN transformation for both +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1) SEMIJOIN(@subq2) */ * FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.tx.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq2`) SEMIJOIN(@`subq1`) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`tx`.`a` = `test`.`t3`.`a`) and (`test`.`ty`.`a` = `test`.`tx`.`b`)) +Test strategies when some are disabled by optimizer_switch +SET optimizer_switch='semijoin=on'; +SET optimizer_switch='loosescan=off'; +This query will get LooseScan by default. FirstMatch now. +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Let's turn off LooseScan also by hint, FirstMatch should still be SELECTed +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Let's also turn off FirstMatch, MatLookup should then be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +Let's also turn off Materialization, DuplicateWeedout should then be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Let's force LooseScan back on +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Forcing another strategy +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +1 SIMPLE NULL eq_ref 4 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +If LooseScan is among candidates, it is used even if originally disabled +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, MATERIALIZATION, +DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Disable another strategy +SET optimizer_switch='firstmatch=off'; +Turn on FirstMatch, but not LooseScan on with hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +Drop all remaining strategies with hint, should use DuplicateWeedout +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +For this query LooseScan and Materialization is not applicable +Should use DuplicateWeedout since FirstMatch is disabled +EXPLAIN +SELECT * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 25.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t3`.`b`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +Turn off all applicable strategies. DuplicateWeedout should still be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Reverse which strategies are allowed with hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +Default for this query is Loosecan for first and FirstMatch for latter +Since both strategies are disabled, will now use DuplicateWeedout +EXPLAIN +SELECT * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Allowing LooseScan and FirstMatch and optimizer_switch is ignored +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) +SEMIJOIN(@subq2 LOOSESCAN, FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Forcing a disabled strategy for one +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Forcing same strategy for both +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +2 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Swap strategies compared to default +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH) SEMIJOIN(@subq2 LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Different subsets of strategies for different subqueries +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) +SEMIJOIN(@subq2 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) SEMIJOIN(@`subq2` MATERIALIZATION, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +Turn off DuplicateWeedout for both. Materialization is left +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 DUPSWEEDOUT) +NO_SEMIJOIN(@subq2 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` DUPSWEEDOUT) NO_SEMIJOIN(@`subq2` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Forcing materialization should have same effect +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) +SEMIJOIN(@subq2 MATERIALIZATION) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` MATERIALIZATION) SEMIJOIN(@`subq2` MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Turn off DuplicateWeedout for first. Materialization is used for both +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +Turn off DuplicateWeedout for second. Same effect. +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq2 DUPSWEEDOUT) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 4 test.t1.a 1 100.00 NULL +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq2` DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = ``.`a`) and (``.`a` = `test`.`t1`.`a`)) +Enable all strategies except DuplicateWeedout +SET optimizer_switch='firstmatch=on,loosescan=on,materialization=on,duplicateweedout=off'; +If we turn off all other strategies, DuplicateWeedout will be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +LooseScan and Materialization is not applicable, FirstMatch is used +EXPLAIN +SELECT * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +Turn off all applicable strategies. DuplicateWeedout should be used +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Similar with SEMIJOIN hint +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Disable all strategies +SET optimizer_switch='firstmatch=off,loosescan=off,materialization=off,duplicateweedout=off'; +DuplicateWeedout is then used +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Turning off extra strategies should not change anything +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN, DUPSWEEDOUT) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 4 test.t3.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN, DUPSWEEDOUT) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +Turning on some strategies should give one of those +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 FIRSTMATCH, MATERIALIZATION) */ * +FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t3 NULL ref a a 4 test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +For this query that cannot use LooseScan or Materialization, +turning those on will still give DupliateWeedout +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, MATERIALIZATION) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((``.`b` = `test`.`t1`.`a`) and (``.`a` = `test`.`t1`.`b`)) +Turning on FirstMatch should give FirstMatch +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN, FIRSTMATCH) */ * FROM t1 +WHERE t1.b IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3 WHERE t3.b = t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +2 SIMPLE t3 NULL ref a a 4 test.t1.b 1 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +SET optimizer_switch = default; +Test that setting optimizer_switch after prepare will change strategy +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) + NO_SEMIJOIN(@subq2 FIRSTMATCH, LOOSESCAN) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) + AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +SET optimizer_switch = 'duplicateweedout=off'; +Will now use materialization +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 .a 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t1.b 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index +3 MATERIALIZED t2 NULL index a a 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = ``.`a`)) +SET optimizer_switch = 'duplicateweedout=on'; +Turn DuplicateWeedout back on +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` FIRSTMATCH, LOOSESCAN) NO_SEMIJOIN(@`subq2` FIRSTMATCH, LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +DEALLOCATE PREPARE stmt1; +SET optimizer_switch = default; +Specifying two SEMIJOIN/NO_SEMIJOIN for same query block gives warning +First has effect, second is ignored +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ NO_SEMIJOIN() SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Try opposite order +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SEMIJOIN() NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint NO_SEMIJOIN( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Specify at different levels, hint inside block has effect +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +Specify at different levels, opposite order +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Duplicate hints also gives warning, but hint has effect +EXPLAIN +SELECT /*+ SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Multiple subqueries with conflicting hints +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) NO_SEMIJOIN() */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) SEMIJOIN(LOOSESCAN) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 SUBQUERY t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated +Warning 3126 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`)))))) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) NO_SEMIJOIN(LOOSESCAN) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) SEMIJOIN(LOOSESCAN) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated +Warning 3126 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Conflicting hints in same hint comment +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 LOOSESCAN) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +EXPLAIN +SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 3126 Hint NO_SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`)) +Non-supported strategies should give warnings +EXPLAIN +SELECT /*+ SEMIJOIN(@subq1 INTOEXISTS) NO_SEMIJOIN(@subq2 INTOEXISTS) */ * +FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) +AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 3 100.00 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using where +1 SIMPLE t2 NULL ref a a 4 test.t1.b 1 100.00 Using index; FirstMatch(t1) +Warnings: +Warning 1064 Optimizer hint syntax error near 'INTOEXISTS) NO_SEMIJOIN(@subq2 INTOEXISTS) */ * +FROM t1 +WHERE t1.a IN (SELECT /*' at line 2 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t3`.`a`)) +SUBQUERY tests +SUBQUERY should disable SEMIJOIN and use specified subquery strategy +EXPLAIN +SELECT * FROM t2 WHERE t2.a IN (SELECT /*+ SUBQUERY(INTOEXISTS) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +Query with two subqueries +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 INTOEXISTS) SUBQUERY(@subq2 MATERIALIZATION) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +3 SUBQUERY ty NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq1` INTOEXISTS) SUBQUERY(@`subq2` MATERIALIZATION) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where ((`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY))) and (`test`.`t3`.`b`,`test`.`t3`.`b` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`ty`.`a` from `test`.`t1` `ty` where true ), (`test`.`t3`.`b` in on where ((`test`.`t3`.`b` = ``.`a`)))))) +Query with nested sub-queries +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 INTOEXISTS) SUBQUERY(@subq2 MATERIALIZATION) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY tx NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where +3 SUBQUERY ty NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq2` MATERIALIZATION) SUBQUERY(@`subq1` INTOEXISTS) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,(((`test`.`t3`.`a`) in t1 on PRIMARY where (`test`.`tx`.`b`,`test`.`tx`.`b` in ( (/* select#3 */ select /*+ QB_NAME(`subq2`) */ `test`.`ty`.`a` from `test`.`t1` `ty` where true ), (`test`.`tx`.`b` in on where ((`test`.`tx`.`b` = ``.`a`)))))))) +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 MATERIALIZATION) SUBQUERY(@subq2 INTOEXISTS) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx +WHERE tx.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY tx NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where +3 DEPENDENT SUBQUERY ty NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq2` INTOEXISTS) SUBQUERY(@`subq1` MATERIALIZATION) */ `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (`test`.`t3`.`a`,`test`.`t3`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`tx`.`a` from `test`.`t1` `tx` where (`test`.`tx`.`b`,(((`test`.`tx`.`b`) in t1 on PRIMARY))) ), (`test`.`t3`.`a` in on where ((`test`.`t3`.`a` = ``.`a`))))) +This query does not support SEMIJOIN. Materialization is default +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`min(a)`))))) +Use In-to-exists instead +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (min(`test`.`t1`.`a`))))) +For this query In-to-exists is default +EXPLAIN +SELECT a, a IN (SELECT a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) AS `a IN (SELECT a FROM t1)` from `test`.`t2` +Force Subquery Materialization +EXPLAIN +SELECT a, a IN (SELECT /*+ SUBQUERY(MATERIALIZATION) */ a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` MATERIALIZATION) */ `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) AS `a IN (SELECT /*+ SUBQUERY(MATERIALIZATION) */ a FROM t1)` from `test`.`t2` +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ a, +a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) AS `a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1)` from `test`.`t2` +This query does not support Subquery Materialization due to type mismatch +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ concat(sum(b),"") FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ concat(sum(`test`.`t1`.`b`),'') from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (concat(sum(`test`.`t1`.`b`),''))))) +Trying to force Subquery Materialization will not change anything +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ concat(sum(b),"") FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ concat(sum(`test`.`t1`.`b`),'') from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (concat(sum(`test`.`t1`.`b`),''))))) +Test hints with prepared statements +PREPARE stmt1 FROM "EXPLAIN +SELECT /*+ SUBQUERY(@subq1 MATERIALIZATION) + SUBQUERY(@subq2 INTOEXISTS) */ * FROM t1 +WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3) + AND t1.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2)"; +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +2 SUBQUERY t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq1` MATERIALIZATION) SUBQUERY(@`subq2` INTOEXISTS) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) and (`test`.`t1`.`b`,(((`test`.`t1`.`b`) in t2 on a)))) +EXECUTE stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index +2 SUBQUERY t3 NULL index a a 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq1` MATERIALIZATION) SUBQUERY(@`subq2` INTOEXISTS) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq1`) */ `test`.`t3`.`a` from `test`.`t3` where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) and (`test`.`t1`.`b`,(((`test`.`t1`.`b`) in t2 on a)))) +DEALLOCATE PREPARE stmt1; +Test optimizer_switch settings with SUBQUERY hint +SET optimizer_switch='materialization=off'; +This query will now use In-to-exist +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having ((`test`.`t2`.`a`) = (min(`test`.`t1`.`a`))))) +Force it to use Materialization +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) */ min(a) FROM t1 group by a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`min(a)`))))) +SET optimizer_switch='materialization=on,subquery_materialization_cost_based=off'; +This query will now use materialization +EXPLAIN +SELECT a, a IN (SELECT a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) AS `a IN (SELECT a FROM t1)` from `test`.`t2` +Force In-to-exists +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ a, +a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a`,(`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) AS `a IN (SELECT /*+ QB_NAME(subq) */ a FROM t1)` from `test`.`t2` +Specifying both strategies should give a warning +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 MATERIALIZATION, INTOEXISTS) +SUBQUERY(@subq2 MATERIALIZATION, INTOEXISTS) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Warning 1064 Optimizer hint syntax error near ', INTOEXISTS) +SUBQUERY(@subq2 MATERIALIZATION, INTOEXISTS) */ * +FROM t3 +WHERE t3' at line 2 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +Non-supported strategies should give warnings +EXPLAIN +SELECT /*+ SUBQUERY(@subq1 FIRSTMATCH) SUBQUERY(@subq2 LOOSESCAN) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t1 tx) +AND t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t1 ty); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL a NULL NULL NULL 3 100.00 Using where +2 SIMPLE tx NULL eq_ref PRIMARY PRIMARY 4 test.t3.a 1 100.00 Using index +2 SIMPLE ty NULL eq_ref PRIMARY PRIMARY 4 test.t3.b 1 100.00 Using index +Warnings: +Warning 1064 Optimizer hint syntax error near 'FIRSTMATCH) SUBQUERY(@subq2 LOOSESCAN) */ * +FROM t3 +WHERE t3.a IN (SELECT /*+ QB' at line 2 +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` `tx` join `test`.`t1` `ty` join `test`.`t3` where ((`test`.`ty`.`a` = `test`.`t3`.`b`) and (`test`.`tx`.`a` = `test`.`t3`.`a`)) +SET optimizer_switch= default; +Specifying two SUBQUERY for same query block gives warning +First has effect, second is ignored +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SUBQUERY(MATERIALIZATION) SUBQUERY(INTOEXISTS) */ a +FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY( INTOEXISTS) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +Try opposite order +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SUBQUERY(INTOEXISTS) SUBQUERY(MATERIALIZATION) */ a +FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY( MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Specify at different levels, hint inside block has effect +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SUBQUERY(INTOEXISTS) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Specify at different levels, opposite order +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SUBQUERY(MATERIALIZATION) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 SUBQUERY t1 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +Specifying combinations of SUBQUERY and SEMIJOIN/NO_SEMIJOIN +for same query block gives warning +First has effect, second is ignored +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ SUBQUERY(INTOEXISTS) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN( ) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Try opposite order +EXPLAIN +SELECT * FROM t2 +WHERE t2.a IN (SELECT /*+ NO_SEMIJOIN() SUBQUERY(MATERIALIZATION) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY( MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +Specify at different levels, hint inside block has effect +EXPLAIN +SELECT /*+ SUBQUERY(@subq MATERIALIZATION) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +EXPLAIN +SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) NO_SEMIJOIN() */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +EXPLAIN +SELECT /*+ SEMIJOIN(@subq FIRSTMATCH) */ * FROM t2 +WHERE t2.a IN (SELECT /*+ QB_NAME(subq) SUBQUERY(@subq INTOEXISTS) */ a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL index NULL a 4 NULL 4 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +Warnings: +Warning 3126 Hint SEMIJOIN(@`subq` FIRSTMATCH) is ignored as conflicting/duplicated +Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(((`test`.`t2`.`a`) in t1 on PRIMARY))) +drop table t1, t2, t3; diff --git a/mysql-test/r/order_by_all.result-pq b/mysql-test/r/order_by_all.result-pq new file mode 100644 index 000000000..0497a732a --- /dev/null +++ b/mysql-test/r/order_by_all.result-pq @@ -0,0 +1,3396 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(6) DEFAULT '0' NOT NULL, +idservice int(5), +clee char(20) NOT NULL, +flag char(1), +KEY id (id), +PRIMARY KEY (clee) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,4,'6067169d','Y'); +INSERT INTO t1 VALUES (2,5,'606716d1','Y'); +INSERT INTO t1 VALUES (2,1,'606717c1','Y'); +INSERT INTO t1 VALUES (3,1,'6067178d','Y'); +INSERT INTO t1 VALUES (2,6,'60671515','Y'); +INSERT INTO t1 VALUES (2,7,'60671569','Y'); +INSERT INTO t1 VALUES (2,3,'dd','Y'); +CREATE TABLE t2 ( +id int(6) NOT NULL auto_increment, +description varchar(40) NOT NULL, +idform varchar(40), +ordre int(6) unsigned DEFAULT '0' NOT NULL, +image varchar(60), +PRIMARY KEY (id), +KEY id (id,ordre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'Emettre un appel d''offres','en_construction.html',10,'emettre.gif'); +INSERT INTO t2 VALUES (2,'Emettre des soumissions','en_construction.html',20,'emettre.gif'); +INSERT INTO t2 VALUES (7,'Liste des t2','t2_liste_form.phtml',51060,'link.gif'); +INSERT INTO t2 VALUES (8,'Consulter les soumissions','consulter_soumissions.phtml',200,'link.gif'); +INSERT INTO t2 VALUES (9,'Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif'); +INSERT INTO t2 VALUES (10,'Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 VALUES (3,'Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 VALUES (4,'Modifier des clients','en_construction.html',40010,'link.gif'); +INSERT INTO t2 VALUES (5,'Effacer des clients','en_construction.html',40020,'link.gif'); +INSERT INTO t2 VALUES (6,'Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif'); +select t1.id,t1.idservice,t2.ordre,t2.description from t1, t2 where t1.id = 2 and t1.idservice = t2.id order by t2.ordre; +id idservice ordre description +2 1 10 Emettre un appel d'offres +2 3 40000 Créer une fiche de client +2 4 40010 Modifier des clients +2 5 40020 Effacer des clients +2 6 51050 Ajouter un service +2 7 51060 Liste des t2 +drop table t1,t2; +create table t1 (first char(10),last char(10)); +insert into t1 values ("Michael","Widenius"); +insert into t1 values ("Allan","Larsson"); +insert into t1 values ("David","Axmark"); +select concat(first," ",last) as name from t1 order by name; +name +Allan Larsson +David Axmark +Michael Widenius +select concat(last," ",first) as name from t1 order by name; +name +Axmark David +Larsson Allan +Widenius Michael +drop table t1; +create table t1 (i int); +insert into t1 values(1),(2),(1),(2),(1),(2),(3); +select distinct i from t1; +i +1 +2 +3 +select distinct i from t1 order by rand(5); +i +1 +2 +3 +select distinct i from t1 order by i desc; +i +3 +2 +1 +select distinct i from t1 order by 1-i; +i +3 +2 +1 +select distinct i from t1 order by mod(i,2),i; +i +2 +1 +3 +drop table t1; +create table t1 ( pk int primary key, name varchar(255) not null, number varchar(255) not null); +insert into t1 values (1, 'Gamma', '123'), (2, 'Gamma Ext', '123a'), (3, 'Alpha', '001'), (4, 'Beta', '200c'); +select distinct t1.name as 'Building Name',t1.number as 'Building Number' from t1 order by t1.name asc; +Building Name Building Number +Alpha 001 +Beta 200c +Gamma 123 +Gamma Ext 123a +drop table t1; +create table t1 (id int not null,col1 int not null,col2 int not null,index(col1)); +insert into t1 values(1,2,2),(2,2,1),(3,1,2),(4,1,1),(5,1,4),(6,2,3),(7,3,1),(8,2,4); +select * from t1 order by col1,col2; +id col1 col2 +4 1 1 +3 1 2 +5 1 4 +2 2 1 +1 2 2 +6 2 3 +8 2 4 +7 3 1 +select col1 from t1 order by id; +col1 +2 +2 +1 +1 +1 +2 +3 +2 +select col1 as id from t1 order by id; +id +1 +1 +1 +2 +2 +2 +2 +3 +select concat(col1) as id from t1 order by id; +id +1 +1 +1 +2 +2 +2 +2 +3 +drop table t1; +CREATE TABLE t1 (id int auto_increment primary key,aika varchar(40),aikakentta timestamp); +insert into t1 (aika) values ('Keskiviikko'); +insert into t1 (aika) values ('Tiistai'); +insert into t1 (aika) values ('Maanantai'); +insert into t1 (aika) values ('Sunnuntai'); +SELECT FIELD(SUBSTRING(t1.aika,1,2),'Ma','Ti','Ke','To','Pe','La','Su') AS test FROM t1 ORDER by test; +test +1 +2 +3 +7 +drop table t1; +CREATE TABLE t1 +( +a int unsigned NOT NULL, +b int unsigned NOT NULL, +c int unsigned NOT NULL, +UNIQUE(a), +INDEX(b), +INDEX(c) +); +CREATE TABLE t2 +( +c int unsigned NOT NULL, +i int unsigned NOT NULL, +INDEX(c) +); +CREATE TABLE t3 +( +c int unsigned NOT NULL, +v varchar(64), +INDEX(c) +); +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t1 VALUES (2,1,2); +INSERT INTO t1 VALUES (3,2,1); +INSERT INTO t1 VALUES (4,2,2); +INSERT INTO t2 VALUES (1,50); +INSERT INTO t2 VALUES (2,25); +INSERT INTO t3 VALUES (1,'123 Park Place'); +INSERT INTO t3 VALUES (2,'453 Boardwalk'); +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 USING(c) +LEFT JOIN t3 ON t3.c = t1.c; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 USING(c) +LEFT JOIN t3 ON t3.c = t1.c +ORDER BY a; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c +ORDER BY a; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +drop table t1,t2,t3; +create table t1 (ID int not null primary key, TransactionID int not null); +insert into t1 (ID, TransactionID) values (1, 87), (2, 89), (3, 92), (4, 94), (5, 486), (6, 490), (7, 753), (9, 828), (10, 832), (11, 834), (12, 840); +create table t2 (ID int not null primary key, GroupID int not null); +insert into t2 (ID, GroupID) values (87, 87), (89, 89), (92, 92), (94, 94), (486, 486), (490, 490),(753, 753), (828, 828), (832, 832), (834, 834), (840, 840); +create table t3 (ID int not null primary key, DateOfAction date not null); +insert into t3 (ID, DateOfAction) values (87, '1999-07-19'), (89, '1999-07-19'), (92, '1999-07-19'), (94, '1999-07-19'), (486, '1999-07-18'), (490, '2000-03-27'), (753, '2000-03-28'), (828, '1999-07-27'), (832, '1999-07-27'),(834, '1999-07-27'), (840, '1999-07-27'); +select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t3.DateOfAction, t1.TransactionID; +DateOfAction TransactionID +1999-07-18 486 +1999-07-19 87 +1999-07-19 89 +1999-07-19 92 +1999-07-19 94 +1999-07-27 828 +1999-07-27 832 +1999-07-27 834 +1999-07-27 840 +2000-03-27 490 +2000-03-28 753 +select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t1.TransactionID,t3.DateOfAction; +DateOfAction TransactionID +1999-07-19 87 +1999-07-19 89 +1999-07-19 92 +1999-07-19 94 +1999-07-18 486 +2000-03-27 490 +2000-03-28 753 +1999-07-27 828 +1999-07-27 832 +1999-07-27 834 +1999-07-27 840 +drop table t1,t2,t3; +CREATE TABLE t1 ( +member_id int(11) NOT NULL auto_increment, +inschrijf_datum varchar(20) NOT NULL default '', +lastchange_datum varchar(20) NOT NULL default '', +nickname varchar(20) NOT NULL default '', +password varchar(8) NOT NULL default '', +voornaam varchar(30) NOT NULL default '', +tussenvoegsels varchar(10) NOT NULL default '', +achternaam varchar(50) NOT NULL default '', +straat varchar(100) NOT NULL default '', +postcode varchar(10) NOT NULL default '', +wijk varchar(40) NOT NULL default '', +plaats varchar(50) NOT NULL default '', +telefoon varchar(10) NOT NULL default '', +geboortedatum date NOT NULL default '0000-00-00', +geslacht varchar(5) NOT NULL default '', +email varchar(80) NOT NULL default '', +uin varchar(15) NOT NULL default '', +homepage varchar(100) NOT NULL default '', +internet varchar(15) NOT NULL default '', +scherk varchar(30) NOT NULL default '', +favo_boek varchar(50) NOT NULL default '', +favo_tijdschrift varchar(50) NOT NULL default '', +favo_tv varchar(50) NOT NULL default '', +favo_eten varchar(50) NOT NULL default '', +favo_muziek varchar(30) NOT NULL default '', +info text NOT NULL default '', +ipnr varchar(30) NOT NULL default '', +PRIMARY KEY (member_id) +) charset utf8mb4 ENGINE=MyISAM PACK_KEYS=1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'info' can't have a default value +insert into t1 (member_id) values (1),(2),(3); +select member_id, nickname, voornaam FROM t1 +ORDER by lastchange_datum DESC LIMIT 2; +member_id nickname voornaam +1 +2 +drop table t1; +create table t1 (a int not null, b int, c varchar(10), key (a, b, c)) charset utf8mb4; +insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 52 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` is null)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc +select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; +a b c +1 NULL b +explain select * from t1 where a >= 1 and a < 3 order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 52 NULL 11 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3)) order by `test`.`t1`.`a` desc +explain format=json select * from t1 where a >= 1 and a < 3 order by a desc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.35" + }, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.10", + "prefix_cost": "1.35", + "data_read_per_join": "616" + }, + "used_columns": [ + "a", + "b", + "c" + ], + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ], + "key_length": "52", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "backward_index_scan": true, + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.10", + "prefix_cost": "1.35", + "data_read_per_join": "616" + }, + "used_columns": [ + "a", + "b", + "c" + ], + "attached_condition": "((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3))" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3)) order by `test`.`t1`.`a` desc +select * from t1 where a >= 1 and a < 3 order by a desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +explain select * from t1 where a = 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 4 const 6 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` = 1) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a = 1 order by a desc, b desc; +a b c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +explain select * from t1 where a = 1 and b is null order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 9 const,const 2 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a = 1 and b is null order by a desc, b desc; +a b c +1 NULL NULL +1 NULL b +explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 9 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 5 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b is null order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 9 const,const 1 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and (b is null or b > 0) order by a +desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 9 NULL 6 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`b` is null) or (`test`.`t1`.`b` > 0))) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b > 0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 5 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b < 2 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` < 2)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 1 order by b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 4 const 6 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` = 1) order by `test`.`t1`.`b` desc +select * from t1 where a = 1 order by b desc; +a b c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +alter table t1 modify b int not null, modify c varchar(10) not null; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'c' at row 3 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 order by a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` +select * from t1 order by a, b, c; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +1 3 b +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +explain select * from t1 order by a desc, b desc, c desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc,`test`.`t1`.`c` desc +select * from t1 order by a desc, b desc, c desc; +a b c +2 3 c +2 2 b +2 2 a +2 1 b +2 1 a +1 3 b +1 1 b +1 1 b +1 1 +1 0 b +1 0 +explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 50 NULL 3 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc +select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; +a b c +1 1 b +1 1 b +explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 4 NULL 6 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` < 2) and (`test`.`t1`.`b` <= 1)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a < 2 and b <= 1 order by a desc, b desc; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +select count(*) from t1 where a < 5 and b > 0; +count(*) +9 +select * from t1 where a < 5 and b > 0 order by a desc,b desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 +1 1 b +1 1 b +1 3 b +explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 33.33 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 50 NULL 11 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` between 1 and 3) and (`test`.`t1`.`b` <= 1)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; +a b c +2 1 a +2 1 b +1 0 +1 0 b +1 1 +1 1 b +1 1 b +explain select * from t1 where a between 0 and 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 4 NULL 6 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` between 0 and 1) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a between 0 and 1 order by a desc, b desc; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +1 3 b +drop table t1; +CREATE TABLE t1 ( +gid int(10) unsigned NOT NULL auto_increment, +cid smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (gid), +KEY component_id (cid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (103853,108),(103867,108),(103962,108),(104505,108),(104619,108),(104620,108); +ALTER TABLE t1 add skr int(10) not null; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +gid int(10) unsigned NOT NULL default '0', +uid smallint(5) unsigned NOT NULL default '1', +sid tinyint(3) unsigned NOT NULL default '1', +PRIMARY KEY (gid), +KEY uid (uid), +KEY status_id (sid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (103853,250,5),(103867,27,5),(103962,27,5),(104505,117,5),(104619,75,5),(104620,15,5); +CREATE TABLE t3 ( +uid smallint(6) NOT NULL auto_increment, +PRIMARY KEY (uid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(15),(27),(75),(117),(250); +ALTER TABLE t3 add skr int(10) not null; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +gid sid uid +104620 5 15 +103867 5 27 +103962 5 27 +104619 5 75 +104505 5 117 +103853 5 250 +select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +gid sid uid +104620 5 15 +103867 5 27 +103962 5 27 +104619 5 75 +104505 5 117 +103853 5 250 +EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 2 NULL 6 100.00 Using index; Using temporary; Using filesort +1 SIMPLE t2 NULL ref PRIMARY,uid uid 2 test.t3.uid 1 100.00 Using index condition +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.gid 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t2`.`sid` AS `sid`,`test`.`t3`.`uid` AS `uid` from `test`.`t3` join `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`gid` = `test`.`t2`.`gid`) and (`test`.`t2`.`uid` = `test`.`t3`.`uid`)) order by `test`.`t1`.`gid`,`test`.`t3`.`uid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`gid` = `test`.`t3`.`uid`) order by `test`.`t1`.`gid`,`test`.`t3`.`skr` +EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,uid NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.gid 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t2`.`sid` AS `sid`,`test`.`t3`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` join `test`.`t3` where ((`test`.`t1`.`gid` = `test`.`t2`.`gid`) and (`test`.`t2`.`uid` = `test`.`t3`.`uid`)) order by `test`.`t3`.`uid`,`test`.`t1`.`gid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`gid` = `test`.`t3`.`uid`) order by `test`.`t3`.`skr`,`test`.`t1`.`gid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 2 test.t1.skr 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`skr` = `test`.`t3`.`uid`) order by `test`.`t1`.`gid`,`test`.`t3`.`skr` +drop table t1,t2,t3; +CREATE TABLE t1 ( +`titre` char(80) NOT NULL default '', +`numeropost` mediumint(8) unsigned NOT NULL auto_increment, +`date` datetime NOT NULL default '0000-00-00 00:00:00', +`auteur` char(35) NOT NULL default '', +`icone` tinyint(2) unsigned NOT NULL default '0', +`lastauteur` char(35) NOT NULL default '', +`nbrep` smallint(6) unsigned NOT NULL default '0', +`dest` char(35) NOT NULL default '', +`lu` tinyint(1) unsigned NOT NULL default '0', +`vue` mediumint(8) unsigned NOT NULL default '0', +`ludest` tinyint(1) unsigned NOT NULL default '0', +`ouvert` tinyint(1) unsigned NOT NULL default '1', +PRIMARY KEY (`numeropost`), +KEY `date` (`date`), +KEY `dest` (`dest`,`ludest`), +KEY `auteur` (`auteur`,`lu`), +KEY `auteur_2` (`auteur`,`date`), +KEY `dest_2` (`dest`,`date`) +) CHECKSUM=1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +`numeropost` mediumint(8) unsigned NOT NULL default '0', +`pseudo` char(35) NOT NULL default '', +PRIMARY KEY (`numeropost`,`pseudo`), +KEY `pseudo` (`pseudo`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (titre,auteur,dest) VALUES ('test','joce','bug'); +INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug'); +SELECT titre,t1.numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +drop table t1,t2; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (3, 4); +INSERT INTO t1 VALUES (5, NULL); +SELECT * FROM t1 ORDER BY b; +a b +5 NULL +1 2 +3 4 +SELECT * FROM t1 ORDER BY b DESC; +a b +3 4 +1 2 +5 NULL +SELECT * FROM t1 ORDER BY (a + b); +a b +5 NULL +1 2 +3 4 +SELECT * FROM t1 ORDER BY (a + b) DESC; +a b +3 4 +1 2 +5 NULL +DROP TABLE t1; +create table t1(id int not null auto_increment primary key, t char(12)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select id,t from t1 order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`t` AS `t` from `test`.`t1` order by `test`.`t1`.`id` +explain select id,t from t1 force index (primary) order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`t` AS `t` from `test`.`t1` FORCE INDEX (PRIMARY) order by `test`.`t1`.`id` +drop table t1; +CREATE TABLE t1 ( +FieldKey varchar(36) NOT NULL default '', +LongVal bigint(20) default NULL, +StringVal mediumtext, +KEY FieldKey (FieldKey), +KEY LongField (FieldKey,LongVal), +KEY StringField (FieldKey,StringVal(32)) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3'); +EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref FieldKey,LongField,StringField LongField 146 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` = '1') order by `test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +FieldKey LongVal StringVal +1 0 2 +1 1 3 +1 2 1 +EXPLAIN SELECT * FROM t1 ignore index (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range StringField StringField 146 NULL 3 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` IGNORE INDEX (`LongField`) IGNORE INDEX (`FieldKey`) where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range FieldKey,LongField,StringField LongField 146 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`FieldKey`,`test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; +CREATE TABLE t1 ( id smallint(6) unsigned NOT NULL default '0', menu tinyint(4) NOT NULL default '0', KEY id (id), KEY menu (menu)) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (11384, 2),(11392, 2); +SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ; +id +11392 +drop table t1; +create table t1(a int, b int, index(b)); +insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where b=1 or b is null order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null b b 5 const 4 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) or (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` +explain format=tree select * from t1 where b=1 or b is null order by a; +EXPLAIN +-> Sort: t1.a (cost=0.90 rows=4) + -> Index lookup on t1 using b (b=1 or NULL), with index condition: ((t1.b = 1) or (t1.b is null)) + +select * from t1 where b=1 or b is null order by a; +a b +1 1 +2 1 +3 NULL +4 NULL +explain select * from t1 where b=2 or b is null order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null b b 5 const 4 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 2) or (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` +select * from t1 where b=2 or b is null order by a; +a b +3 NULL +4 NULL +5 2 +6 2 +drop table t1; +create table t1 (a int not null auto_increment, b int not null, c int not null, d int not null, +key(a,b,d), key(c,b,a)); +create table t2 like t1; +insert into t1 values (NULL, 1, 2, 0), (NULL, 2, 1, 1), (NULL, 3, 4, 2), (NULL, 4, 3, 3); +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +set @row=10; +insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select * from t1 where a=1 and b in (1) order by c, b, a; +a b c d +1 1 2 0 +1 1 12 -1 +1 1 52 -5 +1 1 92 -9 +select * from t1 where a=1 and b in (1); +a b c d +1 1 12 -1 +1 1 2 0 +1 1 52 -5 +1 1 92 -9 +drop table t1, t2; +create table t1 (col1 int, col int); +create table t2 (col2 int, col int); +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1,3),(2,2),(3,1); +select t1.* , t2.col as t2_col from t1 left join t2 on (t1.col1=t2.col2) +order by col; +col1 col t2_col +1 1 3 +2 2 2 +3 3 1 +select col1 as col, col from t1 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select col1 from t1, t2 where t1.col1=t2.col2 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as t1_col, t2.col from t1, t2 where t1.col1=t2.col2 +order by col; +t1_col col +3 1 +2 2 +1 3 +select col2 as c, col as c from t2 order by col; +c c +3 1 +2 2 +1 3 +select col2 as col, col as col2 from t2 order by col; +col col2 +1 3 +2 2 +3 1 +select t2.col2, t2.col, t2.col from t2 order by col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +select t2.col2 as col from t2 order by t2.col; +col +3 +2 +1 +select t2.col2 as col, t2.col from t2 order by t2.col; +col col +3 1 +2 2 +1 3 +select t2.col2, t2.col, t2.col from t2 order by t2.col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +drop table t1, t2; +create table t1 (a char(25)) charset latin1; +insert into t1 set a = repeat('x', 20); +insert into t1 set a = concat(repeat('x', 19), 'z'); +insert into t1 set a = concat(repeat('x', 19), 'ab'); +insert into t1 set a = concat(repeat('x', 19), 'aa'); +set max_sort_length=20; +select a from t1 order by a; +a +xxxxxxxxxxxxxxxxxxxaa +xxxxxxxxxxxxxxxxxxxab +xxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxz +drop table t1; +create table t1 ( +`sid` decimal(8,0) default null, +`wnid` varchar(11) not null default '', +key `wnid14` (`wnid`(4)), +key `wnid` (`wnid`) +) engine=myisam default charset=latin1; +insert into t1 (`sid`, `wnid`) values +('10100','01019000000'),('37986','01019000000'),('37987','01019010000'), +('39560','01019090000'),('37989','01019000000'),('37990','01019011000'), +('37991','01019011000'),('37992','01019019000'),('37993','01019030000'), +('37994','01019090000'),('475','02070000000'),('25253','02071100000'), +('25255','02071100000'),('25256','02071110000'),('25258','02071130000'), +('25259','02071190000'),('25260','02071200000'),('25261','02071210000'), +('25262','02071290000'),('25263','02071300000'),('25264','02071310000'), +('25265','02071310000'),('25266','02071320000'),('25267','02071320000'), +('25269','02071330000'),('25270','02071340000'),('25271','02071350000'), +('25272','02071360000'),('25273','02071370000'),('25281','02071391000'), +('25282','02071391000'),('25283','02071399000'),('25284','02071400000'), +('25285','02071410000'),('25286','02071410000'),('25287','02071420000'), +('25288','02071420000'),('25291','02071430000'),('25290','02071440000'), +('25292','02071450000'),('25293','02071460000'),('25294','02071470000'), +('25295','02071491000'),('25296','02071491000'),('25297','02071499000'); +explain select * from t1 where wnid like '0101%' order by wnid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range wnid14,wnid wnid 13 NULL 10 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sid` AS `sid`,`test`.`t1`.`wnid` AS `wnid` from `test`.`t1` where (`test`.`t1`.`wnid` like '0101%') order by `test`.`t1`.`wnid` +select * from t1 where wnid like '0101%' order by wnid; +sid wnid +10100 01019000000 +37986 01019000000 +37989 01019000000 +37987 01019010000 +37990 01019011000 +37991 01019011000 +37992 01019019000 +37993 01019030000 +39560 01019090000 +37994 01019090000 +drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +a +1 +1 +1 +2 +2 +(SELECT a FROM t1) ORDER BY a; +a +1 +1 +1 +2 +2 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10); +(SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a; +b a +10 1 +10 2 +20 1 +20 2 +30 1 +30 2 +(SELECT b FROM t1 ORDER BY b DESC) ORDER BY b ASC; +b +10 +10 +20 +20 +30 +30 +(SELECT b,a FROM t1 ORDER BY b,a) ORDER BY a,b; +b a +10 1 +20 1 +30 1 +10 2 +20 2 +30 2 +(SELECT b,a FROM t1 ORDER by b,a LIMIT 3) ORDER by a,b; +b a +10 1 +20 1 +10 2 +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT a + 1 AS num FROM t1 ORDER BY 30 - num; +num +3 +2 +SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str); +str +test1 +test2 +SELECT a + 1 AS num FROM t1 GROUP BY 30 - num; +num +2 +3 +SELECT a + 1 AS num FROM t1 HAVING 30 - num; +num +2 +3 +SELECT a + 1 AS num, num + 1 FROM t1; +ERROR 42S22: Unknown column 'num' in 'field list' +SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1; +num (select num + 2 FROM t1 LIMIT 1) +2 4 +3 5 +SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; +ERROR 42S22: Unknown column 'num' in 'on clause' +DROP TABLE t1; +CREATE TABLE bug25126 ( +val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +); +UPDATE bug25126 SET MissingCol = MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET val = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = val ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +DROP TABLE bug25126; +CREATE TABLE t1 (a int); +SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1; +val val1 +SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val; +ERROR 23000: Column 'val' in order clause is ambiguous +SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1; +ERROR 23000: Column 'val' in order clause is ambiguous +DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (2), (4), (1); +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a NOT IN (2,3), a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a NOT BETWEEN 2 AND 3, a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, x2; +x1 x2 + 3 + 4 +1 +2 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, IF(a NOT IN (1,2), a, ''); +x1 x2 + 3 + 4 +1 +2 +SELECT a, a IN (1,2) FROM t1 ORDER BY a IN (1,2); +a a IN (1,2) +3 0 +4 0 +2 1 +1 1 +SELECT a FROM t1 ORDER BY a IN (1,2); +a +3 +4 +2 +1 +SELECT a+10 FROM t1 ORDER BY a IN (1,2); +a+10 +13 +14 +12 +11 +SELECT a, IF(a IN (1,2), a, a+10) FROM t1 +ORDER BY IF(a IN (3,4), a, a+10); +a IF(a IN (1,2), a, a+10) +3 13 +4 14 +1 1 +2 2 +DROP TABLE t1; +create table t1 (a int not null, b int not null, c int not null); +insert t1 values (1,1,1),(1,1,2),(1,2,1); +select a, b from t1 group by a, b order by sum(c); +a b +1 2 +1 1 +drop table t1; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze Error Table 'test.t2' doesn't exist +test.t2 analyze status Operation failed +explain SELECT t1.b as a, t2.b as c FROM +t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `a`,`test`.`t2`.`b` AS `c` from `test`.`t1` left join `test`.`t1` `t2` on(((`test`.`t1`.`a` = 2) and (`test`.`t2`.`a` = 2))) where true order by `c` +SELECT t2.b as c FROM +t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +c +NULL +NULL +2 +explain SELECT t1.b as a, t2.b as c FROM +t1 JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `a`,'2' AS `c` from `test`.`t1` join `test`.`t1` `t2` where true order by `c` +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * from t1; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 SELECT * from t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t4 SELECT * from t1; +INSERT INTO t1 values (0,0),(4,4); +SELECT t2.b FROM t1 LEFT JOIN (t2, t3 LEFT JOIN t4 ON t3.a=t4.a) +ON (t1.a=t2.a AND t1.b=t3.b) order by t2.b; +b +NULL +NULL +1 +2 +3 +DROP TABLE t1,t2,t3,t4; +create table t1 (a int, b int, c int); +insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9); +select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc; +a ratio +1 0.5000 +19 1.3333 +9 2.6667 +drop table t1; +CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME); +INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10); +UPDATE t1 SET b = SEC_TO_TIME(a); +SELECT a, b FROM t1 ORDER BY b DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b)); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT, KEY a (a,b)); +INSERT INTO t2 VALUES (1,1),(1,2),(2,1),(2,2); +EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY,b b 5 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY,b b 5 const 1 100.00 Using index +2 SIMPLE t2 NULL ref a a 5 const 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = '2')) order by `test`.`t2`.`b` +DROP TABLE t1,t2; +CREATE TABLE t1( +id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3)); +INSERT INTO t1 (c2,c3) VALUES +(31,34),(35,38),(34,31),(32,35),(31,39), +(11,14),(15,18),(14,11),(12,15),(11,19); +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +UPDATE t1 SET c2=20 WHERE id%100 = 0; +SELECT COUNT(*) FROM t1; +COUNT(*) +40960 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * FROM t1 ORDER BY id; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL index k2 k3 5 NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` = 11) order by `test`.`t2`.`c3` limit 20 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8192 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ref k2 k2 5 const 8192 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` = 11) order by `test`.`t2`.`c3` limit 4000 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 40 50.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL index k2 k3 5 NULL 40 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` between 10 and 12) order by `test`.`t2`.`c3` limit 20 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 409 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range k2 k2 5 NULL 409 100.00 Using index condition; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` between 20 and 30) order by `test`.`t2`.`c3` limit 4000 +SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +id c3 +6 14 +16 14 +31 14 +41 14 +62 14 +72 14 +82 14 +92 14 +125 14 +135 14 +145 14 +155 14 +165 14 +175 14 +185 14 +195 14 +252 14 +262 14 +272 14 +282 14 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a INT, +b INT, +PRIMARY KEY (a), +KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY, ab) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,ab PRIMARY 4 NULL 128 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR GROUP BY (`ab`) IGNORE INDEX FOR GROUP BY (PRIMARY) group by `test`.`t1`.`a` +flush status; +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY, ab) GROUP BY a; +a +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +13 +14 +15 +16 +17 +18 +19 +2 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY, ab) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 128 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR ORDER BY (`ab`) IGNORE INDEX FOR ORDER BY (PRIMARY) order by `test`.`t1`.`a` +flush status; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +flush status; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`ab`) IGNORE INDEX (PRIMARY) group by `test`.`t1`.`a` +SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) GROUP BY a; +a +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +13 +14 +15 +16 +17 +18 +19 +2 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`ab`) IGNORE INDEX (PRIMARY) order by `test`.`t1`.`a` +SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +DROP TABLE t1; +# +# Bug#31590: Wrong error message on sort buffer being too small. +# +create table t1(a int, b text); +insert into t1 values (1,REPEAT('x', 60000)),(3,REPEAT('y', 60000)); +set session sort_buffer_size= 32768; +CALL mtr.add_suppression("Out of sort memory"); +select * from t1 order by b; +ERROR HY001: Out of sort memory, consider increasing server sort buffer size +drop table t1; +call mtr.add_suppression("Out of sort memory; increase server sort buffer size"); +# +# Bug #39844: Query Crash Mysql Server 5.0.67 +# +CREATE TABLE t1 (a INT PRIMARY KEY); +CREATE TABLE t2 (a INT PRIMARY KEY, b INT); +CREATE TABLE t3 (c INT); +INSERT INTO t1 (a) VALUES (1), (2); +INSERT INTO t2 (a,b) VALUES (1,2), (2,3); +INSERT INTO t3 (c) VALUES (1), (2); +SELECT +(SELECT t1.a FROM t1, t2 WHERE t1.a = t2.b AND t2.a = t3.c ORDER BY t1.a) +FROM t3; +(SELECT t1.a FROM t1, t2 WHERE t1.a = t2.b AND t2.a = t3.c ORDER BY t1.a) +2 +NULL +DROP TABLE t1, t2, t3; +# +# Bug #42760: Select doesn't return desired results when we have null +# values +# +CREATE TABLE t1 ( +a INT, +c INT, +UNIQUE KEY a_c (a,c), +KEY (a)); +INSERT INTO t1 VALUES (1, 10), (2, NULL); +# Must use ref-or-null on the a_c index +EXPLAIN +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 75.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a_c,a a 5 const 1 75.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `col` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` +# Must return 1 row +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +col +1 +# Must use ref-or-null on the a_c index +EXPLAIN +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL ALL NULL x x x x 75.00 x +x x x NULL ref a_c,a x x x x 75.00 x +Warnings: +x x x +# Must return 1 row +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +col +1 +DROP TABLE t1; +End of 5.0 tests +CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, +UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b)) +charset utf8mb4; +CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b)) +charset utf8mb4; +INSERT INTO t3 SELECT * FROM t1; +EXPLAIN +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1 NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a,b b 13 const 4 100.00 Using index condition; Using where; Using temporary; Using filesort +2 SIMPLE t2 NULL ref a,b,c a 136 test.t1.a,const 1 78.90 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1 +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1 NULL ALL NULL NULL NULL NULL 415 27.57 Parallel execute (1 workers) +2 SIMPLE t2 NULL range a,b,c c 5 NULL 415 27.57 Using index condition; Using where +2 SIMPLE t1 NULL eq_ref a a 144 test.t2.a,const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t3` `t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1 +SELECT d FROM t3 AS t1, t2 AS t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.110 ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +13 12 12 +14 13 13 +15 14 14 +16 15 15 +17 16 16 +18 17 17 +19 18 18 +20 19 19 +21 20 20 +22 21 21 +23 22 22 +24 23 23 +25 24 24 +26 25 25 +27 26 26 +28 27 27 +29 28 28 +30 29 29 +31 30 30 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +22 21 21 +23 22 22 +24 23 23 +25 24 24 +26 25 25 +27 26 26 +28 27 27 +29 28 28 +30 29 29 +31 30 30 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +set sort_buffer_size= 32768; +CREATE TEMPORARY TABLE tmp (f1 int, f2 varchar(20)); +INSERT INTO tmp SELECT f1, f2 FROM t1; +INSERT INTO t1(f1, f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1, f2 FROM t1; +INSERT INTO t1(f1, f2) SELECT * FROM tmp; +SELECT * FROM t1 ORDER BY f1 ASC, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +SELECT * FROM t1 ORDER BY f1 ASC, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 ORDER BY f2 DESC, f0 LIMIT 30; +f0 f1 f2 +100 99 99 +200 99 99 +327 99 99 +427 99 99 +527 99 99 +99 98 98 +199 98 98 +326 98 98 +426 98 98 +526 98 98 +98 97 97 +198 97 97 +325 97 97 +425 97 97 +525 97 97 +97 96 96 +197 96 96 +324 96 96 +424 96 96 +524 96 96 +96 95 95 +196 95 95 +323 95 95 +423 95 95 +523 95 95 +95 94 94 +195 94 94 +322 94 94 +422 94 94 +522 94 94 +SELECT * FROM t1 ORDER BY f2 DESC, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +set sort_buffer_size= 32768; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 +ORDER BY f1, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 +ORDER BY f1, f0 LIMIT 0; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +set sort_buffer_size= 327680; +SELECT * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30; +f0 f1 f2 f1 f2 +1 0 0 0 0 +1 0 0 0 0 +1 0 0 0 0 +101 0 0 0 0 +101 0 0 0 0 +101 0 0 0 0 +228 0 0 0 0 +228 0 0 0 0 +228 0 0 0 0 +328 0 0 0 0 +328 0 0 0 0 +328 0 0 0 0 +428 0 0 0 0 +428 0 0 0 0 +428 0 0 0 0 +2 1 1 1 1 +2 1 1 1 1 +2 1 1 1 1 +102 1 1 1 1 +102 1 1 1 1 +102 1 1 1 1 +229 1 1 1 1 +229 1 1 1 1 +229 1 1 1 1 +329 1 1 1 1 +329 1 1 1 1 +329 1 1 1 1 +429 1 1 1 1 +429 1 1 1 1 +429 1 1 1 1 +SELECT * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +3 2 2 2 2 +3 2 2 2 2 +3 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +4 3 3 3 3 +4 3 3 3 3 +4 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +3 2 2 2 2 +3 2 2 2 2 +3 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +4 3 3 3 3 +4 3 3 3 3 +4 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +1500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 JOIN tmp on t1.f2=tmp.f2 +WHERE t1.f2>20 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +24 23 23 23 23 +24 23 23 23 23 +24 23 23 23 23 +124 23 23 23 23 +124 23 23 23 23 +124 23 23 23 23 +251 23 23 23 23 +251 23 23 23 23 +251 23 23 23 23 +351 23 23 23 23 +351 23 23 23 23 +351 23 23 23 23 +451 23 23 23 23 +451 23 23 23 23 +451 23 23 23 23 +25 24 24 24 24 +25 24 24 24 24 +25 24 24 24 24 +125 24 24 24 24 +125 24 24 24 24 +125 24 24 24 24 +252 24 24 24 24 +252 24 24 24 24 +252 24 24 24 24 +352 24 24 24 24 +352 24 24 24 24 +352 24 24 24 24 +452 24 24 24 24 +452 24 24 24 24 +452 24 24 24 24 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +1185 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +CREATE VIEW v1 as SELECT * FROM t1 ORDER BY f1, f0 LIMIT 30; +SELECT * FROM v1; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +drop view v1; +CREATE VIEW v1 as SELECT * FROM t1 ORDER BY f1, f0 LIMIT 100; +SELECT * FROM v1 ORDER BY f2, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +11 10 10 +111 10 10 +238 10 10 +338 10 10 +438 10 10 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +CREATE VIEW v2 as SELECT * FROM t1 ORDER BY f2, f0 LIMIT 100; +SELECT * FROM v1 JOIN v2 on v1.f1=v2.f1 ORDER BY v1.f2,v1.f0,v2.f0 +LIMIT 30; +f0 f1 f2 f0 f1 f2 +1 0 0 1 0 0 +1 0 0 101 0 0 +1 0 0 228 0 0 +1 0 0 328 0 0 +1 0 0 428 0 0 +101 0 0 1 0 0 +101 0 0 101 0 0 +101 0 0 228 0 0 +101 0 0 328 0 0 +101 0 0 428 0 0 +228 0 0 1 0 0 +228 0 0 101 0 0 +228 0 0 228 0 0 +228 0 0 328 0 0 +228 0 0 428 0 0 +328 0 0 1 0 0 +328 0 0 101 0 0 +328 0 0 228 0 0 +328 0 0 328 0 0 +328 0 0 428 0 0 +428 0 0 1 0 0 +428 0 0 101 0 0 +428 0 0 228 0 0 +428 0 0 328 0 0 +428 0 0 428 0 0 +2 1 1 2 1 1 +2 1 1 102 1 1 +2 1 1 229 1 1 +2 1 1 329 1 1 +2 1 1 429 1 1 +SELECT floor(f1/10) f3, count(f2) FROM t1 +GROUP BY 1 ORDER BY 2,1 LIMIT 5; +f3 count(f2) +0 50 +1 50 +2 50 +3 50 +4 50 +SELECT floor(f1/10) f3, count(f2) FROM t1 +GROUP BY 1 ORDER BY 2,1 LIMIT 0; +f3 count(f2) +CREATE PROCEDURE wl1393_sp_test() +BEGIN +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 30; +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 15 OFFSET 15; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 15 OFFSET 15; +SELECT FOUND_ROWS(); +SELECT * FROM v1 ORDER BY f2, f0 LIMIT 30; +END| +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +CALL wl1393_sp_test()| +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +f0 f1 f2 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +f0 f1 f2 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +FOUND_ROWS() +445 +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +11 10 10 +111 10 10 +238 10 10 +338 10 10 +438 10 10 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +DROP PROCEDURE wl1393_sp_test| +SELECT d1.f1, d1.f2 FROM t1 +LEFT JOIN (SELECT * FROM t1 ORDER BY f1 LIMIT 30) d1 on t1.f1=d1.f1 +ORDER BY d1.f2 DESC LIMIT 30; +f1 f2 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +4 4 +4 4 +4 4 +4 4 +4 4 +SELECT * FROM t1 WHERE f1 = (SELECT f1 FROM t1 ORDER BY 1 LIMIT 1); +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +SELECT * FROM t1 WHERE f1 = (SELECT f1 FROM t1 ORDER BY 1 LIMIT 2); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, tmp; +DROP VIEW v1, v2; +# end of WL#1393 - Optimizing filesort with small limit +# +# Bug #58761 +# Crash in Field::is_null in field.h on subquery in WHERE clause +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +INSERT INTO t1 VALUES (27,7,'x'); +INSERT INTO t1 VALUES (28,6,'m'); +INSERT INTO t1 VALUES (29,4,'c'); +CREATE TABLE where_subselect +SELECT DISTINCT `pk` AS field1 , `pk` AS field2 +FROM t1 AS alias1 +WHERE alias1 . `col_int_key` > 229 +OR alias1 . `col_varchar_key` IS NOT NULL +GROUP BY field1, field2 +; +SELECT * +FROM where_subselect +WHERE (field1, field2) IN ( +SELECT DISTINCT `pk` AS field1 , `pk` AS field2 +FROM t1 AS alias1 +WHERE alias1 . `col_int_key` > 229 +OR alias1 . `col_varchar_key` IS NOT NULL +GROUP BY field1, field2 +); +field1 field2 +27 27 +28 28 +29 29 +DROP TABLE t1; +DROP TABLE where_subselect; +# End of Bug #58761 +CREATE TABLE t1 ( +id1 INT NOT NULL, +id2 INT NOT NULL, +junk INT NOT NULL, +PRIMARY KEY (id1, id2, junk), +INDEX id2_j_id1 (id2, junk, id1) +); +INSERT INTO t1 VALUES (1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4); +INSERT INTO t1 VALUES (5, 2, 1), (6, 2, 2), (7, 2, 3), (8, 2, 4); +INSERT INTO t1 VALUES (9, 3, 1), (10, 3, 2), (11, 3, 3), (12, 3, 4); +INSERT INTO t1 VALUES (13, 4, 1), (14, 4, 2), (15, 4, 3), (16, 4, 4); +INSERT INTO t1 VALUES (17, 5, 1), (18, 5, 2), (19, 5, 3), (20, 5, 4); +INSERT INTO t1 VALUES (21, 6, 1), (22, 6, 2), (23, 6, 3), (24, 6, 4); +INSERT INTO t1 VALUES (25, 7, 1), (26, 7, 2), (27, 7, 3), (28, 7, 4); +INSERT INTO t1 VALUES (29, 8, 1), (30, 8, 2), (31, 8, 3), (32, 8, 4); +INSERT INTO t1 VALUES (33, 9, 1), (34, 9, 2), (35, 9, 3), (36, 9, 4); +EXPLAIN SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,id2_j_id1 id2_j_id1 4 const 4 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` where (`test`.`t1`.`id2` = 4) order by `test`.`t1`.`id1` +SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; +id1 +13 +14 +15 +16 +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, +b INT NOT NULL, +c char(100), +KEY (b, c), +KEY (b, a, c) +) +DEFAULT CHARSET = utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); +INSERT INTO t1 SELECT a + 10, b, c + 10 FROM t1; +INSERT INTO t1 SELECT a + 20, b, c + 20 FROM t1; +INSERT INTO t1 SELECT a + 40, b, c + 40 FROM t1; +INSERT INTO t1 SELECT a + 80, b, c + 80 FROM t1; +INSERT INTO t1 SELECT a + 160, b, c + 160 FROM t1; +INSERT INTO t1 SELECT a + 320, b, c + 320 FROM t1; +INSERT INTO t1 SELECT a + 640, b, c + 640 FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c + 1280 FROM t1 LIMIT 80; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 208 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref b,b_2 b_2 4 const 208 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`c` desc limit 9 +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +a +991 +981 +971 +961 +951 +941 +931 +921 +911 +EXPLAIN +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,b_2 b_2 4 const 208 100.00 Using index; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`c` desc limit 0,9 +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; +a +991 +981 +971 +961 +951 +941 +931 +921 +911 +DROP TABLE t1; +# +# Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join buffering +# is used +# +CREATE TABLE t1 (a INT, b INT, KEY (a)); +INSERT INTO t1 VALUES (0, NULL), (1, NULL), (2, NULL), (3, NULL); +INSERT INTO t1 SELECT a+4, b FROM t1; +INSERT INTO t1 SELECT a+8, b FROM t1; +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL), (4,NULL); +INSERT INTO t2 SELECT a+4, b FROM t2; +# shouldn't have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` FORCE INDEX FOR ORDER BY (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +# should have "using filesort" +EXPLAIN +SELECT * FROM t1 USE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition; Using MRR; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` USE INDEX FOR ORDER BY (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +# should have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR JOIN (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition; Using MRR; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` FORCE INDEX FOR JOIN (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +DROP TABLE t1, t2; +# +# Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and +# ORDER BY computed col +# +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, KEY( a, b ) ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t1 SELECT a + 5, b + 5 FROM t1; +CREATE TABLE t2( a INT PRIMARY KEY, b INT ); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t2 SELECT a + 5, b + 5 FROM t2; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT count(*) AS c, t1.a +FROM t1 JOIN t2 ON t1.b = t2.a +WHERE t2.b = 1 +GROUP BY t1.a +ORDER by c +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 10 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t1 NULL index a a 8 NULL 10 10.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `c`,`test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 1)) group by `test`.`t1`.`a` order by `c` limit 2 +DROP TABLE t1, t2; +# +# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory +# and +# Bug #59308: Incorrect result for +SELECT DISTINCT ... ORDER BY DESC + +# Use Valgrind to detect #59110! +# +CREATE TABLE t1 (a INT,KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a`,1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` <> 1) order by `test`.`t1`.`a` desc +SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC; +a 1 +10 1 +9 1 +8 1 +7 1 +6 1 +5 1 +4 1 +3 1 +2 1 +DROP TABLE t1; +# +# Bug#11765255 58201: +# VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS +# +select count(*) order by max(1) + min(1); +count(*) +1 +End of 5.1 tests +# +# Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY +# when it should use index +# +CREATE TABLE t1 (i1 integer NOT NULL PRIMARY KEY); +CREATE TABLE t2 (i2 integer NOT NULL PRIMARY KEY); +CREATE TABLE t3 (i3 integer); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2 +LEFT JOIN t3 ON t2.i2 = t3.i3 +ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 12 100.00 Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i1 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i3` = `test`.`t1`.`i1`)) where (`test`.`t2`.`i2` = `test`.`t1`.`i1`) order by `test`.`t1`.`i1` limit 5 +SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2 +LEFT JOIN t3 ON t2.i2 = t3.i3 +ORDER BY t1.i1 LIMIT 5; +i1 i2 +1 1 +2 2 +3 3 +4 4 +5 5 +DROP TABLE t1, t2, t3; +# +# Bug #11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION +# `TAB->REF.USE_COUNT' +# +CREATE TABLE t1(a INT PRIMARY KEY); +CREATE TABLE t2(b INT,c INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1,2), (2,3); +SELECT (SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) FROM t2; +(SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) +NULL +NULL +DROP TABLE t1, t2; +# +# Bug #13531865 +# TEST_IF_SKIP_SORT_ORDER() INCORRECTLY SKIP FILESORT IF +# 'TYPE' IS REF_OR_NULL +# +# +CREATE TABLE t1 ( +a INT, +c INT, +UNIQUE KEY a_c (a,c), +KEY (a)) engine=myisam; +INSERT INTO t1 VALUES (1,10), (2,NULL), (2,10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Using 'KEY a_c' for order-by opt, would have required +# REF_OR_NULL access which never can be order_by skipped. +# -> Keep initial REF on 'KEY a' selected by cond. optimizer +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +c +NULL +10 +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` desc +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +c +10 +NULL +DROP TABLE t1; +# +# Bug #13528826 +# TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT' +# +# +CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam; +INSERT INTO t1 VALUES +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam; +INSERT INTO t2 VALUES +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +# number of rows in t1 was incorrectly used as an +# implicit limit-clause if not explicit specified +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +# Query above used to be explained identical to this: +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` limit 8 +# A really high limit was required to give the correct explain +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 1000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` limit 1000 +DROP TABLE t1, t2; +# +# Bug #13949068 ASSERT TAB->REF.KEY == REF_KEY IN +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG +# +CREATE TABLE t1 (a INT, b INT, KEY(b), KEY(b,a)) ENGINE=INNODB; +INSERT INTO t1 VALUES (0,0); +EXPLAIN SELECT DISTINCT a FROM t1 WHERE b=1 ORDER BY 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,b_2 b_2 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`a` +SELECT DISTINCT a FROM t1 WHERE b=1 ORDER BY 1; +a +DROP TABLE t1; +# +# Bug#18636076 DEBUG CRASH ON +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3); +CREATE VIEW view_t1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +i1 INTEGER NOT NULL +) ENGINE=MyISAM; +EXPLAIN SELECT DISTINCT t2.i1, view_t1.pk +FROM view_t1 LEFT JOIN t2 +ON view_t1.pk = t2.i1 +WHERE (view_t1.pk <= 204 AND t2.i1 != 3) +OR view_t1.pk BETWEEN 1 AND 7 +ORDER BY t2.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct NULL AS `i1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (((`test`.`t1`.`pk` <= 204) and (NULL <> 3)) or (`test`.`t1`.`pk` between 1 and 7)) order by NULL +SELECT DISTINCT t2.i1, view_t1.pk +FROM view_t1 LEFT JOIN t2 +ON view_t1.pk = t2.i1 +WHERE (view_t1.pk <= 204 AND t2.i1 != 3) +OR view_t1.pk BETWEEN 1 AND 7 +ORDER BY t2.i1; +i1 pk +NULL 1 +NULL 2 +NULL 3 +DROP VIEW view_t1; +DROP TABLE t1, t2; +SET sql_mode = default; +# +# Bug#20455386 INVALID WRITE IN COPY_FIELD::SET CAUSE CRASH WITH TMP TABLES +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +CREATE TABLE t2(c INT) ENGINE=INNODB; +CREATE TABLE t3(b BLOB NOT NULL) ENGINE=INNODB; +SELECT +(SELECT 1 FROM t1 +WHERE (SELECT c FROM t2 ORDER BY COUNT(t3.b )) +) +FROM t3; +(SELECT 1 FROM t1 +WHERE (SELECT c FROM t2 ORDER BY COUNT(t3.b )) +) +NULL +DROP TABLE t1,t2,t3; +# +# Bug#16833464: Presence of ORDER BY changes data type of column in +# CREATE TABLE SELECT +CREATE TABLE z1 (c05 TIME); +(SELECT * FROM z1 ORDER BY '1') ORDER BY '1'; +c05 +CREATE TABLE z2 (SELECT * FROM z1 ORDER BY '1') ORDER BY '1'; +CREATE TABLE z3 (SELECT * FROM z1) ORDER BY '1'; +SHOW CREATE TABLE z2; +Table Create Table +z2 CREATE TABLE `z2` ( + `c05` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE z3; +Table Create Table +z3 CREATE TABLE `z3` ( + `c05` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE z1, z2, z3; +set optimizer_switch=default; diff --git a/mysql-test/r/order_by_icp_mrr.result-pq b/mysql-test/r/order_by_icp_mrr.result-pq new file mode 100644 index 000000000..7fa773d29 --- /dev/null +++ b/mysql-test/r/order_by_icp_mrr.result-pq @@ -0,0 +1,3396 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(6) DEFAULT '0' NOT NULL, +idservice int(5), +clee char(20) NOT NULL, +flag char(1), +KEY id (id), +PRIMARY KEY (clee) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,4,'6067169d','Y'); +INSERT INTO t1 VALUES (2,5,'606716d1','Y'); +INSERT INTO t1 VALUES (2,1,'606717c1','Y'); +INSERT INTO t1 VALUES (3,1,'6067178d','Y'); +INSERT INTO t1 VALUES (2,6,'60671515','Y'); +INSERT INTO t1 VALUES (2,7,'60671569','Y'); +INSERT INTO t1 VALUES (2,3,'dd','Y'); +CREATE TABLE t2 ( +id int(6) NOT NULL auto_increment, +description varchar(40) NOT NULL, +idform varchar(40), +ordre int(6) unsigned DEFAULT '0' NOT NULL, +image varchar(60), +PRIMARY KEY (id), +KEY id (id,ordre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'Emettre un appel d''offres','en_construction.html',10,'emettre.gif'); +INSERT INTO t2 VALUES (2,'Emettre des soumissions','en_construction.html',20,'emettre.gif'); +INSERT INTO t2 VALUES (7,'Liste des t2','t2_liste_form.phtml',51060,'link.gif'); +INSERT INTO t2 VALUES (8,'Consulter les soumissions','consulter_soumissions.phtml',200,'link.gif'); +INSERT INTO t2 VALUES (9,'Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif'); +INSERT INTO t2 VALUES (10,'Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 VALUES (3,'Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 VALUES (4,'Modifier des clients','en_construction.html',40010,'link.gif'); +INSERT INTO t2 VALUES (5,'Effacer des clients','en_construction.html',40020,'link.gif'); +INSERT INTO t2 VALUES (6,'Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif'); +select t1.id,t1.idservice,t2.ordre,t2.description from t1, t2 where t1.id = 2 and t1.idservice = t2.id order by t2.ordre; +id idservice ordre description +2 1 10 Emettre un appel d'offres +2 3 40000 Créer une fiche de client +2 4 40010 Modifier des clients +2 5 40020 Effacer des clients +2 6 51050 Ajouter un service +2 7 51060 Liste des t2 +drop table t1,t2; +create table t1 (first char(10),last char(10)); +insert into t1 values ("Michael","Widenius"); +insert into t1 values ("Allan","Larsson"); +insert into t1 values ("David","Axmark"); +select concat(first," ",last) as name from t1 order by name; +name +Allan Larsson +David Axmark +Michael Widenius +select concat(last," ",first) as name from t1 order by name; +name +Axmark David +Larsson Allan +Widenius Michael +drop table t1; +create table t1 (i int); +insert into t1 values(1),(2),(1),(2),(1),(2),(3); +select distinct i from t1; +i +1 +2 +3 +select distinct i from t1 order by rand(5); +i +1 +2 +3 +select distinct i from t1 order by i desc; +i +3 +2 +1 +select distinct i from t1 order by 1-i; +i +3 +2 +1 +select distinct i from t1 order by mod(i,2),i; +i +2 +1 +3 +drop table t1; +create table t1 ( pk int primary key, name varchar(255) not null, number varchar(255) not null); +insert into t1 values (1, 'Gamma', '123'), (2, 'Gamma Ext', '123a'), (3, 'Alpha', '001'), (4, 'Beta', '200c'); +select distinct t1.name as 'Building Name',t1.number as 'Building Number' from t1 order by t1.name asc; +Building Name Building Number +Alpha 001 +Beta 200c +Gamma 123 +Gamma Ext 123a +drop table t1; +create table t1 (id int not null,col1 int not null,col2 int not null,index(col1)); +insert into t1 values(1,2,2),(2,2,1),(3,1,2),(4,1,1),(5,1,4),(6,2,3),(7,3,1),(8,2,4); +select * from t1 order by col1,col2; +id col1 col2 +4 1 1 +3 1 2 +5 1 4 +2 2 1 +1 2 2 +6 2 3 +8 2 4 +7 3 1 +select col1 from t1 order by id; +col1 +2 +2 +1 +1 +1 +2 +3 +2 +select col1 as id from t1 order by id; +id +1 +1 +1 +2 +2 +2 +2 +3 +select concat(col1) as id from t1 order by id; +id +1 +1 +1 +2 +2 +2 +2 +3 +drop table t1; +CREATE TABLE t1 (id int auto_increment primary key,aika varchar(40),aikakentta timestamp); +insert into t1 (aika) values ('Keskiviikko'); +insert into t1 (aika) values ('Tiistai'); +insert into t1 (aika) values ('Maanantai'); +insert into t1 (aika) values ('Sunnuntai'); +SELECT FIELD(SUBSTRING(t1.aika,1,2),'Ma','Ti','Ke','To','Pe','La','Su') AS test FROM t1 ORDER by test; +test +1 +2 +3 +7 +drop table t1; +CREATE TABLE t1 +( +a int unsigned NOT NULL, +b int unsigned NOT NULL, +c int unsigned NOT NULL, +UNIQUE(a), +INDEX(b), +INDEX(c) +); +CREATE TABLE t2 +( +c int unsigned NOT NULL, +i int unsigned NOT NULL, +INDEX(c) +); +CREATE TABLE t3 +( +c int unsigned NOT NULL, +v varchar(64), +INDEX(c) +); +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t1 VALUES (2,1,2); +INSERT INTO t1 VALUES (3,2,1); +INSERT INTO t1 VALUES (4,2,2); +INSERT INTO t2 VALUES (1,50); +INSERT INTO t2 VALUES (2,25); +INSERT INTO t3 VALUES (1,'123 Park Place'); +INSERT INTO t3 VALUES (2,'453 Boardwalk'); +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 USING(c) +LEFT JOIN t3 ON t3.c = t1.c; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 USING(c) +LEFT JOIN t3 ON t3.c = t1.c +ORDER BY a; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c +ORDER BY a; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +drop table t1,t2,t3; +create table t1 (ID int not null primary key, TransactionID int not null); +insert into t1 (ID, TransactionID) values (1, 87), (2, 89), (3, 92), (4, 94), (5, 486), (6, 490), (7, 753), (9, 828), (10, 832), (11, 834), (12, 840); +create table t2 (ID int not null primary key, GroupID int not null); +insert into t2 (ID, GroupID) values (87, 87), (89, 89), (92, 92), (94, 94), (486, 486), (490, 490),(753, 753), (828, 828), (832, 832), (834, 834), (840, 840); +create table t3 (ID int not null primary key, DateOfAction date not null); +insert into t3 (ID, DateOfAction) values (87, '1999-07-19'), (89, '1999-07-19'), (92, '1999-07-19'), (94, '1999-07-19'), (486, '1999-07-18'), (490, '2000-03-27'), (753, '2000-03-28'), (828, '1999-07-27'), (832, '1999-07-27'),(834, '1999-07-27'), (840, '1999-07-27'); +select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t3.DateOfAction, t1.TransactionID; +DateOfAction TransactionID +1999-07-18 486 +1999-07-19 87 +1999-07-19 89 +1999-07-19 92 +1999-07-19 94 +1999-07-27 828 +1999-07-27 832 +1999-07-27 834 +1999-07-27 840 +2000-03-27 490 +2000-03-28 753 +select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t1.TransactionID,t3.DateOfAction; +DateOfAction TransactionID +1999-07-19 87 +1999-07-19 89 +1999-07-19 92 +1999-07-19 94 +1999-07-18 486 +2000-03-27 490 +2000-03-28 753 +1999-07-27 828 +1999-07-27 832 +1999-07-27 834 +1999-07-27 840 +drop table t1,t2,t3; +CREATE TABLE t1 ( +member_id int(11) NOT NULL auto_increment, +inschrijf_datum varchar(20) NOT NULL default '', +lastchange_datum varchar(20) NOT NULL default '', +nickname varchar(20) NOT NULL default '', +password varchar(8) NOT NULL default '', +voornaam varchar(30) NOT NULL default '', +tussenvoegsels varchar(10) NOT NULL default '', +achternaam varchar(50) NOT NULL default '', +straat varchar(100) NOT NULL default '', +postcode varchar(10) NOT NULL default '', +wijk varchar(40) NOT NULL default '', +plaats varchar(50) NOT NULL default '', +telefoon varchar(10) NOT NULL default '', +geboortedatum date NOT NULL default '0000-00-00', +geslacht varchar(5) NOT NULL default '', +email varchar(80) NOT NULL default '', +uin varchar(15) NOT NULL default '', +homepage varchar(100) NOT NULL default '', +internet varchar(15) NOT NULL default '', +scherk varchar(30) NOT NULL default '', +favo_boek varchar(50) NOT NULL default '', +favo_tijdschrift varchar(50) NOT NULL default '', +favo_tv varchar(50) NOT NULL default '', +favo_eten varchar(50) NOT NULL default '', +favo_muziek varchar(30) NOT NULL default '', +info text NOT NULL default '', +ipnr varchar(30) NOT NULL default '', +PRIMARY KEY (member_id) +) charset utf8mb4 ENGINE=MyISAM PACK_KEYS=1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'info' can't have a default value +insert into t1 (member_id) values (1),(2),(3); +select member_id, nickname, voornaam FROM t1 +ORDER by lastchange_datum DESC LIMIT 2; +member_id nickname voornaam +1 +2 +drop table t1; +create table t1 (a int not null, b int, c varchar(10), key (a, b, c)) charset utf8mb4; +insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 52 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` is null)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc +select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; +a b c +1 NULL b +explain select * from t1 where a >= 1 and a < 3 order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 52 NULL 11 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3)) order by `test`.`t1`.`a` desc +explain format=json select * from t1 where a >= 1 and a < 3 order by a desc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.35" + }, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.10", + "prefix_cost": "1.35", + "data_read_per_join": "616" + }, + "used_columns": [ + "a", + "b", + "c" + ], + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ], + "key_length": "52", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "backward_index_scan": true, + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.10", + "prefix_cost": "1.35", + "data_read_per_join": "616" + }, + "used_columns": [ + "a", + "b", + "c" + ], + "attached_condition": "((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3))" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3)) order by `test`.`t1`.`a` desc +select * from t1 where a >= 1 and a < 3 order by a desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +explain select * from t1 where a = 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 4 const 6 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` = 1) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a = 1 order by a desc, b desc; +a b c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +explain select * from t1 where a = 1 and b is null order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 9 const,const 2 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a = 1 and b is null order by a desc, b desc; +a b c +1 NULL NULL +1 NULL b +explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 9 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 5 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b is null order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 9 const,const 1 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and (b is null or b > 0) order by a +desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 9 NULL 6 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`b` is null) or (`test`.`t1`.`b` > 0))) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b > 0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 5 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b < 2 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` < 2)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 1 order by b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 4 const 6 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` = 1) order by `test`.`t1`.`b` desc +select * from t1 where a = 1 order by b desc; +a b c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +alter table t1 modify b int not null, modify c varchar(10) not null; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'c' at row 3 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 order by a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` +select * from t1 order by a, b, c; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +1 3 b +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +explain select * from t1 order by a desc, b desc, c desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc,`test`.`t1`.`c` desc +select * from t1 order by a desc, b desc, c desc; +a b c +2 3 c +2 2 b +2 2 a +2 1 b +2 1 a +1 3 b +1 1 b +1 1 b +1 1 +1 0 b +1 0 +explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 50 NULL 3 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc +select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; +a b c +1 1 b +1 1 b +explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 4 NULL 6 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` < 2) and (`test`.`t1`.`b` <= 1)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a < 2 and b <= 1 order by a desc, b desc; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +select count(*) from t1 where a < 5 and b > 0; +count(*) +9 +select * from t1 where a < 5 and b > 0 order by a desc,b desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 +1 1 b +1 1 b +1 3 b +explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 33.33 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 50 NULL 11 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` between 1 and 3) and (`test`.`t1`.`b` <= 1)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; +a b c +2 1 a +2 1 b +1 0 +1 0 b +1 1 +1 1 b +1 1 b +explain select * from t1 where a between 0 and 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 4 NULL 6 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` between 0 and 1) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a between 0 and 1 order by a desc, b desc; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +1 3 b +drop table t1; +CREATE TABLE t1 ( +gid int(10) unsigned NOT NULL auto_increment, +cid smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (gid), +KEY component_id (cid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (103853,108),(103867,108),(103962,108),(104505,108),(104619,108),(104620,108); +ALTER TABLE t1 add skr int(10) not null; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +gid int(10) unsigned NOT NULL default '0', +uid smallint(5) unsigned NOT NULL default '1', +sid tinyint(3) unsigned NOT NULL default '1', +PRIMARY KEY (gid), +KEY uid (uid), +KEY status_id (sid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (103853,250,5),(103867,27,5),(103962,27,5),(104505,117,5),(104619,75,5),(104620,15,5); +CREATE TABLE t3 ( +uid smallint(6) NOT NULL auto_increment, +PRIMARY KEY (uid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(15),(27),(75),(117),(250); +ALTER TABLE t3 add skr int(10) not null; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +gid sid uid +104620 5 15 +103867 5 27 +103962 5 27 +104619 5 75 +104505 5 117 +103853 5 250 +select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +gid sid uid +104620 5 15 +103867 5 27 +103962 5 27 +104619 5 75 +104505 5 117 +103853 5 250 +EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 2 NULL 6 100.00 Using index; Using temporary; Using filesort +1 SIMPLE t2 NULL ref PRIMARY,uid uid 2 test.t3.uid 1 100.00 Using index condition +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.gid 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t2`.`sid` AS `sid`,`test`.`t3`.`uid` AS `uid` from `test`.`t3` join `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`gid` = `test`.`t2`.`gid`) and (`test`.`t2`.`uid` = `test`.`t3`.`uid`)) order by `test`.`t1`.`gid`,`test`.`t3`.`uid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`gid` = `test`.`t3`.`uid`) order by `test`.`t1`.`gid`,`test`.`t3`.`skr` +EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,uid NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.gid 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t2`.`sid` AS `sid`,`test`.`t3`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` join `test`.`t3` where ((`test`.`t1`.`gid` = `test`.`t2`.`gid`) and (`test`.`t2`.`uid` = `test`.`t3`.`uid`)) order by `test`.`t3`.`uid`,`test`.`t1`.`gid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`gid` = `test`.`t3`.`uid`) order by `test`.`t3`.`skr`,`test`.`t1`.`gid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 2 test.t1.skr 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`skr` = `test`.`t3`.`uid`) order by `test`.`t1`.`gid`,`test`.`t3`.`skr` +drop table t1,t2,t3; +CREATE TABLE t1 ( +`titre` char(80) NOT NULL default '', +`numeropost` mediumint(8) unsigned NOT NULL auto_increment, +`date` datetime NOT NULL default '0000-00-00 00:00:00', +`auteur` char(35) NOT NULL default '', +`icone` tinyint(2) unsigned NOT NULL default '0', +`lastauteur` char(35) NOT NULL default '', +`nbrep` smallint(6) unsigned NOT NULL default '0', +`dest` char(35) NOT NULL default '', +`lu` tinyint(1) unsigned NOT NULL default '0', +`vue` mediumint(8) unsigned NOT NULL default '0', +`ludest` tinyint(1) unsigned NOT NULL default '0', +`ouvert` tinyint(1) unsigned NOT NULL default '1', +PRIMARY KEY (`numeropost`), +KEY `date` (`date`), +KEY `dest` (`dest`,`ludest`), +KEY `auteur` (`auteur`,`lu`), +KEY `auteur_2` (`auteur`,`date`), +KEY `dest_2` (`dest`,`date`) +) CHECKSUM=1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +`numeropost` mediumint(8) unsigned NOT NULL default '0', +`pseudo` char(35) NOT NULL default '', +PRIMARY KEY (`numeropost`,`pseudo`), +KEY `pseudo` (`pseudo`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (titre,auteur,dest) VALUES ('test','joce','bug'); +INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug'); +SELECT titre,t1.numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +drop table t1,t2; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (3, 4); +INSERT INTO t1 VALUES (5, NULL); +SELECT * FROM t1 ORDER BY b; +a b +5 NULL +1 2 +3 4 +SELECT * FROM t1 ORDER BY b DESC; +a b +3 4 +1 2 +5 NULL +SELECT * FROM t1 ORDER BY (a + b); +a b +5 NULL +1 2 +3 4 +SELECT * FROM t1 ORDER BY (a + b) DESC; +a b +3 4 +1 2 +5 NULL +DROP TABLE t1; +create table t1(id int not null auto_increment primary key, t char(12)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select id,t from t1 order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`t` AS `t` from `test`.`t1` order by `test`.`t1`.`id` +explain select id,t from t1 force index (primary) order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`t` AS `t` from `test`.`t1` FORCE INDEX (PRIMARY) order by `test`.`t1`.`id` +drop table t1; +CREATE TABLE t1 ( +FieldKey varchar(36) NOT NULL default '', +LongVal bigint(20) default NULL, +StringVal mediumtext, +KEY FieldKey (FieldKey), +KEY LongField (FieldKey,LongVal), +KEY StringField (FieldKey,StringVal(32)) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3'); +EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref FieldKey,LongField,StringField LongField 146 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` = '1') order by `test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +FieldKey LongVal StringVal +1 0 2 +1 1 3 +1 2 1 +EXPLAIN SELECT * FROM t1 ignore index (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range StringField StringField 146 NULL 3 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` IGNORE INDEX (`LongField`) IGNORE INDEX (`FieldKey`) where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range FieldKey,LongField,StringField LongField 146 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`FieldKey`,`test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; +CREATE TABLE t1 ( id smallint(6) unsigned NOT NULL default '0', menu tinyint(4) NOT NULL default '0', KEY id (id), KEY menu (menu)) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (11384, 2),(11392, 2); +SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ; +id +11392 +drop table t1; +create table t1(a int, b int, index(b)); +insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where b=1 or b is null order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null b b 5 const 4 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) or (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` +explain format=tree select * from t1 where b=1 or b is null order by a; +EXPLAIN +-> Sort: t1.a (cost=0.90 rows=4) + -> Index lookup on t1 using b (b=1 or NULL), with index condition: ((t1.b = 1) or (t1.b is null)) + +select * from t1 where b=1 or b is null order by a; +a b +1 1 +2 1 +3 NULL +4 NULL +explain select * from t1 where b=2 or b is null order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null b b 5 const 4 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 2) or (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` +select * from t1 where b=2 or b is null order by a; +a b +3 NULL +4 NULL +5 2 +6 2 +drop table t1; +create table t1 (a int not null auto_increment, b int not null, c int not null, d int not null, +key(a,b,d), key(c,b,a)); +create table t2 like t1; +insert into t1 values (NULL, 1, 2, 0), (NULL, 2, 1, 1), (NULL, 3, 4, 2), (NULL, 4, 3, 3); +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +set @row=10; +insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select * from t1 where a=1 and b in (1) order by c, b, a; +a b c d +1 1 2 0 +1 1 12 -1 +1 1 52 -5 +1 1 92 -9 +select * from t1 where a=1 and b in (1); +a b c d +1 1 12 -1 +1 1 2 0 +1 1 52 -5 +1 1 92 -9 +drop table t1, t2; +create table t1 (col1 int, col int); +create table t2 (col2 int, col int); +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1,3),(2,2),(3,1); +select t1.* , t2.col as t2_col from t1 left join t2 on (t1.col1=t2.col2) +order by col; +col1 col t2_col +1 1 3 +2 2 2 +3 3 1 +select col1 as col, col from t1 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select col1 from t1, t2 where t1.col1=t2.col2 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as t1_col, t2.col from t1, t2 where t1.col1=t2.col2 +order by col; +t1_col col +3 1 +2 2 +1 3 +select col2 as c, col as c from t2 order by col; +c c +3 1 +2 2 +1 3 +select col2 as col, col as col2 from t2 order by col; +col col2 +1 3 +2 2 +3 1 +select t2.col2, t2.col, t2.col from t2 order by col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +select t2.col2 as col from t2 order by t2.col; +col +3 +2 +1 +select t2.col2 as col, t2.col from t2 order by t2.col; +col col +3 1 +2 2 +1 3 +select t2.col2, t2.col, t2.col from t2 order by t2.col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +drop table t1, t2; +create table t1 (a char(25)) charset latin1; +insert into t1 set a = repeat('x', 20); +insert into t1 set a = concat(repeat('x', 19), 'z'); +insert into t1 set a = concat(repeat('x', 19), 'ab'); +insert into t1 set a = concat(repeat('x', 19), 'aa'); +set max_sort_length=20; +select a from t1 order by a; +a +xxxxxxxxxxxxxxxxxxxaa +xxxxxxxxxxxxxxxxxxxab +xxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxz +drop table t1; +create table t1 ( +`sid` decimal(8,0) default null, +`wnid` varchar(11) not null default '', +key `wnid14` (`wnid`(4)), +key `wnid` (`wnid`) +) engine=myisam default charset=latin1; +insert into t1 (`sid`, `wnid`) values +('10100','01019000000'),('37986','01019000000'),('37987','01019010000'), +('39560','01019090000'),('37989','01019000000'),('37990','01019011000'), +('37991','01019011000'),('37992','01019019000'),('37993','01019030000'), +('37994','01019090000'),('475','02070000000'),('25253','02071100000'), +('25255','02071100000'),('25256','02071110000'),('25258','02071130000'), +('25259','02071190000'),('25260','02071200000'),('25261','02071210000'), +('25262','02071290000'),('25263','02071300000'),('25264','02071310000'), +('25265','02071310000'),('25266','02071320000'),('25267','02071320000'), +('25269','02071330000'),('25270','02071340000'),('25271','02071350000'), +('25272','02071360000'),('25273','02071370000'),('25281','02071391000'), +('25282','02071391000'),('25283','02071399000'),('25284','02071400000'), +('25285','02071410000'),('25286','02071410000'),('25287','02071420000'), +('25288','02071420000'),('25291','02071430000'),('25290','02071440000'), +('25292','02071450000'),('25293','02071460000'),('25294','02071470000'), +('25295','02071491000'),('25296','02071491000'),('25297','02071499000'); +explain select * from t1 where wnid like '0101%' order by wnid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range wnid14,wnid wnid 13 NULL 10 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sid` AS `sid`,`test`.`t1`.`wnid` AS `wnid` from `test`.`t1` where (`test`.`t1`.`wnid` like '0101%') order by `test`.`t1`.`wnid` +select * from t1 where wnid like '0101%' order by wnid; +sid wnid +10100 01019000000 +37986 01019000000 +37989 01019000000 +37987 01019010000 +37990 01019011000 +37991 01019011000 +37992 01019019000 +37993 01019030000 +39560 01019090000 +37994 01019090000 +drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +a +1 +1 +1 +2 +2 +(SELECT a FROM t1) ORDER BY a; +a +1 +1 +1 +2 +2 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10); +(SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a; +b a +10 1 +10 2 +20 1 +20 2 +30 1 +30 2 +(SELECT b FROM t1 ORDER BY b DESC) ORDER BY b ASC; +b +10 +10 +20 +20 +30 +30 +(SELECT b,a FROM t1 ORDER BY b,a) ORDER BY a,b; +b a +10 1 +20 1 +30 1 +10 2 +20 2 +30 2 +(SELECT b,a FROM t1 ORDER by b,a LIMIT 3) ORDER by a,b; +b a +10 1 +20 1 +10 2 +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT a + 1 AS num FROM t1 ORDER BY 30 - num; +num +3 +2 +SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str); +str +test1 +test2 +SELECT a + 1 AS num FROM t1 GROUP BY 30 - num; +num +2 +3 +SELECT a + 1 AS num FROM t1 HAVING 30 - num; +num +2 +3 +SELECT a + 1 AS num, num + 1 FROM t1; +ERROR 42S22: Unknown column 'num' in 'field list' +SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1; +num (select num + 2 FROM t1 LIMIT 1) +2 4 +3 5 +SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; +ERROR 42S22: Unknown column 'num' in 'on clause' +DROP TABLE t1; +CREATE TABLE bug25126 ( +val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +); +UPDATE bug25126 SET MissingCol = MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET val = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = val ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +DROP TABLE bug25126; +CREATE TABLE t1 (a int); +SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1; +val val1 +SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val; +ERROR 23000: Column 'val' in order clause is ambiguous +SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1; +ERROR 23000: Column 'val' in order clause is ambiguous +DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (2), (4), (1); +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a NOT IN (2,3), a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a NOT BETWEEN 2 AND 3, a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, x2; +x1 x2 + 3 + 4 +1 +2 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, IF(a NOT IN (1,2), a, ''); +x1 x2 + 3 + 4 +1 +2 +SELECT a, a IN (1,2) FROM t1 ORDER BY a IN (1,2); +a a IN (1,2) +3 0 +4 0 +2 1 +1 1 +SELECT a FROM t1 ORDER BY a IN (1,2); +a +3 +4 +2 +1 +SELECT a+10 FROM t1 ORDER BY a IN (1,2); +a+10 +13 +14 +12 +11 +SELECT a, IF(a IN (1,2), a, a+10) FROM t1 +ORDER BY IF(a IN (3,4), a, a+10); +a IF(a IN (1,2), a, a+10) +3 13 +4 14 +1 1 +2 2 +DROP TABLE t1; +create table t1 (a int not null, b int not null, c int not null); +insert t1 values (1,1,1),(1,1,2),(1,2,1); +select a, b from t1 group by a, b order by sum(c); +a b +1 2 +1 1 +drop table t1; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze Error Table 'test.t2' doesn't exist +test.t2 analyze status Operation failed +explain SELECT t1.b as a, t2.b as c FROM +t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `a`,`test`.`t2`.`b` AS `c` from `test`.`t1` left join `test`.`t1` `t2` on(((`test`.`t1`.`a` = 2) and (`test`.`t2`.`a` = 2))) where true order by `c` +SELECT t2.b as c FROM +t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +c +NULL +NULL +2 +explain SELECT t1.b as a, t2.b as c FROM +t1 JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `a`,'2' AS `c` from `test`.`t1` join `test`.`t1` `t2` where true order by `c` +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * from t1; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 SELECT * from t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t4 SELECT * from t1; +INSERT INTO t1 values (0,0),(4,4); +SELECT t2.b FROM t1 LEFT JOIN (t2, t3 LEFT JOIN t4 ON t3.a=t4.a) +ON (t1.a=t2.a AND t1.b=t3.b) order by t2.b; +b +NULL +NULL +1 +2 +3 +DROP TABLE t1,t2,t3,t4; +create table t1 (a int, b int, c int); +insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9); +select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc; +a ratio +1 0.5000 +19 1.3333 +9 2.6667 +drop table t1; +CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME); +INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10); +UPDATE t1 SET b = SEC_TO_TIME(a); +SELECT a, b FROM t1 ORDER BY b DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b)); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT, KEY a (a,b)); +INSERT INTO t2 VALUES (1,1),(1,2),(2,1),(2,2); +EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY,b b 5 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY,b b 5 const 1 100.00 Using index +2 SIMPLE t2 NULL ref a a 5 const 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = '2')) order by `test`.`t2`.`b` +DROP TABLE t1,t2; +CREATE TABLE t1( +id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3)); +INSERT INTO t1 (c2,c3) VALUES +(31,34),(35,38),(34,31),(32,35),(31,39), +(11,14),(15,18),(14,11),(12,15),(11,19); +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +UPDATE t1 SET c2=20 WHERE id%100 = 0; +SELECT COUNT(*) FROM t1; +COUNT(*) +40960 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * FROM t1 ORDER BY id; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL index k2 k3 5 NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` = 11) order by `test`.`t2`.`c3` limit 20 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8192 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ref k2 k2 5 const 8192 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` = 11) order by `test`.`t2`.`c3` limit 4000 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 40 50.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL index k2 k3 5 NULL 40 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` between 10 and 12) order by `test`.`t2`.`c3` limit 20 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 409 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range k2 k2 5 NULL 409 100.00 Using index condition; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` between 20 and 30) order by `test`.`t2`.`c3` limit 4000 +SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +id c3 +6 14 +16 14 +31 14 +41 14 +62 14 +72 14 +82 14 +92 14 +125 14 +135 14 +145 14 +155 14 +165 14 +175 14 +185 14 +195 14 +252 14 +262 14 +272 14 +282 14 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a INT, +b INT, +PRIMARY KEY (a), +KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY, ab) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,ab PRIMARY 4 NULL 128 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR GROUP BY (`ab`) IGNORE INDEX FOR GROUP BY (PRIMARY) group by `test`.`t1`.`a` +flush status; +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY, ab) GROUP BY a; +a +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +13 +14 +15 +16 +17 +18 +19 +2 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY, ab) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 128 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR ORDER BY (`ab`) IGNORE INDEX FOR ORDER BY (PRIMARY) order by `test`.`t1`.`a` +flush status; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +flush status; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`ab`) IGNORE INDEX (PRIMARY) group by `test`.`t1`.`a` +SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) GROUP BY a; +a +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +13 +14 +15 +16 +17 +18 +19 +2 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`ab`) IGNORE INDEX (PRIMARY) order by `test`.`t1`.`a` +SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +DROP TABLE t1; +# +# Bug#31590: Wrong error message on sort buffer being too small. +# +create table t1(a int, b text); +insert into t1 values (1,REPEAT('x', 60000)),(3,REPEAT('y', 60000)); +set session sort_buffer_size= 32768; +CALL mtr.add_suppression("Out of sort memory"); +select * from t1 order by b; +ERROR HY001: Out of sort memory, consider increasing server sort buffer size +drop table t1; +call mtr.add_suppression("Out of sort memory; increase server sort buffer size"); +# +# Bug #39844: Query Crash Mysql Server 5.0.67 +# +CREATE TABLE t1 (a INT PRIMARY KEY); +CREATE TABLE t2 (a INT PRIMARY KEY, b INT); +CREATE TABLE t3 (c INT); +INSERT INTO t1 (a) VALUES (1), (2); +INSERT INTO t2 (a,b) VALUES (1,2), (2,3); +INSERT INTO t3 (c) VALUES (1), (2); +SELECT +(SELECT t1.a FROM t1, t2 WHERE t1.a = t2.b AND t2.a = t3.c ORDER BY t1.a) +FROM t3; +(SELECT t1.a FROM t1, t2 WHERE t1.a = t2.b AND t2.a = t3.c ORDER BY t1.a) +2 +NULL +DROP TABLE t1, t2, t3; +# +# Bug #42760: Select doesn't return desired results when we have null +# values +# +CREATE TABLE t1 ( +a INT, +c INT, +UNIQUE KEY a_c (a,c), +KEY (a)); +INSERT INTO t1 VALUES (1, 10), (2, NULL); +# Must use ref-or-null on the a_c index +EXPLAIN +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 75.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a_c,a a 5 const 1 75.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `col` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` +# Must return 1 row +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +col +1 +# Must use ref-or-null on the a_c index +EXPLAIN +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL ALL NULL x x x x 75.00 x +x x x NULL ref a_c,a x x x x 75.00 x +Warnings: +x x x +# Must return 1 row +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +col +1 +DROP TABLE t1; +End of 5.0 tests +CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, +UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b)) +charset utf8mb4; +CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b)) +charset utf8mb4; +INSERT INTO t3 SELECT * FROM t1; +EXPLAIN +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1 NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a,b b 13 const 4 100.00 Using index condition; Using where; Using temporary; Using filesort +2 SIMPLE t2 NULL ref a,b,c a 136 test.t1.a,const 1 78.90 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1 +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1 NULL ALL NULL NULL NULL NULL 415 27.57 Parallel execute (1 workers) +2 SIMPLE t2 NULL range a,b,c c 5 NULL 415 27.57 Using index condition; Using where +2 SIMPLE t1 NULL eq_ref a a 144 test.t2.a,const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t3` `t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1 +SELECT d FROM t3 AS t1, t2 AS t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.110 ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +13 12 12 +14 13 13 +15 14 14 +16 15 15 +17 16 16 +18 17 17 +19 18 18 +20 19 19 +21 20 20 +22 21 21 +23 22 22 +24 23 23 +25 24 24 +26 25 25 +27 26 26 +28 27 27 +29 28 28 +30 29 29 +31 30 30 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +22 21 21 +23 22 22 +24 23 23 +25 24 24 +26 25 25 +27 26 26 +28 27 27 +29 28 28 +30 29 29 +31 30 30 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +set sort_buffer_size= 32768; +CREATE TEMPORARY TABLE tmp (f1 int, f2 varchar(20)); +INSERT INTO tmp SELECT f1, f2 FROM t1; +INSERT INTO t1(f1, f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1, f2 FROM t1; +INSERT INTO t1(f1, f2) SELECT * FROM tmp; +SELECT * FROM t1 ORDER BY f1 ASC, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +SELECT * FROM t1 ORDER BY f1 ASC, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 ORDER BY f2 DESC, f0 LIMIT 30; +f0 f1 f2 +100 99 99 +200 99 99 +327 99 99 +427 99 99 +527 99 99 +99 98 98 +199 98 98 +326 98 98 +426 98 98 +526 98 98 +98 97 97 +198 97 97 +325 97 97 +425 97 97 +525 97 97 +97 96 96 +197 96 96 +324 96 96 +424 96 96 +524 96 96 +96 95 95 +196 95 95 +323 95 95 +423 95 95 +523 95 95 +95 94 94 +195 94 94 +322 94 94 +422 94 94 +522 94 94 +SELECT * FROM t1 ORDER BY f2 DESC, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +set sort_buffer_size= 32768; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 +ORDER BY f1, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 +ORDER BY f1, f0 LIMIT 0; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +set sort_buffer_size= 327680; +SELECT * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30; +f0 f1 f2 f1 f2 +1 0 0 0 0 +1 0 0 0 0 +1 0 0 0 0 +101 0 0 0 0 +101 0 0 0 0 +101 0 0 0 0 +228 0 0 0 0 +228 0 0 0 0 +228 0 0 0 0 +328 0 0 0 0 +328 0 0 0 0 +328 0 0 0 0 +428 0 0 0 0 +428 0 0 0 0 +428 0 0 0 0 +2 1 1 1 1 +2 1 1 1 1 +2 1 1 1 1 +102 1 1 1 1 +102 1 1 1 1 +102 1 1 1 1 +229 1 1 1 1 +229 1 1 1 1 +229 1 1 1 1 +329 1 1 1 1 +329 1 1 1 1 +329 1 1 1 1 +429 1 1 1 1 +429 1 1 1 1 +429 1 1 1 1 +SELECT * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +3 2 2 2 2 +3 2 2 2 2 +3 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +4 3 3 3 3 +4 3 3 3 3 +4 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +3 2 2 2 2 +3 2 2 2 2 +3 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +4 3 3 3 3 +4 3 3 3 3 +4 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +1500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 JOIN tmp on t1.f2=tmp.f2 +WHERE t1.f2>20 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +24 23 23 23 23 +24 23 23 23 23 +24 23 23 23 23 +124 23 23 23 23 +124 23 23 23 23 +124 23 23 23 23 +251 23 23 23 23 +251 23 23 23 23 +251 23 23 23 23 +351 23 23 23 23 +351 23 23 23 23 +351 23 23 23 23 +451 23 23 23 23 +451 23 23 23 23 +451 23 23 23 23 +25 24 24 24 24 +25 24 24 24 24 +25 24 24 24 24 +125 24 24 24 24 +125 24 24 24 24 +125 24 24 24 24 +252 24 24 24 24 +252 24 24 24 24 +252 24 24 24 24 +352 24 24 24 24 +352 24 24 24 24 +352 24 24 24 24 +452 24 24 24 24 +452 24 24 24 24 +452 24 24 24 24 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +1185 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +CREATE VIEW v1 as SELECT * FROM t1 ORDER BY f1, f0 LIMIT 30; +SELECT * FROM v1; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +drop view v1; +CREATE VIEW v1 as SELECT * FROM t1 ORDER BY f1, f0 LIMIT 100; +SELECT * FROM v1 ORDER BY f2, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +11 10 10 +111 10 10 +238 10 10 +338 10 10 +438 10 10 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +CREATE VIEW v2 as SELECT * FROM t1 ORDER BY f2, f0 LIMIT 100; +SELECT * FROM v1 JOIN v2 on v1.f1=v2.f1 ORDER BY v1.f2,v1.f0,v2.f0 +LIMIT 30; +f0 f1 f2 f0 f1 f2 +1 0 0 1 0 0 +1 0 0 101 0 0 +1 0 0 228 0 0 +1 0 0 328 0 0 +1 0 0 428 0 0 +101 0 0 1 0 0 +101 0 0 101 0 0 +101 0 0 228 0 0 +101 0 0 328 0 0 +101 0 0 428 0 0 +228 0 0 1 0 0 +228 0 0 101 0 0 +228 0 0 228 0 0 +228 0 0 328 0 0 +228 0 0 428 0 0 +328 0 0 1 0 0 +328 0 0 101 0 0 +328 0 0 228 0 0 +328 0 0 328 0 0 +328 0 0 428 0 0 +428 0 0 1 0 0 +428 0 0 101 0 0 +428 0 0 228 0 0 +428 0 0 328 0 0 +428 0 0 428 0 0 +2 1 1 2 1 1 +2 1 1 102 1 1 +2 1 1 229 1 1 +2 1 1 329 1 1 +2 1 1 429 1 1 +SELECT floor(f1/10) f3, count(f2) FROM t1 +GROUP BY 1 ORDER BY 2,1 LIMIT 5; +f3 count(f2) +0 50 +1 50 +2 50 +3 50 +4 50 +SELECT floor(f1/10) f3, count(f2) FROM t1 +GROUP BY 1 ORDER BY 2,1 LIMIT 0; +f3 count(f2) +CREATE PROCEDURE wl1393_sp_test() +BEGIN +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 30; +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 15 OFFSET 15; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 15 OFFSET 15; +SELECT FOUND_ROWS(); +SELECT * FROM v1 ORDER BY f2, f0 LIMIT 30; +END| +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +CALL wl1393_sp_test()| +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +f0 f1 f2 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +f0 f1 f2 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +FOUND_ROWS() +445 +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +11 10 10 +111 10 10 +238 10 10 +338 10 10 +438 10 10 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +DROP PROCEDURE wl1393_sp_test| +SELECT d1.f1, d1.f2 FROM t1 +LEFT JOIN (SELECT * FROM t1 ORDER BY f1 LIMIT 30) d1 on t1.f1=d1.f1 +ORDER BY d1.f2 DESC LIMIT 30; +f1 f2 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +4 4 +4 4 +4 4 +4 4 +4 4 +SELECT * FROM t1 WHERE f1 = (SELECT f1 FROM t1 ORDER BY 1 LIMIT 1); +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +SELECT * FROM t1 WHERE f1 = (SELECT f1 FROM t1 ORDER BY 1 LIMIT 2); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, tmp; +DROP VIEW v1, v2; +# end of WL#1393 - Optimizing filesort with small limit +# +# Bug #58761 +# Crash in Field::is_null in field.h on subquery in WHERE clause +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +INSERT INTO t1 VALUES (27,7,'x'); +INSERT INTO t1 VALUES (28,6,'m'); +INSERT INTO t1 VALUES (29,4,'c'); +CREATE TABLE where_subselect +SELECT DISTINCT `pk` AS field1 , `pk` AS field2 +FROM t1 AS alias1 +WHERE alias1 . `col_int_key` > 229 +OR alias1 . `col_varchar_key` IS NOT NULL +GROUP BY field1, field2 +; +SELECT * +FROM where_subselect +WHERE (field1, field2) IN ( +SELECT DISTINCT `pk` AS field1 , `pk` AS field2 +FROM t1 AS alias1 +WHERE alias1 . `col_int_key` > 229 +OR alias1 . `col_varchar_key` IS NOT NULL +GROUP BY field1, field2 +); +field1 field2 +27 27 +28 28 +29 29 +DROP TABLE t1; +DROP TABLE where_subselect; +# End of Bug #58761 +CREATE TABLE t1 ( +id1 INT NOT NULL, +id2 INT NOT NULL, +junk INT NOT NULL, +PRIMARY KEY (id1, id2, junk), +INDEX id2_j_id1 (id2, junk, id1) +); +INSERT INTO t1 VALUES (1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4); +INSERT INTO t1 VALUES (5, 2, 1), (6, 2, 2), (7, 2, 3), (8, 2, 4); +INSERT INTO t1 VALUES (9, 3, 1), (10, 3, 2), (11, 3, 3), (12, 3, 4); +INSERT INTO t1 VALUES (13, 4, 1), (14, 4, 2), (15, 4, 3), (16, 4, 4); +INSERT INTO t1 VALUES (17, 5, 1), (18, 5, 2), (19, 5, 3), (20, 5, 4); +INSERT INTO t1 VALUES (21, 6, 1), (22, 6, 2), (23, 6, 3), (24, 6, 4); +INSERT INTO t1 VALUES (25, 7, 1), (26, 7, 2), (27, 7, 3), (28, 7, 4); +INSERT INTO t1 VALUES (29, 8, 1), (30, 8, 2), (31, 8, 3), (32, 8, 4); +INSERT INTO t1 VALUES (33, 9, 1), (34, 9, 2), (35, 9, 3), (36, 9, 4); +EXPLAIN SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,id2_j_id1 id2_j_id1 4 const 4 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` where (`test`.`t1`.`id2` = 4) order by `test`.`t1`.`id1` +SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; +id1 +13 +14 +15 +16 +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, +b INT NOT NULL, +c char(100), +KEY (b, c), +KEY (b, a, c) +) +DEFAULT CHARSET = utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); +INSERT INTO t1 SELECT a + 10, b, c + 10 FROM t1; +INSERT INTO t1 SELECT a + 20, b, c + 20 FROM t1; +INSERT INTO t1 SELECT a + 40, b, c + 40 FROM t1; +INSERT INTO t1 SELECT a + 80, b, c + 80 FROM t1; +INSERT INTO t1 SELECT a + 160, b, c + 160 FROM t1; +INSERT INTO t1 SELECT a + 320, b, c + 320 FROM t1; +INSERT INTO t1 SELECT a + 640, b, c + 640 FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c + 1280 FROM t1 LIMIT 80; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 208 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref b,b_2 b_2 4 const 208 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`c` desc limit 9 +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +a +991 +981 +971 +961 +951 +941 +931 +921 +911 +EXPLAIN +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,b_2 b_2 4 const 208 100.00 Using index; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`c` desc limit 0,9 +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; +a +991 +981 +971 +961 +951 +941 +931 +921 +911 +DROP TABLE t1; +# +# Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join buffering +# is used +# +CREATE TABLE t1 (a INT, b INT, KEY (a)); +INSERT INTO t1 VALUES (0, NULL), (1, NULL), (2, NULL), (3, NULL); +INSERT INTO t1 SELECT a+4, b FROM t1; +INSERT INTO t1 SELECT a+8, b FROM t1; +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL), (4,NULL); +INSERT INTO t2 SELECT a+4, b FROM t2; +# shouldn't have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` FORCE INDEX FOR ORDER BY (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +# should have "using filesort" +EXPLAIN +SELECT * FROM t1 USE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition; Using MRR; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` USE INDEX FOR ORDER BY (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +# should have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR JOIN (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using index condition; Using MRR; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` FORCE INDEX FOR JOIN (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +DROP TABLE t1, t2; +# +# Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and +# ORDER BY computed col +# +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, KEY( a, b ) ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t1 SELECT a + 5, b + 5 FROM t1; +CREATE TABLE t2( a INT PRIMARY KEY, b INT ); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t2 SELECT a + 5, b + 5 FROM t2; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT count(*) AS c, t1.a +FROM t1 JOIN t2 ON t1.b = t2.a +WHERE t2.b = 1 +GROUP BY t1.a +ORDER by c +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 10 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t1 NULL index a a 8 NULL 10 10.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `c`,`test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 1)) group by `test`.`t1`.`a` order by `c` limit 2 +DROP TABLE t1, t2; +# +# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory +# and +# Bug #59308: Incorrect result for +SELECT DISTINCT ... ORDER BY DESC + +# Use Valgrind to detect #59110! +# +CREATE TABLE t1 (a INT,KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a`,1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` <> 1) order by `test`.`t1`.`a` desc +SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC; +a 1 +10 1 +9 1 +8 1 +7 1 +6 1 +5 1 +4 1 +3 1 +2 1 +DROP TABLE t1; +# +# Bug#11765255 58201: +# VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS +# +select count(*) order by max(1) + min(1); +count(*) +1 +End of 5.1 tests +# +# Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY +# when it should use index +# +CREATE TABLE t1 (i1 integer NOT NULL PRIMARY KEY); +CREATE TABLE t2 (i2 integer NOT NULL PRIMARY KEY); +CREATE TABLE t3 (i3 integer); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2 +LEFT JOIN t3 ON t2.i2 = t3.i3 +ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 12 100.00 Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i1 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i3` = `test`.`t1`.`i1`)) where (`test`.`t2`.`i2` = `test`.`t1`.`i1`) order by `test`.`t1`.`i1` limit 5 +SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2 +LEFT JOIN t3 ON t2.i2 = t3.i3 +ORDER BY t1.i1 LIMIT 5; +i1 i2 +1 1 +2 2 +3 3 +4 4 +5 5 +DROP TABLE t1, t2, t3; +# +# Bug #11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION +# `TAB->REF.USE_COUNT' +# +CREATE TABLE t1(a INT PRIMARY KEY); +CREATE TABLE t2(b INT,c INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1,2), (2,3); +SELECT (SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) FROM t2; +(SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) +NULL +NULL +DROP TABLE t1, t2; +# +# Bug #13531865 +# TEST_IF_SKIP_SORT_ORDER() INCORRECTLY SKIP FILESORT IF +# 'TYPE' IS REF_OR_NULL +# +# +CREATE TABLE t1 ( +a INT, +c INT, +UNIQUE KEY a_c (a,c), +KEY (a)) engine=myisam; +INSERT INTO t1 VALUES (1,10), (2,NULL), (2,10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Using 'KEY a_c' for order-by opt, would have required +# REF_OR_NULL access which never can be order_by skipped. +# -> Keep initial REF on 'KEY a' selected by cond. optimizer +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +c +NULL +10 +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` desc +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +c +10 +NULL +DROP TABLE t1; +# +# Bug #13528826 +# TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT' +# +# +CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam; +INSERT INTO t1 VALUES +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam; +INSERT INTO t2 VALUES +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +# number of rows in t1 was incorrectly used as an +# implicit limit-clause if not explicit specified +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +# Query above used to be explained identical to this: +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` limit 8 +# A really high limit was required to give the correct explain +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 1000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` limit 1000 +DROP TABLE t1, t2; +# +# Bug #13949068 ASSERT TAB->REF.KEY == REF_KEY IN +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG +# +CREATE TABLE t1 (a INT, b INT, KEY(b), KEY(b,a)) ENGINE=INNODB; +INSERT INTO t1 VALUES (0,0); +EXPLAIN SELECT DISTINCT a FROM t1 WHERE b=1 ORDER BY 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,b_2 b_2 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`a` +SELECT DISTINCT a FROM t1 WHERE b=1 ORDER BY 1; +a +DROP TABLE t1; +# +# Bug#18636076 DEBUG CRASH ON +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3); +CREATE VIEW view_t1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +i1 INTEGER NOT NULL +) ENGINE=MyISAM; +EXPLAIN SELECT DISTINCT t2.i1, view_t1.pk +FROM view_t1 LEFT JOIN t2 +ON view_t1.pk = t2.i1 +WHERE (view_t1.pk <= 204 AND t2.i1 != 3) +OR view_t1.pk BETWEEN 1 AND 7 +ORDER BY t2.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct NULL AS `i1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (((`test`.`t1`.`pk` <= 204) and (NULL <> 3)) or (`test`.`t1`.`pk` between 1 and 7)) order by NULL +SELECT DISTINCT t2.i1, view_t1.pk +FROM view_t1 LEFT JOIN t2 +ON view_t1.pk = t2.i1 +WHERE (view_t1.pk <= 204 AND t2.i1 != 3) +OR view_t1.pk BETWEEN 1 AND 7 +ORDER BY t2.i1; +i1 pk +NULL 1 +NULL 2 +NULL 3 +DROP VIEW view_t1; +DROP TABLE t1, t2; +SET sql_mode = default; +# +# Bug#20455386 INVALID WRITE IN COPY_FIELD::SET CAUSE CRASH WITH TMP TABLES +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +CREATE TABLE t2(c INT) ENGINE=INNODB; +CREATE TABLE t3(b BLOB NOT NULL) ENGINE=INNODB; +SELECT +(SELECT 1 FROM t1 +WHERE (SELECT c FROM t2 ORDER BY COUNT(t3.b )) +) +FROM t3; +(SELECT 1 FROM t1 +WHERE (SELECT c FROM t2 ORDER BY COUNT(t3.b )) +) +NULL +DROP TABLE t1,t2,t3; +# +# Bug#16833464: Presence of ORDER BY changes data type of column in +# CREATE TABLE SELECT +CREATE TABLE z1 (c05 TIME); +(SELECT * FROM z1 ORDER BY '1') ORDER BY '1'; +c05 +CREATE TABLE z2 (SELECT * FROM z1 ORDER BY '1') ORDER BY '1'; +CREATE TABLE z3 (SELECT * FROM z1) ORDER BY '1'; +SHOW CREATE TABLE z2; +Table Create Table +z2 CREATE TABLE `z2` ( + `c05` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE z3; +Table Create Table +z3 CREATE TABLE `z3` ( + `c05` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE z1, z2, z3; +set optimizer_switch=default; diff --git a/mysql-test/r/order_by_limit.result-pq b/mysql-test/r/order_by_limit.result-pq new file mode 100644 index 000000000..2438bd862 --- /dev/null +++ b/mysql-test/r/order_by_limit.result-pq @@ -0,0 +1,477 @@ +# +# WL#6986 : Make switching of index due to order by limit cost based +# +# Testcase for Bug#16522053 +CREATE TABLE t1 ( +pk INT PRIMARY KEY AUTO_INCREMENT, +i INT, +j INT, +INDEX (i), +INDEX (j) +); +INSERT INTO t1 (i,j) VALUES (1,1); +set @d=1; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +INSERT INTO t1 (i,j) SELECT i+@d, j+@d from t1; +set @d=@d*2; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE i<100 AND j<10 +ORDER BY i LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 77.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i,j j 5 NULL 9 77.34 Using index condition; Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j` from `test`.`t1` where ((`test`.`t1`.`i` < 100) and (`test`.`t1`.`j` < 10)) order by `test`.`t1`.`i` limit 5 +SELECT * FROM t1 +WHERE i<100 AND j<10 +ORDER BY i LIMIT 5; +pk i j +1 1 1 +2 2 2 +3 3 3 +4 4 4 +6 5 5 +DROP TABLE t1; +CREATE TABLE t0 ( +i0 INTEGER NOT NULL +); +INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +i2 INTEGER NOT NULL, +INDEX k1 (i1), +INDEX k2 (i1,i2) +) ENGINE=InnoDB; +INSERT INTO t1 +SELECT a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 1000, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 1000 +FROM t0 AS a0, t0 AS a1; +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +INDEX k1 (i1) +) ENGINE=InnoDB; +INSERT INTO t2 +SELECT a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 500 +FROM t0 AS a0, t0 AS a1; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +# Query should use index to optimize the ORDER BY LIMIT +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 2 +ORDER BY t1.i1 LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 29.70 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 6 29.70 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000) and (`test`.`t1`.`i1` > 2)) order by `test`.`t1`.`i1` limit 2 +# Query should not make the switch to use index to +# optimize ORDER BY LIMIT. So should be using filesort +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 2 +ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 99.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 PRIMARY 4 NULL 30 99.00 Using where; Using filesort +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000) and (`test`.`t1`.`i1` > 2)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 2 +ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +8080 80 80 8080 80 +9090 90 90 9090 90 +7171 171 171 7171 171 +8181 181 181 8181 181 +# Changing range condition on i1 should make +# key on i1 get picked to give the order +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 800 +ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 30.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 k2 4 NULL 20 30.00 Using where; Using index +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000) and (`test`.`t1`.`i1` > 800)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t1.i1 > 800 +ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +# Use range condition only on pk to see if switch +# happens just for ORDER BY LIMIT +# Should not happen unless range results in too +# many records +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 PRIMARY 4 NULL 30 100.00 Using where; Using filesort +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +8080 80 80 8080 80 +9090 90 90 9090 90 +7171 171 171 7171 171 +8181 181 181 8181 181 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 1000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 5 90.00 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 1000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 1000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +1010 10 10 1010 10 +2020 20 20 2020 20 +3030 30 30 3030 30 +4040 40 40 4040 40 +5050 50 50 5050 50 +# check if switch happens when the index for order +# by is non-covering +EXPLAIN SELECT t1.i1,t1.i2 FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 100 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 99.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 5 99.00 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 100)) order by `test`.`t1`.`i1` limit 5 +SELECT t1.i1,t1.i2 FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 100 ORDER BY t1.i1 LIMIT 5; +i1 i2 +10 10 +20 20 +30 30 +40 40 +50 50 +# Reduce the fanout for table t2 and check +# that index for order by is not choosen +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t2.pk = 100 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1,k2 PRIMARY 4 NULL 30 100.00 Using where; Using filesort +2 SIMPLE t2 NULL const PRIMARY,k1 PRIMARY 4 const 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t2`.`pk` = 100) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 and t2.pk = 100 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +# Increase the fanout to see if index gets choosen +# for order by for which range scan was choosen +# earlier +INSERT INTO t2 +SELECT a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0 + 1, +(a0.i0 + 10*a1.i0 + 100*a0.i0 + 1000*a1.i0) % 500 +FROM t0 AS a0, t0 AS a1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 30.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k1 4 NULL 6 30.00 Using where +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 STRAIGHT_JOIN t2 ON t1.i1=t2.i1 +WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +7070 70 70 7071 70 +8080 80 80 8080 80 +8080 80 80 8081 80 +9090 90 90 9090 90 +# Check if the index for order by is used when +# force index is done on order by +EXPLAIN SELECT * FROM t1 FORCE INDEX FOR ORDER BY (k2) STRAIGHT_JOIN t2 ON +t1.i1=t2.i1 WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 30.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,k1,k2 k2 8 NULL 6 30.00 Using where; Using index +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` FORCE INDEX FOR ORDER BY (`k2`) straight_join `test`.`t2` where ((`test`.`t2`.`i1` = `test`.`t1`.`i1`) and (`test`.`t1`.`pk` > 7000)) order by `test`.`t1`.`i1` limit 5 +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (k2) STRAIGHT_JOIN t2 ON +t1.i1=t2.i1 WHERE t1.pk > 7000 ORDER BY t1.i1 LIMIT 5; +pk i1 i2 pk i1 +7070 70 70 7070 70 +7070 70 70 7071 70 +8080 80 80 8080 80 +8080 80 80 8081 80 +9090 90 90 9090 90 +DROP TABLE t0, t1, t2; +# +# Bug #26483909: INCORRECT BEHAVIOR FOR QUERY WITH DISTINCT +# and ORDER BY ... LIMIT. +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int int(11), +col_varchar_key varchar(20), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key), +KEY col_varchar_key_2 (col_varchar_key(5)) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,2,'t'), (2,5,'efqsdksj'), +(3,NULL,'fqsdksjijcs'),(4,8,'qsdksjijc'), +(5,40,NULL),(6,3,'dkz'),(7,2,NULL), +(8,3,'dks'),(9,0,'ksjijcsz'), +(10,84,'sjijcszxwbjj'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET @@SESSION.sql_mode='NO_ENGINE_SUBSTITUTION'; +EXPLAIN SELECT DISTINCT col_int +FROM t1 +WHERE col_varchar_key <> 'c' + OR col_varchar_key > 'w' +ORDER BY col_varchar_key +LIMIT 100; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range col_varchar_key,col_varchar_key_2 col_varchar_key_2 23 NULL 8 100.00 Using where; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`col_int` AS `col_int` from `test`.`t1` where ((`test`.`t1`.`col_varchar_key` <> 'c') or (`test`.`t1`.`col_varchar_key` > 'w')) order by `test`.`t1`.`col_varchar_key` limit 100 +SELECT DISTINCT col_int +FROM t1 +WHERE col_varchar_key <> 'c' + OR col_varchar_key > 'w' +ORDER BY col_varchar_key +LIMIT 100; +col_int +3 +5 +NULL +0 +8 +84 +2 +DROP TABLE t1; +# +# Bug#29487181 INCORRECT 'ROWS' AND 'FILTERED' ESTIMATE IN +# 'ORDER BY ... LIMIT .' QUERIES +# +CREATE TABLE t1 ( +col_int_unique INT DEFAULT NULL, +col_int_key INT DEFAULT NULL, +UNIQUE KEY col_int_unique (col_int_unique), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (49,49), (9,7), (0,1), (2,42); +CREATE TABLE t2 ( +col_int_unique INT DEFAULT NULL, +pk INT NOT NULL, +PRIMARY KEY (pk), +UNIQUE KEY col_int_unique (col_int_unique) +); +INSERT INTO t2 VALUES (2,8), (5,2), (6,1); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT STRAIGHT_JOIN t1.col_int_key AS field1 +FROM t1 JOIN t2 +ON t2.pk = t1.col_int_unique OR +t2.col_int_unique = t1.col_int_key +ORDER BY field1 LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_int_unique,col_int_key NULL NULL NULL 4 100.00 Using filesort +2 SIMPLE t2 NULL ALL PRIMARY,col_int_unique NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`col_int_key` AS `field1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`pk` = `test`.`t1`.`col_int_unique`) or (`test`.`t2`.`col_int_unique` = `test`.`t1`.`col_int_key`)) order by `field1` limit 2 +DROP TABLE t1,t2; +# +# Bug#30348211: DANGEROUS OPTIMIZATION RECONSIDERING_ACCESS_PATHS_FOR_ +# INDEX_ORDERING +# +CREATE TABLE t (id BIGINT NOT NULL, other_id BIGINT NOT NULL, +covered_column VARCHAR(50) NOT NULL, non_covered_column VARCHAR(50) NOT NULL, +PRIMARY KEY (id), +INDEX index_other_id_covered_column (other_id, covered_column)); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (10, 10, '10', '10'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (9, 9, '9', '9'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (8, 8, '8', '8'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (7, 7, '7', '7'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (6, 6, '6', '6'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (5, 5, '5', '5'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (4, 4, '4', '4'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (3, 3, '3', '3'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (2, 2, '2', '2'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (1, 1, '1', '1'); +SET +optimizer_trace = "enabled=on", +optimizer_trace_max_mem_size = 1000000, +end_markers_in_json = ON; +SET optimizer_switch = "prefer_ordering_index=on"; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 70.00 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column PRIMARY 8 NULL 2 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL range index_other_id_covered_column index_other_id_covered_column 8 NULL 7 100.00 Using index condition; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_0 FROM information_schema.optimizer_trace; +should_be_0 +0 +SET optimizer_switch = default; +EXPLAIN SELECT non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 70.00 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column PRIMARY 8 NULL 2 70.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=on"; +EXPLAIN SELECT /*+ ORDER_INDEX(t PRIMARY) */ non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index NULL PRIMARY 8 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t`@`select#1` `PRIMARY`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT /*+ ORDER_INDEX(t PRIMARY) */ non_covered_column FROM t WHERE other_id > 3 ORDER BY id ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index NULL PRIMARY 8 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ ORDER_INDEX(`t`@`select#1` `PRIMARY`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`other_id` > 3) order by `test`.`t`.`id` limit 2 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (10+1+10, 10, '10', '10'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (9+1+10, 9, '9', '9'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (8+1+10, 8, '8', '8'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (7+1+10, 7, '7', '7'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (6+1+10, 6, '6', '6'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (5+1+10, 5, '5', '5'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (4+1+10, 4, '4', '4'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (3+1+10, 3, '3', '3'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (2+1+10, 2, '2', '2'); +INSERT INTO t (id, other_id, covered_column, non_covered_column) +VALUES (1+1+10, 1, '1', '1'); +SET optimizer_switch = "prefer_ordering_index=on"; +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 60.00 Parallel execute (1 workers) +2 SIMPLE t NULL index PRIMARY,index_other_id_covered_column index_other_id_covered_column 210 NULL 3 60.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,index_other_id_covered_column PRIMARY 8 NULL 12 100.00 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_0 FROM information_schema.optimizer_trace; +should_be_0 +0 +SET optimizer_switch = default; +EXPLAIN SELECT non_covered_column FROM t WHERE id > 8 GROUP BY id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,index_other_id_covered_column PRIMARY 8 NULL 12 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +0 +SET optimizer_switch = "prefer_ordering_index=on"; +EXPLAIN SELECT /*+ GROUP_INDEX(t index_other_id_covered_column) */ non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column index_other_id_covered_column 210 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t`@`select#1` `index_other_id_covered_column`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +SET optimizer_switch = "prefer_ordering_index=off"; +EXPLAIN SELECT /*+ GROUP_INDEX(t index_other_id_covered_column) */ non_covered_column FROM t WHERE id > 8 GROUP BY other_id LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL index index_other_id_covered_column index_other_id_covered_column 210 NULL 2 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ GROUP_INDEX(`t`@`select#1` `index_other_id_covered_column`) */ `test`.`t`.`non_covered_column` AS `non_covered_column` from `test`.`t` where (`test`.`t`.`id` > 8) group by `test`.`t`.`other_id` limit 1 +SELECT (trace LIKE '%"plan_changed": true%') AS should_be_1 FROM information_schema.optimizer_trace; +should_be_1 +1 +DROP TABLE t; diff --git a/mysql-test/r/order_by_none.result-pq b/mysql-test/r/order_by_none.result-pq new file mode 100644 index 000000000..2902b7d68 --- /dev/null +++ b/mysql-test/r/order_by_none.result-pq @@ -0,0 +1,3396 @@ +drop table if exists t1,t2,t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +id int(6) DEFAULT '0' NOT NULL, +idservice int(5), +clee char(20) NOT NULL, +flag char(1), +KEY id (id), +PRIMARY KEY (clee) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,4,'6067169d','Y'); +INSERT INTO t1 VALUES (2,5,'606716d1','Y'); +INSERT INTO t1 VALUES (2,1,'606717c1','Y'); +INSERT INTO t1 VALUES (3,1,'6067178d','Y'); +INSERT INTO t1 VALUES (2,6,'60671515','Y'); +INSERT INTO t1 VALUES (2,7,'60671569','Y'); +INSERT INTO t1 VALUES (2,3,'dd','Y'); +CREATE TABLE t2 ( +id int(6) NOT NULL auto_increment, +description varchar(40) NOT NULL, +idform varchar(40), +ordre int(6) unsigned DEFAULT '0' NOT NULL, +image varchar(60), +PRIMARY KEY (id), +KEY id (id,ordre) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,'Emettre un appel d''offres','en_construction.html',10,'emettre.gif'); +INSERT INTO t2 VALUES (2,'Emettre des soumissions','en_construction.html',20,'emettre.gif'); +INSERT INTO t2 VALUES (7,'Liste des t2','t2_liste_form.phtml',51060,'link.gif'); +INSERT INTO t2 VALUES (8,'Consulter les soumissions','consulter_soumissions.phtml',200,'link.gif'); +INSERT INTO t2 VALUES (9,'Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif'); +INSERT INTO t2 VALUES (10,'Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 VALUES (3,'Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 VALUES (4,'Modifier des clients','en_construction.html',40010,'link.gif'); +INSERT INTO t2 VALUES (5,'Effacer des clients','en_construction.html',40020,'link.gif'); +INSERT INTO t2 VALUES (6,'Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif'); +select t1.id,t1.idservice,t2.ordre,t2.description from t1, t2 where t1.id = 2 and t1.idservice = t2.id order by t2.ordre; +id idservice ordre description +2 1 10 Emettre un appel d'offres +2 3 40000 Créer une fiche de client +2 4 40010 Modifier des clients +2 5 40020 Effacer des clients +2 6 51050 Ajouter un service +2 7 51060 Liste des t2 +drop table t1,t2; +create table t1 (first char(10),last char(10)); +insert into t1 values ("Michael","Widenius"); +insert into t1 values ("Allan","Larsson"); +insert into t1 values ("David","Axmark"); +select concat(first," ",last) as name from t1 order by name; +name +Allan Larsson +David Axmark +Michael Widenius +select concat(last," ",first) as name from t1 order by name; +name +Axmark David +Larsson Allan +Widenius Michael +drop table t1; +create table t1 (i int); +insert into t1 values(1),(2),(1),(2),(1),(2),(3); +select distinct i from t1; +i +1 +2 +3 +select distinct i from t1 order by rand(5); +i +1 +2 +3 +select distinct i from t1 order by i desc; +i +3 +2 +1 +select distinct i from t1 order by 1-i; +i +3 +2 +1 +select distinct i from t1 order by mod(i,2),i; +i +2 +1 +3 +drop table t1; +create table t1 ( pk int primary key, name varchar(255) not null, number varchar(255) not null); +insert into t1 values (1, 'Gamma', '123'), (2, 'Gamma Ext', '123a'), (3, 'Alpha', '001'), (4, 'Beta', '200c'); +select distinct t1.name as 'Building Name',t1.number as 'Building Number' from t1 order by t1.name asc; +Building Name Building Number +Alpha 001 +Beta 200c +Gamma 123 +Gamma Ext 123a +drop table t1; +create table t1 (id int not null,col1 int not null,col2 int not null,index(col1)); +insert into t1 values(1,2,2),(2,2,1),(3,1,2),(4,1,1),(5,1,4),(6,2,3),(7,3,1),(8,2,4); +select * from t1 order by col1,col2; +id col1 col2 +4 1 1 +3 1 2 +5 1 4 +2 2 1 +1 2 2 +6 2 3 +8 2 4 +7 3 1 +select col1 from t1 order by id; +col1 +2 +2 +1 +1 +1 +2 +3 +2 +select col1 as id from t1 order by id; +id +1 +1 +1 +2 +2 +2 +2 +3 +select concat(col1) as id from t1 order by id; +id +1 +1 +1 +2 +2 +2 +2 +3 +drop table t1; +CREATE TABLE t1 (id int auto_increment primary key,aika varchar(40),aikakentta timestamp); +insert into t1 (aika) values ('Keskiviikko'); +insert into t1 (aika) values ('Tiistai'); +insert into t1 (aika) values ('Maanantai'); +insert into t1 (aika) values ('Sunnuntai'); +SELECT FIELD(SUBSTRING(t1.aika,1,2),'Ma','Ti','Ke','To','Pe','La','Su') AS test FROM t1 ORDER by test; +test +1 +2 +3 +7 +drop table t1; +CREATE TABLE t1 +( +a int unsigned NOT NULL, +b int unsigned NOT NULL, +c int unsigned NOT NULL, +UNIQUE(a), +INDEX(b), +INDEX(c) +); +CREATE TABLE t2 +( +c int unsigned NOT NULL, +i int unsigned NOT NULL, +INDEX(c) +); +CREATE TABLE t3 +( +c int unsigned NOT NULL, +v varchar(64), +INDEX(c) +); +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t1 VALUES (2,1,2); +INSERT INTO t1 VALUES (3,2,1); +INSERT INTO t1 VALUES (4,2,2); +INSERT INTO t2 VALUES (1,50); +INSERT INTO t2 VALUES (2,25); +INSERT INTO t3 VALUES (1,'123 Park Place'); +INSERT INTO t3 VALUES (2,'453 Boardwalk'); +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 USING(c) +LEFT JOIN t3 ON t3.c = t1.c; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 USING(c) +LEFT JOIN t3 ON t3.c = t1.c +ORDER BY a; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c +ORDER BY a; +a b if(b = 1,i,if(b = 2,v,'')) +1 1 50 +2 1 25 +3 2 123 Park Place +4 2 453 Boardwalk +drop table t1,t2,t3; +create table t1 (ID int not null primary key, TransactionID int not null); +insert into t1 (ID, TransactionID) values (1, 87), (2, 89), (3, 92), (4, 94), (5, 486), (6, 490), (7, 753), (9, 828), (10, 832), (11, 834), (12, 840); +create table t2 (ID int not null primary key, GroupID int not null); +insert into t2 (ID, GroupID) values (87, 87), (89, 89), (92, 92), (94, 94), (486, 486), (490, 490),(753, 753), (828, 828), (832, 832), (834, 834), (840, 840); +create table t3 (ID int not null primary key, DateOfAction date not null); +insert into t3 (ID, DateOfAction) values (87, '1999-07-19'), (89, '1999-07-19'), (92, '1999-07-19'), (94, '1999-07-19'), (486, '1999-07-18'), (490, '2000-03-27'), (753, '2000-03-28'), (828, '1999-07-27'), (832, '1999-07-27'),(834, '1999-07-27'), (840, '1999-07-27'); +select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t3.DateOfAction, t1.TransactionID; +DateOfAction TransactionID +1999-07-18 486 +1999-07-19 87 +1999-07-19 89 +1999-07-19 92 +1999-07-19 94 +1999-07-27 828 +1999-07-27 832 +1999-07-27 834 +1999-07-27 840 +2000-03-27 490 +2000-03-28 753 +select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t1.TransactionID,t3.DateOfAction; +DateOfAction TransactionID +1999-07-19 87 +1999-07-19 89 +1999-07-19 92 +1999-07-19 94 +1999-07-18 486 +2000-03-27 490 +2000-03-28 753 +1999-07-27 828 +1999-07-27 832 +1999-07-27 834 +1999-07-27 840 +drop table t1,t2,t3; +CREATE TABLE t1 ( +member_id int(11) NOT NULL auto_increment, +inschrijf_datum varchar(20) NOT NULL default '', +lastchange_datum varchar(20) NOT NULL default '', +nickname varchar(20) NOT NULL default '', +password varchar(8) NOT NULL default '', +voornaam varchar(30) NOT NULL default '', +tussenvoegsels varchar(10) NOT NULL default '', +achternaam varchar(50) NOT NULL default '', +straat varchar(100) NOT NULL default '', +postcode varchar(10) NOT NULL default '', +wijk varchar(40) NOT NULL default '', +plaats varchar(50) NOT NULL default '', +telefoon varchar(10) NOT NULL default '', +geboortedatum date NOT NULL default '0000-00-00', +geslacht varchar(5) NOT NULL default '', +email varchar(80) NOT NULL default '', +uin varchar(15) NOT NULL default '', +homepage varchar(100) NOT NULL default '', +internet varchar(15) NOT NULL default '', +scherk varchar(30) NOT NULL default '', +favo_boek varchar(50) NOT NULL default '', +favo_tijdschrift varchar(50) NOT NULL default '', +favo_tv varchar(50) NOT NULL default '', +favo_eten varchar(50) NOT NULL default '', +favo_muziek varchar(30) NOT NULL default '', +info text NOT NULL default '', +ipnr varchar(30) NOT NULL default '', +PRIMARY KEY (member_id) +) charset utf8mb4 ENGINE=MyISAM PACK_KEYS=1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'info' can't have a default value +insert into t1 (member_id) values (1),(2),(3); +select member_id, nickname, voornaam FROM t1 +ORDER by lastchange_datum DESC LIMIT 2; +member_id nickname voornaam +1 +2 +drop table t1; +create table t1 (a int not null, b int, c varchar(10), key (a, b, c)) charset utf8mb4; +insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 52 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` is null)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc +select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc; +a b c +1 NULL b +explain select * from t1 where a >= 1 and a < 3 order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 52 NULL 11 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3)) order by `test`.`t1`.`a` desc +explain format=json select * from t1 where a >= 1 and a < 3 order by a desc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.35" + }, + "ordering_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "backward_index_scan": true, + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.10", + "prefix_cost": "1.35", + "data_read_per_join": "616" + }, + "used_columns": [ + "a", + "b", + "c" + ], + "ordering_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a", + "b", + "c" + ], + "key_length": "52", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "backward_index_scan": true, + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.10", + "prefix_cost": "1.35", + "data_read_per_join": "616" + }, + "used_columns": [ + "a", + "b", + "c" + ], + "attached_condition": "((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3))" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3)) order by `test`.`t1`.`a` desc +select * from t1 where a >= 1 and a < 3 order by a desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +explain select * from t1 where a = 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 4 const 6 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` = 1) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a = 1 order by a desc, b desc; +a b c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +explain select * from t1 where a = 1 and b is null order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 9 const,const 2 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a = 1 and b is null order by a desc, b desc; +a b c +1 NULL NULL +1 NULL b +explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 9 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` < 3) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b >0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 5 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b is null order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 9 const,const 1 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and (b is null or b > 0) order by a +desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 9 NULL 6 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`b` is null) or (`test`.`t1`.`b` > 0))) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b > 0 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 5 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` > 0)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 2 and b < 2 order by a desc,b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 9 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and (`test`.`t1`.`b` < 2)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +explain select * from t1 where a = 1 order by b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 4 const 6 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` = 1) order by `test`.`t1`.`b` desc +select * from t1 where a = 1 order by b desc; +a b c +1 1 NULL +1 1 b +1 1 b +1 3 b +1 NULL NULL +1 NULL b +alter table t1 modify b int not null, modify c varchar(10) not null; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'c' at row 3 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 order by a, b, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` +select * from t1 order by a, b, c; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +1 3 b +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +explain select * from t1 order by a desc, b desc, c desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 50 NULL 11 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc,`test`.`t1`.`c` desc +select * from t1 order by a desc, b desc, c desc; +a b c +2 3 c +2 2 b +2 2 a +2 1 b +2 1 a +1 3 b +1 1 b +1 1 b +1 1 +1 0 b +1 0 +explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 50 NULL 3 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (((`test`.`t1`.`c` = 'b') and (`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or (`test`.`t1`.`a` > 2)) order by `test`.`t1`.`a` desc +select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc; +a b c +1 1 b +1 1 b +explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 4 NULL 6 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` < 2) and (`test`.`t1`.`b` <= 1)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a < 2 and b <= 1 order by a desc, b desc; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +select count(*) from t1 where a < 5 and b > 0; +count(*) +9 +select * from t1 where a < 5 and b > 0 order by a desc,b desc; +a b c +2 1 a +2 1 b +2 2 a +2 2 b +2 3 c +1 1 +1 1 b +1 1 b +1 3 b +explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 33.33 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 50 NULL 11 33.33 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` between 1 and 3) and (`test`.`t1`.`b` <= 1)) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc; +a b c +2 1 a +2 1 b +1 0 +1 0 b +1 1 +1 1 b +1 1 b +explain select * from t1 where a between 0 and 1 order by a desc, b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 4 NULL 6 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a` between 0 and 1) order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc +select * from t1 where a between 0 and 1 order by a desc, b desc; +a b c +1 0 +1 0 b +1 1 +1 1 b +1 1 b +1 3 b +drop table t1; +CREATE TABLE t1 ( +gid int(10) unsigned NOT NULL auto_increment, +cid smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (gid), +KEY component_id (cid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (103853,108),(103867,108),(103962,108),(104505,108),(104619,108),(104620,108); +ALTER TABLE t1 add skr int(10) not null; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +gid int(10) unsigned NOT NULL default '0', +uid smallint(5) unsigned NOT NULL default '1', +sid tinyint(3) unsigned NOT NULL default '1', +PRIMARY KEY (gid), +KEY uid (uid), +KEY status_id (sid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (103853,250,5),(103867,27,5),(103962,27,5),(104505,117,5),(104619,75,5),(104620,15,5); +CREATE TABLE t3 ( +uid smallint(6) NOT NULL auto_increment, +PRIMARY KEY (uid) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1),(15),(27),(75),(117),(250); +ALTER TABLE t3 add skr int(10) not null; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +select t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +gid sid uid +104620 5 15 +103867 5 27 +103962 5 27 +104619 5 75 +104505 5 117 +103853 5 250 +select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +gid sid uid +104620 5 15 +103867 5 27 +103962 5 27 +104619 5 75 +104505 5 117 +103853 5 250 +EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 2 NULL 6 100.00 Using index; Using temporary; Using filesort +1 SIMPLE t2 NULL ref PRIMARY,uid uid 2 test.t3.uid 1 100.00 Using where +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.gid 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t2`.`sid` AS `sid`,`test`.`t3`.`uid` AS `uid` from `test`.`t3` join `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`gid` = `test`.`t2`.`gid`) and (`test`.`t2`.`uid` = `test`.`t3`.`uid`)) order by `test`.`t1`.`gid`,`test`.`t3`.`uid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`gid` = `test`.`t3`.`uid`) order by `test`.`t1`.`gid`,`test`.`t3`.`skr` +EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,uid NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.gid 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t2`.`sid` AS `sid`,`test`.`t3`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` join `test`.`t3` where ((`test`.`t1`.`gid` = `test`.`t2`.`gid`) and (`test`.`t2`.`uid` = `test`.`t3`.`uid`)) order by `test`.`t3`.`uid`,`test`.`t1`.`gid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`gid` = `test`.`t3`.`uid`) order by `test`.`t3`.`skr`,`test`.`t1`.`gid` +EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 2 test.t1.skr 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`gid` AS `gid`,`test`.`t3`.`uid` AS `uid` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`skr` = `test`.`t3`.`uid`) order by `test`.`t1`.`gid`,`test`.`t3`.`skr` +drop table t1,t2,t3; +CREATE TABLE t1 ( +`titre` char(80) NOT NULL default '', +`numeropost` mediumint(8) unsigned NOT NULL auto_increment, +`date` datetime NOT NULL default '0000-00-00 00:00:00', +`auteur` char(35) NOT NULL default '', +`icone` tinyint(2) unsigned NOT NULL default '0', +`lastauteur` char(35) NOT NULL default '', +`nbrep` smallint(6) unsigned NOT NULL default '0', +`dest` char(35) NOT NULL default '', +`lu` tinyint(1) unsigned NOT NULL default '0', +`vue` mediumint(8) unsigned NOT NULL default '0', +`ludest` tinyint(1) unsigned NOT NULL default '0', +`ouvert` tinyint(1) unsigned NOT NULL default '1', +PRIMARY KEY (`numeropost`), +KEY `date` (`date`), +KEY `dest` (`dest`,`ludest`), +KEY `auteur` (`auteur`,`lu`), +KEY `auteur_2` (`auteur`,`date`), +KEY `dest_2` (`dest`,`date`) +) CHECKSUM=1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +`numeropost` mediumint(8) unsigned NOT NULL default '0', +`pseudo` char(35) NOT NULL default '', +PRIMARY KEY (`numeropost`,`pseudo`), +KEY `pseudo` (`pseudo`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (titre,auteur,dest) VALUES ('test','joce','bug'); +INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug'); +SELECT titre,t1.numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +SELECT titre,numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest +test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug +drop table t1,t2; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (3, 4); +INSERT INTO t1 VALUES (5, NULL); +SELECT * FROM t1 ORDER BY b; +a b +5 NULL +1 2 +3 4 +SELECT * FROM t1 ORDER BY b DESC; +a b +3 4 +1 2 +5 NULL +SELECT * FROM t1 ORDER BY (a + b); +a b +5 NULL +1 2 +3 4 +SELECT * FROM t1 ORDER BY (a + b) DESC; +a b +3 4 +1 2 +5 NULL +DROP TABLE t1; +create table t1(id int not null auto_increment primary key, t char(12)); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select id,t from t1 order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`t` AS `t` from `test`.`t1` order by `test`.`t1`.`id` +explain select id,t from t1 force index (primary) order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`t` AS `t` from `test`.`t1` FORCE INDEX (PRIMARY) order by `test`.`t1`.`id` +drop table t1; +CREATE TABLE t1 ( +FieldKey varchar(36) NOT NULL default '', +LongVal bigint(20) default NULL, +StringVal mediumtext, +KEY FieldKey (FieldKey), +KEY LongField (FieldKey,LongVal), +KEY StringField (FieldKey,StringVal(32)) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3'); +EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref FieldKey,LongField,StringField LongField 146 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` = '1') order by `test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; +FieldKey LongVal StringVal +1 0 2 +1 1 3 +1 2 1 +EXPLAIN SELECT * FROM t1 ignore index (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range StringField StringField 146 NULL 3 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` IGNORE INDEX (`LongField`) IGNORE INDEX (`FieldKey`) where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range FieldKey,LongField,StringField LongField 146 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`FieldKey` AS `FieldKey`,`test`.`t1`.`LongVal` AS `LongVal`,`test`.`t1`.`StringVal` AS `StringVal` from `test`.`t1` where (`test`.`t1`.`FieldKey` > '2') order by `test`.`t1`.`FieldKey`,`test`.`t1`.`LongVal` +SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; +FieldKey LongVal StringVal +3 1 2 +3 2 1 +3 3 3 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; +CREATE TABLE t1 ( id smallint(6) unsigned NOT NULL default '0', menu tinyint(4) NOT NULL default '0', KEY id (id), KEY menu (menu)) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (11384, 2),(11392, 2); +SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ; +id +11392 +drop table t1; +create table t1(a int, b int, index(b)); +insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where b=1 or b is null order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null b b 5 const 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) or (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` +explain format=tree select * from t1 where b=1 or b is null order by a; +EXPLAIN +-> Sort: t1.a (cost=0.90 rows=4) + -> Filter: ((t1.b = 1) or (t1.b is null)) + -> Index lookup on t1 using b (b=1 or NULL) + +select * from t1 where b=1 or b is null order by a; +a b +1 1 +2 1 +3 NULL +4 NULL +explain select * from t1 where b=2 or b is null order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref_or_null b b 5 const 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 2) or (`test`.`t1`.`b` is null)) order by `test`.`t1`.`a` +select * from t1 where b=2 or b is null order by a; +a b +3 NULL +4 NULL +5 2 +6 2 +drop table t1; +create table t1 (a int not null auto_increment, b int not null, c int not null, d int not null, +key(a,b,d), key(c,b,a)); +create table t2 like t1; +insert into t1 values (NULL, 1, 2, 0), (NULL, 2, 1, 1), (NULL, 3, 4, 2), (NULL, 4, 3, 3); +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +set @row=10; +insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select * from t1 where a=1 and b in (1) order by c, b, a; +a b c d +1 1 2 0 +1 1 12 -1 +1 1 52 -5 +1 1 92 -9 +select * from t1 where a=1 and b in (1); +a b c d +1 1 12 -1 +1 1 2 0 +1 1 52 -5 +1 1 92 -9 +drop table t1, t2; +create table t1 (col1 int, col int); +create table t2 (col2 int, col int); +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1,3),(2,2),(3,1); +select t1.* , t2.col as t2_col from t1 left join t2 on (t1.col1=t2.col2) +order by col; +col1 col t2_col +1 1 3 +2 2 2 +3 3 1 +select col1 as col, col from t1 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select col1 from t1, t2 where t1.col1=t2.col2 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as t1_col, t2.col from t1, t2 where t1.col1=t2.col2 +order by col; +t1_col col +3 1 +2 2 +1 3 +select col2 as c, col as c from t2 order by col; +c c +3 1 +2 2 +1 3 +select col2 as col, col as col2 from t2 order by col; +col col2 +1 3 +2 2 +3 1 +select t2.col2, t2.col, t2.col from t2 order by col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +select t2.col2 as col from t2 order by t2.col; +col +3 +2 +1 +select t2.col2 as col, t2.col from t2 order by t2.col; +col col +3 1 +2 2 +1 3 +select t2.col2, t2.col, t2.col from t2 order by t2.col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +drop table t1, t2; +create table t1 (a char(25)) charset latin1; +insert into t1 set a = repeat('x', 20); +insert into t1 set a = concat(repeat('x', 19), 'z'); +insert into t1 set a = concat(repeat('x', 19), 'ab'); +insert into t1 set a = concat(repeat('x', 19), 'aa'); +set max_sort_length=20; +select a from t1 order by a; +a +xxxxxxxxxxxxxxxxxxxaa +xxxxxxxxxxxxxxxxxxxab +xxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxz +drop table t1; +create table t1 ( +`sid` decimal(8,0) default null, +`wnid` varchar(11) not null default '', +key `wnid14` (`wnid`(4)), +key `wnid` (`wnid`) +) engine=myisam default charset=latin1; +insert into t1 (`sid`, `wnid`) values +('10100','01019000000'),('37986','01019000000'),('37987','01019010000'), +('39560','01019090000'),('37989','01019000000'),('37990','01019011000'), +('37991','01019011000'),('37992','01019019000'),('37993','01019030000'), +('37994','01019090000'),('475','02070000000'),('25253','02071100000'), +('25255','02071100000'),('25256','02071110000'),('25258','02071130000'), +('25259','02071190000'),('25260','02071200000'),('25261','02071210000'), +('25262','02071290000'),('25263','02071300000'),('25264','02071310000'), +('25265','02071310000'),('25266','02071320000'),('25267','02071320000'), +('25269','02071330000'),('25270','02071340000'),('25271','02071350000'), +('25272','02071360000'),('25273','02071370000'),('25281','02071391000'), +('25282','02071391000'),('25283','02071399000'),('25284','02071400000'), +('25285','02071410000'),('25286','02071410000'),('25287','02071420000'), +('25288','02071420000'),('25291','02071430000'),('25290','02071440000'), +('25292','02071450000'),('25293','02071460000'),('25294','02071470000'), +('25295','02071491000'),('25296','02071491000'),('25297','02071499000'); +explain select * from t1 where wnid like '0101%' order by wnid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range wnid14,wnid wnid 13 NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sid` AS `sid`,`test`.`t1`.`wnid` AS `wnid` from `test`.`t1` where (`test`.`t1`.`wnid` like '0101%') order by `test`.`t1`.`wnid` +select * from t1 where wnid like '0101%' order by wnid; +sid wnid +10100 01019000000 +37986 01019000000 +37989 01019000000 +37987 01019010000 +37990 01019011000 +37991 01019011000 +37992 01019019000 +37993 01019030000 +39560 01019090000 +37994 01019090000 +drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +a +1 +1 +1 +2 +2 +(SELECT a FROM t1) ORDER BY a; +a +1 +1 +1 +2 +2 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10); +(SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a; +b a +10 1 +10 2 +20 1 +20 2 +30 1 +30 2 +(SELECT b FROM t1 ORDER BY b DESC) ORDER BY b ASC; +b +10 +10 +20 +20 +30 +30 +(SELECT b,a FROM t1 ORDER BY b,a) ORDER BY a,b; +b a +10 1 +20 1 +30 1 +10 2 +20 2 +30 2 +(SELECT b,a FROM t1 ORDER by b,a LIMIT 3) ORDER by a,b; +b a +10 1 +20 1 +10 2 +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT a + 1 AS num FROM t1 ORDER BY 30 - num; +num +3 +2 +SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str); +str +test1 +test2 +SELECT a + 1 AS num FROM t1 GROUP BY 30 - num; +num +2 +3 +SELECT a + 1 AS num FROM t1 HAVING 30 - num; +num +2 +3 +SELECT a + 1 AS num, num + 1 FROM t1; +ERROR 42S22: Unknown column 'num' in 'field list' +SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1; +num (select num + 2 FROM t1 LIMIT 1) +2 4 +3 5 +SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; +ERROR 42S22: Unknown column 'num' in 'on clause' +DROP TABLE t1; +CREATE TABLE bug25126 ( +val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +); +UPDATE bug25126 SET MissingCol = MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET val = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = val ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +DROP TABLE bug25126; +CREATE TABLE t1 (a int); +SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1; +val val1 +SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val; +ERROR 23000: Column 'val' in order clause is ambiguous +SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1; +ERROR 23000: Column 'val' in order clause is ambiguous +DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (3), (2), (4), (1); +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a NOT IN (2,3), a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a IN (2,3), a, a+10) FROM t1 +ORDER BY IF(a NOT IN (2,3), a, a+10); +a IF(a IN (2,3), a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +2 2 +3 3 +1 11 +4 14 +SELECT a, IF(a NOT BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a NOT BETWEEN 2 AND 3, a, a+10) +1 1 +4 4 +2 12 +3 13 +SELECT a, IF(a BETWEEN 2 AND 3, a, a+10) FROM t1 +ORDER BY IF(a NOT BETWEEN 2 AND 3, a, a+10); +a IF(a BETWEEN 2 AND 3, a, a+10) +1 11 +4 14 +2 2 +3 3 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, x2; +x1 x2 + 3 + 4 +1 +2 +SELECT IF(a IN (1,2), a, '') as x1, IF(a NOT IN (1,2), a, '') as x2 +FROM t1 GROUP BY x1, IF(a NOT IN (1,2), a, ''); +x1 x2 + 3 + 4 +1 +2 +SELECT a, a IN (1,2) FROM t1 ORDER BY a IN (1,2); +a a IN (1,2) +3 0 +4 0 +2 1 +1 1 +SELECT a FROM t1 ORDER BY a IN (1,2); +a +3 +4 +2 +1 +SELECT a+10 FROM t1 ORDER BY a IN (1,2); +a+10 +13 +14 +12 +11 +SELECT a, IF(a IN (1,2), a, a+10) FROM t1 +ORDER BY IF(a IN (3,4), a, a+10); +a IF(a IN (1,2), a, a+10) +3 13 +4 14 +1 1 +2 2 +DROP TABLE t1; +create table t1 (a int not null, b int not null, c int not null); +insert t1 values (1,1,1),(1,1,2),(1,2,1); +select a, b from t1 group by a, b order by sum(c); +a b +1 2 +1 1 +drop table t1; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze Error Table 'test.t2' doesn't exist +test.t2 analyze status Operation failed +explain SELECT t1.b as a, t2.b as c FROM +t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `a`,`test`.`t2`.`b` AS `c` from `test`.`t1` left join `test`.`t1` `t2` on(((`test`.`t1`.`a` = 2) and (`test`.`t2`.`a` = 2))) where true order by `c` +SELECT t2.b as c FROM +t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +c +NULL +NULL +2 +explain SELECT t1.b as a, t2.b as c FROM +t1 JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2) +ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `a`,'2' AS `c` from `test`.`t1` join `test`.`t1` `t2` where true order by `c` +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * from t1; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 SELECT * from t1; +CREATE TABLE t4 LIKE t1; +INSERT INTO t4 SELECT * from t1; +INSERT INTO t1 values (0,0),(4,4); +SELECT t2.b FROM t1 LEFT JOIN (t2, t3 LEFT JOIN t4 ON t3.a=t4.a) +ON (t1.a=t2.a AND t1.b=t3.b) order by t2.b; +b +NULL +NULL +1 +2 +3 +DROP TABLE t1,t2,t3,t4; +create table t1 (a int, b int, c int); +insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9); +select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc; +a ratio +1 0.5000 +19 1.3333 +9 2.6667 +drop table t1; +CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME); +INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10); +UPDATE t1 SET b = SEC_TO_TIME(a); +SELECT a, b FROM t1 ORDER BY b DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC; +a b +1000000 277:46:40 +100000 27:46:40 +10000 02:46:40 +1000 00:16:40 +100 00:01:40 +10 00:00:10 +0 00:00:00 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b)); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (a INT, b INT, KEY a (a,b)); +INSERT INTO t2 VALUES (1,1),(1,2),(2,1),(2,2); +EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY,b b 5 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY,b b 5 const 1 100.00 Using index +2 SIMPLE t2 NULL ref a a 5 const 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = '2')) order by `test`.`t2`.`b` +DROP TABLE t1,t2; +CREATE TABLE t1( +id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3)); +INSERT INTO t1 (c2,c3) VALUES +(31,34),(35,38),(34,31),(32,35),(31,39), +(11,14),(15,18),(14,11),(12,15),(11,19); +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +UPDATE t1 SET c2=20 WHERE id%100 = 0; +SELECT COUNT(*) FROM t1; +COUNT(*) +40960 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * FROM t1 ORDER BY id; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL index k2 k3 5 NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` = 11) order by `test`.`t2`.`c3` limit 20 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8192 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ref k2 k2 5 const 8192 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` = 11) order by `test`.`t2`.`c3` limit 4000 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 40 50.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL index k2 k3 5 NULL 40 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` between 10 and 12) order by `test`.`t2`.`c3` limit 20 +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 409 100.00 Parallel execute (3 workers) +2 SIMPLE t2 NULL range k2 k2 5 NULL 409 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where (`test`.`t2`.`c2` between 20 and 30) order by `test`.`t2`.`c3` limit 4000 +SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +id c3 +6 14 +16 14 +31 14 +41 14 +62 14 +72 14 +82 14 +92 14 +125 14 +135 14 +145 14 +155 14 +165 14 +175 14 +185 14 +195 14 +252 14 +262 14 +272 14 +282 14 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a INT, +b INT, +PRIMARY KEY (a), +KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY, ab) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY,ab PRIMARY 4 NULL 128 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR GROUP BY (`ab`) IGNORE INDEX FOR GROUP BY (PRIMARY) group by `test`.`t1`.`a` +flush status; +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY, ab) GROUP BY a; +a +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +13 +14 +15 +16 +17 +18 +19 +2 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY, ab) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 128 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX FOR ORDER BY (`ab`) IGNORE INDEX FOR ORDER BY (PRIMARY) order by `test`.`t1`.`a` +flush status; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +flush status; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`ab`) IGNORE INDEX (PRIMARY) group by `test`.`t1`.`a` +SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) GROUP BY a; +a +1 +10 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +11 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +12 +120 +121 +122 +123 +124 +125 +126 +127 +128 +13 +14 +15 +16 +17 +18 +19 +2 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +3 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +4 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +5 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +6 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +7 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +8 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +9 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 128 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`ab`) IGNORE INDEX (PRIMARY) order by `test`.`t1`.`a` +SELECT a FROM t1 IGNORE INDEX (PRIMARY, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +show status like 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +DROP TABLE t1; +# +# Bug#31590: Wrong error message on sort buffer being too small. +# +create table t1(a int, b text); +insert into t1 values (1,REPEAT('x', 60000)),(3,REPEAT('y', 60000)); +set session sort_buffer_size= 32768; +CALL mtr.add_suppression("Out of sort memory"); +select * from t1 order by b; +ERROR HY001: Out of sort memory, consider increasing server sort buffer size +drop table t1; +call mtr.add_suppression("Out of sort memory; increase server sort buffer size"); +# +# Bug #39844: Query Crash Mysql Server 5.0.67 +# +CREATE TABLE t1 (a INT PRIMARY KEY); +CREATE TABLE t2 (a INT PRIMARY KEY, b INT); +CREATE TABLE t3 (c INT); +INSERT INTO t1 (a) VALUES (1), (2); +INSERT INTO t2 (a,b) VALUES (1,2), (2,3); +INSERT INTO t3 (c) VALUES (1), (2); +SELECT +(SELECT t1.a FROM t1, t2 WHERE t1.a = t2.b AND t2.a = t3.c ORDER BY t1.a) +FROM t3; +(SELECT t1.a FROM t1, t2 WHERE t1.a = t2.b AND t2.a = t3.c ORDER BY t1.a) +2 +NULL +DROP TABLE t1, t2, t3; +# +# Bug #42760: Select doesn't return desired results when we have null +# values +# +CREATE TABLE t1 ( +a INT, +c INT, +UNIQUE KEY a_c (a,c), +KEY (a)); +INSERT INTO t1 VALUES (1, 10), (2, NULL); +# Must use ref-or-null on the a_c index +EXPLAIN +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 75.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a_c,a a 5 const 1 75.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `col` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` +# Must return 1 row +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +col +1 +# Must use ref-or-null on the a_c index +EXPLAIN +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +x x x NULL ALL NULL x x x x 75.00 x +x x x NULL ref a_c,a x x x x 75.00 x +Warnings: +x x x +# Must return 1 row +SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +col +1 +DROP TABLE t1; +End of 5.0 tests +CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, +UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b)) +charset utf8mb4; +CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b)) +charset utf8mb4; +INSERT INTO t3 SELECT * FROM t1; +EXPLAIN +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1 NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a,b b 13 const 4 100.00 Using where; Using temporary; Using filesort +2 SIMPLE t2 NULL ref a,b,c a 136 test.t1.a,const 1 78.90 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1 +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1 NULL ALL NULL NULL NULL NULL 415 27.57 Parallel execute (1 workers) +2 SIMPLE t2 NULL range a,b,c c 5 NULL 415 27.57 Using where +2 SIMPLE t1 NULL eq_ref a a 144 test.t2.a,const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`d` AS `d` from `test`.`t3` `t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'DE') and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 14) and (5.1 < `test`.`t2`.`c`)) order by `test`.`t2`.`c` limit 1 +SELECT d FROM t3 AS t1, t2 AS t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.110 ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +13 12 12 +14 13 13 +15 14 14 +16 15 15 +17 16 16 +18 17 17 +19 18 18 +20 19 19 +21 20 20 +22 21 21 +23 22 22 +24 23 23 +25 24 24 +26 25 25 +27 26 26 +28 27 27 +29 28 28 +30 29 29 +31 30 30 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +22 21 21 +23 22 22 +24 23 23 +25 24 24 +26 25 25 +27 26 26 +28 27 27 +29 28 28 +30 29 29 +31 30 30 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +set sort_buffer_size= 32768; +CREATE TEMPORARY TABLE tmp (f1 int, f2 varchar(20)); +INSERT INTO tmp SELECT f1, f2 FROM t1; +INSERT INTO t1(f1, f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1, f2 FROM t1; +INSERT INTO t1(f1, f2) SELECT * FROM tmp; +SELECT * FROM t1 ORDER BY f1 ASC, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +SELECT * FROM t1 ORDER BY f1 ASC, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 ORDER BY f2 DESC, f0 LIMIT 30; +f0 f1 f2 +100 99 99 +200 99 99 +327 99 99 +427 99 99 +527 99 99 +99 98 98 +199 98 98 +326 98 98 +426 98 98 +526 98 98 +98 97 97 +198 97 97 +325 97 97 +425 97 97 +525 97 97 +97 96 96 +197 96 96 +324 96 96 +424 96 96 +524 96 96 +96 95 95 +196 95 95 +323 95 95 +423 95 95 +523 95 95 +95 94 94 +195 94 94 +322 94 94 +422 94 94 +522 94 94 +SELECT * FROM t1 ORDER BY f2 DESC, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +set sort_buffer_size= 32768; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 +ORDER BY f1, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 +ORDER BY f1, f0 LIMIT 0; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 20; +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 0; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 10 OFFSET 10; +f0 f1 f2 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 0 OFFSET 10; +f0 f1 f2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +445 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +set sort_buffer_size= 327680; +SELECT * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30; +f0 f1 f2 f1 f2 +1 0 0 0 0 +1 0 0 0 0 +1 0 0 0 0 +101 0 0 0 0 +101 0 0 0 0 +101 0 0 0 0 +228 0 0 0 0 +228 0 0 0 0 +228 0 0 0 0 +328 0 0 0 0 +328 0 0 0 0 +328 0 0 0 0 +428 0 0 0 0 +428 0 0 0 0 +428 0 0 0 0 +2 1 1 1 1 +2 1 1 1 1 +2 1 1 1 1 +102 1 1 1 1 +102 1 1 1 1 +102 1 1 1 1 +229 1 1 1 1 +229 1 1 1 1 +229 1 1 1 1 +329 1 1 1 1 +329 1 1 1 1 +329 1 1 1 1 +429 1 1 1 1 +429 1 1 1 1 +429 1 1 1 1 +SELECT * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +3 2 2 2 2 +3 2 2 2 2 +3 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +4 3 3 3 3 +4 3 3 3 3 +4 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 JOIN tmp on t1.f2=tmp.f2 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +3 2 2 2 2 +3 2 2 2 2 +3 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +103 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +230 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +330 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +430 2 2 2 2 +4 3 3 3 3 +4 3 3 3 3 +4 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +104 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +231 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +331 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +431 3 3 3 3 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +1500 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT SQL_CALC_FOUND_ROWS * FROM t1 JOIN tmp on t1.f2=tmp.f2 +WHERE t1.f2>20 +ORDER BY tmp.f1, f0 LIMIT 30 OFFSET 30; +f0 f1 f2 f1 f2 +24 23 23 23 23 +24 23 23 23 23 +24 23 23 23 23 +124 23 23 23 23 +124 23 23 23 23 +124 23 23 23 23 +251 23 23 23 23 +251 23 23 23 23 +251 23 23 23 23 +351 23 23 23 23 +351 23 23 23 23 +351 23 23 23 23 +451 23 23 23 23 +451 23 23 23 23 +451 23 23 23 23 +25 24 24 24 24 +25 24 24 24 24 +25 24 24 24 24 +125 24 24 24 24 +125 24 24 24 24 +125 24 24 24 24 +252 24 24 24 24 +252 24 24 24 24 +252 24 24 24 24 +352 24 24 24 24 +352 24 24 24 24 +352 24 24 24 24 +452 24 24 24 24 +452 24 24 24 24 +452 24 24 24 24 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +SELECT FOUND_ROWS(); +FOUND_ROWS() +1185 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +CREATE VIEW v1 as SELECT * FROM t1 ORDER BY f1, f0 LIMIT 30; +SELECT * FROM v1; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +3 2 2 +103 2 2 +230 2 2 +330 2 2 +430 2 2 +4 3 3 +104 3 3 +231 3 3 +331 3 3 +431 3 3 +5 4 4 +105 4 4 +232 4 4 +332 4 4 +432 4 4 +6 5 5 +106 5 5 +233 5 5 +333 5 5 +433 5 5 +drop view v1; +CREATE VIEW v1 as SELECT * FROM t1 ORDER BY f1, f0 LIMIT 100; +SELECT * FROM v1 ORDER BY f2, f0 LIMIT 30; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +11 10 10 +111 10 10 +238 10 10 +338 10 10 +438 10 10 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +CREATE VIEW v2 as SELECT * FROM t1 ORDER BY f2, f0 LIMIT 100; +SELECT * FROM v1 JOIN v2 on v1.f1=v2.f1 ORDER BY v1.f2,v1.f0,v2.f0 +LIMIT 30; +f0 f1 f2 f0 f1 f2 +1 0 0 1 0 0 +1 0 0 101 0 0 +1 0 0 228 0 0 +1 0 0 328 0 0 +1 0 0 428 0 0 +101 0 0 1 0 0 +101 0 0 101 0 0 +101 0 0 228 0 0 +101 0 0 328 0 0 +101 0 0 428 0 0 +228 0 0 1 0 0 +228 0 0 101 0 0 +228 0 0 228 0 0 +228 0 0 328 0 0 +228 0 0 428 0 0 +328 0 0 1 0 0 +328 0 0 101 0 0 +328 0 0 228 0 0 +328 0 0 328 0 0 +328 0 0 428 0 0 +428 0 0 1 0 0 +428 0 0 101 0 0 +428 0 0 228 0 0 +428 0 0 328 0 0 +428 0 0 428 0 0 +2 1 1 2 1 1 +2 1 1 102 1 1 +2 1 1 229 1 1 +2 1 1 329 1 1 +2 1 1 429 1 1 +SELECT floor(f1/10) f3, count(f2) FROM t1 +GROUP BY 1 ORDER BY 2,1 LIMIT 5; +f3 count(f2) +0 50 +1 50 +2 50 +3 50 +4 50 +SELECT floor(f1/10) f3, count(f2) FROM t1 +GROUP BY 1 ORDER BY 2,1 LIMIT 0; +f3 count(f2) +CREATE PROCEDURE wl1393_sp_test() +BEGIN +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 30; +SELECT * FROM t1 WHERE f1>10 ORDER BY f2, f0 LIMIT 15 OFFSET 15; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE f1>10 +ORDER BY f2, f0 LIMIT 15 OFFSET 15; +SELECT FOUND_ROWS(); +SELECT * FROM v1 ORDER BY f2, f0 LIMIT 30; +END| +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +CALL wl1393_sp_test()| +f0 f1 f2 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +f0 f1 f2 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +f0 f1 f2 +15 14 14 +115 14 14 +242 14 14 +342 14 14 +442 14 14 +16 15 15 +116 15 15 +243 15 15 +343 15 15 +443 15 15 +17 16 16 +117 16 16 +244 16 16 +344 16 16 +444 16 16 +FOUND_ROWS() +445 +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +2 1 1 +102 1 1 +229 1 1 +329 1 1 +429 1 1 +11 10 10 +111 10 10 +238 10 10 +338 10 10 +438 10 10 +12 11 11 +112 11 11 +239 11 11 +339 11 11 +439 11 11 +13 12 12 +113 12 12 +240 12 12 +340 12 12 +440 12 12 +14 13 13 +114 13 13 +241 13 13 +341 13 13 +441 13 13 +DROP PROCEDURE wl1393_sp_test| +SELECT d1.f1, d1.f2 FROM t1 +LEFT JOIN (SELECT * FROM t1 ORDER BY f1 LIMIT 30) d1 on t1.f1=d1.f1 +ORDER BY d1.f2 DESC LIMIT 30; +f1 f2 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +5 5 +4 4 +4 4 +4 4 +4 4 +4 4 +SELECT * FROM t1 WHERE f1 = (SELECT f1 FROM t1 ORDER BY 1 LIMIT 1); +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +SELECT * FROM t1 WHERE f1 = (SELECT f1 FROM t1 ORDER BY 1 LIMIT 2); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1, tmp; +DROP VIEW v1, v2; +# end of WL#1393 - Optimizing filesort with small limit +# +# Bug #58761 +# Crash in Field::is_null in field.h on subquery in WHERE clause +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +INSERT INTO t1 VALUES (27,7,'x'); +INSERT INTO t1 VALUES (28,6,'m'); +INSERT INTO t1 VALUES (29,4,'c'); +CREATE TABLE where_subselect +SELECT DISTINCT `pk` AS field1 , `pk` AS field2 +FROM t1 AS alias1 +WHERE alias1 . `col_int_key` > 229 +OR alias1 . `col_varchar_key` IS NOT NULL +GROUP BY field1, field2 +; +SELECT * +FROM where_subselect +WHERE (field1, field2) IN ( +SELECT DISTINCT `pk` AS field1 , `pk` AS field2 +FROM t1 AS alias1 +WHERE alias1 . `col_int_key` > 229 +OR alias1 . `col_varchar_key` IS NOT NULL +GROUP BY field1, field2 +); +field1 field2 +27 27 +28 28 +29 29 +DROP TABLE t1; +DROP TABLE where_subselect; +# End of Bug #58761 +CREATE TABLE t1 ( +id1 INT NOT NULL, +id2 INT NOT NULL, +junk INT NOT NULL, +PRIMARY KEY (id1, id2, junk), +INDEX id2_j_id1 (id2, junk, id1) +); +INSERT INTO t1 VALUES (1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4); +INSERT INTO t1 VALUES (5, 2, 1), (6, 2, 2), (7, 2, 3), (8, 2, 4); +INSERT INTO t1 VALUES (9, 3, 1), (10, 3, 2), (11, 3, 3), (12, 3, 4); +INSERT INTO t1 VALUES (13, 4, 1), (14, 4, 2), (15, 4, 3), (16, 4, 4); +INSERT INTO t1 VALUES (17, 5, 1), (18, 5, 2), (19, 5, 3), (20, 5, 4); +INSERT INTO t1 VALUES (21, 6, 1), (22, 6, 2), (23, 6, 3), (24, 6, 4); +INSERT INTO t1 VALUES (25, 7, 1), (26, 7, 2), (27, 7, 3), (28, 7, 4); +INSERT INTO t1 VALUES (29, 8, 1), (30, 8, 2), (31, 8, 3), (32, 8, 4); +INSERT INTO t1 VALUES (33, 9, 1), (34, 9, 2), (35, 9, 3), (36, 9, 4); +EXPLAIN SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,id2_j_id1 id2_j_id1 4 const 4 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1` from `test`.`t1` where (`test`.`t1`.`id2` = 4) order by `test`.`t1`.`id1` +SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; +id1 +13 +14 +15 +16 +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, +b INT NOT NULL, +c char(100), +KEY (b, c), +KEY (b, a, c) +) +DEFAULT CHARSET = utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); +INSERT INTO t1 SELECT a + 10, b, c + 10 FROM t1; +INSERT INTO t1 SELECT a + 20, b, c + 20 FROM t1; +INSERT INTO t1 SELECT a + 40, b, c + 40 FROM t1; +INSERT INTO t1 SELECT a + 80, b, c + 80 FROM t1; +INSERT INTO t1 SELECT a + 160, b, c + 160 FROM t1; +INSERT INTO t1 SELECT a + 320, b, c + 320 FROM t1; +INSERT INTO t1 SELECT a + 640, b, c + 640 FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c + 1280 FROM t1 LIMIT 80; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 208 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ref b,b_2 b_2 4 const 208 100.00 Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`c` desc limit 9 +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +a +991 +981 +971 +961 +951 +941 +931 +921 +911 +EXPLAIN +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,b_2 b_2 4 const 208 100.00 Using index; Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`c` desc limit 0,9 +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; +a +991 +981 +971 +961 +951 +941 +931 +921 +911 +DROP TABLE t1; +# +# Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join buffering +# is used +# +CREATE TABLE t1 (a INT, b INT, KEY (a)); +INSERT INTO t1 VALUES (0, NULL), (1, NULL), (2, NULL), (3, NULL); +INSERT INTO t1 SELECT a+4, b FROM t1; +INSERT INTO t1 SELECT a+8, b FROM t1; +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL), (4,NULL); +INSERT INTO t2 SELECT a+4, b FROM t2; +# shouldn't have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` FORCE INDEX FOR ORDER BY (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +# should have "using filesort" +EXPLAIN +SELECT * FROM t1 USE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` USE INDEX FOR ORDER BY (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +# should have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR JOIN (a), t2 WHERE t1.a < 2 ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` FORCE INDEX FOR JOIN (`a`) join `test`.`t2` where (`test`.`t1`.`a` < 2) order by `test`.`t1`.`a` +DROP TABLE t1, t2; +# +# Bug #50394: Regression in EXPLAIN with index scan, LIMIT, GROUP BY and +# ORDER BY computed col +# +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, KEY( a, b ) ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t1 SELECT a + 5, b + 5 FROM t1; +CREATE TABLE t2( a INT PRIMARY KEY, b INT ); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t2 SELECT a + 5, b + 5 FROM t2; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT count(*) AS c, t1.a +FROM t1 JOIN t2 ON t1.b = t2.a +WHERE t2.b = 1 +GROUP BY t1.a +ORDER by c +LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 10 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t1 NULL index a a 8 NULL 10 10.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `c`,`test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 1)) group by `test`.`t1`.`a` order by `c` limit 2 +DROP TABLE t1, t2; +# +# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory +# and +# Bug #59308: Incorrect result for +SELECT DISTINCT ... ORDER BY DESC + +# Use Valgrind to detect #59110! +# +CREATE TABLE t1 (a INT,KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a`,1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` <> 1) order by `test`.`t1`.`a` desc +SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC; +a 1 +10 1 +9 1 +8 1 +7 1 +6 1 +5 1 +4 1 +3 1 +2 1 +DROP TABLE t1; +# +# Bug#11765255 58201: +# VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS +# +select count(*) order by max(1) + min(1); +count(*) +1 +End of 5.1 tests +# +# Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY +# when it should use index +# +CREATE TABLE t1 (i1 integer NOT NULL PRIMARY KEY); +CREATE TABLE t2 (i2 integer NOT NULL PRIMARY KEY); +CREATE TABLE t3 (i3 integer); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2 +LEFT JOIN t3 ON t2.i2 = t3.i3 +ORDER BY t1.i1 LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 12 100.00 Using index; Using temporary; Using filesort +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i1 1 100.00 Using index +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`i3` = `test`.`t1`.`i1`)) where (`test`.`t2`.`i2` = `test`.`t1`.`i1`) order by `test`.`t1`.`i1` limit 5 +SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2 +LEFT JOIN t3 ON t2.i2 = t3.i3 +ORDER BY t1.i1 LIMIT 5; +i1 i2 +1 1 +2 2 +3 3 +4 4 +5 5 +DROP TABLE t1, t2, t3; +# +# Bug #11885377 VOID JOIN_READ_KEY_UNLOCK_ROW(ST_JOIN_TABLE*): ASSERTION +# `TAB->REF.USE_COUNT' +# +CREATE TABLE t1(a INT PRIMARY KEY); +CREATE TABLE t2(b INT,c INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1,2), (2,3); +SELECT (SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) FROM t2; +(SELECT 1 FROM t1 WHERE a=b AND c=1 ORDER BY a DESC) +NULL +NULL +DROP TABLE t1, t2; +# +# Bug #13531865 +# TEST_IF_SKIP_SORT_ORDER() INCORRECTLY SKIP FILESORT IF +# 'TYPE' IS REF_OR_NULL +# +# +CREATE TABLE t1 ( +a INT, +c INT, +UNIQUE KEY a_c (a,c), +KEY (a)) engine=myisam; +INSERT INTO t1 VALUES (1,10), (2,NULL), (2,10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Using 'KEY a_c' for order-by opt, would have required +# REF_OR_NULL access which never can be order_by skipped. +# -> Keep initial REF on 'KEY a' selected by cond. optimizer +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; +c +NULL +10 +EXPLAIN +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_c,a a 5 const 1 55.56 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 2) and ((`test`.`t1`.`c` = 10) or (`test`.`t1`.`c` is null))) order by `test`.`t1`.`c` desc +SELECT c FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC; +c +10 +NULL +DROP TABLE t1; +# +# Bug #13528826 +# TEST_IF_CHEAPER_ORDERING(): CALCULATES INCORRECT 'SELECT_LIMIT' +# +# +CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam; +INSERT INTO t1 VALUES +(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60); +CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam; +INSERT INTO t2 VALUES +(103, 7), (109, 3), (102, 3), (108, 1), (106, 3), +(107, 7), (105, 1), (101, 3), (100, 7), (110, 1); +# number of rows in t1 was incorrectly used as an +# implicit limit-clause if not explicit specified +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` +# Query above used to be explained identical to this: +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` limit 8 +# A really high limit was required to give the correct explain +EXPLAIN +SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 1000; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 8 100.00 Using index +1 SIMPLE t2 NULL ref i_a i_a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true order by `test`.`t1`.`a` limit 1000 +DROP TABLE t1, t2; +# +# Bug #13949068 ASSERT TAB->REF.KEY == REF_KEY IN +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG +# +CREATE TABLE t1 (a INT, b INT, KEY(b), KEY(b,a)) ENGINE=INNODB; +INSERT INTO t1 VALUES (0,0); +EXPLAIN SELECT DISTINCT a FROM t1 WHERE b=1 ORDER BY 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,b_2 b_2 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`a` +SELECT DISTINCT a FROM t1 WHERE b=1 ORDER BY 1; +a +DROP TABLE t1; +# +# Bug#18636076 DEBUG CRASH ON +# PLAN_CHANGE_WATCHDOG::~PLAN_CHANGE_WATCHDOG +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1), (2), (3); +CREATE VIEW view_t1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +i1 INTEGER NOT NULL +) ENGINE=MyISAM; +EXPLAIN SELECT DISTINCT t2.i1, view_t1.pk +FROM view_t1 LEFT JOIN t2 +ON view_t1.pk = t2.i1 +WHERE (view_t1.pk <= 204 AND t2.i1 != 3) +OR view_t1.pk BETWEEN 1 AND 7 +ORDER BY t2.i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct NULL AS `i1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (((`test`.`t1`.`pk` <= 204) and (NULL <> 3)) or (`test`.`t1`.`pk` between 1 and 7)) order by NULL +SELECT DISTINCT t2.i1, view_t1.pk +FROM view_t1 LEFT JOIN t2 +ON view_t1.pk = t2.i1 +WHERE (view_t1.pk <= 204 AND t2.i1 != 3) +OR view_t1.pk BETWEEN 1 AND 7 +ORDER BY t2.i1; +i1 pk +NULL 1 +NULL 2 +NULL 3 +DROP VIEW view_t1; +DROP TABLE t1, t2; +SET sql_mode = default; +# +# Bug#20455386 INVALID WRITE IN COPY_FIELD::SET CAUSE CRASH WITH TMP TABLES +# +CREATE TABLE t1(a INT) ENGINE=INNODB; +CREATE TABLE t2(c INT) ENGINE=INNODB; +CREATE TABLE t3(b BLOB NOT NULL) ENGINE=INNODB; +SELECT +(SELECT 1 FROM t1 +WHERE (SELECT c FROM t2 ORDER BY COUNT(t3.b )) +) +FROM t3; +(SELECT 1 FROM t1 +WHERE (SELECT c FROM t2 ORDER BY COUNT(t3.b )) +) +NULL +DROP TABLE t1,t2,t3; +# +# Bug#16833464: Presence of ORDER BY changes data type of column in +# CREATE TABLE SELECT +CREATE TABLE z1 (c05 TIME); +(SELECT * FROM z1 ORDER BY '1') ORDER BY '1'; +c05 +CREATE TABLE z2 (SELECT * FROM z1 ORDER BY '1') ORDER BY '1'; +CREATE TABLE z3 (SELECT * FROM z1) ORDER BY '1'; +SHOW CREATE TABLE z2; +Table Create Table +z2 CREATE TABLE `z2` ( + `c05` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SHOW CREATE TABLE z3; +Table Create Table +z3 CREATE TABLE `z3` ( + `c05` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE z1, z2, z3; +set optimizer_switch=default; diff --git a/mysql-test/r/order_by_sortkey.result-pq b/mysql-test/r/order_by_sortkey.result-pq new file mode 100644 index 000000000..235cb407f --- /dev/null +++ b/mysql-test/r/order_by_sortkey.result-pq @@ -0,0 +1,269 @@ +CREATE TABLE t1( +f0 int auto_increment PRIMARY KEY, +f1 int, +f2 varchar(200) +) charset latin1; +INSERT INTO t1(f1, f2) VALUES +(0,"0"),(1,"1"),(2,"2"),(3,"3"),(4,"4"),(5,"5"), +(6,"6"),(7,"7"),(8,"8"),(9,"9"),(10,"10"), +(11,"11"),(12,"12"),(13,"13"),(14,"14"),(15,"15"), +(16,"16"),(17,"17"),(18,"18"),(19,"19"),(20,"20"), +(21,"21"),(22,"22"),(23,"23"),(24,"24"),(25,"25"), +(26,"26"),(27,"27"),(28,"28"),(29,"29"),(30,"30"), +(31,"31"),(32,"32"),(33,"33"),(34,"34"),(35,"35"), +(36,"36"),(37,"37"),(38,"38"),(39,"39"),(40,"40"), +(41,"41"),(42,"42"),(43,"43"),(44,"44"),(45,"45"), +(46,"46"),(47,"47"),(48,"48"),(49,"49"),(50,"50"), +(51,"51"),(52,"52"),(53,"53"),(54,"54"),(55,"55"), +(56,"56"),(57,"57"),(58,"58"),(59,"59"),(60,"60"), +(61,"61"),(62,"62"),(63,"63"),(64,"64"),(65,"65"), +(66,"66"),(67,"67"),(68,"68"),(69,"69"),(70,"70"), +(71,"71"),(72,"72"),(73,"73"),(74,"74"),(75,"75"), +(76,"76"),(77,"77"),(78,"78"),(79,"79"),(80,"80"), +(81,"81"),(82,"82"),(83,"83"),(84,"84"),(85,"85"), +(86,"86"),(87,"87"),(88,"88"),(89,"89"),(90,"90"), +(91,"91"),(92,"92"),(93,"93"),(94,"94"),(95,"95"), +(96,"96"),(97,"97"),(98,"98"),(99,"99"); +CREATE TEMPORARY TABLE tmp (f1 int, f2 varchar(20)) charset latin1; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +INSERT INTO tmp SELECT f1,f2 FROM t1; +INSERT INTO t1(f1,f2) SELECT * FROM tmp; +set sort_buffer_size= 32768; +FLUSH STATUS; +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 0 +Sort_scan 0 +SELECT * FROM t1 ORDER BY f2,f0 LIMIT 101; +f0 f1 f2 +1 0 0 +101 0 0 +228 0 0 +328 0 0 +428 0 0 +739 0 0 +839 0 0 +939 0 0 +1250 0 0 +1350 0 0 +1450 0 0 +1550 0 0 +1650 0 0 +1750 0 0 +1850 0 0 +1950 0 0 +2050 0 0 +2150 0 0 +2250 0 0 +3297 0 0 +3397 0 0 +3497 0 0 +3597 0 0 +3697 0 0 +3797 0 0 +3897 0 0 +3997 0 0 +4097 0 0 +4197 0 0 +4297 0 0 +4397 0 0 +4497 0 0 +4597 0 0 +4697 0 0 +4797 0 0 +4897 0 0 +4997 0 0 +5097 0 0 +5197 0 0 +5297 0 0 +5397 0 0 +5497 0 0 +5597 0 0 +5697 0 0 +5797 0 0 +5897 0 0 +5997 0 0 +6097 0 0 +6197 0 0 +7392 0 0 +7492 0 0 +7592 0 0 +7692 0 0 +7792 0 0 +7892 0 0 +7992 0 0 +8092 0 0 +8192 0 0 +8292 0 0 +8392 0 0 +8492 0 0 +8592 0 0 +8692 0 0 +8792 0 0 +8892 0 0 +8992 0 0 +9092 0 0 +9192 0 0 +9292 0 0 +9392 0 0 +9492 0 0 +9592 0 0 +9692 0 0 +9792 0 0 +9892 0 0 +9992 0 0 +10092 0 0 +10192 0 0 +10292 0 0 +10392 0 0 +10492 0 0 +10592 0 0 +10692 0 0 +10792 0 0 +10892 0 0 +10992 0 0 +11092 0 0 +11192 0 0 +11292 0 0 +11392 0 0 +11492 0 0 +11592 0 0 +11692 0 0 +11792 0 0 +11892 0 0 +11992 0 0 +12092 0 0 +12192 0 0 +12292 0 0 +12392 0 0 +12492 0 0 +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 404 +Sort_scan 4 +FLUSH STATUS; +CREATE TABLE t2 (f1 int); +INSERT INTO t2 VALUES (0), (0); +SELECT * FROM t2 where f1 = +(SELECT f2 from t1 where t1.f1 = t2.f1 ORDER BY f1 LIMIT 1); +f1 +0 +0 +SHOW SESSION STATUS LIKE 'Sort%'; +Variable_name Value +Sort_merge_passes 0 +Sort_range 0 +Sort_rows 2 +Sort_scan 2 +DROP TABLE t1, t2, tmp; +Bug#32038406: Filesort used for ORDER BY .. DESC even when +descending index available and used +CREATE TABLE t ( +col1 INTEGER NOT NULL, +col2 BINARY(16) NOT NULL, +col3 VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, +col4 INTEGER NOT NULL, +col5 TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), +col6 BLOB, +PRIMARY KEY (col1), +UNIQUE KEY uc_key (col2, col3, col4) +); +INSERT INTO t VALUES(1, x'4142434445464748494a414243444546', 'WRITEBACK', +0, TIMESTAMP'2020-01-01 00:00:00.000000', NULL); +SELECT t.col1, t.col2, t.col3, t.col4, t.col5, t.col6 +FROM t +WHERE t.col2 IN (x'4142434445464748494a414243444546') AND +t.col3 IN ('WRITEBACK') +ORDER BY t.col2 DESC, t.col3 DESC, t.col4 DESC +LIMIT 1; +col1 col2 col3 col4 col5 col6 +1 ABCDEFGHIJABCDEF WRITEBACK 0 2020-01-01 00:00:00.000000 NULL +explain SELECT t.col1, t.col2, t.col3, t.col4, t.col5, t.col6 +FROM t +WHERE t.col2 IN (x'4142434445464748494a414243444546') AND +t.col3 IN ('WRITEBACK') +ORDER BY t.col2 DESC, t.col3 DESC, t.col4 DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref uc_key uc_key 782 const,const 1 100.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`col1` AS `col1`,`test`.`t`.`col2` AS `col2`,`test`.`t`.`col3` AS `col3`,`test`.`t`.`col4` AS `col4`,`test`.`t`.`col5` AS `col5`,`test`.`t`.`col6` AS `col6` from `test`.`t` where ((`test`.`t`.`col2` = 0x4142434445464748494a414243444546) and (`test`.`t`.`col3` = 'WRITEBACK')) order by `test`.`t`.`col2` desc,`test`.`t`.`col3` desc,`test`.`t`.`col4` desc limit 1 +DROP TABLE t; +Here, latin1 is used because it matches collation of temporal const +CREATE TABLE t1(vc VARCHAR(20) CHARACTER SET latin1); +INSERT INTO t1 VALUES('2021-02-08'), ('21-02-08'); +Verify that a string const value removes ORDER BY clause +SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc ASC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = '2021-02-08') order by `test`.`t1`.`vc` +SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc DESC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = '2021-02-08' ORDER BY vc DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = '2021-02-08') order by `test`.`t1`.`vc` desc +Verify the same with a variable (which is const for execution) +set @strvar = _latin1'2021-02-08'; +SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc ASC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = ((@`strvar`))) order by `test`.`t1`.`vc` +SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc DESC; +vc +2021-02-08 +explain SELECT * FROM t1 WHERE vc = @strvar ORDER BY vc DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = ((@`strvar`))) order by `test`.`t1`.`vc` desc +Verify that a date const value does not remove ORDER BY clause +SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc ASC; +vc +2021-02-08 +21-02-08 +explain SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc ASC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = DATE'2021-02-08') order by `test`.`t1`.`vc` +SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc DESC; +vc +21-02-08 +2021-02-08 +explain SELECT * FROM t1 WHERE vc = DATE'2021-02-08' ORDER BY vc DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vc` AS `vc` from `test`.`t1` where (`test`.`t1`.`vc` = DATE'2021-02-08') order by `test`.`t1`.`vc` desc +DROP TABLE t1; diff --git a/mysql-test/r/outfile.result-pq b/mysql-test/r/outfile.result-pq new file mode 100644 index 0000000000000000000000000000000000000000..e48f80f29774be30d9d7c978bd487a2cd7ff05ce GIT binary patch literal 2457 zcmd^AZEqqs5boFYuNct}yfhG&i~rc4%EEtToB$l-=wg4Yp5#-H+I*!FwkK_q*Q&Kk=#;Cq?tS*-tE* zPRCRDbl2^6-@z@x2K7$ooIV8SH%QijODbx<-j?|U-`)@SUL5(Jh>Oy$T@mvnd=9;s z=N`-VRQCiwF^kKSqWj$}WbAqx^^*va{>M1-tQL8~At!^|LyRC&^$u>c{aNM5F6?JlmRTb%+O}=*Z>X z+^g!q>3CR4gvf&ph^eClgGxn$B{xnup_L7)f0x=?LGqG5;o1hY_-`sv1qK&^(JwZj zZg*%f529CRI17W>U^t1R;MYg)3N*dn0$;y?GTr>B-u6ovgxzkZ+YKh%a4As|zcE{p zcr`+=Mo(yLll8uy>cancTt%8cxluwr+IMWE9r{QY!FdZd_x?Hb_-~2yBPE=Bt($k| zE~JHYwm$>^SQuTxfsNfv$CDkIuGq?wK$GW@S`*DkocC(m+GzDwS)n$(oBbZANi<8+ zo5A#rPK32hSl=RV#3d;ZhHLVp3!7&&AS{@b^5_8Zv;e9VwA+@TH`uNed}+ipc*bf4 zR)cVmaYc=}E08Pb5bJ2rl&IXd9l9MsIVWaux@x($Ux+CO_ay)f_$3WLNS$$6Xm6!f zQI6D30tMcAby`64>Uj6Iel{zxIPo(&}E7rf( z?6Ox4gnpKxwUDC{m|wwKuRtNC(%>|Kky}RqA?QW3DqbZYzGgH=9 10; +a1 a2 a3 a4 a1 a2 a3 a4 +SELECT {fn CONCAT(a1,a2)} FROM t1; +{fn CONCAT(a1,a2)} +UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0; +SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')}; +a1 a4 +DROP TABLE t1, t2, t3; +# +# End of 5.1 tests +# +CREATE TABLE t (id INT PRIMARY KEY); +ALTER TABLE t RENAME TO `t1';; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`t1'' at line 1 +DROP TABLE t; +# +# Bug#13819100 BROKEN SYNTAX ACCEPTED FOR START SLAVE, STOP SLAVE +# +STOP SLAVE ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,' at line 1 +STOP SLAVE ,,,,,,,,,,,,, sql_thread, ,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,, sql_thread, ,,,,,,,,,,,,,,,,,,,' at line 1 +STOP SLAVE ,,,,,,,,,,,,, io_thread, ,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,, io_thread, ,,,,,,,,,,,,,,,,,,,' at line 1 +# +# Bug#13819132 BROKEN SYNTAX ACCEPTED FOR START TRANSACTION +# +START TRANSACTION ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,' at line 1 +# +# Test of collective fix for three parser bugs: +# +# Bug #17727401, Bug #17426017, Bug #17473479: +# The server accepts wrong syntax and then fails in different ways +# +CREATE TABLE t1 (i INT); +# bug #17426017 +SELECT (SELECT EXISTS(SELECT * LIMIT 1 ORDER BY VALUES (c00))); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY VALUES (c00)))' at line 1 +# bug#17473479 +CREATE TABLE a(a int); +CREATE TABLE b(a int); +DELETE FROM b ORDER BY(SELECT 1 FROM a ORDER BY a ORDER BY a); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY a)' at line 1 +DROP TABLE a, b; +# bug #17727401 +SELECT '' IN (SELECT '1' c FROM t1 ORDER BY '' ORDER BY '') FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY '') FROM t1' at line 1 +# regression & coverage tests +# uniform syntax for FROM DUAL clause: +SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE; +1 +1 +SELECT 1 FROM +(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE) a; +1 +1 +SELECT 1 FROM t1 +WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE); +1 +SELECT 1 FROM t1 +UNION +SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE; +1 +1 +(SELECT 1 FROM t1) +UNION +(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE); +1 +1 +# "FOR UPDATE" tests +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1; +1 +SELECT 1 FROM t1 FOR UPDATE UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1' at line 1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 FOR UPDATE; +1 +# "INTO" clause tests +SELECT 1 FROM t1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM DUAL INTO @var17727401; +SELECT 1 INTO @var17727401; +SELECT 1 INTO @var17727401 FROM t1; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 INTO @var17727401 FROM DUAL; +SELECT 1 INTO @var17727401_1 FROM t1 INTO @var17727401_2; +ERROR HY000: Multiple INTO clauses in one query block. +SELECT 1 INTO @var17727401_1 FROM DUAL +INTO @var17727401_2; +ERROR HY000: Multiple INTO clauses in one query block. +SELECT 1 INTO @var17727401 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM t1 WHERE 1 INTO @var17727401 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1' at line 1 +SELECT 1 INTO @var17727401_1 +FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1 +INTO @var17727401_2; +ERROR HY000: Multiple INTO clauses in one query block. +SELECT (SELECT 1 FROM t1 INTO @var17727401); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var17727401)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 INTO @var17727401) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var17727401) a' at line 1 +SELECT EXISTS(SELECT 1 FROM t1 INTO @var17727401); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var17727401)' at line 1 +SELECT 1 FROM t1 INTO @var17727401 UNION SELECT 1 FROM t1 INTO t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 INTO t1' at line 1 +(SELECT 1 FROM t1 INTO @var17727401) UNION (SELECT 1 FROM t1 INTO t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT 1 FROM t1 INTO t1)' at line 1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +# ORDER and LIMIT clause combinations +(SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1; +1 +(SELECT 1 FROM t1 LIMIT 1) LIMIT 1; +1 +((SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1) ORDER BY 1; +ERROR 42000: This version of MySQL doesn't yet support 'parenthesized query expression with more than one external level of ORDER/LIMIT operations' +((SELECT 1 FROM t1 LIMIT 1) LIMIT 1) LIMIT 1; +1 +(SELECT 1 FROM t1 ORDER BY 1) LIMIT 1; +1 +(SELECT 1 FROM t1 LIMIT 1) ORDER BY 1; +1 +((SELECT 1 FROM t1 ORDER BY 1) LIMIT 1) ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +((SELECT 1 FROM t1 LIMIT 1) ORDER BY 1) LIMIT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1; +1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1); +(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1) +NULL +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1) a; +1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1; +1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1); +(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1) +NULL +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1) a; +1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1; +1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1); +(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1) +NULL +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1) a; +1 +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1' at line 1 +SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1) a' at line 1 +SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1' at line 1 +SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 ORDER BY 1) a' at line 1 +SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1' at line 1 +SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1)' at line 1 +SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 FROM t1 LIMIT 1) a' at line 1 +DROP TABLE t1; +# +# Bug #18106014: RECENT REGRESSION: MORE CASES OF ASSERTION FAILED: +# !JOIN->PLAN_IS_CONST() +# +SELECT COUNT(1) FROM DUAL GROUP BY '1' ORDER BY 1 ; +COUNT(1) +1 +SELECT COUNT(1) GROUP BY '1' ORDER BY 1 ; +COUNT(1) +1 +DO(SELECT 1 c GROUP BY 1 HAVING 1 ORDER BY COUNT(1)); +DO(SELECT 1 c FROM DUAL GROUP BY 1 HAVING 1 ORDER BY COUNT(1)); +SELECT (SELECT 1 c GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c FROM DUAL GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c WHERE 1 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is not expected'; +null is not expected +1 +SELECT (SELECT 1 c WHERE 1 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL WHERE 1 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c WHERE 0 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL WHERE 0 GROUP BY 1 HAVING 1 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c WHERE 0 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT (SELECT 1 c FROM DUAL WHERE 0 GROUP BY 1 HAVING 0 ORDER BY COUNT(1)) AS +'null is expected'; +null is expected +NULL +SELECT 1 c FROM DUAL GROUP BY 1 HAVING 1 ORDER BY COUNT(1); +c +1 +SELECT 1 c FROM DUAL GROUP BY 1 HAVING 0 ORDER BY COUNT(1); +c +SELECT 1 c GROUP BY 1 HAVING 1 ORDER BY COUNT(1); +c +1 +# +# Bug #18106058: RECENT REGRESSION: CRASH IN JOIN::MAKE_TMP_TABLES_INFO +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +SELECT ((SELECT 1 AS f HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)); +((SELECT 1 AS f HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)) +1 +SELECT ((SELECT 1 AS f FROM DUAL HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)); +((SELECT 1 AS f FROM DUAL HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f)) +1 +SELECT 1 AS f FROM DUAL HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f; +f +1 +SELECT 1 AS f HAVING EXISTS(SELECT 1 FROM t1) IS TRUE +ORDER BY f; +f +1 +DROP TABLE t1; +# +# Bug#17075846 : unquoted file names for variable values are +# accepted but parsed incorrectly +# +SET default_storage_engine=a.myisam; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +SET default_storage_engine = .a.MyISAM; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.a.MyISAM' at line 1 +SET default_storage_engine = a.b.MyISAM; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +SET default_storage_engine = `a`.MyISAM; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +SET default_storage_engine = `a`.`MyISAM`; +ERROR 42000: Incorrect argument type to variable 'default_storage_engine' +set default_storage_engine = "a.MYISAM"; +ERROR 42000: Unknown storage engine 'a.MYISAM' +set default_storage_engine = 'a.MYISAM'; +ERROR 42000: Unknown storage engine 'a.MYISAM' +set default_storage_engine = `a.MYISAM`; +ERROR 42000: Unknown storage engine 'a.MYISAM' +CREATE TABLE t1 (s VARCHAR(100)); +CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW +SET default_storage_engine = NEW.INNODB; +ERROR 42S22: Unknown column 'INNODB' in 'NEW' +DROP TABLE t1; +# +# Some additional coverage tests for WL#7199 and friends +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 (i INT); +INSERT INTO t2 VALUES (10), (20); +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 WHERE i = 10 +ORDER BY i; +i +1 +10 +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 WHERE i = 10 +LIMIT 100; +i +1 +10 +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 GROUP BY i HAVING i = 10 +ORDER BY i; +i +1 +10 +SELECT i FROM t1 WHERE i = 1 +UNION +SELECT i FROM t2 GROUP BY i HAVING i = 10 +LIMIT 100; +i +1 +10 +(SELECT i FROM t1 WHERE i = 1) ORDER BY i; +i +1 +(SELECT i FROM t1 WHERE i = 1) LIMIT 100; +i +1 +(SELECT i FROM t1 GROUP BY i HAVING i = 1) ORDER BY i; +i +1 +(SELECT i FROM t1 GROUP BY i HAVING i = 1) LIMIT 100; +i +1 +DROP TABLE t1, t2; +# +# Bug#18486460 ASSERTION FAILED: N < M_SIZE AFTER FIX_INNER_REFS +# +CREATE TABLE t1(b INT); +CREATE TABLE t2(a INT, b INT, c INT, d INT); +EXPLAIN SELECT +( +SELECT +ROW(t1.b, a) = ROW( ROW(1, t2.c) = ROW(1, d), c) = a +FROM t1 +) +FROM t2 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t2.c' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.d' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.c' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select (((`test`.`t1`.`b` = ((1 = 1) and (`test`.`t2`.`c` = `test`.`t2`.`d`))) and (`test`.`t2`.`a` = `test`.`t2`.`c`)) = `test`.`t2`.`a`) from `test`.`t1`) AS `( +SELECT +ROW(t1.b, a) = ROW( ROW(1, t2.c) = ROW(1, d), c) = a +FROM t1 +)` from `test`.`t2` group by `test`.`t2`.`a` +DROP TABLE t1, t2; +# +# Bug#18498344: SELECT WITH ALIAS NOT WORKING IN 5.7 +# +CREATE TABLE t1 ( +a INT +); +INSERT INTO t1 VALUES ( 2 ); +# Should succeed +SELECT * +FROM ( SELECT a FROM t1 UNION SELECT 1 ORDER BY a ) AS a1 +WHERE a1.a = 1 OR a1.a = 2; +a +1 +2 +DROP TABLE t1; +# +# Bug #18484088: PROBLEMS IN CREATE_FUNC_CAST ON QUERY ERRORS... +# +DO(CONVERT(CONVERT('',DECIMAL(66,0)), DECIMAL(66,0))), CAST(CONVERT(1,DECIMAL(65,31)) AS DATE); +ERROR 42000: Too-big precision 66 specified for ''''. Maximum is 65. +SELECT CONVERT(CONVERT('',DECIMAL(65,0)), DECIMAL(66,0)); +ERROR 42000: Too-big precision 66 specified for 'CONVERT('',DECIMAL(65,0))'. Maximum is 65. +# +# Bug #18759387: PROBLEM IN ITEM_FUNC_XOR::NEG_TRANSFORMER +# +SELECT 1< +!(1 XOR TO_BASE64())); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2 +SELECT 1< +!(1 XOR TO_BASE64()); +ERROR 42000: Incorrect parameter count in the call to native function 'TO_BASE64' +SELECT !('' XOR LENGTH()); +ERROR 42000: Incorrect parameter count in the call to native function 'LENGTH' +SELECT !((UNHEX() IS NULL)); +ERROR 42000: Incorrect parameter count in the call to native function 'UNHEX' +# +# Bug #20086997: PARSER CONFUSES WITH 7BIT-CHARACTER STRING DETECTION +# +CREATE DATABASE mysqltest1 CHARACTER SET LATIN2; +USE mysqltest1; +CREATE TABLE t1 (a VARCHAR(255) CHARACTER SET LATIN2); +SET CHARACTER SET cp1250_latin2; +INSERT INTO t1 VALUES (''); +INSERT INTO t1 VALUES ('' ''); +SELECT HEX(a) FROM t1; +HEX(a) +A3A1AAAF +A3A1AAAF +DROP DATABASE mysqltest1; +USE test; +# +# WL #7201, WL #7202 and WL#8062 coverage tests +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 () SELECT * FROM t1; +INSERT INTO t1 SELECT HIGH_PRIORITY * FROM t1; +INSERT INTO t1 SELECT DISTINCT ALL * FROM t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +REPLACE INTO `` SELECT * FROM ``; +ERROR 42000: Incorrect table name '' +DELETE QUICK FROM t1 WHERE i = 0; +DROP TABLE t1; +# +# Bug #21035515: PARSE_GCOL_EXPR SHOULD BE A KIND OF RESERVED WORD, +# NOT A KEYWORD +SET @parse_gcol_expr = 1; +SELECT 1 AS parse_gcol_expr; +parse_gcol_expr +1 +CREATE TABLE parse_gcol_expr (i INT); +DROP TABLE parse_gcol_expr; +# parse_gcol_expr can't be a label: +CREATE PROCEDURE p1() +BEGIN +parse_gcol_expr: LOOP +SELECT 1; +END LOOP parse_gcol_expr; +END| +DROP PROCEDURE p1; +# PARSE_GCOL_EXPR is not a valid statement: +PARSE_GCOL_EXPR (1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARSE_GCOL_EXPR (1)' at line 1 +# +# Bug #17400320 ALGORITHM= IS NOT SUPPORTED FOR ALTER TABLE WITH +# +CREATE TABLE t1 (x INT PRIMARY KEY); +ALTER TABLE t1; +ALTER TABLE t1 ALGORITHM=DEFAULT; +ALTER TABLE t1 ALGORITHM=COPY; +ALTER TABLE t1 ALGORITHM=INPLACE; +ALTER TABLE t1 LOCK=DEFAULT; +ALTER TABLE t1 LOCK=NONE; +ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. +ALTER TABLE t1 LOCK=SHARED; +ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE. +ALTER TABLE t1 LOCK=EXCLUSIVE; +ALTER TABLE t1 LOCK=SHARED, ALGORITHM=COPY, +LOCK=NONE, ALGORITHM=DEFAULT, +LOCK=EXCLUSIVE, ALGORITHM=INPLACE; +ALTER TABLE t1 WITH VALIDATION; +ERROR HY000: Incorrect usage of ALTER and WITH VALIDATION +ALTER TABLE t1 WITHOUT VALIDATION; +ERROR HY000: Incorrect usage of ALTER and WITH VALIDATION +ALTER TABLE t1 LOCK=SHARED, WITH VALIDATION, ALGORITHM=COPY, +LOCK=EXCLUSIVE, WITHOUT VALIDATION, ALGORITHM=INPLACE; +ERROR HY000: Incorrect usage of ALTER and WITH VALIDATION +DROP TABLE t1; +# +# WL#8083: Introduce parser rule +# Bug#14743786: PARSE ERROR WITH UNION PARENTHESES ON TOP LEVEL +# +# +# Part1: Regression Testing. +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES ( 1 ); +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES ( 2 ), ( 2 ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES ( 3 ), ( 3 ), ( 3 ); +SELECT 1 UNION SELECT 2; +1 +1 +2 +(SELECT 1) UNION SELECT 2; +1 +1 +2 +SELECT 1 UNION (SELECT 2); +1 +1 +2 +(SELECT 1) UNION (SELECT 2); +1 +1 +2 +SELECT 2 FROM t1 UNION ((SELECT 3 FROM t1)); +2 +2 +3 +(SELECT 2 FROM t1) UNION SELECT 3 FROM t1; +2 +2 +3 +((SELECT 2 FROM t1)) UNION SELECT 3 FROM t1; +2 +2 +3 +(SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1; +1 +1 +(SELECT 1 FROM t1 LIMIT 1) LIMIT 1; +1 +1 +SELECT a FROM t1 LIMIT 1 UNION ALL SELECT a FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION ALL SELECT a FROM t1' at line 1 +(SELECT 1) UNION (SELECT 2 UNION SELECT 3); +ERROR 42000: This version of MySQL doesn't yet support 'nesting of unions at the right-hand side' +(SELECT a FROM t1 LIMIT 1) UNION ALL (SELECT a FROM t1 ORDER BY a) LIMIT 2; +a +1 +1 +(SELECT a FROM t1 LIMIT 1) UNION ALL ((SELECT a FROM t1 ORDER BY a)) LIMIT 2; +a +1 +1 +SELECT 1 UNION SELECT 2 FROM t1 ORDER BY a LIMIT 1; +ERROR 42S22: Unknown column 'a' in 'order clause' +SELECT 1 UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1); +1 +1 +2 +(SELECT 1 FROM t1 LIMIT 2) UNION SELECT 2 FROM t1 ORDER BY a LIMIT 1; +ERROR 42S22: Unknown column 'a' in 'order clause' +(SELECT 1 FROM t1 LIMIT 2) UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1); +1 +1 +2 +(SELECT a FROM t1 LIMIT 2) LIMIT 1; +a +1 +((SELECT a FROM t1 LIMIT 2)) LIMIT 1; +a +1 +(SELECT a FROM t1 LIMIT 2) ORDER BY 1; +a +1 +(SELECT 1 FROM t1 LIMIT 2) UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1) LIMIT 1; +1 +1 +(SELECT 1 FROM t1 LIMIT 2) UNION (SELECT 2 FROM t1 ORDER BY a LIMIT 1) +ORDER BY a; +ERROR 42S22: Unknown column 'a' in 'order clause' +(SELECT 1 FROM t1 LIMIT 1) UNION ((SELECT 2 FROM t1 ORDER BY a LIMIT 2)) +ORDER BY a; +ERROR 42S22: Unknown column 'a' in 'order clause' +(SELECT a FROM t2 LIMIT 1) UNION (SELECT a FROM t3 LIMIT 2) LIMIT 1; +a +2 +(SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1; +1 +1 +(SELECT a FROM t1 LIMIT 1) ORDER BY t1.a; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +((SELECT a FROM t1 LIMIT 1)) ORDER BY t1.a; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +(SELECT a FROM t1 LIMIT 1) UNION ALL (SELECT 2) ORDER BY t1.b; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +(SELECT a FROM t1 LIMIT 1) UNION ALL ((SELECT 2)) ORDER BY t1.b; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +(SELECT a FROM t1 LIMIT 1) UNION ALL (SELECT a FROM t1 ORDER BY a LIMIT 2) +ORDER BY t1.b; +ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause +SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ); +ERROR 42000: This version of MySQL doesn't yet support 'nesting of unions at the right-hand side' +( SELECT 1 UNION SELECT 1 ) UNION SELECT 1; +1 +1 +( (SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ) UNION SELECT 1; +1 +1 +( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ); +ERROR 42000: This version of MySQL doesn't yet support 'nesting of unions at the right-hand side' +( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT a FROM t1 ORDER BY a UNION SELECT a FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT a FROM t1' at line 1 +(SELECT * FROM t1 LIMIT 1) UNION SELECT * FROM t1; +a +1 +(SELECT * FROM t1 ORDER BY a) UNION SELECT * FROM t1; +a +1 +SELECT a FROM t1 +UNION +SELECT a FROM t1 ORDER BY a +UNION +SELECT a FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION +SELECT a FROM t1' at line 4 +(SELECT SQL_CALC_FOUND_ROWS a FROM t1 LIMIT 2) +UNION +(SELECT a FROM t2 ORDER BY a) LIMIT 2; +a +1 +2 +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +DROP TABLE t1, t2, t3; +CREATE PROCEDURE p1() BEGIN IF whatever THEN SELECT 1; END IF; END| +CALL p1(); +ERROR 42S22: Unknown column 'whatever' in 'field list' +DROP PROCEDURE p1; +# +# Part 2: Test of changed (fixed) behavior. +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES ( 1 ); +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES ( 2 ), ( 2 ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES ( 3 ), ( 3 ), ( 3 ); +(SELECT 1 FROM t1 UNION SELECT 2 FROM t1); +1 +1 +2 +((SELECT 1 FROM t1 UNION SELECT 2 FROM t1)); +1 +1 +2 +(SELECT 1 FROM t1 UNION (SELECT 2 FROM t1)); +1 +1 +2 +((SELECT 1 FROM t1 UNION (SELECT 2 FROM t1))); +1 +1 +2 +((SELECT 1 FROM t1 UNION ((SELECT 2 FROM t1)))); +1 +1 +2 +((SELECT 1 FROM t1) UNION SELECT 2 FROM t1); +1 +1 +2 +(((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1); +1 +1 +2 +((((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1)); +1 +1 +2 +((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1)); +1 +1 +2 +(((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1))); +1 +1 +2 +((((SELECT 1 FROM t1)) UNION (SELECT 2 FROM t1))); +1 +1 +2 +(((SELECT 1 FROM t1) UNION ((SELECT 2 FROM t1)))); +1 +1 +2 +((((SELECT 1 FROM t1)) UNION ((SELECT 2 FROM t1)))); +1 +1 +2 +(SELECT 1 UNION SELECT 2) ORDER BY 1; +1 +1 +2 +((SELECT 1 UNION SELECT 2)) ORDER BY 1; +1 +1 +2 +((SELECT 1) ORDER BY 1); +1 +1 +((SELECT 1) LIMIT 1); +1 +1 +(SELECT 1 UNION SELECT 2) LIMIT 1; +1 +1 +((SELECT 1 UNION SELECT 2)) LIMIT 1; +1 +1 +(SELECT a FROM t1) LIMIT 1 UNION ALL ((SELECT a FROM t1 ORDER BY a)) LIMIT 2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION ALL ((SELECT a FROM t1 ORDER BY a)) LIMIT 2' at line 1 +DROP TABLE t1, t2, t3; +# +# Part 3: The syntax. +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES ( 1 ); +CREATE TABLE t2 ( a INT ); +INSERT INTO t2 VALUES ( 2 ); +CREATE TABLE t3 ( a INT ); +INSERT INTO t3 VALUES ( 3 ); +CREATE TABLE t4 ( a INT ); +INSERT INTO t4 VALUES ( 3 ); +SELECT * FROM (SELECT 1 FROM t1 UNION SELECT 2 FROM t1) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1 UNION SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM (SELECT 1 FROM t1 UNION (SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1 UNION (SELECT 2 FROM t1))) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1 UNION ((SELECT 2 FROM t1)))) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1) UNION SELECT 2 FROM t1) dt; +1 +1 +2 +SELECT * FROM (((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1) dt; +1 +1 +2 +SELECT * FROM ((((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM ((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1)) dt; +1 +1 +2 +SELECT * FROM (((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1))) dt; +1 +1 +2 +SELECT * FROM ((((SELECT 1 FROM t1)) UNION (SELECT 2 FROM t1))) dt; +1 +1 +2 +SELECT * FROM (((SELECT 1 FROM t1) UNION ((SELECT 2 FROM t1)))) dt; +1 +1 +2 +SELECT * FROM ((((SELECT 1 FROM t1)) UNION ((SELECT 2 FROM t1)))) dt; +1 +1 +2 +SELECT * FROM (SELECT 1 FROM t1 UNION SELECT 2 FROM t1); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1 UNION SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (SELECT 1 FROM t1 UNION (SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1 UNION (SELECT 2 FROM t1))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1 UNION ((SELECT 2 FROM t1)))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1) UNION SELECT 2 FROM t1); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((((SELECT 1 FROM t1)) UNION SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1)); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (((SELECT 1 FROM t1) UNION (SELECT 2 FROM t1))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((((SELECT 1 FROM t1)) UNION (SELECT 2 FROM t1))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM (((SELECT 1 FROM t1) UNION ((SELECT 2 FROM t1)))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ((((SELECT 1 FROM t1)) UNION ((SELECT 2 FROM t1)))); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ( t1 JOIN t2 ON TRUE ); +a a +1 2 +SELECT * FROM (( t1 JOIN t2 ON TRUE )); +a a +1 2 +SELECT * FROM ( t1 JOIN t2 ON TRUE JOIN t3 ON TRUE ); +a a a +1 2 3 +SELECT * FROM ((t1 JOIN t2 ON TRUE) JOIN t3 ON TRUE ); +a a a +1 2 3 +SELECT * FROM (t1 INNER JOIN t2 ON (t1.a = t2.a)); +a a +SELECT 1 FROM (SELECT 1 FROM t1 INTO @v) a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v) a' at line 1 +SELECT 1 FROM (t1); +1 +1 +SELECT 1 FROM ((t1)); +1 +1 +SELECT 1 UNION SELECT 2 FROM (t2); +1 +1 +2 +SELECT 1 FROM (SELECT 2 ORDER BY 1) AS res; +1 +1 +# +# This syntax is no longer allowed +# +SELECT 1 FROM ((SELECT 2) ORDER BY 1) AS res; +1 +1 +SELECT 1 FROM ((SELECT 2) a ORDER BY 1) AS res; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1) AS res' at line 1 +SELECT 1 FROM ((SELECT 2) LIMIT 1) AS res; +1 +1 +SELECT 1 FROM ((SELECT 2) a LIMIT 1) AS res; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1) AS res' at line 1 +SELECT * FROM ( t1 AS alias1 ); +a +1 +SELECT * FROM t1 AS alias1, t2 AS alias2; +a a +1 2 +SELECT * FROM ( t1 AS alias1, t2 AS alias2 ); +a a +1 2 +SELECT * FROM ( t1 JOIN t2 ON TRUE, t1 JOIN t3 ON TRUE ); +ERROR 42000: Not unique table/alias: 't1' +SELECT * FROM ( t1 JOIN t2 ON TRUE, t1 t11 JOIN t3 ON TRUE ) t1a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a' at line 1 +SELECT * FROM ( t1 JOIN t2 ON TRUE, SELECT 1 FROM DUAL ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1 FROM DUAL )' at line 1 +SELECT * FROM ( t1 JOIN t2 ON TRUE, (SELECT 1 FROM DUAL) t1a ); +a a 1 +1 2 1 +SELECT * FROM t1 JOIN t2 ON TRUE, (SELECT 1 FROM DUAL) t1a; +a a 1 +1 2 1 +SELECT * FROM ( SELECT 1 FROM DUAL ); +ERROR 42000: Every derived table must have its own alias +SELECT * FROM ( SELECT 1 FROM DUAL ) t1a; +1 +1 +SELECT * FROM ( t1, t2 ); +a a +1 2 +SELECT * FROM (( t1, t2 )); +a a +1 2 +SELECT * FROM ( (t1), t2 ); +a a +1 2 +SELECT * FROM (((t1)), t2 ); +a a +1 2 +SELECT * FROM ( (t1), (t2) ); +a a +1 2 +SELECT * FROM ( t1, (t2) ); +a a +1 2 +((SELECT 1 UNION SELECT 1) UNION SELECT 1); +1 +1 +SELECT * FROM ((SELECT 1 UNION SELECT 1) UNION SELECT 1) a; +1 +1 +SELECT * FROM (t1, t2) JOIN (t3, t4) ON TRUE; +a a a a +1 2 3 3 +SELECT * FROM ((t1, t2) JOIN t3 ON TRUE); +a a a +1 2 3 +SELECT * FROM t1 JOIN ( t2, t3 ) USING ( a ); +ERROR 23000: Column 'a' in from clause is ambiguous +DROP TABLE t1, t2, t3, t4; +# Check the format in the note. +CREATE TABLE t1 (a INT); +EXPLAIN SELECT 1 FROM (SELECT 1 FROM t1) t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` +DROP TABLE t1; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( b INT ); +CREATE TABLE t3 ( c INT ); +CREATE TABLE t4 ( d INT ); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (2); +INSERT INTO t4 VALUES (2); +SELECT * FROM t1 LEFT JOIN ( t2, t3, t4 ) ON a = c; +a b c d +1 NULL NULL NULL +SELECT * FROM t1 NATURAL JOIN ((t1 NATURAL JOIN t1), (t1 NATURAL JOIN t1)); +ERROR 42000: Not unique table/alias: 't1' +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( b INT ); +CREATE TABLE t3 ( c INT ); +CREATE TABLE t4 ( d INT ); +CREATE TABLE t5 ( d INT ); +SELECT * FROM t5 NATURAL JOIN ((t1 NATURAL JOIN t2), (t3 NATURAL JOIN t4)); +d a b c +SELECT * FROM ((t1 NATURAL JOIN t2), (t3 NATURAL JOIN t4)) NATURAL JOIN t5; +d a b c +SELECT * FROM t1 JOIN ( t2, t3 ) ON TRUE; +a b c +SELECT * FROM ( t1, t2 , t3 ); +a b c +SELECT * FROM ( ( t1, t2 ), t3 ); +a b c +SELECT * FROM ( ((t1, t2)), t3 ); +a b c +SELECT * FROM ( t1, ( t2, t3 ) ); +a b c +SELECT * FROM ( t1, ((t2, t3)) ); +a b c +SELECT * FROM ((( t1, t2 ), t3)); +a b c +SELECT * FROM ((((t1, t2)), t3)); +a b c +SELECT * FROM ((t1, ( t2, t3 ))); +a b c +SELECT * FROM ((t1, ((t2, t3)))); +a b c +CREATE VIEW v1 AS SELECT 1 INTO @v; +ERROR HY000: View's SELECT contains a 'INTO' clause +CREATE VIEW v1 AS SELECT 1 FROM ( SELECT 1 FROM t1 ) my_table; +DROP TABLE t1, t2, t3, t4, t5; +DROP VIEW v1; +CREATE TABLE t1( a INT ); +INSERT INTO t1 VALUES (1); +SELECT 1 INTO @v; +(SELECT 1 INTO @v); +((SELECT 1 INTO @v)); +SELECT 1 FROM t1 INTO @v; +(SELECT 1 FROM t1 INTO @v); +((SELECT 1 FROM t1 INTO @v)); +SELECT 1 FROM t1 INTO @v UNION SELECT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1' at line 1 +(SELECT 1 FROM t1 INTO @v) UNION SELECT 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1' at line 1 +SELECT 1 FROM t1 INTO @v UNION (SELECT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT 1)' at line 1 +((SELECT 1 FROM t1 INTO @v) UNION (SELECT 1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT 1))' at line 1 +SELECT 1 INTO @v UNION SELECT 1; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +(SELECT 1 INTO @v) UNION SELECT 1; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +SELECT 1 INTO @v UNION (SELECT 1); +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +((SELECT 1 INTO @v) UNION (SELECT 1)); +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +SELECT 1 UNION SELECT 2 INTO @v; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION SELECT 2 INTO @v; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION (SELECT 2 INTO @v); +ERROR 42000: Result consisted of more than one row +((SELECT 1) UNION (SELECT 2 INTO @v)); +ERROR 42000: Result consisted of more than one row +SELECT 1 UNION SELECT 2 INTO @v FROM t1; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION SELECT 2 INTO @v FROM t1; +ERROR 42000: Result consisted of more than one row +(SELECT 1) UNION (SELECT 2 INTO @v FROM t1); +ERROR 42000: Result consisted of more than one row +((SELECT 1) UNION (SELECT 2 INTO @v FROM t1)); +ERROR 42000: Result consisted of more than one row +SELECT 1 UNION SELECT 1 INTO @v FROM t1; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1) UNION SELECT 1 INTO @v FROM t1; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1) UNION (SELECT 1 INTO @v FROM t1); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +((SELECT 1) UNION (SELECT 1 INTO @v FROM t1)); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION SELECT 2 INTO OUTFILE 'parser.test.file1'; +SELECT 1 UNION (SELECT 2 INTO OUTFILE 'parser.test.file2'); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1) UNION SELECT 2 INTO OUTFILE 'parser.test.file3'; +(SELECT 1) UNION (SELECT 2 INTO OUTFILE 'parser.test.file4'); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +((SELECT 1) UNION (SELECT 2 INTO OUTFILE 'parser.test.file5')); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT * FROM (SELECT a INTO @v FROM t1) t1a; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +SELECT * FROM (SELECT a INTO @v) t1a; +ERROR HY000: Misplaced INTO clause, INTO is not allowed inside subqueries, and must be placed at end of UNION clauses. +DROP TABLE t1; +# +# Part 4: The syntax. +# +CREATE TABLE t1( a INT ); +CREATE TABLE t2( b INT ); +CREATE TABLE t3( c INT ); +CREATE TABLE t4( d INT ); +CREATE TABLE t5( e INT ); +# We use EXPLAIN so we can get the parser's interpretation of the +# nesting. We don't really care about the execution plan. +SET optimizer_switch = 'block_nested_loop=off'; +SELECT * FROM t1 JOIN t2; +a b +SELECT * FROM t1 JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 INNER JOIN t2; +a b +SELECT * FROM t1 INNER JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 INNER JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 CROSS JOIN t2; +a b +SELECT * FROM t1 CROSS JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 CROSS JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 STRAIGHT_JOIN t2; +a b +SELECT * FROM t1 STRAIGHT_JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 STRAIGHT_JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 t11 NATURAL JOIN t1 t12; +a +SELECT * FROM t1 t11 NATURAL JOIN t1 t12 ON t11.a = t12.a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON t11.a = t12.a' at line 1 +SELECT * FROM t1 t11 NATURAL JOIN t1 t12 USING ( a ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING ( a )' at line 1 +SELECT * FROM t1 t11 NATURAL INNER JOIN t1 t12; +a +SELECT * FROM t1 LEFT JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 LEFT JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 LEFT JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL LEFT JOIN t2; +a b +SELECT * FROM t1 LEFT OUTER JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 LEFT OUTER JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 LEFT OUTER JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL LEFT OUTER JOIN t2; +a b +SELECT * FROM t1 RIGHT JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 RIGHT JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 RIGHT JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL RIGHT JOIN t2; +b a +SELECT * FROM t1 RIGHT OUTER JOIN t2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +SELECT * FROM t1 RIGHT OUTER JOIN t2 ON a = b; +a b +SELECT * FROM t1 t11 RIGHT OUTER JOIN t1 t12 USING ( a ); +a +SELECT * FROM t1 NATURAL RIGHT OUTER JOIN t2; +b a +# Right-deep join nesting. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t2.b = t3.c ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`c` = `test`.`t1`.`a`)) +# Right-deep join nesting from t2 and on. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t3.c = t4.d ON t2.b = t3.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t3`.`c` = `test`.`t2`.`b`) and (`test`.`t4`.`d` = `test`.`t2`.`b`)) +# Right-deep join nesting from t2 and on. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t3.c = t4.d ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t4`.`d` = `test`.`t3`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`a`)) +# Left-deep join nesting. +EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.a = t2.b JOIN t3 ON t2.b = t3.c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`c` = `test`.`t1`.`a`)) +# A cross join joined with an inner join (i.e. with a join condition). +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 t11 JOIN t2 JOIN t1 t12 USING ( a ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t12 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` join `test`.`t1` `t12` where (`test`.`t12`.`a` = `test`.`t11`.`a`) +# A left-deep cross join tree joined with an inner join. +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 JOIN t5 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t5 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d`,`test`.`t5`.`e` AS `e` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` join `test`.`t5` where (`test`.`t2`.`b` = `test`.`t1`.`a`) +# The different kinds of when used with context-dependent +# join. Tests the top-down build of the parse tree. +EXPLAIN SELECT * FROM t1 JOIN (t2) JOIN t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` +EXPLAIN SELECT * FROM t1 JOIN (SELECT 1 AS b) a JOIN t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,'1' AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t3` +EXPLAIN SELECT * FROM t1 JOIN (t2 JOIN t3) JOIN t4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` +EXPLAIN SELECT * FROM t1 JOIN (t2, t3) JOIN t4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t2.b = t3.c JOIN t4 ON t1.a = t4.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t3`.`c` = `test`.`t2`.`b`) and (`test`.`t4`.`d` = `test`.`t1`.`a`)) +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 ON t2.b = t3.c JOIN t4 ON t1.a = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`c` = `test`.`t1`.`a`)) +EXPLAIN SELECT * FROM t1 t11 JOIN t2 JOIN t1 t12 USING(a) JOIN t1 t13 USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t12 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t13 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t11` join `test`.`t2` join `test`.`t1` `t12` join `test`.`t1` `t13` where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t13`.`a` = `test`.`t11`.`a`)) +EXPLAIN SELECT * FROM t2 JOIN t1 t11 JOIN t1 t12 USING(a) JOIN t1 t13 USING(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t11 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t12 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t13 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` join `test`.`t1` `t11` join `test`.`t1` `t12` join `test`.`t1` `t13` where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t13`.`a` = `test`.`t11`.`a`)) +EXPLAIN SELECT * FROM t1 JOIN t2 JOIN t3 JOIN t4 ON t3.c = t4.d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where (`test`.`t4`.`d` = `test`.`t3`.`c`) +SET optimizer_switch = DEFAULT; +DROP TABLE t1, t2, t3, t4, t5; +# Testing correct nesting of natural joins. +CREATE TABLE t1( a INT, b int ); +CREATE TABLE t2( a INT, c int ); +CREATE TABLE t3( a INT, d int ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +INSERT INTO t2 VALUES (2, 2), (3, 3), (4, 4); +INSERT INTO t3 VALUES (3, 3), (4, 4), (5, 5); +# The two queries below should produce identical result sets. +SELECT * FROM t1 NATURAL LEFT JOIN t2 NATURAL RIGHT JOIN t3; +a d b c +3 3 3 3 +4 4 NULL NULL +5 5 NULL NULL +SELECT * FROM (t1 NATURAL LEFT JOIN t2) NATURAL RIGHT JOIN t3; +a d b c +3 3 3 3 +4 4 NULL NULL +5 5 NULL NULL +# This result should differ from the result sets above. +SELECT * FROM t1 NATURAL LEFT JOIN (t2 NATURAL RIGHT JOIN t3); +a b d c +1 1 NULL NULL +2 2 NULL NULL +3 3 3 3 +DROP TABLE t1, t2, t3; +# +# Bug#22995438: BUILD INDEX DEFINITION SYNTAX BOTTOM-UP +# +# This is regression testing for the refactoring. +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +d INT, +e INT, +f INT, +g INT, +h INT, +i INT, +j INT, +k INT, +l INT, +m INT, +n INT, +o INT +); +CREATE INDEX a_index ON t1( a ); +CREATE UNIQUE INDEX b_index ON t1( b ); +CREATE INDEX c_index USING btree ON t1( c ); +CREATE INDEX c_index USING btree USING btree ON t1( c ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING btree ON t1( c )' at line 1 +CREATE INDEX d_index USING rtree ON t1( d ); +ERROR 42000: A SPATIAL index may only contain a geometrical type column +CREATE INDEX e_index TYPE btree ON t1( e ); +CREATE INDEX type TYPE btree ON t1( f ); +CREATE INDEX TYPE btree ON t1( g ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'btree ON t1( g )' at line 1 +CREATE INDEX h_index TYPE rtree ON t1( h ); +ERROR 42000: A SPATIAL index may only contain a geometrical type column +CREATE INDEX i_index ON t1( i ) KEY_BLOCK_SIZE = 1; +CREATE INDEX j_index ON t1( j ) KEY_BLOCK_SIZE = 1 KEY_BLOCK_SIZE = 1; +CREATE INDEX k_index ON t1( k ) COMMENT 'A comment'; +CREATE INDEX k_index2 ON t1( k ) COMMENT 'A comment' COMMENT 'Another comment'; +Warnings: +Warning 1831 Duplicate index 'k_index2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +CREATE INDEX l_index ON t1( l ) USING btree; +CREATE INDEX m_index ON t1( m ) TYPE btree; +CREATE INDEX n_index USING btree ON t1( n ) USING btree; +CREATE INDEX x_index USING btree ON t1( o ) USING rtree; +ERROR 42000: A SPATIAL index may only contain a geometrical type column +CREATE INDEX o_index USING rtree ON t1( o ) USING btree; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 b_index 1 b A 0 NULL NULL YES BTREE YES NULL +t1 1 a_index 1 a A 0 NULL NULL YES BTREE YES NULL +t1 1 c_index 1 c A 0 NULL NULL YES BTREE YES NULL +t1 1 e_index 1 e A 0 NULL NULL YES BTREE YES NULL +t1 1 type 1 f A 0 NULL NULL YES BTREE YES NULL +t1 1 i_index 1 i A 0 NULL NULL YES BTREE YES NULL +t1 1 j_index 1 j A 0 NULL NULL YES BTREE YES NULL +t1 1 k_index 1 k A 0 NULL NULL YES BTREE A comment YES NULL +t1 1 k_index2 1 k A 0 NULL NULL YES BTREE Another comment YES NULL +t1 1 l_index 1 l A 0 NULL NULL YES BTREE YES NULL +t1 1 m_index 1 m A 0 NULL NULL YES BTREE YES NULL +t1 1 n_index 1 n A 0 NULL NULL YES BTREE YES NULL +t1 1 o_index 1 o A 0 NULL NULL YES BTREE YES NULL +DROP TABLE t1; +# +# WL#8907: Parser refactoring: merge all SELECT rules into one. +# +# Warning on hints in CREATE or ALTER VIEW: +CREATE VIEW v1 AS SELECT /*+ QB_NAME(a) */ 1; +ALTER VIEW v1 AS SELECT /*+ QB_NAME(a) */ 1; +SELECT * FROM v1; +1 +1 +DROP VIEW v1; +# The "Hints aren't supported in CREATE or ALTER VIEW" warning is masked: +CREATE VIEW v1 AS SELECT /*+ BAD_HINT */ 1; +Warnings: +Warning 1064 Optimizer hint syntax error near 'BAD_HINT */ 1' at line 1 +ALTER VIEW v1 AS SELECT /*+ BAD_HINT */ 1; +Warnings: +Warning 1064 Optimizer hint syntax error near 'BAD_HINT */ 1' at line 1 +SELECT * FROM v1; +1 +1 +DROP VIEW v1; +# +# +# Bug#23321895: CRASH IN IS_VIEW_OR_DERIVED OR +# TABLE_LIST::IS_LEAF_FOR_NAME_RESOLUTION +# +CREATE TABLE t1( a INT ); +CREATE TABLE t2( a INT ); +CREATE TABLE t3( a INT ); +CREATE TABLE t4( a INT ); +SELECT 1 +FROM ( SELECT 1 FROM t1 JOIN t2 ON @@q ) AS d +JOIN t3 LEFT JOIN t4 ON 1; +ERROR HY000: Unknown system variable 'q' +DROP TABLE t1, t2, t3, t4; +# +# Bug#39559: dump of stored procedures / functions with C-style +# comment can't be read back +# ++----------+--------+ +| expected | result | ++----------+--------+ +| 2 | 2 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 1 | 1 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 3 | 3 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 2 | 2 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 7 | 7 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 8 | 8 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 7 | 7 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 4 | 4 | ++----------+--------+ ++----------+--------+ +| expected | result | ++----------+--------+ +| 4 | 4 | ++----------+--------+ +# Bug#46527 "COMMIT AND CHAIN RELEASE does not make sense" +# +COMMIT AND CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +COMMIT AND NO CHAIN RELEASE; +COMMIT RELEASE; +COMMIT CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +COMMIT NO CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +COMMIT AND NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +COMMIT AND RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +COMMIT NO RELEASE; +COMMIT CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +COMMIT NO CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +COMMIT AND RELEASE CHAIN; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE CHAIN' at line 1 +COMMIT AND NO CHAIN NO RELEASE; +ROLLBACK AND CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +ROLLBACK AND NO CHAIN RELEASE; +ROLLBACK RELEASE; +ROLLBACK CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +ROLLBACK NO CHAIN RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN RELEASE' at line 1 +ROLLBACK AND NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +ROLLBACK AND RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE' at line 1 +ROLLBACK NO RELEASE; +ROLLBACK CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +ROLLBACK NO CHAIN NO RELEASE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAIN NO RELEASE' at line 1 +ROLLBACK AND RELEASE CHAIN; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELEASE CHAIN' at line 1 +ROLLBACK AND NO CHAIN NO RELEASE; +# +# Bug#26132947: SERVER CAN EXIT ON ALTER TABLE ADD PARTITION SYNTAX +# +CREATE TABLE t1 (a INT PRIMARY KEY) PARTITION BY HASH (a) PARTITIONS 1; +ALTER TABLE t1 ADD PARTITION; +ERROR HY000: At least one partition must be added +DROP TABLE t1; +# +# +# Bug#25717617: Wrong syntax error line numbers when sql_mode has the +# IGNORE_SPACE flag +# +SET @save_sql_mode=@@sql_mode; +SET sql_mode='IGNORE_SPACE'; +# Expected error line number is 2: +CREATE +TABLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2 +# Expected error line number is 5: +CREATE +# +# +# +TABLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5 +# +# Regression test added in WL#8657 +# +CREATE TEMPORARY TABLE t1(a INT); +SHOW COLUMNS FROM t1 WHERE FIELD='a'; +Field Type Null Key Default Extra +a int YES NULL NULL +DROP TABLE t1; +ALTER TABLE t1 RENAME TO ``.t1; +ERROR 42000: Incorrect database name '' +CREATE TABLE t1 (a INT) PARTITION BY KEY ALGORITHM = 10 () PARTITIONS 3; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10 () PARTITIONS 3' at line 1 +ALTER EVENT ev1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +ALTER INSTANCE ROTATE MyISAM MASTER KEY; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MyISAM MASTER KEY' at line 1 +REVOKE SELECT(c1) ON FUNCTION *.* FROM r1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +GRANT SELECT(c1) ON FUNCTION *.* TO r1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +CREATE INDEX idx1 ON `` (c1); +ERROR 42000: Incorrect table name '' +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE `` WITH VALIDATION; +ERROR 42000: Incorrect table name '' +CHECK TABLE ``; +ERROR 42000: Incorrect table name '' +DROP INDEX idx1 ON ``; +ERROR 42000: Incorrect table name '' +CACHE INDEX `` IN c; +ERROR 42000: Incorrect table name '' +CACHE INDEX `` PARTITION (ALL) IN c; +ERROR 42000: Incorrect table name '' +LOAD INDEX INTO CACHE `` PARTITION (ALL); +ERROR 42000: Incorrect table name '' +LOAD INDEX INTO CACHE ``; +ERROR 42000: Incorrect table name '' +SET @@sql_mode=@save_sql_mode; +# +# Bug#24756971: REMOVE OBSOLETE LEXER HACK AROUND SELECT LIST +# +SELECT 1,,2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',2' at line 1 +SELECT ,,1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,1' at line 1 +SELECT ,,,; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,' at line 1 +# +# Removal of undocumented syntax, see bug#27389878. +# +CREATE DATABASE db CHARSET DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +CREATE DATABASE db COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +CREATE TABLE t (i INT) CHARSET DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +CREATE TABLE t (i INT) COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +ALTER DATABASE db CHARSET DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +ALTER DATABASE db COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +ALTER TABLE t COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +SET NAMES utf8 COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 1 +SET NAMES DEFAULT COLLATE DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLLATE DEFAULT' at line 1 +CREATE PROCEDURE p1() +BEGIN +DECLARE c CHAR(1) CHARSET DEFAULT; +END// +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 3 +CREATE PROCEDURE p1() +BEGIN +DECLARE c CHAR(1) COLLATE DEFAULT; +END// +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 3 +CREATE PROCEDURE p1(c CHAR(1) CHARSET DEFAULT) BEGIN END; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) BEGIN END' at line 1 +CREATE PROCEDURE p1(c CHAR(1) COLLATE DEFAULT) BEGIN END; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) BEGIN END' at line 1 +CREATE FUNCTION f1(c CHAR(1) CHARSET DEFAULT) RETURNS INT RETURN 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) RETURNS INT RETURN 1' at line 1 +CREATE FUNCTION f1(c CHAR(1) COLLATE DEFAULT) RETURNS INT RETURN 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT) RETURNS INT RETURN 1' at line 1 +CREATE FUNCTION f1() RETURNS CHAR(1) CHARSET DEFAULT RETURN ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT RETURN ''' at line 1 +CREATE FUNCTION f1() RETURNS CHAR(1) COLLATE DEFAULT RETURN ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT RETURN ''' at line 1 +# +# Bug#27814204: THE "ADMIN" WORD SHOULD BE A NON-RESERVED WORD IN THE +# SQL GRAMMAR +# +CREATE TEMPORARY TABLE admin (admin INT); +DROP TABLE admin; +# +# Bug#27760787: ERROR IN SQL SYNTAX WHEN USING "DEFAULT" KEYWORD IN +# ALTER TABLE COMMAND +SELECT @@default_collation_for_utf8mb4; +@@default_collation_for_utf8mb4 +utf8mb4_0900_ai_ci +######################################################################### +# +# 1. @@default_collation_for_utf8mb4 does not matter: +# +######################################################################### +CREATE DATABASE db1 CHARSET cp1251 COLLATE cp1251_general_ci; +USE db1; +CREATE TABLE t1 (i INT) CHARSET utf8mb4; +# +# Implicit COLLATE: +# +ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=cp1251 +# +# Explicit COLLATE: +# +ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT COLLATE cp1251_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COLLATE=cp1251_bin +DROP DATABASE db1; +######################################################################### +# +# 2. @@default_collation_for_utf8mb4 == utf8mb4_general_ci +# @@collation_database == utf8mb4_0900_ai_ci +# +######################################################################### +SET @@default_collation_for_utf8mb4 = utf8mb4_general_ci; +Warnings: +Warning 1681 Updating 'default_collation_for_utf8mb4' is deprecated. It will be made read-only in a future release. +CREATE DATABASE db2 COLLATE utf8mb4_0900_ai_ci; +USE db2; +CREATE TABLE t2 (i INT) CHARSET latin1; +# +# Implicit COLLATE result in utf8mb4_0900_ai_ci (@@collation_database): +# +ALTER TABLE t2 CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# Cleanup: +ALTER TABLE t2 CONVERT TO CHARACTER SET latin1; +# +# Explicit COLLATE should result in utf8mb4_bin: +# +ALTER TABLE t2 CONVERT TO CHARACTER SET DEFAULT COLLATE utf8mb4_bin; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +DROP DATABASE db2; +######################################################################### +# +# 3. @@default_collation_for_utf8mb4 == utf8mb4_0900_ai_ci +# @@collation_database == utf8mb4_general_ci +# +######################################################################### +SET @@default_collation_for_utf8mb4 = DEFAULT; +Warnings: +Warning 1681 Updating 'default_collation_for_utf8mb4' is deprecated. It will be made read-only in a future release. +SELECT @@default_collation_for_utf8mb4; +@@default_collation_for_utf8mb4 +utf8mb4_0900_ai_ci +CREATE DATABASE db3 COLLATE utf8mb4_general_ci; +USE db3; +CREATE TABLE t3 (i INT) CHARSET latin1; +# +# Implicit COLLATE should result in utf8mb4_general_ci (@@collation_database): +# +ALTER TABLE t3 CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci +# +# Explicit COLLATE should result in utf8mb4_bin: +# +ALTER TABLE t3 CONVERT TO CHARACTER SET DEFAULT COLLATE utf8mb4_bin; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +######################################################################### +# +# 4. Incompatible character set in @@character_set_database and COLLATE should fail: +# +######################################################################### +ALTER TABLE t3 CONVERT TO CHARACTER SET DEFAULT COLLATE cp1251_general_cs; +ERROR 42000: COLLATION 'cp1251_general_cs' is not valid for CHARACTER SET 'utf8mb4' +DROP DATABASE db3; +# Cleanup +USE test; + +Bug #27714748: @@PARSER_MAX_MEM_SIZE DOES NOT WORK FOR ROUTINES + +SET parser_max_mem_size = 10000000; +ERROR HY000: Memory capacity of 10000000 bytes for 'parser_max_mem_size' exceeded. Parser bailed out for this query. +SET parser_max_mem_size = default; +# +# Bug #28968848: SIMPLIFY MYSQL_YYABORT +# +CREATE PROCEDURE p1 () wrong syntax; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'syntax' at line 1 +# +# Bug #25220656: THE "PERSIST" EXTENSION IS A RESERVED KEYWORD +# +SELECT 1 AS PERSIST, 2 AS PERSIST_ONLY; +PERSIST PERSIST_ONLY +1 2 +CREATE ROLE EVENT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EVENT' at line 1 +CREATE ROLE FILE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FILE' at line 1 +CREATE ROLE NONE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NONE' at line 1 +CREATE ROLE PROCESS; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PROCESS' at line 1 +CREATE ROLE PROXY; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PROXY' at line 1 +CREATE ROLE RELOAD; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RELOAD' at line 1 +CREATE ROLE REPLICATION; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REPLICATION' at line 1 +CREATE ROLE RESOURCE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RESOURCE' at line 1 +CREATE ROLE SUPER; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUPER' at line 1 +SET GLOBAL = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET LOCAL = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET PERSIST = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET PERSIST_ONLY = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +SET SESSION = DEFAULT; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= DEFAULT' at line 1 +# +# Bug#29033659: SOME NON-RESERVED WORDS CAN'T BE USED AS SP LABELS +# +CREATE FUNCTION f1() RETURNS INT +BEGIN +ACCOUNT: LOOP RETURN 1; END LOOP; +ALWAYS: LOOP RETURN 1; END LOOP; +BACKUP: LOOP RETURN 1; END LOOP; +CLOSE: LOOP RETURN 1; END LOOP; +FORMAT: LOOP RETURN 1; END LOOP; +GROUP_REPLICATION: LOOP RETURN 1; END LOOP; +HOST: LOOP RETURN 1; END LOOP; +INVISIBLE: LOOP RETURN 1; END LOOP; +OPEN: LOOP RETURN 1; END LOOP; +OPTIONS: LOOP RETURN 1; END LOOP; +OWNER: LOOP RETURN 1; END LOOP; +PARSER: LOOP RETURN 1; END LOOP; +PORT: LOOP RETURN 1; END LOOP; +REMOVE: LOOP RETURN 1; END LOOP; +RESTORE: LOOP RETURN 1; END LOOP; +ROLE: LOOP RETURN 1; END LOOP; +SECONDARY: LOOP RETURN 1; END LOOP; +SECONDARY_ENGINE: LOOP RETURN 1; END LOOP; +SECONDARY_LOAD: LOOP RETURN 1; END LOOP; +SECONDARY_UNLOAD: LOOP RETURN 1; END LOOP; +SECURITY: LOOP RETURN 1; END LOOP; +SERVER: LOOP RETURN 1; END LOOP; +SOCKET: LOOP RETURN 1; END LOOP; +SONAME: LOOP RETURN 1; END LOOP; +UPGRADE: LOOP RETURN 1; END LOOP; +VISIBLE: LOOP RETURN 1; END LOOP; +WRAPPER: LOOP RETURN 1; END LOOP; +END| +DROP FUNCTION f1; +# +# Bug#29205289: PARSER ACCEPTS UNDOCUMENTED SYNTAX: `... = TABLE_ALIAS` +# +CREATE TABLE t1 (i INT); +LOCK TABLES t1=a READ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a READ' at line 1 +HANDLER t1 OPEN=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +SELECT * FROM t1=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +SELECT * FROM (SELECT 1)=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +SELECT * FROM t1 JOIN t1=a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a' at line 1 +UPDATE t1=a SET i=0; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=a SET i=0' at line 1 +DROP TABLE t1; +# +# Bug #22320942: ODBC OUTER JOIN ESCAPE SEQUENCE SYNTAX IS BROKEN +# +CREATE TEMPORARY TABLE t1 (i INT); +CREATE TEMPORARY TABLE t2 (i INT); +SELECT * FROM { OJ t1 LEFT JOIN t2 ON TRUE }; +i i +SELECT * FROM { `OJ` t1 LEFT JOIN t2 ON TRUE }; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`OJ` t1 LEFT JOIN t2 ON TRUE }' at line 1 +SELECT * FROM { random_identifier t1 LEFT JOIN t2 ON TRUE }; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'random_identifier t1 LEFT JOIN t2 ON TRUE }' at line 1 +DROP TABLE t1, t2; +# +# Bug #28997518: "COLLATE X GENERATED ALWAYS ... COLLATE Y": X HAS +# A PRIORITY OVER Y +# +CREATE TABLE t1 ( +x VARCHAR(10) +COLLATE ascii_bin +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_bin +)' at line 4 +CREATE TABLE t2 ( +x VARCHAR(10) +COLLATE ascii_bin +COLLATE ascii_general_ci +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_general_ci +)' at line 4 +CREATE TABLE t3 ( +x VARCHAR(10) +COLLATE ascii_bin +NOT NULL +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_bin +)' at line 5 +CREATE TABLE t3 ( +x VARCHAR(10) +COLLATE ascii_bin +GENERATED ALWAYS AS(NULL) +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'COLLATE ascii_bin +GENERATED ALWAYS AS(NULL) +COLLATE ascii_bin +)' at line 3 +CREATE TABLE t4 ( +x VARCHAR(10) +GENERATED ALWAYS AS(NULL) +COLLATE ascii_bin +COLLATE ascii_bin +); +ERROR 42000: Multiple COLLATE clauses near 'ascii_bin +)' at line 5 +# +# Bug#28961997: REMOVE PARENTHESES INFORMATION FROM AST +# +CREATE VIEW v1 AS (SELECT 1 ORDER BY 1) UNION (SELECT 3 ORDER BY 1) ORDER BY 1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` union select 3 AS `3` order by `1` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +# +# Bug#29871803: REQUIRED PARENTHESES NO LONGER PRINTED FOR CERTAIN UNION +# STATEMENTS +# +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER); +CREATE TABLE t3(a INTEGER, b INTEGER, c INTEGER); +INSERT INTO t3 VALUES(1, 10, 100), (2, 20, 200), (3, 30, 300), (4, 40, 400); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN (SELECT a FROM t1 ORDER BY a LIMIT 1) UNION SELECT a FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using filesort +2 UNION t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 (/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 1) union /* select#2 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +EXPLAIN SELECT a FROM t1 UNION (SELECT a FROM t2 LIMIT 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 UNION t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union (/* select#2 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` limit 1) +CREATE VIEW v1 as (SELECT a FROM t1 ORDER BY a LIMIT 1) UNION SELECT a FROM t2; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `t1`.`a` AS `a` from `t1` order by `t1`.`a` limit 1) union select `t2`.`a` AS `a` from `t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v2 as SELECT a FROM t1 UNION (SELECT a FROM t2 ORDER BY a LIMIT 1); +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a` from `t1` union (select `t2`.`a` AS `a` from `t2` order by `t2`.`a` limit 1) utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN (SELECT * FROM t3 ORDER BY a LIMIT 3) ORDER BY b DESC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 1003 (/* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` order by `test`.`t3`.`a` limit 3) order by `b` desc limit 2 +EXPLAIN ((SELECT * FROM t3 ORDER BY a LIMIT 3) +ORDER BY b DESC LIMIT 2) +ORDER BY c LIMIT 1; +ERROR 42000: This version of MySQL doesn't yet support 'parenthesized query expression with more than one external level of ORDER/LIMIT operations' +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t1, t2, t3; +# +# Bug#30131161: SYNTAX ERROR WITH || WHEN USING PIPES_AS_CONCAT AFTER +# UPGRADING TO 8.0.17 +# +SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT')); +SELECT 'ab' LIKE 'a%', 'ab' LIKE 'a' || '%'; +'ab' LIKE 'a%' 'ab' LIKE 'a' || '%' +1 1 +SELECT 'ab' NOT LIKE 'a%', 'ab' NOT LIKE 'a' || '%'; +'ab' NOT LIKE 'a%' 'ab' NOT LIKE 'a' || '%' +0 0 +SELECT 'ab' LIKE 'ac', 'ab' LIKE 'a' || 'c'; +'ab' LIKE 'ac' 'ab' LIKE 'a' || 'c' +0 0 +SELECT 'ab' NOT LIKE 'ac', 'ab' NOT LIKE 'a' || 'c'; +'ab' NOT LIKE 'ac' 'ab' NOT LIKE 'a' || 'c' +1 1 +SELECT 'a%' LIKE 'a!%' ESCAPE '!', 'a%' LIKE 'a!' || '%' ESCAPE '!'; +'a%' LIKE 'a!%' ESCAPE '!' 'a%' LIKE 'a!' || '%' ESCAPE '!' +1 1 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '!', 'a%' NOT LIKE 'a!' || '%' ESCAPE '!'; +'a%' NOT LIKE 'a!%' ESCAPE '!' 'a%' NOT LIKE 'a!' || '%' ESCAPE '!' +0 0 +SELECT 'a%' LIKE 'a!%' ESCAPE '$', 'a%' LIKE 'a!' || '%' ESCAPE '$'; +'a%' LIKE 'a!%' ESCAPE '$' 'a%' LIKE 'a!' || '%' ESCAPE '$' +0 0 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '$', 'a%' NOT LIKE 'a!' || '%' ESCAPE '$'; +'a%' NOT LIKE 'a!%' ESCAPE '$' 'a%' NOT LIKE 'a!' || '%' ESCAPE '$' +1 1 +SELECT 'a%' LIKE 'a!%' ESCAPE '!', 'a%' LIKE 'a!%' ESCAPE '' || '!'; +'a%' LIKE 'a!%' ESCAPE '!' 'a%' LIKE 'a!%' ESCAPE '' || '!' +1 1 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '!', 'a%' NOT LIKE 'a!%' ESCAPE '' || '!'; +'a%' NOT LIKE 'a!%' ESCAPE '!' 'a%' NOT LIKE 'a!%' ESCAPE '' || '!' +0 0 +SELECT 'a%' LIKE 'a!%' ESCAPE '' || '$', 'a%' LIKE 'a!%' ESCAPE '' || '$'; +'a%' LIKE 'a!%' ESCAPE '' || '$' 'a%' LIKE 'a!%' ESCAPE '' || '$' +0 0 +SELECT 'a%' NOT LIKE 'a!%' ESCAPE '' || '$', 'a%' NOT LIKE 'a!%' ESCAPE '' || '$'; +'a%' NOT LIKE 'a!%' ESCAPE '' || '$' 'a%' NOT LIKE 'a!%' ESCAPE '' || '$' +1 1 +SELECT 1 ^ 100, 1 ^ '10' || '0'; +1 ^ 100 1 ^ '10' || '0' +101 101 +SELECT -1 || '0'; +-1 || '0' +-10 +SET sql_mode=DEFAULT; +# +# WL#13559: Deprecate syntax: confusing combinations of UNION and INTO +# +# +# No warning expected: +# +SELECT 1 UNION SELECT 1 INTO @var; +(SELECT 1 UNION SELECT 1 INTO @var); +SELECT 1 UNION SELECT 1 FROM DUAL INTO @var; +(SELECT 1 UNION SELECT 1 FROM DUAL INTO @var); +SELECT 1 UNION SELECT 1 FROM DUAL FOR UPDATE INTO @var; +(SELECT 1 UNION SELECT 1 FROM DUAL FOR UPDATE INTO @var); +# +# Deprecation warning expected: +# +SELECT 1 UNION SELECT 1 INTO @var FROM DUAL; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION (SELECT 1 INTO @var FROM DUAL); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION SELECT 1 FROM DUAL INTO @var FOR UPDATE; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1 UNION SELECT 1 FROM DUAL INTO @var FOR UPDATE); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +SELECT 1 UNION SELECT 1 INTO @var FOR UPDATE; +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +(SELECT 1 UNION SELECT 1 INTO @var FOR UPDATE); +Warnings: +Warning 3962 The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead. +# +# Syntax error expected: +# +SELECT 1 UNION (SELECT 1 FROM DUAL INTO @var); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var)' at line 1 +# +# Bug#30871301: CTE CAN FAIL WITH A PARSE ERROR ON PSEUDO-COMMENTS +# +WITH cte AS (SELECT 0 /*! ) */ SELECT * FROM cte a, cte b; +0 0 +0 0 +WITH cte AS /*! ( */ SELECT 0) SELECT * FROM cte a, cte b; +0 0 +0 0 +# +# Bug#30528450: SPECIAL SYMBOL NAMED COLUMN NOT HONORED IN A SELECT +# +CREATE TABLE t1 (c1 INT, `*` INT, c3 INT); +INSERT INTO t1 VALUES (1, 2, 3); +SELECT `*` FROM t1; +* +2 +SELECT t1.`*`, t1.* FROM t1; +* c1 * c3 +2 1 2 3 +SELECT test.t1.`*`, test.t1.* FROM t1; +* c1 * c3 +2 1 2 3 +DROP TABLE t1; +# +# Bug#30592703: UNDOCUMENTED SYNTAX +# '('')' {LIMIT|ORDER [LIMIT]} INTO ... +# +(SELECT 1) LIMIT 1 INTO @var; +SELECT @var; +@var +1 +(SELECT 2 AS c) ORDER BY c INTO @var; +SELECT @var; +@var +2 +(SELECT 3 AS c) ORDER BY c LIMIT 1 INTO @var; +SELECT @var; +@var +3 +(SELECT 4) INTO @var; +SELECT @var; +@var +4 +# +# ) + optimizer uses index meets loss of the index +create table t1 (a int, b int, primary key(b),unique index t1_unq_idx(a)); +insert into t1 set a = 0, b = 0; +insert into t1 select a + 1, b + 1 from t1; +insert into t1 select a + 2, b + 2 from t1; +insert into t1 select a + 4, b + 4 from t1; +insert into t1 select a + 8, b + 8 from t1; +# Optimizer strategy: Possible keys = NULL , Extra = Parallel execute (1 workers) +prepare stmt from "select avg(a) from t1"; +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +alter table t1 drop index t1_unq_idx; +# Optimizer strategy: Possible keys = NULL , Extra = Parallel execute (1 workers) +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(1); +SUCCESS + +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +# select AVG() + optimizer uses table scan meets a new index +alter table t1 add unique index t1_unq_idx(a); +# Optimizer strategy: Possible keys = NULL , Extra = Parallel execute (1 workers) +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(1); +SUCCESS + +execute stmt; +avg(a) +7.5000 +call p_verify_reprepare_count(0); +SUCCESS + +deallocate prepare stmt; +drop table t1; +# table replaced by not updatable view - Insert +create table t1 (a int); +prepare stmt from "insert into t1 values(1)"; +execute stmt; +call p_verify_reprepare_count(0); +SUCCESS + +drop table t1; +create view t1 as select 1; +execute stmt; +ERROR HY000: The target table t1 of the INSERT is not insertable-into +call p_verify_reprepare_count(1); +SUCCESS + +drop view t1; +create table t2 (a int); +create view t1 as select * from t2 with check option; +execute stmt; +call p_verify_reprepare_count(1); +SUCCESS + +execute stmt; +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +1 +deallocate prepare stmt; +drop view t1; +drop table t2; +===================================================================== +Some freestyle tests +===================================================================== +create temporary table t1 as select 1 as a; +create procedure p1() +begin +drop temporary table t1; +end| +create function f1() returns int +begin +call p1(); +return 1; +end| +prepare stmt from "select f1() as my_column, a from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +prepare stmt from "select a, f1() as my_column from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +prepare stmt from "select f1() as my_column, count(*) from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +prepare stmt from "select count(*), f1() as my_column from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +# Execute fails, no drop of temporary table +prepare stmt from "select 1 as my_column from (select 1) as t2 + where exists (select f1() from t1)"; +execute stmt; +my_column +1 +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +my_column +1 +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +# Execute drops temporary table +prepare stmt from "select f1()"; +execute stmt; +f1() +1 +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +ERROR 42S02: Unknown table 'test.t1' +call p_verify_reprepare_count(0); +SUCCESS + +drop function f1; +drop procedure p1; +deallocate prepare stmt; +# Execute fails, temporary table is not replaced by another +create temporary table t1 as select 1 as a; +create procedure p1() +begin +drop temporary table t1; +create temporary table t1 as select 'abc' as a; +end| +create function f1() returns int +begin +call p1(); +return 1; +end| +prepare stmt from "select count(*), f1() as my_column from t1"; +execute stmt; +ERROR HY000: Can't reopen table: 't1' +call p_verify_reprepare_count(0); +SUCCESS + +select * from t1; +a +1 +deallocate prepare stmt; +prepare stmt from "call p1"; +execute stmt; +drop procedure p1; +create schema mysqltest; +create procedure mysqltest.p1() +begin +drop schema mysqltest; +create schema mysqltest; +end| +execute stmt; +ERROR 42000: PROCEDURE test.p1 does not exist +call p_verify_reprepare_count(0); +SUCCESS + +execute stmt; +ERROR 42000: PROCEDURE test.p1 does not exist +call p_verify_reprepare_count(0); +SUCCESS + +deallocate prepare stmt; +drop schema mysqltest; +drop temporary table t1; +# Cleanup +# +drop temporary table if exists t1; +drop table if exists t1, t2; +drop procedure if exists p_verify_reprepare_count; +drop procedure if exists p1; +drop function if exists f1; +drop view if exists t1; +drop schema if exists mysqltest; diff --git a/mysql-test/r/range_all.result-pq b/mysql-test/r/range_all.result-pq new file mode 100644 index 000000000..7a032d136 --- /dev/null +++ b/mysql-test/r/range_all.result-pq @@ -0,0 +1,3997 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2, t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +event_date date DEFAULT '0000-00-00' NOT NULL, +type int(11) DEFAULT '0' NOT NULL, +event_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (event_date,type,event_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25), +('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26), +('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45), +('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5), +('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17), +('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40), +('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6), +('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41), +('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41), +('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29), +('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19), +('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42), +('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30), +('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8), +('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22), +('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43), +('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37), +('1999-09-19',100100,37), ('2000-12-18',100700,38); +explain select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 19.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 7 NULL 6 19.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where ((`test`.`t1`.`event_date` >= DATE'1999-07-01') and (`test`.`t1`.`event_date` < DATE'1999-07-15') and ((`test`.`t1`.`type` = 100600) or (`test`.`t1`.`type` = 100100))) order by `test`.`t1`.`event_date` +explain format=tree select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +EXPLAIN +-> Parallel scan on + -> Filter: ((t1.event_date >= DATE'1999-07-01') and (t1.event_date < DATE'1999-07-15') and ((t1.`type` = 100600) or (t1.`type` = 100100))) (cost=1.46 rows=1) + -> PQblock range scan on t1 using PRIMARY (cost=1.46 rows=6) + +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where false order by `test`.`t1`.`event_date` +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +1999-07-15 100600 16 +drop table t1; +CREATE TABLE t1 ( +PAPER_ID smallint(6) DEFAULT '0' NOT NULL, +YEAR smallint(6) DEFAULT '0' NOT NULL, +ISSUE smallint(6) DEFAULT '0' NOT NULL, +CLOSED tinyint(4) DEFAULT '0' NOT NULL, +ISS_DATE date DEFAULT '0000-00-00' NOT NULL, +PRIMARY KEY (PAPER_ID,YEAR,ISSUE) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'), +(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'), +(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'), +(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'), +(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'), +(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'), +(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'), +(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'), +(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'), +(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'), +(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'), +(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'), +(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'), +(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'), +(3,1999,35,0,'1999-07-12'); +select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE; +YEAR ISSUE +1999 29 +1999 30 +1999 31 +1999 32 +1999 33 +1999 34 +1999 35 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair note The storage engine for the table doesn't support repair +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2), +(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2), +(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1), +(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2), +(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2), +(19,3,2), (5,1,1), (179,5,2); +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +drop table t1; +create table t1( +Satellite varchar(25) not null, +SensorMode varchar(25) not null, +FullImageCornersUpperLeftLongitude double not null, +FullImageCornersUpperRightLongitude double not null, +FullImageCornersUpperRightLatitude double not null, +FullImageCornersLowerRightLatitude double not null, +index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude)); +insert into t1 values("OV-3","PAN1",91,-92,40,50); +insert into t1 values("OV-4","PAN1",91,-92,40,50); +select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000; +Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude +OV-3 PAN1 91 -92 40 50 +drop table t1; +create table t1 ( aString char(100) not null default "", key aString (aString(10)) ); +insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love"); +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +alter table t1 drop key aString; +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +drop table t1; +CREATE TABLE t1 ( +t1ID int(10) unsigned NOT NULL auto_increment, +art binary(1) NOT NULL default '', +KNR char(5) NOT NULL default '', +RECHNR char(6) NOT NULL default '', +POSNR char(2) NOT NULL default '', +ARTNR char(10) NOT NULL default '', +TEX char(70) NOT NULL default '', +PRIMARY KEY (t1ID), +KEY IdxArt (art), +KEY IdxKnr (KNR), +KEY IdxArtnr (ARTNR) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'); +select count(*) from t1 where upper(art) = 'J'; +count(*) +213 +select count(*) from t1 where art = 'J' or art = 'j'; +count(*) +602 +select count(*) from t1 where art = 'j' or art = 'J'; +count(*) +602 +select count(*) from t1 where art = 'j'; +count(*) +389 +select count(*) from t1 where art = 'J'; +count(*) +213 +drop table t1; +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` between 7 and ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` >= 7) and (`test`.`t2`.`x` <= ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between ((2 - 1)) and ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= ((2 - 1))) and (`test`.`t2`.`x` <= ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between 0 and 2)) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= 0) and (`test`.`t2`.`x` <= 2)) +explain select count(*) from t1 where x in (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` = 1) +explain select count(*) from t1 where x in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` in (1,2)) +drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +explain select * from t1 force index(i1), t2 force index(j1) where +(t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` FORCE INDEX (`i1`) join `test`.`t2` FORCE INDEX (`j1`) where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a), +KEY b (b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), +(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), +(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), +(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a,b a 5 NULL 2 40.54 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` in (1,2))) +SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +a b +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) +); +a b +15 1 +47 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id int( 11 ) unsigned NOT NULL AUTO_INCREMENT , +line int( 5 ) unsigned NOT NULL default '0', +columnid int( 3 ) unsigned NOT NULL default '0', +owner int( 3 ) unsigned NOT NULL default '0', +ordinal int( 3 ) unsigned NOT NULL default '0', +showid smallint( 6 ) unsigned NOT NULL default '1', +tableid int( 1 ) unsigned NOT NULL default '1', +content int( 5 ) unsigned NOT NULL default '188', +PRIMARY KEY ( owner, id ) , +KEY menu( owner, showid, columnid ) , +KEY `COLUMN` ( owner, columnid, line ) , +KEY `LINES` ( owner, tableid, content, id ) , +KEY recount( owner, line ) +) ENGINE = MYISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); +SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; +id columnid tableid content showid line ordinal +13 13 1 188 1 5 0 +15 15 1 188 1 1 0 +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select id from t1 where id in (2,5,9) ; +id +2 +5 +9 +select id from t1 where id=2 or id=5 or id=9 ; +id +2 +5 +9 +drop table t1; +create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2)); +insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), +(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"), +(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"), +(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"), +(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"), +(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"), +(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa"); +select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; +id1 idnull +drop table t1; +create table t1 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +create table t2 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +insert into t1(id, uid, name) values(1, 0, ' '); +insert into t1(uid, name) values(0, ' '); +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +delete from t2; +insert into t2(uid, name) values +(1, CHAR(64+1)), +(2, CHAR(64+2)), +(3, CHAR(64+3)), +(4, CHAR(64+4)), +(5, CHAR(64+5)), +(6, CHAR(64+6)), +(7, CHAR(64+7)), +(8, CHAR(64+8)), +(9, CHAR(64+9)), +(10, CHAR(64+10)), +(11, CHAR(64+11)), +(12, CHAR(64+12)), +(13, CHAR(64+13)), +(14, CHAR(64+14)), +(15, CHAR(64+15)), +(16, CHAR(64+16)), +(17, CHAR(64+17)), +(18, CHAR(64+18)), +(19, CHAR(64+19)), +(20, CHAR(64+20)), +(21, CHAR(64+21)), +(22, CHAR(64+22)), +(23, CHAR(64+23)), +(24, CHAR(64+24)), +(25, CHAR(64+25)), +(26, CHAR(64+26)); +insert into t1(uid, name) select uid, name from t2 order by uid; +delete from t2; +insert into t2(id, uid, name) select id, uid, name from t1; +select count(*) from t1; +count(*) +1026 +select count(*) from t2; +count(*) +1026 +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +drop table t1,t2; +create table t1 (x bigint unsigned not null); +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +create table t2 (x bigint not null); +insert into t2(x) values (-16); +insert into t2(x) values (-15); +select * from t2; +x +-16 +-15 +select count(*) from t2 where x>0; +count(*) +0 +select count(*) from t2 where x=0; +count(*) +0 +select count(*) from t2 where x<0; +count(*) +2 +select count(*) from t2 where x < -16; +count(*) +0 +select count(*) from t2 where x = -16; +count(*) +1 +select count(*) from t2 where x > -16; +count(*) +1 +select count(*) from t2 where x = 18446744073709551601; +count(*) +0 +drop table t1,t2; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +create table t1 (a bigint unsigned); +create index t1i on t1(a); +insert into t1 select 18446744073709551615; +insert into t1 select 18446744073709551614; +explain select * from t1 where a <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a <> -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1 or a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1 or a < -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where a < -1; +a +drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 11 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 'aaa') +explain select * from t1 where a=binary 'aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using index condition; Using MRR +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (cast('aaa' as char charset binary))) +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using index condition; Using MRR +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_bin))) +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 9 11.11 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_german1_ci))) +drop table t1; +CREATE TABLE t1 ( +`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', +`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTINT` int(11) NOT NULL default '0', +KEY `VERI_CLNT~2` (`ARG1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0), +('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0), +('001',' 3',' 0','Text 017',0); +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2'); +count(*) +4 +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1'); +count(*) +4 +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( +pk1 int(11) NOT NULL, +pk2 int(11) NOT NULL, +pk3 int(11) NOT NULL, +pk4 int(11) NOT NULL, +filler char(82), +PRIMARY KEY (pk1,pk2,pk3,pk4) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B; +INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'), +(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'), +(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler'); +SELECT * FROM t2 +WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635))) +OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635)))) +) AND (pk3 >=1000000); +pk1 pk2 pk3 pk4 filler +2621 2635 1000015 0 filler +drop table t1, t2; +create table t1(a char(2), key(a(1))) charset utf8mb4; +insert into t1 values ('x'), ('xx'); +explain select a from t1 where a > 'x'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'x') +select a from t1 where a > 'x'; +a +xx +drop table t1; +CREATE TABLE t1 ( +OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid', +OXLEFT int NOT NULL DEFAULT '0', +OXRIGHT int NOT NULL DEFAULT '0', +OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +PRIMARY KEY (OXID), +KEY OXNID (OXID), +KEY OXLEFT (OXLEFT), +KEY OXRIGHT (OXRIGHT), +KEY OXROOTID (OXROOTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'), +('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725521'); +EXPLAIN +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE v NULL ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 100.00 NULL +1 SIMPLE s NULL ref OXLEFT,OXROOTID OXROOTID 34 const 5 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`OXID` AS `oxid` from `test`.`t1` `v` join `test`.`t1` `s` where ((`test`.`s`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`v`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`s`.`OXLEFT` > `test`.`v`.`OXLEFT`) and (`test`.`s`.`OXLEFT` < `test`.`v`.`OXRIGHT`)) +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +oxid +d8c4177d151affab2.81582770 +d8c4177d206a333d2.74422679 +d8c4177d225791924.30714720 +d8c4177d2380fc201.39666693 +d8c4177d24ccef970.14957924 +DROP TABLE t1; +create table t1 ( +c1 char(10), c2 char(10), c3 char(10), c4 char(10), +c5 char(10), c6 char(10), c7 char(10), c8 char(10), +c9 char(10), c10 char(10), c11 char(10), c12 char(10), +c13 char(10), c14 char(10), c15 char(10), c16 char(10), +index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); +select * from t1 where +c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 +Warnings: +Warning 3170 Memory capacity of 8388608 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +drop table t1; +End of 4.1 tests +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +status varchar(20), +PRIMARY KEY (id), +KEY (status) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'), +(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'), +(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'), +(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'), +(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'), +(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'), +(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'), +(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'), +(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'), +(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C'); +EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not between 'A' and 'B') +EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` < 'A') or (`test`.`t1`.`status` > 'B')) +SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, primary key(a,b)); +INSERT INTO t1 VALUES +(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3); +CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3; +EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +SELECT a,b FROM t1 WHERE a < 2 and b=3; +a b +1 3 +SELECT a,b FROM v1 WHERE a < 2 and b=3; +a b +1 3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name)); +INSERT INTO t1 VALUES ('Betty'), ('Anna'); +SELECT * FROM t1; +name +Anna +Betty +DELETE FROM t1 WHERE name NOT LIKE 'A%a'; +SELECT * FROM t1; +name +Anna +DROP TABLE t1; +CREATE TABLE t1 (a int, KEY idx(a)); +INSERT INTO t1 VALUES (NULL), (1), (2), (3); +SELECT * FROM t1; +a +NULL +1 +2 +3 +DELETE FROM t1 WHERE NOT(a <=> 2); +SELECT * FROM t1; +a +2 +DROP TABLE t1; +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); +explain select * from t1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from v1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +explain select * from v1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +drop view v1; +drop table t1; +create table t3 (a int); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a varchar(10), filler char(200), key(a)) charset=binary; +insert into t1 values ('a',''); +insert into t1 values ('a ',''); +insert into t1 values ('a ', ''); +insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), '' + from t3 A, t3 B, t3 C; +create table t2 (a varchar(10), filler char(200), key(a)) charset utf8mb4; +insert into t2 select * from t1; +explain select * from t1 where a between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` between 'a' and 'a ') +explain select * from t1 where a = 'a' or a='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') or (`test`.`t1`.`a` = 'a ')) +explain select * from t2 where a between 'a' and 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` between 'a' and 'A') +explain select * from t2 where a = 'a' or a='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') or (`test`.`t2`.`a` = 'A')) +update t1 set a='b' where a<>'a'; +explain select * from t1 where a not between 'b' and 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` not between 'b' and 'b') +select a, hex(filler) from t1 where a not between 'b' and 'b'; +a hex(filler) +a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +drop table t1,t2,t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, key(a)); +insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C; +set @a="select * from t2 force index (a) where a NOT IN(0"; +select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z; +count(*) +1000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @a=concat(@a, ')'); +insert into t2 values (11),(13),(15); +set @b= concat("explain ", @a); +prepare stmt1 from @b; +execute stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1003 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,604,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,784,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1146,1148,1150,1152,1154,1156,1158,1160,1162,1164,1166,1168,1170,1172,1174,1176,1178,1180,1182,1184,1186,1188,1190,1192,1194,1196,1198,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222,1224,1226,1228,1230,1232,1234,1236,1238,1240,1242,1244,1246,1248,1250,1252,1254,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292,1294,1296,1298,1300,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1370,1372,1374,1376,1378,1380,1382,1384,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408,1410,1412,1414,1416,1418,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458,1460,1462,1464,1466,1468,1470,1472,1474,1476,1478,1480,1482,1484,1486,1488,1490,1492,1494,1496,1498,1500,1502,1504,1506,1508,1510,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1552,1554,1556,1558,1560,1562,1564,1566,1568,1570,1572,1574,1576,1578,1580,1582,1584,1586,1588,1590,1592,1594,1596,1598,1600,1602,1604,1606,1608,1610,1612,1614,1616,1618,1620,1622,1624,1626,1628,1630,1632,1634,1636,1638,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678,1680,1682,1684,1686,1688,1690,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1714,1716,1718,1720,1722,1724,1726,1728,1730,1732,1734,1736,1738,1740,1742,1744,1746,1748,1750,1752,1754,1756,1758,1760,1762,1764,1766,1768,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790,1792,1794,1796,1798,1800,1802,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822,1824,1826,1828,1830,1832,1834,1836,1838,1840,1842,1844,1846,1848,1850,1852,1854,1856,1858,1860,1862,1864,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1886,1888,1890,1892,1894,1896,1898,1900,1902,1904,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1964,1966,1968,1970,1972,1974,1976,1978,1980,1982,1984,1986,1988,1990,1992,1994,1996,1998)) +prepare stmt1 from @a; +execute stmt1; +a +11 +13 +15 +drop table t1, t2; +CREATE TABLE t1 ( +id int NOT NULL DEFAULT '0', +b int NOT NULL DEFAULT '0', +c int NOT NULL DEFAULT '0', +INDEX idx1(b,c), INDEX idx2(c)); +INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(b,c) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` <= 3) and (3 <= `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (3 between `test`.`t1`.`b` and `test`.`t1`.`c`) +SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((0 < `test`.`t1`.`b`) or (0 > `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (0 not between `test`.`t1`.`b` and `test`.`t1`.`c`) +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +EXPLAIN +-> Filter: (0 not between t1.b and t1.c) (cost=2.15 rows=3) + -> Index range scan on t1 using sort_union(idx1,idx2) (cost=2.15 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( +item char(20) NOT NULL default '', +started datetime NOT NULL default '0000-00-00 00:00:00', +price decimal(16,3) NOT NULL default '0.000', +PRIMARY KEY (item,started) +) ENGINE=MyISAM, CHARSET utf8mb4; +INSERT INTO t1 VALUES +('A1','2005-11-01 08:00:00',1000), +('A1','2005-11-15 00:00:00',2000), +('A1','2005-12-12 08:00:00',3000), +('A2','2005-12-01 08:00:00',1000); +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP INDEX `PRIMARY` ON t1; +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP TABLE t1; + +BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly" + +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +dateval date default NULL, +PRIMARY KEY (id), +KEY dateval (dateval) +) AUTO_INCREMENT=173; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'), +(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'), +(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11'); +This must use range access: +explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range dateval dateval 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`dateval` AS `dateval` from `test`.`t1` where ((`test`.`t1`.`dateval` >= DATE'2007-01-01') and (`test`.`t1`.`dateval` <= DATE'2007-01-02')) +drop table t1; +CREATE TABLE t1 ( +a varchar(32), index (a) +) DEFAULT CHARSET=latin1 COLLATE=latin1_bin; +INSERT INTO t1 VALUES +('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'); +SELECT a FROM t1 WHERE a='b' OR a='B'; +a +B +B +EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 35 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'b') or (`test`.`t1`.`a` = 'B')) +DROP TABLE t1; +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); +SELECT COUNT(*) FROM t1 WHERE f1 < 256; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 256.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 255; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 < -1; +COUNT(*) +0 +SELECT COUNT(*) FROM t1 WHERE f1 > -1; +COUNT(*) +5 +DROP TABLE t1; +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); +SELECT COUNT(*) FROM t1 WHERE f1 < 128; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 128.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 127; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 > -129; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -129.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -128; +COUNT(*) +4 +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100)); +insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, +t1 B, t1 C where A.a < 5; +insert into t2 select 1000, b, 'filler' from t2; +alter table t2 add index (a,b); +Access method can be range/ALL with #rows >= 500. +Or it can be ref with #rows = 2, only when there is memory limit. +explain select * from t2 where a=1000 and b<11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 500 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range a a 10 NULL 500 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 1000) and (`test`.`t2`.`b` < 11)) +drop table t1, t2; +CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t3( a INT, b INT, KEY( a, b ) ); +INSERT INTO t1( a, b ) +VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7); +INSERT INTO t2( a, b ) +VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1), +( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1), +(11, 1), (12, 1), (13, 1), (14, 1), (15, 1), +(16, 1), (17, 1), (18, 1), (19, 1), (20, 1); +INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t3 +VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), +(6, 0), (7, 0), (8, 0), (9, 0), (10, 0); +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 < `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 1) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +5 2 +6 1 +6 2 +7 1 +7 2 +8 1 +8 2 +9 1 +9 2 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 2) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +a b +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +EXPLAIN +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`b` = 3) and (5 <= `test`.`t3`.`a`) and (`test`.`t3`.`a` < 10)) or (`test`.`t3`.`a` < 5) or (`test`.`t3`.`a` < 10)) +DROP TABLE t1, t2, t3; +# +# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL); +a +DROP TABLE t1; +# +# Bug#47925: regression of range optimizer and date comparison in 5.1.39! +# +CREATE TABLE t1 ( a DATE, KEY ( a ) ); +CREATE TABLE t2 ( a DATETIME, KEY ( a ) ); +# Make optimizer choose range scan +INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22'); +INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23'); +INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'), +('2009-09-22 12:00:00'); +INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'), +('2009-09-23 12:00:00'); +# DATE vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# DATE vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923120000'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923120000; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923000000'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923000000; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# Test of the new get_date_from_str implementation +# Behavior differs slightly between the trunk and mysql-pe. +# The former may give errors for the truncated values, while the latter +# gives warnings. The purpose of this test is not to interfere, and only +# preserve existing behavior. +# This case was made obsolete after the changes applied by +# Bug#28940878 WRONG RESULT WHEN COMPARING DATE[TIME] WITH STRING +# as we don't fallback anymore to string comparison if the date is invalid. +SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND +str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND +str_to_date('2007-20-00', '%Y-%m-%d') <= ''; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; +str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''; +str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +SELECT str_to_date('', '%Y-%m-%d'); +str_to_date('', '%Y-%m-%d') +0000-00-00 +DROP TABLE t1, t2; +# +# Bug#48459: valgrind errors with query using 'Range checked for each +# record' +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY ( c ), +KEY ( d, a, b ( 2 ) ), +KEY ( b ( 1 ) ) +); +INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ), +( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 ); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY ( e ) +); +INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL ); +# Should not give Valgrind warnings +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug #48665: sql-bench's insert test fails due to wrong result +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (0,0), (1,1); +EXPLAIN +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +@ @ @ NULL ALL @ @ @ @ @ 100.00 @ +@ @ @ NULL range @ @ @ @ @ 100.00 @ +Warnings: +@ @ @ +# Should return 2 rows +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +a b +0 0 +1 1 +DROP TABLE t1; +# +# Bug #54802: 'NOT BETWEEN' evaluation is incorrect +# +CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key)); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c_key NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_key` AS `c_key`,`test`.`t1`.`c_notkey` AS `c_notkey` from `test`.`t1` where (2 not between `test`.`t1`.`c_notkey` and `test`.`t1`.`c_key`) +SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +c_key c_notkey +1 1 +3 3 +DROP TABLE t1; +# +# Bug #57030: 'BETWEEN' evaluation is incorrect +# +CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT); +CREATE UNIQUE INDEX i4_uq ON t1(i4); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30); +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between 10 and `test`.`t1`.`i4`) +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between `test`.`t1`.`i4` and 10) +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i4_uq 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 100 and 0) +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and 99999999999999999) +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 999999999999999 and 30) +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and '20') +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +pk i4 +1 10 +2 20 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`) +EXPLAIN FORMAT=tree +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.60 rows=3) + -> Filter: (t1.i4 is not null) (cost=0.55 rows=3) + -> PQblock scan on t1 using i4_uq (cost=0.55 rows=3) + -> Filter: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.i4) (cost=0.28 rows=1) + +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +pk i4 pk i4 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`) +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +pk i4 pk i4 +DROP TABLE t1; +# +# BUG#13519696 - 62940: SELECT RESULTS VARY WITH VERSION AND +# WITH/WITHOUT INDEX RANGE SCAN +# +create table t1 (id int unsigned not null auto_increment primary key); +insert into t1 values (null); +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +create table t2 ( +id int unsigned not null auto_increment, +val decimal(5,3) not null, +primary key (id,val), +unique key (val,id), +unique key (id)); +insert into t2 select null,id*0.0009 from t1; +select count(val) from t2 ignore index (val) where val > 0.1155; +count(val) +185 +select count(val) from t2 force index (val) where val > 0.1155; +count(val) +185 +drop table t2, t1; +# +# BUG#13453382 - REGRESSION SINCE 5.1.39, RANGE OPTIMIZER WRONG +# RESULTS WITH DECIMAL CONVERSION +# +create table t1 (a int,b int,c int,primary key (a,c)); +insert into t1 values (1,1,2),(1,1,3),(1,1,4); +select convert(3, signed integer) > 2.9; +convert(3, signed integer) > 2.9 +1 +select * from t1 force index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 force index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +drop table t1; +# +# BUG#13463488 - 63437: CHAR & BETWEEN WITH INDEX RETURNS WRONG +# RESULT AFTER MYSQL 5.1. +# +CREATE TABLE t1( +F1 CHAR(5) NOT NULL, +F2 CHAR(5) NOT NULL, +F3 CHAR(5) NOT NULL, +PRIMARY KEY(F1), +INDEX IDX_F2(F2) +) COLLATE latin1_swedish_ci; +INSERT INTO t1 VALUES +('A','A','A'),('AA','AA','AA'),('AAA','AAA','AAA'), +('AAAA','AAAA','AAAA'),('AAAAA','AAAAA','AAAAA'); +SELECT * FROM t1 WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 WHERE F1 >= 'A '; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 > 'A '; +F1 F2 F3 +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F2 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F3 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND +'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +DROP TABLE t1; +End of 5.1 tests +CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1)); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT c1 FROM t1 WHERE c1 >= 'A' GROUP BY 1; +c1 +1 +2 +3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +DROP TABLE t1; +create table t1 (a int,b int,key (b),key (a),key (b,a)); +insert into t1(a,b) values (1,2),(3,4),(5,6),(7,8); +create table t2 (c int); +insert into t2(c) values (1),(5),(6),(7),(8); +select 1 from (select c from t1,t2 where b >= 1 and a <=> c group by 1 limit 1) as d1; +1 +1 +drop table t1, t2; +# +# Bug #26106: Wrong plan may be chosen when there are several possible +# range and ref accesses +# +# Note: The fix for this bug has been reverted. The code will no longer +# select the optimal plan for the two following test queries. This is +# not due to a bug but due to minor differences in range estimates +# produced by the storage engine. +CREATE TABLE t1( +a INT, +b INT, +KEY k ( a ), +KEY l ( a, b ) +); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1 +VALUES (2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3); +INSERT INTO t1 SELECT 3, 4 FROM t1 WHERE a = 2 AND b = 3; +INSERT INTO t1 SELECT 4, 1 FROM t1 WHERE a = 2 AND b = 3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +# This must use range over index l, not k. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t1 WHERE a = 1 AND b >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 129 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k,l k 5 const 129 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` >= 2)) +CREATE TABLE t2( +a INT, +b INT, +c INT, +KEY k ( a ), +KEY l ( a, b ), +KEY m ( b ), +KEY n ( a, c ) +); +INSERT INTO t2(a) VALUES (1); +INSERT INTO t2 +VALUES (2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3), +(2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3); +INSERT INTO t2 SELECT 3, 4, 4 FROM t2 WHERE a = 2 AND b = 3; +INSERT INTO t2 SELECT 4, 1, 1 FROM t2 WHERE a = 2 AND b = 3; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +INSERT INTO t2 VALUES (1, 2, 2); +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 VALUES (1, 1, 2); +# This must use range over index l, not n. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t2 WHERE a = 1 AND b >= 2 AND c >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 66 29.16 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref k,l,m,n k 5 const 66 29.16 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` >= 2) and (`test`.`t2`.`c` >= 2)) +DROP TABLE t1, t2; +# +# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER +# AWAY QUALIFYING ROWS +# +CREATE TABLE t10( +K INT NOT NULL AUTO_INCREMENT, +I INT, J INT, +PRIMARY KEY(K), +KEY(I,J) +); +INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5), +(6,6),(6,7),(6,8),(6,9),(6,0); +CREATE TABLE t100 LIKE t10; +INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y; +INSERT INTO t100(I,J) VALUES(8,26); + +EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t100 NULL range I I 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t100`.`K` AS `K`,`test`.`t100`.`I` AS `I`,`test`.`t100`.`J` AS `J` from `test`.`t100` where ((`test`.`t100`.`I` <> 6) or ((`test`.`t100`.`J` = 5) and (`test`.`t100`.`I` <> 8))) + +SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +K I J +128 8 26 +DROP TABLE t10,t100; +# +# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR +# AFTER FLUSH TABLES [-INT VS NULL] +# +CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (-100,1),(1,6); +CREATE TABLE t2 ( +col_int_key INT, +col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT", +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t2 VALUES +(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8); +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t2 NULL ref PRIMARY,col_int_key col_int_key 5 test.t1.col_int # # Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +# need FLUSH so that InnoDB statistics change and thus plan changes +FLUSH TABLES; +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_int_key NULL NULL NULL # # Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +DROP TABLE t1,t2; +# +# Bug#12694872 - +# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_date_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1 ( +col_int_key, +col_int_nokey, +col_date_key, +col_varchar_key, +col_varchar_nokey +) VALUES +(0, 4, '2011-08-25', 'j', 'j'), +(8, 6, '2004-09-18', 'v', 'v'), +(1, 3, '2009-12-01', 'c', 'c'), +(8, 5, '2004-12-17', 'm', 'm'), +(9, 3, '2000-03-14', 'd', 'd'), +(6, 2, '2006-05-25', 'y', 'y'), +(1, 9, '2008-01-23', 't', 't'), +(6, 3, '2007-06-18', 'd', 'd'), +(2, 8, '2002-10-13', 's', 's'), +(4, 1, '1900-01-01', 'r', 'r'), +(8, 8, '1959-04-25', 'm', 'm'), +(4, 8, '2006-03-09', 'b', 'b'), +(4, 5, '2001-06-05', 'x', 'x'), +(7, 7, '2006-05-28', 'g', 'g'), +(4, 5, '2001-04-19', 'p', 'p'), +(1, 1, '1900-01-01', 'q', 'q'), +(9, 6, '2004-08-20', 'w', 'w'), +(4, 2, '2004-10-10', 'd', 'd'), +(8, 9, '2000-04-02', 'e', 'e') +; +SET UNIQUE_CHECKS = 0; +SET FOREIGN_KEY_CHECKS = 0; +SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +SET FOREIGN_KEY_CHECKS = 1; +SET UNIQUE_CHECKS = 1; +CREATE TABLE t2 SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +SELECT * FROM t2 +WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +); +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +DROP TABLE t1, t2; +# +# BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == +# SAVE_READ_SET +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +PRIMARY KEY (c,a), KEY (a),KEY (a) +) ENGINE=INNODB PARTITION BY KEY () PARTITIONS 2; +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1 VALUES (1,5,1),(2,4,1),(3,3,1),(4,2,1),(5,1,1); +UPDATE t1 SET b = 0, c=1 WHERE a <=>0; +SELECT * FROM t1; +a b c +1 5 1 +2 4 1 +3 3 1 +4 2 1 +5 1 1 +DROP TABLE t1; +# +# BUG#13256446 - ASSERTION QUICK->HEAD->READ_SET == +# SAVE_READ_SET' FAILED IN OPT_RANGE.CC:1606 +# +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f2=103; +INSERT INTO t1 VALUES (154,0,NULL,0),(0,NULL,9,0), +(NULL,102,NULL,3),(0,3,NULL,0), (9,0,NULL,0),(0,9,NULL,157); +SELECT * FROM v2; +f1 f2 f3 f4 +UPDATE v2 SET f4=0, f2=NULL, f1=NULL WHERE f1 > 16 ORDER BY f1; +SELECT * FROM v2; +f1 f2 f3 f4 +DROP TABLE t1; +DROP VIEW v2; +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,NULL,NULL,0), (2,2,0,3), (9,0,107,18), +(10,0,0,0), (231,0,0,0), (232,0,8,0), (234,0,0,NULL), (235,8,0,3); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f1<=85 ; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +UPDATE v3 SET f3=0, f4=4 WHERE f2=68 ORDER BY f1; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +DROP TABLE t1; +DROP VIEW v3; +# +# BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(3),(5); +SELECT * FROM t1 WHERE pk <> 3 OR pk < 4; +pk +1 +3 +5 +DROP TABLE t1; +# +# BUG#13803810: TOO FEW ROWS RETURNED FOR RANGE ACCESS IN +# VARCHAR INDEX USING DATETIME VALUE + +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +CREATE TABLE t2 (b VARCHAR(64), KEY (b)) CHARSET utf8mb4; +INSERT INTO t2 VALUES ('2001-01-01'); +INSERT INTO t2 VALUES ('2001.01.01'); +INSERT INTO t2 VALUES ('2001#01#01'); +INSERT INTO t2 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); + +# range/ref access cannot be used for this query + +EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = (cast('2001-01-01' as date))) +SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +b +2001#01#01 +2001-01-01 +2001-01-01 00:00:00 +2001.01.01 + +# range/ref access cannot be used for any of the queries below. +# See BUG#13814468 about 'Range checked for each record' + +EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = cast(`test`.`t2`.`b` as datetime(6))) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (cast(`test`.`t2`.`b` as datetime(6)) = `test`.`t1`.`a`) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +DROP TABLE t1,t2; +# +# WL#7019: Add support for row value constructors in in predicates to +# range optimizer +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY x(a, b)); +INSERT INTO t1 VALUES (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), +(7, 7, 7), (8, 8, 8), (9, 9, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +CREATE TABLE t3 (a INT, b INT, c INT, d INT, KEY x(a, b, c)); +INSERT INTO t3 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((NULL, NULL), (NULL, NULL)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((NULL,NULL),(NULL,NULL))) +EXPLAIN SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +a b +0 0 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` where ((`test`.`t3`.`a`,`test`.`t3`.`b`,`test`.`t3`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 19.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 19.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1) and (`test`.`t2`.`a` = 1)) or ((`test`.`t2`.`c` = 0) and (`test`.`t2`.`b` = 0) and (`test`.`t2`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`c` = 1) and (`test`.`t3`.`b` = 1) and (`test`.`t3`.`a` = 1)) or ((`test`.`t3`.`c` = 0) and (`test`.`t3`.`b` = 0) and (`test`.`t3`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +a b +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (('0',0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +SET @v = 0; +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (((@`v`),0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +CREATE TABLE t4 ( a INT, b INT ); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t4 SELECT a + 5, b + 5 FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +# Inner table in a nested-loops join +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 USING(a, b) +WHERE (t4.a, t4.b) IN ((1, 1), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 2.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 2.00 Using where +2 SIMPLE t1 NULL ref x x 10 test.t4.a,test.t4.b 409 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t4`.`b`) and (`test`.`t1`.`a` = `test`.`t4`.`a`) and ((`test`.`t4`.`a`,`test`.`t4`.`b`) in ((1,1),(0,0)))) +# Join on IN +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(0,0))) +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(1,1))) +# +# Tests for non-deterministic functions. +# +CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (f1(), 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 4098 0.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(`f1`(),1,1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,`f1`(),1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, f1())); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,1,`f1`()))) +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index x x 10 NULL 4098 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = `f1`())) +DROP FUNCTION f1; +# The statement immediately below should not use range access. +EXPLAIN +SELECT a, b +FROM t1 AS t1o +WHERE EXISTS (SELECT /*+ NO_SEMIJOIN() */ 1 +FROM t1 +WHERE (a, b) IN ((t1o.a, t1o.b)) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1o NULL index NULL x 10 NULL 4098 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref x x 10 test.t1o.a,test.t1o.b 409 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1o.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1o.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1o`.`a` AS `a`,`test`.`t1o`.`b` AS `b` from `test`.`t1` `t1o` where exists(/* select#2 */ select 1 from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1o`.`a`) and (`test`.`t1`.`b` = `test`.`t1o`.`b`))) +# +# Tests of dynamic range access +# +CREATE TABLE t5 (a int, b int, KEY (a)); +INSERT INTO t5 VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1); +CREATE TABLE t6 (a int, b int, KEY (a)); +INSERT INTO t6 VALUES (3, 2), (4, 2), (100, 100), (101, 201), (102, 102); +CREATE TABLE t7 (a int, b int, KEY (a, b)); +INSERT INTO t7 VALUES (1, 1), (2, 2), (1000, 1000), (1001, 1001), (1002, 1002), +(1003, 1003), (1004, 1004); +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and (`test`.`t7`.`a` in (`test`.`t5`.`b`,`test`.`t6`.`b`))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +a b a b a b +3 1 3 2 1 1 +3 1 3 2 2 2 +4 1 4 2 1 1 +4 1 4 2 2 2 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and ((`test`.`t7`.`a`,`test`.`t7`.`b`) in ((`test`.`t5`.`b`,1),(`test`.`t6`.`b`,1)))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +a b a b a b +3 1 3 2 1 1 +4 1 4 2 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +# +# Regression tests of the worklog below. +# +# Make sure we process IN predicates only. +# The code around this is very unclear. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) != (1, 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4098 99.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index x x 10 NULL 4098 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` <> 1) or (`test`.`t1`.`b` <> 1)) +# This should give us a ref scan, as it always did. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +EXPLAIN SELECT a, b FROM t1 WHERE (a, c) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`c` = 0) and (`test`.`t1`.`a` = 0)) +# ref scan on x(a). +EXPLAIN SELECT * FROM t1 WHERE (a, c) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`c`) in ((0,0),(1,1))) +DROP TABLE t1, t2, t3, t4, t5, t6, t7; +# +# Bug#17635476: CRASH IN GET_MM_PARTS() OR ASSERT IN +# GET_FUNC_MM_TREE_FROM_IN_PREDICATE() +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY (a) +) ENGINE = INNODB; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +INSERT INTO t1 VALUES (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), +(7, 7), (8, 8), (9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 ( +a INT, +b INT, +KEY (a, b) +); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((NULL,`test`.`t1`.`b`) in ((0,0),(1,1))) +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 10 NULL 10 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((NULL,`test`.`t2`.`b`) in ((0,0),(1,1))) +DROP TABLE t1, t2; +# +# Bug#17755540 VALGRIND ERROR WHEN SETTING UP ROW COMPARATORS +# +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT a, b FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +DROP TABLE t2; +# +# BUG#18364815: OPTIMIZER PREFERS TABLE SCAN WHEN +# USING "IN" WITH VALUE OF DIFFERENT TYPE +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,1), (5,1), (6,1); +EXPLAIN SELECT * FROM t1 WHERE a IN (1, 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE a IN (1, "2"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,'2')) +SELECT * FROM t1 WHERE a IN (1, 2); +a b +1 1 +2 1 +SELECT * FROM t1 WHERE a IN (1, "2"); +a b +1 1 +2 1 +DROP TABLE t1; +# +# Bug#18715670 +# CRASH IN DECIMAL_ACTUAL_FRACTION COMPARING DECIMAL TO NULLS +# +CREATE TABLE t1(n DECIMAL(39,19) NOT NULL, KEY(n)) engine=innodb; +INSERT INTO t1 SET n=0; +SELECT 1 FROM t1 WHERE n NOT IN(NULL, NULL); +1 +DROP TABLE t1; +# +# Bug#18759597 MISSING ROWS ON WHERE .. +# IN QUERY WITH VARIABLES AND CONCAT +# +CREATE TABLE t1 ( +col_varchar_key varchar(2), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('n'),('xm'); +SET @var1 = 't', @var2 = 'him', +@var3 = 'n', @var4 = 'n', +@var5 = 'n', @var6 = 'g', +@var7 = 'b', @var8 = 'o', +@var9 = 'm', @var10 = 'xm', @var11 = 'u' +; +SELECT col_varchar_key AS field1 +FROM t1 +WHERE ( col_varchar_key, col_varchar_key ) IN ( +('m', @var1 ), +('n', @var3 ), +('a', @var5 ), +('l', @var7 ), +(CONCAT('x', @var9 ), @var10 ) +); +field1 +n +xm +DROP TABLE t1; +# +# Bug#18535226 DEBUG CRASH ON QUICK_RANGE_SELECT::RESET +# +SET @old_tmp_table_size=@@tmp_table_size; +SET tmp_table_size=1024; +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_date_key date, +col_date_nokey date, +col_time_key time, +col_time_nokey time, +col_datetime_key datetime, +col_datetime_nokey datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(5,0,'2001-05-06','2001-05-06','16:21:18','16:21:18','2001-11-08 21:02:12', +'2001-11-08 21:02:12','x','x'),(6,7,'2006-03-03','2006-03-03','18:56:33', +'18:56:33','2003-04-01 00:00:00','2003-04-01 00:00:00','i','i'), +(7,7,'2007-12-28','2007-12-28',NULL,NULL,'1900-01-01 00:00:00', +'1900-01-01 00:00:00','e','e'),(8,1,'2004-10-20','2004-10-20','09:29:08', +'09:29:08','2007-07-12 00:00:00','2007-07-12 00:00:00','p','p'), +(9,7,'2008-04-09','2008-04-09','19:11:10','19:11:10', +'2005-04-04 01:21:01','2005-04-04 01:21:01','s','s'), +(10,1,'2005-12-25','2005-12-25','11:57:26','11:57:26', +'1900-01-01 00:00:00','1900-01-01 00:00:00','j','j'); +SELECT alias1.col_int_key +FROM +( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1, t1 AS SQ1_alias2 ) AS alias1, +(SELECT 7 AS col_int_nokey) AS alias2 +WHERE +alias2.col_int_nokey = alias1.pk +AND alias1.col_varchar_nokey < alias1.col_varchar_key +ORDER BY alias1.col_varchar_key; +col_int_key +DROP TABLE t1; +SET tmp_table_size=@old_tmp_table_size; +SET sql_mode = default; +# +# Bug#19585938 Crash in get_full_func_mm_tree with null +# item_field->table_ref +# +CREATE TABLE t1(id INTEGER, col1 INTEGER, col2 INTEGER, PRIMARY KEY(id)); +INSERT INTO t1 VALUES (1,2,3), (3,2,1); +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) < id +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id > SUM(1) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN id AND id+1 +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id BETWEEN SUM(1) AND SUM(5) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN COUNT(*) AND id +) AS c +FROM t1 +GROUP BY col1; +c +1 +DROP TABLE t1; +# +# Bug#21415791 VALGRIND ERROR (CONDITIONAL JUMP) AT KEY_AND +# (RANGE_OPT_PARAM*, SEL_ARG*, SEL_AR +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +pk INTEGER NOT NULL, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t1 ( +pk, col_varchar_10, col_int_key) VALUES +(1, 'ttttt', 0), (2, 'zzzzz', 0), (3, 'ggggg', 0), +(4, 'hhhhh', 0), (5, 'kkkkk', 0), (6, 'lllll', 0); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t2 ( +pk, col_varchar_10) VALUES +(1, '00000'), (2, '00000'), (3, '44444'), (4, '00000'), +(5, NULL), (6, NULL), (7, NULL); +SELECT COUNT(t1.col_int_key) +FROM t2 RIGHT OUTER JOIN t1 ON t2.col_varchar_10 <= t1.col_varchar_10 +WHERE t2.pk <> 4 OR t2.pk != t1.col_int_key AND t2.pk <> 1000; +COUNT(t1.col_int_key) +24 +DROP TABLE t1, t2; +# +# Bug #20229614: OR CONDITIONS ON MULTI-COLUMN INDEX MAY NOT USE ALL +# INDEX COLUMNS TO FILTER ROWS +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c3 INT, +PRIMARY KEY(c1, c2, c3) +) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 2), (1, 1, 3), +(1, 1, 4), (1, 1, 5); +INSERT INTO t1 SELECT c1, 2, c3 FROM t1; +INSERT INTO t1 SELECT c1, 3, c3 FROM t1 WHERE c2 = 1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +15 +EXPLAIN SELECT c1, c2, c3 +FROM t1 +WHERE (c1 = 1 AND c2 = 1 AND c3 = 1) OR +(c1 = 1 AND c2 = 2 AND c3 = 2) OR +(c1 = 1 AND c2 = 2 AND c3 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 12 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where (((`test`.`t1`.`c3` = 1) and (`test`.`t1`.`c2` = 1) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 3) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1))) +DROP TABLE t1; +# +# Bug#21139683: ASSERTION FAILED: TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE +# +CREATE TABLE t1 ( +a BLOB, +PRIMARY KEY(a(1)), +KEY(a(1)) +) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE a <> 'a' OR a <> ""; +1 +DROP TABLE t1; +# +# Bug#19333852: RESULT DIFF IN QUERY HAVING DISTINCT +# WITH GROUP BY +# +CREATE TABLE t1 ( +v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY v1_key (v1(10)) +) ENGINE=InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); +EXPLAIN SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` < (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v1_key v1_key 32 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` = (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` between 'f' and (char(127))) +SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +v1 pk +ABCDE 19 +JLVGO 14 +SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +v1 pk +SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +v1 pk +JLVGO 14 +DROP TABLE t1; +# +# Bug #21761867: ASSERTION `TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE' FAILED. +# +CREATE TABLE t1 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +c18 INT, +PRIMARY KEY (c10,c12), +UNIQUE KEY key_c12(c12), +KEY key_c18(c18)); +INSERT INTO t1 VALUES(11,5,0), (12,6,1), (13,7,2), (14,8,3), (15,9,4); +CREATE TABLE t2 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +PRIMARY KEY(c10,c12)); +CREATE TABLE t3 (c10 INT NOT NULL); +SELECT t2.c10 +FROM t1 +RIGHT JOIN t3 +LEFT JOIN t2 +ON t3.c10 = t2.c10 +ON t1.c12 > t2.c12 +WHERE +t1.c10 <= 25 +AND +t1.c18 IS NOT NULL +OR +t1.c10 > 5 +AND +t1.c18 IN (15,16,18); +c10 +DROP TABLE t1, t2, t3; +# +# Bug #21318711: WRONG RESULTS FOR TRUNCATED COLUMN AND AGGREGATION +# +CREATE TABLE t1 ( +col1 VARCHAR(5), +col2 INT NOT NULL, +PRIMARY KEY (col1, col2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('abcde', 10); +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where (`test`.`t1`.`col1` = 'abcdeaa') +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where multiple equal('abcde ', `test`.`t1`.`col1`) +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +MAX(col2) +NULL +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +MAX(col2) +10 +DROP TABLE t1; +# +# Bug# 22283790: RANGE OPTIMIZER UTILIZES TOO MUCH MEMORY WITH +# MANY OR CONDITIONS +# +CREATE TABLE t1 ( +f1 INTEGER, +KEY (f1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15); +SET @orig_range_optimizer_max_mem_size= @@range_optimizer_max_mem_size; +SET range_optimizer_max_mem_size= 5000; +EXPLAIN SELECT * FROM t1 WHERE f1=1 OR f1=2 OR f1=3 OR f1=4 OR f1=5 +OR f1=6 OR f1=7 OR f1=8 OR f1=9 OR f1=10 OR f1=11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range f1 f1 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` = 1) or (`test`.`t1`.`f1` = 2) or (`test`.`t1`.`f1` = 3) or (`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f1` = 5) or (`test`.`t1`.`f1` = 6) or (`test`.`t1`.`f1` = 7) or (`test`.`t1`.`f1` = 8) or (`test`.`t1`.`f1` = 9) or (`test`.`t1`.`f1` = 10) or (`test`.`t1`.`f1` = 11)) +SET range_optimizer_max_mem_size= @orig_range_optimizer_max_mem_size; +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +SELECT * FROM t1 WHERE pk IN (3, 8) OR pk NOT IN (2); +pk +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +# Indirectly tests ORing with a tree that has a nonzero refcount, +# where nodes are also being skipped over. (There was a bug in +# refcounting such trees earlier.) +# +CREATE TABLE t1 ( +col_int_key int, +pk int NOT NULL, +col_int int, +KEY test_idx (pk,col_int_key,col_int) +); +SELECT * FROM t1 WHERE +(col_int_key >= 6 AND pk > 6) OR +(pk > 2 AND col_int_key = 7 AND col_int > 6); +col_int_key pk col_int +DROP TABLE t1; +# +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE `giant_table` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`one_id` int(11) NOT NULL, +`other_id` bigint(20) NOT NULL DEFAULT '0', +`some_other_id` int(11) DEFAULT 0 NOT NULL, +`something` double NOT NULL DEFAULT '0', +`comment` text COLLATE utf8_unicode_ci, +`flags` int(11) NOT NULL DEFAULT '0', +`time_created` int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (`id`), +KEY `time_created` (`time_created`), +KEY `some_other_id` (`some_other_id`), +KEY `one_other_idx` (`one_id`,`other_id`), +KEY `other_id` (`other_id`,`time_created`) +) ENGINE=InnoDB AUTO_INCREMENT=101651329 +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (66136540), (68983250), (89627210), (77869520), +(82543190), (67538270), (77282760), (77908170), +(70923370), (68066360); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT INTO giant_table(id,one_id) +SELECT c1 + @x, 0 +FROM t1 +WHERE c1 IN (66136540, 68985250, 89627210, 77869520 , 82543190, 67538270, +77282760, 77908170, 70923370, 68066360); +SET @x = @x + 1; +UNTIL @x > 30 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM giant_table; +count(*) +270 +INSERT INTO giant_table (id,one_id) VALUES (66136539, 0), (68983258,1), +(89628210,1), (77869520,2); +INSERT INTO giant_table (id,one_id, some_other_id) VALUES(84673401, 0, 1), +(61069031, 1, 1); +EXPLAIN SELECT id, something, comment, time_created, one_id, other_id, +some_other_id, flags +FROM giant_table +WHERE id IN (66136539, 68983258, 89628210, 77869520, 82543198, 67538272, +84673401, 61069031, 68214385, 77282865, 76991297, 64569216, +89481638, 74534074, 70396537, 80076375, 63308530, 77908270, +70923271, 68066180) +AND (giant_table.flags & 0x01) = 0 AND giant_table.some_other_id = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE giant_table NULL range PRIMARY,some_other_id some_other_id 8 NULL 20 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`giant_table`.`id` AS `id`,`test`.`giant_table`.`something` AS `something`,`test`.`giant_table`.`comment` AS `comment`,`test`.`giant_table`.`time_created` AS `time_created`,`test`.`giant_table`.`one_id` AS `one_id`,`test`.`giant_table`.`other_id` AS `other_id`,`test`.`giant_table`.`some_other_id` AS `some_other_id`,`test`.`giant_table`.`flags` AS `flags` from `test`.`giant_table` where ((`test`.`giant_table`.`some_other_id` = 0) and (`test`.`giant_table`.`id` in (66136539,68983258,89628210,77869520,82543198,67538272,84673401,61069031,68214385,77282865,76991297,64569216,89481638,74534074,70396537,80076375,63308530,77908270,70923271,68066180)) and ((`test`.`giant_table`.`flags` & 0x01) = 0)) +DROP PROCEDURE p; +DROP TABLE giant_table, t1; +# +# Bug#22671573: SIG11 IN SEL_ARG::RB_INSERT |SQL/OPT_RANGE.CC +# +# Tests creating an empty tree (impossible condition) and then ANDing with it. +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY test_idx (b, a) +); +SELECT * FROM t1 WHERE b BETWEEN 8 AND 8 AND a > 8 AND a <= 8; +a b +DROP TABLE t1; +# +# Indirectly tests inserting a node into an empty (impossible) tree. +# +CREATE TABLE t1 ( +pk INT, +PRIMARY KEY ( pk ) +); +SELECT * FROM t1 WHERE pk = 6 OR pk > 6; +pk +DROP TABLE t1; +# +# Indirectly tests ORing with an empty (impossible) tree. +# +CREATE TABLE t1 ( +col_int_key INT, +KEY (col_int_key) +); +SELECT * FROM t1 WHERE col_int_key IS NULL OR col_int_key < 9 OR col_int_key = 9; +col_int_key +DROP TABLE t1; +# +# Indirectly tests deleting the last node from a tree +# (which makes it IMPOSSIBLE) and then inserting more than one node. +# +CREATE TABLE t1 ( +a VARCHAR(64), +KEY a (a) +); +SELECT * FROM t1 WHERE a IS NULL OR a NOT IN ( 'foo', 'bar' ); +a +DROP TABLE t1; +# +# Bug#25229315: ASSERTION TABLE->M_RECORD_BUFFER.RECORD_SIZE() == +# RECORD_PREFIX_SIZE(TAB)' FAIL +# +CREATE TABLE t1 (pk INT PRIMARY KEY, vc VARCHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, NULL), (2, 'w'); +CREATE TABLE t2 ( +i INT, +vc VARCHAR(1), +pk INT PRIMARY KEY, +KEY (i), +KEY (vc) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 'p', 1), (9, 'w', 2), (NULL, 'r', 3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL i,vc NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x6) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`vc` = `test`.`t1`.`vc`) or (`test`.`t2`.`i` = `test`.`t1`.`pk`)) +SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +MIN(t1.pk) +1 +DROP TABLE t1, t2; +# +# Bug #26727773: OPTIMIZER CHOSES COMPOSITE INDEX FOR REF OVER RANGE +# +CREATE TABLE transactions ( +app_trans_id INT DEFAULT NULL, +id INT NOT NULL, +tbl INT NOT NULL DEFAULT 1, +created TIMESTAMP NOT NULL DEFAULT '2017-01-01 01:01:01', +trans_type INT NOT NULL, +description BLOB, +source_lvl1 INT DEFAULT NULL, +source_lvl2 INT DEFAULT NULL, +KEY tbl_id_idx (tbl,id), +KEY created_idx (created), +KEY trans_type_created_idx (trans_type,created), +KEY app_trans_id_idx (app_trans_id) +) ENGINE=INNODB ; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1000), (2000), (3000), (4000), (5000), (6000), +(7000), (8000), (9000); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT IGNORE INTO transactions(id,trans_type, description) +SELECT c1 + @x, @x , 'abcd' + FROM t1; +SET @x = @x + 1; +UNTIL @x > 300 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM transactions; +count(*) +3000 +INSERT IGNORE INTO transactions(id,trans_type, description, created) +SELECT 3, 3 , 'abcd', '2018-01-01 01:01:01' + FROM dual; +EXPLAIN SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE transactions NULL range tbl_id_idx,created_idx,trans_type_created_idx created_idx 4 NULL # # Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select '2017-10-23 01:01:01' AS `2017-10-23 01:01:01`,hour(`test`.`transactions`.`created`) AS `HOUR(created)`,`test`.`transactions`.`source_lvl1` AS `source_lvl1`,`test`.`transactions`.`source_lvl2` AS `source_lvl2`,count(distinct `test`.`transactions`.`app_trans_id`) AS `COUNT(DISTINCT(app_trans_id))` from `test`.`transactions` where ((`test`.`transactions`.`trans_type` = 3) and (`test`.`transactions`.`tbl` = 1) and (`test`.`transactions`.`created` > TIMESTAMP'2017-10-23 01:01:01')) group by '2017-10-23 01:01:01',hour(`test`.`transactions`.`created`),`test`.`transactions`.`source_lvl1`,`test`.`transactions`.`source_lvl2` +SET optimizer_trace="enabled=on"; +SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +2017-10-23 01:01:01 HOUR(created) source_lvl1 source_lvl2 COUNT(DISTINCT(app_trans_id)) +2017-10-23 01:01:01 1 NULL NULL 0 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +SET optimizer_trace="enabled=off"; +DROP PROCEDURE p; +DROP TABLE t1, transactions; +# +# Bug #28086754: OPTIMIZER SKIP THE RANG SCAN ON SECOND COLUMN IN A +# COMPOSITE INDEX +# +CREATE TABLE test_ref ( +a INT PRIMARY KEY, +b VARCHAR(20), +c VARCHAR(20) DEFAULT NULL, +d VARCHAR(3) DEFAULT NULL, +id INT DEFAULT NULL, +KEY idx1 (id, c), +KEY idx2 (id, d)) ENGINE=INNODB ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze Error Table 'test.t1' doesn't exist +test.t1 analyze status Operation failed +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c`,`test`.`test_ref`.`a` limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +a b c d id +34876 D003 gheennse S 3 +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using index condition; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c` desc,`test`.`test_ref`.`a` desc limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +a b c d id +1770649 D003 gheennse S 3 +DROP TABLE test_ref; +# +# Bug #30988735: SELECT QUERY WITH ERROR RESULT WITH "NOT IN" +# WHERE_CLAUSE +# +CREATE TABLE t(f1 INTEGER key, f2 INTEGER)ENGINE=INNODB; +INSERT INTO t VALUES(0,0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT f1,f2 FROM t WHERE f1 NOT IN(-0.1,0.1); +f1 f2 +0 0 +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/range_icp.result-pq b/mysql-test/r/range_icp.result-pq new file mode 100644 index 000000000..fcec8c50c --- /dev/null +++ b/mysql-test/r/range_icp.result-pq @@ -0,0 +1,3997 @@ +set optimizer_switch='index_condition_pushdown=on'; +drop table if exists t1, t2, t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +event_date date DEFAULT '0000-00-00' NOT NULL, +type int(11) DEFAULT '0' NOT NULL, +event_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (event_date,type,event_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25), +('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26), +('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45), +('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5), +('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17), +('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40), +('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6), +('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41), +('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41), +('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29), +('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19), +('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42), +('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30), +('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8), +('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22), +('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43), +('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37), +('1999-09-19',100100,37), ('2000-12-18',100700,38); +explain select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 19.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 7 NULL 6 19.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where ((`test`.`t1`.`event_date` >= DATE'1999-07-01') and (`test`.`t1`.`event_date` < DATE'1999-07-15') and ((`test`.`t1`.`type` = 100600) or (`test`.`t1`.`type` = 100100))) order by `test`.`t1`.`event_date` +explain format=tree select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +EXPLAIN +-> Parallel scan on + -> Filter: ((t1.event_date >= DATE'1999-07-01') and (t1.event_date < DATE'1999-07-15') and ((t1.`type` = 100600) or (t1.`type` = 100100))) (cost=1.46 rows=1) + -> PQblock range scan on t1 using PRIMARY (cost=1.46 rows=6) + +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where false order by `test`.`t1`.`event_date` +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +1999-07-15 100600 16 +drop table t1; +CREATE TABLE t1 ( +PAPER_ID smallint(6) DEFAULT '0' NOT NULL, +YEAR smallint(6) DEFAULT '0' NOT NULL, +ISSUE smallint(6) DEFAULT '0' NOT NULL, +CLOSED tinyint(4) DEFAULT '0' NOT NULL, +ISS_DATE date DEFAULT '0000-00-00' NOT NULL, +PRIMARY KEY (PAPER_ID,YEAR,ISSUE) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'), +(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'), +(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'), +(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'), +(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'), +(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'), +(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'), +(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'), +(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'), +(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'), +(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'), +(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'), +(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'), +(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'), +(3,1999,35,0,'1999-07-12'); +select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE; +YEAR ISSUE +1999 29 +1999 30 +1999 31 +1999 32 +1999 33 +1999 34 +1999 35 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair note The storage engine for the table doesn't support repair +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2), +(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2), +(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1), +(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2), +(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2), +(19,3,2), (5,1,1), (179,5,2); +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +drop table t1; +create table t1( +Satellite varchar(25) not null, +SensorMode varchar(25) not null, +FullImageCornersUpperLeftLongitude double not null, +FullImageCornersUpperRightLongitude double not null, +FullImageCornersUpperRightLatitude double not null, +FullImageCornersLowerRightLatitude double not null, +index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude)); +insert into t1 values("OV-3","PAN1",91,-92,40,50); +insert into t1 values("OV-4","PAN1",91,-92,40,50); +select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000; +Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude +OV-3 PAN1 91 -92 40 50 +drop table t1; +create table t1 ( aString char(100) not null default "", key aString (aString(10)) ); +insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love"); +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +alter table t1 drop key aString; +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +drop table t1; +CREATE TABLE t1 ( +t1ID int(10) unsigned NOT NULL auto_increment, +art binary(1) NOT NULL default '', +KNR char(5) NOT NULL default '', +RECHNR char(6) NOT NULL default '', +POSNR char(2) NOT NULL default '', +ARTNR char(10) NOT NULL default '', +TEX char(70) NOT NULL default '', +PRIMARY KEY (t1ID), +KEY IdxArt (art), +KEY IdxKnr (KNR), +KEY IdxArtnr (ARTNR) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'); +select count(*) from t1 where upper(art) = 'J'; +count(*) +213 +select count(*) from t1 where art = 'J' or art = 'j'; +count(*) +602 +select count(*) from t1 where art = 'j' or art = 'J'; +count(*) +602 +select count(*) from t1 where art = 'j'; +count(*) +389 +select count(*) from t1 where art = 'J'; +count(*) +213 +drop table t1; +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` between 7 and ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` >= 7) and (`test`.`t2`.`x` <= ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using index condition; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between ((2 - 1)) and ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using index condition; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= ((2 - 1))) and (`test`.`t2`.`x` <= ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between 0 and 2)) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= 0) and (`test`.`t2`.`x` <= 2)) +explain select count(*) from t1 where x in (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` = 1) +explain select count(*) from t1 where x in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` in (1,2)) +drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +explain select * from t1 force index(i1), t2 force index(j1) where +(t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` FORCE INDEX (`i1`) join `test`.`t2` FORCE INDEX (`j1`) where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a), +KEY b (b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), +(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), +(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), +(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a,b a 5 NULL 2 40.54 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` in (1,2))) +SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +a b +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) +); +a b +15 1 +47 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id int( 11 ) unsigned NOT NULL AUTO_INCREMENT , +line int( 5 ) unsigned NOT NULL default '0', +columnid int( 3 ) unsigned NOT NULL default '0', +owner int( 3 ) unsigned NOT NULL default '0', +ordinal int( 3 ) unsigned NOT NULL default '0', +showid smallint( 6 ) unsigned NOT NULL default '1', +tableid int( 1 ) unsigned NOT NULL default '1', +content int( 5 ) unsigned NOT NULL default '188', +PRIMARY KEY ( owner, id ) , +KEY menu( owner, showid, columnid ) , +KEY `COLUMN` ( owner, columnid, line ) , +KEY `LINES` ( owner, tableid, content, id ) , +KEY recount( owner, line ) +) ENGINE = MYISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); +SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; +id columnid tableid content showid line ordinal +13 13 1 188 1 5 0 +15 15 1 188 1 1 0 +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select id from t1 where id in (2,5,9) ; +id +2 +5 +9 +select id from t1 where id=2 or id=5 or id=9 ; +id +2 +5 +9 +drop table t1; +create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2)); +insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), +(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"), +(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"), +(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"), +(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"), +(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"), +(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa"); +select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; +id1 idnull +drop table t1; +create table t1 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +create table t2 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +insert into t1(id, uid, name) values(1, 0, ' '); +insert into t1(uid, name) values(0, ' '); +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +delete from t2; +insert into t2(uid, name) values +(1, CHAR(64+1)), +(2, CHAR(64+2)), +(3, CHAR(64+3)), +(4, CHAR(64+4)), +(5, CHAR(64+5)), +(6, CHAR(64+6)), +(7, CHAR(64+7)), +(8, CHAR(64+8)), +(9, CHAR(64+9)), +(10, CHAR(64+10)), +(11, CHAR(64+11)), +(12, CHAR(64+12)), +(13, CHAR(64+13)), +(14, CHAR(64+14)), +(15, CHAR(64+15)), +(16, CHAR(64+16)), +(17, CHAR(64+17)), +(18, CHAR(64+18)), +(19, CHAR(64+19)), +(20, CHAR(64+20)), +(21, CHAR(64+21)), +(22, CHAR(64+22)), +(23, CHAR(64+23)), +(24, CHAR(64+24)), +(25, CHAR(64+25)), +(26, CHAR(64+26)); +insert into t1(uid, name) select uid, name from t2 order by uid; +delete from t2; +insert into t2(id, uid, name) select id, uid, name from t1; +select count(*) from t1; +count(*) +1026 +select count(*) from t2; +count(*) +1026 +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +drop table t1,t2; +create table t1 (x bigint unsigned not null); +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +create table t2 (x bigint not null); +insert into t2(x) values (-16); +insert into t2(x) values (-15); +select * from t2; +x +-16 +-15 +select count(*) from t2 where x>0; +count(*) +0 +select count(*) from t2 where x=0; +count(*) +0 +select count(*) from t2 where x<0; +count(*) +2 +select count(*) from t2 where x < -16; +count(*) +0 +select count(*) from t2 where x = -16; +count(*) +1 +select count(*) from t2 where x > -16; +count(*) +1 +select count(*) from t2 where x = 18446744073709551601; +count(*) +0 +drop table t1,t2; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +create table t1 (a bigint unsigned); +create index t1i on t1(a); +insert into t1 select 18446744073709551615; +insert into t1 select 18446744073709551614; +explain select * from t1 where a <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a <> -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1 or a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1 or a < -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where a < -1; +a +drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 11 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 'aaa') +explain select * from t1 where a=binary 'aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using index condition +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (cast('aaa' as char charset binary))) +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using index condition +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_bin))) +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 9 11.11 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_german1_ci))) +drop table t1; +CREATE TABLE t1 ( +`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', +`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTINT` int(11) NOT NULL default '0', +KEY `VERI_CLNT~2` (`ARG1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0), +('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0), +('001',' 3',' 0','Text 017',0); +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2'); +count(*) +4 +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1'); +count(*) +4 +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( +pk1 int(11) NOT NULL, +pk2 int(11) NOT NULL, +pk3 int(11) NOT NULL, +pk4 int(11) NOT NULL, +filler char(82), +PRIMARY KEY (pk1,pk2,pk3,pk4) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B; +INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'), +(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'), +(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler'); +SELECT * FROM t2 +WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635))) +OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635)))) +) AND (pk3 >=1000000); +pk1 pk2 pk3 pk4 filler +2621 2635 1000015 0 filler +drop table t1, t2; +create table t1(a char(2), key(a(1))) charset utf8mb4; +insert into t1 values ('x'), ('xx'); +explain select a from t1 where a > 'x'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'x') +select a from t1 where a > 'x'; +a +xx +drop table t1; +CREATE TABLE t1 ( +OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid', +OXLEFT int NOT NULL DEFAULT '0', +OXRIGHT int NOT NULL DEFAULT '0', +OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +PRIMARY KEY (OXID), +KEY OXNID (OXID), +KEY OXLEFT (OXLEFT), +KEY OXRIGHT (OXRIGHT), +KEY OXROOTID (OXROOTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'), +('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725521'); +EXPLAIN +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE v NULL ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 100.00 NULL +1 SIMPLE s NULL ref OXLEFT,OXROOTID OXROOTID 34 const 5 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`OXID` AS `oxid` from `test`.`t1` `v` join `test`.`t1` `s` where ((`test`.`s`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`v`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`s`.`OXLEFT` > `test`.`v`.`OXLEFT`) and (`test`.`s`.`OXLEFT` < `test`.`v`.`OXRIGHT`)) +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +oxid +d8c4177d151affab2.81582770 +d8c4177d206a333d2.74422679 +d8c4177d225791924.30714720 +d8c4177d2380fc201.39666693 +d8c4177d24ccef970.14957924 +DROP TABLE t1; +create table t1 ( +c1 char(10), c2 char(10), c3 char(10), c4 char(10), +c5 char(10), c6 char(10), c7 char(10), c8 char(10), +c9 char(10), c10 char(10), c11 char(10), c12 char(10), +c13 char(10), c14 char(10), c15 char(10), c16 char(10), +index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); +select * from t1 where +c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 +Warnings: +Warning 3170 Memory capacity of 8388608 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +drop table t1; +End of 4.1 tests +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +status varchar(20), +PRIMARY KEY (id), +KEY (status) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'), +(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'), +(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'), +(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'), +(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'), +(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'), +(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'), +(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'), +(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'), +(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C'); +EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not between 'A' and 'B') +EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` < 'A') or (`test`.`t1`.`status` > 'B')) +SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, primary key(a,b)); +INSERT INTO t1 VALUES +(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3); +CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3; +EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +SELECT a,b FROM t1 WHERE a < 2 and b=3; +a b +1 3 +SELECT a,b FROM v1 WHERE a < 2 and b=3; +a b +1 3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name)); +INSERT INTO t1 VALUES ('Betty'), ('Anna'); +SELECT * FROM t1; +name +Anna +Betty +DELETE FROM t1 WHERE name NOT LIKE 'A%a'; +SELECT * FROM t1; +name +Anna +DROP TABLE t1; +CREATE TABLE t1 (a int, KEY idx(a)); +INSERT INTO t1 VALUES (NULL), (1), (2), (3); +SELECT * FROM t1; +a +NULL +1 +2 +3 +DELETE FROM t1 WHERE NOT(a <=> 2); +SELECT * FROM t1; +a +2 +DROP TABLE t1; +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); +explain select * from t1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from v1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +explain select * from v1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +drop view v1; +drop table t1; +create table t3 (a int); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a varchar(10), filler char(200), key(a)) charset=binary; +insert into t1 values ('a',''); +insert into t1 values ('a ',''); +insert into t1 values ('a ', ''); +insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), '' + from t3 A, t3 B, t3 C; +create table t2 (a varchar(10), filler char(200), key(a)) charset utf8mb4; +insert into t2 select * from t1; +explain select * from t1 where a between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` between 'a' and 'a ') +explain select * from t1 where a = 'a' or a='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') or (`test`.`t1`.`a` = 'a ')) +explain select * from t2 where a between 'a' and 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` between 'a' and 'A') +explain select * from t2 where a = 'a' or a='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') or (`test`.`t2`.`a` = 'A')) +update t1 set a='b' where a<>'a'; +explain select * from t1 where a not between 'b' and 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` not between 'b' and 'b') +select a, hex(filler) from t1 where a not between 'b' and 'b'; +a hex(filler) +a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +drop table t1,t2,t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, key(a)); +insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C; +set @a="select * from t2 force index (a) where a NOT IN(0"; +select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z; +count(*) +1000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @a=concat(@a, ')'); +insert into t2 values (11),(13),(15); +set @b= concat("explain ", @a); +prepare stmt1 from @b; +execute stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1003 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,604,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,784,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1146,1148,1150,1152,1154,1156,1158,1160,1162,1164,1166,1168,1170,1172,1174,1176,1178,1180,1182,1184,1186,1188,1190,1192,1194,1196,1198,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222,1224,1226,1228,1230,1232,1234,1236,1238,1240,1242,1244,1246,1248,1250,1252,1254,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292,1294,1296,1298,1300,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1370,1372,1374,1376,1378,1380,1382,1384,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408,1410,1412,1414,1416,1418,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458,1460,1462,1464,1466,1468,1470,1472,1474,1476,1478,1480,1482,1484,1486,1488,1490,1492,1494,1496,1498,1500,1502,1504,1506,1508,1510,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1552,1554,1556,1558,1560,1562,1564,1566,1568,1570,1572,1574,1576,1578,1580,1582,1584,1586,1588,1590,1592,1594,1596,1598,1600,1602,1604,1606,1608,1610,1612,1614,1616,1618,1620,1622,1624,1626,1628,1630,1632,1634,1636,1638,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678,1680,1682,1684,1686,1688,1690,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1714,1716,1718,1720,1722,1724,1726,1728,1730,1732,1734,1736,1738,1740,1742,1744,1746,1748,1750,1752,1754,1756,1758,1760,1762,1764,1766,1768,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790,1792,1794,1796,1798,1800,1802,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822,1824,1826,1828,1830,1832,1834,1836,1838,1840,1842,1844,1846,1848,1850,1852,1854,1856,1858,1860,1862,1864,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1886,1888,1890,1892,1894,1896,1898,1900,1902,1904,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1964,1966,1968,1970,1972,1974,1976,1978,1980,1982,1984,1986,1988,1990,1992,1994,1996,1998)) +prepare stmt1 from @a; +execute stmt1; +a +11 +13 +15 +drop table t1, t2; +CREATE TABLE t1 ( +id int NOT NULL DEFAULT '0', +b int NOT NULL DEFAULT '0', +c int NOT NULL DEFAULT '0', +INDEX idx1(b,c), INDEX idx2(c)); +INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(b,c) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` <= 3) and (3 <= `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (3 between `test`.`t1`.`b` and `test`.`t1`.`c`) +SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((0 < `test`.`t1`.`b`) or (0 > `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (0 not between `test`.`t1`.`b` and `test`.`t1`.`c`) +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +EXPLAIN +-> Filter: (0 not between t1.b and t1.c) (cost=2.15 rows=3) + -> Index range scan on t1 using sort_union(idx1,idx2) (cost=2.15 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( +item char(20) NOT NULL default '', +started datetime NOT NULL default '0000-00-00 00:00:00', +price decimal(16,3) NOT NULL default '0.000', +PRIMARY KEY (item,started) +) ENGINE=MyISAM, CHARSET utf8mb4; +INSERT INTO t1 VALUES +('A1','2005-11-01 08:00:00',1000), +('A1','2005-11-15 00:00:00',2000), +('A1','2005-12-12 08:00:00',3000), +('A2','2005-12-01 08:00:00',1000); +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP INDEX `PRIMARY` ON t1; +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP TABLE t1; + +BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly" + +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +dateval date default NULL, +PRIMARY KEY (id), +KEY dateval (dateval) +) AUTO_INCREMENT=173; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'), +(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'), +(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11'); +This must use range access: +explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range dateval dateval 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`dateval` AS `dateval` from `test`.`t1` where ((`test`.`t1`.`dateval` >= DATE'2007-01-01') and (`test`.`t1`.`dateval` <= DATE'2007-01-02')) +drop table t1; +CREATE TABLE t1 ( +a varchar(32), index (a) +) DEFAULT CHARSET=latin1 COLLATE=latin1_bin; +INSERT INTO t1 VALUES +('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'); +SELECT a FROM t1 WHERE a='b' OR a='B'; +a +B +B +EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 35 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'b') or (`test`.`t1`.`a` = 'B')) +DROP TABLE t1; +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); +SELECT COUNT(*) FROM t1 WHERE f1 < 256; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 256.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 255; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 < -1; +COUNT(*) +0 +SELECT COUNT(*) FROM t1 WHERE f1 > -1; +COUNT(*) +5 +DROP TABLE t1; +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); +SELECT COUNT(*) FROM t1 WHERE f1 < 128; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 128.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 127; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 > -129; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -129.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -128; +COUNT(*) +4 +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100)); +insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, +t1 B, t1 C where A.a < 5; +insert into t2 select 1000, b, 'filler' from t2; +alter table t2 add index (a,b); +Access method can be range/ALL with #rows >= 500. +Or it can be ref with #rows = 2, only when there is memory limit. +explain select * from t2 where a=1000 and b<11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 50.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL a NULL NULL NULL 1000 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 1000) and (`test`.`t2`.`b` < 11)) +drop table t1, t2; +CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t3( a INT, b INT, KEY( a, b ) ); +INSERT INTO t1( a, b ) +VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7); +INSERT INTO t2( a, b ) +VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1), +( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1), +(11, 1), (12, 1), (13, 1), (14, 1), (15, 1), +(16, 1), (17, 1), (18, 1), (19, 1), (20, 1); +INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t3 +VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), +(6, 0), (7, 0), (8, 0), (9, 0), (10, 0); +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 < `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 1) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +5 2 +6 1 +6 2 +7 1 +7 2 +8 1 +8 2 +9 1 +9 2 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 2) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +a b +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +EXPLAIN +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`b` = 3) and (5 <= `test`.`t3`.`a`) and (`test`.`t3`.`a` < 10)) or (`test`.`t3`.`a` < 5) or (`test`.`t3`.`a` < 10)) +DROP TABLE t1, t2, t3; +# +# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL); +a +DROP TABLE t1; +# +# Bug#47925: regression of range optimizer and date comparison in 5.1.39! +# +CREATE TABLE t1 ( a DATE, KEY ( a ) ); +CREATE TABLE t2 ( a DATETIME, KEY ( a ) ); +# Make optimizer choose range scan +INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22'); +INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23'); +INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'), +('2009-09-22 12:00:00'); +INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'), +('2009-09-23 12:00:00'); +# DATE vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# DATE vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923120000'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923120000; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923000000'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923000000; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# Test of the new get_date_from_str implementation +# Behavior differs slightly between the trunk and mysql-pe. +# The former may give errors for the truncated values, while the latter +# gives warnings. The purpose of this test is not to interfere, and only +# preserve existing behavior. +# This case was made obsolete after the changes applied by +# Bug#28940878 WRONG RESULT WHEN COMPARING DATE[TIME] WITH STRING +# as we don't fallback anymore to string comparison if the date is invalid. +SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND +str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND +str_to_date('2007-20-00', '%Y-%m-%d') <= ''; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; +str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''; +str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +SELECT str_to_date('', '%Y-%m-%d'); +str_to_date('', '%Y-%m-%d') +0000-00-00 +DROP TABLE t1, t2; +# +# Bug#48459: valgrind errors with query using 'Range checked for each +# record' +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY ( c ), +KEY ( d, a, b ( 2 ) ), +KEY ( b ( 1 ) ) +); +INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ), +( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 ); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY ( e ) +); +INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL ); +# Should not give Valgrind warnings +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug #48665: sql-bench's insert test fails due to wrong result +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (0,0), (1,1); +EXPLAIN +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +@ @ @ NULL ALL @ @ @ @ @ 100.00 @ +@ @ @ NULL range @ @ @ @ @ 100.00 @ +Warnings: +@ @ @ +# Should return 2 rows +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +a b +0 0 +1 1 +DROP TABLE t1; +# +# Bug #54802: 'NOT BETWEEN' evaluation is incorrect +# +CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key)); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c_key NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_key` AS `c_key`,`test`.`t1`.`c_notkey` AS `c_notkey` from `test`.`t1` where (2 not between `test`.`t1`.`c_notkey` and `test`.`t1`.`c_key`) +SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +c_key c_notkey +1 1 +3 3 +DROP TABLE t1; +# +# Bug #57030: 'BETWEEN' evaluation is incorrect +# +CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT); +CREATE UNIQUE INDEX i4_uq ON t1(i4); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30); +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between 10 and `test`.`t1`.`i4`) +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between `test`.`t1`.`i4` and 10) +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i4_uq 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 100 and 0) +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and 99999999999999999) +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 999999999999999 and 30) +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and '20') +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +pk i4 +1 10 +2 20 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`) +EXPLAIN FORMAT=tree +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.60 rows=3) + -> Filter: (t1.i4 is not null) (cost=0.55 rows=3) + -> PQblock scan on t1 using i4_uq (cost=0.55 rows=3) + -> Filter: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.i4) (cost=0.28 rows=1) + +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +pk i4 pk i4 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`) +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +pk i4 pk i4 +DROP TABLE t1; +# +# BUG#13519696 - 62940: SELECT RESULTS VARY WITH VERSION AND +# WITH/WITHOUT INDEX RANGE SCAN +# +create table t1 (id int unsigned not null auto_increment primary key); +insert into t1 values (null); +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +create table t2 ( +id int unsigned not null auto_increment, +val decimal(5,3) not null, +primary key (id,val), +unique key (val,id), +unique key (id)); +insert into t2 select null,id*0.0009 from t1; +select count(val) from t2 ignore index (val) where val > 0.1155; +count(val) +185 +select count(val) from t2 force index (val) where val > 0.1155; +count(val) +185 +drop table t2, t1; +# +# BUG#13453382 - REGRESSION SINCE 5.1.39, RANGE OPTIMIZER WRONG +# RESULTS WITH DECIMAL CONVERSION +# +create table t1 (a int,b int,c int,primary key (a,c)); +insert into t1 values (1,1,2),(1,1,3),(1,1,4); +select convert(3, signed integer) > 2.9; +convert(3, signed integer) > 2.9 +1 +select * from t1 force index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 force index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +drop table t1; +# +# BUG#13463488 - 63437: CHAR & BETWEEN WITH INDEX RETURNS WRONG +# RESULT AFTER MYSQL 5.1. +# +CREATE TABLE t1( +F1 CHAR(5) NOT NULL, +F2 CHAR(5) NOT NULL, +F3 CHAR(5) NOT NULL, +PRIMARY KEY(F1), +INDEX IDX_F2(F2) +) COLLATE latin1_swedish_ci; +INSERT INTO t1 VALUES +('A','A','A'),('AA','AA','AA'),('AAA','AAA','AAA'), +('AAAA','AAAA','AAAA'),('AAAAA','AAAAA','AAAAA'); +SELECT * FROM t1 WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 WHERE F1 >= 'A '; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 > 'A '; +F1 F2 F3 +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F2 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F3 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND +'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +DROP TABLE t1; +End of 5.1 tests +CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1)); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT c1 FROM t1 WHERE c1 >= 'A' GROUP BY 1; +c1 +1 +2 +3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +DROP TABLE t1; +create table t1 (a int,b int,key (b),key (a),key (b,a)); +insert into t1(a,b) values (1,2),(3,4),(5,6),(7,8); +create table t2 (c int); +insert into t2(c) values (1),(5),(6),(7),(8); +select 1 from (select c from t1,t2 where b >= 1 and a <=> c group by 1 limit 1) as d1; +1 +1 +drop table t1, t2; +# +# Bug #26106: Wrong plan may be chosen when there are several possible +# range and ref accesses +# +# Note: The fix for this bug has been reverted. The code will no longer +# select the optimal plan for the two following test queries. This is +# not due to a bug but due to minor differences in range estimates +# produced by the storage engine. +CREATE TABLE t1( +a INT, +b INT, +KEY k ( a ), +KEY l ( a, b ) +); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1 +VALUES (2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3); +INSERT INTO t1 SELECT 3, 4 FROM t1 WHERE a = 2 AND b = 3; +INSERT INTO t1 SELECT 4, 1 FROM t1 WHERE a = 2 AND b = 3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +# This must use range over index l, not k. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t1 WHERE a = 1 AND b >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 129 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k,l k 5 const 129 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` >= 2)) +CREATE TABLE t2( +a INT, +b INT, +c INT, +KEY k ( a ), +KEY l ( a, b ), +KEY m ( b ), +KEY n ( a, c ) +); +INSERT INTO t2(a) VALUES (1); +INSERT INTO t2 +VALUES (2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3), +(2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3); +INSERT INTO t2 SELECT 3, 4, 4 FROM t2 WHERE a = 2 AND b = 3; +INSERT INTO t2 SELECT 4, 1, 1 FROM t2 WHERE a = 2 AND b = 3; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +INSERT INTO t2 VALUES (1, 2, 2); +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 VALUES (1, 1, 2); +# This must use range over index l, not n. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t2 WHERE a = 1 AND b >= 2 AND c >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 66 29.16 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref k,l,m,n k 5 const 66 29.16 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` >= 2) and (`test`.`t2`.`c` >= 2)) +DROP TABLE t1, t2; +# +# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER +# AWAY QUALIFYING ROWS +# +CREATE TABLE t10( +K INT NOT NULL AUTO_INCREMENT, +I INT, J INT, +PRIMARY KEY(K), +KEY(I,J) +); +INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5), +(6,6),(6,7),(6,8),(6,9),(6,0); +CREATE TABLE t100 LIKE t10; +INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y; +INSERT INTO t100(I,J) VALUES(8,26); + +EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t100 NULL range I I 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t100`.`K` AS `K`,`test`.`t100`.`I` AS `I`,`test`.`t100`.`J` AS `J` from `test`.`t100` where ((`test`.`t100`.`I` <> 6) or ((`test`.`t100`.`J` = 5) and (`test`.`t100`.`I` <> 8))) + +SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +K I J +128 8 26 +DROP TABLE t10,t100; +# +# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR +# AFTER FLUSH TABLES [-INT VS NULL] +# +CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (-100,1),(1,6); +CREATE TABLE t2 ( +col_int_key INT, +col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT", +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t2 VALUES +(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8); +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t2 NULL ref PRIMARY,col_int_key col_int_key 5 test.t1.col_int # # Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +# need FLUSH so that InnoDB statistics change and thus plan changes +FLUSH TABLES; +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_int_key NULL NULL NULL # # Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +DROP TABLE t1,t2; +# +# Bug#12694872 - +# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_date_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1 ( +col_int_key, +col_int_nokey, +col_date_key, +col_varchar_key, +col_varchar_nokey +) VALUES +(0, 4, '2011-08-25', 'j', 'j'), +(8, 6, '2004-09-18', 'v', 'v'), +(1, 3, '2009-12-01', 'c', 'c'), +(8, 5, '2004-12-17', 'm', 'm'), +(9, 3, '2000-03-14', 'd', 'd'), +(6, 2, '2006-05-25', 'y', 'y'), +(1, 9, '2008-01-23', 't', 't'), +(6, 3, '2007-06-18', 'd', 'd'), +(2, 8, '2002-10-13', 's', 's'), +(4, 1, '1900-01-01', 'r', 'r'), +(8, 8, '1959-04-25', 'm', 'm'), +(4, 8, '2006-03-09', 'b', 'b'), +(4, 5, '2001-06-05', 'x', 'x'), +(7, 7, '2006-05-28', 'g', 'g'), +(4, 5, '2001-04-19', 'p', 'p'), +(1, 1, '1900-01-01', 'q', 'q'), +(9, 6, '2004-08-20', 'w', 'w'), +(4, 2, '2004-10-10', 'd', 'd'), +(8, 9, '2000-04-02', 'e', 'e') +; +SET UNIQUE_CHECKS = 0; +SET FOREIGN_KEY_CHECKS = 0; +SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +SET FOREIGN_KEY_CHECKS = 1; +SET UNIQUE_CHECKS = 1; +CREATE TABLE t2 SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +SELECT * FROM t2 +WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +); +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +DROP TABLE t1, t2; +# +# BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == +# SAVE_READ_SET +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +PRIMARY KEY (c,a), KEY (a),KEY (a) +) ENGINE=INNODB PARTITION BY KEY () PARTITIONS 2; +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1 VALUES (1,5,1),(2,4,1),(3,3,1),(4,2,1),(5,1,1); +UPDATE t1 SET b = 0, c=1 WHERE a <=>0; +SELECT * FROM t1; +a b c +1 5 1 +2 4 1 +3 3 1 +4 2 1 +5 1 1 +DROP TABLE t1; +# +# BUG#13256446 - ASSERTION QUICK->HEAD->READ_SET == +# SAVE_READ_SET' FAILED IN OPT_RANGE.CC:1606 +# +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f2=103; +INSERT INTO t1 VALUES (154,0,NULL,0),(0,NULL,9,0), +(NULL,102,NULL,3),(0,3,NULL,0), (9,0,NULL,0),(0,9,NULL,157); +SELECT * FROM v2; +f1 f2 f3 f4 +UPDATE v2 SET f4=0, f2=NULL, f1=NULL WHERE f1 > 16 ORDER BY f1; +SELECT * FROM v2; +f1 f2 f3 f4 +DROP TABLE t1; +DROP VIEW v2; +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,NULL,NULL,0), (2,2,0,3), (9,0,107,18), +(10,0,0,0), (231,0,0,0), (232,0,8,0), (234,0,0,NULL), (235,8,0,3); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f1<=85 ; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +UPDATE v3 SET f3=0, f4=4 WHERE f2=68 ORDER BY f1; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +DROP TABLE t1; +DROP VIEW v3; +# +# BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(3),(5); +SELECT * FROM t1 WHERE pk <> 3 OR pk < 4; +pk +1 +3 +5 +DROP TABLE t1; +# +# BUG#13803810: TOO FEW ROWS RETURNED FOR RANGE ACCESS IN +# VARCHAR INDEX USING DATETIME VALUE + +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +CREATE TABLE t2 (b VARCHAR(64), KEY (b)) CHARSET utf8mb4; +INSERT INTO t2 VALUES ('2001-01-01'); +INSERT INTO t2 VALUES ('2001.01.01'); +INSERT INTO t2 VALUES ('2001#01#01'); +INSERT INTO t2 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); + +# range/ref access cannot be used for this query + +EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = (cast('2001-01-01' as date))) +SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +b +2001#01#01 +2001-01-01 +2001-01-01 00:00:00 +2001.01.01 + +# range/ref access cannot be used for any of the queries below. +# See BUG#13814468 about 'Range checked for each record' + +EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = cast(`test`.`t2`.`b` as datetime(6))) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (cast(`test`.`t2`.`b` as datetime(6)) = `test`.`t1`.`a`) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +DROP TABLE t1,t2; +# +# WL#7019: Add support for row value constructors in in predicates to +# range optimizer +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY x(a, b)); +INSERT INTO t1 VALUES (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), +(7, 7, 7), (8, 8, 8), (9, 9, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +CREATE TABLE t3 (a INT, b INT, c INT, d INT, KEY x(a, b, c)); +INSERT INTO t3 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((NULL, NULL), (NULL, NULL)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((NULL,NULL),(NULL,NULL))) +EXPLAIN SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +a b +0 0 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` where ((`test`.`t3`.`a`,`test`.`t3`.`b`,`test`.`t3`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 19.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 19.00 Using index condition; Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1) and (`test`.`t2`.`a` = 1)) or ((`test`.`t2`.`c` = 0) and (`test`.`t2`.`b` = 0) and (`test`.`t2`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`c` = 1) and (`test`.`t3`.`b` = 1) and (`test`.`t3`.`a` = 1)) or ((`test`.`t3`.`c` = 0) and (`test`.`t3`.`b` = 0) and (`test`.`t3`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +a b +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (('0',0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +SET @v = 0; +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (((@`v`),0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +CREATE TABLE t4 ( a INT, b INT ); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t4 SELECT a + 5, b + 5 FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +# Inner table in a nested-loops join +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 USING(a, b) +WHERE (t4.a, t4.b) IN ((1, 1), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 2.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 2.00 Using where +2 SIMPLE t1 NULL ref x x 10 test.t4.a,test.t4.b 409 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t4`.`b`) and (`test`.`t1`.`a` = `test`.`t4`.`a`) and ((`test`.`t4`.`a`,`test`.`t4`.`b`) in ((1,1),(0,0)))) +# Join on IN +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(0,0))) +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(1,1))) +# +# Tests for non-deterministic functions. +# +CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (f1(), 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 4098 0.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(`f1`(),1,1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,`f1`(),1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, f1())); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,1,`f1`()))) +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index x x 10 NULL 4098 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = `f1`())) +DROP FUNCTION f1; +# The statement immediately below should not use range access. +EXPLAIN +SELECT a, b +FROM t1 AS t1o +WHERE EXISTS (SELECT /*+ NO_SEMIJOIN() */ 1 +FROM t1 +WHERE (a, b) IN ((t1o.a, t1o.b)) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1o NULL index NULL x 10 NULL 4098 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref x x 10 test.t1o.a,test.t1o.b 409 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1o.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1o.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1o`.`a` AS `a`,`test`.`t1o`.`b` AS `b` from `test`.`t1` `t1o` where exists(/* select#2 */ select 1 from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1o`.`a`) and (`test`.`t1`.`b` = `test`.`t1o`.`b`))) +# +# Tests of dynamic range access +# +CREATE TABLE t5 (a int, b int, KEY (a)); +INSERT INTO t5 VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1); +CREATE TABLE t6 (a int, b int, KEY (a)); +INSERT INTO t6 VALUES (3, 2), (4, 2), (100, 100), (101, 201), (102, 102); +CREATE TABLE t7 (a int, b int, KEY (a, b)); +INSERT INTO t7 VALUES (1, 1), (2, 2), (1000, 1000), (1001, 1001), (1002, 1002), +(1003, 1003), (1004, 1004); +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and (`test`.`t7`.`a` in (`test`.`t5`.`b`,`test`.`t6`.`b`))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +a b a b a b +3 1 3 2 1 1 +3 1 3 2 2 2 +4 1 4 2 1 1 +4 1 4 2 2 2 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and ((`test`.`t7`.`a`,`test`.`t7`.`b`) in ((`test`.`t5`.`b`,1),(`test`.`t6`.`b`,1)))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +a b a b a b +3 1 3 2 1 1 +4 1 4 2 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +# +# Regression tests of the worklog below. +# +# Make sure we process IN predicates only. +# The code around this is very unclear. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) != (1, 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4098 99.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index x x 10 NULL 4098 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` <> 1) or (`test`.`t1`.`b` <> 1)) +# This should give us a ref scan, as it always did. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +EXPLAIN SELECT a, b FROM t1 WHERE (a, c) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`c` = 0) and (`test`.`t1`.`a` = 0)) +# ref scan on x(a). +EXPLAIN SELECT * FROM t1 WHERE (a, c) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`c`) in ((0,0),(1,1))) +DROP TABLE t1, t2, t3, t4, t5, t6, t7; +# +# Bug#17635476: CRASH IN GET_MM_PARTS() OR ASSERT IN +# GET_FUNC_MM_TREE_FROM_IN_PREDICATE() +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY (a) +) ENGINE = INNODB; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +INSERT INTO t1 VALUES (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), +(7, 7), (8, 8), (9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 ( +a INT, +b INT, +KEY (a, b) +); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((NULL,`test`.`t1`.`b`) in ((0,0),(1,1))) +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 10 NULL 10 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((NULL,`test`.`t2`.`b`) in ((0,0),(1,1))) +DROP TABLE t1, t2; +# +# Bug#17755540 VALGRIND ERROR WHEN SETTING UP ROW COMPARATORS +# +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT a, b FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +DROP TABLE t2; +# +# BUG#18364815: OPTIMIZER PREFERS TABLE SCAN WHEN +# USING "IN" WITH VALUE OF DIFFERENT TYPE +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,1), (5,1), (6,1); +EXPLAIN SELECT * FROM t1 WHERE a IN (1, 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE a IN (1, "2"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,'2')) +SELECT * FROM t1 WHERE a IN (1, 2); +a b +1 1 +2 1 +SELECT * FROM t1 WHERE a IN (1, "2"); +a b +1 1 +2 1 +DROP TABLE t1; +# +# Bug#18715670 +# CRASH IN DECIMAL_ACTUAL_FRACTION COMPARING DECIMAL TO NULLS +# +CREATE TABLE t1(n DECIMAL(39,19) NOT NULL, KEY(n)) engine=innodb; +INSERT INTO t1 SET n=0; +SELECT 1 FROM t1 WHERE n NOT IN(NULL, NULL); +1 +DROP TABLE t1; +# +# Bug#18759597 MISSING ROWS ON WHERE .. +# IN QUERY WITH VARIABLES AND CONCAT +# +CREATE TABLE t1 ( +col_varchar_key varchar(2), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('n'),('xm'); +SET @var1 = 't', @var2 = 'him', +@var3 = 'n', @var4 = 'n', +@var5 = 'n', @var6 = 'g', +@var7 = 'b', @var8 = 'o', +@var9 = 'm', @var10 = 'xm', @var11 = 'u' +; +SELECT col_varchar_key AS field1 +FROM t1 +WHERE ( col_varchar_key, col_varchar_key ) IN ( +('m', @var1 ), +('n', @var3 ), +('a', @var5 ), +('l', @var7 ), +(CONCAT('x', @var9 ), @var10 ) +); +field1 +n +xm +DROP TABLE t1; +# +# Bug#18535226 DEBUG CRASH ON QUICK_RANGE_SELECT::RESET +# +SET @old_tmp_table_size=@@tmp_table_size; +SET tmp_table_size=1024; +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_date_key date, +col_date_nokey date, +col_time_key time, +col_time_nokey time, +col_datetime_key datetime, +col_datetime_nokey datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(5,0,'2001-05-06','2001-05-06','16:21:18','16:21:18','2001-11-08 21:02:12', +'2001-11-08 21:02:12','x','x'),(6,7,'2006-03-03','2006-03-03','18:56:33', +'18:56:33','2003-04-01 00:00:00','2003-04-01 00:00:00','i','i'), +(7,7,'2007-12-28','2007-12-28',NULL,NULL,'1900-01-01 00:00:00', +'1900-01-01 00:00:00','e','e'),(8,1,'2004-10-20','2004-10-20','09:29:08', +'09:29:08','2007-07-12 00:00:00','2007-07-12 00:00:00','p','p'), +(9,7,'2008-04-09','2008-04-09','19:11:10','19:11:10', +'2005-04-04 01:21:01','2005-04-04 01:21:01','s','s'), +(10,1,'2005-12-25','2005-12-25','11:57:26','11:57:26', +'1900-01-01 00:00:00','1900-01-01 00:00:00','j','j'); +SELECT alias1.col_int_key +FROM +( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1, t1 AS SQ1_alias2 ) AS alias1, +(SELECT 7 AS col_int_nokey) AS alias2 +WHERE +alias2.col_int_nokey = alias1.pk +AND alias1.col_varchar_nokey < alias1.col_varchar_key +ORDER BY alias1.col_varchar_key; +col_int_key +DROP TABLE t1; +SET tmp_table_size=@old_tmp_table_size; +SET sql_mode = default; +# +# Bug#19585938 Crash in get_full_func_mm_tree with null +# item_field->table_ref +# +CREATE TABLE t1(id INTEGER, col1 INTEGER, col2 INTEGER, PRIMARY KEY(id)); +INSERT INTO t1 VALUES (1,2,3), (3,2,1); +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) < id +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id > SUM(1) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN id AND id+1 +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id BETWEEN SUM(1) AND SUM(5) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN COUNT(*) AND id +) AS c +FROM t1 +GROUP BY col1; +c +1 +DROP TABLE t1; +# +# Bug#21415791 VALGRIND ERROR (CONDITIONAL JUMP) AT KEY_AND +# (RANGE_OPT_PARAM*, SEL_ARG*, SEL_AR +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +pk INTEGER NOT NULL, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t1 ( +pk, col_varchar_10, col_int_key) VALUES +(1, 'ttttt', 0), (2, 'zzzzz', 0), (3, 'ggggg', 0), +(4, 'hhhhh', 0), (5, 'kkkkk', 0), (6, 'lllll', 0); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t2 ( +pk, col_varchar_10) VALUES +(1, '00000'), (2, '00000'), (3, '44444'), (4, '00000'), +(5, NULL), (6, NULL), (7, NULL); +SELECT COUNT(t1.col_int_key) +FROM t2 RIGHT OUTER JOIN t1 ON t2.col_varchar_10 <= t1.col_varchar_10 +WHERE t2.pk <> 4 OR t2.pk != t1.col_int_key AND t2.pk <> 1000; +COUNT(t1.col_int_key) +24 +DROP TABLE t1, t2; +# +# Bug #20229614: OR CONDITIONS ON MULTI-COLUMN INDEX MAY NOT USE ALL +# INDEX COLUMNS TO FILTER ROWS +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c3 INT, +PRIMARY KEY(c1, c2, c3) +) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 2), (1, 1, 3), +(1, 1, 4), (1, 1, 5); +INSERT INTO t1 SELECT c1, 2, c3 FROM t1; +INSERT INTO t1 SELECT c1, 3, c3 FROM t1 WHERE c2 = 1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +15 +EXPLAIN SELECT c1, c2, c3 +FROM t1 +WHERE (c1 = 1 AND c2 = 1 AND c3 = 1) OR +(c1 = 1 AND c2 = 2 AND c3 = 2) OR +(c1 = 1 AND c2 = 2 AND c3 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 12 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where (((`test`.`t1`.`c3` = 1) and (`test`.`t1`.`c2` = 1) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 3) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1))) +DROP TABLE t1; +# +# Bug#21139683: ASSERTION FAILED: TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE +# +CREATE TABLE t1 ( +a BLOB, +PRIMARY KEY(a(1)), +KEY(a(1)) +) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE a <> 'a' OR a <> ""; +1 +DROP TABLE t1; +# +# Bug#19333852: RESULT DIFF IN QUERY HAVING DISTINCT +# WITH GROUP BY +# +CREATE TABLE t1 ( +v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY v1_key (v1(10)) +) ENGINE=InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); +EXPLAIN SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` < (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v1_key v1_key 32 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` = (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` between 'f' and (char(127))) +SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +v1 pk +ABCDE 19 +JLVGO 14 +SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +v1 pk +SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +v1 pk +JLVGO 14 +DROP TABLE t1; +# +# Bug #21761867: ASSERTION `TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE' FAILED. +# +CREATE TABLE t1 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +c18 INT, +PRIMARY KEY (c10,c12), +UNIQUE KEY key_c12(c12), +KEY key_c18(c18)); +INSERT INTO t1 VALUES(11,5,0), (12,6,1), (13,7,2), (14,8,3), (15,9,4); +CREATE TABLE t2 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +PRIMARY KEY(c10,c12)); +CREATE TABLE t3 (c10 INT NOT NULL); +SELECT t2.c10 +FROM t1 +RIGHT JOIN t3 +LEFT JOIN t2 +ON t3.c10 = t2.c10 +ON t1.c12 > t2.c12 +WHERE +t1.c10 <= 25 +AND +t1.c18 IS NOT NULL +OR +t1.c10 > 5 +AND +t1.c18 IN (15,16,18); +c10 +DROP TABLE t1, t2, t3; +# +# Bug #21318711: WRONG RESULTS FOR TRUNCATED COLUMN AND AGGREGATION +# +CREATE TABLE t1 ( +col1 VARCHAR(5), +col2 INT NOT NULL, +PRIMARY KEY (col1, col2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('abcde', 10); +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where (`test`.`t1`.`col1` = 'abcdeaa') +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where multiple equal('abcde ', `test`.`t1`.`col1`) +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +MAX(col2) +NULL +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +MAX(col2) +10 +DROP TABLE t1; +# +# Bug# 22283790: RANGE OPTIMIZER UTILIZES TOO MUCH MEMORY WITH +# MANY OR CONDITIONS +# +CREATE TABLE t1 ( +f1 INTEGER, +KEY (f1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15); +SET @orig_range_optimizer_max_mem_size= @@range_optimizer_max_mem_size; +SET range_optimizer_max_mem_size= 5000; +EXPLAIN SELECT * FROM t1 WHERE f1=1 OR f1=2 OR f1=3 OR f1=4 OR f1=5 +OR f1=6 OR f1=7 OR f1=8 OR f1=9 OR f1=10 OR f1=11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range f1 f1 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` = 1) or (`test`.`t1`.`f1` = 2) or (`test`.`t1`.`f1` = 3) or (`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f1` = 5) or (`test`.`t1`.`f1` = 6) or (`test`.`t1`.`f1` = 7) or (`test`.`t1`.`f1` = 8) or (`test`.`t1`.`f1` = 9) or (`test`.`t1`.`f1` = 10) or (`test`.`t1`.`f1` = 11)) +SET range_optimizer_max_mem_size= @orig_range_optimizer_max_mem_size; +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +SELECT * FROM t1 WHERE pk IN (3, 8) OR pk NOT IN (2); +pk +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +# Indirectly tests ORing with a tree that has a nonzero refcount, +# where nodes are also being skipped over. (There was a bug in +# refcounting such trees earlier.) +# +CREATE TABLE t1 ( +col_int_key int, +pk int NOT NULL, +col_int int, +KEY test_idx (pk,col_int_key,col_int) +); +SELECT * FROM t1 WHERE +(col_int_key >= 6 AND pk > 6) OR +(pk > 2 AND col_int_key = 7 AND col_int > 6); +col_int_key pk col_int +DROP TABLE t1; +# +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE `giant_table` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`one_id` int(11) NOT NULL, +`other_id` bigint(20) NOT NULL DEFAULT '0', +`some_other_id` int(11) DEFAULT 0 NOT NULL, +`something` double NOT NULL DEFAULT '0', +`comment` text COLLATE utf8_unicode_ci, +`flags` int(11) NOT NULL DEFAULT '0', +`time_created` int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (`id`), +KEY `time_created` (`time_created`), +KEY `some_other_id` (`some_other_id`), +KEY `one_other_idx` (`one_id`,`other_id`), +KEY `other_id` (`other_id`,`time_created`) +) ENGINE=InnoDB AUTO_INCREMENT=101651329 +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (66136540), (68983250), (89627210), (77869520), +(82543190), (67538270), (77282760), (77908170), +(70923370), (68066360); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT INTO giant_table(id,one_id) +SELECT c1 + @x, 0 +FROM t1 +WHERE c1 IN (66136540, 68985250, 89627210, 77869520 , 82543190, 67538270, +77282760, 77908170, 70923370, 68066360); +SET @x = @x + 1; +UNTIL @x > 30 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM giant_table; +count(*) +270 +INSERT INTO giant_table (id,one_id) VALUES (66136539, 0), (68983258,1), +(89628210,1), (77869520,2); +INSERT INTO giant_table (id,one_id, some_other_id) VALUES(84673401, 0, 1), +(61069031, 1, 1); +EXPLAIN SELECT id, something, comment, time_created, one_id, other_id, +some_other_id, flags +FROM giant_table +WHERE id IN (66136539, 68983258, 89628210, 77869520, 82543198, 67538272, +84673401, 61069031, 68214385, 77282865, 76991297, 64569216, +89481638, 74534074, 70396537, 80076375, 63308530, 77908270, +70923271, 68066180) +AND (giant_table.flags & 0x01) = 0 AND giant_table.some_other_id = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE giant_table NULL range PRIMARY,some_other_id PRIMARY 4 NULL 20 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`giant_table`.`id` AS `id`,`test`.`giant_table`.`something` AS `something`,`test`.`giant_table`.`comment` AS `comment`,`test`.`giant_table`.`time_created` AS `time_created`,`test`.`giant_table`.`one_id` AS `one_id`,`test`.`giant_table`.`other_id` AS `other_id`,`test`.`giant_table`.`some_other_id` AS `some_other_id`,`test`.`giant_table`.`flags` AS `flags` from `test`.`giant_table` where ((`test`.`giant_table`.`some_other_id` = 0) and (`test`.`giant_table`.`id` in (66136539,68983258,89628210,77869520,82543198,67538272,84673401,61069031,68214385,77282865,76991297,64569216,89481638,74534074,70396537,80076375,63308530,77908270,70923271,68066180)) and ((`test`.`giant_table`.`flags` & 0x01) = 0)) +DROP PROCEDURE p; +DROP TABLE giant_table, t1; +# +# Bug#22671573: SIG11 IN SEL_ARG::RB_INSERT |SQL/OPT_RANGE.CC +# +# Tests creating an empty tree (impossible condition) and then ANDing with it. +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY test_idx (b, a) +); +SELECT * FROM t1 WHERE b BETWEEN 8 AND 8 AND a > 8 AND a <= 8; +a b +DROP TABLE t1; +# +# Indirectly tests inserting a node into an empty (impossible) tree. +# +CREATE TABLE t1 ( +pk INT, +PRIMARY KEY ( pk ) +); +SELECT * FROM t1 WHERE pk = 6 OR pk > 6; +pk +DROP TABLE t1; +# +# Indirectly tests ORing with an empty (impossible) tree. +# +CREATE TABLE t1 ( +col_int_key INT, +KEY (col_int_key) +); +SELECT * FROM t1 WHERE col_int_key IS NULL OR col_int_key < 9 OR col_int_key = 9; +col_int_key +DROP TABLE t1; +# +# Indirectly tests deleting the last node from a tree +# (which makes it IMPOSSIBLE) and then inserting more than one node. +# +CREATE TABLE t1 ( +a VARCHAR(64), +KEY a (a) +); +SELECT * FROM t1 WHERE a IS NULL OR a NOT IN ( 'foo', 'bar' ); +a +DROP TABLE t1; +# +# Bug#25229315: ASSERTION TABLE->M_RECORD_BUFFER.RECORD_SIZE() == +# RECORD_PREFIX_SIZE(TAB)' FAIL +# +CREATE TABLE t1 (pk INT PRIMARY KEY, vc VARCHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, NULL), (2, 'w'); +CREATE TABLE t2 ( +i INT, +vc VARCHAR(1), +pk INT PRIMARY KEY, +KEY (i), +KEY (vc) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 'p', 1), (9, 'w', 2), (NULL, 'r', 3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL i,vc NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x6) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`vc` = `test`.`t1`.`vc`) or (`test`.`t2`.`i` = `test`.`t1`.`pk`)) +SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +MIN(t1.pk) +1 +DROP TABLE t1, t2; +# +# Bug #26727773: OPTIMIZER CHOSES COMPOSITE INDEX FOR REF OVER RANGE +# +CREATE TABLE transactions ( +app_trans_id INT DEFAULT NULL, +id INT NOT NULL, +tbl INT NOT NULL DEFAULT 1, +created TIMESTAMP NOT NULL DEFAULT '2017-01-01 01:01:01', +trans_type INT NOT NULL, +description BLOB, +source_lvl1 INT DEFAULT NULL, +source_lvl2 INT DEFAULT NULL, +KEY tbl_id_idx (tbl,id), +KEY created_idx (created), +KEY trans_type_created_idx (trans_type,created), +KEY app_trans_id_idx (app_trans_id) +) ENGINE=INNODB ; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1000), (2000), (3000), (4000), (5000), (6000), +(7000), (8000), (9000); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT IGNORE INTO transactions(id,trans_type, description) +SELECT c1 + @x, @x , 'abcd' + FROM t1; +SET @x = @x + 1; +UNTIL @x > 300 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM transactions; +count(*) +3000 +INSERT IGNORE INTO transactions(id,trans_type, description, created) +SELECT 3, 3 , 'abcd', '2018-01-01 01:01:01' + FROM dual; +EXPLAIN SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE transactions NULL range tbl_id_idx,created_idx,trans_type_created_idx created_idx 4 NULL # # Using index condition; Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select '2017-10-23 01:01:01' AS `2017-10-23 01:01:01`,hour(`test`.`transactions`.`created`) AS `HOUR(created)`,`test`.`transactions`.`source_lvl1` AS `source_lvl1`,`test`.`transactions`.`source_lvl2` AS `source_lvl2`,count(distinct `test`.`transactions`.`app_trans_id`) AS `COUNT(DISTINCT(app_trans_id))` from `test`.`transactions` where ((`test`.`transactions`.`trans_type` = 3) and (`test`.`transactions`.`tbl` = 1) and (`test`.`transactions`.`created` > TIMESTAMP'2017-10-23 01:01:01')) group by '2017-10-23 01:01:01',hour(`test`.`transactions`.`created`),`test`.`transactions`.`source_lvl1`,`test`.`transactions`.`source_lvl2` +SET optimizer_trace="enabled=on"; +SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +2017-10-23 01:01:01 HOUR(created) source_lvl1 source_lvl2 COUNT(DISTINCT(app_trans_id)) +2017-10-23 01:01:01 1 NULL NULL 0 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +SET optimizer_trace="enabled=off"; +DROP PROCEDURE p; +DROP TABLE t1, transactions; +# +# Bug #28086754: OPTIMIZER SKIP THE RANG SCAN ON SECOND COLUMN IN A +# COMPOSITE INDEX +# +CREATE TABLE test_ref ( +a INT PRIMARY KEY, +b VARCHAR(20), +c VARCHAR(20) DEFAULT NULL, +d VARCHAR(3) DEFAULT NULL, +id INT DEFAULT NULL, +KEY idx1 (id, c), +KEY idx2 (id, d)) ENGINE=INNODB ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze Error Table 'test.t1' doesn't exist +test.t1 analyze status Operation failed +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c`,`test`.`test_ref`.`a` limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +a b c d id +34876 D003 gheennse S 3 +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using index condition; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c` desc,`test`.`test_ref`.`a` desc limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +a b c d id +1770649 D003 gheennse S 3 +DROP TABLE test_ref; +# +# Bug #30988735: SELECT QUERY WITH ERROR RESULT WITH "NOT IN" +# WHERE_CLAUSE +# +CREATE TABLE t(f1 INTEGER key, f2 INTEGER)ENGINE=INNODB; +INSERT INTO t VALUES(0,0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT f1,f2 FROM t WHERE f1 NOT IN(-0.1,0.1); +f1 f2 +0 0 +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/range_icp_mrr.result-pq b/mysql-test/r/range_icp_mrr.result-pq new file mode 100644 index 000000000..9aace8e15 --- /dev/null +++ b/mysql-test/r/range_icp_mrr.result-pq @@ -0,0 +1,3997 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2, t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +event_date date DEFAULT '0000-00-00' NOT NULL, +type int(11) DEFAULT '0' NOT NULL, +event_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (event_date,type,event_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25), +('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26), +('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45), +('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5), +('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17), +('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40), +('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6), +('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41), +('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41), +('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29), +('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19), +('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42), +('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30), +('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8), +('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22), +('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43), +('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37), +('1999-09-19',100100,37), ('2000-12-18',100700,38); +explain select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 19.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 7 NULL 6 19.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where ((`test`.`t1`.`event_date` >= DATE'1999-07-01') and (`test`.`t1`.`event_date` < DATE'1999-07-15') and ((`test`.`t1`.`type` = 100600) or (`test`.`t1`.`type` = 100100))) order by `test`.`t1`.`event_date` +explain format=tree select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +EXPLAIN +-> Parallel scan on + -> Filter: ((t1.event_date >= DATE'1999-07-01') and (t1.event_date < DATE'1999-07-15') and ((t1.`type` = 100600) or (t1.`type` = 100100))) (cost=1.46 rows=1) + -> PQblock range scan on t1 using PRIMARY (cost=1.46 rows=6) + +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where false order by `test`.`t1`.`event_date` +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +1999-07-15 100600 16 +drop table t1; +CREATE TABLE t1 ( +PAPER_ID smallint(6) DEFAULT '0' NOT NULL, +YEAR smallint(6) DEFAULT '0' NOT NULL, +ISSUE smallint(6) DEFAULT '0' NOT NULL, +CLOSED tinyint(4) DEFAULT '0' NOT NULL, +ISS_DATE date DEFAULT '0000-00-00' NOT NULL, +PRIMARY KEY (PAPER_ID,YEAR,ISSUE) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'), +(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'), +(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'), +(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'), +(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'), +(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'), +(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'), +(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'), +(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'), +(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'), +(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'), +(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'), +(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'), +(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'), +(3,1999,35,0,'1999-07-12'); +select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE; +YEAR ISSUE +1999 29 +1999 30 +1999 31 +1999 32 +1999 33 +1999 34 +1999 35 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair note The storage engine for the table doesn't support repair +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2), +(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2), +(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1), +(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2), +(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2), +(19,3,2), (5,1,1), (179,5,2); +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +drop table t1; +create table t1( +Satellite varchar(25) not null, +SensorMode varchar(25) not null, +FullImageCornersUpperLeftLongitude double not null, +FullImageCornersUpperRightLongitude double not null, +FullImageCornersUpperRightLatitude double not null, +FullImageCornersLowerRightLatitude double not null, +index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude)); +insert into t1 values("OV-3","PAN1",91,-92,40,50); +insert into t1 values("OV-4","PAN1",91,-92,40,50); +select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000; +Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude +OV-3 PAN1 91 -92 40 50 +drop table t1; +create table t1 ( aString char(100) not null default "", key aString (aString(10)) ); +insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love"); +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +alter table t1 drop key aString; +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +drop table t1; +CREATE TABLE t1 ( +t1ID int(10) unsigned NOT NULL auto_increment, +art binary(1) NOT NULL default '', +KNR char(5) NOT NULL default '', +RECHNR char(6) NOT NULL default '', +POSNR char(2) NOT NULL default '', +ARTNR char(10) NOT NULL default '', +TEX char(70) NOT NULL default '', +PRIMARY KEY (t1ID), +KEY IdxArt (art), +KEY IdxKnr (KNR), +KEY IdxArtnr (ARTNR) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'); +select count(*) from t1 where upper(art) = 'J'; +count(*) +213 +select count(*) from t1 where art = 'J' or art = 'j'; +count(*) +602 +select count(*) from t1 where art = 'j' or art = 'J'; +count(*) +602 +select count(*) from t1 where art = 'j'; +count(*) +389 +select count(*) from t1 where art = 'J'; +count(*) +213 +drop table t1; +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` between 7 and ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` >= 7) and (`test`.`t2`.`x` <= ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between ((2 - 1)) and ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= ((2 - 1))) and (`test`.`t2`.`x` <= ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between 0 and 2)) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using index condition; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= 0) and (`test`.`t2`.`x` <= 2)) +explain select count(*) from t1 where x in (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` = 1) +explain select count(*) from t1 where x in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` in (1,2)) +drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +explain select * from t1 force index(i1), t2 force index(j1) where +(t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` FORCE INDEX (`i1`) join `test`.`t2` FORCE INDEX (`j1`) where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a), +KEY b (b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), +(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), +(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), +(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a,b a 5 NULL 2 40.54 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` in (1,2))) +SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +a b +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) +); +a b +15 1 +47 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id int( 11 ) unsigned NOT NULL AUTO_INCREMENT , +line int( 5 ) unsigned NOT NULL default '0', +columnid int( 3 ) unsigned NOT NULL default '0', +owner int( 3 ) unsigned NOT NULL default '0', +ordinal int( 3 ) unsigned NOT NULL default '0', +showid smallint( 6 ) unsigned NOT NULL default '1', +tableid int( 1 ) unsigned NOT NULL default '1', +content int( 5 ) unsigned NOT NULL default '188', +PRIMARY KEY ( owner, id ) , +KEY menu( owner, showid, columnid ) , +KEY `COLUMN` ( owner, columnid, line ) , +KEY `LINES` ( owner, tableid, content, id ) , +KEY recount( owner, line ) +) ENGINE = MYISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); +SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; +id columnid tableid content showid line ordinal +13 13 1 188 1 5 0 +15 15 1 188 1 1 0 +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select id from t1 where id in (2,5,9) ; +id +2 +5 +9 +select id from t1 where id=2 or id=5 or id=9 ; +id +2 +5 +9 +drop table t1; +create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2)); +insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), +(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"), +(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"), +(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"), +(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"), +(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"), +(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa"); +select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; +id1 idnull +drop table t1; +create table t1 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +create table t2 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +insert into t1(id, uid, name) values(1, 0, ' '); +insert into t1(uid, name) values(0, ' '); +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +delete from t2; +insert into t2(uid, name) values +(1, CHAR(64+1)), +(2, CHAR(64+2)), +(3, CHAR(64+3)), +(4, CHAR(64+4)), +(5, CHAR(64+5)), +(6, CHAR(64+6)), +(7, CHAR(64+7)), +(8, CHAR(64+8)), +(9, CHAR(64+9)), +(10, CHAR(64+10)), +(11, CHAR(64+11)), +(12, CHAR(64+12)), +(13, CHAR(64+13)), +(14, CHAR(64+14)), +(15, CHAR(64+15)), +(16, CHAR(64+16)), +(17, CHAR(64+17)), +(18, CHAR(64+18)), +(19, CHAR(64+19)), +(20, CHAR(64+20)), +(21, CHAR(64+21)), +(22, CHAR(64+22)), +(23, CHAR(64+23)), +(24, CHAR(64+24)), +(25, CHAR(64+25)), +(26, CHAR(64+26)); +insert into t1(uid, name) select uid, name from t2 order by uid; +delete from t2; +insert into t2(id, uid, name) select id, uid, name from t1; +select count(*) from t1; +count(*) +1026 +select count(*) from t2; +count(*) +1026 +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using index condition; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +drop table t1,t2; +create table t1 (x bigint unsigned not null); +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +create table t2 (x bigint not null); +insert into t2(x) values (-16); +insert into t2(x) values (-15); +select * from t2; +x +-16 +-15 +select count(*) from t2 where x>0; +count(*) +0 +select count(*) from t2 where x=0; +count(*) +0 +select count(*) from t2 where x<0; +count(*) +2 +select count(*) from t2 where x < -16; +count(*) +0 +select count(*) from t2 where x = -16; +count(*) +1 +select count(*) from t2 where x > -16; +count(*) +1 +select count(*) from t2 where x = 18446744073709551601; +count(*) +0 +drop table t1,t2; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +create table t1 (a bigint unsigned); +create index t1i on t1(a); +insert into t1 select 18446744073709551615; +insert into t1 select 18446744073709551614; +explain select * from t1 where a <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a <> -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1 or a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1 or a < -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where a < -1; +a +drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 11 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 'aaa') +explain select * from t1 where a=binary 'aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using index condition; Using MRR +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (cast('aaa' as char charset binary))) +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using index condition; Using MRR +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_bin))) +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 9 11.11 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_german1_ci))) +drop table t1; +CREATE TABLE t1 ( +`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', +`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTINT` int(11) NOT NULL default '0', +KEY `VERI_CLNT~2` (`ARG1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0), +('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0), +('001',' 3',' 0','Text 017',0); +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2'); +count(*) +4 +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1'); +count(*) +4 +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( +pk1 int(11) NOT NULL, +pk2 int(11) NOT NULL, +pk3 int(11) NOT NULL, +pk4 int(11) NOT NULL, +filler char(82), +PRIMARY KEY (pk1,pk2,pk3,pk4) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B; +INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'), +(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'), +(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler'); +SELECT * FROM t2 +WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635))) +OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635)))) +) AND (pk3 >=1000000); +pk1 pk2 pk3 pk4 filler +2621 2635 1000015 0 filler +drop table t1, t2; +create table t1(a char(2), key(a(1))) charset utf8mb4; +insert into t1 values ('x'), ('xx'); +explain select a from t1 where a > 'x'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'x') +select a from t1 where a > 'x'; +a +xx +drop table t1; +CREATE TABLE t1 ( +OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid', +OXLEFT int NOT NULL DEFAULT '0', +OXRIGHT int NOT NULL DEFAULT '0', +OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +PRIMARY KEY (OXID), +KEY OXNID (OXID), +KEY OXLEFT (OXLEFT), +KEY OXRIGHT (OXRIGHT), +KEY OXROOTID (OXROOTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'), +('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725521'); +EXPLAIN +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE v NULL ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 100.00 NULL +1 SIMPLE s NULL ref OXLEFT,OXROOTID OXROOTID 34 const 5 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`OXID` AS `oxid` from `test`.`t1` `v` join `test`.`t1` `s` where ((`test`.`s`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`v`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`s`.`OXLEFT` > `test`.`v`.`OXLEFT`) and (`test`.`s`.`OXLEFT` < `test`.`v`.`OXRIGHT`)) +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +oxid +d8c4177d151affab2.81582770 +d8c4177d206a333d2.74422679 +d8c4177d225791924.30714720 +d8c4177d2380fc201.39666693 +d8c4177d24ccef970.14957924 +DROP TABLE t1; +create table t1 ( +c1 char(10), c2 char(10), c3 char(10), c4 char(10), +c5 char(10), c6 char(10), c7 char(10), c8 char(10), +c9 char(10), c10 char(10), c11 char(10), c12 char(10), +c13 char(10), c14 char(10), c15 char(10), c16 char(10), +index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); +select * from t1 where +c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 +Warnings: +Warning 3170 Memory capacity of 8388608 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +drop table t1; +End of 4.1 tests +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +status varchar(20), +PRIMARY KEY (id), +KEY (status) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'), +(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'), +(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'), +(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'), +(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'), +(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'), +(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'), +(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'), +(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'), +(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C'); +EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not between 'A' and 'B') +EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` < 'A') or (`test`.`t1`.`status` > 'B')) +SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, primary key(a,b)); +INSERT INTO t1 VALUES +(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3); +CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3; +EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +SELECT a,b FROM t1 WHERE a < 2 and b=3; +a b +1 3 +SELECT a,b FROM v1 WHERE a < 2 and b=3; +a b +1 3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name)); +INSERT INTO t1 VALUES ('Betty'), ('Anna'); +SELECT * FROM t1; +name +Anna +Betty +DELETE FROM t1 WHERE name NOT LIKE 'A%a'; +SELECT * FROM t1; +name +Anna +DROP TABLE t1; +CREATE TABLE t1 (a int, KEY idx(a)); +INSERT INTO t1 VALUES (NULL), (1), (2), (3); +SELECT * FROM t1; +a +NULL +1 +2 +3 +DELETE FROM t1 WHERE NOT(a <=> 2); +SELECT * FROM t1; +a +2 +DROP TABLE t1; +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); +explain select * from t1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from v1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +explain select * from v1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +drop view v1; +drop table t1; +create table t3 (a int); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a varchar(10), filler char(200), key(a)) charset=binary; +insert into t1 values ('a',''); +insert into t1 values ('a ',''); +insert into t1 values ('a ', ''); +insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), '' + from t3 A, t3 B, t3 C; +create table t2 (a varchar(10), filler char(200), key(a)) charset utf8mb4; +insert into t2 select * from t1; +explain select * from t1 where a between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` between 'a' and 'a ') +explain select * from t1 where a = 'a' or a='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') or (`test`.`t1`.`a` = 'a ')) +explain select * from t2 where a between 'a' and 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` between 'a' and 'A') +explain select * from t2 where a = 'a' or a='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') or (`test`.`t2`.`a` = 'A')) +update t1 set a='b' where a<>'a'; +explain select * from t1 where a not between 'b' and 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` not between 'b' and 'b') +select a, hex(filler) from t1 where a not between 'b' and 'b'; +a hex(filler) +a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +drop table t1,t2,t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, key(a)); +insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C; +set @a="select * from t2 force index (a) where a NOT IN(0"; +select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z; +count(*) +1000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @a=concat(@a, ')'); +insert into t2 values (11),(13),(15); +set @b= concat("explain ", @a); +prepare stmt1 from @b; +execute stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1003 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,604,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,784,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1146,1148,1150,1152,1154,1156,1158,1160,1162,1164,1166,1168,1170,1172,1174,1176,1178,1180,1182,1184,1186,1188,1190,1192,1194,1196,1198,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222,1224,1226,1228,1230,1232,1234,1236,1238,1240,1242,1244,1246,1248,1250,1252,1254,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292,1294,1296,1298,1300,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1370,1372,1374,1376,1378,1380,1382,1384,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408,1410,1412,1414,1416,1418,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458,1460,1462,1464,1466,1468,1470,1472,1474,1476,1478,1480,1482,1484,1486,1488,1490,1492,1494,1496,1498,1500,1502,1504,1506,1508,1510,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1552,1554,1556,1558,1560,1562,1564,1566,1568,1570,1572,1574,1576,1578,1580,1582,1584,1586,1588,1590,1592,1594,1596,1598,1600,1602,1604,1606,1608,1610,1612,1614,1616,1618,1620,1622,1624,1626,1628,1630,1632,1634,1636,1638,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678,1680,1682,1684,1686,1688,1690,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1714,1716,1718,1720,1722,1724,1726,1728,1730,1732,1734,1736,1738,1740,1742,1744,1746,1748,1750,1752,1754,1756,1758,1760,1762,1764,1766,1768,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790,1792,1794,1796,1798,1800,1802,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822,1824,1826,1828,1830,1832,1834,1836,1838,1840,1842,1844,1846,1848,1850,1852,1854,1856,1858,1860,1862,1864,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1886,1888,1890,1892,1894,1896,1898,1900,1902,1904,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1964,1966,1968,1970,1972,1974,1976,1978,1980,1982,1984,1986,1988,1990,1992,1994,1996,1998)) +prepare stmt1 from @a; +execute stmt1; +a +11 +13 +15 +drop table t1, t2; +CREATE TABLE t1 ( +id int NOT NULL DEFAULT '0', +b int NOT NULL DEFAULT '0', +c int NOT NULL DEFAULT '0', +INDEX idx1(b,c), INDEX idx2(c)); +INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(b,c) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` <= 3) and (3 <= `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (3 between `test`.`t1`.`b` and `test`.`t1`.`c`) +SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((0 < `test`.`t1`.`b`) or (0 > `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (0 not between `test`.`t1`.`b` and `test`.`t1`.`c`) +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +EXPLAIN +-> Filter: (0 not between t1.b and t1.c) (cost=2.15 rows=3) + -> Index range scan on t1 using sort_union(idx1,idx2) (cost=2.15 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( +item char(20) NOT NULL default '', +started datetime NOT NULL default '0000-00-00 00:00:00', +price decimal(16,3) NOT NULL default '0.000', +PRIMARY KEY (item,started) +) ENGINE=MyISAM, CHARSET utf8mb4; +INSERT INTO t1 VALUES +('A1','2005-11-01 08:00:00',1000), +('A1','2005-11-15 00:00:00',2000), +('A1','2005-12-12 08:00:00',3000), +('A2','2005-12-01 08:00:00',1000); +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP INDEX `PRIMARY` ON t1; +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP TABLE t1; + +BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly" + +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +dateval date default NULL, +PRIMARY KEY (id), +KEY dateval (dateval) +) AUTO_INCREMENT=173; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'), +(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'), +(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11'); +This must use range access: +explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range dateval dateval 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`dateval` AS `dateval` from `test`.`t1` where ((`test`.`t1`.`dateval` >= DATE'2007-01-01') and (`test`.`t1`.`dateval` <= DATE'2007-01-02')) +drop table t1; +CREATE TABLE t1 ( +a varchar(32), index (a) +) DEFAULT CHARSET=latin1 COLLATE=latin1_bin; +INSERT INTO t1 VALUES +('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'); +SELECT a FROM t1 WHERE a='b' OR a='B'; +a +B +B +EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 35 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'b') or (`test`.`t1`.`a` = 'B')) +DROP TABLE t1; +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); +SELECT COUNT(*) FROM t1 WHERE f1 < 256; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 256.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 255; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 < -1; +COUNT(*) +0 +SELECT COUNT(*) FROM t1 WHERE f1 > -1; +COUNT(*) +5 +DROP TABLE t1; +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); +SELECT COUNT(*) FROM t1 WHERE f1 < 128; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 128.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 127; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 > -129; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -129.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -128; +COUNT(*) +4 +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100)); +insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, +t1 B, t1 C where A.a < 5; +insert into t2 select 1000, b, 'filler' from t2; +alter table t2 add index (a,b); +Access method can be range/ALL with #rows >= 500. +Or it can be ref with #rows = 2, only when there is memory limit. +explain select * from t2 where a=1000 and b<11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 500 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range a a 10 NULL 500 100.00 Using index condition; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 1000) and (`test`.`t2`.`b` < 11)) +drop table t1, t2; +CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t3( a INT, b INT, KEY( a, b ) ); +INSERT INTO t1( a, b ) +VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7); +INSERT INTO t2( a, b ) +VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1), +( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1), +(11, 1), (12, 1), (13, 1), (14, 1), (15, 1), +(16, 1), (17, 1), (18, 1), (19, 1), (20, 1); +INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t3 +VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), +(6, 0), (7, 0), (8, 0), (9, 0), (10, 0); +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 < `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 1) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +5 2 +6 1 +6 2 +7 1 +7 2 +8 1 +8 2 +9 1 +9 2 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 2) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +a b +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +EXPLAIN +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`b` = 3) and (5 <= `test`.`t3`.`a`) and (`test`.`t3`.`a` < 10)) or (`test`.`t3`.`a` < 5) or (`test`.`t3`.`a` < 10)) +DROP TABLE t1, t2, t3; +# +# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL); +a +DROP TABLE t1; +# +# Bug#47925: regression of range optimizer and date comparison in 5.1.39! +# +CREATE TABLE t1 ( a DATE, KEY ( a ) ); +CREATE TABLE t2 ( a DATETIME, KEY ( a ) ); +# Make optimizer choose range scan +INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22'); +INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23'); +INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'), +('2009-09-22 12:00:00'); +INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'), +('2009-09-23 12:00:00'); +# DATE vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# DATE vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923120000'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923120000; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923000000'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923000000; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# Test of the new get_date_from_str implementation +# Behavior differs slightly between the trunk and mysql-pe. +# The former may give errors for the truncated values, while the latter +# gives warnings. The purpose of this test is not to interfere, and only +# preserve existing behavior. +# This case was made obsolete after the changes applied by +# Bug#28940878 WRONG RESULT WHEN COMPARING DATE[TIME] WITH STRING +# as we don't fallback anymore to string comparison if the date is invalid. +SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND +str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND +str_to_date('2007-20-00', '%Y-%m-%d') <= ''; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; +str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''; +str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +SELECT str_to_date('', '%Y-%m-%d'); +str_to_date('', '%Y-%m-%d') +0000-00-00 +DROP TABLE t1, t2; +# +# Bug#48459: valgrind errors with query using 'Range checked for each +# record' +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY ( c ), +KEY ( d, a, b ( 2 ) ), +KEY ( b ( 1 ) ) +); +INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ), +( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 ); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY ( e ) +); +INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL ); +# Should not give Valgrind warnings +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug #48665: sql-bench's insert test fails due to wrong result +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (0,0), (1,1); +EXPLAIN +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +@ @ @ NULL ALL @ @ @ @ @ 100.00 @ +@ @ @ NULL range @ @ @ @ @ 100.00 @ +Warnings: +@ @ @ +# Should return 2 rows +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +a b +0 0 +1 1 +DROP TABLE t1; +# +# Bug #54802: 'NOT BETWEEN' evaluation is incorrect +# +CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key)); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c_key NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_key` AS `c_key`,`test`.`t1`.`c_notkey` AS `c_notkey` from `test`.`t1` where (2 not between `test`.`t1`.`c_notkey` and `test`.`t1`.`c_key`) +SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +c_key c_notkey +1 1 +3 3 +DROP TABLE t1; +# +# Bug #57030: 'BETWEEN' evaluation is incorrect +# +CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT); +CREATE UNIQUE INDEX i4_uq ON t1(i4); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30); +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between 10 and `test`.`t1`.`i4`) +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between `test`.`t1`.`i4` and 10) +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i4_uq 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 100 and 0) +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and 99999999999999999) +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 999999999999999 and 30) +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and '20') +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +pk i4 +1 10 +2 20 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`) +EXPLAIN FORMAT=tree +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.60 rows=3) + -> Filter: (t1.i4 is not null) (cost=0.55 rows=3) + -> PQblock scan on t1 using i4_uq (cost=0.55 rows=3) + -> Filter: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.i4) (cost=0.28 rows=1) + +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +pk i4 pk i4 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`) +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +pk i4 pk i4 +DROP TABLE t1; +# +# BUG#13519696 - 62940: SELECT RESULTS VARY WITH VERSION AND +# WITH/WITHOUT INDEX RANGE SCAN +# +create table t1 (id int unsigned not null auto_increment primary key); +insert into t1 values (null); +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +create table t2 ( +id int unsigned not null auto_increment, +val decimal(5,3) not null, +primary key (id,val), +unique key (val,id), +unique key (id)); +insert into t2 select null,id*0.0009 from t1; +select count(val) from t2 ignore index (val) where val > 0.1155; +count(val) +185 +select count(val) from t2 force index (val) where val > 0.1155; +count(val) +185 +drop table t2, t1; +# +# BUG#13453382 - REGRESSION SINCE 5.1.39, RANGE OPTIMIZER WRONG +# RESULTS WITH DECIMAL CONVERSION +# +create table t1 (a int,b int,c int,primary key (a,c)); +insert into t1 values (1,1,2),(1,1,3),(1,1,4); +select convert(3, signed integer) > 2.9; +convert(3, signed integer) > 2.9 +1 +select * from t1 force index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 force index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +drop table t1; +# +# BUG#13463488 - 63437: CHAR & BETWEEN WITH INDEX RETURNS WRONG +# RESULT AFTER MYSQL 5.1. +# +CREATE TABLE t1( +F1 CHAR(5) NOT NULL, +F2 CHAR(5) NOT NULL, +F3 CHAR(5) NOT NULL, +PRIMARY KEY(F1), +INDEX IDX_F2(F2) +) COLLATE latin1_swedish_ci; +INSERT INTO t1 VALUES +('A','A','A'),('AA','AA','AA'),('AAA','AAA','AAA'), +('AAAA','AAAA','AAAA'),('AAAAA','AAAAA','AAAAA'); +SELECT * FROM t1 WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 WHERE F1 >= 'A '; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 > 'A '; +F1 F2 F3 +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F2 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F3 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND +'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +DROP TABLE t1; +End of 5.1 tests +CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1)); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT c1 FROM t1 WHERE c1 >= 'A' GROUP BY 1; +c1 +1 +2 +3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +DROP TABLE t1; +create table t1 (a int,b int,key (b),key (a),key (b,a)); +insert into t1(a,b) values (1,2),(3,4),(5,6),(7,8); +create table t2 (c int); +insert into t2(c) values (1),(5),(6),(7),(8); +select 1 from (select c from t1,t2 where b >= 1 and a <=> c group by 1 limit 1) as d1; +1 +1 +drop table t1, t2; +# +# Bug #26106: Wrong plan may be chosen when there are several possible +# range and ref accesses +# +# Note: The fix for this bug has been reverted. The code will no longer +# select the optimal plan for the two following test queries. This is +# not due to a bug but due to minor differences in range estimates +# produced by the storage engine. +CREATE TABLE t1( +a INT, +b INT, +KEY k ( a ), +KEY l ( a, b ) +); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1 +VALUES (2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3); +INSERT INTO t1 SELECT 3, 4 FROM t1 WHERE a = 2 AND b = 3; +INSERT INTO t1 SELECT 4, 1 FROM t1 WHERE a = 2 AND b = 3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +# This must use range over index l, not k. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t1 WHERE a = 1 AND b >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 129 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k,l k 5 const 129 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` >= 2)) +CREATE TABLE t2( +a INT, +b INT, +c INT, +KEY k ( a ), +KEY l ( a, b ), +KEY m ( b ), +KEY n ( a, c ) +); +INSERT INTO t2(a) VALUES (1); +INSERT INTO t2 +VALUES (2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3), +(2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3); +INSERT INTO t2 SELECT 3, 4, 4 FROM t2 WHERE a = 2 AND b = 3; +INSERT INTO t2 SELECT 4, 1, 1 FROM t2 WHERE a = 2 AND b = 3; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +INSERT INTO t2 VALUES (1, 2, 2); +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 VALUES (1, 1, 2); +# This must use range over index l, not n. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t2 WHERE a = 1 AND b >= 2 AND c >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 66 29.16 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref k,l,m,n k 5 const 66 29.16 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` >= 2) and (`test`.`t2`.`c` >= 2)) +DROP TABLE t1, t2; +# +# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER +# AWAY QUALIFYING ROWS +# +CREATE TABLE t10( +K INT NOT NULL AUTO_INCREMENT, +I INT, J INT, +PRIMARY KEY(K), +KEY(I,J) +); +INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5), +(6,6),(6,7),(6,8),(6,9),(6,0); +CREATE TABLE t100 LIKE t10; +INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y; +INSERT INTO t100(I,J) VALUES(8,26); + +EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t100 NULL range I I 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t100`.`K` AS `K`,`test`.`t100`.`I` AS `I`,`test`.`t100`.`J` AS `J` from `test`.`t100` where ((`test`.`t100`.`I` <> 6) or ((`test`.`t100`.`J` = 5) and (`test`.`t100`.`I` <> 8))) + +SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +K I J +128 8 26 +DROP TABLE t10,t100; +# +# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR +# AFTER FLUSH TABLES [-INT VS NULL] +# +CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (-100,1),(1,6); +CREATE TABLE t2 ( +col_int_key INT, +col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT", +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t2 VALUES +(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8); +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t2 NULL ref PRIMARY,col_int_key col_int_key 5 test.t1.col_int # # Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +# need FLUSH so that InnoDB statistics change and thus plan changes +FLUSH TABLES; +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_int_key NULL NULL NULL # # Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +DROP TABLE t1,t2; +# +# Bug#12694872 - +# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_date_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1 ( +col_int_key, +col_int_nokey, +col_date_key, +col_varchar_key, +col_varchar_nokey +) VALUES +(0, 4, '2011-08-25', 'j', 'j'), +(8, 6, '2004-09-18', 'v', 'v'), +(1, 3, '2009-12-01', 'c', 'c'), +(8, 5, '2004-12-17', 'm', 'm'), +(9, 3, '2000-03-14', 'd', 'd'), +(6, 2, '2006-05-25', 'y', 'y'), +(1, 9, '2008-01-23', 't', 't'), +(6, 3, '2007-06-18', 'd', 'd'), +(2, 8, '2002-10-13', 's', 's'), +(4, 1, '1900-01-01', 'r', 'r'), +(8, 8, '1959-04-25', 'm', 'm'), +(4, 8, '2006-03-09', 'b', 'b'), +(4, 5, '2001-06-05', 'x', 'x'), +(7, 7, '2006-05-28', 'g', 'g'), +(4, 5, '2001-04-19', 'p', 'p'), +(1, 1, '1900-01-01', 'q', 'q'), +(9, 6, '2004-08-20', 'w', 'w'), +(4, 2, '2004-10-10', 'd', 'd'), +(8, 9, '2000-04-02', 'e', 'e') +; +SET UNIQUE_CHECKS = 0; +SET FOREIGN_KEY_CHECKS = 0; +SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +SET FOREIGN_KEY_CHECKS = 1; +SET UNIQUE_CHECKS = 1; +CREATE TABLE t2 SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +SELECT * FROM t2 +WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +); +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +DROP TABLE t1, t2; +# +# BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == +# SAVE_READ_SET +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +PRIMARY KEY (c,a), KEY (a),KEY (a) +) ENGINE=INNODB PARTITION BY KEY () PARTITIONS 2; +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1 VALUES (1,5,1),(2,4,1),(3,3,1),(4,2,1),(5,1,1); +UPDATE t1 SET b = 0, c=1 WHERE a <=>0; +SELECT * FROM t1; +a b c +1 5 1 +2 4 1 +3 3 1 +4 2 1 +5 1 1 +DROP TABLE t1; +# +# BUG#13256446 - ASSERTION QUICK->HEAD->READ_SET == +# SAVE_READ_SET' FAILED IN OPT_RANGE.CC:1606 +# +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f2=103; +INSERT INTO t1 VALUES (154,0,NULL,0),(0,NULL,9,0), +(NULL,102,NULL,3),(0,3,NULL,0), (9,0,NULL,0),(0,9,NULL,157); +SELECT * FROM v2; +f1 f2 f3 f4 +UPDATE v2 SET f4=0, f2=NULL, f1=NULL WHERE f1 > 16 ORDER BY f1; +SELECT * FROM v2; +f1 f2 f3 f4 +DROP TABLE t1; +DROP VIEW v2; +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,NULL,NULL,0), (2,2,0,3), (9,0,107,18), +(10,0,0,0), (231,0,0,0), (232,0,8,0), (234,0,0,NULL), (235,8,0,3); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f1<=85 ; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +UPDATE v3 SET f3=0, f4=4 WHERE f2=68 ORDER BY f1; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +DROP TABLE t1; +DROP VIEW v3; +# +# BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(3),(5); +SELECT * FROM t1 WHERE pk <> 3 OR pk < 4; +pk +1 +3 +5 +DROP TABLE t1; +# +# BUG#13803810: TOO FEW ROWS RETURNED FOR RANGE ACCESS IN +# VARCHAR INDEX USING DATETIME VALUE + +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +CREATE TABLE t2 (b VARCHAR(64), KEY (b)) CHARSET utf8mb4; +INSERT INTO t2 VALUES ('2001-01-01'); +INSERT INTO t2 VALUES ('2001.01.01'); +INSERT INTO t2 VALUES ('2001#01#01'); +INSERT INTO t2 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); + +# range/ref access cannot be used for this query + +EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = (cast('2001-01-01' as date))) +SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +b +2001#01#01 +2001-01-01 +2001-01-01 00:00:00 +2001.01.01 + +# range/ref access cannot be used for any of the queries below. +# See BUG#13814468 about 'Range checked for each record' + +EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = cast(`test`.`t2`.`b` as datetime(6))) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (cast(`test`.`t2`.`b` as datetime(6)) = `test`.`t1`.`a`) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +DROP TABLE t1,t2; +# +# WL#7019: Add support for row value constructors in in predicates to +# range optimizer +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY x(a, b)); +INSERT INTO t1 VALUES (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), +(7, 7, 7), (8, 8, 8), (9, 9, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +CREATE TABLE t3 (a INT, b INT, c INT, d INT, KEY x(a, b, c)); +INSERT INTO t3 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((NULL, NULL), (NULL, NULL)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((NULL,NULL),(NULL,NULL))) +EXPLAIN SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +a b +0 0 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` where ((`test`.`t3`.`a`,`test`.`t3`.`b`,`test`.`t3`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 19.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 19.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1) and (`test`.`t2`.`a` = 1)) or ((`test`.`t2`.`c` = 0) and (`test`.`t2`.`b` = 0) and (`test`.`t2`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`c` = 1) and (`test`.`t3`.`b` = 1) and (`test`.`t3`.`a` = 1)) or ((`test`.`t3`.`c` = 0) and (`test`.`t3`.`b` = 0) and (`test`.`t3`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +a b +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (('0',0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +SET @v = 0; +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (((@`v`),0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +CREATE TABLE t4 ( a INT, b INT ); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t4 SELECT a + 5, b + 5 FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +# Inner table in a nested-loops join +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 USING(a, b) +WHERE (t4.a, t4.b) IN ((1, 1), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 2.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 2.00 Using where +2 SIMPLE t1 NULL ref x x 10 test.t4.a,test.t4.b 409 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t4`.`b`) and (`test`.`t1`.`a` = `test`.`t4`.`a`) and ((`test`.`t4`.`a`,`test`.`t4`.`b`) in ((1,1),(0,0)))) +# Join on IN +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(0,0))) +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(1,1))) +# +# Tests for non-deterministic functions. +# +CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (f1(), 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 4098 0.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(`f1`(),1,1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,`f1`(),1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, f1())); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,1,`f1`()))) +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index x x 10 NULL 4098 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = `f1`())) +DROP FUNCTION f1; +# The statement immediately below should not use range access. +EXPLAIN +SELECT a, b +FROM t1 AS t1o +WHERE EXISTS (SELECT /*+ NO_SEMIJOIN() */ 1 +FROM t1 +WHERE (a, b) IN ((t1o.a, t1o.b)) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1o NULL index NULL x 10 NULL 4098 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref x x 10 test.t1o.a,test.t1o.b 409 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1o.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1o.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1o`.`a` AS `a`,`test`.`t1o`.`b` AS `b` from `test`.`t1` `t1o` where exists(/* select#2 */ select 1 from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1o`.`a`) and (`test`.`t1`.`b` = `test`.`t1o`.`b`))) +# +# Tests of dynamic range access +# +CREATE TABLE t5 (a int, b int, KEY (a)); +INSERT INTO t5 VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1); +CREATE TABLE t6 (a int, b int, KEY (a)); +INSERT INTO t6 VALUES (3, 2), (4, 2), (100, 100), (101, 201), (102, 102); +CREATE TABLE t7 (a int, b int, KEY (a, b)); +INSERT INTO t7 VALUES (1, 1), (2, 2), (1000, 1000), (1001, 1001), (1002, 1002), +(1003, 1003), (1004, 1004); +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and (`test`.`t7`.`a` in (`test`.`t5`.`b`,`test`.`t6`.`b`))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +a b a b a b +3 1 3 2 1 1 +3 1 3 2 2 2 +4 1 4 2 1 1 +4 1 4 2 2 2 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and ((`test`.`t7`.`a`,`test`.`t7`.`b`) in ((`test`.`t5`.`b`,1),(`test`.`t6`.`b`,1)))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +a b a b a b +3 1 3 2 1 1 +4 1 4 2 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +# +# Regression tests of the worklog below. +# +# Make sure we process IN predicates only. +# The code around this is very unclear. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) != (1, 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4098 99.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index x x 10 NULL 4098 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` <> 1) or (`test`.`t1`.`b` <> 1)) +# This should give us a ref scan, as it always did. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +EXPLAIN SELECT a, b FROM t1 WHERE (a, c) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`c` = 0) and (`test`.`t1`.`a` = 0)) +# ref scan on x(a). +EXPLAIN SELECT * FROM t1 WHERE (a, c) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`c`) in ((0,0),(1,1))) +DROP TABLE t1, t2, t3, t4, t5, t6, t7; +# +# Bug#17635476: CRASH IN GET_MM_PARTS() OR ASSERT IN +# GET_FUNC_MM_TREE_FROM_IN_PREDICATE() +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY (a) +) ENGINE = INNODB; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +INSERT INTO t1 VALUES (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), +(7, 7), (8, 8), (9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 ( +a INT, +b INT, +KEY (a, b) +); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((NULL,`test`.`t1`.`b`) in ((0,0),(1,1))) +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 10 NULL 10 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((NULL,`test`.`t2`.`b`) in ((0,0),(1,1))) +DROP TABLE t1, t2; +# +# Bug#17755540 VALGRIND ERROR WHEN SETTING UP ROW COMPARATORS +# +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT a, b FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +DROP TABLE t2; +# +# BUG#18364815: OPTIMIZER PREFERS TABLE SCAN WHEN +# USING "IN" WITH VALUE OF DIFFERENT TYPE +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,1), (5,1), (6,1); +EXPLAIN SELECT * FROM t1 WHERE a IN (1, 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE a IN (1, "2"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,'2')) +SELECT * FROM t1 WHERE a IN (1, 2); +a b +1 1 +2 1 +SELECT * FROM t1 WHERE a IN (1, "2"); +a b +1 1 +2 1 +DROP TABLE t1; +# +# Bug#18715670 +# CRASH IN DECIMAL_ACTUAL_FRACTION COMPARING DECIMAL TO NULLS +# +CREATE TABLE t1(n DECIMAL(39,19) NOT NULL, KEY(n)) engine=innodb; +INSERT INTO t1 SET n=0; +SELECT 1 FROM t1 WHERE n NOT IN(NULL, NULL); +1 +DROP TABLE t1; +# +# Bug#18759597 MISSING ROWS ON WHERE .. +# IN QUERY WITH VARIABLES AND CONCAT +# +CREATE TABLE t1 ( +col_varchar_key varchar(2), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('n'),('xm'); +SET @var1 = 't', @var2 = 'him', +@var3 = 'n', @var4 = 'n', +@var5 = 'n', @var6 = 'g', +@var7 = 'b', @var8 = 'o', +@var9 = 'm', @var10 = 'xm', @var11 = 'u' +; +SELECT col_varchar_key AS field1 +FROM t1 +WHERE ( col_varchar_key, col_varchar_key ) IN ( +('m', @var1 ), +('n', @var3 ), +('a', @var5 ), +('l', @var7 ), +(CONCAT('x', @var9 ), @var10 ) +); +field1 +n +xm +DROP TABLE t1; +# +# Bug#18535226 DEBUG CRASH ON QUICK_RANGE_SELECT::RESET +# +SET @old_tmp_table_size=@@tmp_table_size; +SET tmp_table_size=1024; +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_date_key date, +col_date_nokey date, +col_time_key time, +col_time_nokey time, +col_datetime_key datetime, +col_datetime_nokey datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(5,0,'2001-05-06','2001-05-06','16:21:18','16:21:18','2001-11-08 21:02:12', +'2001-11-08 21:02:12','x','x'),(6,7,'2006-03-03','2006-03-03','18:56:33', +'18:56:33','2003-04-01 00:00:00','2003-04-01 00:00:00','i','i'), +(7,7,'2007-12-28','2007-12-28',NULL,NULL,'1900-01-01 00:00:00', +'1900-01-01 00:00:00','e','e'),(8,1,'2004-10-20','2004-10-20','09:29:08', +'09:29:08','2007-07-12 00:00:00','2007-07-12 00:00:00','p','p'), +(9,7,'2008-04-09','2008-04-09','19:11:10','19:11:10', +'2005-04-04 01:21:01','2005-04-04 01:21:01','s','s'), +(10,1,'2005-12-25','2005-12-25','11:57:26','11:57:26', +'1900-01-01 00:00:00','1900-01-01 00:00:00','j','j'); +SELECT alias1.col_int_key +FROM +( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1, t1 AS SQ1_alias2 ) AS alias1, +(SELECT 7 AS col_int_nokey) AS alias2 +WHERE +alias2.col_int_nokey = alias1.pk +AND alias1.col_varchar_nokey < alias1.col_varchar_key +ORDER BY alias1.col_varchar_key; +col_int_key +DROP TABLE t1; +SET tmp_table_size=@old_tmp_table_size; +SET sql_mode = default; +# +# Bug#19585938 Crash in get_full_func_mm_tree with null +# item_field->table_ref +# +CREATE TABLE t1(id INTEGER, col1 INTEGER, col2 INTEGER, PRIMARY KEY(id)); +INSERT INTO t1 VALUES (1,2,3), (3,2,1); +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) < id +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id > SUM(1) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN id AND id+1 +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id BETWEEN SUM(1) AND SUM(5) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN COUNT(*) AND id +) AS c +FROM t1 +GROUP BY col1; +c +1 +DROP TABLE t1; +# +# Bug#21415791 VALGRIND ERROR (CONDITIONAL JUMP) AT KEY_AND +# (RANGE_OPT_PARAM*, SEL_ARG*, SEL_AR +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +pk INTEGER NOT NULL, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t1 ( +pk, col_varchar_10, col_int_key) VALUES +(1, 'ttttt', 0), (2, 'zzzzz', 0), (3, 'ggggg', 0), +(4, 'hhhhh', 0), (5, 'kkkkk', 0), (6, 'lllll', 0); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t2 ( +pk, col_varchar_10) VALUES +(1, '00000'), (2, '00000'), (3, '44444'), (4, '00000'), +(5, NULL), (6, NULL), (7, NULL); +SELECT COUNT(t1.col_int_key) +FROM t2 RIGHT OUTER JOIN t1 ON t2.col_varchar_10 <= t1.col_varchar_10 +WHERE t2.pk <> 4 OR t2.pk != t1.col_int_key AND t2.pk <> 1000; +COUNT(t1.col_int_key) +24 +DROP TABLE t1, t2; +# +# Bug #20229614: OR CONDITIONS ON MULTI-COLUMN INDEX MAY NOT USE ALL +# INDEX COLUMNS TO FILTER ROWS +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c3 INT, +PRIMARY KEY(c1, c2, c3) +) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 2), (1, 1, 3), +(1, 1, 4), (1, 1, 5); +INSERT INTO t1 SELECT c1, 2, c3 FROM t1; +INSERT INTO t1 SELECT c1, 3, c3 FROM t1 WHERE c2 = 1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +15 +EXPLAIN SELECT c1, c2, c3 +FROM t1 +WHERE (c1 = 1 AND c2 = 1 AND c3 = 1) OR +(c1 = 1 AND c2 = 2 AND c3 = 2) OR +(c1 = 1 AND c2 = 2 AND c3 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 12 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where (((`test`.`t1`.`c3` = 1) and (`test`.`t1`.`c2` = 1) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 3) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1))) +DROP TABLE t1; +# +# Bug#21139683: ASSERTION FAILED: TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE +# +CREATE TABLE t1 ( +a BLOB, +PRIMARY KEY(a(1)), +KEY(a(1)) +) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE a <> 'a' OR a <> ""; +1 +DROP TABLE t1; +# +# Bug#19333852: RESULT DIFF IN QUERY HAVING DISTINCT +# WITH GROUP BY +# +CREATE TABLE t1 ( +v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY v1_key (v1(10)) +) ENGINE=InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); +EXPLAIN SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` < (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v1_key v1_key 32 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` = (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` between 'f' and (char(127))) +SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +v1 pk +ABCDE 19 +JLVGO 14 +SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +v1 pk +SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +v1 pk +JLVGO 14 +DROP TABLE t1; +# +# Bug #21761867: ASSERTION `TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE' FAILED. +# +CREATE TABLE t1 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +c18 INT, +PRIMARY KEY (c10,c12), +UNIQUE KEY key_c12(c12), +KEY key_c18(c18)); +INSERT INTO t1 VALUES(11,5,0), (12,6,1), (13,7,2), (14,8,3), (15,9,4); +CREATE TABLE t2 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +PRIMARY KEY(c10,c12)); +CREATE TABLE t3 (c10 INT NOT NULL); +SELECT t2.c10 +FROM t1 +RIGHT JOIN t3 +LEFT JOIN t2 +ON t3.c10 = t2.c10 +ON t1.c12 > t2.c12 +WHERE +t1.c10 <= 25 +AND +t1.c18 IS NOT NULL +OR +t1.c10 > 5 +AND +t1.c18 IN (15,16,18); +c10 +DROP TABLE t1, t2, t3; +# +# Bug #21318711: WRONG RESULTS FOR TRUNCATED COLUMN AND AGGREGATION +# +CREATE TABLE t1 ( +col1 VARCHAR(5), +col2 INT NOT NULL, +PRIMARY KEY (col1, col2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('abcde', 10); +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where (`test`.`t1`.`col1` = 'abcdeaa') +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where multiple equal('abcde ', `test`.`t1`.`col1`) +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +MAX(col2) +NULL +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +MAX(col2) +10 +DROP TABLE t1; +# +# Bug# 22283790: RANGE OPTIMIZER UTILIZES TOO MUCH MEMORY WITH +# MANY OR CONDITIONS +# +CREATE TABLE t1 ( +f1 INTEGER, +KEY (f1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15); +SET @orig_range_optimizer_max_mem_size= @@range_optimizer_max_mem_size; +SET range_optimizer_max_mem_size= 5000; +EXPLAIN SELECT * FROM t1 WHERE f1=1 OR f1=2 OR f1=3 OR f1=4 OR f1=5 +OR f1=6 OR f1=7 OR f1=8 OR f1=9 OR f1=10 OR f1=11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range f1 f1 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` = 1) or (`test`.`t1`.`f1` = 2) or (`test`.`t1`.`f1` = 3) or (`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f1` = 5) or (`test`.`t1`.`f1` = 6) or (`test`.`t1`.`f1` = 7) or (`test`.`t1`.`f1` = 8) or (`test`.`t1`.`f1` = 9) or (`test`.`t1`.`f1` = 10) or (`test`.`t1`.`f1` = 11)) +SET range_optimizer_max_mem_size= @orig_range_optimizer_max_mem_size; +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +SELECT * FROM t1 WHERE pk IN (3, 8) OR pk NOT IN (2); +pk +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +# Indirectly tests ORing with a tree that has a nonzero refcount, +# where nodes are also being skipped over. (There was a bug in +# refcounting such trees earlier.) +# +CREATE TABLE t1 ( +col_int_key int, +pk int NOT NULL, +col_int int, +KEY test_idx (pk,col_int_key,col_int) +); +SELECT * FROM t1 WHERE +(col_int_key >= 6 AND pk > 6) OR +(pk > 2 AND col_int_key = 7 AND col_int > 6); +col_int_key pk col_int +DROP TABLE t1; +# +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE `giant_table` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`one_id` int(11) NOT NULL, +`other_id` bigint(20) NOT NULL DEFAULT '0', +`some_other_id` int(11) DEFAULT 0 NOT NULL, +`something` double NOT NULL DEFAULT '0', +`comment` text COLLATE utf8_unicode_ci, +`flags` int(11) NOT NULL DEFAULT '0', +`time_created` int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (`id`), +KEY `time_created` (`time_created`), +KEY `some_other_id` (`some_other_id`), +KEY `one_other_idx` (`one_id`,`other_id`), +KEY `other_id` (`other_id`,`time_created`) +) ENGINE=InnoDB AUTO_INCREMENT=101651329 +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (66136540), (68983250), (89627210), (77869520), +(82543190), (67538270), (77282760), (77908170), +(70923370), (68066360); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT INTO giant_table(id,one_id) +SELECT c1 + @x, 0 +FROM t1 +WHERE c1 IN (66136540, 68985250, 89627210, 77869520 , 82543190, 67538270, +77282760, 77908170, 70923370, 68066360); +SET @x = @x + 1; +UNTIL @x > 30 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM giant_table; +count(*) +270 +INSERT INTO giant_table (id,one_id) VALUES (66136539, 0), (68983258,1), +(89628210,1), (77869520,2); +INSERT INTO giant_table (id,one_id, some_other_id) VALUES(84673401, 0, 1), +(61069031, 1, 1); +EXPLAIN SELECT id, something, comment, time_created, one_id, other_id, +some_other_id, flags +FROM giant_table +WHERE id IN (66136539, 68983258, 89628210, 77869520, 82543198, 67538272, +84673401, 61069031, 68214385, 77282865, 76991297, 64569216, +89481638, 74534074, 70396537, 80076375, 63308530, 77908270, +70923271, 68066180) +AND (giant_table.flags & 0x01) = 0 AND giant_table.some_other_id = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE giant_table NULL range PRIMARY,some_other_id some_other_id 8 NULL 20 100.00 Using index condition; Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`giant_table`.`id` AS `id`,`test`.`giant_table`.`something` AS `something`,`test`.`giant_table`.`comment` AS `comment`,`test`.`giant_table`.`time_created` AS `time_created`,`test`.`giant_table`.`one_id` AS `one_id`,`test`.`giant_table`.`other_id` AS `other_id`,`test`.`giant_table`.`some_other_id` AS `some_other_id`,`test`.`giant_table`.`flags` AS `flags` from `test`.`giant_table` where ((`test`.`giant_table`.`some_other_id` = 0) and (`test`.`giant_table`.`id` in (66136539,68983258,89628210,77869520,82543198,67538272,84673401,61069031,68214385,77282865,76991297,64569216,89481638,74534074,70396537,80076375,63308530,77908270,70923271,68066180)) and ((`test`.`giant_table`.`flags` & 0x01) = 0)) +DROP PROCEDURE p; +DROP TABLE giant_table, t1; +# +# Bug#22671573: SIG11 IN SEL_ARG::RB_INSERT |SQL/OPT_RANGE.CC +# +# Tests creating an empty tree (impossible condition) and then ANDing with it. +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY test_idx (b, a) +); +SELECT * FROM t1 WHERE b BETWEEN 8 AND 8 AND a > 8 AND a <= 8; +a b +DROP TABLE t1; +# +# Indirectly tests inserting a node into an empty (impossible) tree. +# +CREATE TABLE t1 ( +pk INT, +PRIMARY KEY ( pk ) +); +SELECT * FROM t1 WHERE pk = 6 OR pk > 6; +pk +DROP TABLE t1; +# +# Indirectly tests ORing with an empty (impossible) tree. +# +CREATE TABLE t1 ( +col_int_key INT, +KEY (col_int_key) +); +SELECT * FROM t1 WHERE col_int_key IS NULL OR col_int_key < 9 OR col_int_key = 9; +col_int_key +DROP TABLE t1; +# +# Indirectly tests deleting the last node from a tree +# (which makes it IMPOSSIBLE) and then inserting more than one node. +# +CREATE TABLE t1 ( +a VARCHAR(64), +KEY a (a) +); +SELECT * FROM t1 WHERE a IS NULL OR a NOT IN ( 'foo', 'bar' ); +a +DROP TABLE t1; +# +# Bug#25229315: ASSERTION TABLE->M_RECORD_BUFFER.RECORD_SIZE() == +# RECORD_PREFIX_SIZE(TAB)' FAIL +# +CREATE TABLE t1 (pk INT PRIMARY KEY, vc VARCHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, NULL), (2, 'w'); +CREATE TABLE t2 ( +i INT, +vc VARCHAR(1), +pk INT PRIMARY KEY, +KEY (i), +KEY (vc) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 'p', 1), (9, 'w', 2), (NULL, 'r', 3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL i,vc NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x6) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`vc` = `test`.`t1`.`vc`) or (`test`.`t2`.`i` = `test`.`t1`.`pk`)) +SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +MIN(t1.pk) +1 +DROP TABLE t1, t2; +# +# Bug #26727773: OPTIMIZER CHOSES COMPOSITE INDEX FOR REF OVER RANGE +# +CREATE TABLE transactions ( +app_trans_id INT DEFAULT NULL, +id INT NOT NULL, +tbl INT NOT NULL DEFAULT 1, +created TIMESTAMP NOT NULL DEFAULT '2017-01-01 01:01:01', +trans_type INT NOT NULL, +description BLOB, +source_lvl1 INT DEFAULT NULL, +source_lvl2 INT DEFAULT NULL, +KEY tbl_id_idx (tbl,id), +KEY created_idx (created), +KEY trans_type_created_idx (trans_type,created), +KEY app_trans_id_idx (app_trans_id) +) ENGINE=INNODB ; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1000), (2000), (3000), (4000), (5000), (6000), +(7000), (8000), (9000); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT IGNORE INTO transactions(id,trans_type, description) +SELECT c1 + @x, @x , 'abcd' + FROM t1; +SET @x = @x + 1; +UNTIL @x > 300 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM transactions; +count(*) +3000 +INSERT IGNORE INTO transactions(id,trans_type, description, created) +SELECT 3, 3 , 'abcd', '2018-01-01 01:01:01' + FROM dual; +EXPLAIN SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE transactions NULL range tbl_id_idx,created_idx,trans_type_created_idx created_idx 4 NULL # # Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select '2017-10-23 01:01:01' AS `2017-10-23 01:01:01`,hour(`test`.`transactions`.`created`) AS `HOUR(created)`,`test`.`transactions`.`source_lvl1` AS `source_lvl1`,`test`.`transactions`.`source_lvl2` AS `source_lvl2`,count(distinct `test`.`transactions`.`app_trans_id`) AS `COUNT(DISTINCT(app_trans_id))` from `test`.`transactions` where ((`test`.`transactions`.`trans_type` = 3) and (`test`.`transactions`.`tbl` = 1) and (`test`.`transactions`.`created` > TIMESTAMP'2017-10-23 01:01:01')) group by '2017-10-23 01:01:01',hour(`test`.`transactions`.`created`),`test`.`transactions`.`source_lvl1`,`test`.`transactions`.`source_lvl2` +SET optimizer_trace="enabled=on"; +SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +2017-10-23 01:01:01 HOUR(created) source_lvl1 source_lvl2 COUNT(DISTINCT(app_trans_id)) +2017-10-23 01:01:01 1 NULL NULL 0 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +SET optimizer_trace="enabled=off"; +DROP PROCEDURE p; +DROP TABLE t1, transactions; +# +# Bug #28086754: OPTIMIZER SKIP THE RANG SCAN ON SECOND COLUMN IN A +# COMPOSITE INDEX +# +CREATE TABLE test_ref ( +a INT PRIMARY KEY, +b VARCHAR(20), +c VARCHAR(20) DEFAULT NULL, +d VARCHAR(3) DEFAULT NULL, +id INT DEFAULT NULL, +KEY idx1 (id, c), +KEY idx2 (id, d)) ENGINE=INNODB ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze Error Table 'test.t1' doesn't exist +test.t1 analyze status Operation failed +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c`,`test`.`test_ref`.`a` limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +a b c d id +34876 D003 gheennse S 3 +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using index condition; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c` desc,`test`.`test_ref`.`a` desc limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +a b c d id +1770649 D003 gheennse S 3 +DROP TABLE test_ref; +# +# Bug #30988735: SELECT QUERY WITH ERROR RESULT WITH "NOT IN" +# WHERE_CLAUSE +# +CREATE TABLE t(f1 INTEGER key, f2 INTEGER)ENGINE=INNODB; +INSERT INTO t VALUES(0,0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT f1,f2 FROM t WHERE f1 NOT IN(-0.1,0.1); +f1 f2 +0 0 +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/range_mrr.result-pq b/mysql-test/r/range_mrr.result-pq new file mode 100644 index 000000000..5a33a8904 --- /dev/null +++ b/mysql-test/r/range_mrr.result-pq @@ -0,0 +1,3997 @@ +set optimizer_switch='mrr=on,mrr_cost_based=off'; +drop table if exists t1, t2, t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +event_date date DEFAULT '0000-00-00' NOT NULL, +type int(11) DEFAULT '0' NOT NULL, +event_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (event_date,type,event_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25), +('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26), +('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45), +('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5), +('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17), +('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40), +('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6), +('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41), +('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41), +('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29), +('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19), +('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42), +('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30), +('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8), +('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22), +('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43), +('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37), +('1999-09-19',100100,37), ('2000-12-18',100700,38); +explain select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 19.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 7 NULL 6 19.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where ((`test`.`t1`.`event_date` >= DATE'1999-07-01') and (`test`.`t1`.`event_date` < DATE'1999-07-15') and ((`test`.`t1`.`type` = 100600) or (`test`.`t1`.`type` = 100100))) order by `test`.`t1`.`event_date` +explain format=tree select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +EXPLAIN +-> Parallel scan on + -> Filter: ((t1.event_date >= DATE'1999-07-01') and (t1.event_date < DATE'1999-07-15') and ((t1.`type` = 100600) or (t1.`type` = 100100))) (cost=1.46 rows=1) + -> PQblock range scan on t1 using PRIMARY (cost=1.46 rows=6) + +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where false order by `test`.`t1`.`event_date` +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +1999-07-15 100600 16 +drop table t1; +CREATE TABLE t1 ( +PAPER_ID smallint(6) DEFAULT '0' NOT NULL, +YEAR smallint(6) DEFAULT '0' NOT NULL, +ISSUE smallint(6) DEFAULT '0' NOT NULL, +CLOSED tinyint(4) DEFAULT '0' NOT NULL, +ISS_DATE date DEFAULT '0000-00-00' NOT NULL, +PRIMARY KEY (PAPER_ID,YEAR,ISSUE) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'), +(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'), +(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'), +(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'), +(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'), +(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'), +(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'), +(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'), +(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'), +(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'), +(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'), +(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'), +(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'), +(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'), +(3,1999,35,0,'1999-07-12'); +select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE; +YEAR ISSUE +1999 29 +1999 30 +1999 31 +1999 32 +1999 33 +1999 34 +1999 35 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair note The storage engine for the table doesn't support repair +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2), +(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2), +(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1), +(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2), +(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2), +(19,3,2), (5,1,1), (179,5,2); +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +drop table t1; +create table t1( +Satellite varchar(25) not null, +SensorMode varchar(25) not null, +FullImageCornersUpperLeftLongitude double not null, +FullImageCornersUpperRightLongitude double not null, +FullImageCornersUpperRightLatitude double not null, +FullImageCornersLowerRightLatitude double not null, +index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude)); +insert into t1 values("OV-3","PAN1",91,-92,40,50); +insert into t1 values("OV-4","PAN1",91,-92,40,50); +select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000; +Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude +OV-3 PAN1 91 -92 40 50 +drop table t1; +create table t1 ( aString char(100) not null default "", key aString (aString(10)) ); +insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love"); +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +alter table t1 drop key aString; +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +drop table t1; +CREATE TABLE t1 ( +t1ID int(10) unsigned NOT NULL auto_increment, +art binary(1) NOT NULL default '', +KNR char(5) NOT NULL default '', +RECHNR char(6) NOT NULL default '', +POSNR char(2) NOT NULL default '', +ARTNR char(10) NOT NULL default '', +TEX char(70) NOT NULL default '', +PRIMARY KEY (t1ID), +KEY IdxArt (art), +KEY IdxKnr (KNR), +KEY IdxArtnr (ARTNR) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'); +select count(*) from t1 where upper(art) = 'J'; +count(*) +213 +select count(*) from t1 where art = 'J' or art = 'j'; +count(*) +602 +select count(*) from t1 where art = 'j' or art = 'J'; +count(*) +602 +select count(*) from t1 where art = 'j'; +count(*) +389 +select count(*) from t1 where art = 'J'; +count(*) +213 +drop table t1; +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` between 7 and ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` >= 7) and (`test`.`t2`.`x` <= ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using where; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between ((2 - 1)) and ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using where; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= ((2 - 1))) and (`test`.`t2`.`x` <= ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between 0 and 2)) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using MRR; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= 0) and (`test`.`t2`.`x` <= 2)) +explain select count(*) from t1 where x in (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` = 1) +explain select count(*) from t1 where x in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` in (1,2)) +drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +explain select * from t1 force index(i1), t2 force index(j1) where +(t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` FORCE INDEX (`i1`) join `test`.`t2` FORCE INDEX (`j1`) where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a), +KEY b (b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), +(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), +(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), +(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a,b a 5 NULL 2 40.54 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` in (1,2))) +SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +a b +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) +); +a b +15 1 +47 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id int( 11 ) unsigned NOT NULL AUTO_INCREMENT , +line int( 5 ) unsigned NOT NULL default '0', +columnid int( 3 ) unsigned NOT NULL default '0', +owner int( 3 ) unsigned NOT NULL default '0', +ordinal int( 3 ) unsigned NOT NULL default '0', +showid smallint( 6 ) unsigned NOT NULL default '1', +tableid int( 1 ) unsigned NOT NULL default '1', +content int( 5 ) unsigned NOT NULL default '188', +PRIMARY KEY ( owner, id ) , +KEY menu( owner, showid, columnid ) , +KEY `COLUMN` ( owner, columnid, line ) , +KEY `LINES` ( owner, tableid, content, id ) , +KEY recount( owner, line ) +) ENGINE = MYISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); +SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; +id columnid tableid content showid line ordinal +13 13 1 188 1 5 0 +15 15 1 188 1 1 0 +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select id from t1 where id in (2,5,9) ; +id +2 +5 +9 +select id from t1 where id=2 or id=5 or id=9 ; +id +2 +5 +9 +drop table t1; +create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2)); +insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), +(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"), +(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"), +(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"), +(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"), +(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"), +(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa"); +select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; +id1 idnull +drop table t1; +create table t1 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +create table t2 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +insert into t1(id, uid, name) values(1, 0, ' '); +insert into t1(uid, name) values(0, ' '); +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +delete from t2; +insert into t2(uid, name) values +(1, CHAR(64+1)), +(2, CHAR(64+2)), +(3, CHAR(64+3)), +(4, CHAR(64+4)), +(5, CHAR(64+5)), +(6, CHAR(64+6)), +(7, CHAR(64+7)), +(8, CHAR(64+8)), +(9, CHAR(64+9)), +(10, CHAR(64+10)), +(11, CHAR(64+11)), +(12, CHAR(64+12)), +(13, CHAR(64+13)), +(14, CHAR(64+14)), +(15, CHAR(64+15)), +(16, CHAR(64+16)), +(17, CHAR(64+17)), +(18, CHAR(64+18)), +(19, CHAR(64+19)), +(20, CHAR(64+20)), +(21, CHAR(64+21)), +(22, CHAR(64+22)), +(23, CHAR(64+23)), +(24, CHAR(64+24)), +(25, CHAR(64+25)), +(26, CHAR(64+26)); +insert into t1(uid, name) select uid, name from t2 order by uid; +delete from t2; +insert into t2(id, uid, name) select id, uid, name from t1; +select count(*) from t1; +count(*) +1026 +select count(*) from t2; +count(*) +1026 +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where; Using MRR +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +drop table t1,t2; +create table t1 (x bigint unsigned not null); +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +create table t2 (x bigint not null); +insert into t2(x) values (-16); +insert into t2(x) values (-15); +select * from t2; +x +-16 +-15 +select count(*) from t2 where x>0; +count(*) +0 +select count(*) from t2 where x=0; +count(*) +0 +select count(*) from t2 where x<0; +count(*) +2 +select count(*) from t2 where x < -16; +count(*) +0 +select count(*) from t2 where x = -16; +count(*) +1 +select count(*) from t2 where x > -16; +count(*) +1 +select count(*) from t2 where x = 18446744073709551601; +count(*) +0 +drop table t1,t2; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +create table t1 (a bigint unsigned); +create index t1i on t1(a); +insert into t1 select 18446744073709551615; +insert into t1 select 18446744073709551614; +explain select * from t1 where a <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a <> -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1 or a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1 or a < -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where a < -1; +a +drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 11 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 'aaa') +explain select * from t1 where a=binary 'aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using where; Using MRR +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (cast('aaa' as char charset binary))) +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using where; Using MRR +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_bin))) +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 9 11.11 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_german1_ci))) +drop table t1; +CREATE TABLE t1 ( +`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', +`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTINT` int(11) NOT NULL default '0', +KEY `VERI_CLNT~2` (`ARG1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0), +('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0), +('001',' 3',' 0','Text 017',0); +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2'); +count(*) +4 +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1'); +count(*) +4 +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( +pk1 int(11) NOT NULL, +pk2 int(11) NOT NULL, +pk3 int(11) NOT NULL, +pk4 int(11) NOT NULL, +filler char(82), +PRIMARY KEY (pk1,pk2,pk3,pk4) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B; +INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'), +(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'), +(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler'); +SELECT * FROM t2 +WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635))) +OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635)))) +) AND (pk3 >=1000000); +pk1 pk2 pk3 pk4 filler +2621 2635 1000015 0 filler +drop table t1, t2; +create table t1(a char(2), key(a(1))) charset utf8mb4; +insert into t1 values ('x'), ('xx'); +explain select a from t1 where a > 'x'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'x') +select a from t1 where a > 'x'; +a +xx +drop table t1; +CREATE TABLE t1 ( +OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid', +OXLEFT int NOT NULL DEFAULT '0', +OXRIGHT int NOT NULL DEFAULT '0', +OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +PRIMARY KEY (OXID), +KEY OXNID (OXID), +KEY OXLEFT (OXLEFT), +KEY OXRIGHT (OXRIGHT), +KEY OXROOTID (OXROOTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'), +('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725521'); +EXPLAIN +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE v NULL ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 100.00 NULL +1 SIMPLE s NULL ref OXLEFT,OXROOTID OXROOTID 34 const 5 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`OXID` AS `oxid` from `test`.`t1` `v` join `test`.`t1` `s` where ((`test`.`s`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`v`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`s`.`OXLEFT` > `test`.`v`.`OXLEFT`) and (`test`.`s`.`OXLEFT` < `test`.`v`.`OXRIGHT`)) +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +oxid +d8c4177d151affab2.81582770 +d8c4177d206a333d2.74422679 +d8c4177d225791924.30714720 +d8c4177d2380fc201.39666693 +d8c4177d24ccef970.14957924 +DROP TABLE t1; +create table t1 ( +c1 char(10), c2 char(10), c3 char(10), c4 char(10), +c5 char(10), c6 char(10), c7 char(10), c8 char(10), +c9 char(10), c10 char(10), c11 char(10), c12 char(10), +c13 char(10), c14 char(10), c15 char(10), c16 char(10), +index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); +select * from t1 where +c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 +Warnings: +Warning 3170 Memory capacity of 8388608 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +drop table t1; +End of 4.1 tests +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +status varchar(20), +PRIMARY KEY (id), +KEY (status) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'), +(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'), +(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'), +(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'), +(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'), +(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'), +(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'), +(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'), +(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'), +(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C'); +EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not between 'A' and 'B') +EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` < 'A') or (`test`.`t1`.`status` > 'B')) +SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, primary key(a,b)); +INSERT INTO t1 VALUES +(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3); +CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3; +EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +SELECT a,b FROM t1 WHERE a < 2 and b=3; +a b +1 3 +SELECT a,b FROM v1 WHERE a < 2 and b=3; +a b +1 3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name)); +INSERT INTO t1 VALUES ('Betty'), ('Anna'); +SELECT * FROM t1; +name +Anna +Betty +DELETE FROM t1 WHERE name NOT LIKE 'A%a'; +SELECT * FROM t1; +name +Anna +DROP TABLE t1; +CREATE TABLE t1 (a int, KEY idx(a)); +INSERT INTO t1 VALUES (NULL), (1), (2), (3); +SELECT * FROM t1; +a +NULL +1 +2 +3 +DELETE FROM t1 WHERE NOT(a <=> 2); +SELECT * FROM t1; +a +2 +DROP TABLE t1; +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); +explain select * from t1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from v1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +explain select * from v1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +drop view v1; +drop table t1; +create table t3 (a int); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a varchar(10), filler char(200), key(a)) charset=binary; +insert into t1 values ('a',''); +insert into t1 values ('a ',''); +insert into t1 values ('a ', ''); +insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), '' + from t3 A, t3 B, t3 C; +create table t2 (a varchar(10), filler char(200), key(a)) charset utf8mb4; +insert into t2 select * from t1; +explain select * from t1 where a between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` between 'a' and 'a ') +explain select * from t1 where a = 'a' or a='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') or (`test`.`t1`.`a` = 'a ')) +explain select * from t2 where a between 'a' and 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` between 'a' and 'A') +explain select * from t2 where a = 'a' or a='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') or (`test`.`t2`.`a` = 'A')) +update t1 set a='b' where a<>'a'; +explain select * from t1 where a not between 'b' and 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` not between 'b' and 'b') +select a, hex(filler) from t1 where a not between 'b' and 'b'; +a hex(filler) +a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +drop table t1,t2,t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, key(a)); +insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C; +set @a="select * from t2 force index (a) where a NOT IN(0"; +select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z; +count(*) +1000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @a=concat(@a, ')'); +insert into t2 values (11),(13),(15); +set @b= concat("explain ", @a); +prepare stmt1 from @b; +execute stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1003 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,604,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,784,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1146,1148,1150,1152,1154,1156,1158,1160,1162,1164,1166,1168,1170,1172,1174,1176,1178,1180,1182,1184,1186,1188,1190,1192,1194,1196,1198,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222,1224,1226,1228,1230,1232,1234,1236,1238,1240,1242,1244,1246,1248,1250,1252,1254,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292,1294,1296,1298,1300,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1370,1372,1374,1376,1378,1380,1382,1384,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408,1410,1412,1414,1416,1418,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458,1460,1462,1464,1466,1468,1470,1472,1474,1476,1478,1480,1482,1484,1486,1488,1490,1492,1494,1496,1498,1500,1502,1504,1506,1508,1510,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1552,1554,1556,1558,1560,1562,1564,1566,1568,1570,1572,1574,1576,1578,1580,1582,1584,1586,1588,1590,1592,1594,1596,1598,1600,1602,1604,1606,1608,1610,1612,1614,1616,1618,1620,1622,1624,1626,1628,1630,1632,1634,1636,1638,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678,1680,1682,1684,1686,1688,1690,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1714,1716,1718,1720,1722,1724,1726,1728,1730,1732,1734,1736,1738,1740,1742,1744,1746,1748,1750,1752,1754,1756,1758,1760,1762,1764,1766,1768,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790,1792,1794,1796,1798,1800,1802,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822,1824,1826,1828,1830,1832,1834,1836,1838,1840,1842,1844,1846,1848,1850,1852,1854,1856,1858,1860,1862,1864,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1886,1888,1890,1892,1894,1896,1898,1900,1902,1904,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1964,1966,1968,1970,1972,1974,1976,1978,1980,1982,1984,1986,1988,1990,1992,1994,1996,1998)) +prepare stmt1 from @a; +execute stmt1; +a +11 +13 +15 +drop table t1, t2; +CREATE TABLE t1 ( +id int NOT NULL DEFAULT '0', +b int NOT NULL DEFAULT '0', +c int NOT NULL DEFAULT '0', +INDEX idx1(b,c), INDEX idx2(c)); +INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(b,c) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` <= 3) and (3 <= `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (3 between `test`.`t1`.`b` and `test`.`t1`.`c`) +SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((0 < `test`.`t1`.`b`) or (0 > `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (0 not between `test`.`t1`.`b` and `test`.`t1`.`c`) +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +EXPLAIN +-> Filter: (0 not between t1.b and t1.c) (cost=2.15 rows=3) + -> Index range scan on t1 using sort_union(idx1,idx2) (cost=2.15 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( +item char(20) NOT NULL default '', +started datetime NOT NULL default '0000-00-00 00:00:00', +price decimal(16,3) NOT NULL default '0.000', +PRIMARY KEY (item,started) +) ENGINE=MyISAM, CHARSET utf8mb4; +INSERT INTO t1 VALUES +('A1','2005-11-01 08:00:00',1000), +('A1','2005-11-15 00:00:00',2000), +('A1','2005-12-12 08:00:00',3000), +('A2','2005-12-01 08:00:00',1000); +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP INDEX `PRIMARY` ON t1; +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP TABLE t1; + +BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly" + +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +dateval date default NULL, +PRIMARY KEY (id), +KEY dateval (dateval) +) AUTO_INCREMENT=173; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'), +(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'), +(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11'); +This must use range access: +explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range dateval dateval 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`dateval` AS `dateval` from `test`.`t1` where ((`test`.`t1`.`dateval` >= DATE'2007-01-01') and (`test`.`t1`.`dateval` <= DATE'2007-01-02')) +drop table t1; +CREATE TABLE t1 ( +a varchar(32), index (a) +) DEFAULT CHARSET=latin1 COLLATE=latin1_bin; +INSERT INTO t1 VALUES +('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'); +SELECT a FROM t1 WHERE a='b' OR a='B'; +a +B +B +EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 35 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'b') or (`test`.`t1`.`a` = 'B')) +DROP TABLE t1; +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); +SELECT COUNT(*) FROM t1 WHERE f1 < 256; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 256.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 255; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 < -1; +COUNT(*) +0 +SELECT COUNT(*) FROM t1 WHERE f1 > -1; +COUNT(*) +5 +DROP TABLE t1; +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); +SELECT COUNT(*) FROM t1 WHERE f1 < 128; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 128.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 127; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 > -129; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -129.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -128; +COUNT(*) +4 +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100)); +insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, +t1 B, t1 C where A.a < 5; +insert into t2 select 1000, b, 'filler' from t2; +alter table t2 add index (a,b); +Access method can be range/ALL with #rows >= 500. +Or it can be ref with #rows = 2, only when there is memory limit. +explain select * from t2 where a=1000 and b<11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 500 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range a a 10 NULL 500 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 1000) and (`test`.`t2`.`b` < 11)) +drop table t1, t2; +CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t3( a INT, b INT, KEY( a, b ) ); +INSERT INTO t1( a, b ) +VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7); +INSERT INTO t2( a, b ) +VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1), +( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1), +(11, 1), (12, 1), (13, 1), (14, 1), (15, 1), +(16, 1), (17, 1), (18, 1), (19, 1), (20, 1); +INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t3 +VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), +(6, 0), (7, 0), (8, 0), (9, 0), (10, 0); +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 < `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 1) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +5 2 +6 1 +6 2 +7 1 +7 2 +8 1 +8 2 +9 1 +9 2 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 2) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +a b +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +EXPLAIN +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`b` = 3) and (5 <= `test`.`t3`.`a`) and (`test`.`t3`.`a` < 10)) or (`test`.`t3`.`a` < 5) or (`test`.`t3`.`a` < 10)) +DROP TABLE t1, t2, t3; +# +# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL); +a +DROP TABLE t1; +# +# Bug#47925: regression of range optimizer and date comparison in 5.1.39! +# +CREATE TABLE t1 ( a DATE, KEY ( a ) ); +CREATE TABLE t2 ( a DATETIME, KEY ( a ) ); +# Make optimizer choose range scan +INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22'); +INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23'); +INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'), +('2009-09-22 12:00:00'); +INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'), +('2009-09-23 12:00:00'); +# DATE vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# DATE vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923120000'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923120000; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923000000'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923000000; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# Test of the new get_date_from_str implementation +# Behavior differs slightly between the trunk and mysql-pe. +# The former may give errors for the truncated values, while the latter +# gives warnings. The purpose of this test is not to interfere, and only +# preserve existing behavior. +# This case was made obsolete after the changes applied by +# Bug#28940878 WRONG RESULT WHEN COMPARING DATE[TIME] WITH STRING +# as we don't fallback anymore to string comparison if the date is invalid. +SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND +str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND +str_to_date('2007-20-00', '%Y-%m-%d') <= ''; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; +str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''; +str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +SELECT str_to_date('', '%Y-%m-%d'); +str_to_date('', '%Y-%m-%d') +0000-00-00 +DROP TABLE t1, t2; +# +# Bug#48459: valgrind errors with query using 'Range checked for each +# record' +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY ( c ), +KEY ( d, a, b ( 2 ) ), +KEY ( b ( 1 ) ) +); +INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ), +( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 ); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY ( e ) +); +INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL ); +# Should not give Valgrind warnings +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug #48665: sql-bench's insert test fails due to wrong result +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (0,0), (1,1); +EXPLAIN +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +@ @ @ NULL ALL @ @ @ @ @ 100.00 @ +@ @ @ NULL range @ @ @ @ @ 100.00 @ +Warnings: +@ @ @ +# Should return 2 rows +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +a b +0 0 +1 1 +DROP TABLE t1; +# +# Bug #54802: 'NOT BETWEEN' evaluation is incorrect +# +CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key)); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c_key NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_key` AS `c_key`,`test`.`t1`.`c_notkey` AS `c_notkey` from `test`.`t1` where (2 not between `test`.`t1`.`c_notkey` and `test`.`t1`.`c_key`) +SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +c_key c_notkey +1 1 +3 3 +DROP TABLE t1; +# +# Bug #57030: 'BETWEEN' evaluation is incorrect +# +CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT); +CREATE UNIQUE INDEX i4_uq ON t1(i4); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30); +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between 10 and `test`.`t1`.`i4`) +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between `test`.`t1`.`i4` and 10) +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i4_uq 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 100 and 0) +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and 99999999999999999) +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 999999999999999 and 30) +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and '20') +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +pk i4 +1 10 +2 20 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`) +EXPLAIN FORMAT=tree +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.60 rows=3) + -> Filter: (t1.i4 is not null) (cost=0.55 rows=3) + -> PQblock scan on t1 using i4_uq (cost=0.55 rows=3) + -> Filter: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.i4) (cost=0.28 rows=1) + +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +pk i4 pk i4 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`) +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +pk i4 pk i4 +DROP TABLE t1; +# +# BUG#13519696 - 62940: SELECT RESULTS VARY WITH VERSION AND +# WITH/WITHOUT INDEX RANGE SCAN +# +create table t1 (id int unsigned not null auto_increment primary key); +insert into t1 values (null); +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +create table t2 ( +id int unsigned not null auto_increment, +val decimal(5,3) not null, +primary key (id,val), +unique key (val,id), +unique key (id)); +insert into t2 select null,id*0.0009 from t1; +select count(val) from t2 ignore index (val) where val > 0.1155; +count(val) +185 +select count(val) from t2 force index (val) where val > 0.1155; +count(val) +185 +drop table t2, t1; +# +# BUG#13453382 - REGRESSION SINCE 5.1.39, RANGE OPTIMIZER WRONG +# RESULTS WITH DECIMAL CONVERSION +# +create table t1 (a int,b int,c int,primary key (a,c)); +insert into t1 values (1,1,2),(1,1,3),(1,1,4); +select convert(3, signed integer) > 2.9; +convert(3, signed integer) > 2.9 +1 +select * from t1 force index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 force index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +drop table t1; +# +# BUG#13463488 - 63437: CHAR & BETWEEN WITH INDEX RETURNS WRONG +# RESULT AFTER MYSQL 5.1. +# +CREATE TABLE t1( +F1 CHAR(5) NOT NULL, +F2 CHAR(5) NOT NULL, +F3 CHAR(5) NOT NULL, +PRIMARY KEY(F1), +INDEX IDX_F2(F2) +) COLLATE latin1_swedish_ci; +INSERT INTO t1 VALUES +('A','A','A'),('AA','AA','AA'),('AAA','AAA','AAA'), +('AAAA','AAAA','AAAA'),('AAAAA','AAAAA','AAAAA'); +SELECT * FROM t1 WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 WHERE F1 >= 'A '; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 > 'A '; +F1 F2 F3 +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F2 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F3 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND +'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +DROP TABLE t1; +End of 5.1 tests +CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1)); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT c1 FROM t1 WHERE c1 >= 'A' GROUP BY 1; +c1 +1 +2 +3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +DROP TABLE t1; +create table t1 (a int,b int,key (b),key (a),key (b,a)); +insert into t1(a,b) values (1,2),(3,4),(5,6),(7,8); +create table t2 (c int); +insert into t2(c) values (1),(5),(6),(7),(8); +select 1 from (select c from t1,t2 where b >= 1 and a <=> c group by 1 limit 1) as d1; +1 +1 +drop table t1, t2; +# +# Bug #26106: Wrong plan may be chosen when there are several possible +# range and ref accesses +# +# Note: The fix for this bug has been reverted. The code will no longer +# select the optimal plan for the two following test queries. This is +# not due to a bug but due to minor differences in range estimates +# produced by the storage engine. +CREATE TABLE t1( +a INT, +b INT, +KEY k ( a ), +KEY l ( a, b ) +); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1 +VALUES (2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3); +INSERT INTO t1 SELECT 3, 4 FROM t1 WHERE a = 2 AND b = 3; +INSERT INTO t1 SELECT 4, 1 FROM t1 WHERE a = 2 AND b = 3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +# This must use range over index l, not k. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t1 WHERE a = 1 AND b >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 129 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k,l k 5 const 129 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` >= 2)) +CREATE TABLE t2( +a INT, +b INT, +c INT, +KEY k ( a ), +KEY l ( a, b ), +KEY m ( b ), +KEY n ( a, c ) +); +INSERT INTO t2(a) VALUES (1); +INSERT INTO t2 +VALUES (2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3), +(2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3); +INSERT INTO t2 SELECT 3, 4, 4 FROM t2 WHERE a = 2 AND b = 3; +INSERT INTO t2 SELECT 4, 1, 1 FROM t2 WHERE a = 2 AND b = 3; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +INSERT INTO t2 VALUES (1, 2, 2); +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 VALUES (1, 1, 2); +# This must use range over index l, not n. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t2 WHERE a = 1 AND b >= 2 AND c >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 66 29.16 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref k,l,m,n k 5 const 66 29.16 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` >= 2) and (`test`.`t2`.`c` >= 2)) +DROP TABLE t1, t2; +# +# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER +# AWAY QUALIFYING ROWS +# +CREATE TABLE t10( +K INT NOT NULL AUTO_INCREMENT, +I INT, J INT, +PRIMARY KEY(K), +KEY(I,J) +); +INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5), +(6,6),(6,7),(6,8),(6,9),(6,0); +CREATE TABLE t100 LIKE t10; +INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y; +INSERT INTO t100(I,J) VALUES(8,26); + +EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t100 NULL range I I 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t100`.`K` AS `K`,`test`.`t100`.`I` AS `I`,`test`.`t100`.`J` AS `J` from `test`.`t100` where ((`test`.`t100`.`I` <> 6) or ((`test`.`t100`.`J` = 5) and (`test`.`t100`.`I` <> 8))) + +SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +K I J +128 8 26 +DROP TABLE t10,t100; +# +# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR +# AFTER FLUSH TABLES [-INT VS NULL] +# +CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (-100,1),(1,6); +CREATE TABLE t2 ( +col_int_key INT, +col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT", +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t2 VALUES +(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8); +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t2 NULL ref PRIMARY,col_int_key col_int_key 5 test.t1.col_int # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +# need FLUSH so that InnoDB statistics change and thus plan changes +FLUSH TABLES; +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_int_key NULL NULL NULL # # Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +DROP TABLE t1,t2; +# +# Bug#12694872 - +# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_date_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1 ( +col_int_key, +col_int_nokey, +col_date_key, +col_varchar_key, +col_varchar_nokey +) VALUES +(0, 4, '2011-08-25', 'j', 'j'), +(8, 6, '2004-09-18', 'v', 'v'), +(1, 3, '2009-12-01', 'c', 'c'), +(8, 5, '2004-12-17', 'm', 'm'), +(9, 3, '2000-03-14', 'd', 'd'), +(6, 2, '2006-05-25', 'y', 'y'), +(1, 9, '2008-01-23', 't', 't'), +(6, 3, '2007-06-18', 'd', 'd'), +(2, 8, '2002-10-13', 's', 's'), +(4, 1, '1900-01-01', 'r', 'r'), +(8, 8, '1959-04-25', 'm', 'm'), +(4, 8, '2006-03-09', 'b', 'b'), +(4, 5, '2001-06-05', 'x', 'x'), +(7, 7, '2006-05-28', 'g', 'g'), +(4, 5, '2001-04-19', 'p', 'p'), +(1, 1, '1900-01-01', 'q', 'q'), +(9, 6, '2004-08-20', 'w', 'w'), +(4, 2, '2004-10-10', 'd', 'd'), +(8, 9, '2000-04-02', 'e', 'e') +; +SET UNIQUE_CHECKS = 0; +SET FOREIGN_KEY_CHECKS = 0; +SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +SET FOREIGN_KEY_CHECKS = 1; +SET UNIQUE_CHECKS = 1; +CREATE TABLE t2 SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +SELECT * FROM t2 +WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +); +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +DROP TABLE t1, t2; +# +# BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == +# SAVE_READ_SET +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +PRIMARY KEY (c,a), KEY (a),KEY (a) +) ENGINE=INNODB PARTITION BY KEY () PARTITIONS 2; +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1 VALUES (1,5,1),(2,4,1),(3,3,1),(4,2,1),(5,1,1); +UPDATE t1 SET b = 0, c=1 WHERE a <=>0; +SELECT * FROM t1; +a b c +1 5 1 +2 4 1 +3 3 1 +4 2 1 +5 1 1 +DROP TABLE t1; +# +# BUG#13256446 - ASSERTION QUICK->HEAD->READ_SET == +# SAVE_READ_SET' FAILED IN OPT_RANGE.CC:1606 +# +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f2=103; +INSERT INTO t1 VALUES (154,0,NULL,0),(0,NULL,9,0), +(NULL,102,NULL,3),(0,3,NULL,0), (9,0,NULL,0),(0,9,NULL,157); +SELECT * FROM v2; +f1 f2 f3 f4 +UPDATE v2 SET f4=0, f2=NULL, f1=NULL WHERE f1 > 16 ORDER BY f1; +SELECT * FROM v2; +f1 f2 f3 f4 +DROP TABLE t1; +DROP VIEW v2; +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,NULL,NULL,0), (2,2,0,3), (9,0,107,18), +(10,0,0,0), (231,0,0,0), (232,0,8,0), (234,0,0,NULL), (235,8,0,3); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f1<=85 ; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +UPDATE v3 SET f3=0, f4=4 WHERE f2=68 ORDER BY f1; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +DROP TABLE t1; +DROP VIEW v3; +# +# BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(3),(5); +SELECT * FROM t1 WHERE pk <> 3 OR pk < 4; +pk +1 +3 +5 +DROP TABLE t1; +# +# BUG#13803810: TOO FEW ROWS RETURNED FOR RANGE ACCESS IN +# VARCHAR INDEX USING DATETIME VALUE + +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +CREATE TABLE t2 (b VARCHAR(64), KEY (b)) CHARSET utf8mb4; +INSERT INTO t2 VALUES ('2001-01-01'); +INSERT INTO t2 VALUES ('2001.01.01'); +INSERT INTO t2 VALUES ('2001#01#01'); +INSERT INTO t2 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); + +# range/ref access cannot be used for this query + +EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = (cast('2001-01-01' as date))) +SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +b +2001#01#01 +2001-01-01 +2001-01-01 00:00:00 +2001.01.01 + +# range/ref access cannot be used for any of the queries below. +# See BUG#13814468 about 'Range checked for each record' + +EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = cast(`test`.`t2`.`b` as datetime(6))) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (cast(`test`.`t2`.`b` as datetime(6)) = `test`.`t1`.`a`) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +DROP TABLE t1,t2; +# +# WL#7019: Add support for row value constructors in in predicates to +# range optimizer +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY x(a, b)); +INSERT INTO t1 VALUES (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), +(7, 7, 7), (8, 8, 8), (9, 9, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +CREATE TABLE t3 (a INT, b INT, c INT, d INT, KEY x(a, b, c)); +INSERT INTO t3 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((NULL, NULL), (NULL, NULL)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((NULL,NULL),(NULL,NULL))) +EXPLAIN SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +a b +0 0 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` where ((`test`.`t3`.`a`,`test`.`t3`.`b`,`test`.`t3`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 19.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 19.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1) and (`test`.`t2`.`a` = 1)) or ((`test`.`t2`.`c` = 0) and (`test`.`t2`.`b` = 0) and (`test`.`t2`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`c` = 1) and (`test`.`t3`.`b` = 1) and (`test`.`t3`.`a` = 1)) or ((`test`.`t3`.`c` = 0) and (`test`.`t3`.`b` = 0) and (`test`.`t3`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +a b +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (('0',0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +SET @v = 0; +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (((@`v`),0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +CREATE TABLE t4 ( a INT, b INT ); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t4 SELECT a + 5, b + 5 FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +# Inner table in a nested-loops join +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 USING(a, b) +WHERE (t4.a, t4.b) IN ((1, 1), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 2.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 2.00 Using where +2 SIMPLE t1 NULL ref x x 10 test.t4.a,test.t4.b 409 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t4`.`b`) and (`test`.`t1`.`a` = `test`.`t4`.`a`) and ((`test`.`t4`.`a`,`test`.`t4`.`b`) in ((1,1),(0,0)))) +# Join on IN +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(0,0))) +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(1,1))) +# +# Tests for non-deterministic functions. +# +CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (f1(), 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 4098 0.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(`f1`(),1,1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,`f1`(),1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, f1())); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,1,`f1`()))) +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index x x 10 NULL 4098 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = `f1`())) +DROP FUNCTION f1; +# The statement immediately below should not use range access. +EXPLAIN +SELECT a, b +FROM t1 AS t1o +WHERE EXISTS (SELECT /*+ NO_SEMIJOIN() */ 1 +FROM t1 +WHERE (a, b) IN ((t1o.a, t1o.b)) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1o NULL index NULL x 10 NULL 4098 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref x x 10 test.t1o.a,test.t1o.b 409 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1o.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1o.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1o`.`a` AS `a`,`test`.`t1o`.`b` AS `b` from `test`.`t1` `t1o` where exists(/* select#2 */ select 1 from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1o`.`a`) and (`test`.`t1`.`b` = `test`.`t1o`.`b`))) +# +# Tests of dynamic range access +# +CREATE TABLE t5 (a int, b int, KEY (a)); +INSERT INTO t5 VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1); +CREATE TABLE t6 (a int, b int, KEY (a)); +INSERT INTO t6 VALUES (3, 2), (4, 2), (100, 100), (101, 201), (102, 102); +CREATE TABLE t7 (a int, b int, KEY (a, b)); +INSERT INTO t7 VALUES (1, 1), (2, 2), (1000, 1000), (1001, 1001), (1002, 1002), +(1003, 1003), (1004, 1004); +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and (`test`.`t7`.`a` in (`test`.`t5`.`b`,`test`.`t6`.`b`))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +a b a b a b +3 1 3 2 1 1 +3 1 3 2 2 2 +4 1 4 2 1 1 +4 1 4 2 2 2 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and ((`test`.`t7`.`a`,`test`.`t7`.`b`) in ((`test`.`t5`.`b`,1),(`test`.`t6`.`b`,1)))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +a b a b a b +3 1 3 2 1 1 +4 1 4 2 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +# +# Regression tests of the worklog below. +# +# Make sure we process IN predicates only. +# The code around this is very unclear. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) != (1, 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4098 99.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index x x 10 NULL 4098 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` <> 1) or (`test`.`t1`.`b` <> 1)) +# This should give us a ref scan, as it always did. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +EXPLAIN SELECT a, b FROM t1 WHERE (a, c) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`c` = 0) and (`test`.`t1`.`a` = 0)) +# ref scan on x(a). +EXPLAIN SELECT * FROM t1 WHERE (a, c) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 20.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`c`) in ((0,0),(1,1))) +DROP TABLE t1, t2, t3, t4, t5, t6, t7; +# +# Bug#17635476: CRASH IN GET_MM_PARTS() OR ASSERT IN +# GET_FUNC_MM_TREE_FROM_IN_PREDICATE() +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY (a) +) ENGINE = INNODB; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +INSERT INTO t1 VALUES (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), +(7, 7), (8, 8), (9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 ( +a INT, +b INT, +KEY (a, b) +); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((NULL,`test`.`t1`.`b`) in ((0,0),(1,1))) +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 10 NULL 10 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((NULL,`test`.`t2`.`b`) in ((0,0),(1,1))) +DROP TABLE t1, t2; +# +# Bug#17755540 VALGRIND ERROR WHEN SETTING UP ROW COMPARATORS +# +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT a, b FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +DROP TABLE t2; +# +# BUG#18364815: OPTIMIZER PREFERS TABLE SCAN WHEN +# USING "IN" WITH VALUE OF DIFFERENT TYPE +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,1), (5,1), (6,1); +EXPLAIN SELECT * FROM t1 WHERE a IN (1, 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE a IN (1, "2"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,'2')) +SELECT * FROM t1 WHERE a IN (1, 2); +a b +1 1 +2 1 +SELECT * FROM t1 WHERE a IN (1, "2"); +a b +1 1 +2 1 +DROP TABLE t1; +# +# Bug#18715670 +# CRASH IN DECIMAL_ACTUAL_FRACTION COMPARING DECIMAL TO NULLS +# +CREATE TABLE t1(n DECIMAL(39,19) NOT NULL, KEY(n)) engine=innodb; +INSERT INTO t1 SET n=0; +SELECT 1 FROM t1 WHERE n NOT IN(NULL, NULL); +1 +DROP TABLE t1; +# +# Bug#18759597 MISSING ROWS ON WHERE .. +# IN QUERY WITH VARIABLES AND CONCAT +# +CREATE TABLE t1 ( +col_varchar_key varchar(2), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('n'),('xm'); +SET @var1 = 't', @var2 = 'him', +@var3 = 'n', @var4 = 'n', +@var5 = 'n', @var6 = 'g', +@var7 = 'b', @var8 = 'o', +@var9 = 'm', @var10 = 'xm', @var11 = 'u' +; +SELECT col_varchar_key AS field1 +FROM t1 +WHERE ( col_varchar_key, col_varchar_key ) IN ( +('m', @var1 ), +('n', @var3 ), +('a', @var5 ), +('l', @var7 ), +(CONCAT('x', @var9 ), @var10 ) +); +field1 +n +xm +DROP TABLE t1; +# +# Bug#18535226 DEBUG CRASH ON QUICK_RANGE_SELECT::RESET +# +SET @old_tmp_table_size=@@tmp_table_size; +SET tmp_table_size=1024; +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_date_key date, +col_date_nokey date, +col_time_key time, +col_time_nokey time, +col_datetime_key datetime, +col_datetime_nokey datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(5,0,'2001-05-06','2001-05-06','16:21:18','16:21:18','2001-11-08 21:02:12', +'2001-11-08 21:02:12','x','x'),(6,7,'2006-03-03','2006-03-03','18:56:33', +'18:56:33','2003-04-01 00:00:00','2003-04-01 00:00:00','i','i'), +(7,7,'2007-12-28','2007-12-28',NULL,NULL,'1900-01-01 00:00:00', +'1900-01-01 00:00:00','e','e'),(8,1,'2004-10-20','2004-10-20','09:29:08', +'09:29:08','2007-07-12 00:00:00','2007-07-12 00:00:00','p','p'), +(9,7,'2008-04-09','2008-04-09','19:11:10','19:11:10', +'2005-04-04 01:21:01','2005-04-04 01:21:01','s','s'), +(10,1,'2005-12-25','2005-12-25','11:57:26','11:57:26', +'1900-01-01 00:00:00','1900-01-01 00:00:00','j','j'); +SELECT alias1.col_int_key +FROM +( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1, t1 AS SQ1_alias2 ) AS alias1, +(SELECT 7 AS col_int_nokey) AS alias2 +WHERE +alias2.col_int_nokey = alias1.pk +AND alias1.col_varchar_nokey < alias1.col_varchar_key +ORDER BY alias1.col_varchar_key; +col_int_key +DROP TABLE t1; +SET tmp_table_size=@old_tmp_table_size; +SET sql_mode = default; +# +# Bug#19585938 Crash in get_full_func_mm_tree with null +# item_field->table_ref +# +CREATE TABLE t1(id INTEGER, col1 INTEGER, col2 INTEGER, PRIMARY KEY(id)); +INSERT INTO t1 VALUES (1,2,3), (3,2,1); +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) < id +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id > SUM(1) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN id AND id+1 +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id BETWEEN SUM(1) AND SUM(5) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN COUNT(*) AND id +) AS c +FROM t1 +GROUP BY col1; +c +1 +DROP TABLE t1; +# +# Bug#21415791 VALGRIND ERROR (CONDITIONAL JUMP) AT KEY_AND +# (RANGE_OPT_PARAM*, SEL_ARG*, SEL_AR +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +pk INTEGER NOT NULL, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t1 ( +pk, col_varchar_10, col_int_key) VALUES +(1, 'ttttt', 0), (2, 'zzzzz', 0), (3, 'ggggg', 0), +(4, 'hhhhh', 0), (5, 'kkkkk', 0), (6, 'lllll', 0); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t2 ( +pk, col_varchar_10) VALUES +(1, '00000'), (2, '00000'), (3, '44444'), (4, '00000'), +(5, NULL), (6, NULL), (7, NULL); +SELECT COUNT(t1.col_int_key) +FROM t2 RIGHT OUTER JOIN t1 ON t2.col_varchar_10 <= t1.col_varchar_10 +WHERE t2.pk <> 4 OR t2.pk != t1.col_int_key AND t2.pk <> 1000; +COUNT(t1.col_int_key) +24 +DROP TABLE t1, t2; +# +# Bug #20229614: OR CONDITIONS ON MULTI-COLUMN INDEX MAY NOT USE ALL +# INDEX COLUMNS TO FILTER ROWS +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c3 INT, +PRIMARY KEY(c1, c2, c3) +) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 2), (1, 1, 3), +(1, 1, 4), (1, 1, 5); +INSERT INTO t1 SELECT c1, 2, c3 FROM t1; +INSERT INTO t1 SELECT c1, 3, c3 FROM t1 WHERE c2 = 1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +15 +EXPLAIN SELECT c1, c2, c3 +FROM t1 +WHERE (c1 = 1 AND c2 = 1 AND c3 = 1) OR +(c1 = 1 AND c2 = 2 AND c3 = 2) OR +(c1 = 1 AND c2 = 2 AND c3 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 12 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where (((`test`.`t1`.`c3` = 1) and (`test`.`t1`.`c2` = 1) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 3) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1))) +DROP TABLE t1; +# +# Bug#21139683: ASSERTION FAILED: TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE +# +CREATE TABLE t1 ( +a BLOB, +PRIMARY KEY(a(1)), +KEY(a(1)) +) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE a <> 'a' OR a <> ""; +1 +DROP TABLE t1; +# +# Bug#19333852: RESULT DIFF IN QUERY HAVING DISTINCT +# WITH GROUP BY +# +CREATE TABLE t1 ( +v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY v1_key (v1(10)) +) ENGINE=InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); +EXPLAIN SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` < (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v1_key v1_key 32 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` = (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` between 'f' and (char(127))) +SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +v1 pk +ABCDE 19 +JLVGO 14 +SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +v1 pk +SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +v1 pk +JLVGO 14 +DROP TABLE t1; +# +# Bug #21761867: ASSERTION `TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE' FAILED. +# +CREATE TABLE t1 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +c18 INT, +PRIMARY KEY (c10,c12), +UNIQUE KEY key_c12(c12), +KEY key_c18(c18)); +INSERT INTO t1 VALUES(11,5,0), (12,6,1), (13,7,2), (14,8,3), (15,9,4); +CREATE TABLE t2 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +PRIMARY KEY(c10,c12)); +CREATE TABLE t3 (c10 INT NOT NULL); +SELECT t2.c10 +FROM t1 +RIGHT JOIN t3 +LEFT JOIN t2 +ON t3.c10 = t2.c10 +ON t1.c12 > t2.c12 +WHERE +t1.c10 <= 25 +AND +t1.c18 IS NOT NULL +OR +t1.c10 > 5 +AND +t1.c18 IN (15,16,18); +c10 +DROP TABLE t1, t2, t3; +# +# Bug #21318711: WRONG RESULTS FOR TRUNCATED COLUMN AND AGGREGATION +# +CREATE TABLE t1 ( +col1 VARCHAR(5), +col2 INT NOT NULL, +PRIMARY KEY (col1, col2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('abcde', 10); +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where (`test`.`t1`.`col1` = 'abcdeaa') +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where multiple equal('abcde ', `test`.`t1`.`col1`) +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +MAX(col2) +NULL +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +MAX(col2) +10 +DROP TABLE t1; +# +# Bug# 22283790: RANGE OPTIMIZER UTILIZES TOO MUCH MEMORY WITH +# MANY OR CONDITIONS +# +CREATE TABLE t1 ( +f1 INTEGER, +KEY (f1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15); +SET @orig_range_optimizer_max_mem_size= @@range_optimizer_max_mem_size; +SET range_optimizer_max_mem_size= 5000; +EXPLAIN SELECT * FROM t1 WHERE f1=1 OR f1=2 OR f1=3 OR f1=4 OR f1=5 +OR f1=6 OR f1=7 OR f1=8 OR f1=9 OR f1=10 OR f1=11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range f1 f1 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` = 1) or (`test`.`t1`.`f1` = 2) or (`test`.`t1`.`f1` = 3) or (`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f1` = 5) or (`test`.`t1`.`f1` = 6) or (`test`.`t1`.`f1` = 7) or (`test`.`t1`.`f1` = 8) or (`test`.`t1`.`f1` = 9) or (`test`.`t1`.`f1` = 10) or (`test`.`t1`.`f1` = 11)) +SET range_optimizer_max_mem_size= @orig_range_optimizer_max_mem_size; +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +SELECT * FROM t1 WHERE pk IN (3, 8) OR pk NOT IN (2); +pk +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +# Indirectly tests ORing with a tree that has a nonzero refcount, +# where nodes are also being skipped over. (There was a bug in +# refcounting such trees earlier.) +# +CREATE TABLE t1 ( +col_int_key int, +pk int NOT NULL, +col_int int, +KEY test_idx (pk,col_int_key,col_int) +); +SELECT * FROM t1 WHERE +(col_int_key >= 6 AND pk > 6) OR +(pk > 2 AND col_int_key = 7 AND col_int > 6); +col_int_key pk col_int +DROP TABLE t1; +# +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE `giant_table` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`one_id` int(11) NOT NULL, +`other_id` bigint(20) NOT NULL DEFAULT '0', +`some_other_id` int(11) DEFAULT 0 NOT NULL, +`something` double NOT NULL DEFAULT '0', +`comment` text COLLATE utf8_unicode_ci, +`flags` int(11) NOT NULL DEFAULT '0', +`time_created` int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (`id`), +KEY `time_created` (`time_created`), +KEY `some_other_id` (`some_other_id`), +KEY `one_other_idx` (`one_id`,`other_id`), +KEY `other_id` (`other_id`,`time_created`) +) ENGINE=InnoDB AUTO_INCREMENT=101651329 +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (66136540), (68983250), (89627210), (77869520), +(82543190), (67538270), (77282760), (77908170), +(70923370), (68066360); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT INTO giant_table(id,one_id) +SELECT c1 + @x, 0 +FROM t1 +WHERE c1 IN (66136540, 68985250, 89627210, 77869520 , 82543190, 67538270, +77282760, 77908170, 70923370, 68066360); +SET @x = @x + 1; +UNTIL @x > 30 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM giant_table; +count(*) +270 +INSERT INTO giant_table (id,one_id) VALUES (66136539, 0), (68983258,1), +(89628210,1), (77869520,2); +INSERT INTO giant_table (id,one_id, some_other_id) VALUES(84673401, 0, 1), +(61069031, 1, 1); +EXPLAIN SELECT id, something, comment, time_created, one_id, other_id, +some_other_id, flags +FROM giant_table +WHERE id IN (66136539, 68983258, 89628210, 77869520, 82543198, 67538272, +84673401, 61069031, 68214385, 77282865, 76991297, 64569216, +89481638, 74534074, 70396537, 80076375, 63308530, 77908270, +70923271, 68066180) +AND (giant_table.flags & 0x01) = 0 AND giant_table.some_other_id = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE giant_table NULL range PRIMARY,some_other_id some_other_id 8 NULL 20 100.00 Using where; Using MRR +Warnings: +Note 1003 /* select#1 */ select `test`.`giant_table`.`id` AS `id`,`test`.`giant_table`.`something` AS `something`,`test`.`giant_table`.`comment` AS `comment`,`test`.`giant_table`.`time_created` AS `time_created`,`test`.`giant_table`.`one_id` AS `one_id`,`test`.`giant_table`.`other_id` AS `other_id`,`test`.`giant_table`.`some_other_id` AS `some_other_id`,`test`.`giant_table`.`flags` AS `flags` from `test`.`giant_table` where ((`test`.`giant_table`.`some_other_id` = 0) and (`test`.`giant_table`.`id` in (66136539,68983258,89628210,77869520,82543198,67538272,84673401,61069031,68214385,77282865,76991297,64569216,89481638,74534074,70396537,80076375,63308530,77908270,70923271,68066180)) and ((`test`.`giant_table`.`flags` & 0x01) = 0)) +DROP PROCEDURE p; +DROP TABLE giant_table, t1; +# +# Bug#22671573: SIG11 IN SEL_ARG::RB_INSERT |SQL/OPT_RANGE.CC +# +# Tests creating an empty tree (impossible condition) and then ANDing with it. +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY test_idx (b, a) +); +SELECT * FROM t1 WHERE b BETWEEN 8 AND 8 AND a > 8 AND a <= 8; +a b +DROP TABLE t1; +# +# Indirectly tests inserting a node into an empty (impossible) tree. +# +CREATE TABLE t1 ( +pk INT, +PRIMARY KEY ( pk ) +); +SELECT * FROM t1 WHERE pk = 6 OR pk > 6; +pk +DROP TABLE t1; +# +# Indirectly tests ORing with an empty (impossible) tree. +# +CREATE TABLE t1 ( +col_int_key INT, +KEY (col_int_key) +); +SELECT * FROM t1 WHERE col_int_key IS NULL OR col_int_key < 9 OR col_int_key = 9; +col_int_key +DROP TABLE t1; +# +# Indirectly tests deleting the last node from a tree +# (which makes it IMPOSSIBLE) and then inserting more than one node. +# +CREATE TABLE t1 ( +a VARCHAR(64), +KEY a (a) +); +SELECT * FROM t1 WHERE a IS NULL OR a NOT IN ( 'foo', 'bar' ); +a +DROP TABLE t1; +# +# Bug#25229315: ASSERTION TABLE->M_RECORD_BUFFER.RECORD_SIZE() == +# RECORD_PREFIX_SIZE(TAB)' FAIL +# +CREATE TABLE t1 (pk INT PRIMARY KEY, vc VARCHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, NULL), (2, 'w'); +CREATE TABLE t2 ( +i INT, +vc VARCHAR(1), +pk INT PRIMARY KEY, +KEY (i), +KEY (vc) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 'p', 1), (9, 'w', 2), (NULL, 'r', 3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL i,vc NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x6) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`vc` = `test`.`t1`.`vc`) or (`test`.`t2`.`i` = `test`.`t1`.`pk`)) +SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +MIN(t1.pk) +1 +DROP TABLE t1, t2; +# +# Bug #26727773: OPTIMIZER CHOSES COMPOSITE INDEX FOR REF OVER RANGE +# +CREATE TABLE transactions ( +app_trans_id INT DEFAULT NULL, +id INT NOT NULL, +tbl INT NOT NULL DEFAULT 1, +created TIMESTAMP NOT NULL DEFAULT '2017-01-01 01:01:01', +trans_type INT NOT NULL, +description BLOB, +source_lvl1 INT DEFAULT NULL, +source_lvl2 INT DEFAULT NULL, +KEY tbl_id_idx (tbl,id), +KEY created_idx (created), +KEY trans_type_created_idx (trans_type,created), +KEY app_trans_id_idx (app_trans_id) +) ENGINE=INNODB ; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1000), (2000), (3000), (4000), (5000), (6000), +(7000), (8000), (9000); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT IGNORE INTO transactions(id,trans_type, description) +SELECT c1 + @x, @x , 'abcd' + FROM t1; +SET @x = @x + 1; +UNTIL @x > 300 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM transactions; +count(*) +3000 +INSERT IGNORE INTO transactions(id,trans_type, description, created) +SELECT 3, 3 , 'abcd', '2018-01-01 01:01:01' + FROM dual; +EXPLAIN SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE transactions NULL range tbl_id_idx,created_idx,trans_type_created_idx created_idx 4 NULL # # Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select '2017-10-23 01:01:01' AS `2017-10-23 01:01:01`,hour(`test`.`transactions`.`created`) AS `HOUR(created)`,`test`.`transactions`.`source_lvl1` AS `source_lvl1`,`test`.`transactions`.`source_lvl2` AS `source_lvl2`,count(distinct `test`.`transactions`.`app_trans_id`) AS `COUNT(DISTINCT(app_trans_id))` from `test`.`transactions` where ((`test`.`transactions`.`trans_type` = 3) and (`test`.`transactions`.`tbl` = 1) and (`test`.`transactions`.`created` > TIMESTAMP'2017-10-23 01:01:01')) group by '2017-10-23 01:01:01',hour(`test`.`transactions`.`created`),`test`.`transactions`.`source_lvl1`,`test`.`transactions`.`source_lvl2` +SET optimizer_trace="enabled=on"; +SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +2017-10-23 01:01:01 HOUR(created) source_lvl1 source_lvl2 COUNT(DISTINCT(app_trans_id)) +2017-10-23 01:01:01 1 NULL NULL 0 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +SET optimizer_trace="enabled=off"; +DROP PROCEDURE p; +DROP TABLE t1, transactions; +# +# Bug #28086754: OPTIMIZER SKIP THE RANG SCAN ON SECOND COLUMN IN A +# COMPOSITE INDEX +# +CREATE TABLE test_ref ( +a INT PRIMARY KEY, +b VARCHAR(20), +c VARCHAR(20) DEFAULT NULL, +d VARCHAR(3) DEFAULT NULL, +id INT DEFAULT NULL, +KEY idx1 (id, c), +KEY idx2 (id, d)) ENGINE=INNODB ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze Error Table 'test.t1' doesn't exist +test.t1 analyze status Operation failed +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c`,`test`.`test_ref`.`a` limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +a b c d id +34876 D003 gheennse S 3 +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c` desc,`test`.`test_ref`.`a` desc limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +a b c d id +1770649 D003 gheennse S 3 +DROP TABLE test_ref; +# +# Bug #30988735: SELECT QUERY WITH ERROR RESULT WITH "NOT IN" +# WHERE_CLAUSE +# +CREATE TABLE t(f1 INTEGER key, f2 INTEGER)ENGINE=INNODB; +INSERT INTO t VALUES(0,0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT f1,f2 FROM t WHERE f1 NOT IN(-0.1,0.1); +f1 f2 +0 0 +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/range_mrr_cost.result-pq b/mysql-test/r/range_mrr_cost.result-pq new file mode 100644 index 000000000..b8c46b578 --- /dev/null +++ b/mysql-test/r/range_mrr_cost.result-pq @@ -0,0 +1,3997 @@ +set optimizer_switch='mrr=on,mrr_cost_based=on'; +drop table if exists t1, t2, t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +event_date date DEFAULT '0000-00-00' NOT NULL, +type int(11) DEFAULT '0' NOT NULL, +event_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (event_date,type,event_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25), +('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26), +('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45), +('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5), +('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17), +('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40), +('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6), +('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41), +('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41), +('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29), +('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19), +('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42), +('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30), +('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8), +('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22), +('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43), +('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37), +('1999-09-19',100100,37), ('2000-12-18',100700,38); +explain select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 19.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 7 NULL 6 19.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where ((`test`.`t1`.`event_date` >= DATE'1999-07-01') and (`test`.`t1`.`event_date` < DATE'1999-07-15') and ((`test`.`t1`.`type` = 100600) or (`test`.`t1`.`type` = 100100))) order by `test`.`t1`.`event_date` +explain format=tree select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +EXPLAIN +-> Parallel scan on + -> Filter: ((t1.event_date >= DATE'1999-07-01') and (t1.event_date < DATE'1999-07-15') and ((t1.`type` = 100600) or (t1.`type` = 100100))) (cost=1.46 rows=1) + -> PQblock range scan on t1 using PRIMARY (cost=1.46 rows=6) + +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where false order by `test`.`t1`.`event_date` +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +1999-07-15 100600 16 +drop table t1; +CREATE TABLE t1 ( +PAPER_ID smallint(6) DEFAULT '0' NOT NULL, +YEAR smallint(6) DEFAULT '0' NOT NULL, +ISSUE smallint(6) DEFAULT '0' NOT NULL, +CLOSED tinyint(4) DEFAULT '0' NOT NULL, +ISS_DATE date DEFAULT '0000-00-00' NOT NULL, +PRIMARY KEY (PAPER_ID,YEAR,ISSUE) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'), +(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'), +(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'), +(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'), +(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'), +(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'), +(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'), +(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'), +(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'), +(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'), +(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'), +(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'), +(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'), +(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'), +(3,1999,35,0,'1999-07-12'); +select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE; +YEAR ISSUE +1999 29 +1999 30 +1999 31 +1999 32 +1999 33 +1999 34 +1999 35 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair note The storage engine for the table doesn't support repair +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2), +(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2), +(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1), +(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2), +(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2), +(19,3,2), (5,1,1), (179,5,2); +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +drop table t1; +create table t1( +Satellite varchar(25) not null, +SensorMode varchar(25) not null, +FullImageCornersUpperLeftLongitude double not null, +FullImageCornersUpperRightLongitude double not null, +FullImageCornersUpperRightLatitude double not null, +FullImageCornersLowerRightLatitude double not null, +index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude)); +insert into t1 values("OV-3","PAN1",91,-92,40,50); +insert into t1 values("OV-4","PAN1",91,-92,40,50); +select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000; +Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude +OV-3 PAN1 91 -92 40 50 +drop table t1; +create table t1 ( aString char(100) not null default "", key aString (aString(10)) ); +insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love"); +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +alter table t1 drop key aString; +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +drop table t1; +CREATE TABLE t1 ( +t1ID int(10) unsigned NOT NULL auto_increment, +art binary(1) NOT NULL default '', +KNR char(5) NOT NULL default '', +RECHNR char(6) NOT NULL default '', +POSNR char(2) NOT NULL default '', +ARTNR char(10) NOT NULL default '', +TEX char(70) NOT NULL default '', +PRIMARY KEY (t1ID), +KEY IdxArt (art), +KEY IdxKnr (KNR), +KEY IdxArtnr (ARTNR) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'); +select count(*) from t1 where upper(art) = 'J'; +count(*) +213 +select count(*) from t1 where art = 'J' or art = 'j'; +count(*) +602 +select count(*) from t1 where art = 'j' or art = 'J'; +count(*) +602 +select count(*) from t1 where art = 'j'; +count(*) +389 +select count(*) from t1 where art = 'J'; +count(*) +213 +drop table t1; +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` between 7 and ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` >= 7) and (`test`.`t2`.`x` <= ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between ((2 - 1)) and ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= ((2 - 1))) and (`test`.`t2`.`x` <= ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between 0 and 2)) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= 0) and (`test`.`t2`.`x` <= 2)) +explain select count(*) from t1 where x in (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` = 1) +explain select count(*) from t1 where x in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` in (1,2)) +drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +explain select * from t1 force index(i1), t2 force index(j1) where +(t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` FORCE INDEX (`i1`) join `test`.`t2` FORCE INDEX (`j1`) where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a), +KEY b (b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), +(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), +(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), +(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a,b a 5 NULL 2 40.54 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` in (1,2))) +SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +a b +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) +); +a b +15 1 +47 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id int( 11 ) unsigned NOT NULL AUTO_INCREMENT , +line int( 5 ) unsigned NOT NULL default '0', +columnid int( 3 ) unsigned NOT NULL default '0', +owner int( 3 ) unsigned NOT NULL default '0', +ordinal int( 3 ) unsigned NOT NULL default '0', +showid smallint( 6 ) unsigned NOT NULL default '1', +tableid int( 1 ) unsigned NOT NULL default '1', +content int( 5 ) unsigned NOT NULL default '188', +PRIMARY KEY ( owner, id ) , +KEY menu( owner, showid, columnid ) , +KEY `COLUMN` ( owner, columnid, line ) , +KEY `LINES` ( owner, tableid, content, id ) , +KEY recount( owner, line ) +) ENGINE = MYISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); +SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; +id columnid tableid content showid line ordinal +13 13 1 188 1 5 0 +15 15 1 188 1 1 0 +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select id from t1 where id in (2,5,9) ; +id +2 +5 +9 +select id from t1 where id=2 or id=5 or id=9 ; +id +2 +5 +9 +drop table t1; +create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2)); +insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), +(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"), +(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"), +(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"), +(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"), +(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"), +(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa"); +select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; +id1 idnull +drop table t1; +create table t1 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +create table t2 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +insert into t1(id, uid, name) values(1, 0, ' '); +insert into t1(uid, name) values(0, ' '); +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +delete from t2; +insert into t2(uid, name) values +(1, CHAR(64+1)), +(2, CHAR(64+2)), +(3, CHAR(64+3)), +(4, CHAR(64+4)), +(5, CHAR(64+5)), +(6, CHAR(64+6)), +(7, CHAR(64+7)), +(8, CHAR(64+8)), +(9, CHAR(64+9)), +(10, CHAR(64+10)), +(11, CHAR(64+11)), +(12, CHAR(64+12)), +(13, CHAR(64+13)), +(14, CHAR(64+14)), +(15, CHAR(64+15)), +(16, CHAR(64+16)), +(17, CHAR(64+17)), +(18, CHAR(64+18)), +(19, CHAR(64+19)), +(20, CHAR(64+20)), +(21, CHAR(64+21)), +(22, CHAR(64+22)), +(23, CHAR(64+23)), +(24, CHAR(64+24)), +(25, CHAR(64+25)), +(26, CHAR(64+26)); +insert into t1(uid, name) select uid, name from t2 order by uid; +delete from t2; +insert into t2(id, uid, name) select id, uid, name from t1; +select count(*) from t1; +count(*) +1026 +select count(*) from t2; +count(*) +1026 +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +drop table t1,t2; +create table t1 (x bigint unsigned not null); +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +create table t2 (x bigint not null); +insert into t2(x) values (-16); +insert into t2(x) values (-15); +select * from t2; +x +-16 +-15 +select count(*) from t2 where x>0; +count(*) +0 +select count(*) from t2 where x=0; +count(*) +0 +select count(*) from t2 where x<0; +count(*) +2 +select count(*) from t2 where x < -16; +count(*) +0 +select count(*) from t2 where x = -16; +count(*) +1 +select count(*) from t2 where x > -16; +count(*) +1 +select count(*) from t2 where x = 18446744073709551601; +count(*) +0 +drop table t1,t2; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +create table t1 (a bigint unsigned); +create index t1i on t1(a); +insert into t1 select 18446744073709551615; +insert into t1 select 18446744073709551614; +explain select * from t1 where a <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a <> -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1 or a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1 or a < -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where a < -1; +a +drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 11 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 'aaa') +explain select * from t1 where a=binary 'aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (cast('aaa' as char charset binary))) +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_bin))) +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 9 11.11 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_german1_ci))) +drop table t1; +CREATE TABLE t1 ( +`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', +`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTINT` int(11) NOT NULL default '0', +KEY `VERI_CLNT~2` (`ARG1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0), +('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0), +('001',' 3',' 0','Text 017',0); +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2'); +count(*) +4 +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1'); +count(*) +4 +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( +pk1 int(11) NOT NULL, +pk2 int(11) NOT NULL, +pk3 int(11) NOT NULL, +pk4 int(11) NOT NULL, +filler char(82), +PRIMARY KEY (pk1,pk2,pk3,pk4) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B; +INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'), +(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'), +(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler'); +SELECT * FROM t2 +WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635))) +OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635)))) +) AND (pk3 >=1000000); +pk1 pk2 pk3 pk4 filler +2621 2635 1000015 0 filler +drop table t1, t2; +create table t1(a char(2), key(a(1))) charset utf8mb4; +insert into t1 values ('x'), ('xx'); +explain select a from t1 where a > 'x'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'x') +select a from t1 where a > 'x'; +a +xx +drop table t1; +CREATE TABLE t1 ( +OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid', +OXLEFT int NOT NULL DEFAULT '0', +OXRIGHT int NOT NULL DEFAULT '0', +OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +PRIMARY KEY (OXID), +KEY OXNID (OXID), +KEY OXLEFT (OXLEFT), +KEY OXRIGHT (OXRIGHT), +KEY OXROOTID (OXROOTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'), +('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725521'); +EXPLAIN +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE v NULL ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 100.00 NULL +1 SIMPLE s NULL ref OXLEFT,OXROOTID OXROOTID 34 const 5 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`OXID` AS `oxid` from `test`.`t1` `v` join `test`.`t1` `s` where ((`test`.`s`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`v`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`s`.`OXLEFT` > `test`.`v`.`OXLEFT`) and (`test`.`s`.`OXLEFT` < `test`.`v`.`OXRIGHT`)) +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +oxid +d8c4177d151affab2.81582770 +d8c4177d206a333d2.74422679 +d8c4177d225791924.30714720 +d8c4177d2380fc201.39666693 +d8c4177d24ccef970.14957924 +DROP TABLE t1; +create table t1 ( +c1 char(10), c2 char(10), c3 char(10), c4 char(10), +c5 char(10), c6 char(10), c7 char(10), c8 char(10), +c9 char(10), c10 char(10), c11 char(10), c12 char(10), +c13 char(10), c14 char(10), c15 char(10), c16 char(10), +index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); +select * from t1 where +c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 +Warnings: +Warning 3170 Memory capacity of 8388608 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +drop table t1; +End of 4.1 tests +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +status varchar(20), +PRIMARY KEY (id), +KEY (status) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'), +(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'), +(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'), +(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'), +(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'), +(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'), +(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'), +(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'), +(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'), +(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C'); +EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not between 'A' and 'B') +EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` < 'A') or (`test`.`t1`.`status` > 'B')) +SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, primary key(a,b)); +INSERT INTO t1 VALUES +(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3); +CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3; +EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +SELECT a,b FROM t1 WHERE a < 2 and b=3; +a b +1 3 +SELECT a,b FROM v1 WHERE a < 2 and b=3; +a b +1 3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name)); +INSERT INTO t1 VALUES ('Betty'), ('Anna'); +SELECT * FROM t1; +name +Anna +Betty +DELETE FROM t1 WHERE name NOT LIKE 'A%a'; +SELECT * FROM t1; +name +Anna +DROP TABLE t1; +CREATE TABLE t1 (a int, KEY idx(a)); +INSERT INTO t1 VALUES (NULL), (1), (2), (3); +SELECT * FROM t1; +a +NULL +1 +2 +3 +DELETE FROM t1 WHERE NOT(a <=> 2); +SELECT * FROM t1; +a +2 +DROP TABLE t1; +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); +explain select * from t1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from v1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +explain select * from v1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +drop view v1; +drop table t1; +create table t3 (a int); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a varchar(10), filler char(200), key(a)) charset=binary; +insert into t1 values ('a',''); +insert into t1 values ('a ',''); +insert into t1 values ('a ', ''); +insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), '' + from t3 A, t3 B, t3 C; +create table t2 (a varchar(10), filler char(200), key(a)) charset utf8mb4; +insert into t2 select * from t1; +explain select * from t1 where a between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` between 'a' and 'a ') +explain select * from t1 where a = 'a' or a='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') or (`test`.`t1`.`a` = 'a ')) +explain select * from t2 where a between 'a' and 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` between 'a' and 'A') +explain select * from t2 where a = 'a' or a='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') or (`test`.`t2`.`a` = 'A')) +update t1 set a='b' where a<>'a'; +explain select * from t1 where a not between 'b' and 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` not between 'b' and 'b') +select a, hex(filler) from t1 where a not between 'b' and 'b'; +a hex(filler) +a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +drop table t1,t2,t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, key(a)); +insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C; +set @a="select * from t2 force index (a) where a NOT IN(0"; +select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z; +count(*) +1000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @a=concat(@a, ')'); +insert into t2 values (11),(13),(15); +set @b= concat("explain ", @a); +prepare stmt1 from @b; +execute stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1003 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,604,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,784,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1146,1148,1150,1152,1154,1156,1158,1160,1162,1164,1166,1168,1170,1172,1174,1176,1178,1180,1182,1184,1186,1188,1190,1192,1194,1196,1198,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222,1224,1226,1228,1230,1232,1234,1236,1238,1240,1242,1244,1246,1248,1250,1252,1254,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292,1294,1296,1298,1300,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1370,1372,1374,1376,1378,1380,1382,1384,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408,1410,1412,1414,1416,1418,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458,1460,1462,1464,1466,1468,1470,1472,1474,1476,1478,1480,1482,1484,1486,1488,1490,1492,1494,1496,1498,1500,1502,1504,1506,1508,1510,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1552,1554,1556,1558,1560,1562,1564,1566,1568,1570,1572,1574,1576,1578,1580,1582,1584,1586,1588,1590,1592,1594,1596,1598,1600,1602,1604,1606,1608,1610,1612,1614,1616,1618,1620,1622,1624,1626,1628,1630,1632,1634,1636,1638,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678,1680,1682,1684,1686,1688,1690,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1714,1716,1718,1720,1722,1724,1726,1728,1730,1732,1734,1736,1738,1740,1742,1744,1746,1748,1750,1752,1754,1756,1758,1760,1762,1764,1766,1768,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790,1792,1794,1796,1798,1800,1802,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822,1824,1826,1828,1830,1832,1834,1836,1838,1840,1842,1844,1846,1848,1850,1852,1854,1856,1858,1860,1862,1864,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1886,1888,1890,1892,1894,1896,1898,1900,1902,1904,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1964,1966,1968,1970,1972,1974,1976,1978,1980,1982,1984,1986,1988,1990,1992,1994,1996,1998)) +prepare stmt1 from @a; +execute stmt1; +a +11 +13 +15 +drop table t1, t2; +CREATE TABLE t1 ( +id int NOT NULL DEFAULT '0', +b int NOT NULL DEFAULT '0', +c int NOT NULL DEFAULT '0', +INDEX idx1(b,c), INDEX idx2(c)); +INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(b,c) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` <= 3) and (3 <= `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (3 between `test`.`t1`.`b` and `test`.`t1`.`c`) +SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((0 < `test`.`t1`.`b`) or (0 > `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (0 not between `test`.`t1`.`b` and `test`.`t1`.`c`) +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +EXPLAIN +-> Filter: (0 not between t1.b and t1.c) (cost=2.15 rows=3) + -> Index range scan on t1 using sort_union(idx1,idx2) (cost=2.15 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( +item char(20) NOT NULL default '', +started datetime NOT NULL default '0000-00-00 00:00:00', +price decimal(16,3) NOT NULL default '0.000', +PRIMARY KEY (item,started) +) ENGINE=MyISAM, CHARSET utf8mb4; +INSERT INTO t1 VALUES +('A1','2005-11-01 08:00:00',1000), +('A1','2005-11-15 00:00:00',2000), +('A1','2005-12-12 08:00:00',3000), +('A2','2005-12-01 08:00:00',1000); +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP INDEX `PRIMARY` ON t1; +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP TABLE t1; + +BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly" + +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +dateval date default NULL, +PRIMARY KEY (id), +KEY dateval (dateval) +) AUTO_INCREMENT=173; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'), +(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'), +(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11'); +This must use range access: +explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range dateval dateval 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`dateval` AS `dateval` from `test`.`t1` where ((`test`.`t1`.`dateval` >= DATE'2007-01-01') and (`test`.`t1`.`dateval` <= DATE'2007-01-02')) +drop table t1; +CREATE TABLE t1 ( +a varchar(32), index (a) +) DEFAULT CHARSET=latin1 COLLATE=latin1_bin; +INSERT INTO t1 VALUES +('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'); +SELECT a FROM t1 WHERE a='b' OR a='B'; +a +B +B +EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 35 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'b') or (`test`.`t1`.`a` = 'B')) +DROP TABLE t1; +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); +SELECT COUNT(*) FROM t1 WHERE f1 < 256; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 256.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 255; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 < -1; +COUNT(*) +0 +SELECT COUNT(*) FROM t1 WHERE f1 > -1; +COUNT(*) +5 +DROP TABLE t1; +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); +SELECT COUNT(*) FROM t1 WHERE f1 < 128; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 128.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 127; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 > -129; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -129.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -128; +COUNT(*) +4 +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100)); +insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, +t1 B, t1 C where A.a < 5; +insert into t2 select 1000, b, 'filler' from t2; +alter table t2 add index (a,b); +Access method can be range/ALL with #rows >= 500. +Or it can be ref with #rows = 2, only when there is memory limit. +explain select * from t2 where a=1000 and b<11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 50.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL a NULL NULL NULL 1000 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 1000) and (`test`.`t2`.`b` < 11)) +drop table t1, t2; +CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t3( a INT, b INT, KEY( a, b ) ); +INSERT INTO t1( a, b ) +VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7); +INSERT INTO t2( a, b ) +VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1), +( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1), +(11, 1), (12, 1), (13, 1), (14, 1), (15, 1), +(16, 1), (17, 1), (18, 1), (19, 1), (20, 1); +INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t3 +VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), +(6, 0), (7, 0), (8, 0), (9, 0), (10, 0); +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 < `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 1) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +5 2 +6 1 +6 2 +7 1 +7 2 +8 1 +8 2 +9 1 +9 2 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 2) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +a b +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +EXPLAIN +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`b` = 3) and (5 <= `test`.`t3`.`a`) and (`test`.`t3`.`a` < 10)) or (`test`.`t3`.`a` < 5) or (`test`.`t3`.`a` < 10)) +DROP TABLE t1, t2, t3; +# +# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL); +a +DROP TABLE t1; +# +# Bug#47925: regression of range optimizer and date comparison in 5.1.39! +# +CREATE TABLE t1 ( a DATE, KEY ( a ) ); +CREATE TABLE t2 ( a DATETIME, KEY ( a ) ); +# Make optimizer choose range scan +INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22'); +INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23'); +INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'), +('2009-09-22 12:00:00'); +INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'), +('2009-09-23 12:00:00'); +# DATE vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# DATE vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923120000'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923120000; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923000000'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923000000; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# Test of the new get_date_from_str implementation +# Behavior differs slightly between the trunk and mysql-pe. +# The former may give errors for the truncated values, while the latter +# gives warnings. The purpose of this test is not to interfere, and only +# preserve existing behavior. +# This case was made obsolete after the changes applied by +# Bug#28940878 WRONG RESULT WHEN COMPARING DATE[TIME] WITH STRING +# as we don't fallback anymore to string comparison if the date is invalid. +SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND +str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND +str_to_date('2007-20-00', '%Y-%m-%d') <= ''; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; +str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''; +str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +SELECT str_to_date('', '%Y-%m-%d'); +str_to_date('', '%Y-%m-%d') +0000-00-00 +DROP TABLE t1, t2; +# +# Bug#48459: valgrind errors with query using 'Range checked for each +# record' +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY ( c ), +KEY ( d, a, b ( 2 ) ), +KEY ( b ( 1 ) ) +); +INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ), +( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 ); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY ( e ) +); +INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL ); +# Should not give Valgrind warnings +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug #48665: sql-bench's insert test fails due to wrong result +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (0,0), (1,1); +EXPLAIN +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +@ @ @ NULL ALL @ @ @ @ @ 100.00 @ +@ @ @ NULL range @ @ @ @ @ 100.00 @ +Warnings: +@ @ @ +# Should return 2 rows +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +a b +0 0 +1 1 +DROP TABLE t1; +# +# Bug #54802: 'NOT BETWEEN' evaluation is incorrect +# +CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key)); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c_key NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_key` AS `c_key`,`test`.`t1`.`c_notkey` AS `c_notkey` from `test`.`t1` where (2 not between `test`.`t1`.`c_notkey` and `test`.`t1`.`c_key`) +SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +c_key c_notkey +1 1 +3 3 +DROP TABLE t1; +# +# Bug #57030: 'BETWEEN' evaluation is incorrect +# +CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT); +CREATE UNIQUE INDEX i4_uq ON t1(i4); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30); +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between 10 and `test`.`t1`.`i4`) +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between `test`.`t1`.`i4` and 10) +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i4_uq 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 100 and 0) +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and 99999999999999999) +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 999999999999999 and 30) +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and '20') +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +pk i4 +1 10 +2 20 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`) +EXPLAIN FORMAT=tree +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.60 rows=3) + -> Filter: (t1.i4 is not null) (cost=0.55 rows=3) + -> PQblock scan on t1 using i4_uq (cost=0.55 rows=3) + -> Filter: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.i4) (cost=0.28 rows=1) + +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +pk i4 pk i4 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`) +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +pk i4 pk i4 +DROP TABLE t1; +# +# BUG#13519696 - 62940: SELECT RESULTS VARY WITH VERSION AND +# WITH/WITHOUT INDEX RANGE SCAN +# +create table t1 (id int unsigned not null auto_increment primary key); +insert into t1 values (null); +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +create table t2 ( +id int unsigned not null auto_increment, +val decimal(5,3) not null, +primary key (id,val), +unique key (val,id), +unique key (id)); +insert into t2 select null,id*0.0009 from t1; +select count(val) from t2 ignore index (val) where val > 0.1155; +count(val) +185 +select count(val) from t2 force index (val) where val > 0.1155; +count(val) +185 +drop table t2, t1; +# +# BUG#13453382 - REGRESSION SINCE 5.1.39, RANGE OPTIMIZER WRONG +# RESULTS WITH DECIMAL CONVERSION +# +create table t1 (a int,b int,c int,primary key (a,c)); +insert into t1 values (1,1,2),(1,1,3),(1,1,4); +select convert(3, signed integer) > 2.9; +convert(3, signed integer) > 2.9 +1 +select * from t1 force index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 force index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +drop table t1; +# +# BUG#13463488 - 63437: CHAR & BETWEEN WITH INDEX RETURNS WRONG +# RESULT AFTER MYSQL 5.1. +# +CREATE TABLE t1( +F1 CHAR(5) NOT NULL, +F2 CHAR(5) NOT NULL, +F3 CHAR(5) NOT NULL, +PRIMARY KEY(F1), +INDEX IDX_F2(F2) +) COLLATE latin1_swedish_ci; +INSERT INTO t1 VALUES +('A','A','A'),('AA','AA','AA'),('AAA','AAA','AAA'), +('AAAA','AAAA','AAAA'),('AAAAA','AAAAA','AAAAA'); +SELECT * FROM t1 WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 WHERE F1 >= 'A '; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 > 'A '; +F1 F2 F3 +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F2 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F3 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND +'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +DROP TABLE t1; +End of 5.1 tests +CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1)); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT c1 FROM t1 WHERE c1 >= 'A' GROUP BY 1; +c1 +1 +2 +3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +DROP TABLE t1; +create table t1 (a int,b int,key (b),key (a),key (b,a)); +insert into t1(a,b) values (1,2),(3,4),(5,6),(7,8); +create table t2 (c int); +insert into t2(c) values (1),(5),(6),(7),(8); +select 1 from (select c from t1,t2 where b >= 1 and a <=> c group by 1 limit 1) as d1; +1 +1 +drop table t1, t2; +# +# Bug #26106: Wrong plan may be chosen when there are several possible +# range and ref accesses +# +# Note: The fix for this bug has been reverted. The code will no longer +# select the optimal plan for the two following test queries. This is +# not due to a bug but due to minor differences in range estimates +# produced by the storage engine. +CREATE TABLE t1( +a INT, +b INT, +KEY k ( a ), +KEY l ( a, b ) +); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1 +VALUES (2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3); +INSERT INTO t1 SELECT 3, 4 FROM t1 WHERE a = 2 AND b = 3; +INSERT INTO t1 SELECT 4, 1 FROM t1 WHERE a = 2 AND b = 3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +# This must use range over index l, not k. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t1 WHERE a = 1 AND b >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 129 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k,l k 5 const 129 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` >= 2)) +CREATE TABLE t2( +a INT, +b INT, +c INT, +KEY k ( a ), +KEY l ( a, b ), +KEY m ( b ), +KEY n ( a, c ) +); +INSERT INTO t2(a) VALUES (1); +INSERT INTO t2 +VALUES (2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3), +(2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3); +INSERT INTO t2 SELECT 3, 4, 4 FROM t2 WHERE a = 2 AND b = 3; +INSERT INTO t2 SELECT 4, 1, 1 FROM t2 WHERE a = 2 AND b = 3; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +INSERT INTO t2 VALUES (1, 2, 2); +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 VALUES (1, 1, 2); +# This must use range over index l, not n. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t2 WHERE a = 1 AND b >= 2 AND c >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 66 29.16 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref k,l,m,n k 5 const 66 29.16 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` >= 2) and (`test`.`t2`.`c` >= 2)) +DROP TABLE t1, t2; +# +# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER +# AWAY QUALIFYING ROWS +# +CREATE TABLE t10( +K INT NOT NULL AUTO_INCREMENT, +I INT, J INT, +PRIMARY KEY(K), +KEY(I,J) +); +INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5), +(6,6),(6,7),(6,8),(6,9),(6,0); +CREATE TABLE t100 LIKE t10; +INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y; +INSERT INTO t100(I,J) VALUES(8,26); + +EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t100 NULL range I I 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t100`.`K` AS `K`,`test`.`t100`.`I` AS `I`,`test`.`t100`.`J` AS `J` from `test`.`t100` where ((`test`.`t100`.`I` <> 6) or ((`test`.`t100`.`J` = 5) and (`test`.`t100`.`I` <> 8))) + +SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +K I J +128 8 26 +DROP TABLE t10,t100; +# +# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR +# AFTER FLUSH TABLES [-INT VS NULL] +# +CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (-100,1),(1,6); +CREATE TABLE t2 ( +col_int_key INT, +col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT", +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t2 VALUES +(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8); +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t2 NULL ref PRIMARY,col_int_key col_int_key 5 test.t1.col_int # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +# need FLUSH so that InnoDB statistics change and thus plan changes +FLUSH TABLES; +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_int_key NULL NULL NULL # # Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +DROP TABLE t1,t2; +# +# Bug#12694872 - +# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_date_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1 ( +col_int_key, +col_int_nokey, +col_date_key, +col_varchar_key, +col_varchar_nokey +) VALUES +(0, 4, '2011-08-25', 'j', 'j'), +(8, 6, '2004-09-18', 'v', 'v'), +(1, 3, '2009-12-01', 'c', 'c'), +(8, 5, '2004-12-17', 'm', 'm'), +(9, 3, '2000-03-14', 'd', 'd'), +(6, 2, '2006-05-25', 'y', 'y'), +(1, 9, '2008-01-23', 't', 't'), +(6, 3, '2007-06-18', 'd', 'd'), +(2, 8, '2002-10-13', 's', 's'), +(4, 1, '1900-01-01', 'r', 'r'), +(8, 8, '1959-04-25', 'm', 'm'), +(4, 8, '2006-03-09', 'b', 'b'), +(4, 5, '2001-06-05', 'x', 'x'), +(7, 7, '2006-05-28', 'g', 'g'), +(4, 5, '2001-04-19', 'p', 'p'), +(1, 1, '1900-01-01', 'q', 'q'), +(9, 6, '2004-08-20', 'w', 'w'), +(4, 2, '2004-10-10', 'd', 'd'), +(8, 9, '2000-04-02', 'e', 'e') +; +SET UNIQUE_CHECKS = 0; +SET FOREIGN_KEY_CHECKS = 0; +SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +SET FOREIGN_KEY_CHECKS = 1; +SET UNIQUE_CHECKS = 1; +CREATE TABLE t2 SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +SELECT * FROM t2 +WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +); +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +DROP TABLE t1, t2; +# +# BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == +# SAVE_READ_SET +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +PRIMARY KEY (c,a), KEY (a),KEY (a) +) ENGINE=INNODB PARTITION BY KEY () PARTITIONS 2; +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1 VALUES (1,5,1),(2,4,1),(3,3,1),(4,2,1),(5,1,1); +UPDATE t1 SET b = 0, c=1 WHERE a <=>0; +SELECT * FROM t1; +a b c +1 5 1 +2 4 1 +3 3 1 +4 2 1 +5 1 1 +DROP TABLE t1; +# +# BUG#13256446 - ASSERTION QUICK->HEAD->READ_SET == +# SAVE_READ_SET' FAILED IN OPT_RANGE.CC:1606 +# +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f2=103; +INSERT INTO t1 VALUES (154,0,NULL,0),(0,NULL,9,0), +(NULL,102,NULL,3),(0,3,NULL,0), (9,0,NULL,0),(0,9,NULL,157); +SELECT * FROM v2; +f1 f2 f3 f4 +UPDATE v2 SET f4=0, f2=NULL, f1=NULL WHERE f1 > 16 ORDER BY f1; +SELECT * FROM v2; +f1 f2 f3 f4 +DROP TABLE t1; +DROP VIEW v2; +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,NULL,NULL,0), (2,2,0,3), (9,0,107,18), +(10,0,0,0), (231,0,0,0), (232,0,8,0), (234,0,0,NULL), (235,8,0,3); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f1<=85 ; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +UPDATE v3 SET f3=0, f4=4 WHERE f2=68 ORDER BY f1; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +DROP TABLE t1; +DROP VIEW v3; +# +# BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(3),(5); +SELECT * FROM t1 WHERE pk <> 3 OR pk < 4; +pk +1 +3 +5 +DROP TABLE t1; +# +# BUG#13803810: TOO FEW ROWS RETURNED FOR RANGE ACCESS IN +# VARCHAR INDEX USING DATETIME VALUE + +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +CREATE TABLE t2 (b VARCHAR(64), KEY (b)) CHARSET utf8mb4; +INSERT INTO t2 VALUES ('2001-01-01'); +INSERT INTO t2 VALUES ('2001.01.01'); +INSERT INTO t2 VALUES ('2001#01#01'); +INSERT INTO t2 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); + +# range/ref access cannot be used for this query + +EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = (cast('2001-01-01' as date))) +SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +b +2001#01#01 +2001-01-01 +2001-01-01 00:00:00 +2001.01.01 + +# range/ref access cannot be used for any of the queries below. +# See BUG#13814468 about 'Range checked for each record' + +EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = cast(`test`.`t2`.`b` as datetime(6))) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (cast(`test`.`t2`.`b` as datetime(6)) = `test`.`t1`.`a`) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +DROP TABLE t1,t2; +# +# WL#7019: Add support for row value constructors in in predicates to +# range optimizer +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY x(a, b)); +INSERT INTO t1 VALUES (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), +(7, 7, 7), (8, 8, 8), (9, 9, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +CREATE TABLE t3 (a INT, b INT, c INT, d INT, KEY x(a, b, c)); +INSERT INTO t3 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((NULL, NULL), (NULL, NULL)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((NULL,NULL),(NULL,NULL))) +EXPLAIN SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +a b +0 0 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` where ((`test`.`t3`.`a`,`test`.`t3`.`b`,`test`.`t3`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 19.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1) and (`test`.`t2`.`a` = 1)) or ((`test`.`t2`.`c` = 0) and (`test`.`t2`.`b` = 0) and (`test`.`t2`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`c` = 1) and (`test`.`t3`.`b` = 1) and (`test`.`t3`.`a` = 1)) or ((`test`.`t3`.`c` = 0) and (`test`.`t3`.`b` = 0) and (`test`.`t3`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +a b +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (('0',0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +SET @v = 0; +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (((@`v`),0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +CREATE TABLE t4 ( a INT, b INT ); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t4 SELECT a + 5, b + 5 FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +# Inner table in a nested-loops join +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 USING(a, b) +WHERE (t4.a, t4.b) IN ((1, 1), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 2.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 2.00 Using where +2 SIMPLE t1 NULL ref x x 10 test.t4.a,test.t4.b 409 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t4`.`b`) and (`test`.`t1`.`a` = `test`.`t4`.`a`) and ((`test`.`t4`.`a`,`test`.`t4`.`b`) in ((1,1),(0,0)))) +# Join on IN +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(0,0))) +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(1,1))) +# +# Tests for non-deterministic functions. +# +CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (f1(), 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 4098 0.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(`f1`(),1,1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,`f1`(),1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, f1())); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,1,`f1`()))) +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index x x 10 NULL 4098 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = `f1`())) +DROP FUNCTION f1; +# The statement immediately below should not use range access. +EXPLAIN +SELECT a, b +FROM t1 AS t1o +WHERE EXISTS (SELECT /*+ NO_SEMIJOIN() */ 1 +FROM t1 +WHERE (a, b) IN ((t1o.a, t1o.b)) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1o NULL index NULL x 10 NULL 4098 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref x x 10 test.t1o.a,test.t1o.b 409 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1o.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1o.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1o`.`a` AS `a`,`test`.`t1o`.`b` AS `b` from `test`.`t1` `t1o` where exists(/* select#2 */ select 1 from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1o`.`a`) and (`test`.`t1`.`b` = `test`.`t1o`.`b`))) +# +# Tests of dynamic range access +# +CREATE TABLE t5 (a int, b int, KEY (a)); +INSERT INTO t5 VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1); +CREATE TABLE t6 (a int, b int, KEY (a)); +INSERT INTO t6 VALUES (3, 2), (4, 2), (100, 100), (101, 201), (102, 102); +CREATE TABLE t7 (a int, b int, KEY (a, b)); +INSERT INTO t7 VALUES (1, 1), (2, 2), (1000, 1000), (1001, 1001), (1002, 1002), +(1003, 1003), (1004, 1004); +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and (`test`.`t7`.`a` in (`test`.`t5`.`b`,`test`.`t6`.`b`))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +a b a b a b +3 1 3 2 1 1 +3 1 3 2 2 2 +4 1 4 2 1 1 +4 1 4 2 2 2 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and ((`test`.`t7`.`a`,`test`.`t7`.`b`) in ((`test`.`t5`.`b`,1),(`test`.`t6`.`b`,1)))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +a b a b a b +3 1 3 2 1 1 +4 1 4 2 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +# +# Regression tests of the worklog below. +# +# Make sure we process IN predicates only. +# The code around this is very unclear. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) != (1, 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4098 99.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index x x 10 NULL 4098 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` <> 1) or (`test`.`t1`.`b` <> 1)) +# This should give us a ref scan, as it always did. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +EXPLAIN SELECT a, b FROM t1 WHERE (a, c) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`c` = 0) and (`test`.`t1`.`a` = 0)) +# ref scan on x(a). +EXPLAIN SELECT * FROM t1 WHERE (a, c) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`c`) in ((0,0),(1,1))) +DROP TABLE t1, t2, t3, t4, t5, t6, t7; +# +# Bug#17635476: CRASH IN GET_MM_PARTS() OR ASSERT IN +# GET_FUNC_MM_TREE_FROM_IN_PREDICATE() +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY (a) +) ENGINE = INNODB; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +INSERT INTO t1 VALUES (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), +(7, 7), (8, 8), (9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 ( +a INT, +b INT, +KEY (a, b) +); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((NULL,`test`.`t1`.`b`) in ((0,0),(1,1))) +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 10 NULL 10 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((NULL,`test`.`t2`.`b`) in ((0,0),(1,1))) +DROP TABLE t1, t2; +# +# Bug#17755540 VALGRIND ERROR WHEN SETTING UP ROW COMPARATORS +# +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT a, b FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +DROP TABLE t2; +# +# BUG#18364815: OPTIMIZER PREFERS TABLE SCAN WHEN +# USING "IN" WITH VALUE OF DIFFERENT TYPE +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,1), (5,1), (6,1); +EXPLAIN SELECT * FROM t1 WHERE a IN (1, 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE a IN (1, "2"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,'2')) +SELECT * FROM t1 WHERE a IN (1, 2); +a b +1 1 +2 1 +SELECT * FROM t1 WHERE a IN (1, "2"); +a b +1 1 +2 1 +DROP TABLE t1; +# +# Bug#18715670 +# CRASH IN DECIMAL_ACTUAL_FRACTION COMPARING DECIMAL TO NULLS +# +CREATE TABLE t1(n DECIMAL(39,19) NOT NULL, KEY(n)) engine=innodb; +INSERT INTO t1 SET n=0; +SELECT 1 FROM t1 WHERE n NOT IN(NULL, NULL); +1 +DROP TABLE t1; +# +# Bug#18759597 MISSING ROWS ON WHERE .. +# IN QUERY WITH VARIABLES AND CONCAT +# +CREATE TABLE t1 ( +col_varchar_key varchar(2), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('n'),('xm'); +SET @var1 = 't', @var2 = 'him', +@var3 = 'n', @var4 = 'n', +@var5 = 'n', @var6 = 'g', +@var7 = 'b', @var8 = 'o', +@var9 = 'm', @var10 = 'xm', @var11 = 'u' +; +SELECT col_varchar_key AS field1 +FROM t1 +WHERE ( col_varchar_key, col_varchar_key ) IN ( +('m', @var1 ), +('n', @var3 ), +('a', @var5 ), +('l', @var7 ), +(CONCAT('x', @var9 ), @var10 ) +); +field1 +n +xm +DROP TABLE t1; +# +# Bug#18535226 DEBUG CRASH ON QUICK_RANGE_SELECT::RESET +# +SET @old_tmp_table_size=@@tmp_table_size; +SET tmp_table_size=1024; +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_date_key date, +col_date_nokey date, +col_time_key time, +col_time_nokey time, +col_datetime_key datetime, +col_datetime_nokey datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(5,0,'2001-05-06','2001-05-06','16:21:18','16:21:18','2001-11-08 21:02:12', +'2001-11-08 21:02:12','x','x'),(6,7,'2006-03-03','2006-03-03','18:56:33', +'18:56:33','2003-04-01 00:00:00','2003-04-01 00:00:00','i','i'), +(7,7,'2007-12-28','2007-12-28',NULL,NULL,'1900-01-01 00:00:00', +'1900-01-01 00:00:00','e','e'),(8,1,'2004-10-20','2004-10-20','09:29:08', +'09:29:08','2007-07-12 00:00:00','2007-07-12 00:00:00','p','p'), +(9,7,'2008-04-09','2008-04-09','19:11:10','19:11:10', +'2005-04-04 01:21:01','2005-04-04 01:21:01','s','s'), +(10,1,'2005-12-25','2005-12-25','11:57:26','11:57:26', +'1900-01-01 00:00:00','1900-01-01 00:00:00','j','j'); +SELECT alias1.col_int_key +FROM +( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1, t1 AS SQ1_alias2 ) AS alias1, +(SELECT 7 AS col_int_nokey) AS alias2 +WHERE +alias2.col_int_nokey = alias1.pk +AND alias1.col_varchar_nokey < alias1.col_varchar_key +ORDER BY alias1.col_varchar_key; +col_int_key +DROP TABLE t1; +SET tmp_table_size=@old_tmp_table_size; +SET sql_mode = default; +# +# Bug#19585938 Crash in get_full_func_mm_tree with null +# item_field->table_ref +# +CREATE TABLE t1(id INTEGER, col1 INTEGER, col2 INTEGER, PRIMARY KEY(id)); +INSERT INTO t1 VALUES (1,2,3), (3,2,1); +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) < id +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id > SUM(1) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN id AND id+1 +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id BETWEEN SUM(1) AND SUM(5) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN COUNT(*) AND id +) AS c +FROM t1 +GROUP BY col1; +c +1 +DROP TABLE t1; +# +# Bug#21415791 VALGRIND ERROR (CONDITIONAL JUMP) AT KEY_AND +# (RANGE_OPT_PARAM*, SEL_ARG*, SEL_AR +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +pk INTEGER NOT NULL, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t1 ( +pk, col_varchar_10, col_int_key) VALUES +(1, 'ttttt', 0), (2, 'zzzzz', 0), (3, 'ggggg', 0), +(4, 'hhhhh', 0), (5, 'kkkkk', 0), (6, 'lllll', 0); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t2 ( +pk, col_varchar_10) VALUES +(1, '00000'), (2, '00000'), (3, '44444'), (4, '00000'), +(5, NULL), (6, NULL), (7, NULL); +SELECT COUNT(t1.col_int_key) +FROM t2 RIGHT OUTER JOIN t1 ON t2.col_varchar_10 <= t1.col_varchar_10 +WHERE t2.pk <> 4 OR t2.pk != t1.col_int_key AND t2.pk <> 1000; +COUNT(t1.col_int_key) +24 +DROP TABLE t1, t2; +# +# Bug #20229614: OR CONDITIONS ON MULTI-COLUMN INDEX MAY NOT USE ALL +# INDEX COLUMNS TO FILTER ROWS +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c3 INT, +PRIMARY KEY(c1, c2, c3) +) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 2), (1, 1, 3), +(1, 1, 4), (1, 1, 5); +INSERT INTO t1 SELECT c1, 2, c3 FROM t1; +INSERT INTO t1 SELECT c1, 3, c3 FROM t1 WHERE c2 = 1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +15 +EXPLAIN SELECT c1, c2, c3 +FROM t1 +WHERE (c1 = 1 AND c2 = 1 AND c3 = 1) OR +(c1 = 1 AND c2 = 2 AND c3 = 2) OR +(c1 = 1 AND c2 = 2 AND c3 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 12 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where (((`test`.`t1`.`c3` = 1) and (`test`.`t1`.`c2` = 1) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 3) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1))) +DROP TABLE t1; +# +# Bug#21139683: ASSERTION FAILED: TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE +# +CREATE TABLE t1 ( +a BLOB, +PRIMARY KEY(a(1)), +KEY(a(1)) +) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE a <> 'a' OR a <> ""; +1 +DROP TABLE t1; +# +# Bug#19333852: RESULT DIFF IN QUERY HAVING DISTINCT +# WITH GROUP BY +# +CREATE TABLE t1 ( +v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY v1_key (v1(10)) +) ENGINE=InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); +EXPLAIN SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` < (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v1_key v1_key 32 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` = (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` between 'f' and (char(127))) +SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +v1 pk +ABCDE 19 +JLVGO 14 +SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +v1 pk +SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +v1 pk +JLVGO 14 +DROP TABLE t1; +# +# Bug #21761867: ASSERTION `TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE' FAILED. +# +CREATE TABLE t1 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +c18 INT, +PRIMARY KEY (c10,c12), +UNIQUE KEY key_c12(c12), +KEY key_c18(c18)); +INSERT INTO t1 VALUES(11,5,0), (12,6,1), (13,7,2), (14,8,3), (15,9,4); +CREATE TABLE t2 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +PRIMARY KEY(c10,c12)); +CREATE TABLE t3 (c10 INT NOT NULL); +SELECT t2.c10 +FROM t1 +RIGHT JOIN t3 +LEFT JOIN t2 +ON t3.c10 = t2.c10 +ON t1.c12 > t2.c12 +WHERE +t1.c10 <= 25 +AND +t1.c18 IS NOT NULL +OR +t1.c10 > 5 +AND +t1.c18 IN (15,16,18); +c10 +DROP TABLE t1, t2, t3; +# +# Bug #21318711: WRONG RESULTS FOR TRUNCATED COLUMN AND AGGREGATION +# +CREATE TABLE t1 ( +col1 VARCHAR(5), +col2 INT NOT NULL, +PRIMARY KEY (col1, col2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('abcde', 10); +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where (`test`.`t1`.`col1` = 'abcdeaa') +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where multiple equal('abcde ', `test`.`t1`.`col1`) +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +MAX(col2) +NULL +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +MAX(col2) +10 +DROP TABLE t1; +# +# Bug# 22283790: RANGE OPTIMIZER UTILIZES TOO MUCH MEMORY WITH +# MANY OR CONDITIONS +# +CREATE TABLE t1 ( +f1 INTEGER, +KEY (f1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15); +SET @orig_range_optimizer_max_mem_size= @@range_optimizer_max_mem_size; +SET range_optimizer_max_mem_size= 5000; +EXPLAIN SELECT * FROM t1 WHERE f1=1 OR f1=2 OR f1=3 OR f1=4 OR f1=5 +OR f1=6 OR f1=7 OR f1=8 OR f1=9 OR f1=10 OR f1=11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range f1 f1 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` = 1) or (`test`.`t1`.`f1` = 2) or (`test`.`t1`.`f1` = 3) or (`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f1` = 5) or (`test`.`t1`.`f1` = 6) or (`test`.`t1`.`f1` = 7) or (`test`.`t1`.`f1` = 8) or (`test`.`t1`.`f1` = 9) or (`test`.`t1`.`f1` = 10) or (`test`.`t1`.`f1` = 11)) +SET range_optimizer_max_mem_size= @orig_range_optimizer_max_mem_size; +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +SELECT * FROM t1 WHERE pk IN (3, 8) OR pk NOT IN (2); +pk +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +# Indirectly tests ORing with a tree that has a nonzero refcount, +# where nodes are also being skipped over. (There was a bug in +# refcounting such trees earlier.) +# +CREATE TABLE t1 ( +col_int_key int, +pk int NOT NULL, +col_int int, +KEY test_idx (pk,col_int_key,col_int) +); +SELECT * FROM t1 WHERE +(col_int_key >= 6 AND pk > 6) OR +(pk > 2 AND col_int_key = 7 AND col_int > 6); +col_int_key pk col_int +DROP TABLE t1; +# +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE `giant_table` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`one_id` int(11) NOT NULL, +`other_id` bigint(20) NOT NULL DEFAULT '0', +`some_other_id` int(11) DEFAULT 0 NOT NULL, +`something` double NOT NULL DEFAULT '0', +`comment` text COLLATE utf8_unicode_ci, +`flags` int(11) NOT NULL DEFAULT '0', +`time_created` int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (`id`), +KEY `time_created` (`time_created`), +KEY `some_other_id` (`some_other_id`), +KEY `one_other_idx` (`one_id`,`other_id`), +KEY `other_id` (`other_id`,`time_created`) +) ENGINE=InnoDB AUTO_INCREMENT=101651329 +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (66136540), (68983250), (89627210), (77869520), +(82543190), (67538270), (77282760), (77908170), +(70923370), (68066360); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT INTO giant_table(id,one_id) +SELECT c1 + @x, 0 +FROM t1 +WHERE c1 IN (66136540, 68985250, 89627210, 77869520 , 82543190, 67538270, +77282760, 77908170, 70923370, 68066360); +SET @x = @x + 1; +UNTIL @x > 30 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM giant_table; +count(*) +270 +INSERT INTO giant_table (id,one_id) VALUES (66136539, 0), (68983258,1), +(89628210,1), (77869520,2); +INSERT INTO giant_table (id,one_id, some_other_id) VALUES(84673401, 0, 1), +(61069031, 1, 1); +EXPLAIN SELECT id, something, comment, time_created, one_id, other_id, +some_other_id, flags +FROM giant_table +WHERE id IN (66136539, 68983258, 89628210, 77869520, 82543198, 67538272, +84673401, 61069031, 68214385, 77282865, 76991297, 64569216, +89481638, 74534074, 70396537, 80076375, 63308530, 77908270, +70923271, 68066180) +AND (giant_table.flags & 0x01) = 0 AND giant_table.some_other_id = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE giant_table NULL range PRIMARY,some_other_id PRIMARY 4 NULL 20 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`giant_table`.`id` AS `id`,`test`.`giant_table`.`something` AS `something`,`test`.`giant_table`.`comment` AS `comment`,`test`.`giant_table`.`time_created` AS `time_created`,`test`.`giant_table`.`one_id` AS `one_id`,`test`.`giant_table`.`other_id` AS `other_id`,`test`.`giant_table`.`some_other_id` AS `some_other_id`,`test`.`giant_table`.`flags` AS `flags` from `test`.`giant_table` where ((`test`.`giant_table`.`some_other_id` = 0) and (`test`.`giant_table`.`id` in (66136539,68983258,89628210,77869520,82543198,67538272,84673401,61069031,68214385,77282865,76991297,64569216,89481638,74534074,70396537,80076375,63308530,77908270,70923271,68066180)) and ((`test`.`giant_table`.`flags` & 0x01) = 0)) +DROP PROCEDURE p; +DROP TABLE giant_table, t1; +# +# Bug#22671573: SIG11 IN SEL_ARG::RB_INSERT |SQL/OPT_RANGE.CC +# +# Tests creating an empty tree (impossible condition) and then ANDing with it. +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY test_idx (b, a) +); +SELECT * FROM t1 WHERE b BETWEEN 8 AND 8 AND a > 8 AND a <= 8; +a b +DROP TABLE t1; +# +# Indirectly tests inserting a node into an empty (impossible) tree. +# +CREATE TABLE t1 ( +pk INT, +PRIMARY KEY ( pk ) +); +SELECT * FROM t1 WHERE pk = 6 OR pk > 6; +pk +DROP TABLE t1; +# +# Indirectly tests ORing with an empty (impossible) tree. +# +CREATE TABLE t1 ( +col_int_key INT, +KEY (col_int_key) +); +SELECT * FROM t1 WHERE col_int_key IS NULL OR col_int_key < 9 OR col_int_key = 9; +col_int_key +DROP TABLE t1; +# +# Indirectly tests deleting the last node from a tree +# (which makes it IMPOSSIBLE) and then inserting more than one node. +# +CREATE TABLE t1 ( +a VARCHAR(64), +KEY a (a) +); +SELECT * FROM t1 WHERE a IS NULL OR a NOT IN ( 'foo', 'bar' ); +a +DROP TABLE t1; +# +# Bug#25229315: ASSERTION TABLE->M_RECORD_BUFFER.RECORD_SIZE() == +# RECORD_PREFIX_SIZE(TAB)' FAIL +# +CREATE TABLE t1 (pk INT PRIMARY KEY, vc VARCHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, NULL), (2, 'w'); +CREATE TABLE t2 ( +i INT, +vc VARCHAR(1), +pk INT PRIMARY KEY, +KEY (i), +KEY (vc) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 'p', 1), (9, 'w', 2), (NULL, 'r', 3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL i,vc NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x6) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`vc` = `test`.`t1`.`vc`) or (`test`.`t2`.`i` = `test`.`t1`.`pk`)) +SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +MIN(t1.pk) +1 +DROP TABLE t1, t2; +# +# Bug #26727773: OPTIMIZER CHOSES COMPOSITE INDEX FOR REF OVER RANGE +# +CREATE TABLE transactions ( +app_trans_id INT DEFAULT NULL, +id INT NOT NULL, +tbl INT NOT NULL DEFAULT 1, +created TIMESTAMP NOT NULL DEFAULT '2017-01-01 01:01:01', +trans_type INT NOT NULL, +description BLOB, +source_lvl1 INT DEFAULT NULL, +source_lvl2 INT DEFAULT NULL, +KEY tbl_id_idx (tbl,id), +KEY created_idx (created), +KEY trans_type_created_idx (trans_type,created), +KEY app_trans_id_idx (app_trans_id) +) ENGINE=INNODB ; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1000), (2000), (3000), (4000), (5000), (6000), +(7000), (8000), (9000); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT IGNORE INTO transactions(id,trans_type, description) +SELECT c1 + @x, @x , 'abcd' + FROM t1; +SET @x = @x + 1; +UNTIL @x > 300 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM transactions; +count(*) +3000 +INSERT IGNORE INTO transactions(id,trans_type, description, created) +SELECT 3, 3 , 'abcd', '2018-01-01 01:01:01' + FROM dual; +EXPLAIN SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE transactions NULL range tbl_id_idx,created_idx,trans_type_created_idx created_idx 4 NULL # # Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select '2017-10-23 01:01:01' AS `2017-10-23 01:01:01`,hour(`test`.`transactions`.`created`) AS `HOUR(created)`,`test`.`transactions`.`source_lvl1` AS `source_lvl1`,`test`.`transactions`.`source_lvl2` AS `source_lvl2`,count(distinct `test`.`transactions`.`app_trans_id`) AS `COUNT(DISTINCT(app_trans_id))` from `test`.`transactions` where ((`test`.`transactions`.`trans_type` = 3) and (`test`.`transactions`.`tbl` = 1) and (`test`.`transactions`.`created` > TIMESTAMP'2017-10-23 01:01:01')) group by '2017-10-23 01:01:01',hour(`test`.`transactions`.`created`),`test`.`transactions`.`source_lvl1`,`test`.`transactions`.`source_lvl2` +SET optimizer_trace="enabled=on"; +SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +2017-10-23 01:01:01 HOUR(created) source_lvl1 source_lvl2 COUNT(DISTINCT(app_trans_id)) +2017-10-23 01:01:01 1 NULL NULL 0 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +SET optimizer_trace="enabled=off"; +DROP PROCEDURE p; +DROP TABLE t1, transactions; +# +# Bug #28086754: OPTIMIZER SKIP THE RANG SCAN ON SECOND COLUMN IN A +# COMPOSITE INDEX +# +CREATE TABLE test_ref ( +a INT PRIMARY KEY, +b VARCHAR(20), +c VARCHAR(20) DEFAULT NULL, +d VARCHAR(3) DEFAULT NULL, +id INT DEFAULT NULL, +KEY idx1 (id, c), +KEY idx2 (id, d)) ENGINE=INNODB ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze Error Table 'test.t1' doesn't exist +test.t1 analyze status Operation failed +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c`,`test`.`test_ref`.`a` limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +a b c d id +34876 D003 gheennse S 3 +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c` desc,`test`.`test_ref`.`a` desc limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +a b c d id +1770649 D003 gheennse S 3 +DROP TABLE test_ref; +# +# Bug #30988735: SELECT QUERY WITH ERROR RESULT WITH "NOT IN" +# WHERE_CLAUSE +# +CREATE TABLE t(f1 INTEGER key, f2 INTEGER)ENGINE=INNODB; +INSERT INTO t VALUES(0,0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT f1,f2 FROM t WHERE f1 NOT IN(-0.1,0.1); +f1 f2 +0 0 +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/range_none.result-pq b/mysql-test/r/range_none.result-pq new file mode 100644 index 000000000..e3cf34efd --- /dev/null +++ b/mysql-test/r/range_none.result-pq @@ -0,0 +1,3996 @@ +drop table if exists t1, t2, t3; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +event_date date DEFAULT '0000-00-00' NOT NULL, +type int(11) DEFAULT '0' NOT NULL, +event_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (event_date,type,event_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25), +('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26), +('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45), +('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5), +('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17), +('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40), +('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6), +('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41), +('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41), +('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29), +('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19), +('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42), +('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30), +('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8), +('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22), +('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43), +('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37), +('1999-09-19',100100,37), ('2000-12-18',100700,38); +explain select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 19.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 7 NULL 6 19.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where ((`test`.`t1`.`event_date` >= DATE'1999-07-01') and (`test`.`t1`.`event_date` < DATE'1999-07-15') and ((`test`.`t1`.`type` = 100600) or (`test`.`t1`.`type` = 100100))) order by `test`.`t1`.`event_date` +explain format=tree select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +EXPLAIN +-> Parallel scan on + -> Filter: ((t1.event_date >= DATE'1999-07-01') and (t1.event_date < DATE'1999-07-15') and ((t1.`type` = 100600) or (t1.`type` = 100100))) (cost=1.46 rows=1) + -> PQblock range scan on t1 using PRIMARY (cost=1.46 rows=6) + +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`event_date` AS `event_date`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`event_id` AS `event_id` from `test`.`t1` where false order by `test`.`t1`.`event_date` +select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099; +event_date type event_id +1999-07-10 100100 24 +1999-07-11 100100 25 +1999-07-13 100600 0 +1999-07-13 100600 4 +1999-07-13 100600 26 +1999-07-14 100600 10 +1999-07-15 100600 16 +drop table t1; +CREATE TABLE t1 ( +PAPER_ID smallint(6) DEFAULT '0' NOT NULL, +YEAR smallint(6) DEFAULT '0' NOT NULL, +ISSUE smallint(6) DEFAULT '0' NOT NULL, +CLOSED tinyint(4) DEFAULT '0' NOT NULL, +ISS_DATE date DEFAULT '0000-00-00' NOT NULL, +PRIMARY KEY (PAPER_ID,YEAR,ISSUE) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'), +(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'), +(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'), +(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'), +(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'), +(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'), +(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'), +(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'), +(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'), +(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'), +(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'), +(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'), +(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'), +(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'), +(3,1999,35,0,'1999-07-12'); +select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE; +YEAR ISSUE +1999 29 +1999 30 +1999 31 +1999 32 +1999 33 +1999 34 +1999 35 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair note The storage engine for the table doesn't support repair +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2), +(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2), +(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1), +(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2), +(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2), +(19,3,2), (5,1,1), (179,5,2); +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id; +id parent_id level +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +drop table t1; +create table t1( +Satellite varchar(25) not null, +SensorMode varchar(25) not null, +FullImageCornersUpperLeftLongitude double not null, +FullImageCornersUpperRightLongitude double not null, +FullImageCornersUpperRightLatitude double not null, +FullImageCornersLowerRightLatitude double not null, +index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude)); +insert into t1 values("OV-3","PAN1",91,-92,40,50); +insert into t1 values("OV-4","PAN1",91,-92,40,50); +select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000; +Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude +OV-3 PAN1 91 -92 40 50 +drop table t1; +create table t1 ( aString char(100) not null default "", key aString (aString(10)) ); +insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love"); +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +alter table t1 drop key aString; +select * from t1 where aString < "believe in myself" order by aString; +aString +baaa +believe +believe in love +select * from t1 where aString > "believe in love" order by aString; +aString +believe in myself +drop table t1; +CREATE TABLE t1 ( +t1ID int(10) unsigned NOT NULL auto_increment, +art binary(1) NOT NULL default '', +KNR char(5) NOT NULL default '', +RECHNR char(6) NOT NULL default '', +POSNR char(2) NOT NULL default '', +ARTNR char(10) NOT NULL default '', +TEX char(70) NOT NULL default '', +PRIMARY KEY (t1ID), +KEY IdxArt (art), +KEY IdxKnr (KNR), +KEY IdxArtnr (ARTNR) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'), +('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'); +select count(*) from t1 where upper(art) = 'J'; +count(*) +213 +select count(*) from t1 where art = 'J' or art = 'j'; +count(*) +602 +select count(*) from t1 where art = 'j' or art = 'J'; +count(*) +602 +select count(*) from t1 where art = 'j'; +count(*) +389 +select count(*) from t1 where art = 'J'; +count(*) +213 +drop table t1; +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` between 7 and ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 8) and (`test`.`t2`.`x` >= 7) and (`test`.`t2`.`x` <= ((8 + 0)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between ((2 - 1)) and ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= ((2 - 1))) and (`test`.`t2`.`x` <= ((2 + 1)))) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` between 0 and 2)) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref y y 5 const 1 100.00 NULL +2 SIMPLE t2 NULL range x x 5 NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y` from `test`.`t1` join `test`.`t1` `t2` where ((`test`.`t1`.`y` = 2) and (`test`.`t2`.`x` >= 0) and (`test`.`t2`.`x` <= 2)) +explain select count(*) from t1 where x in (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` = 1) +explain select count(*) from t1 where x in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`x` in (1,2)) +drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +explain select * from t1 force index(i1), t2 force index(j1) where +(t1.key1 NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref j1 j1 4 const 1 100.00 Using index +2 SIMPLE t1 NULL index i1 i1 4 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t2`.`keya` AS `keya` from `test`.`t1` FORCE INDEX (`i1`) join `test`.`t2` FORCE INDEX (`j1`) where ((`test`.`t2`.`keya` = 3) and (`test`.`t1`.`key1` < ((3 + 1)))) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a int(11) default NULL, +b int(11) default NULL, +KEY a (a), +KEY b (b) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2), +(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3), +(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), +(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a,b a 5 NULL 2 40.54 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` in (1,2))) +SELECT * FROM t1 WHERE a IN(1,2) AND b=5; +a b +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) +); +a b +15 1 +47 1 +DROP TABLE t1; +CREATE TABLE t1 ( +id int( 11 ) unsigned NOT NULL AUTO_INCREMENT , +line int( 5 ) unsigned NOT NULL default '0', +columnid int( 3 ) unsigned NOT NULL default '0', +owner int( 3 ) unsigned NOT NULL default '0', +ordinal int( 3 ) unsigned NOT NULL default '0', +showid smallint( 6 ) unsigned NOT NULL default '1', +tableid int( 1 ) unsigned NOT NULL default '1', +content int( 5 ) unsigned NOT NULL default '188', +PRIMARY KEY ( owner, id ) , +KEY menu( owner, showid, columnid ) , +KEY `COLUMN` ( owner, columnid, line ) , +KEY `LINES` ( owner, tableid, content, id ) , +KEY recount( owner, line ) +) ENGINE = MYISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5); +SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30; +id columnid tableid content showid line ordinal +13 13 1 188 1 5 0 +15 15 1 188 1 1 0 +drop table t1; +create table t1 (id int(10) primary key); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); +select id from t1 where id in (2,5,9) ; +id +2 +5 +9 +select id from t1 where id=2 or id=5 or id=9 ; +id +2 +5 +9 +drop table t1; +create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2)); +insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), +(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"), +(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"), +(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"), +(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"), +(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"), +(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa"); +select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; +id1 idnull +drop table t1; +create table t1 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +create table t2 ( +id int not null auto_increment, +name char(1) not null, +uid int not null, +primary key (id), +index uid_index (uid)); +insert into t1(id, uid, name) values(1, 0, ' '); +insert into t1(uid, name) values(0, ' '); +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t2(uid, name) select uid, name from t1; +insert into t1(uid, name) select uid, name from t2; +delete from t2; +insert into t2(uid, name) values +(1, CHAR(64+1)), +(2, CHAR(64+2)), +(3, CHAR(64+3)), +(4, CHAR(64+4)), +(5, CHAR(64+5)), +(6, CHAR(64+6)), +(7, CHAR(64+7)), +(8, CHAR(64+8)), +(9, CHAR(64+9)), +(10, CHAR(64+10)), +(11, CHAR(64+11)), +(12, CHAR(64+12)), +(13, CHAR(64+13)), +(14, CHAR(64+14)), +(15, CHAR(64+15)), +(16, CHAR(64+16)), +(17, CHAR(64+17)), +(18, CHAR(64+18)), +(19, CHAR(64+19)), +(20, CHAR(64+20)), +(21, CHAR(64+21)), +(22, CHAR(64+22)), +(23, CHAR(64+23)), +(24, CHAR(64+24)), +(25, CHAR(64+25)), +(26, CHAR(64+26)); +insert into t1(uid, name) select uid, name from t2 order by uid; +delete from t2; +insert into t2(id, uid, name) select id, uid, name from t1; +select count(*) from t1; +count(*) +1026 +select count(*) from t2; +count(*) +1026 +analyze table t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (1 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE # NULL ALL NULL NULL NULL # 28 100.00 Parallel execute (2 workers) +2 SIMPLE # NULL range uid_index uid_index 4 # 28 100.00 Using where +2 SIMPLE # NULL ref uid_index uid_index 4 # 28 100.00 NULL +select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0; +id name uid id name uid +1257 A 1 1257 A 1 +1258 B 2 1258 B 2 +1259 C 3 1259 C 3 +1260 D 4 1260 D 4 +1261 E 5 1261 E 5 +1262 F 6 1262 F 6 +1263 G 7 1263 G 7 +1264 H 8 1264 H 8 +1265 I 9 1265 I 9 +1266 J 10 1266 J 10 +1267 K 11 1267 K 11 +1268 L 12 1268 L 12 +1269 M 13 1269 M 13 +1270 N 14 1270 N 14 +1271 O 15 1271 O 15 +1272 P 16 1272 P 16 +1273 Q 17 1273 Q 17 +1274 R 18 1274 R 18 +1275 S 19 1275 S 19 +1276 T 20 1276 T 20 +1277 U 21 1277 U 21 +1278 V 22 1278 V 22 +1279 W 23 1279 W 23 +1280 X 24 1280 X 24 +1281 Y 25 1281 Y 25 +1282 Z 26 1282 Z 26 +drop table t1,t2; +create table t1 (x bigint unsigned not null); +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +create table t2 (x bigint not null); +insert into t2(x) values (-16); +insert into t2(x) values (-15); +select * from t2; +x +-16 +-15 +select count(*) from t2 where x>0; +count(*) +0 +select count(*) from t2 where x=0; +count(*) +0 +select count(*) from t2 where x<0; +count(*) +2 +select count(*) from t2 where x < -16; +count(*) +0 +select count(*) from t2 where x = -16; +count(*) +1 +select count(*) from t2 where x > -16; +count(*) +1 +select count(*) from t2 where x = 18446744073709551601; +count(*) +0 +drop table t1,t2; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0); +insert into t1(x) values (0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +select count(*) from t1 where x > -16; +count(*) +2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +create table t1 (a bigint unsigned); +create index t1i on t1(a); +insert into t1 select 18446744073709551615; +insert into t1 select 18446744073709551614; +explain select * from t1 where a <> -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a <> -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1 or a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1 or a < -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index t1i t1i 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` is not null) +select * from t1 where a > -1; +a +18446744073709551614 +18446744073709551615 +explain select * from t1 where a < -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +select * from t1 where a < -1; +a +drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 11 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 'aaa') +explain select * from t1 where a=binary 'aaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (cast('aaa' as char charset binary))) +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 11 NULL 2 100.00 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_bin))) +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 9 11.11 Using where +Warnings: +Warning 1739 Cannot use ref access on index 'a' due to type or collation conversion on field 'a' +Warning 1739 Cannot use range access on index 'a' due to type or collation conversion on field 'a' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = (('aaa' collate latin1_german1_ci))) +drop table t1; +CREATE TABLE t1 ( +`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', +`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '', +`FUNCTINT` int(11) NOT NULL default '0', +KEY `VERI_CLNT~2` (`ARG1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0), +('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0), +('001',' 3',' 0','Text 017',0); +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2'); +count(*) +4 +SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1'); +count(*) +4 +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( +pk1 int(11) NOT NULL, +pk2 int(11) NOT NULL, +pk3 int(11) NOT NULL, +pk4 int(11) NOT NULL, +filler char(82), +PRIMARY KEY (pk1,pk2,pk3,pk4) +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B; +INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'), +(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'), +(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler'); +SELECT * FROM t2 +WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635))) +OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635)))) +) AND (pk3 >=1000000); +pk1 pk2 pk3 pk4 filler +2621 2635 1000015 0 filler +drop table t1, t2; +create table t1(a char(2), key(a(1))) charset utf8mb4; +insert into t1 values ('x'), ('xx'); +explain select a from t1 where a > 'x'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'x') +select a from t1 where a > 'x'; +a +xx +drop table t1; +CREATE TABLE t1 ( +OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid', +OXLEFT int NOT NULL DEFAULT '0', +OXRIGHT int NOT NULL DEFAULT '0', +OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', +PRIMARY KEY (OXID), +KEY OXNID (OXID), +KEY OXLEFT (OXLEFT), +KEY OXRIGHT (OXRIGHT), +KEY OXROOTID (OXROOTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'), +('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725521'), +('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725521'); +EXPLAIN +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE v NULL ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 100.00 NULL +1 SIMPLE s NULL ref OXLEFT,OXROOTID OXROOTID 34 const 5 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`s`.`OXID` AS `oxid` from `test`.`t1` `v` join `test`.`t1` `s` where ((`test`.`s`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`v`.`OXROOTID` = 'd8c4177d09f8b11f5.52725521') and (`test`.`s`.`OXLEFT` > `test`.`v`.`OXLEFT`) and (`test`.`s`.`OXLEFT` < `test`.`v`.`OXRIGHT`)) +SELECT s.oxid FROM t1 v, t1 s +WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +v.oxrootid ='d8c4177d09f8b11f5.52725521' AND +s.oxleft > v.oxleft AND s.oxleft < v.oxright; +oxid +d8c4177d151affab2.81582770 +d8c4177d206a333d2.74422679 +d8c4177d225791924.30714720 +d8c4177d2380fc201.39666693 +d8c4177d24ccef970.14957924 +DROP TABLE t1; +create table t1 ( +c1 char(10), c2 char(10), c3 char(10), c4 char(10), +c5 char(10), c6 char(10), c7 char(10), c8 char(10), +c9 char(10), c10 char(10), c11 char(10), c12 char(10), +c13 char(10), c14 char(10), c15 char(10), c16 char(10), +index(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,c13,c14,c15,c16) +); +insert into t1 (c1) values ('1'),('1'),('1'),('1'); +select * from t1 where +c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC") +and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh", +"abcdefg1", "123456781", "qwertyui1", "asddfg1", +"abcdefg2", "123456782", "qwertyui2", "asddfg2", +"abcdefg3", "123456783", "qwertyui3", "asddfg3", +"abcdefg4", "123456784", "qwertyui4", "asddfg4", +"abcdefg5", "123456785", "qwertyui5", "asddfg5", +"abcdefg6", "123456786", "qwertyui6", "asddfg6", +"abcdefg7", "123456787", "qwertyui7", "asddfg7", +"abcdefg8", "123456788", "qwertyui8", "asddfg8", +"abcdefg9", "123456789", "qwertyui9", "asddfg9", +"abcdefgA", "12345678A", "qwertyuiA", "asddfgA", +"abcdefgB", "12345678B", "qwertyuiB", "asddfgB", +"abcdefgC", "12345678C", "qwertyuiC", "asddfgC"); +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 +Warnings: +Warning 3170 Memory capacity of 8388608 bytes for 'range_optimizer_max_mem_size' exceeded. Range optimization was not done for this query. +drop table t1; +End of 4.1 tests +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +status varchar(20), +PRIMARY KEY (id), +KEY (status) +) CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'), +(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'), +(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'), +(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'), +(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'), +(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'), +(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'), +(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'), +(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'), +(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C'); +EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status NOT IN ('A','B'); +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` <> 'A') and (`test`.`t1`.`status` <> 'B')) +EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range status status 83 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not in ('A','B')) +EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where (`test`.`t1`.`status` not between 'A' and 'B') +EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range status status 83 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`status` AS `status` from `test`.`t1` where ((`test`.`t1`.`status` < 'A') or (`test`.`t1`.`status` > 'B')) +SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; +id status +53 C +54 C +55 C +56 C +57 C +58 C +59 C +60 C +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, primary key(a,b)); +INSERT INTO t1 VALUES +(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3); +CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3; +EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +EXPLAIN SELECT a,b FROM t1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` < 2) +EXPLAIN SELECT a,b FROM v1 WHERE a < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 3) and (`test`.`t1`.`a` < 2)) +SELECT a,b FROM t1 WHERE a < 2 and b=3; +a b +1 3 +SELECT a,b FROM v1 WHERE a < 2 and b=3; +a b +1 3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name)); +INSERT INTO t1 VALUES ('Betty'), ('Anna'); +SELECT * FROM t1; +name +Anna +Betty +DELETE FROM t1 WHERE name NOT LIKE 'A%a'; +SELECT * FROM t1; +name +Anna +DROP TABLE t1; +CREATE TABLE t1 (a int, KEY idx(a)); +INSERT INTO t1 VALUES (NULL), (1), (2), (3); +SELECT * FROM t1; +a +NULL +1 +2 +3 +DELETE FROM t1 WHERE NOT(a <=> 2); +SELECT * FROM t1; +a +2 +DROP TABLE t1; +create table t1 (a int, b int, primary key(a,b)); +create view v1 as select a, b from t1; +INSERT INTO `t1` VALUES +(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2) +,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3); +explain select * from t1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from v1 where a in (3,4) and b in (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` in (3,4)) and (`test`.`t1`.`b` in (1,2,3))) +explain select * from t1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 11.11 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +explain select * from v1 where a between 3 and 4 and b between 1 and 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 8 NULL # 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` between 3 and 4) and (`test`.`t1`.`b` between 1 and 2)) +drop view v1; +drop table t1; +create table t3 (a int); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a varchar(10), filler char(200), key(a)) charset=binary; +insert into t1 values ('a',''); +insert into t1 values ('a ',''); +insert into t1 values ('a ', ''); +insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), '' + from t3 A, t3 B, t3 C; +create table t2 (a varchar(10), filler char(200), key(a)) charset utf8mb4; +insert into t2 select * from t1; +explain select * from t1 where a between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` between 'a' and 'a ') +explain select * from t1 where a = 'a' or a='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 13 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') or (`test`.`t1`.`a` = 'a ')) +explain select * from t2 where a between 'a' and 'A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where (`test`.`t2`.`a` between 'a' and 'A') +explain select * from t2 where a = 'a' or a='A'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref a a 43 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') or (`test`.`t2`.`a` = 'A')) +update t1 set a='b' where a<>'a'; +explain select * from t1 where a not between 'b' and 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL a NULL NULL NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`a` not between 'b' and 'b') +select a, hex(filler) from t1 where a not between 'b' and 'b'; +a hex(filler) +a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +drop table t1,t2,t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, key(a)); +insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C; +set @a="select * from t2 force index (a) where a NOT IN(0"; +select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z; +count(*) +1000 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @a=concat(@a, ')'); +insert into t2 values (11),(13),(15); +set @b= concat("explain ", @a); +prepare stmt1 from @b; +execute stmt1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1003 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` FORCE INDEX (`a`) where (`test`.`t2`.`a` not in (0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,604,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,640,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,784,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962,964,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118,1120,1122,1124,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1146,1148,1150,1152,1154,1156,1158,1160,1162,1164,1166,1168,1170,1172,1174,1176,1178,1180,1182,1184,1186,1188,1190,1192,1194,1196,1198,1200,1202,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222,1224,1226,1228,1230,1232,1234,1236,1238,1240,1242,1244,1246,1248,1250,1252,1254,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292,1294,1296,1298,1300,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362,1364,1366,1368,1370,1372,1374,1376,1378,1380,1382,1384,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408,1410,1412,1414,1416,1418,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458,1460,1462,1464,1466,1468,1470,1472,1474,1476,1478,1480,1482,1484,1486,1488,1490,1492,1494,1496,1498,1500,1502,1504,1506,1508,1510,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1552,1554,1556,1558,1560,1562,1564,1566,1568,1570,1572,1574,1576,1578,1580,1582,1584,1586,1588,1590,1592,1594,1596,1598,1600,1602,1604,1606,1608,1610,1612,1614,1616,1618,1620,1622,1624,1626,1628,1630,1632,1634,1636,1638,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678,1680,1682,1684,1686,1688,1690,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1714,1716,1718,1720,1722,1724,1726,1728,1730,1732,1734,1736,1738,1740,1742,1744,1746,1748,1750,1752,1754,1756,1758,1760,1762,1764,1766,1768,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790,1792,1794,1796,1798,1800,1802,1804,1806,1808,1810,1812,1814,1816,1818,1820,1822,1824,1826,1828,1830,1832,1834,1836,1838,1840,1842,1844,1846,1848,1850,1852,1854,1856,1858,1860,1862,1864,1866,1868,1870,1872,1874,1876,1878,1880,1882,1884,1886,1888,1890,1892,1894,1896,1898,1900,1902,1904,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1964,1966,1968,1970,1972,1974,1976,1978,1980,1982,1984,1986,1988,1990,1992,1994,1996,1998)) +prepare stmt1 from @a; +execute stmt1; +a +11 +13 +15 +drop table t1, t2; +CREATE TABLE t1 ( +id int NOT NULL DEFAULT '0', +b int NOT NULL DEFAULT '0', +c int NOT NULL DEFAULT '0', +INDEX idx1(b,c), INDEX idx2(c)); +INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); +INSERT INTO t1(b,c) VALUES (3,4), (3,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` <= 3) and (3 <= `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1,idx2 idx2 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (3 between `test`.`t1`.`b` and `test`.`t1`.`c`) +SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id b c +0 3 4 +0 3 4 +SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id b c +0 3 4 +0 3 4 +EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((0 < `test`.`t1`.`b`) or (0 > `test`.`t1`.`c`)) +EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx1,idx2 idx1,idx2 4,4 NULL 3 100.00 Using sort_union(idx1,idx2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (0 not between `test`.`t1`.`b` and `test`.`t1`.`c`) +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; +EXPLAIN +-> Filter: (0 not between t1.b and t1.c) (cost=2.15 rows=3) + -> Index range scan on t1 using sort_union(idx1,idx2) (cost=2.15 rows=3) + +DROP TABLE t1; +CREATE TABLE t1 ( +item char(20) NOT NULL default '', +started datetime NOT NULL default '0000-00-00 00:00:00', +price decimal(16,3) NOT NULL default '0.000', +PRIMARY KEY (item,started) +) ENGINE=MyISAM, CHARSET utf8mb4; +INSERT INTO t1 VALUES +('A1','2005-11-01 08:00:00',1000), +('A1','2005-11-15 00:00:00',2000), +('A1','2005-12-12 08:00:00',3000), +('A2','2005-12-01 08:00:00',1000); +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP INDEX `PRIMARY` ON t1; +EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00'; +ERROR HY000: Incorrect DATETIME value: '2005-12-01 24:00:00' +SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00'; +item started price +A1 2005-11-01 08:00:00 1000.000 +A1 2005-11-15 00:00:00 2000.000 +DROP TABLE t1; + +BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly" + +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +dateval date default NULL, +PRIMARY KEY (id), +KEY dateval (dateval) +) AUTO_INCREMENT=173; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'), +(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'), +(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11'); +This must use range access: +explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range dateval dateval 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`dateval` AS `dateval` from `test`.`t1` where ((`test`.`t1`.`dateval` >= DATE'2007-01-01') and (`test`.`t1`.`dateval` <= DATE'2007-01-02')) +drop table t1; +CREATE TABLE t1 ( +a varchar(32), index (a) +) DEFAULT CHARSET=latin1 COLLATE=latin1_bin; +INSERT INTO t1 VALUES +('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A'); +SELECT a FROM t1 WHERE a='b' OR a='B'; +a +B +B +EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 35 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'b') or (`test`.`t1`.`a` = 'B')) +DROP TABLE t1; +CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(254),(0),(1),(255); +SELECT COUNT(*) FROM t1 WHERE f1 < 256; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 256.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 255; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 < -1; +COUNT(*) +0 +SELECT COUNT(*) FROM t1 WHERE f1 > -1; +COUNT(*) +5 +DROP TABLE t1; +CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127); +SELECT COUNT(*) FROM t1 WHERE f1 < 128; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 128.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 < 127; +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE f1 > -129; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -129.0; +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE f1 > -128; +COUNT(*) +4 +DROP TABLE t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, filler char(100)); +insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, +t1 B, t1 C where A.a < 5; +insert into t2 select 1000, b, 'filler' from t2; +alter table t2 add index (a,b); +Access method can be range/ALL with #rows >= 500. +Or it can be ref with #rows = 2, only when there is memory limit. +explain select * from t2 where a=1000 and b<11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 50.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL a NULL NULL NULL 1000 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` where ((`test`.`t2`.`a` = 1000) and (`test`.`t2`.`b` < 11)) +drop table t1, t2; +CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); +CREATE TABLE t3( a INT, b INT, KEY( a, b ) ); +INSERT INTO t1( a, b ) +VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7); +INSERT INTO t2( a, b ) +VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1), +( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1), +(11, 1), (12, 1), (13, 1), (14, 1), (15, 1), +(16, 1), (17, 1), (18, 1), (19, 1), (20, 1); +INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t3 +VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), +(6, 0), (7, 0), (8, 0), (9, 0), (10, 0); +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 < `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` < 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or ((`test`.`t1`.`b` = 3) and (5 <= `test`.`t1`.`a`)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +a b +5 0 +9 7 +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((3 <= `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 5)) or (3 <= `test`.`t1`.`a`)) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (3 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 1) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +a b +1 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +15 3 +16 1 +16 3 +17 1 +17 3 +18 1 +18 3 +19 1 +19 3 +2 1 +20 1 +3 1 +4 1 +5 1 +5 2 +6 1 +6 2 +7 1 +7 2 +8 1 +8 2 +9 1 +9 2 +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 60 27.10 Parallel execute (4 workers) +2 SIMPLE t2 NULL range a a 10 NULL 60 27.10 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`b` = 2) and (5 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 10)) or ((`test`.`t2`.`b` = 3) and (15 <= `test`.`t2`.`a`) and (`test`.`t2`.`a` < 20)) or ((`test`.`t2`.`b` = 1) and (1 <= `test`.`t2`.`a`))) +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +a b +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +7 0 +8 0 +9 0 +EXPLAIN +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range a a 5 NULL 9 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`b` = 3) and (5 <= `test`.`t3`.`a`) and (`test`.`t3`.`a` < 10)) or (`test`.`t3`.`a` < 5) or (`test`.`t3`.`a` < 10)) +DROP TABLE t1, t2, t3; +# +# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL); +a +DROP TABLE t1; +# +# Bug#47925: regression of range optimizer and date comparison in 5.1.39! +# +CREATE TABLE t1 ( a DATE, KEY ( a ) ); +CREATE TABLE t2 ( a DATETIME, KEY ( a ) ); +# Make optimizer choose range scan +INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22'); +INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23'); +INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'), +('2009-09-22 12:00:00'); +INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'), +('2009-09-23 12:00:00'); +# DATE vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# DATE vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009/09/23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATETIME +EXPLAIN +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '20090923120000'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= 20090923120000; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00'; +a +2009-09-23 12:00:00 +2009-09-23 12:00:00 +2009-09-23 12:00:00 +# DATETIME vs DATE +EXPLAIN +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +X X X NULL ALL NULL NULL X X X 100.00 X +X X X NULL range a a X X X 100.00 X +Warnings: +X X X +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '20090923000000'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= 20090923000000; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00'; +a +2009-09-23 +2009-09-23 +2009-09-23 +# Test of the new get_date_from_str implementation +# Behavior differs slightly between the trunk and mysql-pe. +# The former may give errors for the truncated values, while the latter +# gives warnings. The purpose of this test is not to interfere, and only +# preserve existing behavior. +# This case was made obsolete after the changes applied by +# Bug#28940878 WRONG RESULT WHEN COMPARING DATE[TIME] WITH STRING +# as we don't fallback anymore to string comparison if the date is invalid. +SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND +str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND +str_to_date('2007-20-00', '%Y-%m-%d') <= ''; +ERROR HY000: Incorrect DATE value: '' +SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'; +str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '' +SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''; +str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date +SELECT str_to_date('', '%Y-%m-%d'); +str_to_date('', '%Y-%m-%d') +0000-00-00 +DROP TABLE t1, t2; +# +# Bug#48459: valgrind errors with query using 'Range checked for each +# record' +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY ( c ), +KEY ( d, a, b ( 2 ) ), +KEY ( b ( 1 ) ) +); +INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ), +( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 ); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY ( e ) +); +INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL ); +# Should not give Valgrind warnings +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# Bug #48665: sql-bench's insert test fails due to wrong result +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a)); +INSERT INTO t1 VALUES (0,0), (1,1); +EXPLAIN +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +@ @ @ NULL ALL @ @ @ @ @ 100.00 @ +@ @ @ NULL range @ @ @ @ @ 100.00 @ +Warnings: +@ @ @ +# Should return 2 rows +SELECT * FROM t1 FORCE INDEX (PRIMARY) +WHERE (a>=1 AND a<=2) OR (a>=4 AND a<=5) OR (a>=0 AND a <=10); +a b +0 0 +1 1 +DROP TABLE t1; +# +# Bug #54802: 'NOT BETWEEN' evaluation is incorrect +# +CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key)); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c_key NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c_key` AS `c_key`,`test`.`t1`.`c_notkey` AS `c_notkey` from `test`.`t1` where (2 not between `test`.`t1`.`c_notkey` and `test`.`t1`.`c_key`) +SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key; +c_key c_notkey +1 1 +3 3 +DROP TABLE t1; +# +# Bug #57030: 'BETWEEN' evaluation is incorrect +# +CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT); +CREATE UNIQUE INDEX i4_uq ON t1(i4); +INSERT INTO t1 VALUES (1,10), (2,20), (3,30); +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const i4_uq i4_uq 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `pk`,'10' AS `i4` from `test`.`t1` where true +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between 10 and `test`.`t1`.`i4`) +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (10 between `test`.`t1`.`i4` and 10) +SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10; +pk i4 +1 10 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL i4_uq 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` +SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where false +SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 100 and 0) +SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and 99999999999999999) +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999; +pk i4 +1 10 +2 20 +3 30 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 999999999999999 and 30) +SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30; +pk i4 +EXPLAIN +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range i4_uq i4_uq 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4` from `test`.`t1` where (`test`.`t1`.`i4` between 10 and '20') +SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20'; +pk i4 +1 10 +2 20 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`) +EXPLAIN FORMAT=tree +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.60 rows=3) + -> Filter: (t1.i4 is not null) (cost=0.55 rows=3) + -> PQblock scan on t1 using i4_uq (cost=0.55 rows=3) + -> Filter: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.i4) (cost=0.28 rows=1) + +SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4; +pk i4 pk i4 +EXPLAIN +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index i4_uq i4_uq 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`) +SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk; +pk i4 pk i4 +DROP TABLE t1; +# +# BUG#13519696 - 62940: SELECT RESULTS VARY WITH VERSION AND +# WITH/WITHOUT INDEX RANGE SCAN +# +create table t1 (id int unsigned not null auto_increment primary key); +insert into t1 values (null); +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +insert into t1 select null from t1; +create table t2 ( +id int unsigned not null auto_increment, +val decimal(5,3) not null, +primary key (id,val), +unique key (val,id), +unique key (id)); +insert into t2 select null,id*0.0009 from t1; +select count(val) from t2 ignore index (val) where val > 0.1155; +count(val) +185 +select count(val) from t2 force index (val) where val > 0.1155; +count(val) +185 +drop table t2, t1; +# +# BUG#13453382 - REGRESSION SINCE 5.1.39, RANGE OPTIMIZER WRONG +# RESULTS WITH DECIMAL CONVERSION +# +create table t1 (a int,b int,c int,primary key (a,c)); +insert into t1 values (1,1,2),(1,1,3),(1,1,4); +select convert(3, signed integer) > 2.9; +convert(3, signed integer) > 2.9 +1 +select * from t1 force index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c>= 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 force index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +select * from t1 ignore index (primary) where a=1 and c> 2.9; +a b c +1 1 3 +1 1 4 +drop table t1; +# +# BUG#13463488 - 63437: CHAR & BETWEEN WITH INDEX RETURNS WRONG +# RESULT AFTER MYSQL 5.1. +# +CREATE TABLE t1( +F1 CHAR(5) NOT NULL, +F2 CHAR(5) NOT NULL, +F3 CHAR(5) NOT NULL, +PRIMARY KEY(F1), +INDEX IDX_F2(F2) +) COLLATE latin1_swedish_ci; +INSERT INTO t1 VALUES +('A','A','A'),('AA','AA','AA'),('AAA','AAA','AAA'), +('AAAA','AAAA','AAAA'),('AAAAA','AAAAA','AAAAA'); +SELECT * FROM t1 WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 = 'A '; +F1 F2 F3 +A A A +SELECT * FROM t1 WHERE F1 >= 'A '; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 > 'A '; +F1 F2 F3 +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F1 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F2 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 WHERE F3 BETWEEN 'A ' AND 'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND +'AAAAA'; +F1 F2 F3 +A A A +AA AA AA +AAA AAA AAA +AAAA AAAA AAAA +AAAAA AAAAA AAAAA +DROP TABLE t1; +End of 5.1 tests +CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1)); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT c1 FROM t1 WHERE c1 >= 'A' GROUP BY 1; +c1 +1 +2 +3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'A' +DROP TABLE t1; +create table t1 (a int,b int,key (b),key (a),key (b,a)); +insert into t1(a,b) values (1,2),(3,4),(5,6),(7,8); +create table t2 (c int); +insert into t2(c) values (1),(5),(6),(7),(8); +select 1 from (select c from t1,t2 where b >= 1 and a <=> c group by 1 limit 1) as d1; +1 +1 +drop table t1, t2; +# +# Bug #26106: Wrong plan may be chosen when there are several possible +# range and ref accesses +# +# Note: The fix for this bug has been reverted. The code will no longer +# select the optimal plan for the two following test queries. This is +# not due to a bug but due to minor differences in range estimates +# produced by the storage engine. +CREATE TABLE t1( +a INT, +b INT, +KEY k ( a ), +KEY l ( a, b ) +); +INSERT INTO t1(a) VALUES (1); +INSERT INTO t1 +VALUES (2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3),(2,3); +INSERT INTO t1 SELECT 3, 4 FROM t1 WHERE a = 2 AND b = 3; +INSERT INTO t1 SELECT 4, 1 FROM t1 WHERE a = 2 AND b = 3; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +INSERT INTO t1 SELECT a, b FROM t1 WHERE a=1 AND b=2; +# This must use range over index l, not k. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t1 WHERE a = 1 AND b >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 129 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref k,l k 5 const 129 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` >= 2)) +CREATE TABLE t2( +a INT, +b INT, +c INT, +KEY k ( a ), +KEY l ( a, b ), +KEY m ( b ), +KEY n ( a, c ) +); +INSERT INTO t2(a) VALUES (1); +INSERT INTO t2 +VALUES (2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3), +(2,3,3),(2,3,3),(2,3,3),(2,3,3),(2,3,3); +INSERT INTO t2 SELECT 3, 4, 4 FROM t2 WHERE a = 2 AND b = 3; +INSERT INTO t2 SELECT 4, 1, 1 FROM t2 WHERE a = 2 AND b = 3; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +INSERT INTO t2 VALUES (1, 2, 2); +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 SELECT a, b, c FROM t2 WHERE a=1 AND b=2; +INSERT INTO t2 VALUES (1, 1, 2); +# This must use range over index l, not n. +# Update: Due to patch being reverted and minor differences in +# range estimates k is selected. +EXPLAIN SELECT * FROM t2 WHERE a = 1 AND b >= 2 AND c >= 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 66 29.16 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref k,l,m,n k 5 const 66 29.16 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a` = 1) and (`test`.`t2`.`b` >= 2) and (`test`.`t2`.`c` >= 2)) +DROP TABLE t1, t2; +# +# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER +# AWAY QUALIFYING ROWS +# +CREATE TABLE t10( +K INT NOT NULL AUTO_INCREMENT, +I INT, J INT, +PRIMARY KEY(K), +KEY(I,J) +); +INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5), +(6,6),(6,7),(6,8),(6,9),(6,0); +CREATE TABLE t100 LIKE t10; +INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y; +INSERT INTO t100(I,J) VALUES(8,26); + +EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t100 NULL range I I 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t100`.`K` AS `K`,`test`.`t100`.`I` AS `I`,`test`.`t100`.`J` AS `J` from `test`.`t100` where ((`test`.`t100`.`I` <> 6) or ((`test`.`t100`.`J` = 5) and (`test`.`t100`.`I` <> 8))) + +SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); +K I J +128 8 26 +DROP TABLE t10,t100; +# +# BUG#12698916 - JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR +# AFTER FLUSH TABLES [-INT VS NULL] +# +CREATE TABLE t1 (col_int INT, pk INT) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (-100,1),(1,6); +CREATE TABLE t2 ( +col_int_key INT, +col_varchar VARCHAR(100) NOT NULL DEFAULT "DEFAULT", +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t2 VALUES +(1,"GOOD",1),(100,"",2),(200,"",3),(300,"",4),(400,"",5),(500,"",8); +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t2 NULL ref PRIMARY,col_int_key col_int_key 5 test.t1.col_int # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +# need FLUSH so that InnoDB statistics change and thus plan changes +FLUSH TABLES; +EXPLAIN SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL PRIMARY,col_int_key NULL NULL NULL # # Range checked for each record (index map: 0x3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`pk` AS `pk`,`test`.`t2`.`col_int_key` AS `col_int_key`,`test`.`t2`.`col_varchar` AS `col_varchar`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`col_int_key` = `test`.`t1`.`col_int`) and (`test`.`t2`.`pk` < `test`.`t1`.`pk`)) +EXPLAIN FORMAT=tree SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=1.90 rows=4) + -> PQblock scan on t1 (cost=0.45 rows=2) + -> Filter: ((t2.col_int_key = t1.col_int) and (t2.pk < t1.pk)) (cost=0.22 rows=2) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.22 rows=6) + +SELECT t1.*,t2.* FROM t1 straight_join t2 +ON t2.col_int_key = t1.col_int WHERE t2.pk < t1.pk; +col_int pk col_int_key col_varchar pk +1 6 1 GOOD 1 +DROP TABLE t1,t2; +# +# Bug#12694872 - +# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_int_key INTEGER NOT NULL, +col_date_key DATE NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_date_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1 ( +col_int_key, +col_int_nokey, +col_date_key, +col_varchar_key, +col_varchar_nokey +) VALUES +(0, 4, '2011-08-25', 'j', 'j'), +(8, 6, '2004-09-18', 'v', 'v'), +(1, 3, '2009-12-01', 'c', 'c'), +(8, 5, '2004-12-17', 'm', 'm'), +(9, 3, '2000-03-14', 'd', 'd'), +(6, 2, '2006-05-25', 'y', 'y'), +(1, 9, '2008-01-23', 't', 't'), +(6, 3, '2007-06-18', 'd', 'd'), +(2, 8, '2002-10-13', 's', 's'), +(4, 1, '1900-01-01', 'r', 'r'), +(8, 8, '1959-04-25', 'm', 'm'), +(4, 8, '2006-03-09', 'b', 'b'), +(4, 5, '2001-06-05', 'x', 'x'), +(7, 7, '2006-05-28', 'g', 'g'), +(4, 5, '2001-04-19', 'p', 'p'), +(1, 1, '1900-01-01', 'q', 'q'), +(9, 6, '2004-08-20', 'w', 'w'), +(4, 2, '2004-10-10', 'd', 'd'), +(8, 9, '2000-04-02', 'e', 'e') +; +SET UNIQUE_CHECKS = 0; +SET FOREIGN_KEY_CHECKS = 0; +SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +SET FOREIGN_KEY_CHECKS = 1; +SET UNIQUE_CHECKS = 1; +CREATE TABLE t2 SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +; +SELECT * FROM t2 +WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1, +CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2 +FROM ( t1 AS table1 INNER JOIN t1 AS table2 +ON (( table2.pk <> table1.pk ) AND +( table2.pk >= table1.col_int_nokey ) ) ) +WHERE ( table1.pk > 226 AND +table1.pk < ( 226 + 102 ) OR +( table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 36 ) OR +( table1.col_varchar_key <= 'h' OR +table1.col_int_key > 226 AND +table1.col_int_key < ( 226 + 227 ) ) +) +) +); +field1 field2 +1900-01-01 qb +1900-01-01 qc +1900-01-01 qd +1900-01-01 qd +1900-01-01 qd +1900-01-01 qe +1900-01-01 qg +1900-01-01 rb +1900-01-01 rc +1900-01-01 rd +1900-01-01 rd +1900-01-01 rd +1900-01-01 re +1900-01-01 rg +1959-04-25 mb +1959-04-25 mc +1959-04-25 md +1959-04-25 md +1959-04-25 md +1959-04-25 me +1959-04-25 mg +2000-03-14 dc +2000-03-14 dd +2000-03-14 dd +2000-04-02 eb +2000-04-02 ec +2000-04-02 ed +2000-04-02 ed +2000-04-02 ed +2000-04-02 eg +2001-04-19 pb +2001-04-19 pc +2001-04-19 pd +2001-04-19 pd +2001-04-19 pd +2001-04-19 pe +2001-04-19 pg +2001-06-05 xb +2001-06-05 xc +2001-06-05 xd +2001-06-05 xd +2001-06-05 xd +2001-06-05 xe +2001-06-05 xg +2002-10-13 sb +2002-10-13 sc +2002-10-13 sd +2002-10-13 sd +2002-10-13 sd +2002-10-13 se +2002-10-13 sg +2004-08-20 wb +2004-08-20 wc +2004-08-20 wd +2004-08-20 wd +2004-08-20 wd +2004-08-20 we +2004-08-20 wg +2004-09-18 vd +2004-10-10 db +2004-10-10 dc +2004-10-10 dd +2004-10-10 dd +2004-10-10 de +2004-10-10 dg +2004-12-17 mc +2004-12-17 md +2004-12-17 md +2004-12-17 md +2006-03-09 bc +2006-03-09 bd +2006-03-09 bd +2006-03-09 bd +2006-03-09 be +2006-03-09 bg +2006-05-25 yc +2006-05-25 yd +2006-05-25 yd +2006-05-25 yd +2006-05-28 gb +2006-05-28 gc +2006-05-28 gd +2006-05-28 gd +2006-05-28 gd +2006-05-28 ge +2007-06-18 db +2007-06-18 dc +2007-06-18 dd +2007-06-18 dd +2007-06-18 dg +2008-01-23 tc +2008-01-23 td +2008-01-23 td +2008-01-23 td +2008-01-23 tg +2009-12-01 cd +2009-12-01 cd +2009-12-01 cd +DROP TABLE t1, t2; +# +# BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == +# SAVE_READ_SET +# +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +PRIMARY KEY (c,a), KEY (a),KEY (a) +) ENGINE=INNODB PARTITION BY KEY () PARTITIONS 2; +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1 VALUES (1,5,1),(2,4,1),(3,3,1),(4,2,1),(5,1,1); +UPDATE t1 SET b = 0, c=1 WHERE a <=>0; +SELECT * FROM t1; +a b c +1 5 1 +2 4 1 +3 3 1 +4 2 1 +5 1 1 +DROP TABLE t1; +# +# BUG#13256446 - ASSERTION QUICK->HEAD->READ_SET == +# SAVE_READ_SET' FAILED IN OPT_RANGE.CC:1606 +# +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f2=103; +INSERT INTO t1 VALUES (154,0,NULL,0),(0,NULL,9,0), +(NULL,102,NULL,3),(0,3,NULL,0), (9,0,NULL,0),(0,9,NULL,157); +SELECT * FROM v2; +f1 f2 f3 f4 +UPDATE v2 SET f4=0, f2=NULL, f1=NULL WHERE f1 > 16 ORDER BY f1; +SELECT * FROM v2; +f1 f2 f3 f4 +DROP TABLE t1; +DROP VIEW v2; +CREATE TABLE t1 ( +f1 INT AUTO_INCREMENT, +f2 INT, +f3 INT, +f4 INT, +PRIMARY KEY (f1),KEY(f2) +) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,NULL,NULL,0), (2,2,0,3), (9,0,107,18), +(10,0,0,0), (231,0,0,0), (232,0,8,0), (234,0,0,NULL), (235,8,0,3); +CREATE ALGORITHM=MERGE VIEW v3 AS SELECT f1,f2,f3,f4 FROM t1 WHERE f1<=85 ; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +UPDATE v3 SET f3=0, f4=4 WHERE f2=68 ORDER BY f1; +SELECT * FROM v3; +f1 f2 f3 f4 +1 NULL NULL 0 +2 2 0 3 +9 0 107 18 +10 0 0 0 +DROP TABLE t1; +DROP VIEW v3; +# +# BUG#13731380: RANGE OPTIMIZER CALLS RECORDS_IN_RANGE() FOR OPEN RANGE +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(3),(5); +SELECT * FROM t1 WHERE pk <> 3 OR pk < 4; +pk +1 +3 +5 +DROP TABLE t1; +# +# BUG#13803810: TOO FEW ROWS RETURNED FOR RANGE ACCESS IN +# VARCHAR INDEX USING DATETIME VALUE + +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +CREATE TABLE t2 (b VARCHAR(64), KEY (b)) CHARSET utf8mb4; +INSERT INTO t2 VALUES ('2001-01-01'); +INSERT INTO t2 VALUES ('2001.01.01'); +INSERT INTO t2 VALUES ('2001#01#01'); +INSERT INTO t2 VALUES ('2001-01-01 00:00:00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); + +# range/ref access cannot be used for this query + +EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = (cast('2001-01-01' as date))) +SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE); +b +2001#01#01 +2001-01-01 +2001-01-01 00:00:00 +2001.01.01 + +# range/ref access cannot be used for any of the queries below. +# See BUG#13814468 about 'Range checked for each record' + +EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = cast(`test`.`t2`.`b` as datetime(6))) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL index b b 259 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'b' due to type or collation conversion on field 'b' +Warning 1739 Cannot use range access on index 'b' due to type or collation conversion on field 'b' +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (cast(`test`.`t2`.`b` as datetime(6)) = `test`.`t1`.`a`) order by `cast(t1.a as char charset binary)`,`cast(t2.b as char charset binary)` +SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b; +a b +2001-01-01 00:00:00 2001#01#01 +2001-01-01 00:00:00 2001-01-01 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 00:00:00 2001.01.01 +2001-01-01 11:22:33 2001-01-01 11:22:33 + +DROP TABLE t1,t2; +# +# WL#7019: Add support for row value constructors in in predicates to +# range optimizer +# +CREATE TABLE t1 (a INT, b INT, c INT, KEY x(a, b)); +INSERT INTO t1 VALUES (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6), +(7, 7, 7), (8, 8, 8), (9, 9, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 VALUES (0, 0, 0), (1, 1, 1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +CREATE TABLE t3 (a INT, b INT, c INT, d INT, KEY x(a, b, c)); +INSERT INTO t3 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((NULL, NULL), (NULL, NULL)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((NULL,NULL),(NULL,NULL))) +EXPLAIN SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a = 0 AND b = 0) OR (a = 1 AND b = 1); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +a b +0 0 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t2 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` where ((`test`.`t3`.`a`,`test`.`t3`.`b`,`test`.`t3`.`c`) in ((0,0,0),(1,1,1))) +FLUSH STATUS; +SELECT a, b, c FROM t3 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, 1)); +a b c +0 0 0 +1 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) or ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE a = 0 AND b = 0 OR (a, b) IN ((1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) or ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((1, 1)) OR a = 0 AND b = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 19.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range x x 10 NULL 2 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1) and (`test`.`t2`.`a` = 1)) or ((`test`.`t2`.`c` = 0) and (`test`.`t2`.`b` = 0) and (`test`.`t2`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t2 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t3 NULL range x x 15 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where (((`test`.`t3`.`c` = 1) and (`test`.`t3`.`b` = 1) and (`test`.`t3`.`a` = 1)) or ((`test`.`t3`.`c` = 0) and (`test`.`t3`.`b` = 0) and (`test`.`t3`.`a` = 0))) +FLUSH STATUS; +SELECT a, b FROM t3 WHERE (a, b, c) IN ((1, 1, 1)) OR a = 0 AND b = 0 AND c = 0; +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = 1)) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (((SELECT 1), 1)); +a b +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (('0',0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN (('0', 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +SET @v = 0; +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in (((@`v`),0),(1,1))) +FLUSH STATUS; +SELECT a, b FROM t1 WHERE (a, b) IN ((@v, 0), (1, 1)); +a b +0 0 +1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +CREATE TABLE t4 ( a INT, b INT ); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t4 SELECT a + 5, b + 5 FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t4; +# Inner table in a nested-loops join +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 USING(a, b) +WHERE (t4.a, t4.b) IN ((1, 1), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 2.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 2.00 Using where +2 SIMPLE t1 NULL ref x x 10 test.t4.a,test.t4.b 409 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t4`.`b`) and (`test`.`t1`.`a` = `test`.`t4`.`a`) and ((`test`.`t4`.`a`,`test`.`t4`.`b`) in ((1,1),(0,0)))) +# Join on IN +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(0,0))) +EXPLAIN +SELECT t4.*, t1.a, t1.b +FROM t4 JOIN t1 +WHERE (t1.a, t1.b) IN ((t4.a, t4.b), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 640 100.00 Parallel execute (2 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 640 100.00 NULL +2 SIMPLE t1 NULL index x x 10 NULL 4098 2.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t4` join `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((`test`.`t4`.`a`,`test`.`t4`.`b`),(1,1))) +# +# Tests for non-deterministic functions. +# +CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (f1(), 1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL x NULL NULL NULL 4098 0.20 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(`f1`(),1,1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,`f1`(),1))) +EXPLAIN SELECT a, b FROM t1 WHERE (a, b, c) IN ((0, 0, 0), (1, 1, f1())); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range x x 10 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`) in ((0,0,0),(1,1,`f1`()))) +# The statement immediately below should not use range access. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((f1(), 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index x x 10 NULL 4098 1.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (`test`.`t1`.`a` = `f1`())) +DROP FUNCTION f1; +# The statement immediately below should not use range access. +EXPLAIN +SELECT a, b +FROM t1 AS t1o +WHERE EXISTS (SELECT /*+ NO_SEMIJOIN() */ 1 +FROM t1 +WHERE (a, b) IN ((t1o.a, t1o.b)) ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1o NULL index NULL x 10 NULL 4098 100.00 Using where; Using index +2 DEPENDENT SUBQUERY t1 NULL ref x x 10 test.t1o.a,test.t1o.b 409 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.t1o.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1o.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1o`.`a` AS `a`,`test`.`t1o`.`b` AS `b` from `test`.`t1` `t1o` where exists(/* select#2 */ select 1 from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1o`.`a`) and (`test`.`t1`.`b` = `test`.`t1o`.`b`))) +# +# Tests of dynamic range access +# +CREATE TABLE t5 (a int, b int, KEY (a)); +INSERT INTO t5 VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1); +CREATE TABLE t6 (a int, b int, KEY (a)); +INSERT INTO t6 VALUES (3, 2), (4, 2), (100, 100), (101, 201), (102, 102); +CREATE TABLE t7 (a int, b int, KEY (a, b)); +INSERT INTO t7 VALUES (1, 1), (2, 2), (1000, 1000), (1001, 1001), (1002, 1002), +(1003, 1003), (1004, 1004); +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 28.57 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and (`test`.`t7`.`a` in (`test`.`t5`.`b`,`test`.`t6`.`b`))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE t7.a IN (t5.b, t6.b); +a b a b a b +3 1 3 2 1 1 +3 1 3 2 2 2 +4 1 4 2 1 1 +4 1 4 2 2 2 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +EXPLAIN SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t6 NULL ALL a NULL NULL NULL 5 100.00 Using where +2 SIMPLE t5 NULL ref a a 5 test.t6.a 1 100.00 NULL +2 SIMPLE t7 NULL ALL a NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b` from `test`.`t5` join `test`.`t6` join `test`.`t7` where ((`test`.`t5`.`a` = `test`.`t6`.`a`) and ((`test`.`t7`.`a`,`test`.`t7`.`b`) in ((`test`.`t5`.`b`,1),(`test`.`t6`.`b`,1)))) +FLUSH STATUS; +SELECT * +FROM t5 JOIN t6 ON t5.a = t6.a JOIN t7 +WHERE (t7.a, t7.b) IN ((t5.b, 1), (t6.b, 1)); +a b a b a b +3 1 3 2 1 1 +4 1 4 2 1 1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 3 +Handler_read_key 8 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 22 +# +# Regression tests of the worklog below. +# +# Make sure we process IN predicates only. +# The code around this is very unclear. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) != (1, 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4098 99.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index x x 10 NULL 4098 99.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` <> 1) or (`test`.`t1`.`b` <> 1)) +# This should give us a ref scan, as it always did. +EXPLAIN SELECT a, b FROM t1 WHERE (a, b) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 10 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 0) and (`test`.`t1`.`a` = 0)) +EXPLAIN SELECT a, b FROM t1 WHERE (a, c) IN ((0, 0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref x x 5 const 1 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`c` = 0) and (`test`.`t1`.`a` = 0)) +# ref scan on x(a). +EXPLAIN SELECT * FROM t1 WHERE (a, c) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range x x 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`c`) in ((0,0),(1,1))) +DROP TABLE t1, t2, t3, t4, t5, t6, t7; +# +# Bug#17635476: CRASH IN GET_MM_PARTS() OR ASSERT IN +# GET_FUNC_MM_TREE_FROM_IN_PREDICATE() +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY (a) +) ENGINE = INNODB; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +INSERT INTO t1 VALUES (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), +(7, 7), (8, 8), (9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 ( +a INT, +b INT, +KEY (a, b) +); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range a a 5 NULL 2 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,`test`.`t1`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t1 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range a a 10 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((`test`.`t2`.`a`,`test`.`t2`.`b`) in ((0,0),(1,1))) +FLUSH STATUS; +SELECT DISTINCT a FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a +0 +1 +SHOW STATUS LIKE 'Handler_read_%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 2 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t1 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` where ((NULL,`test`.`t1`.`b`) in ((0,0),(1,1))) +# Should not use range scan. +EXPLAIN SELECT DISTINCT a FROM t2 WHERE (NULL, b) IN ((0, 0), (1, 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 10 NULL 10 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a` from `test`.`t2` where ((NULL,`test`.`t2`.`b`) in ((0,0),(1,1))) +DROP TABLE t1, t2; +# +# Bug#17755540 VALGRIND ERROR WHEN SETTING UP ROW COMPARATORS +# +CREATE TABLE t2 (a INT, b INT, c INT, d INT, KEY x(a, b)); +INSERT INTO t2 VALUES (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 5, 5, 5), +(6, 6, 6, 6), (7, 7, 7, 7), (8, 8, 8, 8), (9, 9, 9, 9); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t2 VALUES (0, 0, 0, 0), (1, 1, 1, 1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT a, b FROM t2 WHERE (a, b) IN ((0, 0), (1, 1)); +a b +0 0 +1 1 +DROP TABLE t2; +# +# BUG#18364815: OPTIMIZER PREFERS TABLE SCAN WHEN +# USING "IN" WITH VALUE OF DIFFERENT TYPE +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (4,1), (5,1), (6,1); +EXPLAIN SELECT * FROM t1 WHERE a IN (1, 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2)) +EXPLAIN SELECT * FROM t1 WHERE a IN (1, "2"); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,'2')) +SELECT * FROM t1 WHERE a IN (1, 2); +a b +1 1 +2 1 +SELECT * FROM t1 WHERE a IN (1, "2"); +a b +1 1 +2 1 +DROP TABLE t1; +# +# Bug#18715670 +# CRASH IN DECIMAL_ACTUAL_FRACTION COMPARING DECIMAL TO NULLS +# +CREATE TABLE t1(n DECIMAL(39,19) NOT NULL, KEY(n)) engine=innodb; +INSERT INTO t1 SET n=0; +SELECT 1 FROM t1 WHERE n NOT IN(NULL, NULL); +1 +DROP TABLE t1; +# +# Bug#18759597 MISSING ROWS ON WHERE .. +# IN QUERY WITH VARIABLES AND CONCAT +# +CREATE TABLE t1 ( +col_varchar_key varchar(2), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('n'),('xm'); +SET @var1 = 't', @var2 = 'him', +@var3 = 'n', @var4 = 'n', +@var5 = 'n', @var6 = 'g', +@var7 = 'b', @var8 = 'o', +@var9 = 'm', @var10 = 'xm', @var11 = 'u' +; +SELECT col_varchar_key AS field1 +FROM t1 +WHERE ( col_varchar_key, col_varchar_key ) IN ( +('m', @var1 ), +('n', @var3 ), +('a', @var5 ), +('l', @var7 ), +(CONCAT('x', @var9 ), @var10 ) +); +field1 +n +xm +DROP TABLE t1; +# +# Bug#18535226 DEBUG CRASH ON QUICK_RANGE_SELECT::RESET +# +SET @old_tmp_table_size=@@tmp_table_size; +SET tmp_table_size=1024; +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_key INT, +col_date_key date, +col_date_nokey date, +col_time_key time, +col_time_nokey time, +col_datetime_key datetime, +col_datetime_nokey datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(5,0,'2001-05-06','2001-05-06','16:21:18','16:21:18','2001-11-08 21:02:12', +'2001-11-08 21:02:12','x','x'),(6,7,'2006-03-03','2006-03-03','18:56:33', +'18:56:33','2003-04-01 00:00:00','2003-04-01 00:00:00','i','i'), +(7,7,'2007-12-28','2007-12-28',NULL,NULL,'1900-01-01 00:00:00', +'1900-01-01 00:00:00','e','e'),(8,1,'2004-10-20','2004-10-20','09:29:08', +'09:29:08','2007-07-12 00:00:00','2007-07-12 00:00:00','p','p'), +(9,7,'2008-04-09','2008-04-09','19:11:10','19:11:10', +'2005-04-04 01:21:01','2005-04-04 01:21:01','s','s'), +(10,1,'2005-12-25','2005-12-25','11:57:26','11:57:26', +'1900-01-01 00:00:00','1900-01-01 00:00:00','j','j'); +SELECT alias1.col_int_key +FROM +( SELECT SQ1_alias1.* FROM t1 AS SQ1_alias1, t1 AS SQ1_alias2 ) AS alias1, +(SELECT 7 AS col_int_nokey) AS alias2 +WHERE +alias2.col_int_nokey = alias1.pk +AND alias1.col_varchar_nokey < alias1.col_varchar_key +ORDER BY alias1.col_varchar_key; +col_int_key +DROP TABLE t1; +SET tmp_table_size=@old_tmp_table_size; +SET sql_mode = default; +# +# Bug#19585938 Crash in get_full_func_mm_tree with null +# item_field->table_ref +# +CREATE TABLE t1(id INTEGER, col1 INTEGER, col2 INTEGER, PRIMARY KEY(id)); +INSERT INTO t1 VALUES (1,2,3), (3,2,1); +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) < id +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id > SUM(1) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN id AND id+1 +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE id BETWEEN SUM(1) AND SUM(5) +) AS c +FROM t1 +GROUP BY col1; +c +1 +SELECT (SELECT 1 +FROM t1 +WHERE SUM(1) BETWEEN COUNT(*) AND id +) AS c +FROM t1 +GROUP BY col1; +c +1 +DROP TABLE t1; +# +# Bug#21415791 VALGRIND ERROR (CONDITIONAL JUMP) AT KEY_AND +# (RANGE_OPT_PARAM*, SEL_ARG*, SEL_AR +# +CREATE TABLE t1 ( +col_varchar_10 VARCHAR(10), +pk INTEGER NOT NULL, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t1 ( +pk, col_varchar_10, col_int_key) VALUES +(1, 'ttttt', 0), (2, 'zzzzz', 0), (3, 'ggggg', 0), +(4, 'hhhhh', 0), (5, 'kkkkk', 0), (6, 'lllll', 0); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +col_varchar_10 VARCHAR(10), +PRIMARY KEY (pk), +KEY col_varchar_10 (col_varchar_10) +) ENGINE=InnoDB; +INSERT INTO t2 ( +pk, col_varchar_10) VALUES +(1, '00000'), (2, '00000'), (3, '44444'), (4, '00000'), +(5, NULL), (6, NULL), (7, NULL); +SELECT COUNT(t1.col_int_key) +FROM t2 RIGHT OUTER JOIN t1 ON t2.col_varchar_10 <= t1.col_varchar_10 +WHERE t2.pk <> 4 OR t2.pk != t1.col_int_key AND t2.pk <> 1000; +COUNT(t1.col_int_key) +24 +DROP TABLE t1, t2; +# +# Bug #20229614: OR CONDITIONS ON MULTI-COLUMN INDEX MAY NOT USE ALL +# INDEX COLUMNS TO FILTER ROWS +# +CREATE TABLE t1 ( +c1 INT, +c2 INT, +c3 INT, +PRIMARY KEY(c1, c2, c3) +) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 1), (1, 1, 2), (1, 1, 3), +(1, 1, 4), (1, 1, 5); +INSERT INTO t1 SELECT c1, 2, c3 FROM t1; +INSERT INTO t1 SELECT c1, 3, c3 FROM t1 WHERE c2 = 1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +15 +EXPLAIN SELECT c1, c2, c3 +FROM t1 +WHERE (c1 = 1 AND c2 = 1 AND c3 = 1) OR +(c1 = 1 AND c2 = 2 AND c3 = 2) OR +(c1 = 1 AND c2 = 2 AND c3 = 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 12 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where (((`test`.`t1`.`c3` = 1) and (`test`.`t1`.`c2` = 1) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1)) or ((`test`.`t1`.`c3` = 3) and (`test`.`t1`.`c2` = 2) and (`test`.`t1`.`c1` = 1))) +DROP TABLE t1; +# +# Bug#21139683: ASSERTION FAILED: TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE +# +CREATE TABLE t1 ( +a BLOB, +PRIMARY KEY(a(1)), +KEY(a(1)) +) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE a <> 'a' OR a <> ""; +1 +DROP TABLE t1; +# +# Bug#19333852: RESULT DIFF IN QUERY HAVING DISTINCT +# WITH GROUP BY +# +CREATE TABLE t1 ( +v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY v1_key (v1(10)) +) ENGINE=InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); +EXPLAIN SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` < (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v1_key v1_key 32 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` = (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v1` AS `v1`,`test`.`t1`.`pk` AS `pk` from `test`.`t1` where (`test`.`t1`.`v1` between 'f' and (char(127))) +SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +v1 pk +ABCDE 19 +JLVGO 14 +SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +v1 pk +SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +v1 pk +JLVGO 14 +DROP TABLE t1; +# +# Bug #21761867: ASSERTION `TYPE_ARG == MAYBE_KEY || +# TYPE_ARG == IMPOSSIBLE' FAILED. +# +CREATE TABLE t1 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +c18 INT, +PRIMARY KEY (c10,c12), +UNIQUE KEY key_c12(c12), +KEY key_c18(c18)); +INSERT INTO t1 VALUES(11,5,0), (12,6,1), (13,7,2), (14,8,3), (15,9,4); +CREATE TABLE t2 ( +c10 INT NOT NULL, +c12 INT NOT NULL, +PRIMARY KEY(c10,c12)); +CREATE TABLE t3 (c10 INT NOT NULL); +SELECT t2.c10 +FROM t1 +RIGHT JOIN t3 +LEFT JOIN t2 +ON t3.c10 = t2.c10 +ON t1.c12 > t2.c12 +WHERE +t1.c10 <= 25 +AND +t1.c18 IS NOT NULL +OR +t1.c10 > 5 +AND +t1.c18 IN (15,16,18); +c10 +DROP TABLE t1, t2, t3; +# +# Bug #21318711: WRONG RESULTS FOR TRUNCATED COLUMN AND AGGREGATION +# +CREATE TABLE t1 ( +col1 VARCHAR(5), +col2 INT NOT NULL, +PRIMARY KEY (col1, col2) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES ('abcde', 10); +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 22 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where (`test`.`t1`.`col1` = 'abcdeaa') +EXPLAIN SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`col2`) AS `MAX(col2)` from `test`.`t1` where multiple equal('abcde ', `test`.`t1`.`col1`) +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcdeaa'; +MAX(col2) +NULL +SELECT MAX(col2) FROM t1 WHERE col1 = 'abcde '; +MAX(col2) +10 +DROP TABLE t1; +# +# Bug# 22283790: RANGE OPTIMIZER UTILIZES TOO MUCH MEMORY WITH +# MANY OR CONDITIONS +# +CREATE TABLE t1 ( +f1 INTEGER, +KEY (f1) +); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15); +SET @orig_range_optimizer_max_mem_size= @@range_optimizer_max_mem_size; +SET range_optimizer_max_mem_size= 5000; +EXPLAIN SELECT * FROM t1 WHERE f1=1 OR f1=2 OR f1=3 OR f1=4 OR f1=5 +OR f1=6 OR f1=7 OR f1=8 OR f1=9 OR f1=10 OR f1=11; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range f1 f1 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f1` = 1) or (`test`.`t1`.`f1` = 2) or (`test`.`t1`.`f1` = 3) or (`test`.`t1`.`f1` = 4) or (`test`.`t1`.`f1` = 5) or (`test`.`t1`.`f1` = 6) or (`test`.`t1`.`f1` = 7) or (`test`.`t1`.`f1` = 8) or (`test`.`t1`.`f1` = 9) or (`test`.`t1`.`f1` = 10) or (`test`.`t1`.`f1` = 11)) +SET range_optimizer_max_mem_size= @orig_range_optimizer_max_mem_size; +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +SELECT * FROM t1 WHERE pk IN (3, 8) OR pk NOT IN (2); +pk +DROP TABLE t1; +# +# Bug #23623110: REFACTOR USE_COUNT IN THE RANGE OPTIMIZER +# +# Tests deleting nodes in tree_delete() not from the end of the +# linked list. +# +# Indirectly tests ORing with a tree that has a nonzero refcount, +# where nodes are also being skipped over. (There was a bug in +# refcounting such trees earlier.) +# +CREATE TABLE t1 ( +col_int_key int, +pk int NOT NULL, +col_int int, +KEY test_idx (pk,col_int_key,col_int) +); +SELECT * FROM t1 WHERE +(col_int_key >= 6 AND pk > 6) OR +(pk > 2 AND col_int_key = 7 AND col_int > 6); +col_int_key pk col_int +DROP TABLE t1; +# +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE `giant_table` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`one_id` int(11) NOT NULL, +`other_id` bigint(20) NOT NULL DEFAULT '0', +`some_other_id` int(11) DEFAULT 0 NOT NULL, +`something` double NOT NULL DEFAULT '0', +`comment` text COLLATE utf8_unicode_ci, +`flags` int(11) NOT NULL DEFAULT '0', +`time_created` int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (`id`), +KEY `time_created` (`time_created`), +KEY `some_other_id` (`some_other_id`), +KEY `one_other_idx` (`one_id`,`other_id`), +KEY `other_id` (`other_id`,`time_created`) +) ENGINE=InnoDB AUTO_INCREMENT=101651329 +DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (66136540), (68983250), (89627210), (77869520), +(82543190), (67538270), (77282760), (77908170), +(70923370), (68066360); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT INTO giant_table(id,one_id) +SELECT c1 + @x, 0 +FROM t1 +WHERE c1 IN (66136540, 68985250, 89627210, 77869520 , 82543190, 67538270, +77282760, 77908170, 70923370, 68066360); +SET @x = @x + 1; +UNTIL @x > 30 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM giant_table; +count(*) +270 +INSERT INTO giant_table (id,one_id) VALUES (66136539, 0), (68983258,1), +(89628210,1), (77869520,2); +INSERT INTO giant_table (id,one_id, some_other_id) VALUES(84673401, 0, 1), +(61069031, 1, 1); +EXPLAIN SELECT id, something, comment, time_created, one_id, other_id, +some_other_id, flags +FROM giant_table +WHERE id IN (66136539, 68983258, 89628210, 77869520, 82543198, 67538272, +84673401, 61069031, 68214385, 77282865, 76991297, 64569216, +89481638, 74534074, 70396537, 80076375, 63308530, 77908270, +70923271, 68066180) +AND (giant_table.flags & 0x01) = 0 AND giant_table.some_other_id = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE giant_table NULL range PRIMARY,some_other_id PRIMARY 4 NULL 20 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`giant_table`.`id` AS `id`,`test`.`giant_table`.`something` AS `something`,`test`.`giant_table`.`comment` AS `comment`,`test`.`giant_table`.`time_created` AS `time_created`,`test`.`giant_table`.`one_id` AS `one_id`,`test`.`giant_table`.`other_id` AS `other_id`,`test`.`giant_table`.`some_other_id` AS `some_other_id`,`test`.`giant_table`.`flags` AS `flags` from `test`.`giant_table` where ((`test`.`giant_table`.`some_other_id` = 0) and (`test`.`giant_table`.`id` in (66136539,68983258,89628210,77869520,82543198,67538272,84673401,61069031,68214385,77282865,76991297,64569216,89481638,74534074,70396537,80076375,63308530,77908270,70923271,68066180)) and ((`test`.`giant_table`.`flags` & 0x01) = 0)) +DROP PROCEDURE p; +DROP TABLE giant_table, t1; +# +# Bug#22671573: SIG11 IN SEL_ARG::RB_INSERT |SQL/OPT_RANGE.CC +# +# Tests creating an empty tree (impossible condition) and then ANDing with it. +# +CREATE TABLE t1 ( +a INT, +b INT, +KEY test_idx (b, a) +); +SELECT * FROM t1 WHERE b BETWEEN 8 AND 8 AND a > 8 AND a <= 8; +a b +DROP TABLE t1; +# +# Indirectly tests inserting a node into an empty (impossible) tree. +# +CREATE TABLE t1 ( +pk INT, +PRIMARY KEY ( pk ) +); +SELECT * FROM t1 WHERE pk = 6 OR pk > 6; +pk +DROP TABLE t1; +# +# Indirectly tests ORing with an empty (impossible) tree. +# +CREATE TABLE t1 ( +col_int_key INT, +KEY (col_int_key) +); +SELECT * FROM t1 WHERE col_int_key IS NULL OR col_int_key < 9 OR col_int_key = 9; +col_int_key +DROP TABLE t1; +# +# Indirectly tests deleting the last node from a tree +# (which makes it IMPOSSIBLE) and then inserting more than one node. +# +CREATE TABLE t1 ( +a VARCHAR(64), +KEY a (a) +); +SELECT * FROM t1 WHERE a IS NULL OR a NOT IN ( 'foo', 'bar' ); +a +DROP TABLE t1; +# +# Bug#25229315: ASSERTION TABLE->M_RECORD_BUFFER.RECORD_SIZE() == +# RECORD_PREFIX_SIZE(TAB)' FAIL +# +CREATE TABLE t1 (pk INT PRIMARY KEY, vc VARCHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, NULL), (2, 'w'); +CREATE TABLE t2 ( +i INT, +vc VARCHAR(1), +pk INT PRIMARY KEY, +KEY (i), +KEY (vc) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 'p', 1), (9, 'w', 2), (NULL, 'r', 3); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL i,vc NULL NULL NULL 3 55.56 Range checked for each record (index map: 0x6) +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`vc` = `test`.`t1`.`vc`) or (`test`.`t2`.`i` = `test`.`t1`.`pk`)) +SELECT MIN(t1.pk) FROM t1, t2 WHERE t2.vc = t1.vc OR t2.i = t1.pk; +MIN(t1.pk) +1 +DROP TABLE t1, t2; +# +# Bug #26727773: OPTIMIZER CHOSES COMPOSITE INDEX FOR REF OVER RANGE +# +CREATE TABLE transactions ( +app_trans_id INT DEFAULT NULL, +id INT NOT NULL, +tbl INT NOT NULL DEFAULT 1, +created TIMESTAMP NOT NULL DEFAULT '2017-01-01 01:01:01', +trans_type INT NOT NULL, +description BLOB, +source_lvl1 INT DEFAULT NULL, +source_lvl2 INT DEFAULT NULL, +KEY tbl_id_idx (tbl,id), +KEY created_idx (created), +KEY trans_type_created_idx (trans_type,created), +KEY app_trans_id_idx (app_trans_id) +) ENGINE=INNODB ; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1000), (2000), (3000), (4000), (5000), (6000), +(7000), (8000), (9000); +CREATE PROCEDURE p() +BEGIN +SET @x = 1; +REPEAT +INSERT IGNORE INTO transactions(id,trans_type, description) +SELECT c1 + @x, @x , 'abcd' + FROM t1; +SET @x = @x + 1; +UNTIL @x > 300 END REPEAT; +END $ +CALL p(); +SELECT count(*) FROM transactions; +count(*) +3000 +INSERT IGNORE INTO transactions(id,trans_type, description, created) +SELECT 3, 3 , 'abcd', '2018-01-01 01:01:01' + FROM dual; +EXPLAIN SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE transactions NULL range tbl_id_idx,created_idx,trans_type_created_idx created_idx 4 NULL # # Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select '2017-10-23 01:01:01' AS `2017-10-23 01:01:01`,hour(`test`.`transactions`.`created`) AS `HOUR(created)`,`test`.`transactions`.`source_lvl1` AS `source_lvl1`,`test`.`transactions`.`source_lvl2` AS `source_lvl2`,count(distinct `test`.`transactions`.`app_trans_id`) AS `COUNT(DISTINCT(app_trans_id))` from `test`.`transactions` where ((`test`.`transactions`.`trans_type` = 3) and (`test`.`transactions`.`tbl` = 1) and (`test`.`transactions`.`created` > TIMESTAMP'2017-10-23 01:01:01')) group by '2017-10-23 01:01:01',hour(`test`.`transactions`.`created`),`test`.`transactions`.`source_lvl1`,`test`.`transactions`.`source_lvl2` +SET optimizer_trace="enabled=on"; +SELECT '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2, +COUNT(DISTINCT(app_trans_id)) +FROM transactions +WHERE created > '2017-10-23 01:01:01' AND tbl = 1 AND trans_type in (3) +GROUP BY '2017-10-23 01:01:01', HOUR(created), source_lvl1, source_lvl2; +2017-10-23 01:01:01 HOUR(created) source_lvl1 source_lvl2 COUNT(DISTINCT(app_trans_id)) +2017-10-23 01:01:01 1 NULL NULL 0 +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +SET optimizer_trace="enabled=off"; +DROP PROCEDURE p; +DROP TABLE t1, transactions; +# +# Bug #28086754: OPTIMIZER SKIP THE RANG SCAN ON SECOND COLUMN IN A +# COMPOSITE INDEX +# +CREATE TABLE test_ref ( +a INT PRIMARY KEY, +b VARCHAR(20), +c VARCHAR(20) DEFAULT NULL, +d VARCHAR(3) DEFAULT NULL, +id INT DEFAULT NULL, +KEY idx1 (id, c), +KEY idx2 (id, d)) ENGINE=INNODB ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze Error Table 'test.t1' doesn't exist +test.t1 analyze status Operation failed +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c`,`test`.`test_ref`.`a` limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c, a +LIMIT 1; +a b c d id +34876 D003 gheennse S 3 +EXPLAIN SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 25 100.00 Parallel execute (1 workers) +2 SIMPLE test_ref NULL range idx1,idx2 idx1 88 NULL 25 100.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`test_ref`.`a` AS `a`,`test`.`test_ref`.`b` AS `b`,`test`.`test_ref`.`c` AS `c`,`test`.`test_ref`.`d` AS `d`,`test`.`test_ref`.`id` AS `id` from `test`.`test_ref` where ((`test`.`test_ref`.`id` = 3) and (`test`.`test_ref`.`c` like 'gh%')) order by `test`.`test_ref`.`c` desc,`test`.`test_ref`.`a` desc limit 1 +SELECT * +FROM test_ref +WHERE id=3 AND c LIKE 'gh%' +ORDER BY c DESC, a DESC +LIMIT 1; +a b c d id +1770649 D003 gheennse S 3 +DROP TABLE test_ref; +# +# Bug #30988735: SELECT QUERY WITH ERROR RESULT WITH "NOT IN" +# WHERE_CLAUSE +# +CREATE TABLE t(f1 INTEGER key, f2 INTEGER)ENGINE=INNODB; +INSERT INTO t VALUES(0,0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT f1,f2 FROM t WHERE f1 NOT IN(-0.1,0.1); +f1 f2 +0 0 +DROP TABLE t; +set optimizer_switch=default; diff --git a/mysql-test/r/row.result-pq b/mysql-test/r/row.result-pq new file mode 100644 index 000000000..bbb3d4d83 --- /dev/null +++ b/mysql-test/r/row.result-pq @@ -0,0 +1,662 @@ +drop table if exists t1; +select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)); +(1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)) +1 +select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)); +row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)) +0 +select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)) +1 +select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)) +0 +select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')); +row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')) +1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'a' +Warning 1292 Truncated incorrect INTEGER value: 'a' +select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)); +row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)) +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a' +select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)); +row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)) +1 +select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)) +1 +select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)) +0 +select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)) +NULL +select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)); +row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)) +0 +select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))); +(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))) +1 +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4)); +ERROR 21000: Operand should contain 2 column(s) +select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); +row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))) +NULL +explain select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select ((1,2,(3,4)) in ((3,2,(3,4)),(1,2,(3,NULL)))) AS `row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))` +select row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(4,5))); +row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(4,5))) +0 +select row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(3,5))); +row(1,2,row(3,null)) IN (row(3,2,row(3,4)), row(1,2,row(3,5))) +NULL +SELECT (1,2,3)=(0,NULL,3); +(1,2,3)=(0,NULL,3) +0 +SELECT (1,2,3)=(1,NULL,3); +(1,2,3)=(1,NULL,3) +NULL +SELECT (1,2,3)=(1,NULL,0); +(1,2,3)=(1,NULL,0) +0 +SELECT ROW(1,2,3)=ROW(1,2,3); +ROW(1,2,3)=ROW(1,2,3) +1 +SELECT ROW(2,2,3)=ROW(1+1,2,3); +ROW(2,2,3)=ROW(1+1,2,3) +1 +SELECT ROW(1,2,3)=ROW(1+1,2,3); +ROW(1,2,3)=ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)ROW(1+1,2,3); +ROW(1,2,3)>ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)<=ROW(1+1,2,3); +ROW(1,2,3)<=ROW(1+1,2,3) +1 +SELECT ROW(1,2,3)>=ROW(1+1,2,3); +ROW(1,2,3)>=ROW(1+1,2,3) +0 +SELECT ROW(1,2,3)<>ROW(1+1,2,3); +ROW(1,2,3)<>ROW(1+1,2,3) +1 +SELECT ROW(NULL,2,3)=ROW(NULL,2,3); +ROW(NULL,2,3)=ROW(NULL,2,3) +NULL +SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3); +ROW(NULL,2,3)<=>ROW(NULL,2,3) +1 +SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)); +ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)) +1 +SELECT ROW('test',2,3.33)=ROW('test',2,3.33); +ROW('test',2,3.33)=ROW('test',2,3.33) +1 +SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); +ERROR 21000: Operand should contain 3 column(s) +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)) +1 +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)) +0 +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)); +ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)) +NULL +SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4); +ERROR 21000: Operand should contain 2 column(s) +create table t1 ( a int, b int, c int); +insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL); +select * from t1 where ROW(1,2,3)=ROW(a,b,c); +a b c +1 2 3 +select * from t1 where ROW(0,2,3)=ROW(a,b,c); +a b c +select * from t1 where ROW(1,2,3) ROW(3,4); +ROW(2,10) <=> ROW(3,4) +0 +SELECT ROW(NULL,10) <=> ROW(3,NULL); +ROW(NULL,10) <=> ROW(3,NULL) +0 +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1)); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2))); +ERROR 21000: Operand should contain 3 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1)); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3))); +ERROR 21000: Operand should contain 2 column(s) +SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0)); +ERROR 21000: Operand should contain 1 column(s) +SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2)); +ERROR 21000: Operand should contain 1 column(s) +CREATE TABLE t1(a int, b int, c int); +INSERT INTO t1 VALUES (1, 2, 3), +(NULL, 2, 3 ), (1, NULL, 3 ), (1, 2, NULL), +(NULL, 2, 3+1), (1, NULL, 3+1), (1, 2+1, NULL), +(NULL, 2, 3-1), (1, NULL, 3-1), (1, 2-1, NULL); +SELECT (1,2,3) = (1, NULL, 3); +(1,2,3) = (1, NULL, 3) +NULL +SELECT (1,2,3) = (1+1, NULL, 3); +(1,2,3) = (1+1, NULL, 3) +0 +SELECT (1,2,3) = (1, NULL, 3+1); +(1,2,3) = (1, NULL, 3+1) +0 +SELECT * FROM t1 WHERE (a,b,c) = (1,2,3); +a b c +1 2 3 +SELECT (1,2,3) <> (1, NULL, 3); +(1,2,3) <> (1, NULL, 3) +NULL +SELECT (1,2,3) <> (1+1, NULL, 3); +(1,2,3) <> (1+1, NULL, 3) +1 +SELECT (1,2,3) <> (1, NULL, 3+1); +(1,2,3) <> (1, NULL, 3+1) +1 +SELECT * FROM t1 WHERE (a,b,c) <> (1,2,3); +a b c +NULL 2 4 +1 NULL 4 +1 3 NULL +NULL 2 2 +1 NULL 2 +1 1 NULL +SELECT (1,2,3) < (NULL, 2, 3); +(1,2,3) < (NULL, 2, 3) +NULL +SELECT (1,2,3) < (1, NULL, 3); +(1,2,3) < (1, NULL, 3) +NULL +SELECT (1,2,3) < (1-1, NULL, 3); +(1,2,3) < (1-1, NULL, 3) +0 +SELECT (1,2,3) < (1+1, NULL, 3); +(1,2,3) < (1+1, NULL, 3) +1 +SELECT * FROM t1 WHERE (a,b,c) < (1,2,3); +a b c +1 1 NULL +SELECT (1,2,3) <= (NULL, 2, 3); +(1,2,3) <= (NULL, 2, 3) +NULL +SELECT (1,2,3) <= (1, NULL, 3); +(1,2,3) <= (1, NULL, 3) +NULL +SELECT (1,2,3) <= (1-1, NULL, 3); +(1,2,3) <= (1-1, NULL, 3) +0 +SELECT (1,2,3) <= (1+1, NULL, 3); +(1,2,3) <= (1+1, NULL, 3) +1 +SELECT * FROM t1 WHERE (a,b,c) <= (1,2,3); +a b c +1 2 3 +1 1 NULL +SELECT (1,2,3) > (NULL, 2, 3); +(1,2,3) > (NULL, 2, 3) +NULL +SELECT (1,2,3) > (1, NULL, 3); +(1,2,3) > (1, NULL, 3) +NULL +SELECT (1,2,3) > (1-1, NULL, 3); +(1,2,3) > (1-1, NULL, 3) +1 +SELECT (1,2,3) > (1+1, NULL, 3); +(1,2,3) > (1+1, NULL, 3) +0 +SELECT * FROM t1 WHERE (a,b,c) > (1,2,3); +a b c +1 3 NULL +SELECT (1,2,3) >= (NULL, 2, 3); +(1,2,3) >= (NULL, 2, 3) +NULL +SELECT (1,2,3) >= (1, NULL, 3); +(1,2,3) >= (1, NULL, 3) +NULL +SELECT (1,2,3) >= (1-1, NULL, 3); +(1,2,3) >= (1-1, NULL, 3) +1 +SELECT (1,2,3) >= (1+1, NULL, 3); +(1,2,3) >= (1+1, NULL, 3) +0 +SELECT * FROM t1 WHERE (a,b,c) >= (1,2,3); +a b c +1 2 3 +1 3 NULL +DROP TABLE t1; +SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ; +1 0 0 0 null +1 0 0 0 NULL +select row(NULL,1)=(2,0); +row(NULL,1)=(2,0) +0 +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'2' AS `b` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a,b)=(3,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a`,'2' AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE a=3 and b=2; +a b +3 2 +SELECT * FROM t1 WHERE (a,b)=(3,2); +a b +3 2 +CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c)); +INSERT INTO t2 VALUES +(1,1,2), (3,1,3), (1,2,2), (4,4,2), +(1,1,1), (3,1,1), (1,2,1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.40 rows=7) + -> PQblock scan on t2 using PRIMARY (cost=0.95 rows=7) + -> Single-row index lookup on t1 using PRIMARY (a=t2.a, b=t2.b) (cost=0.26 rows=1) + +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +EXPLAIN FORMAT=tree SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b); +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.40 rows=7) + -> PQblock scan on t2 using PRIMARY (cost=0.95 rows=7) + -> Single-row index lookup on t1 using PRIMARY (a=t2.a, b=t2.b) (cost=0.26 rows=1) + +SELECT * FROM t1,t2 WHERE t1.a=t2.a and t1.b=t2.b; +a b a b c +1 1 1 1 1 +1 1 1 1 2 +1 2 1 2 1 +1 2 1 2 2 +3 1 3 1 1 +3 1 3 1 3 +SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b); +a b a b c +1 1 1 1 1 +1 1 1 1 2 +1 2 1 2 1 +1 2 1 2 2 +3 1 3 1 1 +3 1 3 1 3 +EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 6 16.67 Using where; Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 6 16.67 Using where; Using index +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * FROM t1,t2 WHERE t1.a=1 and t1.b=t2.b; +a b a b c +1 1 1 1 1 +1 1 1 1 2 +1 1 3 1 1 +1 1 3 1 3 +1 2 1 2 1 +1 2 1 2 2 +SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2); +a b a b c +1 2 1 1 1 +1 2 1 1 2 +1 2 1 2 1 +1 2 1 2 2 +3 2 3 1 1 +3 2 3 1 3 +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 100.00 Using index +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 8 test.t2.a,func 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1))) +SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1); +a b a b c +1 2 1 1 1 +1 2 1 1 2 +3 2 3 1 1 +3 2 3 1 3 +EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 8 NULL 6 100.00 Using index +2 SIMPLE t2 NULL index NULL PRIMARY 12 NULL 7 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (((`test`.`t1`.`a` - 1) = (`test`.`t2`.`a` - 1)) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1))) +SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1); +a b a b c +1 2 1 1 1 +1 2 1 1 2 +3 2 3 1 1 +3 2 3 1 3 +EXPLAIN SELECT * FROM t2 WHERE a=3 AND b=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = 3)) +EXPLAIN SELECT * FROM t2 WHERE (a,b)=(3,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref PRIMARY PRIMARY 8 const,const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = 3)) +SELECT * FROM t2 WHERE a=3 and b=2; +a b c +SELECT * FROM t2 WHERE (a,b)=(3,2); +a b c +EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND t2.b=2 AND t2.c=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 14.29 Using where; Using index +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 test.t2.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +EXPLAIN SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 14.29 Using where; Using index +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 test.t2.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1)); +a b a b c +1 1 1 2 1 +1 2 1 2 1 +EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 14.29 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 12 NULL 7 14.29 Using where; Using index +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 test.t2.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t1`.`a` = `test`.`t2`.`a`)) +SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1); +a b a b c +1 1 1 2 1 +1 2 1 2 1 +DROP TABLE t1,t2; +CREATE TABLE t1( +a int, b int, c int, d int, e int, f int, g int, h int, +PRIMARY KEY (a,b,c,d,e,f,g) +); +INSERT INTO t1 VALUES (1,2,3,4,5,6,7,99); +SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7); +h +99 +SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7)); +SELECT @x; +@x +99 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1); +SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a; +ROW(a, 1) IN (SELECT SUM(b), 1) +1 +SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a; +ROW(a, 1) IN (SELECT SUM(b), 3) +0 +DROP TABLE t1; +create table t1 (a varchar(200), +b int unsigned not null primary key auto_increment) +default character set 'utf8'; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t2 (c varchar(200), +d int unsigned not null primary key auto_increment) +default character set 'latin1'; +insert into t1 (a) values('abc'); +insert into t2 (c) values('abc'); +select * from t1,t2 where (a,b) = (c,d); +a b c d +abc 1 abc 1 +select host,user from mysql.user where (host,user) = ('localhost','test'); +host user +drop table t1,t2; +# +# Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings +# +CREATE TABLE t1 (a TIME NOT NULL, b TINYINT); +INSERT IGNORE INTO t1 VALUES (0, 0),(0, 0); +SELECT 1 FROM t1 WHERE ROW(a, b) >= +ROW('1', (SELECT 1 FROM t1 WHERE a > '1234abc')); +1 +Warnings: +Warning 1292 Incorrect time value: '1234abc' for column 'a' at row 1 +DROP TABLE t1; +# +# Bug #54190: Comparison to row subquery produces incorrect result +# +SELECT ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0) +NULL +SELECT ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); +ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0) +NULL +CREATE TABLE t1 (i INT); +INSERT INTO t1 () VALUES (1), (2), (3); +SELECT ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0); +ROW(1,2) = (SELECT 1,2 FROM t1 WHERE 1 = 0) +NULL +SELECT ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0); +ROW(1,2) = (SELECT 1,3 FROM t1 WHERE 1 = 0) +NULL +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,2 FROM DUAL WHERE 1 = 0); +i +SELECT i FROM t1 WHERE ROW(1,2) = (SELECT 1,3 FROM DUAL WHERE 1 = 0); +i +DROP TABLE t1; +End of 5.1 tests +# +# Bug#18745214: ASSERTION FAILED: FALSE, FILE SQL_TMP_TABLE.CC OR +# MALFORMED PACKET +# +CREATE TABLE t1 ( a INT ) ENGINE = INNODB; +INSERT INTO t1 VALUES ( 1 ); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT row( 1, 1, 1 ) = row( 1, 1 ) FROM t1 GROUP BY a; +ERROR 21000: Operand should contain 3 column(s) +EXPLAIN SELECT row( min(a), 1 ) = row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) = `test`.`t1`.`a`) and (1 = 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) = row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( min(a), 1 ) <> row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) <> `test`.`t1`.`a`) or (1 <> 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) <> row( a, 1 ) AS al FROM t1 GROUP BY a; +al +0 +EXPLAIN SELECT row( min(a), 1 ) <=> row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) <=> `test`.`t1`.`a`) and (1 <=> 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) <=> row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( min(a), 1 ) > row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) > (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) > row( a, 1 ) AS al FROM t1 GROUP BY a; +al +0 +EXPLAIN SELECT row( min(a), 1 ) >= row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) >= (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) >= row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( min(a), 1 ) < row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) < (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) < row( a, 1 ) AS al FROM t1 GROUP BY a; +al +0 +EXPLAIN SELECT row( min(a), 1 ) <= row( a, 1 ) AS al FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`),1) <= (`test`.`t1`.`a`,1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( min(a), 1 ) <= row( a, 1 ) AS al FROM t1 GROUP BY a; +al +1 +EXPLAIN SELECT row( row( min(a), 1 ), 1 ) = row( row( a, 1 ), 1 ) AS al +FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select ((min(`min(t1.a)`) = `test`.`t1`.`a`) and (1 = 1) and (1 = 1)) AS `al` from `test`.`t1` group by `test`.`t1`.`a` +SELECT row( row( min(a), 1 ), 1 ) = row( row( a, 1 ), 1 ) AS al +FROM t1 GROUP BY a; +al +1 +# Test of manually thrown error. +SELECT 1 <=>ALL (SELECT 1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<=>ALL (SELECT 1)' at line 1 +DROP TABLE t1; +# +# Bug #22299664 REGRESSION, ASSERTION FAILED: !THD->IS_ERROR() WITH +# ROW() + SPATIAL FUNCTIONS +# +SELECT ROW(ST_Intersection(POINT(1, 1), 1), (SELECT 1)); +ERROR 22023: Invalid GIS data provided to function st_intersection. +SELECT ROW(1, ST_Intersection(POINT(1, 1), 1), (SELECT 1)); +ERROR 22023: Invalid GIS data provided to function st_intersection. +SELECT ROW(POW(1000, 1000), (SELECT 1)); +ERROR 22003: DOUBLE value is out of range in 'pow(1000,1000)' +SELECT ROW(1, 2, POW(1000, 1000), (SELECT 1)); +ERROR 22003: DOUBLE value is out of range in 'pow(1000,1000)' +# Bug#31590301: Another MySQL 8.0.20 assert over Linux-5.4.0-39-generic +# using X86_64 +CREATE TABLE v0(v1 DEC, v2 INT); +INSERT INTO v0 VALUES (64, 93); +CREATE ALGORITHM = TEMPTABLE VIEW v3 AS +SELECT * +FROM v0 +WHERE (v1, FALSE) IN +((-1, EXISTS (SELECT (-128, 'x', 72) <= (76, 'x', -1))), (-1, 'x')); +DROP VIEW v3; +DROP TABLE v0; diff --git a/mysql-test/r/select_all.result-pq b/mysql-test/r/select_all.result-pq new file mode 100644 index 000000000..a78d9df9a --- /dev/null +++ b/mysql-test/r/select_all.result-pq @@ -0,0 +1,5700 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL id4 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using index condition; Using where; Using MRR +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=9.27 rows=19) + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) (cost=0.40 rows=1) + -> Index lookup on alias2 using i1 (f2=alias1.f1) (cost=0.40 rows=2) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; diff --git a/mysql-test/r/select_all_bka.result-pq b/mysql-test/r/select_all_bka.result-pq new file mode 100644 index 000000000..ac8a3290b --- /dev/null +++ b/mysql-test/r/select_all_bka.result-pq @@ -0,0 +1,5703 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL id4 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using index condition; Using where; Using MRR +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 10 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Batched key access inner join + -> Batch input rows + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) + -> Multi-range index lookup on alias2 using i1 (f2=alias1.f1) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/select_all_bka_nobnl.result-pq b/mysql-test/r/select_all_bka_nobnl.result-pq new file mode 100644 index 000000000..6010b825a --- /dev/null +++ b/mysql-test/r/select_all_bka_nobnl.result-pq @@ -0,0 +1,5703 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref id4 id4 4 test.t3.id3 1 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using index condition; Using where; Using MRR +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 10 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Batched key access inner join + -> Batch input rows + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) + -> Multi-range index lookup on alias2 using i1 (f2=alias1.f1) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/select_count.result-pq b/mysql-test/r/select_count.result-pq new file mode 100644 index 000000000..3ce1f07d1 --- /dev/null +++ b/mysql-test/r/select_count.result-pq @@ -0,0 +1,578 @@ +CREATE TABLE t_innodb(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL, +c3 char(20), +KEY c3_idx(c3))ENGINE=INNODB; +INSERT INTO t_innodb VALUES (1, 1, 'a'), (2,2,'a'), (3,3,'a'); +ANALYZE TABLE t_innodb; +Table Op Msg_type Msg_text +test.t_innodb analyze status OK +CREATE TABLE t_myisam(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL DEFAULT 1, +c3 char(20), +KEY c3_idx(c3)) ENGINE=MYISAM; +INSERT INTO t_myisam(c1) VALUES (1), (2); +ANALYZE TABLE t_myisam; +Table Op Msg_type Msg_text +test.t_myisam analyze status OK +EXPLAIN SELECT COUNT(*) FROM t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` +EXPLAIN SELECT COUNT(*) FROM t_myisam; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_myisam` +EXPLAIN SELECT COUNT(*) FROM t_myisam, t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_myisam NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_myisam` join `test`.`t_innodb` +EXPLAIN SELECT MIN(c2), COUNT(*), MAX(c1) FROM t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t_innodb NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t_innodb`.`c2`) AS `MIN(c2)`,count(0) AS `COUNT(*)`,max(`test`.`t_innodb`.`c1`) AS `MAX(c1)` from `test`.`t_innodb` +EXPLAIN SELECT MIN(c3), COUNT(*) FROM t_innodb; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t_innodb`.`c3`) AS `MIN(c3)`,count(0) AS `COUNT(*)` from `test`.`t_innodb` +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_myisam; +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_myisam, t_innodb; +COUNT(*) +6 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 4 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT MIN(c2), COUNT(*), MAX(c1) FROM t_innodb; +MIN(c2) COUNT(*) MAX(c1) +1 3 3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 1 +Handler_read_key 2 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 4 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT MIN(c3), COUNT(*) FROM t_innodb; +MIN(c3) COUNT(*) +a 3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +CREATE TABLE t_nopk(c1 INT NOT NULL , c2 INT NOT NULL)ENGINE=INNODB; +INSERT INTO t_nopk SELECT c1, c2 FROM t_innodb; +ANALYZE TABLE t_nopk; +Table Op Msg_type Msg_text +test.t_nopk analyze status OK +SHOW CREATE TABLE t_nopk; +Table Create Table +t_nopk CREATE TABLE `t_nopk` ( + `c1` int NOT NULL, + `c2` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +EXPLAIN SELECT COUNT(*) FROM t_nopk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_nopk NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_nopk` +FLUSH STATUS; +SELECT COUNT(*) FROM t_nopk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +CREATE INDEX c2_idx on t_nopk(c2); +SHOW CREATE TABLE t_nopk; +Table Create Table +t_nopk CREATE TABLE `t_nopk` ( + `c1` int NOT NULL, + `c2` int NOT NULL, + KEY `c2_idx` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +EXPLAIN SELECT COUNT(*) FROM t_nopk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_nopk NULL index NULL c2_idx 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_nopk` +FLUSH STATUS; +SELECT COUNT(*) FROM t_nopk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t_nopk; +CREATE TABLE t_innodb_nopk_sk(c1 INT NOT NULL, +c2 INT NOT NULL, KEY c2_idx(c2))ENGINE=INNODB; +CREATE TABLE t_innodb_pk_nosk(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL)ENGINE=INNODB; +CREATE TABLE t_innodb_nopk_nosk(c1 INT NOT NULL, +c2 INT NOT NULL)ENGINE=INNODB; +INSERT INTO t_innodb_nopk_sk(c1,c2) VALUES (1, 1), (2,2), (3,3); +INSERT INTO t_innodb_pk_nosk(c1,c2) SELECT * FROM t_innodb_nopk_sk; +INSERT INTO t_innodb_nopk_nosk(c1,c2) SELECT * FROM t_innodb_nopk_sk; +ANALYZE TABLE t_innodb_nopk_sk, t_innodb_pk_nosk, t_innodb_nopk_nosk; +Table Op Msg_type Msg_text +test.t_innodb_nopk_sk analyze status OK +test.t_innodb_pk_nosk analyze status OK +test.t_innodb_nopk_nosk analyze status OK +EXPLAIN SELECT COUNT(*) FROM t_innodb_nopk_sk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb_nopk_sk NULL index NULL c2_idx 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb_nopk_sk` +EXPLAIN SELECT COUNT(*) FROM t_innodb_pk_nosk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb_pk_nosk NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb_pk_nosk` +EXPLAIN SELECT COUNT(*) FROM t_innodb_nopk_nosk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb_nopk_nosk NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb_nopk_nosk` +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb_nopk_sk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb_pk_nosk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb_nopk_nosk; +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t_innodb_pk_nosk, t_innodb_nopk_sk, t_innodb_nopk_nosk; +CREATE TABLE t_heap(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL, +c3 char(20)) ENGINE=HEAP; +CREATE TABLE t_archive(c1 INT NOT NULL, c2 char(20)) ENGINE=ARCHIVE; +INSERT INTO t_heap SELECT * FROM t_innodb WHERE c1 > 1; +INSERT INTO t_archive SELECT c1, c3 FROM t_innodb WHERE c1 > 1; +EXPLAIN SELECT COUNT(*) FROM t_heap; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_heap` +EXPLAIN SELECT COUNT(*) FROM t_innodb, t_heap; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_heap NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` join `test`.`t_heap` +EXPLAIN SELECT COUNT(*) FROM t_archive; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_archive` +EXPLAIN SELECT COUNT(*) FROM t_innodb, t_archive; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_archive NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` join `test`.`t_archive` +FLUSH STATUS; +SELECT COUNT(*) FROM t_heap; +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb, t_heap; +COUNT(*) +6 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 4 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_archive; +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb, t_archive; +COUNT(*) +6 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 4 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +DROP TABLE t_archive, t_heap; +EXPLAIN SELECT COUNT(*) FROM t_innodb FORCE INDEX(c3_idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_innodb NULL index NULL c3_idx 81 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_innodb` FORCE INDEX (`c3_idx`) +EXPLAIN SELECT COUNT(*) FROM t_myisam FORCE INDEX(c3_idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t_myisam NULL index NULL c3_idx 81 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t_myisam` FORCE INDEX (`c3_idx`) +FLUSH STATUS; +SELECT COUNT(*) FROM t_innodb FORCE INDEX(c3_idx); +COUNT(*) +3 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 1 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +FLUSH STATUS; +SELECT COUNT(*) FROM t_myisam FORCE INDEX(c3_idx); +COUNT(*) +2 +SHOW STATUS LIKE 'Handler_%'; +Variable_name Value +Handler_commit 0 +Handler_delete 0 +Handler_discover 0 +Handler_external_lock 2 +Handler_mrr_init 0 +Handler_prepare 0 +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +Handler_rollback 0 +Handler_savepoint 0 +Handler_savepoint_rollback 0 +Handler_update 0 +Handler_write 0 +SELECT COUNT(*) FROM (SELECT DISTINCT c1 FROM t_myisam) dt, t_myisam; +COUNT(*) +4 +SET @s =1; +SELECT @s, COUNT(*) FROM t_innodb; +@s COUNT(*) +1 3 +set sql_mode=''; +SELECT 1 AS c1, (SELECT COUNT(*) FROM t_innodb HAVING c1 > 0) FROM DUAL; +c1 (SELECT COUNT(*) FROM t_innodb HAVING c1 > 0) +1 3 +SELECT 1 FROM t_innodb HAVING COUNT(*) > 1; +1 +1 +SELECT COUNT(*) c FROM t_innodb HAVING c > 1; +c +3 +SELECT COUNT(*) c FROM t_innodb HAVING c > 7; +c +EXPLAIN FORMAT=tree SELECT COUNT(*) c FROM t_innodb HAVING c > 7; +EXPLAIN +-> Filter: (c > 7) + -> Count rows in t_innodb + +EXPLAIN FORMAT=tree SELECT COUNT(*) c FROM t_myisam HAVING c > 7; +EXPLAIN +-> Filter: (c > 7) + -> Rows fetched before execution (cost=0.00 rows=1) + +SELECT COUNT(*) c FROM t_innodb LIMIT 10 OFFSET 5; +c +set sql_mode=default; +SELECT SQL_BIG_RESULT COUNT(*) FROM t_innodb; +COUNT(*) +3 +SELECT SQL_BIG_RESULT COUNT(*) FROM t_innodb, t_myisam; +COUNT(*) +6 +SELECT /*+ BNL(t2) */ -(t1.c1 + t2.c1) FROM t_innodb t1, t_innodb t2 +UNION ALL SELECT COUNT(*) FROM t_innodb; +-(t1.c1 + t2.c1) +-2 +-3 +-3 +-4 +-4 +-4 +-5 +-5 +-6 +3 +DROP TABLE t_innodb, t_myisam; diff --git a/mysql-test/r/select_icp_mrr.result-pq b/mysql-test/r/select_icp_mrr.result-pq new file mode 100644 index 000000000..2981756df --- /dev/null +++ b/mysql-test/r/select_icp_mrr.result-pq @@ -0,0 +1,5700 @@ +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL id4 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using index condition; Using where; Using MRR +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=9.27 rows=19) + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) (cost=0.40 rows=1) + -> Index lookup on alias2 using i1 (f2=alias1.f1) (cost=0.40 rows=2) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; diff --git a/mysql-test/r/select_icp_mrr_bka.result-pq b/mysql-test/r/select_icp_mrr_bka.result-pq new file mode 100644 index 000000000..ee3b8a279 --- /dev/null +++ b/mysql-test/r/select_icp_mrr_bka.result-pq @@ -0,0 +1,5703 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL id4 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using index condition; Using where; Using MRR +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 10 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Batched key access inner join + -> Batch input rows + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) + -> Multi-range index lookup on alias2 using i1 (f2=alias1.f1) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/select_icp_mrr_bka_nobnl.result-pq b/mysql-test/r/select_icp_mrr_bka_nobnl.result-pq new file mode 100644 index 000000000..86d7a0e02 --- /dev/null +++ b/mysql-test/r/select_icp_mrr_bka_nobnl.result-pq @@ -0,0 +1,5703 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref id4 id4 4 test.t3.id3 1 100.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using index condition; Using where; Using MRR +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using index condition; Using where; Using MRR +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 13 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 10 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using index condition; Using where; Using MRR; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Batched key access inner join + -> Batch input rows + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) + -> Multi-range index lookup on alias2 using i1 (f2=alias1.f1) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/select_none.result-pq b/mysql-test/r/select_none.result-pq new file mode 100644 index 000000000..fa7098fa4 --- /dev/null +++ b/mysql-test/r/select_none.result-pq @@ -0,0 +1,5699 @@ +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL id4 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=9.27 rows=19) + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) (cost=0.40 rows=1) + -> Index lookup on alias2 using i1 (f2=alias1.f1) (cost=0.40 rows=2) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; diff --git a/mysql-test/r/select_none_bka.result-pq b/mysql-test/r/select_none_bka.result-pq new file mode 100644 index 000000000..491a4cdb9 --- /dev/null +++ b/mysql-test/r/select_none_bka.result-pq @@ -0,0 +1,5701 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL id4 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=9.27 rows=19) + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) (cost=0.40 rows=1) + -> Index lookup on alias2 using i1 (f2=alias1.f1) (cost=0.40 rows=2) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/select_none_bka_nobnl.result-pq b/mysql-test/r/select_none_bka_nobnl.result-pq new file mode 100644 index 000000000..b8548dafb --- /dev/null +++ b/mysql-test/r/select_none_bka_nobnl.result-pq @@ -0,0 +1,5701 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +drop table if exists t1,t2,t3,t4,t11; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 0.09 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 0.09 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%" order by fld3; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr, fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct companynr, fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr ,fld3 order by companynr, fld3 limit 100,10; +companynr fld3 repeat("a",length(fld3)) count(*) +29 chancellor aaaaaaaaaa 1 +29 Chippewa aaaaaaaa 1 +29 circumference aaaaaaaaaaaaa 1 +29 circus aaaaaa 1 +29 cited aaaaa 1 +29 Colombo aaaaaaa 1 +29 congresswoman aaaaaaaaaaaaa 1 +29 contrition aaaaaaaaaa 1 +29 corny aaaaa 1 +29 cultivation aaaaaaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 41736 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL 41736 100.00 Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL 1 100.00 NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period 4173 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const 1 100.00 NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10 order by fld3; +fld3 period +abates 9410 +Abraham 9410 +abrogating 9410 +accessed 9410 +Aden 9410 +admiring 9410 +admonishing 9410 +Adolph 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +Aldrich 9410 +alike 9410 +Alison 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +Anatole 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +Antarctica 9410 +Antares 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +Arabia 9410 +arriving 9410 +Artemia 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +Augustine 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +Baird 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +Beebe 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +Butterfield 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +Cassites 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +CERN 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +Chicana 9410 +chillingly 9410 +Chippewa 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +Clayton 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +Conley 9410 +Connally 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +Crays 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +DiMaggio 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +Dutchman 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +Eulerian 9410 +Evanston 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +Everhart 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +Fenton 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +Fitzpatrick 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +Galatean 9410 +galling 9410 +Gandhian 9410 +Ganymede 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +Goldstine 9410 +Gothicism 9410 +governing 9410 +gradually 9410 +Graves 9410 +grazing 9410 +Greenberg 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +Gurkha 9410 +handgun 9410 +handy 9410 +Hawaii 9410 +Hegelian 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +Hornblower 9410 +hostess 9410 +Huffman 9410 +humanness 9410 +humiliation 9410 +humility 9410 +Hunter 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +Joplin 9410 +journalizing 9410 +Judas 9410 +juveniles 9410 +Kane 9410 +kanji 9410 +Kantian 9410 +Kevin 9410 +kingdom 9410 +Kinsey 9410 +kiting 9410 +Kline 9410 +labeled 9410 +languages 9410 +Lars 9410 +laterally 9410 +Latinizes 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +Lillian 9410 +linear 9410 +lists 9410 +lithograph 9410 +Lizzy 9410 +lore 9410 +luckily 9410 +Majorca 9410 +males 9410 +Manhattanize 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +McGovern 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +Melinda 9410 +Merritt 9410 +metaphysically 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +Nabisco 9410 +navies 9410 +navigate 9410 +Nazis 9410 +neat 9410 +neonatal 9410 +nested 9410 +Newtonian 9410 +noncritical 9410 +normalizes 9410 +Norwalk 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +Pandora 9410 +parametrized 9410 +parenthood 9410 +Parsifal 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +Peruvian 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +Punjab 9410 +Pyle 9410 +quagmire 9410 +quitter 9410 +Quixotism 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +Romano 9410 +Romans 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +Sabine 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +Sault 9410 +save 9410 +sawtooth 9410 +Saxony 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +Selfridge 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +Shanghais 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +Simla 9410 +Simon 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +Stalin 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +Steinberg 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +Taoism 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +Teresa 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +Tipperary 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +Weissmuller 9410 +western 9410 +whiteners 9410 +widens 9410 +Winsett 9410 +witchcraft 9410 +workers 9410 +Wotan 9410 +yelped 9410 +youthfulness 9410 +analyze table t2, t3; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 10.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL 1199 10.00 Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY,period PRIMARY 4 test.t2.fld1 1 20.04 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 37) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`) and (`test`.`t3`.`period` >= 1001) and (`test`.`t3`.`period` <= 1002)) order by `test`.`t2`.`fld3`,`test`.`t3`.`period`,`test`.`t3`.`price` +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) ENGINE=INNODB MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +ANALYZE TABLE t2, t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1200 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1200 10.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 33.33 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 33.33 Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 40.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL 11 100.00 Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL 12 100.00 Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +Lillian +label +labeled +labeled +landslide +laterally +leaflet +lewdly +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 9.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from +t3 where companynr = 37 group by companynr,t2nr order by companynr, t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; +companynr count(price) sum(price) min(price) max(price) avg(price) +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +37 12543 309394878010 5987435 39654943 24666736.6667 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +78 8362 414611089292 726498 98439034 49582766.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +0 +1 +3 +4 +5 +6 +7 +8 +9 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +0 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; +companynr count sum diff func +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +37 12543 309394878010 0.0000 464091 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +78 8362 414611089292 0.0000 652236 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; +companynr fld3 sum(price) +512 Micronesia 786542 +512 Miles 786542 +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1199 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1199 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +29 95 14473298 +34 70 17788966 +37 588 83602098 +41 52 12816335 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +29 +34 +37 +41 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL 1199 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +explain format=tree select min(fld1),max(fld1),count(*) from t2; +EXPLAIN +-> Count rows in t2 + +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain format=tree select min(fld1),max(fld1),count(*) from t2 where rand() > 0.5; +EXPLAIN +-> Aggregate: min(`min(fld1)`), max(`max(fld1)`), count(`count(*)`) + -> Parallel scan on + -> Aggregate: + -> Filter: (rand() > 0.5) (cost=123.65 rows=1199) + -> PQblock scan on t2 using fld1 (cost=123.65 rows=1199) + +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A 1171 NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +DO 1; +DO benchmark(100,1+1),1,1; +do default; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +do foobar; +ERROR 42S22: Unknown column 'foobar' in 'field list' +CREATE TABLE t1 ( +id mediumint(8) unsigned NOT NULL auto_increment, +pseudo varchar(35) NOT NULL default '', +PRIMARY KEY (id), +UNIQUE KEY pseudo (pseudo) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (pseudo) VALUES ('test'); +INSERT INTO t1 (pseudo) VALUES ('test1'); +SELECT 1 as rnd1 from t1 where rand() > 2; +rnd1 +DROP TABLE t1; +CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); +CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +ERROR HY000: Incorrect DATETIME value: 'wrong-date-value' +SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +gvid the_success the_fail the_size the_time +DROP TABLE t1,t2; +create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); +select wss_type from t1 where wss_type ='102935229216544106'; +wss_type +select wss_type from t1 where wss_type ='102935229216544105'; +wss_type +select wss_type from t1 where wss_type ='102935229216544104'; +wss_type +select wss_type from t1 where wss_type ='102935229216544093'; +wss_type +102935229216544093 +select wss_type from t1 where wss_type =102935229216544093; +wss_type +102935229216544093 +drop table t1; +select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +select @a; +@a +3 +select @b; +@b +aaaa +select @c; +@c +6.260 +create table t1 (a int not null auto_increment primary key); +insert into t1 values (); +insert into t1 values (); +insert into t1 values (); +select * from (t1 as t2 left join t1 as t3 using (a)), t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1, (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); +a a +1 1 +1 2 +1 3 +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); +a +1 +2 +3 +select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +1 NULL +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); +a +1 +2 +3 +select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; +a +1 +2 +3 +select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; +a a +1 2 +1 3 +2 2 +2 3 +3 2 +3 3 +NULL 1 +select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +2 2 +2 3 +3 1 +3 2 +3 3 +select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); +a +1 +2 +3 +select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; +a +1 +2 +3 +select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); +a +1 +2 +3 +select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; +a +1 +2 +3 +drop table t1; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=INNODB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table t1,t2; +create table t1 (id1 int NOT NULL); +create table t2 (id2 int NOT NULL); +create table t3 (id3 int NOT NULL); +create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); +insert into t1 values (1); +insert into t1 values (2); +insert into t2 values (1); +insert into t4 values (1,1); +explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ref id4 id4 4 test.t3.id3 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t4`.`id4` AS `id4`,`test`.`t4`.`id44` AS `id44` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`id2` = `test`.`t1`.`id1`)) left join `test`.`t3` on((`test`.`t3`.`id3` = `test`.`t1`.`id1`)) left join `test`.`t4` on((`test`.`t4`.`id4` = `test`.`t3`.`id3`)) where ((`test`.`t2`.`id2` = 1) or (`test`.`t4`.`id4` = 1)) +select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 +left join t4 on id3 = id4 where id2 = 1 or id4 = 1; +id1 id2 id3 id4 id44 +1 1 NULL NULL NULL +drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one\b'), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; +create table t1 (a integer, b integer, index(a), index(b)); +create table t2 (c integer, d integer, index(c), index(d)); +insert into t1 values (1,2), (2,2), (3,2), (4,2); +insert into t2 values (1,3), (2,3), (3,4), (4,4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select * from t1 left join t2 on a=c where d in (4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d in (4); +a b c d +3 2 3 4 +4 2 4 4 +explain select * from t1 left join t2 on a=c where d = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c,d d 5 const 2 100.00 Using where +2 SIMPLE t1 NULL ref a a 5 test.t2.c 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` = 4)) +select * from t1 left join t2 on a=c where d = 4; +a b c d +3 2 3 4 +4 2 4 4 +drop table t1, t2; +CREATE TABLE t1 ( +i int(11) NOT NULL default '0', +c char(10) NOT NULL default '', +PRIMARY KEY (i), +UNIQUE KEY c (c) +) ; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'a'); +INSERT INTO t1 VALUES (2,'b'); +INSERT INTO t1 VALUES (3,'c'); +EXPLAIN SELECT i FROM t1 WHERE i=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `i` from `test`.`t1` where true +DROP TABLE t1; +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` USE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref a a 23 test.t1.a 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +DROP TABLE t1, t2; +CREATE TABLE t1 ( city char(30) ) charset utf8mb4; +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); +SELECT * FROM t1 WHERE city='London'; +city +London +SELECT * FROM t1 WHERE city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where (`test`.`t1`.`city` = 'London') +SELECT * FROM t1 WHERE city='London' AND city='london'; +city +London +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`city` AS `city` from `test`.`t1` where ((`test`.`t1`.`city` = 'London') and (`test`.`t1`.`city` like '%london%')) +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +city +London +DROP TABLE t1; +create table t1 (a int(11) unsigned, b int(11) unsigned); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,0), (1,1), (4294967295,1); +select a-b from t1 order by 1; +a-b +0 +1 +4294967294 +select a-b , (a-b < 0) from t1 order by 1; +a-b (a-b < 0) +0 0 +1 0 +4294967294 0 +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +d (a-b >= 0) b +1 1 0 +0 1 1 +select cast((a - b) as unsigned) from t1 order by 1; +cast((a - b) as unsigned) +0 +1 +4294967294 +drop table t1; +create table t1 (a int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +select distinct all * from t1; +ERROR HY000: Incorrect usage of ALL and DISTINCT +drop table t1; +CREATE TABLE t1 ( +kunde_intern_id int(10) unsigned NOT NULL default '0', +kunde_id int(10) unsigned NOT NULL default '0', +FK_firma_id int(10) unsigned NOT NULL default '0', +aktuell enum('Ja','Nein') NOT NULL default 'Ja', +vorname varchar(128) NOT NULL default '', +nachname varchar(128) NOT NULL default '', +geloescht enum('Ja','Nein') NOT NULL default 'Nein', +firma varchar(128) NOT NULL default '' +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'), +(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX'); +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1 +WHERE +( +( +( '' != '' AND firma LIKE CONCAT('%', '', '%')) +OR +(vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND +'Vorname1' != '' AND 'xxxx' != '') +) +AND +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, +geloescht FROM t1 +WHERE +( +( +aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2 +) +AND +( +( '' != '' AND firma LIKE CONCAT('%', '', '%') ) +OR +( vorname LIKE CONCAT('%', 'Vorname1', '%') AND +nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND +'xxxx' != '') +) +) +; +kunde_id FK_firma_id aktuell vorname nachname geloescht +SELECT COUNT(*) FROM t1 WHERE +( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) +AND FK_firma_id = 2; +COUNT(*) +0 +drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; +CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t2` VALUES (0,'READ'); +CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t3` VALUES (1,'fs'); +select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0); +id name gid uid ident level +1 fs NULL NULL 0 READ +drop table t1,t2,t3; +CREATE TABLE t1 ( +acct_id int(11) NOT NULL default '0', +profile_id smallint(6) default NULL, +UNIQUE KEY t1$acct_id (acct_id), +KEY t1$profile_id (profile_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (132,17),(133,18); +CREATE TABLE t2 ( +profile_id smallint(6) default NULL, +queue_id int(11) default NULL, +seq int(11) default NULL, +KEY t2$queue_id (queue_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); +CREATE TABLE t3 ( +id int(11) NOT NULL default '0', +qtype int(11) default NULL, +seq int(11) default NULL, +warn_lvl int(11) default NULL, +crit_lvl int(11) default NULL, +rr1 tinyint(4) NOT NULL default '0', +rr2 int(11) default NULL, +default_queue tinyint(4) NOT NULL default '0', +KEY t3$qtype (qtype), +KEY t3$id (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), +(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE +(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND +(pq.queue_id = q.id) AND (q.rr1 <> 1); +COUNT(*) +4 +drop table t1,t2,t3; +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +f2 +1 +NULL +drop table t1,t2; +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain select * from t2 where a > -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index t2i t2i 2 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` is not null) +select * from t2 where a > -1; +a +0 +254 +255 +drop table t2; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +a b c +50 3 3 +INSERT INTO t1 +SELECT 50, 3, 3 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +found_rows() +0 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +SELECT * FROM t1; +a b c +50 3 3 +select count(*) from t1; +count(*) +1 +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select count(*) from t1 limit 2,3; +count(*) +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +count(*) +Warnings: +Warning 1287 SQL_CALC_FOUND_ROWS is deprecated and will be removed in a future release. Consider using two separate queries instead. +select found_rows(); +found_rows() +1 +Warnings: +Warning 1287 FOUND_ROWS() is deprecated and will be removed in a future release. Consider using COUNT(*) instead. +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +(SELECT a, b AS c FROM t1) ORDER BY c+1; +a c +(SELECT a, b AS c FROM t1) ORDER BY b+1; +a c +SELECT a, b AS c FROM t1 ORDER BY c+1; +a c +SELECT a, b AS c FROM t1 ORDER BY b+1; +a c +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int); +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1)); +f1 +select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL)); +f1 +insert into t1 values(1,1),(2,null); +insert into t2 values(2); +select * from t1,t2 where f1=f3 and (f1,f2) = (2,null); +f1 f2 f3 +select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null); +f1 f2 f3 +2 NULL 2 +drop table t1,t2; +create table t1 (f1 int not null auto_increment primary key, f2 varchar(10)); +create table t11 like t1; +insert into t1 values(1,""),(2,""); +analyze table t1, t11; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t11 analyze status OK +show table status like 't1%'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic 2 8192 X X X X X X X X X NULL +t11 InnoDB 10 Dynamic 0 0 X X X X X X X X X NULL +select 123 as a from t1 where f1 is null; +a +drop table t1,t11; +CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) ); +INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4); +CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT ); +INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3); +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c; +a b c d +1 10 4 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOIN +t1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c; +a b c d +1 10 2 +1 11 2 +1 2 1 1 +1 2 2 1 +1 2 3 1 +SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1 +WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; +a b c d +1 2 1 1 +1 2 2 1 +1 2 3 1 +DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; +create table t1 (f1 int,f2 int); +insert into t1 values(1,1); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t2 values(1,1); +select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2)); +f1 f2 +1 1 +drop table t1,t2; +CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c)); +insert into t1 values (1,0,0),(2,0,0); +CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a)); +insert into t2 values (1,'',''), (2,'',''); +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b)); +insert into t3 values (1,1),(1,2); +explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 +where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and +t2.b like '%%' order by t2.b limit 0,1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref b,c b 5 const 1 100.00 Using temporary; Using filesort +1 SIMPLE t3 NULL index PRIMARY,a,b a 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 2 50.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select straight_join distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`b` = 556476786) and ((`test`.`t2`.`a` = `test`.`t1`.`c`) or ((`test`.`t2`.`a` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`c`))) and (`test`.`t2`.`b` like '%%')) order by `test`.`t2`.`b` limit 0,1 +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int, INDEX idx(a)); +INSERT INTO t1 VALUES (2), (3), (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` IGNORE INDEX (`idx`) +EXPLAIN SELECT * FROM t1 IGNORE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +EXPLAIN SELECT * FROM t1 FORCE INDEX (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,1), (2,1), (4,10); +CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); +INSERT INTO t2 VALUES (1,NULL), (2,10); +ALTER TABLE t1 ENABLE KEYS; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index b b 5 NULL 2 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) or (`test`.`t2`.`b` is null)) +SELECT STRAIGHT_JOIN * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; +a b a b +1 NULL 1 1 +1 NULL 2 1 +1 NULL 4 10 +2 10 4 10 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (key1 double default NULL, UNIQUE KEY key1 (key1)); +CREATE TABLE t2 (key2 double default NULL, UNIQUE KEY key2 (key2)); +INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941); +INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +explain select max(key1) from t1 where key1 <= 0.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where (`test`.`t1`.`key1` <= 0.6158) +explain select max(key2) from t2 where key2 <= 1.6158; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t2`.`key2`) AS `max(key2)` from `test`.`t2` where (`test`.`t2`.`key2` <= 1.6158) +explain select min(key1) from t1 where key1 >= 0.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where (`test`.`t1`.`key1` >= 0.3762) +explain select min(key2) from t2 where key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t2` where (`test`.`t2`.`key2` >= 1.3762) +explain select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)`,min(`test`.`t2`.`key2`) AS `min(key2)` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`key1` <= 0.6158) and (`test`.`t2`.`key2` >= 1.3762)) +explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range key1 key1 9 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`key1`) AS `max(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` <= 0.6158) and ((rand() + 0.5) >= 0.5)) +explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index key1 key1 9 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`key1`) AS `min(key1)` from `test`.`t1` where ((`test`.`t1`.`key1` >= 0.3762) and ((rand() + 0.5) >= 0.5)) +select max(key1) from t1 where key1 <= 0.6158; +max(key1) +0.6158 +select max(key2) from t2 where key2 <= 1.6158; +max(key2) +1.6158 +select min(key1) from t1 where key1 >= 0.3762; +min(key1) +0.3762 +select min(key2) from t2 where key2 >= 1.3762; +min(key2) +1.3762 +select max(key1), min(key2) from t1, t2 +where key1 <= 0.6158 and key2 >= 1.3762; +max(key1) min(key2) +0.6158 1.3762 +select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5; +max(key1) +0.6158 +select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; +min(key1) +0.3762 +DROP TABLE t1,t2; +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') +1 1 1 1 +DROP TABLE t1; +create table t1(a bigint unsigned, b bigint); +insert ignore into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'b' at row 2 +Warning 1264 Out of range value for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +CREATE TABLE t1 (c0 int); +CREATE TABLE t2 (c0 int); +INSERT INTO t1 VALUES(@@connect_timeout); +INSERT INTO t2 VALUES(@@connect_timeout); +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout); +c0 c0 +X X +DROP TABLE t1, t2; +End of 4.1 tests +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND +(F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); +K2C4 K4N4 F2I4 +WART 0200 1 +SELECT K2C4, K4N4, F2I4 FROM t1 +WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); +K2C4 K4N4 F2I4 +WART 0100 1 +WART 0200 1 +WART 0300 3 +DROP TABLE t1; +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +a +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +a +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +a a a +drop table t1,t2; +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +min(s1) +Wall +Wall +drop table t1; +create table t1 (s1 int); +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +avg(distinct s1) +0.0000 +0.0000 +drop table t1; +create table t1 (s1 int); +insert into t1 values (null),(1); +select avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +1.0000 +select distinct avg(s1) as x from t1 group by s1 with rollup; +x +NULL +1.0000 +drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` straight_join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +DROP TABLE t1,t2; +select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; +x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0 +16 16 2 2 +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +f1 f2 f3 f4 + 2 2 2 one + 2 2 2 two +drop table t1,t2; +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +empnum name grp +1 bob 1 +drop table t1,t2; +drop view v1; +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +pk +drop table t1,t2; +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +s1 s2 s3 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'x' +drop table t1; +drop view v1; +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; +select * from t1 natural left join t2; +a1 a2 +1 1 +1 2 +2 1 +2 2 +select * from t1 natural right join t2; +a2 a1 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural left join t2; +c a2 +1 1 +1 2 +2 1 +2 2 +select * from v2 natural right join t2; +a2 c +1 1 +1 2 +2 1 +2 2 +drop table t1, t2; +drop view v2; +create table t1 (a int(10), t1_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (b int(10), t2_val int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t3 (a int(10), b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +CAST(IFNULL(NULL, NULL) AS DECIMAL) +NULL +SELECT ABS(IFNULL(NULL, NULL)); +ABS(IFNULL(NULL, NULL)) +NULL +SELECT IFNULL(NULL, NULL); +IFNULL(NULL, NULL) +NULL +SET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE=''; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode +CREATE TABLE BUG_12595(a varchar(100)) charset latin1; +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +a +hakan% +hakank +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE ''; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SET @@SQL_MODE='NO_BACKSLASH_ESCAPES'; +SHOW LOCAL VARIABLES LIKE 'SQL_MODE'; +Variable_name Value +sql_mode NO_BACKSLASH_ESCAPES +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%'; +a +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +a +hakan% +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\'; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE ''; +ERROR HY000: Incorrect arguments to ESCAPE +SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|'; +a +ha%an +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n'; +ERROR HY000: Incorrect arguments to ESCAPE +SET @@SQL_MODE=@OLD_SQL_MODE12595; +DROP TABLE BUG_12595; +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +a +b +c +select * from t1 natural join t2 where a = 'b'; +a +b +drop table t1, t2; +CREATE TABLE t1 (`id` TINYINT); +CREATE TABLE t2 (`id` TINYINT); +CREATE TABLE t3 (`id` TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); +ERROR 23000: Column 'id' in from clause is ambiguous +drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (a int(10),b int(10)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 +drop table t1, t2; +create table t1 (a int, c int); +create table t2 (b int); +create table t3 (b int, a int); +create table t4 (c int); +insert into t1 values (1,1); +insert into t2 values (1); +insert into t3 values (1,1); +insert into t4 values (1); +select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +a c b b a +1 1 1 1 1 +select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c); +a c b b a c +1 1 1 1 1 1 +select * from t1 join t2 join t4 using (c); +c a b +1 1 1 +drop table t1, t2, t3, t4; +create table t1(x int, y int); +create table t2(x int, y int); +create table t3(x int, primary key(x)); +insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6); +insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6); +insert into t3 values (1), (2), (3), (4), (5); +select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y; +x x +1 1 +2 1 +3 1 +3 2 +3 3 +4 3 +4 4 +4 5 +drop table t1,t2,t3; +create table t1 (id char(16) not null default '', primary key (id)); +insert into t1 values ('100'),('101'),('102'); +create table t2 (id char(16) default null); +insert into t2 values (1); +create view v1 as select t1.id from t1; +create view v2 as select t2.id from t2; +create view v3 as select (t1.id+2) as id from t1 natural left join t2; +select t1.id from t1 left join v2 using (id); +id +100 +101 +102 +select t1.id from v2 right join t1 using (id); +id +100 +101 +102 +select t1.id from t1 left join v3 using (id); +id +100 +101 +102 +select * from t1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join t1 using (id); +id +100 +101 +102 +select * from t1 left join v3 using (id); +id +100 +101 +102 +select v1.id from v1 left join v2 using (id); +id +100 +101 +102 +select v1.id from v2 right join v1 using (id); +id +100 +101 +102 +select v1.id from v1 left join v3 using (id); +id +100 +101 +102 +select * from v1 left join v2 using (id); +id +100 +101 +102 +select * from v2 right join v1 using (id); +id +100 +101 +102 +select * from v1 left join v3 using (id); +id +100 +101 +102 +drop table t1, t2; +drop view v1, v2, v3; +create table t1 (id int(11) not null default '0'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (123),(191),(192); +create table t2 (id char(16) character set utf8 not null); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t2 values ('58013'),('58014'),('58015'),('58016'); +create table t3 (a_id int(11) not null, b_id char(16) character set utf8); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013'); +select count(*) +from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +select count(*) +from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id; +count(*) +6 +drop table t1,t2,t3; +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +select * from t1 join t2 join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 left join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 right join t3 on (t1.a=t3.c); +a b c +select * from t1 join t2 straight_join t3 on (t1.a=t3.c); +a b c +drop table t1, t2 ,t3; +create table t1(f1 int, f2 date); +insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'), +(4,'2005-10-01'),(5,'2005-12-30'); +select * from t1 where f2 >= 0 order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +select * from t1 where f2 >= '0000-00-00' order by f2; +ERROR HY000: Incorrect DATE value: '0000-00-00' +select * from t1 where f2 >= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 >= '2005-09-3a' order by f2; +f1 f2 +3 2005-09-30 +4 2005-10-01 +5 2005-12-30 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +select * from t1 where f2 <= '2005-09-31' order by f2; +ERROR HY000: Incorrect DATE value: '2005-09-31' +select * from t1 where f2 <= '2005-09-3a' order by f2; +f1 f2 +1 2005-01-01 +2 2005-09-01 +Warnings: +Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1 +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (1, 30), (2, 20), (3, 10); +create algorithm=merge view v1 as select f1, f2 from t1; +create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1; +create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1; +select t1.f1 as x1, f1 from t1 order by t1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v1.f1 as x1, f1 from v1 order by v1.f1; +x1 f1 +1 1 +2 2 +3 3 +select v2.f1 as x1, f1 from v2 order by v2.f1; +x1 f1 +10 10 +20 20 +30 30 +select v3.f1 as x1, f1 from v3 order by v3.f1; +x1 f1 +10 10 +20 20 +30 30 +select f1, f2, v1.f1 as x1 from v1 order by v1.f1; +f1 f2 x1 +1 30 1 +2 20 2 +3 10 3 +select f1, f2, v2.f1 as x1 from v2 order by v2.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +select f1, f2, v3.f1 as x1 from v3 order by v3.f1; +f1 f2 x1 +10 3 10 +20 2 20 +30 1 30 +drop table t1; +drop view v1, v2, v3; +CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a)); +CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a)); +CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32), +PRIMARY KEY(key_a,key_b)); +INSERT INTO t1 VALUES (0,''); +INSERT INTO t1 VALUES (1,'i'); +INSERT INTO t1 VALUES (2,'j'); +INSERT INTO t1 VALUES (3,'k'); +INSERT INTO t2 VALUES (1,'r'); +INSERT INTO t2 VALUES (2,'s'); +INSERT INTO t2 VALUES (3,'t'); +INSERT INTO t3 VALUES (1,5,'x'); +INSERT INTO t3 VALUES (1,6,'y'); +INSERT INTO t3 VALUES (2,5,'xx'); +INSERT INTO t3 VALUES (2,6,'yy'); +INSERT INTO t3 VALUES (2,7,'zz'); +INSERT INTO t3 VALUES (3,5,'xxx'); +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +key_a foo +2 xx +EXPLAIN SELECT t2.key_a,foo +FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a +INNER JOIN t3 ON t1.key_a = t3.key_a +WHERE t2.key_a=2 and key_b=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE t3 NULL const PRIMARY PRIMARY 8 const,const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `key_a`,'xx' AS `foo` from `test`.`t1` join `test`.`t2` join `test`.`t3` where true +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +insert into t1 values(1),(2); +create table t2 (f2 int, f3 int, key(f2)); +insert into t2 values(1,1),(2,2); +create table t3 (f4 int not null); +insert into t3 values (2),(2),(2); +select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1; +f1 count +1 0 +2 3 +drop table t1,t2,t3; +create table t1 (f1 int unique); +create table t2 (f2 int unique); +create table t3 (f3 int unique); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +insert into t3 values(1),(NULL); +select * from t3 where f3 is null; +f3 +NULL +select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1; +f2 +1 +drop table t1,t2,t3; +create table t1(f1 char, f2 char not null); +insert into t1 values(null,'a'); +create table t2 (f2 char not null); +insert into t2 values('b'); +select * from t1 left join t2 on f1=t2.f2 where t1.f2='a'; +f1 f2 f2 +NULL a NULL +drop table t1,t2; +select * from (select * left join t on f1=f2) tt; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join t on f1=f2) tt' at line 1 +CREATE TABLE t1 (sku int PRIMARY KEY, pr int); +CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255)); +INSERT INTO t1 VALUES +(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10); +INSERT INTO t2 VALUES +(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'), +(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh'); +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +sku sppr name sku pr +20 10 bbb 10 10 +20 10 bbb 20 10 +EXPLAIN +SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr +FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '20' AS `sku`,'10' AS `sppr`,'bbb' AS `name`,`test`.`t1`.`sku` AS `sku`,`test`.`t1`.`pr` AS `pr` from `test`.`t2` join `test`.`t1` where (((`test`.`t1`.`sku` = 20) or (`test`.`t1`.`sku` = '10'))) +DROP TABLE t1,t2; +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); +INSERT t1 SET i = 0; +UPDATE t1 SET i = -1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = CAST(i - 1 AS SIGNED); +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +UPDATE t1 SET i = i - 1; +Warnings: +Warning 1264 Out of range value for column 'i' at row 1 +SELECT * FROM t1; +i +0 +DROP TABLE t1; +SET SQL_MODE=default; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, e int, primary key(a,b,c)); +# The "ANALYZE TABLE"-command that is executed further down will get +# different results depending on the order of rows in table t2. Since the +# INSERT INTO ... SELECT may be executed using different execution plans, +# we've added ORDER BY to ensure that we rows has the same order every +# time. If not, the estimated number of rows for t2 (alias 'a') in the +# EXPLAIN may change on different platforms. Note that both table t1 and +# t2 may be MYISAM, since many of the test files that includes this file +# forces MYISAM as the default storage engine. +insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C +ORDER BY A.a, B.a, C.a; +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +select 'In next EXPLAIN, B.rows must be exactly 10:' Z; +Z +In next EXPLAIN, B.rows must be exactly 10: +explain select * from t2 a, t2 b where a.a=5 and a.b=5 and a.c<5 +and b.a=5 and b.b=a.e and (b.b =1 or b.b = 3 or b.b=5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 27.10 Parallel execute (1 workers) +2 SIMPLE a NULL range PRIMARY PRIMARY 12 NULL 5 27.10 Using where +2 SIMPLE b NULL ref PRIMARY PRIMARY 8 const,test.a.e 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`a` AS `a`,`test`.`a`.`b` AS `b`,`test`.`a`.`c` AS `c`,`test`.`a`.`e` AS `e`,`test`.`b`.`a` AS `a`,`test`.`b`.`b` AS `b`,`test`.`b`.`c` AS `c`,`test`.`b`.`e` AS `e` from `test`.`t2` `a` join `test`.`t2` `b` where ((`test`.`b`.`b` = `test`.`a`.`e`) and (`test`.`b`.`a` = 5) and (`test`.`a`.`b` = 5) and (`test`.`a`.`a` = 5) and (`test`.`a`.`c` < 5) and ((`test`.`a`.`e` = 1) or (`test`.`a`.`e` = 3) or (`test`.`a`.`e` = 5))) +drop table t1, t2; +CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b)); +INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2), +(3,1), (5,1), (8,9), (2,2), (0,9); +CREATE TABLE t2 (c int, d int, f int, INDEX(c,f)); +INSERT INTO t2 VALUES +(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1), +(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1), +(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 5 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6)) +EXPLAIN +SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 9 NULL 3 90.00 Using where; Using index +2 SIMPLE t2 NULL ref c c 5 test.t1.a 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t2`.`f` AS `f` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t1`.`b` between 4 and 6) and (`test`.`t1`.`a` > 0)) +DROP TABLE t1, t2; +create table t1 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c bit not null +); +create table t2 ( +a int unsigned not null auto_increment primary key, +b bit not null, +c int unsigned not null, +d varchar(50) +); +insert into t1 (b,c) values (0,1), (0,1); +insert into t2 (b,c) values (0,1); +select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.d +from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1 +where t1.b <> 1 order by t1.a; +a t1.b + 0 t1.c + 0 a t2.b + 0 c d +1 0 1 1 0 1 NULL +2 0 1 NULL NULL NULL NULL +drop table t1,t2; +SELECT 0.9888889889 * 1.011111411911; +0.9888889889 * 1.011111411911 +0.9998769417899202067879 +prepare stmt from 'select 1 as " a "'; +Warnings: +Warning 1466 Leading spaces are removed from name ' a ' +execute stmt; +a +1 +CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +CREATE TABLE t2 (c int NOT NULL, INDEX idx(c)); +INSERT INTO t2 VALUES +(1), (1), (1), (1), (1), (1), (1), (1), +(2), (2), (2), (2), +(3), (3), +(4); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '1' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '1')) +EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL ref idx idx 4 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '4' AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = '4')) +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int); +INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2); +CREATE TABLE t2 (b int, c INT, INDEX idx1(b)); +INSERT INTO t2 VALUES (2,1), (3,2); +CREATE TABLE t3 (d int, e int, INDEX idx1(d)); +INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50); +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL const idx1 NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t3 NULL ref idx1 idx1 5 const 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '2' AS `id`,NULL AS `a`,NULL AS `b`,NULL AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL, NULL)) join `test`.`t3` where (`test`.`t3`.`d` = 2) +SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id +WHERE t1.id=2; +id a b c d e +2 NULL NULL NULL 2 10 +2 NULL NULL NULL 2 20 +2 NULL NULL NULL 2 40 +2 NULL NULL NULL 2 50 +DROP TABLE t1,t2,t3; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)); +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16)) charset utf8mb4; +CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10)) charset utf8mb4; +INSERT INTO t1 VALUES +('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), +('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff'); +INSERT INTO t2 VALUES +('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'), +('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'), +('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'), +('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk < 'c' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` < 'c')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` between 'a' and 'b')) +EXPLAIN SELECT t2.* +FROM t1 JOIN t2 ON t2.fk=t1.pk +WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 42 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 66 test.t1.fk 1 5.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`fk` AS `fk` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`fk` = `test`.`t1`.`pk`) and (`test`.`t2`.`pk` = `test`.`t1`.`fk`) and (`test`.`t1`.`pk` in ('a','b'))) +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a)) charset utf8mb4; +CREATE TABLE t2 (a int, b varchar(20) NOT NULL, +PRIMARY KEY (a), UNIQUE KEY (b)) charset utf8mb4; +INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c'); +INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c'); +EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t2 NULL const b b 82 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '3' AS `a` from `test`.`t1` left join `test`.`t2` on(multiple equal('c', 'c')) where true +DROP TABLE t1,t2; +CREATE TABLE t1(id int PRIMARY KEY, b int, e int); +CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a)); +CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c)); +INSERT INTO t1 VALUES +(1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79), +(6,63,67), (5,55,58), (3,38,39), (8,81,89); +INSERT INTO t2 VALUES +(21,210), (41,410), (82,820), (83,830), (84,840), +(65,650), (51,510), (37,370), (94,940), (76,760), +(22,220), (33,330), (40,400), (95,950), (38,380), +(67,670), (88,880), (57,570), (96,960), (97,970); +INSERT INTO t3 VALUES +(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'), +(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'), +(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'), +(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 4 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND +t3.a=t2.a AND t3.c IN ('bb','ee') ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 4 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`i` between '81' and '89') and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si si 5 NULL 2 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` FORCE INDEX (`si`) join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +EXPLAIN +SELECT t3.a FROM t1,t2,t3 +WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND +t3.c IN ('bb','ee'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t2 NULL range si,ai si 5 NULL 2 100.00 Using where +2 SIMPLE t3 NULL eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 30.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`i` = '81') or (`test`.`t2`.`i` = '89')) and (`test`.`t3`.`c` in ('bb','ee'))) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +f1 f2 f3 f4 f5 f6 checked_out f11 +1 1 1 0 0 0 0 NULL +DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a int); +INSERT into t1 values (1), (2), (3); +SELECT * FROM t1 LIMIT 2, -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1 +DROP TABLE t1; +set optimizer_switch='index_merge=off'; +CREATE TABLE t1 ( +ID_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID_with_null), +INDEX idx2 (ID_better) +); +INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL; +COUNT(*) +128 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 98.46 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 98.46 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID_with_null` AS `ID_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID_with_null` is null)) +DROP TABLE t1; +CREATE TABLE t1 ( +ID1_with_null int NULL, +ID2_with_null int NULL, +ID_better int NOT NULL, +INDEX idx1 (ID1_with_null, ID2_with_null), +INDEX idx2 (ID_better) +) ; +INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3), +(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3); +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL; +INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL; +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL; +COUNT(*) +24 +SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL; +COUNT(*) +192 +SELECT COUNT(*) FROM t1 WHERE ID_better=1; +COUNT(*) +2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and ((`test`.`t1`.`ID2_with_null` = 3) is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +DROP INDEX idx1 ON t1; +CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID2_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 9.92 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 9.92 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID1_with_null` = 3) and (`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 79.34 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 79.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and (`test`.`t1`.`ID2_with_null` is null)) +EXPLAIN SELECT * FROM t1 +WHERE ID_better=1 AND ID1_with_null IS NULL AND +(ID2_with_null=1 OR ID2_with_null=2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 2.50 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx1,idx2 idx2 4 const 2 2.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`ID1_with_null` AS `ID1_with_null`,`test`.`t1`.`ID2_with_null` AS `ID2_with_null`,`test`.`t1`.`ID_better` AS `ID_better` from `test`.`t1` where ((`test`.`t1`.`ID_better` = 1) and (`test`.`t1`.`ID1_with_null` is null) and ((`test`.`t1`.`ID2_with_null` = 1) or (`test`.`t1`.`ID2_with_null` = 2))) +DROP TABLE t1; +set optimizer_switch='index_merge=on'; +CREATE TABLE t1 (a INT, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY ts(ts)); +INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a)); +INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00"); +INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SIMPLE t1 NULL range ts ts 4 NULL 2 50.00 Using where +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`ts` AS `ts`,'30' AS `a`,'2006-01-01 00:00:00' AS `dt1`,'2999-12-31 00:00:00' AS `dt2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 30) and (`test`.`t1`.`ts` between '2006-01-01 00:00:00' and '2999-12-31 00:00:00') and (`test`.`t1`.`ts` between '2006-01-01' and '2006-12-31')) +SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 +AND t1.ts BETWEEN t2.dt1 AND t2.dt2 +AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; +a ts a dt1 dt2 +30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1 +DROP TABLE t1,t2; +create table t1 (a bigint unsigned); +insert into t1 values +(if(1, 9223372036854775808, 1)), +(case when 1 then 9223372036854775808 else 1 end), +(coalesce(9223372036854775808, 1)); +select * from t1; +a +9223372036854775808 +9223372036854775808 +9223372036854775808 +drop table t1; +create table t1 charset utf8mb4 select +if(1, 9223372036854775808, 1) i, +case when 1 then 9223372036854775808 else 1 end c, +coalesce(9223372036854775808, 1) co; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` decimal(19,0) NOT NULL DEFAULT '0', + `c` decimal(19,0) NOT NULL DEFAULT '0', + `co` decimal(19,0) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +select +if(1, cast(1111111111111111111 as unsigned), 1) i, +case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, +coalesce(cast(1111111111111111111 as unsigned), 1) co; +i c co +1111111111111111111 1111111111111111111 1111111111111111111 +CREATE TABLE t1 (name varchar(255)) charset latin1; +CREATE TABLE t2 (name varchar(255), n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (name text) charset latin1; +CREATE TABLE t2 (name text, n int, KEY (name(3))) charset latin1; +INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa'); +INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3); +INSERT INTO t2 VALUES (concat('cc ', 0x06), 4); +INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * FROM t2; +name n +bb 1 +aa 2 +cc 3 +cc  4 +cc 5 +bb 6 +cc 7 +SELECT * FROM t2 ORDER BY name; +name n +aa 2 +bb 1 +bb 6 +cc  4 +cc 3 +cc 5 +cc 7 +SELECT name, LENGTH(name), n FROM t2 ORDER BY name; +name LENGTH(name) n +aa 2 2 +bb 2 1 +bb 3 6 +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref name name 6 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` = 'cc ') +SELECT name, LENGTH(name), n FROM t2 WHERE name='cc '; +name LENGTH(name) n +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%'; +name LENGTH(name) n +cc 5 3 +cc  4 4 +cc 2 5 +cc 3 7 +EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range name name 6 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name`,length(`test`.`t2`.`name`) AS `LENGTH(name)`,`test`.`t2`.`n` AS `n` from `test`.`t2` where (`test`.`t2`.`name` like 'cc%') order by `test`.`t2`.`name` +SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name; +name LENGTH(name) n +cc  4 4 +cc 5 3 +cc 2 5 +cc 3 7 +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ref name name 6 test.t1.name 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`name` AS `name`,`test`.`t2`.`name` AS `name`,`test`.`t2`.`n` AS `n` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`name` = `test`.`t1`.`name`)) where true +SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; +name name n +aa aa 2 +aa aa 2 +bb bb 1 +bb bb 6 +cc cc 5 +cc cc 7 +cc cc 3 +ccc NULL NULL +DROP TABLE t1,t2; +CREATE TABLE t1 ( +access_id int NOT NULL default '0', +name varchar(20) default NULL, +`rank` int NOT NULL default '0', +KEY idx (access_id) +); +CREATE TABLE t2 ( +faq_group_id int NOT NULL default '0', +faq_id int NOT NULL default '0', +access_id int default NULL, +UNIQUE KEY idx1 (faq_id), +KEY idx2 (faq_group_id,faq_id) +); +INSERT INTO t1 VALUES +(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4); +INSERT INTO t2 VALUES +(261,265,1),(490,494,1); +SELECT t2.faq_id +FROM t1 INNER JOIN t2 IGNORE INDEX (idx1) +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +SELECT t2.faq_id +FROM t1 INNER JOIN t2 +ON (t1.access_id = t2.access_id) +LEFT JOIN t2 t +ON (t.faq_group_id = t2.faq_group_id AND +find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4')) +WHERE +t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265); +faq_id +265 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, KEY inx (b,a)); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 +ON ( f1.b=f2.b AND f1.a NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE f1 NULL index inx inx 10 NULL 7 100.00 Using where; Using index +2 SIMPLE f2 NULL ref inx inx 5 test.f1.b 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` `f1` join `test`.`t1` `f2` where ((`test`.`f2`.`b` = `test`.`f1`.`b`) and (`test`.`f1`.`b` not in (100,2232,3343,51111)) and (`test`.`f1`.`a` < `test`.`f2`.`a`)) +DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))) > 0; +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; +CREATE TABLE t1 ( +c1 int(11) NOT NULL AUTO_INCREMENT, +c2 varchar(1000) DEFAULT NULL, +c3 bigint(20) DEFAULT NULL, +c4 bigint(20) DEFAULT NULL, +PRIMARY KEY (c1) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN +SELECT join_2.c1 +FROM +t1 AS join_0, +t1 AS join_1, +t1 AS join_2, +t1 AS join_3, +t1 AS join_4, +t1 AS join_5, +t1 AS join_6, +t1 AS join_7 +WHERE +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +OR +join_0.c2 < '?' AND +join_1.c2 < '?' AND +join_2.c2 > '?' AND +join_2.c2 < '!' AND +join_3.c2 > '?' AND +join_4.c2 = '?' AND +join_5.c2 <> '?' AND +join_6.c2 <> '?' AND +join_7.c2 >= '?' AND +join_0.c1=join_1.c1 AND +join_1.c1=join_2.c1 AND +join_2.c1=join_3.c1 AND +join_3.c1=join_4.c1 AND +join_4.c1=join_5.c1 AND +join_5.c1=join_6.c1 AND +join_6.c1=join_7.c1 +GROUP BY +join_3.c1, +join_2.c1, +join_7.c1, +join_1.c1, +join_0.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL # 1 100.00 # +2 SIMPLE join_0 NULL ALL PRIMARY NULL NULL # 1 100.00 # +2 SIMPLE join_1 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_2 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_3 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_4 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_5 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_6 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +2 SIMPLE join_7 NULL eq_ref PRIMARY PRIMARY 4 # 1 100.00 # +Warnings: +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +SHOW WARNINGS; +Level Code Message +Note 1003 /* select#1 */ select `test`.`join_2`.`c1` AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where (((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`)) or ((`test`.`join_1`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_2`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_3`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_5`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_6`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_7`.`c1` = `test`.`join_0`.`c1`) and (`test`.`join_4`.`c2` = '?') and (`test`.`join_0`.`c2` < '?') and (`test`.`join_1`.`c2` < '?') and (`test`.`join_2`.`c2` > '?') and (`test`.`join_2`.`c2` < '!') and (`test`.`join_3`.`c2` > '?') and (`test`.`join_5`.`c2` <> '?') and (`test`.`join_6`.`c2` <> '?') and (`test`.`join_7`.`c2` >= '?'))) group by `test`.`join_3`.`c1`,`test`.`join_2`.`c1`,`test`.`join_7`.`c1`,`test`.`join_1`.`c1`,`test`.`join_0`.`c1` +DROP TABLE t1; +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` `; + +1 +Warnings: +Warning 1474 Name ' ' has become '' +SELECT 1 AS ` x`; +x +1 +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +CREATE VIEW v1 AS SELECT 1 AS ``; +ERROR 42000: Incorrect column name '' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +ERROR 42000: Incorrect column name ' ' +CREATE VIEW v1 AS SELECT 1 AS ` x`; +Warnings: +Warning 1466 Leading spaces are removed from name ' x' +SELECT `x` FROM v1; +x +1 +ALTER VIEW v1 AS SELECT 1 AS ` `; +ERROR 42000: Incorrect column name ' ' +DROP VIEW v1; +select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT'; +str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' + and '2007/10/20 00:00:00 GMT' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT' +Warning 1292 Truncated incorrect date value: '2007/10/20 00:00:00 GMT' +select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'; +str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6' +select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'; +ERROR HY000: Incorrect DATE value: '2007/10/2000:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6' +select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'; +str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6' +select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6' +0 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6' +select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'; +str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56' +1 +select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00' +0 +select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'; +str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00' +1 +Warnings: +Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34' +select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34:00'; +ERROR HY000: Incorrect DATETIME value: '2007-02-30 12:34:00' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' + and '2007/10/20 00:00:00' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=TRADITIONAL; +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'; +ERROR HY000: Incorrect DATETIME value: '2007-10-00 12:34' +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date +select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' + and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +set SQL_MODE=DEFAULT; +select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'; +str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date +select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'; +str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +Warnings: +Warning 1411 Incorrect datetime value: '' for function str_to_date +select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'; +str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34' +NULL +select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''; +ERROR HY000: Incorrect DATETIME value: '' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('1','%Y-%m-%d') = '1'; +ERROR HY000: Incorrect DATE value: '1' +select str_to_date('','%Y-%m-%d') = ''; +ERROR HY000: Incorrect DATE value: '' +select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL +0 +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00' +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '2000-00-00' +select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL; +str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL +0 +CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, +c22 INT DEFAULT NULL, +KEY(c21, c22)); +CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, +c32 INT DEFAULT NULL, +c33 INT NOT NULL, +c34 INT UNSIGNED DEFAULT 0, +KEY (c33, c34, c32)); +INSERT INTO t1 values (),(),(),(),(); +INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b; +INSERT INTO t3 VALUES (1, 1, 1, 0), +(2, 2, 0, 0), +(3, 3, 1, 0), +(4, 4, 0, 0), +(5, 5, 1, 0); +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32; +c32 +1 +1 +3 +3 +5 +5 +SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND +t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND +t3.c33 = 1 AND t2.c22 in (1, 3) +ORDER BY c32 DESC; +c32 +5 +5 +3 +3 +1 +1 +DROP TABLE t1, t2, t3; + +# +# Bug#30736: Row Size Too Large Error Creating a Table and +# Inserting Data. +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; + +CREATE TABLE t1( +c1 DECIMAL(10, 2), +c2 FLOAT); + +INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5); + +CREATE TABLE t2( +c3 DECIMAL(10, 2)) +SELECT +c1 * c2 AS c3 +FROM t1; + +SELECT * FROM t1; +c1 c2 +0.00 1 +2.00 3 +4.00 5 + +SELECT * FROM t2; +c3 +0.00 +6.00 +20.00 + +DROP TABLE t1; +DROP TABLE t2; + +CREATE TABLE t1 (c1 BIGINT NOT NULL); +INSERT INTO t1 (c1) VALUES (1); +SELECT * FROM t1 WHERE c1 > NULL + 1; +c1 +DROP TABLE t1; + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY); +INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0'); +SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar'); +a +foo0 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, c INT, KEY(a)); +INSERT INTO t1 VALUES (1, 1), (2, 2); +INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), +(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), +(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), +(4, 1), (4, 2), (4, 3), (4, 4), (4, 5); +FLUSH STATUS; +SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3; +b +1 +2 +SHOW STATUS LIKE 'Handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 6 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0', +f2 int(11) NOT NULL default '0', +f3 bigint(20) NOT NULL default '0', +f4 varchar(255) NOT NULL default '', +PRIMARY KEY (f1), +KEY key1 (f4), +KEY key2 (f2)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) NOT NULL default '0', +f2 enum('A1','A2','A3') NOT NULL default 'A1', +f3 int(11) NOT NULL default '0', +PRIMARY KEY (f1), +KEY key1 (f3)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0', +f2 datetime NOT NULL default '1980-01-01 00:00:00', +PRIMARY KEY (f1)) charset latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1, 1, 1, 'abc'); +insert into t1 values (2, 1, 2, 'def'); +insert into t1 values (3, 1, 2, 'def'); +insert into t2 values (1, 'A1', 1); +insert into t3 values (1, '1980-01-01'); +SELECT a.f3, cr.f4, count(*) count +FROM t2 a +STRAIGHT_JOIN t1 cr ON cr.f2 = a.f1 +LEFT JOIN +(t1 cr2 +JOIN t3 ae2 ON cr2.f3 = ae2.f1 +) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY AND +cr.f4 = cr2.f4 +GROUP BY a.f3, cr.f4; +f3 f4 count +1 abc 1 +1 def 2 +drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL SRID 0, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL a NULL NULL NULL 2 100.00 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` FORCE INDEX (`a`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; +SET sql_mode = default; +# +# Bug #49199: Optimizer handles incorrectly: +# field='const1' AND field='const2' in some cases + +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = DATE'2001-01-01') +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP NOT NULL NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES('2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +a +2001-01-01 00:00:00 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00') +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = DATE'2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL) charset utf8mb4; +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +a b +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01 00:00:00') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +a b +2001-01-01 00:00:00 2001-01-01 +EXPLAIN SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = '2001-01-01') and (`test`.`t1`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL); +INSERT INTO t1 VALUES('2001-01-01', '2001-01-01'); +SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +a a a +2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00 +EXPLAIN SELECT x.a, y.a, z.a FROM t1 x +JOIN t1 y ON x.a=y.a +JOIN t1 z ON y.a=z.a +WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE x NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE y NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE z NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a`,`test`.`z`.`a` AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where ((`test`.`x`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`y`.`a` = TIMESTAMP'2001-01-01 00:00:00') and (`test`.`z`.`a` = TIMESTAMP'2001-01-01 00:00:00')) +DROP TABLE t1; +# +# Bug #49897: crash in ptr_compare when char(0) NOT NULL +# column is used for ORDER BY +# +SET @old_sort_buffer_size= @@session.sort_buffer_size; +SET @@sort_buffer_size= 40000; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1(a CHAR(0) NOT NULL); +INSERT INTO t1 VALUES (0), (0), (0); +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24404 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24404 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; +CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int); +INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1); +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t1 depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +# Note that the tables may MYISAM, since many of the test files that +# includes this file forces MYISAM as the default storage engine. +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12 +ORDER BY t11.a, t11.b, t11.c; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 5 +SELECT a FROM t1 ORDER BY a LIMIT 5; +a + + + + + +EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 5 +SELECT * FROM t1 ORDER BY a, b LIMIT 5; +a b c + 2 + 2 + 2 + 2 + 2 +EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c` limit 5 +SELECT * FROM t1 ORDER BY a, b, c LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24434 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 24434 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`a` limit 5 +SELECT * FROM t1 ORDER BY c, a LIMIT 5; +a b c + 0 + 0 + 0 + 0 + 0 +SET @@sort_buffer_size= @old_sort_buffer_size; +DROP TABLE t1; +SET sql_mode = default; +End of 5.0 tests +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +a +1 +2 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +a +3 +4 +5 +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +a +3 +4 +5 +DROP TABLE t1; +CREATE TABLE A (date_key date); +CREATE TABLE C ( +pk int, +int_nokey int, +int_key int, +date_key date NOT NULL, +date_nokey date, +varchar_key varchar(1) +); +INSERT IGNORE INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +Warning 1264 Out of range value for column 'date_key' at row 2 +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); +1 +SELECT COUNT(DISTINCT 1) FROM C +WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +COUNT(DISTINCT 1) +SELECT date_nokey FROM C +WHERE int_key IN (SELECT 1 FROM A) +HAVING date_nokey = '10:41:7' +ORDER BY date_key; +ERROR HY000: Incorrect DATE value: '10:41:7' +DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT IGNORE INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT IGNORE INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 +# +# Bug#33546: Slowdown on re-evaluation of constant expressions. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +a +2 +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1 HAVING a = 1 + 1; +a +2 +EXPLAIN SELECT * FROM t1 HAVING a = 1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = ((1 + 1))) +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +a b +4 2 +EXPLAIN SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + ((1 + 1)))) +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +b a +2 3 +EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where true +EXPLAIN SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > (unix_timestamp('2009-03-10 00:00:00'))) +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +SET @cnt := @cnt + 1; +RETURN 1; +END;| +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +a +1 +SELECT @cnt; +@cnt +1 +EXPLAIN SELECT * FROM t1 WHERE a = f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = (`f1`())) +DROP TABLE t1, t2; +DROP FUNCTION f1; +# End of bug#33546 +# +# BUG#48052: Valgrind warning - uninitialized value in init_read_record() +# +# Disable Index condition pushdown +SELECT @old_optimizer_switch:=@@optimizer_switch; +@old_optimizer_switch:=@@optimizer_switch +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1 ( +pk int(11) NOT NULL, +i int(11) DEFAULT NULL, +v varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2,7,'m'); +INSERT INTO t1 VALUES (3,9,'m'); +SELECT v +FROM t1 +WHERE NOT pk > 0 +HAVING v <= 't' +ORDER BY pk; +v +# Restore old value for Index condition pushdown +SET SESSION optimizer_switch=@old_optimizer_switch; +DROP TABLE t1; +# +# Bug#49489 Uninitialized cache led to a wrong result. +# +CREATE TABLE t1(c1 DOUBLE(5,4)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9.1234); +SELECT * FROM t1 WHERE c1 < 9.12345; +c1 +9.1234 +DROP TABLE t1; +# End of test for bug#49489. +# +# Bug #49517: Inconsistent behavior while using +# NULLable BIGINT and INT columns in comparison +# +CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL); +INSERT INTO t1 VALUES(105, NULL, NULL); +SELECT * FROM t1 WHERE b < 102; +a b c +SELECT * FROM t1 WHERE c < 102; +a b c +SELECT * FROM t1 WHERE 102 < b; +a b c +SELECT * FROM t1 WHERE 102 < c; +a b c +DROP TABLE t1; +# +# Bug #54459: Assertion failed: param.sort_length, +# file .\filesort.cc, line 149 (part II) +# +CREATE TABLE t1(a ENUM('') NOT NULL) charset latin1; +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` order by `(t1.a collate latin1_german2_ci)` +SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug #58422: Incorrect result when OUTER JOIN'ing +# with an empty table +# +CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT); +CREATE TABLE t1(pk INT PRIMARY KEY, i INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ; +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); +ANALYZE TABLE t_empty, t1, t2; +Table Op Msg_type Msg_text +test.t_empty analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON TRUE) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`pk` = `test`.`t1`.`pk`) and (`test`.`t1`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 CROSS JOIN t_empty) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +EXPLAIN +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t_empty NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 33.33 Using where +2 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i` AS `i`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i` AS `i`,`test`.`t_empty`.`pk` AS `pk`,`test`.`t_empty`.`i` AS `i` from `test`.`t1` join `test`.`t2` join `test`.`t_empty` where ((`test`.`t2`.`i` = `test`.`t_empty`.`i`) and (`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t2`.`pk` <> 2)) +SELECT * +FROM +t1 +LEFT OUTER JOIN +(t2 INNER JOIN t_empty ON t_empty.i=t2.i) +ON t1.pk=t2.pk +WHERE t2.pk <> 2; +pk i pk i pk i +DROP TABLE t1,t2,t_empty; +End of 5.1 tests +# +# Bug#45227: Lost HAVING clause led to a wrong result. +# +CREATE TABLE `cc` ( +`int_nokey` int(11) NOT NULL, +`int_key` int(11) NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +KEY `int_key` (`int_key`), +KEY `varchar_key` (`varchar_key`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `cc` VALUES +(0,8,'q','q'),(5,8,'m','m'),(7,3,'j','j'),(1,2,'z','z'),(8,2,'a','a'),(2,6,'',''),(1,8,'e' +,'e'),(8,9,'t','t'),(5,2,'q','q'),(4,6,'b','b'),(5,5,'w','w'),(3,2,'m','m'),(0,4,'x','x'), +(8,9,'',''),(0,6,'w','w'),(4,5,'x','x'),(0,0,'e','e'),(0,0,'e','e'),(2,8,'p','p'),(0,0,'x' +,'x'); +EXPLAIN SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 90.00 Parallel execute (1 workers) +2 SIMPLE cc NULL range int_key int_key 4 NULL 9 90.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`cc`.`varchar_nokey` AS `g1` from `test`.`cc` where ((0 <> `test`.`cc`.`int_nokey`) and (`test`.`cc`.`int_key` <= 4)) having (0 <> `g1`) order by `test`.`cc`.`varchar_key` limit 6 +SELECT `varchar_nokey` g1 FROM cc WHERE `int_nokey` AND `int_key` <= 4 +HAVING g1 ORDER BY `varchar_key` LIMIT 6 ; +g1 +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'm' +Warning 1292 Truncated incorrect DOUBLE value: 'q' +Warning 1292 Truncated incorrect DOUBLE value: 'z' +Warnings: +DROP TABLE cc; +# End of test#45227 +# +# Bug#54515: Crash in opt_range.cc::get_best_group_min_max on +# SELECT from VIEW with GROUP BY +# +CREATE TABLE t1 ( +col_int_key int DEFAULT NULL, +KEY int_key (col_int_key) +) ; +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW view_t1 AS +SELECT t1.col_int_key AS col_int_key +FROM t1; +SELECT col_int_key FROM view_t1 GROUP BY col_int_key; +col_int_key +1 +2 +DROP VIEW view_t1; +DROP TABLE t1; +# End of test BUG#54515 +# +# Bug #57203 Assertion `field_length <= 255' failed. +# +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (ST_geomfromtext("point(25379 -22010)"))))) +AS foo +; +ERROR HY000: Incorrect arguments to avg +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; +avg(distinct(t1.a)) +0 +DROP TABLE t1; +# End of test BUG#57203 +# +# Bug#63020: Function "format"'s 'locale' argument is not considered +# when creating a "view' +# +CREATE TABLE t1 (f1 DECIMAL(10,2)); +INSERT INTO t1 VALUES (11.67),(17865.3),(12345678.92); +CREATE VIEW view_t1 AS SELECT FORMAT(f1,1,'sk_SK') AS f1 FROM t1; +SHOW CREATE VIEW view_t1; +View Create View character_set_client collation_connection +view_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_t1` AS select format(`t1`.`f1`,1,'sk_SK') AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM view_t1; +f1 +11,7 +17 865,3 +12 345 678,9 +DROP TABLE t1; +DROP VIEW view_t1; +# End of test BUG#63020 +# +# Bug #13571700 TINYBLOB NOT NULL, CRASH IN PROTOCOL::NET_STORE_DATA +# +CREATE TABLE t1 (a TINYBLOB NOT NULL); +SELECT a, COUNT(*) FROM t1 WHERE 0; +a COUNT(*) +NULL 0 +DROP TABLE t1; +# End of test BUG#13571700 +# +# Bug #18766378: CRASH IN ITEM_SUM_BIT::RESET_FIELD +# +CREATE TABLE t1(b int); +CREATE TABLE t2(a int); +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +SELECT +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +FROM t1, t2 +GROUP BY a; +( SELECT 1 FROM t1 GROUP BY a +HAVING avg(distinct 1) ORDER BY max(a) +) +1 +DROP TABLE t1,t2; +# End of test BUG#18766378 +# +# WL#13002: RESULTSET DIFFERENT NUMBER OF ROWS +# +CREATE TABLE t1 ( +f1 INTEGER, +f2 INTEGER, +INDEX i1 (f2) +); +INSERT INTO t1 VALUES (NULL,1); +INSERT INTO t1 VALUES (2,NULL); +INSERT INTO t1 VALUES (3,1); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (NULL,5); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (13,1); +INSERT INTO t1 VALUES (NULL,0); +INSERT INTO t1 VALUES (5,2); +INSERT INTO t1 VALUES (NULL,8); +INSERT INTO t1 VALUES (NULL,7); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,NULL); +INSERT INTO t1 VALUES (NULL,4); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=tree SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=9.27 rows=19) + -> PQblock scan on alias1 (cost=1.65 rows=14) + -> Filter: (alias2.f1 not between 4 and 12) (cost=0.40 rows=1) + -> Index lookup on alias2 using i1 (f2=alias1.f1) (cost=0.40 rows=2) + +SELECT * +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 ON alias1.f1 = alias2.f2 +WHERE alias2.f1 NOT BETWEEN 4 AND 12; +f1 f2 f1 f2 +DROP TABLE t1; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/skip_records_in_range.result-pq b/mysql-test/r/skip_records_in_range.result-pq new file mode 100644 index 000000000..336d60224 --- /dev/null +++ b/mysql-test/r/skip_records_in_range.result-pq @@ -0,0 +1,748 @@ +CREATE TABLE t1 ( +pk_col1 INT NOT NULL, +a1 CHAR(64), +a2 CHAR(64), +PRIMARY KEY(pk_col1), +KEY t1_a1_idx (a1), +KEY t1_a1_a2_idx (a1, a2) +) ENGINE=INNODB; +INSERT INTO t1 (pk_col1, a1, a2) VALUES (1,'a','b'), (2,'a','b'), (3,'d','c'), +(4,'b','c'), (5,'c','d'), (6,'a','b'); +CREATE TABLE t2 ( +pk_col1 INT NOT NULL, +pk_col2 INT NOT NULL, +a1 CHAR(64), +a2 CHAR(64), +PRIMARY KEY(pk_col1, pk_col2), +KEY t2_a1_idx (a1), +KEY t2_a1_a2_idx (a1, a2) +) ENGINE=INNODB; +INSERT INTO t2 (pk_col1, pk_col2, a1, a2) VALUES (1,1,'a','b'),(1,2,'a','b'), +(1,3,'d','c'),(1,4,'b','c'), +(2,1,'c','d'),(3,1,'a','b'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1 WHERE a1 > 'b'; +a1 +c +d +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +0 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1 WHERE a1 > 'b'' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range t1_a1_idx,t1_a1_a2_idx t1_a1_idx 257 NULL 2 100.00 Using where; Using index +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1 WHERE a1 > 'b'' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.67" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.47", + "eval_cost": "0.20", + "prefix_cost": "0.67", + "data_read_per_join": "528" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.67" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "t1_a1_idx", + "t1_a1_a2_idx" + ], + "key": "t1_a1_idx", + "used_key_parts": [ + "a1" + ], + "key_length": "257", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_where": true, + "using_index": true, + "cost_info": { + "read_cost": "0.47", + "eval_cost": "0.20", + "prefix_cost": "0.67", + "data_read_per_join": "1K" + }, + "used_columns": [ + "a1" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 > 'b'; +a1 +c +d +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +1 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 > 'b'' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL NULL Parallel execute (4 workers) +2 SIMPLE t1 NULL range t1_a1_a2_idx t1_a1_a2_idx 257 NULL 1 100.00 Using where; Using index +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 > 'b'' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "skip_records_in_range_due_to_force": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.00", + "prefix_cost": "0.00", + "data_read_per_join": "0" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.46" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "t1_a1_a2_idx" + ], + "key": "t1_a1_a2_idx", + "used_key_parts": [ + "a1" + ], + "key_length": "257", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_where": true, + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "520" + }, + "used_columns": [ + "a1" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1 WHERE a1 = 'a'; +a1 +a +a +a +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +0 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1 WHERE a1 = 'a'' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL ref t1_a1_idx,t1_a1_a2_idx t1_a1_idx 257 const 3 100.00 Using where; Using index +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1 WHERE a1 = 'a'' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.56" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.27", + "eval_cost": "0.30", + "prefix_cost": "0.57", + "data_read_per_join": "792" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.56" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "t1_a1_idx", + "t1_a1_a2_idx" + ], + "key": "t1_a1_idx", + "used_key_parts": [ + "a1" + ], + "key_length": "257", + "ref": [ + "const" + ], + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_where": true, + "using_index": true, + "cost_info": { + "read_cost": "0.27", + "eval_cost": "0.30", + "prefix_cost": "0.57", + "data_read_per_join": "1K" + }, + "used_columns": [ + "a1" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 = 'a'; +a1 +a +a +a +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +1 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 = 'a'' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL NULL Parallel execute (4 workers) +2 SIMPLE t1 NULL ref t1_a1_a2_idx t1_a1_a2_idx 257 const 1 100.00 Using where; Using index +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 = 'a'' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "skip_records_in_range_due_to_force": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.00", + "prefix_cost": "0.00", + "data_read_per_join": "0" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "t1_a1_a2_idx" + ], + "key": "t1_a1_a2_idx", + "used_key_parts": [ + "a1" + ], + "key_length": "257", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_where": true, + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "520" + }, + "used_columns": [ + "a1" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1; +a1 +a +a +a +b +c +d +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +0 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index NULL t1_a1_idx 257 NULL 6 100.00 Using index +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "1K" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.85" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "key": "t1_a1_idx", + "used_key_parts": [ + "a1" + ], + "key_length": "257", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "3K" + }, + "used_columns": [ + "a1" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx); +a1 +a +a +a +b +c +d +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +0 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx)' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL index NULL t1_a1_a2_idx 514 NULL 6 100.00 Using index +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx)' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.35" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "1.75", + "eval_cost": "0.60", + "prefix_cost": "2.35", + "data_read_per_join": "1K" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "2.35" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "index", + "key": "t1_a1_a2_idx", + "used_key_parts": [ + "a1", + "a2" + ], + "key_length": "514", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "1.75", + "eval_cost": "0.60", + "prefix_cost": "2.35", + "data_read_per_join": "3K" + }, + "used_columns": [ + "a1" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 >= 'a'; +a1 +a +a +a +b +c +d +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +1 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 >= 'a'' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL NULL Parallel execute (4 workers) +2 SIMPLE t1 NULL range t1_a1_a2_idx t1_a1_a2_idx 257 NULL 1 100.00 Using where; Using index +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_a2_idx) WHERE a1 >= 'a'' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.46" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "skip_records_in_range_due_to_force": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.00", + "prefix_cost": "0.00", + "data_read_per_join": "0" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.46" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "t1_a1_a2_idx" + ], + "key": "t1_a1_a2_idx", + "used_key_parts": [ + "a1" + ], + "key_length": "257", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_where": true, + "using_index": true, + "cost_info": { + "read_cost": "0.36", + "eval_cost": "0.10", + "prefix_cost": "0.46", + "data_read_per_join": "520" + }, + "used_columns": [ + "a1" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT a1 FROM t1 FORCE INDEX(t1_a1_idx) WHERE a2 > 'a'; +a1 +a +a +d +b +c +a +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +0 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_idx) WHERE a2 > 'a'' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL NULL Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT a1 FROM t1 FORCE INDEX(t1_a1_idx) WHERE a2 > 'a'' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.35" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "skip_records_in_range_due_to_force": true, + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.00", + "prefix_cost": "0.00", + "data_read_per_join": "0" + }, + "used_columns": [ + "a1" + ], + "query_block": { + "cost_info": { + "query_cost": "2.35" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "using_where": true, + "cost_info": { + "read_cost": "1.75", + "eval_cost": "0.60", + "prefix_cost": "2.35", + "data_read_per_join": "3K" + }, + "used_columns": [ + "a1", + "a2" + ] + } + } + } + } +} +SET optimizer_trace="enabled=on"; +SELECT t2.a1, t2.a2 +FROM t1 FORCE INDEX(t1_a1_a2_idx) JOIN t2 ON (t1.pk_col1 = t2.pk_col2) +WHERE t1.a1 > 'a'; +a1 a2 +b c +d c +SELECT TRACE INTO @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "skipped_due_to_force_index"; +@trace RLIKE "skipped_due_to_force_index" +0 +SET optimizer_trace="enabled=off"; +EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT t2.a1, t2.a2 +FROM t1 FORCE INDEX(t1_a1_a2_idx) JOIN t2 ON (t1.pk_col1 = t2.pk_col2) +WHERE t1.a1 > 'a'' +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (4 workers) +2 SIMPLE t1 NULL range t1_a1_a2_idx t1_a1_a2_idx 257 NULL 3 100.00 Using where; Using index +2 SIMPLE t2 NULL index NULL t2_a1_a2_idx 514 NULL 6 100.00 Using where; Using index; Using join buffer (hash join) +EXPLAIN FORMAT=JSON FOR QUERY 'SELECT t2.a1, t2.a2 +FROM t1 FORCE INDEX(t1_a1_a2_idx) JOIN t2 ON (t1.pk_col1 = t2.pk_col2) +WHERE t1.a1 > 'a'' +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.94" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "parallel_execute": "4 workers", + "cost_info": { + "read_cost": "0.59", + "eval_cost": "0.30", + "prefix_cost": "0.89", + "data_read_per_join": "1K" + }, + "used_columns": [ + "a1", + "a2" + ], + "query_block": { + "cost_info": { + "query_cost": "2.94" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "t1_a1_a2_idx" + ], + "key": "t1_a1_a2_idx", + "used_key_parts": [ + "a1" + ], + "key_length": "257", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_where": true, + "using_index": true, + "cost_info": { + "read_cost": "0.59", + "eval_cost": "0.30", + "prefix_cost": "0.89", + "data_read_per_join": "1K" + }, + "used_columns": [ + "pk_col1", + "a1" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "index", + "key": "t2_a1_a2_idx", + "used_key_parts": [ + "a1", + "a2" + ], + "key_length": "514", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 18, + "filtered": "100.00", + "using_where": true, + "using_index": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.94", + "data_read_per_join": "9K" + }, + "used_columns": [ + "pk_col2", + "a1", + "a2" + ] + } + } + ] + } + } + } +} +DROP TABLE t1, t2; +# +# Bug #26627136: WL#6526: ASSERTION +# `!ALL_SELECTS_LIST->NEXT_SELECT_IN_LIST()' FAILED. +# +CREATE TABLE t1 (v3 INT, KEY(v3)); +CREATE view v1 AS SELECT v3 FROM t1 FORCE KEY (v3) GROUP BY v3; +EXPLAIN select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL index v3 v3 5 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`v3` AS `v3` from `test`.`v1` +select * from v1; +v3 +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/r/skip_scan.result-pq b/mysql-test/r/skip_scan.result-pq new file mode 100644 index 000000000..dfc35cfc3 --- /dev/null +++ b/mysql-test/r/skip_scan.result-pq @@ -0,0 +1,1739 @@ +CREATE TABLE t (a INT, b INT, c INT, d INT, e INT, PRIMARY KEY(a, b, c, d), KEY(b, d)) ENGINE=innodb; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, d FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT b, d FROM t WHERE d < 2; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, d FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT b, d FROM t WHERE d < 2; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d < 2; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, d FROM t WHERE d > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 4) +FLUSH STATUS; +SELECT b, d FROM t WHERE d > 4; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, d FROM t WHERE d > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 4) +FLUSH STATUS; +SELECT b, d FROM t WHERE d > 4; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` > 4) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, d FROM t WHERE d > 4; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 75 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 500 33.33 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b PRIMARY 4 NULL 500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 503 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 500 33.33 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 503 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 166 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 102 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY,b PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 249 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 153 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 2 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 20.00 Parallel execute (2 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 2 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 66 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5) AND b IN (1, 2) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 44 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 50.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 3 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 50.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 3 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 6 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 3 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 249 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 165 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 1 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 10.00 Parallel execute (1 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 1 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 16 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = 5 AND b = 2 AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`a` + 1) AS `a+1`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t`.`a` + 1) AS `a+1`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ (`test`.`t`.`a` + 1) AS `a+1`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a+1, b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 16 NULL 83 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 51 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 10.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = `test`.`t`.`a`) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = `test`.`t`.`a`) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a = b AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = b AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 10.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = `test`.`t`.`a`) and (`test`.`t`.`d` >= 98)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a = b AND d >= 98; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c` +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 1) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,(`test`.`t`.`c` * -(1)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 200 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 1) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`(t.c * -(1))` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 1) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,(`test`.`t`.`c` * -(1)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 1 AND d < 3 ORDER BY d, c * -1; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 200 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT e FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`e` AS `e` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT e FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT e FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`e` AS `e` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT e FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ e FROM t WHERE a = 5 AND d <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`e` AS `e` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` <= 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ e FROM t WHERE a = 5 AND d <= 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c`,`test`.`t`.`e` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c`,`test`.`t`.`e` +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) order by `test`.`t`.`d`,`test`.`t`.`c`,`test`.`t`.`e` +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 10 AND d < 3 ORDER BY d, c, e; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t`.`a`) AS `count(a)`,count(`test`.`t`.`b`) AS `count(b)`,count(`test`.`t`.`c`) AS `count(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t`.`a`) AS `count(a)`,count(`test`.`t`.`b`) AS `count(b)`,count(`test`.`t`.`c`) AS `count(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ count(`test`.`t`.`a`) AS `count(a)`,count(`test`.`t`.`b`) AS `count(b)`,count(`test`.`t`.`c`) AS `count(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ count(a), count(b), count(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t`.`a`) AS `min(a)`,max(`test`.`t`.`b`) AS `max(b)`,min(`test`.`t`.`c`) AS `min(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t`.`a`) AS `min(a)`,max(`test`.`t`.`b`) AS `max(b)`,min(`test`.`t`.`c`) AS `min(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ min(`test`.`t`.`a`) AS `min(a)`,max(`test`.`t`.`b`) AS `max(b)`,min(`test`.`t`.`c`) AS `min(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ min(a), max(b), min(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`a`) AS `sum(a)`,sum(`test`.`t`.`b`) AS `sum(b)`,sum(`test`.`t`.`c`) AS `sum(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`a`) AS `sum(a)`,sum(`test`.`t`.`b`) AS `sum(b)`,sum(`test`.`t`.`c`) AS `sum(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT sum(a), sum(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ sum(a), avg(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ sum(`test`.`t`.`a`) AS `sum(a)`,avg(`test`.`t`.`b`) AS `avg(b)`,sum(`test`.`t`.`c`) AS `sum(c)` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 10) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ sum(a), avg(b), sum(c) FROM t WHERE a = 5 AND c > 10 AND d < 3; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT count(*) FROM t WHERE d < 2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT count(*) FROM t WHERE d < 2;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT count(*) FROM t WHERE d < 2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL b 8 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT count(*) FROM t WHERE d < 2;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ count(*) FROM t WHERE d < 2;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ count(0) AS `count(*)` from `test`.`t` where (`test`.`t`.`d` < 2) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ count(*) FROM t WHERE d < 2;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 250 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +Testing DESC index with skip scan. +ALTER TABLE t DROP PRIMARY KEY; +ALTER TABLE t DROP KEY b; +ALTER TABLE t ADD PRIMARY KEY(a DESC, b, c DESC, d); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c > 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` < 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 11.11 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` < 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` < 3) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c < 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 100 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 3.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 3.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` = 3) and (`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c = 3 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 50 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 150 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 3.70 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 3.70 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 251 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 50 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE a = 5 AND c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 11 +Handler_read_last 0 +Handler_read_next 150 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 500 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 101 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 3.70 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL PRIMARY 16 NULL 2500 3.70 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 12 NULL 500 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`c` between 3 and 5) and (`test`.`t`.`d` < 3)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE c BETWEEN 3 AND 5 AND d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 101 +Handler_read_last 0 +Handler_read_next 1500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT b, c, d FROM t WHERE d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index PRIMARY PRIMARY 16 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 3) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT b, c, d FROM t WHERE d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL index NULL PRIMARY 16 NULL 2500 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 3) +FLUSH STATUS; +SELECT b, c, d FROM t WHERE d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 2504 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE d < 3;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 16 NULL 833 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (`test`.`t`.`d` < 3) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ b, c, d FROM t WHERE d < 3;; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 501 +Handler_read_last 0 +Handler_read_next 500 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 750 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 4 NULL 750 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 7 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 754 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 16 NULL 249 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,3,5)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 3, 5) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 153 +Handler_read_last 0 +Handler_read_next 450 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 300 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 8 NULL 300 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5,3)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 304 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 300 33.33 Parallel execute (4 workers) +2 SIMPLE t NULL range PRIMARY PRIMARY 8 NULL 300 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5,3)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b IN (1, 2) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 304 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b in (1, 2) AND d >= 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY PRIMARY 16 NULL 99 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t`@`select#1`) */ `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,5,3)) and (`test`.`t`.`b` in (1,2)) and (`test`.`t`.`d` >= 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t) */ a, b, c, d FROM t WHERE a IN (1, 5, 3) AND b in (1, 2) AND d >= 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 66 +Handler_read_last 0 +Handler_read_next 180 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = default; +DROP TABLE t; +Testing DESC index with skip scan and NULL range. +CREATE TABLE t1 (a INT, b INT, c INT, d INT, e INT); +INSERT INTO t1 VALUES +(NULL, 1, 1, 3, 4), (NULL, 2, 1, 4, 5), +(1, 2, 1, 3, 4), (2, 2, 1, 4, 5), +(5, 2, 3, 3, 4), (2, 2, 1, 4, 11), +(8, 2, 1, 3, 4), (7, 2, 1, 4, 9); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +ALTER TABLE t1 ADD KEY k1(a DESC, b, c DESC, d, e DESC); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 13 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 13 +Handler_read_last 1 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1 k1 20 NULL 34 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 14 +Handler_read_last 0 +Handler_read_next 32 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +ALTER TABLE t1 DROP KEY k1; +ALTER TABLE t1 ADD KEY k1(a, b DESC, c, d DESC, e); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch = 'skip_scan=on'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +set optimizer_switch = 'skip_scan=off'; +EXPLAIN SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 34 11.11 Parallel execute (4 workers) +2 SIMPLE t1 NULL range k1 k1 10 NULL 34 11.11 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 12 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 36 +include/diff_tables.inc [test.skip_scan, test.no_skip_scan] +EXPLAIN SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1 k1 20 NULL 34 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` where (((`test`.`t1`.`a` in (1,5)) or (`test`.`t1`.`a` is null)) and (`test`.`t1`.`b` in (1,2)) and (`test`.`t1`.`d` between 2 and 5)) +FLUSH STATUS; +SELECT /*+ SKIP_SCAN(t1) */ a, b, c, d FROM t1 WHERE (a IN (1, 5) or a IS NULL) AND b in (1, 2) AND d BETWEEN 2 AND 5; +SHOW STATUS LIKE 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 14 +Handler_read_last 0 +Handler_read_next 32 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +include/diff_tables.inc [test.hint_skip_scan, test.no_skip_scan] +set optimizer_switch = default; +DROP TABLE t1; +# +# Bug#28089360 WL#11322: SIG11 AT QEP_SHARED_OWNER::JOIN | SQL/SQL_OPT_EXEC_SHARED.H:458 +# +CREATE TABLE t1 (f1 INT(11), f2 VARCHAR(1), KEY k1 (f2, f1)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (-682212662,'c'), (-1974921822,'C'), (1260604936,'9'); +CREATE TABLE t2 (f1 INT(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (824388284), (1186821161); +CREATE VIEW v1 AS select f1, f2 from t1; +DELETE FROM t2 WHERE (f1, f1) IN (SELECT f1,f2 FROM v1 WHERE f1 >= 2); +DROP VIEW v1; +DROP TABLE t1, t2; +# +# Bug #29602393 ASSERTION `BITMAP_IS_SET(KEY_INFO->TABLE->READ_SET, +# KEY_INFO->KEY_PART.*FAILED +# +CREATE TABLE t1(f1 INT, f2 VARCHAR(64) NOT NULL, PRIMARY KEY (f1)) +PARTITION BY RANGE(f1) +( +PARTITION p1 VALUES LESS THAN (3), +PARTITION p2 VALUES LESS THAN (maxvalue) +); +INSERT INTO t1 VALUES (1, 'abcde'), (2, 'abcde'), (3, 'abcde'); +CREATE INDEX idx1 ON t1(f2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ SKIP_SCAN(t1 idx1) */ count(*) FROM t1 WHERE f1 <= 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p1,p2 range PRIMARY,idx1 idx1 262 NULL 1 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1` `idx1`) */ count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`f1` <= 3) +SELECT /*+ SKIP_SCAN(t1 idx1) */ count(*) FROM t1 WHERE f1 <= 3; +count(*) +3 +DROP TABLE t1; diff --git a/mysql-test/r/slow_log_extra-big.result-pq b/mysql-test/r/slow_log_extra-big.result-pq new file mode 100644 index 000000000..ad022c354 --- /dev/null +++ b/mysql-test/r/slow_log_extra-big.result-pq @@ -0,0 +1,37 @@ +SET @my_slow_logname = @@global.slow_query_log_file; +SET @my_lqt = @@global.long_query_time; +SET GLOBAL slow_query_log_file= '.../my_extra_big.log'; +SET SESSION long_query_time = 20; +SET GLOBAL long_query_time = 0; +SELECT COUNT(*) FROM big_table_slow; +COUNT(*) +200 +SELECT COUNT(*) FROM big_table_slow; +COUNT(*) +200 +SELECT COUNT(*) FROM big_table_slow WHERE id>100 AND id<200; +COUNT(*) +49 +SELECT * FROM big_table_slow WHERE id=2; +id v t +2 v bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba +SELECT COUNT(*) FROM big_table_slow WHERE id>100; +COUNT(*) +150 +SELECT COUNT(*) FROM big_table_slow WHERE id<100; +COUNT(*) +49 +# Cleanup +SET GLOBAL long_query_time=@my_lqt; +SET GLOBAL slow_query_log_file = @my_slow_logname; +DROP TABLE big_table_slow; +# +# This is a hack to check the log result. +# We strip off time related fields (non-deterministic) and verify the rest are correct. +# +Rows_sent: 1 Rows_examined: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 58 Read_first: 0 Read_last: 0 Read_key: 0 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 0 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 58 Read_first: 0 Read_last: 0 Read_key: 0 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 49 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 57 Read_first: 0 Read_last: 0 Read_key: 2 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 53 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 1 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 307 Read_first: 0 Read_last: 0 Read_key: 1 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 0 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 150 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 58 Read_first: 0 Read_last: 1 Read_key: 2 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 154 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 +Rows_sent: 1 Rows_examined: 49 Errno: 0 Killed: 0 Bytes_received: 0 Bytes_sent: 57 Read_first: 0 Read_last: 0 Read_key: 1 Read_next: 0 Read_prev: 0 Read_rnd: 0 Read_rnd_next: 53 Sort_merge_passes: 0 Sort_range_count: 0 Sort_rows: 0 Sort_scan_count: 0 Created_tmp_disk_tables: 0 Created_tmp_tables: 0 diff --git a/mysql-test/r/sp.result-pq b/mysql-test/r/sp.result-pq new file mode 100644 index 000000000..58f73bd9f --- /dev/null +++ b/mysql-test/r/sp.result-pq @@ -0,0 +1,8587 @@ +use test; +drop table if exists t1,t2,t3,t4; +drop view if exists v1; +drop procedure if exists p1; +drop procedure if exists p2; +drop function if exists f1; +drop function if exists f2; +create table t1 ( +id char(16) not null default '', +data int not null +) engine=myisam; +create table t2 ( +s char(16), +i int, +d double +) engine=myisam; +drop procedure if exists foo42; +create procedure foo42() +insert into test.t1 values ("foo", 42); +call foo42(); +select * from t1; +id data +foo 42 +delete from t1; +drop procedure foo42; +drop procedure if exists bar; +create procedure bar(x char(16), y int) +insert into test.t1 values (x, y); +call bar("bar", 666); +select * from t1; +id data +bar 666 +delete from t1; +drop procedure if exists `empty`| +create procedure `empty`() +begin +end| +call `empty`()| +drop procedure `empty`| +drop procedure if exists scope| +create procedure scope(a int, b float) +begin +declare b int; +declare c float; +begin +declare c int; +end; +end| +drop procedure scope| +drop procedure if exists two| +create procedure two(x1 char(16), x2 char(16), y int) +begin +insert into test.t1 values (x1, y); +insert into test.t1 values (x2, y); +end| +call two("one", "two", 3)| +select * from t1| +id data +one 3 +two 3 +delete from t1| +drop procedure two| +drop procedure if exists locset| +create procedure locset(x char(16), y int) +begin +declare z1, z2 int; +set z1 = y; +set z2 = z1+2; +insert into test.t1 values (x, z2); +end| +call locset("locset", 19)| +select * from t1| +id data +locset 21 +delete from t1| +drop procedure locset| +drop procedure if exists setcontext| +create procedure setcontext() +begin +declare data int default 2; +insert into t1 (id, data) values ("foo", 1); +replace t1 set data = data, id = "bar"; +update t1 set id = "kaka", data = 3 where t1.data = data; +end| +call setcontext()| +select * from t1 order by data| +id data +foo 1 +kaka 3 +delete from t1| +drop procedure setcontext| +create table t3 ( d date, i int, f double, s varchar(32) )| +drop procedure if exists nullset| +create procedure nullset() +begin +declare ld date; +declare li int; +declare lf double; +declare ls varchar(32); +set ld = null, li = null, lf = null, ls = null; +insert into t3 values (ld, li, lf, ls); +insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"), +((li is null), 1, "li is null"), +((li = 0), null, "li = 0"), +((lf is null), 1, "lf is null"), +((lf = 0), null, "lf = 0"), +((ls is null), 1, "ls is null"); +end| +call nullset()| +select * from t3| +d i f s +NULL NULL NULL NULL +NULL 1 1 ld is null +NULL 1 1 li is null +NULL NULL NULL li = 0 +NULL 1 1 lf is null +NULL NULL NULL lf = 0 +NULL 1 1 ls is null +drop table t3| +drop procedure nullset| +drop procedure if exists mixset| +create procedure mixset(x char(16), y int) +begin +declare z int; +set @z = y, z = 666; +insert into test.t1 values (x, z); +end| +call mixset("mixset", 19)| +show variables like 'max_join_size'| +Variable_name Value +max_join_size 18446744073709551615 +select id,data,@z from t1| +id data @z +mixset 666 19 +delete from t1| +drop procedure mixset| +drop procedure if exists zip| +create procedure zip(x char(16), y int) +begin +declare z int; +call zap(y, z); +call bar(x, z); +end| +drop procedure if exists zap| +create procedure zap(x int, out y int) +begin +declare z int; +set z = x+1, y = z; +end| +call zip("zip", 99)| +select * from t1| +id data +zip 100 +delete from t1| +drop procedure zip| +drop procedure bar| +call zap(7, @zap)| +select @zap| +@zap +8 +drop procedure zap| +drop procedure if exists c1| +create procedure c1(x int) +call c2("c", x)| +drop procedure if exists c2| +create procedure c2(s char(16), x int) +call c3(x, s)| +drop procedure if exists c3| +create procedure c3(x int, s char(16)) +call c4("level", x, s)| +drop procedure if exists c4| +create procedure c4(l char(8), x int, s char(16)) +insert into t1 values (concat(l,s), x)| +call c1(42)| +select * from t1| +id data +levelc 42 +delete from t1| +drop procedure c1| +drop procedure c2| +drop procedure c3| +drop procedure c4| +drop procedure if exists iotest| +create procedure iotest(x1 char(16), x2 char(16), y int) +begin +call inc2(x2, y); +insert into test.t1 values (x1, y); +end| +drop procedure if exists inc2| +create procedure inc2(x char(16), y int) +begin +call inc(y); +insert into test.t1 values (x, y); +end| +drop procedure if exists inc| +create procedure inc(inout io int) +set io = io + 1| +call iotest("io1", "io2", 1)| +select * from t1 order by data desc| +id data +io2 2 +io1 1 +delete from t1| +drop procedure iotest| +drop procedure inc2| +drop procedure if exists incr| +create procedure incr(inout x int) +call inc(x)| +select @zap| +@zap +8 +call incr(@zap)| +select @zap| +@zap +9 +drop procedure inc| +drop procedure incr| +drop procedure if exists cbv1| +create procedure cbv1() +begin +declare y int default 3; +call cbv2(y+1, y); +insert into test.t1 values ("cbv1", y); +end| +drop procedure if exists cbv2| +create procedure cbv2(y1 int, inout y2 int) +begin +set y2 = 4711; +insert into test.t1 values ("cbv2", y1); +end| +call cbv1()| +select * from t1 order by data| +id data +cbv2 4 +cbv1 4711 +delete from t1| +drop procedure cbv1| +drop procedure cbv2| +insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)| +drop procedure if exists sub1| +create procedure sub1(id char(16), x int) +insert into test.t1 values (id, x)| +drop procedure if exists sub2| +create procedure sub2(id char(16)) +begin +declare x int; +set x = (select sum(t.i) from test.t2 t); +insert into test.t1 values (id, x); +end| +drop procedure if exists sub3| +create function sub3(i int) returns int deterministic +return i+1| +call sub1("sub1a", (select 7))| +call sub1("sub1b", (select max(i) from t2))| +call sub1("sub1c", (select i,d from t2 limit 1))| +ERROR 21000: Operand should contain 1 column(s) +call sub1("sub1d", (select 1 from (select 1) a))| +call sub2("sub2")| +select * from t1 order by id| +id data +sub1a 7 +sub1b 3 +sub1d 1 +sub2 6 +select sub3((select max(i) from t2))| +sub3((select max(i) from t2)) +4 +drop procedure sub1| +drop procedure sub2| +drop function sub3| +delete from t1| +delete from t2| +drop procedure if exists a0| +create procedure a0(x int) +while x do +set x = x-1; +insert into test.t1 values ("a0", x); +end while| +call a0(3)| +select * from t1 order by data desc| +id data +a0 2 +a0 1 +a0 0 +delete from t1| +drop procedure a0| +drop procedure if exists a| +create procedure a(x int) +while x > 0 do +set x = x-1; +insert into test.t1 values ("a", x); +end while| +call a(3)| +select * from t1 order by data desc| +id data +a 2 +a 1 +a 0 +delete from t1| +drop procedure a| +drop procedure if exists b| +create procedure b(x int) +repeat +insert into test.t1 values (repeat("b",3), x); +set x = x-1; +until x = 0 end repeat| +call b(3)| +select * from t1 order by data desc| +id data +bbb 3 +bbb 2 +bbb 1 +delete from t1| +drop procedure b| +drop procedure if exists b2| +create procedure b2(x int) +repeat +select 1 into outfile 'b2'; +insert into test.t1 values (repeat("b2",3), x); +set x = x-1; +until x = 0 end repeat| +drop procedure b2| +drop procedure if exists c| +create procedure c(x int) +hmm: while x > 0 do +insert into test.t1 values ("c", x); +set x = x-1; +iterate hmm; +insert into test.t1 values ("x", x); +end while hmm| +call c(3)| +select * from t1 order by data desc| +id data +c 3 +c 2 +c 1 +delete from t1| +drop procedure c| +drop procedure if exists d| +create procedure d(x int) +hmm: while x > 0 do +insert into test.t1 values ("d", x); +set x = x-1; +leave hmm; +insert into test.t1 values ("x", x); +end while| +call d(3)| +select * from t1| +id data +d 3 +delete from t1| +drop procedure d| +drop procedure if exists e| +create procedure e(x int) +foo: loop +if x = 0 then +leave foo; +end if; +insert into test.t1 values ("e", x); +set x = x-1; +end loop foo| +call e(3)| +select * from t1 order by data desc| +id data +e 3 +e 2 +e 1 +delete from t1| +drop procedure e| +drop procedure if exists f| +create procedure f(x int) +if x < 0 then +insert into test.t1 values ("f", 0); +elseif x = 0 then +insert into test.t1 values ("f", 1); +else +insert into test.t1 values ("f", 2); +end if| +call f(-2)| +call f(0)| +call f(4)| +select * from t1 order by data| +id data +f 0 +f 1 +f 2 +delete from t1| +drop procedure f| +drop procedure if exists g| +create procedure g(x int) +case +when x < 0 then +insert into test.t1 values ("g", 0); +when x = 0 then +insert into test.t1 values ("g", 1); +else +insert into test.t1 values ("g", 2); +end case| +call g(-42)| +call g(0)| +call g(1)| +select * from t1 order by data| +id data +g 0 +g 1 +g 2 +delete from t1| +drop procedure g| +drop procedure if exists h| +create procedure h(x int) +case x +when 0 then +insert into test.t1 values ("h0", x); +when 1 then +insert into test.t1 values ("h1", x); +else +insert into test.t1 values ("h?", x); +end case| +call h(0)| +call h(1)| +call h(17)| +select * from t1 order by data| +id data +h0 0 +h1 1 +h? 17 +delete from t1| +drop procedure h| +drop procedure if exists i| +create procedure i(x int) +foo: +begin +if x = 0 then +leave foo; +end if; +insert into test.t1 values ("i", x); +end foo| +call i(0)| +call i(3)| +select * from t1| +id data +i 3 +delete from t1| +drop procedure i| +insert into t1 values ("foo", 3), ("bar", 19)| +insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)| +drop procedure if exists sel1| +create procedure sel1() +begin +select * from t1 order by data; +end| +call sel1()| +id data +foo 3 +bar 19 +drop procedure sel1| +drop procedure if exists sel2| +create procedure sel2() +begin +select * from t1 order by data; +select * from t2 order by s; +end| +call sel2()| +id data +foo 3 +bar 19 +s i d +x 9 4.1 +y -1 19.2 +z 3 2.2 +drop procedure sel2| +delete from t1| +delete from t2| +drop procedure if exists into_test| +create procedure into_test(x char(16), y int) +begin +insert into test.t1 values (x, y); +select id,data into x,y from test.t1 limit 1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_test("into", 100)| +select * from t1 order by data| +id data +into 100 +into2 102 +delete from t1| +drop procedure into_test| +drop procedure if exists into_tes2| +create procedure into_test2(x char(16), y int) +begin +insert into test.t1 values (x, y); +select id,data into x,@z from test.t1 limit 1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_test2("into", 100)| +select id,data,@z from t1 order by data| +id data @z +into 100 100 +into2 102 100 +delete from t1| +drop procedure into_test2| +drop procedure if exists into_test3| +create procedure into_test3() +begin +declare x char(16); +declare y int; +select * into x,y from test.t1 limit 1; +insert into test.t2 values (x, y, 0.0); +end| +insert into t1 values ("into3", 19)| +call into_test3()| +call into_test3()| +select * from t2| +s i d +into3 19 0 +into3 19 0 +delete from t1| +delete from t2| +drop procedure into_test3| +drop procedure if exists into_test4| +create procedure into_test4() +begin +declare x int; +select data into x from test.t1 limit 1; +insert into test.t3 values ("into4", x); +end| +delete from t1| +create table t3 ( s char(16), d int)| +call into_test4()| +select * from t3| +s d +into4 NULL +insert into t1 values ("i4", 77)| +call into_test4()| +select * from t3| +s d +into4 NULL +into4 77 +delete from t1| +drop table t3| +drop procedure into_test4| +drop procedure if exists into_outfile| +create procedure into_outfile(x char(16), y int) +begin +insert into test.t1 values (x, y); +select * into outfile "MYSQLTEST_VARDIR/tmp/spout" from test.t1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_outfile("ofile", 1)| +delete from t1| +drop procedure into_outfile| +drop procedure if exists into_dumpfile| +create procedure into_dumpfile(x char(16), y int) +begin +insert into test.t1 values (x, y); +select * into dumpfile "MYSQLTEST_VARDIR/tmp/spdump" from test.t1 limit 1; +insert into test.t1 values (concat(x, "2"), y+2); +end| +call into_dumpfile("dfile", 1)| +delete from t1| +drop procedure into_dumpfile| +drop procedure if exists create_select| +create procedure create_select(x char(16), y int) +begin +insert into test.t1 values (x, y); +create temporary table test.t3 select * from test.t1; +insert into test.t3 values (concat(x, "2"), y+2); +end| +call create_select("cs", 90)| +select * from t1, t3| +id data id data +cs 90 cs 90 +cs 90 cs2 92 +drop table t3| +delete from t1| +drop procedure create_select| +drop function if exists e| +create function e() returns double +return 2.7182818284590452354| +set @e = e()| +select e(), @e| +e() @e +2.718281828459045 2.718281828459045 +drop function if exists inc| +create function inc(i int) returns int +return i+1| +select inc(1), inc(99), inc(-71)| +inc(1) inc(99) inc(-71) +2 100 -70 +drop function if exists mul| +create function mul(x int, y int) returns int +return x*y| +select mul(1,1), mul(3,5), mul(4711, 666)| +mul(1,1) mul(3,5) mul(4711, 666) +1 15 3137526 +drop function if exists append| +create function append(s1 char(8), s2 char(8)) returns char(16) +return concat(s1, s2)| +select append("foo", "bar")| +append("foo", "bar") +foobar +drop function if exists fac| +create function fac(n int unsigned) returns bigint unsigned +begin +declare f bigint unsigned default 1; +while n > 1 do +set f = f * n; +set n = n - 1; +end while; +return f; +end| +select fac(1), fac(2), fac(5), fac(10)| +fac(1) fac(2) fac(5) fac(10) +1 2 120 3628800 +drop function if exists fun| +create function fun(d double, i int, u int unsigned) returns double +return mul(inc(i), fac(u)) / e()| +select fun(2.3, 3, 5)| +fun(2.3, 3, 5) +176.58213176229233 +insert into t2 values (append("xxx", "yyy"), mul(4,3), e())| +insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))| +select * from t2 where s = append("a", "b")| +s i d +ab 24 1324.3659882171924 +select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2) order by i| +s i d +xxxyyy 12 2.718281828459045 +ab 24 1324.3659882171924 +select * from t2 where d = e()| +s i d +xxxyyy 12 2.718281828459045 +select * from t2 order by i| +s i d +xxxyyy 12 2.718281828459045 +ab 24 1324.3659882171924 +delete from t2| +drop function e| +drop function inc| +drop function mul| +drop function append| +drop function fun| +drop procedure if exists hndlr1| +create procedure hndlr1(val int) +begin +declare x int default 0; +declare foo condition for 1136; +declare bar condition for sqlstate '42S98'; # Just for testing syntax +declare zip condition for sqlstate value '42S99'; # Just for testing syntax +declare continue handler for foo set x = 1; +insert into test.t1 values ("hndlr1", val, 2); # Too many values +if (x) then +insert into test.t1 values ("hndlr1", val); # This instead then +end if; +end| +call hndlr1(42)| +select * from t1| +id data +hndlr1 42 +delete from t1| +drop procedure hndlr1| +drop procedure if exists hndlr2| +create procedure hndlr2(val int) +begin +declare x int default 0; +begin +declare exit handler for sqlstate '21S01' set x = 1; +insert into test.t1 values ("hndlr2", val, 2); # Too many values +end; +insert into test.t1 values ("hndlr2", x); +end| +call hndlr2(42)| +select * from t1| +id data +hndlr2 1 +delete from t1| +drop procedure hndlr2| +drop procedure if exists hndlr3| +create procedure hndlr3(val int) +begin +declare x int default 0; +declare continue handler for sqlexception # Any error +begin +declare z int; +set z = 2 * val; +set x = 1; +end; +if val < 10 then +begin +declare y int; +set y = val + 10; +insert into test.t1 values ("hndlr3", y, 2); # Too many values +if x then +insert into test.t1 values ("hndlr3", y); +end if; +end; +end if; +end| +call hndlr3(3)| +select * from t1| +id data +hndlr3 13 +delete from t1| +drop procedure hndlr3| +create table t3 ( id char(16), data int )| +drop procedure if exists hndlr4| +create procedure hndlr4() +begin +declare x int default 0; +declare val int; # No default +declare continue handler for sqlstate '02000' set x=1; +select data into val from test.t3 where id='z' limit 1; # No hits +insert into test.t3 values ('z', val); +end| +call hndlr4()| +select * from t3| +id data +z NULL +drop table t3| +drop procedure hndlr4| +drop procedure if exists cur1| +create procedure cur1() +begin +declare a char(16); +declare b int; +declare c double; +declare done int default 0; +declare c cursor for select * from test.t2; +declare continue handler for sqlstate '02000' set done = 1; +open c; +repeat +fetch c into a, b, c; +if not done then +insert into test.t1 values (a, b+c); +end if; +until done end repeat; +close c; +end| +insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)| +call cur1()| +select * from t1| +id data +foo 40 +bar 15 +zap 663 +drop procedure cur1| +create table t3 ( s char(16), i int )| +drop procedure if exists cur2| +create procedure cur2() +begin +declare done int default 0; +declare c1 cursor for select id,data from test.t1 order by id,data; +declare c2 cursor for select i from test.t2 order by i; +declare continue handler for sqlstate '02000' set done = 1; +open c1; +open c2; +repeat +begin +declare a char(16); +declare b,c int; +fetch from c1 into a, b; +fetch next from c2 into c; +if not done then +if b < c then +insert into test.t3 values (a, b); +else +insert into test.t3 values (a, c); +end if; +end if; +end; +until done end repeat; +close c1; +close c2; +end| +call cur2()| +select * from t3 order by i,s| +s i +bar 3 +foo 40 +zap 663 +delete from t1| +delete from t2| +drop table t3| +drop procedure cur2| +drop procedure if exists chistics| +create procedure chistics() +language sql +modifies sql data +not deterministic +sql security definer +comment 'Characteristics procedure test' + insert into t1 values ("chistics", 1)| +show create procedure chistics| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`() + MODIFIES SQL DATA + COMMENT 'Characteristics procedure test' +insert into t1 values ("chistics", 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call chistics()| +select * from t1| +id data +chistics 1 +delete from t1| +alter procedure chistics sql security invoker| +show create procedure chistics| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `chistics`() + MODIFIES SQL DATA + SQL SECURITY INVOKER + COMMENT 'Characteristics procedure test' +insert into t1 values ("chistics", 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure chistics| +drop function if exists chistics| +create function chistics() returns int +language sql +deterministic +sql security invoker +comment 'Characteristics procedure test' + return 42| +show create function chistics| +Function sql_mode Create Function character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int + DETERMINISTIC + SQL SECURITY INVOKER + COMMENT 'Characteristics procedure test' +return 42 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select chistics()| +chistics() +42 +alter function chistics +no sql +comment 'Characteristics function test'| +show create function chistics| +Function sql_mode Create Function character_set_client collation_connection Database Collation +chistics ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `chistics`() RETURNS int + NO SQL + DETERMINISTIC + SQL SECURITY INVOKER + COMMENT 'Characteristics function test' +return 42 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop function chistics| +insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)| +set @@sql_mode = 'ANSI'| +drop procedure if exists modes$ +create procedure modes(out c1 int, out c2 int) +begin +declare done int default 0; +declare x int; +declare c cursor for select data from t1; +declare continue handler for sqlstate '02000' set done = 1; +select 1 || 2 into c1; +set c2 = 0; +open c; +repeat +fetch c into x; +if not done then +set c2 = c2 + 1; +end if; +until done end repeat; +close c; +end$ +set @@sql_mode = ''| +set sql_select_limit = 1| +call modes(@c1, @c2)| +set sql_select_limit = default| +select @c1, @c2| +@c1 @c2 +12 3 +delete from t1| +drop procedure modes| +create database sp_db1| +drop database sp_db1| +create database sp_db2| +use sp_db2| +create table t3 ( s char(4), t int )| +insert into t3 values ("abcd", 42), ("dcba", 666)| +use test| +drop database sp_db2| +create database sp_db3| +use sp_db3| +drop procedure if exists dummy| +create procedure dummy(out x int) +set x = 42| +use test| +drop database sp_db3| +select routine_type, routine_schema, routine_name from information_schema.routines where routine_schema = 'sp_db3'| +ROUTINE_TYPE ROUTINE_SCHEMA ROUTINE_NAME +drop procedure if exists rc| +create procedure rc() +begin +delete from t1; +insert into t1 values ("a", 1), ("b", 2), ("c", 3); +end| +call rc()| +select row_count()| +row_count() +3 +update t1 set data=42 where id = "b"; +select row_count()| +row_count() +1 +delete from t1| +select row_count()| +row_count() +3 +delete from t1| +select row_count()| +row_count() +0 +select * from t1| +id data +select row_count()| +row_count() +-1 +drop procedure rc| +drop function if exists f0| +drop function if exists f1| +drop function if exists f2| +drop function if exists f3| +drop function if exists f4| +drop function if exists f5| +drop function if exists f6| +drop function if exists f7| +drop function if exists f8| +drop function if exists f9| +drop function if exists f10| +drop function if exists f11| +drop function if exists f12_1| +drop function if exists f12_2| +drop view if exists v0| +drop view if exists v1| +drop view if exists v2| +delete from t1| +delete from t2| +insert into t1 values ("a", 1), ("b", 2) | +insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0) | +create function f1() returns int +return (select sum(data) from t1)| +select f1()| +f1() +3 +select id, f1() from t1 order by id| +id f1() +a 3 +b 3 +create function f2() returns int +return (select data from t1 where data <= (select sum(data) from t1) order by data limit 1)| +select f2()| +f2() +1 +select id, f2() from t1 order by id| +id f2() +a 1 +b 1 +create function f3() returns int +begin +declare n int; +declare m int; +set n:= (select min(data) from t1); +set m:= (select max(data) from t1); +return n < m; +end| +select f3()| +f3() +1 +select id, f3() from t1 order by id| +id f3() +a 1 +b 1 +select f1(), f3()| +f1() f3() +3 1 +select id, f1(), f3() from t1 order by id| +id f1() f3() +a 3 1 +b 3 1 +create function f4() returns double +return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")| +select f4()| +f4() +2 +select s, f4() from t2 order by s| +s f4() +a 2 +b 2 +c 2 +create function f5(i int) returns int +begin +if i <= 0 then +return 0; +elseif i = 1 then +return (select count(*) from t1 where data = i); +else +return (select count(*) + f5( i - 1) from t1 where data = i); +end if; +end| +select f5(1)| +f5(1) +1 +select f5(2)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select f5(3)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +create function f6() returns int +begin +declare n int; +set n:= f1(); +return (select count(*) from t1 where data <= f7() and data <= n); +end| +create function f7() returns int +return (select sum(data) from t1 where data <= f1())| +select f6()| +f6() +2 +select id, f6() from t1 order by id| +id f6() +a 2 +b 2 +create view v1 (a) as select f1()| +select * from v1| +a +3 +select id, a from t1, v1 order by id| +id a +a 3 +b 3 +select * from v1, v1 as v| +a a +3 3 +create view v2 (a) as select a*10 from v1| +select * from v2| +a +30 +select id, a from t1, v2 order by id| +id a +a 30 +b 30 +select * from v1, v2| +a a +3 30 +create function f8 () returns int +return (select count(*) from v2)| +select *, f8() from v1| +a f8() +3 1 +drop function f1| +select * from v1| +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +create function f1() returns int +return (select sum(data) from t1) + (select sum(a) from v1)| +select f1()| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select * from v1| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select * from v2| +ERROR HY000: Recursive stored functions and triggers are not allowed. +drop function f1| +create function f1() returns int +return (select sum(data) from t1)| +create function f0() returns int +return (select * from (select 100) as r)| +select f0()| +f0() +100 +select *, f0() from (select 1) as t| +1 f0() +1 100 +create view v0 as select f0()| +select * from v0| +f0() +100 +select *, f0() from v0| +f0() f0() +100 100 +lock tables t1 read, t1 as t11 read| +select f3()| +f3() +1 +select id, f3() from t1 as t11 order by id| +id f3() +a 1 +b 1 +select f0()| +f0() +100 +select * from v0| +ERROR HY000: Table 'v0' was not locked with LOCK TABLES +select *, f0() from v0, (select 123) as d1| +ERROR HY000: Table 'v0' was not locked with LOCK TABLES +select id, f3() from t1| +ERROR HY000: Table 't1' was not locked with LOCK TABLES +select f4()| +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables| +create function f9() returns int +begin +declare a, b int; +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 values (1), (2), (3); +set a:= (select count(*) from t3); +set b:= (select count(*) from t3 t3_alias); +return a + b; +end| +select f9()| +f9() +6 +select f9() from t1 limit 1| +f9() +6 +create function f10() returns int +begin +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 select id from t4; +return (select count(*) from t3); +end| +select f10()| +ERROR 42S02: Table 'test.t4' doesn't exist +create table t4 as select 1 as id| +select f10()| +f10() +1 +create function f11() returns int +begin +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 values (1), (2), (3); +return (select count(*) from t3 as a, t3 as b); +end| +select f11()| +ERROR HY000: Can't reopen table: 'a' +select f11() from t1| +ERROR HY000: Can't reopen table: 'a' +create function f12_1() returns int +begin +drop temporary table if exists t3; +create temporary table t3 (id int); +insert into t3 values (1), (2), (3); +return f12_2(); +end| +create function f12_2() returns int +return (select count(*) from t3)| +drop temporary table t3| +select f12_1()| +f12_1() +3 +select f12_1() from t1 limit 1| +f12_1() +3 +drop function f0| +drop function f1| +drop function f2| +drop function f3| +drop function f4| +drop function f5| +drop function f6| +drop function f7| +drop function f8| +drop function f9| +drop function f10| +drop function f11| +drop function f12_1| +drop function f12_2| +drop view v0| +drop view v1| +drop view v2| +truncate table t1 | +truncate table t2 | +drop table t4| +drop table if exists t3| +create table t3 (n int unsigned not null primary key, f bigint unsigned)| +drop procedure if exists ifac| +create procedure ifac(n int unsigned) +begin +declare i int unsigned default 1; +if n > 20 then +set n = 20; # bigint overflow otherwise +end if; +while i <= n do +begin +insert into test.t3 values (i, fac(i)); +set i = i + 1; +end; +end while; +end| +call ifac(20)| +select * from t3| +n f +1 1 +10 3628800 +11 39916800 +12 479001600 +13 6227020800 +14 87178291200 +15 1307674368000 +16 20922789888000 +17 355687428096000 +18 6402373705728000 +19 121645100408832000 +2 2 +20 2432902008176640000 +3 6 +4 24 +5 120 +6 720 +7 5040 +8 40320 +9 362880 +drop table t3| +show function status like '%fac'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure ifac| +drop function fac| +show function status like '%fac'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +drop table if exists t3| +create table t3 ( +i int unsigned not null primary key, +p bigint unsigned not null +)| +insert into t3 values +( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13), +( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31), +(10, 37), (11, 41), (12, 43), (13, 47), (14, 53), +(15, 59), (16, 61), (17, 67), (18, 71), (19, 73), +(20, 79), (21, 83), (22, 89), (23, 97), (24, 101), +(25, 103), (26, 107), (27, 109), (28, 113), (29, 127), +(30, 131), (31, 137), (32, 139), (33, 149), (34, 151), +(35, 157), (36, 163), (37, 167), (38, 173), (39, 179), +(40, 181), (41, 191), (42, 193), (43, 197), (44, 199)| +drop procedure if exists opp| +create procedure opp(n bigint unsigned, out pp bool) +begin +declare r double; +declare b, s bigint unsigned default 0; +set r = sqrt(n); +again: +loop +if s = 45 then +set b = b+200, s = 0; +else +begin +declare p bigint unsigned; +select t.p into p from test.t3 t where t.i = s; +if b+p > r then +set pp = 1; +leave again; +end if; +if mod(n, b+p) = 0 then +set pp = 0; +leave again; +end if; +set s = s+1; +end; +end if; +end loop; +end| +drop procedure if exists ip| +create procedure ip(m int unsigned) +begin +declare p bigint unsigned; +declare i int unsigned; +set i=45, p=201; +while i < m do +begin +declare pp bool default 0; +call opp(p, pp); +if pp then +insert into test.t3 values (i, p); +set i = i+1; +end if; +set p = p+2; +end; +end while; +end| +show create procedure opp| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +opp CREATE DEFINER=`root`@`localhost` PROCEDURE `opp`(n bigint unsigned, out pp bool) +begin +declare r double; +declare b, s bigint unsigned default 0; +set r = sqrt(n); +again: +loop +if s = 45 then +set b = b+200, s = 0; +else +begin +declare p bigint unsigned; +select t.p into p from test.t3 t where t.i = s; +if b+p > r then +set pp = 1; +leave again; +end if; +if mod(n, b+p) = 0 then +set pp = 0; +leave again; +end if; +set s = s+1; +end; +end if; +end loop; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show procedure status where name like '%p%' and db='test'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call ip(200)| +select * from t3 where i=45 or i=100 or i=199| +i p +45 211 +100 557 +199 1229 +drop table t3| +drop procedure opp| +drop procedure ip| +show procedure status where name like '%p%' and db='test'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +drop procedure if exists bar| +create procedure bar(x char(16), y int) +comment "111111111111" sql security invoker +insert into test.t1 values (x, y)| +show procedure status like 'bar'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +alter procedure bar comment "2222222222" sql security definer| +alter procedure bar comment "3333333333"| +alter procedure bar| +show create procedure bar| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bar CREATE DEFINER=`root`@`localhost` PROCEDURE `bar`(x char(16), y int) + COMMENT '3333333333' +insert into test.t1 values (x, y) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show procedure status like 'bar'| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bar| +drop procedure if exists p1| +create procedure p1 () +select (select s1 from t3) from t3| +create table t3 (s1 int)| +call p1()| +(select s1 from t3) +insert into t3 values (1)| +call p1()| +(select s1 from t3) +1 +drop procedure p1| +drop table t3| +drop function if exists foo| +create function `foo` () returns int +return 5| +select `foo` ()| +`foo` () +5 +drop function `foo`| +drop function if exists t1max| +create function t1max() returns int +begin +declare x int; +select max(data) into x from t1; +return x; +end| +insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)| +select t1max()| +t1max() +5 +drop function t1max| +create table t3 ( +v char(16) not null primary key, +c int unsigned not null +)| +create function getcount(s char(16)) returns int +begin +declare x int; +select count(*) into x from t3 where v = s; +if x = 0 then +insert into t3 values (s, 1); +else +update t3 set c = c+1 where v = s; +end if; +return x; +end| +select * from t1 where data = getcount("bar")| +id data +zap 1 +select * from t3| +v c +bar 4 +select getcount("zip")| +getcount("zip") +0 +select getcount("zip")| +getcount("zip") +1 +select * from t3| +v c +bar 4 +zip 2 +select getcount(id) from t1 where data = 3| +getcount(id) +0 +select getcount(id) from t1 where data = 5| +getcount(id) +1 +select * from t3| +v c +bar 4 +foo 1 +zip 3 +drop table t3| +drop function getcount| +drop table if exists t3| +drop procedure if exists h_ee| +drop procedure if exists h_es| +drop procedure if exists h_en| +drop procedure if exists h_ew| +drop procedure if exists h_ex| +drop procedure if exists h_se| +drop procedure if exists h_ss| +drop procedure if exists h_sn| +drop procedure if exists h_sw| +drop procedure if exists h_sx| +drop procedure if exists h_ne| +drop procedure if exists h_ns| +drop procedure if exists h_nn| +drop procedure if exists h_we| +drop procedure if exists h_ws| +drop procedure if exists h_ww| +drop procedure if exists h_xe| +drop procedure if exists h_xs| +drop procedure if exists h_xx| +create table t3 (a smallint primary key)| +insert into t3 (a) values (1)| +create procedure h_ee() +deterministic +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Outer (bad)' as 'h_ee'; +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Inner (good)' as 'h_ee'; +insert into t3 values (1); +end; +end| +create procedure h_es() +deterministic +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Outer (bad)' as 'h_es'; +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' + select 'Inner (good)' as 'h_es'; +insert into t3 values (1); +end; +end| +create procedure h_en() +deterministic +begin +declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA +select 'Outer (bad)' as 'h_en'; +begin +declare x int; +declare continue handler for sqlstate '02000' -- no data +select 'Inner (good)' as 'h_en'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_ew() +deterministic +begin +declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE +select 'Outer (bad)' as 'h_ew'; +begin +declare continue handler for sqlwarning +select 'Inner (good)' as 'h_ew'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_ex() +deterministic +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Outer (bad)' as 'h_ex'; +begin +declare continue handler for sqlexception +select 'Inner (good)' as 'h_ex'; +insert into t3 values (1); +end; +end| +create procedure h_se() +deterministic +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Outer (bad)' as 'h_se'; +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Inner (good)' as 'h_se'; +insert into t3 values (1); +end; +end| +create procedure h_ss() +deterministic +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Outer (bad)' as 'h_ss'; +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Inner (good)' as 'h_ss'; +insert into t3 values (1); +end; +end| +create procedure h_sn() +deterministic +begin +-- Note: '02000' is more specific than NOT FOUND ; +-- there might be other not found states +declare continue handler for sqlstate '02000' -- no data +select 'Outer (bad)' as 'h_sn'; +begin +declare x int; +declare continue handler for not found +select 'Inner (good)' as 'h_sn'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_sw() +deterministic +begin +-- data exception - numeric value out of range +declare continue handler for sqlstate '22003' + select 'Outer (bad)' as 'h_sw'; +begin +declare continue handler for sqlwarning +select 'Inner (good)' as 'h_sw'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_sx() +deterministic +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' +select 'Outer (bad)' as 'h_sx'; +begin +declare continue handler for sqlexception +select 'Inner (good)' as 'h_sx'; +insert into t3 values (1); +end; +end| +create procedure h_ne() +deterministic +begin +declare continue handler for not found +select 'Outer (bad)' as 'h_ne'; +begin +declare x int; +declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA +select 'Inner (good)' as 'h_ne'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_ns() +deterministic +begin +declare continue handler for not found +select 'Outer (bad)' as 'h_ns'; +begin +declare x int; +declare continue handler for sqlstate '02000' -- no data +select 'Inner (good)' as 'h_ns'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_nn() +deterministic +begin +declare continue handler for not found +select 'Outer (bad)' as 'h_nn'; +begin +declare x int; +declare continue handler for not found +select 'Inner (good)' as 'h_nn'; +select a into x from t3 where a = 42; +end; +end| +create procedure h_we() +deterministic +begin +declare continue handler for sqlwarning +select 'Outer (bad)' as 'h_we'; +begin +declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE +select 'Inner (good)' as 'h_we'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_ws() +deterministic +begin +declare continue handler for sqlwarning +select 'Outer (bad)' as 'h_ws'; +begin +-- data exception - numeric value out of range +declare continue handler for sqlstate '22003' + select 'Inner (good)' as 'h_ws'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_ww() +deterministic +begin +declare continue handler for sqlwarning +select 'Outer (bad)' as 'h_ww'; +begin +declare continue handler for sqlwarning +select 'Inner (good)' as 'h_ww'; +insert into t3 values (123456789012); +end; +delete from t3; +insert into t3 values (1); +end| +create procedure h_xe() +deterministic +begin +declare continue handler for sqlexception +select 'Outer (bad)' as 'h_xe'; +begin +declare continue handler for 1062 -- ER_DUP_ENTRY +select 'Inner (good)' as 'h_xe'; +insert into t3 values (1); +end; +end| +create procedure h_xs() +deterministic +begin +declare continue handler for sqlexception +select 'Outer (bad)' as 'h_xs'; +begin +-- integrity constraint violation +declare continue handler for sqlstate '23000' + select 'Inner (good)' as 'h_xs'; +insert into t3 values (1); +end; +end| +create procedure h_xx() +deterministic +begin +declare continue handler for sqlexception +select 'Outer (bad)' as 'h_xx'; +begin +declare continue handler for sqlexception +select 'Inner (good)' as 'h_xx'; +insert into t3 values (1); +end; +end| +call h_ee()| +h_ee +Inner (good) +call h_es()| +h_es +Inner (good) +call h_en()| +h_en +Inner (good) +call h_ew()| +h_ew +Inner (good) +call h_ex()| +h_ex +Inner (good) +call h_se()| +h_se +Inner (good) +call h_ss()| +h_ss +Inner (good) +call h_sn()| +h_sn +Inner (good) +call h_sw()| +h_sw +Inner (good) +call h_sx()| +h_sx +Inner (good) +call h_ne()| +h_ne +Inner (good) +call h_ns()| +h_ns +Inner (good) +call h_nn()| +h_nn +Inner (good) +call h_we()| +h_we +Inner (good) +call h_ws()| +h_ws +Inner (good) +call h_ww()| +h_ww +Inner (good) +call h_xe()| +h_xe +Inner (good) +call h_xs()| +h_xs +Inner (good) +call h_xx()| +h_xx +Inner (good) +drop table t3| +drop procedure h_ee| +drop procedure h_es| +drop procedure h_en| +drop procedure h_ew| +drop procedure h_ex| +drop procedure h_se| +drop procedure h_ss| +drop procedure h_sn| +drop procedure h_sw| +drop procedure h_sx| +drop procedure h_ne| +drop procedure h_ns| +drop procedure h_nn| +drop procedure h_we| +drop procedure h_ws| +drop procedure h_ww| +drop procedure h_xe| +drop procedure h_xs| +drop procedure h_xx| +drop procedure if exists bug822| +create procedure bug822(a_id char(16), a_data int) +begin +declare n int; +select count(*) into n from t1 where id = a_id and data = a_data; +if n = 0 then +insert into t1 (id, data) values (a_id, a_data); +end if; +end| +delete from t1| +call bug822('foo', 42)| +call bug822('foo', 42)| +call bug822('bar', 666)| +select * from t1 order by data| +id data +foo 42 +bar 666 +delete from t1| +drop procedure bug822| +drop procedure if exists bug1495| +create procedure bug1495() +begin +declare x int; +select data into x from t1 order by id limit 1; +if x > 10 then +insert into t1 values ("less", x-10); +else +insert into t1 values ("more", x+10); +end if; +end| +insert into t1 values ('foo', 12)| +call bug1495()| +delete from t1 where id='foo'| +insert into t1 values ('bar', 7)| +call bug1495()| +delete from t1 where id='bar'| +select * from t1 order by data| +id data +less 2 +more 17 +delete from t1| +drop procedure bug1495| +drop procedure if exists bug1547| +create procedure bug1547(s char(16)) +begin +declare x int; +select data into x from t1 where s = id limit 1; +if x > 10 then +insert into t1 values ("less", x-10); +else +insert into t1 values ("more", x+10); +end if; +end| +insert into t1 values ("foo", 12), ("bar", 7)| +call bug1547("foo")| +call bug1547("bar")| +select * from t1 order by id| +id data +bar 7 +foo 12 +less 2 +more 17 +delete from t1| +drop procedure bug1547| +drop table if exists t70| +create table t70 (s1 int,s2 int)| +insert into t70 values (1,2)| +drop procedure if exists bug1656| +create procedure bug1656(out p1 int, out p2 int) +select * into p1, p1 from t70| +call bug1656(@1, @2)| +select @1, @2| +@1 @2 +2 NULL +drop table t70| +drop procedure bug1656| +create table t3(a int)| +drop procedure if exists bug1862| +create procedure bug1862() +begin +insert into t3 values(2); +flush tables; +end| +call bug1862()| +call bug1862()| +select * from t3| +a +2 +2 +drop table t3| +drop procedure bug1862| +drop procedure if exists bug1874| +create procedure bug1874() +begin +declare x int; +declare y double; +select max(data) into x from t1; +insert into t2 values ("max", x, 0); +select min(data) into x from t1; +insert into t2 values ("min", x, 0); +select sum(data) into x from t1; +insert into t2 values ("sum", x, 0); +select avg(data) into y from t1; +insert into t2 values ("avg", 0, y); +end| +insert into t1 (data) values (3), (1), (5), (9), (4)| +call bug1874()| +select * from t2 order by i| +s i d +avg 0 4.4 +min 1 0 +max 9 0 +sum 22 0 +delete from t1| +delete from t2| +drop procedure bug1874| +drop procedure if exists bug2260| +create procedure bug2260() +begin +declare v1 int; +declare c1 cursor for select data from t1; +declare continue handler for not found set @x2 = 1; +open c1; +fetch c1 into v1; +set @x2 = 2; +close c1; +end| +call bug2260()| +select @x2| +@x2 +2 +drop procedure bug2260| +drop procedure if exists bug2267_1| +create procedure bug2267_1() +begin +show procedure status where db='test'; +end| +drop procedure if exists bug2267_2| +create procedure bug2267_2() +begin +show function status where db='test'; +end| +drop procedure if exists bug2267_3| +create procedure bug2267_3() +begin +show create procedure bug2267_1; +end| +drop procedure if exists bug2267_4| +drop function if exists bug2267_4| +create procedure bug2267_4() +begin +show create function bug2267_4; +end| +create function bug2267_4() returns int return 100| +call bug2267_1()| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug2267_2()| +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug2267_3()| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug2267_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2267_1`() +begin +show procedure status where db='test'; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug2267_4()| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug2267_4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2267_4`() RETURNS int +return 100 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug2267_1| +drop procedure bug2267_2| +drop procedure bug2267_3| +drop procedure bug2267_4| +drop function bug2267_4| +drop procedure if exists bug2227| +create procedure bug2227(x int) +begin +declare y float default 2.6; +declare z char(16) default "zzz"; +select 1.3, x, y, 42, z; +end| +call bug2227(9)| +1.3 x y 42 z +1.3 9 2.6 42 zzz +drop procedure bug2227| +drop procedure if exists bug2614| +create procedure bug2614() +begin +drop table if exists t3; +create table t3 (id int default '0' not null); +insert into t3 select 12; +insert into t3 select * from t3; +end| +call bug2614()| +call bug2614()| +drop table t3| +drop procedure bug2614| +drop function if exists bug2674| +create function bug2674() returns int +return @@sort_buffer_size| +set @osbs = @@sort_buffer_size| +set @@sort_buffer_size = 262000| +select bug2674()| +bug2674() +262000 +drop function bug2674| +set @@sort_buffer_size = @osbs| +drop procedure if exists bug3259_1 | +create procedure bug3259_1 () begin end| +drop procedure if exists BUG3259_2 | +create procedure BUG3259_2 () begin end| +drop procedure if exists Bug3259_3 | +create procedure Bug3259_3 () begin end| +call BUG3259_1()| +call BUG3259_1()| +call bug3259_2()| +call Bug3259_2()| +call bug3259_3()| +call bUG3259_3()| +drop procedure bUg3259_1| +drop procedure BuG3259_2| +drop procedure BUG3259_3| +drop function if exists bug2772| +create function bug2772() returns char(10) character set latin2 +return 'a'| +select bug2772()| +bug2772() +a +drop function bug2772| +create table t3 (s1 smallint)| +insert into t3 values (123456789012)| +Warnings: +Warning 1264 Out of range value for column 's1' at row 1 +drop procedure if exists bug2780| +create procedure bug2780() +begin +declare exit handler for sqlwarning set @x = 1; +set @x = 0; +insert into t3 values (123456789012); +insert into t3 values (0); +end| +call bug2780()| +select @x| +@x +1 +select * from t3| +s1 +32767 +32767 +drop procedure bug2780| +drop table t3| +create table t3 (content varchar(10) )| +insert into t3 values ("test1")| +insert into t3 values ("test2")| +create table t4 (f1 int, rc int, t3 int)| +drop procedure if exists bug1863| +create procedure bug1863(in1 int) +begin +declare ind int default 0; +declare t1 int; +declare t2 int; +declare t3 int; +declare rc int default 0; +declare continue handler for 1065 set rc = 1; +drop temporary table if exists temp_t1; +create temporary table temp_t1 ( +f1 int auto_increment, f2 varchar(20), primary key (f1) +); +insert into temp_t1 (f2) select content from t3; +select f2 into t3 from temp_t1 where f1 = 10; +if (rc) then +insert into t4 values (1, rc, t3); +end if; +insert into t4 values (2, rc, t3); +end| +call bug1863(10)| +call bug1863(10)| +select * from t4| +f1 rc t3 +2 0 NULL +2 0 NULL +drop procedure bug1863| +drop temporary table temp_t1; +drop table t3, t4| +create table t3 ( +OrderID int not null, +MarketID int, +primary key (OrderID) +)| +create table t4 ( +MarketID int not null, +Market varchar(60), +Status char(1), +primary key (MarketID) +)| +insert t3 (OrderID,MarketID) values (1,1)| +insert t3 (OrderID,MarketID) values (2,2)| +insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")| +insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")| +drop procedure if exists bug2656_1| +create procedure bug2656_1() +begin +select +m.Market +from t4 m JOIN t3 o +ON o.MarketID != 1 and o.MarketID = m.MarketID; +end | +drop procedure if exists bug2656_2| +create procedure bug2656_2() +begin +select +m.Market +from +t4 m, t3 o +where +m.MarketID != 1 and m.MarketID = o.MarketID; +end | +call bug2656_1()| +Market +MarketID Two +call bug2656_1()| +Market +MarketID Two +call bug2656_2()| +Market +MarketID Two +call bug2656_2()| +Market +MarketID Two +drop procedure bug2656_1| +drop procedure bug2656_2| +drop table t3, t4| +drop procedure if exists bug3426| +create procedure bug3426(in_time int unsigned, out x int) +begin +if in_time is null then +set @stamped_time=10; +set x=1; +else +set @stamped_time=in_time; +set x=2; +end if; +end| +set time_zone='+03:00'; +call bug3426(1000, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +2 01-01-1970 03:16:40 +call bug3426(NULL, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +1 01-01-1970 03:00:10 +alter procedure bug3426 sql security invoker| +call bug3426(NULL, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +1 01-01-1970 03:00:10 +call bug3426(1000, @i)| +select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| +@i time +2 01-01-1970 03:16:40 +drop procedure bug3426| +create table t3 ( +id int unsigned auto_increment not null primary key, +title VARCHAR(200), +body text, +fulltext (title,body) +)| +insert into t3 (title,body) values +('MySQL Tutorial','DBMS stands for DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...')| +drop procedure if exists bug3734 | +create procedure bug3734 (param1 varchar(100)) +select * from t3 where match (title,body) against (param1)| +call bug3734('database')| +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +call bug3734('Security')| +id title body +6 MySQL Security When configured properly, MySQL ... +drop procedure bug3734| +drop table t3| +drop procedure if exists bug3863| +create procedure bug3863() +begin +set @a = 0; +while @a < 5 do +set @a = @a + 1; +end while; +end| +call bug3863()| +select @a| +@a +5 +call bug3863()| +select @a| +@a +5 +drop procedure bug3863| +create table t3 ( +id int(10) unsigned not null default 0, +rid int(10) unsigned not null default 0, +msg text not null, +primary key (id), +unique key rid (rid, id) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +drop procedure if exists bug2460_1| +create procedure bug2460_1(in v int) +begin +( select n0.id from t3 as n0 where n0.id = v ) +union +( select n0.id from t3 as n0, t3 as n1 +where n0.id = n1.rid and n1.id = v ) +union +( select n0.id from t3 as n0, t3 as n1, t3 as n2 +where n0.id = n1.rid and n1.id = n2.rid and n2.id = v ); +end| +call bug2460_1(2)| +id +call bug2460_1(2)| +id +insert into t3 values (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'zip zap')| +call bug2460_1(2)| +id +2 +1 +call bug2460_1(2)| +id +2 +1 +drop procedure if exists bug2460_2| +create procedure bug2460_2() +begin +drop table if exists t3; +create temporary table t3 (s1 int); +insert into t3 select 1 union select 1; +end| +call bug2460_2()| +call bug2460_2()| +select * from t3| +s1 +1 +drop procedure bug2460_1| +drop procedure bug2460_2| +drop table t3| +set @@sql_mode = ''| +drop procedure if exists bug2564_1| +create procedure bug2564_1() +comment 'Joe''s procedure' + insert into `t1` values ("foo", 1)| +set @@sql_mode = 'ANSI_QUOTES'| +drop procedure if exists bug2564_2| +create procedure bug2564_2() +insert into "t1" values ('foo', 1)| +set @@sql_mode = ''$ +drop function if exists bug2564_3$ +create function bug2564_3(x int, y int) returns int +return x || y$ +Warnings: +Warning 1287 '|| as a synonym for OR' is deprecated and will be removed in a future release. Please use OR instead +set @@sql_mode = 'ANSI'$ +drop function if exists bug2564_4$ +create function bug2564_4(x int, y int) returns int +return x || y$ +set @@sql_mode = ''| +show create procedure bug2564_1| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug2564_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug2564_1`() + COMMENT 'Joe''s procedure' +insert into `t1` values ("foo", 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create procedure bug2564_2| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug2564_2 ANSI_QUOTES CREATE DEFINER="root"@"localhost" PROCEDURE "bug2564_2"() +insert into "t1" values ('foo', 1) utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create function bug2564_3| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug2564_3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug2564_3`(x int, y int) RETURNS int +return x || y utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create function bug2564_4| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ONLY_FULL_GROUP_BY,ANSI CREATE DEFINER="root"@"localhost" FUNCTION "bug2564_4"(x int, y int) RETURNS int +return x || y utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug2564_1| +drop procedure bug2564_2| +drop function bug2564_3| +drop function bug2564_4| +drop function if exists bug3132| +create function bug3132(s char(20)) returns char(50) +return concat('Hello, ', s, '!')| +select bug3132('Bob') union all select bug3132('Judy')| +bug3132('Bob') +Hello, Bob! +Hello, Judy! +drop function bug3132| +drop procedure if exists bug3843| +create procedure bug3843() +analyze table t1| +call bug3843()| +Table Op Msg_type Msg_text +test.t1 analyze status OK +call bug3843()| +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +select 1+2| +1+2 +3 +drop procedure bug3843| +create table t3 ( s1 char(10) )| +insert into t3 values ('a'), ('b')| +drop procedure if exists bug3368| +create procedure bug3368(v char(10)) +begin +select group_concat(v) from t3; +end| +call bug3368('x')| +group_concat(v) +x,x +call bug3368('yz')| +group_concat(v) +yz,yz +drop procedure bug3368| +drop table t3| +create table t3 (f1 int, f2 int)| +insert into t3 values (1,1)| +drop procedure if exists bug4579_1| +create procedure bug4579_1 () +begin +declare sf1 int; +select f1 into sf1 from t3 where f1=1 and f2=1; +update t3 set f2 = f2 + 1 where f1=1 and f2=1; +call bug4579_2(); +end| +drop procedure if exists bug4579_2| +create procedure bug4579_2 () +begin +end| +call bug4579_1()| +call bug4579_1()| +call bug4579_1()| +drop procedure bug4579_1| +drop procedure bug4579_2| +drop table t3| +drop procedure if exists bug2773| +create function bug2773() returns int return null| +create table t3 as select bug2773()| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `bug2773()` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t3| +drop function bug2773| +drop procedure if exists bug3788| +create function bug3788() returns date return cast("2005-03-04" as date)| +select bug3788()| +bug3788() +2005-03-04 +drop function bug3788| +create function bug3788() returns binary(1) return 5| +select bug3788()| +bug3788() +5 +drop function bug3788| +create table t3 (f1 int, f2 int, f3 int)| +insert into t3 values (1,1,1)| +drop procedure if exists bug4726| +create procedure bug4726() +begin +declare tmp_o_id INT; +declare tmp_d_id INT default 1; +while tmp_d_id <= 2 do +begin +select f1 into tmp_o_id from t3 where f2=1 and f3=1; +set tmp_d_id = tmp_d_id + 1; +end; +end while; +end| +call bug4726()| +call bug4726()| +call bug4726()| +drop procedure bug4726| +drop table t3| +drop procedure if exists bug4902| +set SQL_BIG_SELECTS=1| +create procedure bug4902() +begin +show charset like 'foo'; +show collation like 'foo'; +show create table t1; +show create database test; +show databases like 'foo'; +show errors; +show columns from t1; +show keys from t1; +show open tables like 'foo'; +#show privileges need to be commented as its output differs on different platform +#show privileges; +show status like 'foo'; +show tables like 'foo'; +show variables like 'foo'; +show warnings; +end| +call bug4902()| +Charset Description Default collation Maxlen +Collation Charset Id Default Compiled Sortlen Pad_attribute +Table Create Table +t1 CREATE TABLE `t1` ( + `id` char(16) NOT NULL DEFAULT '', + `data` int NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +Database Create Database +test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ +Database (foo) +Level Code Message +Field Type Null Key Default Extra +id char(16) NO +data int NO NULL +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +Database Table In_use Name_locked +Variable_name Value +Tables_in_test (foo) +Variable_name Value +Level Code Message +call bug4902()| +Charset Description Default collation Maxlen +Collation Charset Id Default Compiled Sortlen Pad_attribute +Table Create Table +t1 CREATE TABLE `t1` ( + `id` char(16) NOT NULL DEFAULT '', + `data` int NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +Database Create Database +test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ +Database (foo) +Level Code Message +Field Type Null Key Default Extra +id char(16) NO +data int NO NULL +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +Database Table In_use Name_locked +Variable_name Value +Tables_in_test (foo) +Variable_name Value +Level Code Message +drop procedure bug4902| +drop procedure if exists bug4904| +create procedure bug4904() +begin +declare continue handler for sqlstate 'HY000' begin end; +create table t2 as select * from t3; +end| +call bug4904()| +ERROR 42S02: Table 'test.t3' doesn't exist +drop procedure bug4904| +create table t3 (s1 char character set latin1, s2 char character set latin2)| +drop procedure if exists bug4904| +create procedure bug4904 () +begin +declare continue handler for sqlstate 'HY000' begin end; +select s1 from t3 union select s2 from t3; +end| +call bug4904()| +drop procedure bug4904| +drop table t3| +drop procedure if exists bug336| +create procedure bug336(out y int) +begin +declare x int; +set x = (select sum(t.data) from test.t1 t); +set y = x; +end| +insert into t1 values ("a", 2), ("b", 3)| +call bug336(@y)| +select @y| +@y +5 +delete from t1| +drop procedure bug336| +drop procedure if exists bug3157| +create procedure bug3157() +begin +if exists(select * from t1) then +set @n= @n + 1; +end if; +if (select count(*) from t1) then +set @n= @n + 1; +end if; +end| +set @n = 0| +insert into t1 values ("a", 1)| +call bug3157()| +select @n| +@n +2 +delete from t1| +drop procedure bug3157| +drop procedure if exists bug5251| +create procedure bug5251() +begin +end| +select created into @c1 from information_schema.routines +where routine_schema='test' and routine_name='bug5251'| +alter procedure bug5251 comment 'foobar'| +select count(*) from information_schema.routines +where routine_schema='test' and routine_name='bug5251' and created = @c1| +count(*) +1 +drop procedure bug5251| +drop procedure if exists bug5251| +create procedure bug5251() +checksum table t1| +call bug5251()| +Table Checksum +test.t1 0 +call bug5251()| +Table Checksum +test.t1 0 +drop procedure bug5251| +drop procedure if exists bug5287| +create procedure bug5287(param1 int) +label1: +begin +declare c cursor for select 5; +loop +if param1 >= 0 then +leave label1; +end if; +end loop; +end| +call bug5287(1)| +drop procedure bug5287| +drop procedure if exists bug5307| +create procedure bug5307() +begin +end; set @x = 3| +call bug5307()| +select @x| +@x +3 +drop procedure bug5307| +drop procedure if exists bug5258| +create procedure bug5258() +begin +end| +drop procedure if exists bug5258_aux| +create procedure bug5258_aux() +begin +declare c, m char(19); +select created,last_altered into c,m from information_schema.routines where routine_name = 'bug5258'; +if c = m then +select 'Ok'; +else +select c, m; +end if; +end| +call bug5258_aux()| +Ok +Ok +drop procedure bug5258| +drop procedure bug5258_aux| +drop function if exists bug4487| +create function bug4487() returns char +begin +declare v char; +return v; +end| +select bug4487()| +bug4487() +NULL +drop function bug4487| +drop procedure if exists bug4941| +drop procedure if exists bug4941| +create procedure bug4941(out x int) +begin +declare c cursor for select i from t2 limit 1; +open c; +fetch c into x; +close c; +end| +insert into t2 values (null, null, null)| +set @x = 42| +call bug4941(@x)| +select @x| +@x +NULL +delete from t1| +drop procedure bug4941| +drop procedure if exists bug4905| +create table t3 (s1 int,primary key (s1))| +drop procedure if exists bug4905| +create procedure bug4905() +begin +declare v int; +declare continue handler for sqlstate '23000' set v = 5; +insert into t3 values (1); +end| +call bug4905()| +select row_count()| +row_count() +1 +call bug4905()| +select row_count()| +row_count() +0 +call bug4905()| +select row_count()| +row_count() +0 +select * from t3| +s1 +1 +drop procedure bug4905| +drop table t3| +drop procedure if exists bug6029| +drop procedure if exists bug6029| +create procedure bug6029() +begin +declare exit handler for 1136 select '1136'; +declare exit handler for sqlstate '23000' select 'sqlstate 23000'; +declare continue handler for sqlexception select 'sqlexception'; +insert into t3 values (1); +insert into t3 values (1,2); +end| +create table t3 (s1 int, primary key (s1))| +insert into t3 values (1)| +call bug6029()| +sqlstate 23000 +sqlstate 23000 +delete from t3| +call bug6029()| +1136 +1136 +drop procedure bug6029| +drop table t3| +drop procedure if exists bug8540| +create procedure bug8540() +begin +declare x int default 1; +select x as y, x+0 as z; +end| +call bug8540()| +y z +1 1 +drop procedure bug8540| +create table t3 (s1 int)| +drop procedure if exists bug6642| +create procedure bug6642() +select abs(count(s1)) from t3| +call bug6642()| +abs(count(s1)) +0 +call bug6642()| +abs(count(s1)) +0 +drop procedure bug6642| +insert into t3 values (0),(1)| +drop procedure if exists bug7013| +create procedure bug7013() +select s1,count(s1) from t3 group by s1 with rollup| +call bug7013()| +s1 count(s1) +0 1 +1 1 +NULL 2 +call bug7013()| +s1 count(s1) +0 1 +1 1 +NULL 2 +drop procedure bug7013| +drop table if exists t4| +create table t4 ( +a mediumint(8) unsigned not null auto_increment, +b smallint(5) unsigned not null, +c char(32) not null, +primary key (a) +) engine=myisam default charset=latin1| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t4 values (1, 2, 'oneword')| +insert into t4 values (2, 2, 'anotherword')| +drop procedure if exists bug7743| +create procedure bug7743 ( searchstring char(28) ) +begin +declare var mediumint(8) unsigned; +select a into var from t4 where b = 2 and c = binary searchstring limit 1; +show warnings; +select var; +end| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +call bug7743("oneword")| +Level Code Message +var +1 +call bug7743("OneWord")| +Level Code Message +Warning 1329 No data - zero rows fetched, selected, or processed +var +NULL +call bug7743("anotherword")| +Level Code Message +var +2 +call bug7743("AnotherWord")| +Level Code Message +Warning 1329 No data - zero rows fetched, selected, or processed +var +NULL +drop procedure bug7743| +drop table t4| +delete from t3| +insert into t3 values(1)| +drop procedure if exists bug7992_1| +Warnings: +Note 1305 PROCEDURE test.bug7992_1 does not exist +drop procedure if exists bug7992_2| +Warnings: +Note 1305 PROCEDURE test.bug7992_2 does not exist +create procedure bug7992_1() +begin +declare i int; +select max(s1)+1 into i from t3; +end| +create procedure bug7992_2() +insert into t3 (s1) select max(t4.s1)+1 from t3 as t4| +call bug7992_1()| +call bug7992_1()| +call bug7992_2()| +call bug7992_2()| +drop procedure bug7992_1| +drop procedure bug7992_2| +drop table t3| +create table t3 ( userid bigint(20) not null default 0 )| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +drop procedure if exists bug8116| +create procedure bug8116(in _userid int) +select * from t3 where userid = _userid| +call bug8116(42)| +userid +call bug8116(42)| +userid +drop procedure bug8116| +drop table t3| +drop procedure if exists bug6857| +create procedure bug6857() +begin +declare t0, t1 int; +declare plus bool default 0; +set t0 = unix_timestamp(); +select sleep(1.1); +set t1 = unix_timestamp(); +if t1 > t0 then +set plus = 1; +end if; +select plus; +end| +call bug6857()| +sleep(1.1) +0 +plus +1 +drop procedure bug6857| +drop procedure if exists bug8757| +create procedure bug8757() +begin +declare x int; +declare c1 cursor for select data from t1 limit 1; +begin +declare y int; +declare c2 cursor for select i from t2 limit 1; +open c2; +fetch c2 into y; +close c2; +select 2,y; +end; +open c1; +fetch c1 into x; +close c1; +select 1,x; +end| +delete from t1| +delete from t2| +insert into t1 values ("x", 1)| +insert into t2 values ("y", 2, 0.0)| +call bug8757()| +2 y +2 2 +1 x +1 1 +delete from t1| +delete from t2| +drop procedure bug8757| +drop procedure if exists bug8762| +drop procedure if exists bug8762; create procedure bug8762() begin end| +drop procedure if exists bug8762; create procedure bug8762() begin end| +drop procedure bug8762| +drop function if exists bug5240| +create function bug5240 () returns int +begin +declare x int; +declare c cursor for select data from t1 limit 1; +open c; +fetch c into x; +close c; +return x; +end| +delete from t1| +insert into t1 values ("answer", 42)| +select id, bug5240() from t1| +id bug5240() +answer 42 +drop function bug5240| +drop procedure if exists p1| +create table t3(id int)| +insert into t3 values(1)| +create procedure bug7992() +begin +declare i int; +select max(id)+1 into i from t3; +end| +call bug7992()| +call bug7992()| +drop procedure bug7992| +drop table t3| +create table t3 ( +lpitnumber int(11) default null, +lrecordtype int(11) default null +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t4 ( +lbsiid int(11) not null default '0', +ltradingmodeid int(11) not null default '0', +ltradingareaid int(11) not null default '0', +csellingprice decimal(19,4) default null, +primary key (lbsiid,ltradingmodeid,ltradingareaid) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t5 ( +lbsiid int(11) not null default '0', +ltradingareaid int(11) not null default '0', +primary key (lbsiid,ltradingareaid) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +drop procedure if exists bug8849| +create procedure bug8849() +begin +insert into t5 +( +t5.lbsiid, +t5.ltradingareaid +) +select distinct t3.lpitnumber, t4.ltradingareaid +from +t4 join t3 on +t3.lpitnumber = t4.lbsiid +and t3.lrecordtype = 1 +left join t4 as price01 on +price01.lbsiid = t4.lbsiid and +price01.ltradingmodeid = 1 and +t4.ltradingareaid = price01.ltradingareaid; +end| +call bug8849()| +call bug8849()| +call bug8849()| +drop procedure bug8849| +drop tables t3,t4,t5| +drop procedure if exists bug8937| +create procedure bug8937() +begin +declare s,x,y,z int; +declare a float; +select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1; +select s,x,y,z; +select avg(data) into a from t1; +select a; +end| +delete from t1| +insert into t1 (data) values (1), (2), (3), (4), (6)| +call bug8937()| +s x y z +16 3 1 6 +a +3.2 +drop procedure bug8937| +delete from t1| +drop procedure if exists bug6900| +drop procedure if exists bug9074| +drop procedure if exists bug6900_9074| +create table t3 (w char unique, x char)| +insert into t3 values ('a', 'b')| +create procedure bug6900() +begin +declare exit handler for sqlexception select '1'; +begin +declare exit handler for sqlexception select '2'; +insert into t3 values ('x', 'y', 'z'); +end; +end| +create procedure bug9074() +begin +declare x1, x2, x3, x4, x5, x6 int default 0; +begin +declare continue handler for sqlstate '23000' set x5 = 1; +insert into t3 values ('a', 'b'); +set x6 = 1; +end; +begin1_label: +begin +declare continue handler for sqlstate '23000' set x1 = 1; +insert into t3 values ('a', 'b'); +set x2 = 1; +begin2_label: +begin +declare exit handler for sqlstate '23000' set x3 = 1; +set x4= 1; +insert into t3 values ('a','b'); +set x4= 0; +end begin2_label; +end begin1_label; +select x1, x2, x3, x4, x5, x6; +end| +create procedure bug6900_9074(z int) +begin +declare exit handler for sqlstate '23000' select '23000'; +begin +declare exit handler for sqlexception select 'sqlexception'; +if z = 1 then +insert into t3 values ('a', 'b'); +else +insert into t3 values ('x', 'y', 'z'); +end if; +end; +end| +call bug6900()| +2 +2 +call bug9074()| +x1 x2 x3 x4 x5 x6 +1 1 1 1 1 1 +call bug6900_9074(0)| +sqlexception +sqlexception +call bug6900_9074(1)| +sqlexception +sqlexception +drop procedure bug6900| +drop procedure bug9074| +drop procedure bug6900_9074| +drop table t3| +drop procedure if exists avg| +create procedure avg () +begin +end| +call avg ()| +drop procedure avg| +drop procedure if exists bug6129| +set @old_mode= @@sql_mode; +set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO"; +create procedure bug6129() +select @@sql_mode| +call bug6129()| +@@sql_mode +ERROR_FOR_DIVISION_BY_ZERO +set @@sql_mode= "STRICT_ALL_TABLES,NO_ZERO_DATE"| +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +call bug6129()| +@@sql_mode +ERROR_FOR_DIVISION_BY_ZERO +set @@sql_mode= "NO_ZERO_IN_DATE"| +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +call bug6129()| +@@sql_mode +ERROR_FOR_DIVISION_BY_ZERO +set @@sql_mode=@old_mode; +drop procedure bug6129| +drop procedure if exists bug9856| +create procedure bug9856() +begin +declare v int; +declare c cursor for select data from t1; +declare exit handler for sqlexception, not found select '16'; +open c; +fetch c into v; +select v; +end| +delete from t1| +call bug9856()| +16 +16 +call bug9856()| +16 +16 +drop procedure bug9856| +drop procedure if exists bug9674_1| +drop procedure if exists bug9674_2| +create procedure bug9674_1(out arg int) +begin +declare temp_in1 int default 0; +declare temp_fl1 int default 0; +set temp_in1 = 100; +set temp_fl1 = temp_in1/10; +set arg = temp_fl1; +end| +create procedure bug9674_2() +begin +declare v int default 100; +select v/10; +end| +call bug9674_1(@sptmp)| +call bug9674_1(@sptmp)| +select @sptmp| +@sptmp +10 +call bug9674_2()| +v/10 +10.0000 +call bug9674_2()| +v/10 +10.0000 +drop procedure bug9674_1| +drop procedure bug9674_2| +drop procedure if exists bug9598_1| +drop procedure if exists bug9598_2| +create procedure bug9598_1(in var_1 char(16), +out var_2 integer, out var_3 integer) +begin +set var_2 = 50; +set var_3 = 60; +end| +create procedure bug9598_2(in v1 char(16), +in v2 integer, +in v3 integer, +in v4 integer, +in v5 integer) +begin +select v1,v2,v3,v4,v5; +call bug9598_1(v1,@tmp1,@tmp2); +select v1,v2,v3,v4,v5; +end| +call bug9598_2('Test',2,3,4,5)| +v1 v2 v3 v4 v5 +Test 2 3 4 5 +v1 v2 v3 v4 v5 +Test 2 3 4 5 +select @tmp1, @tmp2| +@tmp1 @tmp2 +50 60 +drop procedure bug9598_1| +drop procedure bug9598_2| +drop function if exists bug9102| +create function bug9102() returns blob return 'a'| +select bug9102()| +bug9102() +a +drop function bug9102| +drop function if exists bug7648| +create function bug7648() returns bit(8) return 'a'| +select bug7648()| +bug7648() +a +drop function bug7648| +drop function if exists bug9775| +create function bug9775(v1 char(1)) returns enum('a','b') return v1| +select bug9775('a'),bug9775('b'),bug9775('c')| +bug9775('a') bug9775('b') bug9775('c') +a b +Warnings: +Warning 1265 Data truncated for column 'bug9775('c')' at row 1 +drop function bug9775| +create function bug9775(v1 int) returns enum('a','b') return v1| +select bug9775(1),bug9775(2),bug9775(3)| +bug9775(1) bug9775(2) bug9775(3) +a b +Warnings: +Warning 1265 Data truncated for column 'bug9775(3)' at row 1 +drop function bug9775| +create function bug9775(v1 char(1)) returns set('a','b') return v1| +select bug9775('a'),bug9775('b'),bug9775('a,b'),bug9775('c')| +bug9775('a') bug9775('b') bug9775('a,b') bug9775('c') +a b a +Warnings: +Warning 1265 Data truncated for column 'v1' at row 1 +Warning 1265 Data truncated for column 'bug9775('c')' at row 1 +drop function bug9775| +create function bug9775(v1 int) returns set('a','b') return v1| +select bug9775(1),bug9775(2),bug9775(3),bug9775(4)| +bug9775(1) bug9775(2) bug9775(3) bug9775(4) +a b a,b +Warnings: +Warning 1265 Data truncated for column 'bug9775(4)' at row 1 +drop function bug9775| +drop function if exists bug8861| +create function bug8861(v1 int) returns year return v1| +select bug8861(05)| +bug8861(05) +2005 +set @x = bug8861(05)| +select @x| +@x +2005 +drop function bug8861| +drop procedure if exists bug9004_1| +drop procedure if exists bug9004_2| +create procedure bug9004_1(x char(16)) +begin +insert into t1 values (x, 42); +insert into t1 values (x, 17); +end| +create procedure bug9004_2(x char(16)) +call bug9004_1(x)| +call bug9004_1('12345678901234567')| +Warnings: +Warning 1265 Data truncated for column 'x' at row 1 +call bug9004_2('12345678901234567890')| +Warnings: +Warning 1265 Data truncated for column 'x' at row 1 +delete from t1| +drop procedure bug9004_1| +drop procedure bug9004_2| +drop procedure if exists bug7293| +insert into t1 values ('secret', 0)| +create procedure bug7293(p1 varchar(100)) +begin +if exists (select id from t1 where soundex(p1)=soundex(id)) then +select 'yes'; +end if; +end;| +call bug7293('secret')| +yes +yes +call bug7293 ('secrete')| +yes +yes +drop procedure bug7293| +delete from t1| +drop procedure if exists bug9841| +drop view if exists v1| +create view v1 as select * from t1, t2 where id = s| +create procedure bug9841 () +update v1 set data = 10| +call bug9841()| +drop view v1| +drop procedure bug9841| +drop procedure if exists bug5963| +create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;| +create table t3 (s1 int)| +insert into t3 values (5)| +call bug5963_1()| +v +5 +call bug5963_1()| +v +5 +drop procedure bug5963_1| +drop table t3| +create procedure bug5963_2 (cfk_value int) +begin +if cfk_value in (select cpk from t3) then +set @x = 5; +end if; +end; +| +create table t3 (cpk int)| +insert into t3 values (1)| +call bug5963_2(1)| +call bug5963_2(1)| +drop procedure bug5963_2| +drop table t3| +drop function if exists bug9559| +create function bug9559() +returns int +begin +set @y = -6/2; +return @y; +end| +select bug9559()| +bug9559() +-3 +drop function bug9559| +drop procedure if exists bug10961| +create procedure bug10961() +begin +declare v char; +declare x int; +declare c cursor for select * from dual; +declare continue handler for sqlexception select x; +set x = 1; +open c; +set x = 2; +fetch c into v; +set x = 3; +close c; +end| +call bug10961()| +x +1 +x +2 +x +3 +call bug10961()| +x +1 +x +2 +x +3 +drop procedure bug10961| +DROP PROCEDURE IF EXISTS bug6866| +DROP VIEW IF EXISTS tv| +Warnings: +Note 1051 Unknown table 'test.tv' +DROP TABLE IF EXISTS tt1,tt2,tt3| +Warnings: +Note 1051 Unknown table 'test.tt1' +Note 1051 Unknown table 'test.tt2' +Note 1051 Unknown table 'test.tt3' +CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))| +CREATE TABLE tt2 (a2 int, data2 varchar(10))| +CREATE TABLE tt3 (a3 int, data3 varchar(10))| +INSERT INTO tt1 VALUES (1, 1, 4, 'xx')| +INSERT INTO tt2 VALUES (1, 'a')| +INSERT INTO tt2 VALUES (2, 'b')| +INSERT INTO tt2 VALUES (3, 'c')| +INSERT INTO tt3 VALUES (4, 'd')| +INSERT INTO tt3 VALUES (5, 'e')| +INSERT INTO tt3 VALUES (6, 'f')| +CREATE VIEW tv AS +SELECT tt1.*, tt2.data2, tt3.data3 +FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2 +LEFT JOIN tt3 ON tt1.a3 = tt3.a3 +ORDER BY tt1.a1, tt2.a2, tt3.a3| +CREATE PROCEDURE bug6866 (_a1 int) +BEGIN +SELECT * FROM tv WHERE a1 = _a1; +END| +CALL bug6866(1)| +a1 a2 a3 data data2 data3 +1 1 4 xx a d +CALL bug6866(1)| +a1 a2 a3 data data2 data3 +1 1 4 xx a d +CALL bug6866(1)| +a1 a2 a3 data data2 data3 +1 1 4 xx a d +DROP PROCEDURE bug6866; +DROP VIEW tv| +DROP TABLE tt1, tt2, tt3| +DROP PROCEDURE IF EXISTS bug10136| +create table t3 ( name char(5) not null primary key, val float not null)| +insert into t3 values ('aaaaa', 1), ('bbbbb', 2), ('ccccc', 3)| +create procedure bug10136() +begin +declare done int default 3; +repeat +select * from t3; +set done = done - 1; +until done <= 0 end repeat; +end| +call bug10136()| +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +call bug10136()| +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +call bug10136()| +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +name val +aaaaa 1 +bbbbb 2 +ccccc 3 +drop procedure bug10136| +drop table t3| +drop procedure if exists bug11529| +create procedure bug11529() +begin +declare c cursor for select id, data from t1 where data in (10,13); +open c; +begin +declare vid char(16); +declare vdata int; +declare exit handler for not found begin end; +while true do +fetch c into vid, vdata; +end while; +end; +close c; +end| +insert into t1 values +('Name1', 10), +('Name2', 11), +('Name3', 12), +('Name4', 13), +('Name5', 14)| +call bug11529()| +call bug11529()| +delete from t1| +drop procedure bug11529| +set character set utf8| +drop procedure if exists bug6063| +drop procedure if exists bug7088_1| +drop procedure if exists bug7088_2| +create procedure bug6063() +begin +lâbel: begin end; +label: begin end; +label1: begin end; +end| +create procedure bug7088_1() +label1: begin end label1| +create procedure bug7088_2() +läbel1: begin end| +call bug6063()| +call bug7088_1()| +call bug7088_2()| +set character set default| +show create procedure bug6063| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug6063 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug6063`() +begin +lâbel: begin end; +label: begin end; +label1: begin end; +end utf8 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create procedure bug7088_1| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug7088_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug7088_1`() +label1: begin end label1 utf8 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +show create procedure bug7088_2| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug7088_2 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug7088_2`() +läbel1: begin end utf8 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug6063| +drop procedure bug7088_1| +drop procedure bug7088_2| +drop procedure if exists bug9565_sub| +drop procedure if exists bug9565| +create procedure bug9565_sub() +begin +select * from t1; +end| +create procedure bug9565() +begin +insert into t1 values ("one", 1); +call bug9565_sub(); +end| +call bug9565()| +id data +one 1 +delete from t1| +drop procedure bug9565_sub| +drop procedure bug9565| +drop procedure if exists bug9538| +create procedure bug9538() +set @@sort_buffer_size = 1000000| +set @x = @@sort_buffer_size| +set @@sort_buffer_size = 2000000| +select @@sort_buffer_size| +@@sort_buffer_size +2000000 +call bug9538()| +select @@sort_buffer_size| +@@sort_buffer_size +1000000 +set @@sort_buffer_size = @x| +drop procedure bug9538| +drop procedure if exists bug8692| +create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))| +insert into t3 values ('', '', '', '', '', '', NULL)| +Warnings: +Warning 1265 Data truncated for column 'c3' at row 1 +create procedure bug8692() +begin +declare v1 VARCHAR(10); +declare v2 VARCHAR(10); +declare v3 VARCHAR(10); +declare v4 VARCHAR(10); +declare v5 VARCHAR(10); +declare v6 VARCHAR(10); +declare v7 VARCHAR(10); +declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3; +open c8692; +fetch c8692 into v1,v2,v3,v4,v5,v6,v7; +select v1, v2, v3, v4, v5, v6, v7; +end| +call bug8692()| +v1 v2 v3 v4 v5 v6 v7 + NULL +drop procedure bug8692| +drop table t3| +drop function if exists bug10055| +create function bug10055(v char(255)) returns char(255) return lower(v)| +select t.column_name, bug10055(t.column_name) +from information_schema.columns as t +where t.table_schema = 'test' and t.table_name = 't1' +order by t.column_name| +COLUMN_NAME bug10055(t.column_name) +data data +id id +drop function bug10055| +drop procedure if exists bug12297| +create procedure bug12297(lim int) +begin +set @x = 0; +repeat +insert into t1(id,data) +values('aa', @x); +set @x = @x + 1; +until @x >= lim +end repeat; +end| +call bug12297(10)| +drop procedure bug12297| +drop function if exists f_bug11247| +drop procedure if exists p_bug11247| +create function f_bug11247(param int) +returns int +return param + 1| +create procedure p_bug11247(lim int) +begin +declare v int default 0; +while v < lim do +set v= f_bug11247(v); +end while; +end| +call p_bug11247(10)| +drop function f_bug11247| +drop procedure p_bug11247| +drop procedure if exists bug12168| +drop table if exists t3, t4| +create table t3 (a int)| +insert into t3 values (1),(2),(3),(4)| +create table t4 (a int)| +create procedure bug12168(arg1 char(1)) +begin +declare b, c integer; +if arg1 = 'a' then +begin +declare c1 cursor for select a from t3 where a % 2; +declare continue handler for not found set b = 1; +set b = 0; +open c1; +c1_repeat: repeat +fetch c1 into c; +if (b = 1) then +leave c1_repeat; +end if; +insert into t4 values (c); +until b = 1 +end repeat; +end; +end if; +if arg1 = 'b' then +begin +declare c2 cursor for select a from t3 where not a % 2; +declare continue handler for not found set b = 1; +set b = 0; +open c2; +c2_repeat: repeat +fetch c2 into c; +if (b = 1) then +leave c2_repeat; +end if; +insert into t4 values (c); +until b = 1 +end repeat; +end; +end if; +end| +call bug12168('a')| +select * from t4| +a +1 +3 +truncate t4| +call bug12168('b')| +select * from t4| +a +2 +4 +truncate t4| +call bug12168('a')| +select * from t4| +a +1 +3 +truncate t4| +call bug12168('b')| +select * from t4| +a +2 +4 +truncate t4| +drop table t3, t4| +drop procedure if exists bug12168| +drop table if exists t3| +drop procedure if exists bug11333| +create table t3 (c1 char(128))| +insert into t3 values +('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')| +create procedure bug11333(i int) +begin +declare tmp varchar(128); +set @x = 0; +repeat +select c1 into tmp from t3 +where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; +set @x = @x + 1; +until @x >= i +end repeat; +end| +call bug11333(10)| +drop procedure bug11333| +drop table t3| +drop function if exists bug9048| +create function bug9048(f1 char binary) returns char +begin +set f1= concat( 'hello', f1 ); +return f1; +end| +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +drop function bug9048| +create function bug9048(f1 char binary) returns char binary +begin +set f1= concat( 'hello', f1 ); +return f1; +end| +ERROR 42000: This version of MySQL doesn't yet support 'return value collation' +drop procedure if exists bug12849_1| +create procedure bug12849_1(inout x char) select x into x| +set @var='a'| +call bug12849_1(@var)| +select @var| +@var +a +drop procedure bug12849_1| +drop procedure if exists bug12849_2| +create procedure bug12849_2(inout foo varchar(15)) +begin +select concat(foo, foo) INTO foo; +end| +set @var='abcd'| +call bug12849_2(@var)| +select @var| +@var +abcdabcd +drop procedure bug12849_2| +drop procedure if exists bug131333| +drop function if exists bug131333| +create procedure bug131333() +begin +begin +declare a int; +select a; +set a = 1; +select a; +end; +begin +declare b int; +select b; +end; +end| +create function bug131333() +returns int +begin +begin +declare a int; +set a = 1; +end; +begin +declare b int; +return b; +end; +end| +call bug131333()| +a +NULL +a +1 +b +NULL +select bug131333()| +bug131333() +NULL +drop procedure bug131333| +drop function bug131333| +drop function if exists bug12379| +drop procedure if exists bug12379_1| +drop procedure if exists bug12379_2| +drop procedure if exists bug12379_3| +drop table if exists t3| +create table t3 (c1 char(1) primary key not null)| +create function bug12379() +returns integer +begin +insert into t3 values('X'); +insert into t3 values('X'); +return 0; +end| +create procedure bug12379_1() +begin +declare exit handler for sqlexception select 42; +select bug12379(); +END| +create procedure bug12379_2() +begin +declare exit handler for sqlexception begin end; +select bug12379(); +end| +create procedure bug12379_3() +begin +select bug12379(); +end| +select bug12379()| +ERROR 23000: Duplicate entry 'X' for key 't3.PRIMARY' +select 1| +1 +1 +call bug12379_1()| +bug12379() +42 +42 +select 2| +2 +2 +call bug12379_2()| +bug12379() +select 3| +3 +3 +call bug12379_3()| +ERROR 23000: Duplicate entry 'X' for key 't3.PRIMARY' +select 4| +4 +4 +drop function bug12379| +drop procedure bug12379_1| +drop procedure bug12379_2| +drop procedure bug12379_3| +drop table t3| +drop procedure if exists bug13124| +create procedure bug13124() +begin +declare y integer; +set @x=y; +end| +call bug13124()| +drop procedure bug13124| +drop procedure if exists bug12979_1| +create procedure bug12979_1(inout d decimal(5)) set d = d / 2| +set @bug12979_user_var = NULL| +call bug12979_1(@bug12979_user_var)| +drop procedure bug12979_1| +drop procedure if exists bug12979_2| +create procedure bug12979_2() +begin +declare internal_var decimal(5); +set internal_var= internal_var / 2; +select internal_var; +end| +call bug12979_2()| +internal_var +NULL +drop procedure bug12979_2| +drop table if exists t3| +drop procedure if exists bug6127| +create table t3 (s1 int unique)| +set @sm=@@sql_mode| +set sql_mode='traditional'| +create procedure bug6127() +begin +declare continue handler for sqlstate '23000' + begin +declare continue handler for sqlstate '22003' + insert into t3 values (0); +insert into t3 values (1000000000000000); +end; +insert into t3 values (1); +insert into t3 values (1); +end| +call bug6127()| +select * from t3| +s1 +0 +1 +call bug6127()| +ERROR 23000: Duplicate entry '0' for key 't3.s1' +select * from t3| +s1 +0 +1 +set sql_mode=@sm| +drop table t3| +drop procedure bug6127| +drop procedure if exists bug12589_1| +drop procedure if exists bug12589_2| +drop procedure if exists bug12589_3| +create procedure bug12589_1() +begin +declare spv1 decimal(3,3); +set spv1= 123.456; +set spv1 = 'test'; +create temporary table tm1 as select spv1; +show create table tm1; +drop temporary table tm1; +end| +create procedure bug12589_2() +begin +declare spv1 decimal(6,3); +set spv1= 123.456; +create temporary table tm1 as select spv1; +show create table tm1; +drop temporary table tm1; +end| +create procedure bug12589_3() +begin +declare spv1 decimal(6,3); +set spv1= -123.456; +create temporary table tm1 as select spv1; +show create table tm1; +drop temporary table tm1; +end| +call bug12589_1()| +Table Create Table +tm1 CREATE TEMPORARY TABLE `tm1` ( + `spv1` decimal(3,3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +call bug12589_2()| +Table Create Table +tm1 CREATE TEMPORARY TABLE `tm1` ( + `spv1` decimal(6,3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +call bug12589_3()| +Table Create Table +tm1 CREATE TEMPORARY TABLE `tm1` ( + `spv1` decimal(6,3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop procedure bug12589_1| +drop procedure bug12589_2| +drop procedure bug12589_3| +drop table if exists t3| +drop procedure if exists bug7049_1| +drop procedure if exists bug7049_2| +drop procedure if exists bug7049_3| +drop procedure if exists bug7049_4| +drop function if exists bug7049_1| +drop function if exists bug7049_2| +create table t3 ( x int unique )| +create procedure bug7049_1() +begin +insert into t3 values (42); +insert into t3 values (42); +end| +create procedure bug7049_2() +begin +declare exit handler for sqlexception +select 'Caught it' as 'Result'; +call bug7049_1(); +select 'Missed it' as 'Result'; +end| +create procedure bug7049_3() +call bug7049_1()| +create procedure bug7049_4() +begin +declare exit handler for sqlexception +select 'Caught it' as 'Result'; +call bug7049_3(); +select 'Missed it' as 'Result'; +end| +create function bug7049_1() +returns int +begin +insert into t3 values (42); +insert into t3 values (42); +return 42; +end| +create function bug7049_2() +returns int +begin +declare x int default 0; +declare continue handler for sqlexception +set x = 1; +set x = bug7049_1(); +return x; +end| +call bug7049_2()| +Result +Caught it +select * from t3| +x +42 +delete from t3| +call bug7049_4()| +Result +Caught it +select * from t3| +x +42 +select bug7049_2()| +bug7049_2() +1 +drop table t3| +drop procedure bug7049_1| +drop procedure bug7049_2| +drop procedure bug7049_3| +drop procedure bug7049_4| +drop function bug7049_1| +drop function bug7049_2| +drop function if exists bug13941| +drop procedure if exists bug13941| +create function bug13941(p_input_str text) +returns text +begin +declare p_output_str text; +set p_output_str = p_input_str; +set p_output_str = replace(p_output_str, 'xyzzy', 'plugh'); +set p_output_str = replace(p_output_str, 'test', 'prova'); +set p_output_str = replace(p_output_str, 'this', 'questo'); +set p_output_str = replace(p_output_str, ' a ', 'una '); +set p_output_str = replace(p_output_str, 'is', ''); +return p_output_str; +end| +create procedure bug13941(out sout varchar(128)) +begin +set sout = 'Local'; +set sout = ifnull(sout, 'DEF'); +end| +select bug13941('this is a test')| +bug13941('this is a test') +questo una prova +call bug13941(@a)| +select @a| +@a +Local +drop function bug13941| +drop procedure bug13941| +DROP PROCEDURE IF EXISTS bug13095; +DROP TABLE IF EXISTS bug13095_t1; +DROP VIEW IF EXISTS bug13095_v1; +CREATE PROCEDURE bug13095(tbl_name varchar(32)) +BEGIN +SET @str = +CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))"); +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +SET @str = +CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" ); +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +SET @str = +CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name); +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +SELECT * FROM bug13095_v1; +SET @str = +"DROP VIEW bug13095_v1"; +SELECT @str; +PREPARE stmt FROM @str; +EXECUTE stmt; +END| +CALL bug13095('bug13095_t1'); +@str +CREATE TABLE bug13095_t1(stuff char(15)) +@str +INSERT INTO bug13095_t1 VALUES('row1'),('row2'),('row3') +@str +CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM bug13095_t1 +c1 +row1 +row2 +row3 +@str +DROP VIEW bug13095_v1 +DROP PROCEDURE IF EXISTS bug13095; +DROP VIEW IF EXISTS bug13095_v1; +DROP TABLE IF EXISTS bug13095_t1; +drop function if exists bug14723| +drop procedure if exists bug14723| +/*!50003 create function bug14723() +returns bigint(20) +main_loop: begin +return 42; +end */;; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create function bug14723;; +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug14723 CREATE DEFINER=`root`@`localhost` FUNCTION `bug14723`() RETURNS bigint +main_loop: begin +return 42; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select bug14723();; +bug14723() +42 +/*!50003 create procedure bug14723() +main_loop: begin +select 42; +end */;; +show create procedure bug14723;; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug14723 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug14723`() +main_loop: begin +select 42; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call bug14723();; +42 +42 +drop function bug14723| +drop procedure bug14723| +create procedure bug14845() +begin +declare a char(255); +declare done int default 0; +declare c cursor for select count(*) from t1 where 1 = 0; +declare continue handler for sqlstate '02000' set done = 1; +open c; +repeat +fetch c into a; +if not done then +select a; +end if; +until done end repeat; +close c; +end| +call bug14845()| +a +0 +drop procedure bug14845| +drop procedure if exists bug13549_1| +drop procedure if exists bug13549_2| +CREATE PROCEDURE `bug13549_2`() +begin +call bug13549_1(); +end| +CREATE PROCEDURE `bug13549_1`() +begin +declare done int default 0; +set done= not done; +end| +CALL bug13549_2()| +drop procedure bug13549_2| +drop procedure bug13549_1| +drop function if exists bug10100f| +drop procedure if exists bug10100p| +drop procedure if exists bug10100t| +drop procedure if exists bug10100pt| +drop procedure if exists bug10100pv| +drop procedure if exists bug10100pd| +drop procedure if exists bug10100pc| +create function bug10100f(prm int) returns int +begin +if prm > 1 then +return prm * bug10100f(prm - 1); +end if; +return 1; +end| +create procedure bug10100p(prm int, inout res int) +begin +set res = res * prm; +if prm > 1 then +call bug10100p(prm - 1, res); +end if; +end| +create procedure bug10100t(prm int) +begin +declare res int; +set res = 1; +call bug10100p(prm, res); +select res; +end| +create table t3 (a int)| +insert into t3 values (0)| +create view v1 as select a from t3| +create procedure bug10100pt(level int, lim int) +begin +if level < lim then +update t3 set a=level; +FLUSH TABLES; +call bug10100pt(level+1, lim); +else +select * from t3; +end if; +end| +create procedure bug10100pv(level int, lim int) +begin +if level < lim then +update v1 set a=level; +FLUSH TABLES; +call bug10100pv(level+1, lim); +else +select * from v1; +end if; +end| +prepare stmt2 from "select * from t3;"| +create procedure bug10100pd(level int, lim int) +begin +if level < lim then +select level; +prepare stmt1 from "update t3 set a=a+2"; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +deallocate prepare stmt1; +execute stmt2; +select * from t3; +call bug10100pd(level+1, lim); +else +execute stmt2; +end if; +end| +create procedure bug10100pc(level int, lim int) +begin +declare lv int; +declare c cursor for select a from t3; +open c; +if level < lim then +select level; +fetch c into lv; +select lv; +update t3 set a=level+lv; +FLUSH TABLES; +call bug10100pc(level+1, lim); +else +select * from t3; +end if; +close c; +end| +set @@max_sp_recursion_depth=4| +select @@max_sp_recursion_depth| +@@max_sp_recursion_depth +4 +select bug10100f(3)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +select bug10100f(6)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +call bug10100t(5)| +res +120 +call bug10100pt(1,5)| +a +4 +call bug10100pv(1,5)| +a +4 +update t3 set a=1| +call bug10100pd(1,5)| +level +1 +a +7 +a +7 +level +2 +a +13 +a +13 +level +3 +a +19 +a +19 +level +4 +a +25 +a +25 +a +25 +select * from t3| +a +25 +update t3 set a=1| +call bug10100pc(1,5)| +level +1 +lv +1 +level +2 +lv +2 +level +3 +lv +4 +level +4 +lv +7 +a +11 +select * from t3| +a +11 +set @@max_sp_recursion_depth=0| +select @@max_sp_recursion_depth| +@@max_sp_recursion_depth +0 +select bug10100f(5)| +ERROR HY000: Recursive stored functions and triggers are not allowed. +call bug10100t(5)| +ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine bug10100p +deallocate prepare stmt2| +drop function bug10100f| +drop procedure bug10100p| +drop procedure bug10100t| +drop procedure bug10100pt| +drop procedure bug10100pv| +drop procedure bug10100pd| +drop procedure bug10100pc| +drop view v1| +drop procedure if exists bug13729| +drop table if exists t3| +create table t3 (s1 int, primary key (s1))| +insert into t3 values (1),(2)| +create procedure bug13729() +begin +declare continue handler for sqlexception select 55; +update t3 set s1 = 1; +end| +call bug13729()| +55 +55 +select * from t3| +s1 +1 +2 +drop procedure bug13729| +drop table t3| +drop procedure if exists bug14643_1| +drop procedure if exists bug14643_2| +create procedure bug14643_1() +begin +declare continue handler for sqlexception select 'boo' as 'Handler'; +begin +declare v int default undefined_var; +if v = 1 then +select 1; +else +select v, isnull(v); +end if; +end; +end| +create procedure bug14643_2() +begin +declare continue handler for sqlexception select 'boo' as 'Handler'; +case undefined_var +when 1 then +select 1; +else +select 2; +end case; +select undefined_var; +end| +call bug14643_1()| +Handler +boo +v isnull(v) +NULL 1 +call bug14643_2()| +Handler +boo +Handler +boo +drop procedure bug14643_1| +drop procedure bug14643_2| +drop procedure if exists bug14304| +drop table if exists t3, t4| +create table t3(a int primary key auto_increment)| +create table t4(a int primary key auto_increment)| +create procedure bug14304() +begin +insert into t3 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 set a=null; +insert into t4 select null as a; +insert into t3 set a=null; +insert into t3 set a=null; +select * from t3; +end| +call bug14304()| +a +1 +2 +3 +drop procedure bug14304| +drop table t3, t4| +drop procedure if exists bug14376| +create procedure bug14376() +begin +declare x int default x; +end| +call bug14376()| +ERROR 42S22: Unknown column 'x' in 'field list' +drop procedure bug14376| +create procedure bug14376() +begin +declare x int default 42; +begin +declare x int default x; +select x; +end; +end| +call bug14376()| +x +42 +drop procedure bug14376| +create procedure bug14376(x int) +begin +declare x int default x; +select x; +end| +call bug14376(4711)| +x +4711 +drop procedure bug14376| +drop procedure if exists bug5967| +drop table if exists t3| +create table t3 (a varchar(255)) engine=myisam| +insert into t3 (a) values ("a - table column")| +create procedure bug5967(a varchar(255)) +begin +declare i varchar(255); +declare c cursor for select a from t3; +select a; +select a from t3 into i; +select i as 'Parameter takes precedence over table column'; open c; +fetch c into i; +close c; +select i as 'Parameter takes precedence over table column in cursors'; +begin +declare a varchar(255) default 'a - local variable'; +declare c1 cursor for select a from t3; +select a as 'A local variable takes precedence over parameter'; +open c1; +fetch c1 into i; +close c1; +select i as 'A local variable takes precedence over parameter in cursors'; +begin +declare a varchar(255) default 'a - local variable in a nested compound statement'; +declare c2 cursor for select a from t3; +select a as 'A local variable in a nested compound statement takes precedence over a local variable in the outer statement'; +select a from t3 into i; +select i as 'A local variable in a nested compound statement takes precedence over table column'; +open c2; +fetch c2 into i; +close c2; +select i as 'A local variable in a nested compound statement takes precedence over table column in cursors'; +end; +end; +end| +call bug5967("a - stored procedure parameter")| +a +a - stored procedure parameter +Parameter takes precedence over table column +a - stored procedure parameter +Parameter takes precedence over table column in cursors +a - stored procedure parameter +A local variable takes precedence over parameter +a - local variable +A local variable takes precedence over parameter in cursors +a - local variable +A local variable in a nested compound statement takes precedence over a local variable in the outer statement +a - local variable in a nested compound statement +A local variable in a nested compound statement takes precedence over table column +a - local variable in a nested compound statement +A local variable in a nested compound statement takes precedence over table column in cursors +a - local variable in a nested compound statement +drop procedure bug5967| +drop procedure if exists bug13012| +create procedure bug13012() +BEGIN +REPAIR TABLE t1; +END| +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +drop procedure bug13012| +create view v1 as select * from t1| +create procedure bug13012() +BEGIN +REPAIR TABLE t1,t2,t3,v1; +OPTIMIZE TABLE t1,t2,t3,v1; +ANALYZE TABLE t1,t2,t3,v1; +END| +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair status OK +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize status OK +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze status Table is already up to date +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair status OK +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize status OK +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze status Table is already up to date +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +call bug13012()| +Table Op Msg_type Msg_text +test.t1 repair status OK +test.t2 repair status OK +test.t3 repair status OK +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +Table Op Msg_type Msg_text +test.t1 optimize status OK +test.t2 optimize status OK +test.t3 optimize status OK +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +test.t2 analyze status Table is already up to date +test.t3 analyze status Table is already up to date +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +drop procedure bug13012| +drop view v1| +select * from t1 order by data| +id data +aa 0 +aa 1 +aa 2 +aa 3 +aa 4 +aa 5 +aa 6 +aa 7 +aa 8 +aa 9 +drop schema if exists mysqltest1| +Warnings: +Note 1008 Can't drop database 'mysqltest1'; database doesn't exist +drop schema if exists mysqltest2| +Warnings: +Note 1008 Can't drop database 'mysqltest2'; database doesn't exist +drop schema if exists mysqltest3| +Warnings: +Note 1008 Can't drop database 'mysqltest3'; database doesn't exist +create schema mysqltest1| +create schema mysqltest2| +create schema mysqltest3| +use mysqltest3| +create procedure mysqltest1.p1 (out prequestid varchar(100)) +begin +call mysqltest2.p2('call mysqltest3.p3(1, 2)'); +end| +create procedure mysqltest2.p2(in psql text) +begin +declare lsql text; +set @lsql= psql; +prepare lstatement from @lsql; +execute lstatement; +deallocate prepare lstatement; +end| +create procedure mysqltest3.p3(in p1 int) +begin +select p1; +end| +call mysqltest1.p1(@rs)| +ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2 +call mysqltest1.p1(@rs)| +ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2 +call mysqltest1.p1(@rs)| +ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2 +drop schema if exists mysqltest1| +drop schema if exists mysqltest2| +drop schema if exists mysqltest3| +use test| +drop table if exists t3| +drop procedure if exists bug15441| +create table t3 (id int not null primary key, county varchar(25))| +insert into t3 (id, county) values (1, 'York')| +create procedure bug15441(c varchar(25)) +begin +update t3 set id=2, county=values(c); +end| +call bug15441('county')| +ERROR 42S22: Unknown column 'c' in 'field list' +drop procedure bug15441| +create procedure bug15441(county varchar(25)) +begin +declare c varchar(25) default "hello"; +insert into t3 (id, county) values (1, county) +on duplicate key update county= values(county); +select * from t3; +update t3 set id=2, county=values(id); +select * from t3; +end| +call bug15441('Yale')| +id county +1 Yale +id county +2 NULL +drop table t3| +drop procedure bug15441| +drop procedure if exists bug14498_1| +drop procedure if exists bug14498_2| +drop procedure if exists bug14498_3| +drop procedure if exists bug14498_4| +drop procedure if exists bug14498_5| +create procedure bug14498_1() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +if v then +select 'yes' as 'v'; +else +select 'no' as 'v'; +end if; +select 'done' as 'End'; +end| +create procedure bug14498_2() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +while v do +select 'yes' as 'v'; +end while; +select 'done' as 'End'; +end| +create procedure bug14498_3() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +repeat +select 'maybe' as 'v'; +until v end repeat; +select 'done' as 'End'; +end| +create procedure bug14498_4() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +case v +when 1 then +select '1' as 'v'; +when 2 then +select '2' as 'v'; +else +select '?' as 'v'; +end case; +select 'done' as 'End'; +end| +create procedure bug14498_5() +begin +declare continue handler for sqlexception select 'error' as 'Handler'; +case +when v = 1 then +select '1' as 'v'; +when v = 2 then +select '2' as 'v'; +else +select '?' as 'v'; +end case; +select 'done' as 'End'; +end| +call bug14498_1()| +Handler +error +End +done +call bug14498_2()| +Handler +error +End +done +call bug14498_3()| +v +maybe +Handler +error +End +done +call bug14498_4()| +Handler +error +End +done +call bug14498_5()| +Handler +error +End +done +drop procedure bug14498_1| +drop procedure bug14498_2| +drop procedure bug14498_3| +drop procedure bug14498_4| +drop procedure bug14498_5| +drop table if exists t3| +drop procedure if exists bug15231_1| +drop procedure if exists bug15231_2| +drop procedure if exists bug15231_3| +drop procedure if exists bug15231_4| +drop procedure if exists bug15231_5| +drop procedure if exists bug15231_6| +create table t3 (id int not null)| +create procedure bug15231_1() +begin +declare xid integer; +declare xdone integer default 0; +declare continue handler for not found set xdone = 1; +set xid=null; +call bug15231_2(xid); +select xid, xdone; +end| +create procedure bug15231_2(inout ioid integer) +begin +select "Before NOT FOUND condition is triggered" as '1'; +select id into ioid from t3 where id=ioid; +select "After NOT FOUND condtition is triggered" as '2'; +if ioid is null then +set ioid=1; +end if; +end| +create procedure bug15231_3() +begin +declare exit handler for sqlwarning +select 'Caught it (correct)' as 'Result'; +call bug15231_4(); +end| +create procedure bug15231_4() +begin +declare x decimal(2,1); +set x = 'zap'; +select 'Missed it (correct)' as 'Result'; +show warnings; +end| +create procedure bug15231_5() +begin +declare exit handler for sqlwarning +select 'Caught it (wrong)' as 'Result'; +call bug15231_6(); +end| +create procedure bug15231_6() +begin +declare x decimal(2,1); +set x = 'zap'; +select 'Missed it (correct)' as 'Result'; +select id from t3; +end| +call bug15231_1()| +1 +Before NOT FOUND condition is triggered +2 +After NOT FOUND condtition is triggered +xid xdone +1 0 +call bug15231_3()| +Result +Missed it (correct) +Level Code Message +call bug15231_5()| +Result +Missed it (correct) +id +drop table t3| +drop procedure bug15231_1| +drop procedure bug15231_2| +drop procedure bug15231_3| +drop procedure bug15231_4| +drop procedure bug15231_5| +drop procedure bug15231_6| +drop procedure if exists bug15011| +create table t3 (c1 int primary key)| +insert into t3 values (1)| +create procedure bug15011() +deterministic +begin +declare continue handler for 1062 +select 'Outer' as 'Handler'; +begin +declare continue handler for 1062 +select 'Inner' as 'Handler'; +insert into t3 values (1); +end; +end| +call bug15011()| +Handler +Inner +drop procedure bug15011| +drop table t3| +drop procedure if exists bug17476| +create table t3 ( d date )| +insert into t3 values +( '2005-01-01' ), ( '2005-01-02' ), ( '2005-01-03' ), +( '2005-01-04' ), ( '2005-02-01' ), ( '2005-02-02' )| +create procedure bug17476(pDateFormat varchar(10)) +select date_format(t3.d, pDateFormat), count(*) +from t3 +group by date_format(t3.d, pDateFormat)| +call bug17476('%Y-%m')| +date_format(t3.d, pDateFormat) count(*) +2005-01 4 +2005-02 2 +call bug17476('%Y-%m')| +date_format(t3.d, pDateFormat) count(*) +2005-01 4 +2005-02 2 +drop table t3| +drop procedure bug17476| +drop table if exists t3| +drop procedure if exists bug16887| +create table t3 ( c varchar(1) )| +insert into t3 values +(' '),('.'),(';'),(','),('-'),('_'),('('),(')'),('/'),('\\')| +create procedure bug16887() +begin +declare i int default 10; +again: +while i > 0 do +begin +declare breakchar varchar(1); +declare done int default 0; +declare t3_cursor cursor for select c from t3; +declare continue handler for not found set done = 1; +set i = i - 1; +select i; +if i = 3 then +iterate again; +end if; +open t3_cursor; +loop +fetch t3_cursor into breakchar; +if done = 1 then +begin +close t3_cursor; +iterate again; +end; +end if; +end loop; +end; +end while; +end| +call bug16887()| +i +9 +i +8 +i +7 +i +6 +i +5 +i +4 +i +3 +i +2 +i +1 +i +0 +drop table t3| +drop procedure bug16887| +drop procedure if exists bug16474_1| +drop procedure if exists bug16474_2| +delete from t1| +insert into t1 values ('c', 2), ('b', 3), ('a', 1)| +create procedure bug16474_1() +begin +declare x int; +select id from t1 order by x, id; +end| +drop procedure if exists bug14945| +create table t3 (id int not null auto_increment primary key)| +create procedure bug14945() deterministic truncate t3| +insert into t3 values (null)| +call bug14945()| +insert into t3 values (null)| +select * from t3| +id +1 +drop table t3| +drop procedure bug14945| +create procedure bug16474_2(x int) +select id from t1 order by x, id| +call bug16474_1()| +id +a +b +c +call bug16474_2(1)| +id +a +b +c +call bug16474_2(2)| +id +a +b +c +drop procedure bug16474_1| +drop procedure bug16474_2| +set @x = 2| +select * from t1 order by @x, data| +id data +a 1 +c 2 +b 3 +delete from t1| +drop function if exists bug15728| +drop table if exists t3| +create table t3 ( +id int not null auto_increment, +primary key (id) +)| +create function bug15728() returns int(11) +return last_insert_id()| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t3 values (0)| +select last_insert_id()| +last_insert_id() +1 +select bug15728()| +bug15728() +1 +drop function bug15728| +drop table t3| +drop procedure if exists bug18787| +create procedure bug18787() +begin +declare continue handler for sqlexception begin end; +select no_such_function(); +end| +call bug18787()| +drop procedure bug18787| +create database bug18344_012345678901| +use bug18344_012345678901| +create procedure bug18344() begin end| +create procedure bug18344_2() begin end| +create database bug18344_0123456789012| +use bug18344_0123456789012| +create procedure bug18344() begin end| +create procedure bug18344_2() begin end| +use test| +select schema_name from information_schema.schemata where +schema_name like 'bug18344%'| +SCHEMA_NAME +bug18344_012345678901 +bug18344_0123456789012 +select routine_name,routine_schema from information_schema.routines where +routine_schema like 'bug18344%'| +ROUTINE_NAME ROUTINE_SCHEMA +bug18344 bug18344_012345678901 +bug18344 bug18344_0123456789012 +bug18344_2 bug18344_012345678901 +bug18344_2 bug18344_0123456789012 +drop database bug18344_012345678901| +drop database bug18344_0123456789012| +select schema_name from information_schema.schemata where +schema_name like 'bug18344%'| +SCHEMA_NAME +select routine_name,routine_schema from information_schema.routines where +routine_schema like 'bug18344%'| +ROUTINE_NAME ROUTINE_SCHEMA +drop function if exists bug12472| +create function bug12472() returns int return (select count(*) from t1)| +create table t3 as select bug12472() as i| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `i` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3| +i +0 +drop table t3| +create view v1 as select bug12472() as j| +create table t3 as select * from v1| +show create table t3| +Table Create Table +t3 CREATE TABLE `t3` ( + `j` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from t3| +j +0 +drop table t3| +drop view v1| +drop function bug12472| +DROP FUNCTION IF EXISTS bug18589_f1| +DROP PROCEDURE IF EXISTS bug18589_p1| +DROP PROCEDURE IF EXISTS bug18589_p2| +CREATE FUNCTION bug18589_f1(arg TEXT) RETURNS TEXT +BEGIN +RETURN CONCAT(arg, ""); +END| +CREATE PROCEDURE bug18589_p1(arg TEXT, OUT ret TEXT) +BEGIN +SET ret = CONCAT(arg, ""); +END| +CREATE PROCEDURE bug18589_p2(arg TEXT) +BEGIN +DECLARE v TEXT; +CALL bug18589_p1(arg, v); +SELECT v; +END| +SELECT bug18589_f1(REPEAT("a", 767))| +bug18589_f1(REPEAT("a", 767)) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +SET @bug18589_v1 = ""| +CALL bug18589_p1(REPEAT("a", 767), @bug18589_v1)| +SELECT @bug18589_v1| +@bug18589_v1 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +CALL bug18589_p2(REPEAT("a", 767))| +v +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP FUNCTION bug18589_f1| +DROP PROCEDURE bug18589_p1| +DROP PROCEDURE bug18589_p2| +DROP FUNCTION IF EXISTS bug18037_f1| +DROP PROCEDURE IF EXISTS bug18037_p1| +DROP PROCEDURE IF EXISTS bug18037_p2| +CREATE FUNCTION bug18037_f1() RETURNS INT +BEGIN +RETURN @@server_id; +END| +CREATE PROCEDURE bug18037_p1() +BEGIN +DECLARE v INT DEFAULT @@server_id; +END| +CREATE PROCEDURE bug18037_p2() +BEGIN +CASE @@server_id +WHEN -1 THEN +SELECT 0; +ELSE +SELECT 1; +END CASE; +END| +SELECT bug18037_f1()| +bug18037_f1() +1 +CALL bug18037_p1()| +CALL bug18037_p2()| +1 +1 +DROP FUNCTION bug18037_f1| +DROP PROCEDURE bug18037_p1| +DROP PROCEDURE bug18037_p2| +use test| +create table t3 (i int)| +insert into t3 values (1), (2)| +create database mysqltest1| +use mysqltest1| +create function bug17199() returns varchar(2) deterministic return 'ok'| +use test| +select *, mysqltest1.bug17199() from t3| +i mysqltest1.bug17199() +1 ok +2 ok +use mysqltest1| +create function bug18444(i int) returns int no sql deterministic return i + 1| +use test| +select mysqltest1.bug18444(i) from t3| +mysqltest1.bug18444(i) +2 +3 +drop database mysqltest1| +create database mysqltest1 charset=utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create database mysqltest2 charset=utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create procedure mysqltest1.p1() +begin +-- alters the default collation of database test +alter database character set koi8r; +end| +use mysqltest1| +call p1()| +show create database mysqltest1| +Database Create Database +mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET koi8r */ /*!80016 DEFAULT ENCRYPTION='N' */ +show create database mysqltest2| +Database Create Database +mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET utf8 */ /*!80016 DEFAULT ENCRYPTION='N' */ +alter database mysqltest1 character set utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +use mysqltest2| +call mysqltest1.p1()| +show create database mysqltest1| +Database Create Database +mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET koi8r */ /*!80016 DEFAULT ENCRYPTION='N' */ +show create database mysqltest2| +Database Create Database +mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET utf8 */ /*!80016 DEFAULT ENCRYPTION='N' */ +drop database mysqltest1| +drop database mysqltest2| +use test| +drop table if exists t3| +drop procedure if exists bug15217| +create table t3 as select 1| +create procedure bug15217() +begin +declare var1 char(255); +declare cur1 cursor for select * from t3; +open cur1; +fetch cur1 into var1; +select concat('data was: /', var1, '/'); +close cur1; +end | +call bug15217()| +concat('data was: /', var1, '/') +data was: /1/ +flush tables | +call bug15217()| +concat('data was: /', var1, '/') +data was: /1/ +drop table t3| +drop procedure bug15217| +DROP PROCEDURE IF EXISTS bug21013 | +CREATE PROCEDURE bug21013(IN lim INT) +BEGIN +DECLARE i INT DEFAULT 0; +WHILE (i < lim) DO +SET @b = LOCATE(_latin1'b', @a, 1); +SET i = i + 1; +END WHILE; +END | +SET @a = _latin2"aaaaaaaaaa" | +CALL bug21013(10) | +DROP PROCEDURE bug21013 | +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +use mysqltest1| +CREATE FUNCTION bug16211_f1() RETURNS CHAR(10) +RETURN ""| +CREATE FUNCTION bug16211_f2() RETURNS CHAR(10) CHARSET koi8r +RETURN ""| +CREATE FUNCTION mysqltest2.bug16211_f3() RETURNS CHAR(10) +RETURN ""| +CREATE FUNCTION mysqltest2.bug16211_f4() RETURNS CHAR(10) CHARSET koi8r +RETURN ""| +SHOW CREATE FUNCTION bug16211_f1| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION bug16211_f2| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f3| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f4| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"| +DTD_IDENTIFIER +char(10) +SELECT CHARSET(bug16211_f1())| +CHARSET(bug16211_f1()) +utf8mb3 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT CHARSET(bug16211_f2())| +CHARSET(bug16211_f2()) +koi8r +SELECT CHARSET(mysqltest2.bug16211_f3())| +CHARSET(mysqltest2.bug16211_f3()) +utf8mb3 +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +SELECT CHARSET(mysqltest2.bug16211_f4())| +CHARSET(mysqltest2.bug16211_f4()) +koi8r +ALTER DATABASE mysqltest1 CHARACTER SET cp1251| +ALTER DATABASE mysqltest2 CHARACTER SET cp1251| +SHOW CREATE FUNCTION bug16211_f1| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION bug16211_f2| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f3| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8 +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SHOW CREATE FUNCTION mysqltest2.bug16211_f4| +Function sql_mode Create Function character_set_client collation_connection Database Collation +bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r +RETURN "" utf8mb4 utf8mb4_0900_ai_ci utf8_general_ci +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"| +DTD_IDENTIFIER +char(10) +SELECT dtd_identifier +FROM INFORMATION_SCHEMA.ROUTINES +WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"| +DTD_IDENTIFIER +char(10) +SELECT CHARSET(bug16211_f1())| +CHARSET(bug16211_f1()) +utf8mb3 +SELECT CHARSET(bug16211_f2())| +CHARSET(bug16211_f2()) +koi8r +SELECT CHARSET(mysqltest2.bug16211_f3())| +CHARSET(mysqltest2.bug16211_f3()) +utf8mb3 +SELECT CHARSET(mysqltest2.bug16211_f4())| +CHARSET(mysqltest2.bug16211_f4()) +koi8r +use test| +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +use mysqltest1| +CREATE PROCEDURE bug16676_p1( +IN p1 CHAR(10), +INOUT p2 CHAR(10), +OUT p3 CHAR(10)) +BEGIN +SELECT CHARSET(p1), COLLATION(p1); +SELECT CHARSET(p2), COLLATION(p2); +SELECT CHARSET(p3), COLLATION(p3); +END| +CREATE PROCEDURE bug16676_p2( +IN p1 CHAR(10) CHARSET koi8r, +INOUT p2 CHAR(10) CHARSET cp1251, +OUT p3 CHAR(10) CHARSET greek) +BEGIN +SELECT CHARSET(p1), COLLATION(p1); +SELECT CHARSET(p2), COLLATION(p2); +SELECT CHARSET(p3), COLLATION(p3); +END| +SET @v2 = 'b'| +SET @v3 = 'c'| +CALL bug16676_p1('a', @v2, @v3)| +CHARSET(p1) COLLATION(p1) +utf8mb3 utf8_general_ci +CHARSET(p2) COLLATION(p2) +utf8mb3 utf8_general_ci +CHARSET(p3) COLLATION(p3) +utf8mb3 utf8_general_ci +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CALL bug16676_p2('a', @v2, @v3)| +CHARSET(p1) COLLATION(p1) +koi8r koi8r_general_ci +CHARSET(p2) COLLATION(p2) +cp1251 cp1251_general_ci +CHARSET(p3) COLLATION(p3) +greek greek_general_ci +use test| +DROP DATABASE mysqltest1| +drop table if exists t3| +drop table if exists t4| +drop procedure if exists bug8153_subselect| +drop procedure if exists bug8153_subselect_a| +drop procedure if exists bug8153_subselect_b| +drop procedure if exists bug8153_proc_a| +drop procedure if exists bug8153_proc_b| +create table t3 (a int)| +create table t4 (a int)| +insert into t3 values (1), (1), (2), (3)| +insert into t4 values (1), (1)| +create procedure bug8153_subselect() +begin +declare continue handler for sqlexception +begin +select 'statement failed'; +end; +update t3 set a=a+1 where (select a from t4 where a=1) is null; +select 'statement after update'; +end| +call bug8153_subselect()| +statement failed +statement failed +statement after update +statement after update +select * from t3| +a +1 +1 +2 +3 +call bug8153_subselect()| +statement failed +statement failed +statement after update +statement after update +select * from t3| +a +1 +1 +2 +3 +drop procedure bug8153_subselect| +create procedure bug8153_subselect_a() +begin +declare continue handler for sqlexception +begin +select 'in continue handler'; +end; +select 'reachable code a1'; +call bug8153_subselect_b(); +select 'reachable code a2'; +end| +create procedure bug8153_subselect_b() +begin +select 'reachable code b1'; +update t3 set a=a+1 where (select a from t4 where a=1) is null; +select 'unreachable code b2'; +end| +call bug8153_subselect_a()| +reachable code a1 +reachable code a1 +reachable code b1 +reachable code b1 +in continue handler +in continue handler +reachable code a2 +reachable code a2 +select * from t3| +a +1 +1 +2 +3 +call bug8153_subselect_a()| +reachable code a1 +reachable code a1 +reachable code b1 +reachable code b1 +in continue handler +in continue handler +reachable code a2 +reachable code a2 +select * from t3| +a +1 +1 +2 +3 +drop procedure bug8153_subselect_a| +drop procedure bug8153_subselect_b| +create procedure bug8153_proc_a() +begin +declare continue handler for sqlexception +begin +select 'in continue handler'; +end; +select 'reachable code a1'; +call bug8153_proc_b(); +select 'reachable code a2'; +end| +create procedure bug8153_proc_b() +begin +select 'reachable code b1'; +select no_such_function(); +select 'unreachable code b2'; +end| +call bug8153_proc_a()| +reachable code a1 +reachable code a1 +reachable code b1 +reachable code b1 +in continue handler +in continue handler +reachable code a2 +reachable code a2 +drop procedure bug8153_proc_a| +drop procedure bug8153_proc_b| +drop table t3| +drop table t4| +drop procedure if exists bug19862| +CREATE TABLE t11 (a INT)| +CREATE TABLE t12 (a INT)| +CREATE FUNCTION bug19862(x INT) RETURNS INT +BEGIN +INSERT INTO t11 VALUES (x); +RETURN x+1; +END| +INSERT INTO t12 VALUES (1), (2)| +SELECT bug19862(a) FROM t12 ORDER BY 1| +bug19862(a) +2 +3 +SELECT * FROM t11| +a +1 +2 +DROP TABLE t11, t12| +DROP FUNCTION bug19862| +drop table if exists t3| +drop database if exists mysqltest1| +create table t3 (a int)| +insert into t3 (a) values (1), (2)| +create database mysqltest1| +use mysqltest1| +drop database mysqltest1| +select database()| +database() +NULL +select * from (select 1 as a) as t1 natural join (select * from test.t3) as t2| +a +1 +use test| +drop table t3| +DROP PROCEDURE IF EXISTS bug16899_p1| +DROP FUNCTION IF EXISTS bug16899_f1| +CREATE DEFINER=1234567890abcdefGHIKLsdafdsjakfhkshfkshsndvkjsddngjhasdkjghskahfdksjhcnsndkhjkghskjfjsdhfkhskfdhksjdhfkjshfksh@localhost PROCEDURE bug16899_p1() +BEGIN +SET @a = 1; +END| +ERROR HY000: String '1234567890abcdefGHIKLsdafdsjakfhkshfkshsndvkjsddngjhasdkjghskahfdksjhc' is too long for user name (should be no longer than 32) +CREATE DEFINER=some_user_name@host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890X +FUNCTION bug16899_f1() RETURNS INT +BEGIN +RETURN 1; +END| +ERROR HY000: String 'host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij12345' is too long for host name (should be no longer than 255) +drop procedure if exists bug21416| +create procedure bug21416() show create procedure bug21416| +call bug21416()| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`() +show create procedure bug21416 utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure bug21416| +DROP PROCEDURE IF EXISTS bug21414| +CREATE PROCEDURE bug21414() SELECT 1| +FLUSH TABLES WITH READ LOCK| +DROP PROCEDURE bug21414| +ERROR HY000: Can't execute the query because you have a conflicting read lock +UNLOCK TABLES| +The following should succeed. +DROP PROCEDURE bug21414| +CREATE TABLE t3 ( +Member_ID varchar(15) NOT NULL, +PRIMARY KEY (Member_ID) +)| +CREATE TABLE t4 ( +ID int(10) unsigned NOT NULL auto_increment, +Member_ID varchar(15) NOT NULL default '', +Action varchar(12) NOT NULL, +Action_Date datetime NOT NULL, +Track varchar(15) default NULL, +User varchar(12) default NULL, +Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update +CURRENT_TIMESTAMP, +PRIMARY KEY (ID), +KEY Action (Action), +KEY Action_Date (Action_Date) +)| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3(Member_ID) VALUES +('111111'), ('222222'), ('333333'), ('444444'), ('555555'), ('666666')| +INSERT INTO t4(Member_ID, Action, Action_Date, Track) VALUES +('111111', 'Disenrolled', '2006-03-01', 'CAD' ), +('111111', 'Enrolled', '2006-03-01', 'CAD' ), +('111111', 'Disenrolled', '2006-07-03', 'CAD' ), +('222222', 'Enrolled', '2006-03-07', 'CAD' ), +('222222', 'Enrolled', '2006-03-07', 'CHF' ), +('222222', 'Disenrolled', '2006-08-02', 'CHF' ), +('333333', 'Enrolled', '2006-03-01', 'CAD' ), +('333333', 'Disenrolled', '2006-03-01', 'CAD' ), +('444444', 'Enrolled', '2006-03-01', 'CAD' ), +('555555', 'Disenrolled', '2006-03-01', 'CAD' ), +('555555', 'Enrolled', '2006-07-21', 'CAD' ), +('555555', 'Disenrolled', '2006-03-01', 'CHF' ), +('666666', 'Enrolled', '2006-02-09', 'CAD' ), +('666666', 'Enrolled', '2006-05-12', 'CHF' ), +('666666', 'Disenrolled', '2006-06-01', 'CAD' )| +DROP FUNCTION IF EXISTS bug21493| +CREATE FUNCTION bug21493(paramMember VARCHAR(15)) RETURNS varchar(45) +BEGIN +DECLARE tracks VARCHAR(45); +SELECT GROUP_CONCAT(Track SEPARATOR ', ') INTO tracks FROM t4 +WHERE Member_ID=paramMember AND Action='Enrolled' AND +(Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t4 +WHERE Member_ID=paramMember GROUP BY Track); +RETURN tracks; +END| +SELECT bug21493('111111')| +bug21493('111111') +NULL +SELECT bug21493('222222')| +bug21493('222222') +CAD +SELECT bug21493(Member_ID) FROM t3| +bug21493(Member_ID) +NULL +CAD +CAD +CAD +CAD +CHF +DROP FUNCTION bug21493| +DROP TABLE t3,t4| +drop function if exists func_20028_a| +drop function if exists func_20028_b| +drop function if exists func_20028_c| +drop procedure if exists proc_20028_a| +drop procedure if exists proc_20028_b| +drop procedure if exists proc_20028_c| +drop table if exists table_20028| +create table table_20028 (i int)| +SET @save_sql_mode=@@sql_mode| +SET sql_mode=''| +create function func_20028_a() returns integer +begin +declare temp integer; +select i into temp from table_20028 limit 1; +return ifnull(temp, 0); +end| +create function func_20028_b() returns integer +begin +return func_20028_a(); +end| +create function func_20028_c() returns integer +begin +declare div_zero integer; +set SQL_MODE='TRADITIONAL'; +select 1/0 into div_zero; +return div_zero; +end| +create procedure proc_20028_a() +begin +declare temp integer; +select i into temp from table_20028 limit 1; +end| +create procedure proc_20028_b() +begin +call proc_20028_a(); +end| +create procedure proc_20028_c() +begin +declare div_zero integer; +set SQL_MODE='TRADITIONAL'; +select 1/0 into div_zero; +end| +select func_20028_a()| +func_20028_a() +0 +select func_20028_b()| +func_20028_b() +0 +select func_20028_c()| +ERROR 22012: Division by 0 +call proc_20028_a()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_b()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_c()| +ERROR 22012: Division by 0 +SET sql_mode='TRADITIONAL'| +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| +create function func_20028_a() returns integer +begin +declare temp integer; +select i into temp from table_20028 limit 1; +return ifnull(temp, 0); +end| +create function func_20028_b() returns integer +begin +return func_20028_a(); +end| +create function func_20028_c() returns integer +begin +declare div_zero integer; +set SQL_MODE=''; +select 1/0 into div_zero; +return div_zero; +end| +create procedure proc_20028_a() +begin +declare temp integer; +select i into temp from table_20028 limit 1; +end| +create procedure proc_20028_b() +begin +call proc_20028_a(); +end| +create procedure proc_20028_c() +begin +declare div_zero integer; +set SQL_MODE=''; +select 1/0 into div_zero; +end| +select func_20028_a()| +func_20028_a() +0 +select func_20028_b()| +func_20028_b() +0 +select func_20028_c()| +func_20028_c() +NULL +call proc_20028_a()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_b()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_c()| +SET @@sql_mode=@save_sql_mode| +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| +drop table table_20028| +drop procedure if exists proc_21462_a| +drop procedure if exists proc_21462_b| +create procedure proc_21462_a() +begin +select "Called A"; +end| +create procedure proc_21462_b(x int) +begin +select "Called B"; +end| +call proc_21462_a| +Called A +Called A +call proc_21462_a()| +Called A +Called A +call proc_21462_a(1)| +ERROR 42000: Incorrect number of arguments for PROCEDURE test.proc_21462_a; expected 0, got 1 +call proc_21462_b| +ERROR 42000: Incorrect number of arguments for PROCEDURE test.proc_21462_b; expected 1, got 0 +call proc_21462_b()| +ERROR 42000: Incorrect number of arguments for PROCEDURE test.proc_21462_b; expected 1, got 0 +call proc_21462_b(1)| +Called B +Called B +drop procedure proc_21462_a| +drop procedure proc_21462_b| +drop table if exists t3| +drop procedure if exists proc_bug19733| +create table t3 (s1 int)| +create procedure proc_bug19733() +begin +declare v int default 0; +while v < 100 do +create index i on t3 (s1); +drop index i on t3; +set v = v + 1; +end while; +end| +call proc_bug19733()| +call proc_bug19733()| +call proc_bug19733()| +drop procedure proc_bug19733| +drop table t3| +DROP PROCEDURE IF EXISTS p1| +DROP VIEW IF EXISTS v1, v2| +DROP TABLE IF EXISTS t3, t4| +CREATE TABLE t3 (t3_id INT)| +INSERT INTO t3 VALUES (0)| +INSERT INTO t3 VALUES (1)| +CREATE TABLE t4 (t4_id INT)| +INSERT INTO t4 VALUES (2)| +CREATE VIEW v1 AS +SELECT t3.t3_id, t4.t4_id +FROM t3 JOIN t4 ON t3.t3_id = 0| +CREATE VIEW v2 AS +SELECT t3.t3_id AS t3_id_1, v1.t3_id AS t3_id_2, v1.t4_id +FROM t3 LEFT JOIN v1 ON t3.t3_id = 0| +CREATE PROCEDURE p1() SELECT * FROM v2| +CALL p1()| +t3_id_1 t3_id_2 t4_id +0 0 2 +1 NULL NULL +CALL p1()| +t3_id_1 t3_id_2 t4_id +0 0 2 +1 NULL NULL +DROP PROCEDURE p1| +DROP VIEW v1, v2| +DROP TABLE t3, t4| +End of 5.0 tests +Begin of 5.1 tests +drop function if exists pi; +create function pi() returns varchar(50) +return "pie, my favorite desert."; +Warnings: +Note 1585 This function 'pi' has the same name as a native function +SET @save_sql_mode=@@sql_mode; +SET SQL_MODE='IGNORE_SPACE'; +select pi(), pi (); +pi() pi () +3.141593 3.141593 +select test.pi(), test.pi (); +test.pi() test.pi () +pie, my favorite desert. pie, my favorite desert. +SET SQL_MODE=''; +select pi(), pi (); +pi() pi () +3.141593 3.141593 +select test.pi(), test.pi (); +test.pi() test.pi () +pie, my favorite desert. pie, my favorite desert. +SET @@sql_mode=@save_sql_mode; +drop function pi; +drop function if exists test.database; +drop function if exists test.current_user; +drop function if exists test.md5; +create database nowhere; +use nowhere; +drop database nowhere; +SET @save_sql_mode=@@sql_mode; +SET SQL_MODE='IGNORE_SPACE'; +select database(), database (); +database() database () +NULL NULL +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +SET SQL_MODE=''; +select database(), database (); +database() database () +NULL NULL +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +use test; +create function `database`() returns varchar(50) +return "Stored function database"; +Warnings: +Note 1585 This function 'database' has the same name as a native function +create function `current_user`() returns varchar(50) +return "Stored function current_user"; +Warnings: +Note 1585 This function 'current_user' has the same name as a native function +create function md5(x varchar(50)) returns varchar(50) +return "Stored function md5"; +Warnings: +Note 1585 This function 'md5' has the same name as a native function +SET SQL_MODE='IGNORE_SPACE'; +select database(), database (); +database() database () +test test +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +select test.database(), test.database (); +test.database() test.database () +Stored function database Stored function database +select test.current_user(), test.current_user (); +test.current_user() test.current_user () +Stored function current_user Stored function current_user +select test.md5("aaa"), test.md5 ("aaa"); +test.md5("aaa") test.md5 ("aaa") +Stored function md5 Stored function md5 +SET SQL_MODE=''; +select database(), database (); +database() database () +test test +select current_user(), current_user (); +current_user() current_user () +root@localhost root@localhost +select md5("aaa"), md5 ("aaa"); +md5("aaa") md5 ("aaa") +47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808 +select test.database(), test.database (); +test.database() test.database () +Stored function database Stored function database +select test.current_user(), test.current_user (); +test.current_user() test.current_user () +Stored function current_user Stored function current_user +select test.md5("aaa"), test.md5 ("aaa"); +test.md5("aaa") test.md5 ("aaa") +Stored function md5 Stored function md5 +SET @@sql_mode=@save_sql_mode; +drop function test.database; +drop function test.current_user; +drop function md5; +use test; +End of 5.1 tests +DROP TABLE IF EXISTS bug23760| +DROP TABLE IF EXISTS bug23760_log| +DROP PROCEDURE IF EXISTS bug23760_update_log| +DROP PROCEDURE IF EXISTS bug23760_test_row_count| +DROP FUNCTION IF EXISTS bug23760_rc_test| +CREATE TABLE bug23760 ( +id INT NOT NULL AUTO_INCREMENT , +num INT NOT NULL , +PRIMARY KEY ( id ) +)| +CREATE TABLE bug23760_log ( +id INT NOT NULL AUTO_INCREMENT , +reason VARCHAR(50)NULL , +ammount INT NOT NULL , +PRIMARY KEY ( id ) +)| +CREATE PROCEDURE bug23760_update_log(r Varchar(50), a INT) +BEGIN +INSERT INTO bug23760_log (reason, ammount) VALUES(r, a); +END| +CREATE PROCEDURE bug23760_test_row_count() +BEGIN +UPDATE bug23760 SET num = num + 1; +CALL bug23760_update_log('Test is working', ROW_COUNT()); +UPDATE bug23760 SET num = num - 1; +END| +CREATE PROCEDURE bug23760_test_row_count2(level INT) +BEGIN +IF level THEN +UPDATE bug23760 SET num = num + 1; +CALL bug23760_update_log('Test2 is working', ROW_COUNT()); +CALL bug23760_test_row_count2(level - 1); +END IF; +END| +CREATE FUNCTION bug23760_rc_test(in_var INT) RETURNS INT RETURN in_var| +INSERT INTO bug23760 (num) VALUES (0), (1), (1), (2), (3), (5), (8)| +SELECT ROW_COUNT()| +ROW_COUNT() +7 +CALL bug23760_test_row_count()| +SELECT * FROM bug23760_log ORDER BY id| +id reason ammount +1 Test is working 7 +SET @save_max_sp_recursion= @@max_sp_recursion_depth| +SELECT @save_max_sp_recursion| +@save_max_sp_recursion +0 +SET max_sp_recursion_depth= 5| +SELECT @@max_sp_recursion_depth| +@@max_sp_recursion_depth +5 +CALL bug23760_test_row_count2(2)| +SELECT ROW_COUNT()| +ROW_COUNT() +1 +SELECT * FROM bug23760_log ORDER BY id| +id reason ammount +1 Test is working 7 +2 Test2 is working 7 +3 Test2 is working 7 +SELECT * FROM bug23760 ORDER by ID| +id num +1 2 +2 3 +3 3 +4 4 +5 5 +6 7 +7 10 +SET max_sp_recursion_depth= @save_max_sp_recursion| +SELECT bug23760_rc_test(123)| +bug23760_rc_test(123) +123 +INSERT INTO bug23760 (num) VALUES (13), (21), (34), (55)| +SELECT bug23760_rc_test(ROW_COUNT())| +bug23760_rc_test(ROW_COUNT()) +4 +DROP TABLE bug23760, bug23760_log| +DROP PROCEDURE bug23760_update_log| +DROP PROCEDURE bug23760_test_row_count| +DROP PROCEDURE bug23760_test_row_count2| +DROP FUNCTION bug23760_rc_test| +DROP PROCEDURE IF EXISTS bug24117| +DROP TABLE IF EXISTS t3| +CREATE TABLE t3(c1 ENUM('abc'))| +INSERT INTO t3 VALUES('abc')| +CREATE PROCEDURE bug24117() +BEGIN +DECLARE t3c1 ENUM('abc'); +DECLARE mycursor CURSOR FOR SELECT c1 FROM t3; +OPEN mycursor; +FLUSH TABLES; +FETCH mycursor INTO t3c1; +CLOSE mycursor; +END| +CALL bug24117()| +DROP PROCEDURE bug24117| +DROP TABLE t3| +drop function if exists func_8407_a| +drop function if exists func_8407_b| +create function func_8407_a() returns int +begin +declare x int; +declare continue handler for sqlexception +begin +end; +select 1 from no_such_view limit 1 into x; +return x; +end| +create function func_8407_b() returns int +begin +declare x int default 0; +declare continue handler for sqlstate '42S02' + begin +set x:= x+1000; +end; +case (select 1 from no_such_view limit 1) +when 1 then set x:= x+1; +when 2 then set x:= x+2; +else set x:= x+100; +end case; +set x:=x + 500; +return x; +end| +select func_8407_a()| +func_8407_a() +NULL +select func_8407_b()| +func_8407_b() +1500 +drop function func_8407_a| +drop function func_8407_b| +drop table if exists table_26503| +drop procedure if exists proc_26503_ok_1| +drop procedure if exists proc_26503_ok_2| +drop procedure if exists proc_26503_ok_3| +drop procedure if exists proc_26503_ok_4| +create table table_26503(a int unique)| +create procedure proc_26503_ok_1(v int) +begin +declare i int default 5; +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +iterate retry; +select 'dead code'; +end; +end while retry; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end| +create procedure proc_26503_ok_2(v int) +begin +declare i int default 5; +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +leave retry; +select 'dead code'; +end; +end while; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end| +create procedure proc_26503_ok_3(v int) +begin +declare i int default 5; +retry: +begin +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +iterate retry; +select 'dead code'; +end; +end while retry; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end; +end| +create procedure proc_26503_ok_4(v int) +begin +declare i int default 5; +retry: +begin +declare continue handler for sqlexception +begin +select 'caught something'; +retry: +while i > 0 do +begin +set i = i - 1; +select 'looping', i; +leave retry; +select 'dead code'; +end; +end while; +select 'leaving handler'; +end; +select 'do something'; +insert into table_26503 values (v); +select 'do something again'; +insert into table_26503 values (v); +end; +end| +call proc_26503_ok_1(1)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +looping i +looping 3 +looping i +looping 2 +looping i +looping 1 +looping i +looping 0 +leaving handler +leaving handler +call proc_26503_ok_2(2)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +leaving handler +leaving handler +call proc_26503_ok_3(3)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +looping i +looping 3 +looping i +looping 2 +looping i +looping 1 +looping i +looping 0 +leaving handler +leaving handler +call proc_26503_ok_4(4)| +do something +do something +do something again +do something again +caught something +caught something +looping i +looping 4 +leaving handler +leaving handler +drop table table_26503| +drop procedure proc_26503_ok_1| +drop procedure proc_26503_ok_2| +drop procedure proc_26503_ok_3| +drop procedure proc_26503_ok_4| +DROP FUNCTION IF EXISTS bug25373| +CREATE FUNCTION bug25373(p1 INTEGER) RETURNS INTEGER +LANGUAGE SQL DETERMINISTIC +RETURN p1;| +CREATE TABLE t3 (f1 INT, f2 FLOAT)| +INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)| +SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP| +SUM(f2) bug25373(f1) +6.300000071525574 1 +15 2 +21.300000071525574 NULL +DROP FUNCTION bug25373| +DROP TABLE t3| +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +CREATE DATABASE mysqltest1| +CREATE DATABASE mysqltest2| +CREATE PROCEDURE mysqltest1.p1() +DROP DATABASE mysqltest2| +use mysqltest2| +CALL mysqltest1.p1()| +Warnings: +Note 1049 Unknown database 'mysqltest2' +SELECT DATABASE()| +DATABASE() +NULL +DROP DATABASE mysqltest1| +use test| +drop function if exists bug20777| +drop table if exists examplebug20777| +create function bug20777(f1 bigint unsigned) returns bigint unsigned +begin +set f1 = (f1 - 10); set f1 = (f1 + 10); +return f1; +end| +select bug20777(9223372036854775803) as '9223372036854775803 2**63-5'; +9223372036854775803 2**63-5 +9223372036854775803 +select bug20777(9223372036854775804) as '9223372036854775804 2**63-4'; +9223372036854775804 2**63-4 +9223372036854775804 +select bug20777(9223372036854775805) as '9223372036854775805 2**63-3'; +9223372036854775805 2**63-3 +9223372036854775805 +select bug20777(9223372036854775806) as '9223372036854775806 2**63-2'; +9223372036854775806 2**63-2 +9223372036854775806 +select bug20777(9223372036854775807) as '9223372036854775807 2**63-1'; +9223372036854775807 2**63-1 +9223372036854775807 +select bug20777(9223372036854775808) as '9223372036854775808 2**63+0'; +9223372036854775808 2**63+0 +9223372036854775808 +select bug20777(9223372036854775809) as '9223372036854775809 2**63+1'; +9223372036854775809 2**63+1 +9223372036854775809 +select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; +9223372036854775810 2**63+2 +9223372036854775810 +select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(f1@0 - 10)' +select bug20777(9223372036854775807) as 'upper bounds signed bigint'; +upper bounds signed bigint +9223372036854775807 +select bug20777(0) as 'lower bounds unsigned bigint'; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(f1@0 - 10)' +select bug20777(18446744073709551615) as 'upper bounds unsigned bigint'; +upper bounds unsigned bigint +18446744073709551615 +select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1'; +upper bounds unsigned bigint + 1 +18446744073709551615 +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +select bug20777(-1) as 'lower bounds unsigned bigint - 1'; +ERROR 22003: BIGINT UNSIGNED value is out of range in '(f1@0 - 10)' +create table examplebug20777 as select +0 as 'i', +bug20777(9223372036854775806) as '2**63-2', +bug20777(9223372036854775807) as '2**63-1', +bug20777(9223372036854775808) as '2**63', +bug20777(9223372036854775809) as '2**63+1', +bug20777(18446744073709551614) as '2**64-2', +bug20777(18446744073709551615) as '2**64-1', +bug20777(18446744073709551616) as '2**64'; +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616); +show create table examplebug20777; +Table Create Table +examplebug20777 CREATE TABLE `examplebug20777` ( + `i` int NOT NULL DEFAULT '0', + `2**63-2` bigint unsigned DEFAULT NULL, + `2**63-1` bigint unsigned DEFAULT NULL, + `2**63` bigint unsigned DEFAULT NULL, + `2**63+1` bigint unsigned DEFAULT NULL, + `2**64-2` bigint unsigned DEFAULT NULL, + `2**64-1` bigint unsigned DEFAULT NULL, + `2**64` bigint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select * from examplebug20777 order by i; +i 2**63-2 2**63-1 2**63 2**63+1 2**64-2 2**64-1 2**64 +0 9223372036854775806 9223372036854775807 9223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 18446744073709551615 +1 9223372036854775806 9223372036854775807 223372036854775808 9223372036854775809 18446744073709551614 18446744073709551615 8446744073709551616 +drop table examplebug20777; +select bug20777(18446744073709551613)+1; +bug20777(18446744073709551613)+1 +18446744073709551614 +drop function bug20777; +DROP FUNCTION IF EXISTS bug5274_f1| +DROP FUNCTION IF EXISTS bug5274_f2| +CREATE FUNCTION bug5274_f1(p1 CHAR) RETURNS CHAR +RETURN CONCAT(p1, p1)| +CREATE FUNCTION bug5274_f2() RETURNS CHAR +BEGIN +DECLARE v1 INT DEFAULT 0; +DECLARE v2 CHAR DEFAULT 'x'; +WHILE v1 < 30 DO +SET v1 = v1 + 1; +SET v2 = bug5274_f1(v2); +END WHILE; +RETURN v2; +END| +SELECT bug5274_f2()| +bug5274_f2() +x +DROP FUNCTION bug5274_f1| +DROP FUNCTION bug5274_f2| +drop procedure if exists proc_21513| +create procedure proc_21513()`my_label`:BEGIN END| +show create procedure proc_21513| +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_21513 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_21513`() +`my_label`:BEGIN END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +drop procedure proc_21513| +End of 5.0 tests. +drop table t1,t2; +CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM; +CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb; +set @a=0; +CREATE function bug27354() RETURNS int not deterministic +begin +insert into t1 values (null); +set @a=@a+1; +return @a; +end| +update t2 set b=1 where a=bug27354(); +select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */; +count(t_1.a) count(t_2.a) +0 0 +insert into t2 values (1,1),(2,2),(3,3); +update t2 set b=-b where a=bug27354(); +select * from t2 /* must return 1,-1 ... */; +a b +1 -1 +2 -2 +3 -3 +select count(*) from t1 /* must be 3 */; +count(*) +3 +drop table t1,t2; +drop function bug27354; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12; +CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`metered`(`t1`.`a`) AS `metered` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP FUNCTION metered; +DROP TABLE t1; +SET @p1_p2_cnt= 2; +CREATE TABLE t1 (c1 INT); +CREATE VIEW v1 AS SELECT * FROM t1; +PREPARE s1 FROM 'SELECT c1 FROM v1'; +EXECUTE s1; +c1 +EXECUTE s1; +c1 +CREATE PROCEDURE p1(IN loops BIGINT(19) UNSIGNED) +BEGIN +WHILE loops > 0 DO +SELECT c1 FROM v1; +SET loops = loops - 1; +END WHILE; +END| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE PROCEDURE p2(IN loops BIGINT(19) UNSIGNED) +BEGIN +WHILE loops > 0 DO +SELECT c1 FROM v1; +CALL p1(@p1_p2_cnt); +SET loops = loops - 1; +END WHILE; +END| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE FUNCTION f1(loops INT UNSIGNED) +RETURNS INT +BEGIN +DECLARE tmp INT; +WHILE loops > 0 DO +SELECT c1 INTO tmp FROM v1; +SET loops = loops - 1; +END WHILE; +RETURN loops; +END| +CALL p1(2); +c1 +c1 +CALL p2(2); +c1 +c1 +c1 +c1 +c1 +c1 +SELECT f1(2); +f1(2) +0 +PREPARE s1 FROM 'SELECT f1(2)'; +EXECUTE s1; +f1(2) +0 +EXECUTE s1; +f1(2) +0 +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP FUNCTION f1; +DROP VIEW v1; +DROP TABLE t1; +create database mysqltest_db1; +create procedure mysqltest_db1.sp_bug28551() begin end; +call mysqltest_db1.sp_bug28551(); +show warnings; +Level Code Message +drop database mysqltest_db1; +drop database if exists mysqltest_db1; +drop table if exists test.t1; +create database mysqltest_db1; +use mysqltest_db1; +drop database mysqltest_db1; +create table test.t1 (id int); +insert into test.t1 (id) values (1); +create procedure test.sp_bug29050() begin select * from t1; end// +show warnings; +Level Code Message +call test.sp_bug29050(); +id +1 +show warnings; +Level Code Message +use test; +drop procedure sp_bug29050; +drop table t1; +SET NAMES latin1; +CREATE PROCEDURE p1() +BEGIN +DECLARE INT; +SELECT ; +END| +CALL p1(); + +NULL +SET NAMES default; +DROP PROCEDURE p1; +drop procedure if exists proc_25411_a; +drop procedure if exists proc_25411_b; +drop procedure if exists proc_25411_c; +create procedure proc_25411_a() +begin +/* real comment */ +select 1; +/*! select 2; */ +select 3; +/*!00000 select 4; */ +/*!99999 select 5; */ +end +$$ +create procedure proc_25411_b( +/* real comment */ +/*! p1 int, */ +/*!00000 p2 int */ +/*!99999 ,p3 int */ +) +begin +select p1, p2; +end +$$ +create procedure proc_25411_c() +begin +select 1/*!,2*//*!00000,3*//*!99999,4*/; +select 1/*! ,2*//*!00000 ,3*//*!99999 ,4*/; +select 1/*!,2 *//*!00000,3 *//*!99999,4 */; +select 1/*! ,2 *//*!00000 ,3 *//*!99999 ,4 */; +select 1 /*!,2*/ /*!00000,3*/ /*!99999,4*/ ; +end +$$ +show create procedure proc_25411_a; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_25411_a CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_a`() +begin +/* real comment */ +select 1; + select 2; +select 3; + select 4; + +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call proc_25411_a(); +1 +1 +2 +2 +3 +3 +4 +4 +show create procedure proc_25411_b; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_25411_b CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_b`( +/* real comment */ + p1 int, + p2 int + +) +begin +select p1, p2; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select routine_name, routine_definition from information_schema.routines where routine_name like '%25411%'; +ROUTINE_NAME ROUTINE_DEFINITION + + select 2; + select 4; +/* real comment */ +end +end +end +proc_25411_a begin +proc_25411_b begin +proc_25411_c begin +select 1 ,2 ,3 ; +select 1 ,2 ,3 ; +select 1 ,2 ,3 ; +select 1,2 ,3 ; +select 1,2 ,3 ; +select 1; +select 3; +select p1, p2; +select parameter_name from information_schema.parameters where SPECIFIC_NAME= '%25411%'; +PARAMETER_NAME +call proc_25411_b(10, 20); +p1 p2 +10 20 +show create procedure proc_25411_c; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_25411_c CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_25411_c`() +begin +select 1,2 ,3 ; +select 1 ,2 ,3 ; +select 1,2 ,3 ; +select 1 ,2 ,3 ; +select 1 ,2 ,3 ; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +call proc_25411_c(); +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +1 2 3 +drop procedure proc_25411_a; +drop procedure proc_25411_b; +drop procedure proc_25411_c; +drop procedure if exists proc_26302; +create procedure proc_26302() +select 1 /* testing */; +show create procedure proc_26302; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +proc_26302 CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_26302`() +select 1 /* testing */ utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES +where ROUTINE_NAME = "proc_26302"; +ROUTINE_NAME ROUTINE_DEFINITION +proc_26302 select 1 /* testing */ +drop procedure proc_26302; +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC RETURN 2; +CREATE FUNCTION f2(I INT) RETURNS INT DETERMINISTIC RETURN 3; +CREATE TABLE t1 (c1 INT, INDEX(c1)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE VIEW v1 AS SELECT c1 FROM t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE c1=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = 1) +EXPLAIN SELECT * FROM t1 WHERE c1=f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f1`()) +EXPLAIN SELECT * FROM v1 WHERE c1=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = 1) +EXPLAIN SELECT * FROM v1 WHERE c1=f1(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f1`()) +EXPLAIN SELECT * FROM t1 WHERE c1=f2(10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref c1 c1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f2`(10)) +EXPLAIN SELECT * FROM t1 WHERE c1=f2(c1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c1 5 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f2`(`test`.`t1`.`c1`)) +EXPLAIN SELECT * FROM t1 WHERE c1=f2(rand()); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c1 5 NULL 5 20.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (`test`.`t1`.`c1` = `f2`(rand())) +DROP VIEW v1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP TABLE t1; +create function f1() +returns int(11) +not deterministic +contains sql +sql security definer +comment '' +begin +declare x int(11); +set x=-1; +return x; +end| +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create view v1 as select 1 as one, f1() as days; +show create view test.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select 1 AS `one`,`f1`() AS `days` utf8mb4 utf8mb4_0900_ai_ci +select column_name from information_schema.columns +where table_name='v1' and table_schema='test' order by column_name; +COLUMN_NAME +days +one +drop view v1; +drop function f1; + +# Bug#13675. + +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP TABLE IF EXISTS t1; + +CREATE PROCEDURE p1(v DATETIME) CREATE TABLE t1 SELECT v; +CREATE PROCEDURE p2(v INT) CREATE TABLE t1 SELECT v; + +CALL p1(NOW()); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +CALL p1('text'); +Warnings: +Warning 1265 Data truncated for column 'v' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +CALL p2(10); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +CALL p2('text'); +Warnings: +Warning 1366 Incorrect integer value: 'text' for column 'v' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci + +DROP TABLE t1; + +DROP PROCEDURE p1; +DROP PROCEDURE p2; + +# +# Bug#31035. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; + +# +# - Create required objects. +# + +CREATE TABLE t1(c1 INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f2(p INT) +RETURNS INT +NOT DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f3() +RETURNS INT +DETERMINISTIC +RETURN 1; + +CREATE FUNCTION f4(p INT) +RETURNS INT +DETERMINISTIC +RETURN 1; + +# +# - Check. +# + +SELECT f1() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f2(@a) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f3() AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(0) AS a FROM t1 GROUP BY a; +a +1 + +SELECT f4(@a) AS a FROM t1 GROUP BY a; +a +1 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; + +# +# Bug#31191. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode INT(8) UNSIGNED ZEROFILL nOT NULL, +PRIMARY KEY (id), +UNIQUE KEY barcode (barcode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. + +INSERT INTO t1 (id, barcode) VALUES (1, 12345678); +INSERT INTO t1 (id, barcode) VALUES (2, 12345679); + +CREATE TABLE test.t2 ( +id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, +PRIMARY KEY (id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. + +INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); +INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); + +CREATE FUNCTION f1(p INT(8)) +RETURNS BIGINT(11) UNSIGNED +READS SQL DATA +RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. + +# +# - Check. +# + +SELECT DISTINCT t1.barcode, f1(t1.barcode) +FROM t1 +INNER JOIN t2 +ON f1(t1.barcode) = t2.barcode +WHERE t1.barcode=12345678; +barcode f1(t1.barcode) +12345678 12345106708 + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP TABLE t2; +DROP FUNCTION f1; + +# +# Bug#31226. +# + +# +# - Prepare. +# + +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; + +# +# - Create required objects. +# + +CREATE TABLE t1(id INT); + +INSERT INTO t1 VALUES (1), (2), (3); + +CREATE FUNCTION f1() +RETURNS DATETIME +NOT DETERMINISTIC NO SQL +RETURN NOW(); + +# +# - Check. +# + +SELECT f1() FROM t1 GROUP BY 1; +f1() + + +# +# - Cleanup. +# + +DROP TABLE t1; +DROP FUNCTION f1; + +DROP PROCEDURE IF EXISTS db28318_a.t1; +DROP PROCEDURE IF EXISTS db28318_b.t2; +DROP DATABASE IF EXISTS db28318_a; +DROP DATABASE IF EXISTS db28318_b; +CREATE DATABASE db28318_a; +CREATE DATABASE db28318_b; +CREATE PROCEDURE db28318_a.t1() SELECT "db28318_a.t1"; +CREATE PROCEDURE db28318_b.t2() CALL t1(); +use db28318_a; +CALL db28318_b.t2(); +ERROR 42000: PROCEDURE db28318_b.t1 does not exist +DROP PROCEDURE db28318_a.t1; +DROP PROCEDURE db28318_b.t2; +DROP DATABASE db28318_a; +DROP DATABASE db28318_b; +use test; +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS bug29770; +CREATE TABLE t1(a int); +CREATE PROCEDURE bug29770() +BEGIN +DECLARE CONTINUE HANDLER FOR SQLSTATE '42S22' SET @state:= 'run'; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @exception:= 'run'; +SELECT x FROM t1; +END| +CALL bug29770(); +SELECT @state, @exception; +@state @exception +run NULL +DROP TABLE t1; +DROP PROCEDURE bug29770; +use test; +drop table if exists t_33618; +drop procedure if exists proc_33618; +create table t_33618 (`a` int, unique(`a`), `b` varchar(30)) engine=myisam; +insert into t_33618 (`a`,`b`) values (1,'1'),(2,'2'); +create procedure proc_33618(num int) +begin +declare count1 int default '0'; +declare vb varchar(30); +declare last_row int; +while(num>=1) do +set num=num-1; +begin +declare cur1 cursor for select `a` from t_33618; +declare continue handler for not found set last_row = 1; +set last_row:=0; +open cur1; +rep1: +repeat +begin +declare exit handler for 1062 begin end; +fetch cur1 into vb; +if (last_row = 1) then +leave rep1; +end if; +end; +until last_row=1 +end repeat; +close cur1; +end; +end while; +end// +call proc_33618(20); +drop table t_33618; +drop procedure proc_33618; +# +# Bug#30787: Stored function ignores user defined alias. +# +use test; +drop function if exists func30787; +create table t1(f1 int); +insert into t1 values(1),(2); +create function func30787(p1 int) returns int +begin +return p1; +end | +select (select func30787(f1)) as ttt from t1; +ttt +1 +2 +drop function func30787; +drop table t1; +CREATE TABLE t1 (id INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +CREATE PROCEDURE test_sp() +SELECT t1.* FROM t1 RIGHT JOIN t1 t2 ON t1.id=t2.id; +CALL test_sp(); +id +1 +2 +3 +4 +CALL test_sp(); +id +1 +2 +3 +4 +DROP PROCEDURE test_sp; +DROP TABLE t1; +create table t1(c1 INT); +create function f1(p1 int) returns varchar(32) +return 'aaa'; +create view v1 as select f1(c1) as parent_control_name from t1; +create procedure p1() +begin +select parent_control_name as c1 from v1; +end // +call p1(); +c1 +call p1(); +c1 +drop procedure p1; +drop function f1; +drop view v1; +drop table t1; +drop procedure if exists `p2` $ +create procedure `p2`(in `a` text charset utf8) +begin +declare `pos` int default 1; +declare `str` text charset utf8; +set `str` := `a`; +select substr(`str`, `pos`+ 1 ) into `str`; +end $ +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +call `p2`('s s s s s s'); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +drop procedure `p2`; +drop table if exists t1; +drop procedure if exists p1; +create procedure p1() begin select * from t1; end$ +call p1$ +ERROR 42S02: Table 'test.t1' doesn't exist +create table t1 (a integer)$ +call p1$ +a +alter table t1 add b integer; +call p1$ +a b +drop table t1; +drop procedure p1; +# ------------------------------------------------------------------ +# -- End of 5.0 tests +# ------------------------------------------------------------------ + +# +# Bug#20550. +# + +# +# - Prepare. +# + +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; + +# +# - Create required objects. +# + +CREATE FUNCTION f1() RETURNS VARCHAR(65525) RETURN 'Hello'; +Warnings: +Note 1246 Converting column '' from VARCHAR to TEXT + +CREATE FUNCTION f2() RETURNS TINYINT RETURN 1; + +CREATE VIEW v1 AS SELECT f1(); + +CREATE VIEW v2 AS SELECT f2(); + +# +# - Check. +# + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; +DATA_TYPE +mediumtext + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v2'; +DATA_TYPE +tinyint + +# +# - Cleanup. +# + +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP VIEW v1; +DROP VIEW v2; + +# +# - Bug#24923: prepare. +# + +DROP FUNCTION IF EXISTS f1; + +# +# - Bug#24923: create required objects. +# + +CREATE FUNCTION f1(p INT) +RETURNS ENUM ('Very_long_enum_element_identifier', +'Another_very_long_enum_element_identifier') +BEGIN +CASE p +WHEN 1 THEN +RETURN 'Very_long_enum_element_identifier'; +ELSE +RETURN 'Another_very_long_enum_element_identifier'; +END CASE; +END| + +# +# - Bug#24923: check. +# + +SELECT f1(1); +f1(1) +Very_long_enum_element_identifier + +SELECT f1(2); +f1(2) +Another_very_long_enum_element_identifier + +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(p INT) RETURNS enum('Very_long_enum_element_identifier','Another_very_long_enum_element_identifier') CHARSET utf8mb4 +BEGIN +CASE p +WHEN 1 THEN +RETURN 'Very_long_enum_element_identifier'; +ELSE +RETURN 'Another_very_long_enum_element_identifier'; +END CASE; +END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +# +# - Bug#24923: cleanup. +# + +DROP FUNCTION f1; + +drop procedure if exists p; +set @old_mode= @@sql_mode; +set @@sql_mode= cast(pow(2,33)-1 as unsigned integer) & ~0x1003ff00; +Warnings: +Warning 3090 Changing sql mode 'PAD_CHAR_TO_FULL_LENGTH' is deprecated. It will be removed in a future release. +select @@sql_mode into @full_mode; +create procedure p() begin end; +call p(); +set @@sql_mode= @old_mode; +select routine_name from information_schema.routines where routine_name = 'p' and sql_mode = @full_mode; +ROUTINE_NAME +p +drop procedure p; +CREATE DEFINER = 'root'@'localhost' PROCEDURE p1() +NOT DETERMINISTIC +CONTAINS SQL +SQL SECURITY DEFINER +COMMENT '' +BEGIN +SHOW TABLE STATUS like 't1'; +END;// +CREATE TABLE t1 (f1 INT); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; +CREATE TABLE t1 ( f1 integer, primary key (f1)); +CREATE TABLE t2 LIKE t1; +CREATE TEMPORARY TABLE t3 LIKE t1; +CREATE PROCEDURE p1 () BEGIN SELECT f1 FROM t3 AS A WHERE A.f1 IN ( SELECT f1 FROM t3 ) ; +END| +CALL p1; +ERROR HY000: Can't reopen table: 'A' +CREATE VIEW t3 AS SELECT f1 FROM t2 A WHERE A.f1 IN ( SELECT f1 FROM t2 ); +DROP TABLE t3; +CALL p1; +f1 +CALL p1; +f1 +DROP PROCEDURE p1; +DROP TABLE t1, t2; +DROP VIEW t3; +# +# Bug #46629: Item_in_subselect::val_int(): Assertion `0' +# on subquery inside a SP +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT, b INT PRIMARY KEY); +CREATE PROCEDURE p1 () +BEGIN +SELECT a FROM t1 A WHERE A.b IN (SELECT b FROM t2 AS B); +END| +CALL p1; +ERROR 42S22: Unknown column 'A.b' in 'IN/ALL/ANY subquery' +CALL p1; +ERROR 42S22: Unknown column 'A.b' in 'IN/ALL/ANY subquery' +DROP PROCEDURE p1; +DROP TABLE t1, t2; +# +# Bug#47627: SET @@{global.session}.local_variable in stored routine causes crash +# Bug#48626: Crash or lost connection using SET for declared variables with @@ +# +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +CREATE PROCEDURE p1() +BEGIN +DECLARE v INT DEFAULT 0; +SET @@SESSION.v= 10; +END// +ERROR HY000: Unknown system variable 'v' +CREATE PROCEDURE p2() +BEGIN +DECLARE v INT DEFAULT 0; +SET v= 10; +END// +call p2()// +CREATE PROCEDURE p3() +BEGIN +DECLARE v INT DEFAULT 0; +SELECT @@SESSION.v; +END// +ERROR HY000: Unknown system variable 'v' +CREATE PROCEDURE p4() +BEGIN +DECLARE v INT DEFAULT 0; +SET @@GLOBAL.v= 10; +END// +ERROR HY000: Unknown system variable 'v' +CREATE PROCEDURE p5() +BEGIN +DECLARE init_connect INT DEFAULT 0; +SET init_connect= 10; +SET @@GLOBAL.init_connect= 'SELECT 1'; +SET @@SESSION.IDENTITY= 1; +SELECT @@SESSION.IDENTITY; +SELECT @@GLOBAL.init_connect; +SELECT init_connect; +END// +CREATE PROCEDURE p6() +BEGIN +DECLARE v INT DEFAULT 0; +SET @@v= 0; +END// +ERROR HY000: Unknown system variable 'v' +SET @old_init_connect= @@GLOBAL.init_connect; +CALL p5(); +@@SESSION.IDENTITY +1 +@@GLOBAL.init_connect +SELECT 1 +init_connect +10 +SET @@GLOBAL.init_connect= @old_init_connect; +DROP PROCEDURE p2; +DROP PROCEDURE p5; +# +# Bug#11840395 (formerly known as bug#60347): +# The string "versiondata" seems +# to be 'leaking' into the schema name space +# +CREATE DATABASE mixedCaseDbName; +CREATE PROCEDURE mixedCaseDbName.tryMyProc() begin end| +CREATE FUNCTION mixedCaseDbName.tryMyFunc() returns text begin return 'IT WORKS'; end +| +call mixedCaseDbName.tryMyProc(); +select mixedCaseDbName.tryMyFunc(); +mixedCaseDbName.tryMyFunc() +IT WORKS +DROP DATABASE mixedCaseDbName; +# +# Bug#11766594 59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C +# +CREATE TABLE t1 (a INT, b INT, KEY(b)); +CREATE TABLE t2 (c INT, d INT, KEY(c)); +INSERT INTO t1 VALUES (1,1),(1,1),(1,2); +INSERT INTO t2 VALUES (1,1),(1,2); +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +DECLARE a int; +-- SQL statement inside +SELECT 1 INTO a; +RETURN a; +END $ +SELECT COUNT(DISTINCT d) FROM t1, t2 WHERE a = c AND b = f1(); +COUNT(DISTINCT d) +2 +DROP FUNCTION f1; +DROP TABLE t1, t2; +# ------------------------------------------------------------------ +# -- End of 5.1 tests +# ------------------------------------------------------------------ +DROP FUNCTION IF EXISTS f1; +DROP TABLE IF EXISTS t_non_existing; +DROP TABLE IF EXISTS t1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +DECLARE v INT; +SELECT a INTO v FROM t_non_existing; +RETURN 1; +END| +CREATE TABLE t1 (a INT) ENGINE = myisam; +INSERT INTO t1 VALUES (1); +SELECT * FROM t1 WHERE a = f1(); +ERROR 42S02: Table 'test.t_non_existing' doesn't exist +DROP FUNCTION f1; +DROP TABLE t1; +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(a INT, b CHAR) +BEGIN +IF a > 0 THEN +CALL p1(a-1, 'ab'); +ELSE +SELECT 1; +END IF; +END| +SET @save_max_sp_recursion= @@max_sp_recursion_depth; +SET @@max_sp_recursion_depth= 5; +CALL p1(4, 'a'); +1 +1 +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +SET @@max_sp_recursion_depth= @save_max_sp_recursion; +DROP PROCEDURE p1; +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(a CHAR) +BEGIN +SELECT 1; +SELECT CAST('10x' as UNSIGNED INTEGER); +END| +CALL p1('data truncated parameter'); +1 +1 +CAST('10x' as UNSIGNED INTEGER) +10 +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1292 Truncated incorrect INTEGER value: '10x' +DROP PROCEDURE p1; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +CREATE PROCEDURE p1() +CALL p2()| +CREATE PROCEDURE p2() +CALL p3()| +CREATE PROCEDURE p3() +CALL p4()| +CREATE PROCEDURE p4() +BEGIN +SELECT 1; +SELECT CAST('10x' as UNSIGNED INTEGER); +END| +CALL p1(); +1 +1 +CAST('10x' as UNSIGNED INTEGER) +10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10x' +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a CHAR(2)); +INSERT INTO t1 VALUES ('aa'); +CREATE FUNCTION f1() RETURNS CHAR +RETURN (SELECT f2())| +CREATE FUNCTION f2() RETURNS CHAR +RETURN (SELECT f3())| +CREATE FUNCTION f3() RETURNS CHAR +RETURN (SELECT f4())| +CREATE FUNCTION f4() RETURNS CHAR +BEGIN +RETURN (SELECT a FROM t1); +END| +SELECT f1(); +f1() +a +Warnings: +Warning 1265 Data truncated for column 'f4()' at row 2 +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; +DROP TABLE t1; +# +# Bug#34197: CREATE PROCEDURE fails when COMMENT truncated in non +# strict SQL mode +# +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1 () +COMMENT +'12345678901234567890123456789012345678901234567890123456789012345678901234567890' +BEGIN +END; +SELECT routine_comment FROM information_schema.routines WHERE routine_name = "p1"; +ROUTINE_COMMENT +12345678901234567890123456789012345678901234567890123456789012345678901234567890 +DROP PROCEDURE p1; +# +# Bug #47313 assert in check_key_in_view during CALL procedure +# +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS t1, t2_unrelated; +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x); +CREATE VIEW t1 AS SELECT 10 AS f1; +# t1 refers to the view +CALL p1(1); +ERROR HY000: The target table t1 of the INSERT is not insertable-into +CREATE TEMPORARY TABLE t1 (f1 INT); +# Since last call to p1 was unsuccessful, the query will be reparsed +# and the procedure will refer to the temporary table +CALL p1(2); +DROP VIEW t1; +# t1 still refers to the temporary table +CALL p1(3); +# Check which values were inserted into the temp table. +SELECT * FROM t1; +f1 +2 +3 +DROP TEMPORARY TABLE t1; +DROP PROCEDURE p1; +# Now test what happens if the sp cache is invalidated. +CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x); +CREATE VIEW t1 AS SELECT 10 AS f1; +CREATE VIEW v2_unrelated AS SELECT 1 AS r1; +# Load the procedure into the sp cache +CALL p1(4); +ERROR HY000: The target table t1 of the INSERT is not insertable-into +CREATE TEMPORARY TABLE t1 (f1 int); +ALTER VIEW v2_unrelated AS SELECT 2 AS r1; +# Alter view causes the sp cache to be invalidated. +# Now t1 refers to the temporary table, not the view. +CALL p1(5); +# Check which values were inserted into the temp table. +SELECT * FROM t1; +f1 +5 +DROP TEMPORARY TABLE t1; +DROP VIEW t1, v2_unrelated; +DROP PROCEDURE p1; +CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x); +CREATE TEMPORARY TABLE t1 (f1 INT); +# t1 refers to the temporary table +CALL p1(6); +CREATE VIEW t1 AS SELECT 10 AS f1; +# Create view causes the sp cache to be invalidated. +# t1 still refers to the temporary table since it shadows the view. +CALL p1(7); +DROP VIEW t1; +# Check which values were inserted into the temp table. +SELECT * FROM t1; +f1 +6 +7 +DROP TEMPORARY TABLE t1; +DROP PROCEDURE p1; +# +# Bug #11918 Can't use a declared variable in LIMIT clause +# +drop table if exists t1; +drop procedure if exists p1; +create table t1 (c1 int); +insert into t1 (c1) values (1), (2), (3), (4), (5); +create procedure p1() +begin +declare a integer; +declare b integer; +select * from t1 limit a, b; +end| +# How do we handle NULL limit values? +call p1(); +c1 +drop table t1; +create table t1 (a int); +insert into t1 (a) values (1), (2), (3), (4), (5); +# +# Do we correctly resolve identifiers in LIMIT? +# +call p1(); +a +drop table t1; +create table t1 (c1 int); +insert into t1 (c1) values (1), (2), (3), (4), (5); +drop procedure p1; +# Try to create a procedure that +# refers to non-existing variables. +create procedure p1(p1 integer, p2 integer) +select * from t1 limit a, b; +ERROR 42000: Undeclared variable: a +# +# Try to use data types not allowed in LIMIT +# +create procedure p1(p1 date, p2 date) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +create procedure p1(p1 integer, p2 float) select * from t1 limit p1, p2; +ERROR 42000: The variable "p2" has a non-integer based type near 'p2' at line 1 +create procedure p1(p1 integer, p2 char(1)) select * from t1 limit p1, p2; +ERROR 42000: The variable "p2" has a non-integer based type near 'p2' at line 1 +create procedure p1(p1 varchar(5), p2 char(1)) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +create procedure p1(p1 decimal, p2 decimal) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +create procedure p1(p1 double, p2 double) select * from t1 limit p1, p2; +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2' at line 1 +# +# Finally, test the valid case. +# +create procedure p1(p1 integer, p2 integer) +select * from t1 limit p1, p2; +call p1(NULL, NULL); +c1 +call p1(0, 0); +c1 +call p1(0, -1); +c1 +1 +2 +3 +4 +5 +call p1(-1, 0); +c1 +call p1(-1, -1); +c1 +call p1(0, 1); +c1 +1 +call p1(1, 0); +c1 +call p1(1, 5); +c1 +2 +3 +4 +5 +call p1(3, 2); +c1 +4 +5 +# Try to create a function that +# refers to non-existing variables. +create function f1(p1 integer, p2 integer) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit a, b); +return a; +end| +ERROR 42000: Undeclared variable: b +create function f1() +returns int +begin +declare a, b, c int; +set a = (select count(*) from t1 limit b, c); +return a; +end| +# How do we handle NULL limit values? +select f1(); +f1() +NULL +drop function f1; +# +# Try to use data types not allowed in LIMIT +# +create function f1(p1 date, p2 date) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +create function f1(p1 integer, p2 float) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p2" has a non-integer based type near 'p2); +return a; +end' at line 5 +create function f1(p1 integer, p2 char(1)) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p2" has a non-integer based type near 'p2); +return a; +end' at line 5 +create function f1(p1 varchar(5), p2 char(1)) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +create function f1(p1 decimal, p2 decimal) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +create function f1(p1 double, p2 double) +returns int +begin +declare a int; +set a = (select count(*) from t1 limit p1, p2); +return a; +end| +ERROR 42000: The variable "p1" has a non-integer based type near 'p1, p2); +return a; +end' at line 5 +# +# Finally, test the valid case. +# +create function f1(p1 integer, p2 integer) +returns int +begin +declare count int; +set count= (select count(*) from (select * from t1 limit p1, p2) t_1); +return count; +end| +select f1(0, 0); +f1(0, 0) +0 +select f1(0, -1); +f1(0, -1) +5 +select f1(-1, 0); +f1(-1, 0) +0 +select f1(-1, -1); +f1(-1, -1) +0 +select f1(0, 1); +f1(0, 1) +1 +select f1(1, 0); +f1(1, 0) +0 +select f1(1, 5); +f1(1, 5) +4 +select f1(3, 2); +f1(3, 2) +2 +# Cleanup +drop table t1; +drop procedure p1; +drop function f1; +# +# BUG#11766234: 59299: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW) +# FAILS IN SET_FIELD_ITERATOR +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE VIEW v1 AS SELECT a FROM t2; +CREATE PROCEDURE proc() SELECT * FROM t1 NATURAL JOIN v1; +ALTER TABLE t2 CHANGE COLUMN a b CHAR; + +CALL proc(); +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +CALL proc(); +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them + +DROP TABLE t1,t2; +DROP VIEW v1; +DROP PROCEDURE proc; + +# -- +# -- Bug 11765684 - 58674: SP-cache does not detect changes in +# -- pre-locking list caused by triggers +# --- +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT); +CREATE TABLE t3(a INT); +CREATE PROCEDURE p1() +INSERT INTO t1(a) VALUES (1); + +CREATE TRIGGER t1_ai AFTER INSERT ON t1 +FOR EACH ROW +INSERT INTO t2(a) VALUES (new.a); + +CALL p1(); + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 +FOR EACH ROW +INSERT INTO t3(a) VALUES (new.a); + +CALL p1(); + +DROP TABLE t1, t2, t3; +DROP PROCEDURE p1; + + +# -- +# -- Bug#12652769 - 61470: case operator in stored routine retains old +# -- value of input parameter +# --- +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('a'); +CREATE PROCEDURE p1(dt DATETIME, i INT) +BEGIN +SELECT +CASE +WHEN i = 1 THEN 2 +ELSE dt +END AS x1; +SELECT +CASE _latin1'a' + WHEN _utf8'a' THEN 'A' + END AS x2; +SELECT +CASE _utf8'a' + WHEN _latin1'a' THEN _utf8'A' + END AS x3; +SELECT +CASE s1 +WHEN _latin1'a' THEN _latin1'b' + ELSE _latin1'c' + END AS x4 +FROM t1; +END| +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. + +CALL p1('2011-04-03 05:14:10', 1); +x1 +2 +x2 +A +x3 +A +x4 +b +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CALL p1('2011-04-03 05:14:11', 2); +x1 +2011-04-03 05:14:11 +x2 +A +x3 +A +x4 +b +CALL p1('2011-04-03 05:14:12', 2); +x1 +2011-04-03 05:14:12 +x2 +A +x3 +A +x4 +b +CALL p1('2011-04-03 05:14:13', 2); +x1 +2011-04-03 05:14:13 +x2 +A +x3 +A +x4 +b + +DROP TABLE t1; +DROP PROCEDURE p1; + +# +# Bug#12621017 - Crash if a sp variable is used in the +# limit clause of a set statement +# +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1); +CREATE PROCEDURE p1() +BEGIN +DECLARE foo, cnt INT UNSIGNED DEFAULT 1; +SET foo = (SELECT MIN(c1) FROM t1 LIMIT cnt); +END| +CREATE PROCEDURE p2() +BEGIN +DECLARE iLimit INT; +DECLARE iVal INT; +DECLARE cur1 CURSOR FOR +SELECT c1 FROM t1 +LIMIT iLimit; +SET iLimit=1; +OPEN cur1; +FETCH cur1 INTO iVal; +END| +CALL p1(); +CALL p2(); +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP TABLE t1; + +# Bug#13805127: Stored program cache produces wrong result in same THD + +CREATE PROCEDURE p1(x INT UNSIGNED) +BEGIN +SELECT c1, t2.c2, count(c3) +FROM +( +SELECT 3 as c2 FROM dual WHERE x = 1 +UNION +SELECT 2 FROM dual WHERE x = 1 OR x = 2 +) AS t1, +( +SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual +UNION +SELECT '2012-03-01 02:00:00', 3, 2 FROM dual +UNION +SELECT '2012-03-01 01:00:00', 2, 1 FROM dual +) AS t2 +WHERE t2.c2 = t1.c2 +GROUP BY c1 , c2 +ORDER BY c1 , c2 +; +END| + +CALL p1(1); +c1 c2 count(c3) +2012-03-01 01:00:00 2 1 +2012-03-01 01:00:00 3 1 +2012-03-01 02:00:00 3 1 +CALL p1(2); +c1 c2 count(c3) +2012-03-01 01:00:00 2 1 +CALL p1(1); +c1 c2 count(c3) +2012-03-01 01:00:00 2 1 +2012-03-01 01:00:00 3 1 +2012-03-01 02:00:00 3 1 +DROP PROCEDURE p1; +# End of 5.5 test +# +# Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS +# +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1(); +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1(); +RETURN f1(); +END; +END; +RETURN 1; +END $ +SELECT f1(); +f1() +1 +DROP FUNCTION f1; +# +# Bug#12577230 +# RERUN OF STORED FUNCTION CAUSES SEGFAULT IN MAKE_JOIN_SELECT +# +CREATE TABLE t1 (a INT) ENGINE=myisam; +INSERT INTO t1 VALUES (1); +CREATE VIEW v1 AS SELECT a FROM t1; +CREATE PROCEDURE p1() +SELECT 1 FROM v1 JOIN t1 ON v1.a +WHERE (SELECT 1 FROM t1 WHERE v1.a) +; +CALL p1(); +1 +1 +CALL p1(); +1 +1 +DROP PROCEDURE p1; +prepare s from 'select 1 from `v1` join `t1` on `v1`.`a` +where (select 1 from `t1` where `v1`.`a`)'; +execute s; +1 +1 +execute s; +1 +1 +prepare s from 'select 1 from `v1` join `t1` on `v1`.`a`'; +execute s; +1 +1 +execute s; +1 +1 +prepare s from 'select 1 from `v1` join `t1` on `v1`.`a` join t1 as t2 +on v1.a'; +execute s; +1 +1 +execute s; +1 +1 +create view v2 as select 0 as a from t1; +prepare s from 'select 1 from `v2` join `t1` on `v2`.`a` join v1 on `v1`.`a`'; +execute s; +1 +execute s; +1 +prepare s from 'select 1 from `v2` join `t1` on `v2`.`a`, v1 where `v1`.`a`'; +execute s; +1 +execute s; +1 +DROP TABLE t1; +DROP VIEW v1,v2; +# +# WL#2111: Add non-reserved ROW_COUNT keyword. +# +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE row_count INT DEFAULT 1; +SELECT row_count; +SELECT row_count(); +ROW_COUNT: WHILE row_count > 0 DO +SET row_count = row_count - 1; +END WHILE ROW_COUNT; +SELECT ROW_COUNT; +END| +CALL p1(); +row_count +1 +row_count() +-1 +ROW_COUNT +0 +DROP PROCEDURE p1; +# +# BUG #11748187 - 35410: STORED FUNCTION: CONFUSING 'ORDER CLAUSE' IN ERROR MESSAGE +# +DROP FUNCTION if exists f1; +CREATE FUNCTION f1 (p_value INT) RETURNS INT DETERMINISTIC RETURN x; +SELECT f1(1); +ERROR 42S22: Unknown column 'x' in 'field list' +DROP FUNCTION f1; +# +# BUG #12872824 (formerly known as 62125): testing stored function +# result for null incorrectly yields 1292 warning. +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP FUNCTION IF EXISTS f3; +DROP FUNCTION IF EXISTS f4; +CREATE FUNCTION f1() RETURNS VARCHAR(1) +BEGIN RETURN 'X'; END;/ +CREATE FUNCTION f2() RETURNS CHAR(1) +BEGIN RETURN 'X'; END;/ +CREATE FUNCTION f3() RETURNS VARCHAR(1) +BEGIN RETURN NULL; END;/ +CREATE FUNCTION f4() RETURNS CHAR(1) +BEGIN RETURN NULL; END;/ +SELECT f1() IS NULL; +f1() IS NULL +0 +SELECT f2() IS NULL; +f2() IS NULL +0 +SELECT f3() IS NULL; +f3() IS NULL +1 +SELECT f4() IS NULL; +f4() IS NULL +1 +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP FUNCTION f3; +DROP FUNCTION f4; +# +# +# WL#6230: Remove 'SET = DEFAULT' +# +CREATE TABLE t1(a INT); +CREATE PROCEDURE p(p INT) +SET p = DEFAULT| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT' at line 2 +CREATE PROCEDURE p() +BEGIN +DECLARE v INT; +SET v = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 4 +CREATE PROCEDURE p() +BEGIN +DECLARE v INT DEFAULT 1; +SET v = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 4 +CREATE PROCEDURE p() +BEGIN +DECLARE v INT DEFAULT (SELECT * FROM t1); +SET v = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 4 +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +BEGIN +SET NEW.a = DEFAULT; +END| +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT; +END' at line 3 + +# Check that setting system variables to DEFAULT still works in SP. + +CREATE PROCEDURE p1() +SET @@default_storage_engine = DEFAULT; +SET @default_storage_engine_saved = @@default_storage_engine; +SELECT @@default_storage_engine; +@@default_storage_engine +InnoDB +SET @@default_storage_engine = InnoDB; +SELECT @@default_storage_engine; +@@default_storage_engine +InnoDB +CALL p1(); +SELECT @@default_storage_engine; +@@default_storage_engine +InnoDB +SET @@default_storage_engine = @default_storage_engine_saved; +DROP PROCEDURE p1; +DROP TABLE t1; +# End of 5.6 tests +# +# BUG 18484649 - STRICT MODE + CURSOR FETCH INTO WRONG TYPE, ASSERTION +# IN PROTOCOL::END_STATEMENT +# +SET @org_mode= @@sql_mode; +SET sql_mode= 'STRICT_TRANS_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1(a INT) ENGINE= InnoDB; +INSERT INTO t1 VALUES (123456); +CREATE PROCEDURE p1() +BEGIN +DECLARE `v` TINYINT; +DECLARE `c` CURSOR FOR SELECT a FROM t1; +BEGIN +OPEN c; +FETCH c INTO v; +CLOSE c; +END; +END $ +# With the fix, Call to p1 will result in error as the routine was +# created in STRICT MODE. +CALL p1(); +ERROR 22003: Out of range value for column 'v' at row 1 +# Clean-up +SET sql_mode= @org_mode; +DROP PROCEDURE p1; +DROP TABLE t1; +# +# Bug#20583321: CRASH ON PS_THREAD_INFO / SYS USAGE +# +SET sql_mode = 'only_full_group_by'; +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT ); +CREATE PROCEDURE p1 () +BEGIN +DECLARE output INT; +SET output = ( SELECT b FROM t1 LEFT JOIN t2 USING ( a ) GROUP BY t1.a ); +END $$ +CALL p1(); +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +CALL p1(); +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP PROCEDURE p1; +PREPARE s FROM +'SET @x = ( SELECT b FROM t1 LEFT JOIN t2 USING ( a ) GROUP BY t1.a )'; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t1.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1, t2; +SET sql_mode = DEFAULT; +# +# ASSERTION FAILED: FALSE IN CREATE_TMP_FIELD WITH UNKNOWN OUTER FIELD +# +CREATE TABLE t1 ( a INT ); +SET @v = 1; +PREPARE stmt FROM 'SELECT 1 FROM ( SELECT ? FROM t1 GROUP BY a ) al;'; +EXECUTE stmt USING @v; +1 +PREPARE stmt FROM 'CREATE TABLE t2 AS SELECT ? FROM t1'; +EXECUTE stmt USING @v; +DROP TABLE t1, t2; +# +# Bug #18599181: CALLING A ROUTINE WITHOUT SPECIFYING DATABASE PREFIX +# MAY RETURN ERROR 1370 +# +CREATE DATABASE db1; +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE FUNCTION db1.f2() RETURNS INT RETURN test.f1(); +CREATE USER myuser@'localhost'; +GRANT ALL ON db1.* TO myuser@'localhost'; +SELECT f2(); +f2() +1 +SELECT f2(); +f2() +1 +DROP DATABASE db1; +DROP USER myuser@localhost; +DROP FUNCTION f1; +# +# WL#7897 -- Use DD API for Stored Routines. +# Basic test to verify: +# i) The table mysql.proc does not exists any more. +# ii) Stored routine metadata is still available with the +# information_schema tables "routines" and "parameters". +# These tables are filled from the new DD tables mysql.routine +# and mysql.parameter. +# iii) Basic test to cover "READS SQL DATA" in ALTER operation. +# +CREATE FUNCTION f1(a INT) RETURNS INT return 1; +CREATE PROCEDURE p1(IN a INT, INOUT b INT, OUT c INT) select 1; +# The table mysql.proc does not exists any more. +SELECT * FROM mysql.proc; +ERROR 42S02: Table 'mysql.proc' doesn't exist +# Metadata of stored function f1. +SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'f1'; +SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +f1 def test f1 FUNCTION int NULL NULL 10 0 NULL NULL NULL int SQL return 1 NULL SQL SQL NO CONTAINS SQL NULL DEFINER ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION root@localhost utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'f1'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test f1 0 NULL NULL int NULL NULL 10 0 NULL NULL NULL int FUNCTION +def test f1 1 IN a int NULL NULL 10 0 NULL NULL NULL int FUNCTION +# Metadata of stored procedure p1. +SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'p1'; +SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +p1 def test p1 PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL select 1 NULL SQL SQL NO CONTAINS SQL NULL DEFINER ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION root@localhost utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = 'p1'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test p1 1 IN a int NULL NULL 10 0 NULL NULL NULL int PROCEDURE +def test p1 2 INOUT b int NULL NULL 10 0 NULL NULL NULL int PROCEDURE +def test p1 3 OUT c int NULL NULL 10 0 NULL NULL NULL int PROCEDURE +# Basic test to cover "READS SQL DATA" in ALTER operation. +ALTER FUNCTION f1 READS SQL DATA; +DROP FUNCTION f1; +DROP PROCEDURE p1; +# +# WL#9262: All system tables should support 32 character length user names +# +#This should just work with username + hostname of length 93 as DEFINER +CREATE USER user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +#For procedure +CREATE DEFINER=user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char PROCEDURE test.proc_test() SELECT CURRENT_USER(); +#and for function +CREATE DEFINER=user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char FUNCTION test.f_test() RETURNS INT RETURN 1; +SHOW PROCEDURE STATUS LIKE 'proc_test'; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test proc_test PROCEDURE user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +DROP PROCEDURE test.proc_test; +SHOW FUNCTION STATUS LIKE 'f_test'; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test f_test FUNCTION user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char # # DEFINER utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +DROP FUNCTION test.f_test; +DROP USER user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; +drop table if exists t1,t3; +drop procedure if exists bug4902| +create procedure bug4902() +begin +show grants for 'root'@'localhost'; +end| +call bug4902()| +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +call bug4902()| +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +drop procedure bug4902| +drop procedure if exists bug4902_2| +create procedure bug4902_2() +begin +show processlist; +end| +call bug4902_2()| +show warnings| +Level Code Message +call bug4902_2()| +show warnings| +Level Code Message +drop procedure bug4902_2| +drop procedure if exists bug6807| +create procedure bug6807() +begin +declare id int; +set id = connection_id(); +kill query id; +select 'Not reached'; +end| +call bug6807()| +ERROR 70100: Query execution was interrupted +call bug6807()| +ERROR 70100: Query execution was interrupted +drop procedure bug6807| +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'| +drop function if exists bug10100f| +drop procedure if exists bug10100p| +drop procedure if exists bug10100t| +drop procedure if exists bug10100pt| +drop procedure if exists bug10100pv| +drop procedure if exists bug10100pd| +drop procedure if exists bug10100pc| +create function bug10100f(prm int) returns int +begin +if prm > 1 then +return prm * bug10100f(prm - 1); +end if; +return 1; +end| +create procedure bug10100p(prm int, inout res int) +begin +set res = res * prm; +if prm > 1 then +call bug10100p(prm - 1, res); +end if; +end| +create procedure bug10100t(prm int) +begin +declare res int; +set res = 1; +call bug10100p(prm, res); +select res; +end| +create table t3 (a int)| +insert into t3 values (0)| +create view v1 as select a from t3; +create procedure bug10100pt(level int, lim int) +begin +if level < lim then +update t3 set a=level; +FLUSH TABLES; +call bug10100pt(level+1, lim); +else +select * from t3; +end if; +end| +create procedure bug10100pv(level int, lim int) +begin +if level < lim then +update v1 set a=level; +FLUSH TABLES; +call bug10100pv(level+1, lim); +else +select * from v1; +end if; +end| +prepare stmt2 from "select * from t3;"; +create procedure bug10100pd(level int, lim int) +begin +if level < lim then +select level; +prepare stmt1 from "update t3 set a=a+2"; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +execute stmt1; +FLUSH TABLES; +deallocate prepare stmt1; +execute stmt2; +select * from t3; +call bug10100pd(level+1, lim); +else +execute stmt2; +end if; +end| +create procedure bug10100pc(level int, lim int) +begin +declare lv int; +declare c cursor for select a from t3; +open c; +if level < lim then +select level; +fetch c into lv; +select lv; +update t3 set a=level+lv; +FLUSH TABLES; +call bug10100pc(level+1, lim); +else +select * from t3; +end if; +close c; +end| +set @@max_sp_recursion_depth=255| +set @var=1| +call bug10100p(255, @var)| +call bug10100pt(1,255)| +call bug10100pv(1,255)| +call bug10100pd(1,255)| +call bug10100pc(1,255)| +set @@max_sp_recursion_depth=0| +deallocate prepare stmt2| +drop function bug10100f| +drop procedure bug10100p| +drop procedure bug10100t| +drop procedure bug10100pt| +drop procedure bug10100pv| +drop procedure bug10100pd| +drop procedure bug10100pc| +drop view v1| +drop table t3| +SET sql_mode = default; +drop procedure if exists bug15298_1; +drop procedure if exists bug15298_2; +create user 'mysqltest_1'@'localhost'; +grant all privileges on test.* to 'mysqltest_1'@'localhost'; +create procedure 15298_1 () sql security definer show grants for current_user; +create procedure 15298_2 () sql security definer show grants; +call 15298_1(); +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +call 15298_2(); +Grants for root@localhost +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION +GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION +drop user mysqltest_1@localhost; +drop procedure 15298_1; +drop procedure 15298_2; +drop table if exists t1; +drop procedure if exists p1; +create table t1 (value varchar(15)) engine=Myisam; +create procedure p1() update t1 set value='updated' where value='old'; +call p1(); +insert into t1 (value) values ("old"); +select get_lock('b26162',120); +get_lock('b26162',120) +1 +select 'rl_acquirer', value from t1 where get_lock('b26162',120);; +set session low_priority_updates=on; +call p1();; +select 'rl_contender', value from t1; +rl_contender value +rl_contender old +select release_lock('b26162'); +release_lock('b26162') +1 +rl_acquirer value +rl_acquirer old +drop procedure p1; +drop table t1; +set session low_priority_updates=default; +INSERT INTO mysql.user (Host, User, Select_priv, Insert_priv, Update_priv, +Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, +Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, +Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, +Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, +Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, +max_updates, max_connections, max_user_connections) +VALUES('%', 'mysqltest_1', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', +'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '', +'', '', '', '0', '0', '0', '0'); +FLUSH PRIVILEGES; +CREATE PROCEDURE p1(i INT) BEGIN END; +DROP PROCEDURE p1; +DELETE FROM mysql.user WHERE User='mysqltest_1'; +FLUSH PRIVILEGES; +# +# Bug#44521 Prepared Statement: CALL p() - crashes: `! thd->main_da.is_sent' failed et.al. +# +SELECT GET_LOCK('Bug44521', 0); +GET_LOCK('Bug44521', 0) +1 +** Connection con1 +CREATE PROCEDURE p() +BEGIN +SELECT 1; +SELECT GET_LOCK('Bug44521', 100); +SELECT 2; +END$ +CALL p();; +** Default connection +SELECT RELEASE_LOCK('Bug44521'); +RELEASE_LOCK('Bug44521') +1 +DROP PROCEDURE p; +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (1); +CREATE FUNCTION f1 (inp TEXT) RETURNS INT NO SQL RETURN GET_LOCK('Bug47736', 200); +CREATE VIEW v1 AS SELECT f1('a') FROM t1; +SELECT GET_LOCK('Bug47736', 0); +GET_LOCK('Bug47736', 0) +1 +SELECT * FROM v1;; +KILL QUERY ID; +ERROR 70100: Query execution was interrupted +DROP VIEW v1; +DROP TABLE t1; +DROP FUNCTION f1; +# ------------------------------------------------------------------ +# -- End of 5.1 tests +# ------------------------------------------------------------------ +# +# Test for bug#11763757 "56510: ERROR 42000: FUNCTION DOES NOT EXIST +# IF NOT-PRIV USER RECONNECTS ". +# +# The real problem was that server was unable handle properly stored +# functions in databases which names contained dot. +# +DROP DATABASE IF EXISTS `my.db`; +create database `my.db`; +use `my.db`; +CREATE FUNCTION f1(a int) RETURNS INT RETURN a; +# Create new connection. +USE `my.db`; +SELECT f1(1); +f1(1) +1 +SELECT `my.db`.f1(2); +`my.db`.f1(2) +2 +# Switching to default connection. +DROP DATABASE `my.db`; +USE test; +# +# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE +# +SET @@SQL_MODE = ''; +CREATE EVENT teste_bug11763507 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR +DO SELECT 1 $ +SHOW EVENTS LIKE 'teste_bug11763507'; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +test teste_bug11763507 root@localhost SYSTEM ONE TIME # # # # NULL ENABLED 1 utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +SHOW EVENTS LIKE 'TESTE_bug11763507'; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +test teste_bug11763507 root@localhost SYSTEM ONE TIME # # # # NULL ENABLED 1 utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +SHOW CREATE EVENT teste_bug11763507; +Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation +teste_bug11763507 SYSTEM # utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +SHOW CREATE EVENT TESTE_bug11763507; +Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation +teste_bug11763507 SYSTEM # utf8mb4 utf8mb4_0900_ai_ci DATABASE_COLLATION +DROP EVENT teste_bug11763507; +#END OF BUG#11763507 test. + +# WL#4179: Stored programs: validation of stored program statements +# +# Test handle of metadata changes with events. + +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (a INT, b INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES (1, 2); +SELECT COUNT(*) = 1 FROM information_schema.processlist +WHERE user = 'event_scheduler' AND command = 'Daemon'; +COUNT(*) = 1 +1 +SELECT GET_LOCK('e1_lock', 60); +GET_LOCK('e1_lock', 60) +1 +CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND STARTS NOW() DO +BEGIN +DECLARE EXIT HANDLER FOR 1136 BEGIN +INSERT INTO t3 VALUES (1); +END; -- ER_WRONG_VALUE_COUNT_ON_ROW +SELECT GET_LOCK('e1_lock', 60); +SELECT RELEASE_LOCK('e1_lock'); +INSERT INTO t2 SELECT * FROM t1; +END| +SELECT RELEASE_LOCK('e1_lock'); +RELEASE_LOCK('e1_lock') +1 +SELECT GET_LOCK('e1_lock', 60); +GET_LOCK('e1_lock', 60) +1 +ALTER TABLE t1 ADD COLUMN (c INT); +SELECT RELEASE_LOCK('e1_lock'); +RELEASE_LOCK('e1_lock') +1 +# Wait for new rows in t3. That means, the even has been executed, +# and INSERT INTO t2 failed because now t1 has 3 columns. +DROP EVENT e1; +DROP TABLE t1, t2, t3; +set @@global.concurrent_insert= @old_concurrent_insert; +# +# WL#2284: Increase the length of a user name +# +CREATE DATABASE test1; +CREATE TABLE test1.t1 ( +int_field INTEGER UNSIGNED NOT NULL, +char_field CHAR(10), +INDEX(`int_field`) +); +CREATE USER user_name_len_16@localhost; +CREATE USER user_name_len_22_01234@localhost; +CREATE USER user_name_len_32_012345678901234@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_16@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_22_01234@localhost; +# Check that user_name_len16 has no SELECT permission ON t1 +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_16'@'localhost' for table 't1' +# Check that user_name_len_22_01234 has no SELECT permission ON t1 +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_22_01234'@'localhost' for table 't1' +GRANT SELECT ON test1.t1 TO user_name_len_22_01234@localhost; +# Check that user_name_len_22_01234 has *now* SELECT permission ON t1 +SELECT * FROM test1.t1; +int_field char_field +CREATE DEFINER=user_name_len_22_01234@localhost PROCEDURE test1.p1_len22() +SELECT * FROM test1.t1; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_22_01234@localhost; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_16@localhost; +# Now user_name_len_16 should be able to SELECT FROM t1 by calling +# p1_len22 procedure +CALL test1.p1_len22(); +int_field char_field +CREATE DEFINER=user_name_len_33_0123456789012345@localhost PROCEDURE test1.p1_len33() +SELECT * FROM test1.t1; +ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32) +# REVOKE the SELECT permission from user_name_len_22_01234 +REVOKE SELECT ON test1.t1 FROM user_name_len_22_01234@localhost; +# and GRANT it to user_name_len_32_012345678901234 +GRANT SELECT ON test1.t1 TO user_name_len_32_012345678901234@localhost; +CREATE DEFINER = user_name_len_32_012345678901234@localhost FUNCTION test1.f1_len32() RETURNS INT +RETURN (SELECT COUNT(*) FROM test1.t1); +GRANT EXECUTE ON FUNCTION test1.f1_len32 TO user_name_len_32_012345678901234@localhost; +GRANT EXECUTE ON FUNCTION test1.f1_len32 TO user_name_len_22_01234@localhost; +GRANT SELECT ON test1.t1 TO user_name_len_22_01234@localhost; +# Now user_name_len_22_01234 should be able to SELECT COUNT(*) FROM t1 +# by calling f1_len32 function +SELECT test1.f1_len32(); +test1.f1_len32() +0 +# Recreate test1.p1_len22, this time with Security Context set to INVOKER +DROP PROCEDURE test1.p1_len22; +# Make sure user_name_len_22_01234 has SELECT privileges on test.t1 +SELECT * FROM test1.t1; +int_field char_field +CREATE DEFINER=user_name_len_22_01234@localhost PROCEDURE test1.p1_len22() +SQL SECURITY INVOKER +SELECT * FROM test1.t1; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_22_01234@localhost; +GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_16@localhost; +# Now user_name_len_16 should *NOT* be able to SELECT COUNT(*) FROM t1 +# by calling f1_len22 function as this function is using the INVOKER +# security context +CALL test1.p1_len22(); +ERROR 42000: SELECT command denied to user 'user_name_len_16'@'localhost' for table 't1' +CREATE DEFINER=user_name_len_33_0123456789012345@localhost FUNCTION test1.f1_len33() RETURNS INT +RETURN (SELECT COUNT(*) FROM test1.t1); +ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32) +DROP DATABASE test1; +DROP USER user_name_len_16@localhost; +DROP USER user_name_len_22_01234@localhost; +DROP USER user_name_len_32_012345678901234@localhost; +# +# BUG#28156802 - MYSQL 8 SERVICE GOES DOWN ON EXECUTING ONE PROCEDURE. +# +CREATE TABLE t1(y INT); +INSERT INTO t1 VALUES (5),(7),(9),(11),(15); +CREATE PROCEDURE `v1`(_limit_val BIGINT, _offset_val BIGINT) +BEGIN +CREATE TEMPORARY TABLE n1 AS (SELECT * FROM t1 LIMIT _limit_val OFFSET _offset_val); +SELECT * FROM n1; +END $$ +CALL v1(3,2); +y +9 +11 +15 +DROP PROCEDURE v1; +DROP TABLE t1; +# Cursor over union of two tables +CREATE TABLE t1(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(1, 10); +CREATE TABLE t2(c INTEGER, d INTEGER); +INSERT INTO t2 VALUES(2, 20); +CREATE PROCEDURE cursor_over_union(OUT sum_a INTEGER, OUT sum_b INTEGER) +BEGIN +DECLARE a INTEGER; +DECLARE b INTEGER; +DECLARE done INTEGER DEFAULT 0; +DECLARE c1 CURSOR FOR +SELECT t1.a, t1.b FROM t1 +UNION DISTINCT +SELECT t2.c, t2.d FROM t2; +DECLARE c2 CURSOR FOR +SELECT t1.a, t1.b FROM t1 +UNION ALL +SELECT t2.c, t2.d FROM t2; +DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; +SET sum_a = 0; +SET sum_b = 0; +OPEN c1; +REPEAT +FETCH c1 INTO a, b; +if NOT done THEN +SET sum_a = sum_a + a; +SET sum_b = sum_b + b; +END IF; +UNTIL done END REPEAT; +CLOSE c1; +SET done = 0; +OPEN c2; +REPEAT +FETCH c2 INTO a, b; +if NOT done THEN +SET sum_a = sum_a + a; +SET sum_b = sum_b + b; +END IF; +UNTIL done END REPEAT; +CLOSE c2; +end // +SET @sa = 0; +SET @sb = 0; +CALL cursor_over_union(@sa, @sb); +SELECT @sa, @sb; +@sa @sb +6 60 +DROP PROCEDURE cursor_over_union; +DROP TABLE t1, t2; +# +# Bug#30520714 - MYSQL SERVER RETURNS UNEXPECTED ROWS WHEN USING STORED +# FUNCTIONS IN WHERE CLAUSE +# +CREATE TABLE t1( f1 INT NOT NULL PRIMARY KEY, f2 INT); +INSERT INTO t1 VALUES (1, 1); +CREATE FUNCTION ReturnFalse() RETURNS BOOL +DETERMINISTIC +BEGIN +DECLARE result BOOL; +SET result = FALSE; +RETURN result; +END$$ +SELECT IF (COUNT(*) > 0, 'affected', 'not affected') FROM t1 +WHERE f1 = 1 AND f2 AND ReturnFalse(); +IF (COUNT(*) > 0, 'affected', 'not affected') +not affected +DROP FUNCTION ReturnFalse; +DROP TABLE t1; +# Bug#31691060: Assertion `!is_open()' in Materialized_cursor::~Materialized_cursor +CREATE TABLE t1(a INTEGER); +CREATE TABLE t2(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(0), (1), (2); +INSERT INTO t2 VALUES(1, 10), (2, 20), (2, 21); +CREATE PROCEDURE pc(val INTEGER) +BEGIN +DECLARE finished, col_a, col_b INTEGER DEFAULT 0; +DECLARE c CURSOR FOR +SELECT a, (SELECT b FROM t2 WHERE t1.a=t2.a) FROM t1 WHERE a = val; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1; +SET finished = 0; +OPEN c; +loop1: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop1; +END IF; +END LOOP loop1; +CLOSE c; +END // +CREATE PROCEDURE pc_with_flush() +BEGIN +DECLARE finished, col_a, col_b INTEGER DEFAULT 0; +DECLARE val INTEGER DEFAULT 0; +DECLARE c CURSOR FOR +SELECT a, (SELECT b FROM t2 WHERE t1.a=t2.a) FROM t1 WHERE a = val; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1; +SET finished = 0; +OPEN c; +loop1: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop1; +END IF; +END LOOP loop1; +CLOSE c; +FLUSH TABLES; +SET finished = 0; +SET val = 1; +OPEN c; +loop2: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop2; +END IF; +END LOOP loop2; +CLOSE c; +FLUSH TABLES; +SET val = 2; +SET finished = 0; +OPEN c; +loop3: LOOP +FETCH c INTO col_a, col_b; +IF finished = 1 THEN +LEAVE loop3; +END IF; +END LOOP loop3; +CLOSE c; +END // +CALL pc(1); +CALL pc(2); +ERROR 21000: Subquery returns more than 1 row +FLUSH TABLES; +CALL pc(1); +CALL pc(2); +ERROR 21000: Subquery returns more than 1 row +FLUSH TABLES; +CALL pc(2); +ERROR 21000: Subquery returns more than 1 row +CALL pc(1); +CALL pc_with_flush(); +ERROR 21000: Subquery returns more than 1 row +DROP PROCEDURE pc; +DROP PROCEDURE pc_with_flush; +DROP TABLE t1, t2; +# Bug#32078387: Incorrect caching of information_schema variables in procedure +CREATE TABLE foo ( +id INTEGER NOT NULL AUTO_INCREMENT, +fld INTEGER NOT NULL, +PRIMARY KEY(id), +UNIQUE KEY fld(fld) +); +CREATE PROCEDURE test() BEGIN +SET @exist := (SELECT COUNT(*) FROM information_schema.statistics +WHERE table_name = 'foo' and +table_schema = database() and +index_name = 'fld'); +SELECT @exist; +END; +// +CALL test(); +@exist +1 +CALL test(); +@exist +1 +CALL test(); +@exist +1 +DROP PROCEDURE test; +DROP TABLE foo; +# Bug#31731334: m_sp != nullptr' at Item_func_sp::bind_fields in sql/item_func.cc +CREATE FUNCTION f1 (i INTEGER) RETURNS INTEGER +BEGIN +IF i = 0 THEN +RETURN 0; +END IF; +RETURN f2(); +END // +CREATE FUNCTION f2 () RETURNS INTEGER +RETURN f1(0) // +SELECT f2(); +f2() +0 +SELECT f1(1); +ERROR HY000: Recursive stored functions and triggers are not allowed. +DROP FUNCTION f1; +DROP FUNCTION f2; diff --git a/mysql-test/r/ssl.result-pq b/mysql-test/r/ssl.result-pq new file mode 100644 index 000000000..8e1be8736 --- /dev/null +++ b/mysql-test/r/ssl.result-pq @@ -0,0 +1,2307 @@ +SHOW STATUS LIKE 'Ssl_cipher'; +Variable_name Value +Ssl_cipher SSL_CIPHER +SHOW STATUS LIKE 'Ssl_server_not_before'; +Variable_name Value +Ssl_server_not_before Dec 5 04:48:40 2014 GMT +SHOW STATUS LIKE 'Ssl_server_not_after'; +Variable_name Value +Ssl_server_not_after Dec 1 04:48:40 2029 GMT +drop table if exists t1,t2,t3,t4; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +37 +36 +50 +58 +29 +40 +53 +65 +41 +34 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; +fld3 repeat("a",length(fld3)) count(*) +Baird aaaaa 1 +balled aaaaaa 1 +ballgown aaaaaaaa 1 +Baltimorean aaaaaaaaaaa 1 +bankruptcies aaaaaaaaaaaa 1 +Barry aaaaa 1 +batting aaaaaaa 1 +beaner aaaaaa 1 +beasts aaaaaa 1 +beaters aaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL # # Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL # # Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL # # NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL # # NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const # # NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const # # NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10; +fld3 period +Abraham 9410 +Aden 9410 +Adolph 9410 +Aldrich 9410 +Alison 9410 +Anatole 9410 +Antarctica 9410 +Antares 9410 +Arabia 9410 +Artemia 9410 +Augustine 9410 +Baird 9410 +Beebe 9410 +Butterfield 9410 +CERN 9410 +Cassites 9410 +Chicana 9410 +Chippewa 9410 +Clayton 9410 +Conley 9410 +Connally 9410 +Crays 9410 +DiMaggio 9410 +Dutchman 9410 +Eulerian 9410 +Evanston 9410 +Everhart 9410 +Fenton 9410 +Fitzpatrick 9410 +Galatean 9410 +Gandhian 9410 +Ganymede 9410 +Goldstine 9410 +Gothicism 9410 +Graves 9410 +Greenberg 9410 +Gurkha 9410 +Hawaii 9410 +Hegelian 9410 +Hornblower 9410 +Huffman 9410 +Hunter 9410 +Joplin 9410 +Judas 9410 +Kane 9410 +Kantian 9410 +Kevin 9410 +Kinsey 9410 +Kline 9410 +Lars 9410 +Latinizes 9410 +Lillian 9410 +Lizzy 9410 +Majorca 9410 +Manhattanize 9410 +McGovern 9410 +Melinda 9410 +Merritt 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +Nabisco 9410 +Nazis 9410 +Newtonian 9410 +Norwalk 9410 +Pandora 9410 +Parsifal 9410 +Peruvian 9410 +Punjab 9410 +Pyle 9410 +Quixotism 9410 +Romano 9410 +Romans 9410 +Sabine 9410 +Sault 9410 +Saxony 9410 +Selfridge 9410 +Shanghais 9410 +Simla 9410 +Simon 9410 +Stalin 9410 +Steinberg 9410 +Taoism 9410 +Teresa 9410 +Tipperary 9410 +Weissmuller 9410 +Winsett 9410 +Wotan 9410 +abates 9410 +abrogating 9410 +accessed 9410 +admiring 9410 +admonishing 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +alike 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +arriving 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +chillingly 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +galling 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +governing 9410 +gradually 9410 +grazing 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +handgun 9410 +handy 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +hostess 9410 +humanness 9410 +humiliation 9410 +humility 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +journalizing 9410 +juveniles 9410 +kanji 9410 +kingdom 9410 +kiting 9410 +labeled 9410 +languages 9410 +laterally 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +linear 9410 +lists 9410 +lithograph 9410 +lore 9410 +luckily 9410 +males 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +metaphysically 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +navies 9410 +navigate 9410 +neat 9410 +neonatal 9410 +nested 9410 +noncritical 9410 +normalizes 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +parametrized 9410 +parenthood 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +quagmire 9410 +quitter 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +save 9410 +sawtooth 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +western 9410 +whiteners 9410 +widens 9410 +witchcraft 9410 +workers 9410 +yelped 9410 +youthfulness 9410 +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr order by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +analyze table t2,t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +label +labeled +labeled +landslide +laterally +leaflet +lewdly +Lillian +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr order by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr, t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr order by companynr; +companynr count(price) sum(price) min(price) max(price) avg(price) +37 12543 309394878010 5987435 39654943 24666736.6667 +78 8362 414611089292 726498 98439034 49582766.0000 +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +9 +8 +0 +4 +6 +7 +1 +3 +5 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr order by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +29 company 1 +68 company 10 +50 company 11 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +53 company 7 +58 company 8 +65 company 9 +0 Unknown +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr order by companynr; +companynr count sum diff func +37 12543 309394878010 0.0000 464091 +78 8362 414611089292 0.0000 652236 +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4 order by fld1; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3 order by fld3; +companynr fld3 sum(price) +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 Micronesia 786542 +512 Miles 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr order by companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # # Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +37 588 83602098 +29 95 14473298 +41 52 12816335 +34 70 17788966 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +37 +29 +41 +34 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40 order by t2.companynr; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr order by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A # NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A # NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A # NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +cont_nr int(11) NOT NULL auto_increment, +ver_nr int(11) NOT NULL default '0', +aufnr int(11) NOT NULL default '0', +username varchar(50) NOT NULL default '', +hdl_nr int(11) NOT NULL default '0', +eintrag date NOT NULL default '0000-00-00', +st_klasse varchar(40) NOT NULL default '', +st_wert varchar(40) NOT NULL default '', +st_zusatz varchar(40) NOT NULL default '', +st_bemerkung varchar(255) NOT NULL default '', +kunden_art varchar(40) NOT NULL default '', +mcbs_knr int(11) default NULL, +mcbs_aufnr int(11) NOT NULL default '0', +schufa_status char(1) default '?', +bemerkung text, +wirknetz text, +wf_igz int(11) NOT NULL default '0', +tarifcode varchar(80) default NULL, +recycle char(1) default NULL, +sim varchar(30) default NULL, +mcbs_tpl varchar(30) default NULL, +emp_nr int(11) NOT NULL default '0', +laufzeit int(11) default NULL, +hdl_name varchar(30) default NULL, +prov_hdl_nr int(11) NOT NULL default '0', +auto_wirknetz varchar(50) default NULL, +auto_billing varchar(50) default NULL, +touch timestamp NOT NULL, +kategorie varchar(50) default NULL, +kundentyp varchar(20) NOT NULL default '', +sammel_rech_msisdn varchar(30) NOT NULL default '', +p_nr varchar(9) NOT NULL default '', +suffix char(3) NOT NULL default '', +PRIMARY KEY (cont_nr), +KEY idx_aufnr(aufnr), +KEY idx_hdl_nr(hdl_nr), +KEY idx_st_klasse(st_klasse), +KEY ver_nr(ver_nr), +KEY eintrag_idx(eintrag), +KEY emp_nr_idx(emp_nr), +KEY wf_igz(wf_igz), +KEY touch(touch), +KEY hdl_tag(eintrag,hdl_nr), +KEY prov_hdl_nr(prov_hdl_nr), +KEY mcbs_aufnr(mcbs_aufnr), +KEY kundentyp(kundentyp), +KEY p_nr(p_nr,suffix) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET sql_mode = default; +INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007'); +INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie; +Kundentyp kategorie +Privat (Private Nutzung) Mobilfunk +Warnings: +Warning 1052 Column 'kundentyp' in group statement is ambiguous +drop table t1; +SHOW STATUS LIKE 'Ssl_cipher'; +Variable_name Value +Ssl_cipher SSL_CIPHER +# +# Bug#54790: Use of non-blocking mode for sockets limits performance +# +# Open ssl_con and set a timeout. +SET @@SESSION.wait_timeout = 2; +# Wait for ssl_con to be disconnected. +# Check that ssl_con has been disconnected. +# Different behavior depending on how the plattform implements the +SELECT 1; +Got one of the listed errors diff --git a/mysql-test/r/ssl_compress.result-pq b/mysql-test/r/ssl_compress.result-pq new file mode 100644 index 000000000..31ce6e7ce --- /dev/null +++ b/mysql-test/r/ssl_compress.result-pq @@ -0,0 +1,2297 @@ +SHOW STATUS LIKE 'Ssl_cipher'; +Variable_name Value +Ssl_cipher SSL_CIPHER +SHOW STATUS LIKE 'Compression'; +Variable_name Value +Compression ON +drop table if exists t1,t2,t3,t4; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +explain select t2.fld3 from t2 where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` IGNORE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ref fld3 fld3 120 const # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` USE INDEX (`fld3`) USE INDEX (`fld1`) where (`test`.`t2`.`fld3` = 'honeysuckle') +explain select fld3 from t2 ignore index (fld3,not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +explain select fld3 from t2 use index (not_used); +ERROR 42000: Key 'not_used' doesn't exist in table 't2' +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL range fld3 fld3 120 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where ((`test`.`t2`.`fld3` >= 'honeysuckle') and (`test`.`t2`.`fld3` <= 'honoring')) order by `test`.`t2`.`fld3` +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; +fld1 fld3 +232605 appendixes +1232605 appendixes +1232606 appendixes +1232607 appendixes +1232608 appendixes +1232609 appendixes +select fld1 from t2 where fld1=250501 or fld1="250502"; +fld1 +250501 +250502 +explain select fld1 from t2 where fld1=250501 or fld1="250502"; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502)) +select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +fld1 +250501 +250502 +250505 +250601 +explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t2 NULL range fld1 fld1 4 NULL # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld1` AS `fld1` from `test`.`t2` where ((`test`.`t2`.`fld1` = 250501) or (`test`.`t2`.`fld1` = 250502) or ((`test`.`t2`.`fld1` >= 250505) and (`test`.`t2`.`fld1` <= 250601)) or (`test`.`t2`.`fld1` between 250501 and 250502)) +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select distinct companynr from t2; +companynr +00 +37 +36 +50 +58 +29 +40 +53 +65 +41 +34 +68 +select distinct companynr from t2 order by companynr; +companynr +00 +29 +34 +36 +37 +40 +41 +50 +53 +58 +65 +68 +select distinct companynr from t2 order by companynr desc; +companynr +68 +65 +58 +53 +50 +41 +40 +37 +36 +34 +29 +00 +select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; +fld3 period +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +select distinct fld3 from t2 where companynr = 34 order by fld3; +fld3 +absentee +accessed +ahead +alphabetic +Asiaticizations +attitude +aye +bankruptcies +belays +Blythe +bomb +boulevard +bulldozes +cannot +caressing +charcoal +checksumming +chess +clubroom +colorful +cosy +creator +crying +Darius +diffusing +duality +Eiffel +Epiphany +Ernestine +explorers +exterminated +famine +forked +Gershwins +heaving +Hodges +Iraqis +Italianization +Lagos +landslide +libretto +Majorca +mastering +narrowed +occurred +offerers +Palestine +Peruvianizes +pharmaceutic +poisoning +population +Pygmalion +rats +realest +recording +regimented +retransmitting +reviver +rouses +scars +sicker +sleepwalk +stopped +sugars +translatable +uncles +unexpected +uprisings +versatility +vest +select distinct fld3 from t2 limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct fld3 from t2 having fld3 like "A%" limit 10; +fld3 +abates +abiding +Abraham +abrogating +absentee +abut +accessed +accruing +accumulating +accuracies +select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +Adl +adm +Ado +ads +adv +aer +aff +afi +afl +afo +agi +ahe +aim +air +Ald +alg +ali +all +alp +alr +ama +ame +amm +ana +and +ane +Ang +ani +Ann +Ant +api +app +aqu +Ara +arc +Arm +arr +Art +Asi +ask +asp +ass +ast +att +aud +Aug +aut +ave +avo +awe +aye +Azt +select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; +substring(fld3,1,3) +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; +a +aba +abi +Abr +abs +abu +acc +acq +acu +Ade +adj +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +SET BIG_TABLES=1; +select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; +namn +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +SET BIG_TABLES=0; +select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; +concat(fld3," ",fld3) +Abraham Abraham +abrogating abrogating +admonishing admonishing +Adolph Adolph +afield afield +aging aging +ammonium ammonium +analyzable analyzable +animals animals +animized animized +select distinct fld5 from t2 limit 10; +fld5 +neat +Steinberg +jarring +tinily +balled +persist +attainments +fanatic +measures +rightfulness +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=1; +select distinct companynr, fld3,count(*) from t2 group by companynr,fld3 order by companynr, fld3 limit 10; +companynr fld3 count(*) +00 affixed 1 +00 and 1 +00 annoyers 1 +00 Anthony 1 +00 assayed 1 +00 assurers 1 +00 attendants 1 +00 bedlam 1 +00 bedpost 1 +00 boasted 1 +SET BIG_TABLES=0; +select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; +fld3 repeat("a",length(fld3)) count(*) +Baird aaaaa 1 +balled aaaaaa 1 +ballgown aaaaaaaa 1 +Baltimorean aaaaaaaaaaa 1 +bankruptcies aaaaaaaaaaaa 1 +Barry aaaaa 1 +batting aaaaaaa 1 +beaner aaaaaa 1 +beasts aaaaaa 1 +beaters aaaaaaa 1 +select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; +companynr rtrim(space(512+companynr)) +37 +78 +101 +154 +311 +447 +512 +select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; +fld3 +explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL fld1 NULL NULL NULL # # Using where; Using temporary; Using filesort +2 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t2.fld1 # # Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`t2nr` AS `t2nr`,`test`.`t2`.`fld3` AS `fld3` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld1` = `test`.`t3`.`t2nr`)) order by `test`.`t3`.`t2nr`,`test`.`t2`.`fld3` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL period NULL NULL NULL # # Using temporary; Using filesort +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t3`.`period` +explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t3 NULL index period period 4 NULL # # NULL +2 SIMPLE t1 NULL ref period period 4 test.t3.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t1`.`period` = `test`.`t3`.`period`) order by `test`.`t3`.`period` limit 10 +explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL index period period 4 NULL # # NULL +2 SIMPLE t3 NULL ref period period 4 test.t1.period # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t2nr` AS `t2nr`,`test`.`t1`.`period` AS `period`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`companynr` AS `companynr`,`test`.`t1`.`price` AS `price`,`test`.`t1`.`price2` AS `price2`,`test`.`t3`.`t2nr` AS `t2nr`,`test`.`t3`.`period` AS `period`,`test`.`t3`.`name` AS `name`,`test`.`t3`.`companynr` AS `companynr`,`test`.`t3`.`price` AS `price`,`test`.`t3`.`price2` AS `price2` from `test`.`t3` `t1` join `test`.`t3` where (`test`.`t3`.`period` = `test`.`t1`.`period`) order by `test`.`t1`.`period` limit 10 +select period from t1; +period +9410 +select period from t1 where period=1900; +period +select fld3,period from t1,t2 where fld1 = 011401 order by period; +fld3 period +breaking 9410 +select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; +fld3 period +breaking 1001 +explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const fld1 fld1 4 const # # NULL +1 SIMPLE t3 NULL const PRIMARY,period PRIMARY 4 const # # NULL +Warnings: +Note 1003 /* select#1 */ select 'breaking' AS `fld3`,'1001' AS `period` from `test`.`t2` join `test`.`t3` where true +select fld3,period from t2,t1 where companynr*10 = 37*10; +fld3 period +Abraham 9410 +Aden 9410 +Adolph 9410 +Aldrich 9410 +Alison 9410 +Anatole 9410 +Antarctica 9410 +Antares 9410 +Arabia 9410 +Artemia 9410 +Augustine 9410 +Baird 9410 +Beebe 9410 +Butterfield 9410 +CERN 9410 +Cassites 9410 +Chicana 9410 +Chippewa 9410 +Clayton 9410 +Conley 9410 +Connally 9410 +Crays 9410 +DiMaggio 9410 +Dutchman 9410 +Eulerian 9410 +Evanston 9410 +Everhart 9410 +Fenton 9410 +Fitzpatrick 9410 +Galatean 9410 +Gandhian 9410 +Ganymede 9410 +Goldstine 9410 +Gothicism 9410 +Graves 9410 +Greenberg 9410 +Gurkha 9410 +Hawaii 9410 +Hegelian 9410 +Hornblower 9410 +Huffman 9410 +Hunter 9410 +Joplin 9410 +Judas 9410 +Kane 9410 +Kantian 9410 +Kevin 9410 +Kinsey 9410 +Kline 9410 +Lars 9410 +Latinizes 9410 +Lillian 9410 +Lizzy 9410 +Majorca 9410 +Manhattanize 9410 +McGovern 9410 +Melinda 9410 +Merritt 9410 +Micronesia 9410 +Miles 9410 +Miltonism 9410 +Nabisco 9410 +Nazis 9410 +Newtonian 9410 +Norwalk 9410 +Pandora 9410 +Parsifal 9410 +Peruvian 9410 +Punjab 9410 +Pyle 9410 +Quixotism 9410 +Romano 9410 +Romans 9410 +Sabine 9410 +Sault 9410 +Saxony 9410 +Selfridge 9410 +Shanghais 9410 +Simla 9410 +Simon 9410 +Stalin 9410 +Steinberg 9410 +Taoism 9410 +Teresa 9410 +Tipperary 9410 +Weissmuller 9410 +Winsett 9410 +Wotan 9410 +abates 9410 +abrogating 9410 +accessed 9410 +admiring 9410 +admonishing 9410 +afield 9410 +afore 9410 +aging 9410 +airships 9410 +alike 9410 +allot 9410 +already 9410 +amenities 9410 +ammonium 9410 +analogy 9410 +analyzable 9410 +animals 9410 +animized 9410 +annihilates 9410 +announced 9410 +announces 9410 +apiary 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +appendixes 9410 +arriving 9410 +arteriole 9410 +assails 9410 +astound 9410 +attainments 9410 +attrition 9410 +audiology 9410 +avenge 9410 +avoidable 9410 +babies 9410 +babysitting 9410 +balled 9410 +beaner 9410 +beaters 9410 +bee 9410 +befouled 9410 +bellow 9410 +bestseller 9410 +betroth 9410 +bewilderingly 9410 +bills 9410 +bitterroot 9410 +bivalves 9410 +bloater 9410 +bloodbath 9410 +boat 9410 +boom 9410 +boorish 9410 +boulder 9410 +breaking 9410 +brunch 9410 +buckboards 9410 +burlesque 9410 +cage 9410 +capably 9410 +capped 9410 +cascade 9410 +causality 9410 +cautioned 9410 +ceiling 9410 +celery 9410 +certificates 9410 +chafe 9410 +chaperone 9410 +charges 9410 +chasm 9410 +checkpoints 9410 +chewing 9410 +chews 9410 +chillingly 9410 +chronicle 9410 +ciphers 9410 +civics 9410 +clamored 9410 +clenched 9410 +clockers 9410 +coexist 9410 +cokes 9410 +combed 9410 +coming 9410 +commencements 9410 +commonplace 9410 +communicants 9410 +compartment 9410 +comprehensive 9410 +comprised 9410 +conceptions 9410 +concludes 9410 +congregates 9410 +contrary 9410 +contrasted 9410 +convenient 9410 +convulsion 9410 +corset 9410 +count 9410 +coverings 9410 +craziness 9410 +creak 9410 +creek 9410 +critiques 9410 +crunches 9410 +culled 9410 +cult 9410 +cupboard 9410 +cured 9410 +cute 9410 +daughter 9410 +decliner 9410 +decomposition 9410 +deductions 9410 +dehydrate 9410 +deludes 9410 +denizen 9410 +denotative 9410 +denounces 9410 +dental 9410 +dentally 9410 +descendants 9410 +despot 9410 +destroyer 9410 +detectably 9410 +dialysis 9410 +dimensions 9410 +disable 9410 +discounts 9410 +disentangle 9410 +disobedience 9410 +dissociate 9410 +dogging 9410 +dopers 9410 +drains 9410 +dreaded 9410 +ducks 9410 +dusted 9410 +effortlessly 9410 +electroencephalography 9410 +elite 9410 +embassies 9410 +employing 9410 +encompass 9410 +encompasses 9410 +environing 9410 +epistle 9410 +equilibrium 9410 +erases 9410 +error 9410 +eschew 9410 +eternal 9410 +evened 9410 +evenhandedly 9410 +eventful 9410 +excises 9410 +exclamation 9410 +excrete 9410 +exhausts 9410 +expelled 9410 +extents 9410 +externally 9410 +extracted 9410 +faithful 9410 +fanatic 9410 +fated 9410 +featherweight 9410 +feed 9410 +feminine 9410 +fetched 9410 +fetters 9410 +fiftieth 9410 +filial 9410 +fingerings 9410 +finishers 9410 +firearm 9410 +fitting 9410 +fixedly 9410 +flanking 9410 +flint 9410 +flopping 9410 +flurried 9410 +foldout 9410 +foothill 9410 +forgivably 9410 +forthcoming 9410 +freakish 9410 +freest 9410 +freezes 9410 +funereal 9410 +furnishings 9410 +furthermore 9410 +gadfly 9410 +gainful 9410 +galling 9410 +garage 9410 +gentleman 9410 +gifted 9410 +gleaning 9410 +glut 9410 +goblins 9410 +governing 9410 +gradually 9410 +grazing 9410 +gritty 9410 +groupings 9410 +guides 9410 +guitars 9410 +handgun 9410 +handy 9410 +heiress 9410 +hoarder 9410 +honoring 9410 +hostess 9410 +humanness 9410 +humiliation 9410 +humility 9410 +hushes 9410 +husky 9410 +hypothesizer 9410 +icon 9410 +ideas 9410 +impelling 9410 +impending 9410 +imperial 9410 +imperiously 9410 +imprint 9410 +impulsive 9410 +inaccuracy 9410 +inch 9410 +incidentals 9410 +incorrectly 9410 +incurring 9410 +index 9410 +indulge 9410 +indulgences 9410 +ineffective 9410 +infallibly 9410 +infest 9410 +inform 9410 +inmate 9410 +insolence 9410 +instruments 9410 +intelligibility 9410 +intentness 9410 +intercepted 9410 +interdependent 9410 +interrelationships 9410 +interrogate 9410 +investigations 9410 +irresponsibly 9410 +jarring 9410 +journalizing 9410 +juveniles 9410 +kanji 9410 +kingdom 9410 +kiting 9410 +labeled 9410 +languages 9410 +laterally 9410 +lawgiver 9410 +leaflet 9410 +leavings 9410 +lectured 9410 +leftover 9410 +lewdly 9410 +lied 9410 +linear 9410 +lists 9410 +lithograph 9410 +lore 9410 +luckily 9410 +males 9410 +marginal 9410 +mastering 9410 +mayoral 9410 +meanwhile 9410 +measures 9410 +measures 9410 +mechanizing 9410 +medical 9410 +meditation 9410 +metaphysically 9410 +mineral 9410 +miniaturizes 9410 +minima 9410 +minion 9410 +minting 9410 +misted 9410 +misunderstander 9410 +mixture 9410 +motors 9410 +mournfulness 9410 +multilayer 9410 +mumbles 9410 +mushrooms 9410 +mystic 9410 +navies 9410 +navigate 9410 +neat 9410 +neonatal 9410 +nested 9410 +noncritical 9410 +normalizes 9410 +obliterates 9410 +offload 9410 +opaquely 9410 +organizer 9410 +overestimating 9410 +overlay 9410 +parametrized 9410 +parenthood 9410 +parters 9410 +participated 9410 +partridges 9410 +peacock 9410 +peeked 9410 +pellagra 9410 +percentage 9410 +percentage 9410 +persist 9410 +perturb 9410 +pessimist 9410 +pests 9410 +petted 9410 +pictures 9410 +pithed 9410 +pityingly 9410 +poison 9410 +posed 9410 +positioning 9410 +postulation 9410 +praised 9410 +precaution 9410 +precipitable 9410 +preclude 9410 +presentation 9410 +pressure 9410 +previewing 9410 +priceless 9410 +primary 9410 +psychic 9410 +publicly 9410 +puddings 9410 +quagmire 9410 +quitter 9410 +railway 9410 +raining 9410 +rains 9410 +ravines 9410 +readable 9410 +realized 9410 +realtor 9410 +reassigned 9410 +recruited 9410 +reduce 9410 +regimented 9410 +registration 9410 +relatively 9410 +relaxing 9410 +relishing 9410 +relives 9410 +renew 9410 +repelled 9410 +repetitions 9410 +reporters 9410 +reporters 9410 +repressions 9410 +resplendent 9410 +resumes 9410 +rifles 9410 +rightful 9410 +rightfully 9410 +rightfulness 9410 +ripeness 9410 +riser 9410 +roped 9410 +rudeness 9410 +rules 9410 +rural 9410 +rusting 9410 +sadly 9410 +sags 9410 +sanding 9410 +saplings 9410 +sating 9410 +save 9410 +sawtooth 9410 +scarf 9410 +scatterbrain 9410 +scheduling 9410 +schemer 9410 +scholastics 9410 +scornfully 9410 +secures 9410 +securing 9410 +seminaries 9410 +serializations 9410 +serpents 9410 +serving 9410 +severely 9410 +sews 9410 +shapelessly 9410 +shipyard 9410 +shooter 9410 +similarities 9410 +skulking 9410 +slaughter 9410 +sloping 9410 +smoothed 9410 +snatching 9410 +socializes 9410 +sophomore 9410 +sorters 9410 +spatial 9410 +specification 9410 +specifics 9410 +spongers 9410 +spools 9410 +sportswriting 9410 +sporty 9410 +squabbled 9410 +squeaking 9410 +squeezes 9410 +stabilizes 9410 +stairway 9410 +standardizes 9410 +star 9410 +starlet 9410 +stated 9410 +stint 9410 +stodgy 9410 +store 9410 +straight 9410 +stranglings 9410 +subdirectory 9410 +subjective 9410 +subschema 9410 +succumbed 9410 +suites 9410 +sumac 9410 +sureties 9410 +swaying 9410 +sweetish 9410 +swelling 9410 +syndicate 9410 +taxonomically 9410 +techniques 9410 +teem 9410 +teethe 9410 +tempering 9410 +terminal 9410 +terminator 9410 +terminators 9410 +test 9410 +testicle 9410 +textures 9410 +theorizers 9410 +throttles 9410 +tidiness 9410 +timesharing 9410 +tinily 9410 +tinting 9410 +title 9410 +tragedies 9410 +traitor 9410 +trimmings 9410 +tropics 9410 +unaffected 9410 +uncovering 9410 +undoes 9410 +ungrateful 9410 +universals 9410 +unplug 9410 +unruly 9410 +untying 9410 +unwilling 9410 +vacuuming 9410 +validate 9410 +vanish 9410 +ventilate 9410 +veranda 9410 +vests 9410 +wallet 9410 +waltz 9410 +warm 9410 +warningly 9410 +watering 9410 +weasels 9410 +western 9410 +whiteners 9410 +widens 9410 +witchcraft 9410 +workers 9410 +yelped 9410 +youthfulness 9410 +select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; +fld3 period price price2 +admonishing 1002 28357832 8723648 +analyzable 1002 28357832 8723648 +annihilates 1001 5987435 234724 +Antares 1002 28357832 8723648 +astound 1001 5987435 234724 +audiology 1001 5987435 234724 +Augustine 1002 28357832 8723648 +Baird 1002 28357832 8723648 +bewilderingly 1001 5987435 234724 +breaking 1001 5987435 234724 +Conley 1001 5987435 234724 +dentally 1002 28357832 8723648 +dissociate 1002 28357832 8723648 +elite 1001 5987435 234724 +eschew 1001 5987435 234724 +Eulerian 1001 5987435 234724 +flanking 1001 5987435 234724 +foldout 1002 28357832 8723648 +funereal 1002 28357832 8723648 +galling 1002 28357832 8723648 +Graves 1001 5987435 234724 +grazing 1001 5987435 234724 +groupings 1001 5987435 234724 +handgun 1001 5987435 234724 +humility 1002 28357832 8723648 +impulsive 1002 28357832 8723648 +inch 1001 5987435 234724 +intelligibility 1001 5987435 234724 +jarring 1001 5987435 234724 +lawgiver 1001 5987435 234724 +lectured 1002 28357832 8723648 +Merritt 1002 28357832 8723648 +neonatal 1001 5987435 234724 +offload 1002 28357832 8723648 +parters 1002 28357832 8723648 +pityingly 1002 28357832 8723648 +puddings 1002 28357832 8723648 +Punjab 1001 5987435 234724 +quitter 1002 28357832 8723648 +realtor 1001 5987435 234724 +relaxing 1001 5987435 234724 +repetitions 1001 5987435 234724 +resumes 1001 5987435 234724 +Romans 1002 28357832 8723648 +rusting 1001 5987435 234724 +scholastics 1001 5987435 234724 +skulking 1002 28357832 8723648 +stated 1002 28357832 8723648 +suites 1002 28357832 8723648 +sureties 1001 5987435 234724 +testicle 1002 28357832 8723648 +tinily 1002 28357832 8723648 +tragedies 1001 5987435 234724 +trimmings 1001 5987435 234724 +vacuuming 1001 5987435 234724 +ventilate 1001 5987435 234724 +wallet 1001 5987435 234724 +Weissmuller 1002 28357832 8723648 +Wotan 1002 28357832 8723648 +select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; +fld1 fld3 period price price2 +018201 relaxing 1001 5987435 234724 +018601 vacuuming 1001 5987435 234724 +018801 inch 1001 5987435 234724 +018811 repetitions 1001 5987435 234724 +create table t4 ( +companynr tinyint(2) unsigned zerofill NOT NULL default '00', +companyname char(30) NOT NULL default '', +PRIMARY KEY (companynr), +UNIQUE KEY companyname(companyname) +) MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr order by t2.companynr; +companynr companyname +00 Unknown +29 company 1 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +50 company 11 +53 company 7 +58 company 8 +65 company 9 +68 company 10 +select * from t1,t1 t12; +Period Varor_period Period Varor_period +9410 9412 9410 9412 +select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; +fld1 fld1 +250501 250501 +250501 250502 +250501 250503 +250501 250504 +250501 250505 +250502 250501 +250502 250502 +250502 250503 +250502 250504 +250502 250505 +250503 250501 +250503 250502 +250503 250503 +250503 250504 +250503 250505 +250504 250501 +250504 250502 +250504 250503 +250504 250504 +250504 250505 +250505 250501 +250505 250502 +250505 250503 +250505 250504 +250505 250505 +insert into t2 (fld1, companynr) values (999999,99); +analyze table t2,t4; +Table Op Msg_type Msg_text +test.t2 analyze status OK +test.t4 analyze status OK +select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +companynr companyname +99 NULL +select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; +count(*) +1199 +explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # 100.00 Using where; Not exists +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`)) where (`test`.`t4`.`companynr` is null) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 10.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t2`.`companynr` is null) +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +companynr companyname +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +count(*) +1200 +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t2` left join `test`.`t4` on(multiple equal(`test`.`t2`.`companynr`, `test`.`t4`.`companynr`)) where false +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on(multiple equal(`test`.`t4`.`companynr`, `test`.`t2`.`companynr`)) where false +delete from t2 where fld1=999999; +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +2 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 1 test.t2.companynr # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` join `test`.`t2` where ((`test`.`t4`.`companynr` = `test`.`t2`.`companynr`) and (`test`.`t2`.`companynr` > 0) and (`test`.`t2`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) and (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t2`.`companynr` is null)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index PRIMARY companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t2`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t2`.`companynr`,1) > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (`test`.`t4`.`companynr` > 0) +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL range PRIMARY PRIMARY 1 NULL # # Using where +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where ((`test`.`t4`.`companynr` > 0) or (`test`.`t4`.`companynr` > 0)) +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using where; Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`companynr` AS `companynr`,`test`.`t4`.`companyname` AS `companyname` from `test`.`t4` left join `test`.`t2` on((`test`.`t2`.`companynr` = `test`.`t4`.`companynr`)) where (ifnull(`test`.`t4`.`companynr`,1) > 0) +select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +companynr companynr +37 36 +41 40 +explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL index NULL companyname 120 NULL # # Using index; Using temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`companynr` AS `companynr`,`test`.`t4`.`companynr` AS `companynr` from `test`.`t2` join `test`.`t4` where (`test`.`t2`.`companynr` = (`test`.`t4`.`companynr` + 1)) +select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; +fld1 companynr fld3 period +038008 37 reporters 1008 +038208 37 Selfridge 1008 +select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); +period +9410 +select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); +period +9410 +select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; +fld1 +250501 +250502 +250503 +250505 +select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); +fld1 +250502 +250503 +select fld1 from t2 where fld1 between 250502 and 250504; +fld1 +250502 +250503 +250504 +select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; +fld3 +label +labeled +labeled +landslide +laterally +leaflet +lewdly +Lillian +luckily +select count(*) from t1; +count(*) +1 +select companynr,count(*),sum(fld1) from t2 group by companynr order by companynr; +companynr count(*) sum(fld1) +00 82 10355753 +29 95 14473298 +34 70 17788966 +36 215 22786296 +37 588 83602098 +40 37 6618386 +41 52 12816335 +50 11 1595438 +53 4 793210 +58 23 2254293 +65 10 2284055 +68 12 3097288 +select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; +companynr count(*) +68 12 +65 10 +58 23 +53 4 +50 11 +select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +explain select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> '')) +select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr order by companynr limit 3; +companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) +00 82 Anthony windmills 10355753 126289.6707 115550.97568479746 13352027981.708656 +29 95 abut wetness 14473298 152350.5053 8368.547956641249 70032594.90260443 +34 70 absentee vest 17788966 254128.0857 3272.5939722090234 10709871.306938833 +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select /*! SQL_SMALL_RESULT */ +companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr, t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr order by companynr; +companynr count(price) sum(price) min(price) max(price) avg(price) +37 12543 309394878010 5987435 39654943 24666736.6667 +78 8362 414611089292 726498 98439034 49582766.0000 +101 4181 3489454238 834598 834598 834598.0000 +154 4181 4112197254950 983543950 983543950 983543950.0000 +311 4181 979599938 234298 234298 234298.0000 +447 4181 9929180954 2374834 2374834 2374834.0000 +512 4181 3288532102 786542 786542 786542.0000 +select distinct mod(companynr,10) from t4 group by companynr; +mod(companynr,10) +9 +8 +0 +4 +6 +7 +1 +3 +5 +select distinct 1 from t4 group by companynr; +1 +1 +select count(distinct fld1) from t2; +count(distinct fld1) +1199 +select companynr,count(distinct fld1) from t2 group by companynr; +companynr count(distinct fld1) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(*) from t2 group by companynr order by companynr; +companynr count(*) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,1000))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; +companynr count(distinct concat(fld1,repeat(65,200))) +00 82 +29 95 +34 70 +36 215 +37 588 +40 37 +41 52 +50 11 +53 4 +58 23 +65 10 +68 12 +select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; +companynr count(distinct floor(fld1/100)) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; +companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) +00 47 +29 35 +34 14 +36 69 +37 108 +40 16 +41 11 +50 9 +53 1 +58 1 +65 1 +68 1 +select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; +sum(fld1) fld3 +11402 Romans +select name,count(*) from t3 where name='cloakroom' group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name='cloakroom' and price>10 group by name; +name count(*) +cloakroom 4181 +select count(*) from t3 where name='cloakroom' and price2=823742; +count(*) +4181 +select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; +name count(*) +cloakroom 4181 +select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; +name count(*) +extramarital 4181 +gazer 4181 +gems 4181 +Iranizes 4181 +spates 4181 +tucked 4181 +violinist 4181 +select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld3 count(*) +spates 4181 +select companynr|0,companyname from t4 group by 1; +companynr|0 companyname +29 company 1 +68 company 10 +50 company 11 +34 company 2 +36 company 3 +37 company 4 +40 company 5 +41 company 6 +53 company 7 +58 company 8 +65 company 9 +0 Unknown +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; +companynr companyname count(*) +29 company 1 95 +68 company 10 12 +50 company 11 11 +34 company 2 70 +36 company 3 215 +37 company 4 588 +40 company 5 37 +41 company 6 52 +53 company 7 4 +58 company 8 23 +65 company 9 10 +00 Unknown 82 +select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; +fld1 count(*) +158402 4181 +select sum(Period)/count(*) from t1; +sum(Period)/count(*) +9410.0000 +select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr order by companynr; +companynr count sum diff func +37 12543 309394878010 0.0000 464091 +78 8362 414611089292 0.0000 652236 +101 4181 3489454238 0.0000 422281 +154 4181 4112197254950 0.0000 643874 +311 4181 979599938 0.0000 1300291 +447 4181 9929180954 0.0000 1868907 +512 4181 3288532102 0.0000 2140672 +select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; +companynr avg +154 983543950.0000 +select companynr,count(*) from t2 group by companynr order by 2 desc; +companynr count(*) +37 588 +36 215 +29 95 +00 82 +34 70 +41 52 +40 37 +58 23 +68 12 +50 11 +65 10 +53 4 +select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; +companynr count(*) +41 52 +58 23 +68 12 +50 11 +65 10 +53 4 +select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4 order by fld1; +fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) +teethe 000001 1 5987435 5987435 5987435 5987435.0000 +dreaded 011401 1 5987435 5987435 5987435 5987435.0000 +scholastics 011402 1 28357832 28357832 28357832 28357832.0000 +audiology 011403 1 39654943 39654943 39654943 39654943.0000 +wallet 011501 1 5987435 5987435 5987435 5987435.0000 +parters 011701 1 5987435 5987435 5987435 5987435.0000 +eschew 011702 1 28357832 28357832 28357832 28357832.0000 +quitter 011703 1 39654943 39654943 39654943 39654943.0000 +neat 012001 1 5987435 5987435 5987435 5987435.0000 +Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 +balled 012301 1 5987435 5987435 5987435 5987435.0000 +persist 012302 1 28357832 28357832 28357832 28357832.0000 +attainments 012303 1 39654943 39654943 39654943 39654943.0000 +capably 012501 1 5987435 5987435 5987435 5987435.0000 +impulsive 012602 1 28357832 28357832 28357832 28357832.0000 +starlet 012603 1 39654943 39654943 39654943 39654943.0000 +featherweight 012701 1 5987435 5987435 5987435 5987435.0000 +pessimist 012702 1 28357832 28357832 28357832 28357832.0000 +daughter 012703 1 39654943 39654943 39654943 39654943.0000 +lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 +stated 013602 1 28357832 28357832 28357832 28357832.0000 +readable 013603 1 39654943 39654943 39654943 39654943.0000 +testicle 013801 1 5987435 5987435 5987435 5987435.0000 +Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 +leavings 013803 1 39654943 39654943 39654943 39654943.0000 +squeaking 013901 1 5987435 5987435 5987435 5987435.0000 +contrasted 016001 1 5987435 5987435 5987435 5987435.0000 +leftover 016201 1 5987435 5987435 5987435 5987435.0000 +whiteners 016202 1 28357832 28357832 28357832 28357832.0000 +erases 016301 1 5987435 5987435 5987435 5987435.0000 +Punjab 016302 1 28357832 28357832 28357832 28357832.0000 +Merritt 016303 1 39654943 39654943 39654943 39654943.0000 +sweetish 018001 1 5987435 5987435 5987435 5987435.0000 +dogging 018002 1 28357832 28357832 28357832 28357832.0000 +scornfully 018003 1 39654943 39654943 39654943 39654943.0000 +fetters 018012 1 28357832 28357832 28357832 28357832.0000 +bivalves 018013 1 39654943 39654943 39654943 39654943.0000 +skulking 018021 1 5987435 5987435 5987435 5987435.0000 +flint 018022 1 28357832 28357832 28357832 28357832.0000 +flopping 018023 1 39654943 39654943 39654943 39654943.0000 +Judas 018032 1 28357832 28357832 28357832 28357832.0000 +vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 +medical 018041 1 5987435 5987435 5987435 5987435.0000 +bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 +subschema 018043 1 39654943 39654943 39654943 39654943.0000 +interdependent 018051 1 5987435 5987435 5987435 5987435.0000 +Graves 018052 1 28357832 28357832 28357832 28357832.0000 +neonatal 018053 1 39654943 39654943 39654943 39654943.0000 +sorters 018061 1 5987435 5987435 5987435 5987435.0000 +epistle 018062 1 28357832 28357832 28357832 28357832.0000 +Conley 018101 1 5987435 5987435 5987435 5987435.0000 +lectured 018102 1 28357832 28357832 28357832 28357832.0000 +Abraham 018103 1 39654943 39654943 39654943 39654943.0000 +cage 018201 1 5987435 5987435 5987435 5987435.0000 +hushes 018202 1 28357832 28357832 28357832 28357832.0000 +Simla 018402 1 28357832 28357832 28357832 28357832.0000 +reporters 018403 1 39654943 39654943 39654943 39654943.0000 +coexist 018601 1 5987435 5987435 5987435 5987435.0000 +Beebe 018602 1 28357832 28357832 28357832 28357832.0000 +Taoism 018603 1 39654943 39654943 39654943 39654943.0000 +Connally 018801 1 5987435 5987435 5987435 5987435.0000 +fetched 018802 1 28357832 28357832 28357832 28357832.0000 +checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 +gritty 018811 1 5987435 5987435 5987435 5987435.0000 +firearm 018812 1 28357832 28357832 28357832 28357832.0000 +minima 019101 1 5987435 5987435 5987435 5987435.0000 +Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 +disable 019103 1 39654943 39654943 39654943 39654943.0000 +witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 +betroth 030501 1 5987435 5987435 5987435 5987435.0000 +Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 +imprint 030503 1 39654943 39654943 39654943 39654943.0000 +swelling 031901 1 5987435 5987435 5987435 5987435.0000 +interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 +riser 036002 1 28357832 28357832 28357832 28357832.0000 +bee 038001 1 5987435 5987435 5987435 5987435.0000 +kanji 038002 1 28357832 28357832 28357832 28357832.0000 +dental 038003 1 39654943 39654943 39654943 39654943.0000 +railway 038011 1 5987435 5987435 5987435 5987435.0000 +validate 038012 1 28357832 28357832 28357832 28357832.0000 +normalizes 038013 1 39654943 39654943 39654943 39654943.0000 +Kline 038101 1 5987435 5987435 5987435 5987435.0000 +Anatole 038102 1 28357832 28357832 28357832 28357832.0000 +partridges 038103 1 39654943 39654943 39654943 39654943.0000 +recruited 038201 1 5987435 5987435 5987435 5987435.0000 +dimensions 038202 1 28357832 28357832 28357832 28357832.0000 +Chicana 038203 1 39654943 39654943 39654943 39654943.0000 +select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3 order by fld3; +companynr fld3 sum(price) +512 boat 786542 +512 capably 786542 +512 cupboard 786542 +512 decliner 786542 +512 descendants 786542 +512 dopers 786542 +512 erases 786542 +512 Micronesia 786542 +512 Miles 786542 +512 skies 786542 +select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr order by companynr; +companynr count(*) min(fld3) max(fld3) sum(price) avg(price) +00 1 Omaha Omaha 5987435 5987435.0000 +36 1 dubbed dubbed 28357832 28357832.0000 +37 83 Abraham Wotan 1908978016 22999735.1325 +50 2 scribbled tapestry 68012775 34006387.5000 +select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; +t3.companynr+0 t2nr fld3 sum(price) +37 1 Omaha 5987435 +37 11401 breaking 5987435 +37 11402 Romans 28357832 +37 11403 intercepted 39654943 +37 11501 bewilderingly 5987435 +37 11701 astound 5987435 +37 11702 admonishing 28357832 +37 11703 sumac 39654943 +37 12001 flanking 5987435 +37 12003 combed 39654943 +37 12301 Eulerian 5987435 +37 12302 dubbed 28357832 +37 12303 Kane 39654943 +37 12501 annihilates 5987435 +37 12602 Wotan 28357832 +37 12603 snatching 39654943 +37 12701 grazing 5987435 +37 12702 Baird 28357832 +37 12703 celery 39654943 +37 13601 handgun 5987435 +37 13602 foldout 28357832 +37 13603 mystic 39654943 +37 13801 intelligibility 5987435 +37 13802 Augustine 28357832 +37 13803 teethe 39654943 +37 13901 scholastics 5987435 +37 16001 audiology 5987435 +37 16201 wallet 5987435 +37 16202 parters 28357832 +37 16301 eschew 5987435 +37 16302 quitter 28357832 +37 16303 neat 39654943 +37 18001 jarring 5987435 +37 18002 tinily 28357832 +37 18003 balled 39654943 +37 18012 impulsive 28357832 +37 18013 starlet 39654943 +37 18021 lawgiver 5987435 +37 18022 stated 28357832 +37 18023 readable 39654943 +37 18032 testicle 28357832 +37 18033 Parsifal 39654943 +37 18041 Punjab 5987435 +37 18042 Merritt 28357832 +37 18043 Quixotism 39654943 +37 18051 sureties 5987435 +37 18052 puddings 28357832 +37 18053 tapestry 39654943 +37 18061 trimmings 5987435 +37 18062 humility 28357832 +37 18101 tragedies 5987435 +37 18102 skulking 28357832 +37 18103 flint 39654943 +37 18201 relaxing 5987435 +37 18202 offload 28357832 +37 18402 suites 28357832 +37 18403 lists 39654943 +37 18601 vacuuming 5987435 +37 18602 dentally 28357832 +37 18603 humanness 39654943 +37 18801 inch 5987435 +37 18802 Weissmuller 28357832 +37 18803 irresponsibly 39654943 +37 18811 repetitions 5987435 +37 18812 Antares 28357832 +37 19101 ventilate 5987435 +37 19102 pityingly 28357832 +37 19103 interdependent 39654943 +37 19201 Graves 5987435 +37 30501 neonatal 5987435 +37 30502 scribbled 28357832 +37 30503 chafe 39654943 +37 31901 realtor 5987435 +37 36001 elite 5987435 +37 36002 funereal 28357832 +37 38001 Conley 5987435 +37 38002 lectured 28357832 +37 38003 Abraham 39654943 +37 38011 groupings 5987435 +37 38012 dissociate 28357832 +37 38013 coexist 39654943 +37 38101 rusting 5987435 +37 38102 galling 28357832 +37 38103 obliterates 39654943 +37 38201 resumes 5987435 +37 38202 analyzable 28357832 +37 38203 terminator 39654943 +select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; +sum(price) +234298 +select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; +fld1 sum(price) +038008 234298 +explain select fld3 from t2 where 1>2 or 2>3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL # # Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where false +explain select fld3 from t2 where fld1=fld1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`fld3` AS `fld3` from `test`.`t2` where true +select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; +companynr fld1 +34 250501 +34 250502 +select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; +companynr count sum +00 82 10355753 +37 588 83602098 +29 95 14473298 +41 52 12816335 +34 70 17788966 +select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; +companynr +00 +37 +29 +41 +34 +select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40 order by t2.companynr; +companynr companyname count(*) +40 company 5 37 +41 company 6 52 +50 company 11 11 +53 company 7 4 +58 company 8 23 +65 company 9 10 +68 company 10 12 +select count(*) from t2; +count(*) +1199 +select count(*) from t2 where fld1 < 098024; +count(*) +387 +select min(fld1) from t2 where fld1>= 098024; +min(fld1) +98024 +select max(fld1) from t2 where fld1>= 098024; +max(fld1) +1232609 +select count(*) from t3 where price2=76234234; +count(*) +4181 +select count(*) from t3 where companynr=512 and price2=76234234; +count(*) +4181 +explain select min(fld1),max(fld1),count(*) from t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index NULL fld1 4 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t2`.`fld1`) AS `min(fld1)`,max(`test`.`t2`.`fld1`) AS `max(fld1)`,count(0) AS `count(*)` from `test`.`t2` +select min(fld1),max(fld1),count(*) from t2; +min(fld1) max(fld1) count(*) +0 1232609 1199 +select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; +min(t2nr) max(t2nr) +2115 2115 +select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; +count(*) min(t2nr) max(t2nr) +4181 4 41804 +select t2nr,count(*) from t3 where name='gems' group by t2nr order by t2nr limit 20; +t2nr count(*) +9 1 +19 1 +29 1 +39 1 +49 1 +59 1 +69 1 +79 1 +89 1 +99 1 +109 1 +119 1 +129 1 +139 1 +149 1 +159 1 +169 1 +179 1 +189 1 +199 1 +select max(t2nr) from t3 where price=983543950; +max(t2nr) +41807 +select t1.period from t3 t1 limit 1; +period +1001 +select t1.period from t1 as t1 limit 1; +period +9410 +select t1.period as "Nuvarande period" from t1 as t1 limit 1; +Nuvarande period +9410 +select period as ok_period from t1 limit 1; +ok_period +9410 +select period as ok_period from t1 group by ok_period limit 1; +ok_period +9410 +select 1+1 as summa from t1 group by summa limit 1; +summa +2 +select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; +Nuvarande period +9410 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +show tables from test like "s%"; +Tables_in_test (s%) +show tables from test like "t?"; +Tables_in_test (t?) +show full columns from t2; +Field Type Collation Null Key Default Extra Privileges Comment +auto int NULL NO PRI NULL auto_increment select,insert,update,references +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +companynr tinyint(2) unsigned zerofill NULL NO 00 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 'f%'; +Field Type Collation Null Key Default Extra Privileges Comment +fld1 int(6) unsigned zerofill NULL NO UNI 000000 select,insert,update,references +fld3 char(30) utf8mb4_0900_ai_ci NO MUL select,insert,update,references +fld4 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld5 char(35) utf8mb4_0900_ai_ci NO select,insert,update,references +fld6 char(4) utf8mb4_0900_ai_ci NO select,insert,update,references +show full columns from t2 from test like 's%'; +Field Type Collation Null Key Default Extra Privileges Comment +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t2 0 PRIMARY 1 auto A # NULL NULL BTREE YES NULL +t2 0 fld1 1 fld1 A # NULL NULL BTREE YES NULL +t2 1 fld3 1 fld3 A # NULL NULL BTREE YES NULL +drop table t4, t3, t2, t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +cont_nr int(11) NOT NULL auto_increment, +ver_nr int(11) NOT NULL default '0', +aufnr int(11) NOT NULL default '0', +username varchar(50) NOT NULL default '', +hdl_nr int(11) NOT NULL default '0', +eintrag date NOT NULL default '0000-00-00', +st_klasse varchar(40) NOT NULL default '', +st_wert varchar(40) NOT NULL default '', +st_zusatz varchar(40) NOT NULL default '', +st_bemerkung varchar(255) NOT NULL default '', +kunden_art varchar(40) NOT NULL default '', +mcbs_knr int(11) default NULL, +mcbs_aufnr int(11) NOT NULL default '0', +schufa_status char(1) default '?', +bemerkung text, +wirknetz text, +wf_igz int(11) NOT NULL default '0', +tarifcode varchar(80) default NULL, +recycle char(1) default NULL, +sim varchar(30) default NULL, +mcbs_tpl varchar(30) default NULL, +emp_nr int(11) NOT NULL default '0', +laufzeit int(11) default NULL, +hdl_name varchar(30) default NULL, +prov_hdl_nr int(11) NOT NULL default '0', +auto_wirknetz varchar(50) default NULL, +auto_billing varchar(50) default NULL, +touch timestamp NOT NULL, +kategorie varchar(50) default NULL, +kundentyp varchar(20) NOT NULL default '', +sammel_rech_msisdn varchar(30) NOT NULL default '', +p_nr varchar(9) NOT NULL default '', +suffix char(3) NOT NULL default '', +PRIMARY KEY (cont_nr), +KEY idx_aufnr(aufnr), +KEY idx_hdl_nr(hdl_nr), +KEY idx_st_klasse(st_klasse), +KEY ver_nr(ver_nr), +KEY eintrag_idx(eintrag), +KEY emp_nr_idx(emp_nr), +KEY wf_igz(wf_igz), +KEY touch(touch), +KEY hdl_tag(eintrag,hdl_nr), +KEY prov_hdl_nr(prov_hdl_nr), +KEY mcbs_aufnr(mcbs_aufnr), +KEY kundentyp(kundentyp), +KEY p_nr(p_nr,suffix) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET sql_mode = default; +INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007'); +INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','',''); +SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie; +Kundentyp kategorie +Privat (Private Nutzung) Mobilfunk +Warnings: +Warning 1052 Column 'kundentyp' in group statement is ambiguous +drop table t1; +SHOW STATUS LIKE 'Ssl_cipher'; +Variable_name Value +Ssl_cipher SSL_CIPHER +SHOW STATUS LIKE 'Compression'; +Variable_name Value +Compression ON diff --git a/mysql-test/r/status.result-pq b/mysql-test/r/status.result-pq new file mode 100644 index 000000000..ad14ef6cb --- /dev/null +++ b/mysql-test/r/status.result-pq @@ -0,0 +1,521 @@ +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; +SET @old_log_output = @@global.log_output; +SET GLOBAL LOG_OUTPUT = 'FILE'; +flush status; +show status like 'Table_lock%'; +Variable_name Value +Table_locks_immediate 1 +Table_locks_waited 0 +select * from performance_schema.session_status where variable_name like 'Table_lock%'; +VARIABLE_NAME VARIABLE_VALUE +Table_locks_immediate 2 +Table_locks_waited 0 +set sql_log_bin=0; +set @old_general_log = @@global.general_log; +set global general_log = 'OFF'; +drop table if exists t1; +create table t1(n int); +insert into t1 values(1); +select get_lock('mysqltest_lock', 100); +get_lock('mysqltest_lock', 100) +1 +# Switched to connection: con2 +# Sending: +update t1 set n = get_lock('mysqltest_lock', 100) ; +# Switched to connection: con1 +# Wait for the first UPDATE to get blocked. +# Sending: +update t1 set n = 3; +# Switched to connection: default +# wait for the second UPDATE to get blocked +Timeout in wait_condition.inc for select 1 from INFORMATION_SCHEMA.PROCESSLIST +where ID = (select connection_id()) and STATE = "Waiting for table level lock" +select release_lock('mysqltest_lock'); +release_lock('mysqltest_lock') +1 +# Switched to connection: con2 +# Reaping first UPDATE +select release_lock('mysqltest_lock'); +release_lock('mysqltest_lock') +1 +# Switched to connection: con1 +# Reaping second UPDATE +show status like 'Table_locks_waited'; +Variable_name Value +Table_locks_waited 0 +# Switched to connection: default +drop table t1; +set global general_log = @old_general_log; +select 1; +1 +1 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 0.000000 +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where a=6; +a +6 +6 +6 +6 +6 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 5.249000 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 5.249000 +select 1; +1 +1 +show status like 'last_query_cost'; +Variable_name Value +Last_query_cost 0.000000 +drop table t1; +FLUSH STATUS; +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 1 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 1 +SET @save_thread_cache_size=@@thread_cache_size; +SET GLOBAL thread_cache_size=3; +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 3 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 3 +FLUSH STATUS; +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 2 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 2 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 3 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 3 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 4 +SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE 'max_used_connections'; +VARIABLE_NAME VARIABLE_VALUE +Max_used_connections 4 +SET GLOBAL thread_cache_size=@save_thread_cache_size; +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1), (2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT a FROM t1 LIMIT 1; +a +1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.449000 +EXPLAIN SELECT a FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.449000 +SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a; +a +1 +2 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `a` +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1; +a IN (SELECT a FROM t1) +1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1; +x +1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.898000 +SELECT * FROM t1 a, t1 b ORDER BY a.a, b.a LIMIT 1; +a a +1 1 +SHOW SESSION STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.099010 +DROP TABLE t1; +flush status; +show status like 'Com%function'; +Variable_name Value +Com_alter_function 0 +Com_create_function 0 +Com_drop_function 0 +create function f1 (x INTEGER) returns integer +begin +declare ret integer; +set ret = x * 10; +return ret; +end // +drop function f1; +show status like 'Com%function'; +Variable_name Value +Com_alter_function 0 +Com_create_function 1 +Com_drop_function 1 +create database db37908; +create table db37908.t1(f1 int); +insert into db37908.t1 values(1); +create user mysqltest_1@localhost; +grant usage,execute on test.* to mysqltest_1@localhost; +create procedure proc37908() begin select 1; end | +create function func37908() returns int sql security invoker +return (select * from db37908.t1 limit 1)| +select * from db37908.t1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +show status where variable_name ='uptime' and 2 in (select * from db37908.t1); +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +show procedure status where name ='proc37908' and 1 in (select f1 from db37908.t1); +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +show function status where name ='func37908' and 1 in (select func37908()); +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1' +drop database db37908; +drop procedure proc37908; +drop function func37908; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +DROP USER mysqltest_1@localhost; +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INTEGER +BEGIN +DECLARE foo INTEGER; +DECLARE bar INTEGER; +SET foo=1; +SET bar=2; +RETURN foo; +END $$ +CREATE PROCEDURE p1() +BEGIN +SELECT 1; +END $$ +SELECT f1(); +f1() +1 +CALL p1(); +1 +1 +SELECT 9; +9 +9 +DROP PROCEDURE p1; +DROP FUNCTION f1; +# +# Test coverage for status variables which were introduced by +# WL#5772 "Add partitioned Table Definition Cache to avoid +# using LOCK_open and its derivatives in DML queries". +# +create table t1 (i int); +create table t2 (j int); +create table t3 (k int); +# Flush table cache to ensure that it is empty and reset status +# variables. Since to test cache overflow we will need to reduce +# its size, also save original table cache size. +flush tables; +flush status; +set @old_table_open_cache= @@table_open_cache; +# Check that after reset all status variables are zero. +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 0 +Table_open_cache_misses 0 +Table_open_cache_overflows 0 +# The first statement accessing t1 after flush should result +# in table cache miss. +select * from t1; +i +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 1 +Table_open_cache_misses 16 +Table_open_cache_overflows 0 +# The second statement accessing the same table should +# result in table cache hit. +select * from t1; +i +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 2 +Table_open_cache_misses 16 +Table_open_cache_overflows 0 +# Again table cache miss if accessing different table. +select * from t2; +j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 18 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# And cache hit then accessing it second time. +select * from t2; +j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 19 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# The below statement should result in 2 cache hits and +# 4 cache misses since it needs 6 table instances in total. +select * from t1 as a, t2 as b, t1 as c, t2 as d, t1 as e, t2 as f; +i j i j i j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 25 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# Reduce size of table cache to check that status +# variable tracking cache overflows works. +set @@global.table_open_cache= 4; +# The below statement should result in table cache hit, but +# as a side effect it should result in trimming of table +# cache by 2 TABLE instances, meaning that overflow counter +# will get increased by 2. +select * from t1; +i +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 26 +Table_open_cache_misses 17 +Table_open_cache_overflows 0 +# This statement should result in 4 cache hits, 2 cache misses/ +# overflows. +select * from t1 as a, t2 as b, t1 as c, t2 as d, t1 as e, t2 as f; +i j i j i j +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 28 +Table_open_cache_misses 21 +Table_open_cache_overflows 4 +# Finally, the below statement should result in 1 cache miss +# and 1 overflow since it accesses table which is not yet in +# cache and table cache is full. +select * from t3; +k +show status like 'table_open_cache_%'; +Variable_name Value +Table_open_cache_hits 28 +Table_open_cache_misses 38 +Table_open_cache_overflows 21 +# Cleanup +set @@global.table_open_cache= @old_table_open_cache; +drop tables t1, t2, t3; +SHOW STATUS LIKE 'max_used_connections_time'; +Variable_name Value +Max_used_connections_time DTVALUE +# Should report 4 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 4 +# Should report 4 +SHOW STATUS LIKE 'max_used_connections'; +Variable_name Value +Max_used_connections 4 +# This should report 0 as it must have the same value as above +TIMESTAMPDIFF(SECOND,'DTVALUE','DTVALUE') <> 0 +0 +# This should report 0 as timestamp is updated only when connection count strictly exceeds the previos highest value +TIMESTAMPDIFF(SECOND,'DTVALUE','DTVALUE') <> 0 +0 +FLUSH STATUS; +# This should not report 0 as FLUSH STATUS is called. +TIMESTAMPDIFF(SECOND,'DTVALUE','DTVALUE') <> 0 +1 +set @@global.concurrent_insert= @old_concurrent_insert; +SET GLOBAL log_output = @old_log_output; +# +# Bug#28786951 SET LAST_QUERY_COST FOR QUERIES WITH SUBQUERIES AND UNIONS +# +CREATE TABLE t1(x INT, y INT); +INSERT INTO t1 VALUES (1, 2), (3, 4), (5, 6); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN SELECT (SELECT MAX(x) FROM t1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`t1`.`x`) from `test`.`t1`) AS `(SELECT MAX(x) FROM t1)` from `test`.`t1` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN SELECT * FROM t1 WHERE x IN (SELECT MAX(x) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x`,(/* select#2 */ select max(`test`.`t1`.`x`) from `test`.`t1` having ((`test`.`t1`.`x`) = (max(`test`.`t1`.`x`))))) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 2.196000 +EXPLAIN SELECT /*+ NO_MERGE(a) */ * FROM (SELECT * FROM t1) a, t1 b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY b NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_MERGE(`a`@`select#1`) */ `a`.`x` AS `x`,`a`.`y` AS `y`,`test`.`b`.`x` AS `x`,`test`.`b`.`y` AS `y` from (/* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1`) `a` join `test`.`t1` `b` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 4.535526 +EXPLAIN SELECT * FROM t1 WHERE x > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN SELECT * FROM t1 WHERE x > 0 +UNION ALL +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union all /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN SELECT * FROM t1 WHERE x > 0 +UNION DISTINCT +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN INSERT INTO t1 SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select sql_buffer_result `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 0.549000 +EXPLAIN INSERT INTO t1 +SELECT * FROM t1 WHERE x > 0 +UNION ALL +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union all /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +EXPLAIN INSERT INTO t1 +SELECT * FROM t1 WHERE x > 0 +UNION DISTINCT +SELECT * FROM t1 WHERE y > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 NULL ALL NULL NULL NULL NULL NULL NULL NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 UNION t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +Warnings: +Note 1003 insert into `test`.`t1` /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`x` > 0) union /* select#2 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y` from `test`.`t1` where (`test`.`t1`.`y` > 0) +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 1.098000 +DROP TABLE t1; +# +# Bug#28884359: LAST_QUERY_COST IS NEGATIVE AFTER ORDER BY/LIMIT QUERY +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, +i1 INTEGER, +i2 INTEGER NOT NULL, +INDEX k1 (i1), +INDEX k2 (i1, i2)); +INSERT INTO t1 VALUES +(1, NULL, 43), (11, NULL, 103), (10, 32,50), (9, 12, 43), +(8, NULL, 13), (7, 48, 90), (6, 56, 90), (5, 87, 84), +(4, 58, 98), (3, 30, 82), (2, 54, 57), (12, 232, 43), +(13, 43, 103), (14, 32, 45), (15, 12, 43), (16, 89, 23), +(17, 48, 90), (18, 56, 90), (19, 87, 84); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, +i1 INTEGER NOT NULL, +INDEX k1 (i1)); +INSERT INTO t2 VALUES +(3, 89), (4, 98), (5, 84), (6, 8), (7, 99), (8, 110), +(9, 84), (10, 98), (11, 103), (12, 50), (13, 84), +(14, 57), (15, 82), (16, 103), (2, 98), (1, 90); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1, t2 WHERE t1.i1 = t2.i1 ORDER BY t1.i1 LIMIT 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index k1,k2 k2 9 NULL 10 100.00 Using where; Using index +2 SIMPLE t2 NULL ref k1 k1 4 test.t1.i1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i1` AS `i1` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`i1` = `test`.`t1`.`i1`) order by `test`.`t1`.`i1` limit 10 +SHOW STATUS LIKE 'Last_query_cost'; +Variable_name Value +Last_query_cost 9.664743 +DROP TABLE t1, t2; diff --git a/mysql-test/r/subquery_antijoin.result-pq b/mysql-test/r/subquery_antijoin.result-pq new file mode 100644 index 000000000..06079ac3a --- /dev/null +++ b/mysql-test/r/subquery_antijoin.result-pq @@ -0,0 +1,1155 @@ +CREATE TABLE t1( +pk INTEGER PRIMARY KEY, +uk INTEGER UNIQUE, +ukn INTEGER UNIQUE NOT NULL, +ik INTEGER, +d INTEGER, +INDEX ik(ik)); +INSERT INTO t1 VALUES +(0, NULL, 0, NULL, NULL), +(1, 10, 20, 30, 40), +(2, 20, 40, 60, 80); +CREATE TABLE t2( +pk INTEGER PRIMARY KEY); +INSERT INTO t2 VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30), +(31),(32),(33),(34),(35),(36),(37),(38),(39),(40), +(41),(42),(43),(44),(45),(46),(47),(48),(49),(50), +(51),(52),(53),(54),(55),(56),(57),(58),(59),(60), +(61),(62),(63),(64),(65),(66),(67),(68),(69),(70), +(71),(72),(73),(74),(75),(76),(77),(78),(79),(80); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +set optimizer_switch="firstmatch=on,materialization=off"; +select @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=off,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from DUAL where false +SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from `test`.`t2` `ot` where false +SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 24 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL range PRIMARY PRIMARY 4 NULL 24 100.00 Using where; Using index +2 SIMPLE it NULL eq_ref uk uk 5 test.ot.pk 1 100.00 Using where; Not exists; Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((`test`.`it`.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +EXPLAIN FORMAT=JSON SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost: # + "query_cost: # + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "384" + }, + "used_columns": [ + "pk" + ], + "query_block": { + "cost: # + "query_cost: # + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "ot", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "192" + }, + "used_columns": [ + "pk" + ], + "attached_condition": "(`test`.`ot`.`pk` < 25)" + } + }, + { + "table": { + "select_id": 2, + "table_name": "it", + "access_type": "eq_ref", + "possible_keys": [ + "uk" + ], + "key": "uk", + "used_key_parts": [ + "uk" + ], + "key_length": "5", + "ref": [ + "test.ot.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 24, + "filtered": "100.00", + "not_exists": true, + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "576" + }, + "used_columns": [ + "uk" + ], + "attached_condition": "(is_not_null_compl(it), (found_match(it), false, true), true)" + } + } + ] + } + } + } +} +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((`test`.`it`.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +pk +1 +2 +3 +4 +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +16 +17 +18 +19 +21 +22 +23 +24 +set optimizer_switch="firstmatch=off,materialization=on"; +select @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=off,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on,subquery_to_derived=off,prefer_ordering_index=on,hypergraph_optimizer=off,derived_condition_pushdown=on +EXPLAIN SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from DUAL where false +SELECT 1 as a FROM dual +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `a` from `test`.`t2` `ot` where false +SELECT 1 as a FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it); +a +EXPLAIN SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL range PRIMARY PRIMARY 4 NULL 24 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.ot.pk 1 100.00 Using where; Not exists +2 MATERIALIZED it NULL index uk uk 5 NULL 3 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((``.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +EXPLAIN FORMAT=JSON SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost: # + "query_cost: # + }, + "nested_loop": [ + { + "table": { + "table_name": "ot", + "access_type": "range", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "192" + }, + "used_columns": [ + "pk" + ], + "attached_condition": "(`test`.`ot`.`pk` < 25)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.ot.pk" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "(is_not_null_compl(), (found_match(), false, true), true)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "it", + "access_type": "index", + "possible_keys": [ + "uk" + ], + "key": "uk", + "used_key_parts": [ + "uk" + ], + "key_length": "5", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "using_index": true, + "cost: # + "read_cost: # + "eval_cost: # + "prefix_cost: # + "data_read_per_join": "72" + }, + "used_columns": [ + "uk" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` anti join (`test`.`t1` `it`) on((``.`uk` = `test`.`ot`.`pk`)) where (`test`.`ot`.`pk` < 25) +SELECT pk FROM t2 as ot +WHERE NOT EXISTS (SELECT * FROM t1 AS it WHERE it.uk=ot.pk) +AND ot.pk<25; +pk +1 +2 +3 +4 +5 +6 +7 +8 +9 +11 +12 +13 +14 +15 +16 +17 +18 +19 +21 +22 +23 +24 +DROP TABLE t1,t2; +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES(1,1),(2,2),(3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM t1 LEFT JOIN t1 t2 +ON (t1.a IN +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH,LOOSESCAN,DUPSWEEDOUT) */ a FROM +t1 t3 WHERE a > 2)); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.85" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.t1.a" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t3`.`a` > 2)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "3.85", + "data_read_per_join": "144" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2` FIRSTMATCH, LOOSESCAN, DUPSWEEDOUT) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t1` `t2` semi join (`test`.`t1` `t3`)) on(((``.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` > 2))) where true +SELECT * FROM t1 LEFT JOIN t1 t2 +ON (t1.a IN +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH,LOOSESCAN,DUPSWEEDOUT) */ a FROM +t1 t3 WHERE a > 2)); +a b a b +1 1 NULL NULL +2 2 NULL NULL +3 3 1 1 +3 3 2 2 +3 3 3 3 +ALTER TABLE t1 MODIFY a INT NOT NULL; +EXPLAIN SELECT * FROM t1 WHERE t1.a NOT IN +(SELECT a FROM t1 t2 WHERE a NOT IN (SELECT a FROM t1 t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY NULL eq_ref 5 test.t2.a 1 100.00 Using where; Not exists +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t2`.`a`)) where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`)))) is false) +EXPLAIN SELECT * FROM t1 WHERE t1.a IN +(SELECT a FROM t1 t2 WHERE a NOT IN (SELECT a FROM t1 t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY NULL eq_ref 5 test.t2.a 1 100.00 Using where; Not exists +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t2`.`a`)) where true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`a`))))) +EXPLAIN SELECT * FROM t1 JOIN t1 t2 ON t1.a>t2.a +AND NOT EXISTS(SELECT * FROM t1 t3, t1 t4 WHERE t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` anti join (`test`.`t1` `t3` join `test`.`t1` `t4`) on((``.`a` = `test`.`t1`.`a`)) where (`test`.`t1`.`a` > `test`.`t2`.`a`) +EXPLAIN SELECT * FROM t1 WHERE t1.a NOT IN (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE t1.a <> ALL (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +ALTER TABLE t1 MODIFY a INT NULL; +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 8 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where true +EXPLAIN SELECT * FROM t1 WHERE NOT EXISTS(SELECT * FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 8 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where true +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where false +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS NOT FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 8 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where true +EXPLAIN SELECT * FROM t1 WHERE EXISTS(SELECT * FROM t1 t3) IS NOT UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where true +EXPLAIN SELECT * FROM t1 WHERE t1.a IN (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where (``.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 WHERE t1.a NOT IN (SELECT t3.a FROM t1 t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false) +EXPLAIN SELECT * FROM t1 WHERE NOT EXISTS (SELECT t3.a FROM t1 t3 WHERE t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where (``.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false) +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is null) +EXPLAIN SELECT * FROM t1 WHERE ISNULL(t1.a IN (SELECT t3.a FROM t1 t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is null) +SELECT * FROM t1 WHERE ISNULL(t1.a IN (SELECT t3.a FROM t1 t3)); +a b +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is not false) +EXPLAIN SELECT * FROM t1 WHERE (t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is not null) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1` `t3`) where (``.`a` = `test`.`t1`.`a`) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,not (/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is null) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is not false) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 Using where; Not exists +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` anti join (`test`.`t1` `t3`) on((``.`a` = `test`.`t1`.`a`)) where true +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT t3.a FROM t1 t3)) IS NOT UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a`,not (/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where (outer_field_is_not_null, (((`test`.`t1`.`a`) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true) having (outer_field_is_not_null, (`test`.`t3`.`a`), true))) is not null) +EXPLAIN SELECT * FROM t1 WHERE (NOT t1.a IN (SELECT /*+ NO_SEMIJOIN() */ t3.a FROM t1 t3)) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where ((`test`.`t1`.`a`) = `test`.`t3`.`a`)) is true) +EXPLAIN SELECT * FROM t1 WHERE NOT ((t1.a IN (SELECT /*+ NO_SEMIJOIN() */ t3.a FROM t1 t3)) IS TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t3`.`a` from `test`.`t1` `t3` where ((`test`.`t1`.`a`) = `test`.`t3`.`a`)) is not true) +DROP TABLE t1; +# +# Bug#29387313 WL#4245: SIG11 AT QEP_SHARED_OWNER::LAST_INNER() AT SQL/SQL_OPT_EXEC_SHARED.H +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY idx_cc_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES (2,"a"); +CREATE TABLE t2 LIKE t1; +EXPLAIN SELECT col_varchar_key FROM t1 +WHERE NOT EXISTS +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH) */ +subquery2_t1.col_varchar_key AS subquery2_field1 +FROM t2 AS subquery2_t1 LEFT JOIN +t1 AS subquery2_t2 INNER JOIN t1 AS subquery2_t3 +ON TRUE +ON TRUE +WHERE subquery2_t2.col_varchar_key <> subquery2_t1. col_varchar_key OR +subquery2_t1.col_varchar_key >= '2' + ) AND +t1.pk IN (2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +2 SUBQUERY subquery2_t1 NULL index idx_cc_col_varchar_key idx_cc_col_varchar_key 7 NULL 1 100.00 Using index +2 SUBQUERY subquery2_t2 NULL index NULL idx_cc_col_varchar_key 7 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 SUBQUERY subquery2_t3 NULL index NULL idx_cc_col_varchar_key 7 NULL 1 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2` FIRSTMATCH) */ 'a' AS `col_varchar_key` from `test`.`t1` where true +SELECT col_varchar_key FROM t1 +WHERE NOT EXISTS +(SELECT /*+ NO_SEMIJOIN(FIRSTMATCH) */ +subquery2_t1.col_varchar_key AS subquery2_field1 +FROM t2 AS subquery2_t1 LEFT JOIN +t1 AS subquery2_t2 INNER JOIN t1 AS subquery2_t3 +ON TRUE +ON TRUE +WHERE subquery2_t2.col_varchar_key <> subquery2_t1. col_varchar_key OR +subquery2_t1.col_varchar_key >= '2' + ) AND +t1.pk IN (2); +col_varchar_key +a +DROP TABLE t1, t2; +# +# Bug#29402512 WL#4245: SIG6 AT JOIN::MAKE_OUTERJOIN_INFO | SQL_OPTIMIZER.CC +# +CREATE TABLE t1 ( +pk int NOT NULL AUTO_INCREMENT, +col_int_key int, +PRIMARY KEY (pk), +KEY idx_cc_col_int_key (col_int_key)); +INSERT INTO t1 VALUES(1,1); +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +INSERT INTO t1 (col_int_key) SELECT col_int_key*2 from t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT t1.col_int_key +FROM t1 AS t1 LEFT JOIN t1 AS t2 ON t1.pk NOT IN (SELECT 1 FROM t1 AS subq); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL idx_cc_col_int_key 5 NULL 64 100.00 Using index +1 SIMPLE t2 NULL index NULL idx_cc_col_int_key 5 NULL 64 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 4 test.t1.pk 1 100.00 Using where; Not exists +2 MATERIALIZED subq NULL index NULL idx_cc_col_int_key 5 NULL 64 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int_key` AS `col_int_key` from `test`.`t1` left join (`test`.`t1` `t2` anti join (`test`.`t1` `subq`) on((`test`.`t1`.`pk` = 1))) on(true) where true +DROP TABLE t1; +# +# Bug#29499458 WL#4245: SIG 6 AT JOIN::SETUP_SEMIJOIN_MATERIALIZED_TABLE +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int INT NOT NULL, +PRIMARY KEY (pk) +); +EXPLAIN SELECT alias1.pk +FROM t1 AS alias1 LEFT JOIN +(SELECT alias2.* +FROM t1 LEFT JOIN t1 AS alias2 ON TRUE +WHERE NOT EXISTS (SELECT pk FROM t1 AS sj1) +) AS alias3 +ON alias3.pk = alias1.col_int AND +NOT EXISTS (SELECT * FROM t1 AS sj2 WHERE (SELECT 1) IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 PRIMARY alias2 NULL eq_ref PRIMARY PRIMARY 4 test.alias1.col_int 1 100.00 Using index +4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY sj1 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1249 Select 5 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`alias1`.`pk` AS `pk` from `test`.`t1` `alias1` left join (`test`.`t1` join `test`.`t1` `alias2`) on(((`test`.`alias2`.`pk` = `test`.`alias1`.`col_int`) and exists(/* select#4 */ select 1 from `test`.`t1` `sj2` where false) is false and exists(/* select#3 */ select `test`.`sj1`.`pk` from `test`.`t1` `sj1`) is false)) where true +SELECT alias1.pk +FROM t1 AS alias1 LEFT JOIN +(SELECT alias2.* +FROM t1 LEFT JOIN t1 AS alias2 ON TRUE +WHERE NOT EXISTS (SELECT pk FROM t1 AS sj1) +) AS alias3 +ON alias3.pk = alias1.col_int AND +NOT EXISTS (SELECT * FROM t1 AS sj2 WHERE (SELECT 1) IS NULL); +pk +DROP TABLE t1; +# +# Bug#29503228 WL#4245: SIG 6 AT JOIN::SET_SEMIJOIN_EMBEDDING +# +CREATE TABLE t1 ( +col_int INT NOT NULL, +col_int2 INT NOT NULL +); +SELECT * FROM +t1 AS alias1 LEFT JOIN t1 AS alias2 +ON NOT EXISTS +( SELECT * +FROM +( SELECT * FROM t1 +WHERE col_int NOT IN +( SELECT sq1_alias1 . col_int2 +FROM t1 AS sq1_alias1 ) +) AS alias3 +); +col_int col_int2 col_int col_int2 +DROP TABLE t1; +# +# Test index_subquery and subquery-materialization with +# surrounding NOT or IS TRUE/FALSE. +# +CREATE TABLE t1 ( +col_int INT, +col_int2 INT, +key(col_int) +); +INSERT INTO t1 VALUES(1,1),(2,2),(null,null); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET OPTIMIZER_SWITCH="semijoin=off"; +SET OPTIMIZER_SWITCH="materialization=off"; +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int where (((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`)))) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int where (((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`))) is true) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 2 100.00 Using where; Using index; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int checking NULL where (outer_field_is_not_null, ((((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`) or (`test`.`t2`.`col_int` is null)), true) having (outer_field_is_not_null, (`test`.`t2`.`col_int`), true))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 2 100.00 Using where; Using index; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int checking NULL where (outer_field_is_not_null, ((((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`) or (`test`.`t2`.`col_int` is null)), true) having (outer_field_is_not_null, (`test`.`t2`.`col_int`), true))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL index_subquery col_int col_int 5 func 2 100.00 Using where; Using index; Full scan on NULL key +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where (((`test`.`t1`.`col_int` + 1),((((`test`.`t1`.`col_int` + 1)) in t1 on col_int checking NULL where (outer_field_is_not_null, ((((`test`.`t1`.`col_int` + 1)) = `test`.`t2`.`col_int`) or (`test`.`t2`.`col_int` is null)), true) having (outer_field_is_not_null, (`test`.`t2`.`col_int`), true)))) is null) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +col_int col_int2 +2 2 +NULL NULL +SET OPTIMIZER_SWITCH="materialization=on,subquery_materialization_cost_based=off"; +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`))))) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2); +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`)))) is true) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS TRUE; +col_int col_int2 +1 1 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true having true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`)))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS FALSE; +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where ((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true having true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`)))) is false) +SELECT * FROM t1 WHERE +t1.col_int+1 NOT IN (SELECT col_int FROM t1 t2); +col_int col_int2 +EXPLAIN SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2 NULL index col_int col_int 5 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_int` AS `col_int`,`test`.`t1`.`col_int2` AS `col_int2` from `test`.`t1` where (((`test`.`t1`.`col_int` + 1),(`test`.`t1`.`col_int` + 1) in ( (/* select#2 */ select `test`.`t2`.`col_int` from `test`.`t1` `t2` where true having true ), ((`test`.`t1`.`col_int` + 1) in on where (((`test`.`t1`.`col_int` + 1) = ``.`col_int`))))) is null) +SELECT * FROM t1 WHERE +t1.col_int+1 IN (SELECT col_int FROM t1 t2) IS UNKNOWN; +col_int col_int2 +2 2 +NULL NULL +SET OPTIMIZER_SWITCH=DEFAULT; +DROP TABLE t1; +# +# Bug#29525549 WL#4245: SIG 6 AT JOIN::CREATE_ITERATORS() | SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int INT NOT NULL, +PRIMARY KEY (pk) +) ; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET OPTIMIZER_SWITCH="block_nested_loop=off,firstmatch=off"; +EXPLAIN SELECT * FROM t1 LEFT JOIN t1 AS t2 +ON 1 AND t1.col_int > ( SELECT @var FROM t1 as t3 ) AND +NOT EXISTS ( SELECT * FROM t1 as t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +3 SUBQUERY t4 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 UNCACHEABLE SUBQUERY t3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int` AS `col_int`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_int` AS `col_int` from `test`.`t1` left join `test`.`t1` `t2` on(((`test`.`t1`.`col_int` > (/* select#2 */ select (@`var`) from `test`.`t1` `t3`)) and exists(/* select#3 */ select 1 from `test`.`t1` `t4`) is false)) where true +SELECT * FROM t1 LEFT JOIN t1 AS t2 +ON 1 AND t1.col_int > ( SELECT @var FROM t1 as t3 ) AND +NOT EXISTS ( SELECT * FROM t1 as t4); +pk col_int pk col_int +SELECT * FROM t1 LEFT JOIN (t1 AS t2 LEFT JOIN t1 AS sq ON 1=1) +ON 1 AND t1.col_int > ( SELECT @var FROM t1 AS t4 ) +WHERE sq.pk IS NULL; +pk col_int pk col_int pk col_int +SET OPTIMIZER_SWITCH=DEFAULT; +DROP TABLE t1; +# +# Bug#29533644 WL#4245: RESULT DIFFS WITH NOT IN (SUBQUERY) +# +CREATE TABLE t1(id INT); +INSERT INTO t1 VALUES(1),(2),(3),(4),(5); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT ID FROM t1 WHERE id IN ( SELECT 1 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `ID` from `test`.`t1` where (`test`.`t1`.`id` = 1) +SELECT ID FROM t1 WHERE id IN ( SELECT 1 ); +ID +1 +EXPLAIN SELECT ID FROM t1 WHERE id NOT IN ( SELECT 1 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 80.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 80.00 Using where +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `ID` from `test`.`t1` where (not((`test`.`t1`.`id` = 1))) +SELECT ID FROM t1 WHERE id NOT IN ( SELECT 1 ); +ID +2 +3 +4 +5 +EXPLAIN SELECT id, id IN (SELECT NULL) IS TRUE AS test FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1249 Select 2 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`id` = NULL) is true) AS `test` from `test`.`t1` +SELECT id, id IN (SELECT NULL) IS TRUE AS test FROM t1; +id test +1 0 +2 0 +3 0 +4 0 +5 0 +DROP TABLE t1; +# +# Bug#29540222 WL#4245 RESULT DIFFS WITH DUAL +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int int(11) NOT NULL, +col_int_key int(11) NOT NULL, +col_date date NOT NULL, +col_date_key date NOT NULL, +col_time time NOT NULL, +col_time_key time NOT NULL, +col_datetime datetime NOT NULL, +col_datetime_key datetime NOT NULL, +col_varchar varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY idx_C_col_int_key (col_int_key), +KEY idx_C_col_date_key (col_date_key), +KEY idx_C_col_time_key (col_time_key), +KEY idx_C_col_datetime_key (col_datetime_key), +KEY idx_C_col_varchar_key (col_varchar_key) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,1065483706,383929458,'1979-10-05','1976-08-21','22:00:27','23:05:58','1974-07-25 16:05:18','2015-12-02 10:01:50','k','9'),(2,-171723561,486531981,'1980-09-14','2027-01-15','00:57:31','00:12:08','2036-10-28 14:25:40','2010-09-04 08:25:26','M','Z'); +EXPLAIN SELECT alias1.col_int AS field1 , alias2.col_varchar_key AS field2 , +alias1.col_datetime_key AS field3 +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 +ON NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE ( SELECT 1 FROM DUAL ) IS NULL ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL index NULL idx_C_col_varchar_key 6 NULL 2 100.00 Using where; Using index; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `field1`,`test`.`alias2`.`col_varchar_key` AS `field2`,`test`.`alias1`.`col_datetime_key` AS `field3` from `test`.`t1` `alias1` left join `test`.`t1` `alias2` on(exists(/* select#2 */ select 1 from `test`.`t1` `alias3` where false) is false) where true +SELECT alias1.col_int AS field1 , alias2.col_varchar_key AS field2 , +alias1.col_datetime_key AS field3 +FROM t1 AS alias1 LEFT JOIN t1 AS alias2 +ON NOT EXISTS ( SELECT * FROM t1 AS alias3 WHERE ( SELECT 1 FROM DUAL ) IS NULL ); +field1 field2 field3 +-171723561 9 2010-09-04 08:25:26 +-171723561 Z 2010-09-04 08:25:26 +1065483706 9 2015-12-02 10:01:50 +1065483706 Z 2015-12-02 10:01:50 +DROP TABLE t1; +# +# Bug#29759277 ASSERTION FAILED: !"NO DERIVED TABLE FOUND!" +# +CREATE TABLE t1 (c1 INT, c2 INT); +EXPLAIN FORMAT=JSON +SELECT c1 FROM t1 +WHERE NOT EXISTS (SELECT /*+ NO_MERGE() */ c2 +FROM (SELECT c1 FROM t1) AS dt +WHERE FALSE); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "c1" + ], + "query_block": { + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "c1", + "c2" + ] + } + } + } + } +} +Warnings: +Note 1276 Field or reference 'test.t1.c2' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ NO_MERGE(@`select#2`) */ `test`.`t1`.`c1` AS `c1` from `test`.`t1` where true +DROP TABLE t1; +# +# Bug#30691682 MIN/MAX ISSUE WITH NOT EXISTS SUBQUERY +# +CREATE TABLE t1(a INT NOT NULL, index (a)); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(2),(3); +explain SELECT MAX(t1.a) FROM t1 WHERE a NOT IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 4 NULL 2 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Not exists; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a`) AS `MAX(t1.a)` from `test`.`t1` anti join (`test`.`t2`) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where true +SELECT MAX(t1.a) FROM t1 WHERE a NOT IN (SELECT a FROM t2); +MAX(t1.a) +1 +DROP TABLE t1, t2; +# +# Bug#31376809 PERFORMANCE REGRESSION FROM 5.7->8.0, DUE TO ANTIJOIN OF NOT EXISTS SUBQUERY +# +create table t(a int, b int); +insert into t values(1,1),(2,2),(3,3),(4,4),(5,5); +explain format=tree select a from t where (not exists (select b from t)); +EXPLAIN +-> Zero rows (Impossible WHERE) (cost=0.00..0.00 rows=0) + +select a from t where (not exists (select b from t)); +a +explain format=tree select a from t where 1 not in (select 1 from t); +EXPLAIN +-> Zero rows (Impossible WHERE) (cost=0.00..0.00 rows=0) + +select a from t where 1 not in (select 1 from t); +a +drop table t; +# +# Bug#31425664 RECENT REGRESSION: CRASH IN ITEM::SAVE_IN_FIELD +# +CREATE TABLE t (a TIME); +CREATE TABLE s (b INT); +INSERT INTO t VALUES('11:11:11.1111'),('22:22:22.2222'); +INSERT INTO t VALUES('11:11:11.1111'),('22:22:22.2222'); +INSERT INTO t VALUES('11:11:11.1111'),('22:22:22.2222'); +INSERT INTO s VALUES(1),(2),(3),(4); +SELECT 1 FROM t WHERE NOT EXISTS +( +SELECT 1 FROM s +WHERE a=FROM_UNIXTIME(1536999178) +); +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t,s; diff --git a/mysql-test/r/subquery_bugs.result-pq b/mysql-test/r/subquery_bugs.result-pq new file mode 100644 index 000000000..7bb01bb09 --- /dev/null +++ b/mysql-test/r/subquery_bugs.result-pq @@ -0,0 +1,1887 @@ +# Bug#26436185 Assertion 'buf_is_inside_another(data_in_mysql_buf, ...) +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_int int DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES (10,7,5,'l'), (12,7,4,'o'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar varchar(1) DEFAULT NULL, +col_time time DEFAULT NULL, +pk int NOT NULL, +col_date date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime datetime DEFAULT NULL, +col_int int DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key), +KEY col_datetime_key (col_datetime_key), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key), +KEY col_time_key (col_time_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2(col_int_key,col_varchar_key,col_varchar,pk,col_int) VALUES +(8,'a','w',1,5), +(9,'y','f',7,0), +(9,'z','i',11,9), +(9,'r','s',12,3), +(7,'n','i',13,6), +(9,'j','v',17,9), +(240,'u','k',20,6); +CREATE TABLE t3 ( +col_int int DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +pk int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (8,4,1); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT table2.col_int_key AS field1 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 RIGHT OUTER JOIN t2 AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar +) AS table1 +LEFT JOIN t1 AS table2 +RIGHT JOIN t2 AS table3 +ON table3.pk = table2.col_int_key +ON table3.col_int_key = table2.col_int +WHERE table3.col_int_key >= ALL +(SELECT sq2_t1.col_int AS sq2_field1 +FROM t2 AS sq2_t1 STRAIGHT_JOIN t3 AS sq2_t2 +ON sq2_t2.col_int = sq2_t1.pk AND +sq2_t1.col_varchar IN +(SELECT sq21_t1.col_varchar AS sq21_field1 +FROM t2 AS sq21_t1 STRAIGHT_JOIN t1 AS sq21_t2 +ON sq21_t2.col_int_key = sq21_t1.pk +WHERE sq21_t1.pk = 7 +) +WHERE sq2_t2.col_int_key >= table2.col_int AND +sq2_t1.col_int_key <= table2.col_int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY sq1_t2 NULL index NULL col_varchar_key 7 NULL 7 100.00 Using index +1 PRIMARY sq1_t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 PRIMARY table2 NULL ALL col_int_key NULL NULL NULL 2 100.00 NULL +1 PRIMARY table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_key 1 100.00 Using where +3 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +3 DEPENDENT SUBQUERY sq2_t1 NULL ALL PRIMARY,col_int_key NULL NULL NULL 7 14.29 Range checked for each record (index map: 0x9) +3 DEPENDENT SUBQUERY sq2_t2 NULL ALL col_int_key NULL NULL NULL 1 100.00 Range checked for each record (index map: 0x2) +4 MATERIALIZED sq21_t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +4 MATERIALIZED sq21_t2 NULL ref col_int_key col_int_key 5 const 2 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.table2.col_int' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.table2.col_int_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`table2`.`col_int_key` AS `field1` from `test`.`t2` `sq1_t2` left join `test`.`t1` `sq1_t1` on((`test`.`sq1_t1`.`col_varchar` = `test`.`sq1_t2`.`col_varchar_key`)) left join (`test`.`t2` `table3` join `test`.`t1` `table2`) on(((`test`.`table3`.`pk` = `test`.`table2`.`col_int_key`) and (`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int`))) where ((`test`.`table3`.`col_int_key`,(/* select#3 */ select `test`.`sq2_t1`.`col_int` AS `sq2_field1` from `test`.`t2` `sq2_t1` straight_join `test`.`t3` `sq2_t2` semi join (`test`.`t2` `sq21_t1` straight_join `test`.`t1` `sq21_t2`) where ((`test`.`sq2_t2`.`col_int` = `test`.`sq2_t1`.`pk`) and (`test`.`sq2_t1`.`col_varchar` = ``.`sq21_field1`) and (`test`.`sq21_t1`.`pk` = 7) and (`test`.`sq21_t2`.`col_int_key` = 7) and (`test`.`sq2_t2`.`col_int_key` >= `test`.`table2`.`col_int`) and (`test`.`sq2_t1`.`col_int_key` <= `test`.`table2`.`col_int_key`) and (outer_field_is_not_null, (((`test`.`table3`.`col_int_key`) < `test`.`sq2_t1`.`col_int`) or (`test`.`sq2_t1`.`col_int` is null)), true)) having (outer_field_is_not_null, (`test`.`sq2_t1`.`col_int`), true)))) +SELECT table2.col_int_key AS field1 +FROM (SELECT sq1_t1.* +FROM t1 AS sq1_t1 RIGHT OUTER JOIN t2 AS sq1_t2 +ON sq1_t2.col_varchar_key = sq1_t1.col_varchar +) AS table1 +LEFT JOIN t1 AS table2 +RIGHT JOIN t2 AS table3 +ON table3.pk = table2.col_int_key +ON table3.col_int_key = table2.col_int +WHERE table3.col_int_key >= ALL +(SELECT sq2_t1.col_int AS sq2_field1 +FROM t2 AS sq2_t1 STRAIGHT_JOIN t3 AS sq2_t2 +ON sq2_t2.col_int = sq2_t1.pk AND +sq2_t1.col_varchar IN +(SELECT sq21_t1.col_varchar AS sq21_field1 +FROM t2 AS sq21_t1 STRAIGHT_JOIN t1 AS sq21_t2 +ON sq21_t2.col_int_key = sq21_t1.pk +WHERE sq21_t1.pk = 7 +) +WHERE sq2_t2.col_int_key >= table2.col_int AND +sq2_t1.col_int_key <= table2.col_int_key +); +field1 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +DROP TABLE t1, t2, t3; +# +# Bug#24713879 ASSERTION `MAYBE_NULL' FAILED. HANDLE_FATAL_SIGNAL IN TEM_FUNC_CONCAT::VAL_STR +# +CREATE TABLE t1(k VARCHAR(10) PRIMARY KEY); +CREATE TABLE t2(k VARCHAR(10) PRIMARY KEY); +SET SQL_MODE=''; +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'`,sum(`test`.`t1`.`k`) AS `SUM(k)` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' SUM(k) +NULL NULL +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`t1`.`k`) AS `SUM(k)`,`test`.`t1`.`k` AS `k` from `test`.`t1` having ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') +SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +SUM(k) k +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where ((`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X')) and (0 <> sum(`test`.`t1`.`k`)))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX'` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +NULL +SET SQL_MODE=ONLY_FULL_GROUP_BY; +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +SET SQL_MODE=STRICT_TRANS_TABLES; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'`,sum(`test`.`t1`.`k`) AS `SUM(k)` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' SUM(k) +NULL NULL +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`t1`.`k`) AS `SUM(k)`,`test`.`t1`.`k` AS `k` from `test`.`t1` having ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X'))) = 'XXX') +SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +SUM(k) k +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 DEPENDENT SUBQUERY t2 NULL eq_ref PRIMARY PRIMARY 42 func 1 100.00 Using where; Using index +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where ((`test`.`t2`.`k` = concat(`test`.`t1`.`k`,'X')) and (0 <> sum(`test`.`t1`.`k`)))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX'` from `test`.`t1` +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +NULL +SET SQL_MODE=DEFAULT; +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1276 Field or reference 'test.t1.k' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select ((/* select#2 */ select 'X' from `test`.`t2` where (`test`.`t2`.`k` = concat(NULL,'X'))) = 'XXX') AS `(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'` from `test`.`t1` where multiple equal('X', NULL) +SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +FROM t1 +WHERE k ='X'; +(SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX' +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX', +SUM(k) +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT SUM(k), k +FROM t1 +HAVING (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X')) = 'XXX'; +ERROR 42000: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +EXPLAIN SELECT (SELECT 'X' FROM t2 +WHERE t2.k = CONCAT(t1.k, 'X') +AND SUM(t1.k)) = 'XXX' +FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.k'; this is incompatible with sql_mode=only_full_group_by +DROP TABLE t1,t2; +# +# Bug#27665085 ASSERTION FAILED: JOIN == 0. +# +SET sql_mode=''; +CREATE TABLE a(d INT,e BIGINT, KEY(e)); +INSERT a VALUES (0,0); +CREATE TABLE b(f TIME); +INSERT b VALUES (null),(null),(null); +CREATE TABLE c(g DATETIME(6) NOT NULL); +INSERT c(g) VALUES (now()+interval 1 day); +INSERT c(g) VALUES (now()-interval 1 day); +SELECT 1 FROM a WHERE (SELECT f FROM b WHERE (SELECT 1 FROM c)) <=> e GROUP BY d; +ERROR 21000: Subquery returns more than 1 row +SET sql_mode=default; +DROP TABLES a, b, c; +# +# Bug#27182010 SUBQUERY INCORRECTLY SHOWS DUPLICATE VALUES ON SUBQUERIES +# +CREATE TABLE p (Id INT,PRIMARY KEY (Id)); +INSERT INTO p VALUES (1); +# Test UNIQUE KEY with NULL values +CREATE TABLE s (Id INT, u INT, UNIQUE KEY o(Id, u) ); +INSERT INTO s VALUES (1, NULL),(1, NULL); +ANALYZE TABLE s; +Table Op Msg_type Msg_text +test.s analyze status OK +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NULL)ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL ref o o 10 const,const 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s`) where ((`test`.`s`.`Id` = 1) and (`test`.`s`.`u` is null)) order by '1' desc +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL range o o 10 NULL 1 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s`) where ((`test`.`s`.`Id` = 1) and (`test`.`s`.`u` is not null)) order by '1' desc +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NULL)ORDER BY Id DESC; +Id +1 +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +Id +# UNIQUE KEY without NULL values +CREATE TABLE s1 (Id INT, u INT, UNIQUE KEY o(Id, u) ); +INSERT INTO s1 VALUES (1, 2),(1, 3); +ANALYZE TABLE s1; +Table Op Msg_type Msg_text +test.s1 analyze status OK +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s1 NULL index o o 10 NULL 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s1`) where ((`test`.`s1`.`Id` = 1) and (`test`.`s1`.`u` is not null)) order by '1' desc +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u != 1) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s1 NULL index o o 10 NULL 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s1`) where ((`test`.`s1`.`Id` = 1) and (`test`.`s1`.`u` <> 1)) order by '1' desc +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u IS NOT NULL) ORDER BY Id DESC; +Id +1 +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s1.Id FROM s1 WHERE Id=1 AND u != 1) ORDER BY Id DESC; +Id +1 +# NON UNIQUE KEY Scenario +CREATE TABLE s2 (Id INT, u INT, KEY o(Id, u) ); +INSERT INTO s2 VALUES (1, NULL),(1, NULL); +ANALYZE TABLE s2; +Table Op Msg_type Msg_text +test.s2 analyze status OK +#UNIQUE KEY with NON NULL FIELDS +CREATE TABLE s3 (Id INT NOT NULL, u INT NOT NULL, UNIQUE KEY o(Id, u)); +INSERT INTO s3 VALUES (1, 2),(1, 3); +ANALYZE TABLE s3; +Table Op Msg_type Msg_text +test.s3 analyze status OK +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s2 s WHERE Id=1 AND u IS NULL) ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL ref o o 10 const,const 2 100.00 Using where; Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s2` `s`) where ((`test`.`s`.`Id` = 1) and (`test`.`s`.`u` is null)) order by '1' desc +EXPLAIN SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s3 s WHERE Id=1 AND u IS NOT NULL) +ORDER BY Id DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE p NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE s NULL ref o o 4 const 2 100.00 Using index; FirstMatch(p) +Warnings: +Note 1003 /* select#1 */ select '1' AS `Id` from `test`.`p` semi join (`test`.`s3` `s`) where (`test`.`s`.`Id` = 1) order by '1' desc +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s2 s WHERE Id=1 AND u IS NULL) ORDER BY Id DESC; +Id +1 +SELECT p.Id FROM (p) WHERE p.Id IN ( +SELECT s.Id FROM s3 s WHERE Id=1 AND u IS NOT NULL) +ORDER BY Id DESC; +Id +1 +DROP TABLE p, s, s1, s2, s3; +# +# Bug#28239008: WL#9571: SIG11 IN ITEM_FIELD::RESULT_TYPE() AT SQL/ITEM.H +# +CREATE TABLE t1 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('5'); +CREATE TABLE t2 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Y'); +PREPARE prep_stmt FROM "SELECT t2.f1 FROM (t2 LEFT JOIN t1 + ON (1 = ANY (SELECT f1 FROM t1 WHERE 1 IS NULL)))" ; +EXECUTE prep_stmt ; +f1 +Y +DROP TABLE t1,t2; +CREATE TABLE t1 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('Z') ; +CREATE TABLE t2 (f1 varchar(1) DEFAULT NULL); +INSERT INTO t2 VALUES ('Z') ; +PREPARE prep_stmt FROM " +SELECT t2.f1 FROM t2 LEFT OUTER JOIN +(SELECT * FROM t2 WHERE ('y',1) + IN (SELECT alias1.f1 , 0 FROM t1 AS alias1 LEFT JOIN t2 ON 0)) AS alias ON 0"; +EXECUTE prep_stmt ; +f1 +Z +PREPARE prep_stmt FROM " +SELECT t2.f1 FROM (t2 LEFT OUTER JOIN (SELECT * FROM t2 WHERE ('y',1) + IN (SELECT alias1.f1 , 0 FROM + (t1 INNER JOIN (t1 AS alias1 LEFT JOIN t2 ON 0) ON 0))) AS alias ON 0)"; +EXECUTE prep_stmt ; +f1 +Z +DROP TABLE t1,t2; +# +# Bug#28805105: Sig11 in calc_length_and_keyparts +# +CREATE TABLE t1 (cv VARCHAR(1) DEFAULT NULL); +INSERT INTO t1 VALUES ('h'), ('Q'), ('I'), ('q'), ('W'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT cv +FROM t1 +WHERE EXISTS (SELECT alias1.cv AS field1 +FROM t1 AS alias1 RIGHT JOIN t1 AS alias2 +ON alias1.cv = alias2.cv +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL const 8 const 1 100.00 NULL +2 MATERIALIZED alias2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 MATERIALIZED alias1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cv` AS `cv` from `test`.`t1` semi join (`test`.`t1` `alias2` left join `test`.`t1` `alias1` on((`test`.`alias1`.`cv` = `test`.`alias2`.`cv`))) where true +SELECT cv +FROM t1 +WHERE EXISTS (SELECT alias1.cv AS field1 +FROM t1 AS alias1 RIGHT JOIN t1 AS alias2 +ON alias1.cv = alias2.cv +); +cv +h +Q +I +q +W +DROP TABLE t1; +# Bug#28970261: Sig6 in decorrelate_equality() +CREATE TABLE t1 (col_varchar_key varchar(1) DEFAULT NULL); +EXPLAIN SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key > @var1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 UNCACHEABLE SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t1`) where ((`test`.`t1`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = (/* select#3 */ select `test`.`t1`.`col_varchar_key` from `test`.`t1` where (`test`.`t1`.`col_varchar_key` > ((@`var1`)))))) +SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key > @var1 +) +); +col_varchar_key +EXPLAIN SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = RAND() +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 UNCACHEABLE SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t1`) where ((`test`.`t1`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = (/* select#3 */ select `test`.`t1`.`col_varchar_key` from `test`.`t1` where (cast(`test`.`t1`.`col_varchar_key` as double) = rand())))) +SELECT * +FROM t1 +WHERE col_varchar_key IN +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = +(SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key = RAND() +) +); +col_varchar_key +DROP TABLE t1; +# +# Bug #29193761: WL#12470: SIG 11 IN MARKUNHANDLEDDUPLICATES() AT SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 ( +pk integer NOT NULL PRIMARY KEY, +f1 varchar(1), +KEY k1 (f1) +); +CREATE TABLE t2 ( pk integer NOT NULL PRIMARY KEY ); +CREATE VIEW v2 AS select * FROM t2; +INSERT INTO t1 VALUES (1, 'G'); +INSERT INTO t1 VALUES (2, 'j'); +INSERT INTO t1 VALUES (3, 'K'); +INSERT INTO t1 VALUES (4, 'v'); +INSERT INTO t1 VALUES (5, 'E'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE pk IN ( SELECT pk FROM t1 LEFT JOIN v2 USING (pk) WHERE f1 >= 'o' ); +EXPLAIN +-> Nested loop inner join (cost=3.77 rows=1) + -> Table scan on (cost=2.51..2.51 rows=1) + -> Materialize with deduplication (cost=3.42..3.42 rows=1) + -> Nested loop left join (cost=0.81 rows=1) + -> Filter: (t1.f1 >= 'o') (cost=0.46 rows=1) + -> Index range scan on t1 using k1 (cost=0.46 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.35 rows=1) + -> Single-row index lookup on t1 using PRIMARY (pk=``.pk) (cost=0.35 rows=1) + +DROP TABLE t1, t2; +DROP VIEW v2; +# +# Bug #29236241: WL#12470: SIG 6 IN TEMPTABLE::HANDLER::POSITION AT SRC/HANDLER.CC +# +CREATE TABLE t1 ( +f1 varchar(1), +KEY k1 (f1) +); +INSERT INTO t1 VALUES ('6'),('6'); +EXPLAIN FORMAT=tree SELECT 1 WHERE ( +SELECT 1 +FROM t1 LEFT JOIN t1 AS t2 ON 'f' IN ( SELECT f1 FROM t1 ) +WHERE EXISTS ( SELECT * FROM t1 LEFT JOIN t1 AS t3 ON t3.f1='a' ) +); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug #29231551: WL#12470: SIG 6 QEP_TAB->LAST_INNER() == (-2) CONNECTJOINS()|SQL/SQL_EXECUTOR.CC +# +CREATE TABLE t1 ( +pk integer PRIMARY KEY, +f1 integer, +f2 varchar(1) +); +INSERT INTO t1 VALUES (1,100,'x'),(2,200,'y'); +CREATE TABLE t2 ( +f2 varchar(1) +); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 LEFT JOIN t1 AS t3 ON t1.pk = t3.pk AND t1.f2 IN ( SELECT f2 FROM t2 ) +WHERE EXISTS ( SELECT * FROM t1 AS t4, t2 AS t5 ) AND t1.f1 = 80 AND t1.pk > t1.f1; +EXPLAIN +-> Parallel scan on + -> Nested loop left join (cost=0.91 rows=1) + -> Nested loop semijoin (cost=0.68 rows=1) + -> Filter: ((t1.f1 = 80) and (t1.pk > 80)) (cost=0.46 rows=0) + -> PQblock range scan on t1 using PRIMARY (cost=0.46 rows=1) + -> Nested loop inner join (cost=0.77 rows=2) + -> Table scan on t5 (cost=0.45 rows=1) + -> Index scan on t4 using PRIMARY (cost=1.30 rows=2) + -> Nested loop semijoin (cost=0.80 rows=1) + -> Single-row index lookup on t3 using PRIMARY (pk=t1.pk) (cost=0.45 rows=1) + -> Filter: (t2.f2 = t1.f2) (cost=0.70 rows=1) + -> Table scan on t2 (cost=0.70 rows=1) + +DROP TABLE t1, t2; +# +# Bug#29356132:OPTIMIZED-AWAY SUBQUERY IN PREPARED STATEMENT CAUSES ASSERT FAILURE IN EXECUTION +# +CREATE TABLE t1 (f1 varchar(1)); +INSERT INTO t1 VALUES ('5'); +CREATE TABLE t2 (f1 varchar(1)); +INSERT INTO t2 VALUES ('Y'); +PREPARE prep_stmt FROM "SELECT t2.f1 FROM (t2 LEFT JOIN t1 + ON 1 IN (SELECT f1 FROM t1 WHERE FALSE))" ; +EXECUTE prep_stmt ; +f1 +Y +DROP TABLE t1,t2; +# Bug#28955216: Assertion 'keyparts > 0' failed +set optimizer_switch='derived_merge=off'; +CREATE TABLE t1 ( +pk INTEGER, +col_int_key INTEGER, +col_datetime_gckey DATETIME, +col_time_gckey TIME, +col_varchar_key VARCHAR(15) +); +CREATE TABLE t2 ( +pk INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(15) +); +EXPLAIN SELECT alias1.col_time_gckey AS field1, +alias1.col_datetime_gckey AS field2 +FROM t1 AS alias1, +(SELECT DISTINCT sq1_alias2.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +) AS alias2, +(SELECT sq2_alias1.* +FROM t1 AS sq2_alias1 RIGHT OUTER JOIN +t1 AS sq2_alias2 INNER JOIN t2 AS sq2_alias3 +ON sq2_alias3.col_int_key = sq2_alias2.col_int_key +ON sq2_alias3.col_varchar_key = sq2_alias2.col_varchar_key +) AS alias3 +WHERE alias2.col_int_key = SOME +(WITH qn AS +(SELECT sq3_alias1.pk AS sq3_field1 +FROM t1 AS sq3_alias1 +WHERE sq3_alias1.col_int_key = alias3.pk +) +SELECT /*+ MERGE(qn) */ * FROM qn +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 5 .sq3_field1 2 100.00 NULL +1 PRIMARY NULL ref 5 .col_int_key 2 100.00 NULL +4 MATERIALIZED sq3_alias1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED sq2_alias2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED sq2_alias3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +3 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DERIVED sq1_alias1 NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary +2 DERIVED sq1_alias2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'alias3.pk' of SELECT #5 was resolved in SELECT #1 +Note 1003 /* select#1 */ select /*+ MERGE(`qn`@`select#4`) */ `test`.`alias1`.`col_time_gckey` AS `field1`,`test`.`alias1`.`col_datetime_gckey` AS `field2` from `test`.`t1` `alias1` join (/* select#2 */ select distinct `test`.`sq1_alias2`.`pk` AS `pk`,`test`.`sq1_alias2`.`col_int_key` AS `col_int_key`,`test`.`sq1_alias2`.`col_datetime_gckey` AS `col_datetime_gckey`,`test`.`sq1_alias2`.`col_time_gckey` AS `col_time_gckey`,`test`.`sq1_alias2`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` `sq1_alias1` join `test`.`t1` `sq1_alias2`) `alias2` join (/* select#3 */ select `test`.`sq2_alias1`.`pk` AS `pk`,`test`.`sq2_alias1`.`col_int_key` AS `col_int_key`,`test`.`sq2_alias1`.`col_datetime_gckey` AS `col_datetime_gckey`,`test`.`sq2_alias1`.`col_time_gckey` AS `col_time_gckey`,`test`.`sq2_alias1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` `sq2_alias2` join `test`.`t2` `sq2_alias3` left join `test`.`t1` `sq2_alias1` on((`test`.`sq2_alias3`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)) where (`test`.`sq2_alias3`.`col_int_key` = `test`.`sq2_alias2`.`col_int_key`)) `alias3` semi join (`test`.`t1` `sq3_alias1`) where ((`alias3`.`pk` = ``.`col_int_key`) and (`alias2`.`col_int_key` = ``.`sq3_field1`)) +SELECT alias1.col_time_gckey AS field1, +alias1.col_datetime_gckey AS field2 +FROM t1 AS alias1, +(SELECT DISTINCT sq1_alias2.* +FROM t1 AS sq1_alias1, t1 AS sq1_alias2 +) AS alias2, +(SELECT sq2_alias1.* +FROM t1 AS sq2_alias1 RIGHT OUTER JOIN +t1 AS sq2_alias2 INNER JOIN t2 AS sq2_alias3 +ON sq2_alias3.col_int_key = sq2_alias2.col_int_key +ON sq2_alias3.col_varchar_key = sq2_alias2.col_varchar_key +) AS alias3 +WHERE alias2.col_int_key = SOME +(WITH qn AS +(SELECT sq3_alias1.pk AS sq3_field1 +FROM t1 AS sq3_alias1 +WHERE sq3_alias1.col_int_key = alias3.pk +) +SELECT /*+ MERGE(qn) */ * FROM qn +); +field1 field2 +DROP TABLE t1, t2; +set optimizer_switch=default; +# +# Bug #29493026: INCORRECT RESULT FROM QUERY CONTAINING AN IN-SUBQUERY +# +CREATE TABLE t1 ( +pk INTEGER +); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY +); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 ( +col_int_key INTEGER, +pk INTEGER +); +INSERT INTO t3 VALUES (31,4),(2,5),(17,3),(5,2),(17,1); +CREATE TABLE t4 ( +col_int_key INTEGER, +col_int_unique INTEGER, +UNIQUE KEY ix2 (col_int_key,col_int_unique) +); +INSERT INTO t4 VALUES (6,2),(34,3); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +set optimizer_switch='firstmatch=off'; +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE pk IN ( +SELECT t2.pk FROM +t4 +RIGHT JOIN t3 ON t4.col_int_key = t3.pk +RIGHT JOIN t2 ON t3.col_int_key <> t2.pk +); +EXPLAIN +-> Nested loop inner join (cost=0.95 rows=5) + -> Filter: (t1.pk is not null) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Single-row index lookup on using (pk=t1.pk) + -> Materialize with deduplication (cost=1.60..1.60 rows=5) + -> Nested loop left join (cost=1.10 rows=5) + -> Index scan on t2 using PRIMARY (cost=0.35 rows=1) + -> Nested loop left join (cost=2.50 rows=5) + -> Filter: (t3.col_int_key <> t2.pk) (cost=0.75 rows=5) + -> Table scan on t3 (cost=0.75 rows=5) + -> Index lookup on t4 using ix2 (col_int_key=t3.pk) (cost=0.27 rows=1) + +SELECT * FROM t1 WHERE pk IN ( +SELECT t2.pk FROM +t4 +RIGHT JOIN t3 ON t4.col_int_key = t3.pk +RIGHT JOIN t2 ON t3.col_int_key <> t2.pk +); +pk +1 +DROP TABLE t1, t2, t3, t4; +set optimizer_switch=default; +# +# Bug #29693294: ASSERTION FAILURE M_INDEX_CURSOR.IS_POSITIONED() | SRC/HANDLER.CC +# +CREATE TABLE t1 ( pk integer, f1 varchar(1) ); +INSERT INTO t1 VALUES (1,'D'), (20,'G'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=TREE SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS d0 LEFT JOIN t1 ON d0.pk IN ( SELECT 1 FROM t1 ) ORDER BY d0.f1; +EXPLAIN +-> Sort: d0.f1 + -> Stream results (cost=6.95 rows=8) + -> Nested loop left join (cost=6.95 rows=8) + -> Table scan on d0 (cost=1.26..2.52 rows=2) + -> Materialize (cost=4.64..5.90 rows=2) + -> Table scan on (cost=1.26..2.52 rows=2) + -> Temporary table with deduplication (cost=1.91..3.17 rows=2) + -> Table scan on t1 (cost=0.45 rows=2) + -> Nested loop semijoin (cost=0.88 rows=4) + -> Filter: (d0.pk = 1) (cost=0.23 rows=2) + -> Table scan on t1 (cost=0.23 rows=2) + -> Table scan on t1 (cost=0.23 rows=2) + +SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS d0 LEFT JOIN t1 ON d0.pk IN ( SELECT 1 FROM t1 ) ORDER BY d0.f1; +pk f1 pk f1 +1 D 1 D +1 D 20 G +20 G NULL NULL +DROP TABLE t1; +# +# Bug#29664504 REGRESSION: CRASHING FROM ITEM_FUNC_AS_WKT::VAL_STR_ASCII() +# +CREATE TABLE t1(a TINYBLOB); +INSERT INTO t1 VALUES('aaa'),('bbb'),(''),('ccc'); +SELECT DISTINCT * FROM t1 +ORDER BY UUID_TO_BIN( +ST_ISEMPTY( +ST_POINTFROMTEXT( +ST_ASWKT( +NOT EXISTS( +SELECT 1 FROM t1 +WHERE IS_UUID(CAST(SHA(a>>0xA7FE1B22)AS JSON)) WINDOW w1 AS() +),'AXIS-ORDER=SRID-DEFINED' + ),1,'AXIS-ORDER=LONG-LAT' + ) +) +); +ERROR 22032: Invalid JSON text in argument 1 to function cast_as_json: "The document root must not be followed by other values." at position 4. +DROP TABLE t1; +# +# Bug#29669840 REGRESSION: CRASH IN DECIMAL_ADD() +# +CREATE TABLE t1(a DATETIME(2)); +INSERT INTO t1 VALUES(NOW(2)),(NOW(2)); +SELECT STD(IS_FREE_LOCK(0x2ADA5C38)),1 FROM t1 WHERE a+(EXISTS(SELECT 1)); +ERROR 42000: Incorrect user-level lock name '*\xDA\8'. +DROP TABLE t1; +# +# Bug#29668446 REGRESSION: CRASH IN DO_DIV_MOD() +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(2),(3); +SELECT 1 FROM t1 WHERE +(EXISTS(SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WINDOW w1 AS())))/1; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# Bug#29525304 Sig 6 at Item_in_subselect::val_int() +CREATE TABLE t1 (vc varchar(1) NOT NULL); +CREATE VIEW v1 AS SELECT * FROM t1 WHERE 5 IN (SELECT 1) IS UNKNOWN; +DROP VIEW v1; +DROP TABLE t1; +# +# Bug #29889223: SIG 6 AT TEMPTABLE::HANDLER::UPDATE_ROW | SRC/HANDLER.CC +# +set optimizer_switch='block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t1 ( +field1 integer +); +INSERT INTO t1 VALUES (13); +CREATE TABLE t2 ( +field2 integer +); +INSERT INTO t2 VALUES (18); +CREATE TABLE t3 ( +field3 integer +); +INSERT INTO t3 VALUES (1); +UPDATE t3 SET field3 = 9 WHERE field3 IN ( +SELECT 1 +FROM ( SELECT * FROM t2 ) AS alias1 +WHERE EXISTS ( SELECT * FROM t1 WHERE field1 <> alias1.field2 ) +); +DROP TABLE t1, t2, t3; +set optimizer_switch=default; +# +# Bug #29836364: WL#13000: SIG 11 AT COST_SKIP_SCAN() | SQL/OPT_RANGE.CC +# +CREATE TABLE t1 ( +f1 integer NOT NULL PRIMARY KEY, +f2 varchar(1), +KEY f2_idx (f2) +); +INSERT INTO t1 VALUES (20,'2'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain format=tree SELECT ( +SELECT t2.f2 FROM t1 JOIN ( +t1 AS t2 LEFT JOIN t1 AS t3 USING (f2) +) ON t3.f2 = t2.f2 +WHERE t2.f1 > table1.f2 +) FROM t1 AS table1; +EXPLAIN +-> Index scan on table1 using f2_idx (cost=0.35 rows=1) +-> Select #2 (subquery in projection; dependent) + -> Nested loop inner join (cost=1.05 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Index scan on t1 using f2_idx (cost=0.35 rows=1) + -> Filter: (cast(t2.f1 as double) > cast(table1.f2 as double)) (cost=0.35 rows=1) + -> Index range scan on t2 (re-planned for each iteration) (cost=0.35 rows=1) + -> Index lookup on t3 using f2_idx (f2=t2.f2) (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table1.f2' of SELECT #2 was resolved in SELECT #1 +SELECT ( +SELECT t2.f2 FROM t1 JOIN ( +t1 AS t2 LEFT JOIN t1 AS t3 USING (f2) +) ON t3.f2 = t2.f2 +WHERE t2.f1 > table1.f2 +) FROM t1 AS table1; +( +SELECT t2.f2 FROM t1 JOIN ( +t1 AS t2 LEFT JOIN t1 AS t3 USING (f2) +) ON t3.f2 = t2.f2 +WHERE t2.f1 > table1.f2 +) +2 +DROP TABLE t1; +# Bug#28941154: Executing query does not return a result the first time +CREATE TABLE t1 ( +pk int NOT NULL, +col_int int, +col_time_key time, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY idx_CC_col_time_key (col_time_key), +KEY idx_CC_col_varchar_key (col_varchar_key) +); +INSERT INTO t1 VALUES +(1,1244696008,'15:54:41','u'), +(2,893471119,'16:03:34','e'), +(3,462275345,'06:57:11','g'), +(4,2067212400,'06:56:19','E'), +(5,-270339471,'03:38:07','d'), +(6,-734590502,'03:18:29','Q'), +(7,-1230000720,'15:56:21','C'), +(8,-1086526061,'19:08:49','B'), +(9,-1620913518,'22:44:04','3'), +(10,1210237478,'11:18:51','i'), +(11,-886894023,'20:28:00','A'), +(12,-1490912666,'17:51:14','H'), +(13,149282252,'16:51:14','Z'), +(14,1451237940,'09:13:29','L'), +(15,1933327447,'11:14:05','2'), +(16,-693463421,'05:29:04','V'), +(17,333204980,'16:24:13','O'), +(18,279626907,'09:45:54','t'), +(19,-1372487638,'17:45:04','a'), +(20,-150563684,'15:32:40','D'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT table2.col_time_key AS field1 +FROM t1 AS table1 LEFT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_varchar_key +WHERE 1 IN (SELECT 1 FROM t1 AS subq +WHERE subq.pk <= (SELECT DISTINCT MIN(subq.col_int) +FROM t1 as alias1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subq NULL ALL NULL NULL NULL NULL 20 100.00 Using where; FirstMatch +1 PRIMARY table1 NULL index NULL idx_CC_col_varchar_key 7 NULL 20 100.00 Using index; Using join buffer (hash join) +1 PRIMARY table2 NULL ref idx_CC_col_varchar_key idx_CC_col_varchar_key 7 test.table1.col_varchar_key 1 100.00 NULL +3 DEPENDENT SUBQUERY alias1 NULL index NULL idx_CC_col_time_key 4 NULL 20 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.subq.col_int' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`table2`.`col_time_key` AS `field1` from `test`.`t1` `table1` left join `test`.`t1` `table2` on((`test`.`table2`.`col_varchar_key` = `test`.`table1`.`col_varchar_key`)) semi join (`test`.`t1` `subq`) where (`test`.`subq`.`pk` <= (/* select#3 */ select min(`test`.`subq`.`col_int`) from `test`.`t1` `alias1`)) +SELECT table2.col_time_key AS field1 +FROM t1 AS table1 LEFT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_varchar_key +WHERE 1 IN (SELECT 1 FROM t1 AS subq +WHERE subq.pk <= (SELECT DISTINCT MIN(subq.col_int) +FROM t1 as alias1 +) +); +field1 +03:18:29 +03:38:07 +03:38:07 +05:29:04 +06:56:19 +06:56:19 +06:57:11 +09:13:29 +09:45:54 +11:14:05 +11:18:51 +15:32:40 +15:32:40 +15:54:41 +15:56:21 +16:03:34 +16:03:34 +16:24:13 +16:51:14 +17:45:04 +17:45:04 +17:51:14 +19:08:49 +20:28:00 +20:28:00 +22:44:04 +DROP TABLE t1; +# Bug#28910365 Segfault at Item_cache::walk() on 2nd execution +CREATE TABLE t1 ( +pk int NOT NULL, +col_int int DEFAULT NULL +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int int DEFAULT NULL +); +INSERT INTO t2 VALUES (1, 2); +PREPARE st FROM +"DELETE outr1.* + FROM t1 AS outr1 RIGHT OUTER JOIN t2 AS outr2 + ON outr1.col_int = outr2.col_int + WHERE (0, 3) NOT IN (SELECT innr1.pk AS x, innr1.col_int AS y + FROM t2 AS innr1 + WHERE outr1.col_int = 25)"; +EXECUTE st; +EXECUTE st; +DEALLOCATE PREPARE st; +DROP TABLE t1, t2; +# +# Bug #30250091: CONDITIONS WITHIN MATERIALIZED SEMIJOINS ARE FLOATING UP +# +CREATE TABLE t1 ( +f1 INTEGER +); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE TABLE t2 ( +f2 VARCHAR(10) +); +CREATE TABLE t3 ( +f3 INTEGER UNIQUE NOT NULL +); +CREATE TABLE t4 ( +f4 INTEGER +); +INSERT INTO t4 VALUES (13), (14), (NULL); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain format=tree SELECT * FROM t1 +WHERE NOT EXISTS ( +SELECT * +FROM t4 LEFT JOIN t3 ON t4.f4 = t3.f3 +WHERE 'abc' IN ( +SELECT t2.f2 FROM t2 WHERE t3.f3 = 1 HAVING t2.f2 = 'xyz' + ) +); +EXPLAIN +-> Table scan on t1 (cost=0.55 rows=3) + +Warnings: +Note 1276 Field or reference 'test.t3.f3' of SELECT #3 was resolved in SELECT #2 +SELECT * FROM t1 +WHERE NOT EXISTS ( +SELECT * +FROM t4 LEFT JOIN t3 ON t4.f4 = t3.f3 +WHERE 'abc' IN ( +SELECT t2.f2 FROM t2 WHERE t3.f3 = 1 HAVING t2.f2 = 'xyz' + ) +); +f1 +1 +2 +3 +DROP TABLE t1, t2, t3, t4; +# +# Bug #30289052: MYSQL PRODUCES DIFFERENT RESULT FOR MATERIALIZED SUBQUERY IF INDEX EXISTS OR NOT +# +CREATE TABLE table_city (id int NOT NULL PRIMARY KEY); +CREATE TABLE table_user (id int NOT NULL PRIMARY KEY); +CREATE TABLE table_city_user (city int NOT NULL, user int NOT NULL, KEY city (city)); +INSERT INTO table_city (id) VALUES (1),(2),(3),(4),(5),(6); +INSERT INTO table_user (id) VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO table_city_user (city, user) VALUES +(1,1),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(2,1),(2,2),(2,3),(2,4), +(2,5),(3,2),(3,5),(4,5),(4,2),(4,3),(4,8),(4,1); +ANALYZE TABLE table_city, table_user, table_city_user; +Table Op Msg_type Msg_text +test.table_city analyze status OK +test.table_user analyze status OK +test.table_city_user analyze status OK +EXPLAIN FORMAT=tree SELECT id, ( +SELECT GROUP_CONCAT(id) FROM ( +SELECT table_user.id FROM table_user WHERE id IN ( +SELECT user FROM table_city_user WHERE table_city_user.city = table_city.id +) +GROUP BY table_user.id +) AS d +) AS users FROM table_city; +EXPLAIN +-> Index scan on table_city using PRIMARY (cost=0.85 rows=6) +-> Select #2 (subquery in projection; dependent) + -> Aggregate: group_concat(d.id separator ',') + -> Table scan on d (cost=0.51..2.56 rows=5) + -> Materialize (cost=5.85..7.90 rows=5) + -> Table scan on (cost=0.51..2.56 rows=5) + -> Temporary table with deduplication (cost=2.79..4.84 rows=5) + -> Nested loop inner join (cost=1.77 rows=5) + -> Filter: (table_city.id = ``.city) (cost=1.47..1.02 rows=5) + -> Table scan on (cost=0.49..2.56 rows=5) + -> Materialize with deduplication (cost=2.06..4.14 rows=5) + -> Index lookup on table_city_user using city (city=table_city.id) (cost=1.05 rows=5) + -> Single-row index lookup on table_user using PRIMARY (id=``.`user`) (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.table_city.id' of SELECT #4 was resolved in SELECT #1 +SELECT id, ( +SELECT GROUP_CONCAT(id) FROM ( +SELECT table_user.id FROM table_user WHERE id IN ( +SELECT user FROM table_city_user WHERE table_city_user.city = table_city.id +) +GROUP BY table_user.id +) AS d +) AS users FROM table_city; +id users +1 1,2,3,4,5,6,7,8 +2 1,2,3,4,5 +3 2,5 +4 1,2,3,5,8 +5 NULL +6 NULL +DROP TABLE table_city, table_user, table_city_user; +# +# Bug#30267889 ASSERTION `M_INDEX_CURSOR.IS_POSITIONED()' FAILED | TEMPTABLE::HANDLER::POSITION +# +CREATE TABLE b (c INTEGER, KEY idx_b (c)); +CREATE TABLE c (c INTEGER, KEY idx_c (c)); +CREATE TABLE d (c INTEGER, KEY idx_d (c)); +INSERT INTO b VALUES (1), (2); +INSERT INTO c VALUES (1), (2); +INSERT INTO d VALUES (1), (2); +ANALYZE TABLE b, c, d; +Table Op Msg_type Msg_text +test.b analyze status OK +test.c analyze status OK +test.d analyze status OK +EXPLAIN FORMAT=tree SELECT /*+ JOIN_ORDER(b, c_inner, c_inner_inner, d, c) */ d.c +FROM d JOIN c +WHERE d.c IN ( +SELECT +b.c +FROM +b LEFT JOIN c AS c_inner ON c_inner.c = b.c +WHERE +EXISTS ( SELECT c FROM c AS c_inner_inner ) +) ORDER BY d.c; +EXPLAIN +-> Sort: d.c + -> Stream results (cost=1.55 rows=4) + -> Inner hash join (no condition) (cost=1.55 rows=4) + -> Index scan on c using idx_c (cost=0.45 rows=2) + -> Hash + -> Nested loop inner join (cost=0.90 rows=2) + -> Filter: (``.c is not null) (cost=1.20..0.20 rows=2) + -> Table scan on (cost=0.64..2.55 rows=4) + -> Materialize with deduplication (cost=2.84..4.75 rows=4) + -> Filter: (b.c is not null) (cost=1.80 rows=4) + -> Inner hash join (no condition) (cost=1.80 rows=4) + -> Index scan on c_inner_inner using idx_c (cost=0.23 rows=2) + -> Hash + -> Nested loop left join (cost=1.15 rows=2) + -> Index scan on b using idx_b (cost=0.45 rows=2) + -> Index lookup on c_inner using idx_c (c=b.c) (cost=0.30 rows=1) + -> Index lookup on d using idx_d (c=``.c) (cost=0.60 rows=1) + +SELECT /*+ JOIN_ORDER(b, c_inner, c_inner_inner, d, c) */ d.c +FROM d JOIN c +WHERE d.c IN ( +SELECT +b.c +FROM +b LEFT JOIN c AS c_inner ON c_inner.c = b.c +WHERE +EXISTS ( SELECT c FROM c AS c_inner_inner ) +) ORDER BY d.c; +c +1 +1 +2 +2 +DROP TABLE b, c, d; +CREATE TABLE t1(pk INT PRIMARY KEY, col_int_nokey INT); +INSERT INTO t1 VALUES(26, 12); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT /*+ JOIN_ORDER(t3,t1) */ * +FROM +t1 WHERE 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`) */ `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` semi join (`test`.`t1` `t3`) where (`test`.`t3`.`col_int_nokey` = 3) +EXPLAIN FORMAT=TREE SELECT /*+ JOIN_ORDER(t3,t1) */ * +FROM +t1 WHERE 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3); +EXPLAIN +-> Inner hash join (no condition) (cost=0.70 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Hash + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (t3.col_int_nokey = 3) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + +EXPLAIN SELECT /*+ JOIN_ORDER(t1,t3,t2) */ * +FROM +t1 LEFT JOIN t1 AS t2 +ON 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3) +WHERE t1.pk=26; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ JOIN_ORDER(@`select#1` `t1`,`t3`,`t2`) */ '26' AS `pk`,'12' AS `col_int_nokey`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_int_nokey` AS `col_int_nokey` from `test`.`t1` left join (`test`.`t1` `t2` semi join (`test`.`t1` `t3`)) on(((`test`.`t3`.`col_int_nokey` = 3))) where true +EXPLAIN FORMAT=TREE SELECT /*+ JOIN_ORDER(t1,t3,t2) */ * +FROM +t1 LEFT JOIN t1 AS t2 +ON 3 IN (SELECT t3.col_int_nokey FROM t1 AS t3) +WHERE t1.pk=26; +EXPLAIN +-> Remove duplicate (t1, t2) rows using temporary table (weedout) + -> Nested loop left join (cost=0.35 rows=1) + -> Rows fetched before execution (cost=0.00..0.00 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (t3.col_int_nokey = 3) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Table scan on t2 (cost=0.35 rows=1) + +DROP TABLE t1; +# +# Bug#30273827: SIG6 IN SELECT_LEX_UNIT::EXCLUDE_LEVEL() AT +# SQL/SQL_LEX.CC +# +CREATE TABLE t1(f1 varchar(1)) ; +SELECT 1 FROM t1 AS table2 LEFT JOIN (SELECT 'c') AS table3(f1) +ON table3.f1 = table2.f1 WHERE table2.f1 +IN (SELECT 1 FROM (SELECT 1314830897) AS t1(pk) +WHERE t1.pk <= ANY(SELECT 5)) AND FALSE; +1 +DROP TABLE t1; +# Bug#30309982: Sig6 in Item_subselect::exec() +CREATE VIEW v1 AS +SELECT 1 +FROM (SELECT 1) AS table1(pk) JOIN +(SELECT 1) AS table2 +ON table1.pk = (SELECT 1) +WHERE table1.pk IN ((SELECT 1), 2); +SELECT * FROM v1; +1 +1 +DROP VIEW v1; +# +# Bug#30515233 DISTINCT INSIDE LATERAL DERIVED TABLE BREAKS IN ITERATOR EXECUTOR +# +CREATE TABLE t(a INT); +INSERT INTO t VALUES (1),(2),(3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SELECT * FROM +t AS upper JOIN LATERAL +(SELECT DISTINCT ROW_NUMBER() OVER () AS rn FROM t +WHERE (t.a > upper.a)) der ; +a rn +1 1 +1 2 +2 1 +DROP TABLE t; +# +# Verify that decorrelation works for WHERE outer_col=constant +# +CREATE TABLE t1 (a INTEGER, b INTEGER); +CREATE TABLE t2 (a INTEGER); +INSERT INTO t1 VALUES(1,10),(2,10),(3,30); +INSERT INTO t2 VALUES(2),(3),(2),(4); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off,duplicateweedout=off'; +EXPLAIN SELECT * FROM t1 WHERE (t1.a,t1.b) IN (SELECT t2.a,10 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE NULL eq_ref 9 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = 10) and (``.`a` = `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE (t1.a,t1.b) IN (SELECT t2.a,10 FROM t2); +a b +2 10 +EXPLAIN SELECT * FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 WHERE 10=t1.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE NULL eq_ref 9 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = 10) and (``.`a` = `test`.`t1`.`a`)) +SELECT * FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 WHERE 10=t1.b); +a b +2 10 +EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE 10=t1.b AND t1.a=t2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE NULL eq_ref 9 test.t1.b,test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.b' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = 10)) +SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE 10=t1.b AND t1.a=t2.a); +a b +2 10 +DROP TABLE t1,t2; +set optimizer_switch=default; +# +# Bug #30717861: WL#13377 REGRESSION, ITEM REFS ARE SUBSTITUTED TO REFER TABLES NOT YET AVAILABLE +# +CREATE TABLE t1 ( +col_int INTEGER, +pk INTEGER +); +INSERT INTO t1 VALUES (6,24),(7,0),(8,2),(0,15); +CREATE TABLE t2 ( +pk INTEGER, +UNIQUE ( pk ) +); +INSERT INTO t2 VALUES (6),(27),(41); +CREATE TABLE t3 ( +pk INTEGER +); +INSERT INTO t3 VALUES (4),(40),(46); +CREATE TABLE t4 ( +col_int INTEGER +); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN FORMAT=tree +SELECT * FROM +t1 +JOIN t2 ON t1.pk = t2.pk +JOIN t3 ON t2.pk = t3.pk +WHERE (t1.col_int + t2.pk) IN ( SELECT col_int FROM t4 ); +EXPLAIN +-> Nested loop inner join (cost=5.51 rows=3) + -> Inner hash join (t1.pk = t3.pk), ((t1.col_int + t1.pk) = ``.col_int) (cost=4.96 rows=3) + -> Table scan on t1 (cost=0.12 rows=4) + -> Hash + -> Inner hash join (no condition) (cost=3.51 rows=3) + -> Filter: (t3.pk is not null) (cost=0.55 rows=3) + -> Table scan on t3 (cost=0.55 rows=3) + -> Hash + -> Table scan on (cost=2.51..2.51 rows=1) + -> Materialize with deduplication (cost=2.96..2.96 rows=1) + -> Filter: (t4.col_int is not null) (cost=0.35 rows=1) + -> Table scan on t4 (cost=0.35 rows=1) + -> Single-row index lookup on t2 using pk (pk=t3.pk) (cost=0.12 rows=1) + +DROP TABLE t1, t2, t3, t4; +CREATE TABLE t1 ( +col1 CHAR(16), +UNIQUE KEY col1_idx (col1) +); +CREATE TABLE t2 ( +col1 INTEGER, +col2 INTEGER, +UNIQUE KEY ix1 (col1) +); +CREATE TABLE t3 ( +col1 INTEGER, +col2 INTEGER NOT NULL, +UNIQUE KEY ix1 (col1) +); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN FORMAT=tree +SELECT /*+ JOIN_ORDER(t3,t2,t1) */ * FROM t1 +WHERE t1.col1 = ANY ( +SELECT t1.col1 + t2.col2 +FROM t2 JOIN t3 ON t2.col2 = t3.col2 AND t2.col1 = t3.col1 +WHERE t2.col2 BETWEEN 2 AND 9 +); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=1.05 rows=1) + -> Filter: (cast(t1.col1 as double) = (t1.col1 + t2.col2)) (cost=1.05 rows=1) + -> Inner hash join (no condition) (cost=1.05 rows=1) + -> Index scan on t1 using col1_idx (cost=0.35 rows=1) + -> Hash + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: ((t3.col2 between 2 and 9) and (t3.col1 is not null)) (cost=0.35 rows=1) + -> Table scan on t3 (cost=0.35 rows=1) + -> Filter: (t2.col2 = t3.col2) (cost=0.35 rows=1) + -> Single-row index lookup on t2 using ix1 (col1=t3.col1) (cost=0.35 rows=1) + +Warnings: +Note 1276 Field or reference 'test.t1.col1' of SELECT #2 was resolved in SELECT #1 +DROP TABLE t1, t2, t3; +# +# Bug#30659623 ASSERT IN SQL/ITEM_SUBSELECT.CC:3571: SUBSELECT_HASH_SJ_ENGINE::EXEC() +# +CREATE TABLE t1 (col_int_key INT); +INSERT INTO t1 VALUES (NULL); +CREATE TABLE t2 ( +col_int_key INT, col_int_unique INT, +UNIQUE KEY (col_int_unique), KEY (col_int_key) +); +INSERT INTO t2 VALUES (26,14),(3,46),(45,2),(18,30),(11,22),(19,8),(41,3),(1,5), +(1,9),(38,4),(13,38),(32,12),(11,7),(2,26),(5,10),(16,45); +CREATE TABLE t3 (pk INT NOT NULL PRIMARY KEY); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format = tree SELECT * +FROM t1 +LEFT JOIN t2 ON t1.col_int_key = t2.col_int_key +JOIN t3 ON t1.col_int_key = t3.pk +WHERE t3.pk+6 NOT IN ( +SELECT /*+ subquery(materialization) */ +table1s.col_int_unique AS field4 FROM t2 AS table1s); +EXPLAIN +-> Nested loop left join (cost=1.10 rows=1) + -> Nested loop inner join (cost=0.70 rows=1) + -> Filter: (((t1.col_int_key + 6),(t1.col_int_key + 6) in (select #2) is false) and (t1.col_int_key is not null)) (cost=0.35 rows=1) + -> Table scan on t1 (cost=0.35 rows=1) + -> Select #2 (subquery in condition; run only once) + -> Filter: (((t1.col_int_key + 6) = ``.field4)) + -> Limit: 1 row(s) + -> Index lookup on using (field4=(t1.col_int_key + 6)) + -> Materialize with deduplication (cost=3.45..3.45 rows=16) + -> Index scan on table1s using col_int_unique (cost=1.85 rows=16) + -> Single-row index lookup on t3 using PRIMARY (pk=t1.col_int_key) (cost=0.35 rows=1) + -> Index lookup on t2 using col_int_key (col_int_key=t1.col_int_key) (cost=0.40 rows=1) + +SELECT * +FROM t1 +LEFT JOIN t2 ON t1.col_int_key = t2.col_int_key +JOIN t3 ON t1.col_int_key = t3.pk +WHERE t3.pk+6 NOT IN ( +SELECT /*+ subquery(materialization) */ +table1s.col_int_unique AS field4 FROM t2 AS table1s); +col_int_key col_int_key col_int_unique pk +DROP TABLE t1,t2,t3; +# Bug#30837240 Assertion 'item->is_bool_func()' failed +CREATE TABLE t1 ( +col_datetime datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_char char(1) DEFAULT NULL, +col_char_key char(1) DEFAULT NULL, +col_tinyint tinyint DEFAULT NULL, +col_tinyint_key tinyint DEFAULT NULL +); +CREATE TABLE t2 ( +col_real_key double DEFAULT NULL, +col_mediumint mediumint DEFAULT NULL +); +CREATE TABLE t3 ( +col_varchar varchar(1) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL +); +explain SELECT COUNT(table1.col_datetime) AS field1 +FROM t1 AS table1 RIGHT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_char +WHERE table1.col_char_key IN +(SELECT sq2_t1.col_real_key +FROM t2 AS sq2_t1 JOIN +t3 AS sq2_t2 JOIN t1 AS sq2_t3 +ON INSTR(sq2_t3.col_tinyint, 'K') = sq2_t2.col_varchar +ON sq2_t3.col_varchar_key = sq2_t2.col_varchar_key +WHERE sq2_t1.col_mediumint IN +(SELECT sq1_t1.col_varchar_key +FROM t1 AS sq1_t1 JOIN t1 AS sq1_t2 +ON sq1_t2.col_tinyint_key = table1.col_tinyint_key +) +) OR +RTRIM(table1.col_tinyint_key) IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY table2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY table1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY sq2_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY sq2_t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY sq2_t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 DEPENDENT SUBQUERY sq1_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY sq1_t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(sq2_t3) +Warnings: +Note 1276 Field or reference 'test.table1.col_tinyint_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select count(`test`.`table1`.`col_datetime`) AS `field1` from `test`.`t1` `table2` join `test`.`t1` `table1` where (((`test`.`table1`.`col_char_key`,(/* select#2 */ select `test`.`sq2_t1`.`col_real_key` from `test`.`t2` `sq2_t1` join `test`.`t3` `sq2_t2` join `test`.`t1` `sq2_t3` semi join (`test`.`t1` `sq1_t1` join `test`.`t1` `sq1_t2`) where ((`test`.`sq2_t3`.`col_varchar_key` = `test`.`sq2_t2`.`col_varchar_key`) and ((`test`.`table1`.`col_char_key`) = `test`.`sq2_t1`.`col_real_key`) and (cast(`test`.`sq2_t1`.`col_mediumint` as double) = cast(`test`.`sq1_t1`.`col_varchar_key` as double)) and (`test`.`table1`.`col_tinyint_key` = `test`.`sq1_t2`.`col_tinyint_key`) and (cast(locate('K',`test`.`sq2_t3`.`col_tinyint`) as double) = cast(`test`.`sq2_t2`.`col_varchar` as double))))) or (rtrim(`test`.`table1`.`col_tinyint_key`) is not null)) and (`test`.`table1`.`col_varchar_key` = `test`.`table2`.`col_char`)) +SELECT COUNT(table1.col_datetime) AS field1 +FROM t1 AS table1 RIGHT JOIN t1 AS table2 +ON table1.col_varchar_key = table2.col_char +WHERE table1.col_char_key IN +(SELECT sq2_t1.col_real_key +FROM t2 AS sq2_t1 JOIN +t3 AS sq2_t2 JOIN t1 AS sq2_t3 +ON INSTR(sq2_t3.col_tinyint, 'K') = sq2_t2.col_varchar +ON sq2_t3.col_varchar_key = sq2_t2.col_varchar_key +WHERE sq2_t1.col_mediumint IN +(SELECT sq1_t1.col_varchar_key +FROM t1 AS sq1_t1 JOIN t1 AS sq1_t2 +ON sq1_t2.col_tinyint_key = table1.col_tinyint_key +) +) OR +RTRIM(table1.col_tinyint_key) IS NOT NULL; +field1 +0 +DROP TABLE t1, t2, t3; +# +# Bug #30912972 ASSERTION KEYLEN == M_START_KEY.LENGTH FAILED|PARTITION_HANDLER.CC +# +CREATE TABLE t1 ( +col_int_key bigint DEFAULT NULL, +KEY(col_int_key) +) PARTITION BY KEY(col_int_key) PARTITIONS 10; +INSERT INTO t1 VALUES +(NULL); +SELECT 42 +WHERE 11 NOT IN +(SELECT col_int_key FROM t1); +42 +DROP TABLE t1; +# Bug#30753397 ASSERTION `!TR->DERIVED_WHERE_COND || TR->DERIVED_WHERE_COND->FIXED' FAILED. +# +CREATE TABLE t(a INT); +SELECT 1= +( +SELECT 1 FROM +( +SELECT 1 FROM t +LEFT JOIN +( +SELECT 1 FROM t +WHERE NOT EXISTS +( +SELECT 1 FROM t WINDOW w1 AS (PARTITION BY a) +) +) AS x +ON 1 > 2 +) AS z +); +1= +( +SELECT 1 FROM +( +SELECT 1 FROM t +LEFT JOIN +( +SELECT 1 FROM t +WHERE NOT EXISTS +( +SELECT 1 FROM t WINDOW w1 AS (PARTITION BY a) +) +) AS x +ON 1 > 2 +) AS z +) +NULL +DROP TABLE t; +# Bug#30899681 Mysqld got signal 11 at Item::walk() +CREATE TABLE t1 ( +col_varchar varchar(1), +col_varchar_key varchar (1), +key (col_varchar_key) +); +CREATE TABLE t2 ( +col_varchar varchar(1), +col_int_key int, +key (col_int_key) +); +INSERT INTO t2 VALUES ('t', 2); +CREATE TABLE t3 ( +pk integer auto_increment, +col_int int, +col_varchar_key varchar(1), +primary key (pk), +key (col_varchar_key) +); +INSERT INTO t3 (col_int, col_varchar_key) VALUES +(2, 'e'), (NULL, 'n'), (2, NULL), (0, 'a'), (NULL, 'd'), (1, 's'), +(NULL, 'v'), (7, 'l'), (118, NULL), (NULL, 'l'), (8, 'c'), (4, 'a'), +(8, 'r'), (1, 'q'), (3, 'o'), (NULL, 'q'), (2, 'j'), (6, 'f'), +(5, 'e'), (7, 'p'); +CREATE TABLE t4 ( +col_int_key int, +col_varchar varchar(1), +key (col_int_key) +); +INSERT INTO t4 VALUES +(5, 'k'), (5, 'g'), (5, 'k'), (1, 'e'), (9, 'b'), (NULL, 'b'), +(141, 'w'), (0, 'i'), (240, 'x'), (1, 'h'), (NULL, 'p'), (201, 'v'), +(5, 'e'), (NULL, 'e'), (2, 'a'), (3, 'r'), (NULL, 'f'), (8, 's'), +(7, 'k'), (6, 'k'); +CREATE TABLE t5 ( +col_int int, +col_varchar_key varchar(1), +pk integer auto_increment, +primary key(pk) +); +INSERT INTO t5 (col_int, col_varchar_key) VALUES +(9, 'g'), (8, 'c'), (2, 'k'), (3, 'g'), (NULL, 'm'), (2, 'c'), +(1, 'o'), (NULL, 'r'), (0, 'u'), (7, 'z'), (4, 'd'), (1, 'q'), +(3, 't'), (NULL, 'x'), (1, 'g'), (8, 'e'), (2, 'f'), (9, NULL), +(229, 't'), (2, 'i'), (127, 'x'), (75, 'u'), (4, 'r'), (4, 'y'), +(NULL, 'y'), (7, 'n'), (8, 'h'), (0, 'e'), (9, 'h'), (4, 'v'), +(4, 'o'), (0, 'w'), (9, NULL), (7, NULL), (7, 'd'), (74, 's'), +(1, 'j'), (9, 'k'), (5, 'g'), (3, 'o'), (5, 'b'), (1, 'l'), +(3, 'u'), (0, 'v'), (7, 'y'), (9, 'g'), (6, 'i'), (9, 'f'), +(3, 'u'), (4, 'q'), (NULL, NULL), (0, 'k'), (NULL, 'l'), (2, 'q'), +(7, 'r'), (5, 't'), (2, 'h'), (2, NULL), (NULL, 'z'), (7, 'c'), +(NULL, 'd'), (242, 'h'), (7, 'e'), (5, 'e'), (7, 's'), (9, 'u'), +(250, 'z'), (9, 'n'), (7, 'j'), (3, 's'), (8, 'e'), (6, NULL), +(NULL, 'i'), (1, 'n'), (3, 'k'), (7, 'n'), (1, 'w'), (8, 'x'), +(1, 'b'), (9, NULL), (4, 'o'), (3, 'i'), (9, 'n'), (91, 'c'), +(5, 'j'), (8, 'g'), (7, 'c'), (9, NULL), (8, 'd'), (NULL, 'h'), +(4, 'k'), (1, 'r'), (33, 'k'), (8, 'n'), (4, 'h'), (2, 'q'), +(9, 'p'), (1, NULL), (8, 'n'), (0, 'j'); +SET @var1 = 'h', @var2 = 66 ; +PREPARE ps FROM ' +SELECT (SELECT SUM(sq1_t1.col_int) AS sq1_field1 + FROM t3 AS sq1_t1 INNER JOIN t1 AS sq1_t2 + ON sq1_t2.col_varchar_key = sq1_t1.col_varchar_key + WHERE sq1_t2.col_varchar < sq1_t2.col_varchar OR + sq1_t2.col_varchar <> ? + ) AS field1 +FROM t5 AS table1 LEFT OUTER JOIN t4 AS table2 + ON table2.col_int_key = table1.col_int +WHERE table1.pk > ANY + (SELECT sq2_t1.pk AS sq2_field1 + FROM t3 AS sq2_t1 STRAIGHT_JOIN t2 AS sq2_t2 + ON sq2_t2.col_int_key = sq2_t1.pk + WHERE sq2_t2.col_varchar >= table2.col_varchar AND + sq2_t2.col_varchar <= table1.col_varchar_key + ) AND + table1.pk = ?'; +EXECUTE ps USING @var1, @var2; +field1 +NULL +EXECUTE ps USING @var1, @var2; +field1 +NULL +DROP TABLE t1, t2, t3, t4, t5; +Bug#31119132 Semijoin with condition of type column=constant breaks +if different character sets +CREATE TABLE t1( +pk INTEGER, +col_int INTEGER, +col_varchar VARCHAR(1), +col_int_key INTEGER, +col_datetime_key DATETIME, +col_varchar_key VARCHAR(1) +) DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +CREATE PROCEDURE p1() LANGUAGE SQL +SELECT DISTINCT MIN(outr.col_varchar) AS x +FROM t1 AS outr2 LEFT JOIN t1 AS outr +ON outr2.col_int_key <> outr.pk +WHERE outr.col_int IN +(SELECT innr.col_int_key AS y +FROM t1 AS innr +WHERE outr.col_varchar_key = 'z') AND +outr.col_datetime_key = '2003-12-04' +ORDER BY outr.pk, outr.pk; +CALL p1; +x +NULL +CALL p1; +x +NULL +DROP PROCEDURE p1; +DROP TABLE t1; +# +# Bug#31359965 ASSERTION `!TABLE || (!TABLE->READ_SET || BITMAP_IS_SET(TABLE->READ_SET, FIELD_INDEX))' FAILED. IN FIELD_NEW_DECIMAL::VAL_DECIMAL +# +CREATE TABLE t (a DECIMAL(61,14),KEY(a)); +INSERT INTO t VALUES(0),(-1); +SELECT +( +SELECT 1 FROM +( +SELECT a FROM (SELECT 1) u +) z +) +FROM t GROUP BY 1; +( +SELECT 1 FROM +( +SELECT a FROM (SELECT 1) u +) z +) +1 +DROP TABLE t; +# +# Bug #31530529: SERVER CRASH SEEN - (MY_PRINT_STACKTRACE(UNSIGNED CHAR CONST*, UNSIGNED LONG) +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +a VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (3,'N'); +INSERT INTO t1 VALUES (4,'e'); +INSERT INTO t1 VALUES (5,'7'); +INSERT INTO t1 VALUES (6,'7'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 AS table1, t1 AS table2 +WHERE table1.pk = 6 +HAVING table1.a IN (SELECT a FROM t1); +pk a pk a +6 7 3 N +6 7 4 e +6 7 5 7 +6 7 6 7 +DROP TABLE t1; +# Bug#20794575: Assertion failed: bit < map->n_bits +SET optimizer_switch="semijoin=off"; +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(c INTEGER); +SELECT b FROM t1 HAVING 1 IN +(SELECT b FROM t2 WHERE c = 1); +b +SET optimizer_switch=DEFAULT; +DROP TABLE t1, t2; +# Bug#30753397: Assertion `!tr->derived_where_cond || tr->derived_where_cond->fixed' failed +CREATE TABLE t(a INTEGER); +INSERT INTO t VALUES(1),(2),(3); +SELECT 1 = (SELECT 1 +FROM (SELECT 1 +FROM t LEFT JOIN +(SELECT 1 +FROM t +WHERE NOT EXISTS (SELECT 1 +FROM t +WINDOW w1 AS(PARTITION BY a) +) +) AS x +ON 1 > 2 +) AS z +); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t; +# +# Bug #31559978: REGRESSION: HEAP BUFFER OVERFLOW & ASSERTION FAILURE: ROW0SEL.CC:5574:PREBUILT->CAN_PREFETCH_RECORDS() || RECORD_BUFFER == NULLPTR +# +CREATE TABLE t1 ( +a INTEGER, +d VARCHAR(255) NOT NULL, +PRIMARY KEY (d) +); +INSERT INTO t1 VALUES (1,'1'), (2,'2'); +EXPLAIN FORMAT=tree SELECT 1 FROM t1 WHERE d IN (SELECT a FROM t1); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=1.10 rows=2) + -> Inner hash join (cast(t1.d as double) = cast(t1.a as double)) (cost=1.10 rows=2) + -> Index scan on t1 using PRIMARY (cost=0.35 rows=2) + -> Hash + -> Table scan on t1 (cost=0.45 rows=2) + +Warnings: +Warning 1739 Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'd' +Warning 1739 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'd' +SELECT 1 FROM t1 WHERE d IN (SELECT a FROM t1); +1 +1 +1 +DROP TABLE t1; +# +# Bug#31096309 - 8.0.16+ DIFFERENT RESULTSET THAN 5.7 AND <=8.0.15 +# +CREATE TABLE t1 (c1 int, c2 char(10)); +INSERT INTO t1 VALUES (1, 'name1'); +INSERT INTO t1 VALUES (2, 'name2'); +SET optimizer_switch='semijoin=on'; +explain format = tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 1,1); +EXPLAIN +-> Filter: exists(select #2) (cost=0.45 rows=2) + -> Table scan on a (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit/Offset: 1/1 row(s) (cost=0.35 rows=0) + -> Filter: (b.c2 = a.c2) (cost=0.35 rows=1) + -> Table scan on b (cost=0.35 rows=2) + +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 1,1); +c2 +explain format=tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,1); +EXPLAIN +-> Parallel scan on + -> Hash semijoin (b.c2 = a.c2) (cost=0.83 rows=2) + -> PQblock scan on a (cost=0.45 rows=2) + -> Hash + -> Table scan on b (cost=0.18 rows=2) + +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,1); +c2 +name1 +name2 +SET @offset_value=0; +PREPARE explain_stmt FROM "EXPLAIN format = tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT ?,1)"; +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +EXECUTE explain_stmt USING @offset_value; +EXPLAIN +-> Filter: exists(select #2) (cost=0.45 rows=2) + -> Table scan on a (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Limit: 1 row(s) (cost=0.35 rows=1) + -> Filter: (b.c2 = a.c2) (cost=0.35 rows=1) + -> Table scan on b (cost=0.35 rows=2) + +PREPARE stmt FROM "SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT ?,1)"; +EXECUTE stmt USING @offset_value; +c2 +name1 +name2 +explain format = tree SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,0); +EXPLAIN +-> Filter: exists(select #2) (cost=0.45 rows=2) + -> Table scan on a (cost=0.45 rows=2) + -> Select #2 (subquery in condition; dependent) + -> Zero rows (Zero limit) (cost=0.00..0.00 rows=0) + +Warnings: +Note 1276 Field or reference 'test.a.c2' of SELECT #2 was resolved in SELECT #1 +SELECT a.c2 FROM t1 AS a WHERE +EXISTS (SELECT 1 FROM t1 AS b WHERE b.c2 = a.c2 LIMIT 0,0); +c2 +DROP TABLE t1; +SET optimizer_switch=default; +# +# Bug #31586937: REGRESSION: CRASH IN FILESORT::MAKE_SORTORDER +# +CREATE TABLE t1 (a INTEGER); +CREATE TABLE t2 (b INTEGER); +SELECT ( SELECT b FROM t2 ORDER BY a, MIN(a) LIMIT 1 ) FROM t1 GROUP BY a; +( SELECT b FROM t2 ORDER BY a, MIN(a) LIMIT 1 ) +DROP TABLE t1, t2; diff --git a/mysql-test/r/subquery_exists.result-pq b/mysql-test/r/subquery_exists.result-pq new file mode 100644 index 000000000..23d69fe2b --- /dev/null +++ b/mysql-test/r/subquery_exists.result-pq @@ -0,0 +1,541 @@ +CREATE TABLE t1( +pk INTEGER PRIMARY KEY, +uk INTEGER UNIQUE, +ukn INTEGER UNIQUE NOT NULL, +ik INTEGER, +d INTEGER, +INDEX ik(ik)); +INSERT INTO t1 VALUES +(0, NULL, 0, NULL, NULL), +(1, 10, 20, 30, 40), +(2, 20, 40, 60, 80); +CREATE TABLE t2( +pk INTEGER PRIMARY KEY); +INSERT INTO t2 VALUES +(1), (2), (3), (4), (5), (6), (7), (8), (9),(10), +(11),(12),(13),(14),(15),(16),(17),(18),(19),(20), +(21),(22),(23),(24),(25),(26),(27),(28),(29),(30), +(31),(32),(33),(34),(35),(36),(37),(38),(39),(40), +(41),(42),(43),(44),(45),(46),(47),(48),(49),(50), +(51),(52),(53),(54),(55),(56),(57),(58),(59),(60), +(61),(62),(63),(64),(65),(66),(67),(68),(69),(70), +(71),(72),(73),(74),(75),(76),(77),(78),(79),(80); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 FROM dual +WHERE EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +2 SUBQUERY it NULL index NULL ukn 4 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from DUAL where true +SELECT 1 FROM dual +WHERE EXISTS (SELECT * FROM t1 AS it); +1 +1 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` where true +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual WHERE FALSE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` where false +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT 1 FROM dual WHERE FALSE); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL index NULL ukn 4 NULL 3 100.00 Using index; FirstMatch +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where true +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where true +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = 1); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where multiple equal(1, NULL) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where multiple equal(1, NULL) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ref ik ik 5 const 1 100.00 Using index; FirstMatch +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ik` = 1) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`d` = 1) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = 1); +pk uk ukn ik d +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL PRIMARY NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL eq_ref PRIMARY PRIMARY 4 test.ot.pk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where (`test`.`it`.`pk` = `test`.`ot`.`pk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.uk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL uk NULL NULL NULL 3 100.00 Using where +2 SIMPLE it NULL eq_ref uk uk 5 test.ot.uk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.uk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where (`test`.`it`.`uk` = `test`.`ot`.`uk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.uk); +pk uk ukn ik d +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.ukn); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ukn NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL eq_ref ukn ukn 4 test.ot.ukn 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.ukn' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `it` join `test`.`t1` `ot` where (`test`.`it`.`ukn` = `test`.`ot`.`ukn`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.ukn); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.ik); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ik NULL NULL NULL 3 100.00 Using where +2 SIMPLE it NULL ref ik ik 5 test.ot.ik 1 100.00 Using index; FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.ik' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ik` = `test`.`ot`.`ik`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.ik); +pk uk ukn ik d +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`d` = `test`.`ot`.`d`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.d); +pk uk ukn ik d +1 10 20 30 40 +2 20 40 60 80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk > ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL PRIMARY NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL PRIMARY NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`pk` > `test`.`ot`.`pk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk > ot.pk); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk > ot.uk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL uk NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL uk NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x4); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.uk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`uk` > `test`.`ot`.`uk`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk > ot.uk); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn > ot.ukn); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ukn NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL ukn NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x2); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.ukn' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ukn` > `test`.`ot`.`ukn`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn > ot.ukn); +pk uk ukn ik d +0 NULL 0 NULL NULL +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik > ot.ik); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL ik NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL ik NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x8); FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.ik' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`ik` > `test`.`ot`.`ik`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik > ot.ik); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d > ot.d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`d` > `test`.`ot`.`d`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d > ot.d); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL index ik ik 5 NULL 3 100.00 Using where; Using index; LooseScan +1 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.ik 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`pk` = `test`.`it`.`ik`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ik = ot.pk); +pk +30 +60 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL index PRIMARY ukn 4 NULL 3 100.00 Using index +2 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.pk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t1` `it` join `test`.`t2` `ot` where (`test`.`ot`.`pk` = `test`.`it`.`pk`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.pk = ot.pk); +pk +1 +2 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL index uk uk 5 NULL 3 100.00 Using where; Using index +2 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.uk 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t1` `it` join `test`.`t2` `ot` where (`test`.`ot`.`pk` = `test`.`it`.`uk`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.uk = ot.pk); +pk +10 +20 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE it NULL index ukn ukn 4 NULL 3 100.00 Using index +2 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 test.it.ukn 1 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t1` `it` join `test`.`t2` `ot` where (`test`.`ot`.`pk` = `test`.`it`.`ukn`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.ukn = ot.pk); +pk +20 +40 +EXPLAIN SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL eq_ref PRIMARY PRIMARY 4 .d 1 100.00 Using index +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.ot.pk' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`pk` = ``.`d`) +SELECT * FROM t2 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it WHERE it.d = ot.pk); +pk +40 +80 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t2 AS it WHERE ot.d = it.pk - 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 8 test.ot.d 1 100.00 Using where +2 MATERIALIZED it NULL index NULL PRIMARY 4 NULL 80 100.00 Using index +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`d` = ``.`(it.pk - 1)`) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t2 AS it WHERE ot.d = it.pk - 1); +pk uk ukn ik d +1 10 20 30 40 +EXPLAIN SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it1 JOIN t2 AS it2 ON it1.pk > it2.pk +WHERE ot.d = it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE it2 NULL eq_ref PRIMARY PRIMARY 4 test.ot.d 1 100.00 Using index +2 SIMPLE it1 NULL ALL PRIMARY NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1); FirstMatch(it2) +Warnings: +Note 1276 Field or reference 'test.ot.d' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`pk` AS `pk`,`test`.`ot`.`uk` AS `uk`,`test`.`ot`.`ukn` AS `ukn`,`test`.`ot`.`ik` AS `ik`,`test`.`ot`.`d` AS `d` from `test`.`t2` `it2` join `test`.`t1` `ot` semi join (`test`.`t1` `it1`) where ((`test`.`it2`.`pk` = `test`.`ot`.`d`) and (`test`.`it1`.`pk` > `test`.`ot`.`d`)) +SELECT * FROM t1 AS ot +WHERE EXISTS (SELECT * FROM t1 AS it1 JOIN t2 AS it2 ON it1.pk > it2.pk +WHERE ot.d = it2.pk); +pk uk ukn ik d +DROP TABLE t1, t2; +# Bug#28957660 Regression: Crash in select_lex::flatten_subqueries +CREATE TABLE t1 (a INTEGER); +explain SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE 127 = 55); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where false +SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE 127 = 55); +a +explain SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) where true +SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +a +explain SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +32 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) semi join (`test`.`t1`) where false +SELECT * FROM t1 +WHERE EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1) AND +EXISTS (SELECT * FROM t1); +a +DROP TABLE t1; diff --git a/mysql-test/r/subquery_mat_mixed_types.result-pq b/mysql-test/r/subquery_mat_mixed_types.result-pq new file mode 100644 index 000000000..555a36327 --- /dev/null +++ b/mysql-test/r/subquery_mat_mixed_types.result-pq @@ -0,0 +1,10135 @@ +# +# Bug#13960580 SUBQUERY MATERIALIZATION IS TOO RESTRICTIVE ON DATA TYPES +# +CREATE TABLE t1 (c1 INT, KEY(c1)); +CREATE TABLE t2 (c1 BIGINT, KEY(c1)); +CREATE TABLE t3 (c1 DECIMAL(10,2), KEY(c1)); +CREATE TABLE t4 (c1 FLOAT, KEY(c1)); +CREATE TABLE t5 (c1 DOUBLE, KEY(c1)); +CREATE TABLE t6 (c1 CHAR(60), KEY(c1)); +CREATE TABLE t7 (c1 VARCHAR(60), KEY(c1)); +CREATE TABLE t8 (c1 TIME, KEY(c1)); +CREATE TABLE t9 (c1 TIMESTAMP, KEY(c1)); +CREATE TABLE t10 (c1 DATE, KEY(c1)); +CREATE TABLE t11 (c1 DATETIME, KEY(c1)); +CREATE TABLE t12 (c1 CHAR(10) CHARACTER SET UTF16, KEY(c1)); +CREATE TABLE t13 (c1 BIGINT UNSIGNED, KEY(c1)); +INSERT INTO t1 VALUES (19910113), (20010514), (19930513), (19970416), (19960416), +(19950414); +INSERT INTO t2 VALUES (19930513), (19990419), (19950414), (-1), (-19950414); +INSERT INTO t3 VALUES (19930513.3), (19990519), (19950414.0), (19950414.1); +INSERT INTO t4 VALUES (19930513.3), (19990419.2), (19950414e0), (19950414.1e0); +INSERT INTO t5 VALUES (19930513.3), (19990419.2), (19950414e0), (19950414.1e0); +INSERT INTO t6 VALUES ('19910111'), ('20010513'), ('19930513'), ('19950414'), +('19950414.1'); +INSERT INTO t7 VALUES ('19910111'), ('20010513'), ('19930513'), ('19950414'), +('19950414.1'); +INSERT INTO t8 VALUES ('10:22:33'), ('12:34:56'), ('33:22:33'); +INSERT INTO t9 VALUES (20150413102233), (19990102123456); +INSERT INTO t10 VALUES ('1998-01-01'), ('2015-04-13'); +INSERT INTO t11 VALUES ('1999-08-14 01:00:00'), ('2015-04-13 10:22:33'), +('2015-04-14 09:22:33'); +INSERT INTO t12 VALUES ('19910111'), ('19930513'), ('20010513'), ('19950414') +, ('19950414.1'); +INSERT INTO t13 VALUES (19950414),(18446744073709551615); +ANALYZE TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +test.t12 analyze status OK +test.t13 analyze status OK +set optimizer_switch='semijoin=off,materialization=on,subquery_materialization_cost_based=off'; +SET TIMESTAMP=UNIX_TIMESTAMP(20150413000000); +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +c1 c1 +19950414.00 19950400 +19950414.00 19950400 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +c1 c1 +19930513.30 19930513.3 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +c1 c1 +19950400 19950414.00 +19950400 19950414.00 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +c1 c1 +19930513.3 19930513.30 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +33:22:33 2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +2015-04-14 09:22:33 33:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +SET TIMESTAMP=UNIX_TIMESTAMP(20140413000000); +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +set optimizer_switch='semijoin=on,firstmatch=off,loosescan=off,duplicateweedout=off,materialization=on,subquery_materialization_cost_based=off'; +SET TIMESTAMP=UNIX_TIMESTAMP(20150413000000); +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t1.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t3 WHERE t1.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t4 WHERE t1.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t5 WHERE t1.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t6 WHERE t1.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t7 WHERE t1.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t8 WHERE t1.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t9 WHERE t1.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t10 WHERE t1.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t11 WHERE t1.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t12 WHERE t1.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t1 STRAIGHT_JOIN t13 WHERE t1.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t1 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t1 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t1 WHERE (SELECT 1 FROM t1 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t1 WHERE t2.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t3 WHERE t2.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t4 WHERE t2.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t5 WHERE t2.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t6 WHERE t2.c1=t6.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t7 WHERE t2.c1=t7.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t8 WHERE t2.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t9 WHERE t2.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t10 WHERE t2.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t11 WHERE t2.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t12 WHERE t2.c1=t12.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t2 STRAIGHT_JOIN t13 WHERE t2.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t2 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t2 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t2 WHERE (SELECT 1 FROM t2 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t1 WHERE t3.c1=t1.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t2 WHERE t3.c1=t2.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t4 WHERE t3.c1=t4.c1; +c1 c1 +19950414.00 19950400 +19950414.00 19950400 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t5 WHERE t3.c1=t5.c1; +c1 c1 +19930513.30 19930513.3 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19930513.30 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t6 WHERE t3.c1=t6.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t7 WHERE t3.c1=t7.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t8 WHERE t3.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t9 WHERE t3.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t10 WHERE t3.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t11 WHERE t3.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t12 WHERE t3.c1=t12.c1; +c1 c1 +19950414.00 19950414 +19950414.10 19950414.1 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414.00 +19950414.10 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t3 STRAIGHT_JOIN t13 WHERE t3.c1=t13.c1; +c1 c1 +19950414.00 19950414 +EXPLAIN SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t3 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t3 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414.00 +EXPLAIN SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t3 WHERE (SELECT 1 FROM t3 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t1 WHERE t4.c1=t1.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t2 WHERE t4.c1=t2.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t3 WHERE t4.c1=t3.c1; +c1 c1 +19950400 19950414.00 +19950400 19950414.00 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t5 WHERE t4.c1=t5.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t6 WHERE t4.c1=t6.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t7 WHERE t4.c1=t7.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t8 WHERE t4.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t9 WHERE t4.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t10 WHERE t4.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t11 WHERE t4.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t12 WHERE t4.c1=t12.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t4 STRAIGHT_JOIN t13 WHERE t4.c1=t13.c1; +c1 c1 +19950400 19950414 +19950400 19950414 +EXPLAIN SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t4 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950400 +19950400 +EXPLAIN SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t4 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950400 +EXPLAIN SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t4 WHERE (SELECT 1 FROM t4 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t1 WHERE t5.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t2 WHERE t5.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t3 WHERE t5.c1=t3.c1; +c1 c1 +19930513.3 19930513.30 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19930513.3 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t4 WHERE t5.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t6 WHERE t5.c1=t6.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t7 WHERE t5.c1=t7.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t8 WHERE t5.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t9 WHERE t5.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t10 WHERE t5.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t11 WHERE t5.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t12 WHERE t5.c1=t12.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t5 STRAIGHT_JOIN t13 WHERE t5.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t5 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t5 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t5 WHERE (SELECT 1 FROM t5 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t1 WHERE t6.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t2 WHERE t6.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t3 WHERE t6.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t4 WHERE t6.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t5 WHERE t6.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t7 WHERE t6.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t8 WHERE t6.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t9 WHERE t6.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t10 WHERE t6.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t11 WHERE t6.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t12 WHERE t6.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t6 STRAIGHT_JOIN t13 WHERE t6.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t6 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t6 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t6 WHERE (SELECT 1 FROM t6 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t1 WHERE t7.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t2 WHERE t7.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t3 WHERE t7.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t4 WHERE t7.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t5 WHERE t7.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t6 WHERE t7.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t8 WHERE t7.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t9 WHERE t7.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t10 WHERE t7.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t11 WHERE t7.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +1 +1 +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t12 WHERE t7.c1=t12.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t7 STRAIGHT_JOIN t13 WHERE t7.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t7 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t7 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t7 WHERE (SELECT 1 FROM t7 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t1 WHERE t8.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t2 WHERE t8.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t3 WHERE t8.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t4 WHERE t8.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t5 WHERE t8.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t6 WHERE t8.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t7 WHERE t8.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +10:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t10 WHERE t8.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t11 WHERE t8.c1=t11.c1; +c1 c1 +10:22:33 2015-04-13 10:22:33 +33:22:33 2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +10:22:33 +33:22:33 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t12 WHERE t8.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t13 WHERE t8.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t8 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t8 WHERE (SELECT 1 FROM t8 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t1 WHERE t9.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t2 WHERE t9.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t3 WHERE t9.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t4 WHERE t9.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t5 WHERE t9.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t6 WHERE t9.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t7 WHERE t9.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t10 WHERE t9.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t11 WHERE t9.c1=t11.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t12 WHERE t9.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t13 WHERE t9.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t9 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t9 WHERE (SELECT 1 FROM t9 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t1 WHERE t10.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t2 WHERE t10.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t3 WHERE t10.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t4 WHERE t10.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t5 WHERE t10.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t6 WHERE t10.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t7 WHERE t10.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t8 WHERE t10.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t9 WHERE t10.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t11 WHERE t10.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +1 +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t12 WHERE t10.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t10 STRAIGHT_JOIN t13 WHERE t10.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t10 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t10 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t10 WHERE (SELECT 1 FROM t10 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t1 WHERE t11.c1=t1.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t1); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t2 WHERE t11.c1=t2.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t2); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t3 WHERE t11.c1=t3.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t3); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t4 WHERE t11.c1=t4.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t4); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t5 WHERE t11.c1=t5.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t5); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t6 WHERE t11.c1=t6.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t6); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t7 WHERE t11.c1=t7.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t7); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t8 WHERE t11.c1=t8.c1; +c1 c1 +2015-04-13 10:22:33 10:22:33 +2015-04-14 09:22:33 33:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +2015-04-13 10:22:33 +2015-04-14 09:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t9 WHERE t11.c1=t9.c1; +c1 c1 +2015-04-13 10:22:33 2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +2015-04-13 10:22:33 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t10 WHERE t11.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +1 +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t12 WHERE t11.c1=t12.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t12); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t11 STRAIGHT_JOIN t13 WHERE t11.c1=t13.c1; +c1 c1 +EXPLAIN SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t11 WHERE c1 IN (SELECT c1 FROM t13); +c1 +EXPLAIN SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t11 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +DELETE FROM t11 WHERE c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t11 WHERE (SELECT 1 FROM t11 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +INSERT INTO t11 SET c1='2015-04-14 09:22:33'; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t1 WHERE t12.c1=t1.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t2 WHERE t12.c1=t2.c1; +c1 c1 +19930513 19930513 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19930513 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t3 WHERE t12.c1=t3.c1; +c1 c1 +19950414 19950414.00 +19950414.1 19950414.10 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t4 WHERE t12.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t5 WHERE t12.c1=t5.c1; +c1 c1 +19950414 19950414 +19950414.1 19950414.1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +19950414.1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t6 WHERE t12.c1=t6.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t7 WHERE t12.c1=t7.c1; +c1 c1 +19910111 19910111 +19930513 19930513 +19950414 19950414 +19950414.1 19950414.1 +20010513 20010513 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19910111 +19930513 +19950414 +19950414.1 +20010513 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t8 WHERE t12.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t9 WHERE t12.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t10 WHERE t12.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t11 WHERE t12.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t12 STRAIGHT_JOIN t13 WHERE t12.c1=t13.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t12 WHERE c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t12 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t13); +c1 +19950414 +EXPLAIN SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t12 WHERE (SELECT 1 FROM t12 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t13 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t1 WHERE t13.c1=t1.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t1); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t1 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t2 WHERE t13.c1=t2.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t2); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t2 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t3 WHERE t13.c1=t3.c1; +c1 c1 +19950414 19950414.00 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t3); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t3 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t4 WHERE t13.c1=t4.c1; +c1 c1 +19950414 19950400 +19950414 19950400 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t4); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t4 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t5 WHERE t13.c1=t5.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t5); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t5 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t6 WHERE t13.c1=t6.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t6); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t6 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t7 WHERE t13.c1=t7.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t7); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t7 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t8 WHERE t13.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t8); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t8 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t9 WHERE t13.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t9 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t10 WHERE t13.c1=t10.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t10); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t10 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t11 WHERE t13.c1=t11.c1; +c1 c1 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t11); +c1 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t11 WHERE ASCII(c1) = 50); +1 +EXPLAIN SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 STRAIGHT_JOIN t12 WHERE t13.c1=t12.c1; +c1 c1 +19950414 19950414 +EXPLAIN SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t13 WHERE c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# DEPENDENT SUBQUERY # # # # # # # # # # +SELECT * FROM t13 GROUP BY c1 HAVING c1 IN (SELECT c1 FROM t12); +c1 +19950414 +EXPLAIN SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# PRIMARY # # # # # # # # # # +# SUBQUERY # # # # # # # # # # +SELECT 1 FROM t13 WHERE (SELECT 1 FROM t13 WHERE ASCII(c1) = 50) IN +(SELECT 1 FROM t12 WHERE ASCII(c1) = 50); +1 +SET TIMESTAMP=UNIX_TIMESTAMP(20140413000000); +EXPLAIN SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t8 STRAIGHT_JOIN t9 WHERE t8.c1=t9.c1; +c1 c1 +EXPLAIN SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# MATERIALIZED # # # # # # # # # # +SELECT * FROM t8 WHERE c1 IN (SELECT c1 FROM t9); +c1 +EXPLAIN SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 STRAIGHT_JOIN t8 WHERE t9.c1=t8.c1; +c1 c1 +EXPLAIN SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +# SIMPLE # # # # # # # # # # +SELECT * FROM t9 WHERE c1 IN (SELECT c1 FROM t8); +c1 +DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13; diff --git a/mysql-test/r/subquery_sj_all.result-pq b/mysql-test/r/subquery_sj_all.result-pq new file mode 100644 index 000000000..6bec05300 --- /dev/null +++ b/mysql-test/r/subquery_sj_all.result-pq @@ -0,0 +1,12993 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using index condition; Using where; Using MRR +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=42.80..42.80 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.00 rows=48) + -> Nested loop inner join (cost=38.00 rows=48) + -> Filter: (t1.c is not null) (cost=21.20 rows=48) + -> Index range scan on t1 using kp1, with index condition: (t1.kp1 < 20) (cost=21.20 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using index condition; Using MRR; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using index condition; Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`Population` > 5000000)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.20", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "index_condition": "(`test`.`t3`.`Language` = 'English')", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.46", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "(`test`.`t3`.`Percentage` > 10)" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; LooseScan +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=7.85 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_all_bka.result-pq b/mysql-test/r/subquery_sj_all_bka.result-pq new file mode 100644 index 000000000..aed59a467 --- /dev/null +++ b/mysql-test/r/subquery_sj_all_bka.result-pq @@ -0,0 +1,13000 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using index condition; Using where; Using MRR +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=42.80..42.80 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.00 rows=48) + -> Nested loop inner join (cost=38.00 rows=48) + -> Filter: (t1.c is not null) (cost=21.20 rows=48) + -> Index range scan on t1 using kp1, with index condition: (t1.kp1 < 20) (cost=21.20 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where; Using join buffer (Batched Key Access) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using index condition; Using MRR; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using index condition; Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`Population` > 5000000)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.20", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "index_condition": "(`test`.`t3`.`Language` = 'English')", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.46", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "(`test`.`t3`.`Percentage` > 10)" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 Using join buffer (Batched Key Access) +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; LooseScan +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr); Using join buffer (Batched Key Access) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=7.85 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 26 +Handler_read_prev 0 +Handler_read_rnd 22 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_all_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_all_bka_nobnl.result-pq new file mode 100644 index 000000000..2e409a053 --- /dev/null +++ b/mysql-test/r/subquery_sj_all_bka_nobnl.result-pq @@ -0,0 +1,13000 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using index condition; Using where; Using MRR +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=42.80..42.80 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.00 rows=48) + -> Nested loop inner join (cost=38.00 rows=48) + -> Filter: (t1.c is not null) (cost=21.20 rows=48) + -> Index range scan on t1 using kp1, with index condition: (t1.kp1 < 20) (cost=21.20 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where; Using join buffer (Batched Key Access) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=56.54 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.31 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=10.41 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref I1 I1 7 test.t2.b 2 100.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using index condition; Using MRR; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using index condition; Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "index_condition": "(`test`.`t1`.`Population` > 5000000)", + "using_MRR": true, + "cost_info": { + "read_cost": "0.60", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.20", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "index_condition": "(`test`.`t3`.`Language` = 'English')", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.46", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "(`test`.`t3`.`Percentage` > 10)" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using index condition; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 Using join buffer (Batched Key Access) +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE alias3 NULL range PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 50.00 Using index condition; Using where; Using MRR +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`alias3`.`pk` = ``.`sq2_field1`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 Using join buffer (Batched Key Access) +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; LooseScan +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch() +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr); Using join buffer (Batched Key Access) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.63" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "8.63", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.56" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.05", + "eval_cost": "4.00", + "prefix_cost": "13.56", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "60.24" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "60.24", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.77", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "Batched Key Access", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.47", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.53", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=8.04 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=8.04 rows=7) + -> Nested loop inner join (cost=8.04 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.25 rows=1) + -> Filter: (t4.col_int_key = t1.col_int_key) (cost=0.54 rows=1) + -> Table scan on t4 (cost=0.54 rows=6) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; Using join buffer (Batched Key Access) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 26 +Handler_read_prev 0 +Handler_read_rnd 22 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=14.75 rows=54) + -> Nested loop left join (cost=14.75 rows=54) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop inner join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on t1 (cost=0.30 rows=3) + -> Table scan on alias1 (cost=4.80 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_dupsweed.result-pq b/mysql-test/r/subquery_sj_dupsweed.result-pq new file mode 100644 index 000000000..cf20eb0d2 --- /dev/null +++ b/mysql-test/r/subquery_sj_dupsweed.result-pq @@ -0,0 +1,12919 @@ +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 33.33 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.41" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "28.41", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Limit: 1 row(s) (cost=25.35 rows=1) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 1 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.46" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.21", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.47", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 25.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Start temporary +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 10.00 Using where +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.12" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "7.41", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "9.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "61.30" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "20.79", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "61.30", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index; Start temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Limit: 1 row(s) (cost=2.14 rows=1) + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.11 rows=1) + -> Table scan on t3 (cost=0.11 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_dupsweed_bka.result-pq b/mysql-test/r/subquery_sj_dupsweed_bka.result-pq new file mode 100644 index 000000000..b74503b90 --- /dev/null +++ b/mysql-test/r/subquery_sj_dupsweed_bka.result-pq @@ -0,0 +1,12921 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 33.33 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.41" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "28.41", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Limit: 1 row(s) (cost=25.35 rows=1) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 1 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.46" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.21", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.47", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 25.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Start temporary +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 10.00 Using where +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.12" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "7.41", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "9.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "61.30" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "20.79", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "61.30", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index; Start temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Limit: 1 row(s) (cost=2.14 rows=1) + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.11 rows=1) + -> Table scan on t3 (cost=0.11 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=6.20 rows=54) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Inner hash join (no condition) (cost=1.30 rows=6) + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.09 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_dupsweed_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_dupsweed_bka_nobnl.result-pq new file mode 100644 index 000000000..79488c9af --- /dev/null +++ b/mysql-test/r/subquery_sj_dupsweed_bka_nobnl.result-pq @@ -0,0 +1,12908 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index; Start temporary +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "33.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.59", + "eval_cost": "1.10", + "prefix_cost": "33.50", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Limit: 1 row(s) (cost=25.35 rows=1) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) + -> Nested loop left join (cost=117.35 rows=864) + -> Nested loop left join (cost=14.91 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.83 rows=12) + -> Filter: (it3.a = ot1.a) (cost=1.62 rows=3) + -> Table scan on it3 (cost=1.62 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=49.53 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (it3.a = ot2.a) (cost=1.51 rows=3) + -> Table scan on it3 (cost=1.51 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Start temporary +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref I1 I1 7 test.t2.b 2 100.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t1.Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t1.Country,const 1 95.45 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.46" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t1.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.21", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t1.Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.47", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where; Start temporary +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Start temporary +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Start temporary +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index; Start temporary +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 100.00 NULL +2 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 test.it2.col_varchar_nokey 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`ot1`.`col_varchar_key` = `test`.`it2`.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Start temporary +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 10.00 Using where +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; End temporary +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.16" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "cost_info": { + "read_cost": "3.04", + "eval_cost": "0.60", + "prefix_cost": "9.95", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "14.17", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.88" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.67", + "eval_cost": "14.00", + "prefix_cost": "26.88", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "71.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "20.79", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "71.01", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.97", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.67", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where; Start temporary +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index; Start temporary +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop inner join (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Limit: 1 row(s) (cost=2.14 rows=1) + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Start temporary; End temporary +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Remove duplicate t1 rows using temporary table (weedout) (cost=14.75 rows=54) + -> Nested loop left join (cost=14.75 rows=54) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop inner join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on t1 (cost=0.30 rows=3) + -> Table scan on alias1 (cost=4.80 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_firstmatch.result-pq b/mysql-test/r/subquery_sj_firstmatch.result-pq new file mode 100644 index 000000000..97cee946a --- /dev/null +++ b/mysql-test/r/subquery_sj_firstmatch.result-pq @@ -0,0 +1,12945 @@ +set optimizer_switch='semijoin=on,firstmatch=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t22) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = `test`.`t21`.`a`) and (`test`.`t11`.`a` = `test`.`t21`.`a`) and (`test`.`t12`.`a` = `test`.`t21`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t21`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "29.83" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 32, + "rows_produced_per_join": 32, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "3.20", + "prefix_cost": "3.73", + "data_read_per_join": "512" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 32, + "filtered": "12.50", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "3.20", + "prefix_cost": "29.84", + "data_read_per_join": "512" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "24.11" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "first_match": "t0", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "24.11", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop semijoin (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; FirstMatch(c); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 100 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` > 5) or (`test`.`t3`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "921.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "a" + ], + "rows_examined_per_scan": 1000, + "rows_produced_per_join": 793, + "filtered": "79.30", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "46.16", + "eval_cost": "79.30", + "prefix_cost": "126.97", + "data_read_per_join": "322K" + }, + "used_columns": [ + "a", + "b", + "filler" + ], + "attached_condition": "((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 793, + "filtered": "10.00", + "first_match": "t3", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "79.30", + "prefix_cost": "921.10", + "data_read_per_join": "6K" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t3`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t4`.`y` = `test`.`t3`.`b`) and (`test`.`t4`.`x` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`x`.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`it3`.`a` = `test`.`ot1`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot2`.`a`) and (`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it2`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it3`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=98.31 rows=864) + -> Nested loop left join (cost=11.41 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop semijoin (cost=1.81 rows=12) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Filter: (it3.a = ot1.a) (cost=0.08 rows=3) + -> Table scan on it3 (cost=0.08 rows=3) + -> Nested loop semijoin (cost=1.43 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (it3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on it3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(staff) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 50.00 Using where; Using index; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f2` = `test`.`t1`.`f2`) and (`test`.`t2`.`f1` = `test`.`t1`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,Population NULL NULL NULL 16 75.00 Using where +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 10.00 Using where; FirstMatch(t2); Using join buffer (hash join) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t2.Code,const 1 95.45 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.07" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "rows_examined_per_scan": 16, + "rows_produced_per_join": 12, + "filtered": "75.00", + "cost_info": { + "read_cost": "1.13", + "eval_cost": "1.20", + "prefix_cost": "2.33", + "data_read_per_join": "2K" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 12, + "filtered": "10.00", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "7.32", + "eval_cost": "1.20", + "prefix_cost": "10.85", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t1`.`Population` > 5000000))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t2.Code", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "1.15", + "prefix_cost": "12.07", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE t2 NULL ref CountryCode CountryCode 12 test.t1.Code 18 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; FirstMatch(t0) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL index k k 10 NULL 4 25.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot4) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot4`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t1`.`f1` = `test`.`t2`.`f2`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 17 33.33 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_varchar_key NULL NULL NULL 17 33.33 Using where; Using filesort +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.outr.col_varchar_key 1 100.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`outr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_varchar_key NULL NULL NULL 15 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 15 10.00 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 10.00 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent2) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL index a a 7 NULL 4 100.00 Using index +1 SIMPLE it NULL ALL a NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`a` = `test`.`ot`.`a`) and (`test`.`it`.`b` = `test`.`ot`.`a`) and ((`test`.`ot`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(alias2) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using index +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using where; Using index; FirstMatch(gp1) +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`gp1`.`col_varchar_nokey`) and (`test`.`t2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_nokey`) and ('k' <> `test`.`gp1`.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL vc_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child1 NULL ref int_key,vc_key vc_key 7 test.outr.vc_nokey 2 100.00 Using where; Using index +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_key` = `test`.`outr`.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`outr`.`vc_nokey`) and (`test`.`child1`.`vc_key` = `test`.`outr`.`vc_nokey`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 NULL +1 SIMPLE subquery1_t2 NULL ALL PRIMARY NULL NULL NULL 20 10.00 Using where +1 SIMPLE subquery1_t3 NULL ref col_varchar_key col_varchar_key 7 test.subquery1_t2.col_varchar_nokey 1 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; FirstMatch(table3) +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index; FirstMatch(subquery1_t1) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t3`.`col_int_key` = `subquery1_t2`.`pk`) and (`subquery1_t3`.`col_varchar_key` = `subquery1_t2`.`col_varchar_nokey`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`subquery1_t2`.`col_int_nokey` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 32.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; FirstMatch(alias2) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 table1.col_varchar_nokey 0 0.00 Using index; FirstMatch() +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(subquery3_t1); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`test`.`subquery3_t1`.`col_varchar_key` = `table1`.`col_varchar_nokey`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.92" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "5.21", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.92", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "derived1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`derived1`.`col_varchar_nokey` is not null)", + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "derived2", + "access_type": "ref", + "possible_keys": [ + "col_varchar_key" + ], + "key": "col_varchar_key", + "used_key_parts": [ + "col_varchar_key" + ], + "key_length": "7", + "ref": [ + "derived1.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "14.29", + "first_match": "derived1", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "8.19", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "22.71", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `derived1`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "57.82" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "grandparent1", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "17.31", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "57.82", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "151.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "2.00", + "prefix_cost": "2.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.00", + "eval_cost": "2.00", + "prefix_cost": "9.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "5.00", + "cost_info": { + "read_cost": "37.24", + "eval_cost": "2.00", + "prefix_cost": "24.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2))" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "alias3", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "2.00", + "prefix_cost": "110.68", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "40.00", + "prefix_cost": "151.21", + "data_read_per_join": "12K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 7 test.outr.col_varchar_nokey 1 50.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_nokey`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,c1_key NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x3) +2 SIMPLE t3 NULL ref PRIMARY,c1_key c1_key 6 test.t2.c1 1 50.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`c1` = `test`.`t2`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index; FirstMatch(ir2) +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(tv) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 25 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 12 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=4.85 rows=1) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +# +# Bug#51457 Firstmatch semijoin strategy gives wrong results for +# certain query plans +# +SET @@default_storage_engine='innodb'; +SET @@optimizer_switch='semijoin=on,materialization=off,firstmatch=on,loosescan=off,block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t0(a INTEGER); +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(5), (8); +CREATE TABLE t6(a INTEGER); +INSERT INTO t6 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE t8(a INTEGER); +INSERT INTO t8 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +EXPLAIN +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a` from `test`.`t2` `nt2` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a +5 +8 +EXPLAIN +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE nt4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a`,`test`.`nt4`.`a` AS `a` from `test`.`t2` `nt2` join `test`.`t8` `nt4` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a a +5 1 +5 1 +5 3 +5 3 +5 5 +5 7 +5 7 +5 9 +8 1 +8 1 +8 3 +8 3 +8 5 +8 7 +8 7 +8 9 +EXPLAIN +SELECT * +FROM t0 AS ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE it4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +2 SIMPLE nt3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`nt3`.`a` AS `a` from `test`.`t0` `ot1` join `test`.`t2` `nt3` semi join (`test`.`t1` `it2` join `test`.`t8` `it4`) where ((`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it4`.`a` = `test`.`ot1`.`a`)) +SELECT * +FROM t0 as ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +a a +DROP TABLE t0, t1, t2, t6, t8; +SET @@default_storage_engine=default; +SET @@optimizer_switch=default; +# End of bug#51457 +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_firstmatch_bka.result-pq b/mysql-test/r/subquery_sj_firstmatch_bka.result-pq new file mode 100644 index 000000000..395d042c9 --- /dev/null +++ b/mysql-test/r/subquery_sj_firstmatch_bka.result-pq @@ -0,0 +1,12947 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,firstmatch=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t22) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = `test`.`t21`.`a`) and (`test`.`t11`.`a` = `test`.`t21`.`a`) and (`test`.`t12`.`a` = `test`.`t21`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t21`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "29.83" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 32, + "rows_produced_per_join": 32, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "3.20", + "prefix_cost": "3.73", + "data_read_per_join": "512" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 32, + "filtered": "12.50", + "first_match": "t1", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "3.20", + "prefix_cost": "29.84", + "data_read_per_join": "512" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "24.11" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "first_match": "t0", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "24.11", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop semijoin (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; FirstMatch(c); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 100 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` > 5) or (`test`.`t3`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "921.10" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "a" + ], + "rows_examined_per_scan": 1000, + "rows_produced_per_join": 793, + "filtered": "79.30", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "46.16", + "eval_cost": "79.30", + "prefix_cost": "126.97", + "data_read_per_join": "322K" + }, + "used_columns": [ + "a", + "b", + "filler" + ], + "attached_condition": "((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 793, + "filtered": "10.00", + "first_match": "t3", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "79.30", + "prefix_cost": "921.10", + "data_read_per_join": "6K" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t3`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t4`.`y` = `test`.`t3`.`b`) and (`test`.`t4`.`x` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`x`.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`it3`.`a` = `test`.`ot1`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2); Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot2`.`a`) and (`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it2`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it3`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=98.31 rows=864) + -> Nested loop left join (cost=11.41 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop semijoin (cost=1.81 rows=12) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Filter: (it3.a = ot1.a) (cost=0.08 rows=3) + -> Table scan on it3 (cost=0.08 rows=3) + -> Nested loop semijoin (cost=1.43 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (it3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on it3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(staff) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 50.00 Using where; Using index; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 50.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f2` = `test`.`t1`.`f2`) and (`test`.`t2`.`f1` = `test`.`t1`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,Population NULL NULL NULL 16 75.00 Using where +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 10.00 Using where; FirstMatch(t2); Using join buffer (hash join) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t2.Code,const 1 95.45 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.07" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "rows_examined_per_scan": 16, + "rows_produced_per_join": 12, + "filtered": "75.00", + "cost_info": { + "read_cost": "1.13", + "eval_cost": "1.20", + "prefix_cost": "2.33", + "data_read_per_join": "2K" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 12, + "filtered": "10.00", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "7.32", + "eval_cost": "1.20", + "prefix_cost": "10.85", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t1`.`Population` > 5000000))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t2.Code", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "1.15", + "prefix_cost": "12.07", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE t2 NULL ref CountryCode CountryCode 12 test.t1.Code 18 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; FirstMatch(t0) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL index k k 10 NULL 4 25.00 Using where; Using index; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot4) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot4`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t1`.`f1` = `test`.`t2`.`f2`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 17 33.33 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_varchar_key NULL NULL NULL 17 33.33 Using where; Using filesort +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.outr.col_varchar_key 1 100.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`outr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_varchar_key NULL NULL NULL 15 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 15 10.00 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 10.00 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent2) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using temporary; Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL index a a 7 NULL 4 100.00 Using index +1 SIMPLE it NULL ALL a NULL NULL NULL 3 33.33 Using where; FirstMatch(ot); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`a` = `test`.`ot`.`a`) and (`test`.`it`.`b` = `test`.`ot`.`a`) and ((`test`.`ot`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(alias2) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using index +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using where; Using index; FirstMatch(gp1) +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`gp1`.`col_varchar_nokey`) and (`test`.`t2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_nokey`) and ('k' <> `test`.`gp1`.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL vc_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child1 NULL ref int_key,vc_key vc_key 7 test.outr.vc_nokey 2 100.00 Using where; Using index +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_key` = `test`.`outr`.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`outr`.`vc_nokey`) and (`test`.`child1`.`vc_key` = `test`.`outr`.`vc_nokey`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 NULL +1 SIMPLE subquery1_t2 NULL ALL PRIMARY NULL NULL NULL 20 10.00 Using where +1 SIMPLE subquery1_t3 NULL ref col_varchar_key col_varchar_key 7 test.subquery1_t2.col_varchar_nokey 1 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; FirstMatch(table3) +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index; FirstMatch(subquery1_t1) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t3`.`col_int_key` = `subquery1_t2`.`pk`) and (`subquery1_t3`.`col_varchar_key` = `subquery1_t2`.`col_varchar_nokey`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`subquery1_t2`.`col_int_nokey` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 32.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; FirstMatch(alias2) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 table1.col_varchar_nokey 0 0.00 Using index; FirstMatch() +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(subquery3_t1); Using join buffer (hash join) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`test`.`subquery3_t1`.`col_varchar_key` = `table1`.`col_varchar_nokey`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.92" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "first_match": "t2", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "5.21", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.92", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "derived1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`derived1`.`col_varchar_nokey` is not null)", + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "derived2", + "access_type": "ref", + "possible_keys": [ + "col_varchar_key" + ], + "key": "col_varchar_key", + "used_key_parts": [ + "col_varchar_key" + ], + "key_length": "7", + "ref": [ + "derived1.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "14.29", + "first_match": "derived1", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "8.19", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "22.71", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `derived1`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "57.82" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "grandparent1", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "17.31", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "57.82", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "151.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "2.00", + "prefix_cost": "2.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.00", + "eval_cost": "2.00", + "prefix_cost": "9.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "5.00", + "cost_info": { + "read_cost": "37.24", + "eval_cost": "2.00", + "prefix_cost": "24.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2))" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "alias3", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "2.00", + "prefix_cost": "110.68", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "40.00", + "prefix_cost": "151.21", + "data_read_per_join": "12K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 7 test.outr.col_varchar_nokey 1 50.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_nokey`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,c1_key NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x3) +2 SIMPLE t3 NULL ref PRIMARY,c1_key c1_key 6 test.t2.c1 1 50.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`c1` = `test`.`t2`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index; FirstMatch(ir2) +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(tv) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 25 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 12 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=4.85 rows=1) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +# +# Bug#51457 Firstmatch semijoin strategy gives wrong results for +# certain query plans +# +SET @@default_storage_engine='innodb'; +SET @@optimizer_switch='semijoin=on,materialization=off,firstmatch=on,loosescan=off,block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t0(a INTEGER); +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(5), (8); +CREATE TABLE t6(a INTEGER); +INSERT INTO t6 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE t8(a INTEGER); +INSERT INTO t8 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +EXPLAIN +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a` from `test`.`t2` `nt2` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a +5 +8 +EXPLAIN +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE nt4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a`,`test`.`nt4`.`a` AS `a` from `test`.`t2` `nt2` join `test`.`t8` `nt4` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a a +5 1 +5 1 +5 3 +5 3 +5 5 +5 7 +5 7 +5 9 +8 1 +8 1 +8 3 +8 3 +8 5 +8 7 +8 7 +8 9 +EXPLAIN +SELECT * +FROM t0 AS ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE it4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +2 SIMPLE nt3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`nt3`.`a` AS `a` from `test`.`t0` `ot1` join `test`.`t2` `nt3` semi join (`test`.`t1` `it2` join `test`.`t8` `it4`) where ((`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it4`.`a` = `test`.`ot1`.`a`)) +SELECT * +FROM t0 as ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +a a +DROP TABLE t0, t1, t2, t6, t8; +SET @@default_storage_engine=default; +SET @@optimizer_switch=default; +# End of bug#51457 +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_firstmatch_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_firstmatch_bka_nobnl.result-pq new file mode 100644 index 000000000..596ad04d9 --- /dev/null +++ b/mysql-test/r/subquery_sj_firstmatch_bka_nobnl.result-pq @@ -0,0 +1,12936 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,firstmatch=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t1`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t22) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = `test`.`t21`.`a`) and (`test`.`t11`.`a` = `test`.`t21`.`a`) and (`test`.`t12`.`a` = `test`.`t21`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t21`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "45.55" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 32, + "rows_produced_per_join": 32, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "3.20", + "prefix_cost": "3.73", + "data_read_per_join": "512" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + }, + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 32, + "filtered": "12.50", + "first_match": "t1", + "cost_info": { + "read_cost": "16.22", + "eval_cost": "3.20", + "prefix_cost": "45.55", + "data_read_per_join": "512" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t11`.`a` = `test`.`t1`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t11`.`a` = `test`.`t1`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "29.20" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "first_match": "t0", + "cost_info": { + "read_cost": "5.59", + "eval_cost": "1.10", + "prefix_cost": "29.20", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t3`.`a` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref kp1 kp1 5 test.t3.a 1 100.00 Using where +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t1`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t3`.`a` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop semijoin (cost=45.54 rows=100) + -> Filter: ((t3.a < 20) and (t3.a is not null)) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Nested loop inner join (cost=25.35 rows=1) + -> Filter: (t1.c is not null) (cost=0.25 rows=1) + -> Index lookup on t1 using kp1 (kp1=t3.a) (cost=0.25 rows=1) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 10.00 Using where; FirstMatch(c) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`d`.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL a NULL NULL NULL 100 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` > 5) or (`test`.`t3`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1319.85" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "a" + ], + "rows_examined_per_scan": 1000, + "rows_produced_per_join": 793, + "filtered": "79.30", + "cost_info": { + "read_cost": "46.16", + "eval_cost": "79.30", + "prefix_cost": "126.97", + "data_read_per_join": "322K" + }, + "used_columns": [ + "a", + "b", + "filler" + ], + "attached_condition": "((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 793, + "filtered": "10.00", + "first_match": "t3", + "cost_info": { + "read_cost": "399.89", + "eval_cost": "79.30", + "prefix_cost": "1319.86", + "data_read_per_join": "6K" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t3`.`a`)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL a NULL NULL NULL 1000 79.30 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t4`.`y` = `test`.`t3`.`b`) and (`test`.`t4`.`x` = `test`.`t3`.`a`) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE t1 NULL ref a a 10 const,test.t2.a 1 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`x`.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using where; Using index +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`it3`.`a` = `test`.`ot1`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it3`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(ot2) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot2`.`a`) and (`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it2`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it3`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=117.36 rows=864) + -> Nested loop left join (cost=14.92 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop semijoin (cost=17.79 rows=12) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Filter: (it3.a = ot1.a) (cost=1.53 rows=3) + -> Table scan on it3 (cost=1.53 rows=3) + -> Nested loop semijoin (cost=49.53 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (it3.a = ot2.a) (cost=1.51 rows=3) + -> Table scan on it3 (cost=1.51 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot2) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 100.00 Using where +1 SIMPLE t1_1 NULL ref varchar_key varchar_key 7 test.t0.varchar_nokey 2 50.00 Using where; Using index +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t0) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t1_1`.`varchar_key` = `test`.`t0`.`varchar_nokey`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; FirstMatch(ot1) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(staff) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 33.33 Using where; FirstMatch(a) +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`c`.`idObj` = `test`.`a`.`idIndividual`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref I1 I1 7 test.t2.b 2 100.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE t1 NULL ref I1 I1 5 test.t1.b 2 100.00 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL t1_IDX NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 8.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t3`.`EMPNUM` = `test`.`t1`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f2` = `test`.`t1`.`f2`) and (`test`.`t2`.`f1` = `test`.`t1`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY,Population NULL NULL NULL 16 75.00 Using where +1 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 10.00 Using where; FirstMatch(t2) +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 test.t2.Code,const 1 95.45 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "12.07" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "rows_examined_per_scan": 16, + "rows_produced_per_join": 12, + "filtered": "75.00", + "cost_info": { + "read_cost": "1.13", + "eval_cost": "1.20", + "prefix_cost": "2.33", + "data_read_per_join": "2K" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 12, + "filtered": "10.00", + "first_match": "t2", + "cost_info": { + "read_cost": "7.32", + "eval_cost": "1.20", + "prefix_cost": "10.85", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t1`.`Population` > 5000000))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + "test.t2.Code", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "1.15", + "prefix_cost": "12.07", + "data_read_per_join": "1K" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Country` = `test`.`t2`.`Code`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE t2 NULL ref CountryCode CountryCode 12 test.t1.Code 18 33.33 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; FirstMatch(t0) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE t2 NULL ref k k 5 test.t1.i 2 33.33 Using where; Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.id 1 14.29 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and ((`test`.`t1`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(ot4) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`it3`.`a` = `test`.`ot4`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot3) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t1`.`f1` = `test`.`t2`.`f2`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; FirstMatch(t3) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 17 33.33 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_varchar_key NULL NULL NULL 17 33.33 Using where; Using filesort +2 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.outr.col_varchar_key 1 100.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`outr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_varchar_key NULL NULL NULL 15 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 15 10.00 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 10.00 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent2) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.36" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "1.36", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL index a a 7 NULL 4 100.00 Using where; Using index +1 SIMPLE it NULL ref a a 7 test.ot.a 2 33.33 Using where; FirstMatch(ot) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`a` = `test`.`ot`.`a`) and (`test`.`it`.`b` = `test`.`ot`.`a`) and ((`test`.`ot`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(grandparent1) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE sq2_alias1 NULL ref col_varchar_key col_varchar_key 7 test.alias2.col_varchar_nokey 2 100.00 Using index; FirstMatch(alias2) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`sq2_alias1`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 SIMPLE it1 NULL ref PRIMARY,col_varchar_key col_varchar_key 6 test.ot2.col_varchar_nokey 1 100.00 Using index +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`it1`.`col_varchar_key` = `test`.`ot2`.`col_varchar_nokey`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using index +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.gp1.col_varchar_nokey 2 100.00 Using where; Using index; FirstMatch(gp1) +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`gp1`.`col_varchar_nokey`) and (`test`.`t2`.`col_varchar_key` = `test`.`gp1`.`col_varchar_nokey`) and ('k' <> `test`.`gp1`.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL vc_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child1 NULL ref int_key,vc_key vc_key 7 test.outr.vc_nokey 2 100.00 Using where; Using index +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_key` = `test`.`outr`.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`outr`.`vc_nokey`) and (`test`.`child1`.`vc_key` = `test`.`outr`.`vc_nokey`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(ot2) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 NULL +1 SIMPLE subquery1_t2 NULL ALL PRIMARY NULL NULL NULL 20 10.00 Using where +1 SIMPLE subquery1_t3 NULL ref col_varchar_key col_varchar_key 7 test.subquery1_t2.col_varchar_nokey 1 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; FirstMatch(table3) +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery2_t1 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using index; FirstMatch(subquery1_t1) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t3`.`col_int_key` = `subquery1_t2`.`pk`) and (`subquery1_t3`.`col_varchar_key` = `subquery1_t2`.`col_varchar_nokey`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`subquery2_t1`.`col_int_key` = `table2`.`pk`) and (`subquery1_t2`.`col_int_nokey` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index; FirstMatch(alias3) +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 32.00 Using where +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; FirstMatch(alias2) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; FirstMatch(alias2) +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 table1.col_varchar_nokey 0 0.00 Using index; FirstMatch() +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(subquery3_t1) +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`test`.`subquery3_t1`.`col_varchar_key` = `table1`.`col_varchar_nokey`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr) +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.96" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ] + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "16.67", + "first_match": "t2", + "cost_info": { + "read_cost": "3.04", + "eval_cost": "0.60", + "prefix_cost": "7.75", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ], + "attached_condition": "(`test`.`t3`.`vc` = `test`.`t2`.`vc`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "11.97", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t3`.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "25.86" + }, + "nested_loop": [ + { + "table": { + "table_name": "derived1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`derived1`.`col_varchar_nokey` is not null)", + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "derived2", + "access_type": "ref", + "possible_keys": [ + "col_varchar_key" + ], + "key": "col_varchar_key", + "used_key_parts": [ + "col_varchar_key" + ], + "key_length": "7", + "ref": [ + "derived1.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "14.29", + "first_match": "derived1", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "8.19", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.67", + "eval_cost": "14.00", + "prefix_cost": "25.86", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `derived1`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "67.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "grandparent1", + "cost_info": { + "read_cost": "10.00", + "eval_cost": "2.00", + "prefix_cost": "17.31", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "67.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "161.26" + }, + "nested_loop": [ + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "2.00", + "prefix_cost": "2.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.00", + "eval_cost": "2.00", + "prefix_cost": "9.53", + "data_read_per_join": "640" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "5.00", + "cost_info": { + "read_cost": "37.24", + "eval_cost": "2.00", + "prefix_cost": "60.11", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2))" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "10.00", + "first_match": "alias3", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "2.00", + "prefix_cost": "110.68", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.58", + "eval_cost": "40.00", + "prefix_cost": "161.26", + "data_read_per_join": "12K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE innr NULL ref PRIMARY,col_varchar_key col_varchar_key 7 test.outr.col_varchar_nokey 1 50.00 Using where; Using index; FirstMatch(outr) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`innr`.`col_varchar_key` = `test`.`outr`.`col_varchar_nokey`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL PRIMARY,c1_key NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x3) +2 SIMPLE t3 NULL ref PRIMARY,c1_key c1_key 6 test.t2.c1 1 50.00 Using where; Using index; FirstMatch(t2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`c1` = `test`.`t2`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index; FirstMatch(ir2) +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using filesort +2 SIMPLE t1 NULL ref col_int_key col_int_key 5 test.t4.col_int_key 1 100.00 Using index +2 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t1`.`col_int_key` = `test`.`t4`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Parallel scan on + -> Nested loop semijoin (cost=3.05 rows=7) + -> Sort: t4.col_int_key (cost=0.85 rows=6) + -> Filter: (t4.col_int_key is not null) + -> PQblock scan on t4 + -> Filter: (t3.col_int is null) (cost=2.14 rows=1) + -> Nested loop left join (cost=2.14 rows=1) + -> Index lookup on t1 using col_int_key (col_int_key=t4.col_int_key) (cost=0.27 rows=1) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.07 rows=1) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; FirstMatch(tv) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`t1`.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 100.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.uid 1 100.00 Using index +1 SIMPLE t3 NULL ref uid uid 5 const 4 10.00 Using where; FirstMatch(t4) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t1`.`uid`) and (`test`.`t3`.`fid` = `test`.`t1`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 25 +Handler_read_last 0 +Handler_read_next 10 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 12 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (concat(`test`.`t1`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t1`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Nested loop inner join (cost=5.40 rows=3) + -> Limit: 1 row(s) (cost=4.85 rows=1) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +# +# Bug#51457 Firstmatch semijoin strategy gives wrong results for +# certain query plans +# +SET @@default_storage_engine='innodb'; +SET @@optimizer_switch='semijoin=on,materialization=off,firstmatch=on,loosescan=off,block_nested_loop=off,batched_key_access=off'; +CREATE TABLE t0(a INTEGER); +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(5), (8); +CREATE TABLE t6(a INTEGER); +INSERT INTO t6 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE t8(a INTEGER); +INSERT INTO t8 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +EXPLAIN +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a` from `test`.`t2` `nt2` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a +5 +8 +EXPLAIN +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch +1 SIMPLE nt2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE nt4 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`nt2`.`a` AS `a`,`test`.`nt4`.`a` AS `a` from `test`.`t2` `nt2` join `test`.`t8` `nt4` semi join (`test`.`t1` `it1` join `test`.`t6` `it3`) where ((`test`.`it1`.`a` = 1) and (`test`.`it3`.`a` = 1)) +SELECT * +FROM t2 AS nt2, t8 AS nt4 +WHERE 1 IN (SELECT it1.a +FROM t1 AS it1 JOIN t6 AS it3 ON it1.a=it3.a); +a a +5 1 +5 1 +5 3 +5 3 +5 5 +5 7 +5 7 +5 9 +8 1 +8 1 +8 3 +8 3 +8 5 +8 7 +8 7 +8 9 +EXPLAIN +SELECT * +FROM t0 AS ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE it4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1) +2 SIMPLE nt3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`nt3`.`a` AS `a` from `test`.`t0` `ot1` join `test`.`t2` `nt3` semi join (`test`.`t1` `it2` join `test`.`t8` `it4`) where ((`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it4`.`a` = `test`.`ot1`.`a`)) +SELECT * +FROM t0 as ot1, t2 AS nt3 +WHERE ot1.a IN (SELECT it2.a +FROM t1 AS it2 JOIN t8 AS it4 ON it2.a=it4.a); +a a +DROP TABLE t0, t1, t2, t6, t8; +SET @@default_storage_engine=default; +SET @@optimizer_switch=default; +# End of bug#51457 +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_innodb_all.result-pq b/mysql-test/r/subquery_sj_innodb_all.result-pq new file mode 100644 index 000000000..e8ede8c36 --- /dev/null +++ b/mysql-test/r/subquery_sj_innodb_all.result-pq @@ -0,0 +1,191 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9), +(10),(12),(14),(16),(18); +create table t1 ( +a int, +b int +) engine=innodb; +insert into t1 values (1,1),(1,1),(2,2); +create table t2 ( +a int, +b int, +key(b) +) engine=innodb; +insert into t2 select a, a/2 from t0; +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t2; +a b +0 0 +1 1 +2 1 +3 2 +4 2 +5 3 +6 3 +7 4 +8 4 +9 5 +10 5 +12 6 +14 7 +16 8 +18 9 +explain select * from t2 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 .a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`b` = ``.`a`) +select * from t2 where b in (select a from t1); +a b +1 1 +2 1 +3 2 +4 2 +truncate table t0; +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), pk3 char(200), +primary key(pk1, pk2, pk3) +) engine=innodb; +insert into t3 select a,a, a,a,a from t0; +explain select * from t3 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2`,`test`.`t3`.`pk3` AS `pk3` from `test`.`t3` semi join (`test`.`t1`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a from t1); +a b pk1 pk2 pk3 +1 1 1 1 1 +2 2 2 2 2 +set @save_max_heap_table_size= @@max_heap_table_size; +set max_heap_table_size=16384; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +drop table t3; +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), +primary key(pk1, pk2) +) engine=innodb; +insert into t3 select +A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a +from t0 A, t0 B where B.a <5; +explain select * from t3 where b in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a # 100.00 NULL +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2` from `test`.`t3` semi join (`test`.`t0`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a.a+b.a from t0 a, t0 b where b.a<5); +a b pk1 pk2 +0 0 0 0 +1 1 1 1 +10 10 10 10 +11 11 11 11 +12 12 12 12 +13 13 13 13 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 5 5 5 +6 6 6 6 +7 7 7 7 +8 8 8 8 +9 9 9 9 +set join_buffer_size= @save_join_buffer_size; +set max_heap_table_size= @save_max_heap_table_size; +explain select * from t1 where a in (select b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref b b 5 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t1`.`a`) +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t1 where a in (select b from t2); +a b +1 1 +1 1 +2 2 +drop table t0, t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb; +insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1; +insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1; +alter table t2 add filler1 int; +insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size=1; +select * from t2 where filler1 in ( select a from t1); +a b c filler1 +set join_buffer_size=default; +drop table t1, t2; + +BUG#42740: crash in optimize_semijoin_nests + +create table t1 (c6 timestamp,key (c6)) engine=innodb; +create table t2 (c2 double) engine=innodb; +explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`b` = ``.`a`) +select * from t2 where b in (select a from t1); +a b +1 1 +2 1 +3 2 +4 2 +truncate table t0; +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), pk3 char(200), +primary key(pk1, pk2, pk3) +) engine=innodb; +insert into t3 select a,a, a,a,a from t0; +explain select * from t3 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2`,`test`.`t3`.`pk3` AS `pk3` from `test`.`t3` semi join (`test`.`t1`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a from t1); +a b pk1 pk2 pk3 +1 1 1 1 1 +2 2 2 2 2 +set @save_max_heap_table_size= @@max_heap_table_size; +set max_heap_table_size=16384; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +drop table t3; +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), +primary key(pk1, pk2) +) engine=innodb; +insert into t3 select +A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a +from t0 A, t0 B where B.a <5; +explain select * from t3 where b in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a # 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2` from `test`.`t3` semi join (`test`.`t0`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a.a+b.a from t0 a, t0 b where b.a<5); +a b pk1 pk2 +0 0 0 0 +1 1 1 1 +10 10 10 10 +11 11 11 11 +12 12 12 12 +13 13 13 13 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 5 5 5 +6 6 6 6 +7 7 7 7 +8 8 8 8 +9 9 9 9 +set join_buffer_size= @save_join_buffer_size; +set max_heap_table_size= @save_max_heap_table_size; +explain select * from t1 where a in (select b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref b b 5 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t1`.`a`) +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t1 where a in (select b from t2); +a b +1 1 +1 1 +2 2 +drop table t0, t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb; +insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1; +insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1; +alter table t2 add filler1 int; +insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size=1; +select * from t2 where filler1 in ( select a from t1); +a b c filler1 +set join_buffer_size=default; +drop table t1, t2; + +BUG#42740: crash in optimize_semijoin_nests + +create table t1 (c6 timestamp,key (c6)) engine=innodb; +create table t2 (c2 double) engine=innodb; +explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t2 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`b` = ``.`a`) +select * from t2 where b in (select a from t1); +a b +1 1 +2 1 +3 2 +4 2 +truncate table t0; +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), pk3 char(200), +primary key(pk1, pk2, pk3) +) engine=innodb; +insert into t3 select a,a, a,a,a from t0; +explain select * from t3 where b in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a 1 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2`,`test`.`t3`.`pk3` AS `pk3` from `test`.`t3` semi join (`test`.`t1`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a from t1); +a b pk1 pk2 pk3 +1 1 1 1 1 +2 2 2 2 2 +set @save_max_heap_table_size= @@max_heap_table_size; +set max_heap_table_size=16384; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +drop table t3; +create table t3 ( +a int, +b int, +key(b), +pk1 char(200), pk2 char(200), +primary key(pk1, pk2) +) engine=innodb; +insert into t3 select +A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a +from t0 A, t0 B where B.a <5; +explain select * from t3 where b in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 SIMPLE t3 NULL ref b b 5 .a # 100.00 Using join buffer (Batched Key Access) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`pk1` AS `pk1`,`test`.`t3`.`pk2` AS `pk2` from `test`.`t3` semi join (`test`.`t0`) where (`test`.`t3`.`b` = ``.`a`) +select * from t3 where b in (select a.a+b.a from t0 a, t0 b where b.a<5); +a b pk1 pk2 +0 0 0 0 +1 1 1 1 +10 10 10 10 +11 11 11 11 +12 12 12 12 +13 13 13 13 +2 2 2 2 +3 3 3 3 +4 4 4 4 +5 5 5 5 +6 6 6 6 +7 7 7 7 +8 8 8 8 +9 9 9 9 +set join_buffer_size= @save_join_buffer_size; +set max_heap_table_size= @save_max_heap_table_size; +explain select * from t1 where a in (select b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SIMPLE t2 NULL ref b b 5 test.t1.a 1 100.00 Using index; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t1`.`a`) +select * from t1; +a b +1 1 +1 1 +2 2 +select * from t1 where a in (select b from t2); +a b +1 1 +1 1 +2 2 +drop table t0, t1, t2, t3; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb; +insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1; +insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1; +alter table t2 add filler1 int; +insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size=1; +select * from t2 where filler1 in ( select a from t1); +a b c filler1 +set join_buffer_size=default; +drop table t1, t2; + +BUG#42740: crash in optimize_semijoin_nests + +create table t1 (c6 timestamp,key (c6)) engine=innodb; +create table t2 (c2 double) engine=innodb; +explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ref a a 5 test.t1.b 2 100.00 Using index; FirstMatch(t1) +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.32" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 1, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.11", + "prefix_cost": "28.32", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t0`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; LooseScan +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t1) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Inner hash join (t3.a = t1.kp1) (cost=519.20 rows=480) + -> Table scan on t3 (cost=1.54 rows=100) + -> Hash + -> Nested loop semijoin with duplicate removal on kp1 (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 100.00 Start temporary +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`c`.`a` = `test`.`d`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3) and (`test`.`t2`.`b` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY,Percentage NULL NULL NULL 22 9.55 Using where +1 SIMPLE t1 NULL ref Population,Country Country 12 test.t3.Country 3 3.33 Using where; LooseScan +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t3.Country 1 75.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.18" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "rows_examined_per_scan": 22, + "rows_produced_per_join": 2, + "filtered": "9.55", + "cost_info": { + "read_cost": "2.67", + "eval_cost": "0.21", + "prefix_cost": "2.88", + "data_read_per_join": "302" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Country", + "used_key_parts": [ + "Country" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 3, + "rows_produced_per_join": 0, + "filtered": "3.33", + "loosescan": true, + "cost_info": { + "read_cost": "1.57", + "eval_cost": "0.02", + "prefix_cost": "5.14", + "data_read_per_join": "37" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "0.16", + "prefix_cost": "5.19", + "data_read_per_join": "377" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; LooseScan +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 30000 3.33 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`c` = `test`.`t2`.`c`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`d` = `test`.`t2`.`d`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`e` = `test`.`t2`.`e`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f` = `test`.`t2`.`f`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`g` = `test`.`t2`.`g`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`h` = `test`.`t2`.`h`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`j` = `test`.`t2`.`j`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`k` = `test`.`t2`.`k`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 55.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index; LooseScan +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(sq2_alias1) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_nokey` = `test`.`sq2_alias1`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE it1 NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 80.00 Using index; LooseScan +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(it1) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`ot2`.`col_varchar_nokey` = `test`.`it1`.`col_varchar_key`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Start temporary +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE subquery2_t1 NULL range col_int_key col_int_key 5 NULL 16 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery2_t1.col_int_key 1 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.subquery2_t1.col_int_key 2 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table2`.`pk` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_key` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.62" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.10", + "prefix_cost": "6.91", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t3`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "7.62", + "data_read_per_join": "32" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t3`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t3`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t2`.`vc` = `test`.`t3`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.20", + "prefix_cost": "48.22", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "4.00", + "prefix_cost": "52.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Filter: (t3.col_int is null) (cost=7.85 rows=7) + -> Nested loop left join (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=5.40 rows=7) + -> Table scan on t4 (cost=0.05 rows=6) + -> Hash + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.65 rows=1) + -> Table scan on t3 (cost=0.65 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`tv`.`field1` = `test`.`t1`.`var_255_utf8`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (concat(`test`.`t2`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t2`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.35 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=1.65 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_loosescan_bka.result-pq b/mysql-test/r/subquery_sj_loosescan_bka.result-pq new file mode 100644 index 000000000..7b7a609ce --- /dev/null +++ b/mysql-test/r/subquery_sj_loosescan_bka.result-pq @@ -0,0 +1,12909 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,loosescan=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ref a a 5 test.t1.b 2 100.00 Using index; FirstMatch(t1) +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL index a a 5 NULL 4 25.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.32" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 1, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.11", + "prefix_cost": "28.32", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t0`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t0`.`a` = `test`.`t1`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 3.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; LooseScan +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t1) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Inner hash join (t3.a = t1.kp1) (cost=519.20 rows=480) + -> Table scan on t3 (cost=1.54 rows=100) + -> Hash + -> Nested loop semijoin with duplicate removal on kp1 (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 100.00 Start temporary +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`c`.`a` = `test`.`d`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3) and (`test`.`t2`.`b` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) (cost=88.33 rows=864) + -> Left hash join (ot3.a = ot2.a), (it3.a = ot2.a) (cost=88.33 rows=864) + -> Left hash join (it3.a = ot1.a), (ot2.a = ot1.a) (cost=12.10 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Hash + -> Inner hash join (no condition) (cost=2.00 rows=12) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Hash + -> Table scan on it3 (cost=0.30 rows=3) + -> Hash + -> Inner hash join (no condition) (cost=1.43 rows=9) + -> Table scan on it3 (cost=0.03 rows=3) + -> Hash + -> Table scan on ot3 (cost=0.03 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`test`.`it1`.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 Start temporary +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY,Percentage NULL NULL NULL 22 9.55 Using where +1 SIMPLE t1 NULL ref Population,Country Country 12 test.t3.Country 3 3.33 Using where; LooseScan +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t3.Country 1 75.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.18" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "rows_examined_per_scan": 22, + "rows_produced_per_join": 2, + "filtered": "9.55", + "cost_info": { + "read_cost": "2.67", + "eval_cost": "0.21", + "prefix_cost": "2.88", + "data_read_per_join": "302" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Country", + "used_key_parts": [ + "Country" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 3, + "rows_produced_per_join": 0, + "filtered": "3.33", + "loosescan": true, + "cost_info": { + "read_cost": "1.57", + "eval_cost": "0.02", + "prefix_cost": "5.14", + "data_read_per_join": "37" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "0.16", + "prefix_cost": "5.19", + "data_read_per_join": "377" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; LooseScan +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 30000 3.33 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`c` = `test`.`t2`.`c`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`d` = `test`.`t2`.`d`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`e` = `test`.`t2`.`e`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f` = `test`.`t2`.`f`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`g` = `test`.`t2`.`g`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`h` = `test`.`t2`.`h`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`j` = `test`.`t2`.`j`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`k` = `test`.`t2`.`k`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 55.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using join buffer (hash join) +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where; Start temporary +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index; LooseScan +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(sq2_alias1) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_nokey` = `test`.`sq2_alias1`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE it1 NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 80.00 Using index; LooseScan +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(it1) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`ot2`.`col_varchar_nokey` = `test`.`it1`.`col_varchar_key`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Start temporary +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join) +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE subquery2_t1 NULL range col_int_key col_int_key 5 NULL 16 100.00 Using where; Using index; Using join buffer (hash join) +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery2_t1.col_int_key 1 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.subquery2_t1.col_int_key 2 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary; Using join buffer (hash join) +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table2`.`pk` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_key` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 End temporary; Using join buffer (hash join) +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.62" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.10", + "prefix_cost": "6.91", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t3`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "7.62", + "data_read_per_join": "32" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t3`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t3`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t2`.`vc` = `test`.`t3`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "23.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "14.00", + "prefix_cost": "23.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.20", + "prefix_cost": "48.22", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "4.00", + "prefix_cost": "52.73", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.68" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.45", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "48.15", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.68", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=7.85 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=7.85 rows=7) + -> Filter: (t3.col_int is null) (cost=7.85 rows=7) + -> Nested loop left join (cost=7.85 rows=7) + -> Inner hash join (t4.col_int_key = t1.col_int_key) (cost=5.40 rows=7) + -> Table scan on t4 (cost=0.05 rows=6) + -> Hash + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.65 rows=1) + -> Table scan on t3 (cost=0.65 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`tv`.`field1` = `test`.`t1`.`var_255_utf8`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (concat(`test`.`t2`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t2`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.35 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Limit: 1 row(s) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=3.70 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=1.65 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_loosescan_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_loosescan_bka_nobnl.result-pq new file mode 100644 index 000000000..ae851bd75 --- /dev/null +++ b/mysql-test/r/subquery_sj_loosescan_bka_nobnl.result-pq @@ -0,0 +1,12899 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,loosescan=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10004 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ref a a 5 test.t1.b 2 100.00 Using index; FirstMatch(t1) +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t1.a 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 DEPENDENT SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 DEPENDENT SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,(/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where ((`test`.`s00`.`a`) = `test`.`m00`.`a`))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = `test`.`t3`.`i`) and (`test`.`t1`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using temporary; Using filesort; Start temporary +1 SIMPLE t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; End temporary +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`a` = `test`.`t11`.`a`) and (`test`.`t21`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + "test.t11.a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.00", + "eval_cost": "0.80", + "prefix_cost": "6.71", + "data_read_per_join": "128" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `test`.`t11`.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "33.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 11, + "filtered": "10.00", + "cost_info": { + "read_cost": "5.59", + "eval_cost": "1.10", + "prefix_cost": "33.50", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = `test`.`t0`.`a`)" + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index; LooseScan +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t1`.`kp1` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; LooseScan +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index; FirstMatch(t1) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`test`.`t3`.`a` = `test`.`t1`.`kp1`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=544.71 rows=480) + -> Nested loop semijoin with duplicate removal on kp1 (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + -> Filter: (t3.a = t1.kp1) (cost=27.05 rows=10) + -> Table scan on t3 (cost=27.05 rows=100) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE d NULL ALL NULL NULL NULL NULL 12 100.00 Start temporary +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (`test`.`c`.`a` = `test`.`d`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "59.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "3.01", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30)) and (`test`.`t2`.`a` is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "test.t2.a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 100, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "10.00", + "prefix_cost": "59.01", + "data_read_per_join": "40K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where ((`test`.`a`.`a`) = `test`.`t2`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`t2`.`a`) = `test`.`a`.`a`))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 DEPENDENT SUBQUERY a NULL ALL NULL NULL NULL NULL 10 10.00 Using where +2 DEPENDENT SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,(/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where ((`test`.`x`.`a`) = `test`.`a`.`a`))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t2.a 10 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` < 10) or (`test`.`t2`.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ref a a 5 test.t4.x 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `test`.`t4`.`y`) and (`test`.`t3`.`a` = `test`.`t4`.`x`) and ((`test`.`t4`.`x` < 10) or (`test`.`t4`.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3) and (`test`.`t2`.`b` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL NULL NULL NULL NULL 22 100.00 Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `test`.`it`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 NULL +1 SIMPLE it NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`test`.`it`.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 5 NULL 10 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 10.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = (`test`.`t1`.`a` + `test`.`t1`.`a`))) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = `test`.`t2_16`.`b2`) and (`test`.`t1_16`.`a1` = `test`.`t2_16`.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = `test`.`t2_512`.`b2`) and (`test`.`t1_512`.`a1` = `test`.`t2_512`.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having ((`test`.`t1_512`.`a1`) = (group_concat(`test`.`t2_512`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = `test`.`t2_513`.`b2`) and (`test`.`t1_513`.`a1` = `test`.`t2_513`.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having ((`test`.`t1_513`.`a1`) = (group_concat(`test`.`t2_513`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = `test`.`t2_1024`.`b2`) and (`test`.`t1_1024`.`a1` = `test`.`t2_1024`.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having ((`test`.`t1_1024`.`a1`) = (group_concat(`test`.`t2_1024`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = `test`.`t2_1025`.`b2`) and (`test`.`t1_1025`.`a1` = `test`.`t2_1025`.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Start temporary +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having ((`test`.`t1_1025`.`a1`) = (group_concat(`test`.`t2_1025`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +Warning 1260 Row 4 was cut by GROUP_CONCAT() +Warning 1260 Row 5 was cut by GROUP_CONCAT() +Warning 1260 Row 6 was cut by GROUP_CONCAT() +Warning 1260 Row 7 was cut by GROUP_CONCAT() +Warning 1260 Row 8 was cut by GROUP_CONCAT() +Warning 1260 Row 9 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = `test`.`it3`.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Start temporary +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Remove duplicate (ot1, ot2, ot3) rows using temporary table (weedout) + -> Nested loop left join (cost=117.35 rows=864) + -> Nested loop left join (cost=14.91 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.83 rows=12) + -> Filter: (it3.a = ot1.a) (cost=1.62 rows=3) + -> Table scan on it3 (cost=1.62 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=49.53 rows=9) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (it3.a = ot2.a) (cost=1.51 rows=3) + -> Table scan on it3 (cost=1.51 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`it1`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`it1`.`a`) and (`test`.`ot2`.`a` = `test`.`it1`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (`test`.`it2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +1 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where; Start temporary +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = `test`.`it2`.`val`) and (`test`.`it1`.`val` = `test`.`it2`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index NULL int_key 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +1 SIMPLE it2 NULL ref int_key int_key 4 test.ot1.int_nokey 2 90.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`int_key` = `test`.`ot1`.`int_nokey`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Start temporary +1 SIMPLE proj NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((`test`.`works`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`proj`.`PNUM` = `test`.`works`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = `test`.`t2`.`two`) and (`test`.`t1`.`one` = `test`.`t2`.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ref I2 I2 43 test.t1.a 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index I1 I1 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref I2 I2 43 test.t2.a 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ref I2 I2 43 test.t1.a 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 test.t3.EMPNUM 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 9 100.00 End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t3 NULL ref uid uid 5 const 1 50.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t1`.`uid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL PRIMARY,Percentage NULL NULL NULL 22 9.55 Using where +1 SIMPLE t1 NULL ref Population,Country Country 12 test.t3.Country 3 3.33 Using where; LooseScan +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 test.t3.Country 1 75.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.18" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "rows_examined_per_scan": 22, + "rows_produced_per_join": 2, + "filtered": "9.55", + "cost_info": { + "read_cost": "2.67", + "eval_cost": "0.21", + "prefix_cost": "2.88", + "data_read_per_join": "302" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Country", + "used_key_parts": [ + "Country" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 3, + "rows_produced_per_join": 0, + "filtered": "3.33", + "loosescan": true, + "cost_info": { + "read_cost": "1.57", + "eval_cost": "0.02", + "prefix_cost": "5.14", + "data_read_per_join": "37" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + "test.t3.Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.03", + "eval_cost": "0.16", + "prefix_cost": "5.19", + "data_read_per_join": "377" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`Country` = `test`.`t3`.`Country`) and (`test`.`t2`.`Code` = `test`.`t3`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 12 test.t2.CountryCode 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`Code` = `test`.`t2`.`CountryCode`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL ref a a 5 test.t2.a 1 20.00 Using where; LooseScan +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t0`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t2`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 5 NULL 30000 3.33 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ref a a 5 test.t3.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`c` = `test`.`t2`.`c`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`d` = `test`.`t2`.`d`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`e` = `test`.`t2`.`e`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f` = `test`.`t2`.`f`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`g` = `test`.`t2`.`g`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`h` = `test`.`t2`.`h`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`j` = `test`.`t2`.`j`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`k` = `test`.`t2`.`k`) and (`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t1`.`a` = `test`.`t2`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE t2 NULL ref varchar_key varchar_key 6 test.t1.varchar_nokey 2 6.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary +1 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; Start temporary; End temporary +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL ref PRIMARY,col_varchar_10_latin1_key col_varchar_10_latin1_key 43 test.t3.col_varchar_10_latin1_key 2 100.00 Using where; Start temporary +1 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +1 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 55.00 Using where; Using index; Using temporary; Using filesort; LooseScan +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 test.innr.col_varchar_key 1 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Start temporary +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 test.parent1.col_varchar_nokey 2 100.00 End temporary +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 100.00 Using temporary; Using filesort; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 6 test.t2.col_varchar_nokey 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_nokey`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE parent1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Not exists; Start temporary +2 SIMPLE parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((`test`.`grandparent1`.`col_varchar_nokey` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where; Start temporary +1 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 7 test.t4.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Start temporary +1 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 100.00 Start temporary +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = `test`.`it2`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE grandparent1 NULL ref col_int_key col_int_key 4 const 1 100.00 Using where; Not exists; Start temporary +1 SIMPLE parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 1 100.00 Using where +1 SIMPLE parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "not_exists": true, + "cost_info": { + "read_cost": "0.28", + "eval_cost": "0.11", + "prefix_cost": "0.39", + "data_read_per_join": "17" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(((is_not_null_compl(grandparent1..parent2), (found_match(grandparent1..parent2), false, true), true) and (is_not_null_compl(grandparent1..parent2), (('8' <> 3)), true)) and (is_not_null_compl(grandparent1..parent2), (`test`.`grandparent1`.`col_int_nokey` = '8'), true))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.30", + "eval_cost": "0.12", + "prefix_cost": "0.81", + "data_read_per_join": "19" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(grandparent1..parent2), (`test`.`parent1`.`col_int_key` = '8'), true)" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.31", + "eval_cost": "0.10", + "prefix_cost": "2.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it NULL ALL a NULL NULL NULL 3 40.74 Using where; Start temporary +1 SIMPLE ot NULL ref a a 7 test.it.a 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`b` = `test`.`it`.`a`) and (`test`.`ot`.`a` = `test`.`it`.`a`) and ((`test`.`it`.`a` = 'x') or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Start temporary +1 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index; LooseScan +1 SIMPLE sq2_alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(sq2_alias1) +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_nokey` = `test`.`sq2_alias1`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 100.00 Parallel execute (1 workers) +2 SIMPLE ot1 NULL index col_varchar_key col_varchar_key 10 NULL 20 100.00 Using index +2 SIMPLE it1 NULL index PRIMARY,col_varchar_key col_varchar_key 10 NULL 20 80.00 Using index; LooseScan +2 SIMPLE it2 NULL ref col_int_key col_int_key 4 test.it1.pk 1 10.00 Using where; FirstMatch(it1) +2 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it2`.`col_int_key` = `test`.`it1`.`pk`) and (`test`.`ot2`.`col_varchar_nokey` = `test`.`it1`.`col_varchar_key`) and (`test`.`it2`.`col_varchar_nokey` = `test`.`ot1`.`col_varchar_key`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index; Start temporary +1 SIMPLE outr NULL ref vc_key vc_key 7 test.child1.vc_key 3 10.00 Using where +1 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +1 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary +1 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +1 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +2 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where; Start temporary +2 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index; Start temporary +1 SIMPLE subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +1 SIMPLE subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +1 SIMPLE subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +1 SIMPLE subquery2_t1 NULL range col_int_key col_int_key 5 NULL 16 100.00 Using where; Using index +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery2_t1.col_int_key 1 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.subquery2_t1.col_int_key 2 10.00 Using where +1 SIMPLE subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; End temporary +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table2`.`pk` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_key` = `subquery2_t1`.`col_int_key`) and (`table3`.`col_int_nokey` = `subquery1_t2`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Start temporary +1 SIMPLE t2 NULL ref col_int_key col_int_key 5 test.alias3.pk 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((`test`.`inner_t1`.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 3 100.00 Using index; Start temporary; End temporary +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((`test`.`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (`test`.`view_inline_1`.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using where; Using index; Start temporary +1 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +1 PRIMARY NULL ref 7 test.subquery3_t1.col_varchar_key 2 100.00 End temporary +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +2 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; Start temporary; End temporary +2 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "cost_info": { + "read_cost": "3.04", + "eval_cost": "0.10", + "prefix_cost": "9.45", + "data_read_per_join": "16" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` = `test`.`t3`.`vc`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "10.15", + "data_read_per_join": "32" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t3`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t3`.`vc`)) semi join (`test`.`t2` `t3`) where (`test`.`t2`.`vc` = `test`.`t3`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.88" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` is not null))" + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + "test.derived2.col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.70", + "prefix_cost": "9.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 140, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.67", + "eval_cost": "14.00", + "prefix_cost": "26.88", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on((`test`.`t1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) semi join (`test`.`t2` `derived2`) where ((`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.95" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "0.20", + "prefix_cost": "57.93", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)" + } + } + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.02", + "eval_cost": "4.00", + "prefix_cost": "62.95", + "data_read_per_join": "640" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on((`test`.`t1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) semi join (`test`.`t2`) where ((`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.73" + }, + "nested_loop": [ + { + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.97", + "data_read_per_join": "64" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.67", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.73", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), (((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`alias3`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`test`.`alias2`.`col_varchar_key` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 2 100.00 Using where; Using index; LooseScan +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 6 NULL 2 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 test.t3.c1 1 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Start temporary; Full scan on NULL key +2 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; End temporary; Full scan on NULL key +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index; Using temporary; Using filesort; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +1 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=8.04 rows=7) + -> Remove duplicate t4 rows using temporary table (weedout) (cost=8.04 rows=7) + -> Nested loop inner join (cost=8.04 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.25 rows=1) + -> Filter: (t4.col_int_key = t1.col_int_key) (cost=0.54 rows=1) + -> Table scan on t4 (cost=0.54 rows=6) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Start temporary +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 16.67 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (`test`.`tv`.`field1` = `test`.`t1`.`var_255_utf8`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +3 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (concat(`test`.`t2`.`a`,''),(/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and (outer_field_is_not_null, (((concat(`test`.`t2`.`a`,'')) = `test`.`t3`.`a`) or (`test`.`t3`.`a` is null)), true)) having (outer_field_is_not_null, (`test`.`t3`.`a`), true)) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Nested loop inner join (cost=10.50 rows=54) + -> Limit: 1 row(s) (cost=4.85 rows=18) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=5.40 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_mat.result-pq b/mysql-test/r/subquery_sj_mat.result-pq new file mode 100644 index 000000000..824b430d9 --- /dev/null +++ b/mysql-test/r/subquery_sj_mat.result-pq @@ -0,0 +1,13224 @@ +set optimizer_switch='semijoin=on,materialization=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (``.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 3 100.00 Using index +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 10.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY NULL eq_ref 5 test.y.a 1 100.00 NULL +3 MATERIALIZED z NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((``.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where ((``.`a` = 2) and (`test`.`t0`.`a` = 2)) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=43.46..43.46 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.66 rows=48) + -> Nested loop inner join (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (``.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 6 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (``.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE NULL eq_ref 10 test.t2.b,test.t2.a 1 100.00 Using where +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (``.`a` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 3 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 15 test.t1.a,test.t1.b,test.t1.c 1 100.00 NULL +2 MATERIALIZED x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED y NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +2 MATERIALIZED z NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((``.`a` = `test`.`t1`.`c`) and (``.`a` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((``.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (`test`.`ot1`.`a` = ``.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 .a 1 100.00 NULL +3 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (``.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((``.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (``.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 43 .val 1 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 6 30.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = ``.`val`) and (``.`val` = ``.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +2 MATERIALIZED it2 NULL ALL int_key NULL NULL NULL 20 90.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`ot1`.`int_nokey` = ``.`int_key`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 .idObj 1 100.00 Using index +2 MATERIALIZED cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = ``.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = ``.`two`) and (`test`.`t1`.`one` = ``.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = ``.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.b 1 100.00 Using where +2 MATERIALIZED t2 NULL index I1 I1 7 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = ``.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = ``.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = ``.`f2`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 .Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 .Country,const 1 95.45 Using where +2 MATERIALIZED t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.52" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + ".Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.26", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + ".Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.52", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 20.00 Using where +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 30000 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 26 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`c` = `test`.`t1`.`c`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`d` = `test`.`t1`.`d`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`e` = `test`.`t1`.`e`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`f` = `test`.`t1`.`f`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`g` = `test`.`t1`.`g`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`h` = `test`.`t1`.`h`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`i` = `test`.`t1`.`i`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`j` = `test`.`t1`.`j`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`k` = `test`.`t1`.`k`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index k k 10 NULL 4 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED b2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = ``.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.t3.col_varchar_10_latin1_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL range PRIMARY,col_varchar_10_latin1_key PRIMARY 4 NULL 5 100.00 Using where +2 MATERIALIZED alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((``.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 .col_varchar_key 1 33.33 Using where +2 MATERIALIZED innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and (((``.`col_varchar_key` = 'a') and (`test`.`innr`.`col_varchar_key` = 'a')) or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 12 test.t4.col_int_nokey,test.t4.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ref col_int_key col_int_key 5 const 3 100.00 Using where +2 MATERIALIZED t1 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((``.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (``.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.field1 1 100.00 NULL +2 MATERIALIZED alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +2 MATERIALIZED alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((``.`field1` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((``.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL col_int_key NULL NULL NULL 11 100.00 Using where +2 MATERIALIZED parent2 NULL index col_int_key col_int_key 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED grandparent1 NULL ref col_int_key col_int_key 4 test.parent1.col_int_key 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "const", + "key": "", + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "((is_not_null_compl(), (('8' <> 3)), true) and (is_not_null_compl(), (found_match(), false, true), true))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "parent1", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "1.61", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((('8' <> 3)) and (`test`.`parent1`.`col_int_key` = '8'))" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "index", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "3.21", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(parent2), (`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`), true)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_key" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 22, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "2.20", + "prefix_cost": "10.91", + "data_read_per_join": "352" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8'))" + } + } + ] + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.grandparent1.col_varchar_key 1 100.00 NULL +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 7 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (``.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 .col_varchar_nokey 1 100.00 Using index +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL col_int_key NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED it1 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.it2.col_int_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it1`.`pk` = `test`.`it2`.`col_int_key`) and (`test`.`ot2`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`ot1`.`col_varchar_key` = ``.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using index +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((``.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`gp1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> ``.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE outr NULL ref vc_key vc_key 7 .vc_nokey 3 10.00 Using where +2 MATERIALIZED child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index +2 MATERIALIZED middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (``.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_key` = ``.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.outr.col_datetime_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +2 MATERIALIZED alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +2 MATERIALIZED alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (``.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.table1.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (``.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.alias3.pk 1 100.00 NULL +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (``.`sq2_field1` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.outer_t1.col_int_nokey 1 100.00 NULL +2 MATERIALIZED inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((``.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL eq_ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 1 100.00 NULL +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +3 MATERIALIZED NULL ALL NULL NULL NULL NULL 30 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((``.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (``.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 0.00 Using where +1 PRIMARY NULL ref 7 .subquery3_field1 2 100.00 NULL +1 PRIMARY NULL const 8 const 1 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +4 MATERIALIZED subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using index +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = ``.`subquery3_field1`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.outr.col_int_nokey 1 100.00 NULL +1 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED innr NULL ALL col_int_key NULL NULL NULL 20 23.33 Using where +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((``.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL eq_ref 4 const 1 100.00 NULL +3 MATERIALIZED t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 .c1 1 33.33 Using where; Using index +2 MATERIALIZED t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = ``.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL const 4 const 1 100.00 NULL +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index +2 MATERIALIZED t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = ``.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=11.14 rows=7) + -> Inner hash join (t4.col_int_key = ``.col_int_key) (cost=11.14 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Table scan on (cost=0.37..2.59 rows=7) + -> Materialize with deduplication (cost=4.47..6.69 rows=7) + -> Filter: (t1.col_int_key is not null) (cost=3.40 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.59 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=3.94..3.94 rows=18) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.09 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_mat_bka.result-pq b/mysql-test/r/subquery_sj_mat_bka.result-pq new file mode 100644 index 000000000..7850fc004 --- /dev/null +++ b/mysql-test/r/subquery_sj_mat_bka.result-pq @@ -0,0 +1,13226 @@ +set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (``.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 3 100.00 Using index +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 10.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (hash join) +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY NULL eq_ref 5 test.y.a 1 100.00 NULL +3 MATERIALIZED z NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((``.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join) +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where ((``.`a` = 2) and (`test`.`t0`.`a` = 2)) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=43.46..43.46 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.66 rows=48) + -> Nested loop inner join (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (``.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 6 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (``.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "using_join_buffer": "hash join", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE NULL eq_ref 10 test.t2.b,test.t2.a 1 100.00 Using where +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (``.`a` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 3 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 15 test.t1.a,test.t1.b,test.t1.c 1 100.00 NULL +2 MATERIALIZED x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED y NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +2 MATERIALIZED z NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((``.`a` = `test`.`t1`.`c`) and (``.`a` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((``.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (`test`.`ot1`.`a` = ``.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 .a 1 100.00 NULL +3 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (``.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=41.01 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=2.80 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.11 rows=4) + -> Table scan on ot2 (cost=0.11 rows=4) + -> Nested loop inner join (cost=9.93 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.03 rows=3) + -> Table scan on ot3 (cost=0.03 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((``.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (``.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index vkey vkey 7 NULL 5 100.00 Using index; Start temporary +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE t0 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t1`.`vnokey` = `test`.`t2`.`vkey`) and (`test`.`t0`.`pk` = `test`.`t1`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 43 .val 1 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 6 30.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot`.`val` = ``.`val`) and (``.`val` = ``.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +2 MATERIALIZED it2 NULL ALL int_key NULL NULL NULL 20 90.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`ot1`.`int_nokey` = ``.`int_key`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 .idObj 1 100.00 Using index +2 MATERIALIZED cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = ``.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = ``.`two`) and (`test`.`t1`.`one` = ``.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = ``.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.b 1 100.00 Using where +2 MATERIALIZED t2 NULL index I1 I1 7 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = ``.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = ``.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = ``.`f2`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 .Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 .Country,const 1 95.45 Using where +2 MATERIALIZED t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.52" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + ".Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.26", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + ".Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.52", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 20.00 Using where +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 30000 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 26 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`c` = `test`.`t1`.`c`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`d` = `test`.`t1`.`d`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`e` = `test`.`t1`.`e`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`f` = `test`.`t1`.`f`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`g` = `test`.`t1`.`g`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`h` = `test`.`t1`.`h`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`i` = `test`.`t1`.`i`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`j` = `test`.`t1`.`j`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`k` = `test`.`t1`.`k`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index k k 10 NULL 4 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (hash join) +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED b2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = ``.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.t3.col_varchar_10_latin1_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL range PRIMARY,col_varchar_10_latin1_key PRIMARY 4 NULL 5 100.00 Using where +2 MATERIALIZED alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((``.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 .col_varchar_key 1 33.33 Using where +2 MATERIALIZED innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and (((``.`col_varchar_key` = 'a') and (`test`.`innr`.`col_varchar_key` = 'a')) or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 12 test.t4.col_int_nokey,test.t4.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ref col_int_key col_int_key 5 const 3 100.00 Using where +2 MATERIALIZED t1 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((``.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (``.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.field1 1 100.00 NULL +2 MATERIALIZED alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +2 MATERIALIZED alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((``.`field1` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((``.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL col_int_key NULL NULL NULL 11 100.00 Using where +2 MATERIALIZED parent2 NULL index col_int_key col_int_key 4 NULL 1 100.00 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED grandparent1 NULL ref col_int_key col_int_key 4 test.parent1.col_int_key 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "const", + "key": "", + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "((is_not_null_compl(), (('8' <> 3)), true) and (is_not_null_compl(), (found_match(), false, true), true))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "parent1", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "1.61", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((('8' <> 3)) and (`test`.`parent1`.`col_int_key` = '8'))" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "index", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 11, + "filtered": "100.00", + "using_index": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "3.21", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_key" + ], + "attached_condition": "(is_not_null_compl(parent2), (`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`), true)" + } + }, + { + "table": { + "table_name": "grandparent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_key" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 22, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "2.20", + "prefix_cost": "10.91", + "data_read_per_join": "352" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8'))" + } + } + ] + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`parent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 Start temporary +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.grandparent1.col_varchar_key 1 100.00 NULL +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 7 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (``.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 .col_varchar_nokey 1 100.00 Using index +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED it2 NULL ALL col_int_key NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED it1 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.it2.col_int_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it1`.`pk` = `test`.`it2`.`col_int_key`) and (`test`.`ot2`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`ot1`.`col_varchar_key` = ``.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using index +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((``.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`gp1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> ``.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE outr NULL ref vc_key vc_key 7 .vc_nokey 3 10.00 Using where +2 MATERIALIZED child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index +2 MATERIALIZED middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +2 MATERIALIZED child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (``.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_key` = ``.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.outr.col_datetime_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +2 MATERIALIZED alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +2 MATERIALIZED alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (``.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.table1.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (``.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using join buffer (hash join) +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +1 SIMPLE NULL eq_ref 5 test.alias3.pk 1 100.00 NULL +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (``.`sq2_field1` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; Using join buffer (hash join) +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.outer_t1.col_int_nokey 1 100.00 NULL +2 MATERIALIZED inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((``.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (hash join) +1 PRIMARY NULL eq_ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 1 100.00 NULL +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +3 MATERIALIZED NULL ALL NULL NULL NULL NULL 30 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((``.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (``.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 0.00 Using where +1 PRIMARY NULL ref 7 .subquery3_field1 2 100.00 NULL +1 PRIMARY NULL const 8 const 1 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (hash join) +4 MATERIALIZED subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using index +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = ``.`subquery3_field1`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.outr.col_int_nokey 1 100.00 NULL +1 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +2 MATERIALIZED innr NULL ALL col_int_key NULL NULL NULL 20 23.33 Using where +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((``.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.12" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.20", + "prefix_cost": "6.12", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.03" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.52", + "eval_cost": "4.00", + "prefix_cost": "13.03", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "50.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "40.00", + "prefix_cost": "50.53", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "52.48" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "1.33", + "prefix_cost": "16.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "0.20", + "prefix_cost": "47.25", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "47.95", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.53", + "eval_cost": "4.00", + "prefix_cost": "52.48", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (hash join) +2 MATERIALIZED innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL eq_ref 4 const 1 100.00 NULL +3 MATERIALIZED t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 .c1 1 33.33 Using where; Using index +2 MATERIALIZED t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = ``.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL const 4 const 1 100.00 NULL +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index; Using join buffer (hash join) +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (hash join) +2 MATERIALIZED t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index +2 MATERIALIZED t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL col_int_key NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = ``.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=11.14 rows=7) + -> Inner hash join (t4.col_int_key = ``.col_int_key) (cost=11.14 rows=7) + -> Table scan on t4 (cost=0.35 rows=6) + -> Hash + -> Table scan on (cost=0.37..2.59 rows=7) + -> Materialize with deduplication (cost=4.47..6.69 rows=7) + -> Filter: (t1.col_int_key is not null) (cost=3.40 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=1.21 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Filter: (t3.col_int_key = t2.col_int) (cost=0.09 rows=1) + -> Table scan on t3 (cost=0.09 rows=4) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 End temporary; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Inner hash join (no condition) (cost=9.59 rows=54) + -> Table scan on t1 (cost=0.55 rows=3) + -> Hash + -> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=3.94..3.94 rows=18) + -> Left hash join (no condition) (cost=2.14 rows=18) + -> Left hash join (no condition) (cost=1.12 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Hash + -> Table scan on t1 (cost=0.28 rows=3) + -> Hash + -> Table scan on alias1 (cost=0.09 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subquery_sj_mat_bka_nobnl.result-pq b/mysql-test/r/subquery_sj_mat_bka_nobnl.result-pq new file mode 100644 index 000000000..77e85542f --- /dev/null +++ b/mysql-test/r/subquery_sj_mat_bka_nobnl.result-pq @@ -0,0 +1,13216 @@ +set optimizer_switch='batched_key_access=on,block_nested_loop=off,mrr_cost_based=off'; +set optimizer_switch='semijoin=on,materialization=on'; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch='subquery_materialization_cost_based=off'; +drop table if exists t0, t1, t2, t10, t11, t12; +create table t1 (a int not null, b int, primary key (a)); +create table t2 (a int not null, primary key (a)); +create table t3 (a int not null, b int, primary key (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) +drop table t1, t2, t3; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +create table t3 (a int, b int, index a (a)); +insert into t1 values (1,10), (2,20), (3,30), (4,40); +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t1 +select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; +insert into t2 values (2), (3), (4), (5); +insert into t3 values (10,3), (20,4), (30,5); +select * from t2 where t2.a in (select a from t1); +a +2 +3 +4 +explain select * from t2 where t2.a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (``.`a` = `test`.`t2`.`a`) +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +a +2 +3 +explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 3 100.00 Using index +2 MATERIALIZED t1 NULL index a a 10 NULL 10004 10.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) +insert into t1 values (3,31); +select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +a +2 +3 +4 +select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); +a +2 +4 +explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL index a a 10 NULL 10005 90.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((``.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t11(a int, b int); +create table t10 (pk int, a int, primary key(pk)); +insert into t10 select a,a from t0; +create table t12 like t10; +insert into t12 select * from t10; +Flattened because of dependency, t10=func(t1) +explain select * from t1 where a in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) +select * from t1 where a in (select pk from t10); +a b +0 0 +1 1 +2 2 +A confluent case of dependency +explain select * from t1 where a in (select a from t10 where pk=12); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) +select * from t1 where a in (select a from t10 where pk=12); +a b +explain select * from t1 where a in (select a from t10 where pk=9); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) +select * from t1 where a in (select a from t10 where pk=9); +a b +An empty table inside +explain select * from t1 where a in (select a from t11); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select * from t1 where a in (select a from t11); +a b +explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) +select * from t1 where a in (select pk from t10) and b in (select pk from t10); +a b +0 0 +1 1 +2 2 +flattening a nested subquery +explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); +a b +0 0 +1 1 +2 2 +flattening subquery w/ several tables +explain select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where +1 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) +subqueries within outer joins go into ON expr. +explain +select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A and B.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) and (`test`.`A`.`A` = `test`.`t1`.`A`))) where true +t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" +explain +select * from t1 left join t2 on (t2.A= t1.A and t2.A in (select pk from t10)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) and (`test`.`t2`.`A` = `test`.`t1`.`A`))) where true +we shouldn't flatten if we're going to get a join of > MAX_TABLES. +explain select * from +t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, +t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, +t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, +t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, +t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 +where +s00.a in ( +select m00.a from +t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, +t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where (`test`.`s00`.`a`,`test`.`s00`.`a` in ( (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where true ), (`test`.`s00`.`a` in on where ((`test`.`s00`.`a` = ``.`a`))))) +select * from +t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) +where t1.a < 5; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +prepare s1 from +' select * from + t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) + where t1.a < 5'; +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +execute s1; +a b a b +0 0 0 0 +1 1 1 1 +2 2 2 2 +insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; +explain select * from t1 where a in (select pk from t10 where pk<3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) +drop table t0, t1, t2; +drop table t10, t11, t12; +# +# Check that subqueries with outer joins or straight_join work for +# different permutations of const and non-const tables. (Ref. Bug#46692) +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +0 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((NULL <> 0) and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, ``.`i`) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +1 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = '2') and (`test`.`t3`.`i` = '2')) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and ('2' <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select '2' AS `i` from semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 0 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 1 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 0 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i + +EXECUTE stmt; +i +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (2); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 1 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +2 + +EXECUTE stmt; +i +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (1); +SELECT (SELECT COUNT(*) from t1) AS c1, +(SELECT COUNT(*) from t2) AS c2, +(SELECT COUNT(*) from t3) AS c3; +c1 c2 c3 +2 2 2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE EXISTS +(SELECT * FROM t2 LEFT JOIN t3 ON t2.i=t3.i +WHERE t1.i = t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +2 +PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; +EXECUTE stmt; +i +1 +2 + +EXECUTE stmt; +i +1 +2 +DEALLOCATE PREPARE stmt; +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (``.`i` = `test`.`t1`.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +1 +2 +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and (`test`.`t1`.`i` <> 0)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i <> 0); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); +i +EXPLAIN SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((``.`i` = 11) and (`test`.`t3`.`i` = 11)) +SELECT * FROM t1 WHERE (11) IN +(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); +i +INSERT INTO t3 VALUES (0); +DELETE FROM t3; +INSERT INTO t2 VALUES (0); +DELETE FROM t2; +INSERT INTO t1 VALUES (0); +DROP TABLE t1, t2, t3; +create table x1(k int primary key, d1 int, d2 int); +create table x2(k int primary key, d1 int, d2 int); +insert into x1 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30), +(40, 40, 40); +insert into x2 values +(10, 10, 10), +(20, 20, 20), +(21, 20, null), +(30, null, 30); +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is false; +k d1 d2 +40 40 40 +select * +from x1 +where (d1, d2) in (select d1, d2 +from x2) is unknown; +k d1 d2 +21 20 NULL +30 NULL 30 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +40 40 40 +select * +from x1 +where d1 in (select d1 +from x2 +where x1.d2=x2.d2) is unknown; +k d1 d2 +30 NULL 30 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is true; +k d1 d2 +10 10 10 +20 20 20 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is false; +k d1 d2 +21 20 NULL +30 NULL 30 +40 40 40 +select * +from x1 +where 1 in (select 1 +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; +k d1 d2 +select * +from x1 +where exists (select * +from x2 +where x1.d1=x2.d1 and x1.d2=x2.d2); +k d1 d2 +10 10 10 +20 20 20 +drop table x1; +drop table x2; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where +1 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where +2 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` join `test`.`t22` semi join (`test`.`t11` join `test`.`t12`) where ((`test`.`t22`.`a` = ``.`a`) and (`test`.`t21`.`a` = ``.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and (`test`.`t22`.`c` is null) and (`test`.`t11`.`a` in (255,256)) and (`test`.`t11`.`c` is null)) order by `test`.`t21`.`a` +explain format=json select * from t1 where a in (select a from t11); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.71" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.80", + "prefix_cost": "1.31", + "data_read_per_join": "128" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "a" + ], + "key_length": "4", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "6.71", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = ``.`a`) +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +drop table t1, t11, t12, t21, t22; +create table t1(a int); +insert into t1 values (0),(1); +explain +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 DEPENDENT SUBQUERY NULL eq_ref 5 test.y.a 1 100.00 NULL +3 MATERIALIZED z NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((``.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` +select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; +subq +NULL +0 +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL const 5 const 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where ((``.`a` = 2) and (`test`.`t0`.`a` = 2)) +select * from t1 where 2 in (select a from t0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from (select a from t0) x where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL +1 SIMPLE NULL eq_ref 5 func 1 100.00 Using where +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +explain format=json select * from (select a from t0) x where a in (select a from t1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.21" + }, + "nested_loop": [ + { + "table": { + "table_name": "t0", + "access_type": "ALL", + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.10", + "prefix_cost": "1.60", + "data_read_per_join": "88" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "func" + ], + "rows_examined_per_scan": 1, + "attached_condition": "(``.`a` = `test`.`t0`.`a`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "160" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; +explain select * from t3 where a in (select kp1 from t1 where kp1<20); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t1`.`kp1` < 20)) +select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +create table t4 (pk int primary key); +insert into t4 select a from t3; +explain select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +2 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where +2 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((``.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) +explain format=tree select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +EXPLAIN +-> Nested loop inner join (cost=500.54 rows=4800) + -> Filter: (t3.a is not null) (cost=10.54 rows=100) + -> Table scan on t3 (cost=10.54 rows=100) + -> Single-row index lookup on using (kp1=t3.a) + -> Materialize with deduplication (cost=43.46..43.46 rows=48) + -> Filter: (t1.kp1 is not null) (cost=38.66 rows=48) + -> Nested loop inner join (cost=38.66 rows=48) + -> Filter: ((t1.kp1 < 20) and (t1.c is not null)) (cost=21.86 rows=48) + -> Index range scan on t1 using kp1 (cost=21.86 rows=48) + -> Single-row index lookup on t4 using PRIMARY (pk=t1.c) (cost=0.25 rows=1) + +select * from t3 where a in +(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); +a +0 +1 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t1, t3, t4; +create table t1 (a int); +insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); +set session internal_tmp_mem_storage_engine='memory'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@max_heap_table_size= 16384; +# Attempt to make one test that overflows the heap table when a +# non-duplicate row is inserted and one test that overflows the +# heap table when a duplicate record is inserted. Debugging showed +# that these situations occurred with max_heap_table_size=16384 +# and optimizer_join_cache_level equals 1 and 0, respectively. +# Finally execute a test that does not overflow the heap table. +explain +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +1 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.c.a 1 100.00 NULL +2 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` join `test`.`t0` `b` join `test`.`t0` `c` semi join (`test`.`t1` `d`) where (``.`a` = `test`.`c`.`a`) +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +set @@max_heap_table_size= @save_max_heap_table_size; +set session internal_tmp_mem_storage_engine=default; +flush status; +select count(*) from t0 a, t0 b, t0 c +where c.a in (select a from t1 d); +count(*) +400 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +drop table t0, t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` > 5) or (``.`a` < 10))) +select * from t3 where a in (select a from t2); +a filler +1 filler +2 filler +drop table t0, t2, t3; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t1`.`a` as double)) +explain select * from t2 where a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (``.`a` = `test`.`t2`.`a`) +explain select * from t2 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (cast(`test`.`t2`.`a` as double) = cast(`test`.`t3`.`a` as double)) +explain select * from t1 where a in (select a from t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = cast(`test`.`t3`.`a` as date)) +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 6 test.t1.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (``.`a` = `test`.`t1`.`a`) +drop table t1; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)) charset utf8mb4; +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain format=json select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.01" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 1, + "filtered": "10.00", + "cost_info": { + "read_cost": "1.40", + "eval_cost": "0.10", + "prefix_cost": "1.50", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(((``.`a` < 10) or (``.`a` > 30)) and (``.`a` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "1.00", + "prefix_cost": "1.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": [ + "a" + ], + "key": "a", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + ".a" + ], + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "25.00", + "eval_cost": "1.00", + "prefix_cost": "41.01", + "data_read_per_join": "4K" + }, + "used_columns": [ + "a", + "b", + "filler" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t1` join `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and (`test`.`t1`.`a` = 3) and ((``.`a` < 10) or (``.`a` > 30))) +explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where (`test`.`a`.`a`,`test`.`a`.`a` in ( (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where true ), (`test`.`a`.`a` in on where ((`test`.`a`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a`,`test`.`t2`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`t2`.`a` in on where ((`test`.`t2`.`a` = ``.`a`))))) +explain select straight_join * from t2 x, t2 y +where x.a in (select straight_join a.a from t1 a, t1 b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where (`test`.`x`.`a`,`test`.`x`.`a` in ( (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where true ), (`test`.`x`.`a` in on where ((`test`.`x`.`a` = ``.`a`))))) +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .a 10 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = ``.`a`) and ((``.`a` < 10) or (``.`a` > 30))) +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE t3 NULL ref a a 5 .x 10 10.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = ``.`y`) and (`test`.`t3`.`a` = ``.`x`) and ((``.`x` < 10) or (``.`x` > 30))) +drop table t0,t1,t2,t3,t4; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where +1 SIMPLE NULL eq_ref 10 test.t2.b,test.t2.a 1 100.00 Using where +2 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((``.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (``.`a` = 3) and (`test`.`t1`.`a` = 3)) +drop table t1,t2; +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; +explain select * from t1 where (a,b) in (select a,b from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`)) +drop table t0, t1, t2; +# +# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN +# + DATETIME INDEX. +# +CREATE TABLE t1 ( +field1 varchar(255) CHARACTER SET utf8, +field2 varchar(255) CHARACTER SET utf8 +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +('time','time'), +('lpjdzvkp','lpjdzvkp'), +('dzvkpai', 'dzvkpai'); +CREATE TABLE t2 ( col_varchar varchar(10)); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t3 VALUES (22,'come','h'), +(23,'time','aaa'), +(24,'lpjdzvkp','ababa'), +(25,'d','GGDD'); +SELECT * FROM t1 WHERE (field1, field2) IN ( +SELECT table1.col_varchar_255_utf8_key AS field1, +table1.col_varchar_255_utf8_key AS field2 +FROM t3 AS table1 LEFT JOIN t2 AS table2 +ON table1.col_varchar_10_utf8_key <= +table2.col_varchar +WHERE table1.pk >= 6); +field1 field2 +time time +lpjdzvkp lpjdzvkp +DROP TABLE t1,t2,t3; +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 3 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +10.24 +22.11 +drop table t0, t1; +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.t0.a 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (``.`a` = `test`.`t0`.`a`) +select * from t0 where a in (select a from t1); +a +2008-01-01 +2008-02-02 +drop table t0, t1; +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; +explain select * from t1 where (a,b,c) in (select x.a, y.a, z.a from t2 x, t2 y, t2 z where x.b=33); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 15 test.t1.a,test.t1.b,test.t1.c 1 100.00 NULL +2 MATERIALIZED x NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED y NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED z NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((``.`a` = `test`.`t1`.`c`) and (``.`a` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`x`.`b` = 33)) +drop table t0,t1,t2; +set @save_join_buffer_size = @@join_buffer_size; +set join_buffer_size= 8192; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, filler1 binary(200), filler2 binary(200)); +insert into t1 select a, 'filler123456', 'filler123456' from t0; +insert into t1 select a+10, 'filler123456', 'filler123456' from t0; +create table t2 as select * from t1; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 values (2, 'duplicate ok', 'duplicate ok'); +insert into t1 values (18, 'duplicate ok', 'duplicate ok'); +insert into t2 values (3, 'duplicate ok', 'duplicate ok'); +insert into t2 values (19, 'duplicate ok', 'duplicate ok'); +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +insert into t1 select a+20, 'filler123456', 'filler123456' from t0; +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = ``.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) as z +from t1 ot where a in (select a from t2 it); +a mid(filler1, 1,10) z +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 duplicate 1 +18 filler1234 1 +19 filler1234 1 +2 duplicate 1 +2 filler1234 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +explain select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot.a 1 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (``.`a` = `test`.`ot`.`a`) +select +a, mid(filler1, 1,10), length(filler1)=length(filler2) +from t2 ot where a in (select a from t1 it); +a mid(filler1, 1,10) length(filler1)=length(filler2) +0 filler1234 1 +1 filler1234 1 +10 filler1234 1 +11 filler1234 1 +12 filler1234 1 +13 filler1234 1 +14 filler1234 1 +15 filler1234 1 +16 filler1234 1 +17 filler1234 1 +18 filler1234 1 +19 duplicate 1 +19 filler1234 1 +2 filler1234 1 +3 duplicate 1 +3 filler1234 1 +4 filler1234 1 +5 filler1234 1 +6 filler1234 1 +7 filler1234 1 +8 filler1234 1 +9 filler1234 1 +set @@join_buffer_size = @save_join_buffer_size; +drop table t1, t2; +create table t1 (a int, b int, key(a)); +create table t2 (a int, b int, key(a)); +create table t3 (a int, b int, key(a)); +insert into t1 select a,a from t0; +insert into t2 select a,a from t0; +insert into t3 select a,a from t0; +t2 and t3 must be use 'ref', not 'ALL': +explain select * +from t0 where a in +(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 9 test.t0.a 1 100.00 Using where +2 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index +2 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index +2 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = ``.`t2.a+t3.a`)) +drop table t0, t1,t2,t3; + +Test that neither MaterializeLookup strategy for semijoin, +nor subquery materialization is used when BLOBs are involved +(except when arguments of some functions). + +set @prefix_len = 6; +set @blob_len = 16; +set @suffix_len = @blob_len - @prefix_len; +create table t1_16 (a1 blob(16), a2 blob(16)); +create table t2_16 (b1 blob(16), b2 blob(16)); +create table t3_16 (c1 blob(16), c2 blob(16)); +insert into t1_16 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_16 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select b1 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t1_16`.`a2` = ``.`b2`) and (`test`.`t1_16`.`a1` = ``.`b1`) and (`test`.`t2_16`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_16 +where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = ``.`substring(b1,1,16)`)) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,(/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having ((`test`.`t1_16`.`a1`) = (group_concat(`test`.`t2_16`.`b1` separator ','))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where (`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having true ), (`test`.`t1_16`.`a1` in on where ((`test`.`t1_16`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_16 +where a1 in (select group_concat(b1) from t2_16 group by b2); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +create table t1 (a1 char(8), a2 char(8)) charset latin1; +create table t2 (b1 char(8), b2 char(8)) charset latin1; +create table t3 (c1 char(8), c2 char(8)) charset latin1; +insert into t1 values ('1 - 00', '2 - 00'); +insert into t1 values ('1 - 01', '2 - 01'); +insert into t1 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 01', '2 - 01'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 02', '2 - 02'); +insert into t2 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 01', '2 - 01'); +insert into t3 values ('1 - 02', '2 - 02'); +insert into t3 values ('1 - 03', '2 - 03'); +insert into t3 values ('1 - 04', '2 - 04'); +insert into t3 values ('1 - 05', '2 - 05'); +insert into t3 values ('1 - 06', '2 - 06'); +insert into t3 values ('1 - 07', '2 - 07'); +insert into t3 values ('1 - 08', '2 - 08'); +explain +select * from t1 +where concat(a1,'x') IN +(select left(a1,8) from t1_16 +where (a1, a2) IN +(select t2_16.b1, t2_16.b2 from t2_16, t2 +where t2.b2 = substring(t2_16.b2,1,6) and +t2.b1 IN (select c1 from t3 where c2 > '0'))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t1_16` join `test`.`t2_16` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) +drop table t1_16, t2_16, t3_16, t1, t2, t3; +set @blob_len = 512; +set @suffix_len = @blob_len - @prefix_len; +create table t1_512 (a1 blob(512), a2 blob(512)); +create table t2_512 (b1 blob(512), b2 blob(512)); +create table t3_512 (c1 blob(512), c2 blob(512)); +insert into t1_512 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_512 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select b1 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t1_512`.`a2` = ``.`b2`) and (`test`.`t1_512`.`a1` = ``.`b1`) and (`test`.`t2_512`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_512 +where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = ``.`substring(b1,1,512)`)) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where (`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having true ), (`test`.`t1_512`.`a1` in on where ((`test`.`t1_512`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_512 +where a1 in (select group_concat(b1) from t2_512 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_512, t2_512, t3_512; +set @blob_len = 513; +set @suffix_len = @blob_len - @prefix_len; +create table t1_513 (a1 blob(513), a2 blob(513)); +create table t2_513 (b1 blob(513), b2 blob(513)); +create table t3_513 (c1 blob(513), c2 blob(513)); +insert into t1_513 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_513 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select b1 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t1_513`.`a2` = ``.`b2`) and (`test`.`t1_513`.`a1` = ``.`b1`) and (`test`.`t2_513`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_513 +where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = ``.`substring(b1,1,513)`)) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` where (`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having true ), (`test`.`t1_513`.`a1` in on where ((`test`.`t1_513`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_513 +where a1 in (select group_concat(b1) from t2_513 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_513, t2_513, t3_513; +set @blob_len = 1024; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1024 (a1 blob(1024), a2 blob(1024)); +create table t2_1024 (b1 blob(1024), b2 blob(1024)); +create table t3_1024 (c1 blob(1024), c2 blob(1024)); +insert into t1_1024 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1024 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select b1 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t1_1024`.`a2` = ``.`b2`) and (`test`.`t1_1024`.`a1` = ``.`b1`) and (`test`.`t2_1024`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1024 +where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = ``.`substring(b1,1,1024)`)) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where (`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having true ), (`test`.`t1_1024`.`a1` in on where ((`test`.`t1_1024`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1024 +where a1 in (select group_concat(b1) from t2_1024 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1024, t2_1024, t3_1024; +set @blob_len = 1025; +set @suffix_len = @blob_len - @prefix_len; +create table t1_1025 (a1 blob(1025), a2 blob(1025)); +create table t2_1025 (b1 blob(1025), b2 blob(1025)); +create table t3_1025 (c1 blob(1025), c2 blob(1025)); +insert into t1_1025 values +(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t1_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t2_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); +insert into t3_1025 values +(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select b1 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t1_1025`.`a2` = ``.`b2`) and (`test`.`t1_1025`.`a1` = ``.`b1`) and (`test`.`t2_1025`.`b1` > '0')) +select left(a1,7), left(a2,7) +from t1_1025 +where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = ``.`substring(b1,1,1025)`)) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); +left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +set @@group_concat_max_len = 256; +explain select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where (`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having true ), (`test`.`t1_1025`.`a1` in on where ((`test`.`t1_1025`.`a1` = ``.`group_concat(b1)`))))) +select left(a1,7), left(a2,7) +from t1_1025 +where a1 in (select group_concat(b1) from t2_1025 group by b2); +left(a1,7) left(a2,7) +Warnings: +Warning 1260 Row 1 was cut by GROUP_CONCAT() +Warning 1260 Row 2 was cut by GROUP_CONCAT() +Warning 1260 Row 3 was cut by GROUP_CONCAT() +drop table t1_1025, t2_1025, t3_1025; +# +# WL#5561: Enable semi join transformation with outer join. +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +CREATE TABLE it2(a INT); +CREATE TABLE it3(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO it2 VALUES(0),(2),(4),(6); +INSERT INTO it3 VALUES(0),(3),(6); +# Test cases, Subquery Pattern 1 +# Example SQ1.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (`test`.`ot1`.`a` = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +# Example SQ1.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it3`) where (coalesce(`test`.`ot2`.`a`,0) = ``.`a`) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +# Example SQ1.3: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((``.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (`test`.`ot1`.`a` = ``.`a`)) +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +3 NULL +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +3 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 +WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL 3 +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL 3 +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot1.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL 3 +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE ot1.a IN (SELECT a FROM it3); +a a a +0 0 0 +3 NULL NULL +6 6 6 +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +3 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a +LEFT JOIN ot3 ON ot2.a=ot3.a +WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 2 +# Example SQ2.1: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# Example SQ2.2: +explain SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE NULL eq_ref 5 .a 1 100.00 NULL +3 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it2`) semi join (`test`.`it3`) where ((`test`.`ot1`.`a` = ``.`a`) and (`test`.`ot2`.`a` = ``.`a`) and (``.`a` = ``.`a`)) +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) +AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +# More test cases +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) +AND ot2.a IN (SELECT a+0 FROM it3); +a a +0 0 +6 6 +SELECT * +FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +6 6 6 +# Test cases, Subquery Pattern 3 +# Example SQ3.1: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +# Example SQ3.2: +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.3 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# Example SQ3.4 +explain SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 10 test.ot1.a,test.ot2.a 1 100.00 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (``.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`it2`.`a`))) where true +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND +(ot1.a, ot2.a) IN (SELECT it1.a, it2.a +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +# More test cases +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); +a a +0 0 +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) +AND ot2.a IN (SELECT a+0 FROM it2); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND +(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 +FROM it1 JOIN it2 ON it1.a=it2.a); +a a +0 0 +1 NULL +2 2 +3 NULL +4 4 +5 NULL +6 6 +7 NULL +EXPLAIN FORMAT=tree SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +EXPLAIN +-> Nested loop left join (cost=56.54 rows=288) + -> Nested loop left join (cost=11.70 rows=96) + -> Table scan on ot1 (cost=1.30 rows=8) + -> Nested loop inner join (cost=6.31 rows=12) + -> Single-row index lookup on using (a=ot1.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + -> Filter: (ot2.a = ot1.a) (cost=0.55 rows=4) + -> Table scan on ot2 (cost=0.55 rows=4) + -> Nested loop inner join (cost=10.41 rows=3) + -> Filter: (ot3.a = ot2.a) (cost=0.51 rows=3) + -> Table scan on ot3 (cost=0.51 rows=3) + -> Filter: (``.a = ot2.a) (cost=3.23..3.23 rows=1) + -> Single-row index lookup on using (a=ot3.a) + -> Materialize with deduplication (cost=1.10..1.10 rows=3) + -> Filter: (it3.a is not null) (cost=0.80 rows=3) + -> Table scan on it3 (cost=0.80 rows=3) + +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) +LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Test cases, Subquery Pattern 4 +# Example SQ4.1: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# Example SQ4.2: +explain SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot3.a 1 100.00 NULL +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`) where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (``.`a` = `test`.`ot3`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +# Example SQ4.3: +explain SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) semi join (`test`.`it1`) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (``.`a` = `test`.`ot2`.`a`)) +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +# Example SQ4.4: +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`)) semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +# More test cases +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +2 2 NULL +4 4 NULL +6 6 6 +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); +a a a +0 0 0 +1 NULL NULL +2 2 NULL +3 NULL NULL +4 4 NULL +5 NULL NULL +6 6 6 +7 NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) +LEFT JOIN +ot1 AS ot4 +ON ot2.a=ot4.a; +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL 2 +3 NULL NULL NULL +4 4 NULL 4 +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +SELECT * +FROM ot1 +LEFT JOIN +(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a +LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); +a a a a +0 0 0 0 +1 NULL NULL NULL +2 2 NULL NULL +3 NULL NULL NULL +4 4 NULL NULL +5 NULL NULL NULL +6 6 6 6 +7 NULL NULL NULL +DROP TABLE ot1,ot2,ot3,it1,it2,it3; +CREATE TABLE t ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +CREATE TABLE t2 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1),(1); +CREATE TABLE t4 ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO t4 VALUES (1),(1); +CREATE TABLE v ( +a INTEGER DEFAULT NULL +) ENGINE=InnoDB; +INSERT INTO v VALUES (1),(1); +explain SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.t3.a 1 100.00 NULL +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((``.`a` = `test`.`t3`.`a`))) join `test`.`t4`) on(((`test`.`t4`.`a` = 100))) semi join (`test`.`v` `it2`) where (``.`a` = `test`.`t1`.`a`) +SELECT * +FROM t AS t1 +LEFT JOIN +(t2 +LEFT JOIN t AS t3 +ON t3.a IN (SELECT a FROM t AS it) +JOIN t4 +ON t4.a=100 +) +ON TRUE +WHERE t1.a IN (SELECT * FROM v AS it2); +a a a a +1 NULL NULL NULL +DROP TABLE t,t2,t4,v; +# End of WL#5561 +# +# Bug#48868: Left outer join in subquery causes segmentation fault in +# make_join_select. +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +CREATE TABLE t2 (i INTEGER); +INSERT INTO t2 VALUES(1); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); +i +1 +DROP TABLE t1, t2, t3; + +Bug#37899: Wrongly checked optimization prerequisite caused failed +assertion. + +CREATE TABLE t1 ( +`pk` int(11), +`varchar_nokey` varchar(5) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'qk'),(2,'j'),(3,'aew'); +SELECT * +FROM t1 +WHERE varchar_nokey IN ( +SELECT +varchar_nokey +FROM +t1 +) XOR pk = 30; +pk varchar_nokey +1 qk +2 j +3 aew +drop table t1; +# +# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING +# +CREATE TABLE t1 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +) ENGINE=MyISaM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), +(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), +(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), +(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), +(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), +(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), +(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), +(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), +(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), +(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), +(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), +(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), +(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), +(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), +(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), +(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), +(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), +(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_nokey' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_nokey' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_nokey' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_nokey' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 11 +Warning 1264 Out of range value for column 'datetime_nokey' at row 11 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_nokey' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_nokey' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_nokey' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_nokey' at row 18 +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) NOT NULL, +time_key time NOT NULL, +datetime_key datetime NOT NULL, +datetime_nokey datetime NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk), +KEY time_key (time_key), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT IGNORE INTO t2 VALUES +(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), +(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_nokey' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR +WHERE +OUTR.varchar_nokey IN (SELECT +INNR . varchar_nokey AS Y +FROM t2 AS INNR +WHERE +INNR . datetime_key >= INNR . time_key OR +INNR . pk = INNR . int_nokey +) +AND OUTR . varchar_nokey <= 'w' +HAVING X > '2012-12-12'; +X +drop table t1, t2; + +Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order +with semijoin=on" + +CREATE TABLE t1 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +CREATE TABLE t2 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +); +INSERT INTO t2 VALUES +(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), +('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), +('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), +('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), +('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), +('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), +('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), +('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); +CREATE TABLE t3 ( +varchar_key varchar(1) DEFAULT NULL, +KEY varchar_key (varchar_key) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t3 VALUES +(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), +('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); +SELECT varchar_key FROM t3 +WHERE (SELECT varchar_key FROM t3 +WHERE (varchar_key,varchar_key) +IN (SELECT t1.varchar_key, t2 .varchar_key +FROM t1 RIGHT JOIN t2 ON t1.varchar_key +) +); +varchar_key +DROP TABLE t1, t2, t3; +# +# Bug#46556 Returning incorrect, empty results for some IN subqueries +# w/semijoin=on +# +CREATE TABLE t0 ( +pk INTEGER, +vkey VARCHAR(1), +vnokey VARCHAR(1), +PRIMARY KEY (pk), +KEY vkey(vkey) +) charset utf8mb4; +INSERT INTO t0 +VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); +EXPLAIN SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using where +1 SIMPLE t2 NULL ref vkey vkey 7 test.t1.vnokey 2 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` join `test`.`t0` semi join (`test`.`t0` `t2`) where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) +SELECT vkey FROM t0 WHERE pk IN +(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); +vkey +g +n +t +u +v +DROP TABLE t0; +# End of bug#46556 + +Bug#48834: Procedure with view + subquery + semijoin=on +crashes on second call. + +CREATE TABLE t1 ( t1field integer, primary key (t1field)); +CREATE TABLE t2 ( t2field integer, primary key (t2field)); +CREATE VIEW v1 AS +SELECT t1field as v1field +FROM t1 A +WHERE A.t1field IN (SELECT t1field FROM t2 ); +CREATE VIEW v2 AS +SELECT t2field as v2field +FROM t2 A +WHERE A.t2field IN (SELECT t2field FROM t2 ); +CREATE PROCEDURE p1 () +BEGIN +SELECT v1field +FROM v1 +WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); +END| +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (2),(3),(4); +CALL p1; +v1field +2 +3 +CALL p1; +v1field +2 +3 +DROP TABLE t1,t2; +DROP VIEW v1,v2; +DROP PROCEDURE p1; +# End of BUG#48834 +# +# Bug#46692 "Crash occurring on queries with nested FROM subqueries +# using materialization." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +int_key INTEGER, +KEY int_key(int_key) +); +INSERT INTO t2 VALUES (1,7),(2,2); +SELECT * FROM t1 WHERE (140, 4) IN +(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); +pk int_key +DROP TABLE t1, t2; +# +# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query +# causes crash." +# +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +int_key INTEGER, +date_key DATE, +datetime_nokey DATETIME, +varchar_nokey VARCHAR(1) +); +CREATE TABLE t2 ( +date_nokey DATE +); +CREATE TABLE t3 ( +pk INTEGER PRIMARY KEY, +int_nokey INTEGER, +date_key date, +varchar_key VARCHAR(1), +varchar_nokey VARCHAR(1), +KEY date_key (date_key) +); +SELECT date_key FROM t1 +WHERE (int_key, int_nokey) +IN (SELECT t3.int_nokey, t3.pk +FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) +WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk +) +AND (varchar_nokey <> 'f' OR NOT int_key < 7); +date_key +# +# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery +# + AND in outer query". +# +INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), +(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), +(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), +(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), +(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), +(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), +(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), +(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 2 +Warning 1264 Out of range value for column 'datetime_nokey' at row 4 +Warning 1264 Out of range value for column 'datetime_nokey' at row 5 +Warning 1264 Out of range value for column 'datetime_nokey' at row 6 +Warning 1264 Out of range value for column 'date_key' at row 7 +Warning 1264 Out of range value for column 'datetime_nokey' at row 7 +Warning 1264 Out of range value for column 'date_key' at row 8 +INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), +(2,2,'2002-09-17','h','h'); +Warnings: +Warning 1264 Out of range value for column 'date_key' at row 1 +SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey +WHERE t1.varchar_nokey +IN (SELECT varchar_nokey FROM t1 +WHERE (pk) +IN (SELECT t3.int_nokey +FROM t3 LEFT JOIN t1 ON t1.varchar_nokey +WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' + ) +); +varchar_nokey +DROP TABLE t1, t2, t3; +# +# Bug#45219 "Crash on SELECT DISTINCT query containing a +# LEFT JOIN in subquery" +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +int_nokey INTEGER NOT NULL, +datetime_key DATETIME NOT NULL, +varchar_key VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY datetime_key (datetime_key), +KEY varchar_key (varchar_key) +); +INSERT IGNORE INTO t1 VALUES +(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), +(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), +(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), +(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), +(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), +(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), +(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), +(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), +(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), +(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 1 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 8 +Warning 1264 Out of range value for column 'datetime_key' at row 12 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 20 +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), +(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), +(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), +(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), +(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), +(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), +(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), +(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), +(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), +(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 3 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 10 +Warning 1264 Out of range value for column 'datetime_key' at row 13 +Warning 1264 Out of range value for column 'datetime_key' at row 17 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); +SELECT DISTINCT datetime_key FROM t1 +WHERE (int_nokey, pk) +IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) +AND pk = 9; +datetime_key +DROP TABLE t1, t2, t3; +# +# Bug#46550 Azalea returning duplicate results for some IN subqueries +# w/ semijoin=on +# +DROP TABLE IF EXISTS t0, t1, t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +SELECT int_key +FROM t0 +WHERE varchar_nokey IN ( +SELECT t1 .varchar_key from t1 +); +int_key +7 +9 +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +7 +9 +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index +2 MATERIALIZED t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = ``.`varchar_key`) and (0 <> `test`.`t1_1`.`int_key`)) +DROP TABLE t0, t1, t2; +# End of bug#46550 + +Bug #48073 Subquery on char columns from view crashes Mysql + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'American Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM t2 +WHERE LEFT(country, 1) = "A" +); +city country_id +Algeria 2 +SELECT city, country_id +FROM t1 +WHERE city IN ( +SELECT country +FROM v1 +); +city country_id +Algeria 2 +drop table t1, t2; +drop view v1; +# End of bug#48073 + +Bug#49097 subquery with view generates wrong result with +non-prepared statement + +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 ( +city VARCHAR(50) NOT NULL, +country_id SMALLINT UNSIGNED NOT NULL +); +INSERT INTO t1 VALUES +('Batna',2), +('Bchar',2), +('Skikda',2), +('Tafuna',3), +('Algeria',2) ; +CREATE TABLE t2 ( +country_id SMALLINT UNSIGNED NOT NULL, +country VARCHAR(50) NOT NULL +); +INSERT INTO t2 VALUES +(2,'Algeria'), +(3,'XAmerican Samoa') ; +CREATE VIEW v1 AS +SELECT country_id, country +FROM t2 +WHERE LEFT(country,1) = "A" +; +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM t2 +WHERE LEFT(country,1) = "A" +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +SELECT city, country_id +FROM t1 +WHERE country_id IN ( +SELECT country_id +FROM v1 +); +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +PREPARE stmt FROM +" +SELECT city, country_id +FROM t1 +WHERE country_id IN ( + SELECT country_id + FROM v1 +); +"; +execute stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +deallocate prepare stmt; +drop table t1, t2; +drop view v1; +# End of Bug#49097 +# +# Bug#49198 Wrong result for second call of procedure +# with view in subselect. +# +CREATE TABLE t1 (t1field integer, primary key (t1field)); +CREATE TABLE t2 (t2field integer, primary key (t2field)); +CREATE TABLE t3 (t3field integer, primary key (t3field)); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +INSERT INTO t1 VALUES(1),(2); +INSERT INTO t2 VALUES(1),(2); +INSERT INTO t3 VALUES(1),(2); +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +PREPARE stmt FROM +" +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT * FROM v2) + AND t1field IN (SELECT * FROM v3) +"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t2` join `test`.`t3` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) +DROP TABLE t1, t2, t3; +DROP VIEW v2, v3; +# End of Bug#49198 +# +# Bug#48623 Multiple subqueries are optimized incorrectly +# +CREATE TABLE ot(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it1(val VARCHAR(10)) charset utf8mb4; +CREATE TABLE it2(val VARCHAR(10)) charset utf8mb4; +INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); +EXPLAIN +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.ot.val 1 100.00 NULL +1 SIMPLE NULL eq_ref 43 test.ot.val 1 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 36.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 6 30.56 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((``.`val` = `test`.`ot`.`val`) and (``.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) +SELECT * +FROM ot +WHERE ot.val IN (SELECT it1.val FROM it1 +WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') +AND ot.val IN (SELECT it2.val FROM it2 +WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); +val +aaa +eee +DROP TABLE ot; +DROP TABLE it1; +DROP TABLE it2; +# End of Bug#48623 +# +# Bug #51487 Assertion failure when semi-join flattening occurs +# for a subquery in HAVING +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,10),(2,11),(1,13); +CREATE TABLE t2 AS SELECT * FROM t1; +CREATE TABLE t3 AS SELECT * FROM t1; +SELECT COUNT(*) FROM t1 +GROUP BY t1.a +HAVING t1.a IN (SELECT t3.a FROM t3 +WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); +COUNT(*) +2 +1 +DROP TABLE t1, t2, t3; +# End of Bug#51487 +# +# BUG#38075: Wrong result: rows matching a subquery with outer join not returned +# +DROP TABLE IF EXISTS ot1, it1, it2; +CREATE TABLE it2 ( +int_key int(11) NOT NULL, +datetime_key datetime NOT NULL, +KEY int_key (int_key), +KEY datetime_key (datetime_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it2 VALUES +(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), +(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), +(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), +(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), +(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), +(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), +(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), +(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), +(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), +(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'datetime_key' at row 2 +Warning 1264 Out of range value for column 'datetime_key' at row 4 +Warning 1264 Out of range value for column 'datetime_key' at row 5 +Warning 1264 Out of range value for column 'datetime_key' at row 6 +Warning 1264 Out of range value for column 'datetime_key' at row 7 +Warning 1264 Out of range value for column 'datetime_key' at row 9 +Warning 1264 Out of range value for column 'datetime_key' at row 14 +Warning 1264 Out of range value for column 'datetime_key' at row 15 +Warning 1264 Out of range value for column 'datetime_key' at row 16 +Warning 1264 Out of range value for column 'datetime_key' at row 18 +Warning 1264 Out of range value for column 'datetime_key' at row 19 +CREATE TABLE ot1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ot1 VALUES +(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), +(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); +CREATE TABLE it1 ( +int_nokey int(11) NOT NULL, +int_key int(11) NOT NULL, +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO it1 VALUES +(9,5), (0,4); +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +int_key +0 +0 +0 +0 +0 +0 +2 +2 +3 +5 +5 +7 +7 +7 +8 +9 +9 +EXPLAIN +SELECT int_key FROM ot1 +WHERE int_nokey IN (SELECT it2.int_key +FROM it1 LEFT JOIN it2 ON it2.datetime_key); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED it1 NULL index NULL int_key 4 NULL 2 100.00 Using index +2 MATERIALIZED it2 NULL ALL int_key NULL NULL NULL 20 90.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`ot1`.`int_nokey` = ``.`int_key`) and (TIMESTAMP'0000-00-00 00:00:00' <> `test`.`it2`.`datetime_key`)) +DROP TABLE ot1, it1, it2; +# End of BUG#38075 +# +# BUG#50089: Second call of procedure with view in subselect crashes server +# +CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); +CREATE VIEW v1 AS +SELECT t1field AS v1field +FROM t1 a +WHERE a.t1field IN (SELECT t1field FROM t1); +INSERT INTO t1 VALUES(1),(2); +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +t1field +1 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +SELECT t1.t1field +FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); +t1field +1 +1 +2 +2 +EXPLAIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` `a` join `test`.`t1` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) +CREATE PROCEDURE p1() +BEGIN +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +END| +CALL p1; +t1field +1 +2 +CALL p1; +t1field +1 +2 +PREPARE stmt FROM +" +SELECT t1field +FROM t1 +WHERE t1field IN (SELECT v1field FROM v1); +"; +EXECUTE stmt; +t1field +1 +2 + +EXECUTE stmt; +t1field +1 +2 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +# End of BUG#50089 +# +# Bug#45191: Incorrectly initialized semi-join led to a wrong result. +# +CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)) charset latin1; +CREATE TABLE proj (PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)) charset latin1; +INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); +INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO staff VALUES ('E4','Don',12,'Deale'); +INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); +INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO works VALUES ('E1','P1',40); +INSERT INTO works VALUES ('E1','P2',20); +INSERT INTO works VALUES ('E1','P3',80); +INSERT INTO works VALUES ('E1','P4',20); +INSERT INTO works VALUES ('E1','P5',12); +INSERT INTO works VALUES ('E1','P6',12); +INSERT INTO works VALUES ('E2','P1',40); +INSERT INTO works VALUES ('E2','P2',80); +INSERT INTO works VALUES ('E3','P2',20); +INSERT INTO works VALUES ('E4','P2',20); +INSERT INTO works VALUES ('E4','P4',40); +INSERT INTO works VALUES ('E4','P5',80); +explain SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 NULL +1 SIMPLE NULL eq_ref 3 test.staff.EMPNUM 1 100.00 NULL +2 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`works` join `test`.`proj`) where ((``.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) +SELECT EMPNUM, EMPNAME +FROM staff +WHERE EMPNUM IN +(SELECT EMPNUM FROM works +WHERE PNUM IN +(SELECT PNUM FROM proj)); +EMPNUM EMPNAME +E1 Alice +E2 Betty +E3 Carmen +E4 Don +drop table staff,works,proj; +# End of bug#45191 +# +# BUG#36896: Server crash on SELECT FROM DUAL +# +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +res +drop table t1; + +BUG#40118 Crash when running Batched Key Access and requiring one match for each key + +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +drop table t0, t1; +# +# BUG#32665 Query with dependent subquery is too slow +# +create table t1 ( +idIndividual int primary key +); +insert into t1 values (1),(2); +create table t2 ( +idContact int primary key, +contactType int, +idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); +create table t3 ( +idAddress int primary key, +idContact int, +postalStripped varchar(100) +); +insert into t3 values (1,1, 'foo'), (2,2,'bar'); +The following must be converted to a semi-join: +explain SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN +( SELECT c.idObj FROM t3 cona +INNER JOIN t2 c ON c.idContact=cona.idContact +WHERE cona.postalStripped='T2H3B2' + ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 .idObj 1 100.00 Using index +2 MATERIALIZED cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = ``.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) +drop table t1,t2,t3; +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +SELECT * FROM t1 +WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); +one two flag +5 6 N +7 8 N +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +one two +5 6 +7 8 +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +one two test +1 2 NULL +2 3 NULL +3 4 NULL +5 6 1 +7 8 1 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +one two test +1 2 0 +2 3 NULL +3 4 0 +5 6 0 +7 8 0 +10 3 NULL +10 5 NULL +10 10 NULL +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +explain SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`two` = ``.`two`) and (`test`.`t1`.`one` = ``.`one`) and (`test`.`t2`.`flag` = 'N')) +explain SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and (outer_field_is_not_null, (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or (`test`.`t2`.`one` is null)), true) and (outer_field_is_not_null, (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or (`test`.`t2`.`two` is null)), true)) having ((outer_field_is_not_null, (`test`.`t2`.`one`), true) and (outer_field_is_not_null, (`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` +DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t1 VALUES ('a', 'aa'); +INSERT INTO t1 VALUES ('a', 'aaa'); +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE INDEX I1 ON t1 (a); +CREATE INDEX I2 ON t1 (b); +EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = ``.`a`) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); +a b +CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)) charset utf8mb4; +INSERT INTO t2 SELECT * FROM t1; +CREATE INDEX I1 ON t2 (a); +CREATE INDEX I2 ON t2 (b); +EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.b 1 100.00 Using where +2 MATERIALIZED t2 NULL index I1 I1 7 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = ``.`a`) +SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); +a b +EXPLAIN +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.b 1 100.00 Using where +2 MATERIALIZED t1 NULL index I1 I1 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = ``.`a`)) +SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); +a b +DROP TABLE t1,t2; +# +# BUG#45928 "Differing query results depending on MRR and +# engine_condition_pushdown settings" +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`time_nokey` time NOT NULL, +`varchar_key` varchar(1) NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +PRIMARY KEY (`pk`), +KEY `varchar_key` (`varchar_key`) +) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); +SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( +SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER +BY `pk` ; +G1 +DROP TABLE t1; +# +# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), +# file item.cc, line 4448" +# +DROP TABLE IF EXISTS C, BB; +CREATE TABLE C ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO C VALUES +('k'),('a'),(''),('u'),('e'),('v'),('i'), +('t'),('u'),('f'),('u'),('m'),('j'),('f'), +('v'),('j'),('g'),('e'),('h'),('z'); +CREATE TABLE BB ( +varchar_nokey varchar(1) NOT NULL +); +INSERT INTO BB VALUES ('i'),('t'); +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +SELECT varchar_nokey FROM C +WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey +FROM BB); +ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' +DROP TABLE C,BB; +# +# During work with BUG#45863 I had problems with a query that was +# optimized differently in regular and prepared mode. +# Because there was a bug in one of the selected strategies, I became +# aware of the problem. Adding an EXPLAIN query to catch this. +DROP TABLE IF EXISTS t1, t2, t3; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)) charset latin1; +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)) charset latin1; +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)) charset latin1; +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 .EMPNUM 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 .EMPNUM 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP INDEX t1_IDX ON t1; +EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +PREPARE stmt FROM "EXPLAIN SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN + (SELECT EMPNUM + FROM t3 + WHERE PNUM IN + (SELECT PNUM + FROM t2 + WHERE PTYPE = 'Design'))"; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) + +This line is only in place to help --skip_if_hypergraph diffing some more. + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where ((`test`.`t1`.`EMPNUM` = ``.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2, t3; +# +# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing +# +CREATE TABLE t1 ( +i1_key INT, +i2 INT, +i3 INT, +KEY i1_index (i1_key) +); +INSERT INTO t1 VALUES (9,1,2), (9,2,1); +CREATE TABLE t2 ( +pk INT NOT NULL, +i1 INT, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (9,1); +SELECT pk +FROM t2 +WHERE +pk IN ( +SELECT i1_key +FROM t1 +WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 +ORDER BY t1.i2 desc); +pk +9 +DROP TABLE t1,t2; +# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result +# +CREATE TABLE t1( +id INTEGER +); +INSERT INTO t1 VALUES(10),(20); +create table t2 select * from t1; +create table t3 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id +10 +20 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where true +delete from t2; +delete from t3; +INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); +insert into t2 select * from t1; +insert into t3 select * from t1; +create table t4 select * from t1; +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +explain SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t2 +WHERE 1 IN(SELECT 1 +FROM t3 +WHERE 1 IN(SELECT 1 +FROM t4))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +1 SIMPLE NULL const 4 const 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where true +SELECT * +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1 +WHERE 1 IN(SELECT 1 +FROM t1))); +id +10 +20 +30 +40 +50 +60 +70 +80 +90 +drop table t1,t2,t3,t4; +# +# Bug#53236 Segfault in DTCollation::set(DTCollation&) +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_varchar VARCHAR(1), +PRIMARY KEY (pk) +) +; +INSERT INTO t1 (col_varchar) +VALUES +('w'), +('m') +; +SELECT table1.pk +FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = +table2.col_varchar) ) +WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, +SUBQUERY1_t1.pk AS SUBQUERY1_field2 +FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 +ON (SUBQUERY1_t2.col_varchar = +SUBQUERY1_t1.col_varchar) ) ) +; +pk +drop table t1; +# +# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" +# +create table t1 (uid int, fid int); +insert into t1 values (1,1), (3,1); +create table t2 (uid int, name varchar(128)); +insert into t2 values (1, "A"), (2, "B"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values (1,3), (1,3); +create table t4 (uid int); +insert into t4 values (3); +explain select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 0.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` join `test`.`t1` semi join (`test`.`t4` join `test`.`t3`) where ((`test`.`t1`.`uid` = ``.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) +select t2.uid from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +uid +1 +drop table t1,t2,t3,t4; +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c varchar(4), +d varchar(4), +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); +EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); +pk +2 +SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); +pk +2 +DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; +INSERT INTO t1 (f1, f2) VALUES (1, 1.789); +INSERT INTO t1 (f1, f2) VALUES (13, 1.454); +INSERT INTO t1 (f1, f2) VALUES (10, 1.668); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1, 1.789); +INSERT INTO t2 VALUES (13, 1.454); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = ``.`f2`) and (`test`.`t1`.`f1` = ``.`f1`)) +SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); +COUNT(*) +2 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name), +INDEX (Population) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +EXPLAIN SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 12 .Country 1 75.00 Using where +1 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 132 .Country,const 1 95.45 Using where +2 MATERIALIZED t1 NULL range Population,Country Population 4 NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +EXPLAIN FORMAT=JSON SELECT Name FROM t2 +WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) +AND +t2.Code IN (SELECT Country FROM t3 +WHERE Language='English' AND Percentage > 10 AND +t2.Population > 100000); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.52" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t1", + "access_type": "range", + "possible_keys": [ + "Population", + "Country" + ], + "key": "Population", + "used_key_parts": [ + "Population" + ], + "key_length": "4", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.61", + "eval_cost": "0.10", + "prefix_cost": "0.71", + "data_read_per_join": "168" + }, + "used_columns": [ + "Country", + "Population" + ], + "attached_condition": "(`test`.`t1`.`Population` > 5000000)" + } + } + } + } + }, + { + "table": { + "table_name": "t2", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Population" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Code" + ], + "key_length": "12", + "ref": [ + ".Country" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "75.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.08", + "prefix_cost": "2.26", + "data_read_per_join": "180" + }, + "used_columns": [ + "Code", + "Name", + "Population" + ], + "attached_condition": "(`test`.`t2`.`Population` > 100000)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY", + "Percentage" + ], + "key": "PRIMARY", + "used_key_parts": [ + "Country", + "Language" + ], + "key_length": "132", + "ref": [ + ".Country", + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 0, + "filtered": "95.45", + "cost_info": { + "read_cost": "0.19", + "eval_cost": "0.07", + "prefix_cost": "2.52", + "data_read_per_join": "103" + }, + "used_columns": [ + "Country", + "Language", + "Percentage" + ], + "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10))" + } + } + ] + } +} +Warnings: +Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`Code` = ``.`Country`) and (`test`.`t3`.`Country` = ``.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) +DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +Code char(3) NOT NULL DEFAULT '', +Name char(52) NOT NULL DEFAULT '', +Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', +Region char(26) NOT NULL DEFAULT '', +SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', +IndepYear smallint(6) DEFAULT NULL, +Population int(11) NOT NULL DEFAULT '0', +LifeExpectancy float(3,1) DEFAULT NULL, +GNP float(10,2) DEFAULT NULL, +GNPOld float(10,2) DEFAULT NULL, +LocalName char(45) NOT NULL DEFAULT '', +GovernmentForm char(45) NOT NULL DEFAULT '', +HeadOfState char(60) DEFAULT NULL, +Capital int(11) DEFAULT NULL, +Code2 char(2) NOT NULL DEFAULT '', +PRIMARY KEY (Code) +) charset utf8mb4; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL DEFAULT '', +CountryCode char(3) NOT NULL DEFAULT '', +District char(20) NOT NULL DEFAULT '', +Population int(11) NOT NULL DEFAULT '0', +PRIMARY KEY (ID), +KEY CountryCode (CountryCode) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set names latin1; +Fill the table with test data +This must not use LooseScan: +EXPLAIN SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.Code 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((``.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) +SELECT Name FROM t1 +WHERE t1.Code IN ( +SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); +Name +Austria +Canada +China +Czech Republic +drop table t1, t2; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4); +create table t1 (a int, b int, key(a)); +insert into t1 select a,a from t0; +create table t2 (a int, b int, primary key(a)); +insert into t2 select * from t1; +Table t2, unlike table t1, should be displayed as pulled out +explain select * from t0 +where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and +t1.b=t2.b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL a NULL NULL NULL 5 100.00 Using where; Start temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 20.00 Using where +1 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary +Warnings: +Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` join `test`.`t0` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +update t1 set a=3, b=11 where a=4; +update t2 set b=11 where a=3; +select * from t0 where t0.a in (select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); +a +0 +1 +2 +3 +drop table t0, t1, t2; +CREATE TABLE t1 ( +id int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +id int(11) NOT NULL, +fid int(11) NOT NULL, +PRIMARY KEY (id)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1); +insert into t2 values(1,7503),(2,1); +explain select count(*) +from t1 +where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); +ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' +drop table t1, t2; +create table t1 (a int, b int, key (a), key (b)); +insert into t1 values (2,4),(2,4),(2,4); +select t1.a from t1 +where +t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); +a +drop table t1; +create table t1(a int,b int,key(a),key(b)); +insert into t1 values (1,1),(2,2),(3,3); +select 1 from t1 +where t1.a not in (select 1 from t1 +where t1.a in (select 1 from t1) +group by t1.b); +1 +1 +1 +drop table t1; +CREATE TABLE t1 +(EMPNUM CHAR(3) NOT NULL, +EMPNAME CHAR(20), +GRADE DECIMAL(4), +CITY CHAR(15)); +CREATE TABLE t2 +(PNUM CHAR(3) NOT NULL, +PNAME CHAR(20), +PTYPE CHAR(6), +BUDGET DECIMAL(9), +CITY CHAR(15)); +CREATE TABLE t3 +(EMPNUM CHAR(3) NOT NULL, +PNUM CHAR(3) NOT NULL, +HOURS DECIMAL(5)); +INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); +INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); +INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); +INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); +INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); +INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); +INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); +INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); +INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); +INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); +INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); +INSERT INTO t3 VALUES ('E1','P1',40); +INSERT INTO t3 VALUES ('E1','P2',20); +INSERT INTO t3 VALUES ('E1','P3',80); +INSERT INTO t3 VALUES ('E1','P4',20); +INSERT INTO t3 VALUES ('E1','P5',12); +INSERT INTO t3 VALUES ('E1','P6',12); +INSERT INTO t3 VALUES ('E2','P1',40); +INSERT INTO t3 VALUES ('E2','P2',80); +INSERT INTO t3 VALUES ('E3','P2',20); +INSERT INTO t3 VALUES ('E4','P2',20); +INSERT INTO t3 VALUES ('E4','P4',40); +INSERT INTO t3 VALUES ('E4','P5',80); +SELECT * FROM t1; +EMPNUM EMPNAME GRADE CITY +E1 Alice 12 Deale +E2 Betty 10 Vienna +E3 Carmen 13 Vienna +E4 Don 12 Deale +E5 Ed 13 Akron +CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +CREATE INDEX t1_IDX ON t1(EMPNUM); +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP INDEX t1_IDX ON t1; +SELECT EMPNAME +FROM t1 +WHERE EMPNUM IN +(SELECT EMPNUM +FROM t3 +WHERE PNUM IN +(SELECT PNUM +FROM t2 +WHERE PTYPE = 'Design')); +EMPNAME +Alice +Betty +Don +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (f1 INT NOT NULL); +CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; +SELECT * FROM v1; +a +drop view v1; +drop table t1; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int, b int); +insert into t1 values (0,0),(1,1),(2,2); +create table t2 as select * from t1; +create table t3 (pk int, a int, primary key(pk)); +insert into t3 select a,a from t0; +explain +select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where true +drop table t0, t1, t2, t3; +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; +create table t2 (id int, a int, primary key(id), key(a)) charset utf8mb4 as select a as id, a as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `a` int DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +set @a=0; +create table t3 as select * from t2 limit 0; +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select @a:=@a+1, t2.a from t2, t0; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +alter table t3 add primary key(id), add key(a); +The following must use loose index scan over t3, key a: +explain select count(a) from t2 where a in ( SELECT a FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index +1 SIMPLE NULL eq_ref 5 test.t2.a 1 100.00 NULL +2 MATERIALIZED t3 NULL index a a 5 NULL 30000 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (``.`a` = `test`.`t2`.`a`) +select count(a) from t2 where a in ( SELECT a FROM t3); +count(a) +1000 +drop table t0,t1,t2,t3; +# +# Bug#33062: subquery in stored routine cause crash +# +CREATE TABLE t1(a INT); +CREATE TABLE t2(c INT); +CREATE PROCEDURE p1(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p2(v1 int) +BEGIN +SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p3(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a IN (SELECT c FROM t2); +END +// +CREATE PROCEDURE p4(v1 int) +BEGIN +SELECT 1 +FROM +t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, +t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, +t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, +t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, +t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, +t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, +t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, +t1 t57,t1 t58,t1 t59,t1 t60 +WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); +END +// +CALL p1(1); +1 +CALL p2(1); +1 +CALL p3(1); +1 +CALL p4(1); +1 +DROP TABLE t1, t2; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +# +# Bug#48213 Materialized subselect crashes if using GEOMETRY type +# +CREATE TABLE t1 ( +pk int, +a varchar(1), +b varchar(4), +c tinyblob, +d blob, +e mediumblob, +f longblob, +g tinytext, +h text, +i mediumtext, +j longtext, +k geometry, +PRIMARY KEY (pk) +) charset utf8mb4; +INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); +EXPLAIN SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 26 test.t1.a,test.t1.b 1 100.00 NULL +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`b` = `test`.`t1`.`b`) and (``.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`c` = `test`.`t1`.`c`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`d` = `test`.`t1`.`d`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); +pk +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`e` = `test`.`t1`.`e`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`f` = `test`.`t1`.`f`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`g` = `test`.`t1`.`g`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`h` = `test`.`t1`.`h`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`i` = `test`.`t1`.`i`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`j` = `test`.`t1`.`j`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); +pk +1 +2 +EXPLAIN SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((``.`k` = `test`.`t1`.`k`) and (``.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) +SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); +pk +1 +2 +DROP TABLE t1, t2; +# End of Bug#48213 +# +# BUG#53060: LooseScan semijoin strategy does not return all rows +# +CREATE TABLE t1 (i INTEGER); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); +INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); +EXPLAIN +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +2 MATERIALIZED t2 NULL index k k 10 NULL 4 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = ``.`i`) and (`test`.`t2`.`j` > 0)) +SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); +i +1 +2 +DROP TABLE t1, t2; +# End of BUG#53060 +# +# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" +# +create table t1 (uid int, fid int, index(uid)); +insert into t1 values +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t2 (uid int primary key, name varchar(128), index(name)); +insert into t2 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +create table t3 (uid int, fid int, index(uid)); +insert into t3 values +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +create table t4 (uid int primary key, name varchar(128), index(name)); +insert into t4 values +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +explain select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +select name from t2, t1 +where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) +and t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +drop table t1,t2,t3,t4; +# +# Bug#43768 Prepared query with nested subqueries core dump on second execution +# +CREATE TABLE t1 ( +id INT PRIMARY KEY, +partner_id VARCHAR(35) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1, 'partner1'), (2, 'partner2'), +(3, 'partner3'), (4, 'partner4'); +CREATE TABLE t2 ( +id INT NOT NULL, +t1_line_id INT, +article_id VARCHAR(20), +PRIMARY KEY(id, t1_line_id) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1, 1, 'sup'), (2, 1, 'sup'), +(2, 2, 'sup'), (2, 3, 'sup'), +(2, 4, 'imp'), (3, 1, 'sup'), +(4, 1, 'sup'); +CREATE TABLE t3 ( +user_id VARCHAR(50), +article_id VARCHAR(20) NOT NULL, +PRIMARY KEY(user_id) +) charset utf8mb4; +INSERT INTO t3 VALUES('nicke', 'imp'); +EXPLAIN +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( +SELECT t2.id +FROM t2 +WHERE article_id IN ( +SELECT article_id FROM t3 +WHERE user_id = 'nicke' + ) +); +partner_id +partner2 +PREPARE stmt FROM +'EXPLAIN SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) + +EXECUTE stmt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; Start temporary +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.id 1 100.00 End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`article_id` = 'imp')) +PREPARE stmt FROM +'SELECT t1.partner_id +FROM t1 +WHERE t1.id IN ( + SELECT t2.id + FROM t2 + WHERE article_id IN ( + SELECT article_id FROM t3 + WHERE user_id = \'nicke\' + ) + )'; +EXECUTE stmt; +partner_id +partner2 + +EXECUTE stmt; +partner_id +partner2 +DROP TABLE t1,t2,t3; +# End of Bug#43768 +# +# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result +# +CREATE TABLE t1 (i INTEGER); +CREATE TABLE t2 (i INTEGER); +CREATE TABLE t3 (i INTEGER); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (6); +INSERT INTO t3 VALUES (1), (2); +explain SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = ``.`i`) +SELECT * FROM t1 WHERE (t1.i) IN +(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); +i +1 +2 +drop table t1,t2,t3; +# +# BUG#49453: re-execution of prepared statement with view +# and semijoin crashes +# +CREATE TABLE t1 (city VARCHAR(50), country_id INT); +CREATE TABLE t2 (country_id INT, country VARCHAR(50)); +INSERT INTO t1 VALUES +('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; +INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); +CREATE VIEW v1 AS +SELECT country_id as vf_country_id +FROM t2 +WHERE LEFT(country,1) = "A"; +PREPARE stmt FROM " +SELECT city, country_id +FROM t1 +WHERE country_id IN (SELECT vf_country_id FROM v1); +"; + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 + +EXECUTE stmt; +city country_id +Algeria 2 +Batna 2 +Bchar 2 +Skikda 2 +DROP TABLE t1,t2; +DROP VIEW v1; +# +# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch +# and duplicates weedout) +# +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values(1),(1); +insert into t2 values(1),(1),(1),(1); +insert into t3 values(2),(2); +explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); +a +1 +1 +drop table t1,t2,t3; +# +# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES(1),(1); +INSERT INTO t2 VALUES(1),(1); +INSERT INTO t3 VALUES(2),(2); +explain SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (``.`a` = `test`.`t1`.`a`) +SELECT * FROM t1 +WHERE t1.a IN (SELECT t2.a +FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); +a +1 +1 +DROP TABLE t1,t2,t3; +# +# BUG#52329 - Wrong result: subquery materialization, IN, +# non-null field followed by nullable +# +CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); +CREATE TABLE t2a (b1 char(8), b2 char(8)); +CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); +CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); +INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); +INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), +('1 - 11', '2 - 21'), +('1 - 12', '2 - 22'), +('1 - 12', '2 - 22'), +('1 - 13', '2 - 23'); +INSERT INTO t2b SELECT * FROM t2a; +INSERT INTO t2c SELECT * FROM t2a; +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2a WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2b WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +SELECT * FROM t1 +WHERE (a1, a2) IN ( +SELECT b1, b2 FROM t2c WHERE b1 > '0'); +a1 a2 +1 - 12 2 - 22 +DROP TABLE t1,t2a,t2b,t2c; +# End BUG#52329 +# +# Bug#45174: Incorrectly applied equality propagation caused wrong +# result on a query with a materialized semi-join. +# +CREATE TABLE t1 ( +varchar_nokey varchar(1) NOT NULL +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), +('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); +CREATE TABLE t2 ( +pk int NOT NULL, +varchar_key varchar(1) NOT NULL, +varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY varchar_key(varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), +(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), +(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); +SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +varchar_nokey +explain SELECT varchar_nokey +FROM t1 +WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey +FROM t2 +WHERE varchar_nokey < 'n' XOR pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 NULL +1 SIMPLE NULL eq_ref 12 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((``.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (``.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor (0 <> `test`.`t2`.`pk`))) +DROP TABLE t1, t2; +# End of the test for bug#45174. +# +# Bug#50019: Wrong result for IN-query with materialization +# +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(i INT); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t3(i INT); +INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +i +1 +2 +3 +4 +explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i +FROM t2 JOIN t3 +WHERE t2.i + t3.i = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.t1.i 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((``.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) +DROP TABLE t1,t2,t3; +# End of the test for bug#50019. +# +# Bug#52068: Optimizer generates invalid semijoin materialization plan +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(5), (8); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(9), (5), (1), (8); +CREATE TABLE it3(a INTEGER); +INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); +CREATE TABLE ot4(a INTEGER); +INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); +SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +a a +5 1 +5 1 +5 5 +5 7 +5 7 +8 1 +8 1 +8 5 +8 7 +8 7 +explain SELECT * FROM ot1,ot4 +WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a +FROM it2,it3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` join `test`.`ot4` semi join (`test`.`it2` join `test`.`it3`) where ((`test`.`ot4`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +DROP TABLE IF EXISTS ot1, ot4, it2, it3; +# End of the test for bug#52068. +# +# Bug#57623: subquery within before insert trigger causes crash (sj=on) +# +CREATE TABLE ot1(a INT); +CREATE TABLE ot2(a INT); +CREATE TABLE ot3(a INT); +CREATE TABLE it1(a INT); +INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +INSERT INTO ot2 VALUES(0),(2),(4),(6); +INSERT INTO ot3 VALUES(0),(3),(6); +INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); +explain SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` join `test`.`ot3` semi join (`test`.`it1`)) on(((``.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`))) where true +SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +prepare s from 'SELECT * +FROM ot1 +LEFT JOIN +(ot2 JOIN ot3 on ot2.a=ot3.a) +ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +execute s; +a a a +0 0 0 +1 NULL NULL +2 NULL NULL +3 NULL NULL +4 NULL NULL +5 NULL NULL +6 6 6 +7 NULL NULL +deallocate prepare s; +DROP TABLE ot1, ot2, ot3, it1; +# End of the test for bug#57623. +# +# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on +# +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1,1), (2,1); +EXPLAIN SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 MATERIALIZED b2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((true))) where (`test`.`t2`.`f2` = ``.`f1`) +SELECT * FROM t2 +WHERE f2 IN (SELECT t1.f1 +FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); +f1 f2 +1 1 +2 1 +DROP TABLE t1, t2; +# End of the test for bug#11766739. +# +# Bug#11766642: crash in Item_field::register_field_in_read_map with view +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +INSERT INTO t1 VALUES (0),(1),(2); +SELECT a FROM t1 WHERE a IN +(SELECT a XOR a FROM v1) +ORDER BY a; +a +0 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 +# +CREATE TABLE t1 ( +f2 varchar(1024) +); +INSERT INTO t1 VALUES ('v'),('we'); +CREATE TABLE t2 ( +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_int_key int, +col_int int +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); +CREATE TABLE t3 ( +col_int_key int, +col_int int +); +INSERT INTO t3 VALUES (4,4); +SELECT * +FROM t1 +WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 +FROM t2 AS a1 LEFT JOIN t3 AS a2 +ON a1.col_int_key = a2.col_int_key +WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); +f2 +v +we +DROP TABLE t1,t2,t3; +# +# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT +# OF ROWS WHEN JCL>=3 +# +CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); +INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); +CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); +INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); +CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); +INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); +SELECT table2.col_int_key +from t3 as table1 join t1 as table2 on table2.col_int_nokey +where table1.col_int_nokey in +( +select subquery2_t2.col_int_nokey +from t3 as subquery2_t1 +right join +t2 as subquery2_t2 +join t1 as subquery2_t3 +on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey +on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey +where subquery2_t1.col_varchar_key != table1.col_varchar_key +or subquery2_t2.pk <= table1.pk +); +col_int_key +6 +6 +DROP TABLE t1,t2,t3; +# +# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE +# +CREATE TABLE t1 (i1 int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; +INSERT INTO t2 VALUES (1, 2),(7, 3); +SELECT GRANDPARENT1.i1 +FROM t2 AS GRANDPARENT1 +WHERE GRANDPARENT1.i2 +IN ( SELECT PARENT1.i2 +FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) +WHERE +GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) +ORDER BY PARENT1.i1) +ORDER BY GRANDPARENT1.i2 ; +i1 +1 +DROP TABLE t1,t2; +# +# Bug#12640083: Same query executed as WHERE subquery gives different +# results on IN() compare +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, +col_varchar_10_latin1_key varchar(10) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), +KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) +) charset utf8mb4; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES +(1, 'a', 'a'), +(2, 'ab', 'ab'), +(3, 'abc', 'abc'), +(4, 'abcd', 'abcd'); +CREATE TABLE t2 ( +pk int NOT NULL AUTO_INCREMENT, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=Innodb; +CREATE TABLE t3 charset utf8mb4 +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; +EXPLAIN SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 43 test.t3.col_varchar_10_latin1_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL range PRIMARY,col_varchar_10_latin1_key PRIMARY 4 NULL 5 100.00 Using where +2 MATERIALIZED alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index +2 MATERIALIZED alias2 NULL index NULL col_varchar_10_latin1_key 43 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on(((0 <> `test`.`alias1`.`col_varchar_1024_utf8_key`) and (0 <> `test`.`alias2`.`col_varchar_10_latin1_key`)))) where ((``.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and (((0 <> `test`.`alias1`.`pk`) and (`test`.`alias1`.`pk` < 3)) or ((0 <> `test`.`alias1`.`pk`) and (0 <> `test`.`alias3`.`pk`)))) +SELECT * +FROM t3 +WHERE col_varchar_10_latin1_key IN ( +SELECT alias1.col_varchar_10_latin1_key +FROM t1 AS alias1 +LEFT JOIN t1 AS alias2 +JOIN t2 AS alias3 +ON alias2.col_varchar_10_latin1_key +ON alias1.col_varchar_1024_utf8_key +WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); +col_varchar_10_latin1_key +a +ab +DROP TABLE t1, t2, t3; +# End of the test for bug#12640083. +# +# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_int_key(col_int_key), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t1 VALUES +(1,7,'a','a'), +(2,0,'v','v'), +(3,9,'c','c'), +(4,3,'m','m'), +(5,2,'a','a'), +(6,1,'d','d'), +(7,8,'y','y'), +(8,6,'t','t'), +(11,7,'a','x'), +(12,0,'v','v'), +(13,9,'c','c'), +(14,3,'m','m'), +(15,2,'a','x'), +(16,1,'d','d'), +(17,8,'y','y'), +(18,6,'t','u'), +(19,6,'t','u'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY(pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 engine=innodb; +INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES +(8,7,'c'), +(11,4,'l'), +(12,7,'b'), +(13,0,'c'), +(14,2,'i'), +(15,9,'h'), +(16,4,'q'), +(17,1,'m'), +(18,9,'b'), +(19,2,'e'), +(20,1,'c'), +(21,7,'z'), +(22,4,'l'), +(23,7,'z'), +(24,0,'c'), +(25,2,'i'), +(26,9,'h'), +(27,4,'q'), +(28,0,'a'), +(29,1,'d'); +EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE outr NULL ref col_varchar_key col_varchar_key 6 .col_varchar_key 1 33.33 Using where +2 MATERIALIZED innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 6,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and (((``.`col_varchar_key` = 'a') and (`test`.`innr`.`col_varchar_key` = 'a')) or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` +SELECT outr.col_varchar_key AS x, outr.pk AS y +FROM t1 AS outr +WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) +AND outr.col_varchar_nokey < 't' +ORDER BY outr.col_varchar_key, outr.pk; +x y +a 1 +a 5 +c 3 +c 13 +DROP TABLE t1, t2; +# End of bug#12603200 +# +# Bug#12603183: Segfault in hp_movelink +# +CREATE TABLE t1 ( +col_varchar_key varchar(1) , +col_varchar_nokey varchar(1) , +KEY col_varchar_key(col_varchar_key) +) charset latin1; +INSERT INTO t1 VALUES +('i','i'), +('h','h'), +('q','q'), +('a','a'), +('v','v'), +('u','u'), +('s','s'), +('y','y'), +('z','z'), +('h','h'), +('p','p'), +('e','e'), +('i','i'), +('y','y'), +('w','w'); +CREATE TABLE t2 ( +col_varchar_nokey varchar(1) +) charset latin1; +INSERT INTO t2 VALUES +('b'); +EXPLAIN SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 .col_varchar_nokey 2 100.00 NULL +1 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) semi join (`test`.`t1` `parent1` join `test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`))) where ((`test`.`grandparent1`.`col_varchar_key` = ``.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) +WHERE (grandparent1.col_varchar_key) IN +(SELECT parent1.col_varchar_nokey +FROM t1 AS parent1 +WHERE parent1.col_varchar_key IN +(SELECT child1.col_varchar_nokey AS c1 +FROM t1 AS child1 LEFT JOIN t2 AS child2 +ON (child1.col_varchar_key > child2.col_varchar_nokey))); +col_varchar_nokey +a +e +h +h +i +i +p +q +s +u +v +w +y +y +z +DROP TABLE t1, t2; +# End of test for bug#12603183. +# +# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key(col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), +(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), +(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), +(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), +(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), +(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), +(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), +(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), +(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), +(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); +CREATE TABLE t2 ( +col_varchar_nokey VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); +explain SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using filesort +1 SIMPLE NULL eq_ref 6 test.t1.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (``.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 +SELECT col_varchar_key +FROM t1 +WHERE col_varchar_key IN (SELECT col_varchar_nokey +FROM t2) +ORDER BY col_datetime_key LIMIT 4; +col_varchar_key +v +y +v +y +DROP TABLE t1, t2; +# End of test for bug#12818569. +# +# Bug#12803439: Assert in replace_subcondition() on update query +# +CREATE TABLE t1(a INTEGER); +INSERT INTO t1 values(1), (2); +CREATE TABLE t2(a INTEGER); +INSERT INTO t2 VALUES(1), (3); +SELECT * +FROM t1 +WHERE a IN (SELECT a +FROM t2 +HAVING a IN (SELECT a +FROM t2) +) +HAVING a IN (SELECT a +FROM t2); +a +1 +DROP TABLE t1, t2; +# End of test for bug#12803439. +# +# Bug#12797534: Segfault in hp_movelink still exists +# +CREATE TABLE t1 ( +g1 VARCHAR(1) NOT NULL +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('d'), ('s'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key(col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), +(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), +(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), +(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), +(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (10); +EXPLAIN SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 7 test.t1.g1 1 100.00 Using where; Not exists +2 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk 1 100.00 Using index +2 MATERIALIZED grandparent1 NULL ref col_varchar_key col_varchar_key 6 test.parent1.col_varchar_nokey 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` anti join (`test`.`t2` `grandparent1` join `test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent2`.`pk` = `test`.`parent1`.`pk`))) on(((``.`g1` = `test`.`t1`.`g1`) and (`test`.`grandparent1`.`col_varchar_key` = `test`.`parent1`.`col_varchar_nokey`) and (`test`.`grandparent1`.`col_varchar_key` is not null))) where true +SELECT * +FROM t1 +WHERE g1 NOT IN +(SELECT grandparent1.col_varchar_nokey AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_varchar_key IN +(SELECT parent1.col_varchar_nokey AS p1 +FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) +) +AND grandparent1.col_varchar_key IS NOT NULL +); +g1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=INNODB; +INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES +(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER , +col_varchar_key VARCHAR(1) , +col_varchar_nokey VARCHAR(1) , +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES +(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t3 +SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL; +SELECT * +FROM t3 +WHERE x NOT IN +(SELECT outr.col_varchar_nokey AS x +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +(SELECT innr.col_varchar_nokey AS y +FROM t2 AS innr +WHERE innr.col_int_key IS NULL) +AND outr.col_varchar_nokey IS NOT NULL +AND NOT col_varchar_key IS NULL); +x +DROP TABLE t1, t2, t3; +# End of test for bug#12797534. +# +# Bug#12714094: Assert in optimize_semijoin_nests() +# +CREATE TABLE it ( +pk int NOT NULL, +col_varchar VARCHAR(10) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +INSERT INTO it VALUES (1, 'g'); +CREATE TABLE ot +SELECT alias1.pk AS field1 +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +; +SELECT * +FROM ot +WHERE field1 IN ( +SELECT alias1.pk +FROM it AS alias1 +LEFT JOIN it AS alias2 +ON alias1.col_varchar = alias2.col_varchar +); +field1 +1 +DROP TABLE it, ot; +# End of test for bug#12714094 +# +# Bug#12867557: Valgrind: conditional jump/move at key_cmp +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +PRIMARY KEY (pk), +KEY (col_int_key) +) AUTO_INCREMENT=10; +INSERT INTO t1 (col_int_key) VALUES (8); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_key INTEGER, +col_time_key TIME, +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_time_key) +) AUTO_INCREMENT=10; +INSERT INTO t2 (col_int_key, col_time_key) +VALUES +(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), +(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), +(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), +(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), +(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), +(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), +(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); +CREATE TABLE t0 +SELECT DISTINCT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9; +UPDATE t0 +SET g1 = g1 +WHERE g1 IN +(SELECT grandparent1.col_time_key AS g1 +FROM t2 AS grandparent1 +WHERE grandparent1.col_int_key IN +(SELECT parent1.col_int_key AS p1 +FROM t1 AS parent1) +AND grandparent1.pk > 9); +DROP TABLE t0, t1, t2; +# End of test for bug#12867557 +# +# Bug#12711441: crash in fix_after_pullout +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key, col_int_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key INT DEFAULT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t4 ( +col_int_nokey INT DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_varchar_key(col_varchar_key) +); +CREATE TABLE ts +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +; +SELECT * FROM ts WHERE field1 IN ( +SELECT alias1.col_time_key AS field1 +FROM v1 AS alias1 +RIGHT JOIN t3 AS alias2 +ON alias2.col_int_key = alias1.col_int_nokey +WHERE alias1.pk >= SOME( +SELECT SQ1_alias1.pk AS SQ1_field1 +FROM t3 AS SQ1_alias1 +INNER JOIN (t2 AS SQ1_alias2 +INNER JOIN t4 AS SQ1_alias3 +ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) +ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key +WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key +AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) +); +field1 +DROP TABLE t1, t2, t3, t4, ts; +DROP VIEW v1; +# End of test for bug#12711441. +# +# Bug#12664936: Same query executed as where subquery ... +# +CREATE TABLE t1 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +('o'), ('w'), ('m'), ('q'), +('f'), ('p'), ('j'), ('c'); +CREATE TABLE t2 ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key varchar(1), +KEY col_int_key (col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), +(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); +CREATE TABLE t4 +SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1; +EXPLAIN SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 12 test.t4.col_int_nokey,test.t4.col_varchar_key 1 100.00 NULL +2 MATERIALIZED t2 NULL ref col_int_key col_int_key 5 const 3 100.00 Using where +2 MATERIALIZED t1 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((``.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (``.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) +SELECT * +FROM t4 +WHERE (col_int_nokey, col_varchar_key) IN +(SELECT t2.col_int_nokey, t2.col_varchar_key +FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key +WHERE t2.col_int_key = 1 +); +col_int_nokey col_varchar_key +8 o +2 q +DROP TABLE t1, t2, t4; +# End of test for bug#12664936. +# +# Bug#13340270: assertion table->sort.record_pointers == __null +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key, col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(10,8,'x','x'), +(11,7,'d','d'), +(12,1,'r','r'), +(13,7,'f','f'), +(14,9,'y','y'), +(15,NULL,'u','u'), +(16,1,'m','m'), +(17,9,NULL,NULL), +(18,2,'o','o'), +(19,9,'w','w'), +(20,2,'m','m'), +(21,4,'q','q'); +CREATE TABLE t2 +SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' + +; +EXPLAIN SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.t2.field1 1 100.00 NULL +2 MATERIALIZED alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 7,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where +2 MATERIALIZED alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((``.`field1` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) +SELECT * +FROM t2 +WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 +FROM t1 AS alias1 JOIN t1 AS alias2 +ON alias2.col_int_key = alias1.pk OR +alias2.col_int_key = alias1.col_int_key +WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' +); +field1 +o +o +DROP TABLE t1, t2; +# End of test for bug#13340270. +# +# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy +# +CREATE TABLE ot1(a INTEGER); +INSERT INTO ot1 VALUES(1), (2), (3); +CREATE TABLE ot2(a INTEGER); +INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); +CREATE TABLE it1(a INTEGER); +INSERT INTO it1 VALUES(1), (3), (5), (7); +CREATE TABLE it2(a INTEGER); +INSERT INTO it2 VALUES(1), (3), (5), (7), (9); +explain SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot1.a 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +3 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` join `test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`ot2`.`a` = ``.`a`) and (``.`a` = `test`.`ot1`.`a`)) +SELECT ot1.a, ot2.a +FROM ot1, ot2 +WHERE ot1.a IN (SELECT a FROM it1) AND +ot2.a IN (SELECT a FROM it2); +a a +1 1 +3 1 +DROP TABLE ot1, ot2, it1, it2; +# End of test for bug#13335319. +# +# Bug#13334882: Assertion keypart_map failed in MyIsam function +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey INT NOT NULL, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(1,4,0), +(2,6,8), +(3,3,1), +(7,2,6), +(8,9,1), +(9,3,6), +(10,8,2), +(11,1,4), +(12,8,8), +(13,8,4), +(14,5,4); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES +(10,8,7); +CREATE TABLE t3 +SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +; +explain SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL const 5 const 1 100.00 Using where; Not exists +2 MATERIALIZED grandparent1 NULL ALL col_int_key NULL NULL NULL 11 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_int_key col_int_key 4 test.grandparent1.col_int_nokey 2 100.00 Using where +2 MATERIALIZED parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +explain format=json SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "24.82" + }, + "nested_loop": [ + { + "table": { + "table_name": "t3", + "access_type": "system", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.00", + "eval_cost": "0.10", + "prefix_cost": "0.00", + "data_read_per_join": "8" + }, + "used_columns": [ + "g1" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "const", + "key": "", + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "not_exists": true, + "attached_condition": "((is_not_null_compl(), (('8' <> 3)), true) and (is_not_null_compl(), (found_match(), false, true), true))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 11, + "rows_produced_per_join": 11, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "1.10", + "prefix_cost": "1.61", + "data_read_per_join": "176" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "((('8' <> 3)) and ((`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8')))" + } + }, + { + "table": { + "table_name": "parent1", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 22, + "filtered": "100.00", + "cost_info": { + "read_cost": "5.50", + "eval_cost": "2.20", + "prefix_cost": "9.31", + "data_read_per_join": "352" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`parent1`.`col_int_key` = '8')" + } + }, + { + "table": { + "table_name": "parent2", + "access_type": "ref", + "possible_keys": [ + "col_int_key" + ], + "key": "col_int_key", + "used_key_parts": [ + "col_int_key" + ], + "key_length": "4", + "ref": [ + "test.parent1.col_int_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 44, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "5.62", + "eval_cost": "4.40", + "prefix_cost": "19.33", + "data_read_per_join": "704" + }, + "used_columns": [ + "col_int_key" + ] + } + } + ] + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select '8' AS `g1` from anti join (`test`.`t1` `grandparent1` join `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`))) on(((``.`g1` = '8') and (`test`.`grandparent1`.`col_int_key` = '8') and (`test`.`grandparent1`.`col_int_nokey` = '8') and (`test`.`parent1`.`col_int_key` = '8') and ('8' <> 3))) where true +SELECT * FROM t3 +WHERE g1 NOT IN +(SELECT grandparent1.col_int_nokey AS g1 +FROM t1 AS grandparent1 +WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN +(SELECT parent1.col_int_key AS p1, +parent1.col_int_key AS p2 +FROM t1 AS parent1 +LEFT JOIN t2 AS parent2 +ON parent1.col_int_nokey = parent2.col_int_key +) +AND grandparent1.col_int_key <> 3 +); +g1 +DROP TABLE t1, t2, t3; +# End of test for bug#13334882. +# +# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution +# +CREATE TABLE t1 ( +col_int_nokey INT, +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +(1,'o'), +(2,'t'); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 VALUES +(1,'o'), +(4,'f'); +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE TABLE t3 LIKE t1; +INSERT INTO t3 VALUES +(1,'o'), +(4,'f'); +explain SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) +SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3); +col_varchar_nokey +o +PREPARE stmt FROM "SELECT alias1.col_varchar_nokey +FROM t1 AS alias1 +INNER JOIN v_t2 AS alias2 +ON alias2.col_int_nokey = alias1.col_int_nokey AND +'o' IN (SELECT col_varchar_nokey +FROM t3)"; +EXECUTE stmt; +col_varchar_nokey +o +DROP VIEW v_t2; +DROP TABLE t1, t2, t3; +# End of test for bug#13339643. +# +# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t1 VALUES +(10,1,7), (13,7,3), (18,0,1), (23,8,1); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=MyIsam; +INSERT INTO t2 VALUES (1,7); +EXPLAIN SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL +1 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` join `test`.`t1` `t1b` semi join (`test`.`t1`) where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +ALTER TABLE t1 ENGINE=Innodb; +ALTER TABLE t2 ENGINE=Innodb; +SELECT t1a.* +FROM t1 AS t1a +JOIN t1 AS t1b USING ( col_int_nokey ) +WHERE t1a.col_int_key IN ( +SELECT pk +FROM t2 +WHERE col_int_key IN ( +SELECT col_int_nokey +FROM t1 +) +); +pk col_int_nokey col_int_key +18 0 1 +23 8 1 +DROP TABLE t1, t2; +# End of test for bug#13424134. +# +# Bug#13414014: Extra rows in result on semijoin query with where ... +# +CREATE TABLE t1 ( +c INT, +d INT, +a VARCHAR(1), +b VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t1 VALUES +(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); +CREATE TABLE t2 ( +a VARCHAR(1), +KEY a (a) +) charset utf8mb4; +INSERT INTO t2 VALUES +('c'), (NULL), ('x'), ('q'); +explain SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE ot NULL ref a a 7 .a 2 100.00 Using index +2 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((``.`b` = ``.`a`) and (`test`.`ot`.`a` = ``.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((``.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) +SELECT * +FROM t2 AS ot +WHERE (a, a) IN +(SELECT a, b +FROM t1 AS it +WHERE it.a = 'x' OR it.c > it.d +) +; +a +q +x +DROP TABLE t1, t2; +# End of test for bug#13414014. +# +# Bug#13545215: Missing rows on nested in-subquery with materialization +# +CREATE TABLE t1 ( +col_int_key int, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t1 VALUES +(8,'x','x'), (0,'p','p'), (8,'c','c'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), +(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); +CREATE TABLE t3 ( +col_int_nokey int +); +INSERT INTO t3 VALUES (7); +explain SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.grandparent1.col_varchar_key 1 100.00 NULL +1 SIMPLE grandparent2 NULL ref col_int_key col_int_key 5 test.grandparent1.col_int_key 2 100.00 Using index +2 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where +2 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 7 test.child1.col_varchar_nokey 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` join `test`.`t1` `grandparent2` semi join (`test`.`t2` `parent1` join `test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`))) where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (``.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) +SELECT grandparent1.col_varchar_nokey +FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) +WHERE grandparent1.col_varchar_key IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE col_varchar_key IN ( +SELECT child1.col_varchar_nokey +FROM t2 AS child1 LEFT JOIN t3 AS child2 +ON child1.pk < child2.col_int_nokey +) +); +col_varchar_nokey +c +c +p +x +x +DROP TABLE t1, t2, t3; +# End of test for bug#13545215. +# +# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND +# MATERIALIZATION + SEMIJOIN ON +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4,'v','v'); +INSERT INTO t1 VALUES (62,'v','v'); +INSERT INTO t1 VALUES (7,'c','c'); +INSERT INTO t1 VALUES (1,NULL,NULL); +EXPLAIN SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +1 SIMPLE NULL eq_ref 14 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 12 NULL 4 100.00 Using index +2 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((``.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (``.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) +SELECT +alias1.col_varchar_nokey AS a1_nokey, +alias1.col_varchar_key AS a1_key, +alias2.col_varchar_nokey AS a2_nokey +FROM +t1 AS alias1, t1 AS alias2 +WHERE +(alias1.col_varchar_nokey,alias2.col_varchar_nokey) +IN +( +SELECT +sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key +FROM +t1 AS sq2_alias1, t1 AS sq2_alias2 +) +; +a1_nokey a1_key a2_nokey +c c c +c c v +c c v +v v c +v v c +v v v +v v v +v v v +v v v +DROP TABLE t1; +# +# Bug#13541406: Wrong result with loosescan on select .. where .. in +# +CREATE TABLE t1 ( +col_int_key INT NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES +(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), +(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), +(9,'e'), (5,'i'), (0,'y'), (3,'w'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_key INT NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES +(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), +(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), +(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), +(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), +(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); +# This query should never use a LooseScan strategy +explain SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 6 .col_varchar_nokey 1 100.00 Using index +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED it2 NULL ALL col_int_key NULL NULL NULL 20 100.00 NULL +2 MATERIALIZED it1 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.it2.col_int_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` join `test`.`t2` `ot2` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) where ((`test`.`it1`.`pk` = `test`.`it2`.`col_int_key`) and (`test`.`ot2`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`ot1`.`col_varchar_key` = ``.`col_varchar_nokey`)) +SELECT ot1.col_int_key AS field1 +FROM t2 AS ot1, t2 AS ot2 +WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( +SELECT it2.col_varchar_nokey, it1.col_varchar_key +FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); +field1 +1 +1 +1 +2 +6 +6 +6 +6 +6 +8 +8 +8 +8 +8 +8 +9 +DROP TABLE t1, t2; +# End of test for bug#13541406. +# +# Bug#13576391: Missing rows on select with in-subquery and +# batched-key-access=on and semijoin +# +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 engine=InnoDB; +INSERT INTO t1 VALUES +(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), +(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), +(6,'e'), (3,'i'), (6,'y'), (6,'w'); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL +) charset utf8mb4 engine=InnoDB; +INSERT INTO t2 VALUES +(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), +(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), +(1,'q'), (6,'w'), (2,'d'), (9,'e'); +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 33.33 Parallel execute (1 workers) +2 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +2 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=MyISAM; +ALTER TABLE t2 ENGINE=MyISAM; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +ALTER TABLE t1 ENGINE=Memory; +ALTER TABLE t2 ENGINE=Memory; +explain SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort +1 SIMPLE it NULL ref col_varchar_key col_varchar_key 6 test.ot.col_varchar_nokey 2 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` +SELECT col_varchar_nokey +FROM t2 AS ot +WHERE col_varchar_nokey IN ( +SELECT col_varchar_key +FROM t1 AS it +WHERE it.col_int_nokey <= it.col_int_nokey +AND NOT ot.col_int_nokey < 2 +) +ORDER BY col_varchar_nokey; +col_varchar_nokey +c +e +p +s +v +w +y +DROP TABLE t1, t2; +# End of test for bug#13576391. +# +# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" +# +CREATE TABLE t1 ( +id INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (100,'m','m'), +(200,'b','b'), (300,'x','x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('b','b'); +CREATE TABLE t3 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY (col_varchar_key) +) charset utf8mb4; +INSERT INTO t3 VALUES ('k','k'); +EXPLAIN SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t2 NULL index col_varchar_key col_varchar_key 7 NULL 1 100.00 Using index +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED t3 NULL ref col_varchar_key col_varchar_key 7 test.t2.col_varchar_key 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`))) where ((``.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`gp1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> ``.`col_varchar_nokey`)) +SELECT gp1.id +FROM t1 AS gp1 JOIN t3 AS gp2 +ON gp2.col_varchar_key <> gp1.col_varchar_nokey +WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) +IN ( +SELECT col_varchar_nokey, col_varchar_nokey +FROM t1 +WHERE col_varchar_nokey +IN ( SELECT col_varchar_key +FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) +) +; +id +200 +DROP TABLE t1,t2,t3; +# +# Bug #13596176: Missing row on select with nested in clause when +# matr=on and bnl=off + MyISAM +# +CREATE TABLE t1 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +vc_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t1 VALUES +(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), +(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), +(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), +(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), +(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); +CREATE TABLE t2 ( +int_key int DEFAULT NULL, +vc_key varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY vc_key (vc_key, int_key) +) charset utf8mb4 ENGINE=MyISAM; +INSERT INTO t2 VALUES (8,'g'); +explain SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +1 SIMPLE outr NULL ref vc_key vc_key 7 .vc_nokey 3 10.00 Using where +2 MATERIALIZED child1 NULL index int_key,vc_key vc_key 12 NULL 1 100.00 Using where; Using index +2 MATERIALIZED middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where +2 MATERIALIZED child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t1` `middle` join `test`.`t2` `child1` join `test`.`t1` `child2`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (``.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_nokey` = ``.`vc_nokey`) and (`test`.`outr`.`vc_key` = ``.`vc_nokey`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) +SELECT vc_key +FROM t1 as outr +WHERE (vc_nokey, vc_key ) IN +(SELECT vc_nokey, vc_nokey +FROM t1 middle +WHERE vc_nokey IN +(SELECT child1.vc_key +FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) +) +); +vc_key +g +DROP TABLE t1, t2; +# End of test for bug#13596176. +# +# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS +# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO +# ROWS + INDEX DOES NOT RETURN NULL +# +CREATE TABLE t1 ( +pk int(11) PRIMARY KEY, +int_key int(11), +KEY int_key (int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); +MIN(int_key) +NULL +SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); +MIN(int_key) +0 +SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; +MIN(pk) +NULL +DROP TABLE t1; +# BUG#13726217: Crash in Item_ident::fix_after_pullout() +CREATE TABLE t1(a INTEGER) engine=innodb; +INSERT INTO t1 VALUES (0); +SELECT 0 +FROM t1 +WHERE 0 IN +(SELECT 0 +FROM t1 +WHERE 0 LIKE +(SELECT elt(a, 0) AS b +FROM t1 +GROUP BY a +HAVING b +) +); +0 +DROP TABLE t1; +# End of test for bug#13726217. +# BUG#13773979: Missing rows on second execution of prepared statement +CREATE TABLE t1 ( +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1) +); +INSERT INTO t1 VALUES +(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), +(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +); +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +prepare stmt FROM "SELECT * +FROM t1 +WHERE col_int_key IN ( +SELECT alias1.col_int_nokey AS field1 +FROM v1 AS alias1 +WHERE alias1.col_varchar_key < 'v' +)"; +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +execute stmt; +col_int_nokey col_int_key col_varchar_key +1 7 v +2 2 i +4 9 l +7 0 s +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; +# End of test for bug#13773979. +# +# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN +# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER +# +CREATE TABLE t1 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); +INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); +CREATE TABLE t2 ( +col_int_key INT(11) NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SET @old_depth=@@optimizer_search_depth; +SET optimizer_search_depth=4; +EXPLAIN SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.outr.col_datetime_key 1 100.00 NULL +2 MATERIALIZED alias1 NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index +2 MATERIALIZED alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 6 test.alias4.col_varchar_key 1 100.00 Using where; Using index +2 MATERIALIZED alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (``.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) +SELECT col_datetime_key +FROM t1 as outr +WHERE col_datetime_key IN ( +SELECT alias1.col_datetime_key +FROM t1 AS alias1 +LEFT JOIN t1 as alias3 +STRAIGHT_JOIN ( t2 AS alias4 +JOIN t1 AS alias5 +ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) +ON alias5.col_int_key < alias4.col_int_key +ON alias5.col_varchar_key = alias4.col_varchar_key +); +col_datetime_key +2002-02-13 17:30:06 +2008-09-27 00:34:58 +DROP TABLE t1,t2; +SET @@optimizer_search_depth=@old_depth; +# +# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT +# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN +# +CREATE TABLE t1 ( +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t1 VALUES (8,'x'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES ('x'), ('y'); +explain SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +2 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having false +SELECT MIN(col_int_key) +FROM t1 as t1_outer +HAVING (1, 2) IN ( +SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) +FROM t1 as t1_inner JOIN t2 +ON t2.col_varchar_key = t1_inner.col_varchar_key +); +MIN(col_int_key) +DROP TABLE t1,t2; +# Bug#13838810: Segfault in evaluate_null_complemented_join_record +CREATE TABLE t1 ( +pk int NOT NULL, +col_int_nokey int DEFAULT NULL, +col_int_key int DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,NULL,8,'x'); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 ( +pk int NOT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES +(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); +EXPLAIN SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 NULL +1 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where +1 SIMPLE NULL eq_ref 7 test.table1.col_varchar_nokey 1 100.00 NULL +2 MATERIALIZED subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED subquery3_t1 NULL ref col_varchar_key col_varchar_key 7 test.subquery3_t2.col_varchar_key 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` join `test`.`t1` `table3` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`)) on(((`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (``.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where true +SELECT table1.pk,table2.pk, table3.pk +FROM t2 AS table1 +LEFT JOIN t1 AS table2 +LEFT JOIN t1 AS table3 +ON table3.col_int_key = table2.col_int_key +ON table3.pk = table2.col_int_nokey AND +table1.col_varchar_nokey IN ( +SELECT subquery3_t1.col_varchar_nokey +FROM t3 AS subquery3_t1 +LEFT JOIN t1 AS subquery3_t2 +ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key +WHERE subquery3_t2.col_int_nokey <> 9 +) +; +pk pk pk +1 NULL NULL +DROP TABLE t1, t2, t3; +Extra test case for specific code coverage +CREATE TABLE t1(pk INTEGER); +INSERT INTO t1 VALUES(1), (2); +explain SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.ot2.pk 1 100.00 Using where +2 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (``.`pk` = `test`.`ot1`.`pk`))) where true +SELECT * +FROM t1 AS ot1 LEFT JOIN t1 AS ot2 +ON ot1.pk=ot2.pk AND +ot2.pk IN +(SELECT it1.pk +FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); +pk pk +1 1 +2 2 +DROP TABLE t1; +# End of test for bug#13838810. +# +# Bug#13845930: Segfault in st_join_table::and_with_condition +# +CREATE TABLE t1 ( +col_int INTEGER +); +CREATE TABLE t2 ( +col_varchar_1 VARCHAR(1), +col_varchar_2 VARCHAR(1) +); +INSERT INTO t2 VALUES ('x','x'), ('c','c'); +PREPARE stmt FROM ' +SELECT alias2.col_varchar_2 AS field1 +FROM t2 AS alias1 + JOIN + (t2 AS alias2 + LEFT JOIN t2 AS alias3 + ON (8, 92) IN + (SELECT sq1_alias1.col_int, + sq1_alias2.col_int + FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 + ) + ) + ON alias3.col_varchar_1 = alias2.col_varchar_2 +'; +EXECUTE stmt; +field1 + +EXECUTE stmt; +field1 +DEALLOCATE prepare stmt; +DROP TABLE t1, t2; +# End of test for bug#13845930. +# +# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' +# in ha_innobase::index_read +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t1 ( +col_int_key, col_int_nokey, +col_varchar_key, col_varchar_nokey +) VALUES +(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), +(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), +(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), +(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), +(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); +CREATE TABLE t2 ( +pk INT AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT, +PRIMARY KEY (pk), +KEY (col_int_key) +) charset utf8mb4 AUTO_INCREMENT=10 ENGINE=INNODB; +INSERT INTO t2 (col_int_key, col_int_nokey) VALUES +(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), +(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), +(NULL, 6), (0, 2), (NULL, 9), (8, 6); +CREATE TABLE t3 ( +pk INT AUTO_INCREMENT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key) +) charset utf8mb4 ENGINE=INNODB; +INSERT INTO t3 (col_varchar_key) VALUES +('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), +('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); +CREATE VIEW v1 AS +SELECT table2.col_varchar_nokey AS field1 +FROM t2 AS table1 +INNER JOIN (t1 AS table2 +STRAIGHT_JOIN t2 AS table3 +ON table3.col_int_key = table2.pk AND +table3.col_int_nokey = ANY +(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 +FROM t2 AS subquery1_t1 +RIGHT OUTER JOIN t1 AS subquery1_t2 +INNER JOIN t1 AS subquery1_t3 +ON subquery1_t3.col_int_key = subquery1_t2.pk +ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey +WHERE subquery1_t1.pk > 1 +) +) +ON table3.col_int_key IN +(SELECT subquery2_t1.col_int_key AS subquery2_field1 +FROM t2 AS subquery2_t1 +RIGHT OUTER JOIN t3 AS subquery2_t2 +LEFT OUTER JOIN t1 AS subquery2_t3 +ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key +ON subquery2_t3.pk = subquery2_t2.pk +) +; +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index +1 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 NULL +1 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where +1 SIMPLE NULL eq_ref 5 test.table3.col_int_nokey 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.table2.pk 1 100.00 NULL +4 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where +4 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where +4 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 100.00 Using where; Using index +3 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where +3 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` join `test`.`t1` `table2` straight_join `test`.`t2` `table3` semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) where ((`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`table3`.`col_int_key` = `table2`.`pk`) and (``.`subquery2_field1` = `table2`.`pk`) and (``.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) +SELECT * FROM v1; +field1 +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +v +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# End of test for bug#13855925. +# +# Bug#13897959: Segfault in setup_semijoin_dups_elimination() +# +CREATE TABLE t1 ( +col_datetime_key DATETIME DEFAULT NULL, +KEY col_datetime_key (col_datetime_key) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES +('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), +('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), +('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); +CREATE TABLE t2 ( +col_date_nokey date DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key(col_varchar_key) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); +SELECT grandparent1.col_varchar_nokey +FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) +WHERE grandparent1.col_varchar_nokey IN ( +SELECT col_varchar_nokey +FROM t2 AS parent1 +WHERE parent1.col_time_key > grandparent1.col_date_nokey +); +col_varchar_nokey +DROP TABLE t1, t2; +# End of test for bug#13897959. +# +# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN +# BEST_EXTENSION_BY_LIMITED_SEARCH +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (26,6,NULL,'f','f'); +INSERT INTO t1 VALUES (29,6,8,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (1,2,4,'v','v'); +INSERT INTO t2 VALUES (2,150,62,'v','v'); +INSERT INTO t2 VALUES (5,5,0,'x','x'); +INSERT INTO t2 VALUES (6,3,7,'i','i'); +INSERT INTO t2 VALUES (7,1,7,'e','e'); +CREATE VIEW view_c AS SELECT * FROM t2; +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary; End temporary +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index +1 SIMPLE NULL eq_ref 5 test.alias3.pk 1 100.00 NULL +3 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +3 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (``.`sq2_field1` = `test`.`alias3`.`pk`)) +PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +'; +EXECUTE prep_stmt_7430; +field1 +NULL +EXECUTE prep_stmt_7430; +field1 +NULL +EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 +FROM t1 AS alias1 +RIGHT JOIN t2 AS alias2 +INNER JOIN t1 AS alias3 +ON (alias3.col_varchar_key = alias2.col_varchar_key ) +ON ( "v" ) IN ( +SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 +FROM t1 AS sq1_alias1 +) +WHERE alias3.pk IN ( +SELECT sq2_alias1.col_int_key AS sq2_field1 +FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) +WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key +AND sq2_alias1.col_varchar_key < "l" + ) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Start temporary +1 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 7 test.alias3.col_varchar_key 2 100.00 Using index +1 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +1 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE alias1 NULL index NULL col_varchar_key 12 NULL 2 100.00 Using index; End temporary +Warnings: +Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v'))) semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) +DROP TABLE t1,t2; +DROP VIEW view_c; +# +# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD +# ON SECOND EXEC OF PREP STMT +# +CREATE TABLE t1 ( +pk INT, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key (col_varchar_key) +); +CREATE VIEW view_b AS SELECT * FROM t1; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +ALTER TABLE t1 DROP INDEX col_varchar_key; +PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +'; +EXECUTE prep_stmt_20421; +field1 +EXECUTE prep_stmt_20421; +field1 +EXPLAIN SELECT alias2.col_varchar_nokey AS field1 +FROM t1 AS alias1 +INNER JOIN t1 AS alias2 +ON (alias1.col_varchar_key = alias2.col_varchar_nokey +AND ( alias1.col_int_key ) IN ( +SELECT t1.col_int_nokey +FROM t1 +) +) +WHERE alias1.col_varchar_key IN ( +SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 +FROM view_b AS sq2_alias1 +INNER JOIN t1 AS sq2_alias2 +ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) +WHERE sq2_alias1.pk > alias2.pk +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 +Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` join `test`.`t1` `alias2` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`)) +DROP TABLE t1; +DROP VIEW view_b; +# +# Bug#13907277: Segfault in evaluate_null_complemented_join_record +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_nokey VARCHAR(1), +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1, 'x', 'x'); +CREATE TABLE t2 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1, 6, 5, 'r'); +explain SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.outer_t1.col_int_nokey 1 100.00 NULL +2 MATERIALIZED inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL +2 MATERIALIZED inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from left join (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) on(((``.`col_int_nokey` = `test`.`outer_t1`.`col_int_nokey`))) where true +SELECT outer_t1.pk, outer_t2.pk +FROM t3 AS outer_t1 +RIGHT JOIN t2 AS outer_t2 +ON outer_t1.col_int_nokey IN +(SELECT inner_t1.col_int_nokey +FROM t3 AS inner_t1 +LEFT JOIN t1 AS inner_t2 +INNER JOIN t1 AS inner_t3 +ON inner_t3.pk = inner_t2.pk +ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key +); +pk pk +1 1 +DROP TABLE t1, t2, t3; +# End of test for bug#13907277. +# +# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +PREPARE stmt FROM " +SELECT MIN(alias2.col_varchar_key) AS field1 +FROM t1 AS alias1 + INNER JOIN (t1 AS alias2 + INNER JOIN t1 AS alias3 + ON 8 IN + (SELECT sq1_alias1.pk AS sq1_field2 + FROM t1 AS sq1_alias1 + WHERE 9 IN + (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 + FROM t1 AS t1_sq1_alias1 + ) + ) + ) + ON alias3.col_varchar_nokey = alias2.col_varchar_key +WHERE EXISTS + (SELECT sq2_alias1.pk AS sq2_field1 + FROM t1 AS sq2_alias1 + WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey + ) +"; +EXECUTE stmt; +field1 +NULL + +EXECUTE stmt; +field1 +NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# End of test for bug#13955713. +# +# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() +# +CREATE TABLE t1 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +CREATE TABLE t2 ( +pk INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) charset latin1; +INSERT INTO t2 VALUES +(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), +(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), +(18,'v','v'), (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t3 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +KEY col_int_key (col_int_key) +) charset latin1; +INSERT INTO t3 VALUES +(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), +(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), +(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), +(27,0,'p'), (28,NULL,'j'), (29,8,'c'); +CREATE VIEW view_inline_0 AS +SELECT t1.* +FROM t1 INNER JOIN t3 +ON t1.pk = t3.pk; +CREATE VIEW view_inline_1 AS +SELECT sq2_alias2.col_varchar_key AS sq2_field1, +sq2_alias1.col_varchar_key AS sq2_field2 +FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 +ON sq2_alias1.pk = sq2_alias2.col_int_key; +CREATE VIEW view_inline_2 AS +SELECT 'p', 'p' UNION SELECT 'k', 's'; +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL 2 100.00 NULL +1 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where +1 PRIMARY NULL eq_ref 8 test.alias2.col_varchar_nokey,test.view_inline_2.p 1 100.00 NULL +1 PRIMARY NULL ref 8 test.view_inline_2.p,test.view_inline_2.Name_exp_p 2 100.00 NULL +3 MATERIALIZED NULL ALL NULL NULL NULL NULL 30 100.00 NULL +7 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +8 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT NULL ALL NULL NULL NULL NULL NULL NULL Using temporary +6 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL +6 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 NULL +2 DERIVED NULL ALL NULL NULL NULL NULL 15 100.00 NULL +5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`view_inline_2` join `test`.`t2` `alias2` join (/* select#2 */ select `test`.`view_inline_0`.`pk` AS `pk`,`test`.`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`test`.`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` semi join (`test`.`view_inline_1`) where ((``.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `test`.`view_inline_2`.`Name_exp_p`) and (`test`.`alias2`.`col_varchar_key` = `test`.`view_inline_2`.`p`) and (``.`sq2_field2` = `test`.`view_inline_2`.`p`) and (`alias1`.`col_varchar_key` = `test`.`view_inline_2`.`p`)) +SELECT SUM(alias1.col_varchar_nokey) AS field2 +FROM t2 AS alias2 +LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 +ON alias2.col_varchar_key = alias1.col_varchar_key AND +(alias2.col_varchar_nokey, alias2.col_varchar_key) IN +(SELECT * FROM view_inline_1 +) +WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN +(SELECT * FROM view_inline_2 +); +field2 +NULL +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW view_inline_0, view_inline_1, view_inline_2; +DROP TABLE t1, t2, t3; +# End of test for bug#13956813. +# +# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key, col_int_key) +); +INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) +VALUES +(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), +(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), +(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), +(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), +(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_time_key TIME NOT NULL, +col_time_nokey TIME NOT NULL, +PRIMARY KEY (pk), +KEY (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES +(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), +(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), +(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), +(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), +(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), +(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), +(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), +(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), +(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), +(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); +explain SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` join `test`.`t1` `ot2` join `test`.`t1` `ot1` semi join (`test`.`t2` `it2`) where ((`test`.`ot1`.`pk` is null) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) +SELECT ot1.col_int_key AS x +FROM t1 AS ot2 +LEFT JOIN t1 AS ot1 +ON ot2.col_varchar_nokey > ot1.col_varchar_key +WHERE (ot1.col_int_nokey, ot1.pk) IN +(SELECT it1.pk AS x, +it1.col_int_nokey AS y +FROM t2 AS it2 +LEFT JOIN t2 AS it1 +ON it2.col_time_nokey = it1.col_time_key +) AND ot1.pk IS NULL +; +x +DROP TABLE t1, t2; +# End of test for bug#13974177. +# +# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... +# +CREATE TABLE t1 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +CREATE TABLE t2 ( +pk INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk) +) charset utf8mb4 ENGINE=InnoDB; +CREATE TABLE t3 ( +i INT +); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL NULL 0.00 Using where +1 PRIMARY NULL ref 7 .subquery3_field1 2 100.00 NULL +1 PRIMARY NULL const 8 const 1 100.00 NULL +1 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +4 MATERIALIZED subquery3_t1 NULL index col_varchar_key col_varchar_key 12 NULL 0 0.00 Using index +3 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL +2 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where +2 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where ((`test`.`subquery1_t1`.`col_int_key` = 7) and (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`))) `table1` straight_join `test`.`t2` `table2` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) where (`table1`.`col_varchar_nokey` = ``.`subquery3_field1`) +SELECT table1.pk AS field1 +FROM ( SELECT subquery1_t1. * +FROM t2 AS subquery1_t1 +JOIN t2 AS subquery1_t2 +ON subquery1_t2.pk = subquery1_t1.pk) AS table1 +STRAIGHT_JOIN t2 AS table2 +ON table1.col_int_key IN (SELECT 7 FROM t3) +WHERE table1.col_varchar_nokey IN +(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 +FROM t1 AS subquery3_t1 +) +; +field1 +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2, t3; +# End of test for bug#13971022. +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" - Subquery part of test. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +EXPLAIN SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where +1 SIMPLE NULL eq_ref 4 test.outr.col_int_nokey 1 100.00 NULL +1 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index +2 MATERIALIZED innr NULL ALL col_int_key NULL NULL NULL 20 23.33 Using where +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` semi join (`test`.`t1` `innr`) where ((``.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (cast(`test`.`outr2`.`col_time_key` as datetime) > `test`.`outr`.`col_datetime_key`)) +SELECT outr.col_int_nokey +FROM t2 as outr +STRAIGHT_JOIN t3 AS outr2 +ON outr2.col_time_key > outr.col_datetime_key +WHERE outr.col_int_nokey IN ( +SELECT col_int_key +FROM t1 AS innr +WHERE innr.pk >= innr.col_int_nokey +) AND ( +outr.col_int_nokey <= 6 +OR +outr.col_varchar_key IS NULL +); +col_int_nokey +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +# End of test for bug#13623473. +# +# Bug#13980954: Missing data on left join + null value + where..in +# +CREATE TABLE t1 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); +CREATE TABLE t2 ( +ik INT, +vc varchar(1) +) charset utf8mb4; +INSERT INTO t2 VALUES +(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); +explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.63" + }, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(`test`.`t2`.`vc` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "7", + "ref": [ + "test.t2.vc" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.60", + "prefix_cost": "1.11", + "data_read_per_join": "96" + }, + "used_columns": [ + "vc" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.01", + "eval_cost": "1.20", + "prefix_cost": "8.63", + "data_read_per_join": "192" + }, + "used_columns": [ + "ik", + "vc" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) semi join (`test`.`t2` `t3`) where (``.`vc` = `test`.`t2`.`vc`) +SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik +FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc +WHERE t2.vc IN (SELECT vc FROM t2 AS t3); +vc t2_ik t1_ik +e 7 NULL +i 7 NULL +j 1 NULL +p 1 NULL +s 7 NULL +x 0 8 +x 0 NULL +DROP TABLE t1, t2; +# End of test for bug#13980954. +# +# Bug#14048292: Segfault in Item_field::result_type on 2nd execution +# of prep stmt with join of view +# +CREATE TABLE t1 ( +col_int INT +); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW view_t1 AS SELECT * FROM t1; +explain SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE NULL eq_ref 5 test.alias1.col_int 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 MATERIALIZED sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((``.`col_int` = `test`.`alias1`.`col_int`))) where true +PREPARE stmt FROM "SELECT alias1.col_int +FROM t1 AS alias1 +LEFT JOIN view_t1 AS alias2 +ON alias1.col_int IN +(SELECT sq1_alias1.col_int +FROM t1 AS sq1_alias1 +)"; +EXECUTE stmt; +col_int +0 +0 +1 +1 + +EXECUTE stmt; +col_int +0 +0 +1 +1 +DEALLOCATE PREPARE stmt; +DROP VIEW view_t1; +DROP TABLE t1; +# End of test for bug#14048292. +# +# Bug#14064201: Missing data on join of derived table + WHERE .. IN +# with two operands +# +CREATE TABLE t1 ( +col_varchar_nokey VARCHAR(1) +) charset utf8mb4; +INSERT INTO t1 VALUES +('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), +('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); +CREATE TABLE t2 ( +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +KEY col_varchar_key(col_varchar_key) +) charset utf8mb4; +INSERT INTO t2 VALUES +('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format=json SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.56" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (``.`col_varchar_nokey` is not null))", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "derived2", + "access_type": "ALL", + "possible_keys": [ + "col_varchar_key" + ], + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "derived1", + "access_type": "ref", + "possible_keys": [ + "" + ], + "key": "", + "used_key_parts": [ + "col_varchar_nokey" + ], + "key_length": "7", + "ref": [ + ".col_varchar_nokey" + ], + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.50", + "eval_cost": "0.20", + "prefix_cost": "8.51", + "data_read_per_join": "32" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.21" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "0.70", + "prefix_cost": "1.21", + "data_read_per_join": "112" + }, + "used_columns": [ + "col_varchar_key", + "col_varchar_nokey" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.05", + "eval_cost": "4.00", + "prefix_cost": "13.56", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `derived1`.`col_varchar_nokey` AS `col_varchar_nokey`,`derived1`.`col_varchar_key` AS `col_varchar_key` from (/* select#2 */ select `test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2`) `derived1` left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) semi join (`test`.`t2` `derived2`) where ((``.`col_varchar_key` = ``.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = ``.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) +SELECT * +FROM (SELECT * FROM t2) AS derived1 +LEFT JOIN t1 +USING (col_varchar_nokey) +WHERE (col_varchar_nokey, col_varchar_nokey) IN +(SELECT col_varchar_nokey, col_varchar_key +FROM t2 AS derived2 +); +col_varchar_nokey col_varchar_key +c c +d d +d d +j j +m m +v v +v v +y y +y y +y y +SET @@optimizer_switch= @optimizer_switch_saved; +DROP TABLE t1, t2; +CREATE TABLE t1 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t1 VALUES +(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), +(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); +CREATE TABLE t2 ( +col_int_nokey int NOT NULL, +col_int_key int NOT NULL, +KEY col_int_key (col_int_key) +); +INSERT INTO t2 VALUES +(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), +(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); +explain format=json SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "60.24" + }, + "nested_loop": [ + { + "table": { + "table_name": "grandparent1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ] + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "8", + "ref": [ + "test.grandparent1.col_int_nokey", + "test.grandparent1.col_int_nokey" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "possible_keys": [ + "col_int_key" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.51", + "eval_cost": "2.00", + "prefix_cost": "2.51", + "data_read_per_join": "320" + }, + "used_columns": [ + "col_int_nokey", + "col_int_key" + ], + "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 400, + "filtered": "100.00", + "cost_info": { + "read_cost": "10.22", + "eval_cost": "40.00", + "prefix_cost": "60.24", + "data_read_per_join": "6K" + }, + "used_columns": [ + "col_int_nokey" + ], + "attached_condition": "(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_int_nokey` AS `col_int_nokey`,`test`.`grandparent1`.`col_int_key` AS `col_int_key` from `test`.`t1` `grandparent1` left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) semi join (`test`.`t2`) where ((``.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (``.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) +SELECT grandparent1.* +FROM t1 AS grandparent1 +LEFT JOIN t1 USING (col_int_nokey) +WHERE (col_int_nokey, col_int_nokey) IN +(SELECT col_int_nokey, col_int_key +FROM t2 +); +col_int_nokey col_int_key +1 6 +1 6 +1 7 +1 7 +7 0 +7 0 +7 3 +7 3 +8 1 +8 1 +8 5 +8 5 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t1 VALUES +(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), +(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), +(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), +(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), +(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), +(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), +(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), +(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), +(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), +(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); +CREATE TABLE t2 ( +pk int, +col_int_key int, +col_datetime_key datetime, +col_varchar_key varchar(1), +col_varchar_nokey varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4 engine=MyISAM; +INSERT INTO t2 VALUES +(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), +(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), +(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), +(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), +(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), +(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), +(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), +(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), +(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), +(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t2 DISABLE KEYS; +explain format=json SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "62.53" + }, + "nested_loop": [ + { + "table": { + "table_name": "", + "access_type": "ALL", + "attached_condition": "(``.`col_varchar_nokey` = ``.`col_varchar_key`)", + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "nested_loop": [ + { + "table": { + "table_name": "sq2_alias2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 6, + "filtered": "33.33", + "cost_info": { + "read_cost": "1.86", + "eval_cost": "0.67", + "prefix_cost": "2.53", + "data_read_per_join": "213" + }, + "used_columns": [ + "col_int_key", + "col_varchar_key" + ], + "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" + } + }, + { + "table": { + "table_name": "sq2_alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 13, + "filtered": "10.00", + "cost_info": { + "read_cost": "3.53", + "eval_cost": "1.33", + "prefix_cost": "19.39", + "data_read_per_join": "426" + }, + "used_columns": [ + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" + } + } + ] + } + } + } + }, + { + "table": { + "table_name": "alias2", + "access_type": "ALL", + "possible_keys": [ + "PRIMARY" + ], + "rows_examined_per_scan": 20, + "rows_produced_per_join": 2, + "filtered": "10.00", + "cost_info": { + "read_cost": "7.05", + "eval_cost": "0.20", + "prefix_cost": "56.77", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_key", + "col_varchar_nokey" + ], + "attached_condition": "(`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`)" + } + }, + { + "table": { + "table_name": "alias3", + "access_type": "eq_ref", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "pk" + ], + "key_length": "4", + "ref": [ + "test.alias2.pk" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "57.47", + "data_read_per_join": "64" + }, + "used_columns": [ + "pk", + "col_varchar_nokey" + ] + } + }, + { + "table": { + "table_name": "alias1", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "1.06", + "eval_cost": "4.00", + "prefix_cost": "62.53", + "data_read_per_join": "1K" + }, + "used_columns": [ + "col_datetime_key" + ], + "attached_condition": "(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or (0 <> `test`.`alias2`.`col_varchar_nokey`)), true)" + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) or (0 <> `test`.`alias2`.`col_varchar_nokey`))) semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (``.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = ``.`col_varchar_key`) and (`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) +SELECT alias1.col_datetime_key +FROM t2 AS alias1 +RIGHT JOIN t2 AS alias2 +JOIN t2 AS alias3 +ON alias3.pk = alias2.pk +ON alias3.col_varchar_nokey = alias2.col_varchar_key OR +alias2.col_varchar_nokey +WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN +(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey +FROM t1 AS sq2_alias1, t1 AS sq2_alias2 +WHERE sq2_alias2.col_int_key < 2); +col_datetime_key +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +1900-01-01 00:00:00 +2001-01-20 12:47:23 +2001-01-20 12:47:23 +2001-02-15 03:08:38 +2001-02-15 03:08:38 +2002-01-16 00:00:00 +2002-01-16 00:00:00 +2002-02-13 17:30:06 +2002-02-13 17:30:06 +2002-08-20 22:48:00 +2002-08-20 22:48:00 +2002-08-25 20:35:06 +2002-08-25 20:35:06 +2002-12-08 11:34:58 +2002-12-08 11:34:58 +2004-10-02 20:31:15 +2004-10-02 20:31:15 +2005-08-15 00:00:00 +2005-08-15 00:00:00 +2006-10-12 04:32:53 +2006-10-12 04:32:53 +2007-05-28 00:00:00 +2007-05-28 00:00:00 +2008-05-16 08:09:06 +2008-05-16 08:09:06 +2008-07-02 00:00:00 +2008-07-02 00:00:00 +2008-09-27 00:34:58 +2008-09-27 00:34:58 +2009-07-25 09:21:20 +2009-07-25 09:21:20 +DROP TABLE t1, t2; +# End of test for bug#14064201. +# +# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 +# && IDX < PARENT_JOIN->TABLES +# +CREATE TABLE b (d INT); +CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); +SELECT(SELECT 1 +FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) +FROM b) IN (SELECT d FROM c)) as cc FROM b; +cc +INSERT INTO b VALUE(1); +INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); +SELECT(SELECT d FROM b WHERE(SELECT d IN +(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN +(SELECT d FROM c)) as cc FROM c; +cc +1 +1 +1 +DROP TABLE b,c; +# +# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN +# +CREATE TABLE b ( +d INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE c ( +d BLOB +) ; +CREATE TABLE d ( +b INT(11) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO b VALUES(1),(2),(4); +INSERT INTO c VALUES(1),(2),(3); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +INSERT INTO d VALUES(2); +SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; +1 +1 +1 +1 +DROP TABLE b,c,d; +# +# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT +# +CREATE TABLE t1 ( +ID int(11) NOT NULL AUTO_INCREMENT, +id2 int(11) DEFAULT NULL, +id3 int(11) DEFAULT NULL, +id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, +id5 int(11) DEFAULT NULL, +PRIMARY KEY (ID), +KEY id2 (id2), +KEY id3 (id3), +KEY id5 (id5) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3778 'utf8_spanish_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(123,1,1,'1',NULL), +(124,1,1,'2',NULL), +(125,1,1,'4',NULL), +(126,1,1,'3',NULL), +(127,1,1,'6',NULL), +(128,1,1,'8',NULL); +CREATE TABLE t2 ( +id6 int(11) NOT NULL, +id7 int(11) NOT NULL, +PRIMARY KEY (id6,id7), +KEY id7 (id7) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (126,123),(130,123),(135,123); +SELECT ID +FROM t1 p0 +WHERE p0.id3=1 +AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 +p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); +ID +126 +DROP TABLE t1,t2; +set @@optimizer_switch=@old_opt_switch; +# End of 5.6 tests +# +# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +col_varchar_nokey varchar(1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t1 VALUES ('c'),(NULL),('x'); +CREATE TABLE t2 ( +pk int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (10,'l'),(11,'p'); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where +2 MATERIALIZED innr NULL range PRIMARY,col_varchar_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = ``.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) +SELECT 1 +FROM t1 AS outr +WHERE outr.col_varchar_nokey IN +( +SELECT innr.col_varchar_key +FROM t2 AS innr +WHERE innr.pk <= 7 +) +; +1 +DROP TABLE t1,t2; +# +# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT +# +CREATE TABLE t1(d BLOB, b BLOB); +INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); +SELECT 1 FROM t1 +WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN +# PREDICATE INSIDE IN PREDICATE +# +CREATE TABLE t(X INT) ENGINE=InnoDB; +INSERT INTO t VALUES (1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL eq_ref 4 const 1 100.00 NULL +3 MATERIALIZED t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where true +SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); +1 +1 +DROP TABLE t; +# +# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); +CREATE TABLE t3 ( +pk INTEGER NOT NULL, +c1 VARCHAR(1) NOT NULL, +PRIMARY KEY (pk), +KEY c1_key (c1) +) charset utf8mb4 ENGINE=InnoDB; +INSERT INTO t3 VALUES (10,'v'),(11,'s'); +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 NULL +1 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 6 .c1 1 33.33 Using where; Using index +2 MATERIALIZED t3 NULL range PRIMARY,c1_key PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` join `test`.`t2` semi join (`test`.`t3`) where ((`test`.`t2`.`c1` = ``.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) +SELECT * +FROM t1 JOIN t2 ON t1.i1 >= t2.pk +WHERE t2.c1 IN ( +SELECT t3.c1 +FROM t3 +WHERE t3.pk < 3 +); +pk i1 pk c1 +DROP TABLE t1,t2,t3; +# +# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC +# +CREATE TABLE t1(x INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL const 4 const 1 100.00 NULL +3 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where true +SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where false +SELECT 1 FROM t1 WHERE +(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); +1 +DROP TABLE t1; +# +#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE +# EVALUATE_JOIN_RECORD +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'x'); +CREATE TABLE t2 ( +col_date_key date DEFAULT NULL, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_date_key (col_date_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), +('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), +('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), +(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), +('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), +('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), +('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), +('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), +('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), +('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); +CREATE TABLE t3 ( +pk int(11) NOT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), +(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), +(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL NULL 100.00 Using where +2 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 12 NULL 20 100.00 Using where; Using index +2 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key +3 MATERIALIZED iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Full scan on NULL key +3 MATERIALIZED iir1 NULL ref col_varchar_key col_varchar_key 7 test.iir2.col_varchar_nokey 1 100.00 Using index +SELECT r1.col_date_key +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key)) +ORDER BY r1.col_date_key; +col_date_key +2000-04-10 +2000-09-20 +2000-12-03 +2002-10-20 +2002-11-05 +2004-09-18 +2005-09-13 +2006-06-16 +2007-01-08 +2007-06-14 +2007-11-17 +2008-05-03 +2008-06-10 +2008-09-12 +2009-02-23 +SELECT COUNT(r1.col_date_key) AS COUNT_NUM +FROM t2 AS r1 +WHERE r1.col_int_key NOT IN +(SELECT ir2.pk +FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 +ON ir2.col_varchar_nokey = ir1.col_varchar_key +WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey +AND ir2.pk IN +(SELECT iir2.pk +FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 +ON iir2.col_varchar_nokey = iir1.col_varchar_key +WHERE iir2.pk<3)); +COUNT_NUM +15 +DROP TABLE t1,t2,t3; +# +# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR +# +CREATE TABLE t1 ( +pk int NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int, +col_varchar_key varchar(1), +col_varchar varchar(1), +PRIMARY KEY (pk), +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key) +); +INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); +CREATE TABLE t4 ( +col_int int +); +CREATE TABLE t5 ( +col_varchar_key varchar(1), +pk int NOT NULL, +col_int int, +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +); +SELECT table1.col_varchar_key AS field1 +FROM (t3 AS table1 +INNER JOIN ( +SELECT SUBQUERY1_t1.* +FROM (t1 AS SUBQUERY1_t1 +RIGHT JOIN (t2 AS SUBQUERY1_t2 +INNER JOIN t3 AS SUBQUERY1_t3 +ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) +) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) +) +WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( +SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 +FROM (t2 AS CHILD_SUBQUERY1_t1 +LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 +ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) +) +WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk +) +) AS table2 +ON (table2.pk = table1.pk) +) +WHERE (EXISTS (( +SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 +FROM (t4 AS SUBQUERY2_t1 +LEFT OUTER JOIN t5 AS SUBQUERY2_t2 +ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) +) +WHERE SUBQUERY2_t2.col_varchar_key != @var4 +))) +AND table1.col_int_key < (35 + 192) +ORDER BY field1 +; +field1 +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB +# ENGINE +# +CREATE TABLE t1 ( +col_int_key INT, +pk INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE = INNODB; +INSERT INTO t1 VALUES +( 0, 3 ), +( 0, 4 ), +( 3, 1 ), +( 900000000, 2 ), +( 1368719360, 5 ), +( 1922236416, 6 ), +( 8,7 ); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int INT, +PRIMARY KEY (pk) +) ENGINE = INNODB; +INSERT INTO t2 VALUES +( 1, 3 ), +( 2, 2 ), +( 3, 8 ), +( 4, 7 ); +CREATE TABLE t3 ( +col_int_key INT, +col_int INT, +KEY (col_int_key) +) ENGINE = INNODB; +INSERT INTO t3 VALUES +( 5, 1 ), +( -1, -1 ), +( 300000000, 1 ), +( 8, 1 ); +CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; +INSERT INTO t4 VALUES +(0), +(3), +(8), +(900000000), +(1368719360), +(1922236416); +ANALYZE TABLE t1, t2, t3, t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +explain SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort +1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +2 MATERIALIZED t1 NULL index col_int_key col_int_key 5 NULL 7 100.00 Using index +2 MATERIALIZED t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL +2 MATERIALIZED t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = ``.`col_int_key`) and (`test`.`t3`.`col_int` is null)) order by `test`.`t4`.`col_int_key` +explain format=tree SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +EXPLAIN +-> Sort: t4.col_int_key + -> Stream results (cost=11.32 rows=7) + -> Nested loop inner join (cost=11.32 rows=7) + -> Table scan on (cost=0.37..2.59 rows=7) + -> Materialize with deduplication (cost=4.47..6.69 rows=7) + -> Filter: (t1.col_int_key is not null) (cost=3.40 rows=7) + -> Filter: (t3.col_int is null) (cost=3.40 rows=7) + -> Nested loop left join (cost=3.40 rows=7) + -> Index scan on t1 using col_int_key (cost=0.95 rows=7) + -> Nested loop inner join (cost=2.41 rows=1) + -> Single-row index lookup on t2 using PRIMARY (pk=t1.pk) (cost=0.26 rows=1) + -> Index lookup on t3 using col_int_key (col_int_key=t2.col_int) (cost=0.25 rows=1) + -> Filter: (t4.col_int_key = ``.col_int_key) (cost=0.54 rows=1) + -> Table scan on t4 (cost=0.54 rows=6) + +SELECT * +FROM t4 +WHERE (col_int_key) IN ( +SELECT t1.col_int_key +FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) +WHERE t3.col_int IS NULL +) +ORDER BY col_int_key +; +col_int_key +0 +3 +8 +900000000 +1368719360 +1922236416 +DROP TABLE t1, t2, t3, t4; +# +# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC +# +CREATE TABLE t1 ( +pk INTEGER, +var_10_latin1 VARCHAR(10) CHARACTER SET latin1, +var_255_utf8 VARCHAR(255) CHARACTER SET utf8, +var_255_latin1 VARCHAR(255) CHARACTER SET latin1, +var_10_utf8 VARCHAR(10) CHARACTER SET utf8, +PRIMARY KEY (pk) +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES +(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), +(2,'him','a','CHYKN','OZZQT'), +(3,'WBITK','ULWBF','have','rhrh'), +(4,'or','right','up','it'), +(5,'GGDCP','x','who','as'), +(6,'j','i','e','w'); +CREATE TABLE tv +SELECT var_255_utf8 AS field1 +FROM t1; +EXPLAIN SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where +1 SIMPLE NULL eq_ref 768 test.tv.field1 1 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL +2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((`test`.`t1`.`var_10_latin1` = `test`.`t1`.`var_10_utf8`))) where (``.`var_255_utf8` = `test`.`tv`.`field1`) +SELECT * FROM tv +WHERE field1 IN ( +SELECT tv1.var_255_utf8 +FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); +field1 +korrhrspki +a +ULWBF +right +x +i +DROP VIEW v1; +DROP TABLE t1, tv; +# 17832047 Crash in calculate_materialization_costs +CREATE TABLE t1(a INTEGER PRIMARY KEY); +INSERT INTO t1 VALUES (0),(1),(2); +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 +FROM t1 +); +1 +1 +1 +1 +DROP TABLE t1; +# 17845989 Assertion failed: !(used_tables() & ... +CREATE TABLE a(b INTEGER) engine=innodb; +CREATE TABLE c(a INTEGER) engine=innodb; +SELECT 1 +FROM a +WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) +; +1 +DROP TABLE a, c; +# +# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT +# +CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); +INSERT INTO t1 VALUES +(1,1), (1,2), (1,3), (1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t2 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); +INSERT INTO t3 VALUES +(1,1), (1,2), (1,3),(1,4), +(2,5), (2,6), (2,7), (2,8), +(3,1), (3,2), (3,9); +CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); +INSERT INTO t4 VALUES +(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), +(6, "F"), (7, "G"), (8, "H"), (9, "I"); +ANALYZE TABLE t1,t2,t3,t4; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +EXPLAIN SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary +1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index +1 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 4 100.00 Using where; End temporary +1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` join `test`.`t2` join `test`.`t1` semi join (`test`.`t3`) where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) +FLUSH STATUS; +SELECT name FROM t2, t1 +WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) +AND t2.uid=t1.fid; +name +A +A +B +B +C +D +E +F +G +H +I +SHOW STATUS LIKE '%handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 20 +Handler_read_last 0 +Handler_read_next 15 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1,t2,t3,t4; +# End of test for Bug#18194196 +# +# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT +# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() +# +CREATE TABLE t1 ( +pk INTEGER, +col_varchar varchar(1), +col_int INTEGER, +PRIMARY KEY (pk) +) ENGINE=MyISAM; +CREATE TABLE t2 ( +col_int INTEGER, +col_varchar varchar(1) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7,'x'); +INSERT INTO t2 VALUES (4,'z'); +SELECT t2.col_varchar +FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar +JOIN t2 AS table3 ON t1.pk = table3.col_int +WHERE t1.pk IN (SELECT col_int FROM t1); +col_varchar +DROP TABLE t1,t2; +# End of test for Bug#21184091 +# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE TABLE t2(b INTEGER) engine=innodb; +explain SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +4 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select (1,(/* select#3 */ select 1 from `test`.`t1` where ((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`)),(/* select#5 */ select 1 from `test`.`t2` where (outer_field_is_not_null, (((/* select#4 */ select 1 from `test`.`t2` having (0 <> `test`.`t2`.`b`))) = 1), true)) is false))) AS `1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +)` from `test`.`t2`) `z` +SELECT 1 +FROM (SELECT 1 IN (SELECT 1 +FROM t1 +WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) +) +FROM t2 +) AS z; +1 +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER) engine=innodb; +explain SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary; End temporary +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` +SELECT (SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +FROM t1 AS t1; +(SELECT a FROM t1 AS t2 +WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) +DROP TABLE t1; +# End of test for Bug#21139722 +SET DEFAULT_STORAGE_ENGINE=INNODB; +# +# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE t2 (c INT PRIMARY KEY); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where false +SELECT 1 FROM t1 +WHERE 1 IN +(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); +1 +DROP TABLE t1,t2; +# +# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT +# +create table cc (i int) engine="innodb"; +insert into cc values (1); +select (select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +from cc group by i; +(select count(i) from cc as cc_alias +where (cc.i in (select cc_alias.i from cc))) +1 +prepare stmt from +"select (select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) + from cc group by i"; +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +execute stmt; +(select count(i) from cc as cc_alias + where (cc.i in (select cc_alias.i from cc))) +1 +drop table cc; +# +# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT +# RESULTS IN 5.6 +# +CREATE TABLE t(a INT,b INT); +INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY NULL eq_ref 5 test.t1.a 1 100.00 NULL +2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +3 SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((``.`a` = `test`.`t1`.`a`) and (concat(`test`.`t2`.`a`,''),concat(`test`.`t2`.`a`,'') in ( (/* select#3 */ select `test`.`t3`.`a` from `test`.`t` `t3` where (`test`.`t3`.`b` = 1) having true ), (concat(`test`.`t2`.`a`,'') in on where ((concat(`test`.`t2`.`a`,'') = ``.`a`)))) is false)) +SELECT * +FROM t AS t1 +WHERE t1.a IN (SELECT t2.a +FROM t AS t2 +WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a +FROM t AS t3 +WHERE t3.b=1)); +a b +DROP TABLE t; +# +# Bug#24287772 SUBQUERY RETURNS EMPTY LIST WHILE IDENTICAL QUERY +# WITH JOIN RETURNS RESULT +# +CREATE TABLE t SELECT 4096 c; +SELECT c FROM t WHERE 1 IN +(SELECT t.c = page_size FROM information_schema.innodb_cmpmem); +c +4096 +DROP TABLE t; +# +# Bug #29132639: WL#12470: SIG 6 IN CONNECTJOINS|SQL/SQL_EXECUTOR.C +# +CREATE TABLE t1 ( f1 TIME, f2 VARCHAR(1) ); +INSERT INTO t1 VALUES ('08:35:24', 'X'), ('14:51:13', 'S'), ('11:22:33', 'Q'); +CREATE TABLE t2 ( pk INTEGER ); +INSERT INTO t2 VALUES (1), (2); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN FORMAT=tree SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +EXPLAIN +-> Nested loop inner join (cost=12.30 rows=54) + -> Constant row from (cost=0.00..0.00 rows=1) + -> Materialize with deduplication (cost=6.65..6.65 rows=18) + -> Nested loop left join (cost=4.85 rows=18) + -> Nested loop left join (cost=1.55 rows=6) + -> Table scan on t2 (cost=0.45 rows=2) + -> Table scan on t1 (cost=0.40 rows=3) + -> Table scan on alias1 (cost=0.30 rows=3) + -> Table scan on t1 (cost=0.55 rows=3) + +SELECT * FROM t1 WHERE EXISTS ( SELECT alias1.f2 FROM t2 LEFT JOIN t1 ON 1 LEFT JOIN t1 AS alias1 ON 1 ); +f1 f2 +08:35:24 X +11:22:33 Q +14:51:13 S +DROP TABLE t1, t2; +set optimizer_switch=default; +set optimizer_switch=default; diff --git a/mysql-test/r/subselect_debug.result-pq b/mysql-test/r/subselect_debug.result-pq new file mode 100644 index 000000000..5218bcaf0 --- /dev/null +++ b/mysql-test/r/subselect_debug.result-pq @@ -0,0 +1,77 @@ +CREATE TABLE t1(id INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d; +SET @orig_debug = @@debug; +SET SESSION debug="d,subselect_exec_fail"; +SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; +SUM(EXISTS(SELECT RAND() FROM t1)) +0 +SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); +REVERSE(EXISTS(SELECT RAND() FROM t1)) +0 +SET SESSION debug=@orig_debug; +DROP TABLE t1; +# +# Bug#21383882 ASSERTION FAILED: 0 IN SELECT_LEX::PRINT() +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1),(1); +SELECT ((SELECT 1 FROM t1) IN (SELECT 1 FROM t1)) - (11111111111111111111); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# +# Bug#26679495: SIG 11 IN SUBSELECT_HASH_SJ_ENGINE::CLEANUP +# +CREATE TABLE t (x INT); +INSERT INTO t VALUES (1), (2), (3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +# The subquery should be materialized so that we +# use subselect_hash_sj_engine. +EXPLAIN SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL NULL 3 100.00 Using where +2 SUBQUERY t NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`x` AS `x` from `test`.`t` where (`test`.`t`.`x`,`test`.`t`.`x` in ( (/* select#2 */ select count(0) from `test`.`t` group by `test`.`t`.`x` having true ), (`test`.`t`.`x` in on where ((`test`.`t`.`x` = ``.`COUNT(*)`))))) +SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x); +x +1 +# Execute the query with a simulated error in +# subselect_hash_sj_engine::setup(). +SET DEBUG='+d,hash_semijoin_fail_in_setup'; +SELECT * FROM t WHERE x IN (SELECT COUNT(*) FROM t GROUP BY x); +ERROR HY000: Unknown error +SET DEBUG='-d,hash_semijoin_fail_in_setup'; +DROP TABLE t; +# +# Bug#26679983: SIG 11 IN MAKE_JOIN_READINFO|SQL/SQL_SELECT.CC +# +CREATE TABLE t (x INT); +INSERT INTO t VALUES (1), (2), (3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +# We want nested loop with duplicate weedout to reproduce the bug. +SET optimizer_switch = 'firstmatch=off,materialization=off'; +EXPLAIN SELECT * FROM t WHERE x IN (SELECT x FROM t); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary +2 SIMPLE t NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`x` AS `x` from `test`.`t` semi join (`test`.`t`) where (`test`.`t`.`x` = `test`.`t`.`x`) +SELECT * FROM t WHERE x IN (SELECT x FROM t); +x +1 +2 +3 +# Execute the query with a simulated error in +# create_duplicate_weedout_tmp_table(). +SET DEBUG='+d,create_duplicate_weedout_tmp_table_error'; +SELECT * FROM t WHERE x IN (SELECT x FROM t); +ERROR HY000: Unknown error +SET DEBUG='-d,create_duplicate_weedout_tmp_table_error'; +DROP TABLE t; +SET optimizer_switch = DEFAULT; diff --git a/mysql-test/r/temptable_fallback.result-pq b/mysql-test/r/temptable_fallback.result-pq new file mode 100644 index 000000000..dfbeec517 --- /dev/null +++ b/mysql-test/r/temptable_fallback.result-pq @@ -0,0 +1,165 @@ +# Disable sorting by addon fields, as that will enable the +# StreamingIterator in many of the test cases, resulting in +# fewer materializations. +SET debug = '+d,filesort_force_sort_row_ids'; +CREATE TABLE t (c VARCHAR(128)); +INSERT INTO t VALUES +(REPEAT('a', 128)), +(REPEAT('b', 128)), +(REPEAT('c', 128)), +(REPEAT('d', 128)); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 0 +SHOW STATUS LIKE 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +# --------------------------------------------------------------------- +# Scenario 1: (ENGINE=MEMORY, LIMIT=default, CASE=basic, RESULT=success) +# +SET @@internal_tmp_mem_storage_engine = MEMORY; +SELECT * FROM +t AS t1, +t AS t2, +t AS t3, +t AS t4, +t AS t5, +t AS t6 +ORDER BY 1 +LIMIT 2; +SELECT @@internal_tmp_mem_storage_engine; +@@internal_tmp_mem_storage_engine +MEMORY +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 1 +SHOW STATUS LIKE 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +SET @@internal_tmp_mem_storage_engine = default; +# --------------------------------------------------------------------- +# Scenario 2: (ENGINE=MEMORY, LIMIT=default, CASE=no-std-memory, RESULT=ondisk_fallback) +# +SET @@internal_tmp_mem_storage_engine = MEMORY; +SET @@max_heap_table_size = 16384; +SELECT * FROM +t AS t1, +t AS t2, +t AS t3, +t AS t4, +t AS t5, +t AS t6 +ORDER BY 1 +LIMIT 2; +SELECT @@internal_tmp_mem_storage_engine; +@@internal_tmp_mem_storage_engine +MEMORY +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 2 +SHOW STATUS LIKE 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +SET @@internal_tmp_mem_storage_engine = default; +SET @@max_heap_table_size = default; +# --------------------------------------------------------------------- +# Scenario 3: (ENGINE=TempTable, LIMIT=default, CASE=basic, RESULT=success) +# +SET @@internal_tmp_mem_storage_engine = TempTable; +SELECT count_alloc +FROM performance_schema.memory_summary_global_by_event_name +WHERE event_name = 'memory/temptable/physical_disk' + INTO @id1; +SELECT * FROM +t AS t1, +t AS t2, +t AS t3, +t AS t4, +t AS t5, +t AS t6 +ORDER BY 1 +LIMIT 2; +SELECT count_alloc +FROM performance_schema.memory_summary_global_by_event_name +WHERE event_name = 'memory/temptable/physical_disk' + INTO @id2; +SELECT @@internal_tmp_mem_storage_engine; +@@internal_tmp_mem_storage_engine +TempTable +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 3 +SHOW STATUS LIKE 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +SELECT (@id1=@id2); +(@id1=@id2) +1 +# --------------------------------------------------------------------- +# Scenario 4: (ENGINE=TempTable, LIMIT=default, CASE=no-std-memory, RESULT=use_tempfiles) +# +SET @@internal_tmp_mem_storage_engine = TempTable; +SET GLOBAL temptable_max_ram = 2097152; +SELECT count_alloc +FROM performance_schema.memory_summary_global_by_event_name +WHERE event_name = 'memory/temptable/physical_disk' + INTO @id1; +SELECT * FROM +t AS t1, +t AS t2, +t AS t3, +t AS t4, +t AS t5, +t AS t6 +ORDER BY 1 +LIMIT 2; +SELECT count_alloc +FROM performance_schema.memory_summary_global_by_event_name +WHERE event_name = 'memory/temptable/physical_disk' + INTO @id2; +SELECT @@internal_tmp_mem_storage_engine; +@@internal_tmp_mem_storage_engine +TempTable +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 4 +SHOW STATUS LIKE 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +SELECT (@id1<@id2); +(@id1<@id2) +1 +SET @@internal_tmp_mem_storage_engine = default; +SET GLOBAL temptable_max_ram = default; +# --------------------------------------------------------------------- +# Scenario 5: (ENGINE=TempTable, LIMIT=default, CASE=no-disk-memory, RESULT=error) +# +SET @@internal_tmp_mem_storage_engine = TempTable; +SET GLOBAL temptable_max_ram = 2097152; +SET debug = '+d,temptable_fetch_from_disk_return_null'; +SELECT * FROM +t AS t1, +t AS t2, +t AS t3, +t AS t4, +t AS t5, +t AS t6 +ORDER BY 1 +LIMIT 2; +SELECT @@internal_tmp_mem_storage_engine; +@@internal_tmp_mem_storage_engine +TempTable +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 5 +SHOW STATUS LIKE 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +SET @@internal_tmp_mem_storage_engine = default; +SET GLOBAL temptable_max_ram = default; +SET debug = '-d,temptable_fetch_from_disk_return_null'; +DROP TABLE t; +SET optimizer_switch="hash_join=on"; diff --git a/mysql-test/r/truth_value_transform.result-pq b/mysql-test/r/truth_value_transform.result-pq new file mode 100644 index 000000000..80aed4a21 --- /dev/null +++ b/mysql-test/r/truth_value_transform.result-pq @@ -0,0 +1,83 @@ +create table t1(id int, a int); +insert into t1 values(1,1),(2,2),(3,null); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select id, a=1 is false from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is false) AS `a=1 is false` from `test`.`t1` +select id, a=1 is false from t1 ; +id a=1 is false +1 0 +2 1 +3 0 +explain select id, not (a=1 is true) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is not true) AS `not (a=1 is true)` from `test`.`t1` +select id, not (a=1 is true) from t1 ; +id not (a=1 is true) +1 0 +2 1 +3 1 +explain select id, (not a=1) is true from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` <> 1) is true) AS `(not a=1) is true` from `test`.`t1` +select id, (not a=1) is true from t1 ; +id (not a=1) is true +1 0 +2 1 +3 0 +explain select id, not (a=1 is false) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is not false) AS `not (a=1 is false)` from `test`.`t1` +select id, not (a=1 is false) from t1 ; +id not (a=1 is false) +1 1 +2 0 +3 1 +explain select id, not (a=1 is unknown) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` = 1) is not null) AS `not (a=1 is unknown)` from `test`.`t1` +select id, not (a=1 is unknown) from t1 ; +id not (a=1 is unknown) +1 1 +2 1 +3 0 +explain select id, ((not a=1) is true) is false from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,((`test`.`t1`.`a` <> 1) is not true) AS `((not a=1) is true) is false` from `test`.`t1` +select id, ((not a=1) is true) is false from t1 ; +id ((not a=1) is true) is false +1 1 +2 0 +3 1 +explain select id, 3 + (not (a=1 is false)) from t1 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,(3 + ((`test`.`t1`.`a` = 1) is not false)) AS `3 + (not (a=1 is false))` from `test`.`t1` +select id, 3 + (not (a=1 is false)) from t1 ; +id 3 + (not (a=1 is false)) +1 4 +2 3 +3 4 +drop table t1; diff --git a/mysql-test/r/type_bit_innodb.result-pq b/mysql-test/r/type_bit_innodb.result-pq new file mode 100644 index 000000000..fec36ddc8 --- /dev/null +++ b/mysql-test/r/type_bit_innodb.result-pq @@ -0,0 +1,446 @@ +select 0 + b'1'; +0 + b'1' +1 +select 0 + b'0'; +0 + b'0' +0 +select 0 + b'000001'; +0 + b'000001' +1 +select 0 + b'000011'; +0 + b'000011' +3 +select 0 + b'000101'; +0 + b'000101' +5 +select 0 + b'000000'; +0 + b'000000' +0 +select 0 + b'10000000'; +0 + b'10000000' +128 +select 0 + b'11111111'; +0 + b'11111111' +255 +select 0 + b'10000001'; +0 + b'10000001' +129 +select 0 + b'1000000000000000'; +0 + b'1000000000000000' +32768 +select 0 + b'1111111111111111'; +0 + b'1111111111111111' +65535 +select 0 + b'1000000000000001'; +0 + b'1000000000000001' +32769 +drop table if exists t1; +create table t1 (a bit(65)) engine=innodb; +ERROR 42000: Display width out of range for column 'a' (max = 64) +create table t1 (a bit(0)) engine=innodb; +ERROR HY000: Invalid size for column 'a'. +create table t1 (a bit(64)) engine=innodb; +insert into t1 values +(b'1111111111111111111111111111111111111111111111111111111111111111'), +(b'1000000000000000000000000000000000000000000000000000000000000000'), +(b'0000000000000000000000000000000000000000000000000000000000000001'), +(b'1010101010101010101010101010101010101010101010101010101010101010'), +(b'0101010101010101010101010101010101010101010101010101010101010101'); +select hex(a) from t1; +hex(a) +FFFFFFFFFFFFFFFF +8000000000000000 +1 +AAAAAAAAAAAAAAAA +5555555555555555 +drop table t1; +create table t1 (a bit) engine=innodb; +insert ignore into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); +Warnings: +Warning 1406 Data too long for column 'a' at row 4 +select hex(a) from t1; +hex(a) +0 +1 +0 +1 +1 +alter table t1 add unique (a); +ERROR 23000: Duplicate entry '\x01' for key 't1.a' +drop table t1; +create table t1 (a bit(2)) engine=innodb; +insert ignore into t1 values (b'00'), (b'01'), (b'10'), (b'100'); +Warnings: +Warning 1406 Data too long for column 'a' at row 4 +select a+0 from t1; +a+0 +0 +1 +2 +3 +alter table t1 add key (a); +analyze table t1; +explain select a+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 2 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0` from `test`.`t1` +select a+0 from t1; +a+0 +0 +1 +2 +3 +drop table t1; +create table t1 (a bit(7), b bit(9), key(a, b)) engine=innodb; +insert into t1 values +(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), +(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), +(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36), +(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499), +(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403), +(44, 307), (68, 454), (57, 135); +analyze table t1; +explain select a+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 38 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 38 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0` from `test`.`t1` +select a+0 from t1; +a+0 +0 +104 +106 +108 +111 +116 +118 +119 +122 +123 +127 +23 +24 +28 +29 +30 +31 +34 +4 +44 +49 +5 +56 +57 +59 +60 +61 +68 +68 +75 +77 +78 +79 +87 +88 +9 +94 +94 +explain select b+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 38 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 38 100.00 Using index +Note 1003 /* select#1 */ select (`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` +Warnings: +select b+0 from t1; +b+0 +118 +123 +133 +135 +152 +177 +178 +188 +202 +206 +245 +280 +307 +343 +345 +349 +351 +36 +363 +368 +368 +379 +380 +390 +398 +399 +403 +411 +411 +42 +438 +446 +454 +46 +468 +499 +67 +83 +explain select a+0, b+0 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 38 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 38 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` +select a+0, b+0 from t1; +a+0 b+0 +0 177 +104 280 +106 446 +108 67 +111 368 +116 390 +118 380 +119 368 +122 118 +123 411 +127 403 +23 36 +24 398 +28 499 +29 399 +30 83 +31 438 +34 202 +4 245 +44 307 +49 345 +5 178 +56 379 +57 135 +59 188 +60 343 +61 152 +68 206 +68 454 +75 42 +77 133 +78 123 +79 349 +87 351 +88 411 +9 363 +94 46 +94 468 +explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 27 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 2 NULL 27 33.33 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` where ((`test`.`t1`.`a` > 40) and (`test`.`t1`.`b` > 200)) order by `a+0` +select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +a+0 b+0 +44 307 +49 345 +56 379 +60 343 +68 206 +68 454 +79 349 +87 351 +88 411 +94 468 +104 280 +106 446 +111 368 +116 390 +118 380 +119 368 +123 411 +127 403 +explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 2 NULL 9 100.00 Using where; Using index; Using filesort +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` where ((`test`.`t1`.`a` > 40) and (`test`.`t1`.`a` < 70)) order by `b+0` +select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +a+0 b+0 +57 135 +61 152 +59 188 +68 206 +44 307 +60 343 +49 345 +56 379 +68 454 +select hex(min(a)) from t1; +hex(min(a)) +0 +select hex(min(b)) from t1; +hex(min(b)) +24 +select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1; +hex(min(a)) hex(max(a)) hex(min(b)) hex(max(b)) +0 7F 24 1F3 +drop table t1; +create table t1 (a int not null, b bit, c bit(9), key(a, b, c)) engine=innodb; +insert into t1 values +(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54), +(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34); +select a+0, b+0, c+0 from t1; +a+0 b+0 c+0 +1 1 100 +2 1 4 +23 0 1 +4 0 23 +4 0 3 +4 0 34 +4 0 54 +4 1 100 +4 NULL 1 +56 0 22 +select hex(min(b)) from t1 where a = 4; +hex(min(b)) +0 +select hex(min(c)) from t1 where a = 4 and b = 0; +hex(min(c)) +3 +select hex(max(b)) from t1; +hex(max(b)) +1 +select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2; +a+0 b+0 c+0 +4 0 3 +4 0 23 +select a+0, b+0, c+0 from t1 where a = 4 and b = 1; +a+0 b+0 c+0 +4 1 100 +select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100; +a+0 b+0 c+0 +4 1 100 +select b+0, a+0, c+0 from t1 order by b desc; +b+0 a+0 c+0 +1 1 100 +1 2 4 +1 4 100 +0 23 1 +0 4 23 +0 4 3 +0 4 34 +0 4 54 +0 56 22 +NULL 4 1 +select c+0, a+0, b+0 from t1 order by c; +c+0 a+0 b+0 +1 23 0 +1 4 NULL +3 4 0 +4 2 1 +22 56 0 +23 4 0 +34 4 0 +54 4 0 +100 1 1 +100 4 1 +drop table t1; +create table t1(a bit(2), b bit(2)) engine=innodb; +insert into t1 (a) values (0x01), (0x03), (0x02); +update t1 set b= concat(a); +select a+0, b+0 from t1; +a+0 b+0 +1 1 +3 3 +2 2 +drop table t1; +create table t1 (a bit(7), key(a)) engine=innodb; +insert into t1 values (44), (57); +select a+0 from t1; +a+0 +44 +57 +drop table t1; +create table t1 (a bit(3), b bit(12)) engine=innodb; +insert into t1 values (7,(1<<12)-2), (0x01,0x01ff); +select hex(a),hex(b) from t1; +hex(a) hex(b) +7 FFE +1 1FF +select hex(concat(a)),hex(concat(b)) from t1; +hex(concat(a)) hex(concat(b)) +07 0FFE +01 01FF +drop table t1; +create table t1(a int, b bit not null) engine=innodb; +alter table t1 add primary key (a); +drop table t1; +create table t1 (a bit, b bit(10)) engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) DEFAULT NULL, + `b` bit(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) DEFAULT NULL, + `b` bit(10) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) DEFAULT NULL, + `b` bit(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a bit(7)) engine=innodb; +insert into t1 values (0x60); +select * from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a 16 7 1 Y 32 0 63 +a +` +drop table t1; +End of 5.0 tests +# +# Bug #31564742 LOST ULLONG_MAX VALUE IN TABLE WITH TYPE OF BIT(64) +# +CREATE TABLE t1 (a BIT(64)); +INSERT INTO t1 VALUES +(b'1111111111111111111111111111111111111111111111111111111111111111'); +SELECT HEX(a) FROM t1 WHERE a = +b'1111111111111111111111111111111111111111111111111111111111111111'; +HEX(a) +FFFFFFFFFFFFFFFF +DROP TABLE t1; +# +# Bug #31019130 CASTING DOUBLE TO LONGLONG CAUSES UB +# IN FIELD_*::STORE(DOUBLE) +# +CREATE TABLE t_double (a double not null); +INSERT INTO t_double (a) VALUES +(-20000000000000000000000000000.0001), (20000000000000000000000000000.0001); +CREATE TABLE t_bit ( +b bit(3) +); +INSERT IGNORE INTO t_bit (b) SELECT a from t_double; +Warnings: +Warning 1406 Data too long for column 'b' at row 1 +Warning 1406 Data too long for column 'b' at row 2 +SELECT HEX(b) FROM t_bit; +HEX(b) +7 +7 +DROP TABLE t_double, t_bit; diff --git a/mysql-test/r/type_date.result-pq b/mysql-test/r/type_date.result-pq new file mode 100644 index 000000000..b7532cea1 --- /dev/null +++ b/mysql-test/r/type_date.result-pq @@ -0,0 +1,611 @@ +drop table if exists t1,t2; +create table t1 (a char(16), b date, c datetime); +insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01'; +select * from t1 where c = '2000-01-01'; +a b c +test 2000-01-01 2000-01-01 2000-01-01 00:00:00 +select * from t1 where b = '2000-01-01'; +a b c +test 2000-01-01 2000-01-01 2000-01-01 00:00:00 +drop table t1; +CREATE TABLE t1 (name char(6),cdate date); +INSERT INTO t1 VALUES ('name1','1998-01-01'); +INSERT INTO t1 VALUES ('name2','1998-01-01'); +INSERT INTO t1 VALUES ('name1','1998-01-02'); +INSERT INTO t1 VALUES ('name2','1998-01-02'); +CREATE TABLE t2 (cdate date, note char(6)); +INSERT INTO t2 VALUES ('1998-01-01','note01'); +INSERT INTO t2 VALUES ('1998-01-02','note02'); +select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01'; +name cdate note +name1 1998-01-01 note01 +name2 1998-01-01 note01 +drop table t1,t2; +CREATE TABLE t1 ( datum DATE ); +INSERT INTO t1 VALUES ( "2000-1-1" ); +INSERT INTO t1 VALUES ( "2000-1-2" ); +INSERT INTO t1 VALUES ( "2000-1-3" ); +INSERT INTO t1 VALUES ( "2000-1-4" ); +INSERT INTO t1 VALUES ( "2000-1-5" ); +SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date); +datum +2000-01-02 +2000-01-03 +2000-01-04 +SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY; +datum +DROP TABLE t1; +CREATE TABLE t1 ( +user_id char(10), +summa int(11), +rdate date +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('aaa',100,'1998-01-01'); +INSERT INTO t1 VALUES ('aaa',200,'1998-01-03'); +INSERT INTO t1 VALUES ('bbb',50,'1998-01-02'); +INSERT INTO t1 VALUES ('bbb',200,'1998-01-04'); +select max(rdate) as s from t1 where rdate < '1998-01-03' having s> "1998-01-01"; +s +1998-01-02 +select max(rdate) as s from t1 having s="1998-01-04"; +s +1998-01-04 +select max(rdate+0) as s from t1 having s="19980104"; +s +19980104 +drop table t1; +create table t1 (date date); +insert into t1 values ("2000-08-10"),("2000-08-11"); +select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1; +date_add(date,INTERVAL 1 DAY) date_add(date,INTERVAL 1 SECOND) +2000-08-11 2000-08-10 00:00:01 +2000-08-12 2000-08-11 00:00:01 +drop table t1; +CREATE TABLE t1(AFIELD INT); +INSERT INTO t1 VALUES(1); +CREATE TABLE t2(GMT VARCHAR(32)); +INSERT INTO t2 VALUES('GMT-0800'); +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1, t2 GROUP BY t1.AFIELD; +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +Wed, 06 March 2002 10:11:12 GMT-0800 +INSERT INTO t1 VALUES(1); +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)), +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1,t2 GROUP BY t1.AFIELD; +DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +Wed, 06 March 2002 10:11:12 GMT-0800 Wed, 06 March 2002 10:11:12 GMT-0800 +drop table t1,t2; +CREATE TABLE t1 (f1 time default NULL, f2 time default NULL); +INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00'); +SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1; +DATE_FORMAT(f1, "%l.%i %p") DATE_FORMAT(f2, "%l.%i %p") +9.00 AM 12.00 PM +DROP TABLE t1; +CREATE TABLE t1 (f1 DATE); +CREATE TABLE t2 (f2 VARCHAR(8)); +CREATE TABLE t3 (f2 CHAR(8)); +INSERT INTO t1 VALUES ('1978-11-26'); +INSERT INTO t2 SELECT f1+0 FROM t1; +INSERT INTO t2 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1; +INSERT INTO t3 SELECT f1+0 FROM t1 UNION SELECT f1+0 FROM t1; +SELECT * FROM t2; +f2 +19781126 +19781126 +SELECT * FROM t3; +f2 +19781126 +19781126 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (y YEAR); +INSERT IGNORE INTO t1 VALUES ('abc'); +Warnings: +Warning 1366 Incorrect integer value: 'abc' for column 'y' at row 1 +SELECT * FROM t1; +y +0000 +DROP TABLE t1; +create table t1(start_date date, end_date date); +insert into t1 values ('2000-01-01','2000-01-02'); +select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date; +1 +1 +drop table t1; +select @d:=1111; +@d:=1111 +1111 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select year(@d), month(@d), day(@d), cast(@d as date); +year(@d) month(@d) day(@d) cast(@d as date) +2000 11 11 2000-11-11 +select @d:=011111; +@d:=011111 +11111 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select year(@d), month(@d), day(@d), cast(@d as date); +year(@d) month(@d) day(@d) cast(@d as date) +2001 11 11 2001-11-11 +select @d:=1311; +@d:=1311 +1311 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select year(@d), month(@d), day(@d), cast(@d as date); +year(@d) month(@d) day(@d) cast(@d as date) +NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '1311' +Warning 1292 Incorrect datetime value: '1311' +Warning 1292 Incorrect datetime value: '1311' +Warning 1292 Incorrect datetime value: '1311' +create table t1 (d date , dt datetime , ts timestamp); +insert ignore into t1 values (9912101,9912101,9912101); +Warnings: +Warning 1265 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'dt' at row 1 +Warning 1265 Data truncated for column 'ts' at row 1 +insert into t1 values (11111,11111,11111); +select * from t1; +d dt ts +0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 +2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00 +drop table t1; +SET sql_mode='STRICT_TRANS_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 ( +a INT +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); +SELECT str_to_date( '', a ) FROM t1; +str_to_date( '', a ) +0000-00-00 00:00:00.000000 +NULL +DROP TABLE t1; +SET sql_mode=default; +CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (DATE(NOW()), 1); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where multiple equal(now(), `test`.`t1`.`a`) +INSERT INTO t1 VALUES (DATE(NOW()), 2); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where multiple equal(now(), `test`.`t1`.`a`) +SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +COUNT(*) +0 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +ALTER TABLE t1 DROP PRIMARY KEY; +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`a` = (now())) +DROP TABLE t1; +CREATE TABLE t1 (a DATE); +CREATE TABLE t2 (a DATE); +CREATE INDEX i ON t1 (a); +INSERT IGNORE INTO t1 VALUES ('0000-00-00'),('0000-00-00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +INSERT IGNORE INTO t2 VALUES ('0000-00-00'),('0000-00-00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +SET sql_mode = 'ALLOW_INVALID_DATES'; +SELECT * FROM t1 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +SELECT * FROM t2 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +SET SQL_MODE=TRADITIONAL; +EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00'; +ERROR HY000: Incorrect DATE value: '0000-00-00' +SELECT * FROM t1 WHERE a = '0000-00-00'; +ERROR HY000: Incorrect DATE value: '0000-00-00' +SELECT * FROM t2 WHERE a = '0000-00-00'; +ERROR HY000: Incorrect DATE value: '0000-00-00' +INSERT INTO t1 VALUES ('0000-00-00'); +ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1 +SET SQL_MODE=DEFAULT; +DROP TABLE t1,t2; +SET sql_mode = 'ALLOW_INVALID_DATES'; +CREATE TABLE t1 (a DATE); +CREATE TABLE t2 (a DATE); +CREATE INDEX i ON t1 (a); +INSERT IGNORE INTO t1 VALUES ('1000-00-00'),('1000-00-00'); +INSERT IGNORE INTO t2 VALUES ('1000-00-00'),('1000-00-00'); +SELECT * FROM t1 WHERE a = '1000-00-00'; +a +1000-00-00 +1000-00-00 +SELECT * FROM t2 WHERE a = '1000-00-00'; +a +1000-00-00 +1000-00-00 +SET SQL_MODE=TRADITIONAL; +EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00'; +ERROR HY000: Incorrect DATE value: '1000-00-00' +SELECT * FROM t1 WHERE a = '1000-00-00'; +ERROR HY000: Incorrect DATE value: '1000-00-00' +SELECT * FROM t2 WHERE a = '1000-00-00'; +ERROR HY000: Incorrect DATE value: '1000-00-00' +INSERT INTO t1 VALUES ('1000-00-00'); +ERROR 22007: Incorrect date value: '1000-00-00' for column 'a' at row 1 +SET SQL_MODE=DEFAULT; +DROP TABLE t1,t2; +CREATE TABLE t1 SELECT curdate() AS f1; +SELECT hour(f1), minute(f1), second(f1) FROM t1; +hour(f1) minute(f1) second(f1) +0 0 0 +DROP TABLE t1; +End of 5.0 tests +create table t1 (a date, primary key (a))engine=memory; +insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 2 +select * from t1 where a between '0000-00-01' and '0000-00-02'; +a +0000-00-00 +Warnings: +Warning 1292 Incorrect date value: '0000-00-01' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-02' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-01' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-02' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-01' for column 'a' at row 2 +Warning 1292 Incorrect date value: '0000-00-02' for column 'a' at row 2 +drop table t1; +# +# Bug#50918: Date columns treated differently in Views than in Base +# Tables +# +CREATE TABLE t1 ( the_date DATE, the_time TIME ); +INSERT INTO t1 VALUES ( '2010-01-01', '01:01:01' ); +SELECT * FROM t1 t11 JOIN t1 t12 ON addtime( t11.the_date, t11.the_time ) = +addtime( t12.the_date, t12.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = +addtime( v1.the_date, v1.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = +addtime( cast(v1.the_date AS DATETIME), v1.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#59685 crash in String::length with date types +# +CREATE TABLE t1(a DATE, b YEAR, KEY(a)); +INSERT INTO t1 VALUES ('2011-01-01',2011); +SELECT b = CONVERT(a, DATE) FROM t1; +b = CONVERT(a, DATE) +0 +SELECT b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a) FROM t1; +b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a) +0 +SELECT b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE) FROM t1; +b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE) +0 +DROP TABLE t1; +End of 5.1 tests +# +# Bug #33629: last_day function can return null, but has 'not null' +# flag set for result +# +SELECT 1 FROM (SELECT LAST_DAY('0')) a; +1 +1 +Warnings: +Warning 1292 Incorrect datetime value: '0' +SELECT 1 FROM (SELECT MAKEDATE(2011,0)) a; +1 +1 +CREATE TABLE t1 AS +SELECT LAST_DAY('1970-01-01') AS f1, +MAKEDATE(1970, 1) AS f2; +DESCRIBE t1; +Field Type Null Key Default Extra +f1 date YES NULL +f2 date YES NULL +DROP TABLE t1; +# +# +# Bug#57278: Crash on min/max + with date out of range. +# +set @a=(select min(makedate('111','1'))) ; +select @a; +@a +0111-01-01 +# +# +# WL#946: testing rounding from DATETIME/TIME to DATE +# +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01 23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '2001-01-01 23:59:59.4' for column 'a' at row 1 +INSERT INTO t1 VALUES (TIMESTAMP'2001-01-01 23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '2001-01-01 23:59:59' for column 'a' at row 1 +INSERT INTO t1 VALUES (20010101235959.4); +Warnings: +Note 1292 Incorrect date value: '20010101235959.4' for column 'a' at row 1 +INSERT INTO t1 VALUES (TIME'23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '23:59:59' for column 'a' at row 1 +INSERT INTO t1 VALUES +(TIMESTAMP'9999-12-30 23:59:59.4'), +(TIMESTAMP'9999-12-31 23:59:59.4'); +Warnings: +Note 1292 Incorrect date value: '9999-12-30 23:59:59' for column 'a' at row 1 +Note 1292 Incorrect date value: '9999-12-31 23:59:59' for column 'a' at row 2 +SELECT * FROM t1; +a +2001-01-01 +2001-01-01 +2001-01-01 +2001-01-01 +9999-12-30 +9999-12-31 +DROP TABLE t1; +SET timestamp=DEFAULT; +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('2001-01-01 23:59:59.9'); +INSERT INTO t1 VALUES (TIMESTAMP'2001-01-01 23:59:59.9'); +INSERT INTO t1 VALUES (20010101235959.9); +INSERT INTO t1 VALUES (TIME'23:59:59.9'); +INSERT INTO t1 VALUES +(TIMESTAMP'9999-12-30 23:59:59.9'), +(TIMESTAMP'9999-12-31 23:59:59.9'); +ERROR 22008: Datetime function: datetime field overflow +SELECT * FROM t1; +a +2001-01-02 +2001-01-02 +2001-01-02 +2001-01-02 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing cast from DECIMAL to DATE +# +CREATE TABLE t1 (a DECIMAL(23,4)); +INSERT INTO t1 VALUES (NULL),(101010.9999),(-101010.9999); +SELECT a, CAST(a AS DATE) FROM t1; +a CAST(a AS DATE) +NULL NULL +101010.9999 2010-10-10 +-101010.9999 NULL +Warnings: +Warning 1292 Incorrect datetime value: '-101010.9999' +DROP TABLE t1; +# +# Testing CASE with DATE type without a found item +# +SELECT CAST(CASE WHEN 0 THEN '2001-01-01' END AS DATE); +CAST(CASE WHEN 0 THEN '2001-01-01' END AS DATE) +NULL +SELECT CAST(CASE WHEN 0 THEN DATE'2001-01-01' END AS DATE); +CAST(CASE WHEN 0 THEN DATE'2001-01-01' END AS DATE) +NULL +# +# Testing DATE field with NULL value with NOT IN +# +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 WHERE a NOT IN (DATE'2001-01-01',DATE'2002-02-02'); +a +DROP TABLE t1; +# +# Testing COALESCE with DATE type without a found item +# +SELECT COALESCE(DATE(NULL)); +COALESCE(DATE(NULL)) +NULL +# +# Testing Item_func_min_max::val_str when DATE type and NULL +# +SELECT CAST(LEAST(DATE(NULL), DATE(NULL)) AS CHAR); +CAST(LEAST(DATE(NULL), DATE(NULL)) AS CHAR) +NULL +# +# Testing Item_func_min_max::get_date with non-temporal arguments +# +SELECT CAST(LEAST(20010101,20020202) AS DATE); +CAST(LEAST(20010101,20020202) AS DATE) +2001-01-01 +# +# Item::get_date_from_numeric +# +SELECT CAST(SUM(0) AS DATETIME); +CAST(SUM(0) AS DATETIME) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '0' +SELECT CAST(SUM(0 + 0e0) AS DATETIME); +CAST(SUM(0 + 0e0) AS DATETIME) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '0' +SET timestamp=1322115004; +SELECT CAST(UNIX_TIMESTAMP() AS DATE); +CAST(UNIX_TIMESTAMP() AS DATE) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '1322115004' +SET timestamp=DEFAULT; +# +# Item::get_date_from_non_temporal +# +SELECT DATE(20110512154559.6 + 0e0); +DATE(20110512154559.6 + 0e0) +2011-05-12 +# +# Item_name_const::get_date +# +SELECT DATE(NAME_CONST('a', 0)); +DATE(NAME_CONST('a', 0)) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '0' +# +# Item_cache_datetime::get_date +# +SET timestamp=UNIX_TIMESTAMP('2011-11-24'); +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (0); +SELECT DATE(MIN(a)) FROM t1; +DATE(MIN(a)) +2011-11-24 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Bug #13626019 DIFFERENCE IN OUTPUT BETWEEN 5.1 & 5.5 FOR A LAST_DAY IS +# NULL SELECT QUERY +# +CREATE TABLE t1(a INT) ENGINE=InnoDB; +CREATE TABLE t2(b CHAR(19)); +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES('0000-00-00 00:00:00'); +SELECT * FROM t1 WHERE LAST_DAY('0000-00-00 00:00:00') IS NULL; +a +1 +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' +SELECT * FROM t1 WHERE +LAST_DAY((SELECT b FROM t2 WHERE b = '0000-00-00 00:00:00')) IS NULL; +a +1 +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' +DROP TABLE t1,t2; +# +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE IF EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode with NO_ZERO_IN_DATE/NO_ZERO_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATE DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 DATE DEFAULT '0000-00-00'); +ERROR 42000: Invalid default value for 'c1' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATE DEFAULT '2012-02-00'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATE DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 DATE DEFAULT '0000-00-00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t3 (c1 DATE DEFAULT '2012-02-00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 DATE DEFAULT 0); +CREATE TABLE t2 (c1 DATE DEFAULT '0000-00-00'); +CREATE TABLE t3 (c1 DATE DEFAULT '2012-02-00'); +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 INT); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATE DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 DATE DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATE DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATE DEFAULT 0; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +ALTER TABLE t1 ADD c3 DATE DEFAULT '0000-00-00'; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c4 DATE DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +CREATE TABLE t1 (c1 int); +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 DATE DEFAULT 0; +ALTER TABLE t1 ADD c3 DATE DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 DATE DEFAULT '2012-02-00'; +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +End of 5.6 tests +CREATE TABLE t1(a int); +INSERT INTO t1 VALUE(15.00+adddate('2011-00-00', 1)); +ERROR 22007: Incorrect datetime value: '2011-00-00' +DROP TABLE t1; diff --git a/mysql-test/r/type_datetime.result-pq b/mysql-test/r/type_datetime.result-pq new file mode 100644 index 000000000..a5323b1c8 --- /dev/null +++ b/mysql-test/r/type_datetime.result-pq @@ -0,0 +1,989 @@ +drop table if exists t1; +create table t1 (t datetime) ENGINE=InnoDB; +insert ignore into t1 values (101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030100000000),(20030000000000); +Warnings: +Warning 1265 Data truncated for column 't' at row 13 +Warning 1265 Data truncated for column 't' at row 14 +select * from t1; +t +2000-01-01 00:00:00 +2069-12-31 00:00:00 +1970-01-01 00:00:00 +1999-12-31 00:00:00 +1000-01-01 00:00:00 +9999-12-31 00:00:00 +2000-01-01 00:00:00 +2069-12-31 00:00:00 +1970-01-01 00:00:00 +1999-12-31 23:59:59 +1000-01-01 00:00:00 +9999-12-31 23:59:59 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +delete from t1 where t > 0; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +delete from t1; +insert ignore into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000"); +Warnings: +Warning 1264 Out of range value for column 't' at row 14 +Warning 1264 Out of range value for column 't' at row 15 +insert into t1 values ("2003-003-03"); +insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01"); +select * from t1; +t +2000-01-01 00:00:00 +2069-12-31 00:00:00 +1970-01-01 00:00:00 +1999-12-31 00:00:00 +0000-01-01 00:00:00 +0001-01-01 00:00:00 +9999-12-31 00:00:00 +2000-10-10 00:00:00 +2069-12-31 00:00:00 +1970-01-01 00:00:00 +1999-12-31 23:59:59 +1000-01-01 00:00:00 +9999-12-31 23:59:59 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +2003-03-03 00:00:00 +2003-01-02 13:14:15 +2001-01-01 01:01:01 +2001-01-01 01:01:01 +truncate table t1; +insert ignore into t1 values("2003-0303 12:13:14"); +Warnings: +Warning 1265 Data truncated for column 't' at row 1 +select * from t1; +t +0000-00-00 00:00:00 +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b date, c time, d datetime); +insert into t1 (b,c,d) values(now(),curtime(),now()); +Warnings: +Note 1265 Data truncated for column 'b' at row 1 +select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1; +date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0 +1 1 1 +drop table t1; +SET sql_mode = default; +CREATE TABLE t1 (a datetime not null); +insert ignore into t1 values (0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +select * from t1 where a is null; +a +0000-00-00 00:00:00 +drop table t1; +create table t1 (id int, dt datetime); +insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30"); +select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15'); +id dt +1 2001-08-14 00:00:00 +create index dt on t1 (dt); +select * from t1 where dt > 20021020; +id dt +4 2003-09-15 01:20:30 +select * from t1 ignore index (dt) where dt > 20021020; +id dt +4 2003-09-15 01:20:30 +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (t datetime); +insert into t1 values (20030102030460),(20030102036301),(20030102240401), +(20030132030401),(20031302030401),(100001202030401); +Warnings: +Warning 1265 Data truncated for column 't' at row 1 +Warning 1265 Data truncated for column 't' at row 2 +Warning 1265 Data truncated for column 't' at row 3 +Warning 1265 Data truncated for column 't' at row 4 +Warning 1265 Data truncated for column 't' at row 5 +Warning 1264 Out of range value for column 't' at row 6 +select * from t1; +t +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +delete from t1; +insert into t1 values +("2003-01-02 03:04:60"),("2003-01-02 03:63:01"),("2003-01-02 24:04:01"), +("2003-01-32 03:04:01"),("2003-13-02 03:04:01"), ("10000-12-02 03:04:00"); +Warnings: +Warning 1265 Data truncated for column 't' at row 1 +Warning 1265 Data truncated for column 't' at row 2 +Warning 1265 Data truncated for column 't' at row 3 +Warning 1265 Data truncated for column 't' at row 4 +Warning 1265 Data truncated for column 't' at row 5 +Warning 1265 Data truncated for column 't' at row 6 +select * from t1; +t +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +delete from t1; +insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); +Warnings: +Warning 1265 Data truncated for column 't' at row 1 +Warning 1265 Data truncated for column 't' at row 2 +select * from t1 order by t; +t +0000-00-00 00:00:00 +2003-01-01 00:00:00 +drop table t1; +create table t1 (dt datetime); +insert into t1 values ("12-00-00"), ("00-00-00 01:00:00"); +insert into t1 values ("00-00-00"), ("00-00-00 00:00:00"); +select * from t1; +dt +2012-00-00 00:00:00 +2000-00-00 01:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +drop table t1; +SET sql_mode = default; +select cast('2006-12-05 22:10:10' as datetime) + 0; +cast('2006-12-05 22:10:10' as datetime) + 0 +20061205221010 +CREATE TABLE t1(a DATETIME NOT NULL); +INSERT INTO t1 VALUES ('20060606155555'); +SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555"); +a +2006-06-06 15:55:55 +PREPARE s FROM 'SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555")'; +EXECUTE s; +a +2006-06-06 15:55:55 +DROP PREPARE s; +DROP TABLE t1; +SELECT CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6)); +CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6)) +20060810.000000 +SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6)); +CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6)) +20060810101112.000000 +SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6)); +CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6)) +20060810101112.000014 +SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)); +CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6)) +101112.000000 +set @org_mode=@@sql_mode; +create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03'); +Warnings: +Note 1292 Incorrect date value: '1962-03-03 23:33:34' for column 'da' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `da` date DEFAULT '1962-03-03', + `dt` datetime DEFAULT '1962-03-03 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (); +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +Warnings: +Note 1292 Incorrect date value: '2007-03-23 13:49:38' for column 'da' at row 1 +set @@sql_mode='ansi,traditional'; +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +Warnings: +Note 1292 Incorrect date value: '2007-03-23 13:49:38' for column 'da' at row 1 +insert into t1 set dt='2007-03-23 13:49:38',da=dt; +Warnings: +Note 1292 Incorrect date value: '2007-03-23 13:49:38' for column 'da' at row 1 +insert into t1 values ('2007-03-32','2007-03-23 13:49:38'); +ERROR 22007: Incorrect date value: '2007-03-32' for column 'da' at row 1 +select * from t1; +da dt +1962-03-03 1962-03-03 00:00:00 +2007-03-23 2007-03-23 13:49:38 +2007-03-23 2007-03-23 13:49:38 +2007-03-23 2007-03-23 13:49:38 +drop table t1; +create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03'); +ERROR 42000: Invalid default value for 'da' +create table t1 (t time default '916:00:00 a'); +ERROR 42000: Invalid default value for 't' +set @@sql_mode= @org_mode; +create table t1 (f1 date, f2 datetime, f3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1(f1) values(curdate()); +select curdate() < now(), f1 < now(), cast(f1 as date) < now() from t1; +curdate() < now() f1 < now() cast(f1 as date) < now() +1 1 1 +delete from t1; +insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01'); +insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01'); +insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01'); +insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00'); +insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01'); +select f1, f3 from t1 where f1 >= '2001-02-05 00:00:00' and f3 <= '2001-04-15'; +f1 f3 +2001-02-05 2001-02-05 01:01:01 +2001-03-10 2001-03-10 01:01:01 +2001-04-15 2001-04-15 00:00:00 +select f1, f3 from t1 where f1 >= '2001-2-5 0:0:0' and f2 <= '2001-4-15'; +f1 f3 +2001-02-05 2001-02-05 01:01:01 +2001-03-10 2001-03-10 01:01:01 +2001-04-15 2001-04-15 00:00:00 +select f1, f2 from t1 where if(1, f1, 0) >= f2; +f1 f2 +2001-02-05 2001-02-05 00:00:00 +2001-03-10 2001-03-09 01:01:01 +2001-04-15 2001-04-15 00:00:00 +select 1 from dual where cast('2001-1-1 2:3:4' as date) = cast('2001-01-01' as datetime); +1 +1 +select f1, f2, f1 > f2, f1 = f2, f1 < f2 from t1; +f1 f2 f1 > f2 f1 = f2 f1 < f2 +2001-01-01 2001-01-01 01:01:01 0 0 1 +2001-02-05 2001-02-05 00:00:00 0 1 0 +2001-03-10 2001-03-09 01:01:01 1 0 0 +2001-04-15 2001-04-15 00:00:00 0 1 0 +2001-05-20 2001-05-20 01:01:01 0 0 1 +drop table t1; +create table t1 (f1 date, f2 datetime, f3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values('2001-01-01','2001-01-01 01:01:01','2001-01-01 01:01:01'); +insert into t1 values('2001-02-05','2001-02-05 00:00:00','2001-02-05 01:01:01'); +insert into t1 values('2001-03-10','2001-03-09 01:01:01','2001-03-10 01:01:01'); +insert into t1 values('2001-04-15','2001-04-15 00:00:00','2001-04-15 00:00:00'); +insert into t1 values('2001-05-20','2001-05-20 01:01:01','2001-05-20 01:01:01'); +select f2 from t1 where f2 between '2001-2-5' and '01-04-14'; +f2 +2001-02-05 00:00:00 +2001-03-09 01:01:01 +select f1, f2, f3 from t1 where f1 between f2 and f3; +f1 f2 f3 +2001-02-05 2001-02-05 00:00:00 2001-02-05 01:01:01 +2001-03-10 2001-03-09 01:01:01 2001-03-10 01:01:01 +2001-04-15 2001-04-15 00:00:00 2001-04-15 00:00:00 +select f1, f2, f3 from t1 where cast(f1 as datetime) between f2 and +cast(f3 as date); +f1 f2 f3 +2001-02-05 2001-02-05 00:00:00 2001-02-05 01:01:01 +2001-03-10 2001-03-09 01:01:01 2001-03-10 01:01:01 +2001-04-15 2001-04-15 00:00:00 2001-04-15 00:00:00 +select f2 from t1 where '2001-04-10 12:34:56' between f2 and '01-05-01'; +f2 +2001-01-01 01:01:01 +2001-02-05 00:00:00 +2001-03-09 01:01:01 +select f2, f3 from t1 where '01-03-10' between f2 and f3; +f2 f3 +2001-03-09 01:01:01 2001-03-10 01:01:01 +select f2 from t1 where DATE(f2) between "2001-4-15" AND "01-4-15"; +f2 +2001-04-15 00:00:00 +SELECT 1 from dual where NOW() BETWEEN CURRENT_DATE() - INTERVAL 1 DAY AND CURRENT_DATE(); +1 +drop table t1; +create table t1 (f1 date); +insert into t1 values('01-01-01'),('01-01-02'),('01-01-03'); +select * from t1 where f1 in ('01-01-01','2001-01-02','2001-01-03 00:00:00'); +f1 +2001-01-01 +2001-01-02 +2001-01-03 +create table t2(f2 datetime); +insert into t2 values('01-01-01 00:00:00'),('01-02-03 12:34:56'),('02-04-06 11:22:33'); +select * from t2 where f2 in ('01-01-01','01-02-03 12:34:56','01-02-03'); +f2 +2001-01-01 00:00:00 +2001-02-03 12:34:56 +select * from t1,t2 where '01-01-02' in (f1, cast(f2 as date)); +f1 f2 +2001-01-02 2001-01-01 00:00:00 +2001-01-02 2001-02-03 12:34:56 +2001-01-02 2002-04-06 11:22:33 +select * from t1,t2 where '01-01-01' in (f1, '01-02-03'); +f1 f2 +2001-01-01 2001-01-01 00:00:00 +2001-01-01 2001-02-03 12:34:56 +2001-01-01 2002-04-06 11:22:33 +select * from t1,t2 where if(1,'01-02-03 12:34:56','') in (f1, f2); +f1 f2 +2001-01-01 2001-02-03 12:34:56 +2001-01-02 2001-02-03 12:34:56 +2001-01-03 2001-02-03 12:34:56 +create table t3(f3 varchar(20)); +insert into t3 select * from t2; +select * from t2,t3 where f2 in (f3,'03-04-05'); +f2 f3 +2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-02-03 12:34:56 2001-02-03 12:34:56 +2002-04-06 11:22:33 2002-04-06 11:22:33 +select f1,f2,f3 from t1,t2,t3 where (f1,'1') in ((f2,'1'),(f3,'1')) order by f1,f2,f3; +f1 f2 f3 +2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00 +2001-01-01 2001-01-01 00:00:00 2001-02-03 12:34:56 +2001-01-01 2001-01-01 00:00:00 2002-04-06 11:22:33 +2001-01-01 2001-02-03 12:34:56 2001-01-01 00:00:00 +2001-01-01 2002-04-06 11:22:33 2001-01-01 00:00:00 +select f1 from t1 where ('1',f1) in (('1','01-01-01'),('1','2001-1-1 0:0:0'),('1','02-02-02')); +f1 +2001-01-01 +drop table t1,t2,t3; +select least(cast('01-01-01' as date), '01-01-02'); +least(cast('01-01-01' as date), '01-01-02') +2001-01-01 +select greatest(cast('01-01-01' as date), '01-01-02'); +greatest(cast('01-01-01' as date), '01-01-02') +2001-01-02 +select least(cast('01-01-01' as date), '01-01-02') + 0; +least(cast('01-01-01' as date), '01-01-02') + 0 +20010101 +select greatest(cast('01-01-01' as date), '01-01-02') + 0; +greatest(cast('01-01-01' as date), '01-01-02') + 0 +20010102 +select least(cast('01-01-01' as datetime), '01-01-02') + 0; +least(cast('01-01-01' as datetime), '01-01-02') + 0 +20010101000000 +select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed); +cast(least(cast('01-01-01' as datetime), '01-01-02') as signed) +20010101000000 +select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2)); +cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2)) +20010101000000.00 +DROP PROCEDURE IF EXISTS test27759 ; +CREATE PROCEDURE test27759() +BEGIN +declare v_a date default '2007-4-10'; +declare v_b date default '2007-4-11'; +declare v_c datetime default '2004-4-9 0:0:0'; +select v_a as a,v_b as b, +least( v_a, v_b ) as a_then_b, +least( v_b, v_a ) as b_then_a, +least( v_c, v_a ) as c_then_a; +END;| +call test27759(); +a b a_then_b b_then_a c_then_a +2007-04-10 2007-04-11 2007-04-10 2007-04-10 2004-04-09 00:00:00 +drop procedure test27759; +create table t1 (f1 date); +insert into t1 values (curdate()); +select left(f1,10) = curdate() from t1; +left(f1,10) = curdate() +1 +drop table t1; +create table t1(f1 date); +insert into t1 values('01-01-01'),('02-02-02'),('01-01-01'),('02-02-02'); +set @bug28261=''; +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +if(@bug28261 = f1, '', @bug28261:= f1) +2001-01-01 +2002-02-02 +2001-01-01 +2002-02-02 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1292 Incorrect datetime value: '' +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +if(@bug28261 = f1, '', @bug28261:= f1) +2001-01-01 +2002-02-02 +2001-01-01 +2002-02-02 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +if(@bug28261 = f1, '', @bug28261:= f1) +2001-01-01 +2002-02-02 +2001-01-01 +2002-02-02 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +create table t1(f1 datetime); +insert into t1 values('2001-01-01'),('2002-02-02'); +select * from t1 where f1 between 20020101 and 20070101000000; +f1 +2002-02-02 00:00:00 +select * from t1 where f1 between 2002010 and 20070101000000; +f1 +2001-01-01 00:00:00 +2002-02-02 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 1 +Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 1 +Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 1 +select * from t1 where f1 between 20020101 and 2007010100000; +f1 +Warnings: +Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 +Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 +Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 +drop table t1; +# +# Bug#27216: functions with parameters of different date types may +# return wrong type of the result. +# +create table t1 (f1 date, f2 datetime, f3 varchar(20)); +create table t2 as select coalesce(f1,f1) as f4 from t1; +desc t2; +Field Type Null Key Default Extra +f4 date YES NULL +create table t3 as select coalesce(f1,f2) as f4 from t1; +desc t3; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t4 as select coalesce(f2,f2) as f4 from t1; +desc t4; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t5 as select coalesce(f1,f3) as f4 from t1; +desc t5; +Field Type Null Key Default Extra +f4 varchar(20) YES NULL +create table t6 as select coalesce(f2,f3) as f4 from t1; +desc t6; +Field Type Null Key Default Extra +f4 varchar(20) YES NULL +create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1; +desc t7; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t8 as select coalesce(cast('01-01-01' as datetime),f2) as f4 +from t1; +desc t8; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t9 as select case when 1 then cast('01-01-01' as date) +when 0 then cast('01-01-01' as date) end as f4 from t1; +desc t9; +Field Type Null Key Default Extra +f4 date YES NULL +create table t10 as select case when 1 then cast('01-01-01' as datetime) +when 0 then cast('01-01-01' as datetime) end as f4 from t1; +desc t10; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t11 as select if(1, cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t11; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t12 as select least(cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t12; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t13 as select ifnull(cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t13; +Field Type Null Key Default Extra +f4 datetime YES NULL +drop tables t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13; +################################################################### +create table t1 (f1 time); +insert into t1 set f1 = '45:44:44'; +insert into t1 set f1 = '15:44:44'; +select * from t1 where (convert(f1,datetime)) != 1; +f1 +45:44:44 +15:44:44 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (), (), (); +select sum(a) from t1 group by convert(a, datetime); +sum(a) +NULL +drop table t1; +create table t1 (id int(10) not null, cur_date datetime not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (id int(10) not null, cur_date date not null); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22'); +insert into t2 (id, cur_date) values (1, '2007-04-25'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY x1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where (`test`.`t1`.`id`,(/* select#2 */ select `test`.`x1`.`id` from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = TIMESTAMP'0000-00-00 00:00:00') and ((`test`.`t1`.`id`) = `test`.`x1`.`id`)))) +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id cur_date +explain +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY x1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where (`test`.`t2`.`id`,(/* select#2 */ select `test`.`x1`.`id` from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = DATE'0000-00-00') and ((`test`.`t2`.`id`) = `test`.`x1`.`id`)))) +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id cur_date +insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22'); +insert into t2 (id, cur_date) values (2, '2007-04-26'); +explain +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY x1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where (`test`.`t1`.`id`,(/* select#2 */ select `test`.`x1`.`id` from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = TIMESTAMP'0000-00-00 00:00:00') and ((`test`.`t1`.`id`) = `test`.`x1`.`id`)))) +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id cur_date +explain +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY x1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where (`test`.`t2`.`id`,(/* select#2 */ select `test`.`x1`.`id` from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = DATE'0000-00-00') and ((`test`.`t2`.`id`) = `test`.`x1`.`id`)))) +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id cur_date +set @@optimizer_switch=default; +drop table t1,t2; +SELECT +CAST('NULL' AS DATE) <=> CAST('2008-01-01' AS DATE) n1, +CAST('2008-01-01' AS DATE) <=> CAST('NULL' AS DATE) n2, +CAST('NULL' AS DATE) <=> CAST('NULL' AS DATE) n3, +CAST('NULL' AS DATE) <> CAST('2008-01-01' AS DATE) n4, +CAST('2008-01-01' AS DATE) <> CAST('NULL' AS DATE) n5, +CAST('NULL' AS DATE) <> CAST('NULL' AS DATE) n6, +CAST('NULL' AS DATE) < CAST('2008-01-01' AS DATE) n7, +CAST('2008-01-01' AS DATE) < CAST('NULL' AS DATE) n8, +CAST('NULL' AS DATE) < CAST('NULL' AS DATE) n9; +n1 n2 n3 n4 n5 n6 n7 n8 n9 +0 0 1 NULL NULL NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +Warning 1292 Incorrect datetime value: 'NULL' +End of 5.0 tests +set @org_mode=@@sql_mode; +create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03'); +Warnings: +Note 1292 Incorrect date value: '1962-03-03 23:33:34' for column 'da' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `da` date DEFAULT '1962-03-03', + `dt` datetime DEFAULT '1962-03-03 00:00:00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (); +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +Warnings: +Note 1292 Incorrect date value: '2007-03-23 13:49:38' for column 'da' at row 1 +set @@sql_mode='ansi,traditional'; +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +Warnings: +Note 1292 Incorrect date value: '2007-03-23 13:49:38' for column 'da' at row 1 +insert into t1 set dt='2007-03-23 13:49:38',da=dt; +Warnings: +Note 1292 Incorrect date value: '2007-03-23 13:49:38' for column 'da' at row 1 +insert into t1 values ('2007-03-32','2007-03-23 13:49:38'); +ERROR 22007: Incorrect date value: '2007-03-32' for column 'da' at row 1 +select * from t1; +da dt +1962-03-03 1962-03-03 00:00:00 +2007-03-23 2007-03-23 13:49:38 +2007-03-23 2007-03-23 13:49:38 +2007-03-23 2007-03-23 13:49:38 +drop table t1; +create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03'); +ERROR 42000: Invalid default value for 'da' +create table t1 (t time default '916:00:00 a'); +ERROR 42000: Invalid default value for 't' +set @@sql_mode= @org_mode; +SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7)); +CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7)) +20060810101112.0000000 +SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7)); +CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7)) +20060810101112.0000000 +SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7)); +CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7)) +20060810101112.0000000 +SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7)); +CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7)) +20080729104251.0000000 +# +# Bug#59173: Failure to handle DATE(TIME) values where Year, Month or +# Day is ZERO +# +CREATE TABLE t1 (dt1 DATETIME); +INSERT IGNORE INTO t1 (dt1) VALUES ('0000-00-01 00:00:01'); +Warnings: +Warning 1264 Out of range value for column 'dt1' at row 1 +DELETE IGNORE FROM t1 WHERE dt1 = '0000-00-01 00:00:01'; +ERROR HY000: Incorrect DATETIME value: '0000-00-01 00:00:01' +# Should be empty +SELECT * FROM t1; +dt1 +0000-00-00 00:00:00 +DROP TABLE t1; +End of 5.1 tests +# +# Start of 5.5 tests +# +# +# Bug#52849 datetime index not work +# +CREATE TABLE t1 (Id INT, AtTime DATETIME, KEY AtTime (AtTime)); +SET NAMES CP850; +INSERT INTO t1 VALUES (1,'2010-04-12 22:30:12'), (2,'2010-04-12 22:30:12'), (3,'2010-04-12 22:30:12'); +EXPLAIN SELECT * FROM t1 FORCE INDEX(attime) WHERE AtTime = '2010-02-22 18:40:07'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref AtTime AtTime 6 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`Id` AS `Id`,`test`.`t1`.`AtTime` AS `AtTime` from `test`.`t1` FORCE INDEX (`attime`) where (`test`.`t1`.`AtTime` = TIMESTAMP'2010-02-22 18:40:07') +DROP TABLE t1; +SET NAMES latin1; +# +# Bug#56271: Wrong comparison result with STR_TO_DATE function +# +CREATE TABLE t1 ( +`year` int(4) NOT NULL, +`month` int(2) NOT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (2010,3),(2010,4),(2009,8),(2008,9); +SELECT * +FROM t1 +WHERE STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') >= +STR_TO_DATE('1/1/2010', '%m/%d/%Y'); +year month +2010 3 +2010 4 +create table t2(f1 datetime primary key); +insert into t2 select STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') from t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y'); +f1 +2010-04-01 00:00:00 +t2 should be const +explain select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL const PRIMARY PRIMARY 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '2010-04-01 00:00:00' AS `f1` from `test`.`t2` where true +DROP TABLE t1,t2; +# +# Bug#57095: Wrongly chosen expression cache type led to a wrong +# result. +# +CREATE TABLE t1 (`b` datetime ); +INSERT INTO t1 VALUES ('2010-01-01 00:00:00'), ('2010-01-01 00:00:00'); +SELECT * FROM t1 WHERE b <= coalesce(NULL, now()); +b +2010-01-01 00:00:00 +2010-01-01 00:00:00 +DROP TABLE t1; +# +# +# BUG#12561818: RERUN OF STORED FUNCTION GIVES ERROR 1172: +# RESULT CONSISTED OF MORE THAN ONE ROW +# +CREATE TABLE t1 (a DATE NOT NULL, b INT); +INSERT IGNORE INTO t1 VALUES ('0000-00-00',1), ('1999-05-10',2); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +CREATE TABLE t2 (a DATETIME NOT NULL, b INT); +INSERT IGNORE INTO t2 VALUES ('0000-00-00 00:00:00',1), ('1999-05-10 00:00:00',2); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 + +SELECT * FROM t1 WHERE a IS NULL; +a b +0000-00-00 1 +SELECT * FROM t2 WHERE a IS NULL; +a b +0000-00-00 00:00:00 1 +SELECT * FROM t1 LEFT JOIN t1 AS t1_2 ON 1 WHERE t1_2.a IS NULL; +a b a b +0000-00-00 1 0000-00-00 1 +1999-05-10 2 0000-00-00 1 +SELECT * FROM t2 LEFT JOIN t2 AS t2_2 ON 1 WHERE t2_2.a IS NULL; +a b a b +0000-00-00 00:00:00 1 0000-00-00 00:00:00 1 +1999-05-10 00:00:00 2 0000-00-00 00:00:00 1 +SELECT * FROM t1 JOIN t1 AS t1_2 ON 1 WHERE t1_2.a IS NULL; +a b a b +0000-00-00 1 0000-00-00 1 +1999-05-10 2 0000-00-00 1 +SELECT * FROM t2 JOIN t2 AS t2_2 ON 1 WHERE t2_2.a IS NULL; +a b a b +0000-00-00 00:00:00 1 0000-00-00 00:00:00 1 +1999-05-10 00:00:00 2 0000-00-00 00:00:00 1 + +PREPARE stmt1 FROM +'SELECT * + FROM t1 LEFT JOIN t1 AS t1_2 ON 1 + WHERE t1_2.a IS NULL AND t1_2.b < 2'; +EXECUTE stmt1; +a b a b +0000-00-00 1 0000-00-00 1 +1999-05-10 2 0000-00-00 1 +EXECUTE stmt1; +a b a b +0000-00-00 1 0000-00-00 1 +1999-05-10 2 0000-00-00 1 +DEALLOCATE PREPARE stmt1; +DROP TABLE t1,t2; +# +# End of 5.5 tests +# +# +# Start of 5.6 tests +# +# +# WL#946: Testing rounding +# +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9999994'), ('2001-01-01 10:10:10.9999995'); +INSERT INTO t1 VALUES (20010101101010.9999994), (20010101101010.9999995); +SELECT * FROM t1; +a +2001-01-01 10:10:11 +2001-01-01 10:10:11 +2001-01-01 10:10:11 +2001-01-01 10:10:11 +DROP TABLE t1; +# +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE if EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATETIME DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 DATETIME DEFAULT '0000-00-00 00:00:00'); +ERROR 42000: Invalid default value for 'c1' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATETIME DEFAULT '2012-02-00 12:12:12'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 DATETIME DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 DATETIME DEFAULT '0000-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t3 (c1 DATETIME DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 DATETIME DEFAULT 0); +CREATE TABLE t2 (c1 DATETIME DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t3 (c1 DATETIME DEFAULT '2012-02-00 12:12:12'); +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 int); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATETIME DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 DATETIME DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATETIME DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 DATETIME DEFAULT 0; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +ALTER TABLE t1 ADD c3 DATETIME DEFAULT '0000-00-00'; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c4 DATETIME DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INT); +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 DATETIME DEFAULT 0; +ALTER TABLE t1 ADD c3 DATETIME DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 DATETIME DEFAULT '2012-02-00'; +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +# +# End of 5.6 tests +# +# +#Bug#25586673: ASSERT IN DA FOR SQL_CMD_UPDATE::UPDATE_SINGLE_TABLE +#Bug#25586959: SERVER CRASH IN SQL_CMD_DELETE::DELETE_FROM_SINGLE_TABLE +# +CREATE TABLE test.t(col_varchar_nokey VARCHAR(1) NOT NULL, +col_time_nokey time NOT NULL, +col_int_nokey INT NOT NULL, +col_datetime_key datetime not null, +key(col_datetime_key)) ENGINE= InnoDB; +DELETE FROM test.t WHERE `col_int_nokey` > `col_int_nokey` + AND TIMESTAMP( '18:16:35.025453' ) IS NULL; +ERROR 22007: Incorrect datetime value: '18:16:35.025453' +UPDATE test.t SET `col_varchar_nokey` = TIMESTAMP(`col_time_nokey`,'00:00:00') +WHERE `col_int_nokey` > `col_int_nokey` + AND TIMESTAMP('18:16:35.025453') IS NULL; +ERROR 22007: Incorrect datetime value: '18:16:35.025453' +INSERT INTO t VALUES('x', CURRENT_TIME(), 0, CURRENT_TIMESTAMP()); +UPDATE test.t SET `col_datetime_key` = `col_datetime_key` WHERE +`col_datetime_key` <=> FROM_UNIXTIME(1151860736,CONCAT_WS(':','%D','%v')); +ERROR 22007: Incorrect datetime value: '2nd:26' for column 'col_datetime_key' at row 1 +DROP TABLE test.t; +# +# Bug#25866743 - ASSERTION FAILED: FALSE IN +# ITEM_FUNC_GEOMETRY_FROM_TEXT::VAL_STR +# Bug#25866143 CRASH IN ST_ASWKB STRING::COPY +# +do is_ipv4_mapped(bin(maketime(11111,exp(repeat('1',32)),''))); +ERROR 22003: DOUBLE value is out of range in 'exp(repeat('1',32))' +do ifnull((bin_to_uuid(uuid_to_bin(date_format('7088-02-14' + ,0xabbd95)))),(maketime('4678-07-20 03:51:44.174847',1,'b'))); +ERROR HY000: Incorrect string value: '' for function uuid_to_bin +do ucase(insert(maketime(9.565398e+307 ,'', +st_longfromgeohash(('4358-04-12 03:45:08.727399'))), +0xdc0823,6756,release_all_locks())); +ERROR HY000: Incorrect geohash value: '4358-04-12 03:45:08.727399' for function ST_LONGFROMGEOHASH +do soundex(maketime(cast((2530967061762658367) as decimal), +exp(repeat('1',32)),((period_add(579349005,27636))xor (sha(current_user))))); +ERROR 22003: DOUBLE value is out of range in 'exp(repeat('1',32))' +do st_mlinefromtext( +maketime( +now(), +instr(1,pow(15270551309908264860,100)), +31 +) +); +ERROR 22003: DOUBLE value is out of range in 'pow(15270551309908264860,100)' +# +# Bug#26147274 ASSERTION `ITEM->MAYBE_NULL' AT MAKE_SORTKEY_FROM_ITEM +# IN SQL/FILESORT.CC +# +CREATE TABLE t1 ( +col_datetime_1_not_null datetime NOT NULL, +col_datetime_2_not_null datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +SET sql_mode=NO_ENGINE_SUBSTITUTION; +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.0','2005-12-22 19:53:31.01'); +INSERT INTO t1 VALUES ('9999-00-00 00:00:00.0','2005-12-22 19:53:31.01'); +SET sql_mode=default; +SELECT * FROM t1 order by col_datetime_1_not_null; +col_datetime_1_not_null col_datetime_2_not_null +0000-00-00 00:00:00 2005-12-22 19:53:31 +9999-00-00 00:00:00 2005-12-22 19:53:31 +SELECT LEAST( '2005-06-05', +LEAST( col_datetime_1_not_null , col_datetime_2_not_null ) ) +AS c1 FROM t1 ORDER BY c1; +c1 +0000-00-00 00:00:00 +2005-06-05 00:00:00 +DROP TABLE t1; +# +# Tests of date/time literals with time zone displacement. +# +SET time_zone = '+00:00'; +SELECT CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME); +CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME) +2019-09-20 10:00:01 +SELECT CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(1)); +CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(1)) +2019-09-20 10:00:01.0 +SELECT CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(2)); +CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(2)) +2019-09-20 10:00:01.00 +SELECT CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(3)); +CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(3)) +2019-09-20 10:00:01.000 +SELECT CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(4)); +CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(4)) +2019-09-20 10:00:01.0000 +SELECT CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(5)); +CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(5)) +2019-09-20 10:00:01.00000 +SELECT CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(6)); +CAST('2019-09-20 10:00:00.999999+00:00' AS DATETIME(6)) +2019-09-20 10:00:00.999999 +SELECT CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME); +CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME) +2019-09-20 08:00:01 +SELECT CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(1)); +CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(1)) +2019-09-20 08:00:01.0 +SELECT CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(2)); +CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(2)) +2019-09-20 08:00:01.00 +SELECT CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(3)); +CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(3)) +2019-09-20 08:00:01.000 +SELECT CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(4)); +CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(4)) +2019-09-20 08:00:01.0000 +SELECT CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(5)); +CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(5)) +2019-09-20 08:00:01.00000 +SELECT CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(6)); +CAST('2019-09-20 10:00:00.999999+02:00' AS DATETIME(6)) +2019-09-20 08:00:00.999999 +SELECT TIMESTAMP'2019-09-20 10:00:00.999999+02:00 '; +TIMESTAMP'2019-09-20 10:00:00.999999+02:00 ' +2019-09-20 08:00:00.999999 +SET time_zone = DEFAULT; diff --git a/mysql-test/r/type_enum.result-pq b/mysql-test/r/type_enum.result-pq new file mode 100644 index 000000000..bbcc6c749 --- /dev/null +++ b/mysql-test/r/type_enum.result-pq @@ -0,0 +1,1975 @@ +DROP TABLE if exists t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL, +KEY field (field) +); +INSERT INTO t1 VALUES ('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001010'),('001010'),('001010'),('001010'),('001010'),('001018'),('001018'),('001018'),('001018'),('001018'),('001018'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001021'),('001021'),('001021'),('001021'),('001021'),('001021'),('001027'),('001027'),('001028'),('001030'),('001030'),('001030'),('001030'),('001031'),('001031'),('001031'),('001031'),('001031'),('001100'),('001100'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('003002'),('003002'),('003002'),('003002'),('003002'),('003002'),('003003'),('003003'),('003003'),('003003'),('003003'),('003003'),('003004'),('003004'),('003004'),('003004'),('003004'),('003004'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003007'),('003007'),('003007'),('003007'),('003007'),('003008'),('003008'),('003008'),('003008'),('003008'),('003008'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003015'),('003015'),('003015'),('003015'),('003015'),('003015'),('003016'),('003016'),('003016'),('003016'),('003016'),('003016'),('003017'),('003017'),('003017'),('003017'),('003017'),('003018'),('003018'),('003018'),('003018'),('003018'),('003019'),('003019'),('004003'),('004005'),('004005'),('004005'),('004005'),('004005'),('004005'),('004006'),('004008'),('004010'),('004012'),('004012'),('004014'),('004014'),('004014'),('004014'),('004014'),('004016'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004020'),('004020'),('004020'),('004020'),('004020'),('004020'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004022'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004025'),('004026'),('004026'),('004026'),('004026'),('004026'),('006004'),('006006'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006011'),('006011'),('006011'),('006011'),('006011'),('006011'),('006012'),('006012'),('006012'),('006012'),('006012'),('006012'),('006014'),('006014'),('006014'),('007001'),('007001'),('007002'),('007003'),('007005'),('007007'),('007008'),('007009'),('007011'),('007012'),('007013'),('007015'),('007016'),('007017'),('007018'),('007019'),('007019'),('007020'),('007021'),('007021'),('007022'),('007023'),('007023'),('007025'),('007025'),('007025'),('007027'),('007029'),('007031'),('007031'),('007032'),('007034'),('007034'),('007036'),('007036'),('007036'),('007037'),('007037'),('007038'),('007040'),('007040'),('007040'),('007043'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009002'),('009002'),('009002'),('009002'),('009002'),('009004'),('009004'),('009004'),('009004'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009006'),('009006'),('009006'),('009006'),('009007'),('009007'),('009007'),('009007'),('009007'),('009007'),('009008'),('009010'),('009010'),('009010'),('009010'),('009010'),('009010'),('009011'),('009011'),('009011'),('009011'),('009011'),('009012'),('009013'),('009013'),('009013'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010005'),('010005'),('010005'),('010005'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010007'),('010007'),('010007'),('010007'),('010007'),('010007'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010009'),('010009'),('010009'),('010009'),('010009'),('010009'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010013'),('010013'),('010013'),('010013'),('010013'),('010013'),('010015'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010017'),('010017'),('010017'),('010017'),('010017'),('010017'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010019'),('010019'),('010019'),('010019'),('010019'),('010019'),('010020'),('010020'),('010020'),('010021'),('010021'),('010021'),('010021'),('010021'),('010021'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010026'),('010027'),('010028'),('010028'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011012'),('011012'),('011012'),('011013'),('011013'),('011013'),('011013'),('011013'),('011013'),('011014'),('011014'),('011014'),('011014'),('011015'),('011015'),('011015'),('011015'),('011015'),('011016'),('011016'),('011016'),('011016'),('011016'),('012017'),('012017'),('012027'),('012027'),('012032'),('012034'),('012036'),('012036'),('012037'),('012037'),('012038'),('012039'),('014001'),('014001'),('016016'),('016016'),('016016'),('016019'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016022'),('016022'),('016022'),('016023'),('016023'),('016023'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016026'),('016026'),('016026'),('016026'),('016026'),('016026'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016029'),('016029'),('016030'),('016031'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016033'),('016033'),('016033'),('016033'),('016033'),('016034'),('016034'),('016034'),('016034'),('016034'),('017002'),('017002'),('017002'),('017002'),('017002'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('019002'),('019002'),('019002'),('019002'),('019002'),('019002'),('019004'),('019004'),('019004'),('019004'),('019004'),('019004'),('020001'),('020001'),('020001'),('020001'),('020004'),('020006'),('020006'),('020006'),('020006'),('020006'),('020006'),('020008'),('020009'),('020009'),('020009'),('020009'),('020009'),('022001'),('022001'),('022001'),('022001'),('022002'),('022002'),('022002'),('022002'),('022003'),('022003'),('022003'),('022003'),('023001'),('023002'),('023002'),('023002'),('023002'),('023002'),('023002'),('023003'),('023003'),('023003'),('023003'),('023004'),('023004'),('023005'),('023005'),('023006'),('023006'),('023006'),('023006'),('023006'),('023006'),('023007'),('023007'),('023010'),('023010'),('023011'),('023011'),('023017'),('023019'),('023019'),('023019'),('023020'),('023020'),('023025'),('023025'),('023025'),('023026'),('023026'),('023026'),('023027'),('023027'),('023027'),('023028'),('023028'),('023029'),('023029'),('023030'),('023030'),('023032'),('023033'),('023033'),('023033'),('023033'),('023033'),('023033'),('023034'),('023035'),('023035'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025003'),('025003'),('025004'),('025004'),('025005'),('025005'),('025007'),('025007'),('025008'),('025008'),('025009'),('025010'),('025010'),('025010'),('025011'),('025011'),('025012'),('025012'),('025013'),('025013'),('025013'),('025014'),('025015'),('025016'),('025018'),('025018'),('025019'),('025019'),('025020'),('025020'),('025021'),('025022'),('025022'),('025023'),('025023'),('025024'),('025025'),('025025'),('025026'),('025026'),('025027'),('025027'),('025027'),('025028'),('025030'),('025031'),('025033'),('025034'),('025035'),('025037'),('025041'),('025042'),('025043'),('025046'),('025048'),('025048'),('025048'),('025049'),('025049'),('025049'),('025050'),('025050'),('025050'),('025051'),('025051'),('025052'),('025052'),('025052'),('025053'),('025053'),('025054'),('025054'),('025054'),('025054'),('025055'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025057'),('025057'),('025058'),('025058'),('025060'),('025060'),('025061'),('025062'),('025063'),('027001'),('027002'),('027011'),('036001'),('036001'),('036001'),('036001'),('036001'),('037003'),('037006'),('037007'),('037008'),('037008'),('038009'),('039001'),('039001'),('039001'),('039001'),('039001'),('039001'),('039002'),('039002'),('039002'),('039002'),('039002'),('039003'),('039003'),('039003'),('039003'),('039003'),('039003'),('039004'),('039004'),('039004'),('039004'),('039004'),('039005'),('039005'),('039005'),('039005'),('039005'),('039006'),('039006'),('039006'),('039006'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046007'),('046007'),('046007'),('046007'),('046007'),('046007'),('046008'),('046008'),('046008'),('046008'),('046008'),('046009'),('046009'),('046009'),('046010'),('046012'),('046012'),('046012'),('046013'),('046014'),('046014'),('046014'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('051003'),('051003'),('051003'),('051003'),('051003'),('051004'),('051004'),('051004'),('051004'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052002'),('052002'),('052005'),('052005'),('052005'),('052005'),('052005'),('052005'),('053016'),('053019'),('053019'),('053023'),('053023'),('053023'),('053023'),('053024'),('053024'),('053024'),('053026'),('053026'),('053026'),('053026'),('053028'),('053028'),('053029'),('053029'),('053029'),('053029'),('053033'),('053033'),('053033'),('053045'),('053046'),('053051'),('053051'),('053051'),('053054'),('053054'),('053054'),('053054'),('053057'),('053069'),('053069'),('053097'),('053107'),('053125'),('053125'),('053127'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054002'),('054002'),('054002'),('054002'),('054002'),('054002'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054006'),('054006'),('054006'),('054007'),('054007'),('054007'),('054007'),('054007'),('054009'),('054009'),('054009'),('054009'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056003'),('056003'),('056003'),('056003'),('056003'),('056003'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056009'),('056009'),('056009'),('056011'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056018'),('056018'),('056018'),('056018'),('056018'),('056018'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056020'),('056020'),('056020'),('056020'),('056022'),('056022'),('056022'),('056022'),('056022'),('057003'),('057003'),('057004'),('058002'),('058002'),('058002'),('058002'),('058003'),('058003'),('058003'),('058003'),('058004'),('058004'),('058004'),('058005'),('058005'),('058005'),('060001'),('060001'),('060001'),('060001'),('060001'),('060004'),('060004'),('060004'),('060004'),('060004'),('060004'),('060005'),('060005'),('060005'),('060005'),('060005'),('060005'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('061004'),('061004'),('061004'),('061004'),('061004'),('061004'),('061006'),('061006'),('061006'),('061006'),('061006'),('061006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069010'),('069010'),('069010'),('069010'),('069010'),('069010'),('069011'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069016'),('069016'),('069016'),('069016'),('069016'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069020'),('069020'),('069020'),('069020'),('069021'),('069023'),('071002'),('071002'),('071002'),('071002'),('071002'),('071003'),('071003'),('071003'),('071003'),('071003'),('071004'),('071004'),('071004'),('071004'),('071004'),('071005'),('071005'),('071005'),('071005'),('071005'),('071005'),('071006'),('071006'),('071006'),('071006'),('071008'),('071008'),('071008'),('071008'),('071008'),('071008'),('071011'),('071011'),('071011'),('071011'),('071011'),('071020'),('071020'),('071020'),('071020'),('071020'),('071021'),('071022'),('071022'),('071022'),('072001'),('072001'),('074001'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('075001'),('075001'),('075001'),('075007'),('075007'),('075007'),('075007'),('076101'),('076101'),('076101'),('076101'),('076102'),('076102'),('076102'),('076103'),('076103'),('076103'),('076103'),('076103'),('077001'),('077001'),('077001'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077004'),('077004'),('077004'),('077004'),('077004'),('077004'),('077006'),('077006'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('078005'),('078005'),('078005'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079003'),('079003'),('079004'),('079004'),('079005'),('079005'),('079005'),('079005'),('079005'),('079005'),('079006'),('079006'),('079006'),('079006'),('079007'),('079007'),('079007'),('079007'),('079007'),('081001'),('081001'),('081001'),('081001'),('081001'),('082011'),('082011'),('082011'),('082011'),('082011'),('082013'),('082013'),('082013'),('082013'),('082013'),('082013'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082015'),('082015'),('082015'),('082015'),('082015'),('082016'),('082016'),('082016'),('082016'),('082016'),('082016'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082021'),('082021'),('082022'),('082022'),('082022'),('082022'),('082022'),('082023'),('082023'),('082023'),('082023'),('082023'),('082024'),('082024'),('082024'),('082024'),('082024'),('082025'),('082025'),('082025'),('082025'),('082025'),('082026'),('082026'),('082026'),('082026'),('082026'),('082027'),('082027'),('082027'),('082027'),('082027'),('082028'),('082028'),('082028'),('082028'),('082029'),('082029'),('082029'),('082029'),('082029'),('082030'),('082030'),('082030'),('082030'),('082031'),('082031'),('082031'),('082031'),('082031'),('082032'),('082032'),('082032'),('082033'),('082033'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082035'),('082035'),('082035'),('082036'),('082036'),('082036'),('082036'),('082037'),('082037'),('082037'),('082038'),('082038'),('082038'),('082038'),('082039'),('082039'),('082039'),('082039'),('082040'),('082040'),('082040'),('082040'),('082040'),('082041'),('082041'),('082041'),('082041'),('082042'),('082042'),('082043'),('082043'),('082043'),('082043'),('082043'),('082044'),('082044'),('082044'),('082044'),('084001'),('084002'),('084002'),('084002'),('084002'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084004'),('084004'),('084004'),('084004'),('084004'),('084005'),('084005'),('084005'),('084005'),('084005'),('084007'),('084007'),('084007'),('084007'),('084007'),('084007'),('084008'),('084008'),('084008'),('084008'),('084008'),('084008'),('084009'),('084009'),('084009'),('084009'),('084009'),('084009'),('084011'),('084013'),('084013'),('084013'),('084013'),('084013'),('084014'),('084014'),('084014'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084027'),('084027'),('084027'),('084027'),('084027'),('084027'),('084032'),('084032'),('084033'),('084033'),('084033'),('084035'),('084035'),('084035'),('084036'),('084036'),('084036'),('084036'),('084036'),('084036'),('084037'),('084037'),('084038'),('084038'),('084038'),('084038'),('084038'),('084038'),('084039'),('084039'),('084039'),('084039'),('084040'),('084040'),('084040'),('084040'),('084040'),('084041'),('084041'),('084041'),('084041'),('084042'),('084042'),('084043'),('084043'),('084043'),('084043'),('084044'),('084044'),('084044'),('084044'),('084044'),('084045'),('084046'),('084046'),('084046'),('084047'),('084048'),('084048'),('084049'),('084049'),('084050'),('084051'),('084051'),('085001'),('085001'),('085001'),('085001'),('085001'),('085001'),('085002'),('085002'),('085002'),('085002'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085005'),('085005'),('085005'),('085005'),('085005'),('085005'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085009'),('085009'),('085009'),('085009'),('085009'),('085009'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085017'),('085017'),('085017'),('085017'),('085017'),('085018'),('085018'),('085018'),('085018'),('085018'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085020'),('085020'),('085020'),('085020'),('085020'),('085020'),('085022'),('085022'),('085022'),('085022'),('085022'),('085022'),('085023'),('085023'),('085023'),('085023'),('085023'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085033'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085035'),('085035'),('085035'),('085035'),('085035'),('085035'),('085036'),('085036'),('085036'),('085036'),('085036'),('085036'),('085037'),('085037'),('085037'),('085037'),('085037'),('085037'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085043'),('085043'),('085043'),('085043'),('085043'),('085043'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085045'),('085045'),('085045'),('085045'),('085045'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085063'),('085063'),('085063'),('085063'),('085063'),('085064'),('085064'),('085064'),('085064'),('085064'),('085065'),('085065'),('085068'),('085068'),('085068'),('085068'),('085068'),('085068'),('085071'),('085071'),('085071'),('085071'),('085071'),('085071'),('085073'),('085073'),('085082'),('085082'),('085082'),('085082'),('085082'),('085086'),('085086'),('085086'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085089'),('085089'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085091'),('085091'),('085091'),('085091'),('085091'),('085092'),('085092'),('085092'),('085093'),('085093'),('085095'),('085095'),('085095'),('085095'),('085095'),('085096'),('085096'),('085096'),('085096'),('085096'),('085096'),('085097'),('085097'),('085097'),('085097'),('085097'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085102'),('085102'),('085103'),('085103'),('085103'),('085104'),('085104'),('085104'),('085104'),('085104'),('085105'),('085105'),('085106'),('085106'),('085106'),('085106'),('085106'),('085106'),('085108'),('085108'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085110'),('085110'),('085110'),('085110'),('085110'),('085111'),('085111'),('085111'),('085112'),('085112'),('085112'),('085112'),('085113'),('085113'),('085113'),('085113'),('085113'),('085115'),('085120'),('085121'),('085121'),('085121'),('085121'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085125'),('085125'),('085125'),('085125'),('085125'),('085126'),('085126'),('085126'),('085126'),('085126'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085128'),('085128'),('085128'),('085128'),('085128'),('085129'),('085129'),('085129'),('085129'),('085129'),('085130'),('085130'),('085130'),('085130'),('085130'),('085132'),('085132'),('085132'),('085132'),('085132'),('085132'),('085133'),('085133'),('085133'),('085133'),('085133'),('085134'),('085134'),('085134'),('085135'),('085135'),('085135'),('085136'),('085136'),('085136'),('085136'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('086002'),('086002'),('086002'),('086002'),('086003'),('086003'),('086003'),('086003'),('086005'),('088001'),('088001'),('088001'),('088001'),('088001'),('088003'),('088003'),('088003'),('088003'),('088003'),('088003'),('088005'),('088005'),('088005'),('088005'),('088005'),('088006'),('088006'),('088006'),('088006'),('088006'),('088007'),('088007'),('088007'),('088008'),('088008'),('088008'),('088008'),('088009'),('088009'),('088009'),('088009'),('088009'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090002'),('090002'),('090002'),('090002'),('090002'),('090002'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090008'),('090008'),('090008'),('090008'),('090008'),('090009'),('090009'),('090009'),('090009'),('090009'),('090010'),('090010'),('090013'),('090013'),('090013'),('090016'),('090016'),('090017'),('090018'),('090022'),('090027'),('091001'),('091001'),('091001'),('091001'),('091001'),('091001'),('091002'),('091002'),('091002'),('091002'),('091002'),('091002'),('091009'),('091009'),('091009'),('091009'),('091009'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091012'),('091012'),('091013'),('091013'),('091013'),('091013'),('091013'),('091013'),('091015'),('091015'),('091015'),('091015'),('091015'),('091015'),('091016'),('091016'),('091016'),('091016'),('091016'),('091017'),('091017'),('091018'),('091018'),('091018'),('091018'),('093003'),('093003'),('093003'),('093003'),('093003'),('093003'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('100001'),('100001'),('100001'),('100001'),('106001'),('113005'),('113005'),('113005'),('113006'),('113006'),('113018'),('113019'),('113020'),('115001'),('115001'),('115001'),('115002'),('115002'),('115003'),('115004'),('115004'),('115004'),('115004'),('115005'),('115005'),('115005'),('115006'),('115006'),('115006'),('115007'),('115007'),('115007'),('115007'),('115007'),('115008'),('115008'),('115008'),('115009'),('115010'),('115010'),('115010'),('115010'),('115010'),('115011'),('115011'),('115011'),('115011'),('115012'),('115012'),('115013'),('115013'),('115013'),('115014'),('115014'),('115014'),('115014'),('115015'),('115015'),('115015'),('115016'),('115016'),('115016'),('115016'),('115017'),('115017'),('115017'),('115017'),('115017'),('115018'),('115018'),('115020'),('115020'),('115021'),('115021'),('115022'),('115022'),('115022'),('115023'),('115023'),('115023'),('115023'),('115023'),('115025'),('115025'),('115025'),('115026'),('115026'),('115027'),('115027'),('115027'),('115028'),('115028'),('115028'),('115028'),('115029'),('115029'),('115029'),('115030'),('115030'),('115030'),('115031'),('115031'),('115032'),('115032'),('115032'),('115033'),('115033'),('115033'),('115033'),('115034'),('115034'),('115034'),('115035'),('115035'),('115036'),('115036'),('115036'),('115036'),('115036'),('115039'),('115040'),('115040'),('115040'),('115041'),('115041'),('115041'),('115041'),('115041'),('115042'),('115042'),('115042'),('115042'),('115042'),('115043'),('115043'),('115043'),('115044'),('115044'),('115044'),('115044'),('115046'),('115046'),('115046'),('115047'),('115048'),('115050'),('115050'),('115050'),('115050'),('115050'),('115051'),('115051'),('115051'),('115052'),('115053'),('115053'),('115054'),('115054'),('115054'),('115055'),('115055'),('115055'),('115057'),('115059'),('115059'),('115059'),('115059'),('115060'),('115060'),('115060'),('115060'),('115060'),('115060'),('115061'),('115061'),('115061'),('115062'),('115062'),('115062'),('115062'),('115064'),('115064'),('115064'),('115065'),('115065'),('115065'),('115065'),('115066'),('115066'),('115066'),('115067'),('115067'),('115067'),('115068'),('115068'),('115068'),('115069'),('115069'),('115069'),('115069'),('115069'),('115070'),('115070'),('115070'),('115071'),('115071'),('115071'),('115072'),('115072'),('115072'),('115073'),('115073'),('115075'),('115075'),('115075'),('115076'),('115076'),('115076'),('115076'),('115076'),('115076'),('115081'),('115081'),('115081'),('115082'),('115082'),('115082'),('115085'),('115085'),('115085'),('115085'),('115085'),('115086'),('115086'),('115086'),('115087'),('115087'),('115088'),('115088'),('115088'),('115088'),('115088'),('115095'),('115095'),('115095'),('115096'),('115096'),('115097'),('115097'),('115098'),('115098'),('115099'),('115101'),('115102'),('115102'),('115102'),('115103'),('115103'),('115104'),('115104'),('115104'),('115104'),('115105'),('115105'),('115106'),('115106'),('115106'),('115106'),('115106'),('115108'),('115109'),('115111'),('115111'),('115111'),('115111'),('115112'),('115112'),('115112'),('115112'),('115112'),('115113'),('115113'),('115113'),('115114'),('115114'),('115114'),('115114'),('115114'),('115115'),('115115'),('115115'),('115115'),('115116'),('115117'),('115117'),('115117'),('115118'),('115118'),('115119'),('115119'),('115119'),('115119'),('115120'),('115121'),('115121'),('115122'),('115122'),('116001'),('116003'),('116003'),('116003'),('116003'),('116004'),('116004'),('116005'),('116005'),('116006'),('116006'),('116006'),('116007'),('116007'),('116008'),('116008'),('116009'),('116009'),('116009'),('116010'),('116010'),('116010'),('116010'),('116011'),('116011'),('116011'),('116011'),('116012'),('116012'),('123001'),('123001'),('123001'),('123001'),('123001'),('124065'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126012'),('126012'),('126012'),('126012'),('130001'),('130001'),('130001'),('130001'),('132001'),('132001'),('132001'),('132001'),('132001'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('133001'),('133001'),('133008'),('133009'),('133010'),('133011'),('133011'),('133011'),('133011'),('133011'),('133011'),('133012'),('133015'),('133015'),('133015'),('133015'),('133016'),('133018'),('133018'),('133018'),('133018'),('133018'),('133019'),('133021'),('133021'),('133022'),('133022'),('133023'),('133023'),('133024'),('133024'),('133024'),('133024'),('133024'),('133024'),('133025'),('133027'),('133027'),('133027'),('133027'),('133027'),('133028'),('133028'),('133028'),('133029'),('133029'),('133029'),('133029'),('133029'),('133029'),('133030'),('133030'),('133031'),('133031'),('133031'),('134001'),('134001'),('134001'),('135001'),('135001'),('135001'),('135001'),('135001'),('135002'),('135002'),('135002'),('135004'),('135010'),('135010'),('135010'),('135010'),('135010'),('135010'),('137010'),('137011'),('137012'),('137014'),('137015'),('137015'),('137016'),('137019'),('139001'),('140001'),('140001'),('140001'),('140001'),('140001'),('140001'),('141001'),('141001'),('141001'),('141001'),('141001'),('141002'),('141002'),('141002'),('141002'),('141002'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141007'),('141007'),('141007'),('141007'),('141007'),('141009'),('141009'),('141009'),('141009'),('141009'),('141011'),('141011'),('141011'),('141011'),('141011'),('141011'),('141012'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141015'),('141015'),('141015'),('141015'),('141015'),('141016'),('141016'),('141016'),('141016'),('141016'),('141016'),('141017'),('141017'),('141017'),('141017'),('141017'),('141017'),('141018'),('141018'),('141018'),('141018'),('141019'),('141019'),('141019'),('141019'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141021'),('141021'),('141021'),('141021'),('141021'),('141021'),('141022'),('141022'),('141022'),('141022'),('141022'),('141022'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141024'),('141025'),('141025'),('141025'),('141026'),('141026'),('141026'),('141026'),('141026'),('141026'),('141027'),('141027'),('141027'),('141027'),('141027'),('141028'),('141028'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('150009'),('150013'),('150014'),('150015'),('150015'),('150015'),('150016'),('150016'),('150017'),('150017'),('150017'),('150017'),('150020'),('152001'),('152001'),('152001'),('152002'),('152003'),('152003'),('152003'),('152003'),('152004'),('152005'),('152006'),('152006'),('152006'),('152006'),('152007'),('154001'),('154002'),('154002'),('155001'),('155001'),('155002'),('155003'),('155004'),('155004'),('155006'),('159001'),('159003'),('160001'),('160001'),('160001'),('160001'),('160002'),('160002'),('161001'),('162002'),('162002'),('162003'),('162003'),('162003'),('162003'),('162003'),('162007'),('162012'),('162012'),('162012'),('163001'),('163001'),('163001'),('163011'),('163015'),('163016'),('163016'),('165001'),('165001'),('165001'),('165001'),('165002'),('165002'),('165002'),('165002'),('165003'),('165003'),('165003'),('165004'),('165004'),('165004'),('165005'),('165005'),('165005'),('165006'),('165006'),('165006'),('165006'),('165007'),('165007'),('165007'),('165007'),('165008'),('165008'),('165008'),('165008'),('165009'),('165009'),('165009'),('165009'),('165010'),('165010'),('165010'),('165011'),('165011'),('165012'),('165012'),('165012'),('165013'),('165013'),('165013'),('165014'),('165014'),('165014'),('165015'),('165015'),('165015'),('165015'),('165016'),('165016'),('165016'),('165017'),('165017'),('165017'),('165017'),('165018'),('165018'),('165018'),('165018'),('165019'),('165019'),('165019'),('165019'),('165020'),('165020'),('165020'),('165020'),('165021'),('165021'),('165021'),('165021'),('165022'),('165022'),('165022'),('165023'),('165024'),('165024'),('165024'),('165025'),('165025'),('165025'),('165026'),('165026'),('165026'),('165028'),('165029'),('165030'),('165030'),('165030'),('165031'),('165031'),('165033'),('165033'),('165034'),('165034'),('165034'),('165035'),('165035'),('165035'),('165036'),('165036'),('165036'),('168003'),('168003'),('168004'),('168005'),('168014'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169003'),('169003'),('169003'),('169003'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169009'),('169009'),('169009'),('169009'),('169010'),('171006'),('171006'),('171007'),('171007'),('171008'),('171008'),('171008'),('171009'),('171009'),('171009'),('172001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176002'),('176002'),('176002'),('176002'),('176002'),('176003'),('176003'),('176003'),('176003'),('176003'),('176003'),('177001'),('177001'),('177001'),('177001'),('177001'),('177001'),('179007'),('179007'),('179012'),('179012'),('179012'),('179012'),('179012'),('179012'),('179013'),('179013'),('179013'),('179013'),('179013'),('179013'),('179042'),('179044'),('179045'),('180001'),('180013'),('180014'),('180014'),('180015'),('180017'),('180018'),('180020'),('180020'),('180021'),('180021'),('180027'),('180030'),('180033'),('180035'),('180036'),('180037'),('180038'),('180041'),('180042'),('180045'),('180045'),('180047'),('180048'),('180049'),('180050'),('180054'),('180060'),('180066'),('180067'),('180068'),('180070'),('182001'),('184001'),('184002'),('184005'),('184005'),('184005'),('184005'),('184006'),('184006'),('184006'),('184006'),('184008'),('184008'),('184008'),('184008'),('184009'),('184009'),('184009'),('184009'),('184010'),('184010'),('184010'),('184010'),('184011'),('184011'),('184011'),('184011'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('187001'),('191002'),('191002'),('192002'),('194003'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197005'),('197005'),('197005'),('197005'),('197005'),('197005'),('197006'),('197006'),('197006'),('197006'),('197006'),('198001'),('198001'),('198001'),('198001'),('198001'),('198001'),('198003'),('198003'),('198003'),('198004'),('198004'),('198004'),('198004'),('198004'),('198004'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198006'),('198006'),('198006'),('198006'),('198006'),('198006'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198008'),('198008'),('198008'),('198008'),('198008'),('198008'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198010'),('198010'),('198010'),('198010'),('198010'),('198010'),('198011'),('198012'),('198012'),('198012'),('198012'),('198015'),('198015'),('198016'),('198016'),('198016'),('198016'),('198016'),('198016'),('198017'),('198017'),('198017'),('198017'),('198017'),('198017'),('201001'),('201001'),('201001'),('201001'),('201001'),('201002'),('202001'),('202001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203002'),('203002'),('203002'),('203002'),('203003'),('203003'),('203003'),('203003'),('203003'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203018'),('203018'),('203018'),('203018'),('203018'),('203019'),('203019'),('203019'),('203019'),('203019'),('204001'),('204002'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('208001'),('208001'),('208002'),('208002'),('208002'),('208003'),('208003'),('208003'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208005'),('208005'),('208005'),('208005'),('208005'),('209001'),('209001'),('209001'),('209001'),('209001'),('209002'),('209002'),('209002'),('209002'),('209002'),('209003'),('209003'),('209003'),('209003'),('209003'),('210001'),('210001'),('210001'),('210001'),('210001'),('210004'),('210004'),('210004'),('210004'),('210004'),('210004'),('210009'),('210010'),('212001'),('212001'),('212002'),('212002'),('212002'),('212002'),('212003'),('212003'),('212003'),('212004'),('212004'),('212004'),('212005'),('212005'),('212005'),('212005'),('212005'),('212006'),('212006'),('212006'),('212007'),('212007'),('212008'),('212008'),('212008'),('212008'),('212009'),('212009'),('212009'),('212009'),('212010'),('212010'),('212010'),('212010'),('212011'),('212011'),('212012'),('212012'),('212013'),('212013'),('212013'),('218001'),('218004'),('218009'),('218011'),('218011'),('218015'),('218020'),('218021'),('218021'),('218022'),('218022'),('218022'),('218023'),('218024'),('218025'),('218026'),('218026'),('218027'),('218028'),('218029'),('218029'),('218029'),('218030'),('218031'),('221001'),('221001'),('221001'),('221001'),('221001'),('221001'),('221002'),('221002'),('221002'),('221002'),('221002'),('221002'),('221003'),('221003'),('221003'),('221003'),('221003'),('221003'),('221004'),('221004'),('221004'),('221004'),('221004'),('221004'),('221005'),('221005'),('221005'),('221005'),('221005'),('221006'),('221006'),('221006'),('221006'),('221006'),('221007'),('221007'),('221007'),('221007'),('221007'),('221007'),('221008'),('221008'),('221008'),('221008'),('221008'),('221008'),('221009'),('221009'),('221009'),('221009'),('221009'),('221009'),('221010'),('221010'),('221010'),('221010'),('221011'),('221011'),('221011'),('221011'),('221012'),('221012'),('221012'),('221012'),('221012'),('221012'),('221013'),('221013'),('221013'),('221013'),('221013'),('221013'),('223003'),('223003'),('224001'),('224001'),('224002'),('224002'),('224003'),('224007'),('224008'),('225001'),('225002'),('225002'),('225002'),('225003'),('225003'),('225003'),('225003'),('225004'),('225004'),('225004'),('225005'),('225005'),('225005'),('225005'),('225005'),('225005'),('225006'),('225006'),('225006'),('225007'),('225007'),('225007'),('225008'),('225008'),('225008'),('225008'),('225008'),('225009'),('225009'),('225009'),('225010'),('225010'),('225010'),('225011'),('225011'),('225011'),('225011'),('225011'),('225012'),('225012'),('225012'),('225012'),('225012'),('225012'),('225013'),('225013'),('226001'),('226002'),('226003'),('226003'),('226005'),('226005'),('226006'),('226007'),('226007'),('226007'),('226007'),('227011'),('227015'),('227015'),('227041'),('227045'),('227052'),('227056'),('227063'),('227064'),('227066'),('227067'),('227069'),('227071'),('227073'),('227085'),('227116'),('227119'),('227131'),('227133'),('227147'),('229005'),('229005'),('229005'),('233003'),('233004'),('235001'),('235001'),('235002'),('235003'),('235003'),('235003'),('235004'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('236001'),('236001'),('236001'),('236001'),('236002'),('236003'),('236003'),('236003'),('236003'),('236003'),('236003'),('238002'),('238002'),('238002'),('238002'),('238002'),('238002'),('238003'),('238003'),('238003'),('238003'),('238003'),('238003'),('238004'),('238004'),('238004'),('238004'),('238004'),('238005'),('238005'),('238005'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('334005'),('334006'),('337001'),('337001'),('337001'),('337002'),('337002'),('337003'),('337003'),('337003'),('337004'),('343001'),('343001'),('344001'),('344002'),('344003'),('344004'),('344005'),('344005'),('345001'),('345001'),('348001'),('348004'),('348005'),('348005'),('349001'),('349001'),('349002'),('349002'),('349002'),('350001'),('353002'),('353002'),('353002'),('353003'),('355001'),('355002'),('355005'),('355006'),('355006'),('356001'),('358001'),('358001'),('358001'),('359001'),('359001'),('359002'),('359002'),('359002'),('359002'),('360001'),('360001'),('360002'),('360002'),('360003'),('360003'),('360004'),('360004'),('360005'),('360005'),('360005'),('366001'),('366002'),('366002'),('366003'),('366004'),('369001'),('369001'),('373001'),('373002'),('373002'),('373003'),('373003'),('373005'),('373007'),('373008'),('373009'),('373009'),('373010'),('373010'),('373010'),('373011'),('373011'),('373011'),('373011'),('373012'),('373012'),('373012'),('373013'),('373013'),('373014'),('373014'),('373015'),('373015'),('373015'),('373015'),('373017'),('373017'),('373017'),('373017'),('373018'),('373021'),('374002'),('374004'),('374006'),('374007'),('374008'),('374009'),('374010'),('374011'),('374012'),('374015'),('374016'),('382001'),('382002'),('382002'),('384001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386006'),('386006'),('386006'),('386006'),('386006'),('386006'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386009'),('386009'),('386009'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386014'),('386014'),('386014'),('386014'),('389001'),('389002'),('389002'),('389003'),('389003'),('389003'),('389003'),('389004'),('389004'),('389004'),('389004'),('392001'),('393001'),('393002'),('393002'),('393003'),('393004'),('395001'),('395001'),('397001'),('397001'),('397001'),('397002'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399003'),('400001'),('400001'),('400001'),('400001'),('400002'),('403002'),('504001'),('504001'),('504002'),('504002'),('504002'),('504004'),('504004'),('504005'),('504006'),('504007'),('504007'),('504007'),('504008'),('504008'),('504009'),('504009'),('504009'),('504009'),('504009'),('504010'),('504011'),('504011'),('504012'),('504012'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504017'),('504017'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504022'),('504023'),('504023'),('504024'),('504024'),('504025'),('504025'),('506001'),('506001'),('506001'),('506001'),('506001'),('506001'),('506002'),('506002'),('506002'),('506002'),('506002'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511003'),('511003'),('511003'),('511003'),('511003'),('511003'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511007'),('511007'),('511007'),('511007'),('511007'),('511008'),('511008'),('511008'),('511008'),('511008'),('511008'),('511009'),('511009'),('511009'),('511009'),('511009'),('511009'),('511010'),('511010'),('511010'),('511010'),('511010'),('511010'),('511011'),('511011'),('511011'),('511011'),('511011'),('511011'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511014'),('511014'),('511014'),('511014'),('511014'),('511017'),('511018'),('511020'),('511021'),('511022'),('511024'),('511028'),('511029'),('511029'),('511029'),('511029'),('511029'),('511029'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513002'),('513002'),('513002'),('513002'),('513002'),('513002'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513004'),('513004'),('513004'),('515001'),('515001'),('515001'),('515001'),('515001'),('515002'),('515002'),('515003'),('515003'),('515007'),('515007'),('515008'),('515011'),('515011'),('515011'),('515011'),('515011'),('515011'),('515012'),('515012'),('515012'),('515012'),('515013'),('515013'),('515013'),('515013'),('515013'),('515014'),('515014'),('515014'),('515014'),('515014'),('515015'),('515015'),('515015'),('515015'),('515015'),('518001'),('518002'),('521001'),('521002'),('521002'),('521002'),('521003'),('521003'),('521003'),('521003'),('521004'),('521004'),('521004'),('521004'),('521005'),('521005'),('521005'),('521005'),('521006'),('521006'),('521006'),('521009'),('521010'),('521010'),('521010'),('521010'),('521011'),('521011'),('521011'),('521011'),('521012'),('521013'),('521013'),('521015'),('521016'),('521016'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523002'),('523002'),('523002'),('523002'),('523002'),('523002'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523004'),('523004'),('523004'),('523004'),('523004'),('523004'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('524001'),('700001'),('701001'),('701002'),('701003'),('702001'),('702002'),('702004'),('702005'),('704001'),('704004'),('705001'),('706001'),('706002'),('707001'),('707002'),('707003'),('708001'),('710001'),('710002'),('711001'),('711002'),('712001'),('714001'),('714002'),('715001'),('719001'),('719002'),('991002'),('991002'),('991002'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991004'),('991004'),('991004'),('991005'),('991005'),('991005'),('991006'),('991007'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996002'),('996002'),('996003'),('996003'),('996003'),('996003'),('996003'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998004'),('998004'),('998005'),('998005'),('998006'),('998007'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999002'),('999002'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011018'),('011018'),('011018'),('011018'),('034001'),('034001'),('034002'),('034002'),('071010'),('071010'),('071010'),('519001'),('126013'),('126013'),('126013'),('126013'),('126013'),('184012'),('184012'),('184012'),('404001'),('405002'),('405002'),('405001'),('405003'),('405006'),('240011'),('240011'),('240011'),('240011'),('240011'),('240011'),('240010'),('240010'),('240010'),('240009'),('240009'),('240009'),('240009'),('240008'),('240008'),('240008'),('240007'),('240007'),('240007'),('240007'),('240007'),('240007'),('240005'),('240005'),('240005'),('240005'),('240005'),('240004'),('240004'),('240004'),('240004'),('240004'),('240003'),('240003'),('240003'),('240003'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240001'),('240001'),('240001'),('240001'),('240001'),('240012'),('240012'),('240012'),('240012'),('240012'),('240013'),('240014'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240016'),('240016'),('240016'),('240016'),('240016'),('240016'),('240017'),('240017'),('240017'),('357001'),('357001'),('235006'),('235006'),('235007'),('235007'),('235007'),('235007'),('235007'),('056023'),('056023'),('056023'),('056023'),('056023'),('046015'),('019005'),('019005'),('126014'),('126014'),('126014'),('126014'),('126014'),('126014'),('241003'),('241003'),('241003'),('241003'),('241003'),('241003'),('241002'),('241002'),('241002'),('241002'),('241002'),('241002'),('241001'),('241001'),('241001'),('241001'),('241001'),('240020'),('240020'),('240020'),('240020'),('240020'),('240020'),('240019'),('240019'),('240019'),('242001'),('242002'),('242004'),('242005'),('242006'),('089002'),('089002'),('089002'),('089002'),('089002'),('089002'),('406001'),('406002'),('406003'),('406004'),('406004'),('243001'),('243005'),('243006'),('243007'),('243008'),('408001'),('408001'),('408001'),('408001'),('408001'),('366005'),('366005'),('016035'),('016035'),('016035'),('016035'),('077010'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('025064'),('025064'),('025064'),('025064'),('011019'),('011019'),('011019'),('011019'),('011019'),('115123'),('115123'),('504026'),('039007'),('039009'),('039008'),('039008'),('039010'),('039010'),('039011'),('039012'),('180072'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240023'),('240023'),('240023'),('240023'),('405008'),('405008'),('525002'),('410002'),('410002'),('410004'),('410005'),('410005'),('410006'),('410007'),('410007'),('410008'),('410009'),('410010'),('410011'),('410011'),('410012'),('410012'),('410013'),('410013'),('410014'),('410014'),('410016'),('410016'),('344006'),('240031'),('240031'),('240031'),('240031'),('240030'),('240030'),('240030'),('240030'),('240029'),('240029'),('240029'),('240029'),('240028'),('240028'),('240028'),('240028'),('240027'),('240027'),('240026'),('240026'),('240026'),('240025'),('240025'),('240025'),('240025'),('240024'),('240024'),('240034'),('240034'),('240034'),('240033'),('240033'),('240033'),('240032'),('240032'),('240032'),('240032'),('411001'),('411002'),('203020'),('069025'),('069025'),('069025'),('069025'),('069025'),('069025'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('240040'),('240037'),('405009'),('405009'),('405009'),('405010'),('405010'),('240043'),('240043'),('504028'),('504040'),('800001'),('410019'),('410019'),('410020'),('410020'),('410020'),('410021'),('410021'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('413001'),('344007'),('082045'),('082045'),('082045'),('082045'),('082045'),('010031'),('010031'),('010031'),('010031'),('010032'),('010032'),('010032'),('010032'),('010033'),('010033'),('010033'),('010033'),('010033'),('010034'),('010034'),('010034'),('010034'),('010035'),('010035'),('010035'),('010035'),('504044'),('515016'),('515016'),('515016'),('515016'),('801002'),('801003'),('801004'),('801005'),('802001'),('801001'),('414001'),('141029'),('803001'),('803002'),('803004'),('803005'),('803006'),('803007'),('803008'),('803009'),('803013'),('803014'),('803015'),('803016'),('803017'),('410022'),('410023'),('410023'),('803019'),('415002'),('415001'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('011020'),('011020'),('011020'),('011020'),('011023'),('011023'),('011023'),('011023'),('011022'),('011022'),('011022'),('011022'),('011022'),('011022'),('011021'),('011021'),('011021'),('011021'),('025065'),('025065'),('025065'),('025065'),('165037'),('165037'),('165038'),('165038'),('165038'),('165039'),('416001'),('416001'),('416001'),('416001'),('416001'),('416002'),('416003'),('417001'),('418001'),('504045'),('504045'),('504045'),('803022'),('240022'),('240022'),('240022'),('240022'),('420001'),('420001'),('420001'),('420001'),('804010'),('804005'),('804002'),('804018'),('804013'),('511019'),('511016'),('511015'),('511032'),('511031'),('511030'),('511027'),('511026'),('511025'),('511033'),('511023'),('133034'),('133034'),('133034'),('133033'),('169011'),('169011'),('169011'),('169011'),('169011'),('344008'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244026'),('244026'),('244026'),('244026'),('244026'),('244026'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244023'),('244023'),('244023'),('244023'),('244023'),('244023'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('082046'),('082046'),('082046'),('082046'),('082047'),('082047'),('082048'),('082048'),('126015'),('126015'),('126016'),('126016'),('126016'),('126016'),('126016'),('416005'),('421001'),('421001'),('421002'),('016037'),('016037'),('016037'),('016037'),('016036'),('016036'),('016036'),('016036'),('115124'),('115124'),('115126'),('240049'),('240049'),('240048'),('240048'),('240047'),('240047'),('240046'),('240046'),('240045'),('240044'),('244032'),('244033'),('422002'),('422004'),('422004'),('422004'),('422005'),('422005'),('184013'),('184013'),('184013'),('805001'),('805002'),('805003'),('805004'),('805005'),('056024'),('056024'),('056024'),('423001'),('344010'),('235009'),('235009'),('235009'),('235009'),('212014'),('212014'),('056025'),('056025'),('056025'),('056026'),('056026'),('056026'),('056026'),('056026'),('056026'),('244034'),('244034'),('244034'),('244034'),('244034'),('244034'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('203015'),('245002'),('245002'),('245001'),('245001'),('056029'),('056030'),('056032'),('424001'),('056034'),('056034'),('056034'),('056034'),('056033'),('056033'),('056033'),('805006'),('805007'),('805008'),('805009'),('805010'),('422008'),('422008'),('422007'),('422007'),('422006'),('422006'),('422010'),('422009'),('422009'),('422011'),('422011'),('209004'),('209004'),('150022'),('100002'),('056035'),('056035'),('056035'),('023036'),('023036'),('185005'),('246001'),('246001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247002'),('247002'),('425001'),('416006'),('416006'),('165042'),('165041'),('165040'),('165043'),('010040'),('010039'),('010038'),('010036'),('248001'),('248002'),('248003'),('248004'),('248005'),('249001'),('249003'),('249004'),('249005'),('250007'),('250001'),('250002'),('250003'),('250004'),('250005'),('250006'),('250008'),('250009'),('250010'),('250011'),('250012'),('250013'),('251001'),('251002'),('806001'),('806002'),('235010'),('243009'),('249007'),('249008'),('249009'),('011024'),('011025'),('429001'),('429001'),('429002'),('429002'),('429003'),('429003'); +select field from t1 group by field; +field +001001 +001010 +001018 +001020 +001021 +001027 +001028 +001030 +001031 +001100 +002003 +002004 +002005 +002007 +002008 +002009 +002012 +002013 +002014 +003002 +003003 +003004 +003005 +003006 +003007 +003008 +003009 +003010 +003011 +003012 +003013 +003014 +003015 +003016 +003017 +003018 +003019 +004003 +004005 +004006 +004008 +004010 +004012 +004014 +004016 +004017 +004020 +004021 +004022 +004023 +004025 +004026 +006004 +006006 +006010 +006011 +006012 +006014 +007001 +007002 +007003 +007005 +007007 +007008 +007009 +007011 +007012 +007013 +007015 +007016 +007017 +007018 +007019 +007020 +007021 +007022 +007023 +007025 +007027 +007029 +007031 +007032 +007034 +007036 +007037 +007038 +007040 +007043 +009001 +009002 +009004 +009005 +009006 +009007 +009008 +009010 +009011 +009012 +009013 +010002 +010003 +010004 +010005 +010006 +010007 +010008 +010009 +010010 +010011 +010012 +010013 +010015 +010016 +010017 +010018 +010019 +010020 +010021 +010022 +010023 +010026 +010027 +010028 +011001 +011002 +011003 +011004 +011006 +011012 +011013 +011014 +011015 +011016 +012017 +012027 +012032 +012034 +012036 +012037 +012038 +012039 +014001 +016016 +016019 +016020 +016021 +016022 +016023 +016024 +016026 +016028 +016029 +016030 +016031 +016032 +016033 +016034 +017002 +018001 +019002 +019004 +020001 +020004 +020006 +020008 +020009 +022001 +022002 +022003 +023001 +023002 +023003 +023004 +023005 +023006 +023007 +023010 +023011 +023017 +023019 +023020 +023025 +023026 +023027 +023028 +023029 +023030 +023032 +023033 +023034 +023035 +025001 +025003 +025004 +025005 +025007 +025008 +025009 +025010 +025011 +025012 +025013 +025014 +025015 +025016 +025018 +025019 +025020 +025021 +025022 +025023 +025024 +025025 +025026 +025027 +025028 +025030 +025031 +025033 +025034 +025035 +025037 +025041 +025042 +025043 +025046 +025048 +025049 +025050 +025051 +025052 +025053 +025054 +025055 +025056 +025057 +025058 +025060 +025061 +025062 +025063 +027001 +027002 +027011 +036001 +037003 +037006 +037007 +037008 +038009 +039001 +039002 +039003 +039004 +039005 +039006 +046001 +046002 +046003 +046005 +046007 +046008 +046009 +046010 +046012 +046013 +046014 +047001 +047002 +048001 +051003 +051004 +052001 +052002 +052005 +053016 +053019 +053023 +053024 +053026 +053028 +053029 +053033 +053045 +053046 +053051 +053054 +053057 +053069 +053097 +053107 +053125 +053127 +054001 +054002 +054003 +054004 +054006 +054007 +054009 +054010 +056001 +056002 +056003 +056004 +056005 +056006 +056009 +056011 +056016 +056017 +056018 +056019 +056020 +056022 +057003 +057004 +058002 +058003 +058004 +058005 +060001 +060004 +060005 +060007 +061004 +061006 +069006 +069007 +069010 +069011 +069012 +069013 +069014 +069015 +069016 +069018 +069020 +069021 +069023 +071002 +071003 +071004 +071005 +071006 +071008 +071011 +071020 +071021 +071022 +072001 +074001 +074002 +074003 +074004 +074005 +074006 +074007 +074008 +074009 +074010 +074011 +074012 +075001 +075007 +076101 +076102 +076103 +077001 +077002 +077003 +077004 +077006 +077008 +077009 +078005 +079002 +079003 +079004 +079005 +079006 +079007 +081001 +082011 +082013 +082014 +082015 +082016 +082017 +082021 +082022 +082023 +082024 +082025 +082026 +082027 +082028 +082029 +082030 +082031 +082032 +082033 +082034 +082035 +082036 +082037 +082038 +082039 +082040 +082041 +082042 +082043 +082044 +084001 +084002 +084003 +084004 +084005 +084007 +084008 +084009 +084011 +084013 +084014 +084016 +084017 +084027 +084032 +084033 +084035 +084036 +084037 +084038 +084039 +084040 +084041 +084042 +084043 +084044 +084045 +084046 +084047 +084048 +084049 +084050 +084051 +085001 +085002 +085003 +085004 +085005 +085006 +085007 +085009 +085011 +085012 +085014 +085015 +085016 +085017 +085018 +085019 +085020 +085022 +085023 +085028 +085029 +085030 +085031 +085033 +085034 +085035 +085036 +085037 +085038 +085040 +085041 +085042 +085043 +085044 +085045 +085046 +085047 +085048 +085063 +085064 +085065 +085068 +085071 +085073 +085082 +085086 +085088 +085089 +085090 +085091 +085092 +085093 +085095 +085096 +085097 +085098 +085099 +085100 +085101 +085102 +085103 +085104 +085105 +085106 +085108 +085109 +085110 +085111 +085112 +085113 +085115 +085120 +085121 +085122 +085123 +085125 +085126 +085127 +085128 +085129 +085130 +085132 +085133 +085134 +085135 +085136 +085137 +086002 +086003 +086005 +088001 +088003 +088005 +088006 +088007 +088008 +088009 +089001 +090001 +090002 +090003 +090004 +090006 +090008 +090009 +090010 +090013 +090016 +090017 +090018 +090022 +090027 +091001 +091002 +091009 +091011 +091012 +091013 +091015 +091016 +091017 +091018 +093003 +099001 +100001 +106001 +113005 +113006 +113018 +113019 +113020 +115001 +115002 +115003 +115004 +115005 +115006 +115007 +115008 +115009 +115010 +115011 +115012 +115013 +115014 +115015 +115016 +115017 +115018 +115020 +115021 +115022 +115023 +115025 +115026 +115027 +115028 +115029 +115030 +115031 +115032 +115033 +115034 +115035 +115036 +115039 +115040 +115041 +115042 +115043 +115044 +115046 +115047 +115048 +115050 +115051 +115052 +115053 +115054 +115055 +115057 +115059 +115060 +115061 +115062 +115064 +115065 +115066 +115067 +115068 +115069 +115070 +115071 +115072 +115073 +115075 +115076 +115081 +115082 +115085 +115086 +115087 +115088 +115095 +115096 +115097 +115098 +115099 +115101 +115102 +115103 +115104 +115105 +115106 +115108 +115109 +115111 +115112 +115113 +115114 +115115 +115116 +115117 +115118 +115119 +115120 +115121 +115122 +116001 +116003 +116004 +116005 +116006 +116007 +116008 +116009 +116010 +116011 +116012 +123001 +124065 +126001 +126002 +126003 +126004 +126005 +126006 +126007 +126008 +126009 +126010 +126011 +126012 +130001 +132001 +132002 +133001 +133008 +133009 +133010 +133011 +133012 +133015 +133016 +133018 +133019 +133021 +133022 +133023 +133024 +133025 +133027 +133028 +133029 +133030 +133031 +134001 +135001 +135002 +135004 +135010 +137010 +137011 +137012 +137014 +137015 +137016 +137019 +139001 +140001 +141001 +141002 +141003 +141006 +141007 +141009 +141011 +141012 +141014 +141015 +141016 +141017 +141018 +141019 +141020 +141021 +141022 +141023 +141024 +141025 +141026 +141027 +141028 +145001 +145002 +145003 +145004 +145005 +145006 +145008 +145009 +145011 +145012 +145013 +150009 +150013 +150014 +150015 +150016 +150017 +150020 +152001 +152002 +152003 +152004 +152005 +152006 +152007 +154001 +154002 +155001 +155002 +155003 +155004 +155006 +159001 +159003 +160001 +160002 +161001 +162002 +162003 +162007 +162012 +163001 +163011 +163015 +163016 +165001 +165002 +165003 +165004 +165005 +165006 +165007 +165008 +165009 +165010 +165011 +165012 +165013 +165014 +165015 +165016 +165017 +165018 +165019 +165020 +165021 +165022 +165023 +165024 +165025 +165026 +165028 +165029 +165030 +165031 +165033 +165034 +165035 +165036 +168003 +168004 +168005 +168014 +169001 +169002 +169003 +169007 +169008 +169009 +169010 +171006 +171007 +171008 +171009 +172001 +176001 +176002 +176003 +177001 +179007 +179012 +179013 +179042 +179044 +179045 +180001 +180013 +180014 +180015 +180017 +180018 +180020 +180021 +180027 +180030 +180033 +180035 +180036 +180037 +180038 +180041 +180042 +180045 +180047 +180048 +180049 +180050 +180054 +180060 +180066 +180067 +180068 +180070 +182001 +184001 +184002 +184005 +184006 +184008 +184009 +184010 +184011 +185001 +185003 +187001 +191002 +192002 +194003 +197001 +197002 +197003 +197004 +197005 +197006 +198001 +198003 +198004 +198005 +198006 +198007 +198008 +198009 +198010 +198011 +198012 +198015 +198016 +198017 +201001 +201002 +202001 +203001 +203002 +203003 +203017 +203018 +203019 +204001 +204002 +205001 +208001 +208002 +208003 +208004 +208005 +209001 +209002 +209003 +210001 +210004 +210009 +210010 +212001 +212002 +212003 +212004 +212005 +212006 +212007 +212008 +212009 +212010 +212011 +212012 +212013 +218001 +218004 +218009 +218011 +218015 +218020 +218021 +218022 +218023 +218024 +218025 +218026 +218027 +218028 +218029 +218030 +218031 +221001 +221002 +221003 +221004 +221005 +221006 +221007 +221008 +221009 +221010 +221011 +221012 +221013 +223003 +224001 +224002 +224003 +224007 +224008 +225001 +225002 +225003 +225004 +225005 +225006 +225007 +225008 +225009 +225010 +225011 +225012 +225013 +226001 +226002 +226003 +226005 +226006 +226007 +227011 +227015 +227041 +227045 +227052 +227056 +227063 +227064 +227066 +227067 +227069 +227071 +227073 +227085 +227116 +227119 +227131 +227133 +227147 +229005 +233003 +233004 +235001 +235002 +235003 +235004 +235005 +236001 +236002 +236003 +238002 +238003 +238004 +238005 +238007 +238008 +334005 +334006 +337001 +337002 +337003 +337004 +343001 +344001 +344002 +344003 +344004 +344005 +345001 +348001 +348004 +348005 +349001 +349002 +350001 +353002 +353003 +355001 +355002 +355005 +355006 +356001 +358001 +359001 +359002 +360001 +360002 +360003 +360004 +360005 +366001 +366002 +366003 +366004 +369001 +373001 +373002 +373003 +373005 +373007 +373008 +373009 +373010 +373011 +373012 +373013 +373014 +373015 +373017 +373018 +373021 +374002 +374004 +374006 +374007 +374008 +374009 +374010 +374011 +374012 +374015 +374016 +382001 +382002 +384001 +386001 +386002 +386003 +386004 +386005 +386006 +386007 +386008 +386009 +386010 +386011 +386012 +386013 +386014 +389001 +389002 +389003 +389004 +392001 +393001 +393002 +393003 +393004 +395001 +397001 +397002 +399001 +399002 +399003 +400001 +400002 +403002 +504001 +504002 +504004 +504005 +504006 +504007 +504008 +504009 +504010 +504011 +504012 +504014 +504017 +504021 +504022 +504023 +504024 +504025 +506001 +506002 +511001 +511002 +511003 +511004 +511005 +511006 +511007 +511008 +511009 +511010 +511011 +511012 +511013 +511014 +511017 +511018 +511020 +511021 +511022 +511024 +511028 +511029 +513001 +513002 +513003 +513004 +515001 +515002 +515003 +515007 +515008 +515011 +515012 +515013 +515014 +515015 +518001 +518002 +521001 +521002 +521003 +521004 +521005 +521006 +521009 +521010 +521011 +521012 +521013 +521015 +521016 +523001 +523002 +523003 +523004 +523005 +523006 +523007 +524001 +700001 +701001 +701002 +701003 +702001 +702002 +702004 +702005 +704001 +704004 +705001 +706001 +706002 +707001 +707002 +707003 +708001 +710001 +710002 +711001 +711002 +712001 +714001 +714002 +715001 +719001 +719002 +991002 +991003 +991004 +991005 +991006 +991007 +995001 +996001 +996002 +996003 +998001 +998002 +998003 +998004 +998005 +998006 +998007 +999001 +999002 +011017 +011018 +034001 +034002 +071010 +519001 +126013 +184012 +404001 +405002 +405001 +405003 +405006 +240011 +240010 +240009 +240008 +240007 +240005 +240004 +240003 +240002 +240001 +240012 +240013 +240014 +240015 +240016 +240017 +357001 +235006 +235007 +056023 +046015 +019005 +126014 +241003 +241002 +241001 +240020 +240019 +242001 +242002 +242004 +242005 +242006 +089002 +406001 +406002 +406003 +406004 +243001 +243005 +243006 +243007 +243008 +408001 +366005 +016035 +077010 +996004 +025064 +011019 +115123 +504026 +039007 +039009 +039008 +039010 +039011 +039012 +180072 +240021 +240023 +405008 +525002 +410002 +410004 +410005 +410006 +410007 +410008 +410009 +410010 +410011 +410012 +410013 +410014 +410016 +344006 +240031 +240030 +240029 +240028 +240027 +240026 +240025 +240024 +240034 +240033 +240032 +411001 +411002 +203020 +069025 +244001 +244002 +244009 +244008 +244007 +244006 +244004 +244003 +244014 +244013 +244012 +244011 +244016 +244017 +240040 +240037 +405009 +405010 +240043 +504028 +504040 +800001 +410019 +410020 +410021 +244018 +244019 +244020 +413001 +344007 +082045 +010031 +010032 +010033 +010034 +010035 +504044 +515016 +801002 +801003 +801004 +801005 +802001 +801001 +414001 +141029 +803001 +803002 +803004 +803005 +803006 +803007 +803008 +803009 +803013 +803014 +803015 +803016 +803017 +410022 +410023 +803019 +415002 +415001 +244021 +011020 +011023 +011022 +011021 +025065 +165037 +165038 +165039 +416001 +416002 +416003 +417001 +418001 +504045 +803022 +240022 +420001 +804010 +804005 +804002 +804018 +804013 +511019 +511016 +511015 +511032 +511031 +511030 +511027 +511026 +511025 +511033 +511023 +133034 +133033 +169011 +344008 +244022 +244026 +244025 +244030 +244023 +244024 +244027 +244028 +244029 +244031 +082046 +082047 +082048 +126015 +126016 +416005 +421001 +421002 +016037 +016036 +115124 +115126 +240049 +240048 +240047 +240046 +240045 +240044 +244032 +244033 +422002 +422004 +422005 +184013 +805001 +805002 +805003 +805004 +805005 +056024 +423001 +344010 +235009 +212014 +056025 +056026 +244034 +244035 +244036 +244037 +244038 +244039 +203015 +245002 +245001 +056029 +056030 +056032 +424001 +056034 +056033 +805006 +805007 +805008 +805009 +805010 +422008 +422007 +422006 +422010 +422009 +422011 +209004 +150022 +100002 +056035 +023036 +185005 +246001 +247001 +247002 +425001 +416006 +165042 +165041 +165040 +165043 +010040 +010039 +010038 +010036 +248001 +248002 +248003 +248004 +248005 +249001 +249003 +249004 +249005 +250007 +250001 +250002 +250003 +250004 +250005 +250006 +250008 +250009 +250010 +250011 +250012 +250013 +251001 +251002 +806001 +806002 +235010 +243009 +249007 +249008 +249009 +011024 +011025 +429001 +429002 +429003 +drop table t1; +create table t1 (a enum (' ','a','b') not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('','a','b') NOT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a enum (' ','a','b ') not null default 'b '); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('','a','b') NOT NULL DEFAULT 'b' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (a enum ('0','1')); +insert into t1 set a='foobar'; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a + +update t1 set a = replace(a,'x','y'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a + +drop table t1; +set names latin1; +create table t1 (a enum(0xE4, '1', '2') not null default 0xE4) character set latin1; +show columns from t1; +Field Type Null Key Default Extra +a enum('','1','2') NO +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('','1','2') NOT NULL DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=latin1 +drop table t1; +set names latin1; +CREATE TABLE t1 ( +a INT default 1, +b ENUM('value','_value','') character set latin1 NOT NULL +); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT '1', + `b` enum('value','_value','') CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +a int YES 1 +b enum('value','_value','') NO NULL +drop table t1; +CREATE TABLE t1 (c enum('a', 'A') BINARY); +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +INSERT INTO t1 VALUES ('a'),('A'); +SELECT * FROM t1; +c +a +A +DROP TABLE t1; +CREATE TABLE t1 (c enum('ae','oe','ue','ss') collate latin1_german2_ci); +INSERT INTO t1 VALUES (''),(''),(''),(''); +SELECT * FROM t1; +c +ae +oe +ue +ss +DROP TABLE t1; +CREATE TABLE t1 ( +a ENUM('','','') character set utf8 default '' +); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('','','') CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (''), (''), (''); +select a from t1 order by a; +a + + + +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 ( +a ENUM('ä','ö','ü') character set latin1 default 'ü' +); +insert into t1 values ('ä'),('ö'),('ü'); +set names latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('','','') CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select a from t1 order by a; +a + + + +drop table t1; +create table t1 (a enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +insert into t1 values ('Y'); +alter table t1 add b set ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +alter table t1 add c enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +select * from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t1 t1 a a 254 1 1 Y 384 0 8 +def test t1 t1 b b 254 3 0 Y 2176 0 8 +def test t1 t1 c c 254 1 0 Y 384 0 8 +a b c +Y NULL NULL +drop table t1; +create table t1 (a enum('x','y') default 'x'); +alter table t1 alter a set default 'z'; +ERROR 42000: Invalid default value for 'a' +drop table t1; +create table t1 (a set('x','y') default 'x'); +alter table t1 alter a set default 'z'; +ERROR 42000: Invalid default value for 'a' +drop table t1; +create table t1 (f1 int); +alter table t1 add f2 enum(0xFFFF); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int DEFAULT NULL, + `f2` enum('') DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(russian enum('E','F','EF','FE') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian` enum('E','F','EF','FE') NOT NULL DEFAULT 'E' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(denormal enum('E','F','E,F','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `denormal` enum('E','F','E,F','F,E') NOT NULL DEFAULT 'E' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(russian_deviant enum('E','F','EF','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian_deviant` enum('E','F','EF','F,E') NOT NULL DEFAULT 'E' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ',' +  !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz')); +drop table t1; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 ENUM('a', '', 'b') +); +INSERT INTO t1 (c1) VALUES (0), ('a'), (''), ('b'); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +SELECT id, c1 + 0, c1 FROM t1; +id c1 + 0 c1 +1 0 +2 1 a +3 2 +4 3 b +ALTER TABLE t1 CHANGE c1 c1 ENUM('a', '') NOT NULL; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 4 +SELECT id, c1 + 0, c1 FROM t1; +id c1 + 0 c1 +1 0 +2 1 a +3 2 +4 0 +DROP TABLE t1; +End of 4.1 tests +create table t1(f1 set('a','b'), index(f1)); +insert into t1 values(''),(''),('a'),('b'); +select * from t1 where f1=''; +f1 + + +drop table t1; +CREATE TABLE t1 (c1 ENUM('a', '', 'b')); +INSERT INTO t1 (c1) VALUES ('b'); +INSERT INTO t1 (c1) VALUES (''); +INSERT INTO t1 (c1) VALUES (0); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +INSERT INTO t1 (c1) VALUES (''); +SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1; +c1 + 0 COUNT(c1) +0 1 +2 2 +3 1 +CREATE TABLE t2 SELECT * FROM t1; +SELECT c1 + 0 FROM t2; +c1 + 0 +0 +2 +2 +3 +DROP TABLE t1,t2; +CREATE TABLE t1(a enum('a','b','c','d')); +INSERT INTO t1 VALUES (4),(1),(0),(3); +Warnings: +Warning 1265 Data truncated for column 'a' at row 3 +ANALYZE TABLE t1; +SELECT a FROM t1; +a +d +a + +c +EXPLAIN SELECT a FROM t1 WHERE a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 24.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 24.00 Using where +Warnings: +Note 1004 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 0) +SELECT a FROM t1 WHERE a=0; +a + +ALTER TABLE t1 ADD PRIMARY KEY (a); +EXPLAIN SELECT a FROM t1 WHERE a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 1 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '' AS `a` from `test`.`t1` where true +SELECT a FROM t1 WHERE a=0; +a + +DROP TABLE t1; +SET sql_mode = default; +End of 5.1 tests +# +# Bug #25481355: Handle long enum literals gracefully. +# +# Handle a column type element < 255 symbols but > 255 bytes. +CREATE TABLE t1(exhausting_charset enum( +'zz')) +CHARSET=utf8mb4; +DROP TABLE t1; +# Fail if the element is > 255 symbols. +CREATE TABLE t1(exhausting_charset enum( +'zz + zz')) +CHARSET=utf8mb4; +ERROR HY000: Too long enumeration/set value for column exhausting_charset. +# Handle a parameter type element < 255 symbols but > 255 bytes. +CREATE PROCEDURE p1(exhausting_charset enum( +'zz') +CHARACTER SET utf8mb4) +BEGIN +END; +DROP PROCEDURE p1; +# Fail if the element is > 255 symbols. +CREATE PROCEDURE p1(exhausting_charset enum( +'zz + zz') +CHARACTER SET utf8mb4) +BEGIN +END; +ERROR HY000: Too long enumeration/set value for column exhausting_charset. +# +# Bug#28777704, Bug#28769996, Field_enum::cmp() hit ASSERT_COLUMN_MARKED_FOR_READ +# +set session optimizer_switch="derived_merge=off"; +set session internal_tmp_mem_storage_engine=temptable; +show function status; +select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE +from INFORMATION_SCHEMA.ROUTINES +where ROUTINE_TYPE = 'FUNCTION' + order by ROUTINE_SCHEMA, ROUTINE_NAME; +set session internal_tmp_mem_storage_engine=default; +set session optimizer_switch="derived_merge=default"; +CREATE TABLE grants ( +USER char(32), +HOST char(60), +PRIV char(32), +WITH_GRANT_OPTION enum('N','Y'), +PRIMARY KEY (WITH_GRANT_OPTION,`USER`,`HOST`, `PRIV`) +) engine innodb; +insert into grants values ('mysql.session','localhost','PERSIST_RO_VARIABLES_ADMIN','N'); +insert into grants values ('mysql.session','localhost','SESSION_VARIABLES_ADMIN','N'); +insert into grants values ('mysql.session','localhost','SYSTEM_VARIABLES_ADMIN','N'); +insert into grants values ('root','localhost','AXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','BXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','CXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','DXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','EXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','FXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','GXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','HXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','IXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','JXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','KXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','LXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','MXA_RECOVER_ADMIN','Y'); +insert into grants values ('root','localhost','XA_RECOVER_ADMIN','Y'); +analyze table grants; +Table Op Msg_type Msg_text +test.grants analyze status OK +EXPLAIN SELECT COUNT(*) FROM grants WHERE priv = 'XA_RECOVER_ADMIN'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE grants NULL range PRIMARY PRIMARY 497 NULL 2 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`grants` where (`test`.`grants`.`PRIV` = 'XA_RECOVER_ADMIN') +SELECT COUNT(*) FROM grants WHERE priv = 'XA_RECOVER_ADMIN'; +COUNT(*) +1 +drop table grants; +# +# Bug #31019130 CASTING DOUBLE TO LONGLONG CAUSES UB +# IN FIELD_*::STORE(DOUBLE) +# +CREATE TABLE t_double (a double not null); +INSERT INTO t_double (a) VALUES +(-20000000000000000000000000000.0001), (20000000000000000000000000000.0001); +CREATE TABLE t_enum ( +b enum('N','Y') +); +INSERT IGNORE INTO t_enum (b) SELECT a from t_double; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +SELECT b FROM t_enum; +b + + +DROP TABLE t_double, t_enum; diff --git a/mysql-test/r/type_float.result-pq b/mysql-test/r/type_float.result-pq new file mode 100644 index 000000000..ab4c47f7a --- /dev/null +++ b/mysql-test/r/type_float.result-pq @@ -0,0 +1,726 @@ +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +SELECT 10,10.0,10.,.1e+2,100.0e-1; +10 10.0 10. .1e+2 100.0e-1 +10 10.0 10 10 10 +SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000; +6e-16 -6e-16 --6e-16 -6e-16+1.000000 +6e-16 -6e-16 6e-16 0.9999999999999994 +SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; +1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1 +10 10 10 10 10 10 0.1 0.1 0.1 +SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; +0.001e+1 0.001e-1 -0.001e+01 -0.001e-01 +0.01 0.0001 -0.01 -0.0001 +SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0; +123.23E+02 -123.23E-02 "123.23E+02"+0.0 "-123.23E-02"+0.0 +12323 -1.2323 12323 -1.2323 +SELECT 2147483647E+02,21474836.47E+06; +2147483647E+02 21474836.47E+06 +214748364700 21474836470000 +create table t1 (f1 float(24),f2 float(52)); +show full columns from t1; +Field Type Collation Null Key Default Extra Privileges Comment +f1 float NULL YES NULL select,insert,update,references +f2 double NULL YES NULL select,insert,update,references +insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); +Warnings: +Warning 1264 Out of range value for column 'f1' at row 7 +Warning 1264 Out of range value for column 'f1' at row 8 +insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); +select * from t1; +f1 f2 +10 10 +100000 100000 +1234570000 1234567890 +10000000000 10000000000 +1e15 1e15 +1e20 1e20 +3.40282e38 1e50 +3.40282e38 1e150 +-10 -10 +0.00001 0.00001 +0.0000000001 0.0000000001 +0.000000000000001 0.000000000000001 +1e-20 1e-20 +0 1e-50 +0 1e-150 +drop table t1; +create table t1 (datum double); +insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5); +select * from t1; +datum +0.5 +1 +1.5 +2 +2.5 +select * from t1 where datum < 1.5; +datum +0.5 +1 +select * from t1 where datum > 1.5; +datum +2 +2.5 +select * from t1 where datum = 1.5; +datum +1.5 +drop table t1; +create table t1 (a decimal(7,3) not null, key (a)); +insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); +select a from t1 order by a; +a +-0.010 +-0.002 +0.000 +0.000 +1.000 +select min(a) from t1; +min(a) +-0.010 +drop table t1; +create table t1 (c1 double, c2 varchar(20)); +insert t1 values (121,"16"); +select c1 + c1 * (c2 / 100) as col from t1; +col +140.36 +create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1; +select * from t2; +col1 col2 col3 col4 +140.36 121 121 0.00000034785054261852176 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `col1` double DEFAULT NULL, + `col2` double DEFAULT NULL, + `col3` double DEFAULT NULL, + `col4` double DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1,t2; +create table t1 (a float); +insert into t1 values (1); +select max(a),min(a),avg(a) from t1; +max(a) min(a) avg(a) +1 1 1 +drop table t1; +create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +show full columns from t1; +Field Type Collation Null Key Default Extra Privileges Comment +f float NULL YES NULL select,insert,update,references +f2 float NULL YES NULL select,insert,update,references +f3 float(6,2) NULL YES NULL select,insert,update,references +d double NULL YES NULL select,insert,update,references +d2 double NULL YES NULL select,insert,update,references +d3 double(10,3) NULL YES NULL select,insert,update,references +de decimal(10,0) NULL YES NULL select,insert,update,references +de2 decimal(6,0) NULL YES NULL select,insert,update,references +de3 decimal(5,2) NULL YES NULL select,insert,update,references +n decimal(10,0) NULL YES NULL select,insert,update,references +n2 decimal(8,0) NULL YES NULL select,insert,update,references +n3 decimal(7,6) NULL YES NULL select,insert,update,references +drop table t1; +create table t1 (a decimal(7,3) not null, key (a)); +insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); +select a from t1 order by a; +a +-0.010 +-0.002 +0.000 +0.000 +1.000 +select min(a) from t1; +min(a) +-0.010 +drop table t1; +create table t1 (a float(200,100), b double(200,100)); +ERROR 42000: Too big scale 100 specified for column 'a'. Maximum is 30. +create table t1 (c20 char); +insert into t1 values (5000.0); +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +insert into t1 values (0.5e4); +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +drop table t1; +create table t1 (f float(54)); +ERROR 42000: Incorrect column specifier for column 'f' +drop table if exists t1; +create table t1 (d1 double, d2 double unsigned); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +insert into t1 set d1 = -1.0; +update t1 set d2 = d1; +Warnings: +Warning 1264 Out of range value for column 'd2' at row 1 +select * from t1; +d1 d2 +-1 0 +drop table t1; +create table t1 (f float(4,3)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11"); +Warnings: +Warning 1264 Out of range value for column 'f' at row 1 +Warning 1264 Out of range value for column 'f' at row 2 +Warning 1264 Out of range value for column 'f' at row 3 +Warning 1264 Out of range value for column 'f' at row 4 +Warning 1264 Out of range value for column 'f' at row 5 +Warning 1264 Out of range value for column 'f' at row 6 +select * from t1; +f +-9.999 +-9.999 +-9.999 +9.999 +9.999 +9.999 +drop table if exists t1; +create table t1 (f double(4,3)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11"); +Warnings: +Warning 1264 Out of range value for column 'f' at row 1 +Warning 1264 Out of range value for column 'f' at row 2 +Warning 1264 Out of range value for column 'f' at row 3 +Warning 1264 Out of range value for column 'f' at row 4 +Warning 1264 Out of range value for column 'f' at row 5 +Warning 1264 Out of range value for column 'f' at row 6 +select * from t1; +f +-9.999 +-9.999 +-9.999 +9.999 +9.999 +9.999 +drop table if exists t1; +create table t1 (c char(20)); +insert into t1 values (5e-28); +select * from t1; +c +5e-28 +drop table t1; +create table t1 (c char(6)); +insert into t1 values (2e5),(2e6),(2e-4),(2e-5); +select * from t1; +c +200000 +2e6 +0.0002 +2e-5 +drop table t1; +create table t1 (d double(10,1)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +create table t2 (d double(10,9)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values ("100000000.0"); +insert into t2 values ("1.23456780"); +create table t3 select * from t2 union select * from t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +select * from t3; +d +1.234567800 +100000000.000000000 +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `d` double(18,9) DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2, t3; +create table t1 select 105213674794682365.00 + 0.0 x; +show warnings; +Level Code Message +desc t1; +Field Type Null Key Default Extra +x decimal(21,2) NO 0.00 +drop table t1; +create table t1 select 0.0 x; +desc t1; +Field Type Null Key Default Extra +x decimal(2,1) NO 0.0 +create table t2 select 105213674794682365.00 y; +desc t2; +Field Type Null Key Default Extra +y decimal(20,2) NO 0.00 +create table t3 select x+y a from t1,t2; +show warnings; +Level Code Message +desc t3; +Field Type Null Key Default Extra +a decimal(21,2) NO 0.00 +drop table t1,t2,t3; +select 1e-308, 1.00000001e-300, 100000000e-300; +1e-308 1.00000001e-300 100000000e-300 +1e-308 1.00000001e-300 1e-292 +select 10e307; +10e307 +1e308 +create table t1(a int, b double(8, 2)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values +(1, 28.50), (1, 121.85), (1, 157.23), (1, 1351.00), (1, -1965.35), (1, 81.75), +(1, 217.08), (1, 7.94), (4, 96.07), (4, 6404.65), (4, -6500.72), (2, 100.00), +(5, 5.00), (5, -2104.80), (5, 2033.80), (5, 0.07), (5, 65.93), +(3, -4986.24), (3, 5.00), (3, 4857.34), (3, 123.74), (3, 0.16), +(6, -1695.31), (6, 1003.77), (6, 499.72), (6, 191.82); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select sum(b) s from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 26 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 26 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`b`) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +select sum(b) s from t1 group by a; +s +-0.00 +-0.00 +0.00 +0.00 +0.00 +100.00 +select sum(b) s from t1 group by a having s <> 0; +s +100.00 +select sum(b) s from t1 group by a having s <> 0 order by s; +s +100.00 +select sum(b) s from t1 group by a having s <=> 0; +s +-0.00 +-0.00 +0.00 +0.00 +0.00 +select sum(b) s from t1 group by a having s <=> 0 order by s; +s +-0.00 +-0.00 +0.00 +0.00 +0.00 +alter table t1 add key (a, b); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select sum(b) s from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 26 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index a a 14 NULL 26 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`b`) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +select sum(b) s from t1 group by a; +s +-0.00 +0.00 +0.00 +0.00 +0.00 +100.00 +select sum(b) s from t1 group by a having s <> 0; +s +100.00 +select sum(b) s from t1 group by a having s <> 0 order by s; +s +100.00 +select sum(b) s from t1 group by a having s <=> 0; +s +-0.00 +0.00 +0.00 +0.00 +0.00 +select sum(b) s from t1 group by a having s <=> 0 order by s; +s +-0.00 +0.00 +0.00 +0.00 +0.00 +drop table t1; +End of 4.1 tests +create table t1 (s1 float(0,2)); +ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1'). +create table t1 (s1 float(1,2)); +ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1'). +CREATE TABLE t1 ( +f1 real zerofill, +f2 double zerofill, +f3 float zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1); +PREPARE stmt1 FROM 'select f1, f2, f3 FROM t1'; +select f1, f2, f3 FROM t1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +select f1, f2, f3 FROM t1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +EXECUTE stmt1; +f1 f2 f3 +0000000000000003.14152 0000000000000003.14152 000003.14152 +DROP TABLE t1; +create table t1 (f1 double(200, 0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (1e199), (-1e199); +insert into t1 values (1e200), (-1e200); +insert into t1 values (2e200), (-2e200); +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +Warning 1264 Out of range value for column 'f1' at row 2 +select f1 + 0e0 from t1; +f1 + 0e0 +1e199 +-1e199 +1e200 +-1e200 +1e200 +-1e200 +drop table t1; +create table t1 (f1 float(30, 0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t1 values (1e29), (-1e29); +insert into t1 values (1e30), (-1e30); +insert into t1 values (2e30), (-2e30); +Warnings: +Warning 1264 Out of range value for column 'f1' at row 1 +Warning 1264 Out of range value for column 'f1' at row 2 +select f1 + 0e0 from t1; +f1 + 0e0 +1.0000000150474662e29 +-1.0000000150474662e29 +1.0000000150474662e30 +-1.0000000150474662e30 +1.0000000150474662e30 +-1.0000000150474662e30 +drop table t1; +create table t1 (c char(6)); +insert into t1 values (2e6),(2e-5); +select * from t1; +c +2e6 +2e-5 +drop table t1; +CREATE TABLE d1 (d DOUBLE); +INSERT INTO d1 VALUES (1.7976931348623157E+308); +SELECT * FROM d1; +d +1.7976931348623157e308 +INSERT INTO d1 VALUES (1.79769313486232e+308); +ERROR 22007: Illegal double '1.79769313486232e+308' value found during parsing +SELECT * FROM d1; +d +1.7976931348623157e308 +DROP TABLE d1; +create table t1 (a char(20)); +insert into t1 values (1.225e-05); +select a+0 from t1; +a+0 +0.00001225 +drop table t1; +create table t1(d double, u bigint unsigned); +insert into t1(d) values (9.22337203685479e18), +(1.84e19); +update t1 set u = d; +select u from t1; +u +9223372036854790144 +18400000000000000000 +drop table t1; +CREATE TABLE t1 (f1 DOUBLE); +INSERT INTO t1 VALUES(-1.79769313486231e+308); +SELECT f1 FROM t1; +f1 +-1.79769313486231e308 +DROP TABLE t1; +# +# Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL +# +# Ignoring output from misc. float operations +select format(-1.7976931348623157E+307,256) as foo; +select least(-1.1111111111111111111111111, +- group_concat(1.7976931348623157E+308)) as foo; +select concat((truncate((-1.7976931348623157E+307),(0x1e))), +(99999999999999999999999999999999999999999999999999999999999999999)) into @a; +End of 5.0 tests +# +# Bug#12368853 FORMAT() CRASHES WITH LARGE NUMBERS AFTER TRUNCATE... +# +select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo; +foo +0 +# +# Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265 +# (WARN_DATA_TRUNCATED) +# +CREATE TABLE t1 (f FLOAT); +INSERT INTO t1 VALUES ('1.'); +INSERT INTO t1 VALUES ('2.0.'); +Warnings: +Warning 1265 Data truncated for column 'f' at row 1 +INSERT INTO t1 VALUES ('.'); +Warnings: +Warning 1265 Data truncated for column 'f' at row 1 +SELECT * FROM t1 ORDER BY f; +f +0 +1 +2 +DROP TABLE t1; +SET sql_mode = default; +# +# Bug#28225635 RUNTIME ERROR: 1E+52 IS OUTSIDE THE RANGE OF +# REPRESENTABLE VALUES OF TYPE FLOAT +# +CREATE TABLE t5u(c1 FLOAT(58,0) UNSIGNED NOT NULL); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5s(c1 FLOAT(58,0) SIGNED NOT NULL); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t5u VALUES('1e+52'); +ERROR 22003: Out of range value for column 'c1' at row 1 +INSERT INTO t5s VALUES('-1e+52'); +ERROR 22003: Out of range value for column 'c1' at row 1 +SELECT * from t5u; +c1 +SELECT * from t5s; +c1 +DROP TABLE t5u, t5s; +# +# WL#12575: Deprecate AUTO_INCREMENT on DOUBLE and FLOAT +# +CREATE TABLE t1(a FLOAT PRIMARY KEY AUTO_INCREMENT); +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t3(a FLOAT); +ALTER TABLE t3 MODIFY COLUMN a FLOAT PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t4(a INT PRIMARY KEY); +ALTER TABLE t4 DROP PRIMARY KEY, ADD COLUMN b FLOAT PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'b'. +DROP TABLE t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE PRIMARY KEY AUTO_INCREMENT); +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t3(a DOUBLE); +ALTER TABLE t3 MODIFY COLUMN a DOUBLE PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'a'. +CREATE TABLE t4(a INT PRIMARY KEY); +ALTER TABLE t4 DROP PRIMARY KEY, ADD COLUMN b DOUBLE PRIMARY KEY AUTO_INCREMENT; +Warnings: +Warning 3856 AUTO_INCREMENT support for FLOAT/DOUBLE columns is deprecated and will be removed in a future release. Consider removing AUTO_INCREMENT from column 'b'. +DROP TABLE t4, t3, t2, t1; +# +# WL#12595: Deprecate the ability to specify number of digits +# for floating point types +# +CREATE TABLE t1(a FLOAT(255,0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a FLOAT); +ALTER TABLE t4 MODIFY COLUMN a FLOAT(255,0); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b FLOAT(255,0); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t6(a FLOAT(12)); +DROP TABLE t6, t5, t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE(42,12)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a DOUBLE); +ALTER TABLE t4 MODIFY COLUMN a DOUBLE(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DOUBLE(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE PRECISION(42,12)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a DOUBLE); +ALTER TABLE t4 MODIFY COLUMN a DOUBLE PRECISION(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DOUBLE PRECISION(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a REAL(42,12)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t4(a REAL); +ALTER TABLE t4 MODIFY COLUMN a REAL(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b REAL(42,12); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE FUNCTION f1(a FLOAT(255,0)) RETURNS DOUBLE(12,3) RETURN 1; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP FUNCTION f1; +CREATE PROCEDURE p1(IN a FLOAT(255,0), OUT b DOUBLE(12,3)) +BEGIN +SELECT 1 INTO b; +END|| +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +DROP PROCEDURE p1; +# +# WL#12391: Deprecate unsigned attribute for DECIMAL and FLOAT data types +# +CREATE TABLE t1(a FLOAT UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a FLOAT); +ALTER TABLE t4 MODIFY COLUMN a FLOAT UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b FLOAT UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a DOUBLE UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a DOUBLE); +ALTER TABLE t4 MODIFY COLUMN a DOUBLE UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DOUBLE UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a REAL UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a REAL); +ALTER TABLE t4 MODIFY COLUMN a REAL UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b REAL UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE TABLE t1(a DECIMAL(4,2) UNSIGNED); +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +ALTER TABLE t1 ADD COLUMN b INT; +CREATE TABLE t2 LIKE t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t3 AS SELECT * FROM t1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t4(a DECIMAL(4,2)); +ALTER TABLE t4 MODIFY COLUMN a DECIMAL(4,2) UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +CREATE TABLE t5(a INT PRIMARY KEY); +ALTER TABLE t5 ADD COLUMN b DECIMAL(4,2) UNSIGNED; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP TABLE t5, t4, t3, t2, t1; +CREATE FUNCTION f1(a FLOAT UNSIGNED) RETURNS DOUBLE UNSIGNED RETURN 1; +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP FUNCTION f1; +CREATE PROCEDURE p1(IN a FLOAT UNSIGNED, OUT b DOUBLE UNSIGNED) +BEGIN +SELECT 1 INTO b; +END|| +Warnings: +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +DROP PROCEDURE p1; diff --git a/mysql-test/r/type_temporal_fractional.result-pq b/mysql-test/r/type_temporal_fractional.result-pq new file mode 100644 index 000000000..bc0b6e8e8 --- /dev/null +++ b/mysql-test/r/type_temporal_fractional.result-pq @@ -0,0 +1,17792 @@ +DROP TABLE IF EXISTS t1, t2; +SET NAMES latin1; +# +# Testing functions CURRENT_TIME and CURRENT_TIMESTAMP +# +SELECT CURRENT_TIME(6) RLIKE '^[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}$'; +CURRENT_TIME(6) RLIKE '^[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}$' +1 +SELECT CURRENT_TIMESTAMP(6) RLIKE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}$'; +CURRENT_TIMESTAMP(6) RLIKE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}$' +1 +SELECT LEFT(CURRENT_TIME(6), 8) = CONCAT(CURRENT_TIME); +LEFT(CURRENT_TIME(6), 8) = CONCAT(CURRENT_TIME) +1 +SELECT LEFT(CURRENT_TIMESTAMP(6), 8) = CONCAT(CURRENT_TIMESTAMP); +LEFT(CURRENT_TIMESTAMP(6), 8) = CONCAT(CURRENT_TIMESTAMP) +0 +SELECT RIGHT(CURRENT_TIME(6), 7) = RIGHT(CURRENT_TIMESTAMP(6), 7); +RIGHT(CURRENT_TIME(6), 7) = RIGHT(CURRENT_TIMESTAMP(6), 7) +1 +SELECT CURRENT_TIMESTAMP(6)=TIMESTAMP(CURRENT_DATE, CURRENT_TIME(6)); +CURRENT_TIMESTAMP(6)=TIMESTAMP(CURRENT_DATE, CURRENT_TIME(6)) +1 +SELECT CURRENT_TIMESTAMP(6)=NOW(6); +CURRENT_TIMESTAMP(6)=NOW(6) +1 +SELECT CURRENT_TIMESTAMP(6)=LOCALTIME(6); +CURRENT_TIMESTAMP(6)=LOCALTIME(6) +1 +SELECT CURRENT_TIMESTAMP(6)=LOCALTIMESTAMP(6); +CURRENT_TIMESTAMP(6)=LOCALTIMESTAMP(6) +1 +SELECT CURRENT_TIMESTAMP(6)<=SYSDATE(6); +CURRENT_TIMESTAMP(6)<=SYSDATE(6) +1 +SELECT CURRENT_TIMESTAMP(6)<=SYSDATE(6) + 0; +CURRENT_TIMESTAMP(6)<=SYSDATE(6) + 0 +1 +SELECT MICROSECOND(CURRENT_TIME(6))=MICROSECOND(UTC_TIME(6)); +MICROSECOND(CURRENT_TIME(6))=MICROSECOND(UTC_TIME(6)) +1 +SELECT MICROSECOND(CURRENT_TIMESTAMP(6))=MICROSECOND(UTC_TIMESTAMP(6)); +MICROSECOND(CURRENT_TIMESTAMP(6))=MICROSECOND(UTC_TIMESTAMP(6)) +1 +CREATE TABLE t1 AS +SELECT +CONCAT(CURRENT_TIME()), CONCAT(CURRENT_TIME(6)), +CONCAT(UTC_TIME()), CONCAT(UTC_TIME(6)), +CONCAT(CURRENT_TIMESTAMP()), CONCAT(CURRENT_TIMESTAMP(6)), +CONCAT(UTC_TIMESTAMP()), CONCAT(UTC_TIMESTAMP(6)), +CONCAT(LOCALTIME()), CONCAT(LOCALTIME(6)), +CONCAT(LOCALTIMESTAMP()), CONCAT(LOCALTIMESTAMP(6)), +CONCAT(SYSDATE()), CONCAT(SYSDATE(6)); +DESCRIBE t1; +Field Type Null Key Default Extra +CONCAT(CURRENT_TIME()) varchar(8) YES NULL +CONCAT(CURRENT_TIME(6)) varchar(15) YES NULL +CONCAT(UTC_TIME()) varchar(8) YES NULL +CONCAT(UTC_TIME(6)) varchar(15) YES NULL +CONCAT(CURRENT_TIMESTAMP()) varchar(19) YES NULL +CONCAT(CURRENT_TIMESTAMP(6)) varchar(26) YES NULL +CONCAT(UTC_TIMESTAMP()) varchar(19) YES NULL +CONCAT(UTC_TIMESTAMP(6)) varchar(26) YES NULL +CONCAT(LOCALTIME()) varchar(19) YES NULL +CONCAT(LOCALTIME(6)) varchar(26) YES NULL +CONCAT(LOCALTIMESTAMP()) varchar(19) YES NULL +CONCAT(LOCALTIMESTAMP(6)) varchar(26) YES NULL +CONCAT(SYSDATE()) varchar(19) YES NULL +CONCAT(SYSDATE(6)) varchar(26) YES NULL +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +NOW(0), NOW(1), NOW(2), NOW(3), NOW(4), NOW(5), NOW(6); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `NOW(0)` datetime NOT NULL, + `NOW(1)` datetime(1) NOT NULL, + `NOW(2)` datetime(2) NOT NULL, + `NOW(3)` datetime(3) NOT NULL, + `NOW(4)` datetime(4) NOT NULL, + `NOW(5)` datetime(5) NOT NULL, + `NOW(6)` datetime(6) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +SYSDATE(0), +SYSDATE(1), SYSDATE(2), SYSDATE(3), +SYSDATE(4), SYSDATE(5), SYSDATE(6); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `SYSDATE(0)` datetime NOT NULL, + `SYSDATE(1)` datetime(1) NOT NULL, + `SYSDATE(2)` datetime(2) NOT NULL, + `SYSDATE(3)` datetime(3) NOT NULL, + `SYSDATE(4)` datetime(4) NOT NULL, + `SYSDATE(5)` datetime(5) NOT NULL, + `SYSDATE(6)` datetime(6) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +FROM_UNIXTIME(1), +FROM_UNIXTIME(1.1), FROM_UNIXTIME(1.12), FROM_UNIXTIME(1.123), +FROM_UNIXTIME(1.1234), FROM_UNIXTIME(1.12345), FROM_UNIXTIME(1.123456), +FROM_UNIXTIME(1.1234567); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `FROM_UNIXTIME(1)` datetime DEFAULT NULL, + `FROM_UNIXTIME(1.1)` datetime(1) DEFAULT NULL, + `FROM_UNIXTIME(1.12)` datetime(2) DEFAULT NULL, + `FROM_UNIXTIME(1.123)` datetime(3) DEFAULT NULL, + `FROM_UNIXTIME(1.1234)` datetime(4) DEFAULT NULL, + `FROM_UNIXTIME(1.12345)` datetime(5) DEFAULT NULL, + `FROM_UNIXTIME(1.123456)` datetime(6) DEFAULT NULL, + `FROM_UNIXTIME(1.1234567)` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing rounding from VARCHAR and TIME(6) to TIME(N) +# +CREATE TABLE t1 (a VARCHAR(32), +t6 TIME(6), t5 TIME(5), t4 TIME(4), +t3 TIME(3), t2 TIME(2), t1 TIME(1), +t0 TIME); +INSERT INTO t1 (a) VALUES ('10:10:10.999999'); +INSERT INTO t1 (a) VALUES ('10:10:10.999994'); +INSERT INTO t1 (a) VALUES ('10:10:10.999949'); +INSERT INTO t1 (a) VALUES ('10:10:10.999499'); +INSERT INTO t1 (a) VALUES ('10:10:10.994999'); +INSERT INTO t1 (a) VALUES ('10:10:10.949999'); +INSERT INTO t1 (a) VALUES ('10:10:10.499999'); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 10:10:10.999999 +t6 10:10:10.999999 +t5 10:10:11.00000 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.999994 +t6 10:10:10.999994 +t5 10:10:10.99999 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.999949 +t6 10:10:10.999949 +t5 10:10:10.99995 +t4 10:10:10.9999 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.999499 +t6 10:10:10.999499 +t5 10:10:10.99950 +t4 10:10:10.9995 +t3 10:10:10.999 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.994999 +t6 10:10:10.994999 +t5 10:10:10.99500 +t4 10:10:10.9950 +t3 10:10:10.995 +t2 10:10:10.99 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.949999 +t6 10:10:10.949999 +t5 10:10:10.95000 +t4 10:10:10.9500 +t3 10:10:10.950 +t2 10:10:10.95 +t1 10:10:10.9 +t0 10:10:11 +a 10:10:10.499999 +t6 10:10:10.499999 +t5 10:10:10.50000 +t4 10:10:10.5000 +t3 10:10:10.500 +t2 10:10:10.50 +t1 10:10:10.5 +t0 10:10:10 +ALTER TABLE t1 MODIFY a TIME(6); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 10:10:10.999999 +t6 10:10:10.999999 +t5 10:10:11.00000 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.999994 +t6 10:10:10.999994 +t5 10:10:10.99999 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.999949 +t6 10:10:10.999949 +t5 10:10:10.99995 +t4 10:10:10.9999 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.999499 +t6 10:10:10.999499 +t5 10:10:10.99950 +t4 10:10:10.9995 +t3 10:10:10.999 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.994999 +t6 10:10:10.994999 +t5 10:10:10.99500 +t4 10:10:10.9950 +t3 10:10:10.995 +t2 10:10:10.99 +t1 10:10:11.0 +t0 10:10:11 +a 10:10:10.949999 +t6 10:10:10.949999 +t5 10:10:10.95000 +t4 10:10:10.9500 +t3 10:10:10.950 +t2 10:10:10.95 +t1 10:10:10.9 +t0 10:10:11 +a 10:10:10.499999 +t6 10:10:10.499999 +t5 10:10:10.50000 +t4 10:10:10.5000 +t3 10:10:10.500 +t2 10:10:10.50 +t1 10:10:10.5 +t0 10:10:10 +DROP TABLE t1; +# +# Testing rounding from TIME(N) to INT +# +CREATE TABLE t1 (a INT, b TIME(6)); +INSERT INTO t1 (b) VALUES ('10:10:59.500000'); +INSERT INTO t1 (b) VALUES ('10:10:10.500000'); +INSERT INTO t1 (b) VALUES ('10:10:10.499999'); +INSERT INTO t1 (b) VALUES ('-10:10:59.500000'); +INSERT INTO t1 (b) VALUES ('-10:10:10.500000'); +INSERT INTO t1 (b) VALUES ('-10:10:10.499999'); +UPDATE t1 SET a=b; +SELECT * FROM t1; +a b +101100 10:10:59.500000 +101011 10:10:10.500000 +101010 10:10:10.499999 +-101100 -10:10:59.500000 +-101011 -10:10:10.500000 +-101010 -10:10:10.499999 +DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (TIME'01:59:59.499999'); +INSERT INTO t1 VALUES (TIME'01:59:59.500000'); +SELECT * FROM t1; +a +15959 +20000 +DROP TABLE t1; +# +# Inserting TIME into a REAL column +# +CREATE TABLE t1 (a REAL); +INSERT INTO t1 VALUES (TIME'01:02:03.123'); +SELECT * FROM t1; +a +10203.123 +DROP TABLE t1; +# +# Testing rounding when altering TIME(N) to a smaller size +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('10:10:10.999999'); +ALTER TABLE t1 MODIFY a TIME(5); +SELECT * FROM t1; +a +10:10:11.00000 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('10:10:10.999999'); +ALTER TABLE t1 MODIFY a TIME; +SELECT * FROM t1; +a +10:10:11 +DROP TABLE t1; +# +# Testing rounding from DATETIME(6) to TIME(N) +# +CREATE TABLE t1 (a DATETIME(6), +t6 TIME(6), t5 TIME(5), t4 TIME(4), +t3 TIME(3), t2 TIME(2), t1 TIME(1), +t0 TIME); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999994'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999949'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999499'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.994999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.949999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.499999'); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 2001-01-01 10:10:10.999999 +t6 10:10:10.999999 +t5 10:10:11.00000 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 2001-01-01 10:10:10.999994 +t6 10:10:10.999994 +t5 10:10:10.99999 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 2001-01-01 10:10:10.999949 +t6 10:10:10.999949 +t5 10:10:10.99995 +t4 10:10:10.9999 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 2001-01-01 10:10:10.999499 +t6 10:10:10.999499 +t5 10:10:10.99950 +t4 10:10:10.9995 +t3 10:10:10.999 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 2001-01-01 10:10:10.994999 +t6 10:10:10.994999 +t5 10:10:10.99500 +t4 10:10:10.9950 +t3 10:10:10.995 +t2 10:10:10.99 +t1 10:10:11.0 +t0 10:10:11 +a 2001-01-01 10:10:10.949999 +t6 10:10:10.949999 +t5 10:10:10.95000 +t4 10:10:10.9500 +t3 10:10:10.950 +t2 10:10:10.95 +t1 10:10:10.9 +t0 10:10:11 +a 2001-01-01 10:10:10.499999 +t6 10:10:10.499999 +t5 10:10:10.50000 +t4 10:10:10.5000 +t3 10:10:10.500 +t2 10:10:10.50 +t1 10:10:10.5 +t0 10:10:10 +DROP TABLE t1; +# +# Testing rounding from DECIMAL and DOUBLE to TIME(N) +# +CREATE TABLE t1 (a DECIMAL(30,6), +t6 TIME(6), t5 TIME(5), t4 TIME(4), +t3 TIME(3), t2 TIME(2), t1 TIME(1), +t0 TIME); +INSERT INTO t1 (a) VALUES (101010.999999); +INSERT INTO t1 (a) VALUES (101010.999994); +INSERT INTO t1 (a) VALUES (101010.999949); +INSERT INTO t1 (a) VALUES (101010.999499); +INSERT INTO t1 (a) VALUES (101010.994999); +INSERT INTO t1 (a) VALUES (101010.949999); +INSERT INTO t1 (a) VALUES (101010.499999); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 101010.999999 +t6 10:10:10.999999 +t5 10:10:11.00000 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.999994 +t6 10:10:10.999994 +t5 10:10:10.99999 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.999949 +t6 10:10:10.999949 +t5 10:10:10.99995 +t4 10:10:10.9999 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.999499 +t6 10:10:10.999499 +t5 10:10:10.99950 +t4 10:10:10.9995 +t3 10:10:10.999 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.994999 +t6 10:10:10.994999 +t5 10:10:10.99500 +t4 10:10:10.9950 +t3 10:10:10.995 +t2 10:10:10.99 +t1 10:10:11.0 +t0 10:10:11 +a 101010.949999 +t6 10:10:10.949999 +t5 10:10:10.95000 +t4 10:10:10.9500 +t3 10:10:10.950 +t2 10:10:10.95 +t1 10:10:10.9 +t0 10:10:11 +a 101010.499999 +t6 10:10:10.499999 +t5 10:10:10.50000 +t4 10:10:10.5000 +t3 10:10:10.500 +t2 10:10:10.50 +t1 10:10:10.5 +t0 10:10:10 +ALTER TABLE t1 MODIFY a DOUBLE; +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 101010.999999 +t6 10:10:10.999999 +t5 10:10:11.00000 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.999994 +t6 10:10:10.999994 +t5 10:10:10.99999 +t4 10:10:11.0000 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.999949 +t6 10:10:10.999949 +t5 10:10:10.99995 +t4 10:10:10.9999 +t3 10:10:11.000 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.999499 +t6 10:10:10.999499 +t5 10:10:10.99950 +t4 10:10:10.9995 +t3 10:10:10.999 +t2 10:10:11.00 +t1 10:10:11.0 +t0 10:10:11 +a 101010.994999 +t6 10:10:10.994999 +t5 10:10:10.99500 +t4 10:10:10.9950 +t3 10:10:10.995 +t2 10:10:10.99 +t1 10:10:11.0 +t0 10:10:11 +a 101010.949999 +t6 10:10:10.949999 +t5 10:10:10.95000 +t4 10:10:10.9500 +t3 10:10:10.950 +t2 10:10:10.95 +t1 10:10:10.9 +t0 10:10:11 +a 101010.499999 +t6 10:10:10.499999 +t5 10:10:10.50000 +t4 10:10:10.5000 +t3 10:10:10.500 +t2 10:10:10.50 +t1 10:10:10.5 +t0 10:10:10 +DROP TABLE t1; +# +# Testing rounding when casting from DECIMAL to TIME(N) +# +CREATE TABLE t1 (a DECIMAL(23,4)); +INSERT INTO t1 VALUES (NULL),(101010.9999),(-101010.9999); +INSERT IGNORE INTO t1 VALUES (9999999999999999999999.1), (999999.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT a, CAST(a AS TIME(3)) FROM t1; +a CAST(a AS TIME(3)) +NULL NULL +101010.9999 10:10:11.000 +-101010.9999 -10:10:11.000 +9999999999999999999.9999 NULL +999999.1000 NULL +Warnings: +Warning 1292 Truncated incorrect time value: '9999999999999999999.9999' +Warning 1292 Truncated incorrect time value: '999999.1000' +DROP TABLE t1; +# +# Testing that CAST converts days to hours, while EXTRACT/HOUR do not +# +SELECT CAST('1 00:00:00' as TIME), EXTRACT(HOUR FROM '1 00:00:00'), HOUR('1 00:00:00'); +CAST('1 00:00:00' as TIME) EXTRACT(HOUR FROM '1 00:00:00') HOUR('1 00:00:00') +24:00:00 24 24 +CREATE TABLE t1 (a VARCHAR(30)); +INSERT INTO t1 VALUES ('1 00:00:00'); +SELECT CAST(a AS TIME), EXTRACT(HOUR FROM a), HOUR(a) FROM t1; +CAST(a AS TIME) EXTRACT(HOUR FROM a) HOUR(a) +24:00:00 24 24 +DROP TABLE t1; +# +# Testing rounding with CAST +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('10:10:10.999999'); +INSERT INTO t1 VALUES ('10:10:10.999998'); +INSERT INTO t1 VALUES ('10:10:10.999997'); +INSERT INTO t1 VALUES ('10:10:10.999996'); +INSERT INTO t1 VALUES ('10:10:10.999995'); +INSERT INTO t1 VALUES ('10:10:10.999994'); +INSERT INTO t1 VALUES ('10:10:10.999993'); +INSERT INTO t1 VALUES ('10:10:10.999992'); +INSERT INTO t1 VALUES ('10:10:10.999991'); +INSERT INTO t1 VALUES ('10:10:10.999990'); +SELECT a, CAST(a AS TIME(5)) FROM t1; +a CAST(a AS TIME(5)) +10:10:10.999999 10:10:11.00000 +10:10:10.999998 10:10:11.00000 +10:10:10.999997 10:10:11.00000 +10:10:10.999996 10:10:11.00000 +10:10:10.999995 10:10:11.00000 +10:10:10.999994 10:10:10.99999 +10:10:10.999993 10:10:10.99999 +10:10:10.999992 10:10:10.99999 +10:10:10.999991 10:10:10.99999 +10:10:10.999990 10:10:10.99999 +UPDATE t1 SET a=-a; +SELECT a, CAST(a AS TIME(5)) FROM t1; +a CAST(a AS TIME(5)) +-10:10:10.999999 -10:10:11.00000 +-10:10:10.999998 -10:10:11.00000 +-10:10:10.999997 -10:10:11.00000 +-10:10:10.999996 -10:10:11.00000 +-10:10:10.999995 -10:10:11.00000 +-10:10:10.999994 -10:10:10.99999 +-10:10:10.999993 -10:10:10.99999 +-10:10:10.999992 -10:10:10.99999 +-10:10:10.999991 -10:10:10.99999 +-10:10:10.999990 -10:10:10.99999 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(5)); +INSERT INTO t1 VALUES ('10:10:10.99999'); +INSERT INTO t1 VALUES ('10:10:10.99998'); +INSERT INTO t1 VALUES ('10:10:10.99997'); +INSERT INTO t1 VALUES ('10:10:10.99996'); +INSERT INTO t1 VALUES ('10:10:10.99995'); +INSERT INTO t1 VALUES ('10:10:10.99994'); +INSERT INTO t1 VALUES ('10:10:10.99993'); +INSERT INTO t1 VALUES ('10:10:10.99992'); +INSERT INTO t1 VALUES ('10:10:10.99991'); +INSERT INTO t1 VALUES ('10:10:10.99990'); +SELECT a, CAST(a AS TIME(4)) FROM t1; +a CAST(a AS TIME(4)) +10:10:10.99999 10:10:11.0000 +10:10:10.99998 10:10:11.0000 +10:10:10.99997 10:10:11.0000 +10:10:10.99996 10:10:11.0000 +10:10:10.99995 10:10:11.0000 +10:10:10.99994 10:10:10.9999 +10:10:10.99993 10:10:10.9999 +10:10:10.99992 10:10:10.9999 +10:10:10.99991 10:10:10.9999 +10:10:10.99990 10:10:10.9999 +UPDATE t1 SET a=-a; +SELECT a, CAST(a AS TIME(4)) FROM t1; +a CAST(a AS TIME(4)) +-10:10:10.99999 -10:10:11.0000 +-10:10:10.99998 -10:10:11.0000 +-10:10:10.99997 -10:10:11.0000 +-10:10:10.99996 -10:10:11.0000 +-10:10:10.99995 -10:10:11.0000 +-10:10:10.99994 -10:10:10.9999 +-10:10:10.99993 -10:10:10.9999 +-10:10:10.99992 -10:10:10.9999 +-10:10:10.99991 -10:10:10.9999 +-10:10:10.99990 -10:10:10.9999 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(4)); +INSERT INTO t1 VALUES ('10:10:10.9999'); +INSERT INTO t1 VALUES ('10:10:10.9998'); +INSERT INTO t1 VALUES ('10:10:10.9997'); +INSERT INTO t1 VALUES ('10:10:10.9996'); +INSERT INTO t1 VALUES ('10:10:10.9995'); +INSERT INTO t1 VALUES ('10:10:10.9994'); +INSERT INTO t1 VALUES ('10:10:10.9993'); +INSERT INTO t1 VALUES ('10:10:10.9992'); +INSERT INTO t1 VALUES ('10:10:10.9991'); +INSERT INTO t1 VALUES ('10:10:10.9990'); +SELECT a, CAST(a AS TIME(3)) FROM t1; +a CAST(a AS TIME(3)) +10:10:10.9999 10:10:11.000 +10:10:10.9998 10:10:11.000 +10:10:10.9997 10:10:11.000 +10:10:10.9996 10:10:11.000 +10:10:10.9995 10:10:11.000 +10:10:10.9994 10:10:10.999 +10:10:10.9993 10:10:10.999 +10:10:10.9992 10:10:10.999 +10:10:10.9991 10:10:10.999 +10:10:10.9990 10:10:10.999 +UPDATE t1 SET a=-a; +SELECT a, CAST(a AS TIME(3)) FROM t1; +a CAST(a AS TIME(3)) +-10:10:10.9999 -10:10:11.000 +-10:10:10.9998 -10:10:11.000 +-10:10:10.9997 -10:10:11.000 +-10:10:10.9996 -10:10:11.000 +-10:10:10.9995 -10:10:11.000 +-10:10:10.9994 -10:10:10.999 +-10:10:10.9993 -10:10:10.999 +-10:10:10.9992 -10:10:10.999 +-10:10:10.9991 -10:10:10.999 +-10:10:10.9990 -10:10:10.999 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(3)); +INSERT INTO t1 VALUES ('10:10:10.999'); +INSERT INTO t1 VALUES ('10:10:10.998'); +INSERT INTO t1 VALUES ('10:10:10.997'); +INSERT INTO t1 VALUES ('10:10:10.996'); +INSERT INTO t1 VALUES ('10:10:10.995'); +INSERT INTO t1 VALUES ('10:10:10.994'); +INSERT INTO t1 VALUES ('10:10:10.993'); +INSERT INTO t1 VALUES ('10:10:10.992'); +INSERT INTO t1 VALUES ('10:10:10.991'); +INSERT INTO t1 VALUES ('10:10:10.990'); +SELECT a, CAST(a AS TIME(2)) FROM t1; +a CAST(a AS TIME(2)) +10:10:10.999 10:10:11.00 +10:10:10.998 10:10:11.00 +10:10:10.997 10:10:11.00 +10:10:10.996 10:10:11.00 +10:10:10.995 10:10:11.00 +10:10:10.994 10:10:10.99 +10:10:10.993 10:10:10.99 +10:10:10.992 10:10:10.99 +10:10:10.991 10:10:10.99 +10:10:10.990 10:10:10.99 +UPDATE t1 SET a=-a; +SELECT a, CAST(a AS TIME(2)) FROM t1; +a CAST(a AS TIME(2)) +-10:10:10.999 -10:10:11.00 +-10:10:10.998 -10:10:11.00 +-10:10:10.997 -10:10:11.00 +-10:10:10.996 -10:10:11.00 +-10:10:10.995 -10:10:11.00 +-10:10:10.994 -10:10:10.99 +-10:10:10.993 -10:10:10.99 +-10:10:10.992 -10:10:10.99 +-10:10:10.991 -10:10:10.99 +-10:10:10.990 -10:10:10.99 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(2)); +INSERT INTO t1 VALUES ('10:10:10.99'); +INSERT INTO t1 VALUES ('10:10:10.98'); +INSERT INTO t1 VALUES ('10:10:10.97'); +INSERT INTO t1 VALUES ('10:10:10.96'); +INSERT INTO t1 VALUES ('10:10:10.95'); +INSERT INTO t1 VALUES ('10:10:10.94'); +INSERT INTO t1 VALUES ('10:10:10.93'); +INSERT INTO t1 VALUES ('10:10:10.92'); +INSERT INTO t1 VALUES ('10:10:10.91'); +INSERT INTO t1 VALUES ('10:10:10.90'); +SELECT a, CAST(a AS TIME(1)) FROM t1; +a CAST(a AS TIME(1)) +10:10:10.99 10:10:11.0 +10:10:10.98 10:10:11.0 +10:10:10.97 10:10:11.0 +10:10:10.96 10:10:11.0 +10:10:10.95 10:10:11.0 +10:10:10.94 10:10:10.9 +10:10:10.93 10:10:10.9 +10:10:10.92 10:10:10.9 +10:10:10.91 10:10:10.9 +10:10:10.90 10:10:10.9 +UPDATE t1 SET a=-a; +SELECT a, CAST(a AS TIME(1)) FROM t1; +a CAST(a AS TIME(1)) +-10:10:10.99 -10:10:11.0 +-10:10:10.98 -10:10:11.0 +-10:10:10.97 -10:10:11.0 +-10:10:10.96 -10:10:11.0 +-10:10:10.95 -10:10:11.0 +-10:10:10.94 -10:10:10.9 +-10:10:10.93 -10:10:10.9 +-10:10:10.92 -10:10:10.9 +-10:10:10.91 -10:10:10.9 +-10:10:10.90 -10:10:10.9 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(1)); +INSERT INTO t1 VALUES ('10:10:10.9'); +INSERT INTO t1 VALUES ('10:10:10.8'); +INSERT INTO t1 VALUES ('10:10:10.7'); +INSERT INTO t1 VALUES ('10:10:10.6'); +INSERT INTO t1 VALUES ('10:10:10.5'); +INSERT INTO t1 VALUES ('10:10:10.4'); +INSERT INTO t1 VALUES ('10:10:10.3'); +INSERT INTO t1 VALUES ('10:10:10.2'); +INSERT INTO t1 VALUES ('10:10:10.1'); +INSERT INTO t1 VALUES ('10:10:10.0'); +SELECT a, CAST(a AS TIME) FROM t1; +a CAST(a AS TIME) +10:10:10.9 10:10:11 +10:10:10.8 10:10:11 +10:10:10.7 10:10:11 +10:10:10.6 10:10:11 +10:10:10.5 10:10:11 +10:10:10.4 10:10:10 +10:10:10.3 10:10:10 +10:10:10.2 10:10:10 +10:10:10.1 10:10:10 +10:10:10.0 10:10:10 +UPDATE t1 SET a=-a; +SELECT a, CAST(a AS TIME) FROM t1; +a CAST(a AS TIME) +-10:10:10.9 -10:10:11 +-10:10:10.8 -10:10:11 +-10:10:10.7 -10:10:11 +-10:10:10.6 -10:10:11 +-10:10:10.5 -10:10:11 +-10:10:10.4 -10:10:10 +-10:10:10.3 -10:10:10 +-10:10:10.2 -10:10:10 +-10:10:10.1 -10:10:10 +-10:10:10.0 -10:10:10 +DROP TABLE t1; +# +# Testing rounding with FROM_UNIXTIME +# +SET time_zone='+00:00'; +CREATE TABLE t1 (a DECIMAL(20,7)); +INSERT INTO t1 VALUES +(2147483647.999999), +(2147483647.9999990), +(2147483647.9999991), +(2147483647.9999992), +(2147483647.9999993), +(2147483647.9999994), +(2147483647.9999995), +(2147483647.9999996), +(2147483647.9999997), +(2147483647.9999998), +(2147483647.9999999); +SELECT a, FROM_UNIXTIME(a) FROM t1; +a FROM_UNIXTIME(a) +2147483647.9999990 2038-01-19 03:14:07.999999 +2147483647.9999990 2038-01-19 03:14:07.999999 +2147483647.9999991 2038-01-19 03:14:07.999999 +2147483647.9999992 2038-01-19 03:14:07.999999 +2147483647.9999993 2038-01-19 03:14:07.999999 +2147483647.9999994 2038-01-19 03:14:07.999999 +2147483647.9999995 NULL +2147483647.9999996 NULL +2147483647.9999997 NULL +2147483647.9999998 NULL +2147483647.9999999 NULL +DROP TABLE t1; +SET time_zone=DEFAULT; +# +# Testing internal representation format for TIME(N) +# +CREATE TABLE t1 (a6 VARCHAR(32)); +INSERT INTO t1 VALUES ('00:00:00.000000'); +INSERT INTO t1 VALUES ('00:00:00.000001'); +INSERT INTO t1 VALUES ('00:00:00.000002'); +INSERT INTO t1 VALUES ('00:00:00.000003'); +INSERT INTO t1 VALUES ('00:00:00.000004'); +INSERT INTO t1 VALUES ('00:00:00.000005'); +INSERT INTO t1 VALUES ('00:00:00.000006'); +INSERT INTO t1 VALUES ('00:00:00.000007'); +INSERT INTO t1 VALUES ('00:00:00.000008'); +INSERT INTO t1 VALUES ('00:00:00.000009'); +INSERT INTO t1 VALUES ('00:00:00.000010'); +INSERT INTO t1 VALUES ('00:00:00.000011'); +INSERT INTO t1 VALUES ('00:00:00.000012'); +INSERT INTO t1 VALUES ('00:00:00.000013'); +INSERT INTO t1 VALUES ('00:00:00.000014'); +INSERT INTO t1 VALUES ('00:00:00.000015'); +INSERT INTO t1 VALUES ('00:00:00.000016'); +INSERT INTO t1 VALUES ('00:00:00.000099'); +INSERT INTO t1 VALUES ('00:00:00.000999'); +INSERT INTO t1 VALUES ('00:00:00.009999'); +INSERT INTO t1 VALUES ('00:00:00.099999'); +INSERT INTO t1 VALUES ('00:00:00.100000'); +INSERT INTO t1 VALUES ('00:00:00.900000'); +INSERT INTO t1 VALUES ('00:00:00.990000'); +INSERT INTO t1 VALUES ('00:00:00.999000'); +INSERT INTO t1 VALUES ('00:00:00.999900'); +INSERT INTO t1 VALUES ('00:00:00.999990'); +INSERT INTO t1 VALUES ('00:00:00.999999'); +INSERT INTO t1 VALUES ('00:00:01.000000'); +INSERT INTO t1 VALUES ('00:00:01.000001'); +INSERT INTO t1 VALUES ('00:00:01.000002'); +INSERT INTO t1 VALUES ('00:00:01.000003'); +INSERT INTO t1 VALUES ('00:00:01.000004'); +INSERT INTO t1 VALUES ('00:00:01.000005'); +INSERT INTO t1 VALUES ('00:00:01.000006'); +INSERT INTO t1 VALUES ('00:00:01.000007'); +INSERT INTO t1 VALUES ('00:00:01.000008'); +INSERT INTO t1 VALUES ('00:00:01.000009'); +INSERT INTO t1 VALUES ('00:00:01.000010'); +INSERT INTO t1 VALUES ('00:00:01.000011'); +INSERT INTO t1 VALUES ('00:00:01.000012'); +INSERT INTO t1 VALUES ('00:00:01.000013'); +INSERT INTO t1 VALUES ('00:00:01.000014'); +INSERT INTO t1 VALUES ('00:00:01.000015'); +INSERT INTO t1 VALUES ('00:00:01.000016'); +INSERT INTO t1 VALUES ('00:00:01.000099'); +INSERT INTO t1 VALUES ('00:00:01.000999'); +INSERT INTO t1 VALUES ('00:00:01.009999'); +INSERT INTO t1 VALUES ('00:00:01.090000'); +INSERT INTO t1 VALUES ('00:00:01.099999'); +INSERT INTO t1 VALUES ('00:00:01.100000'); +INSERT INTO t1 VALUES ('00:00:01.900000'); +INSERT INTO t1 VALUES ('00:00:01.990000'); +INSERT INTO t1 VALUES ('00:00:01.999000'); +INSERT INTO t1 VALUES ('00:00:01.999900'); +INSERT INTO t1 VALUES ('00:00:01.999990'); +INSERT INTO t1 VALUES ('00:00:01.999999'); +INSERT INTO t1 VALUES ('00:01:00.000001'); +INSERT INTO t1 VALUES ('00:01:00.000008'); +INSERT INTO t1 VALUES ('00:01:00.000015'); +INSERT INTO t1 VALUES ('00:01:00.000016'); +INSERT INTO t1 VALUES ('00:01:00.000099'); +INSERT INTO t1 VALUES ('00:01:00.000999'); +INSERT INTO t1 VALUES ('00:01:00.009999'); +INSERT INTO t1 VALUES ('00:01:00.099999'); +INSERT INTO t1 VALUES ('00:01:00.100000'); +INSERT INTO t1 VALUES ('00:01:00.900000'); +INSERT INTO t1 VALUES ('00:01:00.999999'); +INSERT INTO t1 VALUES ('01:00:00.000001'); +INSERT INTO t1 VALUES ('01:00:00.000008'); +INSERT INTO t1 VALUES ('01:00:00.000015'); +INSERT INTO t1 VALUES ('01:00:00.000016'); +INSERT INTO t1 VALUES ('01:00:00.000099'); +INSERT INTO t1 VALUES ('01:00:00.000999'); +INSERT INTO t1 VALUES ('01:00:00.009999'); +INSERT INTO t1 VALUES ('01:00:00.099999'); +INSERT INTO t1 VALUES ('01:00:00.100000'); +INSERT INTO t1 VALUES ('01:00:00.900000'); +INSERT INTO t1 VALUES ('01:00:00.990000'); +INSERT INTO t1 VALUES ('01:00:00.999000'); +INSERT INTO t1 VALUES ('01:00:00.999900'); +INSERT INTO t1 VALUES ('01:00:00.999990'); +INSERT INTO t1 VALUES ('01:00:00.999999'); +INSERT INTO t1 VALUES ('838:59:58.000001'); +INSERT INTO t1 VALUES ('838:59:58.000008'); +INSERT INTO t1 VALUES ('838:59:58.000015'); +INSERT INTO t1 VALUES ('838:59:58.000016'); +INSERT INTO t1 VALUES ('838:59:58.000099'); +INSERT INTO t1 VALUES ('838:59:58.000999'); +INSERT INTO t1 VALUES ('838:59:58.009999'); +INSERT INTO t1 VALUES ('838:59:58.099999'); +INSERT INTO t1 VALUES ('838:59:58.100000'); +INSERT INTO t1 VALUES ('838:59:58.900000'); +INSERT INTO t1 VALUES ('838:59:58.990000'); +INSERT INTO t1 VALUES ('838:59:58.999000'); +INSERT INTO t1 VALUES ('838:59:58.999900'); +INSERT INTO t1 VALUES ('838:59:58.999990'); +INSERT INTO t1 VALUES ('838:59:58.999999'); +INSERT INTO t1 VALUES ('838:59:59.000000'); +INSERT INTO t1 SELECT CONCAT('-', a6) FROM t1; +ALTER TABLE t1 +ADD a0 VARCHAR(32), +ADD a1 VARCHAR(32), ADD a2 VARCHAR(32), ADD a3 VARCHAR(32), +ADD a4 VARCHAR(32), ADD a5 VARCHAR(32), +ADD t0 TIME(0), +ADD t1 TIME(1), ADD t2 TIME(2), ADD t3 TIME(3), +ADD t4 TIME(4), ADD t5 TIME(5), ADD t6 TIME(6); +UPDATE t1 SET +a0=LEFT(a6, LENGTH(a6) - 6), +a1=LEFT(a6, LENGTH(a6) - 5), +a2=LEFT(a6, LENGTH(a6) - 4), +a3=LEFT(a6, LENGTH(a6) - 3), +a4=LEFT(a6, LENGTH(a6) - 2), +a5=LEFT(a6, LENGTH(a6) - 1); +UPDATE t1 SET t0=a0, t1=a1, t2=a2, t3=a3, t4=a4, t5=a5, t6= a6; +SELECT a6, t6, HEX(WEIGHT_STRING(t6)) FROM t1 ORDER BY t6; +a6 t6 HEX(WEIGHT_STRING(t6)) +-838:59:59.000000 -838:59:59.000000 7FFFCB9105000000 +-838:59:58.999999 -838:59:58.999999 7FFFCB9105F0BDC1 +-838:59:58.999990 -838:59:58.999990 7FFFCB9105F0BDCA +-838:59:58.999900 -838:59:58.999900 7FFFCB9105F0BE24 +-838:59:58.999000 -838:59:58.999000 7FFFCB9105F0C1A8 +-838:59:58.990000 -838:59:58.990000 7FFFCB9105F0E4D0 +-838:59:58.900000 -838:59:58.900000 7FFFCB9105F24460 +-838:59:58.100000 -838:59:58.100000 7FFFCB9105FE7960 +-838:59:58.099999 -838:59:58.099999 7FFFCB9105FE7961 +-838:59:58.009999 -838:59:58.009999 7FFFCB9105FFD8F1 +-838:59:58.000999 -838:59:58.000999 7FFFCB9105FFFC19 +-838:59:58.000099 -838:59:58.000099 7FFFCB9105FFFF9D +-838:59:58.000016 -838:59:58.000016 7FFFCB9105FFFFF0 +-838:59:58.000015 -838:59:58.000015 7FFFCB9105FFFFF1 +-838:59:58.000008 -838:59:58.000008 7FFFCB9105FFFFF8 +-838:59:58.000001 -838:59:58.000001 7FFFCB9105FFFFFF +-01:00:00.999999 -01:00:00.999999 7FFFFFEFFFF0BDC1 +-01:00:00.999990 -01:00:00.999990 7FFFFFEFFFF0BDCA +-01:00:00.999900 -01:00:00.999900 7FFFFFEFFFF0BE24 +-01:00:00.999000 -01:00:00.999000 7FFFFFEFFFF0C1A8 +-01:00:00.990000 -01:00:00.990000 7FFFFFEFFFF0E4D0 +-01:00:00.900000 -01:00:00.900000 7FFFFFEFFFF24460 +-01:00:00.100000 -01:00:00.100000 7FFFFFEFFFFE7960 +-01:00:00.099999 -01:00:00.099999 7FFFFFEFFFFE7961 +-01:00:00.009999 -01:00:00.009999 7FFFFFEFFFFFD8F1 +-01:00:00.000999 -01:00:00.000999 7FFFFFEFFFFFFC19 +-01:00:00.000099 -01:00:00.000099 7FFFFFEFFFFFFF9D +-01:00:00.000016 -01:00:00.000016 7FFFFFEFFFFFFFF0 +-01:00:00.000015 -01:00:00.000015 7FFFFFEFFFFFFFF1 +-01:00:00.000008 -01:00:00.000008 7FFFFFEFFFFFFFF8 +-01:00:00.000001 -01:00:00.000001 7FFFFFEFFFFFFFFF +-00:01:00.999999 -00:01:00.999999 7FFFFFFFBFF0BDC1 +-00:01:00.900000 -00:01:00.900000 7FFFFFFFBFF24460 +-00:01:00.100000 -00:01:00.100000 7FFFFFFFBFFE7960 +-00:01:00.099999 -00:01:00.099999 7FFFFFFFBFFE7961 +-00:01:00.009999 -00:01:00.009999 7FFFFFFFBFFFD8F1 +-00:01:00.000999 -00:01:00.000999 7FFFFFFFBFFFFC19 +-00:01:00.000099 -00:01:00.000099 7FFFFFFFBFFFFF9D +-00:01:00.000016 -00:01:00.000016 7FFFFFFFBFFFFFF0 +-00:01:00.000015 -00:01:00.000015 7FFFFFFFBFFFFFF1 +-00:01:00.000008 -00:01:00.000008 7FFFFFFFBFFFFFF8 +-00:01:00.000001 -00:01:00.000001 7FFFFFFFBFFFFFFF +-00:00:01.999999 -00:00:01.999999 7FFFFFFFFEF0BDC1 +-00:00:01.999990 -00:00:01.999990 7FFFFFFFFEF0BDCA +-00:00:01.999900 -00:00:01.999900 7FFFFFFFFEF0BE24 +-00:00:01.999000 -00:00:01.999000 7FFFFFFFFEF0C1A8 +-00:00:01.990000 -00:00:01.990000 7FFFFFFFFEF0E4D0 +-00:00:01.900000 -00:00:01.900000 7FFFFFFFFEF24460 +-00:00:01.100000 -00:00:01.100000 7FFFFFFFFEFE7960 +-00:00:01.099999 -00:00:01.099999 7FFFFFFFFEFE7961 +-00:00:01.090000 -00:00:01.090000 7FFFFFFFFEFEA070 +-00:00:01.009999 -00:00:01.009999 7FFFFFFFFEFFD8F1 +-00:00:01.000999 -00:00:01.000999 7FFFFFFFFEFFFC19 +-00:00:01.000099 -00:00:01.000099 7FFFFFFFFEFFFF9D +-00:00:01.000016 -00:00:01.000016 7FFFFFFFFEFFFFF0 +-00:00:01.000015 -00:00:01.000015 7FFFFFFFFEFFFFF1 +-00:00:01.000014 -00:00:01.000014 7FFFFFFFFEFFFFF2 +-00:00:01.000013 -00:00:01.000013 7FFFFFFFFEFFFFF3 +-00:00:01.000012 -00:00:01.000012 7FFFFFFFFEFFFFF4 +-00:00:01.000011 -00:00:01.000011 7FFFFFFFFEFFFFF5 +-00:00:01.000010 -00:00:01.000010 7FFFFFFFFEFFFFF6 +-00:00:01.000009 -00:00:01.000009 7FFFFFFFFEFFFFF7 +-00:00:01.000008 -00:00:01.000008 7FFFFFFFFEFFFFF8 +-00:00:01.000007 -00:00:01.000007 7FFFFFFFFEFFFFF9 +-00:00:01.000006 -00:00:01.000006 7FFFFFFFFEFFFFFA +-00:00:01.000005 -00:00:01.000005 7FFFFFFFFEFFFFFB +-00:00:01.000004 -00:00:01.000004 7FFFFFFFFEFFFFFC +-00:00:01.000003 -00:00:01.000003 7FFFFFFFFEFFFFFD +-00:00:01.000002 -00:00:01.000002 7FFFFFFFFEFFFFFE +-00:00:01.000001 -00:00:01.000001 7FFFFFFFFEFFFFFF +-00:00:01.000000 -00:00:01.000000 7FFFFFFFFF000000 +-00:00:00.999999 -00:00:00.999999 7FFFFFFFFFF0BDC1 +-00:00:00.999990 -00:00:00.999990 7FFFFFFFFFF0BDCA +-00:00:00.999900 -00:00:00.999900 7FFFFFFFFFF0BE24 +-00:00:00.999000 -00:00:00.999000 7FFFFFFFFFF0C1A8 +-00:00:00.990000 -00:00:00.990000 7FFFFFFFFFF0E4D0 +-00:00:00.900000 -00:00:00.900000 7FFFFFFFFFF24460 +-00:00:00.100000 -00:00:00.100000 7FFFFFFFFFFE7960 +-00:00:00.099999 -00:00:00.099999 7FFFFFFFFFFE7961 +-00:00:00.009999 -00:00:00.009999 7FFFFFFFFFFFD8F1 +-00:00:00.000999 -00:00:00.000999 7FFFFFFFFFFFFC19 +-00:00:00.000099 -00:00:00.000099 7FFFFFFFFFFFFF9D +-00:00:00.000016 -00:00:00.000016 7FFFFFFFFFFFFFF0 +-00:00:00.000015 -00:00:00.000015 7FFFFFFFFFFFFFF1 +-00:00:00.000014 -00:00:00.000014 7FFFFFFFFFFFFFF2 +-00:00:00.000013 -00:00:00.000013 7FFFFFFFFFFFFFF3 +-00:00:00.000012 -00:00:00.000012 7FFFFFFFFFFFFFF4 +-00:00:00.000011 -00:00:00.000011 7FFFFFFFFFFFFFF5 +-00:00:00.000010 -00:00:00.000010 7FFFFFFFFFFFFFF6 +-00:00:00.000009 -00:00:00.000009 7FFFFFFFFFFFFFF7 +-00:00:00.000008 -00:00:00.000008 7FFFFFFFFFFFFFF8 +-00:00:00.000007 -00:00:00.000007 7FFFFFFFFFFFFFF9 +-00:00:00.000006 -00:00:00.000006 7FFFFFFFFFFFFFFA +-00:00:00.000005 -00:00:00.000005 7FFFFFFFFFFFFFFB +-00:00:00.000004 -00:00:00.000004 7FFFFFFFFFFFFFFC +-00:00:00.000003 -00:00:00.000003 7FFFFFFFFFFFFFFD +-00:00:00.000002 -00:00:00.000002 7FFFFFFFFFFFFFFE +-00:00:00.000001 -00:00:00.000001 7FFFFFFFFFFFFFFF +00:00:00.000000 00:00:00.000000 8000000000000000 +-00:00:00.000000 00:00:00.000000 8000000000000000 +00:00:00.000001 00:00:00.000001 8000000000000001 +00:00:00.000002 00:00:00.000002 8000000000000002 +00:00:00.000003 00:00:00.000003 8000000000000003 +00:00:00.000004 00:00:00.000004 8000000000000004 +00:00:00.000005 00:00:00.000005 8000000000000005 +00:00:00.000006 00:00:00.000006 8000000000000006 +00:00:00.000007 00:00:00.000007 8000000000000007 +00:00:00.000008 00:00:00.000008 8000000000000008 +00:00:00.000009 00:00:00.000009 8000000000000009 +00:00:00.000010 00:00:00.000010 800000000000000A +00:00:00.000011 00:00:00.000011 800000000000000B +00:00:00.000012 00:00:00.000012 800000000000000C +00:00:00.000013 00:00:00.000013 800000000000000D +00:00:00.000014 00:00:00.000014 800000000000000E +00:00:00.000015 00:00:00.000015 800000000000000F +00:00:00.000016 00:00:00.000016 8000000000000010 +00:00:00.000099 00:00:00.000099 8000000000000063 +00:00:00.000999 00:00:00.000999 80000000000003E7 +00:00:00.009999 00:00:00.009999 800000000000270F +00:00:00.099999 00:00:00.099999 800000000001869F +00:00:00.100000 00:00:00.100000 80000000000186A0 +00:00:00.900000 00:00:00.900000 80000000000DBBA0 +00:00:00.990000 00:00:00.990000 80000000000F1B30 +00:00:00.999000 00:00:00.999000 80000000000F3E58 +00:00:00.999900 00:00:00.999900 80000000000F41DC +00:00:00.999990 00:00:00.999990 80000000000F4236 +00:00:00.999999 00:00:00.999999 80000000000F423F +00:00:01.000000 00:00:01.000000 8000000001000000 +00:00:01.000001 00:00:01.000001 8000000001000001 +00:00:01.000002 00:00:01.000002 8000000001000002 +00:00:01.000003 00:00:01.000003 8000000001000003 +00:00:01.000004 00:00:01.000004 8000000001000004 +00:00:01.000005 00:00:01.000005 8000000001000005 +00:00:01.000006 00:00:01.000006 8000000001000006 +00:00:01.000007 00:00:01.000007 8000000001000007 +00:00:01.000008 00:00:01.000008 8000000001000008 +00:00:01.000009 00:00:01.000009 8000000001000009 +00:00:01.000010 00:00:01.000010 800000000100000A +00:00:01.000011 00:00:01.000011 800000000100000B +00:00:01.000012 00:00:01.000012 800000000100000C +00:00:01.000013 00:00:01.000013 800000000100000D +00:00:01.000014 00:00:01.000014 800000000100000E +00:00:01.000015 00:00:01.000015 800000000100000F +00:00:01.000016 00:00:01.000016 8000000001000010 +00:00:01.000099 00:00:01.000099 8000000001000063 +00:00:01.000999 00:00:01.000999 80000000010003E7 +00:00:01.009999 00:00:01.009999 800000000100270F +00:00:01.090000 00:00:01.090000 8000000001015F90 +00:00:01.099999 00:00:01.099999 800000000101869F +00:00:01.100000 00:00:01.100000 80000000010186A0 +00:00:01.900000 00:00:01.900000 80000000010DBBA0 +00:00:01.990000 00:00:01.990000 80000000010F1B30 +00:00:01.999000 00:00:01.999000 80000000010F3E58 +00:00:01.999900 00:00:01.999900 80000000010F41DC +00:00:01.999990 00:00:01.999990 80000000010F4236 +00:00:01.999999 00:00:01.999999 80000000010F423F +00:01:00.000001 00:01:00.000001 8000000040000001 +00:01:00.000008 00:01:00.000008 8000000040000008 +00:01:00.000015 00:01:00.000015 800000004000000F +00:01:00.000016 00:01:00.000016 8000000040000010 +00:01:00.000099 00:01:00.000099 8000000040000063 +00:01:00.000999 00:01:00.000999 80000000400003E7 +00:01:00.009999 00:01:00.009999 800000004000270F +00:01:00.099999 00:01:00.099999 800000004001869F +00:01:00.100000 00:01:00.100000 80000000400186A0 +00:01:00.900000 00:01:00.900000 80000000400DBBA0 +00:01:00.999999 00:01:00.999999 80000000400F423F +01:00:00.000001 01:00:00.000001 8000001000000001 +01:00:00.000008 01:00:00.000008 8000001000000008 +01:00:00.000015 01:00:00.000015 800000100000000F +01:00:00.000016 01:00:00.000016 8000001000000010 +01:00:00.000099 01:00:00.000099 8000001000000063 +01:00:00.000999 01:00:00.000999 80000010000003E7 +01:00:00.009999 01:00:00.009999 800000100000270F +01:00:00.099999 01:00:00.099999 800000100001869F +01:00:00.100000 01:00:00.100000 80000010000186A0 +01:00:00.900000 01:00:00.900000 80000010000DBBA0 +01:00:00.990000 01:00:00.990000 80000010000F1B30 +01:00:00.999000 01:00:00.999000 80000010000F3E58 +01:00:00.999900 01:00:00.999900 80000010000F41DC +01:00:00.999990 01:00:00.999990 80000010000F4236 +01:00:00.999999 01:00:00.999999 80000010000F423F +838:59:58.000001 838:59:58.000001 8000346EFA000001 +838:59:58.000008 838:59:58.000008 8000346EFA000008 +838:59:58.000015 838:59:58.000015 8000346EFA00000F +838:59:58.000016 838:59:58.000016 8000346EFA000010 +838:59:58.000099 838:59:58.000099 8000346EFA000063 +838:59:58.000999 838:59:58.000999 8000346EFA0003E7 +838:59:58.009999 838:59:58.009999 8000346EFA00270F +838:59:58.099999 838:59:58.099999 8000346EFA01869F +838:59:58.100000 838:59:58.100000 8000346EFA0186A0 +838:59:58.900000 838:59:58.900000 8000346EFA0DBBA0 +838:59:58.990000 838:59:58.990000 8000346EFA0F1B30 +838:59:58.999000 838:59:58.999000 8000346EFA0F3E58 +838:59:58.999900 838:59:58.999900 8000346EFA0F41DC +838:59:58.999990 838:59:58.999990 8000346EFA0F4236 +838:59:58.999999 838:59:58.999999 8000346EFA0F423F +838:59:59.000000 838:59:59.000000 8000346EFB000000 +SELECT a5, t5, HEX(WEIGHT_STRING(t5)) FROM t1 ORDER BY t5, a6; +a5 t5 HEX(WEIGHT_STRING(t5)) +-838:59:59.00000 -838:59:59.00000 7FFFCB9105000000 +-838:59:58.99999 -838:59:58.99999 7FFFCB9105F0BDCA +-838:59:58.99999 -838:59:58.99999 7FFFCB9105F0BDCA +-838:59:58.99990 -838:59:58.99990 7FFFCB9105F0BE24 +-838:59:58.99900 -838:59:58.99900 7FFFCB9105F0C1A8 +-838:59:58.99000 -838:59:58.99000 7FFFCB9105F0E4D0 +-838:59:58.90000 -838:59:58.90000 7FFFCB9105F24460 +-838:59:58.10000 -838:59:58.10000 7FFFCB9105FE7960 +-838:59:58.09999 -838:59:58.09999 7FFFCB9105FE796A +-838:59:58.00999 -838:59:58.00999 7FFFCB9105FFD8FA +-838:59:58.00099 -838:59:58.00099 7FFFCB9105FFFC22 +-838:59:58.00009 -838:59:58.00009 7FFFCB9105FFFFA6 +-838:59:58.00001 -838:59:58.00001 7FFFCB9105FFFFF6 +-838:59:58.00001 -838:59:58.00001 7FFFCB9105FFFFF6 +-838:59:58.00000 -838:59:58.00000 7FFFCB9106000000 +-838:59:58.00000 -838:59:58.00000 7FFFCB9106000000 +-01:00:00.99999 -01:00:00.99999 7FFFFFEFFFF0BDCA +-01:00:00.99999 -01:00:00.99999 7FFFFFEFFFF0BDCA +-01:00:00.99990 -01:00:00.99990 7FFFFFEFFFF0BE24 +-01:00:00.99900 -01:00:00.99900 7FFFFFEFFFF0C1A8 +-01:00:00.99000 -01:00:00.99000 7FFFFFEFFFF0E4D0 +-01:00:00.90000 -01:00:00.90000 7FFFFFEFFFF24460 +-01:00:00.10000 -01:00:00.10000 7FFFFFEFFFFE7960 +-01:00:00.09999 -01:00:00.09999 7FFFFFEFFFFE796A +-01:00:00.00999 -01:00:00.00999 7FFFFFEFFFFFD8FA +-01:00:00.00099 -01:00:00.00099 7FFFFFEFFFFFFC22 +-01:00:00.00009 -01:00:00.00009 7FFFFFEFFFFFFFA6 +-01:00:00.00001 -01:00:00.00001 7FFFFFEFFFFFFFF6 +-01:00:00.00001 -01:00:00.00001 7FFFFFEFFFFFFFF6 +-01:00:00.00000 -01:00:00.00000 7FFFFFF000000000 +-01:00:00.00000 -01:00:00.00000 7FFFFFF000000000 +-00:01:00.99999 -00:01:00.99999 7FFFFFFFBFF0BDCA +-00:01:00.90000 -00:01:00.90000 7FFFFFFFBFF24460 +-00:01:00.10000 -00:01:00.10000 7FFFFFFFBFFE7960 +-00:01:00.09999 -00:01:00.09999 7FFFFFFFBFFE796A +-00:01:00.00999 -00:01:00.00999 7FFFFFFFBFFFD8FA +-00:01:00.00099 -00:01:00.00099 7FFFFFFFBFFFFC22 +-00:01:00.00009 -00:01:00.00009 7FFFFFFFBFFFFFA6 +-00:01:00.00001 -00:01:00.00001 7FFFFFFFBFFFFFF6 +-00:01:00.00001 -00:01:00.00001 7FFFFFFFBFFFFFF6 +-00:01:00.00000 -00:01:00.00000 7FFFFFFFC0000000 +-00:01:00.00000 -00:01:00.00000 7FFFFFFFC0000000 +-00:00:01.99999 -00:00:01.99999 7FFFFFFFFEF0BDCA +-00:00:01.99999 -00:00:01.99999 7FFFFFFFFEF0BDCA +-00:00:01.99990 -00:00:01.99990 7FFFFFFFFEF0BE24 +-00:00:01.99900 -00:00:01.99900 7FFFFFFFFEF0C1A8 +-00:00:01.99000 -00:00:01.99000 7FFFFFFFFEF0E4D0 +-00:00:01.90000 -00:00:01.90000 7FFFFFFFFEF24460 +-00:00:01.10000 -00:00:01.10000 7FFFFFFFFEFE7960 +-00:00:01.09999 -00:00:01.09999 7FFFFFFFFEFE796A +-00:00:01.09000 -00:00:01.09000 7FFFFFFFFEFEA070 +-00:00:01.00999 -00:00:01.00999 7FFFFFFFFEFFD8FA +-00:00:01.00099 -00:00:01.00099 7FFFFFFFFEFFFC22 +-00:00:01.00009 -00:00:01.00009 7FFFFFFFFEFFFFA6 +-00:00:01.00001 -00:00:01.00001 7FFFFFFFFEFFFFF6 +-00:00:01.00001 -00:00:01.00001 7FFFFFFFFEFFFFF6 +-00:00:01.00001 -00:00:01.00001 7FFFFFFFFEFFFFF6 +-00:00:01.00001 -00:00:01.00001 7FFFFFFFFEFFFFF6 +-00:00:01.00001 -00:00:01.00001 7FFFFFFFFEFFFFF6 +-00:00:01.00001 -00:00:01.00001 7FFFFFFFFEFFFFF6 +-00:00:01.00001 -00:00:01.00001 7FFFFFFFFEFFFFF6 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:01.00000 -00:00:01.00000 7FFFFFFFFF000000 +-00:00:00.99999 -00:00:00.99999 7FFFFFFFFFF0BDCA +-00:00:00.99999 -00:00:00.99999 7FFFFFFFFFF0BDCA +-00:00:00.99990 -00:00:00.99990 7FFFFFFFFFF0BE24 +-00:00:00.99900 -00:00:00.99900 7FFFFFFFFFF0C1A8 +-00:00:00.99000 -00:00:00.99000 7FFFFFFFFFF0E4D0 +-00:00:00.90000 -00:00:00.90000 7FFFFFFFFFF24460 +-00:00:00.10000 -00:00:00.10000 7FFFFFFFFFFE7960 +-00:00:00.09999 -00:00:00.09999 7FFFFFFFFFFE796A +-00:00:00.00999 -00:00:00.00999 7FFFFFFFFFFFD8FA +-00:00:00.00099 -00:00:00.00099 7FFFFFFFFFFFFC22 +-00:00:00.00009 -00:00:00.00009 7FFFFFFFFFFFFFA6 +-00:00:00.00001 -00:00:00.00001 7FFFFFFFFFFFFFF6 +-00:00:00.00001 -00:00:00.00001 7FFFFFFFFFFFFFF6 +-00:00:00.00001 -00:00:00.00001 7FFFFFFFFFFFFFF6 +-00:00:00.00001 -00:00:00.00001 7FFFFFFFFFFFFFF6 +-00:00:00.00001 -00:00:00.00001 7FFFFFFFFFFFFFF6 +-00:00:00.00001 -00:00:00.00001 7FFFFFFFFFFFFFF6 +-00:00:00.00001 -00:00:00.00001 7FFFFFFFFFFFFFF6 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +-00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00000 00:00:00.00000 8000000000000000 +00:00:00.00001 00:00:00.00001 800000000000000A +00:00:00.00001 00:00:00.00001 800000000000000A +00:00:00.00001 00:00:00.00001 800000000000000A +00:00:00.00001 00:00:00.00001 800000000000000A +00:00:00.00001 00:00:00.00001 800000000000000A +00:00:00.00001 00:00:00.00001 800000000000000A +00:00:00.00001 00:00:00.00001 800000000000000A +00:00:00.00009 00:00:00.00009 800000000000005A +00:00:00.00099 00:00:00.00099 80000000000003DE +00:00:00.00999 00:00:00.00999 8000000000002706 +00:00:00.09999 00:00:00.09999 8000000000018696 +00:00:00.10000 00:00:00.10000 80000000000186A0 +00:00:00.90000 00:00:00.90000 80000000000DBBA0 +00:00:00.99000 00:00:00.99000 80000000000F1B30 +00:00:00.99900 00:00:00.99900 80000000000F3E58 +00:00:00.99990 00:00:00.99990 80000000000F41DC +00:00:00.99999 00:00:00.99999 80000000000F4236 +00:00:00.99999 00:00:00.99999 80000000000F4236 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00000 00:00:01.00000 8000000001000000 +00:00:01.00001 00:00:01.00001 800000000100000A +00:00:01.00001 00:00:01.00001 800000000100000A +00:00:01.00001 00:00:01.00001 800000000100000A +00:00:01.00001 00:00:01.00001 800000000100000A +00:00:01.00001 00:00:01.00001 800000000100000A +00:00:01.00001 00:00:01.00001 800000000100000A +00:00:01.00001 00:00:01.00001 800000000100000A +00:00:01.00009 00:00:01.00009 800000000100005A +00:00:01.00099 00:00:01.00099 80000000010003DE +00:00:01.00999 00:00:01.00999 8000000001002706 +00:00:01.09000 00:00:01.09000 8000000001015F90 +00:00:01.09999 00:00:01.09999 8000000001018696 +00:00:01.10000 00:00:01.10000 80000000010186A0 +00:00:01.90000 00:00:01.90000 80000000010DBBA0 +00:00:01.99000 00:00:01.99000 80000000010F1B30 +00:00:01.99900 00:00:01.99900 80000000010F3E58 +00:00:01.99990 00:00:01.99990 80000000010F41DC +00:00:01.99999 00:00:01.99999 80000000010F4236 +00:00:01.99999 00:00:01.99999 80000000010F4236 +00:01:00.00000 00:01:00.00000 8000000040000000 +00:01:00.00000 00:01:00.00000 8000000040000000 +00:01:00.00001 00:01:00.00001 800000004000000A +00:01:00.00001 00:01:00.00001 800000004000000A +00:01:00.00009 00:01:00.00009 800000004000005A +00:01:00.00099 00:01:00.00099 80000000400003DE +00:01:00.00999 00:01:00.00999 8000000040002706 +00:01:00.09999 00:01:00.09999 8000000040018696 +00:01:00.10000 00:01:00.10000 80000000400186A0 +00:01:00.90000 00:01:00.90000 80000000400DBBA0 +00:01:00.99999 00:01:00.99999 80000000400F4236 +01:00:00.00000 01:00:00.00000 8000001000000000 +01:00:00.00000 01:00:00.00000 8000001000000000 +01:00:00.00001 01:00:00.00001 800000100000000A +01:00:00.00001 01:00:00.00001 800000100000000A +01:00:00.00009 01:00:00.00009 800000100000005A +01:00:00.00099 01:00:00.00099 80000010000003DE +01:00:00.00999 01:00:00.00999 8000001000002706 +01:00:00.09999 01:00:00.09999 8000001000018696 +01:00:00.10000 01:00:00.10000 80000010000186A0 +01:00:00.90000 01:00:00.90000 80000010000DBBA0 +01:00:00.99000 01:00:00.99000 80000010000F1B30 +01:00:00.99900 01:00:00.99900 80000010000F3E58 +01:00:00.99990 01:00:00.99990 80000010000F41DC +01:00:00.99999 01:00:00.99999 80000010000F4236 +01:00:00.99999 01:00:00.99999 80000010000F4236 +838:59:58.00000 838:59:58.00000 8000346EFA000000 +838:59:58.00000 838:59:58.00000 8000346EFA000000 +838:59:58.00001 838:59:58.00001 8000346EFA00000A +838:59:58.00001 838:59:58.00001 8000346EFA00000A +838:59:58.00009 838:59:58.00009 8000346EFA00005A +838:59:58.00099 838:59:58.00099 8000346EFA0003DE +838:59:58.00999 838:59:58.00999 8000346EFA002706 +838:59:58.09999 838:59:58.09999 8000346EFA018696 +838:59:58.10000 838:59:58.10000 8000346EFA0186A0 +838:59:58.90000 838:59:58.90000 8000346EFA0DBBA0 +838:59:58.99000 838:59:58.99000 8000346EFA0F1B30 +838:59:58.99900 838:59:58.99900 8000346EFA0F3E58 +838:59:58.99990 838:59:58.99990 8000346EFA0F41DC +838:59:58.99999 838:59:58.99999 8000346EFA0F4236 +838:59:58.99999 838:59:58.99999 8000346EFA0F4236 +838:59:59.00000 838:59:59.00000 8000346EFB000000 +SELECT a4, t4, HEX(WEIGHT_STRING(t4)) FROM t1 ORDER BY t4, a6; +a4 t4 HEX(WEIGHT_STRING(t4)) +-838:59:59.0000 -838:59:59.0000 7FFFCB9105000000 +-838:59:58.9999 -838:59:58.9999 7FFFCB9105F0BE24 +-838:59:58.9999 -838:59:58.9999 7FFFCB9105F0BE24 +-838:59:58.9999 -838:59:58.9999 7FFFCB9105F0BE24 +-838:59:58.9990 -838:59:58.9990 7FFFCB9105F0C1A8 +-838:59:58.9900 -838:59:58.9900 7FFFCB9105F0E4D0 +-838:59:58.9000 -838:59:58.9000 7FFFCB9105F24460 +-838:59:58.1000 -838:59:58.1000 7FFFCB9105FE7960 +-838:59:58.0999 -838:59:58.0999 7FFFCB9105FE79C4 +-838:59:58.0099 -838:59:58.0099 7FFFCB9105FFD954 +-838:59:58.0009 -838:59:58.0009 7FFFCB9105FFFC7C +-838:59:58.0000 -838:59:58.0000 7FFFCB9106000000 +-838:59:58.0000 -838:59:58.0000 7FFFCB9106000000 +-838:59:58.0000 -838:59:58.0000 7FFFCB9106000000 +-838:59:58.0000 -838:59:58.0000 7FFFCB9106000000 +-838:59:58.0000 -838:59:58.0000 7FFFCB9106000000 +-01:00:00.9999 -01:00:00.9999 7FFFFFEFFFF0BE24 +-01:00:00.9999 -01:00:00.9999 7FFFFFEFFFF0BE24 +-01:00:00.9999 -01:00:00.9999 7FFFFFEFFFF0BE24 +-01:00:00.9990 -01:00:00.9990 7FFFFFEFFFF0C1A8 +-01:00:00.9900 -01:00:00.9900 7FFFFFEFFFF0E4D0 +-01:00:00.9000 -01:00:00.9000 7FFFFFEFFFF24460 +-01:00:00.1000 -01:00:00.1000 7FFFFFEFFFFE7960 +-01:00:00.0999 -01:00:00.0999 7FFFFFEFFFFE79C4 +-01:00:00.0099 -01:00:00.0099 7FFFFFEFFFFFD954 +-01:00:00.0009 -01:00:00.0009 7FFFFFEFFFFFFC7C +-01:00:00.0000 -01:00:00.0000 7FFFFFF000000000 +-01:00:00.0000 -01:00:00.0000 7FFFFFF000000000 +-01:00:00.0000 -01:00:00.0000 7FFFFFF000000000 +-01:00:00.0000 -01:00:00.0000 7FFFFFF000000000 +-01:00:00.0000 -01:00:00.0000 7FFFFFF000000000 +-00:01:00.9999 -00:01:00.9999 7FFFFFFFBFF0BE24 +-00:01:00.9000 -00:01:00.9000 7FFFFFFFBFF24460 +-00:01:00.1000 -00:01:00.1000 7FFFFFFFBFFE7960 +-00:01:00.0999 -00:01:00.0999 7FFFFFFFBFFE79C4 +-00:01:00.0099 -00:01:00.0099 7FFFFFFFBFFFD954 +-00:01:00.0009 -00:01:00.0009 7FFFFFFFBFFFFC7C +-00:01:00.0000 -00:01:00.0000 7FFFFFFFC0000000 +-00:01:00.0000 -00:01:00.0000 7FFFFFFFC0000000 +-00:01:00.0000 -00:01:00.0000 7FFFFFFFC0000000 +-00:01:00.0000 -00:01:00.0000 7FFFFFFFC0000000 +-00:01:00.0000 -00:01:00.0000 7FFFFFFFC0000000 +-00:00:01.9999 -00:00:01.9999 7FFFFFFFFEF0BE24 +-00:00:01.9999 -00:00:01.9999 7FFFFFFFFEF0BE24 +-00:00:01.9999 -00:00:01.9999 7FFFFFFFFEF0BE24 +-00:00:01.9990 -00:00:01.9990 7FFFFFFFFEF0C1A8 +-00:00:01.9900 -00:00:01.9900 7FFFFFFFFEF0E4D0 +-00:00:01.9000 -00:00:01.9000 7FFFFFFFFEF24460 +-00:00:01.1000 -00:00:01.1000 7FFFFFFFFEFE7960 +-00:00:01.0999 -00:00:01.0999 7FFFFFFFFEFE79C4 +-00:00:01.0900 -00:00:01.0900 7FFFFFFFFEFEA070 +-00:00:01.0099 -00:00:01.0099 7FFFFFFFFEFFD954 +-00:00:01.0009 -00:00:01.0009 7FFFFFFFFEFFFC7C +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:01.0000 -00:00:01.0000 7FFFFFFFFF000000 +-00:00:00.9999 -00:00:00.9999 7FFFFFFFFFF0BE24 +-00:00:00.9999 -00:00:00.9999 7FFFFFFFFFF0BE24 +-00:00:00.9999 -00:00:00.9999 7FFFFFFFFFF0BE24 +-00:00:00.9990 -00:00:00.9990 7FFFFFFFFFF0C1A8 +-00:00:00.9900 -00:00:00.9900 7FFFFFFFFFF0E4D0 +-00:00:00.9000 -00:00:00.9000 7FFFFFFFFFF24460 +-00:00:00.1000 -00:00:00.1000 7FFFFFFFFFFE7960 +-00:00:00.0999 -00:00:00.0999 7FFFFFFFFFFE79C4 +-00:00:00.0099 -00:00:00.0099 7FFFFFFFFFFFD954 +-00:00:00.0009 -00:00:00.0009 7FFFFFFFFFFFFC7C +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +-00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0000 00:00:00.0000 8000000000000000 +00:00:00.0009 00:00:00.0009 8000000000000384 +00:00:00.0099 00:00:00.0099 80000000000026AC +00:00:00.0999 00:00:00.0999 800000000001863C +00:00:00.1000 00:00:00.1000 80000000000186A0 +00:00:00.9000 00:00:00.9000 80000000000DBBA0 +00:00:00.9900 00:00:00.9900 80000000000F1B30 +00:00:00.9990 00:00:00.9990 80000000000F3E58 +00:00:00.9999 00:00:00.9999 80000000000F41DC +00:00:00.9999 00:00:00.9999 80000000000F41DC +00:00:00.9999 00:00:00.9999 80000000000F41DC +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0000 00:00:01.0000 8000000001000000 +00:00:01.0009 00:00:01.0009 8000000001000384 +00:00:01.0099 00:00:01.0099 80000000010026AC +00:00:01.0900 00:00:01.0900 8000000001015F90 +00:00:01.0999 00:00:01.0999 800000000101863C +00:00:01.1000 00:00:01.1000 80000000010186A0 +00:00:01.9000 00:00:01.9000 80000000010DBBA0 +00:00:01.9900 00:00:01.9900 80000000010F1B30 +00:00:01.9990 00:00:01.9990 80000000010F3E58 +00:00:01.9999 00:00:01.9999 80000000010F41DC +00:00:01.9999 00:00:01.9999 80000000010F41DC +00:00:01.9999 00:00:01.9999 80000000010F41DC +00:01:00.0000 00:01:00.0000 8000000040000000 +00:01:00.0000 00:01:00.0000 8000000040000000 +00:01:00.0000 00:01:00.0000 8000000040000000 +00:01:00.0000 00:01:00.0000 8000000040000000 +00:01:00.0000 00:01:00.0000 8000000040000000 +00:01:00.0009 00:01:00.0009 8000000040000384 +00:01:00.0099 00:01:00.0099 80000000400026AC +00:01:00.0999 00:01:00.0999 800000004001863C +00:01:00.1000 00:01:00.1000 80000000400186A0 +00:01:00.9000 00:01:00.9000 80000000400DBBA0 +00:01:00.9999 00:01:00.9999 80000000400F41DC +01:00:00.0000 01:00:00.0000 8000001000000000 +01:00:00.0000 01:00:00.0000 8000001000000000 +01:00:00.0000 01:00:00.0000 8000001000000000 +01:00:00.0000 01:00:00.0000 8000001000000000 +01:00:00.0000 01:00:00.0000 8000001000000000 +01:00:00.0009 01:00:00.0009 8000001000000384 +01:00:00.0099 01:00:00.0099 80000010000026AC +01:00:00.0999 01:00:00.0999 800000100001863C +01:00:00.1000 01:00:00.1000 80000010000186A0 +01:00:00.9000 01:00:00.9000 80000010000DBBA0 +01:00:00.9900 01:00:00.9900 80000010000F1B30 +01:00:00.9990 01:00:00.9990 80000010000F3E58 +01:00:00.9999 01:00:00.9999 80000010000F41DC +01:00:00.9999 01:00:00.9999 80000010000F41DC +01:00:00.9999 01:00:00.9999 80000010000F41DC +838:59:58.0000 838:59:58.0000 8000346EFA000000 +838:59:58.0000 838:59:58.0000 8000346EFA000000 +838:59:58.0000 838:59:58.0000 8000346EFA000000 +838:59:58.0000 838:59:58.0000 8000346EFA000000 +838:59:58.0000 838:59:58.0000 8000346EFA000000 +838:59:58.0009 838:59:58.0009 8000346EFA000384 +838:59:58.0099 838:59:58.0099 8000346EFA0026AC +838:59:58.0999 838:59:58.0999 8000346EFA01863C +838:59:58.1000 838:59:58.1000 8000346EFA0186A0 +838:59:58.9000 838:59:58.9000 8000346EFA0DBBA0 +838:59:58.9900 838:59:58.9900 8000346EFA0F1B30 +838:59:58.9990 838:59:58.9990 8000346EFA0F3E58 +838:59:58.9999 838:59:58.9999 8000346EFA0F41DC +838:59:58.9999 838:59:58.9999 8000346EFA0F41DC +838:59:58.9999 838:59:58.9999 8000346EFA0F41DC +838:59:59.0000 838:59:59.0000 8000346EFB000000 +SELECT a3, t3, HEX(WEIGHT_STRING(t3)) FROM t1 ORDER BY t3, a6; +a3 t3 HEX(WEIGHT_STRING(t3)) +-838:59:59.000 -838:59:59.000 7FFFCB9105000000 +-838:59:58.999 -838:59:58.999 7FFFCB9105F0C1A8 +-838:59:58.999 -838:59:58.999 7FFFCB9105F0C1A8 +-838:59:58.999 -838:59:58.999 7FFFCB9105F0C1A8 +-838:59:58.999 -838:59:58.999 7FFFCB9105F0C1A8 +-838:59:58.990 -838:59:58.990 7FFFCB9105F0E4D0 +-838:59:58.900 -838:59:58.900 7FFFCB9105F24460 +-838:59:58.100 -838:59:58.100 7FFFCB9105FE7960 +-838:59:58.099 -838:59:58.099 7FFFCB9105FE7D48 +-838:59:58.009 -838:59:58.009 7FFFCB9105FFDCD8 +-838:59:58.000 -838:59:58.000 7FFFCB9106000000 +-838:59:58.000 -838:59:58.000 7FFFCB9106000000 +-838:59:58.000 -838:59:58.000 7FFFCB9106000000 +-838:59:58.000 -838:59:58.000 7FFFCB9106000000 +-838:59:58.000 -838:59:58.000 7FFFCB9106000000 +-838:59:58.000 -838:59:58.000 7FFFCB9106000000 +-01:00:00.999 -01:00:00.999 7FFFFFEFFFF0C1A8 +-01:00:00.999 -01:00:00.999 7FFFFFEFFFF0C1A8 +-01:00:00.999 -01:00:00.999 7FFFFFEFFFF0C1A8 +-01:00:00.999 -01:00:00.999 7FFFFFEFFFF0C1A8 +-01:00:00.990 -01:00:00.990 7FFFFFEFFFF0E4D0 +-01:00:00.900 -01:00:00.900 7FFFFFEFFFF24460 +-01:00:00.100 -01:00:00.100 7FFFFFEFFFFE7960 +-01:00:00.099 -01:00:00.099 7FFFFFEFFFFE7D48 +-01:00:00.009 -01:00:00.009 7FFFFFEFFFFFDCD8 +-01:00:00.000 -01:00:00.000 7FFFFFF000000000 +-01:00:00.000 -01:00:00.000 7FFFFFF000000000 +-01:00:00.000 -01:00:00.000 7FFFFFF000000000 +-01:00:00.000 -01:00:00.000 7FFFFFF000000000 +-01:00:00.000 -01:00:00.000 7FFFFFF000000000 +-01:00:00.000 -01:00:00.000 7FFFFFF000000000 +-00:01:00.999 -00:01:00.999 7FFFFFFFBFF0C1A8 +-00:01:00.900 -00:01:00.900 7FFFFFFFBFF24460 +-00:01:00.100 -00:01:00.100 7FFFFFFFBFFE7960 +-00:01:00.099 -00:01:00.099 7FFFFFFFBFFE7D48 +-00:01:00.009 -00:01:00.009 7FFFFFFFBFFFDCD8 +-00:01:00.000 -00:01:00.000 7FFFFFFFC0000000 +-00:01:00.000 -00:01:00.000 7FFFFFFFC0000000 +-00:01:00.000 -00:01:00.000 7FFFFFFFC0000000 +-00:01:00.000 -00:01:00.000 7FFFFFFFC0000000 +-00:01:00.000 -00:01:00.000 7FFFFFFFC0000000 +-00:01:00.000 -00:01:00.000 7FFFFFFFC0000000 +-00:00:01.999 -00:00:01.999 7FFFFFFFFEF0C1A8 +-00:00:01.999 -00:00:01.999 7FFFFFFFFEF0C1A8 +-00:00:01.999 -00:00:01.999 7FFFFFFFFEF0C1A8 +-00:00:01.999 -00:00:01.999 7FFFFFFFFEF0C1A8 +-00:00:01.990 -00:00:01.990 7FFFFFFFFEF0E4D0 +-00:00:01.900 -00:00:01.900 7FFFFFFFFEF24460 +-00:00:01.100 -00:00:01.100 7FFFFFFFFEFE7960 +-00:00:01.099 -00:00:01.099 7FFFFFFFFEFE7D48 +-00:00:01.090 -00:00:01.090 7FFFFFFFFEFEA070 +-00:00:01.009 -00:00:01.009 7FFFFFFFFEFFDCD8 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:01.000 -00:00:01.000 7FFFFFFFFF000000 +-00:00:00.999 -00:00:00.999 7FFFFFFFFFF0C1A8 +-00:00:00.999 -00:00:00.999 7FFFFFFFFFF0C1A8 +-00:00:00.999 -00:00:00.999 7FFFFFFFFFF0C1A8 +-00:00:00.999 -00:00:00.999 7FFFFFFFFFF0C1A8 +-00:00:00.990 -00:00:00.990 7FFFFFFFFFF0E4D0 +-00:00:00.900 -00:00:00.900 7FFFFFFFFFF24460 +-00:00:00.100 -00:00:00.100 7FFFFFFFFFFE7960 +-00:00:00.099 -00:00:00.099 7FFFFFFFFFFE7D48 +-00:00:00.009 -00:00:00.009 7FFFFFFFFFFFDCD8 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +-00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.000 00:00:00.000 8000000000000000 +00:00:00.009 00:00:00.009 8000000000002328 +00:00:00.099 00:00:00.099 80000000000182B8 +00:00:00.100 00:00:00.100 80000000000186A0 +00:00:00.900 00:00:00.900 80000000000DBBA0 +00:00:00.990 00:00:00.990 80000000000F1B30 +00:00:00.999 00:00:00.999 80000000000F3E58 +00:00:00.999 00:00:00.999 80000000000F3E58 +00:00:00.999 00:00:00.999 80000000000F3E58 +00:00:00.999 00:00:00.999 80000000000F3E58 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.000 00:00:01.000 8000000001000000 +00:00:01.009 00:00:01.009 8000000001002328 +00:00:01.090 00:00:01.090 8000000001015F90 +00:00:01.099 00:00:01.099 80000000010182B8 +00:00:01.100 00:00:01.100 80000000010186A0 +00:00:01.900 00:00:01.900 80000000010DBBA0 +00:00:01.990 00:00:01.990 80000000010F1B30 +00:00:01.999 00:00:01.999 80000000010F3E58 +00:00:01.999 00:00:01.999 80000000010F3E58 +00:00:01.999 00:00:01.999 80000000010F3E58 +00:00:01.999 00:00:01.999 80000000010F3E58 +00:01:00.000 00:01:00.000 8000000040000000 +00:01:00.000 00:01:00.000 8000000040000000 +00:01:00.000 00:01:00.000 8000000040000000 +00:01:00.000 00:01:00.000 8000000040000000 +00:01:00.000 00:01:00.000 8000000040000000 +00:01:00.000 00:01:00.000 8000000040000000 +00:01:00.009 00:01:00.009 8000000040002328 +00:01:00.099 00:01:00.099 80000000400182B8 +00:01:00.100 00:01:00.100 80000000400186A0 +00:01:00.900 00:01:00.900 80000000400DBBA0 +00:01:00.999 00:01:00.999 80000000400F3E58 +01:00:00.000 01:00:00.000 8000001000000000 +01:00:00.000 01:00:00.000 8000001000000000 +01:00:00.000 01:00:00.000 8000001000000000 +01:00:00.000 01:00:00.000 8000001000000000 +01:00:00.000 01:00:00.000 8000001000000000 +01:00:00.000 01:00:00.000 8000001000000000 +01:00:00.009 01:00:00.009 8000001000002328 +01:00:00.099 01:00:00.099 80000010000182B8 +01:00:00.100 01:00:00.100 80000010000186A0 +01:00:00.900 01:00:00.900 80000010000DBBA0 +01:00:00.990 01:00:00.990 80000010000F1B30 +01:00:00.999 01:00:00.999 80000010000F3E58 +01:00:00.999 01:00:00.999 80000010000F3E58 +01:00:00.999 01:00:00.999 80000010000F3E58 +01:00:00.999 01:00:00.999 80000010000F3E58 +838:59:58.000 838:59:58.000 8000346EFA000000 +838:59:58.000 838:59:58.000 8000346EFA000000 +838:59:58.000 838:59:58.000 8000346EFA000000 +838:59:58.000 838:59:58.000 8000346EFA000000 +838:59:58.000 838:59:58.000 8000346EFA000000 +838:59:58.000 838:59:58.000 8000346EFA000000 +838:59:58.009 838:59:58.009 8000346EFA002328 +838:59:58.099 838:59:58.099 8000346EFA0182B8 +838:59:58.100 838:59:58.100 8000346EFA0186A0 +838:59:58.900 838:59:58.900 8000346EFA0DBBA0 +838:59:58.990 838:59:58.990 8000346EFA0F1B30 +838:59:58.999 838:59:58.999 8000346EFA0F3E58 +838:59:58.999 838:59:58.999 8000346EFA0F3E58 +838:59:58.999 838:59:58.999 8000346EFA0F3E58 +838:59:58.999 838:59:58.999 8000346EFA0F3E58 +838:59:59.000 838:59:59.000 8000346EFB000000 +SELECT a2, t2, HEX(WEIGHT_STRING(t2)) FROM t1 ORDER BY t2, a6; +a2 t2 HEX(WEIGHT_STRING(t2)) +-838:59:59.00 -838:59:59.00 7FFFCB9105000000 +-838:59:58.99 -838:59:58.99 7FFFCB9105F0E4D0 +-838:59:58.99 -838:59:58.99 7FFFCB9105F0E4D0 +-838:59:58.99 -838:59:58.99 7FFFCB9105F0E4D0 +-838:59:58.99 -838:59:58.99 7FFFCB9105F0E4D0 +-838:59:58.99 -838:59:58.99 7FFFCB9105F0E4D0 +-838:59:58.90 -838:59:58.90 7FFFCB9105F24460 +-838:59:58.10 -838:59:58.10 7FFFCB9105FE7960 +-838:59:58.09 -838:59:58.09 7FFFCB9105FEA070 +-838:59:58.00 -838:59:58.00 7FFFCB9106000000 +-838:59:58.00 -838:59:58.00 7FFFCB9106000000 +-838:59:58.00 -838:59:58.00 7FFFCB9106000000 +-838:59:58.00 -838:59:58.00 7FFFCB9106000000 +-838:59:58.00 -838:59:58.00 7FFFCB9106000000 +-838:59:58.00 -838:59:58.00 7FFFCB9106000000 +-838:59:58.00 -838:59:58.00 7FFFCB9106000000 +-01:00:00.99 -01:00:00.99 7FFFFFEFFFF0E4D0 +-01:00:00.99 -01:00:00.99 7FFFFFEFFFF0E4D0 +-01:00:00.99 -01:00:00.99 7FFFFFEFFFF0E4D0 +-01:00:00.99 -01:00:00.99 7FFFFFEFFFF0E4D0 +-01:00:00.99 -01:00:00.99 7FFFFFEFFFF0E4D0 +-01:00:00.90 -01:00:00.90 7FFFFFEFFFF24460 +-01:00:00.10 -01:00:00.10 7FFFFFEFFFFE7960 +-01:00:00.09 -01:00:00.09 7FFFFFEFFFFEA070 +-01:00:00.00 -01:00:00.00 7FFFFFF000000000 +-01:00:00.00 -01:00:00.00 7FFFFFF000000000 +-01:00:00.00 -01:00:00.00 7FFFFFF000000000 +-01:00:00.00 -01:00:00.00 7FFFFFF000000000 +-01:00:00.00 -01:00:00.00 7FFFFFF000000000 +-01:00:00.00 -01:00:00.00 7FFFFFF000000000 +-01:00:00.00 -01:00:00.00 7FFFFFF000000000 +-00:01:00.99 -00:01:00.99 7FFFFFFFBFF0E4D0 +-00:01:00.90 -00:01:00.90 7FFFFFFFBFF24460 +-00:01:00.10 -00:01:00.10 7FFFFFFFBFFE7960 +-00:01:00.09 -00:01:00.09 7FFFFFFFBFFEA070 +-00:01:00.00 -00:01:00.00 7FFFFFFFC0000000 +-00:01:00.00 -00:01:00.00 7FFFFFFFC0000000 +-00:01:00.00 -00:01:00.00 7FFFFFFFC0000000 +-00:01:00.00 -00:01:00.00 7FFFFFFFC0000000 +-00:01:00.00 -00:01:00.00 7FFFFFFFC0000000 +-00:01:00.00 -00:01:00.00 7FFFFFFFC0000000 +-00:01:00.00 -00:01:00.00 7FFFFFFFC0000000 +-00:00:01.99 -00:00:01.99 7FFFFFFFFEF0E4D0 +-00:00:01.99 -00:00:01.99 7FFFFFFFFEF0E4D0 +-00:00:01.99 -00:00:01.99 7FFFFFFFFEF0E4D0 +-00:00:01.99 -00:00:01.99 7FFFFFFFFEF0E4D0 +-00:00:01.99 -00:00:01.99 7FFFFFFFFEF0E4D0 +-00:00:01.90 -00:00:01.90 7FFFFFFFFEF24460 +-00:00:01.10 -00:00:01.10 7FFFFFFFFEFE7960 +-00:00:01.09 -00:00:01.09 7FFFFFFFFEFEA070 +-00:00:01.09 -00:00:01.09 7FFFFFFFFEFEA070 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:01.00 -00:00:01.00 7FFFFFFFFF000000 +-00:00:00.99 -00:00:00.99 7FFFFFFFFFF0E4D0 +-00:00:00.99 -00:00:00.99 7FFFFFFFFFF0E4D0 +-00:00:00.99 -00:00:00.99 7FFFFFFFFFF0E4D0 +-00:00:00.99 -00:00:00.99 7FFFFFFFFFF0E4D0 +-00:00:00.99 -00:00:00.99 7FFFFFFFFFF0E4D0 +-00:00:00.90 -00:00:00.90 7FFFFFFFFFF24460 +-00:00:00.10 -00:00:00.10 7FFFFFFFFFFE7960 +-00:00:00.09 -00:00:00.09 7FFFFFFFFFFEA070 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +-00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.00 00:00:00.00 8000000000000000 +00:00:00.09 00:00:00.09 8000000000015F90 +00:00:00.10 00:00:00.10 80000000000186A0 +00:00:00.90 00:00:00.90 80000000000DBBA0 +00:00:00.99 00:00:00.99 80000000000F1B30 +00:00:00.99 00:00:00.99 80000000000F1B30 +00:00:00.99 00:00:00.99 80000000000F1B30 +00:00:00.99 00:00:00.99 80000000000F1B30 +00:00:00.99 00:00:00.99 80000000000F1B30 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.00 00:00:01.00 8000000001000000 +00:00:01.09 00:00:01.09 8000000001015F90 +00:00:01.09 00:00:01.09 8000000001015F90 +00:00:01.10 00:00:01.10 80000000010186A0 +00:00:01.90 00:00:01.90 80000000010DBBA0 +00:00:01.99 00:00:01.99 80000000010F1B30 +00:00:01.99 00:00:01.99 80000000010F1B30 +00:00:01.99 00:00:01.99 80000000010F1B30 +00:00:01.99 00:00:01.99 80000000010F1B30 +00:00:01.99 00:00:01.99 80000000010F1B30 +00:01:00.00 00:01:00.00 8000000040000000 +00:01:00.00 00:01:00.00 8000000040000000 +00:01:00.00 00:01:00.00 8000000040000000 +00:01:00.00 00:01:00.00 8000000040000000 +00:01:00.00 00:01:00.00 8000000040000000 +00:01:00.00 00:01:00.00 8000000040000000 +00:01:00.00 00:01:00.00 8000000040000000 +00:01:00.09 00:01:00.09 8000000040015F90 +00:01:00.10 00:01:00.10 80000000400186A0 +00:01:00.90 00:01:00.90 80000000400DBBA0 +00:01:00.99 00:01:00.99 80000000400F1B30 +01:00:00.00 01:00:00.00 8000001000000000 +01:00:00.00 01:00:00.00 8000001000000000 +01:00:00.00 01:00:00.00 8000001000000000 +01:00:00.00 01:00:00.00 8000001000000000 +01:00:00.00 01:00:00.00 8000001000000000 +01:00:00.00 01:00:00.00 8000001000000000 +01:00:00.00 01:00:00.00 8000001000000000 +01:00:00.09 01:00:00.09 8000001000015F90 +01:00:00.10 01:00:00.10 80000010000186A0 +01:00:00.90 01:00:00.90 80000010000DBBA0 +01:00:00.99 01:00:00.99 80000010000F1B30 +01:00:00.99 01:00:00.99 80000010000F1B30 +01:00:00.99 01:00:00.99 80000010000F1B30 +01:00:00.99 01:00:00.99 80000010000F1B30 +01:00:00.99 01:00:00.99 80000010000F1B30 +838:59:58.00 838:59:58.00 8000346EFA000000 +838:59:58.00 838:59:58.00 8000346EFA000000 +838:59:58.00 838:59:58.00 8000346EFA000000 +838:59:58.00 838:59:58.00 8000346EFA000000 +838:59:58.00 838:59:58.00 8000346EFA000000 +838:59:58.00 838:59:58.00 8000346EFA000000 +838:59:58.00 838:59:58.00 8000346EFA000000 +838:59:58.09 838:59:58.09 8000346EFA015F90 +838:59:58.10 838:59:58.10 8000346EFA0186A0 +838:59:58.90 838:59:58.90 8000346EFA0DBBA0 +838:59:58.99 838:59:58.99 8000346EFA0F1B30 +838:59:58.99 838:59:58.99 8000346EFA0F1B30 +838:59:58.99 838:59:58.99 8000346EFA0F1B30 +838:59:58.99 838:59:58.99 8000346EFA0F1B30 +838:59:58.99 838:59:58.99 8000346EFA0F1B30 +838:59:59.00 838:59:59.00 8000346EFB000000 +SELECT a1, t1, HEX(WEIGHT_STRING(t1)) FROM t1 ORDER BY t1, a6; +a1 t1 HEX(WEIGHT_STRING(t1)) +-838:59:59.0 -838:59:59.0 7FFFCB9105000000 +-838:59:58.9 -838:59:58.9 7FFFCB9105F24460 +-838:59:58.9 -838:59:58.9 7FFFCB9105F24460 +-838:59:58.9 -838:59:58.9 7FFFCB9105F24460 +-838:59:58.9 -838:59:58.9 7FFFCB9105F24460 +-838:59:58.9 -838:59:58.9 7FFFCB9105F24460 +-838:59:58.9 -838:59:58.9 7FFFCB9105F24460 +-838:59:58.1 -838:59:58.1 7FFFCB9105FE7960 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-838:59:58.0 -838:59:58.0 7FFFCB9106000000 +-01:00:00.9 -01:00:00.9 7FFFFFEFFFF24460 +-01:00:00.9 -01:00:00.9 7FFFFFEFFFF24460 +-01:00:00.9 -01:00:00.9 7FFFFFEFFFF24460 +-01:00:00.9 -01:00:00.9 7FFFFFEFFFF24460 +-01:00:00.9 -01:00:00.9 7FFFFFEFFFF24460 +-01:00:00.9 -01:00:00.9 7FFFFFEFFFF24460 +-01:00:00.1 -01:00:00.1 7FFFFFEFFFFE7960 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-01:00:00.0 -01:00:00.0 7FFFFFF000000000 +-00:01:00.9 -00:01:00.9 7FFFFFFFBFF24460 +-00:01:00.9 -00:01:00.9 7FFFFFFFBFF24460 +-00:01:00.1 -00:01:00.1 7FFFFFFFBFFE7960 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:01:00.0 -00:01:00.0 7FFFFFFFC0000000 +-00:00:01.9 -00:00:01.9 7FFFFFFFFEF24460 +-00:00:01.9 -00:00:01.9 7FFFFFFFFEF24460 +-00:00:01.9 -00:00:01.9 7FFFFFFFFEF24460 +-00:00:01.9 -00:00:01.9 7FFFFFFFFEF24460 +-00:00:01.9 -00:00:01.9 7FFFFFFFFEF24460 +-00:00:01.9 -00:00:01.9 7FFFFFFFFEF24460 +-00:00:01.1 -00:00:01.1 7FFFFFFFFEFE7960 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:01.0 -00:00:01.0 7FFFFFFFFF000000 +-00:00:00.9 -00:00:00.9 7FFFFFFFFFF24460 +-00:00:00.9 -00:00:00.9 7FFFFFFFFFF24460 +-00:00:00.9 -00:00:00.9 7FFFFFFFFFF24460 +-00:00:00.9 -00:00:00.9 7FFFFFFFFFF24460 +-00:00:00.9 -00:00:00.9 7FFFFFFFFFF24460 +-00:00:00.9 -00:00:00.9 7FFFFFFFFFF24460 +-00:00:00.1 -00:00:00.1 7FFFFFFFFFFE7960 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +-00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.0 00:00:00.0 8000000000000000 +00:00:00.1 00:00:00.1 80000000000186A0 +00:00:00.9 00:00:00.9 80000000000DBBA0 +00:00:00.9 00:00:00.9 80000000000DBBA0 +00:00:00.9 00:00:00.9 80000000000DBBA0 +00:00:00.9 00:00:00.9 80000000000DBBA0 +00:00:00.9 00:00:00.9 80000000000DBBA0 +00:00:00.9 00:00:00.9 80000000000DBBA0 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.0 00:00:01.0 8000000001000000 +00:00:01.1 00:00:01.1 80000000010186A0 +00:00:01.9 00:00:01.9 80000000010DBBA0 +00:00:01.9 00:00:01.9 80000000010DBBA0 +00:00:01.9 00:00:01.9 80000000010DBBA0 +00:00:01.9 00:00:01.9 80000000010DBBA0 +00:00:01.9 00:00:01.9 80000000010DBBA0 +00:00:01.9 00:00:01.9 80000000010DBBA0 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.0 00:01:00.0 8000000040000000 +00:01:00.1 00:01:00.1 80000000400186A0 +00:01:00.9 00:01:00.9 80000000400DBBA0 +00:01:00.9 00:01:00.9 80000000400DBBA0 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.0 01:00:00.0 8000001000000000 +01:00:00.1 01:00:00.1 80000010000186A0 +01:00:00.9 01:00:00.9 80000010000DBBA0 +01:00:00.9 01:00:00.9 80000010000DBBA0 +01:00:00.9 01:00:00.9 80000010000DBBA0 +01:00:00.9 01:00:00.9 80000010000DBBA0 +01:00:00.9 01:00:00.9 80000010000DBBA0 +01:00:00.9 01:00:00.9 80000010000DBBA0 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.0 838:59:58.0 8000346EFA000000 +838:59:58.1 838:59:58.1 8000346EFA0186A0 +838:59:58.9 838:59:58.9 8000346EFA0DBBA0 +838:59:58.9 838:59:58.9 8000346EFA0DBBA0 +838:59:58.9 838:59:58.9 8000346EFA0DBBA0 +838:59:58.9 838:59:58.9 8000346EFA0DBBA0 +838:59:58.9 838:59:58.9 8000346EFA0DBBA0 +838:59:58.9 838:59:58.9 8000346EFA0DBBA0 +838:59:59.0 838:59:59.0 8000346EFB000000 +CREATE VIEW v1 AS +SELECT a6, t0, t1, t2, t3, t4, t5, t6, +HEX(WEIGHT_STRING(t0)) as wst0, +HEX(WEIGHT_STRING(t1)) as wst1, +HEX(WEIGHT_STRING(t2)) as wst2, +HEX(WEIGHT_STRING(t3)) as wst3, +HEX(WEIGHT_STRING(t4)) as wst4, +HEX(WEIGHT_STRING(t5)) as wst5, +HEX(WEIGHT_STRING(t6)) as wst6 +FROM t1; +SELECT * FROM v1 WHERE a6 LIKE '%.999999' ORDER BY a6, t6;; +a6 -00:00:00.999999 +t0 00:00:00 +t1 -00:00:00.9 +t2 -00:00:00.99 +t3 -00:00:00.999 +t4 -00:00:00.9999 +t5 -00:00:00.99999 +t6 -00:00:00.999999 +wst0 8000000000000000 +wst1 7FFFFFFFFFF24460 +wst2 7FFFFFFFFFF0E4D0 +wst3 7FFFFFFFFFF0C1A8 +wst4 7FFFFFFFFFF0BE24 +wst5 7FFFFFFFFFF0BDCA +wst6 7FFFFFFFFFF0BDC1 +a6 -00:00:01.999999 +t0 -00:00:01 +t1 -00:00:01.9 +t2 -00:00:01.99 +t3 -00:00:01.999 +t4 -00:00:01.9999 +t5 -00:00:01.99999 +t6 -00:00:01.999999 +wst0 7FFFFFFFFF000000 +wst1 7FFFFFFFFEF24460 +wst2 7FFFFFFFFEF0E4D0 +wst3 7FFFFFFFFEF0C1A8 +wst4 7FFFFFFFFEF0BE24 +wst5 7FFFFFFFFEF0BDCA +wst6 7FFFFFFFFEF0BDC1 +a6 -00:01:00.999999 +t0 -00:01:00 +t1 -00:01:00.9 +t2 -00:01:00.99 +t3 -00:01:00.999 +t4 -00:01:00.9999 +t5 -00:01:00.99999 +t6 -00:01:00.999999 +wst0 7FFFFFFFC0000000 +wst1 7FFFFFFFBFF24460 +wst2 7FFFFFFFBFF0E4D0 +wst3 7FFFFFFFBFF0C1A8 +wst4 7FFFFFFFBFF0BE24 +wst5 7FFFFFFFBFF0BDCA +wst6 7FFFFFFFBFF0BDC1 +a6 -01:00:00.999999 +t0 -01:00:00 +t1 -01:00:00.9 +t2 -01:00:00.99 +t3 -01:00:00.999 +t4 -01:00:00.9999 +t5 -01:00:00.99999 +t6 -01:00:00.999999 +wst0 7FFFFFF000000000 +wst1 7FFFFFEFFFF24460 +wst2 7FFFFFEFFFF0E4D0 +wst3 7FFFFFEFFFF0C1A8 +wst4 7FFFFFEFFFF0BE24 +wst5 7FFFFFEFFFF0BDCA +wst6 7FFFFFEFFFF0BDC1 +a6 -838:59:58.999999 +t0 -838:59:58 +t1 -838:59:58.9 +t2 -838:59:58.99 +t3 -838:59:58.999 +t4 -838:59:58.9999 +t5 -838:59:58.99999 +t6 -838:59:58.999999 +wst0 7FFFCB9106000000 +wst1 7FFFCB9105F24460 +wst2 7FFFCB9105F0E4D0 +wst3 7FFFCB9105F0C1A8 +wst4 7FFFCB9105F0BE24 +wst5 7FFFCB9105F0BDCA +wst6 7FFFCB9105F0BDC1 +a6 00:00:00.999999 +t0 00:00:00 +t1 00:00:00.9 +t2 00:00:00.99 +t3 00:00:00.999 +t4 00:00:00.9999 +t5 00:00:00.99999 +t6 00:00:00.999999 +wst0 8000000000000000 +wst1 80000000000DBBA0 +wst2 80000000000F1B30 +wst3 80000000000F3E58 +wst4 80000000000F41DC +wst5 80000000000F4236 +wst6 80000000000F423F +a6 00:00:01.999999 +t0 00:00:01 +t1 00:00:01.9 +t2 00:00:01.99 +t3 00:00:01.999 +t4 00:00:01.9999 +t5 00:00:01.99999 +t6 00:00:01.999999 +wst0 8000000001000000 +wst1 80000000010DBBA0 +wst2 80000000010F1B30 +wst3 80000000010F3E58 +wst4 80000000010F41DC +wst5 80000000010F4236 +wst6 80000000010F423F +a6 00:01:00.999999 +t0 00:01:00 +t1 00:01:00.9 +t2 00:01:00.99 +t3 00:01:00.999 +t4 00:01:00.9999 +t5 00:01:00.99999 +t6 00:01:00.999999 +wst0 8000000040000000 +wst1 80000000400DBBA0 +wst2 80000000400F1B30 +wst3 80000000400F3E58 +wst4 80000000400F41DC +wst5 80000000400F4236 +wst6 80000000400F423F +a6 01:00:00.999999 +t0 01:00:00 +t1 01:00:00.9 +t2 01:00:00.99 +t3 01:00:00.999 +t4 01:00:00.9999 +t5 01:00:00.99999 +t6 01:00:00.999999 +wst0 8000001000000000 +wst1 80000010000DBBA0 +wst2 80000010000F1B30 +wst3 80000010000F3E58 +wst4 80000010000F41DC +wst5 80000010000F4236 +wst6 80000010000F423F +a6 838:59:58.999999 +t0 838:59:58 +t1 838:59:58.9 +t2 838:59:58.99 +t3 838:59:58.999 +t4 838:59:58.9999 +t5 838:59:58.99999 +t6 838:59:58.999999 +wst0 8000346EFA000000 +wst1 8000346EFA0DBBA0 +wst2 8000346EFA0F1B30 +wst3 8000346EFA0F3E58 +wst4 8000346EFA0F41DC +wst5 8000346EFA0F4236 +wst6 8000346EFA0F423F +SELECT * FROM v1 WHERE a6 LIKE '%.000000' ORDER BY a6, t6;; +a6 -00:00:00.000000 +t0 00:00:00 +t1 00:00:00.0 +t2 00:00:00.00 +t3 00:00:00.000 +t4 00:00:00.0000 +t5 00:00:00.00000 +t6 00:00:00.000000 +wst0 8000000000000000 +wst1 8000000000000000 +wst2 8000000000000000 +wst3 8000000000000000 +wst4 8000000000000000 +wst5 8000000000000000 +wst6 8000000000000000 +a6 -00:00:01.000000 +t0 -00:00:01 +t1 -00:00:01.0 +t2 -00:00:01.00 +t3 -00:00:01.000 +t4 -00:00:01.0000 +t5 -00:00:01.00000 +t6 -00:00:01.000000 +wst0 7FFFFFFFFF000000 +wst1 7FFFFFFFFF000000 +wst2 7FFFFFFFFF000000 +wst3 7FFFFFFFFF000000 +wst4 7FFFFFFFFF000000 +wst5 7FFFFFFFFF000000 +wst6 7FFFFFFFFF000000 +a6 -838:59:59.000000 +t0 -838:59:59 +t1 -838:59:59.0 +t2 -838:59:59.00 +t3 -838:59:59.000 +t4 -838:59:59.0000 +t5 -838:59:59.00000 +t6 -838:59:59.000000 +wst0 7FFFCB9105000000 +wst1 7FFFCB9105000000 +wst2 7FFFCB9105000000 +wst3 7FFFCB9105000000 +wst4 7FFFCB9105000000 +wst5 7FFFCB9105000000 +wst6 7FFFCB9105000000 +a6 00:00:00.000000 +t0 00:00:00 +t1 00:00:00.0 +t2 00:00:00.00 +t3 00:00:00.000 +t4 00:00:00.0000 +t5 00:00:00.00000 +t6 00:00:00.000000 +wst0 8000000000000000 +wst1 8000000000000000 +wst2 8000000000000000 +wst3 8000000000000000 +wst4 8000000000000000 +wst5 8000000000000000 +wst6 8000000000000000 +a6 00:00:01.000000 +t0 00:00:01 +t1 00:00:01.0 +t2 00:00:01.00 +t3 00:00:01.000 +t4 00:00:01.0000 +t5 00:00:01.00000 +t6 00:00:01.000000 +wst0 8000000001000000 +wst1 8000000001000000 +wst2 8000000001000000 +wst3 8000000001000000 +wst4 8000000001000000 +wst5 8000000001000000 +wst6 8000000001000000 +a6 838:59:59.000000 +t0 838:59:59 +t1 838:59:59.0 +t2 838:59:59.00 +t3 838:59:59.000 +t4 838:59:59.0000 +t5 838:59:59.00000 +t6 838:59:59.000000 +wst0 8000346EFB000000 +wst1 8000346EFB000000 +wst2 8000346EFB000000 +wst3 8000346EFB000000 +wst4 8000346EFB000000 +wst5 8000346EFB000000 +wst6 8000346EFB000000 +SELECT * FROM v1 WHERE a6 LIKE '%.100000' ORDER BY a6, t6;; +a6 -00:00:00.100000 +t0 00:00:00 +t1 -00:00:00.1 +t2 -00:00:00.10 +t3 -00:00:00.100 +t4 -00:00:00.1000 +t5 -00:00:00.10000 +t6 -00:00:00.100000 +wst0 8000000000000000 +wst1 7FFFFFFFFFFE7960 +wst2 7FFFFFFFFFFE7960 +wst3 7FFFFFFFFFFE7960 +wst4 7FFFFFFFFFFE7960 +wst5 7FFFFFFFFFFE7960 +wst6 7FFFFFFFFFFE7960 +a6 -00:00:01.100000 +t0 -00:00:01 +t1 -00:00:01.1 +t2 -00:00:01.10 +t3 -00:00:01.100 +t4 -00:00:01.1000 +t5 -00:00:01.10000 +t6 -00:00:01.100000 +wst0 7FFFFFFFFF000000 +wst1 7FFFFFFFFEFE7960 +wst2 7FFFFFFFFEFE7960 +wst3 7FFFFFFFFEFE7960 +wst4 7FFFFFFFFEFE7960 +wst5 7FFFFFFFFEFE7960 +wst6 7FFFFFFFFEFE7960 +a6 -00:01:00.100000 +t0 -00:01:00 +t1 -00:01:00.1 +t2 -00:01:00.10 +t3 -00:01:00.100 +t4 -00:01:00.1000 +t5 -00:01:00.10000 +t6 -00:01:00.100000 +wst0 7FFFFFFFC0000000 +wst1 7FFFFFFFBFFE7960 +wst2 7FFFFFFFBFFE7960 +wst3 7FFFFFFFBFFE7960 +wst4 7FFFFFFFBFFE7960 +wst5 7FFFFFFFBFFE7960 +wst6 7FFFFFFFBFFE7960 +a6 -01:00:00.100000 +t0 -01:00:00 +t1 -01:00:00.1 +t2 -01:00:00.10 +t3 -01:00:00.100 +t4 -01:00:00.1000 +t5 -01:00:00.10000 +t6 -01:00:00.100000 +wst0 7FFFFFF000000000 +wst1 7FFFFFEFFFFE7960 +wst2 7FFFFFEFFFFE7960 +wst3 7FFFFFEFFFFE7960 +wst4 7FFFFFEFFFFE7960 +wst5 7FFFFFEFFFFE7960 +wst6 7FFFFFEFFFFE7960 +a6 -838:59:58.100000 +t0 -838:59:58 +t1 -838:59:58.1 +t2 -838:59:58.10 +t3 -838:59:58.100 +t4 -838:59:58.1000 +t5 -838:59:58.10000 +t6 -838:59:58.100000 +wst0 7FFFCB9106000000 +wst1 7FFFCB9105FE7960 +wst2 7FFFCB9105FE7960 +wst3 7FFFCB9105FE7960 +wst4 7FFFCB9105FE7960 +wst5 7FFFCB9105FE7960 +wst6 7FFFCB9105FE7960 +a6 00:00:00.100000 +t0 00:00:00 +t1 00:00:00.1 +t2 00:00:00.10 +t3 00:00:00.100 +t4 00:00:00.1000 +t5 00:00:00.10000 +t6 00:00:00.100000 +wst0 8000000000000000 +wst1 80000000000186A0 +wst2 80000000000186A0 +wst3 80000000000186A0 +wst4 80000000000186A0 +wst5 80000000000186A0 +wst6 80000000000186A0 +a6 00:00:01.100000 +t0 00:00:01 +t1 00:00:01.1 +t2 00:00:01.10 +t3 00:00:01.100 +t4 00:00:01.1000 +t5 00:00:01.10000 +t6 00:00:01.100000 +wst0 8000000001000000 +wst1 80000000010186A0 +wst2 80000000010186A0 +wst3 80000000010186A0 +wst4 80000000010186A0 +wst5 80000000010186A0 +wst6 80000000010186A0 +a6 00:01:00.100000 +t0 00:01:00 +t1 00:01:00.1 +t2 00:01:00.10 +t3 00:01:00.100 +t4 00:01:00.1000 +t5 00:01:00.10000 +t6 00:01:00.100000 +wst0 8000000040000000 +wst1 80000000400186A0 +wst2 80000000400186A0 +wst3 80000000400186A0 +wst4 80000000400186A0 +wst5 80000000400186A0 +wst6 80000000400186A0 +a6 01:00:00.100000 +t0 01:00:00 +t1 01:00:00.1 +t2 01:00:00.10 +t3 01:00:00.100 +t4 01:00:00.1000 +t5 01:00:00.10000 +t6 01:00:00.100000 +wst0 8000001000000000 +wst1 80000010000186A0 +wst2 80000010000186A0 +wst3 80000010000186A0 +wst4 80000010000186A0 +wst5 80000010000186A0 +wst6 80000010000186A0 +a6 838:59:58.100000 +t0 838:59:58 +t1 838:59:58.1 +t2 838:59:58.10 +t3 838:59:58.100 +t4 838:59:58.1000 +t5 838:59:58.10000 +t6 838:59:58.100000 +wst0 8000346EFA000000 +wst1 8000346EFA0186A0 +wst2 8000346EFA0186A0 +wst3 8000346EFA0186A0 +wst4 8000346EFA0186A0 +wst5 8000346EFA0186A0 +wst6 8000346EFA0186A0 +DROP VIEW v1; +DROP TABLE t1; +# +# Testing that TIME(0) is a synonym to non-fractional TIME +# +CREATE TABLE t1 (a TIME(0) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing bad FSPs +# +CREATE TABLE t1 (a TIME(-1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1 +CREATE TABLE t1 (a TIME(7)); +ERROR 42000: Too-big precision 7 specified for 'a'. Maximum is 6. +CREATE TABLE t1 (a TIME(31)); +ERROR 42000: Too-big precision 31 specified for 'a'. Maximum is 6. +# +# Testing bad FSPs with TIME functions +# +SELECT CURTIME(-1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1)' at line 1 +SELECT CURTIME(7); +ERROR 42000: Too-big precision 7 specified for 'curtime'. Maximum is 6. +SELECT CURTIME(31); +ERROR 42000: Too-big precision 31 specified for 'curtime'. Maximum is 6. +# +# Testing INSERT, ORDER, KEY, BETWEEN, comparison +# +CREATE TABLE t1 (a TIME(6) NOT NULL); +INSERT INTO t1 VALUES ('-838:59:59.000000'); +INSERT INTO t1 VALUES ('-01:00:00.999999'); +INSERT INTO t1 VALUES ('-01:00:00.000001'); +INSERT INTO t1 VALUES ('-01:00:00.000000'); +INSERT INTO t1 VALUES ('-00:00:00.000001'); +INSERT INTO t1 VALUES ('00:00:00.000000'); +INSERT INTO t1 VALUES ('23:59:59.999999'); +INSERT INTO t1 VALUES ('01:02:03'); +INSERT INTO t1 VALUES ('01:02:03.4'); +INSERT INTO t1 VALUES ('01:02:03.45'); +INSERT INTO t1 VALUES ('01:02:03.456'); +INSERT INTO t1 VALUES ('01:02:03.4567'); +INSERT INTO t1 VALUES ('01:02:03.45678'); +INSERT INTO t1 VALUES ('01:02:03.4567891'); +INSERT INTO t1 VALUES ('838:59:59.000000'); +SELECT * FROM t1; +a +-838:59:59.000000 +-01:00:00.999999 +-01:00:00.000001 +-01:00:00.000000 +-00:00:00.000001 +00:00:00.000000 +23:59:59.999999 +01:02:03.000000 +01:02:03.400000 +01:02:03.450000 +01:02:03.456000 +01:02:03.456700 +01:02:03.456780 +01:02:03.456789 +838:59:59.000000 +SELECT * FROM t1 ORDER BY a DESC; +a +838:59:59.000000 +23:59:59.999999 +01:02:03.456789 +01:02:03.456780 +01:02:03.456700 +01:02:03.456000 +01:02:03.450000 +01:02:03.400000 +01:02:03.000000 +00:00:00.000000 +-00:00:00.000001 +-01:00:00.000000 +-01:00:00.000001 +-01:00:00.999999 +-838:59:59.000000 +SELECT * FROM t1 WHERE a='01:02:03.45'; +a +01:02:03.450000 +SELECT * FROM t1 WHERE a='01:02:03.4567'; +a +01:02:03.456700 +SELECT * FROM t1 WHERE a='01:02:03.45670'; +a +01:02:03.456700 +SELECT * FROM t1 WHERE a='01:02:03.456700'; +a +01:02:03.456700 +SELECT * FROM t1 WHERE a BETWEEN '01:02:00' AND '01:03:00'; +a +01:02:03.000000 +01:02:03.400000 +01:02:03.450000 +01:02:03.456000 +01:02:03.456700 +01:02:03.456780 +01:02:03.456789 +SELECT * FROM t1 WHERE a BETWEEN TIME'01:02:03.456' AND TIME'01:02:03.45678'; +a +01:02:03.456000 +01:02:03.456700 +01:02:03.456780 +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1 ORDER BY a; +a +-838:59:59.000000 +-01:00:00.999999 +-01:00:00.000001 +-01:00:00.000000 +-00:00:00.000001 +00:00:00.000000 +01:02:03.000000 +01:02:03.400000 +01:02:03.450000 +01:02:03.456000 +01:02:03.456700 +01:02:03.456780 +01:02:03.456789 +23:59:59.999999 +838:59:59.000000 +SELECT * FROM t1 ORDER BY a DESC; +a +838:59:59.000000 +23:59:59.999999 +01:02:03.456789 +01:02:03.456780 +01:02:03.456700 +01:02:03.456000 +01:02:03.450000 +01:02:03.400000 +01:02:03.000000 +00:00:00.000000 +-00:00:00.000001 +-01:00:00.000000 +-01:00:00.000001 +-01:00:00.999999 +-838:59:59.000000 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a='01:02:03.456700'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 6 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIME'01:02:03.4567') +SELECT * FROM t1 WHERE a='01:02:03.456700'; +a +01:02:03.456700 +SELECT * FROM t1 WHERE a BETWEEN '01:02:00' AND '01:03:00'; +a +01:02:03.000000 +01:02:03.400000 +01:02:03.450000 +01:02:03.456000 +01:02:03.456700 +01:02:03.456780 +01:02:03.456789 +SELECT * FROM t1 WHERE a BETWEEN TIME'01:02:03.456' AND TIME'01:02:03.45678'; +a +01:02:03.456000 +01:02:03.456700 +01:02:03.456780 +DROP TABLE t1; +# +# Testing TIME with days +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00'); +INSERT INTO t1 VALUES ('-24:00:00'), ('24:00:00'); +INSERT INTO t1 VALUES ('-1 00:00:00'), ('1 00:00:00'); +INSERT INTO t1 VALUES ('-10 00:00:00'), ('10 00:00:00'); +SELECT * FROM t1 ORDER BY a; +a +-240:00:00.000000 +-24:00:00.000000 +-24:00:00.000000 +00:00:00.000000 +24:00:00.000000 +24:00:00.000000 +240:00:00.000000 +DROP TABLE t1; +# +# Testing rare formats +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES (1122), ('1:2:3'), ('112233'),('-00:00:00'),('-00:00:00.000000'); +SELECT * FROM t1 ORDER BY a; +a +00:00:00.000000 +00:00:00.000000 +00:11:22.000000 +01:02:03.000000 +11:22:33.000000 +DROP TABLE t1; +# +# Testing bad values +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES (106060); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (106060.0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (106060e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('106060'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +DROP TABLE t1; +SET sql_mode = default; +# +# Testing bad values with TRADITIONAL mode +# +SET sql_mode=traditional; +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00.111111 xxx'); +ERROR 22007: Incorrect time value: '00:00:00.111111 xxx' for column 'a' at row 1 +INSERT INTO t1 VALUES (106060); +ERROR 22007: Incorrect time value: '106060' for column 'a' at row 1 +INSERT INTO t1 VALUES (106060.0); +ERROR 22007: Incorrect time value: '106060.0' for column 'a' at row 1 +INSERT INTO t1 VALUES (106060e0); +ERROR 22007: Incorrect time value: '106060' for column 'a' at row 1 +INSERT INTO t1 VALUES ('106060'); +ERROR 22007: Incorrect time value: '106060' for column 'a' at row 1 +INSERT INTO t1 VALUES ('838:59:59.0000009'); +ERROR 22007: Incorrect time value: '838:59:59.0000009' for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.0000009'); +ERROR 22007: Incorrect time value: '-838:59:59.0000009' for column 'a' at row 1 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS SIGNED)); +ERROR 22007: Incorrect time value: '-4294967296' for column 'a' at row 1 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS UNSIGNED)); +ERROR 22007: Incorrect time value: '18446744069414584320' for column 'a' at row 1 +SELECT * FROM t1; +a +DROP TABLE t1; +SET sql_mode=default; +# +# Testing rounding +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES (105959.1234567); +INSERT INTO t1 VALUES ('00:00:00.1111110'); +INSERT INTO t1 VALUES ('00:00:00.1111111'); +INSERT INTO t1 VALUES ('00:00:00.1111114'); +INSERT INTO t1 VALUES ('00:00:00.1111115'); +INSERT INTO t1 VALUES ('00:00:00.1111119'); +SELECT * FROM t1; +a +10:59:59.123457 +00:00:00.111111 +00:00:00.111111 +00:00:00.111111 +00:00:00.111112 +00:00:00.111112 +DELETE FROM t1; +INSERT INTO t1 VALUES (0.1111110); +INSERT INTO t1 VALUES (0.1111111); +INSERT INTO t1 VALUES (0.1111114); +INSERT INTO t1 VALUES (0.1111115); +INSERT INTO t1 VALUES (0.1111119); +SELECT * FROM t1; +a +00:00:00.111111 +00:00:00.111111 +00:00:00.111111 +00:00:00.111112 +00:00:00.111112 +DELETE FROM t1; +INSERT INTO t1 VALUES (0.1111110e0); +INSERT INTO t1 VALUES (0.1111111e0); +INSERT INTO t1 VALUES (0.1111114e0); +INSERT INTO t1 VALUES (0.1111115e0); +INSERT INTO t1 VALUES (0.1111119e0); +SELECT * FROM t1; +a +00:00:00.111111 +00:00:00.111111 +00:00:00.111111 +00:00:00.111112 +00:00:00.111112 +DROP TABLE t1; +# +# Testing huge values +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS SIGNED)); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS UNSIGNED)); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ( 100000000000000000.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ( 100000000000000000.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-100000000000000000.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-100000000000000000.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (1000000000.0 * 1000000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1000000000.0 * 1000000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +-838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +838:59:59.000000 +-838:59:59.000000 +DROP TABLE t1; +# +# Testing truncation warnings +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00.111111 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +00:00:00.111111 +DROP TABLE t1; +SET sql_mode = default; +# +# Testing IN +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-99:00:00.000000'); +INSERT INTO t1 VALUES ('-99:00:00.000001'); +INSERT INTO t1 VALUES ('-99:00:00.000002'); +INSERT INTO t1 VALUES ('-00:00:00.000001'); +INSERT INTO t1 VALUES ('-00:00:00.000002'); +INSERT INTO t1 VALUES ('00:00:00.000000'); +INSERT INTO t1 VALUES ('00:00:00.000001'); +INSERT INTO t1 VALUES ('00:00:00.000002'); +INSERT INTO t1 VALUES ('10:00:00.000000'); +INSERT INTO t1 VALUES ('10:00:00.000001'); +INSERT INTO t1 VALUES ('10:00:00.000002'); +INSERT INTO t1 VALUES ('99:00:00.000000'); +INSERT INTO t1 VALUES ('99:00:00.000001'); +INSERT INTO t1 VALUES ('99:00:00.000002'); +SELECT * FROM t1 WHERE a IN ('00:00:00', '-99:00:00.000001', '99:00:00.000002'); +a +-99:00:00.000001 +00:00:00.000000 +99:00:00.000002 +SELECT * FROM t1 WHERE a IN (0, -990000, 990000); +a +-99:00:00.000000 +00:00:00.000000 +99:00:00.000000 +SELECT * FROM t1 WHERE a IN (0.000001, -990000.000001, 990000.000001); +a +-99:00:00.000001 +00:00:00.000001 +99:00:00.000001 +# +# Testing Item_temporal_with_ref::print +# +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a IN (990000,0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 14 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 14 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` in ('99:00:00.000000','00:00:00.000000')) +# +# Testing IN with index: field->store_packed +# +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1 WHERE a IN ('00:00:00', '-99:00:00.000001', '99:00:00.000002'); +a +-99:00:00.000001 +00:00:00.000000 +99:00:00.000002 +SELECT * FROM t1 WHERE a IN (0, -990000, 990000); +a +-99:00:00.000000 +00:00:00.000000 +99:00:00.000000 +SELECT * FROM t1 WHERE a IN (0.000001, -990000.000001, 990000.000001); +a +-99:00:00.000001 +00:00:00.000001 +99:00:00.000001 +DROP TABLE t1; +# +# Testing CREATE TABLE LIKE +# +CREATE TABLE t1 (a TIME(6)); +CREATE TABLE t2 LIKE t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +# +# Testing CREATE TABLE .. SELECT +# +CREATE TABLE t1 (a TIME(6)); +CREATE TABLE t2 AS SELECT * FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +# +# Testing JOIN between TIME(6) and TIME(6) +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:01:03.1'); +INSERT INTO t1 VALUES ('00:01:03.12'); +INSERT INTO t1 VALUES ('00:01:03.123'); +INSERT INTO t1 VALUES ('00:01:03.1234'); +INSERT INTO t1 VALUES ('00:01:03.12345'); +INSERT INTO t1 VALUES ('00:01:03.123456'); +CREATE TABLE t2 (a TIME(6)); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +00:01:03.100000 00:01:03.100000 +00:01:03.120000 00:01:03.120000 +00:01:03.123000 00:01:03.123000 +00:01:03.123400 00:01:03.123400 +00:01:03.123450 00:01:03.123450 +00:01:03.123456 00:01:03.123456 +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +00:01:03.100000 00:01:03.100000 +00:01:03.120000 00:01:03.120000 +00:01:03.123000 00:01:03.123000 +00:01:03.123400 00:01:03.123400 +00:01:03.123450 00:01:03.123450 +00:01:03.123456 00:01:03.123456 +ALTER TABLE t2 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +00:01:03.100000 00:01:03.100000 +00:01:03.120000 00:01:03.120000 +00:01:03.123000 00:01:03.123000 +00:01:03.123400 00:01:03.123400 +00:01:03.123450 00:01:03.123450 +00:01:03.123456 00:01:03.123456 +ALTER TABLE t1 DROP KEY a; +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +00:01:03.100000 00:01:03.100000 +00:01:03.120000 00:01:03.120000 +00:01:03.123000 00:01:03.123000 +00:01:03.123400 00:01:03.123400 +00:01:03.123450 00:01:03.123450 +00:01:03.123456 00:01:03.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing JOIN between TIME and TIME(6) +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-836:59:59.000000'); +INSERT INTO t1 VALUES ('10:11:12.000000'); +INSERT INTO t1 VALUES ('10:11:12.000001'); +INSERT INTO t1 VALUES ('10:11:12.000002'); +INSERT INTO t1 VALUES ('10:11:13.000000'); +INSERT INTO t1 VALUES ('10:11:13.000001'); +INSERT INTO t1 VALUES ('10:11:13.000002'); +INSERT INTO t1 VALUES ('835:59:59.999999'); +INSERT INTO t1 VALUES ('836:59:59.000000'); +CREATE TABLE t2 (a TIME); +INSERT INTO t2 VALUES ('10:11:12'); +INSERT INTO t2 VALUES ('10:11:13'); +INSERT INTO t2 VALUES ('-836:59:59'); +INSERT INTO t2 VALUES ('836:59:59'); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +-836:59:59.000000 -836:59:59 +10:11:12.000000 10:11:12 +10:11:13.000000 10:11:13 +836:59:59.000000 836:59:59 +ALTER TABLE t1 ADD KEY(a); +ALTER TABLE t2 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +-836:59:59.000000 -836:59:59 +10:11:12.000000 10:11:12 +10:11:13.000000 10:11:13 +836:59:59.000000 836:59:59 +DROP TABLE t2, t1; +# +# Testing unique index +# +CREATE TABLE t1 (a TIME(6), UNIQUE(a)); +INSERT INTO t1 VALUES ('00:01:02'); +INSERT INTO t1 VALUES ('00:01:02.1'); +INSERT INTO t1 VALUES ('00:01:02.12'); +INSERT INTO t1 VALUES ('00:01:02.123'); +INSERT INTO t1 VALUES ('00:01:02.1234'); +INSERT INTO t1 VALUES ('00:01:02.12345'); +INSERT INTO t1 VALUES ('00:01:02.12345'); +ERROR 23000: Duplicate entry '00:01:02.123450' for key 't1.a' +DROP TABLE t1; +# +# Testing GROUP BY +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:01:02'); +INSERT INTO t1 VALUES ('00:01:02.0'); +INSERT INTO t1 VALUES ('00:01:02.01'); +INSERT INTO t1 VALUES ('00:01:02.010'); +INSERT INTO t1 VALUES ('00:01:02.02'); +INSERT INTO t1 VALUES ('00:01:02.020'); +SELECT a, COUNT(*) FROM t1 GROUP BY a; +a COUNT(*) +00:01:02.000000 2 +00:01:02.010000 2 +00:01:02.020000 2 +DROP TABLE t1; +# +# Testing MIN() and MAX() +# +CREATE TABLE t1 (a INT, b TIME(6)); +INSERT INTO t1 VALUES (1, '00:01:02.000001'); +INSERT INTO t1 VALUES (1, '00:01:02'); +INSERT INTO t1 VALUES (2, '10:01:02'); +INSERT INTO t1 VALUES (2, '10:01:02.000001'); +INSERT INTO t1 VALUES (3, '10:11:02'); +INSERT INTO t1 VALUES (3, '10:11:02.000001'); +SELECT MIN(b), MAX(b) FROM t1; +MIN(b) MAX(b) +00:01:02.000000 10:11:02.000001 +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a; +a MIN(b) MAX(b) +1 00:01:02.000000 00:01:02.000001 +2 10:01:02.000000 10:01:02.000001 +3 10:11:02.000000 10:11:02.000001 +UPDATE t1 SET b=-b; +SELECT MIN(b), MAX(b) FROM t1; +MIN(b) MAX(b) +-10:11:02.000001 -00:01:02.000000 +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a; +a MIN(b) MAX(b) +1 -00:01:02.000001 -00:01:02.000000 +2 -10:01:02.000001 -10:01:02.000000 +3 -10:11:02.000001 -10:11:02.000000 +DROP TABLE t1; +# +# Testing MIN(TIME) and MAX(TIME) in arithmetic expressions and CAST +# This covers Item_sum_hybrid::val_int(), val_real(), val_decimal() +# +CREATE TABLE t1 +( +t0 TIME, +t1 TIME(1), t2 TIME(2), t3 TIME(3), +t4 TIME(4), t5 TIME(5), t6 TIME(6) +); +INSERT INTO t1 VALUES +( +'10:10:10', +'10:10:10.9', '10:10:10.99', '10:10:10.999', +'10:10:10.9999', '10:10:10.99999', '10:10:10.999999' +); +CREATE TABLE t2 AS +SELECT +MAX(t0) + 1, +MAX(t1) + 1, MAX(t2) + 1, MAX(t3) + 1, +MAX(t4) + 1, MAX(t5) + 1, MAX(t6) + 1 +FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +MAX(t0) + 1 int YES NULL +MAX(t1) + 1 decimal(9,1) YES NULL +MAX(t2) + 1 decimal(10,2) YES NULL +MAX(t3) + 1 decimal(11,3) YES NULL +MAX(t4) + 1 decimal(12,4) YES NULL +MAX(t5) + 1 decimal(13,5) YES NULL +MAX(t6) + 1 decimal(14,6) YES NULL +SELECT * FROM t2; +MAX(t0) + 1 MAX(t1) + 1 MAX(t2) + 1 MAX(t3) + 1 MAX(t4) + 1 MAX(t5) + 1 MAX(t6) + 1 +101011 101011.9 101011.99 101011.999 101011.9999 101011.99999 101011.999999 +DROP TABLE t2; +CREATE TABLE t2 AS +SELECT +MAX(t0) + 1.1, +MAX(t1) + 1.1, MAX(t2) + 1.1, MAX(t3) + 1.1, +MAX(t4) + 1.1, MAX(t5) + 1.1, MAX(t6) + 1.1 +FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +MAX(t0) + 1.1 decimal(9,1) YES NULL +MAX(t1) + 1.1 decimal(9,1) YES NULL +MAX(t2) + 1.1 decimal(10,2) YES NULL +MAX(t3) + 1.1 decimal(11,3) YES NULL +MAX(t4) + 1.1 decimal(12,4) YES NULL +MAX(t5) + 1.1 decimal(13,5) YES NULL +MAX(t6) + 1.1 decimal(14,6) YES NULL +SELECT * FROM t2; +MAX(t0) + 1.1 MAX(t1) + 1.1 MAX(t2) + 1.1 MAX(t3) + 1.1 MAX(t4) + 1.1 MAX(t5) + 1.1 MAX(t6) + 1.1 +101011.1 101012.0 101012.09 101012.099 101012.0999 101012.09999 101012.099999 +DROP TABLE t2; +CREATE TABLE t2 AS +SELECT +MAX(t0) + 1.0e0, +MAX(t1) + 1.0e0, MAX(t2) + 1.0e0, MAX(t3) + 1.0e0, +MAX(t4) + 1.0e0, MAX(t5) + 1.0e0, MAX(t6) + 1.0e0 +FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +MAX(t0) + 1.0e0 double YES NULL +MAX(t1) + 1.0e0 double YES NULL +MAX(t2) + 1.0e0 double YES NULL +MAX(t3) + 1.0e0 double YES NULL +MAX(t4) + 1.0e0 double YES NULL +MAX(t5) + 1.0e0 double YES NULL +MAX(t6) + 1.0e0 double YES NULL +SELECT * FROM t2; +MAX(t0) + 1.0e0 MAX(t1) + 1.0e0 MAX(t2) + 1.0e0 MAX(t3) + 1.0e0 MAX(t4) + 1.0e0 MAX(t5) + 1.0e0 MAX(t6) + 1.0e0 +101011 101011.9 101011.99 101011.999 101011.9999 101011.99999 101011.999999 +DROP TABLE t2; +SELECT +MAX(t0) + 1, +MAX(t1) + 1, MAX(t2) + 1, MAX(t3) + 1, +MAX(t4) + 1, MAX(t5) + 1, MAX(t6) + 1 +FROM t1; +MAX(t0) + 1 MAX(t1) + 1 MAX(t2) + 1 MAX(t3) + 1 MAX(t4) + 1 MAX(t5) + 1 MAX(t6) + 1 +101011 101011.9 101011.99 101011.999 101011.9999 101011.99999 101011.999999 +SELECT +CAST(MAX(t0) AS SIGNED), +CAST(MAX(t1) AS SIGNED), CAST(MAX(t2) AS SIGNED), CAST(MAX(t3) AS SIGNED), +CAST(MAX(t4) AS SIGNED), CAST(MAX(t5) AS SIGNED), CAST(MAX(t6) AS SIGNED) +FROM t1; +CAST(MAX(t0) AS SIGNED) CAST(MAX(t1) AS SIGNED) CAST(MAX(t2) AS SIGNED) CAST(MAX(t3) AS SIGNED) CAST(MAX(t4) AS SIGNED) CAST(MAX(t5) AS SIGNED) CAST(MAX(t6) AS SIGNED) +101010 101011 101011 101011 101011 101011 101011 +DROP TABLE t1; +# +# Testing LEAST, GREATEST +# +SELECT LEAST(CAST('00:00:00.1' as TIME(6)), '00:00:01.1') AS a; +a +00:00:00.100000 +SELECT LEAST(TIME'00:00:00.1', TIME'00:00:00.12') AS a; +a +00:00:00.10 +SELECT GREATEST(CAST('00:00:00.1' as TIME(6)), '00:00:01.1') AS a; +a +00:00:01.1 +SELECT GREATEST(TIME'00:00:00.1', TIME'00:00:00.12') AS a; +a +00:00:00.12 +CREATE TABLE t1 AS SELECT +LEAST(TIME'00:00:00.1', TIME'00:00:00.12'), +GREATEST(TIME'00:00:00.1', TIME'00:00:00.12'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `LEAST(TIME'00:00:00.1', TIME'00:00:00.12')` time(2) NOT NULL DEFAULT '00:00:00.00', + `GREATEST(TIME'00:00:00.1', TIME'00:00:00.12')` time(2) NOT NULL DEFAULT '00:00:00.00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing INSERT with near-maximum and near-minimum supported values. +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('838:59:59.999999'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('838:59:59'); +INSERT INTO t1 VALUES ('838:59:59.0000001'); +INSERT INTO t1 VALUES ('838:59:59.0000002'); +INSERT INTO t1 VALUES ('838:59:59.0000003'); +INSERT INTO t1 VALUES ('838:59:59.0000004'); +INSERT INTO t1 VALUES ('838:59:59.0000005'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('838:59:59.0000006'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('838:59:59.0000007'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('838:59:59.0000008'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('838:59:59.0000009'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('838:59:59.1'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('839:00:00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59'); +INSERT INTO t1 VALUES ('-838:59:59.0000001'); +INSERT INTO t1 VALUES ('-838:59:59.0000002'); +INSERT INTO t1 VALUES ('-838:59:59.0000003'); +INSERT INTO t1 VALUES ('-838:59:59.0000004'); +INSERT INTO t1 VALUES ('-838:59:59.0000005'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.0000006'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.0000007'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.0000008'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.0000009'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.000001'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.999999'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-839:00:00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-839:00:00.1'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('-838:59:59.999999'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +DROP TABLE t1; +# +# Testing integer INSERT value +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES (20203); +INSERT INTO t1 VALUES (8385959); +INSERT INTO t1 VALUES (8390000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959); +INSERT INTO t1 VALUES (-8390000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +02:02:03.000000 +838:59:59.000000 +838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +DROP TABLE t1; +# +# Testing decimal INSERT values +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES (20203.4); +INSERT INTO t1 VALUES (20203.45); +INSERT INTO t1 VALUES (20203.456); +INSERT INTO t1 VALUES (20203.4567); +INSERT INTO t1 VALUES (20203.45678); +INSERT INTO t1 VALUES (20203.456789); +INSERT INTO t1 VALUES (20203.4567894); +INSERT INTO t1 VALUES (20203.4567895); +INSERT INTO t1 VALUES (20203.4567896); +INSERT INTO t1 VALUES (20203.456789678); +INSERT INTO t1 VALUES (8385959.999999); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8385959.000000); +INSERT INTO t1 VALUES (8385959.0000001); +INSERT INTO t1 VALUES (8385959.0000002); +INSERT INTO t1 VALUES (8385959.0000003); +INSERT INTO t1 VALUES (8385959.0000004); +INSERT INTO t1 VALUES (8385959.0000005); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8385959.0000006); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8385959.0000007); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8385959.0000008); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8385959.0000009); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8385959.000001); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8390000.000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.000000); +INSERT INTO t1 VALUES (-8385959.0000001); +INSERT INTO t1 VALUES (-8385959.0000002); +INSERT INTO t1 VALUES (-8385959.0000003); +INSERT INTO t1 VALUES (-8385959.0000004); +INSERT INTO t1 VALUES (-8385959.0000005); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.0000006); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.0000007); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.0000008); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.0000009); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.000001); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8390000.000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.999999); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +02:02:03.400000 +02:02:03.450000 +02:02:03.456000 +02:02:03.456700 +02:02:03.456780 +02:02:03.456789 +02:02:03.456789 +02:02:03.456790 +02:02:03.456790 +02:02:03.456790 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +DROP TABLE t1; +# +# Testing double INSERT values +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES (123.4567e-3); +INSERT INTO t1 VALUES (123.4567e-2); +INSERT INTO t1 VALUES (123.4567e-1); +INSERT INTO t1 VALUES (123.4567e0); +INSERT INTO t1 VALUES (123.4567e1); +INSERT INTO t1 VALUES (123.4567e2); +INSERT INTO t1 VALUES (123.4567e3); +INSERT INTO t1 VALUES (8385959.999999e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8385959e0); +INSERT INTO t1 VALUES (8385959.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (8390000.0e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.0e0); +INSERT INTO t1 VALUES (-8385959.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8385959.999999e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-8390000.0e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +00:00:00.123457 +00:00:01.234567 +00:00:12.345670 +00:01:23.456700 +00:12:34.567000 +01:23:45.670000 +12:34:56.700000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +-838:59:59.000000 +DROP TABLE t1; +SET sql_mode = default; +# +# Testing UPDATE between TIME(6) and TIME/INT/DECIMAL/FLOAT +# +CREATE TABLE t1 (t0 TIME, t6 TIME(6), i INT, d DECIMAL(20,6), f DOUBLE); +INSERT INTO t1 (t0) VALUES ('11:22:33'); +UPDATE t1 SET t6=t0, i=t0, d=t0, f=t0; +SELECT * FROM t1; +t0 t6 i d f +11:22:33 11:22:33.000000 112233 112233.000000 112233 +UPDATE t1 SET t6='11:22:33.123'; +UPDATE t1 SET t0=t6, i=t6, d=t6, f=t6; +SELECT * FROM t1; +t0 t6 i d f +11:22:33 11:22:33.123000 112233 112233.123000 112233.123 +UPDATE t1 SET i=112233, d=112233.123, f=112233.123; +UPDATE t1 SET t6=i; +SELECT t6 FROM t1; +t6 +11:22:33.000000 +UPDATE t1 SET t6=d; +SELECT t6 FROM t1; +t6 +11:22:33.123000 +UPDATE t1 SET t6=f; +SELECT t6 FROM t1; +t6 +11:22:33.123000 +DROP TABLE t1; +# +# Testing JOIN with comparison between TIME(6) and INT +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('11:22:33'); +INSERT INTO t1 VALUES ('11:22:33.123'); +INSERT INTO t1 VALUES ('-11:22:33'); +INSERT INTO t1 VALUES ('-11:22:33.123456'); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (112233); +INSERT INTO t2 VALUES (-112233); +SELECT * FROM t1, t2 WHERE a=b; +a b +11:22:33.000000 112233 +-11:22:33.000000 -112233 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIME(6) and DECIMAL(20,6) +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('11:22:33'); +INSERT INTO t1 VALUES ('11:22:33.123'); +INSERT INTO t1 VALUES ('-11:22:33'); +INSERT INTO t1 VALUES ('-11:22:33.123456'); +CREATE TABLE t2 (b DECIMAL(20,6)); +INSERT INTO t2 VALUES (112233.123); +INSERT INTO t2 VALUES (-112233.123456); +SELECT * FROM t1, t2 WHERE a=b; +a b +11:22:33.123000 112233.123000 +-11:22:33.123456 -112233.123456 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIME(6) and DECIMAL(20,3) +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('11:22:33'); +INSERT INTO t1 VALUES ('11:22:33.123'); +INSERT INTO t1 VALUES ('-11:22:33'); +INSERT INTO t1 VALUES ('-11:22:33.123456'); +CREATE TABLE t2 (b DECIMAL(20,3)); +INSERT INTO t2 VALUES (112233.123); +INSERT INTO t2 VALUES (-112233.123456); +Warnings: +Note 1265 Data truncated for column 'b' at row 1 +SELECT * FROM t1, t2 WHERE a=b; +a b +11:22:33.123000 112233.123 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIME(6) and DOUBLE +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('11:22:33'); +INSERT INTO t1 VALUES ('11:22:33.123'); +INSERT INTO t1 VALUES ('-11:22:33'); +INSERT INTO t1 VALUES ('-11:22:33.123456'); +CREATE TABLE t2 (b DOUBLE); +INSERT INTO t2 VALUES (112233.123); +INSERT INTO t2 VALUES (-112233.123456); +SELECT * FROM t1, t2 WHERE a=b; +a b +11:22:33.123000 112233.123 +-11:22:33.123456 -112233.123456 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIME(6) and VARCHAR +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('11:22:33'); +INSERT INTO t1 VALUES ('11:22:33.123'); +INSERT INTO t1 VALUES ('-11:22:33'); +INSERT INTO t1 VALUES ('-11:22:33.123456'); +CREATE TABLE t2 (b VARCHAR(20)); +INSERT INTO t2 VALUES ('11:22:33.123'); +INSERT INTO t2 VALUES ('-11:22:33.123456'); +SELECT * FROM t1, t2 WHERE a=b; +a b +-11:22:33.123456 -11:22:33.123456 +DROP TABLE t1, t2; +# +# Testing arithmetic with INT, DECIMAL, FLOAT +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-00:00:00.000001'); +INSERT INTO t1 VALUES ('00:00:00.000000'); +INSERT INTO t1 VALUES ('00:00:00.000001'); +SELECT a, a + 0, a + 1, a + 1.0, a + 1e0 FROM t1; +a a + 0 a + 1 a + 1.0 a + 1e0 +-00:00:00.000001 -0.000001 0.999999 0.999999 0.999999 +00:00:00.000000 0.000000 1.000000 1.000000 1 +00:00:00.000001 0.000001 1.000001 1.000001 1.000001 +CREATE TABLE t2 AS SELECT a + 1 AS i, a + 1.0 AS d, a + 1e0 AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` decimal(14,6) DEFAULT NULL, + `d` decimal(14,6) DEFAULT NULL, + `f` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Testing that TIME behaves as INT/DECIMAL for numeric arithmetic +# +CREATE TABLE t1 (t0 TIME, t3 TIME(3), t6 TIME(6)); +CREATE TABLE t2 AS SELECT +t0 + 1, t3 + 1, t6 + 1, +t0 - 1, t3 - 1, t6 - 1, +t0 * 1, t3 * 1, t6 * 1, +t0 / 1, t3 / 1, t6 / 1, +TIME'10:10:10' + 1, +TIME'10:10:10.123' + 1, +TIME'10:10:10.123456' + 1, +TIME'10:10:10' - 1, +TIME'10:10:10.123' - 1, +TIME'10:10:10.123456' - 1, +TIME'10:10:10' * 1, +TIME'10:10:10.123' * 1, +TIME'10:10:10.123456' * 1, +TIME'10:10:10' / 1, +TIME'10:10:10.123' / 1, +TIME'10:10:10.123456' / 1 +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t0 + 1` int DEFAULT NULL, + `t3 + 1` decimal(11,3) DEFAULT NULL, + `t6 + 1` decimal(14,6) DEFAULT NULL, + `t0 - 1` int DEFAULT NULL, + `t3 - 1` decimal(11,3) DEFAULT NULL, + `t6 - 1` decimal(14,6) DEFAULT NULL, + `t0 * 1` int DEFAULT NULL, + `t3 * 1` decimal(11,3) DEFAULT NULL, + `t6 * 1` decimal(14,6) DEFAULT NULL, + `t0 / 1` decimal(11,4) DEFAULT NULL, + `t3 / 1` decimal(14,7) DEFAULT NULL, + `t6 / 1` decimal(17,10) DEFAULT NULL, + `TIME'10:10:10' + 1` int NOT NULL DEFAULT '0', + `TIME'10:10:10.123' + 1` decimal(11,3) NOT NULL DEFAULT '0.000', + `TIME'10:10:10.123456' + 1` decimal(14,6) NOT NULL DEFAULT '0.000000', + `TIME'10:10:10' - 1` int NOT NULL DEFAULT '0', + `TIME'10:10:10.123' - 1` decimal(11,3) NOT NULL DEFAULT '0.000', + `TIME'10:10:10.123456' - 1` decimal(14,6) NOT NULL DEFAULT '0.000000', + `TIME'10:10:10' * 1` int NOT NULL DEFAULT '0', + `TIME'10:10:10.123' * 1` decimal(11,3) NOT NULL DEFAULT '0.000', + `TIME'10:10:10.123456' * 1` decimal(14,6) NOT NULL DEFAULT '0.000000', + `TIME'10:10:10' / 1` decimal(11,4) DEFAULT NULL, + `TIME'10:10:10.123' / 1` decimal(14,7) DEFAULT NULL, + `TIME'10:10:10.123456' / 1` decimal(17,10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing that TIME behaves as DECIMAL for SUM() and AVG() +# +SET @t='800:11:12.123456'; +CREATE TABLE t1 (t0 TIME, t3 TIME(3), t6 TIME(6)); +INSERT INTO t1 VALUES (@t, @t, @t); +SELECT MIN(t0), MAX(t0), AVG(t0), SUM(t0) FROM t1; +MIN(t0) 800:11:12 +MAX(t0) 800:11:12 +AVG(t0) 8001112.0000 +SUM(t0) 8001112 +SELECT MIN(t3), MAX(t3), AVG(t3), SUM(t3) FROM t1; +MIN(t3) 800:11:12.123 +MAX(t3) 800:11:12.123 +AVG(t3) 8001112.1230000 +SUM(t3) 8001112.123 +SELECT MIN(t6), MAX(t6), AVG(t6), SUM(t6) FROM t1; +MIN(t6) 800:11:12.123456 +MAX(t6) 800:11:12.123456 +AVG(t6) 8001112.1234560000 +SUM(t6) 8001112.123456 +SET @t='800:11:12.000000'; +INSERT INTO t1 VALUES (@t, @t, @t); +SELECT MIN(t0), MAX(t0), AVG(t0), SUM(t0) FROM t1; +MIN(t0) 800:11:12 +MAX(t0) 800:11:12 +AVG(t0) 8001112.0000 +SUM(t0) 16002224 +SELECT MIN(t3), MAX(t3), AVG(t3), SUM(t3) FROM t1; +MIN(t3) 800:11:12.000 +MAX(t3) 800:11:12.123 +AVG(t3) 8001112.0615000 +SUM(t3) 16002224.123 +SELECT MIN(t6), MAX(t6), AVG(t6), SUM(t6) FROM t1; +MIN(t6) 800:11:12.000000 +MAX(t6) 800:11:12.123456 +AVG(t6) 8001112.0617280000 +SUM(t6) 16002224.123456 +CREATE TABLE t2 AS SELECT +MIN(t0), MAX(t0), AVG(t0), SUM(t0), +MIN(t3), MAX(t3), AVG(t3), SUM(t3), +MIN(t6), MAX(t6), AVG(t6), SUM(t6) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MIN(t0)` time DEFAULT NULL, + `MAX(t0)` time DEFAULT NULL, + `AVG(t0)` decimal(11,4) DEFAULT NULL, + `SUM(t0)` decimal(29,0) DEFAULT NULL, + `MIN(t3)` time(3) DEFAULT NULL, + `MAX(t3)` time(3) DEFAULT NULL, + `AVG(t3)` decimal(14,7) DEFAULT NULL, + `SUM(t3)` decimal(32,3) DEFAULT NULL, + `MIN(t6)` time(6) DEFAULT NULL, + `MAX(t6)` time(6) DEFAULT NULL, + `AVG(t6)` decimal(17,10) DEFAULT NULL, + `SUM(t6)` decimal(35,6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing functions ADDTIME, SUBTIME, TIMEDIFF +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-01:00:00.000001'); +INSERT INTO t1 VALUES ('-01:00:00.000000'); +INSERT INTO t1 VALUES ('-00:00:00.000001'); +INSERT INTO t1 VALUES ('00:00:00.000000'); +INSERT INTO t1 VALUES ('00:00:00.000001'); +INSERT INTO t1 VALUES ('01:00:00.000000'); +INSERT INTO t1 VALUES ('01:00:00.000001'); +SELECT ADDTIME(a, '00:00:00.000001') FROM t1; +ADDTIME(a, '00:00:00.000001') +-01:00:00.000000 +-00:59:59.999999 +00:00:00.000000 +00:00:00.000001 +00:00:00.000002 +01:00:00.000001 +01:00:00.000002 +SELECT ADDTIME(a, '10:00:00.000001') FROM t1; +ADDTIME(a, '10:00:00.000001') +09:00:00.000000 +09:00:00.000001 +10:00:00.000000 +10:00:00.000001 +10:00:00.000002 +11:00:00.000001 +11:00:00.000002 +SELECT ADDTIME(a, a) FROM t1; +ADDTIME(a, a) +-02:00:00.000002 +-02:00:00.000000 +-00:00:00.000002 +00:00:00.000000 +00:00:00.000002 +02:00:00.000000 +02:00:00.000002 +SELECT SUBTIME(a, '00:00:00.000001') FROM t1; +SUBTIME(a, '00:00:00.000001') +-01:00:00.000002 +-01:00:00.000001 +-00:00:00.000002 +-00:00:00.000001 +00:00:00.000000 +00:59:59.999999 +01:00:00.000000 +SELECT SUBTIME(a, '10:00:00.000001') FROM t1; +SUBTIME(a, '10:00:00.000001') +-11:00:00.000002 +-11:00:00.000001 +-10:00:00.000002 +-10:00:00.000001 +-10:00:00.000000 +-09:00:00.000001 +-09:00:00.000000 +SELECT SUBTIME(a, a) FROM t1; +SUBTIME(a, a) +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +SELECT TIMEDIFF(a, '00:00:00.000001') FROM t1; +TIMEDIFF(a, '00:00:00.000001') +-01:00:00.000002 +-01:00:00.000001 +-00:00:00.000002 +-00:00:00.000001 +00:00:00.000000 +00:59:59.999999 +01:00:00.000000 +SELECT TIMEDIFF('00:00:00.000001', a) FROM t1; +TIMEDIFF('00:00:00.000001', a) +01:00:00.000002 +01:00:00.000001 +00:00:00.000002 +00:00:00.000001 +00:00:00.000000 +-00:59:59.999999 +-01:00:00.000000 +SELECT TIMEDIFF(a, a) FROM t1; +TIMEDIFF(a, a) +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +00:00:00.000000 +SELECT TIMEDIFF(CAST(a AS TIME(0)), CAST('10:10:10' AS TIME(0))) FROM t1; +TIMEDIFF(CAST(a AS TIME(0)), CAST('10:10:10' AS TIME(0))) +-11:10:10 +-11:10:10 +-10:10:10 +-10:10:10 +-10:10:10 +-09:10:10 +-09:10:10 +CREATE TABLE t2 AS SELECT +ADDTIME(a, '00:00:00.000001'), +ADDTIME(a,a), +SUBTIME(a, '00:00:00.000001'), +SUBTIME(a,a), +TIMEDIFF(a,'00:00:00.000001'), +TIMEDIFF(a,a), +TIMEDIFF(CAST(a AS TIME(0)), CAST('10:10:10' AS TIME(0))) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ADDTIME(a, '00:00:00.000001')` time(6) DEFAULT NULL, + `ADDTIME(a,a)` time(6) DEFAULT NULL, + `SUBTIME(a, '00:00:00.000001')` time(6) DEFAULT NULL, + `SUBTIME(a,a)` time(6) DEFAULT NULL, + `TIMEDIFF(a,'00:00:00.000001')` time(6) DEFAULT NULL, + `TIMEDIFF(a,a)` time(6) DEFAULT NULL, + `TIMEDIFF(CAST(a AS TIME(0)), CAST('10:10:10' AS TIME(0)))` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT MAX(ADDTIME(a, '00:00:00.1')) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MAX(ADDTIME(a, '00:00:00.1'))` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2; +MAX(ADDTIME(a, '00:00:00.1')) +01:00:00.100001 +DROP TABLE t2; +DROP TABLE t1; +SELECT TIMEDIFF(TIME'00:00:00', TIME'00:00:00'); +TIMEDIFF(TIME'00:00:00', TIME'00:00:00') +00:00:00 +SELECT TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0'); +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0') +00:00:00.0 +SELECT TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00'); +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00') +00:00:00.00 +SELECT TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000'); +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000') +00:00:00.000 +SELECT TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0000'); +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0000') +00:00:00.0000 +SELECT TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00000'); +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00000') +00:00:00.00000 +SELECT TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000000'); +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000000') +00:00:00.000000 +SELECT TIMEDIFF(TIME'00:00:00.0', TIME'00:00:00'); +TIMEDIFF(TIME'00:00:00.0', TIME'00:00:00') +00:00:00.0 +SELECT TIMEDIFF(TIME'00:00:00.00', TIME'00:00:00'); +TIMEDIFF(TIME'00:00:00.00', TIME'00:00:00') +00:00:00.00 +SELECT TIMEDIFF(TIME'00:00:00.000', TIME'00:00:00'); +TIMEDIFF(TIME'00:00:00.000', TIME'00:00:00') +00:00:00.000 +SELECT TIMEDIFF(TIME'00:00:00.0000', TIME'00:00:00'); +TIMEDIFF(TIME'00:00:00.0000', TIME'00:00:00') +00:00:00.0000 +SELECT TIMEDIFF(TIME'00:00:00.00000', TIME'00:00:00'); +TIMEDIFF(TIME'00:00:00.00000', TIME'00:00:00') +00:00:00.00000 +SELECT TIMEDIFF(TIME'00:00:00.000000', TIME'00:00:00'); +TIMEDIFF(TIME'00:00:00.000000', TIME'00:00:00') +00:00:00.000000 +CREATE TABLE t1 AS SELECT +TIMEDIFF(TIME'00:00:00', TIME'00:00:00'), +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0'), +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00'), +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000'), +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0000'), +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00000'), +TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000000'), +TIMEDIFF(TIME'00:00:00.0', TIME'00:00:00'), +TIMEDIFF(TIME'00:00:00.00', TIME'00:00:00'), +TIMEDIFF(TIME'00:00:00.000', TIME'00:00:00'), +TIMEDIFF(TIME'00:00:00.0000', TIME'00:00:00'), +TIMEDIFF(TIME'00:00:00.00000', TIME'00:00:00'), +TIMEDIFF(TIME'00:00:00.000000', TIME'00:00:00'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `TIMEDIFF(TIME'00:00:00', TIME'00:00:00')` time DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0')` time(1) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00')` time(2) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000')` time(3) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00', TIME'00:00:00.0000')` time(4) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00', TIME'00:00:00.00000')` time(5) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00', TIME'00:00:00.000000')` time(6) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00.0', TIME'00:00:00')` time(1) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00.00', TIME'00:00:00')` time(2) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00.000', TIME'00:00:00')` time(3) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00.0000', TIME'00:00:00')` time(4) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00.00000', TIME'00:00:00')` time(5) DEFAULT NULL, + `TIMEDIFF(TIME'00:00:00.000000', TIME'00:00:00')` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SELECT ADDTIME(TIME'00:00:00', TIME'00:00:00'); +ADDTIME(TIME'00:00:00', TIME'00:00:00') +00:00:00 +SELECT ADDTIME(TIME'00:00:00', TIME'00:00:00.0'); +ADDTIME(TIME'00:00:00', TIME'00:00:00.0') +00:00:00.0 +SELECT ADDTIME(TIME'00:00:00', TIME'00:00:00.00'); +ADDTIME(TIME'00:00:00', TIME'00:00:00.00') +00:00:00.00 +SELECT ADDTIME(TIME'00:00:00', TIME'00:00:00.000'); +ADDTIME(TIME'00:00:00', TIME'00:00:00.000') +00:00:00.000 +SELECT ADDTIME(TIME'00:00:00', TIME'00:00:00.0000'); +ADDTIME(TIME'00:00:00', TIME'00:00:00.0000') +00:00:00.0000 +SELECT ADDTIME(TIME'00:00:00', TIME'00:00:00.00000'); +ADDTIME(TIME'00:00:00', TIME'00:00:00.00000') +00:00:00.00000 +SELECT ADDTIME(TIME'00:00:00', TIME'00:00:00.000000'); +ADDTIME(TIME'00:00:00', TIME'00:00:00.000000') +00:00:00.000000 +SELECT ADDTIME(TIME'00:00:00.0', TIME'00:00:00'); +ADDTIME(TIME'00:00:00.0', TIME'00:00:00') +00:00:00.0 +SELECT ADDTIME(TIME'00:00:00.00', TIME'00:00:00'); +ADDTIME(TIME'00:00:00.00', TIME'00:00:00') +00:00:00.00 +SELECT ADDTIME(TIME'00:00:00.000', TIME'00:00:00'); +ADDTIME(TIME'00:00:00.000', TIME'00:00:00') +00:00:00.000 +SELECT ADDTIME(TIME'00:00:00.0000', TIME'00:00:00'); +ADDTIME(TIME'00:00:00.0000', TIME'00:00:00') +00:00:00.0000 +SELECT ADDTIME(TIME'00:00:00.00000', TIME'00:00:00'); +ADDTIME(TIME'00:00:00.00000', TIME'00:00:00') +00:00:00.00000 +SELECT ADDTIME(TIME'00:00:00.000000', TIME'00:00:00'); +ADDTIME(TIME'00:00:00.000000', TIME'00:00:00') +00:00:00.000000 +SELECT SUBTIME(TIME'00:00:00', TIME'00:00:00'); +SUBTIME(TIME'00:00:00', TIME'00:00:00') +00:00:00 +SELECT SUBTIME(TIME'00:00:00', TIME'00:00:00.0'); +SUBTIME(TIME'00:00:00', TIME'00:00:00.0') +00:00:00.0 +SELECT SUBTIME(TIME'00:00:00', TIME'00:00:00.00'); +SUBTIME(TIME'00:00:00', TIME'00:00:00.00') +00:00:00.00 +SELECT SUBTIME(TIME'00:00:00', TIME'00:00:00.000'); +SUBTIME(TIME'00:00:00', TIME'00:00:00.000') +00:00:00.000 +SELECT SUBTIME(TIME'00:00:00', TIME'00:00:00.0000'); +SUBTIME(TIME'00:00:00', TIME'00:00:00.0000') +00:00:00.0000 +SELECT SUBTIME(TIME'00:00:00', TIME'00:00:00.00000'); +SUBTIME(TIME'00:00:00', TIME'00:00:00.00000') +00:00:00.00000 +SELECT SUBTIME(TIME'00:00:00', TIME'00:00:00.000000'); +SUBTIME(TIME'00:00:00', TIME'00:00:00.000000') +00:00:00.000000 +SELECT SUBTIME(TIME'00:00:00.0', TIME'00:00:00'); +SUBTIME(TIME'00:00:00.0', TIME'00:00:00') +00:00:00.0 +SELECT SUBTIME(TIME'00:00:00.00', TIME'00:00:00'); +SUBTIME(TIME'00:00:00.00', TIME'00:00:00') +00:00:00.00 +SELECT SUBTIME(TIME'00:00:00.000', TIME'00:00:00'); +SUBTIME(TIME'00:00:00.000', TIME'00:00:00') +00:00:00.000 +SELECT SUBTIME(TIME'00:00:00.0000', TIME'00:00:00'); +SUBTIME(TIME'00:00:00.0000', TIME'00:00:00') +00:00:00.0000 +SELECT SUBTIME(TIME'00:00:00.00000', TIME'00:00:00'); +SUBTIME(TIME'00:00:00.00000', TIME'00:00:00') +00:00:00.00000 +SELECT SUBTIME(TIME'00:00:00.000000', TIME'00:00:00'); +SUBTIME(TIME'00:00:00.000000', TIME'00:00:00') +00:00:00.000000 +# +# Testing TIME + INTERVAL +# +SELECT CAST('00:00:00' AS TIME) + INTERVAL 2000 HOUR; +CAST('00:00:00' AS TIME) + INTERVAL 2000 HOUR +NULL +Warnings: +Warning 1441 Datetime function: time field overflow +SELECT CAST('00:00:00' AS TIME) + INTERVAL 34 DAY; +CAST('00:00:00' AS TIME) + INTERVAL 34 DAY +816:00:00 +SELECT CAST('00:00:00' AS TIME) + INTERVAL 35 DAY; +CAST('00:00:00' AS TIME) + INTERVAL 35 DAY +NULL +Warnings: +Warning 1441 Datetime function: time field overflow +SELECT CAST('00:00:00' AS TIME) + INTERVAL 1 MONTH; +CAST('00:00:00' AS TIME) + INTERVAL 1 MONTH +NULL +Warnings: +Warning 1441 Datetime function: time field overflow +SELECT CAST('00:00:00' AS TIME) + INTERVAL 1 YEAR; +CAST('00:00:00' AS TIME) + INTERVAL 1 YEAR +NULL +Warnings: +Warning 1441 Datetime function: time field overflow +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +SELECT CAST(CAST('00:00:00.123456' AS TIME(6)) + INTERVAL 1 DAY AS DATETIME(6)); +CAST(CAST('00:00:00.123456' AS TIME(6)) + INTERVAL 1 DAY AS DATETIME(6)) +2001-01-02 00:00:00.123456 +SET @@timestamp=default; +SELECT CAST(CAST('2001-01-01 00:00:00.123456' AS DATETIME(6)) + INTERVAL 30 HOUR AS TIME(6)); +CAST(CAST('2001-01-01 00:00:00.123456' AS DATETIME(6)) + INTERVAL 30 HOUR AS TIME(6)) +06:00:00.123456 +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-10:00:00.1'), ('00:00:00.1'), ('10:00:00.1'); +SELECT a, a + INTERVAL 1 HOUR, a - INTERVAL 1 HOUR FROM t1; +a a + INTERVAL 1 HOUR a - INTERVAL 1 HOUR +-10:00:00.100000 -09:00:00.100000 -11:00:00.100000 +00:00:00.100000 01:00:00.100000 -00:59:59.900000 +10:00:00.100000 11:00:00.100000 09:00:00.100000 +SELECT a, a + INTERVAL 1 SECOND, a - INTERVAL 1 SECOND FROM t1; +a a + INTERVAL 1 SECOND a - INTERVAL 1 SECOND +-10:00:00.100000 -09:59:59.100000 -10:00:01.100000 +00:00:00.100000 00:00:01.100000 -00:00:00.900000 +10:00:00.100000 10:00:01.100000 09:59:59.100000 +SELECT a, a + INTERVAL 1.1 SECOND, a - INTERVAL 1.1 SECOND FROM t1; +a a + INTERVAL 1.1 SECOND a - INTERVAL 1.1 SECOND +-10:00:00.100000 -09:59:59.000000 -10:00:01.200000 +00:00:00.100000 00:00:01.200000 -00:00:01.000000 +10:00:00.100000 10:00:01.200000 09:59:59.000000 +CREATE TABLE t2 AS SELECT +a + INTERVAL 1 HOUR, +a - INTERVAL 1 HOUR, +a + INTERVAL 1 SECOND, +a - INTERVAL 1 SECOND, +a + INTERVAL 1.1 SECOND, +a - INTERVAL 1.1 SECOND +FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +a + INTERVAL 1 HOUR time(6) YES NULL +a - INTERVAL 1 HOUR time(6) YES NULL +a + INTERVAL 1 SECOND time(6) YES NULL +a - INTERVAL 1 SECOND time(6) YES NULL +a + INTERVAL 1.1 SECOND time(6) YES NULL +a - INTERVAL 1.1 SECOND time(6) YES NULL +DROP TABLE t2; +ALTER TABLE t1 MODIFY a TIME; +SELECT a, a + INTERVAL 1 HOUR, a - INTERVAL 1 HOUR FROM t1; +a a + INTERVAL 1 HOUR a - INTERVAL 1 HOUR +-10:00:00 -09:00:00 -11:00:00 +00:00:00 01:00:00 -01:00:00 +10:00:00 11:00:00 09:00:00 +SELECT a, a + INTERVAL 1 SECOND, a - INTERVAL 1 SECOND FROM t1; +a a + INTERVAL 1 SECOND a - INTERVAL 1 SECOND +-10:00:00 -09:59:59 -10:00:01 +00:00:00 00:00:01 -00:00:01 +10:00:00 10:00:01 09:59:59 +SELECT a, a + INTERVAL 1.1 SECOND, a - INTERVAL 1.1 SECOND FROM t1; +a a + INTERVAL 1.1 SECOND a - INTERVAL 1.1 SECOND +-10:00:00 -09:59:58.9 -10:00:01.1 +00:00:00 00:00:01.1 -00:00:01.1 +10:00:00 10:00:01.1 09:59:58.9 +CREATE TABLE t2 AS SELECT +a + INTERVAL 1 HOUR, +a - INTERVAL 1 HOUR, +a + INTERVAL 1 SECOND, +a - INTERVAL 1 SECOND, +a + INTERVAL 1.1 SECOND, +a - INTERVAL 1.1 SECOND +FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +a + INTERVAL 1 HOUR time YES NULL +a - INTERVAL 1 HOUR time YES NULL +a + INTERVAL 1 SECOND time YES NULL +a - INTERVAL 1 SECOND time YES NULL +a + INTERVAL 1.1 SECOND time(1) YES NULL +a - INTERVAL 1.1 SECOND time(1) YES NULL +DROP TABLE t2; +DROP TABLE t1; +# +# Testing SEC_TO_TIME +# +CREATE TABLE t1 AS SELECT SEC_TO_TIME(3661), CAST(SEC_TO_TIME(3661) AS CHAR); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `SEC_TO_TIME(3661)` time DEFAULT NULL, + `CAST(SEC_TO_TIME(3661) AS CHAR)` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +SEC_TO_TIME(3661) CAST(SEC_TO_TIME(3661) AS CHAR) +01:01:01 01:01:01 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +SEC_TO_TIME(3661.1), +SEC_TO_TIME(3661.11), +SEC_TO_TIME(3661.111), +SEC_TO_TIME(3661.1111), +SEC_TO_TIME(3661.11111), +SEC_TO_TIME(3661.111111), +SEC_TO_TIME(3661.1111111); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `SEC_TO_TIME(3661.1)` time(1) DEFAULT NULL, + `SEC_TO_TIME(3661.11)` time(2) DEFAULT NULL, + `SEC_TO_TIME(3661.111)` time(3) DEFAULT NULL, + `SEC_TO_TIME(3661.1111)` time(4) DEFAULT NULL, + `SEC_TO_TIME(3661.11111)` time(5) DEFAULT NULL, + `SEC_TO_TIME(3661.111111)` time(6) DEFAULT NULL, + `SEC_TO_TIME(3661.1111111)` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +SEC_TO_TIME(3661.1) SEC_TO_TIME(3661.11) SEC_TO_TIME(3661.111) SEC_TO_TIME(3661.1111) SEC_TO_TIME(3661.11111) SEC_TO_TIME(3661.111111) SEC_TO_TIME(3661.1111111) +01:01:01.1 01:01:01.11 01:01:01.111 01:01:01.1111 01:01:01.11111 01:01:01.111111 01:01:01.111111 +DROP TABLE t1; +# +# Testing copy from TIME to TIME(6) and vice versa +# +CREATE TABLE t1 (a TIME(6), b TIME); +INSERT INTO t1 VALUES ('01:02:03.123456', '00:00:00'); +UPDATE t1 SET b=a; +SELECT * FROM t1; +a b +01:02:03.123456 01:02:03 +UPDATE t1 SET b='10:11:12'; +UPDATE t1 SET a=b; +SELECT * FROM t1; +a b +10:11:12.000000 10:11:12 +DROP TABLE t1; +# +# Testing ALTER from TIME(6) to TIME and vice versa +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('01:02:03'); +ALTER TABLE t1 MODIFY a TIME(6); +SELECT * FROM t1; +a +01:02:03.000000 +UPDATE t1 SET a='01:03:03.456'; +SELECT * FROM t1; +a +01:03:03.456000 +ALTER TABLE t1 MODIFY a TIME; +SELECT * FROM t1; +a +01:03:03 +DROP TABLE t1; +# +# Testing ALTER between TIME and INT +# +CREATE TABLE t1 (a TIME, b TIME(6)); +INSERT INTO t1 VALUES ('11:22:33', '11:22:33'); +ALTER TABLE t1 MODIFY a INT, MODIFY b INT; +SELECT * FROM t1; +a b +112233 112233 +UPDATE t1 SET a=112233, b=112233; +ALTER TABLE t1 MODIFY a TIME, MODIFY b TIME(6); +SELECT * FROM t1; +a b +11:22:33 11:22:33.000000 +DROP TABLE t1; +# +# Testing ALTER between TIME and DOUBLE +# +CREATE TABLE t1 (a TIME, b TIME(6)); +INSERT INTO t1 VALUES ('11:22:33', '11:22:33.1234'); +ALTER TABLE t1 MODIFY a DOUBLE, MODIFY b DOUBLE; +SELECT * FROM t1; +a b +112233 112233.1234 +UPDATE t1 SET a=112233, b=112233.1234; +ALTER TABLE t1 MODIFY a TIME, MODIFY b TIME(6); +SELECT * FROM t1; +a b +11:22:33 11:22:33.123400 +DROP TABLE t1; +# +# Testing ALTER between TIME and DECIMAL +# +CREATE TABLE t1 (a TIME, b TIME(6)); +INSERT INTO t1 VALUES ('11:22:33', '11:22:33.1234'); +ALTER TABLE t1 MODIFY a DECIMAL(20,6), MODIFY b DECIMAL(20,6); +SELECT * FROM t1; +a b +112233.000000 112233.123400 +UPDATE t1 SET a=112233, b=112233.1234; +ALTER TABLE t1 MODIFY a TIME, MODIFY b TIME(6); +SELECT * FROM t1; +a b +11:22:33 11:22:33.123400 +DROP TABLE t1; +# +# Testing ALTER from TIME to various other temporal types +# +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a TIME(6), b TIME(6), c TIME(6)); +INSERT INTO t1 VALUES ('10:10:10.1', '10:10:10.1', '10:10:10.1'); +INSERT INTO t1 VALUES ('34:10:10.1', '34:10:10.1', '34:10:10.1'); +ALTER TABLE t1 MODIFY a DATETIME(6), MODIFY b TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), MODIFY c DATE; +Warnings: +Note 1292 Incorrect date value: '10:10:10' for column 'c' at row 1 +Note 1292 Incorrect date value: '34:10:10' for column 'c' at row 2 +SELECT * FROM t1; +a b c +2001-01-01 10:10:10.100000 2001-01-01 10:10:10.100000 2001-01-01 +2001-01-02 10:10:10.100000 2001-01-02 10:10:10.100000 2001-01-02 +DROP TABLE t1; +SET @@timestamp=default; +# +# Testing UPDATE from TIME to various other temporal types +# +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (t6 TIME(6), d DATE, ts6 TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), dt6 DATETIME(6)); +INSERT INTO t1 (t6) VALUES ('10:10:10.1'), ('34:10:10.1'); +UPDATE t1 SET d=t6, ts6=t6, dt6=t6; +Warnings: +Note 1292 Incorrect date value: '10:10:10' for column 'd' at row 1 +Note 1292 Incorrect date value: '34:10:10' for column 'd' at row 2 +SELECT * FROM t1; +t6 d ts6 dt6 +10:10:10.100000 2001-01-01 2001-01-01 10:10:10.100000 2001-01-01 10:10:10.100000 +34:10:10.100000 2001-01-02 2001-01-02 10:10:10.100000 2001-01-02 10:10:10.100000 +DROP TABLE t1; +SET @@timestamp=default; +# +# Testing EXPLAIN SELECT for CAST(TIME(N)) +# +EXPLAIN SELECT CAST('10:10:10' AS TIME); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time) AS `CAST('10:10:10' AS TIME)` +EXPLAIN SELECT CAST('10:10:10' AS TIME(0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time) AS `CAST('10:10:10' AS TIME(0))` +EXPLAIN SELECT CAST('10:10:10' AS TIME(1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time(1)) AS `CAST('10:10:10' AS TIME(1))` +EXPLAIN SELECT CAST('10:10:10' AS TIME(2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time(2)) AS `CAST('10:10:10' AS TIME(2))` +EXPLAIN SELECT CAST('10:10:10' AS TIME(3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time(3)) AS `CAST('10:10:10' AS TIME(3))` +EXPLAIN SELECT CAST('10:10:10' AS TIME(4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time(4)) AS `CAST('10:10:10' AS TIME(4))` +EXPLAIN SELECT CAST('10:10:10' AS TIME(5)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time(5)) AS `CAST('10:10:10' AS TIME(5))` +EXPLAIN SELECT CAST('10:10:10' AS TIME(6)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as time(6)) AS `CAST('10:10:10' AS TIME(6))` +# +# Testing CAST with bad FSPs +# +SELECT CAST(1 AS TIME(-1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1 +SELECT CAST(1 AS TIME(7)); +ERROR 42000: Too-big precision 7 specified for 'CAST'. Maximum is 6. +SELECT CAST(1 AS TIME(31)); +ERROR 42000: Too-big precision 31 specified for 'CAST'. Maximum is 6. +# +# Testing conversion from TIME(6) to INT +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('10:10:58.499'); +INSERT INTO t1 VALUES ('10:10:58.999'); +INSERT INTO t1 VALUES ('10:10:59.499'); +INSERT INTO t1 VALUES ('10:10:59.999'); +INSERT INTO t1 VALUES ('-10:10:58.499'); +INSERT INTO t1 VALUES ('-10:10:58.999'); +INSERT INTO t1 VALUES ('-10:10:59.499'); +INSERT INTO t1 VALUES ('-10:10:59.999'); +ALTER TABLE t1 ADD b BIGINT, ADD c TIME(6); +UPDATE t1 SET b=a, c=a; +ALTER TABLE t1 MODIFY c BIGINT; +SELECT a, CAST(a AS SIGNED), b, c FROM t1; +a CAST(a AS SIGNED) b c +10:10:58.499000 101058 101058 101058 +10:10:58.999000 101059 101059 101059 +10:10:59.499000 101059 101059 101059 +10:10:59.999000 101100 101100 101100 +-10:10:58.499000 -101058 -101058 -101058 +-10:10:58.999000 -101059 -101059 -101059 +-10:10:59.499000 -101059 -101059 -101059 +-10:10:59.999000 -101100 -101100 -101100 +DROP TABLE t1; +# +# Testing INT value and CAST of TIME(6) to various other types +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('11:22:33.123'); +INSERT INTO t1 VALUES ('11:22:33.999'); +INSERT INTO t1 VALUES ('-11:22:33.123'); +INSERT INTO t1 VALUES ('-11:22:33.999'); +INSERT INTO t1 VALUES ('-836:56:56.999999'); +SELECT a << 0 FROM t1; +a << 0 +112233 +112234 +18446744073709439383 +18446744073709439382 +18446744073701185959 +SELECT CAST(a AS SIGNED) FROM t1; +CAST(a AS SIGNED) +112233 +112234 +-112233 +-112234 +-8365657 +SELECT CAST(a AS UNSIGNED) FROM t1; +CAST(a AS UNSIGNED) +112233 +112234 +18446744073709439383 +18446744073709439382 +18446744073701185959 +SELECT CAST(a AS DECIMAL(20,6)) FROM t1; +CAST(a AS DECIMAL(20,6)) +112233.123000 +112233.999000 +-112233.123000 +-112233.999000 +-8365656.999999 +SELECT CAST(a AS DECIMAL(20,3)) FROM t1; +CAST(a AS DECIMAL(20,3)) +112233.123 +112233.999 +-112233.123 +-112233.999 +-8365657.000 +SELECT CAST(a AS CHAR) FROM t1; +CAST(a AS CHAR) +11:22:33.123000 +11:22:33.999000 +-11:22:33.123000 +-11:22:33.999000 +-836:56:56.999999 +SELECT CAST(a AS CHAR(6)) FROM t1; +CAST(a AS CHAR(6)) +11:22: +11:22: +-11:22 +-11:22 +-836:5 +Warnings: +Warning 1292 Truncated incorrect CHAR(6) value: '11:22:33.123000' +Warning 1292 Truncated incorrect CHAR(6) value: '11:22:33.999000' +Warning 1292 Truncated incorrect CHAR(6) value: '-11:22:33.123000' +Warning 1292 Truncated incorrect CHAR(6) value: '-11:22:33.999000' +Warning 1292 Truncated incorrect CHAR(6) value: '-836:56:56.999999' +CREATE TABLE t2 AS SELECT CAST(a AS CHAR) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(17) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT a, LENGTH(a) FROM t2; +a LENGTH(a) +11:22:33.123000 15 +11:22:33.999000 15 +-11:22:33.123000 16 +-11:22:33.999000 16 +-836:56:56.999999 17 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing DEFAULT value +# +CREATE TABLE t1 (a TIME(6) NOT NULL DEFAULT '11:22:33.123456'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time(6) NOT NULL DEFAULT '11:22:33.123456' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Mixing TIME(6) with another TIME(6) in IF +# +CREATE TABLE t1 (a TIME(6), b TIME(6)); +CREATE TABLE t2 AS SELECT IF(1, a, b) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing TIME(N) with TIME(M) in IF +# +CREATE TABLE t1 (a TIME(1), b TIME(2)); +CREATE TABLE t2 AS SELECT IF(1, a, b) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` time(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing varios TIME(N) in CASE +# +CREATE TABLE t1 (t0 TIME, t1 TIME(1), t3 TIME(3), t4 TIME(4), t6 TIME(6)); +CREATE TABLE t2 AS SELECT +CASE WHEN 1 THEN t0 ELSE t1 END, +CASE WHEN 1 THEN t0 ELSE t3 END, +CASE WHEN 1 THEN t0 ELSE t4 END, +CASE WHEN 1 THEN t0 ELSE t6 END, +CASE WHEN 1 THEN t1 ELSE t0 END, +CASE WHEN 1 THEN t1 ELSE t3 END, +CASE WHEN 1 THEN t1 ELSE t4 END, +CASE WHEN 1 THEN t1 ELSE t6 END, +CASE WHEN 1 THEN t3 ELSE t0 END, +CASE WHEN 1 THEN t3 ELSE t1 END, +CASE WHEN 1 THEN t3 ELSE t4 END, +CASE WHEN 1 THEN t3 ELSE t6 END, +CASE WHEN 1 THEN t4 ELSE t0 END, +CASE WHEN 1 THEN t4 ELSE t1 END, +CASE WHEN 1 THEN t4 ELSE t3 END, +CASE WHEN 1 THEN t4 ELSE t6 END, +CASE WHEN 1 THEN t6 ELSE t0 END, +CASE WHEN 1 THEN t6 ELSE t1 END, +CASE WHEN 1 THEN t6 ELSE t3 END, +CASE WHEN 1 THEN t6 ELSE t4 END +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CASE WHEN 1 THEN t0 ELSE t1 END` time(1) DEFAULT NULL, + `CASE WHEN 1 THEN t0 ELSE t3 END` time(3) DEFAULT NULL, + `CASE WHEN 1 THEN t0 ELSE t4 END` time(4) DEFAULT NULL, + `CASE WHEN 1 THEN t0 ELSE t6 END` time(6) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t0 END` time(1) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t3 END` time(3) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t4 END` time(4) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t6 END` time(6) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t0 END` time(3) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t1 END` time(3) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t4 END` time(4) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t6 END` time(6) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t0 END` time(4) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t1 END` time(4) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t3 END` time(4) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t6 END` time(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t0 END` time(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t1 END` time(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t3 END` time(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t4 END` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing various TIME(N) in COALESCE +# +CREATE TABLE t1 (a TIME(6), b TIME(6), c TIME, d TIME, e TIME(3), f TIME(4)); +CREATE TABLE t2 AS SELECT +COALESCE(a,b), COALESCE(c,b), +COALESCE(c,d), COALESCE(e,f), +COALESCE(c,e), COALESCE(c,f) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `COALESCE(a,b)` time(6) DEFAULT NULL, + `COALESCE(c,b)` time(6) DEFAULT NULL, + `COALESCE(c,d)` time DEFAULT NULL, + `COALESCE(e,f)` time(4) DEFAULT NULL, + `COALESCE(c,e)` time(3) DEFAULT NULL, + `COALESCE(c,f)` time(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT +CONCAT(COALESCE(a, b)), CONCAT(COALESCE(c, b)), +CONCAT(COALESCE(c, d)), CONCAT(COALESCE(e, f)), +CONCAT(COALESCE(c, e)), CONCAT(COALESCE(c, f)) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CONCAT(COALESCE(a, b))` varchar(17) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, b))` varchar(17) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, d))` varchar(10) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(e, f))` varchar(15) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, e))` varchar(14) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, f))` varchar(15) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing TIME(6) NOT NULL with another TIME(6) NOT NULL +# +CREATE TABLE t1 (a TIME(6) NOT NULL, b TIME(6) NOT NULL); +CREATE TABLE t2 AS SELECT IF(1, a, b) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` time(6) NOT NULL DEFAULT '00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between TIME(6) and TIME(6) +# +CREATE TABLE t1 (a TIME(6) NOT NULL, b TIME(6) NOT NULL); +INSERT INTO t1 VALUES ('11:22:33.123456', '00:11:22.123456'); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` time(6) NOT NULL DEFAULT '00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY a; +a +00:11:22.123456 +11:22:33.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between TIME(6) and TIME +# +CREATE TABLE t1 (t0 TIME NOT NULL, t6 TIME(6) NOT NULL, t3 TIME(3), t4 TIME(4)); +INSERT INTO t1 VALUES +('11:22:33.123456', '00:11:22.123456', '00:11:23.123', '00:11:24.123'); +CREATE TABLE t2 AS SELECT t0 FROM t1 UNION SELECT t6 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t0` time(6) NOT NULL DEFAULT '00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY t0; +t0 +00:11:22.123456 +11:22:33.000000 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT t6 FROM t1 UNION SELECT t0 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t6` time(6) NOT NULL DEFAULT '00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY t6; +t6 +00:11:22.123456 +11:22:33.000000 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT t3 FROM t1 UNION SELECT t4 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t3` time(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY t3; +t3 +00:11:23.1230 +00:11:24.1230 +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between TIME(6) and various other types +# +CREATE TABLE t1 (a TIME(6), b INT, c DOUBLE, d DECIMAL(20,6), e VARCHAR(20)); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(17) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT c FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(22) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT d FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(22) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT e FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(20) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing TIME(6) field in combination with TIME type functions +# +CREATE TABLE t1 (a TIME(6), b TIME(6)); +INSERT INTO t1 VALUES ('10:00:00.123456', '00:00:00.123456'); +INSERT INTO t1 VALUES ('10:00:00', '00:00:00'); +SELECT * FROM t1 WHERE a=ADDTIME(b, '10:00:00'); +a b +10:00:00.123456 00:00:00.123456 +10:00:00.000000 00:00:00.000000 +SELECT * FROM t1 WHERE b=TIMEDIFF(a, '10:00:00'); +a b +10:00:00.123456 00:00:00.123456 +10:00:00.000000 00:00:00.000000 +SELECT a FROM t1 WHERE a=MAKETIME(10,0,0); +a +10:00:00.000000 +SELECT a FROM t1 WHERE a=SEC_TO_TIME(36000); +a +10:00:00.000000 +DELETE FROM t1; +INSERT INTO t1 VALUES (CURTIME(), CURTIME()); +SELECT COUNT(*) FROM t1 WHERE a <= CURTIME(); +COUNT(*) +1 +DROP TABLE t1; +# +# ORDER BY a TIME(6) function +# +CREATE TABLE t1(a TIME(6)); +INSERT INTO t1 (a) VALUES ('835:00:00.000002'); +INSERT INTO t1 (a) VALUES ('835:00:00.000000'); +INSERT INTO t1 (a) VALUES ('835:00:00.000001'); +INSERT INTO t1 (a) VALUES ('00:00:00.000003'); +INSERT INTO t1 (a) VALUES ('00:00:00.000000'); +INSERT INTO t1 (a) VALUES ('00:00:00.000001'); +INSERT INTO t1 (a) VALUES ('-836:00:00.000000'); +INSERT INTO t1 (a) VALUES ('-836:00:00.000001'); +INSERT INTO t1 (a) VALUES ('-836:00:00.000002'); +SELECT * FROM t1 ORDER BY ADDTIME(a, '00:00:00'); +a +-836:00:00.000002 +-836:00:00.000001 +-836:00:00.000000 +00:00:00.000000 +00:00:00.000001 +00:00:00.000003 +835:00:00.000000 +835:00:00.000001 +835:00:00.000002 +SELECT * FROM t1 ORDER BY TIMEDIFF(a, '00:00:00'); +a +-836:00:00.000002 +-836:00:00.000001 +-836:00:00.000000 +00:00:00.000000 +00:00:00.000001 +00:00:00.000003 +835:00:00.000000 +835:00:00.000001 +835:00:00.000002 +SELECT * FROM t1 ORDER BY ADDTIME(a, '00:00:00') DESC; +a +835:00:00.000002 +835:00:00.000001 +835:00:00.000000 +00:00:00.000003 +00:00:00.000001 +00:00:00.000000 +-836:00:00.000000 +-836:00:00.000001 +-836:00:00.000002 +SELECT * FROM t1 ORDER BY TIMEDIFF(a, '00:00:00') DESC; +a +835:00:00.000002 +835:00:00.000001 +835:00:00.000000 +00:00:00.000003 +00:00:00.000001 +00:00:00.000000 +-836:00:00.000000 +-836:00:00.000001 +-836:00:00.000002 +DROP TABLE t1; +# +# Testing partitions +# +CREATE TABLE t1 (a TIME(6)) PARTITION BY KEY(a) PARTITIONS 4; +INSERT INTO t1 VALUES ('00:00:00.000000'); +INSERT INTO t1 VALUES ('00:00:00.000001'); +INSERT INTO t1 VALUES ('00:00:00.000002'); +INSERT INTO t1 VALUES ('00:00:00.000003'); +INSERT INTO t1 VALUES ('00:00:00.000004'); +INSERT INTO t1 VALUES ('00:00:00.000005'); +INSERT INTO t1 VALUES ('00:00:00.000006'); +INSERT INTO t1 VALUES ('00:00:00.000010'); +INSERT INTO t1 VALUES ('00:00:00.000011'); +INSERT INTO t1 VALUES ('00:00:00.000012'); +INSERT INTO t1 VALUES ('00:00:00.000013'); +INSERT INTO t1 VALUES ('00:00:00.000014'); +INSERT INTO t1 VALUES ('00:00:00.000015'); +INSERT INTO t1 VALUES ('00:00:00.000016'); +INSERT INTO t1 VALUES ('00:00:00.000110'); +INSERT INTO t1 VALUES ('00:00:00.000111'); +INSERT INTO t1 VALUES ('00:00:00.000112'); +INSERT INTO t1 VALUES ('00:00:00.000113'); +INSERT INTO t1 VALUES ('00:00:00.000114'); +INSERT INTO t1 VALUES ('00:00:00.000115'); +INSERT INTO t1 VALUES ('00:00:00.000116'); +INSERT INTO t1 VALUES ('00:00:00.000210'); +INSERT INTO t1 VALUES ('00:00:00.000211'); +INSERT INTO t1 VALUES ('00:00:00.000212'); +INSERT INTO t1 VALUES ('00:00:00.000213'); +INSERT INTO t1 VALUES ('00:00:00.000214'); +INSERT INTO t1 VALUES ('00:00:00.000215'); +INSERT INTO t1 VALUES ('00:00:00.000216'); +INSERT INTO t1 VALUES ('00:00:01.000000'); +INSERT INTO t1 VALUES ('00:00:01.000001'); +INSERT INTO t1 VALUES ('00:00:01.000002'); +INSERT INTO t1 VALUES ('00:00:01.000003'); +INSERT INTO t1 VALUES ('00:00:01.000004'); +INSERT INTO t1 VALUES ('00:00:01.000005'); +INSERT INTO t1 VALUES ('00:00:01.000006'); +INSERT INTO t1 VALUES ('00:00:02.000000'); +INSERT INTO t1 VALUES ('00:00:02.000001'); +INSERT INTO t1 VALUES ('00:00:02.000002'); +INSERT INTO t1 VALUES ('00:00:02.000003'); +INSERT INTO t1 VALUES ('00:00:02.000004'); +INSERT INTO t1 VALUES ('00:00:02.000005'); +INSERT INTO t1 VALUES ('00:00:02.000006'); +SELECT * FROM t1 PARTITION(p0); +a +00:00:01.000002 +00:00:01.000006 +SELECT * FROM t1 PARTITION(p1); +a +00:00:00.000000 +00:00:00.000001 +00:00:00.000002 +00:00:00.000003 +00:00:00.000004 +00:00:00.000005 +00:00:00.000006 +00:00:00.000010 +00:00:00.000011 +00:00:00.000012 +00:00:00.000013 +00:00:00.000014 +00:00:00.000015 +00:00:00.000016 +00:00:00.000110 +00:00:00.000111 +00:00:00.000112 +00:00:00.000113 +00:00:00.000114 +00:00:00.000115 +00:00:00.000116 +00:00:00.000210 +00:00:00.000211 +00:00:00.000212 +00:00:00.000213 +00:00:00.000214 +00:00:00.000215 +00:00:00.000216 +00:00:01.000003 +00:00:02.000001 +00:00:02.000003 +00:00:02.000005 +SELECT * FROM t1 PARTITION(p2); +a +00:00:01.000000 +00:00:01.000004 +SELECT * FROM t1 PARTITION(p3); +a +00:00:01.000001 +00:00:01.000005 +00:00:02.000000 +00:00:02.000002 +00:00:02.000004 +00:00:02.000006 +ALTER TABLE t1 PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN ('00:00:00.000200'), +PARTITION p1 VALUES LESS THAN ('00:00:01'), +PARTITION p2 VALUES LESS THAN ('00:00:02.000003'), +PARTITION p3 VALUES LESS THAN MAXVALUE +); +SELECT * FROM t1 PARTITION(p0); +a +00:00:00.000000 +00:00:00.000001 +00:00:00.000002 +00:00:00.000003 +00:00:00.000004 +00:00:00.000005 +00:00:00.000006 +00:00:00.000010 +00:00:00.000011 +00:00:00.000012 +00:00:00.000013 +00:00:00.000014 +00:00:00.000015 +00:00:00.000016 +00:00:00.000110 +00:00:00.000111 +00:00:00.000112 +00:00:00.000113 +00:00:00.000114 +00:00:00.000115 +00:00:00.000116 +SELECT * FROM t1 PARTITION(p1); +a +00:00:00.000210 +00:00:00.000211 +00:00:00.000212 +00:00:00.000213 +00:00:00.000214 +00:00:00.000215 +00:00:00.000216 +SELECT * FROM t1 PARTITION(p2); +a +00:00:01.000002 +00:00:01.000006 +00:00:01.000003 +00:00:02.000001 +00:00:01.000000 +00:00:01.000004 +00:00:01.000001 +00:00:01.000005 +00:00:02.000000 +00:00:02.000002 +SELECT * FROM t1 PARTITION(p3); +a +00:00:02.000003 +00:00:02.000005 +00:00:02.000004 +00:00:02.000006 +DROP TABLE t1; +# +# Checking that a TIME literal can be a partition LESS value +# +CREATE TABLE t1 (s1 TIME(6)) +PARTITION BY RANGE COLUMNS (s1) +(PARTITION p1 VALUES LESS THAN (TIME'01:01:01.000001')); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50500 PARTITION BY RANGE COLUMNS(s1) +(PARTITION p1 VALUES LESS THAN ('01:01:01.000001') ENGINE = InnoDB) */ +DROP TABLE t1; +# +# Testing MAKETIME() +# +CREATE TABLE t1 AS +SELECT +CAST(MAKETIME(1, 1, 1) AS TIME) as a, +CAST(MAKETIME(1, 1, 1) AS CHAR) as b; +SELECT MAKETIME(1, 1, 1); +MAKETIME(1, 1, 1) +01:01:01 +SELECT MAKETIME(1, 1, 1.0); +MAKETIME(1, 1, 1.0) +01:01:01.0 +SELECT MAKETIME(1, 1, 1.00); +MAKETIME(1, 1, 1.00) +01:01:01.00 +SELECT MAKETIME(1, 1, 1.000); +MAKETIME(1, 1, 1.000) +01:01:01.000 +SELECT MAKETIME(1, 1, 1.0000); +MAKETIME(1, 1, 1.0000) +01:01:01.0000 +SELECT MAKETIME(1, 1, 1.00000); +MAKETIME(1, 1, 1.00000) +01:01:01.00000 +SELECT MAKETIME(1, 1, 1.000000); +MAKETIME(1, 1, 1.000000) +01:01:01.000000 +SELECT MAKETIME(0, 0, -0.123); +MAKETIME(0, 0, -0.123) +NULL +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +MAKETIME(1, 1, 1), +MAKETIME(1, 1, 1.0), +MAKETIME(1, 1, 1.00), +MAKETIME(1, 1, 1.000), +MAKETIME(1, 1, 1.0000), +MAKETIME(1, 1, 1.00000), +MAKETIME(1, 1, 1.000000); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `MAKETIME(1, 1, 1)` time DEFAULT NULL, + `MAKETIME(1, 1, 1.0)` time(1) DEFAULT NULL, + `MAKETIME(1, 1, 1.00)` time(2) DEFAULT NULL, + `MAKETIME(1, 1, 1.000)` time(3) DEFAULT NULL, + `MAKETIME(1, 1, 1.0000)` time(4) DEFAULT NULL, + `MAKETIME(1, 1, 1.00000)` time(5) DEFAULT NULL, + `MAKETIME(1, 1, 1.000000)` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing rounding with MAKETIME() +# +CREATE TABLE t1 (hour INT, minute INT, second DECIMAL(23,7)); +INSERT INTO t1 VALUES +(836, 59, 59.999999), +(836, 59, 59.9999990), +(836, 59, 59.9999991), +(836, 59, 59.9999992), +(836, 59, 59.9999993), +(836, 59, 59.9999995), +(836, 59, 59.9999996), +(836, 59, 59.9999997), +(836, 59, 59.9999998), +(836, 59, 59.9999999); +SELECT hour, minute, second, MAKETIME(hour, minute, second) FROM t1; +hour minute second MAKETIME(hour, minute, second) +836 59 59.9999990 836:59:59.999999 +836 59 59.9999990 836:59:59.999999 +836 59 59.9999991 836:59:59.999999 +836 59 59.9999992 836:59:59.999999 +836 59 59.9999993 836:59:59.999999 +836 59 59.9999995 837:00:00.000000 +836 59 59.9999996 837:00:00.000000 +836 59 59.9999997 837:00:00.000000 +836 59 59.9999998 837:00:00.000000 +836 59 59.9999999 837:00:00.000000 +SELECT hour + 1, minute, second, MAKETIME(hour + 1, minute, second) FROM t1; +hour + 1 minute second MAKETIME(hour + 1, minute, second) +837 59 59.9999990 837:59:59.999999 +837 59 59.9999990 837:59:59.999999 +837 59 59.9999991 837:59:59.999999 +837 59 59.9999992 837:59:59.999999 +837 59 59.9999993 837:59:59.999999 +837 59 59.9999995 838:00:00.000000 +837 59 59.9999996 838:00:00.000000 +837 59 59.9999997 838:00:00.000000 +837 59 59.9999998 838:00:00.000000 +837 59 59.9999999 838:00:00.000000 +SELECT -hour, minute, second, MAKETIME(-hour, minute, second) FROM t1; +-hour minute second MAKETIME(-hour, minute, second) +-836 59 59.9999990 -836:59:59.999999 +-836 59 59.9999990 -836:59:59.999999 +-836 59 59.9999991 -836:59:59.999999 +-836 59 59.9999992 -836:59:59.999999 +-836 59 59.9999993 -836:59:59.999999 +-836 59 59.9999995 -837:00:00.000000 +-836 59 59.9999996 -837:00:00.000000 +-836 59 59.9999997 -837:00:00.000000 +-836 59 59.9999998 -837:00:00.000000 +-836 59 59.9999999 -837:00:00.000000 +SELECT -hour - 1, minute, second, MAKETIME(-hour - 1, minute, second) FROM t1; +-hour - 1 minute second MAKETIME(-hour - 1, minute, second) +-837 59 59.9999990 -837:59:59.999999 +-837 59 59.9999990 -837:59:59.999999 +-837 59 59.9999991 -837:59:59.999999 +-837 59 59.9999992 -837:59:59.999999 +-837 59 59.9999993 -837:59:59.999999 +-837 59 59.9999995 -838:00:00.000000 +-837 59 59.9999996 -838:00:00.000000 +-837 59 59.9999997 -838:00:00.000000 +-837 59 59.9999998 -838:00:00.000000 +-837 59 59.9999999 -838:00:00.000000 +DROP TABLE t1; +SELECT MAKETIME(838, 59, 59.0000005); +MAKETIME(838, 59, 59.0000005) +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '838:59:59.0000005' +SELECT MAKETIME(838, 59, 59.00000056); +MAKETIME(838, 59, 59.00000056) +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '838:59:59.00000056' +SELECT MAKETIME(838, 59, 59.000000567); +MAKETIME(838, 59, 59.000000567) +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '838:59:59.000000567' +SELECT MAKETIME(838, 59, 59.0000005678); +MAKETIME(838, 59, 59.0000005678) +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '838:59:59.000000567' +SELECT MAKETIME(838, 59, 59.00000056789); +MAKETIME(838, 59, 59.00000056789) +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '838:59:59.000000567' +# +# Testing CAST to TIME and TIME(6) +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 AS SELECT +CAST(1 AS TIME), +CAST(100000000 AS TIME), +CAST(1.1 AS TIME), +CAST('1' AS TIME), +CAST(1e0 AS TIME), +CAST(1 AS TIME(0)), +CAST(100000000 AS TIME(0)), +CAST(1.1 AS TIME(0)), +CAST('1' AS TIME(0)), +CAST(1e0 AS TIME(0)), +CAST(1 AS TIME(6)), +CAST(100000000 AS TIME(6)), +CAST(1.1 AS TIME(6)), +CAST('1' AS TIME(6)), +CAST(1e0 AS TIME(6)); +Warnings: +Warning 1292 Truncated incorrect time value: '100000000' +Warning 1292 Truncated incorrect time value: '100000000' +Warning 1292 Truncated incorrect time value: '100000000' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CAST(1 AS TIME)` time DEFAULT NULL, + `CAST(100000000 AS TIME)` time DEFAULT NULL, + `CAST(1.1 AS TIME)` time DEFAULT NULL, + `CAST('1' AS TIME)` time DEFAULT NULL, + `CAST(1e0 AS TIME)` time DEFAULT NULL, + `CAST(1 AS TIME(0))` time DEFAULT NULL, + `CAST(100000000 AS TIME(0))` time DEFAULT NULL, + `CAST(1.1 AS TIME(0))` time DEFAULT NULL, + `CAST('1' AS TIME(0))` time DEFAULT NULL, + `CAST(1e0 AS TIME(0))` time DEFAULT NULL, + `CAST(1 AS TIME(6))` time(6) DEFAULT NULL, + `CAST(100000000 AS TIME(6))` time(6) DEFAULT NULL, + `CAST(1.1 AS TIME(6))` time(6) DEFAULT NULL, + `CAST('1' AS TIME(6))` time(6) DEFAULT NULL, + `CAST(1e0 AS TIME(6))` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +SET sql_mode = default; +CREATE TABLE t1 (a TIME, b TIME(6)); +INSERT INTO t1 VALUES ('11:22:33', '11:22:33.123456'); +CREATE TABLE t2 AS SELECT CAST(a AS TIME), CAST(b AS TIME) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS TIME)` time DEFAULT NULL, + `CAST(b AS TIME)` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT CAST(a AS TIME(0)), CAST(b AS TIME(0)) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS TIME(0))` time DEFAULT NULL, + `CAST(b AS TIME(0))` time DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT CAST(a AS TIME(6)), CAST(b AS TIME(6)) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS TIME(6))` time(6) DEFAULT NULL, + `CAST(b AS TIME(6))` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +# +# Testing Item_typecast_time::val_str +# +SELECT CONCAT(CAST(a AS TIME(0))), CONCAT(CAST(b AS TIME(0))) FROM t1; +CONCAT(CAST(a AS TIME(0))) CONCAT(CAST(b AS TIME(0))) +11:22:33 11:22:33 +SELECT CONCAT(CAST(a AS TIME(6))), CONCAT(CAST(b AS TIME(6))) FROM t1; +CONCAT(CAST(a AS TIME(6))) CONCAT(CAST(b AS TIME(6))) +11:22:33.000000 11:22:33.123456 +SELECT CONCAT(CAST(a AS TIME)), CONCAT(CAST(b AS TIME)) FROM t1; +CONCAT(CAST(a AS TIME)) CONCAT(CAST(b AS TIME)) +11:22:33 11:22:33 +# +# Testing Item_typecast_time::get_time +# +SELECT CAST(a AS TIME(0)), CAST(b AS TIME(0)) FROM t1; +CAST(a AS TIME(0)) CAST(b AS TIME(0)) +11:22:33 11:22:33 +SELECT CAST(a AS TIME(6)), CAST(b AS TIME(6)) FROM t1; +CAST(a AS TIME(6)) CAST(b AS TIME(6)) +11:22:33.000000 11:22:33.123456 +SELECT CAST(a AS TIME), CAST(b AS TIME) FROM t1; +CAST(a AS TIME) CAST(b AS TIME) +11:22:33 11:22:33 +DROP TABLE t1; +# +# Testing Item_typecast_time::val_int +# +SELECT CAST('10:11:12' AS TIME(0)) + 1; +CAST('10:11:12' AS TIME(0)) + 1 +101113 +# +# Testing Item_typecast_time::val_decimal +# +SELECT CAST('10:11:12' AS TIME(6)) + 1; +CAST('10:11:12' AS TIME(6)) + 1 +101113.000000 +# +# Testing function TIME(expr) +# +CREATE TABLE t1 AS SELECT +TIME(101), +TIME(101.1), +TIME(101.12), +TIME(101.123), +TIME(101.1234), +TIME(101.12345), +TIME(101.123456), +TIME('00:01:01'), +TIME('00:01:01.1'), +TIME('00:01:01.12'), +TIME('00:01:01.123'), +TIME('00:01:01.1234'), +TIME('00:01:01.12345'), +TIME('00:01:01.123456'), +TIME(CONCAT('00:01:01', '')), +TIME(CONCAT('00:01:01', '.1')), +TIME(CONCAT('00:01:01', '.12')), +TIME(CONCAT('00:01:01', '.123')), +TIME(CONCAT('00:01:01', '.1234')), +TIME(CONCAT('00:01:01', '.12345')), +TIME(CONCAT('00:01:01', '.123456')), +TIME(TIME'00:01:01'), +TIME(TIME'00:01:01.1'), +TIME(TIME'00:01:01.12'), +TIME(TIME'00:01:01.123'), +TIME(TIME'00:01:01.1234'), +TIME(TIME'00:01:01.12345'), +TIME(TIME'00:01:01.123456'), +TIME(TIMESTAMP('2001-01-01 00:00:00')), +TIME(TIMESTAMP('2001-01-01 00:00:00.1')), +TIME(TIMESTAMP('2001-01-01 00:00:00.12')), +TIME(TIMESTAMP('2001-01-01 00:00:00.123')), +TIME(TIMESTAMP('2001-01-01 00:00:00.1234')), +TIME(TIMESTAMP('2001-01-01 00:00:00.12345')), +TIME(TIMESTAMP('2001-01-01 00:00:00.123456')); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `TIME(101)` time DEFAULT NULL, + `TIME(101.1)` time(1) DEFAULT NULL, + `TIME(101.12)` time(2) DEFAULT NULL, + `TIME(101.123)` time(3) DEFAULT NULL, + `TIME(101.1234)` time(4) DEFAULT NULL, + `TIME(101.12345)` time(5) DEFAULT NULL, + `TIME(101.123456)` time(6) DEFAULT NULL, + `TIME('00:01:01')` time DEFAULT NULL, + `TIME('00:01:01.1')` time(1) DEFAULT NULL, + `TIME('00:01:01.12')` time(2) DEFAULT NULL, + `TIME('00:01:01.123')` time(3) DEFAULT NULL, + `TIME('00:01:01.1234')` time(4) DEFAULT NULL, + `TIME('00:01:01.12345')` time(5) DEFAULT NULL, + `TIME('00:01:01.123456')` time(6) DEFAULT NULL, + `TIME(CONCAT('00:01:01', ''))` time DEFAULT NULL, + `TIME(CONCAT('00:01:01', '.1'))` time(1) DEFAULT NULL, + `TIME(CONCAT('00:01:01', '.12'))` time(2) DEFAULT NULL, + `TIME(CONCAT('00:01:01', '.123'))` time(3) DEFAULT NULL, + `TIME(CONCAT('00:01:01', '.1234'))` time(4) DEFAULT NULL, + `TIME(CONCAT('00:01:01', '.12345'))` time(5) DEFAULT NULL, + `TIME(CONCAT('00:01:01', '.123456'))` time(6) DEFAULT NULL, + `TIME(TIME'00:01:01')` time DEFAULT NULL, + `TIME(TIME'00:01:01.1')` time(1) DEFAULT NULL, + `TIME(TIME'00:01:01.12')` time(2) DEFAULT NULL, + `TIME(TIME'00:01:01.123')` time(3) DEFAULT NULL, + `TIME(TIME'00:01:01.1234')` time(4) DEFAULT NULL, + `TIME(TIME'00:01:01.12345')` time(5) DEFAULT NULL, + `TIME(TIME'00:01:01.123456')` time(6) DEFAULT NULL, + `TIME(TIMESTAMP('2001-01-01 00:00:00'))` time DEFAULT NULL, + `TIME(TIMESTAMP('2001-01-01 00:00:00.1'))` time(1) DEFAULT NULL, + `TIME(TIMESTAMP('2001-01-01 00:00:00.12'))` time(2) DEFAULT NULL, + `TIME(TIMESTAMP('2001-01-01 00:00:00.123'))` time(3) DEFAULT NULL, + `TIME(TIMESTAMP('2001-01-01 00:00:00.1234'))` time(4) DEFAULT NULL, + `TIME(TIMESTAMP('2001-01-01 00:00:00.12345'))` time(5) DEFAULT NULL, + `TIME(TIMESTAMP('2001-01-01 00:00:00.123456'))` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing comparison between a TIME(6) field and a TIME(N) type cast +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('10:11:12.000000'); +INSERT INTO t1 VALUES ('10:11:12.000001'); +INSERT INTO t1 VALUES ('10:11:12.000002'); +INSERT INTO t1 VALUES ('10:11:12.000003'); +SELECT * FROM t1 WHERE a=CAST('10:11:12.000003' AS TIME(6)); +a +10:11:12.000003 +SELECT * FROM t1 WHERE a=CAST('10:11:12.000003' AS TIME(0)); +a +10:11:12.000000 +DROP TABLE t1; +# +# Testing comparison between CAST(x AS TIME(N)) +# +SELECT CAST('10:11:12.123' AS TIME(0)) = 101112; +CAST('10:11:12.123' AS TIME(0)) = 101112 +1 +SELECT CAST(101112.123 AS TIME(0)) = 101112; +CAST(101112.123 AS TIME(0)) = 101112 +1 +SELECT CAST(101112.123e0 AS TIME(0)) = 101112; +CAST(101112.123e0 AS TIME(0)) = 101112 +1 +# +# Testing Item_typecast_time::val_int_packed() +# +CREATE TABLE t1 (a TIME, b TIME(6)); +INSERT INTO t1 VALUES ('24:00:00', '24:00:00.123456'); +SELECT CAST('24:00:00' AS TIME) = (SELECT a FROM t1); +CAST('24:00:00' AS TIME) = (SELECT a FROM t1) +1 +SELECT CAST('24:00:00' AS TIME(6)) = (SELECT a FROM t1); +CAST('24:00:00' AS TIME(6)) = (SELECT a FROM t1) +1 +SELECT CAST('24:00:00.123456' AS TIME(0)) = (SELECT a FROM t1); +CAST('24:00:00.123456' AS TIME(0)) = (SELECT a FROM t1) +1 +SELECT CAST('24:00:00.123456' AS TIME(6)) = (SELECT b FROM t1); +CAST('24:00:00.123456' AS TIME(6)) = (SELECT b FROM t1) +1 +DROP TABLE t1; +# +# Testing function MICROSECOND +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('-11:12:13.000001'); +INSERT INTO t1 VALUES ('11:12:13.000001'); +INSERT INTO t1 VALUES ('11:12:13.100001'); +INSERT INTO t1 VALUES ('11:12:13.999999'); +SELECT a, MICROSECOND(a) FROM t1; +a MICROSECOND(a) +-11:12:13.000001 1 +11:12:13.000001 1 +11:12:13.100001 100001 +11:12:13.999999 999999 +SELECT a, EXTRACT(MICROSECOND FROM a) FROM t1; +a EXTRACT(MICROSECOND FROM a) +-11:12:13.000001 -1 +11:12:13.000001 1 +11:12:13.100001 100001 +11:12:13.999999 999999 +DROP TABLE t1; +SELECT MICROSECOND(CAST(123.456 AS TIME(6))); +MICROSECOND(CAST(123.456 AS TIME(6))) +456000 +SELECT EXTRACT(MICROSECOND FROM CAST(123.456 AS TIME(6))); +EXTRACT(MICROSECOND FROM CAST(123.456 AS TIME(6))) +456000 +# +# Testing PS +# +CREATE TABLE t1 (a TIME(6)); +PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)'; +SET @a='11:22:33.123456'; +SET @b=112233.123456; +SET @c=112233.123456e0; +EXECUTE stmt USING @a; +DEALLOCATE PREPARE stmt; +SELECT * FROM t1; +a +11:22:33.123456 +PREPARE stmt FROM 'SELECT * FROM t1 WHERE a=?'; +EXECUTE stmt USING @a; +a +11:22:33.123456 +EXECUTE stmt USING @b; +a +11:22:33.123456 +EXECUTE stmt USING @c; +a +11:22:33.123456 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# +# Testing TIME(6) and user variables +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('11:22:33.123456'); +SET @a='11:22:33.123456'; +SELECT * FROM t1 WHERE a=@a; +a +11:22:33.123456 +SET @a=112233.123456; +SELECT * FROM t1 WHERE a=@a; +a +11:22:33.123456 +SET @a=112233.123456e0; +SELECT * FROM t1 WHERE a=@a; +a +11:22:33.123456 +SET @a=NULL; +SELECT a INTO @a FROM t1 LIMIT 1; +SELECT @a; +@a +11:22:33.123456 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT @a AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` longtext CHARACTER SET latin1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +a +11:22:33.123456 +DROP TABLE t1; +# +# Testing SP +# +CREATE PROCEDURE p1 () +BEGIN +DECLARE a TIME(6); +SET a='11:22:33.123'; +SELECT a; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE a TIME(6); +SET a='11:22:33.123'; +SELECT a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1// +a +11:22:33.123000 +DROP PROCEDURE p1// +CREATE PROCEDURE p1 (a TIME(6)) +BEGIN +SELECT a; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(a TIME(6)) +BEGIN +SELECT a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1(112233)// +a +11:22:33.000000 +CALL p1(112233.123)// +a +11:22:33.123000 +CALL p1(112233.123e0)// +a +11:22:33.123000 +CALL p1('11:22:33.123')// +a +11:22:33.123000 +DROP PROCEDURE p1// +CREATE PROCEDURE p1() +BEGIN +DECLARE a TIME(6); +CREATE TABLE t1 AS SELECT a; +SHOW CREATE TABLE t1; +DROP TABLE t1; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE a TIME(6); +CREATE TABLE t1 AS SELECT a; +SHOW CREATE TABLE t1; +DROP TABLE t1; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1// +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP PROCEDURE p1// +CREATE FUNCTION p1 (a TIME(6)) RETURNS TIME(6) +BEGIN +RETURN a; +END// +SHOW CREATE FUNCTION p1// +Function sql_mode Create Function character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `p1`(a TIME(6)) RETURNS time(6) +BEGIN +RETURN a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +SELECT p1(112233.123)// +p1(112233.123) +11:22:33.123000 +DROP FUNCTION p1// +# +# Testing INFORMATION_SCHEMA.COLUMNS +# +CREATE TABLE t1 (a TIME(6)); +SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1';; +TABLE_CATALOG def +TABLE_SCHEMA test +TABLE_NAME t1 +COLUMN_NAME a +ORDINAL_POSITION 1 +COLUMN_DEFAULT NULL +IS_NULLABLE YES +DATA_TYPE time +CHARACTER_MAXIMUM_LENGTH NULL +CHARACTER_OCTET_LENGTH NULL +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION 6 +CHARACTER_SET_NAME NULL +COLLATION_NAME NULL +COLUMN_TYPE time(6) +COLUMN_KEY +EXTRA +PRIVILEGES # +COLUMN_COMMENT +GENERATION_EXPRESSION +SRS_ID NULL +DROP TABLE t1; +# +# SELECT from a subquery +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00.123456'), ('11:11:11.123456'); +SELECT * FROM (SELECT * FROM t1) t12; +a +00:00:00.123456 +11:11:11.123456 +DROP TABLE t1; +# +# Testing IN and = subqueries +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00.123456'), ('11:11:11.123456'); +SELECT * FROM t1 WHERE a IN (SELECT MIN(a) FROM t1); +a +00:00:00.123456 +SELECT * FROM t1 WHERE a = (SELECT a FROM t1 ORDER BY a DESC LIMIT 1); +a +11:11:11.123456 +DROP TABLE t1; +# +# Testing IN subquery + GROUP +# +CREATE TABLE t1 (id INT, a TIME(6)); +INSERT INTO t1 VALUES (1,'00:00:00.123456'), (1,'11:00:00.123456'); +INSERT INTO t1 VALUES (2,'00:01:00.123456'), (2,'11:01:00.123456'); +INSERT INTO t1 VALUES (3, NULL); +SELECT * FROM t1 WHERE a IN (SELECT MAX(a) FROM t1 GROUP BY id); +id a +1 11:00:00.123456 +2 11:01:00.123456 +DROP TABLE t1; +# +# Testing VIEW +# +CREATE TABLE t1 (a TIME(6)); +INSERT INTO t1 VALUES ('00:00:00.123456'), ('11:11:11.123456'); +CREATE VIEW v1 AS SELECT a FROM t1; +SELECT * FROM v1 WHERE a='00:00:00.123456'; +a +00:00:00.123456 +SELECT MIN(a), MAX(a) FROM v1; +MIN(a) MAX(a) +00:00:00.123456 11:11:11.123456 +SELECT * FROM t1 WHERE a IN (SELECT MAX(a) FROM v1); +a +11:11:11.123456 +DROP VIEW v1; +CREATE VIEW v1 AS SELECT MAX(a) AS a FROM t1; +SELECT * FROM v1; +a +11:11:11.123456 +SELECT * FROM t1 WHERE a=(SELECT a FROM v1); +a +11:11:11.123456 +DROP VIEW v1; +DROP TABLE t1; +# +# Testing hybrid functions in TIME context +# +SELECT DATE_ADD(TIME'00:00:00.0', INTERVAL 10.1 SECOND); +DATE_ADD(TIME'00:00:00.0', INTERVAL 10.1 SECOND) +00:00:10.1 +SELECT DATE_ADD(TIME'00:00:00.0', INTERVAL 10000000.1 SECOND); +DATE_ADD(TIME'00:00:00.0', INTERVAL 10000000.1 SECOND) +NULL +Warnings: +Warning 1441 Datetime function: time field overflow +SELECT DATE_ADD(TIME'00:00:00.0', INTERVAL 100000000000000000.1 SECOND); +DATE_ADD(TIME'00:00:00.0', INTERVAL 100000000000000000.1 SECOND) +NULL +Warnings: +Warning 1441 Datetime function: time field overflow +SELECT DATE_ADD(TIME'00:00:00.0', INTERVAL 1000000000000000000000.1 SECOND); +DATE_ADD(TIME'00:00:00.0', INTERVAL 1000000000000000000000.1 SECOND) +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '1000000000000000000000.1' +CREATE TABLE t1 AS SELECT +DATE_ADD(TIME'00:00:00', INTERVAL 1 SECOND) AS t0s0, +DATE_ADD(TIME'00:00:00', INTERVAL 1.1 SECOND) AS t0s1, +DATE_ADD(TIME'00:00:00', INTERVAL 1.12 SECOND) AS t0s2, +DATE_ADD(TIME'00:00:00', INTERVAL 1.123 SECOND) AS t0s3, +DATE_ADD(TIME'00:00:00', INTERVAL 1.1234 SECOND) AS t0s4, +DATE_ADD(TIME'00:00:00', INTERVAL 1.12345 SECOND) AS t0s5, +DATE_ADD(TIME'00:00:00', INTERVAL 1.123456 SECOND) AS t0s6, +DATE_ADD(TIME'00:00:00.1', INTERVAL 1 SECOND) AS t1s0, +DATE_ADD(TIME'00:00:00.12', INTERVAL 1 SECOND) AS t2s0, +DATE_ADD(TIME'00:00:00.123', INTERVAL 1 SECOND) AS t3s0, +DATE_ADD(TIME'00:00:00.1234', INTERVAL 1 SECOND) AS t4s0, +DATE_ADD(TIME'00:00:00.12345', INTERVAL 1 SECOND) AS t5s0, +DATE_ADD(TIME'00:00:00.123456', INTERVAL 1 SECOND) AS t6s0, +DATE_ADD(TIME'00:00:00', INTERVAL 1 MICROSECOND) AS t0ms; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t0s0` time DEFAULT NULL, + `t0s1` time(1) DEFAULT NULL, + `t0s2` time(2) DEFAULT NULL, + `t0s3` time(3) DEFAULT NULL, + `t0s4` time(4) DEFAULT NULL, + `t0s5` time(5) DEFAULT NULL, + `t0s6` time(6) DEFAULT NULL, + `t1s0` time(1) DEFAULT NULL, + `t2s0` time(2) DEFAULT NULL, + `t3s0` time(3) DEFAULT NULL, + `t4s0` time(4) DEFAULT NULL, + `t5s0` time(5) DEFAULT NULL, + `t6s0` time(6) DEFAULT NULL, + `t0ms` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +ADDTIME(TIME'00:00:00', TIME'00:00:01') AS t0s0, +ADDTIME(TIME'00:00:00', TIME'00:00:01.1') AS t0s1, +ADDTIME(TIME'00:00:00', TIME'00:00:01.12') AS t0s2, +ADDTIME(TIME'00:00:00', TIME'00:00:01.123') AS t0s3, +ADDTIME(TIME'00:00:00', TIME'00:00:01.1234') AS t0s4, +ADDTIME(TIME'00:00:00', TIME'00:00:01.12345') AS t0s5, +ADDTIME(TIME'00:00:00', TIME'00:00:01.123457') AS t0s6, +ADDTIME(TIME'00:00:00.1', TIME '00:00:00') AS t1s0, +ADDTIME(TIME'00:00:00.12', TIME '00:00:00') AS t2s0, +ADDTIME(TIME'00:00:00.123', TIME '00:00:00') AS t3s0, +ADDTIME(TIME'00:00:00.1234', TIME '00:00:00') AS t4s0, +ADDTIME(TIME'00:00:00.12345', TIME '00:00:00') AS t5s0, +ADDTIME(TIME'00:00:00.123456', TIME '00:00:00') AS t6s0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t0s0` time DEFAULT NULL, + `t0s1` time(1) DEFAULT NULL, + `t0s2` time(2) DEFAULT NULL, + `t0s3` time(3) DEFAULT NULL, + `t0s4` time(4) DEFAULT NULL, + `t0s5` time(5) DEFAULT NULL, + `t0s6` time(6) DEFAULT NULL, + `t1s0` time(1) DEFAULT NULL, + `t2s0` time(2) DEFAULT NULL, + `t3s0` time(3) DEFAULT NULL, + `t4s0` time(4) DEFAULT NULL, + `t5s0` time(5) DEFAULT NULL, + `t6s0` time(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing that CAST from various fields to TIME rounds. +# This tests Field::get_time(). +CREATE TABLE t1 (a VARCHAR(32)); +INSERT INTO t1 VALUES +('838:59:58.0000009'), ('838:59:58.9'), +('-838:59:58.0000009'), ('-838:59:58.9'), +('10:10:10.9999994'), ('10:10:10.9999995'), +('-10:10:10.9999994'), ('-10:10:10.9999995'); +SELECT a, CAST(a AS TIME), CAST(a AS TIME(6)) FROM t1; +a CAST(a AS TIME) CAST(a AS TIME(6)) +838:59:58.0000009 838:59:58 838:59:58.000001 +838:59:58.9 838:59:59 838:59:58.900000 +-838:59:58.0000009 -838:59:58 -838:59:58.000001 +-838:59:58.9 -838:59:59 -838:59:58.900000 +10:10:10.9999994 10:10:11 10:10:10.999999 +10:10:10.9999995 10:10:11 10:10:11.000000 +-10:10:10.9999994 -10:10:11 -10:10:10.999999 +-10:10:10.9999995 -10:10:11 -10:10:11.000000 +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(30,7)); +INSERT INTO t1 VALUES +(8385958.0000009), (8385958.9), +(-8385958.0000009), (-8385958.9), +(101010.9999994), (101010.9999995), +(-101010.9999994), (-101010.9999995); +SELECT a, CAST(a AS TIME), CAST(a AS TIME(6)) FROM t1; +a CAST(a AS TIME) CAST(a AS TIME(6)) +8385958.0000009 838:59:58 838:59:58.000001 +8385958.9000000 838:59:59 838:59:58.900000 +-8385958.0000009 -838:59:58 -838:59:58.000001 +-8385958.9000000 -838:59:59 -838:59:58.900000 +101010.9999994 10:10:11 10:10:10.999999 +101010.9999995 10:10:11 10:10:11.000000 +-101010.9999994 -10:10:11 -10:10:10.999999 +-101010.9999995 -10:10:11 -10:10:11.000000 +ALTER TABLE t1 MODIFY a DOUBLE; +SELECT a, CAST(a AS TIME), CAST(a AS TIME(6)) FROM t1; +a CAST(a AS TIME) CAST(a AS TIME(6)) +8385958.0000009 838:59:58 838:59:58.000001 +8385958.9 838:59:59 838:59:58.900000 +-8385958.0000009 -838:59:58 -838:59:58.000001 +-8385958.9 -838:59:59 -838:59:58.900000 +101010.9999994 10:10:11 10:10:10.999999 +101010.9999995 10:10:11 10:10:11.000000 +-101010.9999994 -10:10:11 -10:10:10.999999 +-101010.9999995 -10:10:11 -10:10:11.000000 +DROP TABLE t1; +# +# Testing that Item::get_time() rounds +# +SELECT +CAST('10:10:10.9999994' AS TIME), +CAST('10:10:10.9999995' AS TIME), +CAST('10:10:10.9999994' AS TIME(6)), +CAST('10:10:10.9999995' AS TIME(6)), +CAST(101010.9999994 AS TIME), +CAST(101010.9999995 AS TIME), +CAST(101010.9999994 AS TIME(6)), +CAST(101010.9999995 AS TIME(6)); +CAST('10:10:10.9999994' AS TIME) 10:10:11 +CAST('10:10:10.9999995' AS TIME) 10:10:11 +CAST('10:10:10.9999994' AS TIME(6)) 10:10:10.999999 +CAST('10:10:10.9999995' AS TIME(6)) 10:10:11.000000 +CAST(101010.9999994 AS TIME) 10:10:11 +CAST(101010.9999995 AS TIME) 10:10:11 +CAST(101010.9999994 AS TIME(6)) 10:10:10.999999 +CAST(101010.9999995 AS TIME(6)) 10:10:11.000000 +# +# Testing that comparison rounds +# +CREATE TABLE t1 (t0 TIME, t6 TIME(6)); +INSERT INTO t1 VALUES ('00:00:00', '00:00:00.999999'); +INSERT INTO t1 VALUES ('00:00:01', '00:00:01.000000'); +SELECT t0 FROM t1 WHERE t6='00:00:00.9999998'; +t0 +00:00:01 +SELECT t6 FROM t1 WHERE t6='00:00:00.9999998'; +t6 +00:00:01.000000 +DROP TABLE t1; +# +# Testing that EXTRACT rounds +# +SELECT +EXTRACT(MICROSECOND FROM '00:00:00.9999994'), +EXTRACT(MICROSECOND FROM '00:00:00.9999995'), +EXTRACT(MICROSECOND FROM 0.9999994), +EXTRACT(MICROSECOND FROM 0.9999995); +EXTRACT(MICROSECOND FROM '00:00:00.9999994') 999999 +EXTRACT(MICROSECOND FROM '00:00:00.9999995') 0 +EXTRACT(MICROSECOND FROM 0.9999994) 999999 +EXTRACT(MICROSECOND FROM 0.9999995) 0 +# +# Testing that DATETIME(0) is a synonym to non-fractional DATETIME +# +CREATE TABLE t1 (a DATETIME(0) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing internal representation format for DATETIME(N) +# +CREATE TABLE t1 (a6 VARCHAR(32)); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000001'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000002'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000003'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000004'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000005'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000006'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000007'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000008'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000009'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000010'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000011'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000012'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000013'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000014'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000015'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000016'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000099'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000999'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.009999'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.099999'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.100000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.900000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.990000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.999000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.999900'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.999990'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.999999'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000001'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000002'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000003'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000004'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000005'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000006'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000007'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000008'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000009'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000010'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000011'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000012'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000013'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000014'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000015'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000016'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000099'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.000999'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.009999'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.090000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.099999'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.100000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.900000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.990000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.999000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.999900'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.999990'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.999999'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.000001'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.000008'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.000015'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.000016'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.000099'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.000999'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.009999'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.099999'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.100000'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.900000'); +INSERT INTO t1 VALUES ('0000-00-00 00:01:00.999999'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.000001'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.000008'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.000015'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.000016'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.000099'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.000999'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.009999'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.099999'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.100000'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.900000'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.990000'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.999000'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.999900'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.999990'); +INSERT INTO t1 VALUES ('0000-00-00 01:00:00.999999'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.000008'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.000015'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.000016'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.000099'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.000999'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.009999'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.099999'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.100000'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.900000'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.990000'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.999000'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.999900'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.999990'); +INSERT INTO t1 VALUES ('1001-01-01 00:00:00.999999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000001'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000008'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000015'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000016'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000099'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.009999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.099999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.100000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.900000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.990000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999900'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999990'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:59.000000'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.000001'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.000008'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.000015'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.000016'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.000099'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.000999'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.009999'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.099999'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.100000'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.900000'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.990000'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.999000'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.999900'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.999990'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:58.999999'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:59.000000'); +ALTER TABLE t1 +ADD a0 VARCHAR(32), +ADD a1 VARCHAR(32), ADD a2 VARCHAR(32), ADD a3 VARCHAR(32), +ADD a4 VARCHAR(32), ADD a5 VARCHAR(32), +ADD d0 DATETIME(0), +ADD d1 DATETIME(1), ADD d2 DATETIME(2), ADD d3 DATETIME(3), +ADD d4 DATETIME(4), ADD d5 DATETIME(5), ADD d6 DATETIME(6); +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +UPDATE t1 SET +a0= LEFT(a6, LENGTH(a6) - 6), +a1= LEFT(a6, LENGTH(a6) - 5), +a2= LEFT(a6, LENGTH(a6) - 4), +a3= LEFT(a6, LENGTH(a6) - 3), +a4= LEFT(a6, LENGTH(a6) - 2), +a5= LEFT(a6, LENGTH(a6) - 1); +UPDATE IGNORE t1 SET d0= a0, d1= a1, d2= a2, d3= a3, d4= a4, d5= a5, d6= a6; +SELECT a6, d6, HEX(WEIGHT_STRING(d6)) FROM t1 ORDER BY d6; +a6 d6 HEX(WEIGHT_STRING(d6)) +0000-00-00 00:00:00.000000 0000-00-00 00:00:00.000000 8000000000000000 +0000-00-00 00:00:00.000001 0000-00-00 00:00:00.000001 8000000000000001 +0000-00-00 00:00:00.000002 0000-00-00 00:00:00.000002 8000000000000002 +0000-00-00 00:00:00.000003 0000-00-00 00:00:00.000003 8000000000000003 +0000-00-00 00:00:00.000004 0000-00-00 00:00:00.000004 8000000000000004 +0000-00-00 00:00:00.000005 0000-00-00 00:00:00.000005 8000000000000005 +0000-00-00 00:00:00.000006 0000-00-00 00:00:00.000006 8000000000000006 +0000-00-00 00:00:00.000007 0000-00-00 00:00:00.000007 8000000000000007 +0000-00-00 00:00:00.000008 0000-00-00 00:00:00.000008 8000000000000008 +0000-00-00 00:00:00.000009 0000-00-00 00:00:00.000009 8000000000000009 +0000-00-00 00:00:00.000010 0000-00-00 00:00:00.000010 800000000000000A +0000-00-00 00:00:00.000011 0000-00-00 00:00:00.000011 800000000000000B +0000-00-00 00:00:00.000012 0000-00-00 00:00:00.000012 800000000000000C +0000-00-00 00:00:00.000013 0000-00-00 00:00:00.000013 800000000000000D +0000-00-00 00:00:00.000014 0000-00-00 00:00:00.000014 800000000000000E +0000-00-00 00:00:00.000015 0000-00-00 00:00:00.000015 800000000000000F +0000-00-00 00:00:00.000016 0000-00-00 00:00:00.000016 8000000000000010 +0000-00-00 00:00:00.000099 0000-00-00 00:00:00.000099 8000000000000063 +0000-00-00 00:00:00.000999 0000-00-00 00:00:00.000999 80000000000003E7 +0000-00-00 00:00:00.009999 0000-00-00 00:00:00.009999 800000000000270F +0000-00-00 00:00:00.099999 0000-00-00 00:00:00.099999 800000000001869F +0000-00-00 00:00:00.100000 0000-00-00 00:00:00.100000 80000000000186A0 +0000-00-00 00:00:00.900000 0000-00-00 00:00:00.900000 80000000000DBBA0 +0000-00-00 00:00:00.990000 0000-00-00 00:00:00.990000 80000000000F1B30 +0000-00-00 00:00:00.999000 0000-00-00 00:00:00.999000 80000000000F3E58 +0000-00-00 00:00:00.999900 0000-00-00 00:00:00.999900 80000000000F41DC +0000-00-00 00:00:00.999990 0000-00-00 00:00:00.999990 80000000000F4236 +0000-00-00 00:00:00.999999 0000-00-00 00:00:00.999999 80000000000F423F +0000-00-00 00:00:01.000000 0000-00-00 00:00:01.000000 8000000001000000 +0000-00-00 00:00:01.000001 0000-00-00 00:00:01.000001 8000000001000001 +0000-00-00 00:00:01.000002 0000-00-00 00:00:01.000002 8000000001000002 +0000-00-00 00:00:01.000003 0000-00-00 00:00:01.000003 8000000001000003 +0000-00-00 00:00:01.000004 0000-00-00 00:00:01.000004 8000000001000004 +0000-00-00 00:00:01.000005 0000-00-00 00:00:01.000005 8000000001000005 +0000-00-00 00:00:01.000006 0000-00-00 00:00:01.000006 8000000001000006 +0000-00-00 00:00:01.000007 0000-00-00 00:00:01.000007 8000000001000007 +0000-00-00 00:00:01.000008 0000-00-00 00:00:01.000008 8000000001000008 +0000-00-00 00:00:01.000009 0000-00-00 00:00:01.000009 8000000001000009 +0000-00-00 00:00:01.000010 0000-00-00 00:00:01.000010 800000000100000A +0000-00-00 00:00:01.000011 0000-00-00 00:00:01.000011 800000000100000B +0000-00-00 00:00:01.000012 0000-00-00 00:00:01.000012 800000000100000C +0000-00-00 00:00:01.000013 0000-00-00 00:00:01.000013 800000000100000D +0000-00-00 00:00:01.000014 0000-00-00 00:00:01.000014 800000000100000E +0000-00-00 00:00:01.000015 0000-00-00 00:00:01.000015 800000000100000F +0000-00-00 00:00:01.000016 0000-00-00 00:00:01.000016 8000000001000010 +0000-00-00 00:00:01.000099 0000-00-00 00:00:01.000099 8000000001000063 +0000-00-00 00:00:01.000999 0000-00-00 00:00:01.000999 80000000010003E7 +0000-00-00 00:00:01.009999 0000-00-00 00:00:01.009999 800000000100270F +0000-00-00 00:00:01.090000 0000-00-00 00:00:01.090000 8000000001015F90 +0000-00-00 00:00:01.099999 0000-00-00 00:00:01.099999 800000000101869F +0000-00-00 00:00:01.100000 0000-00-00 00:00:01.100000 80000000010186A0 +0000-00-00 00:00:01.900000 0000-00-00 00:00:01.900000 80000000010DBBA0 +0000-00-00 00:00:01.990000 0000-00-00 00:00:01.990000 80000000010F1B30 +0000-00-00 00:00:01.999000 0000-00-00 00:00:01.999000 80000000010F3E58 +0000-00-00 00:00:01.999900 0000-00-00 00:00:01.999900 80000000010F41DC +0000-00-00 00:00:01.999990 0000-00-00 00:00:01.999990 80000000010F4236 +0000-00-00 00:00:01.999999 0000-00-00 00:00:01.999999 80000000010F423F +0000-00-00 00:01:00.000001 0000-00-00 00:01:00.000001 8000000040000001 +0000-00-00 00:01:00.000008 0000-00-00 00:01:00.000008 8000000040000008 +0000-00-00 00:01:00.000015 0000-00-00 00:01:00.000015 800000004000000F +0000-00-00 00:01:00.000016 0000-00-00 00:01:00.000016 8000000040000010 +0000-00-00 00:01:00.000099 0000-00-00 00:01:00.000099 8000000040000063 +0000-00-00 00:01:00.000999 0000-00-00 00:01:00.000999 80000000400003E7 +0000-00-00 00:01:00.009999 0000-00-00 00:01:00.009999 800000004000270F +0000-00-00 00:01:00.099999 0000-00-00 00:01:00.099999 800000004001869F +0000-00-00 00:01:00.100000 0000-00-00 00:01:00.100000 80000000400186A0 +0000-00-00 00:01:00.900000 0000-00-00 00:01:00.900000 80000000400DBBA0 +0000-00-00 00:01:00.999999 0000-00-00 00:01:00.999999 80000000400F423F +0000-00-00 01:00:00.000001 0000-00-00 01:00:00.000001 8000001000000001 +0000-00-00 01:00:00.000008 0000-00-00 01:00:00.000008 8000001000000008 +0000-00-00 01:00:00.000015 0000-00-00 01:00:00.000015 800000100000000F +0000-00-00 01:00:00.000016 0000-00-00 01:00:00.000016 8000001000000010 +0000-00-00 01:00:00.000099 0000-00-00 01:00:00.000099 8000001000000063 +0000-00-00 01:00:00.000999 0000-00-00 01:00:00.000999 80000010000003E7 +0000-00-00 01:00:00.009999 0000-00-00 01:00:00.009999 800000100000270F +0000-00-00 01:00:00.099999 0000-00-00 01:00:00.099999 800000100001869F +0000-00-00 01:00:00.100000 0000-00-00 01:00:00.100000 80000010000186A0 +0000-00-00 01:00:00.900000 0000-00-00 01:00:00.900000 80000010000DBBA0 +0000-00-00 01:00:00.990000 0000-00-00 01:00:00.990000 80000010000F1B30 +0000-00-00 01:00:00.999000 0000-00-00 01:00:00.999000 80000010000F3E58 +0000-00-00 01:00:00.999900 0000-00-00 01:00:00.999900 80000010000F41DC +0000-00-00 01:00:00.999990 0000-00-00 01:00:00.999990 80000010000F4236 +0000-00-00 01:00:00.999999 0000-00-00 01:00:00.999999 80000010000F423F +1001-01-01 00:00:00.000001 1001-01-01 00:00:00.000001 8CB5820000000001 +1001-01-01 00:00:00.000008 1001-01-01 00:00:00.000008 8CB5820000000008 +1001-01-01 00:00:00.000015 1001-01-01 00:00:00.000015 8CB582000000000F +1001-01-01 00:00:00.000016 1001-01-01 00:00:00.000016 8CB5820000000010 +1001-01-01 00:00:00.000099 1001-01-01 00:00:00.000099 8CB5820000000063 +1001-01-01 00:00:00.000999 1001-01-01 00:00:00.000999 8CB58200000003E7 +1001-01-01 00:00:00.009999 1001-01-01 00:00:00.009999 8CB582000000270F +1001-01-01 00:00:00.099999 1001-01-01 00:00:00.099999 8CB582000001869F +1001-01-01 00:00:00.100000 1001-01-01 00:00:00.100000 8CB58200000186A0 +1001-01-01 00:00:00.900000 1001-01-01 00:00:00.900000 8CB58200000DBBA0 +1001-01-01 00:00:00.990000 1001-01-01 00:00:00.990000 8CB58200000F1B30 +1001-01-01 00:00:00.999000 1001-01-01 00:00:00.999000 8CB58200000F3E58 +1001-01-01 00:00:00.999900 1001-01-01 00:00:00.999900 8CB58200000F41DC +1001-01-01 00:00:00.999990 1001-01-01 00:00:00.999990 8CB58200000F4236 +1001-01-01 00:00:00.999999 1001-01-01 00:00:00.999999 8CB58200000F423F +2001-01-01 23:59:58.000001 2001-01-01 23:59:58.000001 9967837EFA000001 +2001-01-01 23:59:58.000008 2001-01-01 23:59:58.000008 9967837EFA000008 +2001-01-01 23:59:58.000015 2001-01-01 23:59:58.000015 9967837EFA00000F +2001-01-01 23:59:58.000016 2001-01-01 23:59:58.000016 9967837EFA000010 +2001-01-01 23:59:58.000099 2001-01-01 23:59:58.000099 9967837EFA000063 +2001-01-01 23:59:58.000999 2001-01-01 23:59:58.000999 9967837EFA0003E7 +2001-01-01 23:59:58.009999 2001-01-01 23:59:58.009999 9967837EFA00270F +2001-01-01 23:59:58.099999 2001-01-01 23:59:58.099999 9967837EFA01869F +2001-01-01 23:59:58.100000 2001-01-01 23:59:58.100000 9967837EFA0186A0 +2001-01-01 23:59:58.900000 2001-01-01 23:59:58.900000 9967837EFA0DBBA0 +2001-01-01 23:59:58.990000 2001-01-01 23:59:58.990000 9967837EFA0F1B30 +2001-01-01 23:59:58.999000 2001-01-01 23:59:58.999000 9967837EFA0F3E58 +2001-01-01 23:59:58.999900 2001-01-01 23:59:58.999900 9967837EFA0F41DC +2001-01-01 23:59:58.999990 2001-01-01 23:59:58.999990 9967837EFA0F4236 +2001-01-01 23:59:58.999999 2001-01-01 23:59:58.999999 9967837EFA0F423F +2001-01-01 23:59:59.000000 2001-01-01 23:59:59.000000 9967837EFB000000 +9999-12-31 23:59:58.000001 9999-12-31 23:59:58.000001 FEF3FF7EFA000001 +9999-12-31 23:59:58.000008 9999-12-31 23:59:58.000008 FEF3FF7EFA000008 +9999-12-31 23:59:58.000015 9999-12-31 23:59:58.000015 FEF3FF7EFA00000F +9999-12-31 23:59:58.000016 9999-12-31 23:59:58.000016 FEF3FF7EFA000010 +9999-12-31 23:59:58.000099 9999-12-31 23:59:58.000099 FEF3FF7EFA000063 +9999-12-31 23:59:58.000999 9999-12-31 23:59:58.000999 FEF3FF7EFA0003E7 +9999-12-31 23:59:58.009999 9999-12-31 23:59:58.009999 FEF3FF7EFA00270F +9999-12-31 23:59:58.099999 9999-12-31 23:59:58.099999 FEF3FF7EFA01869F +9999-12-31 23:59:58.100000 9999-12-31 23:59:58.100000 FEF3FF7EFA0186A0 +9999-12-31 23:59:58.900000 9999-12-31 23:59:58.900000 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.990000 9999-12-31 23:59:58.990000 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.999000 9999-12-31 23:59:58.999000 FEF3FF7EFA0F3E58 +9999-12-31 23:59:58.999900 9999-12-31 23:59:58.999900 FEF3FF7EFA0F41DC +9999-12-31 23:59:58.999990 9999-12-31 23:59:58.999990 FEF3FF7EFA0F4236 +9999-12-31 23:59:58.999999 9999-12-31 23:59:58.999999 FEF3FF7EFA0F423F +9999-12-31 23:59:59.000000 9999-12-31 23:59:59.000000 FEF3FF7EFB000000 +SELECT a5, d5, HEX(WEIGHT_STRING(d5)) FROM t1 ORDER BY d5, a6; +a5 d5 HEX(WEIGHT_STRING(d5)) +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00000 0000-00-00 00:00:00.00000 8000000000000000 +0000-00-00 00:00:00.00001 0000-00-00 00:00:00.00001 800000000000000A +0000-00-00 00:00:00.00001 0000-00-00 00:00:00.00001 800000000000000A +0000-00-00 00:00:00.00001 0000-00-00 00:00:00.00001 800000000000000A +0000-00-00 00:00:00.00001 0000-00-00 00:00:00.00001 800000000000000A +0000-00-00 00:00:00.00001 0000-00-00 00:00:00.00001 800000000000000A +0000-00-00 00:00:00.00001 0000-00-00 00:00:00.00001 800000000000000A +0000-00-00 00:00:00.00001 0000-00-00 00:00:00.00001 800000000000000A +0000-00-00 00:00:00.00009 0000-00-00 00:00:00.00009 800000000000005A +0000-00-00 00:00:00.00099 0000-00-00 00:00:00.00099 80000000000003DE +0000-00-00 00:00:00.00999 0000-00-00 00:00:00.00999 8000000000002706 +0000-00-00 00:00:00.09999 0000-00-00 00:00:00.09999 8000000000018696 +0000-00-00 00:00:00.10000 0000-00-00 00:00:00.10000 80000000000186A0 +0000-00-00 00:00:00.90000 0000-00-00 00:00:00.90000 80000000000DBBA0 +0000-00-00 00:00:00.99000 0000-00-00 00:00:00.99000 80000000000F1B30 +0000-00-00 00:00:00.99900 0000-00-00 00:00:00.99900 80000000000F3E58 +0000-00-00 00:00:00.99990 0000-00-00 00:00:00.99990 80000000000F41DC +0000-00-00 00:00:00.99999 0000-00-00 00:00:00.99999 80000000000F4236 +0000-00-00 00:00:00.99999 0000-00-00 00:00:00.99999 80000000000F4236 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00000 0000-00-00 00:00:01.00000 8000000001000000 +0000-00-00 00:00:01.00001 0000-00-00 00:00:01.00001 800000000100000A +0000-00-00 00:00:01.00001 0000-00-00 00:00:01.00001 800000000100000A +0000-00-00 00:00:01.00001 0000-00-00 00:00:01.00001 800000000100000A +0000-00-00 00:00:01.00001 0000-00-00 00:00:01.00001 800000000100000A +0000-00-00 00:00:01.00001 0000-00-00 00:00:01.00001 800000000100000A +0000-00-00 00:00:01.00001 0000-00-00 00:00:01.00001 800000000100000A +0000-00-00 00:00:01.00001 0000-00-00 00:00:01.00001 800000000100000A +0000-00-00 00:00:01.00009 0000-00-00 00:00:01.00009 800000000100005A +0000-00-00 00:00:01.00099 0000-00-00 00:00:01.00099 80000000010003DE +0000-00-00 00:00:01.00999 0000-00-00 00:00:01.00999 8000000001002706 +0000-00-00 00:00:01.09000 0000-00-00 00:00:01.09000 8000000001015F90 +0000-00-00 00:00:01.09999 0000-00-00 00:00:01.09999 8000000001018696 +0000-00-00 00:00:01.10000 0000-00-00 00:00:01.10000 80000000010186A0 +0000-00-00 00:00:01.90000 0000-00-00 00:00:01.90000 80000000010DBBA0 +0000-00-00 00:00:01.99000 0000-00-00 00:00:01.99000 80000000010F1B30 +0000-00-00 00:00:01.99900 0000-00-00 00:00:01.99900 80000000010F3E58 +0000-00-00 00:00:01.99990 0000-00-00 00:00:01.99990 80000000010F41DC +0000-00-00 00:00:01.99999 0000-00-00 00:00:01.99999 80000000010F4236 +0000-00-00 00:00:01.99999 0000-00-00 00:00:01.99999 80000000010F4236 +0000-00-00 00:01:00.00000 0000-00-00 00:01:00.00000 8000000040000000 +0000-00-00 00:01:00.00000 0000-00-00 00:01:00.00000 8000000040000000 +0000-00-00 00:01:00.00001 0000-00-00 00:01:00.00001 800000004000000A +0000-00-00 00:01:00.00001 0000-00-00 00:01:00.00001 800000004000000A +0000-00-00 00:01:00.00009 0000-00-00 00:01:00.00009 800000004000005A +0000-00-00 00:01:00.00099 0000-00-00 00:01:00.00099 80000000400003DE +0000-00-00 00:01:00.00999 0000-00-00 00:01:00.00999 8000000040002706 +0000-00-00 00:01:00.09999 0000-00-00 00:01:00.09999 8000000040018696 +0000-00-00 00:01:00.10000 0000-00-00 00:01:00.10000 80000000400186A0 +0000-00-00 00:01:00.90000 0000-00-00 00:01:00.90000 80000000400DBBA0 +0000-00-00 00:01:00.99999 0000-00-00 00:01:00.99999 80000000400F4236 +0000-00-00 01:00:00.00000 0000-00-00 01:00:00.00000 8000001000000000 +0000-00-00 01:00:00.00000 0000-00-00 01:00:00.00000 8000001000000000 +0000-00-00 01:00:00.00001 0000-00-00 01:00:00.00001 800000100000000A +0000-00-00 01:00:00.00001 0000-00-00 01:00:00.00001 800000100000000A +0000-00-00 01:00:00.00009 0000-00-00 01:00:00.00009 800000100000005A +0000-00-00 01:00:00.00099 0000-00-00 01:00:00.00099 80000010000003DE +0000-00-00 01:00:00.00999 0000-00-00 01:00:00.00999 8000001000002706 +0000-00-00 01:00:00.09999 0000-00-00 01:00:00.09999 8000001000018696 +0000-00-00 01:00:00.10000 0000-00-00 01:00:00.10000 80000010000186A0 +0000-00-00 01:00:00.90000 0000-00-00 01:00:00.90000 80000010000DBBA0 +0000-00-00 01:00:00.99000 0000-00-00 01:00:00.99000 80000010000F1B30 +0000-00-00 01:00:00.99900 0000-00-00 01:00:00.99900 80000010000F3E58 +0000-00-00 01:00:00.99990 0000-00-00 01:00:00.99990 80000010000F41DC +0000-00-00 01:00:00.99999 0000-00-00 01:00:00.99999 80000010000F4236 +0000-00-00 01:00:00.99999 0000-00-00 01:00:00.99999 80000010000F4236 +1001-01-01 00:00:00.00000 1001-01-01 00:00:00.00000 8CB5820000000000 +1001-01-01 00:00:00.00000 1001-01-01 00:00:00.00000 8CB5820000000000 +1001-01-01 00:00:00.00001 1001-01-01 00:00:00.00001 8CB582000000000A +1001-01-01 00:00:00.00001 1001-01-01 00:00:00.00001 8CB582000000000A +1001-01-01 00:00:00.00009 1001-01-01 00:00:00.00009 8CB582000000005A +1001-01-01 00:00:00.00099 1001-01-01 00:00:00.00099 8CB58200000003DE +1001-01-01 00:00:00.00999 1001-01-01 00:00:00.00999 8CB5820000002706 +1001-01-01 00:00:00.09999 1001-01-01 00:00:00.09999 8CB5820000018696 +1001-01-01 00:00:00.10000 1001-01-01 00:00:00.10000 8CB58200000186A0 +1001-01-01 00:00:00.90000 1001-01-01 00:00:00.90000 8CB58200000DBBA0 +1001-01-01 00:00:00.99000 1001-01-01 00:00:00.99000 8CB58200000F1B30 +1001-01-01 00:00:00.99900 1001-01-01 00:00:00.99900 8CB58200000F3E58 +1001-01-01 00:00:00.99990 1001-01-01 00:00:00.99990 8CB58200000F41DC +1001-01-01 00:00:00.99999 1001-01-01 00:00:00.99999 8CB58200000F4236 +1001-01-01 00:00:00.99999 1001-01-01 00:00:00.99999 8CB58200000F4236 +2001-01-01 23:59:58.00000 2001-01-01 23:59:58.00000 9967837EFA000000 +2001-01-01 23:59:58.00000 2001-01-01 23:59:58.00000 9967837EFA000000 +2001-01-01 23:59:58.00001 2001-01-01 23:59:58.00001 9967837EFA00000A +2001-01-01 23:59:58.00001 2001-01-01 23:59:58.00001 9967837EFA00000A +2001-01-01 23:59:58.00009 2001-01-01 23:59:58.00009 9967837EFA00005A +2001-01-01 23:59:58.00099 2001-01-01 23:59:58.00099 9967837EFA0003DE +2001-01-01 23:59:58.00999 2001-01-01 23:59:58.00999 9967837EFA002706 +2001-01-01 23:59:58.09999 2001-01-01 23:59:58.09999 9967837EFA018696 +2001-01-01 23:59:58.10000 2001-01-01 23:59:58.10000 9967837EFA0186A0 +2001-01-01 23:59:58.90000 2001-01-01 23:59:58.90000 9967837EFA0DBBA0 +2001-01-01 23:59:58.99000 2001-01-01 23:59:58.99000 9967837EFA0F1B30 +2001-01-01 23:59:58.99900 2001-01-01 23:59:58.99900 9967837EFA0F3E58 +2001-01-01 23:59:58.99990 2001-01-01 23:59:58.99990 9967837EFA0F41DC +2001-01-01 23:59:58.99999 2001-01-01 23:59:58.99999 9967837EFA0F4236 +2001-01-01 23:59:58.99999 2001-01-01 23:59:58.99999 9967837EFA0F4236 +2001-01-01 23:59:59.00000 2001-01-01 23:59:59.00000 9967837EFB000000 +9999-12-31 23:59:58.00000 9999-12-31 23:59:58.00000 FEF3FF7EFA000000 +9999-12-31 23:59:58.00000 9999-12-31 23:59:58.00000 FEF3FF7EFA000000 +9999-12-31 23:59:58.00001 9999-12-31 23:59:58.00001 FEF3FF7EFA00000A +9999-12-31 23:59:58.00001 9999-12-31 23:59:58.00001 FEF3FF7EFA00000A +9999-12-31 23:59:58.00009 9999-12-31 23:59:58.00009 FEF3FF7EFA00005A +9999-12-31 23:59:58.00099 9999-12-31 23:59:58.00099 FEF3FF7EFA0003DE +9999-12-31 23:59:58.00999 9999-12-31 23:59:58.00999 FEF3FF7EFA002706 +9999-12-31 23:59:58.09999 9999-12-31 23:59:58.09999 FEF3FF7EFA018696 +9999-12-31 23:59:58.10000 9999-12-31 23:59:58.10000 FEF3FF7EFA0186A0 +9999-12-31 23:59:58.90000 9999-12-31 23:59:58.90000 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.99000 9999-12-31 23:59:58.99000 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.99900 9999-12-31 23:59:58.99900 FEF3FF7EFA0F3E58 +9999-12-31 23:59:58.99990 9999-12-31 23:59:58.99990 FEF3FF7EFA0F41DC +9999-12-31 23:59:58.99999 9999-12-31 23:59:58.99999 FEF3FF7EFA0F4236 +9999-12-31 23:59:58.99999 9999-12-31 23:59:58.99999 FEF3FF7EFA0F4236 +9999-12-31 23:59:59.00000 9999-12-31 23:59:59.00000 FEF3FF7EFB000000 +SELECT a4, d4, HEX(WEIGHT_STRING(d4)) FROM t1 ORDER BY d4, a6; +a4 d4 HEX(WEIGHT_STRING(d4)) +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0000 0000-00-00 00:00:00.0000 8000000000000000 +0000-00-00 00:00:00.0009 0000-00-00 00:00:00.0009 8000000000000384 +0000-00-00 00:00:00.0099 0000-00-00 00:00:00.0099 80000000000026AC +0000-00-00 00:00:00.0999 0000-00-00 00:00:00.0999 800000000001863C +0000-00-00 00:00:00.1000 0000-00-00 00:00:00.1000 80000000000186A0 +0000-00-00 00:00:00.9000 0000-00-00 00:00:00.9000 80000000000DBBA0 +0000-00-00 00:00:00.9900 0000-00-00 00:00:00.9900 80000000000F1B30 +0000-00-00 00:00:00.9990 0000-00-00 00:00:00.9990 80000000000F3E58 +0000-00-00 00:00:00.9999 0000-00-00 00:00:00.9999 80000000000F41DC +0000-00-00 00:00:00.9999 0000-00-00 00:00:00.9999 80000000000F41DC +0000-00-00 00:00:00.9999 0000-00-00 00:00:00.9999 80000000000F41DC +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0000 0000-00-00 00:00:01.0000 8000000001000000 +0000-00-00 00:00:01.0009 0000-00-00 00:00:01.0009 8000000001000384 +0000-00-00 00:00:01.0099 0000-00-00 00:00:01.0099 80000000010026AC +0000-00-00 00:00:01.0900 0000-00-00 00:00:01.0900 8000000001015F90 +0000-00-00 00:00:01.0999 0000-00-00 00:00:01.0999 800000000101863C +0000-00-00 00:00:01.1000 0000-00-00 00:00:01.1000 80000000010186A0 +0000-00-00 00:00:01.9000 0000-00-00 00:00:01.9000 80000000010DBBA0 +0000-00-00 00:00:01.9900 0000-00-00 00:00:01.9900 80000000010F1B30 +0000-00-00 00:00:01.9990 0000-00-00 00:00:01.9990 80000000010F3E58 +0000-00-00 00:00:01.9999 0000-00-00 00:00:01.9999 80000000010F41DC +0000-00-00 00:00:01.9999 0000-00-00 00:00:01.9999 80000000010F41DC +0000-00-00 00:00:01.9999 0000-00-00 00:00:01.9999 80000000010F41DC +0000-00-00 00:01:00.0000 0000-00-00 00:01:00.0000 8000000040000000 +0000-00-00 00:01:00.0000 0000-00-00 00:01:00.0000 8000000040000000 +0000-00-00 00:01:00.0000 0000-00-00 00:01:00.0000 8000000040000000 +0000-00-00 00:01:00.0000 0000-00-00 00:01:00.0000 8000000040000000 +0000-00-00 00:01:00.0000 0000-00-00 00:01:00.0000 8000000040000000 +0000-00-00 00:01:00.0009 0000-00-00 00:01:00.0009 8000000040000384 +0000-00-00 00:01:00.0099 0000-00-00 00:01:00.0099 80000000400026AC +0000-00-00 00:01:00.0999 0000-00-00 00:01:00.0999 800000004001863C +0000-00-00 00:01:00.1000 0000-00-00 00:01:00.1000 80000000400186A0 +0000-00-00 00:01:00.9000 0000-00-00 00:01:00.9000 80000000400DBBA0 +0000-00-00 00:01:00.9999 0000-00-00 00:01:00.9999 80000000400F41DC +0000-00-00 01:00:00.0000 0000-00-00 01:00:00.0000 8000001000000000 +0000-00-00 01:00:00.0000 0000-00-00 01:00:00.0000 8000001000000000 +0000-00-00 01:00:00.0000 0000-00-00 01:00:00.0000 8000001000000000 +0000-00-00 01:00:00.0000 0000-00-00 01:00:00.0000 8000001000000000 +0000-00-00 01:00:00.0000 0000-00-00 01:00:00.0000 8000001000000000 +0000-00-00 01:00:00.0009 0000-00-00 01:00:00.0009 8000001000000384 +0000-00-00 01:00:00.0099 0000-00-00 01:00:00.0099 80000010000026AC +0000-00-00 01:00:00.0999 0000-00-00 01:00:00.0999 800000100001863C +0000-00-00 01:00:00.1000 0000-00-00 01:00:00.1000 80000010000186A0 +0000-00-00 01:00:00.9000 0000-00-00 01:00:00.9000 80000010000DBBA0 +0000-00-00 01:00:00.9900 0000-00-00 01:00:00.9900 80000010000F1B30 +0000-00-00 01:00:00.9990 0000-00-00 01:00:00.9990 80000010000F3E58 +0000-00-00 01:00:00.9999 0000-00-00 01:00:00.9999 80000010000F41DC +0000-00-00 01:00:00.9999 0000-00-00 01:00:00.9999 80000010000F41DC +0000-00-00 01:00:00.9999 0000-00-00 01:00:00.9999 80000010000F41DC +1001-01-01 00:00:00.0000 1001-01-01 00:00:00.0000 8CB5820000000000 +1001-01-01 00:00:00.0000 1001-01-01 00:00:00.0000 8CB5820000000000 +1001-01-01 00:00:00.0000 1001-01-01 00:00:00.0000 8CB5820000000000 +1001-01-01 00:00:00.0000 1001-01-01 00:00:00.0000 8CB5820000000000 +1001-01-01 00:00:00.0000 1001-01-01 00:00:00.0000 8CB5820000000000 +1001-01-01 00:00:00.0009 1001-01-01 00:00:00.0009 8CB5820000000384 +1001-01-01 00:00:00.0099 1001-01-01 00:00:00.0099 8CB58200000026AC +1001-01-01 00:00:00.0999 1001-01-01 00:00:00.0999 8CB582000001863C +1001-01-01 00:00:00.1000 1001-01-01 00:00:00.1000 8CB58200000186A0 +1001-01-01 00:00:00.9000 1001-01-01 00:00:00.9000 8CB58200000DBBA0 +1001-01-01 00:00:00.9900 1001-01-01 00:00:00.9900 8CB58200000F1B30 +1001-01-01 00:00:00.9990 1001-01-01 00:00:00.9990 8CB58200000F3E58 +1001-01-01 00:00:00.9999 1001-01-01 00:00:00.9999 8CB58200000F41DC +1001-01-01 00:00:00.9999 1001-01-01 00:00:00.9999 8CB58200000F41DC +1001-01-01 00:00:00.9999 1001-01-01 00:00:00.9999 8CB58200000F41DC +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0009 2001-01-01 23:59:58.0009 9967837EFA000384 +2001-01-01 23:59:58.0099 2001-01-01 23:59:58.0099 9967837EFA0026AC +2001-01-01 23:59:58.0999 2001-01-01 23:59:58.0999 9967837EFA01863C +2001-01-01 23:59:58.1000 2001-01-01 23:59:58.1000 9967837EFA0186A0 +2001-01-01 23:59:58.9000 2001-01-01 23:59:58.9000 9967837EFA0DBBA0 +2001-01-01 23:59:58.9900 2001-01-01 23:59:58.9900 9967837EFA0F1B30 +2001-01-01 23:59:58.9990 2001-01-01 23:59:58.9990 9967837EFA0F3E58 +2001-01-01 23:59:58.9999 2001-01-01 23:59:58.9999 9967837EFA0F41DC +2001-01-01 23:59:58.9999 2001-01-01 23:59:58.9999 9967837EFA0F41DC +2001-01-01 23:59:58.9999 2001-01-01 23:59:58.9999 9967837EFA0F41DC +2001-01-01 23:59:59.0000 2001-01-01 23:59:59.0000 9967837EFB000000 +9999-12-31 23:59:58.0000 9999-12-31 23:59:58.0000 FEF3FF7EFA000000 +9999-12-31 23:59:58.0000 9999-12-31 23:59:58.0000 FEF3FF7EFA000000 +9999-12-31 23:59:58.0000 9999-12-31 23:59:58.0000 FEF3FF7EFA000000 +9999-12-31 23:59:58.0000 9999-12-31 23:59:58.0000 FEF3FF7EFA000000 +9999-12-31 23:59:58.0000 9999-12-31 23:59:58.0000 FEF3FF7EFA000000 +9999-12-31 23:59:58.0009 9999-12-31 23:59:58.0009 FEF3FF7EFA000384 +9999-12-31 23:59:58.0099 9999-12-31 23:59:58.0099 FEF3FF7EFA0026AC +9999-12-31 23:59:58.0999 9999-12-31 23:59:58.0999 FEF3FF7EFA01863C +9999-12-31 23:59:58.1000 9999-12-31 23:59:58.1000 FEF3FF7EFA0186A0 +9999-12-31 23:59:58.9000 9999-12-31 23:59:58.9000 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.9900 9999-12-31 23:59:58.9900 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.9990 9999-12-31 23:59:58.9990 FEF3FF7EFA0F3E58 +9999-12-31 23:59:58.9999 9999-12-31 23:59:58.9999 FEF3FF7EFA0F41DC +9999-12-31 23:59:58.9999 9999-12-31 23:59:58.9999 FEF3FF7EFA0F41DC +9999-12-31 23:59:58.9999 9999-12-31 23:59:58.9999 FEF3FF7EFA0F41DC +9999-12-31 23:59:59.0000 9999-12-31 23:59:59.0000 FEF3FF7EFB000000 +SELECT a3, d3, HEX(WEIGHT_STRING(d3)) FROM t1 ORDER BY d3, a6; +a3 d3 HEX(WEIGHT_STRING(d3)) +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.000 0000-00-00 00:00:00.000 8000000000000000 +0000-00-00 00:00:00.009 0000-00-00 00:00:00.009 8000000000002328 +0000-00-00 00:00:00.099 0000-00-00 00:00:00.099 80000000000182B8 +0000-00-00 00:00:00.100 0000-00-00 00:00:00.100 80000000000186A0 +0000-00-00 00:00:00.900 0000-00-00 00:00:00.900 80000000000DBBA0 +0000-00-00 00:00:00.990 0000-00-00 00:00:00.990 80000000000F1B30 +0000-00-00 00:00:00.999 0000-00-00 00:00:00.999 80000000000F3E58 +0000-00-00 00:00:00.999 0000-00-00 00:00:00.999 80000000000F3E58 +0000-00-00 00:00:00.999 0000-00-00 00:00:00.999 80000000000F3E58 +0000-00-00 00:00:00.999 0000-00-00 00:00:00.999 80000000000F3E58 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.000 0000-00-00 00:00:01.000 8000000001000000 +0000-00-00 00:00:01.009 0000-00-00 00:00:01.009 8000000001002328 +0000-00-00 00:00:01.090 0000-00-00 00:00:01.090 8000000001015F90 +0000-00-00 00:00:01.099 0000-00-00 00:00:01.099 80000000010182B8 +0000-00-00 00:00:01.100 0000-00-00 00:00:01.100 80000000010186A0 +0000-00-00 00:00:01.900 0000-00-00 00:00:01.900 80000000010DBBA0 +0000-00-00 00:00:01.990 0000-00-00 00:00:01.990 80000000010F1B30 +0000-00-00 00:00:01.999 0000-00-00 00:00:01.999 80000000010F3E58 +0000-00-00 00:00:01.999 0000-00-00 00:00:01.999 80000000010F3E58 +0000-00-00 00:00:01.999 0000-00-00 00:00:01.999 80000000010F3E58 +0000-00-00 00:00:01.999 0000-00-00 00:00:01.999 80000000010F3E58 +0000-00-00 00:01:00.000 0000-00-00 00:01:00.000 8000000040000000 +0000-00-00 00:01:00.000 0000-00-00 00:01:00.000 8000000040000000 +0000-00-00 00:01:00.000 0000-00-00 00:01:00.000 8000000040000000 +0000-00-00 00:01:00.000 0000-00-00 00:01:00.000 8000000040000000 +0000-00-00 00:01:00.000 0000-00-00 00:01:00.000 8000000040000000 +0000-00-00 00:01:00.000 0000-00-00 00:01:00.000 8000000040000000 +0000-00-00 00:01:00.009 0000-00-00 00:01:00.009 8000000040002328 +0000-00-00 00:01:00.099 0000-00-00 00:01:00.099 80000000400182B8 +0000-00-00 00:01:00.100 0000-00-00 00:01:00.100 80000000400186A0 +0000-00-00 00:01:00.900 0000-00-00 00:01:00.900 80000000400DBBA0 +0000-00-00 00:01:00.999 0000-00-00 00:01:00.999 80000000400F3E58 +0000-00-00 01:00:00.000 0000-00-00 01:00:00.000 8000001000000000 +0000-00-00 01:00:00.000 0000-00-00 01:00:00.000 8000001000000000 +0000-00-00 01:00:00.000 0000-00-00 01:00:00.000 8000001000000000 +0000-00-00 01:00:00.000 0000-00-00 01:00:00.000 8000001000000000 +0000-00-00 01:00:00.000 0000-00-00 01:00:00.000 8000001000000000 +0000-00-00 01:00:00.000 0000-00-00 01:00:00.000 8000001000000000 +0000-00-00 01:00:00.009 0000-00-00 01:00:00.009 8000001000002328 +0000-00-00 01:00:00.099 0000-00-00 01:00:00.099 80000010000182B8 +0000-00-00 01:00:00.100 0000-00-00 01:00:00.100 80000010000186A0 +0000-00-00 01:00:00.900 0000-00-00 01:00:00.900 80000010000DBBA0 +0000-00-00 01:00:00.990 0000-00-00 01:00:00.990 80000010000F1B30 +0000-00-00 01:00:00.999 0000-00-00 01:00:00.999 80000010000F3E58 +0000-00-00 01:00:00.999 0000-00-00 01:00:00.999 80000010000F3E58 +0000-00-00 01:00:00.999 0000-00-00 01:00:00.999 80000010000F3E58 +0000-00-00 01:00:00.999 0000-00-00 01:00:00.999 80000010000F3E58 +1001-01-01 00:00:00.000 1001-01-01 00:00:00.000 8CB5820000000000 +1001-01-01 00:00:00.000 1001-01-01 00:00:00.000 8CB5820000000000 +1001-01-01 00:00:00.000 1001-01-01 00:00:00.000 8CB5820000000000 +1001-01-01 00:00:00.000 1001-01-01 00:00:00.000 8CB5820000000000 +1001-01-01 00:00:00.000 1001-01-01 00:00:00.000 8CB5820000000000 +1001-01-01 00:00:00.000 1001-01-01 00:00:00.000 8CB5820000000000 +1001-01-01 00:00:00.009 1001-01-01 00:00:00.009 8CB5820000002328 +1001-01-01 00:00:00.099 1001-01-01 00:00:00.099 8CB58200000182B8 +1001-01-01 00:00:00.100 1001-01-01 00:00:00.100 8CB58200000186A0 +1001-01-01 00:00:00.900 1001-01-01 00:00:00.900 8CB58200000DBBA0 +1001-01-01 00:00:00.990 1001-01-01 00:00:00.990 8CB58200000F1B30 +1001-01-01 00:00:00.999 1001-01-01 00:00:00.999 8CB58200000F3E58 +1001-01-01 00:00:00.999 1001-01-01 00:00:00.999 8CB58200000F3E58 +1001-01-01 00:00:00.999 1001-01-01 00:00:00.999 8CB58200000F3E58 +1001-01-01 00:00:00.999 1001-01-01 00:00:00.999 8CB58200000F3E58 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.009 2001-01-01 23:59:58.009 9967837EFA002328 +2001-01-01 23:59:58.099 2001-01-01 23:59:58.099 9967837EFA0182B8 +2001-01-01 23:59:58.100 2001-01-01 23:59:58.100 9967837EFA0186A0 +2001-01-01 23:59:58.900 2001-01-01 23:59:58.900 9967837EFA0DBBA0 +2001-01-01 23:59:58.990 2001-01-01 23:59:58.990 9967837EFA0F1B30 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:59.000 2001-01-01 23:59:59.000 9967837EFB000000 +9999-12-31 23:59:58.000 9999-12-31 23:59:58.000 FEF3FF7EFA000000 +9999-12-31 23:59:58.000 9999-12-31 23:59:58.000 FEF3FF7EFA000000 +9999-12-31 23:59:58.000 9999-12-31 23:59:58.000 FEF3FF7EFA000000 +9999-12-31 23:59:58.000 9999-12-31 23:59:58.000 FEF3FF7EFA000000 +9999-12-31 23:59:58.000 9999-12-31 23:59:58.000 FEF3FF7EFA000000 +9999-12-31 23:59:58.000 9999-12-31 23:59:58.000 FEF3FF7EFA000000 +9999-12-31 23:59:58.009 9999-12-31 23:59:58.009 FEF3FF7EFA002328 +9999-12-31 23:59:58.099 9999-12-31 23:59:58.099 FEF3FF7EFA0182B8 +9999-12-31 23:59:58.100 9999-12-31 23:59:58.100 FEF3FF7EFA0186A0 +9999-12-31 23:59:58.900 9999-12-31 23:59:58.900 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.990 9999-12-31 23:59:58.990 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.999 9999-12-31 23:59:58.999 FEF3FF7EFA0F3E58 +9999-12-31 23:59:58.999 9999-12-31 23:59:58.999 FEF3FF7EFA0F3E58 +9999-12-31 23:59:58.999 9999-12-31 23:59:58.999 FEF3FF7EFA0F3E58 +9999-12-31 23:59:58.999 9999-12-31 23:59:58.999 FEF3FF7EFA0F3E58 +9999-12-31 23:59:59.000 9999-12-31 23:59:59.000 FEF3FF7EFB000000 +SELECT a2, d2, HEX(WEIGHT_STRING(d2)) FROM t1 ORDER BY d2, a6; +a2 d2 HEX(WEIGHT_STRING(d2)) +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.00 0000-00-00 00:00:00.00 8000000000000000 +0000-00-00 00:00:00.09 0000-00-00 00:00:00.09 8000000000015F90 +0000-00-00 00:00:00.10 0000-00-00 00:00:00.10 80000000000186A0 +0000-00-00 00:00:00.90 0000-00-00 00:00:00.90 80000000000DBBA0 +0000-00-00 00:00:00.99 0000-00-00 00:00:00.99 80000000000F1B30 +0000-00-00 00:00:00.99 0000-00-00 00:00:00.99 80000000000F1B30 +0000-00-00 00:00:00.99 0000-00-00 00:00:00.99 80000000000F1B30 +0000-00-00 00:00:00.99 0000-00-00 00:00:00.99 80000000000F1B30 +0000-00-00 00:00:00.99 0000-00-00 00:00:00.99 80000000000F1B30 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.00 0000-00-00 00:00:01.00 8000000001000000 +0000-00-00 00:00:01.09 0000-00-00 00:00:01.09 8000000001015F90 +0000-00-00 00:00:01.09 0000-00-00 00:00:01.09 8000000001015F90 +0000-00-00 00:00:01.10 0000-00-00 00:00:01.10 80000000010186A0 +0000-00-00 00:00:01.90 0000-00-00 00:00:01.90 80000000010DBBA0 +0000-00-00 00:00:01.99 0000-00-00 00:00:01.99 80000000010F1B30 +0000-00-00 00:00:01.99 0000-00-00 00:00:01.99 80000000010F1B30 +0000-00-00 00:00:01.99 0000-00-00 00:00:01.99 80000000010F1B30 +0000-00-00 00:00:01.99 0000-00-00 00:00:01.99 80000000010F1B30 +0000-00-00 00:00:01.99 0000-00-00 00:00:01.99 80000000010F1B30 +0000-00-00 00:01:00.00 0000-00-00 00:01:00.00 8000000040000000 +0000-00-00 00:01:00.00 0000-00-00 00:01:00.00 8000000040000000 +0000-00-00 00:01:00.00 0000-00-00 00:01:00.00 8000000040000000 +0000-00-00 00:01:00.00 0000-00-00 00:01:00.00 8000000040000000 +0000-00-00 00:01:00.00 0000-00-00 00:01:00.00 8000000040000000 +0000-00-00 00:01:00.00 0000-00-00 00:01:00.00 8000000040000000 +0000-00-00 00:01:00.00 0000-00-00 00:01:00.00 8000000040000000 +0000-00-00 00:01:00.09 0000-00-00 00:01:00.09 8000000040015F90 +0000-00-00 00:01:00.10 0000-00-00 00:01:00.10 80000000400186A0 +0000-00-00 00:01:00.90 0000-00-00 00:01:00.90 80000000400DBBA0 +0000-00-00 00:01:00.99 0000-00-00 00:01:00.99 80000000400F1B30 +0000-00-00 01:00:00.00 0000-00-00 01:00:00.00 8000001000000000 +0000-00-00 01:00:00.00 0000-00-00 01:00:00.00 8000001000000000 +0000-00-00 01:00:00.00 0000-00-00 01:00:00.00 8000001000000000 +0000-00-00 01:00:00.00 0000-00-00 01:00:00.00 8000001000000000 +0000-00-00 01:00:00.00 0000-00-00 01:00:00.00 8000001000000000 +0000-00-00 01:00:00.00 0000-00-00 01:00:00.00 8000001000000000 +0000-00-00 01:00:00.00 0000-00-00 01:00:00.00 8000001000000000 +0000-00-00 01:00:00.09 0000-00-00 01:00:00.09 8000001000015F90 +0000-00-00 01:00:00.10 0000-00-00 01:00:00.10 80000010000186A0 +0000-00-00 01:00:00.90 0000-00-00 01:00:00.90 80000010000DBBA0 +0000-00-00 01:00:00.99 0000-00-00 01:00:00.99 80000010000F1B30 +0000-00-00 01:00:00.99 0000-00-00 01:00:00.99 80000010000F1B30 +0000-00-00 01:00:00.99 0000-00-00 01:00:00.99 80000010000F1B30 +0000-00-00 01:00:00.99 0000-00-00 01:00:00.99 80000010000F1B30 +0000-00-00 01:00:00.99 0000-00-00 01:00:00.99 80000010000F1B30 +1001-01-01 00:00:00.00 1001-01-01 00:00:00.00 8CB5820000000000 +1001-01-01 00:00:00.00 1001-01-01 00:00:00.00 8CB5820000000000 +1001-01-01 00:00:00.00 1001-01-01 00:00:00.00 8CB5820000000000 +1001-01-01 00:00:00.00 1001-01-01 00:00:00.00 8CB5820000000000 +1001-01-01 00:00:00.00 1001-01-01 00:00:00.00 8CB5820000000000 +1001-01-01 00:00:00.00 1001-01-01 00:00:00.00 8CB5820000000000 +1001-01-01 00:00:00.00 1001-01-01 00:00:00.00 8CB5820000000000 +1001-01-01 00:00:00.09 1001-01-01 00:00:00.09 8CB5820000015F90 +1001-01-01 00:00:00.10 1001-01-01 00:00:00.10 8CB58200000186A0 +1001-01-01 00:00:00.90 1001-01-01 00:00:00.90 8CB58200000DBBA0 +1001-01-01 00:00:00.99 1001-01-01 00:00:00.99 8CB58200000F1B30 +1001-01-01 00:00:00.99 1001-01-01 00:00:00.99 8CB58200000F1B30 +1001-01-01 00:00:00.99 1001-01-01 00:00:00.99 8CB58200000F1B30 +1001-01-01 00:00:00.99 1001-01-01 00:00:00.99 8CB58200000F1B30 +1001-01-01 00:00:00.99 1001-01-01 00:00:00.99 8CB58200000F1B30 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.09 2001-01-01 23:59:58.09 9967837EFA015F90 +2001-01-01 23:59:58.10 2001-01-01 23:59:58.10 9967837EFA0186A0 +2001-01-01 23:59:58.90 2001-01-01 23:59:58.90 9967837EFA0DBBA0 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:59.00 2001-01-01 23:59:59.00 9967837EFB000000 +9999-12-31 23:59:58.00 9999-12-31 23:59:58.00 FEF3FF7EFA000000 +9999-12-31 23:59:58.00 9999-12-31 23:59:58.00 FEF3FF7EFA000000 +9999-12-31 23:59:58.00 9999-12-31 23:59:58.00 FEF3FF7EFA000000 +9999-12-31 23:59:58.00 9999-12-31 23:59:58.00 FEF3FF7EFA000000 +9999-12-31 23:59:58.00 9999-12-31 23:59:58.00 FEF3FF7EFA000000 +9999-12-31 23:59:58.00 9999-12-31 23:59:58.00 FEF3FF7EFA000000 +9999-12-31 23:59:58.00 9999-12-31 23:59:58.00 FEF3FF7EFA000000 +9999-12-31 23:59:58.09 9999-12-31 23:59:58.09 FEF3FF7EFA015F90 +9999-12-31 23:59:58.10 9999-12-31 23:59:58.10 FEF3FF7EFA0186A0 +9999-12-31 23:59:58.90 9999-12-31 23:59:58.90 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.99 9999-12-31 23:59:58.99 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.99 9999-12-31 23:59:58.99 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.99 9999-12-31 23:59:58.99 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.99 9999-12-31 23:59:58.99 FEF3FF7EFA0F1B30 +9999-12-31 23:59:58.99 9999-12-31 23:59:58.99 FEF3FF7EFA0F1B30 +9999-12-31 23:59:59.00 9999-12-31 23:59:59.00 FEF3FF7EFB000000 +SELECT a1, d1, HEX(WEIGHT_STRING(d1)) FROM t1 ORDER BY d1, a6; +a1 d1 HEX(WEIGHT_STRING(d1)) +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.0 0000-00-00 00:00:00.0 8000000000000000 +0000-00-00 00:00:00.1 0000-00-00 00:00:00.1 80000000000186A0 +0000-00-00 00:00:00.9 0000-00-00 00:00:00.9 80000000000DBBA0 +0000-00-00 00:00:00.9 0000-00-00 00:00:00.9 80000000000DBBA0 +0000-00-00 00:00:00.9 0000-00-00 00:00:00.9 80000000000DBBA0 +0000-00-00 00:00:00.9 0000-00-00 00:00:00.9 80000000000DBBA0 +0000-00-00 00:00:00.9 0000-00-00 00:00:00.9 80000000000DBBA0 +0000-00-00 00:00:00.9 0000-00-00 00:00:00.9 80000000000DBBA0 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.0 0000-00-00 00:00:01.0 8000000001000000 +0000-00-00 00:00:01.1 0000-00-00 00:00:01.1 80000000010186A0 +0000-00-00 00:00:01.9 0000-00-00 00:00:01.9 80000000010DBBA0 +0000-00-00 00:00:01.9 0000-00-00 00:00:01.9 80000000010DBBA0 +0000-00-00 00:00:01.9 0000-00-00 00:00:01.9 80000000010DBBA0 +0000-00-00 00:00:01.9 0000-00-00 00:00:01.9 80000000010DBBA0 +0000-00-00 00:00:01.9 0000-00-00 00:00:01.9 80000000010DBBA0 +0000-00-00 00:00:01.9 0000-00-00 00:00:01.9 80000000010DBBA0 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.0 0000-00-00 00:01:00.0 8000000040000000 +0000-00-00 00:01:00.1 0000-00-00 00:01:00.1 80000000400186A0 +0000-00-00 00:01:00.9 0000-00-00 00:01:00.9 80000000400DBBA0 +0000-00-00 00:01:00.9 0000-00-00 00:01:00.9 80000000400DBBA0 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.0 0000-00-00 01:00:00.0 8000001000000000 +0000-00-00 01:00:00.1 0000-00-00 01:00:00.1 80000010000186A0 +0000-00-00 01:00:00.9 0000-00-00 01:00:00.9 80000010000DBBA0 +0000-00-00 01:00:00.9 0000-00-00 01:00:00.9 80000010000DBBA0 +0000-00-00 01:00:00.9 0000-00-00 01:00:00.9 80000010000DBBA0 +0000-00-00 01:00:00.9 0000-00-00 01:00:00.9 80000010000DBBA0 +0000-00-00 01:00:00.9 0000-00-00 01:00:00.9 80000010000DBBA0 +0000-00-00 01:00:00.9 0000-00-00 01:00:00.9 80000010000DBBA0 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.0 1001-01-01 00:00:00.0 8CB5820000000000 +1001-01-01 00:00:00.1 1001-01-01 00:00:00.1 8CB58200000186A0 +1001-01-01 00:00:00.9 1001-01-01 00:00:00.9 8CB58200000DBBA0 +1001-01-01 00:00:00.9 1001-01-01 00:00:00.9 8CB58200000DBBA0 +1001-01-01 00:00:00.9 1001-01-01 00:00:00.9 8CB58200000DBBA0 +1001-01-01 00:00:00.9 1001-01-01 00:00:00.9 8CB58200000DBBA0 +1001-01-01 00:00:00.9 1001-01-01 00:00:00.9 8CB58200000DBBA0 +1001-01-01 00:00:00.9 1001-01-01 00:00:00.9 8CB58200000DBBA0 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.1 2001-01-01 23:59:58.1 9967837EFA0186A0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:59.0 2001-01-01 23:59:59.0 9967837EFB000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.0 9999-12-31 23:59:58.0 FEF3FF7EFA000000 +9999-12-31 23:59:58.1 9999-12-31 23:59:58.1 FEF3FF7EFA0186A0 +9999-12-31 23:59:58.9 9999-12-31 23:59:58.9 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.9 9999-12-31 23:59:58.9 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.9 9999-12-31 23:59:58.9 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.9 9999-12-31 23:59:58.9 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.9 9999-12-31 23:59:58.9 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:58.9 9999-12-31 23:59:58.9 FEF3FF7EFA0DBBA0 +9999-12-31 23:59:59.0 9999-12-31 23:59:59.0 FEF3FF7EFB000000 +SELECT a0, d0, HEX(WEIGHT_STRING(d0)) FROM t1 ORDER BY d0, a6; +a0 d0 HEX(WEIGHT_STRING(d0)) +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:00. 0000-00-00 00:00:00 8000000000000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:00:01. 0000-00-00 00:00:01 8000000001000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 00:01:00. 0000-00-00 00:01:00 8000000040000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +0000-00-00 01:00:00. 0000-00-00 01:00:00 8000001000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +1001-01-01 00:00:00. 1001-01-01 00:00:00 8CB5820000000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:59. 2001-01-01 23:59:59 9967837EFB000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:58. 9999-12-31 23:59:58 FEF3FF7EFA000000 +9999-12-31 23:59:59. 9999-12-31 23:59:59 FEF3FF7EFB000000 +CREATE VIEW v1 AS +SELECT a6, d0, d1, d2, d3, d4, d5, d6, +HEX(WEIGHT_STRING(d0)) as wst0, +HEX(WEIGHT_STRING(d1)) as wst1, +HEX(WEIGHT_STRING(d2)) as wst2, +HEX(WEIGHT_STRING(d3)) as wst3, +HEX(WEIGHT_STRING(d4)) as wst4, +HEX(WEIGHT_STRING(d5)) as wst5, +HEX(WEIGHT_STRING(d6)) as wst6 +FROM t1; +SELECT * FROM v1 WHERE a6 LIKE '%.999999' ORDER BY a6, d6;; +a6 0000-00-00 00:00:00.999999 +d0 0000-00-00 00:00:00 +d1 0000-00-00 00:00:00.9 +d2 0000-00-00 00:00:00.99 +d3 0000-00-00 00:00:00.999 +d4 0000-00-00 00:00:00.9999 +d5 0000-00-00 00:00:00.99999 +d6 0000-00-00 00:00:00.999999 +wst0 8000000000000000 +wst1 80000000000DBBA0 +wst2 80000000000F1B30 +wst3 80000000000F3E58 +wst4 80000000000F41DC +wst5 80000000000F4236 +wst6 80000000000F423F +a6 0000-00-00 00:00:01.999999 +d0 0000-00-00 00:00:01 +d1 0000-00-00 00:00:01.9 +d2 0000-00-00 00:00:01.99 +d3 0000-00-00 00:00:01.999 +d4 0000-00-00 00:00:01.9999 +d5 0000-00-00 00:00:01.99999 +d6 0000-00-00 00:00:01.999999 +wst0 8000000001000000 +wst1 80000000010DBBA0 +wst2 80000000010F1B30 +wst3 80000000010F3E58 +wst4 80000000010F41DC +wst5 80000000010F4236 +wst6 80000000010F423F +a6 0000-00-00 00:01:00.999999 +d0 0000-00-00 00:01:00 +d1 0000-00-00 00:01:00.9 +d2 0000-00-00 00:01:00.99 +d3 0000-00-00 00:01:00.999 +d4 0000-00-00 00:01:00.9999 +d5 0000-00-00 00:01:00.99999 +d6 0000-00-00 00:01:00.999999 +wst0 8000000040000000 +wst1 80000000400DBBA0 +wst2 80000000400F1B30 +wst3 80000000400F3E58 +wst4 80000000400F41DC +wst5 80000000400F4236 +wst6 80000000400F423F +a6 0000-00-00 01:00:00.999999 +d0 0000-00-00 01:00:00 +d1 0000-00-00 01:00:00.9 +d2 0000-00-00 01:00:00.99 +d3 0000-00-00 01:00:00.999 +d4 0000-00-00 01:00:00.9999 +d5 0000-00-00 01:00:00.99999 +d6 0000-00-00 01:00:00.999999 +wst0 8000001000000000 +wst1 80000010000DBBA0 +wst2 80000010000F1B30 +wst3 80000010000F3E58 +wst4 80000010000F41DC +wst5 80000010000F4236 +wst6 80000010000F423F +a6 1001-01-01 00:00:00.999999 +d0 1001-01-01 00:00:00 +d1 1001-01-01 00:00:00.9 +d2 1001-01-01 00:00:00.99 +d3 1001-01-01 00:00:00.999 +d4 1001-01-01 00:00:00.9999 +d5 1001-01-01 00:00:00.99999 +d6 1001-01-01 00:00:00.999999 +wst0 8CB5820000000000 +wst1 8CB58200000DBBA0 +wst2 8CB58200000F1B30 +wst3 8CB58200000F3E58 +wst4 8CB58200000F41DC +wst5 8CB58200000F4236 +wst6 8CB58200000F423F +a6 2001-01-01 23:59:58.999999 +d0 2001-01-01 23:59:58 +d1 2001-01-01 23:59:58.9 +d2 2001-01-01 23:59:58.99 +d3 2001-01-01 23:59:58.999 +d4 2001-01-01 23:59:58.9999 +d5 2001-01-01 23:59:58.99999 +d6 2001-01-01 23:59:58.999999 +wst0 9967837EFA000000 +wst1 9967837EFA0DBBA0 +wst2 9967837EFA0F1B30 +wst3 9967837EFA0F3E58 +wst4 9967837EFA0F41DC +wst5 9967837EFA0F4236 +wst6 9967837EFA0F423F +a6 9999-12-31 23:59:58.999999 +d0 9999-12-31 23:59:58 +d1 9999-12-31 23:59:58.9 +d2 9999-12-31 23:59:58.99 +d3 9999-12-31 23:59:58.999 +d4 9999-12-31 23:59:58.9999 +d5 9999-12-31 23:59:58.99999 +d6 9999-12-31 23:59:58.999999 +wst0 FEF3FF7EFA000000 +wst1 FEF3FF7EFA0DBBA0 +wst2 FEF3FF7EFA0F1B30 +wst3 FEF3FF7EFA0F3E58 +wst4 FEF3FF7EFA0F41DC +wst5 FEF3FF7EFA0F4236 +wst6 FEF3FF7EFA0F423F +SELECT * FROM v1 WHERE a6 LIKE '%.000000' ORDER BY a6, d6;; +a6 0000-00-00 00:00:00.000000 +d0 0000-00-00 00:00:00 +d1 0000-00-00 00:00:00.0 +d2 0000-00-00 00:00:00.00 +d3 0000-00-00 00:00:00.000 +d4 0000-00-00 00:00:00.0000 +d5 0000-00-00 00:00:00.00000 +d6 0000-00-00 00:00:00.000000 +wst0 8000000000000000 +wst1 8000000000000000 +wst2 8000000000000000 +wst3 8000000000000000 +wst4 8000000000000000 +wst5 8000000000000000 +wst6 8000000000000000 +a6 0000-00-00 00:00:01.000000 +d0 0000-00-00 00:00:01 +d1 0000-00-00 00:00:01.0 +d2 0000-00-00 00:00:01.00 +d3 0000-00-00 00:00:01.000 +d4 0000-00-00 00:00:01.0000 +d5 0000-00-00 00:00:01.00000 +d6 0000-00-00 00:00:01.000000 +wst0 8000000001000000 +wst1 8000000001000000 +wst2 8000000001000000 +wst3 8000000001000000 +wst4 8000000001000000 +wst5 8000000001000000 +wst6 8000000001000000 +a6 2001-01-01 23:59:59.000000 +d0 2001-01-01 23:59:59 +d1 2001-01-01 23:59:59.0 +d2 2001-01-01 23:59:59.00 +d3 2001-01-01 23:59:59.000 +d4 2001-01-01 23:59:59.0000 +d5 2001-01-01 23:59:59.00000 +d6 2001-01-01 23:59:59.000000 +wst0 9967837EFB000000 +wst1 9967837EFB000000 +wst2 9967837EFB000000 +wst3 9967837EFB000000 +wst4 9967837EFB000000 +wst5 9967837EFB000000 +wst6 9967837EFB000000 +a6 9999-12-31 23:59:59.000000 +d0 9999-12-31 23:59:59 +d1 9999-12-31 23:59:59.0 +d2 9999-12-31 23:59:59.00 +d3 9999-12-31 23:59:59.000 +d4 9999-12-31 23:59:59.0000 +d5 9999-12-31 23:59:59.00000 +d6 9999-12-31 23:59:59.000000 +wst0 FEF3FF7EFB000000 +wst1 FEF3FF7EFB000000 +wst2 FEF3FF7EFB000000 +wst3 FEF3FF7EFB000000 +wst4 FEF3FF7EFB000000 +wst5 FEF3FF7EFB000000 +wst6 FEF3FF7EFB000000 +SELECT * FROM v1 WHERE a6 LIKE '%.100000' ORDER BY a6, d6;; +a6 0000-00-00 00:00:00.100000 +d0 0000-00-00 00:00:00 +d1 0000-00-00 00:00:00.1 +d2 0000-00-00 00:00:00.10 +d3 0000-00-00 00:00:00.100 +d4 0000-00-00 00:00:00.1000 +d5 0000-00-00 00:00:00.10000 +d6 0000-00-00 00:00:00.100000 +wst0 8000000000000000 +wst1 80000000000186A0 +wst2 80000000000186A0 +wst3 80000000000186A0 +wst4 80000000000186A0 +wst5 80000000000186A0 +wst6 80000000000186A0 +a6 0000-00-00 00:00:01.100000 +d0 0000-00-00 00:00:01 +d1 0000-00-00 00:00:01.1 +d2 0000-00-00 00:00:01.10 +d3 0000-00-00 00:00:01.100 +d4 0000-00-00 00:00:01.1000 +d5 0000-00-00 00:00:01.10000 +d6 0000-00-00 00:00:01.100000 +wst0 8000000001000000 +wst1 80000000010186A0 +wst2 80000000010186A0 +wst3 80000000010186A0 +wst4 80000000010186A0 +wst5 80000000010186A0 +wst6 80000000010186A0 +a6 0000-00-00 00:01:00.100000 +d0 0000-00-00 00:01:00 +d1 0000-00-00 00:01:00.1 +d2 0000-00-00 00:01:00.10 +d3 0000-00-00 00:01:00.100 +d4 0000-00-00 00:01:00.1000 +d5 0000-00-00 00:01:00.10000 +d6 0000-00-00 00:01:00.100000 +wst0 8000000040000000 +wst1 80000000400186A0 +wst2 80000000400186A0 +wst3 80000000400186A0 +wst4 80000000400186A0 +wst5 80000000400186A0 +wst6 80000000400186A0 +a6 0000-00-00 01:00:00.100000 +d0 0000-00-00 01:00:00 +d1 0000-00-00 01:00:00.1 +d2 0000-00-00 01:00:00.10 +d3 0000-00-00 01:00:00.100 +d4 0000-00-00 01:00:00.1000 +d5 0000-00-00 01:00:00.10000 +d6 0000-00-00 01:00:00.100000 +wst0 8000001000000000 +wst1 80000010000186A0 +wst2 80000010000186A0 +wst3 80000010000186A0 +wst4 80000010000186A0 +wst5 80000010000186A0 +wst6 80000010000186A0 +a6 1001-01-01 00:00:00.100000 +d0 1001-01-01 00:00:00 +d1 1001-01-01 00:00:00.1 +d2 1001-01-01 00:00:00.10 +d3 1001-01-01 00:00:00.100 +d4 1001-01-01 00:00:00.1000 +d5 1001-01-01 00:00:00.10000 +d6 1001-01-01 00:00:00.100000 +wst0 8CB5820000000000 +wst1 8CB58200000186A0 +wst2 8CB58200000186A0 +wst3 8CB58200000186A0 +wst4 8CB58200000186A0 +wst5 8CB58200000186A0 +wst6 8CB58200000186A0 +a6 2001-01-01 23:59:58.100000 +d0 2001-01-01 23:59:58 +d1 2001-01-01 23:59:58.1 +d2 2001-01-01 23:59:58.10 +d3 2001-01-01 23:59:58.100 +d4 2001-01-01 23:59:58.1000 +d5 2001-01-01 23:59:58.10000 +d6 2001-01-01 23:59:58.100000 +wst0 9967837EFA000000 +wst1 9967837EFA0186A0 +wst2 9967837EFA0186A0 +wst3 9967837EFA0186A0 +wst4 9967837EFA0186A0 +wst5 9967837EFA0186A0 +wst6 9967837EFA0186A0 +a6 9999-12-31 23:59:58.100000 +d0 9999-12-31 23:59:58 +d1 9999-12-31 23:59:58.1 +d2 9999-12-31 23:59:58.10 +d3 9999-12-31 23:59:58.100 +d4 9999-12-31 23:59:58.1000 +d5 9999-12-31 23:59:58.10000 +d6 9999-12-31 23:59:58.100000 +wst0 FEF3FF7EFA000000 +wst1 FEF3FF7EFA0186A0 +wst2 FEF3FF7EFA0186A0 +wst3 FEF3FF7EFA0186A0 +wst4 FEF3FF7EFA0186A0 +wst5 FEF3FF7EFA0186A0 +wst6 FEF3FF7EFA0186A0 +SET sql_mode = default; +DROP VIEW v1; +DROP TABLE t1; +# +# Testing bad FSPs +# +CREATE TABLE t1 (a DATETIME(-1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1 +CREATE TABLE t1 (a DATETIME(7)); +ERROR 42000: Too-big precision 7 specified for 'a'. Maximum is 6. +CREATE TABLE t1 (a DATETIME(31)); +ERROR 42000: Too-big precision 31 specified for 'a'. Maximum is 6. +# +# Testing bad FSPs with DATETIME functions +# +SELECT SYSDATE(-1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1)' at line 1 +SELECT SYSDATE(7); +ERROR 42000: Too-big precision 7 specified for 'sysdate'. Maximum is 6. +SELECT SYSDATE(31); +ERROR 42000: Too-big precision 31 specified for 'sysdate'. Maximum is 6. +SELECT NOW(-1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1)' at line 1 +SELECT NOW(7); +ERROR 42000: Too-big precision 7 specified for 'now'. Maximum is 6. +SELECT NOW(31); +ERROR 42000: Too-big precision 31 specified for 'now'. Maximum is 6. +# +# Testing INSERT, ORDER, KEY, BETWEEN, comparison +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a DATETIME(6) NOT NULL); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('0000-00-00 23:59:59.999999'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.4'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.45'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.456'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.4567'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.45678'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.4567891'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:59.000000'); +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +0000-00-00 23:59:59.999999 +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +9999-12-31 23:59:59.000000 +SELECT * FROM t1 ORDER BY a DESC; +a +9999-12-31 23:59:59.000000 +2000-01-01 01:02:03.456789 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.000000 +0000-00-00 23:59:59.999999 +0000-00-00 00:00:00.000000 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.45'; +a +2000-01-01 01:02:03.450000 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.4567'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.45670'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.456700'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a BETWEEN '2000-01-01 01:02:00' AND '2000-01-01 01:03:00'; +a +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1 ORDER BY a; +a +0000-00-00 00:00:00.000000 +0000-00-00 23:59:59.999999 +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +9999-12-31 23:59:59.000000 +SELECT * FROM t1 ORDER BY a DESC; +a +9999-12-31 23:59:59.000000 +2000-01-01 01:02:03.456789 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.000000 +0000-00-00 23:59:59.999999 +0000-00-00 00:00:00.000000 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.456700'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 8 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2000-01-01 01:02:03.4567') +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.456700'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a BETWEEN '2000-01-01 01:02:00' AND '2000-01-01 01:03:00'; +a +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +SELECT * FROM t1 WHERE a BETWEEN TIMESTAMP'2000-01-01 01:02:03.456' AND TIMESTAMP'2000-01-01 01:02:03.45678'; +a +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +DROP TABLE t1; +# +# Tesint range: stored_field_cmp_to_item +# +CREATE TABLE t1 (a datetime(6), key(a)); +INSERT INTO t1 VALUES +('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), +('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); +SELECT * FROM t1 WHERE a >= 20000101000000; +a +2000-01-01 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 00:00:01.000000 +2000-01-01 00:00:01.000000 +SELECT * FROM t1 WHERE a >= 20000101000000.0; +a +2000-01-01 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 00:00:01.000000 +2000-01-01 00:00:01.000000 +UPDATE t1 SET a=ADDTIME(a, 0.000001); +SELECT * FROM t1; +a +2000-01-01 00:00:00.000001 +2000-01-01 00:00:00.000001 +2000-01-01 00:00:01.000001 +2000-01-01 00:00:01.000001 +SELECT * FROM t1 WHERE a >= 20000101000000.000001; +a +2000-01-01 00:00:00.000001 +2000-01-01 00:00:00.000001 +2000-01-01 00:00:01.000001 +2000-01-01 00:00:01.000001 +DROP TABLE t1; +# +# Rare DATETIME formats +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES (101.101); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (990101.102); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('990101.103'); +INSERT INTO t1 VALUES (131.104); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('000131.105'); +SELECT * FROM t1; +a +2000-01-01 00:00:00.000000 +1999-01-01 00:00:00.000000 +1999-01-01 10:03:00.000000 +2000-01-31 00:00:00.000000 +2000-01-31 10:05:00.000000 +DROP TABLE t1; +# +# Testing bad values +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('xxxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-01-01 00:00:00.123456 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-01-01 00:00:00 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-01-01 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-00-00 00:00:00'); +INSERT INTO t1 VALUES ('-0000-00-00'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('-0000-00-00 00:00:00'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('-0000-00-00 00:00:00.000000'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (-0.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-0.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.0e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +1999-01-01 00:00:00.123456 +1999-01-01 00:00:00.000000 +1999-01-01 00:00:00.000000 +1999-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing huge values +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS SIGNED)); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS UNSIGNED)); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ( 100000000000000000.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ( 100000000000000000.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-100000000000000000.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-100000000000000000.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +SET sql_mode = default; +# +# Testing values with zeros in dates +# +SET sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (a DATETIME, b DATETIME(6)); +INSERT INTO t1 VALUES ('1999-00-00 00:00:00', '1999-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +SELECT * FROM t1; +a b +0000-00-00 00:00:00 0000-00-00 00:00:00.000000 +DROP TABLE t1; +SET sql_mode=default; +# +# Testing bad values with TRADITIONAL mode +# +SET sql_mode=traditional; +CREATE TABLE t1 (a DATETIME, b DATETIME(6)); +INSERT INTO t1 VALUES ('xxx', NULL); +ERROR 22007: Incorrect datetime value: 'xxx' for column 'a' at row 1 +INSERT INTO t1 VALUES (NULL,'xxx'); +ERROR 22007: Incorrect datetime value: 'xxx' for column 'b' at row 1 +INSERT INTO t1 VALUES ('1999-01-01 00:00:00 xxx', NULL); +ERROR 22007: Incorrect datetime value: '1999-01-01 00:00:00 xxx' for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-00-00 00:00:00 xxx', NULL); +ERROR 22007: Incorrect datetime value: '1999-00-00 00:00:00 xxx' for column 'a' at row 1 +INSERT INTO t1 VALUES (NULL, '1999-00-00 00:00:00 xxx'); +ERROR 22007: Incorrect datetime value: '1999-00-00 00:00:00 xxx' for column 'b' at row 1 +INSERT INTO t1 VALUES ('1999-00-00 xxx', NULL); +ERROR 22007: Incorrect datetime value: '1999-00-00 xxx' for column 'a' at row 1 +INSERT INTO t1 VALUES (NULL, '1999-00-00 xxx'); +ERROR 22007: Incorrect datetime value: '1999-00-00 xxx' for column 'b' at row 1 +INSERT INTO t1 VALUES ('1999-00-00 00:00:00', NULL); +ERROR 22007: Incorrect datetime value: '1999-00-00 00:00:00' for column 'a' at row 1 +INSERT INTO t1 VALUES (NULL, '1999-00-00 00:00:00'); +ERROR 22007: Incorrect datetime value: '1999-00-00 00:00:00' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, TIMESTAMP('0000-00-00 10:00:00')); +ERROR 22007: Incorrect datetime value: '0000-00-00 10:00:00' +INSERT INTO t1 VALUES (NULL, 199991231000000); +ERROR 22007: Incorrect datetime value: '199991231000000' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, -0.1); +ERROR 22007: Incorrect datetime value: '-0.1' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, -1.0); +ERROR 22007: Incorrect datetime value: '-1.0' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, -1.1); +ERROR 22007: Incorrect datetime value: '-1.1' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, -0.1e0); +ERROR 22007: Incorrect datetime value: '-0.1' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, -1.0e0); +ERROR 22007: Incorrect datetime value: '-1' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, -1.1e0); +ERROR 22007: Incorrect datetime value: '-1.1' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, CAST(0xFFFFFFFF00000000 AS SIGNED)); +ERROR 22007: Incorrect datetime value: '-4294967296' for column 'b' at row 1 +INSERT INTO t1 VALUES (NULL, CAST(0xFFFFFFFF00000000 AS UNSIGNED)); +ERROR 22007: Incorrect datetime value: '18446744069414584320' for column 'b' at row 1 +SELECT * FROM t1; +a b +DROP TABLE t1; +SET sql_mode=default; +# +# Testing rounding +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES (20010101100000.1234567); +INSERT INTO t1 VALUES (20010228235959.9999997); +INSERT INTO t1 VALUES (99990228235959.9999997); +INSERT INTO t1 VALUES (99991231235959.9999997); +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('2001-01-01 10:00:00.1234567'); +INSERT INTO t1 VALUES ('2001-02-28 23:59:59.9999997'); +INSERT INTO t1 VALUES ('9999-02-28 23:59:59.9999997'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:59.9999997'); +Warnings: +Warning 1441 Datetime function: datetime field overflow +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +2001-01-01 10:00:00.123457 +2001-03-01 00:00:00.000000 +9999-03-01 00:00:00.000000 +0000-00-00 00:00:00.000000 +2001-01-01 10:00:00.123457 +2001-03-01 00:00:00.000000 +9999-03-01 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing rounding when altering DATETIME(N) to a smaller size +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999999'); +ALTER TABLE t1 MODIFY a DATETIME(5); +SELECT * FROM t1; +a +2001-01-01 10:10:11.00000 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999999'); +ALTER TABLE t1 MODIFY a TIME; +SELECT * FROM t1; +a +10:10:11 +DROP TABLE t1; +# +# Testing rounding from VARCHAR and DATETIME(6) to DATETIME(N) +# +CREATE TABLE t1 (a VARCHAR(32), +t6 DATETIME(6), t5 DATETIME(5), t4 DATETIME(4), +t3 DATETIME(3), t2 DATETIME(2), t1 DATETIME(1), +t0 DATETIME); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999994'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999949'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999499'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.994999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.949999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.499999'); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 2001-01-01 10:10:10.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +ALTER TABLE t1 MODIFY a DATETIME(6); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 2001-01-01 10:10:10.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +DROP TABLE t1; +# +# Testing rounding from DATETIME(N) to BIGINT +# +CREATE TABLE t1 (a BIGINT, b DATETIME(6)); +INSERT INTO t1 (b) VALUES ('2001-01-01 10:10:59.500000'); +INSERT INTO t1 (b) VALUES ('2001-01-01 10:10:10.500000'); +INSERT INTO t1 (b) VALUES ('2001-01-01 10:10:10.499999'); +UPDATE t1 SET a=b; +SELECT * FROM t1; +a b +20010101101100 2001-01-01 10:10:59.500000 +20010101101011 2001-01-01 10:10:10.500000 +20010101101010 2001-01-01 10:10:10.499999 +DROP TABLE t1; +# +# Testing rounding from TIME(6) to DATETIME(N) +# +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a TIME(6), +t6 DATETIME(6), t5 DATETIME(5), t4 DATETIME(4), +t3 DATETIME(3), t2 DATETIME(2), t1 DATETIME(1), +t0 DATETIME); +INSERT INTO t1 (a) VALUES ('10:10:10.999999'); +INSERT INTO t1 (a) VALUES ('10:10:10.999994'); +INSERT INTO t1 (a) VALUES ('10:10:10.999949'); +INSERT INTO t1 (a) VALUES ('10:10:10.999499'); +INSERT INTO t1 (a) VALUES ('10:10:10.994999'); +INSERT INTO t1 (a) VALUES ('10:10:10.949999'); +INSERT INTO t1 (a) VALUES ('10:10:10.499999'); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 10:10:10.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 10:10:10.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +DROP TABLE t1; +SET timestamp=default; +# +# Testing rounding from DECIMAL to DATETIME(N) +# +CREATE TABLE t1 (a DECIMAL(30,6), +t6 DATETIME(6), t5 DATETIME(5), t4 DATETIME(4), +t3 DATETIME(3), t2 DATETIME(2), t1 DATETIME(1), +t0 DATETIME); +INSERT INTO t1 (a) VALUES (20010101101010.999999); +INSERT INTO t1 (a) VALUES (20010101101010.999994); +INSERT INTO t1 (a) VALUES (20010101101010.999949); +INSERT INTO t1 (a) VALUES (20010101101010.999499); +INSERT INTO t1 (a) VALUES (20010101101010.994999); +INSERT INTO t1 (a) VALUES (20010101101010.949999); +INSERT INTO t1 (a) VALUES (20010101101010.499999); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 20010101101010.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 20010101101010.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +DROP TABLE t1; +# +# Testing truncation warnings +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.111111 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.1111110'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.1111111'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.1111114'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.1111115'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.1111119'); +SELECT * FROM t1; +a +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111112 +0000-00-00 00:00:00.111112 +DELETE FROM t1; +INSERT INTO t1 VALUES (0.1111110); +INSERT INTO t1 VALUES (0.1111111); +INSERT INTO t1 VALUES (0.1111114); +INSERT INTO t1 VALUES (0.1111115); +INSERT INTO t1 VALUES (0.1111119); +SELECT * FROM t1; +a +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111112 +0000-00-00 00:00:00.111112 +DELETE FROM t1; +INSERT INTO t1 VALUES (0.1111110e0); +INSERT INTO t1 VALUES (0.1111111e0); +INSERT INTO t1 VALUES (0.1111114e0); +INSERT INTO t1 VALUES (0.1111115e0); +INSERT INTO t1 VALUES (0.1111119e0); +SELECT * FROM t1; +a +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111111 +0000-00-00 00:00:00.111112 +0000-00-00 00:00:00.111112 +DROP TABLE t1; +# +# Testing implicit CAST from TIME to DATETIME +# +SET @@timestamp=UNIX_TIMESTAMP('2008-01-03 10:20:30.1'); +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES (CURRENT_TIME), (CURRENT_TIME(6)); +INSERT INTO t1 VALUES (TIME'08:00:00.123456'), (TIME'240:00:00.000001'); +INSERT INTO t1 VALUES (TIME'-10:00:00.000001'), (TIME'-240:00:00.000001'); +SELECT * FROM t1; +a +2008-01-03 10:20:30.000000 +2008-01-03 10:20:30.100000 +2008-01-03 08:00:00.123456 +2008-01-13 00:00:00.000001 +2008-01-02 13:59:59.999999 +2007-12-23 23:59:59.999999 +DROP TABLE t1; +SET @@timestamp=default; +# +# Testing IN +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000002'); +INSERT INTO t1 VALUES ('2000-01-01 10:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 10:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-01 10:00:00.000002'); +INSERT INTO t1 VALUES ('2000-01-01 23:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 23:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-01 23:00:00.000002'); +SELECT * FROM t1 WHERE a IN ('2000-01-01 00:00:00', '0000-00-00 00:00:00.000001', '2000-01-01 23:00:00.000002'); +a +0000-00-00 00:00:00.000001 +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000002 +SELECT * FROM t1 WHERE a IN (0, 20000101000000, 20000101230000); +a +0000-00-00 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000000 +SELECT * FROM t1 WHERE a IN (0.000001, 20000101000000.000001, 20000101230000.000001); +a +0000-00-00 00:00:00.000001 +2000-01-01 00:00:00.000001 +2000-01-01 23:00:00.000001 +SELECT * FROM t1 WHERE a IN (0e0, 0.000001e0); +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000001 +# +# Testing Item_temporal_with_ref::print +# +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a IN (0.000001,0); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 20.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 11 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` in ('0000-00-00 00:00:00.000001','0000-00-00 00:00:00.000000')) +# +# Testing IN with index: involves field->store_packed() +# +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1 WHERE a IN ('2000-01-01 00:00:00', '0000-00-00 00:00:00.000001','2000-01-01 23:00:00.000002'); +a +0000-00-00 00:00:00.000001 +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000002 +SELECT * FROM t1 WHERE a IN (0, 20000101000000, 20000101230000); +a +0000-00-00 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000000 +SELECT * FROM t1 WHERE a IN (0.000001, 20000101000000.000001, 20000101230000.000001); +a +0000-00-00 00:00:00.000001 +2000-01-01 00:00:00.000001 +2000-01-01 23:00:00.000001 +SELECT * FROM t1 WHERE a IN (0e0, 0.000001e0); +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000001 +DROP TABLE t1; +# +# Testing CREATE TABLE LIKE +# +CREATE TABLE t1 (a DATETIME(6)); +CREATE TABLE t2 LIKE t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +# +# Testing CREATE TABLE .. SELECT +# +CREATE TABLE t1 (a DATETIME(6)); +CREATE TABLE t2 AS SELECT * FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +# +# Testing JOIN between DATETIME(6) and DATETIME(6) +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.1'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.12'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.123'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.1234'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.12345'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.123456'); +CREATE TABLE t2 (a DATETIME(6)); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +ALTER TABLE t2 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +ALTER TABLE t1 DROP KEY a; +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing JOIN between DATETIME and DATETIME(6) +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('0000-00-00 23:59:59.000000'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:12.000000'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:12.000001'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:12.000002'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:13.000000'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:13.000001'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:13.000002'); +INSERT INTO t1 VALUES ('2000-01-01 23:59:59.999999'); +INSERT INTO t1 VALUES ('2000-01-01 23:59:59.000000'); +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 VALUES ('2000-01-01 10:11:12'); +INSERT INTO t2 VALUES ('2000-01-01 10:11:13'); +INSERT INTO t2 VALUES ('0000-00-00 23:59:59'); +INSERT INTO t2 VALUES ('2000-01-01 23:59:59'); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +0000-00-00 23:59:59.000000 0000-00-00 23:59:59 +2000-01-01 10:11:12.000000 2000-01-01 10:11:12 +2000-01-01 10:11:13.000000 2000-01-01 10:11:13 +2000-01-01 23:59:59.000000 2000-01-01 23:59:59 +ALTER TABLE t1 ADD KEY(a); +ALTER TABLE t2 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +0000-00-00 23:59:59.000000 0000-00-00 23:59:59 +2000-01-01 10:11:12.000000 2000-01-01 10:11:12 +2000-01-01 10:11:13.000000 2000-01-01 10:11:13 +2000-01-01 23:59:59.000000 2000-01-01 23:59:59 +DROP TABLE t2, t1; +# +# Testing unique index +# +CREATE TABLE t1 (a DATETIME(6), UNIQUE(a)); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.1'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.12'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.123'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.1234'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.12345'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.12345'); +ERROR 23000: Duplicate entry '2000-01-01 00:01:02.123450' for key 't1.a' +DROP TABLE t1; +# +# Testing GROUP BY +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.0'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.01'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.010'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.02'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.020'); +SELECT a, COUNT(*) FROM t1 GROUP BY a; +a COUNT(*) +2000-01-01 00:01:02.000000 2 +2000-01-01 00:01:02.010000 2 +2000-01-01 00:01:02.020000 2 +DROP TABLE t1; +# +# Testing MIN() and MAX() +# +CREATE TABLE t1 (a INT, b DATETIME(6)); +INSERT INTO t1 VALUES (1, '2001-01-01 00:01:02.000001'); +INSERT INTO t1 VALUES (1, '2001-01-01 00:01:02'); +INSERT INTO t1 VALUES (2, '2001-01-01 10:01:02'); +INSERT INTO t1 VALUES (2, '2001-01-01 10:01:02.000001'); +INSERT INTO t1 VALUES (3, '2001-01-01 10:11:02'); +INSERT INTO t1 VALUES (3, '2001-01-01 10:11:02.000001'); +SELECT MIN(b), MAX(b) FROM t1; +MIN(b) MAX(b) +2001-01-01 00:01:02.000000 2001-01-01 10:11:02.000001 +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a; +a MIN(b) MAX(b) +1 2001-01-01 00:01:02.000000 2001-01-01 00:01:02.000001 +2 2001-01-01 10:01:02.000000 2001-01-01 10:01:02.000001 +3 2001-01-01 10:11:02.000000 2001-01-01 10:11:02.000001 +DROP TABLE t1; +# +# Testing MIN(DATETIME) and MAX(DATETIME) in arithmetic expressions and CAST +# This covers Item_sum_hybrid::val_int(), val_real(), val_decimal() +# +CREATE TABLE t1 +( +t0 DATETIME, +t1 DATETIME(1), t2 DATETIME(2), t3 DATETIME(3), +t4 DATETIME(4), t5 DATETIME(5), t6 DATETIME(6) +); +INSERT INTO t1 VALUES +( +'2001-01-01 10:10:10', +'2001-01-01 10:10:10.9', '2001-01-01 10:10:10.99', '2001-01-01 10:10:10.999', +'2001-01-01 10:10:10.9999', '2001-01-01 10:10:10.99999', '2001-01-01 10:10:10.999999' +); +CREATE TABLE t2 AS +SELECT +MAX(t0) + 1, +MAX(t1) + 1, MAX(t2) + 1, MAX(t3) + 1, +MAX(t4) + 1, MAX(t5) + 1, MAX(t6) + 1 +FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +MAX(t0) + 1 bigint YES NULL +MAX(t1) + 1 decimal(16,1) YES NULL +MAX(t2) + 1 decimal(17,2) YES NULL +MAX(t3) + 1 decimal(18,3) YES NULL +MAX(t4) + 1 decimal(19,4) YES NULL +MAX(t5) + 1 decimal(20,5) YES NULL +MAX(t6) + 1 decimal(21,6) YES NULL +SELECT * FROM t2; +MAX(t0) + 1 MAX(t1) + 1 MAX(t2) + 1 MAX(t3) + 1 MAX(t4) + 1 MAX(t5) + 1 MAX(t6) + 1 +20010101101011 20010101101011.9 20010101101011.99 20010101101011.999 20010101101011.9999 20010101101011.99999 20010101101011.999999 +DROP TABLE t2; +CREATE TABLE t2 AS +SELECT +MAX(t0) + 1.1, +MAX(t1) + 1.1, MAX(t2) + 1.1, MAX(t3) + 1.1, +MAX(t4) + 1.1, MAX(t5) + 1.1, MAX(t6) + 1.1 +FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +MAX(t0) + 1.1 decimal(16,1) YES NULL +MAX(t1) + 1.1 decimal(16,1) YES NULL +MAX(t2) + 1.1 decimal(17,2) YES NULL +MAX(t3) + 1.1 decimal(18,3) YES NULL +MAX(t4) + 1.1 decimal(19,4) YES NULL +MAX(t5) + 1.1 decimal(20,5) YES NULL +MAX(t6) + 1.1 decimal(21,6) YES NULL +SELECT * FROM t2; +MAX(t0) + 1.1 MAX(t1) + 1.1 MAX(t2) + 1.1 MAX(t3) + 1.1 MAX(t4) + 1.1 MAX(t5) + 1.1 MAX(t6) + 1.1 +20010101101011.1 20010101101012.0 20010101101012.09 20010101101012.099 20010101101012.0999 20010101101012.09999 20010101101012.099999 +DROP TABLE t2; +CREATE TABLE t2 AS +SELECT +MAX(t0) + 1.0e0, +MAX(t1) + 1.0e0, MAX(t2) + 1.0e0, MAX(t3) + 1.0e0, +MAX(t4) + 1.0e0, MAX(t5) + 1.0e0, MAX(t6) + 1.0e0 +FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +MAX(t0) + 1.0e0 double YES NULL +MAX(t1) + 1.0e0 double YES NULL +MAX(t2) + 1.0e0 double YES NULL +MAX(t3) + 1.0e0 double YES NULL +MAX(t4) + 1.0e0 double YES NULL +MAX(t5) + 1.0e0 double YES NULL +MAX(t6) + 1.0e0 double YES NULL +DROP TABLE t2; +SELECT +MAX(t0) + 1, +MAX(t1) + 1, MAX(t2) + 1, MAX(t3) + 1, +MAX(t4) + 1, MAX(t5) + 1, MAX(t6) + 1 +FROM t1; +MAX(t0) + 1 MAX(t1) + 1 MAX(t2) + 1 MAX(t3) + 1 MAX(t4) + 1 MAX(t5) + 1 MAX(t6) + 1 +20010101101011 20010101101011.9 20010101101011.99 20010101101011.999 20010101101011.9999 20010101101011.99999 20010101101011.999999 +SELECT +CAST(MAX(t0) AS SIGNED), +CAST(MAX(t1) AS SIGNED), CAST(MAX(t2) AS SIGNED), CAST(MAX(t3) AS SIGNED), +CAST(MAX(t4) AS SIGNED), CAST(MAX(t5) AS SIGNED), CAST(MAX(t6) AS SIGNED) +FROM t1; +CAST(MAX(t0) AS SIGNED) CAST(MAX(t1) AS SIGNED) CAST(MAX(t2) AS SIGNED) CAST(MAX(t3) AS SIGNED) CAST(MAX(t4) AS SIGNED) CAST(MAX(t5) AS SIGNED) CAST(MAX(t6) AS SIGNED) +20010101101010 20010101101011 20010101101011 20010101101011 20010101101011 20010101101011 20010101101011 +DROP TABLE t1; +# +# Testing LEAST +# +SELECT LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2'); +LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2') +2001-01-01 00:00:00.1 +SELECT LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2') + 1; +LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2') + 1 +20010101000001.1 +SELECT LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2') + 1.0; +LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2') + 1.0 +20010101000001.1 +SELECT LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2') + 1e0; +LEAST(TIMESTAMP'2001-01-01 00:00:00.1', TIMESTAMP'2001-01-01 00:00:00.2') + 1e0 +20010101000001.1 +SELECT LEAST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') AS a; +a +2001-01-01 00:00:00.100000 +SELECT LEAST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') + 0 AS a; +a +20010101000000.100000 +SELECT CAST(LEAST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') AS SIGNED) AS a; +a +20010101000000 +SELECT CAST(LEAST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') AS DECIMAL(30,6)) AS a; +a +20010101000000.100000 +SELECT GREATEST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') AS a; +a +2001-01-02 00:00:00.100000 +SELECT GREATEST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') + 0 AS a; +a +20010102000000.100000 +SELECT CAST(GREATEST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') AS SIGNED) AS a; +a +20010102000000 +SELECT CAST(GREATEST(CAST('2001-01-01 00:00:00.1' as DATETIME(6)), '2001-01-02 00:00:00.1') AS DECIMAL(30,6)) AS a; +a +20010102000000.100000 +CREATE TABLE t1 AS SELECT +LEAST(CAST('2001-01-01 00:00:00' AS DATETIME(1)), +CAST('2001-01-01 00:00:00' AS DATETIME(2))) AS l, +GREATEST(CAST('2001-01-01 00:00:00' AS DATETIME(1)), +CAST('2001-01-01 00:00:00' AS DATETIME(2))) AS g; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `l` datetime(2) DEFAULT NULL, + `g` datetime(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing INSERT, MAX and MIN values +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('9999-12-31 23:59:59'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:59.1'); +INSERT INTO t1 VALUES ('9999-12-31 24:00:00'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +9999-12-31 23:59:59.000000 +9999-12-31 23:59:59.100000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing integer INSERT values +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES (19990102); +INSERT INTO t1 VALUES (19990102112233); +INSERT INTO t1 VALUES (100000101112233); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (-1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +1999-01-02 00:00:00.000000 +1999-01-02 11:22:33.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing decimal INSERT values +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES (20010101223344.4); +INSERT INTO t1 VALUES (20010101223344.45); +INSERT INTO t1 VALUES (20010101223344.456); +INSERT INTO t1 VALUES (20010101223344.4567); +INSERT INTO t1 VALUES (20010101223344.45678); +INSERT INTO t1 VALUES (20010101223344.456789); +INSERT INTO t1 VALUES (2001010120203.4567894); +INSERT INTO t1 VALUES (2001010120203.4567895); +INSERT INTO t1 VALUES (2001010120203.4567896); +INSERT INTO t1 VALUES (2001010120203.456789678); +INSERT INTO t1 VALUES (200101018385959.000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-200101018385959.000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +2001-01-01 22:33:44.400000 +2001-01-01 22:33:44.450000 +2001-01-01 22:33:44.456000 +2001-01-01 22:33:44.456700 +2001-01-01 22:33:44.456780 +2001-01-01 22:33:44.456789 +0200-10-10 12:02:03.456789 +0200-10-10 12:02:03.456790 +0200-10-10 12:02:03.456790 +0200-10-10 12:02:03.456790 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing double INSERT values +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES (112.233e-3); +INSERT INTO t1 VALUES (112.223e-2); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e-1); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e0); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e1); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e2); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e3); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e4); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (-123.456e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.112233 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +2000-01-12 00:00:00.000000 +2000-11-22 00:00:00.000000 +2001-12-23 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing UPDATE between DATETIME(6) and DATETIME/BIGINT/DECIMAL/DOUBLE +# +CREATE TABLE t1 (t0 DATETIME, t6 DATETIME(6), i BIGINT, d DECIMAL(20,6), f DOUBLE); +INSERT INTO t1 (t0) VALUES ('0000-00-00 11:22:33'); +UPDATE t1 SET t6=t0, i=t0, d=t0, f=t0; +SELECT * FROM t1; +t0 t6 i d f +0000-00-00 11:22:33 0000-00-00 11:22:33.000000 112233 112233.000000 112233 +UPDATE t1 SET t6='0000-00-00 11:22:33.1'; +UPDATE t1 SET t0=t6, i=t6, d=t6, f=t6; +SELECT * FROM t1; +t0 t6 i d f +0000-00-00 11:22:33 0000-00-00 11:22:33.100000 112233 112233.100000 112233.1 +UPDATE t1 SET i=20000101112233, d=20001010112233.1, f=00001010112233.1; +UPDATE t1 SET t6=i; +SELECT t6 FROM t1; +t6 +2000-01-01 11:22:33.000000 +UPDATE t1 SET t6=d; +SELECT t6 FROM t1; +t6 +2000-10-10 11:22:33.100000 +UPDATE t1 SET t6=f; +SELECT t6 FROM t1; +t6 +2000-10-10 11:22:33.100000 +DROP TABLE t1; +# +# Testing JOIN with comparison between DATETIME(6) and DATE +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-02 00:00:00.000000'); +CREATE TABLE t2 (a DATE); +INSERT INTO t2 VALUES ('2000-01-01'); +INSERT INTO t2 VALUES ('2000-01-02'); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:00:00.000000 2000-01-01 +2000-01-02 00:00:00.000000 2000-01-02 +ALTER TABLE t2 MODIFY a DATETIME(6); +SELECT * FROM t1, t2 WHERE t1.a=CAST(t2.a AS DATE) ORDER BY t1.a, t2.a; +a a +2000-01-01 00:00:00.000000 2000-01-01 00:00:00.000000 +2000-01-02 00:00:00.000000 2000-01-02 00:00:00.000000 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing JOIN with comparison between DATETIME(6) and BIGINT +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33.123'); +CREATE TABLE t2 (b BIGINT); +INSERT INTO t2 VALUES (20000101); +INSERT INTO t2 VALUES (20000101112233); +SELECT * FROM t1, t2 WHERE a=b; +a b +2000-01-01 11:22:33.000000 20000101112233 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between DATETIME(6) and DECIMAL(20,6) +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456'); +CREATE TABLE t2 (b DECIMAL(20,6)); +INSERT INTO t2 VALUES (20010101112233); +INSERT INTO t2 VALUES (20010101112233.123); +INSERT INTO t2 VALUES (20010101112233.123456); +SELECT * FROM t1, t2 WHERE a=b; +a b +2001-01-01 11:22:33.000000 20010101112233.000000 +2001-01-01 11:22:33.123000 20010101112233.123000 +2001-01-01 11:22:33.123456 20010101112233.123456 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between DATETIME(6) and DECIMAL(20,3) +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456'); +CREATE TABLE t2 (b DECIMAL(20,3)); +INSERT INTO t2 VALUES (20010101112233); +INSERT INTO t2 VALUES (20010101112233.123); +SELECT * FROM t1, t2 WHERE a=b; +a b +2001-01-01 11:22:33.000000 20010101112233.000 +2001-01-01 11:22:33.123000 20010101112233.123 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between DATETIME(6) and DOUBLE +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('0000-00-00 11:22:33'); +INSERT INTO t1 VALUES ('0000-00-00 11:22:33.123'); +INSERT INTO t1 VALUES ('0000-00-00 11:22:33.123456'); +CREATE TABLE t2 (b DOUBLE); +INSERT INTO t2 VALUES (112233); +INSERT INTO t2 VALUES (112233.123); +INSERT INTO t2 VALUES (112233.123456); +SELECT * FROM t1, t2 WHERE a=b; +a b +0000-00-00 11:22:33.000000 112233 +0000-00-00 11:22:33.123000 112233.123 +0000-00-00 11:22:33.123456 112233.123456 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between DATETIME(6) and VARCHAR +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +CREATE TABLE t2 (b VARCHAR(64)); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.123'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.1230'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.12300'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.123000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.0'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.0000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.00000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.000000'); +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +ALTER TABLE t1 ADD KEY (a); +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +ALTER TABLE t2 ADD KEY(b); +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +ALTER TABLE t1 DROP KEY a; +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +DROP TABLE t1, t2; +# +# Testing arithmetic with INT, DECIMAL, FLOAT +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000001'); +SELECT a, a + 0, a + 1, a + 1.0, a + 1e0 FROM t1; +a a + 0 a + 1 a + 1.0 a + 1e0 +2001-01-01 00:00:00.000000 20010101000000.000000 20010101000001.000000 20010101000001.000000 20010101000001 +2001-01-01 00:00:00.000001 20010101000000.000001 20010101000001.000001 20010101000001.000001 20010101000001 +CREATE TABLE t2 AS SELECT a + 1 AS i, a + 1.0 AS d, a + 1e0 AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` decimal(21,6) DEFAULT NULL, + `d` decimal(21,6) DEFAULT NULL, + `f` double DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Testing that DATETIME behaves as INT/DECIMAL for numeric arithmetic +# +CREATE TABLE t1 (t0 DATETIME, t3 DATETIME(3), t6 DATETIME(6)); +CREATE TABLE t2 AS SELECT +t0 + 1, t3 + 1, t6 + 1, +t0 - 1, t3 - 1, t6 - 1, +t0 * 1, t3 * 1, t6 * 1, +t0 / 1, t3 / 1, t6 / 1, +TIMESTAMP'2001-01-01 10:10:10' + 1, +TIMESTAMP'2001-01-01 10:10:10.123' + 1, +TIMESTAMP'2001-01-01 10:10:10.123456' + 1, +TIMESTAMP'2001-01-01 10:10:10' - 1, +TIMESTAMP'2001-01-01 10:10:10.123' - 1, +TIMESTAMP'2001-01-01 10:10:10.123456' - 1, +TIMESTAMP'2001-01-01 10:10:10' * 1, +TIMESTAMP'2001-01-01 10:10:10.123' * 1, +TIMESTAMP'2001-01-01 10:10:10.123456' * 1, +TIMESTAMP'2001-01-01 10:10:10' / 1, +TIMESTAMP'2001-01-01 10:10:10.123' / 1, +TIMESTAMP'2001-01-01 10:10:10.123456' / 1 +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t0 + 1` bigint DEFAULT NULL, + `t3 + 1` decimal(18,3) DEFAULT NULL, + `t6 + 1` decimal(21,6) DEFAULT NULL, + `t0 - 1` bigint DEFAULT NULL, + `t3 - 1` decimal(18,3) DEFAULT NULL, + `t6 - 1` decimal(21,6) DEFAULT NULL, + `t0 * 1` bigint DEFAULT NULL, + `t3 * 1` decimal(18,3) DEFAULT NULL, + `t6 * 1` decimal(21,6) DEFAULT NULL, + `t0 / 1` decimal(18,4) DEFAULT NULL, + `t3 / 1` decimal(21,7) DEFAULT NULL, + `t6 / 1` decimal(24,10) DEFAULT NULL, + `TIMESTAMP'2001-01-01 10:10:10' + 1` bigint NOT NULL DEFAULT '0', + `TIMESTAMP'2001-01-01 10:10:10.123' + 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `TIMESTAMP'2001-01-01 10:10:10.123456' + 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `TIMESTAMP'2001-01-01 10:10:10' - 1` bigint NOT NULL DEFAULT '0', + `TIMESTAMP'2001-01-01 10:10:10.123' - 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `TIMESTAMP'2001-01-01 10:10:10.123456' - 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `TIMESTAMP'2001-01-01 10:10:10' * 1` bigint NOT NULL DEFAULT '0', + `TIMESTAMP'2001-01-01 10:10:10.123' * 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `TIMESTAMP'2001-01-01 10:10:10.123456' * 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `TIMESTAMP'2001-01-01 10:10:10' / 1` decimal(18,4) DEFAULT NULL, + `TIMESTAMP'2001-01-01 10:10:10.123' / 1` decimal(21,7) DEFAULT NULL, + `TIMESTAMP'2001-01-01 10:10:10.123456' / 1` decimal(24,10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing that DATETIME behaves as DECIMAL for SUM() and AVG() +# +SET @t='2010-01-01 00:11:12.123456'; +CREATE TABLE t1 (t0 DATETIME, t3 DATETIME(3), t6 DATETIME(6)); +INSERT INTO t1 VALUES (@t, @t, @t); +SELECT MIN(t0), MAX(t0), AVG(t0), SUM(t0) FROM t1; +MIN(t0) 2010-01-01 00:11:12 +MAX(t0) 2010-01-01 00:11:12 +AVG(t0) 20100101001112.0000 +SUM(t0) 20100101001112 +SELECT MIN(t3), MAX(t3), AVG(t3), SUM(t3) FROM t1; +MIN(t3) 2010-01-01 00:11:12.123 +MAX(t3) 2010-01-01 00:11:12.123 +AVG(t3) 20100101001112.1230000 +SUM(t3) 20100101001112.123 +SELECT MIN(t6), MAX(t6), AVG(t6), SUM(t6) FROM t1; +MIN(t6) 2010-01-01 00:11:12.123456 +MAX(t6) 2010-01-01 00:11:12.123456 +AVG(t6) 20100101001112.1234560000 +SUM(t6) 20100101001112.123456 +SET @t='2010-01-01 00:11:12.000000'; +INSERT INTO t1 VALUES (@t, @t, @t); +SELECT MIN(t0), MAX(t0), AVG(t0), SUM(t0) FROM t1; +MIN(t0) 2010-01-01 00:11:12 +MAX(t0) 2010-01-01 00:11:12 +AVG(t0) 20100101001112.0000 +SUM(t0) 40200202002224 +SELECT MIN(t3), MAX(t3), AVG(t3), SUM(t3) FROM t1; +MIN(t3) 2010-01-01 00:11:12.000 +MAX(t3) 2010-01-01 00:11:12.123 +AVG(t3) 20100101001112.0615000 +SUM(t3) 40200202002224.123 +SELECT MIN(t6), MAX(t6), AVG(t6), SUM(t6) FROM t1; +MIN(t6) 2010-01-01 00:11:12.000000 +MAX(t6) 2010-01-01 00:11:12.123456 +AVG(t6) 20100101001112.0617280000 +SUM(t6) 40200202002224.123456 +CREATE TABLE t2 AS SELECT +MIN(t0), MAX(t0), AVG(t0), SUM(t0), +MIN(t3), MAX(t3), AVG(t3), SUM(t3), +MIN(t6), MAX(t6), AVG(t6), SUM(t6) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MIN(t0)` datetime DEFAULT NULL, + `MAX(t0)` datetime DEFAULT NULL, + `AVG(t0)` decimal(18,4) DEFAULT NULL, + `SUM(t0)` decimal(36,0) DEFAULT NULL, + `MIN(t3)` datetime(3) DEFAULT NULL, + `MAX(t3)` datetime(3) DEFAULT NULL, + `AVG(t3)` decimal(21,7) DEFAULT NULL, + `SUM(t3)` decimal(39,3) DEFAULT NULL, + `MIN(t6)` datetime(6) DEFAULT NULL, + `MAX(t6)` datetime(6) DEFAULT NULL, + `AVG(t6)` decimal(24,10) DEFAULT NULL, + `SUM(t6)` decimal(42,6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +SET sql_mode = default; +# +# Testing functions ADDTIME, SUBTIME, TIMESTAMP, TIMEDIFF, DATE_ADD/SUB +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('1000-01-01 01:00:00.000000'); +INSERT INTO t1 VALUES ('1000-01-01 01:00:00.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2001-01-01 01:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 01:00:00.000001'); +SELECT ADDTIME(a, '00:00:00.000001') FROM t1 ORDER BY a; +ADDTIME(a, '00:00:00.000001') +1000-01-01 01:00:00.000001 +1000-01-01 01:00:00.000002 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000002 +2001-01-01 01:00:00.000001 +2001-01-01 01:00:00.000002 +SELECT ADDTIME(a, '10:00:00.000001') FROM t1 ORDER BY a; +ADDTIME(a, '10:00:00.000001') +1000-01-01 11:00:00.000001 +1000-01-01 11:00:00.000002 +2001-01-01 10:00:00.000001 +2001-01-01 10:00:00.000002 +2001-01-01 11:00:00.000001 +2001-01-01 11:00:00.000002 +SELECT ADDTIME(CAST(a AS DATETIME(0)), 100000) FROM t1 ORDER BY a; +ADDTIME(CAST(a AS DATETIME(0)), 100000) +1000-01-01 11:00:00 +1000-01-01 11:00:00 +2001-01-01 10:00:00 +2001-01-01 10:00:00 +2001-01-01 11:00:00 +2001-01-01 11:00:00 +SELECT ADDTIME(CAST(a AS DATETIME(0)), 100000.1) FROM t1 ORDER BY a; +ADDTIME(CAST(a AS DATETIME(0)), 100000.1) +1000-01-01 11:00:00.1 +1000-01-01 11:00:00.1 +2001-01-01 10:00:00.1 +2001-01-01 10:00:00.1 +2001-01-01 11:00:00.1 +2001-01-01 11:00:00.1 +SELECT a, ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(0))) FROM t1 ORDER BY a; +a ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(0))) +1000-01-01 01:00:00.000000 1000-01-01 11:00:00 +1000-01-01 01:00:00.000001 1000-01-01 11:00:00 +2001-01-01 00:00:00.000000 2001-01-01 10:00:00 +2001-01-01 00:00:00.000001 2001-01-01 10:00:00 +2001-01-01 01:00:00.000000 2001-01-01 11:00:00 +2001-01-01 01:00:00.000001 2001-01-01 11:00:00 +SELECT a, ADDTIME(CAST(a AS DATETIME(6)), CAST('10:00:00' AS TIME(0))) FROM t1 ORDER BY a; +a ADDTIME(CAST(a AS DATETIME(6)), CAST('10:00:00' AS TIME(0))) +1000-01-01 01:00:00.000000 1000-01-01 11:00:00.000000 +1000-01-01 01:00:00.000001 1000-01-01 11:00:00.000001 +2001-01-01 00:00:00.000000 2001-01-01 10:00:00.000000 +2001-01-01 00:00:00.000001 2001-01-01 10:00:00.000001 +2001-01-01 01:00:00.000000 2001-01-01 11:00:00.000000 +2001-01-01 01:00:00.000001 2001-01-01 11:00:00.000001 +SELECT a, ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(6))) FROM t1 ORDER BY a; +a ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(6))) +1000-01-01 01:00:00.000000 1000-01-01 11:00:00.000000 +1000-01-01 01:00:00.000001 1000-01-01 11:00:00.000000 +2001-01-01 00:00:00.000000 2001-01-01 10:00:00.000000 +2001-01-01 00:00:00.000001 2001-01-01 10:00:00.000000 +2001-01-01 01:00:00.000000 2001-01-01 11:00:00.000000 +2001-01-01 01:00:00.000001 2001-01-01 11:00:00.000000 +SELECT ADDTIME(a, a) FROM t1 ORDER BY a; +ADDTIME(a, a) +NULL +NULL +NULL +NULL +NULL +NULL +CREATE TABLE t2 AS SELECT +ADDTIME(a, '00:00:00.000001'), +ADDTIME(a, '10:00:00.000001'), +ADDTIME(CAST(a AS DATETIME(0)), 100000), +ADDTIME(CAST(a AS DATETIME(0)), 100000.1), +ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(0))), +ADDTIME(CAST(a AS DATETIME(6)), CAST('10:00:00' AS TIME(0))), +ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(6))) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ADDTIME(a, '00:00:00.000001')` datetime(6) DEFAULT NULL, + `ADDTIME(a, '10:00:00.000001')` datetime(6) DEFAULT NULL, + `ADDTIME(CAST(a AS DATETIME(0)), 100000)` datetime DEFAULT NULL, + `ADDTIME(CAST(a AS DATETIME(0)), 100000.1)` datetime(1) DEFAULT NULL, + `ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(0)))` datetime DEFAULT NULL, + `ADDTIME(CAST(a AS DATETIME(6)), CAST('10:00:00' AS TIME(0)))` datetime(6) DEFAULT NULL, + `ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(6)))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +SELECT TIMESTAMP(a, '10:00:00') FROM t1; +TIMESTAMP(a, '10:00:00') +1000-01-01 11:00:00.000000 +1000-01-01 11:00:00.000001 +2001-01-01 10:00:00.000000 +2001-01-01 10:00:00.000001 +2001-01-01 11:00:00.000000 +2001-01-01 11:00:00.000001 +SELECT TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0))) FROM t1; +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0))) +1000-01-01 01:00:00 +1000-01-01 01:00:00 +2001-01-01 00:00:00 +2001-01-01 00:00:00 +2001-01-01 01:00:00 +2001-01-01 01:00:00 +SELECT TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0))) FROM t1; +TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0))) +1000-01-01 01:00:00.000000 +1000-01-01 01:00:00.000001 +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000001 +2001-01-01 01:00:00.000000 +2001-01-01 01:00:00.000001 +SELECT TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6))) FROM t1; +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6))) +1000-01-01 01:00:00.000000 +1000-01-01 01:00:00.000000 +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000000 +2001-01-01 01:00:00.000000 +2001-01-01 01:00:00.000000 +CREATE TABLE t2 AS SELECT +TIMESTAMP(a, '10:00:00'), +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0))), +TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0))), +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6))) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `TIMESTAMP(a, '10:00:00')` datetime(6) DEFAULT NULL, + `TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0)))` datetime DEFAULT NULL, + `TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0)))` datetime(6) DEFAULT NULL, + `TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6)))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +SELECT SUBTIME(a, '00:00:00.000001') FROM t1 ORDER BY a; +SUBTIME(a, '00:00:00.000001') +1000-01-01 00:59:59.999999 +1000-01-01 01:00:00.000000 +2000-12-31 23:59:59.999999 +2001-01-01 00:00:00.000000 +2001-01-01 00:59:59.999999 +2001-01-01 01:00:00.000000 +SELECT SUBTIME(a, '10:00:00.000001') FROM t1 ORDER BY a; +SUBTIME(a, '10:00:00.000001') +0999-12-31 14:59:59.999999 +0999-12-31 15:00:00.000000 +2000-12-31 13:59:59.999999 +2000-12-31 14:00:00.000000 +2000-12-31 14:59:59.999999 +2000-12-31 15:00:00.000000 +SELECT SUBTIME(a, a) FROM t1 ORDER BY a; +SUBTIME(a, a) +NULL +NULL +NULL +NULL +NULL +NULL +SELECT DATE_ADD(a, INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_ADD(a, INTERVAL 1 MINUTE) +1000-01-01 01:01:00.000000 +1000-01-01 01:01:00.000001 +2001-01-01 00:01:00.000000 +2001-01-01 00:01:00.000001 +2001-01-01 01:01:00.000000 +2001-01-01 01:01:00.000001 +SELECT DATE_SUB(a, INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_SUB(a, INTERVAL 1 MINUTE) +1000-01-01 00:59:00.000000 +1000-01-01 00:59:00.000001 +2000-12-31 23:59:00.000000 +2000-12-31 23:59:00.000001 +2001-01-01 00:59:00.000000 +2001-01-01 00:59:00.000001 +SELECT a, DATE_ADD(a, INTERVAL 1.1 SECOND) FROM t1 ORDER BY a; +a DATE_ADD(a, INTERVAL 1.1 SECOND) +1000-01-01 01:00:00.000000 1000-01-01 01:00:01.100000 +1000-01-01 01:00:00.000001 1000-01-01 01:00:01.100001 +2001-01-01 00:00:00.000000 2001-01-01 00:00:01.100000 +2001-01-01 00:00:00.000001 2001-01-01 00:00:01.100001 +2001-01-01 01:00:00.000000 2001-01-01 01:00:01.100000 +2001-01-01 01:00:00.000001 2001-01-01 01:00:01.100001 +SELECT a, DATE_ADD(a, INTERVAL 1.000009 SECOND) FROM t1 ORDER BY a; +a DATE_ADD(a, INTERVAL 1.000009 SECOND) +1000-01-01 01:00:00.000000 1000-01-01 01:00:01.000009 +1000-01-01 01:00:00.000001 1000-01-01 01:00:01.000010 +2001-01-01 00:00:00.000000 2001-01-01 00:00:01.000009 +2001-01-01 00:00:00.000001 2001-01-01 00:00:01.000010 +2001-01-01 01:00:00.000000 2001-01-01 01:00:01.000009 +2001-01-01 01:00:00.000001 2001-01-01 01:00:01.000010 +SELECT a, DATE_SUB(a, INTERVAL 1.1 SECOND) FROM t1 ORDER BY a; +a DATE_SUB(a, INTERVAL 1.1 SECOND) +1000-01-01 01:00:00.000000 1000-01-01 00:59:58.900000 +1000-01-01 01:00:00.000001 1000-01-01 00:59:58.900001 +2001-01-01 00:00:00.000000 2000-12-31 23:59:58.900000 +2001-01-01 00:00:00.000001 2000-12-31 23:59:58.900001 +2001-01-01 01:00:00.000000 2001-01-01 00:59:58.900000 +2001-01-01 01:00:00.000001 2001-01-01 00:59:58.900001 +SELECT a, DATE_SUB(a, INTERVAL 1.000009 SECOND) FROM t1 ORDER BY a; +a DATE_SUB(a, INTERVAL 1.000009 SECOND) +1000-01-01 01:00:00.000000 1000-01-01 00:59:58.999991 +1000-01-01 01:00:00.000001 1000-01-01 00:59:58.999992 +2001-01-01 00:00:00.000000 2000-12-31 23:59:58.999991 +2001-01-01 00:00:00.000001 2000-12-31 23:59:58.999992 +2001-01-01 01:00:00.000000 2001-01-01 00:59:58.999991 +2001-01-01 01:00:00.000001 2001-01-01 00:59:58.999992 +SELECT a, DATE_ADD(a, INTERVAL -0.1 SECOND) FROM t1 ORDER BY a; +a DATE_ADD(a, INTERVAL -0.1 SECOND) +1000-01-01 01:00:00.000000 1000-01-01 00:59:59.900000 +1000-01-01 01:00:00.000001 1000-01-01 00:59:59.900001 +2001-01-01 00:00:00.000000 2000-12-31 23:59:59.900000 +2001-01-01 00:00:00.000001 2000-12-31 23:59:59.900001 +2001-01-01 01:00:00.000000 2001-01-01 00:59:59.900000 +2001-01-01 01:00:00.000001 2001-01-01 00:59:59.900001 +SELECT a, DATE_SUB(a, INTERVAL -0.1 SECOND) FROM t1 ORDER BY a; +a DATE_SUB(a, INTERVAL -0.1 SECOND) +1000-01-01 01:00:00.000000 1000-01-01 01:00:00.100000 +1000-01-01 01:00:00.000001 1000-01-01 01:00:00.100001 +2001-01-01 00:00:00.000000 2001-01-01 00:00:00.100000 +2001-01-01 00:00:00.000001 2001-01-01 00:00:00.100001 +2001-01-01 01:00:00.000000 2001-01-01 01:00:00.100000 +2001-01-01 01:00:00.000001 2001-01-01 01:00:00.100001 +SELECT DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MINUTE) +1000-01-01 01:01:00 +1000-01-01 01:01:00 +2001-01-01 00:01:00 +2001-01-01 00:01:00 +2001-01-01 01:01:00 +2001-01-01 01:01:00 +SELECT DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MINUTE) +1000-01-01 00:59:00 +1000-01-01 00:59:00 +2000-12-31 23:59:00 +2000-12-31 23:59:00 +2001-01-01 00:59:00 +2001-01-01 00:59:00 +SELECT DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) FROM t1 ORDER BY a; +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) +1000-01-01 01:00:00.000001 +1000-01-01 01:00:00.000001 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000001 +2001-01-01 01:00:00.000001 +2001-01-01 01:00:00.000001 +SELECT DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) FROM t1 ORDER BY a; +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) +1000-01-01 00:59:59.999999 +1000-01-01 00:59:59.999999 +2000-12-31 23:59:59.999999 +2000-12-31 23:59:59.999999 +2001-01-01 00:59:59.999999 +2001-01-01 00:59:59.999999 +CREATE TABLE t2 AS SELECT +DATE_ADD(a, INTERVAL 1 SECOND), +DATE_SUB(a, INTERVAL 1 SECOND), +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 SECOND), +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 SECOND), +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND), +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `DATE_ADD(a, INTERVAL 1 SECOND)` datetime(6) DEFAULT NULL, + `DATE_SUB(a, INTERVAL 1 SECOND)` datetime(6) DEFAULT NULL, + `DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 SECOND)` datetime DEFAULT NULL, + `DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 SECOND)` datetime DEFAULT NULL, + `DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND)` datetime(6) DEFAULT NULL, + `DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND)` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT MAX(ADDTIME(a, '00:00:00.1')) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MAX(ADDTIME(a, '00:00:00.1'))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2; +MAX(ADDTIME(a, '00:00:00.1')) +2001-01-01 01:00:00.100001 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1 SECOND) AS t0s0, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1.1 SECOND) AS t0s1, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1.12 SECOND) AS t0s2, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1.123 SECOND) AS t0s3, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1.1234 SECOND) AS t0s4, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1.12345 SECOND) AS t0s5, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1.123456 SECOND) AS t0s6, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00.1', INTERVAL 1 SECOND) AS t1s0, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00.12', INTERVAL 1 SECOND) AS t2s0, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00.123', INTERVAL 1 SECOND) AS t3s0, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00.1234', INTERVAL 1 SECOND) AS t4s0, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00.12345', INTERVAL 1 SECOND) AS t5s0, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00.123456', INTERVAL 1 SECOND) AS t6s0, +DATE_ADD(TIMESTAMP'2001-01-01 00:00:00', INTERVAL 1 MICROSECOND) AS t0ms; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t0s0` datetime DEFAULT NULL, + `t0s1` datetime(1) DEFAULT NULL, + `t0s2` datetime(2) DEFAULT NULL, + `t0s3` datetime(3) DEFAULT NULL, + `t0s4` datetime(4) DEFAULT NULL, + `t0s5` datetime(5) DEFAULT NULL, + `t0s6` datetime(6) DEFAULT NULL, + `t1s0` datetime(1) DEFAULT NULL, + `t2s0` datetime(2) DEFAULT NULL, + `t3s0` datetime(3) DEFAULT NULL, + `t4s0` datetime(4) DEFAULT NULL, + `t5s0` datetime(5) DEFAULT NULL, + `t6s0` datetime(6) DEFAULT NULL, + `t0ms` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +CONVERT_TZ(TIMESTAMP'2001-01-01 00:00:00', '+00:00', '+01:00') AS d0, +CONVERT_TZ(TIMESTAMP'2001-01-01 00:00:00.1', '+00:00', '+01:00') AS d1, +CONVERT_TZ(TIMESTAMP'2001-01-01 00:00:00.12', '+00:00', '+01:00') AS d2, +CONVERT_TZ(TIMESTAMP'2001-01-01 00:00:00.123', '+00:00', '+01:00') AS d3, +CONVERT_TZ(TIMESTAMP'2001-01-01 00:00:00.1234', '+00:00', '+01:00') AS d4, +CONVERT_TZ(TIMESTAMP'2001-01-01 00:00:00.12345', '+00:00', '+01:00') AS d5, +CONVERT_TZ(TIMESTAMP'2001-01-01 00:00:00.123456', '+00:00', '+01:00') AS d6; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d0` datetime DEFAULT NULL, + `d1` datetime(1) DEFAULT NULL, + `d2` datetime(2) DEFAULT NULL, + `d3` datetime(3) DEFAULT NULL, + `d4` datetime(4) DEFAULT NULL, + `d5` datetime(5) DEFAULT NULL, + `d6` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing copy from DATETIME to DATETIME(6) and vice versa +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a DATETIME(6), b DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 01:02:03.123456','0000-00-00 00:00:00'); +UPDATE t1 SET b=a; +SELECT * FROM t1; +a b +2001-01-01 01:02:03.123456 2001-01-01 01:02:03 +UPDATE t1 SET b='2002-02-02 10:11:12'; +UPDATE t1 SET a=b; +SELECT * FROM t1; +a b +2002-02-02 10:11:12.000000 2002-02-02 10:11:12 +DROP TABLE t1; +# +# Testing ALTER from DATETIME(6) to DATETIME and vice versa +# +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03'); +ALTER TABLE t1 MODIFY a DATETIME(6); +SELECT * FROM t1; +a +2000-01-01 01:02:03.000000 +UPDATE t1 SET a='2000-01-01 01:03:03.456'; +SELECT * FROM t1; +a +2000-01-01 01:03:03.456000 +ALTER TABLE t1 MODIFY a DATETIME; +SELECT * FROM t1; +a +2000-01-01 01:03:03 +DROP TABLE t1; +# +# Testing ALTER between DATETIME and BIGINT +# +CREATE TABLE t1 (a DATETIME, b DATETIME(6)); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33', '2000-01-01 11:22:33'); +ALTER TABLE t1 MODIFY a BIGINT, MODIFY b BIGINT; +SELECT * FROM t1; +a b +20000101112233 20000101112233 +UPDATE t1 SET a=20000101112233, b=20000101112233; +ALTER TABLE t1 MODIFY a DATETIME, MODIFY b DATETIME(6); +SELECT * FROM t1; +a b +2000-01-01 11:22:33 2000-01-01 11:22:33.000000 +DROP TABLE t1; +# +# Testing ALTER between DATETIME(6) and DOUBLE +# +CREATE TABLE t1 (a DATETIME, b DATETIME(6)); +INSERT INTO t1 VALUES ('0001-00-00 11:22:33', '0001-00-00 11:22:33.1234'); +ALTER TABLE t1 MODIFY a DOUBLE, MODIFY b DOUBLE; +SELECT * FROM t1; +a b +10000112233 10000112233.1234 +UPDATE t1 SET a=20010101101112, b=20010101101112.1; +ALTER TABLE t1 MODIFY a DATETIME, MODIFY b DATETIME(6); +SELECT * FROM t1; +a b +2001-01-01 10:11:12 2001-01-01 10:11:12.100000 +DROP TABLE t1; +# +# Testing ALTER between DATETIME(6) and DECIMAL +# +CREATE TABLE t1 (a DATETIME, b DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33', '2001-01-01 11:22:33.1234'); +ALTER TABLE t1 MODIFY a DECIMAL(30,6), MODIFY b DECIMAL(30,6); +SELECT * FROM t1; +a b +20010101112233.000000 20010101112233.123400 +UPDATE t1 SET a=20010101112233, b=20010101112233.1234; +ALTER TABLE t1 MODIFY a DATETIME, MODIFY b DATETIME(6); +SELECT * FROM t1; +a b +2001-01-01 11:22:33 2001-01-01 11:22:33.123400 +DROP TABLE t1; +# +# Testing ALTER from DATETIME to various other temporal types +# +CREATE TABLE t1 (a DATETIME(6), b DATETIME(6), c DATETIME(6)); +INSERT INTO t1 VALUES +('2001-01-01 10:10:10.1', '2001-01-01 10:10:10.1', '2001-01-01 10:10:10.1'); +ALTER TABLE t1 MODIFY a TIME(6), MODIFY b TIMESTAMP(6), MODIFY c DATE; +Warnings: +Note 1265 Data truncated for column 'c' at row 1 +SELECT * FROM t1; +a b c +10:10:10.100000 2001-01-01 10:10:10.100000 2001-01-01 +DROP TABLE t1; +# +# Testing EXPLAIN SELECT for CAST(DATETIME(N)) +# +EXPLAIN SELECT CAST('10:10:10' AS DATETIME); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime) AS `CAST('10:10:10' AS DATETIME)` +EXPLAIN SELECT CAST('10:10:10' AS DATETIME(0)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime) AS `CAST('10:10:10' AS DATETIME(0))` +EXPLAIN SELECT CAST('10:10:10' AS DATETIME(1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime(1)) AS `CAST('10:10:10' AS DATETIME(1))` +EXPLAIN SELECT CAST('10:10:10' AS DATETIME(2)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime(2)) AS `CAST('10:10:10' AS DATETIME(2))` +EXPLAIN SELECT CAST('10:10:10' AS DATETIME(3)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime(3)) AS `CAST('10:10:10' AS DATETIME(3))` +EXPLAIN SELECT CAST('10:10:10' AS DATETIME(4)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime(4)) AS `CAST('10:10:10' AS DATETIME(4))` +EXPLAIN SELECT CAST('10:10:10' AS DATETIME(5)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime(5)) AS `CAST('10:10:10' AS DATETIME(5))` +EXPLAIN SELECT CAST('10:10:10' AS DATETIME(6)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select cast('10:10:10' as datetime(6)) AS `CAST('10:10:10' AS DATETIME(6))` +# +# Testing CAST with bad FSPs +# +SELECT CAST(1 AS DATETIME(-1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1 +SELECT CAST(1 AS DATETIME(7)); +ERROR 42000: Too-big precision 7 specified for 'CAST'. Maximum is 6. +SELECT CAST(1 AS DATETIME(31)); +ERROR 42000: Too-big precision 31 specified for 'CAST'. Maximum is 6. +# +# Testing conversion from DATETIME(6) to INT +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:58.499'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:58.999'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:59.499'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:59.999'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:58.499'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:58.999'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:59.499'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:59.999'); +ALTER TABLE t1 ADD b BIGINT, ADD c DATETIME(6); +UPDATE t1 SET b=a, c=a; +ALTER TABLE t1 MODIFY c BIGINT; +SELECT a, CAST(a AS SIGNED), b, c FROM t1; +a CAST(a AS SIGNED) b c +2001-01-01 10:10:58.499000 20010101101058 20010101101058 20010101101058 +2001-01-01 10:10:58.999000 20010101101059 20010101101059 20010101101059 +2001-01-01 10:10:59.499000 20010101101059 20010101101059 20010101101059 +2001-01-01 10:10:59.999000 20010101101100 20010101101100 20010101101100 +2001-12-31 23:59:58.499000 20011231235958 20011231235958 20011231235958 +2001-12-31 23:59:58.999000 20011231235959 20011231235959 20011231235959 +2001-12-31 23:59:59.499000 20011231235959 20011231235959 20011231235959 +2001-12-31 23:59:59.999000 20020101000000 20020101000000 20020101000000 +DROP TABLE t1; +# +# Testing INT value and CAST of DATETIME(6) to various other types +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.999'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:58.499'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:58.999'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:59.499'); +INSERT INTO t1 VALUES ('2001-12-31 23:59:59.999'); +SELECT a << 0 FROM t1; +a << 0 +20010101112233 +20010101112234 +20011231235958 +20011231235959 +20011231235959 +20020101000000 +SELECT CAST(a AS SIGNED) FROM t1; +CAST(a AS SIGNED) +20010101112233 +20010101112234 +20011231235958 +20011231235959 +20011231235959 +20020101000000 +SELECT CAST(a AS UNSIGNED) FROM t1; +CAST(a AS UNSIGNED) +20010101112233 +20010101112234 +20011231235958 +20011231235959 +20011231235959 +20020101000000 +SELECT CAST(a AS DECIMAL(30,6)) FROM t1; +CAST(a AS DECIMAL(30,6)) +20010101112233.123000 +20010101112233.999000 +20011231235958.499000 +20011231235958.999000 +20011231235959.499000 +20011231235959.999000 +SELECT CAST(a AS DECIMAL(30,3)) FROM t1; +CAST(a AS DECIMAL(30,3)) +20010101112233.123 +20010101112233.999 +20011231235958.499 +20011231235958.999 +20011231235959.499 +20011231235959.999 +SELECT CAST(a AS CHAR) FROM t1; +CAST(a AS CHAR) +2001-01-01 11:22:33.123000 +2001-01-01 11:22:33.999000 +2001-12-31 23:59:58.499000 +2001-12-31 23:59:58.999000 +2001-12-31 23:59:59.499000 +2001-12-31 23:59:59.999000 +SELECT CAST(a AS CHAR(6)) FROM t1; +CAST(a AS CHAR(6)) +2001-0 +2001-0 +2001-1 +2001-1 +2001-1 +2001-1 +Warnings: +Warning 1292 Truncated incorrect CHAR(6) value: '2001-01-01 11:22:33.123000' +Warning 1292 Truncated incorrect CHAR(6) value: '2001-01-01 11:22:33.999000' +Warning 1292 Truncated incorrect CHAR(6) value: '2001-12-31 23:59:58.499000' +Warning 1292 Truncated incorrect CHAR(6) value: '2001-12-31 23:59:58.999000' +Warning 1292 Truncated incorrect CHAR(6) value: '2001-12-31 23:59:59.499000' +Warning 1292 Truncated incorrect CHAR(6) value: '2001-12-31 23:59:59.999000' +CREATE TABLE t2 AS SELECT CAST(a AS CHAR) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT a, LENGTH(a) FROM t2; +a LENGTH(a) +2001-01-01 11:22:33.123000 26 +2001-01-01 11:22:33.999000 26 +2001-12-31 23:59:58.499000 26 +2001-12-31 23:59:58.999000 26 +2001-12-31 23:59:59.499000 26 +2001-12-31 23:59:59.999000 26 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing explicit CAST from TIME to DATETIME +# +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a TIME, b TIME(6), c INT, d VARCHAR(32), e INT); +INSERT INTO t1 VALUES ('15:00:00', '15:00:00.123456', 150000, '15:00:00', 15*3600); +INSERT INTO t1 VALUES ('45:00:00', '45:00:00.123456', 450000, '45:00:00', 45*3600); +INSERT INTO t1 VALUES ('-15:00:00', '-15:00:00.123456', -150000, '-15:00:00', -15*3600); +INSERT INTO t1 VALUES ('-45:00:00', '-45:00:00.123456', -450000, '-45:00:00', -45*3600); +SELECT a, CAST(a AS DATETIME), CAST(b AS DATETIME), CAST(c AS DATETIME), CAST(d AS DATETIME), CAST(SEC_TO_TIME(e) AS DATETIME), CAST(CAST(a AS TIME) AS DATETIME) FROM t1;; +a 15:00:00 +CAST(a AS DATETIME) 2001-01-01 15:00:00 +CAST(b AS DATETIME) 2001-01-01 15:00:00 +CAST(c AS DATETIME) 2015-00-00 00:00:00 +CAST(d AS DATETIME) 2015-00-00 00:00:00 +CAST(SEC_TO_TIME(e) AS DATETIME) 2001-01-01 15:00:00 +CAST(CAST(a AS TIME) AS DATETIME) 2001-01-01 15:00:00 +a 45:00:00 +CAST(a AS DATETIME) 2001-01-02 21:00:00 +CAST(b AS DATETIME) 2001-01-02 21:00:00 +CAST(c AS DATETIME) 2045-00-00 00:00:00 +CAST(d AS DATETIME) 2045-00-00 00:00:00 +CAST(SEC_TO_TIME(e) AS DATETIME) 2001-01-02 21:00:00 +CAST(CAST(a AS TIME) AS DATETIME) 2001-01-02 21:00:00 +a -15:00:00 +CAST(a AS DATETIME) 2000-12-31 09:00:00 +CAST(b AS DATETIME) 2000-12-31 09:00:00 +CAST(c AS DATETIME) NULL +CAST(d AS DATETIME) NULL +CAST(SEC_TO_TIME(e) AS DATETIME) 2000-12-31 09:00:00 +CAST(CAST(a AS TIME) AS DATETIME) 2000-12-31 09:00:00 +a -45:00:00 +CAST(a AS DATETIME) 2000-12-30 03:00:00 +CAST(b AS DATETIME) 2000-12-30 03:00:00 +CAST(c AS DATETIME) NULL +CAST(d AS DATETIME) NULL +CAST(SEC_TO_TIME(e) AS DATETIME) 2000-12-30 03:00:00 +CAST(CAST(a AS TIME) AS DATETIME) 2000-12-30 03:00:00 +Warnings: +Level Warning +Code 1292 +Message Incorrect datetime value: '-150000' +Level Warning +Code 1292 +Message Incorrect datetime value: '-15:00:00' +Level Warning +Code 1292 +Message Incorrect datetime value: '-450000' +Level Warning +Code 1292 +Message Incorrect datetime value: '-45:00:00' +SELECT a, CAST(a AS DATETIME(6)), CAST(b AS DATETIME(6)), CAST(c AS DATETIME(6)), CAST(d AS DATETIME(6)), CAST(SEC_TO_TIME(e) AS DATETIME(6)), CAST(CAST(a AS TIME) AS DATETIME(6)) FROM t1;; +a 15:00:00 +CAST(a AS DATETIME(6)) 2001-01-01 15:00:00.000000 +CAST(b AS DATETIME(6)) 2001-01-01 15:00:00.123456 +CAST(c AS DATETIME(6)) 2015-00-00 00:00:00.000000 +CAST(d AS DATETIME(6)) 2015-00-00 00:00:00.000000 +CAST(SEC_TO_TIME(e) AS DATETIME(6)) 2001-01-01 15:00:00.000000 +CAST(CAST(a AS TIME) AS DATETIME(6)) 2001-01-01 15:00:00.000000 +a 45:00:00 +CAST(a AS DATETIME(6)) 2001-01-02 21:00:00.000000 +CAST(b AS DATETIME(6)) 2001-01-02 21:00:00.123456 +CAST(c AS DATETIME(6)) 2045-00-00 00:00:00.000000 +CAST(d AS DATETIME(6)) 2045-00-00 00:00:00.000000 +CAST(SEC_TO_TIME(e) AS DATETIME(6)) 2001-01-02 21:00:00.000000 +CAST(CAST(a AS TIME) AS DATETIME(6)) 2001-01-02 21:00:00.000000 +a -15:00:00 +CAST(a AS DATETIME(6)) 2000-12-31 09:00:00.000000 +CAST(b AS DATETIME(6)) 2000-12-31 08:59:59.876544 +CAST(c AS DATETIME(6)) NULL +CAST(d AS DATETIME(6)) NULL +CAST(SEC_TO_TIME(e) AS DATETIME(6)) 2000-12-31 09:00:00.000000 +CAST(CAST(a AS TIME) AS DATETIME(6)) 2000-12-31 09:00:00.000000 +a -45:00:00 +CAST(a AS DATETIME(6)) 2000-12-30 03:00:00.000000 +CAST(b AS DATETIME(6)) 2000-12-30 02:59:59.876544 +CAST(c AS DATETIME(6)) NULL +CAST(d AS DATETIME(6)) NULL +CAST(SEC_TO_TIME(e) AS DATETIME(6)) 2000-12-30 03:00:00.000000 +CAST(CAST(a AS TIME) AS DATETIME(6)) 2000-12-30 03:00:00.000000 +Warnings: +Level Warning +Code 1292 +Message Incorrect datetime value: '-150000' +Level Warning +Code 1292 +Message Incorrect datetime value: '-15:00:00' +Level Warning +Code 1292 +Message Incorrect datetime value: '-450000' +Level Warning +Code 1292 +Message Incorrect datetime value: '-45:00:00' +DROP TABLE t1; +SET @@timestamp=default; +# +# Testing comparison between TIME and DATETIME +# This tests Field_time[f]::val_date_temporal() +# +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30.123'); +CREATE TABLE t1 (a TIME, b DATETIME, a6 TIME(6), b6 DATETIME(6)); +INSERT INTO t1 VALUES +(current_time, current_timestamp, current_time(6), current_timestamp(6)); +SELECT a, b FROM t1 WHERE a=b; +a b +10:20:30 2001-01-01 10:20:30 +SELECT a6, b6 FROM t1 WHERE a6=b6; +a6 b6 +10:20:30.123000 2001-01-01 10:20:30.123000 +# In this query both expressions make DATETIME data type +SELECT LEAST(a,b), LEAST(b,a) FROM t1; +LEAST(a,b) LEAST(b,a) +2001-01-01 10:20:30 2001-01-01 10:20:30 +SELECT CONCAT(LEAST(a,b)), CONCAT(LEAST(b,a)) FROM t1; +CONCAT(LEAST(a,b)) CONCAT(LEAST(b,a)) +2001-01-01 10:20:30 2001-01-01 10:20:30 +# In this query all expressions make VARCHAR data type +# So the result format depends on which value wins, with the first value having higher precedence: +SELECT LEAST(a,b,'2001-01-02'), LEAST(b,a,'2001-01-02'), LEAST(a,b,'2000-01-01') FROM t1; +LEAST(a,b,'2001-01-02') LEAST(b,a,'2001-01-02') LEAST(a,b,'2000-01-01') +2001-01-01 10:20:30 2001-01-01 10:20:30 2000-01-01 00:00:00 +# More tests with LEAST: +SELECT a, b FROM t1 WHERE a=LEAST(a,a); +a b +10:20:30 2001-01-01 10:20:30 +SELECT a, b FROM t1 WHERE a=LEAST(a,b); +a b +10:20:30 2001-01-01 10:20:30 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +# +# Comparison between DATETIME column and constant TIME epxression +# +CREATE TABLE t1 (a DATETIME(6)); +SET @@timestamp=UNIX_TIMESTAMP('2010-01-01 10:50:50.123'); +SELECT NOW(6); +NOW(6) +2010-01-01 10:50:50.123000 +INSERT INTO t1 VALUES (CURRENT_TIMESTAMP(6)), ('2010-01-01 00:00:00'); +SELECT * FROM t1 WHERE a=TIME'10:50:50.123'; +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE a=CURRENT_TIME(6); +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE a=CAST('10:50:50.123' AS TIME(6)); +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE a=MAKETIME(10,50,50.123); +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE a=SEC_TO_TIME(39050.123); +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE TIME'10:50:50.123'=a; +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE CURRENT_TIME(6)=a; +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE CAST('10:50:50.123' AS TIME(6))=a; +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE MAKETIME(10,50,50.123)=a; +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE SEC_TO_TIME(39050.123)=a; +a +2010-01-01 10:50:50.123000 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +# +# BETWEEN for combinations of DATETIME and TIME +# +SET @@timestamp=UNIX_TIMESTAMP('2010-01-01 10:50:50.123'); +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES +('2010-01-01 10:50:50.100'), ('2010-01-01 10:50:50.123'), ('2010-01-01 10:50:50.200'); +SELECT * FROM t1 WHERE a BETWEEN TIME'10:50:50.120' AND TIME'10:50:50.123'; +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE a BETWEEN TIMESTAMP'2010-01-01 10:50:50.120' AND TIME'10:50:50.123'; +a +2010-01-01 10:50:50.123000 +SELECT * FROM t1 WHERE a BETWEEN TIME'10:50:50.120' AND TIMESTAMP'2010-01-01 10:50:50.123'; +a +2010-01-01 10:50:50.123000 +ALTER TABLE t1 MODIFY a TIME(6); +SELECT * FROM t1; +a +10:50:50.100000 +10:50:50.123000 +10:50:50.200000 +SELECT * FROM t1 WHERE a BETWEEN TIME'10:50:50.120' AND TIME'10:50:50.123'; +a +10:50:50.123000 +SELECT * FROM t1 WHERE a BETWEEN TIMESTAMP'2010-01-01 10:50:50.120' AND TIME'10:50:50.123'; +a +10:50:50.123000 +SELECT * FROM t1 WHERE a BETWEEN TIME'10:50:50.120' AND TIMESTAMP'2010-01-01 10:50:50.123'; +a +10:50:50.123000 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +CREATE TABLE t1 (c INT, d VARCHAR(32)); +INSERT INTO t1 VALUES (156060, '15:60:60'); +SELECT CAST(c AS DATETIME), CAST(d AS DATETIME) FROM t1; +CAST(c AS DATETIME) CAST(d AS DATETIME) +NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '156060' +Warning 1292 Incorrect datetime value: '15:60:60' +SELECT CAST(c AS DATETIME(6)), CAST(d AS DATETIME(6)) FROM t1; +CAST(c AS DATETIME(6)) CAST(d AS DATETIME(6)) +NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '156060' +Warning 1292 Incorrect datetime value: '15:60:60' +DROP TABLE t1; +# +# Testing function TIMESTAMP(expr) +# +CREATE TABLE t1 AS SELECT +TIMESTAMP(20010101101010), +TIMESTAMP(20010101101010.1), +TIMESTAMP(20010101101010.12), +TIMESTAMP(20010101101010.123), +TIMESTAMP(20010101101010.1234), +TIMESTAMP(20010101101010.12345), +TIMESTAMP(20010101101010.123456), +TIMESTAMP('2001-01-01 00:01:01'), +TIMESTAMP('2001-01-01 00:01:01.1'), +TIMESTAMP('2001-01-01 00:01:01.12'), +TIMESTAMP('2001-01-01 00:01:01.123'), +TIMESTAMP('2001-01-01 00:01:01.1234'), +TIMESTAMP('2001-01-01 00:01:01.12345'), +TIMESTAMP('2001-01-01 00:01:01.123456'), +TIMESTAMP(CONCAT('2001-01-01 00:01:01','')), +TIMESTAMP(CONCAT('2001-01-01 00:01:01','.1')), +TIMESTAMP(CONCAT('2001-01-01 00:01:01','.12')), +TIMESTAMP(CONCAT('2001-01-01 00:01:01','.123')), +TIMESTAMP(CONCAT('2001-01-01 00:01:01','.1234')), +TIMESTAMP(CONCAT('2001-01-01 00:01:01','.12345')), +TIMESTAMP(CONCAT('2001-01-01 00:01:01','.123456')), +TIMESTAMP(TIME'00:01:01'), +TIMESTAMP(TIME'00:01:01.1'), +TIMESTAMP(TIME'00:01:01.12'), +TIMESTAMP(TIME'00:01:01.123'), +TIMESTAMP(TIME'00:01:01.1234'), +TIMESTAMP(TIME'00:01:01.12345'), +TIMESTAMP(TIME'00:01:01.123456'), +TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00')), +TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.1')), +TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.12')), +TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.123')), +TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.1234')), +TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.12345')), +TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.123456')); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `TIMESTAMP(20010101101010)` datetime DEFAULT NULL, + `TIMESTAMP(20010101101010.1)` datetime(1) DEFAULT NULL, + `TIMESTAMP(20010101101010.12)` datetime(2) DEFAULT NULL, + `TIMESTAMP(20010101101010.123)` datetime(3) DEFAULT NULL, + `TIMESTAMP(20010101101010.1234)` datetime(4) DEFAULT NULL, + `TIMESTAMP(20010101101010.12345)` datetime(5) DEFAULT NULL, + `TIMESTAMP(20010101101010.123456)` datetime(6) DEFAULT NULL, + `TIMESTAMP('2001-01-01 00:01:01')` datetime DEFAULT NULL, + `TIMESTAMP('2001-01-01 00:01:01.1')` datetime(1) DEFAULT NULL, + `TIMESTAMP('2001-01-01 00:01:01.12')` datetime(2) DEFAULT NULL, + `TIMESTAMP('2001-01-01 00:01:01.123')` datetime(3) DEFAULT NULL, + `TIMESTAMP('2001-01-01 00:01:01.1234')` datetime(4) DEFAULT NULL, + `TIMESTAMP('2001-01-01 00:01:01.12345')` datetime(5) DEFAULT NULL, + `TIMESTAMP('2001-01-01 00:01:01.123456')` datetime(6) DEFAULT NULL, + `TIMESTAMP(CONCAT('2001-01-01 00:01:01',''))` datetime DEFAULT NULL, + `TIMESTAMP(CONCAT('2001-01-01 00:01:01','.1'))` datetime(1) DEFAULT NULL, + `TIMESTAMP(CONCAT('2001-01-01 00:01:01','.12'))` datetime(2) DEFAULT NULL, + `TIMESTAMP(CONCAT('2001-01-01 00:01:01','.123'))` datetime(3) DEFAULT NULL, + `TIMESTAMP(CONCAT('2001-01-01 00:01:01','.1234'))` datetime(4) DEFAULT NULL, + `TIMESTAMP(CONCAT('2001-01-01 00:01:01','.12345'))` datetime(5) DEFAULT NULL, + `TIMESTAMP(CONCAT('2001-01-01 00:01:01','.123456'))` datetime(6) DEFAULT NULL, + `TIMESTAMP(TIME'00:01:01')` datetime DEFAULT NULL, + `TIMESTAMP(TIME'00:01:01.1')` datetime(1) DEFAULT NULL, + `TIMESTAMP(TIME'00:01:01.12')` datetime(2) DEFAULT NULL, + `TIMESTAMP(TIME'00:01:01.123')` datetime(3) DEFAULT NULL, + `TIMESTAMP(TIME'00:01:01.1234')` datetime(4) DEFAULT NULL, + `TIMESTAMP(TIME'00:01:01.12345')` datetime(5) DEFAULT NULL, + `TIMESTAMP(TIME'00:01:01.123456')` datetime(6) DEFAULT NULL, + `TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00'))` datetime DEFAULT NULL, + `TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.1'))` datetime(1) DEFAULT NULL, + `TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.12'))` datetime(2) DEFAULT NULL, + `TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.123'))` datetime(3) DEFAULT NULL, + `TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.1234'))` datetime(4) DEFAULT NULL, + `TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.12345'))` datetime(5) DEFAULT NULL, + `TIMESTAMP(TIMESTAMP('2001-01-01 00:00:00.123456'))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing DEFAULT value +# +CREATE TABLE t1 (a DATETIME(6) NOT NULL DEFAULT '2000-01-01 11:22:33.123456'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime(6) NOT NULL DEFAULT '2000-01-01 11:22:33.123456' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Mixing varios DATETIME(N) in CASE +# +CREATE TABLE t1 ( +t0 DATETIME, t1 DATETIME(1), t3 DATETIME(3),t4 DATETIME(4), t6 DATETIME(6)); +CREATE TABLE t2 AS SELECT +CASE WHEN 1 THEN t0 ELSE t1 END, +CASE WHEN 1 THEN t0 ELSE t3 END, +CASE WHEN 1 THEN t0 ELSE t4 END, +CASE WHEN 1 THEN t0 ELSE t6 END, +CASE WHEN 1 THEN t1 ELSE t0 END, +CASE WHEN 1 THEN t1 ELSE t3 END, +CASE WHEN 1 THEN t1 ELSE t4 END, +CASE WHEN 1 THEN t1 ELSE t6 END, +CASE WHEN 1 THEN t3 ELSE t0 END, +CASE WHEN 1 THEN t3 ELSE t1 END, +CASE WHEN 1 THEN t3 ELSE t4 END, +CASE WHEN 1 THEN t3 ELSE t6 END, +CASE WHEN 1 THEN t4 ELSE t0 END, +CASE WHEN 1 THEN t4 ELSE t1 END, +CASE WHEN 1 THEN t4 ELSE t3 END, +CASE WHEN 1 THEN t4 ELSE t6 END, +CASE WHEN 1 THEN t6 ELSE t0 END, +CASE WHEN 1 THEN t6 ELSE t1 END, +CASE WHEN 1 THEN t6 ELSE t3 END, +CASE WHEN 1 THEN t6 ELSE t4 END +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CASE WHEN 1 THEN t0 ELSE t1 END` datetime(1) DEFAULT NULL, + `CASE WHEN 1 THEN t0 ELSE t3 END` datetime(3) DEFAULT NULL, + `CASE WHEN 1 THEN t0 ELSE t4 END` datetime(4) DEFAULT NULL, + `CASE WHEN 1 THEN t0 ELSE t6 END` datetime(6) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t0 END` datetime(1) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t3 END` datetime(3) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t4 END` datetime(4) DEFAULT NULL, + `CASE WHEN 1 THEN t1 ELSE t6 END` datetime(6) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t0 END` datetime(3) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t1 END` datetime(3) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t4 END` datetime(4) DEFAULT NULL, + `CASE WHEN 1 THEN t3 ELSE t6 END` datetime(6) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t0 END` datetime(4) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t1 END` datetime(4) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t3 END` datetime(4) DEFAULT NULL, + `CASE WHEN 1 THEN t4 ELSE t6 END` datetime(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t0 END` datetime(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t1 END` datetime(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t3 END` datetime(6) DEFAULT NULL, + `CASE WHEN 1 THEN t6 ELSE t4 END` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing various DATETTIME(N) in COALESCE +# +CREATE TABLE t1 ( +a DATETIME(6), +b DATETIME(6), +c DATETIME, +d DATETIME, +e DATETIME(3), +f DATETIME(4)); +CREATE TABLE t2 AS SELECT +COALESCE(a, b), COALESCE(c, b), +COALESCE(c, d), COALESCE(e, f), +COALESCE(c, e), COALESCE(c, f) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `COALESCE(a, b)` datetime(6) DEFAULT NULL, + `COALESCE(c, b)` datetime(6) DEFAULT NULL, + `COALESCE(c, d)` datetime DEFAULT NULL, + `COALESCE(e, f)` datetime(4) DEFAULT NULL, + `COALESCE(c, e)` datetime(3) DEFAULT NULL, + `COALESCE(c, f)` datetime(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT +CONCAT(COALESCE(a, b)), CONCAT(COALESCE(c, b)), +CONCAT(COALESCE(c, d)), CONCAT(COALESCE(e, f)), +CONCAT(COALESCE(c, e)), CONCAT(COALESCE(c, f)) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CONCAT(COALESCE(a, b))` varchar(26) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, b))` varchar(26) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, d))` varchar(19) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(e, f))` varchar(24) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, e))` varchar(23) CHARACTER SET latin1 DEFAULT NULL, + `CONCAT(COALESCE(c, f))` varchar(24) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing DATETIME(6) with another DATETIME(6) in IF +# +CREATE TABLE t1 (a DATETIME(6), b DATETIME(6)); +CREATE TABLE t2 AS SELECT IF(1, a, b) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing DATETIME(N) with DATETIME(M) in IF +# +CREATE TABLE t1 (a DATETIME(1), b DATETIME(2)); +CREATE TABLE t2 AS SELECT IF(1, a, b), IF(1, b, a) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `IF(1, a, b)` datetime(2) DEFAULT NULL, + `IF(1, b, a)` datetime(2) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing DATETIME(6) NOT NULL with another DATETIME(6) NOT NULL +# +CREATE TABLE t1 (a DATETIME(6) NOT NULL, b DATETIME(6) NOT NULL); +CREATE TABLE t2 AS SELECT IF(1, a, b) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between DATETIME(6) and DATETIME(6) +# +CREATE TABLE t1 (a DATETIME(6) NOT NULL, b DATETIME(6) NOT NULL); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456', '2001-01-01 00:11:22.123456'); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY a; +a +2001-01-01 00:11:22.123456 +2001-01-01 11:22:33.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between DATETIME(n) +# +CREATE TABLE t1 (t0 DATETIME, t1 DATETIME(1), t3 DATETIME(3), t4 DATETIME(4)); +CREATE TABLE t2 AS SELECT t0 FROM t1 UNION SELECT t1 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t0` datetime(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT t1 FROM t1 UNION SELECT t3 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t1` datetime(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT t3 FROM t1 UNION SELECT t4 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t3` datetime(4) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between DATETIME(6) and DATETIME / DATE +# +CREATE TABLE t1 (a DATETIME NOT NULL, b DATETIME(6) NOT NULL, c DATE NOT NULL); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456', '2001-01-01 00:11:22.123456','2001-01-01'); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY a; +a +2001-01-01 00:11:22.123456 +2001-01-01 11:22:33.000000 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT b FROM t1 UNION SELECT a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `b` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY b; +b +2001-01-01 00:11:22.123456 +2001-01-01 11:22:33.000000 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT b FROM t1 UNION SELECT c FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +b datetime(6) NO 0000-00-00 00:00:00.000000 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT c FROM t1 UNION SELECT b FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +c datetime(6) NO 0000-00-00 00:00:00.000000 +SELECT * FROM t2 ORDER BY c; +c +2001-01-01 00:00:00.000000 +2001-01-01 00:11:22.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between DATETIME(6) and various other types +# +CREATE TABLE t1 (a DATETIME(6), b BIGINT, c DOUBLE, d DECIMAL(20,6), e VARCHAR(20)); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT c FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT d FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT e FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing DATETIME(6) field in combination with DATETIME type functions +# +CREATE TABLE t1 (a DATETIME(6), b TIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:00:00.123456', '10:00:00.123456'); +INSERT INTO t1 VALUES ('2001-01-01 10:00:00', '10:00:00'); +SELECT * FROM t1 WHERE a=TIMESTAMP('2001-01-01', b); +a b +2001-01-01 10:00:00.123456 10:00:00.123456 +2001-01-01 10:00:00.000000 10:00:00.000000 +SELECT * FROM t1 WHERE a=ADDTIME('2001-01-01 00:00:00', '10:00:00'); +a b +2001-01-01 10:00:00.000000 10:00:00.000000 +SELECT * FROM t1 WHERE a=ADDTIME('2001-01-01 00:00:00', '10:00:00.123456'); +a b +2001-01-01 10:00:00.123456 10:00:00.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES (CURRENT_TIMESTAMP, CURRENT_TIME); +SELECT COUNT(*) FROM t1 WHERE a <= CURRENT_TIMESTAMP; +COUNT(*) +1 +SELECT COUNT(*) FROM t1 WHERE a >= SUBTIME(CURRENT_TIMESTAMP, '10:00:00'); +COUNT(*) +1 +DROP TABLE t1; +# +# ORDER BY DATETIME(6) function +# +CREATE TABLE t1(a DATETIME(6)); +INSERT INTO t1 (a) VALUES ('9999-12-31 00:00:00.000002'); +INSERT INTO t1 (a) VALUES ('9999-12-31 00:00:00.000001'); +INSERT INTO t1 (a) VALUES ('9999-12-31 00:00:00.000000'); +INSERT INTO t1 (a) VALUES ('9999-12-31 23:59:59.000001'); +INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00.000003'); +INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00.000000'); +INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00.000001'); +INSERT INTO t1 (a) VALUES ('0000-00-00 00:00:00.000000'); +SELECT * FROM t1 ORDER BY ADDTIME(a, '00:00:00'); +a +0000-00-00 00:00:00.000000 +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000003 +9999-12-31 00:00:00.000000 +9999-12-31 00:00:00.000001 +9999-12-31 00:00:00.000002 +9999-12-31 23:59:59.000001 +SELECT * FROM t1 ORDER BY ADDTIME(a, '00:00:00') DESC; +a +9999-12-31 23:59:59.000001 +9999-12-31 00:00:00.000002 +9999-12-31 00:00:00.000001 +9999-12-31 00:00:00.000000 +2001-01-01 00:00:00.000003 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing partitions +# +CREATE TABLE t1 (a DATETIME(6)) PARTITION BY KEY(a) PARTITIONS 4; +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000002'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000003'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000004'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000005'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000006'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000010'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000011'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000012'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000013'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000014'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000015'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000016'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000110'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000111'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000112'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000113'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000114'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000115'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000116'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000210'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000211'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000212'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000213'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000214'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000215'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000216'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000002'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000003'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000004'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000005'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000006'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000002'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000003'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000004'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000005'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000006'); +SELECT * FROM t1 PARTITION(p0); +a +2001-01-01 00:00:01.000000 +2001-01-01 00:00:01.000004 +SELECT * FROM t1 PARTITION(p1); +a +2001-01-01 00:00:01.000001 +2001-01-01 00:00:01.000005 +2001-01-01 00:00:02.000000 +2001-01-01 00:00:02.000002 +2001-01-01 00:00:02.000004 +2001-01-01 00:00:02.000006 +SELECT * FROM t1 PARTITION(p2); +a +2001-01-01 00:00:01.000002 +2001-01-01 00:00:01.000006 +SELECT * FROM t1 PARTITION(p3); +a +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000002 +2001-01-01 00:00:00.000003 +2001-01-01 00:00:00.000004 +2001-01-01 00:00:00.000005 +2001-01-01 00:00:00.000006 +2001-01-01 00:00:00.000010 +2001-01-01 00:00:00.000011 +2001-01-01 00:00:00.000012 +2001-01-01 00:00:00.000013 +2001-01-01 00:00:00.000014 +2001-01-01 00:00:00.000015 +2001-01-01 00:00:00.000016 +2001-01-01 00:00:00.000110 +2001-01-01 00:00:00.000111 +2001-01-01 00:00:00.000112 +2001-01-01 00:00:00.000113 +2001-01-01 00:00:00.000114 +2001-01-01 00:00:00.000115 +2001-01-01 00:00:00.000116 +2001-01-01 00:00:00.000210 +2001-01-01 00:00:00.000211 +2001-01-01 00:00:00.000212 +2001-01-01 00:00:00.000213 +2001-01-01 00:00:00.000214 +2001-01-01 00:00:00.000215 +2001-01-01 00:00:00.000216 +2001-01-01 00:00:01.000003 +2001-01-01 00:00:02.000001 +2001-01-01 00:00:02.000003 +2001-01-01 00:00:02.000005 +ALTER TABLE t1 PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN ('2001-01-01 00:00:00.000200'), +PARTITION p1 VALUES LESS THAN ('2001-01-01 00:00:01'), +PARTITION p2 VALUES LESS THAN ('2001-01-01 00:00:02.000003'), +PARTITION p3 VALUES LESS THAN MAXVALUE +); +SELECT * FROM t1 PARTITION(p0); +a +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000002 +2001-01-01 00:00:00.000003 +2001-01-01 00:00:00.000004 +2001-01-01 00:00:00.000005 +2001-01-01 00:00:00.000006 +2001-01-01 00:00:00.000010 +2001-01-01 00:00:00.000011 +2001-01-01 00:00:00.000012 +2001-01-01 00:00:00.000013 +2001-01-01 00:00:00.000014 +2001-01-01 00:00:00.000015 +2001-01-01 00:00:00.000016 +2001-01-01 00:00:00.000110 +2001-01-01 00:00:00.000111 +2001-01-01 00:00:00.000112 +2001-01-01 00:00:00.000113 +2001-01-01 00:00:00.000114 +2001-01-01 00:00:00.000115 +2001-01-01 00:00:00.000116 +SELECT * FROM t1 PARTITION(p1); +a +2001-01-01 00:00:00.000210 +2001-01-01 00:00:00.000211 +2001-01-01 00:00:00.000212 +2001-01-01 00:00:00.000213 +2001-01-01 00:00:00.000214 +2001-01-01 00:00:00.000215 +2001-01-01 00:00:00.000216 +SELECT * FROM t1 PARTITION(p2); +a +2001-01-01 00:00:01.000000 +2001-01-01 00:00:01.000004 +2001-01-01 00:00:01.000001 +2001-01-01 00:00:01.000005 +2001-01-01 00:00:02.000000 +2001-01-01 00:00:02.000002 +2001-01-01 00:00:01.000002 +2001-01-01 00:00:01.000006 +2001-01-01 00:00:01.000003 +2001-01-01 00:00:02.000001 +SELECT * FROM t1 PARTITION(p3); +a +2001-01-01 00:00:02.000004 +2001-01-01 00:00:02.000006 +2001-01-01 00:00:02.000003 +2001-01-01 00:00:02.000005 +DROP TABLE t1; +# +# Checking that DATETIME/DATE literals can be a partition LESS value +# +CREATE TABLE t1 (s1 DATETIME(6)) +PARTITION BY RANGE COLUMNS (s1) +(PARTITION p1 VALUES LESS THAN (TIMESTAMP'2001-01-01 01:01:01.000001'), +PARTITION p2 VALUES LESS THAN (DATE'2002-01-01')); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50500 PARTITION BY RANGE COLUMNS(s1) +(PARTITION p1 VALUES LESS THAN ('2001-01-01 01:01:01.000001') ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN ('2002-01-01') ENGINE = InnoDB) */ +DROP TABLE t1; +# +# Testing CAST to DATETIME and DATETIME(6) +# +CREATE TABLE t1 AS SELECT +CAST(111 AS DATETIME), +CAST(100000000 AS DATETIME), +CAST(111.1 AS DATETIME), +CAST('20001111' AS DATETIME), +CAST(111e0 AS DATETIME), +CAST(111 AS DATETIME(0)), +CAST(100000000 AS DATETIME(0)), +CAST(111.1 AS DATETIME(0)), +CAST('20001111' AS DATETIME(0)), +CAST(111e0 AS DATETIME(0)), +CAST(111 AS DATETIME(6)), +CAST(100000000 AS DATETIME(6)), +CAST(111.1 AS DATETIME(6)), +CAST('20001111' AS DATETIME(6)), +CAST(111e0 AS DATETIME(6)); +Warnings: +Warning 1292 Incorrect datetime value: '100000000' +Warning 1292 Incorrect datetime value: '100000000' +Warning 1292 Incorrect datetime value: '100000000' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CAST(111 AS DATETIME)` datetime DEFAULT NULL, + `CAST(100000000 AS DATETIME)` datetime DEFAULT NULL, + `CAST(111.1 AS DATETIME)` datetime DEFAULT NULL, + `CAST('20001111' AS DATETIME)` datetime DEFAULT NULL, + `CAST(111e0 AS DATETIME)` datetime DEFAULT NULL, + `CAST(111 AS DATETIME(0))` datetime DEFAULT NULL, + `CAST(100000000 AS DATETIME(0))` datetime DEFAULT NULL, + `CAST(111.1 AS DATETIME(0))` datetime DEFAULT NULL, + `CAST('20001111' AS DATETIME(0))` datetime DEFAULT NULL, + `CAST(111e0 AS DATETIME(0))` datetime DEFAULT NULL, + `CAST(111 AS DATETIME(6))` datetime(6) DEFAULT NULL, + `CAST(100000000 AS DATETIME(6))` datetime(6) DEFAULT NULL, + `CAST(111.1 AS DATETIME(6))` datetime(6) DEFAULT NULL, + `CAST('20001111' AS DATETIME(6))` datetime(6) DEFAULT NULL, + `CAST(111e0 AS DATETIME(6))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME, b DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33', '2001-01-01 11:22:33.123456'); +CREATE TABLE t2 AS SELECT CAST(a AS DATETIME), CAST(b AS DATETIME) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS DATETIME)` datetime DEFAULT NULL, + `CAST(b AS DATETIME)` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT CAST(a AS DATETIME(0)), CAST(b AS DATETIME(0)) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS DATETIME(0))` datetime DEFAULT NULL, + `CAST(b AS DATETIME(0))` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT CAST(a AS DATETIME(6)), CAST(b AS DATETIME(6)) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS DATETIME(6))` datetime(6) DEFAULT NULL, + `CAST(b AS DATETIME(6))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +# +# Testing Item_typecast_datetime::val_str +# +SELECT CONCAT(CAST(a AS DATETIME(0))), CONCAT(CAST(b AS DATETIME(0))) FROM t1; +CONCAT(CAST(a AS DATETIME(0))) CONCAT(CAST(b AS DATETIME(0))) +2001-01-01 11:22:33 2001-01-01 11:22:33 +SELECT CONCAT(CAST(a AS DATETIME(6))), CONCAT(CAST(b AS DATETIME(6))) FROM t1; +CONCAT(CAST(a AS DATETIME(6))) CONCAT(CAST(b AS DATETIME(6))) +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.123456 +SELECT CONCAT(CAST(a AS DATETIME)), CONCAT(CAST(b AS DATETIME)) FROM t1; +CONCAT(CAST(a AS DATETIME)) CONCAT(CAST(b AS DATETIME)) +2001-01-01 11:22:33 2001-01-01 11:22:33 +# +# Testing Item_typecast_datetime::get_time +# +SELECT CAST(a AS DATETIME(0)), CAST(b AS DATETIME(0)) FROM t1; +CAST(a AS DATETIME(0)) CAST(b AS DATETIME(0)) +2001-01-01 11:22:33 2001-01-01 11:22:33 +SELECT CAST(a AS DATETIME(6)), CAST(b AS DATETIME(6)) FROM t1; +CAST(a AS DATETIME(6)) CAST(b AS DATETIME(6)) +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.123456 +SELECT CAST(a AS DATETIME), CAST(b AS DATETIME) FROM t1; +CAST(a AS DATETIME) CAST(b AS DATETIME) +2001-01-01 11:22:33 2001-01-01 11:22:33 +DROP TABLE t1; +# +# Testing Item_typecast_datetime::val_int +# +SELECT CAST('2001-01-01 10:11:12' AS DATETIME(0)) + 1; +CAST('2001-01-01 10:11:12' AS DATETIME(0)) + 1 +20010101101113 +# +# Testing Item_typecast_time::val_decimal +# +SELECT CAST('2001-01-01 10:11:12' AS DATETIME(6)) + 1; +CAST('2001-01-01 10:11:12' AS DATETIME(6)) + 1 +20010101101113.000000 +# +# Testing CAST from numeric types to DATETIME +# +CREATE TABLE t1 (bi BIGINT, d DOUBLE, dc DECIMAL(30,6)); +INSERT INTO t1 VALUES (10101101112, 10101101112.1, 10101101112.1); +INSERT INTO t1 VALUES (20010101101112, 20010101101112.1, 20010101101112.1); +SELECT +CAST(bi AS DATETIME(1)), +CAST(d AS DATETIME(1)), +CAST(dc AS DATETIME(1)), +CAST(10101101112 AS DATETIME(1)), +CAST(10101101112.1 AS DATETIME(1)), +CAST(20010101101112 AS DATETIME(1)), +CAST(20010101101112.1 AS DATETIME(1)) +FROM t1; +CAST(bi AS DATETIME(1)) 2001-01-01 10:11:12.0 +CAST(d AS DATETIME(1)) 2001-01-01 10:11:12.1 +CAST(dc AS DATETIME(1)) 2001-01-01 10:11:12.1 +CAST(10101101112 AS DATETIME(1)) 2001-01-01 10:11:12.0 +CAST(10101101112.1 AS DATETIME(1)) 2001-01-01 10:11:12.1 +CAST(20010101101112 AS DATETIME(1)) 2001-01-01 10:11:12.0 +CAST(20010101101112.1 AS DATETIME(1)) 2001-01-01 10:11:12.1 +CAST(bi AS DATETIME(1)) 2001-01-01 10:11:12.0 +CAST(d AS DATETIME(1)) 2001-01-01 10:11:12.1 +CAST(dc AS DATETIME(1)) 2001-01-01 10:11:12.1 +CAST(10101101112 AS DATETIME(1)) 2001-01-01 10:11:12.0 +CAST(10101101112.1 AS DATETIME(1)) 2001-01-01 10:11:12.1 +CAST(20010101101112 AS DATETIME(1)) 2001-01-01 10:11:12.0 +CAST(20010101101112.1 AS DATETIME(1)) 2001-01-01 10:11:12.1 +DROP TABLE t1; +SELECT CAST(1e300 AS DATETIME); +CAST(1e300 AS DATETIME) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '1e300' +SELECT CAST(999999999999999999999999.999 AS DATETIME); +CAST(999999999999999999999999.999 AS DATETIME) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '999999999999999999999999.999' +SELECT CAST(9223372036854775807 AS DATETIME); +CAST(9223372036854775807 AS DATETIME) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '9223372036854775807' +# +# Testing comparison between a DATETIME(6) field and a DATETIME(N) type cast +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000000'); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000001'); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000002'); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000003'); +SELECT * FROM t1 WHERE a=CAST('2001-01-01 10:11:12.000003' AS DATETIME(6)); +a +2001-01-01 10:11:12.000003 +SELECT * FROM t1 WHERE a=CAST('2001-01-01 10:11:12.000003' AS DATETIME(0)); +a +2001-01-01 10:11:12.000000 +DROP TABLE t1; +# +# Testing comparison between CAST(x AS DATETIME(N)) and INT +# +SELECT CAST('2001-01-01 10:11:12.123' AS DATETIME(0)) = 20010101101112; +CAST('2001-01-01 10:11:12.123' AS DATETIME(0)) = 20010101101112 +1 +SELECT CAST(20010101101112.123 AS DATETIME(0)) = 20010101101112; +CAST(20010101101112.123 AS DATETIME(0)) = 20010101101112 +1 +SELECT CAST(00010101101112.123e0 AS DATETIME(0)) = 20010101101112; +CAST(00010101101112.123e0 AS DATETIME(0)) = 20010101101112 +1 +# +# Testing Item_typecast_time::val_int_packed() +# +CREATE TABLE t1 (a DATETIME, b DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 23:00:00', '2001-01-01 23:00:00.123456'); +SELECT CAST('2001-01-01 23:00:00' AS DATETIME) = (SELECT a FROM t1); +CAST('2001-01-01 23:00:00' AS DATETIME) = (SELECT a FROM t1) +1 +SELECT CAST('2001-01-01 23:00:00' AS DATETIME(6)) = (SELECT a FROM t1); +CAST('2001-01-01 23:00:00' AS DATETIME(6)) = (SELECT a FROM t1) +1 +SELECT CAST('2001-01-01 23:00:00.123456' AS DATETIME(0)) = (SELECT a FROM t1); +CAST('2001-01-01 23:00:00.123456' AS DATETIME(0)) = (SELECT a FROM t1) +1 +SELECT CAST('2001-01-01 23:00:00.123456' AS DATETIME(6)) = (SELECT b FROM t1); +CAST('2001-01-01 23:00:00.123456' AS DATETIME(6)) = (SELECT b FROM t1) +1 +DROP TABLE t1; +# +# Testing function MICROSECOND +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:12:13.000001'); +INSERT INTO t1 VALUES ('2001-01-01 11:12:13.100001'); +INSERT INTO t1 VALUES ('2001-01-01 11:12:13.999999'); +SELECT a, MICROSECOND(a) FROM t1; +a MICROSECOND(a) +2001-01-01 11:12:13.000001 1 +2001-01-01 11:12:13.100001 100001 +2001-01-01 11:12:13.999999 999999 +SELECT a, EXTRACT(MICROSECOND FROM a) FROM t1; +a EXTRACT(MICROSECOND FROM a) +2001-01-01 11:12:13.000001 1 +2001-01-01 11:12:13.100001 100001 +2001-01-01 11:12:13.999999 999999 +DROP TABLE t1; +SELECT MICROSECOND(CAST(20010101235959.456 AS DATETIME(6))); +MICROSECOND(CAST(20010101235959.456 AS DATETIME(6))) +456000 +SELECT EXTRACT(MICROSECOND FROM CAST(20010101235959.456 AS DATETIME(6))); +EXTRACT(MICROSECOND FROM CAST(20010101235959.456 AS DATETIME(6))) +456000 +# +# Testing PS +# +CREATE TABLE t1 (a DATETIME(6)); +PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)'; +SET @a='2001-01-01 11:22:33.123456'; +SET @b=20010101112233.123456; +SET @c=0.123456e0; +EXECUTE stmt USING @a; +EXECUTE stmt USING @c; +DEALLOCATE PREPARE stmt; +SELECT * FROM t1; +a +2001-01-01 11:22:33.123456 +0000-00-00 00:00:00.123456 +PREPARE stmt FROM 'SELECT * FROM t1 WHERE a=?'; +EXECUTE stmt USING @a; +a +2001-01-01 11:22:33.123456 +EXECUTE stmt USING @b; +a +2001-01-01 11:22:33.123456 +EXECUTE stmt USING @c; +a +0000-00-00 00:00:00.123456 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# +# Testing DATETIME(6) and user variables +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.123456'); +SET @a='2001-01-01 11:22:33.123456'; +SELECT * FROM t1 WHERE a=@a; +a +2001-01-01 11:22:33.123456 +SET @a=20010101112233.123456; +SELECT * FROM t1 WHERE a=@a; +a +2001-01-01 11:22:33.123456 +SET @a=0.123456e0; +SELECT * FROM t1 WHERE a=@a; +a +0000-00-00 00:00:00.123456 +SET @a=NULL; +SELECT a INTO @a FROM t1 LIMIT 1; +SELECT @a; +@a +2001-01-01 11:22:33.123456 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT @a AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` longtext CHARACTER SET latin1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +a +2001-01-01 11:22:33.123456 +DROP TABLE t1; +# +# Testing SP +# +CREATE PROCEDURE p1 () +BEGIN +DECLARE a DATETIME(6); +SET a='2001-01-01 11:22:33.123'; +SELECT a; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE a DATETIME(6); +SET a='2001-01-01 11:22:33.123'; +SELECT a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1// +a +2001-01-01 11:22:33.123000 +DROP PROCEDURE p1// +CREATE PROCEDURE p1 (a DATETIME(6)) +BEGIN +SELECT a; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(a DATETIME(6)) +BEGIN +SELECT a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1(20010101112233)// +a +2001-01-01 11:22:33.000000 +CALL p1(20010101112233.123)// +a +2001-01-01 11:22:33.123000 +CALL p1(0.123e0)// +a +0000-00-00 00:00:00.123000 +CALL p1('2001-01-01 11:22:33.123')// +a +2001-01-01 11:22:33.123000 +DROP PROCEDURE p1// +CREATE PROCEDURE p1() +BEGIN +DECLARE a DATETIME(6); +CREATE TABLE t1 AS SELECT a; +SHOW CREATE TABLE t1; +DROP TABLE t1; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE a DATETIME(6); +CREATE TABLE t1 AS SELECT a; +SHOW CREATE TABLE t1; +DROP TABLE t1; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1// +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP PROCEDURE p1// +CREATE FUNCTION p1 (a DATETIME(6)) RETURNS DATETIME(6) +BEGIN +RETURN a; +END// +SHOW CREATE FUNCTION p1// +Function sql_mode Create Function character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `p1`(a DATETIME(6)) RETURNS datetime(6) +BEGIN +RETURN a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +SELECT p1(20010101112233)// +p1(20010101112233) +2001-01-01 11:22:33.000000 +SELECT p1(20010101112233.123)// +p1(20010101112233.123) +2001-01-01 11:22:33.123000 +DROP FUNCTION p1// +# +# Testing INFORMATION_SCHEMA.COLUMNS +# +CREATE TABLE t1 (a DATETIME(6)); +SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1';; +TABLE_CATALOG def +TABLE_SCHEMA test +TABLE_NAME t1 +COLUMN_NAME a +ORDINAL_POSITION 1 +COLUMN_DEFAULT NULL +IS_NULLABLE YES +DATA_TYPE datetime +CHARACTER_MAXIMUM_LENGTH NULL +CHARACTER_OCTET_LENGTH NULL +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION 6 +CHARACTER_SET_NAME NULL +COLLATION_NAME NULL +COLUMN_TYPE datetime(6) +COLUMN_KEY +EXTRA +PRIVILEGES # +COLUMN_COMMENT +GENERATION_EXPRESSION +SRS_ID NULL +DROP TABLE t1; +# +# SELECT from a subquery +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.123456'), ('2001-01-01 11:11:11.123456'); +SELECT * FROM (SELECT * FROM t1) t12; +a +2001-01-01 00:00:00.123456 +2001-01-01 11:11:11.123456 +DROP TABLE t1; +# +# Testing IN and = subqueries +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.123456'), ('2001-01-01 11:11:11.123456'); +SELECT * FROM t1 WHERE a IN (SELECT MIN(a) FROM t1); +a +2001-01-01 00:00:00.123456 +SELECT * FROM t1 WHERE a = (SELECT a FROM t1 ORDER BY a DESC LIMIT 1); +a +2001-01-01 11:11:11.123456 +DROP TABLE t1; +# +# Testing IN subquery + GROUP +# +CREATE TABLE t1 (id INT, a DATETIME(6)); +INSERT INTO t1 VALUES (1, '2001-01-01 00:00:00.123456'), (1, '2001-01-01 11:00:00.123456'); +INSERT INTO t1 VALUES (2, '2001-01-01 00:01:00.123456'), (2, '2001-01-01 11:01:00.123456'); +INSERT INTO t1 VALUES (3, NULL); +SELECT * FROM t1 WHERE a IN (SELECT MAX(a) FROM t1 GROUP BY id); +id a +1 2001-01-01 11:00:00.123456 +2 2001-01-01 11:01:00.123456 +DROP TABLE t1; +# +# Testing VIEW +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.123456'), ('2001-01-01 11:11:11.123456'); +CREATE VIEW v1 AS SELECT a FROM t1; +SELECT * FROM v1 WHERE a='2001-01-01 00:00:00.123456'; +a +2001-01-01 00:00:00.123456 +SELECT MIN(a), MAX(a) FROM v1; +MIN(a) MAX(a) +2001-01-01 00:00:00.123456 2001-01-01 11:11:11.123456 +SELECT * FROM t1 WHERE a IN (SELECT MAX(a) FROM v1); +a +2001-01-01 11:11:11.123456 +DROP VIEW v1; +CREATE VIEW v1 AS SELECT MAX(a) AS a FROM t1; +SELECT * FROM v1; +a +2001-01-01 11:11:11.123456 +SELECT * FROM t1 WHERE a=(SELECT a FROM v1); +a +2001-01-01 11:11:11.123456 +DROP VIEW v1; +DROP TABLE t1; +# +# Testing that CAST from various fields to DATETIME rounds. +# This tests Field::get_date(). +# +CREATE TABLE t1 (a VARCHAR(32)); +INSERT INTO t1 VALUES +('9999-12-31 23:59:59.0000009'), ('9999-12-31 23:59:59.9'), +('2001-01-01 10:10:10.9999994'), ('2001-01-01 10:10:10.9999995'); +SELECT a, CAST(a AS DATETIME), CAST(a AS DATETIME(6)) FROM t1; +a CAST(a AS DATETIME) CAST(a AS DATETIME(6)) +9999-12-31 23:59:59.0000009 9999-12-31 23:59:59 9999-12-31 23:59:59.000001 +9999-12-31 23:59:59.9 NULL 9999-12-31 23:59:59.900000 +2001-01-01 10:10:10.9999994 2001-01-01 10:10:11 2001-01-01 10:10:10.999999 +2001-01-01 10:10:10.9999995 2001-01-01 10:10:11 2001-01-01 10:10:11.000000 +Warnings: +Warning 1441 Datetime function: datetime field overflow +DROP TABLE t1; +CREATE TABLE t1 (a DECIMAL(30, 7)); +INSERT INTO t1 VALUES +(99991231235959.0000009), (99991231235959.9), +(20010101101010.9999994), (20010101101010.9999995); +SELECT a, CAST(a AS DATETIME), CAST(a AS DATETIME(6)) FROM t1; +a CAST(a AS DATETIME) CAST(a AS DATETIME(6)) +99991231235959.0000009 9999-12-31 23:59:59 9999-12-31 23:59:59.000001 +99991231235959.9000000 NULL 9999-12-31 23:59:59.900000 +20010101101010.9999994 2001-01-01 10:10:11 2001-01-01 10:10:10.999999 +20010101101010.9999995 2001-01-01 10:10:11 2001-01-01 10:10:11.000000 +Warnings: +Warning 1441 Datetime function: datetime field overflow +DROP TABLE t1; +# +# Testing rounding with CAST +# +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999999'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999998'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999997'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999996'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999995'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999994'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999993'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999992'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999991'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999990'); +SELECT a, CAST(a AS DATETIME(5)) FROM t1; +a CAST(a AS DATETIME(5)) +2001-01-01 10:10:10.999999 2001-01-01 10:10:11.00000 +2001-01-01 10:10:10.999998 2001-01-01 10:10:11.00000 +2001-01-01 10:10:10.999997 2001-01-01 10:10:11.00000 +2001-01-01 10:10:10.999996 2001-01-01 10:10:11.00000 +2001-01-01 10:10:10.999995 2001-01-01 10:10:11.00000 +2001-01-01 10:10:10.999994 2001-01-01 10:10:10.99999 +2001-01-01 10:10:10.999993 2001-01-01 10:10:10.99999 +2001-01-01 10:10:10.999992 2001-01-01 10:10:10.99999 +2001-01-01 10:10:10.999991 2001-01-01 10:10:10.99999 +2001-01-01 10:10:10.999990 2001-01-01 10:10:10.99999 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(5)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99999'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99998'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99997'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99996'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99995'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99994'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99993'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99992'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99991'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99990'); +SELECT a, CAST(a AS DATETIME(4)) FROM t1; +a CAST(a AS DATETIME(4)) +2001-01-01 10:10:10.99999 2001-01-01 10:10:11.0000 +2001-01-01 10:10:10.99998 2001-01-01 10:10:11.0000 +2001-01-01 10:10:10.99997 2001-01-01 10:10:11.0000 +2001-01-01 10:10:10.99996 2001-01-01 10:10:11.0000 +2001-01-01 10:10:10.99995 2001-01-01 10:10:11.0000 +2001-01-01 10:10:10.99994 2001-01-01 10:10:10.9999 +2001-01-01 10:10:10.99993 2001-01-01 10:10:10.9999 +2001-01-01 10:10:10.99992 2001-01-01 10:10:10.9999 +2001-01-01 10:10:10.99991 2001-01-01 10:10:10.9999 +2001-01-01 10:10:10.99990 2001-01-01 10:10:10.9999 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(4)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9999'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9998'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9997'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9996'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9995'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9994'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9993'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9992'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9991'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9990'); +SELECT a, CAST(a AS DATETIME(3)) FROM t1; +a CAST(a AS DATETIME(3)) +2001-01-01 10:10:10.9999 2001-01-01 10:10:11.000 +2001-01-01 10:10:10.9998 2001-01-01 10:10:11.000 +2001-01-01 10:10:10.9997 2001-01-01 10:10:11.000 +2001-01-01 10:10:10.9996 2001-01-01 10:10:11.000 +2001-01-01 10:10:10.9995 2001-01-01 10:10:11.000 +2001-01-01 10:10:10.9994 2001-01-01 10:10:10.999 +2001-01-01 10:10:10.9993 2001-01-01 10:10:10.999 +2001-01-01 10:10:10.9992 2001-01-01 10:10:10.999 +2001-01-01 10:10:10.9991 2001-01-01 10:10:10.999 +2001-01-01 10:10:10.9990 2001-01-01 10:10:10.999 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(3)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.998'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.997'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.996'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.995'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.994'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.993'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.992'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.991'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.990'); +SELECT a, CAST(a AS DATETIME(2)) FROM t1; +a CAST(a AS DATETIME(2)) +2001-01-01 10:10:10.999 2001-01-01 10:10:11.00 +2001-01-01 10:10:10.998 2001-01-01 10:10:11.00 +2001-01-01 10:10:10.997 2001-01-01 10:10:11.00 +2001-01-01 10:10:10.996 2001-01-01 10:10:11.00 +2001-01-01 10:10:10.995 2001-01-01 10:10:11.00 +2001-01-01 10:10:10.994 2001-01-01 10:10:10.99 +2001-01-01 10:10:10.993 2001-01-01 10:10:10.99 +2001-01-01 10:10:10.992 2001-01-01 10:10:10.99 +2001-01-01 10:10:10.991 2001-01-01 10:10:10.99 +2001-01-01 10:10:10.990 2001-01-01 10:10:10.99 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(2)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.99'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.98'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.97'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.96'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.95'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.94'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.93'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.92'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.91'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.90'); +SELECT a, CAST(a AS DATETIME(1)) FROM t1; +a CAST(a AS DATETIME(1)) +2001-01-01 10:10:10.99 2001-01-01 10:10:11.0 +2001-01-01 10:10:10.98 2001-01-01 10:10:11.0 +2001-01-01 10:10:10.97 2001-01-01 10:10:11.0 +2001-01-01 10:10:10.96 2001-01-01 10:10:11.0 +2001-01-01 10:10:10.95 2001-01-01 10:10:11.0 +2001-01-01 10:10:10.94 2001-01-01 10:10:10.9 +2001-01-01 10:10:10.93 2001-01-01 10:10:10.9 +2001-01-01 10:10:10.92 2001-01-01 10:10:10.9 +2001-01-01 10:10:10.91 2001-01-01 10:10:10.9 +2001-01-01 10:10:10.90 2001-01-01 10:10:10.9 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(1)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.9'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.8'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.7'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.6'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.5'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.4'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.3'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.2'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.1'); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.0'); +SELECT a, CAST(a AS DATETIME) FROM t1; +a CAST(a AS DATETIME) +2001-01-01 10:10:10.9 2001-01-01 10:10:11 +2001-01-01 10:10:10.8 2001-01-01 10:10:11 +2001-01-01 10:10:10.7 2001-01-01 10:10:11 +2001-01-01 10:10:10.6 2001-01-01 10:10:11 +2001-01-01 10:10:10.5 2001-01-01 10:10:11 +2001-01-01 10:10:10.4 2001-01-01 10:10:10 +2001-01-01 10:10:10.3 2001-01-01 10:10:10 +2001-01-01 10:10:10.2 2001-01-01 10:10:10 +2001-01-01 10:10:10.1 2001-01-01 10:10:10 +2001-01-01 10:10:10.0 2001-01-01 10:10:10 +DROP TABLE t1; +# +# Testing that Item::get_date() rounds +# +SELECT +CAST('2001-01-01 10:10:10.9999994' AS DATETIME), +CAST('2001-01-01 10:10:10.9999995' AS DATETIME), +CAST('2001-01-01 10:10:10.9999994' AS DATETIME(6)), +CAST('2001-01-01 10:10:10.9999995' AS DATETIME(6)), +CAST(20010101101010.9999994 AS DATETIME), +CAST(20010101101010.9999995 AS DATETIME), +CAST(20010101101010.9999994 AS DATETIME(6)), +CAST(20010101101010.9999995 AS DATETIME(6)); +CAST('2001-01-01 10:10:10.9999994' AS DATETIME) 2001-01-01 10:10:11 +CAST('2001-01-01 10:10:10.9999995' AS DATETIME) 2001-01-01 10:10:11 +CAST('2001-01-01 10:10:10.9999994' AS DATETIME(6)) 2001-01-01 10:10:10.999999 +CAST('2001-01-01 10:10:10.9999995' AS DATETIME(6)) 2001-01-01 10:10:11.000000 +CAST(20010101101010.9999994 AS DATETIME) 2001-01-01 10:10:11 +CAST(20010101101010.9999995 AS DATETIME) 2001-01-01 10:10:11 +CAST(20010101101010.9999994 AS DATETIME(6)) 2001-01-01 10:10:10.999999 +CAST(20010101101010.9999995 AS DATETIME(6)) 2001-01-01 10:10:11.000000 +# +# Testing that comparison rounds +# +CREATE TABLE t1 (t0 DATETIME, t6 DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00', '2001-01-01 00:00:00.999999'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01', '2001-01-01 00:00:01.000000'); +SELECT t0 FROM t1 WHERE t6='2001-01-01 00:00:00.9999998'; +t0 +2001-01-01 00:00:01 +SELECT t6 FROM t1 WHERE t6='2001-01-01 00:00:00.9999998'; +t6 +2001-01-01 00:00:01.000000 +DROP TABLE t1; +# +# Testing that EXTRACT rounds +# +SELECT +EXTRACT(MICROSECOND FROM '2001-01-01 00:00:00.9999994'), +EXTRACT(MICROSECOND FROM '2001-01-01 00:00:00.9999995'), +EXTRACT(MICROSECOND FROM 20010101000000.9999994), +EXTRACT(MICROSECOND FROM 20010101000000.9999995); +EXTRACT(MICROSECOND FROM '2001-01-01 00:00:00.9999994') 999999 +EXTRACT(MICROSECOND FROM '2001-01-01 00:00:00.9999995') 0 +EXTRACT(MICROSECOND FROM 20010101000000.9999994) 999999 +EXTRACT(MICROSECOND FROM 20010101000000.9999995) 0 +# +# Testing that TIMESTAMP(0) is a synonym to non-fractional TIMESTAMP +# +CREATE TABLE t1 (a TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing internal representation format for DATETIME(N) +# +SET time_zone='+00:00'; +CREATE TABLE t1 (a6 VARCHAR(32)); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000001'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000002'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000003'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000004'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000005'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000006'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000007'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000008'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000009'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000010'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000011'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000012'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000013'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000014'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000015'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000016'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000099'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.000999'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.009999'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.099999'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.100000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.900000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.990000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.999000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.999900'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.999990'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:01.999999'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000001'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000002'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000003'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000004'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000005'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000006'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000007'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000008'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000009'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000010'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000011'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000012'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000013'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000014'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000015'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000016'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000099'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.000999'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.009999'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.090000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.099999'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.100000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.900000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.990000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.999000'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.999900'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.999990'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:02.999999'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.000001'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.000008'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.000015'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.000016'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.000099'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.000999'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.009999'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.099999'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.100000'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.900000'); +INSERT INTO t1 VALUES ('1970-01-01 00:01:00.999999'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.000001'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.000008'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.000015'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.000016'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.000099'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.000999'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.009999'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.099999'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.100000'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.900000'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.990000'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.999000'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.999900'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.999990'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:00.999999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000001'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000008'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000015'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000016'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000099'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.000999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.009999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.099999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.100000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.900000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.990000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999000'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999900'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999990'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:58.999999'); +INSERT INTO t1 VALUES ('2001-01-01 23:59:59.000000'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.000001'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.000008'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.000015'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.000016'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.000099'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.000999'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.009999'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.099999'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.100000'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.900000'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.990000'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.999000'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.999900'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.999990'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:58.999999'); +INSERT INTO t1 VALUES ('2037-01-01 23:59:59.000000'); +ALTER TABLE t1 +ADD a0 VARCHAR(32), +ADD a1 VARCHAR(32), ADD a2 VARCHAR(32), ADD a3 VARCHAR(32), +ADD a4 VARCHAR(32), ADD a5 VARCHAR(32), +ADD d0 TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0), +ADD d1 TIMESTAMP(1), ADD d2 TIMESTAMP(2), ADD d3 TIMESTAMP(3), +ADD d4 TIMESTAMP(4), ADD d5 TIMESTAMP(5), ADD d6 TIMESTAMP(6); +UPDATE t1 SET +a0= LEFT(a6, LENGTH(a6) - 6), +a1= LEFT(a6, LENGTH(a6) - 5), +a2= LEFT(a6, LENGTH(a6) - 4), +a3= LEFT(a6, LENGTH(a6) - 3), +a4= LEFT(a6, LENGTH(a6) - 2), +a5= LEFT(a6, LENGTH(a6) - 1); +UPDATE t1 SET d0= a0, d1= a1, d2= a2, d3= a3, d4= a4, d5= a5, d6= a6; +SELECT a6, d6, HEX(WEIGHT_STRING(d6)) FROM t1 ORDER BY d6; +a6 d6 HEX(WEIGHT_STRING(d6)) +1970-01-01 00:00:01.000000 1970-01-01 00:00:01.000000 9902C20001000000 +1970-01-01 00:00:01.000001 1970-01-01 00:00:01.000001 9902C20001000001 +1970-01-01 00:00:01.000002 1970-01-01 00:00:01.000002 9902C20001000002 +1970-01-01 00:00:01.000003 1970-01-01 00:00:01.000003 9902C20001000003 +1970-01-01 00:00:01.000004 1970-01-01 00:00:01.000004 9902C20001000004 +1970-01-01 00:00:01.000005 1970-01-01 00:00:01.000005 9902C20001000005 +1970-01-01 00:00:01.000006 1970-01-01 00:00:01.000006 9902C20001000006 +1970-01-01 00:00:01.000007 1970-01-01 00:00:01.000007 9902C20001000007 +1970-01-01 00:00:01.000008 1970-01-01 00:00:01.000008 9902C20001000008 +1970-01-01 00:00:01.000009 1970-01-01 00:00:01.000009 9902C20001000009 +1970-01-01 00:00:01.000010 1970-01-01 00:00:01.000010 9902C2000100000A +1970-01-01 00:00:01.000011 1970-01-01 00:00:01.000011 9902C2000100000B +1970-01-01 00:00:01.000012 1970-01-01 00:00:01.000012 9902C2000100000C +1970-01-01 00:00:01.000013 1970-01-01 00:00:01.000013 9902C2000100000D +1970-01-01 00:00:01.000014 1970-01-01 00:00:01.000014 9902C2000100000E +1970-01-01 00:00:01.000015 1970-01-01 00:00:01.000015 9902C2000100000F +1970-01-01 00:00:01.000016 1970-01-01 00:00:01.000016 9902C20001000010 +1970-01-01 00:00:01.000099 1970-01-01 00:00:01.000099 9902C20001000063 +1970-01-01 00:00:01.000999 1970-01-01 00:00:01.000999 9902C200010003E7 +1970-01-01 00:00:01.009999 1970-01-01 00:00:01.009999 9902C2000100270F +1970-01-01 00:00:01.099999 1970-01-01 00:00:01.099999 9902C2000101869F +1970-01-01 00:00:01.100000 1970-01-01 00:00:01.100000 9902C200010186A0 +1970-01-01 00:00:01.900000 1970-01-01 00:00:01.900000 9902C200010DBBA0 +1970-01-01 00:00:01.990000 1970-01-01 00:00:01.990000 9902C200010F1B30 +1970-01-01 00:00:01.999000 1970-01-01 00:00:01.999000 9902C200010F3E58 +1970-01-01 00:00:01.999900 1970-01-01 00:00:01.999900 9902C200010F41DC +1970-01-01 00:00:01.999990 1970-01-01 00:00:01.999990 9902C200010F4236 +1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999999 9902C200010F423F +1970-01-01 00:00:02.000000 1970-01-01 00:00:02.000000 9902C20002000000 +1970-01-01 00:00:02.000001 1970-01-01 00:00:02.000001 9902C20002000001 +1970-01-01 00:00:02.000002 1970-01-01 00:00:02.000002 9902C20002000002 +1970-01-01 00:00:02.000003 1970-01-01 00:00:02.000003 9902C20002000003 +1970-01-01 00:00:02.000004 1970-01-01 00:00:02.000004 9902C20002000004 +1970-01-01 00:00:02.000005 1970-01-01 00:00:02.000005 9902C20002000005 +1970-01-01 00:00:02.000006 1970-01-01 00:00:02.000006 9902C20002000006 +1970-01-01 00:00:02.000007 1970-01-01 00:00:02.000007 9902C20002000007 +1970-01-01 00:00:02.000008 1970-01-01 00:00:02.000008 9902C20002000008 +1970-01-01 00:00:02.000009 1970-01-01 00:00:02.000009 9902C20002000009 +1970-01-01 00:00:02.000010 1970-01-01 00:00:02.000010 9902C2000200000A +1970-01-01 00:00:02.000011 1970-01-01 00:00:02.000011 9902C2000200000B +1970-01-01 00:00:02.000012 1970-01-01 00:00:02.000012 9902C2000200000C +1970-01-01 00:00:02.000013 1970-01-01 00:00:02.000013 9902C2000200000D +1970-01-01 00:00:02.000014 1970-01-01 00:00:02.000014 9902C2000200000E +1970-01-01 00:00:02.000015 1970-01-01 00:00:02.000015 9902C2000200000F +1970-01-01 00:00:02.000016 1970-01-01 00:00:02.000016 9902C20002000010 +1970-01-01 00:00:02.000099 1970-01-01 00:00:02.000099 9902C20002000063 +1970-01-01 00:00:02.000999 1970-01-01 00:00:02.000999 9902C200020003E7 +1970-01-01 00:00:02.009999 1970-01-01 00:00:02.009999 9902C2000200270F +1970-01-01 00:00:02.090000 1970-01-01 00:00:02.090000 9902C20002015F90 +1970-01-01 00:00:02.099999 1970-01-01 00:00:02.099999 9902C2000201869F +1970-01-01 00:00:02.100000 1970-01-01 00:00:02.100000 9902C200020186A0 +1970-01-01 00:00:02.900000 1970-01-01 00:00:02.900000 9902C200020DBBA0 +1970-01-01 00:00:02.990000 1970-01-01 00:00:02.990000 9902C200020F1B30 +1970-01-01 00:00:02.999000 1970-01-01 00:00:02.999000 9902C200020F3E58 +1970-01-01 00:00:02.999900 1970-01-01 00:00:02.999900 9902C200020F41DC +1970-01-01 00:00:02.999990 1970-01-01 00:00:02.999990 9902C200020F4236 +1970-01-01 00:00:02.999999 1970-01-01 00:00:02.999999 9902C200020F423F +1970-01-01 00:01:00.000001 1970-01-01 00:01:00.000001 9902C20040000001 +1970-01-01 00:01:00.000008 1970-01-01 00:01:00.000008 9902C20040000008 +1970-01-01 00:01:00.000015 1970-01-01 00:01:00.000015 9902C2004000000F +1970-01-01 00:01:00.000016 1970-01-01 00:01:00.000016 9902C20040000010 +1970-01-01 00:01:00.000099 1970-01-01 00:01:00.000099 9902C20040000063 +1970-01-01 00:01:00.000999 1970-01-01 00:01:00.000999 9902C200400003E7 +1970-01-01 00:01:00.009999 1970-01-01 00:01:00.009999 9902C2004000270F +1970-01-01 00:01:00.099999 1970-01-01 00:01:00.099999 9902C2004001869F +1970-01-01 00:01:00.100000 1970-01-01 00:01:00.100000 9902C200400186A0 +1970-01-01 00:01:00.900000 1970-01-01 00:01:00.900000 9902C200400DBBA0 +1970-01-01 00:01:00.999999 1970-01-01 00:01:00.999999 9902C200400F423F +1970-01-01 01:00:00.000001 1970-01-01 01:00:00.000001 9902C21000000001 +1970-01-01 01:00:00.000008 1970-01-01 01:00:00.000008 9902C21000000008 +1970-01-01 01:00:00.000015 1970-01-01 01:00:00.000015 9902C2100000000F +1970-01-01 01:00:00.000016 1970-01-01 01:00:00.000016 9902C21000000010 +1970-01-01 01:00:00.000099 1970-01-01 01:00:00.000099 9902C21000000063 +1970-01-01 01:00:00.000999 1970-01-01 01:00:00.000999 9902C210000003E7 +1970-01-01 01:00:00.009999 1970-01-01 01:00:00.009999 9902C2100000270F +1970-01-01 01:00:00.099999 1970-01-01 01:00:00.099999 9902C2100001869F +1970-01-01 01:00:00.100000 1970-01-01 01:00:00.100000 9902C210000186A0 +1970-01-01 01:00:00.900000 1970-01-01 01:00:00.900000 9902C210000DBBA0 +1970-01-01 01:00:00.990000 1970-01-01 01:00:00.990000 9902C210000F1B30 +1970-01-01 01:00:00.999000 1970-01-01 01:00:00.999000 9902C210000F3E58 +1970-01-01 01:00:00.999900 1970-01-01 01:00:00.999900 9902C210000F41DC +1970-01-01 01:00:00.999990 1970-01-01 01:00:00.999990 9902C210000F4236 +1970-01-01 01:00:00.999999 1970-01-01 01:00:00.999999 9902C210000F423F +2001-01-01 23:59:58.000001 2001-01-01 23:59:58.000001 9967837EFA000001 +2001-01-01 23:59:58.000008 2001-01-01 23:59:58.000008 9967837EFA000008 +2001-01-01 23:59:58.000015 2001-01-01 23:59:58.000015 9967837EFA00000F +2001-01-01 23:59:58.000016 2001-01-01 23:59:58.000016 9967837EFA000010 +2001-01-01 23:59:58.000099 2001-01-01 23:59:58.000099 9967837EFA000063 +2001-01-01 23:59:58.000999 2001-01-01 23:59:58.000999 9967837EFA0003E7 +2001-01-01 23:59:58.009999 2001-01-01 23:59:58.009999 9967837EFA00270F +2001-01-01 23:59:58.099999 2001-01-01 23:59:58.099999 9967837EFA01869F +2001-01-01 23:59:58.100000 2001-01-01 23:59:58.100000 9967837EFA0186A0 +2001-01-01 23:59:58.900000 2001-01-01 23:59:58.900000 9967837EFA0DBBA0 +2001-01-01 23:59:58.990000 2001-01-01 23:59:58.990000 9967837EFA0F1B30 +2001-01-01 23:59:58.999000 2001-01-01 23:59:58.999000 9967837EFA0F3E58 +2001-01-01 23:59:58.999900 2001-01-01 23:59:58.999900 9967837EFA0F41DC +2001-01-01 23:59:58.999990 2001-01-01 23:59:58.999990 9967837EFA0F4236 +2001-01-01 23:59:58.999999 2001-01-01 23:59:58.999999 9967837EFA0F423F +2001-01-01 23:59:59.000000 2001-01-01 23:59:59.000000 9967837EFB000000 +2037-01-01 23:59:58.000001 2037-01-01 23:59:58.000001 99DC837EFA000001 +2037-01-01 23:59:58.000008 2037-01-01 23:59:58.000008 99DC837EFA000008 +2037-01-01 23:59:58.000015 2037-01-01 23:59:58.000015 99DC837EFA00000F +2037-01-01 23:59:58.000016 2037-01-01 23:59:58.000016 99DC837EFA000010 +2037-01-01 23:59:58.000099 2037-01-01 23:59:58.000099 99DC837EFA000063 +2037-01-01 23:59:58.000999 2037-01-01 23:59:58.000999 99DC837EFA0003E7 +2037-01-01 23:59:58.009999 2037-01-01 23:59:58.009999 99DC837EFA00270F +2037-01-01 23:59:58.099999 2037-01-01 23:59:58.099999 99DC837EFA01869F +2037-01-01 23:59:58.100000 2037-01-01 23:59:58.100000 99DC837EFA0186A0 +2037-01-01 23:59:58.900000 2037-01-01 23:59:58.900000 99DC837EFA0DBBA0 +2037-01-01 23:59:58.990000 2037-01-01 23:59:58.990000 99DC837EFA0F1B30 +2037-01-01 23:59:58.999000 2037-01-01 23:59:58.999000 99DC837EFA0F3E58 +2037-01-01 23:59:58.999900 2037-01-01 23:59:58.999900 99DC837EFA0F41DC +2037-01-01 23:59:58.999990 2037-01-01 23:59:58.999990 99DC837EFA0F4236 +2037-01-01 23:59:58.999999 2037-01-01 23:59:58.999999 99DC837EFA0F423F +2037-01-01 23:59:59.000000 2037-01-01 23:59:59.000000 99DC837EFB000000 +SELECT a5, d5, HEX(WEIGHT_STRING(d5)) FROM t1 ORDER BY d5, a6; +a5 d5 HEX(WEIGHT_STRING(d5)) +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00000 1970-01-01 00:00:01.00000 9902C20001000000 +1970-01-01 00:00:01.00001 1970-01-01 00:00:01.00001 9902C2000100000A +1970-01-01 00:00:01.00001 1970-01-01 00:00:01.00001 9902C2000100000A +1970-01-01 00:00:01.00001 1970-01-01 00:00:01.00001 9902C2000100000A +1970-01-01 00:00:01.00001 1970-01-01 00:00:01.00001 9902C2000100000A +1970-01-01 00:00:01.00001 1970-01-01 00:00:01.00001 9902C2000100000A +1970-01-01 00:00:01.00001 1970-01-01 00:00:01.00001 9902C2000100000A +1970-01-01 00:00:01.00001 1970-01-01 00:00:01.00001 9902C2000100000A +1970-01-01 00:00:01.00009 1970-01-01 00:00:01.00009 9902C2000100005A +1970-01-01 00:00:01.00099 1970-01-01 00:00:01.00099 9902C200010003DE +1970-01-01 00:00:01.00999 1970-01-01 00:00:01.00999 9902C20001002706 +1970-01-01 00:00:01.09999 1970-01-01 00:00:01.09999 9902C20001018696 +1970-01-01 00:00:01.10000 1970-01-01 00:00:01.10000 9902C200010186A0 +1970-01-01 00:00:01.90000 1970-01-01 00:00:01.90000 9902C200010DBBA0 +1970-01-01 00:00:01.99000 1970-01-01 00:00:01.99000 9902C200010F1B30 +1970-01-01 00:00:01.99900 1970-01-01 00:00:01.99900 9902C200010F3E58 +1970-01-01 00:00:01.99990 1970-01-01 00:00:01.99990 9902C200010F41DC +1970-01-01 00:00:01.99999 1970-01-01 00:00:01.99999 9902C200010F4236 +1970-01-01 00:00:01.99999 1970-01-01 00:00:01.99999 9902C200010F4236 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 9902C20002000000 +1970-01-01 00:00:02.00001 1970-01-01 00:00:02.00001 9902C2000200000A +1970-01-01 00:00:02.00001 1970-01-01 00:00:02.00001 9902C2000200000A +1970-01-01 00:00:02.00001 1970-01-01 00:00:02.00001 9902C2000200000A +1970-01-01 00:00:02.00001 1970-01-01 00:00:02.00001 9902C2000200000A +1970-01-01 00:00:02.00001 1970-01-01 00:00:02.00001 9902C2000200000A +1970-01-01 00:00:02.00001 1970-01-01 00:00:02.00001 9902C2000200000A +1970-01-01 00:00:02.00001 1970-01-01 00:00:02.00001 9902C2000200000A +1970-01-01 00:00:02.00009 1970-01-01 00:00:02.00009 9902C2000200005A +1970-01-01 00:00:02.00099 1970-01-01 00:00:02.00099 9902C200020003DE +1970-01-01 00:00:02.00999 1970-01-01 00:00:02.00999 9902C20002002706 +1970-01-01 00:00:02.09000 1970-01-01 00:00:02.09000 9902C20002015F90 +1970-01-01 00:00:02.09999 1970-01-01 00:00:02.09999 9902C20002018696 +1970-01-01 00:00:02.10000 1970-01-01 00:00:02.10000 9902C200020186A0 +1970-01-01 00:00:02.90000 1970-01-01 00:00:02.90000 9902C200020DBBA0 +1970-01-01 00:00:02.99000 1970-01-01 00:00:02.99000 9902C200020F1B30 +1970-01-01 00:00:02.99900 1970-01-01 00:00:02.99900 9902C200020F3E58 +1970-01-01 00:00:02.99990 1970-01-01 00:00:02.99990 9902C200020F41DC +1970-01-01 00:00:02.99999 1970-01-01 00:00:02.99999 9902C200020F4236 +1970-01-01 00:00:02.99999 1970-01-01 00:00:02.99999 9902C200020F4236 +1970-01-01 00:01:00.00000 1970-01-01 00:01:00.00000 9902C20040000000 +1970-01-01 00:01:00.00000 1970-01-01 00:01:00.00000 9902C20040000000 +1970-01-01 00:01:00.00001 1970-01-01 00:01:00.00001 9902C2004000000A +1970-01-01 00:01:00.00001 1970-01-01 00:01:00.00001 9902C2004000000A +1970-01-01 00:01:00.00009 1970-01-01 00:01:00.00009 9902C2004000005A +1970-01-01 00:01:00.00099 1970-01-01 00:01:00.00099 9902C200400003DE +1970-01-01 00:01:00.00999 1970-01-01 00:01:00.00999 9902C20040002706 +1970-01-01 00:01:00.09999 1970-01-01 00:01:00.09999 9902C20040018696 +1970-01-01 00:01:00.10000 1970-01-01 00:01:00.10000 9902C200400186A0 +1970-01-01 00:01:00.90000 1970-01-01 00:01:00.90000 9902C200400DBBA0 +1970-01-01 00:01:00.99999 1970-01-01 00:01:00.99999 9902C200400F4236 +1970-01-01 01:00:00.00000 1970-01-01 01:00:00.00000 9902C21000000000 +1970-01-01 01:00:00.00000 1970-01-01 01:00:00.00000 9902C21000000000 +1970-01-01 01:00:00.00001 1970-01-01 01:00:00.00001 9902C2100000000A +1970-01-01 01:00:00.00001 1970-01-01 01:00:00.00001 9902C2100000000A +1970-01-01 01:00:00.00009 1970-01-01 01:00:00.00009 9902C2100000005A +1970-01-01 01:00:00.00099 1970-01-01 01:00:00.00099 9902C210000003DE +1970-01-01 01:00:00.00999 1970-01-01 01:00:00.00999 9902C21000002706 +1970-01-01 01:00:00.09999 1970-01-01 01:00:00.09999 9902C21000018696 +1970-01-01 01:00:00.10000 1970-01-01 01:00:00.10000 9902C210000186A0 +1970-01-01 01:00:00.90000 1970-01-01 01:00:00.90000 9902C210000DBBA0 +1970-01-01 01:00:00.99000 1970-01-01 01:00:00.99000 9902C210000F1B30 +1970-01-01 01:00:00.99900 1970-01-01 01:00:00.99900 9902C210000F3E58 +1970-01-01 01:00:00.99990 1970-01-01 01:00:00.99990 9902C210000F41DC +1970-01-01 01:00:00.99999 1970-01-01 01:00:00.99999 9902C210000F4236 +1970-01-01 01:00:00.99999 1970-01-01 01:00:00.99999 9902C210000F4236 +2001-01-01 23:59:58.00000 2001-01-01 23:59:58.00000 9967837EFA000000 +2001-01-01 23:59:58.00000 2001-01-01 23:59:58.00000 9967837EFA000000 +2001-01-01 23:59:58.00001 2001-01-01 23:59:58.00001 9967837EFA00000A +2001-01-01 23:59:58.00001 2001-01-01 23:59:58.00001 9967837EFA00000A +2001-01-01 23:59:58.00009 2001-01-01 23:59:58.00009 9967837EFA00005A +2001-01-01 23:59:58.00099 2001-01-01 23:59:58.00099 9967837EFA0003DE +2001-01-01 23:59:58.00999 2001-01-01 23:59:58.00999 9967837EFA002706 +2001-01-01 23:59:58.09999 2001-01-01 23:59:58.09999 9967837EFA018696 +2001-01-01 23:59:58.10000 2001-01-01 23:59:58.10000 9967837EFA0186A0 +2001-01-01 23:59:58.90000 2001-01-01 23:59:58.90000 9967837EFA0DBBA0 +2001-01-01 23:59:58.99000 2001-01-01 23:59:58.99000 9967837EFA0F1B30 +2001-01-01 23:59:58.99900 2001-01-01 23:59:58.99900 9967837EFA0F3E58 +2001-01-01 23:59:58.99990 2001-01-01 23:59:58.99990 9967837EFA0F41DC +2001-01-01 23:59:58.99999 2001-01-01 23:59:58.99999 9967837EFA0F4236 +2001-01-01 23:59:58.99999 2001-01-01 23:59:58.99999 9967837EFA0F4236 +2001-01-01 23:59:59.00000 2001-01-01 23:59:59.00000 9967837EFB000000 +2037-01-01 23:59:58.00000 2037-01-01 23:59:58.00000 99DC837EFA000000 +2037-01-01 23:59:58.00000 2037-01-01 23:59:58.00000 99DC837EFA000000 +2037-01-01 23:59:58.00001 2037-01-01 23:59:58.00001 99DC837EFA00000A +2037-01-01 23:59:58.00001 2037-01-01 23:59:58.00001 99DC837EFA00000A +2037-01-01 23:59:58.00009 2037-01-01 23:59:58.00009 99DC837EFA00005A +2037-01-01 23:59:58.00099 2037-01-01 23:59:58.00099 99DC837EFA0003DE +2037-01-01 23:59:58.00999 2037-01-01 23:59:58.00999 99DC837EFA002706 +2037-01-01 23:59:58.09999 2037-01-01 23:59:58.09999 99DC837EFA018696 +2037-01-01 23:59:58.10000 2037-01-01 23:59:58.10000 99DC837EFA0186A0 +2037-01-01 23:59:58.90000 2037-01-01 23:59:58.90000 99DC837EFA0DBBA0 +2037-01-01 23:59:58.99000 2037-01-01 23:59:58.99000 99DC837EFA0F1B30 +2037-01-01 23:59:58.99900 2037-01-01 23:59:58.99900 99DC837EFA0F3E58 +2037-01-01 23:59:58.99990 2037-01-01 23:59:58.99990 99DC837EFA0F41DC +2037-01-01 23:59:58.99999 2037-01-01 23:59:58.99999 99DC837EFA0F4236 +2037-01-01 23:59:58.99999 2037-01-01 23:59:58.99999 99DC837EFA0F4236 +2037-01-01 23:59:59.00000 2037-01-01 23:59:59.00000 99DC837EFB000000 +SELECT a4, d4, HEX(WEIGHT_STRING(d4)) FROM t1 ORDER BY d4, a6; +a4 d4 HEX(WEIGHT_STRING(d4)) +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0000 1970-01-01 00:00:01.0000 9902C20001000000 +1970-01-01 00:00:01.0009 1970-01-01 00:00:01.0009 9902C20001000384 +1970-01-01 00:00:01.0099 1970-01-01 00:00:01.0099 9902C200010026AC +1970-01-01 00:00:01.0999 1970-01-01 00:00:01.0999 9902C2000101863C +1970-01-01 00:00:01.1000 1970-01-01 00:00:01.1000 9902C200010186A0 +1970-01-01 00:00:01.9000 1970-01-01 00:00:01.9000 9902C200010DBBA0 +1970-01-01 00:00:01.9900 1970-01-01 00:00:01.9900 9902C200010F1B30 +1970-01-01 00:00:01.9990 1970-01-01 00:00:01.9990 9902C200010F3E58 +1970-01-01 00:00:01.9999 1970-01-01 00:00:01.9999 9902C200010F41DC +1970-01-01 00:00:01.9999 1970-01-01 00:00:01.9999 9902C200010F41DC +1970-01-01 00:00:01.9999 1970-01-01 00:00:01.9999 9902C200010F41DC +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 9902C20002000000 +1970-01-01 00:00:02.0009 1970-01-01 00:00:02.0009 9902C20002000384 +1970-01-01 00:00:02.0099 1970-01-01 00:00:02.0099 9902C200020026AC +1970-01-01 00:00:02.0900 1970-01-01 00:00:02.0900 9902C20002015F90 +1970-01-01 00:00:02.0999 1970-01-01 00:00:02.0999 9902C2000201863C +1970-01-01 00:00:02.1000 1970-01-01 00:00:02.1000 9902C200020186A0 +1970-01-01 00:00:02.9000 1970-01-01 00:00:02.9000 9902C200020DBBA0 +1970-01-01 00:00:02.9900 1970-01-01 00:00:02.9900 9902C200020F1B30 +1970-01-01 00:00:02.9990 1970-01-01 00:00:02.9990 9902C200020F3E58 +1970-01-01 00:00:02.9999 1970-01-01 00:00:02.9999 9902C200020F41DC +1970-01-01 00:00:02.9999 1970-01-01 00:00:02.9999 9902C200020F41DC +1970-01-01 00:00:02.9999 1970-01-01 00:00:02.9999 9902C200020F41DC +1970-01-01 00:01:00.0000 1970-01-01 00:01:00.0000 9902C20040000000 +1970-01-01 00:01:00.0000 1970-01-01 00:01:00.0000 9902C20040000000 +1970-01-01 00:01:00.0000 1970-01-01 00:01:00.0000 9902C20040000000 +1970-01-01 00:01:00.0000 1970-01-01 00:01:00.0000 9902C20040000000 +1970-01-01 00:01:00.0000 1970-01-01 00:01:00.0000 9902C20040000000 +1970-01-01 00:01:00.0009 1970-01-01 00:01:00.0009 9902C20040000384 +1970-01-01 00:01:00.0099 1970-01-01 00:01:00.0099 9902C200400026AC +1970-01-01 00:01:00.0999 1970-01-01 00:01:00.0999 9902C2004001863C +1970-01-01 00:01:00.1000 1970-01-01 00:01:00.1000 9902C200400186A0 +1970-01-01 00:01:00.9000 1970-01-01 00:01:00.9000 9902C200400DBBA0 +1970-01-01 00:01:00.9999 1970-01-01 00:01:00.9999 9902C200400F41DC +1970-01-01 01:00:00.0000 1970-01-01 01:00:00.0000 9902C21000000000 +1970-01-01 01:00:00.0000 1970-01-01 01:00:00.0000 9902C21000000000 +1970-01-01 01:00:00.0000 1970-01-01 01:00:00.0000 9902C21000000000 +1970-01-01 01:00:00.0000 1970-01-01 01:00:00.0000 9902C21000000000 +1970-01-01 01:00:00.0000 1970-01-01 01:00:00.0000 9902C21000000000 +1970-01-01 01:00:00.0009 1970-01-01 01:00:00.0009 9902C21000000384 +1970-01-01 01:00:00.0099 1970-01-01 01:00:00.0099 9902C210000026AC +1970-01-01 01:00:00.0999 1970-01-01 01:00:00.0999 9902C2100001863C +1970-01-01 01:00:00.1000 1970-01-01 01:00:00.1000 9902C210000186A0 +1970-01-01 01:00:00.9000 1970-01-01 01:00:00.9000 9902C210000DBBA0 +1970-01-01 01:00:00.9900 1970-01-01 01:00:00.9900 9902C210000F1B30 +1970-01-01 01:00:00.9990 1970-01-01 01:00:00.9990 9902C210000F3E58 +1970-01-01 01:00:00.9999 1970-01-01 01:00:00.9999 9902C210000F41DC +1970-01-01 01:00:00.9999 1970-01-01 01:00:00.9999 9902C210000F41DC +1970-01-01 01:00:00.9999 1970-01-01 01:00:00.9999 9902C210000F41DC +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0000 2001-01-01 23:59:58.0000 9967837EFA000000 +2001-01-01 23:59:58.0009 2001-01-01 23:59:58.0009 9967837EFA000384 +2001-01-01 23:59:58.0099 2001-01-01 23:59:58.0099 9967837EFA0026AC +2001-01-01 23:59:58.0999 2001-01-01 23:59:58.0999 9967837EFA01863C +2001-01-01 23:59:58.1000 2001-01-01 23:59:58.1000 9967837EFA0186A0 +2001-01-01 23:59:58.9000 2001-01-01 23:59:58.9000 9967837EFA0DBBA0 +2001-01-01 23:59:58.9900 2001-01-01 23:59:58.9900 9967837EFA0F1B30 +2001-01-01 23:59:58.9990 2001-01-01 23:59:58.9990 9967837EFA0F3E58 +2001-01-01 23:59:58.9999 2001-01-01 23:59:58.9999 9967837EFA0F41DC +2001-01-01 23:59:58.9999 2001-01-01 23:59:58.9999 9967837EFA0F41DC +2001-01-01 23:59:58.9999 2001-01-01 23:59:58.9999 9967837EFA0F41DC +2001-01-01 23:59:59.0000 2001-01-01 23:59:59.0000 9967837EFB000000 +2037-01-01 23:59:58.0000 2037-01-01 23:59:58.0000 99DC837EFA000000 +2037-01-01 23:59:58.0000 2037-01-01 23:59:58.0000 99DC837EFA000000 +2037-01-01 23:59:58.0000 2037-01-01 23:59:58.0000 99DC837EFA000000 +2037-01-01 23:59:58.0000 2037-01-01 23:59:58.0000 99DC837EFA000000 +2037-01-01 23:59:58.0000 2037-01-01 23:59:58.0000 99DC837EFA000000 +2037-01-01 23:59:58.0009 2037-01-01 23:59:58.0009 99DC837EFA000384 +2037-01-01 23:59:58.0099 2037-01-01 23:59:58.0099 99DC837EFA0026AC +2037-01-01 23:59:58.0999 2037-01-01 23:59:58.0999 99DC837EFA01863C +2037-01-01 23:59:58.1000 2037-01-01 23:59:58.1000 99DC837EFA0186A0 +2037-01-01 23:59:58.9000 2037-01-01 23:59:58.9000 99DC837EFA0DBBA0 +2037-01-01 23:59:58.9900 2037-01-01 23:59:58.9900 99DC837EFA0F1B30 +2037-01-01 23:59:58.9990 2037-01-01 23:59:58.9990 99DC837EFA0F3E58 +2037-01-01 23:59:58.9999 2037-01-01 23:59:58.9999 99DC837EFA0F41DC +2037-01-01 23:59:58.9999 2037-01-01 23:59:58.9999 99DC837EFA0F41DC +2037-01-01 23:59:58.9999 2037-01-01 23:59:58.9999 99DC837EFA0F41DC +2037-01-01 23:59:59.0000 2037-01-01 23:59:59.0000 99DC837EFB000000 +SELECT a3, d3, HEX(WEIGHT_STRING(d3)) FROM t1 ORDER BY d3, a6; +a3 d3 HEX(WEIGHT_STRING(d3)) +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.000 1970-01-01 00:00:01.000 9902C20001000000 +1970-01-01 00:00:01.009 1970-01-01 00:00:01.009 9902C20001002328 +1970-01-01 00:00:01.099 1970-01-01 00:00:01.099 9902C200010182B8 +1970-01-01 00:00:01.100 1970-01-01 00:00:01.100 9902C200010186A0 +1970-01-01 00:00:01.900 1970-01-01 00:00:01.900 9902C200010DBBA0 +1970-01-01 00:00:01.990 1970-01-01 00:00:01.990 9902C200010F1B30 +1970-01-01 00:00:01.999 1970-01-01 00:00:01.999 9902C200010F3E58 +1970-01-01 00:00:01.999 1970-01-01 00:00:01.999 9902C200010F3E58 +1970-01-01 00:00:01.999 1970-01-01 00:00:01.999 9902C200010F3E58 +1970-01-01 00:00:01.999 1970-01-01 00:00:01.999 9902C200010F3E58 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 9902C20002000000 +1970-01-01 00:00:02.009 1970-01-01 00:00:02.009 9902C20002002328 +1970-01-01 00:00:02.090 1970-01-01 00:00:02.090 9902C20002015F90 +1970-01-01 00:00:02.099 1970-01-01 00:00:02.099 9902C200020182B8 +1970-01-01 00:00:02.100 1970-01-01 00:00:02.100 9902C200020186A0 +1970-01-01 00:00:02.900 1970-01-01 00:00:02.900 9902C200020DBBA0 +1970-01-01 00:00:02.990 1970-01-01 00:00:02.990 9902C200020F1B30 +1970-01-01 00:00:02.999 1970-01-01 00:00:02.999 9902C200020F3E58 +1970-01-01 00:00:02.999 1970-01-01 00:00:02.999 9902C200020F3E58 +1970-01-01 00:00:02.999 1970-01-01 00:00:02.999 9902C200020F3E58 +1970-01-01 00:00:02.999 1970-01-01 00:00:02.999 9902C200020F3E58 +1970-01-01 00:01:00.000 1970-01-01 00:01:00.000 9902C20040000000 +1970-01-01 00:01:00.000 1970-01-01 00:01:00.000 9902C20040000000 +1970-01-01 00:01:00.000 1970-01-01 00:01:00.000 9902C20040000000 +1970-01-01 00:01:00.000 1970-01-01 00:01:00.000 9902C20040000000 +1970-01-01 00:01:00.000 1970-01-01 00:01:00.000 9902C20040000000 +1970-01-01 00:01:00.000 1970-01-01 00:01:00.000 9902C20040000000 +1970-01-01 00:01:00.009 1970-01-01 00:01:00.009 9902C20040002328 +1970-01-01 00:01:00.099 1970-01-01 00:01:00.099 9902C200400182B8 +1970-01-01 00:01:00.100 1970-01-01 00:01:00.100 9902C200400186A0 +1970-01-01 00:01:00.900 1970-01-01 00:01:00.900 9902C200400DBBA0 +1970-01-01 00:01:00.999 1970-01-01 00:01:00.999 9902C200400F3E58 +1970-01-01 01:00:00.000 1970-01-01 01:00:00.000 9902C21000000000 +1970-01-01 01:00:00.000 1970-01-01 01:00:00.000 9902C21000000000 +1970-01-01 01:00:00.000 1970-01-01 01:00:00.000 9902C21000000000 +1970-01-01 01:00:00.000 1970-01-01 01:00:00.000 9902C21000000000 +1970-01-01 01:00:00.000 1970-01-01 01:00:00.000 9902C21000000000 +1970-01-01 01:00:00.000 1970-01-01 01:00:00.000 9902C21000000000 +1970-01-01 01:00:00.009 1970-01-01 01:00:00.009 9902C21000002328 +1970-01-01 01:00:00.099 1970-01-01 01:00:00.099 9902C210000182B8 +1970-01-01 01:00:00.100 1970-01-01 01:00:00.100 9902C210000186A0 +1970-01-01 01:00:00.900 1970-01-01 01:00:00.900 9902C210000DBBA0 +1970-01-01 01:00:00.990 1970-01-01 01:00:00.990 9902C210000F1B30 +1970-01-01 01:00:00.999 1970-01-01 01:00:00.999 9902C210000F3E58 +1970-01-01 01:00:00.999 1970-01-01 01:00:00.999 9902C210000F3E58 +1970-01-01 01:00:00.999 1970-01-01 01:00:00.999 9902C210000F3E58 +1970-01-01 01:00:00.999 1970-01-01 01:00:00.999 9902C210000F3E58 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.000 2001-01-01 23:59:58.000 9967837EFA000000 +2001-01-01 23:59:58.009 2001-01-01 23:59:58.009 9967837EFA002328 +2001-01-01 23:59:58.099 2001-01-01 23:59:58.099 9967837EFA0182B8 +2001-01-01 23:59:58.100 2001-01-01 23:59:58.100 9967837EFA0186A0 +2001-01-01 23:59:58.900 2001-01-01 23:59:58.900 9967837EFA0DBBA0 +2001-01-01 23:59:58.990 2001-01-01 23:59:58.990 9967837EFA0F1B30 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:58.999 2001-01-01 23:59:58.999 9967837EFA0F3E58 +2001-01-01 23:59:59.000 2001-01-01 23:59:59.000 9967837EFB000000 +2037-01-01 23:59:58.000 2037-01-01 23:59:58.000 99DC837EFA000000 +2037-01-01 23:59:58.000 2037-01-01 23:59:58.000 99DC837EFA000000 +2037-01-01 23:59:58.000 2037-01-01 23:59:58.000 99DC837EFA000000 +2037-01-01 23:59:58.000 2037-01-01 23:59:58.000 99DC837EFA000000 +2037-01-01 23:59:58.000 2037-01-01 23:59:58.000 99DC837EFA000000 +2037-01-01 23:59:58.000 2037-01-01 23:59:58.000 99DC837EFA000000 +2037-01-01 23:59:58.009 2037-01-01 23:59:58.009 99DC837EFA002328 +2037-01-01 23:59:58.099 2037-01-01 23:59:58.099 99DC837EFA0182B8 +2037-01-01 23:59:58.100 2037-01-01 23:59:58.100 99DC837EFA0186A0 +2037-01-01 23:59:58.900 2037-01-01 23:59:58.900 99DC837EFA0DBBA0 +2037-01-01 23:59:58.990 2037-01-01 23:59:58.990 99DC837EFA0F1B30 +2037-01-01 23:59:58.999 2037-01-01 23:59:58.999 99DC837EFA0F3E58 +2037-01-01 23:59:58.999 2037-01-01 23:59:58.999 99DC837EFA0F3E58 +2037-01-01 23:59:58.999 2037-01-01 23:59:58.999 99DC837EFA0F3E58 +2037-01-01 23:59:58.999 2037-01-01 23:59:58.999 99DC837EFA0F3E58 +2037-01-01 23:59:59.000 2037-01-01 23:59:59.000 99DC837EFB000000 +SELECT a2, d2, HEX(WEIGHT_STRING(d2)) FROM t1 ORDER BY d2, a6; +a2 d2 HEX(WEIGHT_STRING(d2)) +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.00 1970-01-01 00:00:01.00 9902C20001000000 +1970-01-01 00:00:01.09 1970-01-01 00:00:01.09 9902C20001015F90 +1970-01-01 00:00:01.10 1970-01-01 00:00:01.10 9902C200010186A0 +1970-01-01 00:00:01.90 1970-01-01 00:00:01.90 9902C200010DBBA0 +1970-01-01 00:00:01.99 1970-01-01 00:00:01.99 9902C200010F1B30 +1970-01-01 00:00:01.99 1970-01-01 00:00:01.99 9902C200010F1B30 +1970-01-01 00:00:01.99 1970-01-01 00:00:01.99 9902C200010F1B30 +1970-01-01 00:00:01.99 1970-01-01 00:00:01.99 9902C200010F1B30 +1970-01-01 00:00:01.99 1970-01-01 00:00:01.99 9902C200010F1B30 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 9902C20002000000 +1970-01-01 00:00:02.09 1970-01-01 00:00:02.09 9902C20002015F90 +1970-01-01 00:00:02.09 1970-01-01 00:00:02.09 9902C20002015F90 +1970-01-01 00:00:02.10 1970-01-01 00:00:02.10 9902C200020186A0 +1970-01-01 00:00:02.90 1970-01-01 00:00:02.90 9902C200020DBBA0 +1970-01-01 00:00:02.99 1970-01-01 00:00:02.99 9902C200020F1B30 +1970-01-01 00:00:02.99 1970-01-01 00:00:02.99 9902C200020F1B30 +1970-01-01 00:00:02.99 1970-01-01 00:00:02.99 9902C200020F1B30 +1970-01-01 00:00:02.99 1970-01-01 00:00:02.99 9902C200020F1B30 +1970-01-01 00:00:02.99 1970-01-01 00:00:02.99 9902C200020F1B30 +1970-01-01 00:01:00.00 1970-01-01 00:01:00.00 9902C20040000000 +1970-01-01 00:01:00.00 1970-01-01 00:01:00.00 9902C20040000000 +1970-01-01 00:01:00.00 1970-01-01 00:01:00.00 9902C20040000000 +1970-01-01 00:01:00.00 1970-01-01 00:01:00.00 9902C20040000000 +1970-01-01 00:01:00.00 1970-01-01 00:01:00.00 9902C20040000000 +1970-01-01 00:01:00.00 1970-01-01 00:01:00.00 9902C20040000000 +1970-01-01 00:01:00.00 1970-01-01 00:01:00.00 9902C20040000000 +1970-01-01 00:01:00.09 1970-01-01 00:01:00.09 9902C20040015F90 +1970-01-01 00:01:00.10 1970-01-01 00:01:00.10 9902C200400186A0 +1970-01-01 00:01:00.90 1970-01-01 00:01:00.90 9902C200400DBBA0 +1970-01-01 00:01:00.99 1970-01-01 00:01:00.99 9902C200400F1B30 +1970-01-01 01:00:00.00 1970-01-01 01:00:00.00 9902C21000000000 +1970-01-01 01:00:00.00 1970-01-01 01:00:00.00 9902C21000000000 +1970-01-01 01:00:00.00 1970-01-01 01:00:00.00 9902C21000000000 +1970-01-01 01:00:00.00 1970-01-01 01:00:00.00 9902C21000000000 +1970-01-01 01:00:00.00 1970-01-01 01:00:00.00 9902C21000000000 +1970-01-01 01:00:00.00 1970-01-01 01:00:00.00 9902C21000000000 +1970-01-01 01:00:00.00 1970-01-01 01:00:00.00 9902C21000000000 +1970-01-01 01:00:00.09 1970-01-01 01:00:00.09 9902C21000015F90 +1970-01-01 01:00:00.10 1970-01-01 01:00:00.10 9902C210000186A0 +1970-01-01 01:00:00.90 1970-01-01 01:00:00.90 9902C210000DBBA0 +1970-01-01 01:00:00.99 1970-01-01 01:00:00.99 9902C210000F1B30 +1970-01-01 01:00:00.99 1970-01-01 01:00:00.99 9902C210000F1B30 +1970-01-01 01:00:00.99 1970-01-01 01:00:00.99 9902C210000F1B30 +1970-01-01 01:00:00.99 1970-01-01 01:00:00.99 9902C210000F1B30 +1970-01-01 01:00:00.99 1970-01-01 01:00:00.99 9902C210000F1B30 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.00 2001-01-01 23:59:58.00 9967837EFA000000 +2001-01-01 23:59:58.09 2001-01-01 23:59:58.09 9967837EFA015F90 +2001-01-01 23:59:58.10 2001-01-01 23:59:58.10 9967837EFA0186A0 +2001-01-01 23:59:58.90 2001-01-01 23:59:58.90 9967837EFA0DBBA0 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:58.99 2001-01-01 23:59:58.99 9967837EFA0F1B30 +2001-01-01 23:59:59.00 2001-01-01 23:59:59.00 9967837EFB000000 +2037-01-01 23:59:58.00 2037-01-01 23:59:58.00 99DC837EFA000000 +2037-01-01 23:59:58.00 2037-01-01 23:59:58.00 99DC837EFA000000 +2037-01-01 23:59:58.00 2037-01-01 23:59:58.00 99DC837EFA000000 +2037-01-01 23:59:58.00 2037-01-01 23:59:58.00 99DC837EFA000000 +2037-01-01 23:59:58.00 2037-01-01 23:59:58.00 99DC837EFA000000 +2037-01-01 23:59:58.00 2037-01-01 23:59:58.00 99DC837EFA000000 +2037-01-01 23:59:58.00 2037-01-01 23:59:58.00 99DC837EFA000000 +2037-01-01 23:59:58.09 2037-01-01 23:59:58.09 99DC837EFA015F90 +2037-01-01 23:59:58.10 2037-01-01 23:59:58.10 99DC837EFA0186A0 +2037-01-01 23:59:58.90 2037-01-01 23:59:58.90 99DC837EFA0DBBA0 +2037-01-01 23:59:58.99 2037-01-01 23:59:58.99 99DC837EFA0F1B30 +2037-01-01 23:59:58.99 2037-01-01 23:59:58.99 99DC837EFA0F1B30 +2037-01-01 23:59:58.99 2037-01-01 23:59:58.99 99DC837EFA0F1B30 +2037-01-01 23:59:58.99 2037-01-01 23:59:58.99 99DC837EFA0F1B30 +2037-01-01 23:59:58.99 2037-01-01 23:59:58.99 99DC837EFA0F1B30 +2037-01-01 23:59:59.00 2037-01-01 23:59:59.00 99DC837EFB000000 +SELECT a1, d1, HEX(WEIGHT_STRING(d1)) FROM t1 ORDER BY d1, a6; +a1 d1 HEX(WEIGHT_STRING(d1)) +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.0 1970-01-01 00:00:01.0 9902C20001000000 +1970-01-01 00:00:01.1 1970-01-01 00:00:01.1 9902C200010186A0 +1970-01-01 00:00:01.9 1970-01-01 00:00:01.9 9902C200010DBBA0 +1970-01-01 00:00:01.9 1970-01-01 00:00:01.9 9902C200010DBBA0 +1970-01-01 00:00:01.9 1970-01-01 00:00:01.9 9902C200010DBBA0 +1970-01-01 00:00:01.9 1970-01-01 00:00:01.9 9902C200010DBBA0 +1970-01-01 00:00:01.9 1970-01-01 00:00:01.9 9902C200010DBBA0 +1970-01-01 00:00:01.9 1970-01-01 00:00:01.9 9902C200010DBBA0 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 9902C20002000000 +1970-01-01 00:00:02.1 1970-01-01 00:00:02.1 9902C200020186A0 +1970-01-01 00:00:02.9 1970-01-01 00:00:02.9 9902C200020DBBA0 +1970-01-01 00:00:02.9 1970-01-01 00:00:02.9 9902C200020DBBA0 +1970-01-01 00:00:02.9 1970-01-01 00:00:02.9 9902C200020DBBA0 +1970-01-01 00:00:02.9 1970-01-01 00:00:02.9 9902C200020DBBA0 +1970-01-01 00:00:02.9 1970-01-01 00:00:02.9 9902C200020DBBA0 +1970-01-01 00:00:02.9 1970-01-01 00:00:02.9 9902C200020DBBA0 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.0 1970-01-01 00:01:00.0 9902C20040000000 +1970-01-01 00:01:00.1 1970-01-01 00:01:00.1 9902C200400186A0 +1970-01-01 00:01:00.9 1970-01-01 00:01:00.9 9902C200400DBBA0 +1970-01-01 00:01:00.9 1970-01-01 00:01:00.9 9902C200400DBBA0 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.0 1970-01-01 01:00:00.0 9902C21000000000 +1970-01-01 01:00:00.1 1970-01-01 01:00:00.1 9902C210000186A0 +1970-01-01 01:00:00.9 1970-01-01 01:00:00.9 9902C210000DBBA0 +1970-01-01 01:00:00.9 1970-01-01 01:00:00.9 9902C210000DBBA0 +1970-01-01 01:00:00.9 1970-01-01 01:00:00.9 9902C210000DBBA0 +1970-01-01 01:00:00.9 1970-01-01 01:00:00.9 9902C210000DBBA0 +1970-01-01 01:00:00.9 1970-01-01 01:00:00.9 9902C210000DBBA0 +1970-01-01 01:00:00.9 1970-01-01 01:00:00.9 9902C210000DBBA0 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.0 2001-01-01 23:59:58.0 9967837EFA000000 +2001-01-01 23:59:58.1 2001-01-01 23:59:58.1 9967837EFA0186A0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:58.9 2001-01-01 23:59:58.9 9967837EFA0DBBA0 +2001-01-01 23:59:59.0 2001-01-01 23:59:59.0 9967837EFB000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.0 2037-01-01 23:59:58.0 99DC837EFA000000 +2037-01-01 23:59:58.1 2037-01-01 23:59:58.1 99DC837EFA0186A0 +2037-01-01 23:59:58.9 2037-01-01 23:59:58.9 99DC837EFA0DBBA0 +2037-01-01 23:59:58.9 2037-01-01 23:59:58.9 99DC837EFA0DBBA0 +2037-01-01 23:59:58.9 2037-01-01 23:59:58.9 99DC837EFA0DBBA0 +2037-01-01 23:59:58.9 2037-01-01 23:59:58.9 99DC837EFA0DBBA0 +2037-01-01 23:59:58.9 2037-01-01 23:59:58.9 99DC837EFA0DBBA0 +2037-01-01 23:59:58.9 2037-01-01 23:59:58.9 99DC837EFA0DBBA0 +2037-01-01 23:59:59.0 2037-01-01 23:59:59.0 99DC837EFB000000 +SELECT a0, d0, HEX(WEIGHT_STRING(d0)) FROM t1 ORDER BY d0, a6; +a0 d0 HEX(WEIGHT_STRING(d0)) +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:01. 1970-01-01 00:00:01 9902C20001000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:00:02. 1970-01-01 00:00:02 9902C20002000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 00:01:00. 1970-01-01 00:01:00 9902C20040000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +1970-01-01 01:00:00. 1970-01-01 01:00:00 9902C21000000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:58. 2001-01-01 23:59:58 9967837EFA000000 +2001-01-01 23:59:59. 2001-01-01 23:59:59 9967837EFB000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:58. 2037-01-01 23:59:58 99DC837EFA000000 +2037-01-01 23:59:59. 2037-01-01 23:59:59 99DC837EFB000000 +CREATE VIEW v1 AS +SELECT a6, d0, d1, d2, d3, d4, d5, d6, +HEX(WEIGHT_STRING(d0)) as wst0, +HEX(WEIGHT_STRING(d1)) as wst1, +HEX(WEIGHT_STRING(d2)) as wst2, +HEX(WEIGHT_STRING(d3)) as wst3, +HEX(WEIGHT_STRING(d4)) as wst4, +HEX(WEIGHT_STRING(d5)) as wst5, +HEX(WEIGHT_STRING(d6)) as wst6 +FROM t1; +SELECT * FROM v1 WHERE a6 LIKE '%.999999' ORDER BY a6, d6;; +a6 1970-01-01 00:00:01.999999 +d0 1970-01-01 00:00:01 +d1 1970-01-01 00:00:01.9 +d2 1970-01-01 00:00:01.99 +d3 1970-01-01 00:00:01.999 +d4 1970-01-01 00:00:01.9999 +d5 1970-01-01 00:00:01.99999 +d6 1970-01-01 00:00:01.999999 +wst0 9902C20001000000 +wst1 9902C200010DBBA0 +wst2 9902C200010F1B30 +wst3 9902C200010F3E58 +wst4 9902C200010F41DC +wst5 9902C200010F4236 +wst6 9902C200010F423F +a6 1970-01-01 00:00:02.999999 +d0 1970-01-01 00:00:02 +d1 1970-01-01 00:00:02.9 +d2 1970-01-01 00:00:02.99 +d3 1970-01-01 00:00:02.999 +d4 1970-01-01 00:00:02.9999 +d5 1970-01-01 00:00:02.99999 +d6 1970-01-01 00:00:02.999999 +wst0 9902C20002000000 +wst1 9902C200020DBBA0 +wst2 9902C200020F1B30 +wst3 9902C200020F3E58 +wst4 9902C200020F41DC +wst5 9902C200020F4236 +wst6 9902C200020F423F +a6 1970-01-01 00:01:00.999999 +d0 1970-01-01 00:01:00 +d1 1970-01-01 00:01:00.9 +d2 1970-01-01 00:01:00.99 +d3 1970-01-01 00:01:00.999 +d4 1970-01-01 00:01:00.9999 +d5 1970-01-01 00:01:00.99999 +d6 1970-01-01 00:01:00.999999 +wst0 9902C20040000000 +wst1 9902C200400DBBA0 +wst2 9902C200400F1B30 +wst3 9902C200400F3E58 +wst4 9902C200400F41DC +wst5 9902C200400F4236 +wst6 9902C200400F423F +a6 1970-01-01 01:00:00.999999 +d0 1970-01-01 01:00:00 +d1 1970-01-01 01:00:00.9 +d2 1970-01-01 01:00:00.99 +d3 1970-01-01 01:00:00.999 +d4 1970-01-01 01:00:00.9999 +d5 1970-01-01 01:00:00.99999 +d6 1970-01-01 01:00:00.999999 +wst0 9902C21000000000 +wst1 9902C210000DBBA0 +wst2 9902C210000F1B30 +wst3 9902C210000F3E58 +wst4 9902C210000F41DC +wst5 9902C210000F4236 +wst6 9902C210000F423F +a6 2001-01-01 23:59:58.999999 +d0 2001-01-01 23:59:58 +d1 2001-01-01 23:59:58.9 +d2 2001-01-01 23:59:58.99 +d3 2001-01-01 23:59:58.999 +d4 2001-01-01 23:59:58.9999 +d5 2001-01-01 23:59:58.99999 +d6 2001-01-01 23:59:58.999999 +wst0 9967837EFA000000 +wst1 9967837EFA0DBBA0 +wst2 9967837EFA0F1B30 +wst3 9967837EFA0F3E58 +wst4 9967837EFA0F41DC +wst5 9967837EFA0F4236 +wst6 9967837EFA0F423F +a6 2037-01-01 23:59:58.999999 +d0 2037-01-01 23:59:58 +d1 2037-01-01 23:59:58.9 +d2 2037-01-01 23:59:58.99 +d3 2037-01-01 23:59:58.999 +d4 2037-01-01 23:59:58.9999 +d5 2037-01-01 23:59:58.99999 +d6 2037-01-01 23:59:58.999999 +wst0 99DC837EFA000000 +wst1 99DC837EFA0DBBA0 +wst2 99DC837EFA0F1B30 +wst3 99DC837EFA0F3E58 +wst4 99DC837EFA0F41DC +wst5 99DC837EFA0F4236 +wst6 99DC837EFA0F423F +SELECT * FROM v1 WHERE a6 LIKE '%.000000' ORDER BY a6, d6;; +a6 1970-01-01 00:00:01.000000 +d0 1970-01-01 00:00:01 +d1 1970-01-01 00:00:01.0 +d2 1970-01-01 00:00:01.00 +d3 1970-01-01 00:00:01.000 +d4 1970-01-01 00:00:01.0000 +d5 1970-01-01 00:00:01.00000 +d6 1970-01-01 00:00:01.000000 +wst0 9902C20001000000 +wst1 9902C20001000000 +wst2 9902C20001000000 +wst3 9902C20001000000 +wst4 9902C20001000000 +wst5 9902C20001000000 +wst6 9902C20001000000 +a6 1970-01-01 00:00:02.000000 +d0 1970-01-01 00:00:02 +d1 1970-01-01 00:00:02.0 +d2 1970-01-01 00:00:02.00 +d3 1970-01-01 00:00:02.000 +d4 1970-01-01 00:00:02.0000 +d5 1970-01-01 00:00:02.00000 +d6 1970-01-01 00:00:02.000000 +wst0 9902C20002000000 +wst1 9902C20002000000 +wst2 9902C20002000000 +wst3 9902C20002000000 +wst4 9902C20002000000 +wst5 9902C20002000000 +wst6 9902C20002000000 +a6 2001-01-01 23:59:59.000000 +d0 2001-01-01 23:59:59 +d1 2001-01-01 23:59:59.0 +d2 2001-01-01 23:59:59.00 +d3 2001-01-01 23:59:59.000 +d4 2001-01-01 23:59:59.0000 +d5 2001-01-01 23:59:59.00000 +d6 2001-01-01 23:59:59.000000 +wst0 9967837EFB000000 +wst1 9967837EFB000000 +wst2 9967837EFB000000 +wst3 9967837EFB000000 +wst4 9967837EFB000000 +wst5 9967837EFB000000 +wst6 9967837EFB000000 +a6 2037-01-01 23:59:59.000000 +d0 2037-01-01 23:59:59 +d1 2037-01-01 23:59:59.0 +d2 2037-01-01 23:59:59.00 +d3 2037-01-01 23:59:59.000 +d4 2037-01-01 23:59:59.0000 +d5 2037-01-01 23:59:59.00000 +d6 2037-01-01 23:59:59.000000 +wst0 99DC837EFB000000 +wst1 99DC837EFB000000 +wst2 99DC837EFB000000 +wst3 99DC837EFB000000 +wst4 99DC837EFB000000 +wst5 99DC837EFB000000 +wst6 99DC837EFB000000 +SELECT * FROM v1 WHERE a6 LIKE '%.100000' ORDER BY a6, d6;; +a6 1970-01-01 00:00:01.100000 +d0 1970-01-01 00:00:01 +d1 1970-01-01 00:00:01.1 +d2 1970-01-01 00:00:01.10 +d3 1970-01-01 00:00:01.100 +d4 1970-01-01 00:00:01.1000 +d5 1970-01-01 00:00:01.10000 +d6 1970-01-01 00:00:01.100000 +wst0 9902C20001000000 +wst1 9902C200010186A0 +wst2 9902C200010186A0 +wst3 9902C200010186A0 +wst4 9902C200010186A0 +wst5 9902C200010186A0 +wst6 9902C200010186A0 +a6 1970-01-01 00:00:02.100000 +d0 1970-01-01 00:00:02 +d1 1970-01-01 00:00:02.1 +d2 1970-01-01 00:00:02.10 +d3 1970-01-01 00:00:02.100 +d4 1970-01-01 00:00:02.1000 +d5 1970-01-01 00:00:02.10000 +d6 1970-01-01 00:00:02.100000 +wst0 9902C20002000000 +wst1 9902C200020186A0 +wst2 9902C200020186A0 +wst3 9902C200020186A0 +wst4 9902C200020186A0 +wst5 9902C200020186A0 +wst6 9902C200020186A0 +a6 1970-01-01 00:01:00.100000 +d0 1970-01-01 00:01:00 +d1 1970-01-01 00:01:00.1 +d2 1970-01-01 00:01:00.10 +d3 1970-01-01 00:01:00.100 +d4 1970-01-01 00:01:00.1000 +d5 1970-01-01 00:01:00.10000 +d6 1970-01-01 00:01:00.100000 +wst0 9902C20040000000 +wst1 9902C200400186A0 +wst2 9902C200400186A0 +wst3 9902C200400186A0 +wst4 9902C200400186A0 +wst5 9902C200400186A0 +wst6 9902C200400186A0 +a6 1970-01-01 01:00:00.100000 +d0 1970-01-01 01:00:00 +d1 1970-01-01 01:00:00.1 +d2 1970-01-01 01:00:00.10 +d3 1970-01-01 01:00:00.100 +d4 1970-01-01 01:00:00.1000 +d5 1970-01-01 01:00:00.10000 +d6 1970-01-01 01:00:00.100000 +wst0 9902C21000000000 +wst1 9902C210000186A0 +wst2 9902C210000186A0 +wst3 9902C210000186A0 +wst4 9902C210000186A0 +wst5 9902C210000186A0 +wst6 9902C210000186A0 +a6 2001-01-01 23:59:58.100000 +d0 2001-01-01 23:59:58 +d1 2001-01-01 23:59:58.1 +d2 2001-01-01 23:59:58.10 +d3 2001-01-01 23:59:58.100 +d4 2001-01-01 23:59:58.1000 +d5 2001-01-01 23:59:58.10000 +d6 2001-01-01 23:59:58.100000 +wst0 9967837EFA000000 +wst1 9967837EFA0186A0 +wst2 9967837EFA0186A0 +wst3 9967837EFA0186A0 +wst4 9967837EFA0186A0 +wst5 9967837EFA0186A0 +wst6 9967837EFA0186A0 +a6 2037-01-01 23:59:58.100000 +d0 2037-01-01 23:59:58 +d1 2037-01-01 23:59:58.1 +d2 2037-01-01 23:59:58.10 +d3 2037-01-01 23:59:58.100 +d4 2037-01-01 23:59:58.1000 +d5 2037-01-01 23:59:58.10000 +d6 2037-01-01 23:59:58.100000 +wst0 99DC837EFA000000 +wst1 99DC837EFA0186A0 +wst2 99DC837EFA0186A0 +wst3 99DC837EFA0186A0 +wst4 99DC837EFA0186A0 +wst5 99DC837EFA0186A0 +wst6 99DC837EFA0186A0 +DROP VIEW v1; +DROP TABLE t1; +SET time_zone=default; +# +# Testing bad FSPs +# +CREATE TABLE t1 (a TIMESTAMP(-1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1 +CREATE TABLE t1 (a TIMESTAMP(7)); +ERROR 42000: Too-big precision 7 specified for 'a'. Maximum is 6. +CREATE TABLE t1 (a TIMESTAMP(31)); +ERROR 42000: Too-big precision 31 specified for 'a'. Maximum is 6. +# +# Testing rounding when altering TIMESTAMP(N) to a smaller size +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999999'); +ALTER TABLE t1 MODIFY a TIMESTAMP(5); +SELECT * FROM t1; +a +2001-01-01 10:10:11.00000 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:10:10.999999'); +ALTER TABLE t1 MODIFY a TIME; +SELECT * FROM t1; +a +10:10:11 +DROP TABLE t1; +# +# Testing rounding from VARCHAR and DATETIME(6) to TIMESTAMP(N) +# +CREATE TABLE t1 (a VARCHAR(32), +t6 TIMESTAMP(6) NULL DEFAULT NULL, +t5 TIMESTAMP(5) NULL DEFAULT NULL, +t4 TIMESTAMP(4) NULL DEFAULT NULL, +t3 TIMESTAMP(3) NULL DEFAULT NULL, +t2 TIMESTAMP(2) NULL DEFAULT NULL, +t1 TIMESTAMP(1) NULL DEFAULT NULL, +t0 TIMESTAMP NULL DEFAULT NULL); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999994'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999949'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.999499'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.994999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.949999'); +INSERT INTO t1 (a) VALUES ('2001-01-01 10:10:10.499999'); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 2001-01-01 10:10:10.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +ALTER TABLE t1 MODIFY a TIMESTAMP(6); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 2001-01-01 10:10:10.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 2001-01-01 10:10:10.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +DROP TABLE t1; +# +# Testing rounding from TIMESTAMP(N) to BIGINT +# +CREATE TABLE t1 (a BIGINT, b TIMESTAMP(6) NULL DEFAULT NULL); +INSERT INTO t1 (b) VALUES ('2001-01-01 10:10:59.500000'); +INSERT INTO t1 (b) VALUES ('2001-01-01 10:10:10.500000'); +INSERT INTO t1 (b) VALUES ('2001-01-01 10:10:10.499999'); +UPDATE t1 SET a=b; +SELECT * FROM t1; +a b +20010101101100 2001-01-01 10:10:59.500000 +20010101101011 2001-01-01 10:10:10.500000 +20010101101010 2001-01-01 10:10:10.499999 +DROP TABLE t1; +# +# Testing rounding from TIME(6) to TIMESTAMP(N) +# +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +CREATE TABLE t1 (a TIME(6), +t6 TIMESTAMP(6), t5 TIMESTAMP(5), t4 TIMESTAMP(4), +t3 TIMESTAMP(3), t2 TIMESTAMP(2), t1 TIMESTAMP(1), +t0 TIMESTAMP); +INSERT INTO t1 (a) VALUES ('10:10:10.999999'); +INSERT INTO t1 (a) VALUES ('10:10:10.999994'); +INSERT INTO t1 (a) VALUES ('10:10:10.999949'); +INSERT INTO t1 (a) VALUES ('10:10:10.999499'); +INSERT INTO t1 (a) VALUES ('10:10:10.994999'); +INSERT INTO t1 (a) VALUES ('10:10:10.949999'); +INSERT INTO t1 (a) VALUES ('10:10:10.499999'); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 10:10:10.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 10:10:10.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 10:10:10.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +DROP TABLE t1; +SET timestamp=default; +# +# Testing rounding from DECIMAL to TIMESTAMP(N) +# +CREATE TABLE t1 (a DECIMAL(30,6), +t6 TIMESTAMP(6), t5 TIMESTAMP(5), t4 TIMESTAMP(4), +t3 TIMESTAMP(3), t2 TIMESTAMP(2), t1 TIMESTAMP(1), +t0 TIMESTAMP); +INSERT INTO t1 (a) VALUES (20010101101010.999999); +INSERT INTO t1 (a) VALUES (20010101101010.999994); +INSERT INTO t1 (a) VALUES (20010101101010.999949); +INSERT INTO t1 (a) VALUES (20010101101010.999499); +INSERT INTO t1 (a) VALUES (20010101101010.994999); +INSERT INTO t1 (a) VALUES (20010101101010.949999); +INSERT INTO t1 (a) VALUES (20010101101010.499999); +UPDATE t1 SET t0=a, t1=a, t2=a, t3=a, t4=a, t5=a, t6=a; +SELECT * FROM t1;; +a 20010101101010.999999 +t6 2001-01-01 10:10:10.999999 +t5 2001-01-01 10:10:11.00000 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.999994 +t6 2001-01-01 10:10:10.999994 +t5 2001-01-01 10:10:10.99999 +t4 2001-01-01 10:10:11.0000 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.999949 +t6 2001-01-01 10:10:10.999949 +t5 2001-01-01 10:10:10.99995 +t4 2001-01-01 10:10:10.9999 +t3 2001-01-01 10:10:11.000 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.999499 +t6 2001-01-01 10:10:10.999499 +t5 2001-01-01 10:10:10.99950 +t4 2001-01-01 10:10:10.9995 +t3 2001-01-01 10:10:10.999 +t2 2001-01-01 10:10:11.00 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.994999 +t6 2001-01-01 10:10:10.994999 +t5 2001-01-01 10:10:10.99500 +t4 2001-01-01 10:10:10.9950 +t3 2001-01-01 10:10:10.995 +t2 2001-01-01 10:10:10.99 +t1 2001-01-01 10:10:11.0 +t0 2001-01-01 10:10:11 +a 20010101101010.949999 +t6 2001-01-01 10:10:10.949999 +t5 2001-01-01 10:10:10.95000 +t4 2001-01-01 10:10:10.9500 +t3 2001-01-01 10:10:10.950 +t2 2001-01-01 10:10:10.95 +t1 2001-01-01 10:10:10.9 +t0 2001-01-01 10:10:11 +a 20010101101010.499999 +t6 2001-01-01 10:10:10.499999 +t5 2001-01-01 10:10:10.50000 +t4 2001-01-01 10:10:10.5000 +t3 2001-01-01 10:10:10.500 +t2 2001-01-01 10:10:10.50 +t1 2001-01-01 10:10:10.5 +t0 2001-01-01 10:10:10 +DROP TABLE t1; +# +# Testing INSERT, ORDER, KEY, BETWEEN, comparison +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('0000-00-00 23:59:59.999999'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('2000-01-01 01:02:03'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.4'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.45'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.456'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.4567'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.45678'); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03.4567891'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:59.000000'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +0000-00-00 00:00:00.000000 +SELECT * FROM t1 ORDER BY a DESC; +a +2000-01-01 01:02:03.456789 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.45'; +a +2000-01-01 01:02:03.450000 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.4567'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.45670'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.456700'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a BETWEEN '2000-01-01 01:02:00' AND '2000-01-01 01:03:00'; +a +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1 ORDER BY a; +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +SELECT * FROM t1 ORDER BY a DESC; +a +2000-01-01 01:02:03.456789 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.456700'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 7 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = TIMESTAMP'2000-01-01 01:02:03.4567') +SELECT * FROM t1 WHERE a='2000-01-01 01:02:03.456700'; +a +2000-01-01 01:02:03.456700 +SELECT * FROM t1 WHERE a BETWEEN '2000-01-01 01:02:00' AND '2000-01-01 01:03:00'; +a +2000-01-01 01:02:03.000000 +2000-01-01 01:02:03.400000 +2000-01-01 01:02:03.450000 +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +2000-01-01 01:02:03.456789 +SELECT * FROM t1 WHERE a BETWEEN TIMESTAMP'2000-01-01 01:02:03.456' AND '2000-01-01 01:02:03.45678'; +a +2000-01-01 01:02:03.456000 +2000-01-01 01:02:03.456700 +2000-01-01 01:02:03.456780 +DROP TABLE t1; +# +# Testing range: stored_field_cmp_to_item +# +CREATE TABLE t1 (a datetime(6), key(a)); +INSERT INTO t1 VALUES +('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), +('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); +SELECT * FROM t1 WHERE a >= 20000101000000; +a +2000-01-01 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 00:00:01.000000 +2000-01-01 00:00:01.000000 +SELECT * FROM t1 WHERE a >= 20000101000000.0; +a +2000-01-01 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 00:00:01.000000 +2000-01-01 00:00:01.000000 +UPDATE t1 SET a=ADDTIME(a, 0.000001); +SELECT * FROM t1; +a +2000-01-01 00:00:00.000001 +2000-01-01 00:00:00.000001 +2000-01-01 00:00:01.000001 +2000-01-01 00:00:01.000001 +SELECT * FROM t1 WHERE a >= 20000101000000.000001; +a +2000-01-01 00:00:00.000001 +2000-01-01 00:00:00.000001 +2000-01-01 00:00:01.000001 +2000-01-01 00:00:01.000001 +DROP TABLE t1; +# +# Rare TIMESTAMP formats +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES (101.101); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (990101.102); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('990101.103'); +INSERT INTO t1 VALUES (131.104); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('000131.105'); +SELECT * FROM t1; +a +2000-01-01 00:00:00.000000 +1999-01-01 00:00:00.000000 +1999-01-01 10:03:00.000000 +2000-01-31 00:00:00.000000 +2000-01-31 10:05:00.000000 +DROP TABLE t1; +# +# Testing bad values +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('xxxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-01-01 00:00:00.123456 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-01-01 00:00:00 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1999-01-01 xxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.123'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (0.123); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (0.123e0); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (CAST('0000-00-00 00:00:00.123' AS DATETIME(6))); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +1999-01-01 00:00:00.123456 +1999-01-01 00:00:00.000000 +1999-01-01 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing huge values +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ( 100000000000000000.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ( 100000000000000000.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-100000000000000000.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-100000000000000000.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS SIGNED)); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFF00000000 AS UNSIGNED)); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing implicit CAST from TIME to TIMESTAMP +# +SET time_zone='+00:00'; +SET @@timestamp=UNIX_TIMESTAMP('2008-01-03 10:20:30.1'); +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES (CURRENT_TIME), (CURRENT_TIME(6)); +INSERT INTO t1 VALUES (TIME'08:00:00.123456'), (TIME'240:00:00.000001'); +INSERT INTO t1 VALUES (TIME'-10:00:00.000001'), (TIME'-240:00:00.000001'); +SELECT CURRENT_DATE, CURRENT_TIME(6); +CURRENT_DATE CURRENT_TIME(6) +2008-01-03 10:20:30.100000 +SELECT a, HEX(WEIGHT_STRING(a)) FROM t1; +a HEX(WEIGHT_STRING(a)) +2008-01-03 10:20:30.000000 997E46A51E000000 +2008-01-03 10:20:30.100000 997E46A51E0186A0 +2008-01-03 08:00:00.123456 997E46800001E240 +2008-01-13 00:00:00.000001 997E5A0000000001 +2008-01-02 13:59:59.999999 997E44DEFB0F423F +2007-12-23 23:59:59.999999 997DEF7EFB0F423F +DELETE FROM t1; +SET time_zone='-12:00'; +INSERT INTO t1 VALUES (CURRENT_TIME), (CURRENT_TIME(6)); +INSERT INTO t1 VALUES (TIME'08:00:00.123456'), (TIME'240:00:00.000001'); +INSERT INTO t1 VALUES (TIME'-10:00:00.000001'), (TIME'-240:00:00.000001'); +SELECT CURRENT_DATE, CURRENT_TIME(6); +CURRENT_DATE CURRENT_TIME(6) +2008-01-02 22:20:30.100000 +SELECT a, HEX(WEIGHT_STRING(a)) FROM t1; +a HEX(WEIGHT_STRING(a)) +2008-01-02 22:20:30.000000 997E46A51E000000 +2008-01-02 22:20:30.100000 997E46A51E0186A0 +2008-01-02 08:00:00.123456 997E45400001E240 +2008-01-12 00:00:00.000001 997E58C000000001 +2008-01-01 13:59:59.999999 997E441EFB0F423F +2007-12-22 23:59:59.999999 997DEEBEFB0F423F +SET time_zone='+00:00'; +SELECT CURRENT_DATE, CURRENT_TIME(6); +CURRENT_DATE CURRENT_TIME(6) +2008-01-03 10:20:30.100000 +SELECT a, HEX(WEIGHT_STRING(a)) FROM t1; +a HEX(WEIGHT_STRING(a)) +2008-01-03 10:20:30.000000 997E46A51E000000 +2008-01-03 10:20:30.100000 997E46A51E0186A0 +2008-01-02 20:00:00.123456 997E45400001E240 +2008-01-12 12:00:00.000001 997E58C000000001 +2008-01-02 01:59:59.999999 997E441EFB0F423F +2007-12-23 11:59:59.999999 997DEEBEFB0F423F +DROP TABLE t1; +SET time_zone=default; +SET @@timestamp=default; +# +# Testing IN +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000001'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000002'); +INSERT INTO t1 VALUES ('2000-01-01 10:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 10:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-01 10:00:00.000002'); +INSERT INTO t1 VALUES ('2000-01-01 23:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 23:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-01 23:00:00.000002'); +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 00:00:00.000001 +2000-01-01 00:00:00.000002 +2000-01-01 10:00:00.000000 +2000-01-01 10:00:00.000001 +2000-01-01 10:00:00.000002 +2000-01-01 23:00:00.000000 +2000-01-01 23:00:00.000001 +2000-01-01 23:00:00.000002 +SELECT * FROM t1 WHERE a IN ('2000-01-01 00:00:00', '0000-00-00 00:00:00.000001', '2000-01-01 23:00:00.000002'); +a +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000002 +SELECT * FROM t1 WHERE a IN (0, 20000101000000, 20000101230000); +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000000 +SELECT * FROM t1 WHERE a=0.1; +a +Warnings: +Warning 1292 Incorrect datetime value: '0.1' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.1' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.1' for column 'a' at row 1 +SELECT * FROM t1 WHERE a IN (0.1); +a +Warnings: +Warning 1292 Incorrect datetime value: '0.1' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.1' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.1' for column 'a' at row 1 +SELECT * FROM t1 WHERE a IN (20000101000000.000001, 20000101230000.000001); +a +2000-01-01 00:00:00.000001 +2000-01-01 23:00:00.000001 +SELECT * FROM t1 WHERE +a IN (0.000001, 20000101000000.000001, 20000101230000.000001); +a +Warnings: +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +SELECT * FROM t1 WHERE a IN (0e0, 0.000001e0); +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +Warnings: +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +# +# Testing IN with index: involves field->store_packed() +# +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1 WHERE a IN ('2000-01-01 00:00:00', '0000-00-00 00:00:00.000001', '2000-01-01 23:00:00.000002'); +a +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000002 +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00.000001' for column 'a' at row 1 +SELECT * FROM t1 WHERE a IN (0, 20000101000000, 20000101230000); +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +2000-01-01 00:00:00.000000 +2000-01-01 23:00:00.000000 +SELECT * FROM t1 WHERE a IN (0.000001, 20000101000000.000001, 20000101230000.000001); +a +Warnings: +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +SELECT * FROM t1 WHERE a IN (20000101000000.000001, 20000101230000.000001); +a +2000-01-01 00:00:00.000001 +2000-01-01 23:00:00.000001 +SELECT * FROM t1 WHERE a IN (0e0, 0.000001e0); +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +Warnings: +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +Warning 1292 Incorrect datetime value: '0.000001' for column 'a' at row 1 +DROP TABLE t1; +# +# Testing CREATE TABLE LIKE +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +CREATE TABLE t2 LIKE t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +# +# Testing CREATE TABLE .. SELECT +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +CREATE TABLE t2 AS SELECT * FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +# +# Testing JOIN between TIMESTAMP(6) and TIMESTAMP(6) +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.1'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.12'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.123'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.1234'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.12345'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:03.123456'); +CREATE TABLE t2 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t2 SELECT * FROM t1; +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +ALTER TABLE t1 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +ALTER TABLE t2 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +ALTER TABLE t1 DROP KEY a; +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:01:03.100000 2000-01-01 00:01:03.100000 +2000-01-01 00:01:03.120000 2000-01-01 00:01:03.120000 +2000-01-01 00:01:03.123000 2000-01-01 00:01:03.123000 +2000-01-01 00:01:03.123400 2000-01-01 00:01:03.123400 +2000-01-01 00:01:03.123450 2000-01-01 00:01:03.123450 +2000-01-01 00:01:03.123456 2000-01-01 00:01:03.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing JOIN between TIMESTAMP and TIMESTAMP(6) +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('0000-00-00 23:59:59.000000'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('2000-01-01 10:11:12.000000'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:12.000001'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:12.000002'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:13.000000'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:13.000001'); +INSERT INTO t1 VALUES ('2000-01-01 10:11:13.000002'); +INSERT INTO t1 VALUES ('2000-01-01 23:59:59.999999'); +INSERT INTO t1 VALUES ('2000-01-01 23:59:59.000000'); +CREATE TABLE t2 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t2 VALUES ('2000-01-01 10:11:12'); +INSERT INTO t2 VALUES ('2000-01-01 10:11:13'); +INSERT INTO t2 VALUES ('0000-00-00 23:59:59'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t2 VALUES ('2000-01-01 23:59:59'); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +0000-00-00 00:00:00.000000 0000-00-00 00:00:00 +2000-01-01 10:11:12.000000 2000-01-01 10:11:12 +2000-01-01 10:11:13.000000 2000-01-01 10:11:13 +2000-01-01 23:59:59.000000 2000-01-01 23:59:59 +ALTER TABLE t1 ADD KEY(a); +ALTER TABLE t2 ADD KEY(a); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +0000-00-00 00:00:00.000000 0000-00-00 00:00:00 +2000-01-01 10:11:12.000000 2000-01-01 10:11:12 +2000-01-01 10:11:13.000000 2000-01-01 10:11:13 +2000-01-01 23:59:59.000000 2000-01-01 23:59:59 +DROP TABLE t2, t1; +# +# Testing unique index +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), UNIQUE(a)); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.1'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.12'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.123'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.1234'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.12345'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.12345'); +ERROR 23000: Duplicate entry '2000-01-01 00:01:02.123450' for key 't1.a' +DROP TABLE t1; +# +# Testing GROUP BY +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.0'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.01'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.010'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.02'); +INSERT INTO t1 VALUES ('2000-01-01 00:01:02.020'); +SELECT a, COUNT(*) FROM t1 GROUP BY a; +a COUNT(*) +2000-01-01 00:01:02.000000 2 +2000-01-01 00:01:02.010000 2 +2000-01-01 00:01:02.020000 2 +DROP TABLE t1; +# +# Testing MIN() and MAX() +# +CREATE TABLE t1 (a INT, b TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES (1, '2001-01-01 00:01:02.000001'); +INSERT INTO t1 VALUES (1, '2001-01-01 00:01:02'); +INSERT INTO t1 VALUES (2, '2001-01-01 10:01:02'); +INSERT INTO t1 VALUES (2, '2001-01-01 10:01:02.000001'); +INSERT INTO t1 VALUES (3, '2001-01-01 10:11:02'); +INSERT INTO t1 VALUES (3, '2001-01-01 10:11:02.000001'); +SELECT MIN(b), MAX(b) FROM t1; +MIN(b) MAX(b) +2001-01-01 00:01:02.000000 2001-01-01 10:11:02.000001 +SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a; +a MIN(b) MAX(b) +1 2001-01-01 00:01:02.000000 2001-01-01 00:01:02.000001 +2 2001-01-01 10:01:02.000000 2001-01-01 10:01:02.000001 +3 2001-01-01 10:11:02.000000 2001-01-01 10:11:02.000001 +DROP TABLE t1; +# +# Testing LEAST +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.1'); +SELECT LEAST(a, '2001-01-02 00:00:00.1') AS a FROM t1; +a +2001-01-01 00:00:00.100000 +SELECT LEAST(a, '2001-01-02 00:00:00.1') + 0 AS a FROM t1; +a +20010101000000.100000 +SELECT CAST(LEAST(a, '2001-01-02 00:00:00.1') AS SIGNED) AS a FROM t1; +a +20010101000000 +SELECT CAST(LEAST(a, '2001-01-02 00:00:00.1') AS DECIMAL(30,6)) AS a FROM t1; +a +20010101000000.100000 +SELECT GREATEST(a, '2001-01-02 00:00:00.1') AS a FROM t1; +a +2001-01-02 00:00:00.100000 +SELECT GREATEST(a, '2001-01-02 00:00:00.1') + 0 AS a FROM t1; +a +20010102000000.100000 +SELECT CAST(GREATEST(a, '2001-01-02 00:00:00.1') AS SIGNED) AS a FROM t1; +a +20010102000000 +SELECT CAST(GREATEST(a, '2001-01-02 00:00:00.1') AS DECIMAL(30,6)) AS a FROM t1; +a +20010102000000.100000 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(1) NOT NULL DEFAULT CURRENT_TIMESTAMP(1) ON UPDATE CURRENT_TIMESTAMP(1), b TIMESTAMP(2) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'); +CREATE TABLE t2 AS SELECT LEAST(a, b), GREATEST(a, b) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `LEAST(a, b)` timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `GREATEST(a, b)` timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing INSERT, MAX and MIN values +# '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC +# +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2038-01-19 03:14:07'); +INSERT INTO t1 VALUES ('2038-01-19 03:14:07.999999'); +INSERT INTO t1 VALUES ('2038-01-19 03:14:08'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.999999'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:01'); +SELECT * FROM t1; +a +2038-01-19 03:14:07.000000 +2038-01-19 03:14:07.999999 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +1970-01-01 00:00:01.000000 +DROP TABLE t1; +# +# Testing bad values +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.1'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('0000-00-00 00:00:01.1'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (0.1); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (1.1); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (0.1e0); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (1.1e0); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (-0.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-0.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.0e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-1.1e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing integer INSERT value +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES (19990102); +INSERT INTO t1 VALUES (19990102112233); +INSERT INTO t1 VALUES (100000101112233); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (-1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +1999-01-02 00:00:00.000000 +1999-01-02 11:22:33.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing decimal INSERT values +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES (20010101223344.4); +INSERT INTO t1 VALUES (20010101223344.45); +INSERT INTO t1 VALUES (20010101223344.456); +INSERT INTO t1 VALUES (20010101223344.4567); +INSERT INTO t1 VALUES (20010101223344.45678); +INSERT INTO t1 VALUES (20010101223344.456789); +INSERT INTO t1 VALUES (20010101202030.4567894); +INSERT INTO t1 VALUES (20010101202030.4567895); +INSERT INTO t1 VALUES (20010101202030.4567896); +INSERT INTO t1 VALUES (20010101202030.456789678); +INSERT INTO t1 VALUES (200101018385959.000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (-200101018385959.000000); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +2001-01-01 22:33:44.400000 +2001-01-01 22:33:44.450000 +2001-01-01 22:33:44.456000 +2001-01-01 22:33:44.456700 +2001-01-01 22:33:44.456780 +2001-01-01 22:33:44.456789 +2001-01-01 20:20:30.456789 +2001-01-01 20:20:30.456790 +2001-01-01 20:20:30.456790 +2001-01-01 20:20:30.456790 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing double INSERT values +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES (112.233e-3); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.223e-2); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e-1); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e0); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e1); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e2); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e3); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (112.233e4); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES (-123.456e0); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +2000-01-12 00:00:00.000000 +2000-11-22 00:00:00.000000 +2001-12-23 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +0000-00-00 00:00:00.000000 +DROP TABLE t1; +# +# Testing UPDATE between TIMESTAMP(6) and TIMESTAMP/BIGINT/DECIMAL/DOUBLE +# +CREATE TABLE t1 (t0 TIMESTAMP, t6 TIMESTAMP(6), i BIGINT, d DECIMAL(20,6), f DOUBLE); +INSERT INTO t1 (t0) VALUES ('2000-01-01 11:22:33'); +UPDATE t1 SET t6=t0, i=t0, d=t0, f=t0; +SELECT t6, i, d FROM t1; +t6 i d +2000-01-01 11:22:33.000000 20000101112233 20000101112233.000000 +UPDATE t1 SET t6='2001-02-02 11:22:33.1'; +UPDATE t1 SET t0=t6, i=t6, d=t6, f=t6; +SELECT * FROM t1; +t0 t6 i d f +2001-02-02 11:22:33 2001-02-02 11:22:33.100000 20010202112233 20010202112233.100000 20010202112233.1 +UPDATE t1 SET i=20000101112233, d=20001010112233.1, f=00001010112233.1; +UPDATE t1 SET t6=i; +SELECT t6 FROM t1; +t6 +2000-01-01 11:22:33.000000 +UPDATE t1 SET t6=d; +SELECT t6 FROM t1; +t6 +2000-10-10 11:22:33.100000 +UPDATE t1 SET t6=f; +SELECT t6 FROM t1; +t6 +2000-10-10 11:22:33.100000 +DROP TABLE t1; +# +# Testing JOIN with comparison between TIMESTAMP(6) and DATE +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2000-01-02 00:00:00.000000'); +CREATE TABLE t2 (a DATE); +INSERT INTO t2 VALUES ('2000-01-01'); +INSERT INTO t2 VALUES ('2000-01-02'); +SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t1.a, t2.a; +a a +2000-01-01 00:00:00.000000 2000-01-01 +2000-01-02 00:00:00.000000 2000-01-02 +ALTER TABLE t2 MODIFY a TIMESTAMP(6); +SELECT * FROM t1, t2 WHERE t1.a=CAST(t2.a AS DATE) ORDER BY t1.a, t2.a; +a a +2000-01-01 00:00:00.000000 2000-01-01 00:00:00.000000 +2000-01-02 00:00:00.000000 2000-01-02 00:00:00.000000 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing JOIN with comparison between TIMESTAMP(6) and BIGINT +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33.123'); +CREATE TABLE t2 (b BIGINT); +INSERT INTO t2 VALUES (20000101); +INSERT INTO t2 VALUES (20000101112233); +SELECT * FROM t1, t2 WHERE a=b; +a b +2000-01-01 11:22:33.000000 20000101112233 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIMESTAMP(6) and DECIMAL(20,6) +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456'); +CREATE TABLE t2 (b DECIMAL(20,6)); +INSERT INTO t2 VALUES (20010101112233); +INSERT INTO t2 VALUES (20010101112233.123); +INSERT INTO t2 VALUES (20010101112233.123456); +SELECT * FROM t1, t2 WHERE a=b; +a b +2001-01-01 11:22:33.000000 20010101112233.000000 +2001-01-01 11:22:33.123000 20010101112233.123000 +2001-01-01 11:22:33.123456 20010101112233.123456 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIMESTAMP(6) and DECIMAL(20,3) +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456'); +CREATE TABLE t2 (b DECIMAL(20,3)); +INSERT INTO t2 VALUES (20010101112233); +INSERT INTO t2 VALUES (20010101112233.123); +SELECT * FROM t1, t2 WHERE a=b; +a b +2001-01-01 11:22:33.000000 20010101112233.000 +2001-01-01 11:22:33.123000 20010101112233.123 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIMESTAMP(6) and DOUBLE +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33.1'); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33.12'); +CREATE TABLE t2 (b DOUBLE); +INSERT INTO t2 VALUES (20000101112233); +INSERT INTO t2 VALUES (20000101112233.1); +INSERT INTO t2 VALUES (20000101112233.12); +SELECT * FROM t2; +b +20000101112233 +20000101112233.1 +20000101112233.12 +SELECT * FROM t1, t2 WHERE a=b; +a b +2000-01-01 11:22:33.000000 20000101112233 +2000-01-01 11:22:33.100000 20000101112233.1 +2000-01-01 11:22:33.120000 20000101112233.12 +DROP TABLE t1, t2; +# +# Testing JOIN with comparison between TIMESTAMP(6) and VARCHAR +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +CREATE TABLE t2 (b VARCHAR(64)); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.123'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.1230'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.12300'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.123000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.0'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.00'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.0000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.00000'); +INSERT INTO t2 VALUES ('2001-01-01 11:22:33.000000'); +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +ALTER TABLE t1 ADD KEY (a); +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +ALTER TABLE t2 ADD KEY (b); +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +ALTER TABLE t1 DROP KEY a; +SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b; +a b +2001-01-01 11:22:33.000000 2001-01-01 11:22:33 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33. +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.0000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.00000 +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.000000 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.1230 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.12300 +2001-01-01 11:22:33.123000 2001-01-01 11:22:33.123000 +DROP TABLE t1, t2; +# +# Testing arithmetic with INT, DECIMAL, FLOAT +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000001'); +SELECT a, a + 0, a + 1, a + 1.0, a + 1e0 FROM t1; +a a + 0 a + 1 a + 1.0 a + 1e0 +2001-01-01 00:00:00.000000 20010101000000.000000 20010101000001.000000 20010101000001.000000 20010101000001 +2001-01-01 00:00:00.000001 20010101000000.000001 20010101000001.000001 20010101000001.000001 20010101000001 +CREATE TABLE t2 AS SELECT a + 1 AS i, a + 1.0 AS d, a + 1e0 AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `i` decimal(21,6) NOT NULL DEFAULT '0.000000', + `d` decimal(21,6) NOT NULL DEFAULT '0.000000', + `f` double NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1, t2; +# +# Testing that TIMESTAMP behaves as INT/DECIMAL for numeric arithmetic +# +CREATE TABLE t1 (t0 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, t3 TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00', t6 TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t2 AS SELECT +t0 + 1, t3 + 1, t6 + 1, +t0 - 1, t3 - 1, t6 - 1, +t0 * 1, t3 * 1, t6 * 1, +t0 / 1, t3 / 1, t6 / 1, +TIMESTAMP'2001-01-01 10:10:10' + 1, +TIMESTAMP'2001-01-01 10:10:10.123' + 1, +TIMESTAMP'2001-01-01 10:10:10.123456' + 1, +TIMESTAMP'2001-01-01 10:10:10' - 1, +TIMESTAMP'2001-01-01 10:10:10.123' - 1, +TIMESTAMP'2001-01-01 10:10:10.123456' - 1, +TIMESTAMP'2001-01-01 10:10:10' * 1, +TIMESTAMP'2001-01-01 10:10:10.123' * 1, +TIMESTAMP'2001-01-01 10:10:10.123456' * 1, +TIMESTAMP'2001-01-01 10:10:10' / 1, +TIMESTAMP'2001-01-01 10:10:10.123' / 1, +TIMESTAMP'2001-01-01 10:10:10.123456' / 1 +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t0 + 1` bigint NOT NULL DEFAULT '0', + `t3 + 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `t6 + 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `t0 - 1` bigint NOT NULL DEFAULT '0', + `t3 - 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `t6 - 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `t0 * 1` bigint NOT NULL DEFAULT '0', + `t3 * 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `t6 * 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `t0 / 1` decimal(18,4) DEFAULT NULL, + `t3 / 1` decimal(21,7) DEFAULT NULL, + `t6 / 1` decimal(24,10) DEFAULT NULL, + `TIMESTAMP'2001-01-01 10:10:10' + 1` bigint NOT NULL DEFAULT '0', + `TIMESTAMP'2001-01-01 10:10:10.123' + 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `TIMESTAMP'2001-01-01 10:10:10.123456' + 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `TIMESTAMP'2001-01-01 10:10:10' - 1` bigint NOT NULL DEFAULT '0', + `TIMESTAMP'2001-01-01 10:10:10.123' - 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `TIMESTAMP'2001-01-01 10:10:10.123456' - 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `TIMESTAMP'2001-01-01 10:10:10' * 1` bigint NOT NULL DEFAULT '0', + `TIMESTAMP'2001-01-01 10:10:10.123' * 1` decimal(18,3) NOT NULL DEFAULT '0.000', + `TIMESTAMP'2001-01-01 10:10:10.123456' * 1` decimal(21,6) NOT NULL DEFAULT '0.000000', + `TIMESTAMP'2001-01-01 10:10:10' / 1` decimal(18,4) DEFAULT NULL, + `TIMESTAMP'2001-01-01 10:10:10.123' / 1` decimal(21,7) DEFAULT NULL, + `TIMESTAMP'2001-01-01 10:10:10.123456' / 1` decimal(24,10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing that TIMESTAMP behaves as DECIMAL for SUM() and AVG() +# +SET @t='2010-01-01 00:11:12.123456'; +CREATE TABLE t1 (t0 DATETIME, t3 DATETIME(3), t6 DATETIME(6)); +INSERT INTO t1 VALUES (@t, @t, @t); +SELECT MIN(t0), MAX(t0), AVG(t0), SUM(t0) FROM t1; +MIN(t0) 2010-01-01 00:11:12 +MAX(t0) 2010-01-01 00:11:12 +AVG(t0) 20100101001112.0000 +SUM(t0) 20100101001112 +SELECT MIN(t3), MAX(t3), AVG(t3), SUM(t3) FROM t1; +MIN(t3) 2010-01-01 00:11:12.123 +MAX(t3) 2010-01-01 00:11:12.123 +AVG(t3) 20100101001112.1230000 +SUM(t3) 20100101001112.123 +SELECT MIN(t6), MAX(t6), AVG(t6), SUM(t6) FROM t1; +MIN(t6) 2010-01-01 00:11:12.123456 +MAX(t6) 2010-01-01 00:11:12.123456 +AVG(t6) 20100101001112.1234560000 +SUM(t6) 20100101001112.123456 +SET @t='2010-01-01 00:11:12.000000'; +INSERT INTO t1 VALUES (@t, @t, @t); +SELECT MIN(t0), MAX(t0), AVG(t0), SUM(t0) FROM t1; +MIN(t0) 2010-01-01 00:11:12 +MAX(t0) 2010-01-01 00:11:12 +AVG(t0) 20100101001112.0000 +SUM(t0) 40200202002224 +SELECT MIN(t3), MAX(t3), AVG(t3), SUM(t3) FROM t1; +MIN(t3) 2010-01-01 00:11:12.000 +MAX(t3) 2010-01-01 00:11:12.123 +AVG(t3) 20100101001112.0615000 +SUM(t3) 40200202002224.123 +SELECT MIN(t6), MAX(t6), AVG(t6), SUM(t6) FROM t1; +MIN(t6) 2010-01-01 00:11:12.000000 +MAX(t6) 2010-01-01 00:11:12.123456 +AVG(t6) 20100101001112.0617280000 +SUM(t6) 40200202002224.123456 +CREATE TABLE t2 AS SELECT +MIN(t0), MAX(t0), AVG(t0), SUM(t0), +MIN(t3), MAX(t3), AVG(t3), SUM(t3), +MIN(t6), MAX(t6), AVG(t6), SUM(t6) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MIN(t0)` datetime DEFAULT NULL, + `MAX(t0)` datetime DEFAULT NULL, + `AVG(t0)` decimal(18,4) DEFAULT NULL, + `SUM(t0)` decimal(36,0) DEFAULT NULL, + `MIN(t3)` datetime(3) DEFAULT NULL, + `MAX(t3)` datetime(3) DEFAULT NULL, + `AVG(t3)` decimal(21,7) DEFAULT NULL, + `SUM(t3)` decimal(39,3) DEFAULT NULL, + `MIN(t6)` datetime(6) DEFAULT NULL, + `MAX(t6)` datetime(6) DEFAULT NULL, + `AVG(t6)` decimal(24,10) DEFAULT NULL, + `SUM(t6)` decimal(42,6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing functions ADDTIME, SUBTIME, TIMESTAMP, TIMEDIFF, DATE_ADD/SUB +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('1970-01-01 01:00:01.000000'); +INSERT INTO t1 VALUES ('1970-01-01 01:00:01.000001'); +INSERT INTO t1 VALUES ('1971-01-01 01:00:00.000000'); +INSERT INTO t1 VALUES ('1971-01-01 01:00:00.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2001-01-01 01:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 01:00:00.000001'); +SELECT ADDTIME(a, '00:00:00.000001') FROM t1 ORDER BY a; +ADDTIME(a, '00:00:00.000001') +1970-01-01 01:00:01.000001 +1970-01-01 01:00:01.000002 +1971-01-01 01:00:00.000001 +1971-01-01 01:00:00.000002 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000002 +2001-01-01 01:00:00.000001 +2001-01-01 01:00:00.000002 +SELECT ADDTIME(a, '10:00:00.000001') FROM t1 ORDER BY a; +ADDTIME(a, '10:00:00.000001') +1970-01-01 11:00:01.000001 +1970-01-01 11:00:01.000002 +1971-01-01 11:00:00.000001 +1971-01-01 11:00:00.000002 +2001-01-01 10:00:00.000001 +2001-01-01 10:00:00.000002 +2001-01-01 11:00:00.000001 +2001-01-01 11:00:00.000002 +SELECT ADDTIME(CAST(a AS DATETIME(0)), 100000) FROM t1 ORDER BY a; +ADDTIME(CAST(a AS DATETIME(0)), 100000) +1970-01-01 11:00:01 +1970-01-01 11:00:01 +1971-01-01 11:00:00 +1971-01-01 11:00:00 +2001-01-01 10:00:00 +2001-01-01 10:00:00 +2001-01-01 11:00:00 +2001-01-01 11:00:00 +SELECT ADDTIME(CAST(a AS DATETIME(0)), 100000.1) FROM t1 ORDER BY a; +ADDTIME(CAST(a AS DATETIME(0)), 100000.1) +1970-01-01 11:00:01.1 +1970-01-01 11:00:01.1 +1971-01-01 11:00:00.1 +1971-01-01 11:00:00.1 +2001-01-01 10:00:00.1 +2001-01-01 10:00:00.1 +2001-01-01 11:00:00.1 +2001-01-01 11:00:00.1 +SELECT a, ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(0))) FROM t1 ORDER BY a; +a ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(0))) +1970-01-01 01:00:01.000000 1970-01-01 11:00:01 +1970-01-01 01:00:01.000001 1970-01-01 11:00:01 +1971-01-01 01:00:00.000000 1971-01-01 11:00:00 +1971-01-01 01:00:00.000001 1971-01-01 11:00:00 +2001-01-01 00:00:00.000000 2001-01-01 10:00:00 +2001-01-01 00:00:00.000001 2001-01-01 10:00:00 +2001-01-01 01:00:00.000000 2001-01-01 11:00:00 +2001-01-01 01:00:00.000001 2001-01-01 11:00:00 +SELECT a, ADDTIME(CAST(a AS DATETIME(6)), CAST('10:00:00' AS TIME(0))) FROM t1 ORDER BY a; +a ADDTIME(CAST(a AS DATETIME(6)), CAST('10:00:00' AS TIME(0))) +1970-01-01 01:00:01.000000 1970-01-01 11:00:01.000000 +1970-01-01 01:00:01.000001 1970-01-01 11:00:01.000001 +1971-01-01 01:00:00.000000 1971-01-01 11:00:00.000000 +1971-01-01 01:00:00.000001 1971-01-01 11:00:00.000001 +2001-01-01 00:00:00.000000 2001-01-01 10:00:00.000000 +2001-01-01 00:00:00.000001 2001-01-01 10:00:00.000001 +2001-01-01 01:00:00.000000 2001-01-01 11:00:00.000000 +2001-01-01 01:00:00.000001 2001-01-01 11:00:00.000001 +SELECT a, ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(6))) FROM t1 ORDER BY a; +a ADDTIME(CAST(a AS DATETIME(0)), CAST('10:00:00' AS TIME(6))) +1970-01-01 01:00:01.000000 1970-01-01 11:00:01.000000 +1970-01-01 01:00:01.000001 1970-01-01 11:00:01.000000 +1971-01-01 01:00:00.000000 1971-01-01 11:00:00.000000 +1971-01-01 01:00:00.000001 1971-01-01 11:00:00.000000 +2001-01-01 00:00:00.000000 2001-01-01 10:00:00.000000 +2001-01-01 00:00:00.000001 2001-01-01 10:00:00.000000 +2001-01-01 01:00:00.000000 2001-01-01 11:00:00.000000 +2001-01-01 01:00:00.000001 2001-01-01 11:00:00.000000 +SELECT ADDTIME(a, a) FROM t1 ORDER BY a; +ADDTIME(a, a) +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +CREATE TABLE t2 AS SELECT +ADDTIME(a, '00:00:00.000001'), +ADDTIME(a, '10:00:00.000001'), +ADDTIME(CAST(a AS DATETIME(0)), 100000), +ADDTIME(CAST(a AS DATETIME(0)), 100000.1), +ADDTIME(a,a) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ADDTIME(a, '00:00:00.000001')` datetime(6) DEFAULT NULL, + `ADDTIME(a, '10:00:00.000001')` datetime(6) DEFAULT NULL, + `ADDTIME(CAST(a AS DATETIME(0)), 100000)` datetime DEFAULT NULL, + `ADDTIME(CAST(a AS DATETIME(0)), 100000.1)` datetime(1) DEFAULT NULL, + `ADDTIME(a,a)` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +SELECT TIMESTAMP(a, '10:00:00') FROM t1; +TIMESTAMP(a, '10:00:00') +1970-01-01 11:00:01.000000 +1970-01-01 11:00:01.000001 +1971-01-01 11:00:00.000000 +1971-01-01 11:00:00.000001 +2001-01-01 10:00:00.000000 +2001-01-01 10:00:00.000001 +2001-01-01 11:00:00.000000 +2001-01-01 11:00:00.000001 +SELECT TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0))) FROM t1; +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0))) +1970-01-01 01:00:01 +1970-01-01 01:00:01 +1971-01-01 01:00:00 +1971-01-01 01:00:00 +2001-01-01 00:00:00 +2001-01-01 00:00:00 +2001-01-01 01:00:00 +2001-01-01 01:00:00 +SELECT TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0))) FROM t1; +TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0))) +1970-01-01 01:00:01.000000 +1970-01-01 01:00:01.000001 +1971-01-01 01:00:00.000000 +1971-01-01 01:00:00.000001 +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000001 +2001-01-01 01:00:00.000000 +2001-01-01 01:00:00.000001 +SELECT TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6))) FROM t1; +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6))) +1970-01-01 01:00:01.000000 +1970-01-01 01:00:01.000000 +1971-01-01 01:00:00.000000 +1971-01-01 01:00:00.000000 +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000000 +2001-01-01 01:00:00.000000 +2001-01-01 01:00:00.000000 +CREATE TABLE t2 AS SELECT +TIMESTAMP(a, '10:00:00'), +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0))), +TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0))), +TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6))) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `TIMESTAMP(a, '10:00:00')` datetime(6) DEFAULT NULL, + `TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(0)))` datetime DEFAULT NULL, + `TIMESTAMP(CAST(a AS DATETIME(6)), CAST('00:00:00' AS TIME(0)))` datetime(6) DEFAULT NULL, + `TIMESTAMP(CAST(a AS DATETIME(0)), CAST('00:00:00' AS TIME(6)))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +SELECT SUBTIME(a, '00:00:00.000001') FROM t1 ORDER BY a; +SUBTIME(a, '00:00:00.000001') +1970-01-01 01:00:00.999999 +1970-01-01 01:00:01.000000 +1971-01-01 00:59:59.999999 +1971-01-01 01:00:00.000000 +2000-12-31 23:59:59.999999 +2001-01-01 00:00:00.000000 +2001-01-01 00:59:59.999999 +2001-01-01 01:00:00.000000 +SELECT SUBTIME(a, '10:00:00.000001') FROM t1 ORDER BY a; +SUBTIME(a, '10:00:00.000001') +1969-12-31 15:00:00.999999 +1969-12-31 15:00:01.000000 +1970-12-31 14:59:59.999999 +1970-12-31 15:00:00.000000 +2000-12-31 13:59:59.999999 +2000-12-31 14:00:00.000000 +2000-12-31 14:59:59.999999 +2000-12-31 15:00:00.000000 +SELECT SUBTIME(a, a) FROM t1 ORDER BY a; +SUBTIME(a, a) +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +CREATE TABLE t2 AS SELECT +SUBTIME(a, '00:00:00.000001'), +SUBTIME(a, '10:00:00.000001'), +SUBTIME(CAST(a AS DATETIME(0)), 100000), +SUBTIME(CAST(a AS DATETIME(0)), 100000.1), +SUBTIME(a,a) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `SUBTIME(a, '00:00:00.000001')` datetime(6) DEFAULT NULL, + `SUBTIME(a, '10:00:00.000001')` datetime(6) DEFAULT NULL, + `SUBTIME(CAST(a AS DATETIME(0)), 100000)` datetime DEFAULT NULL, + `SUBTIME(CAST(a AS DATETIME(0)), 100000.1)` datetime(1) DEFAULT NULL, + `SUBTIME(a,a)` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +SELECT DATE_ADD(a, INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_ADD(a, INTERVAL 1 MINUTE) +1970-01-01 01:01:01.000000 +1970-01-01 01:01:01.000001 +1971-01-01 01:01:00.000000 +1971-01-01 01:01:00.000001 +2001-01-01 00:01:00.000000 +2001-01-01 00:01:00.000001 +2001-01-01 01:01:00.000000 +2001-01-01 01:01:00.000001 +SELECT DATE_SUB(a, INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_SUB(a, INTERVAL 1 MINUTE) +1970-01-01 00:59:01.000000 +1970-01-01 00:59:01.000001 +1971-01-01 00:59:00.000000 +1971-01-01 00:59:00.000001 +2000-12-31 23:59:00.000000 +2000-12-31 23:59:00.000001 +2001-01-01 00:59:00.000000 +2001-01-01 00:59:00.000001 +SELECT DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MINUTE) +1970-01-01 01:01:01 +1970-01-01 01:01:01 +1971-01-01 01:01:00 +1971-01-01 01:01:00 +2001-01-01 00:01:00 +2001-01-01 00:01:00 +2001-01-01 01:01:00 +2001-01-01 01:01:00 +SELECT DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MINUTE) FROM t1 ORDER BY a; +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MINUTE) +1970-01-01 00:59:01 +1970-01-01 00:59:01 +1971-01-01 00:59:00 +1971-01-01 00:59:00 +2000-12-31 23:59:00 +2000-12-31 23:59:00 +2001-01-01 00:59:00 +2001-01-01 00:59:00 +SELECT DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) FROM t1 ORDER BY a; +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) +1970-01-01 01:00:01.000001 +1970-01-01 01:00:01.000001 +1971-01-01 01:00:00.000001 +1971-01-01 01:00:00.000001 +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000001 +2001-01-01 01:00:00.000001 +2001-01-01 01:00:00.000001 +SELECT DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) FROM t1 ORDER BY a; +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) +1970-01-01 01:00:00.999999 +1970-01-01 01:00:00.999999 +1971-01-01 00:59:59.999999 +1971-01-01 00:59:59.999999 +2000-12-31 23:59:59.999999 +2000-12-31 23:59:59.999999 +2001-01-01 00:59:59.999999 +2001-01-01 00:59:59.999999 +SELECT a, DATE_ADD(a, INTERVAL -0.1 SECOND) FROM t1 ORDER BY a; +a DATE_ADD(a, INTERVAL -0.1 SECOND) +1970-01-01 01:00:01.000000 1970-01-01 01:00:00.900000 +1970-01-01 01:00:01.000001 1970-01-01 01:00:00.900001 +1971-01-01 01:00:00.000000 1971-01-01 00:59:59.900000 +1971-01-01 01:00:00.000001 1971-01-01 00:59:59.900001 +2001-01-01 00:00:00.000000 2000-12-31 23:59:59.900000 +2001-01-01 00:00:00.000001 2000-12-31 23:59:59.900001 +2001-01-01 01:00:00.000000 2001-01-01 00:59:59.900000 +2001-01-01 01:00:00.000001 2001-01-01 00:59:59.900001 +SELECT a, DATE_SUB(a, INTERVAL -0.1 SECOND) FROM t1 ORDER BY a; +a DATE_SUB(a, INTERVAL -0.1 SECOND) +1970-01-01 01:00:01.000000 1970-01-01 01:00:01.100000 +1970-01-01 01:00:01.000001 1970-01-01 01:00:01.100001 +1971-01-01 01:00:00.000000 1971-01-01 01:00:00.100000 +1971-01-01 01:00:00.000001 1971-01-01 01:00:00.100001 +2001-01-01 00:00:00.000000 2001-01-01 00:00:00.100000 +2001-01-01 00:00:00.000001 2001-01-01 00:00:00.100001 +2001-01-01 01:00:00.000000 2001-01-01 01:00:00.100000 +2001-01-01 01:00:00.000001 2001-01-01 01:00:00.100001 +CREATE TABLE t2 AS SELECT +DATE_ADD(a, INTERVAL 1 SECOND), +DATE_SUB(a, INTERVAL 1 SECOND), +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 SECOND), +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 SECOND), +DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND), +DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `DATE_ADD(a, INTERVAL 1 SECOND)` datetime(6) DEFAULT NULL, + `DATE_SUB(a, INTERVAL 1 SECOND)` datetime(6) DEFAULT NULL, + `DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 SECOND)` datetime DEFAULT NULL, + `DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 SECOND)` datetime DEFAULT NULL, + `DATE_ADD(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND)` datetime(6) DEFAULT NULL, + `DATE_SUB(CAST(a AS DATETIME), INTERVAL 1 MICROSECOND)` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT MAX(DATE_ADD(a, INTERVAL 1 MINUTE)) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `MAX(DATE_ADD(a, INTERVAL 1 MINUTE))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2; +MAX(DATE_ADD(a, INTERVAL 1 MINUTE)) +2001-01-01 01:01:00.000001 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing explicit CAST of datetime hybrid functions to DATETIME +# +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +SELECT CAST(ADDTIME('20:10:10', 10) AS DATETIME); +CAST(ADDTIME('20:10:10', 10) AS DATETIME) +2001-01-01 20:10:20 +SELECT CAST(CAST('10:10:20' AS TIME) + INTERVAL 10 HOUR AS DATETIME); +CAST(CAST('10:10:20' AS TIME) + INTERVAL 10 HOUR AS DATETIME) +2001-01-01 20:10:20 +SELECT CAST(CAST('10:10:20' AS TIME(6)) + INTERVAL 10 HOUR AS DATETIME); +CAST(CAST('10:10:20' AS TIME(6)) + INTERVAL 10 HOUR AS DATETIME) +2001-01-01 20:10:20 +SELECT CAST(STR_TO_DATE('23:59:01','%H:%i:%s') AS DATETIME); +CAST(STR_TO_DATE('23:59:01','%H:%i:%s') AS DATETIME) +2001-01-01 23:59:01 +SELECT CAST(STR_TO_DATE('23:59:01.123','%H:%i:%s.%f') AS DATETIME(6)); +CAST(STR_TO_DATE('23:59:01.123','%H:%i:%s.%f') AS DATETIME(6)) +2001-01-01 23:59:01.123000 +SELECT CAST(ADDTIME('40:10:10', 10) as DATETIME); +CAST(ADDTIME('40:10:10', 10) as DATETIME) +2001-01-02 16:10:20 +SELECT CAST(CAST('10:10:20' AS TIME) + INTERVAL 30 HOUR AS DATETIME); +CAST(CAST('10:10:20' AS TIME) + INTERVAL 30 HOUR AS DATETIME) +2001-01-02 16:10:20 +SELECT CAST(CAST('10:10:20' AS TIME(6)) + INTERVAL 30 HOUR AS DATETIME); +CAST(CAST('10:10:20' AS TIME(6)) + INTERVAL 30 HOUR AS DATETIME) +2001-01-02 16:10:20 +SET @@timestamp=default; +# +# Testing copy from TIMESTAMP to TIMESTAMP(6) and vice versa +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), b TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 01:02:03.123456', '0000-00-00 00:00:00'); +UPDATE t1 SET b=a; +SELECT b FROM t1; +b +2001-01-01 01:02:03 +UPDATE t1 SET b='2002-02-02 10:11:12'; +UPDATE t1 SET a=b; +SELECT a FROM t1; +a +2002-02-02 10:11:12.000000 +DROP TABLE t1; +# +# Testing ALTER from TIMESTAMP(6) to TIMESTAMP and vice versa +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ('2000-01-01 01:02:03'); +ALTER TABLE t1 MODIFY a TIMESTAMP(6); +SELECT * FROM t1; +a +2000-01-01 01:02:03.000000 +UPDATE t1 SET a='2000-01-01 01:03:03.456'; +SELECT * FROM t1; +a +2000-01-01 01:03:03.456000 +ALTER TABLE t1 MODIFY a TIMESTAMP; +SELECT * FROM t1; +a +2000-01-01 01:03:03 +DROP TABLE t1; +# +# Testing ALTER between TIMESTAMP and BIGINT +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('2000-01-01 11:22:33', '2000-01-01 11:22:33'); +ALTER TABLE t1 MODIFY a BIGINT, MODIFY b BIGINT; +SELECT * FROM t1; +a b +20000101112233 20000101112233 +UPDATE t1 SET a=20000101112233, b=20000101112233; +ALTER TABLE t1 MODIFY a TIMESTAMP, MODIFY b TIMESTAMP(6); +SELECT * FROM t1; +a b +2000-01-01 11:22:33 2000-01-01 11:22:33.000000 +DROP TABLE t1; +# +# Testing ALTER between TIMESTAMP(6) and DOUBLE +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33', '2001-01-01 11:22:33.1234'); +ALTER TABLE t1 MODIFY a DOUBLE, MODIFY b DOUBLE; +SELECT * FROM t1; +a b +20010101112233 20010101112233.125 +UPDATE t1 SET a=20010101101112, b=20010101101112.1; +ALTER TABLE t1 MODIFY a TIMESTAMP, MODIFY b TIMESTAMP(6); +SELECT * FROM t1; +a b +2001-01-01 10:11:12 2001-01-01 10:11:12.100000 +DROP TABLE t1; +# +# Testing ALTER between TIMESTAMP(6) and DECIMAL +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33', '2001-01-01 11:22:33.1234'); +ALTER TABLE t1 MODIFY a DECIMAL(30,6), MODIFY b DECIMAL(30,6); +SELECT * FROM t1; +a b +20010101112233.000000 20010101112233.123400 +UPDATE t1 SET a=20010101112233, b=20010101112233.1234; +ALTER TABLE t1 MODIFY a TIMESTAMP, MODIFY b TIMESTAMP(6); +SELECT * FROM t1; +a b +2001-01-01 11:22:33 2001-01-01 11:22:33.123400 +DROP TABLE t1; +# +# Testing ALTER from TIMESTAMP to various other temporal types +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00', c TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +INSERT INTO t1 VALUES +('2001-01-01 10:10:10.1', '2001-01-01 10:10:10.1', '2001-01-01 10:10:10.1'); +ALTER TABLE t1 MODIFY a TIME(6), MODIFY b DATETIME(6), MODIFY c DATE; +Warnings: +Note 1265 Data truncated for column 'c' at row 1 +SELECT * FROM t1; +a b c +10:10:10.100000 2001-01-01 10:10:10.100000 2001-01-01 +DROP TABLE t1; +# +# Testing INT value and CAST of TIMESTAMP(6) to various other types +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123'); +SELECT CAST(a AS DATETIME) FROM t1; +CAST(a AS DATETIME) +2001-01-01 11:22:33 +SELECT CAST(a AS DATETIME(6)) FROM t1; +CAST(a AS DATETIME(6)) +2001-01-01 11:22:33.123000 +SELECT CAST(a AS TIME) FROM t1; +CAST(a AS TIME) +11:22:33 +SELECT CAST(a AS TIME(6)) FROM t1; +CAST(a AS TIME(6)) +11:22:33.123000 +SELECT a << 0 FROM t1; +a << 0 +20010101112233 +SELECT CAST(a AS SIGNED) FROM t1; +CAST(a AS SIGNED) +20010101112233 +SELECT CAST(a AS UNSIGNED) FROM t1; +CAST(a AS UNSIGNED) +20010101112233 +SELECT CAST(a AS DECIMAL(30,6)) FROM t1; +CAST(a AS DECIMAL(30,6)) +20010101112233.123000 +SELECT CAST(a AS DECIMAL(30,3)) FROM t1; +CAST(a AS DECIMAL(30,3)) +20010101112233.123 +SELECT CAST(a AS CHAR) FROM t1; +CAST(a AS CHAR) +2001-01-01 11:22:33.123000 +SELECT CAST(a AS CHAR(6)) FROM t1; +CAST(a AS CHAR(6)) +2001-0 +Warnings: +Warning 1292 Truncated incorrect CHAR(6) value: '2001-01-01 11:22:33.123000' +CREATE TABLE t2 AS SELECT CAST(a AS CHAR) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT a, LENGTH(a) FROM t2; +a LENGTH(a) +2001-01-01 11:22:33.123000 26 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing that default precision in "DEFAULT CURRENT_TIMESTAMP(N)" +# and "ON UPDATE CURRENT_TIMESTAMP(N)" is the same to the precision +# of the field itself. +# +CREATE TABLE t1 (a TIMESTAMP(1) NOT NULL DEFAULT CURRENT_TIMESTAMP(1) ON UPDATE CURRENT_TIMESTAMP(1)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(1) NOT NULL DEFAULT CURRENT_TIMESTAMP(1) ON UPDATE CURRENT_TIMESTAMP(1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(4) NOT NULL DEFAULT CURRENT_TIMESTAMP(4) ON UPDATE CURRENT_TIMESTAMP(4)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP(4) ON UPDATE CURRENT_TIMESTAMP(4) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(5) NOT NULL DEFAULT CURRENT_TIMESTAMP(5) ON UPDATE CURRENT_TIMESTAMP(5)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(5) NOT NULL DEFAULT CURRENT_TIMESTAMP(5) ON UPDATE CURRENT_TIMESTAMP(5) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing DEFAULT value +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT '2000-01-01 11:22:33.123456'); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(6) NOT NULL DEFAULT '2000-01-01 11:22:33.123456' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing DEFAULT CURRENT_TIMESTAMP +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(0)); +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(1)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(2)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(3)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(4)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(5)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP DEFAULT CURRENT_TIMESTAMP(6)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(0)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(1)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(2)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3)); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a timestamp(3) NO CURRENT_TIMESTAMP(3) DEFAULT_GENERATED +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(4)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(5)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(6)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(0)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(1)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(2)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(4)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(5)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a timestamp(6) NO CURRENT_TIMESTAMP(6) DEFAULT_GENERATED +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME DEFAULT CURRENT_TIMESTAMP(0)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME DEFAULT CURRENT_TIMESTAMP(1)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME DEFAULT CURRENT_TIMESTAMP(2)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME DEFAULT CURRENT_TIMESTAMP(3)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME DEFAULT CURRENT_TIMESTAMP(4)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME DEFAULT CURRENT_TIMESTAMP(5)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME DEFAULT CURRENT_TIMESTAMP(6)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP(0)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP(1)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP(2)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3)); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a datetime(3) YES CURRENT_TIMESTAMP(3) DEFAULT_GENERATED +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP(4)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP(5)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(3) DEFAULT CURRENT_TIMESTAMP(6)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(6) DEFAULT CURRENT_TIMESTAMP); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(6) DEFAULT CURRENT_TIMESTAMP(0)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(6) DEFAULT CURRENT_TIMESTAMP(1)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(6) DEFAULT CURRENT_TIMESTAMP(2)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(6) DEFAULT CURRENT_TIMESTAMP(4)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(6) DEFAULT CURRENT_TIMESTAMP(5)); +ERROR 42000: Invalid default value for 'a' +CREATE TABLE t1 (a DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a datetime(6) YES CURRENT_TIMESTAMP(6) DEFAULT_GENERATED +DROP TABLE t1; +# +# Testing that DEFAULT CURRENT_TIMESTAMP(n) truncates rather than rounds +# +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00.999999'); +CREATE TABLE t1 ( +a TIMESTAMP(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2), +b DATETIME(2) DEFAULT CURRENT_TIMESTAMP(2) +); +INSERT INTO t1 VALUES (DEFAULT, DEFAULT); +INSERT INTO t1 VALUES (); +SELECT CURRENT_TIMESTAMP(6); +CURRENT_TIMESTAMP(6) +2001-01-01 00:00:00.999999 +SELECT * FROM t1; +a b +2001-01-01 00:00:00.99 2001-01-01 00:00:00.99 +2001-01-01 00:00:00.99 2001-01-01 00:00:00.99 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing ON UPDATE CURRENT_TIMESTAMP +# +CREATE TABLE t1 (a TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(0)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(1)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(2)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(4)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(5)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' ON UPDATE CURRENT_TIMESTAMP(6)); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a timestamp(6) NO 0000-00-00 00:00:00.000000 on update CURRENT_TIMESTAMP(6) +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' ON UPDATE CURRENT_TIMESTAMP(6) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME(6) ON UPDATE CURRENT_TIMESTAMP); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a DATETIME(6) ON UPDATE CURRENT_TIMESTAMP(0)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a DATETIME(6) ON UPDATE CURRENT_TIMESTAMP(1)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a DATETIME(6) ON UPDATE CURRENT_TIMESTAMP(2)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a DATETIME(6) ON UPDATE CURRENT_TIMESTAMP(4)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a DATETIME(6) ON UPDATE CURRENT_TIMESTAMP(5)); +ERROR HY000: Invalid ON UPDATE clause for 'a' column +CREATE TABLE t1 (a DATETIME(6) ON UPDATE CURRENT_TIMESTAMP(6)); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a datetime(6) YES NULL on update CURRENT_TIMESTAMP(6) +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` datetime(6) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(6) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Testing that ON UPDATE CURRENT_TIMESTAMP(n) truncates rather than rounds +# +SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00.999999'); +CREATE TABLE t1 ( +a TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2), +b DATETIME(2) ON UPDATE CURRENT_TIMESTAMP(2), +c INT); +INSERT INTO t1 VALUES ('1999-01-01 00:00:00', '1999-01-01 00:00:00', 1); +SELECT * FROM t1; +a b c +1999-01-01 00:00:00.00 1999-01-01 00:00:00.00 1 +UPDATE t1 SET c=2; +SELECT CURRENT_TIMESTAMP(6); +CURRENT_TIMESTAMP(6) +2001-01-01 00:00:00.999999 +SELECT * FROM t1; +a b c +2001-01-01 00:00:00.99 2001-01-01 00:00:00.99 2 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Mixing varios TIMESTAMP(N) in CASE +# +CREATE TABLE t1 ( +t0 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +t1 TIMESTAMP(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +t3 TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +t4 TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +t6 TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00.0'); +CREATE TABLE t2 AS SELECT +CASE WHEN 1 THEN t0 ELSE t1 END, +CASE WHEN 1 THEN t0 ELSE t3 END, +CASE WHEN 1 THEN t0 ELSE t4 END, +CASE WHEN 1 THEN t0 ELSE t6 END, +CASE WHEN 1 THEN t1 ELSE t0 END, +CASE WHEN 1 THEN t1 ELSE t3 END, +CASE WHEN 1 THEN t1 ELSE t4 END, +CASE WHEN 1 THEN t1 ELSE t6 END, +CASE WHEN 1 THEN t3 ELSE t0 END, +CASE WHEN 1 THEN t3 ELSE t1 END, +CASE WHEN 1 THEN t3 ELSE t4 END, +CASE WHEN 1 THEN t3 ELSE t6 END, +CASE WHEN 1 THEN t4 ELSE t0 END, +CASE WHEN 1 THEN t4 ELSE t1 END, +CASE WHEN 1 THEN t4 ELSE t3 END, +CASE WHEN 1 THEN t4 ELSE t6 END, +CASE WHEN 1 THEN t6 ELSE t0 END, +CASE WHEN 1 THEN t6 ELSE t1 END, +CASE WHEN 1 THEN t6 ELSE t3 END, +CASE WHEN 1 THEN t6 ELSE t4 END +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CASE WHEN 1 THEN t0 ELSE t1 END` timestamp(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `CASE WHEN 1 THEN t0 ELSE t3 END` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `CASE WHEN 1 THEN t0 ELSE t4 END` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `CASE WHEN 1 THEN t0 ELSE t6 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `CASE WHEN 1 THEN t1 ELSE t0 END` timestamp(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', + `CASE WHEN 1 THEN t1 ELSE t3 END` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `CASE WHEN 1 THEN t1 ELSE t4 END` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `CASE WHEN 1 THEN t1 ELSE t6 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `CASE WHEN 1 THEN t3 ELSE t0 END` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `CASE WHEN 1 THEN t3 ELSE t1 END` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `CASE WHEN 1 THEN t3 ELSE t4 END` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `CASE WHEN 1 THEN t3 ELSE t6 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `CASE WHEN 1 THEN t4 ELSE t0 END` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `CASE WHEN 1 THEN t4 ELSE t1 END` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `CASE WHEN 1 THEN t4 ELSE t3 END` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `CASE WHEN 1 THEN t4 ELSE t6 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `CASE WHEN 1 THEN t6 ELSE t0 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `CASE WHEN 1 THEN t6 ELSE t1 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `CASE WHEN 1 THEN t6 ELSE t3 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `CASE WHEN 1 THEN t6 ELSE t4 END` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing various TIMESTAMP(N) in COALESCE +# +CREATE TABLE t1 ( +a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), +b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00', +c TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00.0', +d TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00.0', +e TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +f TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0'); +CREATE TABLE t2 AS SELECT +COALESCE(a, b), COALESCE(c, b), +COALESCE(c, d), COALESCE(e, f), +COALESCE(c, e), COALESCE(c, f) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `COALESCE(a, b)` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `COALESCE(c, b)` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', + `COALESCE(c, d)` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `COALESCE(e, f)` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', + `COALESCE(c, e)` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', + `COALESCE(c, f)` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT +CONCAT(COALESCE(a, b)), CONCAT(COALESCE(c, b)), +CONCAT(COALESCE(c, d)), CONCAT(COALESCE(e, f)), +CONCAT(COALESCE(c, e)), CONCAT(COALESCE(c, f)) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CONCAT(COALESCE(a, b))` varchar(26) CHARACTER SET latin1 NOT NULL DEFAULT '', + `CONCAT(COALESCE(c, b))` varchar(26) CHARACTER SET latin1 NOT NULL DEFAULT '', + `CONCAT(COALESCE(c, d))` varchar(19) CHARACTER SET latin1 NOT NULL DEFAULT '', + `CONCAT(COALESCE(e, f))` varchar(24) CHARACTER SET latin1 NOT NULL DEFAULT '', + `CONCAT(COALESCE(c, e))` varchar(23) CHARACTER SET latin1 NOT NULL DEFAULT '', + `CONCAT(COALESCE(c, f))` varchar(24) CHARACTER SET latin1 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing TIMESTAMP(6) with another TIMESTAMP(6) in IF +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t2 AS SELECT IF(1, a, b) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing TIMESTAMP(N) and TIMESTAMP(M) in IF +# +CREATE TABLE t1 (a TIMESTAMP(1) NOT NULL DEFAULT CURRENT_TIMESTAMP(1) ON UPDATE CURRENT_TIMESTAMP(1), b TIMESTAMP(2) NOT NULL DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t2 AS SELECT IF(1, a, b), IF(1, b, a) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `IF(1, a, b)` timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', + `IF(1, b, a)` timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Mixing TIMESTAMP(6) NOT NULL with another TIMESTAMP(6) NOT NULL +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t2 AS SELECT IF(1, a, b) AS a FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between TIMESTAMP(6) and TIMESTAMP(6) +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456', '2001-01-01 00:11:22.123456'); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2 ORDER BY a; +a +2001-01-01 00:11:22.123456 +2001-01-01 11:22:33.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between TIMESTAMP(n) +# +CREATE TABLE t1 (t0 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, t1 TIMESTAMP(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', t3 TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00.0', t4 TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0'); +CREATE TABLE t2 AS SELECT t0 FROM t1 UNION SELECT t1 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t0` timestamp(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT t1 FROM t1 UNION SELECT t3 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t1` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT t3 FROM t1 UNION SELECT t4 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t3` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between TIMESTAMP(6) and TIMESTAMP / DATE / DATETIME +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00', c DATE NOT NULL, d DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456', '2001-01-01 00:11:22.123456','2001-01-01','2001-01-01 20:20:20.123456'); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +a timestamp(6) NO 0000-00-00 00:00:00.000000 +SELECT * FROM t2 ORDER BY a; +a +2001-01-01 00:11:22.123456 +2001-01-01 11:22:33.000000 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT b FROM t1 UNION SELECT a FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +b timestamp(6) NO 0000-00-00 00:00:00.000000 +SELECT * FROM t2 ORDER BY b; +b +2001-01-01 00:11:22.123456 +2001-01-01 11:22:33.000000 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT c FROM t1 UNION SELECT b FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +c datetime(6) NO 0000-00-00 00:00:00.000000 +SELECT * FROM t2 ORDER BY c; +c +2001-01-01 00:00:00.000000 +2001-01-01 00:11:22.123456 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT d FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +a datetime(6) YES NULL +SELECT * FROM t2 ORDER BY a; +a +2001-01-01 11:22:33.000000 +2001-01-01 20:20:20.123456 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT b FROM t1 UNION SELECT c FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +b datetime(6) NO 0000-00-00 00:00:00.000000 +SELECT * FROM t2 ORDER BY b; +b +2001-01-01 00:00:00.000000 +2001-01-01 00:11:22.123456 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT c FROM t1 UNION SELECT b FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +c datetime(6) NO 0000-00-00 00:00:00.000000 +SELECT * FROM t2 ORDER BY c; +c +2001-01-01 00:00:00.000000 +2001-01-01 00:11:22.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# UNION between TIMESTAMP(6) and various other types +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), b BIGINT, c DOUBLE, d DECIMAL(20,6), e VARCHAR(20)); +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT b FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT c FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT d FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT e FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(26) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +# +# Testing TIMESTAMP(6) field in combination with DATETIME type functions +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), b TIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:00:00.123456', '10:00:00.123456'); +INSERT INTO t1 VALUES ('2001-01-01 10:00:00', '10:00:00'); +SELECT * FROM t1 WHERE a=TIMESTAMP('2001-01-01', b); +a b +2001-01-01 10:00:00.123456 10:00:00.123456 +2001-01-01 10:00:00.000000 10:00:00.000000 +SELECT * FROM t1 WHERE a=ADDTIME('2001-01-01 00:00:00', '10:00:00'); +a b +2001-01-01 10:00:00.000000 10:00:00.000000 +SELECT * FROM t1 WHERE a=ADDTIME('2001-01-01 00:00:00', '10:00:00.123456'); +a b +2001-01-01 10:00:00.123456 10:00:00.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES (CURRENT_TIMESTAMP, CURRENT_TIME); +SELECT COUNT(*) FROM t1 WHERE a <= CURRENT_TIMESTAMP; +COUNT(*) +1 +SELECT COUNT(*) FROM t1 WHERE a >= SUBTIME(CURRENT_TIMESTAMP, '10:00:00'); +COUNT(*) +1 +DROP TABLE t1; +# +# Testing partitions +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)) PARTITION BY KEY(a) PARTITIONS 4; +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000002'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000003'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000004'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000005'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000006'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000010'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000011'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000012'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000013'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000014'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000015'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000016'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000110'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000111'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000112'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000113'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000114'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000115'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000116'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000210'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000211'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000212'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000213'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000214'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000215'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000216'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000002'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000003'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000004'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000005'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:01.000006'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000000'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000001'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000002'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000003'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000004'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000005'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:02.000006'); +SELECT * FROM t1 PARTITION(p0); +a +2001-01-01 00:00:00.000003 +2001-01-01 00:00:00.000011 +2001-01-01 00:00:00.000015 +2001-01-01 00:00:00.000111 +2001-01-01 00:00:00.000115 +2001-01-01 00:00:00.000211 +2001-01-01 00:00:00.000215 +2001-01-01 00:00:01.000003 +2001-01-01 00:00:02.000003 +SELECT * FROM t1 PARTITION(p1); +a +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000004 +2001-01-01 00:00:00.000012 +2001-01-01 00:00:00.000016 +2001-01-01 00:00:00.000112 +2001-01-01 00:00:00.000116 +2001-01-01 00:00:00.000212 +2001-01-01 00:00:00.000216 +2001-01-01 00:00:01.000002 +2001-01-01 00:00:01.000006 +2001-01-01 00:00:02.000000 +2001-01-01 00:00:02.000004 +SELECT * FROM t1 PARTITION(p2); +a +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000005 +2001-01-01 00:00:00.000013 +2001-01-01 00:00:00.000113 +2001-01-01 00:00:00.000213 +2001-01-01 00:00:01.000001 +2001-01-01 00:00:01.000005 +2001-01-01 00:00:02.000001 +2001-01-01 00:00:02.000005 +SELECT * FROM t1 PARTITION(p3); +a +2001-01-01 00:00:00.000002 +2001-01-01 00:00:00.000006 +2001-01-01 00:00:00.000010 +2001-01-01 00:00:00.000014 +2001-01-01 00:00:00.000110 +2001-01-01 00:00:00.000114 +2001-01-01 00:00:00.000210 +2001-01-01 00:00:00.000214 +2001-01-01 00:00:01.000000 +2001-01-01 00:00:01.000004 +2001-01-01 00:00:02.000002 +2001-01-01 00:00:02.000006 +ALTER TABLE t1 PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN ('2001-01-01 00:00:00.000200'), +PARTITION p1 VALUES LESS THAN ('2001-01-01 00:00:01'), +PARTITION p2 VALUES LESS THAN ('2001-01-01 00:00:02.000003'), +PARTITION p3 VALUES LESS THAN MAXVALUE +); +ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning +SELECT * FROM t1 PARTITION(p0); +a +2001-01-01 00:00:00.000003 +2001-01-01 00:00:00.000011 +2001-01-01 00:00:00.000015 +2001-01-01 00:00:00.000111 +2001-01-01 00:00:00.000115 +2001-01-01 00:00:00.000211 +2001-01-01 00:00:00.000215 +2001-01-01 00:00:01.000003 +2001-01-01 00:00:02.000003 +SELECT * FROM t1 PARTITION(p1); +a +2001-01-01 00:00:00.000000 +2001-01-01 00:00:00.000004 +2001-01-01 00:00:00.000012 +2001-01-01 00:00:00.000016 +2001-01-01 00:00:00.000112 +2001-01-01 00:00:00.000116 +2001-01-01 00:00:00.000212 +2001-01-01 00:00:00.000216 +2001-01-01 00:00:01.000002 +2001-01-01 00:00:01.000006 +2001-01-01 00:00:02.000000 +2001-01-01 00:00:02.000004 +SELECT * FROM t1 PARTITION(p2); +a +2001-01-01 00:00:00.000001 +2001-01-01 00:00:00.000005 +2001-01-01 00:00:00.000013 +2001-01-01 00:00:00.000113 +2001-01-01 00:00:00.000213 +2001-01-01 00:00:01.000001 +2001-01-01 00:00:01.000005 +2001-01-01 00:00:02.000001 +2001-01-01 00:00:02.000005 +SELECT * FROM t1 PARTITION(p3); +a +2001-01-01 00:00:00.000002 +2001-01-01 00:00:00.000006 +2001-01-01 00:00:00.000010 +2001-01-01 00:00:00.000014 +2001-01-01 00:00:00.000110 +2001-01-01 00:00:00.000114 +2001-01-01 00:00:00.000210 +2001-01-01 00:00:00.000214 +2001-01-01 00:00:01.000000 +2001-01-01 00:00:01.000004 +2001-01-01 00:00:02.000002 +2001-01-01 00:00:02.000006 +DROP TABLE t1; +# +# CAST from TIMESTAMP to TATETIME +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33', '2001-01-01 11:22:33.123456'); +CREATE TABLE t2 AS SELECT CAST(a AS DATETIME), CAST(b AS DATETIME) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS DATETIME)` datetime DEFAULT NULL, + `CAST(b AS DATETIME)` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2; +CAST(a AS DATETIME) CAST(b AS DATETIME) +2001-01-01 11:22:33 2001-01-01 11:22:33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT CAST(a AS DATETIME(0)), CAST(b AS DATETIME(0)) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS DATETIME(0))` datetime DEFAULT NULL, + `CAST(b AS DATETIME(0))` datetime DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2; +CAST(a AS DATETIME(0)) CAST(b AS DATETIME(0)) +2001-01-01 11:22:33 2001-01-01 11:22:33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT CAST(a AS DATETIME(6)), CAST(b AS DATETIME(6)) FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `CAST(a AS DATETIME(6))` datetime(6) DEFAULT NULL, + `CAST(b AS DATETIME(6))` datetime(6) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t2; +CAST(a AS DATETIME(6)) CAST(b AS DATETIME(6)) +2001-01-01 11:22:33.000000 2001-01-01 11:22:33.123456 +DROP TABLE t2; +DROP TABLE t1; +# +# Testing comparison between a TIMESTAMP(6) field and a DATETIME(N) cast +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000000'); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000001'); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000002'); +INSERT INTO t1 VALUES ('2001-01-01 10:11:12.000003'); +SELECT * FROM t1 WHERE a=CAST('2001-01-01 10:11:12.000003' AS DATETIME(6)); +a +2001-01-01 10:11:12.000003 +SELECT * FROM t1 WHERE a=CAST('2001-01-01 10:11:12.000003' AS DATETIME(0)); +a +2001-01-01 10:11:12.000000 +DROP TABLE t1; +# +# Testing TIMESTAMP subquery in combination with CAST to DATETIME(N) +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +INSERT INTO t1 VALUES ('2001-01-01 23:00:00', '2001-01-01 23:00:00.123456'); +SELECT CAST('2001-01-01 23:00:00' AS DATETIME) = (SELECT a FROM t1); +CAST('2001-01-01 23:00:00' AS DATETIME) = (SELECT a FROM t1) +1 +SELECT CAST('2001-01-01 23:00:00' AS DATETIME(6)) = (SELECT a FROM t1); +CAST('2001-01-01 23:00:00' AS DATETIME(6)) = (SELECT a FROM t1) +1 +SELECT CAST('2001-01-01 23:00:00.123456' AS DATETIME(0)) = (SELECT a FROM t1); +CAST('2001-01-01 23:00:00.123456' AS DATETIME(0)) = (SELECT a FROM t1) +1 +SELECT CAST('2001-01-01 23:00:00.123456' AS DATETIME(6)) = (SELECT b FROM t1); +CAST('2001-01-01 23:00:00.123456' AS DATETIME(6)) = (SELECT b FROM t1) +1 +DROP TABLE t1; +# +# Testing TIMESTAMP column with function MICROSECOND +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:12:13.000001'); +INSERT INTO t1 VALUES ('2001-01-01 11:12:13.100001'); +INSERT INTO t1 VALUES ('2001-01-01 11:12:13.999999'); +SELECT a, MICROSECOND(a) FROM t1; +a MICROSECOND(a) +2001-01-01 11:12:13.000001 1 +2001-01-01 11:12:13.100001 100001 +2001-01-01 11:12:13.999999 999999 +SELECT a, EXTRACT(MICROSECOND FROM a) FROM t1; +a EXTRACT(MICROSECOND FROM a) +2001-01-01 11:12:13.000001 1 +2001-01-01 11:12:13.100001 100001 +2001-01-01 11:12:13.999999 999999 +DROP TABLE t1; +# +# Testing PS +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)'; +SET @a='2001-01-01 11:22:33.123456'; +SET @b=20010101112233.123456; +SET @c=0.123456e0; +EXECUTE stmt USING @a; +EXECUTE stmt USING @c; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +DEALLOCATE PREPARE stmt; +SELECT * FROM t1; +a +2001-01-01 11:22:33.123456 +0000-00-00 00:00:00.000000 +PREPARE stmt FROM 'SELECT * FROM t1 WHERE a=?'; +EXECUTE stmt USING @a; +a +2001-01-01 11:22:33.123456 +EXECUTE stmt USING @b; +a +2001-01-01 11:22:33.123456 +EXECUTE stmt USING @c; +a +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +# +# Testing TIMESTAMP(6) and user variables +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 11:22:33.123456'); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.100000'); +SELECT * FROM t1; +a +2001-01-01 11:22:33.123456 +2001-01-01 00:00:00.100000 +SET @a='2001-01-01 11:22:33.123456'; +SELECT * FROM t1 WHERE a=@a; +a +2001-01-01 11:22:33.123456 +SET @a=20010101112233.123456; +SELECT * FROM t1 WHERE a=@a; +a +2001-01-01 11:22:33.123456 +SET @a=20010101000000.1e0; +SELECT @a; +@a +20010101000000.1 +SELECT * FROM t1 WHERE a=@a; +a +2001-01-01 00:00:00.100000 +SET @a=NULL; +SELECT a INTO @a FROM t1 LIMIT 1; +SELECT @a; +@a +2001-01-01 11:22:33.123456 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT @a AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` longtext CHARACTER SET latin1 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +a +2001-01-01 11:22:33.123456 +DROP TABLE t1; +# +# Testing SP +# +CREATE PROCEDURE p1 () +BEGIN +DECLARE a TIMESTAMP(6); +SET a='2001-01-01 11:22:33.123'; +SELECT a; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE a TIMESTAMP(6); +SET a='2001-01-01 11:22:33.123'; +SELECT a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1// +a +2001-01-01 11:22:33.123000 +DROP PROCEDURE p1// +CREATE PROCEDURE p1 (a TIMESTAMP(6)) +BEGIN +SELECT a; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(a TIMESTAMP(6)) +BEGIN +SELECT a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1(20010101112233)// +a +2001-01-01 11:22:33.000000 +CALL p1(20010101112233.123)// +a +2001-01-01 11:22:33.123000 +CALL p1(0.123e0)// +a +0000-00-00 00:00:00.000000 +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +CALL p1('2001-01-01 11:22:33.123')// +a +2001-01-01 11:22:33.123000 +DROP PROCEDURE p1// +CREATE PROCEDURE p1() +BEGIN +DECLARE a TIMESTAMP(6); +CREATE TABLE t1 AS SELECT a; +SHOW CREATE TABLE t1; +DROP TABLE t1; +END// +SHOW CREATE PROCEDURE p1// +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +BEGIN +DECLARE a TIMESTAMP(6); +CREATE TABLE t1 AS SELECT a; +SHOW CREATE TABLE t1; +DROP TABLE t1; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +CALL p1// +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(6) NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP PROCEDURE p1// +CREATE FUNCTION p1 (a TIMESTAMP(6)) RETURNS TIMESTAMP(6) +BEGIN +RETURN a; +END// +SHOW CREATE FUNCTION p1// +Function sql_mode Create Function character_set_client collation_connection Database Collation +p1 NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `p1`(a TIMESTAMP(6)) RETURNS timestamp(6) +BEGIN +RETURN a; +END latin1 latin1_swedish_ci utf8mb4_0900_ai_ci +SELECT p1(20010101112233)// +p1(20010101112233) +2001-01-01 11:22:33.000000 +SELECT p1(20010101112233.123)// +p1(20010101112233.123) +2001-01-01 11:22:33.123000 +DROP FUNCTION p1// +# +# Testing INFORMATION_SCHEMA.COLUMNS +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1';; +TABLE_CATALOG def +TABLE_SCHEMA test +TABLE_NAME t1 +COLUMN_NAME a +ORDINAL_POSITION 1 +COLUMN_DEFAULT CURRENT_TIMESTAMP(6) +IS_NULLABLE NO +DATA_TYPE timestamp +CHARACTER_MAXIMUM_LENGTH NULL +CHARACTER_OCTET_LENGTH NULL +NUMERIC_PRECISION NULL +NUMERIC_SCALE NULL +DATETIME_PRECISION 6 +CHARACTER_SET_NAME NULL +COLLATION_NAME NULL +COLUMN_TYPE timestamp(6) +COLUMN_KEY +EXTRA DEFAULT_GENERATED on update CURRENT_TIMESTAMP(6) +PRIVILEGES # +COLUMN_COMMENT +GENERATION_EXPRESSION +SRS_ID NULL +DROP TABLE t1; +# +# SELECT from a subquery +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.123456'), ('2001-01-01 11:11:11.123456'); +SELECT * FROM (SELECT * FROM t1) t12; +a +2001-01-01 00:00:00.123456 +2001-01-01 11:11:11.123456 +DROP TABLE t1; +# +# Testing IN and = subqueries +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.123456'), ('2001-01-01 11:11:11.123456'); +SELECT * FROM t1 WHERE a IN (SELECT MIN(a) FROM t1); +a +2001-01-01 00:00:00.123456 +SELECT * FROM t1 WHERE a = (SELECT a FROM t1 ORDER BY a DESC LIMIT 1); +a +2001-01-01 11:11:11.123456 +DROP TABLE t1; +# +# Testing IN subquery + GROUP +# +CREATE TABLE t1 (id INT, a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES (1, '2001-01-01 00:00:00.123456'), (1, '2001-01-01 11:00:00.123456'); +INSERT INTO t1 VALUES (2, '2001-01-01 00:01:00.123456'), (2, '2001-01-01 11:01:00.123456'); +SELECT * FROM t1 WHERE a IN (SELECT MAX(a) FROM t1 GROUP BY id); +id a +1 2001-01-01 11:00:00.123456 +2 2001-01-01 11:01:00.123456 +DROP TABLE t1; +# +# Testing VIEW +# +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.123456'), ('2001-01-01 11:11:11.123456'); +CREATE VIEW v1 AS SELECT a FROM t1; +SELECT * FROM v1 WHERE a='2001-01-01 00:00:00.123456'; +a +2001-01-01 00:00:00.123456 +SELECT MIN(a), MAX(a) FROM v1; +MIN(a) MAX(a) +2001-01-01 00:00:00.123456 2001-01-01 11:11:11.123456 +SELECT * FROM t1 WHERE a IN (SELECT MAX(a) FROM v1); +a +2001-01-01 11:11:11.123456 +DROP VIEW v1; +CREATE VIEW v1 AS SELECT MAX(a) AS a FROM t1; +SELECT * FROM v1; +a +2001-01-01 11:11:11.123456 +SELECT * FROM t1 WHERE a=(SELECT a FROM v1); +a +2001-01-01 11:11:11.123456 +DROP VIEW v1; +DROP TABLE t1; +# +# Testing default value +# +CREATE TABLE t1 (a DATETIME(6), b TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 (a) VALUES (CURRENT_TIMESTAMP(6)); +SELECT a=b FROM t1; +a=b +1 +DROP TABLE t1; +SET time_zone=DEFAULT; +CREATE TABLE t1 (a DATETIME(6), b TIME(6)); +INSERT INTO t1 VALUES ('1212-12-12 21:21:21.555555', '00:00:00.21'); +INSERT INTO t1 VALUES ('9999-12-31 23:59:59.999999', '00:00:00.000001'); +SELECT a + b FROM t1; +a + b +12121212212121.765555 +99991231235960.000000 +DROP TABLE t1; +# +# Testing that IF always returns correct number of decimal digits +# +SET timestamp=UNIX_TIMESTAMP('2011-11-10 18:04:30'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT if(0, dt2, t3), CONCAT(if(0, dt2, t3)) FROM t1; +if(0, dt2, t3) CONCAT(if(0, dt2, t3)) +2011-11-10 00:00:00.567 2011-11-10 00:00:00.567 +SELECT if(1, dt2, t3), CONCAT(if(1, dt2, t3)) FROM t1; +if(1, dt2, t3) CONCAT(if(1, dt2, t3)) +2001-01-01 00:00:00.120 2001-01-01 00:00:00.120 +SELECT if(0, t3, dt2), CONCAT(if(0, t3, dt2)) FROM t1; +if(0, t3, dt2) CONCAT(if(0, t3, dt2)) +2001-01-01 00:00:00.120 2001-01-01 00:00:00.120 +SELECT if(1, t3, dt2), CONCAT(if(1, t3, dt2)) FROM t1; +if(1, t3, dt2) CONCAT(if(1, t3, dt2)) +2011-11-10 00:00:00.567 2011-11-10 00:00:00.567 +SELECT if(0, t3, d), CONCAT(if(0, t3, d)) FROM t1; +if(0, t3, d) CONCAT(if(0, t3, d)) +2002-01-01 00:00:00.000 2002-01-01 00:00:00.000 +SELECT if(1, t3, d), CONCAT(if(1, t3, d)) FROM t1; +if(1, t3, d) CONCAT(if(1, t3, d)) +2011-11-10 00:00:00.567 2011-11-10 00:00:00.567 +SELECT if(0, d, t3), CONCAT(if(0, d, t3)) FROM t1; +if(0, d, t3) CONCAT(if(0, d, t3)) +2011-11-10 00:00:00.567 2011-11-10 00:00:00.567 +SELECT if(1, d, t3), CONCAT(if(1, d, t3)) FROM t1; +if(1, d, t3) CONCAT(if(1, d, t3)) +2002-01-01 00:00:00.000 2002-01-01 00:00:00.000 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing that CASE always returns correct number of decimal digits +# +SET timestamp=UNIX_TIMESTAMP('2011-11-10 18:04:30'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1; +CASE WHEN 0 THEN dt2 ELSE t3 END +2011-11-10 00:00:00.567 +SELECT CONCAT(CASE WHEN 0 THEN dt2 ELSE t3 END) FROM t1; +CONCAT(CASE WHEN 0 THEN dt2 ELSE t3 END) +2011-11-10 00:00:00.567 +SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1; +CASE WHEN 1 THEN dt2 ELSE t3 END +2001-01-01 00:00:00.120 +SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1; +CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) +2001-01-01 00:00:00.120 +SELECT CASE WHEN 0 THEN t3 ELSE dt2 END FROM t1; +CASE WHEN 0 THEN t3 ELSE dt2 END +2001-01-01 00:00:00.120 +SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1; +CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) +2001-01-01 00:00:00.120 +SELECT CASE WHEN 1 THEN t3 ELSE dt2 END FROM t1; +CASE WHEN 1 THEN t3 ELSE dt2 END +2011-11-10 00:00:00.567 +SELECT CONCAT(CASE WHEN 1 THEN t3 ELSE dt2 END) FROM t1; +CONCAT(CASE WHEN 1 THEN t3 ELSE dt2 END) +2011-11-10 00:00:00.567 +SELECT CASE WHEN 0 THEN d ELSE t3 END FROM t1; +CASE WHEN 0 THEN d ELSE t3 END +2011-11-10 00:00:00.567 +SELECT CONCAT(CASE WHEN 0 THEN d ELSE t3 END) FROM t1; +CONCAT(CASE WHEN 0 THEN d ELSE t3 END) +2011-11-10 00:00:00.567 +SELECT CASE WHEN 1 THEN d ELSE t3 END FROM t1; +CASE WHEN 1 THEN d ELSE t3 END +2002-01-01 00:00:00.000 +SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1; +CONCAT(CASE WHEN 1 THEN d ELSE t3 END) +2002-01-01 00:00:00.000 +SELECT CASE WHEN 0 THEN t3 ELSE d END FROM t1; +CASE WHEN 0 THEN t3 ELSE d END +2002-01-01 00:00:00.000 +SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE d END) FROM t1; +CONCAT(CASE WHEN 0 THEN t3 ELSE d END) +2002-01-01 00:00:00.000 +SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1; +CASE WHEN 1 THEN t3 ELSE d END +2011-11-10 00:00:00.567 +SELECT CONCAT(CASE WHEN 1 THEN t3 ELSE d END) FROM t1; +CONCAT(CASE WHEN 1 THEN t3 ELSE d END) +2011-11-10 00:00:00.567 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing that COALESCE always returns correct number of decimal digits +# +SET timestamp=UNIX_TIMESTAMP('2011-11-10 18:04:30'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT COALESCE(dt2, t3) FROM t1; +COALESCE(dt2, t3) +2001-01-01 00:00:00.120 +SELECT CONCAT(COALESCE(dt2, t3)) FROM t1; +CONCAT(COALESCE(dt2, t3)) +2001-01-01 00:00:00.120 +SELECT COALESCE(t3, dt2) FROM t1; +COALESCE(t3, dt2) +2011-11-10 00:00:00.567 +SELECT CONCAT(COALESCE(t3, dt2)) FROM t1; +CONCAT(COALESCE(t3, dt2)) +2011-11-10 00:00:00.567 +SELECT COALESCE(d, t3) FROM t1; +COALESCE(d, t3) +2002-01-01 00:00:00.000 +SELECT CONCAT(COALESCE(d, t3)) FROM t1; +CONCAT(COALESCE(d, t3)) +2002-01-01 00:00:00.000 +SELECT COALESCE(t3, d) FROM t1; +COALESCE(t3, d) +2011-11-10 00:00:00.567 +SELECT CONCAT(COALESCE(t3, d)) FROM t1; +CONCAT(COALESCE(t3, d)) +2011-11-10 00:00:00.567 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing that IFNULL always returns correct number of decimal digits +# +SET timestamp=UNIX_TIMESTAMP('2011-11-10 18:04:30'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT IFNULL(dt2, t3) FROM t1; +IFNULL(dt2, t3) +2001-01-01 00:00:00.120 +SELECT CONCAT(IFNULL(dt2, t3)) FROM t1; +CONCAT(IFNULL(dt2, t3)) +2001-01-01 00:00:00.120 +SELECT IFNULL(t3, dt2) FROM t1; +IFNULL(t3, dt2) +2011-11-10 00:00:00.567 +SELECT CONCAT(IFNULL(t3, dt2)) FROM t1; +CONCAT(IFNULL(t3, dt2)) +2011-11-10 00:00:00.567 +SELECT IFNULL(d, t3) FROM t1; +IFNULL(d, t3) +2002-01-01 00:00:00.000 +SELECT CONCAT(IFNULL(d, t3)) FROM t1; +CONCAT(IFNULL(d, t3)) +2002-01-01 00:00:00.000 +SELECT IFNULL(t3, d) FROM t1; +IFNULL(t3, d) +2011-11-10 00:00:00.567 +SELECT CONCAT(IFNULL(t3, d)) FROM t1; +CONCAT(IFNULL(t3, d)) +2011-11-10 00:00:00.567 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing that LEAST always returns correct number of decimal digits +# +SET timestamp=UNIX_TIMESTAMP('2011-11-10 18:04:30'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +INSERT INTO t1 VALUES ('2012-01-01 00:00:00.12', '00:00:00.567', '2013-01-01'); +SELECT LEAST(dt2, t3) FROM t1; +LEAST(dt2, t3) +2001-01-01 00:00:00.120 +2011-11-10 00:00:00.567 +SELECT CONCAT(LEAST(dt2, t3)) FROM t1; +CONCAT(LEAST(dt2, t3)) +2001-01-01 00:00:00.120 +2011-11-10 00:00:00.567 +SELECT LEAST(t3, dt2) FROM t1; +LEAST(t3, dt2) +2001-01-01 00:00:00.120 +2011-11-10 00:00:00.567 +SELECT CONCAT(LEAST(t3, dt2)) FROM t1; +CONCAT(LEAST(t3, dt2)) +2001-01-01 00:00:00.120 +2011-11-10 00:00:00.567 +SELECT LEAST(d, t3) FROM t1; +LEAST(d, t3) +2002-01-01 00:00:00.000 +2011-11-10 00:00:00.567 +SELECT CONCAT(LEAST(d, t3)) FROM t1; +CONCAT(LEAST(d, t3)) +2002-01-01 00:00:00.000 +2011-11-10 00:00:00.567 +SELECT LEAST(t3, d) FROM t1; +LEAST(t3, d) +2002-01-01 00:00:00.000 +2011-11-10 00:00:00.567 +SELECT CONCAT(LEAST(t3, d)) FROM t1; +CONCAT(LEAST(t3, d)) +2002-01-01 00:00:00.000 +2011-11-10 00:00:00.567 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing that GREATEST always returns correct number of decimal digits +# +SET timestamp=UNIX_TIMESTAMP('2011-11-10 18:04:30'); +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +INSERT INTO t1 VALUES ('2012-01-01 00:00:00.12', '00:00:00.567', '2013-01-01'); +SELECT GREATEST(dt2, t3) FROM t1; +GREATEST(dt2, t3) +2011-11-10 00:00:00.567 +2012-01-01 00:00:00.120 +SELECT CONCAT(GREATEST(dt2, t3)) FROM t1; +CONCAT(GREATEST(dt2, t3)) +2011-11-10 00:00:00.567 +2012-01-01 00:00:00.120 +SELECT GREATEST(t3, dt2) FROM t1; +GREATEST(t3, dt2) +2011-11-10 00:00:00.567 +2012-01-01 00:00:00.120 +SELECT CONCAT(GREATEST(t3, dt2)) FROM t1; +CONCAT(GREATEST(t3, dt2)) +2011-11-10 00:00:00.567 +2012-01-01 00:00:00.120 +SELECT GREATEST(d, t3) FROM t1; +GREATEST(d, t3) +2011-11-10 00:00:00.567 +2013-01-01 00:00:00.000 +SELECT CONCAT(GREATEST(d, t3)) FROM t1; +CONCAT(GREATEST(d, t3)) +2011-11-10 00:00:00.567 +2013-01-01 00:00:00.000 +SELECT GREATEST(t3, d) FROM t1; +GREATEST(t3, d) +2011-11-10 00:00:00.567 +2013-01-01 00:00:00.000 +SELECT CONCAT(GREATEST(t3, d)) FROM t1; +CONCAT(GREATEST(t3, d)) +2011-11-10 00:00:00.567 +2013-01-01 00:00:00.000 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Testing that hybrid type functions correctly convert +# from DATETIME to TIME +# +CREATE TABLE t1 (a DATETIME(3)); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30.123'); +SELECT CAST(IF(0, a, a) AS TIME(6)) FROM t1; +CAST(IF(0, a, a) AS TIME(6)) +10:20:30.123000 +SELECT CAST(COALESCE(a, a) AS TIME(6)) FROM t1; +CAST(COALESCE(a, a) AS TIME(6)) +10:20:30.123000 +SELECT CAST(IFNULL(a, a) AS TIME(6)) FROM t1; +CAST(IFNULL(a, a) AS TIME(6)) +10:20:30.123000 +SELECT CAST(CASE WHEN 0 THEN a ELSE a END AS TIME(6)) FROM t1; +CAST(CASE WHEN 0 THEN a ELSE a END AS TIME(6)) +10:20:30.123000 +SELECT CAST(GREATEST(a, a) AS TIME(6)) FROM t1; +CAST(GREATEST(a, a) AS TIME(6)) +10:20:30.123000 +SELECT CAST(LEAST(a, a) AS TIME(6)) FROM t1; +CAST(LEAST(a, a) AS TIME(6)) +10:20:30.123000 +DROP TABLE t1; +# +# Testing that hybrid type functions correctly convert +# from TIME to DATETIME +# +SET timestamp=UNIX_TIMESTAMP('2011-11-10 00:00:00'); +CREATE TABLE t1 (a TIME(3)); +INSERT INTO t1 VALUES ('10:20:30.123'); +SELECT CAST(IF(0, a, a) AS DATETIME(6)) FROM t1; +CAST(IF(0, a, a) AS DATETIME(6)) +2011-11-10 10:20:30.123000 +SELECT CAST(COALESCE(a, a) AS DATETIME(6)) FROM t1; +CAST(COALESCE(a, a) AS DATETIME(6)) +2011-11-10 10:20:30.123000 +SELECT CAST(IFNULL(a, a) AS DATETIME(6)) FROM t1; +CAST(IFNULL(a, a) AS DATETIME(6)) +2011-11-10 10:20:30.123000 +SELECT CAST(CASE WHEN 0 THEN a ELSE a END AS DATETIME(6)) FROM t1; +CAST(CASE WHEN 0 THEN a ELSE a END AS DATETIME(6)) +2011-11-10 10:20:30.123000 +SELECT CAST(GREATEST(a, a) AS DATETIME(6)) FROM t1; +CAST(GREATEST(a, a) AS DATETIME(6)) +2011-11-10 10:20:30.123000 +SELECT CAST(LEAST(a, a) AS DATETIME(6)) FROM t1; +CAST(LEAST(a, a) AS DATETIME(6)) +2011-11-10 10:20:30.123000 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Storing TIME functions into VARCHAR column +# +SET @@timestamp=1000000000; +CREATE TABLE t1 (a VARCHAR(32)); +INSERT INTO t1 VALUES (CAST('00:00:00' AS TIME)); +INSERT INTO t1 VALUES (CAST('00:00:00' AS TIME(6))); +SELECT * FROM t1; +a +00:00:00 +00:00:00.000000 +DELETE FROM t1; +INSERT INTO t1 VALUES (SEC_TO_TIME(10)); +INSERT INTO t1 VALUES (SEC_TO_TIME(-0.1)); +INSERT INTO t1 VALUES (SEC_TO_TIME(-0.01)); +INSERT INTO t1 VALUES (SEC_TO_TIME(-0.001)); +INSERT INTO t1 VALUES (SEC_TO_TIME(-0.0001)); +INSERT INTO t1 VALUES (SEC_TO_TIME(-0.00001)); +INSERT INTO t1 VALUES (SEC_TO_TIME(-0.000001)); +INSERT INTO t1 VALUES (SEC_TO_TIME(10.0)); +INSERT INTO t1 VALUES (SEC_TO_TIME(10.1)); +INSERT INTO t1 VALUES (SEC_TO_TIME(10.12)); +INSERT INTO t1 VALUES (SEC_TO_TIME(10.123)); +INSERT INTO t1 VALUES (SEC_TO_TIME(10.1234)); +INSERT INTO t1 VALUES (SEC_TO_TIME(10.12345)); +INSERT INTO t1 VALUES (SEC_TO_TIME(10.123456)); +SELECT * FROM t1; +a +00:00:10 +-00:00:00.1 +-00:00:00.01 +-00:00:00.001 +-00:00:00.0001 +-00:00:00.00001 +-00:00:00.000001 +00:00:10.0 +00:00:10.1 +00:00:10.12 +00:00:10.123 +00:00:10.1234 +00:00:10.12345 +00:00:10.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES (TIMEDIFF(NOW(), NOW())); +INSERT INTO t1 VALUES (TIMEDIFF(NOW(6), NOW(6))); +SELECT * FROM t1; +a +00:00:00 +00:00:00.000000 +DELETE FROM t1; +INSERT INTO t1 VALUES (MAKETIME(10, 10, 10)); +INSERT INTO t1 VALUES (MAKETIME(10, 10, 10.1)); +INSERT INTO t1 VALUES (MAKETIME(10, 10, 10.12)); +INSERT INTO t1 VALUES (MAKETIME(10, 10, 10.123)); +INSERT INTO t1 VALUES (MAKETIME(10, 10, 10.1234)); +INSERT INTO t1 VALUES (MAKETIME(10, 10, 10.12345)); +INSERT INTO t1 VALUES (MAKETIME(10, 10, 10.123456)); +SELECT * FROM t1; +a +10:10:10 +10:10:10.1 +10:10:10.12 +10:10:10.123 +10:10:10.1234 +10:10:10.12345 +10:10:10.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES (CURRENT_TIME()); +INSERT INTO t1 VALUES (CURRENT_TIME(6)); +SELECT LENGTH(a) FROM t1; +LENGTH(a) +8 +15 +DELETE FROM t1; +DROP TABLE t1; +SET @@timestamp=default; +# +# Storing DATETIME functions into VARCHAR column +# +SET @@time_zone='+00:00'; +SET @@timestamp=1000000000; +CREATE TABLE t1 (a VARCHAR(32)); +INSERT INTO t1 VALUES (CAST('2001-01-01 00:00:00' AS DATETIME)); +INSERT INTO t1 VALUES (CAST('2001-01-01 00:00:00' AS DATETIME(6))); +SELECT * FROM t1; +a +2001-01-01 00:00:00 +2001-01-01 00:00:00.000000 +DELETE FROM t1; +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000)); +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000.0)); +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000.1)); +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000.12)); +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000.123)); +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000.1234)); +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000.12345)); +INSERT INTO t1 VALUES (FROM_UNIXTIME(1000000000.123456)); +SELECT * FROM t1; +a +2001-09-09 01:46:40 +2001-09-09 01:46:40.0 +2001-09-09 01:46:40.1 +2001-09-09 01:46:40.12 +2001-09-09 01:46:40.123 +2001-09-09 01:46:40.1234 +2001-09-09 01:46:40.12345 +2001-09-09 01:46:40.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES (CONVERT_TZ(CAST('2001-01-01 00:00:00' AS DATETIME), '+00:00', '+10:00')); +INSERT INTO t1 VALUES (CONVERT_TZ(CAST('2001-01-01 00:00:00' AS DATETIME(6)), '+00:00', '+10:00')); +SELECT * FROM t1; +a +2001-01-01 10:00:00 +2001-01-01 10:00:00.000000 +DELETE FROM t1; +INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()); +INSERT INTO t1 VALUES (CURRENT_TIMESTAMP(6)); +SELECT LENGTH(a) FROM t1; +LENGTH(a) +19 +26 +DELETE FROM t1; +DROP TABLE t1; +SET @@timestamp=default; +SET @@time_zone=default; +# +# Storing DATE/TIME hybrid functions into VARCHAR column +# +SET @@time_zone='+00:00'; +SET @@timestamp=1000000000; +CREATE TABLE t1 (a VARCHAR(32)); +INSERT INTO t1 VALUES (ADDTIME('10:10:10', 10)); +INSERT INTO t1 VALUES (ADDTIME('10:10:10', 10.123456)); +INSERT INTO t1 VALUES (ADDTIME('10:10:10.000000', 10)); +INSERT INTO t1 VALUES (ADDTIME('10:10:10.123456', 10)); +SELECT * FROM t1; +a +10:10:20 +10:10:20.123456 +10:10:20 +10:10:20.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES (ADDTIME(CURRENT_TIME, 10)); +INSERT INTO t1 VALUES (ADDTIME(CURRENT_TIME, 10.123456)); +INSERT INTO t1 VALUES (ADDTIME(CURRENT_TIMESTAMP, 10)); +INSERT INTO t1 VALUES (ADDTIME(CURRENT_TIMESTAMP, 10.123456)); +SELECT * FROM t1; +a +01:46:50 +01:46:50.123456 +2001-09-09 01:46:50 +2001-09-09 01:46:50.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES(DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD('2001-01-01 00:00:00.000000', INTERVAL 1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND)); +SELECT * FROM t1; +a +2001-01-01 00:00:01 +2001-01-01 00:00:01.100000 +2001-01-01 00:00:01 +2001-01-01 00:00:01.123456 +DELETE FROM t1; +INSERT INTO t1 VALUES(DATE_ADD(CAST('2001-01-01 00:00:00' AS DATETIME), INTERVAL 1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD(CAST('2001-01-01 00:00:00' AS DATETIME(6)), INTERVAL 1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD(CAST('2001-01-01 00:00:00' AS DATETIME), INTERVAL 1.1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD(CAST('2001-01-01 00:00:00' AS DATETIME(6)), INTERVAL 1.1 SECOND)); +SELECT * FROM t1; +a +2001-01-01 00:00:01 +2001-01-01 00:00:01.000000 +2001-01-01 00:00:01.1 +2001-01-01 00:00:01.100000 +DELETE FROM t1; +INSERT INTO t1 VALUES(DATE_ADD(CAST('00:00:00' AS TIME), INTERVAL 1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD(CAST('00:00:00' AS TIME(6)), INTERVAL 1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD(CAST('00:00:00' AS TIME), INTERVAL 1.1 SECOND)); +INSERT INTO t1 VALUES(DATE_ADD(CAST('00:00:00' AS TIME(6)), INTERVAL 1.1 SECOND)); +SELECT * FROM t1; +a +00:00:01 +00:00:01.000000 +00:00:01.1 +00:00:01.100000 +DELETE FROM t1; +INSERT INTO t1 VALUES (STR_TO_DATE('2000', '%Y')); +INSERT INTO t1 VALUES (STR_TO_DATE('2000 10', '%Y %h')); +INSERT INTO t1 VALUES (STR_TO_DATE('2000 10 000000', '%Y %h %f')); +INSERT INTO t1 VALUES (STR_TO_DATE('2000 10 123456', '%Y %h %f')); +INSERT INTO t1 VALUES (STR_TO_DATE('2000 10 000000', '2000 %h 000000')); +INSERT INTO t1 VALUES (STR_TO_DATE('2000 10 123456', '2000 %h 123456')); +INSERT INTO t1 VALUES (STR_TO_DATE('2000 10 000000', '2000 %h %f')); +INSERT INTO t1 VALUES (STR_TO_DATE('2000 10 123456', '2000 %h %f')); +SELECT * FROM t1; +a +2000-00-00 +2000-00-00 10:00:00 +2000-00-00 10:00:00.000000 +2000-00-00 10:00:00.123456 +10:00:00 +10:00:00 +10:00:00.000000 +10:00:00.123456 +DELETE FROM t1; +DROP TABLE t1; +SET @@timestamp=default; +SET @@time_zone=default; +# +# Testing ALTER from DATE to various other temporal types +# +CREATE TABLE t1 (a DATE, b DATE, c DATE); +INSERT INTO t1 VALUES ('2001-01-01', '2001-01-01', '2001-01-01'); +ALTER TABLE t1 MODIFY a DATETIME(6), MODIFY b TIMESTAMP(6), MODIFY c TIME(6); +SELECT * FROM t1; +a b c +2001-01-01 00:00:00.000000 2001-01-01 00:00:00.000000 00:00:00.000000 +DROP TABLE t1; +# +# Examples from the WL#946 section "Literals" +# +CREATE TABLE t1 (datetime_column DATETIME(1)); +INSERT INTO t1 VALUES ('0000/1/1T1.23'); +SELECT * FROM t1; +datetime_column +0000-01-01 01:23:00.0 +DROP TABLE t1; +CREATE TABLE t1 (datetime_column DATETIME(1)); +INSERT INTO t1 VALUES ('1111.11.11 11.11.11.55'); +SELECT * FROM t1; +datetime_column +1111-11-11 11:11:11.6 +DROP TABLE t1; +CREATE TABLE t1 (time_column TIME(1)); +INSERT INTO t1 VALUES ('1.1'); +SELECT * FROM t1; +time_column +00:00:01.1 +DROP TABLE t1; +CREATE TABLE t1 (time_column TIME(1)); +INSERT INTO t1 VALUES ('1:2:3:4'); +Warnings: +Warning 1265 Data truncated for column 'time_column' at row 1 +SELECT * FROM t1; +time_column +01:02:03.0 +DROP TABLE t1; +CREATE TABLE t1 (datetime_column DATETIME(2)); +INSERT INTO t1 VALUES ('73-1-1 1:1:1.2'); +SELECT * FROM t1; +datetime_column +1973-01-01 01:01:01.20 +DROP TABLE t1; +CREATE TABLE t1 (datetime_column DATETIME(2)); +INSERT INTO t1 VALUES (1101010101.55); +SELECT * FROM t1; +datetime_column +2000-11-01 01:01:01.55 +DROP TABLE t1; +SELECT TIMEDIFF('00:00:00.1', '00:00:00.3'); +TIMEDIFF('00:00:00.1', '00:00:00.3') +-00:00:00.2 +# +# Examples from the WL#946 section "Treat like decimals" +# +CREATE TABLE t1 (time_column TIME(6)); +INSERT INTO t1 SET time_column=TIME'1.000001'; +SELECT * FROM t1; +time_column +00:00:01.000001 +DROP TABLE t1; +CREATE TABLE t1 (time_column TIME(6)); +INSERT INTO t1 SET time_column=TIME'1.0000005'; +SELECT * FROM t1; +time_column +00:00:01.000001 +DROP TABLE t1; +CREATE TABLE t1 (time_column TIME(6)); +INSERT INTO t1 SET time_column=TIME'1.0000005' + 0.000001; +SELECT * FROM t1; +time_column +00:00:01.000002 +DROP TABLE t1; +SELECT TIME'00:00:00.1' = TIME'00:00:00.100'; +TIME'00:00:00.1' = TIME'00:00:00.100' +1 +CREATE TABLE t1 (timestamp_column TIMESTAMP(0)); +INSERT INTO t1 SET timestamp_column = '2005-01-01 23:59:59.9'; +SELECT * FROM t1; +timestamp_column +2005-01-02 00:00:00 +DROP TABLE t1; +CREATE TABLE t1 (ts3 TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), ts2 TIMESTAMP(2) NOT NULL DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t2 AS SELECT ts3 FROM t1 UNION SELECT ts2 FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +ts3 timestamp(3) NO 0000-00-00 00:00:00.000 +DROP TABLE t2; +DROP TABLE t1; +# +# Examples from the WL#946 section "Behaviour changes" +# +CREATE TABLE t1 AS SELECT +TIME'10:10:10' + INTERVAL 1 SECOND, +ADDTIME(TIME'10:10:10', '1.1'); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIME'10:10:10' + INTERVAL 1 SECOND time YES NULL +ADDTIME(TIME'10:10:10', '1.1') time(1) YES NULL +DROP TABLE t1; +SELECT TIME'10:10:10' + INTERVAL .6 SECOND; +TIME'10:10:10' + INTERVAL .6 SECOND +10:10:10.6 +SELECT TIME('20:20:20') + INTERVAL .4 SECOND; +TIME('20:20:20') + INTERVAL .4 SECOND +20:20:20.4 +CREATE TABLE t1 AS SELECT +TIMESTAMP'2001-01-01 00:00:00' + INTERVAL 1 MICROSECOND AS a; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a datetime(6) YES NULL +DROP TABLE t1; +SELECT ADDTIME('9999-01-01 00:00:00', '.1'); +ADDTIME('9999-01-01 00:00:00', '.1') +9999-01-01 00:00:00.100000 +SELECT ADDTIME(TIMESTAMP'9999-01-01 00:00:00', '.1'); +ADDTIME(TIMESTAMP'9999-01-01 00:00:00', '.1') +9999-01-01 00:00:00.1 +SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30'); +SELECT CURRENT_TIME(6), CURRENT_TIME; +CURRENT_TIME(6) CURRENT_TIME +10:20:30.000000 10:20:30 +SET timestamp=DEFAULT; +SET time_zone='+00:00'; +SELECT FROM_UNIXTIME(0.5); +FROM_UNIXTIME(0.5) +1970-01-01 00:00:00.5 +SET time_zone=DEFAULT; +CREATE TABLE t1 (s1 DATETIME); +INSERT INTO t1 VALUES ('2000-12-31 23:59:59.9'); +SELECT * FROM t1; +s1 +2001-01-01 00:00:00 +DROP TABLE t1; +SELECT SEC_TO_TIME(36000.123); +SEC_TO_TIME(36000.123) +10:00:00.123 +SET timestamp=1308300674; +SELECT @@timestamp; +@@timestamp +1308300674.000000 +CREATE TABLE t1 AS SELECT @@timestamp; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +@@timestamp double(22,6) YES NULL +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Examples from the WL#946 section "Metadata" +# +CREATE TABLE t1 (a TIME(3)); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +a time(3) YES NULL +DESC t1; +Field Type Null Key Default Extra +a time(3) YES NULL +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +a time(3) YES NULL +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` time(3) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug#12546965 - 60990: INCORRECT DATE COMPARISON +# +CREATE TABLE t1 +(first_usage DATE, last_recharge DATETIME, life_time SMALLINT(4) UNSIGNED); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('2011-04-27', null, 900); +SELECT +DATE_ADD(GREATEST(first_usage, IFNULL(last_recharge, first_usage)), INTERVAL life_time DAY ) as dt, +DATE_ADD(GREATEST(first_usage, IFNULL(last_recharge, first_usage)), INTERVAL life_time DAY ) < +DATE('2011-04-28') as exp FROM t1; +dt exp +2013-10-13 00:00:00 0 +DROP TABLE t1; +# +# Bug 12565857 - 61193: INCORRECT ROUNDING OF DATE DECIMAL(17,3) +# +SELECT TIME(20110512154559.616), +DATE(20110512154559.616), DATE(FLOOR(20110512154559.616)); +TIME(20110512154559.616) DATE(20110512154559.616) DATE(FLOOR(20110512154559.616)) +15:45:59.616 2011-05-12 2011-05-12 +# +# "SELECT 3 IN (SELECT MAX(a) FROM t1)" returned 0 instead of NULL +# at some point of WL#946 development. +# This case is not covered elsewhere in the tests. +# +CREATE TABLE t1 (a INT); +SELECT 3 IN (SELECT MAX(a) FROM t1); +3 IN (SELECT MAX(a) FROM t1) +NULL +DROP TABLE t1; +CREATE TABLE t1(s1 DATETIME(6), s2 TIME(6)); +INSERT INTO t1 VALUES ('1212-12-12 21:21:21.555555', '00:00:00.21'); +SELECT s1 + s2 FROM t1; +s1 + s2 +12121212212121.765555 +DROP TABLE t1; +CREATE TABLE t1 (s1 TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)); +INSERT INTO t1 VALUES ('1971-01-01 00:00:00.0000099'); +SELECT * FROM t1; +s1 +1971-01-01 00:00:00.000010 +DROP TABLE t1; +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 10:00:00'); +CREATE TABLE t1 (s0 TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0), s6 TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00'); +INSERT INTO t1 VALUES (TIME'11:11:11.123456', TIME'11:11:11.123456'); +SELECT * FROM t1; +s0 s6 +2001-01-01 11:11:11 2001-01-01 11:11:11.123456 +DROP TABLE t1; +SET @@timestamp=default; +SET sql_mode='' /* not 'no_zero_in_date' */; +CREATE TABLE t1 (s1 DATETIME); +INSERT INTO t1 VALUES ('1000-00-01 00:00:00'); +INSERT INTO t1 VALUES (TIMESTAMP'1000-00-01 00:00:00'); +SELECT * FROM t1; +s1 +1000-00-01 00:00:00 +1000-00-01 00:00:00 +DROP TABLE t1; +SELECT SYSDATE(6) LIKE '____-__-__ __:__:__.______'; +SYSDATE(6) LIKE '____-__-__ __:__:__.______' +1 +SELECT SYSDATE(6) NOT LIKE '%.000000' || SYSDATE(6) NOT LIKE '%.000000'; +SYSDATE(6) NOT LIKE '%.000000' || SYSDATE(6) NOT LIKE '%.000000' +1 +Warnings: +Warning 1287 '|| as a synonym for OR' is deprecated and will be removed in a future release. Please use OR instead +CREATE TABLE t1 (s1 DATETIME(2)); +INSERT INTO t1 VALUES ('1970-01-01 11:11:11.1234'); +SELECT * FROM t1; +s1 +1970-01-01 11:11:11.12 +DROP TABLE t1; +CREATE TABLE t1 (s1 DATETIME(2)); +INSERT INTO t1 VALUES (TIMESTAMP '0001-01-01 00:00:00.05'); +SELECT TIMESTAMPADD(second, 1, s1) FROM t1; +TIMESTAMPADD(second, 1, s1) +0001-01-01 00:00:01.05 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT TIME'11:11:11.1234567'; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIME'11:11:11.1234567' time(6) NO 00:00:00.000000 +SELECT * FROM t1; +TIME'11:11:11.1234567' +11:11:11.123457 +DROP TABLE t1; +CREATE TABLE t1 (s1 datetime(6)); +INSERT INTO t1 VALUES ('2011-05-18 16:17:11.291816'); +SELECT MAX(s1), MAX(s1 + 0), MAX(s1) FROM t1; +MAX(s1) MAX(s1 + 0) MAX(s1) +2011-05-18 16:17:11.291816 20110518161711.291816 2011-05-18 16:17:11.291816 +DROP TABLE t1; +SELECT TIMESTAMP'2011-05-18 16:17:11.'; +TIMESTAMP'2011-05-18 16:17:11.' +2011-05-18 16:17:11 +SELECT TIMESTAMP('2011-05-18 16:17:11.2', '11.29'); +TIMESTAMP('2011-05-18 16:17:11.2', '11.29') +2011-05-18 16:17:22.49 +SELECT TIMESTAMPADD(second, 1, '2011-05-18 16:17:11.0'); +TIMESTAMPADD(second, 1, '2011-05-18 16:17:11.0') +2011-05-18 16:17:12 +SELECT DATE_ADD('2011-05-18 16:17:11.0', INTERVAL 1 SECOND); +DATE_ADD('2011-05-18 16:17:11.0', INTERVAL 1 SECOND) +2011-05-18 16:17:12 +SELECT TIMESTAMPADD(second, 1.1, '2011-05-18 16:17:11.0'); +TIMESTAMPADD(second, 1.1, '2011-05-18 16:17:11.0') +2011-05-18 16:17:12.100000 +SELECT DATE_ADD('2011-05-18 16:17:11.0', INTERVAL 1.1 SECOND); +DATE_ADD('2011-05-18 16:17:11.0', INTERVAL 1.1 SECOND) +2011-05-18 16:17:12.100000 +CREATE TABLE t1 (time_column TIME(6)); +INSERT INTO t1 VALUES (0); +UPDATE t1 SET time_column=TIME '1.0000005'; +SELECT * FROM t1; +time_column +00:00:01.000001 +DROP TABLE t1; +CREATE TABLE t1 (time_column TIME(6)); +INSERT INTO t1 VALUES (0); +UPDATE t1 SET time_column=TIME '1.0000005' + 0.000001; +SELECT * FROM t1; +time_column +00:00:01.000002 +DROP TABLE t1; +CREATE TABLE t1 (timestamp_column TIMESTAMP(0)); +INSERT INTO t1 VALUES (DEFAULT); +UPDATE t1 SET timestamp_column = '2005-01-01 23:59:59.9'; +SELECT * FROM t1; +timestamp_column +2005-01-02 00:00:00 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT TIME('00:00:00.123'); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIME('00:00:00.123') time(3) YES NULL +SELECT * FROM t1; +TIME('00:00:00.123') +00:00:00.123 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT TIMESTAMP('2000-01-01 00:00:00.123'); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIMESTAMP('2000-01-01 00:00:00.123') datetime(3) YES NULL +SELECT * FROM t1; +TIMESTAMP('2000-01-01 00:00:00.123') +2000-01-01 00:00:00.123 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT TIME'10:20:30.1234567'; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIME'10:20:30.1234567' time(6) NO 00:00:00.000000 +SELECT * FROM t1; +TIME'10:20:30.1234567' +10:20:30.123457 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(1)); +INSERT INTO t1 VALUES ('1.1'); +SELECT * FROM t1; +a +00:00:01.1 +DROP TABLE t1; +SET time_zone='+00:00'; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 20:40:05.123456'); +CREATE TABLE t1 AS SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP(6)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `UNIX_TIMESTAMP(CURRENT_TIMESTAMP(6))` decimal(17,6) NOT NULL DEFAULT '0.000000' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +UNIX_TIMESTAMP(CURRENT_TIMESTAMP(6)) +1316637605.123456 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +SET time_zone=DEFAULT; +SET @@timestamp=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456'); +SELECT FROM_UNIXTIME(@@timestamp); +FROM_UNIXTIME(@@timestamp) +1970-01-02 03:04:05.123456 +SET @@timestamp=default; +# +# Bugs found by Saikumar during testing. +# The below function calls made server crash. +# +SET TIMESTAMP=UNIX_TIMESTAMP('2001-01-01 00:00:00'); +SELECT ADDTIME(UTC_DATE, '23:28:14.014837') FROM dual; +ADDTIME(UTC_DATE, '23:28:14.014837') +23:28:14.014837 +SELECT SUBTIME(UTC_DATE, '04:44:03.014042') FROM dual ; +SUBTIME(UTC_DATE, '04:44:03.014042') +-04:44:03.014042 +SELECT TIMEDIFF(CURRENT_DATE, '2004-12-07') FROM dual; +TIMEDIFF(CURRENT_DATE, '2004-12-07') +-838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '-34464:00:00' +SELECT TIMEDIFF('0000-00-00 00:00:00.00000', UTC_DATE) FROM dual; +TIMEDIFF('0000-00-00 00:00:00.00000', UTC_DATE) +NULL +SELECT TIME(CURRENT_DATE) FROM dual; +TIME(CURRENT_DATE) +00:00:00 +CREATE TABLE t1 ( +pk TIMESTAMP(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +PRIMARY KEY (pk) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ('2011-07-13 13:17:58.3'), ('2011-07-13 13:17:59.3'); +SELECT EXTRACT(HOUR_SECOND FROM CURRENT_DATE) FROM t1; +EXTRACT(HOUR_SECOND FROM CURRENT_DATE) +0 +0 +DROP TABLE t1; +SET TIMESTAMP=DEFAULT; +# +# bug7 +# +CREATE TABLE t1 ( +col_timestamp_2_not_null_key timestamp(2) NULL DEFAULT '0000-00-00 00:00:00.00', +col_datetime_4_not_null_key datetime(4) NOT NULL, +KEY col_timestamp_2_not_null_key (col_timestamp_2_not_null_key), +KEY col_datetime_4_not_null_key (col_datetime_4_not_null_key)); +UPDATE t1 SET col_datetime_4_not_null_key = 9 +WHERE col_timestamp_2_not_null_key !=9; +Warnings: +Warning 1292 Incorrect datetime value: '9' for column 'col_timestamp_2_not_null_key' at row 1 +Warning 1292 Incorrect datetime value: '9' for column 'col_timestamp_2_not_null_key' at row 1 +DROP TABLE t1; +# +# bug8 +# +CREATE TABLE t1 ( +col_time_3_not_null_key time(3) NOT NULL, +col_datetime_4_not_null_key datetime(4) NOT NULL, +KEY col_time_3_not_null_key (col_time_3_not_null_key), +KEY col_datetime_4_not_null_key (col_datetime_4_not_null_key)); +SELECT col_time_3_not_null_key +FROM t1 +WHERE col_datetime_4_not_null_key > 7; +col_time_3_not_null_key +Warnings: +Warning 1292 Incorrect datetime value: '7' for column 'col_datetime_4_not_null_key' at row 1 +Warning 1292 Incorrect datetime value: '7' for column 'col_datetime_4_not_null_key' at row 1 +Warning 1292 Incorrect datetime value: '7' for column 'col_datetime_4_not_null_key' at row 1 +Warning 1292 Incorrect datetime value: '7' for column 'col_datetime_4_not_null_key' at row 1 +DROP TABLE t1; +# +# bug9 +# +CREATE TABLE t1 ( col_time_3_key time(3) DEFAULT NULL, col_datetime_5_not_null datetime(5) NOT NULL, pk datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', PRIMARY KEY (pk), KEY col_time_3_key (col_time_3_key)); +INSERT INTO t1 VALUES +(NULL,'2003-02-10 18:14:45.03977','2011-07-16 20:53:44.979841'), +('07:57:19.051','0000-00-00 00:00:00.00000','2011-07-16 20:53:45.979841'), +('05:18:39.031','0000-00-00 00:00:00.00000','2011-07-16 20:53:46.979841'), +('12:15:34.041','2001-12-22 00:00:00.00000','2011-07-16 20:53:47.979841'), +('03:40:59.005','0000-00-00 00:00:00.00000','2011-07-16 20:53:48.979841'), +('01:41:57.004','0000-00-00 00:00:00.00000','2011-07-16 20:53:49.979841'); +SELECT col_datetime_5_not_null +FROM t1 +WHERE TIMESTAMPADD(QUARTER, 5, col_time_3_key); +col_datetime_5_not_null +Warnings: +Warning 1441 Datetime function: time field overflow +Warning 1441 Datetime function: time field overflow +Warning 1441 Datetime function: time field overflow +Warning 1441 Datetime function: time field overflow +Warning 1441 Datetime function: time field overflow +DROP TABLE t1; +# +# bug10 +# +CREATE TABLE t1 ( +col_time_1_not_null_key time(1) NOT NULL, +col_time_2_key time(2) DEFAULT NULL, +col_datetime_6_not_null_key datetime(6) NOT NULL, +col_datetime_4_not_null_key datetime(4) NOT NULL, +col_datetime_6_key datetime(6) DEFAULT NULL, +col_timestamp_4_key timestamp(4) NULL DEFAULT '0000-00-00 00:00:00.0000', +col_timestamp_5_key timestamp(5) NULL DEFAULT '0000-00-00 00:00:00.00000', +col_datetime_key datetime DEFAULT NULL, +col_datetime_5_not_null_key datetime(5) NOT NULL, +col_time_5_key time(5) DEFAULT NULL, +col_datetime_3_key datetime(3) DEFAULT NULL, +pk datetime NOT NULL DEFAULT '0000-00-00 00:00:00', +col_time_not_null_key time NOT NULL, +col_time_4_not_null_key time(4) NOT NULL, +PRIMARY KEY (pk), +KEY col_time_1_not_null_key (col_time_1_not_null_key), +KEY col_time_2_key (col_time_2_key), +KEY col_datetime_6_not_null_key (col_datetime_6_not_null_key), +KEY col_datetime_4_not_null_key (col_datetime_4_not_null_key), +KEY col_datetime_6_key (col_datetime_6_key), +KEY col_timestamp_4_key (col_timestamp_4_key), +KEY col_timestamp_5_key (col_timestamp_5_key), +KEY col_datetime_key (col_datetime_key), +KEY col_datetime_5_not_null_key (col_datetime_5_not_null_key), +KEY col_time_5_key (col_time_5_key), +KEY col_datetime_3_key (col_datetime_3_key), +KEY col_time_not_null_key (col_time_not_null_key), +KEY col_time_4_not_null_key (col_time_4_not_null_key)) +/*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +SELECT col_datetime_3_key , COUNT( col_timestamp_5_key ) +FROM t1 FORCE KEY +(PRIMARY, col_datetime_5_not_null_key, col_datetime_6_key, col_time_5_key, col_time_2_key) +WHERE +(col_time_4_not_null_key NOT +BETWEEN '2002-01-01 21:50:38.023562' AND '20090504151448.022774' + AND col_time_1_not_null_key IN +('2000-07-13 21:35:51.034786', +'2004-10-13 19:51:18.029716', +'2001-11-23 10:22:42.001689', +'2001-12-07 06:56:47.034426', +'20081109153313.042580' + ) +) +AND +(col_timestamp_4_key BETWEEN '0000-00-00 00:00:00' AND '2008-06-16 10:42:11.032174' + OR +col_time_not_null_key BETWEEN '2007-02-13 14:29:42.008072' AND '2009-05-18 17:06:18.036503' + ) +AND +( +(col_datetime_key <> '2004-09-06 19:57:07.024714') +AND col_datetime_5_not_null_key NOT IN +('20061212182915.005997', +'0000-00-00 00:00:00', +'20000920051358.001283', +'2000-09-03 00:07:36.061713' + ) +) +AND +(col_datetime_4_not_null_key IS NULL OR col_time_5_key BETWEEN '20051201163954.001782' AND '0000-00-00 00:00:00') +GROUP BY col_datetime_6_not_null_key; +col_datetime_3_key COUNT( col_timestamp_5_key ) +DROP TABLE t1; +# +# bug11 +# +CREATE TABLE t1 ( +col_time_5 time(5) DEFAULT NULL, +col_time_1_not_null time(1) NOT NULL, +col_time_2_key time(2) DEFAULT NULL, +col_timestamp_2_not_null timestamp(2) NULL DEFAULT '0000-00-00 00:00:00.00', +col_datetime_not_null datetime NOT NULL, +col_timestamp_3_not_null_key timestamp(3) NULL DEFAULT '0000-00-00 00:00:00.000', +col_datetime_5_key datetime(5) DEFAULT NULL, +pk time(3) NOT NULL DEFAULT '00:00:00.000', +PRIMARY KEY (pk), +KEY col_time_2_key (col_time_2_key), +KEY col_timestamp_3_not_null_key (col_timestamp_3_not_null_key), +KEY col_datetime_5_key (col_datetime_5_key)) +/*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ( +'00:20:00.00000', +'15:50:06.1', +'00:20:07.00', +'0000-00-00 00:00:00.00', +'2009-07-16 09:31:21', +'2009-10-14 21:00:00.000', +'0000-00-00 00:00:00.00000', +'22:59:36.734'); +SELECT col_datetime_5_key AS c1 +FROM t1 +WHERE col_datetime_not_null NOT BETWEEN col_time_5 AND +LEAST(col_time_1_not_null, +ADDDATE(CAST(col_time_2_key AS DATE), +col_timestamp_2_not_null)) +ORDER BY 1; +c1 +0000-00-00 00:00:00.00000 +DROP TABLE t1; +# +# bug13 +# +SET timestamp=UNIX_TIMESTAMP('2011-07-31 10:00:00'); +CREATE TABLE t1 ( +col_datetime_2_not_null_key datetime(2) NOT NULL, +col_datetime_5 datetime(5) DEFAULT NULL, +col_time_key time DEFAULT NULL, +col_time_not_null time NOT NULL, +pk datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000', +PRIMARY KEY (pk), +KEY col_datetime_2_not_null_key (col_datetime_2_not_null_key), +KEY col_time_key (col_time_key)); +INSERT INTO t1 VALUES +('2001-10-20 00:00:00.00','2001-09-20 11:18:18.03630','03:00:10','00:20:01','2011-07-19 17:37:06.26725'), +('0000-00-00 00:00:00.00','0000-00-00 00:00:00.00000','08:30:41','00:20:01','2011-07-19 17:37:07.26725'), +('0000-00-00 00:00:00.00','0000-00-00 00:00:00.00000','20:07:31','01:12:26','2011-07-19 17:37:08.26725'), +('2000-01-14 17:55:57.03','0000-00-00 00:00:00.00000','00:20:04','14:35:10','2011-07-19 17:37:09.26725'), +('2006-12-27 07:25:14.04',NULL,'08:07:59','07:58:50','2011-07-19 17:37:10.26725'), +('2000-10-17 22:03:12.01','0000-00-00 00:00:00.00000','00:20:02','23:21:51','2011-07-19 17:37:11.26725'), +('0000-00-00 00:00:00.00','0000-00-00 00:00:00.00000','00:20:05','00:20:04','2011-07-19 17:37:12.26725'), +('0000-00-00 00:00:00.00','0000-00-00 00:00:00.00000','00:20:04','23:19:52','2011-07-19 17:37:13.26725'), +('0000-00-00 00:00:00.00','2008-06-04 23:05:50.03642','00:20:03','22:28:03','2011-07-19 17:37:14.26725'), +('2000-10-22 23:52:09.01',NULL,'00:20:07','00:20:07','2011-07-19 17:37:15.26725'); +SELECT col_datetime_2_not_null_key AS c1, col_time_not_null AS c2 +FROM t1 +WHERE +pk = LEAST(STR_TO_DATE(DATE_FORMAT(col_time_key, +CONCAT_WS( ':','%I','%m' )) , +CONCAT_WS('-','%y','%H','%V','%k','%k' )), +'0000-00-00') +OR +col_datetime_5 = CURRENT_DATE() +ORDER BY 1; +c1 c2 +Warnings: +Warning 1411 Incorrect datetime value: '03:07' for function str_to_date +Warning 1411 Incorrect datetime value: '08:07' for function str_to_date +Warning 1411 Incorrect datetime value: '08:07' for function str_to_date +Warning 1411 Incorrect datetime value: '12:07' for function str_to_date +Warning 1411 Incorrect datetime value: '08:07' for function str_to_date +Warning 1411 Incorrect datetime value: '12:07' for function str_to_date +Warning 1411 Incorrect datetime value: '12:07' for function str_to_date +Warning 1411 Incorrect datetime value: '12:07' for function str_to_date +Warning 1411 Incorrect datetime value: '12:07' for function str_to_date +Warning 1411 Incorrect datetime value: '12:07' for function str_to_date +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# bug15 +# +CREATE TABLE t1 ( +col_datetime_5 datetime(5) DEFAULT NULL, +col_timestamp_6_key timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', +col_time_2_not_null time(2) NOT NULL, +KEY col_timestamp_6_key (col_timestamp_6_key)) +ENGINE=MEMORY DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (current_timestamp(5),current_timestamp(6),current_time(6)); +SELECT col_datetime_5 AS c1 FROM t1 +WHERE col_time_2_not_null = GREATEST(CURRENT_DATE(),col_timestamp_6_key) +ORDER BY 1; +c1 +DROP TABLE t1; +SET @@time_zone='+00:00'; +CREATE TABLE t1 (col_datetime_4_not_null DATETIME(4) NOT NULL); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00.0000'),('2006-05-12 07:06:44.0441'),('2007-11-08 00:00:00.0000'), +('2007-07-23 00:00:00.0000'),('2006-01-10 22:19:14.0158'),('2006-09-13 18:54:05.0013'), +('2002-03-26 00:00:00.0000'),('2002-10-22 10:53:06.0151'),('0000-00-00 00:00:00.0000'), +('2001-06-04 00:00:00.0000'),('0000-00-00 00:00:00.0000'),('2000-12-11 10:47:58.0505'), +('2009-04-21 20:01:40.0570'),('2007-03-12 10:48:41.0031'),('0000-00-00 00:00:00.0000'), +('2009-06-22 00:00:00.0000'),('2008-01-21 15:28:44.0592'),('2003-10-05 00:43:55.0577'), +('2002-11-04 00:46:30.0630'),('2006-01-19 11:38:03.0378'),('0000-00-00 00:00:00.0000'), +('2001-02-04 00:00:00.0000'),('2004-10-22 21:59:04.0394'),('2006-03-20 18:54:13.0139'), +('2004-06-09 03:17:31.0403'),('0000-00-00 00:00:00.0000'),('2003-06-01 17:59:12.0365'), +('0000-00-00 00:00:00.0000'),('2009-06-15 08:58:58.0329'),('0000-00-00 00:00:00.0000'), +('2004-03-26 00:00:00.0000'),('2009-04-27 00:00:00.0000'),('2000-09-07 00:00:00.0000'), +('2006-11-04 00:51:03.0501'),('2005-02-20 00:30:47.0647'),('0000-00-00 00:00:00.0000'), +('2004-12-07 00:00:00.0000'),('0000-00-00 00:00:00.0000'),('0000-00-00 00:00:00.0000'), +('2002-08-17 00:27:20.0536'),('2006-10-12 12:12:28.0337'),('0000-00-00 00:00:00.0000'), +('0000-00-00 00:00:00.0000'),('2009-09-09 14:16:05.0354'),('2000-02-25 00:00:00.0000'), +('2003-12-16 05:38:37.0626'),('2000-10-05 03:46:43.0067'),('0000-00-00 00:00:00.0000'), +('2000-10-08 06:45:51.0547'),('0000-00-00 00:00:00.0000'),('2000-04-06 01:46:21.0620'), +('2001-08-10 23:15:40.0304'),('2001-06-24 10:14:00.0497'),('0000-00-00 00:00:00.0000'), +('0000-00-00 00:00:00.0000'),('2004-10-22 00:00:00.0000'),('0000-00-00 00:00:00.0000'), +('0000-00-00 00:00:00.0000'),('2005-08-23 06:34:23.0058'),('2005-03-28 18:34:18.0138'), +('2004-05-18 00:00:00.0000'); +SELECT UNIX_TIMESTAMP(col_datetime_4_not_null) FROM t1 ORDER BY 1; +UNIX_TIMESTAMP(col_datetime_4_not_null) +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +0.0000 +951436800.0000 +954985581.0620 +968284800.0000 +970717603.0067 +970987551.0547 +976531678.0505 +981244800.0000 +991612800.0000 +993377640.0497 +997485340.0304 +1017100800.0000 +1029544040.0536 +1035283986.0151 +1036370790.0630 +1054490352.0365 +1065314635.0577 +1071553117.0626 +1080259200.0000 +1084838400.0000 +1086751051.0403 +1098403200.0000 +1098482344.0394 +1102377600.0000 +1108859447.0647 +1112034858.0138 +1124778863.0058 +1136931554.0158 +1137670683.0378 +1142880853.0139 +1147417604.0441 +1158173645.0013 +1160655148.0337 +1162601463.0501 +1173696521.0031 +1185148800.0000 +1194480000.0000 +1200929324.0592 +1240344100.0570 +1240790400.0000 +1245056338.0329 +1245628800.0000 +1252505765.0354 +DROP TABLE t1; +SET @@time_zone=DEFAULT; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 10:20:30.123456'); +CREATE TABLE t1 +( +col_timestamp_4_not_null_key TIMESTAMP(4) NULL DEFAULT '0000-00-00 00:00:00.0000', +col_datetime_6_not_null DATETIME(6) NOT NULL, +col_time_2_not_null TIME(2) NOT NULL, +pk TIME(5) NOT NULL DEFAULT '00:00:00.00000', +col_timestamp_5_not_null_key TIMESTAMP(5) NULL DEFAULT '0000-00-00 00:00:00.00000', +PRIMARY KEY (pk), +KEY col_timestamp_4_not_null_key (col_timestamp_4_not_null_key), +KEY col_timestamp_5_not_null_key (col_timestamp_5_not_null_key) +) /*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +SELECT +LEAST('2008-05-18', LOCALTIMESTAMP(), col_timestamp_5_not_null_key ) AS c1 +FROM t1 +WHERE col_time_2_not_null = TIME +(STR_TO_DATE +(DATE_FORMAT +(DATE('2009-05-04'), +CONCAT_WS(':', '%M', '%a', '%x', '%S', '%j' )), +CONCAT_WS('-', '%V', '%S', '%U' ))) +AND +col_timestamp_4_not_null_key +BETWEEN CURDATE() +AND STR_TO_DATE(DATE_FORMAT(col_datetime_6_not_null, +CONCAT_WS('-', '%I', '%S', '%v' )), +CONCAT_WS('-', '%V', '%H' )); +c1 +Warnings: +Warning 1411 Incorrect datetime value: 'May:Mon:2009:00:124' for function str_to_date +DROP TABLE t1; +SET @@timestamp=DEFAULT; +SET @@timestamp= UNIX_TIMESTAMP('2011-09-21 08:20:30.123456'); +CREATE TABLE t1 ( +col_datetime_6 DATETIME(6) DEFAULT NULL, +col_time_1_key TIME(1) DEFAULT NULL, +col_time_4_key TIME(4) DEFAULT NULL, +col_time_1 TIME(1) DEFAULT NULL, +pk TIME(4) NOT NULL DEFAULT '00:00:00.0000', +col_time_2_key TIME(2) DEFAULT NULL, +col_datetime DATETIME DEFAULT NULL, +col_datetime_5_not_null DATETIME(5) NOT NULL, +col_time_3_key TIME(3) DEFAULT NULL, +col_time_3 TIME(3) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_1_key (col_time_1_key), +KEY col_time_4_key (col_time_4_key), +KEY col_time_2_key (col_time_2_key), +KEY col_time_3_key (col_time_3_key) +)/*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ('2004-06-28 22:47:21.052552','17:11:33.0','00:20:09.0000','00:20:04.0','02:05:58.4461','08:36:44.02','0000-00-00 00:00:00','0000-00-00 00:00:00.00000','02:17:50.049','07:31:13.030'); +SELECT col_datetime_6 AS c1, col_datetime AS c2 +FROM t1 +WHERE col_time_2_key +NOT BETWEEN +SUBTIME(DATE('0000-00-00 00:00:00'), '19:30:30.005477' ) +AND CURRENT_TIME() +ORDER BY +col_time_1, col_time_3, col_datetime_6, col_time_3_key, +col_datetime_5_not_null, col_time_1_key, col_time_4_key; +c1 c2 +2004-06-28 22:47:21.052552 0000-00-00 00:00:00 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 10:20:30'); +CREATE TABLE t1 ( +col_time_6_not_null_key TIME(6) NOT NULL, +col_time_not_null TIME NOT NULL, +pk TIME(4) NOT NULL DEFAULT '00:00:00.0000', +col_time_key TIME DEFAULT NULL, +col_time_2_not_null_key TIME(2) NOT NULL, +col_time_4 TIME(4) DEFAULT NULL, +col_time_3_not_null TIME(3) NOT NULL, +col_datetime_2 DATETIME(2) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_6_not_null_key (col_time_6_not_null_key), +KEY col_time_key (col_time_key), +KEY col_time_2_not_null_key (col_time_2_not_null_key) +) /*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ( +CURRENT_TIME(4), +CURRENT_TIME(), +CURRENT_TIME(4), +CURRENT_TIME(), +CURRENT_TIME(2), +CURRENT_TIME(4), +CURRENT_TIME(3), +CURRENT_TIMESTAMP(2)); +SELECT col_datetime_2 AS c1, col_time_not_null AS c2 +FROM t1 +WHERE +col_time_6_not_null_key > +COALESCE(col_time_2_not_null_key, col_time_4, col_time_not_null, col_time_3_not_null) +ORDER BY 1; +c1 c2 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +CREATE TABLE t1 ( +col_time_6_not_null_key TIME(6) NOT NULL, +col_time_5_key TIME(5) DEFAULT NULL, +col_timestamp TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00', +col_time_key TIME DEFAULT NULL, +col_datetime_key DATETIME DEFAULT NULL, +col_time_not_null TIME NOT NULL, +pk TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', +PRIMARY KEY (pk), +KEY col_time_6_not_null_key (col_time_6_not_null_key), +KEY col_time_5_key (col_time_5_key), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key) +) /*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES +('03:07:29.013169',NULL,'0000-00-00 00:00:00','18:29:54','2000-06-10 19:41:30', +'13:56:51','2011-09-07 23:08:20.8362'),('00:20:06.000000','08:25:11.04580', +'2009-06-16 04:33:32','00:20:04','2004-08-23 21:05:10','00:20:06', +'2011-09-07 23:08:22.8362'),('00:20:03.000000','00:20:07.00000', +'2007-05-28 13:16:25','00:26:33','0000-00-00 00:00:00','01:04:48', +'2011-09-07 23:08:24.8362'),('19:48:23.009935','00:20:07.00000', +'2009-04-09 13:29:15','00:20:01',NULL,'21:43:24','2011-09-07 23:08:26.8362'), +('00:20:01.000000','22:27:30.00296','2009-03-21 23:00:46',NULL,'2003-01-23 14:57:31', +'00:20:09','2011-09-07 23:08:28.8362'),('23:09:37.056340','07:01:38.05720', +'2006-01-25 15:25:59','00:20:05',NULL,'05:10:32','2011-09-07 23:08:19.8362'), +('09:44:10.025082','00:20:07.00000','2009-01-06 18:48:29','00:20:02', +'0000-00-00 00:00:00','00:20:00','2011-09-07 23:08:21.8362'), +('23:02:50.013380','22:48:12.05831',NULL,NULL,'2003-11-18 04:32:18','00:20:06', +'2011-09-07 23:08:23.8362'),('00:20:01.000000','16:19:55.00007', +'0000-00-00 00:00:00','07:55:21','0000-00-00 00:00:00','14:48:29', +'2011-09-07 23:08:25.8362'),('06:00:36.034953','00:20:01.00000','2007-03-15 21:00:00', +'00:20:01',NULL,'23:29:59','2011-09-07 23:08:27.8362'); +SELECT col_time_5_key AS c1, col_time_key AS c2, col_timestamp AS c3 +FROM t1 +WHERE col_time_not_null +NOT BETWEEN EXTRACT(YEAR_MONTH FROM '0000-00-00 00:00:00') +AND COALESCE (col_time_6_not_null_key, col_datetime_key) +ORDER BY 1, 2; +c1 c2 c3 +NULL 18:29:54 0000-00-00 00:00:00 +00:20:01.00000 00:20:01 2007-03-15 21:00:00 +00:20:07.00000 00:20:01 2009-04-09 13:29:15 +00:20:07.00000 00:26:33 2007-05-28 13:16:25 +16:19:55.00007 07:55:21 0000-00-00 00:00:00 +22:27:30.00296 NULL 2009-03-21 23:00:46 +DROP TABLE t1; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 10:20:30.123456'); +CREATE TABLE t1 ( +col_time_5_not_null TIME(5) NOT NULL, +col_timestamp_4_not_null_key TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', +col_timestamp_1 TIMESTAMP(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +pk TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', +col_date_key date DEFAULT NULL, +col_time TIME DEFAULT NULL, +col_timestamp TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', +col_time_3_not_null_key TIME(3) NOT NULL, +PRIMARY KEY (pk), +KEY col_timestamp_4_not_null_key (col_timestamp_4_not_null_key), +KEY col_date_key (col_date_key), +KEY col_time_3_not_null_key (col_time_3_not_null_key) +) ENGINE=InnoDB /*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ( +CURRENT_TIME(5), +CURRENT_TIMESTAMP(4), +CURRENT_TIMESTAMP(1), +CURRENT_TIMESTAMP(), +CURRENT_DATE(), +CURRENT_TIME(), +CURRENT_TIMESTAMP(),CURRENT_TIME()); +SELECT col_time_3_not_null_key AS c1 +FROM t1 +WHERE col_timestamp <> col_date_key +AND col_time <=> MAKETIME(24, 60, 4) +ORDER BY 1; +c1 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 09:30:40'); +CREATE TABLE t1 ( +col_datetime_5 DATETIME(5) DEFAULT NULL, +col_time_2_key TIME(2) DEFAULT NULL, +col_time_3_not_null TIME(3) NOT NULL, +col_timestamp_1 TIMESTAMP(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +col_time_4_key TIME(4) DEFAULT NULL, +col_datetime_3_key DATETIME(3) DEFAULT NULL, +col_time_not_null TIME NOT NULL, +col_time_6_key TIME(6) DEFAULT NULL, +col_time_5_not_null TIME(5) NOT NULL, +col_datetime_2_not_null DATETIME(2) NOT NULL, +col_datetime_4 DATETIME(4) DEFAULT NULL, +col_time_5 TIME(5) DEFAULT NULL, +col_datetime_3 DATETIME(3) DEFAULT NULL, +col_timestamp_2_not_null_key TIMESTAMP(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', +col_time_3_key TIME(3) DEFAULT NULL, +col_time_6_not_null_key TIME(6) NOT NULL, +col_timestamp_2_key TIMESTAMP(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', +col_timestamp_3 TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', +col_timestamp_6 TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', +col_date date DEFAULT NULL, +col_timestamp_3_not_null TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', +col_datetime_1_not_null_key DATETIME(1) NOT NULL, +KEY col_time_2_key (col_time_2_key), +KEY col_time_4_key (col_time_4_key), +KEY col_datetime_3_key (col_datetime_3_key), +KEY col_time_6_key (col_time_6_key), +KEY col_timestamp_2_not_null_key (col_timestamp_2_not_null_key), +KEY col_time_3_key (col_time_3_key), +KEY col_time_6_not_null_key (col_time_6_not_null_key), +KEY col_timestamp_2_key (col_timestamp_2_key), +KEY col_datetime_1_not_null_key (col_datetime_1_not_null_key) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00.00000','00:20:08.00','00:20:01.000','0000-00-00 00:00:00.0','00:20:01.0000','0000-00-00 00:00:00.000','00:20:04','09:45:20.061990','00:20:09.00000','0000-00-00 00:00:00.00','0000-00-00 00:00:00.0000','00:20:04.00000','2001-05-23 09:36:42.052','2009-01-05 21:00:00.00','00:20:05.000','14:46:32.052047','2002-11-17 18:55:09.02','0000-00-00 00:00:00.000','2008-09-13 21:00:00.000000','2008-08-19','2007-02-10 21:00:00.000','0000-00-00 00:00:00.0'), +('2000-07-14 05:54:53.06239','00:20:05.00','00:20:05.000','1999-12-31 21:00:00.0','07:03:39.0208','2000-08-23 21:06:58.019','00:20:04','00:20:02.000000','15:44:52.01936','2005-11-17 00:00:00.00','2004-08-13 00:00:00.0000','06:06:48.02990','2006-09-05 02:09:02.053','2002-05-20 13:05:03.02','16:55:37.028','18:50:32.053805','2006-07-19 07:48:53.03','2007-03-18 04:55:22.063','2005-03-03 01:11:52.063987','2000-11-21','2006-01-03 23:43:37.061','2004-03-24 11:09:52.0'), +('0000-00-00 00:00:00.00000','18:28:33.04','00:20:01.000','2000-01-26 21:00:00.0','00:20:04.0000','0000-00-00 00:00:00.000','00:20:04','05:34:26.042699','00:40:37.02528','0000-00-00 00:00:00.00','2005-10-05 00:00:00.0000','23:03:38.03254','2002-07-10 00:00:00.000','2004-08-17 21:00:00.00','00:20:09.000','00:20:02.000000','2007-04-28 12:39:49.01','2009-10-19 21:00:00.000','2002-10-15 22:19:51.010640','2004-09-02','2000-06-03 21:00:00.000','2006-01-21 21:56:34.1'), +('2002-06-04 00:00:00.00000','17:18:15.01','00:20:07.000','0000-00-00 00:00:00.0','00:20:08.0000','0000-00-00 00:00:00.000','00:20:02','03:08:54.060553','07:16:55.00371','2004-05-23 00:18:17.06','2006-10-15 07:36:25.0250','21:17:33.03725','0000-00-00 00:00:00.000','2006-01-09 21:00:00.00','17:37:00.021','20:34:56.023570','2006-07-19 12:40:27.03','0000-00-00 00:00:00.000','0000-00-00 00:00:00.000000','0000-00-00','2001-02-17 08:11:26.052','0000-00-00 00:00:00.0'), +('2008-06-08 06:20:14.03026','00:20:02.00','00:20:09.000','2005-04-05 12:46:20.0','17:11:24.0634','2002-11-21 00:00:00.000','10:43:56','00:20:08.000000','00:20:07.00000','2008-05-13 10:13:26.06','2001-04-17 00:00:00.0000','01:47:22.02812','2009-09-16 14:44:14.026','0000-00-00 00:00:00.00','00:20:01.000','01:09:04.037569','2004-07-22 03:01:37.04','0000-00-00 00:00:00.000','2001-05-21 21:00:00.000000','0000-00-00','0000-00-00 00:00:00.000','0000-00-00 00:00:00.0'), +('0000-00-00 00:00:00.00000','00:20:08.00','12:51:21.056','0000-00-00 00:00:00.0','00:39:29.0565','2003-01-04 00:00:00.000','01:19:53','00:20:05.000000','17:19:59.03478','2001-07-12 00:00:00.00','2008-12-16 13:56:12.0187','00:21:45.00721','0000-00-00 00:00:00.000','0000-00-00 00:00:00.00','13:54:49.005','00:20:07.000000','2004-02-23 10:21:57.02','0000-00-00 00:00:00.000','0000-00-00 00:00:00.000000','2005-10-10','2000-07-10 21:37:07.038','0000-00-00 00:00:00.0'), +('0000-00-00 00:00:00.00000','23:11:02.06','00:20:04.000','2002-09-06 08:31:08.0','20:03:26.0050','0000-00-00 00:00:00.000','09:40:06','17:18:46.036378','01:21:25.03109','0000-00-00 00:00:00.00','2005-11-11 12:10:13.0077','00:20:09.00000','0000-00-00 00:00:00.000','0000-00-00 00:00:00.00','09:04:28.034','00:20:08.000000','0000-00-00 00:00:00.00','2009-07-28 08:02:12.002','0000-00-00 00:00:00.000000','2005-04-06','2006-06-09 07:10:23.064','0000-00-00 00:00:00.0'), +('0000-00-00 00:00:00.00000','00:20:09.00','04:15:43.040','2002-09-15 21:00:00.0','00:20:03.0000','0000-00-00 00:00:00.000','11:07:33','00:20:00.000000','00:20:09.00000','0000-00-00 00:00:00.00','0000-00-00 00:00:00.0000','04:06:54.01875','2001-12-06 21:09:30.042','2002-09-23 22:33:09.03','13:56:42.014','07:56:26.029465','0000-00-00 00:00:00.00','2001-05-19 19:41:58.064','2006-03-28 06:12:25.002048','0000-00-00','0000-00-00 00:00:00.000','0000-00-00 00:00:00.0'), +('2008-05-22 00:00:00.00000','21:46:17.04','00:20:00.000','2004-05-01 21:00:00.0','00:20:04.0000','0000-00-00 00:00:00.000','16:08:23','00:20:00.000000','00:39:12.04586','2001-08-25 00:00:00.00','2003-09-08 20:19:27.0197','16:01:03.03502','2005-02-14 00:00:00.000','0000-00-00 00:00:00.00','13:29:52.038','00:20:02.000000','2004-10-07 23:51:00.06','2009-02-03 23:21:26.017','0000-00-00 00:00:00.000000','0000-00-00','0000-00-00 00:00:00.000','2004-09-13 00:00:00.0'), +('2005-10-13 00:00:00.00000','00:20:08.00','18:41:54.050','2007-09-10 21:00:00.0','01:55:43.0424','0000-00-00 00:00:00.000','00:20:07','06:49:20.035790','00:20:04.00000','0000-00-00 00:00:00.00','2008-02-13 10:19:26.0346','00:20:01.00000','0000-00-00 00:00:00.000','0000-00-00 00:00:00.00','15:01:22.011','18:47:41.003944','2008-02-11 21:00:00.00','0000-00-00 00:00:00.000','2005-02-17 12:54:03.001418','2000-08-18','0000-00-00 00:00:00.000','2004-09-19 23:37:42.0'); +SELECT col_timestamp_3 AS c1, col_date AS c2, CURTIME() AS c3 +FROM t1 +WHERE col_time_3_not_null NOT IN +(col_time_not_null, +CAST(col_time_5 AS DATETIME(3)), +MAKEDATE(DAYOFMONTH('2002-09-13'), DATEDIFF('2009-12-15', col_timestamp_6)), +CURRENT_DATE()) +AND +col_time_3_key NOT +BETWEEN LEAST(CURRENT_TIME(), TIMESTAMPADD(HOUR, 187, MAKETIME(209, 60, 1))) +AND CURTIME() +AND col_datetime_2_not_null NOT IN +(DATE('2009-03-28'), col_timestamp_2_not_null_key, +ADDDATE(col_timestamp_2_key, 28), +col_datetime_3, +UTC_DATE()) +OR col_time_6_key IS NOT NULL +AND col_timestamp_3_not_null IN +(col_timestamp_1, col_datetime_3_key, col_time_4_key) +OR col_time_6_not_null_key +BETWEEN TIMESTAMP('0000-00-00', '16:50:23.062015') +AND col_datetime_5 +AND col_datetime_4 >= col_time_2_key +AND col_time_5_not_null +BETWEEN col_timestamp_3_not_null +AND col_datetime_1_not_null_key +ORDER BY col_time_4_key, col_datetime_3_key; +c1 c2 c3 +2001-05-19 19:41:58.064 0000-00-00 09:30:40 +2009-02-03 23:21:26.017 0000-00-00 09:30:40 +0000-00-00 00:00:00.000 2000-08-18 09:30:40 +2007-03-18 04:55:22.063 2000-11-21 09:30:40 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +CREATE TABLE t1 ( +col_datetime_1_key DATETIME(1) DEFAULT NULL, +col_time_5_not_null_key TIME(5) NOT NULL, +col_datetime_2_not_null DATETIME(2) NOT NULL, +pk DATETIME(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', +col_time_2_not_null_key TIME(2) NOT NULL, +col_time_2_key TIME(2) DEFAULT NULL, +col_timestamp_3_not_null TIMESTAMP(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', +col_timestamp_4 TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', +PRIMARY KEY (pk), +KEY col_datetime_1_key (col_datetime_1_key), +KEY col_time_5_not_null_key (col_time_5_not_null_key), +KEY col_time_2_not_null_key (col_time_2_not_null_key), +KEY col_time_2_key (col_time_2_key) +)/*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ('2007-11-05 00:00:00.0','00:20:01.00000','0000-00-00 00:00:00.00','0000-00-00 00:00:00.00','00:20:08.00','07:54:36.06','0000-00-00 00:00:00.000','2008-02-19 21:00:00.0000'),('2001-09-22 23:10:01.0','00:20:00.00000','0000-00-00 00:00:00.00','2011-09-09 20:59:53.03','00:20:01.00','00:20:02.00','0000-00-00 00:00:00.000','2003-07-11 13:55:04.0379'),('2007-10-20 00:00:00.0','22:15:28.06072','0000-00-00 00:00:00.00','2011-09-09 20:59:54.03','00:20:03.00','00:20:07.00','0000-00-00 00:00:00.000','0000-00-00 00:00:00.0000'),('0000-00-00 00:00:00.0','00:20:03.00000','2009-01-27 00:00:00.00','2011-09-09 20:59:55.03','03:34:18.06','14:32:24.01','0000-00-00 00:00:00.000','2003-11-17 09:58:11.0160'),('2008-04-10 00:00:00.0','00:20:05.00000','2004-10-16 01:19:20.06','2011-09-09 20:59:56.03','21:14:08.05','02:32:00.04','2008-09-15 17:48:32.047','2003-01-16 21:00:00.0000'),('0000-00-00 00:00:00.0','00:20:03.00000','0000-00-00 00:00:00.00','2011-09-09 20:59:57.03','00:20:05.00','22:08:39.02','0000-00-00 00:00:00.000','2003-03-19 02:39:29.0637'),('2009-04-10 21:16:38.0','00:20:07.00000','2001-05-17 15:25:33.04','2011-09-09 20:59:58.03','00:20:05.00','09:36:28.04','2005-01-12 10:44:24.031','0000-00-00 00:00:00.0000'),('2001-06-10 20:23:08.0','07:38:25.03484','2002-06-22 00:00:00.00','2011-09-09 20:59:59.03','02:05:30.01','04:24:09.06','2002-05-25 21:00:00.000','2006-05-16 06:48:03.0399'); +SELECT +col_datetime_2_not_null AS c1, +col_time_2_key AS c2, +col_time_5_not_null_key AS c3 +FROM t1 +WHERE col_time_2_not_null_key NOT IN +(TIMESTAMP(MAKEDATE(19 + 0, 213)), +MAKEDATE(46, DATEDIFF('0000-00-00 00:00:00', '0000-00-00 00:00:00'))) +AND col_datetime_1_key IS NULL +OR col_timestamp_4 < col_timestamp_3_not_null +ORDER BY 1; +c1 c2 c3 +2001-05-17 15:25:33.04 09:36:28.04 00:20:07.00000 +2004-10-16 01:19:20.06 02:32:00.04 00:20:05.00000 +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' +Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' +DROP TABLE t1; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 10:20:30.123456'); +CREATE TABLE t1 ( +col_time_1_not_null TIME(1) NOT NULL, +col_time_6 TIME(6) DEFAULT NULL, +col_datetime_6_not_null_key DATETIME(6) NOT NULL, +col_timestamp_key TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00', +col_timestamp_2 TIMESTAMP(2) NULL DEFAULT '0000-00-00 00:00:00.00', +col_timestamp_not_null TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00', +col_timestamp TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00', +pk DATETIME(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000', +col_time_6_not_null TIME(6) NOT NULL, +col_datetime_3_not_null DATETIME(3) NOT NULL, +PRIMARY KEY (pk), +KEY col_datetime_6_not_null_key (col_datetime_6_not_null_key), +KEY col_timestamp_key (col_timestamp_key) +) /*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ( +CURRENT_TIME(1), +CURRENT_TIME(6), +CURRENT_TIMESTAMP(6), +CURRENT_TIMESTAMP(), +CURRENT_TIMESTAMP(2), +CURRENT_TIMESTAMP(), +CURRENT_TIMESTAMP, +CURRENT_TIMESTAMP(3), +CURRENT_TIME(6), +CURRENT_TIMESTAMP(3)); +SELECT col_timestamp_not_null AS c1, col_datetime_6_not_null_key AS c2 +FROM t1 +WHERE col_timestamp IS NOT NULL +AND col_timestamp_2 <> col_time_1_not_null +AND col_timestamp_key BETWEEN col_datetime_3_not_null AND CURRENT_TIME() +OR col_time_6_not_null != LEAST(col_time_6, UTC_TIME()); +c1 c2 +2011-09-21 10:20:30 2011-09-21 10:20:30.123456 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 10:20:30.123456'); +CREATE TABLE t1 ( +col_timestamp_2 TIMESTAMP(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', +col_datetime_5 DATETIME(5) DEFAULT NULL, +col_time_3 TIME(3) DEFAULT NULL, +col_time_4_not_null TIME(4) NOT NULL, +col_datetime_5_not_null DATETIME(5) NOT NULL, +col_timestamp_5_key TIMESTAMP(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000', +col_time_1_not_null_key TIME(1) NOT NULL, +col_datetime DATETIME DEFAULT NULL, +col_timestamp_4 TIMESTAMP(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000', +KEY col_timestamp_5_key (col_timestamp_5_key), +KEY col_time_1_not_null_key (col_time_1_not_null_key) +); +INSERT INTO t1 VALUES ( +CURRENT_TIMESTAMP(2), +CURRENT_TIMESTAMP(5), +CURRENT_TIME(3), +CURRENT_TIME(4), +CURRENT_TIMESTAMP(5), +CURRENT_TIMESTAMP(5), +CURRENT_TIME(1), +CURRENT_TIMESTAMP(), +CURRENT_TIMESTAMP(4)); +SELECT col_datetime_5_not_null AS c1, col_time_1_not_null_key AS c2 +FROM t1 +WHERE +col_time_4_not_null = MAKETIME(24, 60, 3 ) +AND +col_time_3 NOT IN ( +col_datetime_5, +UTC_DATE(), +col_timestamp_5_key, +ADDDATE('0000-00-00 00:00:00', +DATEDIFF('2001-09-21',FROM_UNIXTIME(1018888192, +CONCAT_WS('-','%s','%V','%u')))), +col_timestamp_4) +AND +col_timestamp_2 NOT BETWEEN col_datetime AND '2005-09-12' +ORDER BY 1; +c1 c2 +SELECT col_datetime_5_not_null AS c1, col_time_1_not_null_key AS c2 +FROM t1 +WHERE col_time_4_not_null=MAKETIME(24,60, 3) +AND col_time_3 NOT IN +(col_datetime_5, UTC_DATE(), col_timestamp_5_key, col_timestamp_4) +AND +col_timestamp_2 NOT BETWEEN col_datetime AND '2005-09-12' +ORDER BY 1; +c1 c2 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +SET @@timestamp=UNIX_TIMESTAMP('2011-09-21 10:20:30.123456'); +CREATE TABLE t1 ( +col_time_4_key TIME(4) DEFAULT NULL, +col_datetime_4_not_null DATETIME(4) NOT NULL, +col_timestamp_5 TIMESTAMP(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000', +col_datetime_not_null_key DATETIME NOT NULL, +col_timestamp_key TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', +KEY col_time_4_key (col_time_4_key), +KEY col_datetime_not_null_key (col_datetime_not_null_key), +KEY col_timestamp_key (col_timestamp_key) +); +INSERT INTO t1 VALUES ('00:20:08.0000','0000-00-00 00:00:00.0000','0000-00-00 00:00:00.00000','0000-00-00 00:00:00','2006-10-24 21:00:00'),('19:24:23.0232','2006-12-11 22:04:06.0393','2004-12-08 21:00:00.00000','2009-06-04 03:01:35','2003-08-19 21:00:00'); +SELECT UNIX_TIMESTAMP(col_datetime_4_not_null) AS c1 +FROM t1 +WHERE col_time_4_key NOT +BETWEEN '2001-07-06' + AND LEAST(FROM_DAYS(col_timestamp_key), col_timestamp_5) +OR CONVERT_TZ(MAKETIME(24, 5, 7), 'Japan', 'Japan') IS NULL +OR CURRENT_TIMESTAMP() IS NOT NULL +OR col_datetime_not_null_key >= UTC_TIME() +ORDER BY 1 ; +c1 +0.0000 +1165863846.0393 +DROP TABLE t1; +SET @@timestamp=DEFAULT; +CREATE TABLE t1 ( +col_time_not_null_key TIME NOT NULL, +col_datetime_5_not_null_key DATETIME(5) NOT NULL, +col_timestamp_6_key TIMESTAMP(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', +col_time_1 TIME(1) DEFAULT NULL, +pk DATETIME(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0', +col_time_2_key TIME(2) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_not_null_key (col_time_not_null_key), +KEY col_datetime_5_not_null_key (col_datetime_5_not_null_key), +KEY col_timestamp_6_key (col_timestamp_6_key), +KEY col_time_2_key (col_time_2_key) +)/*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ('00:20:02','2007-08-09 05:14:12.05054','2007-06-20 21:00:00.000000','06:16:36.0','2011-09-09 21:37:45.2','19:15:37.02'),('18:00:14','0000-00-00 00:00:00.00000','2000-12-10 12:35:01.029761','00:20:04.0','2011-09-09 21:37:46.2','06:21:03.03'); +SELECT col_time_1 AS c1 +FROM t1 +WHERE col_time_not_null_key <= col_timestamp_6_key +AND col_time_2_key > SUBTIME('2006-07-16', '05:05:02.040778') +ORDER BY col_datetime_5_not_null_key, col_time_1; +c1 +Warnings: +Warning 1292 Truncated incorrect time value: '2006-07-16' +Warning 1292 Truncated incorrect time value: '2006-07-16' +DROP TABLE t1; +CREATE TABLE t1 ( +col_timestamp_3_not_null_key timestamp(3) NULL DEFAULT '0000-00-00 00:00:00.000', +pk time(1) NOT NULL DEFAULT '00:00:00.0', +col_datetime_6 datetime(6) DEFAULT NULL, +col_time_5_not_null_key time(5) NOT NULL, +col_timestamp_1_not_null_key timestamp(1) NULL DEFAULT '0000-00-00 00:00:00.0', +col_datetime_4_key datetime(4) DEFAULT NULL, +col_time_2_not_null_key time(2) NOT NULL, +PRIMARY KEY (pk), +KEY col_timestamp_3_not_null_key (col_timestamp_3_not_null_key), +KEY col_time_5_not_null_key (col_time_5_not_null_key), +KEY col_timestamp_1_not_null_key (col_timestamp_1_not_null_key), +KEY col_datetime_4_key (col_datetime_4_key), +KEY col_time_2_not_null_key (col_time_2_not_null_key) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000','14:09:27.6','0000-00-00 00:00:00.000000','18:38:36.04289','2003-07-01 21:00:00.0','2009-09-15 09:25:49.0110','15:47:52.01'); +INSERT INTO t1 VALUES ('2004-04-08 23:25:16.012','14:09:26.6',NULL,'05:45:23.05509','2008-12-11 21:00:00.0','2001-04-23 20:41:27.0470','05:09:23.04'); +SELECT SUBTIME(col_timestamp_3_not_null_key , SYSDATE()) AS c1 FROM t1 +WHERE col_timestamp_1_not_null_key NOT IN +(col_datetime_4_key , GREATEST(DATE('2006-04-26'), UTC_DATE())) +ORDER BY col_datetime_6 , col_time_2_not_null_key , col_time_5_not_null_key; +DROP TABLE t1; +CREATE TABLE t1 ( +col_time_1_not_null_key time(1) NOT NULL, +pk timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', +col_datetime_3_not_null_key datetime(3) NOT NULL, +col_time_2_key time(2) DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_1_not_null_key (col_time_1_not_null_key), +KEY col_datetime_3_not_null_key (col_datetime_3_not_null_key), +KEY col_time_2_key (col_time_2_key) +) DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY KEY (pk)PARTITIONS 2 */; +INSERT INTO t1 VALUES ('00:20:05.0','1999-12-31 21:00:01','0000-00-00 00:00:00.000','04:25:59.01'); +INSERT INTO t1 VALUES ('00:15:56.0','1999-12-31 21:00:03','0000-00-00 00:00:00.000','00:20:06.00'); +INSERT INTO t1 VALUES ('00:20:03.0','1999-12-31 21:00:05','2002-10-18 16:08:58.006','00:20:00.00'); +INSERT INTO t1 VALUES ('00:20:09.0','1999-12-31 21:00:07','2002-11-11 17:21:02.045','18:39:12.05'); +INSERT INTO t1 VALUES ('13:51:22.0','1999-12-31 21:00:09','2002-08-07 10:27:35.055','00:20:07.00'); +INSERT INTO t1 VALUES ('00:20:06.0','0000-00-00 00:00:00','2003-08-12 00:00:00.000','20:35:34.01'); +SELECT col_time_1_not_null_key AS c1 +FROM t1 +WHERE col_datetime_3_not_null_key NOT IN +(LEAST( DATE('0000-00-00 00:00:00'), CURDATE()), col_time_2_key); +DROP TABLE t1; +SET timestamp=UNIX_TIMESTAMP('2001-11-07 15:13:00'); +CREATE TABLE t1 ( +col_time_3_not_null time(3) NOT NULL, +col_datetime_4_not_null_key datetime(4) NOT NULL, +col_datetime_key datetime DEFAULT NULL, +col_time_1_key time(1) DEFAULT NULL, +col_time_5 time(5) DEFAULT NULL, +col_timestamp_6_not_null_key timestamp(6) NULL DEFAULT '0000-00-00 00:00:00.000000', +pk datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', +PRIMARY KEY (pk), +KEY col_datetime_4_not_null_key (col_datetime_4_not_null_key), +KEY col_datetime_key (col_datetime_key), +KEY col_time_1_key (col_time_1_key), +KEY col_timestamp_6_not_null_key (col_timestamp_6_not_null_key)); +INSERT INTO t1 VALUES ('12:52:24.022','0000-00-00 00:00:00.0000','2003-05-24 00:00:00','00:20:09.0','15:11:20.03463','0000-00-00 00:00:00.000000','2011-11-07 12:01:35.111932'); +INSERT INTO t1 VALUES ('18:52:49.043','2000-10-13 00:00:00.0000','2005-07-22 00:00:00',NULL,'08:19:02.03845','2000-09-20 03:26:09.009008','2011-11-07 12:01:36.111932'); +INSERT INTO t1 VALUES ('23:46:05.010','2005-12-27 04:06:15.0087','0000-00-00 00:00:00','23:40:13.0','08:30:24.03114','0000-00-00 00:00:00.000000','2011-11-07 12:01:37.111932'); +INSERT INTO t1 VALUES ('00:20:05.000','2009-06-01 08:01:58.0532','2007-03-26 12:18:48','00:20:03.0','20:32:22.04519','2000-08-19 21:00:00.000000','2011-11-07 12:01:38.111932'); +INSERT INTO t1 VALUES ('00:20:05.000','2002-05-01 00:00:00.0000','0000-00-00 00:00:00','04:31:10.0','00:20:04.00000','0000-00-00 00:00:00.000000','2011-11-07 12:01:39.111932'); +INSERT INTO t1 VALUES ('00:20:06.000','2007-07-25 22:20:58.0023','0000-00-00 00:00:00','00:23:16.1',NULL,'2008-03-19 16:17:15.042024','2011-11-07 12:01:40.111932'); +INSERT INTO t1 VALUES ('02:55:32.040','0000-00-00 00:00:00.0000',NULL,'00:20:02.0','08:45:57.00998','2009-06-25 10:21:16.011345','2011-11-07 12:01:41.111932'); +INSERT INTO t1 VALUES ('00:20:06.000','2009-01-07 01:12:15.0324','2000-05-26 00:00:00','17:41:45.1','00:20:07.00000','0000-00-00 00:00:00.000000','2011-11-07 12:01:42.111932'); +INSERT INTO t1 VALUES ('12:01:30.061','2009-04-01 00:00:00.0000','2001-05-08 05:31:04','07:43:41.1','11:12:29.03251','2009-12-22 17:45:46.040987','2011-11-07 12:01:43.111932'); +INSERT INTO t1 VALUES ('00:16:22.057','2005-05-10 00:18:58.0345',NULL,'02:24:15.0',NULL,'2008-02-14 20:55:46.023678','2011-11-07 12:01:44.111932'); +INSERT INTO t1 VALUES ('06:54:17.018','2002-12-27 12:28:03.0382','0000-00-00 00:00:00','19:19:54.0','01:42:30.03406','0000-00-00 00:00:00.000000','2011-11-07 12:01:45.111932'); +INSERT INTO t1 VALUES ('00:20:04.000','2007-03-11 00:00:00.0000','0000-00-00 00:00:00',NULL,'13:12:03.05778','2005-02-19 02:31:13.046418','2011-11-07 12:01:46.111932'); +INSERT INTO t1 VALUES ('00:20:01.000','2009-08-13 00:00:00.0000','0000-00-00 00:00:00','00:20:02.0',NULL,'2008-05-21 10:53:59.004633','2011-11-07 12:01:47.111932'); +INSERT INTO t1 VALUES ('02:44:13.025','2001-07-02 14:06:37.0411','2009-04-01 00:43:45','00:20:07.0','16:15:02.01279','2004-07-28 17:34:20.031118','2011-11-07 12:01:48.111932'); +INSERT INTO t1 VALUES ('14:51:02.019','2006-02-24 04:12:05.0014','0000-00-00 00:00:00','00:20:08.0','00:20:09.00000','2001-04-25 21:00:00.000000','2011-11-07 12:01:49.111932'); +SELECT +col_timestamp_6_not_null_key AS c1, +col_datetime_key AS c2, +UTC_DATE() AS c3 +FROM t1 +WHERE col_time_1_key BETWEEN +TIMESTAMPADD(MONTH, 38 ,CONVERT_TZ( DATE(MAKEDATE(207, 38 )), '+00:00','+04:00')) +AND LOCALTIMESTAMP() +ORDER BY col_datetime_4_not_null_key , col_time_5 , col_time_3_not_null; +c1 c2 c3 +2009-06-25 10:21:16.011345 NULL 2001-11-07 +0000-00-00 00:00:00.000000 2003-05-24 00:00:00 2001-11-07 +2004-07-28 17:34:20.031118 2009-04-01 00:43:45 2001-11-07 +0000-00-00 00:00:00.000000 0000-00-00 00:00:00 2001-11-07 +2008-02-14 20:55:46.023678 NULL 2001-11-07 +2001-04-25 21:00:00.000000 0000-00-00 00:00:00 2001-11-07 +2008-03-19 16:17:15.042024 0000-00-00 00:00:00 2001-11-07 +2009-12-22 17:45:46.040987 2001-05-08 05:31:04 2001-11-07 +2000-08-19 21:00:00.000000 2007-03-26 12:18:48 2001-11-07 +2008-05-21 10:53:59.004633 0000-00-00 00:00:00 2001-11-07 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Bug#13359097 ASSERT FAILURE IN MAKE_SORTKEY +# +SET timestamp=UNIX_TIMESTAMP('2011-11-01 17:48:00'); +CREATE TABLE t1 ( +pk time(6) NOT NULL DEFAULT '00:00:00.000000', +col_date_not_null date NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES ('00:00:00.000000','2001-09-10'); +INSERT INTO t1 VALUES ('12:07:41.148239','2000-05-23'); +SELECT GREATEST('2004-04-07', COALESCE (pk, col_date_not_null)) FROM t1 ORDER BY 1; +GREATEST('2004-04-07', COALESCE (pk, col_date_not_null)) +2011-11-01 00:00:00.000000 +2011-11-01 12:07:41.148239 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# BUG 13385275 - ASSERT FAILURE IN TIME_FROM_LONGLONG_PACKED +# +CREATE TABLE t1 ( +col_date_not_null_key date NOT NULL, +KEY col_date_not_null_key (col_date_not_null_key)); +INSERT INTO t1 VALUES ('0000-00-00'), ('2000-11-20'); +SELECT ADDTIME(GREATEST(col_date_not_null_key, TIMESTAMP '2007-03-11 08:51:19.009408'), +'12:20:40.029940') +FROM t1; +ADDTIME(GREATEST(col_date_not_null_key, TIMESTAMP '2007-03-11 08:51:19.009408'), +'12:20:40.029940') +2007-03-11 21:11:59.039348 +2007-03-11 21:11:59.039348 +DROP TABLE t1; +# +# BUG#13386657 ASSERT FAILURE IN ITEM::GET_DATE_FROM_NON_TEMPORAL +# +CREATE TABLE t1 ( +col_time_5_not_null_key time(5) NOT NULL, +col_datetime_4 datetime(4) DEFAULT NULL, +col_timestamp_1_not_null_key timestamp(1) NULL DEFAULT '0000-00-00 00:00:00.0', +col_datetime_3_not_null_key datetime(3) NOT NULL, +KEY col_time_5_not_null_key (col_time_5_not_null_key), +KEY col_timestamp_1_not_null_key (col_timestamp_1_not_null_key), +KEY col_datetime_3_not_null_key (col_datetime_3_not_null_key)); +INSERT INTO t1 VALUES ('15:01:38.00004','0000-00-00 00:00:00.0000','2005-06-08 16:51:23.0','0000-00-00 00:00:00.000'); +SELECT col_datetime_4 +FROM t1 +WHERE col_datetime_3_not_null_key IN +(COALESCE (col_timestamp_1_not_null_key), col_time_5_not_null_key); +col_datetime_4 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999'); +SELECT CAST(COALESCE(a,a) AS CHAR) FROM t1; +CAST(COALESCE(a,a) AS CHAR) +2001-01-01 10:20:30.999 +SELECT CAST(COALESCE(a,a) AS SIGNED) FROM t1; +CAST(COALESCE(a,a) AS SIGNED) +20010101102031 +SELECT CAST(COALESCE(a,a) AS DECIMAL(25,3)) FROM t1; +CAST(COALESCE(a,a) AS DECIMAL(25,3)) +20010101102030.999 +SELECT CAST(COALESCE(a,a) AS DATETIME(6)) FROM t1; +CAST(COALESCE(a,a) AS DATETIME(6)) +2001-01-01 10:20:30.999000 +SELECT CAST(COALESCE(a,a) AS TIME(6)) FROM t1; +CAST(COALESCE(a,a) AS TIME(6)) +10:20:30.999000 +SELECT ROUND(COALESCE(a,a)) FROM t1; +ROUND(COALESCE(a,a)) +20010101102031 +DROP TABLE t1; +# +# Bug#13391370 ASSERT FAILURE IN TIME_TO_LONGLONG_DATETIME_PACKED +# +SET timestamp=UNIX_TIMESTAMP('2011-11-15 16:25:30'); +CREATE TABLE t1 ( +col_time_2_not_null time(2) NOT NULL, +col_timestamp_1_not_null timestamp(1) NULL DEFAULT '0000-00-00 00:00:00.0', +col_datetime_1 datetime(1) DEFAULT NULL, +col_timestamp_4_not_null timestamp(4) NULL DEFAULT '0000-00-00 00:00:00.0000', +col_timestamp_6_not_null_key timestamp(6) NULL DEFAULT '0000-00-00 00:00:00.000000', +col_date date DEFAULT NULL, +KEY col_timestamp_6_not_null_key (col_timestamp_6_not_null_key)); +DELETE FROM t1; +INSERT INTO t1 VALUES ('00:20:09.00','2008-02-09 00:19:47.1','0000-00-00 00:00:00.0','2009-03-13 00:56:44.0401','2008-10-17 09:43:02.051040','2000-11-13'); +INSERT INTO t1 VALUES ('00:20:04.00','0000-00-00 00:00:00.0','0000-00-00 00:00:00.0','0000-00-00 00:00:00.0000','0000-00-00 00:00:00.000000','2006-11-14'); +INSERT INTO t1 VALUES ('15:54:14.06','2003-04-19 04:55:47.0',NULL,'0000-00-00 00:00:00.0000','2009-12-27 02:49:14.005722','0000-00-00'); +INSERT INTO t1 VALUES ('04:58:16.02','2004-02-17 21:00:00.0',NULL,'0000-00-00 00:00:00.0000','2001-10-07 11:02:50.054375','2000-04-10'); +INSERT INTO t1 VALUES ('10:34:28.04','2006-10-16 21:00:00.0',NULL,'0000-00-00 00:00:00.0000','2008-05-17 05:14:50.028683','0000-00-00'); +INSERT INTO t1 VALUES ('14:17:38.04','2001-06-24 04:33:25.0','2008-09-05 21:25:39.0','0000-00-00 00:00:00.0000','0000-00-00 00:00:00.000000',NULL); +INSERT INTO t1 VALUES ('00:20:06.00','2005-06-26 22:52:46.0','0000-00-00 00:00:00.0','2000-09-11 02:51:17.0211','0000-00-00 00:00:00.000000','2006-10-10'); +INSERT INTO t1 VALUES ('00:09:41.03','0000-00-00 00:00:00.0','2008-02-16 19:59:19.0','2000-10-21 21:00:00.0000','2006-11-14 10:22:27.009969','0000-00-00'); +INSERT INTO t1 VALUES ('16:57:08.01','2009-05-13 21:03:39.0','2004-01-12 11:46:42.0','2000-02-28 10:51:01.0152','2001-05-10 14:21:38.022082',NULL); +INSERT INTO t1 VALUES ('19:02:15.03','0000-00-00 00:00:00.0','2009-07-16 20:15:38.1','0000-00-00 00:00:00.0000','0000-00-00 00:00:00.000000',NULL); +SELECT +SUBTIME('2002-04-08 06:05:42.056589', '01:26:40.063385') AS c1 +FROM +t1 +WHERE +col_timestamp_6_not_null_key IN ( +LEAST(col_datetime_1, MAKETIME(24,8,0), +ADDTIME(NOW(),'06:07:21.061946'), col_time_2_not_null), +DATE ('2005-11-03'), +CURTIME(), +COALESCE(col_timestamp_4_not_null, TIMESTAMP('2003-09-10'))) +ORDER BY +col_date, +col_timestamp_1_not_null; +c1 +2002-04-08 04:39:01.993204 +2002-04-08 04:39:01.993204 +2002-04-08 04:39:01.993204 +2002-04-08 04:39:01.993204 +DROP TABLE t1; +CREATE TABLE t1 (a datetime(1)); +INSERT INTO t1 VALUES ('2006-11-14 10:22:27.009969'); +SELECT * FROM t1 +WHERE timestamp'2006-11-14 10:22:27.009969' IN (LEAST(a, MAKETIME(24,8,0))); +a +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Bug#13384069 - EMBEDED UPDATE WITH CAST AND DATETIME WITH FSP DOES NOT WORK +# +CREATE TABLE t1 ( +pk timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', +col_datetime_6 datetime(6) DEFAULT NULL, +PRIMARY KEY (pk)); +INSERT INTO t1 VALUES ('2011-11-11 17:59:41.12','0000-00-00 00:00:00.000000'); +SELECT col_datetime_6, CAST(col_datetime_6 AS DATETIME(2)) AS c1 FROM t1; +col_datetime_6 c1 +0000-00-00 00:00:00.000000 0000-00-00 00:00:00.00 +CREATE TABLE t2 AS SELECT CAST(col_datetime_6 AS DATETIME(2)) AS c1 FROM t1; +SELECT * FROM t2; +c1 +0000-00-00 00:00:00.00 +UPDATE t2 SET c1=(SELECT CAST(col_datetime_6 AS DATETIME(2)) AS c1 FROM t1); +SELECT * FROM t2; +c1 +0000-00-00 00:00:00.00 +DROP TABLE t1, t2; +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES ('0000-00-00'); +SELECT CAST(COALESCE(a,a) AS SIGNED) FROM t1; +CAST(COALESCE(a,a) AS SIGNED) +0 +SELECT CAST(COALESCE(a,a) AS CHAR) FROM t1; +CAST(COALESCE(a,a) AS CHAR) +0000-00-00 +SELECT CAST(COALESCE(a,a) AS DECIMAL(25,3)) FROM t1; +CAST(COALESCE(a,a) AS DECIMAL(25,3)) +0.000 +SELECT CAST(COALESCE(a,a) AS DATETIME(6)) FROM t1; +CAST(COALESCE(a,a) AS DATETIME(6)) +0000-00-00 00:00:00.000000 +SELECT CAST(COALESCE(a,a) AS TIME(6)) FROM t1; +CAST(COALESCE(a,a) AS TIME(6)) +00:00:00.000000 +SELECT ROUND(COALESCE(a,a)) FROM t1; +ROUND(COALESCE(a,a)) +0 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00'); +SELECT CAST(COALESCE(a,a) AS SIGNED) FROM t1; +CAST(COALESCE(a,a) AS SIGNED) +0 +SELECT CAST(COALESCE(a,a) AS CHAR) FROM t1; +CAST(COALESCE(a,a) AS CHAR) +0000-00-00 00:00:00 +SELECT CAST(COALESCE(a,a) AS DECIMAL(25,3)) FROM t1; +CAST(COALESCE(a,a) AS DECIMAL(25,3)) +0.000 +SELECT CAST(COALESCE(a,a) AS DATETIME(6)) FROM t1; +CAST(COALESCE(a,a) AS DATETIME(6)) +0000-00-00 00:00:00.000000 +SELECT CAST(COALESCE(a,a) AS TIME(6)) FROM t1; +CAST(COALESCE(a,a) AS TIME(6)) +00:00:00.000000 +SELECT ROUND(COALESCE(a,a)) FROM t1; +ROUND(COALESCE(a,a)) +0 +DROP TABLE t1; +# +# Bug#13383838 - DELETE DOESN'T EMPTY RECORDS WHEN CAST WITH DATETIME TYPE IN EMBEDED SELECT +# +CREATE TABLE t1 ( +pk timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', +col_datetime_6 datetime(6) DEFAULT NULL, +PRIMARY KEY (pk)); +INSERT INTO t1 VALUES ('2011-11-11 17:59:41.12','0000-00-00 00:00:00.000000'); +CREATE TABLE t2 SELECT CAST(col_datetime_6 AS DATETIME) AS c1 FROM t1; +UPDATE t2 SET c1=(SELECT CAST(col_datetime_6 AS DATETIME) AS c1 FROM t1) +WHERE c1 IN (SELECT CAST(col_datetime_6 AS DATETIME) AS c1 FROM t1); +SELECT * FROM t2 WHERE c1 IN (SELECT CAST( col_datetime_6 AS DATETIME ) AS c1 FROM t1); +c1 +0000-00-00 00:00:00 +DELETE FROM t2 WHERE c1 IN (SELECT CAST( col_datetime_6 AS DATETIME ) AS c1 FROM t1); +SELECT COUNT(*) FROM t2; +COUNT(*) +0 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk timestamp(2) NOT NULL DEFAULT '0000-00-00 00:00:00.00', +col_date date DEFAULT NULL, +PRIMARY KEY (pk)); +INSERT INTO t1 VALUES ('2011-11-11 17:59:41.12','0000-00-00'); +CREATE TABLE t2 SELECT CAST(col_date AS DATE) AS c1 FROM t1; +UPDATE t2 SET c1=(SELECT CAST(col_date AS DATE) AS c1 FROM t1) +WHERE c1 IN (SELECT CAST(col_date AS DATE) AS c1 FROM t1); +SELECT * FROM t2 WHERE c1 IN (SELECT CAST(col_date AS DATE) AS c1 FROM t1); +c1 +0000-00-00 +DELETE FROM t2 WHERE c1 IN (SELECT CAST(col_date AS DATE) AS c1 FROM t1); +SELECT COUNT(*) FROM t2; +COUNT(*) +0 +DROP TABLE t1, t2; +# +# Bug#13392141 ASSERT FAILURE IN SEC_SINCE_EPOCH +# +SELECT CONVERT_TZ(TIMESTAMP'2021-00-00 00:00:00', '+00:00', '+7:5'); +CONVERT_TZ(TIMESTAMP'2021-00-00 00:00:00', '+00:00', '+7:5') +NULL +SELECT CONVERT_TZ(DATE'2021-00-00', '+00:00', '+7:5'); +CONVERT_TZ(DATE'2021-00-00', '+00:00', '+7:5') +NULL +SELECT CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2021-00-00')),'+00:00','+7:5'); +CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2021-00-00')),'+00:00','+7:5') +NULL +SET timestamp=UNIX_TIMESTAMP('2011-11-16 17:28:30'); +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 ( +col_timestamp_2_not_null_key timestamp(2) NULL DEFAULT '0000-00-00 00:00:00.00', +pk time NOT NULL DEFAULT '00:00:00', +PRIMARY KEY (pk), +KEY col_timestamp_2_not_null_key (col_timestamp_2_not_null_key)); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:49:56'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:49:58'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:00'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:02'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:03'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:05'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:12'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:14'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:18'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:19'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:23'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:24'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:28'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:30'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:34'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:35'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:37'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:38'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:46'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:47'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:50'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00','18:50:52'); +INSERT INTO t1 VALUES ('2000-05-24 21:00:00.00','18:50:11'); +INSERT INTO t1 VALUES ('2000-08-09 13:04:19.05','18:50:32'); +INSERT INTO t1 VALUES ('2000-10-05 09:01:10.01','18:50:42'); +INSERT INTO t1 VALUES ('2000-12-08 03:00:13.05','18:50:04'); +INSERT INTO t1 VALUES ('2001-03-02 07:52:23.01','18:50:44'); +INSERT INTO t1 VALUES ('2001-04-24 10:01:32.05','18:50:49'); +INSERT INTO t1 VALUES ('2003-02-18 14:31:23.06','18:50:39'); +INSERT INTO t1 VALUES ('2003-03-07 21:00:00.00','18:50:29'); +INSERT INTO t1 VALUES ('2003-04-16 21:00:00.00','18:50:17'); +INSERT INTO t1 VALUES ('2003-08-10 21:00:00.00','18:50:36'); +INSERT INTO t1 VALUES ('2003-11-24 06:30:37.06','18:49:53'); +INSERT INTO t1 VALUES ('2003-12-01 21:00:00.00','18:50:41'); +INSERT INTO t1 VALUES ('2004-05-16 19:56:24.05','18:50:31'); +INSERT INTO t1 VALUES ('2004-05-27 18:45:05.06','18:50:08'); +INSERT INTO t1 VALUES ('2004-06-05 22:51:19.04','18:50:20'); +INSERT INTO t1 VALUES ('2004-10-16 21:00:00.00','18:49:54'); +INSERT INTO t1 VALUES ('2004-11-02 21:00:00.00','18:50:51'); +INSERT INTO t1 VALUES ('2005-02-23 00:35:02.05','18:50:07'); +INSERT INTO t1 VALUES ('2005-08-15 16:33:48.01','18:50:43'); +INSERT INTO t1 VALUES ('2006-03-14 21:15:50.03','18:50:33'); +INSERT INTO t1 VALUES ('2006-04-24 18:46:21.06','18:50:01'); +INSERT INTO t1 VALUES ('2006-05-14 01:54:29.01','18:50:40'); +INSERT INTO t1 VALUES ('2006-08-23 22:33:51.02','18:50:06'); +INSERT INTO t1 VALUES ('2006-11-15 02:06:29.02','18:49:59'); +INSERT INTO t1 VALUES ('2006-11-28 11:32:09.03','18:50:15'); +INSERT INTO t1 VALUES ('2007-01-19 18:45:01.00','18:50:25'); +INSERT INTO t1 VALUES ('2007-01-23 18:04:25.01','18:50:27'); +INSERT INTO t1 VALUES ('2007-06-20 18:42:45.01','18:50:48'); +INSERT INTO t1 VALUES ('2007-08-27 21:00:00.00','18:50:22'); +INSERT INTO t1 VALUES ('2007-10-11 09:54:15.02','18:50:45'); +INSERT INTO t1 VALUES ('2008-01-24 18:55:00.04','18:50:10'); +INSERT INTO t1 VALUES ('2008-03-03 16:06:21.03','18:50:16'); +INSERT INTO t1 VALUES ('2008-03-23 21:00:00.00','18:50:26'); +INSERT INTO t1 VALUES ('2008-05-28 10:12:34.06','18:49:57'); +INSERT INTO t1 VALUES ('2009-06-09 21:31:23.04','18:50:21'); +INSERT INTO t1 VALUES ('2009-06-14 09:15:36.06','18:50:09'); +INSERT INTO t1 VALUES ('2009-06-30 23:31:57.01','18:49:55'); +INSERT INTO t1 VALUES ('2009-12-25 17:54:17.00','18:50:13'); +INSERT INTO t1 VALUES ('2005-12-15 18:49:06.05','00:00:00'); +SELECT col_timestamp_2_not_null_key +FROM t1 +WHERE CONVERT_TZ(GREATEST('2005-11-05 18:16:50.055749', STR_TO_DATE(CURRENT_TIME, '%Y')), +'+00:00', CONCAT('+', CONCAT_WS(':', 7, 5))); +col_timestamp_2_not_null_key +Warnings: +Warning 1292 Truncated incorrect date value: '17:28:30' +Warning 1292 Incorrect datetime value: '2017-00-00' +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Bug#13365131 - VALGRIND: CONDITIONAL JUMP OR MOVE DEPENDS ON UNINITIALISED IN MY_TIME_COMPARE +# +CREATE TABLE t1 ( +col_time_not_null_key time not null, +col_timestamp_6_not_null_key timestamp(6) not null NULL DEFAULT 0, +col_datetime_6_not_null_key datetime(6) not null, +col_datetime_6_key datetime(6), +col_time_3_not_null_key time(3) not null, +col_datetime_3_key datetime(3), +key (col_datetime_6_not_null_key), +key (col_datetime_3_key)) ENGINE=innodb; +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1; +SELECT col_datetime_3_key AS c1 FROM v1 +WHERE SYSDATE() IS NULL +OR col_datetime_6_not_null_key < TIMEDIFF('0000-00-00','2002-11-24' ) +AND col_timestamp_6_not_null_key IS NULL; +c1 +Warnings: +Warning 1292 Truncated incorrect time value: '0000-00-00' +Warning 1292 Truncated incorrect time value: '2002-11-24' +Warning 1292 Truncated incorrect time value: '0000-00-00' +Warning 1292 Truncated incorrect time value: '2002-11-24' +Warning 1292 Truncated incorrect time value: '0000-00-00' +Warning 1292 Truncated incorrect time value: '2002-11-24' +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#13401354 ITEM->FIELD_TYPE() == MYSQL_TYPE_TIME || ITEM->FIELD_TYPE() == MYSQL_TYPE_NULL +# +CREATE TABLE t1 (col_time_not_null TIME NOT NULL); +SELECT * FROM t1 +WHERE col_time_not_null = DATE(NULL) AND col_time_not_null = TIME(NULL); +col_time_not_null +DROP TABLE t1; +CREATE TABLE t1 ( +col_date DATE, +col_time_not_null TIME not null, +pk TIMESTAMP(6), +col_timestamp_3_not_null_key TIMESTAMP(3) NOT NULL, +col_date_not_null DATE NOT NULL, +col_time_3_key TIME(3), +col_timestamp_6_key TIMESTAMP(6) NOT NULL, +col_datetime DATETIME, +col_datetime_6 DATETIME(6), +col_timestamp_3_key TIMESTAMP(3) NOT NULL, +col_time_6_not_null TIME(6) NOT NULL, +col_time_6 TIME(6), +col_time_6_not_null_key TIME(6) NOT NULL, +col_datetime_not_null DATETIME NOT NULL, +col_datetime_3_not_null_key DATETIME(3) NOT NULL, +KEY (col_datetime_3_not_null_key)); +SELECT col_time_6 AS c1, NOW() AS c2 FROM t1 +WHERE +col_datetime_not_null BETWEEN SUBTIME('0000-00-00','00:00:00') AND col_date_not_null +AND +col_time_not_null=STR_TO_DATE(DATE_FORMAT(TIME('00:00:00.000000'),CONCAT_WS('-','%s','%k' )),CONCAT_WS(':','%i','%M')) +AND +col_date BETWEEN UNIX_TIMESTAMP('0000-00-00 00:00:00') AND col_timestamp_3_key +AND +col_datetime_6 NOT IN (col_time_6_not_null,'0000-00-00') +AND +col_time_not_null = TIMEDIFF(CURDATE(),'00:00:00.000000') +AND +col_time_3_key NOT IN (col_timestamp_6_key,pk) +AND +col_timestamp_3_not_null_key < col_datetime; +c1 c2 +Warnings: +Warning 1411 Incorrect datetime value: '00-0' for function str_to_date +DROP TABLE t1; +# +# Bug#13399082 - ASSERTION `MON > 0 && MON < 13' FAILED IN TZTIME.CC | SEC_SINCE_EPOCH +# +SET TIME_ZONE='+02:00'; +SELECT UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y')); +UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y')) +0 +SET TIME_ZONE=DEFAULT; +# This should return NULL +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES(NULL); +SELECT UNIX_TIMESTAMP(a) FROM t1; +UNIX_TIMESTAMP(a) +NULL +DROP TABLE t1; +SELECT UNIX_TIMESTAMP(NULL); +UNIX_TIMESTAMP(NULL) +NULL +SELECT UNIX_TIMESTAMP(DATE(NULL)); +UNIX_TIMESTAMP(DATE(NULL)) +NULL +SELECT UNIX_TIMESTAMP(TIME(NULL)); +UNIX_TIMESTAMP(TIME(NULL)) +NULL +SELECT UNIX_TIMESTAMP(TIMESTAMP(NULL)); +UNIX_TIMESTAMP(TIMESTAMP(NULL)) +NULL +SELECT CONCAT(UNIX_TIMESTAMP(NULL)); +CONCAT(UNIX_TIMESTAMP(NULL)) +NULL +SELECT CAST(UNIX_TIMESTAMP(NULL) AS SIGNED); +CAST(UNIX_TIMESTAMP(NULL) AS SIGNED) +NULL +SELECT CAST(UNIX_TIMESTAMP(NULL) AS DECIMAL(23,6)); +CAST(UNIX_TIMESTAMP(NULL) AS DECIMAL(23,6)) +NULL +# This should return 0 +CREATE TABLE t1 (a VARCHAR(30)); +INSERT INTO t1 VALUES +('0000-01-01 00:00:00'),('2001-00-01 00:00:01'),('2001-01-00 00:00:00'), +('0000-00-00 00:00:01'),('0000-00-00 00:00:00.1'); +SELECT UNIX_TIMESTAMP(a) FROM t1; +UNIX_TIMESTAMP(a) +0.000000 +0.000000 +0.000000 +0.000000 +0.000000 +DROP TABLE t1; +SELECT UNIX_TIMESTAMP('0000-01-01 00:00:00'); +UNIX_TIMESTAMP('0000-01-01 00:00:00') +0 +SELECT UNIX_TIMESTAMP('2001-00-01 00:00:00'); +UNIX_TIMESTAMP('2001-00-01 00:00:00') +0 +SELECT UNIX_TIMESTAMP('2001-01-00 00:00:00'); +UNIX_TIMESTAMP('2001-01-00 00:00:00') +0 +SELECT UNIX_TIMESTAMP('0000-00-00 10:10:20'); +UNIX_TIMESTAMP('0000-00-00 10:10:20') +0 +SELECT UNIX_TIMESTAMP('0000-00-00 00:00:00.1'); +UNIX_TIMESTAMP('0000-00-00 00:00:00.1') +0.0 +SELECT UNIX_TIMESTAMP(TIMESTAMP'0000-00-00 10:10:20'); +UNIX_TIMESTAMP(TIMESTAMP'0000-00-00 10:10:20') +0 +SELECT UNIX_TIMESTAMP(TIMESTAMP'0000-00-00 00:00:00.1'); +UNIX_TIMESTAMP(TIMESTAMP'0000-00-00 00:00:00.1') +0.0 +SELECT UNIX_TIMESTAMP(TIMESTAMP('0000-00-00 10:10:20')); +UNIX_TIMESTAMP(TIMESTAMP('0000-00-00 10:10:20')) +0 +SELECT UNIX_TIMESTAMP(TIMESTAMP('0000-00-00 00:00:00.1')); +UNIX_TIMESTAMP(TIMESTAMP('0000-00-00 00:00:00.1')) +0.0 +# +# Bug#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP +# +SET timestamp=UNIX_TIMESTAMP('2011-11-18 14:36:00'); +CREATE TABLE t1 ( +pk time(2) NOT NULL DEFAULT '00:00:00.00', +col_timestamp_3_not_null timestamp(3) NULL DEFAULT '0000-00-00 00:00:00.000', +col_datetime_1_key datetime(1) DEFAULT NULL, +col_datetime_6_not_null_key datetime(6) NOT NULL, +col_datetime_2_not_null datetime(2) NOT NULL, +PRIMARY KEY (pk), +KEY col_datetime_1_key (col_datetime_1_key), +KEY col_datetime_6_not_null_key (col_datetime_6_not_null_key)) +DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('19:14:35.36','0000-00-00 00:00:00.000','0000-00-00 00:00:00.0','2000-08-28 07:34:20.051690','2009-09-20 07:32:39.06'); +INSERT INTO t1 VALUES ('19:14:37.36','2005-07-04 08:03:50.051','0000-00-00 00:00:00.0','0000-00-00 00:00:00.000000','0000-00-00 00:00:00.00'); +INSERT INTO t1 VALUES ('19:14:39.36','0000-00-00 00:00:00.000',NULL,'2005-10-11 07:24:45.059064','2009-11-19 00:00:00.00'); +INSERT INTO t1 VALUES ('19:14:41.36','2005-11-22 21:00:00.000',NULL,'0000-00-00 00:00:00.000000','0000-00-00 00:00:00.00'); +INSERT INTO t1 VALUES ('19:14:43.36','2009-11-06 21:00:00.000','2007-07-03 11:13:08.0','2002-09-02 00:17:37.037583','2003-09-25 09:29:41.00'); +INSERT INTO t1 VALUES ('19:14:36.36','2009-08-15 05:43:18.029','2009-01-18 00:00:00.0','0000-00-00 00:00:00.000000','2007-07-20 08:31:37.02'); +INSERT INTO t1 VALUES ('19:14:38.36','0000-00-00 00:00:00.000','0000-00-00 00:00:00.0','0000-00-00 00:00:00.000000','2004-08-16 05:11:47.04'); +INSERT INTO t1 VALUES ('19:14:40.36','2000-04-16 21:00:00.000',NULL,'2004-04-27 00:00:00.000000','2009-06-03 00:18:49.04'); +INSERT INTO t1 VALUES ('19:14:42.36','2009-01-18 20:46:41.035','2003-03-23 11:37:04.0','0000-00-00 00:00:00.000000','2009-12-26 00:00:00.00'); +INSERT INTO t1 VALUES ('19:14:44.36','0000-00-00 00:00:00.000','0000-00-00 00:00:00.0','2005-09-14 15:13:53.062460','0000-00-00 00:00:00.00'); +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1; +SELECT UNIX_TIMESTAMP(col_datetime_2_not_null) AS c1 +FROM v1 +WHERE col_datetime_6_not_null_key > col_datetime_1_key +AND col_timestamp_3_not_null IS NOT NULL +ORDER BY 1; +c1 +0.00 +1253421159.06 +DROP VIEW v1; +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# Bug#13394031 VALGRIND: CONDITIONAL JUMP/MOVE DEPENDS ON UNINITIALISED IN FIELD::IS_REAL_NULL +# +CREATE TABLE t1 ( +pk time, +c_timestamp timestamp NULL DEFAULT 0, +c_time time, +primary key (pk), +key (c_timestamp) +) ENGINE=INNODB; +INSERT INTO t1 VALUES +(SEC_TO_TIME(2),'20000627024305.040518','00:00:00.000000'), +(SEC_TO_TIME(4),'0000-00-00','20010412233415.034269'), +(SEC_TO_TIME(46),'20030628121312.000376','20020323065409.039577'), +(SEC_TO_TIME(48),'20071219173306.048009',NULL), +(SEC_TO_TIME(50),'0000-00-00',NULL); +Warnings: +Note 1265 Data truncated for column 'c_time' at row 2 +Note 1265 Data truncated for column 'c_time' at row 3 +SELECT c_time FROM t1; +c_time +00:00:00 +23:34:15 +06:54:09 +NULL +NULL +SELECT c_time AS c1 FROM t1 +WHERE c_timestamp NOT IN (NULL, '0000-00-00 00:00:00'); +c1 +DROP TABLE t1; +# +# Various tests for better gcov coverage +# +# +# Comparing DATETIME value to TIME(NULL) +# +SELECT TIMESTAMP'2001-01-01 00:00:00' = TIME(NULL); +TIMESTAMP'2001-01-01 00:00:00' = TIME(NULL) +NULL +# +# BUG#13450867 - CRASH ON UPDATE A TIME COLUMN +# +CREATE TABLE t1 (a TIME(6), b TIME(6), c TIME(6), d TIME(6)); +INSERT INTO t1 VALUES +('-838:59:59.999999', '-838:59:59.000001', +'838:59:59.999999', '838:59:59.000001'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +Warning 1264 Out of range value for column 'c' at row 1 +Warning 1264 Out of range value for column 'd' at row 1 +SELECT * FROM t1; +a b c d +-838:59:59.000000 -838:59:59.000000 838:59:59.000000 838:59:59.000000 +UPDATE t1 SET +a= a - INTERVAL 999999 MICROSECOND, b= b - INTERVAL 1 MICROSECOND, +c= c + INTERVAL 999999 MICROSECOND, d= d + INTERVAL 1 MICROSECOND; +Warnings: +Warning 1441 Datetime function: time field overflow +Warning 1441 Datetime function: time field overflow +Warning 1441 Datetime function: time field overflow +Warning 1441 Datetime function: time field overflow +SELECT * FROM t1; +a b c d +NULL NULL NULL NULL +DROP TABLE t1; +SELECT SEC_TO_TIME(3200399.999999); +SEC_TO_TIME(3200399.999999) +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '3200399.999999' +SELECT SEC_TO_TIME(3200399.000001); +SEC_TO_TIME(3200399.000001) +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '3200399.000001' +SELECT SEC_TO_TIME(-3200399.999999); +SEC_TO_TIME(-3200399.999999) +-838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '-3200399.999999' +SELECT SEC_TO_TIME(-3200399.000001); +SEC_TO_TIME(-3200399.000001) +-838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '-3200399.000001' +# +# BUG#13451866 - DIFFERENCE IN RESULTS WHEN USING +# EXTRACT( MINUTE_MICROSECOND ) +# +CREATE TABLE t1 (a DATETIME(6) DEFAULT NULL); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000000'); +SELECT * FROM t1; +a +0000-00-00 00:00:00.000000 +SELECT EXTRACT(MINUTE_MICROSECOND FROM a) FROM t1; +EXTRACT(MINUTE_MICROSECOND FROM a) +0 +SELECT EXTRACT(MINUTE_MICROSECOND FROM '0000-00-00 00:00:00.000000'); +EXTRACT(MINUTE_MICROSECOND FROM '0000-00-00 00:00:00.000000') +0 +DROP TABLE t1; +# +# BUG#13436875 - ASSERTION '!ARGS[0]->IS_TEMPORAL() || +# !ARGS[1]->IS_TEMPORAL()' +# +CREATE TABLE t1 (a DATETIME NOT NULL); +SELECT 1 FROM t1 WHERE GREATEST(a, a) / a; +1 +SELECT 1 FROM t1 WHERE LEAST(a, a) / a; +1 +SELECT 1 FROM t1 WHERE COALESCE(a, a) / a; +1 +SELECT 1 FROM t1 WHERE IF(0, a, a) / a; +1 +SELECT 1 FROM t1 WHERE IFNULL(a, a) / a; +1 +SELECT 1 FROM t1 WHERE CASE WHEN 0 then a ELSE a END / a; +1 +SELECT 1 FROM t1 WHERE (SELECT a FROM t1) / a; +1 +DROP TABLE t1; +# +# BUG#13616434 ASSERTION FAILED: NANOSECONDS < 1000000000 +# +SELECT +EXTRACT(DAY FROM (-0.1111111111)), +EXTRACT(YEAR FROM (-0.1111111)), +EXTRACT(YEAR_MONTH FROM (-0.1111111111)), +EXTRACT(DAY FROM (-0.1111111)), +EXTRACT(QUARTER FROM (-0.1111111111)), +EXTRACT(MONTH FROM (-0.1111111)), +EXTRACT(WEEK FROM (-0.1111111)), +DATE(-0.1111111), +QUARTER(-0.1111111111), +TIMESTAMP(-0.1111111111), +LAST_DAY(-0.1111111111), +DAY(-0.1111111111), +MONTH(-0.1111111111), +YEAR(-0.1111111), +DAYOFMONTH(-0.1111111111), +TIMESTAMP((-0.1111111111),'{$x'), +DATE_FORMAT(-0.1111111111,'+'), +CONVERT(-0.1111111,DATE), +CAST(-0.1111111111 AS DATE); +EXTRACT(DAY FROM (-0.1111111111)) EXTRACT(YEAR FROM (-0.1111111)) EXTRACT(YEAR_MONTH FROM (-0.1111111111)) EXTRACT(DAY FROM (-0.1111111)) EXTRACT(QUARTER FROM (-0.1111111111)) EXTRACT(MONTH FROM (-0.1111111)) EXTRACT(WEEK FROM (-0.1111111)) DATE(-0.1111111) QUARTER(-0.1111111111) TIMESTAMP(-0.1111111111) LAST_DAY(-0.1111111111) DAY(-0.1111111111) MONTH(-0.1111111111) YEAR(-0.1111111) DAYOFMONTH(-0.1111111111) TIMESTAMP((-0.1111111111),'{$x') DATE_FORMAT(-0.1111111111,'+') CONVERT(-0.1111111,DATE) CAST(-0.1111111111 AS DATE) +NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111' +Warning 1292 Incorrect datetime value: '-0.1111111' +Warning 1292 Incorrect datetime value: '-0.1111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +Warning 1292 Incorrect datetime value: '-0.1111111' +Warning 1292 Incorrect datetime value: '-0.1111111111' +# +# Bug#13375823 - FSP(DECIMAL) RESULT DIFFERENCE WITH QUERY USING UNION ALL +# +CREATE TABLE t1 (a DATETIME(3) NOT NULL); +INSERT INTO t1 VALUES ('2000-07-16 05:58:04.035'); +INSERT INTO t1 VALUES ('2008-08-21 00:00:00.000'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000'); +# Testing INT number +SELECT GREATEST(a, 20010101120000) FROM t1; +GREATEST(a, 20010101120000) +2001-01-01 12:00:00.000 +2008-08-21 00:00:00.000 +2001-01-01 12:00:00.000 +(SELECT GREATEST(a, 20010101120000) FROM t1) UNION ALL (SELECT GREATEST(a, 20010101120000) FROM t1 LIMIT 0); +GREATEST(a, 20010101120000) +2001-01-01 12:00:00.000 +2008-08-21 00:00:00.000 +2001-01-01 12:00:00.000 +SELECT LEAST(a, 20010101120000) FROM t1; +LEAST(a, 20010101120000) +2000-07-16 05:58:04.035 +2001-01-01 12:00:00.000 +0000-00-00 00:00:00.000 +(SELECT LEAST(a, 20010101120000) FROM t1) UNION ALL (SELECT LEAST(a, 20010101120000) FROM t1 LIMIT 0); +LEAST(a, 20010101120000) +2000-07-16 05:58:04.035 +2001-01-01 12:00:00.000 +0000-00-00 00:00:00.000 +# Testing DECIMAL number +SELECT GREATEST(a, 20010101120000.123456) FROM t1; +GREATEST(a, 20010101120000.123456) +2001-01-01 12:00:00.123456 +2008-08-21 00:00:00.000000 +2001-01-01 12:00:00.123456 +(SELECT GREATEST(a, 20010101120000.123456) FROM t1) UNION ALL (SELECT GREATEST(a, 20010101120000.123456) FROM t1 LIMIT 0); +GREATEST(a, 20010101120000.123456) +2001-01-01 12:00:00.123456 +2008-08-21 00:00:00.000000 +2001-01-01 12:00:00.123456 +SELECT LEAST(a, 20010101120000.123456) FROM t1; +LEAST(a, 20010101120000.123456) +2000-07-16 05:58:04.035000 +2001-01-01 12:00:00.123456 +0000-00-00 00:00:00.000 +(SELECT LEAST(a, 20010101120000.123456) FROM t1) UNION ALL (SELECT LEAST(a, 20010101120000.123456) FROM t1 LIMIT 0); +LEAST(a, 20010101120000.123456) +2000-07-16 05:58:04.035000 +2001-01-01 12:00:00.123456 +0000-00-00 00:00:00.000 +# Testing REAL number +SELECT GREATEST(a, 20010101120000e0) FROM t1; +GREATEST(a, 20010101120000e0) +2001-01-01 12:00:00.000000 +2008-08-21 00:00:00.000000 +2001-01-01 12:00:00.000000 +(SELECT GREATEST(a, 20010101120000e0) FROM t1) UNION ALL (SELECT GREATEST(a, 20010101120000e0) FROM t1 LIMIT 0); +GREATEST(a, 20010101120000e0) +2001-01-01 12:00:00.000000 +2008-08-21 00:00:00.000000 +2001-01-01 12:00:00.000000 +SELECT LEAST(a, 20010101120000e0) FROM t1; +LEAST(a, 20010101120000e0) +2000-07-16 05:58:04.035000 +2001-01-01 12:00:00.000000 +0000-00-00 00:00:00.000 +(SELECT LEAST(a, 20010101120000e0) FROM t1) UNION ALL (SELECT LEAST(a, 20010101120000e0) FROM t1 LIMIT 0); +LEAST(a, 20010101120000e0) +2000-07-16 05:58:04.035000 +2001-01-01 12:00:00.000000 +0000-00-00 00:00:00.000 +DROP TABLE t1; +# Make sure precision of 6 fractional digits does not get lost +CREATE TABLE t1 (a DATETIME(6)); +INSERT INTO t1 VALUES ('2001-01-01 01:01:01.123456'); +SELECT GREATEST(a,20010101120000), LEAST(a,20010101120000) FROM t1; +GREATEST(a,20010101120000) LEAST(a,20010101120000) +2001-01-01 12:00:00.000000 2001-01-01 01:01:01.123456 +DROP TABLE t1; +# +# Bug#13976233 ASSERTION FAILED: !CHECK_TIME_MMSSFF_RANGE(LTIME), FILE SQL_TIME.CC, LINE 304 +# +SELECT SECOND(4.99999999991e0); +SECOND(4.99999999991e0) +5 +SELECT SECOND(-4.99999999991e0); +SECOND(-4.99999999991e0) +5 +SELECT SECOND(TRUNCATE('5',180)); +SECOND(TRUNCATE('5',180)) +5 +# +# Bug#17080703 INCONSISTENT DATETIME CONVERSIONS WITH FRACTIONAL SECONDS +# +# Test for TIMESTAMP datatype. +SELECT TIMESTAMP '20130710010203'; +TIMESTAMP '20130710010203' +2013-07-10 01:02:03 +SELECT TIMESTAMP '201307100102031'; +ERROR HY000: Incorrect DATETIME value: '201307100102031' +SELECT TIMESTAMP '2013071001020312'; +ERROR HY000: Incorrect DATETIME value: '2013071001020312' +SELECT TIMESTAMP '20130710010203123'; +ERROR HY000: Incorrect DATETIME value: '20130710010203123' +SELECT TIMESTAMP '201307100102031234'; +ERROR HY000: Incorrect DATETIME value: '201307100102031234' +SELECT TIMESTAMP '2013071001020312345'; +ERROR HY000: Incorrect DATETIME value: '2013071001020312345' +SELECT TIMESTAMP '20130710010203123456'; +ERROR HY000: Incorrect DATETIME value: '20130710010203123456' +# Test non decimal point as delimiter for fractional seconds. +SELECT TIMESTAMP '2013:07:10 01:02:03:04'; +ERROR HY000: Incorrect DATETIME value: '2013:07:10 01:02:03:04' +# Test for invalid seconds >= 60 properly separated by decimal point with fractions. +SELECT TIMESTAMP '2013:07:10 01.02.131'; +ERROR HY000: Incorrect DATETIME value: '2013:07:10 01.02.131' +SELECT TIMESTAMP '2013:07:10 01.02.131.2'; +ERROR HY000: Incorrect DATETIME value: '2013:07:10 01.02.131.2' +SELECT TIMESTAMP '2013:07:10 01.02.0312.3'; +ERROR HY000: Incorrect DATETIME value: '2013:07:10 01.02.0312.3' +SELECT TIMESTAMP '2013.07.10 01.02.131.23456'; +ERROR HY000: Incorrect DATETIME value: '2013.07.10 01.02.131.23456' +SELECT TIMESTAMP '201307100102031.'; +ERROR HY000: Incorrect DATETIME value: '201307100102031.' +SELECT TIMESTAMP '2012071001021.1'; +ERROR HY000: Incorrect DATETIME value: '2012071001021.1' +# Test for valid seconds properly separated by decimal point with fractions. +SELECT TIMESTAMP '2013:07:10 01.02.0.31'; +TIMESTAMP '2013:07:10 01.02.0.31' +2013-07-10 01:02:00.31 +SELECT TIMESTAMP '20130710010203.'; +TIMESTAMP '20130710010203.' +2013-07-10 01:02:03 +# Test for valid seconds properly separated by decimal point with fractions. +SELECT TIMESTAMP '20130710010203.1'; +TIMESTAMP '20130710010203.1' +2013-07-10 01:02:03.1 +SELECT TIMESTAMP '20130710010203.12'; +TIMESTAMP '20130710010203.12' +2013-07-10 01:02:03.12 +SELECT TIMESTAMP '20130710010203.123'; +TIMESTAMP '20130710010203.123' +2013-07-10 01:02:03.123 +SELECT TIMESTAMP '20130710010203.1234'; +TIMESTAMP '20130710010203.1234' +2013-07-10 01:02:03.1234 +SELECT TIMESTAMP '20130710010203.12345'; +TIMESTAMP '20130710010203.12345' +2013-07-10 01:02:03.12345 +SELECT TIMESTAMP '20130710010203.123456'; +TIMESTAMP '20130710010203.123456' +2013-07-10 01:02:03.123456 +SELECT TIMESTAMP '20130710010203.1234567'; +TIMESTAMP '20130710010203.1234567' +2013-07-10 01:02:03.123457 +# Test for valid time literals in insert operation. +CREATE TABLE t(key1 INT UNIQUE, col TIMESTAMP(6)); +INSERT INTO t VALUES (1, '20130710010203.1'), (2, '20130710010203.12'), (3, '20130710010203.123'), (4, '20130710010203.1234'), +(5,'20130710010203.12345'), (6, '20130710010203.123456'), (7, '201207100102'); +SELECT * FROM t ORDER BY key1; +key1 col +1 2013-07-10 01:02:03.100000 +2 2013-07-10 01:02:03.120000 +3 2013-07-10 01:02:03.123000 +4 2013-07-10 01:02:03.123400 +5 2013-07-10 01:02:03.123450 +6 2013-07-10 01:02:03.123456 +7 2020-12-07 10:01:02.000000 +DELETE FROM t; +# Test for invalid time literals in insert operation. +INSERT INTO t VALUES (1, '201307100102031'), (2, '2013071001020312'), (3, '20130710010203123'), (4, '201307100102031234'), +(5, '2013071001020312345'), (6, '20130710010203123456'), (7, '2013:07:10 01.02.031'), (8, '2013:07:10 01.02.031.2'), +(9, '2013:07:10 01.02.0312.3'), (10, '2012071001021.1'), (11, '2012071001021'); +Warnings: +Warning 1265 Data truncated for column 'col' at row 1 +Warning 1265 Data truncated for column 'col' at row 2 +Warning 1265 Data truncated for column 'col' at row 3 +Warning 1265 Data truncated for column 'col' at row 4 +Warning 1265 Data truncated for column 'col' at row 5 +Warning 1265 Data truncated for column 'col' at row 6 +Warning 1265 Data truncated for column 'col' at row 9 +Warning 1265 Data truncated for column 'col' at row 10 +Warning 1265 Data truncated for column 'col' at row 11 +SELECT * FROM t ORDER BY key1; +key1 col +1 2013-07-10 01:02:03.000000 +2 2013-07-10 01:02:03.000000 +3 2013-07-10 01:02:03.000000 +4 2013-07-10 01:02:03.000000 +5 2013-07-10 01:02:03.000000 +6 2013-07-10 01:02:03.000000 +7 2013-07-10 01:02:31.000000 +8 2013-07-10 01:02:31.200000 +9 0000-00-00 00:00:00.000000 +10 2020-12-07 10:01:02.000000 +11 2020-12-07 10:01:02.000000 +DROP TABLE t; +# Test for DATETIME datatype. +# Test for valid time literals in insert operation. +CREATE TABLE t(key1 INT UNIQUE, col DATETIME(6)); +INSERT INTO t VALUES (1, '20130710010203.1'), (2, '20130710010203.12'), (3, '20130710010203.123'), (4, '20130710010203.1234'), +(5, '20130710010203.12345'), (6, '20130710010203.123456'), (7, '201207100102'); +SELECT * FROM t ORDER BY key1; +key1 col +1 2013-07-10 01:02:03.100000 +2 2013-07-10 01:02:03.120000 +3 2013-07-10 01:02:03.123000 +4 2013-07-10 01:02:03.123400 +5 2013-07-10 01:02:03.123450 +6 2013-07-10 01:02:03.123456 +7 2020-12-07 10:01:02.000000 +DELETE FROM t; +# Test for invalid time literals in insert operation. +INSERT INTO t VALUES (1, '201307100102031'), (2, '2013071001020312'), (3, '20130710010203123'), (4, '201307100102031234'), +(5, '2013071001020312345'), (6, '20130710010203123456'), (7, '2013:07:10 01.02.031'), (8, '2013:07:10 01.02.031.2'), +(9, '2013:07:10 01.02.0312.3'), (10, '2012071001021.1'), (11, '2012071001021'); +Warnings: +Warning 1265 Data truncated for column 'col' at row 1 +Warning 1265 Data truncated for column 'col' at row 2 +Warning 1265 Data truncated for column 'col' at row 3 +Warning 1265 Data truncated for column 'col' at row 4 +Warning 1265 Data truncated for column 'col' at row 5 +Warning 1265 Data truncated for column 'col' at row 6 +Warning 1265 Data truncated for column 'col' at row 9 +Warning 1265 Data truncated for column 'col' at row 10 +Warning 1265 Data truncated for column 'col' at row 11 +SELECT * FROM t ORDER BY key1; +key1 col +1 2013-07-10 01:02:03.000000 +2 2013-07-10 01:02:03.000000 +3 2013-07-10 01:02:03.000000 +4 2013-07-10 01:02:03.000000 +5 2013-07-10 01:02:03.000000 +6 2013-07-10 01:02:03.000000 +7 2013-07-10 01:02:31.000000 +8 2013-07-10 01:02:31.200000 +9 0000-00-00 00:00:00.000000 +10 2020-12-07 10:01:02.000000 +11 2020-12-07 10:01:02.000000 +DROP TABLE t; +# Test for TIME datatype. +SELECT TIME '010203'; +TIME '010203' +01:02:03 +SELECT TIME '1010203'; +TIME '1010203' +101:02:03 +SELECT TIME '01010203'; +TIME '01010203' +101:02:03 +SELECT TIME '10102031'; +ERROR HY000: Incorrect TIME value: '10102031' +SELECT TIME '101020312'; +ERROR HY000: Incorrect TIME value: '101020312' +SELECT TIME '1010203123'; +ERROR HY000: Incorrect TIME value: '1010203123' +SELECT TIME '10102031234'; +ERROR HY000: Incorrect TIME value: '10102031234' +SELECT TIME '101020312345'; +ERROR HY000: Incorrect TIME value: '101020312345' +SELECT TIME '1010203123456'; +ERROR HY000: Incorrect TIME value: '1010203123456' +# Test non decimal point as delimiter for fractional seconds. +SELECT TIME '01:02:03:04'; +ERROR HY000: Incorrect TIME value: '01:02:03:04' +# Test for invalid seconds >= 60 properly separated by decimal point with fractions. +SELECT TIME '01:02:131'; +ERROR HY000: Incorrect TIME value: '01:02:131' +SELECT TIME '01:02:131.2'; +ERROR HY000: Incorrect TIME value: '01:02:131.2' +SELECT TIME '01:02:0312.3'; +ERROR HY000: Incorrect TIME value: '01:02:0312.3' +SELECT TIME '01:02:131.23456'; +ERROR HY000: Incorrect TIME value: '01:02:131.23456' +SELECT TIME '11102031.'; +ERROR HY000: Incorrect TIME value: '11102031.' +# Test for valid seconds properly separated by decimal point with fractions. +SELECT TIME '01:02:0.31'; +TIME '01:02:0.31' +01:02:00.31 +SELECT TIME '010203.'; +TIME '010203.' +01:02:03 +# Test for valid seconds properly separated by decimal point with fractions. +SELECT TIME '110203.1'; +TIME '110203.1' +11:02:03.1 +SELECT TIME '010203.12'; +TIME '010203.12' +01:02:03.12 +SELECT TIME '010203.123'; +TIME '010203.123' +01:02:03.123 +SELECT TIME '010203.1234'; +TIME '010203.1234' +01:02:03.1234 +SELECT TIME '010203.12345'; +TIME '010203.12345' +01:02:03.12345 +SELECT TIME '010203.123456'; +TIME '010203.123456' +01:02:03.123456 +SELECT TIME '010203.1234567'; +TIME '010203.1234567' +01:02:03.123457 +SELECT TIME '01021.1'; +TIME '01021.1' +00:10:21.1 +# Test for valid time literals in insert operation. +CREATE TABLE t(key1 INT UNIQUE, col TIME(6)); +INSERT INTO t VALUES (1, '010203.1'), (2, '010203.12'), (3, '010203.123'), (4, '010203.1234'), +(5, '010203.12345'), (6, '010203.123456'), (7, '0203.123456'), (8, '03.123456'), (9, '0.123456'); +SELECT * FROM t ORDER BY key1; +key1 col +1 01:02:03.100000 +2 01:02:03.120000 +3 01:02:03.123000 +4 01:02:03.123400 +5 01:02:03.123450 +6 01:02:03.123456 +7 00:02:03.123456 +8 00:00:03.123456 +9 00:00:00.123456 +DELETE FROM t; +# Test for invalid time literals in insert operation. +INSERT INTO t VALUES (1, '0102031'), (2, '01020312'), (3, '010203123'), (4, '0102031234'), +(5, '01020312345'), (6, '010203123456'), (7, '01:02:031'), (8, '01:02:031.2'), +(9, '01:02:0312.3'); +Warnings: +Warning 1264 Out of range value for column 'col' at row 3 +Warning 1264 Out of range value for column 'col' at row 4 +Warning 1264 Out of range value for column 'col' at row 5 +Note 1265 Data truncated for column 'col' at row 6 +Warning 1264 Out of range value for column 'col' at row 9 +SELECT * FROM t ORDER BY key1; +key1 col +1 10:20:31.000000 +2 102:03:12.000000 +3 838:59:59.000000 +4 838:59:59.000000 +5 838:59:59.000000 +6 12:34:56.000000 +7 01:02:31.000000 +8 01:02:31.200000 +9 00:00:00.000000 +DROP TABLE t; +SET sql_mode = default; +# End of 5.6 tests +# +# Bug#20565160 ASSERTION `SORT_FIELD->LENGTH >= LENGTH' FAILED +# +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t1 ( +c datetime(1) NOT NULL, +KEY(c) +) +; +INSERT INTO t1 VALUES +('2002-08-12 22:00:00.0'),('2002-08-12 22:00:00.1'),('2002-08-12 22:00:00.2'); +SELECT LEAST(c , '2005-05-14' ) AS c1 +FROM t1 +ORDER BY 1; +c1 +2002-08-12 22:00:00.0 +2002-08-12 22:00:00.1 +2002-08-12 22:00:00.2 +DROP TABLE t1; +SET NAMES default; +# Bug#19900900 ASSERTION `!CHECK_DATETIME_RANGE(LTIME)' FAILED +# TIME_TO_LONGLONG_DATETIME_PACKED +# +SET @@session.sql_buffer_result=TRUE; +CREATE TABLE t1(a DATETIME) engine=innodb; +INSERT INTO t1 VALUES('9999-12-31 23:59:58.000015'); +SELECT ADDTIME(a, 100000) FROM t1; +ADDTIME(a, 100000) +NULL +Warnings: +Warning 1441 Datetime function: add_time field overflow +SET @@session.sql_buffer_result=default; +DROP TABLE t1; +# +# Bug #28671811 FROM_UNIXTIME ACCEPTS AN OUT OF RANGE PARAMETER +# THROUGH ROUNDING +# +SET time_zone='+00:00'; +SELECT +FROM_UNIXTIME(2147483647) AS c1, +FROM_UNIXTIME(2147483648) AS c2, +FROM_UNIXTIME(2147483647.9999999) AS c3; +c1 c2 c3 +2038-01-19 03:14:07 NULL NULL +SET time_zone=default; +SELECT +FROM_UNIXTIME(2147483647) AS c1, +FROM_UNIXTIME(2147483648) AS c2, +FROM_UNIXTIME(2147483647.9999999) AS c3; +c1 c2 c3 +2038-01-19 06:14:07 NULL NULL +SET sql_mode=time_truncate_fractional; +SET time_zone='+00:00'; +SELECT +FROM_UNIXTIME(2147483647) AS c1, +FROM_UNIXTIME(2147483648) AS c2, +FROM_UNIXTIME(2147483647.9999999) AS c3; +c1 c2 c3 +2038-01-19 03:14:07 NULL 2038-01-19 03:14:07.999999 +SET time_zone=default; +SELECT +FROM_UNIXTIME(2147483647) AS c1, +FROM_UNIXTIME(2147483648) AS c2, +FROM_UNIXTIME(2147483647.9999999) AS c3; +c1 c2 c3 +2038-01-19 06:14:07 NULL 2038-01-19 06:14:07.999999 +SET sql_mode=default; +# +# Bug#29120569 SETTING OUT OF RANGE FRACTIONAL PART PRODUCES +# INCORRECT TIMESTAMPS +# +SET time_zone='+00:00'; +SET SESSION TIMESTAMP=1.9999996; +SELECT CURRENT_TIMESTAMP(6); +CURRENT_TIMESTAMP(6) +1970-01-01 00:00:01.999999 +CREATE TABLE t0( ts TIMESTAMP(0) not null, dt DATETIME(0) not null); +CREATE TABLE t1( ts TIMESTAMP(1) not null, dt DATETIME(1) not null); +CREATE TABLE t2( ts TIMESTAMP(2) not null, dt DATETIME(2) not null); +CREATE TABLE t3( ts TIMESTAMP(3) not null, dt DATETIME(3) not null); +CREATE TABLE t4( ts TIMESTAMP(4) not null, dt DATETIME(4) not null); +CREATE TABLE t5( ts TIMESTAMP(5) not null, dt DATETIME(5) not null); +CREATE TABLE t6( ts TIMESTAMP(6) not null, dt DATETIME(6) not null); +INSERT INTO t0 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t1 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t2 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t3 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t4 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t5 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t6 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +SELECT * FROM t0; +ts dt +1970-01-01 00:00:02 1970-01-01 00:00:02 +SELECT * FROM t1; +ts dt +1970-01-01 00:00:02.0 1970-01-01 00:00:02.0 +SELECT * FROM t2; +ts dt +1970-01-01 00:00:02.00 1970-01-01 00:00:02.00 +SELECT * FROM t3; +ts dt +1970-01-01 00:00:02.000 1970-01-01 00:00:02.000 +SELECT * FROM t4; +ts dt +1970-01-01 00:00:02.0000 1970-01-01 00:00:02.0000 +SELECT * FROM t5; +ts dt +1970-01-01 00:00:02.00000 1970-01-01 00:00:02.00000 +SELECT * FROM t6; +ts dt +1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999999 +DROP TABLE t0, t1, t2, t3, t4, t5, t6; +SET sql_mode=time_truncate_fractional; +SET SESSION TIMESTAMP=1.9999996; +CREATE TABLE t0( ts TIMESTAMP(0) not null, dt DATETIME(0) not null); +CREATE TABLE t1( ts TIMESTAMP(1) not null, dt DATETIME(1) not null); +CREATE TABLE t2( ts TIMESTAMP(2) not null, dt DATETIME(2) not null); +CREATE TABLE t3( ts TIMESTAMP(3) not null, dt DATETIME(3) not null); +CREATE TABLE t4( ts TIMESTAMP(4) not null, dt DATETIME(4) not null); +CREATE TABLE t5( ts TIMESTAMP(5) not null, dt DATETIME(5) not null); +CREATE TABLE t6( ts TIMESTAMP(6) not null, dt DATETIME(6) not null); +INSERT INTO t0 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t1 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t2 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t3 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t4 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t5 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +INSERT INTO t6 values (CURRENT_TIMESTAMP(6), CURRENT_TIMESTAMP(6)); +SELECT * FROM t0; +ts dt +1970-01-01 00:00:01 1970-01-01 00:00:01 +SELECT * FROM t1; +ts dt +1970-01-01 00:00:01.9 1970-01-01 00:00:01.9 +SELECT * FROM t2; +ts dt +1970-01-01 00:00:01.99 1970-01-01 00:00:01.99 +SELECT * FROM t3; +ts dt +1970-01-01 00:00:01.999 1970-01-01 00:00:01.999 +SELECT * FROM t4; +ts dt +1970-01-01 00:00:01.9999 1970-01-01 00:00:01.9999 +SELECT * FROM t5; +ts dt +1970-01-01 00:00:01.99999 1970-01-01 00:00:01.99999 +SELECT * FROM t6; +ts dt +1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999999 +DROP TABLE t0, t1, t2, t3, t4, t5, t6; +SET sql_mode=default; +SET SESSION TIMESTAMP=default; +SET time_zone=default; +# +# Bug#29594951 DECIMAL2LLDIV_T REFERS TO UNINITIALIZED VALUES! +# +CREATE TABLE t1 (c1 LONGTEXT); +INSERT INTO t1 VALUES('2018-10-15 01:29:55'); +SELECT * FROM t1 WHERE +'2018-10-15 01:29:55'=(c1 + INTERVAL(json_keys(0xceedc36e,'$$')) SECOND); +ERROR 22032: Cannot create a JSON value from a string with CHARACTER SET 'binary'. +DROP TABLE t1; +# +# Bug#29587536 UBSAN: SIGNED INTEGER OVERFLOW IN +# ITEM_DATE_ADD_INTERVAL::GET_TIME_INTERNAL +# +do date_add(utc_time(), interval(oct(-11779)) microsecond); +Warnings: +Warning 1441 Datetime function: time field overflow +# +# Bug #31054071 UBSAN: SIGNED INTEGER OVERFLOW IN +# ITEM_DATE_ADD_INTERVAL::GET_TIME_INTERNAL +# +CREATE TABLE t(a TIME(1), b DECIMAL(55,13)); +INSERT INTO t(a,b) VALUES +('-765:38:03.6',999999999999999999999999999999999999999999.9999999999999); +SELECT a - INTERVAL(b) MICROSECOND FROM t; +a - INTERVAL(b) MICROSECOND +NULL +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '999999999999999999999999999999999999999999.9999999999999' +Warning 1441 Datetime function: time field overflow +DROP TABLE t; +# +# Bug #30324587 ASSERTION FAILED: (*REF)->IS_TEMPORAL() +# +SELECT current_date IN ( MAX(NULL), 1 ); +current_date IN ( MAX(NULL), 1 ) +NULL +SELECT current_time IN ( MAX(NULL), 1 ); +current_time IN ( MAX(NULL), 1 ) +NULL diff --git a/mysql-test/r/type_time.result-pq b/mysql-test/r/type_time.result-pq new file mode 100644 index 000000000..561e3fc0c --- /dev/null +++ b/mysql-test/r/type_time.result-pq @@ -0,0 +1,2820 @@ +drop table if exists t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (t time); +insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34"); +Warnings: +Note 1265 Data truncated for column 't' at row 13 +insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32"); +select * from t1; +t +10:22:33 +12:34:57 +00:00:10 +00:12:34 +12:34:57 +123:46:00 +00:00:01 +01:23:00 +01:23:45 +00:00:10 +-241:22:33 +490:22:33 +20:33:34 +00:00:30 +00:12:30 +00:12:30 +12:30:00 +12:30:35 +36:30:31 +insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a"); +Warnings: +Warning 1265 Data truncated for column 't' at row 1 +Warning 1264 Out of range value for column 't' at row 2 +Warning 1264 Out of range value for column 't' at row 3 +Warning 1264 Out of range value for column 't' at row 4 +Warning 1265 Data truncated for column 't' at row 6 +select * from t1; +t +10:22:33 +12:34:57 +00:00:10 +00:12:34 +12:34:57 +123:46:00 +00:00:01 +01:23:00 +01:23:45 +00:00:10 +-241:22:33 +490:22:33 +20:33:34 +00:00:30 +00:12:30 +00:12:30 +12:30:00 +12:30:35 +36:30:31 +00:00:10 +00:00:00 +838:59:59 +838:59:59 +262:22:00 +00:00:12 +drop table t1; +create table t1 (t time); +insert into t1 values ('09:00:00'),('13:00:00'),('19:38:34'), ('13:00:00'),('09:00:00'),('09:00:00'),('13:00:00'),('13:00:00'),('13:00:00'),('09:00:00'); +select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1; +t time_to_sec(t) sec_to_time(time_to_sec(t)) +09:00:00 32400 09:00:00 +13:00:00 46800 13:00:00 +19:38:34 70714 19:38:34 +13:00:00 46800 13:00:00 +09:00:00 32400 09:00:00 +09:00:00 32400 09:00:00 +13:00:00 46800 13:00:00 +13:00:00 46800 13:00:00 +13:00:00 46800 13:00:00 +09:00:00 32400 09:00:00 +select sec_to_time(time_to_sec(t)) from t1; +sec_to_time(time_to_sec(t)) +09:00:00 +13:00:00 +19:38:34 +13:00:00 +09:00:00 +09:00:00 +13:00:00 +13:00:00 +13:00:00 +09:00:00 +drop table t1; +CREATE TABLE t1 (t TIME); +INSERT INTO t1 VALUES (+10), (+10.0), (+10e0); +INSERT INTO t1 VALUES (-10), (-10.0), (-10e0); +SELECT * FROM t1; +t +00:00:10 +00:00:10 +00:00:10 +-00:00:10 +-00:00:10 +-00:00:10 +DROP TABLE t1; +SELECT CAST(235959.123456 AS TIME); +CAST(235959.123456 AS TIME) +23:59:59 +SELECT CAST(0.235959123456e+6 AS TIME); +CAST(0.235959123456e+6 AS TIME) +23:59:59 +SELECT CAST(235959123456e-6 AS TIME); +CAST(235959123456e-6 AS TIME) +23:59:59 +SELECT CAST(235959.1234567 AS TIME); +CAST(235959.1234567 AS TIME) +23:59:59 +SELECT CAST(0.2359591234567e6 AS TIME); +CAST(0.2359591234567e6 AS TIME) +23:59:59 +SELECT CAST(0.2359591234567e+30 AS TIME); +CAST(0.2359591234567e+30 AS TIME) +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '2.359591234567e29' +End of 4.1 tests +select cast('100:55:50' as time) < cast('24:00:00' as time); +cast('100:55:50' as time) < cast('24:00:00' as time) +0 +select cast('100:55:50' as time) < cast('024:00:00' as time); +cast('100:55:50' as time) < cast('024:00:00' as time) +0 +select cast('300:55:50' as time) < cast('240:00:00' as time); +cast('300:55:50' as time) < cast('240:00:00' as time) +0 +select cast('100:55:50' as time) > cast('24:00:00' as time); +cast('100:55:50' as time) > cast('24:00:00' as time) +1 +select cast('100:55:50' as time) > cast('024:00:00' as time); +cast('100:55:50' as time) > cast('024:00:00' as time) +1 +select cast('300:55:50' as time) > cast('240:00:00' as time); +cast('300:55:50' as time) > cast('240:00:00' as time) +1 +create table t1 (f1 time); +insert into t1 values ('24:00:00'); +select cast('24:00:00' as time) = (select f1 from t1); +cast('24:00:00' as time) = (select f1 from t1) +1 +drop table t1; +create table t1(f1 time, f2 time); +insert into t1 values('20:00:00','150:00:00'); +select 1 from t1 where cast('100:00:00' as time) between f1 and f2; +1 +1 +drop table t1; +CREATE TABLE t1 ( +f2 date NOT NULL, +f3 int(11) unsigned NOT NULL default '0', +PRIMARY KEY (f3, f2) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values('2007-07-01', 1); +insert into t1 values('2007-07-01', 2); +insert into t1 values('2007-07-02', 1); +insert into t1 values('2007-07-02', 2); +SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; +sum(f3) +3 +drop table t1; +# +# Bug #44792: valgrind warning when casting from time to time +# +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +CAST(c AS TIME) +00:00:00 +DROP TABLE t1; +End of 5.0 tests +# +# Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values +# +SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 01:00:00'); +CREATE TABLE t1(f1 TIME); +INSERT INTO t1 VALUES ('23:38:57'); +SELECT TIMESTAMP(f1,'1') FROM t1; +TIMESTAMP(f1,'1') +2001-01-01 23:38:58 +DROP TABLE t1; +SET @@timestamp=default; +End of 5.1 tests +CREATE TABLE t1 (f1 TIME); +INSERT INTO t1 VALUES ('24:00:00'); +SELECT '24:00:00' = (SELECT f1 FROM t1); +'24:00:00' = (SELECT f1 FROM t1) +1 +SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1) +1 +SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1) +0 +TRUNCATE t1; +INSERT INTO t1 VALUES ('-24:00:00'); +SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1) +0 +SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1); +CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1) +1 +SELECT '-24:00:00' = (SELECT f1 FROM t1); +'-24:00:00' = (SELECT f1 FROM t1) +1 +DROP TABLE t1; +# +# Start of 5.6 tests +# +# +# WL#946 Testing <=> operator with TIME +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('20:00:00'),('19:20:30'); +SELECT * FROM t1 WHERE a<=>'19:20:30'; +a +19:20:30 +SELECT * FROM t1 WHERE a<=>TIME'19:20:30'; +a +19:20:30 +SELECT * FROM t1 WHERE a<=>192030; +a +19:20:30 +DROP TABLE t1; +# +# WL#946: Testing rounding +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('10:10:10.9999994'), ('10:10:10.9999995'); +INSERT INTO t1 VALUES (101010.9999994), (101010.9999995); +SELECT * FROM t1; +a +10:10:11 +10:10:11 +10:10:11 +10:10:11 +DROP TABLE t1; +# +# Before WL#946 TIME did not reject too big negative minutes/seconds +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('-10:60:59'), ('-10:59:60'), (-106059), (-105960); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'a' at row 3 +Warning 1264 Out of range value for column 'a' at row 4 +SELECT * FROM t1; +a +00:00:00 +00:00:00 +00:00:00 +00:00:00 +DROP TABLE t1; +# +# WL#946 Make sure case from number to TIME properly handles +# too big negative minutes/secons +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (-106059), (-105960); +SELECT CAST(a AS TIME) FROM t1; +CAST(a AS TIME) +NULL +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '-106059' +Warning 1292 Truncated incorrect time value: '-105960' +DROP TABLE t1; +# +# WL#946 Checking function TIME() +# +SELECT TIME('1000009:10:10'); +TIME('1000009:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009:10:10' +SELECT TIME('1000009:10:10.1999999999999'); +TIME('1000009:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009:10:10.1999999999999' +SELECT TIME('10000090:10:10'); +TIME('10000090:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '10000090:10:10' +SELECT TIME('10000090:10:10.1999999999999'); +TIME('10000090:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '10000090:10:10.1999999999999' +SELECT TIME('100000900:10:10'); +TIME('100000900:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '100000900:10:10' +SELECT TIME('100000900:10:10.1999999999999'); +TIME('100000900:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '100000900:10:10.1999999999999' +SELECT TIME('1000009000:10:10'); +TIME('1000009000:10:10') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009000:10:10' +SELECT TIME('1000009000:10:10.1999999999999'); +TIME('1000009000:10:10.1999999999999') +838:59:59.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '1000009000:10:10.1999999999999' +SELECT TIME('10000090000:10:10'); +TIME('10000090000:10:10') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '10000090000:10:10' +SELECT TIME('10000090000:10:10.1999999999999'); +TIME('10000090000:10:10.1999999999999') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '10000090000:10:10.1999999999999' +# +# Checking Item_func_if::val_str with TIME arguments +# +SELECT CAST(IF(1, TIME'00:00:00',TIME'00:00:00') AS CHAR); +CAST(IF(1, TIME'00:00:00',TIME'00:00:00') AS CHAR) +00:00:00 +# +# Checking Item_func_case::val_str with TIME arguments +# +SELECT CAST(CASE WHEN 1 THEN TIME'00:00:00' ELSE TIME'00:00:00' END AS CHAR); +CAST(CASE WHEN 1 THEN TIME'00:00:00' ELSE TIME'00:00:00' END AS CHAR) +00:00:00 +# +# Testing CASE with TIME type without a found item +# +SELECT CAST(CASE WHEN 0 THEN '01:01:01' END AS TIME); +CAST(CASE WHEN 0 THEN '01:01:01' END AS TIME) +NULL +SELECT CAST(CASE WHEN 0 THEN TIME'01:01:01' END AS TIME); +CAST(CASE WHEN 0 THEN TIME'01:01:01' END AS TIME) +NULL +# +# Testing COALESCE with TIME type without a found item +# +SELECT COALESCE(TIME(NULL)); +COALESCE(TIME(NULL)) +NULL +# +# Testing TIME field with NULL value with NOT IN +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 WHERE a NOT IN (TIME'20:20:20',TIME'10:10:10'); +a +DROP TABLE t1; +# +# Testing Item_func_numhybrid::val_int when TIME type +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('10:10:10'); +SELECT CAST(COALESCE(a,a) AS SIGNED) FROM t1; +CAST(COALESCE(a,a) AS SIGNED) +101010 +DROP TABLE t1; +# +# Testing Item_func_numhybrid::val_decimal when TIME type +# +CREATE TABLE t1 (a TIME); +INSERT INTO t1 VALUES ('10:10:10'); +SELECT CAST(COALESCE(a,a) AS DECIMAL(23,6)) FROM t1; +CAST(COALESCE(a,a) AS DECIMAL(23,6)) +101010.000000 +DROP TABLE t1; +# +# Testing Item_func_numhybrid::get_time when non-temporal type +# +SELECT CAST(COALESCE(10,20) AS TIME); +CAST(COALESCE(10,20) AS TIME) +00:00:10 +# +# Testing Item_func_min_max::get_time when DATE type and NULL +# +SELECT CAST(LEAST(DATE(NULL), DATE(NULL)) AS TIME); +CAST(LEAST(DATE(NULL), DATE(NULL)) AS TIME) +NULL +# +# Testing Item_func_min_max::get_time with non-temporal arguments +# +SELECT CAST(LEAST(111111,222222) AS TIME); +CAST(LEAST(111111,222222) AS TIME) +11:11:11 +# +# Item::get_time_from_numeric +# +SELECT CAST(SUM(0) AS TIME); +CAST(SUM(0) AS TIME) +00:00:00 +SELECT CAST(SUM(0 + 0e0) AS TIME); +CAST(SUM(0 + 0e0) AS TIME) +00:00:00 +SET timestamp=1322115328; +SELECT CAST(UNIX_TIMESTAMP() AS TIME); +CAST(UNIX_TIMESTAMP() AS TIME) +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '1322115328' +SET timestamp=default; +# +# Item::get_time_from_non_temporal +# +SELECT TIME(154559.616 + 0e0); +TIME(154559.616 + 0e0) +15:45:59.616000 +# +# Item_name_const::get_time +# +SELECT TIME(NAME_CONST('a', 0)); +TIME(NAME_CONST('a', 0)) +00:00:00 +# +# Item_cache_datetime::get_time +# +CREATE TABLE t1 (a DATE); +INSERT INTO t1 VALUES (0); +SELECT TIME(MIN(a)) FROM t1; +TIME(MIN(a)) +00:00:00 +DROP TABLE t1; +# +# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH +# TIME/DATETIME COMPARE" +# +# Systematic testing of ref access and range scan +SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); +CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key)) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('00:00:00'),('-24:00:00'),('-48:00:00'),('24:00:00'),('48:00:00'); +CREATE TABLE t2 (col_datetime_key DATETIME, KEY(col_datetime_key)) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1; +ANALYZE TABLE t2; +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using where; Using index +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key = col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using where; Using index +2 SIMPLE t2 NULL ref col_datetime_key col_datetime_key 6 test.t1.col_time_key 1 100.00 Using where; Using index +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key = col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) = `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key = col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 20.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use ref access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` = cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key = col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key >= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key >= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) >= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key >= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` >= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key >= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key > col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key > col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key > col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` > cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key > col_time_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key <= col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-30 00:00:00 +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-29 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-01-31 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-01 00:00:00 +24:00:00 2012-02-02 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key <= col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +-24:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +00:00:00 2012-01-31 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +24:00:00 2012-02-01 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +48:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) <= `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key <= col_datetime_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` <= cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key <= col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 -48:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 -24:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 00:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 24:00:00 +2012-02-01 00:00:00 48:00:00 +2012-02-02 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` IGNORE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 ignore INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` IGNORE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 ignore INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_time_key < col_datetime_key; +col_time_key col_datetime_key +-24:00:00 2012-01-31 00:00:00 +-24:00:00 2012-02-01 00:00:00 +-24:00:00 2012-02-02 00:00:00 +-48:00:00 2012-01-30 00:00:00 +-48:00:00 2012-01-31 00:00:00 +-48:00:00 2012-02-01 00:00:00 +-48:00:00 2012-02-02 00:00:00 +00:00:00 2012-02-01 00:00:00 +00:00:00 2012-02-02 00:00:00 +24:00:00 2012-02-02 00:00:00 +EXPLAIN SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 100.00 Using index +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 5 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col_time_key` AS `col_time_key`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` FORCE INDEX (`col_time_key`) straight_join `test`.`t2` FORCE INDEX (`col_datetime_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t1 force INDEX (col_time_key) +STRAIGHT_JOIN +t2 force INDEX (col_datetime_key) +WHERE col_datetime_key < col_time_key; +col_time_key col_datetime_key +-24:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-29 00:00:00 +00:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-29 00:00:00 +24:00:00 2012-01-30 00:00:00 +24:00:00 2012-01-31 00:00:00 +48:00:00 2012-01-29 00:00:00 +48:00:00 2012-01-30 00:00:00 +48:00:00 2012-01-31 00:00:00 +48:00:00 2012-02-01 00:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` IGNORE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 ignore INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` IGNORE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 ignore INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (cast(`test`.`t1`.`col_time_key` as datetime) < `test`.`t2`.`col_datetime_key`) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_time_key < col_datetime_key; +col_datetime_key col_time_key +2012-01-30 00:00:00 -48:00:00 +2012-01-31 00:00:00 -24:00:00 +2012-01-31 00:00:00 -48:00:00 +2012-02-01 00:00:00 -24:00:00 +2012-02-01 00:00:00 -48:00:00 +2012-02-01 00:00:00 00:00:00 +2012-02-02 00:00:00 -24:00:00 +2012-02-02 00:00:00 -48:00:00 +2012-02-02 00:00:00 00:00:00 +2012-02-02 00:00:00 24:00:00 +EXPLAIN SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index col_datetime_key col_datetime_key 6 NULL 5 100.00 Using index +2 SIMPLE t1 NULL index col_time_key col_time_key 4 NULL 5 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t1`.`col_time_key` AS `col_time_key` from `test`.`t2` FORCE INDEX (`col_datetime_key`) straight_join `test`.`t1` FORCE INDEX (`col_time_key`) where (`test`.`t2`.`col_datetime_key` < cast(`test`.`t1`.`col_time_key` as datetime)) +SELECT * FROM +t2 force INDEX (col_datetime_key) +STRAIGHT_JOIN +t1 force INDEX (col_time_key) +WHERE col_datetime_key < col_time_key; +col_datetime_key col_time_key +2012-01-29 00:00:00 -24:00:00 +2012-01-29 00:00:00 00:00:00 +2012-01-29 00:00:00 24:00:00 +2012-01-29 00:00:00 48:00:00 +2012-01-30 00:00:00 00:00:00 +2012-01-30 00:00:00 24:00:00 +2012-01-30 00:00:00 48:00:00 +2012-01-31 00:00:00 24:00:00 +2012-01-31 00:00:00 48:00:00 +2012-02-01 00:00:00 48:00:00 +DROP TABLE t1,t2; + +# Original test of the bug report + +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_nokey INT, +col_int_key INT NOT NULL, +PRIMARY KEY (pk), +KEY col_int_key (col_int_key) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), +(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), +(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), +(27,3,5), (28,6,0), (29,6,3); +CREATE TABLE t2 ( +col_int_nokey INT NOT NULL, +col_datetime_key DATETIME NOT NULL, +col_varchar_key VARCHAR(1) NOT NULL, +KEY col_datetime_key (col_datetime_key), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); +CREATE TABLE t3 ( +col_time_key TIME, +KEY col_time_key (col_time_key) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), +('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), +('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), +('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), +('02:59:24'), ('00:01:58'); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +ANALYZE TABLE t3; +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 FORCE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (hash join) +Warnings: +Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_nokey` AS `col_int_nokey`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t3`.`col_time_key` AS `col_time_key` from `test`.`t2` straight_join `test`.`t3` FORCE INDEX (`col_time_key`) where (cast(`test`.`t3`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM t2 STRAIGHT_JOIN t3 FORCE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +col_int_nokey col_datetime_key col_varchar_key col_time_key +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:01:58 +1 2001-11-04 19:07:55 k 00:21:38 +1 2001-11-04 19:07:55 k 02:59:24 +1 2001-11-04 19:07:55 k 03:53:16 +1 2001-11-04 19:07:55 k 04:08:02 +1 2001-11-04 19:07:55 k 05:03:03 +1 2001-11-04 19:07:55 k 07:05:51 +1 2001-11-04 19:07:55 k 09:16:38 +1 2001-11-04 19:07:55 k 10:14:58 +1 2001-11-04 19:07:55 k 10:50:38 +1 2001-11-04 19:07:55 k 11:14:24 +1 2001-11-04 19:07:55 k 15:37:26 +1 2001-11-04 19:07:55 k 15:57:25 +1 2001-11-04 19:07:55 k 16:25:11 +1 2001-11-04 19:07:55 k 19:22:21 +1 2001-11-04 19:07:55 k 19:47:59 +1 2001-11-04 19:07:55 k 21:22:34 +EXPLAIN SELECT * FROM t2 STRAIGHT_JOIN t3 IGNORE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL col_datetime_key NULL NULL NULL 1 100.00 NULL +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`col_int_nokey` AS `col_int_nokey`,`test`.`t2`.`col_datetime_key` AS `col_datetime_key`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t3`.`col_time_key` AS `col_time_key` from `test`.`t2` straight_join `test`.`t3` IGNORE INDEX (`col_time_key`) where (cast(`test`.`t3`.`col_time_key` as datetime) > `test`.`t2`.`col_datetime_key`) +SELECT * FROM t2 STRAIGHT_JOIN t3 IGNORE INDEX (col_time_key) +ON t3.col_time_key > t2.col_datetime_key; +col_int_nokey col_datetime_key col_varchar_key col_time_key +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:00:00 +1 2001-11-04 19:07:55 k 00:01:58 +1 2001-11-04 19:07:55 k 00:21:38 +1 2001-11-04 19:07:55 k 02:59:24 +1 2001-11-04 19:07:55 k 03:53:16 +1 2001-11-04 19:07:55 k 04:08:02 +1 2001-11-04 19:07:55 k 05:03:03 +1 2001-11-04 19:07:55 k 07:05:51 +1 2001-11-04 19:07:55 k 09:16:38 +1 2001-11-04 19:07:55 k 10:14:58 +1 2001-11-04 19:07:55 k 10:50:38 +1 2001-11-04 19:07:55 k 11:14:24 +1 2001-11-04 19:07:55 k 15:37:26 +1 2001-11-04 19:07:55 k 15:57:25 +1 2001-11-04 19:07:55 k 16:25:11 +1 2001-11-04 19:07:55 k 19:22:21 +1 2001-11-04 19:07:55 k 19:47:59 +1 2001-11-04 19:07:55 k 21:22:34 +DROP TABLE t1,t2,t3; +SET TIMESTAMP = DEFAULT; +SET sql_mode = default; +# +# End of 5.6 tests +# diff --git a/mysql-test/r/type_timestamp.result-pq b/mysql-test/r/type_timestamp.result-pq new file mode 100644 index 000000000..257041904 --- /dev/null +++ b/mysql-test/r/type_timestamp.result-pq @@ -0,0 +1,686 @@ +drop table if exists t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +set time_zone="+03:00"; +CREATE TABLE t1 (a int, t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +CREATE TABLE t2 (a int, t datetime); +SET TIMESTAMP=1234; +insert into t1 values(1,NULL); +insert into t1 values(2,"2002-03-03"); +SET TIMESTAMP=1235; +insert into t1 values(3,NULL); +SET TIMESTAMP=1236; +insert into t1 (a) values(4); +insert into t2 values(5,"2002-03-04"),(6,NULL),(7,"2002-03-05"),(8,"00-00-00"); +SET TIMESTAMP=1237; +insert into t1 select * from t2; +SET TIMESTAMP=1238; +insert into t1 (a) select a+1 from t2 where a=8; +select * from t1; +a t +1 1970-01-01 03:20:34 +2 2002-03-03 00:00:00 +3 1970-01-01 03:20:35 +4 1970-01-01 03:20:36 +5 2002-03-04 00:00:00 +6 1970-01-01 03:20:37 +7 2002-03-05 00:00:00 +8 0000-00-00 00:00:00 +9 1970-01-01 03:20:38 +drop table t1,t2; +SET TIMESTAMP=1234; +CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id)); +INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00"); +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET value="my value" WHERE id="myKey"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET id="myKey" WHERE value="my value"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +drop table t1; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (now()); +select date_format(a,"%Y %y"),year(a),year(now()) from t1; +date_format(a,"%Y %y") year(a) year(now()) +1970 70 1970 1970 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +19990930232922 +19990531232922 +19990501000000 +19991101000000 +19990501000000 +truncate table t1; +insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +drop table t1; +CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959); +INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000); +INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959); +INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000); +INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000); +INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000); +INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000); +INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959); +INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000); +INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959); +INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000); +INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000); +SELECT * FROM t1; +date date_time time_stamp +1998-12-31 1998-12-31 23:59:59 1998-12-31 23:59:59 +1999-01-01 1999-01-01 00:00:00 1999-01-01 00:00:00 +1999-09-09 1999-09-09 23:59:59 1999-09-09 23:59:59 +2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00 +2000-02-28 2000-02-28 00:00:00 2000-02-28 00:00:00 +2000-02-29 2000-02-29 00:00:00 2000-02-29 00:00:00 +2000-03-01 2000-03-01 00:00:00 2000-03-01 00:00:00 +2000-12-31 2000-12-31 23:59:59 2000-12-31 23:59:59 +2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00 +2004-12-31 2004-12-31 23:59:59 2004-12-31 23:59:59 +2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00 +2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1265 Data truncated for column 'ix' at row 7 +Warning 1265 Data truncated for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1264 Out of range value for column 'ix' at row 7 +Warning 1264 Out of range value for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 1 +Warning 1265 Data truncated for column 'ix' at row 2 +select ix+0 from t1; +ix+0 +0 +20030101000000 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00', t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000000; +insert into t1 values (); +SET TIMESTAMP=1000000001; +update t1 set t2=now(); +SET TIMESTAMP=1000000002; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2003-01-01 00:00:00 2001-09-09 04:46:41 0000-00-00 00:00:00 +2003-01-01 00:00:00 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00', + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default now(), t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000002; +insert into t1 values (); +SET TIMESTAMP=1000000003; +update t1 set t2=now(); +SET TIMESTAMP=1000000003; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:42 2001-09-09 04:46:43 0000-00-00 00:00:00 +2001-09-09 04:46:43 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00' on update now(), t2 datetime); +SET TIMESTAMP=1000000004; +insert into t1 values (); +select * from t1; +t1 t2 +2003-01-01 00:00:00 NULL +SET TIMESTAMP=1000000005; +update t1 set t2=now(); +SET TIMESTAMP=1000000005; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:45 2001-09-09 04:46:45 +2003-01-01 00:00:00 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp not null default now() on update now(), t2 datetime); +SET TIMESTAMP=1000000006; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:46 NULL +SET TIMESTAMP=1000000007; +update t1 set t2=now(); +SET TIMESTAMP=1000000007; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:47 2001-09-09 04:46:47 +2001-09-09 04:46:47 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000007; +insert into t1 values (); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:47 NULL 0000-00-00 00:00:00 +SET TIMESTAMP=1000000008; +update t1 set t2=now(); +SET TIMESTAMP=1000000008; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:48 2001-09-09 04:46:48 0000-00-00 00:00:00 +2001-09-09 04:46:48 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp, t2 datetime); +SET TIMESTAMP=1000000009; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:49 NULL +SET TIMESTAMP=1000000010; +update t1 set t2=now(); +SET TIMESTAMP=1000000011; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:50 2001-09-09 04:46:50 +2001-09-09 04:46:51 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +truncate table t1; +insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); +SET TIMESTAMP=1000000012; +update t1 set t1= '2004-04-02 00:00:00'; +select * from t1; +t1 t2 +2004-04-02 00:00:00 2004-04-01 00:00:00 +update t1 as ta, t1 as tb set tb.t1= '2004-04-03 00:00:00'; +select * from t1; +t1 t2 +2004-04-03 00:00:00 2004-04-01 00:00:00 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000013; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:53 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default '2003-01-01 00:00:00' on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000014; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2003-01-01 00:00:00 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000015; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:55 20 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp); +insert into t1 values ('2004-04-01 00:00:00'); +SET TIMESTAMP=1000000016; +alter table t1 add i int default 10; +select * from t1; +t1 i +2004-04-01 00:00:00 10 +drop table t1; +create table t1 (a timestamp null, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000017; +insert into t1 values (); +select * from t1; +a b +NULL NULL +NULL NULL +drop table t1; +create table t1 (a timestamp null default current_timestamp on update current_timestamp, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000018; +insert into t1 values (); +select * from t1; +a b +NULL NULL +2001-09-09 04:46:58 NULL +drop table t1; +create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT '2003-01-01 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +insert into t1 values (DEFAULT, DEFAULT); +select * from t1; +a b +NULL NULL +NULL 2003-01-01 00:00:00 +drop table t1; +create table t1 (a bigint, b bigint); +insert into t1 values (NULL, NULL), (20030101000000, 20030102000000); +set timestamp=1000000019; +alter table t1 modify a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modify b timestamp NOT NULL DEFAULT '0000-00-00 00:00:0'; +select * from t1; +a b +2001-09-09 04:46:59 2001-09-09 04:46:59 +2003-01-01 00:00:00 2003-01-02 00:00:00 +drop table t1; +create table t1 (a char(2), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), +('b', '2004-02-01 00:00:00'); +select max(t) from t1 group by a; +max(t) +2004-01-01 01:00:00 +2004-02-01 00:00:00 +drop table t1; +create table t1 (a int auto_increment primary key, b int, c timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 (a, b, c) values (1, 0, '2001-01-01 01:01:01'), +(2, 0, '2002-02-02 02:02:02'), (3, 0, '2003-03-03 03:03:03'); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 0 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +update t1 set b = 2, c = c where a = 2; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +insert into t1 (a) values (4); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2001-09-09 04:46:59 +update t1 set c = '2004-04-04 04:04:04' where a = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +insert into t1 (a) values (3), (5) on duplicate key update b = 3, c = c; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +5 NULL 2001-09-09 04:46:59 +insert into t1 (a, c) values (4, '2004-04-04 00:00:00'), +(6, '2006-06-06 06:06:06') on duplicate key update b = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 4 2001-09-09 04:46:59 +5 NULL 2001-09-09 04:46:59 +6 NULL 2006-06-06 06:06:06 +drop table t1; +End of 4.1 tests +set time_zone= @@global.time_zone; +CREATE TABLE t1 ( f1 INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, +f2 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +f3 TIMESTAMP NOT NULL default '0000-00-00 00:00:00'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (f2,f3) VALUES (NOW(), "0000-00-00 00:00:00"); +INSERT INTO t1 (f2,f3) VALUES (NOW(), NULL); +INSERT INTO t1 (f2,f3) VALUES (NOW(), ASCII(NULL)); +INSERT INTO t1 (f2,f3) VALUES (NOW(), FROM_UNIXTIME('9999999999')); +INSERT INTO t1 (f2,f3) VALUES (NOW(), TIME(NULL)); +UPDATE t1 SET f2=NOW(), f3=FROM_UNIXTIME('9999999999') WHERE f1=1; +SELECT f1,f2-f3 FROM t1; +f1 f2-f3 +1 0 +2 0 +3 0 +4 0 +5 0 +DROP TABLE t1; +End of 5.0 tests +# +# Bug #55779: select does not work properly in mysql server +# Version "5.1.42 SUSE MySQL RPM" +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY (a)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), +('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); +SELECT a FROM t1 WHERE a >= 20000101000000; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +SELECT a FROM t1 WHERE a >= '20000101000000'; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +DROP TABLE t1; +# +# Bug#50774: failed to get the correct resultset when timestamp values +# are appended with .0 +# +CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:04' ); +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +CREATE TABLE t2 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:04' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:05' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:06' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:07' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:08' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:09' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:10' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:11' ); +# The bug would cause the range optimizer's comparison to use an open +# interval here. This reveals itself only in the number of reads +# performed. +FLUSH STATUS; +SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +SHOW STATUS LIKE 'Handler_read_next'; +Variable_name Value +Handler_read_next 0 +DROP TABLE t1, t2; +End of 5.1 tests + +Bug#50888 valgrind warnings in Field_timestamp::val_str + +SET TIMESTAMP=0; +CREATE TABLE t1(a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02'); +FLUSH TABLES t1; +SELECT MAX(a) FROM t1; +MAX(a) +2010-03-05 11:08:02 +SELECT a FROM t1; +a +2008-02-23 09:23:45 +2010-03-05 11:08:02 +DROP TABLE t1; +End of Bug#50888 +# +# Bug59330: Incorrect result when comparing an aggregate +# function with TIMESTAMP +# +CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP); +INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30'); +SELECT MAX(dt), MAX(ts) FROM t1; +MAX(dt) MAX(ts) +2011-01-06 12:34:30 2011-01-06 12:34:30 +SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1; +MAX(ts) < '2010-01-01 00:00:00' +0 +SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1; +MAX(dt) < '2010-01-01 00:00:00' +0 +SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1; +MAX(ts) > '2010-01-01 00:00:00' +1 +SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1; +MAX(dt) > '2010-01-01 00:00:00' +1 +SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1; +MAX(ts) = '2011-01-06 12:34:30' +1 +SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1; +MAX(dt) = '2011-01-06 12:34:30' +1 +DROP TABLE t1; +End of 5.5 tests +# +# Start of 5.6 tests +# +# +# Bug#13596893 - "ERROR 1690 (22003): BIGINT UNSIGNED VALUE IS OUT OF RANGE" ON DATE OPERATION +# +CREATE TABLE t1 ( +`c1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +`c2` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' +); +INSERT INTO t1 VALUES ('2003-05-16 23:53:29','2000-01-27 23:13:41'); +SELECT c2-c1 FROM t1; +c2-c1 +-30389003988 +SELECT * FROM t1; +c1 c2 +2003-05-16 23:53:29 2000-01-27 23:13:41 +SELECT TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29'; +TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29' +-30389003988 +SELECT TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29'); +TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29') +-30389003988 +DROP TABLE t1; +SET sql_mode = default; +# +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE IF EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 INT); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +# +# End of 5.6 tests +# diff --git a/mysql-test/r/type_timestamp_explicit.result-pq b/mysql-test/r/type_timestamp_explicit.result-pq new file mode 100644 index 000000000..80768ec92 --- /dev/null +++ b/mysql-test/r/type_timestamp_explicit.result-pq @@ -0,0 +1,872 @@ +drop table if exists t1,t2; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +set time_zone="+03:00"; +CREATE TABLE t1 (a int, t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +CREATE TABLE t2 (a int, t datetime); +SET TIMESTAMP=1234; +insert into t1 values(2,"2002-03-03"); +SET TIMESTAMP=1235; +SET TIMESTAMP=1236; +insert into t1 (a) values(4); +insert into t2 values(5,"2002-03-04"),(6,NULL),(7,"2002-03-05"),(8,"00-00-00"); +SET TIMESTAMP=1237; +insert into t1 select * from t2; +Warnings: +Warning 1048 Column 't' cannot be null +SET TIMESTAMP=1238; +insert into t1 (a) select a+1 from t2 where a=8; +select * from t1; +a t +2 2002-03-03 00:00:00 +4 1970-01-01 03:20:36 +5 2002-03-04 00:00:00 +6 0000-00-00 00:00:00 +7 2002-03-05 00:00:00 +8 0000-00-00 00:00:00 +9 1970-01-01 03:20:38 +drop table t1,t2; +SET TIMESTAMP=1234; +CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id)); +INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00"); +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET value="my value" WHERE id="myKey"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +UPDATE t1 SET id="myKey" WHERE value="my value"; +SELECT stamp FROM t1 WHERE id="myKey"; +stamp +1999-04-02 00:00:00 +drop table t1; +create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (now()); +select date_format(a,"%Y %y"),year(a),year(now()) from t1; +date_format(a,"%Y %y") year(a) year(now()) +1970 70 1970 1970 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +19990930232922 +19990531232922 +19990501000000 +19991101000000 +19990501000000 +truncate table t1; +insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"); +select ix+0 from t1; +ix+0 +19991101000000 +19990102030405 +19990630232922 +19990601000000 +drop table t1; +CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959); +INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000); +INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959); +INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000); +INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000); +INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000); +INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000); +INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959); +INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000); +INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959); +INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000); +INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000); +SELECT * FROM t1; +date date_time time_stamp +1998-12-31 1998-12-31 23:59:59 1998-12-31 23:59:59 +1999-01-01 1999-01-01 00:00:00 1999-01-01 00:00:00 +1999-09-09 1999-09-09 23:59:59 1999-09-09 23:59:59 +2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00 +2000-02-28 2000-02-28 00:00:00 2000-02-28 00:00:00 +2000-02-29 2000-02-29 00:00:00 2000-02-29 00:00:00 +2000-03-01 2000-03-01 00:00:00 2000-03-01 00:00:00 +2000-12-31 2000-12-31 23:59:59 2000-12-31 23:59:59 +2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00 +2004-12-31 2004-12-31 23:59:59 2004-12-31 23:59:59 +2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00 +2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00 +drop table t1; +create table t1 (ix timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1265 Data truncated for column 'ix' at row 7 +Warning 1265 Data truncated for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 2 +Warning 1265 Data truncated for column 'ix' at row 3 +Warning 1265 Data truncated for column 'ix' at row 4 +Warning 1265 Data truncated for column 'ix' at row 5 +Warning 1265 Data truncated for column 'ix' at row 6 +Warning 1264 Out of range value for column 'ix' at row 7 +Warning 1264 Out of range value for column 'ix' at row 8 +select ix+0 from t1; +ix+0 +0 +0 +0 +0 +0 +0 +0 +0 +truncate table t1; +insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); +Warnings: +Warning 1265 Data truncated for column 'ix' at row 1 +Warning 1265 Data truncated for column 'ix' at row 2 +select ix+0 from t1; +ix+0 +0 +20030101000000 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00', t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000000; +insert into t1 values (); +SET TIMESTAMP=1000000001; +update t1 set t2=now(); +SET TIMESTAMP=1000000002; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2003-01-01 00:00:00 2001-09-09 04:46:41 0000-00-00 00:00:00 +2003-01-01 00:00:00 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00', + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default now(), t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000002; +insert into t1 values (); +SET TIMESTAMP=1000000003; +update t1 set t2=now(); +SET TIMESTAMP=1000000003; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:42 2001-09-09 04:46:43 0000-00-00 00:00:00 +2001-09-09 04:46:43 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default '2003-01-01 00:00:00' on update now(), t2 datetime); +SET TIMESTAMP=1000000004; +insert into t1 values (); +select * from t1; +t1 t2 +2003-01-01 00:00:00 NULL +SET TIMESTAMP=1000000005; +update t1 set t2=now(); +SET TIMESTAMP=1000000005; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:45 2001-09-09 04:46:45 +2003-01-01 00:00:00 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT '2003-01-01 00:00:00' ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO 2003-01-01 00:00:00 on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp not null default now() on update now(), t2 datetime); +SET TIMESTAMP=1000000006; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:46 NULL +SET TIMESTAMP=1000000007; +update t1 set t2=now(); +SET TIMESTAMP=1000000007; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:47 2001-09-09 04:46:47 +2001-09-09 04:46:47 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +drop table t1; +create table t1 (t1 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, t2 datetime, t3 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'); +SET TIMESTAMP=1000000007; +insert into t1 values (); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:47 NULL 0000-00-00 00:00:00 +SET TIMESTAMP=1000000008; +update t1 set t2=now(); +SET TIMESTAMP=1000000008; +insert into t1 (t1,t3) values (default, default); +select * from t1; +t1 t2 t3 +2001-09-09 04:46:48 2001-09-09 04:46:48 0000-00-00 00:00:00 +2001-09-09 04:46:48 NULL 0000-00-00 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL, + `t3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +t3 timestamp NO 0000-00-00 00:00:00 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp, t2 datetime); +SET TIMESTAMP=1000000009; +insert into t1 values (); +select * from t1; +t1 t2 +2001-09-09 04:46:49 NULL +SET TIMESTAMP=1000000010; +update t1 set t2=now(); +SET TIMESTAMP=1000000011; +insert into t1 (t1) values (default); +select * from t1; +t1 t2 +2001-09-09 04:46:50 2001-09-09 04:46:50 +2001-09-09 04:46:51 NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `t2` datetime DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP +t2 datetime YES NULL +truncate table t1; +insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); +SET TIMESTAMP=1000000012; +update t1 set t1= '2004-04-02 00:00:00'; +select * from t1; +t1 t2 +2004-04-02 00:00:00 2004-04-01 00:00:00 +update t1 as ta, t1 as tb set tb.t1= '2004-04-03 00:00:00'; +select * from t1; +t1 t2 +2004-04-03 00:00:00 2004-04-01 00:00:00 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000013; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:53 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default '2003-01-01 00:00:00' on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000014; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2003-01-01 00:00:00 20 +drop table t1; +create table t1 (pk int primary key, t1 timestamp not null default current_timestamp on update current_timestamp, bulk int); +insert into t1 values (1, '2004-04-01 00:00:00', 10); +SET TIMESTAMP=1000000015; +replace into t1 set pk = 1, bulk= 20; +select * from t1; +pk t1 bulk +1 2001-09-09 04:46:55 20 +drop table t1; +create table t1 (t1 timestamp not null default current_timestamp on update current_timestamp); +insert into t1 values ('2004-04-01 00:00:00'); +SET TIMESTAMP=1000000016; +alter table t1 add i int default 10; +select * from t1; +t1 i +2004-04-01 00:00:00 10 +drop table t1; +create table t1 (a timestamp null, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000017; +insert into t1 values (); +select * from t1; +a b +NULL NULL +NULL NULL +drop table t1; +create table t1 (a timestamp null default current_timestamp on update current_timestamp, b timestamp null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `b` timestamp NULL DEFAULT NULL +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +SET TIMESTAMP=1000000018; +insert into t1 values (); +select * from t1; +a b +NULL NULL +2001-09-09 04:46:58 NULL +drop table t1; +create table t1 (a timestamp null default null, b timestamp null default '2003-01-01 00:00:00'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT '2003-01-01 00:00:00' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (NULL, NULL); +insert into t1 values (DEFAULT, DEFAULT); +select * from t1; +a b +NULL NULL +NULL 2003-01-01 00:00:00 +drop table t1; +create table t1 (a bigint, b bigint); +insert into t1 values (NULL, NULL), (20030101000000, 20030102000000); +set timestamp=1000000019; +alter table t1 modify a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modify b timestamp NOT NULL DEFAULT '0000-00-00 00:00:0'; +select * from t1; +a b +2001-09-09 04:46:59 2001-09-09 04:46:59 +2003-01-01 00:00:00 2003-01-02 00:00:00 +drop table t1; +create table t1 (a char(2), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), +('b', '2004-02-01 00:00:00'); +select max(t) from t1 group by a; +max(t) +2004-01-01 01:00:00 +2004-02-01 00:00:00 +drop table t1; +create table t1 (a int auto_increment primary key, b int, c timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 (a, b, c) values (1, 0, '2001-01-01 01:01:01'), +(2, 0, '2002-02-02 02:02:02'), (3, 0, '2003-03-03 03:03:03'); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 0 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +update t1 set b = 2, c = c where a = 2; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +insert into t1 (a) values (4); +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2001-09-09 04:46:59 +update t1 set c = '2004-04-04 04:04:04' where a = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 0 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +insert into t1 (a) values (3), (5) on duplicate key update b = 3, c = c; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 NULL 2004-04-04 04:04:04 +5 NULL 2001-09-09 04:46:59 +insert into t1 (a, c) values (4, '2004-04-04 00:00:00'), +(6, '2006-06-06 06:06:06') on duplicate key update b = 4; +select * from t1; +a b c +1 0 2001-01-01 01:01:01 +2 2 2002-02-02 02:02:02 +3 3 2003-03-03 03:03:03 +4 4 2001-09-09 04:46:59 +5 NULL 2001-09-09 04:46:59 +6 NULL 2006-06-06 06:06:06 +drop table t1; +End of 4.1 tests +set time_zone= @@global.time_zone; +CREATE TABLE t1 ( f1 INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, +f2 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +f3 TIMESTAMP NOT NULL default '0000-00-00 00:00:00'); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (f2,f3) VALUES (NOW(), "0000-00-00 00:00:00"); +UPDATE t1 SET f2=NOW(), f3=FROM_UNIXTIME('9999999999') WHERE f1=1; +Warnings: +Warning 1048 Column 'f3' cannot be null +SELECT f1,f2-f3 FROM t1; +f1 f2-f3 +1 20010909044659 +DROP TABLE t1; +End of 5.0 tests +# +# Bug #55779: select does not work properly in mysql server +# Version "5.1.42 SUSE MySQL RPM" +# +CREATE TABLE t1 (a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY (a)); +INSERT INTO t1 VALUES ('2000-01-01 00:00:00'), ('2000-01-01 00:00:00'), +('2000-01-01 00:00:01'), ('2000-01-01 00:00:01'); +SELECT a FROM t1 WHERE a >= 20000101000000; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +SELECT a FROM t1 WHERE a >= '20000101000000'; +a +2000-01-01 00:00:00 +2000-01-01 00:00:00 +2000-01-01 00:00:01 +2000-01-01 00:00:01 +DROP TABLE t1; +# +# Bug#50774: failed to get the correct resultset when timestamp values +# are appended with .0 +# +CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:04' ); +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a; +a +2010-02-01 09:31:01 +2010-02-01 09:31:02 +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:02 +2010-02-01 09:31:03 +2010-02-01 09:31:04 +CREATE TABLE t2 ( a TIMESTAMP, KEY ( a ) ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:04' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:05' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:06' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:07' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:08' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:09' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:10' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:11' ); +# The bug would cause the range optimizer's comparison to use an open +# interval here. This reveals itself only in the number of reads +# performed. +FLUSH STATUS; +SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0'; +a +2010-02-01 09:31:01 +SHOW STATUS LIKE 'Handler_read_next'; +Variable_name Value +Handler_read_next 0 +DROP TABLE t1, t2; +End of 5.1 tests + +Bug#50888 valgrind warnings in Field_timestamp::val_str + +SET TIMESTAMP=0; +CREATE TABLE t1(a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02'); +FLUSH TABLES t1; +SELECT MAX(a) FROM t1; +MAX(a) +2010-03-05 11:08:02 +SELECT a FROM t1; +a +2008-02-23 09:23:45 +2010-03-05 11:08:02 +DROP TABLE t1; +End of Bug#50888 +# +# Bug59330: Incorrect result when comparing an aggregate +# function with TIMESTAMP +# +CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP); +INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30'); +SELECT MAX(dt), MAX(ts) FROM t1; +MAX(dt) MAX(ts) +2011-01-06 12:34:30 2011-01-06 12:34:30 +SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1; +MAX(ts) < '2010-01-01 00:00:00' +0 +SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1; +MAX(dt) < '2010-01-01 00:00:00' +0 +SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1; +MAX(ts) > '2010-01-01 00:00:00' +1 +SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1; +MAX(dt) > '2010-01-01 00:00:00' +1 +SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1; +MAX(ts) = '2011-01-06 12:34:30' +1 +SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1; +MAX(dt) = '2011-01-06 12:34:30' +1 +DROP TABLE t1; +End of 5.5 tests +# +# Start of 5.6 tests +# +# +# Bug#13596893 - "ERROR 1690 (22003): BIGINT UNSIGNED VALUE IS OUT OF RANGE" ON DATE OPERATION +# +CREATE TABLE t1 ( +`c1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +`c2` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' +); +INSERT INTO t1 VALUES ('2003-05-16 23:53:29','2000-01-27 23:13:41'); +SELECT c2-c1 FROM t1; +c2-c1 +-30389003988 +SELECT * FROM t1; +c1 c2 +2003-05-16 23:53:29 2000-01-27 23:13:41 +SELECT TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29'; +TIMESTAMP'2000-01-27 23:13:41' - TIMESTAMP'2003-05-16 23:53:29' +-30389003988 +SELECT TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29'); +TIMESTAMP('2000-01-27','23:13:41') - TIMESTAMP('2003-05-16','23:53:29') +-30389003988 +DROP TABLE t1; +SET sql_mode = default; +# +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE IF EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 INT); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +# +# End of 5.6 tests +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +# +# WL6292 - Test cases to test new behavior with +# --explicit_defaults_for_timestamp +# Almost all the scenario's required to test this WL, is already tested +# by most of existing test case. Adding some basic tests here. +# +CREATE TABLE t1 (f1 TIMESTAMP, f2 TIMESTAMP); +ALTER TABLE t1 ADD COLUMN (f3 TIMESTAMP NOT NULL); +ALTER TABLE t1 ADD COLUMN (f4 TIMESTAMP DEFAULT NULL); +ALTER TABLE t1 ADD COLUMN (f5 TIMESTAMP DEFAULT '0:0:0'); +ALTER TABLE t1 ADD COLUMN (f6 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +# Following is expected out of SHOW CREATE TABLE +# `f1` timestamp NULL DEFAULT NULL, +# `f2` timestamp NULL DEFAULT NULL, +# `f3` timestamp NOT NULL, +# `f4` timestamp NULL DEFAULT NULL, +# `f5` timestamp NULL DEFAULT '0000-00-00 00:00:00' +# `f6` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` timestamp NULL DEFAULT NULL, + `f2` timestamp NULL DEFAULT NULL, + `f3` timestamp NOT NULL, + `f4` timestamp NULL DEFAULT NULL, + `f5` timestamp NULL DEFAULT '0000-00-00 00:00:00', + `f6` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +# The new behavior affects CREATE SELECT with column definitions +# before SELECT keyword. The columns f1,f2 in t2 do not get promoted +# with the new behavior. +CREATE TABLE t2 (f1 TIMESTAMP, f2 TIMESTAMP) SELECT f1,f2,f3,f4,f5,f6 FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` timestamp NULL DEFAULT NULL, + `f2` timestamp NULL DEFAULT NULL, + `f3` timestamp NOT NULL, + `f4` timestamp NULL DEFAULT NULL, + `f5` timestamp NULL DEFAULT '0000-00-00 00:00:00', + `f6` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +DROP TABLE t2; +# With --explicit_defaults_for_timestamp, +# inserting NULL in TIMESTAMP NOT NULL gives error, not NOW(). +# INT serves as model. +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NOT NULL DEFAULT '2001-01-01 01:01:01', +c3 INT NOT NULL DEFAULT 42); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` timestamp NOT NULL, + `c2` timestamp NOT NULL DEFAULT '2001-01-01 01:01:01', + `c3` int NOT NULL DEFAULT '42' +) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (NULL, DEFAULT, DEFAULT); +ERROR 23000: Column 'c1' cannot be null +INSERT INTO t1 VALUES ('2005-05-05 06:06:06', NULL, DEFAULT); +ERROR 23000: Column 'c2' cannot be null +INSERT INTO t1 VALUES ('2005-05-05 06:06:06', DEFAULT, NULL); +ERROR 23000: Column 'c3' cannot be null +INSERT INTO t1 VALUES ('2005-05-05 06:06:06', DEFAULT, DEFAULT); +SELECT * FROM t1; +c1 c2 c3 +2005-05-05 06:06:06 2001-01-01 01:01:01 42 +UPDATE t1 SET c1=NULL,c2=NULL,c3=NULL; +Warnings: +Warning 1048 Column 'c1' cannot be null +Warning 1048 Column 'c2' cannot be null +Warning 1048 Column 'c3' cannot be null +SELECT * FROM t1; +c1 c2 c3 +0000-00-00 00:00:00 0000-00-00 00:00:00 0 +DROP TABLE t1; +SET sql_mode = default; +# +#Bug#19881933 : TABLE CREATION WITH TIMESTAMP IS REJECTED +# +SET sql_mode=TRADITIONAL; +CREATE TABLE t1( +dummy INT, +i1_null_const INT NULL DEFAULT 42, +t1_null_now TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, +t1_null_const TIMESTAMP NULL DEFAULT '2001-01-01 03:03:03', +i2_not_null_const INT NOT NULL DEFAULT 42, +t2_not_null_now TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +t2_not_null_const TIMESTAMP NOT NULL DEFAULT '2001-01-01 03:03:03', +i3_null INT NULL, +t3_null TIMESTAMP NULL, +i4_not_null INT NOT NULL, +t4_not_null TIMESTAMP NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `dummy` int DEFAULT NULL, + `i1_null_const` int DEFAULT '42', + `t1_null_now` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `t1_null_const` timestamp NULL DEFAULT '2001-01-01 03:03:03', + `i2_not_null_const` int NOT NULL DEFAULT '42', + `t2_not_null_now` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `t2_not_null_const` timestamp NOT NULL DEFAULT '2001-01-01 03:03:03', + `i3_null` int DEFAULT NULL, + `t3_null` timestamp NULL DEFAULT NULL, + `i4_not_null` int NOT NULL, + `t4_not_null` timestamp NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE t1(a TIMESTAMP, b TIMESTAMP); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp NULL DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TABLE t2(a INT); +ALTER TABLE t2 ADD COLUMN b TIMESTAMP; +ALTER TABLE t2 ADD COLUMN c TIMESTAMP; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL, + `c` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t2 ADD COLUMN d TIMESTAMP; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + `b` timestamp NULL DEFAULT NULL, + `c` timestamp NULL DEFAULT NULL, + `d` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +ALTER TABLE t2 MODIFY b TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'; +ERROR 42000: Invalid default value for 'b' +ALTER TABLE t2 MODIFY b TIMESTAMP DEFAULT '0000-00-00 00:00:00'; +ERROR 42000: Invalid default value for 'b' +INSERT INTO t1 VALUES(); +SET sql_mode=''; +INSERT INTO t1 VALUES(); +SET sql_mode=TRADITIONAL; +SELECT b FROM t1; +b +NULL +NULL +CREATE TABLE t3(a TIMESTAMP, b TIMESTAMP); +# INSERT SELECT statement +INSERT INTO t3 SELECT * from t1; +#CREATE SELECT with data in t1 +CREATE TABLE t4 AS SELECT * FROM t1; +DELETE FROM t1; +DROP TABLE t4; +#CREATE SELECT without data +CREATE TABLE t4 AS SELECT * FROM t1; +#DML statements +INSERT INTO t1 VALUES(default, default); +INSERT INTO t1 VALUES(default(a), default(b)); +UPDATE t1 SET b=default; +UPDATE t1 SET b=default(b); +CREATE TABLE t5(a TIMESTAMP NOT NULL); +CREATE TABLE t6(a TIMESTAMP, b TIMESTAMP NOT NULL); +DROP TABLE t1,t2,t3,t4,t5,t6; +SET sql_mode=default; +# +# BUG#27041502: ASSERTION `TYPE() != MYSQL_TYPE_TIMESTAMP' +# FAILED. +CREATE TABLE t1(fld1 TIMESTAMP,PRIMARY KEY (fld1)); +CREATE TRIGGER trg BEFORE INSERT ON t1 FOR EACH ROW SET @a=1; +# Without patch, an assert is triggered in the below +# INSERT/UPDATE cases. +INSERT INTO t1 VALUES(NULL); +ERROR 23000: Column 'fld1' cannot be null +DROP TRIGGER trg; +CREATE TRIGGER trg AFTER INSERT ON t1 FOR EACH ROW SET @a=1; +INSERT INTO t1 VALUES(NULL); +ERROR 23000: Column 'fld1' cannot be null +DROP TRIGGER trg; +CREATE TRIGGER trg BEFORE UPDATE ON t1 FOR EACH ROW SET @a=1; +INSERT INTO t1 VALUES("20121231"); +UPDATE t1 SET fld1=NULL WHERE fld1="20121231"; +ERROR 23000: Column 'fld1' cannot be null +SELECT * from t1; +fld1 +2012-12-31 00:00:00 +DROP TRIGGER trg; +CREATE TRIGGER trg AFTER UPDATE ON t1 FOR EACH ROW SET @a=1; +UPDATE t1 SET fld1=NULL WHERE fld1="20121231"; +ERROR 23000: Column 'fld1' cannot be null +DROP TRIGGER trg; +DROP TABLE t1; diff --git a/mysql-test/r/type_varchar.result-pq b/mysql-test/r/type_varchar.result-pq new file mode 100644 index 000000000..f8e81f8f8 --- /dev/null +++ b/mysql-test/r/type_varchar.result-pq @@ -0,0 +1,614 @@ +drop table if exists t1, t2; +create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(30) DEFAULT NULL, + `c` char(3) DEFAULT NULL, + `e` enum('abc','def','ghi') DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values ('abc', 'de', 'ghi', 'jkl'); +insert into t1 values ('abc ', 'de ', 'ghi', 'jkl '); +insert into t1 values ('abc ', 'd ', 'ghi', 'jkl '); +select length(v),length(c),length(e),length(t) from t1; +length(v) length(c) length(e) length(t) +3 2 3 3 +4 2 3 4 +7 1 3 7 +drop table t1; +create table t1 (v varchar(20)) charset latin1; +insert into t1 values('a '); +select v='a' from t1; +v='a' +1 +select binary v='a' from t1; +binary v='a' +0 +select binary v='a ' from t1; +binary v='a ' +1 +insert into t1 values('a'); +alter table t1 add primary key (v); +ERROR 23000: Duplicate entry 'a ' for key 't1.PRIMARY' +drop table t1; +create table t1 (v varbinary(20)); +insert into t1 values('a'); +insert into t1 values('a '); +alter table t1 add primary key (v); +drop table t1; +create table t1 (v varchar(254), index (v)) charset latin1; +insert into t1 values ("This is a test "); +insert into t1 values ("Some sample data"); +insert into t1 values (" garbage "); +insert into t1 values (" This is a test "); +insert into t1 values ("This is a test"); +insert into t1 values ("Hello world"); +insert into t1 values ("Foo bar"); +insert into t1 values ("This is a test"); +insert into t1 values ("MySQL varchar test"); +insert into t1 values ("test MySQL varchar"); +insert into t1 values ("This is a long string to have some random length data included"); +insert into t1 values ("Short string"); +insert into t1 values ("VSS"); +insert into t1 values ("Some samples"); +insert into t1 values ("Bar foo"); +insert into t1 values ("Bye"); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 257 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(255); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 258 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(256); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 259 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(257); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 260 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(258); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 1 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 261 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 2 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(259); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 262 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 262 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 262 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(258); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 261 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 261 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(257); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 260 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 260 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(256); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 259 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 259 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(255); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 258 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 258 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(254); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 3 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 257 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 4 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 257 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +alter table t1 change v v varchar(253); +alter table t1 change v v varchar(254), drop key v; +alter table t1 change v v varchar(300), add key (v(10)); +select * from t1 where v like 'This is a test' order by v; +v +This is a test +This is a test +select * from t1 where v='This is a test' order by v; +v +This is a test +This is a test +This is a test +select * from t1 where v like 'S%' order by v; +v +Short string +Some sample data +Some samples +explain select * from t1 where v like 'This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 13 NULL 4 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'This is a test') order by `test`.`t1`.`v` +Helper line 5 for --skip_if_hypergraph diffing +explain select * from t1 where v='This is a test' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` = 'This is a test') order by `test`.`t1`.`v` +Helper line 6 for --skip_if_hypergraph diffing +explain select * from t1 where v like 'S%' order by v; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 13 NULL 3 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`v` like 'S%') order by `test`.`t1`.`v` +drop table t1; +create table t1 (pkcol varchar(16), othercol varchar(16), primary key (pkcol)); +insert into t1 values ('test', 'something'); +update t1 set othercol='somethingelse' where pkcol='test'; +select * from t1; +pkcol othercol +test somethingelse +drop table t1; +create table t1 (a int, b varchar(12)); +insert into t1 values (1, 'A'), (22, NULL); +create table t2 (a int); +insert into t2 values (22), (22); +select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a +group by t1.b, t1.a; +a b min(t1.b) +22 NULL NULL +drop table t1, t2; +create table t1 (f1 varchar(65500)) charset latin1; +create index index1 on t1(f1(10)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(65500) DEFAULT NULL, + KEY `index1` (`f1`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +alter table t1 modify f1 varchar(255); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(255) DEFAULT NULL, + KEY `index1` (`f1`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +alter table t1 modify f1 tinytext; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` tinytext, + KEY `index1` (`f1`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(f1 VARCHAR(100) DEFAULT 'test'); +INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3)); +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test'); +INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3)); +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a CHAR(2)); +INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t'); +SELECT a,(a + 0) FROM t1 ORDER BY a; +a (a + 0) +10 10 +1a 1 +30 30 +50 50 +60 60 +t 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1a' +Warning 1292 Truncated incorrect DOUBLE value: 't' +SELECT a,(a DIV 2) FROM t1 ORDER BY a; +a (a DIV 2) +10 5 +1a 0 +30 15 +50 25 +60 30 +t 0 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '1a' +Warning 1366 Incorrect DECIMAL value: '0' for column '' at row -1 +Warning 1292 Truncated incorrect DECIMAL value: 't' +SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a; +a CAST(a AS SIGNED) +10 10 +1a 1 +30 30 +50 50 +60 60 +t 0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '1a' +Warning 1292 Truncated incorrect INTEGER value: 't' +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(16)); +INSERT INTO t1 VALUES ('5'), ('s'), (''); +SELECT 5 = a FROM t1; +5 = a +1 +0 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 's' +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(16)); +INSERT INTO t1 VALUES ('5'), ('s'), (''); +SELECT 5 = a FROM t1; +5 = a +1 +0 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 's' +DROP TABLE t1; diff --git a/mysql-test/r/update.result-pq b/mysql-test/r/update.result-pq new file mode 100644 index 000000000..cd208da02 --- /dev/null +++ b/mysql-test/r/update.result-pq @@ -0,0 +1,983 @@ +drop table if exists t1,t2; +create table t1 (a int auto_increment , primary key (a)); +insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +update t1 set a=a+10 where a > 34; +update t1 set a=a+100 where a > 0; +update t1 set a=a+100 limit 0; +explain update t1 set a=a+100 limit 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL LIMIT is zero +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = (`test`.`t1`.`a` + 100) limit 0 +update t1 set a=a+100 where a=1 and a=2; +update t1 set a=b+100 where a=1 and a=2; +ERROR 42S22: Unknown column 'b' in 'field list' +update t1 set a=b+100 where c=1 and a=2; +ERROR 42S22: Unknown column 'c' in 'where clause' +update t1 set d=a+100 where a=1; +ERROR 42S22: Unknown column 'd' in 'field list' +select * from t1; +a +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +145 +146 +drop table t1; +CREATE TABLE t1 +( +place_id int (10) unsigned NOT NULL, +shows int(10) unsigned DEFAULT '0' NOT NULL, +ishows int(10) unsigned DEFAULT '0' NOT NULL, +ushows int(10) unsigned DEFAULT '0' NOT NULL, +clicks int(10) unsigned DEFAULT '0' NOT NULL, +iclicks int(10) unsigned DEFAULT '0' NOT NULL, +uclicks int(10) unsigned DEFAULT '0' NOT NULL, +ts timestamp, +PRIMARY KEY (place_id,ts) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts) +VALUES (1,0,0,0,0,0,0,20000928174434); +UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00"; +select place_id,shows from t1; +place_id shows +1 1 +drop table t1; +create table t1 (a int not null, b int not null, key (a)); +insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3); +SET @tmp=0; +update t1 set b=(@tmp:=@tmp+1) order by a; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 set b=99 where a=1 order by b asc limit 1; +select * from t1 order by a,b; +a b +1 2 +1 3 +1 99 +2 4 +2 5 +2 6 +3 7 +3 8 +3 9 +3 10 +3 11 +3 12 +update t1 set b=100 where a=1 order by b desc limit 2; +update t1 set a=a+10+b where a=1 order by b; +select * from t1 order by a,b; +a b +2 4 +2 5 +2 6 +3 7 +3 8 +3 9 +3 10 +3 11 +3 12 +13 2 +111 100 +111 100 +create table t2 (a int not null, b int not null); +insert into t2 values (1,1),(1,2),(1,3); +update t1 set b=(select distinct 1 from (select * from t2) a); +drop table t1,t2; +create table t1 (F1 VARCHAR(30), F2 VARCHAR(30), F3 VARCHAR(30), cnt int, groupid int, KEY groupid_index (groupid)); +insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6), +('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2), +('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4), +('2','2','0',1,7); +delete from m1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3); +select * from t1; +F1 F2 F3 cnt groupid +0 0 0 1 6 +0 1 2 1 5 +0 2 0 1 3 +1 0 1 1 2 +1 2 1 1 1 +2 0 1 2 4 +2 2 0 1 7 +drop table t1; +CREATE TABLE t1 ( +`colA` int(10) unsigned NOT NULL auto_increment, +`colB` int(11) NOT NULL default '0', +PRIMARY KEY (`colA`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4433,5424); +CREATE TABLE t2 ( +`colC` int(10) unsigned NOT NULL default '0', +`colA` int(10) unsigned NOT NULL default '0', +`colD` int(10) unsigned NOT NULL default '0', +`colE` int(10) unsigned NOT NULL default '0', +`colF` int(10) unsigned NOT NULL default '0', +PRIMARY KEY (`colC`,`colA`,`colD`,`colE`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (3,4433,10005,495,500); +INSERT INTO t2 VALUES (3,4433,10005,496,500); +INSERT INTO t2 VALUES (3,4433,10009,494,500); +INSERT INTO t2 VALUES (3,4433,10011,494,500); +INSERT INTO t2 VALUES (3,4433,10005,497,500); +INSERT INTO t2 VALUES (3,4433,10013,489,500); +INSERT INTO t2 VALUES (3,4433,10005,494,500); +INSERT INTO t2 VALUES (3,4433,10005,493,500); +INSERT INTO t2 VALUES (3,4433,10005,492,500); +UPDATE IGNORE t2,t1 set t2.colE = t2.colE + 1,colF=0 WHERE t1.colA = t2.colA AND (t1.colB & 4096) > 0 AND (colE + 1) < colF; +Warnings: +Warning 1062 Duplicate entry '3-4433-10005-493' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-494' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-495' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-496' for key 't2.PRIMARY' +Warning 1062 Duplicate entry '3-4433-10005-497' for key 't2.PRIMARY' +SELECT * FROM t2; +colC colA colD colE colF +3 4433 10005 492 500 +3 4433 10005 493 500 +3 4433 10005 494 500 +3 4433 10005 495 500 +3 4433 10005 496 500 +3 4433 10005 498 0 +3 4433 10009 495 0 +3 4433 10011 495 0 +3 4433 10013 490 0 +DROP TABLE t1; +DROP TABLE t2; +create table t1 (c1 int, c2 char(6), c3 int); +create table t2 (c1 int, c2 char(6)); +insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20); +update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1"; +update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10; +drop table t1, t2; +create table t1 (id int not null auto_increment primary key, id_str varchar(32)); +insert into t1 (id_str) values ("test"); +update t1 set id_str = concat(id_str, id) where id = last_insert_id(); +select * from t1; +id id_str +1 test1 +drop table t1; +create table t1 (a int, b char(255), key(a, b(20))); +insert into t1 values (0, '1'); +update t1 set b = b + 1 where a = 0; +select * from t1; +a b +0 2 +drop table t1; +create table t1(f1 int, f2 int); +create table t2(f3 int, f4 int); +create index idx on t2(f3); +insert into t1 values(1,0),(2,0); +insert into t2 values(1,1),(2,2); +UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +select * from t1; +f1 f2 +1 1 +2 2 +drop table t1,t2; +create table t1(f1 int); +select DATABASE(); +DATABASE() +test +update t1 set f1=1 where count(*)=1; +ERROR HY000: Invalid use of group function +select DATABASE(); +DATABASE() +test +delete from t1 where count(*)=1; +ERROR HY000: Invalid use of group function +drop table t1; +create table t1 ( a int, b int default 0, index (a) ); +insert into t1 (a) values (0),(0),(0),(0),(0),(0),(0),(0); +flush status; +select a from t1 order by a limit 1; +a +0 +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 1 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 1 +flush status; +update t1 set a=9999 order by a limit 1; +update t1 set b=9999 order by a limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 2 +Handler_read_key 4 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 2 +Handler_read_rnd_next 0 +flush status; +delete from t1 order by a, b desc limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 9 +flush status; +delete from t1 order by a desc, b desc limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 8 +alter table t1 disable keys; +Warnings: +Note 1031 Table storage engine for 't1' doesn't have this option +flush status; +delete from t1 order by a limit 1; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 1 +Handler_read_key 3 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +select * from t1; +a b +0 0 +0 0 +0 0 +0 0 +0 0 +update t1 set a=a+10,b=1 order by a limit 3; +update t1 set a=a+11,b=2 order by a limit 3; +update t1 set a=a+12,b=3 order by a limit 3; +select * from t1 order by a; +a b +11 2 +21 2 +22 3 +22 3 +23 3 +drop table t1; +create table t1 (f1 int); +create table t2 (f2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(1); +update t1,t2 set f1=3,f2=3 where f1=f2 and f1=1; +affected rows: 3 +info: Rows matched: 3 Changed: 3 Warnings: 0 +update t2 set f2=1; +update t1 set f1=1 where f1=3; +update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1; +affected rows: 3 +info: Rows matched: 3 Changed: 3 Warnings: 0 +drop table t1,t2; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler1 char(200), filler2 char(200), key(a)); +insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B; +flush status; +update t2 set a=3 where a=2; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 2 +Handler_read_last 0 +Handler_read_next 1 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 0 +drop table t1, t2; +create table t1(f1 int, `*f2` int); +insert into t1 values (1,1); +update t1 set `*f2`=1; +drop table t1; +create table t1(f1 int); +update t1 set f2=1 order by f2; +ERROR 42S22: Unknown column 'f2' in 'field list' +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +request_id int unsigned NOT NULL auto_increment, +user_id varchar(12) default NULL, +time_stamp datetime NOT NULL default '0000-00-00 00:00:00', +ip_address varchar(15) default NULL, +PRIMARY KEY (request_id), +KEY user_id_2 (user_id,time_stamp) +); +INSERT INTO t1 (user_id) VALUES ('user1'); +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +INSERT INTO t1(user_id) SELECT user_id FROM t1; +flush status; +SELECT user_id FROM t1 WHERE request_id=9999999999999; +user_id +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999; +user_id +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +UPDATE t1 SET user_id=null WHERE request_id=9999999999999; +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999; +show status like '%Handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 0 +Handler_read_last 0 +Handler_read_next 0 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 0 +DROP TABLE t1; +SET sql_mode = default; +CREATE TABLE t1 ( +a INT(11), +quux decimal( 31, 30 ), +UNIQUE KEY bar (a), +KEY quux (quux) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO +t1 ( a, quux ) +VALUES +( 1, 1 ), +( 2, 0.1 ); +INSERT INTO t1( a ) +SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT * FROM t1; +a quux +1 1.000000000000000000000000000000 +2 0.100000000000000000000000000000 +3 NULL +DROP TABLE t1; +set tmp_table_size=1024; +create table t1 (id int, a int, key idx(a)); +create table t2 (id int unsigned not null auto_increment primary key, a int); +insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8); +insert into t2(a) select a from t2; +insert into t2(a) select a from t2; +insert into t2(a) select a from t2; +update t2 set a=id; +insert into t1 select * from t2; +select count(*) from t1 join t2 on (t1.a=t2.a); +count(*) +64 +update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id; +affected rows: 0 +info: Rows matched: 64 Changed: 0 Warnings: 0 +insert into t2(a) select a from t2; +update t2 set a=id; +truncate t1; +insert into t1 select * from t2; +select count(*) from t1 join t2 on (t1.a=t2.a); +count(*) +128 +update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id; +affected rows: 0 +info: Rows matched: 128 Changed: 0 Warnings: 0 +update t1 set a=1; +update t2 set a=1; +select count(*) from t1 join t2 on (t1.a=t2.a); +count(*) +16384 +update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id; +affected rows: 127 +info: Rows matched: 128 Changed: 127 Warnings: 0 +drop table t1,t2; +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INT RETURN f1(); +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +UPDATE t1 SET i = 3 WHERE f1(); +ERROR HY000: Recursive stored functions and triggers are not allowed. +UPDATE t1 SET i = f1(); +ERROR HY000: Recursive stored functions and triggers are not allowed. +DROP TABLE t1; +DROP FUNCTION f1; +End of 5.0 tests +# +# Bug #47919 assert in open_table during ALTER temporary table +# +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1)); +CREATE TEMPORARY TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ALTER TABLE t2 COMMENT = 'ABC'; +UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9; +ALTER TABLE t2 COMMENT = 'DEF'; +DROP TABLE t1, t2; +# +# Bug#50545: Single table UPDATE IGNORE crashes on join view in +# sql_safe_updates mode. +# +CREATE TABLE t1 ( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (0), (1); +CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12; +SET SESSION sql_safe_updates = 1; +UPDATE IGNORE v1 SET a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. +SET SESSION sql_safe_updates = DEFAULT; +DROP TABLE t1; +DROP VIEW v1; +# +# Bug#54734 assert in Diagnostics_area::set_ok_status +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +DROP TABLE IF EXISTS t1, not_exists; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk; +CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists); +CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13; +UPDATE v1 SET pk = 7 WHERE pk > 0; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v1; +DROP FUNCTION f1; +DROP TABLE t1; +SET sql_mode = default; +# +# Verify that UPDATE does the same number of handler_update +# operations, no matter if there is ORDER BY or not. +# +CREATE TABLE t1 (i INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), +(20),(21),(22),(23),(24),(25),(26),(27),(28),(29), +(30),(31),(32),(33),(34),(35); +CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), +INDEX idx (a,b(1),c)) ENGINE=INNODB; +INSERT INTO t2 SELECT i, i, i, i FROM t1; +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET d = 10 WHERE b = 10 LIMIT 5; +SET @binlog_handler_update= IF(@@global.log_bin AND @@global.binlog_format != 'STATEMENT', 1, 0); +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +1 +ROLLBACK; +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +1 +ROLLBACK; +Same test with a different UPDATE. +ALTER TABLE t2 DROP INDEX idx, ADD INDEX idx2 (a, b); +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET c = 10 LIMIT 5; +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +5 +ROLLBACK; +FLUSH STATUS; +START TRANSACTION; +UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; +SELECT VARIABLE_VALUE + @binlog_handler_update FROM performance_schema.session_status WHERE VARIABLE_NAME = 'HANDLER_UPDATE'; +VARIABLE_VALUE + @binlog_handler_update +5 +ROLLBACK; +DROP TABLE t1, t2; +# Bug#20454533: Assertion failed: sargables == 0 || *keyfields ... +CREATE TABLE t1( +a int, +c int, +e int, +f int, +g blob, +h int, +i int, +j blob, +unique key (g(221),c), +unique key (c,a,j(148)), +key (i) +) engine=innodb; +UPDATE (SELECT 1 AS a FROM t1 NATURAL JOIN t1 AS t2) AS x, t1 +SET t1.e= x.a; +DROP TABLE t1; +# Bug #21143080: UPDATE ON VARCHAR AND TEXT COLUMNS PRODUCE INCORRECT +# RESULTS +CREATE TABLE t1 (a VARCHAR(50), b TEXT, c CHAR(50)) ENGINE=INNODB; +INSERT INTO t1 (a, b, c) VALUES ('start trail', '', 'even longer string'); +UPDATE t1 SET b = a, a = 'inject'; +SELECT a, b FROM t1; +a b +inject start trail +UPDATE t1 SET b = c, c = 'inject'; +SELECT c, b FROM t1; +c b +inject even longer string +DROP TABLE t1; +# +# Bug#18698556: UPDATE ORDER BY DOES A FILESORT IF UPDATING +# A COLUMN IN THE INDEX +# +CREATE TABLE t1 ( +a INTEGER, +b INTEGER, +c INTEGER, +d INTEGER, +KEY key1 (a,b,c) +); +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 72 where (`test`.`t1`.`a` = 2) order by `test`.`t1`.`b` limit 1 +UPDATE t1 SET c = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +explain UPDATE t1 SET d = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`d` = 72 where (`test`.`t1`.`a` = 2) order by `test`.`t1`.`b` limit 1 +UPDATE t1 SET d = 72 WHERE a = 2 ORDER BY b ASC LIMIT 1; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +INSERT INTO t1 (a,b,c,d) VALUES (5, 5, 1, 1), (5, 5, 2, 1), (5, 5, 4, 1); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 3 WHERE a = 5 ORDER BY b ASC LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 3 where (`test`.`t1`.`a` = 5) order by `test`.`t1`.`b` limit 3 +UPDATE t1 SET c = 3 WHERE a = 5 ORDER BY b ASC LIMIT 3; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +5 5 3 1 +5 5 3 1 +5 5 3 1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 62 WHERE a > 4 ORDER BY b ASC LIMIT 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL range key1 key1 5 const # 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 62 where (`test`.`t1`.`a` > 4) order by `test`.`t1`.`b` limit 3 +UPDATE t1 SET c = 62 WHERE a > 4 ORDER BY b ASC LIMIT 3; +SELECT * FROM t1; +a b c d +1 1 1 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL index NULL key1 15 NULL # 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 82 order by `test`.`t1`.`a` limit 1 +UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 1; +SELECT * FROM t1; +a b c d +1 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +explain UPDATE t1 SET a = 82 ORDER BY b ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 82 order by `test`.`t1`.`b` limit 1 +UPDATE t1 SET a = 82 ORDER BY b ASC LIMIT 1; +SELECT * FROM t1; +a b c d +82 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +explain UPDATE t1 SET b = 82 ORDER BY d ASC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`b` = 82 order by `test`.`t1`.`d` limit 1 +UPDATE t1 SET b = 82 ORDER BY d ASC LIMIT 1; +SELECT * FROM t1; +a b c d +82 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 82 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +INSERT INTO t1 (a,b,c,d) VALUES (1, 1, 1, 4), (2, 2, 2, 5), (2, 3, 4, 7), +(3, 3, 3, 9), (4, 4, 4, 0), (5, 5, 5, 1), (5, 6, 7, 3), (5, 7, 9, 9); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL index NULL key1 15 NULL # 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c` = 82 order by `test`.`t1`.`a` limit 2 +UPDATE t1 SET c = 82 ORDER BY a ASC LIMIT 2; +SELECT * FROM t1; +a b c d +82 1 82 4 +2 2 72 72 +2 3 4 7 +3 3 3 9 +4 82 4 0 +5 5 62 1 +5 6 7 3 +5 7 9 9 +5 5 62 1 +5 5 62 1 +5 5 3 1 +1 1 82 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +1 1 82 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +1 1 1 4 +2 2 2 5 +2 3 4 7 +3 3 3 9 +4 4 4 0 +5 5 5 1 +5 6 7 3 +5 7 9 9 +DROP TABLE t1; +# End of test for Bug#18698556 +# +# Bug#21944866: REFACTORING: REMOVE KILL_BAD_DATA +# +CREATE TABLE t1 (a INT PRIMARY KEY, b DATE); +UPDATE t1 SET b= NULL WHERE a < '00:38:47.008761'; +ERROR 22007: Truncated incorrect DOUBLE value: '00:38:47.008761' +DROP TABLE t1; +# +# Bug#21032418: PERFORMANCE REGRESSION IN 5.6: UPDATE DOES NOT USE INDEX +# +CREATE TABLE t1( +id INTEGER NOT NULL AUTO_INCREMENT, +token VARCHAR(255) DEFAULT NULL, +PRIMARY KEY (id), +KEY token (token) +)DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (1, "abc"), (2, "def"); +SET sql_mode=''; +UPDATE t1 SET token = X'ad'; +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 2 +SELECT * FROM t1; +id token +1 +2 +EXPLAIN UPDATE t1 SET token = NULL WHERE token = X'ad'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +Note 1003 update `test`.`t1` set `test`.`t1`.`token` = NULL where (`test`.`t1`.`token` = 0xad) +UPDATE t1 SET token = NULL WHERE token = X'ad'; +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +SET sql_mode=default; +EXPLAIN UPDATE t1 SET token = NULL WHERE token = X'ad'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +Note 1003 update `test`.`t1` set `test`.`t1`.`token` = NULL where (`test`.`t1`.`token` = 0xad) +UPDATE t1 SET token = NULL WHERE token = X'ad'; +Warnings: +Warning 1366 Incorrect string value: '\xAD' for column 'token' at row 1 +SELECT * FROM t1; +id token +1 +2 +DROP TABLE t1; +# End of test for Bug#21032418 +# +# Bug #29047894: ASSERTION FAILURE: ROW0MYSQL.CC:2387:TRX->ALLOW_SEMI_CONSISTENT() +# +CREATE TABLE t1 (a INTEGER); +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +INSERT INTO t1 VALUES (0); +UPDATE t1 SET a=1 ORDER BY CAST('invalid' AS DATETIME); +ERROR 22007: Incorrect datetime value: 'invalid' +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +DELETE FROM t1 WHERE a=2; +DROP TABLE t1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +# +# Bug#30158954: INCONSISTENT ROWS MATCHED VALUE FOR UPDATE +# WITH FAILED CONSTRAINT +# +CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT CHECK (f2 < 400)); +CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT); +CREATE VIEW v2 AS SELECT * FROM t2 WHERE f2 < 400 WITH CHECK OPTION; +INSERT INTO t1 VALUES (1, 10), (2, 20); +INSERT INTO t2 VALUES (1, 10), (2, 20); +UPDATE IGNORE t1 SET f2 = 400; +affected rows: 0 +info: Rows matched: 2 Changed: 0 Warnings: 2 +Warnings: +Warning 3819 Check constraint 't1_chk_1' is violated. +Warning 3819 Check constraint 't1_chk_1' is violated. +UPDATE IGNORE v2 SET f2 = 400; +affected rows: 0 +info: Rows matched: 2 Changed: 0 Warnings: 2 +Warnings: +Warning 1369 CHECK OPTION failed 'test.v2' +Warning 1369 CHECK OPTION failed 'test.v2' +UPDATE IGNORE t2 SET f2 = 400; +affected rows: 2 +info: Rows matched: 2 Changed: 2 Warnings: 0 +DROP VIEW v2; +DROP TABLE t2, t1; +Bug#22671310: Generated columns mess up explain of multi-table update +CREATE TABLE t1(a INTEGER, b INTEGER AS (a)); +CREATE TABLE t2(a INTEGER); +EXPLAIN +UPDATE t1 JOIN t2 USING(a) SET t2.a=t2.a+1 WHERE t1.b>0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +1 UPDATE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t2`.`a` = (`test`.`t2`.`a` + 1) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` > 0)) +DROP TABLE t1, t2; +# Bug#22891840: Error message from update of non-updatable part of +# join view is inaccurate +CREATE TABLE t1(a1 INTEGER PRIMARY KEY, b1 INTEGER); +CREATE TABLE t2(a2 INTEGER PRIMARY KEY, b2 INTEGER); +CREATE VIEW vmat2 AS SELECT DISTINCT * FROM t2; +CREATE VIEW vtr AS +SELECT * FROM t1 JOIN vmat2 AS dt2 ON t1.a1=dt2.a2; +UPDATE vtr SET b1=b1+1 WHERE a1=1; +UPDATE vtr SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtr of the UPDATE is not updatable +DROP VIEW vtr, vmat2; +DROP TABLE t1, t2; +# Bug#31360425: Segfault in Query_result_update::optimize() +CREATE TABLE g(c INTEGER, b INTEGER); +CREATE TABLE t(a INTEGER); +UPDATE t SET a=1 WHERE EXISTS(SELECT b FROM g WHERE 1 NOT LIKE c FOR UPDATE); +DROP TABLE g, t; +# +# Bug#32112403: UPDATE ON TEXT TYPE COLUMN MAY LEAVE IT EMPTY +# +CREATE TABLE t1(i int primary key, c1 tinytext, c2 text); +INSERT INTO t1 VALUES (-1, 'twofiftyfive', '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234'); +INSERT INTO t1 VALUES(0,'zero', +'0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345'); +INSERT INTO t1 VALUES (1, 'one', '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'); +INSERT INTO t1 VALUES (2, 'two', '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567'); +# Ok because the c2 value can fit in c1 +UPDATE t1 SET c1 = c2 WHERE i = -1; +# Fails because these c2 value are too large to fit in c1 +UPDATE t1 SET c1 = c2 WHERE i = 0; +ERROR 22001: Data too long for column 'c1' at row 1 +# Ok with warning when using IGNORE +UPDATE IGNORE t1 SET c1 = c2 WHERE i = 1; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +# Ok with warning with empty sql_mode +SET SESSION sql_mode = ''; +UPDATE t1 SET c1 = c2 WHERE i = 2; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +SET SESSION sql_mode = DEFAULT; +SELECT * FROM t1; +i c1 c2 +-1 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 +0 zero 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 +1 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 +2 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 +DROP TABlE t1; diff --git a/mysql-test/r/user_var.result-pq b/mysql-test/r/user_var.result-pq new file mode 100644 index 000000000..9429eb2ca --- /dev/null +++ b/mysql-test/r/user_var.result-pq @@ -0,0 +1,1087 @@ +drop table if exists t1,t2; +set @a := foo; +ERROR 42S22: Unknown column 'foo' in 'field list' +set @a := connection_id() + 3; +select @a - connection_id(); +@a - connection_id() +3 +set @b := 1; +select @b; +@b +1 +CREATE TABLE t1 ( i int not null, v int not null,index (i)); +insert into t1 values (1,1),(1,3),(2,1); +create table t2 (i int not null, unique (i)); +insert into t2 select distinct i from t1; +select * from t2; +i +1 +2 +select distinct t2.i,@vv1:=if(sv1.i,1,0),@vv2:=if(sv2.i,1,0),@vv3:=if(sv3.i,1,0), @vv1+@vv2+@vv3 from t2 left join t1 as sv1 on sv1.i=t2.i and sv1.v=1 left join t1 as sv2 on sv2.i=t2.i and sv2.v=2 left join t1 as sv3 on sv3.i=t2.i and sv3.v=3; +i @vv1:=if(sv1.i,1,0) @vv2:=if(sv2.i,1,0) @vv3:=if(sv3.i,1,0) @vv1+@vv2+@vv3 +1 1 0 1 2 +2 1 0 0 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where i=@vv1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i i 4 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`i` = (@`vv1`)) +select @vv1,i,v from t1 where i=@vv1; +@vv1 i v +1 1 1 +1 1 3 +explain select * from t1 where @vv1:=@vv1+1 and i=@vv1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`v` AS `v` from `test`.`t1` where (0 <> (@vv1:=((0 <> ((@`vv1`) + 1)) and (`test`.`t1`.`i` = (@`vv1`))))) +explain select @vv1:=i from t1 where i=@vv1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL i 4 NULL 3 33.33 Using where; Using index +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select (@vv1:=`test`.`t1`.`i`) AS `@vv1:=i` from `test`.`t1` where (`test`.`t1`.`i` = (@`vv1`)) +explain select * from t1 where i=@vv1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i i 4 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i`,`test`.`t1`.`v` AS `v` from `test`.`t1` where (`test`.`t1`.`i` = (@`vv1`)) +drop table t1,t2; +set @a=0,@b=0; +select @a:=10, @b:=1, @a > @b, @a < @b; +@a:=10 @b:=1 @a > @b @a < @b +10 1 1 0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:="10", @b:="1", @a > @b, @a < @b; +@a:="10" @b:="1" @a > @b @a < @b +10 1 1 0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:=10, @b:=2, @a > @b, @a < @b; +@a:=10 @b:=2 @a > @b @a < @b +10 2 0 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:="10", @b:="2", @a > @b, @a < @b; +@a:="10" @b:="2" @a > @b @a < @b +10 2 1 0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:=1; +@a:=1 +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a, @a:=1; +@a @a:=1 +1 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 (id int, d double, c char(10)); +insert into t1 values (1,2.0, "test"); +select @c:=0; +@c:=0 +0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 SET id=(@c:=@c+1); +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @c; +@c +1 +select @c:=0; +@c:=0 +0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 set id=(@c:=@c+1); +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @c; +@c +1 +select @c:=0; +@c:=0 +0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @c:=@c+1; +@c:=@c+1 +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @d,(@d:=id),@d from t1; +@d (@d:=id) @d +NULL 1 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @e,(@e:=d),@e from t1; +@e (@e:=d) @e +NULL 2 2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @f,(@f:=c),@f from t1; +@f (@f:=c) @f +NULL test test +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @g=1; +select @g,(@g:=c),@g from t1; +@g (@g:=c) @g +1 test 0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @c, @d, @e, @f; +@c @d @e @f +1 1 2 test +select @d:=id, @e:=id, @f:=id, @g:=@id from t1; +@d:=id @e:=id @f:=id @g:=@id +1 1 1 NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @c, @d, @e, @f, @g; +@c @d @e @f @g +1 1 1 1 NULL +drop table t1; +select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; +@a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b +10 2 1 10 2 1 10 2 1 10 2 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; +@a:=0 +0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +@a @a:=@a+count(*) count(*) @a +0 1 1 0 +0 2 2 0 +0 3 3 0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:=0; +@a:=0 +0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +@a+0 @a:=@a+0+count(*) count(*) @a+0 +0 1 1 0 +0 2 2 0 +0 3 3 0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @a=0; +select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i; +@a @a:="hello" @a @a:=3 @a @a:="hello again" +0 hello 0 3 0 hello again +0 hello 0 3 0 hello again +0 hello 0 3 0 hello again +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i; +@a @a:="hello" @a @a:=3 @a @a:="hello again" +hello again hello hello again 3 hello again hello again +hello again hello hello again 3 hello again hello again +hello again hello hello again 3 hello again hello again +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +set @a=_latin2'test'; +select charset(@a),collation(@a),coercibility(@a); +charset(@a) collation(@a) coercibility(@a) +latin2 latin2_general_ci 2 +select @a=_latin2'TEST'; +@a=_latin2'TEST' +1 +select @a=_latin2'TEST' collate latin2_bin; +@a=_latin2'TEST' collate latin2_bin +0 +set @a=_latin2'test' collate latin2_general_ci; +select charset(@a),collation(@a),coercibility(@a); +charset(@a) collation(@a) coercibility(@a) +latin2 latin2_general_ci 2 +select @a=_latin2'TEST'; +@a=_latin2'TEST' +1 +select @a=_latin2'TEST' collate latin2_bin; +@a=_latin2'TEST' collate latin2_bin +0 +select charset(@a:=_latin2'test'); +charset(@a:=_latin2'test') +latin2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select collation(@a:=_latin2'test'); +collation(@a:=_latin2'test') +latin2_general_ci +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select coercibility(@a:=_latin2'test'); +coercibility(@a:=_latin2'test') +2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select collation(@a:=_latin2'test' collate latin2_bin); +collation(@a:=_latin2'test' collate latin2_bin) +latin2_bin +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select coercibility(@a:=_latin2'test' collate latin2_bin); +coercibility(@a:=_latin2'test' collate latin2_bin) +2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST'; +(@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' +0 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select charset(@a),collation(@a),coercibility(@a); +charset(@a) collation(@a) coercibility(@a) +latin2 latin2_bin 2 +select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; +(@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +set @var= NULL ; +select FIELD( @var,'1it','Hit') as my_column; +my_column +0 +select @v, coercibility(@v); +@v coercibility(@v) +NULL 2 +set @v1=null, @v2=1, @v3=1.1, @v4=now(); +select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4); +coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4) +2 2 2 2 +set session @honk=99; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@honk=99' at line 1 +select @@local.max_allowed_packet; +@@local.max_allowed_packet +# +select @@session.max_allowed_packet; +@@session.max_allowed_packet +# +select @@global.max_allowed_packet; +@@global.max_allowed_packet +# +select @@max_allowed_packet; +@@max_allowed_packet +# +select @@Max_Allowed_Packet; +@@Max_Allowed_Packet +# +select @@version; +@@version +# +select @@global.version; +@@global.version +# +End of 4.1 tests +set @first_var= NULL; +create table t1 select @first_var; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `@first_var` longblob +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @first_var= cast(NULL as signed integer); +create table t1 select @first_var; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `@first_var` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @first_var= NULL; +create table t1 select @first_var; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `@first_var` bigint DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @first_var= concat(NULL); +create table t1 select @first_var; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `@first_var` longblob +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @first_var=1; +set @first_var= cast(NULL as CHAR); +create table t1 select @first_var; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `@first_var` longtext +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +set @a=18446744071710965857; +select @a; +@a +18446744071710965857 +CREATE TABLE `bigfailure` ( +`afield` BIGINT UNSIGNED NOT NULL +); +INSERT INTO `bigfailure` VALUES (18446744071710965857); +SELECT * FROM bigfailure; +afield +18446744071710965857 +select * from (SELECT afield FROM bigfailure) as b; +afield +18446744071710965857 +select * from bigfailure where afield = (SELECT afield FROM bigfailure); +afield +18446744071710965857 +select * from bigfailure where afield = 18446744071710965857; +afield +18446744071710965857 +select * from bigfailure where afield = 18446744071710965856+1; +afield +18446744071710965857 +SET @a := (SELECT afield FROM bigfailure); +SELECT @a; +@a +18446744071710965857 +SET @a := (select afield from (SELECT afield FROM bigfailure) as b); +SELECT @a; +@a +18446744071710965857 +SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailure)); +SELECT @a; +@a +18446744071710965857 +drop table bigfailure; +create table t1(f1 int, f2 int); +insert into t1 values (1,2),(2,3),(3,1); +select @var:=f2 from t1 group by f1 order by f2 desc limit 1; +@var:=f2 +3 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @var; +@var +3 +create table t2 as select @var:=f2 from t1 group by f1 order by f2 desc limit 1; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select * from t2; +@var:=f2 +3 +select @var; +@var +3 +drop table t1,t2; +insert into city 'blah'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''blah'' at line 1 +SHOW COUNT(*) WARNINGS; +@@session.warning_count +1 +SHOW COUNT(*) ERRORS; +@@session.error_count +1 +create table t1(f1 int, f2 varchar(2), f3 float, f4 decimal(2,1)); +insert into t1 values +(1, "a", 1.5, 1.6), (1, "a", 1.5, 1.6), (2, "b", 2.5, 2.6), +(3, "c", 3.5, 3.6), (4, "d", 4.5, 4.6), (1, "a", 1.5, 1.6), +(3, "c", 3.5, 3.6), (1, "a", 1.5, 1.6); +select @a:=f1, count(f1) from t1 group by 1 order by 1 desc; +@a:=f1 count(f1) +4 1 +3 2 +2 1 +1 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:=f1, count(f1) from t1 group by 1 order by 1 asc; +@a:=f1 count(f1) +1 4 +2 1 +3 2 +4 1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:=f2, count(f2) from t1 group by 1 order by 1 desc; +@a:=f2 count(f2) +d 1 +c 2 +b 1 +a 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:=f3, count(f3) from t1 group by 1 order by 1 desc; +@a:=f3 count(f3) +4.5 1 +3.5 2 +2.5 1 +1.5 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select @a:=f4, count(f4) from t1 group by 1 order by 1 desc; +@a:=f4 count(f4) +4.6 1 +3.6 2 +2.6 1 +1.6 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +create table t1 (f1 int); +insert into t1 values (2), (1); +select @i := f1 as j from t1 order by 1; +j +1 +2 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +create table t1(a int); +insert into t1 values(5),(4),(4),(3),(2),(2),(2),(1); +set @rownum := 0; +set @rank := 0; +set @prev_score := NULL; +select @rownum := @rownum + 1 as `row`, +@rank := IF(@prev_score!=a, @rownum, @rank) as `rank`, +@prev_score := a as score +from t1 order by score desc; +drop table t1; +create table t1(b bigint); +insert into t1 (b) values (10), (30), (10); +set @var := 0; +select if(b=@var, 999, b) , @var := b from t1 order by b; +if(b=@var, 999, b) @var := b +10 10 +999 10 +30 30 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +create temporary table t1 (id int); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +@lastid != id @lastid @lastid := id +1 -1 2 +1 2 3 +0 3 3 +1 3 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +create temporary table t1 (id bigint); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +@lastid != id @lastid @lastid := id +1 -1 2 +1 2 3 +0 3 3 +1 3 4 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +drop table t1; +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20); +SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +SELECT @a, @b; +@a @b +2 3 +SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +a b +2 3 +DROP TABLE t1; +CREATE TABLE t1 (f1 int(11) default NULL, f2 int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (f1 int(11) default NULL, f2 int(11) default NULL, foo int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t3 (f1 int(11) default NULL, f2 int(11) default NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES(10, 10); +INSERT INTO t1 VALUES(10, 10); +INSERT INTO t2 VALUES(10, 10, 10); +INSERT INTO t2 VALUES(10, 10, 10); +INSERT INTO t3 VALUES(10, 10); +INSERT INTO t3 VALUES(10, 10); +SELECT MIN(t2.f1), +@bar:= (SELECT MIN(t3.f2) FROM t3 WHERE t3.f2 > foo) +FROM t1,t2 WHERE t1.f1 = t2.f1 ORDER BY t2.f1; +MIN(t2.f1) @bar:= (SELECT MIN(t3.f2) FROM t3 WHERE t3.f2 > foo) +10 NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1, t2, t3; +End of 5.0 tests +CREATE TABLE t1 (i INT); +CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +DROP TABLE t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +# BUG#55615 : should not crash +SELECT (@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) FROM t1 GROUP BY @a; +(@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) +1 +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +# BUG#55564 : should not crash +SELECT IF( +@v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), +count(*), 1) +FROM t1 GROUP BY a LIMIT 1; +IF( +@v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), +count(*), 1) +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +select @v:=@v:=sum(1) from dual; +@v:=@v:=sum(1) +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CREATE TABLE t1(a DECIMAL(31,21)); +INSERT INTO t1 VALUES (0); +SELECT (@v:=a) <> (@v:=1) FROM t1; +(@v:=a) <> (@v:=1) +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +End of 5.1 tests +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1)); +INSERT INTO t1 SET f1 = NULL ; +SET @aux = NULL ; +INSERT INTO t1 SET f1 = @aux ; +SET @aux1 = 0.123E-1; +SET @aux1 = NULL; +INSERT INTO t1 SET f1 = @aux1 ; +SELECT * FROM t1; +f1 +1 +2 +3 +DROP TABLE t1; +CREATE TABLE t1(f1 VARCHAR(257) , f2 INT, PRIMARY KEY(f2)); +CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1; +SET @aux = 1; +SET @aux = NULL; +INSERT INTO test.t1 (f1, f2) VALUES (1, 1), (@aux, 2); +SET @aux = 'text'; +SET @aux = NULL; +INSERT INTO t1(f1, f2) VALUES (1, 3), (@aux, 4); +SELECT f1, f2 FROM t1 ORDER BY f2; +f1 f2 +1 1 +1 2 +1 3 +1 4 +DROP TRIGGER trg1; +DROP TABLE t1; +# +# Bug #12408412: GROUP_CONCAT + ORDER BY + INPUT/OUTPUT +# SAME USER VARIABLE = CRASH +# +SET @bug12408412=1; +SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412; +End of 5.5 tests +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (1), (2); +SELECT DISTINCT @a:=MIN(t1.a) FROM t1, t1 AS t2 +GROUP BY @b:=(SELECT COUNT(*) > t2.a); +@a:=MIN(t1.a) +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +CREATE TABLE t1(a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (0); +SELECT DISTINCT POW(COUNT(*), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a)) +AS b FROM t1 GROUP BY a; +b +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @a; +@a +1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES (1,2),(2,3),(3,1); +CREATE TABLE t2(a INT); +INSERT INTO t2 VALUES (1); +SET @var=NULL; +SELECT @var:=(SELECT f2 FROM t2 WHERE @var) FROM t1 GROUP BY f1 ORDER BY f2 DESC +LIMIT 1; +@var:=(SELECT f2 FROM t2 WHERE @var) +NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT @var; +@var +NULL +DROP TABLE t1, t2; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2(a INT); +INSERT INTO t2 VALUES (1), (3), (5), (7), (9); +CREATE TABLE t3(a INT); +INSERT INTO t3 VALUES (1), (4), (7), (10); +SET @var1 = 6; +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain format=json SELECT t1.a, t2.a, t3.a, (@var1:= @var1+0) AS var +FROM t1 +LEFT JOIN t2 ON t1.a=t2.a AND t2.a < @var1 +LEFT JOIN t3 ON t1.a=t3.a AND t3.a < @var1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.75" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 50, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "5.00", + "prefix_cost": "6.50", + "data_read_per_join": "400" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(is_not_null_compl(t2), ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < (@`var1`))), true)" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 200, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "20.00", + "prefix_cost": "26.75", + "data_read_per_join": "1K" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(is_not_null_compl(t3), ((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < (@`var1`))), true)" + } + } + ] + } +} +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,(@var1:=((@`var1`) + 0)) AS `var` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < (@`var1`)))) left join `test`.`t3` on(((`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < (@`var1`)))) where true +SELECT t1.a, t2.a, t3.a, (@var1:= @var1+0) AS var +FROM t1 +LEFT JOIN t2 ON t1.a=t2.a AND t2.a < @var1 +LEFT JOIN t3 ON t1.a=t3.a AND t3.a < @var1; +a a a var +1 1 1 6 +10 NULL NULL 6 +2 NULL NULL 6 +3 3 NULL 6 +4 NULL 4 6 +5 5 NULL 6 +6 NULL NULL 6 +7 NULL NULL 6 +8 NULL NULL 6 +9 NULL NULL 6 +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warnings: +DROP TABLE t1, t2, t3; +set @X234567890123456789012345678901234567890123456789012345678901234 = 12; +select @X234567890123456789012345678901234567890123456789012345678901234; +@X234567890123456789012345678901234567890123456789012345678901234 +12 +set @X2345678901234567890123456789012345678901234567890123456789012345 = 12; +ERROR 42000: User variable name 'X2345678901234567890123456789012345678901234567890123456789012345' is illegal +set @``= "illegal"; +ERROR 42000: User variable name '' is illegal +set @`endswithspace `= "illegal"; +ERROR 42000: User variable name 'endswithspace ' is illegal +select @X2345678901234567890123456789012345678901234567890123456789012345; +@X2345678901234567890123456789012345678901234567890123456789012345 +NULL +select @``; +@`` +NULL +select @`endswithspace `; +@`endswithspace ` +NULL +CREATE TABLE t1(a INT,KEY(a))ENGINE=INNODB; +SELECT 1 NOT IN (SELECT 1 FROM t1 as t1 GROUP BY 1 LIKE (SELECT 1 FROM t1 as t2)) AS col; +col +1 +SELECT 1 NOT IN (SELECT 1 FROM t1 as t1 ORDER BY 1 LIKE (SELECT 1 FROM t1 as t2)) AS col; +col +1 +SET @c =(SELECT 1 NOT IN (SELECT 1 FROM t1 as t1 GROUP BY 1 LIKE (SELECT 1 FROM t1 as t2)) AS col); +SET @d =(SELECT 1 NOT IN (SELECT 1 FROM t1 as t1 ORDER BY 1 LIKE (SELECT 1 FROM t1 as t2)) AS col); +DROP TABLE t1; +Bug#25727892: Refactor Item::const_item() as a non-virtual function +Coverage for cached and non-cached user variables +CREATE TABLE t1(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES (1,1), (1,2), (2,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain SELECT a FROM t1 WHERE a = @x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((@`x`))) +explain SELECT a FROM t1 WHERE a = @x AND (@x:= @x); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = (@`x`)) and (0 <> (@x:=(@`x`)))) +explain SELECT a FROM t1 WHERE a = @x INTO @x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = ((@`x`))) +SET @x= 1; +SELECT a FROM t1 WHERE a = @x; +a +1 +1 +SELECT a FROM t1 WHERE a = @x AND (@x:= @x); +a +1 +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT a FROM t1 WHERE a = @x INTO @x; +ERROR 42000: Result consisted of more than one row +SET @x= 2; +SELECT a FROM t1 WHERE a = @x INTO @x; +DROP TABLE t1; +# +# Bug#28960901: ASSERTION FAILED: (TLEN % 2) == 0 +# +CREATE TABLE t1(a VARCHAR(10) CHARSET latin1, b VARCHAR(20) CHARSET utf16); +INSERT INTO t1 VALUES ('a', 'abcd'); +SELECT (@x:=b) FROM t1; +(@x:=b) +abcd +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT * FROM t1 WHERE b = (SELECT (@x:=1) FROM t1) OR a = @x; +a b +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +Warning 1292 Truncated incorrect DOUBLE value: '' +SELECT (@x:=a) FROM t1; +(@x:=a) +a +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT * FROM t1 WHERE a = (SELECT (@x:=_utf16 0x1023) FROM t1) OR b = @x; +ERROR HY000: Invalid latin1 character string: '\x10\x23' +DROP TABLE t1; +# +# Bug#29665165: REGRESSION: SOUNDS LIKE CRASHING TO ME +# +SET @c := FROM_UNIXTIME(1537002029); +DO ((@c := (_utf32' -'))) SOUNDS LIKE(@c); +ERROR HY000: Invalid latin1 character string: '\x00\x00\x20\x2D' +# 'Temporal = string literal' compares as temporals, but +# 'Temporal = string user variable' compares as DOUBLE. +# It is a behaviour change introduced by WL#6570. +# Note that +# https://dev.mysql.com/doc/refman/8.0/en/type-conversion.html +# suggests explicit casts as safer. Bug#90076 should fix this. +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, d DATE); +INSERT INTO t1 VALUES(1, '2017-01-01'); +SELECT d < 00010101000000.0 AS a FROM t1; +a +0 +set @tsn= 00010101000000.0; +SELECT d < @tsn AS a FROM t1; +a +1 +DROP TABLE t1; +CREATE TABLE numbers +(pk INTEGER PRIMARY KEY, +ui BIGINT UNSIGNED, +si BIGINT +); +INSERT INTO numbers VALUES +(0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807); +SET @ui_min = CAST(0 AS UNSIGNED); +SET @ui_max = CAST(18446744073709551615 AS UNSIGNED); +SET @si_min = CAST(-9223372036854775808 AS SIGNED); +SET @si_max = CAST(9223372036854775807 AS SIGNED); +PREPARE s1 FROM 'SELECT * FROM numbers WHERE ui=?'; +PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?'; +EXECUTE s1 USING @ui_min; +pk ui si +0 0 -9223372036854775808 +EXECUTE s1 USING @ui_max; +pk ui si +1 18446744073709551615 9223372036854775807 +EXECUTE s1 USING @si_min; +pk ui si +EXECUTE s1 USING @si_max; +pk ui si +EXECUTE s2 USING @ui_min; +pk ui si +EXECUTE s2 USING @ui_max; +pk ui si +EXECUTE s2 USING @si_min; +pk ui si +0 0 -9223372036854775808 +EXECUTE s2 USING @si_max; +pk ui si +1 18446744073709551615 9223372036854775807 +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DROP TABLE numbers; +CREATE TABLE strings +(pk INTEGER PRIMARY KEY, +vc_ascii VARCHAR(20) COLLATE ascii_general_ci, +vc_latin1 VARCHAR(20) COLLATE latin1_general_ci, +vc_utf8mb4 VARCHAR(20) COLLATE utf8mb4_0900_ai_ci, +vc_utf16 VARCHAR(20) COLLATE utf16_general_ci, +vc_utf32 VARCHAR(20) COLLATE utf32_general_ci +); +SET @str_ascii=_ASCII'abcxyz'; +SET @str_utf8mb4=CONVERT(x'616263C3A6C3B8C3A578797A' USING utf8mb4); +SET @str_latin1=CONVERT(@str_utf8mb4 USING latin1); +SET @str_utf16=CONVERT(@str_utf8mb4 USING utf16); +SET @str_utf32=CONVERT(@str_utf8mb4 USING utf32); +INSERT INTO strings VALUES +(0, @str_ascii, @str_ascii, @str_ascii, @str_ascii, @str_ascii), +(1, @str_ascii, @str_utf8mb4, @str_utf8mb4, @str_utf8mb4, @str_utf8mb4); +PREPARE s1 FROM 'SELECT HEX(vc_utf8mb4) FROM strings WHERE vc_ascii = ?'; +PREPARE s2 FROM 'SELECT HEX(vc_utf8mb4) FROM strings WHERE vc_latin1 = ?'; +PREPARE s3 FROM 'SELECT HEX(vc_utf8mb4) FROM strings WHERE vc_utf8mb4 = ?'; +PREPARE s4 FROM 'SELECT HEX(vc_utf8mb4) FROM strings WHERE vc_utf16 = ?'; +PREPARE s5 FROM 'SELECT HEX(vc_utf8mb4) FROM strings WHERE vc_utf32 = ?'; +EXECUTE s1 USING @str_ascii; +HEX(vc_utf8mb4) +61626378797A +616263C3A6C3B8C3A578797A +EXECUTE s1 USING @str_latin1; +ERROR HY000: Conversion from collation latin1_swedish_ci into ascii_general_ci impossible for parameter +EXECUTE s1 USING @str_utf8mb4; +ERROR HY000: Conversion from collation utf8mb4_0900_ai_ci into ascii_general_ci impossible for parameter +EXECUTE s1 USING @str_utf16; +ERROR HY000: Conversion from collation utf16_general_ci into ascii_general_ci impossible for parameter +EXECUTE s1 USING @str_utf32; +ERROR HY000: Conversion from collation utf32_general_ci into ascii_general_ci impossible for parameter +EXECUTE s2 USING @str_ascii; +HEX(vc_utf8mb4) +61626378797A +EXECUTE s2 USING @str_latin1; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s2 USING @str_utf8mb4; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s2 USING @str_utf16; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s2 USING @str_utf32; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s3 USING @str_ascii; +HEX(vc_utf8mb4) +61626378797A +EXECUTE s3 USING @str_latin1; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s3 USING @str_utf8mb4; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s3 USING @str_utf16; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s3 USING @str_utf32; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s4 USING @str_ascii; +HEX(vc_utf8mb4) +61626378797A +EXECUTE s4 USING @str_latin1; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s4 USING @str_utf8mb4; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s4 USING @str_utf16; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s4 USING @str_utf32; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s5 USING @str_ascii; +HEX(vc_utf8mb4) +61626378797A +EXECUTE s5 USING @str_latin1; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s5 USING @str_utf8mb4; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s5 USING @str_utf16; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +EXECUTE s5 USING @str_utf32; +HEX(vc_utf8mb4) +616263C3A6C3B8C3A578797A +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DEALLOCATE PREPARE s3; +DEALLOCATE PREPARE s4; +DEALLOCATE PREPARE s5; +DROP TABLE strings; +set @maxint=18446744073709551615; +SELECT @maxint + 0e0; +@maxint + 0e0 +1.8446744073709552e19 +SELECT 18446744073709551615 + 0e0; +18446744073709551615 + 0e0 +1.8446744073709552e19 +SELECT @maxint + 0.0; +@maxint + 0.0 +18446744073709551615.0 +SELECT 18446744073709551615 + 0.0; +18446744073709551615 + 0.0 +18446744073709551615.0 +PREPARE s FROM 'SELECT 0e0 + ?'; +EXECUTE s USING @maxint; +0e0 + ? +1.8446744073709552e19 +DEALLOCATE PREPARE s; +PREPARE s FROM 'SELECT 0.0 + ?'; +EXECUTE s USING @maxint; +0.0 + ? +18446744073709551615.000000000000000000000000000000 +DEALLOCATE PREPARE s; +PREPARE s FROM 'SELECT 0 + ?'; +EXECUTE s USING @maxint; +0 + ? +18446744073709551615 +DEALLOCATE PREPARE s; +PREPARE s FROM 'SELECT concat(?,"")'; +EXECUTE s USING @maxint; +concat(?,"") +18446744073709551615 +DEALLOCATE PREPARE s; +# Bug#31358565: Assertion `false' failed. In Item_func_get_user_var::propagate_type' +do null not between 1 and @undefined_var; +do null not between @undefined_var and 1; +# Bug#28013997: Assertion failed: (slen % 4) == 0 +SET @f = _utf32 'a'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('2018-05-12 07:43:04'), ('2018-05-12 07:43:04'); +SELECT 1 FROM t1 WHERE @f<>'3761-03-28' XOR (@f:='5570-12-30') > a; +1 +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t1; +# Bug#31599885: Global-buffer-overflow in decimal_bin_size_inline +CREATE TABLE t(a BIT(4), b INTEGER); +SELECT AVG((@e:= a)) FROM t; +AVG((@e:= a)) +NULL +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +SELECT AVG((@e:= a)) FROM t GROUP BY b; +AVG((@e:= a)) +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +DROP TABLE t; diff --git a/mysql-test/r/varbinary.result-pq b/mysql-test/r/varbinary.result-pq new file mode 100644 index 000000000..75eab51c7 --- /dev/null +++ b/mysql-test/r/varbinary.result-pq @@ -0,0 +1,717 @@ +drop table if exists t1; +select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ; +0x41 0x41+0 0x41 | 0x7fffffffffffffff | 0 0xffffffffffffffff | 0 +A 65 9223372036854775807 18446744073709551615 +select 0x31+1,concat(0x31)+1,-0xf; +0x31+1 concat(0x31)+1 -0xf +50 2 -15 +select x'31',X'ffff'+0; +x'31' X'ffff'+0 +1 65535 +create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) ); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 set UNIQ=0x38afba1d73e6a18a; +insert into t1 set UNIQ=123; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 where UNIQ=0x38afba1d73e6a18a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const UNIQ UNIQ 8 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select '00000001' AS `ID`,'004084688022709641610' AS `UNIQ` from `test`.`t1` where true +drop table t1; +select x'hello'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1 +select 0xfg; +ERROR 42S22: Unknown column '0xfg' in 'field list' +create table t1 select 1 as x, 2 as xx; +select x,xx from t1; +x xx +1 2 +drop table t1; +drop table if exists table_28127_a; +drop table if exists table_28127_b; +create table table_28127_a(0b02 int); +show create table table_28127_a; +Table Create Table +table_28127_a CREATE TABLE `table_28127_a` ( + `0b02` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table table_28127_b(0b2 int); +show create table table_28127_b; +Table Create Table +table_28127_b CREATE TABLE `table_28127_b` ( + `0b2` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table table_28127_a; +drop table table_28127_b; +select 0b01000001; +0b01000001 +A +select 0x41; +0x41 +A +select b'01000001'; +b'01000001' +A +select x'41', 0+x'41'; +x'41' 0+x'41' +A 65 +select N'abc', length(N'abc'); +abc length(N'abc') +abc 3 +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +select N'', length(N''); + length(N'') + 0 +Warnings: +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +Warning 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. +select '', length(''); + length('') + 0 +select b'', 0+b''; +b'' 0+b'' + 0 +select x'', 0+x''; +x'' 0+x'' + 0 +select 0x; +ERROR 42S22: Unknown column '0x' in 'field list' +select 0b; +ERROR 42S22: Unknown column '0b' in 'field list' +create TABLE t1(a INT, b VARBINARY(4), c VARBINARY(4)); +INSERT INTO t1 VALUES +(1, 0x31393831, 0x31303037), +(2, 0x31393832, 0x31303038), +(3, 0x31393833, 0x31303039), +(3, 0x31393834, 0x31393831), +(4, 0x31393835, 0x31393832), +(5, 0x31393836, 0x31303038); +# +# deprecation warnings +# +SELECT +hex(b & c), hex(b & 0x31393838), b & NULL, hex(b & 0b00000000000000000000000000001011), +hex(0x31393838 & b), NULL & b, hex(0b00000000000000000000000000001011 & b) +FROM t1; +hex(b & c) hex(b & 0x31393838) b & NULL hex(b & 0b00000000000000000000000000001011) hex(0x31393838 & b) NULL & b hex(0b00000000000000000000000000001011 & b) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 +31393830 31393830 NULL 00000001 31393830 NULL 00000001 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 +SELECT +hex(b | c), hex(b | 0x31393838), b | NULL, hex(b | 0b00000000000000000000000000001011), +hex(0x31393838 | b), NULL | b, hex(0b00000000000000000000000000001011 | b) +FROM t1; +hex(b | c) hex(b | 0x31393838) b | NULL hex(b | 0b00000000000000000000000000001011) hex(0x31393838 | b) NULL | b hex(0b00000000000000000000000000001011 | b) +31393837 31393839 NULL 3139383B 31393839 NULL 3139383B +3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B +3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B +31393835 3139383C NULL 3139383F 3139383C NULL 3139383F +31393837 3139383D NULL 3139383F 3139383D NULL 3139383F +3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F +SELECT +hex(b ^ c), hex(b ^ 0x31393838), b ^ NULL, hex(b ^ 0b00000000000000000000000000001011), +hex(0x31393838 ^ b), NULL ^ b, hex(0b00000000000000000000000000001011 ^ b) +FROM t1; +hex(b ^ c) hex(b ^ 0x31393838) b ^ NULL hex(b ^ 0b00000000000000000000000000001011) hex(0x31393838 ^ b) NULL ^ b hex(0b00000000000000000000000000001011 ^ b) +00090806 00000009 NULL 3139383A 00000009 NULL 3139383A +0009080A 0000000A NULL 31393839 0000000A NULL 31393839 +0009080A 0000000B NULL 31393838 0000000B NULL 31393838 +00000005 0000000C NULL 3139383F 0000000C NULL 3139383F +00000007 0000000D NULL 3139383E 0000000D NULL 3139383E +0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D +SELECT BIT_COUNT(b), HEX(~b), HEX(b << 1), HEX(b >> 1) from t1; +BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +13 CEC6C7CE 62727062 189C9C18 +13 CEC6C7CD 62727064 189C9C19 +14 CEC6C7CC 62727066 189C9C19 +13 CEC6C7CB 62727068 189C9C1A +14 CEC6C7CA 6272706A 189C9C1A +14 CEC6C7C9 6272706C 189C9C1B +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +# +# stored procedures with warnings +# +CREATE PROCEDURE test_bin_op() +SELECT +HEX(b & c), HEX(b & 0x31393838), b & NULL, HEX(b & 0b00000000000000000000000000001011), +HEX(0x31393838 & b), NULL & b, HEX(0b00000000000000000000000000001011 & b), +HEX(b | c), HEX(b | 0x31393838), b | NULL, HEX(b | 0b00000000000000000000000000001011), +HEX(0x31393838 | b), NULL | b, HEX(0b00000000000000000000000000001011 | b), +HEX(b ^ c), HEX(b ^ 0x31393838), b ^ NULL, HEX(b ^ 0b00000000000000000000000000001011), +HEX(0x31393838 ^ b), NULL ^ b, HEX(0b00000000000000000000000000001011 ^ b), +BIT_COUNT(b), HEX(~b), HEX(b << 1), HEX(b >> 1) +FROM t1; +CALL test_bin_op(); +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +CALL test_bin_op(); +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +DROP PROCEDURE test_bin_op; +CREATE PROCEDURE test_bin_op() +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a; +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +DROP PROCEDURE test_bin_op; +CREATE PROCEDURE test_bin_op() +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1; +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +CALL test_bin_op(); +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +DROP PROCEDURE test_bin_op; +# +# prepared statements with warnings +# +PREPARE s1 FROM +"SELECT +HEX(b & c), HEX(b & 0x31393838), b & NULL, HEX(b & 0b00000000000000000000000000001011), +HEX(0x31393838 & b), NULL & b, HEX(0b00000000000000000000000000001011 & b), +HEX(b | c), HEX(b | 0x31393838), b | NULL, HEX(b | 0b00000000000000000000000000001011), +HEX(0x31393838 | b), NULL | b, HEX(0b00000000000000000000000000001011 | b), +HEX(b ^ c), HEX(b ^ 0x31393838), b ^ NULL, HEX(b ^ 0b00000000000000000000000000001011), +HEX(0x31393838 ^ b), NULL ^ b, HEX(0b00000000000000000000000000001011 ^ b), +BIT_COUNT(b), HEX( ~b), HEX(b << 1), HEX(b >> 1) +FROM t1;"; +EXECUTE s1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX( ~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +EXECUTE s1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX( ~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +PREPARE s2 from "SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a"; +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +PREPARE s2 from "SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1"; +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +EXECUTE s2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +# +# views with warnings +# +CREATE VIEW v1 AS +SELECT +HEX(b & c), HEX(b & 0x31393838), b & NULL, HEX(b & 0b00000000000000000000000000001011), +HEX(0x31393838 & b), NULL & b, HEX(0b00000000000000000000000000001011 & b), +HEX(b | c), HEX(b | 0x31393838), b | NULL, HEX(b | 0b00000000000000000000000000001011), +HEX(0x31393838 | b), NULL | b, HEX(0b00000000000000000000000000001011 | b), +HEX(b ^ c), HEX(b ^ 0x31393838), b ^ NULL, HEX(b ^ 0b00000000000000000000000000001011), +HEX(0x31393838 ^ b), NULL ^ b, HEX(0b00000000000000000000000000001011 ^ b), +BIT_COUNT(b), HEX(~b), HEX(b << 1), HEX(b >> 1) +FROM t1; +SELECT * from v1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +SELECT * from v1; +HEX(b & c) HEX(b & 0x31393838) b & NULL HEX(b & 0b00000000000000000000000000001011) HEX(0x31393838 & b) NULL & b HEX(0b00000000000000000000000000001011 & b) HEX(b | c) HEX(b | 0x31393838) b | NULL HEX(b | 0b00000000000000000000000000001011) HEX(0x31393838 | b) NULL | b HEX(0b00000000000000000000000000001011 | b) HEX(b ^ c) HEX(b ^ 0x31393838) b ^ NULL HEX(b ^ 0b00000000000000000000000000001011) HEX(0x31393838 ^ b) NULL ^ b HEX(0b00000000000000000000000000001011 ^ b) BIT_COUNT(b) HEX(~b) HEX(b << 1) HEX(b >> 1) +31303031 31393830 NULL 00000001 31393830 NULL 00000001 31393837 31393839 NULL 3139383B 31393839 NULL 3139383B 00090806 00000009 NULL 3139383A 00000009 NULL 3139383A 13 CEC6C7CE 62727062 189C9C18 +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383A 3139383A NULL 3139383B 3139383A NULL 3139383B 0009080A 0000000A NULL 31393839 0000000A NULL 31393839 13 CEC6C7CD 62727064 189C9C19 +31303031 31393830 NULL 00000003 31393830 NULL 00000003 3139383B 3139383B NULL 3139383B 3139383B NULL 3139383B 0009080A 0000000B NULL 31393838 0000000B NULL 31393838 14 CEC6C7CC 62727066 189C9C19 +31393830 31393830 NULL 00000000 31393830 NULL 00000000 31393835 3139383C NULL 3139383F 3139383C NULL 3139383F 00000005 0000000C NULL 3139383F 0000000C NULL 3139383F 13 CEC6C7CB 62727068 189C9C1A +31393830 31393830 NULL 00000001 31393830 NULL 00000001 31393837 3139383D NULL 3139383F 3139383D NULL 3139383F 00000007 0000000D NULL 3139383E 0000000D NULL 3139383E 14 CEC6C7CA 6272706A 189C9C1A +31303030 31393830 NULL 00000002 31393830 NULL 00000002 3139383E 3139383E NULL 3139383F 3139383E NULL 3139383F 0009080E 0000000E NULL 3139383D 0000000E NULL 3139383D 14 CEC6C7C9 6272706C 189C9C1B +CREATE VIEW v2 AS +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1 GROUP BY a; +SELECT * from v2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +SELECT * from v2; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393831 31393831 31393831 +31393832 31393832 31393832 +31393830 31393837 00000007 +31393835 31393835 31393835 +31393836 31393836 31393836 +CREATE VIEW v3 AS +SELECT HEX(BIT_AND(b)), HEX(BIT_OR(b)), HEX(BIT_XOR(b)) FROM t1; +SELECT * from v3; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +SELECT * from v3; +HEX(BIT_AND(b)) HEX(BIT_OR(b)) HEX(BIT_XOR(b)) +31393830 31393837 00000007 +DROP VIEW v1,v2,v3; +# +# working as before +# +SELECT +a & 0x31393838, 0x31393838 & a, 0x31393838 & 0x31393838, 0x31393838 & NULL, +0x31393838 & 0b1011, NULL & 0x31393838, 0b1011 & 0x31393838, NULL & NULL, +NULL & 0b1011, 0b1011 & NULL, 0b1011 & 0b1011, BIT_COUNT(a) +FROM t1; +a & 0x31393838 0x31393838 & a 0x31393838 & 0x31393838 0x31393838 & NULL 0x31393838 & 0b1011 NULL & 0x31393838 0b1011 & 0x31393838 NULL & NULL NULL & 0b1011 0b1011 & NULL 0b1011 & 0b1011 BIT_COUNT(a) +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 1 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 1 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 2 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 2 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 1 +0 0 825833528 NULL 8 NULL 8 NULL NULL NULL 11 2 +SELECT +a | 0x31393838, 0x31393838 | a, 0x31393838 | 0x31393838, 0x31393838 | NULL, +0x31393838 | 0b1011, NULL | 0x31393838, 0b1011 | 0x31393838, NULL | NULL, +NULL | 0b1011, 0b1011 | NULL, 0b1011 | 0b1011 +FROM t1; +a | 0x31393838 0x31393838 | a 0x31393838 | 0x31393838 0x31393838 | NULL 0x31393838 | 0b1011 NULL | 0x31393838 0b1011 | 0x31393838 NULL | NULL NULL | 0b1011 0b1011 | NULL 0b1011 | 0b1011 +825833529 825833529 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833530 825833530 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833531 825833531 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833531 825833531 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833532 825833532 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +825833533 825833533 825833528 NULL 825833531 NULL 825833531 NULL NULL NULL 11 +SELECT +a ^ 0x31393838, 0x31393838 ^ a, 0x31393838 ^ 0x31393838, 0x31393838 ^ NULL, +0x31393838 ^ 0b1011, NULL ^ 0x31393838, 0b1011 ^ 0x31393838, NULL ^ NULL, +NULL ^ 0b1011, 0b1011 ^ NULL, 0b1011 ^ 0b1011 +FROM t1; +a ^ 0x31393838 0x31393838 ^ a 0x31393838 ^ 0x31393838 0x31393838 ^ NULL 0x31393838 ^ 0b1011 NULL ^ 0x31393838 0b1011 ^ 0x31393838 NULL ^ NULL NULL ^ 0b1011 0b1011 ^ NULL 0b1011 ^ 0b1011 +825833529 825833529 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833530 825833530 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833531 825833531 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833531 825833531 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833532 825833532 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +825833533 825833533 0 NULL 825833523 NULL 825833523 NULL NULL NULL 0 +SELECT a, BIT_AND(a), BIT_OR(a), BIT_XOR(a), +~NULL, NULL << 1, NULL >> 1, 1 << NULL, 1 >> NULL, +~0x31393838, 0x31393838 << 1, 0x31393838 >> 1, +~0b1011, 0b1011 << 1, 0b1011 >> 1 +FROM t1 +GROUP BY a; +a BIT_AND(a) BIT_OR(a) BIT_XOR(a) ~NULL NULL << 1 NULL >> 1 1 << NULL 1 >> NULL ~0x31393838 0x31393838 << 1 0x31393838 >> 1 ~0b1011 0b1011 << 1 0b1011 >> 1 +1 1 1 1 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +2 2 2 2 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +3 3 3 0 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +4 4 4 4 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +5 5 5 5 NULL NULL NULL NULL NULL 18446744072883718087 1651667056 412916764 18446744073709551604 22 5 +# +# binary/varbinary vs char/varchar +# +SELECT '12' | '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def '12' | '12' 8 21 2 N 32929 0 63 +'12' | '12' +12 +SELECT _binary '12' | '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | '12' 8 21 2 N 32929 0 63 +_binary '12' | '12' +12 +SELECT _binary '12' | _binary '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | _binary '12' 253 2 2 N 129 31 63 +_binary '12' | _binary '12' +12 +SELECT _binary '12' | 0x0001; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | 0x0001 253 2 2 N 129 31 63 +_binary '12' | 0x0001 +13 +SELECT _binary '12' | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' | 1 8 21 2 N 32929 0 63 +_binary '12' | 1 +13 +SELECT binary '12' | '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | '12' 8 21 2 Y 32928 0 63 +binary '12' | '12' +12 +SELECT binary '12' | binary '12'; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | binary '12' 253 8 2 Y 128 31 63 +binary '12' | binary '12' +12 +SELECT binary '12' | 0x0001; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | 0x0001 253 8 2 Y 128 31 63 +binary '12' | 0x0001 +13 +SELECT binary '12' | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' | 1 8 21 2 Y 32928 0 63 +binary '12' | 1 +13 +SELECT '12' | 0x01; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def '12' | 0x01 8 21 2 N 32929 0 63 +'12' | 0x01 +13 +SELECT '12' | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def '12' | 1 8 21 2 N 32929 0 63 +'12' | 1 +13 +SELECT CAST('12' AS binary) | 0x0001; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST('12' AS binary) | 0x0001 253 8 2 Y 128 31 63 +CAST('12' AS binary) | 0x0001 +13 +SELECT CAST('12' AS binary) | 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST('12' AS binary) | 1 8 21 2 Y 32928 0 63 +CAST('12' AS binary) | 1 +13 +SELECT CAST(b AS char) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS char) | 0x31393838 CAST(b AS char) | 0x31393838 8 21 9 Y 32800 0 63 +CAST(b AS char) | 0x31393838 +825835453 +SELECT (b + 0) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def (b + 0) | 0x31393838 (b + 0) | 0x31393838 8 21 9 Y 32800 0 63 +(b + 0) | 0x31393838 +825835453 +SELECT CAST(0x01 AS char) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(0x01 AS char) | 0x31393838 8 21 9 Y 32928 0 63 +CAST(0x01 AS char) | 0x31393838 +825833528 +SELECT 0x01 << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def 0x01 << 1 8 21 1 N 32929 0 63 +0x01 << 1 +2 +SELECT _binary '12' << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def _binary '12' << 1 253 2 2 N 129 31 63 +_binary '12' << 1 +bd +SELECT binary '12' << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def binary '12' << 1 253 8 2 Y 128 31 63 +binary '12' << 1 +bd +SELECT CAST('12' AS binary) << 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST('12' AS binary) << 1 253 8 2 Y 128 31 63 +CAST('12' AS binary) << 1 +bd +SELECT CAST(b AS char) << 1 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS char) << 1 CAST(b AS char) << 1 8 21 4 Y 32800 0 63 +CAST(b AS char) << 1 +3962 +SELECT CAST(b AS unsigned) << 1 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS unsigned) << 1 CAST(b AS unsigned) << 1 8 21 4 Y 32800 0 63 +CAST(b AS unsigned) << 1 +3962 +SELECT (b + 0) << 1 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def (b + 0) << 1 (b + 0) << 1 8 21 4 Y 32800 0 63 +(b + 0) << 1 +3962 +SELECT CAST(b AS unsigned) | 0x31393838 FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS unsigned) | 0x31393838 CAST(b AS unsigned) | 0x31393838 8 21 9 Y 32800 0 63 +CAST(b AS unsigned) | 0x31393838 +825835453 +SELECT CAST(b AS unsigned) | CAST(c AS unsigned) FROM t1 LIMIT 1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def CAST(b AS unsigned) | CAST(c AS unsigned) CAST(b AS unsigned) | CAST(c AS unsigned) 8 21 4 Y 32800 0 63 +CAST(b AS unsigned) | CAST(c AS unsigned) +2047 +DROP TABLE t1; +PREPARE ps FROM 'SELECT (~?)'; +SET @a:=0; +EXECUTE ps USING @a; +(~?) +18446744073709551615 +SET @a:='abcd'; +EXECUTE ps USING @a; +(~?) +18446744073709551615 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'abcd' +SET @a:=_binary 'abcd'; +EXECUTE ps USING @a; +(~?) +18446744073709551615 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'abcd' +SET @a:=34; +EXECUTE ps USING @a; +(~?) +18446744073709551581 +SELECT (_binary x'31' | x'31'); +(_binary x'31' | x'31') +1 +SELECT _binary '1' + 0; +_binary '1' + 0 +1 +SELECT (_binary x'31' | x'31') + 0; +(_binary x'31' | x'31') + 0 +1 +SELECT 1.0 * (_binary x'312E35' | x'312E35'); +1.0 * (_binary x'312E35' | x'312E35') +1.5 +SELECT 1.0 * (x'312E35' | x'312E35'); +1.0 * (x'312E35' | x'312E35') +3223093.0 +SELECT HEX(_binary 0x0003 << (_binary 0x38 | NULL)); +HEX(_binary 0x0003 << (_binary 0x38 | NULL)) +NULL +SELECT (_binary x'31' | NULL) + 0; +(_binary x'31' | NULL) + 0 +NULL +SELECT CONCAT("", (0x39 | NULL)); +CONCAT("", (0x39 | NULL)) +NULL +SELECT ~(CONCAT ("", NULL)); +~(CONCAT ("", NULL)) +NULL +# +# Testing datetime and time without warnings +# +SELECT DATEDIFF((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'), '2012-05-21 09:06:07'); +DATEDIFF((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'), '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(20120519090607 | 20120519090607, '2012-05-21 09:06:07'); +DATEDIFF(20120519090607 | 20120519090607, '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(20120519090607, '2012-05-21 09:06:07'); +DATEDIFF(20120519090607, '2012-05-21 09:06:07') +-2 +SELECT SUBTIME((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'),'1 1:1:1.000002'); +SUBTIME((_binary '2012-05-19 09:06:07' | _binary '2012-05-19 09:06:07'),'1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(20120519090607 | 20120519090607 ,'1 1:1:1.000002'); +SUBTIME(20120519090607 | 20120519090607 ,'1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(20120519090607 ,'1 1:1:1.000002'); +SUBTIME(20120519090607 ,'1 1:1:1.000002') +2012-05-18 08:05:05.999998 +# +# Testing datetime and time with warnings +# +SELECT DATEDIFF((_binary '12012-05-19 09:06:07' | _binary '12012-05-19 09:06:07'), '2012-05-21 09:06:07'); +DATEDIFF((_binary '12012-05-19 09:06:07' | _binary '12012-05-19 09:06:07'), '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '12012-05-19 09:06:07' +SELECT DATEDIFF(120120519090607 | 120120519090607, '2012-05-21 09:06:07'); +DATEDIFF(120120519090607 | 120120519090607, '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +SELECT DATEDIFF(120120519090607, '12012-05-21 09:06:07'); +DATEDIFF(120120519090607, '12012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +Warning 1292 Incorrect datetime value: '12012-05-21 09:06:07' +SELECT SUBTIME((_binary '12007-12-31 23:59:59.999999' | _binary '12007-12-31 23:59:59.999999'),'1 1:1:1.000002'); +SUBTIME((_binary '12007-12-31 23:59:59.999999' | _binary '12007-12-31 23:59:59.999999'),'1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '12007-12-31 23:59:59.999999' +SELECT SUBTIME(120120519090607 | 120120519090607 ,'1 1:1:1.000002'); +SUBTIME(120120519090607 | 120120519090607 ,'1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +SELECT SUBTIME(120120519090607 ,'1 1:1:1.000002'); +SUBTIME(120120519090607 ,'1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +CREATE TABLE t1(gid INT, a VARBINARY(20), b BIGINT); +INSERT INTO t1 VALUES(1, _binary '2012-05-19 09:06:07', 20120519090607), +(1, _binary '2012-05-19 09:06:07', 20120519090607), +(2, _binary '12012-05-19 09:06:07', 120120519090607), +(2, _binary '12012-05-19 09:06:07', 120120519090607); +SELECT DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') FROM t1 GROUP BY gid; +DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') +-2 +NULL +Warnings: +Warning 1292 Incorrect datetime value: '12012-05-19 09:06:07' +SELECT DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') FROM t1 GROUP BY gid; +DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') +-2 +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +SELECT DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') FROM t1 WHERE gid = 1; +DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') FROM t1 WHERE gid = 1; +DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') +-2 +SELECT DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') FROM t1 WHERE gid = 2; +DATEDIFF(BIT_OR(a), '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '12012-05-19 09:06:07' +SELECT DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') FROM t1 WHERE gid = 2; +DATEDIFF(BIT_OR(b), '2012-05-21 09:06:07') +NULL +Warnings: +Warning 1292 Incorrect datetime value: '120120519090607' +SELECT SUBTIME(BIT_OR(a), '1 1:1:1.000002') FROM t1 GROUP BY gid; +SUBTIME(BIT_OR(a), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '12012-05-19 09:06:07' +SELECT SUBTIME(BIT_OR(b), '1 1:1:1.000002') FROM t1 GROUP BY gid; +SUBTIME(BIT_OR(b), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +SELECT SUBTIME(BIT_OR(a), '1 1:1:1.000002') FROM t1 WHERE gid = 1; +SUBTIME(BIT_OR(a), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(BIT_OR(b), '1 1:1:1.000002') FROM t1 WHERE gid = 1; +SUBTIME(BIT_OR(b), '1 1:1:1.000002') +2012-05-18 08:05:05.999998 +SELECT SUBTIME(BIT_OR(a), '1 1:1:1.000002') FROM t1 WHERE gid = 2; +SUBTIME(BIT_OR(a), '1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '12012-05-19 09:06:07' +SELECT SUBTIME(BIT_OR(b), '1 1:1:1.000002') FROM t1 WHERE gid = 2; +SUBTIME(BIT_OR(b), '1 1:1:1.000002') +NULL +Warnings: +Warning 1292 Truncated incorrect time value: '120120519090607' +DROP TABLE t1; +# +# Test conversions +# +CREATE TABLE t1(vb varbinary(10), i INT, d DECIMAL(5,2), f FLOAT(5,2), dd DOUBLE(5,2), gid INT); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (_binary "-98765.23", 98765, 0.0, 0.0, 0.0, 1); +INSERT INTO t1 VALUES (_binary "-98765.23", 98765, 1.0, 1.0, 1.0, 2); +SELECT +d + (vb | vb) , f + (vb | vb), dd + (vb | vb), CAST((vb | vb) AS DECIMAL(10,2)), +d + (i | i) , f + (i | i), dd + (i | i), CAST((i | i) AS DECIMAL(10,2)) +FROM t1 +WHERE gid = 1; +d + (vb | vb) f + (vb | vb) dd + (vb | vb) CAST((vb | vb) AS DECIMAL(10,2)) d + (i | i) f + (i | i) dd + (i | i) CAST((i | i) AS DECIMAL(10,2)) +-98765.23 -98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 98765.00 +SELECT +d * (vb | vb) , f * (vb | vb), dd * (vb | vb), +(vb | vb) / d , (vb | vb) / f, (vb | vb) / dd, +d * (i | i) , f * (i | i), dd * (i | i), +(i | i) / d , (i | i) / f, (i | i) / dd +FROM t1 WHERE gid = 2; +d * (vb | vb) f * (vb | vb) dd * (vb | vb) (vb | vb) / d (vb | vb) / f (vb | vb) / dd d * (i | i) f * (i | i) dd * (i | i) (i | i) / d (i | i) / f (i | i) / dd +-98765.23 -98765.23 -98765.23 -98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 98765.0000 98765.000000 98765.000000 +SET sql_mode=''; +SELECT +d + BIT_OR(vb), f + BIT_OR(vb), dd + BIT_OR(vb), CAST(BIT_OR(vb) AS DECIMAL(10,2)), +d + BIT_OR(i), f + BIT_OR(i), dd + BIT_OR(i), CAST(BIT_OR(i) AS DECIMAL(10,2)) +FROM t1 +WHERE gid= 1; +d + BIT_OR(vb) f + BIT_OR(vb) dd + BIT_OR(vb) CAST(BIT_OR(vb) AS DECIMAL(10,2)) d + BIT_OR(i) f + BIT_OR(i) dd + BIT_OR(i) CAST(BIT_OR(i) AS DECIMAL(10,2)) +-98765.23 -98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 98765.00 +SELECT +d * BIT_OR(vb), f * BIT_OR(vb), dd * BIT_OR(vb), BIT_OR(vb) / d, +CAST(BIT_OR(vb) AS DECIMAL(10,2)), BIT_OR(vb) / f, BIT_OR(vb) / dd, +d * BIT_OR(i), f * BIT_OR(i), dd * BIT_OR(i), BIT_OR(i) / d, +CAST(BIT_OR(i) AS DECIMAL(10,2)), BIT_OR(i) / f, BIT_OR(i) / dd +FROM t1 +WHERE gid= 2; +d * BIT_OR(vb) f * BIT_OR(vb) dd * BIT_OR(vb) BIT_OR(vb) / d CAST(BIT_OR(vb) AS DECIMAL(10,2)) BIT_OR(vb) / f BIT_OR(vb) / dd d * BIT_OR(i) f * BIT_OR(i) dd * BIT_OR(i) BIT_OR(i) / d CAST(BIT_OR(i) AS DECIMAL(10,2)) BIT_OR(i) / f BIT_OR(i) / dd +-98765.23 -98765.23 -98765.23 -98765.230000 -98765.23 -98765.230000 -98765.230000 98765.00 98765.00 98765.00 98765.0000 98765.00 98765.000000 98765.000000 +SELECT +d + BIT_OR(vb), f + BIT_OR(vb), dd + BIT_OR(vb), +d + BIT_OR(i), f + BIT_OR(i), dd + BIT_OR(i) +FROM t1 +WHERE gid= 1 +GROUP BY gid; +d + BIT_OR(vb) f + BIT_OR(vb) dd + BIT_OR(vb) d + BIT_OR(i) f + BIT_OR(i) dd + BIT_OR(i) +-98765.23 -98765.23 -98765.23 98765.00 98765.00 98765.00 +SELECT +d * BIT_OR(vb), f * BIT_OR(vb), dd * BIT_OR(vb), BIT_OR(vb) / d, +BIT_OR(vb) / f, BIT_OR(vb) / dd, +d * BIT_OR(i), f * BIT_OR(i), dd * BIT_OR(i), BIT_OR(i) / d, +BIT_OR(i) / f, BIT_OR(i) / dd +FROM t1 +WHERE gid= 2 +GROUP BY gid; +d * BIT_OR(vb) f * BIT_OR(vb) dd * BIT_OR(vb) BIT_OR(vb) / d BIT_OR(vb) / f BIT_OR(vb) / dd d * BIT_OR(i) f * BIT_OR(i) dd * BIT_OR(i) BIT_OR(i) / d BIT_OR(i) / f BIT_OR(i) / dd +-98765.23 -98765.23 -98765.23 -98765.230000 -98765.230000 -98765.230000 98765.00 98765.00 98765.00 98765.0000 98765.000000 98765.000000 +drop table t1; diff --git a/mysql-test/r/view.result-pq b/mysql-test/r/view.result-pq new file mode 100644 index 000000000..2ee749246 --- /dev/null +++ b/mysql-test/r/view.result-pq @@ -0,0 +1,6745 @@ +drop table if exists t1,t2,t3,t4,t9,`t1a``b`,v1,v2,v3,v4,v5,v6; +drop view if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6; +drop database if exists mysqltest; +use test; +create view v1 (c,d) as select a,b from t1; +ERROR 42S02: Table 'test.t1' doesn't exist +create temporary table t1 (a int, b int); +create view v1 (c) as select b+1 from t1; +ERROR HY000: View's SELECT refers to a temporary table 't1' +drop table t1; +create table t1 (a int, b int); +insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10); +create view v1 (c,d) as select a,b+@@global.max_user_connections from t1; +ERROR HY000: View's SELECT contains a variable or parameter +create view v1 (c,d) as select a,b from t1 +where a = @@global.max_user_connections; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT @a=1 FROM DUAL; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE @a>1; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT (@a:= 1) AS one FROM DUAL; +ERROR HY000: View's SELECT contains a variable or parameter +CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE (@a:= 1); +ERROR HY000: View's SELECT contains a variable or parameter +create view v1 (c) as select b+1 from t1; +select c from v1; +c +3 +4 +5 +6 +11 +select is_updatable from information_schema.views where table_name='v1'; +IS_UPDATABLE +NO +create temporary table t1 (a int, b int); +select * from t1; +a b +select c from v1; +c +3 +4 +5 +6 +11 +show create table v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`c`) AS select (`t1`.`b` + 1) AS `b+1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`c`) AS select (`t1`.`b` + 1) AS `b+1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +show create view t1; +ERROR HY000: 'test.t1' is not VIEW +drop table t1; +select a from v1; +ERROR 42S22: Unknown column 'a' in 'field list' +select v1.a from v1; +ERROR 42S22: Unknown column 'v1.a' in 'field list' +select b from v1; +ERROR 42S22: Unknown column 'b' in 'field list' +select v1.b from v1; +ERROR 42S22: Unknown column 'v1.b' in 'field list' +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select c from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` + 1) AS `c` from `test`.`t1` +create algorithm=temptable view v2 (c) as select b+1 from t1; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` (`c`) AS select (`t1`.`b` + 1) AS `b+1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +select c from v2; +c +3 +4 +5 +6 +11 +explain select c from v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v2`.`c` AS `c` from `test`.`v2` +create view v3 (c) as select a+1 from v1; +ERROR 42S22: Unknown column 'a' in 'field list' +create view v3 (c) as select b+1 from v1; +ERROR 42S22: Unknown column 'b' in 'field list' +create view v3 (c) as select c+1 from v1; +select c from v3; +c +4 +5 +6 +7 +12 +explain select c from v3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select ((`test`.`t1`.`b` + 1) + 1) AS `c` from `test`.`t1` +create algorithm=temptable view v4 (c) as select c+1 from v2; +select c from v4; +c +4 +5 +6 +7 +12 +explain select c from v4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v4`.`c` AS `c` from `test`.`v4` +create view v5 (c) as select c+1 from v2; +select c from v5; +c +4 +5 +6 +7 +12 +explain select c from v5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`v2`.`c` + 1) AS `c` from `test`.`v2` +create algorithm=temptable view v6 (c) as select c+1 from v1; +select c from v6; +c +4 +5 +6 +7 +12 +explain select c from v6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v6`.`c` AS `c` from `test`.`v6` +show tables; +Tables_in_test +t1 +v1 +v2 +v3 +v4 +v5 +v6 +show full tables; +Tables_in_test Table_type +t1 BASE TABLE +v1 VIEW +v2 VIEW +v3 VIEW +v4 VIEW +v5 VIEW +v6 VIEW +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic # # # # 0 0 NULL # # NULL utf8mb4_0900_ai_ci NULL +v1 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v2 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v3 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v4 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v5 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +v6 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL VIEW +drop view v1,v2,v3,v4,v5,v6; +create view v1 (c,d,e,f) as select a,b, +a in (select a+2 from t1), a = all (select a from t1) from t1; +create view v2 as select c, d from v1; +select * from v1; +c d e f +1 2 0 0 +1 3 0 0 +2 4 0 0 +2 5 0 0 +3 10 1 0 +select * from v2; +c d +1 2 +1 3 +2 4 +2 5 +3 10 +create view v1 (c,d,e,f) as select a,b, a in (select a+2 from t1), a = all (select a from t1) from t1; +ERROR 42S01: Table 'v1' already exists +create or replace view v1 (c,d,e,f) as select a,b, a in (select a+2 from t1), a = all (select a from t1) from t1; +drop view v2; +alter view v2 as select c, d from v1; +ERROR 42S02: Table 'test.v2' doesn't exist +create or replace view v2 as select c, d from v1; +alter view v1 (c,d) as select a,max(b) from t1 group by a; +select * from v1; +c d +1 3 +2 5 +3 10 +select * from v2; +c d +1 3 +2 5 +3 10 +drop view v100; +ERROR 42S02: Unknown table 'test.v100' +drop view t1; +ERROR HY000: 'test.t1' is not VIEW +drop table v1; +ERROR 42S02: Unknown table 'test.v1' +drop view v1,v2; +drop table t1; +create table t1 (a int); +insert into t1 values (1), (2), (3); +create view v1 (a) as select a+1 from t1; +create view v2 (a) as select a-1 from t1; +select * from t1 natural left join v1; +a +1 +2 +3 +select * from v2 natural left join t1; +a +0 +1 +2 +select * from v2 natural left join v1; +a +0 +1 +2 +drop view v1, v2; +drop table t1; +create table t1 (a int); +insert into t1 values (1), (2), (3), (1), (2), (3); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 as select distinct a from t1; +select * from v1; +a +1 +2 +3 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +select * from t1; +a +1 +2 +3 +1 +2 +3 +drop view v1; +drop table t1; +create table t1 (a int); +create view v1 as select distinct a from t1 WITH CHECK OPTION; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v1' +create view v1 as select a from t1 WITH CHECK OPTION; +create view v2 as select a from t1 WITH CASCADED CHECK OPTION; +create view v3 as select a from t1 WITH LOCAL CHECK OPTION; +drop view v3 RESTRICT; +drop view v2 CASCADE; +drop view v1; +drop table t1; +create table t1 (a int, b int); +insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10); +create view v1 (c) as select b+1 from t1; +select test.c from v1 test; +c +3 +4 +5 +6 +11 +create algorithm=temptable view v2 (c) as select b+1 from t1; +select test.c from v2 test; +c +3 +4 +5 +6 +11 +select test1.* from v1 test1, v2 test2 where test1.c=test2.c; +c +3 +4 +5 +6 +11 +select test2.* from v1 test1, v2 test2 where test1.c=test2.c; +c +3 +4 +5 +6 +11 +drop table t1; +drop view v1,v2; +create table t1 (a int); +insert into t1 values (1), (2), (3), (4); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 as select a+1 from t1 order by 1 desc limit 2; +select * from v1; +a+1 +5 +4 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a+1` AS `a+1` from `test`.`v1` +drop view v1; +drop table t1; +create table t1 (a int); +insert into t1 values (1), (2), (3), (4); +create view v1 as select a+1 from t1; +create table t2 select * from v1; +show columns from t2; +Field Type Null Key Default Extra +a+1 bigint YES NULL +select * from t2; +a+1 +2 +3 +4 +5 +drop view v1; +drop table t1,t2; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +select is_updatable from information_schema.views where table_name='v2'; +IS_UPDATABLE +NO +select is_updatable from information_schema.views where table_name='v1'; +IS_UPDATABLE +YES +update v1 set c=a+c; +ERROR HY000: Column 'c' is not updatable +update v2 set a=a+c; +ERROR HY000: The target table v2 of the UPDATE is not updatable +update v1 set a=a+c; +select * from v1; +a c +13 3 +24 4 +35 5 +46 6 +61 11 +select * from t1; +a b +13 2 +24 3 +35 4 +46 5 +61 10 +drop table t1; +drop view v1,v2; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create table t2 (x int); +insert into t2 values (10), (20); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +update t2,v1 set v1.c=v1.a+v1.c where t2.x=v1.a; +ERROR HY000: Column 'c' is not updatable +update t2,v2 set v2.a=v2.a+c where t2.x=v2.a; +ERROR HY000: The target table v2 of the UPDATE is not updatable +update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.a; +select * from v1; +a c +13 3 +24 4 +30 5 +40 6 +50 11 +select * from t1; +a b +13 2 +24 3 +30 4 +40 5 +50 10 +drop table t1,t2; +drop view v1,v2; +create table t1 (a int, b int, primary key(b)); +insert into t1 values (1,20), (2,30), (3,40), (4,50), (5,100); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 (c) as select b from t1 where a<3; +select * from v1; +c +20 +30 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `c` from `test`.`t1` where (`test`.`t1`.`a` < 3) +update v1 set c=c+1; +select * from t1; +a b +1 21 +2 31 +3 40 +4 50 +5 100 +create view v2 (c) as select b from t1 where a>=3; +select * from v1, v2; +c c +21 100 +21 40 +21 50 +31 100 +31 40 +31 50 +drop view v1, v2; +drop table t1; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +delete from v2 where c < 4; +ERROR HY000: The target table v2 of the DELETE is not updatable +delete from v1 where c < 4; +select * from v1; +a c +2 4 +3 5 +4 6 +5 11 +select * from t1; +a b +2 3 +3 4 +4 5 +5 10 +drop table t1; +drop view v1,v2; +create table t1 (a int, b int, primary key(a)); +insert into t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create table t2 (x int); +insert into t2 values (1), (2), (3), (4); +create view v1 (a,c) as select a, b+1 from t1; +create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +delete v2 from t2,v2 where t2.x=v2.a; +ERROR HY000: The target table v2 of the DELETE is not updatable +delete v1 from t2,v1 where t2.x=v1.a; +select * from v1; +a c +5 11 +select * from t1; +a b +5 10 +drop table t1,t2; +drop view v1,v2; +create table t1 (a int, b int, c int, primary key(a,b)); +insert into t1 values (10,2,-1), (20,3,-2), (30,4,-3), (40,5,-4), (50,10,-5); +create view v1 (x,y) as select a, b from t1; +create view v2 (x,y) as select a, c from t1; +set updatable_views_with_limit=NO; +update v1 set x=x+1; +update v2 set x=x+1; +update v1 set x=x+1 limit 1; +update v2 set x=x+1 limit 1; +ERROR HY000: The target table v2 of the UPDATE is not updatable +delete from v2 limit 1; +ERROR HY000: The target table v2 of the DELETE is not updatable +set updatable_views_with_limit=YES; +update v1 set x=x+1 limit 1; +update v2 set x=x+1 limit 1; +Warnings: +Note 1355 View being updated does not have complete key of underlying table in it +set updatable_views_with_limit=DEFAULT; +show variables like "updatable_views_with_limit"; +Variable_name Value +updatable_views_with_limit YES +select * from t1; +a b c +15 2 -1 +22 3 -2 +32 4 -3 +42 5 -4 +52 10 -5 +drop table t1; +drop view v1,v2; +create table t1 (a int, b int, c int, primary key(a,b)); +insert into t1 values (10,2,-1), (20,3,-2); +create view v1 (x,y,z) as select c, b, a from t1; +create view v2 (x,y) as select b, a from t1; +create view v3 (x,y,z) as select b, a, b from t1; +create view v4 (x,y,z) as select c+1, b, a from t1; +create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; +insert into v3 values (-60,4,30); +ERROR HY000: The target table v3 of the INSERT is not insertable-into +insert into v4 values (-60,4,30); +ERROR HY000: Column 'x' is not updatable +insert into v5 values (-60,4,30); +ERROR HY000: The target table v5 of the INSERT is not insertable-into +insert into v1 values (-60,4,30); +insert into v1 (z,y,x) values (50,6,-100); +insert into v2 values (5,40); +select * from t1; +a b c +10 2 -1 +20 3 -2 +30 4 -60 +40 5 NULL +50 6 -100 +drop table t1; +drop view v1,v2,v3,v4,v5; +create table t1 (a int, b int, c int, primary key(a,b)); +insert into t1 values (10,2,-1), (20,3,-2); +create table t2 (a int, b int, c int, primary key(a,b)); +insert into t2 values (30,4,-60); +create view v1 (x,y,z) as select c, b, a from t1; +create view v2 (x,y) as select b, a from t1; +create view v3 (x,y,z) as select b, a, b from t1; +create view v4 (x,y,z) as select c+1, b, a from t1; +create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; +insert into v3 select c, b, a from t2; +ERROR HY000: The target table v3 of the INSERT is not insertable-into +insert into v4 select c, b, a from t2; +ERROR HY000: Column 'x' is not updatable +insert into v5 select c, b, a from t2; +ERROR HY000: The target table v5 of the INSERT is not insertable-into +insert into v1 select c, b, a from t2; +insert into v1 (z,y,x) select a+20,b+2,-100 from t2; +insert into v2 select b+1, a+10 from t2; +select * from t1; +a b c +10 2 -1 +20 3 -2 +30 4 -60 +40 5 NULL +50 6 -100 +drop table t1, t2; +drop view v1,v2,v3,v4,v5; +create table t1 (a int, primary key(a)); +insert into t1 values (1), (2), (3); +create view v1 (x) as select a from t1 where a > 1; +select t1.a, v1.x from t1 left join v1 on (t1.a= v1.x); +a x +1 NULL +2 2 +3 3 +drop table t1; +drop view v1; +create table t1 (a int, primary key(a)); +insert into t1 values (1), (2), (3), (200); +create view v1 (x) as select a from t1 where a > 1; +create view v2 (y) as select x from v1 where x < 100; +select * from v2; +y +2 +3 +drop table t1; +drop view v1,v2; +create table t1 (a int, primary key(a)); +insert into t1 values (1), (2), (3), (200); +create ALGORITHM=TEMPTABLE view v1 (x) as select a from t1; +create view v2 (y) as select x from v1; +update v2 set y=10 where y=2; +ERROR HY000: The target table v2 of the UPDATE is not updatable +drop table t1; +drop view v1,v2; +create table t1 (a int not null auto_increment, b int not null, primary key(a), unique(b)); +create view v1 (x) as select b from t1; +insert into v1 values (1); +select last_insert_id(); +last_insert_id() +0 +insert into t1 (b) values (2); +select last_insert_id(); +last_insert_id() +2 +select * from t1; +a b +1 1 +2 2 +drop view v1; +drop table t1; +set sql_mode='ansi'; +create table t1 ("a*b" int); +create view v1 as select "a*b" from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE VIEW "v1" AS select "t1"."a*b" AS "a*b" from "t1" utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +set sql_mode=default; +create table t1 (t_column int); +create view v1 as select 'a'; +select * from v1, t1; +a t_column +drop view v1; +drop table t1; +create table `t1a``b` (col1 char(2)); +create view v1 as select * from `t1a``b`; +select * from v1; +col1 +describe v1; +Field Type Null Key Default Extra +col1 char(2) YES NULL +drop view v1; +drop table `t1a``b`; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (col1 char(5),col2 char(5)); +create view v1 as select * from t1; +drop table t1; +create table t1 (col1 char(5),newcol2 char(5)); +insert into v1 values('a','aa'); +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop table t1; +select * from v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1; +SET sql_mode = default; +create view v1 (a,a) as select 'a','a'; +ERROR 42S21: Duplicate column name 'a' +create table t1 (col1 int,col2 char(22)); +insert into t1 values(5,'Hello, world of views'); +create view v1 as select * from t1; +create view v2 as select * from v1; +update v2 set col2='Hello, view world'; +select is_updatable from information_schema.views where +table_schema != 'sys' and table_schema != 'information_schema'; +IS_UPDATABLE +YES +YES +select * from t1; +col1 col2 +5 Hello, view world +drop view v2, v1; +drop table t1; +create table t1 (a int, b int); +create view v1 as select a, sum(b) from t1 group by a; +select b from v1 use index (some_index) where b=1; +ERROR 42000: Key 'some_index' doesn't exist in table 'v1' +drop view v1; +drop table t1; +create table t1 (col1 char(5),col2 char(5)); +create view v1 (col1,col2) as select col1,col2 from t1; +insert into v1 values('s1','p1'),('s1','p2'),('s1','p3'),('s1','p4'),('s2','p1'),('s3','p2'),('s4','p4'); +select distinct first.col2 from t1 first where first.col2 in (select second.col2 from t1 second where second.col1<>first.col1); +col2 +p1 +p2 +p4 +select distinct first.col2 from v1 first where first.col2 in (select second.col2 from t1 second where second.col1<>first.col1); +col2 +p1 +p2 +p4 +drop view v1; +drop table t1; +create table t1 (a int); +create view v1 as select a from t1; +insert into t1 values (1); +SET @v0 = '2'; +PREPARE stmt FROM 'UPDATE v1 SET a = ?'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +SET @v0 = '3'; +PREPARE stmt FROM 'insert into v1 values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +SET @v0 = '4'; +PREPARE stmt FROM 'insert into v1 (a) values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +select * from t1; +a +2 +3 +4 +drop view v1; +drop table t1; +CREATE VIEW v02 AS SELECT * FROM DUAL; +ERROR HY000: No tables used +SHOW TABLES; +Tables_in_test +CREATE VIEW v1 AS SELECT EXISTS (SELECT 1 UNION SELECT 2); +select * from v1; +EXISTS (SELECT 1 UNION SELECT 2) +1 +drop view v1; +create table t1 (col1 int,col2 char(22)); +create view v1 as select * from t1; +create index i1 on v1 (col1); +ERROR HY000: 'test.v1' is not BASE TABLE +drop view v1; +drop table t1; +CREATE VIEW v1 (f1,f2,f3,f4) AS SELECT connection_id(), pi(), current_user(), version(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`f1`,`f2`,`f3`,`f4`) AS select connection_id() AS `connection_id()`,pi() AS `pi()`,current_user() AS `current_user()`,version() AS `version()` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +create table t1 (s1 int); +create table t2 (s2 int); +insert into t1 values (1), (2); +insert into t2 values (2), (3); +create view v1 as select * from t1,t2 union all select * from t1,t2; +select * from v1; +s1 s2 +1 2 +1 2 +1 3 +1 3 +2 2 +2 2 +2 3 +2 3 +drop view v1; +drop tables t1, t2; +create table t1 (col1 int); +insert into t1 values (1); +create view v1 as select count(*) from t1; +insert into t1 values (null); +select * from v1; +count(*) +2 +drop view v1; +drop table t1; +create table t1 (a int); +create table t2 (a int); +create view v1 as select a from t1; +create view v2 as select a from t2 where a in (select a from v1); +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where `t2`.`a` in (select `v1`.`a` from `v1`) utf8mb4 utf8mb4_0900_ai_ci +drop view v2, v1; +drop table t1, t2; +CREATE VIEW `v 1` AS select 5 AS `5`; +show create view `v 1`; +View Create View character_set_client collation_connection +v 1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v 1` AS select 5 AS `5` utf8mb4 utf8mb4_0900_ai_ci +drop view `v 1`; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create view mysqltest.v1 as select a from mysqltest.t1; +alter view mysqltest.v1 as select b from mysqltest.t1; +alter view mysqltest.v1 as select a from mysqltest.t1; +drop database mysqltest; +CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2)); +insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer'); +select * from t1 WHERE match (c2) against ('Beer'); +c1 c2 +1 real Beer +7 almost real Beer +CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer'); +select * from v1; +c1 c2 +1 real Beer +7 almost real Beer +drop view v1; +drop table t1; +create table t1 (a int); +insert into t1 values (1),(1),(2),(2),(3),(3); +create view v1 as select a from t1; +select distinct a from v1; +a +1 +2 +3 +select distinct a from v1 limit 2; +a +1 +2 +select distinct a from t1 limit 2; +a +1 +2 +prepare stmt1 from "select distinct a from v1 limit 2"; +execute stmt1; +a +1 +2 +execute stmt1; +a +1 +2 +deallocate prepare stmt1; +drop view v1; +drop table t1; +create table t1 (tg_column bigint); +create view v1 as select count(tg_column) as vg_column from t1; +select avg(vg_column) from v1; +avg(vg_column) +0.0000 +drop view v1; +drop table t1; +create table t1 (col1 bigint not null, primary key (col1)); +create table t2 (col1 bigint not null, key (col1)); +create view v1 as select * from t1; +create view v2 as select * from t2; +insert into v1 values (1); +insert into v2 values (1); +create view v3 (a,b) as select v1.col1 as a, v2.col1 as b from v1, v2 where v1.col1 = v2.col1; +select * from v3; +a b +1 1 +show create view v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` (`a`,`b`) AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from (`v1` join `v2`) where (`v1`.`col1` = `v2`.`col1`) utf8mb4 utf8mb4_0900_ai_ci +drop view v3, v2, v1; +drop table t2, t1; +create function `f``1` () returns int return 5; +create view v1 as select test.`f``1` (); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`f``1`() AS `test.``f````1`` ()` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +test.`f``1` () +5 +drop view v1; +drop function `f``1`; +create function a() returns int return 5; +create view v1 as select a(); +select * from v1; +a() +5 +drop view v1; +drop function a; +create table t2 (col1 char collate latin1_german2_ci); +create view v2 as select col1 collate latin1_german1_ci from t2; +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2` utf8mb4 utf8mb4_0900_ai_ci +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t2`.`col1` collate latin1_german1_ci) AS `col1 collate latin1_german1_ci` from `t2` utf8mb4 utf8mb4_0900_ai_ci +drop view v2; +drop table t2; +create table t1 (a int); +insert into t1 values (1), (2); +create view v1 as select 5 from t1 order by 1; +select * from v1; +5 +5 +5 +drop view v1; +drop table t1; +create function x1 () returns int return 5; +create table t1 (s1 int); +create view v1 as select x1() from t1; +drop function x1; +select * from v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 InnoDB 10 Dynamic # # # # 0 0 NULL # # NULL utf8mb4_0900_ai_ci NULL +v1 NULL NULL NULL # # # # NULL NULL NULL # # NULL NULL NULL NULL View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +Warnings: +Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1; +drop table t1; +create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +SET @old_cs_client = @@character_set_client; +SET @old_cs_results = @@character_set_results; +SET @old_cs_connection = @@character_set_connection; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table tü (cü char); +create view vü as select cü from tü; +insert into vü values ('ü'); +select * from vü; +cü +ü +drop view vü; +drop table tü; +SET character_set_client = @old_cs_client; +SET character_set_results = @old_cs_results; +SET character_set_connection = @old_cs_connection; +create table t1 (a int, b int); +insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10); +create view v1(c) as select a+1 from t1 where b >= 4; +select c from v1 where exists (select * from t1 where a=2 and b=c); +c +4 +drop view v1; +drop table t1; +create view v1 as select cast(1 as char(3)); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1 as char(3) charset utf8mb4) AS `cast(1 as char(3))` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +cast(1 as char(3)) +1 +drop view v1; +create table t1 (a int); +create view v1 as select a from t1; +create view v3 as select a from t1; +create database mysqltest; +rename table v1 to mysqltest.v1; +ERROR HY000: Changing schema from 'test' to 'mysqltest' is not allowed. +rename table v1 to v2; +rename table v3 to v1, v2 to t1; +ERROR 42S01: Table 't1' already exists +drop table t1; +drop view v2,v3; +drop database mysqltest; +create view v1 as select 'a',1; +create view v2 as select * from v1 union all select * from v1; +create view v3 as select * from v2 where 1 = (select `1` from v2); +create view v4 as select * from v3; +select * from v4; +ERROR 21000: Subquery returns more than 1 row +drop view v4, v3, v2, v1; +create view v1 as select 5 into @w; +ERROR HY000: View's SELECT contains a 'INTO' clause +create view v1 as select 5 into outfile 'ttt'; +ERROR HY000: View's SELECT contains a 'INTO' clause +create table t1 (a int); +create view v1 as select 1 from (select 1) as d1; +drop view v1; +drop table t1; +create table t1 (s1 int, primary key (s1)); +create view v1 as select * from t1; +insert into v1 values (1) on duplicate key update s1 = 7; +insert into v1 values (1) on duplicate key update s1 = 7; +select * from t1; +s1 +7 +drop view v1; +drop table t1; +create table t1 (col1 int); +create table t2 (col1 int); +create table t3 (col1 datetime not null); +create view v1 as select * from t1; +create view v2 as select * from v1; +create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; +update v2 set col1 = (select max(col1) from v1); +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2'. +update v2 set col1 = (select max(col1) from t1); +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'. +update v2 set col1 = (select max(col1) from v2); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2'. +update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't1'. +update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'. +update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'. +update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'. +update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'. +update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v1'. +update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't1'. +update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v1'. +update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'. +update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'. +update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'. +update v3 set v3.col1 = (select max(col1) from v1); +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v3'. +update v3 set v3.col1 = (select max(col1) from t1); +ERROR HY000: The definition of table 'v3' prevents operation UPDATE on table 'v3'. +update v3 set v3.col1 = (select max(col1) from v2); +ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v3'. +update v3 set v3.col1 = (select max(col1) from v3); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +delete from v2 where col1 = (select max(col1) from v1); +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'. +delete from v2 where col1 = (select max(col1) from t1); +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'. +delete from v2 where col1 = (select max(col1) from v2); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'. +delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 't1'. +delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'. +delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v1'. +delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 't1'. +delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1; +ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v1'. +insert into v2 values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2'. +insert into t1 values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 't1'. +insert into v2 values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2'. +insert into v2 values ((select max(col1) from t1)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'. +insert into t1 values ((select max(col1) from t1)); +ERROR HY000: You can't specify target table 't1' for update in FROM clause +insert into v2 values ((select max(col1) from t1)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'. +insert into v2 values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into t1 values ((select max(col1) from v2)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 't1'. +insert into v2 values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into v3 (col1) values ((select max(col1) from v1)); +ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select max(col1) from t1)); +ERROR HY000: The definition of table 'v3' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select max(col1) from v2)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); +ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3'. +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +ERROR 23000: Column 'col1' cannot be null +create algorithm=temptable view v4 as select * from t1; +insert into t1 values (1),(2),(3); +insert into t1 (col1) values ((select max(col1) from v4)); +select * from t1; +col1 +NULL +1 +2 +3 +3 +drop view v4,v3,v2,v1; +drop table t1,t2,t3; +create table t1 (s1 int); +create view v1 as select * from t1; +handler v1 open as xx; +ERROR HY000: 'test.v1' is not BASE TABLE +drop view v1; +drop table t1; +create table t1(a int); +insert into t1 values (0), (1), (2), (3); +create table t2 (a int); +insert into t2 select a from t1 where a > 1; +create view v1 as select a from t1 where a > 1; +select * from t1 left join (t2 as t, v1) on v1.a=t1.a; +a a a +0 NULL NULL +1 NULL NULL +2 2 2 +2 3 2 +3 2 3 +3 3 3 +select * from t1 left join (t2 as t, t2) on t2.a=t1.a; +a a a +0 NULL NULL +1 NULL NULL +2 2 2 +2 3 2 +3 2 3 +3 3 3 +drop view v1; +drop table t1, t2; +create table t1 (s1 char) charset latin1; +create view v1 as select s1 collate latin1_german1_ci as s1 from t1; +insert into v1 values ('a'); +select * from v1; +s1 +a +update v1 set s1='b'; +select * from v1; +s1 +b +update v1,t1 set v1.s1='c' where t1.s1=v1.s1; +select * from v1; +s1 +c +prepare stmt1 from "update v1,t1 set v1.s1=? where t1.s1=v1.s1"; +set @arg='d'; +execute stmt1 using @arg; +select * from v1; +s1 +d +set @arg='e'; +execute stmt1 using @arg; +select * from v1; +s1 +e +deallocate prepare stmt1; +drop view v1; +drop table t1; +create table t1 (a int); +create table t2 (a int); +create view v1 as select * from t1; +lock tables t1 read, v1 read; +select * from v1; +a +select * from t2; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +unlock tables; +drop view v1; +drop table t1, t2; +create table t1 (a int); +create view v1 as select * from t1 where a < 2 with check option; +insert into v1 values(1); +insert into v1 values(3); +ERROR HY000: CHECK OPTION failed 'test.v1' +insert ignore into v1 values (2),(3),(0); +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a +1 +0 +delete from t1; +insert into v1 SELECT 1; +insert into v1 SELECT 3; +ERROR HY000: CHECK OPTION failed 'test.v1' +create table t2 (a int); +insert into t2 values (2),(3),(0); +insert ignore into v1 SELECT a from t2; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1 order by a desc; +a +1 +0 +update v1 set a=-1 where a=0; +update v1 set a=2 where a=1; +ERROR HY000: CHECK OPTION failed 'test.v1' +select * from t1 order by a desc; +a +1 +-1 +update v1 set a=0 where a=0; +insert into t2 values (1); +update v1,t2 set v1.a=v1.a-1 where v1.a=t2.a; +select * from t1 order by a desc; +a +0 +-1 +update v1 set a=a+1; +update ignore v1,t2 set v1.a=v1.a+1 where v1.a=t2.a; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a +1 +1 +drop view v1; +drop table t1, t2; +create table t1 (a int); +create view v1 as select * from t1 where a < 2 with check option; +create view v2 as select * from v1 where a > 0 with local check option; +create view v3 as select * from v1 where a > 0 with cascaded check option; +insert into v2 values (1); +insert into v3 values (1); +insert into v2 values (0); +ERROR HY000: CHECK OPTION failed 'test.v2' +insert into v3 values (0); +ERROR HY000: CHECK OPTION failed 'test.v3' +insert into v2 values (2); +ERROR HY000: CHECK OPTION failed 'test.v2' +insert into v3 values (2); +ERROR HY000: CHECK OPTION failed 'test.v3' +select * from t1; +a +1 +1 +drop view v3,v2,v1; +drop table t1; +create table t1 (a int, primary key (a)); +create view v1 as select * from t1 where a < 2 with check option; +insert into v1 values (1) on duplicate key update a=2; +insert into v1 values (1) on duplicate key update a=2; +ERROR HY000: CHECK OPTION failed 'test.v1' +insert ignore into v1 values (1) on duplicate key update a=2; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a +1 +drop view v1; +drop table t1; +create table t1 (s1 int); +create view v1 as select * from t1; +create view v2 as select * from v1; +alter view v1 as select * from v2; +ERROR 42S02: Table 'test.v1' doesn't exist +alter view v1 as select * from v1; +ERROR 42S02: Table 'test.v1' doesn't exist +create or replace view v1 as select * from v2; +ERROR 42S02: Table 'test.v1' doesn't exist +create or replace view v1 as select * from v1; +ERROR 42S02: Table 'test.v1' doesn't exist +drop view v2,v1; +drop table t1; +create table t1 (a int); +create view v1 as select * from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +alter algorithm=undefined view v1 as select * from t1 with check option; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +alter algorithm=merge view v1 as select * from t1 with cascaded check option; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` WITH CASCADED CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +alter algorithm=temptable view v1 as select * from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +create table t1 (s1 int); +create table t2 (s1 int); +create view v2 as select * from t2 where s1 in (select s1 from t1); +insert into v2 values (5); +insert into t1 values (5); +select * from v2; +s1 +5 +update v2 set s1 = 0; +select * from v2; +s1 +select * from t2; +s1 +0 +alter view v2 as select * from t2 where s1 in (select s1 from t1) with check option; +insert into v2 values (5); +update v2 set s1 = 1; +ERROR HY000: CHECK OPTION failed 'test.v2' +insert into t1 values (1); +update v2 set s1 = 1; +select * from v2; +s1 +1 +select * from t2; +s1 +0 +1 +prepare stmt1 from "select * from v2;"; +execute stmt1; +s1 +1 +insert into t1 values (0); +execute stmt1; +s1 +0 +1 +deallocate prepare stmt1; +drop view v2; +drop table t1, t2; +create table t1 (t time); +create view v1 as select substring_index(t,':',2) as t from t1; +insert into t1 (t) values ('12:24:10'); +select substring_index(t,':',2) from t1; +substring_index(t,':',2) +12:24 +select substring_index(t,':',2) from v1; +substring_index(t,':',2) +12:24 +drop view v1; +drop table t1; +create table t1 (s1 tinyint); +create view v1 as select * from t1 where s1 <> 0 with local check option; +create view v2 as select * from v1 with cascaded check option; +insert into v2 values (0); +ERROR HY000: CHECK OPTION failed 'test.v2' +drop view v2, v1; +drop table t1; +create table t1 (s1 int); +create view v1 as select * from t1 where s1 < 5 with check option; +insert ignore into v1 values (6); +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +insert ignore into v1 values (6),(3); +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +s1 +3 +drop view v1; +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (s1 tinyint); +create trigger t1_bi before insert on t1 for each row set new.s1 = 500; +create view v1 as select * from t1 where s1 <> 127 with check option; +insert into v1 values (0); +ERROR HY000: CHECK OPTION failed 'test.v1' +select * from v1; +s1 +select * from t1; +s1 +drop trigger t1_bi; +drop view v1; +drop table t1; +SET sql_mode = default; +create table t1 (s1 tinyint); +create view v1 as select * from t1 where s1 <> 0; +create view v2 as select * from v1 where s1 <> 1 with cascaded check option; +insert into v2 values (0); +ERROR HY000: CHECK OPTION failed 'test.v2' +select * from v2; +s1 +select * from t1; +s1 +drop view v2, v1; +drop table t1; +create table t1 (a text, b text); +create view v1 as select * from t1 where a <> 'Field A' with check option; +load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; +ERROR HY000: CHECK OPTION failed 'test.v1' +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +delete from t1; +load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1261 Row 2 doesn't contain data for all columns +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +drop view v1; +drop table t1; +create table t1 (a int, b char(10)) charset latin1; +create view v1 as select * from t1 where a != 0 with check option; +load data infile '../../std_data/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +ERROR HY000: Incorrect integer value: 'error ' for column 'a' at row 3 +select * from t1; +a b +select * from v1; +a b +delete from t1; +load data infile '../../std_data/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +Warnings: +Warning 1366 Incorrect integer value: 'error ' for column 'a' at row 3 +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1366 Incorrect integer value: 'wrong end ' for column 'a' at row 4 +Warning 1369 CHECK OPTION failed 'test.v1' +select * from t1; +a b +1 row 1 +2 row 2 +3 row 3 +select * from v1; +a b +1 row 1 +2 row 2 +3 row 3 +drop view v1; +drop table t1; +create table t1 (a text, b text) ; +create view v1 as select * from t1 where a <> 'Field A' with check option; +load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; +ERROR HY000: CHECK OPTION failed 'test.v1' +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +delete from t1; +load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; +Warnings: +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1261 Row 2 doesn't contain data for all columns +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +select concat('|',a,'|'), concat('|',b,'|') from v1; +concat('|',a,'|') concat('|',b,'|') +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +drop view v1; +drop table t1; +create table t1 (s1 smallint); +create view v1 as select * from t1 where 20 < (select (s1) from t1); +insert into v1 values (30); +ERROR HY000: The target table v1 of the INSERT is not insertable-into +create view v2 as select * from t1; +create view v3 as select * from t1 where 20 < (select (s1) from v2); +insert into v3 values (30); +ERROR HY000: The target table v3 of the INSERT is not insertable-into +create view v4 as select * from v2 where 20 < (select (s1) from t1); +insert into v4 values (30); +ERROR HY000: The target table v4 of the INSERT is not insertable-into +drop view v4, v3, v2, v1; +drop table t1; +create table t1 (a int); +create view v1 as select * from t1; +check table t1,v1; +Table Op Msg_type Msg_text +test.t1 check status OK +test.v1 check status OK +check table v1,t1; +Table Op Msg_type Msg_text +test.v1 check status OK +test.t1 check status OK +drop table t1; +check table v1; +Table Op Msg_type Msg_text +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check error Corrupt +drop view v1; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 values (1), (2), (3); +insert into t2 values (1), (3); +insert into t3 values (1), (2), (4); +analyze table t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +create view v3 (a,b) as select t1.a as a, t2.a as b from t1 left join t2 on (t1.a=t2.a); +select * from t3 left join v3 on (t3.a = v3.a); +a a b +1 1 1 +2 2 NULL +4 NULL NULL +explain select * from t3 left join v3 on (t3.a = v3.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`))) on((`test`.`t1`.`a` = `test`.`t3`.`a`)) where true +create view v1 (a) as select a from t1; +create view v2 (a) as select a from t2; +create view v4 (a,b) as select v1.a as a, v2.a as b from v1 left join v2 on (v1.a=v2.a); +select * from t3 left join v4 on (t3.a = v4.a); +a a b +1 1 1 +2 2 NULL +4 NULL NULL +explain select * from t3 left join v4 on (t3.a = v4.a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join (`test`.`t2`) on(((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)))) on((`test`.`t1`.`a` = `test`.`t3`.`a`)) where true +prepare stmt1 from "select * from t3 left join v4 on (t3.a = v4.a);"; +execute stmt1; +a a b +1 1 1 +2 2 NULL +4 NULL NULL +execute stmt1; +a a b +1 1 1 +2 2 NULL +4 NULL NULL +deallocate prepare stmt1; +drop view v4,v3,v2,v1; +drop tables t1,t2,t3; +create table t1 (a int, primary key (a), b int); +create table t2 (a int, primary key (a)); +insert into t1 values (1,100), (2,200); +insert into t2 values (1), (3); +create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2; +update v3 set a= 10 where a=1; +select * from t1; +a b +10 100 +2 200 +select * from t2; +a +1 +3 +create view v2 (a,b) as select t1.b as a, t2.a as b from t1, t2; +set updatable_views_with_limit=NO; +update v2 set a= 10 where a=200 limit 1; +Got one of the listed errors +set updatable_views_with_limit=DEFAULT; +select * from v3; +a b +10 1 +10 3 +2 1 +2 3 +select * from v2; +a b +100 1 +100 3 +200 1 +200 3 +set @a= 10; +set @b= 100; +prepare stmt1 from "update v3 set a= ? where a=?"; +execute stmt1 using @a,@b; +select * from v3; +a b +10 1 +10 3 +2 1 +2 3 +set @a= 300; +set @b= 10; +execute stmt1 using @a,@b; +select * from v3; +a b +2 1 +2 3 +300 1 +300 3 +deallocate prepare stmt1; +drop view v3,v2; +drop tables t1,t2; +create table t1 (a int, primary key (a), b int); +create table t2 (a int, primary key (a), b int); +insert into t2 values (1000, 2000); +create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2; +insert into v3 values (1,2); +ERROR HY000: Can not insert into join view 'test.v3' without fields list +insert into v3 select * from t2; +ERROR HY000: Can not insert into join view 'test.v3' without fields list +insert into v3(a,b) values (1,2); +ERROR HY000: Can not modify more than one base table through a join view 'test.v3' +insert into v3(a,b) select * from t2; +ERROR HY000: Can not modify more than one base table through a join view 'test.v3' +update v3 set a=1,b=2; +ERROR HY000: Can not modify more than one base table through a join view 'test.v3' +insert into v3(a) values (1); +insert into v3(b) values (10); +insert into v3(a) select a from t2; +insert into v3(b) select b from t2; +ERROR 23000: Column 'a' cannot be null +insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +a b +10 NULL +1000 NULL +10002 NULL +select * from t2; +a b +10 NULL +1000 2000 +delete from v3; +ERROR HY000: Can not delete from join view 'test.v3' +delete v3,t1 from v3,t1; +ERROR HY000: Can not delete from join view 'test.v3' +delete t1,v3 from t1,v3; +ERROR HY000: Can not delete from join view 'test.v3' +delete from t1; +prepare stmt1 from "insert into v3(a) values (?);"; +set @a= 100; +execute stmt1 using @a; +set @a= 300; +execute stmt1 using @a; +deallocate prepare stmt1; +prepare stmt1 from "insert into v3(a) select ?;"; +set @a= 101; +execute stmt1 using @a; +set @a= 301; +execute stmt1 using @a; +deallocate prepare stmt1; +select * from v3; +a b +100 10 +100 1000 +101 10 +101 1000 +300 10 +300 1000 +301 10 +301 1000 +drop view v3; +drop tables t1,t2; +create table t1(f1 int); +create view v1 as select f1 from t1; +select * from v1 where F1 = 1; +f1 +drop view v1; +drop table t1; +create table t1(c1 int); +create table t2(c2 int); +insert into t1 values (1),(2),(3); +insert into t2 values (1); +SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2); +c1 +1 +SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1); +c1 +1 +create view v1 as SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2); +create view v2 as SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1); +select * from v1; +c1 +1 +select * from v2; +c1 +1 +select * from (select c1 from v2) X; +c1 +1 +drop view v2, v1; +drop table t1, t2; +CREATE TABLE t1 (C1 INT, C2 INT); +CREATE TABLE t2 (C2 INT); +CREATE VIEW v1 AS SELECT C2 FROM t2; +CREATE VIEW v2 AS SELECT C1 FROM t1 LEFT OUTER JOIN v1 USING (C2); +SELECT * FROM v2; +C1 +drop view v2, v1; +drop table t1, t2; +create table t1 (col1 char(5),col2 int,col3 int); +insert into t1 values ('one',10,25), ('two',10,50), ('two',10,50), ('one',20,25), ('one',30,25); +create view v1 as select * from t1; +select col1,group_concat(col2,col3) from t1 group by col1; +col1 group_concat(col2,col3) +one 1025,2025,3025 +two 1050,1050 +select col1,group_concat(col2,col3) from v1 group by col1; +col1 group_concat(col2,col3) +one 1025,2025,3025 +two 1050,1050 +drop view v1; +drop table t1; +create table t1 (s1 int, s2 char); +create view v1 as select s1, s2 from t1; +select s2 from v1 vq1 where 2 = (select count(*) from v1 vq2 having vq1.s2 = vq2.s2); +ERROR 42S22: Unknown column 'vq2.s2' in 'having clause' +select s2 from v1 vq1 where 2 = (select count(*) aa from v1 vq2 having vq1.s2 = aa); +s2 +drop view v1; +drop table t1; +CREATE TABLE t1 (a1 int); +CREATE TABLE t2 (a2 int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1(a,b) AS SELECT a1,a2 FROM t1 JOIN t2 ON a1=a2 WHERE a1>1; +SELECT * FROM v1; +a b +2 2 +3 3 +CREATE TABLE t3 SELECT * FROM v1; +SELECT * FROM t3; +a b +2 2 +3 3 +DROP VIEW v1; +DROP TABLE t1,t2,t3; +create table t1 (a int); +create table t2 like t1; +create table t3 like t1; +create view v1 as select t1.a x, t2.a y from t1 join t2 where t1.a=t2.a; +insert into t3 select x from v1; +insert into t2 select x from v1; +drop view v1; +drop table t1,t2,t3; +CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10)); +INSERT INTO t1 VALUES(1,'trudy'); +INSERT INTO t1 VALUES(2,'peter'); +INSERT INTO t1 VALUES(3,'sanja'); +INSERT INTO t1 VALUES(4,'monty'); +INSERT INTO t1 VALUES(5,'david'); +INSERT INTO t1 VALUES(6,'kent'); +INSERT INTO t1 VALUES(7,'carsten'); +INSERT INTO t1 VALUES(8,'ranger'); +INSERT INTO t1 VALUES(10,'matt'); +CREATE TABLE t2 (col1 int, col2 int, col3 char(1)); +INSERT INTO t2 VALUES (1,1,'y'); +INSERT INTO t2 VALUES (1,2,'y'); +INSERT INTO t2 VALUES (2,1,'n'); +INSERT INTO t2 VALUES (3,1,'n'); +INSERT INTO t2 VALUES (4,1,'y'); +INSERT INTO t2 VALUES (4,2,'n'); +INSERT INTO t2 VALUES (4,3,'n'); +INSERT INTO t2 VALUES (6,1,'n'); +INSERT INTO t2 VALUES (8,1,'y'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT a.col1,a.col2,b.col2,b.col3 +FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +10 matt NULL NULL +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +10 matt NULL NULL +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +CREATE VIEW v2 AS SELECT * FROM t2; +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +10 matt NULL NULL +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 +WHERE a.col1 IN (1,5,9) AND +(b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1)); +col1 col2 col2 col3 +1 trudy 2 y +5 david NULL NULL +CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9); +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +5 david NULL NULL +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; +create table t1 as select 1 A union select 2 union select 3; +create table t2 as select * from t1; +create view v1 as select * from t1 where a in (select * from t2); +select * from v1 A, v1 B where A.a = B.a; +A A +1 1 +2 2 +3 3 +create table t3 as select a a,a b from t2; +create view v2 as select * from t3 where +a in (select * from t1) or b in (select * from t2); +select * from v2 A, v2 B where A.a = B.b; +a b a b +1 1 1 1 +2 2 2 2 +3 3 3 3 +drop view v1, v2; +drop table t1, t2, t3; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (4), (2); +CREATE VIEW v1 AS SELECT * FROM t1,t2 WHERE t1.a=t2.b; +SELECT * FROM v1; +a b +2 2 +4 4 +CREATE VIEW v2 AS SELECT * FROM v1; +SELECT * FROM v2; +a b +2 2 +4 4 +DROP VIEW v2,v1; +DROP TABLE t1, t2; +create table t1 (a int); +create view v1 as select sum(a) from t1 group by a; +create procedure p1() +begin +select * from v1; +end// +call p1(); +sum(a) +call p1(); +sum(a) +drop procedure p1; +drop view v1; +drop table t1; +CREATE TABLE t1(a char(2) primary key, b char(2)); +CREATE TABLE t2(a char(2), b char(2), index i(a)); +INSERT INTO t1 VALUES ('a','1'), ('b','2'); +INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6'); +CREATE VIEW v1 AS +SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a; +SELECT d, c FROM v1 ORDER BY d,c; +d c +5 1 +5 2 +6 1 +6 2 +DROP VIEW v1; +DROP TABLE t1, t2; +create table t1 (s1 int); +create view v1 as select sum(distinct s1) from t1; +select * from v1; +sum(distinct s1) +NULL +drop view v1; +create view v1 as select avg(distinct s1) from t1; +select * from v1; +avg(distinct s1) +NULL +drop view v1; +drop table t1; +create view v1 as select cast(1 as decimal); +select * from v1; +cast(1 as decimal) +1 +drop view v1; +create table t1(f1 int); +create table t2(f2 int); +insert into t1 values(1),(2),(3); +insert into t2 values(1),(2),(3); +create view v1 as select * from t1,t2 where f1=f2; +create table t3 (f1 int, f2 int); +insert into t3 select * from v1 order by 1; +select * from t3; +f1 f2 +1 1 +2 2 +3 3 +drop view v1; +drop table t1,t2,t3; +create view v1 as select '\\','\\shazam'; +select * from v1; +\ \shazam +\ \shazam +drop view v1; +create view v1 as select '\'','\shazam'; +select * from v1; +' shazam +' shazam +drop view v1; +create view v1 as select 'k','K'; +select * from v1; +k Name_exp_K +k K +drop view v1; +create table t1 (s1 int); +create view v1 as select s1, 's1' from t1; +select * from v1; +s1 Name_exp_s1 +drop view v1; +create view v1 as select 's1', s1 from t1; +select * from v1; +Name_exp_s1 s1 +drop view v1; +create view v1 as select 's1', s1, 1 as Name_exp_s1 from t1; +select * from v1; +Name_exp_1_s1 s1 Name_exp_s1 +drop view v1; +create view v1 as select 1 as Name_exp_s1, 's1', s1 from t1; +select * from v1; +Name_exp_s1 Name_exp_1_s1 s1 +drop view v1; +create view v1 as select 1 as s1, 's1', 's1' from t1; +select * from v1; +s1 Name_exp_s1 Name_exp_1_s1 +drop view v1; +create view v1 as select 's1', 's1', 1 as s1 from t1; +select * from v1; +Name_exp_1_s1 Name_exp_s1 s1 +drop view v1; +create view v1 as select s1, 's1', 's1' from t1; +select * from v1; +s1 Name_exp_s1 Name_exp_1_s1 +drop view v1; +create view v1 as select 's1', 's1', s1 from t1; +select * from v1; +Name_exp_1_s1 Name_exp_s1 s1 +drop view v1; +create view v1 as select 1 as s1, 's1', s1 from t1; +ERROR 42S21: Duplicate column name 's1' +create view v1 as select 's1', s1, 1 as s1 from t1; +ERROR 42S21: Duplicate column name 's1' +drop table t1; +create view v1(k, K) as select 1,2; +ERROR 42S21: Duplicate column name 'k' +create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t; +select * from v1; +t +01:00 +drop view v1; +create table t1 (a timestamp default now()); +create table t2 (b timestamp default now()); +create view v1 as select a,b,t1.a < now() from t1,t2 where t1.a < now(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,(`t1`.`a` < now()) AS `t1.a < now()` from (`t1` join `t2`) where (`t1`.`a` < now()) utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1, t2; +CREATE TABLE t1 ( a varchar(50) ); +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = CURRENT_USER(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = current_user()) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = VERSION(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = version()) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = DATABASE(); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` = database()) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (col1 time); +CREATE TABLE t2 (col1 time); +CREATE VIEW v1 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1; +CREATE VIEW v2 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; +CREATE VIEW v3 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1; +CREATE VIEW v4 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; +CREATE VIEW v5 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1; +CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; +DROP TABLE t1; +CHECK TABLE v1, v2, v3, v4, v5, v6; +Table Op Msg_type Msg_text +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check error Corrupt +test.v2 check status OK +test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check error Corrupt +test.v4 check status OK +test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check error Corrupt +test.v6 check status OK +drop view v1, v2, v3, v4, v5, v6; +drop table t2; +drop function if exists f1; +drop function if exists f2; +CREATE TABLE t1 (col1 time); +CREATE TABLE t2 (col1 time); +CREATE TABLE t3 (col1 time); +create function f1 () returns int return (select max(col1) from t1); +create function f2 () returns int return (select max(col1) from t2); +CREATE VIEW v1 AS SELECT f1() FROM t3; +CREATE VIEW v2 AS SELECT f2() FROM t3; +CREATE VIEW v3 AS SELECT f1() FROM t3; +CREATE VIEW v4 AS SELECT f2() FROM t3; +CREATE VIEW v5 AS SELECT f1() FROM t3; +CREATE VIEW v6 AS SELECT f2() FROM t3; +drop function f1; +CHECK TABLE v1, v2, v3, v4, v5, v6; +Table Op Msg_type Msg_text +test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v1 check status Operation failed +test.v2 check status OK +test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v3 check status Operation failed +test.v4 check status OK +test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +test.v5 check status Operation failed +test.v6 check status OK +create function f1 () returns int return (select max(col1) from t1); +DROP TABLE t1; +CHECK TABLE v1, v2, v3, v4, v5, v6; +Table Op Msg_type Msg_text +test.v1 check status OK +test.v2 check status OK +test.v3 check status OK +test.v4 check status OK +test.v5 check status OK +test.v6 check status OK +drop function f1; +drop function f2; +drop view v1, v2, v3, v4, v5, v6; +drop table t2,t3; +create table t1 (f1 date); +insert into t1 values ('2005-01-01'),('2005-02-02'); +create view v1 as select * from t1; +select * from v1 where f1='2005.02.02'; +f1 +2005-02-02 +select * from v1 where '2005.02.02'=f1; +f1 +2005-02-02 +drop view v1; +drop table t1; +CREATE VIEW v1 AS SELECT SUBSTRING_INDEX("dkjhgd:kjhdjh", ":", 1); +SELECT * FROM v1; +SUBSTRING_INDEX("dkjhgd:kjhdjh", ":", 1) +dkjhgd +drop view v1; +create table t1 (f59 int, f60 int, f61 int); +insert into t1 values (19,41,32); +create view v1 as select f59, f60 from t1 where f59 in +(select f59 from t1); +update v1 set f60=2345; +ERROR HY000: The target table v1 of the UPDATE is not updatable +update t1 set f60=(select max(f60) from v1); +ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't1'. +drop view v1; +drop table t1; +create table t1 (s1 int); +create view v1 as select var_samp(s1) from t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select var_samp(`t1`.`s1`) AS `var_samp(s1)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +CREATE TABLE t1 (col1 INT NOT NULL, col2 INT NOT NULL); +CREATE VIEW v1 (vcol1) AS SELECT col1 FROM t1; +CREATE VIEW v2 (vcol1) AS SELECT col1 FROM t1 WHERE col2 > 2; +INSERT INTO t1 (col1) VALUES(12); +ERROR HY000: Field 'col2' doesn't have a default value +INSERT INTO v1 (vcol1) VALUES(12); +ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value +INSERT INTO v2 (vcol1) VALUES(12); +ERROR HY000: Field of view 'test.v2' underlying table doesn't have a default value +drop view v2,v1; +drop table t1; +create table t1 (f1 int); +insert into t1 values (1); +create view v1 as select f1 from t1; +select f1 as alias from v1; +alias +1 +drop view v1; +drop table t1; +CREATE TABLE t1 (s1 int, s2 int); +INSERT INTO t1 VALUES (1,2); +CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1; +SELECT * FROM v1; +s1 s2 +2 1 +CREATE PROCEDURE p1 () SELECT * FROM v1; +CALL p1(); +s1 s2 +2 1 +ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1; +CALL p1(); +s1 s2 +1 2 +DROP VIEW v1; +CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1; +CALL p1(); +s1 s2 +2 1 +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +create table t1 (f1 int, f2 int); +create view v1 as select f1 as f3, f2 as f1 from t1; +insert into t1 values (1,3),(2,1),(3,2); +select * from v1 order by f1; +f3 f1 +2 1 +3 2 +1 3 +drop view v1; +drop table t1; +CREATE TABLE t1 (f1 char); +INSERT INTO t1 VALUES ('A'); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES('B'); +SELECT * FROM v1; +f1 +A +B +SELECT * FROM t1; +f1 +A +B +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 ( bug_table_seq INTEGER NOT NULL); +CREATE OR REPLACE VIEW v1 AS SELECT * from t1; +DROP PROCEDURE IF EXISTS p1; +Warnings: +Note 1305 PROCEDURE test.p1 does not exist +CREATE PROCEDURE p1 ( ) +BEGIN +DO (SELECT @next := IFNULL(max(bug_table_seq),0) + 1 FROM v1); +INSERT INTO t1 VALUES (1); +END // +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +CALL p1(); +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; +create table t1(f1 datetime); +insert into t1 values('2005.01.01 12:0:0'); +create view v1 as select f1, subtime(f1, '1:1:1') as sb from t1; +select * from v1; +f1 sb +2005-01-01 12:00:00 2005-01-01 10:58:59 +drop view v1; +drop table t1; +CREATE TABLE t1 ( +aid int PRIMARY KEY, +fn varchar(20) NOT NULL, +ln varchar(20) NOT NULL +); +CREATE TABLE t2 ( +aid int NOT NULL, +pid int NOT NULL +); +INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d'); +INSERT INTO t2 values (1,1), (2,1), (2,2); +CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid; +SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2 +WHERE t1.aid = t2.aid GROUP BY pid; +pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) +1 a b,c d +2 c d +SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid; +pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) +1 a b,c d +2 c d +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255)); +CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2; +INSERT INTO t1 VALUES (2, 'foo2'); +INSERT INTO t1 VALUES (1, 'foo1'); +SELECT * FROM v1; +id f +1 foo1 +2 foo2 +SELECT * FROM v1; +id f +1 foo1 +2 foo2 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (pk int PRIMARY KEY, b int); +CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t3 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t4 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t5 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE VIEW v1 AS +SELECT t1.pk as a FROM t1,t2,t3,t4,t5 +WHERE t1.b IS NULL AND +t1.pk=t2.fk AND t2.pk=t3.fk AND t3.pk=t4.fk AND t4.pk=t5.fk; +SELECT a FROM v1; +a +DROP VIEW v1; +DROP TABLE t1,t2,t3,t4,t5; +create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1; +select * from v1; +f1 +1 +drop view v1; +create table t1(a int); +create procedure p1() create view v1 as select * from t1; +drop table t1; +call p1(); +ERROR 42S02: Table 'test.t1' doesn't exist +call p1(); +ERROR 42S02: Table 'test.t1' doesn't exist +drop procedure p1; +create table t1 (f1 int); +create table t2 (f1 int); +insert into t1 values (1); +insert into t2 values (2); +create view v1 as select * from t1 union select * from t2 union all select * from t2; +select * from v1; +f1 +1 +2 +2 +drop view v1; +drop table t1,t2; +CREATE TEMPORARY TABLE t1 (a int); +CREATE FUNCTION f1 () RETURNS int RETURN (SELECT COUNT(*) FROM t1); +CREATE VIEW v1 AS SELECT f1(); +ERROR HY000: View's SELECT refers to a temporary table 't1' +DROP FUNCTION f1; +DROP TABLE t1; +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +CREATE TABLE t1 (f4 CHAR(5)); +CREATE VIEW v1 AS SELECT * FROM t1; +DESCRIBE v1; +Field Type Null Key Default Extra +f4 char(5) YES NULL +ALTER TABLE t1 CHANGE COLUMN f4 f4x CHAR(5); +DESCRIBE v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP TABLE t1; +DROP VIEW v1; +create table t1 (f1 char); +create view v1 as select strcmp(f1,'a') from t1; +select * from v1; +strcmp(f1,'a') +drop view v1; +drop table t1; +create table t1 (f1 int, f2 int,f3 int); +insert into t1 values (1,10,20),(2,0,0); +create view v1 as select * from t1; +select if(sum(f1)>1,f2,f3) from v1 group by f1; +if(sum(f1)>1,f2,f3) +20 +0 +drop view v1; +drop table t1; +create table t1 ( +r_object_id char(16) NOT NULL, +group_name varchar(32) NOT NULL +) engine = InnoDB; +create table t2 ( +r_object_id char(16) NOT NULL, +i_position int(11) NOT NULL, +users_names varchar(32) default NULL +) Engine = InnoDB; +create view v1 as select r_object_id, group_name from t1; +create view v2 as select r_object_id, i_position, users_names from t2; +create unique index r_object_id on t1(r_object_id); +create index group_name on t1(group_name); +create unique index r_object_id_i_position on t2(r_object_id,i_position); +create index users_names on t2(users_names); +insert into t1 values('120001a080000542','tstgroup1'); +insert into t2 values('120001a080000542',-1, 'guser01'); +insert into t2 values('120001a080000542',-2, 'guser02'); +select v1.r_object_id, v2.users_names from v1, v2 +where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id +order by users_names; +r_object_id users_names +120001a080000542 guser01 +120001a080000542 guser02 +drop view v1, v2; +drop table t1, t2; +create table t1 (s1 int); +create view abc as select * from t1 as abc; +drop table t1; +drop view abc; +create table t1(f1 char(1)); +create view v1 as select * from t1; +select * from (select f1 as f2 from v1) v where v.f2='a'; +f2 +drop view v1; +drop table t1; +create view v1 as SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET'); +select * from v1; +CONVERT_TZ('2004-01-01 12:00:00','GMT','MET') +NULL +drop view v1; +CREATE TABLE t1 (date DATE NOT NULL); +INSERT INTO t1 VALUES ('2005-09-06'); +CREATE VIEW v1 AS SELECT DAYNAME(date) FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select dayname(`t1`.`date`) AS `DAYNAME(date)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v2 AS SELECT DAYOFWEEK(date) FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select dayofweek(`t1`.`date`) AS `DAYOFWEEK(date)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v3 AS SELECT WEEKDAY(date) FROM t1; +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select weekday(`t1`.`date`) AS `WEEKDAY(date)` from `t1` utf8mb4 utf8mb4_0900_ai_ci +SELECT DAYNAME('2005-09-06'); +DAYNAME('2005-09-06') +Tuesday +SELECT DAYNAME(date) FROM t1; +DAYNAME(date) +Tuesday +SELECT * FROM v1; +DAYNAME(date) +Tuesday +SELECT DAYOFWEEK('2005-09-06'); +DAYOFWEEK('2005-09-06') +3 +SELECT DAYOFWEEK(date) FROM t1; +DAYOFWEEK(date) +3 +SELECT * FROM v2; +DAYOFWEEK(date) +3 +SELECT WEEKDAY('2005-09-06'); +WEEKDAY('2005-09-06') +1 +SELECT WEEKDAY(date) FROM t1; +WEEKDAY(date) +1 +SELECT * FROM v3; +WEEKDAY(date) +1 +DROP TABLE t1; +DROP VIEW v1, v2, v3; +CREATE TABLE t1 ( a int, b int ); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +CREATE VIEW v1 AS SELECT a,b FROM t1; +SELECT t1.a FROM t1 GROUP BY t1.a HAVING a > 1; +a +2 +3 +SELECT v1.a FROM v1 GROUP BY v1.a HAVING a > 1; +a +2 +3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 ( a int, b int ); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +CREATE VIEW v1 AS SELECT a,b FROM t1; +SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a > 1; +a +2 +3 +SELECT v1.a FROM v1 GROUP BY v1.a HAVING v1.a > 1; +a +2 +3 +SELECT t_1.a FROM t1 AS t_1 GROUP BY t_1.a HAVING t_1.a IN (1,2,3); +a +1 +2 +3 +SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3); +a +1 +2 +3 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, INDEX(a,b)); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 (a INT); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +INSERT INTO t2 VALUES (1,1),(2,2),(3,3); +INSERT INTO t3 VALUES (1),(2),(3); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +CREATE VIEW v1 AS SELECT t1.* FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b; +CREATE VIEW v2 AS SELECT t3.* FROM t1,t3 WHERE t1.a=t3.a; +EXPLAIN SELECT t1.* FROM t1 JOIN t2 WHERE t1.a=t2.a AND t1.b=t2.b AND t1.a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const # # Using where; Using index +2 SIMPLE t2 NULL ref a a 10 const,test.t1.b # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 1) and (`test`.`t2`.`a` = 1)) +EXPLAIN SELECT * FROM v1 WHERE a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const # # Using where; Using index +1 SIMPLE t2 NULL ref a a 10 const,test.t1.b # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 1) and (`test`.`t2`.`a` = 1)) +EXPLAIN SELECT * FROM v2 WHERE a=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const # # Using index +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t3` where ((`test`.`t1`.`a` = 1) and (`test`.`t3`.`a` = 1)) +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3; +create table t1 (f1 int); +create view v1 as select t1.f1 as '123 +456' from t1; +select * from v1; +123 +456 +drop view v1; +drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values(1,1),(1,2),(1,3); +create view v1 as select f1 ,group_concat(f2 order by f2 asc) from t1 group by f1; +create view v2 as select f1 ,group_concat(f2 order by f2 desc) from t1 group by f1; +select * from v1; +f1 group_concat(f2 order by f2 asc) +1 1,2,3 +select * from v2; +f1 group_concat(f2 order by f2 desc) +1 3,2,1 +drop view v1,v2; +drop table t1; +create table t1 (x int, y int); +create table t2 (x int, y int, z int); +create table t3 (x int, y int, z int); +create table t4 (x int, y int, z int); +create view v1 as +select t1.x +from ( +(t1 join t2 on ((t1.y = t2.y))) +join +(t3 left join t4 on (t3.y = t4.y) and (t3.z = t4.z)) +); +prepare stmt1 from "select count(*) from v1 where x = ?"; +set @parm1=1; +execute stmt1 using @parm1; +count(*) +0 +execute stmt1 using @parm1; +count(*) +0 +drop view v1; +drop table t1,t2,t3,t4; +CREATE TABLE t1(id INT); +CREATE VIEW v1 AS SELECT id FROM t1; +OPTIMIZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +ANALYZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +REPAIR TABLE v1; +Table Op Msg_type Msg_text +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +DROP TABLE t1; +OPTIMIZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 optimize Error 'test.v1' is not BASE TABLE +test.v1 optimize status Operation failed +ANALYZE TABLE v1; +Table Op Msg_type Msg_text +test.v1 analyze Error 'test.v1' is not BASE TABLE +test.v1 analyze status Operation failed +REPAIR TABLE v1; +Table Op Msg_type Msg_text +test.v1 repair Error 'test.v1' is not BASE TABLE +test.v1 repair status Operation failed +DROP VIEW v1; +create definer = current_user() sql security invoker view v1 as select 1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +create definer = current_user sql security invoker view v1 as select 1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +create table t1 (id INT, primary key(id)); +insert into t1 values (1),(2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create view v1 as select * from t1; +explain select id from v1 order by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` order by `test`.`t1`.`id` +drop view v1; +drop table t1; +create table t1(f1 int, f2 int); +insert into t1 values (null, 10), (null,2); +select f1, sum(f2) from t1 group by f1; +f1 sum(f2) +NULL 12 +create view v1 as select * from t1; +select f1, sum(f2) from v1 group by f1; +f1 sum(f2) +NULL 12 +drop view v1; +drop table t1; +drop procedure if exists p1; +create procedure p1 () deterministic +begin +create view v1 as select 1; +end; +// +call p1(); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop procedure p1; +CREATE VIEW v1 AS SELECT 42 AS Meaning; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INTEGER +BEGIN +DECLARE retn INTEGER; +SELECT Meaning FROM v1 INTO retn; +RETURN retn; +END +// +CREATE VIEW v2 AS SELECT f1(); +select * from v2; +f1() +42 +drop view v2,v1; +drop function f1; +create table t1 (id numeric, warehouse_id numeric); +create view v1 as select id from t1; +create view v2 as +select t1.warehouse_id, v1.id as receipt_id +from t1, v1 where t1.id = v1.id; +insert into t1 (id, warehouse_id) values(3, 2); +insert into t1 (id, warehouse_id) values(4, 2); +insert into t1 (id, warehouse_id) values(5, 1); +select v2.receipt_id as alias1, v2.receipt_id as alias2 from v2 +order by v2.receipt_id; +alias1 alias2 +3 3 +4 4 +5 5 +drop view v2, v1; +drop table t1; +CREATE TABLE t1 (a int PRIMARY KEY, b int); +INSERT INTO t1 VALUES (2,20), (3,10), (1,10), (0,30), (5,10); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT MAX(a) FROM t1; +MAX(a) +5 +SELECT MAX(a) FROM v1; +MAX(a) +5 +EXPLAIN SELECT MAX(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` +EXPLAIN SELECT MAX(a) FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` +SELECT MIN(a) FROM t1; +MIN(a) +0 +SELECT MIN(a) FROM v1; +MIN(a) +0 +EXPLAIN SELECT MIN(a) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a`) AS `MIN(a)` from `test`.`t1` +EXPLAIN SELECT MIN(a) FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`a`) AS `MIN(a)` from `test`.`t1` +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (x varchar(10)); +INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT IF(x IS NULL, 'blank', 'not blank') FROM v1 GROUP BY x; +IF(x IS NULL, 'blank', 'not blank') +blank +not blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM t1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1; +x +blank +not blank +not blank +blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS y FROM v1 GROUP BY y; +y +blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +DROP VIEW v1; +DROP TABLE t1; +drop table if exists t1; +drop view if exists v1; +create table t1 (id int); +create view v1 as select * from t1; +drop table t1; +show create view v1; +drop view v1; +// +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id` from `t1` utf8mb4 utf8mb4_0900_ai_ci +create table t1(f1 int, f2 int); +create view v1 as select ta.f1 as a, tb.f1 as b from t1 ta, t1 tb where ta.f1=tb +.f1 and ta.f2=tb.f2; +insert into t1 values(1,1),(2,2); +create view v2 as select * from v1 where a > 1 with local check option; +select * from v2; +a b +2 2 +update v2 set b=3 where a=2; +select * from v2; +a b +3 3 +drop view v2, v1; +drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2); +CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1; +SELECT my_sqrt FROM v1 ORDER BY my_sqrt; +my_sqrt +1 +1.4142135623730951 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY); +CREATE TABLE t2 (id int PRIMARY KEY); +INSERT INTO t1 VALUES (1), (3); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v2 AS SELECT * FROM t2; +SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.id=t2.id; +COUNT(*) +2 +SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id; +id id +1 1 +3 3 +SELECT COUNT(*) FROM t1 LEFT JOIN v2 ON t1.id=v2.id; +COUNT(*) +2 +DROP VIEW v2; +DROP TABLE t1, t2; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, +td date DEFAULT NULL, KEY idx(td)); +INSERT INTO t1 VALUES +(1, '2005-01-01'), (2, '2005-01-02'), (3, '2005-01-02'), +(4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'), +(7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE); +id td +2 2005-01-02 +3 2005-01-02 +4 2005-01-03 +5 2005-01-04 +SELECT * FROM v1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE); +id td +2 2005-01-02 +3 2005-01-02 +4 2005-01-03 +5 2005-01-04 +DROP VIEW v1; +DROP TABLE t1; +create table t1 (a int); +create view v1 as select * from t1; +create view v2 as select * from v1; +drop table t1; +rename table v2 to t1; +select * from v1; +ERROR HY000: `test`.`v1` contains view recursion +drop view t1, v1; +create table t1 (a int); +create function f1() returns int +begin +declare mx int; +select max(a) from t1 into mx; +return mx; +end// +create view v1 as select f1() as a; +create view v2 as select * from v1; +drop table t1; +rename table v2 to t1; +select * from v1; +ERROR HY000: Recursive stored functions and triggers are not allowed. +drop function f1; +drop view t1, v1; +create table t1 (dt datetime); +insert into t1 values (20040101000000), (20050101000000), (20060101000000); +create view v1 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from t1; +select * from v1; +ldt +2004-01-01 03:00:00 +2005-01-01 03:00:00 +2006-01-01 03:00:00 +drop view v1; +create view v1 as select * from t1 where convert_tz(dt, 'UTC', 'Europe/Moscow') >= 20050101000000; +select * from v1; +dt +2005-01-01 00:00:00 +2006-01-01 00:00:00 +create view v2 as select * from v1 where dt < 20060101000000; +select * from v2; +dt +2005-01-01 00:00:00 +drop view v2; +create view v2 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from v1; +select * from v2; +ldt +2005-01-01 03:00:00 +2006-01-01 03:00:00 +drop view v1, v2; +drop table t1; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime); +CREATE VIEW v1 AS +SELECT id, date(d) + INTERVAL TIME_TO_SEC(d) SECOND AS t, COUNT(*) +FROM t1 GROUP BY id, t; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`id` AS `id`,(cast(`t1`.`d` as date) + interval time_to_sec(`t1`.`d`) second) AS `t`,count(0) AS `COUNT(*)` from `t1` group by `t1`.`id`,`t` utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM v1; +id t COUNT(*) +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (i INT, j BIGINT); +INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2); +CREATE VIEW v1 AS SELECT MIN(j) AS j FROM t1; +CREATE VIEW v2 AS SELECT MIN(i) FROM t1 WHERE j = ( SELECT * FROM v1 ); +SELECT * FROM v2; +MIN(i) +1 +DROP VIEW v2, v1; +DROP TABLE t1; +CREATE TABLE t1( +fName varchar(25) NOT NULL, +lName varchar(25) NOT NULL, +DOB date NOT NULL, +test_date date NOT NULL, +uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); +INSERT INTO t1(fName, lName, DOB, test_date) VALUES +('Hank', 'Hill', '1964-09-29', '2007-01-01'), +('Tom', 'Adams', '1908-02-14', '2007-01-01'), +('Homer', 'Simpson', '1968-03-05', '2007-01-01'); +CREATE VIEW v1 AS +SELECT (year(test_date)-year(DOB)) AS Age +FROM t1 HAVING Age < 75; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(`t1`.`test_date`) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) utf8mb4 utf8mb4_0900_ai_ci +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; +Age +43 +39 +SELECT * FROM v1; +Age +43 +39 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx'); +INSERT INTO t1(id) VALUES (1), (2), (3), (4); +INSERT INTO t1 VALUES (5,'yyy'), (6,'yyy'); +SELECT * FROM t1; +id a +1 xxx +2 xxx +3 xxx +4 xxx +5 yyy +6 yyy +CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a; +SELECT * FROM v1; +a m +xxx 1 +yyy 5 +CREATE TABLE t2 SELECT * FROM v1; +INSERT INTO t2(m) VALUES (0); +SELECT * FROM t2; +a m +xxx 1 +yyy 5 +xxx 0 +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (id int PRIMARY KEY, e ENUM('a','b') NOT NULL DEFAULT 'b'); +INSERT INTO t1(id) VALUES (1), (2), (3); +INSERT INTO t1 VALUES (4,'a'); +SELECT * FROM t1; +id e +1 b +2 b +3 b +4 a +CREATE VIEW v1(m, e) AS SELECT MIN(id), e FROM t1 GROUP BY e; +CREATE TABLE t2 SELECT * FROM v1; +SELECT * FROM t2; +m e +1 b +4 a +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT NOT NULL, b INT NULL DEFAULT NULL); +CREATE VIEW v1 AS SELECT a, b FROM t1; +INSERT IGNORE INTO v1 (b) VALUES (2); +Warnings: +Warning 1423 Field of view 'test.v1' underlying table doesn't have a default value +SET SQL_MODE = STRICT_ALL_TABLES; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +INSERT INTO v1 (b) VALUES (4); +ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value +SET SQL_MODE = ''; +SELECT * FROM t1; +a b +0 2 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (firstname text, surname text); +INSERT INTO t1 VALUES +("Bart","Simpson"),("Milhouse","van Houten"),("Montgomery","Burns"); +CREATE VIEW v1 AS SELECT CONCAT(firstname," ",surname) AS name FROM t1; +SELECT CONCAT(LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," ")), +LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," "))) AS f1 +FROM v1; +f1 +BartBart +Milhouse vanMilhouse van +MontgomeryMontgomery +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (i int, j int); +CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1; +DESCRIBE v1; +Field Type Null Key Default Extra +COALESCE(i,j) bigint YES NULL +CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +COALESCE(i,j) int YES NULL +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (s varchar(10)); +INSERT INTO t1 VALUES ('yadda'), ('yady'); +SELECT TRIM(BOTH 'y' FROM s) FROM t1; +TRIM(BOTH 'y' FROM s) +adda +ad +CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1; +SELECT * FROM v1; +TRIM(BOTH 'y' FROM s) +adda +ad +DROP VIEW v1; +SELECT TRIM(LEADING 'y' FROM s) FROM t1; +TRIM(LEADING 'y' FROM s) +adda +ady +CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1; +SELECT * FROM v1; +TRIM(LEADING 'y' FROM s) +adda +ady +DROP VIEW v1; +SELECT TRIM(TRAILING 'y' FROM s) FROM t1; +TRIM(TRAILING 'y' FROM s) +yadda +yad +CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1; +SELECT * FROM v1; +TRIM(TRAILING 'y' FROM s) +yadda +yad +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (x INT, y INT); +CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v1 AS SELECT x, y FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x`,`t1`.`y` AS `y` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (s1 char) charset latin1; +INSERT INTO t1 VALUES ('Z'); +CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1; +CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1; +INSERT INTO v1 (col) VALUES ('b'); +INSERT INTO v2 (col) VALUES ('c'); +SELECT s1 FROM t1; +s1 +Z +b +c +DROP VIEW v1, v2; +DROP TABLE t1; +CREATE TABLE t1 (id INT); +CREATE VIEW v1 AS SELECT id FROM t1; +SHOW TABLES; +Tables_in_test +t1 +v1 +DROP VIEW v2,v1; +ERROR 42S02: Unknown table 'test.v2' +SHOW TABLES; +Tables_in_test +t1 +v1 +DROP VIEW t1,v1; +ERROR HY000: 'test.t1' is not VIEW +SHOW TABLES; +Tables_in_test +t1 +v1 +DROP TABLE t1; +DROP VIEW IF EXISTS v1; +CREATE DATABASE bug21261DB; +USE bug21261DB; +CREATE TABLE t1 (x INT); +CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; +CREATE USER 'user21261'@'localhost'; +GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost'; +GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost'; +CREATE TABLE t2 (y INT); +GRANT SELECT ON t2 TO 'user21261'@'localhost'; +INSERT INTO v1 (x) VALUES (5); +UPDATE v1 SET x=1; +GRANT SELECT ON v1 TO 'user21261'@'localhost'; +GRANT SELECT ON t1 TO 'user21261'@'localhost'; +UPDATE v1,t2 SET x=1 WHERE x=y; +SELECT * FROM t1; +x +1 +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost'; +DROP USER 'user21261'@'localhost'; +DROP VIEW v1; +DROP TABLE t1; +DROP DATABASE bug21261DB; +USE test; +create table t1 (f1 datetime); +create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute)) utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop table t1; +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +CREATE TABLE t1(a INT, b INT); +CREATE DEFINER=1234567890abcdefGHIKL1234567890abcdefGHIKL@localhost +VIEW v1 AS SELECT a FROM t1; +ERROR HY000: String '1234567890abcdefGHIKL1234567890abcdefGHIKL' is too long for user name (should be no longer than 32) +CREATE DEFINER=some_user_name@host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij1234567890X +VIEW v2 AS SELECT b FROM t1; +ERROR HY000: String 'host_1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij12345' is too long for host name (should be no longer than 255) +DROP TABLE t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP VIEW IF EXISTS v1, v2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +INSERT INTO v1 VALUES (0); +RETURN 0; +END | +SELECT f1(); +f1() +0 +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t1; +CREATE FUNCTION f2() RETURNS INT +BEGIN +INSERT INTO v2 VALUES (0); +RETURN 0; +END | +SELECT f2(); +ERROR HY000: The target table v2 of the INSERT is not insertable-into +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP VIEW v1, v2; +DROP TABLE t1; +CREATE TABLE t1 (s1 int); +CREATE VIEW v1 AS SELECT * FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1` from `test`.`t1` +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1` from `test`.`t1` +INSERT INTO t1 VALUES (1), (3), (2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t NULL ALL NULL NULL NULL # # # Using where +2 SUBQUERY t1 NULL ALL NULL NULL NULL # # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`s1` AS `s1` from `test`.`t1` `t` where ((`test`.`t`.`s1` + 1) < (/* select#2 */ select max(`test`.`t1`.`s1`) from `test`.`t1`)) +EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL # # # Using where +2 SUBQUERY t1 NULL ALL NULL NULL NULL # # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1` from `test`.`t1` where ((`test`.`t1`.`s1` + 1) < (/* select#2 */ select max(`test`.`t1`.`s1`) from `test`.`t1`)) +DROP VIEW v1; +DROP TABLE t1; +create table t1 (s1 int); +create view v1 as select s1 as a, s1 as b from t1; +insert into v1 values (1,1); +ERROR HY000: The target table v1 of the INSERT is not insertable-into +update v1 set a = 5; +drop view v1; +drop table t1; +CREATE TABLE t1(pk int PRIMARY KEY); +CREATE TABLE t2(pk int PRIMARY KEY, fk int, ver int, org int); +CREATE ALGORITHM=MERGE VIEW v1 AS +SELECT t1.* +FROM t1 JOIN t2 +ON t2.fk = t1.pk AND +t2.ver = (SELECT MAX(t.ver) FROM t2 t WHERE t.org = t2.org); +SHOW WARNINGS; +Level Code Message +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver` = (select max(`t`.`ver`) from `t2` `t` where (`t`.`org` = `t2`.`org`)))))) utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +DROP TABLE t1, t2; +DROP FUNCTION IF EXISTS f1; +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +CREATE VIEW v1 AS SELECT MAX(i) FROM t1; +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +SET NEW.i = (SELECT * FROM v1) + 1; +INSERT INTO t1 VALUES (1); +CREATE FUNCTION f1() RETURNS INT RETURN (SELECT * FROM v1); +UPDATE t1 SET i= f1(); +DROP FUNCTION f1; +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL); +CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION; +INSERT INTO v1 (val) VALUES (2); +INSERT INTO v1 (val) VALUES (4); +INSERT INTO v1 (val) VALUES (6); +ERROR HY000: CHECK OPTION failed 'test.v1' +UPDATE v1 SET val=6 WHERE id=2; +ERROR HY000: CHECK OPTION failed 'test.v1' +DROP VIEW v1; +DROP TABLE t1; +DROP VIEW IF EXISTS v1, v2; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT); +CREATE VIEW v1 AS SELECT j FROM t1; +CREATE VIEW v2 AS SELECT * FROM t1; +INSERT INTO t1 (j) VALUES (1); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT INTO v1 (j) VALUES (2); +# LAST_INSERT_ID() should not change. +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT INTO v2 (j) VALUES (3); +# LAST_INSERT_ID() should be updated. +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +INSERT INTO v1 (j) SELECT j FROM t1; +# LAST_INSERT_ID() should not change. +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +SELECT * FROM t1; +i j +1 1 +2 2 +3 3 +4 1 +5 2 +6 3 +DROP VIEW v1, v2; +DROP TABLE t1; +CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL; +Warnings: +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select ((0 = 0) * 5) AS `x` utf8mb4 utf8mb4_0900_ai_ci +SELECT !0 * 5 AS x FROM DUAL; +x +5 +Warnings: +Warning 1287 '!' is deprecated and will be removed in a future release. Please use NOT instead +SELECT * FROM v; +x +5 +DROP VIEW v; +DROP VIEW IF EXISTS v1; +CREATE VIEW v1 AS SELECT 'The\ZEnd'; +SELECT * FROM v1; +TheEnd +TheEnd +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 'The\ZEnd' AS `TheEnd` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE TABLE t1 (mydate DATETIME); +INSERT INTO t1 VALUES +('2007-01-01'), ('2007-01-02'), ('2007-01-30'), ('2007-01-31'); +CREATE VIEW v1 AS SELECT mydate from t1; +SELECT * FROM t1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31'; +mydate +2007-01-01 00:00:00 +2007-01-02 00:00:00 +2007-01-30 00:00:00 +2007-01-31 00:00:00 +SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31'; +mydate +2007-01-01 00:00:00 +2007-01-02 00:00:00 +2007-01-30 00:00:00 +2007-01-31 00:00:00 +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +CREATE VIEW v1 AS +SELECT t2.b FROM t1,t2 WHERE t1.a = t2.b WITH CHECK OPTION; +SELECT * FROM v1; +b +1 +2 +UPDATE v1 SET b=3; +ERROR HY000: CHECK OPTION failed 'test.v1' +SELECT * FROM v1; +b +1 +2 +SELECT * FROM t1; +a +1 +2 +SELECT * FROM t2; +b +1 +2 +DROP VIEW v1; +DROP TABLE t1,t2; +create table t1(f1 int, f2 int); +insert into t1 values(1,2),(1,3),(1,1),(2,3),(2,1),(2,2); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select * from t1; +f1 f2 +1 2 +1 3 +1 1 +2 3 +2 1 +2 2 +create view v1 as select * from t1 order by f2; +select * from v1; +f1 f2 +1 1 +2 1 +1 2 +2 2 +1 3 +2 3 +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` order by `test`.`t1`.`f2` +select * from v1 order by f1; +f1 f2 +1 2 +1 3 +1 1 +2 3 +2 1 +2 2 +explain select * from v1 order by f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` order by `test`.`t1`.`f1` +drop view v1; +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL PRIMARY KEY, +country varchar(32), +code int(11) default NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,'ITALY',100),(2,'ITALY',200),(3,'FRANCE',100), (4,'ITALY',100); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT code, COUNT(DISTINCT country) FROM t1 GROUP BY code ORDER BY MAX(id); +code COUNT(DISTINCT country) +200 1 +100 2 +SELECT code, COUNT(DISTINCT country) FROM v1 GROUP BY code ORDER BY MAX(id); +code COUNT(DISTINCT country) +200 1 +100 2 +DROP VIEW v1; +DROP TABLE t1; +DROP VIEW IF EXISTS v1; +SELECT * FROM (SELECT 1) AS t; +1 +1 +CREATE VIEW v1 AS SELECT * FROM (SELECT 1) AS t; +DROP VIEW v1; +# Previously the following would fail. +SELECT * FROM (SELECT 1) AS t; +1 +1 +drop view if exists view_24532_a; +drop view if exists view_24532_b; +drop table if exists table_24532; +create table table_24532 ( +a int, +b bigint, +c int(4), +d bigint(48) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create view view_24532_a as +select +a IS TRUE, +a IS NOT TRUE, +a IS FALSE, +a IS NOT FALSE, +a IS UNKNOWN, +a IS NOT UNKNOWN, +a is NULL, +a IS NOT NULL, +ISNULL(a), +b IS TRUE, +b IS NOT TRUE, +b IS FALSE, +b IS NOT FALSE, +b IS UNKNOWN, +b IS NOT UNKNOWN, +b is NULL, +b IS NOT NULL, +ISNULL(b), +c IS TRUE, +c IS NOT TRUE, +c IS FALSE, +c IS NOT FALSE, +c IS UNKNOWN, +c IS NOT UNKNOWN, +c is NULL, +c IS NOT NULL, +ISNULL(c), +d IS TRUE, +d IS NOT TRUE, +d IS FALSE, +d IS NOT FALSE, +d IS UNKNOWN, +d IS NOT UNKNOWN, +d is NULL, +d IS NOT NULL, +ISNULL(d) +from table_24532; +describe view_24532_a; +Field Type Null Key Default Extra +a IS TRUE int NO 0 +a IS NOT TRUE int NO 0 +a IS FALSE int NO 0 +a IS NOT FALSE int NO 0 +a IS UNKNOWN int NO 0 +a IS NOT UNKNOWN int NO 0 +a is NULL int NO 0 +a IS NOT NULL int NO 0 +ISNULL(a) int NO 0 +b IS TRUE int NO 0 +b IS NOT TRUE int NO 0 +b IS FALSE int NO 0 +b IS NOT FALSE int NO 0 +b IS UNKNOWN int NO 0 +b IS NOT UNKNOWN int NO 0 +b is NULL int NO 0 +b IS NOT NULL int NO 0 +ISNULL(b) int NO 0 +c IS TRUE int NO 0 +c IS NOT TRUE int NO 0 +c IS FALSE int NO 0 +c IS NOT FALSE int NO 0 +c IS UNKNOWN int NO 0 +c IS NOT UNKNOWN int NO 0 +c is NULL int NO 0 +c IS NOT NULL int NO 0 +ISNULL(c) int NO 0 +d IS TRUE int NO 0 +d IS NOT TRUE int NO 0 +d IS FALSE int NO 0 +d IS NOT FALSE int NO 0 +d IS UNKNOWN int NO 0 +d IS NOT UNKNOWN int NO 0 +d is NULL int NO 0 +d IS NOT NULL int NO 0 +ISNULL(d) int NO 0 +create view view_24532_b as +select +a IS TRUE, +if(ifnull(a, 0), 1, 0) as old_istrue, +a IS NOT TRUE, +if(ifnull(a, 0), 0, 1) as old_isnottrue, +a IS FALSE, +if(ifnull(a, 1), 0, 1) as old_isfalse, +a IS NOT FALSE, +if(ifnull(a, 1), 1, 0) as old_isnotfalse +from table_24532; +describe view_24532_b; +Field Type Null Key Default Extra +a IS TRUE int NO 0 +old_istrue int NO 0 +a IS NOT TRUE int NO 0 +old_isnottrue int NO 0 +a IS FALSE int NO 0 +old_isfalse int NO 0 +a IS NOT FALSE int NO 0 +old_isnotfalse int NO 0 +show create view view_24532_b; +View Create View character_set_client collation_connection +view_24532_b CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_24532_b` AS select ((0 <> `table_24532`.`a`) is true) AS `a IS TRUE`,if(ifnull(`table_24532`.`a`,0),1,0) AS `old_istrue`,((0 <> `table_24532`.`a`) is not true) AS `a IS NOT TRUE`,if(ifnull(`table_24532`.`a`,0),0,1) AS `old_isnottrue`,((0 <> `table_24532`.`a`) is false) AS `a IS FALSE`,if(ifnull(`table_24532`.`a`,1),0,1) AS `old_isfalse`,((0 <> `table_24532`.`a`) is not false) AS `a IS NOT FALSE`,if(ifnull(`table_24532`.`a`,1),1,0) AS `old_isnotfalse` from `table_24532` utf8mb4 utf8mb4_0900_ai_ci +insert into table_24532 values (0, 0, 0, 0); +select * from view_24532_b; +a IS TRUE old_istrue a IS NOT TRUE old_isnottrue a IS FALSE old_isfalse a IS NOT FALSE old_isnotfalse +0 0 1 1 1 1 0 0 +update table_24532 set a=1; +select * from view_24532_b; +a IS TRUE old_istrue a IS NOT TRUE old_isnottrue a IS FALSE old_isfalse a IS NOT FALSE old_isnotfalse +1 1 0 0 0 0 1 1 +update table_24532 set a=NULL; +select * from view_24532_b; +a IS TRUE old_istrue a IS NOT TRUE old_isnottrue a IS FALSE old_isfalse a IS NOT FALSE old_isnotfalse +0 0 1 1 0 0 1 1 +drop view view_24532_a; +drop view view_24532_b; +drop table table_24532; +CREATE TABLE t1 ( +lid int NOT NULL PRIMARY KEY, +name char(10) NOT NULL +); +INSERT INTO t1 (lid, name) VALUES +(1, 'YES'), (2, 'NO'); +CREATE TABLE t2 ( +id int NOT NULL PRIMARY KEY, +gid int NOT NULL, +lid int NOT NULL, +dt date +); +CREATE TABLE t3 ( +id int NOT NULL PRIMARY KEY, +gid int NOT NULL, +lid int NOT NULL, +dt date +); +INSERT INTO t2 (id, gid, lid, dt) VALUES +(1, 1, 1, '2007-01-01'),(2, 1, 2, '2007-01-02'), +(3, 2, 2, '2007-02-01'),(4, 2, 1, '2007-02-02'); +INSERT INTO t3 (id, gid, lid, dt) VALUES +(1, 1, 1, '2007-01-01'),(2, 1, 2, '2007-01-02'), +(3, 2, 2, '2007-02-01'),(4, 2, 1, '2007-02-02'); +SELECT DISTINCT t2.gid AS lgid, +(SELECT t1.name FROM t1, t3 +WHERE t1.lid = t3.lid AND t3.gid = t2.gid +ORDER BY t3.dt DESC LIMIT 1 +) as clid +FROM t2; +lgid clid +1 NO +2 YES +CREATE VIEW v1 AS +SELECT DISTINCT t2.gid AS lgid, +(SELECT t1.name FROM t1, t3 +WHERE t1.lid = t3.lid AND t3.gid = t2.gid +ORDER BY t3.dt DESC LIMIT 1 +) as clid +FROM t2; +SELECT * FROM v1; +lgid clid +1 NO +2 YES +DROP VIEW v1; +DROP table t1,t2,t3; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a; +SELECT * FROM t1 UNION SELECT * FROM v1; +a +1 +2 +3 +EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT * FROM v1 UNION SELECT * FROM t1; +a +1 +2 +3 +EXPLAIN SELECT * FROM v1 UNION SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a; +a +1 +2 +3 +EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 UNION t1 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `a` +DROP VIEW v1; +DROP TABLE t1; +CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col; +SELECT * FROM v1; +col +1.23457 +DESCRIBE v1; +Field Type Null Key Default Extra +col decimal(7,5) NO 0.00000 +DROP VIEW v1; +CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1.23456789 as decimal(8,0)) AS `col` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (b INT, c INT DEFAULT 0); +INSERT INTO t1 (a) VALUES (1), (2); +INSERT INTO t2 (b) VALUES (1), (2); +CREATE VIEW v1 AS SELECT t2.b,t2.c FROM t1, t2 +WHERE t1.a=t2.b AND t2.b < 3 WITH CHECK OPTION; +SELECT * FROM v1; +b c +1 0 +2 0 +UPDATE v1 SET c=1 WHERE b=1; +SELECT * FROM v1; +b c +1 1 +2 0 +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int, c int DEFAULT 0); +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t2 (id) VALUES (1); +CREATE VIEW v1 AS +SELECT t2.c FROM t1, t2 +WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION; +UPDATE v1 SET c=1; +DROP VIEW v1; +DROP TABLE t1,t2; +CREATE TABLE t1 (a1 INT, c INT DEFAULT 0); +CREATE TABLE t2 (a2 INT); +CREATE TABLE t3 (a3 INT); +CREATE TABLE t4 (a4 INT); +INSERT INTO t1 (a1) VALUES (1),(2); +INSERT INTO t2 (a2) VALUES (1),(2); +INSERT INTO t3 (a3) VALUES (1),(2); +INSERT INTO t4 (a4) VALUES (1),(2); +CREATE VIEW v1 AS +SELECT t1.a1, t1.c FROM t1 JOIN t2 ON t1.a1=t2.a2 AND t1.c < 3 +WITH CHECK OPTION; +SELECT * FROM v1; +a1 c +1 0 +2 0 +UPDATE v1 SET c=3; +ERROR HY000: CHECK OPTION failed 'test.v1' +PREPARE t FROM 'UPDATE v1 SET c=3'; +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v1' +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v1' +INSERT INTO v1(a1, c) VALUES (3, 3); +ERROR HY000: CHECK OPTION failed 'test.v1' +UPDATE v1 SET c=1 WHERE a1=1; +SELECT * FROM v1; +a1 c +1 1 +2 0 +SELECT * FROM t1; +a1 c +1 1 +2 0 +CREATE VIEW v2 AS SELECT t1.a1, t1.c +FROM (t1 JOIN t2 ON t1.a1=t2.a2 AND t1.c < 3) +JOIN (t3 JOIN t4 ON t3.a3=t4.a4) +ON t2.a2=t3.a3 WITH CHECK OPTION; +SELECT * FROM v2; +a1 c +1 1 +2 0 +UPDATE v2 SET c=3; +ERROR HY000: CHECK OPTION failed 'test.v2' +PREPARE t FROM 'UPDATE v2 SET c=3'; +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v2' +EXECUTE t; +ERROR HY000: CHECK OPTION failed 'test.v2' +INSERT INTO v2(a1, c) VALUES (3, 3); +ERROR HY000: CHECK OPTION failed 'test.v2' +UPDATE v2 SET c=2 WHERE a1=1; +SELECT * FROM v2; +a1 c +1 2 +2 0 +SELECT * FROM t1; +a1 c +1 2 +2 0 +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,2), (2,2), (1,3), (1,2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT a, b+1 as b FROM t1; +SELECT b, SUM(a) FROM v1 WHERE b=3 GROUP BY b; +b SUM(a) +3 4 +EXPLAIN SELECT b, SUM(a) FROM v1 WHERE b=3 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`b` + 1) AS `b`,sum(`test`.`t1`.`a`) AS `SUM(a)` from `test`.`t1` where ((`test`.`t1`.`b` + 1) = 3) group by (`test`.`t1`.`b` + 1) +SELECT a, SUM(b) FROM v1 WHERE b=3 GROUP BY a; +a SUM(b) +1 6 +2 3 +EXPLAIN SELECT a, SUM(b) FROM v1 WHERE b=3 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum((`test`.`t1`.`b` + 1)) AS `SUM(b)` from `test`.`t1` where ((`test`.`t1`.`b` + 1) = 3) group by `test`.`t1`.`a` +SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a; +a SUM(b) +1 10 +EXPLAIN SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum((`test`.`t1`.`b` + 1)) AS `SUM(b)` from `test`.`t1` where (`test`.`t1`.`a` = 1) group by `test`.`t1`.`a` +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 ( +person_id int NOT NULL PRIMARY KEY, +username varchar(40) default NULL, +status_flg char(1) NOT NULL default 'A' +); +CREATE TABLE t2 ( +person_role_id int NOT NULL auto_increment PRIMARY KEY, +role_id int NOT NULL, +person_id int NOT NULL, +INDEX idx_person_id (person_id), +INDEX idx_role_id (role_id) +); +CREATE TABLE t3 ( +role_id int NOT NULL auto_increment PRIMARY KEY, +role_name varchar(100) default NULL, +app_name varchar(40) NOT NULL, +INDEX idx_app_name(app_name) +); +CREATE VIEW v1 AS +SELECT profile.person_id AS person_id +FROM t1 profile, t2 userrole, t3 `role` + WHERE userrole.person_id = profile.person_id AND +role.role_id = userrole.role_id AND +profile.status_flg = 'A' + ORDER BY profile.person_id,role.app_name,role.role_name; +INSERT INTO t1 VALUES +(6,'Sw','A'), (-1136332546,'ols','e'), (0,' *\n','0'), +(-717462680,'ENTS Ta','0'), (-904346964,'ndard SQL\n','0'); +INSERT INTO t2 VALUES +(1,3,6),(2,4,7),(3,5,8),(4,6,9),(5,1,6),(6,1,7),(7,1,8),(8,1,9),(9,1,10); +INSERT INTO t3 VALUES +(1,'NUCANS_APP_USER','NUCANSAPP'),(2,'NUCANS_TRGAPP_USER','NUCANSAPP'), +(3,'IA_INTAKE_COORDINATOR','IACANS'),(4,'IA_SCREENER','IACANS'), +(5,'IA_SUPERVISOR','IACANS'),(6,'IA_READONLY','IACANS'), +(7,'SOC_USER','SOCCANS'),(8,'CAYIT_USER','CAYITCANS'), +(9,'RTOS_DCFSPOS_SUPERVISOR','RTOS'); +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE profile NULL const PRIMARY PRIMARY 4 const # # Using temporary; Using filesort +1 SIMPLE userrole NULL ref idx_person_id,idx_role_id idx_person_id 4 const # # NULL +1 SIMPLE role NULL eq_ref PRIMARY PRIMARY 4 test.userrole.role_id # # NULL +Warnings: +Note 1003 /* select#1 */ select '6' AS `a`,'6' AS `b` from `test`.`t1` `profile` join `test`.`t2` `userrole` join `test`.`t3` `role` where ((`test`.`role`.`role_id` = `test`.`userrole`.`role_id`) and (`test`.`userrole`.`person_id` = 6)) order by '6',`test`.`role`.`app_name`,`test`.`role`.`role_name` +SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6; +a b +6 6 +6 6 +DROP VIEW v1; +DROP TABLE t1,t2,t3; +create table t1 (i int); +insert into t1 values (1), (2), (1), (3), (2), (4); +create view v1 as select distinct i from t1; +select * from v1; +i +1 +2 +3 +4 +select table_name, is_updatable from information_schema.views +where table_name = 'v1'; +TABLE_NAME IS_UPDATABLE +v1 NO +drop view v1; +drop table t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1 USE KEY(non_existant); +ERROR 42000: Key 'non_existant' doesn't exist in table 'v1' +SELECT * FROM v1 FORCE KEY(non_existant); +ERROR 42000: Key 'non_existant' doesn't exist in table 'v1' +SELECT * FROM v1 IGNORE KEY(non_existant); +ERROR 42000: Key 'non_existant' doesn't exist in table 'v1' +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0, +PRIMARY KEY(a), KEY (b)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY) FORCE INDEX (`b`) order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (PRIMARY) FORCE INDEX (`b`) order by `test`.`t1`.`a` +CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT * FROM v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () order by `test`.`t1`.`a` +CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a; +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a` utf8mb4 utf8mb4_0900_ai_ci +EXPLAIN SELECT * FROM v3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` IGNORE INDEX (`b`) order by `test`.`t1`.`a` +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; +# +# Bug#29477 Not all fields of the target table were checked to have +# a default value when inserting into a view. +# +create table t1(f1 int, f2 int not null); +create view v1 as select f1 from t1; +insert into v1 values(1); +Warnings: +Warning 1423 Field of view 'test.v1' underlying table doesn't have a default value +set @old_mode=@@sql_mode; +set @@sql_mode=traditional; +insert into v1 values(1); +ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value +set @@sql_mode=@old_mode; +drop view v1; +drop table t1; +create table t1 (a int, key(a)); +create table t2 (c int); +create view v1 as select a b from t1; +create view v2 as select 1 a from t2, v1 where c in +(select 1 from t1 where b = a); +insert into t1 values (1), (1); +insert into t2 values (1), (1); +prepare stmt from "select * from v2 where a = 1"; +execute stmt; +a +1 +1 +1 +1 +drop view v1, v2; +drop table t1, t2; +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT p.a AS a FROM t1 p, t1 q; +INSERT INTO t1 VALUES (1), (1); +SELECT MAX(a), COUNT(DISTINCT a) FROM v1 GROUP BY a; +MAX(a) COUNT(DISTINCT a) +1 1 +DROP VIEW v1; +DROP TABLE t1; +# ----------------------------------------------------------------- +# -- Bug#34337 Server crash when Altering a view using a table name. +# ----------------------------------------------------------------- + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1(c1 INT); + +SELECT * FROM t1; +c1 +ALTER ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW t1 (c2) AS SELECT (1); +ERROR HY000: 'test.t1' is not VIEW + +DROP TABLE t1; + +# -- End of test case for Bug#34337. + +# ----------------------------------------------------------------- +# -- Bug#35193 VIEW query is rewritten without "FROM DUAL", +# -- causing syntax error +# ----------------------------------------------------------------- + +CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE 1; + +SELECT * FROM v1; +1 +1 +SHOW CREATE TABLE v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` from DUAL where (0 <> 1) utf8mb4 utf8mb4_0900_ai_ci + +DROP VIEW v1; + +# -- End of test case for Bug#35193. + +CREATE VIEW v1 AS SELECT 1; +DROP VIEW v1; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, INDEX (c2)); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +SELECT * FROM t1 USE INDEX (PRIMARY) WHERE c1=2; +c1 c2 +2 2 +SELECT * FROM t1 USE INDEX (c2) WHERE c2=2; +c1 c2 +2 2 +CREATE VIEW v1 AS SELECT c1, c2 FROM t1; +SHOW INDEX FROM v1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +SELECT * FROM v1 USE INDEX (PRIMARY) WHERE c1=2; +ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1' +SELECT * FROM v1 FORCE INDEX (PRIMARY) WHERE c1=2; +ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1' +SELECT * FROM v1 IGNORE INDEX (PRIMARY) WHERE c1=2; +ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1' +SELECT * FROM v1 USE INDEX (c2) WHERE c2=2; +ERROR 42000: Key 'c2' doesn't exist in table 'v1' +SELECT * FROM v1 FORCE INDEX (c2) WHERE c2=2; +ERROR 42000: Key 'c2' doesn't exist in table 'v1' +SELECT * FROM v1 IGNORE INDEX (c2) WHERE c2=2; +ERROR 42000: Key 'c2' doesn't exist in table 'v1' +DROP VIEW v1; +DROP TABLE t1; +# +# Bug #45806 crash when replacing into a view with a join! +# +CREATE TABLE t1(a INT UNIQUE); +CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a; +INSERT INTO t1 VALUES (1), (2); +REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v1' +SELECT * FROM v1; +a +1 +1 +2 +2 +REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v1' +SELECT * FROM v1; +a +1 +1 +2 +2 +DELETE FROM t1 WHERE a=3; +INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v1`.`a`= 1; +SELECT * FROM v1; +a +1 +1 +2 +2 +CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a; +REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v2' +SELECT * FROM v2; +a +1 +1 +1 +1 +2 +2 +2 +2 +REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c; +ERROR HY000: Can not delete from join view 'test.v2' +SELECT * FROM v2; +a +1 +1 +1 +1 +2 +2 +2 +2 +INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v2`.`a`= 1; +SELECT * FROM v2; +a +1 +1 +1 +1 +2 +2 +2 +2 +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t1; +# -- End of test case for Bug#45806 +# ----------------------------------------------------------------- +# -- Bug#40825: Error 1356 while selecting from a view +# -- with a "HAVING" clause though query works +# ----------------------------------------------------------------- + +CREATE TABLE t1 (c INT); + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`view_column`) AS select `t1`.`c` AS `alias` from `t1` having (0 <> `alias`) utf8mb4 utf8mb4_0900_ai_ci +SELECT * FROM v1; +view_column + +DROP VIEW v1; +DROP TABLE t1; + +# -- End of test case for Bug#40825 + +# ----------------------------------------------------------------- +# -- End of 5.0 tests. +# ----------------------------------------------------------------- +DROP DATABASE IF EXISTS `d-1`; +CREATE DATABASE `d-1`; +USE `d-1`; +CREATE TABLE `t-1` (c1 INT); +CREATE VIEW `v-1` AS SELECT c1 FROM `t-1`; +SHOW TABLES; +Tables_in_d-1 +t-1 +v-1 +RENAME TABLE `t-1` TO `t-2`; +RENAME TABLE `v-1` TO `v-2`; +SHOW TABLES; +Tables_in_d-1 +t-2 +v-2 +DROP TABLE `t-2`; +DROP VIEW `v-2`; +DROP DATABASE `d-1`; +USE test; + +# +# Bug#26676 VIEW using old table schema in a session. +# + +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 2), (3, 4); + +SELECT * FROM t1; +c1 c2 +1 2 +3 4 + +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT * FROM v1; +c1 c2 +1 2 +3 4 + +ALTER TABLE t1 ADD COLUMN c3 INT AFTER c2; + +SELECT * FROM t1; +c1 c2 c3 +1 2 NULL +3 4 NULL + +SELECT * FROM v1; +c1 c2 +1 2 +3 4 + +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` utf8mb4 utf8mb4_0900_ai_ci + +DROP VIEW v1; +DROP TABLE t1; + +# End of test case for Bug#26676. + +# ----------------------------------------------------------------- +# -- Bug#32538 View definition picks up character set, but not collation +# ----------------------------------------------------------------- + +DROP VIEW IF EXISTS v1; + +SET collation_connection = latin1_general_ci; +CREATE VIEW v1 AS SELECT _latin1 'text1' AS c1, 'text2' AS c2; + +SELECT COLLATION(c1), COLLATION(c2) FROM v1; +COLLATION(c1) COLLATION(c2) +latin1_swedish_ci latin1_general_ci + +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'text1' AS `c1`,'text2' AS `c2` utf8mb4 latin1_general_ci + +SELECT * FROM v1 WHERE c1 = 'text1'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin1_general_ci,COERCIBLE) for operation '=' + +SELECT * FROM v1 WHERE c2 = 'text2'; +c1 c2 +text1 text2 + +use test; +SET names latin1; + +SELECT COLLATION(c1), COLLATION(c2) FROM v1; +COLLATION(c1) COLLATION(c2) +latin1_swedish_ci latin1_general_ci + +SELECT * FROM v1 WHERE c1 = 'text1'; +c1 c2 +text1 text2 + +SELECT * FROM v1 WHERE c2 = 'text2'; +ERROR HY000: Illegal mix of collations (latin1_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation '=' + +DROP VIEW v1; +SET NAMES DEFAULT; + +# -- End of test case for Bug#32538. + +drop view if exists a; +drop procedure if exists p; +create procedure p() +begin +declare continue handler for sqlexception begin end; +create view a as select 1; +end| +call p(); +call p(); +drop view a; +drop procedure p; +# +# Bug #44860: ALTER TABLE on view crashes server +# +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +ALTER TABLE v1; +ERROR HY000: 'test.v1' is not BASE TABLE +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (); +CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE +ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' ))); +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817 +# +CREATE TABLE t1 (a CHAR(1) CHARSET latin1, b CHAR(1) CHARSET utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE VIEW v1 AS SELECT 1 from t1 +WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1')); +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846 +# +CREATE TABLE t1(a int); +CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY +SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1))); +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#57352 valgrind warnings when creating view +# +CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f; +DROP VIEW v1; +# +# Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY +# +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a; +SELECT * FROM v1; +a +DROP VIEW v1; +DROP TABLE t1; +# ----------------------------------------------------------------- +# -- End of 5.1 tests. +# ----------------------------------------------------------------- +drop table if exists t_9801; +drop view if exists v_9801; +create table t_9801 (s1 int); +create view v_9801 as +select sum(s1) from t_9801 with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +create view v_9801 as +select sum(s1) from t_9801 group by s1 with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +create view v_9801 as +select sum(s1) from t_9801 group by s1 with rollup with check option; +ERROR HY000: CHECK OPTION on non-updatable view 'test.v_9801' +drop table t_9801; +# +# Bug #47335 assert in get_table_share +# +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +CREATE TEMPORARY TABLE t1 (id INT); +ALTER VIEW t1 AS SELECT 1 AS f1; +ERROR 42S02: Table 'test.t1' doesn't exist +DROP TABLE t1; +CREATE VIEW v1 AS SELECT 1 AS f1; +CREATE TEMPORARY TABLE v1 (id INT); +ALTER VIEW v1 AS SELECT 2 AS f1; +DROP TABLE v1; +SELECT * FROM v1; +f1 +2 +DROP VIEW v1; +# +# Bug #47635 assert in start_waiting_global_read_lock +# during CREATE VIEW +# +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS t2; +CREATE TABLE t1 (f1 integer); +CREATE TEMPORARY TABLE IF NOT EXISTS t1 (f1 integer); +CREATE TEMPORARY TABLE t2 (f1 integer); +DROP TABLE t1; +FLUSH TABLES WITH READ LOCK; +CREATE VIEW t2 AS SELECT * FROM t1; +ERROR HY000: Can't execute the query because you have a conflicting read lock +UNLOCK TABLES; +DROP TABLE t1, t2; +# +# Bug#48315 Metadata lock is not taken for merged views that +# use an INFORMATION_SCHEMA table +# +DROP VIEW IF EXISTS v1; +DROP PROCEDURE IF EXISTS p1; +# Connection default +CREATE VIEW v1 AS SELECT schema_name FROM information_schema.schemata; +CREATE PROCEDURE p1() SELECT COUNT(*), GET_LOCK('blocker', 100) FROM v1; +# CALL p1() so the view is merged. +CALL p1(); +SELECT RELEASE_LOCK('blocker'); +RELEASE_LOCK('blocker') +1 +# Connection 3 +SELECT GET_LOCK('blocker', 100); +GET_LOCK('blocker', 100) +1 +# Connection default +# Try to CALL p1() again, this time it should block for t1. +# Sending: +CALL p1(); +# Connection 2 +# ... then try to drop the view. This should block. +# Sending: +DROP VIEW v1; +# Connection 3 +# Now allow CALL p1() to complete +SELECT RELEASE_LOCK('blocker'); +RELEASE_LOCK('blocker') +1 +# Connection default +# Reaping: CALL p1() +SELECT RELEASE_LOCK('blocker'); +RELEASE_LOCK('blocker') +1 +# Connection 2 +# Reaping: DROP VIEW v1 +# Connection default +DROP PROCEDURE p1; +# +# Bug#11766440 59546: Assertion m_sp == __null fails in +# Item_func_sp::init_result_field with functions +# +CREATE TABLE t1 (a INT); +CREATE FUNCTION f1 () RETURNS INTEGER RETURN 1; +CREATE FUNCTION f2 (i INTEGER) RETURNS INTEGER RETURN 1; +CREATE VIEW v1 AS SELECT f1() AS a FROM t1; +CREATE VIEW v2 AS SELECT f2(a) AS a FROM v1; +DROP FUNCTION f1; +SELECT f2(a) FROM v2; +ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v2; +DROP VIEW v1; +DROP FUNCTION f2; +DROP TABLE t1; +# +# Bug#13418197: ASSERTION `(*TABLES)->REGINFO.LOCK_TYPE >= +# TL_READ' FAILED | MYSQL_LOCK_TABLES +# +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (a INT) engine=InnoDB; +CREATE VIEW t1 AS SELECT 1; +DROP VIEW t1; +DROP TEMPORARY TABLE t1; +# +# Bug#13601606: FAILED VIEW CREATION ERROR MESSAGE (FOR DB NOT PRESENT) +# NEEDS BIG IMPROVEMENT +# +DROP DATABASE IF EXISTS nodb; +CREATE VIEW nodb.a AS SELECT 1; +ERROR 42000: Unknown database 'nodb' +# +# Bug#13633549 HANDLE_FATAL_SIGNAL IN +# TEST_IF_SKIP_SORT_ORDER/CREATE_SORT_INDEX +# +CREATE TABLE t1 ( +pk INT AUTO_INCREMENT, +c_int_key INT, +PRIMARY KEY (pk), +KEY (c_int_key) +) +ENGINE=innodb; +CREATE VIEW v_t1 AS SELECT * FROM t1; +CREATE TABLE t2 ( +pk INT auto_increment, +c_varchar_600_x VARCHAR(600), +c_int_key INT, +c_varchar_600_y VARCHAR(600), +c_varchar_600_z VARCHAR(600), +PRIMARY KEY (pk), +KEY (c_int_key) +) +ENGINE=innodb; +CREATE VIEW v_t2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES +( +NULL, +repeat('x', 600), +3, +repeat('y', 600), +repeat('z', 600) +); +SELECT a1.pk AS f1 +FROM v_t1 AS a1 LEFT JOIN v_t2 AS a2 ON a1.pk=a2.c_int_key +WHERE +a1.pk > 8 +OR ((a1.pk BETWEEN 9 AND 13) AND a1.pk = 90) +ORDER BY f1 ; +f1 +DROP TABLE t1, t2; +DROP VIEW v_t1, v_t2; +# +# Bug#13783777 CONSTANT PROPAGATION IS WRONG FOR +# DISJUNCTIVE PREDICATES IN VIEWS +# +CREATE TABLE t1 ( +pk INTEGER, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1), (2); +CREATE VIEW v_t1 AS SELECT * FROM t1; +SELECT pk +FROM t1 +WHERE +pk > 8 +OR ((pk BETWEEN 9 AND 13) AND pk = 90) +; +pk +SELECT pk +FROM v_t1 +WHERE +pk > 8 +OR ((pk BETWEEN 9 AND 13) AND pk = 90) +; +pk +DROP VIEW v_t1; +DROP TABLE t1; +# +# WL#5275 Process subqueries in FROM clause in the same way as view +# +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER, b INTEGER); +INSERT INTO t1 VALUES(1, 10), (2, 20); +INSERT INTO t2 VALUES(1, 100), (2, 200); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v2_sj AS SELECT * FROM t2 +WHERE a IN (SELECT a FROM t1); +CREATE VIEW v12_1 AS SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a); +CREATE VIEW v12_2 AS SELECT t1.a, t2.b FROM t1 JOIN t2 USING (a); +CREATE VIEW v12_3 AS SELECT t2.a, t2.b FROM t1 JOIN t2 USING (a) +WHERE t1.b > 15; +CREATE VIEW vu_1 AS SELECT * FROM t2 UNION SELECT * FROM t2; +CREATE VIEW vu_2 AS SELECT * FROM t2 UNION ALL SELECT * FROM t2; +CREATE VIEW vd_1 AS SELECT DISTINCT a, b FROM t2; +CREATE VIEW va_1 AS SELECT SUM(a) AS a, SUM(b) AS b FROM t2; +CREATE VIEW vg_1 AS SELECT a, SUM(b) AS b FROM t2 GROUP BY a; +CREATE VIEW vh_1 AS SELECT 1 AS a FROM t2 HAVING COUNT(*) > 1; +CREATE VIEW vl_1 AS SELECT * FROM t2 LIMIT 1; +CREATE VIEW vlo_1 AS SELECT * FROM t2 LIMIT 2 OFFSET 1; +CREATE VIEW vrow AS SELECT 1 AS a; +CREATE VIEW vo_1 AS SELECT * FROM t2 ORDER BY a; +CREATE VIEW vo_2 AS SELECT * FROM t2 ORDER BY a DESC; +CREATE VIEW vx AS SELECT a, (SELECT b) AS b FROM t2; +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +SELECT * +FROM t1 JOIN v2 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN v2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1, v2 AS dt WHERE t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1, v2 AS dt WHERE t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN v2 AS dt ON t1.a=dt.a; +a b a b a b +1 10 1 100 1 100 +2 20 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 ON t1.a=t2.a) JOIN v2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN v12_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN v12_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_2 AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN v12_1 AS dt2 +ON dt1.a=dt2.a; +a b b a b a b +1 10 100 1 100 1 100 +2 20 200 2 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_2 AS dt1 +ON t1.a=dt1.a AND t2.b=dt1.b +JOIN v12_1 AS dt2 +ON dt1.a=dt2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN v12_3 AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN v12_3 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` > 15)) +SELECT * +FROM t1 JOIN v2_sj AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN v2_sj AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; FirstMatch(t2); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`)) +SELECT * +FROM t1 JOIN vu_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vu_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +NULL UNION RESULT NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vu_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vu_2 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +1 10 1 100 +2 20 2 200 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vu_2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +3 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vu_2` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vd_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vd_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vd_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN va_1 AS dt ON t1.a=dt.a; +a b a b +explain SELECT * +FROM t1 JOIN va_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'3' AS `a`,'300' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '3') +SELECT * +FROM t1 JOIN vg_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vg_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vg_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vh_1 AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN vh_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN vl_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +explain SELECT * +FROM t1 JOIN vl_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a`,'100' AS `b` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM t1 JOIN vlo_1 AS dt ON t1.a=dt.a; +a b a b +2 20 2 200 +explain SELECT * +FROM t1 JOIN vlo_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`vlo_1` `dt` where (`test`.`dt`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vrow AS dt ON t1.a=dt.a; +a b a +1 10 1 +explain SELECT * +FROM t1 JOIN vrow AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED NULL NULL NULL NULL NULL NULL NULL # # No tables used +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'1' AS `a` from `test`.`t1` where (`test`.`t1`.`a` = '1') +SELECT * +FROM vo_1 AS dt; +a b +1 100 +2 200 +explain SELECT * +FROM vo_1 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` +SELECT * +FROM vo_2 AS dt; +a b +2 200 +1 100 +explain SELECT * +FROM vo_2 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` desc +SELECT * +FROM vo_1 AS dt +WHERE dt.a > 0; +a b +1 100 +2 200 +explain SELECT * +FROM vo_1 AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` +SELECT * +FROM vo_2 AS dt +WHERE dt.a > 0; +a b +2 200 +1 100 +explain SELECT * +FROM vo_2 AS dt +WHERE dt.a > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 0) order by `test`.`t2`.`a` desc +SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SELECT dt.a, COUNT(*) +FROM vo_1 AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM vo_1 AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT dt.a, COUNT(*) +FROM vo_2 AS dt +GROUP BY dt.a; +a COUNT(*) +1 1 +2 1 +explain SELECT dt.a, COUNT(*) +FROM vo_2 AS dt +GROUP BY dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,count(0) AS `COUNT(*)` from `test`.`t2` group by `test`.`t2`.`a` +SELECT COUNT(*) +FROM vo_1 AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM vo_1 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT COUNT(*) +FROM vo_2 AS dt; +COUNT(*) +2 +explain SELECT COUNT(*) +FROM vo_2 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` +SELECT DISTINCT * +FROM vo_1 AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM vo_1 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT DISTINCT * +FROM vo_2 AS dt; +a b +1 100 +2 200 +explain SELECT DISTINCT * +FROM vo_2 AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_1 AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a +ORDER BY t1.b; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vo_2 AS dt ON t1.a=dt.a +ORDER BY t1.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`b` +SELECT * +FROM t1 JOIN vx AS dt ON t1.a=dt.a; +a b a b +1 10 1 100 +2 20 2 200 +explain SELECT * +FROM t1 JOIN vx AS dt ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 +Note 1249 Select 3 was reduced during optimization +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +1 PRIMARY NULL ref 5 test.t1.a # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`dt`.`a` AS `a`,`test`.`dt`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`v12_1` `dt` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`dt`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch="derived_merge=on"; +SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +a b b a b +1 10 100 1 100 +2 20 200 2 200 +explain SELECT * +FROM (t1 JOIN t2 USING (a)) +JOIN v12_1 AS dt +ON t1.a=dt.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`)) +SET @@optimizer_switch= @optimizer_switch_saved; +DROP VIEW v2, v2_sj, v12_1, v12_2, v12_3; +DROP VIEW vu_1, vu_2, vd_1, va_1, vg_1, vh_1, vl_1; +DROP VIEW vlo_1, vrow, vo_1, vo_2, vx; +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER); +INSERT INTO t1 VALUES +(1, 10), +(2, 20), (2, 21), +(3, NULL), +(4, 40), (4, 41), (4, 42), (4, 43), (4, 44); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (NULL); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t2) AS dt; +SELECT * FROM v1; +a +1 +2 +3 +4 +5 +NULL +SELECT * FROM (SELECT * FROM t2) AS dt; +a +1 +2 +3 +4 +5 +NULL +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +explain SELECT * FROM (SELECT * FROM t2) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 WHERE b=a*10) AS dt; +SELECT * FROM v1; +a b +1 10 +2 20 +4 40 +SELECT * FROM (SELECT * FROM t1 WHERE b=a*10) AS dt; +a b +1 10 +2 20 +4 40 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = (`test`.`t1`.`a` * 10)) +explain SELECT * FROM (SELECT * FROM t1 WHERE b=a*10) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = (`test`.`t1`.`a` * 10)) +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, SUM(b) AS s, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY a) AS dt; +SELECT * FROM v1; +a s c +1 10 1 +2 41 2 +3 NULL 1 +4 210 5 +SELECT * FROM (SELECT a, SUM(b) AS s, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY a) AS dt; +a s c +1 10 1 +2 41 2 +3 NULL 1 +4 210 5 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`s` AS `s`,`dt`.`c` AS `c` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `s`,count(0) AS `c` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a`) `dt` +explain SELECT * FROM (SELECT a, SUM(b) AS s, COUNT(*) AS c FROM t1 GROUP BY a ORDER BY a) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`s` AS `s`,`dt`.`c` AS `c` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `s`,count(0) AS `c` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a`) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT DISTINCT a FROM t1) AS dt; +SELECT * FROM v1; +a +1 +2 +3 +4 +SELECT * FROM (SELECT DISTINCT a FROM t1) AS dt; +a +1 +2 +3 +4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#3 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +explain SELECT * FROM (SELECT DISTINCT a FROM t1) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 LIMIT 3 OFFSET 3) AS dt; +SELECT * FROM v1; +a b +3 NULL +4 40 +4 41 +SELECT * FROM (SELECT * FROM t1 LIMIT 3 OFFSET 3) AS dt; +a b +3 NULL +4 40 +4 41 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`b` AS `b` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` limit 3,3) `dt` +explain SELECT * FROM (SELECT * FROM t1 LIMIT 3 OFFSET 3) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` limit 3,3) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT DISTINCT a FROM t1 UNION ALL SELECT a FROM t2) AS dt; +SELECT * FROM v1; +a +1 +2 +3 +4 +1 +2 +3 +4 +5 +NULL +SELECT * FROM (SELECT DISTINCT a FROM t1 UNION ALL SELECT a FROM t2) AS dt; +a +1 +2 +3 +4 +1 +2 +3 +4 +5 +NULL +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +4 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#3 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` union all /* select#4 */ select `test`.`t2`.`a` AS `a` from `test`.`t2`) `dt` +explain SELECT * FROM (SELECT DISTINCT a FROM t1 UNION ALL SELECT a FROM t2) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 UNION t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` union all /* select#3 */ select `test`.`t2`.`a` AS `a` from `test`.`t2`) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 WHERE (SELECT a FROM t1 LIMIT 1) = b/10) AS dt; +SELECT * FROM v1; +a b +1 10 +SELECT * FROM (SELECT * FROM t1 WHERE (SELECT a FROM t1 LIMIT 1) = b/10) AS dt; +a b +1 10 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +4 SUBQUERY t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((/* select#4 */ select `test`.`t1`.`a` from `test`.`t1` limit 1) = (`test`.`t1`.`b` / 10)) +explain SELECT * FROM (SELECT * FROM t1 WHERE (SELECT a FROM t1 LIMIT 1) = b/10) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using where +3 SUBQUERY t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` limit 1) = (`test`.`t1`.`b` / 10)) +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT * FROM t1 WHERE a IN (SELECT a FROM t2 WHERE a % 2 = 0)) AS dt; +SELECT * FROM v1; +a b +2 20 +2 21 +4 40 +4 41 +4 42 +4 43 +4 44 +SELECT * FROM (SELECT * FROM t1 WHERE a IN (SELECT a FROM t2 WHERE a % 2 = 0)) AS dt; +a b +2 20 +2 21 +4 40 +4 41 +4 42 +4 43 +4 44 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` % 2) = 0)) +explain SELECT * FROM (SELECT * FROM t1 WHERE a IN (SELECT a FROM t2 WHERE a % 2 = 0)) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` % 2) = 0)) +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, (SELECT a FROM t2 WHERE a=t1.a) +FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +SELECT * FROM v1; +a (SELECT a FROM t2 WHERE a=t1.a) +1 1 +2 2 +4 4 +SELECT * FROM (SELECT a, (SELECT a FROM t2 WHERE a=t1.a) +FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +a (SELECT a FROM t2 WHERE a=t1.a) +1 1 +2 2 +4 4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +3 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Start temporary +3 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +5 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #5 was resolved in SELECT #3 +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`(SELECT a FROM t2 WHERE a=t1.a)` AS `(SELECT a FROM t2 WHERE a=t1.a)` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,(/* select#5 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `(SELECT a FROM t2 WHERE a=t1.a)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) `dt` +explain SELECT * FROM (SELECT a, (SELECT a FROM t2 WHERE a=t1.a) +FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # Start temporary +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `dt`.`a` AS `a`,`dt`.`(SELECT a FROM t2 WHERE a=t1.a)` AS `(SELECT a FROM t2 WHERE a=t1.a)` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,(/* select#3 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `(SELECT a FROM t2 WHERE a=t1.a)` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) `dt` +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, (SELECT a FROM t2) FROM t1 WHERE b=a*10) AS dt; +SELECT * FROM v1; +ERROR 21000: Subquery returns more than 1 row +SELECT * FROM (SELECT a, (SELECT a FROM t2) FROM t1 WHERE b=a*10) AS dt; +ERROR 21000: Subquery returns more than 1 row +DROP VIEW v1; +CREATE VIEW v1 AS +SELECT * FROM (SELECT a, b FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt; +SELECT * FROM v1 JOIN t2 ON v1.a=t2.a; +a b a +1 10 1 +2 20 2 +4 40 4 +SELECT * FROM (SELECT a, b FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt JOIN t2 ON dt.a=t2.a; +a b a +1 10 1 +2 20 2 +4 40 4 +explain SELECT * FROM v1 JOIN t2 ON v1.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) +explain SELECT * FROM (SELECT a, b FROM t1 WHERE b IN (SELECT a*10 FROM t2)) AS dt JOIN t2 ON dt.a=t2.a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Start temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # Using where; End temporary; Using join buffer (hash join) +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`a` * 10))) +DROP VIEW v1; +DROP TABLE t1, t2; +CREATE TABLE t1(a INTEGER, b INTEGER); +CREATE TABLE t2(a INTEGER); +INSERT INTO t1 VALUES +(1, 10), +(2, 20), (2, 21), +(3, NULL), +(4, 40), (4, 41), (4, 42), (4, 43), (4, 44); +INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (NULL); +ANALYZE TABLE t1,t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +CREATE VIEW v1 AS SELECT a, b, (SELECT 1 FROM t2 WHERE a=3) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT 1 FROM t2 WHERE a=3) AS s +FROM t1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#3 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 3)) AS `s` from `test`.`t1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain SELECT a, b, (SELECT 1 FROM t2 WHERE a=3) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 3)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 NULL +2 20 NULL +2 21 NULL +3 NULL NULL +4 40 NULL +4 41 NULL +4 42 NULL +4 43 NULL +4 44 NULL +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +a b s +1 10 NULL +2 20 NULL +2 21 NULL +3 NULL NULL +4 40 NULL +4 41 NULL +4 42 NULL +4 43 NULL +4 44 NULL +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#3 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 6)) AS `s` from `test`.`t1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain SELECT a, b, (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 6)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT 1 FROM t2 WHERE a>=3) AS s +FROM t1; +SELECT * FROM v1; +ERROR 21000: Subquery returns more than 1 row +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT 1 FROM t2 WHERE a>=3) AS s +FROM t1; +ERROR 21000: Subquery returns more than 1 row +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, a IN (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, a IN (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +a b s +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, a IN (SELECT 1 FROM t2 WHERE a=6) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select 1 from `test`.`t2` where (`test`.`t2`.`a` = 6) ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`1`))))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT COUNT(*) FROM t2) AS c +FROM t1; +SELECT * FROM v1; +a b c +1 10 6 +2 20 6 +2 21 6 +3 NULL 6 +4 40 6 +4 41 6 +4 42 6 +4 43 6 +4 44 6 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT COUNT(*) FROM t2) AS c +FROM t1; +a b c +1 10 6 +2 20 6 +2 21 6 +3 NULL 6 +4 40 6 +4 41 6 +4 42 6 +4 43 6 +4 44 6 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#3 */ select count(0) from `test`.`t2`) AS `c` from `test`.`t1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain SELECT a, b, (SELECT COUNT(*) FROM t2) AS c +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select count(0) from `test`.`t2`) AS `c` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, a IN (SELECT COUNT(*) FROM t2) AS c +FROM t1; +SELECT * FROM v1; +a b c +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, a IN (SELECT COUNT(*) FROM t2) AS c +FROM t1; +a b c +1 10 0 +2 20 0 +2 21 0 +3 NULL 0 +4 40 0 +4 41 0 +4 42 0 +4 43 0 +4 44 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`c` AS `c` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, a IN (SELECT COUNT(*) FROM t2) AS c +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(`test`.`t1`.`a`,`test`.`t1`.`a` in ( (/* select#2 */ select count(0) from `test`.`t2` having true ), (`test`.`t1`.`a` in on where ((`test`.`t1`.`a` = ``.`COUNT(*)`))))) AS `c` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 2 +2 20 4 +2 21 4 +3 NULL 6 +4 40 8 +4 41 8 +4 42 8 +4 43 8 +4 44 8 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 2 +2 20 4 +2 21 4 +3 NULL 6 +4 40 8 +4 41 8 +4 42 8 +4 43 8 +4 44 8 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select (`test`.`t2`.`a` * 2) from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, EXISTS (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, EXISTS (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, EXISTS (SELECT a*2 FROM t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,exists(/* select#2 */ select (`test`.`t2`.`a` * 2) from `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 2 +2 21 2 +3 NULL 1 +4 40 5 +4 41 5 +4 42 5 +4 43 5 +4 44 5 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 1 +2 20 2 +2 21 2 +3 NULL 1 +4 40 5 +4 41 5 +4 42 5 +4 43 5 +4 44 5 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,(/* select#2 */ select count(0) from `test`.`t1` `t2` where (`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, b, EXISTS (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +SELECT * FROM v1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +SELECT a FROM v1; +a +1 +2 +2 +3 +4 +4 +4 +4 +4 +SELECT a, b, EXISTS (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +a b s +1 10 1 +2 20 1 +2 21 1 +3 NULL 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`b` AS `b`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, b, EXISTS (SELECT COUNT(*) FROM t1 AS t2 WHERE a=t1.a) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,exists(/* select#2 */ select count(0) from `test`.`t1` `t2` where (`t2`.`a` = `test`.`t1`.`a`)) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +s +4 +SELECT (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +s +4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '4' AS `s` from dual +explain SELECT (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2)))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT COUNT(*) AS a, (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +a s +9 4 +SELECT a FROM v1; +a +9 +SELECT COUNT(*) AS a, (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +a s +9 4 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a`,'4' AS `s` from dual +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a` from dual +explain SELECT COUNT(*) AS a, (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select count(0) AS `a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2)))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +s +0 +SELECT a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +s +0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '0' AS `s` from dual +explain SELECT a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select (`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2))) having (outer_field_is_not_null, ((`test`.`t1`.`a`) = (`test`.`t2`.`a`)), true))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT COUNT(*) AS a, a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +SELECT * FROM v1; +a s +9 0 +SELECT a FROM v1; +a +9 +SELECT COUNT(*) AS a, a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +a s +9 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a`,'0' AS `s` from dual +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL system NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # NULL +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select '9' AS `a` from dual +explain SELECT COUNT(*) AS a, a IN (SELECT a FROM t2 WHERE a=FLOOR(COUNT(t1.a)/2)) AS s +FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select count(0) AS `a`,(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = floor((count(`test`.`t1`.`a`) / 2))) having (outer_field_is_not_null, ((`test`.`t1`.`a`) = (`test`.`t2`.`a`)), true))) AS `s` from `test`.`t1` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, COUNT(*) AS c, (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +SELECT * FROM v1; +a c s +1 1 1 +2 2 2 +3 1 1 +4 5 5 +SELECT a FROM v1; +a +1 +2 +3 +4 +SELECT a, COUNT(*) AS c, (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +a c s +1 1 1 +2 2 2 +3 1 1 +4 5 5 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`c` AS `c`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, COUNT(*) AS c, (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(0) AS `c`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = count(`test`.`t1`.`a`))) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +DROP VIEW v1; +CREATE VIEW v1 AS SELECT a, COUNT(*) AS c, a IN (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +SELECT * FROM v1; +a c s +1 1 1 +2 2 1 +3 1 0 +4 5 0 +SELECT a FROM v1; +a +1 +2 +3 +4 +SELECT a, COUNT(*) AS c, a IN (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +a c s +1 1 1 +2 2 1 +3 1 0 +4 5 0 +explain SELECT * FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a`,`test`.`v1`.`c` AS `c`,`test`.`v1`.`s` AS `s` from `test`.`v1` +explain SELECT a FROM v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # # Using temporary +3 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2 +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +explain SELECT a, COUNT(*) AS c, a IN (SELECT a FROM t2 WHERE a=COUNT(t1.a)) AS s +FROM t1 +GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # # Using temporary +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL # # Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(0) AS `c`,(`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = count(`test`.`t1`.`a`)) having (outer_field_is_not_null, ((`test`.`t1`.`a`) = (`test`.`t2`.`a`)), true))) AS `s` from `test`.`t1` group by `test`.`t1`.`a` +DROP VIEW v1; +DROP TABLE t1, t2; +# +# Bug#19789450 Assert fail in add_key_field +# +CREATE TABLE t1 ( +pk int NOT NULL, +col_date_key date DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_date_key (col_date_key) +) ; +CREATE TABLE t2 ( +pk int NOT NULL, +col_time_key time DEFAULT NULL, +col_datetime_key datetime DEFAULT NULL, +PRIMARY KEY (pk), +KEY col_time_key (col_time_key), +KEY col_datetime_key (col_datetime_key) +); +CREATE ALGORITHM=MERGE VIEW v1 AS +SELECT col_date_key +FROM t1 WHERE (pk, pk, col_date_key) IN +(SELECT col_datetime_key, +col_time_key, +col_time_key +FROM t2 +WHERE pk <= 7); +SELECT * FROM v1; +col_date_key +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#14117018 - MYSQL SERVER CREATES INVALID VIEW DEFINITION +# BUG#18405221 - SHOW CREATE VIEW OUTPUT INCCORRECT +# +CREATE VIEW v1 AS (SELECT '' FROM DUAL); +CREATE VIEW v2 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL +(SELECT '' FROM DUAL); +CREATE VIEW v3 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL +(SELECT '' FROM DUAL) UNION ALL +(SELECT '' FROM DUAL); +CREATE VIEW v4 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL +(SELECT '' AS col2 FROM DUAL) UNION ALL +(SELECT '' FROM DUAL); +# Name for the column in select1 is set properly with or +# without this fix. +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select '' AS `Name_exp_1` utf8mb4 utf8mb4_0900_ai_ci +# Name for the column in select2 is set with this fix. +# Without this fix, name would not have set for the +# columns in select2. +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select 'BUG#14117018' AS `col1` union all select '' AS `Name_exp_2` utf8mb4 utf8mb4_0900_ai_ci +# Name for the field item in select2 & select3 is set with this fix. +# Without this fix, name would not have set for the +# columns in select2 & select3. +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select 'BUG#14117018' AS `col1` union all select '' AS `Name_exp_2` union all select '' AS `Name_exp_3` utf8mb4 utf8mb4_0900_ai_ci +# Name for the field item in select3 is set with this fix. +# Without this fix, name would not have set for the +# columns in select3. +SHOW CREATE VIEW v4; +View Create View character_set_client collation_connection +v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select 'BUG#14117018' AS `col1` union all select '' AS `col2` union all select '' AS `Name_exp_3` utf8mb4 utf8mb4_0900_ai_ci +DROP VIEW v1, v2, v3, v4; +# Bug#20087932 Assert fail in Join_tab_compare_straight::operator() +CREATE TABLE t1 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t2 ( +pk int NOT NULL, +col_varchar_key varchar(1) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE TABLE t3 ( +pk int NOT NULL, +col_int_key int NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +PRIMARY KEY (pk) +); +CREATE VIEW v2 AS SELECT * FROM t2; +ANALYZE TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +explain SELECT STRAIGHT_JOIN alias1.pk +FROM t2 AS alias1 +RIGHT JOIN +(SELECT sq1_alias2.* +FROM t1 AS sq1_alias1 +RIGHT OUTER JOIN +v2 AS sq1_alias2 +ON sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key AND +sq1_alias2.col_varchar_nokey IN +(SELECT c_sq1_alias1.col_varchar_nokey AS c_sq1_field1 +FROM t3 AS c_sq1_alias1 +WHERE c_sq1_alias1.col_int_key <> c_sq1_alias1.col_int_key +) +) AS alias2 +ON alias2.col_varchar_key = alias1.col_varchar_key; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL # # NULL +1 PRIMARY alias1 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +2 DERIVED t2 NULL ALL NULL NULL NULL NULL # # NULL +2 DERIVED sq1_alias1 NULL ALL NULL NULL NULL NULL # # Using where +2 DERIVED c_sq1_alias1 NULL ALL NULL NULL NULL NULL # # Using where; FirstMatch(sq1_alias1) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`alias1`.`pk` AS `pk` from (/* select#2 */ select `test`.`t2`.`pk` AS `pk`,`test`.`t2`.`col_varchar_key` AS `col_varchar_key`,`test`.`t2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` left join (`test`.`t1` `sq1_alias1` semi join (`test`.`t3` `c_sq1_alias1`)) on(((`test`.`c_sq1_alias1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_nokey`) and (`test`.`sq1_alias1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`) and (`test`.`c_sq1_alias1`.`col_int_key` <> `test`.`c_sq1_alias1`.`col_int_key`))) where true) `alias2` left join `test`.`t2` `alias1` on((`test`.`alias1`.`col_varchar_key` = `alias2`.`col_varchar_key`)) where true +SELECT STRAIGHT_JOIN alias1.pk +FROM t2 AS alias1 +RIGHT JOIN +(SELECT sq1_alias2.* +FROM t1 AS sq1_alias1 +RIGHT OUTER JOIN +v2 AS sq1_alias2 +ON sq1_alias2.col_varchar_key = sq1_alias1.col_varchar_key AND +sq1_alias2.col_varchar_nokey IN +(SELECT c_sq1_alias1.col_varchar_nokey AS c_sq1_field1 +FROM t3 AS c_sq1_alias1 +WHERE c_sq1_alias1.col_int_key <> c_sq1_alias1.col_int_key +) +) AS alias2 +ON alias2.col_varchar_key = alias1.col_varchar_key; +pk +DROP VIEW v2; +DROP TABLE t1, t2, t3; +CREATE TABLE t0(x INTEGER); +INSERT INTO t0 VALUES(0); +CREATE TABLE t1(a1 INTEGER PRIMARY KEY, b1 INTEGER); +CREATE TABLE t2(a2 INTEGER PRIMARY KEY, b2 INTEGER); +CREATE VIEW v0 AS SELECT DISTINCT x FROM t0; +CREATE VIEW vmat1 AS SELECT DISTINCT * FROM t1; +CREATE VIEW vmat2 AS SELECT DISTINCT * FROM t2; +CREATE VIEW vtt AS +SELECT * FROM t1 JOIN t2 ON t1.a1=t2.a2; +CREATE VIEW vtr AS +SELECT * FROM t1 JOIN vmat2 AS dt2 ON t1.a1=dt2.a2; +CREATE VIEW vtrd AS +SELECT * FROM t1 JOIN (SELECT DISTINCT * FROM t2) AS dt2 ON t1.a1=dt2.a2; +CREATE VIEW vrt AS +SELECT * FROM vmat1 AS dt1 JOIN t2 ON dt1.a1=t2.a2; +CREATE VIEW vrtd AS +SELECT * FROM (SELECT DISTINCT * FROM t1) AS dt1 JOIN t2 ON dt1.a1=t2.a2; +CREATE VIEW vrr AS +SELECT * FROM vmat1 AS dt1 JOIN vmat2 AS dt2 ON dt1.a1=dt2.a2; +CREATE VIEW vrrd AS +SELECT * FROM (SELECT DISTINCT * FROM t1) AS dt1 JOIN +(SELECT DISTINCT * FROM t2) AS dt2 ON dt1.a1=dt2.a2; +INSERT INTO vtt(a1,b1) VALUES (1,100); +INSERT INTO vtt(a2,b2) VALUES (1,100); +INSERT INTO vtr(a1,b1) VALUES (2,100); +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a1,b1) VALUES (3,100); +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vtr(a2,b2) VALUES (2,100); +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a2,b2) VALUES (3,100); +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vrt(a1,b1) VALUES (4,100); +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a1,b1) VALUES (5,100); +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrt(a2,b2) VALUES (4,100); +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a2,b2) VALUES (5,100); +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrr(a1,b1) VALUES (6,100); +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a1,b1) VALUES (7,100); +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +INSERT INTO vrr(a2,b2) VALUES (6,100); +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a2,b2) VALUES (7,100); +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +SELECT * FROM vtt; +a1 b1 a2 b2 +1 100 1 100 +DELETE FROM t1; +DELETE FROM t2; +INSERT INTO vtt(a1,b1) SELECT 1,100; +INSERT INTO vtt(a2,b2) SELECT 1,100; +INSERT INTO vtr(a1,b1) SELECT 2,100; +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a1,b1) SELECT 3,100; +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vtr(a2,b2) SELECT 2,100; +ERROR HY000: The target table vtr of the INSERT is not insertable-into +INSERT INTO vtrd(a2,b2) SELECT 3,100; +ERROR HY000: The target table vtrd of the INSERT is not insertable-into +INSERT INTO vrt(a1,b1) SELECT 4,100; +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a1,b1) SELECT 5,100; +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrt(a2,b2) SELECT 4,100; +ERROR HY000: The target table vrt of the INSERT is not insertable-into +INSERT INTO vrtd(a2,b2) SELECT 5,100; +ERROR HY000: The target table vrtd of the INSERT is not insertable-into +INSERT INTO vrr(a1,b1) SELECT 6,100; +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a1,b1) SELECT 7,100; +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +INSERT INTO vrr(a2,b2) SELECT 6,100; +ERROR HY000: The target table vrr of the INSERT is not insertable-into +INSERT INTO vrrd(a2,b2) SELECT 7,100; +ERROR HY000: The target table vrrd of the INSERT is not insertable-into +SELECT * FROM vtt; +a1 b1 a2 b2 +1 100 1 100 +DELETE FROM t1; +DELETE FROM t2; +INSERT INTO t1 VALUES +(1,100), (2,100), (3,100), (4,100), (5,100), +(6,100), (7,100), (8,100), (9,100), (10,100), +(11,100), (12,100), (13,100), (14,100); +INSERT INTO t2 VALUES +(1,100), (2,100), (3,100), (4,100), (5,100), +(6,100), (7,100), (8,100), (9,100), (10,100), +(11,100), (12,100), (13,100), (14,100); +DELETE FROM vtt WHERE a1=1; +ERROR HY000: Can not delete from join view 'test.vtt' +DELETE FROM vtr WHERE a1=2; +ERROR HY000: Can not delete from join view 'test.vtr' +DELETE FROM vtrd WHERE a1=3; +ERROR HY000: Can not delete from join view 'test.vtrd' +DELETE FROM vrt WHERE a1=4; +ERROR HY000: Can not delete from join view 'test.vrt' +DELETE FROM vrtd WHERE a1=5; +ERROR HY000: Can not delete from join view 'test.vrtd' +DELETE FROM vrr WHERE a1=6; +ERROR HY000: The target table vrr of the DELETE is not updatable +DELETE FROM vrrd WHERE a1=7; +ERROR HY000: The target table vrrd of the DELETE is not updatable +DELETE vtt FROM vtt WHERE a1=8; +ERROR HY000: Can not delete from join view 'test.vtt' +DELETE vtr FROM vtr WHERE a1=9; +ERROR HY000: Can not delete from join view 'test.vtr' +DELETE vtrd FROM vtrd WHERE a1=10; +ERROR HY000: Can not delete from join view 'test.vtrd' +DELETE vrt FROM vrt WHERE a1=11; +ERROR HY000: Can not delete from join view 'test.vrt' +DELETE vrtd FROM vrtd WHERE a1=12; +ERROR HY000: Can not delete from join view 'test.vrtd' +DELETE vrr FROM vrr WHERE a1=13; +ERROR HY000: The target table vrr of the DELETE is not updatable +DELETE vrrd FROM vrrd WHERE a1=14; +ERROR HY000: The target table vrrd of the DELETE is not updatable +SELECT * FROM vtt; +a1 b1 a2 b2 +1 100 1 100 +2 100 2 100 +3 100 3 100 +4 100 4 100 +5 100 5 100 +6 100 6 100 +7 100 7 100 +8 100 8 100 +9 100 9 100 +10 100 10 100 +11 100 11 100 +12 100 12 100 +13 100 13 100 +14 100 14 100 +DELETE FROM t1; +DELETE FROM t2; +INSERT INTO t1 VALUES (1,100); +INSERT INTO t2 VALUES (1,100); +UPDATE vtt SET b1=b1+1 WHERE a1=1; +UPDATE vtt SET b2=b2+1 WHERE a2=1; +UPDATE vtr SET b1=b1+1 WHERE a1=1; +UPDATE vtrd SET b1=b1+1 WHERE a1=1; +UPDATE vtr SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtr of the UPDATE is not updatable +UPDATE vtrd SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtrd of the UPDATE is not updatable +UPDATE vrt SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrt of the UPDATE is not updatable +UPDATE vrtd SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrtd of the UPDATE is not updatable +UPDATE vrt SET b2=b2+1 WHERE a2=1; +UPDATE vrtd SET b2=b2+1 WHERE a2=1; +UPDATE vrr SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +UPDATE vrr SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +UPDATE vtt, v0 AS dt SET b1=b1+1 WHERE a1=1; +UPDATE vtt, v0 SET b2=b2+1 WHERE a2=1; +UPDATE vtr, v0 SET b1=b1+1 WHERE a1=1; +UPDATE vtrd, v0 SET b1=b1+1 WHERE a1=1; +UPDATE vtr, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtr of the UPDATE is not updatable +UPDATE vtrd, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vtrd of the UPDATE is not updatable +UPDATE vrt, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrt of the UPDATE is not updatable +UPDATE vrtd, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrtd of the UPDATE is not updatable +UPDATE vrt, v0 SET b2=b2+1 WHERE a2=1; +UPDATE vrtd, v0 SET b2=b2+1 WHERE a2=1; +UPDATE vrr, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd, v0 SET b1=b1+1 WHERE a1=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +UPDATE vrr, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrr of the UPDATE is not updatable +UPDATE vrrd, v0 SET b2=b2+1 WHERE a2=1; +ERROR HY000: The target table vrrd of the UPDATE is not updatable +SELECT * FROM vtt; +a1 b1 a2 b2 +1 106 1 106 +DROP VIEW v0, vtt, vtr, vrt, vrr, vmat1, vmat2; +DROP VIEW vtrd, vrtd, vrrd; +DROP TABLE t0, t1, t2; +# +# Bug#20407961 VIEW'S CHECK OPTION SOMETIMES NOT HONOURED IF INCLUDED IN A TOP VIEW +# +create table t1 (a varchar(100)); +# n/c/l letter suffix means: no/cascaded/local check option +create view v1n as select * from t1 where a like '%v1n%'; +create view v2c as select * from t1 where a like '%v2c%' + with check option; +show create view v2c; +View Create View character_set_client collation_connection +v2c CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2c` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` like '%v2c%') WITH CASCADED CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +create view v3l as select * from t1 where a like '%v3l%' + with local check option; +show create view v3l; +View Create View character_set_client collation_connection +v3l CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3l` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` like '%v3l%') WITH LOCAL CHECK OPTION utf8mb4 utf8mb4_0900_ai_ci +# The basic, single-view feature works: +insert into t1 values(''); +insert into v1n values(''); +insert into v2c values(''); +ERROR HY000: CHECK OPTION failed 'test.v2c' +insert into v2c values('v2c'); +insert into v3l values(''); +ERROR HY000: CHECK OPTION failed 'test.v3l' +insert into v3l values('v3l'); +# We also test UPDATE of the successfully inserted row +update v1n set a='_'; +# if this update to v2c was allowed, it would be produce a row in t1 +# not matching v2c's filter, which is against the goal of CHECK +# OPTION. +update v2c set a=''; +ERROR HY000: CHECK OPTION failed 'test.v2c' +update v3l set a=''; +ERROR HY000: CHECK OPTION failed 'test.v3l' +# Top view without no CHECK OPTION, still CHECK OPTION conditions +# of underlying views are checked. +create view v4n as select * from v2c where a like '%v4n%'; +create view v5n as select * from v3l where a like '%v5n%'; +# The view's nesting structure is: +# v4n -> v2c -> t1 +# We present the query with needed tags, verify that it passes, +# then we take each tag away and verify that it fails. +insert into v4n values('v2c'); +insert into v4n values(''); +ERROR HY000: CHECK OPTION failed 'test.v4n' +# To check UPDATE on v4n, we need to update a row originally +# visible in v4n, so we create it: +insert into v4n values('v4n v2c'); +# This row can legally disappear from v4n: +update v4n set a='v2c'; +insert into v4n values('v4n v2c'); +# But this row cannot disappear from v2c: +update v4n set a='v4n'; +ERROR HY000: CHECK OPTION failed 'test.v4n' +# Lest we delete it: +delete from v4n; +# v5n -> v3l -> t1 +insert into v5n values('v3l'); +insert into v5n values(''); +ERROR HY000: CHECK OPTION failed 'test.v5n' +# Top view with LOCAL CHECK OPTION, still CHECK OPTION conditions +# of underlying views are checked. +create view v4l as select * from v2c where a like '%v4l%' + with local check option; +create view v5l as select * from v3l where a like '%v5l%' + with local check option; +# v4l -> v2c -> t1 +insert into v4l values('v4l v2c'); +insert into v4l values('v2c'); +ERROR HY000: CHECK OPTION failed 'test.v4l' +update v4l set a='v2c'; +ERROR HY000: CHECK OPTION failed 'test.v4l' +insert into v4l values('v4l'); +ERROR HY000: CHECK OPTION failed 'test.v4l' +update v4l set a='v4l'; +ERROR HY000: CHECK OPTION failed 'test.v4l' +# v5l -> v3l -> t1 +insert into v5l values('v5l v3l'); +insert into v5l values('v3l'); +ERROR HY000: CHECK OPTION failed 'test.v5l' +update v5l set a='v3l'; +ERROR HY000: CHECK OPTION failed 'test.v5l' +insert into v5l values('v5l'); +ERROR HY000: CHECK OPTION failed 'test.v5l' +update v5l set a='v5l'; +ERROR HY000: CHECK OPTION failed 'test.v5l' +# CASCADED makes all filtering conditions a requirement +create view v6c as select * from v5n where a like '%v6c%' + with cascaded check option; +# v6c -> v5n -> v3l -> t1 +insert into v6c values('v6c v5n v3l'); +insert into v6c values('v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v6c' +update v6c set a='v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v6c' +insert into v6c values('v6c v3l'); +ERROR HY000: CHECK OPTION failed 'test.v6c' +update v6c set a='v6c v3l'; +ERROR HY000: CHECK OPTION failed 'test.v6c' +insert into v6c values('v6c v5n'); +ERROR HY000: CHECK OPTION failed 'test.v6c' +update v6c set a='v6c v5n'; +ERROR HY000: CHECK OPTION failed 'test.v6c' +# Also true if top view has no check option: +create view v7n as select * from v6c where a like '%v7n%'; +# v7n -> v6c -> v5n -> v3l -> t1 +insert into v7n values('v6c v5n v3l'); +insert into v7n values('v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v7n' +insert into v7n values('v6c v3l'); +ERROR HY000: CHECK OPTION failed 'test.v7n' +insert into v7n values('v6c v5n'); +ERROR HY000: CHECK OPTION failed 'test.v7n' +# Make a visible row to update: +insert into v7n values('v7n v6c v5n v3l'); +update v7n set a='v7n v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v7n' +update v7n set a='v7n v6c v3l'; +ERROR HY000: CHECK OPTION failed 'test.v7n' +update v7n set a='v7n v6c v5nà'; +ERROR HY000: CHECK OPTION failed 'test.v7n' +# Also true if top view has LOCAL: +create view v8l as select * from v7n where a like '%v8l%' + with local check option; +# v8l -> v7n -> v6c -> v5n -> v3l -> t1 +insert into v8l values('v8l v6c v5n v3l'); +insert into v8l values('v6c v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +insert into v8l values('v8l v5n v3l'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +insert into v8l values('v8l v6c v3l'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +insert into v8l values('v8l v6c v5n'); +ERROR HY000: CHECK OPTION failed 'test.v8l' +# Make a visible row (=> satisfy v7n's WHERE clause): +insert into v8l values('v8l v7n v6c v5n v3l'); +update v8l set a='v7n v6c v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +update v8l set a='v8l v7n v5n v3l'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +update v8l set a='v8l v7n v6c v3l'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +update v8l set a='v8l v7n v6c v5n'; +ERROR HY000: CHECK OPTION failed 'test.v8l' +drop view v1n,v2c,v3l,v4n,v5n,v4l,v5l,v6c,v7n,v8l; +drop table t1; +# Bug#20982756 Crash in Table_list::fetch_number_of_rows +CREATE TABLE t1(a INTEGER) engine=innodb; +CREATE VIEW v3 AS SELECT 1 FROM t1; +CREATE VIEW v2 AS SELECT 1 FROM v3 LEFT JOIN t1 ON 1; +PREPARE s FROM "set @a:=(SELECT 1 FROM t1,v2);"; +EXECUTE s; +EXECUTE s; +DROP VIEW v2,v3; +DROP TABLE t1; +# Bug#21097485 *insert_table_ref && (*insert_table_ref)->is_insertable +CREATE TABLE t1 (r INTEGER) engine=innodb; +CREATE VIEW v1 AS +SELECT 1 AS z from t1; +INSERT INTO v1(z) VALUES(1); +ERROR HY000: Column 'z' is not updatable +DROP VIEW v1; +DROP TABLE t1; +# Bug#21277074: crash (segfault) in THD::change_item_tree on exec of prep +CREATE TABLE t (i INTEGER); +PREPARE s1 FROM +"SELECT (SELECT MAX(i)) AS field1 + FROM (SELECT * FROM t) AS table1" +; +EXECUTE s1; +field1 +NULL +CREATE VIEW v AS SELECT * FROM t; +PREPARE s2 FROM +"SELECT (SELECT MAX(i)) AS field1 + FROM v AS table1" +; +EXECUTE s2; +field1 +NULL +DEALLOCATE PREPARE s1; +DEALLOCATE PREPARE s2; +DROP VIEW v; +DROP TABLE t; +# +# BUG#19886430: VIEW CREATION WITH NAMED COLUMNS, OVER UNION, +# IS REJECTED +# Without the patch, reports an error. +CREATE VIEW v1 (fld1, fld2) AS +SELECT 1 AS a, 2 AS b +UNION ALL +SELECT 1 AS a, 1 AS a; +# The column names are explicitly specified and not duplicates, hence +# succeeds. +CREATE VIEW v2 (fld1, fld2) AS +SELECT 1 AS a, 2 AS a +UNION ALL +SELECT 1 AS a, 1 AS a; +# The column name in the first SELECT are not duplicates, hence succeeds. +CREATE VIEW v3 AS +SELECT 1 AS a, 2 AS b +UNION ALL +SELECT 1 AS a, 1 AS a; +# Should report an error, since the explicitly specified column names are +# duplicates. +CREATE VIEW v4 (fld1, fld1) AS +SELECT 1 AS a, 2 AS b +UNION ALL +SELECT 1 AS a, 1 AS a; +ERROR 42S21: Duplicate column name 'fld1' +# Should report an error, since duplicate column name is specified in the +# First SELECT. +CREATE VIEW v4 AS +SELECT 1 AS a, 2 AS a +UNION ALL +SELECT 1 AS a, 1 AS a; +ERROR 42S21: Duplicate column name 'a' +# Cleanup +DROP VIEW v1, v2, v3; +# +# Bug #22108567 ASSERTION `TABLE != 0' FAILED +# +PREPARE X FROM 'CREATE VIEW bug22108567_v1 AS SELECT 1 FROM (SELECT 1) AS D1'; +EXECUTE X; +DROP VIEW bug22108567_v1; +# +# BUG#21877062: MIN/MAX IN VIEW ON TIMESTAMDIFF IN VIEW CONFUSES +# OPTIMIZER TO THROW SYNTAX ERROR +# +CREATE TABLE t(ts1 DATETIME(6), ts2 DATETIME(6)); +INSERT INTO t VALUES('2016-01-11 09:15:25','2016-01-11 21:15:25'); +CREATE VIEW v1 AS +SELECT TIMESTAMPDIFF(MICROSECOND, ts1, ts2) duration FROM t; +# Without the patch, a syntax error is reported. +SELECT * FROM v1; +duration +43200000000 +CREATE VIEW v2 AS +SELECT MIN(duration) AS dmin, MAX(duration) AS dmax FROM v1; +DROP VIEW v1, v2; +DROP TABLE t; +# +# Bug24786327 SIG 11 IN __STPCPY_SSE2_UNALIGNED FROM MY_STPCPY() IN SQL/AUTH/SQL_AUTH_CACHE.CC +# +CREATE TABLE t1_base_N3 (pk INT, col_int INT); +CREATE VIEW t1_view_N3 AS SELECT * FROM t1_base_N3 WHERE `pk` BETWEEN 1 AND +2; +CREATE VIEW t1_view_N4 AS SELECT * FROM ( SELECT * FROM t1_view_N3 ) AS A; +UPDATE t1_view_N3 AS A JOIN t1_view_N4 B SET A. col_int = 1 , B. col_int = 2; +ERROR HY000: The target table B of the UPDATE is not updatable +DROP VIEW t1_view_N3, t1_view_N4; +DROP TABLE t1_base_N3; +# +# WL#7743: New data dictionary: changes to DDL-related parts of SE API +# +CREATE TABLE t1(a INT); +CREATE VIEW v1 AS SELECT * FROM t1; +RENAME TABLE t1 TO t2, v1 TO v2; +SELECT * FROM information_schema.views WHERE table_schema='test'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION +def test v2 select `test`.`t1`.`a` AS `a` from `test`.`t1` NONE YES root@localhost DEFINER utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v2; +DROP TABLE t2; +CREATE TABLE t1(a INT); +CREATE TABLE t2(b INT); +CREATE TABLE t3(a INT); +CREATE TABLE t4(b INT); +CREATE VIEW v1 AS SELECT * FROM t1, t2; +DROP TABLE t1, t2; +RENAME TABLE t3 TO t1, t4 TO t2; +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#25634576: DATABASE NAME IN SHOW CREATE VIEW +# +CREATE DATABASE db; +CREATE TABLE db.t1(fld1 INT); +CREATE TABLE db.t2(fld2 INT); +CREATE TABLE t1(fld1 INT); +CREATE TABLE t2(fld2 INT); +# With patch, db name is appended only to those tables +# which are not present in the current database. +# Test cases with reference to table within current +# db and outside current db. +CREATE VIEW v1 AS SELECT * FROM t1 UNION SELECT * FROM t2; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`fld1` AS `fld1` from `t1` union select `t2`.`fld2` AS `fld2` from `t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v2 AS SELECT * FROM t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`fld1` AS `fld1` from `t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v3 AS SELECT fld1 FROM t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`fld1` AS `fld1` from `t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v4 AS SELECT t1.fld1 FROM t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v4; +View Create View character_set_client collation_connection +v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`fld1` AS `fld1` from `t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v5 AS SELECT * FROM db.t1 UNION SELECT * FROM db.t2; +SHOW CREATE VIEW v5; +View Create View character_set_client collation_connection +v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v5` AS select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1` union select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` utf8mb4 utf8mb4_0900_ai_ci +# Test cases with subquery. +CREATE VIEW v6 AS SELECT * FROM t2 WHERE fld2 IN (SELECT fld1 FROM t1); +SHOW CREATE VIEW v6; +View Create View character_set_client collation_connection +v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t2`.`fld2` AS `fld2` from `t2` where `t2`.`fld2` in (select `t1`.`fld1` from `t1`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v7 AS SELECT * FROM db.t2 WHERE fld2 IN (SELECT fld1 FROM t1); +SHOW CREATE VIEW v7; +View Create View character_set_client collation_connection +v7 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v7` AS select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2` where `db`.`t2`.`fld2` in (select `t1`.`fld1` from `t1`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v8 AS SELECT * FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v8; +View Create View character_set_client collation_connection +v8 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v8` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v9 AS SELECT fld1 FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v9; +View Create View character_set_client collation_connection +v9 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v9` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v10 AS SELECT t1.fld1 FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v10; +View Create View character_set_client collation_connection +v10 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v10` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v11 AS SELECT * FROM db.t1 WHERE fld1 NOT IN +(SELECT fld2 FROM db.t2); +SHOW CREATE VIEW v11; +View Create View character_set_client collation_connection +v11 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v11` AS select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1` where `db`.`t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +# Test cases which uses derived table in sub query. +CREATE VIEW v12 AS SELECT * FROM (SELECT fld1 FROM t1) dummy; +SHOW CREATE VIEW v12; +View Create View character_set_client collation_connection +v12 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v12` AS select `dummy`.`fld1` AS `fld1` from (select `t1`.`fld1` AS `fld1` from `t1`) `dummy` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v13 AS SELECT * FROM (SELECT fld1 FROM db.t1) dummy; +SHOW CREATE VIEW v13; +View Create View character_set_client collation_connection +v13 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v13` AS select `dummy`.`fld1` AS `fld1` from (select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1`) `dummy` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v14 AS SELECT * FROM db.t2, (SELECT fld1 FROM t1) dummy; +SHOW CREATE VIEW v14; +View Create View character_set_client collation_connection +v14 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v14` AS select `db`.`t2`.`fld2` AS `fld2`,`dummy`.`fld1` AS `fld1` from (`db`.`t2` join (select `t1`.`fld1` AS `fld1` from `t1`) `dummy`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v15 AS SELECT * FROM db.t2, (SELECT fld1 FROM db.t1) dummy; +SHOW CREATE VIEW v15; +View Create View character_set_client collation_connection +v15 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v15` AS select `db`.`t2`.`fld2` AS `fld2`,`dummy`.`fld1` AS `fld1` from (`db`.`t2` join (select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1`) `dummy`) utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v16 AS SELECT db.t2.fld2 FROM db.t2, (SELECT t1.fld1 FROM db.t1) dummy; +SHOW CREATE VIEW v16; +View Create View character_set_client collation_connection +v16 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v16` AS select `db`.`t2`.`fld2` AS `fld2` from (`db`.`t2` join (select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1`) `dummy`) utf8mb4 utf8mb4_0900_ai_ci +# Test cases using CTE. +CREATE VIEW v17 AS WITH cte AS (SELECT * FROM t1) SELECT * FROM cte; +SHOW CREATE VIEW v17; +View Create View character_set_client collation_connection +v17 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v17` AS with `cte` as (select `t1`.`fld1` AS `fld1` from `t1`) select `cte`.`fld1` AS `fld1` from `cte` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v18 AS WITH cte AS (SELECT fld1 FROM t1) SELECT * FROM cte; +SHOW CREATE VIEW v18; +View Create View character_set_client collation_connection +v18 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v18` AS with `cte` as (select `t1`.`fld1` AS `fld1` from `t1`) select `cte`.`fld1` AS `fld1` from `cte` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW v19 AS WITH cte AS (SELECT db.t2.fld2 FROM db.t2) SELECT * FROM cte; +SHOW CREATE VIEW v19; +View Create View character_set_client collation_connection +v19 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v19` AS with `cte` as (select `db`.`t2`.`fld2` AS `fld2` from `db`.`t2`) select `cte`.`fld2` AS `fld2` from `cte` utf8mb4 utf8mb4_0900_ai_ci +# Test case added for coverage where view is created in different db. +CREATE VIEW db.v1 AS SELECT * FROM db.t1 UNION SELECT * FROM t2; +SHOW CREATE VIEW db.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db`.`v1` AS select `db`.`t1`.`fld1` AS `fld1` from `db`.`t1` union select `t2`.`fld2` AS `fld2` from `t2` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW db.v2 AS SELECT * FROM t1 where fld1 NOT IN (SELECT fld2 FROM db.t2); +SHOW CREATE VIEW db.v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db`.`v2` AS select `t1`.`fld1` AS `fld1` from `t1` where `t1`.`fld1` in (select `db`.`t2`.`fld2` from `db`.`t2`) is false utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW db.v3 AS SELECT * FROM (SELECT fld1 FROM t1) dummy; +SHOW CREATE VIEW db.v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db`.`v3` AS select `dummy`.`fld1` AS `fld1` from (select `t1`.`fld1` AS `fld1` from `t1`) `dummy` utf8mb4 utf8mb4_0900_ai_ci +# Cleanup. +DROP VIEW v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, +v16, v17, v18, v19; +DROP TABLE t1, t2; +DROP DATABASE db; +# +# Bug#25832861: TABLE_SHARE->TMP_TABLE != NO_TMP_TABLE || M_LOCK_TYPE == 1' AT HANDLER::HA_UPDAT +# +CREATE TABLE t1 (a INTEGER); +INSERT INTO t1 VALUES (1), (2); +CREATE VIEW v1 AS SELECT a FROM t1; +CREATE VIEW v2 AS SELECT 1; +CREATE VIEW v3 AS SELECT a FROM (SELECT a FROM v1) AS dt; +CREATE VIEW v4 AS SELECT a FROM (SELECT a FROM t1) AS dt; +CREATE VIEW v5 AS SELECT a FROM (SELECT a FROM v3) AS dt2; +UPDATE v3 SET v3.a=3; +ERROR HY000: The target table v3 of the UPDATE is not updatable +UPDATE v3, v2 SET v3.a=3; +ERROR HY000: The target table v3 of the UPDATE is not updatable +UPDATE v3, v1 SET v1.a=3; +SELECT * FROM t1; +a +3 +3 +UPDATE v3, t1 SET t1.a=4; +SELECT * FROM t1; +a +4 +4 +UPDATE v4 SET v4.a=6; +ERROR HY000: The target table v4 of the UPDATE is not updatable +SELECT * FROM t1; +a +4 +4 +UPDATE v4, v2 SET v4.a=6; +ERROR HY000: The target table v4 of the UPDATE is not updatable +UPDATE v4, v1 SET v1.a=6; +SELECT * FROM t1; +a +6 +6 +UPDATE v4, t1 SET t1.a=7; +SELECT * FROM t1; +a +7 +7 +UPDATE v5 SET v5.a=9; +ERROR HY000: The target table v5 of the UPDATE is not updatable +UPDATE v5, v2 SET v5.a=9; +ERROR HY000: The target table v5 of the UPDATE is not updatable +UPDATE v5, v1 SET v1.a=9; +SELECT * FROM t1; +a +9 +9 +UPDATE v5, t1 SET t1.a=10; +SELECT * FROM t1; +a +10 +10 +DROP TABLE t1; +DROP VIEW v1, v2, v3, v4, v5; +# Bug#26659699 Assertion !(thd->lex->context_analysis_only & 2) failed +CREATE TABLE t1(pk INTEGER, cik INTEGER, UNIQUE KEY(cik)) +PARTITION BY KEY(cik) PARTITIONS 10; +CREATE TABLE t2(pk INTEGER, cvk VARCHAR(20), cik INTEGER, UNIQUE KEY(cik)) +PARTITION BY KEY(cik) PARTITIONS 10; +CREATE VIEW v1 AS +SELECT MAX(t2.pk) AS field1 +FROM t1, t2 +WHERE (SELECT 7 FROM DUAL) IS NOT NULL AND +t1.pk BETWEEN 123 AND (123 + 128) AND +t2.cvk <= 'p' +ORDER BY t1.pk DESC; +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#26266789: ON SERVER 8.0 CREATE OR REPLACE VIEW FAILS FOR COLUMN SIZE > 64 +# +CREATE TABLE t1(fld1 INT, fld2 INT); +INSERT INTO t1 VALUES(1, 1); +# Without patch, a dictionary store error is triggered on release +# build and an assert on debug build. +CREATE OR REPLACE VIEW v1 +(`x12345678901234567890123456789012345678901234567890123456789012322`) AS +SELECT fld1 FROM t1; +ERROR 42000: Incorrect column name 'x12345678901234567890123456789012345678901234567890123456789012322' +# Clean up. +DROP TABLE t1; +# +# Bug#26360114 WRONG RESULT WITH AGGREGATE AND HAVING CLAUSE IN VIEW +# +CREATE TABLE t1 ( +col_date_key DATE, +KEY col_date_key (col_date_key) +); +INSERT INTO t1 VALUES ('2007-02-08'); +INSERT INTO t1 VALUES ('2007-02-08'); +INSERT INTO t1 VALUES ('2008-11-04'); +INSERT INTO t1 VALUES ('2008-11-04'); +INSERT INTO t1 VALUES ('2009-01-14'); +INSERT INTO t1 VALUES ('2009-01-14'); +SELECT MAX(col_date_key) AS x +FROM t1 +HAVING x >= CAST('2009-01-01' AS DATE) +; +x +2009-01-14 +CREATE VIEW v1 AS +SELECT MAX(col_date_key) AS x +FROM t1 +HAVING x >= CAST('2009-01-01' AS DATE) +; +SELECT * FROM v1; +x +2009-01-14 +DROP VIEW v1; +DROP TABLE t1; +# +# Bug#27121663: SIG 11 IN FILL_DD_VIEW_TABLES | SQL/DD/DD_VIEW.CC +# +CREATE TABLE t1 (pk INT); +CREATE VIEW v1 AS SELECT COUNT(*) FROM t1 +ORDER BY (SELECT 1 FROM t1 WHERE 1 IN (SELECT * FROM (SELECT 1 as field) AS dt)); +DROP TABLE t1; +DROP VIEW v1; +# +# Bug #28278220 - WRONG COLUMN TYPE , VIEW , BINARY +# +CREATE VIEW v AS SELECT null AS 'c' UNION SELECT 'a' AS 'c'; +# Without fix, type for field c is listed as binary instead of +# varchar(1). With fix type is listed correctly. +SHOW FIELDS FROM v; +Field Type Null Key Default Extra +c varchar(1) YES NULL +DROP VIEW v; +# +# Bug#32050275 - can't create synonym of information_schema using create_synonym_db() +# +PREPARE stmt FROM "CREATE VIEW v1 AS SELECT * FROM + JSON_TABLE('[]', '$[*]' COLUMNS (c1 INT PATH '$.x')) AS jt"; +EXECUTE stmt; +EXECUTE stmt; +ERROR 42S01: Table 'v1' already exists +DROP VIEW v1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +PREPARE stmt FROM "CREATE VIEW v1 AS WITH RECURSIVE cte (n) AS + ( + SELECT 1 + UNION ALL + SELECT n + 1 FROM cte WHERE n < 5 + ) + SELECT * FROM cte"; +EXECUTE stmt; +EXECUTE stmt; +ERROR 42S01: Table 'v1' already exists +DROP VIEW v1; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +call sys.create_synonym_db("INFORMATION_SCHEMA", "I_S"); +summary +Created XX views in the `I_S` database +DROP DATABASE I_S; diff --git a/mysql-test/r/view_grant.result-pq b/mysql-test/r/view_grant.result-pq new file mode 100644 index 000000000..9eb257808 --- /dev/null +++ b/mysql-test/r/view_grant.result-pq @@ -0,0 +1,2743 @@ +set @orig_sql_mode_session= @@SESSION.sql_mode; +set @orig_sql_mode_global= @@GLOBAL.sql_mode; +drop database if exists mysqltest; +drop view if exists v1,v2,v3; +create user test@localhost; +grant create view on test.* to test@localhost; +show grants for test@localhost; +Grants for test@localhost +GRANT USAGE ON *.* TO `test`@`localhost` +GRANT CREATE VIEW ON `test`.* TO `test`@`localhost` +revoke create view on test.* from test@localhost; +show grants for test@localhost; +Grants for test@localhost +GRANT USAGE ON *.* TO `test`@`localhost` +drop user test@localhost; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +create user mysqltest_1@localhost; +grant select on mysqltest.t1 to mysqltest_1@localhost; +grant create view,select on test.* to mysqltest_1@localhost; +create definer=root@localhost view v1 as select * from mysqltest.t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +create view v1 as select * from mysqltest.t1; +alter view v1 as select * from mysqltest.t1; +ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create or replace view v1 as select * from mysqltest.t1; +ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create view mysqltest.v2 as select * from mysqltest.t1; +ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +create view v2 as select * from mysqltest.t2; +ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2' +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +grant create view,drop,select on test.* to mysqltest_1@localhost; +use test; +alter view v1 as select * from mysqltest.t1; +create or replace view v1 as select * from mysqltest.t1; +revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; +revoke all privileges on test.* from mysqltest_1@localhost; +drop database mysqltest; +drop view test.v1; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select d from mysqltest.v1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select d from mysqltest.v1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +flush privileges; +create user mysqltest_1@localhost; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1; +create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2; +create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2; +create view mysqltest.v5 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.v2 to mysqltest_1@localhost; +grant select on mysqltest.v3 to mysqltest_1@localhost; +grant select on mysqltest.v4 to mysqltest_1@localhost; +grant show view on mysqltest.v5 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select c from mysqltest.v2; +c +select c from mysqltest.v3; +c +select c from mysqltest.v4; +c +select c from mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +show columns from mysqltest.v1; +Field Type Null Key Default Extra +c bigint YES NULL +d bigint YES NULL +show columns from mysqltest.v2; +Field Type Null Key Default Extra +c bigint YES NULL +d bigint YES NULL +explain select c from mysqltest.v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +explain select c from mysqltest.v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v2; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' +explain select c from mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +show create view mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +grant select on mysqltest.v5 to mysqltest_1@localhost; +show create view mysqltest.v5; +View Create View character_set_client collation_connection +v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v5` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +grant show view on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.t1 to mysqltest_1@localhost; +revoke select on mysqltest.v5 from mysqltest_1@localhost; +explain select c from mysqltest.v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`mysqltest`.`t1`.`a` + 1) AS `c` from `mysqltest`.`t1` +show create view mysqltest.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v2; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' +explain select c from mysqltest.v5; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5' +grant show view on mysqltest.* to mysqltest_1@localhost; +explain select c from mysqltest.v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`mysqltest`.`t1`.`a` + 1) AS `c` from `mysqltest`.`t1` +show create view mysqltest.v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest`.`v2`.`c` AS `c` from `mysqltest`.`v2` +show create view mysqltest.v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v2` (`c`,`d`) AS select (`mysqltest`.`t1`.`a` + 1) AS `a+1`,(`mysqltest`.`t1`.`b` + 1) AS `b+1` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` (`c`,`d`) AS select (`mysqltest`.`t2`.`a` + 1) AS `a+1`,(`mysqltest`.`t2`.`b` + 1) AS `b+1` from `mysqltest`.`t2` utf8mb4 utf8mb4_0900_ai_ci +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +View Create View character_set_client collation_connection +v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v4` (`c`,`d`) AS select (`mysqltest`.`t2`.`a` + 1) AS `a+1`,(`mysqltest`.`t2`.`b` + 1) AS `b+1` from `mysqltest`.`t2` utf8mb4 utf8mb4_0900_ai_ci +revoke all privileges, grant option from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +flush privileges; +create user mysqltest_1@localhost; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1; +grant update (a) on mysqltest.v2 to mysqltest_1@localhost; +grant update on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; +select * from t1; +a b +13 2 +24 3 +35 4 +46 5 +50 10 +update v1 set a=a+c; +select * from t1; +a b +16 2 +28 3 +40 4 +52 5 +61 10 +update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c; +select * from t1; +a b +16 2 +31 3 +44 4 +57 5 +61 10 +update v2 set a=a+c; +select * from t1; +a b +18 2 +34 3 +48 4 +62 5 +71 10 +update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' +update v2 set c=a+c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' +update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 'v3' +update v3 set a=a+c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1; +grant delete on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +delete from v1 where c < 4; +select * from t1; +a b +2 3 +3 4 +4 5 +5 10 +delete v1 from t2,v1 where t2.x=v1.c; +select * from t1; +a b +5 10 +delete v2 from t2,v2 where t2.x=v2.c; +ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' +delete from v2 where c < 4; +ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3); +create table mysqltest.t2 (x int, y int); +insert into mysqltest.t2 values (3,4); +create view mysqltest.v1 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; +grant insert on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +insert into v1 values (5,6); +select * from t1; +a b +1 2 +2 3 +5 6 +insert into v1 select x,y from t2; +select * from t1; +a b +1 2 +2 3 +3 4 +5 6 +insert into v2 values (5,6); +ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' +insert into v2 select x,y from t2; +ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +grant update on mysqltest.t1 to mysqltest_1@localhost; +grant update(b) on mysqltest.t2 to mysqltest_1@localhost; +grant create view,update on test.* to mysqltest_1@localhost; +create view v1 as select * from mysqltest.t1; +create view v2 as select b from mysqltest.t2; +create view mysqltest.v1 as select * from mysqltest.t1; +ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create view v3 as select a from mysqltest.t2; +ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't2' +create table mysqltest.v3 (b int); +grant create view on mysqltest.v3 to mysqltest_1@localhost; +drop table mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +grant create view, update on mysqltest.v3 to mysqltest_1@localhost; +drop view mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +create view v4 as select b+1 from mysqltest.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' +grant create view,update,select on test.* to mysqltest_1@localhost; +create view v4 as select b+1 from mysqltest.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' +grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost; +create view v4 as select b+1 from mysqltest.t2; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +drop view v1,v2,v4; +create database mysqltest; +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +create view v1 as select * from t1; +use test; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +grant select on mysqltest.t1 to mysqltest_1@localhost; +grant create view,select on test.* to mysqltest_1@localhost; +create view v1 as select * from mysqltest.t1; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` utf8mb4 utf8mb4_0900_ai_ci +revoke select on mysqltest.t1 from mysqltest_1@localhost; +select * from v1; +ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +grant select on mysqltest.t1 to mysqltest_1@localhost; +select * from v1; +a b +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop view v1; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +insert into t1 values (1); +create table t2 (s1 int); +create function f2 () returns int begin declare v int; select s1 from t2 +into v; return v; end// +create algorithm=TEMPTABLE view v1 as select f2() from t1; +create algorithm=MERGE view v2 as select f2() from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1; +create SQL SECURITY INVOKER view v5 as select * from v4; +grant select on v1 to mysqltest_1@localhost; +grant select on v2 to mysqltest_1@localhost; +grant select on v3 to mysqltest_1@localhost; +grant select on v4 to mysqltest_1@localhost; +grant select on v5 to mysqltest_1@localhost; +use mysqltest; +select * from v1; +f2() +NULL +select * from v2; +f2() +NULL +select * from v3; +ERROR HY000: View 'mysqltest.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v4; +ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +use test; +drop view v1, v2, v3, v4, v5; +drop function f2; +drop table t1, t2; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +insert into t1 values (1); +create table t2 (s1 int); +create function f2 () returns int begin declare v int; select s1 from t2 +into v; return v; end// +grant select on t1 to mysqltest_1@localhost; +grant execute on function f2 to mysqltest_1@localhost; +grant create view on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +create algorithm=TEMPTABLE view v1 as select f2() from t1; +create algorithm=MERGE view v2 as select f2() from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1; +use test; +create view v5 as select * from v1; +revoke execute on function f2 from mysqltest_1@localhost; +select * from v1; +ERROR HY000: View 'mysqltest.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v2; +ERROR HY000: View 'mysqltest.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v3; +f2() +NULL +select * from v4; +f2() +NULL +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop view v1, v2, v3, v4, v5; +drop function f2; +drop table t1, t2; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +create table v1 (a int); +insert into t1 values (1); +grant select on t1 to mysqltest_1@localhost; +grant select on v1 to mysqltest_1@localhost; +grant create view on mysqltest.* to mysqltest_1@localhost; +drop table v1; +use mysqltest; +create algorithm=TEMPTABLE view v1 as select *, a as b from t1; +create algorithm=MERGE view v2 as select *, a as b from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1; +create view v5 as select * from v1; +use test; +revoke select on t1 from mysqltest_1@localhost; +select * from v1; +ERROR HY000: View 'mysqltest.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v2; +ERROR HY000: View 'mysqltest.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v3; +a b +1 1 +select * from v4; +a b +1 1 +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +drop table t1; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int); +insert into t1 values (1); +create algorithm=TEMPTABLE view v1 as select *, a as b from t1; +create algorithm=MERGE view v2 as select *, a as b from t1; +create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from t1; +create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1; +create SQL SECURITY INVOKER view v5 as select * from v4; +grant select on v1 to mysqltest_1@localhost; +grant select on v2 to mysqltest_1@localhost; +grant select on v3 to mysqltest_1@localhost; +grant select on v4 to mysqltest_1@localhost; +grant select on v5 to mysqltest_1@localhost; +use mysqltest; +select * from v1; +a b +1 1 +select * from v2; +a b +1 1 +select * from v3; +ERROR HY000: View 'mysqltest.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v4; +ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +select * from v5; +ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +use test; +drop view v1, v2, v3, v4, v5; +drop table t1; +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +drop view if exists v1; +drop table if exists t1; +create table t1 as select * from mysql.user where user=''; +delete from mysql.user where user=''; +flush privileges; +create user 'test14256'@'%'; +grant all on test.* to 'test14256'@'%'; +use test; +create view v1 as select 42; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` utf8mb4 utf8mb4_0900_ai_ci +select definer into @v1def1 from information_schema.views +where table_schema = 'test' and table_name='v1'; +drop view v1; +create definer=`test14256`@`%` view v1 as select 42; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`test14256`@`%` SQL SECURITY DEFINER VIEW `v1` AS select 42 AS `42` utf8mb4 utf8mb4_0900_ai_ci +select definer into @v1def2 from information_schema.views +where table_schema = 'test' and table_name='v1'; +drop view v1; +select @v1def1, @v1def2, @v1def1=@v1def2; +@v1def1 @v1def2 @v1def1=@v1def2 +test14256@% test14256@% 1 +drop user test14256; +insert into mysql.user select * from t1; +flush privileges; +drop table t1; +create database mysqltest; +use mysqltest; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +GRANT SELECT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost; +use mysqltest; +LOCK TABLES v1 READ; +SHOW CREATE TABLE v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +UNLOCK TABLES; +use test; +use test; +drop user mysqltest_1@localhost; +drop database mysqltest; +create definer=some_user@`` sql security invoker view v1 as select 1; +Warnings: +Note 1449 The user specified as a definer ('some_user'@'') does not exist +create definer=some_user@localhost sql security invoker view v2 as select 1; +Warnings: +Note 1449 The user specified as a definer ('some_user'@'localhost') does not exist +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`some_user`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select 1 AS `1` utf8mb4 utf8mb4_0900_ai_ci +drop view v1; +drop view v2; +CREATE DATABASE mysqltest1; +CREATE USER readonly@localhost; +CREATE TABLE mysqltest1.t1 (x INT); +INSERT INTO mysqltest1.t1 VALUES (1), (2); +CREATE SQL SECURITY INVOKER VIEW mysqltest1.v_t1 AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_ts AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_ti AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tu AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tus AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_td AS SELECT * FROM mysqltest1.t1; +CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tds AS SELECT * FROM mysqltest1.t1; +GRANT SELECT, INSERT, UPDATE, DELETE ON mysqltest1.v_t1 TO readonly@localhost; +GRANT SELECT ON mysqltest1.v_ts TO readonly@localhost; +GRANT INSERT ON mysqltest1.v_ti TO readonly@localhost; +GRANT UPDATE ON mysqltest1.v_tu TO readonly@localhost; +GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost; +GRANT DELETE ON mysqltest1.v_td TO readonly@localhost; +GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost; +SELECT * FROM mysqltest1.v_t1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +INSERT INTO mysqltest1.v_t1 VALUES(4); +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM mysqltest1.v_t1 WHERE x = 1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE mysqltest1.v_t1 SET x = 3 WHERE x = 2; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE mysqltest1.v_t1 SET x = 3; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM mysqltest1.v_t1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SET sql_mode = default; +SELECT 1 FROM mysqltest1.v_t1; +ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM mysqltest1.t1; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 't1' +SELECT * FROM mysqltest1.v_ts; +x +1 +2 +SELECT * FROM mysqltest1.v_ts, mysqltest1.t1 WHERE mysqltest1.t1.x = mysqltest1.v_ts.x; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 't1' +SELECT * FROM mysqltest1.v_ti; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for table 'v_ti' +INSERT INTO mysqltest1.v_ts VALUES (100); +ERROR 42000: INSERT command denied to user 'readonly'@'localhost' for table 'v_ts' +INSERT INTO mysqltest1.v_ti VALUES (100); +UPDATE mysqltest1.v_ts SET x= 200 WHERE x = 100; +ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table 'v_ts' +UPDATE mysqltest1.v_ts SET x= 200; +ERROR 42000: UPDATE command denied to user 'readonly'@'localhost' for table 'v_ts' +UPDATE mysqltest1.v_tu SET x= 200 WHERE x = 100; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for column 'x' in table 'v_tu' +UPDATE mysqltest1.v_tus SET x= 200 WHERE x = 100; +UPDATE mysqltest1.v_tu SET x= 200; +DELETE FROM mysqltest1.v_ts WHERE x= 200; +ERROR 42000: DELETE command denied to user 'readonly'@'localhost' for table 'v_ts' +DELETE FROM mysqltest1.v_ts; +ERROR 42000: DELETE command denied to user 'readonly'@'localhost' for table 'v_ts' +DELETE FROM mysqltest1.v_td WHERE x= 200; +ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for column 'x' in table 'v_td' +DELETE FROM mysqltest1.v_tds WHERE x= 200; +DELETE FROM mysqltest1.v_td; +DROP VIEW mysqltest1.v_tds; +DROP VIEW mysqltest1.v_td; +DROP VIEW mysqltest1.v_tus; +DROP VIEW mysqltest1.v_tu; +DROP VIEW mysqltest1.v_ti; +DROP VIEW mysqltest1.v_ts; +DROP VIEW mysqltest1.v_t1; +DROP TABLE mysqltest1.t1; +DROP USER readonly@localhost; +DROP DATABASE mysqltest1; +CREATE TABLE t1 (a INT PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2), (3); +CREATE DEFINER = 'no-such-user'@localhost VIEW v AS SELECT a from t1; +Warnings: +Note 1449 The user specified as a definer ('no-such-user'@'localhost') does not exist +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`no-such-user`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no-such-user'@'localhost') does not exist +SELECT * FROM v; +ERROR HY000: The user specified as a definer ('no-such-user'@'localhost') does not exist +DROP VIEW v; +DROP TABLE t1; +USE test; +CREATE USER mysqltest_db1@localhost identified by 'PWD'; +GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION; +CREATE SCHEMA mysqltest_db1 ; +USE mysqltest_db1 ; +CREATE TABLE t1 (f1 INTEGER); +CREATE VIEW view1 AS +SELECT * FROM t1; +SHOW CREATE VIEW view1; +View Create View character_set_client collation_connection +view1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view1` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +CREATE VIEW view2 AS +SELECT * FROM view1; +# Here comes a suspicious warning +SHOW CREATE VIEW view2; +View Create View character_set_client collation_connection +view2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_db1`@`localhost` SQL SECURITY DEFINER VIEW `view2` AS select `view1`.`f1` AS `f1` from `view1` utf8mb4 utf8mb4_0900_ai_ci +# But the view view2 is usable +SELECT * FROM view2; +f1 +CREATE VIEW view3 AS +SELECT * FROM view2; +SELECT * from view3; +f1 +DROP VIEW mysqltest_db1.view3; +DROP VIEW mysqltest_db1.view2; +DROP VIEW mysqltest_db1.view1; +DROP TABLE mysqltest_db1.t1; +DROP SCHEMA mysqltest_db1; +DROP USER mysqltest_db1@localhost; +CREATE DATABASE test1; +CREATE DATABASE test2; +CREATE TABLE test1.t0 (a VARCHAR(20)); +CREATE TABLE test2.t1 (a VARCHAR(20)); +CREATE VIEW test2.t3 AS SELECT * FROM test1.t0; +CREATE OR REPLACE VIEW test.v1 AS +SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb; +DROP VIEW test.v1; +DROP VIEW test2.t3; +DROP TABLE test2.t1, test1.t0; +DROP DATABASE test2; +DROP DATABASE test1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +DROP VIEW IF EXISTS v3; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +DROP PROCEDURE IF EXISTS p1; +CREATE SQL SECURITY DEFINER VIEW v1 AS SELECT CURRENT_USER() AS cu; +CREATE FUNCTION f1() RETURNS VARCHAR(77) SQL SECURITY INVOKER +RETURN CURRENT_USER(); +CREATE SQL SECURITY DEFINER VIEW v2 AS SELECT f1() AS cu; +CREATE PROCEDURE p1(OUT cu VARCHAR(77)) SQL SECURITY INVOKER +SET cu= CURRENT_USER(); +CREATE FUNCTION f2() RETURNS VARCHAR(77) SQL SECURITY INVOKER +BEGIN +DECLARE cu VARCHAR(77); +CALL p1(cu); +RETURN cu; +END| +CREATE SQL SECURITY DEFINER VIEW v3 AS SELECT f2() AS cu; +CREATE USER mysqltest_u1@localhost; +GRANT ALL ON test.* TO mysqltest_u1@localhost; + +The following tests should all return 1. + +SELECT CURRENT_USER() = 'mysqltest_u1@localhost'; +CURRENT_USER() = 'mysqltest_u1@localhost' +1 +SELECT f1() = 'mysqltest_u1@localhost'; +f1() = 'mysqltest_u1@localhost' +1 +CALL p1(@cu); +SELECT @cu = 'mysqltest_u1@localhost'; +@cu = 'mysqltest_u1@localhost' +1 +SELECT f2() = 'mysqltest_u1@localhost'; +f2() = 'mysqltest_u1@localhost' +1 +SELECT cu = 'root@localhost' FROM v1; +cu = 'root@localhost' +1 +SELECT cu = 'root@localhost' FROM v2; +cu = 'root@localhost' +1 +SELECT cu = 'root@localhost' FROM v3; +cu = 'root@localhost' +1 +DROP VIEW v3; +DROP FUNCTION f2; +DROP PROCEDURE p1; +DROP FUNCTION f1; +DROP VIEW v2; +DROP VIEW v1; +DROP USER mysqltest_u1@localhost; +CREATE DATABASE db17254; +USE db17254; +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (10),(20); +CREATE USER def_17254@localhost; +GRANT SELECT ON db17254.* TO def_17254@localhost; +CREATE USER inv_17254@localhost; +GRANT SELECT ON db17254.t1 TO inv_17254@localhost; +GRANT CREATE VIEW ON db17254.* TO def_17254@localhost; +CREATE VIEW v1 AS SELECT * FROM t1; +DROP USER def_17254@localhost; +Warnings: +Warning 4005 User 'def_17254'@'localhost' is referenced as a definer account in a view. +for a user +SELECT * FROM v1; +ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1' +for a superuser +SELECT * FROM v1; +ERROR HY000: The user specified as a definer ('def_17254'@'localhost') does not exist +DROP USER inv_17254@localhost; +DROP DATABASE db17254; +DROP DATABASE IF EXISTS mysqltest_db1; +DROP DATABASE IF EXISTS mysqltest_db2; +DROP USER mysqltest_u1; +DROP USER mysqltest_u2; +CREATE USER mysqltest_u1@localhost; +CREATE USER mysqltest_u2@localhost; +CREATE DATABASE mysqltest_db1; +CREATE DATABASE mysqltest_db2; +GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost WITH GRANT OPTION; +GRANT ALL ON mysqltest_db2.* TO mysqltest_u2@localhost; +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +CREATE VIEW v1 AS SELECT i FROM t1 WHERE 1 IN (SELECT * FROM t1); +CREATE TABLE t2 (s CHAR(7)); +INSERT INTO t2 VALUES ('public'); +GRANT SELECT ON v1 TO mysqltest_u2@localhost; +GRANT SELECT ON t2 TO mysqltest_u2@localhost; +SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2; +i s +1 public +PREPARE stmt1 FROM "SELECT * FROM mysqltest_db1.t2"; +EXECUTE stmt1; +s +public +PREPARE stmt2 FROM "SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2"; +EXECUTE stmt2; +i s +1 public +REVOKE SELECT ON t2 FROM mysqltest_u2@localhost; +UPDATE t2 SET s = 'private' WHERE s = 'public'; +SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2' +EXECUTE stmt1; +ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2' +EXECUTE stmt2; +ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2' +REVOKE ALL ON mysqltest_db1.* FROM mysqltest_u1@localhost; +REVOKE ALL ON mysqltest_db2.* FROM mysqltest_u2@localhost; +DROP DATABASE mysqltest_db1; +DROP DATABASE mysqltest_db2; +DROP USER mysqltest_u1@localhost; +DROP USER mysqltest_u2@localhost; +CREATE DATABASE db26813; +USE db26813; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE VIEW v1 AS SELECT f1 FROM t1; +CREATE VIEW v2 AS SELECT f1 FROM t1; +CREATE VIEW v3 AS SELECT f1 FROM t1; +CREATE USER u26813@localhost; +GRANT DROP ON db26813.v1 TO u26813@localhost; +GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost; +GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost; +GRANT SELECT ON db26813.t1 TO u26813@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1' +ALTER VIEW v2 AS SELECT f2 FROM t1; +ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2' +ALTER VIEW v3 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP USER u26813@localhost; +DROP DATABASE db26813; +# +# Bug#29908 A user can gain additional access through the ALTER VIEW. +# +CREATE DATABASE mysqltest_29908; +USE mysqltest_29908; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE USER u29908_1@localhost; +CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1; +CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS +SELECT f1 FROM t1; +GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost; +GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost; +CREATE USER u29908_2@localhost; +GRANT SELECT, DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost; +GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +ALTER VIEW v2 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v1 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` utf8mb4 utf8mb4_0900_ai_ci +DROP USER u29908_1@localhost; +Warnings: +Warning 4005 User 'u29908_1'@'localhost' is referenced as a definer account in a view. +DROP USER u29908_2@localhost; +DROP DATABASE mysqltest_29908; +####################################################################### +DROP DATABASE IF EXISTS mysqltest1; +DROP DATABASE IF EXISTS mysqltest2; +CREATE DATABASE mysqltest1; +CREATE DATABASE mysqltest2; +CREATE TABLE mysqltest1.t1(c1 INT); +CREATE TABLE mysqltest1.t2(c2 INT); +CREATE TABLE mysqltest1.t3(c3 INT); +CREATE TABLE mysqltest1.t4(c4 INT); +INSERT INTO mysqltest1.t1 VALUES (11), (12), (13), (14); +INSERT INTO mysqltest1.t2 VALUES (21), (22), (23), (24); +INSERT INTO mysqltest1.t3 VALUES (31), (32), (33), (34); +INSERT INTO mysqltest1.t4 VALUES (41), (42), (43), (44); +CREATE USER mysqltest_u1@localhost; +GRANT SELECT ON mysqltest1.t1 TO mysqltest_u1@localhost; +GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost; +GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost; +GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost; +GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost; + +---> connection: bug24040_con +SELECT * FROM mysqltest1.t1; +c1 +11 +12 +13 +14 +INSERT INTO mysqltest1.t2 VALUES(25); +UPDATE mysqltest1.t3 SET c3 = 331 WHERE c3 = 31; +DELETE FROM mysqltest1.t4 WHERE c4 = 44; +CREATE VIEW v1 AS SELECT * FROM mysqltest1.t1; +CREATE VIEW v2 AS SELECT * FROM mysqltest1.t2; +CREATE VIEW v3 AS SELECT * FROM mysqltest1.t3; +CREATE VIEW v4 AS SELECT * FROM mysqltest1.t4; +SELECT * FROM v1; +c1 +11 +12 +13 +14 +INSERT INTO v2 VALUES(26); +UPDATE v3 SET c3 = 332 WHERE c3 = 32; +DELETE FROM v4 WHERE c4 = 43; +CREATE VIEW v12 AS SELECT c1, c2 FROM mysqltest1.t1, mysqltest1.t2; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v12' +CREATE VIEW v13 AS SELECT c1, c3 FROM mysqltest1.t1, mysqltest1.t3; +CREATE VIEW v14 AS SELECT c1, c4 FROM mysqltest1.t1, mysqltest1.t4; +CREATE VIEW v21 AS SELECT c2, c1 FROM mysqltest1.t2, mysqltest1.t1; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c1' in table 'v21' +CREATE VIEW v23 AS SELECT c2, c3 FROM mysqltest1.t2, mysqltest1.t3; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c3' in table 'v23' +CREATE VIEW v24 AS SELECT c2, c4 FROM mysqltest1.t2, mysqltest1.t4; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c4' in table 'v24' +CREATE VIEW v31 AS SELECT c3, c1 FROM mysqltest1.t3, mysqltest1.t1; +CREATE VIEW v32 AS SELECT c3, c2 FROM mysqltest1.t3, mysqltest1.t2; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v32' +CREATE VIEW v34 AS SELECT c3, c4 FROM mysqltest1.t3, mysqltest1.t4; +CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1; +CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2; +ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v42' +CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3; + +---> connection: default +SELECT * FROM mysqltest1.t1; +c1 +11 +12 +13 +14 +SELECT * FROM mysqltest1.t2; +c2 +21 +22 +23 +24 +25 +26 +SELECT * FROM mysqltest1.t3; +c3 +331 +332 +33 +34 +SELECT * FROM mysqltest1.t4; +c4 +41 +42 +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; +DROP USER mysqltest_u1@localhost; +CREATE DATABASE db1; +USE db1; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE VIEW v1 AS SELECT f1, f2 FROM t1; +CREATE USER foo; +GRANT SELECT (f1) ON t1 TO foo; +GRANT SELECT (f1) ON v1 TO foo; +USE db1; +SELECT f1 FROM t1; +f1 +SELECT f2 FROM t1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 't1' +SELECT * FROM t1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 't1' +SELECT f1 FROM v1; +f1 +SELECT f2 FROM v1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 'v1' +SELECT * FROM v1; +ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 'v1' +USE test; +REVOKE SELECT (f1) ON db1.t1 FROM foo; +REVOKE SELECT (f1) ON db1.v1 FROM foo; +DROP USER foo; +DROP VIEW db1.v1; +DROP TABLE db1.t1; +DROP DATABASE db1; +Bug #11765687/#58677: +No privilege on table/view, but can know #rows / underlying table's name +create database mysqltest1; +create table mysqltest1.t1 (i int); +create table mysqltest1.t2 (j int); +create table mysqltest1.t3 (k int, secret int); +create user alice@localhost; +create user bob@localhost; +create user cecil@localhost; +create user dan@localhost; +create user eugene@localhost; +create user fiona@localhost; +create user greg@localhost; +create user han@localhost; +create user inga@localhost; +create user jamie@localhost; +create user karl@localhost; +create user lena@localhost; +create user mhairi@localhost; +create user noam@localhost; +create user olga@localhost; +create user pjotr@localhost; +create user quintessa@localhost; +grant all privileges on mysqltest1.* to alice@localhost with grant option; +... as alice +create view v1 as select * from t1; +create view v2 as select * from v1, t2; +create view v3 as select k from t3; +grant select on mysqltest1.v1 to bob@localhost; +grant show view on mysqltest1.v1 to cecil@localhost; +grant select, show view on mysqltest1.v1 to dan@localhost; +grant select on mysqltest1.t1 to dan@localhost; +grant select on mysqltest1.* to eugene@localhost; +grant select, show view on mysqltest1.v2 to fiona@localhost; +grant select, show view on mysqltest1.v2 to greg@localhost; +grant show view on mysqltest1.v1 to greg@localhost; +grant select(k) on mysqltest1.t3 to han@localhost; +grant select, show view on mysqltest1.v3 to han@localhost; +grant select on mysqltest1.t1 to inga@localhost; +grant select on mysqltest1.t2 to inga@localhost; +grant select on mysqltest1.v1 to inga@localhost; +grant select, show view on mysqltest1.v2 to inga@localhost; +grant select on mysqltest1.t1 to jamie@localhost; +grant select on mysqltest1.t2 to jamie@localhost; +grant show view on mysqltest1.v1 to jamie@localhost; +grant select, show view on mysqltest1.v2 to jamie@localhost; +grant select on mysqltest1.t1 to karl@localhost; +grant select on mysqltest1.t2 to karl@localhost; +grant select, show view on mysqltest1.v1 to karl@localhost; +grant select on mysqltest1.v2 to karl@localhost; +grant select on mysqltest1.t1 to lena@localhost; +grant select on mysqltest1.t2 to lena@localhost; +grant select, show view on mysqltest1.v1 to lena@localhost; +grant show view on mysqltest1.v2 to lena@localhost; +grant select on mysqltest1.t1 to mhairi@localhost; +grant select on mysqltest1.t2 to mhairi@localhost; +grant select, show view on mysqltest1.v1 to mhairi@localhost; +grant select, show view on mysqltest1.v2 to mhairi@localhost; +grant select on mysqltest1.t1 to noam@localhost; +grant select, show view on mysqltest1.v1 to noam@localhost; +grant select, show view on mysqltest1.v2 to noam@localhost; +grant select on mysqltest1.t2 to olga@localhost; +grant select, show view on mysqltest1.v1 to olga@localhost; +grant select, show view on mysqltest1.v2 to olga@localhost; +grant select on mysqltest1.t1 to pjotr@localhost; +grant select on mysqltest1.t2 to pjotr@localhost; +grant select, show view on mysqltest1.v2 to pjotr@localhost; +grant select, show view on mysqltest1.v1 to quintessa@localhost; +... as bob +select * from v1; +i +explain select * from v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as cecil +select * from v1; +ERROR 42000: SELECT command denied to user 'cecil'@'localhost' for table 'v1' +explain select * from v1; +ERROR 42000: SELECT command denied to user 'cecil'@'localhost' for table 'v1' +... as dan +select * from v1; +i +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`i` AS `i` from `mysqltest1`.`t1` +... as eugene +select * from v1; +i +explain select * from v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as fiona +select * from v2; +i j +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`alice`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`i` AS `i`,`t2`.`j` AS `j` from (`v1` join `t2`) utf8mb4 utf8mb4_0900_ai_ci +explain select * from t1; +ERROR 42000: SELECT command denied to user 'fiona'@'localhost' for table 't1' +explain select * from v1; +ERROR 42000: SELECT command denied to user 'fiona'@'localhost' for table 'v1' +explain select * from t2; +ERROR 42000: SELECT command denied to user 'fiona'@'localhost' for table 't2' +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as greg +select * from v2; +i j +explain select * from v1; +ERROR 42000: SELECT command denied to user 'greg'@'localhost' for table 'v1' +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as han +select * from t3; +ERROR 42000: SELECT command denied to user 'han'@'localhost' for table 't3' +explain select * from t3; +ERROR 42000: SELECT command denied to user 'han'@'localhost' for table 't3' +select k from t3; +k +explain select k from t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t3`.`k` AS `k` from `mysqltest1`.`t3` +select * from v3; +k +explain select * from v3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t3`.`k` AS `k` from `mysqltest1`.`t3` +... as inga +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as jamie +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as karl +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as lena +select * from v2; +ERROR 42000: SELECT command denied to user 'lena'@'localhost' for table 'v2' +explain select * from v2; +ERROR 42000: SELECT command denied to user 'lena'@'localhost' for table 'v2' +... as mhairi +select * from v2; +i j +explain select * from v2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`i` AS `i`,`mysqltest1`.`t2`.`j` AS `j` from `mysqltest1`.`t1` join `mysqltest1`.`t2` +... as noam +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as olga +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as pjotr +select * from v2; +i j +explain select * from v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as quintessa +select * from v1; +i +explain select * from v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +... as root again at last: clean-up time! +drop user alice@localhost; +Warnings: +Warning 4005 User 'alice'@'localhost' is referenced as a definer account in a view. +drop user bob@localhost; +drop user cecil@localhost; +drop user dan@localhost; +drop user eugene@localhost; +drop user fiona@localhost; +drop user greg@localhost; +drop user han@localhost; +drop user inga@localhost; +drop user jamie@localhost; +drop user karl@localhost; +drop user lena@localhost; +drop user mhairi@localhost; +drop user noam@localhost; +drop user olga@localhost; +drop user pjotr@localhost; +drop user quintessa@localhost; +drop database mysqltest1; +End of 5.0 tests. +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; +ALTER VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_1') does not exist +ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_2') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such'@'user_2') does not exist +DROP VIEW v1; +DROP TABLE t1; +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( b INT ); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +GRANT CREATE VIEW ON mysqltest1.* TO mysqluser1@localhost; +GRANT SELECT ON t1 TO mysqluser1@localhost; +GRANT INSERT ON t2 TO mysqluser1@localhost; +This would lead to failed assertion. +CREATE VIEW v1 AS SELECT a, b FROM t1, t2; +SELECT * FROM v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +SELECT b FROM v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +DROP TABLE t1, t2; +DROP VIEW v1; +DROP DATABASE mysqltest1; +DROP USER mysqluser1@localhost; +USE test; +End of 5.1 tests. +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT, b INT ); +CREATE VIEW v1 AS SELECT a, b FROM t1; +GRANT SELECT( a ) ON v1 TO mysqluser1@localhost; +GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost; +SELECT * FROM mysqltest1.v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +CREATE VIEW v1 AS SELECT * FROM mysqltest1.t2; +ERROR 42000: ANY command denied to user 'mysqluser1'@'localhost' for table 't2' +DROP TABLE t1, t2; +DROP VIEW v1; +DROP DATABASE mysqltest1; +DROP USER mysqluser1@localhost; +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE VIEW v1 AS SELECT * FROM information_schema.tables LIMIT 1; +CREATE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT 1 AS A; +CREATE VIEW test.v3 AS SELECT 1 AS a; +GRANT SELECT ON mysqltest1.* to mysqluser1@localhost; +GRANT ALL ON test.* TO mysqluser1@localhost; +PREPARE stmt_v1 FROM "SELECT * FROM mysqltest1.v1"; +PREPARE stmt_v2 FROM "SELECT * FROM mysqltest1.v2"; +REVOKE SELECT ON mysqltest1.* FROM mysqluser1@localhost; +EXECUTE stmt_v1; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1' +EXECUTE stmt_v2; +ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v2' +PREPARE stmt FROM "SELECT a FROM v3"; +EXECUTE stmt; +a +1 +DROP VIEW v1, v2; +DROP DATABASE mysqltest1; +DROP VIEW test.v3; +DROP USER mysqluser1@localhost; +USE test; +# +# Bug#35996: SELECT + SHOW VIEW should be enough to display view +# definition +# +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +CREATE DATABASE mysqltest2; +GRANT USAGE, SELECT, CREATE VIEW, SHOW VIEW +ON mysqltest2.* TO mysqluser1@localhost; +USE mysqltest1; +CREATE TABLE t1( a INT ); +CREATE TABLE t2( a INT, b INT ); +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v1 AS SELECT 1 AS a; +CREATE VIEW v2 AS SELECT 1 AS a, 2 AS b; +GRANT SELECT ON TABLE t1 TO mysqluser1@localhost; +GRANT SELECT (a, b) ON TABLE t2 TO mysqluser1@localhost; +GRANT EXECUTE ON FUNCTION f1 TO mysqluser1@localhost; +GRANT SELECT ON TABLE v1 TO mysqluser1@localhost; +GRANT SELECT (a, b) ON TABLE v2 TO mysqluser1@localhost; +CREATE VIEW v_t1 AS SELECT * FROM t1; +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE VIEW v_f1 AS SELECT f1() AS a; +CREATE VIEW v_v1 AS SELECT * FROM v1; +CREATE VIEW v_v2 AS SELECT * FROM v2; +GRANT SELECT, SHOW VIEW ON v_t1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_t2 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_f1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_v1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_v2 TO mysqluser1@localhost; +CREATE VIEW v_mysqluser1_t1 AS SELECT * FROM mysqltest1.t1; +CREATE VIEW v_mysqluser1_t2 AS SELECT * FROM mysqltest1.t2; +CREATE VIEW v_mysqluser1_f1 AS SELECT mysqltest1.f1() AS a; +CREATE VIEW v_mysqluser1_v1 AS SELECT * FROM mysqltest1.v1; +CREATE VIEW v_mysqluser1_v2 AS SELECT * FROM mysqltest1.v2; +SHOW CREATE VIEW mysqltest1.v_t1; +View Create View character_set_client collation_connection +v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_t2; +View Create View character_set_client collation_connection +v_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_f1; +View Create View character_set_client collation_connection +v_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_f1` AS select `f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v1; +View Create View character_set_client collation_connection +v_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v2; +View Create View character_set_client collation_connection +v_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t2; +View Create View character_set_client collation_connection +v_mysqluser1_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v2; +View Create View character_set_client collation_connection +v_mysqluser1_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +REVOKE SELECT ON TABLE t1 FROM mysqluser1@localhost; +REVOKE SELECT (a) ON TABLE t2 FROM mysqluser1@localhost; +REVOKE EXECUTE ON FUNCTION f1 FROM mysqluser1@localhost; +REVOKE SELECT ON TABLE v1 FROM mysqluser1@localhost; +SHOW CREATE VIEW mysqltest1.v_t1; +View Create View character_set_client collation_connection +v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_t2; +View Create View character_set_client collation_connection +v_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_f1; +View Create View character_set_client collation_connection +v_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_f1` AS select `f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v1; +View Create View character_set_client collation_connection +v_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW mysqltest1.v_v2; +View Create View character_set_client collation_connection +v_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_t2; +View Create View character_set_client collation_connection +v_mysqluser1_t2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t2` AS select `mysqltest1`.`t2`.`a` AS `a`,`mysqltest1`.`t2`.`b` AS `b` from `mysqltest1`.`t2` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +SHOW CREATE VIEW v_mysqluser1_v2; +View Create View character_set_client collation_connection +v_mysqluser1_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v2` AS select `mysqltest1`.`v2`.`a` AS `a`,`mysqltest1`.`v2`.`b` AS `b` from `mysqltest1`.`v2` utf8mb4 utf8mb4_0900_ai_ci +# Testing the case when the views reference missing objects. +# Obviously, there are no privileges to check for, so we +# need only each object type once. +DROP TABLE t1; +DROP FUNCTION f1; +DROP VIEW v1; +SHOW CREATE VIEW mysqltest1.v_t1; +View Create View character_set_client collation_connection +v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW mysqltest1.v_f1; +View Create View character_set_client collation_connection +v_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_f1` AS select `f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest1.v_f1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW mysqltest1.v_v1; +View Create View character_set_client collation_connection +v_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest1.v_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_f1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +REVOKE SHOW VIEW ON v_t1 FROM mysqluser1@localhost; +REVOKE SHOW VIEW ON v_f1 FROM mysqluser1@localhost; +REVOKE SHOW VIEW ON v_v1 FROM mysqluser1@localhost; +SHOW CREATE VIEW mysqltest1.v_t1; +ERROR 42000: SHOW VIEW command denied to user 'mysqluser1'@'localhost' for table 'v_t1' +SHOW CREATE VIEW mysqltest1.v_f1; +ERROR 42000: SHOW VIEW command denied to user 'mysqluser1'@'localhost' for table 'v_f1' +SHOW CREATE VIEW mysqltest1.v_v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqluser1'@'localhost' for table 'v_v1' +SHOW CREATE VIEW v_mysqluser1_t1; +View Create View character_set_client collation_connection +v_mysqluser1_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_f1; +View Create View character_set_client collation_connection +v_mysqluser1_f1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_f1` AS select `mysqltest1`.`f1`() AS `a` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_f1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW CREATE VIEW v_mysqluser1_v1; +View Create View character_set_client collation_connection +v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `mysqltest1`.`v1`.`a` AS `a` from `mysqltest1`.`v1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Warning 1356 View 'mysqltest2.v_mysqluser1_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP USER mysqluser1@localhost; +Warnings: +Warning 4005 User 'mysqluser1'@'localhost' is referenced as a definer account in a view. +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; +USE test; +CREATE TABLE t1( a INT ); +CREATE DEFINER = no_such_user@no_such_host VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +Warnings: +Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist +DROP TABLE t1; +DROP VIEW v1; +# +# Bug #46019: ERROR 1356 When selecting from within another +# view that has Group By +# +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 (a INT); +CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT a FROM t1 GROUP BY a; +CREATE SQL SECURITY INVOKER VIEW v2 AS SELECT a FROM v1; +CREATE USER mysqluser1; +GRANT SELECT ON TABLE t1 TO mysqluser1; +GRANT SELECT, SHOW VIEW ON TABLE v1 TO mysqluser1; +GRANT SELECT, SHOW VIEW ON TABLE v2 TO mysqluser1; +SELECT a FROM v1; +a +SELECT a FROM v2; +a +DROP USER mysqluser1; +DROP DATABASE mysqltest1; +USE test; +# +# Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer +# +CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; +Warnings: +Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist +LOCK TABLES v1 READ; +ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist +DROP VIEW v1; +# +# Bug #58499 "DEFINER-security view selecting from INVOKER-security view +# access check wrong". +# +# Check that we correctly handle privileges for various combinations +# of INVOKER and DEFINER-security views using each other. +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (j INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +# +# 1) DEFINER-security view uses INVOKER-security view (covers +# scenario originally described in the bug report). +CREATE SQL SECURITY INVOKER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY INVOKER VIEW v1_uses_t2 AS SELECT * FROM t2; +CREATE USER 'mysqluser1'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser1'@'%'; +GRANT SELECT ON t1 TO 'mysqluser1'@'%'; +# To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser1'. +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +# +# Connection 'default'. +CREATE USER 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser2'@'%'; +GRANT SELECT ON t2 TO 'mysqluser2'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser2'@'%'; +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# The below statement should succeed thanks to suid nature of v2_uses_t1. +SELECT * FROM v2_uses_t1; +i +1 +# The below statement should fail due to suid nature of v2_uses_t2. +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# 2) INVOKER-security view uses INVOKER-security view. +# +# Connection 'default'. +DROP VIEW v2_uses_t1, v2_uses_t2; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser2'@'%'; +# +# Connection 'mysqluser1'. +# For both versions of 'v2' 'mysqluser1' privileges should be used. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# Connection 'mysqluser2'. +# And now for both versions of 'v2' 'mysqluser2' privileges should +# be used. +SELECT * FROM v2_uses_t1; +ERROR HY000: View 'mysqltest1.v2_uses_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM v2_uses_t2; +j +2 +# +# 3) INVOKER-security view uses DEFINER-security view. +# +# Connection 'default'. +DROP VIEW v1_uses_t1, v1_uses_t2; +# To be able create 'v1_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser1'. +CREATE SQL SECURITY DEFINER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY DEFINER VIEW v1_uses_t2 AS SELECT * FROM t2; +# +# Connection 'default'. +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# Due to suid nature of v1_uses_t1 and v1_uses_t2 the first +# select should succeed and the second select should fail. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# 4) DEFINER-security view uses DEFINER-security view. +# +# Connection 'default'. +DROP VIEW v2_uses_t1, v2_uses_t2; +# To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +# +# Connection 'default'. +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# Again privileges of creator of innermost views should apply. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +USE test; +DROP DATABASE mysqltest1; +DROP USER 'mysqluser1'@'%'; +DROP USER 'mysqluser2'@'%'; +# +# Test for bug #11766767 - "59957: VIEW USING MERGE PERMISSIONS +# IN MULTI-TABLE UPDATE". +# +drop database if exists mysqltest1; +drop database if exists mysqltest2; +# +# Prepare playground. +create database mysqltest1; +create database mysqltest2; +create user user_11766767; +grant select on mysqltest1.* to user_11766767; +grant all on mysqltest2.* to user_11766767; +use mysqltest1; +create table t1 (id int primary key, val varchar(20)); +insert into t1 values (1, 'test1'); +create table t11 (id int primary key); +insert into t11 values (1); +create algorithm=temptable view v1_temp as select * from t1; +create algorithm=merge view v1_merge as select * from t1; +create algorithm=temptable view v11_temp as +select t1.id as id, t1.val as val from t1, t11 where t1.id= t11.id; +create algorithm=merge view v11_merge as +select t1.id as id, t1.val as val from t1, t11 where t1.id= t11.id; +use mysqltest2; +create table t2 (id int primary key, val varchar(20)); +insert into t2 values (1, 'test2'); +create table t21 (id int primary key); +insert into t21 values (1); +create algorithm=temptable view v2_temp as select * from t2; +create algorithm=merge view v2_merge as select * from t2; +create algorithm=temptable view v21_temp as +select t2.id as id, t2.val as val from t2, t21 where t2.id= t21.id; +create algorithm=merge view v21_merge as +select t2.id as id, t2.val as val from t2, t21 where t2.id= t21.id; +create algorithm=temptable sql security invoker view v3_temp as +select t1.id as id, t1.val as val from mysqltest1.t1 as t1, mysqltest1.t11 as t11 +where t1.id = t11.id; +create algorithm=merge sql security invoker view v3_merge as +select t1.id as id, t1.val as val from mysqltest1.t1 as t1, mysqltest1.t11 as t11 +where t1.id = t11.id; +create sql security invoker view v31 as +select t2.id as id, t2.val as val from mysqltest2.t2 as t2, mysqltest1.t11 as t11 +where t2.id = t11.id; +create sql security invoker view v4 as +select t2.id as id, t2.val as val from mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 +where t2.id = v1.id; +create sql security invoker view v41 as +select v1.id as id, v1.val as val from mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 +where t2.id = v1.id; +create sql security invoker view v42 as +select v2.id as id, v2.val as val from mysqltest2.t2 as t2, mysqltest2.v2_merge as v2 +where t2.id = v2.id; +# +# Connect as user_11766767 +# +# A) Check how we handle privilege checking in multi-update for +# directly used views. +# +# A.1) Originally reported problem, view is used in read-only mode. +# This should work with only SELECT privilege for both mergeable +# and temptable algorithms. +update mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 set t2.val= 'test3' + where t2.id= v1.id; +update mysqltest2.t2 as t2, mysqltest1.v1_temp as v1 set t2.val= 'test4' + where t2.id= v1.id; +# +# A.2) If view is updated an UPDATE privilege on it is required. +# Temptable views can't be updated. +update mysqltest2.t2 as t2, mysqltest1.v1_merge as v1 set v1.val= 'test5' + where t2.id= v1.id; +ERROR 42000: UPDATE command denied to user 'user_11766767'@'localhost' for column 'val' in table 'v1_merge' +update mysqltest1.t1 as t1, mysqltest2.v2_merge as v2 set v2.val= 'test6' + where t1.id= v2.id; +# +# Note that the below error is OK even though user lacks UPDATE +# privilege on v1_temp since he/she still has SELECT privilege on +# this view. +update mysqltest2.t2 as t2, mysqltest1.v1_temp as v1 set v1.val= 'test7' + where t2.id= v1.id; +ERROR HY000: The target table v1 of the UPDATE is not updatable +update mysqltest1.t1 as t1, mysqltest2.v2_temp as v2 set v2.val= 'test8' + where t1.id= v2.id; +ERROR HY000: The target table v2 of the UPDATE is not updatable +# +# A.3) This also works for correctly for multi-table views. +# When usage is read-only SELECT is enough. +update mysqltest2.t2 as t2, mysqltest1.v11_merge as v11 set t2.val= 'test9' + where t2.id= v11.id; +update mysqltest2.t2 as t2, mysqltest1.v11_temp as v11 set t2.val= 'test10' + where t2.id= v11.id; +# When one of view's tables is updated, UPDATE is required +# on a view. +update mysqltest2.t2 as t2, mysqltest1.v11_merge as v11 set v11.val= 'test11' + where t2.id= v11.id; +ERROR 42000: UPDATE command denied to user 'user_11766767'@'localhost' for column 'val' in table 'v11_merge' +update mysqltest1.t1 as t1, mysqltest2.v21_merge as v21 set v21.val= 'test12' + where t1.id= v21.id; +# As before, temptable views are not updateable. +update mysqltest2.t2 as t2, mysqltest1.v11_temp as v11 set v11.val= 'test13' + where t2.id= v11.id; +ERROR HY000: The target table v11 of the UPDATE is not updatable +update mysqltest1.t1 as t1, mysqltest2.v21_temp as v21 set v21.val= 'test14' + where t1.id= v21.id; +ERROR HY000: The target table v21 of the UPDATE is not updatable +# +# B) Now check that correct privileges are required on underlying +# tables. To simplify this part of test we will use SECURITY +# INVOKER views in it. +# +# B.1) In case when view is used for read only it is enough to have +# SELECT on its underlying tables. +update mysqltest2.t2 as t2, mysqltest2.v3_merge as v3 set t2.val= 'test15' + where t2.id= v3.id; +update mysqltest2.t2 as t2, mysqltest2.v3_temp as v3 set t2.val= 'test16' + where t2.id= v3.id; +# +# B.2) If view is updated, UPDATE privilege on the table being updated +# is required (since we already checked that temptable views are +# not updateable we don't test them here). +update mysqltest2.t2 as t2, mysqltest2.v3_merge as v3 set v3.val= 'test17' + where t2.id= v3.id; +ERROR HY000: View 'mysqltest2.v3_merge' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +update mysqltest1.t11 as t11, mysqltest2.v31 as v31 set v31.val= 'test18' + where t11.id= v31.id; +# +# C) Finally, check how we handle privilege checking in case when +# view is used through another view. Again we will use SECURITY +# INVOKER views for simplicity. +# +# C.1) As usual, when a view used by another view is going to be used +# in read-only fashion, only SELECT privilege is necessary. +update mysqltest1.t11 as t11, mysqltest2.v4 as v4 set v4.val= 'test19' + where t11.id= v4.id; +# +# C.2) If one of underlying tables of the view is updated then +# UPDATE on a view is necessary. +update mysqltest1.t11 as t11, mysqltest2.v41 as v4 set v4.val= 'test20' + where t11.id= v4.id; +ERROR HY000: View 'mysqltest2.v41' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +update mysqltest1.t11 as t11, mysqltest2.v42 as v4 set v4.val= 'test20' + where t11.id= v4.id; +# +# Clean-up. +# +# Switching to connection 'default'. +drop user user_11766767; +drop database mysqltest1; +drop database mysqltest2; +# +# WL#5275 Process subqueries in FROM clause in the same way as view +# Extended testing of column privileges for views +# +CREATE DATABASE test1; +USE test1; +CREATE USER user1@localhost; +CREATE TABLE test1.t1 +(cn CHAR(1), cs CHAR(1), ci CHAR(1), cu CHAR(1), cus CHAR(1)); +GRANT SELECT(cs,cus) ON test1.t1 TO user1@localhost; +GRANT INSERT(ci) ON test1.t1 TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.t1 TO user1@localhost; +INSERT INTO test1.t1 VALUES('0', '0', '0', '0', '0'); +CREATE TABLE test1.single (a INTEGER); +GRANT ALL PRIVILEGES ON test1.single TO user1@localhost; +INSERT INTO test1.single VALUES(1); +CREATE SQL SECURITY INVOKER VIEW test1.v1_none AS +SELECT * FROM test1.t1; +CREATE SQL SECURITY INVOKER VIEW test1.v1_all AS +SELECT * FROM test1.t1; +GRANT SELECT,INSERT,UPDATE,DELETE ON test1.v1_all TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_same AS +SELECT * FROM test1.t1; +GRANT SELECT(cs,cus) ON test1.v1_same TO user1@localhost; +GRANT INSERT(ci) ON test1.v1_same TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.v1_same TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_cross AS +SELECT * FROM test1.t1; +GRANT SELECT(cu,ci) ON test1.v1_cross TO user1@localhost; +GRANT INSERT(cus) ON test1.v1_cross TO user1@localhost; +GRANT UPDATE(cs) ON test1.v1_cross TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_middle AS +SELECT * FROM test1.t1; +GRANT SELECT(cus) ON test1.v1_middle TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_multi AS +SELECT * FROM test1.v1_middle; +GRANT SELECT(cs,cus) ON test1.v1_multi TO user1@localhost; +GRANT INSERT(ci) ON test1.v1_multi TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.v1_multi TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_renamed AS +SELECT cn AS cs, cn AS cx, cs AS cus, cs AS cy FROM test1.t1; +GRANT SELECT(cs,cus) ON test1.v1_renamed TO user1@localhost; +# Connect as user1 on database test +# Test access to a base table +SELECT cs, cus FROM test1.t1; +cs cus +0 0 +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cn FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT ci FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT cu FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT cs FROM test1.t1 WHERE cs = '0'; +cs +0 +SELECT cs FROM test1.t1 WHERE cus = '0'; +cs +0 +SELECT cs FROM test1.t1 WHERE cn = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cs FROM test1.t1 WHERE ci = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT cs FROM test1.t1 WHERE cu = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cs; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cus; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY ci; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cu; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cs) = '0'; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cus) = '0'; +c +1 +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cn) = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(ci) = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cu) = '0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cs); +c +1 +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cus); +c +1 +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cn); +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(ci); +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cu); +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +UPDATE test1.t1 SET cu='u'; +UPDATE test1.t1 SET cus='s' WHERE cus='0'; +UPDATE test1.t1, test1.single SET cu='u'; +UPDATE test1.t1, test1.single SET cus='s' WHERE cus='0'; +UPDATE test1.t1 SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +UPDATE test1.t1, test1.single SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +UPDATE test1.t1 SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +UPDATE test1.t1, test1.single SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +UPDATE test1.t1 SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +UPDATE test1.t1, test1.single SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +UPDATE test1.t1 SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +UPDATE test1.t1, test1.single SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(ci) VALUES('i'); +INSERT INTO test1.t1(ci) SELECT 'i' FROM test1.single; +INSERT INTO test1.t1(ci) VALUES('i') +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.t1(ci) SELECT 'i' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.t1(cn) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(cn) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(cs) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +INSERT INTO test1.t1(cs) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 't1' +INSERT INTO test1.t1(cu) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +INSERT INTO test1.t1(cu) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +INSERT INTO test1.t1(cus) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 't1' +INSERT INTO test1.t1(cus) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 't1' +INSERT INTO test1.t1(ci) VALUES('i') +ON DUPLICATE KEY UPDATE cn='u'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +INSERT INTO test1.t1(ci) SELECT 'i' FROM test1.single +ON DUPLICATE KEY UPDATE cn='u'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +DELETE FROM test1.t1; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 't1' +DELETE FROM test1.t1 WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 't1' +DELETE test1.t1 FROM test1.t1, test1.single WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 't1' +# Test access to derived tables +SELECT * FROM (SELECT cs FROM test1.t1) AS dt; +cs +0 +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cus FROM test1.t1) AS dt; +cus +s +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT cu FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT ci FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT MIN(cs) AS c FROM test1.t1) AS dt; +c +0 +SELECT * FROM (SELECT MIN(cus) AS c FROM test1.t1) AS dt; +c +s +SELECT * FROM (SELECT MIN(cn) AS c FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT MIN(cu) AS c FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT MIN(ci) AS c FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cs = '0') AS dt; +cs +0 +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cus = '0') AS dt; +cs +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cn = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT cs FROM test1.t1 WHERE ci = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT cs FROM test1.t1 WHERE cu = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cs) AS dt; +c +1 +4 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cus) AS dt; +c +1 +4 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cn) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY ci) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 GROUP BY cu) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cs) = '0') AS dt; +c +5 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cus) = '0') AS dt; +c +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cn) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(ci) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 HAVING MIN(cu) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cs)) AS dt; +c +5 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cus)) AS dt; +c +5 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cn)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(ci)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.t1 ORDER BY MIN(cu)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +# Test access to a view with no privileges +SELECT cs, cus FROM test1.v1_none; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none SET cu='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none, test1.single SET cu='x'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none SET cus='x' WHERE cus='0'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +UPDATE test1.v1_none, test1.single SET cus='x' WHERE cus='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) VALUES('x') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT, UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +INSERT INTO test1.v1_none(ci) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT, UPDATE command denied to user 'user1'@'localhost' for table 'v1_none' +DELETE FROM test1.v1_none; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_none' +DELETE FROM test1.v1_none WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_none' +DELETE test1.v1_none FROM test1.v1_none, test1.single WHERE cs='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 'v1_none' +# Test access to a view with all privileges +SELECT cs, cus FROM test1.v1_all; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT * FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cn FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT ci FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cu FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET cu='v'; +UPDATE test1.v1_all, test1.single SET cu='v'; +UPDATE test1.v1_all SET cus='t' WHERE cus='0'; +UPDATE test1.v1_all, test1.single SET cus='t' WHERE cus='0'; +UPDATE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET cs='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET cs='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET ci='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET ci='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all SET cu='x' WHERE cn='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_all, test1.single SET cu='x' WHERE cn='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(ci) VALUES('j'); +INSERT INTO test1.v1_all(ci) SELECT 'j' FROM test1.single; +INSERT INTO test1.v1_all(ci) VALUES('j') +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_all(ci) SELECT 'j' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_all(cn) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cn) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cs) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cs) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cu) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cu) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cus) VALUES('x'); +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cus) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cn) VALUES('x') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(cn) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(ci) VALUES('x') +ON DUPLICATE KEY UPDATE cn='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_all(ci) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cn='u'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_all; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_all WHERE cs='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE test1.v1_all FROM test1.v1_all, test1.single WHERE cs='0'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# Test access to a view with all privileges, inside derived table +SELECT * FROM (SELECT cs FROM test1.v1_all) AS dt; +cs +0 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cus FROM test1.v1_all) AS dt; +cus +s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cu FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT ci FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT MIN(cs) AS c FROM test1.v1_all) AS dt; +c +0 +SELECT * FROM (SELECT MIN(cus) AS c FROM test1.v1_all) AS dt; +c +s +SELECT * FROM (SELECT MIN(cn) AS c FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT MIN(cu) AS c FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT MIN(ci) AS c FROM test1.v1_all) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cs = '0') AS dt; +cs +0 +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cus = '0') AS dt; +cs +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cn = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE ci = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT cs FROM test1.v1_all WHERE cu = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cs) AS dt; +c +1 +8 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cus) AS dt; +c +1 +8 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cn) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY ci) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all GROUP BY cu) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cs) = '0') AS dt; +c +9 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cus) = '0') AS dt; +c +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cn) = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(ci) = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all HAVING MIN(cu) = '0') AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cs)) AS dt; +c +9 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cus)) AS dt; +c +9 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cn)) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(ci)) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_all ORDER BY MIN(cu)) AS dt; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# Test access to a view with same privileges as base table +SELECT cs, cus FROM test1.v1_same; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT * FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT cn FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT ci FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT cu FROM test1.v1_same; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +UPDATE test1.v1_same SET cu='w'; +UPDATE test1.v1_same, test1.single SET cu='w'; +UPDATE test1.v1_same SET cus='z' WHERE cus='0'; +UPDATE test1.v1_same, test1.single SET cus='z' WHERE cus='0'; +UPDATE test1.v1_same SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +UPDATE test1.v1_same SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET cs='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +UPDATE test1.v1_same SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +UPDATE test1.v1_same SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +UPDATE test1.v1_same, test1.single SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +INSERT INTO test1.v1_same(ci) VALUES('k'); +INSERT INTO test1.v1_same(ci) SELECT 'k' FROM test1.single; +INSERT INTO test1.v1_same(ci) VALUES('k') +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_same(ci) SELECT 'k' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +INSERT INTO test1.v1_same(cn) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +INSERT INTO test1.v1_same(cn) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +INSERT INTO test1.v1_same(cs) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +INSERT INTO test1.v1_same(cs) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_same' +INSERT INTO test1.v1_same(cu) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +INSERT INTO test1.v1_same(cu) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +INSERT INTO test1.v1_same(cus) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_same' +INSERT INTO test1.v1_same(cus) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_same' +DELETE FROM test1.v1_same; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_same' +DELETE FROM test1.v1_same WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_same' +DELETE test1.v1_same FROM test1.v1_same, test1.single WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_same' +# Test access to a view with same privileges, inside derived table +SELECT * FROM (SELECT cs FROM test1.v1_same) AS dt; +cs +0 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cus FROM test1.v1_same) AS dt; +cus +s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT cu FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT ci FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT MIN(cs) AS c FROM test1.v1_same) AS dt; +c +0 +SELECT * FROM (SELECT MIN(cus) AS c FROM test1.v1_same) AS dt; +c +s +SELECT * FROM (SELECT MIN(cn) AS c FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT MIN(cu) AS c FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT MIN(ci) AS c FROM test1.v1_same) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cs = '0') AS dt; +cs +0 +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cus = '0') AS dt; +cs +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cn = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE ci = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT cs FROM test1.v1_same WHERE cu = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cs) AS dt; +c +1 +12 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cus) AS dt; +c +1 +12 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cn) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY ci) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same GROUP BY cu) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cs) = '0') AS dt; +c +13 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cus) = '0') AS dt; +c +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cn) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(ci) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same HAVING MIN(cu) = '0') AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cs)) AS dt; +c +13 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cus)) AS dt; +c +13 +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cn)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(ci)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_same' +SELECT * FROM (SELECT COUNT(*) AS c FROM test1.v1_same ORDER BY MIN(cu)) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_same' +# Test access to a view with "mixed" privileges +SELECT cs, cus FROM test1.v1_cross; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_cross' +SELECT * FROM test1.v1_cross; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +SELECT cn FROM test1.v1_cross; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +SELECT ci FROM test1.v1_cross; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cu FROM test1.v1_cross; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_cross SET cu='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cu='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +UPDATE test1.v1_cross SET cus='x' WHERE cus='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cus='x' WHERE cus='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cus' in table 'v1_cross' +UPDATE test1.v1_cross SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cn='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +UPDATE test1.v1_cross SET cs='x'; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_cross, test1.single SET cs='x'; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_cross SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET ci='x'; +ERROR 42000: UPDATE command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +UPDATE test1.v1_cross SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +UPDATE test1.v1_cross, test1.single SET cu='x' WHERE cn='0'; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) VALUES('k') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(ci) SELECT 'k' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'ci' in table 'v1_cross' +INSERT INTO test1.v1_cross(cn) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +INSERT INTO test1.v1_cross(cn) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_cross' +INSERT INTO test1.v1_cross(cs) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_cross' +INSERT INTO test1.v1_cross(cs) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cs' in table 'v1_cross' +INSERT INTO test1.v1_cross(cu) VALUES('x'); +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +INSERT INTO test1.v1_cross(cu) SELECT 'x' FROM test1.single; +ERROR 42000: INSERT command denied to user 'user1'@'localhost' for column 'cu' in table 'v1_cross' +INSERT INTO test1.v1_cross(cus) VALUES('x'); +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_cross(cus) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_cross' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_cross; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_cross' +DELETE FROM test1.v1_cross WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_cross' +DELETE test1.v1_cross FROM test1.v1_cross, test1.single WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_cross' +# Test access to a multi-level view with no privileges +SELECT cs FROM test1.v1_multi; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cus FROM test1.v1_multi; +cus +s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +UPDATE test1.v1_multi SET cu='x'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_multi, test1.single SET cu='x'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_multi SET cus='x' WHERE cus='0'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE test1.v1_multi, test1.single SET cus='x' WHERE cus='0'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) VALUES('x'); +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) SELECT 'x' FROM test1.single; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) VALUES('x') +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +INSERT INTO test1.v1_multi(ci) SELECT 'x' FROM test1.single +ON DUPLICATE KEY UPDATE cu='u'; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DELETE FROM test1.v1_multi; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_multi' +DELETE FROM test1.v1_multi WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_multi' +DELETE test1.v1_multi FROM test1.v1_multi WHERE cs='0'; +ERROR 42000: DELETE command denied to user 'user1'@'localhost' for table 'v1_multi' +# Test access to a renamed view +SELECT cn FROM test1.v1_renamed; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 'v1_renamed' +SELECT cs FROM test1.v1_renamed; +ERROR HY000: View 'test1.v1_renamed' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT cus FROM test1.v1_renamed; +cus +0 +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT cx FROM test1.v1_renamed; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cx' in table 'v1_renamed' +SELECT cy FROM test1.v1_renamed; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cy' in table 'v1_renamed' +# Test access to a derived tables. Since they can be used in SELECT +# only, update functions are not needed +SELECT cs, cus FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cn FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT ci FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT cu FROM (SELECT * FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT cs, cus FROM test1.t1) AS dt; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT cs, cus FROM (SELECT cs, cus FROM test1.t1) AS dt; +cs cus +0 s +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +NULL NULL +SELECT cx FROM (SELECT CONCAT(cs, cus) AS cx FROM test1.t1) AS dt; +cx +0s +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +SELECT * FROM (SELECT cn FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cn' in table 't1' +SELECT * FROM (SELECT ci FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT * FROM (SELECT cu FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT CONCAT(cs, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT * FROM (SELECT CONCAT(ci, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +SELECT cx FROM (SELECT CONCAT(cs, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'cu' in table 't1' +SELECT cx FROM (SELECT CONCAT(ci, cu) AS cx FROM test1.t1) AS dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'ci' in table 't1' +DROP VIEW test1.v1_none, test1.v1_all, test1.v1_same; +DROP VIEW test1.v1_cross, test1.v1_middle, test1.v1_multi; +DROP VIEW test1.v1_renamed; +DROP USER user1@localhost; +CREATE USER user1@localhost; +GRANT SELECT(cs) ON test1.t1 TO user1@localhost; +CREATE DEFINER=user1@localhost SQL SECURITY DEFINER VIEW test1.v1_none AS +SELECT cs FROM test1.t1; +CREATE DEFINER=user1@localhost SQL SECURITY DEFINER VIEW test1.v1_middle AS +SELECT cs FROM test1.t1; +CREATE DEFINER=user1@localhost SQL SECURITY DEFINER VIEW test1.v1_multi AS +SELECT * FROM test1.v1_middle; +REVOKE SELECT(cs) ON test1.t1 FROM user1@localhost; +SHOW GRANTS FOR user1@localhost; +Grants for user1@localhost +GRANT USAGE ON *.* TO `user1`@`localhost` +SELECT * FROM test1.t1 LIMIT 1; +cn cs ci cu cus +0 0 0 w s +# Test access to a view with no privileges +SELECT cs FROM test1.v1_none; +ERROR HY000: View 'test1.v1_none' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +GRANT SELECT(cs) ON test1.t1 TO user1@localhost; +SELECT cs FROM test1.v1_none LIMIT 1; +cs +0 +SELECT cs FROM test1.v1_multi; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +GRANT SELECT(cs) ON test1.v1_middle TO user1@localhost; +SELECT cs FROM test1.v1_multi LIMIT 1; +cs +0 +REVOKE SELECT(cs) ON test1.t1 FROM user1@localhost; +SELECT cs FROM test1.v1_multi; +ERROR HY000: View 'test1.v1_multi' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP USER user1@localhost; +Warnings: +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a view. +DROP DATABASE test1; +# +# Bug#20032855 STRICT MODE REVEALS UNDERLYING PRIVILEGE ERROR +# +CREATE DATABASE test1; +CREATE USER 'user1'@'localhost'; +CREATE TABLE test1.t1 (cn CHAR(1), cs CHAR(1), ci CHAR(1), cu CHAR(1), cus CHAR(1)); +GRANT SELECT(cs,cus) ON test1.t1 TO user1@localhost; +GRANT INSERT(ci) ON test1.t1 TO user1@localhost; +GRANT UPDATE(cu,cus) ON test1.t1 TO user1@localhost; +CREATE SQL SECURITY INVOKER VIEW test1.v1_all AS +SELECT * FROM test1.t1; +GRANT SELECT,INSERT,UPDATE,DELETE ON test1.v1_all TO user1@localhost; +FLUSH PRIVILEGES; +connect con1,localhost,user1,,; +SET sql_mode='STRICT_ALL_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +UPDATE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW WARNINGS; +Level Code Message +Error 1356 View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SET sql_mode=''; +UPDATE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW WARNINGS; +Level Code Message +Error 1356 View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +UPDATE IGNORE test1.v1_all SET cn='x'; +ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SHOW WARNINGS; +Level Code Message +Error 1356 View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them + +# Bug21338077 HANDLE_FATAL_SIGNAL (SIG=11) IN __STPCPY_SSE2_UNALIGNED FROM MY_STPCPY + +CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d1; +PREPARE stmt FROM 'SELECT * FROM v1'; +EXECUTE stmt; +1 +1 +DROP PREPARE stmt; +DROP VIEW v1; +connection default; +disconnect con1; +DROP USER 'user1'@'localhost'; +DROP DATABASE test1; +set GLOBAL sql_mode= @orig_sql_mode_global; +set SESSION sql_mode= @orig_sql_mode_session; +# +# WL#2284: Increase the length of a user name +# +CREATE DATABASE test1; +CREATE TABLE test1.t1 ( +int_field INTEGER UNSIGNED NOT NULL, +char_field CHAR(10), +INDEX(`int_field`) +); +use test; +CREATE USER user_name_len_22_01234@localhost; +CREATE USER user_name_len_32_012345678901234@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_22_01234@localhost; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_32_012345678901234@localhost; +# Check that user_name_len_22_01234 has no SELECT permission ON t1 +connect con_user_22,localhost,user_name_len_22_01234,,test; +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_22_01234'@'localhost' for table 't1' +# Check that user_name_len_32_012345678901234 has no SELECT permission ON t1 +connect con_user_32,localhost,user_name_len_32_012345678901234,,test; +SELECT * FROM test1.t1; +ERROR 42000: SELECT command denied to user 'user_name_len_32_012345678901234'@'localhost' for table 't1' +connection default; +GRANT ALL ON test1.* TO user_name_len_32_012345678901234@localhost; +CREATE DEFINER=user_name_len_32_012345678901234@localhost +VIEW test1.v1 AS SELECT int_field FROM test1.t1; +GRANT SELECT ON test1.v1 TO user_name_len_22_01234@localhost; +# Now user_name_len_22_01234 should be able to SELECT int_field FROM +# test1.t1 by using test1.v1 +connection con_user_22; +SELECT * FROM test1.v1; +int_field +connection default; +CREATE DEFINER=user_name_len_33_0123456789012345@localhost +VIEW test1.v2 AS SELECT int_field FROM test1.t1; +ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32) +DROP DATABASE test1; +DROP USER user_name_len_22_01234@localhost; +DROP USER user_name_len_32_012345678901234@localhost; +# +# WL#9262: All system tables should support 32 character length user names +# +#Create user with max length (max username length + max hostname length) +CREATE USER user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +CREATE TABLE silly_one (ID INT); +CREATE DEFINER=user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char VIEW silly_view AS SELECT * FROM silly_one; +SELECT DEFINER FROM information_schema.VIEWS WHERE TABLE_NAME='silly_view'; +DEFINER +user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char +DROP USER user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; +Warnings: +Warning 4005 User 'user_name_robert_golebiowski'@'oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char' is referenced as a definer account in a view. +DROP VIEW silly_view; +DROP TABLE silly_one; +# +# Bug #27094955 -- INCORRECT CHECKING FOR FILE PRIVILEGE IN CASE QUERY IS RUN AGAINST A VIEW +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +CREATE USER `u1`@`localhost`; +CREATE USER `u2`@`localhost`; +# Create a view for that a user specified as definer doesn't have the FILE privilege +CREATE DEFINER=`u2`@`localhost` VIEW v1 AS SELECT a FROM t1; +# Grant the FILE privilege to a user who will run the SELECT INTO OUTFILE against the view v1 +GRANT FILE ON *.* TO `u1`@`localhost`; +connect con1,localhost,u1,,; +connection con1; +# Run SELECT from a view with the clause "INTO OUTFILE". +# Without the patch this query would failed with error ER_ACCESS_DENIED_ERROR. +SELECT a INTO OUTFILE '' +FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' +LINES TERMINATED BY '\n' +FROM v1; +disconnect con1; +connection default; +1 +# Now revoke the privilege FILE from the user u1@localhost +# in order to check that without this privilege the statement +# "SELECT INTO OUTFILE .. FROM view" will fail. That is, check that +# the privilege FILE is still taken into account during processing +# when the clause INTO OUTFILE is specified. +REVOKE FILE ON *.* FROM `u1`@`localhost`; +connect con1,localhost,u1,,; +connection con1; +# Check that querying from v1 with the clause INTO OUTFILE is failed in case +# a user who running a query doesn't have the FILE privilege +SELECT a INTO OUTFILE '' +FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' +LINES TERMINATED BY '\n' +FROM v1; +ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation +disconnect con1; +connection default; +DROP USER `u1`@`localhost`; +DROP USER `u2`@`localhost`; +Warnings: +Warning 4005 User 'u2'@'localhost' is referenced as a definer account in a view. +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/r/window_functions_explain.result-pq b/mysql-test/r/window_functions_explain.result-pq new file mode 100644 index 000000000..96195c2aa --- /dev/null +++ b/mysql-test/r/window_functions_explain.result-pq @@ -0,0 +1,16944 @@ +# Explain of SQL window functions. +# ---------------------------------------------------------------------- +SET NAMES utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Single window function (plus ORDER BY). +CREATE TABLE t(i INT, j INT); +INSERT INTO t VALUES (1,1), (1,4), (1,2), (1,4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +Single partition, no sorting +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=TRADITIONAL SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc +With LIMIT +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC LIMIT 3; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.65" + }, + "ordering_operation": { + "using_filesort": true, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc limit 3 +Single ordered partition +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j ROWS UNBOUNDED PRECEDING) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +EXPLAIN FORMAT=TRADITIONAL SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` +View with window function +CREATE VIEW v AS +SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t; +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t`.`i` AS `i`,`t`.`j` AS `j`,sum((`t`.`i` + `t`.`j`)) OVER (ORDER BY `t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `t` utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.95" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.55", + "eval_cost": "0.40", + "prefix_cost": "2.95", + "data_read_per_join": "128" + }, + "used_columns": [ + "i", + "j", + "foo" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "4.65" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`i` AS `i`,`test`.`v`.`j` AS `j`,`test`.`v`.`foo` AS `foo` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` +EXPLAIN FORMAT=JSON SELECT i, j, SUM(i+j) OVER (ORDER BY j DESC ROWS UNBOUNDED PRECEDING) foo FROM t ORDER BY foo DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.65" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "4.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.40", + "prefix_cost": "0.65", + "data_read_per_join": "64" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum((`test`.`t`.`i` + `test`.`t`.`j`)) OVER (ORDER BY `test`.`t`.`j` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` order by `foo` desc +TRUNCATE TABLE t; +Check my_decimal bug: no warning if c=a+b and c is one of a,b... just fails over 9 digits +INSERT INTO t VALUES (999961560, DEFAULT), (44721, DEFAULT); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT SUM(i) OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`i`) OVER () AS `SUM(i) OVER ()` from `test`.`t` +DROP TABLE t; +CREATE TABLE t(i INT, j INT, k INT); +INSERT INTO t VALUES (1,1,1), (1,4,1), (1,2,1), (1,4,1); +INSERT INTO t VALUES (1,1,2), (1,4,2), (1,2,2), (1,4,2); +INSERT INTO t VALUES (1,1,3), (1,4,3), (1,2,3), (1,4,3); +INSERT INTO t VALUES (1,1,4), (1,4,4), (1,2,4), (1,4,4); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +---------------------------------------------------------------------- +- Combination with GROUP BY +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT k, SUM(k) OVER (ROWS UNBOUNDED PRECEDING) wf FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "k" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `wf` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT k, MIN(i), SUM(j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) wf FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "i", + "j", + "k" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,min(`test`.`t`.`i`) AS `MIN(i)`,sum(`test`.`t`.`j`) AS `SUM(j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `wf` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, MIN(i), SUM(j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) wf FROM t GROUP BY (k) ORDER BY wf DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "ordering_operation": { + "using_filesort": true, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "i", + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,min(`test`.`t`.`i`) AS `MIN(i)`,sum(`test`.`t`.`j`) AS `SUM(j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `wf` from `test`.`t` group by `test`.`t`.`k` order by `wf` desc +EXPLAIN FORMAT=JSON SELECT k, GROUP_CONCAT(j ORDER BY j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,group_concat(`test`.`t`.`j` order by `test`.`t`.`j` ASC separator ',') AS `GROUP_CONCAT(j ORDER BY j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, AVG(DISTINCT j), SUM(k) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,avg(distinct `test`.`t`.`j`) AS `AVG(DISTINCT j)`,sum(`test`.`t`.`k`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, GROUP_CONCAT(j ORDER BY j), SUM(k+1) OVER (ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,group_concat(`test`.`t`.`j` order by `test`.`t`.`j` ASC separator ',') AS `GROUP_CONCAT(j ORDER BY j)`,sum((`test`.`t`.`k` + 1)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +EXPLAIN FORMAT=JSON SELECT k, GROUP_CONCAT(j ORDER BY j), SUM(k+1) OVER (ORDER BY k DESC ROWS UNBOUNDED PRECEDING) foo FROM t GROUP BY (k); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "33.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`k` desc" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "16.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "16.00" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.60", + "prefix_cost": "1.85", + "data_read_per_join": "256" + }, + "used_columns": [ + "j", + "k" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`k` AS `k`,group_concat(`test`.`t`.`j` order by `test`.`t`.`j` ASC separator ',') AS `GROUP_CONCAT(j ORDER BY j)`,sum((`test`.`t`.`k` + 1)) OVER (ORDER BY `test`.`t`.`k` desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `foo` from `test`.`t` group by `test`.`t`.`k` +DROP TABLE t; +---------------------------------------------------------------------- +- Some RANK, DENSE_RANK tests +---------------------------------------------------------------------- +CREATE TABLE t1 (id INTEGER, sex CHAR(1)); +INSERT INTO t1 VALUES (1, 'M'), +(2, 'F'), +(3, 'F'), +(4, 'F'), +(5, 'M'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +CREATE TABLE t2 (user_id INTEGER NOT NULL, date DATE); +INSERT INTO t2 VALUES (1, '2002-06-09'), +(2, '2002-06-09'), +(1, '2002-06-09'), +(3, '2002-06-09'), +(4, '2002-06-09'), +(4, '2002-06-09'), +(5, '2002-06-09'); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN FORMAT=JSON SELECT RANK() OVER (ORDER BY user_id) r FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER (ORDER BY `test`.`t2`.`user_id` ) AS `r` from `test`.`t2` +EXPLAIN FORMAT=JSON SELECT DENSE_RANK() OVER (ORDER BY user_id) r FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "functions": [ + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select dense_rank() OVER (ORDER BY `test`.`t2`.`user_id` ) AS `r` from `test`.`t2` +EXPLAIN FORMAT=JSON SELECT sex, SUM(DISTINCT id) AS uids FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex ORDER BY uids; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.50" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,sum(distinct `test`.`t1`.`id`) AS `uids` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` order by `uids` +EXPLAIN FORMAT=JSON SELECT id, sex, RANK() OVER (ORDER BY sex) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.75" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `RANK() OVER (ORDER BY sex)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, sex, DENSE_RANK() OVER (ORDER BY sex) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.75" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,dense_rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `DENSE_RANK() OVER (ORDER BY sex)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT sex, RANK() OVER (ORDER BY sex DESC) `rank`, AVG(DISTINCT id) AS uids FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.50" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`u`.`sex` desc ) AS `rank`,avg(distinct `test`.`t1`.`id`) AS `uids` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` order by `test`.`u`.`sex` +Explicit window definition, WINDOW DESC ordering from GROUP BY +EXPLAIN FORMAT=JSON SELECT sex, AVG(id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(id)); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.50" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "avg(`id`)" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(`test`.`u`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(`test`.`u`.`id`) ) +Explicit window definition, window ordering from DISTINCT GROUP BY +EXPLAIN FORMAT=JSON SELECT sex, AVG(DISTINCT id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(DISTINCT id) DESC) ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.50" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(distinct `id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(distinct `test`.`t1`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(distinct `test`.`t1`.`id`) desc ) order by `test`.`u`.`sex` +Explicit window definition, window ordering from GROUP BY, final ORDER BY +EXPLAIN FORMAT=JSON SELECT sex, AVG(id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(id) DESC) +ORDER BY `rank` DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.50" + }, + "ordering_operation": { + "using_filesort": true, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 5, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "4.50", + "data_read_per_join": "80" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(`test`.`u`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(`test`.`u`.`id`) desc ) order by `rank` desc +EXPLAIN FORMAT=TRADITIONAL SELECT sex, AVG(id) AS uids, RANK() OVER w `rank` FROM t1 u, t2 +WHERE t2.user_id = u.id GROUP BY sex +WINDOW w AS (ORDER BY AVG(id) DESC) +ORDER BY `rank` DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE u NULL ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 7 14.29 Using where; Using join buffer (hash join) +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `test`.`u`.`sex` AS `sex`,avg(`test`.`u`.`id`) AS `uids`,rank() OVER `w` AS `rank` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` window `w` AS (ORDER BY avg(`test`.`u`.`id`) desc ) order by `rank` desc +With NULLs +INSERT INTO t1 VALUES (10, NULL), (11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, sex, RANK() OVER w, DENSE_RANK() OVER w FROM t1 +WINDOW w AS (ORDER BY sex) ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank", + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER `w` AS `RANK() OVER w`,dense_rank() OVER `w` AS `DENSE_RANK() OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`sex` ) order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, sex, RANK() OVER (ORDER BY sex DESC) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` desc ) AS `RANK() OVER (ORDER BY sex DESC)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id value, +SUM(id) OVER (ROWS UNBOUNDED PRECEDING) +FROM t1 u, t2 WHERE t2.user_id = u.id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.10" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`u`.`id` AS `value`,sum(`test`.`u`.`id`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) +Aggregate with GROUP BY arguments to window function +EXPLAIN FORMAT=JSON SELECT AVG(id) average, +SUM(AVG(id)) OVER (ROWS UNBOUNDED PRECEDING) +FROM t1 u, t2 WHERE t2.user_id = u.id GROUP BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.10" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`u`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`u`.`id`) AS `average`,sum(avg(`test`.`u`.`id`)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(AVG(id)) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` `u` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`u`.`id`) group by `test`.`u`.`sex` +Aggregate with GROUP BY in window's ORDER BY clause, with aggregate present in +SELECT list or not. +EXPLAIN FORMAT=JSON SELECT sex, AVG(id), RANK() OVER (ORDER BY AVG(id) DESC) FROM t1 GROUP BY sex ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,avg(`test`.`t1`.`id`) AS `AVG(id)`,rank() OVER (ORDER BY avg(`test`.`t1`.`id`) desc ) AS `RANK() OVER (ORDER BY AVG(id) DESC)` from `test`.`t1` group by `test`.`t1`.`sex` order by `test`.`t1`.`sex` +EXPLAIN FORMAT=JSON SELECT sex, RANK() OVER (ORDER BY AVG(id) DESC) FROM t1 GROUP BY sex ORDER BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`) desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY avg(`test`.`t1`.`id`) desc ) AS `RANK() OVER (ORDER BY AVG(id) DESC)` from `test`.`t1` group by `test`.`t1`.`sex` order by `test`.`t1`.`sex` +Implicit group aggregate arguments to window function and in +window's ORDER BY clause +EXPLAIN FORMAT=JSON SELECT RANK() OVER (ORDER BY AVG(id)) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER (ORDER BY avg(`test`.`t1`.`id`) ) AS `RANK() OVER (ORDER BY AVG(id))` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id), RANK() OVER (ORDER BY AVG(id)) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) AS `AVG(id)`,rank() OVER (ORDER BY avg(`test`.`t1`.`id`) ) AS `RANK() OVER (ORDER BY AVG(id))` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id), SUM(AVG(id)) OVER (ORDER BY AVG(id) ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) AS `AVG(id)`,sum(avg(`test`.`t1`.`id`)) OVER (ORDER BY avg(`test`.`t1`.`id`) ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(AVG(id)) OVER (ORDER BY AVG(id) ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +Several partitions, several window functions over the same window +EXPLAIN FORMAT=JSON SELECT sex, id, RANK() OVER (PARTITION BY sex ORDER BY id DESC) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,rank() OVER (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` desc ) AS `RANK() OVER (PARTITION BY sex ORDER BY id DESC)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT sex, id, RANK() OVER (PARTITION BY sex ORDER BY id ASC) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,rank() OVER (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ) AS `RANK() OVER (PARTITION BY sex ORDER BY id ASC)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT sex, id, SUM(id) OVER w summ, RANK() OVER w `rank` FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ASC ROWS UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `summ`,rank() OVER `w` AS `rank` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT sex, id, SUM(id) OVER w summ, RANK() OVER w `rank` FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ASC ROWS UNBOUNDED PRECEDING) ORDER BY summ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `summ`,rank() OVER `w` AS `rank` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) order by `summ` +CREATE TABLE t(d decimal(10,2), date DATE); +INSERT INTO t values (10.4, '2002-06-09'), +(20.5, '2002-06-09'), +(10.4, '2002-06-10'), +(3, '2002-06-09'), +(40.2, '2015-08-01'), +(40.2, '2002-06-09'), +(5, '2015-08-01'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT RANK() OVER (ORDER BY d) AS `rank`, d, date FROM t) alias ORDER BY `rank`, d, date; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "168" + }, + "used_columns": [ + "rank", + "d", + "date" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "d", + "date" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`rank` AS `rank`,`alias`.`d` AS `d`,`alias`.`date` AS `date` from (/* select#2 */ select rank() OVER (ORDER BY `test`.`t`.`d` ) AS `rank`,`test`.`t`.`d` AS `d`,`test`.`t`.`date` AS `date` from `test`.`t`) `alias` order by `alias`.`rank`,`alias`.`d`,`alias`.`date` +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT RANK() OVER (ORDER BY date) AS `rank`, date, d FROM t) alias ORDER BY `rank`, d DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "168" + }, + "used_columns": [ + "rank", + "date", + "d" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`date`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "d", + "date" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`rank` AS `rank`,`alias`.`date` AS `date`,`alias`.`d` AS `d` from (/* select#2 */ select rank() OVER (ORDER BY `test`.`t`.`date` ) AS `rank`,`test`.`t`.`date` AS `date`,`test`.`t`.`d` AS `d` from `test`.`t`) `alias` order by `alias`.`rank`,`alias`.`d` desc +DROP TABLE t; +Check that SUM stays that same when it sees NULL values +CREATE TABLE t(i INT, j INT); +INSERT INTO t VALUES (1,NULL), +(1,NULL), +(1,1), +(1,NULL), +(1,2), +(2,1), +(2,2), +(2,NULL), +(2,NULL); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT i, j, SUM(j) OVER (PARTITION BY i ORDER BY j ROWS UNBOUNDED PRECEDING) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum(`test`.`t`.`j`) OVER (PARTITION BY `test`.`t`.`i` ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(j) OVER (PARTITION BY i ORDER BY j ROWS UNBOUNDED PRECEDING)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT SUM(id), SUM(SUM(id)) OVER (ORDER BY sex ROWS UNBOUNDED PRECEDING) FROM t1,t2 WHERE t1.id=t2.user_id GROUP BY sex; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `SUM(id)`,sum(sum(`test`.`t1`.`id`)) OVER (ORDER BY `test`.`t1`.`sex` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(SUM(id)) OVER (ORDER BY sex ROWS UNBOUNDED PRECEDING)` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) group by `test`.`t1`.`sex` +EXPLAIN FORMAT=JSON SELECT RANK() OVER w FROM t1,t2 WHERE t1.id=t2.user_id WINDOW w AS (PARTITION BY id ORDER BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT RANK() OVER w FROM (SELECT * FROM t1,t2 WHERE t1.id=t2.user_id) t WINDOW w AS (PARTITION BY id ORDER BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) +Check that aggregate window functions that reference columns not in the SELECT list work +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER (PARTITION BY sex ORDER BY id ROWS UNBOUNDED PRECEDING) summ, sex FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `summ`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` +---------------------------------------------------------------------- +- Some ROW_NUMBER tests +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT user_id, ROW_NUMBER() OVER (PARTITION BY user_id) FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,row_number() OVER (PARTITION BY `test`.`t2`.`user_id` ) AS `ROW_NUMBER() OVER (PARTITION BY user_id)` from `test`.`t2` +EXPLAIN FORMAT=JSON SELECT * FROM t1,t2 WHERE t1.id=t2.user_id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.10" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "168" + }, + "used_columns": [ + "id", + "sex", + "user_id", + "date" + ], + "query_block": { + "cost_info": { + "query_cost": "6.10" + }, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,`test`.`t2`.`user_id` AS `user_id`,`test`.`t2`.`date` AS `date` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) +EXPLAIN FORMAT=JSON SELECT sex, id, date, ROW_NUMBER() OVER w AS row_no, RANK() OVER w AS `rank` FROM t1,t2 +WHERE t1.id=t2.user_id +WINDOW w AS (PARTITION BY id ORDER BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,`test`.`t2`.`date` AS `date`,row_number() OVER `w` AS `row_no`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT sex, id, date, ROW_NUMBER() OVER w AS row_no, RANK() OVER w AS `rank` FROM t1,t2 +WHERE t1.id=t2.user_id +WINDOW w AS (PARTITION BY date ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,`test`.`t2`.`date` AS `date`,row_number() OVER `w` AS `row_no`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) +---------------------------------------------------------------------- +- Window function in subquery +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT date,id, RANK() OVER w AS `rank` FROM t1,t2 WINDOW w AS (PARTITION BY date ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "55.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "49.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 49, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.90", + "prefix_cost": "6.10", + "data_read_per_join": "784" + }, + "used_columns": [ + "date" + ] + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`date` AS `date`,`test`.`t1`.`id` AS `id`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT * from (SELECT date,id, RANK() OVER w AS `rank` FROM t1,t2 WINDOW w AS (PARTITION BY date ORDER BY id)) t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.01" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 49, + "rows_produced_per_join": 49, + "filtered": "100.00", + "cost_info": { + "read_cost": "3.11", + "eval_cost": "4.90", + "prefix_cost": "8.01", + "data_read_per_join": "1K" + }, + "used_columns": [ + "date", + "id", + "rank" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "55.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "49.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 49, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.90", + "prefix_cost": "6.10", + "data_read_per_join": "784" + }, + "used_columns": [ + "date" + ] + } + } + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`date` AS `date`,`t`.`id` AS `id`,`t`.`rank` AS `rank` from (/* select#2 */ select `test`.`t2`.`date` AS `date`,`test`.`t1`.`id` AS `id`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) ) `t` +---------------------------------------------------------------------- +- Window function in parent and subquery +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT t.*, SUM(t.`rank`) OVER (ROWS UNBOUNDED PRECEDING) FROM +(SELECT sex, id, date, ROW_NUMBER() OVER w AS row_no, RANK() OVER w AS `rank` FROM t1,t2 +WHERE t1.id=t2.user_id +WINDOW w AS (PARTITION BY date ORDER BY id) +) AS t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "280" + }, + "used_columns": [ + "sex", + "id", + "date", + "row_no", + "rank" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "13.10" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`date`", + "`id`" + ], + "functions": [ + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "14.29", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "6.10", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ], + "attached_condition": "(`test`.`t2`.`user_id` = `test`.`t1`.`id`)" + } + } + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`sex` AS `sex`,`t`.`id` AS `id`,`t`.`date` AS `date`,`t`.`row_no` AS `row_no`,`t`.`rank` AS `rank`,sum(`t`.`rank`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(t.``rank``) OVER (ROWS UNBOUNDED PRECEDING)` from (/* select#2 */ select `test`.`t1`.`sex` AS `sex`,`test`.`t1`.`id` AS `id`,`test`.`t2`.`date` AS `date`,row_number() OVER `w` AS `row_no`,rank() OVER `w` AS `rank` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`user_id` = `test`.`t1`.`id`) window `w` AS (PARTITION BY `test`.`t2`.`date` ORDER BY `test`.`t1`.`id` ) ) `t` +---------------------------------------------------------------------- +- Multiple windows +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT t1.*, RANK() OVER (ORDER BY sex), SUM(id) OVER (ORDER BY sex,id ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "14.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `RANK() OVER (ORDER BY sex)`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY sex,id ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT * from (SELECT t1.*, SUM(id) OVER (ROWS UNBOUNDED PRECEDING), RANK() OVER (ORDER BY sex) FROM t1) alias ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "280" + }, + "used_columns": [ + "id", + "sex", + "SUM(id) OVER (ROWS UNBOUNDED PRECEDING)", + "RANK() OVER (ORDER BY sex)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`id` AS `id`,`alias`.`sex` AS `sex`,`alias`.`SUM(id) OVER (ROWS UNBOUNDED PRECEDING)` AS `SUM(id) OVER (ROWS UNBOUNDED PRECEDING)`,`alias`.`RANK() OVER (ORDER BY sex)` AS `RANK() OVER (ORDER BY sex)` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,sum(`test`.`t1`.`id`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ROWS UNBOUNDED PRECEDING)`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `RANK() OVER (ORDER BY sex)` from `test`.`t1`) `alias` order by `alias`.`id` +EXPLAIN FORMAT=JSON SELECT t1.*, SUM(id) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING), +RANK() OVER (ORDER BY sex,id), +ROW_NUMBER() OVER (ORDER BY sex,id) +FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "14.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "14.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING)`,rank() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` ) AS `RANK() OVER (ORDER BY sex,id)`,row_number() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` ) AS `ROW_NUMBER() OVER (ORDER BY sex,id)` from `test`.`t1` +a little more windows + subquery +EXPLAIN FORMAT=JSON SELECT t.*, SUM(id + r00 + r01) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING) AS s FROM ( +SELECT t1.*, +RANK() OVER (ORDER BY sex) AS r00, +RANK() OVER (ORDER BY sex DESC) AS r01, +RANK() OVER (ORDER BY sex, id DESC) AS r02, +RANK() OVER (PARTITION BY id ORDER BY sex) AS r03, +RANK() OVER (ORDER BY sex) AS r04, +RANK() OVER (ORDER BY sex) AS r05, +RANK() OVER (ORDER BY sex) AS r06, +RANK() OVER (ORDER BY sex) AS r07, +RANK() OVER (ORDER BY sex) AS r08, +RANK() OVER (ORDER BY sex) AS r09, +RANK() OVER (ORDER BY sex) AS r10, +RANK() OVER (ORDER BY sex) AS r11, +RANK() OVER (ORDER BY sex) AS r12, +RANK() OVER (ORDER BY sex) AS r13, +RANK() OVER (ORDER BY sex) AS r14 +FROM t1) t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "952" + }, + "used_columns": [ + "id", + "sex", + "r00", + "r01", + "r02", + "r03", + "r04", + "r05", + "r06", + "r07", + "r08", + "r09", + "r10", + "r11", + "r12", + "r13", + "r14" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "28.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 5, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 6, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 7, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 8, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 9, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 10, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 11, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 12, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 13, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 14, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 15, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "28.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`id` AS `id`,`t`.`sex` AS `sex`,`t`.`r00` AS `r00`,`t`.`r01` AS `r01`,`t`.`r02` AS `r02`,`t`.`r03` AS `r03`,`t`.`r04` AS `r04`,`t`.`r05` AS `r05`,`t`.`r06` AS `r06`,`t`.`r07` AS `r07`,`t`.`r08` AS `r08`,`t`.`r09` AS `r09`,`t`.`r10` AS `r10`,`t`.`r11` AS `r11`,`t`.`r12` AS `r12`,`t`.`r13` AS `r13`,`t`.`r14` AS `r14`,sum(((`t`.`id` + `t`.`r00`) + `t`.`r01`)) OVER (ORDER BY `t`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `s` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r00`,rank() OVER (ORDER BY `test`.`t1`.`sex` desc ) AS `r01`,rank() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` desc ) AS `r02`,rank() OVER (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) AS `r03`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r04`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r05`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r06`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r07`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r08`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r09`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r10`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r11`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r12`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r13`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r14` from `test`.`t1`) `t` +With LIMIT +EXPLAIN FORMAT=JSON SELECT t.*, SUM(id + r00 + r01) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING) AS s FROM ( +SELECT t1.*, +RANK() OVER (ORDER BY sex) AS r00, +RANK() OVER (ORDER BY sex DESC) AS r01, +RANK() OVER (ORDER BY sex, id DESC) AS r02, +RANK() OVER (PARTITION BY id ORDER BY sex) AS r03, +RANK() OVER (ORDER BY sex) AS r04, +RANK() OVER (ORDER BY sex) AS r05, +RANK() OVER (ORDER BY sex) AS r06, +RANK() OVER (ORDER BY sex) AS r07, +RANK() OVER (ORDER BY sex) AS r08, +RANK() OVER (ORDER BY sex) AS r09, +RANK() OVER (ORDER BY sex) AS r10, +RANK() OVER (ORDER BY sex) AS r11, +RANK() OVER (ORDER BY sex) AS r12, +RANK() OVER (ORDER BY sex) AS r13, +RANK() OVER (ORDER BY sex) AS r14 +FROM t1 LIMIT 4) t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "4.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 4, + "rows_produced_per_join": 4, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.55", + "eval_cost": "0.40", + "prefix_cost": "2.95", + "data_read_per_join": "544" + }, + "used_columns": [ + "id", + "sex", + "r00", + "r01", + "r02", + "r03", + "r04", + "r05", + "r06", + "r07", + "r08", + "r09", + "r10", + "r11", + "r12", + "r13", + "r14" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "28.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 5, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 6, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 7, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 8, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 9, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 10, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 11, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 12, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 13, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 14, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 15, + "using_temporary_table": true, + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`", + "`sex`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`sex` desc" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id` desc" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "28.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `t`.`id` AS `id`,`t`.`sex` AS `sex`,`t`.`r00` AS `r00`,`t`.`r01` AS `r01`,`t`.`r02` AS `r02`,`t`.`r03` AS `r03`,`t`.`r04` AS `r04`,`t`.`r05` AS `r05`,`t`.`r06` AS `r06`,`t`.`r07` AS `r07`,`t`.`r08` AS `r08`,`t`.`r09` AS `r09`,`t`.`r10` AS `r10`,`t`.`r11` AS `r11`,`t`.`r12` AS `r12`,`t`.`r13` AS `r13`,`t`.`r14` AS `r14`,sum(((`t`.`id` + `t`.`r00`) + `t`.`r01`)) OVER (ORDER BY `t`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `s` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r00`,rank() OVER (ORDER BY `test`.`t1`.`sex` desc ) AS `r01`,rank() OVER (ORDER BY `test`.`t1`.`sex`,`test`.`t1`.`id` desc ) AS `r02`,rank() OVER (PARTITION BY `test`.`t1`.`id` ORDER BY `test`.`t1`.`sex` ) AS `r03`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r04`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r05`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r06`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r07`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r08`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r09`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r10`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r11`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r12`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r13`,rank() OVER (ORDER BY `test`.`t1`.`sex` ) AS `r14` from `test`.`t1` limit 4) `t` +---------------------------------------------------------------------- +- SUM, AVG, COUNT with frames +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w * 2, AVG(id) OVER w, COUNT(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select (sum(`test`.`t1`.`id`) OVER `w` * 2) AS `SUM(id) OVER w * 2`,avg(`test`.`t1`.`id`) OVER `w` AS `AVG(id) OVER w`,count(`test`.`t1`.`id`) OVER `w` AS `COUNT(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT id, SUM(id) OVER w, COUNT(*) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex) +) alias ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.29" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "280" + }, + "used_columns": [ + "id", + "SUM(id) OVER w", + "COUNT(*) OVER w", + "sex" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`id` AS `id`,`alias`.`SUM(id) OVER w` AS `SUM(id) OVER w`,`alias`.`COUNT(*) OVER w` AS `COUNT(*) OVER w`,`alias`.`sex` AS `sex` from (/* select#2 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,count(0) OVER `w` AS `COUNT(*) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ) ) `alias` order by `alias`.`id` +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w FROM t1 WINDOW w AS (PARTITION BY sex); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ) +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +try the same as a view +CREATE VIEW v AS +SELECT id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t1`.`id` AS `id`,sum(`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`t1`.`sex` AS `sex` from `t1` window `w` AS (PARTITION BY `t1`.`sex` ORDER BY `t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "224" + }, + "used_columns": [ + "id", + "SUM(id) OVER w", + "sex" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`SUM(id) OVER w` AS `SUM(id) OVER w`,`test`.`v`.`sex` AS `sex` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT SUM(id) OVER w, COUNT(*) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,count(0) OVER `w` AS `COUNT(*) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER (ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "avg" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `AVG(id) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER w, COUNT(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `AVG(id) OVER w`,count(`test`.`t1`.`id`) OVER `w` AS `COUNT(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +AVG, SUM with double type +CREATE TABLE td(d DOUBLE); +INSERT INTO td VALUES (2),(2),(3),(1),(1.2),(NULL); +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ORDER BY d), AVG(d) OVER (ORDER BY d) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `SUM(d) OVER (ORDER BY d)`,avg(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `AVG(d) OVER (ORDER BY d)` from `test`.`td` +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ORDER BY d), AVG(d) OVER () FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `SUM(d) OVER (ORDER BY d)`,avg(`test`.`td`.`d`) OVER () AS `AVG(d) OVER ()` from `test`.`td` +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ORDER BY d), AVG(d) OVER (ORDER BY d ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ) AS `SUM(d) OVER (ORDER BY d)`,avg(`test`.`td`.`d`) OVER (ORDER BY `test`.`td`.`d` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS `AVG(d) OVER (ORDER BY d ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)` from `test`.`td` +Check system variable "windowing_use_high_precision" +TRUNCATE td; +INSERT INTO td VALUES (1.7976931348623157E+307), (1); +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +should be default off: +SHOW VARIABLES LIKE 'windowing_use_high_precision'; +Variable_name Value +windowing_use_high_precision ON +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS `SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING)` from `test`.`td` +allow unsafe optimization: result changes +SET SESSION windowing_use_high_precision=FALSE; +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM td; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS `SUM(d) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING)` from `test`.`td` +SET SESSION windowing_use_high_precision=TRUE; +bugfix: AVG for moving range frame +TRUNCATE td; +INSERT INTO td VALUES (10),(1),(2),(3),(4),(5),(6),(7),(8),(9); +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=FALSE; +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=TRUE; +INSERT INTO td SELECT * FROM td; +ANALYZE TABLE td; +Table Op Msg_type Msg_text +test.td analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=FALSE; +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, AVG(d) OVER w FROM td +WINDOW w AS (ORDER BY d RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "20.00" + }, + "table": { + "table_name": "td", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td`.`d` AS `d`,sum(`test`.`td`.`d`) OVER `w` AS `SUM(d) OVER w`,avg(`test`.`td`.`d`) OVER `w` AS `AVG(d) OVER w` from `test`.`td` window `w` AS (ORDER BY `test`.`td`.`d` RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) +SET SESSION windowing_use_high_precision=TRUE; +DROP TABLE td; +---------------------------------------------------------------------- +- NTILE (requires two passes over partition). +- Currently suboptimal in that it causes N*N reads of tmp buffer +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT id, NTILE(NULL) OVER w FROM t1 WINDOW w AS (ORDER BY id); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL) OVER w FROM t1 WINDOW w AS (ORDER BY id)' at line 1 +EXPLAIN FORMAT=JSON SELECT id, NTILE(1) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(1) OVER `w` AS `NTILE(1) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, NTILE(2) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(2) OVER `w` AS `NTILE(2) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, NTILE(5) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(5) OVER `w` AS `NTILE(5) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, NTILE(11) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(11) OVER `w` AS `NTILE(11) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +combo with frame +EXPLAIN FORMAT=JSON SELECT id, ROW_NUMBER() OVER w, NTILE(4) OVER w, SUM(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id ROWS 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "ntile", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,ntile(4) OVER `w` AS `NTILE(4) OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +Try one where there are no extras +DELETE FROM t1 WHERE id=11; +EXPLAIN FORMAT=JSON SELECT id, NTILE(3) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,ntile(3) OVER `w` AS `NTILE(3) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +INSERT INTO t1 VALUES (11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +Simulated NTILE via other SQL window functions. Exercises an +an expression containing window functions defined on different +windows +EXPLAIN FORMAT=JSON SELECT (ROW_NUMBER() OVER w1 * 5 - 1) DIV (COUNT(*) OVER w2) + 1 AS cnt +FROM t1 WINDOW w1 AS (ORDER BY id ASC), +w2 AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w1", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "w2", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select ((((row_number() OVER `w1` * 5) - 1) DIV count(0) OVER `w2`) + 1) AS `cnt` from `test`.`t1` window `w1` AS (ORDER BY `test`.`t1`.`id` ) , `w2` AS () +EXPLAIN FORMAT=JSON SELECT (ROW_NUMBER() OVER w1 * 5 - 1) DIV (COUNT(*) OVER w2) + 1 AS ntile_manually, +COUNT(*) OVER w3 +FROM t1 WINDOW w1 AS (ORDER BY id ASC), +w2 AS (), w3 AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w1", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "w2", + "definition_position": 2, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w3", + "definition_position": 3, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select ((((row_number() OVER `w1` * 5) - 1) DIV count(0) OVER `w2`) + 1) AS `ntile_manually`,count(0) OVER `w3` AS `COUNT(*) OVER w3` from `test`.`t1` window `w1` AS (ORDER BY `test`.`t1`.`id` ) , `w2` AS () , `w3` AS () +NTILE in combination with a frame that doesn't cover current row (was bug) +EXPLAIN FORMAT=JSON SELECT id, ROW_NUMBER() OVER w, SUM(id) OVER w, NTILE(5) OVER w FROM t1 +WINDOW w AS (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "sum", + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,ntile(5) OVER `w` AS `NTILE(5) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING) +---------------------------------------------------------------------- +- SUM with frames in combination with non-framing window functions +- ROW_NUMBER and RANK +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER w, id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select row_number() OVER `w` AS `ROW_NUMBER() OVER w`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER w, SUM(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select row_number() OVER `w` AS `ROW_NUMBER() OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +INSERT INTO t1 VALUES (10, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT RANK() OVER w, id, SUM(id) OVER w, sex FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "rank", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT RANK() OVER w, SUM(id) OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id +ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "rank", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select rank() OVER `w` AS `RANK() OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, sex, SUM(id) OVER w, +ROW_NUMBER() OVER w, +RANK() OVER w FROM t1 +WINDOW w AS (PARTITION BY sex ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "row_number", + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'rank' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,rank() OVER `w` AS `RANK() OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +---------------------------------------------------------------------- +- FIRST_VALUE +---------------------------------------------------------------------- +INSERT INTO t1 VALUES (NULL, 'M'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS () +select id, FIRST_VALUE(id) OVER (ROWS UNBOUNDED PRECEDING) FROM t1; +id FIRST_VALUE(id) OVER (ROWS UNBOUNDED PRECEDING) +1 1 +2 1 +3 1 +4 1 +5 1 +10 1 +11 1 +10 1 +NULL 1 +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ORDER BY `test`.`t1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +CREATE VIEW v AS +SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t1`.`id` AS `id`,first_value(`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `t1` window `w` AS (ORDER BY `t1`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.51" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.61", + "eval_cost": "0.90", + "prefix_cost": "3.51", + "data_read_per_join": "216" + }, + "used_columns": [ + "id", + "FIRST_VALUE(id) OVER w" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`FIRST_VALUE(id) OVER w` AS `FIRST_VALUE(id) OVER w` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +CREATE TABLE td1 (id DOUBLE, sex CHAR(1)); +INSERT INTO td1 SELECT * FROM t1; +ANALYZE TABLE td1; +Table Op Msg_type Msg_text +test.td1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (PARTITION BY `test`.`td1`.`sex` ORDER BY `test`.`td1`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td1 WINDOW w AS (ORDER BY id RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td1`.`id` AS `id`,first_value(`test`.`td1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td1` window `w` AS (ORDER BY `test`.`td1`.`id` RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +DROP TABLE td1; +CREATE TABLE td_dec (id DECIMAL(10,2), sex CHAR(1)); +INSERT INTO td_dec SELECT * FROM t1; +ANALYZE TABLE td_dec; +Table Op Msg_type Msg_text +test.td_dec analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (PARTITION BY `test`.`td_dec`.`sex` ORDER BY `test`.`td_dec`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_dec WINDOW w AS (ORDER BY id RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_dec", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_dec`.`id` AS `id`,first_value(`test`.`td_dec`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_dec` window `w` AS (ORDER BY `test`.`td_dec`.`id` RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +DROP TABLE td_dec; +CREATE TABLE td_str (id VARCHAR(20), sex CHAR(1)); +INSERT INTO td_str SELECT * FROM t1; +ANALYZE TABLE td_str; +Table Op Msg_type Msg_text +test.td_str analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (PARTITION BY sex ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`sex`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (PARTITION BY `test`.`td_str`.`sex` ORDER BY `test`.`td_str`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM td_str WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "td_str", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "792" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`td_str`.`id` AS `id`,first_value(`test`.`td_str`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`td_str` window `w` AS (ORDER BY `test`.`td_str`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +DROP TABLE td_str; +CREATE TABLE t_date(id DATE); +INSERT INTO t_date VALUES ('2002-06-09'), +('2002-06-09'), +('2002-06-10'), +('2002-06-09'), +('2015-08-01'), +('2002-06-09'), +('2015-08-01'); +ANALYZE TABLE t_date; +Table Op Msg_type Msg_text +test.t_date analyze status OK +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS () +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` desc ) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE INTERVAL 2 DAY PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN INTERVAL 2 day PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN INTERVAL 2 DAY PRECEDING AND INTERVAL 1 DAY PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN INTERVAL 2 day PRECEDING AND INTERVAL 1 day PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +CREATE VIEW v AS +SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t_date`.`id` AS `id`,first_value(`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `t_date` window `w` AS (ORDER BY `t_date`.`id` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "FIRST_VALUE(id) OVER w" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`FIRST_VALUE(id) OVER w` AS `FIRST_VALUE(id) OVER w` from `test`.`v` +DROP VIEW v; +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN INTERVAL 2 DAY FOLLOWING AND INTERVAL 3 DAY FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_date`.`id` AS `id`,first_value(`test`.`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t_date` window `w` AS (ORDER BY `test`.`t_date`.`id` RANGE BETWEEN INTERVAL 2 day FOLLOWING AND INTERVAL 3 day FOLLOWING) +CREATE VIEW v AS +SELECT id, FIRST_VALUE(id) OVER w FROM t_date WINDOW w AS (ORDER BY id RANGE BETWEEN INTERVAL 2 DAY FOLLOWING AND INTERVAL 3 DAY FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `t_date`.`id` AS `id`,first_value(`t_date`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `t_date` window `w` AS (ORDER BY `t_date`.`id` RANGE BETWEEN INTERVAL 2 day FOLLOWING AND INTERVAL 3 day FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.29" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.59", + "eval_cost": "0.70", + "prefix_cost": "3.29", + "data_read_per_join": "112" + }, + "used_columns": [ + "id", + "FIRST_VALUE(id) OVER w" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t_date", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "56" + }, + "used_columns": [ + "id" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`id` AS `id`,`test`.`v`.`FIRST_VALUE(id) OVER w` AS `FIRST_VALUE(id) OVER w` from `test`.`v` +DROP VIEW v; +DROP TABLE t_date; +CREATE TABLE t_time(t TIME, ts TIMESTAMP); +INSERT INTO t_time VALUES ('12:30', '2016-07-05 08:30:42'); +INSERT INTO t_time VALUES ('22:30', '2015-07-05 08:30:43'); +INSERT INTO t_time VALUES ('13:30', '2014-07-05 08:30:44'); +INSERT INTO t_time VALUES ('01:30', '2013-07-05 08:30:45'); +INSERT INTO t_time VALUES ('15:30', '2016-08-05 08:31:42'); +INSERT INTO t_time VALUES ('20:30', '2016-09-05 08:32:42'); +INSERT INTO t_time VALUES ('04:30', '2016-10-05 08:33:42'); +INSERT INTO t_time VALUES ('06:30', '2016-11-05 08:34:42'); +INSERT INTO t_time VALUES ('18:30', '2016-07-05 09:30:42'); +INSERT INTO t_time VALUES ('21:30', '2016-07-06 10:30:42'); +INSERT INTO t_time VALUES ('00:30', '2016-07-07 11:30:42'); +INSERT INTO t_time VALUES ('00:31', '2016-07-08 12:30:42'); +ANALYZE TABLE t_time; +Table Op Msg_type Msg_text +test.t_time analyze status OK +CREATE TABLE t_time2(t TIME, ts TIMESTAMP, p INTEGER DEFAULT 1); +INSERT INTO t_time2(t, ts) SELECT * FROM t_time; +UPDATE t_time2 SET p=p+1; +INSERT INTO t_time2(t, ts) SELECT * FROM t_time; +ANALYZE TABLE t_time2; +Table Op Msg_type Msg_text +test.t_time2 analyze status OK +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (); +EXPLAIN + "first_value" + "optimized_frame_evaluation": true + "using_temporary_table": true, + "data_read_per_join": "192" + "eval_cost": "1.20", + "frame_buffer": { + "functions": [ + "name": "w", + "prefix_cost": "1.45", + "read_cost": "0.25", + "t" + ] + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "table_name": "t_time", + "used_columns": [ + ] + { + } + }, + "query_cost": "1.45" + "table": { + "windows": [ + ], + } + "cost_info": { + "select_id": 1, + "windowing": { + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS () +Warnings: +{ +} +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t); +EXPLAIN + "`t`" + "first_value" + "optimized_frame_evaluation": true + "using_temporary_table": true, + "data_read_per_join": "192" + "eval_cost": "1.20", + "filesort_key": [ + "frame_buffer": { + "functions": [ + "name": "w", + "prefix_cost": "1.45", + "read_cost": "0.25", + "t" + "using_filesort": true, + ] + ], + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "sort_cost": "12.00" + "table_name": "t_time", + "used_columns": [ + ] + { + } + }, + "cost_info": { + "query_cost": "13.45" + "table": { + "windows": [ + ], + } + }, + "cost_info": { + "select_id": 1, + "windowing": { + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ) +Warnings: +{ +} +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` desc ) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE INTERVAL 2 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR PRECEDING AND INTERVAL 1 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND INTERVAL 1 hour PRECEDING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT t, FIRST_VALUE(t) OVER w FROM t_time WINDOW w AS (ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR FOLLOWING AND INTERVAL 3 HOUR FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t_time", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time`.`t` AS `t`,first_value(`test`.`t_time`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time` window `w` AS (ORDER BY `test`.`t_time`.`t` RANGE BETWEEN INTERVAL 2 hour FOLLOWING AND INTERVAL 3 hour FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t); +EXPLAIN + "`p`", + "`t`" + "first_value" + "optimized_frame_evaluation": true + "using_temporary_table": true, + "data_read_per_join": "384" + "eval_cost": "2.40", + "filesort_key": [ + "frame_buffer": { + "functions": [ + "name": "w", + "p" + "prefix_cost": "2.65", + "read_cost": "0.25", + "t", + "using_filesort": true, + ] + ], + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "sort_cost": "24.00" + "table_name": "t_time2", + "used_columns": [ + ] + { + } + }, + "cost_info": { + "query_cost": "26.65" + "table": { + "windows": [ + ], + } + }, + "cost_info": { + "select_id": 1, + "windowing": { + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ) +Warnings: +{ +} +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t DESC); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` desc ) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE INTERVAL 2 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR PRECEDING AND INTERVAL 1 HOUR PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN INTERVAL 2 hour PRECEDING AND INTERVAL 1 hour PRECEDING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` ROWS BETWEEN 2 FOLLOWING AND 3 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT p, t, FIRST_VALUE(t) OVER w FROM t_time2 WINDOW w AS (PARTITION by p ORDER BY t RANGE BETWEEN INTERVAL 2 HOUR FOLLOWING AND INTERVAL 3 HOUR FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "26.65" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "24.00" + }, + "table": { + "table_name": "t_time2", + "access_type": "ALL", + "rows_examined_per_scan": 24, + "rows_produced_per_join": 24, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.40", + "prefix_cost": "2.65", + "data_read_per_join": "384" + }, + "used_columns": [ + "t", + "p" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t_time2`.`p` AS `p`,`test`.`t_time2`.`t` AS `t`,first_value(`test`.`t_time2`.`t`) OVER `w` AS `FIRST_VALUE(t) OVER w` from `test`.`t_time2` window `w` AS (PARTITION BY `test`.`t_time2`.`p` ORDER BY `test`.`t_time2`.`t` RANGE BETWEEN INTERVAL 2 hour FOLLOWING AND INTERVAL 3 hour FOLLOWING) +DROP TABLE t_time, t_time2; +---------------------------------------------------------------------- +- Aggregates with RANGE frame specification +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.15" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ], + "query_block": { + "cost_info": { + "query_cost": "1.15" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`sex` AS `sex` from `test`.`t1` +Make t11 a clone of t1 but with an extra partitioning column, but other values +repeated, so we can test it the same frames work on more than one partition +CREATE TABLE t11 (id INTEGER, sex CHAR(1), p INTEGER DEFAULT 1); +INSERT INTO t11(id, sex) SELECT * FROM t1; +UPDATE t11 SET p=p+1; +INSERT INTO t11(id, sex) SELECT * FROM t1; +ANALYZE TABLE t11; +Table Op Msg_type Msg_text +test.t11 analyze status OK +Make t22 a clone of t2 but with an extra partitioning column, but other values +repeated, so we can test it the same frames work on more than one partition +CREATE TABLE t22 (user_id INTEGER NOT NULL, date DATE, p INTEGER DEFAULT 1); +INSERT INTO t22(user_id, date) SELECT * FROM t2; +UPDATE t22 SET p=p+1; +INSERT INTO t22(user_id, date) SELECT * FROM t2; +ANALYZE TABLE t22; +Table Op Msg_type Msg_text +test.t22 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER (ORDER BY id RANGE 2 PRECEDING) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.15" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "9.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY id RANGE 2 PRECEDING)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER (ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.15" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "9.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS `SUM(id) OVER (ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT id, SUM(id) OVER (ORDER BY id RANGE UNBOUNDED PRECEDING) FROM t1 ORDER BY id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "19.15" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "9.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER (ORDER BY `test`.`t1`.`id` RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (ORDER BY id RANGE UNBOUNDED PRECEDING)` from `test`.`t1` order by `test`.`t1`.`id` +EXPLAIN FORMAT=JSON SELECT p, id, SUM(id) OVER (PARTITION BY p ORDER BY id RANGE 2 PRECEDING) FROM t11 ORDER BY p,id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (PARTITION BY p ORDER BY id RANGE 2 PRECEDING)` from `test`.`t11` order by `test`.`t11`.`p`,`test`.`t11`.`id` +EXPLAIN FORMAT=JSON SELECT p, id, SUM(id) OVER (PARTITION BY p ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t11 ORDER BY p,id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS `SUM(id) OVER (PARTITION BY p ORDER BY id RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)` from `test`.`t11` order by `test`.`t11`.`p`,`test`.`t11`.`id` +EXPLAIN FORMAT=JSON SELECT p, id, SUM(id) OVER (PARTITION BY p ORDER BY id RANGE UNBOUNDED PRECEDING) FROM t11 ORDER BY p,id; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `SUM(id) OVER (PARTITION BY p ORDER BY id RANGE UNBOUNDED PRECEDING)` from `test`.`t11` order by `test`.`t11`.`p`,`test`.`t11`.`id` +Implicit frame due to ORDER BY, with last in peer group as upper bound +EXPLAIN FORMAT=JSON SELECT user_id, SUM(user_id) OVER w, AVG(user_id) OVER w FROM t2 WINDOW w AS (ORDER BY user_id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,sum(`test`.`t2`.`user_id`) OVER `w` AS `SUM(user_id) OVER w`,avg(`test`.`t2`.`user_id`) OVER `w` AS `AVG(user_id) OVER w` from `test`.`t2` window `w` AS (ORDER BY `test`.`t2`.`user_id` ) +EXPLAIN FORMAT=JSON SELECT p, user_id, SUM(user_id) OVER w, AVG(user_id) OVER w FROM t22 WINDOW w AS (PARTITION BY p ORDER BY user_id) ORDER BY p; +EXPLAIN + "`p`", + "`user_id`" + "avg" + "optimized_frame_evaluation": true + "sum", + "using_temporary_table": true, + "data_read_per_join": "224" + "eval_cost": "1.40", + "filesort_key": [ + "frame_buffer": { + "functions": [ + "name": "w", + "p" + "prefix_cost": "1.65", + "read_cost": "0.25", + "user_id", + "using_filesort": true, + "using_temporary_table": true, + ] + ], + }, + "access_type": "ALL", + "cost_info": { + "filtered": "100.00", + "rows_examined_per_scan": 14, + "rows_produced_per_join": 14, + "sort_cost": "14.00" + "table_name": "t22", + "used_columns": [ + ] + { + } + }, + "cost_info": { + "sort_cost": "14.00" + "table": { + "windows": [ + ], + } + }, + "cost_info": { + "query_cost": "29.65" + "using_filesort": true, + "windowing": { + } + }, + "cost_info": { + "ordering_operation": { + "select_id": 1, + } + }, + "query_block": { + } +Note 1003 /* select#1 */ select `test`.`t22`.`p` AS `p`,`test`.`t22`.`user_id` AS `user_id`,sum(`test`.`t22`.`user_id`) OVER `w` AS `SUM(user_id) OVER w`,avg(`test`.`t22`.`user_id`) OVER `w` AS `AVG(user_id) OVER w` from `test`.`t22` window `w` AS (PARTITION BY `test`.`t22`.`p` ORDER BY `test`.`t22`.`user_id` ) order by `test`.`t22`.`p` +Warnings: +{ +} +Window function use of same field in different windows, both of which +need buffering. In this case we need subsequent rewrites of arg fields +Field pointer in tmp files for window 2..n The intervening internal +window buffering in each step used to mess that up. +EXPLAIN FORMAT=JSON SELECT user_id, SUM(user_id) OVER w, AVG(user_id) OVER w1 FROM t2 +WINDOW w AS (ORDER BY user_id), w1 AS (ORDER BY user_id); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "w", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`user_id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "w1", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,sum(`test`.`t2`.`user_id`) OVER `w` AS `SUM(user_id) OVER w`,avg(`test`.`t2`.`user_id`) OVER `w1` AS `AVG(user_id) OVER w1` from `test`.`t2` window `w` AS (ORDER BY `test`.`t2`.`user_id` ) , `w1` AS (ORDER BY `test`.`t2`.`user_id` ) +Check descending order by with RANGE: 2 PRECEDING in this case means larger than +current row. +EXPLAIN FORMAT=JSON SELECT NTILE(5) OVER w, ROW_NUMBER() OVER w, id, SUM(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id DESC RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile", + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select ntile(5) OVER `w` AS `NTILE(5) OVER w`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,`test`.`t1`.`id` AS `id`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` desc RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT p, NTILE(5) OVER w, ROW_NUMBER() OVER w, id, SUM(id) OVER w FROM t11 +WINDOW w AS (PARTITION BY p ORDER BY id DESC RANGE 2 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "20.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`p`", + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile", + "row_number", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t11", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "id", + "p" + ] + } + } + } +} +Warnings: +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 3599 Window function 'row_number' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t11`.`p` AS `p`,ntile(5) OVER `w` AS `NTILE(5) OVER w`,row_number() OVER `w` AS `ROW_NUMBER() OVER w`,`test`.`t11`.`id` AS `id`,sum(`test`.`t11`.`id`) OVER `w` AS `SUM(id) OVER w` from `test`.`t11` window `w` AS (PARTITION BY `test`.`t11`.`p` ORDER BY `test`.`t11`.`id` desc RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) +update t2 set date=date + user_id; +EXPLAIN FORMAT=JSON SELECT user_id, date, COUNT(*) OVER (ORDER BY date RANGE INTERVAL 1 DAY PRECEDING) FROM t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`date`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "user_id", + "date" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`user_id` AS `user_id`,`test`.`t2`.`date` AS `date`,count(0) OVER (ORDER BY `test`.`t2`.`date` RANGE BETWEEN INTERVAL 1 day PRECEDING AND CURRENT ROW) AS `COUNT(*) OVER (ORDER BY date RANGE INTERVAL 1 DAY PRECEDING)` from `test`.`t2` +CREATE TABLE t3(d DOUBLE); +INSERT INTO t3 +VALUES (1.1),(1.9),(4.0),(8.3),(16.0),(24.0),(20.1),(22.0),(23.0); +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN FORMAT=JSON SELECT d, SUM(d) OVER w, COUNT(*) OVER w FROM t3 WINDOW w AS (ORDER BY d RANGE BETWEEN 2.1 PRECEDING AND 1.1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`d` AS `d`,sum(`test`.`t3`.`d`) OVER `w` AS `SUM(d) OVER w`,count(0) OVER `w` AS `COUNT(*) OVER w` from `test`.`t3` window `w` AS (ORDER BY `test`.`t3`.`d` RANGE BETWEEN 2.1 PRECEDING AND 1.1 FOLLOWING) +---------------------------------------------------------------------- +- wf over JSON +---------------------------------------------------------------------- +CREATE TABLE tj(j JSON, i INT DEFAULT 7); +INSERT INTO tj(j) VALUES ('1'), ('2'), ('3'), ('4'), ('5'), (NULL); +INSERT INTO tj(j) VALUES ('3.14'); +INSERT INTO tj(j) VALUES ('[1,2,3]'); +ANALYZE TABLE tj; +Table Op Msg_type Msg_text +test.tj analyze status OK +EXPLAIN FORMAT=JSON SELECT CAST(SUM(j) OVER () AS JSON) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select cast(sum(`test`.`tj`.`j`) OVER () as json) AS `CAST(SUM(j) OVER () AS JSON)` from `test`.`tj` +---------------------------------------------------------------------- +- SELECT DISTINCT +---------------------------------------------------------------------- +One window +EXPLAIN FORMAT=JSON SELECT DISTINCT i,COUNT(*) OVER () FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "duplicates_removal": { + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`tj`.`i` AS `i`,count(0) OVER () AS `COUNT(*) OVER ()` from `test`.`tj` +Several windows with final ORDER BY also +EXPLAIN FORMAT=JSON SELECT DISTINCT i,NTILE(3) OVER (ORDER BY i), SUM(i) OVER (), COUNT(*) OVER () FROM tj ORDER BY NTILE(3) OVER (ORDER BY i); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "17.05" + }, + "ordering_operation": { + "using_filesort": true, + "duplicates_removal": { + "using_filesort": false, + "cost_info": { + "sort_cost": "8.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + }, + { + "name": "", + "definition_position": 3, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`tj`.`i` AS `i`,ntile(3) OVER (ORDER BY `test`.`tj`.`i` ) AS `NTILE(3) OVER (ORDER BY i)`,sum(`test`.`tj`.`i`) OVER () AS `SUM(i) OVER ()`,count(0) OVER () AS `COUNT(*) OVER ()` from `test`.`tj` order by ntile(3) OVER (ORDER BY `test`.`tj`.`i` ) +UPDATE tj SET i=i+CASE WHEN JSON_TYPE(j) = 'ARRAY' THEN 1 ELSE j END; +UPDATE tj SET i=7 where i=8 AND JSON_TYPE(j) != 'ARRAY'; +CREATE TABLE tj2 AS SELECT * FROM tj; +UPDATE tj2 SET i=MOD(i,3); +EXPLAIN FORMAT=JSON SELECT * FROM tj2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj2`.`j` AS `j`,`test`.`tj2`.`i` AS `i` from `test`.`tj2` +With GROUP BY +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER (), MOD(SUM(i),2) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER () AS `COUNT(*) OVER ()`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)` from `test`.`tj2` group by `test`.`tj2`.`i` +EXPLAIN FORMAT=JSON SELECT DISTINCT COUNT(*) OVER (), MOD(SUM(i),2) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct count(0) OVER () AS `COUNT(*) OVER ()`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)` from `test`.`tj2` group by `test`.`tj2`.`i` +Bug fix GROUP BY with window function referring column used in grouping expression +EXPLAIN FORMAT=JSON SELECT i, SUM(i) OVER (), MOD(SUM(i),2) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj2`.`i` AS `i`,sum(`test`.`tj2`.`i`) OVER () AS `SUM(i) OVER ()`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)` from `test`.`tj2` group by `test`.`tj2`.`i` +EXPLAIN FORMAT=JSON SELECT i, SUM(SUM(i)) OVER (), SUM(i) OVER (ORDER BY i), MOD(SUM(i),2), SUM(i) FROM tj2 GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "tj2", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj2`.`i` AS `i`,sum(sum(`test`.`tj2`.`i`)) OVER () AS `SUM(SUM(i)) OVER ()`,sum(`test`.`tj2`.`i`) OVER (ORDER BY `test`.`tj2`.`i` ) AS `SUM(i) OVER (ORDER BY i)`,(sum(`test`.`tj2`.`i`) % 2) AS `MOD(SUM(i),2)`,sum(`test`.`tj2`.`i`) AS `SUM(i)` from `test`.`tj2` group by `test`.`tj2`.`i` +DROP TABLE tj2; +---------------------------------------------------------------------- +- Bug fixes +---------------------------------------------------------------------- +Bug fix for FIRST_VALUE, LAST_VALUE when not buffered processing +EXPLAIN FORMAT=JSON SELECT LAST_VALUE(j) OVER w, FIRST_VALUE(j) OVER w FROM tj WINDOW w AS (PARTITION BY i ORDER BY j ROWS UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "functions": [ + "last_value", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select last_value(`test`.`tj`.`j`) OVER `w` AS `LAST_VALUE(j) OVER w`,first_value(`test`.`tj`.`j`) OVER `w` AS `FIRST_VALUE(j) OVER w` from `test`.`tj` window `w` AS (PARTITION BY `test`.`tj`.`i` ORDER BY `test`.`tj`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +Bug missing hidden column (j) induction to select list: FIRST_VALUE/LAST_VALUE +EXPLAIN FORMAT=JSON SELECT i, LAST_VALUE((CAST(j AS UNSIGNED))) OVER w, FIRST_VALUE(CAST(j AS UNSIGNED)) OVER w FROM tj +WINDOW w AS (PARTITION BY i ORDER BY CAST(j AS UNSIGNED) RANGE UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`i`", + "cast(`j` as unsigned)" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "last_value", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`i` AS `i`,last_value(cast(`test`.`tj`.`j` as unsigned)) OVER `w` AS `LAST_VALUE((CAST(j AS UNSIGNED))) OVER w`,first_value(cast(`test`.`tj`.`j` as unsigned)) OVER `w` AS `FIRST_VALUE(CAST(j AS UNSIGNED)) OVER w` from `test`.`tj` window `w` AS (PARTITION BY `test`.`tj`.`i` ORDER BY cast(`test`.`tj`.`j` as unsigned) RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +Fix for lineno in warnings buffered and unbuffered windows +EXPLAIN FORMAT=JSON SELECT j,CAST(SUM(j) OVER (PARTITION BY i) AS JSON), CAST(SUM(j) OVER () AS JSON) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,cast(sum(`test`.`tj`.`j`) OVER (PARTITION BY `test`.`tj`.`i` ) as json) AS `CAST(SUM(j) OVER (PARTITION BY i) AS JSON)`,cast(sum(`test`.`tj`.`j`) OVER () as json) AS `CAST(SUM(j) OVER () AS JSON)` from `test`.`tj` +EXPLAIN FORMAT=JSON SELECT j,CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON), CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "sum" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,cast(sum(`test`.`tj`.`j`) OVER (PARTITION BY `test`.`tj`.`i` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as json) AS `CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON)`,cast(sum(`test`.`tj`.`j`) OVER (PARTITION BY `test`.`tj`.`i` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as json) AS `CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON)` from `test`.`tj` +Bug fix for UNION +EXPLAIN FORMAT=JSON SELECT i, ROW_NUMBER() OVER () FROM tj UNION ALL SELECT i, ROW_NUMBER() OVER () FROM tj; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": false, + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "1.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "i" + ] + } + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`i` AS `i`,row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`tj` union all /* select#2 */ select `test`.`tj`.`i` AS `i`,row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`tj` +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT i, j, ROW_NUMBER() OVER (ORDER BY j) FROM tj UNION SELECT i, j, ROW_NUMBER() OVER (ORDER BY j) FROM tj) alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.30" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 16, + "rows_produced_per_join": 16, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.70", + "eval_cost": "1.60", + "prefix_cost": "4.30", + "data_read_per_join": "640" + }, + "used_columns": [ + "", + "i", + "j", + "ROW_NUMBER() OVER (ORDER BY j)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "union_result": { + "using_temporary_table": true, + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "192" + }, + "used_columns": [ + "j", + "i" + ] + } + } + } + } + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`i` AS `i`,`alias`.`j` AS `j`,`alias`.`ROW_NUMBER() OVER (ORDER BY j)` AS `ROW_NUMBER() OVER (ORDER BY j)` from (/* select#2 */ select `test`.`tj`.`i` AS `i`,`test`.`tj`.`j` AS `j`,row_number() OVER (ORDER BY `test`.`tj`.`j` ) AS `ROW_NUMBER() OVER (ORDER BY j)` from `test`.`tj` union /* select#3 */ select `test`.`tj`.`i` AS `i`,`test`.`tj`.`j` AS `j`,row_number() OVER (ORDER BY `test`.`tj`.`j` ) AS `ROW_NUMBER() OVER (ORDER BY j)` from `test`.`tj`) `alias` +DROP TABLE tj; +---------------------------------------------------------------------- +- More JSON +---------------------------------------------------------------------- +CREATE TABLE tj(j JSON); +INSERT INTO tj VALUES ('1'), ('2'), ('3'), ('4'), ('5'), (NULL); +EXPLAIN FORMAT=JSON SELECT j, JSON_TYPE(j), SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,json_type(`test`.`tj`.`j`) AS `JSON_TYPE(j)`,sum(`test`.`tj`.`j`) OVER (ORDER BY `test`.`tj`.`j` ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS `SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING)` from `test`.`tj` +INSERT INTO tj VALUES ('3.14'); +EXPLAIN FORMAT=JSON SELECT j, JSON_TYPE(j), SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING) FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,json_type(`test`.`tj`.`j`) AS `JSON_TYPE(j)`,sum(`test`.`tj`.`j`) OVER (ORDER BY `test`.`tj`.`j` ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS `SUM(j) OVER (ORDER BY j ROWS 3 PRECEDING)` from `test`.`tj` +INSERT INTO tj VALUES ('[1,2,3]'); +ANALYZE TABLE tj; +Table Op Msg_type Msg_text +test.tj analyze status OK +EXPLAIN FORMAT=JSON SELECT j, +JSON_TYPE(j), +SUM(CASE WHEN JSON_TYPE(j) = 'ARRAY' THEN j->"$[0]" ELSE j END) +OVER (ORDER BY j ROWS 3 PRECEDING) +FROM tj; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "8.00" + }, + "table": { + "table_name": "tj", + "access_type": "ALL", + "rows_examined_per_scan": 8, + "rows_produced_per_join": 8, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.80", + "prefix_cost": "1.05", + "data_read_per_join": "128" + }, + "used_columns": [ + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`tj`.`j` AS `j`,json_type(`test`.`tj`.`j`) AS `JSON_TYPE(j)`,sum((case when (json_type(`test`.`tj`.`j`) = 'ARRAY') then json_extract(`test`.`tj`.`j`,'$[0]') else `test`.`tj`.`j` end)) OVER (ORDER BY `test`.`tj`.`j` ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS `SUM(CASE WHEN JSON_TYPE(j) = 'ARRAY' THEN j->"$[0]" ELSE j END) +OVER (ORDER BY j ROWS 3 PRECEDING)` from `test`.`tj` +CREATE TABLE t5(b BIGINT UNSIGNED); +INSERT INTO t5 VALUES (1), (2), (3), (4), (5), (6), (7); +ANALYZE TABLE t5; +Table Op Msg_type Msg_text +test.t5 analyze status OK +last row should have COUNT(*) == 0 , not 1 (bug fix) +EXPLAIN FORMAT=JSON SELECT b, COUNT(*) OVER (ORDER BY b RANGE BETWEEN 1 FOLLOWING AND 100 FOLLOWING) bb FROM t5; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "7.95" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "7.00" + }, + "table": { + "table_name": "t5", + "access_type": "ALL", + "rows_examined_per_scan": 7, + "rows_produced_per_join": 7, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.70", + "prefix_cost": "0.95", + "data_read_per_join": "112" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t5`.`b` AS `b`,count(0) OVER (ORDER BY `test`.`t5`.`b` RANGE BETWEEN 1 FOLLOWING AND 100 FOLLOWING) AS `bb` from `test`.`t5` +CREATE TABLE t6(t TIME, ts TIMESTAMP); +INSERT INTO t6 VALUES ('12:30', '2016-07-05 08:30:42'); +INSERT INTO t6 VALUES ('22:30', '2015-07-05 08:30:43'); +INSERT INTO t6 VALUES ('13:30', '2014-07-05 08:30:44'); +INSERT INTO t6 VALUES ('01:30', '2013-07-05 08:30:45'); +INSERT INTO t6 VALUES ('15:30', '2016-08-05 08:31:42'); +INSERT INTO t6 VALUES ('20:30', '2016-09-05 08:32:42'); +INSERT INTO t6 VALUES ('04:30', '2016-10-05 08:33:42'); +INSERT INTO t6 VALUES ('06:30', '2016-11-05 08:34:42'); +INSERT INTO t6 VALUES ('18:30', '2016-07-05 09:30:42'); +INSERT INTO t6 VALUES ('21:30', '2016-07-06 10:30:42'); +INSERT INTO t6 VALUES ('00:30', '2016-07-07 11:30:42'); +INSERT INTO t6 VALUES ('00:31', '2016-07-08 12:30:42'); +ANALYZE TABLE t6; +Table Op Msg_type Msg_text +test.t6 analyze status OK +INTERVAL specified with string as below failed +EXPLAIN FORMAT=JSON SELECT t, COUNT(*) OVER (ORDER BY t RANGE +BETWEEN INTERVAL 1 HOUR PRECEDING AND INTERVAL '2:2' MINUTE_SECOND FOLLOWING) AS cnt FROM t6; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t6`.`t` AS `t`,count(0) OVER (ORDER BY `test`.`t6`.`t` RANGE BETWEEN INTERVAL 1 hour PRECEDING AND INTERVAL '2:2' minute_second FOLLOWING) AS `cnt` from `test`.`t6` +---------------------------------------------------------------------- +- Window spec inheritance +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER w0, +COUNT(*) OVER w, +COUNT(*) OVER w1 FROM t6 +WINDOW w0 AS (), +w AS (w0 ORDER BY t), +w1 AS (w RANGE BETWEEN INTERVAL 24 HOUR PRECEDING AND INTERVAL '2:2' MINUTE_SECOND FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w0", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w1", + "definition_position": 3, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER `w0` AS `COUNT(*) OVER w0`,count(0) OVER `w` AS `COUNT(*) OVER w`,count(0) OVER `w1` AS `COUNT(*) OVER w1` from `test`.`t6` window `w0` AS () , `w` AS (`w0` ORDER BY `test`.`t6`.`t` ) , `w1` AS (`w` RANGE BETWEEN INTERVAL 24 hour PRECEDING AND INTERVAL '2:2' minute_second FOLLOWING) +CREATE VIEW v AS +SELECT COUNT(*) OVER w0, +COUNT(*) OVER w, +COUNT(*) OVER w1 FROM t6 +WINDOW w0 AS (), +w AS (w0 ORDER BY t), +w1 AS (w RANGE BETWEEN INTERVAL 24 HOUR PRECEDING AND INTERVAL '2:2' MINUTE_SECOND FOLLOWING); +SHOW CREATE VIEW v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select count(0) OVER `w0` AS `COUNT(*) OVER w0`,count(0) OVER `w` AS `COUNT(*) OVER w`,count(0) OVER `w1` AS `COUNT(*) OVER w1` from `t6` window `w0` AS () , `w` AS (`w0` ORDER BY `t6`.`t` ) , `w1` AS (`w` RANGE BETWEEN INTERVAL 24 hour PRECEDING AND INTERVAL '2:2' minute_second FOLLOWING) utf8 utf8_general_ci +EXPLAIN FORMAT=JSON SELECT * FROM v; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.85" + }, + "table": { + "table_name": "v", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.65", + "eval_cost": "1.20", + "prefix_cost": "3.85", + "data_read_per_join": "384" + }, + "used_columns": [ + "COUNT(*) OVER w0", + "COUNT(*) OVER w", + "COUNT(*) OVER w1" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "13.45" + }, + "windowing": { + "windows": [ + { + "name": "w0", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`t`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "w1", + "definition_position": 3, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t6", + "access_type": "ALL", + "rows_examined_per_scan": 12, + "rows_produced_per_join": 12, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.20", + "prefix_cost": "1.45", + "data_read_per_join": "192" + }, + "used_columns": [ + "t" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`v`.`COUNT(*) OVER w0` AS `COUNT(*) OVER w0`,`test`.`v`.`COUNT(*) OVER w` AS `COUNT(*) OVER w`,`test`.`v`.`COUNT(*) OVER w1` AS `COUNT(*) OVER w1` from `test`.`v` +DROP VIEW v; +---------------------------------------------------------------------- +- Bugs with induction of hidden fields from window function also used +- in ORDER BY/PARTITION BY +---------------------------------------------------------------------- +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER (PARTITION BY id) summ FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id) OVER (PARTITION BY id) summ FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT id, AVG(id) OVER (PARTITION BY id) summ, +AVG(id) OVER (PARTITION BY id) summ2 FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ2` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT AVG(id) OVER (PARTITION BY id) summ, +AVG(id) OVER (PARTITION BY id) summ2 FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "144" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ`,avg(`test`.`t1`.`id`) OVER (PARTITION BY `test`.`t1`.`id` ) AS `summ2` from `test`.`t1` +Bug for AVG in presence of several NULLs +INSERT INTO t1 VALUES (NULL, 'F'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT COUNT(id) OVER w, id, AVG(id) OVER w, SUM(id) OVER w, FIRST_VALUE(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id RANGE 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "avg", + "sum", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`id`) OVER `w` AS `COUNT(id) OVER w`,`test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `AVG(id) OVER w`,sum(`test`.`t1`.`id`) OVER `w` AS `SUM(id) OVER w`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 PRECEDING AND CURRENT ROW) +Check frame size, COUNT(*) vs COUNT() in frames with NULLs +EXPLAIN FORMAT=JSON SELECT id, count(id) over w, count(*) over w, FIRST_VALUE(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id ASC RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "count", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,count(`test`.`t1`.`id`) OVER `w` AS `count(id) over w`,count(0) OVER `w` AS `count(*) over w`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +EXPLAIN FORMAT=JSON SELECT id, count(id) over w, count(*) over w, FIRST_VALUE(id) OVER w FROM t1 +WINDOW w AS (ORDER BY id DESC RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "count", + "first_value" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,count(`test`.`t1`.`id`) OVER `w` AS `count(id) over w`,count(0) OVER `w` AS `count(*) over w`,first_value(`test`.`t1`.`id`) OVER `w` AS `FIRST_VALUE(id) OVER w` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` desc RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) +CREATE TABLE ss(c CHAR(1)); +INSERT INTO ss VALUES ('M'); +ANALYZE TABLE ss; +Table Op Msg_type Msg_text +test.ss analyze status OK +EXPLAIN FORMAT=JSON SELECT sex, NTILE(2) OVER w, SUM(ASCII(sex)) OVER w s FROM t1 +HAVING sex=(SELECT c FROM ss LIMIT 1) +WINDOW w AS (ORDER BY id ROWS UNBOUNDED PRECEDING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "11.25" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile", + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id", + "sex" + ] + }, + "having_subqueries": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "ss", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "c" + ] + } + } + } + ] + } + } +} +Warnings: +Note 3599 Window function 'ntile' ignores the frame clause of window 'w' and aggregates over the whole partition +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,ntile(2) OVER `w` AS `NTILE(2) OVER w`,sum(ascii(`test`.`t1`.`sex`)) OVER `w` AS `s` from `test`.`t1` having (`test`.`t1`.`sex` = (/* select#2 */ select `test`.`ss`.`c` from `test`.`ss` limit 1)) window `w` AS (ORDER BY `test`.`t1`.`id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +EXPLAIN FORMAT=JSON SELECT sex, AVG(id), ROW_NUMBER() OVER w FROM t1 +GROUP BY sex HAVING sex='M' OR sex IS NULL +WINDOW w AS (ORDER BY AVG(id)) ORDER BY sex DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "21.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "10.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "avg(`id`)" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "10.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "id", + "sex" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`sex` AS `sex`,avg(`test`.`t1`.`id`) AS `AVG(id)`,row_number() OVER `w` AS `ROW_NUMBER() OVER w` from `test`.`t1` group by `test`.`t1`.`sex` desc having ((`test`.`t1`.`sex` = 'M') or (`test`.`t1`.`sex` is null)) window `w` AS (ORDER BY avg(`test`.`t1`.`id`) ) order by `test`.`t1`.`sex` desc +DROP TABLE t, t1, t11, t2, t22, t3, t5, t6, tj, ss; +---------------------------------------------------------------------- +- ORDER BY + RANK with more than one ordering expression +---------------------------------------------------------------------- +CREATE TABLE t(i INT, j INT, k INT); +INSERT INTO t VALUES (1,1,1), +(1,1,2), +(1,1,2), +(1,2,1), +(1,2,2), +(2,1,1), +(2,1,1), +(2,1,2), +(2,2,1), +(2,2,2); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT *, RANK() OVER (ORDER BY i,j,k) AS O_IJK, +RANK() OVER (ORDER BY j) AS O_J, +RANK() OVER (ORDER BY k,j) AS O_KJ FROM t ORDER BY i,j,k; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "41.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "10.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`", + "`k`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "rank" + ] + }, + { + "name": "", + "definition_position": 3, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`k`", + "`j`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "30.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "160" + }, + "used_columns": [ + "i", + "j", + "k" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,`test`.`t`.`k` AS `k`,rank() OVER (ORDER BY `test`.`t`.`i`,`test`.`t`.`j`,`test`.`t`.`k` ) AS `O_IJK`,rank() OVER (ORDER BY `test`.`t`.`j` ) AS `O_J`,rank() OVER (ORDER BY `test`.`t`.`k`,`test`.`t`.`j` ) AS `O_KJ` from `test`.`t` order by `test`.`t`.`i`,`test`.`t`.`j`,`test`.`t`.`k` +DROP TABLE t; +---------------------------------------------------------------------- +- Gulutzan's sanity tests in +- http://ocelot.ca/blog/blog/2016/04/18/mariadb-10-2-window-functions/ +- His comments are quoted. +---------------------------------------------------------------------- +CREATE TABLE t1 (s1 INT, s2 CHAR(5)); +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (NULL, NULL); +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (NULL, 'a'); +INSERT INTO t1 VALUES (2, 'b'); +INSERT INTO t1 VALUES (-1, ''); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +"The following statements all cause the MariaDB server to crash" +MySQL doesn't crash +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "message": "No tables used" + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` +EXPLAIN FORMAT=JSON SELECT *, ABS(ROW_NUMBER() OVER (ORDER BY s1,s2)) +- ROW_NUMBER() OVER (ORDER BY s1,s2) AS X FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`s1`", + "`s2`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,(abs(row_number() OVER (ORDER BY `test`.`t1`.`s1`,`test`.`t1`.`s2` ) ) - row_number() OVER (ORDER BY `test`.`t1`.`s1`,`test`.`t1`.`s2` ) ) AS `X` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT RANK() OVER (ORDER BY AVG(s1)) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select rank() OVER (ORDER BY avg(`test`.`t1`.`s1`) ) AS `RANK() OVER (ORDER BY AVG(s1))` from `test`.`t1` +"The following statements all give the wrong answers with MariaDB" +Correct with MySQL. +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER (ORDER BY s2) FROM t1 WHERE s2 IS NULL; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`s2`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "1.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 1, + "filtered": "16.67", + "cost_info": { + "read_cost": "0.75", + "eval_cost": "0.10", + "prefix_cost": "0.85", + "data_read_per_join": "32" + }, + "used_columns": [ + "s2" + ], + "attached_condition": "(`test`.`t1`.`s2` is null)" + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER (ORDER BY `test`.`t1`.`s2` ) AS `COUNT(*) OVER (ORDER BY s2)` from `test`.`t1` where (`test`.`t1`.`s2` is null) +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT *,DENSE_RANK() OVER (ORDER BY s2 DESC), +DENSE_RANK() OVER (ORDER BY s2) FROM t1 +) alias ORDER BY s1,s2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.17" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.58", + "eval_cost": "0.60", + "prefix_cost": "3.18", + "data_read_per_join": "288" + }, + "used_columns": [ + "s1", + "s2", + "DENSE_RANK() OVER (ORDER BY s2 DESC)", + "DENSE_RANK() OVER (ORDER BY s2)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "12.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`s2` desc" + ], + "functions": [ + "dense_rank" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`s2`" + ], + "functions": [ + "dense_rank" + ] + } + ], + "cost_info": { + "sort_cost": "12.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`s1` AS `s1`,`alias`.`s2` AS `s2`,`alias`.`DENSE_RANK() OVER (ORDER BY s2 DESC)` AS `DENSE_RANK() OVER (ORDER BY s2 DESC)`,`alias`.`DENSE_RANK() OVER (ORDER BY s2)` AS `DENSE_RANK() OVER (ORDER BY s2)` from (/* select#2 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,dense_rank() OVER (ORDER BY `test`.`t1`.`s2` desc ) AS `DENSE_RANK() OVER (ORDER BY s2 DESC)`,dense_rank() OVER (ORDER BY `test`.`t1`.`s2` ) AS `DENSE_RANK() OVER (ORDER BY s2)` from `test`.`t1`) `alias` order by `alias`.`s1`,`alias`.`s2` +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT *, SUM(s1) OVER (ORDER BY s1) FROM t1 ORDER BY s1 +) alias ORDER BY s1,s2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "9.17" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.58", + "eval_cost": "0.60", + "prefix_cost": "3.18", + "data_read_per_join": "288" + }, + "used_columns": [ + "s1", + "s2", + "SUM(s1) OVER (ORDER BY s1)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "12.85" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "6.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`s1`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`s1` AS `s1`,`alias`.`s2` AS `s2`,`alias`.`SUM(s1) OVER (ORDER BY s1)` AS `SUM(s1) OVER (ORDER BY s1)` from (/* select#2 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,sum(`test`.`t1`.`s1`) OVER (ORDER BY `test`.`t1`.`s1` ) AS `SUM(s1) OVER (ORDER BY s1)` from `test`.`t1` order by `test`.`t1`.`s1`) `alias` order by `alias`.`s1`,`alias`.`s2` +EXPLAIN FORMAT=JSON SELECT AVG(s1), RANK() OVER (ORDER BY s1) FROM t1; +ERROR 42000: In aggregated query without GROUP BY, expression #1 of PARTITION BY or ORDER BY clause of window '' contains nonaggregated column 'test.t1.s1'; this is incompatible with sql_mode=only_full_group_by +"The following statement causes the client to hang (it loops in +mysql_store_result, I think this is the first time I've seen this type of +error)" +No issue with MySQL +EXPLAIN FORMAT=JSON SELECT *, AVG(s1) OVER () FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,avg(`test`.`t1`.`s1`) OVER () AS `AVG(s1) OVER ()` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT *, AVG(s1) OVER (ROWS UNBOUNDED PRECEDING) FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "avg" + ] + } + ], + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "192" + }, + "used_columns": [ + "s1", + "s2" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,avg(`test`.`t1`.`s1`) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `AVG(s1) OVER (ROWS UNBOUNDED PRECEDING)` from `test`.`t1` +DROP TABLE t1; +Some negative tests (from Srikanth) +CREATE TABLE t (a INT, b INT, c INT); +INSERT INTO t VALUES (1,1,1), (1,1,2), (1,1,3), +(1,2,1), (1,2,2), (1,2,3), +(1,3,1), (1,3,2), (1,3,3), +(2,1,1), (2,1,2), (2,1,3), +(2,2,1), (2,2,2), (2,2,3), +(2,3,1), (2,3,2), (2,3,3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +Wfs OK in ORDER BY, but not in WHERE or HAVING clauses +EXPLAIN FORMAT=JSON SELECT * FROM t ORDER BY RANK() OVER (ORDER BY a DESC,b,c); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`a` desc", + "`b`", + "`c`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c` from `test`.`t` order by rank() OVER (ORDER BY `test`.`t`.`a` desc,`test`.`t`.`b`,`test`.`t`.`c` ) +EXPLAIN FORMAT=JSON SELECT *, RANK() OVER (ORDER BY a DESC,b,c) AS `rank` FROM t ORDER BY `rank`; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "38.05" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`a` desc", + "`b`", + "`c`" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,rank() OVER (ORDER BY `test`.`t`.`a` desc,`test`.`t`.`b`,`test`.`t`.`c` ) AS `rank` from `test`.`t` order by `rank` +Windows should only be allowed in order by of a simple table query +This is legal, though: +(select a from t) union (select a from t order by (row_number() over ())); +a +1 +2 +Non constants as frame bounds +Non-unique window name +Illegal legacy position indication in window's ORDER BY clause +EXPLAIN FORMAT=JSON SELECT * FROM ( +SELECT a,b,c, RANK() OVER (ORDER BY 1*1) FROM t +) alias ORDER BY a,b,c; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "22.52" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "a", + "b", + "c", + "RANK() OVER (ORDER BY 1*1)" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "20.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "(1 * 1)" + ], + "functions": [ + "rank" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b", + "c" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`a` AS `a`,`alias`.`b` AS `b`,`alias`.`c` AS `c`,`alias`.`RANK() OVER (ORDER BY 1*1)` AS `RANK() OVER (ORDER BY 1*1)` from (/* select#2 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,rank() OVER (ORDER BY (1 * 1) ) AS `RANK() OVER (ORDER BY 1*1)` from `test`.`t`) `alias` order by `alias`.`a`,`alias`.`b`,`alias`.`c` +Crashed: more than one window in subquery +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT count(*) OVER (), sum(c) OVER () AS sum1, a from t) as alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "720" + }, + "used_columns": [ + "count(*) OVER ()", + "sum1", + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "c" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`count(*) OVER ()` AS `count(*) OVER ()`,`alias`.`sum1` AS `sum1`,`alias`.`a` AS `a` from (/* select#2 */ select count(0) OVER () AS `count(*) OVER ()`,sum(`test`.`t`.`c`) OVER () AS `sum1`,`test`.`t`.`a` AS `a` from `test`.`t`) `alias` +Crashed: expression containing window function(s) in subquery +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT count(*) OVER () + sum(c) OVER () AS sum1, a from t) as alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "sum1", + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "c" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`sum1` AS `sum1`,`alias`.`a` AS `a` from (/* select#2 */ select (count(0) OVER () + sum(`test`.`t`.`c`) OVER () ) AS `sum1`,`test`.`t`.`a` AS `a` from `test`.`t`) `alias` +Wrong result if subquery window function referenced another column in the select list +This was OK, but: +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT SUM(b) OVER (), a FROM t) AS alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "SUM(b) OVER ()", + "a" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`SUM(b) OVER ()` AS `SUM(b) OVER ()`,`alias`.`a` AS `a` from (/* select#2 */ select sum(`test`.`t`.`b`) OVER () AS `SUM(b) OVER ()`,`test`.`t`.`a` AS `a` from `test`.`t`) `alias` +this one failed with NULL as sum +EXPLAIN FORMAT=JSON SELECT * FROM (SELECT SUM(b) OVER (), b FROM t) AS alias; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.52" + }, + "table": { + "table_name": "alias", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "2.73", + "eval_cost": "1.80", + "prefix_cost": "4.53", + "data_read_per_join": "576" + }, + "used_columns": [ + "SUM(b) OVER ()", + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "2.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "b" + ] + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `alias`.`SUM(b) OVER ()` AS `SUM(b) OVER ()`,`alias`.`b` AS `b` from (/* select#2 */ select sum(`test`.`t`.`b`) OVER () AS `SUM(b) OVER ()`,`test`.`t`.`b` AS `b` from `test`.`t`) `alias` +Window function having subquery in argument: +CREATE TABLE u(d INT); +SELECT AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u)) FROM t; +AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u)) +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +EXPLAIN FORMAT=JSON SELECT AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u)) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "20.05" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "(select (`a` + `d`) from `u`)", + "(select `d` from `u`)" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "18.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 18, + "rows_produced_per_join": 18, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.80", + "prefix_cost": "2.05", + "data_read_per_join": "288" + }, + "used_columns": [ + "a" + ] + }, + "select_list_subqueries": [ + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 4, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "d" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 3, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "d" + ] + } + } + }, + { + "dependent": true, + "cacheable": false, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "u", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "d" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1276 Field or reference 'test.t.a' of SELECT #4 was resolved in SELECT #1 +Note 1276 Field or reference 'test.t.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ select avg((`test`.`t`.`a` * (/* select#4 */ select (`test`.`t`.`a` * `test`.`u`.`d`) from `test`.`u`))) OVER (PARTITION BY (/* select#2 */ select (`test`.`t`.`a` + `test`.`u`.`d`) from `test`.`u`) ORDER BY (/* select#3 */ select `test`.`u`.`d` from `test`.`u`) ) AS `AVG(a * (SELECT a*d FROM u)) OVER +(PARTITION BY (SELECT a+d FROM u) ORDER BY (SELECT d FROM u))` from `test`.`t` +DROP TABLE u; +Crash due to unguarded access for window name string for an unnamed +window while producing the error message +Check that DISTINCT is not allowed in wfs +Check that GROUPS bounds unit is not supported yet +Check that EXCLUDE in frames is not supported yet +Check Nested wfs +DROP TABLE t; +Crash report (Srikanth) +CREATE TABLE t(a int, b int); +INSERT INTO t VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT SUM(a) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`a`) OVER (ORDER BY `test`.`t`.`b` ) AS `SUM(a) OVER (ORDER BY b)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT COUNT(*) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(0) OVER (ORDER BY `test`.`t`.`b` ) AS `COUNT(*) OVER (ORDER BY b)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT AVG(b) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t`.`b`) OVER (ORDER BY `test`.`t`.`b` ) AS `AVG(b) OVER (ORDER BY b)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT a,b,LAST_VALUE(a) OVER (ORDER BY b,a) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`", + "`a`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,last_value(`test`.`t`.`a`) OVER (ORDER BY `test`.`t`.`b`,`test`.`t`.`a` ) AS `LAST_VALUE(a) OVER (ORDER BY b,a)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT NTILE(2) OVER (ORDER BY b) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "ntile" + ] + } + ], + "cost_info": { + "sort_cost": "6.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select ntile(2) OVER (ORDER BY `test`.`t`.`b` ) AS `NTILE(2) OVER (ORDER BY b)` from `test`.`t` +DROP TABLE t; +Wrong result (Srikanth) +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (1,2), +(1,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT a, b, COUNT(a) OVER w count, +SUM(a) OVER w sum, +AVG(a) over w average, +LAST_VALUE(a) OVER w lastval FROM t1 +WINDOW w as (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.45" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`a`", + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "sum", + "avg", + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "2.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) OVER `w` AS `count`,sum(`test`.`t1`.`a`) OVER `w` AS `sum`,avg(`test`.`t1`.`a`) OVER `w` AS `average`,last_value(`test`.`t1`.`a`) OVER `w` AS `lastval` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`a` ORDER BY `test`.`t1`.`b` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +INSERT INTO t1 VALUES (1,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT a, b, COUNT(a) OVER w count, +SUM(a) OVER w sum, +AVG(a) OVER w average, +LAST_VALUE(a) OVER w lastval FROM t1 +WINDOW w as (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.55" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`a`", + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "sum", + "avg", + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "3.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) OVER `w` AS `count`,sum(`test`.`t1`.`a`) OVER `w` AS `sum`,avg(`test`.`t1`.`a`) OVER `w` AS `average`,last_value(`test`.`t1`.`a`) OVER `w` AS `lastval` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`a` ORDER BY `test`.`t1`.`b` ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) +EXPLAIN FORMAT=JSON SELECT a, b, COUNT(a) OVER w count, +SUM(a) OVER w sum, +AVG(a) OVER w average, +LAST_VALUE(a) OVER w lastval FROM t1 +WINDOW w as (PARTITION BY a ORDER BY b ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.55" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`a`", + "`b`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count", + "sum", + "avg", + "last_value" + ] + } + ], + "cost_info": { + "sort_cost": "3.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) OVER `w` AS `count`,sum(`test`.`t1`.`a`) OVER `w` AS `sum`,avg(`test`.`t1`.`a`) OVER `w` AS `average`,last_value(`test`.`t1`.`a`) OVER `w` AS `lastval` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`a` ORDER BY `test`.`t1`.`b` ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING) +DROP TABLE t1; +frame buffer navigation assert +CREATE TABLE ta (a INT(11) DEFAULT NULL, b INT(11) DEFAULT NULL); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO ta VALUES (1,1), (1,2), (1,3), (2,1), (2,2), (2,3); +ANALYZE TABLE ta; +Table Op Msg_type Msg_text +test.ta analyze status OK +EXPLAIN FORMAT=JSON SELECT last_value(b) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM ta; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.85" + }, + "windowing": { + "windows": [ + { + "name": "", + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "last_value" + ] + } + ], + "table": { + "table_name": "ta", + "access_type": "ALL", + "rows_examined_per_scan": 6, + "rows_produced_per_join": 6, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.60", + "prefix_cost": "0.85", + "data_read_per_join": "96" + }, + "used_columns": [ + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select last_value(`test`.`ta`.`b`) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS `last_value(b) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)` from `test`.`ta` +DROP TABLE ta; +Nullability fix bug for COUNT OVER in non optimized eval strategy +CREATE TABLE t(d DOUBLE); +INSERT INTO t VALUES (1.0), (2.0), (3.0); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT SUM(d) OVER w, COUNT(*) OVER w FROM t WINDOW W AS (ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.55" + }, + "windowing": { + "windows": [ + { + "name": "W", + "frame_buffer": { + "using_temporary_table": true + }, + "functions": [ + "sum", + "count" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 3, + "rows_produced_per_join": 3, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.30", + "prefix_cost": "0.55", + "data_read_per_join": "48" + }, + "used_columns": [ + "d" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`d`) OVER `W` AS `SUM(d) OVER w`,count(0) OVER `W` AS `COUNT(*) OVER w` from `test`.`t` window `W` AS (ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +DROP TABLE t; +Bug in inverse logic with initial NULL and RANGE BETWEEN N FOLLOWING AND M FOLLOWING +CREATE TABLE t1 (d DOUBLE, id INT, sex CHAR(1), n INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(n)); +INSERT INTO t1(d, id, sex) VALUES (1.0, 1, 'M'), +(2.0, 2, 'F'), +(3.0, 3, 'F'), +(4.0, 4, 'F'), +(5.0, 5, 'M'), +(NULL, NULL, 'M'), +(10.0, 10, NULL), +(10.0, 10, NULL), +(11.0, 11, NULL); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN FORMAT=JSON SELECT id, AVG(id) over w `avg`, SUM(id) OVER w `sum`, COUNT(*) OVER w cnt FROM t1 WINDOW w as (ORDER BY id RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`id`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "id", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,avg(`test`.`t1`.`id`) OVER `w` AS `avg`,sum(`test`.`t1`.`id`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`id` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +SET windowing_use_high_precision= OFF; +EXPLAIN FORMAT=JSON SELECT d, AVG(d) over w `avg`, SUM(d) OVER w `sum`, COUNT(*) OVER w cnt FROM t1 WINDOW w as (ORDER BY d RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "10.15" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`d`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg", + "sum", + "count" + ] + } + ], + "cost_info": { + "sort_cost": "9.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 9, + "rows_produced_per_join": 9, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.90", + "prefix_cost": "1.15", + "data_read_per_join": "216" + }, + "used_columns": [ + "d", + "n" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`d` AS `d`,avg(`test`.`t1`.`d`) OVER `w` AS `avg`,sum(`test`.`t1`.`d`) OVER `w` AS `sum`,count(0) OVER `w` AS `cnt` from `test`.`t1` window `w` AS (ORDER BY `test`.`t1`.`d` RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) +SET windowing_use_high_precision= ON; +DROP TABLE t1; +Bug in inverse logic with e.g. ROWS BETWEEN UNBOUNDED PRECEDING AND 1 +FOLLOWING: at end of partition, when no rows are removed or added we +lacked initialization of aggregates in optimized mode. +CREATE TABLE t (i char(10), j int); +INSERT INTO t VALUES('A', 1); +INSERT INTO t VALUES('A', 3); +INSERT INTO t VALUES('A', 5); +INSERT INTO t VALUES('B', 1); +INSERT INTO t VALUES('B', 7); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT i, j, SUM(j) OVER w FROM t +WINDOW w AS (PARTITION BY i ORDER BY j +ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "windowing": { + "windows": [ + { + "name": "w", + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "240" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`j` AS `j`,sum(`test`.`t`.`j`) OVER `w` AS `SUM(j) OVER w` from `test`.`t` window `w` AS (PARTITION BY `test`.`t`.`i` ORDER BY `test`.`t`.`j` ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) +Test definition_position: references don't count, only definitions, +thus we have an unnamed, then another unnamed (based on w but not +exactly w) then w then two unnamed. +EXPLAIN FORMAT=JSON SELECT SUM(j) OVER w, COUNT(j) OVER (), +AVG(j) OVER (w ORDER BY j), FIRST_VALUE(j) OVER w +FROM t WINDOW w AS (PARTITION BY i) +ORDER BY LAST_VALUE(j) OVER w, NTH_VALUE(j,1) OVER (), +ROW_NUMBER() OVER (PARTITION BY j); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "20.75" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "windowing": { + "windows": [ + { + "name": "w", + "definition_position": 3, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum", + "first_value", + "last_value" + ] + }, + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "count" + ] + }, + { + "name": "", + "definition_position": 2, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`", + "`j`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "avg" + ] + }, + { + "name": "", + "definition_position": 4, + "using_temporary_table": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "nth_value" + ] + }, + { + "name": "", + "definition_position": 5, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`j`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "15.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "240" + }, + "used_columns": [ + "i", + "j" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t`.`j`) OVER `w` AS `SUM(j) OVER w`,count(`test`.`t`.`j`) OVER () AS `COUNT(j) OVER ()`,avg(`test`.`t`.`j`) OVER (`w` ORDER BY `test`.`t`.`j` ) AS `AVG(j) OVER (w ORDER BY j)`,first_value(`test`.`t`.`j`) OVER `w` AS `FIRST_VALUE(j) OVER w` from `test`.`t` window `w` AS (PARTITION BY `test`.`t`.`i` ) order by last_value(`test`.`t`.`j`) OVER `w`,nth_value(`test`.`t`.`j`,1) OVER () ,row_number() OVER (PARTITION BY `test`.`t`.`j` ) +DROP TABLE t; +# +# Bug#26114396 WL#9603: SIG11 AT OPT_EXPLAIN_JSON_NAMESPACE::WINDOW_CTX::FORMAT_BODY +# +CREATE TABLE t1(a int,b int); +CREATE TABLE t2(a int,b int); +INSERT INTO t1 VALUES (0,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +INSERT INTO t2 VALUES +(2,8),(81,0),(6,7),(8,1),(4,0),(0,2),(6,5),(5,4),(0,6),(9,3), +(5,0),(6,254),(6,0),(2,7),(8,73),(9,7),(3,5),(0,5),(7,75),(2,1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN FORMAT=JSON +SELECT ROW_NUMBER() OVER () AS rn +FROM ( t1 LEFT JOIN t2 ON (t2.a <= t1 . a ) ) +WHERE t1.a = 3 +GROUP BY t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.60" + }, + "grouping_operation": { + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t1`.`a` = 3)" + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 20, + "rows_produced_per_join": 20, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.00", + "prefix_cost": "2.60", + "data_read_per_join": "320" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`a` <= 3), true)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `rn` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` <= 3)) where (`test`.`t1`.`a` = 3) group by `test`.`t1`.`a` +DROP TABLE t1,t2; +# +# Printing the true number of "using temporary table" +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES(1, 1); +FLUSH STATUS; +SELECT t1.a, SUM(t2.b) OVER(ORDER BY t1.a) FROM t1, t1 AS t2 ORDER BY t2.a; +a SUM(t2.b) OVER(ORDER BY t1.a) +1 1 +SHOW STATUS LIKE 'Created_tmp_tables'; +Variable_name Value +Created_tmp_tables 2 +EXPLAIN FORMAT=JSON SELECT t1.a, SUM(t2.b) OVER(ORDER BY t1.a) FROM t1, t1 AS t2 ORDER BY t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "2.70" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "1.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`a`" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "1.00" + }, + "buffer_result": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "a" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.70", + "data_read_per_join": "16" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t2`.`b`) OVER (ORDER BY `test`.`t1`.`a` ) AS `SUM(t2.b) OVER(ORDER BY t1.a)` from `test`.`t1` join `test`.`t1` `t2` order by `test`.`t2`.`a` +DROP TABLE t1; +# +# Bug#26612356 WINDOW FUNCTIONS: FIX COST ESTIMATES +# +CREATE TABLE t(i INT); +INSERT INTO t VALUES +(2), (3), (1), (5), (8), (4), (6), (2), (10), (16), (4), (6), (2), +(10), (16), (8), (12), (4), (20), (32), (19), (29), (9), (49), (79), +(39), (59), (19), (99), (159), (39), (59), (19), (99), (159), (79), +(119), (39), (199), (319); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN FORMAT=JSON SELECT * FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "query_block": { + "cost_info": { + "query_cost": "4.25" + }, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT * FROM t ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "ordering_operation": { + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` order by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT * FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` group by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT * FROM t GROUP BY i ORDER BY i DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "640" + }, + "used_columns": [ + "i" + ], + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i` from `test`.`t` group by `test`.`t`.`i` desc order by `test`.`t`.`i` desc +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT DISTINCT i FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t`.`i` AS `i` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT DISTINCT ROW_NUMBER() OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "duplicates_removal": { + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER () FROM t ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` order by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER () FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "functions": [ + "row_number" + ] + } + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER () AS `ROW_NUMBER() OVER ()` from `test`.`t` group by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT DISTINCT ROW_NUMBER() OVER (PARTITION BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "duplicates_removal": { + "using_filesort": false, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` +Final ORDER BY i could be eliminated +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` order by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t ORDER BY i DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` order by `test`.`t`.`i` desc +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER () FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER () AS `SUM(i) OVER ()` from `test`.`t` +Sorting for 2nd window redundant and skipped +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` ) AS `SUM(i) OVER (ORDER BY i)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "84.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` +Could be optimized further to drop final ordering +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i ORDER BY i DESC; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "124.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` desc order by `test`.`t`.`i` desc +Reordering of windows could have made it possible to eliminate final ORDER BY +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i ORDER BY i; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "124.25" + }, + "ordering_operation": { + "using_filesort": true, + "cost_info": { + "sort_cost": "40.00" + }, + "windowing": { + "windows": [ + { + "name": "", + "definition_position": 1, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + }, + { + "name": "", + "definition_position": 2, + "last_executed_window": true, + "using_temporary_table": true, + "using_filesort": true, + "filesort_key": [ + "`i` desc" + ], + "frame_buffer": { + "using_temporary_table": true, + "optimized_frame_evaluation": true + }, + "functions": [ + "sum" + ] + } + ], + "cost_info": { + "sort_cost": "80.00" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)`,sum(`test`.`t`.`i`) OVER (ORDER BY `test`.`t`.`i` desc ) AS `SUM(i) OVER (ORDER BY i DESC)` from `test`.`t` group by `test`.`t`.`i` order by `test`.`t`.`i` +Implicit grouping should eliminate windowing ordering costs: only one row +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (ORDER BY AVG(i)) AS rn FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "4.25" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (ORDER BY avg(`test`.`t`.`i`) ) AS `rn` from `test`.`t` +Used to miss printing the sorting key +EXPLAIN FORMAT=JSON SELECT ROW_NUMBER() OVER (PARTITION BY i) FROM t; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "44.25" + }, + "windowing": { + "windows": [ + { + "name": "", + "using_filesort": true, + "filesort_key": [ + "`i`" + ], + "functions": [ + "row_number" + ] + } + ], + "cost_info": { + "sort_cost": "40.00" + }, + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 40, + "rows_produced_per_join": 40, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "4.00", + "prefix_cost": "4.25", + "data_read_per_join": "320" + }, + "used_columns": [ + "i" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select row_number() OVER (PARTITION BY `test`.`t`.`i` ) AS `ROW_NUMBER() OVER (PARTITION BY i)` from `test`.`t` +Test optimizer trace with window costs +SET optimizer_trace="enabled=on"; +SELECT ROW_NUMBER() OVER (PARTITION BY i), SUM(i) OVER (ORDER BY i DESC) FROM t GROUP BY i ORDER BY i; +ROW_NUMBER() OVER (PARTITION BY i) SUM(i) OVER (ORDER BY i DESC) +1 1297 +1 1296 +1 1294 +1 1291 +1 1287 +1 1282 +1 1276 +1 1268 +1 1259 +1 1249 +1 1237 +1 1221 +1 1202 +1 1182 +1 1153 +1 1121 +1 1082 +1 1033 +1 974 +1 895 +1 796 +1 677 +1 518 +1 319 +SELECT REGEXP_SUBSTR(TRACE, 'join_optimization.*', 1, 1, 'n') FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +REGEXP_SUBSTR(TRACE, 'join_optimization.*', 1, 1, 'n') +join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "table_scan": { + "rows": 40, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 40, + "access_type": "scan", + "resulting_rows": 40, + "cost": 4.25, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 40, + "cost_for_plan": 4.25, + "sort_cost": 40, + "new_cost_for_plan": 44.25, + "chosen": true, + "windowing_sort_cost": 80, + "new_cost_for_plan": 124.25 + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t`.`i`", + "items": [ + { + "item": "`t`.`i`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t`.`i`" + }, + "simplifying_group_by": { + "original_clause": "`t`.`i`", + "items": [ + { + "item": "`t`.`i`" + } + ], + "resulting_clause_is_simple": false, + "resulting_clause": "`t`.`i`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + }, + { + "adding_tmp_table_in_plan_at_position": 2, + "cause": "output_for_window_functions", + "with_buffer": false, + "write_method": "write_all_rows", + "adding_sort_to_previous_table": { + "filesort": { + "adding_sort_to_table": "" + } + } + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "intermediate_tmp_table", + "columns": 6, + "row_length": 29, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "adding_tmp_table_in_plan_at_position": 3, + "cause": "output_for_window_functions", + "with_buffer": true, + "write_method": "write_all_rows", + "adding_sort_to_previous_table": { + "filesort": { + "adding_sort_to_table": "" + } + }, + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 3, + "columns": 7, + "row_length": 45, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "materialize": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 2, + "columns": 6, + "row_length": 29, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "materialize": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 5, + "row_length": 22, + "key_length": 5, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "TempTable" + } + } + }, + { + "materialize": { + "select#": 1, + "steps": [ + ] + } + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "asc", + "expression": "`t`.`i`" + } + ], + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + }, + "filesort_execution": [ + ], + "filesort_summary": { + "memory_available": 262144, + "key_size": "XXX", + "row_size": "XXX", + "max_rows_per_buffer": "NNN", + "num_rows_estimate": 40, + "num_rows_found": 24, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::stable_sort", + "sort_mode": "" + } + } + ] + } + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "desc", + "expression": "`t`.`i`" + } + ], + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + }, + "filesort_execution": [ + ], + "filesort_summary": { + "memory_available": 262144, + "key_size": "XXX", + "row_size": "XXX", + "max_rows_per_buffer": "NNN", + "num_rows_estimate": 15, + "num_rows_found": 24, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::stable_sort", + "sort_mode": "" + } + } + ] + } + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "asc", + "expression": "`t`.`i`" + } + ], + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + }, + "filesort_execution": [ + ], + "filesort_summary": { + "memory_available": 262144, + "key_size": "XXX", + "row_size": "XXX", + "max_rows_per_buffer": "NNN", + "num_rows_estimate": 15, + "num_rows_found": 24, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::sort", + "sort_mode": "" + } + } + ] + } + } + ] +} +SET optimizer_trace="enabled=off"; +DROP TABLE t; diff --git a/mysql-test/r/with_grant.result-pq b/mysql-test/r/with_grant.result-pq new file mode 100644 index 000000000..e3eae4b05 --- /dev/null +++ b/mysql-test/r/with_grant.result-pq @@ -0,0 +1,55 @@ +# privileges +create database mysqltest1; +use mysqltest1; +create table t1(pub int, priv int); +insert into t1 values(1,2); +analyze table t1; +Table Op Msg_type Msg_text +mysqltest1.t1 analyze status OK +CREATE USER user1@localhost; +GRANT SELECT (pub) ON mysqltest1.t1 TO user1@localhost; +use mysqltest1; +select pub from t1; +pub +1 +select priv from t1; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +select * from (select pub from t1) as dt; +pub +1 +explain select * from (select pub from t1) as dt; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`pub` AS `pub` from `mysqltest1`.`t1` +select /*+ merge(dt) */ * from (select priv from t1) as dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +select /*+ no_merge(dt) */ * from (select priv from t1) as dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +explain select * from (select priv from t1) as dt; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +with qn as (select pub from t1) select * from qn; +pub +1 +explain with qn as (select pub from t1) select * from qn; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `mysqltest1`.`t1`.`pub` AS `pub` from `mysqltest1`.`t1` +with qn as (select priv from t1) select /*+ merge(qn) */ * from qn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +with qn as (select priv from t1) select /*+ no_merge(qn) */ * from qn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +explain with qn as (select priv from t1) select * from qn; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +with qn2 as (with qn as (select pub from t1) select * from qn) +select * from qn2; +pub +1 +with qn2 as (with qn as (select priv from t1) select * from qn) +select * from qn2; +ERROR 42000: SELECT command denied to user 'user1'@'localhost' for column 'priv' in table 't1' +drop user user1@localhost; +drop database mysqltest1; diff --git a/mysql-test/r/with_non_recursive.result-pq b/mysql-test/r/with_non_recursive.result-pq new file mode 100644 index 000000000..4b9e13389 --- /dev/null +++ b/mysql-test/r/with_non_recursive.result-pq @@ -0,0 +1,2230 @@ +# In-memory tmp tables +set big_tables=0; +# WL#883 Non-recursive WITH clause (common table expression) +flush status; +create table t1(a int, b int, c int); +insert into t1 values(null,null,null),(2,3,4); +WITH qn AS (SELECT a FROM t1) +SELECT 1 FROM dual; +1 +1 +# two query names +WITH qn AS (SELECT a FROM t1), qn2 as (select b from t1) +SELECT 1 FROM dual; +1 +1 +# duplicate query names +WITH qn AS (SELECT a FROM t1), qn as (select b from t1) +SELECT 1 FROM qn; +ERROR 42000: Not unique table/alias: 'qn' +# multiple refs +WITH qn AS (SELECT b as a FROM t1) +SELECT qn.a, qn2.a FROM qn, qn as qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT c FROM t1 WHERE a IS NULL or a>0) +SELECT qn.a, qn2.c FROM qn, qn2; +a c +3 4 +3 NULL +NULL 4 +NULL NULL +# qn2 ref qn: +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a FROM qn) +SELECT * from qn2; +3*a +NULL +60 +WITH qn AS (SELECT a FROM t1), qn2 AS (SELECT a FROM qn) +SELECT * from qn2; +a +NULL +2 +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +EXPLAIN WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 75.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `a`,`test`.`t1`.`b` AS `a` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`b` is null) or (`test`.`t1`.`b` > 0)) +# forward ref (should error) +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM t1) +SELECT qn2.a FROM qn2; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn1 as (with qn3 as (select * from qn2) select * from qn3), +qn2 as (select 1) +select * from qn1; +ERROR 42S02: Table 'test.qn2' doesn't exist +# This is valid; it is to test moving boundaries. +# When we resolve qn3, resolving qn1 moves the right bound to +# qn0, but the bound is properly restored so that we can later +# resolve qn2. +with qn0 as (select 1), qn1 as (select * from qn0), qn2 as (select 1), qn3 as (select 1 from qn1, qn2) select 1 from qn3; +1 +1 +# No ref +explain with qn as (select 1) select 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 2 AS `2` +with qn as (select 1) select 2; +2 +2 +# circular ref +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM qn2) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# recursive +WITH qn AS (SELECT a FROM qn) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +WITH qn1 AS (SELECT a FROM qn3), +qn2 AS (SELECT a FROM qn1), +qn3 AS (SELECT a FROM t1), +qn4 AS (SELECT a FROM qn2) +SELECT a FROM qn4; +ERROR 42S02: Table 'test.qn3' doesn't exist +# ref from subq +with qn as (select * from t1) select (select max(a) from qn); +(select max(a) from qn) +2 +# QN defined in subq +SELECT (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +FROM t1; +(WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +NULL +NULL +SELECT * +FROM (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2) +AS dt; +b +NULL +60 +# WITH in WITH +with qn as +(with qn2 as (select "qn2" as a from t1) select "qn", a from qn2) +select * from qn; +qn a +qn qn2 +qn qn2 +# outer ref to a table, placed in a QN in a subq (later) +# QN defined in view +CREATE VIEW v AS +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM v; +b +NULL +60 +DROP VIEW v; +# CREATE INSERT SELECT +CREATE TABLE t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +INSERT INTO t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +NULL +60 +DROP TABLE t2; +# Double use of QN in two subqueries. +explain with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 SUBQUERY NULL ref 5 const 1 100.00 NULL +2 SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` limit 10) /* select#1 */ select (/* select#2 */ select max(`qn`.`a`) from `qn` where (`qn`.`a` = 0)) AS `(select max(a) from qn where a=0)`,(/* select#4 */ select min(`qn`.`b`) from `qn` where (`qn`.`b` = 3)) AS `(select min(b) from qn where b=3)` +with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +(select max(a) from qn where a=0) (select min(b) from qn where b=3) +NULL 3 +# when QN, when table. +create table qn select "base"; +select * from qn; +base +base +with qn as (select "with") select * from qn; +with +with +# In a non-recursive WITH, the scope of the QN doesn't extend to its +# subquery, so "qn" inside AS() is the base table. +WITH qn AS (select * from qn) select * from qn; +base +base +# View doesn't look out to external QNs +create view v as select * from qn; +select * from v; +base +base +with qn as (select "with") select * from v; +base +base +with qn as (select * from v) select * from qn; +base +base +# Even if the base table is temporarily dropped +drop table qn; +with qn as (select "with") select * from v; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +with qn as (select * from v) select * from qn; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +create table qn select "base" as a; +# Neither does SP +create function f() returns varchar(10) +return (select * from qn); +select f(); +f() +base +with qn as (select "with") select f(); +f() +base +with qn as (select f()) select * from qn; +f() +base +# QN shadows tmp table +create temporary table qn select "tmp" as a; +select * from qn; +a +tmp +with qn as (select "with") select * from qn; +with +with +drop function f; +drop view v; +# DT shadows QN: +with qn as (select "with") select * from (select "dt") as qn; +dt +dt +# QN of subq shadows outer QN +WITH qn AS (select "outer" as a) +SELECT (WITH qn AS (SELECT "inner" as a) SELECT a from qn), +qn.a +FROM qn; +(WITH qn AS (SELECT "inner" as a) SELECT a from qn) a +inner outer +# Qualified name isn't allowed after WITH: +with test.qn as (select "with") select * from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.qn as (select "with") select * from test.qn' at line 1 +# Adding a db. prefix to a field still resolves to the QN; it's a bit awkward as +# the QN doesn't belong to a db, but it's the same with derived table: +select test.qn.a from (select "with" as a) qn; +a +with +# OTOH, db. prefix in FROM doesn't resolve to QN, which is good +with qn as (select "with") select * from qn; +with +with +with qn as (select "with") select * from test.qn; +a +tmp +with qn as (select "with" as a) select a from qn; +a +with +with qn as (select "with" as a) select qn.a from qn; +a +with +with qn as (select "with" as a) select test.qn.a from qn; +a +with +with qn as (select "with" as a) select a from test.qn; +a +tmp +with qn as (select "with" as a) select qn.a from test.qn; +a +tmp +with qn as (select "with" as a) select test.qn.a from test.qn; +a +tmp +drop temporary table qn; +with qn as (select "with" as a) select a from test.qn; +a +base +with qn as (select "with" as a) select qn.a from test.qn; +a +base +with qn as (select "with" as a) select test.qn.a from test.qn; +a +base +drop table qn; +with qn as (select "with" as a) select a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select test.qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# Unions +WITH qn AS (SELECT b as a FROM t1 UNION SELECT b+5 FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a FROM qn +UNION SELECT qn2.a FROM qn2 WHERE qn2.a>3; +a +NULL +3 +8 +# No double WITH +with qn as (select "with" as a) +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# with comma +with qn as (select "with" as a), +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# ORDER BY removed unless there is LIMIT or single table (check "Using filesort") +explain +with qn as (select a from t1 order by 1) +select a from qn; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `qn`.`a` +explain +with qn as (select a from t1 order by 1) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t1` `t2` +explain +with qn as (select a from t1 order by 1 limit 10) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 with `qn` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 10) /* select#1 */ select `qn`.`a` AS `a` from `qn` join `test`.`t1` `t2` +# Merge hint +explain +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn2` as (/* select#3 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qn2`.`b` AS `b` from `test`.`t1` join `qn2` +explain +with qn as (select a from t1) +select /*+ merge(qn) no_merge(qn2) */ qn2.a from qn, qn as qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `qn2`.`a` AS `a` from `test`.`t1` join `qn` `qn2` +# FD detection +with qn as (select a, b from t1) +select b from qn group by a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'qn.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +with qn as (select a, b from t1 where a=b) +select b from qn group by a; +b +with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a; +s +NULL +3 +# CTEs work if used in SET +set @myvar= +(with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a having s is not null); +select @myvar; +@myvar +3 +# CTE works with semijoin +explain with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `cte` as (/* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` `t2` limit 1) /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`cte`) where (`test`.`t1`.`a` = (`cte`.`a` + 0)) +with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +a b c +explain with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t1` `t2`) where (`test`.`t1`.`a` = (`test`.`t2`.`a` + 0)) +with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +a b c +2 3 4 +# Column names +# empty list +with qn () as (select 1) select * from qn, qn qn1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as (select 1) select * from qn, qn qn1' at line 1 +# Materialization +with qn (foo, bar) as (select 1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +explain with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` (`foo`,`bar`) as (/* select#2 */ select 1 AS `1`,2 AS `2` from `test`.`t1` limit 2) /* select#1 */ select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar`,`qn1`.`foo` AS `foo`,`qn1`.`bar` AS `bar` from `qn` join `qn` `qn1` +with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll union +select a,b from t1) select qn1.bar from qn qn1; +bar +2 +NULL +3 +with qn (foo, bar) as (select a, b from t1 limit 2) select qn.bar,foo from qn; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1 limit 2) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Merge +with qn (foo, bar) as (select 1 from t1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +explain with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `foo`,2 AS `bar`,1 AS `foo`,2 AS `bar` from `test`.`t1` join `test`.`t1` +with qn (foo, bar) as (select 1 as col, 2 as coll from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select a, b from t1) select qn1.bar,foo from qn qn1; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Disambiguates same-name expressions +with qn as (select 1,1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1) select * from qn; +foo bar +1 1 +with qn as (select 1,1 from t1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +foo bar +1 1 +1 1 +# Duplicate names are forbidden +with qn (foo, foo) as (select 1,2) select * from qn; +ERROR 42S21: Duplicate column name 'foo' +# Derived tables support this too +select * from (select '1', 1) dt(foo,bar); +foo bar +1 1 +select * from (select a,b from t1) dt(foo,bar); +foo bar +NULL NULL +2 3 +select * from (select a from t1) dt(foo,bar); +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +# Column names for QN/DT are printed +create view v1 as +with qn (foo, bar) as (select 1,1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +show fields from v1; +Field Type Null Key Default Extra +foo int NO 0 +bar int NO 0 +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +select * from (select 1,1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1` from `t1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +create view v1 as +select * from (select 1,1 from t1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1` from `t1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +# printing with back-quoting is necessary, when using a +# reserved word as column name. +create view v1 as +select * from (select 1) dt(`select`); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`select` AS `select` from (select 1 AS `1`) `dt` (`select`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +select +1 +drop view v1; +# Works for views too. Using testcase of: +# Bug#23265335 SPECIFYING A NAME FOR VIEW'S COLUMN IN CREATE VIEW MAKES SELECT FAIL +create view v1 (bar) as +select 1 as foo group by foo union select 2 order by foo; +select * from v1; +bar +1 +2 +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`bar`) AS select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` utf8mb4 utf8mb4_0900_ai_ci +# The column's name for the view +select TABLE_NAME,COLUMN_NAME from information_schema.columns +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +TABLE_NAME COLUMN_NAME +v1 bar +# is different from the alias in the defining SELECT +select VIEW_DEFINITION from information_schema.views +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +VIEW_DEFINITION +select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` +drop view v1; +create view v1 (bar) as +select 1, 2 from t1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +drop table t1; +# Prove that a materialized QN is shared among all references: +create table t1(a int); +insert into t1 values(1),(2),(3),(4); +flush status; +with qn as (select 123 as col) +select * from qn; +col +123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +flush status; +with qn as (select 123 as col) +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +create view qn as select 123 as col; +flush status; +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +drop view qn; +drop table t1; +# Printing of WITH to DD for view +create view v as +select (with qn as (select "with") select * from qn) as scal_subq +from dual; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (with `qn` as (select 'with' AS `with`) select `qn`.`with` from `qn`) AS `scal_subq` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +scal_subq +with +drop view v; +create view v as select * from (with qn as (select "with") select * from qn) as dt; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `dt`.`with` AS `with` from (with `qn` as (select 'with' AS `with`) select `qn`.`with` AS `with` from `qn`) `dt` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +with +with +drop view v; +# Printing of merged/materialized QN, with or without alias +create table t1 (a int); +explain with qne as (select a from t1), +qnm as (select a from t1), +qnea as (select a from t1), +qnma as (select a from t1) +select /*+ merge(qne) no_merge(qnm) merge(alias1) no_merge(alias2) */ +qne.a,qnm.a,alias1.a,alias2.a +from qne, qnm, qnea as alias1, qnma as alias2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 with `qnm` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`), `qnma` as (/* select#5 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qne`@`select#1`) NO_MERGE(`qnm`@`select#1`) MERGE(`alias1`@`select#1`) NO_MERGE(`alias2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qnm`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`alias2`.`a` AS `a` from `test`.`t1` join `qnm` join `test`.`t1` join `qnma` `alias2` +drop table t1; +# Automatic index creation if materialized +create table t1 (a int); +insert into t1(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# EXPLAIN should not fill the tmp table +flush status; +# Should use auto_key0 and ref access. +explain with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a # 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 with `tt` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ NO_MERGE(`tt`@`select#1`) */ `tt`.`a` AS `a` from `test`.`t1` straight_join `tt` where (`tt`.`a` = `test`.`t1`.`a`) limit 1 +show status like "handler_write"; +Variable_name Value +Handler_write 0 +flush status; +with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +a +1 +show status like "handler_write"; +Variable_name Value +Handler_write 10 +# With two references +with tt as (select * from t1) +select /*+ no_merge(tt) no_merge(tt_)*/ tt.a +from t1 straight_join tt straight_join tt as tt_ +where t1.a=tt.a and tt.a=tt_.a +limit 1; +a +1 +# One merged, one materialized: index creation on the second +# should of course ignore the first +with q as (select * from t1) +select /*+ merge(q) no_merge(q1) */ * from q, q q1 where q.a=1 and q1.a=2; +a a +1 2 +drop table t1; +# Must not create more than 64 indexes. +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +(select max(c1) from qn where qn.c1=1) (select max(c2) from qn where qn.c2=1) (select max(c3) from qn where qn.c3=1) (select max(c4) from qn where qn.c4=1) (select max(c5) from qn where qn.c5=1) (select max(c6) from qn where qn.c6=1) (select max(c7) from qn where qn.c7=1) (select max(c8) from qn where qn.c8=1) (select max(c9) from qn where qn.c9=1) (select max(c10) from qn where qn.c10=1) (select max(c11) from qn where qn.c11=1) (select max(c12) from qn where qn.c12=1) (select max(c13) from qn where qn.c13=1) (select max(c14) from qn where qn.c14=1) (select max(c15) from qn where qn.c15=1) (select max(c16) from qn where qn.c16=1) (select max(c17) from qn where qn.c17=1) (select max(c18) from qn where qn.c18=1) (select max(c19) from qn where qn.c19=1) (select max(c20) from qn where qn.c20=1) (select max(c21) from qn where qn.c21=1) (select max(c22) from qn where qn.c22=1) (select max(c23) from qn where qn.c23=1) (select max(c24) from qn where qn.c24=1) (select max(c25) from qn where qn.c25=1) (select max(c26) from qn where qn.c26=1) (select max(c27) from qn where qn.c27=1) (select max(c28) from qn where qn.c28=1) (select max(c29) from qn where qn.c29=1) (select max(c30) from qn where qn.c30=1) (select max(c31) from qn where qn.c31=1) (select max(c32) from qn where qn.c32=1) (select max(c33) from qn where qn.c33=1) (select max(c34) from qn where qn.c34=1) (select max(c35) from qn where qn.c35=1) (select max(c36) from qn where qn.c36=1) (select max(c37) from qn where qn.c37=1) (select max(c38) from qn where qn.c38=1) (select max(c39) from qn where qn.c39=1) (select max(c40) from qn where qn.c40=1) (select max(c41) from qn where qn.c41=1) (select max(c42) from qn where qn.c42=1) (select max(c43) from qn where qn.c43=1) (select max(c44) from qn where qn.c44=1) (select max(c45) from qn where qn.c45=1) (select max(c46) from qn where qn.c46=1) (select max(c47) from qn where qn.c47=1) (select max(c48) from qn where qn.c48=1) (select max(c49) from qn where qn.c49=1) (select max(c50) from qn where qn.c50=1) (select max(c51) from qn where qn.c51=1) (select max(c52) from qn where qn.c52=1) (select max(c53) from qn where qn.c53=1) (select max(c54) from qn where qn.c54=1) (select max(c55) from qn where qn.c55=1) (select max(c56) from qn where qn.c56=1) (select max(c57) from qn where qn.c57=1) (select max(c58) from qn where qn.c58=1) (select max(c59) from qn where qn.c59=1) (select max(c60) from qn where qn.c60=1) (select max(c61) from qn where qn.c61=1) (select max(c62) from qn where qn.c62=1) (select max(c63) from qn where qn.c63=1) (select max(c64) from qn where qn.c64=1) (select max(c65) from qn where qn.c65=1) (select max(c66) from qn where qn.c66=1) (select max(c67) from qn where qn.c67=1) (select max(c68) from qn where qn.c68=1) (select max(c69) from qn where qn.c69=1) (select max(c70) from qn where qn.c70=1) (select max(c71) from qn where qn.c71=1) (select max(c72) from qn where qn.c72=1) (select max(c73) from qn where qn.c73=1) (select max(c74) from qn where qn.c74=1) (select max(c75) from qn where qn.c75=1) (select max(c76) from qn where qn.c76=1) (select max(c77) from qn where qn.c77=1) (select max(c78) from qn where qn.c78=1) (select max(c79) from qn where qn.c79=1) (select max(c80) from qn where qn.c80=1) (select max(c81) from qn where qn.c81=1) (select max(c82) from qn where qn.c82=1) (select max(c83) from qn where qn.c83=1) (select max(c84) from qn where qn.c84=1) (select max(c85) from qn where qn.c85=1) (select max(c86) from qn where qn.c86=1) (select max(c87) from qn where qn.c87=1) (select max(c88) from qn where qn.c88=1) (select max(c89) from qn where qn.c89=1) (select max(c90) from qn where qn.c90=1) (select max(c91) from qn where qn.c91=1) (select max(c92) from qn where qn.c92=1) (select max(c93) from qn where qn.c93=1) (select max(c94) from qn where qn.c94=1) (select max(c95) from qn where qn.c95=1) (select max(c96) from qn where qn.c96=1) (select max(c97) from qn where qn.c97=1) (select max(c98) from qn where qn.c98=1) (select max(c99) from qn where qn.c99=1) (select max(c100) from qn where qn.c100=1) +NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +drop table t; +# Choice between two auto_key: +create table t1(a int, b int); +insert into t1 values (null, 6), (null, 10); +# Test the covering key; note that MEMORY doesn't use a +# covering key (always reads the "data file"). But InnoDB does. +EXPLAIN with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 with `t2` as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a` = `test`.`t1`.`a`) or (`test`.`t1`.`b` <= 6)) and (`test`.`t1`.`a` is null))) /* select#1 */ select /*+ NO_MERGE(`t2`@`select#1`) */ `t2`.`a` AS `a`,`t2`.`b` AS `b` from `t2` +with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +a b +NULL 6 +drop table t1; +# QN referencing view of same name isn't a "recursive view", +# shouldn't cause ER_VIEW_RECURSIVE +create view v1 as select "with"; +with v1 as (select * from v1) select * from v1; +with +with +drop view v1; +# QN inside view +create view v1 as +with qn as (select 1 as col) select * from qn; +select * from v1; +col +1 +drop view v1; +create table t1(a int, b int); +# Alas merge hints are ignored in views (filed Bug#23017428) +create view v1 as +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t1` +drop view v1; +# Materializing view doesn't impose materializing query name +create algorithm=temptable view v1 as +with qn as (select a from t1) +select qn.a from qn; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +drop table t1; +# CTE referenced four times, including in subqueries in other CTEs +create table sales_days(day_of_sale DATE, amount INT); +insert into sales_days values +('2015-01-02', 100), ('2015-01-05', 200), +('2015-02-02', 10), ('2015-02-10', 100), +('2015-03-02', 10), ('2015-03-18', 1); +with +# first CTE: one row per month, with amount sold on all days of month +sales_by_month(month,total) as +(select month(day_of_sale), sum(amount) from sales_days +where year(day_of_sale)=2015 +group by month(day_of_sale)), +# second CTE: best month +best_month(month, total, award) as +(select month, total, "best" from sales_by_month +where total=(select max(total) from sales_by_month)), +# 3rd CTE: worst month +worst_month(month, total, award) as +(select month, total, "worst" from sales_by_month +where total=(select min(total) from sales_by_month)) +# Now show results: +select * from best_month union all select * from worst_month; +month total award +1 300 best +3 11 worst +drop table sales_days; +# Special parser command not allowed to users. +parse_cte ( select 1 ) ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'parse_cte ( select 1 )' at line 1 +# Query names are a partial workaround to the problem that +# user-created temp tables can't be referenced twice. +create temporary table tmp(a int) as select 1; +select * from tmp, tmp tmp1; +ERROR HY000: Can't reopen table: 'tmp' +# the workaround works if the temp table's life is necessary +# only for a single statement: +with qn as (select 1) select * from qn, qn qn1; +1 1 +1 1 +# If the tmp table is necessary, wrapping it in a query name doesn't +# help: +with qn as (select * from tmp) select /*+ merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +with qn as (select * from tmp) select /*+ no_merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +drop temporary table tmp; +# Using a query name in UPDATE +create table t1(a int, b int); +insert into t1 values(1,2),(3,4); +create table t2 select * from t1; +set autocommit=0; +# Multi-table syntax +with qn as (select a, b from t1) update t1, qn set qn.a=qn.a+10; +ERROR HY000: The target table t1 of the UPDATE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` set `test`.`t1`.`a` = ((`test`.`t1`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` join `qn` set `test`.`t1`.`a` = (`qn`.`a` + 10) where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +# Two references to query name +explain with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +13 4 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select (`qn`.`a` + 10) from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ MERGE(`qn`@`select#2`) */ `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select ((`test`.`t2`.`a` + 2) + 10) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +# Using a query name in DELETE +# Multi-table syntax +with qn as (select a, b from t1) delete qn from t1,qn; +ERROR HY000: The target table qn of the DELETE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` from `test`.`t1` join `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select `qn`.`a` from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 delete /*+ MERGE(`qn`@`select#2`) */ from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select (`test`.`t2`.`a` + 2) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +drop table t1,t2; +set autocommit=default; +# No default db +select database(); +database() +test +create database mysqltest1; +use mysqltest1; +drop database mysqltest1; +select database(); +database() +NULL +with qn as (select 1) select * from qn; +1 +1 +# Back to usual db 'test' +use test; +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 0 +# On-disk tmp tables +set big_tables=1; +# WL#883 Non-recursive WITH clause (common table expression) +flush status; +create table t1(a int, b int, c int); +insert into t1 values(null,null,null),(2,3,4); +WITH qn AS (SELECT a FROM t1) +SELECT 1 FROM dual; +1 +1 +# two query names +WITH qn AS (SELECT a FROM t1), qn2 as (select b from t1) +SELECT 1 FROM dual; +1 +1 +# duplicate query names +WITH qn AS (SELECT a FROM t1), qn as (select b from t1) +SELECT 1 FROM qn; +ERROR 42000: Not unique table/alias: 'qn' +# multiple refs +WITH qn AS (SELECT b as a FROM t1) +SELECT qn.a, qn2.a FROM qn, qn as qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT c FROM t1 WHERE a IS NULL or a>0) +SELECT qn.a, qn2.c FROM qn, qn2; +a c +3 4 +3 NULL +NULL 4 +NULL NULL +# qn2 ref qn: +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a FROM qn) +SELECT * from qn2; +3*a +NULL +60 +WITH qn AS (SELECT a FROM t1), qn2 AS (SELECT a FROM qn) +SELECT * from qn2; +a +NULL +2 +WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +a a +3 3 +3 NULL +NULL 3 +NULL NULL +EXPLAIN WITH qn AS (SELECT b as a FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a, qn2.a FROM qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 75.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 75.00 Using where +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `a`,`test`.`t1`.`b` AS `a` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`b` is null) or (`test`.`t1`.`b` > 0)) +# forward ref (should error) +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM t1) +SELECT qn2.a FROM qn2; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn1 as (with qn3 as (select * from qn2) select * from qn3), +qn2 as (select 1) +select * from qn1; +ERROR 42S02: Table 'test.qn2' doesn't exist +# This is valid; it is to test moving boundaries. +# When we resolve qn3, resolving qn1 moves the right bound to +# qn0, but the bound is properly restored so that we can later +# resolve qn2. +with qn0 as (select 1), qn1 as (select * from qn0), qn2 as (select 1), qn3 as (select 1 from qn1, qn2) select 1 from qn3; +1 +1 +# No ref +explain with qn as (select 1) select 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ select 2 AS `2` +with qn as (select 1) select 2; +2 +2 +# circular ref +WITH qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0), +qn AS (SELECT b as a FROM qn2) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# recursive +WITH qn AS (SELECT a FROM qn) +SELECT qn.a FROM qn; +ERROR 42S02: Table 'test.qn' doesn't exist +WITH qn1 AS (SELECT a FROM qn3), +qn2 AS (SELECT a FROM qn1), +qn3 AS (SELECT a FROM t1), +qn4 AS (SELECT a FROM qn2) +SELECT a FROM qn4; +ERROR 42S02: Table 'test.qn3' doesn't exist +# ref from subq +with qn as (select * from t1) select (select max(a) from qn); +(select max(a) from qn) +2 +# QN defined in subq +SELECT (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +FROM t1; +(WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2 LIMIT 1) +NULL +NULL +SELECT * +FROM (WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2) +AS dt; +b +NULL +60 +# WITH in WITH +with qn as +(with qn2 as (select "qn2" as a from t1) select "qn", a from qn2) +select * from qn; +qn a +qn qn2 +qn qn2 +# outer ref to a table, placed in a QN in a subq (later) +# QN defined in view +CREATE VIEW v AS +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM v; +b +NULL +60 +DROP VIEW v; +# CREATE INSERT SELECT +CREATE TABLE t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +INSERT INTO t2 +WITH qn AS (SELECT 10*a as a FROM t1), +qn2 AS (SELECT 3*a AS b FROM qn) +SELECT * from qn2; +SELECT * FROM t2; +b +NULL +60 +NULL +60 +DROP TABLE t2; +# Double use of QN in two subqueries. +explain with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used +4 SUBQUERY NULL ref 5 const 1 100.00 NULL +2 SUBQUERY NULL ref 5 const 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` limit 10) /* select#1 */ select (/* select#2 */ select max(`qn`.`a`) from `qn` where (`qn`.`a` = 0)) AS `(select max(a) from qn where a=0)`,(/* select#4 */ select min(`qn`.`b`) from `qn` where (`qn`.`b` = 3)) AS `(select min(b) from qn where b=3)` +with qn as (select * from t1 limit 10) +select (select max(a) from qn where a=0), +(select min(b) from qn where b=3); +(select max(a) from qn where a=0) (select min(b) from qn where b=3) +NULL 3 +# when QN, when table. +create table qn select "base"; +select * from qn; +base +base +with qn as (select "with") select * from qn; +with +with +# In a non-recursive WITH, the scope of the QN doesn't extend to its +# subquery, so "qn" inside AS() is the base table. +WITH qn AS (select * from qn) select * from qn; +base +base +# View doesn't look out to external QNs +create view v as select * from qn; +select * from v; +base +base +with qn as (select "with") select * from v; +base +base +with qn as (select * from v) select * from qn; +base +base +# Even if the base table is temporarily dropped +drop table qn; +with qn as (select "with") select * from v; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +with qn as (select * from v) select * from qn; +ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +create table qn select "base" as a; +# Neither does SP +create function f() returns varchar(10) +return (select * from qn); +select f(); +f() +base +with qn as (select "with") select f(); +f() +base +with qn as (select f()) select * from qn; +f() +base +# QN shadows tmp table +create temporary table qn select "tmp" as a; +select * from qn; +a +tmp +with qn as (select "with") select * from qn; +with +with +drop function f; +drop view v; +# DT shadows QN: +with qn as (select "with") select * from (select "dt") as qn; +dt +dt +# QN of subq shadows outer QN +WITH qn AS (select "outer" as a) +SELECT (WITH qn AS (SELECT "inner" as a) SELECT a from qn), +qn.a +FROM qn; +(WITH qn AS (SELECT "inner" as a) SELECT a from qn) a +inner outer +# Qualified name isn't allowed after WITH: +with test.qn as (select "with") select * from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.qn as (select "with") select * from test.qn' at line 1 +# Adding a db. prefix to a field still resolves to the QN; it's a bit awkward as +# the QN doesn't belong to a db, but it's the same with derived table: +select test.qn.a from (select "with" as a) qn; +a +with +# OTOH, db. prefix in FROM doesn't resolve to QN, which is good +with qn as (select "with") select * from qn; +with +with +with qn as (select "with") select * from test.qn; +a +tmp +with qn as (select "with" as a) select a from qn; +a +with +with qn as (select "with" as a) select qn.a from qn; +a +with +with qn as (select "with" as a) select test.qn.a from qn; +a +with +with qn as (select "with" as a) select a from test.qn; +a +tmp +with qn as (select "with" as a) select qn.a from test.qn; +a +tmp +with qn as (select "with" as a) select test.qn.a from test.qn; +a +tmp +drop temporary table qn; +with qn as (select "with" as a) select a from test.qn; +a +base +with qn as (select "with" as a) select qn.a from test.qn; +a +base +with qn as (select "with" as a) select test.qn.a from test.qn; +a +base +drop table qn; +with qn as (select "with" as a) select a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +with qn as (select "with" as a) select test.qn.a from test.qn; +ERROR 42S02: Table 'test.qn' doesn't exist +# Unions +WITH qn AS (SELECT b as a FROM t1 UNION SELECT b+5 FROM t1), +qn2 AS (SELECT a FROM qn WHERE a IS NULL or a>0) +SELECT qn.a FROM qn +UNION SELECT qn2.a FROM qn2 WHERE qn2.a>3; +a +NULL +3 +8 +# No double WITH +with qn as (select "with" as a) +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# with comma +with qn as (select "with" as a), +with qn2 as (select "with" as a) +select a from test.qn; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'with qn2 as (select "with" as a) +select a from test.qn' at line 2 +# ORDER BY removed unless there is LIMIT or single table (check "Using filesort") +explain +with qn as (select a from t1 order by 1) +select a from qn; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `qn`.`a` +explain +with qn as (select a from t1 order by 1) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t1` `t2` +explain +with qn as (select a from t1 order by 1 limit 10) +select qn.a from qn, t1 as t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 with `qn` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` limit 10) /* select#1 */ select `qn`.`a` AS `a` from `qn` join `test`.`t1` `t2` +# Merge hint +explain +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn2` as (/* select#3 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qn2`.`b` AS `b` from `test`.`t1` join `qn2` +explain +with qn as (select a from t1) +select /*+ merge(qn) no_merge(qn2) */ qn2.a from qn, qn as qn2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qn`@`select#1`) NO_MERGE(`qn2`@`select#1`) */ `qn2`.`a` AS `a` from `test`.`t1` join `qn` `qn2` +# FD detection +with qn as (select a, b from t1) +select b from qn group by a; +ERROR 42000: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'qn.b' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by +with qn as (select a, b from t1 where a=b) +select b from qn group by a; +b +with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a; +s +NULL +3 +# CTEs work if used in SET +set @myvar= +(with qn as (select a, sum(b) as s from t1 group by a) +select s from qn group by a having s is not null); +select @myvar; +@myvar +3 +# CTE works with semijoin +explain with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `cte` as (/* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` `t2` limit 1) /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`cte`) where (`test`.`t1`.`a` = (`cte`.`a` + 0)) +with cte as (select * from t1 as t2 limit 1) +select * from t1 where t1.a in (select a+0 from cte); +a b c +explain with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t1` `t2`) where (`test`.`t1`.`a` = (`test`.`t2`.`a` + 0)) +with cte as (select * from t1 as t2) +select * from t1 where t1.a in (select a+0 from cte); +a b c +2 3 4 +# Column names +# empty list +with qn () as (select 1) select * from qn, qn qn1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as (select 1) select * from qn, qn qn1' at line 1 +# Materialization +with qn (foo, bar) as (select 1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +explain with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` (`foo`,`bar`) as (/* select#2 */ select 1 AS `1`,2 AS `2` from `test`.`t1` limit 2) /* select#1 */ select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar`,`qn1`.`foo` AS `foo`,`qn1`.`bar` AS `bar` from `qn` join `qn` `qn1` +with qn (foo, bar) as (select 1, 2 from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll from t1 limit 2) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select 1 as col, 2 as coll union +select a,b from t1) select qn1.bar from qn qn1; +bar +NULL +2 +3 +with qn (foo, bar) as (select a, b from t1 limit 2) select qn.bar,foo from qn; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1 limit 2) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Merge +with qn (foo, bar) as (select 1 from t1) select * from qn, qn qn1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +explain with qn (foo, bar) as (select 1, 2 from t1) select * from qn, qn qn1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select 1 AS `foo`,2 AS `bar`,1 AS `foo`,2 AS `bar` from `test`.`t1` join `test`.`t1` +with qn (foo, bar) as (select 1 as col, 2 as coll from t1) select * from qn, qn qn1; +foo bar foo bar +1 2 1 2 +1 2 1 2 +1 2 1 2 +1 2 1 2 +with qn (foo, bar) as (select a, b from t1) select qn1.bar,foo from qn qn1; +bar foo +NULL NULL +3 2 +create table t3 +with qn (foo, bar) as (select a, b from t1) select bar,foo from qn; +desc t3; +Field Type Null Key Default Extra +bar int YES NULL +foo int YES NULL +drop table t3; +# Disambiguates same-name expressions +with qn as (select 1,1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1) select * from qn; +foo bar +1 1 +with qn as (select 1,1 from t1) select * from qn; +ERROR 42S21: Duplicate column name '1' +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +foo bar +1 1 +1 1 +# Duplicate names are forbidden +with qn (foo, foo) as (select 1,2) select * from qn; +ERROR 42S21: Duplicate column name 'foo' +# Derived tables support this too +select * from (select '1', 1) dt(foo,bar); +foo bar +1 1 +select * from (select a,b from t1) dt(foo,bar); +foo bar +NULL NULL +2 3 +select * from (select a from t1) dt(foo,bar); +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +# Column names for QN/DT are printed +create view v1 as +with qn (foo, bar) as (select 1,1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +show fields from v1; +Field Type Null Key Default Extra +foo int NO 0 +bar int NO 0 +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +select * from (select 1,1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +drop view v1; +create view v1 as +with qn (foo, bar) as (select 1,1 from t1) select * from qn; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with `qn` (`foo`,`bar`) as (select 1 AS `1`,1 AS `1` from `t1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +create view v1 as +select * from (select 1,1 from t1) dt(foo,bar); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`foo` AS `foo`,`dt`.`bar` AS `bar` from (select 1 AS `1`,1 AS `1` from `t1`) `dt` (`foo`,`bar`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +foo bar +1 1 +1 1 +drop view v1; +# printing with back-quoting is necessary, when using a +# reserved word as column name. +create view v1 as +select * from (select 1) dt(`select`); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `dt`.`select` AS `select` from (select 1 AS `1`) `dt` (`select`) utf8mb4 utf8mb4_0900_ai_ci +select * from v1; +select +1 +drop view v1; +# Works for views too. Using testcase of: +# Bug#23265335 SPECIFYING A NAME FOR VIEW'S COLUMN IN CREATE VIEW MAKES SELECT FAIL +create view v1 (bar) as +select 1 as foo group by foo union select 2 order by foo; +select * from v1; +bar +1 +2 +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` (`bar`) AS select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` utf8mb4 utf8mb4_0900_ai_ci +# The column's name for the view +select TABLE_NAME,COLUMN_NAME from information_schema.columns +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +TABLE_NAME COLUMN_NAME +v1 bar +# is different from the alias in the defining SELECT +select VIEW_DEFINITION from information_schema.views +where TABLE_SCHEMA='test' and TABLE_NAME='v1'; +VIEW_DEFINITION +select 1 AS `foo` group by `foo` union select 2 AS `2` order by `foo` +drop view v1; +create view v1 (bar) as +select 1, 2 from t1; +ERROR HY000: In definition of view, derived table or common table expression, SELECT list and column names list have different column counts +drop table t1; +# Prove that a materialized QN is shared among all references: +create table t1(a int); +insert into t1 values(1),(2),(3),(4); +flush status; +with qn as (select 123 as col) +select * from qn; +col +123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +flush status; +with qn as (select 123 as col) +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 1 +create view qn as select 123 as col; +flush status; +select * from qn, qn as qn1; +col col +123 123 +show status like "handler_write"; +Variable_name Value +Handler_write 2 +drop view qn; +drop table t1; +# Printing of WITH to DD for view +create view v as +select (with qn as (select "with") select * from qn) as scal_subq +from dual; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (with `qn` as (select 'with' AS `with`) select `qn`.`with` from `qn`) AS `scal_subq` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +scal_subq +with +drop view v; +create view v as select * from (with qn as (select "with") select * from qn) as dt; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `dt`.`with` AS `with` from (with `qn` as (select 'with' AS `with`) select `qn`.`with` AS `with` from `qn`) `dt` utf8mb4 utf8mb4_0900_ai_ci +select * from v; +with +with +drop view v; +# Printing of merged/materialized QN, with or without alias +create table t1 (a int); +explain with qne as (select a from t1), +qnm as (select a from t1), +qnea as (select a from t1), +qnma as (select a from t1) +select /*+ merge(qne) no_merge(qnm) merge(alias1) no_merge(alias2) */ +qne.a,qnm.a,alias1.a,alias2.a +from qne, qnm, qnea as alias1, qnma as alias2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (hash join) +5 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +3 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 with `qnm` as (/* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`), `qnma` as (/* select#5 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ MERGE(`qne`@`select#1`) NO_MERGE(`qnm`@`select#1`) MERGE(`alias1`@`select#1`) NO_MERGE(`alias2`@`select#1`) */ `test`.`t1`.`a` AS `a`,`qnm`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`alias2`.`a` AS `a` from `test`.`t1` join `qnm` join `test`.`t1` join `qnma` `alias2` +drop table t1; +# Automatic index creation if materialized +create table t1 (a int); +insert into t1(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# EXPLAIN should not fill the tmp table +flush status; +# Should use auto_key0 and ref access. +explain with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL ALL NULL NULL NULL NULL # 100.00 Using where +1 PRIMARY NULL ref 5 test.t1.a # 100.00 Using index +2 DERIVED t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 with `tt` as (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) /* select#1 */ select /*+ NO_MERGE(`tt`@`select#1`) */ `tt`.`a` AS `a` from `test`.`t1` straight_join `tt` where (`tt`.`a` = `test`.`t1`.`a`) limit 1 +show status like "handler_write"; +Variable_name Value +Handler_write 0 +flush status; +with tt as (select * from t1) +select /*+ no_merge(tt) */ tt.a +from t1 straight_join tt where t1.a=tt.a +limit 1; +a +1 +show status like "handler_write"; +Variable_name Value +Handler_write 10 +# With two references +with tt as (select * from t1) +select /*+ no_merge(tt) no_merge(tt_)*/ tt.a +from t1 straight_join tt straight_join tt as tt_ +where t1.a=tt.a and tt.a=tt_.a +limit 1; +a +1 +# One merged, one materialized: index creation on the second +# should of course ignore the first +with q as (select * from t1) +select /*+ merge(q) no_merge(q1) */ * from q, q q1 where q.a=1 and q1.a=2; +a a +1 2 +drop table t1; +# Must not create more than 64 indexes. +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +(select max(c1) from qn where qn.c1=1) (select max(c2) from qn where qn.c2=1) (select max(c3) from qn where qn.c3=1) (select max(c4) from qn where qn.c4=1) (select max(c5) from qn where qn.c5=1) (select max(c6) from qn where qn.c6=1) (select max(c7) from qn where qn.c7=1) (select max(c8) from qn where qn.c8=1) (select max(c9) from qn where qn.c9=1) (select max(c10) from qn where qn.c10=1) (select max(c11) from qn where qn.c11=1) (select max(c12) from qn where qn.c12=1) (select max(c13) from qn where qn.c13=1) (select max(c14) from qn where qn.c14=1) (select max(c15) from qn where qn.c15=1) (select max(c16) from qn where qn.c16=1) (select max(c17) from qn where qn.c17=1) (select max(c18) from qn where qn.c18=1) (select max(c19) from qn where qn.c19=1) (select max(c20) from qn where qn.c20=1) (select max(c21) from qn where qn.c21=1) (select max(c22) from qn where qn.c22=1) (select max(c23) from qn where qn.c23=1) (select max(c24) from qn where qn.c24=1) (select max(c25) from qn where qn.c25=1) (select max(c26) from qn where qn.c26=1) (select max(c27) from qn where qn.c27=1) (select max(c28) from qn where qn.c28=1) (select max(c29) from qn where qn.c29=1) (select max(c30) from qn where qn.c30=1) (select max(c31) from qn where qn.c31=1) (select max(c32) from qn where qn.c32=1) (select max(c33) from qn where qn.c33=1) (select max(c34) from qn where qn.c34=1) (select max(c35) from qn where qn.c35=1) (select max(c36) from qn where qn.c36=1) (select max(c37) from qn where qn.c37=1) (select max(c38) from qn where qn.c38=1) (select max(c39) from qn where qn.c39=1) (select max(c40) from qn where qn.c40=1) (select max(c41) from qn where qn.c41=1) (select max(c42) from qn where qn.c42=1) (select max(c43) from qn where qn.c43=1) (select max(c44) from qn where qn.c44=1) (select max(c45) from qn where qn.c45=1) (select max(c46) from qn where qn.c46=1) (select max(c47) from qn where qn.c47=1) (select max(c48) from qn where qn.c48=1) (select max(c49) from qn where qn.c49=1) (select max(c50) from qn where qn.c50=1) (select max(c51) from qn where qn.c51=1) (select max(c52) from qn where qn.c52=1) (select max(c53) from qn where qn.c53=1) (select max(c54) from qn where qn.c54=1) (select max(c55) from qn where qn.c55=1) (select max(c56) from qn where qn.c56=1) (select max(c57) from qn where qn.c57=1) (select max(c58) from qn where qn.c58=1) (select max(c59) from qn where qn.c59=1) (select max(c60) from qn where qn.c60=1) (select max(c61) from qn where qn.c61=1) (select max(c62) from qn where qn.c62=1) (select max(c63) from qn where qn.c63=1) (select max(c64) from qn where qn.c64=1) (select max(c65) from qn where qn.c65=1) (select max(c66) from qn where qn.c66=1) (select max(c67) from qn where qn.c67=1) (select max(c68) from qn where qn.c68=1) (select max(c69) from qn where qn.c69=1) (select max(c70) from qn where qn.c70=1) (select max(c71) from qn where qn.c71=1) (select max(c72) from qn where qn.c72=1) (select max(c73) from qn where qn.c73=1) (select max(c74) from qn where qn.c74=1) (select max(c75) from qn where qn.c75=1) (select max(c76) from qn where qn.c76=1) (select max(c77) from qn where qn.c77=1) (select max(c78) from qn where qn.c78=1) (select max(c79) from qn where qn.c79=1) (select max(c80) from qn where qn.c80=1) (select max(c81) from qn where qn.c81=1) (select max(c82) from qn where qn.c82=1) (select max(c83) from qn where qn.c83=1) (select max(c84) from qn where qn.c84=1) (select max(c85) from qn where qn.c85=1) (select max(c86) from qn where qn.c86=1) (select max(c87) from qn where qn.c87=1) (select max(c88) from qn where qn.c88=1) (select max(c89) from qn where qn.c89=1) (select max(c90) from qn where qn.c90=1) (select max(c91) from qn where qn.c91=1) (select max(c92) from qn where qn.c92=1) (select max(c93) from qn where qn.c93=1) (select max(c94) from qn where qn.c94=1) (select max(c95) from qn where qn.c95=1) (select max(c96) from qn where qn.c96=1) (select max(c97) from qn where qn.c97=1) (select max(c98) from qn where qn.c98=1) (select max(c99) from qn where qn.c99=1) (select max(c100) from qn where qn.c100=1) +NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +drop table t; +# Choice between two auto_key: +create table t1(a int, b int); +insert into t1 values (null, 6), (null, 10); +# Test the covering key; note that MEMORY doesn't use a +# covering key (always reads the "data file"). But InnoDB does. +EXPLAIN with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 with `t2` as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (((`test`.`t1`.`a` = `test`.`t1`.`a`) or (`test`.`t1`.`b` <= 6)) and (`test`.`t1`.`a` is null))) /* select#1 */ select /*+ NO_MERGE(`t2`@`select#1`) */ `t2`.`a` AS `a`,`t2`.`b` AS `b` from `t2` +with t2 as +(select * from t1) +SELECT /*+ no_merge(t2) */ * FROM t2 +WHERE (a = a OR b <= 6) AND (a IS NULL); +a b +NULL 6 +drop table t1; +# QN referencing view of same name isn't a "recursive view", +# shouldn't cause ER_VIEW_RECURSIVE +create view v1 as select "with"; +with v1 as (select * from v1) select * from v1; +with +with +drop view v1; +# QN inside view +create view v1 as +with qn as (select 1 as col) select * from qn; +select * from v1; +col +1 +drop view v1; +create table t1(a int, b int); +# Alas merge hints are ignored in views (filed Bug#23017428) +create view v1 as +with qn as (select a from t1), +qn2 as (select b from t1) +select /*+ merge(qn) no_merge(qn2) */ qn.a,qn2.b from qn, qn2; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t1` +drop view v1; +# Materializing view doesn't impose materializing query name +create algorithm=temptable view v1 as +with qn as (select a from t1) +select qn.a from qn; +explain select * from v1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`v1`.`a` AS `a` from `test`.`v1` +drop view v1; +drop table t1; +# CTE referenced four times, including in subqueries in other CTEs +create table sales_days(day_of_sale DATE, amount INT); +insert into sales_days values +('2015-01-02', 100), ('2015-01-05', 200), +('2015-02-02', 10), ('2015-02-10', 100), +('2015-03-02', 10), ('2015-03-18', 1); +with +# first CTE: one row per month, with amount sold on all days of month +sales_by_month(month,total) as +(select month(day_of_sale), sum(amount) from sales_days +where year(day_of_sale)=2015 +group by month(day_of_sale)), +# second CTE: best month +best_month(month, total, award) as +(select month, total, "best" from sales_by_month +where total=(select max(total) from sales_by_month)), +# 3rd CTE: worst month +worst_month(month, total, award) as +(select month, total, "worst" from sales_by_month +where total=(select min(total) from sales_by_month)) +# Now show results: +select * from best_month union all select * from worst_month; +month total award +1 300 best +3 11 worst +drop table sales_days; +# Special parser command not allowed to users. +parse_cte ( select 1 ) ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'parse_cte ( select 1 )' at line 1 +# Query names are a partial workaround to the problem that +# user-created temp tables can't be referenced twice. +create temporary table tmp(a int) as select 1; +select * from tmp, tmp tmp1; +ERROR HY000: Can't reopen table: 'tmp' +# the workaround works if the temp table's life is necessary +# only for a single statement: +with qn as (select 1) select * from qn, qn qn1; +1 1 +1 1 +# If the tmp table is necessary, wrapping it in a query name doesn't +# help: +with qn as (select * from tmp) select /*+ merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +with qn as (select * from tmp) select /*+ no_merge(qn,qn1) */ * from qn, qn qn1; +ERROR HY000: Can't reopen table: 'tmp' +drop temporary table tmp; +# Using a query name in UPDATE +create table t1(a int, b int); +insert into t1 values(1,2),(3,4); +create table t2 select * from t1; +set autocommit=0; +# Multi-table syntax +with qn as (select a, b from t1) update t1, qn set qn.a=qn.a+10; +ERROR HY000: The target table t1 of the UPDATE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` set `test`.`t1`.`a` = ((`test`.`t1`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) update t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` join `qn` set `test`.`t1`.`a` = (`qn`.`a` + 10) where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) update /*+ no_merge(qn) */ t1, qn set t1.a=qn.a+10 where t1.a-qn.a=0; +select * from t1; +a b +1 2 +13 4 +rollback; +# Two references to query name +explain with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` join `test`.`t2` set `test`.`t1`.`a` = ((`test`.`t2`.`a` + 2) + 10) where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +update t1, qn, qn as qn2 set t1.a=qn.a+10 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +13 4 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) update `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select (`qn`.`a` + 10) from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +explain with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update /*+ MERGE(`qn`@`select#2`) */ `test`.`t1` set `test`.`t1`.`a` = (/* select#2 */ select ((`test`.`t2`.`a` + 2) + 10) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1) +with qn as (select a+2 as a, b from t2) update t1 +set t1.a=(select /*+ merge(qn) */ qn.a+10 from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +NULL 2 +13 4 +rollback; +# Using a query name in DELETE +# Multi-table syntax +with qn as (select a, b from t1) delete qn from t1,qn; +ERROR HY000: The target table qn of the DELETE is not updatable +select * from t1; +a b +1 2 +3 4 +rollback; +explain with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`a` - (`test`.`t1`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t1) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) +with qn as (select a+2 as a, b from t2) delete t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +2 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 with `qn` as (/* select#2 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete /*+ NO_MERGE(`qn`@`select#1`) */ `test`.`t1` from `test`.`t1` join `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) +with qn as (select a+2 as a, b from t2) delete /*+ no_merge(qn) */ t1 from t1, qn where t1.a-qn.a=0; +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where +Warnings: +Note 1003 delete `test`.`t1` from `test`.`t1` join `test`.`t2` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t2`.`b`) and ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0)) +with qn as (select a+2 as a, b from t2) +delete t1 from t1, qn, qn as qn2 where t1.a-qn.a=0 and qn.b=qn2.b; +select * from t1; +a b +1 2 +rollback; +# Single-table syntax +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY NULL ALL NULL NULL NULL NULL 2 100.00 Using where +3 DERIVED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 with `qn` as (/* select#3 */ select (`test`.`t2`.`a` + 2) AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) delete from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select `qn`.`a` from `qn` where ((`test`.`t1`.`a` - `qn`.`a`) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +explain with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 delete /*+ MERGE(`qn`@`select#2`) */ from `test`.`t1` where (`test`.`t1`.`a` = (/* select#2 */ select (`test`.`t2`.`a` + 2) from `test`.`t2` where ((`test`.`t1`.`a` - (`test`.`t2`.`a` + 2)) = 0) limit 1)) +with qn as (select a+2 as a, b from t2) +delete from t1 where t1.a=(select /*+ merge(qn) */ qn.a from qn where t1.a-qn.a=0 limit 1); +select * from t1; +a b +1 2 +rollback; +drop table t1,t2; +set autocommit=default; +# No default db +select database(); +database() +test +create database mysqltest1; +use mysqltest1; +drop database mysqltest1; +select database(); +database() +NULL +with qn as (select 1) select * from qn; +1 +1 +# Back to usual db 'test' +use test; +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 17 diff --git a/mysql-test/suite/gcol/r/gcol_keys_innodb.result-pq b/mysql-test/suite/gcol/r/gcol_keys_innodb.result-pq new file mode 100644 index 000000000..012c77061 --- /dev/null +++ b/mysql-test/suite/gcol/r/gcol_keys_innodb.result-pq @@ -0,0 +1,1790 @@ +SET @@session.default_storage_engine = 'InnoDB'; +# - UNIQUE KEY +# - INDEX +# - FULLTEXT INDEX +# - SPATIAL INDEX (not supported) +# - FOREIGN INDEX (partially supported) +# - CHECK (allowed but not used) +# UNIQUE +create table t1 (a int, b int generated always as (a*2) virtual unique); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL VIRTUAL GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored unique); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual, unique key (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL VIRTUAL GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored, unique (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + UNIQUE KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES UNI NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual); +alter table t1 add unique key (b); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored); +alter table t1 add unique key (b); +drop table t1; +# Testing data manipulation operations involving UNIQUE keys +# on generated columns can be found in: +# - gcol_ins_upd.inc +# - gcol_select.inc +# +# INDEX +create table t1 (a int, b int generated always as (a*2) virtual, index (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) VIRTUAL, + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES MUL NULL VIRTUAL GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual, index (a,b)); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored, index (b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES NULL +b int YES MUL NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored, index (a,b)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL, + `b` int GENERATED ALWAYS AS ((`a` * 2)) STORED, + KEY `a` (`a`,`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +describe t1; +Field Type Null Key Default Extra +a int YES MUL NULL +b int YES NULL STORED GENERATED +drop table t1; +create table t1 (a int, b int generated always as (a*2) virtual); +alter table t1 add index (b); +alter table t1 add index (a,b); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored); +alter table t1 add index (b); +drop table t1; +create table t1 (a int, b int generated always as (a*2) stored); +alter table t1 add index (a,b); +create table t2 like t1; +drop table t2; +drop table t1; +# Testing data manipulation operations involving INDEX +# on generated columns can be found in: +# - gcol_select.inc +# +# TODO: FULLTEXT INDEX +# SPATIAL INDEX +# FOREIGN KEY +# Rejected FK options. +create table t1 (a int, b int generated always as (a+1) stored, +foreign key (b) references t2(a) on update set null); +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column. +create table t1 (a int, b int generated always as (a+1) stored, +foreign key (b) references t2(a) on update cascade); +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column. +create table t1 (a int, b int generated always as (a+1) stored, +foreign key (b) references t2(a) on delete set null); +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column. +create table t1 (a int, b int generated always as (a+1) stored); +alter table t1 add foreign key (b) references t2(a) on update set null; +ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a generated column. +alter table t1 add foreign key (b) references t2(a) on update cascade; +ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a generated column. +alter table t1 add foreign key (b) references t2(a) on delete set null; +ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a generated column. +drop table t1; +create table t2 (a int primary key); +create table t1 (a int, b int generated always as (a+1) virtual, +foreign key (b) references t2(a)); +ERROR HY000: Foreign key 't1_ibfk_1' uses virtual column 'b' which is not supported. +create table t1 (a int, b int generated always as (a+1) virtual); +alter table t1 add foreign key (b) references t2(a); +ERROR HY000: Foreign key 't1_ibfk_1' uses virtual column 'b' which is not supported. +drop table t1, t2; +# Allowed FK options. +create table t2 (a int primary key, b char(5)); +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on update restrict); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on update no action); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on delete restrict); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on delete cascade); +drop table t1; +create table t1 (a int, b int generated always as (a % 10) stored, +foreign key (b) references t2(a) on delete no action); +drop table t1,t2; +# +# Bug#20553262: WL8149: ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED +# +CREATE TABLE c ( +pk integer AUTO_INCREMENT, +col_datetime_nokey DATETIME /*! NULL */, +col_time_nokey TIME /*! NULL */, +col_datetime_key DATETIME GENERATED ALWAYS AS +(ADDTIME(col_datetime_nokey, col_time_nokey)), +col_time_key TIME GENERATED ALWAYS AS +(ADDTIME(col_datetime_nokey, col_time_nokey)), +col_varchar_nokey VARCHAR(1) /*! NULL */, +PRIMARY KEY (pk), +KEY (col_time_key), +KEY (col_datetime_key)); +INSERT INTO c ( col_time_nokey,col_datetime_nokey,col_varchar_nokey) values +('14:03:03.042673','2001-11-28 00:50:27.051028', 'c'), +('01:46:09.016386','2007-10-09 19:53:04.008332', NULL), +('16:21:18.052408','2001-11-08 21:02:12.009395', 'x'), +('18:56:33.027423','2003-04-01 00:00:00', 'i'); +EXPLAIN SELECT +outr.col_time_key AS x +FROM c as outr +WHERE +outr.col_varchar_nokey in ('c', 'x', 'i') +AND (outr.col_time_key IS NULL OR +outr.col_datetime_key = '2009-09-27'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE outr NULL index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL x x Using sort_union(col_time_key,col_datetime_key); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`outr`.`col_time_key` AS `x` from `test`.`c` `outr` where ((`test`.`outr`.`col_varchar_nokey` in ('c','x','i')) and ((`test`.`outr`.`col_time_key` is null) or (`test`.`outr`.`col_datetime_key` = TIMESTAMP'2009-09-27 00:00:00'))) +SELECT +outr.col_time_key AS x +FROM c AS outr +WHERE +outr.col_varchar_nokey in ('c', 'x', 'i') +AND (outr.col_time_key IS NULL OR +outr.col_datetime_key = '2009-09-27'); +x +DROP TABLE c; +# +# Bug#20913803: WL8149: SIG 11 IN DFIELD_DUP | +# INNOBASE/INCLUDE/DATA0DATA.IC:253 +# +CREATE TABLE A ( +col_varchar_nokey TEXT , +col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)), +KEY (col_varchar_key(50)) +); +INSERT INTO A (col_varchar_nokey) VALUES (''); +CREATE TABLE D ( +pk INTEGER AUTO_INCREMENT, +col_date_nokey BLOB, +col_date_key BLOB GENERATED ALWAYS AS (REPEAT(col_date_nokey,1000)) VIRTUAL, +col_datetime_nokey LONGBLOB, +col_time_nokey LONGTEXT, +col_datetime_key LONGBLOB GENERATED ALWAYS AS (REPEAT(col_datetime_nokey, 1000)), +col_time_key LONGTEXT GENERATED ALWAYS AS (REPEAT(col_datetime_nokey, 1000)), +col_varchar_nokey TEXT, +col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)), +PRIMARY KEY (pk), +KEY (col_varchar_key(50)), +KEY (col_date_key(20)), +KEY (col_time_key(20)), +KEY (col_datetime_key(20)), +KEY (col_varchar_key(10), col_date_key(10), col_time_key(5), col_datetime_key(5)) +); +INSERT INTO D ( +col_date_nokey, +col_time_nokey, +col_datetime_nokey, +col_varchar_nokey +) VALUES ('', '', '', ''),('', '', '', ''); +DELETE FROM OUTR1.* USING D AS OUTR1 RIGHT JOIN A AS OUTR2 ON +( OUTR1 . `col_varchar_nokey` = OUTR2 . `col_varchar_nokey` ); +DROP TABLE IF EXISTS A,D; +# +# Bug#21024896: SIG 11 INNOBASE_ADD_ONE_VIRTUAL | +# INNOBASE/HANDLER/HANDLER0ALTER.CC +# +CREATE TABLE t1 ( +col1 int(11) DEFAULT NULL, +col2 int(11) DEFAULT NULL, +col3 int(11) NOT NULL, +col4 int(11) DEFAULT NULL, +col5 int(11) GENERATED ALWAYS AS (col2 / col2) VIRTUAL, +col7 int(11) GENERATED ALWAYS AS (col5 + col5) VIRTUAL, +col8 int(11) GENERATED ALWAYS AS (col5 * col5) VIRTUAL, +col9 text, +col6 int(11) DEFAULT NULL, +PRIMARY KEY (`col3`), +UNIQUE KEY uidx (`col2`), +KEY idx (`col5`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(col1,col2,col3,col4,col9,col6) +VALUES(1,1,0,1,REPEAT(col1,1000),0), (3,2,1,1,REPEAT(col1,1000),NULL); +ALTER TABLE t1 ADD COLUMN extra INT; +DROP TABLE t1; +# +# Bug#21316860: WL8149:INNODB: FAILING ASSERTION: +# TEMPL->CLUST_REC_FIELD_NO != ULINT_UNDEFINED +# +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey int(11), +col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) VIRTUAL NOT NULL, +col_date_nokey date, +col_date_key date GENERATED ALWAYS AS (col_date_nokey) VIRTUAL NOT NULL, +PRIMARY KEY (pk), +UNIQUE KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 DROP COLUMN pk; +DROP TABLE t1; +# Remove the impact on PK choose by index on virtual generated column +CREATE TABLE t1 ( +pk int(11) NOT NULL, +col_int_nokey int(11) DEFAULT NULL, +col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) VIRTUAL NOT NULL, +UNIQUE KEY col_int_key (col_int_key) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 add unique index idx(pk), algorithm=inplace; +DESC t1; +Field Type Null Key Default Extra +pk int NO PRI NULL +col_int_nokey int YES NULL +col_int_key int NO UNI NULL VIRTUAL GENERATED +DROP TABLE t1; +# +# Bug#21346132: WL8149:INNODB: FAILING ASSERTION: +# PRIMARY_KEY_NO == -1 || PRIMARY_KEY_NO == 0 +# +CREATE TABLE t1 ( +col_int_nokey int(11) NOT NULL, +col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) NOT NULL, +col_varchar_nokey varchar(1) NOT NULL, +col_varchar_key varchar(2) GENERATED ALWAYS AS (col_varchar_nokey) NOT NULL, +UNIQUE KEY col_int_key (col_int_key), +UNIQUE KEY col_varchar_key (col_varchar_key), +UNIQUE KEY col_int_key_2 (col_int_key,col_varchar_key), +UNIQUE KEY col_varchar_key_2 (col_varchar_key,col_varchar_nokey), +KEY col_int_key_3 (col_int_key,col_int_nokey) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t1 DROP COLUMN col_varchar_key; +Warnings: +Warning 1831 Duplicate index 'col_int_key_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +DROP TABLE t1; +# +# Bug#21320151 WL8149: WRONG RESULT WITH INDEX SCAN +# +CREATE TABLE t1 ( +id INTEGER NOT NULL, +b INTEGER GENERATED ALWAYS AS (id+1) VIRTUAL NOT NULL, +UNIQUE KEY (b) +); +INSERT INTO t1 (id) VALUES (2),(3),(4),(5),(6),(7),(8),(9),(10); +EXPLAIN SELECT b FROM t1 FORCE INDEX(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL b 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) +SELECT b FROM t1 FORCE INDEX(b); +b +3 +4 +5 +6 +7 +8 +9 +10 +11 +EXPLAIN SELECT b FROM t1 FORCE INDEX(b) WHERE b BETWEEN 1 AND 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range b b 4 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (`b`) where (`test`.`t1`.`b` between 1 and 5) +SELECT b FROM t1 FORCE INDEX(b) WHERE b BETWEEN 1 AND 5; +b +3 +4 +5 +DROP TABLE t1; + +# Testing data manipulation operations involving FOREIGN KEY +# on generated columns can be found in: +# - gcol_ins_upd.inc +# - gcol_select.inc +# +# TODO: CHECK +# +# Test how optimizer picks indexes defined on a GC +# +SET optimizer_trace_max_mem_size=1048576; +SET optimizer_trace="enabled=on,one_line=off"; +SET end_markers_in_json="on"; +CREATE TABLE t1 (f1 int, gc int AS (f1 + 1) STORED PRIMARY KEY); +INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Should use index +SELECT * FROM t1 WHERE f1 + 1 > 7; +f1 gc +7 8 +8 9 +9 10 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where (`test`.`t1`.`gc` > 7) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`f1` AS `f1`,`t1`.`gc` AS `gc` from `t1` where ((`t1`.`f1` + 1) > 7)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`f1` + 1) > 7)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`f1` + 1) > 7)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`f1` + 1) > 7)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`f1` + 1) > 7)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + "resulting_condition": "(`t1`.`gc` > 7)" + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 10, + "cost": 3.35 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "gc" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "7 < gc" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 3, + "cost": 0.560618, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 3, + "ranges": [ + "7 < gc" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 3, + "cost_for_plan": 0.560618, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 3, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 3, + "cost": 0.860618, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.860618, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`gc` > 7)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`gc` > 7)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`gc` > 7)", + "final_table_condition ": "(`t1`.`gc` > 7)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SELECT * FROM t1 WHERE f1 + 1 = 7; +f1 gc +6 7 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '6' AS `f1`,'7' AS `gc` from `test`.`t1` where true +SELECT * FROM t1 WHERE f1 + 1 IN (7,5); +f1 gc +4 5 +6 7 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where (`test`.`t1`.`gc` in (7,5)) +SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7; +f1 gc +4 5 +5 6 +6 7 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where (`test`.`t1`.`gc` between 5 and 7) +# Check that expression isn't transformed for a disabled key +SELECT * FROM t1 IGNORE KEY FOR JOIN(PRIMARY) WHERE f1 + 1 BETWEEN 5 AND 7; +f1 gc +4 5 +5 6 +6 7 +EXPLAIN SELECT * FROM t1 IGNORE KEY FOR JOIN(PRIMARY) WHERE f1 + 1 BETWEEN 5 AND 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` IGNORE INDEX FOR JOIN (PRIMARY) where ((`test`.`t1`.`f1` + 1) between 5 and 7) +# Check that ORDER BY could be optimized +SELECT * FROM t1 ORDER BY f1 + 1; +f1 gc +0 1 +1 2 +2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +EXPLAIN SELECT * FROM t1 ORDER BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` order by (`test`.`t1`.`f1` + 1) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 ORDER BY f1 + 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`f1` AS `f1`,`t1`.`gc` AS `gc` from `t1` order by (`t1`.`f1` + 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + "resulting_ORDER_BY": "`t1`.`gc`" + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 10, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 10, + "access_type": "scan", + "resulting_rows": 10, + "cost": 1.25, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10, + "cost_for_plan": 1.25, + "sort_cost": 10, + "new_cost_for_plan": 11.25, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`gc`", + "items": [ + { + "item": "`t1`.`gc`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`gc`" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT * FROM t1 IGNORE KEY FOR ORDER BY(PRIMARY) ORDER BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` IGNORE INDEX FOR ORDER BY (PRIMARY) order by (`test`.`t1`.`f1` + 1) +# Check that GROUP BY could be optimized +SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1; +f1 + 1 MAX(GC) +1 1 +10 10 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`f1` + 1) AS `f1 + 1`,max(`test`.`t1`.`gc`) AS `MAX(GC)` from `test`.`t1` group by (`test`.`t1`.`f1` + 1) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select (`t1`.`f1` + 1) AS `f1 + 1`,max(`t1`.`gc`) AS `MAX(GC)` from `t1` group by (`t1`.`f1` + 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + "resulting_GROUP_BY": "`t1`.`gc`" + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "const_keys_added": { + "keys": [ + "PRIMARY" + ] /* keys */, + "cause": "group_by" + } /* const_keys_added */, + "range_analysis": { + "table_scan": { + "rows": 10, + "cost": 3.35 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "gc" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_covering" + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 10, + "access_type": "scan", + "resulting_rows": 10, + "cost": 1.25, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10, + "cost_for_plan": 1.25, + "sort_cost": 10, + "new_cost_for_plan": 11.25, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`gc`", + "items": [ + { + "item": "`t1`.`gc`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`gc`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT f1 + 1, MAX(GC) +FROM t1 IGNORE KEY FOR GROUP BY(PRIMARY) GROUP BY f1 + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select (`test`.`t1`.`f1` + 1) AS `f1 + 1`,max(`test`.`t1`.`gc`) AS `MAX(GC)` from `test`.`t1` IGNORE INDEX FOR GROUP BY (PRIMARY) group by (`test`.`t1`.`f1` + 1) +# Shouldn't use index +SELECT * FROM t1 WHERE f1 + 1 > 7.0; +f1 gc +7 8 +8 9 +9 10 +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc` AS `gc` from `test`.`t1` where ((`test`.`t1`.`f1` + 1) > 7.0) +DROP TABLE t1; +# Pick index with proper type +CREATE TABLE t1 (f1 int, +gc_int int AS (f1 + 1) STORED, +gc_date DATE AS (f1 + 1) STORED, +KEY gc_int_idx(gc_int), +KEY gc_date_idx(gc_date)); +INSERT INTO t1(f1) VALUES +(030303),(040404), +(050505),(060606), +(010101),(020202), +(030303),(040404), +(050505),(060606), +(010101),(020202), +(090909),(101010), +(010101),(020202), +(070707),(080808); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE f1 + 1 > 070707; +f1 gc_int gc_date +101010 101011 2010-10-11 +70707 70708 2007-07-08 +80808 80809 2008-08-09 +90909 90910 2009-09-10 +# INT column & index should be picked +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc_int_idx gc_int_idx 5 NULL 4 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc_int` AS `gc_int`,`test`.`t1`.`gc_date` AS `gc_date` from `test`.`t1` where (`test`.`t1`.`gc_int` > 70707) +SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE); +f1 gc_int gc_date +101010 101011 2010-10-11 +70707 70708 2007-07-08 +80808 80809 2008-08-09 +90909 90910 2009-09-10 +# DATE column & index should be picked +EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc_date_idx gc_date_idx 4 NULL 4 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`gc_int` AS `gc_int`,`test`.`t1`.`gc_date` AS `gc_date` from `test`.`t1` where (`test`.`t1`.`gc_date` > (cast(70707 as date))) +DROP TABLE t1; +# +# BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST +# +CREATE TABLE t1 ( +pk int primary key auto_increment, +col_int_key INTEGER , +col_int_gc_key INT GENERATED ALWAYS AS (col_int_key + 1) STORED, +KEY col_int_gc_key(col_int_gc_key) +); +INSERT INTO t1 ( col_int_key) VALUES (7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +ORDER BY field1, field2; +field1 field2 +8 7 +EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +ORDER BY field1, field2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using temporary; Using filesort +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`table1`.`col_int_key` + 1) AS `field1`,`test`.`table2`.`col_int_key` AS `field2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table2`.`pk` = `test`.`table1`.`pk`) order by `field1`,`field2` +SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +GROUP BY field1, field2; +field1 field2 +8 7 +EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2 +FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk)) +GROUP BY field1, field2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE table1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using temporary +1 SIMPLE table2 NULL eq_ref PRIMARY PRIMARY 4 test.table1.pk 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select (`test`.`table1`.`col_int_key` + 1) AS `field1`,`test`.`table2`.`col_int_key` AS `field2` from `test`.`t1` `table1` join `test`.`t1` `table2` where (`test`.`table2`.`pk` = `test`.`table1`.`pk`) group by `field1`,`field2` +DROP TABLE t1; +# +# Bug#21391781 ASSERT WHEN RUNNING ALTER TABLE ON A TABLE WITH INDEX +# ON VIRTUAL COLUMN +# +CREATE TABLE t1 ( +col1 INTEGER NOT NULL, +col2 INTEGER NOT NULL, +gcol1 INTEGER GENERATED ALWAYS AS (col1 + col2) VIRTUAL, +col3 INTEGER NOT NULL, +col4 INTEGER NOT NULL, +col5 INTEGER DEFAULT NULL, +col6 INTEGER DEFAULT NULL, +col7 INTEGER DEFAULT NULL, +col8 INTEGER DEFAULT NULL, +col9 INTEGER DEFAULT NULL, +col10 INTEGER DEFAULT NULL, +col11 INTEGER DEFAULT NULL, +col12 INTEGER DEFAULT NULL, +col13 INTEGER DEFAULT NULL, +col14 INTEGER DEFAULT NULL, +col15 INTEGER DEFAULT NULL, +col16 INTEGER DEFAULT NULL, +col17 INTEGER DEFAULT NULL, +col18 INTEGER DEFAULT NULL, +col19 INTEGER DEFAULT NULL, +col20 INTEGER DEFAULT NULL, +col21 INTEGER DEFAULT NULL, +col22 INTEGER DEFAULT NULL, +col23 INTEGER DEFAULT NULL, +col24 INTEGER DEFAULT NULL, +col25 INTEGER DEFAULT NULL, +col26 INTEGER DEFAULT NULL, +col27 INTEGER DEFAULT NULL, +col28 INTEGER DEFAULT NULL, +col29 INTEGER DEFAULT NULL, +col30 INTEGER DEFAULT NULL, +col31 INTEGER DEFAULT NULL, +col32 INTEGER DEFAULT NULL, +col33 INTEGER DEFAULT NULL, +col34 INTEGER DEFAULT NULL, +col35 INTEGER DEFAULT NULL, +col36 INTEGER DEFAULT NULL, +col37 INTEGER DEFAULT NULL, +col38 INTEGER DEFAULT NULL, +col39 INTEGER DEFAULT NULL, +col40 INTEGER DEFAULT NULL, +col41 INTEGER DEFAULT NULL, +col42 INTEGER DEFAULT NULL, +col43 INTEGER DEFAULT NULL, +col44 INTEGER DEFAULT NULL, +col45 INTEGER DEFAULT NULL, +col46 INTEGER DEFAULT NULL, +col47 INTEGER DEFAULT NULL, +col48 INTEGER DEFAULT NULL, +col49 INTEGER DEFAULT NULL, +col50 INTEGER DEFAULT NULL, +col51 INTEGER DEFAULT NULL, +col52 INTEGER DEFAULT NULL, +col53 INTEGER DEFAULT NULL, +col54 INTEGER DEFAULT NULL, +col55 INTEGER DEFAULT NULL, +col56 INTEGER DEFAULT NULL, +col57 INTEGER DEFAULT NULL, +col58 INTEGER DEFAULT NULL, +col59 INTEGER DEFAULT NULL, +col60 INTEGER DEFAULT NULL, +col61 INTEGER DEFAULT NULL, +col62 INTEGER DEFAULT NULL, +col63 INTEGER DEFAULT NULL, +col64 INTEGER DEFAULT NULL, +col65 INTEGER DEFAULT NULL, +gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL, +KEY idx1 (gcol1) +); +INSERT INTO t1 (col1, col2, col3, col4) +VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5); +ALTER TABLE t1 ADD COLUMN extra INTEGER; +SELECT gcol1 FROM t1 FORCE INDEX(idx1); +gcol1 +2 +4 +6 +8 +10 +DROP TABLE t1; +CREATE TABLE t1 ( +col1 INTEGER NOT NULL, +col2 INTEGER NOT NULL, +gcol1 INTEGER GENERATED ALWAYS AS (col1 + col2) VIRTUAL, +col3 INTEGER NOT NULL, +col4 INTEGER NOT NULL, +col5 INTEGER DEFAULT NULL, +col6 INTEGER DEFAULT NULL, +col7 INTEGER DEFAULT NULL, +col8 INTEGER DEFAULT NULL, +col9 INTEGER DEFAULT NULL, +col10 INTEGER DEFAULT NULL, +col11 INTEGER DEFAULT NULL, +col12 INTEGER DEFAULT NULL, +col13 INTEGER DEFAULT NULL, +col14 INTEGER DEFAULT NULL, +col15 INTEGER DEFAULT NULL, +col16 INTEGER DEFAULT NULL, +col17 INTEGER DEFAULT NULL, +col18 INTEGER DEFAULT NULL, +col19 INTEGER DEFAULT NULL, +col20 INTEGER DEFAULT NULL, +col21 INTEGER DEFAULT NULL, +col22 INTEGER DEFAULT NULL, +col23 INTEGER DEFAULT NULL, +col24 INTEGER DEFAULT NULL, +col25 INTEGER DEFAULT NULL, +col26 INTEGER DEFAULT NULL, +col27 INTEGER DEFAULT NULL, +col28 INTEGER DEFAULT NULL, +col29 INTEGER DEFAULT NULL, +col30 INTEGER DEFAULT NULL, +col31 INTEGER DEFAULT NULL, +col32 INTEGER DEFAULT NULL, +col33 INTEGER DEFAULT NULL, +col34 INTEGER DEFAULT NULL, +col35 INTEGER DEFAULT NULL, +col36 INTEGER DEFAULT NULL, +col37 INTEGER DEFAULT NULL, +col38 INTEGER DEFAULT NULL, +col39 INTEGER DEFAULT NULL, +col40 INTEGER DEFAULT NULL, +col41 INTEGER DEFAULT NULL, +col42 INTEGER DEFAULT NULL, +col43 INTEGER DEFAULT NULL, +col44 INTEGER DEFAULT NULL, +col45 INTEGER DEFAULT NULL, +col46 INTEGER DEFAULT NULL, +col47 INTEGER DEFAULT NULL, +col48 INTEGER DEFAULT NULL, +col49 INTEGER DEFAULT NULL, +col50 INTEGER DEFAULT NULL, +col51 INTEGER DEFAULT NULL, +col52 INTEGER DEFAULT NULL, +col53 INTEGER DEFAULT NULL, +col54 INTEGER DEFAULT NULL, +col55 INTEGER DEFAULT NULL, +col56 INTEGER DEFAULT NULL, +col57 INTEGER DEFAULT NULL, +col58 INTEGER DEFAULT NULL, +col59 INTEGER DEFAULT NULL, +col60 INTEGER DEFAULT NULL, +col61 INTEGER DEFAULT NULL, +col62 INTEGER DEFAULT NULL, +col63 INTEGER DEFAULT NULL, +col64 INTEGER DEFAULT NULL, +col65 INTEGER DEFAULT NULL, +gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL, +KEY idx1 (gcol2) +); +INSERT INTO t1 (col1, col2, col3, col4) +VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5); +ALTER TABLE t1 ADD COLUMN extra INTEGER; +SELECT gcol2 FROM t1 FORCE INDEX(idx1); +gcol2 +1 +1 +1 +1 +1 +DROP TABLE t1; +# +# Bug#21628161 CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN +# +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +CREATE TABLE t (a INT, +b BOOLEAN GENERATED ALWAYS AS (a+10000) VIRTUAL, +c BLOB GENERATED ALWAYS AS (b=2) VIRTUAL); +INSERT INTO t(a) VALUES (1); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +SELECT * FROM t WHERE c = '0'; +a b c +1 127 0 +ALTER TABLE t ADD UNIQUE INDEX (c(1)); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +SELECT * FROM t WHERE c = '0'; +a b c +1 127 0 +DROP TABLE t; +# +# Bug#21688115 VIRTUAL COLUMN COMPUTATION SAVE_IN_FIELD() +# DID NOT RETURN TRUE WITH DIVIDE 0 +# +CREATE TABLE t (a INT, b INT, h VARCHAR(10)); +INSERT INTO t VALUES (12, 3, "ss"); +INSERT INTO t VALUES (13, 4, "ss"); +INSERT INTO t VALUES (14, 0, "ss"); +ALTER TABLE t ADD c INT GENERATED ALWAYS AS (a/b) VIRTUAL; +CREATE INDEX idx ON t(c); +ERROR 22012: Division by 0 +CALL mtr.add_suppression("\\[Warning\\] \\[[^]]*\\] InnoDB: Compute virtual column values failed"); +DROP TABLE t; +# +# Bug#21770798 OPTIMIZER DOES NOT USE INDEX FOR GENERATED EXPRESSIONS +# WITH LOGICAL OPERATORS +# +CREATE TABLE t (a INT, b INT, +gc_and INT GENERATED ALWAYS AS (a AND b) STORED, +gc_or INT GENERATED ALWAYS AS (a OR b) STORED, +gc_xor INT GENERATED ALWAYS AS (a XOR b) STORED, +gc_not INT GENERATED ALWAYS AS (NOT a) STORED, +gc_case INT GENERATED ALWAYS AS +(CASE WHEN (a AND b) THEN a ELSE b END) STORED, +INDEX(gc_and), INDEX(gc_or), INDEX(gc_xor), INDEX(gc_not), +INDEX(gc_case)); +INSERT INTO t (a, b) VALUES (0, 0), (0, 1), (1, 0), (1, 1); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT a, b FROM t WHERE (a AND b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_and gc_and 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_and` = 1) +SELECT a, b FROM t WHERE (a AND b) = 1; +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE 1 = (a AND b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_and gc_and 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (1 = `test`.`t`.`gc_and`) +SELECT a, b FROM t WHERE 1 = (a AND b); +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range gc_and gc_and 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_and` in (1,2,3)) +SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3); +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a OR b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_or gc_or 5 const 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_or` = 1) +SELECT a, b FROM t WHERE (a OR b) = 1; +a b +0 1 +1 0 +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range gc_or gc_or 5 NULL 3 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_or` between 1 and 10) +SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10; +a b +0 1 +1 0 +1 1 +EXPLAIN SELECT a, b FROM t WHERE (a XOR b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_xor gc_xor 5 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`gc_xor` = 1) +SELECT a, b FROM t WHERE (a XOR b) = 1; +a b +0 1 +1 0 +EXPLAIN SELECT a FROM t WHERE (NOT a) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_not gc_not 5 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (`test`.`t`.`gc_not` = 1) +SELECT a FROM t WHERE (NOT a) = 1; +a +0 +0 +EXPLAIN SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc_case gc_case 5 const 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a` from `test`.`t` where (`test`.`t`.`gc_case` = 1) +SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1; +a +0 +1 +EXPLAIN SELECT a, b FROM t WHERE 1 = (b AND a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (1 = ((0 <> `test`.`t`.`b`) and (0 <> `test`.`t`.`a`))) +SELECT a, b FROM t WHERE 1 = (b AND a); +a b +1 1 +EXPLAIN SELECT a, b FROM t WHERE 1 = (b OR a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ALL NULL NULL NULL NULL 4 100.00 Using where +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b` from `test`.`t` where (1 = ((0 <> `test`.`t`.`b`) or (0 <> `test`.`t`.`a`))) +Warnings: +SELECT a, b FROM t WHERE 1 = (b OR a); +a b +0 1 +1 0 +1 1 +DROP TABLE t; +# +# Bug#21854241: QUERY USING JSON_EXTRACT() RETURNS WRONG RESULT +# AFTER ADDING VIRTUAL INDEX +# +CREATE TABLE employees ( +data JSON, +name1 VARCHAR(30) AS (JSON_EXTRACT(data, "$.name")) STORED, +name2 VARCHAR(30) AS (JSON_UNQUOTE(JSON_EXTRACT(data, "$.name"))) STORED +); +INSERT INTO employees (data) VALUES('{"id": 1, "name": "Jane"}'); +INSERT INTO employees (data) VALUES('{"id": 2, "name": "Joe"}'); +ANALYZE TABLE employees; +Table Op Msg_type Msg_text +test.employees analyze status OK +EXPLAIN SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE employees NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`employees`.`data` AS `data`,`test`.`employees`.`name1` AS `name1`,`test`.`employees`.`name2` AS `name2` from `test`.`employees` where (json_extract(`test`.`employees`.`data`,'$.name') = 'Jane') +SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +data name1 name2 +{"id": 1, "name": "Jane"} "Jane" Jane +ALTER TABLE employees ADD INDEX name_idx1(name1); +ANALYZE TABLE employees; +Table Op Msg_type Msg_text +test.employees analyze status OK +EXPLAIN SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE employees NULL ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`employees`.`data` AS `data`,`test`.`employees`.`name1` AS `name1`,`test`.`employees`.`name2` AS `name2` from `test`.`employees` where (json_extract(`test`.`employees`.`data`,'$.name') = 'Jane') +SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +data name1 name2 +{"id": 1, "name": "Jane"} "Jane" Jane +ALTER TABLE employees ADD INDEX name_idx2(name2); +ANALYZE TABLE employees; +Table Op Msg_type Msg_text +test.employees analyze status OK +EXPLAIN SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE employees NULL ref name_idx2 name_idx2 123 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`employees`.`data` AS `data`,`test`.`employees`.`name1` AS `name1`,`test`.`employees`.`name2` AS `name2` from `test`.`employees` where (`test`.`employees`.`name2` = 'Jane') +SELECT * FROM employees WHERE JSON_EXTRACT(data, '$.name') = 'Jane'; +data name1 name2 +{"id": 1, "name": "Jane"} "Jane" Jane +DROP TABLE employees; +# +# Bug#22077611 UPDATE .. WHERE JSON_EXTRACT(..) = '..' NOT USING +# VIRTUAL COL INDEX +# +CREATE TABLE t(a INT, b INT, gc INT GENERATED ALWAYS AS (a+1) STORED, KEY(gc)); +INSERT INTO t(a) VALUES (1), (2), (3), (4), (5), (1), (2), (3), (4), (5); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN UPDATE t SET b = 10 WHERE (a+1) = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t NULL range gc gc 5 const 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t` set `test`.`t`.`b` = 10 where (`test`.`t`.`gc` = 3) +UPDATE t SET b = 10 WHERE (a+1) = 3; +SELECT * FROM t ORDER BY a, b; +a b gc +1 NULL 2 +1 NULL 2 +2 10 3 +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN UPDATE t SET b = 9 ORDER BY (a+1) LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 UPDATE t NULL index NULL gc 5 NULL 1 100.00 Using temporary +Warnings: +Note 1003 update `test`.`t` set `test`.`t`.`b` = 9 order by `test`.`t`.`gc` limit 1 +UPDATE t SET b = 9 ORDER BY (a+1) LIMIT 1; +SELECT * FROM t ORDER BY a, b; +a b gc +1 NULL 2 +1 9 2 +2 10 3 +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN DELETE FROM t WHERE (a+1) = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t NULL range gc gc 5 const 2 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t` where (`test`.`t`.`gc` = 2) +DELETE FROM t WHERE (a+1) = 2; +SELECT * FROM t ORDER BY a, b; +a b gc +2 10 3 +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN DELETE FROM t ORDER BY (a+1) LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 DELETE t NULL index NULL gc 5 NULL 1 100.00 NULL +Warnings: +Note 1003 delete from `test`.`t` order by `test`.`t`.`gc` limit 1 +DELETE FROM t ORDER BY (a+1) LIMIT 1; +SELECT * FROM t ORDER BY a, b; +a b gc +2 10 3 +3 NULL 4 +3 NULL 4 +4 NULL 5 +4 NULL 5 +5 NULL 6 +5 NULL 6 +DROP TABLE t; +# +# Bug#22095783: ALTER TABLE ADD COLUMN FAILS WITH OUT +# OF RANGE VALUE ERROR +CREATE TABLE c1(doc JSON,_id VARCHAR(32) GENERATED ALWAYS +AS (JSON_UNQUOTE(JSON_EXTRACT(doc, '$._id'))) STORED NOT NULL UNIQUE); +INSERT INTO c1(doc) VALUES('{"X":10,"_id":9}'); +ALTER TABLE c1 ADD COLUMN vc1 DOUBLE(4, 3) GENERATED +ALWAYS AS (JSON_EXTRACT(doc, '$.X')) VIRTUAL , ADD INDEX IX1 (vc1); +ERROR 22003: Out of range value for column 'vc1' at row 1 +ALTER TABLE c1 ADD vc2 INT(11); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE c1 ADD COLUMN vc3 INT(11) GENERATED ALWAYS AS +(JSON_EXTRACT(doc, '$.X')) VIRTUAL , ADD UNIQUE INDEX IX2 (vc3); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE c1 drop vc2; +ALTER TABLE c1 ADD vc4 INT(11); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +DROP TABLE c1; +# +# Bug#22810883: ASSERTION FAILED: +# !(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE)) +# +CREATE TABLE t1 (a1 INTEGER GENERATED ALWAYS AS (1 AND 0) STORED, +a2 INTEGER, KEY (a1)); +INSERT INTO t1 VALUES (); +CREATE TABLE t2 (b INTEGER); +INSERT INTO t2 VALUES (1); +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +# Used to choose the index on a1 and get wrong results. +EXPLAIN SELECT * FROM t1 WHERE (a2 AND a2) = 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (((0 <> `test`.`t1`.`a2`) and (0 <> `test`.`t1`.`a2`)) = 0) +SELECT * FROM t1 WHERE (a2 AND a2) = 0; +a1 a2 +# Used to get assertion or wrong results. +EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where ((((0 <> `test`.`t2`.`b`) and (0 <> `test`.`t2`.`b`)) = 1) and (0 <> `test`.`t2`.`b`)) +SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1; +a1 a2 b +0 NULL 1 +DROP TABLE t1, t2; +# +# Bug#24345509: WRONG RESULTS WHEN GCOL INDEX IS USED +# +CREATE TABLE t1 ( +pk INT PRIMARY KEY AUTO_INCREMENT, +i INT, +vc VARCHAR(7), +gc1 VARCHAR(14) GENERATED ALWAYS AS (concat(vc, vc)) VIRTUAL NOT NULL, +gc2 VARCHAR(14) GENERATED ALWAYS AS (concat(gc1, 'x')) VIRTUAL NOT NULL, +KEY gc2_key (gc2), +KEY gc2_key_prefix (gc2(5)) +); +INSERT INTO t1 (i, vc) VALUES +(7, 'xcek'), (3, 'ceksat'), (3, 'eksate'), (3, 'ksatef'), (6, 's'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT i FROM t1 WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key,gc2_key_prefix gc2_key 58 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT i FROM t1 WHERE gc2 <= 'ksatefksatefx'; +i +3 +3 +3 +EXPLAIN SELECT i FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key_prefix gc2_key_prefix 22 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` FORCE INDEX (`gc2_key_prefix`) where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT i FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +i +3 +3 +3 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key,gc2_key_prefix gc2_key 58 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT COUNT(*) FROM t1 WHERE gc2 <= 'ksatefksatefx'; +COUNT(*) +3 +EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range gc2_key_prefix gc2_key_prefix 22 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`gc2_key_prefix`) where (`test`.`t1`.`gc2` <= 'ksatefksatefx') +SELECT COUNT(*) FROM t1 FORCE INDEX (gc2_key_prefix) +WHERE gc2 <= 'ksatefksatefx'; +COUNT(*) +3 +CREATE TABLE t2 ( +i INT NOT NULL, +gc INT GENERATED ALWAYS AS (i) VIRTUAL NOT NULL, +KEY (gc) +); +INSERT INTO t2 (i) VALUES (-1), (0), (1), (2); +BEGIN; +SELECT i FROM t2 FORCE INDEX (gc) WHERE gc <= -1; +i +-1 +SELECT gc FROM t2 FORCE INDEX (gc) WHERE gc <= -1; +gc +-1 +COMMIT; +DROP TABLE t1, t2; +# +# Bug#27010089: ASSERTION FAILURE: +# ROW0SEL.CC:2846:TEMPL->MYSQL_COL_LEN == LEN +# +CREATE TABLE t ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +col_int_key INTEGER GENERATED ALWAYS AS (1) VIRTUAL, +col_varchar VARCHAR(7) , +col_varchar_key VARCHAR(14) GENERATED ALWAYS AS ('abc') VIRTUAL, +KEY (col_varchar_key(5), col_int_key), +KEY (col_int_key, col_varchar_key)); +INSERT INTO t VALUES (), (); +SELECT 1 FROM t AS alias1 +WHERE EXISTS +(SELECT SQ2_alias1.col_int_key AS SQ2_field1 +FROM t AS SQ2_alias1 JOIN t AS SQ2_alias2 +ON (SQ2_alias2.col_varchar_key = SQ2_alias1.col_varchar_key) +WHERE SQ2_alias1.col_varchar <> alias1.col_varchar AND +SQ2_alias1.col_int_key >= SQ2_alias2.pk); +1 +DROP TABLE t; +# +# Bug#27403367: GENERATED COLUMN EXPRESSIONS IGNORED WITH PREFIX INDEX +# +CREATE TABLE t (vc VARCHAR(100), +gc VARCHAR(100) GENERATED ALWAYS AS (REVERSE(vc)) STORED, +KEY (gc(3))); +INSERT INTO t(vc) VALUES ('a'), ('abc'), ('abcabc'), ('abcdef'); +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +EXPLAIN SELECT * FROM t WHERE REVERSE(vc) = 'cba'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc gc 15 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`vc` AS `vc`,`test`.`t`.`gc` AS `gc` from `test`.`t` where (`test`.`t`.`gc` = 'cba') +SELECT * FROM t WHERE REVERSE(vc) = 'cba'; +vc gc +abc cba +EXPLAIN SELECT * FROM t WHERE REVERSE(vc) = 'cbacba'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref gc gc 15 const 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`vc` AS `vc`,`test`.`t`.`gc` AS `gc` from `test`.`t` where (`test`.`t`.`gc` = 'cbacba') +SELECT * FROM t WHERE REVERSE(vc) = 'cbacba'; +vc gc +abcabc cbacba +EXPLAIN SELECT * FROM t WHERE REVERSE(vc) BETWEEN 'c' AND 'e'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range gc gc 15 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`vc` AS `vc`,`test`.`t`.`gc` AS `gc` from `test`.`t` where (`test`.`t`.`gc` between 'c' and 'e') +SELECT * FROM t WHERE REVERSE(vc) BETWEEN 'c' AND 'e'; +vc gc +abc cba +abcabc cbacba +DROP TABLE t; +# +# +# BUG#21365158 WL8149:ASSERTION `!TABLE || (!TABLE->WRITE_SET +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +col_varchar_key VARCHAR(2) GENERATED ALWAYS AS +(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null, +PRIMARY KEY (pk) +); +INSERT INTO t1 ( col_int_nokey, col_varchar_nokey) +VALUES (4, 'b'),(9, 'o'),(4, 'k'),(5, 'a'),(5, 'f'), +(9, 't'),(3, 'c'),(8, 'c'),(0, 'r'),(98, 'k'); +CREATE TABLE t2 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER NOT NULL, +col_varchar_nokey VARCHAR(1) NOT NULL, +col_varchar_key VARCHAR(2) GENERATED ALWAYS AS +(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null, +PRIMARY KEY (pk), +UNIQUE KEY (col_varchar_key) +); +INSERT INTO t2 ( col_int_nokey, col_varchar_nokey) +VALUES (1, 'c'),(8, 'm'),(9, 'd'), (6, 'y'),(1, 't'), +(2, 's'),(4, 'r'); +SELECT +CONCAT( t2.col_varchar_nokey , t2.col_varchar_nokey ) AS f2, +t1.col_varchar_key AS f5 +FROM +t2 LEFT JOIN t1 ON t2.col_int_nokey > t1.col_int_nokey +ORDER BY f2, f5; +f2 f5 +cc rr +dd aa +dd bb +dd cc +dd cc +dd ff +dd kk +dd rr +mm aa +mm bb +mm cc +mm ff +mm kk +mm rr +rr cc +rr rr +ss rr +tt rr +yy aa +yy bb +yy cc +yy ff +yy kk +yy rr +DROP TABLE t1,t2; +# +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2,t3; +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +DROP TRIGGER IF EXISTS trg1; +DROP TRIGGER IF EXISTS trg2; +set sql_warnings = 0; diff --git a/mysql-test/suite/innodb/include/innodb_redo_debug.inc b/mysql-test/suite/innodb/include/innodb_redo_debug.inc index 479e342fa..d22618786 100644 --- a/mysql-test/suite/innodb/include/innodb_redo_debug.inc +++ b/mysql-test/suite/innodb/include/innodb_redo_debug.inc @@ -160,6 +160,7 @@ SELECT SLEEP(0.1); # works --source include/start_mysqld.inc --echo # Check rows which are not modified by parallel load +--sleep 1 SELECT col1 FROM dbredoopt.t1 WHERE col1%50=0 AND (col1 < 501 AND col1 > 0 ); --echo # Check rows which are updated by parallel load diff --git a/mysql-test/suite/innodb/r/innodb-2byte-collation.result-pq b/mysql-test/suite/innodb/r/innodb-2byte-collation.result-pq new file mode 100644 index 000000000..bb24909ab --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-2byte-collation.result-pq @@ -0,0 +1,152 @@ +show variables like 'character_sets_dir%'; +Variable_name Value +character_sets_dir MYSQL_TEST_DIR/std_data/ +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select collation_name, character_set_name, id from information_schema.collations where id>256 order by id; +collation_name character_set_name id +utf8mb4_is_0900_ai_ci utf8mb4 257 +utf8mb4_lv_0900_ai_ci utf8mb4 258 +utf8mb4_ro_0900_ai_ci utf8mb4 259 +utf8mb4_sl_0900_ai_ci utf8mb4 260 +utf8mb4_pl_0900_ai_ci utf8mb4 261 +utf8mb4_et_0900_ai_ci utf8mb4 262 +utf8mb4_es_0900_ai_ci utf8mb4 263 +utf8mb4_sv_0900_ai_ci utf8mb4 264 +utf8mb4_tr_0900_ai_ci utf8mb4 265 +utf8mb4_cs_0900_ai_ci utf8mb4 266 +utf8mb4_da_0900_ai_ci utf8mb4 267 +utf8mb4_lt_0900_ai_ci utf8mb4 268 +utf8mb4_sk_0900_ai_ci utf8mb4 269 +utf8mb4_es_trad_0900_ai_ci utf8mb4 270 +utf8mb4_la_0900_ai_ci utf8mb4 271 +utf8mb4_eo_0900_ai_ci utf8mb4 273 +utf8mb4_hu_0900_ai_ci utf8mb4 274 +utf8mb4_hr_0900_ai_ci utf8mb4 275 +utf8mb4_vi_0900_ai_ci utf8mb4 277 +utf8mb4_0900_as_cs utf8mb4 278 +utf8mb4_de_pb_0900_as_cs utf8mb4 279 +utf8mb4_is_0900_as_cs utf8mb4 280 +utf8mb4_lv_0900_as_cs utf8mb4 281 +utf8mb4_ro_0900_as_cs utf8mb4 282 +utf8mb4_sl_0900_as_cs utf8mb4 283 +utf8mb4_pl_0900_as_cs utf8mb4 284 +utf8mb4_et_0900_as_cs utf8mb4 285 +utf8mb4_es_0900_as_cs utf8mb4 286 +utf8mb4_sv_0900_as_cs utf8mb4 287 +utf8mb4_tr_0900_as_cs utf8mb4 288 +utf8mb4_cs_0900_as_cs utf8mb4 289 +utf8mb4_da_0900_as_cs utf8mb4 290 +utf8mb4_lt_0900_as_cs utf8mb4 291 +utf8mb4_sk_0900_as_cs utf8mb4 292 +utf8mb4_es_trad_0900_as_cs utf8mb4 293 +utf8mb4_la_0900_as_cs utf8mb4 294 +utf8mb4_eo_0900_as_cs utf8mb4 296 +utf8mb4_hu_0900_as_cs utf8mb4 297 +utf8mb4_hr_0900_as_cs utf8mb4 298 +utf8mb4_vi_0900_as_cs utf8mb4 300 +utf8mb4_ja_0900_as_cs utf8mb4 303 +utf8mb4_ja_0900_as_cs_ks utf8mb4 304 +utf8mb4_0900_as_ci utf8mb4 305 +utf8mb4_ru_0900_ai_ci utf8mb4 306 +utf8mb4_ru_0900_as_cs utf8mb4 307 +utf8mb4_zh_0900_as_cs utf8mb4 308 +utf8mb4_0900_bin utf8mb4 309 +utf8mb4_test_ci utf8mb4 326 +utf16_test_ci utf16 327 +utf8mb4_test_400_ci utf8mb4 328 +utf8_bengali_standard_ci utf8 336 +utf8_bengali_traditional_ci utf8 337 +utf8_phone_ci utf8 352 +utf8_test_ci utf8 353 +utf8_5624_1 utf8 354 +utf8_5624_2 utf8 355 +utf8_5624_3 utf8 356 +utf8_5624_4 utf8 357 +ucs2_test_ci ucs2 358 +ucs2_vn_ci ucs2 359 +ucs2_5624_1 ucs2 360 +utf8_5624_5 utf8 368 +utf32_test_ci utf32 391 +latin1_test latin1 1025 +utf8_maxuserid_ci utf8 2047 +show collation like '%test%'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +latin1_test latin1 1025 0 PAD SPACE +ucs2_test_ci ucs2 358 8 PAD SPACE +utf16_test_ci utf16 327 8 PAD SPACE +utf32_test_ci utf32 391 8 PAD SPACE +utf8mb4_test_400_ci utf8mb4 328 8 PAD SPACE +utf8mb4_test_ci utf8mb4 326 8 PAD SPACE +utf8_test_ci utf8 353 8 PAD SPACE +show collation like 'ucs2_vn_ci'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +ucs2_vn_ci ucs2 359 8 PAD SPACE +create table 2byte_collation (c1 char(1) character set ucs2 collate ucs2_vn_ci) +engine = InnoDB; +insert into 2byte_collation values (0x0061); +set @@character_set_results=NULL; +select hex(c1) from 2byte_collation; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def hex(c1) hex(c1) 253 12 4 Y 0 0 33 +hex(c1) +0061 +drop table 2byte_collation; +CREATE TABLE 2byte_collation (s1 char(10) character set utf8 collate utf8_maxuserid_ci) engine = innodb; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_maxuserid_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO 2byte_collation VALUES ('a'),('b'); +SELECT * FROM 2byte_collation WHERE s1='a' ORDER BY BINARY s1; +s1 +a +b +DROP TABLE 2byte_collation; +SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; +SET GLOBAL innodb_change_buffering_debug = 1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +show collation like 'utf8_maxuserid_ci'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8_maxuserid_ci utf8 2047 8 PAD SPACE +CREATE TABLE 2byte_collation( +a INT AUTO_INCREMENT PRIMARY KEY, +b CHAR(100) character set utf8 collate utf8_maxuserid_ci, +c INT, +z INT, +INDEX(b)) +ENGINE=InnoDB STATS_PERSISTENT=0; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3778 'utf8_maxuserid_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO 2byte_collation VALUES(0,'x',1, 1); +CREATE UNIQUE INDEX idx3 ON 2byte_collation(c, b); +INSERT INTO 2byte_collation SELECT 0,b,c+1,z+1 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+10,z+10 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+20,z+20 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+50,z+50 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+100,z+100 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+200,z+200 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+400,z+400 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+800,z+800 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+1600,z+1600 FROM 2byte_collation; +INSERT INTO 2byte_collation SELECT 0,b,c+4000,z+4000 FROM 2byte_collation; +CREATE INDEX idx5 ON 2byte_collation(b, c); +SELECT b FROM 2byte_collation LIMIT 10; +b +x +x +x +x +x +x +x +x +x +x +INSERT INTO 2byte_collation VALUES (10001, "a", 20001, 20001); +UPDATE 2byte_collation set b = "aaa" where c = 20001; +DROP TABLE 2byte_collation; +SET GLOBAL innodb_change_buffering_debug = 0; diff --git a/mysql-test/suite/innodb/r/innodb-index-debug.result-pq b/mysql-test/suite/innodb/r/innodb-index-debug.result-pq new file mode 100644 index 000000000..7f80e66f4 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-debug.result-pq @@ -0,0 +1,343 @@ +CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1)) Engine=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5); +SET SESSION DEBUG='+d,ib_build_indexes_too_many_concurrent_trxs, ib_rename_indexes_too_many_concurrent_trxs, ib_drop_index_too_many_concurrent_trxs'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Too many active concurrent transactions +SET SESSION DEBUG=DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX(c2)) +ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, 0), (4, 0), (0, 0); +SET DEBUG='+d,ib_row_merge_buf_add_two'; +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG='-d,ib_row_merge_buf_add_two'; +DROP TABLE bug13861218; +CREATE TABLE bug13861218 (c1 INT NOT NULL, c2 INT UNIQUE) ENGINE=InnoDB; +INSERT INTO bug13861218 VALUES (8, NULL), (4, NULL), (0, NULL); +SET DEBUG='+d,ib_row_merge_buf_add_two'; +CREATE UNIQUE INDEX ui ON bug13861218(c1); +SET DEBUG='-d,ib_row_merge_buf_add_two'; +DROP TABLE bug13861218; +# +# Bug #17657223 EXCESSIVE TEMPORARY FILE USAGE IN ALTER TABLE +# +create table t480(a serial)engine=innodb; +insert into t480 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), +(),(),(),(),(),(),(),(); +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +primary key(f1,f2,f3), key(f1))engine=innodb charset latin1; +insert into t1 select NULL,'aaa','bbb' from t480; +insert into t1 select NULL,'aaaa','bbbb' from t480; +insert into t1 select NULL,'aaaaa','bbbbb' from t480; +insert into t1 select NULL,'aaaaaa','bbbbbb' from t480; +SET DEBUG = '+d,row_merge_write_failure'; +alter table t1 drop primary key,add primary key(f2,f1); +ERROR HY000: Temporary file write failure. +SET DEBUG = '-d,row_merge_write_failure'; +drop table t1; +create table t1(k1 int auto_increment primary key, +k2 char(200),k3 char(200))engine=innodb; +insert into t1 values(NULL,'a','b'), (NULL,'aa','bb'); +SET DEBUG_SYNC= 'row_merge_after_scan +SIGNAL opened WAIT_FOR flushed'; +optimize table t1; +connection default +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +INSERT INTO t1 select NULL,'aaa','bbb' from t480; +SET DEBUG_SYNC= 'now SIGNAL flushed'; +/*con1 reap*/ Optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +affected rows: 2 +SELECT COUNT(k1),k2,k3 FROM t1 GROUP BY k2,k3 ORDER BY k2,k3; +COUNT(k1) k2 k3 +1 a b +1 aa bb +480 aaa bbb +drop table t1; +create table t1(k1 int auto_increment primary key, +k2 char(200),k3 char(200))engine=innodb; +SET DEBUG_SYNC= 'row_merge_after_scan +SIGNAL opened WAIT_FOR flushed'; +ALTER TABLE t1 ADD COLUMN k4 int, ALGORITHM=INPLACE; +connection default +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +SET debug = '+d,row_log_tmpfile_fail'; +INSERT INTO t1 select NULL,'aaa','bbb' from t480; +INSERT INTO t1 select NULL,'aaaa','bbbb' from t480; +SET DEBUG_SYNC= 'now SIGNAL flushed'; +SET debug = '-d,row_log_tmpfile_fail'; +/*con1 reap*/ ALTER TABLE t1 ADD COLUMN k4 int, ALGORITHM=INPLACE; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SELECT COUNT(k1),k2,k3 FROM t1 GROUP BY k2,k3; +COUNT(k1) k2 k3 +480 aaa bbb +480 aaaa bbbb +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `k1` int NOT NULL AUTO_INCREMENT, + `k2` char(200) DEFAULT NULL, + `k3` char(200) DEFAULT NULL, + PRIMARY KEY (`k1`) +) ENGINE=InnoDB AUTO_INCREMENT=1023 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SET DEBUG_SYNC='RESET'; +# SDI output shouldn't show new column "k4" because +# ALTER failed +# Remove json files +# restart +drop table t1; +drop table t480; +SET DEBUG_SYNC='RESET'; +# +# BUG#21612714 ALTER TABLE SORTING SKIPPED WHEN CHANGE PK AND DROP +# LAST COLUMN OF OLD PK +# +SET debug="+d,innodb_alter_table_pk_assert_no_sort"; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 add n1 int not null, drop primary key, add primary key(o1, n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1, o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(3))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1)) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(3))) engine = innodb; +insert into t1 values(1,'abd'), (2,'acd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values(1,'abd'), (2,'acd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values(1, 'abd'), (2, 'acd'); +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values(1, 'abd'), (2, 'acd'); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(3),o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (2, 'acd', 2); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (2, 'acd', 2); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(2))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(2))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2,o3(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(2))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(3))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2,o3(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(3))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1,o2,o3(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,o1,n2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,n2,o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(o1,n1,n2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, o4 int not null, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2,2),(2,2,1,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,o3,o4), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1), lock=none; +drop table t1; +CREATE TABLE t1(o1 int, o2 int, o3 int, PRIMARY KEY(o1), KEY(o2)) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,1,2),(2,2,1); +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +ALTER TABLE t1 DROP INDEX o2, ADD INDEX (o2 DESC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +o1 o2 o3 +1 1 2 +2 2 1 +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +ALTER TABLE t1 DROP INDEX o2, ADD INDEX (o2 ASC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +o1 o2 o3 +1 1 2 +2 2 1 +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +DROP TABLE t1; +SET debug="-d,innodb_alter_table_pk_assert_no_sort"; diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result-pq b/mysql-test/suite/innodb/r/innodb-index-online.result-pq new file mode 100644 index 000000000..e119aad04 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index-online.result-pq @@ -0,0 +1,330 @@ +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 TEXT) +ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); +SET GLOBAL innodb_monitor_enable = module_ddl; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +INSERT INTO t1 VALUES(1,2,3); +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +CREATE UNIQUE INDEX c2 ON t1(c2); +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +CREATE UNIQUE INDEX c2 ON t1(c2); +DROP INDEX c2 ON t1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int DEFAULT NULL, + `c3` text, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci STATS_PERSISTENT=0 +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR rollback_done'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +COMMIT; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +ERROR 23000: Duplicate entry '4' for key 't1.c2' +DELETE FROM t1 WHERE c1 = 7; +ALTER TABLE t1 ADD FOREIGN KEY(c2) REFERENCES t1(c2), ALGORITHM = INPLACE; +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 't1_ibfk_1' in the referenced table 't1' +ALTER TABLE t1 ADD UNIQUE INDEX(c2), LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +DROP INDEX c2 ON t1; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET GLOBAL innodb_monitor_reset = module_ddl; +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +SET DEBUG_SYNC = 'now SIGNAL rollback_done'; +ERROR 23000: Duplicate entry '4' for key 't1.c2' +SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done'; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SET DEBUG_SYNC = 'now WAIT_FOR created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +ddl_pending_alter_table 1 +SET GLOBAL innodb_monitor_reset = module_ddl; +INSERT INTO t1 VALUES(6,3,1); +SET DEBUG_SYNC = 'now SIGNAL dml_done'; +ERROR 23000: Duplicate entry for key 'c2' +DELETE FROM t1 WHERE c1=6; +ALTER TABLE t1 ADD UNIQUE INDEX(c2); +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +INSERT INTO t1 VALUES(6,3,1); +ERROR 23000: Duplicate entry '3' for key 't1.c2' +INSERT INTO t1 VALUES(7,4,2); +ERROR 23000: Duplicate entry '4' for key 't1.c2' +ALTER TABLE t1 STATS_PERSISTENT=1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +UPDATE mysql.innodb_index_stats SET stat_value = 5 +WHERE database_name = 'test' AND table_name= 't1' AND index_name = 'PRIMARY' +AND stat_value = 6; +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1 +test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index +test t1 c2 LAST_UPDATE n_diff_pfx01 5 1 c2 +test t1 c2 LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 c2 LAST_UPDATE size 1 NULL Number of pages in the index +CREATE TABLE t1_c2_stats SELECT * FROM mysql.innodb_index_stats +WHERE database_name = 'test' AND table_name = 't1' and index_name = 'c2'; +DROP INDEX c2 ON t1; +ANALYZE TABLE t1_c2_stats; +Table Op Msg_type Msg_text +test.t1_c2_stats analyze status OK +SELECT * FROM mysql.innodb_index_stats WHERE table_name IN ('t1', 't1_c2_stats'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1 +test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index +test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_diff_pfx01 3 1 DB_ROW_ID +test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index +test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE size 1 NULL Number of pages in the index +KILL QUERY @id; +ERROR 70100: Query execution was interrupted +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2d_created WAIT_FOR kill_done'; +CREATE INDEX c2d ON t1(c2); +SET DEBUG_SYNC = 'now WAIT_FOR c2d_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET GLOBAL innodb_monitor_reset = module_ddl; +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; +ERROR 70100: Query execution was interrupted +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 80 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 80 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`c2` > 3) +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +UPDATE t1_c2_stats SET index_name = 'c2d'; +UPDATE t1_c2_stats SET stat_value = 2 WHERE stat_name = 'n_diff_pfx01'; +INSERT INTO t1_c2_stats +SELECT database_name, table_name, index_name, last_update, 'n_diff_pfx02', 80, +sample_size, 'c2,c1' FROM t1_c2_stats +WHERE stat_name = 'n_diff_pfx01' AND stat_description = 'c2'; +INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats; +DROP TABLE t1_c2_stats; +CREATE INDEX c2d ON t1(c2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 c1 A 80 NULL NULL BTREE YES NULL +t1 1 c2d 1 c2 A 5 NULL NULL YES BTREE YES NULL +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c2d c2d 5 NULL 32 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`c2` > 3) +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int DEFAULT NULL, + `c3` text, + PRIMARY KEY (`c1`), + KEY `c2d` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci STATS_PERSISTENT=1 +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2e_created WAIT_FOR dml2_done'; +SET lock_wait_timeout = 10; +ALTER TABLE t1 CHANGE c2 c22 INT, DROP INDEX c2d, ADD INDEX c2e(c22), +ALGORITHM = INPLACE; +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET GLOBAL innodb_monitor_reset = module_ddl; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET GLOBAL innodb_monitor_reset = module_ddl; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c2e'; +NAME POS +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; +ERROR HY000: Creating index 'c2e' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again. +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c2e'; +NAME POS +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +ALTER TABLE t1 COMMENT 'testing if c2e will be dropped'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; +ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; +SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET GLOBAL innodb_monitor_reset = module_ddl; +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 160; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET GLOBAL innodb_monitor_reset = module_ddl; +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; +Warnings: +Warning 1831 Duplicate index 'c2f' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +SELECT COUNT(c22f) FROM t1; +COUNT(c22f) +320 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +ERROR 23000: Duplicate entry 'NULL' for key 't1.c3p5' +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c3p5_created WAIT_FOR ins_done'; +ALTER TABLE t1 ADD UNIQUE INDEX c3p5(c3(5)); +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = '?c3p5'; +NAME POS +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +INSERT INTO t1 VALUES(347,33101,NULL); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +SELECT sf.name, sf.pos FROM INFORMATION_SCHEMA.INNODB_INDEXES si +INNER JOIN INFORMATION_SCHEMA.INNODB_FIELDS sf +ON si.index_id = sf.index_id WHERE si.name = 'c3p5'; +NAME POS +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c22f` int DEFAULT NULL, + `c3` text, + PRIMARY KEY (`c1`), + KEY `c2d` (`c22f`), + KEY `c2f` (`c22f`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci STATS_PERSISTENT=1 COMMENT='testing if c2e will be dropped' +ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count > 0; +name count +SET GLOBAL innodb_monitor_reset = module_ddl; +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = INPLACE; +ALTER TABLE t1 ADD INDEX c2h(c22f), ALGORITHM = COPY; +ERROR 42000: Duplicate key name 'c2h' +SET DEBUG_SYNC = 'RESET'; +SET DEBUG = ''; +SET GLOBAL innodb_monitor_disable = module_ddl; +DROP TABLE t1; +SET GLOBAL DEBUG = ''; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +SET GLOBAL innodb_monitor_reset = default; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb-index.result-pq b/mysql-test/suite/innodb/r/innodb-index.result-pq new file mode 100644 index 000000000..a9d78a0b4 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index.result-pq @@ -0,0 +1,2007 @@ +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS; +create table t1(a varchar(2) primary key) engine=innodb; +insert into t1 values(''); +create index t1a1 on t1(a(1)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +drop table t1; +create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb; +insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak'); +commit; +alter table t1 add index b (b), add index b (b); +ERROR 42000: Duplicate key name 'b' +alter table t1 add index (b,b); +ERROR 42S21: Duplicate column name 'b' +alter table t1 add index d2 (d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + KEY `d2` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +analyze table t1; +explain select * from t1 force index(d2) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d2 83 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d2`) order by `test`.`t1`.`d` +select * from t1 force index (d2) order by d; +a b c d +3 4 ad ad +2 3 ak ak +5 5 oo oo +4 4 tr tr +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '4' for key 't1.b' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + KEY `d2` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + KEY `d2` (`d`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add unique index (c), add index (d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1831 Duplicate index 'd' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 40 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +alter table t1 add primary key (a), drop index c; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +affected rows: 1 +alter table t1 add primary key (c); +ERROR 42000: Multiple primary key defined +alter table t1 drop primary key, add primary key (b); +ERROR 23000: Duplicate entry '4' for key 't1.PRIMARY' +create unique index c on t1 (c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 40 NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +select * from t1 force index(c) order by c; +a b c d +3 4 ad ad +2 3 ak ak +5 5 oo oo +4 4 tr tr +alter table t1 drop index b, add index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values(6,1,'ggg','ggg'); +select * from t1; +a b c d +2 3 ak ak +3 4 ad ad +4 4 tr tr +5 5 oo oo +6 1 ggg ggg +select * from t1 force index(b) order by b; +a b c d +6 1 ggg ggg +2 3 ak ak +3 4 ad ad +4 4 tr tr +5 5 oo oo +select * from t1 force index(c) order by c; +a b c d +3 4 ad ad +2 3 ak ak +6 1 ggg ggg +5 5 oo oo +4 4 tr tr +select * from t1 force index(d) order by d; +a b c d +3 4 ad ad +2 3 ak ak +6 1 ggg ggg +5 5 oo oo +4 4 tr tr +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 40 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d 83 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) NOT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `d2` (`d`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add index (c(2)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +affected rows: 1 +alter table t1 add unique index (d(10)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `d` (`d`(10)), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +affected rows: 1 +insert into t1 values(5,1,'ggg','ggg'); +analyze table t1; +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +select * from t1 force index(c) order by c; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +select * from t1 force index(d) order by d; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `d` (`d`(10)), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 drop index d; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +5 1 ggg ggg +8 9 fff fff +select * from t1 force index(c) order by c; +a b c d +1 1 ab ab +2 2 ac ac +3 3 ad ad +4 4 afe afe +8 9 fff fff +5 1 ggg ggg +analyze table t1; +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `c` (`c`(2)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add unique index (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 46 NULL 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`,`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add index (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(11,11,'kkk','kkk'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 46 NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`,`c`), + KEY `b_2` (`b`,`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 add unique index (c,d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values(13,13,'yyy','aaa'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +13 13 yyy aaa +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +13 13 yyy aaa +select * from t1 force index(c) order by c; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +11 11 kkk kkk +13 13 yyy aaa +analyze table t1; +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 46 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 124 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`,`c`), + UNIQUE KEY `c` (`c`,`d`), + KEY `b_2` (`b`,`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb; +create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb; +create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb; +create table t2(a int not null, b int, c int, d int, e int, +foreign key (b) references t1(b) on delete set null, +foreign key (c) references t3(c), foreign key (d) references t4(d) on update set null) +engine = innodb; +alter table t1 drop index b; +ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint +alter table t3 drop index c; +ERROR HY000: Cannot drop index 'c': needed in a foreign key constraint +alter table t4 drop index d; +ERROR HY000: Cannot drop index 'd': needed in a foreign key constraint +alter table t2 drop index b; +ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint +alter table t2 drop index b, drop index c, drop index d; +ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY; +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=INPLACE; +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +SET FOREIGN_KEY_CHECKS=0; +alter table t2 DROP COLUMN b, ALGORITHM=COPY; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' +alter table t2 DROP COLUMN b; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' +alter table t1 DROP COLUMN b, ALGORITHM=COPY; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' of table 't2' +alter table t1 DROP COLUMN b; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' of table 't2' +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +create unique index dc on t2 (d,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +create index dc on t1 (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +alter table t2 add primary key (alpha), change a alpha int, +change b beta int not null, change c charlie int not null; +ERROR HY000: Column 'beta' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +alter table t2 add primary key (alpha), change a alpha int, +change c charlie int not null, change d delta int not null; +ERROR HY000: Column 'delta' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_3' SET NULL +alter table t2 add primary key (alpha), change a alpha int, +change b beta int, modify c int not null; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (1,1,1); +insert into t3 values (1,1,1); +insert into t4 values (1,1,1); +insert into t2 values (1,1,1,1,1); +commit; +alter table t4 add constraint dc foreign key (a) references t1(a); +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +show create table t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `a` int NOT NULL, + `d` int NOT NULL, + `e` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `d` (`d`), + CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t3 add constraint dc foreign key (a) references t1(a); +ERROR HY000: Duplicate foreign key constraint name 'dc' +SET FOREIGN_KEY_CHECKS=0; +alter table t3 add constraint dc foreign key (a) references t1(a); +ERROR HY000: Duplicate foreign key constraint name 'dc' +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `a` int NOT NULL, + `c` int NOT NULL, + `d` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t2 drop index b, add index (beta); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `alpha` int NOT NULL, + `beta` int DEFAULT NULL, + `c` int NOT NULL, + `d` int DEFAULT NULL, + `e` int DEFAULT NULL, + PRIMARY KEY (`alpha`), + UNIQUE KEY `dc` (`d`,`c`), + KEY `c` (`c`), + KEY `beta` (`beta`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`beta`) REFERENCES `t1` (`b`) ON DELETE SET NULL, + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t3` (`c`), + CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`d`) REFERENCES `t4` (`d`) ON UPDATE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +delete from t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +drop index dc on t4; +ERROR 42000: Can't DROP 'dc'; check that column/key exists +alter table t3 drop foreign key dc; +ERROR 42000: Can't DROP 'dc'; check that column/key exists +alter table t4 drop foreign key dc; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +select * from t2; +alpha beta c d e +1 1 1 1 1 +delete from t1; +select * from t2; +alpha beta c d e +1 NULL 1 1 1 +drop table t2,t4,t3,t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '2' for key 't1.b' +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +alter table t1 add index (b); +insert into t1 values(10,10,'kkk','iii'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +alter table t1 add unique index (c), add index (d); +insert into t1 values(11,11,'aaa','mmm'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(c) order by c; +a b c d +11 11 aaa mmm +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(d) order by d; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 31 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d 63 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1(a int not null, b int) engine = innodb; +insert into t1 values (1,1),(1,1),(1,1),(1,1); +alter table t1 add unique index (a); +ERROR 23000: Duplicate entry '1' for key 't1.a' +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '1' for key 't1.b' +alter table t1 add unique index (a), add unique index(b); +ERROR 23000: Duplicate entry '1' for key 't1.a' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, c int not null,b int, primary key(a), unique key(c), key(b)) engine = innodb; +alter table t1 drop index c, drop index b; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `c` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, primary key(a)) engine = innodb; +alter table t1 add index (b); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ac','ac'),(4,4,'afe','afe'),(5,4,'affe','affe'); +alter table t1 add unique index (b), add unique index (c), add unique index (d); +ERROR 23000: Duplicate entry '4' for key 't1.b' +alter table t1 add unique index (c), add unique index (b), add index (d); +ERROR 23000: Duplicate entry 'ac' for key 't1.c' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb; +insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1); +alter table t1 add unique index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int NOT NULL, + `c` int DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`), + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +analyze table t1; +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 5 NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +select * from t1 order by a; +a b c +1 5 1 +2 4 2 +3 3 3 +4 2 4 +5 1 5 +10 20 20 +11 19 19 +12 18 18 +13 17 17 +select * from t1 force index(b) order by b; +a b c +5 1 5 +4 2 4 +3 3 3 +2 4 2 +1 5 1 +13 17 17 +12 18 18 +11 19 19 +10 20 20 +select * from t1 force index(c) order by c; +a b c +1 5 1 +2 4 2 +3 3 3 +4 2 4 +5 1 5 +13 17 17 +12 18 18 +11 19 19 +10 20 20 +drop table t1; +create table t1(a int not null, b int not null) engine=innodb; +insert into t1 values (1,1); +alter table t1 add primary key(b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (2,2); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int NOT NULL, + PRIMARY KEY (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select * from t1; +a b +1 1 +2 2 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` +checksum table t1; +Table Checksum +test.t1 582702641 +drop table t1; +create table t1(a int not null) engine=innodb; +insert into t1 values (1); +alter table t1 add primary key(a); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +insert into t1 values (2); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +commit; +select * from t1; +a +1 +2 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +drop table t1; +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET FOREIGN_KEY_CHECKS=0; +CREATE TABLE t1( +c1 BIGINT(12) NOT NULL, +PRIMARY KEY (c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2( +c1 BIGINT(16) NOT NULL, +c2 BIGINT(12) NOT NULL, +c3 BIGINT(12) NOT NULL, +PRIMARY KEY (c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3) REFERENCES t1(c1); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `i_t2_c3_c2` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; +INSERT INTO t2 VALUES(0,0,0); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)) +INSERT INTO t1 VALUES(0); +INSERT INTO t2 VALUES(0,0,0); +DROP TABLE t2; +CREATE TABLE t2( +c1 BIGINT(16) NOT NULL, +c2 BIGINT(12) NOT NULL, +c3 BIGINT(12) NOT NULL, +PRIMARY KEY (c1,c2,c3) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3) REFERENCES t1(c1); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`,`c2`,`c3`), + KEY `fk_t2_ca` (`c3`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`,`c2`,`c3`), + KEY `i_t2_c3_c2` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +INSERT INTO t2 VALUES(0,0,1); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)) +INSERT INTO t2 VALUES(0,0,0); +DELETE FROM t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`) REFERENCES `t1` (`c1`)) +DELETE FROM t2; +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1( +c1 BIGINT(12) NOT NULL, +c2 INT(4) NOT NULL, +PRIMARY KEY (c2,c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2( +c1 BIGINT(16) NOT NULL, +c2 BIGINT(12) NOT NULL, +c3 BIGINT(12) NOT NULL, +PRIMARY KEY (c1) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1), ALGORITHM=COPY; +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1); +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +ERROR HY000: Referencing column 'c2' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); +ERROR HY000: Referencing column 'c2' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=INPLACE; +ERROR HY000: Referencing column 'c3' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=COPY; +ERROR HY000: Referencing column 'c3' and referenced column 'c2' in foreign key constraint 'fk_t2_ca' are incompatible. +ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); +ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +affected rows: 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + PRIMARY KEY (`c2`,`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +CREATE INDEX i_t2_c2_c1 ON t2(c2, c1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`,`c2`), + KEY `i_t2_c2_c1` (`c2`,`c1`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `fk_t2_ca` (`c3`,`c2`), + KEY `i_t2_c2_c1` (`c2`,`c1`), + KEY `i_t2_c3_c1_c2` (`c3`,`c1`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + `c3` bigint NOT NULL, + PRIMARY KEY (`c1`), + KEY `i_t2_c2_c1` (`c2`,`c1`), + KEY `i_t2_c3_c1_c2` (`c3`,`c1`,`c2`), + KEY `i_t2_c3_c2` (`c3`,`c2`), + CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e'); +CREATE TABLE t2 (a INT, b CHAR(1)) ENGINE=InnoDB; +CREATE TABLE t2i (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +CREATE TABLE t2c (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t2i SELECT * FROM t1; +INSERT INTO t2c SELECT * FROM t1; +BEGIN; +SELECT * FROM t1; +a b +3 a +3 b +1 c +0 d +1 e +SET lock_wait_timeout=1; +CREATE INDEX t1a ON t1(a); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +CREATE INDEX t2a ON t2(a); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t2i ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t2c ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=COPY; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +SELECT * FROM t2i; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2c; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +COMMIT; +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2i; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2c; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +alter table t2 add index t2a(b); +ERROR 42000: Duplicate key name 't2a' +alter table t2 drop index t2a, add index t2a(b); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + `b` char(1) DEFAULT NULL, + KEY `t2a` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2i; +Table Create Table +t2i CREATE TABLE `t2i` ( + `a` int NOT NULL, + `b` char(1) NOT NULL, + PRIMARY KEY (`a`,`b`), + KEY `t2a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2c; +Table Create Table +t2c CREATE TABLE `t2c` ( + `a` int NOT NULL, + `b` char(1) NOT NULL, + PRIMARY KEY (`a`,`b`), + KEY `t2a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1,t2,t2c,t2i; +# +# Bug #17657223 EXCESSIVE TEMPORARY FILE USAGE IN ALTER TABLE +# +SET GLOBAL innodb_monitor_enable = module_ddl; +create table t1(f1 int not null, f2 blob)engine=innodb; +insert into t1 values(1, repeat('a',20000)); +# Skip sort +# Reusing the same pk +alter table t1 force; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +drop table t1; +create table t1(f1 int not null, f2 int not null, +primary key(f1))engine=innodb; +insert into t1 values(1,2), (3,4); +# Add Secondary index. +# Skip temp file usage due to small table size +alter table t1 add key(f2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +drop table t1; +create table t480(a serial)engine=innodb; +insert into t480 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), +(),(),(),(),(),(),(),(); +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +insert into t480 select 0 from t480; +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1))engine=innodb charset latin1; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480; +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480; +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480; +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480; +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480; +select count(*) from t1; +count(*) +2880 +# Skip sort +# Change PK from (f1) to (f1,f2,f3,f4) +alter table t1 drop primary key, add primary key(f1,f2,f3,f4); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK from (f1,f2,f3,f4) to (f1,f2,added_columns) +alter table t1 drop primary key,add column f5 int not null, +add column f6 int not null,add primary key(f1,f2,f5,f6); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK from (f1,f2,f5,f6) to (f1,f2,f5) +alter table t1 drop column f6; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same PK +alter table t1 add column f6 int; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 drop column f6; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Must sort +# Change PK from (f1,f2,f5) to (f1,f5) +alter table t1 drop column f2; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 add column f2n int after f1, drop primary key, add +primary key (f1,f5,f2n); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 change f5 f2n int not null,change f2n f5 int not null, +add column f8 int not null; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK from (f1,f4,f2n) to (f1,f4,added_column,f2n) +alter table t1 add column f7 int, drop primary key, +add primary key (f1,f5,f7,f2n); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 force; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 row_format=compact; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Reusing the same pk +alter table t1 engine=innodb; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Optimize table +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +affected rows: 2 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Sort files used for adding secondary index +alter table t1 drop primary key, add primary key(f1,f5,f7), add index +i(f3); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# No sort files used for dropping secondary index +alter table t1 drop primary key, add primary key(f1,f5),drop index i; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK(f1,f5) to (f1,added_columns) and drop f5 +alter table t1 drop primary key, add primary key(f1,f12), +drop column f5, add column f12 int not null; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Must sort +# Change PK(f1,f12) to (f1,existing_columns) +alter table t1 drop primary key, add primary key(f1,f3); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort +# Change PK(f1,f3) to (f1,added_column,f3,added_column) +alter table t1 drop primary key, add column f3n int, +add column f4n int, add primary key(f1,f3n,f3,f4n); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +SET GLOBAL innodb_monitor_reset = module_ddl; +# Adding Secondary index alone. +alter table t1 add key(f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Must sort +# Change PK(f1,f3) to (existing_column,f1) +alter table t1 drop primary key, add primary key(f4,f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 3 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort for PK. +# Change PK(f4,f1) to (added_columns,f4,f1) +# Secondary index rebuild happens +alter table t1 drop primary key, add column f5n int, +add column f6n int, add primary key(f5n,f6n,f4,f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +# Skip sort for PK. +# Change PK(f5n,f6n,f4,f1) to +# (added_columns,f5n,added_column,f6n,f4,f1) +# Secondary index rebuild happens +alter table t1 drop primary key, add column f7n int, +add column f8n int, add primary key(f7n,f5n,f8n,f6n,f4,f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and count_reset > 0; +name count_reset +ddl_sort_file_alter_table 2 +SET GLOBAL innodb_monitor_reset = module_ddl; +SET GLOBAL innodb_monitor_disable = module_ddl; +select count(*) from t1; +count(*) +2880 +drop table t1; +SET GLOBAL innodb_monitor_reset = default; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; +# Bug#19163915 INNODB: DUPLICATE RECORDS COULD EXIST +# WHEN SKIPPING SORT FOR CLUSTER INDEX +SELECT @@innodb_sort_buffer_size; +@@innodb_sort_buffer_size +65536 +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1,f2,f3,f4)) charset latin1; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 values(106, 'aaa','bbb','cccc'); +select count(*) from t1; +count(*) +481 +# Skip sort +# Change PK from (f1,f2,f3,f4) to (f1,f2,f3) +alter table t1 drop primary key, add primary key(f1,f2,f3); +ERROR 23000: Duplicate entry '106-aaa-bbb' for key 't1.PRIMARY' +select count(*) from t1; +count(*) +481 +drop table t1; +create table t1(f1 int auto_increment not null, +f2 char(200) not null, f3 char(200) not null, +f4 char(200) not null,primary key(f1,f2,f3,f4)) charset latin1; +insert into t1 select NULL,'aaa','bbb','ccc' from t480; +insert into t1 values(108,'aaa','bbb','cccc'); +select count(*) from t1; +count(*) +481 +alter table t1 drop primary key, add primary key(f1,f2,f3); +ERROR 23000: Duplicate entry '108-aaa-bbb' for key 't1.PRIMARY' +select count(*) from t1; +count(*) +481 +drop table t1, t480; +# +# Bug #19896922 SORTING SKIPPED WHEN PREFIX LENGTH OF THE PK +# FIELD IS CHANGED +# +create table t1(a int not null, b varchar(30) not null, +primary key (b(10), a)) engine = innodb; +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UxW8L'); +select * from t1; +a b +0 khdHps6UxW8Lwaoxa604oK6zkb +1 khdHps6UxW8L +alter table t1 drop primary key, add primary key (b(18),a); +select * from t1; +a b +1 khdHps6UxW8L +0 khdHps6UxW8Lwaoxa604oK6zkb +drop table t1; +create table t1(a int not null, b varchar(30) not null, +primary key (b(10), a)) engine = innodb; +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UtW8L'); +select * from t1; +a b +1 khdHps6UtW8L +0 khdHps6UxW8Lwaoxa604oK6zkb +alter table t1 drop primary key, add primary key (b(8),a); +select * from t1; +a b +0 khdHps6UxW8Lwaoxa604oK6zkb +1 khdHps6UtW8L +drop table t1; +# +# Bug #21103101 SORTING SKIPPED WHEN DROPPING THE SINGLE +# COLUMN PRIMARY KEY +# +create table t1(f1 int not null, f2 int not null, +primary key (f1), unique key(f1, f2))engine=innodb; +insert into t1 values(1,3), (2,2); +alter table t1 drop column f1; +drop table t1; +create table t1(f1 int not null, f2 int not null, +primary key (f1), unique key(f1, f2))engine=innodb; +insert into t1 values(1,3), (2,2); +alter table t1 drop primary key, lock=none; +ERROR 0A000: LOCK=NONE is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try LOCK=SHARED. +drop table t1; +# +# BUG#21612714 ALTER TABLE SORTING SKIPPED WHEN CHANGE PK AND DROP +# LAST COLUMN OF OLD PK +# +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3), drop o2, lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop o1, drop o2, add primary key(o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 add column n1 int not null, drop primary key, add primary key(n1,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add column n1 int not null, drop primary key, add primary key(o3,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2, o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o2,o1)) engine = innodb; +insert into t1 values(1,1,2),(2,1,1); +alter table t1 drop primary key, add primary key(o2,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop primary key, add primary key(o3,o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop primary key, add primary key(o1,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop o1, lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(1,2,1); +alter table t1 drop o2, lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,2,2),(2,1,1); +alter table t1 drop o1, drop o2, lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1(3), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1, o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1(3), o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb; +insert into t1 values('abd', 1, 1), ('abc', 2, 2); +alter table t1 drop primary key, add primary key(o1, o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abc', 2, 1), ('abd', 1, 2); +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb; +insert into t1 values('abc', 2, 1), ('abd', 1, 2); +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abc', 2, 2), ('abd', 1, 1); +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb; +insert into t1 values('abc', 2, 2), ('abd', 1, 1); +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (1, 'abc', 2); +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (1, 'abc', 2); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb; +insert into t1 values('abc', 'acd'), ('abd', 'abd'); +alter table t1 drop primary key, add primary key(o1(2),o2(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values('abc', 'acd'), ('abd', 'abd'); +alter table t1 drop primary key, add primary key(o1(2),o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o2(3),o1(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o2,o1), lock=none; +drop table t1; +CREATE TABLE t1(a INT NOT NULL, b INT, PRIMARY KEY (a ASC)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +INSERT INTO t1 VALUES(5,5), (4,4), (3,4), (2,3); +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a DESC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b +5 5 +4 4 +3 4 +2 3 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a ASC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b +2 3 +3 4 +4 4 +5 5 +DROP TABLE t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 add n1 int not null, drop primary key, add primary key(o1, n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1, o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1(3))) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), primary key(o1)) engine = innodb; +insert into t1 values('abd'), ('acd'); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 drop primary key, add primary key(o1(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3),n1), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb; +insert into t1 values('abd', 1), ('acd', 2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(3))) engine = innodb; +insert into t1 values(1,'abd'), (2,'acd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values(1,'abd'), (2,'acd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values(1, 'abd'), (2, 'acd'); +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values(1, 'abd'), (2, 'acd'); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(3),o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (2, 'acd', 2); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1, 'abd', 1), (2, 'acd', 2); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(2))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2(2))) engine = innodb; +insert into t1 values('abd', 'acd'), ('acd', 'abd'); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(2))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2,o3(3)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(2))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(3))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1(3),o2,o3(2)), lock=none; +drop table t1; +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(3))) engine = innodb; +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd'); +alter table t1 drop primary key, add primary key(o1,o2,o3(2)), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,o1,n2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,n2,o1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(o1,n1,n2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1),(2,2); +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none; +drop table t1; +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, o4 int not null, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2,2),(2,2,1,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,o3,o4), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none; +drop table t1; +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb; +insert into t1 values(1,1,2),(2,2,1); +alter table t1 drop primary key, add primary key(o1), lock=none; +drop table t1; +CREATE TABLE t1(o1 int, o2 int, o3 int, PRIMARY KEY(o1), KEY(o2)) ENGINE=INNODB; +INSERT INTO t1 VALUES(1,1,2),(2,2,1); +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +ALTER TABLE t1 DROP INDEX o2, ADD INDEX (o2 DESC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +o1 o2 o3 +1 1 2 +2 2 1 +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +ALTER TABLE t1 DROP INDEX o2, ADD INDEX (o2 ASC); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +o1 o2 o3 +1 1 2 +2 2 1 +EXPLAIN SELECT * FROM t1 ORDER BY o2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`o1` AS `o1`,`test`.`t1`.`o2` AS `o2`,`test`.`t1`.`o3` AS `o3` from `test`.`t1` order by `test`.`t1`.`o2` +SELECT * FROM t1 ORDER BY o2; +o1 o2 o3 +1 1 2 +2 2 1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-index_ucs2.result-pq b/mysql-test/suite/innodb/r/innodb-index_ucs2.result-pq new file mode 100644 index 000000000..63cccbc98 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-index_ucs2.result-pq @@ -0,0 +1,128 @@ +create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=ucs2; +insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); +commit; +alter table t1 add unique index (b); +ERROR 23000: Duplicate entry '2' for key 't1.b' +insert into t1 values(8,9,'fff','fff'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=ucs2 +alter table t1 add index (b); +insert into t1 values(10,10,'kkk','iii'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 6 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=ucs2 +alter table t1 add unique index (c), add index (d); +insert into t1 values(11,11,'aaa','mmm'); +select * from t1; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(b) order by b; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +select * from t1 force index(c) order by c; +a b c d +11 11 aaa mmm +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +select * from t1 force index(d) order by d; +a b c d +1 1 ab ab +2 2 ac ac +3 2 ad ad +4 4 afe afe +8 9 fff fff +10 10 kkk iii +11 11 aaa mmm +explain select * from t1 force index(b) order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 5 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`b`) order by `test`.`t1`.`b` +explain select * from t1 force index(c) order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c 21 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`c`) order by `test`.`t1`.`c` +explain select * from t1 force index(d) order by d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL d 43 NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d` from `test`.`t1` FORCE INDEX (`d`) order by `test`.`t1`.`d` +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `b` int DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `d` varchar(20) DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `c` (`c`), + KEY `b` (`b`), + KEY `d` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=ucs2 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result-pq b/mysql-test/suite/innodb/r/innodb-table-online.result-pq new file mode 100644 index 000000000..32c674545 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-table-online.result-pq @@ -0,0 +1,365 @@ +SET @global_innodb_file_per_table_orig = @@global.innodb_file_per_table; +SET GLOBAL innodb_file_per_table = on; +CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 TEXT NOT NULL) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,1,''), (2,2,''), (3,3,''), (4,4,''), (5,5,''); +SET GLOBAL innodb_monitor_enable = module_ddl; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +SET DEBUG_SYNC = 'RESET'; +SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; +INSERT INTO t1 VALUES(1,2,3); +# Establish session con1 (user=root) +SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; +SET lock_wait_timeout = 1; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL go_ahead'; +# session default +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +# session con1 +SET SESSION DEBUG = '+d,innodb_OOM_prepare_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_prepare_inplace_alter'; +SET SESSION DEBUG = '+d,innodb_OOM_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space +SET SESSION DEBUG = '-d,innodb_OOM_inplace_alter'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT, ALGORITHM=INPLACE, LOCK=NONE; +# session default +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int NOT NULL, + `c3` text NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +# session con1 +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done'; +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# session default +COMMIT; +# session con1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2); +ERROR 23000: Duplicate entry '4' for key 't1.c2' +# session default +DELETE FROM t1 WHERE c1 = 7; +# session con1 +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ROW_FORMAT=COMPACT, +LOCK = SHARED, ALGORITHM = INPLACE; +ALTER TABLE t1 ADD UNIQUE INDEX(c2), +LOCK = EXCLUSIVE, ALGORITHM = INPLACE; +Warnings: +Warning 1831 Duplicate index 'c2_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP INDEX c2, ALGORITHM = INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try ALGORITHM=COPY. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1); +# session default +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +INSERT INTO t1 VALUES(4,7,2); +SET DEBUG_SYNC = 'now SIGNAL insert_done'; +# session con1 +ERROR 23000: Duplicate entry '4' for key 't1.PRIMARY' +# session default +ROLLBACK; +# session con1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int NOT NULL, + `c3` text NOT NULL, + UNIQUE KEY `c2` (`c2`), + UNIQUE KEY `c2_2` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +ALTER TABLE t1 DROP PRIMARY KEY, ADD UNIQUE INDEX(c2), ALGORITHM = INPLACE; +ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists +ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +# session default +INSERT INTO t1 VALUES(6,3,1); +ERROR 23000: Duplicate entry '3' for key 't1.c2_2' +INSERT INTO t1 VALUES(7,4,2); +ERROR 23000: Duplicate entry '4' for key 't1.c2_2' +DROP INDEX c2_2 ON t1; +BEGIN; +INSERT INTO t1 VALUES(7,4,2); +ROLLBACK; +# session con1 +KILL QUERY @id; +ERROR 70100: Query execution was interrupted +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR kill_done'; +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +# session default +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +KILL QUERY @id; +SET DEBUG_SYNC = 'now SIGNAL kill_done'; +# session con1 +ERROR 70100: Query execution was interrupted +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +# session default +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 SELECT 5 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 10 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 20 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 40 + c1, c2, c3 FROM t1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 80 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 80 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`c2` > 3) +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# session con1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int NOT NULL, + `c2` int NOT NULL, + `c3` text NOT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt2 WAIT_FOR dml2_done'; +SET lock_wait_timeout = 10; +ALTER TABLE t1 ROW_FORMAT=COMPACT, ALGORITHM = INPLACE; +# session default +INSERT INTO t1 SELECT 80 + c1, c2, c3 FROM t1; +INSERT INTO t1 SELECT 160 + c1, c2, c3 FROM t1; +UPDATE t1 SET c2 = c2 + 1; +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +BEGIN; +DELETE FROM t1; +ROLLBACK; +UPDATE t1 SET c2 = c2 + 1; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET DEBUG_SYNC = 'now SIGNAL dml2_done'; +# session con1 +ERROR HY000: Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again. +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL rebuilt3 WAIT_FOR dml3_done'; +ALTER TABLE t1 ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +ERROR 42000: Multiple primary key defined +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c22f), CHANGE c2 c22f INT; +ERROR 23000: Duplicate entry '5' for key 't1.PRIMARY' +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c22f,c4(5)), +CHANGE c2 c22f INT, CHANGE c3 c3 TEXT NULL, CHANGE c1 c1 INT AFTER c22f, +ADD COLUMN c4 VARCHAR(6) DEFAULT 'Online'; +# session default +SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +BEGIN; +INSERT INTO t1 SELECT 320 + c1, c2, c3 FROM t1 WHERE c1 > 240; +DELETE FROM t1 WHERE c1 > 320; +ROLLBACK; +BEGIN; +UPDATE t1 SET c2 = c2 + 1; +DELETE FROM t1; +ROLLBACK; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +ddl_online_create_index 1 +ddl_pending_alter_table 1 +SET DEBUG_SYNC = 'now SIGNAL dml3_done'; +# session con1 +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +SELECT COUNT(c22f) FROM t1; +COUNT(c22f) +320 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)); +ERROR 23000: Duplicate entry '' for key 't1.PRIMARY' +UPDATE t1 SET c3 = NULL WHERE c3 = ''; +SET lock_wait_timeout = 1; +ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5)); +ERROR 42000: Multiple primary key defined +ALTER TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)), +ALGORITHM = INPLACE; +ERROR 22004: Invalid use of NULL value +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +ERROR 22004: Invalid use of NULL value +UPDATE t1 SET c3=CONCAT(c1,REPEAT('foo',c1)) WHERE c3 IS NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0'; +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL, DROP COLUMN c22f, +ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST; +# session default +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created0'; +BEGIN; +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti','YLETV2'); +INSERT INTO t1 VALUES(33101,347,NULL,''); +SET DEBUG_SYNC = 'now SIGNAL ins_done0'; +# session con1 +ERROR 22004: Invalid use of NULL value +# session default +ROLLBACK; +# session con1 +ALTER TABLE t1 MODIFY c3 TEXT NOT NULL; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created WAIT_FOR ins_done'; +ALTER TABLE t1 DROP PRIMARY KEY, DROP COLUMN c22f, +ADD COLUMN c6 VARCHAR(1000) DEFAULT +'I love tracking down hard-to-reproduce bugs.', +ADD PRIMARY KEY c3p5(c3(5), c6(2)); +# session default +SET DEBUG_SYNC = 'now WAIT_FOR c3p5_created'; +SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL ins_done WAIT_FOR ddl_timed_out'; +INSERT INTO t1 VALUES(347,33101,NULL,''); +ERROR 23000: Column 'c3' cannot be null +INSERT INTO t1 VALUES(347,33101,'Pikku kakkosen posti',''); +# session con1 +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; +SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE +subsystem = 'ddl' and name not in +('ddl_sort_file_alter_table','ddl_log_file_alter_table') and count > 0; +name count +# session default +SELECT COUNT(*) FROM t1; +COUNT(*) +321 +ALTER TABLE t1 ROW_FORMAT=REDUNDANT; +SELECT * FROM t1 LIMIT 10; +c22f c1 c3 c4 +5 1 1foo Online +6 2 2foofoo Online +7 3 3foofoofoo Online +8 4 4foofoofoofoo Online +9 5 5foofoofoofoofoo Online +5 6 6foofoofoofoofoofoo Online +6 7 7foofoofoofoofoofoofoo Online +7 8 8foofoofoofoofoofoofoofoo Online +8 9 9foofoofoofoofoofoofoofoofoo Online +9 10 10foofoofoofoofoofoofoofoofoofoo Online +# session con1 +ALTER TABLE t1 DISCARD TABLESPACE; +# session default +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c22f` int NOT NULL, + `c1` int NOT NULL, + `c3` text NOT NULL, + `c4` varchar(6) NOT NULL DEFAULT 'Online', + PRIMARY KEY (`c1`,`c22f`,`c4`(5)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Bug#18894337 ONLINE ALTER TABLE LOG APPLY FAILS TO SKIP LOCKING +# +# session con1 +CREATE TABLE t1 (a SERIAL, c64 VARCHAR(64) UNIQUE) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0, NULL); +SET DEBUG='+d,innodb_trx_duplicates'; +SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL t1_ddl WAIT_FOR t1_dml'; +ALTER TABLE t1 ENGINE=InnoDB; +# session default +SET DEBUG_SYNC='now WAIT_FOR t1_ddl'; +INSERT INTO t1 VALUES(0, NULL), (0, NULL); +SET DEBUG_SYNC='now SIGNAL t1_dml'; +# session con1 +# Disconnect session con1 +# session default +DROP TABLE t1; +SET DEBUG_SYNC = 'RESET'; +SET DEBUG = ''; +SET GLOBAL innodb_monitor_disable = module_ddl; +SET GLOBAL DEBUG = ''; +SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; +SET GLOBAL innodb_monitor_enable = default; +SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/r/innodb.result-pq b/mysql-test/suite/innodb/r/innodb.result-pq new file mode 100644 index 000000000..22f6a9b6b --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb.result-pq @@ -0,0 +1,3491 @@ +drop table if exists t1,t2,t3,t4; +drop database if exists mysqltest; +CREATE TABLE bug58912 (a BLOB, b TEXT, PRIMARY KEY(a(1))) ENGINE=InnoDB; +INSERT INTO bug58912 VALUES(REPEAT('a',8000),REPEAT('b',8000)); +UPDATE bug58912 SET a=REPEAT('a',7999); +create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb; +insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +update ignore t1 set id = 8, name = 'Sinisa' where id < 3; +Warnings: +Warning 1062 Duplicate entry '8' for key 't1.PRIMARY' +select id, code, name from t1 order by id; +id code name +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +8 1 Sinisa +update ignore t1 set id = id + 10, name = 'Ralph' where id < 4; +Warnings: +Warning 1062 Duplicate entry 'Ralph' for key 't1.name' +select id, code, name from t1 order by id; +id code name +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +8 1 Sinisa +12 1 Ralph +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY parent_id (parent_id), +KEY level (level) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2); +update t1 set parent_id=parent_id+100; +select * from t1 where parent_id=102; +id parent_id level +8 102 2 +9 102 2 +15 102 2 +update t1 set id=id+1000; +update t1 set id=1024 where id=1009; +Got one of the listed errors +select * from t1; +id parent_id level +1001 100 0 +1002 101 1 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 102 2 +1009 102 2 +1015 102 2 +1016 103 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 104 2 +1022 104 2 +1024 104 2 +1025 105 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 106 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 107 2 +1037 107 2 +1038 107 2 +1040 107 2 +1157 100 0 +1179 105 2 +1183 104 2 +1193 105 2 +1202 107 2 +1203 107 2 +update ignore t1 set id=id+1; +Warnings: +Warning 1062 Duplicate entry '1002' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1003' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1004' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1005' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1006' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1007' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1008' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1009' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1016' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1017' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1018' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1019' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1020' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1021' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1022' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1025' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1026' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1027' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1028' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1029' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1030' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1031' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1032' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1033' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1034' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1035' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1036' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1037' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1038' for key 't1.PRIMARY' +Warning 1062 Duplicate entry '1203' for key 't1.PRIMARY' +select * from t1; +id parent_id level +1001 100 0 +1002 101 1 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 102 2 +1010 102 2 +1015 102 2 +1016 103 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 104 2 +1023 104 2 +1024 104 2 +1025 105 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 106 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 107 2 +1037 107 2 +1039 107 2 +1041 107 2 +1158 100 0 +1180 105 2 +1184 104 2 +1194 105 2 +1202 107 2 +1204 107 2 +update ignore t1 set id=1023 where id=1010; +Warnings: +Warning 1062 Duplicate entry '1023' for key 't1.PRIMARY' +select * from t1 where parent_id=102; +id parent_id level +1008 102 2 +1010 102 2 +1015 102 2 +explain select level from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level` from `test`.`t1` where (`test`.`t1`.`level` = 1) +explain select level,id from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level`,`test`.`t1`.`id` AS `id` from `test`.`t1` where (`test`.`t1`.`level` = 1) +explain select level,id,parent_id from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`parent_id` AS `parent_id` from `test`.`t1` where (`test`.`t1`.`level` = 1) +select level,id from t1 where level=1; +level id +1 1002 +1 1003 +1 1004 +1 1005 +1 1006 +1 1007 +select level,id,parent_id from t1 where level=1; +level id parent_id +1 1002 101 +1 1003 101 +1 1004 101 +1 1005 101 +1 1006 101 +1 1007 101 +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 id A # NULL NULL BTREE YES NULL +t1 1 parent_id 1 parent_id A # NULL NULL BTREE YES NULL +t1 1 level 1 level A # NULL NULL BTREE YES NULL +drop table t1; +CREATE TABLE t1 ( +gesuchnr int(11) DEFAULT '0' NOT NULL, +benutzer_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (gesuchnr,benutzer_id) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +replace into t1 (gesuchnr,benutzer_id) values (2,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +select * from t1; +gesuchnr benutzer_id +1 1 +2 1 +drop table t1; +create table t1 (a int) engine=innodb; +insert into t1 values (1), (2); +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +delete from t1 where a = 1; +select * from t1; +a +2 +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a int,b varchar(20)) engine=innodb; +insert into t1 values (1,""), (2,"testing"); +delete from t1 where a = 1; +select * from t1; +a b +2 testing +create index skr on t1 (a); +insert into t1 values (3,""), (4,"testing"); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 skr 1 a A # NULL NULL YES BTREE YES NULL +drop table t1; +create table t1 (a int,b varchar(20),key(a)) engine=innodb; +insert into t1 values (1,""), (2,"testing"); +select * from t1 where a = 1; +a b +1 +drop table t1; +create table t1 (n int not null primary key) engine=innodb; +set autocommit=0; +insert into t1 values (4); +rollback; +select n, "after rollback" from t1; +n after rollback +insert into t1 values (4); +commit; +select n, "after commit" from t1; +n after commit +4 after commit +commit; +insert into t1 values (5); +insert into t1 values (4); +ERROR 23000: Duplicate entry '4' for key 't1.PRIMARY' +commit; +select n, "after commit" from t1; +n after commit +4 after commit +5 after commit +set autocommit=1; +insert into t1 values (6); +insert into t1 values (4); +ERROR 23000: Duplicate entry '4' for key 't1.PRIMARY' +select n from t1; +n +4 +5 +6 +set autocommit=0; +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +n +3 +4 +5 +6 +7 +savepoint savept3; +rollback to savepoint savept2; +rollback to savepoint savept3; +ERROR 42000: SAVEPOINT savept3 does not exist +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +n +4 +5 +6 +7 +rollback to savepoint `my_savepoint`; +ERROR 42000: SAVEPOINT my_savepoint does not exist +rollback to savepoint savept2; +ERROR 42000: SAVEPOINT savept2 does not exist +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +rollback; +drop table t1; +create table t1 (n int not null primary key) engine=innodb; +start transaction; +insert into t1 values (4); +flush tables with read lock; +commit; +unlock tables; +commit; +select * from t1; +n +4 +drop table t1; +create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb; +begin; +insert into t1 values(1,'hamdouni'); +select id as afterbegin_id,nom as afterbegin_nom from t1; +afterbegin_id afterbegin_nom +1 hamdouni +rollback; +select id as afterrollback_id,nom as afterrollback_nom from t1; +afterrollback_id afterrollback_nom +set autocommit=0; +insert into t1 values(2,'mysql'); +select id as afterautocommit0_id,nom as afterautocommit0_nom from t1; +afterautocommit0_id afterautocommit0_nom +2 mysql +rollback; +select id as afterrollback_id,nom as afterrollback_nom from t1; +afterrollback_id afterrollback_nom +set autocommit=1; +drop table t1; +CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; +insert into t1 values ('pippo', 12); +insert into t1 values ('pippo', 12); +ERROR 23000: Duplicate entry 'pippo' for key 't1.PRIMARY' +delete from t1; +delete from t1 where id = 'pippo'; +select * from t1; +id val +insert into t1 values ('pippo', 12); +set autocommit=0; +delete from t1; +rollback; +select * from t1; +id val +pippo 12 +delete from t1; +commit; +select * from t1; +id val +drop table t1; +create table t1 (a integer) engine=innodb; +start transaction; +rename table t1 to t2; +create table t1 (b integer) engine=innodb; +insert into t1 values (1); +rollback; +drop table t1; +rename table t2 to t1; +drop table t1; +set autocommit=1; +CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb; +INSERT INTO t1 VALUES (1, 'Jochen'); +select * from t1; +ID NAME +1 Jochen +drop table t1; +CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb; +set autocommit=0; +INSERT INTO t1 SET _userid='marc@anyware.co.uk'; +COMMIT; +SELECT * FROM t1; +_userid +marc@anyware.co.uk +SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk'; +_userid +marc@anyware.co.uk +drop table t1; +set autocommit=1; +CREATE TABLE t1 ( +user_id int(10) DEFAULT '0' NOT NULL, +name varchar(100), +phone varchar(100), +ref_email varchar(100) DEFAULT '' NOT NULL, +detail varchar(200), +PRIMARY KEY (user_id,ref_email) +)engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar'); +select * from t1 where user_id=10292; +user_id name phone ref_email detail +10292 sanjeev 29153373 sansh777@hotmail.com xxx +10292 shirish 2333604 shirish@yahoo.com ddsds +10292 sonali 323232 sonali@bolly.com filmstar +INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds'); +select * from t1 where user_id=10292; +user_id name phone ref_email detail +10292 sanjeev 29153373 sansh777@hotmail.com xxx +10292 shirish 2333604 shirish@yahoo.com ddsds +10292 sonali 323232 sonali@bolly.com filmstar +select * from t1 where user_id>=10292; +user_id name phone ref_email detail +10292 sanjeev 29153373 sansh777@hotmail.com xxx +10292 shirish 2333604 shirish@yahoo.com ddsds +10292 sonali 323232 sonali@bolly.com filmstar +10293 shirish 2333604 shirish@yahoo.com ddsds +select * from t1 where user_id>10292; +user_id name phone ref_email detail +10293 shirish 2333604 shirish@yahoo.com ddsds +select * from t1 where user_id<10292; +user_id name phone ref_email detail +10291 sanjeev 29153373 sansh777@hotmail.com xxx +drop table t1; +CREATE TABLE t1 (a int not null, b int not null,c int not null, +key(a),primary key(a,b), unique(c),key(a),unique(b)); +Warnings: +Warning 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES NULL +t1 0 PRIMARY 2 b A # NULL NULL BTREE YES NULL +t1 0 c 1 c A # NULL NULL BTREE YES NULL +t1 0 b 1 b A # NULL NULL BTREE YES NULL +t1 1 a 1 a A # NULL NULL BTREE YES NULL +t1 1 a_2 1 a A # NULL NULL BTREE YES NULL +drop table t1; +create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)); +alter table t1 engine=innodb; +insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4'); +select * from t1; +col1 col2 +1 1 +2 3 +3 4 +4 4 +5 2 +update t1 set col2='7' where col1='4'; +select * from t1; +col1 col2 +1 1 +2 3 +3 4 +4 7 +5 2 +alter table t1 add co3 int not null; +select * from t1; +col1 col2 co3 +1 1 0 +2 3 0 +3 4 0 +4 7 0 +5 2 0 +update t1 set col2='9' where col1='2'; +select * from t1; +col1 col2 co3 +1 1 0 +2 9 0 +3 4 0 +4 7 0 +5 2 0 +drop table t1; +create table t1 (a int not null , b int, primary key (a)) engine = innodb; +create table t2 (a int not null , b int, primary key (a)) engine = myisam; +insert into t1 VALUES (1,3) , (2,3), (3,3); +select * from t1; +a b +1 3 +2 3 +3 3 +insert into t2 select * from t1; +select * from t2; +a b +1 3 +2 3 +3 3 +delete from t1 where b = 3; +select * from t1; +a b +insert into t1 select * from t2; +select * from t1; +a b +1 3 +2 3 +3 3 +select * from t2; +a b +1 3 +2 3 +3 3 +drop table t1,t2; +CREATE TABLE t1 ( +user_name varchar(12), +password text, +subscribed char(1), +user_id int(11) DEFAULT '0' NOT NULL, +quota bigint(20), +weight double, +access_date date, +access_time time, +approved datetime, +dummy_primary_key int(11) NOT NULL auto_increment, +PRIMARY KEY (dummy_primary_key) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1); +INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2); +INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3); +INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4); +INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5); +select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name; +user_name password subscribed user_id quota weight access_date access_time approved dummy_primary_key +user_0 somepassword N 0 0 0 2000-09-07 23:06:59 2000-09-07 23:06:59 1 +user_1 somepassword Y 1 1 1 2000-09-07 23:06:59 2000-09-07 23:06:59 2 +user_2 somepassword N 2 2 1.4142135623731 2000-09-07 23:06:59 2000-09-07 23:06:59 3 +user_3 somepassword Y 3 3 1.7320508075689 2000-09-07 23:06:59 2000-09-07 23:06:59 4 +user_4 somepassword N 4 4 2 2000-09-07 23:06:59 2000-09-07 23:06:59 5 +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +parent_id int(11) DEFAULT '0' NOT NULL, +level tinyint(4) DEFAULT '0' NOT NULL, +KEY (id), +KEY parent_id (parent_id), +KEY level (level) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1); +INSERT INTO t1 values (179,5,2); +update t1 set parent_id=parent_id+100; +select * from t1 where parent_id=102; +id parent_id level +8 102 2 +9 102 2 +15 102 2 +update t1 set id=id+1000; +update t1 set id=1024 where id=1009; +select * from t1; +id parent_id level +1001 100 0 +1002 101 1 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 102 2 +1015 102 2 +1016 103 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 104 2 +1022 104 2 +1024 102 2 +1024 104 2 +1025 105 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 106 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 107 2 +1037 107 2 +1038 107 2 +1040 107 2 +1157 100 0 +1179 105 2 +1183 104 2 +1193 105 2 +1202 107 2 +1203 107 2 +update ignore t1 set id=id+1; +select * from t1; +id parent_id level +1002 100 0 +1003 101 1 +1004 101 1 +1005 101 1 +1006 101 1 +1007 101 1 +1008 101 1 +1009 102 2 +1016 102 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 103 2 +1022 104 2 +1023 104 2 +1025 102 2 +1025 104 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 105 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 106 2 +1037 107 2 +1038 107 2 +1039 107 2 +1041 107 2 +1158 100 0 +1180 105 2 +1184 104 2 +1194 105 2 +1203 107 2 +1204 107 2 +update ignore t1 set id=1023 where id=1010; +select * from t1 where parent_id=102; +id parent_id level +1009 102 2 +1025 102 2 +1016 102 2 +explain select level from t1 where level=1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref level level 1 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`level` AS `level` from `test`.`t1` where (`test`.`t1`.`level` = 1) +select level,id from t1 where level=1; +level id +1 1003 +1 1004 +1 1005 +1 1006 +1 1007 +1 1008 +select level,id,parent_id from t1 where level=1; +level id parent_id +1 1003 101 +1 1004 101 +1 1005 101 +1 1006 101 +1 1007 101 +1 1008 101 +select level,id from t1 where level=1 order by id; +level id +1 1003 +1 1004 +1 1005 +1 1006 +1 1007 +1 1008 +delete from t1 where level=1; +select * from t1; +id parent_id level +1002 100 0 +1009 102 2 +1016 102 2 +1017 103 2 +1018 103 2 +1019 103 2 +1020 103 2 +1021 103 2 +1022 104 2 +1023 104 2 +1025 102 2 +1025 104 2 +1026 105 2 +1027 105 2 +1028 105 2 +1029 105 2 +1030 105 2 +1031 105 2 +1032 106 2 +1033 106 2 +1034 106 2 +1035 106 2 +1036 106 2 +1037 107 2 +1038 107 2 +1039 107 2 +1041 107 2 +1158 100 0 +1180 105 2 +1184 104 2 +1194 105 2 +1203 107 2 +1204 107 2 +drop table t1; +CREATE TABLE t1 ( +sca_code char(6) NOT NULL, +cat_code char(6) NOT NULL, +sca_desc varchar(50), +lan_code char(2) NOT NULL, +sca_pic varchar(100), +sca_sdesc varchar(50), +sca_sch_desc varchar(16), +PRIMARY KEY (sca_code, cat_code, lan_code), +INDEX sca_pic (sca_pic) +) engine = innodb ; +INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING'); +select count(*) from t1 where sca_code = 'PD'; +count(*) +1 +select count(*) from t1 where sca_code <= 'PD'; +count(*) +1 +select count(*) from t1 where sca_pic is null; +count(*) +2 +alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic); +select count(*) from t1 where sca_code='PD' and sca_pic is null; +count(*) +1 +select count(*) from t1 where cat_code='E'; +count(*) +0 +alter table t1 drop index sca_pic, add index (sca_pic, cat_code); +select count(*) from t1 where sca_code='PD' and sca_pic is null; +count(*) +1 +select count(*) from t1 where sca_pic >= 'n'; +count(*) +1 +select sca_pic from t1 where sca_pic is null; +sca_pic +NULL +NULL +update t1 set sca_pic="test" where sca_pic is null; +delete from t1 where sca_code='pd'; +drop table t1; +set @a:=now(); +CREATE TABLE t1 (a int not null, b timestamp not null default +current_timestamp on update current_timestamp, primary key (a)) engine=innodb; +insert into t1 (a) values(1),(2),(3); +select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a; +a +1 +2 +3 +select a from t1 natural join t1 as t2 where b >= @a order by a; +a +1 +2 +3 +update t1 set a=5 where a=1; +select a from t1; +a +2 +3 +5 +drop table t1; +create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb; +insert into t1 values("hello",1),("world",2); +select * from t1 order by b desc; +a b +world 2 +hello 1 +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +show keys from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES NULL +drop table t1; +create table t1 (i int, j int ) ENGINE=innodb; +insert into t1 values (1,2); +select * from t1 where i=1 and j=2; +i j +1 2 +create index ax1 on t1 (i,j); +select * from t1 where i=1 and j=2; +i j +1 2 +drop table t1; +CREATE TABLE t1 ( +a int3 unsigned NOT NULL, +b int1 unsigned NOT NULL, +UNIQUE (a, b) +) ENGINE = innodb; +INSERT INTO t1 VALUES (1, 1); +SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1; +MIN(B) MAX(b) +1 1 +drop table t1; +create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb; +insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +explain select * from t1 where a > 0 and a < 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e`,`test`.`t1`.`f` AS `f`,`test`.`t1`.`g` AS `g`,`test`.`t1`.`h` AS `h`,`test`.`t1`.`i` AS `i`,`test`.`t1`.`j` AS `j`,`test`.`t1`.`k` AS `k`,`test`.`t1`.`l` AS `l`,`test`.`t1`.`m` AS `m`,`test`.`t1`.`n` AS `n`,`test`.`t1`.`o` AS `o`,`test`.`t1`.`p` AS `p`,`test`.`t1`.`q` AS `q`,`test`.`t1`.`r` AS `r`,`test`.`t1`.`s` AS `s`,`test`.`t1`.`t` AS `t`,`test`.`t1`.`u` AS `u`,`test`.`t1`.`v` AS `v`,`test`.`t1`.`w` AS `w`,`test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t1`.`z` AS `z`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`a3` AS `a3`,`test`.`t1`.`a4` AS `a4`,`test`.`t1`.`a5` AS `a5`,`test`.`t1`.`a6` AS `a6`,`test`.`t1`.`a7` AS `a7`,`test`.`t1`.`a8` AS `a8`,`test`.`t1`.`a9` AS `a9`,`test`.`t1`.`b1` AS `b1`,`test`.`t1`.`b2` AS `b2`,`test`.`t1`.`b3` AS `b3`,`test`.`t1`.`b4` AS `b4`,`test`.`t1`.`b5` AS `b5`,`test`.`t1`.`b6` AS `b6` from `test`.`t1` where ((`test`.`t1`.`a` > 0) and (`test`.`t1`.`a` < 50)) +drop table t1; +create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; +insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); +LOCK TABLES t1 WRITE; +insert into t1 values (99,1,2,'D'),(1,1,2,'D'); +ERROR 23000: Duplicate entry '1-1' for key 't1.PRIMARY' +select id from t1; +id +0 +1 +2 +select id from t1; +id +0 +1 +2 +UNLOCK TABLES; +DROP TABLE t1; +create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; +insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); +LOCK TABLES t1 WRITE; +begin; +insert into t1 values (99,1,2,'D'),(1,1,2,'D'); +ERROR 23000: Duplicate entry '1-1' for key 't1.PRIMARY' +select id from t1; +id +0 +1 +2 +insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D'); +Warnings: +Warning 1062 Duplicate entry '1-1' for key 't1.PRIMARY' +commit; +select id,id3 from t1; +id id3 +0 0 +1 1 +2 2 +100 2 +UNLOCK TABLES; +DROP TABLE t1; +create table t1 (a char(20), unique (a(5))) engine=innodb; +drop table t1; +create table t1 (a char(20), index (a(5))) engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(20) DEFAULT NULL, + KEY `a` (`a`(5)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb; +insert into t1 values (NULL),(NULL),(NULL); +delete from t1 where a=3; +insert into t1 values (NULL); +select * from t1; +a +1 +2 +4 +alter table t1 add b int; +select * from t1; +a b +1 NULL +2 NULL +4 NULL +drop table t1; +create table t1 +( +id int auto_increment primary key, +name varchar(32) not null, +value text not null, +uid int not null, +unique key(name,uid) +) engine=innodb; +insert into t1 values (1,'one','one value',101), +(2,'two','two value',102),(3,'three','three value',103); +set insert_id=5; +replace into t1 (value,name,uid) values ('other value','two',102); +delete from t1 where uid=102; +set insert_id=5; +replace into t1 (value,name,uid) values ('other value','two',102); +set insert_id=6; +replace into t1 (value,name,uid) values ('other value','two',102); +select * from t1; +id name value uid +1 one one value 101 +3 three three value 103 +6 two other value 102 +drop table t1; +create database mysqltest; +create table mysqltest.t1 (a int not null) engine= innodb; +insert into mysqltest.t1 values(1); +create table mysqltest.t2 (a int not null) engine= myisam; +insert into mysqltest.t2 values(1); +create table mysqltest.t3 (a int not null) engine= heap; +insert into mysqltest.t3 values(1); +commit; +drop database mysqltest; +show tables from mysqltest; +ERROR 42000: Unknown database 'mysqltest' +set autocommit=0; +create table t1 (a int not null) engine= innodb; +insert into t1 values(1),(2); +truncate table t1; +commit; +truncate table t1; +truncate table t1; +select * from t1; +a +insert into t1 values(1),(2); +delete from t1; +select * from t1; +a +commit; +drop table t1; +set autocommit=1; +create table t1 (a int not null) engine= innodb; +insert into t1 values(1),(2); +truncate table t1; +insert into t1 values(1),(2); +select * from t1; +a +1 +2 +truncate table t1; +insert into t1 values(1),(2); +delete from t1; +select * from t1; +a +drop table t1; +create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb; +insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); +explain select * from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`a` +explain select * from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`b` +explain select * from t1 order by c; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` order by `test`.`t1`.`c` +explain select a from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `test`.`t1`.`a` +explain select b from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` +explain select a,b from t1 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` +explain select a,b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +explain select a,b,c from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` +drop table t1; +create table t1 (t int not null default 1, key (t)) engine=innodb; +desc t1; +Field Type Null Key Default Extra +t int NO MUL 1 +drop table t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 ( +number bigint(20) NOT NULL default '0', +cname char(15) NOT NULL default '', +carrier_id smallint(6) NOT NULL default '0', +privacy tinyint(4) NOT NULL default '0', +last_mod_date timestamp NOT NULL, +last_mod_id smallint(6) NOT NULL default '0', +last_app_date timestamp NOT NULL, +last_app_id smallint(6) default '-1', +version smallint(6) NOT NULL default '0', +assigned_scps int(11) default '0', +status tinyint(4) default '0' +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1); +INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0); +INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1); +INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0); +INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0); +INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0); +CREATE TABLE t2 ( +number bigint(20) NOT NULL default '0', +cname char(15) NOT NULL default '', +carrier_id smallint(6) NOT NULL default '0', +privacy tinyint(4) NOT NULL default '0', +last_mod_date timestamp NOT NULL, +last_mod_id smallint(6) NOT NULL default '0', +last_app_date timestamp NOT NULL, +last_app_id smallint(6) default '-1', +version smallint(6) NOT NULL default '0', +assigned_scps int(11) default '0', +status tinyint(4) default '0' +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1); +INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0); +INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1); +INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0); +select * from t1; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +302467 Sue's Subshop 90 3 2002-01-09 11:32:41 500 2002-01-02 11:51:11 501 7 24 0 +333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 +4077711111 SeanWheeler 90 2 2002-01-11 11:28:46 500 0000-00-00 00:00:00 -1 2 3 1 +6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 +650 San Francisco 0 0 2001-12-27 11:13:36 342 0000-00-00 00:00:00 -1 1 24 1 +9197722223 berry 90 3 2002-01-11 11:28:09 500 2002-01-02 11:45:32 501 4 10 0 +select * from t2; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 +4077711111 SeanWheeler 0 2 2002-01-11 11:28:53 500 0000-00-00 00:00:00 -1 2 3 1 +650 San Francisco 90 0 2002-01-09 11:31:58 342 0000-00-00 00:00:00 -1 1 24 1 +9197722223 berry 90 3 2002-01-11 11:28:18 500 2002-01-02 11:45:32 501 4 10 0 +delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null); +select * from t1; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 +333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 +select * from t2; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 +select * from t2; +number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status +333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 +drop table t1,t2; +SET sql_mode = default; +create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb; +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +SELECT @@transaction_isolation,@@global.transaction_isolation; +@@transaction_isolation @@global.transaction_isolation +SERIALIZABLE REPEATABLE-READ +insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +COMMIT; +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +COMMIT; +SET binlog_format='MIXED'; +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt'); +select id, code, name from t1 order by id; +id code name +1 1 Tim +2 1 Monty +3 2 David +4 2 Erik +5 3 Sasha +6 3 Jeremy +7 4 Matt +COMMIT; +DROP TABLE t1; +create table t1 (n int(10), d int(10)) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (n int(10), d int(10)) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values(1,1),(1,2); +insert into t2 values(1,10),(2,20); +UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; +select * from t1; +n d +1 10 +1 10 +select * from t2; +n d +1 30 +2 20 +drop table t1,t2; +drop table if exists t1, t2; +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; +create trigger trg_del_t2 after delete on t2 for each row +insert into t1 values (1); +insert into t1 values (1); +insert into t2 values (1),(2); +delete t2 from t2; +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +select count(*) from t2 /* must be 2 as restored after rollback caused by the error */; +count(*) +2 +drop table t1, t2; +drop table if exists t1, t2; +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; +create trigger trg_del_t2 after delete on t2 for each row +insert into t1 values (1); +insert into t1 values (1); +insert into t2 values (1),(2); +delete t2 from t2; +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +select count(*) from t2 /* must be 2 as restored after rollback caused by the error */; +count(*) +2 +drop table t1, t2; +create table t1 (a int, b int) engine=innodb; +insert into t1 values(20,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a; +b ifnull(t2.b,"this is null") +NULL this is null +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +insert into t1 values(10,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +b ifnull(t2.b,"this is null") +NULL this is null +NULL this is null +drop table t1; +create table t1 (a varchar(10) not null) engine=myisam; +create table t2 (b varchar(10) not null unique) engine=innodb; +select t1.a from t1,t2 where t1.a=t2.b; +a +drop table t1,t2; +create table t1 (a int not null, b int, primary key (a)) engine = innodb; +create table t2 (a int not null, b int, primary key (a)) engine = innodb; +insert into t1 values (10, 20); +insert into t2 values (10, 20); +update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10; +drop table t1,t2; +CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE ) ENGINE=INNODB; +insert into t1 set id=1; +insert into t2 set id=1, t1_id=1; +delete t1,t2 from t1,t2 where t1.id=t2.t1_id; +select * from t1; +id +select * from t2; +id t1_id +drop table t2,t1; +CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) ENGINE=INNODB; +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(1, 1); +SELECT * from t1; +id +1 +UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1; +SELECT * from t1; +id +2 +UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id; +SELECT * from t1; +id +3 +DROP TABLE t1,t2; +set autocommit=0; +CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; +CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; +CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB; +INSERT INTO t3 VALUES("my-test-1", "my-test-2"); +COMMIT; +INSERT INTO t1 VALUES("this-key", "will disappear"); +INSERT INTO t2 VALUES("this-key", "will also disappear"); +DELETE FROM t3 WHERE id1="my-test-1"; +SELECT * FROM t1; +id value +this-key will disappear +SELECT * FROM t2; +id value +this-key will also disappear +SELECT * FROM t3; +id1 id2 +ROLLBACK; +SELECT * FROM t1; +id value +SELECT * FROM t2; +id value +SELECT * FROM t3; +id1 id2 +my-test-1 my-test-2 +SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE; +id1 id2 +my-test-1 my-test-2 +COMMIT; +set autocommit=1; +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb; +INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); +UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000; +SELECT * from t1; +a b +1 1 +102 2 +103 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +drop table t1; +CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM; +CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB; +SET AUTOCOMMIT=0; +INSERT INTO t1 ( B_ID ) VALUES ( 1 ); +INSERT INTO t2 ( NEXT_T ) VALUES ( 1 ); +ROLLBACK; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +SELECT * FROM t1; +B_ID +drop table t1,t2; +create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = innodb; +insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2); +select distinct parent,child from t1 order by parent; +parent child +0 4 +1 2 +1 3 +2 1 +drop table t1; +create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb; +create table t2 (a int not null auto_increment primary key, b int); +insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null); +insert into t2 (a) select b from t1; +insert into t1 (b) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +insert into t2 (a) select b from t1; +insert into t1 (a) select b from t2; +select count(*) from t1; +count(*) +623 +explain select * from t1 where c between 1 and 2500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range c c 5 NULL # 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` between 1 and 2500) +update t1 set c=a; +explain select * from t1 where c between 1 and 2500; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (2 workers) +2 SIMPLE t1 NULL ALL c NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` between 1 and 2500) +drop table t1,t2; +create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb; +insert into t1 (id) values (null),(null),(null),(null),(null); +update t1 set fk=69 where fk is null order by id limit 1; +SELECT * from t1; +id fk +1 69 +2 NULL +3 NULL +4 NULL +5 NULL +drop table t1; +create table t1 (a int not null, b int not null, key (a)); +insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3); +SET @tmp=0; +update t1 set b=(@tmp:=@tmp+1) order by a; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 set b=99 where a=1 order by b asc limit 1; +update t1 set b=100 where a=1 order by b desc limit 2; +update t1 set a=a+10+b where a=1 order by b; +select * from t1 order by a,b; +a b +2 4 +2 5 +2 6 +3 7 +3 8 +3 9 +3 10 +3 11 +3 12 +13 2 +111 100 +111 100 +drop table t1; +create table t1 ( c char(8) not null ) engine=innodb; +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb; +insert into t2 select * from t1; +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +drop table t1,t2; +SET AUTOCOMMIT=1; +create table t1 (a integer auto_increment primary key) engine=innodb; +insert into t1 (a) values (NULL),(NULL); +truncate table t1; +insert into t1 (a) values (NULL),(NULL); +SELECT * from t1; +a +1 +2 +drop table t1; +CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) ENGINE=INNODB; +drop table t2,t1; +create table `t1` (`id` int( 11 ) not null ,primary key ( `id` )) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into `t1`values ( 1 ) ; +create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into `t2`values ( 1 ) ; +create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into `t3`values ( 1 ) ; +delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)) +update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)) +update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +ERROR 42S22: Unknown column 't1.id' in 'where clause' +drop table t3,t2,t1; +CREATE TABLE t1 ( +c1 VARCHAR(8), c2 VARCHAR(8), +PRIMARY KEY (c1, c2) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +c0 INT PRIMARY KEY, +c1 VARCHAR(8) UNIQUE, +FOREIGN KEY (c1) REFERENCES t1 (c1) ON UPDATE CASCADE +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('old', 'somevalu'), ('other', 'anyvalue'); +INSERT INTO t2 VALUES (10, 'old'), (20, 'other'); +UPDATE t1 SET c1 = 'other' WHERE c1 = 'old'; +ERROR 23000: Foreign key constraint for table 't1', record 'other-somevalu' would lead to a duplicate entry in table 't2', key 'c1' +DROP TABLE t2,t1; +create table t1( +id int primary key, +pid int, +index(pid), +foreign key(pid) references t1(id) on delete cascade) engine=innodb; +insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6), +(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14); +delete from t1 where id=0; +ERROR HY000: Foreign key cascade delete/update exceeds max depth of 15. +delete from t1 where id=15; +delete from t1 where id=0; +drop table t1; +CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx +(stamp))ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values (1),(2),(3); +insert ignore into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000); +Warnings: +Warning 1265 Data truncated for column 'stamp' at row 3 +SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < +'20020204120000' GROUP BY col1; +col1 +1 +2 +3 +4 +drop table t1,t2; +CREATE TABLE t1 ( +`id` int(10) unsigned NOT NULL auto_increment, +`id_object` int(10) unsigned default '0', +`id_version` int(10) unsigned NOT NULL default '1', +`label` varchar(100) NOT NULL default '', +`description` text, +PRIMARY KEY (`id`), +KEY `id_object` (`id_object`), +KEY `id_version` (`id_version`) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL); +CREATE TABLE t2 ( +`id` int(10) unsigned NOT NULL auto_increment, +`id_version` int(10) unsigned NOT NULL default '1', +PRIMARY KEY (`id`), +KEY `id_version` (`id_version`) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9"); +SELECT t2.id, t1.`label` FROM t2 INNER JOIN +(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl +ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object) ORDER BY 1; +id label +102 Le Pekin (Test) +1794 Test de resto +1822 Test 3 +3382 Test +3524 Societe Test +3525 Fournisseur Test +drop table t1,t2; +create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam; +create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb; +create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb; +insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); +insert t2 select * from t1; +insert t3 select * from t1; +checksum table t1, t2, t3, t4 quick; +Table Checksum +test.t1 2948697075 +test.t2 NULL +test.t3 NULL +test.t4 NULL +Warnings: +Error 1146 Table 'test.t4' doesn't exist +checksum table t1, t2, t3, t4; +Table Checksum +test.t1 2948697075 +test.t2 2948697075 +test.t3 2948697075 +test.t4 NULL +Warnings: +Error 1146 Table 'test.t4' doesn't exist +checksum table t1, t2, t3, t4 extended; +Table Checksum +test.t1 2948697075 +test.t2 2948697075 +test.t3 2948697075 +test.t4 NULL +Warnings: +Error 1146 Table 'test.t4' doesn't exist +drop table t1,t2,t3; +create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; +insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); +select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1; +trim(name2) +fff +sss +ttt +first +second +third +1 +2 +3 +drop table t1; +create table t1 (a int) engine=innodb; +create table t2 like t1; +drop table t1,t2; +create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `t1_id_fk` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create index id on t2 (id); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `id` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create index id2 on t2 (id); +Warnings: +Warning 1831 Duplicate index 'id2' defined on the table 'test.t2'. This is deprecated and will be disallowed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `id` (`id`), + KEY `id2` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop index id2 on t2; +drop index id on t2; +ERROR HY000: Cannot drop index 'id': needed in a foreign key constraint +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + KEY `id` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + KEY `t1_id_fk` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create unique index id on t2 (id,id2); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + KEY `t1_id_fk` (`id2`,`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `id2` int NOT NULL, + UNIQUE KEY `id` (`id`,`id2`), + KEY `t1_id_fk` (`id2`,`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL AUTO_INCREMENT, + `id2` int NOT NULL, + PRIMARY KEY (`id`), + KEY `id` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL AUTO_INCREMENT, + `id2` int NOT NULL, + KEY `t1_id_fk` (`id`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t2 add index id_test (id), add index id_test2 (id,id2); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL AUTO_INCREMENT, + `id2` int NOT NULL, + KEY `id_test` (`id`), + KEY `id_test2` (`id`,`id2`), + CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; +ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match +create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b_2` (`b`), + KEY `b` (`b`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2; +create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `b` (`b`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`), + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2, t1; +create table t1 (c char(10), index (c,c)) engine=innodb; +ERROR 42S21: Duplicate column name 'c' +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10)) engine=innodb; +alter table t1 add key (c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c2,c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c2,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c1,c2); +ERROR 42S21: Duplicate column name 'c1' +drop table t1; +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), +CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +a_id b_list +1 1,2,3 +2 4,5 +3 NULL +DROP TABLE t2; +DROP TABLE t1; +create temporary table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +a +42 +drop table t1; +create table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +a +42 +drop table t1; +create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb; +insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3); +analyze table t1; +select * from t1 order by a,b,c,d; +a b c d e +1 1 a 1 1 +2 2 b 2 2 +3 3 ab 3 3 +explain select * from t1 order by a,b,c,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`,`test`.`t1`.`c`,`test`.`t1`.`d` +drop table t1; +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +min(a) +4 +select min(b) from t1 where a='8'; +min(b) +6 +drop table t1; +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); +select * from t1; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x>0; +count(*) +2 +select count(*) from t1 where x=0; +count(*) +0 +select count(*) from t1 where x<0; +count(*) +0 +select count(*) from t1 where x < -16; +count(*) +0 +select count(*) from t1 where x = -16; +count(*) +0 +explain select count(*) from t1 where x > -16; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 8 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where true +select count(*) from t1 where x > -16; +count(*) +2 +select * from t1 where x > -16; +x +18446744073709551600 +18446744073709551601 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 +drop table t1; +SELECT variable_value FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total'; +variable_value +{checked_valid} +SELECT variable_value FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size'; +variable_value +{checked_valid} +SELECT sum(variable_value) - @innodb_rows_deleted_orig FROM performance_schema.global_status WHERE LOWER(variable_name) like 'innodb%_rows_deleted'; +sum(variable_value) - @innodb_rows_deleted_orig +1830 +SELECT sum(variable_value) - @innodb_rows_inserted_orig FROM performance_schema.global_status WHERE LOWER(variable_name) like 'innodb%_rows_inserted'; +sum(variable_value) - @innodb_rows_inserted_orig +2733 +SELECT sum(variable_value) - @innodb_rows_updated_orig FROM performance_schema.global_status WHERE LOWER(variable_name) like 'innodb%_rows_updated'; +sum(variable_value) - @innodb_rows_updated_orig +2635 +SELECT variable_value - @innodb_row_lock_waits_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits'; +variable_value - @innodb_row_lock_waits_orig +0 +SELECT variable_value - @innodb_row_lock_current_waits_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits'; +variable_value - @innodb_row_lock_current_waits_orig +0 +SELECT variable_value - @innodb_row_lock_time_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time'; +variable_value - @innodb_row_lock_time_orig +0 +SELECT variable_value - @innodb_row_lock_time_max_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max'; +variable_value - @innodb_row_lock_time_max_orig +0 +SELECT variable_value - @innodb_row_lock_time_avg_orig FROM performance_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg'; +variable_value - @innodb_row_lock_time_avg_orig +0 +SET @innodb_sync_spin_loops_orig = @@innodb_sync_spin_loops; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 30 +set global innodb_sync_spin_loops=1000; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 1000 +set global innodb_sync_spin_loops=0; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 0 +set global innodb_sync_spin_loops=20; +show variables like "innodb_sync_spin_loops"; +Variable_name Value +innodb_sync_spin_loops 20 +set global innodb_sync_spin_loops=@innodb_sync_spin_loops_orig; +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 0 +set global innodb_thread_concurrency=1001; +Warnings: +Warning 1292 Truncated incorrect innodb_thread_concurrency value: '1001' +Warning 1210 Current innodb_thread_concurrency is too big for safety of log files. Consider decreasing it or increase number of log files. +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 1000 +set global innodb_thread_concurrency=0; +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 0 +set global innodb_thread_concurrency=16; +show variables like "innodb_thread_concurrency"; +Variable_name Value +innodb_thread_concurrency 16 +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 5000 +set global innodb_concurrency_tickets=1000; +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 1000 +set global innodb_concurrency_tickets=0; +Warnings: +Warning 1292 Truncated incorrect innodb_concurrency_tickets value: '0' +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 1 +set global innodb_concurrency_tickets=5000; +show variables like "innodb_concurrency_tickets"; +Variable_name Value +innodb_concurrency_tickets 5000 +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 10000 +set global innodb_thread_sleep_delay=100000; +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 100000 +set global innodb_thread_sleep_delay=0; +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 0 +set global innodb_thread_sleep_delay=10000; +show variables like "innodb_thread_sleep_delay"; +Variable_name Value +innodb_thread_sleep_delay 10000 +set default_storage_engine=INNODB; +set session old_alter_table=1; +drop table if exists t1,t2,t3; +--- Testing varchar --- +--- Testing varchar --- +create table t1 (v varchar(10), c char(10), t text); +insert into t1 values('+ ', '+ ', '+ '); +set @a=repeat(' ',20); +insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); +Warnings: +Note 1265 Data truncated for column 'v' at row 1 +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+ *+*+ * +*+ *+*+ * +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t2 like t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +create table t3 select * from t1; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify c varchar(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` text +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify v char(10); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` text +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 modify t varchar(10); +Warnings: +Note 1265 Data truncated for column 't' at row 2 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) DEFAULT NULL, + `c` varchar(10) DEFAULT NULL, + `t` varchar(10) DEFAULT NULL +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +select concat('*',v,'*',c,'*',t,'*') from t1; +concat('*',v,'*',c,'*',t,'*') +*+*+*+ * +*+*+*+ * +drop table t1,t2,t3; +create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10))) +stats_persistent=0 charset latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `v` (`v`), + KEY `c` (`c`), + KEY `t` (`t`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select count(*) from t1; +count(*) +270 +insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where c='a'; +count(*) +10 +select count(*) from t1 where t='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where c='a '; +count(*) +10 +select count(*) from t1 where t='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where c like 'a%'; +count(*) +11 +select count(*) from t1 where t like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where c='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref c c 11 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`c` = 'a ') +explain select count(*) from t1 where t='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref t t 13 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`t` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 13 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 13 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +alter table t1 add unique(v); +ERROR 23000: Duplicate entry '{ ' for key 't1.v_2' +alter table t1 add key(v); +Warnings: +Warning 1831 Duplicate index 'v_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; +qq +*a*a*a* +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +*a *a*a * +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v,v_2 # 13 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select TRIM(v),count(*) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(c) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(c) from t1 group by TRIM(v) order by TRIM(v) limit 10; +TRIM(v) count(c) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(*) from t1 group by c order by c limit 10; +c count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select c,count(t) from t1 group by c order by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result c,count(t) from t1 group by c limit 10; +c count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(t),count(*) from t1 group by TRIM(t) order by TRIM(t) limit 10; +TRIM(t) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(t),count(t) from t1 group by TRIM(t) order by TRIM(t) limit 10; +TRIM(t) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(t),count(t) from t1 group by TRIM(t) order by TRIM(t) limit 10; +TRIM(t) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(300) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `c` (`c`), + KEY `t` (`t`(10)), + KEY `v` (`v`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 303 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 303 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 303 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 303 const # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 303 const # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select v,count(*) from t1 group by v order by v limit 10; +v count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +alter table t1 drop key v, add key v (v(30)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(300) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `c` (`c`), + KEY `t` (`t`(10)), + KEY `v` (`v`(30)) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select count(*) from t1 where v='a'; +count(*) +10 +select count(*) from t1 where v='a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a '; +count(*) +10 +select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +count(*) +10 +select count(*) from t1 where v like 'a%'; +count(*) +11 +select count(*) from t1 where v like 'a %'; +count(*) +9 +explain select count(*) from t1 where v='a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` = 'a ') +explain select count(*) from t1 where v like 'a%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v v 33 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` like 'a%') +explain select count(*) from t1 where v between 'a' and 'a '; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where (`test`.`t1`.`v` between 'a' and 'a ') +explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`v` between 'a' and 'a ') and (`test`.`t1`.`v` between 'a ' and 'b\n')) +explain select * from t1 where v='a'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref v v 33 const # 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`t` AS `t` from `test`.`t1` where (`test`.`t1`.`v` = 'a') +select TRIM(v),count(*) from t1 group by v order by v limit 10; +TRIM(v) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +alter table t1 modify v varchar(600), drop key v, add key v (v); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(600) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `c` (`c`), + KEY `t` (`t`(10)), + KEY `v` (`v`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=0 +select TRIM(v),count(*) from t1 group by v order by v limit 10; +TRIM(v) count(*) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +select sql_big_result TRIM(v),count(t) from t1 group by v order by v limit 10; +TRIM(v) count(t) +a 1 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 +drop table t1; +SET NAMES utf8mb4; +create table t1 (a char(10), unique (a)); +insert into t1 values ('a '); +insert into t1 values ('a '); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +alter table t1 modify a varchar(10); +insert into t1 values ('a'),('á'),('à'),('å'); +ERROR 23000: Duplicate entry 'a' for key 't1.a' +insert into t1 values ('á'); +ERROR 23000: Duplicate entry 'á' for key 't1.a' +insert into t1 values ('A'); +ERROR 23000: Duplicate entry 'A' for key 't1.a' +insert into t1 values ('å'); +ERROR 23000: Duplicate entry 'å' for key 't1.a' +update t1 set a='a ' where a like 'a%'; +select concat(a,'.') from t1; +concat(a,'.') +a . +update t1 set a='abc ' where a like 'a '; +select concat(a,'.') from t1; +concat(a,'.') +a . +update t1 set a='a ' where a like 'a %'; +select concat(a,'.') from t1; +concat(a,'.') +a . +update t1 set a='a ' where a like 'a '; +select concat(a,'.') from t1; +concat(a,'.') +a . +drop table t1; +SET NAMES DEFAULT; +create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL, + `t` text, + KEY `v` (`v`(5)), + KEY `c` (`c`(5)), + KEY `t` (`t`(5)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v char(10) character set utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v varchar(10), c char(10)) row_format=fixed; +Warnings: +Warning 1478 InnoDB: assuming ROW_FORMAT=DYNAMIC. +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` varchar(10) DEFAULT NULL, + `c` char(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +insert into t1 values('a','a'),('a ','a '); +select concat('*',v,'*',c,'*') from t1; +concat('*',v,'*',c,'*') +*a*a* +*a *a* +drop table t1; +create table t1 (v varchar(65530), key(v(10))) charset latin1; +insert into t1 values(repeat('a',65530)); +select length(v) from t1 where v=repeat('a',65530); +length(v) +65530 +drop table t1; +create table t1(a int, b varchar(12), key ba(b, a)); +insert into t1 values (1, 'A'), (20, NULL); +explain select * from t1 where a=20 and b is null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref ba ba 56 const,const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 20) and (`test`.`t1`.`b` is null)) +select * from t1 where a=20 and b is null; +a b +20 NULL +drop table t1; +set session old_alter_table=0; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'; +Warnings: +Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. +create table t1 (v varchar(65530), key(v)) charset latin1 ROW_FORMAT=COMPACT; +Got one of the listed errors +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (v varchar(65536)); +Warnings: +Note 1246 Converting column 'v' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` mediumtext +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +create table t1 (v varchar(65530) character set utf8); +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Note 1246 Converting column 'v' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v` mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +SET sql_mode = default; +set default_storage_engine=MyISAM; +create table t1 (v varchar(16384)) charset latin1 engine=innodb; +drop table t1; +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +min(a) +4 +select min(b) from t1 where a='8'; +min(b) +6 +drop table t1; +CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 (b) values (1); +replace into t1 (b) values (2), (1), (3); +select * from t1; +a b +2 2 +3 1 +4 3 +truncate table t1; +insert into t1 (b) values (1); +replace into t1 (b) values (2); +replace into t1 (b) values (1); +replace into t1 (b) values (3); +select * from t1; +a b +2 2 +3 1 +4 3 +drop table t1; +create table t1 (rowid int not null auto_increment, val int not null,primary +key (rowid), unique(val)) engine=innodb; +replace into t1 (val) values ('1'),('2'); +replace into t1 (val) values ('1'),('2'); +insert into t1 (val) values ('1'),('2'); +ERROR 23000: Duplicate entry '1' for key 't1.val' +select * from t1; +rowid val +3 1 +4 2 +drop table t1; +create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB; +insert into t1 (val) values (1); +update t1 set a=2 where a=1; +insert into t1 (val) values (3); +select * from t1; +a val +2 1 +3 3 +insert into t1 values (2, 2); +ERROR 23000: Duplicate entry '2' for key 't1.PRIMARY' +select * from t1; +a val +2 1 +3 3 +drop table t1; +CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; +INSERT INTO t1 (GRADE) VALUES (151),(252),(343); +SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; +GRADE +252 +SELECT GRADE FROM t1 WHERE GRADE= 151; +GRADE +151 +DROP TABLE t1; +create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb; +create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb; +insert into t2 values ('aa','cc'); +insert into t1 values ('aa','bb'),('aa','cc'); +delete t1 from t1,t2 where f1=f3 and f4='cc'; +select * from t1; +f1 f2 +drop table t1,t2; +CREATE TABLE t1 ( +id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) +) ENGINE=InnoDB; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +id +1 +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +id +1 +DELETE FROM t1; +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +id +1 +DROP TABLE t1; +CREATE TABLE t1 +( +id INT PRIMARY KEY +) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 +( +id INT NOT NULL PRIMARY KEY, +b INT, +FOREIGN KEY (b) REFERENCES test.t1(id) +) ENGINE=InnoDB; +ERROR HY000: Cannot add foreign key constraint +DROP TABLE t1; +create table t1 (col1 varchar(2000), index (col1(767))) +character set = latin1 engine = innodb; +create table t2 (col1 char(255), index (col1)) +character set = latin1 engine = innodb; +create table t3 (col1 binary(255), index (col1)) +character set = latin1 engine = innodb; +create table t4 (col1 varchar(767), index (col1)) +character set = latin1 engine = innodb; +create table t5 (col1 varchar(767) primary key) +character set = latin1 engine = innodb; +create table t6 (col1 varbinary(767) primary key) +character set = latin1 engine = innodb; +create table t7 (col1 text, index(col1(767))) +character set = latin1 engine = innodb; +create table t8 (col1 blob, index(col1(767))) +character set = latin1 engine = innodb; +drop table t1, t2, t3, t4, t5, t6, t7, t8; +CREATE TABLE t1 +( +id INT PRIMARY KEY +) ENGINE=InnoDB; +CREATE TABLE t2 +( +v INT, +CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES(2); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`)) +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(1); +DELETE FROM t1 WHERE id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`)) +DROP TABLE t1; +ERROR HY000: Cannot drop table 't1' referenced by a foreign key constraint 'c1' on table 't2'. +SET FOREIGN_KEY_CHECKS=0; +DROP TABLE t1; +SET FOREIGN_KEY_CHECKS=1; +INSERT INTO t2 VALUES(3); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`)) +DROP TABLE t2; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into t1 values (1),(2); +set autocommit=0; +checksum table t1; +Table Checksum +test.t1 1531596814 +insert into t1 values(3); +checksum table t1; +Table Checksum +test.t1 1531596814 +commit; +checksum table t1; +Table Checksum +test.t1 2050879373 +commit; +drop table t1; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into t1 values (1),(2); +set autocommit=1; +checksum table t1; +Table Checksum +test.t1 1531596814 +set autocommit=1; +insert into t1 values(3); +checksum table t1; +Table Checksum +test.t1 2050879373 +drop table t1; +set foreign_key_checks=0; +create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb; +create table t1(a char(10) primary key, b varchar(20)) engine = innodb; +ERROR HY000: Referencing column 'b' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t2; +set foreign_key_checks=0; +create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8; +ERROR HY000: Referencing column 'a' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t1; +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb; +create table t1(a varchar(10) primary key) engine = innodb; +alter table t1 modify column a int; +ERROR HY000: Referencing column 'a' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t2,t1; +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1; +create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; +alter table t1 convert to character set utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +set foreign_key_checks=1; +drop table t2,t1; +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1; +create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +rename table t3 to t1; +ERROR HY000: Referencing column 'a' and referenced column 'a' in foreign key constraint 't2_ibfk_1' are incompatible. +set foreign_key_checks=1; +drop table t2,t3; +create table t1(a int primary key) row_format=redundant engine=innodb; +create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb; +create table t3(a int primary key) row_format=compact engine=innodb; +create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb; +insert into t1 values(1); +insert into t3 values(1); +insert into t2 values(2); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +insert into t4 values(2); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`)) +insert into t2 values(1); +insert into t4 values(1); +update t1 set a=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +update t2 set a=2; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) +update t3 set a=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`)) +update t4 set a=2; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`)) +truncate t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +truncate t3; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1`) +truncate t2; +truncate t4; +truncate t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +truncate t3; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1`) +drop table t4,t3,t2,t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb; +create table t2 (s1 binary(2),primary key (s1)) engine=innodb; +create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values (0x41),(0x4120),(0x4100); +insert into t2 values (0x41),(0x4120),(0x4100); +ERROR 23000: Duplicate entry 'A' for key 't2.PRIMARY' +insert into t2 values (0x41),(0x4120); +insert into t3 values (0x41),(0x4120),(0x4100); +ERROR 23000: Duplicate entry 'A ' for key 't3.PRIMARY' +insert into t3 values (0x41),(0x4100); +insert into t4 values (0x41),(0x4120),(0x4100); +ERROR 23000: Duplicate entry 'A' for key 't4.PRIMARY' +insert into t4 values (0x41),(0x4100); +select hex(s1) from t1; +hex(s1) +41 +4100 +4120 +select hex(s1) from t2; +hex(s1) +4100 +4120 +select hex(s1) from t3; +hex(s1) +4100 +41 +select hex(s1) from t4; +hex(s1) +4100 +41 +drop table t1,t2,t3,t4; +create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb; +create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb; +insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42); +insert into t2 values(0x42); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +insert into t2 values(0x41); +select hex(s1) from t2; +hex(s1) +4100 +update t1 set s1=0x123456 where a=2; +select hex(s1) from t2; +hex(s1) +4100 +update t1 set s1=0x12 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +update t1 set s1=0x12345678 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +update t1 set s1=0x123457 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +update t1 set s1=0x1220 where a=1; +select hex(s1) from t2; +hex(s1) +1220 +update t1 set s1=0x1200 where a=1; +select hex(s1) from t2; +hex(s1) +1200 +update t1 set s1=0x4200 where a=1; +select hex(s1) from t2; +hex(s1) +4200 +delete from t1 where a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +delete from t1 where a=2; +update t2 set s1=0x4120; +delete from t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +delete from t1 where a!=3; +select a,hex(s1) from t1; +a hex(s1) +3 4120 +select hex(s1) from t2; +hex(s1) +4120 +drop table t2,t1; +create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb; +Warnings: +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 values(1,0x4100),(2,0x41); +insert into t2 values(0x41); +select hex(s1) from t2; +hex(s1) +41 +update t1 set s1=0x1234 where a=1; +select hex(s1) from t2; +hex(s1) +41 +update t1 set s1=0x12 where a=2; +select hex(s1) from t2; +hex(s1) +12 +delete from t1 where a=1; +delete from t1 where a=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +select a,hex(s1) from t1; +a hex(s1) +2 12 +select hex(s1) from t2; +hex(s1) +12 +drop table t2,t1; +CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB; +CREATE TABLE t2(a INT) ENGINE=InnoDB; +ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a); +ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1; +ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a); +ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int DEFAULT NULL, + KEY `t2_ibfk_0` (`a`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2,t1; +SET sql_mode = default; +CREATE TABLE t1 ( +field1 varchar(8) NOT NULL DEFAULT '', +field2 varchar(8) NOT NULL DEFAULT '', +PRIMARY KEY (field1, field2) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, +FOREIGN KEY (field1) REFERENCES t1 (field1) +ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('old', 'somevalu'); +INSERT INTO t1 VALUES ('other', 'anyvalue'); +INSERT INTO t2 VALUES ('old'); +INSERT INTO t2 VALUES ('other'); +UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; +ERROR 23000: Foreign key constraint for table 't1', record 'other-somevalu' would lead to a duplicate entry in table 't2', key 'PRIMARY' +DROP TABLE t2; +DROP TABLE t1; +create table t1 ( +c1 bigint not null, +c2 bigint not null, +primary key (c1), +unique key (c2) +) engine=innodb; +create table t2 ( +c1 bigint not null, +primary key (c1) +) engine=innodb; +alter table t1 add constraint c2_fk foreign key (c2) +references t2(c1) on delete cascade; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + PRIMARY KEY (`c1`), + UNIQUE KEY `c2` (`c2`), + CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +alter table t1 drop foreign key c2_fk; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint NOT NULL, + `c2` bigint NOT NULL, + PRIMARY KEY (`c1`), + UNIQUE KEY `c2` (`c2`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1, t2; +create table t1(a date) engine=innodb; +create table t2(a date, key(a)) engine=innodb; +insert into t1 values('2005-10-01'); +insert into t2 values('2005-10-01'); +select * from t1, t2 +where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; +a a +2005-10-01 2005-10-01 +drop table t1, t2; +create table t1 (id int not null, f_id int not null, f int not null, +primary key(f_id, id)) engine=innodb; +create table t2 (id int not null,s_id int not null,s varchar(200), +primary key(id)) engine=innodb; +INSERT INTO t1 VALUES (8, 1, 3); +INSERT INTO t1 VALUES (1, 2, 1); +INSERT INTO t2 VALUES (1, 0, ''); +INSERT INTO t2 VALUES (8, 1, ''); +commit; +DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id) +WHERE mm.id IS NULL; +select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id) +where mm.id is null lock in share mode; +id f_id f +drop table t1,t2; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3); +commit; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +update t1 set b = 5 where b = 1; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +select * from t1 where a = 7 and b = 3 for update; +a b +7 3 +commit; +commit; +drop table t1; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); +commit; +set autocommit = 0; +select * from t1 lock in share mode; +a b +1 1 +2 2 +3 1 +4 2 +5 1 +6 2 +update t1 set b = 5 where b = 1; +set autocommit = 0; +select * from t1 where a = 2 and b = 2 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +commit; +commit; +drop table t1; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values (1,2),(5,3),(4,2); +create table t2(d int not null, e int, primary key(d)) engine=innodb; +insert into t2 values (8,6),(12,1),(3,1); +commit; +set autocommit = 0; +select * from t2 for update; +d e +3 1 +8 6 +12 1 +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +insert into t1 select * from t2; +update t1 set b = (select e from t2 where a = d); +create table t3(d int not null, e int, primary key(d)) engine=innodb +select * from t2; +commit; +commit; +drop table t1, t2, t3; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values (1,2),(5,3),(4,2); +create table t2(a int not null, b int, primary key(a)) engine=innodb; +insert into t2 values (8,6),(12,1),(3,1); +create table t3(d int not null, b int, primary key(d)) engine=innodb; +insert into t3 values (8,6),(12,1),(3,1); +create table t5(a int not null, b int, primary key(a)) engine=innodb; +insert into t5 values (1,2),(5,3),(4,2); +create table t6(d int not null, e int, primary key(d)) engine=innodb; +insert into t6 values (8,6),(12,1),(3,1); +create table t8(a int not null, b int, primary key(a)) engine=innodb; +insert into t8 values (1,2),(5,3),(4,2); +create table t9(d int not null, e int, primary key(d)) engine=innodb; +insert into t9 values (8,6),(12,1),(3,1); +commit; +set autocommit = 0; +select * from t2 for update; +a b +3 1 +8 6 +12 1 +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +insert into t1 select * from t2; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +update t3 set b = (select b from t2 where a = d); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +insert into t5 (select * from t2 lock in share mode); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +update t6 set e = (select b from t2 where a = d lock in share mode); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +insert into t8 (select * from t2 for update); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +update t9 set e = (select b from t2 where a = d for update); +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +ERROR HY000: Can't update table 't2' while 't10' is being created. +commit; +drop table t1, t2, t3, t5, t6, t8, t9; +CREATE TABLE t1 (DB_ROW_ID int) engine=innodb; +ERROR 42000: Incorrect column name 'DB_ROW_ID' +CREATE TABLE t1 ( +a BIGINT(20) NOT NULL, +PRIMARY KEY (a) +) ENGINE=INNODB DEFAULT CHARSET=UTF8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +a BIGINT(20) NOT NULL, +b VARCHAR(128) NOT NULL, +c TEXT NOT NULL, +PRIMARY KEY (a,b), +KEY idx_t2_b_c (b,c(100)), +CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) +ON DELETE CASCADE +) ENGINE=INNODB DEFAULT CHARSET=UTF8; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1, 'bar', 'vbar'); +INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR'); +INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi'); +INSERT INTO t2 VALUES (1, 'customer_over', '1'); +SELECT * FROM t2 WHERE b = 'customer_over'; +a b c +1 customer_over 1 +SELECT * FROM t2 WHERE BINARY b = 'customer_over'; +a b c +1 customer_over 1 +SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over'; +a +1 +/* Bang: Empty result set, above was expected: */ +SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; +a +1 +SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; +a +1 +drop table t2, t1; +CREATE TABLE t1 ( a int ) ENGINE=innodb; +BEGIN; +INSERT INTO t1 VALUES (1); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; +CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL, +CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id) +ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB; +ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON +DELETE CASCADE ON UPDATE CASCADE; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int NOT NULL, + `f` int NOT NULL, + PRIMARY KEY (`id`), + KEY `f` (`f`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2, t1; +CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB; +CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL; +ALTER TABLE t2 MODIFY a INT NOT NULL; +ERROR HY000: Column 'a' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +DELETE FROM t1; +DROP TABLE t2,t1; +CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY) +ENGINE=InnoDB; +Warnings: +Warning 3778 'utf8_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead. +INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4); +DELETE FROM t1; +INSERT INTO t1 VALUES ('DDD'); +SELECT * FROM t1; +a +DDD +DROP TABLE t1; +CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB +AUTO_INCREMENT=42; +INSERT INTO t1 VALUES (0),(347),(0); +SELECT * FROM t1; +id +42 +347 +348 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 VALUES(42),(347),(348); +ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`) +) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1,t2; +SET innodb_strict_mode=ON; +CREATE TABLE t1 ( +c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255), +c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255), +c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255), +c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255), +c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255), +c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255), +c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255), +c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255) +) charset latin1 ENGINE = InnoDB; +ERROR 42000: Row size too large (> {checked_valid}). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline. +SET innodb_strict_mode=OFF; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1( +id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES(-10); +SELECT * FROM t1; +id +-10 +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +id +-10 +1 +DROP TABLE t1; +create table t1 (i int, j int) engine=innodb; +insert into t1 (i, j) values (1, 1), (2, 2); +update t1 set j = 2; +affected rows: 1 +info: Rows matched: 2 Changed: 1 Warnings: 0 +drop table t1; +create table t1 (id int) comment='this is a comment' engine=innodb; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select table_comment, data_free > 0 as data_free_is_set +from information_schema.tables +where table_schema='test' and table_name = 't1'; +TABLE_COMMENT data_free_is_set +this is a comment 1 +drop table t1; +CREATE TABLE t1 ( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +c2 VARCHAR(128) NOT NULL, +PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t2 ( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +c2 INT(10) UNSIGNED DEFAULT NULL, +PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +AUTO_INCREMENT +200 +ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1); +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +AUTO_INCREMENT +200 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (c1 int default NULL, +c2 int default NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +TRUNCATE TABLE t1; +affected rows: 0 +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +TRUNCATE TABLE t1; +affected rows: 0 +DROP TABLE t1; +Variable_name Value +Handler_update 10 +Variable_name Value +Handler_delete 0 +Variable_name Value +Handler_update 11 +Variable_name Value +Handler_delete 1 +DROP TABLE bug58912; +create table t1 (f1 integer primary key) engine=innodb; +flush status; +show status like "handler_read_key"; +Variable_name Value +Handler_read_key 0 +select f1 from t1; +f1 +show status like "handler_read_key"; +Variable_name Value +Handler_read_key 1 +drop table t1; +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 (c1 INT) ENGINE=InnoDB; +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(0); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ROLLBACK; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 +START TRANSACTION READ ONLY; +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +INSERT INTO t2 VALUES(1); +COMMIT; +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +COMMIT; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 +1 +3 +DROP TABLE t2; +CREATE TEMPORARY TABLE t2 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, INDEX idx(c2)) ENGINE=InnoDB; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `c1` int NOT NULL AUTO_INCREMENT, + `c2` int DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `idx` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ROLLBACK; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 c2 +START TRANSACTION READ ONLY; +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +COMMIT; +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +COMMIT; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `c1` int NOT NULL AUTO_INCREMENT, + `c2` int DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `idx` (`c2`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 c2 +4 1 +5 2 +6 3 +7 1 +8 2 +9 3 +DROP TABLE t1; +DROP TABLE t2; +count_alloc WHERE event_name like 'memory/innodb/other' +count_alloc +0 +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; +create table t1 (col1 integer primary key, col2 integer) engine=innodb; +insert t1 values (1,100); +create function f1 () returns integer begin +declare var1 int; +select col2 into var1 from t1 where col1=1 for update; +return var1; +end| +start transaction; +select f1(); +f1() +100 +update t1 set col2=0 where col1=1; +select * from t1; +col1 col2 +1 100 +rollback; +rollback; +drop table t1; +drop function f1; +SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; diff --git a/mysql-test/suite/innodb/r/innodb_autoinc_lock_mode_zero.result-pq b/mysql-test/suite/innodb/r/innodb_autoinc_lock_mode_zero.result-pq new file mode 100644 index 000000000..572d6ed8c --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_autoinc_lock_mode_zero.result-pq @@ -0,0 +1,43 @@ +drop table if exists t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +ggid varchar(32) binary DEFAULT '' NOT NULL, +email varchar(64) DEFAULT '' NOT NULL, +passwd varchar(32) binary DEFAULT '' NOT NULL, +PRIMARY KEY (id), +UNIQUE ggid (ggid) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +Warning 1287 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead +insert into t1 (ggid,passwd) values ('test1','xxx'); +insert into t1 (ggid,passwd) values ('test2','yyy'); +insert into t1 (ggid,passwd) values ('test2','this will fail'); +ERROR 23000: Duplicate entry 'test2' for key 't1.ggid' +insert into t1 (ggid,id) values ('this will fail',1); +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +select * from t1 where ggid='test1'; +id ggid email passwd +1 test1 xxx +select * from t1 where passwd='xxx'; +id ggid email passwd +1 test1 xxx +select * from t1 where id=2; +id ggid email passwd +2 test2 yyy +replace into t1 (ggid,id) values ('this will work',1); +replace into t1 (ggid,passwd) values ('test2','this will work'); +update t1 set id=100,ggid='test2' where id=1; +ERROR 23000: Duplicate entry 'test2' for key 't1.ggid' +select * from t1; +id ggid email passwd +1 this will work +4 test2 this will work +select * from t1 where id=1; +id ggid email passwd +1 this will work +select * from t1 where id=999; +id ggid email passwd +drop table t1; +End of tests diff --git a/mysql-test/suite/innodb/r/innodb_bug30423.result-pq b/mysql-test/suite/innodb/r/innodb_bug30423.result-pq new file mode 100644 index 000000000..7144f9daa --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug30423.result-pq @@ -0,0 +1,103 @@ +set global innodb_stats_method = default; +select @@innodb_stats_method; +@@innodb_stats_method +nulls_equal +select count(*) from bug30243_3 where org_id is not NULL; +count(*) +20 +select count(*) from bug30243_3 where org_id is NULL; +count(*) +16384 +select count(*) from bug30243_2 where org_id is not NULL; +count(*) +224 +select count(*) from bug30243_2 where org_id is NULL; +count(*) +65536 +select @@innodb_stats_method; +@@innodb_stats_method +nulls_equal +analyze table bug30243_1; +Table Op Msg_type Msg_text +test.bug30243_1 analyze status OK +analyze table bug30243_2; +Table Op Msg_type Msg_text +test.bug30243_2 analyze status OK +analyze table bug30243_3; +Table Op Msg_type Msg_text +test.bug30243_3 analyze status OK +set global innodb_stats_method = "NULL"; +ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of 'NULL' +set global innodb_stats_method = "nulls_ignored"; +select @@innodb_stats_method; +@@innodb_stats_method +nulls_ignored +analyze table bug30243_1; +Table Op Msg_type Msg_text +test.bug30243_1 analyze status OK +analyze table bug30243_2; +Table Op Msg_type Msg_text +test.bug30243_2 analyze status OK +analyze table bug30243_3; +Table Op Msg_type Msg_text +test.bug30243_3 analyze status OK +explain SELECT COUNT(*), 0 +FROM bug30243_1 orgs +LEFT JOIN bug30243_3 sa_opportunities +ON orgs.org_id=sa_opportunities.org_id +LEFT JOIN bug30243_2 contacts +ON orgs.org_id=contacts.org_id ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (1 workers) +2 SIMPLE orgs NULL index NULL org_id 4 NULL ROWS 100.00 Using index +2 SIMPLE sa_opportunities NULL ref org_id org_id 5 test.orgs.org_id ROWS 100.00 Using index +2 SIMPLE contacts NULL ref contacts$org_id contacts$org_id 5 test.orgs.org_id ROWS 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)`,0 AS `0` from `test`.`bug30243_1` `orgs` left join `test`.`bug30243_3` `sa_opportunities` on((`test`.`sa_opportunities`.`org_id` = `test`.`orgs`.`org_id`)) left join `test`.`bug30243_2` `contacts` on((`test`.`contacts`.`org_id` = `test`.`orgs`.`org_id`)) where true +select @@innodb_stats_method; +@@innodb_stats_method +nulls_ignored +set global innodb_stats_method = "nulls_unequal"; +select @@innodb_stats_method; +@@innodb_stats_method +nulls_unequal +analyze table bug30243_1; +Table Op Msg_type Msg_text +test.bug30243_1 analyze status OK +analyze table bug30243_2; +Table Op Msg_type Msg_text +test.bug30243_2 analyze status OK +analyze table bug30243_3; +Table Op Msg_type Msg_text +test.bug30243_3 analyze status OK +explain SELECT COUNT(*), 0 +FROM bug30243_1 orgs +LEFT JOIN bug30243_3 sa_opportunities +ON orgs.org_id=sa_opportunities.org_id +LEFT JOIN bug30243_2 contacts +ON orgs.org_id=contacts.org_id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL ROWS 100.00 Parallel execute (1 workers) +2 SIMPLE orgs NULL index NULL org_id 4 NULL ROWS 100.00 Using index +2 SIMPLE sa_opportunities NULL ref org_id org_id 5 test.orgs.org_id ROWS 100.00 Using index +2 SIMPLE contacts NULL ref contacts$org_id contacts$org_id 5 test.orgs.org_id ROWS 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)`,0 AS `0` from `test`.`bug30243_1` `orgs` left join `test`.`bug30243_3` `sa_opportunities` on((`test`.`sa_opportunities`.`org_id` = `test`.`orgs`.`org_id`)) left join `test`.`bug30243_2` `contacts` on((`test`.`contacts`.`org_id` = `test`.`orgs`.`org_id`)) where true +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT COUNT(*) FROM table_bug30423 WHERE org_id IS NULL; +COUNT(*) +1024 +set global innodb_stats_method = "nulls_unequal"; +analyze table table_bug30423; +Table Op Msg_type Msg_text +test.table_bug30423 analyze status OK +set global innodb_stats_method = "nulls_ignored"; +analyze table table_bug30423; +Table Op Msg_type Msg_text +test.table_bug30423 analyze status OK +set global innodb_stats_method = nulls_equal; +drop table bug30243_2; +drop table bug30243_1; +drop table bug30243_3; +drop table table_bug30423; diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index.result-pq b/mysql-test/suite/innodb/r/innodb_bulk_create_index.result-pq new file mode 100644 index 000000000..b5b318fdb --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index.result-pq @@ -0,0 +1,1073 @@ +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +SET GLOBAL innodb_file_per_table=1; +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b BLOB, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=default; +DROP PROCEDURE populate_t1; +SET GLOBAL innodb_fill_factor=10; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +10 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +SET GLOBAL innodb_fill_factor=50; +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 10000) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +50 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +5000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 4010 AND id > 3990; +INSERT INTO t1 VALUES(4000, 4000, 'b4000'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 3010 AND id > 2990; +SELECT * FROM t1 WHERE id = 3000; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE title = 'a3000'; +class id title +SELECT * FROM t1 WHERE title = 'b3000'; +class id title +3000 3000 b3000 +SELECT * FROM t1 WHERE id = 4000; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE title = 'a4000'; +class id title +SELECT * FROM t1 WHERE title = 'b4000'; +class id title +4000 4000 b4000 +SELECT * FROM t1 WHERE id = 4001; +class id title +SELECT * FROM t1 WHERE title = 'a4001'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +9992 +/* Add column. */ +ALTER TABLE t1 ADD COLUMN content TEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE title = 'a10'; +class id title content +10 10 a10 NULL +SELECT * FROM t1 WHERE id = 5000; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE title = 'a5000'; +class id title content +5000 5000 a5000 NULL +SELECT * FROM t1 WHERE id = 10000; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE title = 'a10000'; +class id title content +10000 10000 a10000 NULL +SELECT * FROM t1 WHERE id = 10010; +class id title content +SELECT * FROM t1 WHERE title = 'a10010'; +class id title content +/* Drop column. */ +ALTER TABLE t1 DROP COLUMN content; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 5000; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE title = 'a5000'; +class id title +5000 5000 a5000 +SELECT * FROM t1 WHERE id = 10000; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE title = 'a10000'; +class id title +10000 10000 a10000 +SELECT * FROM t1 WHERE id = 10010; +class id title +SELECT * FROM t1 WHERE title = 'a10010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +ALTER TABLE t1 ADD INDEX `idx` (a,b(5)); +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +10000 +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +1 +UPDATE t1 SET b = REPEAT(CONCAT('b',4975),2000) WHERE a=4975 AND b like 'a4975%'; +SELECT b=REPEAT(CONCAT('a',4975),2000) FROM t1 WHERE a=4975 AND b like 'a4975%'; +b=REPEAT(CONCAT('a',4975),2000) +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +1 +DELETE FROM t1 WHERE a=4975 AND b like 'b4975%'; +SELECT b=REPEAT(CONCAT('b',4975),2000) FROM t1 WHERE a=4975 AND b like 'b4975%'; +b=REPEAT(CONCAT('b',4975),2000) +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +DROP PROCEDURE populate_t1; +SET GLOBAL innodb_fill_factor=default; diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result-pq b/mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result-pq new file mode 100644 index 000000000..b5c4242f3 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_replication.result-pq @@ -0,0 +1,228 @@ +include/master-slave.inc +Warnings: +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. +[connection master] +CREATE PROCEDURE populate_t1(load_even INT) +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 100) DO +IF i%2 = 0 AND load_even = 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +IF i%2 != 0 AND load_even != 1 THEN +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +END IF; +SET i = i + 1; +END WHILE; +COMMIT; +END| +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) charset latin1 ENGINE=InnoDB ; +SELECT COUNT(*) FROM t1; +COUNT(*) +50 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 103 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t1 WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t1 WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t1 WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +/*Insert/Update/Delete. */ +DELETE FROM t1 WHERE id < 40 AND id > 30; +INSERT INTO t1 VALUES(38, 38, 'b38'); +UPDATE t1 SET title = CONCAT('b', id) WHERE id < 30 AND id > 20; +SELECT * FROM t1 WHERE id = 28; +class id title +28 28 b28 +SELECT * FROM t1 WHERE title = 'a28'; +class id title +SELECT * FROM t1 WHERE title = 'b28'; +class id title +28 28 b28 +SELECT * FROM t1 WHERE id = 38; +class id title +38 38 b38 +SELECT * FROM t1 WHERE title = 'a38'; +class id title +SELECT * FROM t1 WHERE title = 'b38'; +class id title +38 38 b38 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +SELECT COUNT(*) FROM t1; +COUNT(*) +97 +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t1 WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t1 WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t1 WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +CREATE TABLE t_part ( +class INT , +id INT , +title VARCHAR(30) +) charset latin1 ENGINE=InnoDB +PARTITION BY RANGE(id) +SUBPARTITION BY KEY(id) +SUBPARTITIONS 4 +( +PARTITION p0 VALUES LESS THAN (5000), +PARTITION p1 VALUES LESS THAN (MAXVALUE) +); +INSERT INTO t_part SELECT * FROM t1; +ALTER TABLE t_part ADD INDEX `idx` (class,id,title(10)); +SELECT * FROM t_part WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t_part WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t_part WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t_part WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t_part WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t_part WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t_part WHERE id = 101; +class id title +SELECT * FROM t_part WHERE title = 'a101'; +class id title +include/sync_slave_sql_with_master.inc +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `class` int DEFAULT NULL, + `id` int DEFAULT NULL, + `title` varchar(100) DEFAULT NULL, + KEY `idx_id` (`id`), + KEY `idx_title` (`title`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t_part; +Table Create Table +t_part CREATE TABLE `t_part` ( + `class` int DEFAULT NULL, + `id` int DEFAULT NULL, + `title` varchar(30) DEFAULT NULL, + KEY `idx` (`class`,`id`,`title`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (`id`) +SUBPARTITION BY KEY (id) +SUBPARTITIONS 4 +(PARTITION p0 VALUES LESS THAN (5000) ENGINE = InnoDB, + PARTITION p1 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ +SELECT COUNT(*) FROM t1; +COUNT(*) +97 +SELECT COUNT(*) FROM t_part; +COUNT(*) +97 +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t1 WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t1 WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t1 WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t1 WHERE id = 101; +class id title +SELECT * FROM t1 WHERE title = 'a101'; +class id title +SELECT * FROM t_part WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t_part WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t_part WHERE id = 20; +class id title +20 20 a20 +SELECT * FROM t_part WHERE title = 'a20'; +class id title +20 20 a20 +SELECT * FROM t_part WHERE id = 30; +class id title +30 30 a30 +SELECT * FROM t_part WHERE title = 'a30'; +class id title +30 30 a30 +SELECT * FROM t_part WHERE id = 101; +class id title +SELECT * FROM t_part WHERE title = 'a101'; +class id title +DROP PROCEDURE populate_t1; +DROP TABLE t1; +DROP TABLE t_part; +include/rpl_end.inc diff --git a/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result-pq b/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result-pq new file mode 100644 index 000000000..9f50903dd --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bulk_create_index_small.result-pq @@ -0,0 +1,151 @@ +CREATE PROCEDURE populate_t1() +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 1000) DO +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +SET i = i + 1; +END WHILE; +COMMIT; +END| +SELECT @@innodb_fill_factor; +@@innodb_fill_factor +100 +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPACT; +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 500; +class id title +500 500 a500 +SELECT * FROM t1 WHERE title = 'a500'; +class id title +500 500 a500 +SELECT * FROM t1 WHERE id = 1000; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE title = 'a1000'; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE id = 1010; +class id title +SELECT * FROM t1 WHERE title = 'a1010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES +(1, REPEAT('a',10000), 'a'), +(2, REPEAT('b',20000), 'b'), +(3, REPEAT('c',40000), 'c'), +(4, REPEAT('d',60000), 'd'); +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=default; +SET GLOBAL innodb_file_per_table=1; +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +/* Create index. */ +CREATE INDEX idx_id ON t1(id); +CREATE INDEX idx_title ON t1(title); +/* Check table. */ +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +/* Select by index. */ +EXPLAIN SELECT * FROM t1 WHERE id = 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_id idx_id 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`id` = 10) +EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref idx_title idx_title 403 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`class` AS `class`,`test`.`t1`.`id` AS `id`,`test`.`t1`.`title` AS `title` from `test`.`t1` where (`test`.`t1`.`title` = 'a10') +SELECT * FROM t1 WHERE id = 10; +class id title +10 10 a10 +SELECT * FROM t1 WHERE title = 'a10'; +class id title +10 10 a10 +SELECT * FROM t1 WHERE id = 500; +class id title +500 500 a500 +SELECT * FROM t1 WHERE title = 'a500'; +class id title +500 500 a500 +SELECT * FROM t1 WHERE id = 1000; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE title = 'a1000'; +class id title +1000 1000 a1000 +SELECT * FROM t1 WHERE id = 1010; +class id title +SELECT * FROM t1 WHERE title = 'a1010'; +class id title +DROP TABLE t1; +CREATE TABLE t1( +a INT PRIMARY KEY, +b TEXT, +c TEXT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; +INSERT INTO t1 VALUES +(1, REPEAT('a',10000), 'a'), +(2, REPEAT('b',20000), 'b'), +(3, REPEAT('c',40000), 'c'), +(4, REPEAT('d',60000), 'd'); +ALTER TABLE t1 DROP COLUMN c; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT CHAR_LENGTH(b) FROM t1 WHERE a=4975; +CHAR_LENGTH(b) +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=default; +DROP PROCEDURE populate_t1; diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result-pq b/mysql-test/suite/innodb/r/innodb_mysql.result-pq new file mode 100644 index 000000000..52ec4f692 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_mysql.result-pq @@ -0,0 +1,3491 @@ +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_TMP_STORAGE_ENGINE = InnoDB; +drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4; +drop procedure if exists p1; +create table t1 ( +c_id int(11) not null default '0', +org_id int(11) default null, +unique key contacts$c_id (c_id), +key contacts$org_id (org_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t1 values +(2,null),(120,null),(141,null),(218,7), (128,1), +(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3), +(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4); +create table t2 ( +slai_id int(11) not null default '0', +owner_tbl int(11) default null, +owner_id int(11) default null, +sla_id int(11) default null, +inc_web int(11) default null, +inc_email int(11) default null, +inc_chat int(11) default null, +inc_csr int(11) default null, +inc_total int(11) default null, +time_billed int(11) default null, +activedate timestamp null default null, +expiredate timestamp null default null, +state int(11) default null, +sla_set int(11) default null, +unique key t2$slai_id (slai_id), +key t2$owner_id (owner_id), +key t2$sla_id (sla_id) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2(slai_id, owner_tbl, owner_id, sla_id) values +(1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7), +(8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12); +flush tables; +select si.slai_id +from t1 c join t2 si on +((si.owner_tbl = 3 and si.owner_id = c.org_id) or +( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where +c.c_id = 218 and expiredate is null; +slai_id +12 +select * from t1 where org_id is null; +c_id org_id +2 NULL +120 NULL +141 NULL +select si.slai_id +from t1 c join t2 si on +((si.owner_tbl = 3 and si.owner_id = c.org_id) or +( si.owner_tbl = 2 and si.owner_id = c.c_id)) +where +c.c_id = 218 and expiredate is null; +slai_id +12 +drop table t1, t2; +CREATE TABLE t1 (a int, b int, KEY b (b)); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b)); +CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a), +UNIQUE KEY b (b,c), KEY a (a,b,c)); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 SELECT a + 1, b + 1 FROM t1; +INSERT INTO t1 SELECT a + 2, b + 2 FROM t1; +INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8); +INSERT INTO t2 SELECT a + 1, b FROM t2; +DELETE FROM t2 WHERE a = 1 AND b < 2; +INSERT INTO t3 VALUES (1,1,1),(2,1,2); +INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3; +INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3; +SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE +t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2) +ORDER BY t1.b LIMIT 2; +b a +1 1 +2 2 +SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE +t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2) +ORDER BY t1.b LIMIT 5; +b a +1 1 +2 2 +2 2 +3 3 +3 3 +DROP TABLE t1, t2, t3; +CREATE TABLE `t1` (`id1` INT) ; +INSERT INTO `t1` (`id1`) VALUES (1),(5),(2); +CREATE TABLE `t2` ( +`id1` INT, +`id2` INT NOT NULL, +`id3` INT, +`id4` INT NOT NULL, +UNIQUE (`id2`,`id4`), +KEY (`id1`) +); +INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES +(1,1,1,0), +(1,1,2,1), +(5,1,2,2), +(6,1,2,3), +(1,2,2,2), +(1,2,1,1); +SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2); +id1 +2 +DROP TABLE t1, t2; +create table t1 (c1 int) engine=innodb; +handler t1 open; +handler t1 read first; +c1 +Before and after comparison +0 +drop table t1; +CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1) +ENGINE=INNODB CHARACTER SET UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 (c1) VALUES ('1a'); +SELECT * FROM t1; +c1 cnt +1a 1 +INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +c1 cnt +1a 2 +DROP TABLE t1; +CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1) +ENGINE=INNODB CHARACTER SET UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 (c1) VALUES ('1a'); +SELECT * FROM t1; +c1 cnt +1a 1 +INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +c1 cnt +1a 2 +DROP TABLE t1; +CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1) +ENGINE=INNODB CHARACTER SET UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 (c1) VALUES ('1a'); +SELECT * FROM t1; +c1 cnt +1a 1 +INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; +SELECT * FROM t1; +c1 cnt +1a 2 +DROP TABLE t1; +CREATE TABLE t1 ( +a1 decimal(10,0) DEFAULT NULL, +a2 blob, +a3 time DEFAULT NULL, +a4 blob, +a5 char(175) DEFAULT NULL, +a6 timestamp NOT NULL DEFAULT '2000-01-01 01:01:01', +a7 tinyblob, +INDEX idx (a6,a7(239),a5) +) charset latin1 ENGINE=InnoDB; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a4 FROM t1 WHERE +a6=NULL AND +a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a4` AS `a4` from `test`.`t1` where (multiple equal(NULL, `test`.`t1`.`a6`) and multiple equal('UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS', `test`.`t1`.`a4`)) +EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE +t.a6=t.a6 AND t1.a6=NULL AND +t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a4` AS `a4` from `test`.`t1` join `test`.`t1` `t` where (multiple equal(NULL, `test`.`t1`.`a6`) and multiple equal('UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS', `test`.`t1`.`a4`)) +DROP TABLE t1; +create table t1m (a int) engine = MEMORY; +create table t1i (a int); +create table t2m (a int) engine = MEMORY; +create table t2i (a int); +insert into t2m values (5); +insert into t2i values (5); +select min(a) from t1i; +min(a) +NULL +select min(7) from t1i; +min(7) +NULL +select min(7) from DUAL; +min(7) +7 +explain select min(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select min(7) AS `min(7)` from `test`.`t2i` join `test`.`t1i` +select min(7) from t2i join t1i; +min(7) +NULL +select max(a) from t1i; +max(a) +NULL +select max(7) from t1i; +max(7) +NULL +select max(7) from DUAL; +max(7) +7 +explain select max(7) from t2i join t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select max(7) AS `max(7)` from `test`.`t2i` join `test`.`t1i` +select max(7) from t2i join t1i; +max(7) +NULL +select 1, min(a) from t1i where a=99; +1 min(a) +1 NULL +select 1, min(a) from t1i where 1=99; +1 min(a) +1 NULL +select 1, min(1) from t1i where a=99; +1 min(1) +1 NULL +select 1, min(1) from t1i where 1=99; +1 min(1) +1 NULL +select 1, max(a) from t1i where a=99; +1 max(a) +1 NULL +select 1, max(a) from t1i where 1=99; +1 max(a) +1 NULL +select 1, max(1) from t1i where a=99; +1 max(1) +1 NULL +select 1, max(1) from t1i where 1=99; +1 max(1) +1 NULL +explain select count(*), min(7), max(7) from t1m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t1i` +select count(*), min(7), max(7) from t1m, t1i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t1m, t2i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1m` join `test`.`t2i` +select count(*), min(7), max(7) from t1m, t2i; +count(*) min(7) max(7) +0 NULL NULL +explain select count(*), min(7), max(7) from t2m, t1i; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2m NULL system NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE t1i NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)`,min(7) AS `min(7)`,max(7) AS `max(7)` from `test`.`t1i` +select count(*), min(7), max(7) from t2m, t1i; +count(*) min(7) max(7) +0 NULL NULL +drop table t1m, t1i, t2m, t2i; +create table t1 ( +a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +) ENGINE = MEMORY; +insert into t1 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +create table t4 ( +pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +); +insert into t4 (a1, a2, b, c, d, dummy) select * from t1; +create index idx12672_0 on t4 (a1); +create index idx12672_1 on t4 (a1,a2,b,c); +create index idx12672_2 on t4 (a1,a2,b); +analyze table t4; +Table Op Msg_type Msg_text +test.t4 analyze status OK +select distinct a1 from t4 where pk_col not in (1,2,3,4); +a1 +a +b +c +d +drop table t1,t4; +DROP TABLE IF EXISTS t2, t1; +CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB; +CREATE TABLE t2 ( +i INT NOT NULL, +FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION +) ENGINE= InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +DELETE IGNORE FROM t1 WHERE i = 1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`)) +SELECT * FROM t1, t2; +i i +1 1 +DROP TABLE t2, t1; +End of 4.1 tests. +create table t1 ( +a varchar(30), b varchar(30), primary key(a), key(b) +); +select distinct a from t1; +a +drop table t1; +create table t1(a int, key(a)); +insert into t1 values(1); +select a, count(a) from t1 group by a with rollup; +a count(a) +1 1 +NULL 1 +drop table t1; +create table t1 (f1 int, f2 char(1), primary key(f1,f2)) stats_persistent=0; +insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); +alter table t1 drop primary key, add primary key (f2, f1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select distinct f1 a, f1 b from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index; Using temporary +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `a`,`test`.`t1`.`f1` AS `b` from `test`.`t1` +explain select distinct f1, f2 from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index PRIMARY PRIMARY 8 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` +drop table t1; +CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20), +INDEX (name)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11)); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +ALTER TABLE t2 ADD FOREIGN KEY (fkey) REFERENCES t2(id); +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id +WHERE t1.name LIKE 'A%' OR FALSE; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,name name 83 NULL 2 100.00 Using where; Using index +2 SIMPLE t2 NULL ref fkey fkey 5 test.t1.id 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`fkey` = `test`.`t1`.`id`) and (`test`.`t1`.`name` like 'A%')) +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int NOT NULL, +name varchar(20) NOT NULL, +dept varchar(20) NOT NULL, +age tinyint(3) unsigned NOT NULL, +PRIMARY KEY (id), +INDEX (name,dept) +) ENGINE=InnoDB STATS_PERSISTENT=0; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1(id, dept, age, name) VALUES +(3987, 'cs1', 10, 'rs1'), (3988, 'cs2', 20, 'rs1'), (3995, 'cs3', 10, 'rs2'), +(3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'), +(4011, 'cs7', 10, 'rs4'), (4012, 'cs8', 20, 'rs4'), (4019, 'cs9', 10, 'rs5'), +(4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746). +EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref name name 82 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`name` AS `name`,`test`.`t1`.`dept` AS `dept` from `test`.`t1` where (`test`.`t1`.`name` = 'rs5') +SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +name dept +rs5 cs10 +rs5 cs9 +DELETE FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +# Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746). +EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref name name 82 const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`name` AS `name`,`test`.`t1`.`dept` AS `dept` from `test`.`t1` where (`test`.`t1`.`name` = 'rs5') +SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; +name dept +DROP TABLE t1; +drop table if exists t1; +show variables like 'innodb_rollback_on_timeout'; +Variable_name Value +innodb_rollback_on_timeout OFF +create table t1 (a int unsigned not null primary key) engine = innodb; +insert into t1 values (1); +commit; +begin work; +insert into t1 values (2); +select * from t1; +a +1 +2 +begin work; +insert into t1 values (5); +select * from t1; +a +1 +5 +insert into t1 values (2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +select * from t1; +a +1 +5 +commit; +select * from t1; +a +1 +2 +commit; +select * from t1; +a +1 +2 +5 +drop table t1; +End of 5.0 tests +# +# Bug#23753319: !M_THD->TRANSACTION_ROLLBACK_REQUEST' AT +# THD::ATTACHABLE_TRX::INIT IN SQL/SQL_C +# +create table t1 (i int); +insert into t1 values (42); +# Grab locks which will block another con from doing select in RR +BEGIN; +select * from t1 for update; +i +42 +# Create competing connection using RR +BEGIN; +set session transaction isolation level repeatable read; +# Will fail and request rollback due to blocking for update +# (prior to fix this would trigger the assert). +create table t2 as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Additional coverage for WL#7743 "New data dictionary: changes +# to DDL-related parts of SE API". Check how rollback is handled +# by similar CTS for non-transactional table. +BEGIN; +create table t2 engine=myisam as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Cleanup +COMMIT; +drop table t1; +create table t1( +id int auto_increment, +c char(1) not null, +counter int not null default 1, +primary key (id), +unique key (c) +) engine=innodb; +insert into t1 (id, c) values +(NULL, 'a'), +(NULL, 'a') +on duplicate key update id = values(id), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +2 a 2 +insert into t1 (id, c) values +(NULL, 'b') +on duplicate key update id = values(id), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +2 a 2 +3 b 1 +truncate table t1; +insert into t1 (id, c) values (NULL, 'a'); +select * from t1; +id c counter +1 a 1 +insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b') +on duplicate key update id = values(id), c = values(c), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +1 a 1 +3 b 2 +insert into t1 (id, c) values (NULL, 'a') +on duplicate key update id = values(id), c = values(c), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +select * from t1; +id c counter +3 b 2 +4 a 2 +drop table t1; +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1( +id int AUTO_INCREMENT PRIMARY KEY, +stat_id int NOT NULL, +acct_id int DEFAULT NULL, +INDEX idx1 (stat_id, acct_id), +INDEX idx2 (acct_id) +) ENGINE=MyISAM; +CREATE TABLE t2( +id int AUTO_INCREMENT PRIMARY KEY, +stat_id int NOT NULL, +acct_id int DEFAULT NULL, +INDEX idx1 (stat_id, acct_id), +INDEX idx2 (acct_id) +) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1(stat_id,acct_id) VALUES +(1,759), (2,831), (3,785), (4,854), (1,921), +(1,553), (2,589), (3,743), (2,827), (2,545), +(4,779), (4,783), (1,597), (1,785), (4,832), +(1,741), (1,833), (3,788), (2,973), (1,907); +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; +UPDATE t1 SET acct_id=785 +WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +40960 +SELECT COUNT(*) FROM t1 WHERE acct_id=785; +COUNT(*) +8702 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx1,idx2 idx1 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`acct_id` = 785) and (`test`.`t1`.`stat_id` in (1,3))) +INSERT INTO t2 SELECT * FROM t1; +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL range idx1,idx2 idx1 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` where ((`test`.`t2`.`acct_id` = 785) and (`test`.`t2`.`stat_id` in (1,3))) +SET sql_mode=default; +DROP TABLE t1,t2; +create table t1(a int) engine=innodb; +alter table t1 comment '123'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='123' +drop table t1; +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('uk'),('bg'); +SELECT * FROM t1 WHERE a = 'uk'; +a +uk +DELETE FROM t1 WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +UPDATE t1 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t1 WHERE a = 'uk'; +a +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB; +INSERT INTO t2 VALUES ('uk'),('bg'); +SELECT * FROM t2 WHERE a = 'uk'; +a +uk +DELETE FROM t2 WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +INSERT INTO t2 VALUES ('uk'); +UPDATE t2 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t2 WHERE a = 'uk'; +a +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM; +INSERT INTO t3 VALUES ('uk'),('bg'); +SELECT * FROM t3 WHERE a = 'uk'; +a +uk +DELETE FROM t3 WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +INSERT INTO t3 VALUES ('uk'); +UPDATE t3 SET a = 'us' WHERE a = 'uk'; +SELECT * FROM t3 WHERE a = 'uk'; +a +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT) ENGINE=InnoDB; +switch to connection c1 +SET AUTOCOMMIT=0; +INSERT INTO t2 VALUES (1); +switch to connection c2 +SET AUTOCOMMIT=0; +SET @old_lock_wait_timeout= @@lock_wait_timeout; +SET lock_wait_timeout= 1; +LOCK TABLES t1 READ, t2 READ; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET @@lock_wait_timeout= @old_lock_wait_timeout; +switch to connection c1 +COMMIT; +INSERT INTO t1 VALUES (1); +switch to connection default +SET AUTOCOMMIT=default; +DROP TABLE t1,t2; +CREATE TABLE t1 ( +id int NOT NULL auto_increment PRIMARY KEY, +b int NOT NULL, +c datetime NOT NULL, +INDEX idx_b(b), +INDEX idx_c(c) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +b int NOT NULL auto_increment PRIMARY KEY, +c datetime NOT NULL +) ENGINE= MyISAM; +INSERT INTO t2(c) VALUES ('2007-01-01'); +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t2(c) SELECT c FROM t2; +INSERT INTO t1(b,c) SELECT b,c FROM t2; +UPDATE t2 SET c='2007-01-02'; +INSERT INTO t1(b,c) SELECT b,c FROM t2; +UPDATE t2 SET c='2007-01-03'; +INSERT INTO t1(b,c) SELECT b,c FROM t2; +set @@sort_buffer_size=8192; +Warnings: +Warning 1292 Truncated incorrect sort_buffer_size value: '8192' +SELECT COUNT(*) FROM t1; +COUNT(*) +3072 +EXPLAIN +SELECT COUNT(*) FROM t1 +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (4 workers) +2 SIMPLE t1 NULL ALL idx_b,idx_c NULL NULL NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (((`test`.`t1`.`c` >= TIMESTAMP'2007-01-02 00:00:00') and (`test`.`t1`.`c` <= TIMESTAMP'2007-01-03 00:00:00')) or (`test`.`t1`.`b` >= 1)) +SELECT COUNT(*) FROM t1 +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +COUNT(*) +3072 +EXPLAIN +SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge idx_b,idx_c idx_c,idx_b 5,4 NULL # # Using sort_union(idx_c,idx_b); Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`idx_c`) FORCE INDEX (`idx_b`) where (((`test`.`t1`.`c` >= TIMESTAMP'2007-01-02 00:00:00') and (`test`.`t1`.`c` <= TIMESTAMP'2007-01-03 00:00:00')) or (`test`.`t1`.`b` >= 1)) +SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) +WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; +COUNT(*) +3072 +set @@sort_buffer_size=default; +DROP TABLE t1,t2; +CREATE TABLE t1 (a int, b int); +insert into t1 values (1,1),(1,2); +CREATE TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +drop table if exists t2; +Warnings: +Note 1051 Unknown table 'test.t2' +CREATE TABLE t2 (a int, b int, primary key (a)); +BEGIN; +INSERT INTO t2 values(100,100); +CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +Warnings: +Note 1050 Table 't2' already exists +SELECT * from t2; +a b +100 100 +ROLLBACK; +SELECT * from t2; +a b +100 100 +TRUNCATE table t2; +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t2; +CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)); +BEGIN; +INSERT INTO t2 values(100,100); +CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +Warnings: +Note 1050 Table 't2' already exists +SELECT * from t2; +a b +100 100 +COMMIT; +BEGIN; +INSERT INTO t2 values(101,101); +CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +Warnings: +Note 1050 Table 't2' already exists +SELECT * from t2; +a b +100 100 +101 101 +ROLLBACK; +SELECT * from t2; +a b +100 100 +TRUNCATE table t2; +INSERT INTO t2 select * from t1; +ERROR 23000: Duplicate entry '1' for key 't2.PRIMARY' +SELECT * from t2; +a b +drop table t1,t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB; +INSERT INTO t1 VALUES ( 1 , 1 , 1); +INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1; +INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1; +EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index b b 5 NULL 128 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,sum(`test`.`t1`.`c`) AS `SUM(c)` from `test`.`t1` group by `test`.`t1`.`b` +EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL b NULL NULL NULL 128 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b`,sum(`test`.`t1`.`c`) AS `SUM(c)` from `test`.`t1` group by `test`.`t1`.`b` +DROP TABLE t1; +drop table if exists t1; +show variables like 'innodb_rollback_on_timeout'; +Variable_name Value +innodb_rollback_on_timeout OFF +create table t1 (a int unsigned not null primary key) engine = innodb; +insert into t1 values (1); +commit; +begin work; +insert into t1 values (2); +select * from t1; +a +1 +2 +begin work; +insert into t1 values (5); +select * from t1; +a +1 +5 +insert into t1 values (2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +select * from t1; +a +1 +5 +commit; +select * from t1; +a +1 +2 +commit; +select * from t1; +a +1 +2 +5 +drop table t1; +End of 5.0 tests +# +# Bug#23753319: !M_THD->TRANSACTION_ROLLBACK_REQUEST' AT +# THD::ATTACHABLE_TRX::INIT IN SQL/SQL_C +# +create table t1 (i int); +insert into t1 values (42); +# Grab locks which will block another con from doing select in RR +BEGIN; +select * from t1 for update; +i +42 +# Create competing connection using RR +BEGIN; +set session transaction isolation level repeatable read; +# Will fail and request rollback due to blocking for update +# (prior to fix this would trigger the assert). +create table t2 as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Additional coverage for WL#7743 "New data dictionary: changes +# to DDL-related parts of SE API". Check how rollback is handled +# by similar CTS for non-transactional table. +BEGIN; +create table t2 engine=myisam as select * from t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Cleanup +COMMIT; +drop table t1; +drop table if exists t1; +create table t1 (a int) engine=innodb; +alter table t1 alter a set default 1; +drop table t1; + +Bug#24918 drop table and lock / inconsistent between +perm and temp tables + +Check transactional tables under LOCK TABLES + +drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp, +t24918_access; +create table t24918_access (id int); +create table t24918 (id int) engine=myisam; +create temporary table t24918_tmp (id int) engine=myisam; +create table t24918_trans (id int) engine=innodb; +create temporary table t24918_trans_tmp (id int) engine=innodb; +lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write; +drop table t24918; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +drop table t24918_trans; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +drop table t24918_trans_tmp; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +drop table t24918_tmp; +select * from t24918_access; +ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES +unlock tables; +drop table t24918_access; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2); +INSERT INTO t1 SELECT a + 8, 2 FROM t1; +INSERT INTO t1 SELECT a + 16, 1 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 5 +ref const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 2) order by `test`.`t1`.`a` +SELECT * FROM t1 WHERE b=2 ORDER BY a; +a b +1 2 +2 2 +3 2 +4 2 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +11 2 +12 2 +13 2 +14 2 +15 2 +16 2 +EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 32 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys bkey +key PRIMARY +key_len 4 +ref NULL +rows 32 +filtered 100.00 +Extra Using where +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` between 1 and 2) order by `test`.`t1`.`a` +SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; +a b +1 2 +2 2 +3 2 +4 2 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +11 2 +12 2 +13 2 +14 2 +15 2 +16 2 +17 1 +18 1 +19 1 +20 1 +21 1 +22 1 +23 1 +24 1 +25 1 +26 1 +27 1 +28 1 +29 1 +30 1 +31 1 +32 1 +EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 32 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys bkey +key bkey +key_len 5 +ref NULL +rows 32 +filtered 100.00 +Extra Using where; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` between 1 and 2) order by `test`.`t1`.`b`,`test`.`t1`.`a` +SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a; +a b +17 1 +18 1 +19 1 +20 1 +21 1 +22 1 +23 1 +24 1 +25 1 +26 1 +27 1 +28 1 +29 1 +30 1 +31 1 +32 1 +1 2 +2 2 +3 2 +4 2 +5 2 +6 2 +7 2 +8 2 +9 2 +10 2 +11 2 +12 2 +13 2 +14 2 +15 2 +16 2 +CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a), KEY bkey (b,c)) +ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,1,1),(3,1,1),(2,1,1),(4,1,1); +INSERT INTO t2 SELECT a + 4, 1, 1 FROM t2; +INSERT INTO t2 SELECT a + 8, 1, 1 FROM t2; +EXPLAIN SELECT * FROM t2 WHERE b=1 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 5 +ref const +rows 16 +filtered 100.00 +Extra Using index; Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where (`test`.`t2`.`b` = 1) order by `test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 ORDER BY a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 10 +ref const,const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1)) order by `test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 10 +ref const,const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1)) order by `test`.`t2`.`b`,`test`.`t2`.`c`,`test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 16 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t2 +partitions NULL +type ref +possible_keys bkey +key bkey +key_len 10 +ref const,const +rows 16 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 1)) order by `test`.`t2`.`c`,`test`.`t2`.`a` +SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a; +a b c +1 1 1 +2 1 1 +3 1 1 +4 1 1 +5 1 1 +6 1 1 +7 1 1 +8 1 1 +9 1 1 +10 1 1 +11 1 1 +12 1 1 +13 1 1 +14 1 1 +15 1 1 +16 1 1 +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, PRIMARY KEY (a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); +INSERT INTO t1 SELECT a + 8 FROM t1; +INSERT INTO t1 SELECT a + 16 FROM t1; +CREATE PROCEDURE p1 () +BEGIN +DECLARE i INT DEFAULT 50; +DECLARE cnt INT; +# Continue even in the presence of ER_LOCK_DEADLOCK. +DECLARE CONTINUE HANDLER FOR 1213 BEGIN END; +START TRANSACTION; +ALTER TABLE t1 ENGINE=InnoDB; +COMMIT; +START TRANSACTION; +WHILE (i > 0) DO +SET i = i - 1; +SELECT COUNT(*) INTO cnt FROM t1 LOCK IN SHARE MODE; +END WHILE; +COMMIT; +END;| +CALL p1(); +CALL p1(); +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +create table t1(a text) engine=innodb row_format=dynamic default charset=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +insert into t1 values('aaa'); +alter table t1 add index(a(1025)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text, + KEY `a` (`a`(1024)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC +drop table t1; +SET sql_mode=default; +CREATE TABLE t1 ( +a INT, +b INT, +KEY (b) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,10), (2,10), (2,20), (3,30); +START TRANSACTION; +SELECT * FROM t1 WHERE b=20 FOR UPDATE; +a b +2 20 +START TRANSACTION; +SELECT * FROM t1 WHERE b=10 ORDER BY A FOR UPDATE; +a b +1 10 +2 10 +ROLLBACK; +ROLLBACK; +DROP TABLE t1; +CREATE TABLE t1( +a INT, +b INT NOT NULL, +c INT NOT NULL, +d INT, +UNIQUE KEY (c,b) +) engine=innodb; +INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 GROUP BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` order by NULL +SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` order by `test`.`t1`.`c`,`test`.`t1`.`b`,`test`.`t1`.`d` +SELECT c,b,d FROM t1 ORDER BY c,b,d; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL c NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`d` AS `d` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b,d FROM t1 GROUP BY c,b; +c b d +1 1 50 +3 1 4 +3 2 40 +EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index c c 8 NULL 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,`test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`c`,`test`.`t1`.`b` +SELECT c,b FROM t1 GROUP BY c,b; +c b +1 1 +3 1 +3 2 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB; +INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2); +EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type ref +possible_keys b +key b +key_len 5 +ref const +rows 2 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 2) order by `test`.`t1`.`a` +SELECT * FROM t1 WHERE b=2 ORDER BY a ASC; +a b +2 2 +3 2 +EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 2 +filtered 100.00 +Extra Backward index scan; Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type ref +possible_keys b +key b +key_len 5 +ref const +rows 2 +filtered 100.00 +Extra Backward index scan; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 2) order by `test`.`t1`.`a` desc +SELECT * FROM t1 WHERE b=2 ORDER BY a DESC; +a b +3 2 +2 2 +EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b`,`test`.`t1`.`a` +SELECT * FROM t1 ORDER BY b ASC, a ASC; +a b +1 1 +2 2 +3 2 +EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Backward index scan; Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Backward index scan; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` desc,`test`.`t1`.`a` desc +SELECT * FROM t1 ORDER BY b DESC, a DESC; +a b +3 2 +2 2 +1 1 +EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Using index; Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b`,`test`.`t1`.`a` desc +SELECT * FROM t1 ORDER BY b ASC, a DESC; +a b +1 1 +3 2 +2 2 +EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 3 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 5 +ref NULL +rows 3 +filtered 100.00 +Extra Using index; Using filesort +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`b` desc,`test`.`t1`.`a` +SELECT * FROM t1 ORDER BY b DESC, a ASC; +a b +2 2 +3 2 +1 1 +DROP TABLE t1; + +# +# Bug#27610: ALTER TABLE ROW_FORMAT=... does not rebuild the table. +# + +# - prepare; + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1(c INT) +ENGINE = InnoDB +ROW_FORMAT = COMPACT; + +# - initial check; + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; +TABLE_SCHEMA TABLE_NAME ROW_FORMAT +test t1 Compact + +# - change ROW_FORMAT and check; + +ALTER TABLE t1 ROW_FORMAT = REDUNDANT; + +SELECT table_schema, table_name, row_format +FROM INFORMATION_SCHEMA.TABLES +WHERE table_schema = DATABASE() AND table_name = 't1'; +TABLE_SCHEMA TABLE_NAME ROW_FORMAT +test t1 Redundant + +# - that's it, cleanup. + +DROP TABLE t1; +create table t1(a char(10) not null, unique key aa(a(1)), +b char(4) not null, unique key bb(b(4))) engine=innodb; +desc t1; +Field Type Null Key Default Extra +a char(10) NO UNI NULL +b char(4) NO PRI NULL +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) NOT NULL, + `b` char(4) NOT NULL, + UNIQUE KEY `bb` (`b`), + UNIQUE KEY `aa` (`a`(1)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t1; +CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), +(201, 'member', 2), (NULL, 'member', 5), (191, 'member', 6), +(191, 'member', 7), (191, 'member', 8), (191, 'member', 9), +(191, 'member', 10); +EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 90.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL idx NULL NULL NULL 10 90.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`type` AS `type`,`test`.`t1`.`d` AS `d` from `test`.`t1` where ((`test`.`t1`.`id` = 191) or (`test`.`t1`.`id` is null)) order by `test`.`t1`.`d` +SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; +id type d +191 member 1 +NULL member 3 +NULL member 4 +NULL member 5 +191 member 6 +191 member 7 +191 member 8 +191 member 9 +191 member 10 +DROP TABLE t1; +set @my_innodb_autoextend_increment=@@global.innodb_autoextend_increment; +set global innodb_autoextend_increment=8; +set global innodb_autoextend_increment=@my_innodb_autoextend_increment; +set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency; +set global innodb_commit_concurrency=0; +set global innodb_commit_concurrency=@my_innodb_commit_concurrency; +CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b)) +ENGINE=InnoDB; +INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1); +INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1; +INSERT INTO t1 (a,b,c) SELECT a+8,b,c FROM t1; +EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range t1_b t1_b 5 NULL 16 100.00 Using index condition; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`b` = 1) order by `test`.`t1`.`a` desc limit 5 +SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; +a b c +16 1 1 +15 1 1 +14 1 1 +13 1 1 +12 1 1 +DROP TABLE t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a char(50)) ENGINE=InnoDB; +CREATE INDEX i1 on t1 (a(3)); +SELECT * FROM t1 WHERE a = 'abcde'; +a +DROP TABLE t1; +# +# BUG #26288: savepoint are not deleted on comit, if the transaction +# was otherwise empty +# +BEGIN; +SAVEPOINT s1; +COMMIT; +RELEASE SAVEPOINT s1; +ERROR 42000: SAVEPOINT s1 does not exist +BEGIN; +SAVEPOINT s2; +COMMIT; +ROLLBACK TO SAVEPOINT s2; +ERROR 42000: SAVEPOINT s2 does not exist +BEGIN; +SAVEPOINT s3; +ROLLBACK; +RELEASE SAVEPOINT s3; +ERROR 42000: SAVEPOINT s3 does not exist +BEGIN; +SAVEPOINT s4; +ROLLBACK; +ROLLBACK TO SAVEPOINT s4; +ERROR 42000: SAVEPOINT s4 does not exist +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int NOT NULL COMMENT 'My ID#', + `f2` int DEFAULT NULL, + `f3` char(10) DEFAULT 'My ID#', + PRIMARY KEY (`f1`), + KEY `f2_ref` (`f2`), + CONSTRAINT `f2_ref` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug #36995: valgrind error in remove_const during subquery executions +# +create table t1 (a bit(1) not null,b int) engine=myisam; +create table t2 (c int) engine=innodb; +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +explain +select b from t1 where a not in (select b from t1,t2 group by a) group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty +Warnings: +Note 1003 /* select#1 */ select NULL AS `b` from `test`.`t1` where (NULL,(/* select#2 */ select `test`.`t1`.`b` from `test`.`t1` join `test`.`t2` where (((NULL) = `test`.`t1`.`b`) or (`test`.`t1`.`b` is null)) having (`test`.`t1`.`b`)) is false) group by NULL +DROP TABLE t1,t2; +SET sql_mode=default; +End of 5.0 tests +CREATE TABLE `t2` ( +`k` int(11) NOT NULL auto_increment, +`a` int(11) default NULL, +`c` int(11) default NULL, +PRIMARY KEY (`k`), +UNIQUE KEY `idx_1` (`a`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +insert into t2 ( a ) values ( 7 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +2 +select * from t2; +k a c +1 6 NULL +2 7 NULL +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +2 +select last_insert_id(0); +last_insert_id(0) +0 +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1; +select last_insert_id(); +last_insert_id() +0 +select * from t2; +k a c +1 6 2 +2 7 NULL +insert ignore into t2 values (null,6,1),(10,8,1); +Warnings: +Warning 1062 Duplicate entry '6' for key 't2.idx_1' +select last_insert_id(); +last_insert_id() +0 +insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); +Warnings: +Warning 1062 Duplicate entry '6' for key 't2.idx_1' +Warning 1062 Duplicate entry '8' for key 't2.idx_1' +select last_insert_id(); +last_insert_id() +11 +select * from t2; +k a c +1 6 2 +2 7 NULL +10 8 1 +11 15 1 +12 20 1 +insert into t2 ( a ) values ( 6 ) on duplicate key update c = +ifnull( c, +0 ) + 1, k=last_insert_id(k); +select last_insert_id(); +last_insert_id() +1 +select * from t2; +k a c +1 6 3 +2 7 NULL +10 8 1 +11 15 1 +12 20 1 +drop table t2; +drop table if exists t1, t2; +create table t1 (i int); +alter table t1 modify i int default 1; +alter table t1 modify i int default 2, rename t2; +lock table t2 write; +alter table t2 modify i int default 3; +unlock tables; +lock table t2 write; +alter table t2 modify i int default 4, rename t1; +unlock tables; +drop table t1; +drop table if exists t1; +create table t1 (i int); +insert into t1 values (); +lock table t1 write; +alter table t1 modify i int default 1; +insert into t1 values (); +select * from t1; +i +NULL +1 +alter table t1 change i c char(10) default "Two"; +insert into t1 values (); +select * from t1; +c +NULL +1 +Two +unlock tables; +select * from t1; +c +NULL +1 +Two +drop tables t1; +create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT +CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1(f1) values(1); +select @a:=f2 from t1; +@a:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +update t1 set f1=1; +select @b:=f2 from t1; +@b:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if(@a=@b,"ok","wrong"); +if(@a=@b,"ok","wrong") +ok +insert into t1(f1) values (1) on duplicate key update f1="1"; +select @b:=f2 from t1; +@b:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if(@a=@b,"ok","wrong"); +if(@a=@b,"ok","wrong") +ok +insert into t1(f1) select f1 from t1 on duplicate key update f1="1"; +select @b:=f2 from t1; +@b:=f2 +# +Warnings: +# 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +select if(@a=@b,"ok","wrong"); +if(@a=@b,"ok","wrong") +ok +drop table t1; +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +set binlog_format=mixed; +# Switch to connection con1 +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,2); +# 1. test for locking: +BEGIN; +UPDATE t1 SET b = 12 WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 12 +# Switch to connection con2 +UPDATE t1 SET b = 21 WHERE a = 1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Switch to connection con1 +SELECT * FROM t1; +a b +1 12 +ROLLBACK; +# Switch to connection con2 +ROLLBACK; +# Switch to connection con1 +# 2. test for serialized update: +CREATE TABLE t2 (a INT); +TRUNCATE t1; +INSERT INTO t1 VALUES (1,'init'); +CREATE PROCEDURE p1() +BEGIN +UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; +INSERT INTO t2 VALUES (); +END| +BEGIN; +UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +1 init+con1 +COMMIT; +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +1 init+con1+con2 +COMMIT; +# Switch to connection con1 +# 3. test for updated key column: +TRUNCATE t1; +TRUNCATE t2; +INSERT INTO t1 VALUES (1,'init'); +BEGIN; +UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +2 init+con1 +COMMIT; +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +2 init+con1 +DROP PROCEDURE p1; +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb; +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'c2': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'c2': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c1 FOREIGN KEY c2 (c) REFERENCES t1 (a) ON DELETE NO ACTION, +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; +ALTER TABLE t2 DROP FOREIGN KEY c2; +DROP TABLE t2; +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'foreign key without name': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT f1 FOREIGN KEY (c) REFERENCES t1 (a,k) ON UPDATE NO ACTION) engine=innodb; +ERROR 42000: Incorrect foreign key definition for 'f1': Key reference and table reference don't match +CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), +CONSTRAINT c1 FOREIGN KEY f1 (c) REFERENCES t1 (a) ON DELETE NO ACTION, +CONSTRAINT c2 FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION, +FOREIGN KEY f3 (c) REFERENCES t1 (a) ON UPDATE NO ACTION, +FOREIGN KEY (c) REFERENCES t1 (a) ON UPDATE NO ACTION) engine=innodb; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` int NOT NULL, + `d` int NOT NULL, + PRIMARY KEY (`c`,`d`), + CONSTRAINT `c1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`), + CONSTRAINT `c2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`), + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t2; +DROP TABLE t1; +create table t1 (a int auto_increment primary key) engine=innodb; +alter table t1 order by a; +Warnings: +Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 't1' +drop table t1; +CREATE TABLE t1 +(vid integer NOT NULL, +tid integer NOT NULL, +idx integer NOT NULL, +name varchar(128) NOT NULL, +type varchar(128) NULL, +PRIMARY KEY(idx, vid, tid), +UNIQUE(vid, tid, name) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(1,1,1,'pk',NULL),(2,1,1,'pk',NULL),(3,1,1,'pk',NULL),(4,1,1,'c1',NULL), +(5,1,1,'pk',NULL),(1,1,2,'c1',NULL),(2,1,2,'c1',NULL),(3,1,2,'c1',NULL), +(4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL), +(4,1,3,'pk',NULL),(5,1,3,'c2',NULL), +(2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL); +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 16 6.25 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 12 NULL 16 6.25 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`vid` AS `vid`,`test`.`t1`.`tid` AS `tid`,`test`.`t1`.`idx` AS `idx`,`test`.`t1`.`name` AS `name`,`test`.`t1`.`type` AS `type` from `test`.`t1` FORCE INDEX (PRIMARY) where ((`test`.`t1`.`vid` = 3) and (`test`.`t1`.`tid` = 1)) order by `test`.`t1`.`idx` desc +SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +vid tid idx name type +3 1 4 c_extra NULL +3 1 3 c2 NULL +3 1 2 c1 NULL +3 1 1 pk NULL +DROP TABLE t1; +# +# Bug #44290: explain crashes for subquery with distinct in +# SQL_SELECT::test_quick_select +# (reproduced only with InnoDB tables) +# +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ref c3,c2 c3 5 const 2 40.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` where ((`test`.`t1`.`c3` = 2) and (`test`.`t1`.`c2` in (1,1))) group by `test`.`t1`.`c2`) `x` +DROP TABLE t1; +CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ref c3,c2 c3 9 const 2 40.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` where ((`test`.`t1`.`c2` in (1,1)) and (`test`.`t1`.`c3` = 2)) group by `test`.`t1`.`c2`) `x` +DROP TABLE t1; +CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), +KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t1 NULL ref c3,c2 c3 7 const 2 40.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select count(distinct `test`.`t1`.`c1`) AS `COUNT(DISTINCT c1)` from `test`.`t1` where ((`test`.`t1`.`c2` in (1,1)) and (`test`.`t1`.`c3` = 2.00)) group by `test`.`t1`.`c2`) `x` +DROP TABLE t1; +End of 5.1 tests +# +# Bug#43600: Incorrect type conversion caused wrong result. +# +CREATE TABLE t1 ( +a int NOT NULL +) engine= innodb; +CREATE TABLE t2 ( +a int NOT NULL, +b int NOT NULL, +filler char(100) DEFAULT NULL, +KEY a (a,b) +) engine= innodb; +insert into t1 values (0),(1),(2),(3),(4); +insert into t2 select A.a + 10 *B.a, 1, 'filler' from t1 A, t1 B; +explain select * from t1, t2 where t2.a=t1.a and t2.b + 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 100.00 NULL +2 SIMPLE t2 NULL ref a a 4 test.t1.a 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (0 <> (`test`.`t2`.`b` + 1))) +select * from t1, t2 where t2.a=t1.a and t2.b + 1; +a a b filler +0 0 1 filler +1 1 1 filler +2 2 1 filler +3 3 1 filler +4 4 1 filler +drop table t1,t2; +# End of test case for the bug#43600 +# +# Bug#42643: InnoDB does not support replication of TRUNCATE TABLE +# +# Check that a TRUNCATE TABLE statement, needing an exclusive meta +# data lock, waits for a shared metadata lock owned by a concurrent +# transaction. +# +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); +BEGIN; +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +# Connection con1 +TRUNCATE TABLE t1;; +# Connection default +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +ROLLBACK; +# Connection con1 +# Reaping TRUNCATE TABLE +SELECT * FROM t1; +a +# Disconnect con1 +# Connection default +DROP TABLE t1; +# +# BUG#35850: Performance regression in 5.1.23/5.1.24 +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb; +insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +# this must use key 'a', not PRIMARY: +explain select a from t2 where a=b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (2 workers) +2 SIMPLE t2 NULL index NULL a 10 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`b` = `test`.`t2`.`a`) +drop table t1, t2; +# +# Bug #40360: Binlog related errors with binlog off +# +SET @save_log_bin= @@sql_log_bin; +SET @save_binlog_format=@@binlog_format; +SET @@sql_log_bin = 0; +SET SESSION BINLOG_FORMAT=STATEMENT; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +select @@session.sql_log_bin, @@session.binlog_format, @@session.transaction_isolation; +@@session.sql_log_bin 0 +@@session.binlog_format STATEMENT +@@session.transaction_isolation READ-COMMITTED +CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +DROP TABLE t1; +SET @@sql_log_bin=@save_log_bin; +SET @@binlog_format=@save_binlog_format; +# +# Bug#37284 Crash in Field_string::type() +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a char(50)) ENGINE=InnoDB; +CREATE INDEX i1 on t1 (a(3)); +SELECT * FROM t1 WHERE a = 'abcde'; +a +DROP TABLE t1; +# +# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +# requested column +# +CREATE TABLE foo (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=innodb; +CREATE TABLE foo2 (a int, b int, c char(10), +PRIMARY KEY (c), +KEY b (b) +) engine=innodb; +CREATE TABLE bar (a int, b int, c char(10), +PRIMARY KEY (c(3)), +KEY b (b) +) engine=myisam; +INSERT INTO foo VALUES +(1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'), +(4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'), (5,6,'trondheim'), +(6,7,'stockholm'), (7,8,'copenhagen'), (8,9,'helsinki'), +(9,10,'reykjavik'); +INSERT INTO bar SELECT * FROM foo; +INSERT INTO foo2 SELECT * FROM foo; +ANALYZE TABLE bar; +ANALYZE TABLE foo; +ANALYZE TABLE foo2; +EXPLAIN SELECT c FROM bar WHERE b>2;; +id 1 +select_type SIMPLE +table bar +partitions NULL +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 11 +filtered 90.91 +Extra Using where +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`bar`.`c` AS `c` from `test`.`bar` where (`test`.`bar`.`b` > 2) +EXPLAIN SELECT c FROM foo WHERE b>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 11 +filtered 90.91 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo +partitions NULL +type ALL +possible_keys b +key NULL +key_len NULL +ref NULL +rows 11 +filtered 90.91 +Extra Using where +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo`.`c` AS `c` from `test`.`foo` where (`test`.`foo`.`b` > 2) +EXPLAIN SELECT c FROM foo2 WHERE b>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 10 +filtered 100.00 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo2 +partitions NULL +type range +possible_keys b +key b +key_len 5 +ref NULL +rows 10 +filtered 100.00 +Extra Using where; Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo2`.`c` AS `c` from `test`.`foo2` where (`test`.`foo2`.`b` > 2) +EXPLAIN SELECT c FROM bar WHERE c>2;; +id 1 +select_type SIMPLE +table bar +partitions NULL +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Using where +Warnings: +Level Warning +Code 1739 +Message Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'c' +Level Note +Code 1003 +Message /* select#1 */ select `test`.`bar`.`c` AS `c` from `test`.`bar` where (`test`.`bar`.`c` > 2) +EXPLAIN SELECT c FROM foo WHERE c>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo +partitions NULL +type ALL +possible_keys PRIMARY +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Using where +Warnings: +Level Warning +Code 1739 +Message Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'c' +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo`.`c` AS `c` from `test`.`foo` where (`test`.`foo`.`c` > 2) +EXPLAIN SELECT c FROM foo2 WHERE c>2;; +id 1 +select_type SIMPLE +table +partitions NULL +type ALL +possible_keys NULL +key NULL +key_len NULL +ref NULL +rows 11 +filtered 33.33 +Extra Parallel execute (1 workers) +id 2 +select_type SIMPLE +table foo2 +partitions NULL +type index +possible_keys PRIMARY +key b +key_len 5 +ref NULL +rows 11 +filtered 33.33 +Extra Using where; Using index +Warnings: +Level Warning +Code 1739 +Message Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'c' +Level Warning +Code 1739 +Message Cannot use range access on index 'b' due to type or collation conversion on field 'c' +Level Note +Code 1003 +Message /* select#1 */ select `test`.`foo2`.`c` AS `c` from `test`.`foo2` where (`test`.`foo2`.`c` > 2) +DROP TABLE foo, bar, foo2; +# +# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +# +DROP TABLE IF EXISTS t1,t3,t2; +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS VARCHAR(250) +BEGIN +return 'hhhhhhh' ; +END| +CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB; +BEGIN WORK; +CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB; +CREATE TEMPORARY TABLE t3 LIKE t2; +INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL); +SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl'); +PREPARE stmt1 FROM @stmt; +SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2'); +PREPARE stmt3 FROM @stmt; +EXECUTE stmt1; +COMMIT; +DEALLOCATE PREPARE stmt1; +DEALLOCATE PREPARE stmt3; +DROP TABLE t1,t3,t2; +DROP FUNCTION f1; +# +# Bug#37016: TRUNCATE TABLE removes some rows but not all +# +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, +t1_id INT, INDEX par_ind (t1_id), +FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (3,2); +SET AUTOCOMMIT = 0; +START TRANSACTION; +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +SELECT * FROM t1; +id +1 +2 +COMMIT; +SELECT * FROM t1; +id +1 +2 +START TRANSACTION; +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +SELECT * FROM t1; +id +1 +2 +ROLLBACK; +SELECT * FROM t1; +id +1 +2 +SET AUTOCOMMIT = 1; +START TRANSACTION; +SELECT * FROM t1; +id +1 +2 +COMMIT; +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +SELECT * FROM t1; +id +1 +2 +DELETE FROM t2 WHERE id = 3; +START TRANSACTION; +SELECT * FROM t1; +id +1 +2 +TRUNCATE TABLE t1; +ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1`) +ROLLBACK; +SELECT * FROM t1; +id +1 +2 +TRUNCATE TABLE t2; +DROP TABLE t2; +DROP TABLE t1; +# +# Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0 +# +CREATE TABLE t1 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +PRIMARY KEY (id) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +id INT UNSIGNED NOT NULL AUTO_INCREMENT, +aid INT UNSIGNED NOT NULL, +PRIMARY KEY (id), +FOREIGN KEY (aid) REFERENCES t1 (id) +) ENGINE=InnoDB; +CREATE TABLE t3 ( +bid INT UNSIGNED NOT NULL, +FOREIGN KEY (bid) REFERENCES t2 (id) +) ENGINE=InnoDB; +CREATE TABLE t4 ( +a INT +) ENGINE=InnoDB; +CREATE TABLE t5 ( +a INT +) ENGINE=InnoDB; +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t2 (id, aid) VALUES (1, 1),(2,1),(3,1),(4,1); +INSERT INTO t3 (bid) VALUES (1); +INSERT INTO t4 VALUES (1),(2),(3),(4),(5); +INSERT INTO t5 VALUES (1); +DELETE t5 FROM t4 LEFT JOIN t5 ON t4.a= t5.a; +DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`)) +DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`)) +DELETE IGNORE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `t1` (`id`)) +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; +DROP TABLES t4,t5; +# Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0 +# Testing for any side effects of IGNORE on AFTER DELETE triggers used with +# transactional tables. +# +CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (a VARCHAR(100)) ENGINE=InnoDB; +CREATE TABLE t3 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t4 (i INT NOT NULL PRIMARY KEY, t1i INT, +FOREIGN KEY (t1i) REFERENCES t1(i)) +ENGINE=InnoDB; +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN +SET @b:='EXECUTED TRIGGER'; +INSERT INTO t2 VALUES (@b); +SET @a:= error_happens_here; +END|| +SET @b:=""; +SET @a:=""; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 SELECT * FROM t1; +** An error in a trigger causes rollback of the statement. +DELETE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +ERROR 42S22: Unknown column 'error_happens_here' in 'field list' +SELECT @a,@b; +@a @b + EXECUTED TRIGGER +SELECT * FROM t2; +a +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +1 1 +2 2 +3 3 +4 4 +** Same happens with the IGNORE option +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +ERROR 42S22: Unknown column 'error_happens_here' in 'field list' +SELECT * FROM t2; +a +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +1 1 +2 2 +3 3 +4 4 +** +** The following is an attempt to demonstrate +** error handling inside a row iteration. +** +DROP TRIGGER trg; +DELETE FROM t1; +DELETE FROM t2; +DELETE FROM t3; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 VALUES (1),(2),(3),(4); +INSERT INTO t4 VALUES (3,3),(4,4); +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN +SET @b:= CONCAT('EXECUTED TRIGGER FOR ROW ',CAST(OLD.i AS CHAR)); +INSERT INTO t2 VALUES (@b); +END|| +** DELETE is prevented by foreign key constrains but errors are silenced. +** The AFTER trigger isn't fired. +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +Warnings: +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`t1i`) REFERENCES `t1` (`i`)) +Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`t1i`) REFERENCES `t1` (`i`)) +** Tables are modified by best effort: +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +3 3 +4 4 +** The AFTER trigger was only executed on successful rows: +SELECT * FROM t2; +a +EXECUTED TRIGGER FOR ROW 1 +EXECUTED TRIGGER FOR ROW 2 +DROP TRIGGER trg; +** +** Induce an error midway through an AFTER-trigger +** +DELETE FROM t4; +DELETE FROM t1; +DELETE FROM t3; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 VALUES (1),(2),(3),(4); +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN +SET @a:= @a+1; +IF @a > 2 THEN +INSERT INTO t4 VALUES (5,5); +END IF; +END|| +SET @a:=0; +** Errors in the trigger causes the statement to abort. +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`t1i`) REFERENCES `t1` (`i`)) +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +i i +1 1 +2 2 +3 3 +4 4 +SELECT * FROM t4; +i t1i +DROP TRIGGER trg; +DROP TABLE t4; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +# +# Bug#43580: Issue with Innodb on multi-table update +# +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; +CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; +CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t2 straight_join t1 SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b; +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +UPDATE t4 straight_join t3 SET t3.a = t3.a + 100, t4.b = t3.a + 10 +WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100; +SELECT * FROM t4; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2, t3, t4; +# +# Bug#44886: SIGSEGV in test_if_skip_sort_order() - +# uninitialized variable used as subscript +# +CREATE TABLE t1 (a INT, b INT, c INT, d INT, PRIMARY KEY (b), KEY (a,c)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1,0); +CREATE TABLE t2 (a INT, b INT, e INT, KEY (e)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,1,2); +CREATE TABLE t3 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t3 VALUES (1, 1); +SET sql_mode='NO_ENGINE_SUBSTITUTION'; +SELECT * FROM t1, t2, t3 +WHERE t1.a = t3.a AND (t1.b = t3.b OR t1.d) AND t2.b = t1.b AND t2.e = 2 +GROUP BY t1.b; +a b c d a b e a b +1 1 1 0 1 1 2 1 1 +SET sql_mode=default; +DROP TABLE t1, t2, t3; +# +# Bug #45828: Optimizer won't use partial primary key if another +# index can prevent filesort +# +CREATE TABLE `t1` ( +c1 int NOT NULL, +c2 int NOT NULL, +c3 int NOT NULL, +PRIMARY KEY (c1,c2), +KEY (c3) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,2,1246276747); +INSERT INTO t1 VALUES (2,1,1246281721); +INSERT INTO t1 VALUES (7,3,1246281756); +INSERT INTO t1 VALUES (4,2,1246282139); +INSERT INTO t1 VALUES (3,1,1246282230); +INSERT INTO t1 VALUES (1,0,1246282712); +INSERT INTO t1 VALUES (8,3,1246282765); +INSERT INTO t1 SELECT c1+10,c2+10,c3+10 FROM t1; +INSERT INTO t1 SELECT c1+100,c2+100,c3+100 from t1; +INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1; +INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1; +INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1; +INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +c1 c2 c3 +EXPLAIN SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,c3 PRIMARY 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` where ((`test`.`t1`.`c1` = 99999999) and (`test`.`t1`.`c3` > 1)) order by `test`.`t1`.`c3` +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 const 1 33.33 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` FORCE INDEX (PRIMARY) where ((`test`.`t1`.`c1` = 99999999) and (`test`.`t1`.`c3` > 1)) order by `test`.`t1`.`c3` +CREATE TABLE t2 ( +c1 int NOT NULL, +c2 int NOT NULL, +c3 int NOT NULL, +KEY (c1,c2), +KEY (c3) +) ENGINE=InnoDB; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain SELECT * FROM t2 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref c1,c3 c1 4 const 1 100.00 Using where; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`c3` AS `c3` from `test`.`t2` where ((`test`.`t2`.`c1` = 99999999) and (`test`.`t2`.`c3` > 1)) order by `test`.`t2`.`c3` +DROP TABLE t1,t2; +# +# 36259: Optimizing with ORDER BY +# +CREATE TABLE t1 ( +a INT NOT NULL AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL, +d VARCHAR(5), +e INT NOT NULL, +PRIMARY KEY (a), KEY i2 (b,c,d) +) ENGINE=InnoDB; +INSERT INTO t1 (b,c,d,e) VALUES (1,1,'a',1), (2,2,'b',2); +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +ANALYZE TABLE t1; +EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i2 i2 8 const,const 1 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` where ((`test`.`t1`.`c` = 1) and (`test`.`t1`.`b` = 1)) order by `test`.`t1`.`a` +EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i2 i2 8 const,const 1 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` FORCE INDEX (`i2`) where ((`test`.`t1`.`c` = 1) and (`test`.`t1`.`b` = 1)) order by `test`.`t1`.`a` +EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # # Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t1`.`d` AS `d`,`test`.`t1`.`e` AS `e` from `test`.`t1` FORCE INDEX (PRIMARY) where ((`test`.`t1`.`c` = 1) and (`test`.`t1`.`b` = 1)) order by `test`.`t1`.`a` +DROP TABLE t1; +# +# Bug #47963: Wrong results when index is used +# +CREATE TABLE t1( +a VARCHAR(5) NOT NULL, +b VARCHAR(5) NOT NULL, +c DATETIME NOT NULL, +KEY (c) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES('TEST', 'TEST', '2009-10-09 00:00:00'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00.0'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00.0'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.000' AND c <= '2009-10-09 00:00:00.000'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.00' AND c <= '2009-10-09 00:00:00.001'; +a b c +TEST TEST 2009-10-09 00:00:00 +SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00'; +a b c +EXPLAIN SELECT * FROM t1 WHERE a = 'TEST' AND +c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`c` >= TIMESTAMP'2009-10-09 00:00:00.001') and (`test`.`t1`.`c` <= TIMESTAMP'2009-10-09 00:00:00') and multiple equal('TEST', `test`.`t1`.`a`)) +DROP TABLE t1; +# +# Bug #46175: NULL read_view and consistent read assertion +# +CREATE TABLE t1(a CHAR(13),KEY(a)) ENGINE=innodb; +CREATE TABLE t2(b DATETIME,KEY(b)) ENGINE=innodb; +INSERT INTO t1 VALUES (),(); +INSERT INTO t2 VALUES (),(); +CREATE OR REPLACE VIEW v1 AS SELECT 1 FROM t2 +WHERE b =(SELECT a FROM t1 LIMIT 1); +CREATE PROCEDURE p1(num INT) +BEGIN +DECLARE i INT DEFAULT 0; +REPEAT +SHOW CREATE VIEW v1; +SET i:=i+1; +UNTIL i>num END REPEAT; +END| +# Should not crash +# Should not crash +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1,t2; +# +# Bug #49324: more valgrind errors in test_if_skip_sort_order +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; +# should not cause valgrind warnings +SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; +1 +DROP TABLE t1; +# +# Bug#50843: Filesort used instead of clustered index led to +# performance degradation. +# +create table t1(f1 int not null primary key, f2 int) engine=innodb; +create table t2(f1 int not null, key (f1)) engine=innodb; +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1),(2),(3); +analyze table t1; +analyze table t2; +explain select t1.* from t1 left join t2 using(f1) group by t1.f1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 NULL +2 SIMPLE t2 NULL ref f1 f1 4 test.t1.f1 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`f1` = `test`.`t1`.`f1`)) where true group by `test`.`t1`.`f1` +drop table t1,t2; +# +# +# Bug #39653: find_shortest_key in sql_select.cc does not consider +# clustered primary keys +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, d INT, e INT, f INT, +KEY (b,c)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1,1,1,1,1,1), (2,2,2,2,2,2), (3,3,3,3,3,3), +(4,4,4,4,4,4), (5,5,5,5,5,5), (6,6,6,6,6,6), +(7,7,7,7,7,7), (8,8,8,8,8,8), (9,9,9,9,9,9), +(11,11,11,11,11,11); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 10 +ref NULL +rows 10 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP TABLE t1; +# +# Bug #49838: DROP INDEX and ADD UNIQUE INDEX for same index may +# corrupt definition at engine +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, KEY k (a,b)) +ENGINE=InnoDB; +ALTER TABLE t1 DROP INDEX k, ADD UNIQUE INDEX k (a,b); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1;; +Table t1 +Non_unique 0 +Key_name k +Seq_in_index 1 +Column_name a +Collation A +Cardinality 0 +Sub_part NULL +Packed NULL +Null +Index_type BTREE +Comment +Index_comment +Visible YES +Expression NULL +Table t1 +Non_unique 0 +Key_name k +Seq_in_index 2 +Column_name b +Collation A +Cardinality 0 +Sub_part NULL +Packed NULL +Null +Index_type BTREE +Comment +Index_comment +Visible YES +Expression NULL +DROP TABLE t1; +# +# Bug #53334: wrong result for outer join with impossible ON condition +# (see the same test case for MyISAM in join.test) +# +CREATE TABLE t1 (id INT PRIMARY KEY); +CREATE TABLE t2 (id INT); +INSERT INTO t1 VALUES (75); +INSERT INTO t1 VALUES (79); +INSERT INTO t1 VALUES (78); +INSERT INTO t1 VALUES (77); +REPLACE INTO t1 VALUES (76); +REPLACE INTO t1 VALUES (76); +INSERT INTO t1 VALUES (104); +INSERT INTO t1 VALUES (103); +INSERT INTO t1 VALUES (102); +INSERT INTO t1 VALUES (101); +INSERT INTO t1 VALUES (105); +INSERT INTO t1 VALUES (106); +INSERT INTO t1 VALUES (107); +INSERT INTO t2 VALUES (107),(75),(1000); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SELECT t1.id,t2.id FROM t2 LEFT JOIN t1 ON t1.id>=74 AND t1.id<=0 +WHERE t2.id=75 AND t1.id IS NULL; +id id +NULL 75 +EXPLAIN SELECT t1.id,t2.id FROM t2 LEFT JOIN t1 ON t1.id>=74 AND t1.id<=0 +WHERE t2.id=75 AND t1.id IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t2`.`id` AS `id` from `test`.`t2` left join `test`.`t1` on(((`test`.`t1`.`id` >= 74) and (`test`.`t1`.`id` <= 0))) where ((`test`.`t2`.`id` = 75) and (`test`.`t1`.`id` is null)) +DROP TABLE t1,t2; +# +# Bug#38999 valgrind warnings for update statement in function compare_record() +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 values (1),(2),(3),(4),(5); +INSERT INTO t2 values (1); +SELECT * FROM t1 WHERE a = 2; +a +2 +UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1; +DROP TABLE t1,t2; +# +# Bug #53830: !table || (!table->read_set || bitmap_is_set(table->read_set, field_index)) +# +CREATE TABLE t1 (a INT, b INT, c INT, d INT, +PRIMARY KEY(a,b,c), KEY(b,d)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (0, 77, 1, 3); +UPDATE t1 SET d = 0 WHERE b = 77 AND c = 25; +DROP TABLE t1; +# +# Bug#50389 Using intersect does not return all rows +# +CREATE TABLE t1 ( +f1 INT(10) NOT NULL, +f2 INT(10), +f3 INT(10), +f4 TINYINT(4), +f5 VARCHAR(50), +PRIMARY KEY (f1), +KEY idx1 (f2,f5,f4), +KEY idx2 (f2,f4) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1; +ANALYZE TABLE t1; +SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, +3470988,3305175,3329875,3817277,3856380,3796193, +3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; +f1 f2 f3 f4 f5 +3305175 1221457 0 0 abcdefghijklmnopwrst +3329875 1221457 1382427 0 abcdefghijklmnopwrst +3336022 1221457 0 0 abcdefghijklmnopwrst +3346860 1221457 0 0 abcdefghijklmnopwrst +3772880 1221457 0 0 abcdefghijklmnopwrst +3784744 1221457 1382427 0 abcdefghijklmnopwrst +3796193 1221457 0 0 abcdefghijklmnopwrst +4228206 1221457 0 0 abcdefghijklmnopwrst +4494153 1221457 0 0 abcdefghijklmnopwrst +4559596 1221457 0 0 abcdefghijklmnopwrst +EXPLAIN SELECT * FROM t1 WHERE f1 IN +(3305028,3353871,3772880,3346860,4228206,3336022, +3470988,3305175,3329875,3817277,3856380,3796193, +3784744,4180925,4559596,3963734,3856391,4494153) +AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 0.28 Parallel execute (4 workers) +2 SIMPLE t1 NULL range PRIMARY,idx1,idx2 PRIMARY 4 NULL 18 0.28 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5` from `test`.`t1` where ((`test`.`t1`.`f4` = 0) and (`test`.`t1`.`f2` = 1221457) and (`test`.`t1`.`f5` = 'abcdefghijklmnopwrst') and (`test`.`t1`.`f1` in (3305028,3353871,3772880,3346860,4228206,3336022,3470988,3305175,3329875,3817277,3856380,3796193,3784744,4180925,4559596,3963734,3856391,4494153))) +DROP TABLE t1; +# +# Bug#51431 Wrong sort order after import of dump file +# +CREATE TABLE t1 ( +f1 INT(11) NOT NULL, +f2 int(11) NOT NULL, +f3 int(11) NOT NULL, +f4 tinyint(1) NOT NULL, +PRIMARY KEY (f1), +UNIQUE KEY (f2, f3), +KEY (f4) +) ENGINE=InnoDB STATS_PERSISTENT=0; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES +(1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1), +(6,1,996,1), (7,1,997,1), (8,1,998,1), (10,1,999,1), (11,1,9910,1), +(16,1,9911,1), (17,1,9912,1), (18,1,9913,1), (19,1,9914,1), (20,1,9915,1), +(21,1,9916,1), (22,1,9917,1), (23,1,9918,1), (24,1,9919,1), (25,1,9920,1), +(26,1,9921,1), (27,1,9922,1); +FLUSH TABLES; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; +f1 f2 f3 f4 +27 1 9922 1 +26 1 9921 1 +25 1 9920 1 +24 1 9919 1 +23 1 9918 1 +EXPLAIN SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE +ORDER BY f1 DESC LIMIT 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 22 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range f2,f4 f4 1 NULL 22 100.00 Using index condition; Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4` from `test`.`t1` where ((`test`.`t1`.`f4` = true) and (`test`.`t1`.`f2` = 1)) order by `test`.`t1`.`f1` desc limit 5 +DROP TABLE t1; +# +# Bug#54117 crash in thr_multi_unlock, temporary table +# +CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB; +LOCK TABLES t1 READ; +ALTER TABLE t1 COMMENT 'test'; +UNLOCK TABLES; +DROP TABLE t1; +# +# Bug#55656: mysqldump can be slower after bug #39653 fix +# +CREATE TABLE t1 (a INT , b INT, c INT, d INT, +KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 4 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP INDEX b ON t1; +CREATE INDEX b ON t1(a,b); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 8 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP INDEX b ON t1; +CREATE INDEX b ON t1(a,b,c); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key b +key_len 13 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP INDEX b ON t1; +CREATE INDEX b ON t1(a,b,c,d); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id 1 +select_type SIMPLE +table t1 +partitions NULL +type index +possible_keys NULL +key PRIMARY +key_len 8 +ref NULL +rows 3 +filtered 100.00 +Extra Using index +Warnings: +Level Note +Code 1003 +Message /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +DROP TABLE t1; +# +# Bug#55826: create table .. select crashes with when KILL_BAD_DATA +# is returned +# +CREATE TABLE t1(a INT) ENGINE=innodb; +INSERT INTO t1 VALUES (0); +CREATE TABLE t2 +SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; +ERROR 22007: Incorrect datetime value: '' for column 'NOW()' at row 2 +DROP TABLE t1; +# +# Bug#56862 Moved to innodb_16k.test +# +# +# Test for bug #39932 "create table fails if column for FK is in different +# case than in corr index". +# +drop tables if exists t1, t2; +create table t1 (pk int primary key) engine=InnoDB; +create table t2 (fk int, key x (fk), +constraint x foreign key (FK) references t1 (PK)) engine=InnoDB; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fk` int DEFAULT NULL, + KEY `x` (`fk`), + CONSTRAINT `x` FOREIGN KEY (`fk`) REFERENCES `t1` (`pk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +drop table t2, t1; +# +# Test for bug #11762012 - "54553: INNODB ASSERTS IN HA_INNOBASE:: +# UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK". +# +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (c int) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1); +LOCK TABLES t1 READ; +# Even though temporary table was locked for READ we +# still allow writes to it to be compatible with MyISAM. +# This is possible since due to fact that temporary tables +# are specific to connection and therefore locking for them +# is irrelevant. +UPDATE t1 SET c = 5; +UNLOCK TABLES; +DROP TEMPORARY TABLE t1; +# End of 5.1 tests +# +# Bug#49604 "6.0 processing compound WHERE clause incorrectly +# with Innodb - extra rows" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 INT, +PRIMARY KEY (c1), +KEY k1 (c2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (12,1); +INSERT INTO t1 VALUES (15,1); +INSERT INTO t1 VALUES (16,1); +INSERT INTO t1 VALUES (22,1); +INSERT INTO t1 VALUES (20,2); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 INT, +PRIMARY KEY (c1) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,2); +INSERT INTO t2 VALUES (2,9); +SELECT STRAIGHT_JOIN t2.c2, t1.c2, t2.c1 +FROM t1 JOIN t2 ON t1.c2 = t2.c1 +WHERE t2.c1 IN (2, 1, 6) OR t2.c1 NOT IN (1); +c2 c2 c1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +9 2 2 +DROP TABLE t1, t2; +# +# Bug#44613 SELECT statement inside FUNCTION takes a shared lock +# +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +CREATE TABLE t1(x INT PRIMARY KEY, y INT) ENGINE=innodb; +INSERT INTO t1 VALUES (1, 0), (2, 0); +CREATE FUNCTION f1(z INT) RETURNS INT READS SQL DATA +RETURN (SELECT x FROM t1 WHERE x = z); +# Connection default +START TRANSACTION; +SELECT f1(1); +f1(1) +1 +# Connection con2 +START TRANSACTION; +SELECT f1(1); +f1(1) +1 +UPDATE t1 SET y = 1 WHERE x = 1; +COMMIT; +# Connection default +COMMIT; +DROP TABLE t1; +DROP FUNCTION f1; +# +# Bug#42744: Crash when using a join buffer to join a table with a blob +# column and an additional column used for duplicate elimination. +# +CREATE TABLE t1 (a tinyblob) ENGINE=InnoDB; +CREATE TABLE t2 (a int PRIMARY KEY, b tinyblob) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('1'), (NULL); +INSERT INTO t2 VALUES (1, '1'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +1 SIMPLE NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (hash join) +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (hash join) +2 MATERIALIZED t2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` semi join (`test`.`t2`) where (`test`.`t1`.`a` = ``.`1`) +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); +b +1 +DROP TABLE t1,t2; +# +# Bug#48093: 6.0 Server not processing equivalent IN clauses properly +# with Innodb tables +# +CREATE TABLE t1 ( +i int(11) DEFAULT NULL, +v1 varchar(1) DEFAULT NULL, +v2 varchar(20) DEFAULT NULL, +KEY i (i), +KEY v (v1,i) +) ENGINE=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1,'f','no'); +INSERT INTO t1 VALUES (2,'u','yes-u'); +INSERT INTO t1 VALUES (2,'h','yes-h'); +INSERT INTO t1 VALUES (3,'d','no'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK + +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; +v2 +yes-u +yes-h + +# Should not use index_merge +EXPLAIN +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i,v i 5 const 2 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v2` AS `v2` from `test`.`t1` where ((`test`.`t1`.`i` = 2) and (`test`.`t1`.`v1` in ('f','d','h','u'))) +DROP TABLE t1; +# +# Bug#54606 innodb fast alter table + pack_keys=0 +# prevents adding new indexes +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) +ENGINE=InnoDB +PACK_KEYS=0; +CREATE INDEX a ON t1 (a); +CREATE INDEX c on t1 (c); +DROP TABLE t1; +# +# Additional coverage for refactoring which is made as part +# of fix for Bug#27480 "Extend CREATE TEMPORARY TABLES privilege +# to allow temp table operations". +# +# Check that OPTIMIZE table works for temporary InnoDB tables. +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +DROP TABLE t1; +# +# Bug#11762345 54927: DROPPING AND ADDING AN INDEX IN ONE +# COMMAND CAN FAIL IN INNODB PLUGIN 1.0 +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (id int, a int, b int, PRIMARY KEY (id), +INDEX a (a)) ENGINE=innodb; +ALTER TABLE t1 DROP INDEX a, ADD INDEX a (b, a); +ALTER TABLE t1 DROP INDEX a, ADD INDEX (a, b); +DROP TABLE t1; +# +# Check the prefix index on BLOB could not be promoted to PRIMARY KEY +# +CREATE TABLE t1 (a INT NOT NULL, d INT NOT NULL, b TEXT NOT NULL, c TEXT, +UNIQUE KEY (b(8) desc, a asc, d)) ENGINE = InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL, + `d` int NOT NULL, + `b` text NOT NULL, + `c` text, + UNIQUE KEY `b` (`b`(8) DESC,`a`,`d`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# Bug#25650516. The problem is the index order for the old and new +# dd::Table are different +# +CREATE TABLE t1 (col1 INT, col2 INT) ENGINE = InnoDB; +ALTER TABLE t1 ADD UNIQUE KEY uidx ( col2 ); +ALTER TABLE t1 ADD UNIQUE KEY uidx ( col1 ), RENAME KEY uidx TO new_uidx; +ALTER TABLE t1 ADD PRIMARY KEY ( col1 ); +ALTER TABLE t1 ALTER COLUMN col1 DROP DEFAULT; +DROP TABLE t1; +# +# BUG 25674492 - INNODB: ASSERTION FAILURE: HA_INNODB.CC:13881 +# :DD_TABLE_MATCH(TABLE, DD_TABLE) +# +CREATE TABLE t1 (col1 INT, col4 TEXT) ENGINE = InnoDB ROW_FORMAT = COMPACT; +ALTER TABLE t1 ADD KEY idx ( col1 ), ADD FULLTEXT KEY ftidx ( col4 ); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +ALTER TABLE t1 DROP KEY ftidx; +TRUNCATE TABLE t1; +DROP TABLE t1; +End of 6.0 tests diff --git a/mysql-test/suite/innodb/r/instant_add_column_basic.result-pq b/mysql-test/suite/innodb/r/instant_add_column_basic.result-pq new file mode 100644 index 000000000..8e4d9cfa3 --- /dev/null +++ b/mysql-test/suite/innodb/r/instant_add_column_basic.result-pq @@ -0,0 +1,6258 @@ +############################################## +# Test instant ADD COLUMN for REDUNDANT format +############################################## +# +# Scenario 1: +# Create a small table, and add all kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 INT, ALGORITHM=INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 1; +c1 +1 +ALTER TABLE t1 ADD COLUMN c2 INT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 8000000a +INSERT INTO t1(a, c2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE c2 = 10; +count(*) = max(a) +1 +SELECT c2 FROM t1 WHERE c2 = 11; +c2 +11 +ALTER TABLE t1 ADD COLUMN d1 BIGINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +SELECT d1 FROM t1 WHERE d1 = 1; +d1 +1 +ALTER TABLE t1 ADD COLUMN d2 BIGINT NOT NULL DEFAULT 1234567890; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd2' AND has_default = 1; +name default_value +d2 80000000499602d2 +INSERT INTO t1(a, d2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE d2 = 1234567890; +count(*) = max(a) +1 +SELECT d2 FROM t1 WHERE d2 = 1234; +d2 +1234 +ALTER TABLE t1 ADD COLUMN e1 SMALLINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +SELECT e1 FROM t1 WHERE e1 = 1; +e1 +1 +ALTER TABLE t1 ADD COLUMN e2 SMALLINT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e2' AND has_default = 1; +name default_value +e2 800a +INSERT INTO t1(a, e2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE e2 = 10; +count(*) = max(a) +1 +SELECT e2 FROM t1 WHERE e2 = 11; +e2 +11 +ALTER TABLE t1 ADD COLUMN f1 TINYINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +SELECT f1 FROM t1 WHERE f1 = 1; +f1 +1 +ALTER TABLE t1 ADD COLUMN f2 TINYINT NOT NULL DEFAULT 123; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f2' AND has_default = 1; +name default_value +f2 fb +INSERT INTO t1(a, f2) VALUES(0, 12); +SELECT count(*) = max(a) FROM t1 WHERE f2 = 123; +count(*) = max(a) +1 +SELECT f2 FROM t1 WHERE f2 = 12; +f2 +12 +ALTER TABLE t1 ADD COLUMN g1 MEDIUMINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +SELECT g1 FROM t1 WHERE g1 = 1; +g1 +1 +ALTER TABLE t1 ADD COLUMN g2 MEDIUMINT NOT NULL DEFAULT 12345; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g2' AND has_default = 1; +name default_value +g2 803039 +INSERT INTO t1(a, g2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE g2 = 12345; +count(*) = max(a) +1 +SELECT g2 FROM t1 WHERE g2 = 1234; +g2 +1234 +ALTER TABLE t1 ADD COLUMN h1 FLOAT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, 1.0); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +SELECT h1 FROM t1 WHERE h1 = 1; +h1 +1 +ALTER TABLE t1 ADD COLUMN h2 FLOAT NOT NULL DEFAULT 12.34; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h2' AND has_default = 1; +name default_value +h2 a4704541 +INSERT INTO t1(a, h2) VALUES(0, 1.234); +SELECT count(*) = max(a) FROM t1 WHERE h2 = 12.34; +count(*) = max(a) +NULL +SELECT h2 FROM t1 WHERE h2 = 1.234; +h2 +ALTER TABLE t1 ADD COLUMN i1 DECIMAL(5, 2), ADD COLUMN i2 double, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'i1' OR name = 'i2') AND has_default = 1; +name default_value +i1 NULL +i2 NULL +INSERT INTO t1(a, i1, i2) VALUES(0, 10.10, 20.20); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE i2 IS NULL; +count(*) = max(a) +1 +SELECT i1 FROM t1 WHERE i1 = 10.10; +i1 +10.10 +SELECT i2 FROM t1 WHERE i2 = 20.20; +i2 +20.2 +ALTER TABLE t1 ADD COLUMN j1 DECIMAL(5, 2) NOT NULL DEFAULT 100.00, ADD COLUMN j2 double NOT NULL DEFAULT 1000.5678; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'j1' OR name = 'j2') AND has_default = 1; +name default_value +j1 806400 +j2 5af5b9da8a448f40 +INSERT INTO t1(a, j1, j2) VALUES(0, 90.90, 1000.1234); +SELECT count(*) = max(a) FROM t1 WHERE j1 = 100.00; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE j2 = 1000.5678; +count(*) = max(a) +1 +SELECT j1 FROM t1 WHERE j1 = 90.90; +j1 +90.90 +SELECT j2 FROM t1 WHERE j2 = 1000.1234; +j2 +1000.1234 +ALTER TABLE t1 ADD COLUMN k1 BIT(8), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k1' AND has_default = 1; +name default_value +k1 NULL +INSERT INTO t1(a, k1) VALUES(0, b'010101'); +SELECT count(*) = max(a) FROM t1 WHERE k1 IS NULL; +count(*) = max(a) +1 +SELECT hex(k1) FROM t1 WHERE k1 = b'010101'; +hex(k1) +15 +ALTER TABLE t1 ADD COLUMN k2 BIT(8) NOT NULL DEFAULT b'101010'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k2' AND has_default = 1; +name default_value +k2 2a +INSERT INTO t1(a, k2) VALUES(0, b'110011'); +SELECT count(*) = max(a) FROM t1 WHERE k2 = b'101010'; +count(*) = max(a) +1 +SELECT hex(k2) FROM t1 WHERE k2 = b'110011'; +hex(k2) +33 +ALTER TABLE t1 ADD COLUMN l1 CHAR(50), ADD COLUMN l2 VARCHAR(100), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'l1' OR name = 'l2') AND has_default = 1; +name default_value +l1 NULL +l2 NULL +INSERT INTO t1(a, l1, l2) VALUES(0, 'ABCD EFGH', 'abcdefg hijklmn '); +SELECT count(*) = max(a) FROM t1 WHERE l2 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE l1 IS NULL; +count(*) = max(a) +1 +SELECT l1 FROM t1 WHERE l1 = 'ABCD EFGH'; +l1 +ABCD EFGH +SELECT l2 FROM t1 WHERE l2 = 'abcdefg hijklmn '; +l2 +abcdefg hijklmn +ALTER TABLE t1 ADD COLUMN m1 CHAR(50) default 'The fox jumps over', ADD COLUMN m2 VARCHAR(50) DEFAULT 'The fox jumps over the lazy dog.'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'm1' OR name = 'm2') AND has_default = 1; +name default_value +m1 54686520666f78206a756d7073206f7665722020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020 +m2 54686520666f78206a756d7073206f76657220746865206c617a7920646f672e +INSERT INTO t1(a, m1, m2) VALUES(0, 'over the lazy dog', 'The lazy dog jumps over the fox.'); +SELECT count(*) = max(a) FROM t1 WHERE m1 = 'The fox jumps over'; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE m2 like 'The fox jumps%'; +count(*) = max(a) +1 +SELECT m1 FROM t1 WHERE m1 = 'over the lazy dog'; +m1 +over the lazy dog +SELECT m2 FROM t1 WHERE m2 like '%the fox.'; +m2 +The lazy dog jumps over the fox. +ALTER TABLE t1 ADD COLUMN n1 BINARY(10), ADD COLUMN n2 VARBINARY(10), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'n1' OR name = 'n2') AND has_default = 1; +name default_value +n1 NULL +n2 NULL +INSERT INTO t1(a, n1, n2) VALUES(0, 0x010203040506070809, 0x102030405060708090); +SELECT count(*) = max(a) FROM t1 WHERE n1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE n2 IS NULL; +count(*) = max(a) +1 +SELECT hex(n1) FROM t1 WHERE n1 = 0x01020304050607080900; +hex(n1) +01020304050607080900 +SELECT hex(n2) FROM t1 WHERE n2 = 0x102030405060708090; +hex(n2) +102030405060708090 +ALTER TABLE t1 ADD COLUMN o1 BINARY(10) DEFAULT 0x11223344, ADD COLUMN o2 VARBINARY(10) DEFAULT 0x55667788; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'o1' OR name = 'o2') AND has_default = 1; +name default_value +o1 11223344000000000000 +o2 55667788 +INSERT INTO t1(a, o1, o2) VALUES(0, 0x44332211, 0x88776655); +SELECT count(*) = max(a) FROM t1 WHERE o1 = 0x11223344000000000000; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE o2 = 0x55667788; +count(*) = max(a) +1 +SELECT hex(o1) FROM t1 WHERE o1 = 0x44332211000000000000; +hex(o1) +44332211000000000000 +SELECT hex(o2) FROM t1 WHERE o2 = 0x88776655; +hex(o2) +88776655 +ALTER TABLE t1 ADD COLUMN p1 DATETIME, ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p1' AND has_default = 1; +name default_value +p1 NULL +INSERT INTO t1(a, p1) VALUES(0, '2017-12-31 00:00:00'); +SELECT count(*) = max(a) FROM t1 WHERE p1 IS NULL; +count(*) = max(a) +1 +SELECT p1 FROM t1 WHERE p1 = '2017-12-31 00:00:00'; +p1 +2017-12-31 00:00:00 +ALTER TABLE t1 ADD COLUMN p2 DATETIME NOT NULL DEFAULT '2017-12-31 01:02:03'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p2' AND has_default = 1; +name default_value +p2 999e7e1083 +SELECT count(*) = max(a) FROM t1 GROUP BY p2; +count(*) = max(a) +1 +INSERT INTO t1(a, p2) VALUES(0, now()); +SELECT count(*) FROM t1 GROUP BY p2; +count(*) +26 +1 +ALTER TABLE t1 ADD COLUMN q1 ENUM ('value1','value2','value3'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'q1' AND has_default = 1; +name default_value +q1 NULL +INSERT INTO t1(a, q1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE q1 IS NULL; +count(*) = max(a) +1 +SELECT q1 FROM t1 WHERE q1 = 1; +q1 +value1 +ALTER TABLE t1 ADD COLUMN r1 SET ('a','b','c'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'r1' AND has_default = 1; +name default_value +r1 NULL +INSERT INTO t1(a, r1) VALUES(0, 'a'); +SELECT count(*) = max(a) FROM t1 WHERE r1 IS NULL; +count(*) = max(a) +1 +SELECT r1 FROM t1 WHERE r1 = 'a'; +r1 +a +ALTER TABLE t1 ADD COLUMN s1 BLOB, ADD COLUMN s2 TEXT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 's1' OR name = 's2') AND has_default = 1; +name default_value +s1 NULL +s2 NULL +INSERT INTO t1(a, s1, s2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE s1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE s2 IS NULL; +count(*) = max(a) +1 +SELECT hex(s1) FROM t1 WHERE s1 = 0x0102030405; +hex(s1) +0102030405 +SELECT s2 FROM t1 WHERE s2 = 'abcd qwerty'; +s2 +abcd qwerty +ALTER TABLE t1 ADD COLUMN u1 BLOB NOT NULL, ADD COLUMN u2 TEXT NOT NULL; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'u1' OR name = 'u2') AND has_default = 1; +name default_value +u1 +u2 +INSERT INTO t1(a, u1, u2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE u1 = ''; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE u2 = ''; +count(*) = max(a) +1 +SELECT hex(u1) FROM t1 WHERE u1 = 0x0102030405; +hex(u1) +0102030405 +SELECT u2 FROM t1 WHERE u2 = 'abcd qwerty'; +u2 +abcd qwerty +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` int DEFAULT NULL, + `c2` int NOT NULL DEFAULT '10', + `d1` bigint DEFAULT NULL, + `d2` bigint NOT NULL DEFAULT '1234567890', + `e1` smallint DEFAULT NULL, + `e2` smallint NOT NULL DEFAULT '10', + `f1` tinyint DEFAULT NULL, + `f2` tinyint NOT NULL DEFAULT '123', + `g1` mediumint DEFAULT NULL, + `g2` mediumint NOT NULL DEFAULT '12345', + `h1` float DEFAULT NULL, + `h2` float NOT NULL DEFAULT '12.34', + `i1` decimal(5,2) DEFAULT NULL, + `i2` double DEFAULT NULL, + `j1` decimal(5,2) NOT NULL DEFAULT '100.00', + `j2` double NOT NULL DEFAULT '1000.5678', + `k1` bit(8) DEFAULT NULL, + `k2` bit(8) NOT NULL DEFAULT b'101010', + `l1` char(50) DEFAULT NULL, + `l2` varchar(100) DEFAULT NULL, + `m1` char(50) DEFAULT 'The fox jumps over', + `m2` varchar(50) DEFAULT 'The fox jumps over the lazy dog.', + `n1` binary(10) DEFAULT NULL, + `n2` varbinary(10) DEFAULT NULL, + `o1` binary(10) DEFAULT '"3D\0\0\0\0\0\0', + `o2` varbinary(10) DEFAULT 'Ufw?', + `p1` datetime DEFAULT NULL, + `p2` datetime NOT NULL DEFAULT '2017-12-31 01:02:03', + `q1` enum('value1','value2','value3') DEFAULT NULL, + `r1` set('a','b','c') DEFAULT NULL, + `s1` blob, + `s2` text, + `u1` blob NOT NULL, + `u2` text NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 2: +# Create a small table, add some columns instantly, along with +# virtual columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL, ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c) VALUES(0, 6, 20); +SELECT * FROM t1; +a b c d +1 1 0 2 +2 2 0 4 +3 3 0 6 +4 4 0 8 +5 5 0 10 +6 6 20 12 +ALTER TABLE t1 ADD COLUMN e VARCHAR(100) DEFAULT 'ABCD EFGH', ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(e)); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, c, e) VALUES(0, 20, 'Hello'), (0, 20, 'World'), (0, 20, 'Hello World'); +SELECT * FROM t1; +a b c d e f +1 1 0 2 ABCD EFGH 9 +2 2 0 4 ABCD EFGH 9 +3 3 0 6 ABCD EFGH 9 +4 4 0 8 ABCD EFGH 9 +5 5 0 10 ABCD EFGH 9 +6 6 20 12 ABCD EFGH 9 +7 NULL 20 NULL Hello 5 +8 NULL 20 NULL World 5 +9 NULL 20 NULL Hello World 11 +ALTER TABLE t1 ADD COLUMN g VARCHAR(100) GENERATED ALWAYS AS (e), ADD COLUMN h BIGINT DEFAULT 10000, ADD COLUMN i BIGINT GENERATED ALWAYS AS (h * 2 + b); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +INSERT INTO t1(a, b, c, h) VALUES(0, 7, 40, 2000), (0, 7, 40, 20000); +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +10 7 40 14 ABCD EFGH 9 ABCD EFGH 2000 4007 +11 7 40 14 ABCD EFGH 9 ABCD EFGH 20000 40007 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL, + `d` int GENERATED ALWAYS AS ((`b` * 2)) VIRTUAL, + `e` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`e`)) VIRTUAL, + `g` varchar(100) GENERATED ALWAYS AS (`e`) VIRTUAL, + `h` bigint DEFAULT '10000', + `i` bigint GENERATED ALWAYS AS (((`h` * 2) + `b`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 3: +# Create a small table, add some columns instantly, then change +# their default values, check original default values are correct +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +INSERT INTO t1(a, b, c, e) VALUES(0, 6, 200, 'Good day'), (0, 7, 300, 'Good DAY'); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND has_default = 1; +default_value +80000064 +ALTER TABLE t1 ALTER COLUMN c SET DEFAULT 500; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND +has_default = 1; +default_value +80000064 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +INSERT INTO t1(a, b) VALUES(0, 8), (0, 9); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +ALTER TABLE t1 ALTER COLUMN e SET DEFAULT 'HELLO MySQL!'; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +INSERT INTO t1(a, b) VALUES(0, 10), (0, 20); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +10 10 500 1010 HELLO MySQL! +11 20 500 1020 HELLO MySQL! +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '500', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'HELLO MySQL!', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 4: +# Create a small table, add some columns instantly, then do DML +# on the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 200 WHERE a > 3; +SELECT distinct(c) FROM t1; +c +100 +200 +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +DELETE FROM t1 WHERE c = 100; +UPDATE t1 SET c = 300; +SELECT distinct(c) FROM t1; +c +300 +SELECT count(*) FROM t1; +count(*) +16 +ALTER TABLE t1 ADD COLUMN t DATETIME DEFAULT CURRENT_TIMESTAMP; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 10; +UPDATE t1 SET e = 'Hello MySQL!!' WHERE a > 20; +SELECT distinct(e) FROM t1; +e +Hello world +Hello MySQL +Hello MySQL!! +UPDATE t1 SET c = 500 WHERE e LIKE '%world%'; +SELECT c, e FROM t1 GROUP BY c, e; +c e +300 Hello MySQL +300 Hello MySQL!! +500 Hello world +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET t = CURRENT_TIMESTAMP WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +16 +DELETE FROM t1 WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + `t` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 5: +# Create a small table, add some columns instantly, then do DDL +# to build indexes +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT c FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` +SELECT c FROM t1 WHERE c != 100; +c +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 30; +ALTER TABLE t1 ADD KEY(e); +EXPLAIN SELECT e FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL e # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`e` AS `e` from `test`.`t1` +SELECT count(e) FROM t1 WHERE e LIKE '%MySQL%'; +count(e) +17 +SELECT count(e) FROM t1 WHERE e LIKE '%world%'; +count(e) +23 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(a, c); +SELECT a, c, e FROM t1 WHERE a > 25 AND a < 40; +a c e +28 100 Hello world +29 100 Hello world +30 100 Hello world +31 100 Hello MySQL +32 100 Hello MySQL +33 100 Hello MySQL +34 100 Hello MySQL +35 100 Hello MySQL +36 100 Hello MySQL +37 100 Hello MySQL +38 100 Hello MySQL +39 100 Hello MySQL +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`,`c`), + KEY `c` (`c`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 6: +# Create a small table, add some columns instantly, then do DML +# on the table, and some simple rollback +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; +a b c +1 1 500 +2 1000 100 +ROLLBACK; +SELECT a, b, c FROM t1; +a b c +1 1 100 +2 2 100 +3 3 100 +4 4 100 +5 5 100 +START TRANSACTION; +DELETE FROM t1 WHERE a < 5; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +5 5 100 205 Hello world +7 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +CREATE TABLE t1(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000)) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(1, repeat('a', 4000), repeat('b', 4000), repeat('c', 1)); +SELECT id, length(c1), length(c2), length(c3) FROM t1; +id length(c1) length(c2) length(c3) +1 4000 4000 1 +ALTER TABLE t1 ADD COLUMN c4 VARCHAR(500) NOT NULL DEFAULT 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c1 = repeat('x', 200) WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c4 = 'x' WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +DROP TABLE t1; +# +# Scenario 7: +# Confirm some ADD COLUMN are instant, some are not +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100 AFTER b; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN e INT NOT NULL DEFAULT 100, ADD KEY(e); +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN f INT NOT NULL DEFAULT 100, FORCE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN g INT NOT NULL DEFAULT 100, ALGORITHM=INPLACE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `d` int NOT NULL DEFAULT '100', + `c` int NOT NULL DEFAULT '100', + `e` int NOT NULL DEFAULT '100', + `f` int NOT NULL DEFAULT '100', + `g` int NOT NULL DEFAULT '100', + PRIMARY KEY (`a`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c TEXT, FULLTEXT(c)) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1, 'Hello'), (0, 2, 'HELLO'), (0, 3, 'World'), (0, 4, 'Hello world'), (0, 5, 'HELLO WORLD'); +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 8: +# Check FK constraints on instantly added columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +CREATE TABLE t2(a INT NOT NULL PRIMARY KEY, b INT, c INT, KEY(c)); +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(1, 2, 3), (2, 3, 4), (3, 4, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 3; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 4 WHERE a = 2; +UPDATE t1 SET c = 5 WHERE a = 3; +ALTER TABLE t1 ADD KEY(c); +ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1(c) ON UPDATE CASCADE, ALGORITHM = COPY; +UPDATE t1 SET c = 10 WHERE a = 1; +SELECT c FROM t2; +c +10 +4 +5 +UPDATE t1 SET c = 10; +SELECT c FROM t2; +c +10 +10 +10 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '3', + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t2; +DROP TABLE t1; +# +# Scenario 9: +# Instant ADD COLUMN on partitioned table, only simple test here +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +3 3 5 +6 6 5 +1 1 5 +4 4 5 +7 7 5 +2 2 5 +5 5 5 +8 8 5 +INSERT INTO t1 VALUES(0, 9, 10), (0, 10, 20); +SELECT * FROM t1 WHERE b > 8; +a b c +9 9 10 +10 10 20 +UPDATE t1 SET c = 8 WHERE a = 1 OR a = 3 OR a = 5 OR a = 7; +SELECT * FROM t1; +a b c +3 3 8 +6 6 5 +9 9 10 +1 1 8 +4 4 5 +7 7 8 +10 10 20 +2 2 5 +5 5 8 +8 8 5 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +/*!50100 PARTITION BY HASH (`a`) +PARTITIONS 3 */ +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ROW_FORMAT=REDUNDANT PARTITION BY HASH(a) PARTITIONS 2;; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE COLUMN c c1 INT; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 10: +# EXCHANGE PARTITION is not allowed if either is instant +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5) ROW_FORMAT=REDUNDANT PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30));; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +ALTER TABLE t2 ADD COLUMN d INT; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INPLACE; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +/*!50100 PARTITION BY RANGE (`a`) +(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN (20) ENGINE = InnoDB, + PARTITION p3 VALUES LESS THAN (30) ENGINE = InnoDB) */ +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +DROP TABLE t1, t2; +# +# Scenario 11: +# PRIMARY KEY with more than one column, at least to verify it works with REDUDANT +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a, b)) ROW_FORMAT=REDUNDANT;; +INSERT INTO t1 VALUES(0, 1), (1, 2), (2, 3), (3, 4); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 5 +1 2 5 +2 3 5 +3 4 5 +UPDATE t1 SET c = b WHERE b <= 2; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 1 +1 2 2 +2 3 5 +3 4 5 +DROP TABLE t1; +# +# Scenario 12: +# Mix ALTER PARTITION and ALTER TABLE ... INPLACE. This is to check if first partition is not +# instant after ALTER PARTITION, will the metadata be copied correctly +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 TEXT) ENGINE = InnoDB PARTITION BY RANGE(col1 * 2) ( PARTITION p0 VALUES LESS THAN (128), PARTITION p1 VALUES LESS THAN (256) , PARTITION p2 VALUES LESS THAN (384) , PARTITION p3 VALUES LESS THAN MAXVALUE);; +INSERT INTO t1 VALUES(1, 2, 3, 'abcdefg'), (100, 200, 300, 'qwerty'), (200, 300, 400, 'asdfg'); +ALTER TABLE t1 ALGORITHM DEFAULT, ADD COLUMN col5 VARCHAR(500), ADD COLUMN col6 TEXT; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 4` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 4 +4 +ALTER TABLE t1 ALGORITHM INPLACE, REORGANIZE PARTITION p0 INTO (PARTITION p0_a VALUES LESS THAN (64), PARTITION p0_b VALUES LESS THAN (128)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, ADD KEY idx4(col4(10)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, LOCK EXCLUSIVE, REORGANIZE PARTITION p0_a, p0_b INTO (PARTITION p0 VALUES LESS THAN (128) TABLESPACE innodb_file_per_table); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY idx3(col3); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +col1 col2 col3 col4 col5 col6 +1 2 3 abcdefg NULL NULL +100 200 300 qwerty NULL NULL +200 300 400 asdfg NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +ALTER TABLE t1 ADD PARTITION PARTITIONS 10; +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(b); +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +1 1 5 +2 2 5 +3 3 5 +4 4 5 +5 5 5 +6 6 5 +7 7 5 +8 8 5 +DROP TABLE t1; +# +# Scenario 13: +# Create a table with a two level clustered index, do instant ADD COLUMN, then the non-leaf node +# should be parsed correctly +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, d INT NOT NULL, b BLOB NOT NULL, c VARCHAR(87), INDEX(d), INDEX(a ASC), PRIMARY KEY (a, d DESC, c DESC)) ROW_FORMAT=REDUNDANT PARTITION BY LINEAR KEY(c) PARTITIONS 9;; +INSERT INTO t1(d, b, c) VALUES(1, 2, 'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(2, 3, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(3, 4, 'bbbbbbbbbbaaaaaaaaaahhhhhhhhhhccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(4, 5, 'eeeeeeeeeehhhhhhhhhhbbbbbbbbbbccccccccccddddddddddaaaaaaaaaaffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(5, 6, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbddddddddddcccccccccceeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(6, 7, 'cccccccccchhhhhhhhhhbbbbbbbbbbaaaaaaaaaaddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +ALTER TABLE t1 ADD COLUMN nc086 BIGINT NOT NULL FIRST, ALGORITHM=INPLACE, LOCK=DEFAULT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN nc082 TINYTEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +384 +DROP TABLE t1; +# +# Scenario 14: +# Create a small table, and add GIS kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 POINT, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, ST_PointFromText('POINT(10 10)')); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN d1 LINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN e1 POLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN f1 MULTIPOINT, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN g1 MULTILINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN h1 MULTIPOLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN i1 GEOMETRYCOLLECTION, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'i1' AND has_default = 1; +name default_value +i1 NULL +INSERT INTO t1(a, i1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN j1 GEOMETRY, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'j1' AND has_default = 1; +name default_value +j1 NULL +INSERT INTO t1(a, j1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE j1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` point DEFAULT NULL, + `d1` linestring DEFAULT NULL, + `e1` polygon DEFAULT NULL, + `f1` multipoint DEFAULT NULL, + `g1` multilinestring DEFAULT NULL, + `h1` multipolygon DEFAULT NULL, + `i1` geomcollection DEFAULT NULL, + `j1` geometry DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 15: +# Create a small table, and add JSON columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 JSON, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, '{"key1": "value1", "key2": "value2"}'); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` json DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 16: +# Create a small table, and add INSTANT columns and verify with trigger +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +INSERT INTO t2 VALUES(0,6); +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP TRIGGER t1_ai; +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 63636363 +CREATE TRIGGER t2_ai AFTER INSERT ON t2 FOR EACH ROW +INSERT INTO t1(a,c1) VALUES(0,'eeee'); +INSERT INTO t2(a, c1) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t2 WHERE c1='cccc'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'dddd'; +c1 +dddd +DROP TRIGGER t2_ai; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1,t2; +# +# Scenario 17: +# Create a small table, and add INSTANT columns and verify with storedprocedure +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE PROCEDURE p1() INSERT INTO t1(a,c1) VALUES(0, 'bbbb'); +CALL p1(); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP PROCEDURE p1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 18: +# Create a small table, and add INSTANT columns and verify with view +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +SELECT * FROM v1; +a b c1 +1 1 aaaa +2 2 aaaa +3 3 aaaa +4 4 aaaa +5 5 aaaa +6 NULL bbbb +DROP VIEW v1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 19: +# Create a small table, and add INSTANT columns and drop it and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 DROP COLUMN c1; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 20: +# Create a small table, and add INSTANT columns and rename table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 RENAME t2; +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t2(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t2 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'bbbb'; +c1 +bbbb +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t2; +# +# Scenario 21: +# Create a small table, and add INSTANT columns and change its data type INSTANTly won't work +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 CHANGE c1 c2 CHAR(10) NOT NULL DEFAULT 'cccc'; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c2` char(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 22: +# Create a small table, and add INSTANT columns and create hash,btree multi column index and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE INDEX id1 ON t1(c1) USING BTREE; +CREATE INDEX id2 ON t1(c1) USING HASH; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +Warning 1831 Duplicate index 'id2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP INDEX id1 ON t1; +DROP INDEX id2 ON t1; +ALTER TABLE t1 ADD COLUMN c2 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 63636363 +CREATE INDEX id1 ON t1(c1 ASC,c2 DESC) USING BTREE; +INSERT INTO t1(a, c2) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t1 WHERE c1='cccc'; +count(*) = max(a) +NULL +SELECT c1 FROM t1 WHERE c1 = 'dddd'; +c1 +ALTER TABLE t1 RENAME INDEX id1 TO id2; +DROP INDEX id2 ON t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + `c2` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +# +# Scenario 23: +# Create a small table, and add INSTANT columns and perform table join operation +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'cccc'; +c1 +cccc +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'bbbb', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 62626262 +INSERT INTO t2(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t2 WHERE c1='bbbb'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'cccc'; +c1 +cccc +SELECT * FROM t1 JOIN t2 ON t1.c1=t2.c1; +a b c1 a b c1 +6 NULL cccc 6 NULL cccc +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'bbbb', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +DROP TABLE t2; +# +# Scenario 24: +# Create a small table, and add stored and(or) virtual columns +# after last stored column in the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT, d INT GENERATED ALWAYS AS (b + c) VIRTUAL, e INT GENERATED ALWAYS AS (b * c) VIRTUAL) ROW_FORMAT=REDUNDANT; +INSERT INTO t1(a, b, c) VALUES(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 5, 6); +ALTER TABLE t1 ADD COLUMN h INT NOT NULL AFTER c; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h) VALUES(0, 6, 20, 40); +SELECT * FROM t1; +a b c h d e +1 1 2 0 3 2 +2 2 3 0 5 6 +3 3 4 0 7 12 +4 4 5 0 9 20 +5 5 6 0 11 30 +6 6 20 40 26 120 +ALTER TABLE t1 ADD COLUMN i VARCHAR(100) DEFAULT 'ABCD EFGH' AFTER h, ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(i)) AFTER i; +Table id did not change +SELECT 3 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h, i) VALUES(0, 20, 30, 50, 'qwerty'); +SELECT * FROM t1; +a b c h i f d e +1 1 2 0 ABCD EFGH 9 3 2 +2 2 3 0 ABCD EFGH 9 5 6 +3 3 4 0 ABCD EFGH 9 7 12 +4 4 5 0 ABCD EFGH 9 9 20 +5 5 6 0 ABCD EFGH 9 11 30 +6 6 20 40 ABCD EFGH 9 26 120 +7 20 30 50 qwerty 6 50 600 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + `h` int NOT NULL, + `i` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`i`)) VIRTUAL, + `d` int GENERATED ALWAYS AS ((`b` + `c`)) VIRTUAL, + `e` int GENERATED ALWAYS AS ((`b` * `c`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=REDUNDANT +DROP TABLE t1; +############################################ +# Test instant ADD COLUMN for DYNAMIC format +############################################ +# +# Scenario 1: +# Create a small table, and add all kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 INT, ALGORITHM=INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 1; +c1 +1 +ALTER TABLE t1 ADD COLUMN c2 INT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 8000000a +INSERT INTO t1(a, c2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE c2 = 10; +count(*) = max(a) +1 +SELECT c2 FROM t1 WHERE c2 = 11; +c2 +11 +ALTER TABLE t1 ADD COLUMN d1 BIGINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +SELECT d1 FROM t1 WHERE d1 = 1; +d1 +1 +ALTER TABLE t1 ADD COLUMN d2 BIGINT NOT NULL DEFAULT 1234567890; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd2' AND has_default = 1; +name default_value +d2 80000000499602d2 +INSERT INTO t1(a, d2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE d2 = 1234567890; +count(*) = max(a) +1 +SELECT d2 FROM t1 WHERE d2 = 1234; +d2 +1234 +ALTER TABLE t1 ADD COLUMN e1 SMALLINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +SELECT e1 FROM t1 WHERE e1 = 1; +e1 +1 +ALTER TABLE t1 ADD COLUMN e2 SMALLINT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e2' AND has_default = 1; +name default_value +e2 800a +INSERT INTO t1(a, e2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE e2 = 10; +count(*) = max(a) +1 +SELECT e2 FROM t1 WHERE e2 = 11; +e2 +11 +ALTER TABLE t1 ADD COLUMN f1 TINYINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +SELECT f1 FROM t1 WHERE f1 = 1; +f1 +1 +ALTER TABLE t1 ADD COLUMN f2 TINYINT NOT NULL DEFAULT 123; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f2' AND has_default = 1; +name default_value +f2 fb +INSERT INTO t1(a, f2) VALUES(0, 12); +SELECT count(*) = max(a) FROM t1 WHERE f2 = 123; +count(*) = max(a) +1 +SELECT f2 FROM t1 WHERE f2 = 12; +f2 +12 +ALTER TABLE t1 ADD COLUMN g1 MEDIUMINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +SELECT g1 FROM t1 WHERE g1 = 1; +g1 +1 +ALTER TABLE t1 ADD COLUMN g2 MEDIUMINT NOT NULL DEFAULT 12345; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g2' AND has_default = 1; +name default_value +g2 803039 +INSERT INTO t1(a, g2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE g2 = 12345; +count(*) = max(a) +1 +SELECT g2 FROM t1 WHERE g2 = 1234; +g2 +1234 +ALTER TABLE t1 ADD COLUMN h1 FLOAT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, 1.0); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +SELECT h1 FROM t1 WHERE h1 = 1; +h1 +1 +ALTER TABLE t1 ADD COLUMN h2 FLOAT NOT NULL DEFAULT 12.34; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h2' AND has_default = 1; +name default_value +h2 a4704541 +INSERT INTO t1(a, h2) VALUES(0, 1.234); +SELECT count(*) = max(a) FROM t1 WHERE h2 = 12.34; +count(*) = max(a) +NULL +SELECT h2 FROM t1 WHERE h2 = 1.234; +h2 +ALTER TABLE t1 ADD COLUMN i1 DECIMAL(5, 2), ADD COLUMN i2 double, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'i1' OR name = 'i2') AND has_default = 1; +name default_value +i1 NULL +i2 NULL +INSERT INTO t1(a, i1, i2) VALUES(0, 10.10, 20.20); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE i2 IS NULL; +count(*) = max(a) +1 +SELECT i1 FROM t1 WHERE i1 = 10.10; +i1 +10.10 +SELECT i2 FROM t1 WHERE i2 = 20.20; +i2 +20.2 +ALTER TABLE t1 ADD COLUMN j1 DECIMAL(5, 2) NOT NULL DEFAULT 100.00, ADD COLUMN j2 double NOT NULL DEFAULT 1000.5678; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'j1' OR name = 'j2') AND has_default = 1; +name default_value +j1 806400 +j2 5af5b9da8a448f40 +INSERT INTO t1(a, j1, j2) VALUES(0, 90.90, 1000.1234); +SELECT count(*) = max(a) FROM t1 WHERE j1 = 100.00; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE j2 = 1000.5678; +count(*) = max(a) +1 +SELECT j1 FROM t1 WHERE j1 = 90.90; +j1 +90.90 +SELECT j2 FROM t1 WHERE j2 = 1000.1234; +j2 +1000.1234 +ALTER TABLE t1 ADD COLUMN k1 BIT(8), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k1' AND has_default = 1; +name default_value +k1 NULL +INSERT INTO t1(a, k1) VALUES(0, b'010101'); +SELECT count(*) = max(a) FROM t1 WHERE k1 IS NULL; +count(*) = max(a) +1 +SELECT hex(k1) FROM t1 WHERE k1 = b'010101'; +hex(k1) +15 +ALTER TABLE t1 ADD COLUMN k2 BIT(8) NOT NULL DEFAULT b'101010'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k2' AND has_default = 1; +name default_value +k2 2a +INSERT INTO t1(a, k2) VALUES(0, b'110011'); +SELECT count(*) = max(a) FROM t1 WHERE k2 = b'101010'; +count(*) = max(a) +1 +SELECT hex(k2) FROM t1 WHERE k2 = b'110011'; +hex(k2) +33 +ALTER TABLE t1 ADD COLUMN l1 CHAR(50), ADD COLUMN l2 VARCHAR(100), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'l1' OR name = 'l2') AND has_default = 1; +name default_value +l1 NULL +l2 NULL +INSERT INTO t1(a, l1, l2) VALUES(0, 'ABCD EFGH', 'abcdefg hijklmn '); +SELECT count(*) = max(a) FROM t1 WHERE l2 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE l1 IS NULL; +count(*) = max(a) +1 +SELECT l1 FROM t1 WHERE l1 = 'ABCD EFGH'; +l1 +ABCD EFGH +SELECT l2 FROM t1 WHERE l2 = 'abcdefg hijklmn '; +l2 +abcdefg hijklmn +ALTER TABLE t1 ADD COLUMN m1 CHAR(50) default 'The fox jumps over', ADD COLUMN m2 VARCHAR(50) DEFAULT 'The fox jumps over the lazy dog.'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'm1' OR name = 'm2') AND has_default = 1; +name default_value +m1 54686520666f78206a756d7073206f7665722020202020202020202020202020202020202020202020202020202020202020 +m2 54686520666f78206a756d7073206f76657220746865206c617a7920646f672e +INSERT INTO t1(a, m1, m2) VALUES(0, 'over the lazy dog', 'The lazy dog jumps over the fox.'); +SELECT count(*) = max(a) FROM t1 WHERE m1 = 'The fox jumps over'; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE m2 like 'The fox jumps%'; +count(*) = max(a) +1 +SELECT m1 FROM t1 WHERE m1 = 'over the lazy dog'; +m1 +over the lazy dog +SELECT m2 FROM t1 WHERE m2 like '%the fox.'; +m2 +The lazy dog jumps over the fox. +ALTER TABLE t1 ADD COLUMN n1 BINARY(10), ADD COLUMN n2 VARBINARY(10), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'n1' OR name = 'n2') AND has_default = 1; +name default_value +n1 NULL +n2 NULL +INSERT INTO t1(a, n1, n2) VALUES(0, 0x010203040506070809, 0x102030405060708090); +SELECT count(*) = max(a) FROM t1 WHERE n1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE n2 IS NULL; +count(*) = max(a) +1 +SELECT hex(n1) FROM t1 WHERE n1 = 0x01020304050607080900; +hex(n1) +01020304050607080900 +SELECT hex(n2) FROM t1 WHERE n2 = 0x102030405060708090; +hex(n2) +102030405060708090 +ALTER TABLE t1 ADD COLUMN o1 BINARY(10) DEFAULT 0x11223344, ADD COLUMN o2 VARBINARY(10) DEFAULT 0x55667788; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'o1' OR name = 'o2') AND has_default = 1; +name default_value +o1 11223344000000000000 +o2 55667788 +INSERT INTO t1(a, o1, o2) VALUES(0, 0x44332211, 0x88776655); +SELECT count(*) = max(a) FROM t1 WHERE o1 = 0x11223344000000000000; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE o2 = 0x55667788; +count(*) = max(a) +1 +SELECT hex(o1) FROM t1 WHERE o1 = 0x44332211000000000000; +hex(o1) +44332211000000000000 +SELECT hex(o2) FROM t1 WHERE o2 = 0x88776655; +hex(o2) +88776655 +ALTER TABLE t1 ADD COLUMN p1 DATETIME, ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p1' AND has_default = 1; +name default_value +p1 NULL +INSERT INTO t1(a, p1) VALUES(0, '2017-12-31 00:00:00'); +SELECT count(*) = max(a) FROM t1 WHERE p1 IS NULL; +count(*) = max(a) +1 +SELECT p1 FROM t1 WHERE p1 = '2017-12-31 00:00:00'; +p1 +2017-12-31 00:00:00 +ALTER TABLE t1 ADD COLUMN p2 DATETIME NOT NULL DEFAULT '2017-12-31 01:02:03'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p2' AND has_default = 1; +name default_value +p2 999e7e1083 +SELECT count(*) = max(a) FROM t1 GROUP BY p2; +count(*) = max(a) +1 +INSERT INTO t1(a, p2) VALUES(0, now()); +SELECT count(*) FROM t1 GROUP BY p2; +count(*) +26 +1 +ALTER TABLE t1 ADD COLUMN q1 ENUM ('value1','value2','value3'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'q1' AND has_default = 1; +name default_value +q1 NULL +INSERT INTO t1(a, q1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE q1 IS NULL; +count(*) = max(a) +1 +SELECT q1 FROM t1 WHERE q1 = 1; +q1 +value1 +ALTER TABLE t1 ADD COLUMN r1 SET ('a','b','c'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'r1' AND has_default = 1; +name default_value +r1 NULL +INSERT INTO t1(a, r1) VALUES(0, 'a'); +SELECT count(*) = max(a) FROM t1 WHERE r1 IS NULL; +count(*) = max(a) +1 +SELECT r1 FROM t1 WHERE r1 = 'a'; +r1 +a +ALTER TABLE t1 ADD COLUMN s1 BLOB, ADD COLUMN s2 TEXT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 's1' OR name = 's2') AND has_default = 1; +name default_value +s1 NULL +s2 NULL +INSERT INTO t1(a, s1, s2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE s1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE s2 IS NULL; +count(*) = max(a) +1 +SELECT hex(s1) FROM t1 WHERE s1 = 0x0102030405; +hex(s1) +0102030405 +SELECT s2 FROM t1 WHERE s2 = 'abcd qwerty'; +s2 +abcd qwerty +ALTER TABLE t1 ADD COLUMN u1 BLOB NOT NULL, ADD COLUMN u2 TEXT NOT NULL; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'u1' OR name = 'u2') AND has_default = 1; +name default_value +u1 +u2 +INSERT INTO t1(a, u1, u2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE u1 = ''; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE u2 = ''; +count(*) = max(a) +1 +SELECT hex(u1) FROM t1 WHERE u1 = 0x0102030405; +hex(u1) +0102030405 +SELECT u2 FROM t1 WHERE u2 = 'abcd qwerty'; +u2 +abcd qwerty +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` int DEFAULT NULL, + `c2` int NOT NULL DEFAULT '10', + `d1` bigint DEFAULT NULL, + `d2` bigint NOT NULL DEFAULT '1234567890', + `e1` smallint DEFAULT NULL, + `e2` smallint NOT NULL DEFAULT '10', + `f1` tinyint DEFAULT NULL, + `f2` tinyint NOT NULL DEFAULT '123', + `g1` mediumint DEFAULT NULL, + `g2` mediumint NOT NULL DEFAULT '12345', + `h1` float DEFAULT NULL, + `h2` float NOT NULL DEFAULT '12.34', + `i1` decimal(5,2) DEFAULT NULL, + `i2` double DEFAULT NULL, + `j1` decimal(5,2) NOT NULL DEFAULT '100.00', + `j2` double NOT NULL DEFAULT '1000.5678', + `k1` bit(8) DEFAULT NULL, + `k2` bit(8) NOT NULL DEFAULT b'101010', + `l1` char(50) DEFAULT NULL, + `l2` varchar(100) DEFAULT NULL, + `m1` char(50) DEFAULT 'The fox jumps over', + `m2` varchar(50) DEFAULT 'The fox jumps over the lazy dog.', + `n1` binary(10) DEFAULT NULL, + `n2` varbinary(10) DEFAULT NULL, + `o1` binary(10) DEFAULT '"3D\0\0\0\0\0\0', + `o2` varbinary(10) DEFAULT 'Ufw?', + `p1` datetime DEFAULT NULL, + `p2` datetime NOT NULL DEFAULT '2017-12-31 01:02:03', + `q1` enum('value1','value2','value3') DEFAULT NULL, + `r1` set('a','b','c') DEFAULT NULL, + `s1` blob, + `s2` text, + `u1` blob NOT NULL, + `u2` text NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 2: +# Create a small table, add some columns instantly, along with +# virtual columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL, ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c) VALUES(0, 6, 20); +SELECT * FROM t1; +a b c d +1 1 0 2 +2 2 0 4 +3 3 0 6 +4 4 0 8 +5 5 0 10 +6 6 20 12 +ALTER TABLE t1 ADD COLUMN e VARCHAR(100) DEFAULT 'ABCD EFGH', ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(e)); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, c, e) VALUES(0, 20, 'Hello'), (0, 20, 'World'), (0, 20, 'Hello World'); +SELECT * FROM t1; +a b c d e f +1 1 0 2 ABCD EFGH 9 +2 2 0 4 ABCD EFGH 9 +3 3 0 6 ABCD EFGH 9 +4 4 0 8 ABCD EFGH 9 +5 5 0 10 ABCD EFGH 9 +6 6 20 12 ABCD EFGH 9 +7 NULL 20 NULL Hello 5 +8 NULL 20 NULL World 5 +9 NULL 20 NULL Hello World 11 +ALTER TABLE t1 ADD COLUMN g VARCHAR(100) GENERATED ALWAYS AS (e), ADD COLUMN h BIGINT DEFAULT 10000, ADD COLUMN i BIGINT GENERATED ALWAYS AS (h * 2 + b); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +INSERT INTO t1(a, b, c, h) VALUES(0, 7, 40, 2000), (0, 7, 40, 20000); +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +10 7 40 14 ABCD EFGH 9 ABCD EFGH 2000 4007 +11 7 40 14 ABCD EFGH 9 ABCD EFGH 20000 40007 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL, + `d` int GENERATED ALWAYS AS ((`b` * 2)) VIRTUAL, + `e` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`e`)) VIRTUAL, + `g` varchar(100) GENERATED ALWAYS AS (`e`) VIRTUAL, + `h` bigint DEFAULT '10000', + `i` bigint GENERATED ALWAYS AS (((`h` * 2) + `b`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 3: +# Create a small table, add some columns instantly, then change +# their default values, check original default values are correct +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +INSERT INTO t1(a, b, c, e) VALUES(0, 6, 200, 'Good day'), (0, 7, 300, 'Good DAY'); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND has_default = 1; +default_value +80000064 +ALTER TABLE t1 ALTER COLUMN c SET DEFAULT 500; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND +has_default = 1; +default_value +80000064 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +INSERT INTO t1(a, b) VALUES(0, 8), (0, 9); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +ALTER TABLE t1 ALTER COLUMN e SET DEFAULT 'HELLO MySQL!'; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +INSERT INTO t1(a, b) VALUES(0, 10), (0, 20); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +10 10 500 1010 HELLO MySQL! +11 20 500 1020 HELLO MySQL! +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '500', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'HELLO MySQL!', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 4: +# Create a small table, add some columns instantly, then do DML +# on the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 200 WHERE a > 3; +SELECT distinct(c) FROM t1; +c +100 +200 +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +DELETE FROM t1 WHERE c = 100; +UPDATE t1 SET c = 300; +SELECT distinct(c) FROM t1; +c +300 +SELECT count(*) FROM t1; +count(*) +16 +ALTER TABLE t1 ADD COLUMN t DATETIME DEFAULT CURRENT_TIMESTAMP; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 10; +UPDATE t1 SET e = 'Hello MySQL!!' WHERE a > 20; +SELECT distinct(e) FROM t1; +e +Hello world +Hello MySQL +Hello MySQL!! +UPDATE t1 SET c = 500 WHERE e LIKE '%world%'; +SELECT c, e FROM t1 GROUP BY c, e; +c e +300 Hello MySQL +300 Hello MySQL!! +500 Hello world +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET t = CURRENT_TIMESTAMP WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +16 +DELETE FROM t1 WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + `t` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 5: +# Create a small table, add some columns instantly, then do DDL +# to build indexes +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT c FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` +SELECT c FROM t1 WHERE c != 100; +c +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 30; +ALTER TABLE t1 ADD KEY(e); +EXPLAIN SELECT e FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL e # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`e` AS `e` from `test`.`t1` +SELECT count(e) FROM t1 WHERE e LIKE '%MySQL%'; +count(e) +17 +SELECT count(e) FROM t1 WHERE e LIKE '%world%'; +count(e) +23 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(a, c); +SELECT a, c, e FROM t1 WHERE a > 25 AND a < 40; +a c e +28 100 Hello world +29 100 Hello world +30 100 Hello world +31 100 Hello MySQL +32 100 Hello MySQL +33 100 Hello MySQL +34 100 Hello MySQL +35 100 Hello MySQL +36 100 Hello MySQL +37 100 Hello MySQL +38 100 Hello MySQL +39 100 Hello MySQL +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`,`c`), + KEY `c` (`c`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 6: +# Create a small table, add some columns instantly, then do DML +# on the table, and some simple rollback +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; +a b c +1 1 500 +2 1000 100 +ROLLBACK; +SELECT a, b, c FROM t1; +a b c +1 1 100 +2 2 100 +3 3 100 +4 4 100 +5 5 100 +START TRANSACTION; +DELETE FROM t1 WHERE a < 5; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +5 5 100 205 Hello world +7 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +CREATE TABLE t1(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000)) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(1, repeat('a', 4000), repeat('b', 4000), repeat('c', 1)); +SELECT id, length(c1), length(c2), length(c3) FROM t1; +id length(c1) length(c2) length(c3) +1 4000 4000 1 +ALTER TABLE t1 ADD COLUMN c4 VARCHAR(500) NOT NULL DEFAULT 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c1 = repeat('x', 200) WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c4 = 'x' WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +DROP TABLE t1; +# +# Scenario 7: +# Confirm some ADD COLUMN are instant, some are not +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100 AFTER b; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN e INT NOT NULL DEFAULT 100, ADD KEY(e); +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN f INT NOT NULL DEFAULT 100, FORCE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN g INT NOT NULL DEFAULT 100, ALGORITHM=INPLACE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `d` int NOT NULL DEFAULT '100', + `c` int NOT NULL DEFAULT '100', + `e` int NOT NULL DEFAULT '100', + `f` int NOT NULL DEFAULT '100', + `g` int NOT NULL DEFAULT '100', + PRIMARY KEY (`a`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c TEXT, FULLTEXT(c)) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1, 'Hello'), (0, 2, 'HELLO'), (0, 3, 'World'), (0, 4, 'Hello world'), (0, 5, 'HELLO WORLD'); +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 8: +# Check FK constraints on instantly added columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +CREATE TABLE t2(a INT NOT NULL PRIMARY KEY, b INT, c INT, KEY(c)); +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(1, 2, 3), (2, 3, 4), (3, 4, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 3; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 4 WHERE a = 2; +UPDATE t1 SET c = 5 WHERE a = 3; +ALTER TABLE t1 ADD KEY(c); +ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1(c) ON UPDATE CASCADE, ALGORITHM = COPY; +UPDATE t1 SET c = 10 WHERE a = 1; +SELECT c FROM t2; +c +10 +4 +5 +UPDATE t1 SET c = 10; +SELECT c FROM t2; +c +10 +10 +10 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '3', + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t2; +DROP TABLE t1; +# +# Scenario 9: +# Instant ADD COLUMN on partitioned table, only simple test here +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +3 3 5 +6 6 5 +1 1 5 +4 4 5 +7 7 5 +2 2 5 +5 5 5 +8 8 5 +INSERT INTO t1 VALUES(0, 9, 10), (0, 10, 20); +SELECT * FROM t1 WHERE b > 8; +a b c +9 9 10 +10 10 20 +UPDATE t1 SET c = 8 WHERE a = 1 OR a = 3 OR a = 5 OR a = 7; +SELECT * FROM t1; +a b c +3 3 8 +6 6 5 +9 9 10 +1 1 8 +4 4 5 +7 7 8 +10 10 20 +2 2 5 +5 5 8 +8 8 5 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +/*!50100 PARTITION BY HASH (`a`) +PARTITIONS 3 */ +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ROW_FORMAT=DYNAMIC PARTITION BY HASH(a) PARTITIONS 2;; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE COLUMN c c1 INT; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 10: +# EXCHANGE PARTITION is not allowed if either is instant +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5) ROW_FORMAT=DYNAMIC PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30));; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +ALTER TABLE t2 ADD COLUMN d INT; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INPLACE; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +/*!50100 PARTITION BY RANGE (`a`) +(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN (20) ENGINE = InnoDB, + PARTITION p3 VALUES LESS THAN (30) ENGINE = InnoDB) */ +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +DROP TABLE t1, t2; +# +# Scenario 11: +# PRIMARY KEY with more than one column, at least to verify it works with REDUDANT +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a, b)) ROW_FORMAT=DYNAMIC;; +INSERT INTO t1 VALUES(0, 1), (1, 2), (2, 3), (3, 4); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 5 +1 2 5 +2 3 5 +3 4 5 +UPDATE t1 SET c = b WHERE b <= 2; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 1 +1 2 2 +2 3 5 +3 4 5 +DROP TABLE t1; +# +# Scenario 12: +# Mix ALTER PARTITION and ALTER TABLE ... INPLACE. This is to check if first partition is not +# instant after ALTER PARTITION, will the metadata be copied correctly +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 TEXT) ENGINE = InnoDB PARTITION BY RANGE(col1 * 2) ( PARTITION p0 VALUES LESS THAN (128), PARTITION p1 VALUES LESS THAN (256) , PARTITION p2 VALUES LESS THAN (384) , PARTITION p3 VALUES LESS THAN MAXVALUE);; +INSERT INTO t1 VALUES(1, 2, 3, 'abcdefg'), (100, 200, 300, 'qwerty'), (200, 300, 400, 'asdfg'); +ALTER TABLE t1 ALGORITHM DEFAULT, ADD COLUMN col5 VARCHAR(500), ADD COLUMN col6 TEXT; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 4` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 4 +4 +ALTER TABLE t1 ALGORITHM INPLACE, REORGANIZE PARTITION p0 INTO (PARTITION p0_a VALUES LESS THAN (64), PARTITION p0_b VALUES LESS THAN (128)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, ADD KEY idx4(col4(10)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, LOCK EXCLUSIVE, REORGANIZE PARTITION p0_a, p0_b INTO (PARTITION p0 VALUES LESS THAN (128) TABLESPACE innodb_file_per_table); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY idx3(col3); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +col1 col2 col3 col4 col5 col6 +1 2 3 abcdefg NULL NULL +100 200 300 qwerty NULL NULL +200 300 400 asdfg NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +ALTER TABLE t1 ADD PARTITION PARTITIONS 10; +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(b); +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +1 1 5 +2 2 5 +3 3 5 +4 4 5 +5 5 5 +6 6 5 +7 7 5 +8 8 5 +DROP TABLE t1; +# +# Scenario 13: +# Create a table with a two level clustered index, do instant ADD COLUMN, then the non-leaf node +# should be parsed correctly +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, d INT NOT NULL, b BLOB NOT NULL, c VARCHAR(87), INDEX(d), INDEX(a ASC), PRIMARY KEY (a, d DESC, c DESC)) ROW_FORMAT=DYNAMIC PARTITION BY LINEAR KEY(c) PARTITIONS 9;; +INSERT INTO t1(d, b, c) VALUES(1, 2, 'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(2, 3, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(3, 4, 'bbbbbbbbbbaaaaaaaaaahhhhhhhhhhccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(4, 5, 'eeeeeeeeeehhhhhhhhhhbbbbbbbbbbccccccccccddddddddddaaaaaaaaaaffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(5, 6, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbddddddddddcccccccccceeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(6, 7, 'cccccccccchhhhhhhhhhbbbbbbbbbbaaaaaaaaaaddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +ALTER TABLE t1 ADD COLUMN nc086 BIGINT NOT NULL FIRST, ALGORITHM=INPLACE, LOCK=DEFAULT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN nc082 TINYTEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +384 +DROP TABLE t1; +# +# Scenario 14: +# Create a small table, and add GIS kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 POINT, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, ST_PointFromText('POINT(10 10)')); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN d1 LINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN e1 POLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN f1 MULTIPOINT, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN g1 MULTILINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN h1 MULTIPOLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN i1 GEOMETRYCOLLECTION, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'i1' AND has_default = 1; +name default_value +i1 NULL +INSERT INTO t1(a, i1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN j1 GEOMETRY, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'j1' AND has_default = 1; +name default_value +j1 NULL +INSERT INTO t1(a, j1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE j1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` point DEFAULT NULL, + `d1` linestring DEFAULT NULL, + `e1` polygon DEFAULT NULL, + `f1` multipoint DEFAULT NULL, + `g1` multilinestring DEFAULT NULL, + `h1` multipolygon DEFAULT NULL, + `i1` geomcollection DEFAULT NULL, + `j1` geometry DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 15: +# Create a small table, and add JSON columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 JSON, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, '{"key1": "value1", "key2": "value2"}'); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` json DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 16: +# Create a small table, and add INSTANT columns and verify with trigger +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +INSERT INTO t2 VALUES(0,6); +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP TRIGGER t1_ai; +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 63636363 +CREATE TRIGGER t2_ai AFTER INSERT ON t2 FOR EACH ROW +INSERT INTO t1(a,c1) VALUES(0,'eeee'); +INSERT INTO t2(a, c1) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t2 WHERE c1='cccc'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'dddd'; +c1 +dddd +DROP TRIGGER t2_ai; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1,t2; +# +# Scenario 17: +# Create a small table, and add INSTANT columns and verify with storedprocedure +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE PROCEDURE p1() INSERT INTO t1(a,c1) VALUES(0, 'bbbb'); +CALL p1(); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP PROCEDURE p1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 18: +# Create a small table, and add INSTANT columns and verify with view +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +SELECT * FROM v1; +a b c1 +1 1 aaaa +2 2 aaaa +3 3 aaaa +4 4 aaaa +5 5 aaaa +6 NULL bbbb +DROP VIEW v1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 19: +# Create a small table, and add INSTANT columns and drop it and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 DROP COLUMN c1; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 20: +# Create a small table, and add INSTANT columns and rename table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 RENAME t2; +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t2(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t2 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'bbbb'; +c1 +bbbb +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t2; +# +# Scenario 21: +# Create a small table, and add INSTANT columns and change its data type INSTANTly won't work +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 CHANGE c1 c2 CHAR(10) NOT NULL DEFAULT 'cccc'; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c2` char(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 22: +# Create a small table, and add INSTANT columns and create hash,btree multi column index and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE INDEX id1 ON t1(c1) USING BTREE; +CREATE INDEX id2 ON t1(c1) USING HASH; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +Warning 1831 Duplicate index 'id2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP INDEX id1 ON t1; +DROP INDEX id2 ON t1; +ALTER TABLE t1 ADD COLUMN c2 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 63636363 +CREATE INDEX id1 ON t1(c1 ASC,c2 DESC) USING BTREE; +INSERT INTO t1(a, c2) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t1 WHERE c1='cccc'; +count(*) = max(a) +NULL +SELECT c1 FROM t1 WHERE c1 = 'dddd'; +c1 +ALTER TABLE t1 RENAME INDEX id1 TO id2; +DROP INDEX id2 ON t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + `c2` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +# +# Scenario 23: +# Create a small table, and add INSTANT columns and perform table join operation +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'cccc'; +c1 +cccc +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'bbbb', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 62626262 +INSERT INTO t2(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t2 WHERE c1='bbbb'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'cccc'; +c1 +cccc +SELECT * FROM t1 JOIN t2 ON t1.c1=t2.c1; +a b c1 a b c1 +6 NULL cccc 6 NULL cccc +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'bbbb', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +DROP TABLE t2; +# +# Scenario 24: +# Create a small table, and add stored and(or) virtual columns +# after last stored column in the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT, d INT GENERATED ALWAYS AS (b + c) VIRTUAL, e INT GENERATED ALWAYS AS (b * c) VIRTUAL) ROW_FORMAT=DYNAMIC; +INSERT INTO t1(a, b, c) VALUES(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 5, 6); +ALTER TABLE t1 ADD COLUMN h INT NOT NULL AFTER c; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h) VALUES(0, 6, 20, 40); +SELECT * FROM t1; +a b c h d e +1 1 2 0 3 2 +2 2 3 0 5 6 +3 3 4 0 7 12 +4 4 5 0 9 20 +5 5 6 0 11 30 +6 6 20 40 26 120 +ALTER TABLE t1 ADD COLUMN i VARCHAR(100) DEFAULT 'ABCD EFGH' AFTER h, ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(i)) AFTER i; +Table id did not change +SELECT 3 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h, i) VALUES(0, 20, 30, 50, 'qwerty'); +SELECT * FROM t1; +a b c h i f d e +1 1 2 0 ABCD EFGH 9 3 2 +2 2 3 0 ABCD EFGH 9 5 6 +3 3 4 0 ABCD EFGH 9 7 12 +4 4 5 0 ABCD EFGH 9 9 20 +5 5 6 0 ABCD EFGH 9 11 30 +6 6 20 40 ABCD EFGH 9 26 120 +7 20 30 50 qwerty 6 50 600 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + `h` int NOT NULL, + `i` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`i`)) VIRTUAL, + `d` int GENERATED ALWAYS AS ((`b` + `c`)) VIRTUAL, + `e` int GENERATED ALWAYS AS ((`b` * `c`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +DROP TABLE t1; +############################################ +# Test instant ADD COLUMN for COMPACT format +############################################ +# +# Scenario 1: +# Create a small table, and add all kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 INT, ALGORITHM=INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 1; +c1 +1 +ALTER TABLE t1 ADD COLUMN c2 INT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 8000000a +INSERT INTO t1(a, c2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE c2 = 10; +count(*) = max(a) +1 +SELECT c2 FROM t1 WHERE c2 = 11; +c2 +11 +ALTER TABLE t1 ADD COLUMN d1 BIGINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +SELECT d1 FROM t1 WHERE d1 = 1; +d1 +1 +ALTER TABLE t1 ADD COLUMN d2 BIGINT NOT NULL DEFAULT 1234567890; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd2' AND has_default = 1; +name default_value +d2 80000000499602d2 +INSERT INTO t1(a, d2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE d2 = 1234567890; +count(*) = max(a) +1 +SELECT d2 FROM t1 WHERE d2 = 1234; +d2 +1234 +ALTER TABLE t1 ADD COLUMN e1 SMALLINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +SELECT e1 FROM t1 WHERE e1 = 1; +e1 +1 +ALTER TABLE t1 ADD COLUMN e2 SMALLINT NOT NULL DEFAULT 10; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e2' AND has_default = 1; +name default_value +e2 800a +INSERT INTO t1(a, e2) VALUES(0, 11); +SELECT count(*) = max(a) FROM t1 WHERE e2 = 10; +count(*) = max(a) +1 +SELECT e2 FROM t1 WHERE e2 = 11; +e2 +11 +ALTER TABLE t1 ADD COLUMN f1 TINYINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +SELECT f1 FROM t1 WHERE f1 = 1; +f1 +1 +ALTER TABLE t1 ADD COLUMN f2 TINYINT NOT NULL DEFAULT 123; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f2' AND has_default = 1; +name default_value +f2 fb +INSERT INTO t1(a, f2) VALUES(0, 12); +SELECT count(*) = max(a) FROM t1 WHERE f2 = 123; +count(*) = max(a) +1 +SELECT f2 FROM t1 WHERE f2 = 12; +f2 +12 +ALTER TABLE t1 ADD COLUMN g1 MEDIUMINT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +SELECT g1 FROM t1 WHERE g1 = 1; +g1 +1 +ALTER TABLE t1 ADD COLUMN g2 MEDIUMINT NOT NULL DEFAULT 12345; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g2' AND has_default = 1; +name default_value +g2 803039 +INSERT INTO t1(a, g2) VALUES(0, 1234); +SELECT count(*) = max(a) FROM t1 WHERE g2 = 12345; +count(*) = max(a) +1 +SELECT g2 FROM t1 WHERE g2 = 1234; +g2 +1234 +ALTER TABLE t1 ADD COLUMN h1 FLOAT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, 1.0); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +SELECT h1 FROM t1 WHERE h1 = 1; +h1 +1 +ALTER TABLE t1 ADD COLUMN h2 FLOAT NOT NULL DEFAULT 12.34; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h2' AND has_default = 1; +name default_value +h2 a4704541 +INSERT INTO t1(a, h2) VALUES(0, 1.234); +SELECT count(*) = max(a) FROM t1 WHERE h2 = 12.34; +count(*) = max(a) +NULL +SELECT h2 FROM t1 WHERE h2 = 1.234; +h2 +ALTER TABLE t1 ADD COLUMN i1 DECIMAL(5, 2), ADD COLUMN i2 double, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'i1' OR name = 'i2') AND has_default = 1; +name default_value +i1 NULL +i2 NULL +INSERT INTO t1(a, i1, i2) VALUES(0, 10.10, 20.20); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE i2 IS NULL; +count(*) = max(a) +1 +SELECT i1 FROM t1 WHERE i1 = 10.10; +i1 +10.10 +SELECT i2 FROM t1 WHERE i2 = 20.20; +i2 +20.2 +ALTER TABLE t1 ADD COLUMN j1 DECIMAL(5, 2) NOT NULL DEFAULT 100.00, ADD COLUMN j2 double NOT NULL DEFAULT 1000.5678; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'j1' OR name = 'j2') AND has_default = 1; +name default_value +j1 806400 +j2 5af5b9da8a448f40 +INSERT INTO t1(a, j1, j2) VALUES(0, 90.90, 1000.1234); +SELECT count(*) = max(a) FROM t1 WHERE j1 = 100.00; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE j2 = 1000.5678; +count(*) = max(a) +1 +SELECT j1 FROM t1 WHERE j1 = 90.90; +j1 +90.90 +SELECT j2 FROM t1 WHERE j2 = 1000.1234; +j2 +1000.1234 +ALTER TABLE t1 ADD COLUMN k1 BIT(8), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k1' AND has_default = 1; +name default_value +k1 NULL +INSERT INTO t1(a, k1) VALUES(0, b'010101'); +SELECT count(*) = max(a) FROM t1 WHERE k1 IS NULL; +count(*) = max(a) +1 +SELECT hex(k1) FROM t1 WHERE k1 = b'010101'; +hex(k1) +15 +ALTER TABLE t1 ADD COLUMN k2 BIT(8) NOT NULL DEFAULT b'101010'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'k2' AND has_default = 1; +name default_value +k2 2a +INSERT INTO t1(a, k2) VALUES(0, b'110011'); +SELECT count(*) = max(a) FROM t1 WHERE k2 = b'101010'; +count(*) = max(a) +1 +SELECT hex(k2) FROM t1 WHERE k2 = b'110011'; +hex(k2) +33 +ALTER TABLE t1 ADD COLUMN l1 CHAR(50), ADD COLUMN l2 VARCHAR(100), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'l1' OR name = 'l2') AND has_default = 1; +name default_value +l1 NULL +l2 NULL +INSERT INTO t1(a, l1, l2) VALUES(0, 'ABCD EFGH', 'abcdefg hijklmn '); +SELECT count(*) = max(a) FROM t1 WHERE l2 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE l1 IS NULL; +count(*) = max(a) +1 +SELECT l1 FROM t1 WHERE l1 = 'ABCD EFGH'; +l1 +ABCD EFGH +SELECT l2 FROM t1 WHERE l2 = 'abcdefg hijklmn '; +l2 +abcdefg hijklmn +ALTER TABLE t1 ADD COLUMN m1 CHAR(50) default 'The fox jumps over', ADD COLUMN m2 VARCHAR(50) DEFAULT 'The fox jumps over the lazy dog.'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'm1' OR name = 'm2') AND has_default = 1; +name default_value +m1 54686520666f78206a756d7073206f7665722020202020202020202020202020202020202020202020202020202020202020 +m2 54686520666f78206a756d7073206f76657220746865206c617a7920646f672e +INSERT INTO t1(a, m1, m2) VALUES(0, 'over the lazy dog', 'The lazy dog jumps over the fox.'); +SELECT count(*) = max(a) FROM t1 WHERE m1 = 'The fox jumps over'; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE m2 like 'The fox jumps%'; +count(*) = max(a) +1 +SELECT m1 FROM t1 WHERE m1 = 'over the lazy dog'; +m1 +over the lazy dog +SELECT m2 FROM t1 WHERE m2 like '%the fox.'; +m2 +The lazy dog jumps over the fox. +ALTER TABLE t1 ADD COLUMN n1 BINARY(10), ADD COLUMN n2 VARBINARY(10), ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'n1' OR name = 'n2') AND has_default = 1; +name default_value +n1 NULL +n2 NULL +INSERT INTO t1(a, n1, n2) VALUES(0, 0x010203040506070809, 0x102030405060708090); +SELECT count(*) = max(a) FROM t1 WHERE n1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE n2 IS NULL; +count(*) = max(a) +1 +SELECT hex(n1) FROM t1 WHERE n1 = 0x01020304050607080900; +hex(n1) +01020304050607080900 +SELECT hex(n2) FROM t1 WHERE n2 = 0x102030405060708090; +hex(n2) +102030405060708090 +ALTER TABLE t1 ADD COLUMN o1 BINARY(10) DEFAULT 0x11223344, ADD COLUMN o2 VARBINARY(10) DEFAULT 0x55667788; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'o1' OR name = 'o2') AND has_default = 1; +name default_value +o1 11223344000000000000 +o2 55667788 +INSERT INTO t1(a, o1, o2) VALUES(0, 0x44332211, 0x88776655); +SELECT count(*) = max(a) FROM t1 WHERE o1 = 0x11223344000000000000; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE o2 = 0x55667788; +count(*) = max(a) +1 +SELECT hex(o1) FROM t1 WHERE o1 = 0x44332211000000000000; +hex(o1) +44332211000000000000 +SELECT hex(o2) FROM t1 WHERE o2 = 0x88776655; +hex(o2) +88776655 +ALTER TABLE t1 ADD COLUMN p1 DATETIME, ALGORITHM=DEFAULT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p1' AND has_default = 1; +name default_value +p1 NULL +INSERT INTO t1(a, p1) VALUES(0, '2017-12-31 00:00:00'); +SELECT count(*) = max(a) FROM t1 WHERE p1 IS NULL; +count(*) = max(a) +1 +SELECT p1 FROM t1 WHERE p1 = '2017-12-31 00:00:00'; +p1 +2017-12-31 00:00:00 +ALTER TABLE t1 ADD COLUMN p2 DATETIME NOT NULL DEFAULT '2017-12-31 01:02:03'; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'p2' AND has_default = 1; +name default_value +p2 999e7e1083 +SELECT count(*) = max(a) FROM t1 GROUP BY p2; +count(*) = max(a) +1 +INSERT INTO t1(a, p2) VALUES(0, now()); +SELECT count(*) FROM t1 GROUP BY p2; +count(*) +26 +1 +ALTER TABLE t1 ADD COLUMN q1 ENUM ('value1','value2','value3'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'q1' AND has_default = 1; +name default_value +q1 NULL +INSERT INTO t1(a, q1) VALUES(0, 1); +SELECT count(*) = max(a) FROM t1 WHERE q1 IS NULL; +count(*) = max(a) +1 +SELECT q1 FROM t1 WHERE q1 = 1; +q1 +value1 +ALTER TABLE t1 ADD COLUMN r1 SET ('a','b','c'), ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'r1' AND has_default = 1; +name default_value +r1 NULL +INSERT INTO t1(a, r1) VALUES(0, 'a'); +SELECT count(*) = max(a) FROM t1 WHERE r1 IS NULL; +count(*) = max(a) +1 +SELECT r1 FROM t1 WHERE r1 = 'a'; +r1 +a +ALTER TABLE t1 ADD COLUMN s1 BLOB, ADD COLUMN s2 TEXT, ALGORITHM=INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 's1' OR name = 's2') AND has_default = 1; +name default_value +s1 NULL +s2 NULL +INSERT INTO t1(a, s1, s2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE s1 IS NULL; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE s2 IS NULL; +count(*) = max(a) +1 +SELECT hex(s1) FROM t1 WHERE s1 = 0x0102030405; +hex(s1) +0102030405 +SELECT s2 FROM t1 WHERE s2 = 'abcd qwerty'; +s2 +abcd qwerty +ALTER TABLE t1 ADD COLUMN u1 BLOB NOT NULL, ADD COLUMN u2 TEXT NOT NULL; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE (name = 'u1' OR name = 'u2') AND has_default = 1; +name default_value +u1 +u2 +INSERT INTO t1(a, u1, u2) VALUES(0, 0x0102030405, 'abcd qwerty'); +SELECT count(*) = max(a) FROM t1 WHERE u1 = ''; +count(*) = max(a) +1 +SELECT count(*) = max(a) FROM t1 WHERE u2 = ''; +count(*) = max(a) +1 +SELECT hex(u1) FROM t1 WHERE u1 = 0x0102030405; +hex(u1) +0102030405 +SELECT u2 FROM t1 WHERE u2 = 'abcd qwerty'; +u2 +abcd qwerty +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` int DEFAULT NULL, + `c2` int NOT NULL DEFAULT '10', + `d1` bigint DEFAULT NULL, + `d2` bigint NOT NULL DEFAULT '1234567890', + `e1` smallint DEFAULT NULL, + `e2` smallint NOT NULL DEFAULT '10', + `f1` tinyint DEFAULT NULL, + `f2` tinyint NOT NULL DEFAULT '123', + `g1` mediumint DEFAULT NULL, + `g2` mediumint NOT NULL DEFAULT '12345', + `h1` float DEFAULT NULL, + `h2` float NOT NULL DEFAULT '12.34', + `i1` decimal(5,2) DEFAULT NULL, + `i2` double DEFAULT NULL, + `j1` decimal(5,2) NOT NULL DEFAULT '100.00', + `j2` double NOT NULL DEFAULT '1000.5678', + `k1` bit(8) DEFAULT NULL, + `k2` bit(8) NOT NULL DEFAULT b'101010', + `l1` char(50) DEFAULT NULL, + `l2` varchar(100) DEFAULT NULL, + `m1` char(50) DEFAULT 'The fox jumps over', + `m2` varchar(50) DEFAULT 'The fox jumps over the lazy dog.', + `n1` binary(10) DEFAULT NULL, + `n2` varbinary(10) DEFAULT NULL, + `o1` binary(10) DEFAULT '"3D\0\0\0\0\0\0', + `o2` varbinary(10) DEFAULT 'Ufw?', + `p1` datetime DEFAULT NULL, + `p2` datetime NOT NULL DEFAULT '2017-12-31 01:02:03', + `q1` enum('value1','value2','value3') DEFAULT NULL, + `r1` set('a','b','c') DEFAULT NULL, + `s1` blob, + `s2` text, + `u1` blob NOT NULL, + `u2` text NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 2: +# Create a small table, add some columns instantly, along with +# virtual columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL, ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c) VALUES(0, 6, 20); +SELECT * FROM t1; +a b c d +1 1 0 2 +2 2 0 4 +3 3 0 6 +4 4 0 8 +5 5 0 10 +6 6 20 12 +ALTER TABLE t1 ADD COLUMN e VARCHAR(100) DEFAULT 'ABCD EFGH', ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(e)); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, c, e) VALUES(0, 20, 'Hello'), (0, 20, 'World'), (0, 20, 'Hello World'); +SELECT * FROM t1; +a b c d e f +1 1 0 2 ABCD EFGH 9 +2 2 0 4 ABCD EFGH 9 +3 3 0 6 ABCD EFGH 9 +4 4 0 8 ABCD EFGH 9 +5 5 0 10 ABCD EFGH 9 +6 6 20 12 ABCD EFGH 9 +7 NULL 20 NULL Hello 5 +8 NULL 20 NULL World 5 +9 NULL 20 NULL Hello World 11 +ALTER TABLE t1 ADD COLUMN g VARCHAR(100) GENERATED ALWAYS AS (e), ADD COLUMN h BIGINT DEFAULT 10000, ADD COLUMN i BIGINT GENERATED ALWAYS AS (h * 2 + b); +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +INSERT INTO t1(a, b, c, h) VALUES(0, 7, 40, 2000), (0, 7, 40, 20000); +SELECT * FROM t1; +a b c d e f g h i +1 1 0 2 ABCD EFGH 9 ABCD EFGH 10000 20001 +2 2 0 4 ABCD EFGH 9 ABCD EFGH 10000 20002 +3 3 0 6 ABCD EFGH 9 ABCD EFGH 10000 20003 +4 4 0 8 ABCD EFGH 9 ABCD EFGH 10000 20004 +5 5 0 10 ABCD EFGH 9 ABCD EFGH 10000 20005 +6 6 20 12 ABCD EFGH 9 ABCD EFGH 10000 20006 +7 NULL 20 NULL Hello 5 Hello 10000 NULL +8 NULL 20 NULL World 5 World 10000 NULL +9 NULL 20 NULL Hello World 11 Hello World 10000 NULL +10 7 40 14 ABCD EFGH 9 ABCD EFGH 2000 4007 +11 7 40 14 ABCD EFGH 9 ABCD EFGH 20000 40007 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL, + `d` int GENERATED ALWAYS AS ((`b` * 2)) VIRTUAL, + `e` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`e`)) VIRTUAL, + `g` varchar(100) GENERATED ALWAYS AS (`e`) VIRTUAL, + `h` bigint DEFAULT '10000', + `i` bigint GENERATED ALWAYS AS (((`h` * 2) + `b`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 3: +# Create a small table, add some columns instantly, then change +# their default values, check original default values are correct +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +INSERT INTO t1(a, b, c, e) VALUES(0, 6, 200, 'Good day'), (0, 7, 300, 'Good DAY'); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND has_default = 1; +default_value +80000064 +ALTER TABLE t1 ALTER COLUMN c SET DEFAULT 500; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'c' AND +has_default = 1; +default_value +80000064 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +INSERT INTO t1(a, b) VALUES(0, 8), (0, 9); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +ALTER TABLE t1 ALTER COLUMN e SET DEFAULT 'HELLO MySQL!'; +SELECT default_value FROM information_schema.innodb_columns WHERE name = 'e' AND has_default = 1; +default_value +48656c6c6f20776f726c64 +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +INSERT INTO t1(a, b) VALUES(0, 10), (0, 20); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 200 406 Good day +7 7 300 607 Good DAY +8 8 500 1008 Hello world +9 9 500 1009 Hello world +10 10 500 1010 HELLO MySQL! +11 20 500 1020 HELLO MySQL! +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '500', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'HELLO MySQL!', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 4: +# Create a small table, add some columns instantly, then do DML +# on the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 200 WHERE a > 3; +SELECT distinct(c) FROM t1; +c +100 +200 +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +DELETE FROM t1 WHERE c = 100; +UPDATE t1 SET c = 300; +SELECT distinct(c) FROM t1; +c +300 +SELECT count(*) FROM t1; +count(*) +16 +ALTER TABLE t1 ADD COLUMN t DATETIME DEFAULT CURRENT_TIMESTAMP; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 10; +UPDATE t1 SET e = 'Hello MySQL!!' WHERE a > 20; +SELECT distinct(e) FROM t1; +e +Hello world +Hello MySQL +Hello MySQL!! +UPDATE t1 SET c = 500 WHERE e LIKE '%world%'; +SELECT c, e FROM t1 GROUP BY c, e; +c e +300 Hello MySQL +300 Hello MySQL!! +500 Hello world +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET t = CURRENT_TIMESTAMP WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +16 +DELETE FROM t1 WHERE a < 50; +SELECT count(t) FROM t1 GROUP BY t; +count(t) +16 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + `t` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 5: +# Create a small table, add some columns instantly, then do DDL +# to build indexes +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(c); +EXPLAIN SELECT c FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL c # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1` +SELECT c FROM t1 WHERE c != 100; +c +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +INSERT INTO t1(b, c, e) SELECT b, c, e FROM t1; +UPDATE t1 SET e = 'Hello MySQL' WHERE a > 30; +ALTER TABLE t1 ADD KEY(e); +EXPLAIN SELECT e FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL # NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL e # NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`e` AS `e` from `test`.`t1` +SELECT count(e) FROM t1 WHERE e LIKE '%MySQL%'; +count(e) +17 +SELECT count(e) FROM t1 WHERE e LIKE '%world%'; +count(e) +23 +ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(a, c); +SELECT a, c, e FROM t1 WHERE a > 25 AND a < 40; +a c e +28 100 Hello world +29 100 Hello world +30 100 Hello world +31 100 Hello MySQL +32 100 Hello MySQL +33 100 Hello MySQL +34 100 Hello MySQL +35 100 Hello MySQL +36 100 Hello MySQL +37 100 Hello MySQL +38 100 Hello MySQL +39 100 Hello MySQL +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`,`c`), + KEY `c` (`c`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 6: +# Create a small table, add some columns instantly, then do DML +# on the table, and some simple rollback +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; +a b c +1 1 500 +2 1000 100 +ROLLBACK; +SELECT a, b, c FROM t1; +a b c +1 1 100 +2 2 100 +3 3 100 +4 4 100 +5 5 100 +START TRANSACTION; +DELETE FROM t1 WHERE a < 5; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +5 5 100 205 Hello world +7 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '100', + `d` int GENERATED ALWAYS AS (((`c` * 2) + `b`)) VIRTUAL, + `e` varchar(100) DEFAULT 'Hello world', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +CREATE TABLE t1(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000)) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(1, repeat('a', 4000), repeat('b', 4000), repeat('c', 1)); +SELECT id, length(c1), length(c2), length(c3) FROM t1; +id length(c1) length(c2) length(c3) +1 4000 4000 1 +ALTER TABLE t1 ADD COLUMN c4 VARCHAR(500) NOT NULL DEFAULT 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c1 = repeat('x', 200) WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +START TRANSACTION; +UPDATE t1 SET c4 = 'x' WHERE id = 1; +ROLLBACK; +SELECT id, length(c1), length(c2), length(c3), length(c4) FROM t1; +id length(c1) length(c2) length(c3) length(c4) +1 4000 4000 1 500 +DROP TABLE t1; +# +# Scenario 7: +# Confirm some ADD COLUMN are instant, some are not +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100 AFTER b; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN e INT NOT NULL DEFAULT 100, ADD KEY(e); +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN f INT NOT NULL DEFAULT 100, FORCE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +ALTER TABLE t1 ADD COLUMN g INT NOT NULL DEFAULT 100, ALGORITHM=INPLACE; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_columns WHERE has_default = 1; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `d` int NOT NULL DEFAULT '100', + `c` int NOT NULL DEFAULT '100', + `e` int NOT NULL DEFAULT '100', + `f` int NOT NULL DEFAULT '100', + `g` int NOT NULL DEFAULT '100', + PRIMARY KEY (`a`), + KEY `e` (`e`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c TEXT, FULLTEXT(c)) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1, 'Hello'), (0, 2, 'HELLO'), (0, 3, 'World'), (0, 4, 'Hello world'), (0, 5, 'HELLO WORLD'); +ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT 100 AFTER b; +Table ID differed +count(*) = 1 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 8: +# Check FK constraints on instantly added columns +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +CREATE TABLE t2(a INT NOT NULL PRIMARY KEY, b INT, c INT, KEY(c)); +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(1, 2, 3), (2, 3, 4), (3, 4, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 3; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 SET c = 4 WHERE a = 2; +UPDATE t1 SET c = 5 WHERE a = 3; +ALTER TABLE t1 ADD KEY(c); +ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1(c) ON UPDATE CASCADE, ALGORITHM = COPY; +UPDATE t1 SET c = 10 WHERE a = 1; +SELECT c FROM t2; +c +10 +4 +5 +UPDATE t1 SET c = 10; +SELECT c FROM t2; +c +10 +10 +10 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '3', + PRIMARY KEY (`a`), + KEY `c` (`c`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t2; +DROP TABLE t1; +# +# Scenario 9: +# Instant ADD COLUMN on partitioned table, only simple test here +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +3 3 5 +6 6 5 +1 1 5 +4 4 5 +7 7 5 +2 2 5 +5 5 5 +8 8 5 +INSERT INTO t1 VALUES(0, 9, 10), (0, 10, 20); +SELECT * FROM t1 WHERE b > 8; +a b c +9 9 10 +10 10 20 +UPDATE t1 SET c = 8 WHERE a = 1 OR a = 3 OR a = 5 OR a = 7; +SELECT * FROM t1; +a b c +3 3 8 +6 6 5 +9 9 10 +1 1 8 +4 4 5 +7 7 8 +10 10 20 +2 2 5 +5 5 8 +8 8 5 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +/*!50100 PARTITION BY HASH (`a`) +PARTITIONS 3 */ +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ROW_FORMAT=COMPACT PARTITION BY HASH(a) PARTITIONS 2;; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 CHANGE COLUMN c c1 INT; +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# Scenario 10: +# EXCHANGE PARTITION is not allowed if either is instant +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5) ROW_FORMAT=COMPACT PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30));; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +ALTER TABLE t2 ADD COLUMN d INT; +ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INPLACE; +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +ERROR HY000: Non matching attribute 'INSTANT COLUMN(s)' between partition and table +OPTIMIZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 optimize note Table does not support optimize, doing recreate + analyze instead +test.t2 optimize status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int NOT NULL DEFAULT '5', + `d` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +/*!50100 PARTITION BY RANGE (`a`) +(PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN (20) ENGINE = InnoDB, + PARTITION p3 VALUES LESS THAN (30) ENGINE = InnoDB) */ +ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; +DROP TABLE t1, t2; +# +# Scenario 11: +# PRIMARY KEY with more than one column, at least to verify it works with REDUDANT +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a, b)) ROW_FORMAT=COMPACT;; +INSERT INTO t1 VALUES(0, 1), (1, 2), (2, 3), (3, 4); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 5 +1 2 5 +2 3 5 +3 4 5 +UPDATE t1 SET c = b WHERE b <= 2; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +0 1 1 +1 2 2 +2 3 5 +3 4 5 +DROP TABLE t1; +# +# Scenario 12: +# Mix ALTER PARTITION and ALTER TABLE ... INPLACE. This is to check if first partition is not +# instant after ALTER PARTITION, will the metadata be copied correctly +# +CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 TEXT) ENGINE = InnoDB PARTITION BY RANGE(col1 * 2) ( PARTITION p0 VALUES LESS THAN (128), PARTITION p1 VALUES LESS THAN (256) , PARTITION p2 VALUES LESS THAN (384) , PARTITION p3 VALUES LESS THAN MAXVALUE);; +INSERT INTO t1 VALUES(1, 2, 3, 'abcdefg'), (100, 200, 300, 'qwerty'), (200, 300, 400, 'asdfg'); +ALTER TABLE t1 ALGORITHM DEFAULT, ADD COLUMN col5 VARCHAR(500), ADD COLUMN col6 TEXT; +Table id did not change +count(*) = 2 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 4` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 4 +4 +ALTER TABLE t1 ALGORITHM INPLACE, REORGANIZE PARTITION p0 INTO (PARTITION p0_a VALUES LESS THAN (64), PARTITION p0_b VALUES LESS THAN (128)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, ADD KEY idx4(col4(10)); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ALGORITHM DEFAULT, LOCK EXCLUSIVE, REORGANIZE PARTITION p0_a, p0_b INTO (PARTITION p0 VALUES LESS THAN (128) TABLESPACE innodb_file_per_table); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY idx3(col3); +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +col1 col2 col3 col4 col5 col6 +1 2 3 abcdefg NULL NULL +100 200 300 qwerty NULL NULL +200 300 400 asdfg NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT PARTITION BY HASH(a) PARTITIONS 3;; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 5; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT count(*) AS `Expect 3` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 3 +3 +ALTER TABLE t1 ADD PARTITION PARTITIONS 10; +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD KEY(b); +SELECT count(*) AS `Expect 0` FROM information_schema.innodb_tables WHERE instant_cols != 0; +Expect 0 +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1; +a b c +1 1 5 +2 2 5 +3 3 5 +4 4 5 +5 5 5 +6 6 5 +7 7 5 +8 8 5 +DROP TABLE t1; +# +# Scenario 13: +# Create a table with a two level clustered index, do instant ADD COLUMN, then the non-leaf node +# should be parsed correctly +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, d INT NOT NULL, b BLOB NOT NULL, c VARCHAR(87), INDEX(d), INDEX(a ASC), PRIMARY KEY (a, d DESC, c DESC)) ROW_FORMAT=COMPACT PARTITION BY LINEAR KEY(c) PARTITIONS 9;; +INSERT INTO t1(d, b, c) VALUES(1, 2, 'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(2, 3, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(3, 4, 'bbbbbbbbbbaaaaaaaaaahhhhhhhhhhccccccccccddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(4, 5, 'eeeeeeeeeehhhhhhhhhhbbbbbbbbbbccccccccccddddddddddaaaaaaaaaaffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(5, 6, 'aaaaaaaaaahhhhhhhhhhbbbbbbbbbbddddddddddcccccccccceeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) VALUES(6, 7, 'cccccccccchhhhhhhhhhbbbbbbbbbbaaaaaaaaaaddddddddddeeeeeeeeeeffffffffffggggggggggjjjjjjj'); +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +INSERT INTO t1(d, b, c) SELECT d, b, c FROM t1; +ALTER TABLE t1 ADD COLUMN nc086 BIGINT NOT NULL FIRST, ALGORITHM=INPLACE, LOCK=DEFAULT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 ADD COLUMN nc082 TINYTEXT; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT COUNT(*) FROM t1; +COUNT(*) +384 +DROP TABLE t1; +# +# Scenario 14: +# Create a small table, and add GIS kinds of new columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 POINT, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, ST_PointFromText('POINT(10 10)')); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN d1 LINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'd1' AND has_default = 1; +name default_value +d1 NULL +INSERT INTO t1(a, d1) VALUES(0, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')); +SELECT count(*) = max(a) FROM t1 WHERE d1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN e1 POLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'e1' AND has_default = 1; +name default_value +e1 NULL +INSERT INTO t1(a, e1) VALUES(0, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE e1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN f1 MULTIPOINT, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'f1' AND has_default = 1; +name default_value +f1 NULL +INSERT INTO t1(a, f1) VALUES(0, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')); +SELECT count(*) = max(a) FROM t1 WHERE f1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN g1 MULTILINESTRING, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'g1' AND has_default = 1; +name default_value +g1 NULL +INSERT INTO t1(a, g1) VALUES(0, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')); +SELECT count(*) = max(a) FROM t1 WHERE g1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN h1 MULTIPOLYGON, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'h1' AND has_default = 1; +name default_value +h1 NULL +INSERT INTO t1(a, h1) VALUES(0, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')); +SELECT count(*) = max(a) FROM t1 WHERE h1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN i1 GEOMETRYCOLLECTION, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'i1' AND has_default = 1; +name default_value +i1 NULL +INSERT INTO t1(a, i1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE i1 IS NULL; +count(*) = max(a) +1 +ALTER TABLE t1 ADD COLUMN j1 GEOMETRY, ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'j1' AND has_default = 1; +name default_value +j1 NULL +INSERT INTO t1(a, j1) VALUES(0, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')); +SELECT count(*) = max(a) FROM t1 WHERE j1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` point DEFAULT NULL, + `d1` linestring DEFAULT NULL, + `e1` polygon DEFAULT NULL, + `f1` multipoint DEFAULT NULL, + `g1` multilinestring DEFAULT NULL, + `h1` multipolygon DEFAULT NULL, + `i1` geomcollection DEFAULT NULL, + `j1` geometry DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 15: +# Create a small table, and add JSON columns and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 JSON, ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 NULL +INSERT INTO t1(a, c1) VALUES(0, '{"key1": "value1", "key2": "value2"}'); +SELECT count(*) = max(a) FROM t1 WHERE c1 IS NULL; +count(*) = max(a) +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` json DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 16: +# Create a small table, and add INSTANT columns and verify with trigger +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +INSERT INTO t2 VALUES(0,6); +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP TRIGGER t1_ai; +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 63636363 +CREATE TRIGGER t2_ai AFTER INSERT ON t2 FOR EACH ROW +INSERT INTO t1(a,c1) VALUES(0,'eeee'); +INSERT INTO t2(a, c1) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t2 WHERE c1='cccc'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'dddd'; +c1 +dddd +DROP TRIGGER t2_ai; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1,t2; +# +# Scenario 17: +# Create a small table, and add INSTANT columns and verify with storedprocedure +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE PROCEDURE p1() INSERT INTO t1(a,c1) VALUES(0, 'bbbb'); +CALL p1(); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP PROCEDURE p1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 18: +# Create a small table, and add INSTANT columns and verify with view +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +SELECT * FROM v1; +a b c1 +1 1 aaaa +2 2 aaaa +3 3 aaaa +4 4 aaaa +5 5 aaaa +6 NULL bbbb +DROP VIEW v1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 19: +# Create a small table, and add INSTANT columns and drop it and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 DROP COLUMN c1; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 20: +# Create a small table, and add INSTANT columns and rename table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +ALTER TABLE t1 RENAME t2; +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t2(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t2 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'bbbb'; +c1 +bbbb +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t2; +# +# Scenario 21: +# Create a small table, and add INSTANT columns and change its data type INSTANTly won't work +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +ALTER TABLE t1 CHANGE c1 c2 CHAR(10) NOT NULL DEFAULT 'cccc'; +Table ID differed +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +0 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c2` char(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 22: +# Create a small table, and add INSTANT columns and create hash,btree multi column index and verify +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +CREATE INDEX id1 ON t1(c1) USING BTREE; +CREATE INDEX id2 ON t1(c1) USING HASH; +Warnings: +Note 3502 This storage engine does not support the HASH index algorithm, storage engine default was used instead. +Warning 1831 Duplicate index 'id2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +INSERT INTO t1(a, c1) VALUES(0, 'bbbb'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'bbbb'; +c1 +bbbb +DROP INDEX id1 ON t1; +DROP INDEX id2 ON t1; +ALTER TABLE t1 ADD COLUMN c2 VARCHAR(10) NOT NULL DEFAULT 'cccc', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c2' AND has_default = 1; +name default_value +c2 63636363 +CREATE INDEX id1 ON t1(c1 ASC,c2 DESC) USING BTREE; +INSERT INTO t1(a, c2) VALUES(0, 'dddd'); +SELECT count(*) = max(a) FROM t1 WHERE c1='cccc'; +count(*) = max(a) +NULL +SELECT c1 FROM t1 WHERE c1 = 'dddd'; +c1 +ALTER TABLE t1 RENAME INDEX id1 TO id2; +DROP INDEX id2 ON t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + `c2` varchar(10) NOT NULL DEFAULT 'cccc', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Scenario 23: +# Create a small table, and add INSTANT columns and perform table join operation +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +INSERT INTO t2 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'aaaa', ALGORITHM = INSTANT; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +INSERT INTO t1(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t1 WHERE c1='aaaa'; +count(*) = max(a) +1 +SELECT c1 FROM t1 WHERE c1 = 'cccc'; +c1 +cccc +ALTER TABLE t2 ADD COLUMN c1 VARCHAR(10) NOT NULL DEFAULT 'bbbb', ALGORITHM = INSTANT; +Table id did not change +SELECT 2 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT name, default_value FROM information_schema.innodb_columns WHERE name = 'c1' AND has_default = 1; +name default_value +c1 61616161 +c1 62626262 +INSERT INTO t2(a, c1) VALUES(0, 'cccc'); +SELECT count(*) = max(a) FROM t2 WHERE c1='bbbb'; +count(*) = max(a) +1 +SELECT c1 FROM t2 WHERE c1 = 'cccc'; +c1 +cccc +SELECT * FROM t1 JOIN t2 ON t1.c1=t2.c1; +a b c1 a b c1 +6 NULL cccc 6 NULL cccc +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'aaaa', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c1` varchar(10) NOT NULL DEFAULT 'bbbb', + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +DROP TABLE t2; +# +# Scenario 24: +# Create a small table, and add stored and(or) virtual columns +# after last stored column in the table +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT, d INT GENERATED ALWAYS AS (b + c) VIRTUAL, e INT GENERATED ALWAYS AS (b * c) VIRTUAL) ROW_FORMAT=COMPACT; +INSERT INTO t1(a, b, c) VALUES(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 5, 6); +ALTER TABLE t1 ADD COLUMN h INT NOT NULL AFTER c; +Table id did not change +count(*) = 1 +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h) VALUES(0, 6, 20, 40); +SELECT * FROM t1; +a b c h d e +1 1 2 0 3 2 +2 2 3 0 5 6 +3 3 4 0 7 12 +4 4 5 0 9 20 +5 5 6 0 11 30 +6 6 20 40 26 120 +ALTER TABLE t1 ADD COLUMN i VARCHAR(100) DEFAULT 'ABCD EFGH' AFTER h, ADD COLUMN f INT GENERATED ALWAYS AS (LENGTH(i)) AFTER i; +Table id did not change +SELECT 3 = instant_cols AS `Instant columns equal` FROM information_schema.innodb_tables WHERE name like '%t1%'; +Instant columns equal +1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1(a, b, c, h, i) VALUES(0, 20, 30, 50, 'qwerty'); +SELECT * FROM t1; +a b c h i f d e +1 1 2 0 ABCD EFGH 9 3 2 +2 2 3 0 ABCD EFGH 9 5 6 +3 3 4 0 ABCD EFGH 9 7 12 +4 4 5 0 ABCD EFGH 9 9 20 +5 5 6 0 ABCD EFGH 9 11 30 +6 6 20 40 ABCD EFGH 9 26 120 +7 20 30 50 qwerty 6 50 600 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int NOT NULL AUTO_INCREMENT, + `b` int DEFAULT NULL, + `c` int DEFAULT NULL, + `h` int NOT NULL, + `i` varchar(100) DEFAULT 'ABCD EFGH', + `f` int GENERATED ALWAYS AS (length(`i`)) VIRTUAL, + `d` int GENERATED ALWAYS AS ((`b` + `c`)) VIRTUAL, + `e` int GENERATED ALWAYS AS ((`b` * `c`)) VIRTUAL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=COMPACT +DROP TABLE t1; +# +# Test cases which don't care about row format start here +# +# +# Bug #28040201 ADDING A NEW COLUMN TO A TABLE HAVING A GENRATED COLUMN +# CRASHES THE SERVER +# +CREATE TABLE t1 (a TEXT GENERATED ALWAYS AS (lpad(1, 1, 1)) VIRTUAL); +ALTER TABLE t1 ADD COLUMN (b INT); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text GENERATED ALWAYS AS (lpad(1,1,1)) VIRTUAL, + `b` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +DROP TABLE t1; +# +# BUG#27784462 - DD::COLUMN::SE_PRIVATE_DATA[TABLE_ID] IS NOT MAINTAINED PROPERLY +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, c INT NOT NULL DEFAULT 5, e INT GENERATED ALWAYS AS ((c + 2)) VIRTUAL) PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (30)); +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO (PARTITION p1_a VALUES LESS THAN (5), PARTITION p1_b VALUES LESS THAN (10)); +ALTER TABLE t1 ADD COLUMN d INT GENERATED ALWAYS AS ((b * 2)) VIRTUAL, ALGORITHM = INSTANT; +DROP TABLE t1; +# +# Check adding a stored columns(along with virtual columns) +# after the last stored column of a table with functional index +# should be fine +# +CREATE TABLE t1 (col1 INT, col2 INT AS (col1 + col1), INDEX (col2)); +INSERT INTO t1(col1) VALUES(10), (20), (30), (40); +ALTER TABLE t1 ADD COLUMN new_col INT AFTER col1, ALGORITHM=INSTANT; +SELECT * FROM t1; +col1 new_col col2 +10 NULL 20 +20 NULL 40 +30 NULL 60 +40 NULL 80 +ALTER TABLE t1 ADD COLUMN new_col_1 INT AFTER new_col, ADD COLUMN new_col_2 INT GENERATED ALWAYS AS (new_col * 3), ALGORITHM=INSTANT; +INSERT INTO t1(col1, new_col, new_col_1) VALUES(100, 200, 300); +SELECT * FROM t1; +col1 new_col new_col_1 col2 new_col_2 +10 NULL NULL 20 NULL +20 NULL NULL 40 NULL +30 NULL NULL 60 NULL +40 NULL NULL 80 NULL +100 200 300 200 600 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `col1` int DEFAULT NULL, + `new_col` int DEFAULT NULL, + `new_col_1` int DEFAULT NULL, + `col2` int GENERATED ALWAYS AS ((`col1` + `col1`)) VIRTUAL, + `new_col_2` int GENERATED ALWAYS AS ((`new_col` * 3)) VIRTUAL, + KEY `col2` (`col2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/monitor.result-pq b/mysql-test/suite/innodb/r/monitor.result-pq new file mode 100644 index 000000000..e172c5007 --- /dev/null +++ b/mysql-test/suite/innodb/r/monitor.result-pq @@ -0,0 +1,739 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = all; +set global innodb_monitor_reset_all = all; +select 1 from `information_schema`.`INNODB_METRICS` +where case (1) when (1) then (AVG_COUNT_RESET) else (1) end; +1 +set global innodb_monitor_enable = default; +set global innodb_monitor_disable = default; +set global innodb_monitor_reset = default; +set global innodb_monitor_reset_all = default; +# +# Bug#22576241 SETTING INNODB_MONITOR_ENABLE TO ALL DOES NOT ENABLE ALL +# MONITORS +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf 0 +SET GLOBAL innodb_monitor_enable='module_buffer_page'; +INSERT INTO t1 VALUES (1), (2), (3), (4); +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf NNNN +SET GLOBAL innodb_monitor_disable='module_buffer_page'; +SET GLOBAL innodb_monitor_reset_all='module_buffer_page'; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf 0 +SET GLOBAL innodb_monitor_enable='%'; +INSERT INTO t1 VALUES (5), (6), (7), (8); +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf NNNN +SET GLOBAL innodb_monitor_disable='%'; +SET GLOBAL innodb_monitor_reset_all='%'; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf 0 +SET GLOBAL innodb_monitor_enable='ALL'; +INSERT INTO t1 VALUES (9), (10), (11), (12); +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +LIKE 'buffer_page_written_index_leaf'; +NAME COUNT +buffer_page_written_index_leaf NNNN +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/optimizer_temporary_table.result-pq b/mysql-test/suite/innodb/r/optimizer_temporary_table.result-pq new file mode 100644 index 000000000..48f359d01 --- /dev/null +++ b/mysql-test/suite/innodb/r/optimizer_temporary_table.result-pq @@ -0,0 +1,4825 @@ +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 'test.t1' +Note 1051 Unknown table 'test.t2' +create table t1 (a int, b varchar(20)); +create table t2 (a int, b varchar(20)); +insert into t1 values(1, 'a'), (2, 'b'), (3, 'c'), (3, 'c'), (4, 'c'); +insert into t2 values(2, 'd'), (3, 'e'), (4, 'f'), (4, 'f'), (5, 'e'); +drop function if exists func1; +Warnings: +Note 1305 FUNCTION test.func1 does not exist +create function func1(x int) returns int deterministic +begin +declare z1, z2 int; +set z1 = x; +set z2 = z1 + 2; +return z2; +end| +drop table if exists t3; +Warnings: +Note 1051 Unknown table 'test.t3' +create table t3 like t1; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +insert into t3 select 5 + 10000 * rand(), '5' from t3; +drop table if exists t4; +Warnings: +Note 1051 Unknown table 'test.t4' +create table t4 (a int, b int, c int, d char, e blob); +insert into t4 values (1, 2, 3, '4', '5'); +drop table if exists t5; +Warnings: +Note 1051 Unknown table 'test.t5' +create table t5 (a int, b int primary key); +insert into t5 values (1,7), (1,8); +drop table if exists t6; +Warnings: +Note 1051 Unknown table 'test.t6' +create table t6 (a int, b int, c int, d char); +insert into t6 values(1, 2, 3, '4'); +create index t6_indx1 on t6(a); +drop table if exists t7; +Warnings: +Note 1051 Unknown table 'test.t7' +create table t7 (a int, b varchar(20)); +insert into t7 values(1, 'a'), (2, 'b'), (3, 'c'), (3, 'c'), (4, 'c'); +create index indx7 on t7(b); +drop table if exists t8; +Warnings: +Note 1051 Unknown table 'test.t8' +create table t8 ( +pk integer auto_increment, col_int_key integer, +col_varchar_key varchar(1), primary key (pk), +key (col_int_key), key (col_varchar_key, col_int_key)) engine = innodb; +insert into t8 values (1, 2, 'v'), (2, 150, 'v'); +drop table if exists t9, t10; +Warnings: +Note 1051 Unknown table 'test.t9' +Note 1051 Unknown table 'test.t10' +create table t9 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_date_nokey date default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_varchar_key (col_int_key) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1831 Duplicate index 'col_varchar_key' defined on the table 'test.t9'. This is deprecated and will be disallowed in a future release. +create table t10 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_date_nokey date default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_varchar_key (col_int_key) +) engine=innodb; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1831 Duplicate index 'col_varchar_key' defined on the table 'test.t10'. This is deprecated and will be disallowed in a future release. +insert into t9 values +(1, 2, 4, '2008-12-05', '2008-12-05'), +(2, 150, 62, '2005-03-27', '2005-03-27'), +(3, NULL, 7, '2004-04-09', '2004-04-09'), +(4, 2, 1, '2006-05-13', '2006-05-13'), +(5, 5, 0, '2001-05-06', '2001-05-06'), +(6, 3, 7, '2006-03-03', '2006-03-03'), +(7, 1, 7, '2007-12-28', '2007-12-28'), +(8, 4, 1, '2004-10-20', '2004-10-20'), +(9, NULL, 7, '2008-04-09', '2008-04-09'), +(10, 2, 1, '2005-12-25', '2005-12-25'), +(11, 6, 5, '1900-01-01', '1900-01-01'), +(12, 6, 2, NULL, NULL), +(13, 8, 0, '1900-01-01', '1900-01-01'), +(14, 2, 1, '2001-01-16', '2001-01-16'), +(15, 6, 8, '1900-01-01', '1900-01-01'), +(16, 8, 1, '2001-11-23', '2001-11-23'), +(17, 3, 1, '2004-11-04', '2004-11-04'), +(18, 3, 9, '2003-03-12', '2003-03-12'), +(19, 9, 1, '2002-06-22', '2002-06-22'), +(20, 6, 5, '2004-10-10', '2004-10-10'); +insert into t10 values +(1, 8, 4, '2002-01-03', '2002-01-03'), +(2, 3, 5, '2007-07-08', '2007-07-08'), +(3, 3, 8, '2000-08-02', '2000-08-02'), +(4, NULL, 4, '2000-03-06', '2000-03-06'), +(5, 7, 8, '2002-06-05', '2002-06-05'), +(6, 4, 2, '2009-08-09', '2009-08-09'), +(7, 7, 9, '2001-03-22', '2001-03-22'), +(8, 7, 6, '2002-10-08', '2002-10-08'), +(9, 8, NULL, NULL, NULL), +(10, 6, NULL, '2007-09-13', '2007-09-13'), +(11, 3, 48, '2003-12-08', '2003-12-08'), +(12, 210, 228, '2006-06-01', '2006-06-01'), +(13, 1, 3, '2001-10-04', '2001-10-04'), +(14, 2, 5, '2004-11-16', '2004-11-16'), +(15, 251, 39, NULL, NULL), +(16, 4, 6, '2005-06-22', '2005-06-22'), +(17, 4, 8, '2003-04-19', '2003-04-19'), +(18, 9, 3, '2006-03-23', '2006-03-23'), +(19, 4, NULL, NULL, NULL), +(20, NULL, 2, '2008-10-22', '2008-10-22'), +(21, 4, 6, '2009-04-04', '2009-04-04'), +(22, NULL, 3, NULL, NULL), +(23, 1, 1, '2001-07-15', '2001-07-15'), +(24, 6, 4, '2004-09-25', '2004-09-25'), +(25, 2, 3, '2001-02-20', '2001-02-20'), +(26, NULL, 1, '1900-01-01', '1900-01-01'), +(27, 4, NULL, '2004-08-02', '2004-08-02'), +(28, 248, 97, '2009-02-26', '2009-02-26'), +(29, 4, 0, '2002-11-23', '2002-11-23'), +(30, 8, 0, '2008-12-17', '2008-12-17'), +(31, 4, 9, '2005-08-26', '2005-08-26'), +(32, 5, 5, '2001-03-10', '2001-03-10'), +(33, 9, 9, '1900-01-01', '1900-01-01'), +(34, 2, 0, '2003-08-04', '2003-08-04'), +(35, 4, 2, '2007-11-06', '2007-11-06'), +(36, 211, 172, '2009-04-23', '2009-04-23'), +(37, 2, NULL, '2002-10-06', '2002-10-06'), +(38, 4, 5, '2008-02-12', '2008-02-12'), +(39, 125, 119, '2007-09-18', '2007-09-18'), +(40, 9, 1, '2007-06-26', '2007-06-26'), +(41, 4, 4, NULL, NULL), +(42, 8, 8, '2009-05-05', '2009-05-05'), +(43, 8, NULL, '2003-05-04', '2003-05-04'), +(44, NULL, 6, '2003-11-10', '2003-11-10'), +(45, 8, 5, '2009-02-19', '2009-02-19'), +(46, 4, 5, '2006-11-17', '2006-11-17'), +(47, 8, 1, '2000-02-23', '2000-02-23'), +(48, NULL, 7, '1900-01-01', '1900-01-01'), +(49, 1, 2, '2003-04-08', '2003-04-08'), +(50, 3, 8, '2006-07-08', '2006-07-08'), +(51, 5, 9, '2001-05-21', '2001-05-21'), +(52, 8, NULL, NULL, NULL), +(53, 7, NULL, '2009-01-05', '2009-01-05'), +(54, 2, 3, '2001-08-05', '2001-08-05'), +(55, NULL, 172, '2000-11-01', '2000-11-01'), +(56, 3, NULL, '2004-12-16', '2004-12-16'), +(57, NULL, 6, '2003-02-06', '2003-02-06'), +(58, 9, 6, '2008-04-23', '2008-04-23'), +(59, 1, 5, '2005-12-20', '2005-12-20'), +(60, 0, 4, '2002-03-13', '2002-03-13'), +(61, 0, 3, NULL, NULL), +(62, 8, 2, '2006-07-20', '2006-07-20'), +(63, NULL, 7, '2002-12-19', '2002-12-19'), +(64, 9, 4, '2001-07-09', '2001-07-09'), +(65, 1, 6, '2006-05-27', '2006-05-27'), +(66, 9, 0, '2007-02-26', '2007-02-26'), +(67, 7, 8, NULL, NULL), +(68, 2, 5, '2007-02-07', '2007-02-07'), +(69, 1, 8, '2005-01-22', '2005-01-22'), +(70, 9, 2, '2006-04-25', '2006-04-25'), +(71, 5, 9, '2002-11-13', '2002-11-13'), +(72, 4, 7, '2007-10-26', '2007-10-26'), +(73, 6, 5, '2003-06-16', '2003-06-16'), +(74, 5, 7, '2006-01-18', '2006-01-18'), +(75, 2, 0, '1900-01-01', '1900-01-01'), +(76, 4, 4, '2000-09-13', '2000-09-13'), +(77, 0, 3, '2003-01-26', '2003-01-26'), +(78, 3, 1, '2002-09-09', '2002-09-09'), +(79, 0, 0, '2001-09-06', '2001-09-06'), +(80, 6, 6, '2006-02-23', '2006-02-23'), +(81, 1, 2, '2004-06-21', '2004-06-21'), +(82, 9, NULL, '2006-12-02', '2006-12-02'), +(83, 4, 8, '2005-05-17', '2005-05-17'), +(84, 9, NULL, '2001-12-27', '2001-12-27'), +(85, 4, NULL, '2008-04-11', '2008-04-11'), +(86, 1, NULL, '2000-09-24', '2000-09-24'), +(87, 2, 3, '2004-04-20', '2004-04-20'), +(88, 8, 7, '2008-07-10', '2008-07-10'), +(89, 1, 3, '2007-08-14', '2007-08-14'), +(90, 0, 5, '2008-06-08', '2008-06-08'), +(91, 2, 5, '2001-07-26', '2001-07-26'), +(92, 0, 1, '2008-09-17', '2008-09-17'), +(93, 1, 2, NULL, NULL), +(94, 2, 1, '2004-02-25', '2004-02-25'), +(95, NULL, 7, '2009-11-02', '2009-11-02'), +(96, 3, 1, '2001-12-14', '2001-12-14'), +(97, 8, 9, NULL, NULL), +(98, 4, 9, '1900-01-01', '1900-01-01'), +(99, 4, 8, '2002-04-12', '2002-04-12'), +(100, NULL, 3, '2000-02-09', '2000-02-09'); +create table t11 ( +col_date_key date default null, +col_varchar_10_utf8 varchar(10) CHARACTER SET utf8 default null, +col_varchar_10_latin1 varchar(10) default null, +col_varchar_10_latin1_key varchar(10) default null, +col_datetime datetime default null, +col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8 default null, +col_varchar_1024_latin1_key varchar(1024) default null, +col_varchar_1024_latin1 varchar(1024) default null, +col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 default null, +col_int_key int(11) default null, +col_date date default null, +col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 default null, +col_int int(11) default null, +pk int(11) not null auto_increment, +col_datetime_key datetime default null, +primary key (pk), +key col_date_key (col_date_key), +key col_varchar_10_latin1_key (col_varchar_10_latin1_key), +key col_varchar_10_utf8_key (col_varchar_10_utf8_key), +key col_varchar_1024_latin1_key (col_varchar_1024_latin1_key(1000)), +key col_int_key (col_int_key), +key col_varchar_1024_utf8_key (col_varchar_1024_utf8_key(333)), +key col_datetime_key (col_datetime_key) +) engine=myisam auto_increment=76 default charset=latin1; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert ignore into t11 values +('2005-03-10','have','o','gryvuwdllyhymuwyypoiuyeqbnaanbur','2004','going','h','well','f',1140785152,'2003','YTLDF',NULL,NULL,'20050908213850.042201'), +('2003', 'g', 'ELTFL', 'got', '20:07:16.048352', 'ryvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnvspyaftisgdbkzlevczyrlossygtnatwcobbtsxqhjrdykmthpyzmdgyirxwlidiknxwsufkyexucekyhivscjdcouswuiyltrpmrngriwvrxgovfyewdsvlwirfzkwexxzoccufvuvhsjfvuwjsrrzguntudxxhblzbescayrbbrijnvucxxmbyltlojlgcweddzrfxsmwnxxewigapgrowtmrlqsknuaegzfvdwfdnnbfyubwckwfdrwmrymagyswwvvyeqhaaskgxogthhrzsdlsyqoeuvhwxquwbnivpowtybzehvbsoppuefqngkqohtdeylosjyvtxuziotnfpbqxkpxvzcjbgxokjzitakfevxduhtudsslluhzgcwgrcrtpnczgxchnmmgnubjzvvuklklfhiupbsjzhcqyadhskxtjzabzesulhgpykga', 'she', 'have', 'PYJKD', 9, '2008-06-10', 'yvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnv', NULL, NULL, '2008-01-09'); +create table t12 (t text, c char(10), b blob, d varbinary(10)) engine=innodb; +insert into t12 values (NULL, NULL, NULL,NULL); +insert into t12 values ("", "", "", ""); +insert into t12 values ("hello", "hello", "hello", "hello"); +insert into t12 values ("HELLO", "HELLO","HELLO", "HELLO"); +insert into t12 values ("HELLO MY", "HELLO MY", "HELLO MY", "HELLO MY"); +insert into t12 values ("a", "a", "a", "a"); +insert into t12 values (1,1,1,1); +insert into t12 values (NULL,NULL,NULL,NULL); +create table t13 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_time_key time default null, +col_varchar_key varchar(1) default null, +col_varchar_nokey varchar(1) default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_time_key (col_time_key), +key col_varchar_key (col_varchar_key, col_int_key) +) engine=myisam auto_increment=21; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t13 values +(2, 150, 62, '2005-03-27', '14:26:02', 'v', 'v'), +(3, NULL, 7, '2004-04-09', '14:03:03', 'c', 'c'), +(4, 2, 1, '2006-05-13', '01:46:09', NULL, NULL), +(5, 5, 0, '2001-05-06', '16:21:18', 'x', 'x'), +(6, 3, 7, '2006-03-03', '18:56:33', 'i', 'i'), +(7, 1, 7, '2007-12-28', NULL, 'e', 'e'), +(8, 4, 1, '2004-10-20', '09:29:08', 'p', 'p'), +(9, NULL, 7, '2008-04-09', '19:11:10', 's', 's'), +(10, 2, 1, '2005-12-25', '11:57:26', 'j', 'j'), +(11, 6, 5, '1900-01-01', '00:39:46', 'z', 'z'), +(12, 6, 2, NULL, '03:28:15', 'c', 'c'), +(13, 8, 0, '1900-01-01', '06:44:18', 'a', 'a'), +(14, 2, 1, '2001-01-16', '14:36:39', 'q', 'q'), +(15, 6, 8, '1900-01-01', '18:42:45', 'y', 'y'), +(16, 8, 1, '2001-11-23', '02:57:29', NULL, NULL), +(17, 3, 1, '2004-11-04', '16:46:13', 'r', 'r'), +(18, 3, 9, '2003-03-12', '19:39:02', 'v', 'v'), +(19, 9, 1, '2002-06-22', NULL, NULL, NULL), +(20, 6, 5, '2004-10-10', '20:58:33', 'r', 'r'); +create table t14 ( +pk int(11) not null auto_increment, +col_int_nokey int(11) default null, +col_int_key int(11) default null, +col_date_key date default null, +col_time_key time default null, +col_varchar_key varchar(1) default null, +col_varchar_nokey varchar(1) default null, +primary key (pk), +key col_int_key (col_int_key), +key col_date_key (col_date_key), +key col_time_key (col_time_key), +key col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=myisam auto_increment=30; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t14 values +(10, NULL, 8, '2000-12-03', '22:55:23', 'x', 'x'), +(11, 8, 7, '2008-05-03', '10:19:31', 'd', 'd'), +(12, 1, 1, '2005-12-06', '14:40:36', 'r', 'r'), +(13, 9, 7, '2000-04-10', '04:37:47', 'f', 'f'), +(14, 4, 9, '2002-11-05', '19:34:06', 'y', 'y'), +(15, 3, NULL, '2000-09-06', '20:35:33', 'u', 'u'), +(16, 2, 1, NULL, NULL, 'm', 'm'), +(17, NULL, 9, '2007-06-14', '14:43:37', NULL, NULL), +(18, 2, 2, '2007-11-17', '02:23:09', 'o', 'o'), +(19, NULL, 9, '2009-02-23', '01:22:45', 'w', 'w'), +(20, 6, 2, '2007-01-08', '00:00:00', 'm', 'm'), +(21, 7, 4, '2008-06-10', '00:13:25', 'q', 'q'), +(22, 2, 0, '2002-10-20', '03:47:16', NULL, NULL), +(23, 5, 4, '2008-09-12', '01:41:48', 'd', 'd'), +(24, 7, 8, '2006-06-16', '00:00:00', 'g', 'g'), +(25, 6, NULL, '2004-09-18', '22:32:04', 'x', 'x'), +(26, 6, NULL, '1900-01-01', '16:44:14', 'f', 'f'), +(27, 2, 0, '2005-09-13', '17:38:37', 'p', 'p'), +(28, 9, NULL, '2007-04-09', '08:46:48', 'j', 'j'), +(29, 6, 8, '2000-09-20', '14:11:27', 'c', 'c'); +analyze table t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +test.t4 analyze status OK +test.t5 analyze status OK +test.t6 analyze status OK +test.t7 analyze status OK +test.t8 analyze status OK +test.t9 analyze status OK +test.t10 analyze status OK +test.t11 analyze status OK +test.t12 analyze status OK +test.t13 analyze status OK +test.t14 analyze status OK +# restart: --big-tables=1 +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format = json select sql_buffer_result * from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +select sql_buffer_result * from t1; +a b +1 a +2 b +3 c +3 c +4 c +explain format = json select sql_buffer_result * from t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select sql_buffer_result * from t2; +a b +2 d +3 e +4 f +4 f +5 e +explain format = json select * from t1 left join t2 on t1.b = t2.b order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "25.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`b` = `test`.`t1`.`b`), true)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true order by `test`.`t1`.`a` +select * from t1 left join t2 on t1.b = t2.b order by t1.a; +a b a b +1 a NULL NULL +2 b NULL NULL +3 c NULL NULL +3 c NULL NULL +4 c NULL NULL +explain format = json select * from t1 order by func1(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `func1`(`test`.`t1`.`a`) +select * from t1 order by func1(a); +a b +1 a +2 b +3 c +3 c +4 c +explain format = json select a from t1 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t1.a)", + "b", + "a" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b` order by sum(`sum(t1.a)`) +select a from t1 group by b order by sum(a); +a +1 +2 +3 +explain format = json select a from t7 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t7.a)", + "b", + "a" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t7", + "access_type": "index", + "possible_keys": [ + "indx7" + ], + "key": "indx7", + "used_key_parts": [ + "b" + ], + "key_length": "83", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t7`.`a` AS `a` from `test`.`t7` group by `test`.`t7`.`b` order by sum(`sum(t7.a)`) +select a from t7 group by b order by sum(a); +a +1 +2 +3 +explain format = json select sql_big_result distinct * from t1, t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` +select sql_big_result distinct * from t1, t2; +a b a b +1 a 2 d +1 a 3 e +1 a 4 f +1 a 5 e +2 b 2 d +2 b 3 e +2 b 4 f +2 b 5 e +3 c 2 d +3 c 3 e +3 c 4 f +3 c 5 e +4 c 2 d +4 c 3 e +4 c 4 f +4 c 5 e +explain format = json select sql_big_result t1.b from t1, t2 group by t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`b` +select sql_big_result t1.b from t1, t2 group by t1.b; +b +a +b +c +explain format = json select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`,`test`.`t1`.`b` +select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +a +1 +2 +3 +4 +explain format = json select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t2`.`a` +select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +a b +2 b +3 c +3 c +4 c +4 c +explain format = json select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`a` +select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +a b +2 b +3 c +3 c +4 c +4 c +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +a b +2 b +3 c +4 c +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t2`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +a b +2 b +3 c +4 c +explain format = json select a from t1 group by a order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a` +select a from t1 group by a order by a; +a +1 +2 +3 +4 +explain format = json select b from t1 group by b order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`b` order by `test`.`t1`.`a` +select b from t1 group by b order by a; +b +a +b +c +explain format = json select distinct t1.a from t1, t2 where t1.b = t2.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`b`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +select distinct t1.a from t1, t2 where t1.b = t2.b; +a +explain format = json select distinct a from t1 group by b,a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b`,`test`.`t1`.`a` +select distinct a from t1 group by b,a; +a +1 +2 +3 +4 +set @old_sort_buffer_size = @@sort_buffer_size; +set @@sort_buffer_size = 32804; +explain format = json select distinct b from t3 group by a having count(*) > 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "88" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t3`.`b` AS `b` from `test`.`t3` group by `test`.`t3`.`a` having (count(0) > 1) +select distinct b from t3 group by a having count(*) > 1; +b +select distinct b from t3 group by a; +b +set @@sort_buffer_size = @old_sort_buffer_size; +explain format = json select distinct t4.a,e from t4, t1 order by t4.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.11" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "cost_info": { + "sort_cost": "5.00" + }, + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b", + "e" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.27", + "eval_cost": "0.50", + "prefix_cost": "1.12", + "data_read_per_join": "440" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t4`.`a` AS `a`,`test`.`t4`.`e` AS `e` from `test`.`t4` join `test`.`t1` order by `test`.`t4`.`b` +select distinct t4.a,e from t4, t1 order by t4.b; +a e +1 5 +explain format = json select * from t1 union all select * from t2; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": false, + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select * from t1 union all select * from t2; +a b +1 a +2 b +3 c +3 c +4 c +2 d +3 e +4 f +4 f +5 e +explain format = json select * from t1 union select * from t2 order by b; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": true, + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `b` +select * from t1 union select * from t2 order by b; +a b +1 a +2 b +3 c +4 c +2 d +3 e +5 e +4 f +explain format = json select tt.* from (select * from t1) as tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`a` AS `a`,`tt`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `tt` +select tt.* from (select * from t1) as tt; +a b +1 a +2 b +3 c +3 c +4 c +select * from t5; +a b +1 7 +1 8 +explain format = json select b from (select b from t5 where b > 5) tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "t5", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "b" + ], + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t5`.`b` > 5)" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`b` AS `b` from (/* select#2 */ select `test`.`t5`.`b` AS `b` from `test`.`t5` where (`test`.`t5`.`b` > 5)) `tt` +select b from (select b from t5 where b > 5) tt; +b +7 +8 +explain format = json select * from (select b from t1) as t1, (select b from t2) as t2; +EXPLAIN + "b" + "b" + "data_read_per_join": "440" + "data_read_per_join": "440" + "eval_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "prefix_cost": "0.75", + "read_cost": "0.25", + "read_cost": "0.25", + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "query_cost": "0.75" + "query_cost": "0.75" + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + ] + ] + }, + }, + "cost_info": { + "cost_info": { + "select_id": 2, + "select_id": 3, + "table": { + "table": { + } + } + }, + }, + "b" + "b" + "cacheable": true, + "cacheable": true, + "data_read_per_join": "2K" + "data_read_per_join": "440" + "dependent": false, + "dependent": false, + "eval_cost": "0.50", + "eval_cost": "2.50", + "prefix_cost": "1.00", + "prefix_cost": "4.00", + "query_block": { + "query_block": { + "read_cost": "0.50", + "read_cost": "0.50", + "using_temporary_table": true, + "using_temporary_table": true, + } + } + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "materialized_from_subquery": { + "materialized_from_subquery": { + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + "using_join_buffer": "hash join", + ], + ], + } + } + }, + }, + "table": { + "table": { + } + } + "query_cost": "4.00" + { + { + } + }, + "cost_info": { + "nested_loop": [ + "select_id": 1, + ] + }, + "query_block": { + } +Note 1003 /* select#1 */ select `t1`.`b` AS `b`,`t2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) `t1` join (/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `t2` +Warnings: +{ +} +select * from (select b from t1) as t1, (select b from t2) as t2; +b b +a d +a e +a e +a f +a f +b d +b e +b e +b f +b f +c d +c d +c d +c e +c e +c e +c e +c e +c e +c f +c f +c f +c f +c f +c f +explain format = json select * from t1, (select * from t6) as t where t.a =5; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.95" + }, + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "t6", + "access_type": "ref", + "possible_keys": [ + "t6_indx1" + ], + "key": "t6_indx1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.95", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`t`.`a` AS `a`,`t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `test`.`t1` join (/* select#2 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`c` AS `c`,`test`.`t6`.`d` AS `d` from `test`.`t6` where (`test`.`t6`.`a` = 5)) `t` +select * from t1, (select * from t6) as t where t.a =5; +a b a b c d +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(`test`.`t1`.`a` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.t1.a" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +2 b +3 c +3 c +4 c +set optimizer_switch='materialization=off'; +set optimizer_switch='firstmatch=off'; +set optimizer_switch='loosescan=off'; +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.50" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "query_block": { + "cost_info": { + "query_cost": "5.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "5.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +2 b +3 c +3 c +4 c +set optimizer_switch='default,derived_merge=off'; +explain format = json update t1, t2 set t1.a = 9, t2.a = 10 where t1.b = 'a'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.50" + }, + "nested_loop": [ + { + "table": { + "update": true, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 1, + "filtered": "20.00", + "cost_info": { + "read_cost": "0.65", + "eval_cost": "0.10", + "prefix_cost": "0.75", + "data_read_per_join": "88" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(`test`.`t1`.`b` = 'a')" + } + }, + { + "table": { + "update": true, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "1.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 9,`test`.`t2`.`a` = 10 where (`test`.`t1`.`b` = 'a') +update t1, t2 set t1.a = 9, t2.a = 10 where t1.b = 'a'; +explain format = json select count(distinct a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `count(distinct a)` from `test`.`t1` +select count(distinct a) from t1; +count(distinct a) +4 +explain format = json select b, group_concat(a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,group_concat(`test`.`t1`.`a` separator ',') AS `group_concat(a)` from `test`.`t1` +select b, group_concat(a) from t1; +b group_concat(a) +a 9,2,3,3,4 +select * from t1; +a b +9 a +2 b +3 c +3 c +4 c +explain format = json select b, count(a), sum(a), avg(a), std(a), +min(a), max(a), bit_and(a), bit_or(a) from t1 group by b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) AS `count(a)`,sum(`test`.`t1`.`a`) AS `sum(a)`,avg(`test`.`t1`.`a`) AS `avg(a)`,std(`test`.`t1`.`a`) AS `std(a)`,min(`test`.`t1`.`a`) AS `min(a)`,max(`test`.`t1`.`a`) AS `max(a)`,bit_and(`test`.`t1`.`a`) AS `bit_and(a)`,bit_or(`test`.`t1`.`a`) AS `bit_or(a)` from `test`.`t1` group by `test`.`t1`.`b` +select b, count(a), sum(a), avg(a), std(a), min(a), +max(a), bit_and(a), bit_or(a) from t1 group by b; +b count(a) sum(a) avg(a) std(a) min(a) max(a) bit_and(a) bit_or(a) +a 1 9 9.0000 0 9 9 9 9 +b 1 2 2.0000 0 2 2 2 2 +c 3 10 3.3333 0.4714045207910316 3 4 0 7 +select sql_big_result * from performance_schema.global_variables where variable_name like 'internal_tmp_mem_storage_engine'; +VARIABLE_NAME VARIABLE_VALUE +internal_tmp_mem_storage_engine TempTable +select 1 union distinct select 1 union all select 1; +1 +1 +1 +select alias1.`col_int_key` AS field1 from (t8 as alias1) where (5) in +(select 7 union select 1) order by alias1.`col_varchar_key` asc; +field1 +select count(table2.col_date_key) as field1 from +(t10 as table1 inner join +((t10 as table2 right join +t9 as table3 on +((table3.pk = table2.pk) or +(table3.pk = table2.col_int_key)))) +on ((table3.pk < table2.col_int_nokey))) +order by field1 ASC; +field1 +2200 +select distinct table1.col_varchar_1024_utf8_key as field1 +from t11 as table1 left join t11 as table2 on +table1.col_varchar_1024_utf8 = table2.col_varchar_1024_latin1_key +order by field1; +field1 +YTLDF +yvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnv +select t from t12 group by c; +t +NULL + +1 +a +hello +HELLO MY +select count(outr.col_varchar_nokey) AS x +from t13 as outr2 left join +(select * from t13) as outr +on (outr2.col_time_key > outr.col_date_key) +where outr.pk in +(select innr.col_int_nokey AS y from +(select * from t14) as innr2 left join +(select * from t14) AS innr +ON (innr2.col_int_nokey = innr.col_int_key) +where innr.col_varchar_nokey > innr.col_varchar_key +or not outr.pk > 9) +or outr.col_varchar_key is null; +x +102 +SET @@optimizer_switch=@optimizer_switch_saved; +SET GLOBAL innodb_fast_shutdown = 0; +# restart: --big-tables=1 --innodb-read-only +SET @optimizer_switch_saved= @@optimizer_switch; +SET @@optimizer_switch="derived_merge=off"; +explain format = json select sql_buffer_result * from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` +select sql_buffer_result * from t1; +a b +9 a +2 b +3 c +3 c +4 c +explain format = json select sql_buffer_result * from t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "buffer_result": { + "using_temporary_table": true, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "buffer_result": { + "using_temporary_table": true, + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_buffer_result `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select sql_buffer_result * from t2; +a b +10 d +10 e +10 f +10 f +10 e +explain format = json select * from t1 left join t2 on t1.b = t2.b order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "28.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "25.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(is_not_null_compl(t2), (`test`.`t2`.`b` = `test`.`t1`.`b`), true)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where true order by `test`.`t1`.`a` +select * from t1 left join t2 on t1.b = t2.b order by t1.a; +a b a b +2 b NULL NULL +3 c NULL NULL +3 c NULL NULL +4 c NULL NULL +9 a NULL NULL +explain format = json select * from t1 order by func1(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `func1`(`test`.`t1`.`a`) +select * from t1 order by func1(a); +a b +2 b +3 c +3 c +4 c +9 a +explain format = json select a from t1 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t1.a)", + "b", + "a" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b` order by sum(`sum(t1.a)`) +select a from t1 group by b order by sum(a); +a +2 +9 +3 +explain format = json select a from t7 group by b order by sum(a); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "560" + }, + "used_columns": [ + "sum(t7.a)", + "b", + "a" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "grouping_operation": { + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t7", + "access_type": "index", + "possible_keys": [ + "indx7" + ], + "key": "indx7", + "used_key_parts": [ + "b" + ], + "key_length": "83", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t7`.`a` AS `a` from `test`.`t7` group by `test`.`t7`.`b` order by sum(`sum(t7.a)`) +select a from t7 group by b order by sum(a); +a +1 +2 +3 +explain format = json select sql_big_result distinct * from t1, t2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` +select sql_big_result distinct * from t1, t2; +a b a b +2 b 10 d +2 b 10 e +2 b 10 f +3 c 10 d +3 c 10 e +3 c 10 f +4 c 10 d +4 c 10 e +4 c 10 f +9 a 10 d +9 a 10 e +9 a 10 f +explain format = json select sql_big_result t1.b from t1, t2 group by t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select sql_big_result `test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`b` +select sql_big_result t1.b from t1, t2 group by t1.b; +b +a +b +c +explain format = json select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "2.50", + "prefix_cost": "3.50", + "data_read_per_join": "2K" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct sql_big_result `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`,`test`.`t1`.`b` +select sql_big_result distinct t1.a from t1, t2 group by t1.a, t1.b; +a +2 +3 +4 +9 +explain format = json select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t2`.`a` +select t1.* from t1 inner join t2 on t1.a = t2.a order by t2.a; +a b +explain format = json select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "8.50" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) order by `test`.`t1`.`a` +select t1.* from t1, t2 where t1.a = t2.a order by t1.a; +a b +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t1`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t1.a; +a b +explain format = json select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "a", + "b" + ], + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`a`) group by `test`.`t2`.`a` +select t1.* from t1 inner join t2 where t1.a = t2.a group by t2.a; +a b +explain format = json select a from t1 group by a order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.75" + }, + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "cost_info": { + "sort_cost": "5.00" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "80" + }, + "used_columns": [ + "a" + ], + "ordering_operation": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": true, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` order by `test`.`t1`.`a` +select a from t1 group by a order by a; +a +2 +3 +4 +9 +explain format = json select b from t1 group by b order by a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "ordering_operation": { + "using_filesort": true, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` group by `test`.`t1`.`b` order by `test`.`t1`.`a` +select b from t1 group by b order by a; +b +b +c +a +explain format = json select distinct t1.a from t1, t2 where t1.b = t2.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "3.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t2`.`b` = `test`.`t1`.`b`)" + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +select distinct t1.a from t1, t2 where t1.b = t2.b; +a +explain format = json select distinct a from t1 group by b,a; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`b`,`test`.`t1`.`a` +select distinct a from t1 group by b,a; +a +2 +3 +4 +9 +set @old_sort_buffer_size = @@sort_buffer_size; +set @@sort_buffer_size = 32804; +explain format = json select distinct b from t3 group by a having count(*) > 1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "duplicates_removal": { + "using_filesort": false, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t3", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "88" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t3`.`b` AS `b` from `test`.`t3` group by `test`.`t3`.`a` having (count(0) > 1) +select distinct b from t3 group by a having count(*) > 1; +b +select distinct b from t3 group by a; +b +set @@sort_buffer_size = @old_sort_buffer_size; +explain format = json select distinct t4.a,e from t4, t1 order by t4.b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "6.11" + }, + "ordering_operation": { + "using_temporary_table": true, + "using_filesort": true, + "duplicates_removal": { + "using_temporary_table": true, + "using_filesort": false, + "cost_info": { + "sort_cost": "5.00" + }, + "nested_loop": [ + { + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "32" + }, + "used_columns": [ + "a", + "b", + "e" + ] + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "distinct": true, + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.27", + "eval_cost": "0.50", + "prefix_cost": "1.12", + "data_read_per_join": "440" + } + } + } + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t4`.`a` AS `a`,`test`.`t4`.`e` AS `e` from `test`.`t4` join `test`.`t1` order by `test`.`t4`.`b` +select distinct t4.a,e from t4, t1 order by t4.b; +a e +1 5 +explain format = json select * from t1 union all select * from t2; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": false, + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union all /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` +select * from t1 union all select * from t2; +a b +9 a +2 b +3 c +3 c +4 c +10 d +10 e +10 f +10 f +10 e +explain format = json select * from t1 union select * from t2 order by b; +EXPLAIN +{ + "query_block": { + "union_result": { + "using_temporary_table": true, + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + }, + { + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `b` +select * from t1 union select * from t2 order by b; +a b +9 a +2 b +3 c +4 c +10 d +10 e +10 f +explain format = json select tt.* from (select * from t1) as tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.00" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "1.00", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`a` AS `a`,`tt`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) `tt` +select tt.* from (select * from t1) as tt; +a b +9 a +2 b +3 c +3 c +4 c +select * from t5; +a b +1 7 +1 8 +explain format = json select b from (select b from t5 where b > 5) tt; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.70" + }, + "table": { + "table_name": "tt", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.45" + }, + "table": { + "table_name": "t5", + "access_type": "index", + "possible_keys": [ + "PRIMARY" + ], + "key": "PRIMARY", + "used_key_parts": [ + "b" + ], + "key_length": "4", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "using_index": true, + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.20", + "prefix_cost": "0.45", + "data_read_per_join": "32" + }, + "used_columns": [ + "b" + ], + "attached_condition": "(`test`.`t5`.`b` > 5)" + } + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `tt`.`b` AS `b` from (/* select#2 */ select `test`.`t5`.`b` AS `b` from `test`.`t5` where (`test`.`t5`.`b` > 5)) `tt` +select b from (select b from t5 where b > 5) tt; +b +7 +8 +explain format = json select * from (select b from t1) as t1, (select b from t2) as t2; +EXPLAIN + "b" + "b" + "data_read_per_join": "440" + "data_read_per_join": "440" + "eval_cost": "0.50", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "prefix_cost": "0.75", + "read_cost": "0.25", + "read_cost": "0.25", + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "query_cost": "0.75" + "query_cost": "0.75" + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + ] + ] + }, + }, + "cost_info": { + "cost_info": { + "select_id": 2, + "select_id": 3, + "table": { + "table": { + } + } + }, + }, + "b" + "b" + "cacheable": true, + "cacheable": true, + "data_read_per_join": "2K" + "data_read_per_join": "440" + "dependent": false, + "dependent": false, + "eval_cost": "0.50", + "eval_cost": "2.50", + "prefix_cost": "1.00", + "prefix_cost": "4.00", + "query_block": { + "query_block": { + "read_cost": "0.50", + "read_cost": "0.50", + "using_temporary_table": true, + "using_temporary_table": true, + } + } + "access_type": "ALL", + "access_type": "ALL", + "cost_info": { + "cost_info": { + "filtered": "100.00", + "filtered": "100.00", + "materialized_from_subquery": { + "materialized_from_subquery": { + "rows_examined_per_scan": 5, + "rows_examined_per_scan": 5, + "rows_produced_per_join": 25, + "rows_produced_per_join": 5, + "table_name": "t1", + "table_name": "t2", + "used_columns": [ + "used_columns": [ + "using_join_buffer": "hash join", + ], + ], + } + } + }, + }, + "table": { + "table": { + } + } + "query_cost": "4.00" + { + { + } + }, + "cost_info": { + "nested_loop": [ + "select_id": 1, + ] + }, + "query_block": { + } +Note 1003 /* select#1 */ select `t1`.`b` AS `b`,`t2`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`b` AS `b` from `test`.`t1`) `t1` join (/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `t2` +Warnings: +{ +} +select * from (select b from t1) as t1, (select b from t2) as t2; +b b +a d +a e +a e +a f +a f +b d +b e +b e +b f +b f +c d +c d +c d +c e +c e +c e +c e +c e +c e +c f +c f +c f +c f +c f +c f +explain format = json select * from t1, (select * from t6) as t where t.a =5; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.95" + }, + "nested_loop": [ + { + "table": { + "table_name": "t", + "access_type": "ALL", + "rows_examined_per_scan": 2, + "rows_produced_per_join": 2, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.20", + "prefix_cost": "0.70", + "data_read_per_join": "48" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ], + "materialized_from_subquery": { + "using_temporary_table": true, + "dependent": false, + "cacheable": true, + "query_block": { + "select_id": 2, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "t6", + "access_type": "ref", + "possible_keys": [ + "t6_indx1" + ], + "key": "t6_indx1", + "used_key_parts": [ + "a" + ], + "key_length": "5", + "ref": [ + "const" + ], + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "24" + }, + "used_columns": [ + "a", + "b", + "c", + "d" + ] + } + } + } + } + }, + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 10, + "filtered": "100.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.95", + "data_read_per_join": "880" + }, + "used_columns": [ + "a", + "b" + ] + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`t`.`a` AS `a`,`t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `test`.`t1` join (/* select#2 */ select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t6`.`c` AS `c`,`test`.`t6`.`d` AS `d` from `test`.`t6` where (`test`.`t6`.`a` = 5)) `t` +select * from t1, (select * from t6) as t where t.a =5; +a b a b c d +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "3.50" + }, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ], + "attached_condition": "(`test`.`t1`.`a` is not null)" + } + }, + { + "table": { + "table_name": "", + "access_type": "eq_ref", + "key": "", + "key_length": "5", + "ref": [ + "test.t1.a" + ], + "rows_examined_per_scan": 1, + "materialized_from_subquery": { + "using_temporary_table": true, + "query_block": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } + } + } + } + ] + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (``.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +set optimizer_switch='materialization=off'; +set optimizer_switch='firstmatch=off'; +set optimizer_switch='loosescan=off'; +explain format = json select * from t1 where t1.a in (select a from t2) ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "5.50" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "480" + }, + "used_columns": [ + "a", + "b" + ], + "query_block": { + "cost_info": { + "query_cost": "5.50" + }, + "duplicates_removal": { + "using_temporary_table": true, + "nested_loop": [ + { + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + }, + { + "table": { + "select_id": 2, + "table_name": "t2", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "20.00", + "using_join_buffer": "hash join", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "5.50", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ], + "attached_condition": "(`test`.`t2`.`a` = `test`.`t1`.`a`)" + } + } + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) +select * from t1 where t1.a in (select a from t2) ; +a b +set optimizer_switch='default,derived_merge=off'; +explain format = json select count(distinct a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select count(distinct `test`.`t1`.`a`) AS `count(distinct a)` from `test`.`t1` +select count(distinct a) from t1; +count(distinct a) +4 +explain format = json select b, group_concat(a) from t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,group_concat(`test`.`t1`.`a` separator ',') AS `group_concat(a)` from `test`.`t1` +select b, group_concat(a) from t1; +b group_concat(a) +a 9,2,3,3,4 +select * from t1; +a b +9 a +2 b +3 c +3 c +4 c +explain format = json select b, count(a), sum(a), avg(a), std(a), +min(a), max(a), bit_and(a), bit_or(a) from t1 group by b; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.75" + }, + "grouping_operation": { + "using_temporary_table": true, + "using_filesort": false, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 5, + "rows_produced_per_join": 5, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.50", + "prefix_cost": "0.75", + "data_read_per_join": "440" + }, + "used_columns": [ + "a", + "b" + ] + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,count(`test`.`t1`.`a`) AS `count(a)`,sum(`test`.`t1`.`a`) AS `sum(a)`,avg(`test`.`t1`.`a`) AS `avg(a)`,std(`test`.`t1`.`a`) AS `std(a)`,min(`test`.`t1`.`a`) AS `min(a)`,max(`test`.`t1`.`a`) AS `max(a)`,bit_and(`test`.`t1`.`a`) AS `bit_and(a)`,bit_or(`test`.`t1`.`a`) AS `bit_or(a)` from `test`.`t1` group by `test`.`t1`.`b` +select b, count(a), sum(a), avg(a), std(a), min(a), +max(a), bit_and(a), bit_or(a) from t1 group by b; +b count(a) sum(a) avg(a) std(a) min(a) max(a) bit_and(a) bit_or(a) +a 1 9 9.0000 0 9 9 9 9 +b 1 2 2.0000 0 2 2 2 2 +c 3 10 3.3333 0.4714045207910316 3 4 0 7 +select sql_big_result * from performance_schema.global_variables where variable_name like 'internal_tmp_mem_storage_engine'; +VARIABLE_NAME VARIABLE_VALUE +internal_tmp_mem_storage_engine TempTable +select 1 union distinct select 1 union all select 1; +1 +1 +1 +select alias1.`col_int_key` AS field1 from (t8 as alias1) where (5) in +(select 7 union select 1) order by alias1.`col_varchar_key` asc; +field1 +select count(table2.col_date_key) as field1 from +(t10 as table1 inner join +((t10 as table2 right join +t9 as table3 on +((table3.pk = table2.pk) or +(table3.pk = table2.col_int_key)))) +on ((table3.pk < table2.col_int_nokey))) +order by field1 ASC; +field1 +2200 +select distinct table1.col_varchar_1024_utf8_key as field1 +from t11 as table1 left join t11 as table2 on +table1.col_varchar_1024_utf8 = table2.col_varchar_1024_latin1_key +order by field1; +field1 +YTLDF +yvuwdllyhymuwyypoiuyeqbnaanbursgddnqhyvxnnpadsjiqdkajofferjfslatroorycttbiuhlubvmoikwwnalqyewgthdmfvsedatazrflwenzeiwdxtheqppbmqfydsawvanehgvfvbsqxzkqzhtjkybvikmpexipoddmoulsnzfchusfgkdazecevrpuakfioamyyqyribcnydfxmmzsxcpkydyczmeajaebsaskneaqwxjbpjptiwgiizoxfygnbjojpifpzldsdhrukdbwpzribxgafunywmmcfpjugozduylotsugqocbadhcnxjqlugncbebwsbobhxgghyyphxfqqnpliazusgjswynfotwdonpbkllfdbuoqceirksegypasuuxnrjumrkaryhkgkbdfgoqbdmrdrmpvwitqzswgossxltimkbtrxitnmigcxgfaqmrnv +select t from t12 group by c; +t +NULL + +1 +a +hello +HELLO MY +select count(outr.col_varchar_nokey) AS x +from t13 as outr2 left join +(select * from t13) as outr +on (outr2.col_time_key > outr.col_date_key) +where outr.pk in +(select innr.col_int_nokey AS y from +(select * from t14) as innr2 left join +(select * from t14) AS innr +ON (innr2.col_int_nokey = innr.col_int_key) +where innr.col_varchar_nokey > innr.col_varchar_key +or not outr.pk > 9) +or outr.col_varchar_key is null; +x +102 +SET @@optimizer_switch=@optimizer_switch_saved; +# restart +select @@big_tables; +@@big_tables +1 +create table t0 (m int, n int, key(m)) engine=innodb; +begin; +select count(*) from t0; +count(*) +0 +set @@session.sql_mode = ANSI; +set @@session.tmp_table_size = 0; +Warnings: +Warning 1292 Truncated incorrect tmp_table_size value: '0' +set @@session.big_tables = 1; +select @@big_tables; +@@big_tables +1 +select event_name, e.min_timer_wait, min(t.min_timer_wait) from +performance_schema.events_waits_summary_global_by_event_name as e JOIN +performance_schema.events_waits_summary_by_thread_by_event_name as t USING +(event_name) group by event_name; +select * from t0; +m n +commit; +drop table t0; +set session big_tables = 1; +select @@big_tables; +@@big_tables +1 +drop function func1; +drop table t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14; +# +# BUG#20762059 - innodb_thread_concurrency=1 and queries using intrinsic +# temp tables, causes hang +# +# Scenario 1: Without timezone tables +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1); +# On default connection +SET @@session.max_heap_table_size=0; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '0' +SET @@global.innodb_thread_concurrency=1; +# Executing I_S query which will create and do index read on +# intrinsic temporary tables +# Switch to connection con1 +SELECT * FROM t1; +a +1 +# Switch to connection default +DROP TABLE t1; +SET @@session.max_heap_table_size = default; +SET @@global.innodb_thread_concurrency = default; +SET @@global.innodb_thread_sleep_delay = default; +# +# Scenario 2: with I_S query and timezone table(uses attachable +# transaction) +# +SET @@session.max_heap_table_size=0; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '0' +SET @@global.innodb_thread_concurrency=1; +# Executing I_S query which will create and do index read on +# intrinsic temporary tables +select convert_tz(0,'a','a'); +convert_tz(0,'a','a') +NULL +SET @@session.max_heap_table_size = default; +SET @@global.innodb_thread_concurrency = default; +SET @@global.innodb_thread_sleep_delay = default; +# +# Scenario 3: with I_S query and help table(uses attachable +# transaction) +# +SET @@global.innodb_thread_concurrency=1; +# Executing I_S query which will create and do index read on +# intrinsic temporary tables +HELP '%function_2'; +name is_it_category +SET @@global.innodb_thread_concurrency = default; +SET @@global.innodb_thread_sleep_delay = default; +# +# Bug#21871451: INNODB: FAILING ASSERTION: !(&BUF_POOL->MUTEX) +# +SELECT 'SUCCESS_INNODB_CMPMEM' FROM DUAL WHERE EXISTS +(SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM); +SUCCESS_INNODB_CMPMEM +SUCCESS_INNODB_CMPMEM +SELECT 'SUCCESS_INNODB_CMP' FROM DUAL WHERE EXISTS +(SELECT * FROM INFORMATION_SCHEMA.INNODB_CMPMEM_RESET); +SUCCESS_INNODB_CMP +SUCCESS_INNODB_CMP diff --git a/mysql-test/suite/innodb/r/select_count_perf.result-pq b/mysql-test/suite/innodb/r/select_count_perf.result-pq new file mode 100644 index 000000000..17c9358dd --- /dev/null +++ b/mysql-test/suite/innodb/r/select_count_perf.result-pq @@ -0,0 +1,1899 @@ +# +# WL#6742 - Test the interaction of multiple transactions using +# different isolation levels to make sure that the value returned +# by count(*) always reflects the correct view of the table according +# to the transaction's selected isolation level. +# +# +# Traverse various indexes to get the right counts. +# This especially tests count(*) which is pushed down to InnoDB in WL#6742. +# +CREATE TABLE t1 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, +c3 INT, +c4 INT, +INDEX k2(c2) +) Engine=InnoDB; +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 (SELECT * FROM t1); +affected rows: 10 +info: Records: 10 Duplicates: 0 Warnings: 0 +CREATE TABLE t3 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, +c3 INT, +c4 INT, +INDEX k2(c2) +) Engine=InnoDB PARTITION BY HASH(c1) PARTITIONS 4; +INSERT INTO t3 (SELECT * FROM t1); +affected rows: 10 +info: Records: 10 Duplicates: 0 Warnings: 0 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +55 +SELECT SUM(c2) FROM t1; +SUM(c2) +10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Do some DML in the default connection and leave the transaction pending. +# +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +UPDATE t1 SET c2 = c2 * 3 WHERE c1 = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +UPDATE t3 SET c2 = c2 * 3 WHERE c1 = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +DELETE FROM t1 WHERE c1 = 6; +affected rows: 1 +DELETE FROM t3 WHERE c1 = 6; +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +49 +SELECT SUM(c2) FROM t1; +SUM(c2) +11 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Start transactions of Repeatable Read, Read Committed, and Read Uncommitted +# +# Connection 1 REPEATABLE READ +# +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +55 +SELECT SUM(c2) FROM t1; +SUM(c2) +10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +UPDATE t1 SET c2 = c2 * 5 WHERE c1 = 2; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +UPDATE t3 SET c2 = c2 * 5 WHERE c1 = 2; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +DELETE FROM t1 WHERE c1 = 7; +affected rows: 1 +DELETE FROM t3 WHERE c1 = 7; +affected rows: 1 +INSERT INTO t1(c2,c3,c4) VALUES (100, 1, 1); +affected rows: 1 +INSERT INTO t3(c2,c3,c4) VALUES (100, 1, 1); +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +113 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Test a lock wait timeout during COUNT(*) +# +SET innodb_lock_wait_timeout = 1; +SELECT COUNT(*) FROM t1 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# +# Connection 2 READ COMMITTED +# +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +55 +SELECT SUM(c2) FROM t1; +SUM(c2) +10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.5000 10 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +UPDATE t1 SET c2 = c2 * 7 WHERE c1 = 3; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +DELETE FROM t1 WHERE c1 = 8; +affected rows: 1 +DELETE FROM t3 WHERE c1 = 8; +affected rows: 1 +INSERT INTO t1(c2,c3,c4) VALUES (1000, 1, 1); +affected rows: 1 +INSERT INTO t3(c2,c3,c4) VALUES (1000, 1, 1); +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +9 1 1 1 +10 1 1 1 +12 1000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +1015 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Connection 3 READ UNCOMMITTED +# +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +BEGIN; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 1 1 1 +5 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +57 +SELECT SUM(c2) FROM t1; +SUM(c2) +1119 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3333 12 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3333 12 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +9 1 +10 1 +11 100 +12 1000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +9 1 +10 1 +11 100 +12 1000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +UPDATE t1 SET c2 = c2 * 11 WHERE c1 = 4; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +UPDATE t3 SET c2 = c2 * 11 WHERE c1 = 4; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +INSERT INTO t1(c2,c3,c4) VALUES (10000, 1, 1); +affected rows: 1 +INSERT INTO t3(c2,c3,c4) VALUES (10000, 1, 1); +affected rows: 1 +DELETE FROM t1 WHERE c1 in(9); +affected rows: 1 +DELETE FROM t3 WHERE c1 in(9); +affected rows: 1 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection default REPEATABLE READ +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +49 +SELECT SUM(c2) FROM t1; +SUM(c2) +11 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Commit the 3 extra connections +# +# Connection 1 REPEATABLE READ +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +113 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Connection 2 READ COMMITTED +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +9 1 1 1 +10 1 1 1 +12 1000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +1015 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 12 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +9 1 +10 1 +12 1000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Connection 3 READ UNCOMMITTED +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +COMMIT; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection 2 READ COMMITTED +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +10 1 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +63 +SELECT SUM(c2) FROM t1; +SUM(c2) +11024 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +COMMIT; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 1 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +6 1 1 1 +7 1 1 1 +10 1 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +63 +SELECT SUM(c2) FROM t1; +SUM(c2) +11024 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.3000 13 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +7 1 +10 1 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection 1 REPEATABLE READ +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +6 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +11 100 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +59 +SELECT SUM(c2) FROM t1; +SUM(c2) +113 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.9000 11 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +8 1 +9 1 +10 1 +11 100 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +5 +############################################### +# +# Select the first 5 records FOR UPDATE using count(*) in a subquery. +# The second record is still pending so we get a lock timeout. +# +SET innodb_lock_wait_timeout = 1; +SELECT c1, c2 FROM t1 WHERE c1 < ((SELECT COUNT(*) FROM t1) / 2) FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SELECT COUNT(*) FROM t1 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +COMMIT; +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 1 1 1 +2 5 1 1 +3 7 1 1 +4 11 1 1 +5 1 1 1 +6 1 1 1 +10 1 1 1 +11 100 1 1 +12 1000 1 1 +13 10000 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT COUNT(*) FROM t3; +COUNT(*) +10 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +10 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +10 +SELECT SUM(c1) FROM t1; +SUM(c1) +67 +SELECT SUM(c2) FROM t1; +SUM(c2) +11127 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7000 13 1 1.0000 10 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7000 13 1 1.0000 10 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +6 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +6 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Show The EXPLAIN output for these queries; +# +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3`,`test`.`t1`.`c4` AS `c4` from `test`.`t1` +EXPLAIN SELECT COUNT(*) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +EXPLAIN SELECT COUNT(*) FROM t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t3` +EXPLAIN SELECT COUNT(c1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c1`) AS `COUNT(c1)` from `test`.`t1` +EXPLAIN SELECT COUNT(c2) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c2`) AS `COUNT(c2)` from `test`.`t1` +EXPLAIN SELECT COUNT(c3) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c3`) AS `COUNT(c3)` from `test`.`t1` +EXPLAIN SELECT SUM(c1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`c1`) AS `SUM(c1)` from `test`.`t1` +EXPLAIN SELECT SUM(c2) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`c2`) AS `SUM(c2)` from `test`.`t1` +EXPLAIN SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t1`.`c1`) AS `AVG(c1)`,max(`test`.`t1`.`c1`) AS `MAX(c1)`,min(`test`.`t1`.`c2`) AS `MIN(c2)`,avg(`test`.`t1`.`c3`) AS `AVG(c3)`,sum(`test`.`t1`.`c4`) AS `SUM(c4)` from `test`.`t1` +EXPLAIN SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 p0,p1,p2,p3 ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`test`.`t3`.`c1`) AS `AVG(c1)`,max(`test`.`t3`.`c1`) AS `MAX(c1)`,min(`test`.`t3`.`c2`) AS `MIN(c2)`,avg(`test`.`t3`.`c3`) AS `AVG(c3)`,sum(`test`.`t3`.`c4`) AS `SUM(c4)` from `test`.`t3` +EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t1`) / 2))) +EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t3`) / 2))) +EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c2`) AS `COUNT(c2)` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t1`) / 2))) +EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where +2 SUBQUERY t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`test`.`t1`.`c2`) AS `COUNT(c2)` from `test`.`t1` where (`test`.`t1`.`c1` > (((/* select#2 */ select count(0) from `test`.`t3`) / 2))) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where; Using index +2 SUBQUERY t1 NULL index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`c1` > (/* select#2 */ select avg(`test`.`t1`.`c1`) from `test`.`t1`)) +EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 NULL range PRIMARY,k2 PRIMARY 4 NULL # 100.00 Using where; Using index +2 SUBQUERY t3 p0,p1,p2,p3 index NULL k2 5 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`c1` > (/* select#2 */ select avg(`test`.`t3`.`c1`) from `test`.`t3`)) +# +# Make all indexes in t2 obsolete to the active repeatable read transaction +# in the default connection. +# +ALTER TABLE t2 row_format=redundant; +# +# Connection default REPEATABLE READ +# Do more DML in the default REPEATABLE READ transaction in order to use recently committed records. +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 1 +2 1 1 1 +3 1 1 1 +4 1 1 1 +5 1 1 1 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 1 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +49 +SELECT SUM(c2) FROM t1; +SUM(c2) +11 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +5.4444 10 1 1.0000 9 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +7 1 +8 1 +9 1 +10 1 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +UPDATE t1 SET c4 = c2 * 10; +affected rows: 9 +info: Rows matched: 9 Changed: 9 Warnings: 0 +UPDATE t3 SET c4 = c2 * 10; +affected rows: 9 +info: Rows matched: 9 Changed: 9 Warnings: 0 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 30 +2 5 1 50 +3 7 1 70 +4 11 1 110 +5 1 1 10 +7 1 1 1 +8 1 1 1 +9 1 1 1 +10 1 1 10 +11 100 1 1000 +12 1000 1 10000 +13 10000 1 100000 +SELECT COUNT(*) FROM t1; +COUNT(*) +12 +SELECT COUNT(*) FROM t3; +COUNT(*) +12 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +12 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +12 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +12 +SELECT SUM(c1) FROM t1; +SUM(c1) +85 +SELECT SUM(c2) FROM t1; +SUM(c2) +11131 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +7.0833 13 1 1.0000 111283 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +7.0833 13 1 1.0000 111223 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +7 1 +8 1 +9 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +7 1 +8 1 +9 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +7 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +7 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +6 +############################################### +# +# Table t2 has been altered to a new row format. +# The index should not be useable. +# +SELECT COUNT(*) FROM t2; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +ERROR HY000: Table definition has changed, please retry transaction +COMMIT; +SELECT COUNT(*) FROM t2; +COUNT(*) +10 +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 30 +2 5 1 50 +3 7 1 70 +4 11 1 110 +5 1 1 10 +10 1 1 10 +11 100 1 1000 +12 1000 1 10000 +13 10000 1 100000 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111280 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111220 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Connection 2 +# +########## innodb_wl6742_selects.inc ########## +SELECT * FROM t1; +c1 c2 c3 c4 +1 3 1 30 +2 5 1 50 +3 7 1 70 +4 11 1 110 +5 1 1 10 +10 1 1 10 +11 100 1 1000 +12 1000 1 10000 +13 10000 1 100000 +SELECT COUNT(*) FROM t1; +COUNT(*) +9 +SELECT COUNT(*) FROM t3; +COUNT(*) +9 +SELECT COUNT(c1) FROM t1; +COUNT(c1) +9 +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +SELECT COUNT(c3) FROM t1; +COUNT(c3) +9 +SELECT SUM(c1) FROM t1; +SUM(c1) +61 +SELECT SUM(c2) FROM t1; +SUM(c2) +11128 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111280 +SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t3; +AVG(c1) MAX(c1) MIN(c2) AVG(c3) SUM(c4) +6.7778 13 1 1.0000 111220 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +c1 c2 +5 1 +10 1 +11 100 +12 1000 +13 10000 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2); +COUNT(c2) +5 +SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t3) / 2); +COUNT(c2) +5 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1); +COUNT(*) +4 +SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t3); +COUNT(*) +4 +############################################### +# +# Try COUNT(*) on a DISCARDED table. +# +CREATE TABLE t4 LIKE t1; +INSERT INTO t4 (SELECT * FROM t1); +SELECT COUNT(*) FROM t4; +COUNT(*) +9 +ALTER TABLE t4 DISCARD TABLESPACE; +SELECT COUNT(*) FROM t4; +ERROR HY000: Tablespace has been discarded for table 't4' +# +# Test the interaction of a repeatable read transaction +# to changes that happen outside its view. +# +CREATE TABLE t5 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB; +INSERT INTO t5(b) VALUES ("inserted by client 1"); +INSERT INTO t5(b) VALUES ("inserted by client 1"); +INSERT INTO t5(b) VALUES ("inserted by client 1"); +INSERT INTO t5(b) VALUES ("inserted by client 1"); +UPDATE t5 SET aa=a, bb=b; +CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB; +INSERT INTO t6(b) VALUES ("inserted by client 1"); +INSERT INTO t6(b) VALUES ("inserted by client 1"); +INSERT INTO t6(b) VALUES ("inserted by client 1"); +INSERT INTO t6(b) VALUES ("inserted by client 1"); +UPDATE t6 SET aa=a, bb=b; +CREATE TABLE t7 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, aa INT, bb TEXT) Engine=InnoDB; +INSERT INTO t7(b) VALUES ("inserted by client 1"); +INSERT INTO t7(b) VALUES ("inserted by client 1"); +INSERT INTO t7(b) VALUES ("inserted by client 1"); +INSERT INTO t7(b) VALUES ("inserted by client 1"); +UPDATE t7 SET aa=a, bb=b; +BEGIN; +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +SELECT COUNT(*) FROM t5; +COUNT(*) +4 +SELECT * FROM t6; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +4 +SELECT * FROM t7; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +SELECT COUNT(*) FROM t7; +COUNT(*) +4 +# +# Connection 1 +# +INSERT INTO t5(b) VALUES ("inserted by client 2"); +UPDATE t5 SET a = 10 where a = 1; +UPDATE t5 SET b = "updated by client 2" where a = 2; +DELETE FROM t5 WHERE a = 3; +SELECT * FROM t5; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +5 inserted by client 2 NULL NULL +10 inserted by client 1 1 inserted by client 1 +SELECT COUNT(*) FROM t5; +COUNT(*) +4 +INSERT INTO t6(b) VALUES ("inserted by client 2"); +UPDATE t6 SET a = 10 where a = 1; +UPDATE t6 SET b = "updated by client 2" where a = 2; +DELETE FROM t6 WHERE a = 3; +SELECT * FROM t6; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +5 inserted by client 2 NULL NULL +10 inserted by client 1 1 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +4 +INSERT INTO t7(b) VALUES ("inserted by client 2"); +UPDATE t7 SET a = 10 where a = 1; +UPDATE t7 SET b = "updated by client 2" where a = 2; +DELETE FROM t7 WHERE a = 3; +SELECT * FROM t7; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +5 inserted by client 2 NULL NULL +10 inserted by client 1 1 inserted by client 1 +SELECT COUNT(*) FROM t7; +COUNT(*) +4 +# +# Connection default +# +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +INSERT INTO t5(b) VALUES ("inserted by client 1"); +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 inserted by client 1 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 inserted by client 1 4 inserted by client 1 +11 inserted by client 1 NULL NULL +UPDATE t5 SET a = a + 100; +SELECT * FROM t5; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +102 updated by client 2 2 inserted by client 1 +104 inserted by client 1 4 inserted by client 1 +105 inserted by client 2 NULL NULL +110 inserted by client 1 1 inserted by client 1 +111 inserted by client 1 NULL NULL +SELECT COUNT(*) FROM t5; +COUNT(*) +7 +UPDATE t6 SET b = "updated by client 2"; +SELECT * FROM t6; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +2 updated by client 2 2 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +4 updated by client 2 4 inserted by client 1 +5 updated by client 2 NULL NULL +10 updated by client 2 1 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +6 +DELETE FROM t7; +SELECT * FROM t7; +a b aa bb +1 inserted by client 1 1 inserted by client 1 +3 inserted by client 1 3 inserted by client 1 +SELECT COUNT(*) FROM t7; +COUNT(*) +2 +COMMIT; +SELECT * FROM t5; +a b aa bb +102 updated by client 2 2 inserted by client 1 +104 inserted by client 1 4 inserted by client 1 +105 inserted by client 2 NULL NULL +110 inserted by client 1 1 inserted by client 1 +111 inserted by client 1 NULL NULL +SELECT COUNT(*) FROM t5; +COUNT(*) +5 +SELECT * FROM t6; +a b aa bb +2 updated by client 2 2 inserted by client 1 +4 updated by client 2 4 inserted by client 1 +5 updated by client 2 NULL NULL +10 updated by client 2 1 inserted by client 1 +SELECT COUNT(*) FROM t6; +COUNT(*) +4 +SELECT * FROM t7; +a b aa bb +SELECT COUNT(*) FROM t7; +COUNT(*) +0 +# +# Cleanup +# +DROP TABLE t1,t2,t3,t4,t5,t6,t7; +# +# Bug #23596760: FORCE INDEX IS SKIPPED WHILE EXECUTING SELECT COUNT(*) +# +CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY, +c2 INT NOT NULL DEFAULT 1, +c3 char(20) DEFAULT '', +KEY c2_idx (c2)); +INSERT INTO t1(c1) VALUES (1), (2), (3); +INSERT INTO t1(c1) SELECT c1 + 10 FROM t1; +INSERT INTO t1(c1) SELECT c1 + 100 FROM t1; +CREATE TABLE t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT COUNT(*) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` +EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`c2_idx`) +EXPLAIN SELECT COUNT(*) FROM t1, t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` join `test`.`t2` +EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(c2_idx), t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL c2_idx 4 NULL # 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL # 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` FORCE INDEX (`c2_idx`) join `test`.`t2` +DROP TABLE t1, t2; diff --git a/mysql-test/suite/innodb/r/tablespace_encrypt_9.result-pq b/mysql-test/suite/innodb/r/tablespace_encrypt_9.result-pq new file mode 100644 index 000000000..e7d6806b3 --- /dev/null +++ b/mysql-test/suite/innodb/r/tablespace_encrypt_9.result-pq @@ -0,0 +1,137 @@ +######################################################################### +# START : WITHOUT KEYRING PLUGIN +######################################################################### + +######### +# SETUP # +######### +CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd' ENGINE=InnoDB ENCRYPTION="N"; +CREATE TABLE t1(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts; +set global innodb_buf_flush_list_now = 1; +SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts'; +NAME ENCRYPTION +encrypt_ts N +SELECT * FROM t1 LIMIT 10; +c1 +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; +ERROR HY000: Can't find master key from keyring, please check in the server log if a keyring is loaded and initialized successfully. +############################################################# +# TEST 1 : CRASH DURING ALTER ENCRYPT A TABLESPACE. +############################################################# + +######################################################################### +# RESTART 1 : WITH KEYRING PLUGIN +######################################################################### +############################################################ +# ALTER TABLESPACE 1 : Unencrypted => Encrypted # +# (crash at page 10) # +############################################################ +# Set Encryption process to crash at page 10 +SET SESSION debug= '+d,alter_encrypt_tablespace_page_10'; +SET GLOBAL innodb_log_checkpoint_now = ON; +SET GLOBAL innodb_page_cleaner_disabled_debug = 1; +SET GLOBAL innodb_dict_stats_disabled_debug = 1; +SET GLOBAL innodb_master_thread_disabled_debug = 1; +# Encrypt the tablespace. It will cause crash. +ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; +# Restart after crash without Keyring plugin loaded +Pattern "CORRUPT LOG RECORD FOUND" found +# Server shouldn't have restarted, so query should fail. +SELECT * from test.t1 limit 10; +ERROR HY000: Lost connection to MySQL server during query +######################################################################### +# RESTART 2 : WITH KEYRING PLUGIN +######################################################################### +# Server should have restarted properly. +SELECT * from test.t1 limit 10; +c1 +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +# +# Bug#30888919 : [INNODB] ASSERTION FAILURE:SPACE->ENCRYPTION_OP_IN_PROGRESS == NONE +# +ALTER TABLESPACE encrypt_ts ENCRYPTION='N'; +SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts'; +NAME ENCRYPTION +encrypt_ts N +SELECT * FROM t1 LIMIT 10; +c1 +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +############################################################ +# ALTER TABLESPACE : Unencrypted => Encrypted # +# (crash at page 10) # +############################################################ +# Connection con1: +# Set Encryption process to crash at page 10 +SET SESSION debug= '+d,alter_encrypt_tablespace_page_10'; +# Encrypt the tablespace. It will cause crash. +ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; +# Restart after crash with sleep_resume_alter_encrypt to make resume +# thread to sleep. +# Connection con2: +# Check that this connection id is same as of the one which was trying +# to encrypt the tablespace before crash. +Connectin ids are not same. +CREATE TABLESPACE temp_ts ADD DATAFILE 'temp_ts.ibd'; +# connection con3 +SELECT connection_id(); +connection_id() +10 +# Run a DDL with this connection con3 +ALTER TABLESPACE temp_ts ENCRYPTION='Y'; +set global innodb_buf_flush_list_now = 1; +# Now restart without sleep_resume_alter_encrypt. +# Kill and restart: --early-plugin-load=keyring_file=keyring_file.so --loose-keyring_file_data=MYSQL_TMP_DIR/mysecret_keyring --plugin-dir=KEYRING_PLUGIN_PATH +# Wait for Encryption processing to finish in background thread +# After restart/recovery, check that Encryption was roll-forward +SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts'; +NAME ENCRYPTION +encrypt_ts Y +SELECT * FROM t1 LIMIT 10; +c1 +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +SOME VALUES +# Now try to encrypt tablespace. Without patch, an assert will be hit. +ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; +########### +# Cleanup # +########### +DROP TABLE t1; +DROP TABLESPACE encrypt_ts; +# Restarting server without keyring to restore server state +# restart: diff --git a/mysql-test/suite/innodb/t/innodb-index-debug.test b/mysql-test/suite/innodb/t/innodb-index-debug.test index b8a512fde..764611ac9 100644 --- a/mysql-test/suite/innodb/t/innodb-index-debug.test +++ b/mysql-test/suite/innodb/t/innodb-index-debug.test @@ -94,7 +94,14 @@ connection con1; --echo /*con1 reap*/ Optimize table t1; reap; --disable_info -SELECT COUNT(k1),k2,k3 FROM t1 GROUP BY k2,k3; +if ($PQ_TEST) +{ + SELECT COUNT(k1),k2,k3 FROM t1 GROUP BY k2,k3 ORDER BY k2,k3; +} +if (!$PQ_TEST) +{ + SELECT COUNT(k1),k2,k3 FROM t1 GROUP BY k2,k3; +} drop table t1; # Log file creation failure. diff --git a/mysql-test/suite/innodb_zip/r/index_large_prefix.result-pq b/mysql-test/suite/innodb_zip/r/index_large_prefix.result-pq new file mode 100644 index 000000000..524da565d --- /dev/null +++ b/mysql-test/suite/innodb_zip/r/index_large_prefix.result-pq @@ -0,0 +1,467 @@ +SET default_storage_engine=InnoDB; +set global innodb_file_per_table=1; +### Test 1 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +insert into worklog5743 values(repeat("a", 20000)); +update worklog5743 set a = (repeat("b", 16000)); +create index idx on worklog5743(a(2000)); +show warnings; +Level Code Message +begin; +update worklog5743 set a = (repeat("x", 17000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +0 +select a = repeat("b", 16000) from worklog5743; +a = repeat("b", 16000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +1 +rollback; +drop table worklog5743; +### Test 2 ### +create table worklog5743(a1 int, a2 TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +create index idx on worklog5743(a1, a2(2000)); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = convert(repeat('a',10000) using latin1)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 3 ### +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +create index idx on worklog5743(a1, a2(50)); +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = repeat('a',10000)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 4 ### +create table worklog5743_1(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=4; +create table worklog5743_8(a1 int, a2 TEXT, a3 TEXT) charset latin1 KEY_BLOCK_SIZE=8; +create table worklog5743_16(a1 int, a2 TEXT, a3 TEXT) charset latin1 KEY_BLOCK_SIZE=16; +create index idx2 on worklog5743_1(a2(4000)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743_1(a2(436)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_1(a2(434)); +show warnings; +Level Code Message +create index idx5 on worklog5743_1(a1, a2(430)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_1(a1, a2(428)); +show warnings; +Level Code Message +SET sql_mode= ''; +create index idx2 on worklog5743_2(a2(4000)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx3 on worklog5743_2(a2(948)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_2(a2(946)); +show warnings; +Level Code Message +create index idx5 on worklog5743_2(a1, a2(942)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_2(a1, a2(940)); +show warnings; +Level Code Message +create index idx2 on worklog5743_4(a2(4000)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx3 on worklog5743_4(a2(1972)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_4(a2(1970)); +show warnings; +Level Code Message +create index idx5 on worklog5743_4(a1, a2(1966)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_4(a1, a2(1964)); +show warnings; +Level Code Message +create index idx2 on worklog5743_8(a2(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743_8(a2(3072)); +Warnings: +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_8(a1, a2(3069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx5 on worklog5743_8(a1, a2(3068)); +show warnings; +Level Code Message +create index idx6 on worklog5743_8(a1, a2(2000), a3(1069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx7 on worklog5743_8(a1, a2(2000), a3(1068)); +show warnings; +Level Code Message +create index idx2 on worklog5743_16(a2(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743_16(a2(3072)); +Warnings: +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_16'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_16'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_16(a1, a2(3069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx5 on worklog5743_16(a1, a2(3068)); +show warnings; +Level Code Message +create index idx6 on worklog5743_16(a1, a2(2000), a3(1069)); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx7 on worklog5743_16(a1, a2(2000), a3(1068)); +show warnings; +Level Code Message +set sql_mode= default; +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_8 values(9, repeat("a", 10000), repeat("a", 10000)); +insert into worklog5743_16 values(9, repeat("a", 10000), repeat("a", 10000)); +insert into worklog5743_1 values(2, repeat("b", 10000)); +insert into worklog5743_2 values(2, repeat("b", 10000)); +insert into worklog5743_4 values(2, repeat("b", 10000)); +insert into worklog5743_8 values(2, repeat("b", 10000), repeat("b", 10000)); +insert into worklog5743_16 values(2, repeat("b", 10000), repeat("b", 10000)); +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_16; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +begin; +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +update worklog5743_8 set a1 = 1000; +update worklog5743_16 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_16; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_1 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_1`.`a1` AS `a1`,left(`test`.`worklog5743_1`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_1` where (`test`.`worklog5743_1`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_2 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_2`.`a1` AS `a1`,left(`test`.`worklog5743_2`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_2` where (`test`.`worklog5743_2`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_4 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_4`.`a1` AS `a1`,left(`test`.`worklog5743_4`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_4` where (`test`.`worklog5743_4`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_8 NULL ref idx5,idx7 idx5 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_8`.`a1` AS `a1`,left(`test`.`worklog5743_8`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_8` where (`test`.`worklog5743_8`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_16 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_16 NULL ref idx5,idx7 idx5 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_16`.`a1` AS `a1`,left(`test`.`worklog5743_16`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_16` where (`test`.`worklog5743_16`.`a1` = 9) +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_16 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_16 where a1 = 9; +a1 left(a2, 20) +rollback; +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +drop table worklog5743_8; +drop table worklog5743_16; +### Test 5 ### +create table worklog5743(a1 int, +a2 varchar(20000), +a3 varchar(3073), +a4 varchar(3072), +a5 varchar(3069), +a6 varchar(3068)) +charset latin1 +ROW_FORMAT=DYNAMIC; +SET sql_mode=''; +create index idx1 on worklog5743(a2); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx2 on worklog5743(a3); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx3 on worklog5743(a4); +show warnings; +Level Code Message +SET sql_mode= default; +create index idx4 on worklog5743(a1, a2); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx5 on worklog5743(a1, a5); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +create index idx6 on worklog5743(a1, a6); +show warnings; +Level Code Message +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a1` int DEFAULT NULL, + `a2` varchar(20000) DEFAULT NULL, + `a3` varchar(3073) DEFAULT NULL, + `a4` varchar(3072) DEFAULT NULL, + `a5` varchar(3069) DEFAULT NULL, + `a6` varchar(3068) DEFAULT NULL, + KEY `idx1` (`a2`(3072)), + KEY `idx2` (`a3`(3072)), + KEY `idx3` (`a4`), + KEY `idx6` (`a1`,`a6`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC +insert into worklog5743 values(9, +repeat("a", 20000), repeat("a", 3073), +repeat("a", 3072), repeat("a", 3069), +repeat("a", 3068)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1 from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE worklog5743 NULL ref idx6 idx6 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1 from worklog5743 where a1 = 9; +a1 +9 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1 from worklog5743 where a1 = 9; +a1 +rollback; +drop table worklog5743; +### Test 6 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) +charset latin1 +row_format=compact; +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table worklog5743(a TEXT) +charset latin1 +row_format=compact; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx on worklog5743(a(767)); +insert into worklog5743 values(repeat("a", 20000)); +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("a", 20000) from worklog5743; +a = repeat("a", 20000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 25000) from worklog5743; +a = repeat("x", 25000) +1 +1 +rollback; +drop table worklog5743; +### Test 7 ### +create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC; +SET sql_mode=''; +create index idx1 on worklog5743(a(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +create index idx2 on worklog5743(a(3072)); +Warnings: +Warning 1071 Specified key was too long; max key length is 3072 bytes +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a` text NOT NULL, + KEY `idx1` (`a`(768)), + KEY `idx2` (`a`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +drop table worklog5743; +SET sql_mode= default; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=REDUNDANT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/innodb_zip/r/index_large_prefix_4k.result-pq b/mysql-test/suite/innodb_zip/r/index_large_prefix_4k.result-pq new file mode 100644 index 000000000..ba07f7c27 --- /dev/null +++ b/mysql-test/suite/innodb_zip/r/index_large_prefix_4k.result-pq @@ -0,0 +1,388 @@ +SET default_storage_engine=InnoDB; +set global innodb_file_per_table=1; +### Test 1 ### +create table worklog5743(a TEXT not null, primary key (a(768))) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +insert into worklog5743 values(repeat("a", 20000)); +update worklog5743 set a = (repeat("b", 16000)); +SET sql_mode= ''; +create index idx on worklog5743(a(900)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +SET sql_mode= default; +begin; +update worklog5743 set a = (repeat("x", 17000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +0 +select a = repeat("b", 16000) from worklog5743; +a = repeat("b", 16000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +1 +rollback; +drop table worklog5743; +### Test 2 ### +create table worklog5743(a1 int, a2 TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +create index idx on worklog5743(a1, a2(750)); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1111; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = convert(repeat('a',10000) using latin1)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 3 ### +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +create index idx on worklog5743(a1, a2(50)); +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 2222; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = repeat('a',10000)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 4 ### +create table worklog5743_1(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=4; +create index idx1 on worklog5743_1(a2(4000)); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +create index idx3 on worklog5743_1(a2(436)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_1(a2(434)); +show warnings; +Level Code Message +create index idx5 on worklog5743_1(a1, a2(430)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_1(a1, a2(428)); +show warnings; +Level Code Message +SET sql_mode= ''; +create index idx1 on worklog5743_2(a2(4000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +show create table worklog5743_2; +Table Create Table +worklog5743_2 CREATE TABLE `worklog5743_2` ( + `a1` int DEFAULT NULL, + `a2` text NOT NULL, + KEY `idx1` (`a2`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2 +create index idx3 on worklog5743_2(a2(769)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_2(a2(768)); +Warnings: +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_2'. This is deprecated and will be disallowed in a future release. +create index idx5 on worklog5743_2(a1, a2(765)); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +create index idx6 on worklog5743_2(a1, a2(764)); +show warnings; +Level Code Message +create index idx1 on worklog5743_4(a2(4000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +show create table worklog5743_4; +Table Create Table +worklog5743_4 CREATE TABLE `worklog5743_4` ( + `a1` int DEFAULT NULL, + `a2` text NOT NULL, + KEY `idx1` (`a2`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=4 +create index idx3 on worklog5743_4(a2(769)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_4(a2(768)); +Warnings: +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx5 on worklog5743_4(a1, a2(765)); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +create index idx6 on worklog5743_4(a1, a2(764)); +show warnings; +Level Code Message +SET sql_mode= default; +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_1 values(2, repeat("b", 10000)); +insert into worklog5743_2 values(2, repeat("b", 10000)); +insert into worklog5743_4 values(2, repeat("b", 10000)); +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +begin; +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_1 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_1`.`a1` AS `a1`,left(`test`.`worklog5743_1`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_1` where (`test`.`worklog5743_1`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_2 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_2`.`a1` AS `a1`,left(`test`.`worklog5743_2`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_2` where (`test`.`worklog5743_2`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_4 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_4`.`a1` AS `a1`,left(`test`.`worklog5743_4`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_4` where (`test`.`worklog5743_4`.`a1` = 9) +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +rollback; +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +### Test 5 ### +create table worklog5743(a1 int, a2 varchar(20000)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 3072 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(3072)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(769)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(768)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 768)); +update worklog5743 set a1 = 3333; +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(765)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +ERROR 42000: Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 768 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(764)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 764)); +begin; +update worklog5743 set a1 = 4444; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1 from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE worklog5743 NULL ref idx1 idx1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1 from worklog5743 where a1 = 9; +a1 +9 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1 from worklog5743 where a1 = 9; +a1 +rollback; +drop table worklog5743; +### Test 6 ### +create table worklog5743(a TEXT not null, primary key (a(1000))); +ERROR 42000: Specified key was too long; max key length is 768 bytes +create table worklog5743(a TEXT) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx on worklog5743(a(767)); +insert into worklog5743 values(repeat("a", 20000)); +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("a", 20000) from worklog5743; +a = repeat("a", 20000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 25000) from worklog5743; +a = repeat("x", 25000) +1 +1 +rollback; +drop table worklog5743; +### Test 7 ### +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +SET sql_mode= ''; +create index idx1 on worklog5743(a(769)); +Warnings: +Warning 1071 Specified key was too long; max key length is 768 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 768 bytes +SET sql_mode= default; +create index idx2 on worklog5743(a(768)); +Warnings: +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a` text NOT NULL, + KEY `idx1` (`a`(768)), + KEY `idx2` (`a`(768)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC +insert into worklog5743 values(repeat("a", 768)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=REDUNDANT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/innodb_zip/r/index_large_prefix_8k.result-pq b/mysql-test/suite/innodb_zip/r/index_large_prefix_8k.result-pq new file mode 100644 index 000000000..c7f235fc8 --- /dev/null +++ b/mysql-test/suite/innodb_zip/r/index_large_prefix_8k.result-pq @@ -0,0 +1,396 @@ +SET default_storage_engine=InnoDB; +set global innodb_file_per_table=1; +### Test 1 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +insert into worklog5743 values(repeat("a", 20000)); +update worklog5743 set a = (repeat("b", 16000)); +SET sql_mode= ''; +create index idx on worklog5743(a(2000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +SET sql_mode= default; +begin; +update worklog5743 set a = (repeat("x", 17000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +0 +select a = repeat("b", 16000) from worklog5743; +a = repeat("b", 16000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 17000) from worklog5743; +a = repeat("x", 17000) +1 +rollback; +drop table worklog5743; +### Test 2 ### +create table worklog5743(a1 int, a2 TEXT not null) charset latin1 ROW_FORMAT=DYNAMIC; +show warnings; +Level Code Message +create index idx on worklog5743(a1, a2(1250)); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = convert(repeat('a',10000) using latin1)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 3 ### +create table worklog5743(a1 int, a2 TEXT not null) ROW_FORMAT=DYNAMIC; +create index idx on worklog5743(a1, a2(50)); +insert into worklog5743 values(9, repeat("a", 10000)); +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743 NULL ref idx idx 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1`,(`test`.`worklog5743`.`a2` = repeat('a',10000)) AS `a2 = repeat("a", 10000)` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +9 1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, a2 = repeat("a", 10000) from worklog5743 where a1 = 9; +a1 a2 = repeat("a", 10000) +rollback; +drop table worklog5743; +### Test 4 ### +create table worklog5743_1(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=1; +create table worklog5743_2(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=2; +create table worklog5743_4(a1 int, a2 TEXT not null) charset latin1 KEY_BLOCK_SIZE=4; +create table worklog5743_8(a1 int, a2 TEXT, a3 TEXT) charset latin1 KEY_BLOCK_SIZE=8; +create index idx2 on worklog5743_1(a2(4000)); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +create index idx3 on worklog5743_1(a2(436)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_1(a2(434)); +show warnings; +Level Code Message +create index idx5 on worklog5743_1(a1, a2(430)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_1(a1, a2(428)); +show warnings; +Level Code Message +SET sql_mode= ''; +create index idx2 on worklog5743_2(a2(4000)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx3 on worklog5743_2(a2(948)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx4 on worklog5743_2(a2(946)); +show warnings; +Level Code Message +create index idx5 on worklog5743_2(a1, a2(942)); +ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +show warnings; +Level Code Message +Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 4030. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs +create index idx6 on worklog5743_2(a1, a2(940)); +show warnings; +Level Code Message +create index idx1 on worklog5743_4(a2(4000)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +create index idx3 on worklog5743_4(a2(1537)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_4(a2(1536)); +Warnings: +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1831 Duplicate index 'idx4' defined on the table 'test.worklog5743_4'. This is deprecated and will be disallowed in a future release. +create index idx5 on worklog5743_4(a1, a2(1533)); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +create index idx6 on worklog5743_4(a1, a2(1532)); +show warnings; +Level Code Message +create index idx2 on worklog5743_8(a2(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +create index idx3 on worklog5743_8(a2(3072)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +show warnings; +Level Code Message +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx3' defined on the table 'test.worklog5743_8'. This is deprecated and will be disallowed in a future release. +create index idx4 on worklog5743_8(a1, a2(1533)); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +create index idx5 on worklog5743_8(a1, a2(1532)); +show warnings; +Level Code Message +SET sql_mode= default; +insert into worklog5743_1 values(9, repeat("a", 10000)); +insert into worklog5743_2 values(9, repeat("a", 10000)); +insert into worklog5743_4 values(9, repeat("a", 10000)); +insert into worklog5743_8 values(9, repeat("a", 10000), repeat("a", 10000)); +insert into worklog5743_1 values(2, repeat("b", 10000)); +insert into worklog5743_2 values(2, repeat("b", 10000)); +insert into worklog5743_4 values(2, repeat("b", 10000)); +insert into worklog5743_8 values(2, repeat("b", 10000), repeat("b", 10000)); +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +2 bbbbbbbbbbbbbbbbbbbb +begin; +update worklog5743_1 set a1 = 1000; +update worklog5743_2 set a1 = 1000; +update worklog5743_4 set a1 = 1000; +update worklog5743_8 set a1 = 1000; +select a1, left(a2, 20) from worklog5743_1; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_2; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_4; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select a1, left(a2, 20) from worklog5743_8; +a1 left(a2, 20) +1000 aaaaaaaaaaaaaaaaaaaa +1000 bbbbbbbbbbbbbbbbbbbb +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_1 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_1`.`a1` AS `a1`,left(`test`.`worklog5743_1`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_1` where (`test`.`worklog5743_1`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_2 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_2`.`a1` AS `a1`,left(`test`.`worklog5743_2`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_2` where (`test`.`worklog5743_2`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_4 NULL ref idx6 idx6 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_4`.`a1` AS `a1`,left(`test`.`worklog5743_4`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_4` where (`test`.`worklog5743_4`.`a1` = 9) +explain select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE worklog5743_8 NULL ref idx5 idx5 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743_8`.`a1` AS `a1`,left(`test`.`worklog5743_8`.`a2`,20) AS `left(a2, 20)` from `test`.`worklog5743_8` where (`test`.`worklog5743_8`.`a1` = 9) +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +9 aaaaaaaaaaaaaaaaaaaa +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1, left(a2, 20) from worklog5743_1 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_2 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_4 where a1 = 9; +a1 left(a2, 20) +select a1, left(a2, 20) from worklog5743_8 where a1 = 9; +a1 left(a2, 20) +rollback; +drop table worklog5743_1; +drop table worklog5743_2; +drop table worklog5743_4; +drop table worklog5743_8; +### Test 5 ### +create table worklog5743(a1 int, a2 varchar(20000)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 3072 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1537)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1536)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 1536)); +update worklog5743 set a1 = 1000; +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1533)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +ERROR 42000: Specified key was too long; max key length is 1536 bytes +show warnings; +Level Code Message +Error 1071 Specified key was too long; max key length is 1536 bytes +drop table worklog5743; +create table worklog5743(a1 int, a2 varchar(1532)) charset latin1 ROW_FORMAT=DYNAMIC; +create index idx1 on worklog5743(a1, a2); +show warnings; +Level Code Message +insert into worklog5743 values(9, repeat("a", 1532)); +update worklog5743 set a1 = 1000; +begin; +update worklog5743 set a1 = 1000; +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +explain select a1 from worklog5743 where a1 = 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE worklog5743 NULL ref idx1 idx1 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`worklog5743`.`a1` AS `a1` from `test`.`worklog5743` where (`test`.`worklog5743`.`a1` = 9) +select a1 from worklog5743 where a1 = 9; +a1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a1 from worklog5743 where a1 = 9; +a1 +rollback; +drop table worklog5743; +### Test 6 ### +create table worklog5743(a TEXT not null, primary key (a(1000))) +charset latin1 +row_format=compact; +ERROR 42000: Specified key was too long; max key length is 767 bytes +create table worklog5743(a TEXT) charset latin1 row_format=compact; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx on worklog5743(a(767)); +insert into worklog5743 values(repeat("a", 20000)); +begin; +insert into worklog5743 values(repeat("b", 20000)); +update worklog5743 set a = (repeat("x", 25000)); +select @@session.transaction_isolation; +@@session.transaction_isolation +REPEATABLE-READ +select a = repeat("a", 20000) from worklog5743; +a = repeat("a", 20000) +1 +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +select @@session.transaction_isolation; +@@session.transaction_isolation +READ-UNCOMMITTED +select a = repeat("x", 25000) from worklog5743; +a = repeat("x", 25000) +1 +1 +rollback; +drop table worklog5743; +### Test 7 ### +create table worklog5743(a TEXT not null) ROW_FORMAT=DYNAMIC; +SET sql_mode= ''; +create index idx1 on worklog5743(a(3073)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +create index idx2 on worklog5743(a(3072)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1536 bytes +Warning 1831 Duplicate index 'idx2' defined on the table 'test.worklog5743'. This is deprecated and will be disallowed in a future release. +SET sql_mode= default; +show create table worklog5743; +Table Create Table +worklog5743 CREATE TABLE `worklog5743` ( + `a` text NOT NULL, + KEY `idx1` (`a`(384)), + KEY `idx2` (`a`(384)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=REDUNDANT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +create table worklog5743(a TEXT not null) charset latin1 ROW_FORMAT=COMPACT; +create index idx on worklog5743(a(768)); +ERROR 42000: Specified key was too long; max key length is 767 bytes +create index idx2 on worklog5743(a(767)); +drop table worklog5743; +SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/opt_trace/r/bugs_no_prot_all.result-pq b/mysql-test/suite/opt_trace/r/bugs_no_prot_all.result-pq new file mode 100644 index 000000000..13a24052a --- /dev/null +++ b/mysql-test/suite/opt_trace/r/bugs_no_prot_all.result-pq @@ -0,0 +1,3121 @@ +set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; +set optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +# +# BUG#12430646 - SEL_ARG::LEFT AND RIGHT POINTERS INCORRECTLY +# USED. CRASHES OPTIMIZER TRACING +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY (c), +KEY (d,a,b(2)), +KEY (b(1)) +); +INSERT INTO t1 VALUES (NULL, 'a', 1, 2), (NULL, 'a', 1, 2), +(1, 'a', 1, 2), (1, 'a', 1, 2); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY (e) +); +INSERT INTO t2 VALUES (1, 1, NULL), (1, 1, NULL); +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# BUG#12595210 - JSON SYNTAX ERROR ASSERT ON WHERE FIELD NOT IN SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t2 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t3 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t4 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE VIEW view_t4 AS SELECT * FROM t4; +CREATE TABLE where_subselect_19379 SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +); +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)); +field1 field2 +select * from information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select `t4`.`pk` AS `pk`,`t4`.`col_int_key` AS `col_int_key`,`t4`.`col_varchar_key` AS `col_varchar_key` from `t4`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`view_t4` `sq1_alias1`", + "select#": 5, + "merged": true + } /* view */ + }, + { + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) where `alias2`.`col_varchar_key` in (/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`))" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */, + "evaluating_constant_having_conditions": [ + ] /* evaluating_constant_having_conditions */ + } /* transformation */ + }, + { + "transformation": { + "select#": 4, + "from": "IN (SELECT)", + "to": "semijoin", + "chosen": true, + "transformation_to_semi_join": { + "subquery_predicate": "`alias2`.`col_varchar_key` in (/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`))", + "embedded in": "WHERE", + "evaluating_constant_semijoin_conditions": [ + ] /* evaluating_constant_semijoin_conditions */, + "semi-join condition": "((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`))", + "decorrelated_predicates": [ + { + "outer": "`alias2`.`col_varchar_key`", + "inner": "`sq2_alias1`.`col_varchar_nokey`" + } + ] /* decorrelated_predicates */ + } /* transformation_to_semi_join */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19379`.`field1` AS `field1`,`where_subselect_19379`.`field2` AS `field2` from `where_subselect_19379` where ((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "semijoin", + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` semi join (`t3` `sq2_alias1`) where ((outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19379`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19379`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +drop table t1,t2,t3,t4,where_subselect_19379; +drop view view_t4; +# +# BUG#12607524 JSON PARSE ERROR ON SELECT ... FROM ... WHERE .. IN (SUBQUERY) +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (8,'g'); +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'x'); +CREATE TABLE where_subselect_19033 +SELECT +( SELECT col_int_key FROM t2 ) as field1 +FROM t1 +; +SELECT * FROM where_subselect_19033; +field1 +7 +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) +; +field1 +7 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t2`.`col_int_key` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` where `where_subselect_19033`.`field1` in (/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`)" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "semijoin", + "chosen": true, + "transformation_to_semi_join": { + "subquery_predicate": "`where_subselect_19033`.`field1` in (/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`)", + "embedded in": "WHERE", + "semi-join condition": "(`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`))", + "decorrelated_predicates": [ + { + "outer": "`where_subselect_19033`.`field1`", + "inner": "(/* select#3 */ select `t2`.`col_int_key` from `t2`)" + } + ] /* decorrelated_predicates */ + } /* transformation_to_semi_join */ + } /* transformation */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "semijoin" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` semi join (`t1`) where ((`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`)))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19033`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "pulled_out_semijoin_tables": [ + ] /* pulled_out_semijoin_tables */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19033`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + }, + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.501221 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "execution_plan_for_potential_materialization": { + "steps": [ + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.601221, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.601221, + "chosen": true + } + ] /* considered_execution_plans */ + } + ] /* steps */ + } /* execution_plan_for_potential_materialization */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + "`where_subselect_19033`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.601221, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.601221, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 0.601221, + "rows": 1, + "chosen": true + }, + { + "strategy": "MaterializeLookup", + "cost": 1.80122, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 1.80122, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "chosen": true + }, + { + "final_semijoin_strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + ] /* tables */ + } /* recalculate_access_paths_and_cost */ + } + ] /* considered_execution_plans */ + }, + { + "condition_on_constant_tables": "true", + "condition_value": true + }, + { + "attaching_conditions_to_tables": { + "original_condition": "true", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_19033,t1,t2; + +# BUG#12612201 - SEGFAULT IN +# SUBSELECT_UNIQUESUBQUERY_ENGINE::PRINT WITH OPTIMIZER TRACE + +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,4,'v','v'),(20,5,'r','r'); +CREATE TABLE t3 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (NULL,'j','j'),(8,'c','c'); +CREATE TABLE where_updatedelete_20769 select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 +; +UPDATE where_updatedelete_20769 SET field1 = ( select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 + ); +DROP TABLE where_updatedelete_20769; +DROP TABLE t1,t2,t3; + +# BUG#12710761 - INVALID JSON TRACE ON SUBQUERY IN IN-CLAUSE + +CREATE TABLE t1 (col_int_key int, KEY col_int_key (col_int_key)); +INSERT INTO t1 VALUES (0),(8),(1),(8); +CREATE TABLE where_subselect_20070 +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key; +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +); +field1 ( SELECT COUNT( col_int_key ) +FROM t1 +) +0 4 +1 4 +8 4 +8 4 +8 4 +8 4 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`)))" + }, + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` where (`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) in (/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`))))" + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "semijoin", + "chosen": true, + "transformation_to_semi_join": { + "subquery_predicate": "(`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) in (/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "embedded in": "WHERE", + "evaluating_constant_semijoin_conditions": [ + ] /* evaluating_constant_semijoin_conditions */, + "semi-join condition": "((`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))", + "decorrelated_predicates": [ + { + "outer": "`where_subselect_20070`.`field1`", + "inner": "`table2`.`col_int_key`" + }, + { + "outer": "(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)", + "inner": "(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)" + } + ] /* decorrelated_predicates */ + } /* transformation_to_semi_join */ + } /* transformation */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "semijoin", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` semi join (`t1` `table1` join `t1` `table2`) where ((`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + { + "join_optimization": { + "select#": 4, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": "multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_20070`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table2`", + "row_may_be_null": false, + "map_bit": 2, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "`where_subselect_20070`.`field1`", + "null_rejecting": true + }, + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "`table2`.`col_int_key`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "`where_subselect_20070`.`field1`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "`table1`.`col_int_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "pulled_out_semijoin_tables": [ + ] /* pulled_out_semijoin_tables */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_20070`", + "table_scan": { + "rows": 6, + "cost": 0.504761 + } /* table_scan */ + }, + { + "table": "`t1` `table1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + }, + { + "table": "`t1` `table2`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "execution_plan_for_potential_materialization": { + "steps": [ + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* considered_execution_plans */ + } + ] /* steps */ + } /* execution_plan_for_potential_materialization */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 6, + "cost": 1.10476, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 6, + "cost_for_plan": 1.10476, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 2.73488, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.90186, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 12, + "cost_for_plan": 3.83964, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`where_subselect_20070`", + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 5.30212, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 25, + "rows_for_plan": 12, + "cost_for_plan": 9.14177, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 10.8205, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 9.30941, + "rows": 6, + "chosen": true + }, + { + "strategy": "MaterializeLookup", + "cost": 6.22973, + "rows": 6, + "duplicate_tables_left": false, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 11.9418, + "rows": 6, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 2.73488, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.90186, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 12, + "cost_for_plan": 3.83964, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`where_subselect_20070`", + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 5.30212, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 25, + "rows_for_plan": 12, + "cost_for_plan": 9.14177, + "semijoin_strategy_choice": [ + { + "strategy": "FirstMatch", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 5.46977, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 10.8205, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 9.30941, + "rows": 6, + "chosen": true + }, + { + "strategy": "MaterializeLookup", + "cost": 6.22973, + "rows": 6, + "duplicate_tables_left": false, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 11.9418, + "rows": 6, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.9048, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 4, + "cost_for_plan": 3.80651, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`", + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10185, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 5.62976, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 7.52976, + "rows": 1, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "semijoin_strategy_choice": [ + { + "strategy": "MaterializeScan", + "choice": "deferred" + } + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`", + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 5.30491, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 8, + "cost_for_plan": 8.02988, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "col_int_key", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "MaterializeScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.90484, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 7.8298, + "rows": 1, + "duplicate_tables_left": true, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 9.92988, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.9048, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 4, + "cost_for_plan": 3.80651, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`", + "`where_subselect_20070`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10185, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 5.62976, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 7.52976, + "rows": 1, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 1.82326, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 2.10175, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 2.72496, + "semijoin_strategy_choice": [ + { + "strategy": "MaterializeScan", + "choice": "deferred" + } + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`", + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 5.30491, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 16.6667, + "rows_for_plan": 8, + "cost_for_plan": 8.02988, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_2": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "col_int_key", + "covering_scan": { + "cost": 0.267442, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 5.30491, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 7.79561, + "rows": 1, + "chosen": true + }, + { + "strategy": "MaterializeScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 6, + "cost": 2.90484, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 7.8298, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 9.92988, + "rows": 1, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "final_semijoin_strategy": "MaterializeLookup" + } + ] /* considered_execution_plans */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "columns": 2, + "row_length": 13, + "key_length": 14, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((``.`field1` = `where_subselect_20070`.`field1`) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", + "attached_conditions_computation": [ + { + "table": "`t1` `table1`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 4, + "cost": 3.00171 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "col_int_key", + "usable": true, + "key_parts": [ + "col_int_key" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "col_int_key", + "cost": 0.667442, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "col_int_key", + "ranges": [ + "NULL < col_int_key" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 4, + "cost": 0.677442, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`where_subselect_20070`", + "attached": "(`where_subselect_20070`.`field1` is not null)" + }, + { + "table": "``", + "attached": "(``.`field1` = `where_subselect_20070`.`field1`)" + }, + { + "table": "`t1` `table1`", + "attached": "(`table1`.`col_int_key` is not null)" + }, + { + "table": "`t1` `table2`", + "attached": "(`table2`.`col_int_key` = `table1`.`col_int_key`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`where_subselect_20070`", + "original_table_condition": "(`where_subselect_20070`.`field1` is not null)", + "final_table_condition ": "(`where_subselect_20070`.`field1` is not null)" + }, + { + "table": "``", + "original_table_condition": "(``.`field1` = `where_subselect_20070`.`field1`)", + "final_table_condition ": null + }, + { + "table": "`t1` `table1`", + "original_table_condition": "(`table1`.`col_int_key` is not null)", + "final_table_condition ": "(`table1`.`col_int_key` is not null)" + }, + { + "table": "`t1` `table2`", + "original_table_condition": "(`table2`.`col_int_key` = `table1`.`col_int_key`)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`where_subselect_20070`" + }, + { + "table": "``" + }, + { + "table": "`t1` `table1`" + }, + { + "table": "`t1` `table2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "materialize": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_20070,t1; +# +# Bug#13430443 - ASSERTION `NEW_TYPE[0] != 'U'' FAILED. WHEN +# OPTIMIZER_TRACE IS ENABLED +# +CREATE TABLE t1 +(a INT,b INT,c INT, KEY(a),KEY (a,c)) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c); +1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "transformations_to_subquery": [ + "removed_ordering" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from `t1` where (1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = 1)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1, + "cost": 2.45 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a" + ] /* key_parts */ + }, + { + "index": "a_2", + "usable": true, + "key_parts": [ + "a", + "c" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a_2", + "cost": 0.35, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "a_2", + "usable": false, + "cause": "no_range_predicate" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": true, + "index_only": false, + "rows": 1, + "cost": 0.6, + "chosen": false, + "cause": "cost" + }, + { + "index": "a_2", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "a_2", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "chosen": false, + "cause": "covering_index_better_than_full_scan" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`a` = 1)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`a` = 1)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`a` = 1)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# +# Bug #18346750 OPTIMIZER_TRACE & DBUG_PRINT CRASH IN ST_SELECT_LEX::PRINT +# +"Skipped since this engine does not support native partitioning. +# +# Bug#18791851 CRASH IN ST_SELECT_LEX::PRINT WITH OPTIMIZER_TRACE ON SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t4 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +SELECT alias1.col_int_nokey AS field1, +alias2.col_varchar_key AS field2, +alias1.col_time_key AS field3, +MIN( alias1.col_int_nokey ) AS field4 +FROM ( +( +SELECT SQ1_alias1.* +FROM ( t1 AS SQ1_alias1, t2 AS SQ1_alias2 ) +) AS alias1, +t4 AS alias2 +) +WHERE +EXISTS ( +SELECT DISTINCT SQ2_alias2.col_varchar_nokey AS SQ2_field1 +FROM t2 AS SQ2_alias1 +INNER JOIN (t4 AS SQ2_alias2 +INNER JOIN t3 AS SQ2_alias3 +ON SQ2_alias3.pk = SQ2_alias2.pk) +ON SQ2_alias3.col_varchar_key = SQ2_alias2.col_varchar_nokey +) +AND alias1.col_int_key = alias2.pk +HAVING alias1.col_int_nokey IN ( SELECT 2 FROM DUAL ) ; +field1 field2 field3 field4 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a INT); +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1 +HAVING 3 IN (SELECT 2 FROM DUAL)), +1)); +DROP TABLE t1; +# +# Bug #18945693 CRASH IN PRINT_TABLE_ARRAY AT SQL/SQL_LEX.CC ON 2ND EXEC OF PREPARED STATEMENT +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t1 VALUES (13,7,3,'y','y'),(14,0,4,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t2 VALUES (20,9,8,'e','e'); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t3 VALUES (1,1,7,'k','k'); +PREPARE prep_stmt FROM " +SELECT + alias1.col_varchar_nokey AS field1, + MAX(alias1.pk) AS field2 +FROM t3 AS alias1 +GROUP BY field1 +HAVING + 1 > ( + SELECT MAX(SQ4_alias1.col_varchar_nokey) + FROM t1 AS SQ4_alias1 + RIGHT OUTER JOIN + ( + t2 AS SQ4_alias2 + JOIN t1 AS SQ4_alias3 + ON SQ4_alias3.col_int_key = SQ4_alias2.col_int_nokey + ) + ON SQ4_alias3.pk = SQ4_alias2.col_int_nokey + ) +"; +EXECUTE prep_stmt; +field1 field2 +EXECUTE prep_stmt; +field1 field2 +DROP TABLE t1,t2,t3; +# +# Bug#19063289 CRASH IN PRINT_TABLE_ARRAY ON 2ND EXECUTION OF PS WITH SUBQUERY AND VIEW +# +CREATE TABLE B ( +pk INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1) +); +CREATE TABLE C ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) ; +CREATE TABLE CC ( +pk INTEGER, +col_int_key INTEGER +) ENGINE=MYISAM; +INSERT INTO CC VALUES (1, 0),(2, 7); +PREPARE stmt FROM " +SELECT +alias1.col_int_key AS field1 , +COUNT(alias1.pk) AS field2 +FROM +CC AS alias1 +GROUP BY field1 +HAVING +alias1.col_int_key > + ( + SELECT + MAX( SQ2_alias2.col_int_key ) AS SQ2_field1 + FROM + C AS SQ2_alias1 LEFT JOIN + ( B AS SQ2_alias2 INNER JOIN C AS SQ2_alias3 + ON 1) + ON 1 + ) +OR field2 < 2 +"; +EXECUTE stmt; +field1 field2 +0 1 +7 1 +EXECUTE stmt; +field1 field2 +0 1 +7 1 +DROP TABLE B,C,CC; +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE t1 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=MyISAM, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=INNODB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1),('a',2); +INSERT INTO t2 VALUES ('a',1),('a',2),('a',3),('b',1),('c',1),('c',4),('e',2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (`test`.`t1`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +EXPLAIN SELECT * FROM t2 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') and (`test`.`t2`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +DROP TABLE t1, t2; +# +# Bug #23227428: SQL PLAN IS NOT ACCORDING WITH OPTIMIZER_TRACE +# +CREATE TABLE t1(c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +c2 CHAR(12)) ENGINE=INNODB; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Backward index scan; Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` order by `test`.`t1`.`c1` desc limit 1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` order by `t1`.`c1` desc limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1000, + "cost": 1 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1000, + "access_type": "scan", + "resulting_rows": 1000, + "cost": 101, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1000, + "cost_for_plan": 101, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1` desc", + "items": [ + { + "item": "`t1`.`c1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1` desc" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# Bug#29016383 - fil_report_invalid_page_access +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER, +b VARCHAR(20) +); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +c VARCHAR(20), +KEY (c) +); +INSERT INTO t2 VALUES +(1,'koeiwsgpmfyvvuqvtjnc'), +(2,'pmfyvvuqvtjncdsvq'), +(3,'mfyv'), +(4,NULL); +SET end_markers_in_json=off; +SELECT alias1.* +FROM t2 AS alias1, t2 AS alias2 +WHERE alias2.c IN ( +WITH qn AS (SELECT b FROM t1 WHERE a = alias1.pk) +SELECT * FROM qn); +pk c +# Prove that the predicate from the WHERE clause of the CTE +# is decorrelated: +SELECT json_extract(trace,'$**.decorrelated_predicates') +FROM information_schema.optimizer_trace; +json_extract(trace,'$**.decorrelated_predicates') +[[{"inner": "`t1`.`b`", "outer": "`alias2`.`c`"}, {"inner": "`t1`.`a`", "outer": "`alias1`.`pk`"}]] +DROP TABLE t1, t2; diff --git a/mysql-test/suite/opt_trace/r/bugs_no_prot_none.result-pq b/mysql-test/suite/opt_trace/r/bugs_no_prot_none.result-pq new file mode 100644 index 000000000..920d41083 --- /dev/null +++ b/mysql-test/suite/opt_trace/r/bugs_no_prot_none.result-pq @@ -0,0 +1,2395 @@ +set optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +# +# BUG#12430646 - SEL_ARG::LEFT AND RIGHT POINTERS INCORRECTLY +# USED. CRASHES OPTIMIZER TRACING +# +CREATE TABLE t1 ( +a INT, +b CHAR(2), +c INT, +d INT, +KEY (c), +KEY (d,a,b(2)), +KEY (b(1)) +); +INSERT INTO t1 VALUES (NULL, 'a', 1, 2), (NULL, 'a', 1, 2), +(1, 'a', 1, 2), (1, 'a', 1, 2); +CREATE TABLE t2 ( +a INT, +c INT, +e INT, +KEY (e) +); +INSERT INTO t2 VALUES (1, 1, NULL), (1, 1, NULL); +SELECT 1 +FROM t1, t2 +WHERE t1.d <> '1' AND t1.b > '1' +AND t1.a = t2.a AND t1.c = t2.c; +1 +1 +1 +1 +1 +DROP TABLE t1, t2; +# +# BUG#12595210 - JSON SYNTAX ERROR ASSERT ON WHERE FIELD NOT IN SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t2 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t3 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +col_varchar_nokey VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE TABLE t4 ( +pk INT NOT NULL AUTO_INCREMENT, +col_int_key INT DEFAULT NULL, +col_varchar_key VARCHAR(1) DEFAULT NULL, +PRIMARY KEY (pk) +) ENGINE=InnoDB, CHARSET utf8mb4; +CREATE VIEW view_t4 AS SELECT * FROM t4; +CREATE TABLE where_subselect_19379 SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +); +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)); +field1 field2 +select * from information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN +(SELECT +( +SELECT SUM(sq1_alias1.pk) AS sq1_field1 +FROM view_t4 AS sq1_alias1 +INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = +sq1_alias1.col_varchar_key ) +) AS field1, +alias1.col_varchar_nokey AS field2 +FROM (t2 AS alias1 +LEFT JOIN ( t2 AS alias2 +LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = +alias2.col_varchar_key ) +) ON (alias3.col_varchar_key = alias2.col_varchar_key) +) +WHERE ( alias2.col_varchar_key IN ( +SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 +FROM t3 AS sq2_alias1 +WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key +) +)) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select `t4`.`pk` AS `pk`,`t4`.`col_int_key` AS `col_int_key`,`t4`.`col_varchar_key` AS `col_varchar_key` from `t4`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`view_t4` `sq1_alias1`", + "select#": 5, + "merged": true + } /* view */ + }, + { + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`)" + }, + { + "transformation": { + "select#": 4, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) where (`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`))))" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */, + "evaluating_constant_having_conditions": [ + ] /* evaluating_constant_having_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19379`.`field1` AS `field1`,`where_subselect_19379`.`field2` AS `field2` from `where_subselect_19379` where ((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` join `t2` `alias2` join `t2` `alias3` where ((`alias2`.`col_varchar_key`,(/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where ((`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and ((`alias2`.`col_varchar_key`) = `sq2_alias1`.`col_varchar_nokey`)))) and (outer_field_is_not_null, (((`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) is null)), true) and (outer_field_is_not_null, (((`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or (`alias1`.`col_varchar_nokey` is null)), true) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having ((outer_field_is_not_null, ((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and (outer_field_is_not_null, (`alias1`.`col_varchar_nokey`), true))) is false)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19379`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19379`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +drop table t1,t2,t3,t4,where_subselect_19379; +drop view view_t4; +# +# BUG#12607524 JSON PARSE ERROR ON SELECT ... FROM ... WHERE .. IN (SUBQUERY) +# +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (8,'g'); +CREATE TABLE t2 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +KEY col_int_key (col_int_key), +KEY col_varchar_key (col_varchar_key,col_int_key) +) ENGINE=MyISAM; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (7,'x'); +CREATE TABLE where_subselect_19033 +SELECT +( SELECT col_int_key FROM t2 ) as field1 +FROM t1 +; +SELECT * FROM where_subselect_19033; +field1 +7 +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) +; +field1 +7 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT field1 +FROM where_subselect_19033 +WHERE field1 IN +( SELECT +( SELECT col_int_key FROM t2 ) +FROM t1 +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t2`.`col_int_key` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`" + }, + { + "transformation": { + "select#": 2, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` where (`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(`where_subselect_19033`.`field1`,(/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1` where ((`where_subselect_19033`.`field1`) = (/* select#3 */ select `t2`.`col_int_key` from `t2`))))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_19033`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_19033`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(('7') = (/* select#3 */ select `t2`.`col_int_key` from `t2`))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "condition_on_constant_tables": "('7',(/* select#2 */ select (/* select#3 */ select '7' from dual) from dual where (('7') = (/* select#3 */ select '7' from dual))))", + "condition_value": true + }, + { + "attaching_conditions_to_tables": { + "original_condition": "('7',(/* select#2 */ select (/* select#3 */ select '7' from dual) from dual where (('7') = (/* select#3 */ select '7' from dual))))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_19033,t1,t2; + +# BUG#12612201 - SEGFAULT IN +# SUBSELECT_UNIQUESUBQUERY_ENGINE::PRINT WITH OPTIMIZER TRACE + +CREATE TABLE t1 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +pk int(11) NOT NULL AUTO_INCREMENT, +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL, +PRIMARY KEY (pk) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (1,4,'v','v'),(20,5,'r','r'); +CREATE TABLE t3 ( +col_int_key int(11) DEFAULT NULL, +col_varchar_key varchar(1) DEFAULT NULL, +col_varchar_nokey varchar(1) DEFAULT NULL +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t3 VALUES (NULL,'j','j'),(8,'c','c'); +CREATE TABLE where_updatedelete_20769 select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 +; +UPDATE where_updatedelete_20769 SET field1 = ( select count( alias2 . col_varchar_key ) as field1 +from ( +(select sq1_alias1 . * +from ( t3 as sq1_alias1 +straight_join t1 as sq1_alias2 +on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) +) +where sq1_alias1 . col_int_key in ( +select c_sq1_alias1 . pk as c_sq1_field1 +from t2 as c_sq1_alias1 +) +) as alias1 +left outer join t1 as alias2 +on (alias2 . col_varchar_key = alias1 . col_varchar_key ) +) +where ( alias2 . col_varchar_key in ( +select sq2_alias1 . col_varchar_nokey as sq2_field1 +from t2 as sq2_alias1 +where sq2_alias1 . col_int_key in ( +select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 +from t3 as c_sq2_alias1 +) +) ) +or alias1 . col_int_key = 2 +and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey +order by alias1 . col_varchar_key , field1 + ); +DROP TABLE where_updatedelete_20769; +DROP TABLE t1,t2,t3; + +# BUG#12710761 - INVALID JSON TRACE ON SUBQUERY IN IN-CLAUSE + +CREATE TABLE t1 (col_int_key int, KEY col_int_key (col_int_key)); +INSERT INTO t1 VALUES (0),(8),(1),(8); +CREATE TABLE where_subselect_20070 +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key; +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +); +field1 ( SELECT COUNT( col_int_key ) +FROM t1 +) +0 4 +1 4 +8 4 +8 4 +8 4 +8 4 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * +FROM where_subselect_20070 +WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( +SELECT table2 .col_int_key AS field1, +( SELECT COUNT( col_int_key ) +FROM t1 +) +FROM t1 AS table1 +JOIN t1 AS table2 +ON table2 .col_int_key = table1 .col_int_key +) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`)))" + }, + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select count(`t1`.`col_int_key`) from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` where ((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`))) where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))))" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`where_subselect_20070`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`where_subselect_20070`", + "table_scan": { + "rows": 6, + "cost": 0.504761 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`where_subselect_20070`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 6, + "access_type": "scan", + "resulting_rows": 6, + "cost": 1.10476, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 6, + "cost_for_plan": 1.10476, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`where_subselect_20070`", + "attached": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`where_subselect_20070`", + "original_table_condition": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))", + "final_table_condition ": "((`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)),(/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from `t1` `table1` join `t1` `table2` where (((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`where_subselect_20070`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`table2`.`col_int_key`, `table1`.`col_int_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`where_subselect_20070`.`field1`) = `table2`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`table2`.`col_int_key`, `table1`.`col_int_key`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1` `table1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table2`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "(`where_subselect_20070`.`field1`)", + "null_rejecting": true + }, + { + "table": "`t1` `table1`", + "field": "col_int_key", + "equals": "`table2`.`col_int_key`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "(`where_subselect_20070`.`field1`)", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_int_key", + "equals": "`table1`.`col_int_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1` `table1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + }, + { + "table": "`t1` `table2`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.455814, + "chosen": true + }, + { + "access_type": "scan", + "cost": 0.901709, + "rows": 4, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.455814, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.911628, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 1.30173, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.36744, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.455814, + "chosen": true + }, + { + "access_type": "scan", + "cost": 0.901709, + "rows": 4, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.455814, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table2`" + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_int_key", + "rows": 2, + "cost": 0.911628, + "chosen": true + }, + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 4, + "cost": 1.30173, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.36744, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`table2`.`col_int_key` = `table1`.`col_int_key`) and ((`where_subselect_20070`.`field1`) = `table1`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1` `table1`", + "attached": "(((`where_subselect_20070`.`field1`) = `table1`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))" + }, + { + "table": "`t1` `table2`", + "attached": "(`table2`.`col_int_key` = `table1`.`col_int_key`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1` `table1`", + "original_table_condition": "(((`where_subselect_20070`.`field1`) = `table1`.`col_int_key`) and (((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)))", + "final_table_condition ": "(((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`))" + }, + { + "table": "`t1` `table2`", + "original_table_condition": "(`table2`.`col_int_key` = `table1`.`col_int_key`)", + "final_table_condition ": "(`table2`.`col_int_key` = `table1`.`col_int_key`)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1` `table1`" + }, + { + "table": "`t1` `table2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 4, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 4, + "cost": 0.501709 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "access_type": "scan", + "resulting_rows": 4, + "cost": 0.901709, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 0.901709, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + { + "join_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 3, + "steps": [ + { + "join_execution": { + "select#": 3, + "steps": [ + { + "subselect_execution": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE where_subselect_20070,t1; +# +# Bug#13430443 - ASSERTION `NEW_TYPE[0] != 'U'' FAILED. WHEN +# OPTIMIZER_TRACE IS ENABLED +# +CREATE TABLE t1 +(a INT,b INT,c INT, KEY(a),KEY (a,c)) ENGINE=INNODB; +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c); +1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM t1 WHERE 1 LIKE +(SELECT a FROM t1 WHERE a = 1 ORDER BY c) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "transformations_to_subquery": [ + "removed_ordering" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from `t1` where (1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1)))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = 1)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal(1, `t1`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1, + "cost": 2.45 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a" + ] /* key_parts */ + }, + { + "index": "a_2", + "usable": true, + "key_parts": [ + "a", + "c" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a_2", + "cost": 0.35, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "a_2", + "usable": false, + "cause": "no_range_predicate" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": false, + "cause": "cost" + }, + { + "index": "a_2", + "ranges": [ + "1 <= a <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "a_2", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "chosen": false, + "cause": "covering_index_better_than_full_scan" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`a` = 1)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`a` = 1)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`a` = 1)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# +# Bug #18346750 OPTIMIZER_TRACE & DBUG_PRINT CRASH IN ST_SELECT_LEX::PRINT +# +"Skipped since this engine does not support native partitioning. +# +# Bug#18791851 CRASH IN ST_SELECT_LEX::PRINT WITH OPTIMIZER_TRACE ON SUBQUERY +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +CREATE TABLE t4 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_time_key time, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key,col_int_key) +); +SELECT alias1.col_int_nokey AS field1, +alias2.col_varchar_key AS field2, +alias1.col_time_key AS field3, +MIN( alias1.col_int_nokey ) AS field4 +FROM ( +( +SELECT SQ1_alias1.* +FROM ( t1 AS SQ1_alias1, t2 AS SQ1_alias2 ) +) AS alias1, +t4 AS alias2 +) +WHERE +EXISTS ( +SELECT DISTINCT SQ2_alias2.col_varchar_nokey AS SQ2_field1 +FROM t2 AS SQ2_alias1 +INNER JOIN (t4 AS SQ2_alias2 +INNER JOIN t3 AS SQ2_alias3 +ON SQ2_alias3.pk = SQ2_alias2.pk) +ON SQ2_alias3.col_varchar_key = SQ2_alias2.col_varchar_nokey +) +AND alias1.col_int_key = alias2.pk +HAVING alias1.col_int_nokey IN ( SELECT 2 FROM DUAL ) ; +field1 field2 field3 field4 +DROP TABLE t1,t2,t3,t4; +CREATE TABLE t1(a INT); +SET @a:=(SELECT ROW(1, 2)= +ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1 +HAVING 3 IN (SELECT 2 FROM DUAL)), +1)); +DROP TABLE t1; +# +# Bug #18945693 CRASH IN PRINT_TABLE_ARRAY AT SQL/SQL_LEX.CC ON 2ND EXEC OF PREPARED STATEMENT +# +CREATE TABLE t1 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t1 VALUES (13,7,3,'y','y'),(14,0,4,'c','c'); +CREATE TABLE t2 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t2 VALUES (20,9,8,'e','e'); +CREATE TABLE t3 ( +pk INT NOT NULL, +col_int_nokey INT, +col_int_key INT, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +); +INSERT INTO t3 VALUES (1,1,7,'k','k'); +PREPARE prep_stmt FROM " +SELECT + alias1.col_varchar_nokey AS field1, + MAX(alias1.pk) AS field2 +FROM t3 AS alias1 +GROUP BY field1 +HAVING + 1 > ( + SELECT MAX(SQ4_alias1.col_varchar_nokey) + FROM t1 AS SQ4_alias1 + RIGHT OUTER JOIN + ( + t2 AS SQ4_alias2 + JOIN t1 AS SQ4_alias3 + ON SQ4_alias3.col_int_key = SQ4_alias2.col_int_nokey + ) + ON SQ4_alias3.pk = SQ4_alias2.col_int_nokey + ) +"; +EXECUTE prep_stmt; +field1 field2 +EXECUTE prep_stmt; +field1 field2 +DROP TABLE t1,t2,t3; +# +# Bug#19063289 CRASH IN PRINT_TABLE_ARRAY ON 2ND EXECUTION OF PS WITH SUBQUERY AND VIEW +# +CREATE TABLE B ( +pk INTEGER, +col_int_key INTEGER, +col_varchar_nokey VARCHAR(1) +); +CREATE TABLE C ( +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1) +) ; +CREATE TABLE CC ( +pk INTEGER, +col_int_key INTEGER +) ENGINE=MYISAM; +INSERT INTO CC VALUES (1, 0),(2, 7); +PREPARE stmt FROM " +SELECT +alias1.col_int_key AS field1 , +COUNT(alias1.pk) AS field2 +FROM +CC AS alias1 +GROUP BY field1 +HAVING +alias1.col_int_key > + ( + SELECT + MAX( SQ2_alias2.col_int_key ) AS SQ2_field1 + FROM + C AS SQ2_alias1 LEFT JOIN + ( B AS SQ2_alias2 INNER JOIN C AS SQ2_alias3 + ON 1) + ON 1 + ) +OR field2 < 2 +"; +EXECUTE stmt; +field1 field2 +0 1 +7 1 +EXECUTE stmt; +field1 field2 +0 1 +7 1 +DROP TABLE B,C,CC; +# +# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY +# INDEX, EVEN THOUGH COST IS HIGHER +# +CREATE TABLE t1 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=MyISAM, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +CREATE TABLE t2 ( +a TINYTEXT NOT NULL, +b TINYINT(3) UNSIGNED NOT NULL, +PRIMARY KEY (a(32),b) +) ENGINE=INNODB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES ('a',1),('a',2); +INSERT INTO t2 VALUES ('a',1),('a',2),('a',3),('b',1),('c',1),('c',4),('e',2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (`test`.`t1`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +EXPLAIN SELECT * FROM t2 WHERE a='a' AND b in (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY PRIMARY 131 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`a` = 'a') and (`test`.`t2`.`b` in (1,2))) +SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +SELECT @trace RLIKE "range_uses_more_keyparts"; +@trace RLIKE "range_uses_more_keyparts" +1 +DROP TABLE t1, t2; +# +# Bug #23227428: SQL PLAN IS NOT ACCORDING WITH OPTIMIZER_TRACE +# +CREATE TABLE t1(c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +c2 CHAR(12)) ENGINE=INNODB; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Backward index scan; Parallel execute (3 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 Backward index scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` order by `test`.`t1`.`c1` desc limit 1 +SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` order by `t1`.`c1` desc limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1000, + "cost": 1 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1000, + "access_type": "scan", + "resulting_rows": 1000, + "cost": 101, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1000, + "cost_for_plan": 101, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1` desc", + "items": [ + { + "item": "`t1`.`c1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1` desc" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "PRIMARY", + "plan_changed": true, + "access_type": "index" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# Bug#29016383 - fil_report_invalid_page_access +CREATE TABLE t1 ( +pk INTEGER PRIMARY KEY, +a INTEGER, +b VARCHAR(20) +); +CREATE TABLE t2 ( +pk INTEGER PRIMARY KEY, +c VARCHAR(20), +KEY (c) +); +INSERT INTO t2 VALUES +(1,'koeiwsgpmfyvvuqvtjnc'), +(2,'pmfyvvuqvtjncdsvq'), +(3,'mfyv'), +(4,NULL); +SET end_markers_in_json=off; +SELECT alias1.* +FROM t2 AS alias1, t2 AS alias2 +WHERE alias2.c IN ( +WITH qn AS (SELECT b FROM t1 WHERE a = alias1.pk) +SELECT * FROM qn); +pk c +# Prove that the predicate from the WHERE clause of the CTE +# is decorrelated: +SELECT json_extract(trace,'$**.decorrelated_predicates') +FROM information_schema.optimizer_trace; +json_extract(trace,'$**.decorrelated_predicates') +NULL +DROP TABLE t1, t2; +# +# BUG#18365641: SERVER EXIT IN TRACE OF QUICK SELECT +# +CREATE TABLE t1 ( +pk INT(11), +i1 INT(11), +vc VARCHAR(10), +vc2 VARCHAR(10), +PRIMARY KEY (pk), +KEY i1 (i1), +KEY vc (vc) +) ENGINE=InnoDB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (1, -1281753088,'p','r'); +INSERT INTO t1 VALUES (4, NULL,'a','i'); +INSERT INTO t1 VALUES (5, NULL,'lhtrovamzq','t'); +INSERT INTO t1 VALUES (6, 3,'d','RZDUH'); +INSERT INTO t1 VALUES (7, 951910400,'z','it\'s'); +INSERT INTO t1 VALUES (8, 1067319296,'get','WZJHD'); +INSERT INTO t1 VALUES (9, -1666187264,'zqrdcenchy','me'); +INSERT INTO t1 VALUES (10, NULL,'what','there'); +CREATE TABLE t2 ( +vc VARCHAR(10), +pk INT(11), +PRIMARY KEY (pk), +KEY vc2 (vc) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES ('ukkoeiwsgp',1); +EXPLAIN +SELECT * +FROM t1 LEFT JOIN t2 +ON t1.i1 < t2.vc +WHERE t1.vc IN ( 'AVZPQ' ) +OR t1.i1 IS NULL AND t1.pk >= 9; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,i1,vc vc,i1,PRIMARY 43,9,4 NULL 2 100.00 Using union(vc,intersect(i1,PRIMARY)); Using where +1 SIMPLE t2 NULL ALL vc2 NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`vc` AS `vc`,`test`.`t1`.`vc2` AS `vc2`,`test`.`t2`.`vc` AS `vc`,`test`.`t2`.`pk` AS `pk` from `test`.`t1` left join `test`.`t2` on((cast(`test`.`t1`.`i1` as double) < cast(`test`.`t2`.`vc` as double))) where ((`test`.`t1`.`vc` = 'AVZPQ') or ((`test`.`t1`.`i1` is null) and (`test`.`t1`.`pk` >= 9))) +SELECT * +FROM t1 LEFT JOIN t2 +ON t1.i1 < t2.vc +WHERE t1.vc IN ( 'AVZPQ' ) +OR t1.i1 IS NULL AND t1.pk >= 9; +pk i1 vc vc2 vc pk +10 NULL what there NULL NULL +DROP TABLE t1, t2; diff --git a/mysql-test/suite/opt_trace/r/charset.result-pq b/mysql-test/suite/opt_trace/r/charset.result-pq new file mode 100644 index 000000000..3cb43d67b --- /dev/null +++ b/mysql-test/suite/opt_trace/r/charset.result-pq @@ -0,0 +1,889 @@ +set @@session.end_markers_in_json=on; +set @@session.optimizer_trace="enabled=on"; +create table t1(a int); +insert into t1 values(1); +set names latin1; +explain select '', _latin1'' from t1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select '' AS ``,_latin1'\xC1\xC2\xC3\xC4\xC5' AS `` from `test`.`t1` limit 1 +select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE; +(@query:=QUERY)+NULL (@trace:=TRACE)+NULL +NULL NULL +select @query, @trace; +@query @trace +explain select '', _latin1'' from t1 limit 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select '' AS ``,_latin1'\\xC1\\xC2\\xC3\\xC4\\xC5' AS `` from `t1` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @query, @trace; +@query @trace +explain select 'ÁÂÃÄÅ', _latin1'ÁÂÃÄÅ' from t1 limit 1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select 'ÁÂÃÄÅ' AS `ÁÂÃÄÅ`,_latin1'\\xC1\\xC2\\xC3\\xC4\\xC5' AS `ÁÂÃÄÅ` from `t1` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +set names latin1; +create view v1 as select '' as col from t1 limit 1; +select * from v1 where v1.col = ''; +col + +select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE; +(@query:=QUERY)+NULL (@trace:=TRACE)+NULL +NULL NULL +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @query, @trace; +@query @trace +select * from v1 where v1.col = 'ÁÂÃÄÅ' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 'ÁÂÃÄÅ' AS `col` from `t1` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`v1`", + "select#": 2, + "materialized": true + } /* view */ + }, + { + "expanded_query": "/* select#1 */ select `v1`.`col` AS `col` from `v1` where (`v1`.`col` = 'ÁÂÃÄÅ')" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`v1`", + "columns": 1, + "row_length": 7, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + }, + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`v1`.`col` = 'ÁÂÃÄÅ')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal('ÁÂÃÄÅ', `v1`.`col`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal('ÁÂÃÄÅ', `v1`.`col`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal('ÁÂÃÄÅ', `v1`.`col`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`v1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`v1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "condition_on_constant_tables": "true", + "condition_value": true + }, + { + "attaching_conditions_to_tables": { + "original_condition": "true", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +drop table t1; +drop view v1; +set names latin1; +create table t1(c char(4) primary key) charset latin1; +insert into t1 values ('aaa'), (''); +select * from t1 where c < ''; +c +aaa + +select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE; +(@query:=QUERY)+NULL (@trace:=TRACE)+NULL +NULL NULL +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +select @query, @trace; +@query @trace +select * from t1 where c < 'ÁÂÃÄÅ' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c` AS `c` from `t1` where (`t1`.`c` < 'ÁÂÃÄÅ')" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`c` < 'ÁÂÃÄÅ')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`c` < 'ÁÂÃÄÅ')" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`c` < 'ÁÂÃÄÅ')" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`c` < 'ÁÂÃÄÅ')" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.55 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "c" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "PRIMARY", + "cost": 0.450244, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "c <= ÁÂÃÄ" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.71, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`c` < 'ÁÂÃÄÅ')", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`c` < 'ÁÂÃÄÅ')" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`c` < 'ÁÂÃÄÅ')", + "final_table_condition ": "(`t1`.`c` < 'ÁÂÃÄÅ')" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +drop table t1; +create table `t +1 a`(`col +1 a` int, index `index +1 a` (`col +1 a`)); +insert into `t +1 a` values(2),(3); +create view `v +1 a` as select * from `t +1 a`; +select `col +1 a` from `v +1 a` where `col +1 a` < 6; +col +1 a +2 +3 +select query, trace from information_schema.OPTIMIZER_TRACE; +query trace +select `col +1 a` from `v +1 a` where `col +1 a` < 6 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t\n1\ta`.`col\n1\ta` AS `col\n1\ta` from `t\n1\ta`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "view": { + "table": "`v\n1\ta`", + "select#": 2, + "merged": true + } /* view */ + }, + { + "expanded_query": "/* select#1 */ select `t\n1\ta`.`col\n1\ta` AS `col\n1\ta` from (`t\n1\ta`) where (`t\n1\ta`.`col\n1\ta` < 6)" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `t\n1\ta`.`col\n1\ta` AS `col\n1\ta` from `t\n1\ta` where (`t\n1\ta`.`col\n1\ta` < 6)" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t\n1\ta`.`col\n1\ta` < 6)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t\n1\ta`.`col\n1\ta` < 6)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t\n1\ta`.`col\n1\ta` < 6)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t\n1\ta`.`col\n1\ta` < 6)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t\n1\ta`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t\n1\ta`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.55 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "index\n1\ta", + "usable": true, + "key_parts": [ + "col\n1\ta" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "index\n1\ta", + "cost": 0.450336, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "index\n1\ta", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "index\n1\ta", + "ranges": [ + "NULL < col\n1\ta < 6" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.460336, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t\n1\ta`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.45, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.45, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t\n1\ta`.`col\n1\ta` < 6)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t\n1\ta`", + "attached": "(`t\n1\ta`.`col\n1\ta` < 6)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t\n1\ta`", + "original_table_condition": "(`t\n1\ta`.`col\n1\ta` < 6)", + "final_table_condition ": "(`t\n1\ta`.`col\n1\ta` < 6)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t\n1\ta`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +drop table `t +1 a`; +drop view `v +1 a`; +set optimizer_trace=default; diff --git a/mysql-test/suite/opt_trace/r/eq_range_statistics.result-pq b/mysql-test/suite/opt_trace/r/eq_range_statistics.result-pq new file mode 100644 index 000000000..0bdd314de --- /dev/null +++ b/mysql-test/suite/opt_trace/r/eq_range_statistics.result-pq @@ -0,0 +1,1702 @@ +SET optimizer_trace_max_mem_size=1048576; +SET optimizer_trace="enabled=on,one_line=off"; +SET end_markers_in_json="on"; +SET eq_range_index_dive_limit=default; +SELECT @@eq_range_index_dive_limit; +@@eq_range_index_dive_limit +200 +CREATE TABLE t1 ( +a INT, +b INT, +KEY (a,b) +); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t1 VALUES (4,1), (4,2), (4,3); +INSERT INTO t1 VALUES (5,1), (5,2), (5,3); +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A # NULL NULL YES BTREE YES NULL +t1 1 a 2 b A # NULL NULL YES BTREE YES NULL +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 a 1 a A # NULL NULL YES BTREE YES NULL +t1 1 a 2 b A # NULL NULL YES BTREE YES NULL +##### +# Apply knowledge about the statistics (each index value for +# the first key part has an estimate of 2 rows) to ensure that +# index statistics kicks in correctly. +##### +# Index dives are done, giving correct estimate of 3 records +EXPLAIN SELECT * FROM t1 WHERE a IN (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2,3)) +SET eq_range_index_dive_limit=3; +SELECT @@eq_range_index_dive_limit; +@@eq_range_index_dive_limit +3 +SET SESSION DEBUG="+d,crash_records_in_range"; +# Index statistics kicks in, giving incorrect estimate of 3x2=6 records +EXPLAIN SELECT * FROM t1 WHERE a IN (1,2,3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (1,2,3)) +SELECT * FROM t1 WHERE a IN (1,2,3); +a b +1 1 +2 2 +3 3 +SET SESSION DEBUG="-d,crash_records_in_range"; +##### +# Below: A number of tests to verify that the number of equality ranges +# are counted correctly +##### + +# 2 equality ranges: should not use index statistics +EXPLAIN SELECT * FROM t1 WHERE a=5 OR a>10 OR a IN (1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 5 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) or (`test`.`t1`.`a` > 10) or (`test`.`t1`.`a` = 1)) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE a=5 OR a>10 OR a IN (1) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where ((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` = 1))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` = 1))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`a`) or (`t1`.`a` > 10) or multiple equal(1, `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`a`) or (`t1`.`a` > 10) or multiple equal(1, `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(5, `t1`.`a`) or (`t1`.`a` > 10) or multiple equal(1, `t1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 9, + "cost": 3.25 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a", + "cost": 1.1539, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "1 <= a <= 1", + "5 <= a <= 5", + "10 < a" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 5, + "cost": 0.761949, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "a", + "rows": 5, + "ranges": [ + "1 <= a <= 1", + "5 <= a <= 5", + "10 < a" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 5, + "cost_for_plan": 0.761949, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 5, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "a" + } /* range_details */, + "resulting_rows": 5, + "cost": 1.26195, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 5, + "cost_for_plan": 1.26195, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` = 1))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` = 1))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` = 1))", + "final_table_condition ": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` = 1))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +# 3 equality ranges: should use index statistics +EXPLAIN SELECT * FROM t1 WHERE a=5 OR a>10 OR a IN (1,2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range a a 5 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) or (`test`.`t1`.`a` > 10) or (`test`.`t1`.`a` in (1,2))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE a=5 OR a>10 OR a IN (1,2) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "IN_uses_bisection": true + }, + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where ((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`a`) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`a`) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(5, `t1`.`a`) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 9, + "cost": 3.25 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a", + "cost": 1.1539, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "1 <= a <= 1", + "2 <= a <= 2", + "5 <= a <= 5", + "10 < a" + ] /* ranges */, + "index_dives_for_eq_ranges": false, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 4, + "cost": 0.661462, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "a", + "rows": 4, + "ranges": [ + "1 <= a <= 1", + "2 <= a <= 2", + "5 <= a <= 5", + "10 < a" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 4, + "cost_for_plan": 0.661462, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 4, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "a" + } /* range_details */, + "resulting_rows": 4, + "cost": 1.06146, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 1.06146, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))", + "final_table_condition ": "((`t1`.`a` = 5) or (`t1`.`a` > 10) or (`t1`.`a` in (1,2)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +# 3 equality ranges: should use index statistics +SET SESSION DEBUG="+d,crash_records_in_range"; +EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b=4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and ((`test`.`t1`.`b` = 2) or (`test`.`t1`.`b` = 3) or (`test`.`t1`.`b` = 4))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b=4) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where ((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or multiple equal(4, `t1`.`b`)) and multiple equal(5, `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or multiple equal(4, `t1`.`b`)) and multiple equal(5, `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or multiple equal(4, `t1`.`b`)) and multiple equal(5, `t1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 9, + "cost": 3.25 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a", + "cost": 1.1539, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "no_range_predicate" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3", + "5 <= a <= 5 AND 4 <= b <= 4" + ] /* ranges */, + "index_dives_for_eq_ranges": false, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.560975, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "a", + "rows": 3, + "ranges": [ + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3", + "5 <= a <= 5 AND 4 <= b <= 4" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 3, + "cost_for_plan": 0.560975, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 3, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "a" + } /* range_details */, + "resulting_rows": 3, + "cost": 0.860975, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.860975, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))", + "final_table_condition ": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET SESSION DEBUG="-d,crash_records_in_range"; + +# 2 equality ranges: should not use index statistics +EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b>4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and ((`test`.`t1`.`b` = 2) or (`test`.`t1`.`b` = 3) or (`test`.`t1`.`b` > 4))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b>4) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where ((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` > 4)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` > 4)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or (`t1`.`b` > 4)) and multiple equal(5, `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or (`t1`.`b` > 4)) and multiple equal(5, `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or (`t1`.`b` > 4)) and multiple equal(5, `t1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 9, + "cost": 3.25 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a", + "cost": 1.1539, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3", + "5 <= a <= 5 AND 4 < b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.560975, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "a", + "rows": 3, + "ranges": [ + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3", + "5 <= a <= 5 AND 4 < b" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 3, + "cost_for_plan": 0.560975, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 3, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "a" + } /* range_details */, + "resulting_rows": 3, + "cost": 0.860975, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.860975, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` > 4)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` > 4)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` > 4)))", + "final_table_condition ": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` > 4)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +# 2 equality ranges: should not use index statistics +EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b IS NULL); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range a a 10 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and ((`test`.`t1`.`b` = 2) or (`test`.`t1`.`b` = 3) or (`test`.`t1`.`b` is null))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE a=5 AND (b=2 OR b=3 OR b IS NULL) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where ((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` is null)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` is null)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or (`t1`.`b` is null)) and multiple equal(5, `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or (`t1`.`b` is null)) and multiple equal(5, `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or (`t1`.`b` is null)) and multiple equal(5, `t1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 9, + "cost": 3.25 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a", + "cost": 1.1539, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "no_range_predicate" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "5 <= a <= 5 AND NULL <= b <= NULL", + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.560975, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "a", + "rows": 3, + "ranges": [ + "5 <= a <= 5 AND NULL <= b <= NULL", + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 3, + "cost_for_plan": 0.560975, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 3, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "a" + } /* range_details */, + "resulting_rows": 3, + "cost": 0.860975, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.860975, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` is null)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` is null)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` is null)))", + "final_table_condition ": "((`t1`.`a` = 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` is null)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +# 0 equality ranges: should not use index statistics +EXPLAIN SELECT * FROM t1 WHERE a>5 AND (b=2 OR b=3 OR b=4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 29.77 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 1 29.77 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` > 5) and ((`test`.`t1`.`b` = 2) or (`test`.`t1`.`b` = 3) or (`test`.`t1`.`b` = 4))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE a>5 AND (b=2 OR b=3 OR b=4) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where ((`t1`.`a` > 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` > 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`a` > 5) and (multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or multiple equal(4, `t1`.`b`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`a` > 5) and (multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or multiple equal(4, `t1`.`b`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`a` > 5) and (multiple equal(2, `t1`.`b`) or multiple equal(3, `t1`.`b`) or multiple equal(4, `t1`.`b`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 9, + "cost": 3.25 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a", + "cost": 1.1539, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "5 < a" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "a", + "rows": 1, + "ranges": [ + "5 < a" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.36, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.297668, + "access_type": "range", + "range_details": { + "used_index": "a" + } /* range_details */, + "resulting_rows": 0.297668, + "cost": 0.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 0.297668, + "cost_for_plan": 0.46, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` > 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` > 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` > 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))", + "final_table_condition ": "((`t1`.`a` > 5) and ((`t1`.`b` = 2) or (`t1`.`b` = 3) or (`t1`.`b` = 4)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET eq_range_index_dive_limit=0; + +# 1 equality range: should not use index statistics +EXPLAIN SELECT * FROM t1 WHERE a=5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref a a 5 const 3 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 5) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE a=5 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where (`t1`.`a` = 5)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = 5)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal(5, `t1`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal(5, `t1`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal(5, `t1`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 9, + "cost": 3.25 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "a", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "a", + "cost": 1.1539, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "a", + "usable": false, + "cause": "no_range_predicate" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "a", + "ranges": [ + "5 <= a <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.560975, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "a", + "rows": 3, + "ranges": [ + "5 <= a <= 5" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 3, + "cost_for_plan": 0.560975, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 3, + "cost": 0.550975, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "a" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.550975, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`a` = 5)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`a` = 5)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`a` = 5)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +SET eq_range_index_dive_limit=default; diff --git a/mysql-test/suite/opt_trace/r/filesort_pack.result-pq b/mysql-test/suite/opt_trace/r/filesort_pack.result-pq new file mode 100644 index 000000000..84e34a006 --- /dev/null +++ b/mysql-test/suite/opt_trace/r/filesort_pack.result-pq @@ -0,0 +1,947 @@ +call mtr.add_suppression("Cannot add field"); +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=off; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 ( +c1 VARCHAR(1022) NOT NULL DEFAULT '', +c2 VARCHAR(1022) NOT NULL DEFAULT '', +c3 VARCHAR(1022) NOT NULL DEFAULT '', +c4 VARCHAR(1022) NOT NULL DEFAULT '', +c5 VARCHAR(1022) NOT NULL DEFAULT '', +c6 VARCHAR(1022) NOT NULL DEFAULT '', +c7 VARCHAR(1022) NOT NULL DEFAULT '', +c8 VARCHAR(1022) NOT NULL DEFAULT '', +c9 VARCHAR(1022) NOT NULL DEFAULT '', +c10 VARCHAR(1022) NOT NULL DEFAULT '', +c11 VARCHAR(1022) NOT NULL DEFAULT '', +c12 VARCHAR(1022) NOT NULL DEFAULT '', +c13 VARCHAR(1022) NOT NULL DEFAULT '', +c14 VARCHAR(1022) NOT NULL DEFAULT '', +c15 VARCHAR(1022) NOT NULL DEFAULT '', +c16 VARCHAR(1022) NOT NULL DEFAULT '', +c17 VARCHAR(1022) NOT NULL DEFAULT '', +c18 VARCHAR(1022) NOT NULL DEFAULT '', +c19 VARCHAR(1022) NOT NULL DEFAULT '', +c20 VARCHAR(1022) NOT NULL DEFAULT '', +c21 VARCHAR(1022) NOT NULL DEFAULT '', +c22 VARCHAR(1022) NOT NULL DEFAULT '', +c23 VARCHAR(1022) NOT NULL DEFAULT '', +c24 VARCHAR(1022) NOT NULL DEFAULT '', +c25 VARCHAR(1022) NOT NULL DEFAULT '', +c26 VARCHAR(1022) NOT NULL DEFAULT '', +c27 VARCHAR(1022) NOT NULL DEFAULT '', +c28 VARCHAR(1022) NOT NULL DEFAULT '', +c29 VARCHAR(1022) NOT NULL DEFAULT '', +c30 VARCHAR(1022) NOT NULL DEFAULT '', +c31 VARCHAR(1022) NOT NULL DEFAULT '', +c32 VARCHAR(1022) NOT NULL DEFAULT '', +c33 VARCHAR(1022) NOT NULL DEFAULT '', +c34 VARCHAR(1022) NOT NULL DEFAULT '', +c35 VARCHAR(1022) NOT NULL DEFAULT '', +c36 VARCHAR(1022) NOT NULL DEFAULT '', +c37 VARCHAR(1022) NOT NULL DEFAULT '', +c38 VARCHAR(1022) NOT NULL DEFAULT '', +c39 VARCHAR(1022) NOT NULL DEFAULT '', +c40 VARCHAR(1022) NOT NULL DEFAULT '', +c41 VARCHAR(1022) NOT NULL DEFAULT '', +c42 VARCHAR(1022) NOT NULL DEFAULT '', +c43 VARCHAR(1022) NOT NULL DEFAULT '', +c44 VARCHAR(1022) NOT NULL DEFAULT '', +c45 VARCHAR(1022) NOT NULL DEFAULT '', +c46 VARCHAR(1022) NOT NULL DEFAULT '', +c47 VARCHAR(1022) NOT NULL DEFAULT '', +c48 VARCHAR(1022) NOT NULL DEFAULT '', +c49 VARCHAR(1022) NOT NULL DEFAULT '', +c50 VARCHAR(1022) NOT NULL DEFAULT '', +c51 VARCHAR(1022) NOT NULL DEFAULT '', +c52 VARCHAR(1022) NOT NULL DEFAULT '', +c53 VARCHAR(1022) NOT NULL DEFAULT '', +c54 VARCHAR(1022) NOT NULL DEFAULT '', +c55 VARCHAR(1022) NOT NULL DEFAULT '', +c56 VARCHAR(1022) NOT NULL DEFAULT '', +c57 VARCHAR(1022) NOT NULL DEFAULT '', +c58 VARCHAR(1022) NOT NULL DEFAULT '', +c59 VARCHAR(1022) NOT NULL DEFAULT '', +c60 VARCHAR(1022) NOT NULL DEFAULT '', +c61 VARCHAR(1022) NOT NULL DEFAULT '', +c62 VARCHAR(1022) NOT NULL DEFAULT '', +c63 VARCHAR(1022) NOT NULL DEFAULT '', +c64 VARCHAR(1021) NOT NULL DEFAULT '' +) ENGINE = INNODB, charset latin1; +SET @save_sort_buffer_size= @@sort_buffer_size; +SET @@sort_buffer_size = 8 + 15 * (65535 + 1022 + 8); +select * from t1 order by c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select * from t1 order by c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET @@sort_buffer_size = 8 + 15 * (65535 + 1023 + 8); +select * from t1 order by c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select * from t1 order by c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET @@sort_buffer_size = 8 + 15 * (65535 + 1024 + 8); +select * from t1 order by c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select * from t1 order by c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET @@sort_buffer_size= @save_sort_buffer_size; +DROP TABLE t1; +SET innodb_strict_mode=off; +CREATE TABLE t1 ( +c1 CHAR(255) NOT NULL DEFAULT '', +c2 CHAR(255) NOT NULL DEFAULT '', +c3 CHAR(255) NOT NULL DEFAULT '', +c4 CHAR(255) NOT NULL DEFAULT '', +c5 CHAR(255) NOT NULL DEFAULT '', +c6 CHAR(255) NOT NULL DEFAULT '', +c7 CHAR(255) NOT NULL DEFAULT '', +c8 CHAR(255) NOT NULL DEFAULT '', +c9 CHAR(255) NOT NULL DEFAULT '', +c10 CHAR(255) NOT NULL DEFAULT '', +c11 CHAR(255) NOT NULL DEFAULT '', +c12 CHAR(255) NOT NULL DEFAULT '', +c13 CHAR(255) NOT NULL DEFAULT '', +c14 CHAR(255) NOT NULL DEFAULT '', +c15 CHAR(255) NOT NULL DEFAULT '', +c16 CHAR(255) NOT NULL DEFAULT '', +c17 CHAR(255) NOT NULL DEFAULT '', +c18 CHAR(255) NOT NULL DEFAULT '', +c19 CHAR(255) NOT NULL DEFAULT '', +c20 CHAR(255) NOT NULL DEFAULT '', +c21 CHAR(255) NOT NULL DEFAULT '', +c22 CHAR(255) NOT NULL DEFAULT '', +c23 CHAR(255) NOT NULL DEFAULT '', +c24 CHAR(255) NOT NULL DEFAULT '', +c25 CHAR(255) NOT NULL DEFAULT '', +c26 CHAR(255) NOT NULL DEFAULT '', +c27 CHAR(255) NOT NULL DEFAULT '', +c28 CHAR(255) NOT NULL DEFAULT '', +c29 CHAR(255) NOT NULL DEFAULT '', +c30 CHAR(255) NOT NULL DEFAULT '', +c31 CHAR(255) NOT NULL DEFAULT '', +c32 CHAR(255) NOT NULL DEFAULT '', +c33 CHAR(255) NOT NULL DEFAULT '', +c34 CHAR(255) NOT NULL DEFAULT '', +c35 CHAR(255) NOT NULL DEFAULT '', +c36 CHAR(255) NOT NULL DEFAULT '', +c37 CHAR(255) NOT NULL DEFAULT '', +c38 CHAR(255) NOT NULL DEFAULT '', +c39 CHAR(255) NOT NULL DEFAULT '', +c40 CHAR(255) NOT NULL DEFAULT '', +c41 CHAR(255) NOT NULL DEFAULT '', +c42 CHAR(255) NOT NULL DEFAULT '', +c43 CHAR(255) NOT NULL DEFAULT '', +c44 CHAR(255) NOT NULL DEFAULT '', +c45 CHAR(255) NOT NULL DEFAULT '', +c46 CHAR(255) NOT NULL DEFAULT '', +c47 CHAR(255) NOT NULL DEFAULT '', +c48 CHAR(255) NOT NULL DEFAULT '', +c49 CHAR(255) NOT NULL DEFAULT '', +c50 CHAR(255) NOT NULL DEFAULT '', +c51 CHAR(255) NOT NULL DEFAULT '', +c52 CHAR(255) NOT NULL DEFAULT '', +c53 CHAR(255) NOT NULL DEFAULT '', +c54 CHAR(255) NOT NULL DEFAULT '', +c55 CHAR(255) NOT NULL DEFAULT '', +c56 CHAR(255) NOT NULL DEFAULT '', +c57 CHAR(255) NOT NULL DEFAULT '', +c58 CHAR(255) NOT NULL DEFAULT '', +c59 CHAR(255) NOT NULL DEFAULT '', +c60 CHAR(255) NOT NULL DEFAULT '', +c61 CHAR(255) NOT NULL DEFAULT '', +c62 CHAR(255) NOT NULL DEFAULT '', +c63 CHAR(255) NOT NULL DEFAULT '', +c64 CHAR(255) NOT NULL DEFAULT '', +c65 CHAR(255) NOT NULL DEFAULT '', +c66 CHAR(255) NOT NULL DEFAULT '', +c67 CHAR(255) NOT NULL DEFAULT '', +c68 CHAR(255) NOT NULL DEFAULT '', +c69 CHAR(255) NOT NULL DEFAULT '', +c70 CHAR(255) NOT NULL DEFAULT '', +c71 CHAR(255) NOT NULL DEFAULT '', +c72 CHAR(255) NOT NULL DEFAULT '', +c73 CHAR(255) NOT NULL DEFAULT '', +c74 CHAR(255) NOT NULL DEFAULT '', +c75 CHAR(255) NOT NULL DEFAULT '', +c76 CHAR(255) NOT NULL DEFAULT '', +c77 CHAR(255) NOT NULL DEFAULT '', +c78 CHAR(255) NOT NULL DEFAULT '', +c79 CHAR(255) NOT NULL DEFAULT '', +c80 CHAR(255) NOT NULL DEFAULT '', +c81 CHAR(255) NOT NULL DEFAULT '', +c82 CHAR(255) NOT NULL DEFAULT '', +c83 CHAR(255) NOT NULL DEFAULT '', +c84 CHAR(255) NOT NULL DEFAULT '', +c85 CHAR(255) NOT NULL DEFAULT '', +c86 CHAR(255) NOT NULL DEFAULT '', +c87 CHAR(255) NOT NULL DEFAULT '', +c88 CHAR(255) NOT NULL DEFAULT '', +c89 CHAR(255) NOT NULL DEFAULT '', +c90 CHAR(255) NOT NULL DEFAULT '', +c91 CHAR(255) NOT NULL DEFAULT '', +c92 CHAR(255) NOT NULL DEFAULT '', +c93 CHAR(255) NOT NULL DEFAULT '', +c94 CHAR(255) NOT NULL DEFAULT '', +c95 CHAR(255) NOT NULL DEFAULT '', +c96 CHAR(255) NOT NULL DEFAULT '', +c97 CHAR(255) NOT NULL DEFAULT '', +c98 CHAR(255) NOT NULL DEFAULT '', +c99 CHAR(255) NOT NULL DEFAULT '', +c100 CHAR(255) NOT NULL DEFAULT '', +c101 CHAR(255) NOT NULL DEFAULT '', +c102 CHAR(255) NOT NULL DEFAULT '', +c103 CHAR(255) NOT NULL DEFAULT '', +c104 CHAR(255) NOT NULL DEFAULT '', +c105 CHAR(255) NOT NULL DEFAULT '', +c106 CHAR(255) NOT NULL DEFAULT '', +c107 CHAR(255) NOT NULL DEFAULT '', +c108 CHAR(255) NOT NULL DEFAULT '', +c109 CHAR(255) NOT NULL DEFAULT '', +c110 CHAR(255) NOT NULL DEFAULT '', +c111 CHAR(255) NOT NULL DEFAULT '', +c112 CHAR(255) NOT NULL DEFAULT '', +c113 CHAR(255) NOT NULL DEFAULT '', +c114 CHAR(255) NOT NULL DEFAULT '', +c115 CHAR(255) NOT NULL DEFAULT '', +c116 CHAR(255) NOT NULL DEFAULT '', +c117 CHAR(255) NOT NULL DEFAULT '', +c118 CHAR(255) NOT NULL DEFAULT '', +c119 CHAR(255) NOT NULL DEFAULT '', +c120 CHAR(255) NOT NULL DEFAULT '', +c121 CHAR(255) NOT NULL DEFAULT '', +c122 CHAR(255) NOT NULL DEFAULT '', +c123 CHAR(255) NOT NULL DEFAULT '', +c124 CHAR(255) NOT NULL DEFAULT '', +c125 CHAR(255) NOT NULL DEFAULT '', +c126 CHAR(255) NOT NULL DEFAULT '', +c127 CHAR(255) NOT NULL DEFAULT '', +c128 CHAR(255) NOT NULL DEFAULT '', +c129 CHAR(255) NOT NULL DEFAULT '', +c130 CHAR(255) NOT NULL DEFAULT '', +c131 CHAR(255) NOT NULL DEFAULT '', +c132 CHAR(255) NOT NULL DEFAULT '', +c133 CHAR(255) NOT NULL DEFAULT '', +c134 CHAR(255) NOT NULL DEFAULT '', +c135 CHAR(255) NOT NULL DEFAULT '', +c136 CHAR(255) NOT NULL DEFAULT '', +c137 CHAR(255) NOT NULL DEFAULT '', +c138 CHAR(255) NOT NULL DEFAULT '', +c139 CHAR(255) NOT NULL DEFAULT '', +c140 CHAR(255) NOT NULL DEFAULT '', +c141 CHAR(255) NOT NULL DEFAULT '', +c142 CHAR(255) NOT NULL DEFAULT '', +c143 CHAR(255) NOT NULL DEFAULT '', +c144 CHAR(255) NOT NULL DEFAULT '', +c145 CHAR(255) NOT NULL DEFAULT '', +c146 CHAR(255) NOT NULL DEFAULT '', +c147 CHAR(255) NOT NULL DEFAULT '', +c148 CHAR(255) NOT NULL DEFAULT '', +c149 CHAR(255) NOT NULL DEFAULT '', +c150 CHAR(255) NOT NULL DEFAULT '', +c151 CHAR(255) NOT NULL DEFAULT '', +c152 CHAR(255) NOT NULL DEFAULT '', +c153 CHAR(255) NOT NULL DEFAULT '', +c154 CHAR(255) NOT NULL DEFAULT '', +c155 CHAR(255) NOT NULL DEFAULT '', +c156 CHAR(255) NOT NULL DEFAULT '', +c157 CHAR(255) NOT NULL DEFAULT '', +c158 CHAR(255) NOT NULL DEFAULT '', +c159 CHAR(255) NOT NULL DEFAULT '', +c160 CHAR(255) NOT NULL DEFAULT '', +c161 CHAR(255) NOT NULL DEFAULT '', +c162 CHAR(255) NOT NULL DEFAULT '', +c163 CHAR(255) NOT NULL DEFAULT '', +c164 CHAR(255) NOT NULL DEFAULT '', +c165 CHAR(255) NOT NULL DEFAULT '', +c166 CHAR(255) NOT NULL DEFAULT '', +c167 CHAR(255) NOT NULL DEFAULT '', +c168 CHAR(255) NOT NULL DEFAULT '', +c169 CHAR(255) NOT NULL DEFAULT '', +c170 CHAR(255) NOT NULL DEFAULT '', +c171 CHAR(255) NOT NULL DEFAULT '', +c172 CHAR(255) NOT NULL DEFAULT '', +c173 CHAR(255) NOT NULL DEFAULT '', +c174 CHAR(255) NOT NULL DEFAULT '', +c175 CHAR(255) NOT NULL DEFAULT '', +c176 CHAR(255) NOT NULL DEFAULT '', +c177 CHAR(255) NOT NULL DEFAULT '', +c178 CHAR(255) NOT NULL DEFAULT '', +c179 CHAR(255) NOT NULL DEFAULT '', +c180 CHAR(255) NOT NULL DEFAULT '', +c181 CHAR(255) NOT NULL DEFAULT '', +c182 CHAR(255) NOT NULL DEFAULT '', +c183 CHAR(255) NOT NULL DEFAULT '', +c184 CHAR(255) NOT NULL DEFAULT '', +c185 CHAR(255) NOT NULL DEFAULT '', +c186 CHAR(255) NOT NULL DEFAULT '', +c187 CHAR(255) NOT NULL DEFAULT '', +c188 CHAR(255) NOT NULL DEFAULT '', +c189 CHAR(255) NOT NULL DEFAULT '', +c190 CHAR(255) NOT NULL DEFAULT '', +c191 CHAR(255) NOT NULL DEFAULT '', +c192 CHAR(255) NOT NULL DEFAULT '', +c193 CHAR(255) NOT NULL DEFAULT '', +c194 CHAR(255) NOT NULL DEFAULT '', +c195 CHAR(255) NOT NULL DEFAULT '', +c196 CHAR(255) NOT NULL DEFAULT '', +c197 CHAR(255) NOT NULL DEFAULT '', +c198 CHAR(255) NOT NULL DEFAULT '', +c199 CHAR(255) NOT NULL DEFAULT '', +c200 CHAR(255) NOT NULL DEFAULT '', +c201 CHAR(255) NOT NULL DEFAULT '', +c202 CHAR(255) NOT NULL DEFAULT '', +c203 CHAR(255) NOT NULL DEFAULT '', +c204 CHAR(255) NOT NULL DEFAULT '', +c205 CHAR(255) NOT NULL DEFAULT '', +c206 CHAR(255) NOT NULL DEFAULT '', +c207 CHAR(255) NOT NULL DEFAULT '', +c208 CHAR(255) NOT NULL DEFAULT '', +c209 CHAR(255) NOT NULL DEFAULT '', +c210 CHAR(255) NOT NULL DEFAULT '', +c211 CHAR(255) NOT NULL DEFAULT '', +c212 CHAR(255) NOT NULL DEFAULT '', +c213 CHAR(255) NOT NULL DEFAULT '', +c214 CHAR(255) NOT NULL DEFAULT '', +c215 CHAR(255) NOT NULL DEFAULT '', +c216 CHAR(255) NOT NULL DEFAULT '', +c217 CHAR(255) NOT NULL DEFAULT '', +c218 CHAR(255) NOT NULL DEFAULT '', +c219 CHAR(255) NOT NULL DEFAULT '', +c220 CHAR(255) NOT NULL DEFAULT '', +c221 CHAR(255) NOT NULL DEFAULT '', +c222 CHAR(255) NOT NULL DEFAULT '', +c223 CHAR(255) NOT NULL DEFAULT '', +c224 CHAR(255) NOT NULL DEFAULT '', +c225 CHAR(255) NOT NULL DEFAULT '', +c226 CHAR(255) NOT NULL DEFAULT '', +c227 CHAR(255) NOT NULL DEFAULT '', +c228 CHAR(255) NOT NULL DEFAULT '', +c229 CHAR(255) NOT NULL DEFAULT '', +c230 CHAR(255) NOT NULL DEFAULT '', +c231 CHAR(255) NOT NULL DEFAULT '', +c232 CHAR(255) NOT NULL DEFAULT '', +c233 CHAR(255) NOT NULL DEFAULT '', +c234 CHAR(255) NOT NULL DEFAULT '', +c235 CHAR(255) NOT NULL DEFAULT '', +c236 CHAR(255) NOT NULL DEFAULT '', +c237 CHAR(255) NOT NULL DEFAULT '', +c238 CHAR(255) NOT NULL DEFAULT '', +c239 CHAR(255) NOT NULL DEFAULT '', +c240 CHAR(255) NOT NULL DEFAULT '', +c241 CHAR(255) NOT NULL DEFAULT '', +c242 CHAR(255) NOT NULL DEFAULT '', +c243 CHAR(255) NOT NULL DEFAULT '', +c244 CHAR(255) NOT NULL DEFAULT '', +c245 CHAR(255) NOT NULL DEFAULT '', +c246 CHAR(255) NOT NULL DEFAULT '', +c247 CHAR(255) NOT NULL DEFAULT '', +c248 CHAR(255) NOT NULL DEFAULT '', +c249 CHAR(255) NOT NULL DEFAULT '', +c250 CHAR(255) NOT NULL DEFAULT '', +c251 CHAR(255) NOT NULL DEFAULT '', +c252 CHAR(255) NOT NULL DEFAULT '', +c253 CHAR(255) NOT NULL DEFAULT '', +c254 CHAR(255) NOT NULL DEFAULT '', +c255 CHAR(255) NOT NULL DEFAULT '', +c256 CHAR(255) NOT NULL DEFAULT '', +c257 CHAR(254) NOT NULL DEFAULT '' +) ENGINE = INNODB ROW_FORMAT=COMPACT charset latin1; +Warnings: +Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. +SELECT * FROM t1 ORDER BY c1; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 c40 c41 c42 c43 c44 c45 c46 c47 c48 c49 c50 c51 c52 c53 c54 c55 c56 c57 c58 c59 c60 c61 c62 c63 c64 c65 c66 c67 c68 c69 c70 c71 c72 c73 c74 c75 c76 c77 c78 c79 c80 c81 c82 c83 c84 c85 c86 c87 c88 c89 c90 c91 c92 c93 c94 c95 c96 c97 c98 c99 c100 c101 c102 c103 c104 c105 c106 c107 c108 c109 c110 c111 c112 c113 c114 c115 c116 c117 c118 c119 c120 c121 c122 c123 c124 c125 c126 c127 c128 c129 c130 c131 c132 c133 c134 c135 c136 c137 c138 c139 c140 c141 c142 c143 c144 c145 c146 c147 c148 c149 c150 c151 c152 c153 c154 c155 c156 c157 c158 c159 c160 c161 c162 c163 c164 c165 c166 c167 c168 c169 c170 c171 c172 c173 c174 c175 c176 c177 c178 c179 c180 c181 c182 c183 c184 c185 c186 c187 c188 c189 c190 c191 c192 c193 c194 c195 c196 c197 c198 c199 c200 c201 c202 c203 c204 c205 c206 c207 c208 c209 c210 c211 c212 c213 c214 c215 c216 c217 c218 c219 c220 c221 c222 c223 c224 c225 c226 c227 c228 c229 c230 c231 c232 c233 c234 c235 c236 c237 c238 c239 c240 c241 c242 c243 c244 c245 c246 c247 c248 c249 c250 c251 c252 c253 c254 c255 c256 c257 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT * FROM t1 ORDER BY c1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2`,`t1`.`c3` AS `c3`,`t1`.`c4` AS `c4`,`t1`.`c5` AS `c5`,`t1`.`c6` AS `c6`,`t1`.`c7` AS `c7`,`t1`.`c8` AS `c8`,`t1`.`c9` AS `c9`,`t1`.`c10` AS `c10`,`t1`.`c11` AS `c11`,`t1`.`c12` AS `c12`,`t1`.`c13` AS `c13`,`t1`.`c14` AS `c14`,`t1`.`c15` AS `c15`,`t1`.`c16` AS `c16`,`t1`.`c17` AS `c17`,`t1`.`c18` AS `c18`,`t1`.`c19` AS `c19`,`t1`.`c20` AS `c20`,`t1`.`c21` AS `c21`,`t1`.`c22` AS `c22`,`t1`.`c23` AS `c23`,`t1`.`c24` AS `c24`,`t1`.`c25` AS `c25`,`t1`.`c26` AS `c26`,`t1`.`c27` AS `c27`,`t1`.`c28` AS `c28`,`t1`.`c29` AS `c29`,`t1`.`c30` AS `c30`,`t1`.`c31` AS `c31`,`t1`.`c32` AS `c32`,`t1`.`c33` AS `c33`,`t1`.`c34` AS `c34`,`t1`.`c35` AS `c35`,`t1`.`c36` AS `c36`,`t1`.`c37` AS `c37`,`t1`.`c38` AS `c38`,`t1`.`c39` AS `c39`,`t1`.`c40` AS `c40`,`t1`.`c41` AS `c41`,`t1`.`c42` AS `c42`,`t1`.`c43` AS `c43`,`t1`.`c44` AS `c44`,`t1`.`c45` AS `c45`,`t1`.`c46` AS `c46`,`t1`.`c47` AS `c47`,`t1`.`c48` AS `c48`,`t1`.`c49` AS `c49`,`t1`.`c50` AS `c50`,`t1`.`c51` AS `c51`,`t1`.`c52` AS `c52`,`t1`.`c53` AS `c53`,`t1`.`c54` AS `c54`,`t1`.`c55` AS `c55`,`t1`.`c56` AS `c56`,`t1`.`c57` AS `c57`,`t1`.`c58` AS `c58`,`t1`.`c59` AS `c59`,`t1`.`c60` AS `c60`,`t1`.`c61` AS `c61`,`t1`.`c62` AS `c62`,`t1`.`c63` AS `c63`,`t1`.`c64` AS `c64`,`t1`.`c65` AS `c65`,`t1`.`c66` AS `c66`,`t1`.`c67` AS `c67`,`t1`.`c68` AS `c68`,`t1`.`c69` AS `c69`,`t1`.`c70` AS `c70`,`t1`.`c71` AS `c71`,`t1`.`c72` AS `c72`,`t1`.`c73` AS `c73`,`t1`.`c74` AS `c74`,`t1`.`c75` AS `c75`,`t1`.`c76` AS `c76`,`t1`.`c77` AS `c77`,`t1`.`c78` AS `c78`,`t1`.`c79` AS `c79`,`t1`.`c80` AS `c80`,`t1`.`c81` AS `c81`,`t1`.`c82` AS `c82`,`t1`.`c83` AS `c83`,`t1`.`c84` AS `c84`,`t1`.`c85` AS `c85`,`t1`.`c86` AS `c86`,`t1`.`c87` AS `c87`,`t1`.`c88` AS `c88`,`t1`.`c89` AS `c89`,`t1`.`c90` AS `c90`,`t1`.`c91` AS `c91`,`t1`.`c92` AS `c92`,`t1`.`c93` AS `c93`,`t1`.`c94` AS `c94`,`t1`.`c95` AS `c95`,`t1`.`c96` AS `c96`,`t1`.`c97` AS `c97`,`t1`.`c98` AS `c98`,`t1`.`c99` AS `c99`,`t1`.`c100` AS `c100`,`t1`.`c101` AS `c101`,`t1`.`c102` AS `c102`,`t1`.`c103` AS `c103`,`t1`.`c104` AS `c104`,`t1`.`c105` AS `c105`,`t1`.`c106` AS `c106`,`t1`.`c107` AS `c107`,`t1`.`c108` AS `c108`,`t1`.`c109` AS `c109`,`t1`.`c110` AS `c110`,`t1`.`c111` AS `c111`,`t1`.`c112` AS `c112`,`t1`.`c113` AS `c113`,`t1`.`c114` AS `c114`,`t1`.`c115` AS `c115`,`t1`.`c116` AS `c116`,`t1`.`c117` AS `c117`,`t1`.`c118` AS `c118`,`t1`.`c119` AS `c119`,`t1`.`c120` AS `c120`,`t1`.`c121` AS `c121`,`t1`.`c122` AS `c122`,`t1`.`c123` AS `c123`,`t1`.`c124` AS `c124`,`t1`.`c125` AS `c125`,`t1`.`c126` AS `c126`,`t1`.`c127` AS `c127`,`t1`.`c128` AS `c128`,`t1`.`c129` AS `c129`,`t1`.`c130` AS `c130`,`t1`.`c131` AS `c131`,`t1`.`c132` AS `c132`,`t1`.`c133` AS `c133`,`t1`.`c134` AS `c134`,`t1`.`c135` AS `c135`,`t1`.`c136` AS `c136`,`t1`.`c137` AS `c137`,`t1`.`c138` AS `c138`,`t1`.`c139` AS `c139`,`t1`.`c140` AS `c140`,`t1`.`c141` AS `c141`,`t1`.`c142` AS `c142`,`t1`.`c143` AS `c143`,`t1`.`c144` AS `c144`,`t1`.`c145` AS `c145`,`t1`.`c146` AS `c146`,`t1`.`c147` AS `c147`,`t1`.`c148` AS `c148`,`t1`.`c149` AS `c149`,`t1`.`c150` AS `c150`,`t1`.`c151` AS `c151`,`t1`.`c152` AS `c152`,`t1`.`c153` AS `c153`,`t1`.`c154` AS `c154`,`t1`.`c155` AS `c155`,`t1`.`c156` AS `c156`,`t1`.`c157` AS `c157`,`t1`.`c158` AS `c158`,`t1`.`c159` AS `c159`,`t1`.`c160` AS `c160`,`t1`.`c161` AS `c161`,`t1`.`c162` AS `c162`,`t1`.`c163` AS `c163`,`t1`.`c164` AS `c164`,`t1`.`c165` AS `c165`,`t1`.`c166` AS `c166`,`t1`.`c167` AS `c167`,`t1`.`c168` AS `c168`,`t1`.`c169` AS `c169`,`t1`.`c170` AS `c170`,`t1`.`c171` AS `c171`,`t1`.`c172` AS `c172`,`t1`.`c173` AS `c173`,`t1`.`c174` AS `c174`,`t1`.`c175` AS `c175`,`t1`.`c176` AS `c176`,`t1`.`c177` AS `c177`,`t1`.`c178` AS `c178`,`t1`.`c179` AS `c179`,`t1`.`c180` AS `c180`,`t1`.`c181` AS `c181`,`t1`.`c182` AS `c182`,`t1`.`c183` AS `c183`,`t1`.`c184` AS `c184`,`t1`.`c185` AS `c185`,`t1`.`c186` AS `c186`,`t1`.`c187` AS `c187`,`t1`.`c188` AS `c188`,`t1`.`c189` AS `c189`,`t1`.`c190` AS `c190`,`t1`.`c191` AS `c191`,`t1`.`c192` AS `c192`,`t1`.`c193` AS `c193`,`t1`.`c194` AS `c194`,`t1`.`c195` AS `c195`,`t1`.`c196` AS `c196`,`t1`.`c197` AS `c197`,`t1`.`c198` AS `c198`,`t1`.`c199` AS `c199`,`t1`.`c200` AS `c200`,`t1`.`c201` AS `c201`,`t1`.`c202` AS `c202`,`t1`.`c203` AS `c203`,`t1`.`c204` AS `c204`,`t1`.`c205` AS `c205`,`t1`.`c206` AS `c206`,`t1`.`c207` AS `c207`,`t1`.`c208` AS `c208`,`t1`.`c209` AS `c209`,`t1`.`c210` AS `c210`,`t1`.`c211` AS `c211`,`t1`.`c212` AS `c212`,`t1`.`c213` AS `c213`,`t1`.`c214` AS `c214`,`t1`.`c215` AS `c215`,`t1`.`c216` AS `c216`,`t1`.`c217` AS `c217`,`t1`.`c218` AS `c218`,`t1`.`c219` AS `c219`,`t1`.`c220` AS `c220`,`t1`.`c221` AS `c221`,`t1`.`c222` AS `c222`,`t1`.`c223` AS `c223`,`t1`.`c224` AS `c224`,`t1`.`c225` AS `c225`,`t1`.`c226` AS `c226`,`t1`.`c227` AS `c227`,`t1`.`c228` AS `c228`,`t1`.`c229` AS `c229`,`t1`.`c230` AS `c230`,`t1`.`c231` AS `c231`,`t1`.`c232` AS `c232`,`t1`.`c233` AS `c233`,`t1`.`c234` AS `c234`,`t1`.`c235` AS `c235`,`t1`.`c236` AS `c236`,`t1`.`c237` AS `c237`,`t1`.`c238` AS `c238`,`t1`.`c239` AS `c239`,`t1`.`c240` AS `c240`,`t1`.`c241` AS `c241`,`t1`.`c242` AS `c242`,`t1`.`c243` AS `c243`,`t1`.`c244` AS `c244`,`t1`.`c245` AS `c245`,`t1`.`c246` AS `c246`,`t1`.`c247` AS `c247`,`t1`.`c248` AS `c248`,`t1`.`c249` AS `c249`,`t1`.`c250` AS `c250`,`t1`.`c251` AS `c251`,`t1`.`c252` AS `c252`,`t1`.`c253` AS `c253`,`t1`.`c254` AS `c254`,`t1`.`c255` AS `c255`,`t1`.`c256` AS `c256`,`t1`.`c257` AS `c257` from `t1` order by `t1`.`c1`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 1, + "cost": 0.25 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1, + "access_type": "scan", + "resulting_rows": 1, + "cost": 0.35, + "chosen": true, + "use_tmp_table": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "sort_cost": 1, + "new_cost_for_plan": 1.35, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] + } + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`c1`", + "items": [ + { + "item": "`t1`.`c1`" + } + ], + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`c1`" + } + } + }, + { + "finalizing_table_conditions": [ + ] + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] + }, + { + "considering_tmp_tables": [ + { + "adding_sort_to_table": "t1" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "filesort": { + "adding_sort_to_table": "" + } + } + ] + } + } + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +DROP TABLE t1; diff --git a/mysql-test/suite/opt_trace/r/histograms.result-pq b/mysql-test/suite/opt_trace/r/histograms.result-pq new file mode 100644 index 000000000..6eb028ada --- /dev/null +++ b/mysql-test/suite/opt_trace/r/histograms.result-pq @@ -0,0 +1,166 @@ +SET optimizer_trace_max_mem_size = 1000000; +SET optimizer_trace="enabled=on"; +SET @path = "$**.filtering_effect"; +CREATE TABLE t1 (col1 INT, col2 INT); +INSERT INTO t1 VALUES (1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (NULL, NULL); +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +UPDATE mysql.innodb_table_stats SET n_rows = 6 +WHERE database_name = "test" AND table_name = "t1"; +EXPLAIN SELECT * FROM t1 WHERE col1 < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` < 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` < 4)", "histogram_selectivity": 0.5}]] +EXPLAIN SELECT * FROM t1 WHERE col1 > 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` > 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` > 4)", "histogram_selectivity": 0.166667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 >= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` >= 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` >= 4)", "histogram_selectivity": 0.333333}]] +EXPLAIN SELECT * FROM t1 WHERE col1 <= 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` <= 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` <= 4)", "histogram_selectivity": 0.666667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` = 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` = 4)", "histogram_selectivity": 0.166667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 != 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` <> 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` <> 4)", "histogram_selectivity": 0.666667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 <> 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 66.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` <> 4) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` <> 4)", "histogram_selectivity": 0.666667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` between 4 and 6) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` between 4 and 6)", "histogram_selectivity": 0.333333}]] +EXPLAIN SELECT * FROM t1 WHERE col1 NOT BETWEEN 4 AND 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 50.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` not between 4 and 6) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` not between 4 and 6)", "histogram_selectivity": 0.5}]] +EXPLAIN SELECT * FROM t1 WHERE col1 IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` is null) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` is null)", "histogram_selectivity": 0.166667}]] +EXPLAIN SELECT * FROM t1 WHERE col1 IS NOT NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 83.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 83.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` is not null) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` is not null)", "histogram_selectivity": 0.833333}]] +DROP TABLE t1; +# +# Show that histogram selecitivty estimation is printed for other acecss +# methods as well. +# +# Access method: RANGE +CREATE TABLE t1 (col1 INT, col2 INT); +INSERT INTO t1 VALUES (15, 84), (19, 51), (70, 52), (54, 82), (33, 93), (80, 0), +(51, 82), (50, 14), (22, 27), (96, 82), (96, 3), (86, 61), (4, 58), (95, 20), +(28, 56), (64, 99), (10, 85), (30, 81), (13, 85), (28, 94); +CREATE INDEX idx1 ON t1 (col1, col2); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1, col2 WITH 8 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +test.t1 histogram status Histogram statistics created for column 'col2'. +EXPLAIN SELECT * FROM t1 WHERE col1 > 10 AND col2 < 88; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 18 80.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx1 idx1 5 NULL 18 80.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where ((`test`.`t1`.`col1` > 10) and (`test`.`t1`.`col2` < 88)) +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col2` < 88)", "histogram_selectivity": 0.8}]] +DROP TABLE t1; +# +# Show the difference between the calculated selectivity estimation for +# each predicate and the total calculated selectivity estimation +# +CREATE TABLE t1 (col1 INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ANALYZE TABLE t1 UPDATE HISTOGRAM ON col1 WITH 2 BUCKETS; +Table Op Msg_type Msg_text +test.t1 histogram status Histogram statistics created for column 'col1'. +EXPLAIN SELECT * FROM t1 WHERE col1 > 2 AND col1 <= 7; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 8 65.62 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 65.62 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where ((`test`.`t1`.`col1` > 2) and (`test`.`t1`.`col1` <= 7)) +# Selectivity estimations for each conditions. +SELECT JSON_EXTRACT(trace, @path) FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, @path) +[[{"condition": "(`t1`.`col1` > 2)", "histogram_selectivity": 0.75}, {"condition": "(`t1`.`col1` <= 7)", "histogram_selectivity": 0.875}]] +# Total calculated selectivity estimation. +SELECT JSON_EXTRACT(trace, "$**.final_filtering_effect") +FROM information_schema.OPTIMIZER_TRACE; +JSON_EXTRACT(trace, "$**.final_filtering_effect") +[0.65625] +DROP TABLE t1; diff --git a/mysql-test/suite/opt_trace/r/opt_hints_index_merge.result-pq b/mysql-test/suite/opt_trace/r/opt_hints_index_merge.result-pq new file mode 100644 index 000000000..74f9de2c1 --- /dev/null +++ b/mysql-test/suite/opt_trace/r/opt_hints_index_merge.result-pq @@ -0,0 +1,1362 @@ +CREATE TABLE t1 (f1 INT, f2 INT, f3 CHAR(1), f4 CHAR(1), f5 CHAR(1), f6 CHAR(1), +PRIMARY KEY (f5, f1), KEY (f2), KEY (f3), KEY (f4)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 'a', 'h', 'i', ''), (2, 3, 'a', 'h', 'i', ''), (3, 2, 'b', '', 'j', ''), (4, 2, 'b', '', 'j', ''); +INSERT INTO t1 VALUES (5, 1, 'a', 'h', 'i', ''), (6, 3, 'a', 'h', 'i', ''), (7, 2, 'b', '', 'j', ''), (8, 2, 'b', '', 'j', ''); +INSERT INTO t1 SELECT f1 + 8, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 SELECT f1 + 16, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 VALUES (33, 3, 'c', 'g', '', ''), (34, 4, 'c', 'g', '', ''), (35, 5, 'd', 'f', '', ''), (36, 6, 'd', 'f', '', ''); +INSERT INTO t1 SELECT f1 + 36, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 SELECT f1 + 72, f2, f3, f4, f5, f6 FROM t1; +INSERT INTO t1 SELECT f1 + 144, f2, f3, f4, f5, f6 FROM t1; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +SET optimizer_switch='index_merge_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 288 53.12 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL f2,f3,f4 NULL NULL NULL 288 53.12 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `test`.`t1`.`f1` AS `f1` from `test`.`t1` where ((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'c') or (`test`.`t1`.`f4` = 'f')) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3) */ f1 FROM t1 WHERE f2 = 5 OR f3 = 'c' OR f4 = 'f' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`) */ `t1`.`f1` AS `f1` from `t1` where ((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`f2`) or multiple equal('c', `t1`.`f3`) or multiple equal('f', `t1`.`f4`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(5, `t1`.`f2`) or multiple equal('c', `t1`.`f3`) or multiple equal('f', `t1`.`f4`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(5, `t1`.`f2`) or multiple equal('c', `t1`.`f3`) or multiple equal('f', `t1`.`f4`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 8, + "cost": 1.06277, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 1.06277 + }, + { + "range_scan_alternatives": [ + { + "index": "f3", + "ranges": [ + "c <= f3 <= c" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 16, + "cost": 1.86594, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f3", + "cumulated_cost": 2.92872 + }, + { + "range_scan_alternatives": [ + { + "index": "f4", + "chosen": false, + "cause": "index_merge_hint" + } + ] /* range_scan_alternatives */, + "chosen": false, + "cause": "cost" + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 2.92872, + "chosen": false, + "cause": "cost" + } + ] /* analyzing_index_merge_union */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 288, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.53125, + "access_type": "scan", + "resulting_rows": 153, + "cost": 29.05, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 153, + "cost_for_plan": 29.05, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))", + "final_table_condition ": "((`t1`.`f2` = 5) or (`t1`.`f3` = 'c') or (`t1`.`f4` = 'f'))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET optimizer_switch='index_merge=on,index_merge_intersection=on'; +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 128 19.75 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref f2,f3,f4 f2 5 const 128 19.75 Using where +Warnings: +Note 1003 /* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`f3` = 'b') and (`test`.`t1`.`f2` = 2) and (`test`.`t1`.`f4` = 'h')) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ NO_INDEX_MERGE(t1 f3) */ COUNT(*) FROM t1 WHERE f4 = 'h' AND f2 = 2 AND f3 = 'b' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ NO_INDEX_MERGE(`t1`@`select#1` `f3`) */ count(0) AS `COUNT(*)` from `t1` where ((`t1`.`f4` = 'h') and (`t1`.`f2` = 2) and (`t1`.`f3` = 'b'))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`f4` = 'h') and (`t1`.`f2` = 2) and (`t1`.`f3` = 'b'))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal('h', `t1`.`f4`) and multiple equal(2, `t1`.`f2`) and multiple equal('b', `t1`.`f3`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal('h', `t1`.`f4`) and multiple equal(2, `t1`.`f2`) and multiple equal('b', `t1`.`f3`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal('h', `t1`.`f4`) and multiple equal(2, `t1`.`f2`) and multiple equal('b', `t1`.`f3`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "f2", + "equals": "2", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "f3", + "equals": "'b'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "f4", + "equals": "'h'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "2 <= f2 <= 2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 128, + "cost": 45.06, + "chosen": false, + "cause": "cost" + }, + { + "index": "f3", + "chosen": false, + "cause": "index_merge_hint" + }, + { + "index": "f4", + "ranges": [ + "h <= f4 <= h" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 128, + "cost": 45.06, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "f2", + "index_scan_cost": 0.300317, + "cumulated_index_scan_cost": 0.300317, + "disk_sweep_cost": 1, + "cumulated_total_cost": 1.30032, + "usable": true, + "matching_rows_now": 128, + "isect_covering_with_this_index": false, + "chosen": true + }, + { + "index": "f4", + "index_scan_cost": 0.300317, + "cumulated_index_scan_cost": 0.600634, + "disk_sweep_cost": 1, + "cumulated_total_cost": 1.60063, + "usable": true, + "matching_rows_now": 56.8889, + "isect_covering_with_this_index": false, + "chosen": false, + "cause": "does_not_reduce_cost" + } + ] /* intersecting_indexes */, + "clustered_pk": { + "clustered_pk_added_to_intersect": false, + "cause": "no_clustered_pk_index" + } /* clustered_pk */, + "chosen": false, + "cause": "too_few_indexes_to_merge" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "f2", + "rows": 128, + "cost": 13.55, + "chosen": true + }, + { + "access_type": "ref", + "index": "f3", + "rows": 128, + "cost": 13.55, + "chosen": false + }, + { + "access_type": "ref", + "index": "f4", + "rows": 128, + "cost": 13.55, + "chosen": false + }, + { + "rows_to_scan": 288, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.0877915, + "access_type": "scan", + "resulting_rows": 25.284, + "cost": 29.05, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 19.7531, + "rows_for_plan": 25.284, + "cost_for_plan": 13.55, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`f3` = 'b') and (`t1`.`f2` = 2) and (`t1`.`f4` = 'h'))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`f3` = 'b') and (`t1`.`f2` = 2) and (`t1`.`f4` = 'h'))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`f3` = 'b') and (`t1`.`f2` = 2) and (`t1`.`f4` = 'h'))", + "final_table_condition ": "((`t1`.`f3` = 'b') and (`t1`.`f4` = 'h'))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET optimizer_switch='index_merge_union=off,index_merge=off'; +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 300 AND 310 OR f4 = 'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f4 5,5 NULL 2 100.00 Using sort_union(f2,f4); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'b')) and ((`test`.`t1`.`f2` between 300 and 310) or (`test`.`t1`.`f4` = 'b'))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 300 AND 310 OR f4 = 'b') { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `t1`.`f1` AS `f1`,`t1`.`f2` AS `f2`,`t1`.`f3` AS `f3`,`t1`.`f4` AS `f4`,`t1`.`f5` AS `f5`,`t1`.`f6` AS `f6` from `t1` where (((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 300 and 310) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 300 and 310) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 300 and 310) or multiple equal('b', `t1`.`f4`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 8, + "cost": 1.06277, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 1.06277 + }, + { + "range_scan_alternatives": [ + { + "index": "f3", + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 128, + "cost": 13.1103, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f3", + "cumulated_cost": 14.1731 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 14.1731, + "use_roworder_union": true, + "cause": "always_cheaper_than_not_roworder_retrieval", + "analyzing_roworder_scans": [ + { + "type": "range_scan", + "index": "f2", + "rows": 8, + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + }, + { + "type": "range_scan", + "index": "f3", + "rows": 128, + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } + ] /* analyzing_roworder_scans */, + "index_roworder_union_cost": 21.9731, + "members": 2, + "chosen": true + }, + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "300 <= f2 <= 310" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 0.36 + }, + { + "range_scan_alternatives": [ + { + "index": "f4", + "ranges": [ + "b <= f4 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f4", + "cumulated_cost": 0.72 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 0.72, + "cost_sort_rowid_and_read_disk": 0.4375, + "cost_duplicate_removal": 0.254503, + "total_cost": 1.412 + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_merge", + "index_merge_of": [ + { + "type": "range_scan", + "index": "f2", + "rows": 1, + "ranges": [ + "300 <= f2 <= 310" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "f4", + "rows": 1, + "ranges": [ + "b <= f4 <= b" + ] /* ranges */ + } + ] /* index_merge_of */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.412, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "sort_union(f2,f4)" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.612, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.612, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))", + "final_table_condition ": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 300 and 310) or (`t1`.`f4` = 'b')))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 1 AND 10 OR f4 = 'b'); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge f2,f3,f4 f2,f3 5,5 NULL 136 100.00 Using union(f2,f3); Using where +Warnings: +Note 1003 /* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t1`.`f3` AS `f3`,`test`.`t1`.`f4` AS `f4`,`test`.`t1`.`f5` AS `f5`,`test`.`t1`.`f6` AS `f6` from `test`.`t1` where (((`test`.`t1`.`f2` = 5) or (`test`.`t1`.`f3` = 'b')) and ((`test`.`t1`.`f2` between 1 and 10) or (`test`.`t1`.`f4` = 'b'))) +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT /*+ INDEX_MERGE(t1 f2, f3, f4) */ * FROM t1 WHERE (f2 = 5 OR f3 = 'b') AND (f2 BETWEEN 1 AND 10 OR f4 = 'b') { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select /*+ INDEX_MERGE(`t1`@`select#1` `f2`, `f3`, `f4`) */ `t1`.`f1` AS `f1`,`t1`.`f2` AS `f2`,`t1`.`f3` AS `f3`,`t1`.`f4` AS `f4`,`t1`.`f5` AS `f5`,`t1`.`f6` AS `f6` from `t1` where (((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 1 and 10) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 1 and 10) or multiple equal('b', `t1`.`f4`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(5, `t1`.`f2`) or multiple equal('b', `t1`.`f3`)) and ((`t1`.`f2` between 1 and 10) or multiple equal('b', `t1`.`f4`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 288, + "cost": 31.15 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "f2", + "usable": true, + "key_parts": [ + "f2", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f3", + "usable": true, + "key_parts": [ + "f3", + "f5", + "f1" + ] /* key_parts */ + }, + { + "index": "f4", + "usable": true, + "key_parts": [ + "f4", + "f5", + "f1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "f2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "f4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 8, + "cost": 1.06277, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 1.06277 + }, + { + "range_scan_alternatives": [ + { + "index": "f3", + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 128, + "cost": 13.1103, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f3", + "cumulated_cost": 14.1731 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 14.1731, + "use_roworder_union": true, + "cause": "always_cheaper_than_not_roworder_retrieval", + "analyzing_roworder_scans": [ + { + "type": "range_scan", + "index": "f2", + "rows": 8, + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + }, + { + "type": "range_scan", + "index": "f3", + "rows": 128, + "ranges": [ + "b <= f3 <= b" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } + ] /* analyzing_roworder_scans */, + "index_roworder_union_cost": 21.9731, + "members": 2, + "chosen": true + }, + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "f2", + "ranges": [ + "1 <= f2 <= 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 288, + "cost": 29.1737, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f2", + "cumulated_cost": 29.1737 + }, + { + "range_scan_alternatives": [ + { + "index": "f4", + "ranges": [ + "b <= f4 <= b" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "f4", + "cumulated_cost": 29.5337 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 29.5337, + "cost_sort_rowid_and_read_disk": 1, + "cost_duplicate_removal": 195.921, + "total_cost": 226.454 + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_union", + "union_of": [ + { + "type": "range_scan", + "index": "f2", + "rows": 8, + "ranges": [ + "5 <= f2 <= 5" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "f3", + "rows": 128, + "ranges": [ + "b <= f3 <= b" + ] /* ranges */ + } + ] /* union_of */ + } /* range_access_plan */, + "rows_for_plan": 136, + "cost_for_plan": 21.9731, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 136, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "union(f2,f3)" + } /* range_details */, + "resulting_rows": 136, + "cost": 35.5731, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 136, + "cost_for_plan": 35.5731, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))", + "final_table_condition ": "(((`t1`.`f2` = 5) or (`t1`.`f3` = 'b')) and ((`t1`.`f2` between 1 and 10) or (`t1`.`f4` = 'b')))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +SET optimizer_switch=default; +DROP TABLE t1; diff --git a/mysql-test/suite/opt_trace/r/range_no_prot.result-pq b/mysql-test/suite/opt_trace/r/range_no_prot.result-pq new file mode 100644 index 000000000..259102a9c --- /dev/null +++ b/mysql-test/suite/opt_trace/r/range_no_prot.result-pq @@ -0,0 +1,7444 @@ +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 +( +key1 INT NOT NULL, +INDEX i1(key1) +); +Inserting 1024 records into t1 +ALTER TABLE t1 ADD key2 INT NOT NULL, ADD INDEX i2(key2); +ALTER TABLE t1 ADD key3 INT NOT NULL, ADD INDEX i3(key3); +ALTER TABLE t1 ADD key4 INT NOT NULL, ADD INDEX i4(key4); +ALTER TABLE t1 ADD key5 INT NOT NULL, ADD INDEX i5(key5); +ALTER TABLE t1 ADD key6 INT NOT NULL, ADD INDEX i6(key6); +ALTER TABLE t1 ADD key7 INT NOT NULL, ADD INDEX i7(key7); +ALTER TABLE t1 ADD key8 INT NOT NULL, ADD INDEX i8(key8); +UPDATE t1 SET +key2=key1, +key3=key1, +key4=key1, +key5=key1, +key6=key1, +key7=key1, +key8=1024-key1; +CREATE TABLE t2 ( +key1a INT NOT NULL, +key1b INT NOT NULL, +key2 INT NOT NULL, +key2_1 INT NOT NULL, +key2_2 INT NOT NULL, +key3 INT NOT NULL, +primary key i1a (key1a, key1b), +INDEX i1b (key1b, key1a), +INDEX i2_1(key2, key2_1), +INDEX i2_2(key2, key2_1) +); +Warnings: +Warning 1831 Duplicate index 'i2_2' defined on the table 'test.t2'. This is deprecated and will be disallowed in a future release. +INSERT INTO t2 SELECT key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 FROM t1; + +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i2 i2 4 NULL 47 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` < 5) or (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "key2 < 5", + "1020 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 47, + "cost": 16.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2", + "rows": 47, + "ranges": [ + "key2 < 5", + "1020 < key2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 47, + "cost_for_plan": 16.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 47, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2" + } /* range_details */, + "resulting_rows": 47, + "cost": 21.66, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 47, + "cost_for_plan": 21.66, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "final_table_condition ": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +set @@optimizer_trace_features="range_optimizer=off"; + +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i2 i2 4 NULL 47 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` < 5) or (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key2 < 5 OR key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": "...", + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": "...", + "skip_scan_range": "...", + "analyzing_range_alternatives": "...", + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2", + "rows": 47, + "ranges": [ + "key2 < 5", + "1020 < key2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 47, + "cost_for_plan": 16.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 47, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2" + } /* range_details */, + "resulting_rows": 47, + "cost": 21.66, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 47, + "cost_for_plan": 21.66, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "final_table_condition ": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "((`t1`.`key2` < 5) or (`t1`.`key2` > 1020))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +set @@optimizer_trace_features="range_optimizer=on"; + +EXPLAIN SELECT * FROM t1 WHERE key1 < 3 OR key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL 45 100.00 Using sort_union(i1,i2); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` < 3) or (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key1 < 3 OR key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": true, + "key_parts": [ + "key1" + ] /* key_parts */ + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "i1", + "ranges": [ + "key1 < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.57, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i1", + "cumulated_cost": 0.57 + }, + { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "1020 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 42, + "cost": 4.68, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i2", + "cumulated_cost": 5.25 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 5.25, + "cost_sort_rowid_and_read_disk": 2.24, + "cost_duplicate_removal": 19.18, + "total_cost": 26.67 + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_merge", + "index_merge_of": [ + { + "type": "range_scan", + "index": "i1", + "rows": 3, + "ranges": [ + "key1 < 3" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "i2", + "rows": 42, + "ranges": [ + "1020 < key2" + ] /* ranges */ + } + ] /* index_merge_of */ + } /* range_access_plan */, + "rows_for_plan": 45, + "cost_for_plan": 26.67, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 45, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "sort_union(i1,i2)" + } /* range_details */, + "resulting_rows": 45, + "cost": 31.17, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 45, + "cost_for_plan": 31.17, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))", + "final_table_condition ": "((`t1`.`key1` < 3) or (`t1`.`key2` > 1020))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 GROUP BY key2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range i2_1,i2_2 i2_1 4 NULL 103 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key2` AS `key2`,min(`test`.`t2`.`key2_1`) AS `MIN(key2_1)` from `test`.`t2` group by `test`.`t2`.`key2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 GROUP BY key2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key2` AS `key2`,min(`t2`.`key2_1`) AS `MIN(key2_1)` from `t2` group by `t2`.`key2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "const_keys_added": { + "keys": [ + "i2_1", + "i2_2" + ] /* keys */, + "cause": "group_by" + } /* const_keys_added */, + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "i2_1", + "cost": 109.96, + "chosen": false, + "cause": "cost" + } /* best_covering_index_scan */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "i2_1", + "covering": true, + "rows": 103, + "cost": 28.1 + }, + { + "index": "i2_2", + "covering": true, + "rows": 103, + "cost": 28.1 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "i2_1", + "group_attribute": "key2_1", + "min_aggregate": true, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_group", + "index": "i2_1", + "group_attribute": "key2_1", + "min_aggregate": true, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 103, + "cost_for_plan": 28.1, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 103, + "access_type": "range", + "range_details": { + "used_index": "index_for_group_by(i2_1)" + } /* range_details */, + "resulting_rows": 103, + "cost": 38.4, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 103, + "cost_for_plan": 38.4, + "sort_cost": 103, + "new_cost_for_plan": 141.4, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t2`.`key2`", + "items": [ + { + "item": "`t2`.`key2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t2`.`key2`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t2`", + "index_provides_order": true, + "order_direction": "asc", + "index": "i2_1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +EXPLAIN SELECT DISTINCT key2 FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range i2_1,i2_2 i2_1 4 NULL 103 100.00 Using index for group-by +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t2`.`key2` AS `key2` from `test`.`t2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT DISTINCT key2 FROM t2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select distinct `t2`.`key2` AS `key2` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "const_keys_added": { + "keys": [ + "i2_1", + "i2_2" + ] /* keys */, + "cause": "distinct" + } /* const_keys_added */, + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "i2_1", + "cost": 109.96, + "chosen": false, + "cause": "cost" + } /* best_covering_index_scan */, + "group_index_range": { + "distinct_query": true, + "potential_group_range_indexes": [ + { + "index": "i2_1", + "covering": true, + "rows": 103, + "cost": 28.1 + }, + { + "index": "i2_2", + "covering": true, + "rows": 103, + "cost": 28.1 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "i2_1", + "group_attribute": null, + "min_aggregate": false, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "disjuntive_predicate_present" + } /* skip_scan_range */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_group", + "index": "i2_1", + "group_attribute": null, + "min_aggregate": false, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 103, + "cost": 28.1, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 103, + "cost_for_plan": 28.1, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 103, + "access_type": "range", + "range_details": { + "used_index": "index_for_group_by(i2_1)" + } /* range_details */, + "resulting_rows": 103, + "cost": 38.4, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 103, + "cost_for_plan": 38.4, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "changed_distinct_to_group_by": true, + "simplifying_group_by": { + "original_clause": "`t2`.`key2`", + "items": [ + { + "item": "`t2`.`key2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t2`.`key2`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t2`", + "index_provides_order": true, + "order_direction": "asc", + "index": "i2_1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 +WHERE key2 = 5 or key2 = 4 or key2 = 3 or key2 = 2 or key2 = 1 +GROUP BY key2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range i2_1,i2_2 i2_1 4 NULL 47 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key2` AS `key2`,min(`test`.`t2`.`key2_1`) AS `MIN(key2_1)` from `test`.`t2` where ((`test`.`t2`.`key2` = 5) or (`test`.`t2`.`key2` = 4) or (`test`.`t2`.`key2` = 3) or (`test`.`t2`.`key2` = 2) or (`test`.`t2`.`key2` = 1)) group by `test`.`t2`.`key2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT key2, MIN(key2_1) FROM t2 +WHERE key2 = 5 or key2 = 4 or key2 = 3 or key2 = 2 or key2 = 1 +GROUP BY key2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key2` AS `key2`,min(`t2`.`key2_1`) AS `MIN(key2_1)` from `t2` where ((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1)) group by `t2`.`key2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(5, `t2`.`key2`) or multiple equal(4, `t2`.`key2`) or multiple equal(3, `t2`.`key2`) or multiple equal(2, `t2`.`key2`) or multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(5, `t2`.`key2`) or multiple equal(4, `t2`.`key2`) or multiple equal(3, `t2`.`key2`) or multiple equal(2, `t2`.`key2`) or multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(5, `t2`.`key2`) or multiple equal(4, `t2`.`key2`) or multiple equal(3, `t2`.`key2`) or multiple equal(2, `t2`.`key2`) or multiple equal(1, `t2`.`key2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "i2_1", + "cost": 109.96, + "chosen": false, + "cause": "cost" + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "i2_1", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "rows": 5, + "cost": 8.5 + }, + { + "index": "i2_2", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "rows": 5, + "cost": 8.5 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "i2_1", + "group_attribute": "key2_1", + "min_aggregate": true, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 5, + "cost": 8.5, + "key_parts_used_for_access": [ + "key2" + ] /* key_parts_used_for_access */, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2_1", + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 47, + "cost": 5.29, + "chosen": true + }, + { + "index": "i2_2", + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 47, + "cost": 5.29, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2_1", + "rows": 47, + "ranges": [ + "1 <= key2 <= 1", + "2 <= key2 <= 2", + "3 <= key2 <= 3", + "4 <= key2 <= 4", + "5 <= key2 <= 5" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 47, + "cost_for_plan": 5.29, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 47, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2_1" + } /* range_details */, + "resulting_rows": 47, + "cost": 9.99, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 47, + "cost_for_plan": 9.99, + "sort_cost": 47, + "new_cost_for_plan": 56.99, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t2`.`key2`", + "items": [ + { + "item": "`t2`.`key2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t2`.`key2`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t2`", + "index_provides_order": true, + "order_direction": "asc", + "index": "i2_1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))", + "final_table_condition ": "((`t2`.`key2` = 5) or (`t2`.`key2` = 4) or (`t2`.`key2` = 3) or (`t2`.`key2` = 2) or (`t2`.`key2` = 1))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE key2 = 1 AND (key2_1 = 1 OR key3 = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ref i2_1,i2_2 i2_1 4 const 10 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key2` = 1) and ((`test`.`t2`.`key2_1` = 1) or (`test`.`t2`.`key3` = 5))) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE key2 = 1 AND (key2_1 = 1 OR key3 = 5) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((multiple equal(1, `t2`.`key2_1`) or multiple equal(5, `t2`.`key3`)) and multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((multiple equal(1, `t2`.`key2_1`) or multiple equal(5, `t2`.`key3`)) and multiple equal(1, `t2`.`key2`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((multiple equal(1, `t2`.`key2_1`) or multiple equal(5, `t2`.`key3`)) and multiple equal(1, `t2`.`key2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t2`", + "field": "key2", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t2`", + "field": "key2", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i2_1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i2_2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2_1", + "ranges": [ + "1 <= key2 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 10, + "cost": 3.76, + "chosen": true + }, + { + "index": "i2_2", + "ranges": [ + "1 <= key2 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 10, + "cost": 3.76, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2_1", + "rows": 10, + "ranges": [ + "1 <= key2 <= 1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 10, + "cost_for_plan": 3.76, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i2_1", + "rows": 10, + "cost": 3.5, + "chosen": true + }, + { + "access_type": "ref", + "index": "i2_2", + "rows": 10, + "cost": 3.5, + "chosen": false + }, + { + "access_type": "range", + "range_details": { + "used_index": "i2_1" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 19, + "rows_for_plan": 1.9, + "cost_for_plan": 3.5, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key2` = 1) and ((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5)))", + "final_table_condition ": "((`t2`.`key2_1` = 1) or (`t2`.`key3` = 5))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge i2,i3,i4 i2,i3 4,4 NULL 2 100.00 Using union(i2,i3); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) or (`test`.`t1`.`key3` = 3) or (`test`.`t1`.`key4` <=> NULL)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(10, `t1`.`key2`) or multiple equal(3, `t1`.`key3`) or (`t1`.`key4` <=> NULL))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(10, `t1`.`key2`) or multiple equal(3, `t1`.`key3`) or (`t1`.`key4` <=> NULL))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(10, `t1`.`key2`) or multiple equal(3, `t1`.`key3`) or (`t1`.`key4` <=> NULL))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": true, + "key_parts": [ + "key3" + ] /* key_parts */ + }, + { + "index": "i4", + "usable": true, + "key_parts": [ + "key4" + ] /* key_parts */ + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "null_field_in_non_null_column" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i3", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i4", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "10 <= key2 <= 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i2", + "cumulated_cost": 0.36 + }, + { + "range_scan_alternatives": [ + { + "index": "i3", + "ranges": [ + "3 <= key3 <= 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "index_to_merge": "i3", + "cumulated_cost": 0.72 + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 0.72, + "use_roworder_union": true, + "cause": "always_cheaper_than_not_roworder_retrieval", + "analyzing_roworder_scans": [ + { + "type": "range_scan", + "index": "i2", + "rows": 1, + "ranges": [ + "10 <= key2 <= 10" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + }, + { + "type": "range_scan", + "index": "i3", + "rows": 1, + "ranges": [ + "3 <= key3 <= 3" + ] /* ranges */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } + ] /* analyzing_roworder_scans */, + "index_roworder_union_cost": 1.29, + "members": 2, + "chosen": true + } + ] /* analyzing_index_merge_union */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_union", + "union_of": [ + { + "type": "range_scan", + "index": "i2", + "rows": 1, + "ranges": [ + "10 <= key2 <= 10" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "i3", + "rows": 1, + "ranges": [ + "3 <= key3 <= 3" + ] /* ranges */ + } + ] /* union_of */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.29, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "union(i2,i3)" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.49, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.49, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))", + "final_table_condition ": "((`t1`.`key2` = 10) or (`t1`.`key3` = 3) or (`t1`.`key4` <=> NULL))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE key2_1 < 79 OR key2 = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL i2_1,i2_2 NULL NULL NULL 1024 33.98 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key2_1` < 79) or (`test`.`t2`.`key2` = 2)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE key2_1 < 79 OR key2 = 2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`key2_1` < 79) or multiple equal(2, `t2`.`key2`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`key2_1` < 79) or multiple equal(2, `t2`.`key2`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t2`.`key2_1` < 79) or multiple equal(2, `t2`.`key2`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i1b", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_1", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + }, + { + "index": "i2_2", + "usable": true, + "key_parts": [ + "key2", + "key2_1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "range_scan_possible": false, + "cause": "condition_always_true", + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "disjuntive_predicate_present" + } /* skip_scan_range */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1024, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.34, + "access_type": "scan", + "resulting_rows": 347.97, + "cost": 104.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 347.97, + "cost_for_plan": 104.46, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))", + "final_table_condition ": "((`t2`.`key2_1` < 79) or (`t2`.`key2` = 2))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE key1a = 5 and key1b < 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY,i1b PRIMARY 8 NULL 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1a` = 5) and (`test`.`t2`.`key1b` < 10)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE key1a = 5 and key1b < 10 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and multiple equal(5, `t2`.`key1a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and multiple equal(5, `t2`.`key1a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t2`.`key1b` < 10) and multiple equal(5, `t2`.`key1a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t2`", + "field": "key1a", + "equals": "5", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "key1a", + "key1b" + ] /* key_parts */ + }, + { + "index": "i1b", + "usable": true, + "key_parts": [ + "key1b", + "key1a" + ] /* key_parts */ + }, + { + "index": "i2_1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_2", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "5 <= key1a <= 5 AND key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "i1b", + "ranges": [ + "key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 9, + "cost": 3.41, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 1, + "ranges": [ + "5 <= key1a <= 5 AND key1b < 10" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 10, + "cost": 3.5, + "chosen": true + }, + { + "rows_to_scan": 1, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 1, + "cost": 0.71, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.71, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "final_table_condition ": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`", + "pushed_index_condition": "((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE (key1a = 5 and key1b < 10 and key1b > 2) or +(key1a = 4 and key1b < 7 and key1b > 3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY,i1b PRIMARY 8 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where (((`test`.`t2`.`key1a` = 5) and (`test`.`t2`.`key1b` < 10) and (`test`.`t2`.`key1b` > 2)) or ((`test`.`t2`.`key1a` = 4) and (`test`.`t2`.`key1b` < 7) and (`test`.`t2`.`key1b` > 3))) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE (key1a = 5 and key1b < 10 and key1b > 2) or +(key1a = 4 and key1b < 7 and key1b > 3) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where (((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(((`t2`.`key1b` < 10) and (`t2`.`key1b` > 2) and multiple equal(5, `t2`.`key1a`)) or ((`t2`.`key1b` < 7) and (`t2`.`key1b` > 3) and multiple equal(4, `t2`.`key1a`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(((`t2`.`key1b` < 10) and (`t2`.`key1b` > 2) and multiple equal(5, `t2`.`key1a`)) or ((`t2`.`key1b` < 7) and (`t2`.`key1b` > 3) and multiple equal(4, `t2`.`key1a`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(((`t2`.`key1b` < 10) and (`t2`.`key1b` > 2) and multiple equal(5, `t2`.`key1a`)) or ((`t2`.`key1b` < 7) and (`t2`.`key1b` > 3) and multiple equal(4, `t2`.`key1a`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "key1a", + "key1b" + ] /* key_parts */ + }, + { + "index": "i1b", + "usable": true, + "key_parts": [ + "key1b", + "key1a" + ] /* key_parts */ + }, + { + "index": "i2_1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_2", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "4 <= key1a <= 4 AND 3 < key1b < 7", + "5 <= key1a <= 5 AND 2 < key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 1.21, + "chosen": true + }, + { + "index": "i1b", + "ranges": [ + "2 < key1b <= 3", + "3 < key1b < 7", + "7 <= key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 6, + "cost": 2.86, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 2, + "ranges": [ + "4 <= key1a <= 4 AND 3 < key1b < 7", + "5 <= key1a <= 5 AND 2 < key1b < 10" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.21, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.41, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.41, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "final_table_condition ": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`", + "pushed_index_condition": "(((`t2`.`key1a` = 5) and (`t2`.`key1b` < 10) and (`t2`.`key1b` > 2)) or ((`t2`.`key1a` = 4) and (`t2`.`key1b` < 7) and (`t2`.`key1b` > 3)))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t2 WHERE (key1b < 10 and key1b > 7) and +(key1a = 4 or key1a = 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL range PRIMARY,i1b i1b 4 NULL 2 19.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t2` where ((`test`.`t2`.`key1b` < 10) and (`test`.`t2`.`key1b` > 7) and ((`test`.`t2`.`key1a` = 4) or (`test`.`t2`.`key1a` = 5))) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t2 WHERE (key1b < 10 and key1b > 7) and +(key1a = 4 or key1a = 5) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t2` where ((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and (multiple equal(4, `t2`.`key1a`) or multiple equal(5, `t2`.`key1a`)))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and (multiple equal(4, `t2`.`key1a`) or multiple equal(5, `t2`.`key1a`)))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and (multiple equal(4, `t2`.`key1a`) or multiple equal(5, `t2`.`key1a`)))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 106.56 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "key1a", + "key1b" + ] /* key_parts */ + }, + { + "index": "i1b", + "usable": true, + "key_parts": [ + "key1b", + "key1a" + ] /* key_parts */ + }, + { + "index": "i2_1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2_2", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "4 <= key1a <= 4 AND 7 < key1b < 10", + "5 <= key1a <= 5 AND 7 < key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 1.21, + "chosen": true + }, + { + "index": "i1b", + "ranges": [ + "7 < key1b < 10" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i1b", + "rows": 2, + "ranges": [ + "7 < key1b < 10" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.19, + "access_type": "range", + "range_details": { + "used_index": "i1b" + } /* range_details */, + "resulting_rows": 0.38, + "cost": 1.16, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 0.38, + "cost_for_plan": 1.16, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "final_table_condition ": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`", + "pushed_index_condition": "((`t2`.`key1b` < 10) and (`t2`.`key1b` > 7) and ((`t2`.`key1a` = 4) or (`t2`.`key1a` = 5)))", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t1 WHERE (key1 > 1 OR key2 > 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL i1,i2 NULL NULL NULL 1024 55.55 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` > 1) or (`test`.`t1`.`key2` > 2)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE (key1 > 1 OR key2 > 2) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8` from `t1` where ((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": true, + "key_parts": [ + "key1" + ] /* key_parts */ + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "analyzing_index_merge_union": [ + { + "indexes_to_merge": [ + { + "range_scan_alternatives": [ + { + "index": "i1", + "ranges": [ + "1 < key1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1023, + "cost": 108, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "chosen": false, + "cause": "cost" + }, + { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "2 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 1022, + "cost": 107.89, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "chosen": false, + "cause": "cost" + } + ] /* indexes_to_merge */, + "cost_of_reading_ranges": 0, + "chosen": false, + "cause": "cost" + } + ] /* analyzing_index_merge_union */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 1024, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.56, + "access_type": "scan", + "resulting_rows": 568.84, + "cost": 104.96, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 568.84, + "cost_for_plan": 104.96, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))", + "final_table_condition ": "((`t1`.`key1` > 1) or (`t1`.`key2` > 2))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1, t2 +WHERE t1.key1=t2.key1a AND t1.key2 > 1020; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range i1,i2 i2 4 NULL 42 100.00 Using index condition +1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.key1 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8`,`test`.`t2`.`key1a` AS `key1a`,`test`.`t2`.`key1b` AS `key1b`,`test`.`t2`.`key2` AS `key2`,`test`.`t2`.`key2_1` AS `key2_1`,`test`.`t2`.`key2_2` AS `key2_2`,`test`.`t2`.`key3` AS `key3` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`key1a` = `test`.`t1`.`key1`) and (`test`.`t1`.`key2` > 1020)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1, t2 +WHERE t1.key1=t2.key1a AND t1.key2 > 1020 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select straight_join `t1`.`key1` AS `key1`,`t1`.`key2` AS `key2`,`t1`.`key3` AS `key3`,`t1`.`key4` AS `key4`,`t1`.`key5` AS `key5`,`t1`.`key6` AS `key6`,`t1`.`key7` AS `key7`,`t1`.`key8` AS `key8`,`t2`.`key1a` AS `key1a`,`t2`.`key1b` AS `key1b`,`t2`.`key2` AS `key2`,`t2`.`key2_1` AS `key2_1`,`t2`.`key2_2` AS `key2_2`,`t2`.`key3` AS `key3` from `t1` join `t2` where ((`t1`.`key1` = `t2`.`key1a`) and (`t1`.`key2` > 1020))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`key1` = `t2`.`key1a`) and (`t1`.`key2` > 1020))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`key2` > 1020) and multiple equal(`t1`.`key1`, `t2`.`key1a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`key2` > 1020) and multiple equal(`t1`.`key1`, `t2`.`key1a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`key2` > 1020) and multiple equal(`t1`.`key1`, `t2`.`key1a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + 0 + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "key1", + "equals": "`t2`.`key1a`", + "null_rejecting": true + }, + { + "table": "`t2`", + "field": "key1a", + "equals": "`t1`.`key1`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 1024, + "cost": 107.06 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "i1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i2", + "usable": true, + "key_parts": [ + "key2" + ] /* key_parts */ + }, + { + "index": "i3", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i4", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i5", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i6", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i7", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i8", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i2", + "ranges": [ + "1020 < key2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 42, + "cost": 14.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i2", + "rows": 42, + "ranges": [ + "1020 < key2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 42, + "cost_for_plan": 14.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + }, + { + "table": "`t2`", + "table_scan": { + "rows": 1024, + "cost": 2.06 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i1", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 42, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "i2" + } /* range_details */, + "resulting_rows": 42, + "cost": 19.16, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 42, + "cost_for_plan": 19.16 + }, + { + "plan_prefix": [ + "`t1`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 10, + "cost": 147, + "chosen": true + }, + { + "rows_to_scan": 1024, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 1024, + "cost": 4302.87, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 420, + "cost_for_plan": 166.16 + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t2`.`key1a` = `t1`.`key1`) and (`t1`.`key2` > 1020))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`key2` > 1020)" + }, + { + "table": "`t2`", + "attached": "(`t2`.`key1a` = `t1`.`key1`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`key2` > 1020)", + "final_table_condition ": "(`t1`.`key2` > 1020)" + }, + { + "table": "`t2`", + "original_table_condition": "(`t2`.`key1a` = `t1`.`key1`)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "(`t1`.`key2` > 1020)", + "table_condition_attached": null + }, + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1,t2; +CREATE TABLE t1 ( +cola char(3) not null, +colb char(3) not null, +filler char(200), +key(cola), +key(colb) +) CHARSET utf8mb4; +INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ'); +Inserting records + +EXPLAIN SELECT * FROM t1 WHERE cola = 'foo' AND colb = 'bar'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge cola,colb cola,colb 12,12 NULL 29 100.00 Using intersect(cola,colb); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where ((`test`.`t1`.`colb` = 'bar') and (`test`.`t1`.`cola` = 'foo')) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE cola = 'foo' AND colb = 'bar' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`cola` AS `cola`,`t1`.`colb` AS `colb`,`t1`.`filler` AS `filler` from `t1` where ((`t1`.`cola` = 'foo') and (`t1`.`colb` = 'bar'))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`cola` = 'foo') and (`t1`.`colb` = 'bar'))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal('foo', `t1`.`cola`) and multiple equal('bar', `t1`.`colb`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal('foo', `t1`.`cola`) and multiple equal('bar', `t1`.`colb`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal('foo', `t1`.`cola`) and multiple equal('bar', `t1`.`colb`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "cola", + "equals": "'foo'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "colb", + "equals": "'bar'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 8704, + "cost": 1311.28 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "cola", + "usable": true, + "key_parts": [ + "cola" + ] /* key_parts */ + }, + { + "index": "colb", + "usable": true, + "key_parts": [ + "colb" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "cola", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "colb", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "cola", + "ranges": [ + "foo <= cola <= foo" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 504, + "cost": 176.66, + "chosen": true + }, + { + "index": "colb", + "ranges": [ + "bar <= colb <= bar" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 504, + "cost": 176.66, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "cola", + "index_scan_cost": 4.90741, + "cumulated_index_scan_cost": 4.90741, + "disk_sweep_cost": 109.54, + "cumulated_total_cost": 114.448, + "usable": true, + "matching_rows_now": 504, + "isect_covering_with_this_index": false, + "chosen": true + }, + { + "index": "colb", + "index_scan_cost": 4.90741, + "cumulated_index_scan_cost": 9.81481, + "disk_sweep_cost": 7.19243, + "cumulated_total_cost": 17.0072, + "usable": true, + "matching_rows_now": 29.1838, + "isect_covering_with_this_index": false, + "chosen": true + } + ] /* intersecting_indexes */, + "clustered_pk": { + "clustered_pk_added_to_intersect": false, + "cause": "no_clustered_pk_index" + } /* clustered_pk */, + "rows": 29, + "cost": 17.0072, + "covering": false, + "chosen": true + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_intersect", + "rows": 29, + "cost": 17.0072, + "covering": false, + "clustered_pk_scan": false, + "intersect_of": [ + { + "type": "range_scan", + "index": "cola", + "rows": 504, + "ranges": [ + "foo <= cola <= foo" + ] /* ranges */ + }, + { + "type": "range_scan", + "index": "colb", + "rows": 504, + "ranges": [ + "bar <= colb <= bar" + ] /* ranges */ + } + ] /* intersect_of */ + } /* range_access_plan */, + "rows_for_plan": 29, + "cost_for_plan": 17.0072, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "cola", + "rows": 504, + "cost": 176.4, + "chosen": true + }, + { + "access_type": "ref", + "index": "colb", + "rows": 504, + "cost": 176.4, + "chosen": false + }, + { + "rows_to_scan": 29, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "intersect(cola,colb)" + } /* range_details */, + "resulting_rows": 29, + "cost": 19.9072, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 29, + "cost_for_plan": 19.9072, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))", + "final_table_condition ": "((`t1`.`colb` = 'bar') and (`t1`.`cola` = 'foo'))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT * FROM t1 WHERE cola = 'f\no'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref cola cola 12 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`cola` AS `cola`,`test`.`t1`.`colb` AS `colb`,`test`.`t1`.`filler` AS `filler` from `test`.`t1` where (`test`.`t1`.`cola` = 'f\no') + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE cola = 'f\no' { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`cola` AS `cola`,`t1`.`colb` AS `colb`,`t1`.`filler` AS `filler` from `t1` where (`t1`.`cola` = 'f\\no')" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`cola` = 'f\\no')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal('f\\no', `t1`.`cola`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal('f\\no', `t1`.`cola`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal('f\\no', `t1`.`cola`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "cola", + "equals": "'f\\no'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 8704, + "cost": 1311.28 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "cola", + "usable": true, + "key_parts": [ + "cola" + ] /* key_parts */ + }, + { + "index": "colb", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "cola", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "cola", + "ranges": [ + "f\no <= cola <= f\no" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "cola", + "rows": 1, + "ranges": [ + "f\no <= cola <= f\no" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "cola", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "cola" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`cola` = 'f\\no')", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`cola` = 'f\\no')" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`cola` = 'f\\no')", + "final_table_condition ": "(`t1`.`cola` = 'f\\no')" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "(`t1`.`cola` = 'f\\no')", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +CREATE TABLE t1(c INT); +INSERT INTO t1 VALUES (),(); +CREATE TABLE t2 (b INT, KEY(b)); +INSERT INTO t2 VALUES (),(),(); +SET optimizer_trace_features="greedy_search=off,dynamic_range=on"; +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL b NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `test`.`t2` join `test`.`t1` where (`test`.`t2`.`b` < `test`.`t1`.`c`) group by '' limit 1) `d2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": " `d2`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1) `d2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 3, + "cost": 0.501282 + } /* table_scan */ + }, + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.500854 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "attached_conditions_computation": [ + { + "table": "`t2`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 3.05 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "b", + "chosen": false, + "cause": "depends_on_unread_values" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2`", + "attached": "(`t2`.`b` < `t1`.`c`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "''", + "items": [ + { + "item": "1", + "uses_only_constant_tables": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "(`t2`.`b` < `t1`.`c`)", + "final_table_condition ": "(`t2`.`b` < `t1`.`c`)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": " `d2`", + "columns": 1, + "row_length": 5, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + { + "rows_estimation_per_outer_row": { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90128 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "comparison_with_null_always_false" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */ + } /* rows_estimation_per_outer_row */ + }, + { + "rows_estimation_per_outer_row": { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90128 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "comparison_with_null_always_false" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */ + } /* rows_estimation_per_outer_row */ + } + ] /* steps */ + } /* join_execution */ + }, + { + "table_dependencies": [ + { + "table": " `d2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": " `d2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + { + "join_explain": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +SET optimizer_trace_features="greedy_search=off,dynamic_range=off"; +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +2 DERIVED t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +2 DERIVED t2 NULL ALL b NULL NULL NULL 3 33.33 Range checked for each record (index map: 0x1) +Warnings: +Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `test`.`t2` join `test`.`t1` where (`test`.`t2`.`b` < `test`.`t1`.`c`) group by '' limit 1) `d2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT 1 FROM +(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": " `d2`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from (/* select#2 */ select 1 AS `1` from `t2` join `t1` where (`t2`.`b` < `t1`.`c`) group by '' limit 1) `d2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t2`.`b` < `t1`.`c`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 3, + "cost": 0.501282 + } /* table_scan */ + }, + { + "table": "`t1`", + "table_scan": { + "rows": 2, + "cost": 0.500854 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t2`.`b` < `t1`.`c`)", + "attached_conditions_computation": [ + { + "table": "`t2`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 3.05 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "b", + "chosen": false, + "cause": "depends_on_unread_values" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + }, + { + "table": "`t2`", + "attached": "(`t2`.`b` < `t1`.`c`)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "''", + "items": [ + { + "item": "1", + "uses_only_constant_tables": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t2`", + "original_table_condition": "(`t2`.`b` < `t1`.`c`)", + "final_table_condition ": "(`t2`.`b` < `t1`.`c`)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + }, + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": " `d2`", + "columns": 1, + "row_length": 5, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + { + "rows_estimation_per_outer_row": { + "table": "`t2`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90128 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.561628, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + { + "impossible_condition": { + "cause": "comparison_with_null_always_false" + } /* impossible_condition */ + } + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */ + } /* rows_estimation_per_outer_row */ + } + ] /* steps */ + } /* join_execution */ + }, + { + "table_dependencies": [ + { + "table": " `d2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": " `d2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + { + "join_explain": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1,t2; +SET optimizer_trace_features=default; +CREATE TABLE t1 ( +i1 int, +i2 int, +c char(1), +KEY k1 (i1), +KEY k2 (i1, i2) +) CHARSET utf8mb4; +INSERT INTO t1 VALUES (0,1,'2'),(3,2,'1'); +EXPLAIN SELECT * FROM t1 WHERE i1 > '2' ORDER BY i1, i2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range k1,k2 k2 5 NULL 2 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1`,`test`.`t1`.`i2` AS `i2`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`i1` > 2) order by `test`.`t1`.`i1`,`test`.`t1`.`i2` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE i1 > '2' ORDER BY i1, i2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`i1` AS `i1`,`t1`.`i2` AS `i2`,`t1`.`c` AS `c` from `t1` where (`t1`.`i1` > '2') order by `t1`.`i1`,`t1`.`i2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`i1` > '2')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`i1` > '2')" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`i1` > '2')" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`i1` > 2)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80159 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": true, + "key_parts": [ + "i1" + ] /* key_parts */ + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "i1", + "i2" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k1", + "ranges": [ + "2 < i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": true + }, + { + "index": "k2", + "ranges": [ + "2 < i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k1", + "rows": 2, + "ranges": [ + "2 < i1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "k1" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.16, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.16, + "sort_cost": 2, + "new_cost_for_plan": 3.16, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`i1` > 2)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`i1` > 2)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`i1`,`t1`.`i2`", + "items": [ + { + "item": "`t1`.`i1`" + }, + { + "item": "`t1`.`i2`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1`,`t1`.`i2`" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + { + "rows_estimation": { + "table": "`t1`", + "index": "k2", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80159 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "i1", + "i2" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k2", + "ranges": [ + "2 < i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.96, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k2", + "rows": 2, + "ranges": [ + "2 < i1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.96, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } /* rows_estimation */ + } + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "k2", + "plan_changed": true, + "access_type": "range" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`i1` > 2)", + "final_table_condition ": "(`t1`.`i1` > 2)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`", + "pushed_index_condition": "(`t1`.`i1` > 2)", + "table_condition_attached": null + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +EXPLAIN SELECT DISTINCT i1 FROM t1 WHERE i1 >= '1' ORDER BY i1 DESC; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index k1,k2 k1 5 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select distinct `test`.`t1`.`i1` AS `i1` from `test`.`t1` where (`test`.`t1`.`i1` >= 1) order by `test`.`t1`.`i1` desc + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT DISTINCT i1 FROM t1 WHERE i1 >= '1' ORDER BY i1 DESC { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select distinct `t1`.`i1` AS `i1` from `t1` where (`t1`.`i1` >= '1') order by `t1`.`i1` desc" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`i1` >= '1')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`i1` >= '1')" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`i1` >= '1')" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`i1` >= 1)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80159 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": true, + "key_parts": [ + "i1" + ] /* key_parts */ + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "i1", + "i2" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "k1", + "cost": 0.455814, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "distinct_query": true, + "potential_group_range_indexes": [ + { + "index": "k1", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= i1" + ] /* ranges */, + "rows": 3, + "cost": 0.7 + }, + { + "index": "k2", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= i1" + ] /* ranges */, + "rows": 3, + "cost": 0.7 + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "k1", + "group_attribute": null, + "min_aggregate": false, + "max_aggregate": false, + "distinct_aggregate": false, + "rows": 3, + "cost": 0.7, + "key_parts_used_for_access": [ + "i1" + ] /* key_parts_used_for_access */, + "ranges": [ + "1 <= i1" + ] /* ranges */, + "chosen": false, + "cause": "cost" + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_select_distinct" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k1", + "ranges": [ + "1 <= i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.465814, + "chosen": false, + "cause": "cost" + }, + { + "index": "k2", + "ranges": [ + "1 <= i1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.468065, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.701587, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.701587, + "sort_cost": 2, + "new_cost_for_plan": 2.70159, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`i1` >= 1)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`i1` >= 1)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`i1` desc", + "items": [ + { + "item": "`t1`.`i1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1` desc" + } /* simplifying_order_by */, + "unknown_key_1": { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "k1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + "unknown_key_2": { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "k1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + "changed_distinct_to_group_by": true, + "simplifying_group_by": { + "original_clause": "`t1`.`i1` desc", + "items": [ + { + "item": "`t1`.`i1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1` desc" + } /* simplifying_group_by */, + "removed_order_by": true + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "GROUP BY", + "steps": [ + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "desc", + "index": "k1", + "plan_changed": false + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`i1` >= 1)", + "final_table_condition ": "(`t1`.`i1` >= 1)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1; +CREATE TABLE t1 ( +pk INT PRIMARY KEY, +i1 INT, +i2 INT, +v varchar(1), +INDEX i1_idx (i1), +INDEX v_idx (v,i1) +) ENGINE=InnoDB, CHARSET utf8mb4; +INSERT INTO t1 VALUES (1, 1, 9,'a'), (2, 2, 8,'b'), (3, 3, 7,'c'), +(4, 4, 6,'d'), (5, 5, 5,'e'); + +# Covering ROR intersect not chosen: Index with more keyparts found. +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND v = 'a' AND pk < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,i1_idx,v_idx v_idx 16 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where ((`test`.`t1`.`v` = 'a') and (`test`.`t1`.`i1` = 1) and (`test`.`t1`.`pk` < 3)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND v = 'a' AND pk < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`v` AS `v` from `t1` where ((`t1`.`i1` = 1) and (`t1`.`v` = 'a') and (`t1`.`pk` < 3))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`i1` = 1) and (`t1`.`v` = 'a') and (`t1`.`pk` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`) and multiple equal('a', `t1`.`v`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`) and multiple equal('a', `t1`.`v`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`) and multiple equal('a', `t1`.`v`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "i1", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "v", + "equals": "'a'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "i1", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 5, + "cost": 2.85 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "pk" + ] /* key_parts */ + }, + { + "index": "i1_idx", + "usable": true, + "key_parts": [ + "i1", + "pk" + ] /* key_parts */ + }, + { + "index": "v_idx", + "usable": true, + "key_parts": [ + "v", + "i1", + "pk" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "v_idx", + "cost": 0.751949, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1_idx", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "v_idx", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.71, + "chosen": true + }, + { + "index": "i1_idx", + "ranges": [ + "1 <= i1 <= 1 AND pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "v_idx", + "ranges": [ + "a <= v <= a AND 1 <= i1 <= 1 AND pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 1, + "cost": 0.36, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "v_idx", + "index_scan_cost": 0.25, + "cumulated_index_scan_cost": 0.25, + "disk_sweep_cost": 0, + "cumulated_total_cost": 0.25, + "usable": true, + "matching_rows_now": 1, + "isect_covering_with_this_index": true, + "chosen": true + } + ] /* intersecting_indexes */, + "clustered_pk": { + "clustered_pk_added_to_intersect": false, + "cause": "roworder_is_covering" + } /* clustered_pk */, + "chosen": false, + "cause": "too_few_indexes_to_merge" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "v_idx", + "rows": 1, + "ranges": [ + "a <= v <= a AND 1 <= i1 <= 1 AND pk < 3" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.36, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i1_idx", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "access_type": "ref", + "index": "v_idx", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 1, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "v_idx" + } /* range_details */, + "resulting_rows": 1, + "cost": 0.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.46, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "final_table_condition ": "((`t1`.`v` = 'a') and (`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +# Chooses ROR intersect +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND pk < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index_merge PRIMARY,i1_idx,v_idx i1_idx,PRIMARY 9,4 NULL 1 100.00 Using intersect(i1_idx,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`v` AS `v` from `test`.`t1` where ((`test`.`t1`.`i1` = 1) and (`test`.`t1`.`pk` < 3)) + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT v FROM t1 WHERE i1 = 1 AND pk < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`v` AS `v` from `t1` where ((`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`pk` < 3) and multiple equal(1, `t1`.`i1`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "i1", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 5, + "cost": 2.85 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "pk" + ] /* key_parts */ + }, + { + "index": "i1_idx", + "usable": true, + "key_parts": [ + "i1", + "pk" + ] /* key_parts */ + }, + { + "index": "v_idx", + "usable": true, + "key_parts": [ + "v", + "i1", + "pk" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "v_idx", + "cost": 0.751949, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "i1_idx", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "v_idx", + "tree_travel_cost": 0.15, + "num_groups": 6, + "rows": 5, + "cost": 2.80195 + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "v_idx", + "key_parts_used_for_access": [ + "v", + "i1" + ] /* key_parts_used_for_access */, + "range": [ + "1 <= i1 <= 1" + ] /* range */, + "chosen": false, + "cause": "cost" + } /* best_skip_scan_summary */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 0.71, + "chosen": true + }, + { + "index": "i1_idx", + "ranges": [ + "1 <= i1 <= 1 AND pk < 3" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "v_idx", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "intersecting_indexes": [ + { + "index": "i1_idx", + "index_scan_cost": 0.25, + "cumulated_index_scan_cost": 0.25, + "disk_sweep_cost": 0.25, + "cumulated_total_cost": 0.5, + "usable": true, + "matching_rows_now": 1, + "isect_covering_with_this_index": false, + "chosen": true + } + ] /* intersecting_indexes */, + "clustered_pk": { + "index_scan_cost": 0.05, + "cumulated_index_scan_cost": 0.3, + "disk_sweep_cost": 0, + "clustered_pk_scan_added_to_intersect": true, + "cumulated_cost": 0.3 + } /* clustered_pk */, + "rows": 1, + "cost": 0.3, + "covering": false, + "chosen": true + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "index_roworder_intersect", + "rows": 1, + "cost": 0.3, + "covering": false, + "clustered_pk_scan": true, + "intersect_of": [ + { + "type": "range_scan", + "index": "i1_idx", + "rows": 1, + "ranges": [ + "1 <= i1 <= 1 AND pk < 3" + ] /* ranges */ + } + ] /* intersect_of */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.3, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i1_idx", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 1, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "intersect(i1_idx,PRIMARY)" + } /* range_details */, + "resulting_rows": 1, + "cost": 0.4, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.4, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))", + "final_table_condition ": "((`t1`.`i1` = 1) and (`t1`.`pk` < 3))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1; +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b), KEY b (b)) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 VALUES (1,1),(1,2),(1,0),(1,3); + +# Test trace for unreliable_ref_cost_and_range_uses_more_keyparts to +# ignore ref access on index with overly optimistic cost-estimate +EXPLAIN SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,b b 4 NULL 2 25.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`b`) AS `MAX(b)`,`test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1) and (`test`.`t1`.`b` < 2)) group by `test`.`t1`.`a` + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select max(`t1`.`b`) AS `MAX(b)`,`t1`.`a` AS `a` from `t1` where ((`t1`.`b` < 2) and (`t1`.`a` = 1)) group by `t1`.`a`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`b` < 2) and (`t1`.`a` = 1))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t1`.`b` < 2) and multiple equal(1, `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t1`.`b` < 2) and multiple equal(1, `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t1`.`b` < 2) and multiple equal(1, `t1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "a", + "equals": "1", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 4, + "cost": 2.75 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b" + ] /* key_parts */ + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "a" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "best_covering_index_scan": { + "index": "b", + "cost": 0.651098, + "chosen": true + } /* best_covering_index_scan */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "potential_group_range_indexes": [ + { + "index": "PRIMARY", + "covering": true, + "index_dives_for_eq_ranges": true, + "ranges": [ + "1 <= a <= 1 AND b < 2" + ] /* ranges */, + "rows": 2, + "cost": 0.55 + }, + { + "index": "b", + "covering": true, + "usable": false, + "cause": "group_attribute_not_prefix_in_index" + } + ] /* potential_group_range_indexes */ + } /* group_index_range */, + "best_group_range_summary": { + "type": "index_group", + "index": "PRIMARY", + "group_attribute": "b", + "min_aggregate": false, + "max_aggregate": true, + "distinct_aggregate": false, + "rows": 2, + "cost": 0.55, + "key_parts_used_for_access": [ + "a" + ] /* key_parts_used_for_access */, + "ranges": [ + "1 <= a <= 1 AND b < 2" + ] /* ranges */, + "chosen": true + } /* best_group_range_summary */, + "skip_scan_range": { + "chosen": false, + "cause": "has_group_by" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "1 <= a <= 1 AND b < 2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.71, + "chosen": false, + "cause": "cost" + }, + { + "index": "b", + "ranges": [ + "b < 2" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 2, + "cost": 0.460366, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "b", + "rows": 2, + "ranges": [ + "b < 2" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 0.460366, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "chosen": false, + "cause": "range_uses_more_keyparts" + }, + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.25, + "access_type": "range", + "range_details": { + "used_index": "b" + } /* range_details */, + "resulting_rows": 0.5, + "cost": 0.660366, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 0.5, + "cost_for_plan": 0.660366, + "sort_cost": 0.5, + "new_cost_for_plan": 1.16037, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t1`.`a` = 1) and (`t1`.`b` < 2))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "((`t1`.`a` = 1) and (`t1`.`b` < 2))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`a`", + "items": [ + { + "item": "`t1`.`a`", + "equals_constant_in_where": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "((`t1`.`a` = 1) and (`t1`.`b` < 2))", + "final_table_condition ": "((`t1`.`a` = 1) and (`t1`.`b` < 2))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4 + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 + +drop table t1; +# +# Tracing of when test_if_skip_sort_order() switches to another +# index and we abandon ICP, +# see "disabling_pushed_condition_on_old_index" in trace. +# +CREATE TABLE t1 ( +c1 VARCHAR(2) NOT NULL, +i1 INTEGER NOT NULL, +c2 VARCHAR(2) NOT NULL, +KEY k1 (c1), +KEY k2 (c1, i1) +) CHARSET utf8mb4; +INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'); +EXPLAIN SELECT * FROM t1 WHERE c1 = '1' ORDER BY i1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref k1,k2 k2 10 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`i1` AS `i1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` where (`test`.`t1`.`c1` = '1') order by `test`.`t1`.`i1` +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT * FROM t1 WHERE c1 = '1' ORDER BY i1 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`i1` AS `i1`,`t1`.`c2` AS `c2` from `t1` where (`t1`.`c1` = '1') order by `t1`.`i1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`c1` = '1')", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal('1', `t1`.`c1`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal('1', `t1`.`c1`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal('1', `t1`.`c1`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1`", + "field": "c1", + "equals": "'1'", + "null_rejecting": true + }, + { + "table": "`t1`", + "field": "c1", + "equals": "'1'", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80244 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": true, + "key_parts": [ + "c1" + ] /* key_parts */ + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "c1", + "i1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "query_references_nonkey_column" + }, + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k1", + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + }, + { + "index": "k2", + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": false, + "cause": "cost" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k1", + "rows": 1, + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "k1", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "k2", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "range", + "range_details": { + "used_index": "k1" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t1`.`c1` = '1')", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": "(`t1`.`c1` = '1')" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`t1`.`i1`", + "items": [ + { + "item": "`t1`.`i1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`i1`" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "reconsidering_access_paths_for_index_ordering": { + "clause": "ORDER BY", + "steps": [ + { + "check_if_range_uses_more_keyparts_than_ref": { + "rerunning_range_optimizer_for_single_index": { + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 1.79769e+308 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "k1", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "k2", + "usable": true, + "key_parts": [ + "c1", + "i1" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "k2", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "k2", + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "k2", + "rows": 1, + "ranges": [ + "1 <= c1 <= 1" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */, + "access_type_unchanged": { + "ref_key_length": 10, + "range_key_length": 10 + } /* access_type_unchanged */ + } /* rerunning_range_optimizer_for_single_index */ + } /* check_if_range_uses_more_keyparts_than_ref */ + } + ] /* steps */, + "index_order_summary": { + "table": "`t1`", + "index_provides_order": true, + "order_direction": "asc", + "index": "k2", + "plan_changed": true, + "access_type": "ref" + } /* index_order_summary */ + } /* reconsidering_access_paths_for_index_ordering */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1`", + "original_table_condition": "(`t1`.`c1` = '1')", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} 0 0 +# +# Bug#30266767 OPTIMIZER TRACE CONTAINS INVALID JSON FOR FORCE INDEX QUERIES +# +SELECT JSON_TYPE(REGEXP_SUBSTR(TRACE, "1.*e[+]?308")) AS json_type +FROM information_schema.OPTIMIZER_TRACE; +json_type +DOUBLE +DROP TABLE t1; + +# BUG#18023222 OPTIMIZER TRACE ERROR ON RANGE ANALYSIS OF +# INDEX ON A BINARY COLUMN + +CREATE TABLE t(i INT PRIMARY KEY, b BINARY(16), INDEX i_b(b)); +INSERT INTO t VALUES (1, x'D95B94336A9946A39CF5B58CFE772D8C'); +INSERT INTO t VALUES (2, NULL); +EXPLAIN SELECT * FROM t WHERE b IN (0xD95B94336A9946A39CF5B58CFE772D8C); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref i_b i_b 17 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c) +SELECT trace FROM information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`i` AS `i`,`t`.`b` AS `b` from `t` where (`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "multiple equal(0xd95b94336a9946a39cf5b58cfe772d8c, `t`.`b`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "multiple equal(0xd95b94336a9946a39cf5b58cfe772d8c, `t`.`b`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "multiple equal(0xd95b94336a9946a39cf5b58cfe772d8c, `t`.`b`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "b", + "equals": "0xd95b94336a9946a39cf5b58cfe772d8c", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80256 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i_b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i_b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i_b", + "ranges": [ + "0xd95b94336a9946a39cf5b58cfe772d8c <= b <= 0xd95b94336a9946a39cf5b58cfe772d8c" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i_b", + "rows": 1, + "ranges": [ + "0xd95b94336a9946a39cf5b58cfe772d8c <= b <= 0xd95b94336a9946a39cf5b58cfe772d8c" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i_b", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "i_b" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "final_table_condition ": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t`", + "pushed_index_condition": "(`t`.`b` = 0xd95b94336a9946a39cf5b58cfe772d8c)", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +EXPLAIN SELECT * FROM t WHERE b IS NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL ref i_b i_b 17 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`i` AS `i`,`test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`b` is null) +SELECT trace FROM information_schema.optimizer_trace; +trace +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`i` AS `i`,`t`.`b` AS `b` from `t` where (`t`.`b` is null)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t`.`b` is null)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t`.`b` is null)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t`.`b` is null)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t`.`b` is null)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "b", + "equals": "NULL", + "null_rejecting": false + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80256 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "i_b", + "usable": true, + "key_parts": [ + "b" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + } /* group_index_range */, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "i_b", + "usable": false, + "cause": "query_references_nonkey_column" + } + ] /* potential_skip_scan_indexes */ + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "i_b", + "ranges": [ + "NULL <= b <= NULL" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "i_b", + "rows": 1, + "ranges": [ + "NULL <= b <= NULL" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 1, + "cost_for_plan": 0.61, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "i_b", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "i_b" + } /* range_details */, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t`.`b` is null)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "(`t`.`b` is null)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "(`t`.`b` is null)", + "final_table_condition ": "(`t`.`b` is null)" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t`", + "pushed_index_condition": "(`t`.`b` is null)", + "table_condition_attached": null + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_explain */ + } + ] /* steps */ +} +drop table t; +# +# Test trace of geometry fields +# +CREATE TABLE t1( +pk INT AUTO_INCREMENT PRIMARY KEY, +col_geom GEOMETRY NOT NULL SRID 0 +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, ST_GeomFromText('POINT(10 10)')); +INSERT INTO t1 VALUES (2, ST_GeomFromText('POINT(11 11)')); +CREATE SPATIAL INDEX idx3 on t1(col_geom); +# Show that geometry data is traced as "unprintable_geometry_value" +EXPLAIN +SELECT pk, ST_AsText(col_geom) +FROM t1 +WHERE MBREquals(t1.col_geom, ST_GeomFromText('POINT(12 13)')); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx3 idx3 34 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,st_astext(`test`.`t1`.`col_geom`) AS `ST_AsText(col_geom)` from `test`.`t1` where mbrequals(`test`.`t1`.`col_geom`,(st_geomfromtext('POINT(12 13)'))) +SELECT show_json_object('"range_scan_alternatives": [', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"range_scan_alternatives": [', TRACE) +"range_scan_alternatives": [ + { + "index": "idx3", + "ranges": [ + "col_geom unprintable_geometry_value" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 0.61, + "chosen": true + } + ] +DROP TABLE t1; +DROP FUNCTION show_json_object; diff --git a/mysql-test/suite/opt_trace/r/security_no_prot.result-pq b/mysql-test/suite/opt_trace/r/security_no_prot.result-pq new file mode 100644 index 000000000..09f6d3928 --- /dev/null +++ b/mysql-test/suite/opt_trace/r/security_no_prot.result-pq @@ -0,0 +1,962 @@ +set @old_size = @@global.optimizer_trace_max_mem_size; +set global optimizer_trace_max_mem_size=1048576; +select user(); +user() +root@localhost +create database somedb; +use somedb; +create table t1(a varchar(100)); +insert into t1 values("first"); +create table t2(a varchar(100)); +insert into t2 values("first"); +create table t3(a varchar(100)); +insert into t3 values("first"); +SET sql_mode = 'ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION'; +create procedure p1() sql security definer +begin +declare b int; +if (select count(*) from t1) +then +select 22 into b from dual; +end if; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +end| +create function f1() returns int sql security definer +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end| +create trigger trg2 before insert on t2 for each row +begin +insert into t3 select * from t3; +end| +SET sql_mode = default; +create sql security definer view v1 as select * from t1; +create user user1@localhost identified by ''; +grant all on *.* to user1@localhost with grant option; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +show grants; +Grants for user1@localhost +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `user1`@`localhost` WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `user1`@`localhost` WITH GRANT OPTION + +# ========================================================== +# Part A. +# Test that security context changes are allowed when, and only +# when, invoker has all global privileges. +# ========================================================== + +# Because invoker has all global privileges, all traces are visible: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 3065 0 +select 22 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +# this SET always purges all remembered traces +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +freturn 3 36 20 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +root@localhost +root@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +insert into t2 values(current_user()) 20 0 +insert into t3 select * from t3 3080 0 + +# Show that really all global privileges are needed: let root +# revoke just one from user1. Because user1 does not have all global +# privileges anymore, security context changes are forbidden, +# thus there is no trace. + +select user(); +user() +root@localhost +revoke shutdown on *.* from user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +show grants; +Grants for user1@localhost +GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `user1`@`localhost` WITH GRANT OPTION +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `user1`@`localhost` WITH GRANT OPTION +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# In CALL we execute stored procedure and notice a security +# context change. The context change is probably only relevant +# for substatements, but we still hide CALL. This is to be +# consistent with what we do when routine body should not be +# exposed. And it also feels safer to disable I_S output as +# soon as possible. +# Ps-protocol-specific note: mysqltest uses normal protocol for CALL +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +root@localhost +root@localhost +root@localhost +root@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 + +# Verify that user1 cannot circumvent security checks by +# setting @@optimizer_trace_offset so that I_S output is disabled +# before the object (routine) is checked, and enabled in the +# middle of object usage, when 'offset' is passed. + +set optimizer_trace_offset=2,optimizer_trace_limit=1; +call p1(); +# Even though the routine's execution started before +# 'offset', it detected the security context changes. So the +# trace of CALL gets the "missing privilege" mark but we don't +# see it as CALL was before 'offset'. +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + +# Finally, verify that if the routine's definer does modify +# @@optimizer_trace from "enabled=off" to "enabled=on", in the +# body of the routine, then tracing works. This is no security +# issue, as it was done by the routine's definer. + +select user(); +user() +root@localhost +create procedure p2() sql security definer +begin +declare b int; +set optimizer_trace="enabled=on"; +select 22 into b from dual; +end| + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=off"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p2(); +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES +select 22 into b from dual { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select 22 AS `22`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 +# Variable is as set by the routine +select @@optimizer_trace; +@@optimizer_trace +enabled=on,one_line=off + +# ========================================================== +# Part B. +# Do same tests but with SQL SECURITY INVOKER objects, to verify that +# the restriction on security context changes is not present. +# ========================================================== + +select user(); +user() +root@localhost +alter procedure p1 sql security invoker; +alter function f1 sql security invoker; +alter sql security invoker view v1 as select * from t1; +# Triggers cannot be SQL SECURITY INVOKER so we don't test +# them here. +alter procedure p2 sql security invoker; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 3065 0 +select 22 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 407 0 +select a into b from t1 limit 1 2253 0 +insert into t1 values(current_user()) 20 0 +freturn 3 36 20 0 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +set optimizer_trace_offset=2,optimizer_trace_limit=1; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 2868 0 +set optimizer_trace="enabled=off"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p2(); +# SELECT substatement is traced (no security context change) +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES +select 22 into b from dual { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select 22 AS `22`" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + ] + } + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 +select @@optimizer_trace; +@@optimizer_trace +enabled=on,one_line=off + +# ========================================================== +# Part C. +# User1 got traces. Determine the minimum set of privileges he +# needed for that. +# ========================================================== + +drop procedure p2; +select user(); +user() +root@localhost +revoke all privileges, grant option from user1@localhost; +# Grant minimum privileges to use the routines and views, +# without considering optimizer trace: +grant execute on procedure p1 to user1@localhost; +grant execute on function f1 to user1@localhost; +grant select (a) on v1 to user1@localhost; +# Objects above are SQL SECURITY INVOKER, so invoker needs +# privileges on objects used internally: +grant select (a) on t1 to user1@localhost; +grant insert (a) on t1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +show grants; +Grants for user1@localhost +GRANT EXECUTE ON FUNCTION `somedb`.`f1` TO `user1`@`localhost` +GRANT EXECUTE ON PROCEDURE `somedb`.`p1` TO `user1`@`localhost` +GRANT SELECT (`a`) ON `somedb`.`v1` TO `user1`@`localhost` +GRANT SELECT (`a`), INSERT (`a`) ON `somedb`.`t1` TO `user1`@`localhost` +GRANT USAGE ON *.* TO `user1`@`localhost` + +# Those privileges are not enough to see traces: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# In CALL we execute stored procedure and notice that body should +# not be exposed. The trace of this CALL would not expose the +# body. Trace of substatements would. But, due to +# implementation, CALL is hidden. +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +# SELECT is hidden (same reason as for CALL). +# Ps-protocol-specific note: preparation of SELECT above does not +# execute f1, so does not risk exposing body, so its trace is +# visible. +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it would expose body of view +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# C.0) Add more privileges: + +select user(); +user() +root@localhost +# - for use of t1 in routines and view: +grant select on t1 to user1@localhost; +# - for use of view: +grant select, show view on v1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create procedure p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION NULL utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select * from t1 limit 1; +a +first +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION NULL utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +# Trace exposed body of view, and content of t1, which we +# could see anyway: +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci + +# Now remove each privilege to verify that it was needed: +# C.1) remove table-level SELECT privilege on t1 + +select user(); +user() +root@localhost +revoke select on t1 from user1@localhost; +grant select (a) on t1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# Cannot see those substatements which use t1 +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +# Cannot see those substatements which use t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Trace exposed body of routine, which we could see anyway: +set optimizer_trace="enabled=off"; +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION NULL utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace="enabled=on"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# C.2) remove table-level SELECT privilege on view + +select user(); +user() +root@localhost +# Put back privilege removed in C.1 +grant select on t1 to user1@localhost; +# And remove a next one: +revoke select on v1 from user1@localhost; +grant select (a) on v1 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +# Cannot see anything as it might expose some data from columns +# of v1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# C.3) remove SHOW VIEW privilege on view + +select user(); +user() +root@localhost +# Put back privilege removed in C.3 +grant select on v1 to user1@localhost; +# And remove a next one: +revoke show view on v1 from user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=off"; +# We have no right to see view's body: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +set optimizer_trace="enabled=on"; +# Verify that optimizer trace does not influence the privilege +# checking in SHOW CREATE: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +# Cannot see anything as it would expose body of view +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 + +# ========================================================== +# Part D. +# Like Part C, but instead of SQL SECURITY INVOKER objects +# created by root and used by User1, let's have SQL SECURITY +# DEFINER objects created and used by User1. Determine the +# minimum set of privileges he needs for that. +# ========================================================== + +select user(); +user() +root@localhost +drop procedure p1; +drop function f1; +drop view v1; +drop trigger trg2; +revoke all privileges, grant option from user1@localhost; +# Grant minimum privileges to create and use objects, +# without considering optimizer trace: +grant create routine on somedb.* to user1@localhost; +grant trigger on t2 to user1@localhost; +grant create view on somedb.* to user1@localhost; +grant select (a) on t1 to user1@localhost; +grant insert (a) on t1 to user1@localhost; +grant insert (a) on t2 to user1@localhost; +grant select (a) on t3 to user1@localhost; +grant insert (a) on t3 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace="enabled=on"; +SET sql_mode = 'ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION'; +create procedure p1() sql security definer +begin +declare b int; +if (select count(*) from t1) +then +select 22 into b from dual; +end if; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +end| +create function f1() returns int sql security definer +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end| +create trigger trg2 before insert on t2 for each row +begin +insert into t3 select * from t3; +end| +create sql security definer view v1 as select * from t1; +SET sql_mode = default; +# Creating a view is not enough to be able to SELECT it... +select user(); +user() +root@localhost +grant select (a) on v1 to user1@localhost; + +select user(); +user() +user1@localhost +# Those privileges are not enough to see traces: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +# Can see body of routine (as definer), but not statements using t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 + 0 1 +select 22 into b from dual 407 0 + 0 1 + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +# Can see body of routine (as definer), but not statements using t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 407 0 + 0 1 + 0 1 +freturn 3 36 20 0 +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` FUNCTION `f1`() RETURNS int +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +# Cannot see anything as it might expose some data from +# columns of t2 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 +# Also test a query accessing t1 in FROM clause: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select a from (select a from t1 where a like "f%") as tt where a like "fi%"; +a +first +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# D.0) Add more privileges: + +select user(); +user() +root@localhost +# - for use of t1 in routines and view: +grant select on t1 to user1@localhost; +# - for use of view: +grant select, show view on v1 to user1@localhost; +# - for use of trigger +grant select on t2 to user1@localhost; +grant select on t3 to user1@localhost; +delete from t1 where a<>"first"; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +call p1(); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +call p1() 20 0 +set b@0 NULL 20 0 +jump_if_not 3(3) (select count(0) from `somedb`.`t1`) 2868 0 +select 22 into b from dual 218 0 +select a into b from t1 limit 1 2041 0 +insert into t1 values(current_user()) 20 0 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create procedure p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` PROCEDURE `p1`() +begin +declare b int; +if (select count(*) from t1) +then +select 22 into b from dual; +end if; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +select * from t1 limit 1; +a +first +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select f1(); +f1() +36 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select f1() 413 0 +set b@0 NULL 20 0 +select 48 into b from dual 218 0 +select a into b from t1 limit 1 2041 0 +insert into t1 values(current_user()) 20 0 +freturn 3 36 20 0 +# Trace exposed body of routine, and content of t1, which we +# could see anyway: +show create function f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` FUNCTION `f1`() RETURNS int +begin +declare b int; +select 48 into b from dual; +select a into b from t1 limit 1; +insert into t1 values(current_user()); +return 36; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select * from v1 2920 0 +# Trace exposed body of view, and content of t1, which we +# could see anyway: +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`user1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_0900_ai_ci +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +insert into t2 values(current_user()) 20 0 +insert into t3 select * from t3 2841 0 +# Trace exposed body of trigger, and content of t2/t3, which we +# could see anyway: +show create trigger trg2; +Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation Created +trg2 ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`localhost` TRIGGER `trg2` BEFORE INSERT ON `t2` FOR EACH ROW begin +insert into t3 select * from t3; +end utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci # +select * from t2, t3 order by t2.a, t3.a limit 1; +a a +first first +# Trace exposed content of t1 which we could see anyway: +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select a from (select a from t1 where a like "f%") as tt where a like "fi%"; +a +first +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +select a from (select a from t1 where a like "f%") as tt where a like "fi%" 4649 0 + +# For routines, as they only use t1 and we added only one +# privilege on t1, we have nothing to remove. + +# Now remove each privilege to verify that it was needed for +# the view. +# D.1) remove table-level SELECT privilege on v1 + +select user(); +user() +root@localhost +revoke select on v1 from user1@localhost; +grant select (a) on v1 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of v1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# D.2) remove table-level SHOW VIEW privilege on v1 + +select user(); +user() +root@localhost +# Put back privilege removed in D.1 +grant select on v1 to user1@localhost; +# And remove a next one: +revoke show view on v1 from user1@localhost; + +select user(); +user() +user1@localhost +# We have no right to see view's body: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it would expose body of view +select QUERY, TRACE, INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY TRACE INSUFFICIENT_PRIVILEGES + 1 + +# D.3) remove table-level SELECT privilege on t1 + +select user(); +user() +root@localhost +# Put back privilege removed in D.2 +grant show view on v1 to user1@localhost; +# And remove a next one: +revoke select on t1 from user1@localhost; +grant select (a) on t1 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1; +a +first +user1@localhost +user1@localhost +# Cannot see anything as it might expose some data from columns +# of t1 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# Now remove each privilege to verify that it was needed for +# the trigger: +# D.4) remove table-level SELECT privilege on t2 + +select user(); +user() +root@localhost +revoke select on t2 from user1@localhost; +grant select (a) on t2 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +# Cannot see anything as it might expose some data from +# columns of t2 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES + 0 1 + +# D.5) remove table-level SELECT privilege on t3 + + +select user(); +user() +root@localhost +# Put back privilege removed in D.4 +grant select on t2 to user1@localhost; +# And remove a next one: +revoke select on t3 from user1@localhost; +grant select (a) on t3 to user1@localhost; + +select user(); +user() +user1@localhost +set optimizer_trace_offset=0,optimizer_trace_limit=100; +insert into t2 values(current_user()); +# Cannot see substatement as it might expose some data from +# columns of t3 +select QUERY, length(TRACE), INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE; +QUERY length(TRACE) INSUFFICIENT_PRIVILEGES +insert into t2 values(current_user()) 20 0 + 0 1 + +# Cleanup +select user(); +user() +root@localhost +drop user user1@localhost; +Warnings: +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a view. +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a stored routine. +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a trigger. + +# ========================================================== +# Part E. +# Misc tests. +# ========================================================== + +select user(); +user() +root@localhost +drop view v1; +create sql security definer view v1 as select * from t1 where 'secret'; +create user user1@localhost identified by ''; +Warnings: +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a stored routine. +Warning 4005 User 'user1'@'localhost' is referenced as a definer account in a trigger. +grant create, insert, select on somedb.* to user1@localhost; +grant create routine on somedb.* to user1@localhost; + +select user(); +user() +user1@localhost +user1 cannot see view's body: +show create view v1; +ERROR 42000: SHOW VIEW command denied to user 'user1'@'localhost' for table 'v1' +SET sql_mode = 'ONLY_FULL_GROUP_BY,NO_ENGINE_SUBSTITUTION'; +user1 creates a procedure +create procedure proc() sql security definer +begin +set optimizer_trace="enabled=on"; +set optimizer_trace_offset=0,optimizer_trace_limit=100; +select * from v1 limit 0; +create table leak select * from information_schema.optimizer_trace; +set optimizer_trace="enabled=off"; +end| +SET sql_mode = default; +select user(); +user() +root@localhost +root runs procedure, without fear of risk as it is SQL SECURITY DEFINER +call proc(); +a + +select user(); +user() +user1@localhost +user1 cannot see view's body: +select * from leak; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES + +# Cleanup +select user(); +user() +root@localhost +drop database somedb; +drop user user1@localhost; +set @@global.optimizer_trace_max_mem_size = @old_size; diff --git a/mysql-test/suite/opt_trace/r/skip_scan.result-pq b/mysql-test/suite/opt_trace/r/skip_scan.result-pq new file mode 100644 index 000000000..6930beb29 --- /dev/null +++ b/mysql-test/suite/opt_trace/r/skip_scan.result-pq @@ -0,0 +1,1225 @@ +CREATE TABLE t (a INT, b INT, c INT, d INT, e INT, PRIMARY KEY(a, b, c, d), KEY(b, d)) ENGINE=innodb; +# Since ANALYZE TABLE only reads a subset of the data, the statistics for +# table t depends on the row order. And since the INSERT INTO ... SELECT +# may be executed using different execution plans, we've added ORDER BY +# to ensure that we rows has the same order every time. If not, the +# estimated number of rows in EXPLAIN may change on different platforms. +ANALYZE TABLE t; +Table Op Msg_type Msg_text +test.t analyze status OK +SET optimizer_switch = 'skip_scan=on'; +SET optimizer_trace="enabled=on,one_line=off"; +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 2 AND d >= 98 AND e = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 3.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 3.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`e` = 2) and (`test`.`t`.`a` = 2) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%query_references_nonkey_column%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 OR b = 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL index_merge PRIMARY,b b,PRIMARY 8,4 NULL 251 100.00 Using sort_union(b,PRIMARY); Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) or ((`test`.`t`.`b` = 2) and (`test`.`t`.`d` >= 98))) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%disjuntive_predicate_present%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 OR b = 2 OR d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 52.00 Parallel execute (4 workers) +2 SIMPLE t NULL index PRIMARY,b b 8 NULL 2500 52.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) or (`test`.`t`.`b` = 2) or (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%disjuntive_predicate_present%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 5 OR d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2500 40.00 Parallel execute (4 workers) +2 SIMPLE t NULL index PRIMARY b 8 NULL 2500 40.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) or (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%disjuntive_predicate_present%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE ((a = 5 AND b = 2) OR a = 2) and d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 300 33.33 Parallel execute (2 workers) +2 SIMPLE t NULL range PRIMARY,b PRIMARY 8 NULL 300 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 5)) or (`test`.`t`.`a` = 2)) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%keypart_in_disjunctive_query%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a > 2 AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 833 80.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` > 2) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%prefix_not_const_equality%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 2 AND (d >= 98 OR d < 2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 55.55 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY PRIMARY 4 const 250 55.55 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 2) and ((`test`.`t`.`d` >= 98) or (`test`.`t`.`d` < 2))) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%range_predicate_too_complex%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a = 2 AND b = 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 50 100.00 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 8 const,const 50 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`b` = 2) and (`test`.`t`.`a` = 2)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%no_range_predicate%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE (a < 1 OR a = 4 OR a = 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 46.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 8 NULL 3 46.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where (((`test`.`t`.`a` < 1) or (`test`.`t`.`a` = 4) or (`test`.`t`.`a` = 5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +SELECT count(*) FROM information_schema.optimizer_trace WHERE trace LIKE '%prefix_not_const_equality%'; +count(*) +1 +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 50.00 Parallel execute (3 workers) +2 SIMPLE t NULL range PRIMARY,b b 12 NULL 3 50.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`a` AS `a`,`test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` in (1,2,3,4,5)) and (`test`.`t`.`b` in (1,2,3)) and (`test`.`t`.`d` >= 98)) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT a, b, c, d FROM t WHERE a IN (1, 2, 3, 4, 5) AND b IN (1, 2, 3) AND d >= 98 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "IN_uses_bisection": true + }, + { + "IN_uses_bisection": true + }, + { + "expanded_query": "/* select#1 */ select `t`.`a` AS `a`,`t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `t` where ((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "tree_travel_cost": 0.6, + "num_groups": 76, + "rows": 249, + "cost": 129.041 + }, + { + "index": "b", + "usable": false, + "cause": "prefix_not_const_equality" + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c", + "d" + ], + "prefix ranges": [ + "1 <= a <= 1 AND 1 <= b <= 1", + "1 <= a <= 1 AND 2 <= b <= 2", + "1 <= a <= 1 AND 3 <= b <= 3", + "2 <= a <= 2 AND 1 <= b <= 1", + "2 <= a <= 2 AND 2 <= b <= 2", + "2 <= a <= 2 AND 3 <= b <= 3", + "3 <= a <= 3 AND 1 <= b <= 1", + "3 <= a <= 3 AND 2 <= b <= 2", + "3 <= a <= 3 AND 3 <= b <= 3", + "4 <= a <= 4 AND 1 <= b <= 1", + "4 <= a <= 4 AND 2 <= b <= 2", + "4 <= a <= 4 AND 3 <= b <= 3", + "5 <= a <= 5 AND 1 <= b <= 1", + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3" + ], + "range": [ + "98 <= d" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "1 <= a <= 1 AND 1 <= b <= 1", + "1 <= a <= 1 AND 2 <= b <= 2", + "1 <= a <= 1 AND 3 <= b <= 3", + "2 <= a <= 2 AND 1 <= b <= 1", + "2 <= a <= 2 AND 2 <= b <= 2", + "2 <= a <= 2 AND 3 <= b <= 3", + "3 <= a <= 3 AND 1 <= b <= 1", + "3 <= a <= 3 AND 2 <= b <= 2", + "3 <= a <= 3 AND 3 <= b <= 3", + "4 <= a <= 4 AND 1 <= b <= 1", + "4 <= a <= 4 AND 2 <= b <= 2", + "4 <= a <= 4 AND 3 <= b <= 3", + "5 <= a <= 5 AND 1 <= b <= 1", + "5 <= a <= 5 AND 2 <= b <= 2", + "5 <= a <= 5 AND 3 <= b <= 3" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 750, + "cost": 79.0151, + "chosen": true + }, + { + "index": "b", + "ranges": [ + "1 <= b <= 1 AND 98 <= d", + "2 <= b <= 2 AND 98 <= d", + "3 <= b <= 3 AND 98 <= d" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": true, + "rows": 3, + "cost": 0.561462, + "chosen": true + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "b", + "rows": 3, + "ranges": [ + "1 <= b <= 1 AND 98 <= d", + "2 <= b <= 2 AND 98 <= d", + "3 <= b <= 3 AND 98 <= d" + ] + }, + "rows_for_plan": 3, + "cost_for_plan": 0.561462, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 3, + "filtering_effect": [ + ], + "final_filtering_effect": 0.5, + "access_type": "range", + "range_details": { + "used_index": "b" + }, + "resulting_rows": 1.5, + "cost": 0.861462, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 1.5, + "cost_for_plan": 0.861462, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))", + "final_table_condition ": "((`t`.`a` in (1,2,3,4,5)) and (`t`.`b` in (1,2,3)) and (`t`.`d` >= 98))" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t`", + "degree of parallel": 4 + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 4 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b PRIMARY 12 NULL 83 33.33 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`c` > 4) and (`test`.`t`.`d` < 3)) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND c > 4 AND d < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `t` where ((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t`.`c` > 4) and (`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t`.`c` > 4) and (`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t`.`c` > 4) and (`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 83, + "cost": 19.9798 + }, + { + "index": "b", + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 833, + "cost": 133.008 + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c" + ], + "prefix ranges": [ + "5 <= a <= 5" + ], + "range": [ + "4 < c" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "5 <= a <= 5" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 250, + "cost": 25.345, + "chosen": false, + "cause": "cost" + }, + { + "index": "b", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c" + ], + "prefix ranges": [ + "5 <= a <= 5" + ], + "range": [ + "4 < c" + ] + }, + "rows_for_plan": 83, + "cost_for_plan": 19.9798, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 250, + "cost": 25.4922, + "chosen": true + }, + { + "rows_to_scan": 83, + "filtering_effect": [ + ], + "final_filtering_effect": 0.3333, + "access_type": "range", + "range_details": { + "used_index": "index_for_skip_scan(PRIMARY)" + }, + "resulting_rows": 27.6639, + "cost": 28.2798, + "chosen": false + } + ] + }, + "condition_filtering_pct": 11.1089, + "rows_for_plan": 27.7722, + "cost_for_plan": 25.4922, + "chosen": true + } + ] + }, + { + "access_type_changed": { + "table": "`t`", + "index": "PRIMARY", + "old_type": "ref", + "new_type": "range", + "cause": "uses_more_keyparts" + } + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))", + "final_table_condition ": "((`t`.`a` = 5) and (`t`.`c` > 4) and (`t`.`d` < 3))" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 250 33.33 Parallel execute (1 workers) +2 SIMPLE t NULL ref PRIMARY,b PRIMARY 4 const 250 33.33 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`a` = 5) and (`test`.`t`.`d` < 3)) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT b, c, d FROM t WHERE a = 5 AND d < 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`b` AS `b`,`t`.`c` AS `c`,`t`.`d` AS `d` from `t` where ((`t`.`a` = 5) and (`t`.`d` < 3))" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t`.`a` = 5) and (`t`.`d` < 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "((`t`.`d` < 3) and multiple equal(5, `t`.`a`))" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t`", + "field": "a", + "equals": "5", + "null_rejecting": true + } + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "tree_travel_cost": 0.6, + "num_groups": 26, + "rows": 83, + "cost": 43.9798 + }, + { + "index": "b", + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 833, + "cost": 133.008 + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "PRIMARY", + "key_parts_used_for_access": [ + "a", + "b", + "c", + "d" + ], + "prefix ranges": [ + "5 <= a <= 5" + ], + "range": [ + "d < 3" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "5 <= a <= 5" + ], + "index_dives_for_eq_ranges": true, + "rowid_ordered": true, + "using_mrr": false, + "index_only": true, + "rows": 250, + "cost": 25.345, + "chosen": true + }, + { + "index": "b", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 250, + "ranges": [ + "5 <= a <= 5" + ] + }, + "rows_for_plan": 250, + "cost_for_plan": 25.345, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "PRIMARY", + "rows": 250, + "cost": 25.4922, + "chosen": true + }, + { + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + }, + "chosen": false, + "cause": "heuristic_index_cheaper" + } + ] + }, + "condition_filtering_pct": 33.33, + "rows_for_plan": 83.325, + "cost_for_plan": 25.4922, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`t`.`a` = 5) and (`t`.`d` < 3))", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "((`t`.`a` = 5) and (`t`.`d` < 3))" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "((`t`.`a` = 5) and (`t`.`d` < 3))", + "final_table_condition ": "(`t`.`d` < 3)" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t`", + "degree of parallel": 4 + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +ANALYZE TABLE t UPDATE HISTOGRAM ON d WITH 10 BUCKETS; +Table Op Msg_type Msg_text +test.t histogram status Histogram statistics created for column 'd'. +EXPLAIN SELECT b FROM t WHERE d < 2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t NULL range PRIMARY,b b 8 NULL 250 100.00 Using where; Using index for skip scan +Warnings: +Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b` from `test`.`t` where (`test`.`t`.`d` < 2) +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +EXPLAIN SELECT b FROM t WHERE d < 2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t`.`b` AS `b` from `t` where (`t`.`d` < 2)" + } + ] + } + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t`.`d` < 2)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t`.`d` < 2)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t`.`d` < 2)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t`.`d` < 2)" + } + ] + } + }, + { + "substitute_generated_columns": { + } + }, + { + "table_dependencies": [ + { + "table": "`t`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] + } + ] + }, + { + "ref_optimizer_key_uses": [ + ] + }, + { + "rows_estimation": [ + { + "table": "`t`", + "range_analysis": { + "table_scan": { + "rows": 2500, + "cost": 254.1 + }, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "a", + "b", + "c", + "d" + ] + }, + { + "index": "b", + "usable": true, + "key_parts": [ + "b", + "d", + "a", + "c" + ] + } + ], + "best_covering_index_scan": { + "index": "b", + "cost": 252.077, + "chosen": true + }, + "setup_range_conditions": [ + ], + "group_index_range": { + "chosen": false, + "cause": "not_group_by_or_distinct" + }, + "skip_scan_range": { + "potential_skip_scan_indexes": [ + { + "index": "PRIMARY", + "histogram_selectivity": { + "condition": "(`t`.`d` < 2)", + "histogram_selectivity": 0.1 + }, + "tree_travel_cost": 0.6, + "num_groups": 251, + "rows": 250, + "cost": 339.192 + }, + { + "index": "b", + "histogram_selectivity": { + "condition": "(`t`.`d` < 2)", + "histogram_selectivity": 0.1 + }, + "tree_travel_cost": 0.6, + "num_groups": 6, + "rows": 250, + "cost": 45.132 + } + ] + }, + "best_skip_scan_summary": { + "type": "skip_scan", + "index": "b", + "key_parts_used_for_access": [ + "b", + "d" + ], + "range": [ + "d < 2" + ], + "chosen": true + }, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "chosen": false, + "cause": "no_valid_range_for_this_index" + }, + { + "index": "b", + "chosen": false, + "cause": "no_valid_range_for_this_index" + } + ], + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } + }, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "skip_scan", + "index": "b", + "key_parts_used_for_access": [ + "b", + "d" + ], + "range": [ + "d < 2" + ] + }, + "rows_for_plan": 250, + "cost_for_plan": 45.132, + "chosen": true + } + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ], + "table": "`t`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 250, + "filtering_effect": [ + ], + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "index_for_skip_scan(b)" + }, + "resulting_rows": 250, + "cost": 70.132, + "chosen": true + } + ] + }, + "condition_filtering_pct": 100, + "rows_for_plan": 250, + "cost_for_plan": 70.132, + "chosen": true + } + ] + }, + { + "attaching_conditions_to_tables": { + "original_condition": "(`t`.`d` < 2)", + "attached_conditions_computation": [ + ], + "attached_conditions_summary": [ + { + "table": "`t`", + "attached": "(`t`.`d` < 2)" + } + ] + } + }, + { + "finalizing_table_conditions": [ + { + "table": "`t`", + "original_table_condition": "(`t`.`d` < 2)", + "final_table_condition ": "(`t`.`d` < 2)" + } + ] + }, + { + "refine_plan": [ + { + "table": "`t`" + } + ] + } + ] + } + }, + { + "join_explain": { + "select#": 1, + "steps": [ + ] + } + } + ] +} 0 0 +SET optimizer_trace="enabled=off"; +DROP TABLE t; +SET optimizer_switch = 'skip_scan=on'; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 (f1 VARCHAR(10), f2 CHAR(10), f3 INT, KEY(f1, f2, f3)); +INSERT INTO t1 VALUES ('a', 'aaaa', 1); +EXPLAIN SELECT /*+ SKIP_SCAN(t1) */ count(*) FROM t1 WHERE f1 BETWEEN 'a' and 'a ' AND f3 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index f1 f1 89 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select /*+ SKIP_SCAN(`t1`@`select#1`) */ count(0) AS `count(*)` from `test`.`t1` where ((`test`.`t1`.`f1` between 'a' and 'a ') and (`test`.`t1`.`f3` > 0)) +SELECT count(*) FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE WHERE trace LIKE '%prefix_not_const_equality%'; +count(*) +1 +DROP TABLE t1; +SET optimizer_trace="enabled=off"; diff --git a/mysql-test/suite/opt_trace/r/subquery_no_prot.result-pq b/mysql-test/suite/opt_trace/r/subquery_no_prot.result-pq new file mode 100644 index 000000000..db65a2762 --- /dev/null +++ b/mysql-test/suite/opt_trace/r/subquery_no_prot.result-pq @@ -0,0 +1,3400 @@ +SET optimizer_trace_max_mem_size=1048576; +SET end_markers_in_json=on; +SET optimizer_trace="enabled=on,one_line=off"; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (1,7),(2,7); +# Subselect execute is traced every time it is executed +SET @@optimizer_trace_features="greedy_search=off,repeated_subselect=on"; +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2; +(SELECT a FROM t1 WHERE t1.a=t2.a) a +NULL 1 +2 2 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)) AS `(SELECT a FROM t1 WHERE t1.a=t2.a)`,`t2`.`a` AS `a` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.501099 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = `t2`.`a`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "('2' = `t2`.`a`)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + }, + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +# Subselect execute is traced only the first time it is executed +SET @@optimizer_trace_features="greedy_search=off,repeated_subselect=off"; +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2; +(SELECT a FROM t1 WHERE t1.a=t2.a) a +NULL 1 +2 2 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT (SELECT a FROM t1 WHERE t1.a=t2.a), a FROM t2 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = `t2`.`a`)) AS `(SELECT a FROM t1 WHERE t1.a=t2.a)`,`t2`.`a` AS `a` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "table_scan": { + "rows": 2, + "cost": 0.501099 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": "..." + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t2`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(`t1`.`a` = `t2`.`a`)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(`t1`.`a` = `t2`.`a`)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + } + ] /* rows_estimation */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "('2' = `t2`.`a`)", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "refine_plan": [ + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1,t2; +SET @@optimizer_trace_features="default"; +CREATE TABLE t1 (a FLOAT(5,4) zerofill); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +CREATE TABLE t2 (a FLOAT(5,4),b FLOAT(2,0)); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +SELECT t1.a +FROM t1 +WHERE t1.a= (SELECT b FROM t2 LIMIT 1) AND NOT +t1.a= (SELECT a FROM t2 LIMIT 1) ; +a + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT t1.a +FROM t1 +WHERE t1.a= (SELECT b FROM t2 LIMIT 1) AND NOT +t1.a= (SELECT a FROM t2 LIMIT 1) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t2`.`b` from `t2` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t2`.`a` from `t2` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `t1`.`a` AS `a` from `t1` where ((`t1`.`a` = (/* select#2 */ select `t2`.`b` from `t2` limit 1)) and (`t1`.`a` <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t1`.`a` = (/* select#2 */ select `t2`.`b` from `t2` limit 1)) and (`t1`.`a` <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": "((NULL <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)) and multiple equal((/* select#2 */ select NULL from `t2` limit 1), `t1`.`a`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((NULL <> (/* select#3 */ select `t2`.`a` from `t2` limit 1)) and multiple equal((/* select#2 */ select NULL from `t2` limit 1), `t1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +SELECT 1 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t2 WHERE a = 50 AND b = 3); +1 +1 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM DUAL +WHERE NOT EXISTS +(SELECT * FROM t2 WHERE a = 50 AND b = 3) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from DUAL where exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select 1 from `t2` where ((`t2`.`a` = 50) and (`t2`.`b` = 3))) is false" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`t2`.`a` = 50) and (`t2`.`b` = 3))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "((`t2`.`a` = 50) and (`t2`.`b` = 3))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "((`t2`.`a` = 50) and (`t2`.`b` = 3))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */, + "empty_result": { + "cause": "Impossible WHERE" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +SELECT 1 FROM DUAL WHERE NOT EXISTS (SELECT DISTINCT(a) FROM t2 GROUP BY a ORDER BY b); +1 +1 + +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT 1 FROM DUAL WHERE NOT EXISTS (SELECT DISTINCT(a) FROM t2 GROUP BY a ORDER BY b) { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "transformations_to_subquery": [ + "removed_ordering", + "removed_distinct", + "removed_grouping" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#2 */ select `t2`.`a` from `t2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select 1 AS `1` from DUAL where exists(/* select#2 */ select `t2`.`a` from `t2`) is false" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "exists(/* select#2 */ select `t2`.`a` from `t2`) is false", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select `t2`.`a` from `t2`) is false" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "exists(/* select#2 */ select `t2`.`a` from `t2`) is false" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "resulting_condition": null + } + ] /* steps */ + } /* condition_processing */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 + +DROP TABLE t1,t2; +# +# BUG#12905521 - ASSERT IN OPT_TRACE_STMT::SYNTAX_ERROR ON SELECT +# DISTINCT/MIN/JOIN/SUBQ QUERY +# +CREATE TABLE t1 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +CREATE TABLE t2 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +CREATE TABLE t3 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_time_key TIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_time_key), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +CREATE TABLE t4 ( +pk INTEGER, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_date_key DATE, +col_date_nokey DATE, +col_time_key TIME, +col_time_nokey TIME, +col_datetime_key DATETIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +INSERT IGNORE INTO t4 ( +col_int_key,col_int_nokey, +col_date_key,col_date_nokey, +col_time_key,col_time_nokey, +col_datetime_key,col_datetime_nokey, +col_varchar_key,col_varchar_nokey +) VALUES +(8,7,'2008-10-02','2008-10-02','04:07:22.028954','04:07:22.028954','2001-10-08 00:00:00','2001-10-08 00:00:00','g','g'); +Warnings: +Warning 1364 Field 'pk' doesn't have a default value +CREATE TABLE t5 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_date_key DATE, +col_date_nokey DATE, +col_time_key TIME, +col_time_nokey TIME, +col_datetime_key DATETIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_int_key), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM; +INSERT INTO t5 ( +col_int_key,col_int_nokey, +col_date_key,col_date_nokey, +col_time_key,col_time_nokey, +col_datetime_key,col_datetime_nokey, +col_varchar_key,col_varchar_nokey +) VALUES +(8,NULL,'2000-12-03','2000-12-03','22:55:23.019225','22:55:23.019225','2005-07-20 00:00:00','2005-07-20 00:00:00','x','x'), +(7,8,'2008-05-03','2008-05-03','10:19:31.050677','10:19:31.050677','2007-10-06 17:56:40.056051','2007-10-06 17:56:40.056051','d','d'), +(8,6,'2000-09-20','2000-09-20','14:11:27.044095','14:11:27.044095','2003-06-13 23:19:49.018300','2003-06-13 23:19:49.018300','c','c'); +set @old_opt_switch=@@optimizer_switch; +select distinct +alias1.`col_varchar_key` as field1 ,alias1.`col_date_key` as +field2 ,( select min( sq1_alias1.`col_varchar_nokey` ) as sq1_field1 from ( t1 +as sq1_alias1 inner join ( t5 as sq1_alias2 left join t5 as sq1_alias3 on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) where +exists ( select distinct c_sq1_alias2.`col_int_nokey` as c_sq1_field1 from ( +t3 as c_sq1_alias1 right join t4 as c_sq1_alias2 on (c_sq1_alias2.`col_int_nokey` = c_sq1_alias1.`pk` ) ) where +c_sq1_alias2.`col_varchar_key` = sq1_alias2.`col_varchar_nokey` ) ) as field3 +,( select max( sq2_alias1.`pk` ) as sq2_field1 from t5 as sq2_alias1 ) as +field4 ,alias2.`col_varchar_nokey` as field5 ,alias2.`col_varchar_nokey` as +field6 from ( t5 as alias1 right outer join ( ( ( select sq3_alias2.* from ( t5 as sq3_alias1 ,t4 as sq3_alias2 ) ) as alias2 right join t4 +as alias3 on (alias3.`col_varchar_key` = alias2.`col_varchar_key` ) ) ) on +(alias3.`col_int_key` = alias2.`pk` ) ) where ( alias1.`col_varchar_nokey` in +( select sq4_alias1.`col_varchar_key` as sq4_field1 from ( t3 as sq4_alias1 +inner join ( t2 as sq4_alias2 right outer join t3 as sq4_alias3 on +(sq4_alias3.`pk` = sq4_alias2.`col_int_key` ) ) on +(sq4_alias3.`col_varchar_nokey` = sq4_alias2.`col_varchar_key` ) ) where +sq4_alias2.`col_int_key` < alias1.`col_int_nokey` and +sq4_alias3.`col_varchar_nokey` <> alias1.`col_varchar_key` ) ) and +alias1.`col_int_key` not in (214) group by field1,field2,field3, +field4,field5,field6; +field1 field2 field3 field4 field5 field6 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select distinct +alias1.`col_varchar_key` as field1 ,alias1.`col_date_key` as +field2 ,( select min( sq1_alias1.`col_varchar_nokey` ) as sq1_field1 from ( t1 +as sq1_alias1 inner join ( t5 as sq1_alias2 left join t5 as sq1_alias3 on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) on +(sq1_alias3.`col_varchar_nokey` = sq1_alias2.`col_varchar_key` ) ) where +exists ( select distinct c_sq1_alias2.`col_int_nokey` as c_sq1_field1 from ( +t3 as c_sq1_alias1 right join t4 as c_sq1_alias2 on (c_sq1_alias2.`col_int_nokey` = c_sq1_alias1.`pk` ) ) where +c_sq1_alias2.`col_varchar_key` = sq1_alias2.`col_varchar_nokey` ) ) as field3 +,( select max( sq2_alias1.`pk` ) as sq2_field1 from t5 as sq2_alias1 ) as +field4 ,alias2.`col_varchar_nokey` as field5 ,alias2.`col_varchar_nokey` as +field6 from ( t5 as alias1 right outer join ( ( ( select sq3_alias2.* from ( t5 as sq3_alias1 ,t4 as sq3_alias2 ) ) as alias2 right join t4 +as alias3 on (alias3.`col_varchar_key` = alias2.`col_varchar_key` ) ) ) on +(alias3.`col_int_key` = alias2.`pk` ) ) where ( alias1.`col_varchar_nokey` in +( select sq4_alias1.`col_varchar_key` as sq4_field1 from ( t3 as sq4_alias1 +inner join ( t2 as sq4_alias2 right outer join t3 as sq4_alias3 on +(sq4_alias3.`pk` = sq4_alias2.`col_int_key` ) ) on +(sq4_alias3.`col_varchar_nokey` = sq4_alias2.`col_varchar_key` ) ) where +sq4_alias2.`col_int_key` < alias1.`col_int_nokey` and +sq4_alias3.`col_varchar_nokey` <> alias1.`col_varchar_key` ) ) and +alias1.`col_int_key` not in (214) group by field1,field2,field3, +field4,field5,field6 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select `sq3_alias2`.`pk` AS `pk`,`sq3_alias2`.`col_int_nokey` AS `col_int_nokey`,`sq3_alias2`.`col_int_key` AS `col_int_key`,`sq3_alias2`.`col_date_key` AS `col_date_key`,`sq3_alias2`.`col_date_nokey` AS `col_date_nokey`,`sq3_alias2`.`col_time_key` AS `col_time_key`,`sq3_alias2`.`col_time_nokey` AS `col_time_nokey`,`sq3_alias2`.`col_datetime_key` AS `col_datetime_key`,`sq3_alias2`.`col_datetime_nokey` AS `col_datetime_nokey`,`sq3_alias2`.`col_varchar_key` AS `col_varchar_key`,`sq3_alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from (`t5` `sq3_alias1` join `t4` `sq3_alias2`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": "`` `alias2`", + "select#": 5, + "merged": true + } /* derived */ + }, + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "transformations_to_subquery": [ + "removed_distinct" + ] /* transformations_to_subquery */ + }, + { + "expanded_query": "/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from (`t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`))) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from (`t1` `sq1_alias1` join (`t5` `sq1_alias2` left join `t5` `sq1_alias3` on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) where exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from (`t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`))) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select max(`sq2_alias1`.`pk`) AS `sq2_field1` from `t5` `sq2_alias1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 6, + "steps": [ + { + "expanded_query": "/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from (`t3` `sq4_alias1` join (`t3` `sq4_alias3` left join `t2` `sq4_alias2` on((`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`))) on((`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`))) where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`))" + }, + { + "transformation": { + "select#": 6, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "expanded_query": "/* select#1 */ select `alias1`.`col_varchar_key` AS `field1`,`alias1`.`col_date_key` AS `field2`,(/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from (`t1` `sq1_alias1` join (`t5` `sq1_alias2` left join `t5` `sq1_alias3` on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) on((`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) where exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from (`t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`))) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`))) AS `field3`,(/* select#4 */ select max(`sq2_alias1`.`pk`) AS `sq2_field1` from `t5` `sq2_alias1`) AS `field4`,`sq3_alias2`.`col_varchar_nokey` AS `field5`,`sq3_alias2`.`col_varchar_nokey` AS `field6` from ((`t4` `alias3` left join ((`t5` `sq3_alias1` join `t4` `sq3_alias2`)) on((`alias3`.`col_varchar_key` = `sq3_alias2`.`col_varchar_key`))) left join `t5` `alias1` on((`alias3`.`col_int_key` = `sq3_alias2`.`pk`))) where ((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from (`t3` `sq4_alias1` join (`t3` `sq4_alias3` left join `t2` `sq4_alias2` on((`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`))) on((`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`))) where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`)))) and (`alias1`.`col_int_key` <> 214)) group by `field1`,`field2`,`field3`,`field4`,`field5`,`field6`" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`))" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from `t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`)) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from `t1` `sq1_alias1` join `t5` `sq1_alias2` join `t5` `sq1_alias3` where (exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from `t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`)) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))" + } /* transformations_to_nested_joins */ + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "outer_join_to_inner_join", + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select `alias1`.`col_varchar_key` AS `field1`,`alias1`.`col_date_key` AS `field2`,(/* select#2 */ select min(`sq1_alias1`.`col_varchar_nokey`) AS `sq1_field1` from `t1` `sq1_alias1` join `t5` `sq1_alias2` join `t5` `sq1_alias3` where (exists(/* select#3 */ select `c_sq1_alias2`.`col_int_nokey` AS `c_sq1_field1` from `t4` `c_sq1_alias2` left join `t3` `c_sq1_alias1` on((`c_sq1_alias2`.`col_int_nokey` = `c_sq1_alias1`.`pk`)) where (`c_sq1_alias2`.`col_varchar_key` = `sq1_alias2`.`col_varchar_nokey`)) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`) and (`sq1_alias3`.`col_varchar_nokey` = `sq1_alias2`.`col_varchar_key`))) AS `field3`,(/* select#4 */ select max(`sq2_alias1`.`pk`) AS `sq2_field1` from `t5` `sq2_alias1`) AS `field4`,`sq3_alias2`.`col_varchar_nokey` AS `field5`,`sq3_alias2`.`col_varchar_nokey` AS `field6` from `t4` `alias3` join `t5` `sq3_alias1` join `t4` `sq3_alias2` join `t5` `alias1` where ((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and (`alias3`.`col_int_key` = `sq3_alias2`.`pk`) and (`alias3`.`col_varchar_key` = `sq3_alias2`.`col_varchar_key`)) group by `field1`,`field2`,`field3`,`field4`,`field5`,`field6`" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and (`alias3`.`col_int_key` = `sq3_alias2`.`pk`) and (`alias3`.`col_varchar_key` = `sq3_alias2`.`col_varchar_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and multiple equal(`alias3`.`col_int_key`, `sq3_alias2`.`pk`) and multiple equal(`alias3`.`col_varchar_key`, `sq3_alias2`.`col_varchar_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and multiple equal(`alias3`.`col_int_key`, `sq3_alias2`.`pk`) and multiple equal(`alias3`.`col_varchar_key`, `sq3_alias2`.`col_varchar_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "((`alias1`.`col_varchar_nokey`,(/* select#6 */ select `sq4_alias1`.`col_varchar_key` AS `sq4_field1` from `t3` `sq4_alias1` join `t3` `sq4_alias3` join `t2` `sq4_alias2` where ((`sq4_alias2`.`col_int_key` < `alias1`.`col_int_nokey`) and (`sq4_alias3`.`col_varchar_nokey` <> `alias1`.`col_varchar_key`) and ((`alias1`.`col_varchar_nokey`) = `sq4_alias1`.`col_varchar_key`) and (`sq4_alias3`.`col_varchar_nokey` = `sq4_alias2`.`col_varchar_key`) and (`sq4_alias3`.`pk` = `sq4_alias2`.`col_int_key`)))) and (`alias1`.`col_int_key` <> 214) and multiple equal(`alias3`.`col_int_key`, `sq3_alias2`.`pk`) and multiple equal(`alias3`.`col_varchar_key`, `sq3_alias2`.`col_varchar_key`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t4` `alias3`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t5` `sq3_alias1`", + "row_may_be_null": true, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t4` `sq3_alias2`", + "row_may_be_null": true, + "map_bit": 2, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t5` `alias1`", + "row_may_be_null": true, + "map_bit": 3, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t4` `alias3`", + "field": "col_varchar_key", + "equals": "`sq3_alias2`.`col_varchar_key`", + "null_rejecting": true + }, + { + "table": "`t4` `alias3`", + "field": "col_int_key", + "equals": "`sq3_alias2`.`pk`", + "null_rejecting": true + }, + { + "table": "`t4` `sq3_alias2`", + "field": "pk", + "equals": "`alias3`.`col_int_key`", + "null_rejecting": true + }, + { + "table": "`t4` `sq3_alias2`", + "field": "col_varchar_key", + "equals": "`alias3`.`col_varchar_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t4` `alias3`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + }, + { + "table": "`t5` `sq3_alias1`", + "table_scan": { + "rows": 3, + "cost": 0.508545 + } /* table_scan */ + }, + { + "table": "`t4` `sq3_alias2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": false + }, + { + "table": "`t5` `alias1`", + "range_analysis": { + "table_scan": { + "rows": 3, + "cost": 2.90854 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "col_int_key", + "usable": true, + "key_parts": [ + "col_int_key" + ] /* key_parts */ + }, + { + "index": "col_varchar_key", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "impossible_range": true + } /* range_analysis */, + "rows": 0, + "cause": "impossible_where_condition" + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + "`t4` `alias3`", + "`t4` `sq3_alias2`", + "`t5` `alias1`" + ] /* plan_prefix */, + "table": "`t5` `sq3_alias1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 3, + "access_type": "scan", + "resulting_rows": 3, + "cost": 0.808545, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 3, + "cost_for_plan": 0.808545, + "chosen": true + } + ] /* considered_execution_plans */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +set optimizer_switch=@old_opt_switch; +drop table t1,t2,t3,t4,t5; +# +# BUG#12905758 - ASSERT IN OPT_TRACE_STMT::SYNTAX_ERROR ON +# SELECT/SUBQ/SUM QUERY +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT, +col_int_nokey INTEGER, +col_int_key INTEGER, +col_date_key DATE, +col_date_nokey DATE, +col_time_key TIME, +col_time_nokey TIME, +col_datetime_key DATETIME, +col_datetime_nokey DATETIME, +col_varchar_key VARCHAR(1), +col_varchar_nokey VARCHAR(1), +PRIMARY KEY (pk), +KEY (col_varchar_key,col_int_key) +) ENGINE=MYISAM, CHARSET utf8mb4; +INSERT INTO t1 ( +col_int_key,col_int_nokey, +col_date_key,col_date_nokey, +col_time_key,col_time_nokey, +col_datetime_key,col_datetime_nokey, +col_varchar_key,col_varchar_nokey +) VALUES +(8,NULL,'2000-12-03','2000-12-03','22:55:23.019225','22:55:23.019225','2005-07-20 00:00:00','2005-07-20 00:00:00','x','x'), +(8,6,'2000-09-20','2000-09-20','14:11:27.044095','14:11:27.044095','2003-06-13 23:19:49.018300','2003-06-13 23:19:49.018300','c','c'); +CREATE TABLE t2 (I INTEGER); +select ( select sum( subquery1_t1.`col_int_nokey` ) as subquery1_field1 from +t1 as subquery1_t1 ) as field1 from ( t1 as table1 straight_join t1 as table2 +on (table2.`col_varchar_key` = table1.`col_varchar_key` ) ) where ( +table2.`col_int_nokey` <> any ( select 5 from t2 ) ) and table1.`pk` in +(192,18) order by field1 desc; +field1 +select * from information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +select ( select sum( subquery1_t1.`col_int_nokey` ) as subquery1_field1 from +t1 as subquery1_t1 ) as field1 from ( t1 as table1 straight_join t1 as table2 +on (table2.`col_varchar_key` = table1.`col_varchar_key` ) ) where ( +table2.`col_int_nokey` <> any ( select 5 from t2 ) ) and table1.`pk` in +(192,18) order by field1 desc { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select 5 from `t2`" + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "EXISTS (CORRELATED SELECT)", + "chosen": true, + "evaluating_constant_where_conditions": [ + ] /* evaluating_constant_where_conditions */ + } /* transformation */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "IN_uses_bisection": true + }, + { + "expanded_query": "/* select#1 */ select (/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`) AS `field1` from (`t1` `table1` straight_join `t1` `table2` on((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`))) where (((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18))) order by `field1` desc" + }, + { + "transformations_to_nested_joins": { + "transformations": [ + "JOIN_condition_to_WHERE", + "parenthesis_removal" + ] /* transformations */, + "expanded_query": "/* select#1 */ select (/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`) AS `field1` from `t1` `table1` straight_join `t1` `table2` where (((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and (`table2`.`col_varchar_key` = `table1`.`col_varchar_key`)) order by `field1` desc" + } /* transformations_to_nested_joins */ + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and (`table2`.`col_varchar_key` = `table1`.`col_varchar_key`))", + "steps": [ + { + "transformation": "equality_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and multiple equal(`table2`.`col_varchar_key`, `table1`.`col_varchar_key`))" + }, + { + "transformation": "constant_propagation", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and multiple equal(`table2`.`col_varchar_key`, `table1`.`col_varchar_key`))" + }, + { + "transformation": "trivial_condition_removal", + "subselect_evaluation": [ + ] /* subselect_evaluation */, + "resulting_condition": "(((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)) and multiple equal(`table2`.`col_varchar_key`, `table1`.`col_varchar_key`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1` `table1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`t1` `table2`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + 0 + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`t1` `table1`", + "field": "col_varchar_key", + "equals": "`table2`.`col_varchar_key`", + "null_rejecting": true + }, + { + "table": "`t1` `table2`", + "field": "col_varchar_key", + "equals": "`table1`.`col_varchar_key`", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t1` `table1`", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80562 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": true, + "key_parts": [ + "pk" + ] /* key_parts */ + }, + { + "index": "col_varchar_key", + "usable": false, + "cause": "not_applicable" + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "PRIMARY", + "ranges": [ + "18 <= pk <= 18", + "192 <= pk <= 192" + ] /* ranges */, + "index_dives_for_eq_ranges": true, + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 2, + "cost": 1.21, + "chosen": true + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */, + "chosen_range_access_summary": { + "range_access_plan": { + "type": "range_scan", + "index": "PRIMARY", + "rows": 2, + "ranges": [ + "18 <= pk <= 18", + "192 <= pk <= 192" + ] /* ranges */ + } /* range_access_plan */, + "rows_for_plan": 2, + "cost_for_plan": 1.21, + "chosen": true + } /* chosen_range_access_summary */ + } /* range_analysis */ + }, + { + "table": "`t1` `table2`", + "table_scan": { + "rows": 2, + "cost": 0.505615 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `table1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_varchar_key", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "range", + "range_details": { + "used_index": "PRIMARY" + } /* range_details */, + "resulting_rows": 2, + "cost": 1.41, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 1.41, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1` `table1`" + ] /* plan_prefix */, + "table": "`t1` `table2`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "col_varchar_key", + "rows": 2, + "cost": 1.4, + "chosen": true + }, + { + "rows_to_scan": 2, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 2, + "cost": 0.905658, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 4, + "cost_for_plan": 2.31566, + "chosen": true + } + ] /* rest_of_plan */ + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))) and (`table1`.`pk` in (192,18)))", + "attached_conditions_computation": [ + { + "table": "`t1` `table2`", + "rechecking_index_usage": { + "recheck_reason": "not_first_table", + "range_analysis": { + "table_scan": { + "rows": 2, + "cost": 2.80562 + } /* table_scan */, + "potential_range_indexes": [ + { + "index": "PRIMARY", + "usable": false, + "cause": "not_applicable" + }, + { + "index": "col_varchar_key", + "usable": true, + "key_parts": [ + "col_varchar_key", + "col_int_key" + ] /* key_parts */ + } + ] /* potential_range_indexes */, + "setup_range_conditions": [ + ] /* setup_range_conditions */, + "group_index_range": { + "chosen": false, + "cause": "not_single_table" + } /* group_index_range */, + "skip_scan_range": { + "chosen": false, + "cause": "not_single_table" + } /* skip_scan_range */, + "analyzing_range_alternatives": { + "range_scan_alternatives": [ + { + "index": "col_varchar_key", + "chosen": false, + "cause": "depends_on_unread_values" + } + ] /* range_scan_alternatives */, + "analyzing_roworder_intersect": { + "usable": false, + "cause": "too_few_roworder_scans" + } /* analyzing_roworder_intersect */ + } /* analyzing_range_alternatives */ + } /* range_analysis */ + } /* rechecking_index_usage */ + } + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1` `table1`", + "attached": "(`table1`.`pk` in (192,18))" + }, + { + "table": "`t1` `table2`", + "attached": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))))" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`field1` desc", + "items": [ + { + "item": "(/* select#2 */ select sum(`subquery1_t1`.`col_int_nokey`) AS `subquery1_field1` from `t1` `subquery1_t1`)", + "subselect_evaluation": [ + { + "subselect_execution": { + "select#": 2, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1` `subquery1_t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1` `subquery1_t1`", + "table_scan": { + "rows": 2, + "cost": 0.505615 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1` `subquery1_t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 0.705615, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 0.705615, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1` `subquery1_t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1` `subquery1_t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ + } /* subselect_execution */ + } + ] /* subselect_evaluation */, + "uses_only_constant_tables": true + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "" + } /* simplifying_order_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`t1` `table1`", + "original_table_condition": "(`table1`.`pk` in (192,18))", + "final_table_condition ": "(`table1`.`pk` in (192,18))" + }, + { + "table": "`t1` `table2`", + "original_table_condition": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))))", + "final_table_condition ": "((`table2`.`col_varchar_key` = `table1`.`col_varchar_key`) and ((`table2`.`col_int_nokey`,(/* select#3 */ select 5 from `t2` where (outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)))))" + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1` `table1`", + "pushed_index_condition": "(`table1`.`pk` in (192,18))", + "table_condition_attached": null + }, + { + "table": "`t1` `table2`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(outer_field_is_not_null, ((`table2`.`col_int_nokey`) <> 5), true)" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t2`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`t2`", + "rows": 1, + "cost": 1, + "table_type": "system", + "empty": true + } + ] /* rows_estimation */ + }, + { + "transformation": { + "select#": 3, + "from": "IN (SELECT)", + "to": "materialization", + "possible": false, + "cause": "not an IN predicate" + } /* transformation */ + } + ] /* steps */, + "empty_result": { + "cause": "no matching row in const table" + } /* empty_result */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +drop table t1,t2; + +# +# Tracing of semijoin loosescan +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)) charset utf8mb4; +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; +set @old_opt_switch=@@optimizer_switch; +set optimizer_switch="firstmatch=off,materialization=off,duplicateweedout=off"; +set @old_opt_prune_level=@@optimizer_prune_level; +set optimizer_prune_level=0; +explain select * from t2 where a in (select b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 3)) +# Equality-propagation involving inner field => 1st sj equality is bound +explain select * from t2 where (b+0,a+0) in (select a,b from t1 where a=3); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a a 5 const 8 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = 3) and ((`test`.`t2`.`b` + 0) = 3) and ((`test`.`t2`.`a` + 0) = `test`.`t1`.`b`)) +# Equality-propagation involving outer field => 3rd sj equality is bound. +explain select * from t2 where (b,a,filler) in (select a,b,a*3 from t1) and filler='abc'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index a a 10 NULL 100 100.00 Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t2`.`filler` = 'abc') and (cast(`test`.`t2`.`filler` as double) = cast((`test`.`t1`.`a` * 3) as double))) +SELECT show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +"recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 0.1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 10, + "cost": 112.038, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } +# Remove the condition on 'filler' => 3rd sj equality is not bound. +explain select * from t2 where (b,a,filler) in (select a,b,a*3 from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where +1 SIMPLE t1 NULL ref a a 10 test.t2.b,test.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = `test`.`t2`.`b`) and (cast(`test`.`t2`.`filler` as double) = cast((`test`.`t2`.`b` * 3) as double))) +SELECT show_json_object('"searching_loose_scan_index": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"searching_loose_scan_index": {', TRACE) +"searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } +# Equality-propagation involving outer field => 3rd sj equality is bound. +explain select * from t2 as t3, t2 +where t2.filler=t3.filler and +(t2.b,t2.a,t2.filler) in (select a,b,a*3 from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +1 SIMPLE t1 NULL index a a 10 NULL 100 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` `t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`a`) and (`test`.`t2`.`filler` = `test`.`t3`.`filler`) and (cast(`test`.`t3`.`filler` as double) = cast((`test`.`t1`.`a` * 3) as double))) +SELECT show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"recalculate_access_paths_and_cost": {', TRACE) +"recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } +# In plan t3-t1-t2, 3rd outer expression is dependent only on +# previous tables => 3rd sj equality is bound. +# If t1 is before t3, 3rd sj equality is not bound. +explain select * from t2 as t3 left join t2 on t2.filler+10=t3.filler+20 +where (t2.b,t2.a,t3.filler+2) in (select a,b,a*3 from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +1 SIMPLE t1 NULL index a a 10 NULL 100 100.00 Using where; Using index; LooseScan +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 1.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` `t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`a`) and ((`test`.`t3`.`filler` + 2) = (`test`.`t1`.`a` * 3)) and ((`test`.`t2`.`filler` + 10) = (`test`.`t3`.`filler` + 20))) +SELECT show_json_object('"considered_execution_plans": [', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"considered_execution_plans": [', TRACE) +"considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 12.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016.46, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`", + "`t2`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 3500, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 32, + "resulting_rows": 100, + "cost": 100097, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 4516.46, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 6517.46, + "rows": 10000, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016.46, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2` `t3`", + "`t1`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 1, + "rows_for_plan": 10000, + "cost_for_plan": 101067, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_1": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "cost": 101065, + "rows": 100, + "chosen": true + }, + { + "strategy": "DuplicatesWeedout", + "cost": 102078, + "rows": 100, + "duplicate_tables_left": false, + "chosen": false + } + ] /* semijoin_strategy_choice */, + "chosen": true, + "cause": "previous_plan_used_disabled_strategy" + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 12.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016.46, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2`", + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 3500, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 32, + "resulting_rows": 100, + "cost": 100097, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 4516.46, + "semijoin_strategy_choice": [ + { + "strategy": "DuplicatesWeedout", + "cost": 6517.46, + "rows": 10000, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": false, + "cause": "plan_uses_disabled_strategy" + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t2`" + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 35, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.46, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 47.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t2`", + "`t1`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.48, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1051.47, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "rows": 1, + "cost": 35, + "chosen": true + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": false + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_2": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 3052.47, + "rows": 10000, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": false, + "cause": "plan_uses_disabled_strategy" + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 100, + "cost_for_plan": 12.9963, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.01, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 1016, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2` `t3`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 16, + "resulting_rows": 100, + "cost": 100051, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 1, + "rows_for_plan": 10000, + "cost_for_plan": 101067, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_3": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 102078, + "rows": 100, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "pruned_by_cost": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + "`t1`" + ] /* plan_prefix */, + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.01, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 1, + "rows_for_plan": 100, + "cost_for_plan": 1016, + "semijoin_strategy_choice": [ + ] /* semijoin_strategy_choice */, + "rest_of_plan": [ + { + "plan_prefix": [ + "`t1`", + "`t2`" + ] /* plan_prefix */, + "table": "`t2` `t3`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 1, + "resulting_rows": 100, + "cost": 1003.48, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 10000, + "cost_for_plan": 2019.48, + "semijoin_strategy_choice": [ + { + "strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 12.9963, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_4": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "index_handles_needed_semijoin_equalities": false + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */, + "chosen": false + }, + { + "strategy": "DuplicatesWeedout", + "cost": 3030.48, + "rows": 100, + "duplicate_tables_left": true, + "chosen": true + } + ] /* semijoin_strategy_choice */, + "chosen": false, + "cause": "plan_uses_disabled_strategy" + } + ] /* rest_of_plan */ + } + ] /* rest_of_plan */ + }, + { + "final_semijoin_strategy": "LooseScan", + "recalculate_access_paths_and_cost": { + "tables": [ + { + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "a", + "usable": false, + "chosen": false + }, + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "resulting_rows": 100, + "cost": 1299.63, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "unknown_key_5": { + "searching_loose_scan_index": { + "indexes": [ + { + "index": "a", + "covering_scan": { + "cost": 1.04839, + "chosen": true + } /* covering_scan */ + } + ] /* indexes */ + } /* searching_loose_scan_index */ + } + }, + { + "table": "`t2`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 100, + "filtering_effect": [ + ] /* filtering_effect */, + "final_filtering_effect": 1, + "access_type": "scan", + "using_join_cache": true, + "buffers_needed": 32, + "resulting_rows": 100, + "cost": 100097, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */ + } + ] /* tables */ + } /* recalculate_access_paths_and_cost */ + } + ] +drop table t0,t1,t2; +# +# Discover bound equality thanks to equality propagation +# specific of ON clause. +# +CREATE TABLE t1 ( +a int(11) DEFAULT NULL, +b varchar(100) DEFAULT NULL, +c int(11) DEFAULT NULL, +KEY b_c_a (b,c,a) +) ENGINE=InnoDB, CHARSET utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +explain select * +from t1 left join t1 as t2 +on (t2.a= t1.a and (t2.a,t2.b) in (select a,b from t1 as t3)) +where t1.a < 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL b_c_a 413 NULL 1 100.00 Using where; Using index +2 SIMPLE t3 NULL index b_c_a b_c_a 413 NULL 1 100.00 Using where; Using index; LooseScan +2 SIMPLE t2 NULL ref b_c_a b_c_a 403 test.t3.b 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` left join (`test`.`t1` `t2` semi join (`test`.`t1` `t3`)) on(((`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))) where (`test`.`t1`.`a` < 5) +drop table t1; +# +# Show that loosescan planning is not dependent on order of +# creation of indexes anymore. +# +create table it(a int, b int, index a_b (a,b), index a (a)) +engine=InnoDB; +insert into it values(1,1),(2,3),(4,3); +select * from it as ot +where (ot.a,ot.b) in (select it.a,it.b from it where it.b=3); +a b +2 3 +4 3 +select TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +from information_schema.optimizer_trace; +TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +0 +drop table it; +create table it(a int, b int, index a (a),index a_b (a,b)) +engine=InnoDB; +insert into it values(1,1),(2,3),(4,3); +select * from it as ot +where (ot.a,ot.b) in (select it.a,it.b from it where it.b=3); +a b +2 3 +4 3 +select TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +from information_schema.optimizer_trace; +TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +0 +drop table it; +# +# Show that we reject LooseScan if no handled key parts +# +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE=INNODB; +CREATE TABLE t2 (a INT, b INT) ENGINE=INNODB; +EXPLAIN SELECT * FROM t2 AS t3, t2 +WHERE t2.b=t3.b AND +(t2.b) IN (SELECT b*3 FROM t1 WHERE a=10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (hash join) +2 SIMPLE t1 NULL ref a a 5 const 1 100.00 Using where; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` `t3` join `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = 10) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` = (`test`.`t1`.`b` * 3))) +SELECT TRACE LIKE '%"some_index_part_used": false%' +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +TRACE LIKE '%"some_index_part_used": false%' +1 +DROP TABLE t1,t2; +# +# Show that we detect a hole in sequence of key parts +# +CREATE TABLE ot1 (a INTEGER); +INSERT INTO ot1 VALUES (0),(1),(3),(7); +CREATE TABLE it1 (a VARCHAR(1), b INTEGER, KEY (a,b)) CHARSET utf8mb4; +INSERT INTO it1 VALUES ('a',7), ('b',7); +CREATE TABLE it2 (a VARCHAR(1), b INTEGER, KEY (a,b)) CHARSET utf8mb4; +INSERT INTO it2 VALUES ('a',7), ('b',7); +explain SELECT * FROM ot1 +WHERE a IN ( +SELECT it1.b +FROM it1 JOIN it2 +ON it1.a = it2.a +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE it1 NULL index a a 12 NULL 2 100.00 Using index; Start temporary +1 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (hash join) +1 SIMPLE it2 NULL index a a 12 NULL 2 50.00 Using where; Using index; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`it2`.`a` = `test`.`it1`.`a`) and (`test`.`ot1`.`a` = `test`.`it1`.`b`)) +SELECT TRACE LIKE '%"index_can_remove_duplicates": false%' +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +TRACE LIKE '%"index_can_remove_duplicates": false%' +1 +DROP TABLE ot1, it1, it2; +# +# Show that handled keyparts cannot be on prefix +# +create table t1 (a int, b varchar(100), key a_b (a,b)) charset utf8mb4; +insert into t1 values(25,'111111'),(25,'1111112'); +explain select * from t1 as t2 where t2.b in (select b from t1 where a=25); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_b a_b 5 const 1 100.00 Using index; LooseScan +1 SIMPLE t2 NULL index NULL a_b 408 NULL 2 50.00 Using where; Using index; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t2` semi join (`test`.`t1`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 25)) +select * from t1 as t2 where t2.b in (select b from t1 where a=25); +a b +25 111111 +25 1111112 +alter table t1 drop key a_b, add key a_b_prefix (a,b(2)); +explain select * from t1 as t2 where t2.b in (select b from t1 where a=25); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ref a_b_prefix a_b_prefix 5 const 1 100.00 Start temporary +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` `t2` semi join (`test`.`t1`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = 25)) +select * from t1 as t2 where t2.b in (select b from t1 where a=25); +a b +25 111111 +25 1111112 +select TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +from information_schema.optimizer_trace; +TRACE LIKE '%"index_handles_needed_semijoin_equalities": false%' +1 +drop table t1; +set optimizer_switch=@old_opt_switch; +set optimizer_prune_level=@old_opt_prune_level; +# Tracing of CTEs using the same tmp table: observe +# "reusing_tmp_table" and only one "creating_tmp_table". +with q(a) as (select 1 union all select 2) +select * from q, q q1 where q.a=1 and q1.a=2; +a a +1 2 +select TRACE from information_schema.optimizer_trace; +TRACE +{ + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 AS `1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select 2 AS `2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": "`q`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "join_preparation": { + "select#": 4, + "steps": [ + { + "expanded_query": "/* select#4 */ select 1 AS `1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 5, + "steps": [ + { + "expanded_query": "/* select#5 */ select 2 AS `2`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": "`q` `q1`", + "select#": 4, + "materialized": true, + "reusing_tmp_table": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select `q`.`a` AS `a`,`q1`.`a` AS `a` from `q` join `q` `q1` where ((`q`.`a` = 1) and (`q1`.`a` = 2))" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 4, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 5, + "steps": [ + ] /* steps */ + } /* join_optimization */ + }, + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "((`q`.`a` = 1) and (`q1`.`a` = 2))", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "(multiple equal(1, `q`.`a`) and multiple equal(2, `q1`.`a`))" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "(multiple equal(1, `q`.`a`) and multiple equal(2, `q1`.`a`))" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "(multiple equal(1, `q`.`a`) and multiple equal(2, `q1`.`a`))" + } + ] /* steps */ + } /* condition_processing */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`q`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + }, + { + "table": "`q` `q1`", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "ref_optimizer_key_uses": [ + { + "table": "`q`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`q`", + "field": "a", + "equals": "1", + "null_rejecting": true + }, + { + "table": "`q` `q1`", + "field": "a", + "equals": "2", + "null_rejecting": true + }, + { + "table": "`q` `q1`", + "field": "a", + "equals": "2", + "null_rejecting": true + } + ] /* ref_optimizer_key_uses */ + }, + { + "rows_estimation": [ + { + "table": "`q`", + "table_scan": { + "rows": 2, + "cost": 2.525 + } /* table_scan */ + }, + { + "table": "`q` `q1`", + "table_scan": { + "rows": 2, + "cost": 2.525 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`q`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "cost": 2.725, + "rows": 2, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "rest_of_plan": [ + { + "plan_prefix": [ + "`q`" + ] /* plan_prefix */, + "table": "`q` `q1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "cost": 2.725, + "rows": 2, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.7, + "chosen": true + } + ] /* rest_of_plan */ + }, + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`q` `q1`", + "best_access_path": { + "considered_access_paths": [ + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": true + }, + { + "access_type": "ref", + "index": "", + "rows": 1, + "cost": 0.35, + "chosen": false + }, + { + "access_type": "scan", + "cost": 2.725, + "rows": 2, + "chosen": false, + "cause": "cost" + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 1, + "cost_for_plan": 0.35, + "pruned_by_heuristic": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": "((`q1`.`a` = 2) and (`q`.`a` = 1))", + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`q`", + "attached": "(`q`.`a` = 1)" + }, + { + "table": "`q` `q1`", + "attached": "(`q1`.`a` = 2)" + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + { + "table": "`q`", + "original_table_condition": "(`q`.`a` = 1)", + "final_table_condition ": null + }, + { + "table": "`q` `q1`", + "original_table_condition": "(`q1`.`a` = 2)", + "final_table_condition ": null + } + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`q`" + }, + { + "table": "`q` `q1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`q`", + "in_plan_at_position": 0, + "columns": 1, + "row_length": 9, + "key_length": 8, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} +# Tracing of repetitions of the recursive member +# can be silenced with repeated_subselect=off +with recursive qn(n) as +(select 1 union all select n+1 from qn where n<4) +select count(*) from qn; +count(*) +4 +SELECT show_json_object('"join_execution": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"join_execution": {', TRACE) +"join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`qn`", + "in_plan_at_position": 0, + "columns": 1, + "row_length": 9, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } +SET @@optimizer_trace_features="repeated_subselect=off"; +with recursive qn(n) as +(select 1 union all select n+1 from qn where n<4) +select count(*) from qn; +count(*) +4 +SELECT show_json_object('"join_execution": {', TRACE) +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +show_json_object('"join_execution": {', TRACE) +"join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "`qn`", + "in_plan_at_position": 0, + "columns": 1, + "row_length": 9, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } +SET @@optimizer_trace_features=default; +drop function show_json_object; diff --git a/mysql-test/suite/opt_trace/r/temp_table.result-pq b/mysql-test/suite/opt_trace/r/temp_table.result-pq new file mode 100644 index 000000000..5d1bc41a2 --- /dev/null +++ b/mysql-test/suite/opt_trace/r/temp_table.result-pq @@ -0,0 +1,1399 @@ +SET optimizer_trace_max_mem_size=1048576; +SET optimizer_trace="enabled=on,one_line=off"; +SET end_markers_in_json="on"; +CREATE TABLE tmp ( +pk INT PRIMARY KEY AUTO_INCREMENT, +col1 CHAR (1) +); +INSERT INTO tmp(col1) VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'); +CREATE TABLE t1 ( +uniq VARCHAR(10), +col1 VARCHAR(10), +col2 VARCHAR(1024) +) CHARSET utf8mb4; +INSERT INTO t1 SELECT pk, col1, col1 FROM tmp; +SELECT uniq, col1 FROM t1 GROUP BY col2,uniq LIMIT 3; +uniq col1 +1 a +2 b +3 c +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT uniq, col1 FROM t1 GROUP BY col2,uniq LIMIT 3 { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`uniq` AS `uniq`,`t1`.`col1` AS `col1` from `t1` group by `t1`.`col2`,`t1`.`uniq` limit 3" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 8, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 8, + "access_type": "scan", + "resulting_rows": 8, + "cost": 1.05, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 1.05, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`col2`,`t1`.`uniq`", + "items": [ + { + "item": "`t1`.`col2`" + }, + { + "item": "`t1`.`uniq`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`col2`,`t1`.`uniq`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 4, + "row_length": 4190, + "key_length": 8, + "unique_constraint": true, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq ; +uniq col1 col2 +1 a a +2 b b +3 c c +4 d d +5 e e +6 f f +7 g g +8 h h +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`uniq` AS `uniq`,`t1`.`col1` AS `col1`,`t1`.`col2` AS `col2` from `t1` group by `t1`.`uniq`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 8, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 8, + "access_type": "scan", + "resulting_rows": 8, + "cost": 1.05, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 8, + "cost_for_plan": 1.05, + "sort_cost": 8, + "new_cost_for_plan": 9.05, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`uniq`", + "items": [ + { + "item": "`t1`.`uniq`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`uniq`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 3, + "row_length": 4182, + "key_length": 43, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "TempTable" + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 1, + "steps": [ + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +select @@tmp_table_size; +@@tmp_table_size +16777216 +SET @old_size= @@tmp_table_size; +SET SESSION tmp_table_size= 1024; +SET SESSION internal_tmp_mem_storage_engine='memory'; +INSERT INTO t1 SELECT pk+8, col1, col1 FROM tmp; +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq; +uniq col1 col2 +1 a a +10 b b +11 c c +12 d d +13 e e +14 f f +15 g g +16 h h +2 b b +3 c c +4 d d +5 e e +6 f f +7 g g +8 h h +9 a a +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT uniq, col1, col2 FROM t1 GROUP BY uniq { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `t1`.`uniq` AS `uniq`,`t1`.`col1` AS `col1`,`t1`.`col2` AS `col2` from `t1` group by `t1`.`uniq`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 16, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 16, + "access_type": "scan", + "resulting_rows": 16, + "cost": 1.85, + "chosen": true, + "use_tmp_table": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 16, + "cost_for_plan": 1.85, + "sort_cost": 16, + "new_cost_for_plan": 17.85, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_group_by": { + "original_clause": "`t1`.`uniq`", + "items": [ + { + "item": "`t1`.`uniq`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`t1`.`uniq`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "make_parallel_query_plan": { + "select#": 1, + "detail": [ + { + "table": "`t1`", + "degree of parallel": 4, + "unknown_key_1": { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 0, + "cause": "output_for_parallel_query", + "write_method": "write_all_rows" + } + ] /* considering_tmp_tables */ + } + } + ] /* detail */ + } /* make_parallel_query_plan */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 3, + "row_length": 4182, + "key_length": 43, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 1, + "steps": [ + { + "converting_tmp_table_to_ondisk": { + "cause": "memory_table_size_exceeded", + "tmp_table_info": { + "in_plan_at_position": 1, + "columns": 3, + "row_length": 4182, + "key_length": 43, + "unique_constraint": false, + "makes_grouped_rows": true, + "cannot_insert_duplicates": false, + "location": "disk (TMP_TABLE_ENGINE)", + "record_format": "packed" + } /* tmp_table_info */ + } /* converting_tmp_table_to_ondisk */ + } + ] /* steps */ + } /* materialize */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +SET SESSION internal_tmp_mem_storage_engine=default; +SET GLOBAL tmp_table_size= @old_size; +SELECT pool_id FROM information_schema.INNODB_BUFFER_PAGE LIMIT 1; +pool_id +0 +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT pool_id FROM information_schema.INNODB_BUFFER_PAGE LIMIT 1 { + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "columns": 21, + "row_length": 6863, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ select `information_schema`.`INNODB_BUFFER_PAGE`.`POOL_ID` AS `pool_id` from `information_schema`.`INNODB_BUFFER_PAGE` limit 1" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "table_dependencies": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "table_scan": { + "rows": 2, + "cost": 2.525 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 2, + "access_type": "scan", + "resulting_rows": 2, + "cost": 2.725, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 2, + "cost_for_plan": 2.725, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "converting_tmp_table_to_ondisk": { + "cause": "memory_table_size_exceeded", + "tmp_table_info": { + "table": "`information_schema`.`INNODB_BUFFER_PAGE`", + "in_plan_at_position": 0, + "columns": 21, + "row_length": 6863, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "disk (TMP_TABLE_ENGINE)", + "record_format": "packed" + } /* tmp_table_info */ + } /* converting_tmp_table_to_ondisk */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1, tmp; +# +# Bug#17231940: THE OPTIMIZER STILL USES FIXED LENGTH TEMPORARY TABLES +# ON DISK +# +CREATE TABLE t1 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 VARCHAR(250) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1(c2) VALUES ('b'),('b'); +INSERT INTO t1(c2) SELECT t1.c2 FROM t1, t1 t2, t1 t3, t1 t4, t1 t5, t1 t6; +SET @@max_heap_table_size=1; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '1' +SET @@group_concat_max_len= 500; +SET SESSION internal_tmp_mem_storage_engine='memory'; +SELECT c1,GROUP_CONCAT(c2) cc FROM +(SELECT * FROM t1 UNION SELECT c1, 'a' FROM t1) tt +GROUP BY c1 +ORDER BY cc; +c1 cc +1 a,b +10 a,b +11 a,b +12 a,b +13 a,b +14 a,b +15 a,b +16 a,b +17 a,b +18 a,b +19 a,b +2 a,b +20 a,b +21 a,b +22 a,b +23 a,b +24 a,b +25 a,b +26 a,b +27 a,b +28 a,b +29 a,b +3 a,b +30 a,b +31 a,b +32 a,b +33 a,b +34 a,b +35 a,b +36 a,b +37 a,b +38 a,b +39 a,b +4 a,b +40 a,b +41 a,b +42 a,b +43 a,b +44 a,b +45 a,b +46 a,b +47 a,b +48 a,b +49 a,b +5 a,b +50 a,b +51 a,b +52 a,b +53 a,b +54 a,b +55 a,b +56 a,b +57 a,b +58 a,b +59 a,b +6 a,b +60 a,b +61 a,b +62 a,b +63 a,b +64 a,b +65 a,b +66 a,b +7 a,b +8 a,b +9 a,b +SELECT * FROM information_schema.OPTIMIZER_TRACE; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +SELECT c1,GROUP_CONCAT(c2) cc FROM +(SELECT * FROM t1 UNION SELECT c1, 'a' FROM t1) tt +GROUP BY c1 +ORDER BY cc { + "steps": [ + { + "join_preparation": { + "select#": 1, + "steps": [ + { + "join_preparation": { + "select#": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_preparation": { + "select#": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select `t1`.`c1` AS `c1`,'a' AS `a` from `t1`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "creating_tmp_table": { + "tmp_table_info": { + "table": "intermediate_tmp_table", + "columns": 2, + "row_length": 757, + "key_length": 757, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "join_preparation": { + "select#": "fake", + "steps": [ + { + "expanded_query": "/* select#fake */ select `c1` AS `c1`,`c2` AS `c2` from dual" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "derived": { + "table": " `tt`", + "select#": 2, + "materialized": true + } /* derived */ + }, + { + "expanded_query": "/* select#1 */ select `tt`.`c1` AS `c1`,group_concat(`tt`.`c2` separator ',') AS `cc` from (/* select#2 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` union /* select#3 */ select `t1`.`c1` AS `c1`,'a' AS `a` from `t1`) `tt` group by `tt`.`c1` order by `cc`" + } + ] /* steps */ + } /* join_preparation */ + }, + { + "join_optimization": { + "select#": 1, + "steps": [ + { + "join_optimization": { + "select#": 2, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 66, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 66, + "access_type": "scan", + "resulting_rows": 66, + "cost": 6.85, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 66, + "cost_for_plan": 6.85, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": 3, + "steps": [ + { + "table_dependencies": [ + { + "table": "`t1`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "`t1`", + "table_scan": { + "rows": 66, + "cost": 0.25 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "`t1`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 66, + "access_type": "scan", + "resulting_rows": 66, + "cost": 6.85, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 66, + "cost_for_plan": 6.85, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "`t1`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "`t1`" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_optimization": { + "select#": "fake", + "steps": [ + { + "table_dependencies": [ + { + "table": "``", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": "``", + "table_scan": { + "rows": 0, + "cost": 2.5 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": "``", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 0, + "access_type": "scan", + "resulting_rows": 0, + "cost": 2.5, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 0, + "cost_for_plan": 2.5, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": "``", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": "``" + } + ] /* refine_plan */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "substitute_generated_columns": { + } /* substitute_generated_columns */ + }, + { + "table_dependencies": [ + { + "table": " `tt`", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [ + ] /* depends_on_map_bits */ + } + ] /* table_dependencies */ + }, + { + "rows_estimation": [ + { + "table": " `tt`", + "table_scan": { + "rows": 132, + "cost": 4.15 + } /* table_scan */ + } + ] /* rows_estimation */ + }, + { + "considered_execution_plans": [ + { + "plan_prefix": [ + ] /* plan_prefix */, + "table": " `tt`", + "best_access_path": { + "considered_access_paths": [ + { + "rows_to_scan": 132, + "access_type": "scan", + "resulting_rows": 132, + "cost": 17.35, + "chosen": true + } + ] /* considered_access_paths */ + } /* best_access_path */, + "condition_filtering_pct": 100, + "rows_for_plan": 132, + "cost_for_plan": 17.35, + "chosen": true + } + ] /* considered_execution_plans */ + }, + { + "attaching_conditions_to_tables": { + "original_condition": null, + "attached_conditions_computation": [ + ] /* attached_conditions_computation */, + "attached_conditions_summary": [ + { + "table": " `tt`", + "attached": null + } + ] /* attached_conditions_summary */ + } /* attaching_conditions_to_tables */ + }, + { + "optimizing_distinct_group_by_order_by": { + "simplifying_order_by": { + "original_clause": "`cc`", + "items": [ + { + "item": "group_concat(`tt`.`c2` separator ',')" + } + ] /* items */, + "resulting_clause_is_simple": false, + "resulting_clause": "`cc`" + } /* simplifying_order_by */, + "simplifying_group_by": { + "original_clause": "`tt`.`c1`", + "items": [ + { + "item": "`tt`.`c1`" + } + ] /* items */, + "resulting_clause_is_simple": true, + "resulting_clause": "`tt`.`c1`" + } /* simplifying_group_by */ + } /* optimizing_distinct_group_by_order_by */ + }, + { + "finalizing_table_conditions": [ + ] /* finalizing_table_conditions */ + }, + { + "refine_plan": [ + { + "table": " `tt`" + } + ] /* refine_plan */ + }, + { + "considering_tmp_tables": [ + { + "adding_tmp_table_in_plan_at_position": 1, + "filesort": { + "adding_sort_to_table": "tt" + } /* filesort */, + "unknown_key_1": { + "creating_tmp_table": { + "tmp_table_info": { + "table": "intermediate_tmp_table", + "columns": 1, + "row_length": 753, + "key_length": 0, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": false, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + "write_method": "write_group_row_when_complete" + }, + { + "adding_sort_to_table": "" + } /* filesort */ + ] /* considering_tmp_tables */ + } + ] /* steps */ + } /* join_optimization */ + }, + { + "join_execution": { + "select#": 1, + "steps": [ + { + "creating_tmp_table": { + "tmp_table_info": { + "table": " `tt`", + "in_plan_at_position": 0, + "columns": 2, + "row_length": 757, + "key_length": 757, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "memory (heap)", + "row_limit_estimate": 1 + } /* tmp_table_info */ + } /* creating_tmp_table */ + }, + { + "materialize": { + "select#": 2, + "steps": [ + { + "converting_tmp_table_to_ondisk": { + "cause": "memory_table_size_exceeded", + "tmp_table_info": { + "table": " `tt`", + "in_plan_at_position": 0, + "columns": 2, + "row_length": 757, + "key_length": 757, + "unique_constraint": false, + "makes_grouped_rows": false, + "cannot_insert_duplicates": true, + "location": "disk (TMP_TABLE_ENGINE)", + "record_format": "packed" + } /* tmp_table_info */ + } /* converting_tmp_table_to_ondisk */ + } + ] /* steps */ + } /* materialize */ + }, + { + "materialize": { + "select#": 3, + "steps": [ + ] /* steps */ + } /* materialize */ + }, + { + "sorting_table": "tt", + "filesort_information": [ + { + "direction": "asc", + "expression": "`tt`.`c1`" + } + ] /* filesort_information */, + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + } /* filesort_priority_queue_optimization */, + "filesort_execution": [ + ] /* filesort_execution */, + "filesort_summary": { + "memory_available": 262144, + "key_size": 8, + "row_size": 769, + "max_rows_per_buffer": 132, + "num_rows_estimate": 132, + "num_rows_found": 132, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::stable_sort", + "sort_mode": "" + } /* filesort_summary */ + }, + { + "sorting_table": "", + "filesort_information": [ + { + "direction": "asc", + "expression": "`cc`" + } + ] /* filesort_information */, + "filesort_priority_queue_optimization": { + "usable": false, + "cause": "not applicable (no LIMIT)" + } /* filesort_priority_queue_optimization */, + "filesort_execution": [ + ] /* filesort_execution */, + "filesort_summary": { + "memory_available": 262144, + "key_size": 1001, + "row_size": 2512, + "max_rows_per_buffer": 104, + "num_rows_estimate": 18446744073709551615, + "num_rows_found": 66, + "num_initial_chunks_spilled_to_disk": 0, + "peak_memory_used": "NNN", + "sort_algorithm": "std::sort", + "sort_mode": "" + } /* filesort_summary */ + } + ] /* steps */ + } /* join_execution */ + } + ] /* steps */ +} 0 0 +DROP TABLE t1; +# +SET SESSION internal_tmp_mem_storage_engine=default; +# +# Bug #30773218 ASSERTION IN SQL_TMP_TABLE.CC::TRACE_TMP_TABLE +# +CREATE TABLE t1(name VARCHAR(64), type TEXT); +INSERT INTO t1(name, type) VALUES +('t1', 'table'), +('t2', 'table'), +('t3', 'table'), +('t4', 'table'), +('t5', 'table'), +('t6', 'table'), +('t7', 'table'), +('t8', 'table'), +('t9', 'table'), +('t10', 'table'), +('t11', 'table'); +CREATE TABLE t2(name VARCHAR(64), data TEXT); +INSERT INTO t2(name, data) VALUES +('t1', 'data'), +('t2', 'data'), +('t3', 'data'), +('t4', 'data'), +('t5', 'data'), +('t6', 'data'), +('t7', 'data'), +('t8', 'data'); +SET SESSION internal_tmp_mem_storage_engine=MEMORY; +SET @@session.optimizer_trace='enabled=on'; +SET @@session.tmp_table_size = 1024; +SET @@optimizer_switch='semijoin=off'; +SELECT name, data FROM t2 WHERE name IN +( SELECT name FROM t1 WHERE type='table'); +name data +t1 data +t2 data +t3 data +t4 data +t5 data +t6 data +t7 data +t8 data +DROP TABLE t1, t2; +SET SESSION internal_tmp_mem_storage_engine=default; +SET @@session.optimizer_trace='enabled=default'; +SET @@session.tmp_table_size = default; +SET @@optimizer_switch='semijoin=default'; diff --git a/mysql-test/suite/parallel_query/include/pq_test.inc b/mysql-test/suite/parallel_query/include/pq_test.inc new file mode 100644 index 000000000..a1199cf17 --- /dev/null +++ b/mysql-test/suite/parallel_query/include/pq_test.inc @@ -0,0 +1,4 @@ +if (!$PQ_TEST) +{ + --skip Test needs '--pq' option +} diff --git a/mysql-test/suite/parallel_query/r/pq_abort.result-pq b/mysql-test/suite/parallel_query/r/pq_abort.result-pq new file mode 100644 index 000000000..aff9beb5a --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_abort.result-pq @@ -0,0 +1,116 @@ +create table t1(id int, a varchar(10)); +insert into t1 values(1, 'aa'), (2, 'bb'); +set @saved_force_parallel_execute = @@force_parallel_execute; +set session force_parallel_execute = 1; +explain select * from t1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` limit 1 +select * from t1 limit 1; +id a +1 aa +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, dup_thd_abort"; +explain select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, dup_join_abort"; +explain select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, dup_select_abort1"; +explain select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, dup_select_abort2"; +explain select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug="+d, pq_leader_abort1"; +explain select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, pq_leader_abort2"; +explain select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +select * from t1 limit 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +explain select * from t1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`a` AS `a` from `test`.`t1` limit 1 +select * from t1 limit 1; +id a +1 aa +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +drop table t1; +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES +(1,1),(2,2),(3,3); +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, f3 CHAR(200), KEY(f1, f2)); +INSERT INTO t2 VALUES +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'), +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'); +CREATE TABLE t3 (f1 INT NOT NULL, f2 INT, f3 VARCHAR(32), +PRIMARY KEY(f1), KEY f2_idx(f1), KEY f3_idx(f3)); +INSERT INTO t3 VALUES +(1, 1, 'qwerty'), (2, 1, 'ytrewq'), +(3, 2, 'uiop'), (4, 2, 'poiu'), (5, 2, 'lkjh'), +(6, 2, 'uiop'), (7, 2, 'poiu'), (8, 2, 'lkjh'), +(9, 2, 'uiop'), (10, 2, 'poiu'), (11, 2, 'lkjh'), +(12, 2, 'uiop'), (13, 2, 'poiu'), (14, 2, 'lkjh'); +INSERT INTO t3 SELECT f1 + 20, f2, f3 FROM t3; +INSERT INTO t3 SELECT f1 + 40, f2, f3 FROM t3; +SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; +f1 f2 f3 +1 1 qwerty +2 2 qwerty +1 1 qwerty +2 2 qwerty +drop table t1, t2, t3; +set session force_parallel_execute = @saved_force_parallel_execute; +# restart diff --git a/mysql-test/suite/parallel_query/r/pq_aggr_no_record.result-pq b/mysql-test/suite/parallel_query/r/pq_aggr_no_record.result-pq new file mode 100644 index 000000000..06aa44fd1 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_aggr_no_record.result-pq @@ -0,0 +1,34 @@ +# check aggregation when innodb return zero line +CREATE TABLE records_in_range_test ( +c1 VARCHAR(16), +c2 VARCHAR(512), +PRIMARY KEY (c1) +) ENGINE=INNODB; +INSERT INTO records_in_range_test VALUES +('ccc', REPEAT('v', 512)), +('kkk01', REPEAT('v', 512)), +('kkk02', REPEAT('v', 512)), +('kkk03', REPEAT('v', 512)), +('kkk04', REPEAT('v', 512)), +('kkk05', REPEAT('v', 512)), +('kkk06', REPEAT('v', 512)), +('kkk07', REPEAT('v', 512)), +('kkk08', REPEAT('v', 512)), +('mmm', REPEAT('v', 512)), +('nnn', REPEAT('v', 512)), +('uuu01', REPEAT('v', 512)), +('uuu02', REPEAT('v', 512)), +('uuu03', REPEAT('v', 512)), +('uuu04', REPEAT('v', 512)), +('uuu05', REPEAT('v', 512)), +('uuu06', REPEAT('v', 512)), +('uuu07', REPEAT('v', 512)), +('uuu08', REPEAT('v', 512)), +('xxx', REPEAT('v', 512)); +SELECT COUNT(*) FROM records_in_range_test WHERE c1 < 'ccc'; +COUNT(*) +0 +SELECT COUNT(*) FROM records_in_range_test WHERE c1 < 'xxx'; +COUNT(*) +19 +drop table records_in_range_test; diff --git a/mysql-test/suite/parallel_query/r/pq_blob.result-pq b/mysql-test/suite/parallel_query/r/pq_blob.result-pq new file mode 100644 index 000000000..eaaacb8c0 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_blob.result-pq @@ -0,0 +1,27 @@ +create database pq_test; +use pq_test; +DROP TABLE IF EXISTS t1; +CREATE TABLE t2(d varchar(17) PRIMARY KEY) ENGINE=innodb DEFAULT CHARSET=utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +CREATE TABLE t3(a int PRIMARY KEY) ENGINE=innodb; +INSERT INTO t3 VALUES (22),(44),(33),(55),(66); +INSERT INTO t2 VALUES ('jejdkrun87'),('adfd72nh9k'), ('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik'); +CREATE TABLE t1(a int, b blob, c text, d text NOT NULL) ENGINE=innodb DEFAULT CHARSET=utf8 STATS_PERSISTENT=0; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 SELECT a,LEFT(REPEAT(d,100*a),65535),REPEAT(d,20*a),d FROM t2,t3 order by a, d; +DROP TABLE t2, t3; +DELETE FROM t1 WHERE d='null'; +DELETE FROM t1 WHERE a%2; +CHECK TABLE t1; +Table Op Msg_type Msg_text +pq_test.t1 check status OK +ALTER TABLE t1 ADD PRIMARY KEY (a,b(255),c(255)), ADD KEY (b(767)); +set force_parallel_execute=1; +set parallel_cost_threshold=0; +SELECT COUNT(*) FROM t1 WHERE a=44; +COUNT(*) +5 +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_charset.result-pq b/mysql-test/suite/parallel_query/r/pq_charset.result-pq new file mode 100644 index 000000000..48374e7dc --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_charset.result-pq @@ -0,0 +1,266 @@ +create database pq_test; +use pq_test; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 +(a INT, +b INT, +PRIMARY KEY (a)) +ENGINE = InnoDB; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +# con1 +use pq_test; +ALTER TABLE t1 ADD INDEX idx1 (b); +# con default +SELECT b FROM t1 WHERE b = 0; +ERROR HY000: Table definition has changed, please retry transaction +SELECT b FROM t1 WHERE b = 0; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t1; +ERROR HY000: Table definition has changed, please retry transaction +drop table pq_test.t1; +create table t1(a int) charset utf8mb4; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; +create table t3 ( +a char(8) not null, b char(8) not null, filler char(200), +key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), +'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), +'filler-2' from t2 A; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +set optimizer_switch='mrr=on,mrr_cost_based=off'; +select a,filler from t3 where a >= 'c-9011=w'; +a filler +drop table pq_test.t1; +set optimizer_switch='mrr=on,mrr_cost_based=on'; +create table t1 (a int, key (a)); +insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +analyze table t1; +Table Op Msg_type Msg_text +pq_test.t1 analyze status OK +explain select * from t1 where not(a < 5 or a > 15); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` where ((`pq_test`.`t1`.`a` >= 5) and (`pq_test`.`t1`.`a` <= 15)) +select * from t1 where not(a < 5 or a > 15); +a +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +explain select * from t1 where a = 2 or not(a < 10); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 11 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 11 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` where ((`pq_test`.`t1`.`a` = 2) or (`pq_test`.`t1`.`a` >= 10)) +select * from t1 where a = 2 or not(a < 10); +a +2 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +explain select * from t1 where a = 7 or not(a < 15 and a > 5); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL range a a 5 NULL 12 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` where ((`pq_test`.`t1`.`a` = 7) or (`pq_test`.`t1`.`a` >= 15) or (`pq_test`.`t1`.`a` <= 5)) +select * from t1 where a = 7 or not(a < 15 and a > 5); +a +0 +1 +2 +3 +4 +5 +7 +15 +16 +17 +18 +19 +delete from t1 where a > 3; +select a from t1; +a +NULL +0 +1 +2 +3 +analyze table t1; +Table Op Msg_type Msg_text +pq_test.t1 analyze status OK +explain select * from t1 force index(a) where not(a >0 and a < 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range a a 5 NULL 4 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` FORCE INDEX (`a`) where ((`pq_test`.`t1`.`a` <= 0) or (`pq_test`.`t1`.`a` >= 1)) +select * from t1 force index(a) where not(a >0 and a < 1); +a +0 +1 +2 +3 +select * from t1 where a < 3; +a +0 +1 +2 +select * from t1 where a is null; +a +NULL +drop table pq_test.t1; +create table t1 (id int, id2 int, index (id)); +insert into t1 values(2,2); +analyze table t1; +Table Op Msg_type Msg_text +pq_test.t1 analyze status OK +select * from t1 where id is null or id > 1; +id id2 +2 2 +insert into t1 values(null,2); +select * from t1; +id id2 +2 2 +NULL 2 +select * from t1 where id is null or id > 1; +id id2 +NULL 2 +2 2 +drop table pq_test.t1; +create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10))) +stats_persistent=0; +insert into t1 values(concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' ')); +insert into t1 values(concat(char(ascii('a')),' '),concat(char(ascii('a')),' '),concat(char(ascii('a')),' ')); +insert into t1 values(concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' ')); +insert into t1 values(concat(char(ascii('a')),' '),concat(char(ascii('a')),' '),concat(char(ascii('a')),' ')); +select * from t1; +v c t +b b b +a a a +b b b +a a a +alter table t1 add key(v); +Warnings: +Warning 1831 Duplicate index 'v_2' defined on the table 'pq_test.t1'. This is deprecated and will be disallowed in a future release. +alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); +select count(*) from t1 where v like 'a%'; +count(*) +2 +select count(*) from t1 where v like 'a %'; +count(*) +2 +alter table t1 drop key v, add key v (v(30)); +select 1 from t1 where v like 'a%'; +1 +1 +1 +select 1 from t1 where v like 'a %'; +1 +1 +1 +drop table pq_test.t1; +set names utf8mb4; +create table t1 ( +a int primary key, +b varchar(6), +index b3(b(3)) +) engine=innodb character set=utf8mb4; +insert into t1 values(1,'foo'),(2,'foobar'); +select * from t1 where b like 'foob%'; +a b +2 foobar +drop table pq_test.t1; +CREATE TABLE t1 ( +a char(255) DEFAULT '', +KEY(a(10)) +) ENGINE=innodb DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +drop table pq_test.t1; +SET time_zone='+00:00'; +CREATE TABLE t1 (a DECIMAL(20,7)); +INSERT INTO t1 VALUES +(2147483647.999999), +(2147483647.9999990), +(2147483647.9999991), +(2147483647.9999992), +(2147483647.9999993), +(2147483647.9999994), +(2147483647.9999995), +(2147483647.9999996), +(2147483647.9999997), +(2147483647.9999998), +(2147483647.9999999); +SELECT a, FROM_UNIXTIME(a) FROM t1; +a FROM_UNIXTIME(a) +2147483647.9999990 2038-01-19 03:14:07.999999 +2147483647.9999990 2038-01-19 03:14:07.999999 +2147483647.9999991 2038-01-19 03:14:07.999999 +2147483647.9999992 2038-01-19 03:14:07.999999 +2147483647.9999993 2038-01-19 03:14:07.999999 +2147483647.9999994 2038-01-19 03:14:07.999999 +2147483647.9999995 NULL +2147483647.9999996 NULL +2147483647.9999997 NULL +2147483647.9999998 NULL +2147483647.9999999 NULL +drop table pq_test.t1; +drop table pq_test.t2; +drop table pq_test.t3; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_check_first_rewritten_tab.result-pq b/mysql-test/suite/parallel_query/r/pq_check_first_rewritten_tab.result-pq new file mode 100644 index 0000000000000000000000000000000000000000..76e2c6c3b09ca85d85e09fa1ab2ea8397571c938 GIT binary patch literal 4406 zcmcgwOK%%h6mBJ0%q(EZ3hCgDZRAGtu*Y^nq|VE2z;&e9sXz$Q@pzI9jAvZW7+fKw zrX@6pM~PZgM4^>h`VvKLMFmYn+7%mq0sF>wBOxJHAdo2MjvdFT8z=57vPPrpd(Zv8 z?|kRn8|!65^9=B`yoFCT1hfXG?LlTV2buA7Is!oF;T^54Piy5+j0poB1~s#5B%=iIBkXHu3n10v)Vu*GP%g{Y|5hlw{5tk3q8kMIx%3n#d6ahywls}&?l$}zGgE5gS-p6S>Vx?|h86TS`yr}Auq;h712+O!SVn9$AO z5G{|XVorseD5X^*kqmpqF+w)PGN=c66Xl#b1|)7PLIhq>Ukm9WjtPguL-a@{tB&Ph zB$FE@O6(QW<7zg75QFU@F_-4$_bfML`hK<5<-@x1cnzRS&iayPEE>5HK_=aq+m!n zsjxT&*KHD7O3I>?Oo?(b#VWk4lF*W%GIAV)@uEPskX7V}TPRT#1E)kuLYAAOM!XV1 zCns=OD>P!0FmPN#xl%C9=y(oJ~hwZT>sE-xIf&3#k*Zf1G$ zLmXK-`9bZ%tverIs~w%ceee+Vs1i#(*#30m=2HEmBaOu$Yd_sYcz3SOH7?JuoVb4b z;7tAEmHMTH#>~}~v!@z|Pd8@1_W?hoO{ji%r0ZYI)=n-p&Yh~?xIr}i_N)5g+1lc9 z1X`a%5ohWrE;Wvyu6_DhOVfw78`bZQ^zz~&YF0acsD9==LR`Lauzqpr&aE$3W*6$$ zPS?MlBg*w_Rcb3ydv!E@eanUrZ5BwAjga2G+Nnuv!hw#~&2nTwhnKUX8GI?gl;IQ& zuY3Uexjlvb4u*krbVcgBqhk*bP8*ix1o1`mz?;Ui#4H-%Ou|%Ivpv(E0u3xje;e>D z(7?k%SM!@LS@K?hbm+h!1f;Uzd4UK7jG|^*WF${Uc2=v^0o^GE-pA?L+{7+~p2Bk> zXH>mVu;d_nY{rR!WHgzGvy8xVz()tTSR%o4u_PZ02T2$1aULl~$*>ECt(%5R5FrEC zfI`P8=$Z|A1NK);JTDPT$ug=<@Puk$Fu*ZvYzM>Q2UvcPVek`(1k4hC#U{A{R!9u6 z11t`e4Yy)>I6O%>Zc0gral9Z1(IzD%COHZ!-P>xS!YPA(qjVq8*STI3i$%Ec2xPjXRY zmT^2lxZvd9!n4~&`}?L_Wkk@Y(QU3zjo7j1xE{$`(Xo+a#Wf00H1JMin{Khmbz=*% zoX}}NBJRd+5{P@&*}IvH=CikXqdboW<`XS3VgeeOX^GK&A2JIRUWq83D&Tdk?!-%3XZcWDtR38()CR0C4hS@>3GQD` z(6$(~s%H(?e@|`u?HJ;^_WS%#bec++P?}2x3O?1L*m%tjrH~zVM zu&F=Pe6;iY=ihh#br9{F&puyG60|J~ znuQ2x5y-FI%$rVpP!~R+e;zKqk5qcPTgy(d@)6M2iG@XrVm-!UMMt?;xXVuvR+naZh>-d3z{1ov&2l}pM literal 0 HcmV?d00001 diff --git a/mysql-test/suite/parallel_query/r/pq_coverage.result-pq b/mysql-test/suite/parallel_query/r/pq_coverage.result-pq new file mode 100644 index 000000000..dfc401ada --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_coverage.result-pq @@ -0,0 +1,130 @@ +CREATE TABLE t1(id int, name varchar(10), primary key(id)); +INSERT INTO t1 VALUES(1,'AAAA'); +INSERT INTO t1 VALUES(2,'BBBB'); +INSERT INTO t1 VALUES(3,'CCCC'); +EXPLAIN SELECT * FROM t1 WHERE id > 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`name` AS `name` from `test`.`t1` where (`test`.`t1`.`id` > 1) +SELECT * FROM t1 WHERE id > 1; +id name +2 BBBB +3 CCCC +SET session debug="+d, pq_clone_error1"; +SELECT * FROM t1 WHERE id > 1; +ERROR HY000: Failed to parallel execute. this SQL is not supported. +SET session debug="-d, pq_clone_error1"; +SELECT LOCATE("A", name, 2) FROM t1; +LOCATE("A", name, 2) +2 +0 +0 +set @saved_parallel_max_threads = @@parallel_max_threads; +SET GLOBAL parallel_max_threads = 5; +CREATE PROCEDURE pro_insert(cnt int) +BEGIN +DECLARE i int DEFAULT 0; +START TRANSACTION; +WHILE i b; +i a b +1 101.40 21.40 +1 -80.00 0.00 +2 -13.20 0.00 +2 59.60 46.40 +3 37.00 7.40 +3 -29.60 0.00 +4 60.00 15.40 +4 -10.60 0.00 +4 -34.00 0.00 +5 33.00 0.00 +5 -25.80 0.00 +5 0.00 7.20 +6 -51.40 0.00 +SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b; +i a b +6 -51.40 0.00 +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_coverage_index.result b/mysql-test/suite/parallel_query/r/pq_coverage_index.result new file mode 100644 index 000000000..ba4c56881 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_coverage_index.result @@ -0,0 +1,31 @@ +create database pq_test; +use pq_test; +SET GLOBAL transaction_isolation='REPEATABLE-READ'; +SET GLOBAL innodb_file_per_table=on; +CREATE TABLE bug56680( +a INT AUTO_INCREMENT PRIMARY KEY, +b CHAR(1), +c INT, +INDEX(b)) +ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO bug56680 VALUES(0,'x',1); +BEGIN; +SELECT b FROM bug56680; +b +x +use pq_test; +BEGIN; +UPDATE bug56680 SET b='X'; +SELECT b FROM bug56680; +b +x +SELECT * FROM bug56680; +a b c +1 x 1 +ROLLBACK; +SELECT b FROM bug56680; +b +x +COMMIT; +drop table pq_test.bug56680; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_demon.result-pq b/mysql-test/suite/parallel_query/r/pq_demon.result-pq new file mode 100644 index 000000000..066243de8 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_demon.result-pq @@ -0,0 +1,2 @@ +create table t1(a int); +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_explain.result-pq b/mysql-test/suite/parallel_query/r/pq_explain.result-pq new file mode 100644 index 000000000..d15774299 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_explain.result-pq @@ -0,0 +1,822 @@ +set @saved_force_parallel_execute = @@force_parallel_execute; +CREATE TABLE `cast_info` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`person_id` int(11) NOT NULL, +`movie_id` int(11) NOT NULL, +`person_role_id` int(11) DEFAULT NULL, +`note` varchar(250) DEFAULT NULL, +`nr_order` int(11) DEFAULT NULL, +`role_id` int(11) NOT NULL, +PRIMARY KEY (`id`), +KEY `role_id_note` (`role_id`,`note`) +) ENGINE=InnoDB; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +set session force_parallel_execute=0; +explain SELECT * FROM cast_info WHERE role_id = 1 and note like '%Jaime%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE cast_info NULL ref role_id_note role_id_note 4 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`cast_info`.`id` AS `id`,`test`.`cast_info`.`person_id` AS `person_id`,`test`.`cast_info`.`movie_id` AS `movie_id`,`test`.`cast_info`.`person_role_id` AS `person_role_id`,`test`.`cast_info`.`note` AS `note`,`test`.`cast_info`.`nr_order` AS `nr_order`,`test`.`cast_info`.`role_id` AS `role_id` from `test`.`cast_info` where ((`test`.`cast_info`.`role_id` = 1) and (`test`.`cast_info`.`note` like '%Jaime%')) +set session force_parallel_execute=1; +explain SELECT * FROM cast_info WHERE role_id = 1 and note like '%Jaime%'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE cast_info NULL ref role_id_note role_id_note 4 const 1 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`cast_info`.`id` AS `id`,`test`.`cast_info`.`person_id` AS `person_id`,`test`.`cast_info`.`movie_id` AS `movie_id`,`test`.`cast_info`.`person_role_id` AS `person_role_id`,`test`.`cast_info`.`note` AS `note`,`test`.`cast_info`.`nr_order` AS `nr_order`,`test`.`cast_info`.`role_id` AS `role_id` from `test`.`cast_info` where ((`test`.`cast_info`.`role_id` = 1) and (`test`.`cast_info`.`note` like '%Jaime%')) +drop table cast_info; +create database pq_test; +use pq_test; +create table t1( +id int primary key auto_increment, +col1 varchar(100), +col2 int, +key idx_col2(col2) +)engine= innodb; +set session force_parallel_execute = 0; +explain select count(*) from pq_test.t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL idx_col2 5 NULL 10 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` +set session force_parallel_execute = 1; +explain select count(*) from pq_test.t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL idx_col2 5 NULL 10 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` +set session force_parallel_execute = 0; +explain select * from pq_test.t1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` limit 1 +set session force_parallel_execute = 1; +explain select * from pq_test.t1 limit 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` limit 1 +set session force_parallel_execute = 0; +explain select * from pq_test.t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` +set session force_parallel_execute = 1; +explain select * from pq_test.t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` +set session force_parallel_execute = 0; +explain select id, col2 from pq_test.t1 force index(idx_col2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL idx_col2 5 NULL 10 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) +set session force_parallel_execute = 1; +explain select id, col2 from pq_test.t1 force index(idx_col2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL idx_col2 5 NULL 10 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) +set session force_parallel_execute = 1; +set DEBUG_SYNC='after_pq_leader_plan SIGNAL ready WAIT_FOR continue'; +select * from pq_test.t1 limit 1;; +set DEBUG_SYNC='now WAIT_FOR ready'; +EXPLAIN FOR CONNECTION #;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE NULL ALL NULL NULL NULL NULL # #.# Parallel execute (# workers) +# SIMPLE t# NULL ALL NULL NULL NULL NULL # #.# NULL +set DEBUG_SYNC='now SIGNAL continue'; +id col1 col2 +1 testtesttesttest 10 +set DEBUG_SYNC="reset"; +set DEBUG_SYNC="reset"; +set session force_parallel_execute = 1; +explain format=tree select * from pq_test.t1; +EXPLAIN +-> Parallel scan on + -> PQblock scan on t1 (cost=1.25 rows=10) + +explain format=json select * from pq_test.t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "1.25" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "4K" + }, + "used_columns": [ + "id", + "col1", + "col2" + ], + "query_block": { + "cost_info": { + "query_cost": "1.25" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 10, + "rows_produced_per_join": 10, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "1.00", + "prefix_cost": "1.25", + "data_read_per_join": "4K" + }, + "used_columns": [ + "id", + "col1", + "col2" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` +set session force_parallel_execute = @saved_force_parallel_execute; +drop table pq_test.t1; +drop database pq_test; +create database pq_test; +use pq_test; +create table t1( +id int primary key auto_increment, +col1 varchar(100), +col2 int, +key idx_col2(col2) +)engine= innodb; +show variables like 'force_parallel_execute'; +Variable_name Value +force_parallel_execute ON +select count(*) from pq_test.t1; +count(*) +100 +select * from pq_test.t1 limit 1; +id col1 col2 +1 testtesttesttest 100 +select * from pq_test.t1 order by id desc limit 1; +id col1 col2 +100 testtesttesttest 1 +explain select * from pq_test.t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 100 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` +explain select * from pq_test.t1 for share; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` +explain select * from pq_test.t1 for update; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 100 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 29 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (`pq_test`.`t1`.`id` < 30) +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 29 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 29 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (`pq_test`.`t1`.`id` < 30) +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id <= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 30 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (`pq_test`.`t1`.`id` <= 30) +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id <= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 30 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (`pq_test`.`t1`.`id` <= 30) +set session force_parallel_execute = 0; +explain select id from pq_test.t1 ignore index(idx_col2) where id > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 80 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (`pq_test`.`t1`.`id` > 20) +set session force_parallel_execute = 1; +explain select id from pq_test.t1 ignore index(idx_col2) where id > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 80 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 80 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (`pq_test`.`t1`.`id` > 20) +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id >= 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 81 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (`pq_test`.`t1`.`id` >= 20) +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id > 10 and id < 80; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 69 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 69 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`id` > 10) and (`pq_test`.`t1`.`id` < 80)) +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id >= 10 and id <= 80; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 71 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`id` >= 10) and (`pq_test`.`t1`.`id` <= 80)) +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id >= 10 and id <= 80; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 71 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 71 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`id` >= 10) and (`pq_test`.`t1`.`id` <= 80)) +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30 or id > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 79 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`id` < 30) or (`pq_test`.`t1`.`id` > 50)) +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30 or id > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 79 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 79 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`id` < 30) or (`pq_test`.`t1`.`id` > 50)) +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where (id > 10 and id < 50) or (id > 60 and id < 90); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 68 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (((`pq_test`.`t1`.`id` > 10) and (`pq_test`.`t1`.`id` < 50)) or ((`pq_test`.`t1`.`id` > 60) and (`pq_test`.`t1`.`id` < 90))) +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where (id > 10 and id < 50) or (id > 60 and id < 90); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 68 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 68 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col1` AS `col1`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` IGNORE INDEX (`idx_col2`) where (((`pq_test`.`t1`.`id` > 10) and (`pq_test`.`t1`.`id` < 50)) or ((`pq_test`.`t1`.`id` > 60) and (`pq_test`.`t1`.`id` < 90))) +set session force_parallel_execute = @saved_force_parallel_execute; +drop table pq_test.t1; +drop database pq_test; +create database pq_test; +use pq_test; +create table t1( +id int primary key auto_increment, +col1 varchar(100), +col2 int, +key idx_col2(col2) +)engine= innodb; +show variables like 'force_parallel_execute'; +Variable_name Value +force_parallel_execute ON +select count(*) from pq_test.t1; +count(*) +100 +select * from pq_test.t1 limit 1; +id col1 col2 +1 testtesttesttest 100 +select * from pq_test.t1 order by id desc limit 1; +id col1 col2 +100 testtesttesttest 1 +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 29 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` < 30) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 29 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 29 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` < 30) +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 <= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 30 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` <= 30) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 <= 30; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 30 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 30 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` <= 30) +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 80 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` > 20) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 80 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 80 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` > 20) +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 81 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` >= 20) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 20; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 81 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 81 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (`pq_test`.`t1`.`col2` >= 20) +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 10 and col2 < 80; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 69 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`col2` > 10) and (`pq_test`.`t1`.`col2` < 80)) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 10 and col2 < 80; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 69 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 69 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`col2` > 10) and (`pq_test`.`t1`.`col2` < 80)) +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 10 and col2 <= 80; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 71 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`col2` >= 10) and (`pq_test`.`t1`.`col2` <= 80)) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 10 and col2 <= 80; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 71 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 71 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`col2` >= 10) and (`pq_test`.`t1`.`col2` <= 80)) +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30 or col2 > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 79 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`col2` < 30) or (`pq_test`.`t1`.`col2` > 50)) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30 or col2 > 50; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 79 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 79 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where ((`pq_test`.`t1`.`col2` < 30) or (`pq_test`.`t1`.`col2` > 50)) +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where (col2 > 10 and col2 < 50) or (col2 > 60 and col2 < 90); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 68 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (((`pq_test`.`t1`.`col2` > 10) and (`pq_test`.`t1`.`col2` < 50)) or ((`pq_test`.`t1`.`col2` > 60) and (`pq_test`.`t1`.`col2` < 90))) +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where (col2 > 10 and col2 < 50) or (col2 > 60 and col2 < 90); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 68 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL range idx_col2 idx_col2 5 NULL 68 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`id` AS `id`,`pq_test`.`t1`.`col2` AS `col2` from `pq_test`.`t1` FORCE INDEX (`idx_col2`) where (((`pq_test`.`t1`.`col2` > 10) and (`pq_test`.`t1`.`col2` < 50)) or ((`pq_test`.`t1`.`col2` > 60) and (`pq_test`.`t1`.`col2` < 90))) +set session force_parallel_execute = @saved_force_parallel_execute; +drop table pq_test.t1; +drop database pq_test; +create database pq_test; +use pq_test; +create table t1(a int primary key, b varchar(10), c decimal(5,2)); +insert into t1 values (1, 'The', '3.14'); +insert into t1 values (2, 'quick', '4.25'); +insert into t1 values (3, 'brown', '5.36'); +insert into t1 values (4, 'fox', '6.47'); +insert into t1 values (5, 'jumps', '3.14'); +insert into t1 values (6, 'over', '4.25'); +insert into t1 values (7, 'the', '5.36'); +insert into t1 values (8, 'lazy', '6.47'); +insert into t1 values (9, 'dog', '7.58'); +set session force_parallel_execute=0; +explain select count(*) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` +explain select count(c) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t1`.`c`) AS `count(c)` from `pq_test`.`t1` +explain select sum(a) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`a`) AS `sum(a)` from `pq_test`.`t1` +explain select sum(c) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`c`) AS `sum(c)` from `pq_test`.`t1` +explain select avg(a) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`a`) AS `avg(a)` from `pq_test`.`t1` +explain select avg(c) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`c`) AS `avg(c)` from `pq_test`.`t1` +set session force_parallel_execute=1; +explain select count(*) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` +explain select count(c) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t1`.`c`) AS `count(c)` from `pq_test`.`t1` +explain select sum(a) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`a`) AS `sum(a)` from `pq_test`.`t1` +explain select sum(c) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`c`) AS `sum(c)` from `pq_test`.`t1` +explain select avg(a) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 9 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`a`) AS `avg(a)` from `pq_test`.`t1` +explain select avg(c) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`c`) AS `avg(c)` from `pq_test`.`t1` +set session force_parallel_execute=0; +explain select sum(c) from t1 where a > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`c`) AS `sum(c)` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` > 5) +explain select sum(a) from t1 where c > 5.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`a`) AS `sum(a)` from `pq_test`.`t1` where (`pq_test`.`t1`.`c` > 5.00) +explain select avg(c) from t1 where a > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`c`) AS `avg(c)` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` > 5) +explain select avg(a) from t1 where c > 5.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`a`) AS `avg(a)` from `pq_test`.`t1` where (`pq_test`.`t1`.`c` > 5.00) +explain select count(*) from t1 where c > 5.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` where (`pq_test`.`t1`.`c` > 5.00) +explain select count(c) from t1 where a > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t1`.`c`) AS `count(c)` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` > 5) +set session force_parallel_execute=1; +explain select sum(c) from t1 where a > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`c`) AS `sum(c)` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` > 5) +explain select sum(a) from t1 where c > 5.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t1`.`a`) AS `sum(a)` from `pq_test`.`t1` where (`pq_test`.`t1`.`c` > 5.00) +explain select avg(c) from t1 where a > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`c`) AS `avg(c)` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` > 5) +explain select avg(a) from t1 where c > 5.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t1`.`a`) AS `avg(a)` from `pq_test`.`t1` where (`pq_test`.`t1`.`c` > 5.00) +explain select count(*) from t1 where c > 5.0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 33.33 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` where (`pq_test`.`t1`.`c` > 5.00) +explain select count(c) from t1 where a > 5; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t1`.`c`) AS `count(c)` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` > 5) +set session force_parallel_execute=0; +explain select c,sum(a) from t1 group by(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`c` AS `c`,sum(`pq_test`.`t1`.`a`) AS `sum(a)` from `pq_test`.`t1` group by `pq_test`.`t1`.`c` +explain select b,sum(c) from t1 group by(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`b` AS `b`,sum(`pq_test`.`t1`.`c`) AS `sum(c)` from `pq_test`.`t1` group by `pq_test`.`t1`.`b` +explain select c,avg(a) from t1 group by(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`c` AS `c`,avg(`pq_test`.`t1`.`a`) AS `avg(a)` from `pq_test`.`t1` group by `pq_test`.`t1`.`c` +explain select b,avg(c) from t1 group by(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`b` AS `b`,avg(`pq_test`.`t1`.`c`) AS `avg(c)` from `pq_test`.`t1` group by `pq_test`.`t1`.`b` +explain select count(*) from t1 group by(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` group by `pq_test`.`t1`.`c` +explain select count(c) from t1 group by(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t1`.`c`) AS `count(c)` from `pq_test`.`t1` group by `pq_test`.`t1`.`b` +set session force_parallel_execute=1; +explain select c,sum(a) from t1 group by(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`c` AS `c`,sum(`pq_test`.`t1`.`a`) AS `sum(a)` from `pq_test`.`t1` group by `pq_test`.`t1`.`c` +explain select b,sum(c) from t1 group by(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`b` AS `b`,sum(`pq_test`.`t1`.`c`) AS `sum(c)` from `pq_test`.`t1` group by `pq_test`.`t1`.`b` +explain select c,avg(a) from t1 group by(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`c` AS `c`,avg(`pq_test`.`t1`.`a`) AS `avg(a)` from `pq_test`.`t1` group by `pq_test`.`t1`.`c` +explain select b,avg(c) from t1 group by(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`b` AS `b`,avg(`pq_test`.`t1`.`c`) AS `avg(c)` from `pq_test`.`t1` group by `pq_test`.`t1`.`b` +explain select count(*) from t1 group by(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` group by `pq_test`.`t1`.`c` +explain select count(c) from t1 group by(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t1`.`c`) AS `count(c)` from `pq_test`.`t1` group by `pq_test`.`t1`.`b` +CREATE TABLE `t2` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`a` varchar(10) DEFAULT NULL, +PRIMARY KEY (`id`) +); +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2 values(1, 'a'), (2, 'b'); +set session force_parallel_execute=0; +explain select sum(id) from t2 group by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t2`.`id`) AS `sum(id)` from `pq_test`.`t2` group by `pq_test`.`t2`.`id` +explain select avg(id) from t2 group by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t2`.`id`) AS `avg(id)` from `pq_test`.`t2` group by `pq_test`.`t2`.`id` +explain select count(id) from t2 group by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t2`.`id`) AS `count(id)` from `pq_test`.`t2` group by `pq_test`.`t2`.`id` +set session force_parallel_execute=1; +explain select sum(id) from t2 group by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select sum(`pq_test`.`t2`.`id`) AS `sum(id)` from `pq_test`.`t2` group by `pq_test`.`t2`.`id` +explain select avg(id) from t2 group by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select avg(`pq_test`.`t2`.`id`) AS `avg(id)` from `pq_test`.`t2` group by `pq_test`.`t2`.`id` +explain select count(id) from t2 group by id; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(`pq_test`.`t2`.`id`) AS `count(id)` from `pq_test`.`t2` group by `pq_test`.`t2`.`id` +drop table t1; +drop table t2; +CREATE TABLE t1 (spID int, userID int, date date); +INSERT INTO t1 VALUES (1,1,'1998-01-01'); +INSERT INTO t1 VALUES (2,2,'2001-02-03'); +INSERT INTO t1 VALUES (3,1,'1988-12-20'); +INSERT INTO t1 VALUES (4,2,'1972-12-12'); +EXPLAIN SELECT MIN(t1.userID) = MIN(date) FROM t1 GROUP BY userid; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select (cast(min(`min(t1.userID)`) as double) = cast(min(`min(t1.``date``)`) as double)) AS `MIN(t1.userID) = MIN(date)` from `pq_test`.`t1` group by `pq_test`.`t1`.`userID` +EXPLAIN SELECT FIRST_VALUE(date) OVER (ORDER BY spID = date) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select first_value(`pq_test`.`t1`.`date`) OVER (ORDER BY (cast(`pq_test`.`t1`.`spID` as double) = cast(`pq_test`.`t1`.`date` as double)) ) AS `FIRST_VALUE(date) OVER (ORDER BY spID = date)` from `pq_test`.`t1` +EXPLAIN SELECT date, spid = FIRST_VALUE(date) OVER (ORDER BY date ) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 Using filesort +Warnings: +Note 3598 To get information about window functions use EXPLAIN FORMAT=JSON +Note 1003 /* select#1 */ select `pq_test`.`t1`.`date` AS `date`,(cast(`pq_test`.`t1`.`spID` as double) = cast(first_value(`pq_test`.`t1`.`date`) OVER (ORDER BY `pq_test`.`t1`.`date` ) as double)) AS `spid = FIRST_VALUE(date) OVER (ORDER BY date )` from `pq_test`.`t1` +# +# No casts when constants or constant functions are involved +# +EXPLAIN SELECT * from t1 WHERE userID = DATE'2012-02-20'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`spID` AS `spID`,`pq_test`.`t1`.`userID` AS `userID`,`pq_test`.`t1`.`date` AS `date` from `pq_test`.`t1` where (`pq_test`.`t1`.`userID` = DATE'2012-02-20') +EXPLAIN SELECT * FROM t1 WHERE date = NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`spID` AS `spID`,`pq_test`.`t1`.`userID` AS `userID`,`pq_test`.`t1`.`date` AS `date` from `pq_test`.`t1` where (`pq_test`.`t1`.`date` = NULL) +EXPLAIN SELECT * FROM t1 WHERE date = CAST('20:21:22' AS TIME); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 25.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`spID` AS `spID`,`pq_test`.`t1`.`userID` AS `userID`,`pq_test`.`t1`.`date` AS `date` from `pq_test`.`t1` where (`pq_test`.`t1`.`date` = (cast('20:21:22' as time))) +EXPLAIN SELECT date, to_seconds(date) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`date` AS `date`,to_seconds(`pq_test`.`t1`.`date`) AS `to_seconds(date)` from `pq_test`.`t1` +EXPLAIN SELECT date, period_add(concat(year(date), month(date)), 1) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`date` AS `date`,period_add(concat(year(`pq_test`.`t1`.`date`),month(`pq_test`.`t1`.`date`)),1) AS `period_add(concat(year(date), month(date)), 1)` from `pq_test`.`t1` +EXPLAIN SELECT date, period_diff(concat(year(date), month(date)), 197001) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`date` AS `date`,period_diff(concat(year(`pq_test`.`t1`.`date`),month(`pq_test`.`t1`.`date`)),197001) AS `period_diff(concat(year(date), month(date)), 197001)` from `pq_test`.`t1` +EXPLAIN SELECT concat(spID, space(2)) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select concat(`pq_test`.`t1`.`spID`,space(2)) AS `concat(spID, space(2))` from `pq_test`.`t1` +CREATE TABLE t2 (c1 int, c2 varchar(3)); +INSERT INTO t2 VALUES (1, 'aaa'); +INSERT INTO t2 VALUES (2, 'bbb'); +INSERT INTO t2 VALUES (3, 'ccc'); +EXPLAIN SELECT c2, AES_ENCRYPT(c2, 'a') FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`c2` AS `c2`,aes_encrypt(`pq_test`.`t2`.`c2`,'a') AS `AES_ENCRYPT(c2, 'a')` from `pq_test`.`t2` +EXPLAIN SELECT c2, BIT_LENGTH(c2) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`c2` AS `c2`,bit_length(`pq_test`.`t2`.`c2`) AS `BIT_LENGTH(c2)` from `pq_test`.`t2` +EXPLAIN SELECT c1, c2, NULLIF(c1, 1) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`c1` AS `c1`,`pq_test`.`t2`.`c2` AS `c2`,nullif(`pq_test`.`t2`.`c1`,1) AS `NULLIF(c1, 1)` from `pq_test`.`t2` +EXPLAIN SELECT c2, compress(c2) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`c2` AS `c2`,compress(`pq_test`.`t2`.`c2`) AS `compress(c2)` from `pq_test`.`t2` +EXPLAIN SELECT c2, uncompressed_length(c2) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`c2` AS `c2`,uncompressed_length(`pq_test`.`t2`.`c2`) AS `uncompressed_length(c2)` from `pq_test`.`t2` +EXPLAIN SELECT export_set(5, c2, upper(c2)) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select export_set(5,`pq_test`.`t2`.`c2`,upper(`pq_test`.`t2`.`c2`)) AS `export_set(5, c2, upper(c2))` from `pq_test`.`t2` +EXPLAIN SELECT export_set(5, c2, upper(c2), ",") FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select export_set(5,`pq_test`.`t2`.`c2`,upper(`pq_test`.`t2`.`c2`),',') AS `export_set(5, c2, upper(c2), ",")` from `pq_test`.`t2` +EXPLAIN SELECT export_set(5, c2, upper(c2), ",", 5) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select export_set(5,`pq_test`.`t2`.`c2`,upper(`pq_test`.`t2`.`c2`),',',5) AS `export_set(5, c2, upper(c2), ",", 5)` from `pq_test`.`t2` +EXPLAIN SELECT SHA2(c2, 5) FROM t2; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +Warnings: +Warning 1583 Incorrect parameters in the call to native function 'sha2' +Note 1003 /* select#1 */ select sha2(`pq_test`.`t2`.`c2`,5) AS `SHA2(c2, 5)` from `pq_test`.`t2` +EXPLAIN SELECT * FROM t2 WHERE c1 IN (1, 2, 4); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 50.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 50.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`c1` AS `c1`,`pq_test`.`t2`.`c2` AS `c2` from `pq_test`.`t2` where (`pq_test`.`t2`.`c1` in (1,2,4)) +DROP TABLE t1, t2; +set session force_parallel_execute = @saved_force_parallel_execute; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_flush.result-pq b/mysql-test/suite/parallel_query/r/pq_flush.result-pq new file mode 100644 index 000000000..1fc3e4a63 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_flush.result-pq @@ -0,0 +1,32 @@ +# Test pq select while flush tables +drop table if exists t1; +# --> connect default +create table t1 (a int); +insert into t1 values(1),(2),(3); +select * from t1; +a +1 +2 +3 +# sending lock table t1 read ... +lock table t1 read; +# --> connect con1 +# sending flush table t1 ... +flush table t1; +# Let flush table sync in. +select * from t1; +a +1 +2 +3 +#--> connection con2 +select * from t1; +# --> connection default +# con2 cannot do select while flushing +select * from t1; +a +1 +2 +3 +unlock tables; +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_fullscan.result-pq b/mysql-test/suite/parallel_query/r/pq_fullscan.result-pq new file mode 100644 index 000000000..7243703b5 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_fullscan.result-pq @@ -0,0 +1,41 @@ +create database pq_test; +use pq_test; +create table t1( +id int primary key auto_increment, +col1 varchar(100), +col2 int, +key idx_col2(col2) +)engine= innodb; +show variables like 'force_parallel_execute'; +Variable_name Value +force_parallel_execute ON +select count(*) from pq_test.t1; +count(*) +100 +select * from pq_test.t1 limit 1; +id col1 col2 +1 testtesttesttest 100 +select * from pq_test.t1; +select id, col2 from pq_test.t1 force index(idx_col2); +SELECT * FROM t1 WHERE id IN (1, 10, 20, 80, 90, 100, 30, 40, 50, 60, 70); +id col1 col2 +1 testtesttesttest 100 +10 testtesttesttest 91 +20 testtesttesttest 81 +30 testtesttesttest 71 +40 testtesttesttest 61 +50 testtesttesttest 51 +60 testtesttesttest 41 +70 testtesttesttest 31 +80 testtesttesttest 21 +90 testtesttesttest 11 +100 testtesttesttest 1 +drop table pq_test.t1; +drop database pq_test; +use test; +create table t1( firstname char(20), lastname char(20)); +insert into t1 values ("john","doe"),("John","Doe"); +select * from t1 where firstname='john' and binary 'john' = firstname; +firstname lastname +john doe +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_group_by.result b/mysql-test/suite/parallel_query/r/pq_group_by.result new file mode 100644 index 000000000..c56d1a30c --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_group_by.result @@ -0,0 +1,886 @@ +create table t1(a int primary key, b varchar(10), c decimal(5,2), d double); +SELECT COUNT(a) FROM t1; +COUNT(a) +0 +SELECT SUM(a) FROM t1; +SUM(a) +NULL +SELECT AVG(a) FROM t1; +AVG(a) +NULL +insert into t1 values (1, 'The', '3.14', '3.14'); +insert into t1 values (2, 'quick', '4.25', '3.14'); +insert into t1 values (3, 'brown', '5.36', '3.14'); +insert into t1 values (4, 'fox', '6.47', '3.14'); +insert into t1 values (5, 'jumps', '3.14', '6.28'); +insert into t1 values (6, 'over', '4.25', '6.28'); +insert into t1 values (7, 'the', '5.36', '6.28'); +insert into t1 values (8, 'lazy', '6.47', '6.28'); +insert into t1 values (9, 'dog', '7.58', '6.28'); +select count(*) from t1; +count(*) +9 +select count(a) from t1; +count(a) +9 +select count(b) from t1; +count(b) +9 +select count(c) from t1; +count(c) +9 +select count(d) from t1; +count(d) +9 +select sum(a) from t1; +sum(a) +45 +select sum(c) from t1; +sum(c) +46.02 +select sum(d) from t1; +sum(d) +43.96 +select avg(a) from t1; +avg(a) +5.0000 +select avg(c) from t1; +avg(c) +5.113333 +select avg(d) from t1; +avg(d) +4.884444444444444 +select std(d) from t1; +std(d) +1.5602785442998535 +select variance(d) from t1; +variance(d) +2.4344691358024697 +select sum(a) from t1 where c > 5.0; +sum(a) +31 +select sum(c) from t1 where a > 5; +sum(c) +23.66 +select sum(d) from t1 where c > 5.0; +sum(d) +25.12 +select avg(a) from t1 where c > 5.0; +avg(a) +6.2000 +select avg(c) from t1 where a > 5; +avg(c) +5.915000 +select avg(d) from t1 where c > 5.0; +avg(d) +5.024 +select count(*) from t1 where c > 5.0; +count(*) +5 +select count(a) from t1 where a > 5; +count(a) +4 +select count(b) from t1 where c > 5.0; +count(b) +5 +select count(c) from t1 where d > 6.0; +count(c) +5 +select count(d) from t1 where a > 5; +count(d) +4 +select c,sum(a) from t1 group by(c); +c sum(a) +3.14 6 +4.25 8 +5.36 10 +6.47 12 +7.58 9 +select b,sum(c) from t1 group by(b); +b sum(c) +The 8.50 +quick 4.25 +brown 5.36 +fox 6.47 +jumps 3.14 +over 4.25 +lazy 6.47 +dog 7.58 +select c,sum(d) from t1 group by(c); +c sum(d) +3.14 9.42 +4.25 9.42 +5.36 9.42 +6.47 9.42 +7.58 6.28 +select c,avg(a) from t1 group by(c); +c avg(a) +3.14 3.0000 +4.25 4.0000 +5.36 5.0000 +6.47 6.0000 +7.58 9.0000 +select b,avg(c) from t1 group by(b); +b avg(c) +The 4.250000 +quick 4.250000 +brown 5.360000 +fox 6.470000 +jumps 3.140000 +over 4.250000 +lazy 6.470000 +dog 7.580000 +select c,avg(d) from t1 group by(c); +c avg(d) +3.14 4.71 +4.25 4.71 +5.36 4.71 +6.47 4.71 +7.58 6.28 +select count(*) from t1 group by(c); +count(*) +2 +2 +2 +2 +1 +select count(a) from t1 group by(a); +count(a) +1 +1 +1 +1 +1 +1 +1 +1 +1 +select count(b) from t1 group by(c); +count(b) +2 +2 +2 +2 +1 +select count(c) from t1 group by(b); +count(c) +2 +1 +1 +1 +1 +1 +1 +1 +select count(d) from t1 group by(c); +count(d) +2 +2 +2 +2 +1 +drop table t1; +CREATE TABLE `t2` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`a` varchar(10) DEFAULT NULL, +PRIMARY KEY (`id`) +); +insert into t2 values(1, 'a'), (2, 'b'); +select sum(id) from t2 group by id; +sum(id) +1 +2 +select avg(id) from t2 group by id; +avg(id) +1.0000 +2.0000 +select count(id) from t2 group by id; +count(id) +1 +1 +drop table t2; +create table t1 (a char(2), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), ('b', '2004-02-01 00:00:00'); +select max(t) from t1 group by a; +max(t) +2004-01-01 01:00:00 +2004-02-01 00:00:00 +explain select max(t) from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`t`) AS `max(t)` from `test`.`t1` group by `test`.`t1`.`a` +select min(t) from t1 group by a; +min(t) +2004-01-01 00:00:00 +2004-02-01 00:00:00 +explain select min(t) from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`t`) AS `min(t)` from `test`.`t1` group by `test`.`t1`.`a` +drop table t1; +set sql_mode = ''; +set big_tables = 1; +CREATE TABLE t1( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +c2 INT NOT NULL, +UNIQUE KEY (c2,c1)); +INSERT INTO t1(c1,c2) VALUES (5,1), (4,1), (3,5), (2,3), (1,3); +SELECT * FROM t1 ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY id DESC; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +drop table t1; +CREATE TABLE t1 ( +spID int(10) unsigned, +userID int(10) unsigned, +score smallint(5) unsigned, +key (spid), +key (score) +); +INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select userid,count(*) from t1 group by userid order by userid; +userid count(*) +1 2 +2 1 +3 5 +select userid,count(*) from t1 group by userid order by null; +userid count(*) +1 2 +2 1 +3 5 +select userid,count(*) from t1 group by userid order by userid desc; +userid count(*) +3 5 +2 1 +1 2 +select spid,count(*) from t1 group by spid; +spid count(*) +1 1 +2 2 +3 1 +4 1 +5 1 +6 1 +7 1 +select spid,count(*) from t1 group by spid order by spid; +spid count(*) +1 1 +2 2 +3 1 +4 1 +5 1 +6 1 +7 1 +select spid,count(*) from t1 group by spid order by spid desc; +spid count(*) +7 1 +6 1 +5 1 +4 1 +3 1 +2 2 +1 1 +drop table t1; +set sql_mode = ''; +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234); +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 +group by companynr,t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +drop table t3; +CREATE TABLE t1 (a int, b int); +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a; +a sum(a) +0 0 +1 96 +2 192 +3 288 +4 384 +5 480 +6 576 +7 672 +8 768 +9 864 +10 960 +11 1056 +12 1152 +13 1248 +14 1344 +15 1440 +16 1536 +17 1632 +18 1728 +19 1216 +20 1280 +21 1344 +22 1408 +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a desc; +a sum(a) +22 1408 +21 1344 +20 1280 +19 1216 +18 1728 +17 1632 +16 1536 +15 1440 +14 1344 +13 1248 +12 1152 +11 1056 +10 960 +9 864 +8 768 +7 672 +6 576 +5 480 +4 384 +3 288 +2 192 +1 96 +0 0 +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a limit 10; +a sum(a) +0 0 +1 96 +2 192 +3 288 +4 384 +5 480 +6 576 +7 672 +8 768 +9 864 +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a limit 10, 10; +a sum(a) +10 960 +11 1056 +12 1152 +13 1248 +14 1344 +15 1440 +16 1536 +17 1632 +18 1728 +19 1216 +SELECT b, avg(a) FROM t1 GROUP BY a, b ORDER BY b, NULL limit 10; +b avg(a) +0 0.0000 +0 5.0000 +0 7.0000 +0 4.0000 +0 2.0000 +0 9.0000 +0 3.0000 +0 6.0000 +0 8.0000 +0 1.0000 +SELECT b, sum(a) FROM t1 GROUP BY a, b ORDER BY NULL, a, b, NULL, a, NULL; +b sum(a) +0 0 +1 0 +3 0 +5 0 +7 0 +8 0 +9 0 +13 0 +14 0 +17 0 +18 0 +21 0 +25 0 +0 9 +1 21 +3 12 +5 9 +7 12 +8 3 +9 3 +13 12 +14 3 +17 3 +18 3 +21 3 +25 3 +0 18 +1 42 +3 24 +5 18 +7 24 +8 6 +9 6 +13 24 +14 6 +17 6 +18 6 +21 6 +25 6 +0 27 +1 63 +3 36 +5 27 +7 36 +8 9 +9 9 +13 36 +14 9 +17 9 +18 9 +21 9 +25 9 +0 36 +1 84 +3 48 +5 36 +7 48 +8 12 +9 12 +13 48 +14 12 +17 12 +18 12 +21 12 +25 12 +0 45 +1 105 +3 60 +5 45 +7 60 +8 15 +9 15 +13 60 +14 15 +17 15 +18 15 +21 15 +25 15 +0 54 +1 126 +3 72 +5 54 +7 72 +8 18 +9 18 +13 72 +14 18 +17 18 +18 18 +21 18 +25 18 +0 63 +1 147 +3 84 +5 63 +7 84 +8 21 +9 21 +13 84 +14 21 +17 21 +18 21 +21 21 +25 21 +0 72 +1 168 +3 96 +5 72 +7 96 +8 24 +9 24 +13 96 +14 24 +17 24 +18 24 +21 24 +25 24 +0 81 +1 189 +3 108 +5 81 +7 108 +8 27 +9 27 +13 108 +14 27 +17 27 +18 27 +21 27 +25 27 +0 90 +1 210 +3 120 +5 90 +7 120 +8 30 +9 30 +13 120 +14 30 +17 30 +18 30 +21 30 +25 30 +0 99 +1 231 +3 132 +5 99 +7 132 +8 33 +9 33 +13 132 +14 33 +17 33 +18 33 +21 33 +25 33 +0 108 +1 252 +3 144 +5 108 +7 144 +8 36 +9 36 +13 144 +14 36 +17 36 +18 36 +21 36 +25 36 +0 117 +1 273 +3 156 +5 117 +7 156 +8 39 +9 39 +13 156 +14 39 +17 39 +18 39 +21 39 +25 39 +0 126 +1 294 +3 168 +5 126 +7 168 +8 42 +9 42 +13 168 +14 42 +17 42 +18 42 +21 42 +25 42 +0 135 +1 315 +3 180 +5 135 +7 180 +8 45 +9 45 +13 180 +14 45 +17 45 +18 45 +21 45 +25 45 +0 144 +1 336 +3 192 +5 144 +7 192 +8 48 +9 48 +13 192 +14 48 +17 48 +18 48 +21 48 +25 48 +0 153 +1 357 +3 204 +5 153 +7 204 +8 51 +9 51 +13 204 +14 51 +17 51 +18 51 +21 51 +25 51 +0 162 +1 378 +3 216 +5 162 +7 216 +8 54 +9 54 +13 216 +14 54 +17 54 +18 54 +21 54 +25 54 +0 114 +1 266 +3 152 +5 114 +7 152 +8 38 +9 38 +13 152 +14 38 +17 38 +18 38 +21 38 +25 38 +0 120 +1 280 +3 160 +5 120 +7 160 +8 40 +9 40 +13 160 +14 40 +17 40 +18 40 +21 40 +25 40 +0 126 +1 294 +3 168 +5 126 +7 168 +8 42 +9 42 +13 168 +14 42 +17 42 +18 42 +21 42 +25 42 +0 132 +1 308 +3 176 +5 132 +7 176 +8 44 +9 44 +13 176 +14 44 +17 44 +18 44 +21 44 +25 44 +SELECT b, sum(a) FROM t1 GROUP BY a, b ORDER BY NULL, a, b, NULL, a, NULL limit 10, 5; +b sum(a) +18 0 +21 0 +25 0 +0 9 +1 21 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +SELECT a FROM t1 GROUP BY a ORDER by a Limit 10; +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +SELECT a FROM t1 GROUP BY a HAVING a > 1 ORDER by a Limit 10; +a +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1 ORDER by a Limit 10; +a +SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1 ORDER by a Limit 10; +x a +SELECT a FROM t1 GROUP BY a HAVING (a % 11) > 1 ORDER by a Limit 10; +a +2 +3 +4 +5 +6 +7 +8 +9 +10 +13 +SELECT a, b FROM t1 GROUP BY a, b HAVING a + b > 31 ORDER by a, b Limit 10; +a b +22 10 +23 9 +23 10 +24 8 +24 9 +24 10 +25 7 +25 8 +25 9 +25 10 +SELECT a, b FROM t1 GROUP BY a, b HAVING a * b > 61 ORDER by a, b Limit 10, 10; +a b +10 8 +10 9 +10 10 +11 6 +11 7 +11 8 +11 9 +11 10 +12 6 +12 7 +SELECT a, b FROM t1 GROUP BY a, b HAVING sin(a % 11) > 0.5 and cos(b % 7) < 0.5 ORDER by a, b Limit 10, 10; +a b +2 9 +2 10 +7 2 +7 3 +7 4 +7 5 +7 9 +7 10 +8 2 +8 3 +EXPLAIN SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2048 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `sum(b)` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` having (sum(`test`.`t1`.`b`) > 5) order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 10 +SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +a sum(b) +0 6 +0 12 +0 18 +0 24 +0 30 +0 36 +0 42 +0 48 +0 54 +0 60 +EXPLAIN SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2048 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `sum(b)` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` having (sum(`test`.`t1`.`b`) > 5) order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 10 +SELECT a, b from t1 GROUP BY a, b HAVING avg(b) > 5 ORDER BY a, b LIMIT 10; +a b +0 6 +0 7 +0 8 +0 9 +0 10 +1 6 +1 7 +1 8 +1 9 +1 10 +SELECT sum(a), avg(b) from t1 GROUP BY a, b HAVING sum(a) * avg(b) > 25 ORDER BY a, b LIMIT 10; +sum(a) avg(b) +9 3.0000 +9 4.0000 +9 5.0000 +9 6.0000 +9 7.0000 +9 8.0000 +9 9.0000 +9 10.0000 +18 2.0000 +18 3.0000 +DROP TABLE t1; diff --git a/mysql-test/suite/parallel_query/r/pq_group_by.result-pq b/mysql-test/suite/parallel_query/r/pq_group_by.result-pq new file mode 100644 index 000000000..0c51cf6be --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_group_by.result-pq @@ -0,0 +1,888 @@ +create table t1(a int primary key, b varchar(10), c decimal(5,2), d double); +SELECT COUNT(a) FROM t1; +COUNT(a) +0 +SELECT SUM(a) FROM t1; +SUM(a) +NULL +SELECT AVG(a) FROM t1; +AVG(a) +NULL +insert into t1 values (1, 'The', '3.14', '3.14'); +insert into t1 values (2, 'quick', '4.25', '3.14'); +insert into t1 values (3, 'brown', '5.36', '3.14'); +insert into t1 values (4, 'fox', '6.47', '3.14'); +insert into t1 values (5, 'jumps', '3.14', '6.28'); +insert into t1 values (6, 'over', '4.25', '6.28'); +insert into t1 values (7, 'the', '5.36', '6.28'); +insert into t1 values (8, 'lazy', '6.47', '6.28'); +insert into t1 values (9, 'dog', '7.58', '6.28'); +select count(*) from t1; +count(*) +9 +select count(a) from t1; +count(a) +9 +select count(b) from t1; +count(b) +9 +select count(c) from t1; +count(c) +9 +select count(d) from t1; +count(d) +9 +select sum(a) from t1; +sum(a) +45 +select sum(c) from t1; +sum(c) +46.02 +select sum(d) from t1; +sum(d) +43.96 +select avg(a) from t1; +avg(a) +5.0000 +select avg(c) from t1; +avg(c) +5.113333 +select avg(d) from t1; +avg(d) +4.884444444444444 +select std(d) from t1; +std(d) +1.5602785442998535 +select variance(d) from t1; +variance(d) +2.4344691358024697 +select sum(a) from t1 where c > 5.0; +sum(a) +31 +select sum(c) from t1 where a > 5; +sum(c) +23.66 +select sum(d) from t1 where c > 5.0; +sum(d) +25.12 +select avg(a) from t1 where c > 5.0; +avg(a) +6.2000 +select avg(c) from t1 where a > 5; +avg(c) +5.915000 +select avg(d) from t1 where c > 5.0; +avg(d) +5.024 +select count(*) from t1 where c > 5.0; +count(*) +5 +select count(a) from t1 where a > 5; +count(a) +4 +select count(b) from t1 where c > 5.0; +count(b) +5 +select count(c) from t1 where d > 6.0; +count(c) +5 +select count(d) from t1 where a > 5; +count(d) +4 +select c,sum(a) from t1 group by(c); +c sum(a) +3.14 6 +4.25 8 +5.36 10 +6.47 12 +7.58 9 +select b,sum(c) from t1 group by(b); +b sum(c) +The 8.50 +quick 4.25 +brown 5.36 +fox 6.47 +jumps 3.14 +over 4.25 +lazy 6.47 +dog 7.58 +select c,sum(d) from t1 group by(c); +c sum(d) +3.14 9.42 +4.25 9.42 +5.36 9.42 +6.47 9.42 +7.58 6.28 +select c,avg(a) from t1 group by(c); +c avg(a) +3.14 3.0000 +4.25 4.0000 +5.36 5.0000 +6.47 6.0000 +7.58 9.0000 +select b,avg(c) from t1 group by(b); +b avg(c) +The 4.250000 +quick 4.250000 +brown 5.360000 +fox 6.470000 +jumps 3.140000 +over 4.250000 +lazy 6.470000 +dog 7.580000 +select c,avg(d) from t1 group by(c); +c avg(d) +3.14 4.71 +4.25 4.71 +5.36 4.71 +6.47 4.71 +7.58 6.28 +select count(*) from t1 group by(c); +count(*) +2 +2 +2 +2 +1 +select count(a) from t1 group by(a); +count(a) +1 +1 +1 +1 +1 +1 +1 +1 +1 +select count(b) from t1 group by(c); +count(b) +2 +2 +2 +2 +1 +select count(c) from t1 group by(b); +count(c) +2 +1 +1 +1 +1 +1 +1 +1 +select count(d) from t1 group by(c); +count(d) +2 +2 +2 +2 +1 +drop table t1; +CREATE TABLE `t2` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`a` varchar(10) DEFAULT NULL, +PRIMARY KEY (`id`) +); +insert into t2 values(1, 'a'), (2, 'b'); +select sum(id) from t2 group by id; +sum(id) +1 +2 +select avg(id) from t2 group by id; +avg(id) +1.0000 +2.0000 +select count(id) from t2 group by id; +count(id) +1 +1 +drop table t2; +create table t1 (a char(2), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), ('b', '2004-02-01 00:00:00'); +select max(t) from t1 group by a; +max(t) +2004-01-01 01:00:00 +2004-02-01 00:00:00 +explain select max(t) from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select max(`test`.`t1`.`t`) AS `max(t)` from `test`.`t1` group by `test`.`t1`.`a` +select min(t) from t1 group by a; +min(t) +2004-01-01 00:00:00 +2004-02-01 00:00:00 +explain select min(t) from t1 group by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select min(`test`.`t1`.`t`) AS `min(t)` from `test`.`t1` group by `test`.`t1`.`a` +drop table t1; +set sql_mode = ''; +set big_tables = 1; +CREATE TABLE t1( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +c2 INT NOT NULL, +UNIQUE KEY (c2,c1)); +INSERT INTO t1(c1,c2) VALUES (5,1), (4,1), (3,5), (2,3), (1,3); +SELECT * FROM t1 ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY c1; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +SELECT * FROM t1 GROUP BY id ORDER BY id DESC; +id c1 c2 +5 1 3 +4 2 3 +3 3 5 +2 4 1 +1 5 1 +drop table t1; +CREATE TABLE t1 ( +spID int(10) unsigned, +userID int(10) unsigned, +score smallint(5) unsigned, +key (spid), +key (score) +); +INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +select userid,count(*) from t1 group by userid order by userid; +userid count(*) +1 2 +2 1 +3 5 +select userid,count(*) from t1 group by userid order by null; +userid count(*) +1 2 +2 1 +3 5 +select userid,count(*) from t1 group by userid order by userid desc; +userid count(*) +3 5 +2 1 +1 2 +select spid,count(*) from t1 group by spid; +spid count(*) +1 1 +2 2 +3 1 +4 1 +5 1 +6 1 +7 1 +select spid,count(*) from t1 group by spid order by spid; +spid count(*) +1 1 +2 2 +3 1 +4 1 +5 1 +6 1 +7 1 +select spid,count(*) from t1 group by spid order by spid desc; +spid count(*) +7 1 +6 1 +5 1 +4 1 +3 1 +2 2 +1 1 +drop table t1; +set sql_mode = ''; +create table t3 ( +period int not null, +name char(32) not null, +companynr int not null, +price double(11,0), +price2 double(11,0), +key (period), +key (name) +); +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234); +create temporary table tmp select * from t3; +Warnings: +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release. +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +alter table t3 add t2nr int not null auto_increment primary key first; +drop table tmp; +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 +group by companynr,t2nr order by companynr,t2nr limit 10; +companynr t2nr count(price) sum(price) min(price) max(price) avg(price) +37 1 1 5987435 5987435 5987435 5987435.0000 +37 2 1 28357832 28357832 28357832 28357832.0000 +37 3 1 39654943 39654943 39654943 39654943.0000 +37 11 1 5987435 5987435 5987435 5987435.0000 +37 12 1 28357832 28357832 28357832 28357832.0000 +37 13 1 39654943 39654943 39654943 39654943.0000 +37 21 1 5987435 5987435 5987435 5987435.0000 +37 22 1 28357832 28357832 28357832 28357832.0000 +37 23 1 39654943 39654943 39654943 39654943.0000 +37 31 1 5987435 5987435 5987435 5987435.0000 +drop table t3; +CREATE TABLE t1 (a int, b int); +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a; +a sum(a) +0 0 +1 96 +2 192 +3 288 +4 384 +5 480 +6 576 +7 672 +8 768 +9 864 +10 960 +11 1056 +12 1152 +13 1248 +14 1344 +15 1440 +16 1536 +17 1632 +18 1728 +19 1216 +20 1280 +21 1344 +22 1408 +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a desc; +a sum(a) +22 1408 +21 1344 +20 1280 +19 1216 +18 1728 +17 1632 +16 1536 +15 1440 +14 1344 +13 1248 +12 1152 +11 1056 +10 960 +9 864 +8 768 +7 672 +6 576 +5 480 +4 384 +3 288 +2 192 +1 96 +0 0 +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a limit 10; +a sum(a) +0 0 +1 96 +2 192 +3 288 +4 384 +5 480 +6 576 +7 672 +8 768 +9 864 +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a limit 10, 10; +a sum(a) +10 960 +11 1056 +12 1152 +13 1248 +14 1344 +15 1440 +16 1536 +17 1632 +18 1728 +19 1216 +SELECT b, avg(a) FROM t1 GROUP BY a, b ORDER BY b, NULL limit 10; +b avg(a) +0 0.0000 +0 5.0000 +0 7.0000 +0 4.0000 +0 2.0000 +0 9.0000 +0 3.0000 +0 6.0000 +0 8.0000 +0 1.0000 +SELECT b, sum(a) FROM t1 GROUP BY a, b ORDER BY NULL, a, b, NULL, a, NULL; +b sum(a) +0 0 +1 0 +3 0 +5 0 +7 0 +8 0 +9 0 +13 0 +14 0 +17 0 +18 0 +21 0 +25 0 +0 9 +1 21 +3 12 +5 9 +7 12 +8 3 +9 3 +13 12 +14 3 +17 3 +18 3 +21 3 +25 3 +0 18 +1 42 +3 24 +5 18 +7 24 +8 6 +9 6 +13 24 +14 6 +17 6 +18 6 +21 6 +25 6 +0 27 +1 63 +3 36 +5 27 +7 36 +8 9 +9 9 +13 36 +14 9 +17 9 +18 9 +21 9 +25 9 +0 36 +1 84 +3 48 +5 36 +7 48 +8 12 +9 12 +13 48 +14 12 +17 12 +18 12 +21 12 +25 12 +0 45 +1 105 +3 60 +5 45 +7 60 +8 15 +9 15 +13 60 +14 15 +17 15 +18 15 +21 15 +25 15 +0 54 +1 126 +3 72 +5 54 +7 72 +8 18 +9 18 +13 72 +14 18 +17 18 +18 18 +21 18 +25 18 +0 63 +1 147 +3 84 +5 63 +7 84 +8 21 +9 21 +13 84 +14 21 +17 21 +18 21 +21 21 +25 21 +0 72 +1 168 +3 96 +5 72 +7 96 +8 24 +9 24 +13 96 +14 24 +17 24 +18 24 +21 24 +25 24 +0 81 +1 189 +3 108 +5 81 +7 108 +8 27 +9 27 +13 108 +14 27 +17 27 +18 27 +21 27 +25 27 +0 90 +1 210 +3 120 +5 90 +7 120 +8 30 +9 30 +13 120 +14 30 +17 30 +18 30 +21 30 +25 30 +0 99 +1 231 +3 132 +5 99 +7 132 +8 33 +9 33 +13 132 +14 33 +17 33 +18 33 +21 33 +25 33 +0 108 +1 252 +3 144 +5 108 +7 144 +8 36 +9 36 +13 144 +14 36 +17 36 +18 36 +21 36 +25 36 +0 117 +1 273 +3 156 +5 117 +7 156 +8 39 +9 39 +13 156 +14 39 +17 39 +18 39 +21 39 +25 39 +0 126 +1 294 +3 168 +5 126 +7 168 +8 42 +9 42 +13 168 +14 42 +17 42 +18 42 +21 42 +25 42 +0 135 +1 315 +3 180 +5 135 +7 180 +8 45 +9 45 +13 180 +14 45 +17 45 +18 45 +21 45 +25 45 +0 144 +1 336 +3 192 +5 144 +7 192 +8 48 +9 48 +13 192 +14 48 +17 48 +18 48 +21 48 +25 48 +0 153 +1 357 +3 204 +5 153 +7 204 +8 51 +9 51 +13 204 +14 51 +17 51 +18 51 +21 51 +25 51 +0 162 +1 378 +3 216 +5 162 +7 216 +8 54 +9 54 +13 216 +14 54 +17 54 +18 54 +21 54 +25 54 +0 114 +1 266 +3 152 +5 114 +7 152 +8 38 +9 38 +13 152 +14 38 +17 38 +18 38 +21 38 +25 38 +0 120 +1 280 +3 160 +5 120 +7 160 +8 40 +9 40 +13 160 +14 40 +17 40 +18 40 +21 40 +25 40 +0 126 +1 294 +3 168 +5 126 +7 168 +8 42 +9 42 +13 168 +14 42 +17 42 +18 42 +21 42 +25 42 +0 132 +1 308 +3 176 +5 132 +7 176 +8 44 +9 44 +13 176 +14 44 +17 44 +18 44 +21 44 +25 44 +SELECT b, sum(a) FROM t1 GROUP BY a, b ORDER BY NULL, a, b, NULL, a, NULL limit 10, 5; +b sum(a) +18 0 +21 0 +25 0 +0 9 +1 21 +DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +SELECT a FROM t1 GROUP BY a ORDER by a Limit 10; +a +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +SELECT a FROM t1 GROUP BY a HAVING a > 1 ORDER by a Limit 10; +a +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1 ORDER by a Limit 10; +a +SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1 ORDER by a Limit 10; +x a +SELECT a FROM t1 GROUP BY a HAVING (a % 11) > 1 ORDER by a Limit 10; +a +2 +3 +4 +5 +6 +7 +8 +9 +10 +13 +SELECT a, b FROM t1 GROUP BY a, b HAVING a + b > 31 ORDER by a, b Limit 10; +a b +22 10 +23 9 +23 10 +24 8 +24 9 +24 10 +25 7 +25 8 +25 9 +25 10 +SELECT a, b FROM t1 GROUP BY a, b HAVING a * b > 61 ORDER by a, b Limit 10, 10; +a b +10 8 +10 9 +10 10 +11 6 +11 7 +11 8 +11 9 +11 10 +12 6 +12 7 +SELECT a, b FROM t1 GROUP BY a, b HAVING sin(a % 11) > 0.5 and cos(b % 7) < 0.5 ORDER by a, b Limit 10, 10; +a b +2 9 +2 10 +7 2 +7 3 +7 4 +7 5 +7 9 +7 10 +8 2 +8 3 +EXPLAIN SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2048 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `sum(b)` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` having (sum(`test`.`t1`.`b`) > 5) order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 10 +SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +a sum(b) +0 6 +0 12 +0 18 +0 24 +0 30 +0 36 +0 42 +0 48 +0 54 +0 60 +EXPLAIN SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2048 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,sum(`test`.`t1`.`b`) AS `sum(b)` from `test`.`t1` group by `test`.`t1`.`a`,`test`.`t1`.`b` having (sum(`test`.`t1`.`b`) > 5) order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 10 +SELECT a, b from t1 GROUP BY a, b HAVING avg(b) > 5 ORDER BY a, b LIMIT 10; +a b +0 6 +0 7 +0 8 +0 9 +0 10 +1 6 +1 7 +1 8 +1 9 +1 10 +SELECT sum(a), avg(b) from t1 GROUP BY a, b HAVING sum(a) * avg(b) > 25 ORDER BY a, b LIMIT 10; +sum(a) avg(b) +9 3.0000 +9 4.0000 +9 5.0000 +9 6.0000 +9 7.0000 +9 8.0000 +9 9.0000 +9 10.0000 +18 2.0000 +18 3.0000 +DROP TABLE t1; diff --git a/mysql-test/suite/parallel_query/r/pq_having.result-pq b/mysql-test/suite/parallel_query/r/pq_having.result-pq new file mode 100644 index 000000000..bff6773f1 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_having.result-pq @@ -0,0 +1,251 @@ +drop database if exists pq_having_database; +create database pq_having_database; +use pq_having_database; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( +`fd1` int NOT NULL, +`fd2` int NOT NULL +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO t1 VALUES(1, 1); +INSERT INTO t1 VALUES(2, 2); +INSERT INTO t1 VALUES(3, 3); +analyze table t1; +Table Op Msg_type Msg_text +pq_having_database.t1 analyze status OK +explain select fd1, avg(fd2) from t1 group by fd1 having avg(fd1) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (avg(`pq_having_database`.`t1`.`fd1`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having avg(fd1) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having bit_and(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (bit_and(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having bit_and(fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having bit_or(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (bit_or(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having bit_or(fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having bit_xor(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (bit_xor(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having bit_xor(fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having count(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (count(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having count(fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having count(distinct fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (count(distinct `pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having count(distinct fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having group_concat(distinct fd2) is not null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (group_concat(distinct `pq_having_database`.`t1`.`fd2` separator ',') is not null) +select fd1, avg(fd2) from t1 group by fd1 having group_concat(distinct fd2) is not null; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, fd2, avg(fd2) from t1 group by fd1, fd2 having json_arrayagg(fd2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Warning 3986 Evaluating a JSON value in SQL boolean context does an implicit comparison against JSON integer 0; if this is not what you want, consider converting JSON to a SQL numeric type with JSON_VALUE RETURNING +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,`pq_having_database`.`t1`.`fd2` AS `fd2`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1`,`pq_having_database`.`t1`.`fd2` having (0 <> json_arrayagg(`pq_having_database`.`t1`.`fd2`)) +select fd1, fd2, avg(fd2) from t1 group by fd1, fd2 having json_arrayagg(fd2); +fd1 fd2 avg(fd2) +1 1 1.0000 +2 2 2.0000 +3 3 3.0000 +Warnings: +Warning 3986 Evaluating a JSON value in SQL boolean context does an implicit comparison against JSON integer 0; if this is not what you want, consider converting JSON to a SQL numeric type with JSON_VALUE RETURNING +explain select fd1, avg(fd2) from t1 group by fd1, fd2 having json_object(fd1, fd2) is not null; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1`,`pq_having_database`.`t1`.`fd2` having (json_object(`pq_having_database`.`t1`.`fd1`,`pq_having_database`.`t1`.`fd2`) is not null) +select fd1, avg(fd2) from t1 group by fd1, fd2 having json_object(fd1, fd2) is not null; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having std(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (std(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having std(fd2) > 0; +fd1 avg(fd2) +explain select fd1, avg(fd2) from t1 group by fd1 having stddev(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (std(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having stddev(fd2) > 0; +fd1 avg(fd2) +explain select fd1, avg(fd2) from t1 group by fd1 having stddev_pop(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (std(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having stddev_pop(fd2) > 0; +fd1 avg(fd2) +explain select fd1, avg(fd2) from t1 group by fd1 having stddev_samp(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (stddev_samp(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having stddev_samp(fd2) > 0; +fd1 avg(fd2) +explain select fd1, avg(fd2) from t1 group by fd1 having max(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (max(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having max(fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having min(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (min(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having min(fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having sum(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (sum(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having sum(fd2) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having var_pop(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (variance(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having var_pop(fd2) > 0; +fd1 avg(fd2) +explain select fd1, avg(fd2) from t1 group by fd1 having var_samp(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (var_samp(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having var_samp(fd2) > 0; +fd1 avg(fd2) +explain select fd1, avg(fd2) from t1 group by fd1 having variance(fd2) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (variance(`pq_having_database`.`t1`.`fd2`) > 0) +select fd1, avg(fd2) from t1 group by fd1 having variance(fd2) > 0; +fd1 avg(fd2) +explain select fd1, avg(fd2) from t1 group by fd1 having max(fd1)/min(fd1) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having ((max(`pq_having_database`.`t1`.`fd1`) / min(`pq_having_database`.`t1`.`fd1`)) > 0) +select fd1, avg(fd2) from t1 group by fd1 having max(fd1)/min(fd1) > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having max(fd1) + 1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having ((max(`pq_having_database`.`t1`.`fd1`) + 1) > 0) +select fd1, avg(fd2) from t1 group by fd1 having max(fd1) + 1 > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having fd1 + 1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having ((`pq_having_database`.`t1`.`fd1` + 1) > 0) +select fd1, avg(fd2) from t1 group by fd1 having fd1 + 1 > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2) from t1 group by fd1 having fd1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (`pq_having_database`.`t1`.`fd1` > 0) +select fd1, avg(fd2) from t1 group by fd1 having fd1 > 0; +fd1 avg(fd2) +1 1.0000 +2 2.0000 +3 3.0000 +explain select fd1, avg(fd2), max(fd1) from t1 group by fd1 having fd1 > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)`,max(`pq_having_database`.`t1`.`fd1`) AS `max(fd1)` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (`pq_having_database`.`t1`.`fd1` > 0) +select fd1, avg(fd2), max(fd1) from t1 group by fd1 having fd1 > 0; +fd1 avg(fd2) max(fd1) +1 1.0000 1 +2 2.0000 2 +3 3.0000 3 +explain select fd1, avg(fd2), avg(fd1) as avg from t1 group by fd1 having avg > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_having_database`.`t1`.`fd1` AS `fd1`,avg(`pq_having_database`.`t1`.`fd2`) AS `avg(fd2)`,avg(`pq_having_database`.`t1`.`fd1`) AS `avg` from `pq_having_database`.`t1` group by `pq_having_database`.`t1`.`fd1` having (`avg` > 0) +select fd1, avg(fd2), avg(fd1) as avg from t1 group by fd1 having avg > 0; +fd1 avg(fd2) avg +1 1.0000 1.0000 +2 2.0000 2.0000 +3 3.0000 3.0000 +drop table t1; +drop database pq_having_database; diff --git a/mysql-test/suite/parallel_query/r/pq_instant_add_column.result-pq b/mysql-test/suite/parallel_query/r/pq_instant_add_column.result-pq new file mode 100644 index 000000000..d268b929e --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_instant_add_column.result-pq @@ -0,0 +1,36 @@ +create database pq_test; +use pq_test; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; +CHECK TABLE t1; +Table Op Msg_type Msg_text +pq_test.t1 check status OK +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +6 6 100 206 Hello world +ROLLBACK; +SELECT * FROM t1; +a b c d e +1 1 100 201 Hello world +2 2 100 202 Hello world +3 3 100 203 Hello world +4 4 100 204 Hello world +5 5 100 205 Hello world +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; +a b c +1 1 500 +2 1000 100 +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_join.result-pq b/mysql-test/suite/parallel_query/r/pq_join.result-pq new file mode 100644 index 000000000..175f763f0 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_join.result-pq @@ -0,0 +1,286 @@ +drop database if exists pq_database; +create database pq_database; +use pq_database; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +create table t1(f1 TIME, f2 VARCHAR(1)); +insert into t1 values('08:35:24', 'X'); +insert into t1 values('14:51:13', 'S'); +insert into t1 values('11:22:33', 'Q'); +create table t2(pk integer); +insert into t2 values(1); +insert into t2 values(2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +analyze table t1; +Table Op Msg_type Msg_text +pq_database.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +pq_database.t2 analyze status OK +explain select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 16569 100.00 FirstMatch +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`select#2` FIRSTMATCH) */ `pq_database`.`t1`.`f1` AS `f1`,`pq_database`.`t1`.`f2` AS `f2` from `pq_database`.`t1` semi join (`pq_database`.`t2`) where true +select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2); +f1 f2 +08:35:24 X +14:51:13 S +11:22:33 Q +explain select * from t1 where exists (select /*+ semijoin(DUPSWEEDOUT)*/* from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 16569 100.00 Start temporary; End temporary +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`select#2` DUPSWEEDOUT) */ `pq_database`.`t1`.`f1` AS `f1`,`pq_database`.`t1`.`f2` AS `f2` from `pq_database`.`t1` semi join (`pq_database`.`t2`) where true +select * from t1 where exists (select /*+ semijoin(DUPSWEEDOUT)*/* from t2); +f1 f2 +08:35:24 X +14:51:13 S +11:22:33 Q +drop table t1; +drop table t2; +CREATE TABLE t1 (a INTEGER NOT NULL, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INTEGER NOT NULL); +CREATE TABLE t3 (a INTEGER NOT NULL, b INT, key(a)); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +set global innodb_limit_optimistic_insert_debug = 3; +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (2,3), (3,4), (4,5), (5,6), (2,7), (3,8), (4,3), (50,4); +set global innodb_limit_optimistic_insert_debug = 0; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +pq_database.t1 analyze status OK +pq_database.t2 analyze status OK +pq_database.t3 analyze status OK +explain select /*+ semijoin(@subq1 LOOSESCAN) */ * from t1 where t1.a in (select /*+ QB_NAME(subq1) */ a from t3) and +t1.b in (select a from t2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 NULL index a a 4 NULL 8 62.50 Using index; LooseScan +1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 pq_database.t3.a 1 100.00 NULL +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1); Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `pq_database`.`t1`.`a` AS `a`,`pq_database`.`t1`.`b` AS `b` from `pq_database`.`t1` semi join (`pq_database`.`t3`) semi join (`pq_database`.`t2`) where ((`pq_database`.`t2`.`a` = `pq_database`.`t1`.`b`) and (`pq_database`.`t1`.`a` = `pq_database`.`t3`.`a`)) +select /*+ semijoin(@subq1 LOOSESCAN) */ * from t1 where t1.a in (select /*+ QB_NAME(subq1) */ a from t3) and +t1.b in (select a from t2); +a b +2 2 +3 3 +4 4 +drop table t1; +drop table t2; +drop table t3; +create table t1(a varchar(10), primary key (a)); +create table t2(a varchar(10), b int); +insert into t1 values('t1'); +set global innodb_limit_optimistic_insert_debug = 3; +insert into t2 values('t1', 1); +insert into t2 values('t1', 2); +insert into t2 values('t1', 3); +insert into t2 values('t1', 4); +insert into t2 values('t1', 5); +insert into t2 values('t1', 6); +insert into t2 values('t1', 7); +insert into t2 values('t1', 8); +insert into t2 values('t1', 9); +insert into t2 values('t1', 10); +insert into t2 values('t1', 11); +insert into t2 values('t1', 12); +insert into t2 values('t1', 13); +insert into t2 values('t1', 14); +insert into t2 values('t1', 15); +set global innodb_limit_optimistic_insert_debug = 0; +analyze table t1; +Table Op Msg_type Msg_text +pq_database.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +pq_database.t2 analyze status OK +explain select * from t1 left join t2 on t2.a = 't1' and t2.b = 1 where t1.a = 't1'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL const PRIMARY PRIMARY 42 const 1 100.00 Using index +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 15 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select 't1' AS `a`,`pq_database`.`t2`.`a` AS `a`,`pq_database`.`t2`.`b` AS `b` from `pq_database`.`t1` left join `pq_database`.`t2` on(((`pq_database`.`t2`.`b` = 1) and (`pq_database`.`t2`.`a` = 't1'))) where true +select * from t1 left join t2 on t2.a = 't1' and t2.b = 1 where t1.a = 't1'; +a a b +t1 t1 1 +explain select * from t1 left join t2 on 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL PRIMARY 42 NULL 1 100.00 Using index +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 15 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `pq_database`.`t1`.`a` AS `a`,`pq_database`.`t2`.`a` AS `a`,`pq_database`.`t2`.`b` AS `b` from `pq_database`.`t1` left join `pq_database`.`t2` on(true) where true +select * from t1 left join t2 on 1; +a a b +t1 t1 15 +t1 t1 14 +t1 t1 13 +t1 t1 12 +t1 t1 11 +t1 t1 10 +t1 t1 9 +t1 t1 8 +t1 t1 7 +t1 t1 6 +t1 t1 5 +t1 t1 4 +t1 t1 3 +t1 t1 2 +t1 t1 1 +drop table t1; +drop table t2; +create table t1(a int); +create table t2(b int, primary key (b)); +insert into t1 values(1); +insert into t1 values(2); +insert into t1 values(3); +insert into t2 values(1); +insert into t2 values(2); +insert into t2 values(3); +analyze table t1; +Table Op Msg_type Msg_text +pq_database.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +pq_database.t2 analyze status OK +explain select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2 left join t1 on 1 ); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL +2 SIMPLE t2 NULL index NULL PRIMARY 4 NULL 3 100.00 Using index +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`select#2` FIRSTMATCH) */ `pq_database`.`t1`.`a` AS `a` from `pq_database`.`t1` semi join (`pq_database`.`t2` left join `pq_database`.`t1` on(true)) where true +select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2 left join t1 on 1); +a +1 +2 +3 +drop table t1; +drop table t2; +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +insert into t1 values (1, 10), (2,20), (3, 30), (4, 40); +insert into t2 values (2), (3), (4), (5); +analyze table t1; +Table Op Msg_type Msg_text +pq_database.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +pq_database.t2 analyze status OK +explain select * from t2 where t2.a in (select /*+ semijoin(DUPSWEEDOUT)*/ a from t1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index +2 SIMPLE t1 NULL ref a a 5 pq_database.t2.a 1 100.00 Using index; Start temporary; End temporary +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`select#2` DUPSWEEDOUT) */ `pq_database`.`t2`.`a` AS `a` from `pq_database`.`t2` semi join (`pq_database`.`t1`) where (`pq_database`.`t1`.`a` = `pq_database`.`t2`.`a`) +select * from t2 where t2.a in (select /*+ semijoin(DUPSWEEDOUT)*/ a from t1); +a +2 +3 +4 +drop table t1; +drop table t2; +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +INSERT INTO t2 VALUES (123,NULL,NULL); +analyze table t0; +Table Op Msg_type Msg_text +pq_database.t0 analyze status OK +analyze table t1; +Table Op Msg_type Msg_text +pq_database.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +pq_database.t2 analyze status OK +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT /*+ semijoin(LOOSESCAN) */ t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL index NULL int_key 5 NULL 1 100.00 Using index +2 SIMPLE t1_1 NULL index varchar_key varchar_key 12 NULL 2 50.00 Using where; Using index; LooseScan +2 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) +2 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`select#2` LOOSESCAN) */ `pq_database`.`t0`.`int_key` AS `int_key` from `pq_database`.`t0` join `pq_database`.`t2` semi join (`pq_database`.`t1` `t1_1` join `pq_database`.`t1` `t1_2`) where ((`pq_database`.`t0`.`varchar_nokey` = `pq_database`.`t1_1`.`varchar_key`) and (0 <> `pq_database`.`t1_1`.`int_key`)) +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT /*+ semijoin(LOOSESCAN) */ t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); +int_key +9 +7 +drop table t0; +drop table t1; +drop table t2; +drop database pq_database; diff --git a/mysql-test/suite/parallel_query/r/pq_jt_ref.result-pq b/mysql-test/suite/parallel_query/r/pq_jt_ref.result-pq new file mode 100644 index 000000000..e996547ca --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_jt_ref.result-pq @@ -0,0 +1,59 @@ +create database pq_test; +use pq_test; +DROP TABLE IF EXISTS t2; +CREATE TABLE `t2` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`a` int(11) DEFAULT NULL, +`b` int(11) DEFAULT NULL, +`c` varchar(100) DEFAULT NULL, +`d` varchar(100) DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `idx_abc` (`a`,`b`,`c`) +) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +Warning 1681 Integer display width is deprecated and will be removed in a future release. +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +select * from t2; +id a b c d +16384 6 4 bcabcabcabca bcabcabcabca +16385 6 4 bcabcabcabca bcabcabcabca +16386 6 4 bcabcabcabca bcabcabcabca +16387 6 4 bcabcabcabca bcabcabcabca +16388 6 4 bcabcabcabca bcabcabcabca +explain select * from t2 where a = 6; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 5 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref idx_abc idx_abc 5 const 5 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`id` AS `id`,`pq_test`.`t2`.`a` AS `a`,`pq_test`.`t2`.`b` AS `b`,`pq_test`.`t2`.`c` AS `c`,`pq_test`.`t2`.`d` AS `d` from `pq_test`.`t2` where (`pq_test`.`t2`.`a` = 6) +select * from t2 where a = 6; +id a b c d +16384 6 4 bcabcabcabca bcabcabcabca +16385 6 4 bcabcabcabca bcabcabcabca +16386 6 4 bcabcabcabca bcabcabcabca +16387 6 4 bcabcabcabca bcabcabcabca +16388 6 4 bcabcabcabca bcabcabcabca +explain select * from t2 where a = 8; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref idx_abc idx_abc 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`id` AS `id`,`pq_test`.`t2`.`a` AS `a`,`pq_test`.`t2`.`b` AS `b`,`pq_test`.`t2`.`c` AS `c`,`pq_test`.`t2`.`d` AS `d` from `pq_test`.`t2` where (`pq_test`.`t2`.`a` = 8) +select * from t2 where a = 8; +id a b c d +explain select * from t2 where a = 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ref idx_abc idx_abc 5 const 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`id` AS `id`,`pq_test`.`t2`.`a` AS `a`,`pq_test`.`t2`.`b` AS `b`,`pq_test`.`t2`.`c` AS `c`,`pq_test`.`t2`.`d` AS `d` from `pq_test`.`t2` where (`pq_test`.`t2`.`a` = 4) +select * from t2 where a = 4; +id a b c d +drop table pq_test.t2; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_kill_query.result-pq b/mysql-test/suite/parallel_query/r/pq_kill_query.result-pq new file mode 100644 index 000000000..9ee195ee5 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_kill_query.result-pq @@ -0,0 +1,33 @@ +CALL mtr.add_suppression("send message to MQ error"); +set @saved_debug_pq_worker_stall = @@debug_pq_worker_stall; +create table t1(id int, a varchar(10)); +set global debug_pq_worker_stall = true; +select @@force_parallel_execute; +@@force_parallel_execute +1 +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1000 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +select sum(id) from t1;; +show status like "PQ_threads_running"; +Variable_name Value +PQ_threads_running 7 +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used ####### +KILL query #; +ERROR 70100: Query execution was interrupted +show status like "PQ_threads_running"; +Variable_name Value +PQ_threads_running 4 +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set global debug_pq_worker_stall = @saved_debug_pq_worker_stall; +SET @@SESSION.max_execution_time= 2; +SELECT *, SLEEP(0.5) from t1; +ERROR HY000: Query execution was interrupted, maximum statement execution time exceeded +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_mdl_lock.result-pq b/mysql-test/suite/parallel_query/r/pq_mdl_lock.result-pq new file mode 100644 index 000000000..eed487c98 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_mdl_lock.result-pq @@ -0,0 +1,40 @@ +set @saved_autocommit = @@autocommit; +SET session autocommit=0; +CREATE TABLE t1 (f1 INT) ENGINE="InnoDB"; +SELECT 1 FROM DUAL; +1 +1 +SELECT f1 FROM t1; +f1 +UNLOCK TABLES; +LOCK TABLES t1 WRITE; +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +explain SELECT f1 FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` +SELECT f1 FROM t1; +f1 +2 +2 +2 +2 +2 +2 +2 +2 +2 +COMMIT; +UNLOCK TABLES; +SET session autocommit = @saved_autocommit; +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_memory_limit.result-pq b/mysql-test/suite/parallel_query/r/pq_memory_limit.result-pq new file mode 100644 index 000000000..22a79278f --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_memory_limit.result-pq @@ -0,0 +1,62 @@ +set @saved_debug_pq_worker_stall = @@debug_pq_worker_stall; +set @saved_pq_memory_limit = @@parallel_memory_limit; +create table t1(id int, a varchar(10)); +set global debug_pq_worker_stall = true; +select @@force_parallel_execute; +@@force_parallel_execute +1 +select sum(id) from t1;; +show status like "PQ_threads_running"; +Variable_name Value +PQ_threads_running 7 +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used ####### +show status like "PQ_memory_refused"; +Variable_name Value +PQ_memory_refused 0 +EXPLAIN FOR CONNECTION #;; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +# SIMPLE NULL ALL NULL NULL NULL NULL # #.# Parallel execute (# workers) +# SIMPLE t# NULL ALL NULL NULL NULL NULL # #.# NULL +set global parallel_memory_limit=40960; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1000 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set global debug_pq_worker_stall = false; +sum(id) +500500 +show status like "PQ_threads_running"; +Variable_name Value +PQ_threads_running 4 +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +show status like "PQ_memory_refused"; +Variable_name Value +PQ_memory_refused 1 +set global debug_pq_worker_stall = @saved_debug_pq_worker_stall; +set global parallel_memory_limit = @saved_pq_memory_limit; +drop table t1; +CREATE TABLE t1 (i INT); +SELECT 1 FROM t1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM DUAL INTO @var17727401; +SELECT 1 INTO @var17727401; +SELECT 1 INTO @var17727401 FROM t1; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 INTO @var17727401 FROM DUAL; +SELECT 1 INTO @var17727401 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 INTO @var17727401; +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_mq_error.result-pq b/mysql-test/suite/parallel_query/r/pq_mq_error.result-pq new file mode 100644 index 000000000..a42ab42e9 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_mq_error.result-pq @@ -0,0 +1,58 @@ +create table t1(id int, a varchar(10)); +insert into t1 values(1, 'aa'), (2, 'bb'); +set @saved_force_parallel_execute = @@force_parallel_execute; +set session force_parallel_execute = 1; +set session sql_mode = ''; +set session debug=""; +set session debug="+d, pq_mq_error1"; +select * from t1; +ERROR HY000: Parallel execution error +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, pq_mq_error2"; +select a, sum(a) from t1 group by a order by a desc, id; +ERROR HY000: Parallel execution error +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, pq_mq_error3"; +select a from t1 order by a desc, id; +ERROR HY000: Memory allocation error: in function (MQ::receive). +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, pq_mq_error4"; +select a from t1 order by a desc, id; +ERROR HY000: Parallel execution error +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, pq_mq_error5"; +select a from t1 order by a desc, id; +ERROR HY000: Parallel execution error +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug="+d, pq_mq_error6"; +select * from t1 limit 20; +ERROR HY000: Parallel execution error +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id limit 20; +a sum(a) +cc 0 +bb 0 +aa 0 +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +drop table t1; +SET debug= DEFAULT; +# restart diff --git a/mysql-test/suite/parallel_query/r/pq_not_equal.result-pq b/mysql-test/suite/parallel_query/r/pq_not_equal.result-pq new file mode 100644 index 0000000000000000000000000000000000000000..12dfb87c200d31315cc83be8813bb6686ef5bd52 GIT binary patch literal 856 zcmb7D(N4lJ6xGM}E3Qu)W-&qGY4KrV)#=#CR#2Ztfg(+y)2@)<*V~P4LWoBDw7Z_u zd(P?YRB@&`%$Q~qmUDRjNHx#3i`VJ7yDsCVhVmp zqg{G1@`52r_Hl>b*e()rtdS_fwj3+cTxFJ{)ta}CY?s`ca-Ydhwlr9)rxx2>bD3Mt zoGtTXVomWTiY?g6P)7WX{i(|%mr~4mAuZsU{Ha5stnTu-$fVpF0yTqHHF0r50@9;! z4tH_XhjE$c7@i+UOsdKZ%oxtDq3t#UguVv@HCK+ByTq5MN&z()pc8zBDx;{diB53` j)izLJ!a%xcrxFz!4PvIUcQ8+6*}Ra8QlY!sIetE0rY_`6 literal 0 HcmV?d00001 diff --git a/mysql-test/suite/parallel_query/r/pq_not_support.result-pq b/mysql-test/suite/parallel_query/r/pq_not_support.result-pq new file mode 100644 index 000000000..263265dc5 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_not_support.result-pq @@ -0,0 +1,128 @@ +CREATE TABLE t0 ( col1 INT NOT NULL, col2 INT ) ENGINE=InnoDB; +insert into t0 values(0,1),(1,2),(2,3); +CREATE TABLE t1 (col3 DECIMAL(35,0) DEFAULT NULL, col1 INT NOT NULL, col2 INT NOT NULL DEFAULT '0', PRIMARY KEY (col1)) ENGINE=MyISAM; +REPLACE INTO t1 ( col1,col2) SELECT col1,col2 FROM t0; +select * from t1; +col3 col1 col2 +NULL 0 1 +NULL 1 2 +NULL 2 3 +drop table t0, t1; +drop database if exists pq_bit_database; +create database pq_bit_database; +use pq_bit_database; +CREATE TABLE t1 (a char(1), b VARBINARY(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('a', null); +INSERT INTO t1 VALUES ('a', null); +INSERT INTO t1 VALUES ('b', null); +INSERT INTO t1 VALUES ('b', 0x12); +INSERT INTO t1 VALUES ('c', 0x12); +INSERT INTO t1 VALUES ('b', 0x02); +INSERT INTO t1 VALUES ('c', 0x40); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +pq_bit_database.t1 analyze status OK +SET @orig_sql_mode = @@sql_mode; +set sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; +EXPLAIN SELECT a, BIT_AND(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,bit_and(`pq_bit_database`.`t1`.`b`) AS `BIT_AND(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, BIT_OR(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,bit_or(`pq_bit_database`.`t1`.`b`) AS `BIT_OR(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, BIT_XOR(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,bit_xor(`pq_bit_database`.`t1`.`b`) AS `BIT_XOR(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, 1 + BIT_AND(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(1 + bit_and(`pq_bit_database`.`t1`.`b`)) AS `1 + BIT_AND(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, 1 + BIT_OR(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(1 + bit_or(`pq_bit_database`.`t1`.`b`)) AS `1 + BIT_OR(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, 1 + BIT_XOR(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(1 + bit_xor(`pq_bit_database`.`t1`.`b`)) AS `1 + BIT_XOR(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, SUM(b) + BIT_AND(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(sum(`pq_bit_database`.`t1`.`b`) + bit_and(`pq_bit_database`.`t1`.`b`)) AS `SUM(b) + BIT_AND(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, SUM(b) + BIT_OR(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(sum(`pq_bit_database`.`t1`.`b`) + bit_or(`pq_bit_database`.`t1`.`b`)) AS `SUM(b) + BIT_OR(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, SUM(b) + BIT_XOR(b) FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(sum(`pq_bit_database`.`t1`.`b`) + bit_xor(`pq_bit_database`.`t1`.`b`)) AS `SUM(b) + BIT_XOR(b)` from `pq_bit_database`.`t1` +EXPLAIN SELECT a, 1 + BIT_AND(b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(1 + bit_and(`pq_bit_database`.`t1`.`b`)) AS `1 + BIT_AND(b)` from `pq_bit_database`.`t1` group by `pq_bit_database`.`t1`.`a` +EXPLAIN SELECT a, 1 + BIT_OR(b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(1 + bit_or(`pq_bit_database`.`t1`.`b`)) AS `1 + BIT_OR(b)` from `pq_bit_database`.`t1` group by `pq_bit_database`.`t1`.`a` +EXPLAIN SELECT a, 1 + BIT_XOR(b) FROM t1 GROUP BY a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,(1 + bit_xor(`pq_bit_database`.`t1`.`b`)) AS `1 + BIT_XOR(b)` from `pq_bit_database`.`t1` group by `pq_bit_database`.`t1`.`a` +EXPLAIN SELECT a, b FROM t1 having BIT_AND(b) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,`pq_bit_database`.`t1`.`b` AS `b` from `pq_bit_database`.`t1` having (bit_and(`pq_bit_database`.`t1`.`b`) > 0) +EXPLAIN SELECT a, b FROM t1 having BIT_OR(b) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,`pq_bit_database`.`t1`.`b` AS `b` from `pq_bit_database`.`t1` having (bit_or(`pq_bit_database`.`t1`.`b`) > 0) +EXPLAIN SELECT a, b FROM t1 having BIT_XOR(b) > 0; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,`pq_bit_database`.`t1`.`b` AS `b` from `pq_bit_database`.`t1` having (bit_xor(`pq_bit_database`.`t1`.`b`) > 0) +EXPLAIN SELECT a, BIT_AND(b) FROM t1 GROUP BY a ORDER BY BIT_AND(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,bit_and(`pq_bit_database`.`t1`.`b`) AS `BIT_AND(b)` from `pq_bit_database`.`t1` group by `pq_bit_database`.`t1`.`a` order by bit_and(`pq_bit_database`.`t1`.`b`) +EXPLAIN SELECT a, BIT_AND(b) FROM t1 GROUP BY a ORDER BY BIT_OR(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,bit_and(`pq_bit_database`.`t1`.`b`) AS `BIT_AND(b)` from `pq_bit_database`.`t1` group by `pq_bit_database`.`t1`.`a` order by bit_or(`pq_bit_database`.`t1`.`b`) +EXPLAIN SELECT a, BIT_AND(b) FROM t1 GROUP BY a ORDER BY BIT_XOR(b); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 7 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `pq_bit_database`.`t1`.`a` AS `a`,bit_and(`pq_bit_database`.`t1`.`b`) AS `BIT_AND(b)` from `pq_bit_database`.`t1` group by `pq_bit_database`.`t1`.`a` order by bit_xor(`pq_bit_database`.`t1`.`b`) +SELECT a, BIT_AND(b) FROM t1; +a BIT_AND(b) +a +SELECT a, BIT_OR(b) FROM t1; +a BIT_OR(b) +a R +SELECT a, BIT_XOR(b) FROM t1; +a BIT_XOR(b) +a B +DROP TABLE t1; +SET sql_mode = @orig_sql_mode; +drop database pq_bit_database; diff --git a/mysql-test/suite/parallel_query/r/pq_opt_trace.result-pq b/mysql-test/suite/parallel_query/r/pq_opt_trace.result-pq new file mode 100644 index 000000000..f5675ce6a --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_opt_trace.result-pq @@ -0,0 +1,10 @@ +create table t1(id int, a varchar(10)); +set session optimizer_trace="enabled=on"; +select * from t1 limit 1; +id a +1000 aa +Select locate("make_parallel_query_plan", trace) > 1 From Information_Schema.Optimizer_Trace; +locate("make_parallel_query_plan", trace) > 1 +1 +set session optimizer_trace="enabled=on"; +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_order_aggregation.result-pq b/mysql-test/suite/parallel_query/r/pq_order_aggregation.result-pq new file mode 100644 index 000000000..f70f8cbb6 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_order_aggregation.result-pq @@ -0,0 +1,496 @@ +drop database if exists pq_database; +create database pq_database; +use pq_database; +drop table if exists t1; +set global innodb_limit_optimistic_insert_debug = 3; +show variables like "innodb_limit_optimistic_insert_debug"; +Variable_name Value +innodb_limit_optimistic_insert_debug 3 +create table t1 ( +a int not null, +b int not null, +c int not null +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t1 values(1, 2, 3); +insert into t1 values(1, 5, 5); +insert into t1 values(1, 2, 4); +insert into t1 values(2, 4, 2); +insert into t1 values(2, 1, 3); +insert into t1 values(3, 5, 1); +insert into t1 values(3, 2, 3); +insert into t1 values(3, 2, 4); +insert into t1 values(4, 6, 8); +insert into t1 values(5, 8, 6); +insert into t1 values(5, 3, 9); +insert into t1 values(6, 9, 2); +analyze table t1; +Table Op Msg_type Msg_text +pq_database.t1 analyze status OK +explain select a, sum(a) from t1 group by a order by sum(a); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 12 100.00 Using temporary; Using filesort +Warnings: +Note 1003 /* select#1 */ select `pq_database`.`t1`.`a` AS `a`,sum(`pq_database`.`t1`.`a`) AS `sum(a)` from `pq_database`.`t1` group by `pq_database`.`t1`.`a` order by sum(`sum(a)`) +select a, sum(a) from t1 group by a order by sum(a); +a sum(a) +1 3 +2 4 +4 4 +6 6 +3 9 +5 10 +select a, sum(a) from t1 group by a order by sum(b); +a sum(a) +2 4 +4 4 +1 3 +3 9 +6 6 +5 10 +select a, sum(a) from t1 group by a order by sum(b) + 2; +a sum(a) +2 4 +4 4 +1 3 +3 9 +6 6 +5 10 +select a, sum(a) from t1 group by a order by sum(b) - 2; +a sum(a) +2 4 +4 4 +1 3 +3 9 +6 6 +5 10 +select a, sum(a) from t1 group by a order by sum(b) * 2; +a sum(a) +2 4 +4 4 +1 3 +3 9 +6 6 +5 10 +select a, sum(a) from t1 group by a order by sum(b) / 2; +a sum(a) +2 4 +4 4 +1 3 +3 9 +6 6 +5 10 +select a, sum(a) from t1 group by a order by sum(b + 2), a; +a sum(a) +4 4 +2 4 +6 6 +1 3 +3 9 +5 10 +select a, sum(a) from t1 group by a order by sum(b - 2), a; +a sum(a) +2 4 +1 3 +3 9 +4 4 +5 10 +6 6 +select a, sum(a) from t1 group by a order by sum(b * 2), a; +a sum(a) +2 4 +4 4 +1 3 +3 9 +6 6 +5 10 +select a, sum(a) from t1 group by a order by sum(b / 2), a; +a sum(a) +2 4 +4 4 +1 3 +3 9 +6 6 +5 10 +select a, sum(a) from t1 group by a order by sum(b + 2) + sum(a); +a sum(a) +4 4 +2 4 +6 6 +1 3 +3 9 +5 10 +select a, avg(a) from t1 group by a order by avg(a); +a avg(a) +1 1.0000 +2 2.0000 +3 3.0000 +4 4.0000 +5 5.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b); +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b) + 2; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b) - 2; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b) * 2; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b) / 2; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b + 2), a; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b - 2), a; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b * 2), a; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b / 2), a; +a avg(a) +2 2.0000 +1 1.0000 +3 3.0000 +5 5.0000 +4 4.0000 +6 6.0000 +select a, avg(a) from t1 group by a order by avg(b + 2) + avg(a); +a avg(a) +1 1.0000 +2 2.0000 +3 3.0000 +4 4.0000 +5 5.0000 +6 6.0000 +select a, count(a) from t1 group by a order by count(a), a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b), a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b) + 2, a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b) - 2, a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b) * 2, a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b) / 2, a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b + 2), a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b - 2), a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b * 2), a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b / 2), a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, count(a) from t1 group by a order by count(b + 2) + count(a), a; +a count(a) +4 1 +6 1 +2 2 +5 2 +1 3 +3 3 +select a, max(a) from t1 group by a order by max(a), a; +a max(a) +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b), a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b) + 2, a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b) - 2, a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b) * 2, a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b) / 2, a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b + 2), a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b - 2), a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b * 2), a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b / 2), a; +a max(a) +2 2 +1 1 +3 3 +4 4 +5 5 +6 6 +select a, max(a) from t1 group by a order by max(b + 2) + max(a), a; +a max(a) +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +select a, min(a) from t1 group by a order by min(a), a; +a min(a) +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +select a, min(a) from t1 group by a order by min(b), a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b) + 2, a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b) - 2, a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b) * 2, a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b) / 2, a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b + 2), a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b - 2), a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b * 2), a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b / 2), a; +a min(a) +2 2 +1 1 +3 3 +5 5 +4 4 +6 6 +select a, min(a) from t1 group by a order by min(b + 2) + min(a), a; +a min(a) +1 1 +2 2 +3 3 +5 5 +4 4 +6 6 +select a, sum(a) from t1 group by a order by max(b) + min(c); +a sum(a) +2 4 +3 9 +1 3 +6 6 +4 4 +5 10 +select a, sum(a) from t1 group by a order by count(b + 1) + max(c * 2); +a sum(a) +6 6 +2 4 +3 9 +1 3 +4 4 +5 10 +set global innodb_limit_optimistic_insert_debug = 0; +show variables like "innodb_limit_optimistic_insert_debug"; +Variable_name Value +innodb_limit_optimistic_insert_debug 0 +drop table t1; +drop database pq_database; diff --git a/mysql-test/suite/parallel_query/r/pq_order_by.result b/mysql-test/suite/parallel_query/r/pq_order_by.result new file mode 100644 index 000000000..15a0afd51 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_order_by.result @@ -0,0 +1,232 @@ +create table t1( +a tinyint NOT NULL, +b smallint, +c mediumint not null, +d int, +e bigint not null, +f float, +g double, +h decimal (6, 2)) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t1 values (1, 10, 20, 11, 101, 0.1, 1.1, 5.21); +insert into t1 values (28, 11, 21, 14, 49, 10.11, 29.12, 405.43); +insert into t1 values (-7, 4, 198, 20081, 109992784, -1004.22, 49727648.11, 8857.29); +insert into t1 values (88, -22, 9847, null, 91001544, null, 298847.91, null); +insert into t1 values (09, null, 18837, 105, 8475291, 1746.11, -1837491.90, -472.11); +select * from t1 order by a, b; +a b c d e f g h +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +1 10 20 11 101 0.1 1.1 5.21 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +28 11 21 14 49 10.11 29.12 405.43 +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +select a, c, e, f from t1 order by g; +a c e f +9 18837 8475291 1746.11 +1 20 101 0.1 +28 21 49 10.11 +88 9847 91001544 NULL +-7 198 109992784 -1004.22 +select * from t1 order by a, b desc; +a b c d e f g h +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +1 10 20 11 101 0.1 1.1 5.21 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +28 11 21 14 49 10.11 29.12 405.43 +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +select h, e, g, a from t1 order by a, b desc; +h e g a +8857.29 109992784 49727648.11 -7 +5.21 101 1.1 1 +-472.11 8475291 -1837491.9 9 +405.43 49 29.12 28 +NULL 91001544 298847.91 88 +select * from t1 order by a, b desc; +a b c d e f g h +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +1 10 20 11 101 0.1 1.1 5.21 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +28 11 21 14 49 10.11 29.12 405.43 +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +select * from t1 order by a desc, b asc; +a b c d e f g h +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +28 11 21 14 49 10.11 29.12 405.43 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +1 10 20 11 101 0.1 1.1 5.21 +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +select a, c, e, f from t1 order by g, a desc, c asc; +a c e f +9 18837 8475291 1746.11 +1 20 101 0.1 +28 21 49 10.11 +88 9847 91001544 NULL +-7 198 109992784 -1004.22 +create table t2( +a int NOT NULL, +b int NOT NULL, +c int, +primary key(a), +unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t2 values (1, 1, 2); +insert into t2 values (0, 1, 4); +insert into t2 values (2, 0, 3); +select * from t2 order by a, c; +a b c +0 1 4 +1 1 2 +2 0 3 +select * from t2 order by b; +a b c +2 0 3 +0 1 4 +1 1 2 +select * from t2 order by a desc, c asc; +a b c +2 0 3 +1 1 2 +0 1 4 +select * from t2 order by a; +a b c +0 1 4 +1 1 2 +2 0 3 +select * from t2 order by c; +a b c +1 1 2 +2 0 3 +0 1 4 +select * from t2 order by a desc; +a b c +2 0 3 +1 1 2 +0 1 4 +select * from t2 order by c desc; +a b c +0 1 4 +2 0 3 +1 1 2 +select * from t2; +a b c +0 1 4 +1 1 2 +2 0 3 +select a, c from t2; +a c +1 2 +2 3 +0 4 +select a, b from t2; +a b +0 1 +1 1 +2 0 +select b, c from t2; +b c +1 4 +1 2 +0 3 +create table t3( +a int NOT NULL, +b int NOT NULL, +c int NOT NULL, +primary key (a, b), +unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t3 values (1, 1, 2); +insert into t3 values (1, 2, 1); +insert into t3 values (0, 1, 3); +insert into t3 values (1, 0, 4); +select * from t3; +a b c +1 2 1 +1 1 2 +0 1 3 +1 0 4 +select * from t3 order by a; +a b c +0 1 3 +1 0 4 +1 1 2 +1 2 1 +select * from t3 order by a, b; +a b c +0 1 3 +1 0 4 +1 1 2 +1 2 1 +select * from t3 order by b, a; +a b c +1 0 4 +0 1 3 +1 1 2 +1 2 1 +select * from t3 order by a, c; +a b c +0 1 3 +1 2 1 +1 1 2 +1 0 4 +select * from t3 order by a desc, b asc; +a b c +1 0 4 +1 1 2 +1 2 1 +0 1 3 +select * from t3 order by a + b; +a b c +0 1 3 +1 0 4 +1 1 2 +1 2 1 +select * from t3 order by a + b desc; +a b c +1 2 1 +1 1 2 +0 1 3 +1 0 4 +select * from t3 order by a + b * c; +a b c +1 0 4 +1 2 1 +1 1 2 +0 1 3 +select c from t3 order by a desc, b + c asc; +c +1 +2 +4 +3 +CREATE TABLE `t4` ( +`id` int NOT NULL AUTO_INCREMENT, +`a` int DEFAULT NULL, +`b` int DEFAULT NULL, +`c` varchar(100) DEFAULT NULL, +`d` varchar(100) DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `idx_abc` (`a`,`b`,`c`) +) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +INSERT INTO `t4` VALUES +(1,1,2,'abcabcabcabc','cbacbacbacba'), +(2,1,2,'abcabcabcabc','cbacbacbacba'), +(3,1,2,'abcabcabcabc','cbacbacbacba'), +(4,1,2,'abcabcabcabc','cbacbacbacba'), +(5,1,2,'abcabcabcabc','cbacbacbacba'), +(6,1,2,'abcabcabcabc','cbacbacbacba'), +(7,1,2,'abcabcabcabc','cbacbacbacba'), +(8,1,2,'abcabcabcabc','cbacbacbacba'), +(9,1,2,'abcabcabcabc','cbacbacbacba'), +(10,1,2,'abcabcabcabc','cbacbacbacba'); +select count(*), a from t4 group by a; +count(*) a +10 1 +select sum(b), a from t4 group by a order by sum(b); +sum(b) a +20 1 +select avg(b), a from t4 group by a order by avg(b); +avg(b) a +2.0000 1 +drop table t1; +drop table t2; +drop table t3; +drop table t4; diff --git a/mysql-test/suite/parallel_query/r/pq_order_by.result-pq b/mysql-test/suite/parallel_query/r/pq_order_by.result-pq new file mode 100644 index 000000000..19a5f10a9 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_order_by.result-pq @@ -0,0 +1,363 @@ +create table t1( +a tinyint NOT NULL, +b smallint, +c mediumint not null, +d int, +e bigint not null, +f float, +g double, +h decimal (6, 2)) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t1 values (1, 10, 20, 11, 101, 0.1, 1.1, 5.21); +insert into t1 values (28, 11, 21, 14, 49, 10.11, 29.12, 405.43); +insert into t1 values (-7, 4, 198, 20081, 109992784, -1004.22, 49727648.11, 8857.29); +insert into t1 values (88, -22, 9847, null, 91001544, null, 298847.91, null); +insert into t1 values (09, null, 18837, 105, 8475291, 1746.11, -1837491.90, -472.11); +select * from t1 order by a, b; +a b c d e f g h +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +1 10 20 11 101 0.1 1.1 5.21 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +28 11 21 14 49 10.11 29.12 405.43 +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +select a, c, e, f from t1 order by g; +a c e f +9 18837 8475291 1746.11 +1 20 101 0.1 +28 21 49 10.11 +88 9847 91001544 NULL +-7 198 109992784 -1004.22 +select * from t1 order by a, b desc; +a b c d e f g h +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +1 10 20 11 101 0.1 1.1 5.21 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +28 11 21 14 49 10.11 29.12 405.43 +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +select h, e, g, a from t1 order by a, b desc; +h e g a +8857.29 109992784 49727648.11 -7 +5.21 101 1.1 1 +-472.11 8475291 -1837491.9 9 +405.43 49 29.12 28 +NULL 91001544 298847.91 88 +select * from t1 order by a, b desc; +a b c d e f g h +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +1 10 20 11 101 0.1 1.1 5.21 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +28 11 21 14 49 10.11 29.12 405.43 +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +select * from t1 order by a desc, b asc; +a b c d e f g h +88 -22 9847 NULL 91001544 NULL 298847.91 NULL +28 11 21 14 49 10.11 29.12 405.43 +9 NULL 18837 105 8475291 1746.11 -1837491.9 -472.11 +1 10 20 11 101 0.1 1.1 5.21 +-7 4 198 20081 109992784 -1004.22 49727648.11 8857.29 +select a, c, e, f from t1 order by g, a desc, c asc; +a c e f +9 18837 8475291 1746.11 +1 20 101 0.1 +28 21 49 10.11 +88 9847 91001544 NULL +-7 198 109992784 -1004.22 +create table t2( +a int NOT NULL, +b int NOT NULL, +c int, +primary key(a), +unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t2 values (1, 1, 2); +insert into t2 values (0, 1, 4); +insert into t2 values (2, 0, 3); +select * from t2 order by a, c; +a b c +0 1 4 +1 1 2 +2 0 3 +select * from t2 order by b; +a b c +2 0 3 +0 1 4 +1 1 2 +select * from t2 order by a desc, c asc; +a b c +2 0 3 +1 1 2 +0 1 4 +select * from t2 order by a; +a b c +0 1 4 +1 1 2 +2 0 3 +select * from t2 order by c; +a b c +1 1 2 +2 0 3 +0 1 4 +select * from t2 order by a desc; +a b c +2 0 3 +1 1 2 +0 1 4 +select * from t2 order by c desc; +a b c +0 1 4 +2 0 3 +1 1 2 +select * from t2; +a b c +0 1 4 +1 1 2 +2 0 3 +select a, c from t2; +a c +1 2 +2 3 +0 4 +select a, b from t2; +a b +0 1 +1 1 +2 0 +select b, c from t2; +b c +1 4 +1 2 +0 3 +create table t3( +a int NOT NULL, +b int NOT NULL, +c int NOT NULL, +primary key (a, b), +unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t3 values (1, 1, 2); +insert into t3 values (1, 2, 1); +insert into t3 values (0, 1, 3); +insert into t3 values (1, 0, 4); +select * from t3; +a b c +1 2 1 +1 1 2 +0 1 3 +1 0 4 +select * from t3 order by a; +a b c +0 1 3 +1 0 4 +1 1 2 +1 2 1 +select * from t3 order by a, b; +a b c +0 1 3 +1 0 4 +1 1 2 +1 2 1 +select * from t3 order by b, a; +a b c +1 0 4 +0 1 3 +1 1 2 +1 2 1 +select * from t3 order by a, c; +a b c +0 1 3 +1 2 1 +1 1 2 +1 0 4 +select * from t3 order by a desc, b asc; +a b c +1 0 4 +1 1 2 +1 2 1 +0 1 3 +select * from t3 order by a + b; +a b c +0 1 3 +1 0 4 +1 1 2 +1 2 1 +select * from t3 order by a + b desc; +a b c +1 2 1 +1 1 2 +0 1 3 +1 0 4 +select * from t3 order by a + b * c; +a b c +1 0 4 +1 2 1 +1 1 2 +0 1 3 +select c from t3 order by a desc, b + c asc; +c +1 +2 +4 +3 +CREATE TABLE `t4` ( +`id` int NOT NULL AUTO_INCREMENT, +`a` int DEFAULT NULL, +`b` int DEFAULT NULL, +`c` varchar(100) DEFAULT NULL, +`d` varchar(100) DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `idx_abc` (`a`,`b`,`c`) +) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +INSERT INTO `t4` VALUES +(1,1,2,'abcabc', 'cbacbacbacba'), +(2,1,2,'abcabca', 'cbacbacbacba'), +(3,1,2,'abca', 'cbacbacbacba'), +(4,1,2,'abcabca', 'cbacbacbacba'), +(5,1,2,'abcabcabc', 'cbacbacbacba'), +(6,1,2,'cabcabcabc','cbacbacbacba'), +(7,1,2,'abc', 'cbacbacbacba'), +(8,1,2,'abcabd', 'cbacbacbacba'), +(9,1,2,'xabcabcad', 'cbacbacbacba'), +(10,1,2,'xycabcab', 'cbacbacbacba'); +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +select count(*), a from t4 group by a; +count(*) a +20480 1 +select sum(b), a from t4 group by a order by sum(b); +sum(b) a +40960 1 +select avg(b), a from t4 group by a order by avg(b); +avg(b) a +2.0000 1 +SELECT c, d FROM t4 ORDER BY c LIMIT 10; +c d +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +abc cbacbacbacba +SELECT c, d FROM t4 ORDER BY c desc LIMIT 10; +c d +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +xycabcab cbacbacbacba +set session debug=""; +set session debug="+d, pq_msort_error6"; +select c, d from t4 order by c, d LIMIT 10; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_msort_error7"; +select c, d from t4 order by c, d LIMIT 10; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_msort_error8"; +select c, d from t4 order by c, d LIMIT 10; +ERROR HY000: Memory allocation error: in function (PQ::add_unorderd). +set session debug=""; +SELECT * FROM t4 ORDER BY c, id LIMIT 10; +id a b c d +7 1 2 abc cbacbacbacba +16390 1 2 abc cbacbacbacba +16405 1 2 abc cbacbacbacba +16415 1 2 abc cbacbacbacba +16436 1 2 abc cbacbacbacba +16446 1 2 abc cbacbacbacba +16456 1 2 abc cbacbacbacba +16466 1 2 abc cbacbacbacba +16499 1 2 abc cbacbacbacba +16509 1 2 abc cbacbacbacba +drop table t1; +drop table t2; +drop table t3; +drop table t4; +CREATE TABLE t3(c1 DATETIME NOT NULL, c2 DATETIME NULL, c3 DATE, +c4 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +UNIQUE INDEX idx(c1,c2)); +INSERT INTO t3 VALUES('98-12-31 11:30:45','98.12.31 11+30+45','98-12-31 11:30:45','98.12.31 11+30+45'),('98/12/30 11*30*45','98@12@30 11^30^45','98/12/30 11*30*45','98@12@30 11^30^45'),('98-12-29','98.12.29','98-12-29','98.12.29'),('98/12/28','98@12@28','98/12/28','98@12@28'); +INSERT INTO t3 VALUES('20070523091528','070523091528','20070524091528','070524091528'),('20070525','070525','20070526','070526'); +INSERT INTO t3 VALUES(19830905132800,830905132800,19830906132800,830906132800),(19830907,830907,19830908,830908); +SET TIMESTAMP=1233216687; +INSERT INTO t3 VALUES(NOW(),CURRENT_DATE,NOW(),CURRENT_DATE); +INSERT INTO t3 VALUES('98-12-31 11:30:45','98@12@30 11^30^45','98-12-31 11:30:45','98.12.31 11+30+45'),('98-12-29','98@12@30 11^30^45','98/12/30 11*30*45','98@12@30 11^30^45'); +INSERT INTO t3 VALUES('2008-01-01',NULL,'08-01-02','08/01/03'); +set @saved_sql_mode = @@SQL_MODE; +set SQL_MODE = ''; +ANALYZE TABLE t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +EXPLAIN SELECT * FROM t3 WHERE c1 >= '0000-00-00' AND c1 < '2009-01-29' AND c2 = '1998-12-30 11:30:45'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 12 9.17 Parallel execute (1 workers) +2 SIMPLE t3 NULL ALL idx NULL NULL NULL 12 9.17 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2`,`test`.`t3`.`c3` AS `c3`,`test`.`t3`.`c4` AS `c4` from `test`.`t3` where ((`test`.`t3`.`c2` = TIMESTAMP'1998-12-30 11:30:45') and (`test`.`t3`.`c1` >= TIMESTAMP'0000-00-00 00:00:00') and (`test`.`t3`.`c1` < TIMESTAMP'2009-01-29 00:00:00')) +SELECT * FROM t3 WHERE c1 >= '0000-00-00' AND c1 < '2009-01-29' AND c2 = '1998-12-30 11:30:45' ORDER BY c1,c2 LIMIT 2; +c1 c2 c3 c4 +1998-12-29 00:00:00 1998-12-30 11:30:45 1998-12-30 1998-12-30 11:30:45 +1998-12-30 11:30:45 1998-12-30 11:30:45 1998-12-30 1998-12-30 11:30:45 +DROP TABLE t3; +set session SQL_MODE = @saved_sql_mode; +CREATE TABLE t1 ( +userid int(10) unsigned, +score smallint(5) unsigned, +key (score) +); +INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set big_tables=1; +SELECT userid,count(*) FROM t1 GROUP BY userid ORDER BY userid DESC; +userid count(*) +3 5 +2 1 +1 2 +DROP TABLE t1; +CREATE TABLE `t2` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`a` int(11) DEFAULT NULL, +`b` int(11) DEFAULT NULL, +`c` varchar(100) DEFAULT NULL, +`d` varchar(100) DEFAULT NULL, +PRIMARY KEY (`id`), +KEY `idx_abc` (`a`,`b`,`c`) +) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +explain select * from t2 where a < 5 limit 10; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4096 100.00 Parallel execute (4 workers) +2 SIMPLE t2 NULL range idx_abc idx_abc 5 NULL 4096 100.00 Using index condition +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`id` AS `id`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where (`test`.`t2`.`a` < 5) limit 10 +select * from t2 where a < 5 limit 10; +id a b c d +1 1 2 abcabcabcabc cbacbacbacba +2 1 2 abcabcabcabc cbacbacbacba +3 1 2 abcabcabcabc cbacbacbacba +4 1 2 abcabcabcabc cbacbacbacba +5 1 2 abcabcabcabc cbacbacbacba +6 1 2 abcabcabcabc cbacbacbacba +7 1 2 abcabcabcabc cbacbacbacba +8 1 2 abcabcabcabc cbacbacbacba +9 1 2 abcabcabcabc cbacbacbacba +10 1 2 abcabcabcabc cbacbacbacba +DROP TABLE t2; diff --git a/mysql-test/suite/parallel_query/r/pq_order_const.result-pq b/mysql-test/suite/parallel_query/r/pq_order_const.result-pq new file mode 100644 index 000000000..19ccdf1ca --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_order_const.result-pq @@ -0,0 +1,181 @@ +create table t1( +a int NOT NULL, +b varchar(50) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t1 values (2, 'mysql'), (1, NULL), (0, 'hwsql'); +select * from t1; +a b +2 mysql +1 NULL +0 hwsql +select 1 from t1 group by 1; +1 +1 +select 1+1 as summa from t1 group by summa; +summa +2 +select 1+1 as summa from t1 group by 1+2; +summa +2 +select 1 from t1 group by "HWSQL"; +1 +1 +select 1+1 from t1 group by "HWSQL"; +1+1 +2 +select 1, "HWSQL" from t1 group by 1; +1 HWSQL +1 HWSQL +select 1, "HWSQL" from t1 group by "HWSQL"; +1 HWSQL +1 HWSQL +select a from t1 group by 1; +a +2 +1 +0 +set sql_mode=''; +select 1, a from t1 group by 1; +1 a +1 2 +select 1, a from t1 group by "HWSQL"; +1 a +1 2 +select 1+1 as summa, a from t1 group by summa; +summa a +2 2 +select 1+1 as summa, a from t1 group by 1+2; +summa a +2 2 +select 1+1 as summa, a from t1 group by "HWSQL"; +summa a +2 2 +select 1 from t1 order by 1; +1 +1 +1 +1 +select 1+1 as summa from t1 order by summa; +summa +2 +2 +2 +select 1+1 as summa from t1 order by 1+2; +summa +2 +2 +2 +select 1 from t1 order by "HWSQL"; +1 +1 +1 +1 +select 1+1 from t1 order by "HWSQL"; +1+1 +2 +2 +2 +select 1, "HWSQL" from t1 order by 1; +1 HWSQL +1 HWSQL +1 HWSQL +1 HWSQL +select 1, "HWSQL" from t1 order by "HWSQL"; +1 HWSQL +1 HWSQL +1 HWSQL +1 HWSQL +select a from t1 order by 1; +a +0 +1 +2 +select 1, a from t1 order by 1; +1 a +1 2 +1 1 +1 0 +select 1, a from t1 order by "HWSQL"; +1 a +1 2 +1 1 +1 0 +select 1+1 as summa, a from t1 order by summa; +summa a +2 2 +2 1 +2 0 +select 1+1 as summa, a from t1 order by 1+2; +summa a +2 2 +2 1 +2 0 +select 1+1 as summa, a from t1 order by "HWSQL"; +summa a +2 2 +2 1 +2 0 +select sum(a) from t1 group by 1 + 2; +sum(a) +3 +select 1, sum(a) from t1 group by 1; +1 sum(a) +1 3 +select 1, sum(a) from t1 group by 1+2; +1 sum(a) +1 3 +select 1+1, sum(a) from t1 group by a; +1+1 sum(a) +2 2 +2 1 +2 0 +select 1, sum(a) from t1 group by 1 order by 1; +1 sum(a) +1 3 +select a, sum(a) from t1 group by a order by 1; +a sum(a) +0 0 +1 1 +2 2 +select avg(a) from t1 group by b order by 1; +avg(a) +0.0000 +1.0000 +2.0000 +select avg(a) from t1 group by b order by a; +avg(a) +0.0000 +1.0000 +2.0000 +select 1, a from t1 group by NULL; +1 a +1 2 +select 1, a from t1 group by a order by NULL; +1 a +1 2 +1 1 +1 0 +select 1, a from t1 group by 1 + 1, NULL; +1 a +1 2 +select 1, sum(a) from t1 group by 1 order by 1+1, NULL; +1 sum(a) +1 3 +select 1, sum(a) from t1 group by 1+1, NULL order by 1; +1 sum(a) +1 3 +select 1, sum(a) from t1 group by 1, NULL order by 1+1, 1, NULL; +1 sum(a) +1 3 +select 1, sum(a) from t1 group by a, NULL order by 1, a, NULL; +1 sum(a) +1 0 +1 1 +1 2 +select 1, sum(a) from t1 group by NULL, a, NULL order by 1, a, NULL, NULL, a; +1 sum(a) +1 0 +1 1 +1 2 +drop table t1; +# restart diff --git a/mysql-test/suite/parallel_query/r/pq_range_clust.result b/mysql-test/suite/parallel_query/r/pq_range_clust.result new file mode 100644 index 000000000..0cc03894d --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_range_clust.result @@ -0,0 +1,30 @@ +create database pq_test; +use pq_test; +create table t1( +id int primary key auto_increment, +col1 varchar(100), +col2 int, +key idx_col2(col2) +)engine= innodb; +show variables like 'sql_pq_scan'; +Variable_name Value +sql_pq_scan 4 +select count(*) from pq_test.t1; +count(*) +10000 +select * from pq_test.t1 limit 1; +id col1 col2 +1 testtesttesttest 10000 +select * from pq_test.t1 order by id desc limit 1; +id col1 col2 +10000 testtesttesttest 1 +select * from pq_test.t1 ignore index(idx_col2) where id < 3000; +select * from pq_test.t1 ignore index(idx_col2) where id <= 3000; +select id from pq_test.t1 ignore index(idx_col2) where id > 2000; +select * from pq_test.t1 ignore index(idx_col2) where id >= 2000; +select * from pq_test.t1 ignore index(idx_col2) where id > 1000 and id < 8000; +select * from pq_test.t1 ignore index(idx_col2) where id >= 1000 and id <= 8000; +select * from pq_test.t1 ignore index(idx_col2) where id < 3000 or id > 5000; +select * from pq_test.t1 ignore index(idx_col2) where (id > 1000 and id < 5000) or (id > 6000 and id < 9000); +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_range_clust.result-pq b/mysql-test/suite/parallel_query/r/pq_range_clust.result-pq new file mode 100644 index 000000000..9640d56d6 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_range_clust.result-pq @@ -0,0 +1,30 @@ +create database pq_test; +use pq_test; +create table t1( +id int primary key auto_increment, +col1 varchar(100), +col2 int, +key idx_col2(col2) +)engine= innodb; +show variables like 'force_parallel_execute'; +Variable_name Value +force_parallel_execute ON +select count(*) from pq_test.t1; +count(*) +1000 +select * from pq_test.t1 limit 1; +id col1 col2 +1 testtesttesttest 1000 +select * from pq_test.t1 order by id desc limit 1; +id col1 col2 +1000 testtesttesttest 1 +select * from pq_test.t1 ignore index(idx_col2) where id < 300; +select * from pq_test.t1 ignore index(idx_col2) where id <= 300; +select id from pq_test.t1 ignore index(idx_col2) where id > 200; +select * from pq_test.t1 ignore index(idx_col2) where id >= 200; +select * from pq_test.t1 ignore index(idx_col2) where id > 100 and id < 800; +select * from pq_test.t1 ignore index(idx_col2) where id >= 100 and id <= 800; +select * from pq_test.t1 ignore index(idx_col2) where id < 300 or id > 500; +select * from pq_test.t1 ignore index(idx_col2) where (id > 100 and id < 500) or (id > 600 and id < 900); +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_range_scan_reverse.result-pq b/mysql-test/suite/parallel_query/r/pq_range_scan_reverse.result-pq new file mode 100644 index 000000000..a7151e73f --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_range_scan_reverse.result-pq @@ -0,0 +1,90 @@ +create database pq_test; +use pq_test; +create table t1 (a int, key(a desc)); +insert into t1 values(1),(2),(3),(4),(5),(6),(7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +pq_test.t1 analyze status OK +explain select a from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` +select a from t1; +a +7 +6 +5 +4 +3 +2 +1 +explain select * from t1 where a < 4; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` < 4) +select * from t1 where a < 4; +a +3 +2 +1 +explain select * from t1 where a < 4 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` < 4) order by `pq_test`.`t1`.`a` +select * from t1 where a < 4 order by a; +a +1 +2 +3 +explain select * from t1 where a < 4 order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range a a 5 NULL 3 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` where (`pq_test`.`t1`.`a` < 4) order by `pq_test`.`t1`.`a` desc +select * from t1 where a < 4 order by a desc; +a +3 +2 +1 +drop table pq_test.t1; +create table t2(a int not null, b int , primary key(a), key(b)); +insert into t2 values (1,1),(2,2),(3,3),(4,4); +explain select * from t2 where b < 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range b b 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`a` AS `a`,`pq_test`.`t2`.`b` AS `b` from `pq_test`.`t2` where (`pq_test`.`t2`.`b` < 3) +select * from t2 where b < 3; +a b +1 1 +2 2 +explain select * from t2 where b < 3 order by b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range b b 5 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`a` AS `a`,`pq_test`.`t2`.`b` AS `b` from `pq_test`.`t2` where (`pq_test`.`t2`.`b` < 3) order by `pq_test`.`t2`.`b` +select * from t2 where b < 3 order by b; +a b +1 1 +2 2 +explain select * from t2 where b < 3 order by b desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL range b b 5 NULL 2 100.00 Using where; Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t2`.`a` AS `a`,`pq_test`.`t2`.`b` AS `b` from `pq_test`.`t2` where (`pq_test`.`t2`.`b` < 3) order by `pq_test`.`t2`.`b` desc +select * from t2 where b < 3 order by b desc; +a b +2 2 +1 1 +drop table pq_test.t2; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_range_sec.result-pq b/mysql-test/suite/parallel_query/r/pq_range_sec.result-pq new file mode 100644 index 000000000..e179e9288 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_range_sec.result-pq @@ -0,0 +1,262 @@ +create database pq_test; +use pq_test; +create table t1( +id int primary key auto_increment, +col1 varchar(100), +col2 int, +key idx_col2(col2) +)engine= innodb; +show variables like 'force_parallel_execute'; +Variable_name Value +force_parallel_execute ON +select count(*) from pq_test.t1; +count(*) +1000 +select * from pq_test.t1 limit 1; +id col1 col2 +1 testtesttesttest 1000 +select * from pq_test.t1 order by id desc limit 1; +id col1 col2 +1000 testtesttesttest 1 +select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 300; +select id,col2 from pq_test.t1 force index(idx_col2) where col2 <= 300; +select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 200; +select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 200; +select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 100 and col2 < 800; +select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 100 and col2 <= 800; +select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 300 or col2 > 500; +select id,col2 from pq_test.t1 force index(idx_col2) where (col2 > 100 and col2 < 500) or (col2 > 600 and col2 < 900); +drop table pq_test.t1; +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 ( +id integer, +id2 integer not null, +index (id), +index (id2) +); +insert into t1 values(null,null),(1,1); +Warnings: +Warning 1048 Column 'id2' cannot be null +select * from t1 where id <=> null or id > 0; +id id2 +NULL 0 +1 1 +drop table t1; +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +Warnings: +Warning 1366 Incorrect string value: '\xF1\xF2\xF1\xF2\xF1\xF2...' for column 'b' at row 1 +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +Warnings: +Warning 1366 Incorrect string value: '\xF1\xF2\xF1\xF2\xF1\xF2...' for column 'b' at row 1 +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +Warnings: +Warning 1366 Incorrect string value: '\xF1\xF2\xF1\xF2\xF1\xF2...' for column 'b' at row 1 +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +Warnings: +Warning 1366 Incorrect string value: '\xF1\xF2\xF1\xF2\xF1\xF2...' for column 'b' at row 1 +SELECT hex(concat(repeat(0xF1F2, 10), '%')); +hex(concat(repeat(0xF1F2, 10), '%')) +F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225 +3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); +a hex(b) c +drop table t1; +CREATE TABLE t1 ( +v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, +pk INTEGER NOT NULL, +PRIMARY KEY (pk), +KEY v1_key (v1(10)) +) ENGINE=InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); +EXPLAIN SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 2 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`v1` AS `v1`,`pq_test`.`t1`.`pk` AS `pk` from `pq_test`.`t1` where (`pq_test`.`t1`.`v1` < (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref v1_key v1_key 32 const 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`v1` AS `v1`,`pq_test`.`t1`.`pk` AS `pk` from `pq_test`.`t1` where (`pq_test`.`t1`.`v1` = (char(127))) +EXPLAIN SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range v1_key v1_key 32 NULL 1 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`v1` AS `v1`,`pq_test`.`t1`.`pk` AS `pk` from `pq_test`.`t1` where (`pq_test`.`t1`.`v1` between 'f' and (char(127))) +SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +v1 pk +ABCDE 19 +JLVGO 14 +SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +v1 pk +SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); +v1 pk +JLVGO 14 +DROP TABLE t1; +CREATE TABLE t2 ( +auto int not null auto_increment, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL, +UNIQUE fld1 (fld1), +KEY fld3 (fld3), +PRIMARY KEY (auto) +) charset utf8mb4; +fld3 +fld3 +fld3 companynr +fld3 companynr +fld3 +yelped +Wotan +wallet +tinily +teethe +sumac +succumbed +subjective +Steinberg +snatching +fld3 +yelped +Wotan +wallet +tinily +teethe +fld3 +sumac +succumbed +subjective +Steinberg +snatching +fld3 +fld3 +fld3 +fld3 +fld3 +fld3 +fld3 +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +Warnings: +Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. +a filler +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +a filler +c-1011=w filler +c-1011=w filler-1 +c-1011=w filler-2 +c-1012=w filler +c-1012=w filler-1 +c-1012=w filler-2 +c-1013=w filler +c-1013=w filler-1 +c-1013=w filler-2 +c-1014=w filler +c-1014=w filler-1 +c-1014=w filler-2 +c-1015=w filler +c-1015=w filler-1 +c-1015=w filler-2 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +pq_test.t1 analyze status OK +# +# REF access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` where ((`pq_test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`pq_test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +count(*) +2 +EXPLAIN SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref PRIMARY,k1 k1 10 const,const # 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`pk_2` AS `pk_2` from `pq_test`.`t1` where ((`pq_test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`pq_test`.`t1`.`pk_1` = 3)) +FLUSH STATUS; +SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +pk_2 +3 +13 +# +# RANGE access optimization +# +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL range PRIMARY,k1 k1 10 NULL # 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select count(0) AS `count(*)` from `pq_test`.`t1` where ((`pq_test`.`t1`.`f1` = TIMESTAMP'2000-01-03 00:00:00') and (`pq_test`.`t1`.`pk_1` between 3 and 5)) +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +count(*) +6 +drop table t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_rec_visible.result-pq b/mysql-test/suite/parallel_query/r/pq_rec_visible.result-pq new file mode 100644 index 000000000..e2c6ca834 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_rec_visible.result-pq @@ -0,0 +1,30 @@ +CREATE TABLE t1 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, +c3 INT, +c4 INT, +INDEX k2(c2) +) Engine=InnoDB; +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (2, 2, 2); +INSERT INTO t1(c2,c3,c4) VALUES (3, 3, 3); +INSERT INTO t1(c2,c3,c4) VALUES (4, 4, 4); +INSERT INTO t1(c2,c3,c4) VALUES (5, 5, 5); +INSERT INTO t1(c2,c3,c4) VALUES (6, 6, 6); +INSERT INTO t1(c2,c3,c4) VALUES (7, 7, 7); +INSERT INTO t1(c2,c3,c4) VALUES (8, 8, 8); +INSERT INTO t1(c2,c3,c4) VALUES (9, 9, 9); +INSERT INTO t1(c2,c3,c4) VALUES (10, 10, 10); +BEGIN; +UPDATE t1 SET c2 = c2 * 3 WHERE c1 = 1; +DELETE FROM t1 WHERE c1 = 6; +SELECT COUNT(c2) FROM t1; +COUNT(c2) +9 +BEGIN; +SELECT COUNT(c2) FROM t1; +COUNT(c2) +10 +COMMIT; +COMMIT; +DROP TABLE t1; diff --git a/mysql-test/suite/parallel_query/r/pq_ref_reverse_scan.result-pq b/mysql-test/suite/parallel_query/r/pq_ref_reverse_scan.result-pq new file mode 100644 index 000000000..778b8a114 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_ref_reverse_scan.result-pq @@ -0,0 +1,27 @@ +create database pq_test; +use pq_test; +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (), (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +pq_test.t1 analyze status OK +explain select * from t1 where c1_idx = 'y' order by pk desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL ref c1_idx c1_idx 5 const 4 100.00 Using where; Backward index scan +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`pk` AS `pk`,`pq_test`.`t1`.`c1_idx` AS `c1_idx`,`pq_test`.`t1`.`c2` AS `c2` from `pq_test`.`t1` where (`pq_test`.`t1`.`c1_idx` = 'y') order by `pq_test`.`t1`.`pk` desc +select * from t1 where c1_idx = 'y' order by pk desc; +pk c1_idx c2 +4 y NULL +3 y NULL +2 y NULL +1 y NULL +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_restart_after_select.result-pq b/mysql-test/suite/parallel_query/r/pq_restart_after_select.result-pq new file mode 100644 index 000000000..792789193 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_restart_after_select.result-pq @@ -0,0 +1,11 @@ +create table t(id int); +insert into t values(1),(2),(3),(4),(5); +select * from t; +id +1 +2 +3 +4 +5 +drop table t; +# restart diff --git a/mysql-test/suite/parallel_query/r/pq_reverse_index_scan.result-pq b/mysql-test/suite/parallel_query/r/pq_reverse_index_scan.result-pq new file mode 100644 index 000000000..93ec5d3bb --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_reverse_index_scan.result-pq @@ -0,0 +1,54 @@ +create database pq_test; +use pq_test; +create table t1 (a int, key(a desc)); +insert into t1 values(1),(2),(3),(4),(5),(6),(7); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +pq_test.t1 analyze status OK +explain select a from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` +select a from t1; +a +7 +6 +5 +4 +3 +2 +1 +explain select a from t1 order by a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Backward index scan; Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 7 100.00 Backward index scan; Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` order by `pq_test`.`t1`.`a` +select a from t1 order by a; +a +1 +2 +3 +4 +5 +6 +7 +explain select a from t1 order by a desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 7 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL index NULL a 5 NULL 7 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `pq_test`.`t1`.`a` AS `a` from `pq_test`.`t1` order by `pq_test`.`t1`.`a` desc +select a from t1 order by a desc; +a +7 +6 +5 +4 +3 +2 +1 +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/r/pq_sec_index_min.result-pq b/mysql-test/suite/parallel_query/r/pq_sec_index_min.result-pq new file mode 100644 index 000000000..202a51c1e --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_sec_index_min.result-pq @@ -0,0 +1,22 @@ +CREATE TABLE t1 (i INT, j INT, INDEX (i), INDEX (j)); +INSERT INTO t1 (i,j) VALUES (1,1); +SELECT * FROM t1 WHERE i<3; +i j +1 1 +SET force_parallel_execute=0; +SELECT * FROM t1 WHERE i<3; +i j +1 1 +DROP TABLE t1; +CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, i INT, j INT, INDEX (i), INDEX (j)); +INSERT INTO t1 (i,j) VALUES (1,1); +SELECT * FROM t1 WHERE i<3 and j < 4; +pk i j +1 1 1 +DROP TABLE t1; +CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i), INDEX (j)); +INSERT INTO t1 (i,j) VALUES (1,1); +SELECT * FROM t1 WHERE j<3; +i j +1 1 +DROP TABLE t1; diff --git a/mysql-test/suite/parallel_query/r/pq_sp_trigger.result-pq b/mysql-test/suite/parallel_query/r/pq_sp_trigger.result-pq new file mode 100644 index 000000000..761696595 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_sp_trigger.result-pq @@ -0,0 +1,186 @@ +create table t3 (f1 int, f2 int)| +insert into t3 values (1,1)| +drop procedure if exists bug4579_1| +create procedure bug4579_1 () +begin +declare sf1 int; +select f1 into sf1 from t3 where f1=1 and f2=1; +update t3 set f2 = f2 + 1 where f1=1 and f2=1; +call bug4579_2(); +end| +drop procedure if exists bug4579_2| +create procedure bug4579_2 () +begin +end| +call bug4579_1()| +call bug4579_1()| +call bug4579_1()| +drop procedure bug4579_1| +drop procedure bug4579_2| +drop table t3| +drop function if exists func_20028_a| +drop function if exists func_20028_b| +drop function if exists func_20028_c| +drop procedure if exists proc_20028_a| +drop procedure if exists proc_20028_b| +drop procedure if exists proc_20028_c| +drop table if exists table_20028| +create table table_20028 (i int)| +SET @save_sql_mode=@@sql_mode| +SET sql_mode=''| +create function func_20028_a() returns integer +begin +declare temp integer; +select i into temp from table_20028 limit 1; +return ifnull(temp, 0); +end| +create function func_20028_b() returns integer +begin +return func_20028_a(); +end| +create function func_20028_c() returns integer +begin +declare div_zero integer; +set SQL_MODE='TRADITIONAL'; +select 1/0 into div_zero; +return div_zero; +end| +create procedure proc_20028_a() +begin +declare temp integer; +select i into temp from table_20028 limit 1; +end| +create procedure proc_20028_b() +begin +call proc_20028_a(); +end| +create procedure proc_20028_c() +begin +declare div_zero integer; +set SQL_MODE='TRADITIONAL'; +select 1/0 into div_zero; +end| +select func_20028_a()| +func_20028_a() +0 +select func_20028_b()| +func_20028_b() +0 +select func_20028_c()| +ERROR 22012: Division by 0 +call proc_20028_a()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_b()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_c()| +ERROR 22012: Division by 0 +SET sql_mode='TRADITIONAL'| +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| +create function func_20028_a() returns integer +begin +declare temp integer; +select i into temp from table_20028 limit 1; +return ifnull(temp, 0); +end| +create function func_20028_b() returns integer +begin +return func_20028_a(); +end| +create function func_20028_c() returns integer +begin +declare div_zero integer; +set SQL_MODE=''; +select 1/0 into div_zero; +return div_zero; +end| +create procedure proc_20028_a() +begin +declare temp integer; +select i into temp from table_20028 limit 1; +end| +create procedure proc_20028_b() +begin +call proc_20028_a(); +end| +create procedure proc_20028_c() +begin +declare div_zero integer; +set SQL_MODE=''; +select 1/0 into div_zero; +end| +select func_20028_a()| +func_20028_a() +0 +select func_20028_b()| +func_20028_b() +0 +select func_20028_c()| +func_20028_c() +NULL +call proc_20028_a()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_b()| +Warnings: +Warning 1329 No data - zero rows fetched, selected, or processed +call proc_20028_c()| +SET @@sql_mode=@save_sql_mode| +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| +drop table table_20028| +create table t1 (i int, j int default 10)| +create table t2 (i int)| +insert into t2 values (1), (2)| +create trigger trg1 before insert on t1 for each row +begin +if new.i = 1 then +set new.j := 1; +end if; +end| +create trigger trg2 after insert on t1 for each row set @a:= 1| +set @a:= 0| +insert into t1 (i) select * from t2| +select * from t1| +i j +1 1 +2 10 +select @a| +@a +1 +drop table t1, t2| +create table t1 (a varchar(64), b int); +create table t2 like t1; +create trigger t1_ai after insert on t1 for each row +set @a:= (select max(a) from t1); +insert into t1 (a) values +("Twas"),("brillig"),("and"),("the"),("slithy"),("toves"), +("Did"),("gyre"),("and"),("gimble"),("in"),("the"),("wabe"); +create trigger t2_ai after insert on t2 for each row +set @a:= (select max(a) from t2); +insert into t2 select * from t1; +load data infile '../../std_data/words.dat' into table t1 (a); +drop trigger t1_ai; +drop trigger t2_ai; +drop table t1,t2; +drop table if exists t1, t2; +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; +create trigger trg_del_t2 after delete on t2 for each row +insert into t1 values (1); +insert into t1 values (1); +insert into t2 values (1),(2); +delete t2 from t2; +ERROR 23000: Duplicate entry '1' for key 't1.PRIMARY' +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/parallel_query/r/pq_sql_cond.result-pq b/mysql-test/suite/parallel_query/r/pq_sql_cond.result-pq new file mode 100644 index 000000000..144062cea --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_sql_cond.result-pq @@ -0,0 +1,21 @@ +CREATE TABLE t1 (a enum ('aac','aab','aaa') not null); +INSERT INTO t1 VALUES ('aaa'),('aab'),('aac'); +explain SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 3 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,cast(`test`.`t1`.`a` as char(3) charset utf8mb4) AS `CAST(a AS CHAR(3))` from `test`.`t1` order by `cast(t1.a as char(2) charset utf8mb4)`,`test`.`t1`.`a` +SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; +a CAST(a AS CHAR(3)) +aac aac +aab aab +aaa aaa +Warnings: +Warning 1292 Truncated incorrect CHAR(2) value: 'aaa' +Warning 1292 Truncated incorrect CHAR(2) value: 'aab' +Warning 1292 Truncated incorrect CHAR(2) value: 'aac' +Warning 1292 Truncated incorrect CHAR(2) value: 'aac' +Warning 1292 Truncated incorrect CHAR(2) value: 'aab' +Warning 1292 Truncated incorrect CHAR(2) value: 'aaa' +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_stable_output.result-pq b/mysql-test/suite/parallel_query/r/pq_stable_output.result-pq new file mode 100644 index 000000000..dde0742b0 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_stable_output.result-pq @@ -0,0 +1,31705 @@ +drop table if exists t1; +SET @test_character_set= 'euckr'; +SET @test_collation= 'euckr_korean_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) euckr_korean_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) euckr_korean_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert ignore into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) DEFAULT NULL, + `level` smallint unsigned DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=euckr +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +# +# WL#3332 Korean Enhancements +# euckr valid codes are now [81..FE][41..5A,61..7A,81..FE] +# +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a binary(1), key(a)); +CREATE TABLE t2 (s VARCHAR(4), a VARCHAR(1) CHARACTER SET euckr); +INSERT INTO t2 +SELECT hex(concat(t11.a, t12.a)), concat(t11.a, t12.a) +FROM t1 t11, t1 t12 +WHERE t11.a >= 0x81 AND t11.a <= 0xFE +AND t12.a >= 0x41 AND t12.a <= 0xFE +ORDER BY t11.a, t12.a; +SELECT s as bad_code FROM t2 WHERE a='' ORDER BY s; +bad_code +815B +815C +815D +815E +815F +8160 +817B +817C +817D +817E +817F +8180 +825B +825C +825D +825E +825F +8260 +827B +827C +827D +827E +827F +8280 +835B +835C +835D +835E +835F +8360 +837B +837C +837D +837E +837F +8380 +845B +845C +845D +845E +845F +8460 +847B +847C +847D +847E +847F +8480 +855B +855C +855D +855E +855F +8560 +857B +857C +857D +857E +857F +8580 +865B +865C +865D +865E +865F +8660 +867B +867C +867D +867E +867F +8680 +875B +875C +875D +875E +875F +8760 +877B +877C +877D +877E +877F +8780 +885B +885C +885D +885E +885F +8860 +887B +887C +887D +887E +887F +8880 +895B +895C +895D +895E +895F +8960 +897B +897C +897D +897E +897F +8980 +8A5B +8A5C +8A5D +8A5E +8A5F +8A60 +8A7B +8A7C +8A7D +8A7E +8A7F +8A80 +8B5B +8B5C +8B5D +8B5E +8B5F +8B60 +8B7B +8B7C +8B7D +8B7E +8B7F +8B80 +8C5B +8C5C +8C5D +8C5E +8C5F +8C60 +8C7B +8C7C +8C7D +8C7E +8C7F +8C80 +8D5B +8D5C +8D5D +8D5E +8D5F +8D60 +8D7B +8D7C +8D7D +8D7E +8D7F +8D80 +8E5B +8E5C +8E5D +8E5E +8E5F +8E60 +8E7B +8E7C +8E7D +8E7E +8E7F +8E80 +8F5B +8F5C +8F5D +8F5E +8F5F +8F60 +8F7B +8F7C +8F7D +8F7E +8F7F +8F80 +905B +905C +905D +905E +905F +9060 +907B +907C +907D +907E +907F +9080 +915B +915C +915D +915E +915F +9160 +917B +917C +917D +917E +917F +9180 +925B +925C +925D +925E +925F +9260 +927B +927C +927D +927E +927F +9280 +935B +935C +935D +935E +935F +9360 +937B +937C +937D +937E +937F +9380 +945B +945C +945D +945E +945F +9460 +947B +947C +947D +947E +947F +9480 +955B +955C +955D +955E +955F +9560 +957B +957C +957D +957E +957F +9580 +965B +965C +965D +965E +965F +9660 +967B +967C +967D +967E +967F +9680 +975B +975C +975D +975E +975F +9760 +977B +977C +977D +977E +977F +9780 +985B +985C +985D +985E +985F +9860 +987B +987C +987D +987E +987F +9880 +995B +995C +995D +995E +995F +9960 +997B +997C +997D +997E +997F +9980 +9A5B +9A5C +9A5D +9A5E +9A5F +9A60 +9A7B +9A7C +9A7D +9A7E +9A7F +9A80 +9B5B +9B5C +9B5D +9B5E +9B5F +9B60 +9B7B +9B7C +9B7D +9B7E +9B7F +9B80 +9C5B +9C5C +9C5D +9C5E +9C5F +9C60 +9C7B +9C7C +9C7D +9C7E +9C7F +9C80 +9D5B +9D5C +9D5D +9D5E +9D5F +9D60 +9D7B +9D7C +9D7D +9D7E +9D7F +9D80 +9E5B +9E5C +9E5D +9E5E +9E5F +9E60 +9E7B +9E7C +9E7D +9E7E +9E7F +9E80 +9F5B +9F5C +9F5D +9F5E +9F5F +9F60 +9F7B +9F7C +9F7D +9F7E +9F7F +9F80 +A05B +A05C +A05D +A05E +A05F +A060 +A07B +A07C +A07D +A07E +A07F +A080 +A15B +A15C +A15D +A15E +A15F +A160 +A17B +A17C +A17D +A17E +A17F +A180 +A25B +A25C +A25D +A25E +A25F +A260 +A27B +A27C +A27D +A27E +A27F +A280 +A35B +A35C +A35D +A35E +A35F +A360 +A37B +A37C +A37D +A37E +A37F +A380 +A45B +A45C +A45D +A45E +A45F +A460 +A47B +A47C +A47D +A47E +A47F +A480 +A55B +A55C +A55D +A55E +A55F +A560 +A57B +A57C +A57D +A57E +A57F +A580 +A65B +A65C +A65D +A65E +A65F +A660 +A67B +A67C +A67D +A67E +A67F +A680 +A75B +A75C +A75D +A75E +A75F +A760 +A77B +A77C +A77D +A77E +A77F +A780 +A85B +A85C +A85D +A85E +A85F +A860 +A87B +A87C +A87D +A87E +A87F +A880 +A95B +A95C +A95D +A95E +A95F +A960 +A97B +A97C +A97D +A97E +A97F +A980 +AA5B +AA5C +AA5D +AA5E +AA5F +AA60 +AA7B +AA7C +AA7D +AA7E +AA7F +AA80 +AB5B +AB5C +AB5D +AB5E +AB5F +AB60 +AB7B +AB7C +AB7D +AB7E +AB7F +AB80 +AC5B +AC5C +AC5D +AC5E +AC5F +AC60 +AC7B +AC7C +AC7D +AC7E +AC7F +AC80 +AD5B +AD5C +AD5D +AD5E +AD5F +AD60 +AD7B +AD7C +AD7D +AD7E +AD7F +AD80 +AE5B +AE5C +AE5D +AE5E +AE5F +AE60 +AE7B +AE7C +AE7D +AE7E +AE7F +AE80 +AF5B +AF5C +AF5D +AF5E +AF5F +AF60 +AF7B +AF7C +AF7D +AF7E +AF7F +AF80 +B05B +B05C +B05D +B05E +B05F +B060 +B07B +B07C +B07D +B07E +B07F +B080 +B15B +B15C +B15D +B15E +B15F +B160 +B17B +B17C +B17D +B17E +B17F +B180 +B25B +B25C +B25D +B25E +B25F +B260 +B27B +B27C +B27D +B27E +B27F +B280 +B35B +B35C +B35D +B35E +B35F +B360 +B37B +B37C +B37D +B37E +B37F +B380 +B45B +B45C +B45D +B45E +B45F +B460 +B47B +B47C +B47D +B47E +B47F +B480 +B55B +B55C +B55D +B55E +B55F +B560 +B57B +B57C +B57D +B57E +B57F +B580 +B65B +B65C +B65D +B65E +B65F +B660 +B67B +B67C +B67D +B67E +B67F +B680 +B75B +B75C +B75D +B75E +B75F +B760 +B77B +B77C +B77D +B77E +B77F +B780 +B85B +B85C +B85D +B85E +B85F +B860 +B87B +B87C +B87D +B87E +B87F +B880 +B95B +B95C +B95D +B95E +B95F +B960 +B97B +B97C +B97D +B97E +B97F +B980 +BA5B +BA5C +BA5D +BA5E +BA5F +BA60 +BA7B +BA7C +BA7D +BA7E +BA7F +BA80 +BB5B +BB5C +BB5D +BB5E +BB5F +BB60 +BB7B +BB7C +BB7D +BB7E +BB7F +BB80 +BC5B +BC5C +BC5D +BC5E +BC5F +BC60 +BC7B +BC7C +BC7D +BC7E +BC7F +BC80 +BD5B +BD5C +BD5D +BD5E +BD5F +BD60 +BD7B +BD7C +BD7D +BD7E +BD7F +BD80 +BE5B +BE5C +BE5D +BE5E +BE5F +BE60 +BE7B +BE7C +BE7D +BE7E +BE7F +BE80 +BF5B +BF5C +BF5D +BF5E +BF5F +BF60 +BF7B +BF7C +BF7D +BF7E +BF7F +BF80 +C05B +C05C +C05D +C05E +C05F +C060 +C07B +C07C +C07D +C07E +C07F +C080 +C15B +C15C +C15D +C15E +C15F +C160 +C17B +C17C +C17D +C17E +C17F +C180 +C25B +C25C +C25D +C25E +C25F +C260 +C27B +C27C +C27D +C27E +C27F +C280 +C35B +C35C +C35D +C35E +C35F +C360 +C37B +C37C +C37D +C37E +C37F +C380 +C45B +C45C +C45D +C45E +C45F +C460 +C47B +C47C +C47D +C47E +C47F +C480 +C55B +C55C +C55D +C55E +C55F +C560 +C57B +C57C +C57D +C57E +C57F +C580 +C65B +C65C +C65D +C65E +C65F +C660 +C67B +C67C +C67D +C67E +C67F +C680 +C75B +C75C +C75D +C75E +C75F +C760 +C77B +C77C +C77D +C77E +C77F +C780 +C85B +C85C +C85D +C85E +C85F +C860 +C87B +C87C +C87D +C87E +C87F +C880 +C95B +C95C +C95D +C95E +C95F +C960 +C97B +C97C +C97D +C97E +C97F +C980 +CA5B +CA5C +CA5D +CA5E +CA5F +CA60 +CA7B +CA7C +CA7D +CA7E +CA7F +CA80 +CB5B +CB5C +CB5D +CB5E +CB5F +CB60 +CB7B +CB7C +CB7D +CB7E +CB7F +CB80 +CC5B +CC5C +CC5D +CC5E +CC5F +CC60 +CC7B +CC7C +CC7D +CC7E +CC7F +CC80 +CD5B +CD5C +CD5D +CD5E +CD5F +CD60 +CD7B +CD7C +CD7D +CD7E +CD7F +CD80 +CE5B +CE5C +CE5D +CE5E +CE5F +CE60 +CE7B +CE7C +CE7D +CE7E +CE7F +CE80 +CF5B +CF5C +CF5D +CF5E +CF5F +CF60 +CF7B +CF7C +CF7D +CF7E +CF7F +CF80 +D05B +D05C +D05D +D05E +D05F +D060 +D07B +D07C +D07D +D07E +D07F +D080 +D15B +D15C +D15D +D15E +D15F +D160 +D17B +D17C +D17D +D17E +D17F +D180 +D25B +D25C +D25D +D25E +D25F +D260 +D27B +D27C +D27D +D27E +D27F +D280 +D35B +D35C +D35D +D35E +D35F +D360 +D37B +D37C +D37D +D37E +D37F +D380 +D45B +D45C +D45D +D45E +D45F +D460 +D47B +D47C +D47D +D47E +D47F +D480 +D55B +D55C +D55D +D55E +D55F +D560 +D57B +D57C +D57D +D57E +D57F +D580 +D65B +D65C +D65D +D65E +D65F +D660 +D67B +D67C +D67D +D67E +D67F +D680 +D75B +D75C +D75D +D75E +D75F +D760 +D77B +D77C +D77D +D77E +D77F +D780 +D85B +D85C +D85D +D85E +D85F +D860 +D87B +D87C +D87D +D87E +D87F +D880 +D95B +D95C +D95D +D95E +D95F +D960 +D97B +D97C +D97D +D97E +D97F +D980 +DA5B +DA5C +DA5D +DA5E +DA5F +DA60 +DA7B +DA7C +DA7D +DA7E +DA7F +DA80 +DB5B +DB5C +DB5D +DB5E +DB5F +DB60 +DB7B +DB7C +DB7D +DB7E +DB7F +DB80 +DC5B +DC5C +DC5D +DC5E +DC5F +DC60 +DC7B +DC7C +DC7D +DC7E +DC7F +DC80 +DD5B +DD5C +DD5D +DD5E +DD5F +DD60 +DD7B +DD7C +DD7D +DD7E +DD7F +DD80 +DE5B +DE5C +DE5D +DE5E +DE5F +DE60 +DE7B +DE7C +DE7D +DE7E +DE7F +DE80 +DF5B +DF5C +DF5D +DF5E +DF5F +DF60 +DF7B +DF7C +DF7D +DF7E +DF7F +DF80 +E05B +E05C +E05D +E05E +E05F +E060 +E07B +E07C +E07D +E07E +E07F +E080 +E15B +E15C +E15D +E15E +E15F +E160 +E17B +E17C +E17D +E17E +E17F +E180 +E25B +E25C +E25D +E25E +E25F +E260 +E27B +E27C +E27D +E27E +E27F +E280 +E35B +E35C +E35D +E35E +E35F +E360 +E37B +E37C +E37D +E37E +E37F +E380 +E45B +E45C +E45D +E45E +E45F +E460 +E47B +E47C +E47D +E47E +E47F +E480 +E55B +E55C +E55D +E55E +E55F +E560 +E57B +E57C +E57D +E57E +E57F +E580 +E65B +E65C +E65D +E65E +E65F +E660 +E67B +E67C +E67D +E67E +E67F +E680 +E75B +E75C +E75D +E75E +E75F +E760 +E77B +E77C +E77D +E77E +E77F +E780 +E85B +E85C +E85D +E85E +E85F +E860 +E87B +E87C +E87D +E87E +E87F +E880 +E95B +E95C +E95D +E95E +E95F +E960 +E97B +E97C +E97D +E97E +E97F +E980 +EA5B +EA5C +EA5D +EA5E +EA5F +EA60 +EA7B +EA7C +EA7D +EA7E +EA7F +EA80 +EB5B +EB5C +EB5D +EB5E +EB5F +EB60 +EB7B +EB7C +EB7D +EB7E +EB7F +EB80 +EC5B +EC5C +EC5D +EC5E +EC5F +EC60 +EC7B +EC7C +EC7D +EC7E +EC7F +EC80 +ED5B +ED5C +ED5D +ED5E +ED5F +ED60 +ED7B +ED7C +ED7D +ED7E +ED7F +ED80 +EE5B +EE5C +EE5D +EE5E +EE5F +EE60 +EE7B +EE7C +EE7D +EE7E +EE7F +EE80 +EF5B +EF5C +EF5D +EF5E +EF5F +EF60 +EF7B +EF7C +EF7D +EF7E +EF7F +EF80 +F05B +F05C +F05D +F05E +F05F +F060 +F07B +F07C +F07D +F07E +F07F +F080 +F15B +F15C +F15D +F15E +F15F +F160 +F17B +F17C +F17D +F17E +F17F +F180 +F25B +F25C +F25D +F25E +F25F +F260 +F27B +F27C +F27D +F27E +F27F +F280 +F35B +F35C +F35D +F35E +F35F +F360 +F37B +F37C +F37D +F37E +F37F +F380 +F45B +F45C +F45D +F45E +F45F +F460 +F47B +F47C +F47D +F47E +F47F +F480 +F55B +F55C +F55D +F55E +F55F +F560 +F57B +F57C +F57D +F57E +F57F +F580 +F65B +F65C +F65D +F65E +F65F +F660 +F67B +F67C +F67D +F67E +F67F +F680 +F75B +F75C +F75D +F75E +F75F +F760 +F77B +F77C +F77D +F77E +F77F +F780 +F85B +F85C +F85D +F85E +F85F +F860 +F87B +F87C +F87D +F87E +F87F +F880 +F95B +F95C +F95D +F95E +F95F +F960 +F97B +F97C +F97D +F97E +F97F +F980 +FA5B +FA5C +FA5D +FA5E +FA5F +FA60 +FA7B +FA7C +FA7D +FA7E +FA7F +FA80 +FB5B +FB5C +FB5D +FB5E +FB5F +FB60 +FB7B +FB7C +FB7D +FB7E +FB7F +FB80 +FC5B +FC5C +FC5D +FC5E +FC5F +FC60 +FC7B +FC7C +FC7D +FC7E +FC7F +FC80 +FD5B +FD5C +FD5D +FD5E +FD5F +FD60 +FD7B +FD7C +FD7D +FD7E +FD7F +FD80 +FE5B +FE5C +FE5D +FE5E +FE5F +FE60 +FE7B +FE7C +FE7D +FE7E +FE7F +FE80 +DELETE FROM t2 WHERE a=''; +ALTER TABLE t2 ADD u VARCHAR(1) CHARACTER SET utf8, ADD a2 VARCHAR(1) CHARACTER SET euckr; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +UPDATE t2 SET u=a, a2=u; +SELECT s as unassigned_code FROM t2 WHERE u='?'; +unassigned_code +A2E8 +A2E9 +A2EA +A2EB +A2EC +A2ED +A2EE +A2EF +A2F0 +A2F1 +A2F2 +A2F3 +A2F4 +A2F5 +A2F6 +A2F7 +A2F8 +A2F9 +A2FA +A2FB +A2FC +A2FD +A2FE +A5AB +A5AC +A5AD +A5AE +A5AF +A5BA +A5BB +A5BC +A5BD +A5BE +A5BF +A5C0 +A5D9 +A5DA +A5DB +A5DC +A5DD +A5DE +A5DF +A5E0 +A5F9 +A5FA +A5FB +A5FC +A5FD +A5FE +A6E5 +A6E6 +A6E7 +A6E8 +A6E9 +A6EA +A6EB +A6EC +A6ED +A6EE +A6EF +A6F0 +A6F1 +A6F2 +A6F3 +A6F4 +A6F5 +A6F6 +A6F7 +A6F8 +A6F9 +A6FA +A6FB +A6FC +A6FD +A6FE +A7F0 +A7F1 +A7F2 +A7F3 +A7F4 +A7F5 +A7F6 +A7F7 +A7F8 +A7F9 +A7FA +A7FB +A7FC +A7FD +A7FE +A8A5 +A8A7 +A8B0 +AAF4 +AAF5 +AAF6 +AAF7 +AAF8 +AAF9 +AAFA +AAFB +AAFC +AAFD +AAFE +ABF7 +ABF8 +ABF9 +ABFA +ABFB +ABFC +ABFD +ABFE +ACC2 +ACC3 +ACC4 +ACC5 +ACC6 +ACC7 +ACC8 +ACC9 +ACCA +ACCB +ACCC +ACCD +ACCE +ACCF +ACD0 +ACF2 +ACF3 +ACF4 +ACF5 +ACF6 +ACF7 +ACF8 +ACF9 +ACFA +ACFB +ACFC +ACFD +ACFE +ADA1 +ADA2 +ADA3 +ADA4 +ADA5 +ADA6 +ADA7 +ADA8 +ADA9 +ADAA +ADAB +ADAC +ADAD +ADAE +ADAF +ADB0 +ADB1 +ADB2 +ADB3 +ADB4 +ADB5 +ADB6 +ADB7 +ADB8 +ADB9 +ADBA +ADBB +ADBC +ADBD +ADBE +ADBF +ADC0 +ADC1 +ADC2 +ADC3 +ADC4 +ADC5 +ADC6 +ADC7 +ADC8 +ADC9 +ADCA +ADCB +ADCC +ADCD +ADCE +ADCF +ADD0 +ADD1 +ADD2 +ADD3 +ADD4 +ADD5 +ADD6 +ADD7 +ADD8 +ADD9 +ADDA +ADDB +ADDC +ADDD +ADDE +ADDF +ADE0 +ADE1 +ADE2 +ADE3 +ADE4 +ADE5 +ADE6 +ADE7 +ADE8 +ADE9 +ADEA +ADEB +ADEC +ADED +ADEE +ADEF +ADF0 +ADF1 +ADF2 +ADF3 +ADF4 +ADF5 +ADF6 +ADF7 +ADF8 +ADF9 +ADFA +ADFB +ADFC +ADFD +ADFE +AEA1 +AEA2 +AEA3 +AEA4 +AEA5 +AEA6 +AEA7 +AEA8 +AEA9 +AEAA +AEAB +AEAC +AEAD +AEAE +AEAF +AEB0 +AEB1 +AEB2 +AEB3 +AEB4 +AEB5 +AEB6 +AEB7 +AEB8 +AEB9 +AEBA +AEBB +AEBC +AEBD +AEBE +AEBF +AEC0 +AEC1 +AEC2 +AEC3 +AEC4 +AEC5 +AEC6 +AEC7 +AEC8 +AEC9 +AECA +AECB +AECC +AECD +AECE +AECF +AED0 +AED1 +AED2 +AED3 +AED4 +AED5 +AED6 +AED7 +AED8 +AED9 +AEDA +AEDB +AEDC +AEDD +AEDE +AEDF +AEE0 +AEE1 +AEE2 +AEE3 +AEE4 +AEE5 +AEE6 +AEE7 +AEE8 +AEE9 +AEEA +AEEB +AEEC +AEED +AEEE +AEEF +AEF0 +AEF1 +AEF2 +AEF3 +AEF4 +AEF5 +AEF6 +AEF7 +AEF8 +AEF9 +AEFA +AEFB +AEFC +AEFD +AEFE +AFA1 +AFA2 +AFA3 +AFA4 +AFA5 +AFA6 +AFA7 +AFA8 +AFA9 +AFAA +AFAB +AFAC +AFAD +AFAE +AFAF +AFB0 +AFB1 +AFB2 +AFB3 +AFB4 +AFB5 +AFB6 +AFB7 +AFB8 +AFB9 +AFBA +AFBB +AFBC +AFBD +AFBE +AFBF +AFC0 +AFC1 +AFC2 +AFC3 +AFC4 +AFC5 +AFC6 +AFC7 +AFC8 +AFC9 +AFCA +AFCB +AFCC +AFCD +AFCE +AFCF +AFD0 +AFD1 +AFD2 +AFD3 +AFD4 +AFD5 +AFD6 +AFD7 +AFD8 +AFD9 +AFDA +AFDB +AFDC +AFDD +AFDE +AFDF +AFE0 +AFE1 +AFE2 +AFE3 +AFE4 +AFE5 +AFE6 +AFE7 +AFE8 +AFE9 +AFEA +AFEB +AFEC +AFED +AFEE +AFEF +AFF0 +AFF1 +AFF2 +AFF3 +AFF4 +AFF5 +AFF6 +AFF7 +AFF8 +AFF9 +AFFA +AFFB +AFFC +AFFD +AFFE +C653 +C654 +C655 +C656 +C657 +C658 +C659 +C65A +C661 +C662 +C663 +C664 +C665 +C666 +C667 +C668 +C669 +C66A +C66B +C66C +C66D +C66E +C66F +C670 +C671 +C672 +C673 +C674 +C675 +C676 +C677 +C678 +C679 +C67A +C681 +C682 +C683 +C684 +C685 +C686 +C687 +C688 +C689 +C68A +C68B +C68C +C68D +C68E +C68F +C690 +C691 +C692 +C693 +C694 +C695 +C696 +C697 +C698 +C699 +C69A +C69B +C69C +C69D +C69E +C69F +C6A0 +C741 +C742 +C743 +C744 +C745 +C746 +C747 +C748 +C749 +C74A +C74B +C74C +C74D +C74E +C74F +C750 +C751 +C752 +C753 +C754 +C755 +C756 +C757 +C758 +C759 +C75A +C761 +C762 +C763 +C764 +C765 +C766 +C767 +C768 +C769 +C76A +C76B +C76C +C76D +C76E +C76F +C770 +C771 +C772 +C773 +C774 +C775 +C776 +C777 +C778 +C779 +C77A +C781 +C782 +C783 +C784 +C785 +C786 +C787 +C788 +C789 +C78A +C78B +C78C +C78D +C78E +C78F +C790 +C791 +C792 +C793 +C794 +C795 +C796 +C797 +C798 +C799 +C79A +C79B +C79C +C79D +C79E +C79F +C7A0 +C841 +C842 +C843 +C844 +C845 +C846 +C847 +C848 +C849 +C84A +C84B +C84C +C84D +C84E +C84F +C850 +C851 +C852 +C853 +C854 +C855 +C856 +C857 +C858 +C859 +C85A +C861 +C862 +C863 +C864 +C865 +C866 +C867 +C868 +C869 +C86A +C86B +C86C +C86D +C86E +C86F +C870 +C871 +C872 +C873 +C874 +C875 +C876 +C877 +C878 +C879 +C87A +C881 +C882 +C883 +C884 +C885 +C886 +C887 +C888 +C889 +C88A +C88B +C88C +C88D +C88E +C88F +C890 +C891 +C892 +C893 +C894 +C895 +C896 +C897 +C898 +C899 +C89A +C89B +C89C +C89D +C89E +C89F +C8A0 +C941 +C942 +C943 +C944 +C945 +C946 +C947 +C948 +C949 +C94A +C94B +C94C +C94D +C94E +C94F +C950 +C951 +C952 +C953 +C954 +C955 +C956 +C957 +C958 +C959 +C95A +C961 +C962 +C963 +C964 +C965 +C966 +C967 +C968 +C969 +C96A +C96B +C96C +C96D +C96E +C96F +C970 +C971 +C972 +C973 +C974 +C975 +C976 +C977 +C978 +C979 +C97A +C981 +C982 +C983 +C984 +C985 +C986 +C987 +C988 +C989 +C98A +C98B +C98C +C98D +C98E +C98F +C990 +C991 +C992 +C993 +C994 +C995 +C996 +C997 +C998 +C999 +C99A +C99B +C99C +C99D +C99E +C99F +C9A0 +C9A1 +C9A2 +C9A3 +C9A4 +C9A5 +C9A6 +C9A7 +C9A8 +C9A9 +C9AA +C9AB +C9AC +C9AD +C9AE +C9AF +C9B0 +C9B1 +C9B2 +C9B3 +C9B4 +C9B5 +C9B6 +C9B7 +C9B8 +C9B9 +C9BA +C9BB +C9BC +C9BD +C9BE +C9BF +C9C0 +C9C1 +C9C2 +C9C3 +C9C4 +C9C5 +C9C6 +C9C7 +C9C8 +C9C9 +C9CA +C9CB +C9CC +C9CD +C9CE +C9CF +C9D0 +C9D1 +C9D2 +C9D3 +C9D4 +C9D5 +C9D6 +C9D7 +C9D8 +C9D9 +C9DA +C9DB +C9DC +C9DD +C9DE +C9DF +C9E0 +C9E1 +C9E2 +C9E3 +C9E4 +C9E5 +C9E6 +C9E7 +C9E8 +C9E9 +C9EA +C9EB +C9EC +C9ED +C9EE +C9EF +C9F0 +C9F1 +C9F2 +C9F3 +C9F4 +C9F5 +C9F6 +C9F7 +C9F8 +C9F9 +C9FA +C9FB +C9FC +C9FD +C9FE +CA41 +CA42 +CA43 +CA44 +CA45 +CA46 +CA47 +CA48 +CA49 +CA4A +CA4B +CA4C +CA4D +CA4E +CA4F +CA50 +CA51 +CA52 +CA53 +CA54 +CA55 +CA56 +CA57 +CA58 +CA59 +CA5A +CA61 +CA62 +CA63 +CA64 +CA65 +CA66 +CA67 +CA68 +CA69 +CA6A +CA6B +CA6C +CA6D +CA6E +CA6F +CA70 +CA71 +CA72 +CA73 +CA74 +CA75 +CA76 +CA77 +CA78 +CA79 +CA7A +CA81 +CA82 +CA83 +CA84 +CA85 +CA86 +CA87 +CA88 +CA89 +CA8A +CA8B +CA8C +CA8D +CA8E +CA8F +CA90 +CA91 +CA92 +CA93 +CA94 +CA95 +CA96 +CA97 +CA98 +CA99 +CA9A +CA9B +CA9C +CA9D +CA9E +CA9F +CAA0 +CB41 +CB42 +CB43 +CB44 +CB45 +CB46 +CB47 +CB48 +CB49 +CB4A +CB4B +CB4C +CB4D +CB4E +CB4F +CB50 +CB51 +CB52 +CB53 +CB54 +CB55 +CB56 +CB57 +CB58 +CB59 +CB5A +CB61 +CB62 +CB63 +CB64 +CB65 +CB66 +CB67 +CB68 +CB69 +CB6A +CB6B +CB6C +CB6D +CB6E +CB6F +CB70 +CB71 +CB72 +CB73 +CB74 +CB75 +CB76 +CB77 +CB78 +CB79 +CB7A +CB81 +CB82 +CB83 +CB84 +CB85 +CB86 +CB87 +CB88 +CB89 +CB8A +CB8B +CB8C +CB8D +CB8E +CB8F +CB90 +CB91 +CB92 +CB93 +CB94 +CB95 +CB96 +CB97 +CB98 +CB99 +CB9A +CB9B +CB9C +CB9D +CB9E +CB9F +CBA0 +CC41 +CC42 +CC43 +CC44 +CC45 +CC46 +CC47 +CC48 +CC49 +CC4A +CC4B +CC4C +CC4D +CC4E +CC4F +CC50 +CC51 +CC52 +CC53 +CC54 +CC55 +CC56 +CC57 +CC58 +CC59 +CC5A +CC61 +CC62 +CC63 +CC64 +CC65 +CC66 +CC67 +CC68 +CC69 +CC6A +CC6B +CC6C +CC6D +CC6E +CC6F +CC70 +CC71 +CC72 +CC73 +CC74 +CC75 +CC76 +CC77 +CC78 +CC79 +CC7A +CC81 +CC82 +CC83 +CC84 +CC85 +CC86 +CC87 +CC88 +CC89 +CC8A +CC8B +CC8C +CC8D +CC8E +CC8F +CC90 +CC91 +CC92 +CC93 +CC94 +CC95 +CC96 +CC97 +CC98 +CC99 +CC9A +CC9B +CC9C +CC9D +CC9E +CC9F +CCA0 +CD41 +CD42 +CD43 +CD44 +CD45 +CD46 +CD47 +CD48 +CD49 +CD4A +CD4B +CD4C +CD4D +CD4E +CD4F +CD50 +CD51 +CD52 +CD53 +CD54 +CD55 +CD56 +CD57 +CD58 +CD59 +CD5A +CD61 +CD62 +CD63 +CD64 +CD65 +CD66 +CD67 +CD68 +CD69 +CD6A +CD6B +CD6C +CD6D +CD6E +CD6F +CD70 +CD71 +CD72 +CD73 +CD74 +CD75 +CD76 +CD77 +CD78 +CD79 +CD7A +CD81 +CD82 +CD83 +CD84 +CD85 +CD86 +CD87 +CD88 +CD89 +CD8A +CD8B +CD8C +CD8D +CD8E +CD8F +CD90 +CD91 +CD92 +CD93 +CD94 +CD95 +CD96 +CD97 +CD98 +CD99 +CD9A +CD9B +CD9C +CD9D +CD9E +CD9F +CDA0 +CE41 +CE42 +CE43 +CE44 +CE45 +CE46 +CE47 +CE48 +CE49 +CE4A +CE4B +CE4C +CE4D +CE4E +CE4F +CE50 +CE51 +CE52 +CE53 +CE54 +CE55 +CE56 +CE57 +CE58 +CE59 +CE5A +CE61 +CE62 +CE63 +CE64 +CE65 +CE66 +CE67 +CE68 +CE69 +CE6A +CE6B +CE6C +CE6D +CE6E +CE6F +CE70 +CE71 +CE72 +CE73 +CE74 +CE75 +CE76 +CE77 +CE78 +CE79 +CE7A +CE81 +CE82 +CE83 +CE84 +CE85 +CE86 +CE87 +CE88 +CE89 +CE8A +CE8B +CE8C +CE8D +CE8E +CE8F +CE90 +CE91 +CE92 +CE93 +CE94 +CE95 +CE96 +CE97 +CE98 +CE99 +CE9A +CE9B +CE9C +CE9D +CE9E +CE9F +CEA0 +CF41 +CF42 +CF43 +CF44 +CF45 +CF46 +CF47 +CF48 +CF49 +CF4A +CF4B +CF4C +CF4D +CF4E +CF4F +CF50 +CF51 +CF52 +CF53 +CF54 +CF55 +CF56 +CF57 +CF58 +CF59 +CF5A +CF61 +CF62 +CF63 +CF64 +CF65 +CF66 +CF67 +CF68 +CF69 +CF6A +CF6B +CF6C +CF6D +CF6E +CF6F +CF70 +CF71 +CF72 +CF73 +CF74 +CF75 +CF76 +CF77 +CF78 +CF79 +CF7A +CF81 +CF82 +CF83 +CF84 +CF85 +CF86 +CF87 +CF88 +CF89 +CF8A +CF8B +CF8C +CF8D +CF8E +CF8F +CF90 +CF91 +CF92 +CF93 +CF94 +CF95 +CF96 +CF97 +CF98 +CF99 +CF9A +CF9B +CF9C +CF9D +CF9E +CF9F +CFA0 +D041 +D042 +D043 +D044 +D045 +D046 +D047 +D048 +D049 +D04A +D04B +D04C +D04D +D04E +D04F +D050 +D051 +D052 +D053 +D054 +D055 +D056 +D057 +D058 +D059 +D05A +D061 +D062 +D063 +D064 +D065 +D066 +D067 +D068 +D069 +D06A +D06B +D06C +D06D +D06E +D06F +D070 +D071 +D072 +D073 +D074 +D075 +D076 +D077 +D078 +D079 +D07A +D081 +D082 +D083 +D084 +D085 +D086 +D087 +D088 +D089 +D08A +D08B +D08C +D08D +D08E +D08F +D090 +D091 +D092 +D093 +D094 +D095 +D096 +D097 +D098 +D099 +D09A +D09B +D09C +D09D +D09E +D09F +D0A0 +D141 +D142 +D143 +D144 +D145 +D146 +D147 +D148 +D149 +D14A +D14B +D14C +D14D +D14E +D14F +D150 +D151 +D152 +D153 +D154 +D155 +D156 +D157 +D158 +D159 +D15A +D161 +D162 +D163 +D164 +D165 +D166 +D167 +D168 +D169 +D16A +D16B +D16C +D16D +D16E +D16F +D170 +D171 +D172 +D173 +D174 +D175 +D176 +D177 +D178 +D179 +D17A +D181 +D182 +D183 +D184 +D185 +D186 +D187 +D188 +D189 +D18A +D18B +D18C +D18D +D18E +D18F +D190 +D191 +D192 +D193 +D194 +D195 +D196 +D197 +D198 +D199 +D19A +D19B +D19C +D19D +D19E +D19F +D1A0 +D241 +D242 +D243 +D244 +D245 +D246 +D247 +D248 +D249 +D24A +D24B +D24C +D24D +D24E +D24F +D250 +D251 +D252 +D253 +D254 +D255 +D256 +D257 +D258 +D259 +D25A +D261 +D262 +D263 +D264 +D265 +D266 +D267 +D268 +D269 +D26A +D26B +D26C +D26D +D26E +D26F +D270 +D271 +D272 +D273 +D274 +D275 +D276 +D277 +D278 +D279 +D27A +D281 +D282 +D283 +D284 +D285 +D286 +D287 +D288 +D289 +D28A +D28B +D28C +D28D +D28E +D28F +D290 +D291 +D292 +D293 +D294 +D295 +D296 +D297 +D298 +D299 +D29A +D29B +D29C +D29D +D29E +D29F +D2A0 +D341 +D342 +D343 +D344 +D345 +D346 +D347 +D348 +D349 +D34A +D34B +D34C +D34D +D34E +D34F +D350 +D351 +D352 +D353 +D354 +D355 +D356 +D357 +D358 +D359 +D35A +D361 +D362 +D363 +D364 +D365 +D366 +D367 +D368 +D369 +D36A +D36B +D36C +D36D +D36E +D36F +D370 +D371 +D372 +D373 +D374 +D375 +D376 +D377 +D378 +D379 +D37A +D381 +D382 +D383 +D384 +D385 +D386 +D387 +D388 +D389 +D38A +D38B +D38C +D38D +D38E +D38F +D390 +D391 +D392 +D393 +D394 +D395 +D396 +D397 +D398 +D399 +D39A +D39B +D39C +D39D +D39E +D39F +D3A0 +D441 +D442 +D443 +D444 +D445 +D446 +D447 +D448 +D449 +D44A +D44B +D44C +D44D +D44E +D44F +D450 +D451 +D452 +D453 +D454 +D455 +D456 +D457 +D458 +D459 +D45A +D461 +D462 +D463 +D464 +D465 +D466 +D467 +D468 +D469 +D46A +D46B +D46C +D46D +D46E +D46F +D470 +D471 +D472 +D473 +D474 +D475 +D476 +D477 +D478 +D479 +D47A +D481 +D482 +D483 +D484 +D485 +D486 +D487 +D488 +D489 +D48A +D48B +D48C +D48D +D48E +D48F +D490 +D491 +D492 +D493 +D494 +D495 +D496 +D497 +D498 +D499 +D49A +D49B +D49C +D49D +D49E +D49F +D4A0 +D541 +D542 +D543 +D544 +D545 +D546 +D547 +D548 +D549 +D54A +D54B +D54C +D54D +D54E +D54F +D550 +D551 +D552 +D553 +D554 +D555 +D556 +D557 +D558 +D559 +D55A +D561 +D562 +D563 +D564 +D565 +D566 +D567 +D568 +D569 +D56A +D56B +D56C +D56D +D56E +D56F +D570 +D571 +D572 +D573 +D574 +D575 +D576 +D577 +D578 +D579 +D57A +D581 +D582 +D583 +D584 +D585 +D586 +D587 +D588 +D589 +D58A +D58B +D58C +D58D +D58E +D58F +D590 +D591 +D592 +D593 +D594 +D595 +D596 +D597 +D598 +D599 +D59A +D59B +D59C +D59D +D59E +D59F +D5A0 +D641 +D642 +D643 +D644 +D645 +D646 +D647 +D648 +D649 +D64A +D64B +D64C +D64D +D64E +D64F +D650 +D651 +D652 +D653 +D654 +D655 +D656 +D657 +D658 +D659 +D65A +D661 +D662 +D663 +D664 +D665 +D666 +D667 +D668 +D669 +D66A +D66B +D66C +D66D +D66E +D66F +D670 +D671 +D672 +D673 +D674 +D675 +D676 +D677 +D678 +D679 +D67A +D681 +D682 +D683 +D684 +D685 +D686 +D687 +D688 +D689 +D68A +D68B +D68C +D68D +D68E +D68F +D690 +D691 +D692 +D693 +D694 +D695 +D696 +D697 +D698 +D699 +D69A +D69B +D69C +D69D +D69E +D69F +D6A0 +D741 +D742 +D743 +D744 +D745 +D746 +D747 +D748 +D749 +D74A +D74B +D74C +D74D +D74E +D74F +D750 +D751 +D752 +D753 +D754 +D755 +D756 +D757 +D758 +D759 +D75A +D761 +D762 +D763 +D764 +D765 +D766 +D767 +D768 +D769 +D76A +D76B +D76C +D76D +D76E +D76F +D770 +D771 +D772 +D773 +D774 +D775 +D776 +D777 +D778 +D779 +D77A +D781 +D782 +D783 +D784 +D785 +D786 +D787 +D788 +D789 +D78A +D78B +D78C +D78D +D78E +D78F +D790 +D791 +D792 +D793 +D794 +D795 +D796 +D797 +D798 +D799 +D79A +D79B +D79C +D79D +D79E +D79F +D7A0 +D841 +D842 +D843 +D844 +D845 +D846 +D847 +D848 +D849 +D84A +D84B +D84C +D84D +D84E +D84F +D850 +D851 +D852 +D853 +D854 +D855 +D856 +D857 +D858 +D859 +D85A +D861 +D862 +D863 +D864 +D865 +D866 +D867 +D868 +D869 +D86A +D86B +D86C +D86D +D86E +D86F +D870 +D871 +D872 +D873 +D874 +D875 +D876 +D877 +D878 +D879 +D87A +D881 +D882 +D883 +D884 +D885 +D886 +D887 +D888 +D889 +D88A +D88B +D88C +D88D +D88E +D88F +D890 +D891 +D892 +D893 +D894 +D895 +D896 +D897 +D898 +D899 +D89A +D89B +D89C +D89D +D89E +D89F +D8A0 +D941 +D942 +D943 +D944 +D945 +D946 +D947 +D948 +D949 +D94A +D94B +D94C +D94D +D94E +D94F +D950 +D951 +D952 +D953 +D954 +D955 +D956 +D957 +D958 +D959 +D95A +D961 +D962 +D963 +D964 +D965 +D966 +D967 +D968 +D969 +D96A +D96B +D96C +D96D +D96E +D96F +D970 +D971 +D972 +D973 +D974 +D975 +D976 +D977 +D978 +D979 +D97A +D981 +D982 +D983 +D984 +D985 +D986 +D987 +D988 +D989 +D98A +D98B +D98C +D98D +D98E +D98F +D990 +D991 +D992 +D993 +D994 +D995 +D996 +D997 +D998 +D999 +D99A +D99B +D99C +D99D +D99E +D99F +D9A0 +DA41 +DA42 +DA43 +DA44 +DA45 +DA46 +DA47 +DA48 +DA49 +DA4A +DA4B +DA4C +DA4D +DA4E +DA4F +DA50 +DA51 +DA52 +DA53 +DA54 +DA55 +DA56 +DA57 +DA58 +DA59 +DA5A +DA61 +DA62 +DA63 +DA64 +DA65 +DA66 +DA67 +DA68 +DA69 +DA6A +DA6B +DA6C +DA6D +DA6E +DA6F +DA70 +DA71 +DA72 +DA73 +DA74 +DA75 +DA76 +DA77 +DA78 +DA79 +DA7A +DA81 +DA82 +DA83 +DA84 +DA85 +DA86 +DA87 +DA88 +DA89 +DA8A +DA8B +DA8C +DA8D +DA8E +DA8F +DA90 +DA91 +DA92 +DA93 +DA94 +DA95 +DA96 +DA97 +DA98 +DA99 +DA9A +DA9B +DA9C +DA9D +DA9E +DA9F +DAA0 +DB41 +DB42 +DB43 +DB44 +DB45 +DB46 +DB47 +DB48 +DB49 +DB4A +DB4B +DB4C +DB4D +DB4E +DB4F +DB50 +DB51 +DB52 +DB53 +DB54 +DB55 +DB56 +DB57 +DB58 +DB59 +DB5A +DB61 +DB62 +DB63 +DB64 +DB65 +DB66 +DB67 +DB68 +DB69 +DB6A +DB6B +DB6C +DB6D +DB6E +DB6F +DB70 +DB71 +DB72 +DB73 +DB74 +DB75 +DB76 +DB77 +DB78 +DB79 +DB7A +DB81 +DB82 +DB83 +DB84 +DB85 +DB86 +DB87 +DB88 +DB89 +DB8A +DB8B +DB8C +DB8D +DB8E +DB8F +DB90 +DB91 +DB92 +DB93 +DB94 +DB95 +DB96 +DB97 +DB98 +DB99 +DB9A +DB9B +DB9C +DB9D +DB9E +DB9F +DBA0 +DC41 +DC42 +DC43 +DC44 +DC45 +DC46 +DC47 +DC48 +DC49 +DC4A +DC4B +DC4C +DC4D +DC4E +DC4F +DC50 +DC51 +DC52 +DC53 +DC54 +DC55 +DC56 +DC57 +DC58 +DC59 +DC5A +DC61 +DC62 +DC63 +DC64 +DC65 +DC66 +DC67 +DC68 +DC69 +DC6A +DC6B +DC6C +DC6D +DC6E +DC6F +DC70 +DC71 +DC72 +DC73 +DC74 +DC75 +DC76 +DC77 +DC78 +DC79 +DC7A +DC81 +DC82 +DC83 +DC84 +DC85 +DC86 +DC87 +DC88 +DC89 +DC8A +DC8B +DC8C +DC8D +DC8E +DC8F +DC90 +DC91 +DC92 +DC93 +DC94 +DC95 +DC96 +DC97 +DC98 +DC99 +DC9A +DC9B +DC9C +DC9D +DC9E +DC9F +DCA0 +DD41 +DD42 +DD43 +DD44 +DD45 +DD46 +DD47 +DD48 +DD49 +DD4A +DD4B +DD4C +DD4D +DD4E +DD4F +DD50 +DD51 +DD52 +DD53 +DD54 +DD55 +DD56 +DD57 +DD58 +DD59 +DD5A +DD61 +DD62 +DD63 +DD64 +DD65 +DD66 +DD67 +DD68 +DD69 +DD6A +DD6B +DD6C +DD6D +DD6E +DD6F +DD70 +DD71 +DD72 +DD73 +DD74 +DD75 +DD76 +DD77 +DD78 +DD79 +DD7A +DD81 +DD82 +DD83 +DD84 +DD85 +DD86 +DD87 +DD88 +DD89 +DD8A +DD8B +DD8C +DD8D +DD8E +DD8F +DD90 +DD91 +DD92 +DD93 +DD94 +DD95 +DD96 +DD97 +DD98 +DD99 +DD9A +DD9B +DD9C +DD9D +DD9E +DD9F +DDA0 +DE41 +DE42 +DE43 +DE44 +DE45 +DE46 +DE47 +DE48 +DE49 +DE4A +DE4B +DE4C +DE4D +DE4E +DE4F +DE50 +DE51 +DE52 +DE53 +DE54 +DE55 +DE56 +DE57 +DE58 +DE59 +DE5A +DE61 +DE62 +DE63 +DE64 +DE65 +DE66 +DE67 +DE68 +DE69 +DE6A +DE6B +DE6C +DE6D +DE6E +DE6F +DE70 +DE71 +DE72 +DE73 +DE74 +DE75 +DE76 +DE77 +DE78 +DE79 +DE7A +DE81 +DE82 +DE83 +DE84 +DE85 +DE86 +DE87 +DE88 +DE89 +DE8A +DE8B +DE8C +DE8D +DE8E +DE8F +DE90 +DE91 +DE92 +DE93 +DE94 +DE95 +DE96 +DE97 +DE98 +DE99 +DE9A +DE9B +DE9C +DE9D +DE9E +DE9F +DEA0 +DF41 +DF42 +DF43 +DF44 +DF45 +DF46 +DF47 +DF48 +DF49 +DF4A +DF4B +DF4C +DF4D +DF4E +DF4F +DF50 +DF51 +DF52 +DF53 +DF54 +DF55 +DF56 +DF57 +DF58 +DF59 +DF5A +DF61 +DF62 +DF63 +DF64 +DF65 +DF66 +DF67 +DF68 +DF69 +DF6A +DF6B +DF6C +DF6D +DF6E +DF6F +DF70 +DF71 +DF72 +DF73 +DF74 +DF75 +DF76 +DF77 +DF78 +DF79 +DF7A +DF81 +DF82 +DF83 +DF84 +DF85 +DF86 +DF87 +DF88 +DF89 +DF8A +DF8B +DF8C +DF8D +DF8E +DF8F +DF90 +DF91 +DF92 +DF93 +DF94 +DF95 +DF96 +DF97 +DF98 +DF99 +DF9A +DF9B +DF9C +DF9D +DF9E +DF9F +DFA0 +E041 +E042 +E043 +E044 +E045 +E046 +E047 +E048 +E049 +E04A +E04B +E04C +E04D +E04E +E04F +E050 +E051 +E052 +E053 +E054 +E055 +E056 +E057 +E058 +E059 +E05A +E061 +E062 +E063 +E064 +E065 +E066 +E067 +E068 +E069 +E06A +E06B +E06C +E06D +E06E +E06F +E070 +E071 +E072 +E073 +E074 +E075 +E076 +E077 +E078 +E079 +E07A +E081 +E082 +E083 +E084 +E085 +E086 +E087 +E088 +E089 +E08A +E08B +E08C +E08D +E08E +E08F +E090 +E091 +E092 +E093 +E094 +E095 +E096 +E097 +E098 +E099 +E09A +E09B +E09C +E09D +E09E +E09F +E0A0 +E141 +E142 +E143 +E144 +E145 +E146 +E147 +E148 +E149 +E14A +E14B +E14C +E14D +E14E +E14F +E150 +E151 +E152 +E153 +E154 +E155 +E156 +E157 +E158 +E159 +E15A +E161 +E162 +E163 +E164 +E165 +E166 +E167 +E168 +E169 +E16A +E16B +E16C +E16D +E16E +E16F +E170 +E171 +E172 +E173 +E174 +E175 +E176 +E177 +E178 +E179 +E17A +E181 +E182 +E183 +E184 +E185 +E186 +E187 +E188 +E189 +E18A +E18B +E18C +E18D +E18E +E18F +E190 +E191 +E192 +E193 +E194 +E195 +E196 +E197 +E198 +E199 +E19A +E19B +E19C +E19D +E19E +E19F +E1A0 +E241 +E242 +E243 +E244 +E245 +E246 +E247 +E248 +E249 +E24A +E24B +E24C +E24D +E24E +E24F +E250 +E251 +E252 +E253 +E254 +E255 +E256 +E257 +E258 +E259 +E25A +E261 +E262 +E263 +E264 +E265 +E266 +E267 +E268 +E269 +E26A +E26B +E26C +E26D +E26E +E26F +E270 +E271 +E272 +E273 +E274 +E275 +E276 +E277 +E278 +E279 +E27A +E281 +E282 +E283 +E284 +E285 +E286 +E287 +E288 +E289 +E28A +E28B +E28C +E28D +E28E +E28F +E290 +E291 +E292 +E293 +E294 +E295 +E296 +E297 +E298 +E299 +E29A +E29B +E29C +E29D +E29E +E29F +E2A0 +E341 +E342 +E343 +E344 +E345 +E346 +E347 +E348 +E349 +E34A +E34B +E34C +E34D +E34E +E34F +E350 +E351 +E352 +E353 +E354 +E355 +E356 +E357 +E358 +E359 +E35A +E361 +E362 +E363 +E364 +E365 +E366 +E367 +E368 +E369 +E36A +E36B +E36C +E36D +E36E +E36F +E370 +E371 +E372 +E373 +E374 +E375 +E376 +E377 +E378 +E379 +E37A +E381 +E382 +E383 +E384 +E385 +E386 +E387 +E388 +E389 +E38A +E38B +E38C +E38D +E38E +E38F +E390 +E391 +E392 +E393 +E394 +E395 +E396 +E397 +E398 +E399 +E39A +E39B +E39C +E39D +E39E +E39F +E3A0 +E441 +E442 +E443 +E444 +E445 +E446 +E447 +E448 +E449 +E44A +E44B +E44C +E44D +E44E +E44F +E450 +E451 +E452 +E453 +E454 +E455 +E456 +E457 +E458 +E459 +E45A +E461 +E462 +E463 +E464 +E465 +E466 +E467 +E468 +E469 +E46A +E46B +E46C +E46D +E46E +E46F +E470 +E471 +E472 +E473 +E474 +E475 +E476 +E477 +E478 +E479 +E47A +E481 +E482 +E483 +E484 +E485 +E486 +E487 +E488 +E489 +E48A +E48B +E48C +E48D +E48E +E48F +E490 +E491 +E492 +E493 +E494 +E495 +E496 +E497 +E498 +E499 +E49A +E49B +E49C +E49D +E49E +E49F +E4A0 +E541 +E542 +E543 +E544 +E545 +E546 +E547 +E548 +E549 +E54A +E54B +E54C +E54D +E54E +E54F +E550 +E551 +E552 +E553 +E554 +E555 +E556 +E557 +E558 +E559 +E55A +E561 +E562 +E563 +E564 +E565 +E566 +E567 +E568 +E569 +E56A +E56B +E56C +E56D +E56E +E56F +E570 +E571 +E572 +E573 +E574 +E575 +E576 +E577 +E578 +E579 +E57A +E581 +E582 +E583 +E584 +E585 +E586 +E587 +E588 +E589 +E58A +E58B +E58C +E58D +E58E +E58F +E590 +E591 +E592 +E593 +E594 +E595 +E596 +E597 +E598 +E599 +E59A +E59B +E59C +E59D +E59E +E59F +E5A0 +E641 +E642 +E643 +E644 +E645 +E646 +E647 +E648 +E649 +E64A +E64B +E64C +E64D +E64E +E64F +E650 +E651 +E652 +E653 +E654 +E655 +E656 +E657 +E658 +E659 +E65A +E661 +E662 +E663 +E664 +E665 +E666 +E667 +E668 +E669 +E66A +E66B +E66C +E66D +E66E +E66F +E670 +E671 +E672 +E673 +E674 +E675 +E676 +E677 +E678 +E679 +E67A +E681 +E682 +E683 +E684 +E685 +E686 +E687 +E688 +E689 +E68A +E68B +E68C +E68D +E68E +E68F +E690 +E691 +E692 +E693 +E694 +E695 +E696 +E697 +E698 +E699 +E69A +E69B +E69C +E69D +E69E +E69F +E6A0 +E741 +E742 +E743 +E744 +E745 +E746 +E747 +E748 +E749 +E74A +E74B +E74C +E74D +E74E +E74F +E750 +E751 +E752 +E753 +E754 +E755 +E756 +E757 +E758 +E759 +E75A +E761 +E762 +E763 +E764 +E765 +E766 +E767 +E768 +E769 +E76A +E76B +E76C +E76D +E76E +E76F +E770 +E771 +E772 +E773 +E774 +E775 +E776 +E777 +E778 +E779 +E77A +E781 +E782 +E783 +E784 +E785 +E786 +E787 +E788 +E789 +E78A +E78B +E78C +E78D +E78E +E78F +E790 +E791 +E792 +E793 +E794 +E795 +E796 +E797 +E798 +E799 +E79A +E79B +E79C +E79D +E79E +E79F +E7A0 +E841 +E842 +E843 +E844 +E845 +E846 +E847 +E848 +E849 +E84A +E84B +E84C +E84D +E84E +E84F +E850 +E851 +E852 +E853 +E854 +E855 +E856 +E857 +E858 +E859 +E85A +E861 +E862 +E863 +E864 +E865 +E866 +E867 +E868 +E869 +E86A +E86B +E86C +E86D +E86E +E86F +E870 +E871 +E872 +E873 +E874 +E875 +E876 +E877 +E878 +E879 +E87A +E881 +E882 +E883 +E884 +E885 +E886 +E887 +E888 +E889 +E88A +E88B +E88C +E88D +E88E +E88F +E890 +E891 +E892 +E893 +E894 +E895 +E896 +E897 +E898 +E899 +E89A +E89B +E89C +E89D +E89E +E89F +E8A0 +E941 +E942 +E943 +E944 +E945 +E946 +E947 +E948 +E949 +E94A +E94B +E94C +E94D +E94E +E94F +E950 +E951 +E952 +E953 +E954 +E955 +E956 +E957 +E958 +E959 +E95A +E961 +E962 +E963 +E964 +E965 +E966 +E967 +E968 +E969 +E96A +E96B +E96C +E96D +E96E +E96F +E970 +E971 +E972 +E973 +E974 +E975 +E976 +E977 +E978 +E979 +E97A +E981 +E982 +E983 +E984 +E985 +E986 +E987 +E988 +E989 +E98A +E98B +E98C +E98D +E98E +E98F +E990 +E991 +E992 +E993 +E994 +E995 +E996 +E997 +E998 +E999 +E99A +E99B +E99C +E99D +E99E +E99F +E9A0 +EA41 +EA42 +EA43 +EA44 +EA45 +EA46 +EA47 +EA48 +EA49 +EA4A +EA4B +EA4C +EA4D +EA4E +EA4F +EA50 +EA51 +EA52 +EA53 +EA54 +EA55 +EA56 +EA57 +EA58 +EA59 +EA5A +EA61 +EA62 +EA63 +EA64 +EA65 +EA66 +EA67 +EA68 +EA69 +EA6A +EA6B +EA6C +EA6D +EA6E +EA6F +EA70 +EA71 +EA72 +EA73 +EA74 +EA75 +EA76 +EA77 +EA78 +EA79 +EA7A +EA81 +EA82 +EA83 +EA84 +EA85 +EA86 +EA87 +EA88 +EA89 +EA8A +EA8B +EA8C +EA8D +EA8E +EA8F +EA90 +EA91 +EA92 +EA93 +EA94 +EA95 +EA96 +EA97 +EA98 +EA99 +EA9A +EA9B +EA9C +EA9D +EA9E +EA9F +EAA0 +EB41 +EB42 +EB43 +EB44 +EB45 +EB46 +EB47 +EB48 +EB49 +EB4A +EB4B +EB4C +EB4D +EB4E +EB4F +EB50 +EB51 +EB52 +EB53 +EB54 +EB55 +EB56 +EB57 +EB58 +EB59 +EB5A +EB61 +EB62 +EB63 +EB64 +EB65 +EB66 +EB67 +EB68 +EB69 +EB6A +EB6B +EB6C +EB6D +EB6E +EB6F +EB70 +EB71 +EB72 +EB73 +EB74 +EB75 +EB76 +EB77 +EB78 +EB79 +EB7A +EB81 +EB82 +EB83 +EB84 +EB85 +EB86 +EB87 +EB88 +EB89 +EB8A +EB8B +EB8C +EB8D +EB8E +EB8F +EB90 +EB91 +EB92 +EB93 +EB94 +EB95 +EB96 +EB97 +EB98 +EB99 +EB9A +EB9B +EB9C +EB9D +EB9E +EB9F +EBA0 +EC41 +EC42 +EC43 +EC44 +EC45 +EC46 +EC47 +EC48 +EC49 +EC4A +EC4B +EC4C +EC4D +EC4E +EC4F +EC50 +EC51 +EC52 +EC53 +EC54 +EC55 +EC56 +EC57 +EC58 +EC59 +EC5A +EC61 +EC62 +EC63 +EC64 +EC65 +EC66 +EC67 +EC68 +EC69 +EC6A +EC6B +EC6C +EC6D +EC6E +EC6F +EC70 +EC71 +EC72 +EC73 +EC74 +EC75 +EC76 +EC77 +EC78 +EC79 +EC7A +EC81 +EC82 +EC83 +EC84 +EC85 +EC86 +EC87 +EC88 +EC89 +EC8A +EC8B +EC8C +EC8D +EC8E +EC8F +EC90 +EC91 +EC92 +EC93 +EC94 +EC95 +EC96 +EC97 +EC98 +EC99 +EC9A +EC9B +EC9C +EC9D +EC9E +EC9F +ECA0 +ED41 +ED42 +ED43 +ED44 +ED45 +ED46 +ED47 +ED48 +ED49 +ED4A +ED4B +ED4C +ED4D +ED4E +ED4F +ED50 +ED51 +ED52 +ED53 +ED54 +ED55 +ED56 +ED57 +ED58 +ED59 +ED5A +ED61 +ED62 +ED63 +ED64 +ED65 +ED66 +ED67 +ED68 +ED69 +ED6A +ED6B +ED6C +ED6D +ED6E +ED6F +ED70 +ED71 +ED72 +ED73 +ED74 +ED75 +ED76 +ED77 +ED78 +ED79 +ED7A +ED81 +ED82 +ED83 +ED84 +ED85 +ED86 +ED87 +ED88 +ED89 +ED8A +ED8B +ED8C +ED8D +ED8E +ED8F +ED90 +ED91 +ED92 +ED93 +ED94 +ED95 +ED96 +ED97 +ED98 +ED99 +ED9A +ED9B +ED9C +ED9D +ED9E +ED9F +EDA0 +EE41 +EE42 +EE43 +EE44 +EE45 +EE46 +EE47 +EE48 +EE49 +EE4A +EE4B +EE4C +EE4D +EE4E +EE4F +EE50 +EE51 +EE52 +EE53 +EE54 +EE55 +EE56 +EE57 +EE58 +EE59 +EE5A +EE61 +EE62 +EE63 +EE64 +EE65 +EE66 +EE67 +EE68 +EE69 +EE6A +EE6B +EE6C +EE6D +EE6E +EE6F +EE70 +EE71 +EE72 +EE73 +EE74 +EE75 +EE76 +EE77 +EE78 +EE79 +EE7A +EE81 +EE82 +EE83 +EE84 +EE85 +EE86 +EE87 +EE88 +EE89 +EE8A +EE8B +EE8C +EE8D +EE8E +EE8F +EE90 +EE91 +EE92 +EE93 +EE94 +EE95 +EE96 +EE97 +EE98 +EE99 +EE9A +EE9B +EE9C +EE9D +EE9E +EE9F +EEA0 +EF41 +EF42 +EF43 +EF44 +EF45 +EF46 +EF47 +EF48 +EF49 +EF4A +EF4B +EF4C +EF4D +EF4E +EF4F +EF50 +EF51 +EF52 +EF53 +EF54 +EF55 +EF56 +EF57 +EF58 +EF59 +EF5A +EF61 +EF62 +EF63 +EF64 +EF65 +EF66 +EF67 +EF68 +EF69 +EF6A +EF6B +EF6C +EF6D +EF6E +EF6F +EF70 +EF71 +EF72 +EF73 +EF74 +EF75 +EF76 +EF77 +EF78 +EF79 +EF7A +EF81 +EF82 +EF83 +EF84 +EF85 +EF86 +EF87 +EF88 +EF89 +EF8A +EF8B +EF8C +EF8D +EF8E +EF8F +EF90 +EF91 +EF92 +EF93 +EF94 +EF95 +EF96 +EF97 +EF98 +EF99 +EF9A +EF9B +EF9C +EF9D +EF9E +EF9F +EFA0 +F041 +F042 +F043 +F044 +F045 +F046 +F047 +F048 +F049 +F04A +F04B +F04C +F04D +F04E +F04F +F050 +F051 +F052 +F053 +F054 +F055 +F056 +F057 +F058 +F059 +F05A +F061 +F062 +F063 +F064 +F065 +F066 +F067 +F068 +F069 +F06A +F06B +F06C +F06D +F06E +F06F +F070 +F071 +F072 +F073 +F074 +F075 +F076 +F077 +F078 +F079 +F07A +F081 +F082 +F083 +F084 +F085 +F086 +F087 +F088 +F089 +F08A +F08B +F08C +F08D +F08E +F08F +F090 +F091 +F092 +F093 +F094 +F095 +F096 +F097 +F098 +F099 +F09A +F09B +F09C +F09D +F09E +F09F +F0A0 +F141 +F142 +F143 +F144 +F145 +F146 +F147 +F148 +F149 +F14A +F14B +F14C +F14D +F14E +F14F +F150 +F151 +F152 +F153 +F154 +F155 +F156 +F157 +F158 +F159 +F15A +F161 +F162 +F163 +F164 +F165 +F166 +F167 +F168 +F169 +F16A +F16B +F16C +F16D +F16E +F16F +F170 +F171 +F172 +F173 +F174 +F175 +F176 +F177 +F178 +F179 +F17A +F181 +F182 +F183 +F184 +F185 +F186 +F187 +F188 +F189 +F18A +F18B +F18C +F18D +F18E +F18F +F190 +F191 +F192 +F193 +F194 +F195 +F196 +F197 +F198 +F199 +F19A +F19B +F19C +F19D +F19E +F19F +F1A0 +F241 +F242 +F243 +F244 +F245 +F246 +F247 +F248 +F249 +F24A +F24B +F24C +F24D +F24E +F24F +F250 +F251 +F252 +F253 +F254 +F255 +F256 +F257 +F258 +F259 +F25A +F261 +F262 +F263 +F264 +F265 +F266 +F267 +F268 +F269 +F26A +F26B +F26C +F26D +F26E +F26F +F270 +F271 +F272 +F273 +F274 +F275 +F276 +F277 +F278 +F279 +F27A +F281 +F282 +F283 +F284 +F285 +F286 +F287 +F288 +F289 +F28A +F28B +F28C +F28D +F28E +F28F +F290 +F291 +F292 +F293 +F294 +F295 +F296 +F297 +F298 +F299 +F29A +F29B +F29C +F29D +F29E +F29F +F2A0 +F341 +F342 +F343 +F344 +F345 +F346 +F347 +F348 +F349 +F34A +F34B +F34C +F34D +F34E +F34F +F350 +F351 +F352 +F353 +F354 +F355 +F356 +F357 +F358 +F359 +F35A +F361 +F362 +F363 +F364 +F365 +F366 +F367 +F368 +F369 +F36A +F36B +F36C +F36D +F36E +F36F +F370 +F371 +F372 +F373 +F374 +F375 +F376 +F377 +F378 +F379 +F37A +F381 +F382 +F383 +F384 +F385 +F386 +F387 +F388 +F389 +F38A +F38B +F38C +F38D +F38E +F38F +F390 +F391 +F392 +F393 +F394 +F395 +F396 +F397 +F398 +F399 +F39A +F39B +F39C +F39D +F39E +F39F +F3A0 +F441 +F442 +F443 +F444 +F445 +F446 +F447 +F448 +F449 +F44A +F44B +F44C +F44D +F44E +F44F +F450 +F451 +F452 +F453 +F454 +F455 +F456 +F457 +F458 +F459 +F45A +F461 +F462 +F463 +F464 +F465 +F466 +F467 +F468 +F469 +F46A +F46B +F46C +F46D +F46E +F46F +F470 +F471 +F472 +F473 +F474 +F475 +F476 +F477 +F478 +F479 +F47A +F481 +F482 +F483 +F484 +F485 +F486 +F487 +F488 +F489 +F48A +F48B +F48C +F48D +F48E +F48F +F490 +F491 +F492 +F493 +F494 +F495 +F496 +F497 +F498 +F499 +F49A +F49B +F49C +F49D +F49E +F49F +F4A0 +F541 +F542 +F543 +F544 +F545 +F546 +F547 +F548 +F549 +F54A +F54B +F54C +F54D +F54E +F54F +F550 +F551 +F552 +F553 +F554 +F555 +F556 +F557 +F558 +F559 +F55A +F561 +F562 +F563 +F564 +F565 +F566 +F567 +F568 +F569 +F56A +F56B +F56C +F56D +F56E +F56F +F570 +F571 +F572 +F573 +F574 +F575 +F576 +F577 +F578 +F579 +F57A +F581 +F582 +F583 +F584 +F585 +F586 +F587 +F588 +F589 +F58A +F58B +F58C +F58D +F58E +F58F +F590 +F591 +F592 +F593 +F594 +F595 +F596 +F597 +F598 +F599 +F59A +F59B +F59C +F59D +F59E +F59F +F5A0 +F641 +F642 +F643 +F644 +F645 +F646 +F647 +F648 +F649 +F64A +F64B +F64C +F64D +F64E +F64F +F650 +F651 +F652 +F653 +F654 +F655 +F656 +F657 +F658 +F659 +F65A +F661 +F662 +F663 +F664 +F665 +F666 +F667 +F668 +F669 +F66A +F66B +F66C +F66D +F66E +F66F +F670 +F671 +F672 +F673 +F674 +F675 +F676 +F677 +F678 +F679 +F67A +F681 +F682 +F683 +F684 +F685 +F686 +F687 +F688 +F689 +F68A +F68B +F68C +F68D +F68E +F68F +F690 +F691 +F692 +F693 +F694 +F695 +F696 +F697 +F698 +F699 +F69A +F69B +F69C +F69D +F69E +F69F +F6A0 +F741 +F742 +F743 +F744 +F745 +F746 +F747 +F748 +F749 +F74A +F74B +F74C +F74D +F74E +F74F +F750 +F751 +F752 +F753 +F754 +F755 +F756 +F757 +F758 +F759 +F75A +F761 +F762 +F763 +F764 +F765 +F766 +F767 +F768 +F769 +F76A +F76B +F76C +F76D +F76E +F76F +F770 +F771 +F772 +F773 +F774 +F775 +F776 +F777 +F778 +F779 +F77A +F781 +F782 +F783 +F784 +F785 +F786 +F787 +F788 +F789 +F78A +F78B +F78C +F78D +F78E +F78F +F790 +F791 +F792 +F793 +F794 +F795 +F796 +F797 +F798 +F799 +F79A +F79B +F79C +F79D +F79E +F79F +F7A0 +F841 +F842 +F843 +F844 +F845 +F846 +F847 +F848 +F849 +F84A +F84B +F84C +F84D +F84E +F84F +F850 +F851 +F852 +F853 +F854 +F855 +F856 +F857 +F858 +F859 +F85A +F861 +F862 +F863 +F864 +F865 +F866 +F867 +F868 +F869 +F86A +F86B +F86C +F86D +F86E +F86F +F870 +F871 +F872 +F873 +F874 +F875 +F876 +F877 +F878 +F879 +F87A +F881 +F882 +F883 +F884 +F885 +F886 +F887 +F888 +F889 +F88A +F88B +F88C +F88D +F88E +F88F +F890 +F891 +F892 +F893 +F894 +F895 +F896 +F897 +F898 +F899 +F89A +F89B +F89C +F89D +F89E +F89F +F8A0 +F941 +F942 +F943 +F944 +F945 +F946 +F947 +F948 +F949 +F94A +F94B +F94C +F94D +F94E +F94F +F950 +F951 +F952 +F953 +F954 +F955 +F956 +F957 +F958 +F959 +F95A +F961 +F962 +F963 +F964 +F965 +F966 +F967 +F968 +F969 +F96A +F96B +F96C +F96D +F96E +F96F +F970 +F971 +F972 +F973 +F974 +F975 +F976 +F977 +F978 +F979 +F97A +F981 +F982 +F983 +F984 +F985 +F986 +F987 +F988 +F989 +F98A +F98B +F98C +F98D +F98E +F98F +F990 +F991 +F992 +F993 +F994 +F995 +F996 +F997 +F998 +F999 +F99A +F99B +F99C +F99D +F99E +F99F +F9A0 +FA41 +FA42 +FA43 +FA44 +FA45 +FA46 +FA47 +FA48 +FA49 +FA4A +FA4B +FA4C +FA4D +FA4E +FA4F +FA50 +FA51 +FA52 +FA53 +FA54 +FA55 +FA56 +FA57 +FA58 +FA59 +FA5A +FA61 +FA62 +FA63 +FA64 +FA65 +FA66 +FA67 +FA68 +FA69 +FA6A +FA6B +FA6C +FA6D +FA6E +FA6F +FA70 +FA71 +FA72 +FA73 +FA74 +FA75 +FA76 +FA77 +FA78 +FA79 +FA7A +FA81 +FA82 +FA83 +FA84 +FA85 +FA86 +FA87 +FA88 +FA89 +FA8A +FA8B +FA8C +FA8D +FA8E +FA8F +FA90 +FA91 +FA92 +FA93 +FA94 +FA95 +FA96 +FA97 +FA98 +FA99 +FA9A +FA9B +FA9C +FA9D +FA9E +FA9F +FAA0 +FB41 +FB42 +FB43 +FB44 +FB45 +FB46 +FB47 +FB48 +FB49 +FB4A +FB4B +FB4C +FB4D +FB4E +FB4F +FB50 +FB51 +FB52 +FB53 +FB54 +FB55 +FB56 +FB57 +FB58 +FB59 +FB5A +FB61 +FB62 +FB63 +FB64 +FB65 +FB66 +FB67 +FB68 +FB69 +FB6A +FB6B +FB6C +FB6D +FB6E +FB6F +FB70 +FB71 +FB72 +FB73 +FB74 +FB75 +FB76 +FB77 +FB78 +FB79 +FB7A +FB81 +FB82 +FB83 +FB84 +FB85 +FB86 +FB87 +FB88 +FB89 +FB8A +FB8B +FB8C +FB8D +FB8E +FB8F +FB90 +FB91 +FB92 +FB93 +FB94 +FB95 +FB96 +FB97 +FB98 +FB99 +FB9A +FB9B +FB9C +FB9D +FB9E +FB9F +FBA0 +FC41 +FC42 +FC43 +FC44 +FC45 +FC46 +FC47 +FC48 +FC49 +FC4A +FC4B +FC4C +FC4D +FC4E +FC4F +FC50 +FC51 +FC52 +FC53 +FC54 +FC55 +FC56 +FC57 +FC58 +FC59 +FC5A +FC61 +FC62 +FC63 +FC64 +FC65 +FC66 +FC67 +FC68 +FC69 +FC6A +FC6B +FC6C +FC6D +FC6E +FC6F +FC70 +FC71 +FC72 +FC73 +FC74 +FC75 +FC76 +FC77 +FC78 +FC79 +FC7A +FC81 +FC82 +FC83 +FC84 +FC85 +FC86 +FC87 +FC88 +FC89 +FC8A +FC8B +FC8C +FC8D +FC8E +FC8F +FC90 +FC91 +FC92 +FC93 +FC94 +FC95 +FC96 +FC97 +FC98 +FC99 +FC9A +FC9B +FC9C +FC9D +FC9E +FC9F +FCA0 +FD41 +FD42 +FD43 +FD44 +FD45 +FD46 +FD47 +FD48 +FD49 +FD4A +FD4B +FD4C +FD4D +FD4E +FD4F +FD50 +FD51 +FD52 +FD53 +FD54 +FD55 +FD56 +FD57 +FD58 +FD59 +FD5A +FD61 +FD62 +FD63 +FD64 +FD65 +FD66 +FD67 +FD68 +FD69 +FD6A +FD6B +FD6C +FD6D +FD6E +FD6F +FD70 +FD71 +FD72 +FD73 +FD74 +FD75 +FD76 +FD77 +FD78 +FD79 +FD7A +FD81 +FD82 +FD83 +FD84 +FD85 +FD86 +FD87 +FD88 +FD89 +FD8A +FD8B +FD8C +FD8D +FD8E +FD8F +FD90 +FD91 +FD92 +FD93 +FD94 +FD95 +FD96 +FD97 +FD98 +FD99 +FD9A +FD9B +FD9C +FD9D +FD9E +FD9F +FDA0 +FE41 +FE42 +FE43 +FE44 +FE45 +FE46 +FE47 +FE48 +FE49 +FE4A +FE4B +FE4C +FE4D +FE4E +FE4F +FE50 +FE51 +FE52 +FE53 +FE54 +FE55 +FE56 +FE57 +FE58 +FE59 +FE5A +FE61 +FE62 +FE63 +FE64 +FE65 +FE66 +FE67 +FE68 +FE69 +FE6A +FE6B +FE6C +FE6D +FE6E +FE6F +FE70 +FE71 +FE72 +FE73 +FE74 +FE75 +FE76 +FE77 +FE78 +FE79 +FE7A +FE81 +FE82 +FE83 +FE84 +FE85 +FE86 +FE87 +FE88 +FE89 +FE8A +FE8B +FE8C +FE8D +FE8E +FE8F +FE90 +FE91 +FE92 +FE93 +FE94 +FE95 +FE96 +FE97 +FE98 +FE99 +FE9A +FE9B +FE9C +FE9D +FE9E +FE9F +FEA0 +FEA1 +FEA2 +FEA3 +FEA4 +FEA5 +FEA6 +FEA7 +FEA8 +FEA9 +FEAA +FEAB +FEAC +FEAD +FEAE +FEAF +FEB0 +FEB1 +FEB2 +FEB3 +FEB4 +FEB5 +FEB6 +FEB7 +FEB8 +FEB9 +FEBA +FEBB +FEBC +FEBD +FEBE +FEBF +FEC0 +FEC1 +FEC2 +FEC3 +FEC4 +FEC5 +FEC6 +FEC7 +FEC8 +FEC9 +FECA +FECB +FECC +FECD +FECE +FECF +FED0 +FED1 +FED2 +FED3 +FED4 +FED5 +FED6 +FED7 +FED8 +FED9 +FEDA +FEDB +FEDC +FEDD +FEDE +FEDF +FEE0 +FEE1 +FEE2 +FEE3 +FEE4 +FEE5 +FEE6 +FEE7 +FEE8 +FEE9 +FEEA +FEEB +FEEC +FEED +FEEE +FEEF +FEF0 +FEF1 +FEF2 +FEF3 +FEF4 +FEF5 +FEF6 +FEF7 +FEF8 +FEF9 +FEFA +FEFB +FEFC +FEFD +FEFE +DELETE FROM t2 WHERE u='?'; +SELECT count(*) as roundtrip_problem_chars FROM t2 WHERE hex(a) <> hex(a2); +roundtrip_problem_chars +0 +SELECT s, hex(a), hex(u), hex(a2) FROM t2 ORDER BY s; +s hex(a) hex(u) hex(a2) +8141 8141 EAB082 8141 +8142 8142 EAB083 8142 +8143 8143 EAB085 8143 +8144 8144 EAB086 8144 +8145 8145 EAB08B 8145 +8146 8146 EAB08C 8146 +8147 8147 EAB08D 8147 +8148 8148 EAB08E 8148 +8149 8149 EAB08F 8149 +814A 814A EAB098 814A +814B 814B EAB09E 814B +814C 814C EAB09F 814C +814D 814D EAB0A1 814D +814E 814E EAB0A2 814E +814F 814F EAB0A3 814F +8150 8150 EAB0A5 8150 +8151 8151 EAB0A6 8151 +8152 8152 EAB0A7 8152 +8153 8153 EAB0A8 8153 +8154 8154 EAB0A9 8154 +8155 8155 EAB0AA 8155 +8156 8156 EAB0AB 8156 +8157 8157 EAB0AE 8157 +8158 8158 EAB0B2 8158 +8159 8159 EAB0B3 8159 +815A 815A EAB0B4 815A +8161 8161 EAB0B5 8161 +8162 8162 EAB0B6 8162 +8163 8163 EAB0B7 8163 +8164 8164 EAB0BA 8164 +8165 8165 EAB0BB 8165 +8166 8166 EAB0BD 8166 +8167 8167 EAB0BE 8167 +8168 8168 EAB0BF 8168 +8169 8169 EAB181 8169 +816A 816A EAB182 816A +816B 816B EAB183 816B +816C 816C EAB184 816C +816D 816D EAB185 816D +816E 816E EAB186 816E +816F 816F EAB187 816F +8170 8170 EAB188 8170 +8171 8171 EAB189 8171 +8172 8172 EAB18A 8172 +8173 8173 EAB18C 8173 +8174 8174 EAB18E 8174 +8175 8175 EAB18F 8175 +8176 8176 EAB190 8176 +8177 8177 EAB191 8177 +8178 8178 EAB192 8178 +8179 8179 EAB193 8179 +817A 817A EAB195 817A +8181 8181 EAB196 8181 +8182 8182 EAB197 8182 +8183 8183 EAB199 8183 +8184 8184 EAB19A 8184 +8185 8185 EAB19B 8185 +8186 8186 EAB19D 8186 +8187 8187 EAB19E 8187 +8188 8188 EAB19F 8188 +8189 8189 EAB1A0 8189 +818A 818A EAB1A1 818A +818B 818B EAB1A2 818B +818C 818C EAB1A3 818C +818D 818D EAB1A4 818D +818E 818E EAB1A5 818E +818F 818F EAB1A6 818F +8190 8190 EAB1A7 8190 +8191 8191 EAB1A8 8191 +8192 8192 EAB1A9 8192 +8193 8193 EAB1AA 8193 +8194 8194 EAB1AB 8194 +8195 8195 EAB1AC 8195 +8196 8196 EAB1AD 8196 +8197 8197 EAB1AE 8197 +8198 8198 EAB1AF 8198 +8199 8199 EAB1B2 8199 +819A 819A EAB1B3 819A +819B 819B EAB1B5 819B +819C 819C EAB1B6 819C +819D 819D EAB1B9 819D +819E 819E EAB1BB 819E +819F 819F EAB1BC 819F +81A0 81A0 EAB1BD 81A0 +81A1 81A1 EAB1BE 81A1 +81A2 81A2 EAB1BF 81A2 +81A3 81A3 EAB282 81A3 +81A4 81A4 EAB287 81A4 +81A5 81A5 EAB288 81A5 +81A6 81A6 EAB28D 81A6 +81A7 81A7 EAB28E 81A7 +81A8 81A8 EAB28F 81A8 +81A9 81A9 EAB291 81A9 +81AA 81AA EAB292 81AA +81AB 81AB EAB293 81AB +81AC 81AC EAB295 81AC +81AD 81AD EAB296 81AD +81AE 81AE EAB297 81AE +81AF 81AF EAB298 81AF +81B0 81B0 EAB299 81B0 +81B1 81B1 EAB29A 81B1 +81B2 81B2 EAB29B 81B2 +81B3 81B3 EAB29E 81B3 +81B4 81B4 EAB2A2 81B4 +81B5 81B5 EAB2A3 81B5 +81B6 81B6 EAB2A4 81B6 +81B7 81B7 EAB2A5 81B7 +81B8 81B8 EAB2A6 81B8 +81B9 81B9 EAB2A7 81B9 +81BA 81BA EAB2AB 81BA +81BB 81BB EAB2AD 81BB +81BC 81BC EAB2AE 81BC +81BD 81BD EAB2B1 81BD +81BE 81BE EAB2B2 81BE +81BF 81BF EAB2B3 81BF +81C0 81C0 EAB2B4 81C0 +81C1 81C1 EAB2B5 81C1 +81C2 81C2 EAB2B6 81C2 +81C3 81C3 EAB2B7 81C3 +81C4 81C4 EAB2BA 81C4 +81C5 81C5 EAB2BE 81C5 +81C6 81C6 EAB2BF 81C6 +81C7 81C7 EAB380 81C7 +81C8 81C8 EAB382 81C8 +81C9 81C9 EAB383 81C9 +81CA 81CA EAB385 81CA +81CB 81CB EAB386 81CB +81CC 81CC EAB387 81CC +81CD 81CD EAB389 81CD +81CE 81CE EAB38A 81CE +81CF 81CF EAB38B 81CF +81D0 81D0 EAB38D 81D0 +81D1 81D1 EAB38E 81D1 +81D2 81D2 EAB38F 81D2 +81D3 81D3 EAB390 81D3 +81D4 81D4 EAB391 81D4 +81D5 81D5 EAB392 81D5 +81D6 81D6 EAB393 81D6 +81D7 81D7 EAB394 81D7 +81D8 81D8 EAB396 81D8 +81D9 81D9 EAB398 81D9 +81DA 81DA EAB399 81DA +81DB 81DB EAB39A 81DB +81DC 81DC EAB39B 81DC +81DD 81DD EAB39C 81DD +81DE 81DE EAB39D 81DE +81DF 81DF EAB39E 81DF +81E0 81E0 EAB39F 81E0 +81E1 81E1 EAB3A2 81E1 +81E2 81E2 EAB3A3 81E2 +81E3 81E3 EAB3A5 81E3 +81E4 81E4 EAB3A6 81E4 +81E5 81E5 EAB3A9 81E5 +81E6 81E6 EAB3AB 81E6 +81E7 81E7 EAB3AD 81E7 +81E8 81E8 EAB3AE 81E8 +81E9 81E9 EAB3B2 81E9 +81EA 81EA EAB3B4 81EA +81EB 81EB EAB3B7 81EB +81EC 81EC EAB3B8 81EC +81ED 81ED EAB3B9 81ED +81EE 81EE EAB3BA 81EE +81EF 81EF EAB3BB 81EF +81F0 81F0 EAB3BE 81F0 +81F1 81F1 EAB3BF 81F1 +81F2 81F2 EAB481 81F2 +81F3 81F3 EAB482 81F3 +81F4 81F4 EAB483 81F4 +81F5 81F5 EAB485 81F5 +81F6 81F6 EAB487 81F6 +81F7 81F7 EAB488 81F7 +81F8 81F8 EAB489 81F8 +81F9 81F9 EAB48A 81F9 +81FA 81FA EAB48B 81FA +81FB 81FB EAB48E 81FB +81FC 81FC EAB490 81FC +81FD 81FD EAB492 81FD +81FE 81FE EAB493 81FE +8241 8241 EAB494 8241 +8242 8242 EAB495 8242 +8243 8243 EAB496 8243 +8244 8244 EAB497 8244 +8245 8245 EAB499 8245 +8246 8246 EAB49A 8246 +8247 8247 EAB49B 8247 +8248 8248 EAB49D 8248 +8249 8249 EAB49E 8249 +824A 824A EAB49F 824A +824B 824B EAB4A1 824B +824C 824C EAB4A2 824C +824D 824D EAB4A3 824D +824E 824E EAB4A4 824E +824F 824F EAB4A5 824F +8250 8250 EAB4A6 8250 +8251 8251 EAB4A7 8251 +8252 8252 EAB4A8 8252 +8253 8253 EAB4AA 8253 +8254 8254 EAB4AB 8254 +8255 8255 EAB4AE 8255 +8256 8256 EAB4AF 8256 +8257 8257 EAB4B0 8257 +8258 8258 EAB4B1 8258 +8259 8259 EAB4B2 8259 +825A 825A EAB4B3 825A +8261 8261 EAB4B6 8261 +8262 8262 EAB4B7 8262 +8263 8263 EAB4B9 8263 +8264 8264 EAB4BA 8264 +8265 8265 EAB4BB 8265 +8266 8266 EAB4BD 8266 +8267 8267 EAB4BE 8267 +8268 8268 EAB4BF 8268 +8269 8269 EAB580 8269 +826A 826A EAB581 826A +826B 826B EAB582 826B +826C 826C EAB583 826C +826D 826D EAB586 826D +826E 826E EAB588 826E +826F 826F EAB58A 826F +8270 8270 EAB58B 8270 +8271 8271 EAB58C 8271 +8272 8272 EAB58D 8272 +8273 8273 EAB58E 8273 +8274 8274 EAB58F 8274 +8275 8275 EAB591 8275 +8276 8276 EAB592 8276 +8277 8277 EAB593 8277 +8278 8278 EAB595 8278 +8279 8279 EAB596 8279 +827A 827A EAB597 827A +8281 8281 EAB599 8281 +8282 8282 EAB59A 8282 +8283 8283 EAB59B 8283 +8284 8284 EAB59C 8284 +8285 8285 EAB59D 8285 +8286 8286 EAB59E 8286 +8287 8287 EAB59F 8287 +8288 8288 EAB5A0 8288 +8289 8289 EAB5A2 8289 +828A 828A EAB5A4 828A +828B 828B EAB5A5 828B +828C 828C EAB5A6 828C +828D 828D EAB5A7 828D +828E 828E EAB5A8 828E +828F 828F EAB5A9 828F +8290 8290 EAB5AA 8290 +8291 8291 EAB5AB 8291 +8292 8292 EAB5AE 8292 +8293 8293 EAB5AF 8293 +8294 8294 EAB5B1 8294 +8295 8295 EAB5B2 8295 +8296 8296 EAB5B7 8296 +8297 8297 EAB5B8 8297 +8298 8298 EAB5B9 8298 +8299 8299 EAB5BA 8299 +829A 829A EAB5BE 829A +829B 829B EAB680 829B +829C 829C EAB683 829C +829D 829D EAB684 829D +829E 829E EAB685 829E +829F 829F EAB686 829F +82A0 82A0 EAB687 82A0 +82A1 82A1 EAB68A 82A1 +82A2 82A2 EAB68B 82A2 +82A3 82A3 EAB68D 82A3 +82A4 82A4 EAB68E 82A4 +82A5 82A5 EAB68F 82A5 +82A6 82A6 EAB691 82A6 +82A7 82A7 EAB692 82A7 +82A8 82A8 EAB693 82A8 +82A9 82A9 EAB694 82A9 +82AA 82AA EAB695 82AA +82AB 82AB EAB696 82AB +82AC 82AC EAB697 82AC +82AD 82AD EAB698 82AD +82AE 82AE EAB699 82AE +82AF 82AF EAB69A 82AF +82B0 82B0 EAB69B 82B0 +82B1 82B1 EAB69E 82B1 +82B2 82B2 EAB69F 82B2 +82B3 82B3 EAB6A0 82B3 +82B4 82B4 EAB6A1 82B4 +82B5 82B5 EAB6A2 82B5 +82B6 82B6 EAB6A3 82B6 +82B7 82B7 EAB6A5 82B7 +82B8 82B8 EAB6A6 82B8 +82B9 82B9 EAB6A7 82B9 +82BA 82BA EAB6A8 82BA +82BB 82BB EAB6A9 82BB +82BC 82BC EAB6AA 82BC +82BD 82BD EAB6AB 82BD +82BE 82BE EAB6AC 82BE +82BF 82BF EAB6AD 82BF +82C0 82C0 EAB6AE 82C0 +82C1 82C1 EAB6AF 82C1 +82C2 82C2 EAB6B0 82C2 +82C3 82C3 EAB6B1 82C3 +82C4 82C4 EAB6B2 82C4 +82C5 82C5 EAB6B3 82C5 +82C6 82C6 EAB6B4 82C6 +82C7 82C7 EAB6B5 82C7 +82C8 82C8 EAB6B6 82C8 +82C9 82C9 EAB6B8 82C9 +82CA 82CA EAB6B9 82CA +82CB 82CB EAB6BA 82CB +82CC 82CC EAB6BB 82CC +82CD 82CD EAB6BC 82CD +82CE 82CE EAB6BD 82CE +82CF 82CF EAB6BE 82CF +82D0 82D0 EAB6BF 82D0 +82D1 82D1 EAB782 82D1 +82D2 82D2 EAB783 82D2 +82D3 82D3 EAB785 82D3 +82D4 82D4 EAB786 82D4 +82D5 82D5 EAB787 82D5 +82D6 82D6 EAB789 82D6 +82D7 82D7 EAB78A 82D7 +82D8 82D8 EAB78B 82D8 +82D9 82D9 EAB78C 82D9 +82DA 82DA EAB78D 82DA +82DB 82DB EAB78E 82DB +82DC 82DC EAB78F 82DC +82DD 82DD EAB792 82DD +82DE 82DE EAB794 82DE +82DF 82DF EAB795 82DF +82E0 82E0 EAB796 82E0 +82E1 82E1 EAB797 82E1 +82E2 82E2 EAB798 82E2 +82E3 82E3 EAB799 82E3 +82E4 82E4 EAB79A 82E4 +82E5 82E5 EAB79B 82E5 +82E6 82E6 EAB79D 82E6 +82E7 82E7 EAB79E 82E7 +82E8 82E8 EAB79F 82E8 +82E9 82E9 EAB7A1 82E9 +82EA 82EA EAB7A2 82EA +82EB 82EB EAB7A3 82EB +82EC 82EC EAB7A5 82EC +82ED 82ED EAB7A6 82ED +82EE 82EE EAB7A7 82EE +82EF 82EF EAB7A8 82EF +82F0 82F0 EAB7A9 82F0 +82F1 82F1 EAB7AA 82F1 +82F2 82F2 EAB7AB 82F2 +82F3 82F3 EAB7AC 82F3 +82F4 82F4 EAB7AD 82F4 +82F5 82F5 EAB7AE 82F5 +82F6 82F6 EAB7AF 82F6 +82F7 82F7 EAB7B0 82F7 +82F8 82F8 EAB7B1 82F8 +82F9 82F9 EAB7B2 82F9 +82FA 82FA EAB7B3 82FA +82FB 82FB EAB7B4 82FB +82FC 82FC EAB7B5 82FC +82FD 82FD EAB7B6 82FD +82FE 82FE EAB7B7 82FE +8341 8341 EAB7BA 8341 +8342 8342 EAB7BB 8342 +8343 8343 EAB7BD 8343 +8344 8344 EAB7BE 8344 +8345 8345 EAB882 8345 +8346 8346 EAB883 8346 +8347 8347 EAB884 8347 +8348 8348 EAB885 8348 +8349 8349 EAB886 8349 +834A 834A EAB887 834A +834B 834B EAB88A 834B +834C 834C EAB88C 834C +834D 834D EAB88E 834D +834E 834E EAB88F 834E +834F 834F EAB890 834F +8350 8350 EAB891 8350 +8351 8351 EAB892 8351 +8352 8352 EAB893 8352 +8353 8353 EAB895 8353 +8354 8354 EAB896 8354 +8355 8355 EAB897 8355 +8356 8356 EAB898 8356 +8357 8357 EAB899 8357 +8358 8358 EAB89A 8358 +8359 8359 EAB89B 8359 +835A 835A EAB89C 835A +8361 8361 EAB89D 8361 +8362 8362 EAB89E 8362 +8363 8363 EAB89F 8363 +8364 8364 EAB8A0 8364 +8365 8365 EAB8A1 8365 +8366 8366 EAB8A2 8366 +8367 8367 EAB8A3 8367 +8368 8368 EAB8A4 8368 +8369 8369 EAB8A5 8369 +836A 836A EAB8A6 836A +836B 836B EAB8A7 836B +836C 836C EAB8A8 836C +836D 836D EAB8A9 836D +836E 836E EAB8AA 836E +836F 836F EAB8AB 836F +8370 8370 EAB8AC 8370 +8371 8371 EAB8AD 8371 +8372 8372 EAB8AE 8372 +8373 8373 EAB8AF 8373 +8374 8374 EAB8B2 8374 +8375 8375 EAB8B3 8375 +8376 8376 EAB8B5 8376 +8377 8377 EAB8B6 8377 +8378 8378 EAB8B9 8378 +8379 8379 EAB8BB 8379 +837A 837A EAB8BC 837A +8381 8381 EAB8BD 8381 +8382 8382 EAB8BE 8382 +8383 8383 EAB8BF 8383 +8384 8384 EAB982 8384 +8385 8385 EAB984 8385 +8386 8386 EAB987 8386 +8387 8387 EAB988 8387 +8388 8388 EAB989 8388 +8389 8389 EAB98B 8389 +838A 838A EAB98F 838A +838B 838B EAB991 838B +838C 838C EAB992 838C +838D 838D EAB993 838D +838E 838E EAB995 838E +838F 838F EAB997 838F +8390 8390 EAB998 8390 +8391 8391 EAB999 8391 +8392 8392 EAB99A 8392 +8393 8393 EAB99B 8393 +8394 8394 EAB99E 8394 +8395 8395 EAB9A2 8395 +8396 8396 EAB9A3 8396 +8397 8397 EAB9A4 8397 +8398 8398 EAB9A6 8398 +8399 8399 EAB9A7 8399 +839A 839A EAB9AA 839A +839B 839B EAB9AB 839B +839C 839C EAB9AD 839C +839D 839D EAB9AE 839D +839E 839E EAB9AF 839E +839F 839F EAB9B1 839F +83A0 83A0 EAB9B2 83A0 +83A1 83A1 EAB9B3 83A1 +83A2 83A2 EAB9B4 83A2 +83A3 83A3 EAB9B5 83A3 +83A4 83A4 EAB9B6 83A4 +83A5 83A5 EAB9B7 83A5 +83A6 83A6 EAB9BA 83A6 +83A7 83A7 EAB9BE 83A7 +83A8 83A8 EAB9BF 83A8 +83A9 83A9 EABA80 83A9 +83AA 83AA EABA81 83AA +83AB 83AB EABA82 83AB +83AC 83AC EABA83 83AC +83AD 83AD EABA86 83AD +83AE 83AE EABA87 83AE +83AF 83AF EABA88 83AF +83B0 83B0 EABA89 83B0 +83B1 83B1 EABA8A 83B1 +83B2 83B2 EABA8B 83B2 +83B3 83B3 EABA8D 83B3 +83B4 83B4 EABA8E 83B4 +83B5 83B5 EABA8F 83B5 +83B6 83B6 EABA90 83B6 +83B7 83B7 EABA91 83B7 +83B8 83B8 EABA92 83B8 +83B9 83B9 EABA93 83B9 +83BA 83BA EABA94 83BA +83BB 83BB EABA95 83BB +83BC 83BC EABA96 83BC +83BD 83BD EABA97 83BD +83BE 83BE EABA98 83BE +83BF 83BF EABA99 83BF +83C0 83C0 EABA9A 83C0 +83C1 83C1 EABA9B 83C1 +83C2 83C2 EABA9C 83C2 +83C3 83C3 EABA9D 83C3 +83C4 83C4 EABA9E 83C4 +83C5 83C5 EABA9F 83C5 +83C6 83C6 EABAA0 83C6 +83C7 83C7 EABAA1 83C7 +83C8 83C8 EABAA2 83C8 +83C9 83C9 EABAA3 83C9 +83CA 83CA EABAA4 83CA +83CB 83CB EABAA5 83CB +83CC 83CC EABAA6 83CC +83CD 83CD EABAA7 83CD +83CE 83CE EABAA8 83CE +83CF 83CF EABAA9 83CF +83D0 83D0 EABAAA 83D0 +83D1 83D1 EABAAB 83D1 +83D2 83D2 EABAAC 83D2 +83D3 83D3 EABAAD 83D3 +83D4 83D4 EABAAE 83D4 +83D5 83D5 EABAAF 83D5 +83D6 83D6 EABAB0 83D6 +83D7 83D7 EABAB1 83D7 +83D8 83D8 EABAB2 83D8 +83D9 83D9 EABAB3 83D9 +83DA 83DA EABAB4 83DA +83DB 83DB EABAB5 83DB +83DC 83DC EABAB6 83DC +83DD 83DD EABAB7 83DD +83DE 83DE EABAB8 83DE +83DF 83DF EABAB9 83DF +83E0 83E0 EABABA 83E0 +83E1 83E1 EABABB 83E1 +83E2 83E2 EABABF 83E2 +83E3 83E3 EABB81 83E3 +83E4 83E4 EABB82 83E4 +83E5 83E5 EABB83 83E5 +83E6 83E6 EABB85 83E6 +83E7 83E7 EABB86 83E7 +83E8 83E8 EABB87 83E8 +83E9 83E9 EABB88 83E9 +83EA 83EA EABB89 83EA +83EB 83EB EABB8A 83EB +83EC 83EC EABB8B 83EC +83ED 83ED EABB8E 83ED +83EE 83EE EABB92 83EE +83EF 83EF EABB93 83EF +83F0 83F0 EABB94 83F0 +83F1 83F1 EABB95 83F1 +83F2 83F2 EABB96 83F2 +83F3 83F3 EABB97 83F3 +83F4 83F4 EABB9A 83F4 +83F5 83F5 EABB9B 83F5 +83F6 83F6 EABB9D 83F6 +83F7 83F7 EABB9E 83F7 +83F8 83F8 EABB9F 83F8 +83F9 83F9 EABBA0 83F9 +83FA 83FA EABBA1 83FA +83FB 83FB EABBA2 83FB +83FC 83FC EABBA3 83FC +83FD 83FD EABBA4 83FD +83FE 83FE EABBA5 83FE +8441 8441 EABBA6 8441 +8442 8442 EABBA7 8442 +8443 8443 EABBA9 8443 +8444 8444 EABBAA 8444 +8445 8445 EABBAC 8445 +8446 8446 EABBAE 8446 +8447 8447 EABBAF 8447 +8448 8448 EABBB0 8448 +8449 8449 EABBB1 8449 +844A 844A EABBB2 844A +844B 844B EABBB3 844B +844C 844C EABBB5 844C +844D 844D EABBB6 844D +844E 844E EABBB7 844E +844F 844F EABBB9 844F +8450 8450 EABBBA 8450 +8451 8451 EABBBB 8451 +8452 8452 EABBBD 8452 +8453 8453 EABBBE 8453 +8454 8454 EABBBF 8454 +8455 8455 EABC80 8455 +8456 8456 EABC81 8456 +8457 8457 EABC82 8457 +8458 8458 EABC83 8458 +8459 8459 EABC84 8459 +845A 845A EABC85 845A +8461 8461 EABC86 8461 +8462 8462 EABC89 8462 +8463 8463 EABC8A 8463 +8464 8464 EABC8B 8464 +8465 8465 EABC8C 8465 +8466 8466 EABC8E 8466 +8467 8467 EABC8F 8467 +8468 8468 EABC91 8468 +8469 8469 EABC92 8469 +846A 846A EABC93 846A +846B 846B EABC94 846B +846C 846C EABC95 846C +846D 846D EABC96 846D +846E 846E EABC97 846E +846F 846F EABC98 846F +8470 8470 EABC99 8470 +8471 8471 EABC9A 8471 +8472 8472 EABC9B 8472 +8473 8473 EABC9C 8473 +8474 8474 EABC9D 8474 +8475 8475 EABC9E 8475 +8476 8476 EABC9F 8476 +8477 8477 EABCA0 8477 +8478 8478 EABCA1 8478 +8479 8479 EABCA2 8479 +847A 847A EABCA3 847A +8481 8481 EABCA4 8481 +8482 8482 EABCA5 8482 +8483 8483 EABCA6 8483 +8484 8484 EABCA7 8484 +8485 8485 EABCA8 8485 +8486 8486 EABCA9 8486 +8487 8487 EABCAA 8487 +8488 8488 EABCAB 8488 +8489 8489 EABCAE 8489 +848A 848A EABCAF 848A +848B 848B EABCB1 848B +848C 848C EABCB3 848C +848D 848D EABCB5 848D +848E 848E EABCB6 848E +848F 848F EABCB7 848F +8490 8490 EABCB8 8490 +8491 8491 EABCB9 8491 +8492 8492 EABCBA 8492 +8493 8493 EABCBB 8493 +8494 8494 EABCBE 8494 +8495 8495 EABD80 8495 +8496 8496 EABD84 8496 +8497 8497 EABD85 8497 +8498 8498 EABD86 8498 +8499 8499 EABD87 8499 +849A 849A EABD8A 849A +849B 849B EABD8B 849B +849C 849C EABD8C 849C +849D 849D EABD8D 849D +849E 849E EABD8E 849E +849F 849F EABD8F 849F +84A0 84A0 EABD91 84A0 +84A1 84A1 EABD92 84A1 +84A2 84A2 EABD93 84A2 +84A3 84A3 EABD94 84A3 +84A4 84A4 EABD95 84A4 +84A5 84A5 EABD96 84A5 +84A6 84A6 EABD97 84A6 +84A7 84A7 EABD98 84A7 +84A8 84A8 EABD99 84A8 +84A9 84A9 EABD9A 84A9 +84AA 84AA EABD9B 84AA +84AB 84AB EABD9E 84AB +84AC 84AC EABD9F 84AC +84AD 84AD EABDA0 84AD +84AE 84AE EABDA1 84AE +84AF 84AF EABDA2 84AF +84B0 84B0 EABDA3 84B0 +84B1 84B1 EABDA6 84B1 +84B2 84B2 EABDA7 84B2 +84B3 84B3 EABDA8 84B3 +84B4 84B4 EABDA9 84B4 +84B5 84B5 EABDAA 84B5 +84B6 84B6 EABDAB 84B6 +84B7 84B7 EABDAC 84B7 +84B8 84B8 EABDAD 84B8 +84B9 84B9 EABDAE 84B9 +84BA 84BA EABDAF 84BA +84BB 84BB EABDB0 84BB +84BC 84BC EABDB1 84BC +84BD 84BD EABDB2 84BD +84BE 84BE EABDB3 84BE +84BF 84BF EABDB4 84BF +84C0 84C0 EABDB5 84C0 +84C1 84C1 EABDB6 84C1 +84C2 84C2 EABDB7 84C2 +84C3 84C3 EABDB8 84C3 +84C4 84C4 EABDBA 84C4 +84C5 84C5 EABDBB 84C5 +84C6 84C6 EABDBC 84C6 +84C7 84C7 EABDBD 84C7 +84C8 84C8 EABDBE 84C8 +84C9 84C9 EABDBF 84C9 +84CA 84CA EABE81 84CA +84CB 84CB EABE82 84CB +84CC 84CC EABE83 84CC +84CD 84CD EABE85 84CD +84CE 84CE EABE86 84CE +84CF 84CF EABE87 84CF +84D0 84D0 EABE89 84D0 +84D1 84D1 EABE8A 84D1 +84D2 84D2 EABE8B 84D2 +84D3 84D3 EABE8C 84D3 +84D4 84D4 EABE8D 84D4 +84D5 84D5 EABE8E 84D5 +84D6 84D6 EABE8F 84D6 +84D7 84D7 EABE92 84D7 +84D8 84D8 EABE93 84D8 +84D9 84D9 EABE94 84D9 +84DA 84DA EABE96 84DA +84DB 84DB EABE97 84DB +84DC 84DC EABE98 84DC +84DD 84DD EABE99 84DD +84DE 84DE EABE9A 84DE +84DF 84DF EABE9B 84DF +84E0 84E0 EABE9D 84E0 +84E1 84E1 EABE9E 84E1 +84E2 84E2 EABE9F 84E2 +84E3 84E3 EABEA0 84E3 +84E4 84E4 EABEA1 84E4 +84E5 84E5 EABEA2 84E5 +84E6 84E6 EABEA3 84E6 +84E7 84E7 EABEA4 84E7 +84E8 84E8 EABEA5 84E8 +84E9 84E9 EABEA6 84E9 +84EA 84EA EABEA7 84EA +84EB 84EB EABEA8 84EB +84EC 84EC EABEA9 84EC +84ED 84ED EABEAA 84ED +84EE 84EE EABEAB 84EE +84EF 84EF EABEAC 84EF +84F0 84F0 EABEAD 84F0 +84F1 84F1 EABEAE 84F1 +84F2 84F2 EABEAF 84F2 +84F3 84F3 EABEB0 84F3 +84F4 84F4 EABEB1 84F4 +84F5 84F5 EABEB2 84F5 +84F6 84F6 EABEB3 84F6 +84F7 84F7 EABEB4 84F7 +84F8 84F8 EABEB5 84F8 +84F9 84F9 EABEB6 84F9 +84FA 84FA EABEB7 84FA +84FB 84FB EABEBA 84FB +84FC 84FC EABEBB 84FC +84FD 84FD EABEBD 84FD +84FE 84FE EABEBE 84FE +8541 8541 EABEBF 8541 +8542 8542 EABF81 8542 +8543 8543 EABF82 8543 +8544 8544 EABF83 8544 +8545 8545 EABF84 8545 +8546 8546 EABF85 8546 +8547 8547 EABF86 8547 +8548 8548 EABF8A 8548 +8549 8549 EABF8C 8549 +854A 854A EABF8F 854A +854B 854B EABF90 854B +854C 854C EABF91 854C +854D 854D EABF92 854D +854E 854E EABF93 854E +854F 854F EABF95 854F +8550 8550 EABF96 8550 +8551 8551 EABF97 8551 +8552 8552 EABF98 8552 +8553 8553 EABF99 8553 +8554 8554 EABF9A 8554 +8555 8555 EABF9B 8555 +8556 8556 EABF9D 8556 +8557 8557 EABF9E 8557 +8558 8558 EABF9F 8558 +8559 8559 EABFA0 8559 +855A 855A EABFA1 855A +8561 8561 EABFA2 8561 +8562 8562 EABFA3 8562 +8563 8563 EABFA4 8563 +8564 8564 EABFA5 8564 +8565 8565 EABFA6 8565 +8566 8566 EABFA7 8566 +8567 8567 EABFAA 8567 +8568 8568 EABFAB 8568 +8569 8569 EABFAC 8569 +856A 856A EABFAD 856A +856B 856B EABFAE 856B +856C 856C EABFAF 856C +856D 856D EABFB2 856D +856E 856E EABFB3 856E +856F 856F EABFB5 856F +8570 8570 EABFB6 8570 +8571 8571 EABFB7 8571 +8572 8572 EABFB9 8572 +8573 8573 EABFBA 8573 +8574 8574 EABFBB 8574 +8575 8575 EABFBC 8575 +8576 8576 EABFBD 8576 +8577 8577 EABFBE 8577 +8578 8578 EABFBF 8578 +8579 8579 EB8082 8579 +857A 857A EB8083 857A +8581 8581 EB8085 8581 +8582 8582 EB8086 8582 +8583 8583 EB8087 8583 +8584 8584 EB8088 8584 +8585 8585 EB8089 8585 +8586 8586 EB808A 8586 +8587 8587 EB808B 8587 +8588 8588 EB808D 8588 +8589 8589 EB808E 8589 +858A 858A EB808F 858A +858B 858B EB8091 858B +858C 858C EB8092 858C +858D 858D EB8093 858D +858E 858E EB8095 858E +858F 858F EB8096 858F +8590 8590 EB8097 8590 +8591 8591 EB8098 8591 +8592 8592 EB8099 8592 +8593 8593 EB809A 8593 +8594 8594 EB809B 8594 +8595 8595 EB809E 8595 +8596 8596 EB809F 8596 +8597 8597 EB80A0 8597 +8598 8598 EB80A1 8598 +8599 8599 EB80A2 8599 +859A 859A EB80A3 859A +859B 859B EB80A4 859B +859C 859C EB80A5 859C +859D 859D EB80A6 859D +859E 859E EB80A7 859E +859F 859F EB80A9 859F +85A0 85A0 EB80AA 85A0 +85A1 85A1 EB80AB 85A1 +85A2 85A2 EB80AC 85A2 +85A3 85A3 EB80AD 85A3 +85A4 85A4 EB80AE 85A4 +85A5 85A5 EB80AF 85A5 +85A6 85A6 EB80B0 85A6 +85A7 85A7 EB80B1 85A7 +85A8 85A8 EB80B2 85A8 +85A9 85A9 EB80B3 85A9 +85AA 85AA EB80B4 85AA +85AB 85AB EB80B5 85AB +85AC 85AC EB80B6 85AC +85AD 85AD EB80B7 85AD +85AE 85AE EB80B8 85AE +85AF 85AF EB80B9 85AF +85B0 85B0 EB80BA 85B0 +85B1 85B1 EB80BB 85B1 +85B2 85B2 EB80BC 85B2 +85B3 85B3 EB80BD 85B3 +85B4 85B4 EB80BE 85B4 +85B5 85B5 EB80BF 85B5 +85B6 85B6 EB8180 85B6 +85B7 85B7 EB8181 85B7 +85B8 85B8 EB8182 85B8 +85B9 85B9 EB8183 85B9 +85BA 85BA EB8186 85BA +85BB 85BB EB8187 85BB +85BC 85BC EB8189 85BC +85BD 85BD EB818B 85BD +85BE 85BE EB818D 85BE +85BF 85BF EB818F 85BF +85C0 85C0 EB8190 85C0 +85C1 85C1 EB8191 85C1 +85C2 85C2 EB8192 85C2 +85C3 85C3 EB8196 85C3 +85C4 85C4 EB8198 85C4 +85C5 85C5 EB819A 85C5 +85C6 85C6 EB819B 85C6 +85C7 85C7 EB819C 85C7 +85C8 85C8 EB819E 85C8 +85C9 85C9 EB819F 85C9 +85CA 85CA EB81A0 85CA +85CB 85CB EB81A1 85CB +85CC 85CC EB81A2 85CC +85CD 85CD EB81A3 85CD +85CE 85CE EB81A4 85CE +85CF 85CF EB81A5 85CF +85D0 85D0 EB81A6 85D0 +85D1 85D1 EB81A7 85D1 +85D2 85D2 EB81A8 85D2 +85D3 85D3 EB81A9 85D3 +85D4 85D4 EB81AA 85D4 +85D5 85D5 EB81AB 85D5 +85D6 85D6 EB81AC 85D6 +85D7 85D7 EB81AD 85D7 +85D8 85D8 EB81AE 85D8 +85D9 85D9 EB81AF 85D9 +85DA 85DA EB81B0 85DA +85DB 85DB EB81B1 85DB +85DC 85DC EB81B2 85DC +85DD 85DD EB81B3 85DD +85DE 85DE EB81B4 85DE +85DF 85DF EB81B5 85DF +85E0 85E0 EB81B6 85E0 +85E1 85E1 EB81B7 85E1 +85E2 85E2 EB81B8 85E2 +85E3 85E3 EB81B9 85E3 +85E4 85E4 EB81BA 85E4 +85E5 85E5 EB81BB 85E5 +85E6 85E6 EB81BE 85E6 +85E7 85E7 EB81BF 85E7 +85E8 85E8 EB8281 85E8 +85E9 85E9 EB8282 85E9 +85EA 85EA EB8283 85EA +85EB 85EB EB8285 85EB +85EC 85EC EB8286 85EC +85ED 85ED EB8287 85ED +85EE 85EE EB8288 85EE +85EF 85EF EB8289 85EF +85F0 85F0 EB828A 85F0 +85F1 85F1 EB828B 85F1 +85F2 85F2 EB828E 85F2 +85F3 85F3 EB8290 85F3 +85F4 85F4 EB8292 85F4 +85F5 85F5 EB8293 85F5 +85F6 85F6 EB8294 85F6 +85F7 85F7 EB8295 85F7 +85F8 85F8 EB8296 85F8 +85F9 85F9 EB8297 85F9 +85FA 85FA EB829B 85FA +85FB 85FB EB829D 85FB +85FC 85FC EB829E 85FC +85FD 85FD EB82A3 85FD +85FE 85FE EB82A4 85FE +8641 8641 EB82A5 8641 +8642 8642 EB82A6 8642 +8643 8643 EB82A7 8643 +8644 8644 EB82AA 8644 +8645 8645 EB82B0 8645 +8646 8646 EB82B2 8646 +8647 8647 EB82B6 8647 +8648 8648 EB82B7 8648 +8649 8649 EB82B9 8649 +864A 864A EB82BA 864A +864B 864B EB82BB 864B +864C 864C EB82BD 864C +864D 864D EB82BE 864D +864E 864E EB82BF 864E +864F 864F EB8380 864F +8650 8650 EB8381 8650 +8651 8651 EB8382 8651 +8652 8652 EB8383 8652 +8653 8653 EB8386 8653 +8654 8654 EB838A 8654 +8655 8655 EB838B 8655 +8656 8656 EB838C 8656 +8657 8657 EB838D 8657 +8658 8658 EB838E 8658 +8659 8659 EB838F 8659 +865A 865A EB8392 865A +8661 8661 EB8393 8661 +8662 8662 EB8395 8662 +8663 8663 EB8396 8663 +8664 8664 EB8397 8664 +8665 8665 EB8399 8665 +8666 8666 EB839A 8666 +8667 8667 EB839B 8667 +8668 8668 EB839C 8668 +8669 8669 EB839D 8669 +866A 866A EB839E 866A +866B 866B EB839F 866B +866C 866C EB83A1 866C +866D 866D EB83A2 866D +866E 866E EB83A3 866E +866F 866F EB83A4 866F +8670 8670 EB83A6 8670 +8671 8671 EB83A7 8671 +8672 8672 EB83A8 8672 +8673 8673 EB83A9 8673 +8674 8674 EB83AA 8674 +8675 8675 EB83AB 8675 +8676 8676 EB83AC 8676 +8677 8677 EB83AD 8677 +8678 8678 EB83AE 8678 +8679 8679 EB83AF 8679 +867A 867A EB83B0 867A +8681 8681 EB83B1 8681 +8682 8682 EB83B2 8682 +8683 8683 EB83B3 8683 +8684 8684 EB83B4 8684 +8685 8685 EB83B5 8685 +8686 8686 EB83B6 8686 +8687 8687 EB83B7 8687 +8688 8688 EB83B8 8688 +8689 8689 EB83B9 8689 +868A 868A EB83BA 868A +868B 868B EB83BB 868B +868C 868C EB83BC 868C +868D 868D EB83BD 868D +868E 868E EB83BE 868E +868F 868F EB83BF 868F +8690 8690 EB8480 8690 +8691 8691 EB8481 8691 +8692 8692 EB8482 8692 +8693 8693 EB8483 8693 +8694 8694 EB8484 8694 +8695 8695 EB8485 8695 +8696 8696 EB8486 8696 +8697 8697 EB8487 8697 +8698 8698 EB848A 8698 +8699 8699 EB848D 8699 +869A 869A EB848E 869A +869B 869B EB848F 869B +869C 869C EB8491 869C +869D 869D EB8494 869D +869E 869E EB8495 869E +869F 869F EB8496 869F +86A0 86A0 EB8497 86A0 +86A1 86A1 EB849A 86A1 +86A2 86A2 EB849E 86A2 +86A3 86A3 EB849F 86A3 +86A4 86A4 EB84A0 86A4 +86A5 86A5 EB84A1 86A5 +86A6 86A6 EB84A2 86A6 +86A7 86A7 EB84A6 86A7 +86A8 86A8 EB84A7 86A8 +86A9 86A9 EB84A9 86A9 +86AA 86AA EB84AA 86AA +86AB 86AB EB84AB 86AB +86AC 86AC EB84AD 86AC +86AD 86AD EB84AE 86AD +86AE 86AE EB84AF 86AE +86AF 86AF EB84B0 86AF +86B0 86B0 EB84B1 86B0 +86B1 86B1 EB84B2 86B1 +86B2 86B2 EB84B3 86B2 +86B3 86B3 EB84B6 86B3 +86B4 86B4 EB84BA 86B4 +86B5 86B5 EB84BB 86B5 +86B6 86B6 EB84BC 86B6 +86B7 86B7 EB84BD 86B7 +86B8 86B8 EB84BE 86B8 +86B9 86B9 EB84BF 86B9 +86BA 86BA EB8582 86BA +86BB 86BB EB8583 86BB +86BC 86BC EB8585 86BC +86BD 86BD EB8586 86BD +86BE 86BE EB8587 86BE +86BF 86BF EB8589 86BF +86C0 86C0 EB858A 86C0 +86C1 86C1 EB858B 86C1 +86C2 86C2 EB858C 86C2 +86C3 86C3 EB858D 86C3 +86C4 86C4 EB858E 86C4 +86C5 86C5 EB858F 86C5 +86C6 86C6 EB8592 86C6 +86C7 86C7 EB8593 86C7 +86C8 86C8 EB8596 86C8 +86C9 86C9 EB8597 86C9 +86CA 86CA EB8599 86CA +86CB 86CB EB859A 86CB +86CC 86CC EB859B 86CC +86CD 86CD EB859D 86CD +86CE 86CE EB859E 86CE +86CF 86CF EB859F 86CF +86D0 86D0 EB85A1 86D0 +86D1 86D1 EB85A2 86D1 +86D2 86D2 EB85A3 86D2 +86D3 86D3 EB85A4 86D3 +86D4 86D4 EB85A5 86D4 +86D5 86D5 EB85A6 86D5 +86D6 86D6 EB85A7 86D6 +86D7 86D7 EB85A8 86D7 +86D8 86D8 EB85A9 86D8 +86D9 86D9 EB85AA 86D9 +86DA 86DA EB85AB 86DA +86DB 86DB EB85AC 86DB +86DC 86DC EB85AD 86DC +86DD 86DD EB85AE 86DD +86DE 86DE EB85AF 86DE +86DF 86DF EB85B0 86DF +86E0 86E0 EB85B1 86E0 +86E1 86E1 EB85B2 86E1 +86E2 86E2 EB85B3 86E2 +86E3 86E3 EB85B4 86E3 +86E4 86E4 EB85B5 86E4 +86E5 86E5 EB85B6 86E5 +86E6 86E6 EB85B7 86E6 +86E7 86E7 EB85BA 86E7 +86E8 86E8 EB85BB 86E8 +86E9 86E9 EB85BD 86E9 +86EA 86EA EB85BE 86EA +86EB 86EB EB85BF 86EB +86EC 86EC EB8681 86EC +86ED 86ED EB8683 86ED +86EE 86EE EB8684 86EE +86EF 86EF EB8685 86EF +86F0 86F0 EB8686 86F0 +86F1 86F1 EB8687 86F1 +86F2 86F2 EB868A 86F2 +86F3 86F3 EB868C 86F3 +86F4 86F4 EB868E 86F4 +86F5 86F5 EB868F 86F5 +86F6 86F6 EB8690 86F6 +86F7 86F7 EB8691 86F7 +86F8 86F8 EB8695 86F8 +86F9 86F9 EB8696 86F9 +86FA 86FA EB8697 86FA +86FB 86FB EB8699 86FB +86FC 86FC EB869A 86FC +86FD 86FD EB869B 86FD +86FE 86FE EB869D 86FE +8741 8741 EB869E 8741 +8742 8742 EB869F 8742 +8743 8743 EB86A0 8743 +8744 8744 EB86A1 8744 +8745 8745 EB86A2 8745 +8746 8746 EB86A3 8746 +8747 8747 EB86A4 8747 +8748 8748 EB86A5 8748 +8749 8749 EB86A6 8749 +874A 874A EB86A7 874A +874B 874B EB86A9 874B +874C 874C EB86AA 874C +874D 874D EB86AB 874D +874E 874E EB86AC 874E +874F 874F EB86AD 874F +8750 8750 EB86AE 8750 +8751 8751 EB86AF 8751 +8752 8752 EB86B0 8752 +8753 8753 EB86B1 8753 +8754 8754 EB86B2 8754 +8755 8755 EB86B3 8755 +8756 8756 EB86B4 8756 +8757 8757 EB86B5 8757 +8758 8758 EB86B6 8758 +8759 8759 EB86B7 8759 +875A 875A EB86B8 875A +8761 8761 EB86B9 8761 +8762 8762 EB86BA 8762 +8763 8763 EB86BB 8763 +8764 8764 EB86BC 8764 +8765 8765 EB86BD 8765 +8766 8766 EB86BE 8766 +8767 8767 EB86BF 8767 +8768 8768 EB8780 8768 +8769 8769 EB8781 8769 +876A 876A EB8782 876A +876B 876B EB8783 876B +876C 876C EB8784 876C +876D 876D EB8785 876D +876E 876E EB8786 876E +876F 876F EB8787 876F +8770 8770 EB8788 8770 +8771 8771 EB8789 8771 +8772 8772 EB878A 8772 +8773 8773 EB878B 8773 +8774 8774 EB878D 8774 +8775 8775 EB878E 8775 +8776 8776 EB878F 8776 +8777 8777 EB8791 8777 +8778 8778 EB8792 8778 +8779 8779 EB8793 8779 +877A 877A EB8795 877A +8781 8781 EB8796 8781 +8782 8782 EB8797 8782 +8783 8783 EB8798 8783 +8784 8784 EB8799 8784 +8785 8785 EB879A 8785 +8786 8786 EB879B 8786 +8787 8787 EB879E 8787 +8788 8788 EB87A0 8788 +8789 8789 EB87A1 8789 +878A 878A EB87A2 878A +878B 878B EB87A3 878B +878C 878C EB87A4 878C +878D 878D EB87A5 878D +878E 878E EB87A6 878E +878F 878F EB87A7 878F +8790 8790 EB87AA 8790 +8791 8791 EB87AB 8791 +8792 8792 EB87AD 8792 +8793 8793 EB87AE 8793 +8794 8794 EB87AF 8794 +8795 8795 EB87B1 8795 +8796 8796 EB87B2 8796 +8797 8797 EB87B3 8797 +8798 8798 EB87B4 8798 +8799 8799 EB87B5 8799 +879A 879A EB87B6 879A +879B 879B EB87B7 879B +879C 879C EB87B8 879C +879D 879D EB87BA 879D +879E 879E EB87BC 879E +879F 879F EB87BE 879F +87A0 87A0 EB87BF 87A0 +87A1 87A1 EB8880 87A1 +87A2 87A2 EB8881 87A2 +87A3 87A3 EB8882 87A3 +87A4 87A4 EB8883 87A4 +87A5 87A5 EB8886 87A5 +87A6 87A6 EB8887 87A6 +87A7 87A7 EB8889 87A7 +87A8 87A8 EB888A 87A8 +87A9 87A9 EB888D 87A9 +87AA 87AA EB888E 87AA +87AB 87AB EB888F 87AB +87AC 87AC EB8890 87AC +87AD 87AD EB8891 87AD +87AE 87AE EB8892 87AE +87AF 87AF EB8893 87AF +87B0 87B0 EB8896 87B0 +87B1 87B1 EB8898 87B1 +87B2 87B2 EB889A 87B2 +87B3 87B3 EB889B 87B3 +87B4 87B4 EB889C 87B4 +87B5 87B5 EB889D 87B5 +87B6 87B6 EB889E 87B6 +87B7 87B7 EB889F 87B7 +87B8 87B8 EB88A1 87B8 +87B9 87B9 EB88A2 87B9 +87BA 87BA EB88A3 87BA +87BB 87BB EB88A4 87BB +87BC 87BC EB88A5 87BC +87BD 87BD EB88A6 87BD +87BE 87BE EB88A7 87BE +87BF 87BF EB88A8 87BF +87C0 87C0 EB88A9 87C0 +87C1 87C1 EB88AA 87C1 +87C2 87C2 EB88AB 87C2 +87C3 87C3 EB88AC 87C3 +87C4 87C4 EB88AD 87C4 +87C5 87C5 EB88AE 87C5 +87C6 87C6 EB88AF 87C6 +87C7 87C7 EB88B0 87C7 +87C8 87C8 EB88B1 87C8 +87C9 87C9 EB88B2 87C9 +87CA 87CA EB88B3 87CA +87CB 87CB EB88B5 87CB +87CC 87CC EB88B6 87CC +87CD 87CD EB88B7 87CD +87CE 87CE EB88B8 87CE +87CF 87CF EB88B9 87CF +87D0 87D0 EB88BA 87D0 +87D1 87D1 EB88BB 87D1 +87D2 87D2 EB88BD 87D2 +87D3 87D3 EB88BE 87D3 +87D4 87D4 EB88BF 87D4 +87D5 87D5 EB8980 87D5 +87D6 87D6 EB8981 87D6 +87D7 87D7 EB8982 87D7 +87D8 87D8 EB8983 87D8 +87D9 87D9 EB8984 87D9 +87DA 87DA EB8985 87DA +87DB 87DB EB8986 87DB +87DC 87DC EB8987 87DC +87DD 87DD EB8988 87DD +87DE 87DE EB8989 87DE +87DF 87DF EB898A 87DF +87E0 87E0 EB898B 87E0 +87E1 87E1 EB898C 87E1 +87E2 87E2 EB898D 87E2 +87E3 87E3 EB898E 87E3 +87E4 87E4 EB898F 87E4 +87E5 87E5 EB8990 87E5 +87E6 87E6 EB8991 87E6 +87E7 87E7 EB8992 87E7 +87E8 87E8 EB8993 87E8 +87E9 87E9 EB8994 87E9 +87EA 87EA EB8995 87EA +87EB 87EB EB8996 87EB +87EC 87EC EB8997 87EC +87ED 87ED EB8999 87ED +87EE 87EE EB899A 87EE +87EF 87EF EB899B 87EF +87F0 87F0 EB899D 87F0 +87F1 87F1 EB899E 87F1 +87F2 87F2 EB899F 87F2 +87F3 87F3 EB89A1 87F3 +87F4 87F4 EB89A2 87F4 +87F5 87F5 EB89A3 87F5 +87F6 87F6 EB89A4 87F6 +87F7 87F7 EB89A5 87F7 +87F8 87F8 EB89A6 87F8 +87F9 87F9 EB89A7 87F9 +87FA 87FA EB89AA 87FA +87FB 87FB EB89AB 87FB +87FC 87FC EB89AC 87FC +87FD 87FD EB89AD 87FD +87FE 87FE EB89AE 87FE +8841 8841 EB89AF 8841 +8842 8842 EB89B0 8842 +8843 8843 EB89B1 8843 +8844 8844 EB89B2 8844 +8845 8845 EB89B3 8845 +8846 8846 EB89B6 8846 +8847 8847 EB89B7 8847 +8848 8848 EB89B8 8848 +8849 8849 EB89B9 8849 +884A 884A EB89BA 884A +884B 884B EB89BB 884B +884C 884C EB89BD 884C +884D 884D EB89BE 884D +884E 884E EB89BF 884E +884F 884F EB8A80 884F +8850 8850 EB8A81 8850 +8851 8851 EB8A82 8851 +8852 8852 EB8A83 8852 +8853 8853 EB8A86 8853 +8854 8854 EB8A87 8854 +8855 8855 EB8A88 8855 +8856 8856 EB8A8A 8856 +8857 8857 EB8A8B 8857 +8858 8858 EB8A8C 8858 +8859 8859 EB8A8D 8859 +885A 885A EB8A8E 885A +8861 8861 EB8A8F 8861 +8862 8862 EB8A92 8862 +8863 8863 EB8A93 8863 +8864 8864 EB8A95 8864 +8865 8865 EB8A96 8865 +8866 8866 EB8A97 8866 +8867 8867 EB8A9B 8867 +8868 8868 EB8A9C 8868 +8869 8869 EB8A9D 8869 +886A 886A EB8A9E 886A +886B 886B EB8A9F 886B +886C 886C EB8AA2 886C +886D 886D EB8AA4 886D +886E 886E EB8AA7 886E +886F 886F EB8AA8 886F +8870 8870 EB8AA9 8870 +8871 8871 EB8AAB 8871 +8872 8872 EB8AAD 8872 +8873 8873 EB8AAE 8873 +8874 8874 EB8AAF 8874 +8875 8875 EB8AB1 8875 +8876 8876 EB8AB2 8876 +8877 8877 EB8AB3 8877 +8878 8878 EB8AB5 8878 +8879 8879 EB8AB6 8879 +887A 887A EB8AB7 887A +8881 8881 EB8AB8 8881 +8882 8882 EB8AB9 8882 +8883 8883 EB8ABA 8883 +8884 8884 EB8ABB 8884 +8885 8885 EB8ABC 8885 +8886 8886 EB8ABD 8886 +8887 8887 EB8ABE 8887 +8888 8888 EB8ABF 8888 +8889 8889 EB8B80 8889 +888A 888A EB8B81 888A +888B 888B EB8B82 888B +888C 888C EB8B83 888C +888D 888D EB8B84 888D +888E 888E EB8B85 888E +888F 888F EB8B86 888F +8890 8890 EB8B87 8890 +8891 8891 EB8B8A 8891 +8892 8892 EB8B8B 8892 +8893 8893 EB8B8D 8893 +8894 8894 EB8B8E 8894 +8895 8895 EB8B8F 8895 +8896 8896 EB8B91 8896 +8897 8897 EB8B93 8897 +8898 8898 EB8B94 8898 +8899 8899 EB8B95 8899 +889A 889A EB8B96 889A +889B 889B EB8B97 889B +889C 889C EB8B9A 889C +889D 889D EB8B9C 889D +889E 889E EB8B9E 889E +889F 889F EB8B9F 889F +88A0 88A0 EB8BA0 88A0 +88A1 88A1 EB8BA1 88A1 +88A2 88A2 EB8BA3 88A2 +88A3 88A3 EB8BA7 88A3 +88A4 88A4 EB8BA9 88A4 +88A5 88A5 EB8BAA 88A5 +88A6 88A6 EB8BB0 88A6 +88A7 88A7 EB8BB1 88A7 +88A8 88A8 EB8BB2 88A8 +88A9 88A9 EB8BB6 88A9 +88AA 88AA EB8BBC 88AA +88AB 88AB EB8BBD 88AB +88AC 88AC EB8BBE 88AC +88AD 88AD EB8C82 88AD +88AE 88AE EB8C83 88AE +88AF 88AF EB8C85 88AF +88B0 88B0 EB8C86 88B0 +88B1 88B1 EB8C87 88B1 +88B2 88B2 EB8C89 88B2 +88B3 88B3 EB8C8A 88B3 +88B4 88B4 EB8C8B 88B4 +88B5 88B5 EB8C8C 88B5 +88B6 88B6 EB8C8D 88B6 +88B7 88B7 EB8C8E 88B7 +88B8 88B8 EB8C8F 88B8 +88B9 88B9 EB8C92 88B9 +88BA 88BA EB8C96 88BA +88BB 88BB EB8C97 88BB +88BC 88BC EB8C98 88BC +88BD 88BD EB8C99 88BD +88BE 88BE EB8C9A 88BE +88BF 88BF EB8C9B 88BF +88C0 88C0 EB8C9D 88C0 +88C1 88C1 EB8C9E 88C1 +88C2 88C2 EB8C9F 88C2 +88C3 88C3 EB8CA0 88C3 +88C4 88C4 EB8CA1 88C4 +88C5 88C5 EB8CA2 88C5 +88C6 88C6 EB8CA3 88C6 +88C7 88C7 EB8CA4 88C7 +88C8 88C8 EB8CA5 88C8 +88C9 88C9 EB8CA6 88C9 +88CA 88CA EB8CA7 88CA +88CB 88CB EB8CA8 88CB +88CC 88CC EB8CA9 88CC +88CD 88CD EB8CAA 88CD +88CE 88CE EB8CAB 88CE +88CF 88CF EB8CAC 88CF +88D0 88D0 EB8CAD 88D0 +88D1 88D1 EB8CAE 88D1 +88D2 88D2 EB8CAF 88D2 +88D3 88D3 EB8CB0 88D3 +88D4 88D4 EB8CB1 88D4 +88D5 88D5 EB8CB2 88D5 +88D6 88D6 EB8CB3 88D6 +88D7 88D7 EB8CB4 88D7 +88D8 88D8 EB8CB5 88D8 +88D9 88D9 EB8CB6 88D9 +88DA 88DA EB8CB7 88DA +88DB 88DB EB8CB8 88DB +88DC 88DC EB8CB9 88DC +88DD 88DD EB8CBA 88DD +88DE 88DE EB8CBB 88DE +88DF 88DF EB8CBC 88DF +88E0 88E0 EB8CBD 88E0 +88E1 88E1 EB8CBE 88E1 +88E2 88E2 EB8CBF 88E2 +88E3 88E3 EB8D80 88E3 +88E4 88E4 EB8D81 88E4 +88E5 88E5 EB8D82 88E5 +88E6 88E6 EB8D83 88E6 +88E7 88E7 EB8D84 88E7 +88E8 88E8 EB8D85 88E8 +88E9 88E9 EB8D86 88E9 +88EA 88EA EB8D87 88EA +88EB 88EB EB8D88 88EB +88EC 88EC EB8D89 88EC +88ED 88ED EB8D8A 88ED +88EE 88EE EB8D8B 88EE +88EF 88EF EB8D8C 88EF +88F0 88F0 EB8D8D 88F0 +88F1 88F1 EB8D8E 88F1 +88F2 88F2 EB8D8F 88F2 +88F3 88F3 EB8D90 88F3 +88F4 88F4 EB8D91 88F4 +88F5 88F5 EB8D92 88F5 +88F6 88F6 EB8D93 88F6 +88F7 88F7 EB8D97 88F7 +88F8 88F8 EB8D99 88F8 +88F9 88F9 EB8D9A 88F9 +88FA 88FA EB8D9D 88FA +88FB 88FB EB8DA0 88FB +88FC 88FC EB8DA1 88FC +88FD 88FD EB8DA2 88FD +88FE 88FE EB8DA3 88FE +8941 8941 EB8DA6 8941 +8942 8942 EB8DA8 8942 +8943 8943 EB8DAA 8943 +8944 8944 EB8DAC 8944 +8945 8945 EB8DAD 8945 +8946 8946 EB8DAF 8946 +8947 8947 EB8DB2 8947 +8948 8948 EB8DB3 8948 +8949 8949 EB8DB5 8949 +894A 894A EB8DB6 894A +894B 894B EB8DB7 894B +894C 894C EB8DB9 894C +894D 894D EB8DBA 894D +894E 894E EB8DBB 894E +894F 894F EB8DBC 894F +8950 8950 EB8DBD 8950 +8951 8951 EB8DBE 8951 +8952 8952 EB8DBF 8952 +8953 8953 EB8E82 8953 +8954 8954 EB8E86 8954 +8955 8955 EB8E87 8955 +8956 8956 EB8E88 8956 +8957 8957 EB8E89 8957 +8958 8958 EB8E8A 8958 +8959 8959 EB8E8B 8959 +895A 895A EB8E8D 895A +8961 8961 EB8E8E 8961 +8962 8962 EB8E8F 8962 +8963 8963 EB8E91 8963 +8964 8964 EB8E92 8964 +8965 8965 EB8E93 8965 +8966 8966 EB8E95 8966 +8967 8967 EB8E96 8967 +8968 8968 EB8E97 8968 +8969 8969 EB8E98 8969 +896A 896A EB8E99 896A +896B 896B EB8E9A 896B +896C 896C EB8E9B 896C +896D 896D EB8E9C 896D +896E 896E EB8E9D 896E +896F 896F EB8E9E 896F +8970 8970 EB8E9F 8970 +8971 8971 EB8EA2 8971 +8972 8972 EB8EA3 8972 +8973 8973 EB8EA4 8973 +8974 8974 EB8EA5 8974 +8975 8975 EB8EA6 8975 +8976 8976 EB8EA7 8976 +8977 8977 EB8EA9 8977 +8978 8978 EB8EAA 8978 +8979 8979 EB8EAB 8979 +897A 897A EB8EAD 897A +8981 8981 EB8EAE 8981 +8982 8982 EB8EAF 8982 +8983 8983 EB8EB0 8983 +8984 8984 EB8EB1 8984 +8985 8985 EB8EB2 8985 +8986 8986 EB8EB3 8986 +8987 8987 EB8EB4 8987 +8988 8988 EB8EB5 8988 +8989 8989 EB8EB6 8989 +898A 898A EB8EB7 898A +898B 898B EB8EB8 898B +898C 898C EB8EB9 898C +898D 898D EB8EBA 898D +898E 898E EB8EBB 898E +898F 898F EB8EBC 898F +8990 8990 EB8EBD 8990 +8991 8991 EB8EBE 8991 +8992 8992 EB8EBF 8992 +8993 8993 EB8F80 8993 +8994 8994 EB8F81 8994 +8995 8995 EB8F82 8995 +8996 8996 EB8F83 8996 +8997 8997 EB8F86 8997 +8998 8998 EB8F87 8998 +8999 8999 EB8F89 8999 +899A 899A EB8F8A 899A +899B 899B EB8F8D 899B +899C 899C EB8F8F 899C +899D 899D EB8F91 899D +899E 899E EB8F92 899E +899F 899F EB8F93 899F +89A0 89A0 EB8F96 89A0 +89A1 89A1 EB8F98 89A1 +89A2 89A2 EB8F9A 89A2 +89A3 89A3 EB8F9C 89A3 +89A4 89A4 EB8F9E 89A4 +89A5 89A5 EB8F9F 89A5 +89A6 89A6 EB8FA1 89A6 +89A7 89A7 EB8FA2 89A7 +89A8 89A8 EB8FA3 89A8 +89A9 89A9 EB8FA5 89A9 +89AA 89AA EB8FA6 89AA +89AB 89AB EB8FA7 89AB +89AC 89AC EB8FA9 89AC +89AD 89AD EB8FAA 89AD +89AE 89AE EB8FAB 89AE +89AF 89AF EB8FAC 89AF +89B0 89B0 EB8FAD 89B0 +89B1 89B1 EB8FAE 89B1 +89B2 89B2 EB8FAF 89B2 +89B3 89B3 EB8FB0 89B3 +89B4 89B4 EB8FB1 89B4 +89B5 89B5 EB8FB2 89B5 +89B6 89B6 EB8FB3 89B6 +89B7 89B7 EB8FB4 89B7 +89B8 89B8 EB8FB5 89B8 +89B9 89B9 EB8FB6 89B9 +89BA 89BA EB8FB7 89BA +89BB 89BB EB8FB8 89BB +89BC 89BC EB8FB9 89BC +89BD 89BD EB8FBA 89BD +89BE 89BE EB8FBB 89BE +89BF 89BF EB8FBD 89BF +89C0 89C0 EB8FBE 89C0 +89C1 89C1 EB8FBF 89C1 +89C2 89C2 EB9080 89C2 +89C3 89C3 EB9081 89C3 +89C4 89C4 EB9082 89C4 +89C5 89C5 EB9083 89C5 +89C6 89C6 EB9084 89C6 +89C7 89C7 EB9085 89C7 +89C8 89C8 EB9086 89C8 +89C9 89C9 EB9087 89C9 +89CA 89CA EB9088 89CA +89CB 89CB EB9089 89CB +89CC 89CC EB908A 89CC +89CD 89CD EB908B 89CD +89CE 89CE EB908C 89CE +89CF 89CF EB908D 89CF +89D0 89D0 EB908E 89D0 +89D1 89D1 EB908F 89D1 +89D2 89D2 EB9091 89D2 +89D3 89D3 EB9092 89D3 +89D4 89D4 EB9093 89D4 +89D5 89D5 EB9094 89D5 +89D6 89D6 EB9095 89D6 +89D7 89D7 EB9096 89D7 +89D8 89D8 EB9097 89D8 +89D9 89D9 EB9099 89D9 +89DA 89DA EB909A 89DA +89DB 89DB EB909B 89DB +89DC 89DC EB909D 89DC +89DD 89DD EB909E 89DD +89DE 89DE EB909F 89DE +89DF 89DF EB90A1 89DF +89E0 89E0 EB90A2 89E0 +89E1 89E1 EB90A3 89E1 +89E2 89E2 EB90A4 89E2 +89E3 89E3 EB90A5 89E3 +89E4 89E4 EB90A6 89E4 +89E5 89E5 EB90A7 89E5 +89E6 89E6 EB90AA 89E6 +89E7 89E7 EB90AC 89E7 +89E8 89E8 EB90AD 89E8 +89E9 89E9 EB90AE 89E9 +89EA 89EA EB90AF 89EA +89EB 89EB EB90B0 89EB +89EC 89EC EB90B1 89EC +89ED 89ED EB90B2 89ED +89EE 89EE EB90B3 89EE +89EF 89EF EB90B5 89EF +89F0 89F0 EB90B6 89F0 +89F1 89F1 EB90B7 89F1 +89F2 89F2 EB90B8 89F2 +89F3 89F3 EB90B9 89F3 +89F4 89F4 EB90BA 89F4 +89F5 89F5 EB90BB 89F5 +89F6 89F6 EB90BC 89F6 +89F7 89F7 EB90BD 89F7 +89F8 89F8 EB90BE 89F8 +89F9 89F9 EB90BF 89F9 +89FA 89FA EB9180 89FA +89FB 89FB EB9181 89FB +89FC 89FC EB9182 89FC +89FD 89FD EB9183 89FD +89FE 89FE EB9184 89FE +8A41 8A41 EB9185 8A41 +8A42 8A42 EB9186 8A42 +8A43 8A43 EB9187 8A43 +8A44 8A44 EB9188 8A44 +8A45 8A45 EB9189 8A45 +8A46 8A46 EB918A 8A46 +8A47 8A47 EB918B 8A47 +8A48 8A48 EB918C 8A48 +8A49 8A49 EB918D 8A49 +8A4A 8A4A EB918E 8A4A +8A4B 8A4B EB918F 8A4B +8A4C 8A4C EB9192 8A4C +8A4D 8A4D EB9193 8A4D +8A4E 8A4E EB9195 8A4E +8A4F 8A4F EB9196 8A4F +8A50 8A50 EB9197 8A50 +8A51 8A51 EB9199 8A51 +8A52 8A52 EB919A 8A52 +8A53 8A53 EB919B 8A53 +8A54 8A54 EB919C 8A54 +8A55 8A55 EB919D 8A55 +8A56 8A56 EB919E 8A56 +8A57 8A57 EB919F 8A57 +8A58 8A58 EB91A2 8A58 +8A59 8A59 EB91A4 8A59 +8A5A 8A5A EB91A6 8A5A +8A61 8A61 EB91A7 8A61 +8A62 8A62 EB91A8 8A62 +8A63 8A63 EB91A9 8A63 +8A64 8A64 EB91AA 8A64 +8A65 8A65 EB91AB 8A65 +8A66 8A66 EB91AD 8A66 +8A67 8A67 EB91AE 8A67 +8A68 8A68 EB91AF 8A68 +8A69 8A69 EB91B0 8A69 +8A6A 8A6A EB91B1 8A6A +8A6B 8A6B EB91B2 8A6B +8A6C 8A6C EB91B3 8A6C +8A6D 8A6D EB91B4 8A6D +8A6E 8A6E EB91B5 8A6E +8A6F 8A6F EB91B6 8A6F +8A70 8A70 EB91B7 8A70 +8A71 8A71 EB91B8 8A71 +8A72 8A72 EB91B9 8A72 +8A73 8A73 EB91BA 8A73 +8A74 8A74 EB91BB 8A74 +8A75 8A75 EB91BC 8A75 +8A76 8A76 EB91BD 8A76 +8A77 8A77 EB91BE 8A77 +8A78 8A78 EB91BF 8A78 +8A79 8A79 EB9281 8A79 +8A7A 8A7A EB9282 8A7A +8A81 8A81 EB9283 8A81 +8A82 8A82 EB9284 8A82 +8A83 8A83 EB9285 8A83 +8A84 8A84 EB9286 8A84 +8A85 8A85 EB9287 8A85 +8A86 8A86 EB9289 8A86 +8A87 8A87 EB928A 8A87 +8A88 8A88 EB928B 8A88 +8A89 8A89 EB928C 8A89 +8A8A 8A8A EB928D 8A8A +8A8B 8A8B EB928E 8A8B +8A8C 8A8C EB928F 8A8C +8A8D 8A8D EB9290 8A8D +8A8E 8A8E EB9291 8A8E +8A8F 8A8F EB9292 8A8F +8A90 8A90 EB9293 8A90 +8A91 8A91 EB9294 8A91 +8A92 8A92 EB9295 8A92 +8A93 8A93 EB9296 8A93 +8A94 8A94 EB9297 8A94 +8A95 8A95 EB9298 8A95 +8A96 8A96 EB9299 8A96 +8A97 8A97 EB929A 8A97 +8A98 8A98 EB929B 8A98 +8A99 8A99 EB929C 8A99 +8A9A 8A9A EB929E 8A9A +8A9B 8A9B EB929F 8A9B +8A9C 8A9C EB92A0 8A9C +8A9D 8A9D EB92A1 8A9D +8A9E 8A9E EB92A2 8A9E +8A9F 8A9F EB92A3 8A9F +8AA0 8AA0 EB92A5 8AA0 +8AA1 8AA1 EB92A6 8AA1 +8AA2 8AA2 EB92A7 8AA2 +8AA3 8AA3 EB92A9 8AA3 +8AA4 8AA4 EB92AA 8AA4 +8AA5 8AA5 EB92AB 8AA5 +8AA6 8AA6 EB92AD 8AA6 +8AA7 8AA7 EB92AE 8AA7 +8AA8 8AA8 EB92AF 8AA8 +8AA9 8AA9 EB92B0 8AA9 +8AAA 8AAA EB92B1 8AAA +8AAB 8AAB EB92B2 8AAB +8AAC 8AAC EB92B3 8AAC +8AAD 8AAD EB92B4 8AAD +8AAE 8AAE EB92B6 8AAE +8AAF 8AAF EB92B8 8AAF +8AB0 8AB0 EB92BA 8AB0 +8AB1 8AB1 EB92BB 8AB1 +8AB2 8AB2 EB92BC 8AB2 +8AB3 8AB3 EB92BD 8AB3 +8AB4 8AB4 EB92BE 8AB4 +8AB5 8AB5 EB92BF 8AB5 +8AB6 8AB6 EB9381 8AB6 +8AB7 8AB7 EB9382 8AB7 +8AB8 8AB8 EB9383 8AB8 +8AB9 8AB9 EB9385 8AB9 +8ABA 8ABA EB9386 8ABA +8ABB 8ABB EB9387 8ABB +8ABC 8ABC EB9389 8ABC +8ABD 8ABD EB938A 8ABD +8ABE 8ABE EB938B 8ABE +8ABF 8ABF EB938C 8ABF +8AC0 8AC0 EB938D 8AC0 +8AC1 8AC1 EB938E 8AC1 +8AC2 8AC2 EB938F 8AC2 +8AC3 8AC3 EB9391 8AC3 +8AC4 8AC4 EB9392 8AC4 +8AC5 8AC5 EB9393 8AC5 +8AC6 8AC6 EB9394 8AC6 +8AC7 8AC7 EB9396 8AC7 +8AC8 8AC8 EB9397 8AC8 +8AC9 8AC9 EB9398 8AC9 +8ACA 8ACA EB9399 8ACA +8ACB 8ACB EB939A 8ACB +8ACC 8ACC EB939B 8ACC +8ACD 8ACD EB939E 8ACD +8ACE 8ACE EB939F 8ACE +8ACF 8ACF EB93A1 8ACF +8AD0 8AD0 EB93A2 8AD0 +8AD1 8AD1 EB93A5 8AD1 +8AD2 8AD2 EB93A7 8AD2 +8AD3 8AD3 EB93A8 8AD3 +8AD4 8AD4 EB93A9 8AD4 +8AD5 8AD5 EB93AA 8AD5 +8AD6 8AD6 EB93AB 8AD6 +8AD7 8AD7 EB93AE 8AD7 +8AD8 8AD8 EB93B0 8AD8 +8AD9 8AD9 EB93B2 8AD9 +8ADA 8ADA EB93B3 8ADA +8ADB 8ADB EB93B4 8ADB +8ADC 8ADC EB93B5 8ADC +8ADD 8ADD EB93B6 8ADD +8ADE 8ADE EB93B7 8ADE +8ADF 8ADF EB93B9 8ADF +8AE0 8AE0 EB93BA 8AE0 +8AE1 8AE1 EB93BB 8AE1 +8AE2 8AE2 EB93BC 8AE2 +8AE3 8AE3 EB93BD 8AE3 +8AE4 8AE4 EB93BE 8AE4 +8AE5 8AE5 EB93BF 8AE5 +8AE6 8AE6 EB9480 8AE6 +8AE7 8AE7 EB9481 8AE7 +8AE8 8AE8 EB9482 8AE8 +8AE9 8AE9 EB9483 8AE9 +8AEA 8AEA EB9484 8AEA +8AEB 8AEB EB9485 8AEB +8AEC 8AEC EB9486 8AEC +8AED 8AED EB9487 8AED +8AEE 8AEE EB9488 8AEE +8AEF 8AEF EB9489 8AEF +8AF0 8AF0 EB948A 8AF0 +8AF1 8AF1 EB948B 8AF1 +8AF2 8AF2 EB948C 8AF2 +8AF3 8AF3 EB948D 8AF3 +8AF4 8AF4 EB948E 8AF4 +8AF5 8AF5 EB948F 8AF5 +8AF6 8AF6 EB9490 8AF6 +8AF7 8AF7 EB9491 8AF7 +8AF8 8AF8 EB9492 8AF8 +8AF9 8AF9 EB9493 8AF9 +8AFA 8AFA EB9496 8AFA +8AFB 8AFB EB9497 8AFB +8AFC 8AFC EB9499 8AFC +8AFD 8AFD EB949A 8AFD +8AFE 8AFE EB949D 8AFE +8B41 8B41 EB949E 8B41 +8B42 8B42 EB949F 8B42 +8B43 8B43 EB94A0 8B43 +8B44 8B44 EB94A1 8B44 +8B45 8B45 EB94A2 8B45 +8B46 8B46 EB94A3 8B46 +8B47 8B47 EB94A6 8B47 +8B48 8B48 EB94AB 8B48 +8B49 8B49 EB94AC 8B49 +8B4A 8B4A EB94AD 8B4A +8B4B 8B4B EB94AE 8B4B +8B4C 8B4C EB94AF 8B4C +8B4D 8B4D EB94B2 8B4D +8B4E 8B4E EB94B3 8B4E +8B4F 8B4F EB94B5 8B4F +8B50 8B50 EB94B6 8B50 +8B51 8B51 EB94B7 8B51 +8B52 8B52 EB94B9 8B52 +8B53 8B53 EB94BA 8B53 +8B54 8B54 EB94BB 8B54 +8B55 8B55 EB94BC 8B55 +8B56 8B56 EB94BD 8B56 +8B57 8B57 EB94BE 8B57 +8B58 8B58 EB94BF 8B58 +8B59 8B59 EB9582 8B59 +8B5A 8B5A EB9586 8B5A +8B61 8B61 EB9587 8B61 +8B62 8B62 EB9588 8B62 +8B63 8B63 EB9589 8B63 +8B64 8B64 EB958A 8B64 +8B65 8B65 EB958E 8B65 +8B66 8B66 EB958F 8B66 +8B67 8B67 EB9591 8B67 +8B68 8B68 EB9592 8B68 +8B69 8B69 EB9593 8B69 +8B6A 8B6A EB9595 8B6A +8B6B 8B6B EB9596 8B6B +8B6C 8B6C EB9597 8B6C +8B6D 8B6D EB9598 8B6D +8B6E 8B6E EB9599 8B6E +8B6F 8B6F EB959A 8B6F +8B70 8B70 EB959B 8B70 +8B71 8B71 EB959E 8B71 +8B72 8B72 EB95A2 8B72 +8B73 8B73 EB95A3 8B73 +8B74 8B74 EB95A4 8B74 +8B75 8B75 EB95A5 8B75 +8B76 8B76 EB95A6 8B76 +8B77 8B77 EB95A7 8B77 +8B78 8B78 EB95A8 8B78 +8B79 8B79 EB95A9 8B79 +8B7A 8B7A EB95AA 8B7A +8B81 8B81 EB95AB 8B81 +8B82 8B82 EB95AC 8B82 +8B83 8B83 EB95AD 8B83 +8B84 8B84 EB95AE 8B84 +8B85 8B85 EB95AF 8B85 +8B86 8B86 EB95B0 8B86 +8B87 8B87 EB95B1 8B87 +8B88 8B88 EB95B2 8B88 +8B89 8B89 EB95B3 8B89 +8B8A 8B8A EB95B4 8B8A +8B8B 8B8B EB95B5 8B8B +8B8C 8B8C EB95B6 8B8C +8B8D 8B8D EB95B7 8B8D +8B8E 8B8E EB95B8 8B8E +8B8F 8B8F EB95B9 8B8F +8B90 8B90 EB95BA 8B90 +8B91 8B91 EB95BB 8B91 +8B92 8B92 EB95BC 8B92 +8B93 8B93 EB95BD 8B93 +8B94 8B94 EB95BE 8B94 +8B95 8B95 EB95BF 8B95 +8B96 8B96 EB9680 8B96 +8B97 8B97 EB9681 8B97 +8B98 8B98 EB9682 8B98 +8B99 8B99 EB9683 8B99 +8B9A 8B9A EB9684 8B9A +8B9B 8B9B EB9685 8B9B +8B9C 8B9C EB9686 8B9C +8B9D 8B9D EB9687 8B9D +8B9E 8B9E EB9688 8B9E +8B9F 8B9F EB9689 8B9F +8BA0 8BA0 EB968A 8BA0 +8BA1 8BA1 EB968B 8BA1 +8BA2 8BA2 EB968C 8BA2 +8BA3 8BA3 EB968D 8BA3 +8BA4 8BA4 EB968E 8BA4 +8BA5 8BA5 EB968F 8BA5 +8BA6 8BA6 EB9690 8BA6 +8BA7 8BA7 EB9691 8BA7 +8BA8 8BA8 EB9692 8BA8 +8BA9 8BA9 EB9693 8BA9 +8BAA 8BAA EB9694 8BAA +8BAB 8BAB EB9695 8BAB +8BAC 8BAC EB9696 8BAC +8BAD 8BAD EB9697 8BAD +8BAE 8BAE EB9698 8BAE +8BAF 8BAF EB9699 8BAF +8BB0 8BB0 EB969A 8BB0 +8BB1 8BB1 EB969B 8BB1 +8BB2 8BB2 EB969C 8BB2 +8BB3 8BB3 EB969D 8BB3 +8BB4 8BB4 EB969E 8BB4 +8BB5 8BB5 EB969F 8BB5 +8BB6 8BB6 EB96A2 8BB6 +8BB7 8BB7 EB96A3 8BB7 +8BB8 8BB8 EB96A5 8BB8 +8BB9 8BB9 EB96A6 8BB9 +8BBA 8BBA EB96A7 8BBA +8BBB 8BBB EB96A9 8BBB +8BBC 8BBC EB96AC 8BBC +8BBD 8BBD EB96AD 8BBD +8BBE 8BBE EB96AE 8BBE +8BBF 8BBF EB96AF 8BBF +8BC0 8BC0 EB96B2 8BC0 +8BC1 8BC1 EB96B6 8BC1 +8BC2 8BC2 EB96B7 8BC2 +8BC3 8BC3 EB96B8 8BC3 +8BC4 8BC4 EB96B9 8BC4 +8BC5 8BC5 EB96BA 8BC5 +8BC6 8BC6 EB96BE 8BC6 +8BC7 8BC7 EB96BF 8BC7 +8BC8 8BC8 EB9781 8BC8 +8BC9 8BC9 EB9782 8BC9 +8BCA 8BCA EB9783 8BCA +8BCB 8BCB EB9785 8BCB +8BCC 8BCC EB9786 8BCC +8BCD 8BCD EB9787 8BCD +8BCE 8BCE EB9788 8BCE +8BCF 8BCF EB9789 8BCF +8BD0 8BD0 EB978A 8BD0 +8BD1 8BD1 EB978B 8BD1 +8BD2 8BD2 EB978E 8BD2 +8BD3 8BD3 EB9792 8BD3 +8BD4 8BD4 EB9793 8BD4 +8BD5 8BD5 EB9794 8BD5 +8BD6 8BD6 EB9795 8BD6 +8BD7 8BD7 EB9796 8BD7 +8BD8 8BD8 EB9797 8BD8 +8BD9 8BD9 EB9799 8BD9 +8BDA 8BDA EB979A 8BDA +8BDB 8BDB EB979B 8BDB +8BDC 8BDC EB979C 8BDC +8BDD 8BDD EB979D 8BDD +8BDE 8BDE EB979E 8BDE +8BDF 8BDF EB979F 8BDF +8BE0 8BE0 EB97A0 8BE0 +8BE1 8BE1 EB97A1 8BE1 +8BE2 8BE2 EB97A2 8BE2 +8BE3 8BE3 EB97A3 8BE3 +8BE4 8BE4 EB97A4 8BE4 +8BE5 8BE5 EB97A5 8BE5 +8BE6 8BE6 EB97A6 8BE6 +8BE7 8BE7 EB97A7 8BE7 +8BE8 8BE8 EB97A8 8BE8 +8BE9 8BE9 EB97A9 8BE9 +8BEA 8BEA EB97AA 8BEA +8BEB 8BEB EB97AB 8BEB +8BEC 8BEC EB97AD 8BEC +8BED 8BED EB97AE 8BED +8BEE 8BEE EB97AF 8BEE +8BEF 8BEF EB97B0 8BEF +8BF0 8BF0 EB97B1 8BF0 +8BF1 8BF1 EB97B2 8BF1 +8BF2 8BF2 EB97B3 8BF2 +8BF3 8BF3 EB97B4 8BF3 +8BF4 8BF4 EB97B5 8BF4 +8BF5 8BF5 EB97B6 8BF5 +8BF6 8BF6 EB97B7 8BF6 +8BF7 8BF7 EB97B8 8BF7 +8BF8 8BF8 EB97B9 8BF8 +8BF9 8BF9 EB97BA 8BF9 +8BFA 8BFA EB97BB 8BFA +8BFB 8BFB EB97BC 8BFB +8BFC 8BFC EB97BD 8BFC +8BFD 8BFD EB97BE 8BFD +8BFE 8BFE EB97BF 8BFE +8C41 8C41 EB9880 8C41 +8C42 8C42 EB9881 8C42 +8C43 8C43 EB9882 8C43 +8C44 8C44 EB9883 8C44 +8C45 8C45 EB9884 8C45 +8C46 8C46 EB9885 8C46 +8C47 8C47 EB9886 8C47 +8C48 8C48 EB9887 8C48 +8C49 8C49 EB9888 8C49 +8C4A 8C4A EB9889 8C4A +8C4B 8C4B EB988A 8C4B +8C4C 8C4C EB988B 8C4C +8C4D 8C4D EB988C 8C4D +8C4E 8C4E EB988D 8C4E +8C4F 8C4F EB988E 8C4F +8C50 8C50 EB988F 8C50 +8C51 8C51 EB9892 8C51 +8C52 8C52 EB9893 8C52 +8C53 8C53 EB9895 8C53 +8C54 8C54 EB9896 8C54 +8C55 8C55 EB9897 8C55 +8C56 8C56 EB9899 8C56 +8C57 8C57 EB989A 8C57 +8C58 8C58 EB989B 8C58 +8C59 8C59 EB989C 8C59 +8C5A 8C5A EB989D 8C5A +8C61 8C61 EB989E 8C61 +8C62 8C62 EB989F 8C62 +8C63 8C63 EB98A0 8C63 +8C64 8C64 EB98A1 8C64 +8C65 8C65 EB98A2 8C65 +8C66 8C66 EB98A3 8C66 +8C67 8C67 EB98A4 8C67 +8C68 8C68 EB98A6 8C68 +8C69 8C69 EB98A7 8C69 +8C6A 8C6A EB98A8 8C6A +8C6B 8C6B EB98A9 8C6B +8C6C 8C6C EB98AA 8C6C +8C6D 8C6D EB98AB 8C6D +8C6E 8C6E EB98AD 8C6E +8C6F 8C6F EB98AE 8C6F +8C70 8C70 EB98AF 8C70 +8C71 8C71 EB98B0 8C71 +8C72 8C72 EB98B1 8C72 +8C73 8C73 EB98B2 8C73 +8C74 8C74 EB98B3 8C74 +8C75 8C75 EB98B5 8C75 +8C76 8C76 EB98B6 8C76 +8C77 8C77 EB98B7 8C77 +8C78 8C78 EB98B8 8C78 +8C79 8C79 EB98B9 8C79 +8C7A 8C7A EB98BA 8C7A +8C81 8C81 EB98BB 8C81 +8C82 8C82 EB98BC 8C82 +8C83 8C83 EB98BD 8C83 +8C84 8C84 EB98BE 8C84 +8C85 8C85 EB98BF 8C85 +8C86 8C86 EB9980 8C86 +8C87 8C87 EB9981 8C87 +8C88 8C88 EB9982 8C88 +8C89 8C89 EB9983 8C89 +8C8A 8C8A EB9984 8C8A +8C8B 8C8B EB9985 8C8B +8C8C 8C8C EB9986 8C8C +8C8D 8C8D EB9987 8C8D +8C8E 8C8E EB9989 8C8E +8C8F 8C8F EB998A 8C8F +8C90 8C90 EB998B 8C90 +8C91 8C91 EB998C 8C91 +8C92 8C92 EB998D 8C92 +8C93 8C93 EB998E 8C93 +8C94 8C94 EB998F 8C94 +8C95 8C95 EB9990 8C95 +8C96 8C96 EB9991 8C96 +8C97 8C97 EB9992 8C97 +8C98 8C98 EB9993 8C98 +8C99 8C99 EB9994 8C99 +8C9A 8C9A EB9995 8C9A +8C9B 8C9B EB9996 8C9B +8C9C 8C9C EB9997 8C9C +8C9D 8C9D EB9998 8C9D +8C9E 8C9E EB9999 8C9E +8C9F 8C9F EB999A 8C9F +8CA0 8CA0 EB999B 8CA0 +8CA1 8CA1 EB999C 8CA1 +8CA2 8CA2 EB999D 8CA2 +8CA3 8CA3 EB999E 8CA3 +8CA4 8CA4 EB999F 8CA4 +8CA5 8CA5 EB99A0 8CA5 +8CA6 8CA6 EB99A1 8CA6 +8CA7 8CA7 EB99A2 8CA7 +8CA8 8CA8 EB99A3 8CA8 +8CA9 8CA9 EB99A5 8CA9 +8CAA 8CAA EB99A6 8CAA +8CAB 8CAB EB99A7 8CAB +8CAC 8CAC EB99A9 8CAC +8CAD 8CAD EB99AA 8CAD +8CAE 8CAE EB99AB 8CAE +8CAF 8CAF EB99AC 8CAF +8CB0 8CB0 EB99AD 8CB0 +8CB1 8CB1 EB99AE 8CB1 +8CB2 8CB2 EB99AF 8CB2 +8CB3 8CB3 EB99B0 8CB3 +8CB4 8CB4 EB99B1 8CB4 +8CB5 8CB5 EB99B2 8CB5 +8CB6 8CB6 EB99B3 8CB6 +8CB7 8CB7 EB99B4 8CB7 +8CB8 8CB8 EB99B5 8CB8 +8CB9 8CB9 EB99B6 8CB9 +8CBA 8CBA EB99B7 8CBA +8CBB 8CBB EB99B8 8CBB +8CBC 8CBC EB99B9 8CBC +8CBD 8CBD EB99BA 8CBD +8CBE 8CBE EB99BB 8CBE +8CBF 8CBF EB99BC 8CBF +8CC0 8CC0 EB99BD 8CC0 +8CC1 8CC1 EB99BE 8CC1 +8CC2 8CC2 EB99BF 8CC2 +8CC3 8CC3 EB9A80 8CC3 +8CC4 8CC4 EB9A81 8CC4 +8CC5 8CC5 EB9A82 8CC5 +8CC6 8CC6 EB9A83 8CC6 +8CC7 8CC7 EB9A84 8CC7 +8CC8 8CC8 EB9A85 8CC8 +8CC9 8CC9 EB9A86 8CC9 +8CCA 8CCA EB9A87 8CCA +8CCB 8CCB EB9A88 8CCB +8CCC 8CCC EB9A89 8CCC +8CCD 8CCD EB9A8A 8CCD +8CCE 8CCE EB9A8B 8CCE +8CCF 8CCF EB9A8C 8CCF +8CD0 8CD0 EB9A8D 8CD0 +8CD1 8CD1 EB9A8E 8CD1 +8CD2 8CD2 EB9A8F 8CD2 +8CD3 8CD3 EB9A90 8CD3 +8CD4 8CD4 EB9A91 8CD4 +8CD5 8CD5 EB9A92 8CD5 +8CD6 8CD6 EB9A93 8CD6 +8CD7 8CD7 EB9A94 8CD7 +8CD8 8CD8 EB9A95 8CD8 +8CD9 8CD9 EB9A96 8CD9 +8CDA 8CDA EB9A97 8CDA +8CDB 8CDB EB9A98 8CDB +8CDC 8CDC EB9A99 8CDC +8CDD 8CDD EB9A9A 8CDD +8CDE 8CDE EB9A9B 8CDE +8CDF 8CDF EB9A9E 8CDF +8CE0 8CE0 EB9A9F 8CE0 +8CE1 8CE1 EB9AA1 8CE1 +8CE2 8CE2 EB9AA2 8CE2 +8CE3 8CE3 EB9AA3 8CE3 +8CE4 8CE4 EB9AA5 8CE4 +8CE5 8CE5 EB9AA6 8CE5 +8CE6 8CE6 EB9AA7 8CE6 +8CE7 8CE7 EB9AA8 8CE7 +8CE8 8CE8 EB9AA9 8CE8 +8CE9 8CE9 EB9AAA 8CE9 +8CEA 8CEA EB9AAD 8CEA +8CEB 8CEB EB9AAE 8CEB +8CEC 8CEC EB9AAF 8CEC +8CED 8CED EB9AB0 8CED +8CEE 8CEE EB9AB2 8CEE +8CEF 8CEF EB9AB3 8CEF +8CF0 8CF0 EB9AB4 8CF0 +8CF1 8CF1 EB9AB5 8CF1 +8CF2 8CF2 EB9AB6 8CF2 +8CF3 8CF3 EB9AB7 8CF3 +8CF4 8CF4 EB9AB8 8CF4 +8CF5 8CF5 EB9AB9 8CF5 +8CF6 8CF6 EB9ABA 8CF6 +8CF7 8CF7 EB9ABB 8CF7 +8CF8 8CF8 EB9ABC 8CF8 +8CF9 8CF9 EB9ABD 8CF9 +8CFA 8CFA EB9ABE 8CFA +8CFB 8CFB EB9ABF 8CFB +8CFC 8CFC EB9B80 8CFC +8CFD 8CFD EB9B81 8CFD +8CFE 8CFE EB9B82 8CFE +8D41 8D41 EB9B83 8D41 +8D42 8D42 EB9B84 8D42 +8D43 8D43 EB9B85 8D43 +8D44 8D44 EB9B86 8D44 +8D45 8D45 EB9B87 8D45 +8D46 8D46 EB9B88 8D46 +8D47 8D47 EB9B89 8D47 +8D48 8D48 EB9B8A 8D48 +8D49 8D49 EB9B8B 8D49 +8D4A 8D4A EB9B8C 8D4A +8D4B 8D4B EB9B8D 8D4B +8D4C 8D4C EB9B8E 8D4C +8D4D 8D4D EB9B8F 8D4D +8D4E 8D4E EB9B90 8D4E +8D4F 8D4F EB9B91 8D4F +8D50 8D50 EB9B92 8D50 +8D51 8D51 EB9B93 8D51 +8D52 8D52 EB9B95 8D52 +8D53 8D53 EB9B96 8D53 +8D54 8D54 EB9B97 8D54 +8D55 8D55 EB9B98 8D55 +8D56 8D56 EB9B99 8D56 +8D57 8D57 EB9B9A 8D57 +8D58 8D58 EB9B9B 8D58 +8D59 8D59 EB9B9C 8D59 +8D5A 8D5A EB9B9D 8D5A +8D61 8D61 EB9B9E 8D61 +8D62 8D62 EB9B9F 8D62 +8D63 8D63 EB9BA0 8D63 +8D64 8D64 EB9BA1 8D64 +8D65 8D65 EB9BA2 8D65 +8D66 8D66 EB9BA3 8D66 +8D67 8D67 EB9BA4 8D67 +8D68 8D68 EB9BA5 8D68 +8D69 8D69 EB9BA6 8D69 +8D6A 8D6A EB9BA7 8D6A +8D6B 8D6B EB9BA8 8D6B +8D6C 8D6C EB9BA9 8D6C +8D6D 8D6D EB9BAA 8D6D +8D6E 8D6E EB9BAB 8D6E +8D6F 8D6F EB9BAC 8D6F +8D70 8D70 EB9BAD 8D70 +8D71 8D71 EB9BAE 8D71 +8D72 8D72 EB9BAF 8D72 +8D73 8D73 EB9BB1 8D73 +8D74 8D74 EB9BB2 8D74 +8D75 8D75 EB9BB3 8D75 +8D76 8D76 EB9BB5 8D76 +8D77 8D77 EB9BB6 8D77 +8D78 8D78 EB9BB7 8D78 +8D79 8D79 EB9BB9 8D79 +8D7A 8D7A EB9BBA 8D7A +8D81 8D81 EB9BBB 8D81 +8D82 8D82 EB9BBC 8D82 +8D83 8D83 EB9BBD 8D83 +8D84 8D84 EB9BBE 8D84 +8D85 8D85 EB9BBF 8D85 +8D86 8D86 EB9C82 8D86 +8D87 8D87 EB9C83 8D87 +8D88 8D88 EB9C84 8D88 +8D89 8D89 EB9C86 8D89 +8D8A 8D8A EB9C87 8D8A +8D8B 8D8B EB9C88 8D8B +8D8C 8D8C EB9C89 8D8C +8D8D 8D8D EB9C8A 8D8D +8D8E 8D8E EB9C8B 8D8E +8D8F 8D8F EB9C8C 8D8F +8D90 8D90 EB9C8D 8D90 +8D91 8D91 EB9C8E 8D91 +8D92 8D92 EB9C8F 8D92 +8D93 8D93 EB9C90 8D93 +8D94 8D94 EB9C91 8D94 +8D95 8D95 EB9C92 8D95 +8D96 8D96 EB9C93 8D96 +8D97 8D97 EB9C94 8D97 +8D98 8D98 EB9C95 8D98 +8D99 8D99 EB9C96 8D99 +8D9A 8D9A EB9C97 8D9A +8D9B 8D9B EB9C98 8D9B +8D9C 8D9C EB9C99 8D9C +8D9D 8D9D EB9C9A 8D9D +8D9E 8D9E EB9C9B 8D9E +8D9F 8D9F EB9C9C 8D9F +8DA0 8DA0 EB9C9D 8DA0 +8DA1 8DA1 EB9C9E 8DA1 +8DA2 8DA2 EB9C9F 8DA2 +8DA3 8DA3 EB9CA0 8DA3 +8DA4 8DA4 EB9CA1 8DA4 +8DA5 8DA5 EB9CA2 8DA5 +8DA6 8DA6 EB9CA3 8DA6 +8DA7 8DA7 EB9CA4 8DA7 +8DA8 8DA8 EB9CA5 8DA8 +8DA9 8DA9 EB9CA6 8DA9 +8DAA 8DAA EB9CA7 8DAA +8DAB 8DAB EB9CAA 8DAB +8DAC 8DAC EB9CAB 8DAC +8DAD 8DAD EB9CAD 8DAD +8DAE 8DAE EB9CAE 8DAE +8DAF 8DAF EB9CB1 8DAF +8DB0 8DB0 EB9CB2 8DB0 +8DB1 8DB1 EB9CB3 8DB1 +8DB2 8DB2 EB9CB4 8DB2 +8DB3 8DB3 EB9CB5 8DB3 +8DB4 8DB4 EB9CB6 8DB4 +8DB5 8DB5 EB9CB7 8DB5 +8DB6 8DB6 EB9CBA 8DB6 +8DB7 8DB7 EB9CBC 8DB7 +8DB8 8DB8 EB9CBD 8DB8 +8DB9 8DB9 EB9CBE 8DB9 +8DBA 8DBA EB9CBF 8DBA +8DBB 8DBB EB9D80 8DBB +8DBC 8DBC EB9D81 8DBC +8DBD 8DBD EB9D82 8DBD +8DBE 8DBE EB9D83 8DBE +8DBF 8DBF EB9D85 8DBF +8DC0 8DC0 EB9D86 8DC0 +8DC1 8DC1 EB9D87 8DC1 +8DC2 8DC2 EB9D89 8DC2 +8DC3 8DC3 EB9D8A 8DC3 +8DC4 8DC4 EB9D8B 8DC4 +8DC5 8DC5 EB9D8D 8DC5 +8DC6 8DC6 EB9D8E 8DC6 +8DC7 8DC7 EB9D8F 8DC7 +8DC8 8DC8 EB9D90 8DC8 +8DC9 8DC9 EB9D91 8DC9 +8DCA 8DCA EB9D92 8DCA +8DCB 8DCB EB9D93 8DCB +8DCC 8DCC EB9D96 8DCC +8DCD 8DCD EB9D97 8DCD +8DCE 8DCE EB9D98 8DCE +8DCF 8DCF EB9D99 8DCF +8DD0 8DD0 EB9D9A 8DD0 +8DD1 8DD1 EB9D9B 8DD1 +8DD2 8DD2 EB9D9C 8DD2 +8DD3 8DD3 EB9D9D 8DD3 +8DD4 8DD4 EB9D9E 8DD4 +8DD5 8DD5 EB9D9F 8DD5 +8DD6 8DD6 EB9DA1 8DD6 +8DD7 8DD7 EB9DA2 8DD7 +8DD8 8DD8 EB9DA3 8DD8 +8DD9 8DD9 EB9DA5 8DD9 +8DDA 8DDA EB9DA6 8DDA +8DDB 8DDB EB9DA7 8DDB +8DDC 8DDC EB9DA9 8DDC +8DDD 8DDD EB9DAA 8DDD +8DDE 8DDE EB9DAB 8DDE +8DDF 8DDF EB9DAC 8DDF +8DE0 8DE0 EB9DAD 8DE0 +8DE1 8DE1 EB9DAE 8DE1 +8DE2 8DE2 EB9DAF 8DE2 +8DE3 8DE3 EB9DB2 8DE3 +8DE4 8DE4 EB9DB4 8DE4 +8DE5 8DE5 EB9DB6 8DE5 +8DE6 8DE6 EB9DB7 8DE6 +8DE7 8DE7 EB9DB8 8DE7 +8DE8 8DE8 EB9DB9 8DE8 +8DE9 8DE9 EB9DBA 8DE9 +8DEA 8DEA EB9DBB 8DEA +8DEB 8DEB EB9DBE 8DEB +8DEC 8DEC EB9DBF 8DEC +8DED 8DED EB9E81 8DED +8DEE 8DEE EB9E82 8DEE +8DEF 8DEF EB9E83 8DEF +8DF0 8DF0 EB9E85 8DF0 +8DF1 8DF1 EB9E86 8DF1 +8DF2 8DF2 EB9E87 8DF2 +8DF3 8DF3 EB9E88 8DF3 +8DF4 8DF4 EB9E89 8DF4 +8DF5 8DF5 EB9E8A 8DF5 +8DF6 8DF6 EB9E8B 8DF6 +8DF7 8DF7 EB9E8E 8DF7 +8DF8 8DF8 EB9E93 8DF8 +8DF9 8DF9 EB9E94 8DF9 +8DFA 8DFA EB9E95 8DFA +8DFB 8DFB EB9E9A 8DFB +8DFC 8DFC EB9E9B 8DFC +8DFD 8DFD EB9E9D 8DFD +8DFE 8DFE EB9E9E 8DFE +8E41 8E41 EB9E9F 8E41 +8E42 8E42 EB9EA1 8E42 +8E43 8E43 EB9EA2 8E43 +8E44 8E44 EB9EA3 8E44 +8E45 8E45 EB9EA4 8E45 +8E46 8E46 EB9EA5 8E46 +8E47 8E47 EB9EA6 8E47 +8E48 8E48 EB9EA7 8E48 +8E49 8E49 EB9EAA 8E49 +8E4A 8E4A EB9EAE 8E4A +8E4B 8E4B EB9EAF 8E4B +8E4C 8E4C EB9EB0 8E4C +8E4D 8E4D EB9EB1 8E4D +8E4E 8E4E EB9EB2 8E4E +8E4F 8E4F EB9EB3 8E4F +8E50 8E50 EB9EB6 8E50 +8E51 8E51 EB9EB7 8E51 +8E52 8E52 EB9EB9 8E52 +8E53 8E53 EB9EBA 8E53 +8E54 8E54 EB9EBB 8E54 +8E55 8E55 EB9EBC 8E55 +8E56 8E56 EB9EBD 8E56 +8E57 8E57 EB9EBE 8E57 +8E58 8E58 EB9EBF 8E58 +8E59 8E59 EB9F80 8E59 +8E5A 8E5A EB9F81 8E5A +8E61 8E61 EB9F82 8E61 +8E62 8E62 EB9F83 8E62 +8E63 8E63 EB9F84 8E63 +8E64 8E64 EB9F85 8E64 +8E65 8E65 EB9F86 8E65 +8E66 8E66 EB9F88 8E66 +8E67 8E67 EB9F8A 8E67 +8E68 8E68 EB9F8B 8E68 +8E69 8E69 EB9F8C 8E69 +8E6A 8E6A EB9F8D 8E6A +8E6B 8E6B EB9F8E 8E6B +8E6C 8E6C EB9F8F 8E6C +8E6D 8E6D EB9F90 8E6D +8E6E 8E6E EB9F91 8E6E +8E6F 8E6F EB9F92 8E6F +8E70 8E70 EB9F93 8E70 +8E71 8E71 EB9F94 8E71 +8E72 8E72 EB9F95 8E72 +8E73 8E73 EB9F96 8E73 +8E74 8E74 EB9F97 8E74 +8E75 8E75 EB9F98 8E75 +8E76 8E76 EB9F99 8E76 +8E77 8E77 EB9F9A 8E77 +8E78 8E78 EB9F9B 8E78 +8E79 8E79 EB9F9C 8E79 +8E7A 8E7A EB9F9D 8E7A +8E81 8E81 EB9F9E 8E81 +8E82 8E82 EB9F9F 8E82 +8E83 8E83 EB9FA0 8E83 +8E84 8E84 EB9FA1 8E84 +8E85 8E85 EB9FA2 8E85 +8E86 8E86 EB9FA3 8E86 +8E87 8E87 EB9FA4 8E87 +8E88 8E88 EB9FA5 8E88 +8E89 8E89 EB9FA6 8E89 +8E8A 8E8A EB9FA7 8E8A +8E8B 8E8B EB9FA8 8E8B +8E8C 8E8C EB9FA9 8E8C +8E8D 8E8D EB9FAA 8E8D +8E8E 8E8E EB9FAB 8E8E +8E8F 8E8F EB9FAE 8E8F +8E90 8E90 EB9FAF 8E90 +8E91 8E91 EB9FB1 8E91 +8E92 8E92 EB9FB2 8E92 +8E93 8E93 EB9FB3 8E93 +8E94 8E94 EB9FB5 8E94 +8E95 8E95 EB9FB6 8E95 +8E96 8E96 EB9FB7 8E96 +8E97 8E97 EB9FB8 8E97 +8E98 8E98 EB9FB9 8E98 +8E99 8E99 EB9FBA 8E99 +8E9A 8E9A EB9FBB 8E9A +8E9B 8E9B EB9FBE 8E9B +8E9C 8E9C EBA082 8E9C +8E9D 8E9D EBA083 8E9D +8E9E 8E9E EBA084 8E9E +8E9F 8E9F EBA085 8E9F +8EA0 8EA0 EBA086 8EA0 +8EA1 8EA1 EBA08A 8EA1 +8EA2 8EA2 EBA08B 8EA2 +8EA3 8EA3 EBA08D 8EA3 +8EA4 8EA4 EBA08E 8EA4 +8EA5 8EA5 EBA08F 8EA5 +8EA6 8EA6 EBA091 8EA6 +8EA7 8EA7 EBA092 8EA7 +8EA8 8EA8 EBA093 8EA8 +8EA9 8EA9 EBA094 8EA9 +8EAA 8EAA EBA095 8EAA +8EAB 8EAB EBA096 8EAB +8EAC 8EAC EBA097 8EAC +8EAD 8EAD EBA09A 8EAD +8EAE 8EAE EBA09C 8EAE +8EAF 8EAF EBA09E 8EAF +8EB0 8EB0 EBA09F 8EB0 +8EB1 8EB1 EBA0A0 8EB1 +8EB2 8EB2 EBA0A1 8EB2 +8EB3 8EB3 EBA0A2 8EB3 +8EB4 8EB4 EBA0A3 8EB4 +8EB5 8EB5 EBA0A6 8EB5 +8EB6 8EB6 EBA0A7 8EB6 +8EB7 8EB7 EBA0A9 8EB7 +8EB8 8EB8 EBA0AA 8EB8 +8EB9 8EB9 EBA0AB 8EB9 +8EBA 8EBA EBA0AD 8EBA +8EBB 8EBB EBA0AE 8EBB +8EBC 8EBC EBA0AF 8EBC +8EBD 8EBD EBA0B0 8EBD +8EBE 8EBE EBA0B1 8EBE +8EBF 8EBF EBA0B2 8EBF +8EC0 8EC0 EBA0B3 8EC0 +8EC1 8EC1 EBA0B6 8EC1 +8EC2 8EC2 EBA0BA 8EC2 +8EC3 8EC3 EBA0BB 8EC3 +8EC4 8EC4 EBA0BC 8EC4 +8EC5 8EC5 EBA0BD 8EC5 +8EC6 8EC6 EBA0BE 8EC6 +8EC7 8EC7 EBA0BF 8EC7 +8EC8 8EC8 EBA181 8EC8 +8EC9 8EC9 EBA182 8EC9 +8ECA 8ECA EBA183 8ECA +8ECB 8ECB EBA185 8ECB +8ECC 8ECC EBA186 8ECC +8ECD 8ECD EBA187 8ECD +8ECE 8ECE EBA188 8ECE +8ECF 8ECF EBA189 8ECF +8ED0 8ED0 EBA18A 8ED0 +8ED1 8ED1 EBA18B 8ED1 +8ED2 8ED2 EBA18C 8ED2 +8ED3 8ED3 EBA18D 8ED3 +8ED4 8ED4 EBA18E 8ED4 +8ED5 8ED5 EBA18F 8ED5 +8ED6 8ED6 EBA190 8ED6 +8ED7 8ED7 EBA192 8ED7 +8ED8 8ED8 EBA194 8ED8 +8ED9 8ED9 EBA195 8ED9 +8EDA 8EDA EBA196 8EDA +8EDB 8EDB EBA197 8EDB +8EDC 8EDC EBA198 8EDC +8EDD 8EDD EBA199 8EDD +8EDE 8EDE EBA19A 8EDE +8EDF 8EDF EBA19B 8EDF +8EE0 8EE0 EBA19E 8EE0 +8EE1 8EE1 EBA19F 8EE1 +8EE2 8EE2 EBA1A1 8EE2 +8EE3 8EE3 EBA1A2 8EE3 +8EE4 8EE4 EBA1A3 8EE4 +8EE5 8EE5 EBA1A5 8EE5 +8EE6 8EE6 EBA1A6 8EE6 +8EE7 8EE7 EBA1A7 8EE7 +8EE8 8EE8 EBA1A8 8EE8 +8EE9 8EE9 EBA1A9 8EE9 +8EEA 8EEA EBA1AA 8EEA +8EEB 8EEB EBA1AB 8EEB +8EEC 8EEC EBA1AE 8EEC +8EED 8EED EBA1B0 8EED +8EEE 8EEE EBA1B2 8EEE +8EEF 8EEF EBA1B3 8EEF +8EF0 8EF0 EBA1B4 8EF0 +8EF1 8EF1 EBA1B5 8EF1 +8EF2 8EF2 EBA1B6 8EF2 +8EF3 8EF3 EBA1B7 8EF3 +8EF4 8EF4 EBA1B9 8EF4 +8EF5 8EF5 EBA1BA 8EF5 +8EF6 8EF6 EBA1BB 8EF6 +8EF7 8EF7 EBA1BD 8EF7 +8EF8 8EF8 EBA1BE 8EF8 +8EF9 8EF9 EBA1BF 8EF9 +8EFA 8EFA EBA280 8EFA +8EFB 8EFB EBA281 8EFB +8EFC 8EFC EBA282 8EFC +8EFD 8EFD EBA283 8EFD +8EFE 8EFE EBA284 8EFE +8F41 8F41 EBA285 8F41 +8F42 8F42 EBA286 8F42 +8F43 8F43 EBA287 8F43 +8F44 8F44 EBA288 8F44 +8F45 8F45 EBA289 8F45 +8F46 8F46 EBA28A 8F46 +8F47 8F47 EBA28B 8F47 +8F48 8F48 EBA28C 8F48 +8F49 8F49 EBA28E 8F49 +8F4A 8F4A EBA28F 8F4A +8F4B 8F4B EBA290 8F4B +8F4C 8F4C EBA291 8F4C +8F4D 8F4D EBA292 8F4D +8F4E 8F4E EBA293 8F4E +8F4F 8F4F EBA294 8F4F +8F50 8F50 EBA295 8F50 +8F51 8F51 EBA296 8F51 +8F52 8F52 EBA297 8F52 +8F53 8F53 EBA298 8F53 +8F54 8F54 EBA299 8F54 +8F55 8F55 EBA29A 8F55 +8F56 8F56 EBA29B 8F56 +8F57 8F57 EBA29C 8F57 +8F58 8F58 EBA29D 8F58 +8F59 8F59 EBA29E 8F59 +8F5A 8F5A EBA29F 8F5A +8F61 8F61 EBA2A0 8F61 +8F62 8F62 EBA2A1 8F62 +8F63 8F63 EBA2A2 8F63 +8F64 8F64 EBA2A3 8F64 +8F65 8F65 EBA2A4 8F65 +8F66 8F66 EBA2A5 8F66 +8F67 8F67 EBA2A6 8F67 +8F68 8F68 EBA2A7 8F68 +8F69 8F69 EBA2A9 8F69 +8F6A 8F6A EBA2AA 8F6A +8F6B 8F6B EBA2AB 8F6B +8F6C 8F6C EBA2AC 8F6C +8F6D 8F6D EBA2AD 8F6D +8F6E 8F6E EBA2AE 8F6E +8F6F 8F6F EBA2AF 8F6F +8F70 8F70 EBA2B1 8F70 +8F71 8F71 EBA2B2 8F71 +8F72 8F72 EBA2B3 8F72 +8F73 8F73 EBA2B5 8F73 +8F74 8F74 EBA2B6 8F74 +8F75 8F75 EBA2B7 8F75 +8F76 8F76 EBA2B9 8F76 +8F77 8F77 EBA2BA 8F77 +8F78 8F78 EBA2BB 8F78 +8F79 8F79 EBA2BC 8F79 +8F7A 8F7A EBA2BD 8F7A +8F81 8F81 EBA2BE 8F81 +8F82 8F82 EBA2BF 8F82 +8F83 8F83 EBA382 8F83 +8F84 8F84 EBA384 8F84 +8F85 8F85 EBA386 8F85 +8F86 8F86 EBA387 8F86 +8F87 8F87 EBA388 8F87 +8F88 8F88 EBA389 8F88 +8F89 8F89 EBA38A 8F89 +8F8A 8F8A EBA38B 8F8A +8F8B 8F8B EBA38D 8F8B +8F8C 8F8C EBA38E 8F8C +8F8D 8F8D EBA38F 8F8D +8F8E 8F8E EBA391 8F8E +8F8F 8F8F EBA392 8F8F +8F90 8F90 EBA393 8F90 +8F91 8F91 EBA395 8F91 +8F92 8F92 EBA396 8F92 +8F93 8F93 EBA397 8F93 +8F94 8F94 EBA398 8F94 +8F95 8F95 EBA399 8F95 +8F96 8F96 EBA39A 8F96 +8F97 8F97 EBA39B 8F97 +8F98 8F98 EBA39C 8F98 +8F99 8F99 EBA39E 8F99 +8F9A 8F9A EBA3A0 8F9A +8F9B 8F9B EBA3A2 8F9B +8F9C 8F9C EBA3A3 8F9C +8F9D 8F9D EBA3A4 8F9D +8F9E 8F9E EBA3A5 8F9E +8F9F 8F9F EBA3A6 8F9F +8FA0 8FA0 EBA3A7 8FA0 +8FA1 8FA1 EBA3AA 8FA1 +8FA2 8FA2 EBA3AB 8FA2 +8FA3 8FA3 EBA3AD 8FA3 +8FA4 8FA4 EBA3AE 8FA4 +8FA5 8FA5 EBA3AF 8FA5 +8FA6 8FA6 EBA3B1 8FA6 +8FA7 8FA7 EBA3B2 8FA7 +8FA8 8FA8 EBA3B3 8FA8 +8FA9 8FA9 EBA3B4 8FA9 +8FAA 8FAA EBA3B5 8FAA +8FAB 8FAB EBA3B6 8FAB +8FAC 8FAC EBA3B7 8FAC +8FAD 8FAD EBA3BA 8FAD +8FAE 8FAE EBA3BC 8FAE +8FAF 8FAF EBA3BE 8FAF +8FB0 8FB0 EBA3BF 8FB0 +8FB1 8FB1 EBA480 8FB1 +8FB2 8FB2 EBA481 8FB2 +8FB3 8FB3 EBA482 8FB3 +8FB4 8FB4 EBA483 8FB4 +8FB5 8FB5 EBA485 8FB5 +8FB6 8FB6 EBA486 8FB6 +8FB7 8FB7 EBA487 8FB7 +8FB8 8FB8 EBA488 8FB8 +8FB9 8FB9 EBA489 8FB9 +8FBA 8FBA EBA48A 8FBA +8FBB 8FBB EBA48B 8FBB +8FBC 8FBC EBA48C 8FBC +8FBD 8FBD EBA48D 8FBD +8FBE 8FBE EBA48E 8FBE +8FBF 8FBF EBA48F 8FBF +8FC0 8FC0 EBA490 8FC0 +8FC1 8FC1 EBA491 8FC1 +8FC2 8FC2 EBA492 8FC2 +8FC3 8FC3 EBA493 8FC3 +8FC4 8FC4 EBA494 8FC4 +8FC5 8FC5 EBA495 8FC5 +8FC6 8FC6 EBA496 8FC6 +8FC7 8FC7 EBA497 8FC7 +8FC8 8FC8 EBA499 8FC8 +8FC9 8FC9 EBA49A 8FC9 +8FCA 8FCA EBA49B 8FCA +8FCB 8FCB EBA49C 8FCB +8FCC 8FCC EBA49D 8FCC +8FCD 8FCD EBA49E 8FCD +8FCE 8FCE EBA49F 8FCE +8FCF 8FCF EBA4A1 8FCF +8FD0 8FD0 EBA4A2 8FD0 +8FD1 8FD1 EBA4A3 8FD1 +8FD2 8FD2 EBA4A4 8FD2 +8FD3 8FD3 EBA4A5 8FD3 +8FD4 8FD4 EBA4A6 8FD4 +8FD5 8FD5 EBA4A7 8FD5 +8FD6 8FD6 EBA4A8 8FD6 +8FD7 8FD7 EBA4A9 8FD7 +8FD8 8FD8 EBA4AA 8FD8 +8FD9 8FD9 EBA4AB 8FD9 +8FDA 8FDA EBA4AC 8FDA +8FDB 8FDB EBA4AD 8FDB +8FDC 8FDC EBA4AE 8FDC +8FDD 8FDD EBA4AF 8FDD +8FDE 8FDE EBA4B0 8FDE +8FDF 8FDF EBA4B1 8FDF +8FE0 8FE0 EBA4B2 8FE0 +8FE1 8FE1 EBA4B3 8FE1 +8FE2 8FE2 EBA4B4 8FE2 +8FE3 8FE3 EBA4B5 8FE3 +8FE4 8FE4 EBA4B6 8FE4 +8FE5 8FE5 EBA4B7 8FE5 +8FE6 8FE6 EBA4B8 8FE6 +8FE7 8FE7 EBA4B9 8FE7 +8FE8 8FE8 EBA4BA 8FE8 +8FE9 8FE9 EBA4BB 8FE9 +8FEA 8FEA EBA4BE 8FEA +8FEB 8FEB EBA4BF 8FEB +8FEC 8FEC EBA581 8FEC +8FED 8FED EBA582 8FED +8FEE 8FEE EBA583 8FEE +8FEF 8FEF EBA585 8FEF +8FF0 8FF0 EBA586 8FF0 +8FF1 8FF1 EBA587 8FF1 +8FF2 8FF2 EBA588 8FF2 +8FF3 8FF3 EBA589 8FF3 +8FF4 8FF4 EBA58A 8FF4 +8FF5 8FF5 EBA58B 8FF5 +8FF6 8FF6 EBA58D 8FF6 +8FF7 8FF7 EBA58E 8FF7 +8FF8 8FF8 EBA590 8FF8 +8FF9 8FF9 EBA592 8FF9 +8FFA 8FFA EBA593 8FFA +8FFB 8FFB EBA594 8FFB +8FFC 8FFC EBA595 8FFC +8FFD 8FFD EBA596 8FFD +8FFE 8FFE EBA597 8FFE +9041 9041 EBA59A 9041 +9042 9042 EBA59B 9042 +9043 9043 EBA59D 9043 +9044 9044 EBA59E 9044 +9045 9045 EBA59F 9045 +9046 9046 EBA5A1 9046 +9047 9047 EBA5A2 9047 +9048 9048 EBA5A3 9048 +9049 9049 EBA5A4 9049 +904A 904A EBA5A5 904A +904B 904B EBA5A6 904B +904C 904C EBA5A7 904C +904D 904D EBA5AA 904D +904E 904E EBA5AC 904E +904F 904F EBA5AE 904F +9050 9050 EBA5AF 9050 +9051 9051 EBA5B0 9051 +9052 9052 EBA5B1 9052 +9053 9053 EBA5B2 9053 +9054 9054 EBA5B3 9054 +9055 9055 EBA5B6 9055 +9056 9056 EBA5B7 9056 +9057 9057 EBA5B9 9057 +9058 9058 EBA5BA 9058 +9059 9059 EBA5BB 9059 +905A 905A EBA5BD 905A +9061 9061 EBA5BE 9061 +9062 9062 EBA5BF 9062 +9063 9063 EBA680 9063 +9064 9064 EBA681 9064 +9065 9065 EBA682 9065 +9066 9066 EBA683 9066 +9067 9067 EBA686 9067 +9068 9068 EBA688 9068 +9069 9069 EBA68B 9069 +906A 906A EBA68C 906A +906B 906B EBA68F 906B +906C 906C EBA690 906C +906D 906D EBA691 906D +906E 906E EBA692 906E +906F 906F EBA693 906F +9070 9070 EBA694 9070 +9071 9071 EBA695 9071 +9072 9072 EBA696 9072 +9073 9073 EBA697 9073 +9074 9074 EBA698 9074 +9075 9075 EBA699 9075 +9076 9076 EBA69A 9076 +9077 9077 EBA69B 9077 +9078 9078 EBA69C 9078 +9079 9079 EBA69D 9079 +907A 907A EBA69E 907A +9081 9081 EBA69F 9081 +9082 9082 EBA6A0 9082 +9083 9083 EBA6A1 9083 +9084 9084 EBA6A2 9084 +9085 9085 EBA6A3 9085 +9086 9086 EBA6A4 9086 +9087 9087 EBA6A5 9087 +9088 9088 EBA6A6 9088 +9089 9089 EBA6A7 9089 +908A 908A EBA6A8 908A +908B 908B EBA6A9 908B +908C 908C EBA6AA 908C +908D 908D EBA6AB 908D +908E 908E EBA6AE 908E +908F 908F EBA6AF 908F +9090 9090 EBA6B1 9090 +9091 9091 EBA6B2 9091 +9092 9092 EBA6B3 9092 +9093 9093 EBA6B5 9093 +9094 9094 EBA6B6 9094 +9095 9095 EBA6B7 9095 +9096 9096 EBA6B8 9096 +9097 9097 EBA6B9 9097 +9098 9098 EBA6BA 9098 +9099 9099 EBA6BB 9099 +909A 909A EBA6BE 909A +909B 909B EBA780 909B +909C 909C EBA782 909C +909D 909D EBA783 909D +909E 909E EBA784 909E +909F 909F EBA785 909F +90A0 90A0 EBA786 90A0 +90A1 90A1 EBA787 90A1 +90A2 90A2 EBA78A 90A2 +90A3 90A3 EBA78B 90A3 +90A4 90A4 EBA78D 90A4 +90A5 90A5 EBA793 90A5 +90A6 90A6 EBA794 90A6 +90A7 90A7 EBA795 90A7 +90A8 90A8 EBA796 90A8 +90A9 90A9 EBA797 90A9 +90AA 90AA EBA79A 90AA +90AB 90AB EBA79C 90AB +90AC 90AC EBA79F 90AC +90AD 90AD EBA7A0 90AD +90AE 90AE EBA7A2 90AE +90AF 90AF EBA7A6 90AF +90B0 90B0 EBA7A7 90B0 +90B1 90B1 EBA7A9 90B1 +90B2 90B2 EBA7AA 90B2 +90B3 90B3 EBA7AB 90B3 +90B4 90B4 EBA7AD 90B4 +90B5 90B5 EBA7AE 90B5 +90B6 90B6 EBA7AF 90B6 +90B7 90B7 EBA7B0 90B7 +90B8 90B8 EBA7B1 90B8 +90B9 90B9 EBA7B2 90B9 +90BA 90BA EBA7B3 90BA +90BB 90BB EBA7B6 90BB +90BC 90BC EBA7BB 90BC +90BD 90BD EBA7BC 90BD +90BE 90BE EBA7BD 90BE +90BF 90BF EBA7BE 90BF +90C0 90C0 EBA7BF 90C0 +90C1 90C1 EBA882 90C1 +90C2 90C2 EBA883 90C2 +90C3 90C3 EBA884 90C3 +90C4 90C4 EBA885 90C4 +90C5 90C5 EBA886 90C5 +90C6 90C6 EBA887 90C6 +90C7 90C7 EBA889 90C7 +90C8 90C8 EBA88A 90C8 +90C9 90C9 EBA88B 90C9 +90CA 90CA EBA88C 90CA +90CB 90CB EBA88D 90CB +90CC 90CC EBA88E 90CC +90CD 90CD EBA88F 90CD +90CE 90CE EBA890 90CE +90CF 90CF EBA891 90CF +90D0 90D0 EBA892 90D0 +90D1 90D1 EBA893 90D1 +90D2 90D2 EBA894 90D2 +90D3 90D3 EBA896 90D3 +90D4 90D4 EBA897 90D4 +90D5 90D5 EBA898 90D5 +90D6 90D6 EBA899 90D6 +90D7 90D7 EBA89A 90D7 +90D8 90D8 EBA89B 90D8 +90D9 90D9 EBA89C 90D9 +90DA 90DA EBA89D 90DA +90DB 90DB EBA89E 90DB +90DC 90DC EBA89F 90DC +90DD 90DD EBA8A0 90DD +90DE 90DE EBA8A1 90DE +90DF 90DF EBA8A2 90DF +90E0 90E0 EBA8A3 90E0 +90E1 90E1 EBA8A4 90E1 +90E2 90E2 EBA8A5 90E2 +90E3 90E3 EBA8A6 90E3 +90E4 90E4 EBA8A7 90E4 +90E5 90E5 EBA8A8 90E5 +90E6 90E6 EBA8A9 90E6 +90E7 90E7 EBA8AA 90E7 +90E8 90E8 EBA8AB 90E8 +90E9 90E9 EBA8AC 90E9 +90EA 90EA EBA8AD 90EA +90EB 90EB EBA8AE 90EB +90EC 90EC EBA8AF 90EC +90ED 90ED EBA8B0 90ED +90EE 90EE EBA8B1 90EE +90EF 90EF EBA8B2 90EF +90F0 90F0 EBA8B3 90F0 +90F1 90F1 EBA8B4 90F1 +90F2 90F2 EBA8B5 90F2 +90F3 90F3 EBA8B6 90F3 +90F4 90F4 EBA8B7 90F4 +90F5 90F5 EBA8BA 90F5 +90F6 90F6 EBA8BB 90F6 +90F7 90F7 EBA8BD 90F7 +90F8 90F8 EBA8BE 90F8 +90F9 90F9 EBA8BF 90F9 +90FA 90FA EBA981 90FA +90FB 90FB EBA983 90FB +90FC 90FC EBA984 90FC +90FD 90FD EBA985 90FD +90FE 90FE EBA986 90FE +9141 9141 EBA987 9141 +9142 9142 EBA98A 9142 +9143 9143 EBA98C 9143 +9144 9144 EBA98F 9144 +9145 9145 EBA990 9145 +9146 9146 EBA991 9146 +9147 9147 EBA992 9147 +9148 9148 EBA996 9148 +9149 9149 EBA997 9149 +914A 914A EBA999 914A +914B 914B EBA99A 914B +914C 914C EBA99B 914C +914D 914D EBA99D 914D +914E 914E EBA99E 914E +914F 914F EBA99F 914F +9150 9150 EBA9A0 9150 +9151 9151 EBA9A1 9151 +9152 9152 EBA9A2 9152 +9153 9153 EBA9A3 9153 +9154 9154 EBA9A6 9154 +9155 9155 EBA9AA 9155 +9156 9156 EBA9AB 9156 +9157 9157 EBA9AC 9157 +9158 9158 EBA9AD 9158 +9159 9159 EBA9AE 9159 +915A 915A EBA9AF 915A +9161 9161 EBA9B2 9161 +9162 9162 EBA9B3 9162 +9163 9163 EBA9B5 9163 +9164 9164 EBA9B6 9164 +9165 9165 EBA9B7 9165 +9166 9166 EBA9B9 9166 +9167 9167 EBA9BA 9167 +9168 9168 EBA9BB 9168 +9169 9169 EBA9BC 9169 +916A 916A EBA9BD 916A +916B 916B EBA9BE 916B +916C 916C EBA9BF 916C +916D 916D EBAA80 916D +916E 916E EBAA81 916E +916F 916F EBAA82 916F +9170 9170 EBAA86 9170 +9171 9171 EBAA88 9171 +9172 9172 EBAA89 9172 +9173 9173 EBAA8A 9173 +9174 9174 EBAA8B 9174 +9175 9175 EBAA8D 9175 +9176 9176 EBAA8E 9176 +9177 9177 EBAA8F 9177 +9178 9178 EBAA90 9178 +9179 9179 EBAA91 9179 +917A 917A EBAA92 917A +9181 9181 EBAA93 9181 +9182 9182 EBAA94 9182 +9183 9183 EBAA95 9183 +9184 9184 EBAA96 9184 +9185 9185 EBAA97 9185 +9186 9186 EBAA98 9186 +9187 9187 EBAA99 9187 +9188 9188 EBAA9A 9188 +9189 9189 EBAA9B 9189 +918A 918A EBAA9C 918A +918B 918B EBAA9D 918B +918C 918C EBAA9E 918C +918D 918D EBAA9F 918D +918E 918E EBAAA0 918E +918F 918F EBAAA1 918F +9190 9190 EBAAA2 9190 +9191 9191 EBAAA3 9191 +9192 9192 EBAAA4 9192 +9193 9193 EBAAA5 9193 +9194 9194 EBAAA6 9194 +9195 9195 EBAAA7 9195 +9196 9196 EBAAAA 9196 +9197 9197 EBAAAD 9197 +9198 9198 EBAAAE 9198 +9199 9199 EBAAAF 9199 +919A 919A EBAAB1 919A +919B 919B EBAAB3 919B +919C 919C EBAAB4 919C +919D 919D EBAAB5 919D +919E 919E EBAAB6 919E +919F 919F EBAAB7 919F +91A0 91A0 EBAABA 91A0 +91A1 91A1 EBAABC 91A1 +91A2 91A2 EBAABE 91A2 +91A3 91A3 EBAABF 91A3 +91A4 91A4 EBAB80 91A4 +91A5 91A5 EBAB81 91A5 +91A6 91A6 EBAB82 91A6 +91A7 91A7 EBAB83 91A7 +91A8 91A8 EBAB85 91A8 +91A9 91A9 EBAB86 91A9 +91AA 91AA EBAB87 91AA +91AB 91AB EBAB89 91AB +91AC 91AC EBAB8A 91AC +91AD 91AD EBAB8B 91AD +91AE 91AE EBAB8C 91AE +91AF 91AF EBAB8D 91AF +91B0 91B0 EBAB8E 91B0 +91B1 91B1 EBAB8F 91B1 +91B2 91B2 EBAB90 91B2 +91B3 91B3 EBAB91 91B3 +91B4 91B4 EBAB92 91B4 +91B5 91B5 EBAB93 91B5 +91B6 91B6 EBAB94 91B6 +91B7 91B7 EBAB95 91B7 +91B8 91B8 EBAB96 91B8 +91B9 91B9 EBAB97 91B9 +91BA 91BA EBAB9A 91BA +91BB 91BB EBAB9B 91BB +91BC 91BC EBAB9C 91BC +91BD 91BD EBAB9D 91BD +91BE 91BE EBAB9E 91BE +91BF 91BF EBAB9F 91BF +91C0 91C0 EBABA0 91C0 +91C1 91C1 EBABA1 91C1 +91C2 91C2 EBABA2 91C2 +91C3 91C3 EBABA3 91C3 +91C4 91C4 EBABA4 91C4 +91C5 91C5 EBABA5 91C5 +91C6 91C6 EBABA6 91C6 +91C7 91C7 EBABA7 91C7 +91C8 91C8 EBABA8 91C8 +91C9 91C9 EBABA9 91C9 +91CA 91CA EBABAA 91CA +91CB 91CB EBABAB 91CB +91CC 91CC EBABAC 91CC +91CD 91CD EBABAD 91CD +91CE 91CE EBABAE 91CE +91CF 91CF EBABAF 91CF +91D0 91D0 EBABB0 91D0 +91D1 91D1 EBABB1 91D1 +91D2 91D2 EBABB2 91D2 +91D3 91D3 EBABB3 91D3 +91D4 91D4 EBABB4 91D4 +91D5 91D5 EBABB5 91D5 +91D6 91D6 EBABB6 91D6 +91D7 91D7 EBABB7 91D7 +91D8 91D8 EBABB8 91D8 +91D9 91D9 EBABB9 91D9 +91DA 91DA EBABBA 91DA +91DB 91DB EBABBB 91DB +91DC 91DC EBABBD 91DC +91DD 91DD EBABBE 91DD +91DE 91DE EBABBF 91DE +91DF 91DF EBAC81 91DF +91E0 91E0 EBAC82 91E0 +91E1 91E1 EBAC83 91E1 +91E2 91E2 EBAC85 91E2 +91E3 91E3 EBAC86 91E3 +91E4 91E4 EBAC87 91E4 +91E5 91E5 EBAC88 91E5 +91E6 91E6 EBAC89 91E6 +91E7 91E7 EBAC8A 91E7 +91E8 91E8 EBAC8B 91E8 +91E9 91E9 EBAC8C 91E9 +91EA 91EA EBAC8E 91EA +91EB 91EB EBAC90 91EB +91EC 91EC EBAC92 91EC +91ED 91ED EBAC93 91ED +91EE 91EE EBAC94 91EE +91EF 91EF EBAC95 91EF +91F0 91F0 EBAC96 91F0 +91F1 91F1 EBAC97 91F1 +91F2 91F2 EBAC99 91F2 +91F3 91F3 EBAC9A 91F3 +91F4 91F4 EBAC9B 91F4 +91F5 91F5 EBAC9D 91F5 +91F6 91F6 EBAC9E 91F6 +91F7 91F7 EBAC9F 91F7 +91F8 91F8 EBACA1 91F8 +91F9 91F9 EBACA2 91F9 +91FA 91FA EBACA3 91FA +91FB 91FB EBACA4 91FB +91FC 91FC EBACA5 91FC +91FD 91FD EBACA6 91FD +91FE 91FE EBACA7 91FE +9241 9241 EBACA8 9241 +9242 9242 EBACAA 9242 +9243 9243 EBACAC 9243 +9244 9244 EBACAD 9244 +9245 9245 EBACAE 9245 +9246 9246 EBACAF 9246 +9247 9247 EBACB0 9247 +9248 9248 EBACB1 9248 +9249 9249 EBACB2 9249 +924A 924A EBACB3 924A +924B 924B EBACB7 924B +924C 924C EBACB9 924C +924D 924D EBACBA 924D +924E 924E EBACBF 924E +924F 924F EBAD80 924F +9250 9250 EBAD81 9250 +9251 9251 EBAD82 9251 +9252 9252 EBAD83 9252 +9253 9253 EBAD86 9253 +9254 9254 EBAD88 9254 +9255 9255 EBAD8A 9255 +9256 9256 EBAD8B 9256 +9257 9257 EBAD8C 9257 +9258 9258 EBAD8E 9258 +9259 9259 EBAD91 9259 +925A 925A EBAD92 925A +9261 9261 EBAD93 9261 +9262 9262 EBAD95 9262 +9263 9263 EBAD96 9263 +9264 9264 EBAD97 9264 +9265 9265 EBAD99 9265 +9266 9266 EBAD9A 9266 +9267 9267 EBAD9B 9267 +9268 9268 EBAD9C 9268 +9269 9269 EBAD9D 9269 +926A 926A EBAD9E 926A +926B 926B EBAD9F 926B +926C 926C EBADA0 926C +926D 926D EBADA2 926D +926E 926E EBADA4 926E +926F 926F EBADA5 926F +9270 9270 EBADA6 9270 +9271 9271 EBADA7 9271 +9272 9272 EBADA8 9272 +9273 9273 EBADA9 9273 +9274 9274 EBADAA 9274 +9275 9275 EBADAB 9275 +9276 9276 EBADAD 9276 +9277 9277 EBADAE 9277 +9278 9278 EBADAF 9278 +9279 9279 EBADB0 9279 +927A 927A EBADB1 927A +9281 9281 EBADB2 9281 +9282 9282 EBADB3 9282 +9283 9283 EBADB4 9283 +9284 9284 EBADB5 9284 +9285 9285 EBADB6 9285 +9286 9286 EBADB7 9286 +9287 9287 EBADB8 9287 +9288 9288 EBADB9 9288 +9289 9289 EBADBA 9289 +928A 928A EBADBB 928A +928B 928B EBADBC 928B +928C 928C EBADBD 928C +928D 928D EBADBE 928D +928E 928E EBADBF 928E +928F 928F EBAE80 928F +9290 9290 EBAE81 9290 +9291 9291 EBAE82 9291 +9292 9292 EBAE83 9292 +9293 9293 EBAE84 9293 +9294 9294 EBAE85 9294 +9295 9295 EBAE86 9295 +9296 9296 EBAE87 9296 +9297 9297 EBAE89 9297 +9298 9298 EBAE8A 9298 +9299 9299 EBAE8B 9299 +929A 929A EBAE8D 929A +929B 929B EBAE8E 929B +929C 929C EBAE8F 929C +929D 929D EBAE91 929D +929E 929E EBAE92 929E +929F 929F EBAE93 929F +92A0 92A0 EBAE94 92A0 +92A1 92A1 EBAE95 92A1 +92A2 92A2 EBAE96 92A2 +92A3 92A3 EBAE97 92A3 +92A4 92A4 EBAE98 92A4 +92A5 92A5 EBAE99 92A5 +92A6 92A6 EBAE9A 92A6 +92A7 92A7 EBAE9B 92A7 +92A8 92A8 EBAE9C 92A8 +92A9 92A9 EBAE9D 92A9 +92AA 92AA EBAE9E 92AA +92AB 92AB EBAE9F 92AB +92AC 92AC EBAEA0 92AC +92AD 92AD EBAEA1 92AD +92AE 92AE EBAEA2 92AE +92AF 92AF EBAEA3 92AF +92B0 92B0 EBAEA5 92B0 +92B1 92B1 EBAEA6 92B1 +92B2 92B2 EBAEA7 92B2 +92B3 92B3 EBAEA9 92B3 +92B4 92B4 EBAEAA 92B4 +92B5 92B5 EBAEAB 92B5 +92B6 92B6 EBAEAD 92B6 +92B7 92B7 EBAEAE 92B7 +92B8 92B8 EBAEAF 92B8 +92B9 92B9 EBAEB0 92B9 +92BA 92BA EBAEB1 92BA +92BB 92BB EBAEB2 92BB +92BC 92BC EBAEB3 92BC +92BD 92BD EBAEB5 92BD +92BE 92BE EBAEB6 92BE +92BF 92BF EBAEB8 92BF +92C0 92C0 EBAEB9 92C0 +92C1 92C1 EBAEBA 92C1 +92C2 92C2 EBAEBB 92C2 +92C3 92C3 EBAEBC 92C3 +92C4 92C4 EBAEBD 92C4 +92C5 92C5 EBAEBE 92C5 +92C6 92C6 EBAEBF 92C6 +92C7 92C7 EBAF81 92C7 +92C8 92C8 EBAF82 92C8 +92C9 92C9 EBAF83 92C9 +92CA 92CA EBAF85 92CA +92CB 92CB EBAF86 92CB +92CC 92CC EBAF87 92CC +92CD 92CD EBAF89 92CD +92CE 92CE EBAF8A 92CE +92CF 92CF EBAF8B 92CF +92D0 92D0 EBAF8C 92D0 +92D1 92D1 EBAF8D 92D1 +92D2 92D2 EBAF8E 92D2 +92D3 92D3 EBAF8F 92D3 +92D4 92D4 EBAF91 92D4 +92D5 92D5 EBAF92 92D5 +92D6 92D6 EBAF94 92D6 +92D7 92D7 EBAF95 92D7 +92D8 92D8 EBAF96 92D8 +92D9 92D9 EBAF97 92D9 +92DA 92DA EBAF98 92DA +92DB 92DB EBAF99 92DB +92DC 92DC EBAF9A 92DC +92DD 92DD EBAF9B 92DD +92DE 92DE EBAF9C 92DE +92DF 92DF EBAF9D 92DF +92E0 92E0 EBAF9E 92E0 +92E1 92E1 EBAF9F 92E1 +92E2 92E2 EBAFA0 92E2 +92E3 92E3 EBAFA1 92E3 +92E4 92E4 EBAFA2 92E4 +92E5 92E5 EBAFA3 92E5 +92E6 92E6 EBAFA4 92E6 +92E7 92E7 EBAFA5 92E7 +92E8 92E8 EBAFA6 92E8 +92E9 92E9 EBAFA7 92E9 +92EA 92EA EBAFA8 92EA +92EB 92EB EBAFA9 92EB +92EC 92EC EBAFAA 92EC +92ED 92ED EBAFAB 92ED +92EE 92EE EBAFAC 92EE +92EF 92EF EBAFAD 92EF +92F0 92F0 EBAFAE 92F0 +92F1 92F1 EBAFAF 92F1 +92F2 92F2 EBAFB0 92F2 +92F3 92F3 EBAFB1 92F3 +92F4 92F4 EBAFB2 92F4 +92F5 92F5 EBAFB3 92F5 +92F6 92F6 EBAFB4 92F6 +92F7 92F7 EBAFB5 92F7 +92F8 92F8 EBAFB6 92F8 +92F9 92F9 EBAFB7 92F9 +92FA 92FA EBAFBA 92FA +92FB 92FB EBAFBB 92FB +92FC 92FC EBAFBD 92FC +92FD 92FD EBAFBE 92FD +92FE 92FE EBB081 92FE +9341 9341 EBB083 9341 +9342 9342 EBB084 9342 +9343 9343 EBB085 9343 +9344 9344 EBB086 9344 +9345 9345 EBB087 9345 +9346 9346 EBB08A 9346 +9347 9347 EBB08E 9347 +9348 9348 EBB090 9348 +9349 9349 EBB092 9349 +934A 934A EBB093 934A +934B 934B EBB099 934B +934C 934C EBB09A 934C +934D 934D EBB0A0 934D +934E 934E EBB0A1 934E +934F 934F EBB0A2 934F +9350 9350 EBB0A3 9350 +9351 9351 EBB0A6 9351 +9352 9352 EBB0A8 9352 +9353 9353 EBB0AA 9353 +9354 9354 EBB0AB 9354 +9355 9355 EBB0AC 9355 +9356 9356 EBB0AE 9356 +9357 9357 EBB0AF 9357 +9358 9358 EBB0B2 9358 +9359 9359 EBB0B3 9359 +935A 935A EBB0B5 935A +9361 9361 EBB0B6 9361 +9362 9362 EBB0B7 9362 +9363 9363 EBB0B9 9363 +9364 9364 EBB0BA 9364 +9365 9365 EBB0BB 9365 +9366 9366 EBB0BC 9366 +9367 9367 EBB0BD 9367 +9368 9368 EBB0BE 9368 +9369 9369 EBB0BF 9369 +936A 936A EBB182 936A +936B 936B EBB186 936B +936C 936C EBB187 936C +936D 936D EBB188 936D +936E 936E EBB18A 936E +936F 936F EBB18B 936F +9370 9370 EBB18E 9370 +9371 9371 EBB18F 9371 +9372 9372 EBB191 9372 +9373 9373 EBB192 9373 +9374 9374 EBB193 9374 +9375 9375 EBB194 9375 +9376 9376 EBB195 9376 +9377 9377 EBB196 9377 +9378 9378 EBB197 9378 +9379 9379 EBB198 9379 +937A 937A EBB199 937A +9381 9381 EBB19A 9381 +9382 9382 EBB19B 9382 +9383 9383 EBB19C 9383 +9384 9384 EBB19E 9384 +9385 9385 EBB19F 9385 +9386 9386 EBB1A0 9386 +9387 9387 EBB1A1 9387 +9388 9388 EBB1A2 9388 +9389 9389 EBB1A3 9389 +938A 938A EBB1A4 938A +938B 938B EBB1A5 938B +938C 938C EBB1A6 938C +938D 938D EBB1A7 938D +938E 938E EBB1A8 938E +938F 938F EBB1A9 938F +9390 9390 EBB1AA 9390 +9391 9391 EBB1AB 9391 +9392 9392 EBB1AC 9392 +9393 9393 EBB1AD 9393 +9394 9394 EBB1AE 9394 +9395 9395 EBB1AF 9395 +9396 9396 EBB1B0 9396 +9397 9397 EBB1B1 9397 +9398 9398 EBB1B2 9398 +9399 9399 EBB1B3 9399 +939A 939A EBB1B4 939A +939B 939B EBB1B5 939B +939C 939C EBB1B6 939C +939D 939D EBB1B7 939D +939E 939E EBB1B8 939E +939F 939F EBB1B9 939F +93A0 93A0 EBB1BA 93A0 +93A1 93A1 EBB1BB 93A1 +93A2 93A2 EBB1BC 93A2 +93A3 93A3 EBB1BD 93A3 +93A4 93A4 EBB1BE 93A4 +93A5 93A5 EBB1BF 93A5 +93A6 93A6 EBB280 93A6 +93A7 93A7 EBB281 93A7 +93A8 93A8 EBB282 93A8 +93A9 93A9 EBB283 93A9 +93AA 93AA EBB286 93AA +93AB 93AB EBB287 93AB +93AC 93AC EBB289 93AC +93AD 93AD EBB28A 93AD +93AE 93AE EBB28D 93AE +93AF 93AF EBB28F 93AF +93B0 93B0 EBB290 93B0 +93B1 93B1 EBB291 93B1 +93B2 93B2 EBB292 93B2 +93B3 93B3 EBB293 93B3 +93B4 93B4 EBB296 93B4 +93B5 93B5 EBB298 93B5 +93B6 93B6 EBB29B 93B6 +93B7 93B7 EBB29C 93B7 +93B8 93B8 EBB29D 93B8 +93B9 93B9 EBB29E 93B9 +93BA 93BA EBB29F 93BA +93BB 93BB EBB2A2 93BB +93BC 93BC EBB2A3 93BC +93BD 93BD EBB2A5 93BD +93BE 93BE EBB2A6 93BE +93BF 93BF EBB2A9 93BF +93C0 93C0 EBB2AA 93C0 +93C1 93C1 EBB2AB 93C1 +93C2 93C2 EBB2AC 93C2 +93C3 93C3 EBB2AD 93C3 +93C4 93C4 EBB2AE 93C4 +93C5 93C5 EBB2AF 93C5 +93C6 93C6 EBB2B2 93C6 +93C7 93C7 EBB2B6 93C7 +93C8 93C8 EBB2B7 93C8 +93C9 93C9 EBB2B8 93C9 +93CA 93CA EBB2B9 93CA +93CB 93CB EBB2BA 93CB +93CC 93CC EBB2BB 93CC +93CD 93CD EBB2BE 93CD +93CE 93CE EBB2BF 93CE +93CF 93CF EBB381 93CF +93D0 93D0 EBB382 93D0 +93D1 93D1 EBB383 93D1 +93D2 93D2 EBB385 93D2 +93D3 93D3 EBB386 93D3 +93D4 93D4 EBB387 93D4 +93D5 93D5 EBB388 93D5 +93D6 93D6 EBB389 93D6 +93D7 93D7 EBB38A 93D7 +93D8 93D8 EBB38B 93D8 +93D9 93D9 EBB38C 93D9 +93DA 93DA EBB38E 93DA +93DB 93DB EBB392 93DB +93DC 93DC EBB393 93DC +93DD 93DD EBB394 93DD +93DE 93DE EBB396 93DE +93DF 93DF EBB397 93DF +93E0 93E0 EBB399 93E0 +93E1 93E1 EBB39A 93E1 +93E2 93E2 EBB39B 93E2 +93E3 93E3 EBB39D 93E3 +93E4 93E4 EBB39E 93E4 +93E5 93E5 EBB39F 93E5 +93E6 93E6 EBB3A0 93E6 +93E7 93E7 EBB3A1 93E7 +93E8 93E8 EBB3A2 93E8 +93E9 93E9 EBB3A3 93E9 +93EA 93EA EBB3A4 93EA +93EB 93EB EBB3A5 93EB +93EC 93EC EBB3A6 93EC +93ED 93ED EBB3A7 93ED +93EE 93EE EBB3A8 93EE +93EF 93EF EBB3A9 93EF +93F0 93F0 EBB3AA 93F0 +93F1 93F1 EBB3AB 93F1 +93F2 93F2 EBB3AC 93F2 +93F3 93F3 EBB3AD 93F3 +93F4 93F4 EBB3AE 93F4 +93F5 93F5 EBB3AF 93F5 +93F6 93F6 EBB3B0 93F6 +93F7 93F7 EBB3B1 93F7 +93F8 93F8 EBB3B2 93F8 +93F9 93F9 EBB3B3 93F9 +93FA 93FA EBB3B7 93FA +93FB 93FB EBB3B9 93FB +93FC 93FC EBB3BA 93FC +93FD 93FD EBB3BB 93FD +93FE 93FE EBB3BD 93FE +9441 9441 EBB3BE 9441 +9442 9442 EBB3BF 9442 +9443 9443 EBB480 9443 +9444 9444 EBB481 9444 +9445 9445 EBB482 9445 +9446 9446 EBB483 9446 +9447 9447 EBB486 9447 +9448 9448 EBB488 9448 +9449 9449 EBB48A 9449 +944A 944A EBB48B 944A +944B 944B EBB48C 944B +944C 944C EBB48D 944C +944D 944D EBB48E 944D +944E 944E EBB48F 944E +944F 944F EBB491 944F +9450 9450 EBB492 9450 +9451 9451 EBB493 9451 +9452 9452 EBB495 9452 +9453 9453 EBB496 9453 +9454 9454 EBB497 9454 +9455 9455 EBB498 9455 +9456 9456 EBB499 9456 +9457 9457 EBB49A 9457 +9458 9458 EBB49B 9458 +9459 9459 EBB49C 9459 +945A 945A EBB49D 945A +9461 9461 EBB49E 9461 +9462 9462 EBB49F 9462 +9463 9463 EBB4A0 9463 +9464 9464 EBB4A1 9464 +9465 9465 EBB4A2 9465 +9466 9466 EBB4A3 9466 +9467 9467 EBB4A5 9467 +9468 9468 EBB4A6 9468 +9469 9469 EBB4A7 9469 +946A 946A EBB4A8 946A +946B 946B EBB4A9 946B +946C 946C EBB4AA 946C +946D 946D EBB4AB 946D +946E 946E EBB4AD 946E +946F 946F EBB4AE 946F +9470 9470 EBB4AF 9470 +9471 9471 EBB4B0 9471 +9472 9472 EBB4B1 9472 +9473 9473 EBB4B2 9473 +9474 9474 EBB4B3 9474 +9475 9475 EBB4B4 9475 +9476 9476 EBB4B5 9476 +9477 9477 EBB4B6 9477 +9478 9478 EBB4B7 9478 +9479 9479 EBB4B8 9479 +947A 947A EBB4B9 947A +9481 9481 EBB4BA 9481 +9482 9482 EBB4BB 9482 +9483 9483 EBB4BC 9483 +9484 9484 EBB4BD 9484 +9485 9485 EBB4BE 9485 +9486 9486 EBB4BF 9486 +9487 9487 EBB581 9487 +9488 9488 EBB582 9488 +9489 9489 EBB583 9489 +948A 948A EBB584 948A +948B 948B EBB585 948B +948C 948C EBB586 948C +948D 948D EBB587 948D +948E 948E EBB58A 948E +948F 948F EBB58B 948F +9490 9490 EBB58D 9490 +9491 9491 EBB58E 9491 +9492 9492 EBB58F 9492 +9493 9493 EBB591 9493 +9494 9494 EBB592 9494 +9495 9495 EBB593 9495 +9496 9496 EBB594 9496 +9497 9497 EBB595 9497 +9498 9498 EBB596 9498 +9499 9499 EBB597 9499 +949A 949A EBB59A 949A +949B 949B EBB59B 949B +949C 949C EBB59C 949C +949D 949D EBB59D 949D +949E 949E EBB59E 949E +949F 949F EBB59F 949F +94A0 94A0 EBB5A0 94A0 +94A1 94A1 EBB5A1 94A1 +94A2 94A2 EBB5A2 94A2 +94A3 94A3 EBB5A3 94A3 +94A4 94A4 EBB5A5 94A4 +94A5 94A5 EBB5A6 94A5 +94A6 94A6 EBB5A7 94A6 +94A7 94A7 EBB5A9 94A7 +94A8 94A8 EBB5AA 94A8 +94A9 94A9 EBB5AB 94A9 +94AA 94AA EBB5AC 94AA +94AB 94AB EBB5AD 94AB +94AC 94AC EBB5AE 94AC +94AD 94AD EBB5AF 94AD +94AE 94AE EBB5B0 94AE +94AF 94AF EBB5B1 94AF +94B0 94B0 EBB5B2 94B0 +94B1 94B1 EBB5B3 94B1 +94B2 94B2 EBB5B4 94B2 +94B3 94B3 EBB5B5 94B3 +94B4 94B4 EBB5B6 94B4 +94B5 94B5 EBB5B7 94B5 +94B6 94B6 EBB5B8 94B6 +94B7 94B7 EBB5B9 94B7 +94B8 94B8 EBB5BA 94B8 +94B9 94B9 EBB5BB 94B9 +94BA 94BA EBB5BC 94BA +94BB 94BB EBB5BD 94BB +94BC 94BC EBB5BE 94BC +94BD 94BD EBB5BF 94BD +94BE 94BE EBB682 94BE +94BF 94BF EBB683 94BF +94C0 94C0 EBB685 94C0 +94C1 94C1 EBB686 94C1 +94C2 94C2 EBB68B 94C2 +94C3 94C3 EBB68C 94C3 +94C4 94C4 EBB68D 94C4 +94C5 94C5 EBB68E 94C5 +94C6 94C6 EBB68F 94C6 +94C7 94C7 EBB692 94C7 +94C8 94C8 EBB694 94C8 +94C9 94C9 EBB696 94C9 +94CA 94CA EBB697 94CA +94CB 94CB EBB698 94CB +94CC 94CC EBB69B 94CC +94CD 94CD EBB69D 94CD +94CE 94CE EBB69E 94CE +94CF 94CF EBB69F 94CF +94D0 94D0 EBB6A0 94D0 +94D1 94D1 EBB6A1 94D1 +94D2 94D2 EBB6A2 94D2 +94D3 94D3 EBB6A3 94D3 +94D4 94D4 EBB6A5 94D4 +94D5 94D5 EBB6A6 94D5 +94D6 94D6 EBB6A7 94D6 +94D7 94D7 EBB6A8 94D7 +94D8 94D8 EBB6A9 94D8 +94D9 94D9 EBB6AA 94D9 +94DA 94DA EBB6AB 94DA +94DB 94DB EBB6AC 94DB +94DC 94DC EBB6AD 94DC +94DD 94DD EBB6AE 94DD +94DE 94DE EBB6AF 94DE +94DF 94DF EBB6B1 94DF +94E0 94E0 EBB6B2 94E0 +94E1 94E1 EBB6B3 94E1 +94E2 94E2 EBB6B4 94E2 +94E3 94E3 EBB6B5 94E3 +94E4 94E4 EBB6B6 94E4 +94E5 94E5 EBB6B7 94E5 +94E6 94E6 EBB6B9 94E6 +94E7 94E7 EBB6BA 94E7 +94E8 94E8 EBB6BB 94E8 +94E9 94E9 EBB6BC 94E9 +94EA 94EA EBB6BD 94EA +94EB 94EB EBB6BE 94EB +94EC 94EC EBB6BF 94EC +94ED 94ED EBB780 94ED +94EE 94EE EBB781 94EE +94EF 94EF EBB782 94EF +94F0 94F0 EBB783 94F0 +94F1 94F1 EBB784 94F1 +94F2 94F2 EBB785 94F2 +94F3 94F3 EBB786 94F3 +94F4 94F4 EBB787 94F4 +94F5 94F5 EBB788 94F5 +94F6 94F6 EBB789 94F6 +94F7 94F7 EBB78A 94F7 +94F8 94F8 EBB78B 94F8 +94F9 94F9 EBB78C 94F9 +94FA 94FA EBB78D 94FA +94FB 94FB EBB78E 94FB +94FC 94FC EBB78F 94FC +94FD 94FD EBB790 94FD +94FE 94FE EBB791 94FE +9541 9541 EBB792 9541 +9542 9542 EBB793 9542 +9543 9543 EBB796 9543 +9544 9544 EBB797 9544 +9545 9545 EBB799 9545 +9546 9546 EBB79A 9546 +9547 9547 EBB79B 9547 +9548 9548 EBB79D 9548 +9549 9549 EBB79E 9549 +954A 954A EBB79F 954A +954B 954B EBB7A0 954B +954C 954C EBB7A1 954C +954D 954D EBB7A2 954D +954E 954E EBB7A3 954E +954F 954F EBB7A4 954F +9550 9550 EBB7A5 9550 +9551 9551 EBB7A6 9551 +9552 9552 EBB7A7 9552 +9553 9553 EBB7A8 9553 +9554 9554 EBB7AA 9554 +9555 9555 EBB7AB 9555 +9556 9556 EBB7AC 9556 +9557 9557 EBB7AD 9557 +9558 9558 EBB7AE 9558 +9559 9559 EBB7AF 9559 +955A 955A EBB7B1 955A +9561 9561 EBB7B2 9561 +9562 9562 EBB7B3 9562 +9563 9563 EBB7B5 9563 +9564 9564 EBB7B6 9564 +9565 9565 EBB7B7 9565 +9566 9566 EBB7B9 9566 +9567 9567 EBB7BA 9567 +9568 9568 EBB7BB 9568 +9569 9569 EBB7BC 9569 +956A 956A EBB7BD 956A +956B 956B EBB7BE 956B +956C 956C EBB7BF 956C +956D 956D EBB881 956D +956E 956E EBB882 956E +956F 956F EBB884 956F +9570 9570 EBB886 9570 +9571 9571 EBB887 9571 +9572 9572 EBB888 9572 +9573 9573 EBB889 9573 +9574 9574 EBB88A 9574 +9575 9575 EBB88B 9575 +9576 9576 EBB88E 9576 +9577 9577 EBB88F 9577 +9578 9578 EBB891 9578 +9579 9579 EBB892 9579 +957A 957A EBB893 957A +9581 9581 EBB895 9581 +9582 9582 EBB896 9582 +9583 9583 EBB897 9583 +9584 9584 EBB898 9584 +9585 9585 EBB899 9585 +9586 9586 EBB89A 9586 +9587 9587 EBB89B 9587 +9588 9588 EBB89E 9588 +9589 9589 EBB8A0 9589 +958A 958A EBB8A1 958A +958B 958B EBB8A2 958B +958C 958C EBB8A3 958C +958D 958D EBB8A4 958D +958E 958E EBB8A5 958E +958F 958F EBB8A6 958F +9590 9590 EBB8A7 9590 +9591 9591 EBB8A8 9591 +9592 9592 EBB8A9 9592 +9593 9593 EBB8AA 9593 +9594 9594 EBB8AB 9594 +9595 9595 EBB8AC 9595 +9596 9596 EBB8AD 9596 +9597 9597 EBB8AE 9597 +9598 9598 EBB8AF 9598 +9599 9599 EBB8B0 9599 +959A 959A EBB8B1 959A +959B 959B EBB8B2 959B +959C 959C EBB8B3 959C +959D 959D EBB8B4 959D +959E 959E EBB8B5 959E +959F 959F EBB8B6 959F +95A0 95A0 EBB8B7 95A0 +95A1 95A1 EBB8B8 95A1 +95A2 95A2 EBB8B9 95A2 +95A3 95A3 EBB8BA 95A3 +95A4 95A4 EBB8BB 95A4 +95A5 95A5 EBB8BC 95A5 +95A6 95A6 EBB8BD 95A6 +95A7 95A7 EBB8BE 95A7 +95A8 95A8 EBB8BF 95A8 +95A9 95A9 EBB980 95A9 +95AA 95AA EBB981 95AA +95AB 95AB EBB982 95AB +95AC 95AC EBB983 95AC +95AD 95AD EBB986 95AD +95AE 95AE EBB987 95AE +95AF 95AF EBB989 95AF +95B0 95B0 EBB98A 95B0 +95B1 95B1 EBB98B 95B1 +95B2 95B2 EBB98D 95B2 +95B3 95B3 EBB98F 95B3 +95B4 95B4 EBB990 95B4 +95B5 95B5 EBB991 95B5 +95B6 95B6 EBB992 95B6 +95B7 95B7 EBB993 95B7 +95B8 95B8 EBB996 95B8 +95B9 95B9 EBB998 95B9 +95BA 95BA EBB99C 95BA +95BB 95BB EBB99D 95BB +95BC 95BC EBB99E 95BC +95BD 95BD EBB99F 95BD +95BE 95BE EBB9A2 95BE +95BF 95BF EBB9A3 95BF +95C0 95C0 EBB9A5 95C0 +95C1 95C1 EBB9A6 95C1 +95C2 95C2 EBB9A7 95C2 +95C3 95C3 EBB9A9 95C3 +95C4 95C4 EBB9AB 95C4 +95C5 95C5 EBB9AC 95C5 +95C6 95C6 EBB9AD 95C6 +95C7 95C7 EBB9AE 95C7 +95C8 95C8 EBB9AF 95C8 +95C9 95C9 EBB9B2 95C9 +95CA 95CA EBB9B6 95CA +95CB 95CB EBB9B7 95CB +95CC 95CC EBB9B8 95CC +95CD 95CD EBB9B9 95CD +95CE 95CE EBB9BA 95CE +95CF 95CF EBB9BE 95CF +95D0 95D0 EBB9BF 95D0 +95D1 95D1 EBBA81 95D1 +95D2 95D2 EBBA82 95D2 +95D3 95D3 EBBA83 95D3 +95D4 95D4 EBBA85 95D4 +95D5 95D5 EBBA86 95D5 +95D6 95D6 EBBA87 95D6 +95D7 95D7 EBBA88 95D7 +95D8 95D8 EBBA89 95D8 +95D9 95D9 EBBA8A 95D9 +95DA 95DA EBBA8B 95DA +95DB 95DB EBBA8E 95DB +95DC 95DC EBBA92 95DC +95DD 95DD EBBA93 95DD +95DE 95DE EBBA94 95DE +95DF 95DF EBBA95 95DF +95E0 95E0 EBBA96 95E0 +95E1 95E1 EBBA97 95E1 +95E2 95E2 EBBA9A 95E2 +95E3 95E3 EBBA9B 95E3 +95E4 95E4 EBBA9C 95E4 +95E5 95E5 EBBA9D 95E5 +95E6 95E6 EBBA9E 95E6 +95E7 95E7 EBBA9F 95E7 +95E8 95E8 EBBAA0 95E8 +95E9 95E9 EBBAA1 95E9 +95EA 95EA EBBAA2 95EA +95EB 95EB EBBAA3 95EB +95EC 95EC EBBAA4 95EC +95ED 95ED EBBAA5 95ED +95EE 95EE EBBAA6 95EE +95EF 95EF EBBAA7 95EF +95F0 95F0 EBBAA9 95F0 +95F1 95F1 EBBAAA 95F1 +95F2 95F2 EBBAAB 95F2 +95F3 95F3 EBBAAC 95F3 +95F4 95F4 EBBAAD 95F4 +95F5 95F5 EBBAAE 95F5 +95F6 95F6 EBBAAF 95F6 +95F7 95F7 EBBAB0 95F7 +95F8 95F8 EBBAB1 95F8 +95F9 95F9 EBBAB2 95F9 +95FA 95FA EBBAB3 95FA +95FB 95FB EBBAB4 95FB +95FC 95FC EBBAB5 95FC +95FD 95FD EBBAB6 95FD +95FE 95FE EBBAB7 95FE +9641 9641 EBBAB8 9641 +9642 9642 EBBAB9 9642 +9643 9643 EBBABA 9643 +9644 9644 EBBABB 9644 +9645 9645 EBBABC 9645 +9646 9646 EBBABD 9646 +9647 9647 EBBABE 9647 +9648 9648 EBBABF 9648 +9649 9649 EBBB80 9649 +964A 964A EBBB81 964A +964B 964B EBBB82 964B +964C 964C EBBB83 964C +964D 964D EBBB84 964D +964E 964E EBBB85 964E +964F 964F EBBB86 964F +9650 9650 EBBB87 9650 +9651 9651 EBBB88 9651 +9652 9652 EBBB89 9652 +9653 9653 EBBB8A 9653 +9654 9654 EBBB8B 9654 +9655 9655 EBBB8C 9655 +9656 9656 EBBB8D 9656 +9657 9657 EBBB8E 9657 +9658 9658 EBBB8F 9658 +9659 9659 EBBB92 9659 +965A 965A EBBB93 965A +9661 9661 EBBB95 9661 +9662 9662 EBBB96 9662 +9663 9663 EBBB99 9663 +9664 9664 EBBB9A 9664 +9665 9665 EBBB9B 9665 +9666 9666 EBBB9C 9666 +9667 9667 EBBB9D 9667 +9668 9668 EBBB9E 9668 +9669 9669 EBBB9F 9669 +966A 966A EBBBA1 966A +966B 966B EBBBA2 966B +966C 966C EBBBA6 966C +966D 966D EBBBA7 966D +966E 966E EBBBA8 966E +966F 966F EBBBA9 966F +9670 9670 EBBBAA 9670 +9671 9671 EBBBAB 9671 +9672 9672 EBBBAD 9672 +9673 9673 EBBBAE 9673 +9674 9674 EBBBAF 9674 +9675 9675 EBBBB0 9675 +9676 9676 EBBBB1 9676 +9677 9677 EBBBB2 9677 +9678 9678 EBBBB3 9678 +9679 9679 EBBBB4 9679 +967A 967A EBBBB5 967A +9681 9681 EBBBB6 9681 +9682 9682 EBBBB7 9682 +9683 9683 EBBBB8 9683 +9684 9684 EBBBB9 9684 +9685 9685 EBBBBA 9685 +9686 9686 EBBBBB 9686 +9687 9687 EBBBBC 9687 +9688 9688 EBBBBD 9688 +9689 9689 EBBBBE 9689 +968A 968A EBBBBF 968A +968B 968B EBBC80 968B +968C 968C EBBC82 968C +968D 968D EBBC83 968D +968E 968E EBBC84 968E +968F 968F EBBC85 968F +9690 9690 EBBC86 9690 +9691 9691 EBBC87 9691 +9692 9692 EBBC8A 9692 +9693 9693 EBBC8B 9693 +9694 9694 EBBC8C 9694 +9695 9695 EBBC8D 9695 +9696 9696 EBBC8E 9696 +9697 9697 EBBC8F 9697 +9698 9698 EBBC90 9698 +9699 9699 EBBC91 9699 +969A 969A EBBC92 969A +969B 969B EBBC93 969B +969C 969C EBBC94 969C +969D 969D EBBC95 969D +969E 969E EBBC96 969E +969F 969F EBBC97 969F +96A0 96A0 EBBC9A 96A0 +96A1 96A1 EBBC9E 96A1 +96A2 96A2 EBBC9F 96A2 +96A3 96A3 EBBCA0 96A3 +96A4 96A4 EBBCA1 96A4 +96A5 96A5 EBBCA2 96A5 +96A6 96A6 EBBCA3 96A6 +96A7 96A7 EBBCA4 96A7 +96A8 96A8 EBBCA5 96A8 +96A9 96A9 EBBCA6 96A9 +96AA 96AA EBBCA7 96AA +96AB 96AB EBBCA8 96AB +96AC 96AC EBBCA9 96AC +96AD 96AD EBBCAA 96AD +96AE 96AE EBBCAB 96AE +96AF 96AF EBBCAC 96AF +96B0 96B0 EBBCAD 96B0 +96B1 96B1 EBBCAE 96B1 +96B2 96B2 EBBCAF 96B2 +96B3 96B3 EBBCB0 96B3 +96B4 96B4 EBBCB1 96B4 +96B5 96B5 EBBCB2 96B5 +96B6 96B6 EBBCB3 96B6 +96B7 96B7 EBBCB4 96B7 +96B8 96B8 EBBCB5 96B8 +96B9 96B9 EBBCB6 96B9 +96BA 96BA EBBCB7 96BA +96BB 96BB EBBCB8 96BB +96BC 96BC EBBCB9 96BC +96BD 96BD EBBCBA 96BD +96BE 96BE EBBCBB 96BE +96BF 96BF EBBCBC 96BF +96C0 96C0 EBBCBD 96C0 +96C1 96C1 EBBCBE 96C1 +96C2 96C2 EBBCBF 96C2 +96C3 96C3 EBBD82 96C3 +96C4 96C4 EBBD83 96C4 +96C5 96C5 EBBD85 96C5 +96C6 96C6 EBBD86 96C6 +96C7 96C7 EBBD87 96C7 +96C8 96C8 EBBD89 96C8 +96C9 96C9 EBBD8A 96C9 +96CA 96CA EBBD8B 96CA +96CB 96CB EBBD8C 96CB +96CC 96CC EBBD8D 96CC +96CD 96CD EBBD8E 96CD +96CE 96CE EBBD8F 96CE +96CF 96CF EBBD92 96CF +96D0 96D0 EBBD93 96D0 +96D1 96D1 EBBD94 96D1 +96D2 96D2 EBBD96 96D2 +96D3 96D3 EBBD97 96D3 +96D4 96D4 EBBD98 96D4 +96D5 96D5 EBBD99 96D5 +96D6 96D6 EBBD9A 96D6 +96D7 96D7 EBBD9B 96D7 +96D8 96D8 EBBD9C 96D8 +96D9 96D9 EBBD9D 96D9 +96DA 96DA EBBD9E 96DA +96DB 96DB EBBD9F 96DB +96DC 96DC EBBDA0 96DC +96DD 96DD EBBDA1 96DD +96DE 96DE EBBDA2 96DE +96DF 96DF EBBDA3 96DF +96E0 96E0 EBBDA4 96E0 +96E1 96E1 EBBDA5 96E1 +96E2 96E2 EBBDA6 96E2 +96E3 96E3 EBBDA7 96E3 +96E4 96E4 EBBDA8 96E4 +96E5 96E5 EBBDA9 96E5 +96E6 96E6 EBBDAA 96E6 +96E7 96E7 EBBDAB 96E7 +96E8 96E8 EBBDAC 96E8 +96E9 96E9 EBBDAD 96E9 +96EA 96EA EBBDAE 96EA +96EB 96EB EBBDAF 96EB +96EC 96EC EBBDB0 96EC +96ED 96ED EBBDB1 96ED +96EE 96EE EBBDB2 96EE +96EF 96EF EBBDB3 96EF +96F0 96F0 EBBDB4 96F0 +96F1 96F1 EBBDB5 96F1 +96F2 96F2 EBBDB6 96F2 +96F3 96F3 EBBDB7 96F3 +96F4 96F4 EBBDB8 96F4 +96F5 96F5 EBBDB9 96F5 +96F6 96F6 EBBDBA 96F6 +96F7 96F7 EBBDBB 96F7 +96F8 96F8 EBBDBC 96F8 +96F9 96F9 EBBDBD 96F9 +96FA 96FA EBBDBE 96FA +96FB 96FB EBBDBF 96FB +96FC 96FC EBBE80 96FC +96FD 96FD EBBE81 96FD +96FE 96FE EBBE82 96FE +9741 9741 EBBE83 9741 +9742 9742 EBBE84 9742 +9743 9743 EBBE85 9743 +9744 9744 EBBE86 9744 +9745 9745 EBBE87 9745 +9746 9746 EBBE88 9746 +9747 9747 EBBE89 9747 +9748 9748 EBBE8A 9748 +9749 9749 EBBE8B 9749 +974A 974A EBBE8C 974A +974B 974B EBBE8D 974B +974C 974C EBBE8E 974C +974D 974D EBBE8F 974D +974E 974E EBBE90 974E +974F 974F EBBE91 974F +9750 9750 EBBE92 9750 +9751 9751 EBBE93 9751 +9752 9752 EBBE95 9752 +9753 9753 EBBE96 9753 +9754 9754 EBBE97 9754 +9755 9755 EBBE98 9755 +9756 9756 EBBE99 9756 +9757 9757 EBBE9A 9757 +9758 9758 EBBE9B 9758 +9759 9759 EBBE9C 9759 +975A 975A EBBE9D 975A +9761 9761 EBBE9E 9761 +9762 9762 EBBE9F 9762 +9763 9763 EBBEA0 9763 +9764 9764 EBBEA1 9764 +9765 9765 EBBEA2 9765 +9766 9766 EBBEA3 9766 +9767 9767 EBBEA4 9767 +9768 9768 EBBEA5 9768 +9769 9769 EBBEA6 9769 +976A 976A EBBEA7 976A +976B 976B EBBEA8 976B +976C 976C EBBEA9 976C +976D 976D EBBEAA 976D +976E 976E EBBEAB 976E +976F 976F EBBEAC 976F +9770 9770 EBBEAD 9770 +9771 9771 EBBEAE 9771 +9772 9772 EBBEAF 9772 +9773 9773 EBBEB1 9773 +9774 9774 EBBEB2 9774 +9775 9775 EBBEB3 9775 +9776 9776 EBBEB4 9776 +9777 9777 EBBEB5 9777 +9778 9778 EBBEB6 9778 +9779 9779 EBBEB7 9779 +977A 977A EBBEB8 977A +9781 9781 EBBEB9 9781 +9782 9782 EBBEBA 9782 +9783 9783 EBBEBB 9783 +9784 9784 EBBEBC 9784 +9785 9785 EBBEBD 9785 +9786 9786 EBBEBE 9786 +9787 9787 EBBEBF 9787 +9788 9788 EBBF80 9788 +9789 9789 EBBF81 9789 +978A 978A EBBF82 978A +978B 978B EBBF83 978B +978C 978C EBBF84 978C +978D 978D EBBF86 978D +978E 978E EBBF87 978E +978F 978F EBBF88 978F +9790 9790 EBBF89 9790 +9791 9791 EBBF8A 9791 +9792 9792 EBBF8B 9792 +9793 9793 EBBF8E 9793 +9794 9794 EBBF8F 9794 +9795 9795 EBBF91 9795 +9796 9796 EBBF92 9796 +9797 9797 EBBF93 9797 +9798 9798 EBBF95 9798 +9799 9799 EBBF96 9799 +979A 979A EBBF97 979A +979B 979B EBBF98 979B +979C 979C EBBF99 979C +979D 979D EBBF9A 979D +979E 979E EBBF9B 979E +979F 979F EBBF9D 979F +97A0 97A0 EBBF9E 97A0 +97A1 97A1 EBBFA0 97A1 +97A2 97A2 EBBFA2 97A2 +97A3 97A3 EBBFA3 97A3 +97A4 97A4 EBBFA4 97A4 +97A5 97A5 EBBFA5 97A5 +97A6 97A6 EBBFA6 97A6 +97A7 97A7 EBBFA7 97A7 +97A8 97A8 EBBFA8 97A8 +97A9 97A9 EBBFA9 97A9 +97AA 97AA EBBFAA 97AA +97AB 97AB EBBFAB 97AB +97AC 97AC EBBFAC 97AC +97AD 97AD EBBFAD 97AD +97AE 97AE EBBFAE 97AE +97AF 97AF EBBFAF 97AF +97B0 97B0 EBBFB0 97B0 +97B1 97B1 EBBFB1 97B1 +97B2 97B2 EBBFB2 97B2 +97B3 97B3 EBBFB3 97B3 +97B4 97B4 EBBFB4 97B4 +97B5 97B5 EBBFB5 97B5 +97B6 97B6 EBBFB6 97B6 +97B7 97B7 EBBFB7 97B7 +97B8 97B8 EBBFB8 97B8 +97B9 97B9 EBBFB9 97B9 +97BA 97BA EBBFBA 97BA +97BB 97BB EBBFBB 97BB +97BC 97BC EBBFBC 97BC +97BD 97BD EBBFBD 97BD +97BE 97BE EBBFBE 97BE +97BF 97BF EBBFBF 97BF +97C0 97C0 EC8080 97C0 +97C1 97C1 EC8081 97C1 +97C2 97C2 EC8082 97C2 +97C3 97C3 EC8083 97C3 +97C4 97C4 EC8084 97C4 +97C5 97C5 EC8085 97C5 +97C6 97C6 EC8086 97C6 +97C7 97C7 EC8087 97C7 +97C8 97C8 EC8088 97C8 +97C9 97C9 EC8089 97C9 +97CA 97CA EC808A 97CA +97CB 97CB EC808B 97CB +97CC 97CC EC808C 97CC +97CD 97CD EC808D 97CD +97CE 97CE EC808E 97CE +97CF 97CF EC808F 97CF +97D0 97D0 EC8090 97D0 +97D1 97D1 EC8091 97D1 +97D2 97D2 EC8092 97D2 +97D3 97D3 EC8093 97D3 +97D4 97D4 EC8094 97D4 +97D5 97D5 EC8095 97D5 +97D6 97D6 EC8096 97D6 +97D7 97D7 EC8097 97D7 +97D8 97D8 EC8098 97D8 +97D9 97D9 EC8099 97D9 +97DA 97DA EC809A 97DA +97DB 97DB EC809B 97DB +97DC 97DC EC809C 97DC +97DD 97DD EC809D 97DD +97DE 97DE EC809E 97DE +97DF 97DF EC809F 97DF +97E0 97E0 EC80A0 97E0 +97E1 97E1 EC80A1 97E1 +97E2 97E2 EC80A2 97E2 +97E3 97E3 EC80A3 97E3 +97E4 97E4 EC80A4 97E4 +97E5 97E5 EC80A5 97E5 +97E6 97E6 EC80A6 97E6 +97E7 97E7 EC80A7 97E7 +97E8 97E8 EC80A8 97E8 +97E9 97E9 EC80A9 97E9 +97EA 97EA EC80AA 97EA +97EB 97EB EC80AB 97EB +97EC 97EC EC80AC 97EC +97ED 97ED EC80AD 97ED +97EE 97EE EC80AE 97EE +97EF 97EF EC80AF 97EF +97F0 97F0 EC80B0 97F0 +97F1 97F1 EC80B1 97F1 +97F2 97F2 EC80B2 97F2 +97F3 97F3 EC80B3 97F3 +97F4 97F4 EC80B4 97F4 +97F5 97F5 EC80B5 97F5 +97F6 97F6 EC80B6 97F6 +97F7 97F7 EC80B7 97F7 +97F8 97F8 EC80B8 97F8 +97F9 97F9 EC80B9 97F9 +97FA 97FA EC80BA 97FA +97FB 97FB EC80BB 97FB +97FC 97FC EC80BD 97FC +97FD 97FD EC80BE 97FD +97FE 97FE EC80BF 97FE +9841 9841 EC8180 9841 +9842 9842 EC8181 9842 +9843 9843 EC8182 9843 +9844 9844 EC8183 9844 +9845 9845 EC8184 9845 +9846 9846 EC8185 9846 +9847 9847 EC8186 9847 +9848 9848 EC8187 9848 +9849 9849 EC8188 9849 +984A 984A EC8189 984A +984B 984B EC818A 984B +984C 984C EC818B 984C +984D 984D EC818C 984D +984E 984E EC818D 984E +984F 984F EC818E 984F +9850 9850 EC818F 9850 +9851 9851 EC8190 9851 +9852 9852 EC8192 9852 +9853 9853 EC8193 9853 +9854 9854 EC8194 9854 +9855 9855 EC8195 9855 +9856 9856 EC8196 9856 +9857 9857 EC8197 9857 +9858 9858 EC8199 9858 +9859 9859 EC819A 9859 +985A 985A EC819B 985A +9861 9861 EC819D 9861 +9862 9862 EC819E 9862 +9863 9863 EC819F 9863 +9864 9864 EC81A1 9864 +9865 9865 EC81A2 9865 +9866 9866 EC81A3 9866 +9867 9867 EC81A4 9867 +9868 9868 EC81A5 9868 +9869 9869 EC81A6 9869 +986A 986A EC81A7 986A +986B 986B EC81AA 986B +986C 986C EC81AB 986C +986D 986D EC81AC 986D +986E 986E EC81AD 986E +986F 986F EC81AE 986F +9870 9870 EC81AF 9870 +9871 9871 EC81B0 9871 +9872 9872 EC81B1 9872 +9873 9873 EC81B2 9873 +9874 9874 EC81B3 9874 +9875 9875 EC81B4 9875 +9876 9876 EC81B5 9876 +9877 9877 EC81B6 9877 +9878 9878 EC81B7 9878 +9879 9879 EC81B8 9879 +987A 987A EC81B9 987A +9881 9881 EC81BA 9881 +9882 9882 EC81BB 9882 +9883 9883 EC81BC 9883 +9884 9884 EC81BD 9884 +9885 9885 EC81BE 9885 +9886 9886 EC81BF 9886 +9887 9887 EC8280 9887 +9888 9888 EC8281 9888 +9889 9889 EC8282 9889 +988A 988A EC8283 988A +988B 988B EC8284 988B +988C 988C EC8285 988C +988D 988D EC8286 988D +988E 988E EC8287 988E +988F 988F EC8288 988F +9890 9890 EC8289 9890 +9891 9891 EC828A 9891 +9892 9892 EC828B 9892 +9893 9893 EC828C 9893 +9894 9894 EC828D 9894 +9895 9895 EC828E 9895 +9896 9896 EC828F 9896 +9897 9897 EC8292 9897 +9898 9898 EC8293 9898 +9899 9899 EC8295 9899 +989A 989A EC8296 989A +989B 989B EC8297 989B +989C 989C EC8299 989C +989D 989D EC829A 989D +989E 989E EC829B 989E +989F 989F EC829C 989F +98A0 98A0 EC829D 98A0 +98A1 98A1 EC829E 98A1 +98A2 98A2 EC829F 98A2 +98A3 98A3 EC82A2 98A3 +98A4 98A4 EC82A4 98A4 +98A5 98A5 EC82A6 98A5 +98A6 98A6 EC82A7 98A6 +98A7 98A7 EC82A8 98A7 +98A8 98A8 EC82A9 98A8 +98A9 98A9 EC82AA 98A9 +98AA 98AA EC82AB 98AA +98AB 98AB EC82AE 98AB +98AC 98AC EC82B1 98AC +98AD 98AD EC82B2 98AD +98AE 98AE EC82B7 98AE +98AF 98AF EC82B8 98AF +98B0 98B0 EC82B9 98B0 +98B1 98B1 EC82BA 98B1 +98B2 98B2 EC82BB 98B2 +98B3 98B3 EC82BE 98B3 +98B4 98B4 EC8382 98B4 +98B5 98B5 EC8383 98B5 +98B6 98B6 EC8384 98B6 +98B7 98B7 EC8386 98B7 +98B8 98B8 EC8387 98B8 +98B9 98B9 EC838A 98B9 +98BA 98BA EC838B 98BA +98BB 98BB EC838D 98BB +98BC 98BC EC838E 98BC +98BD 98BD EC838F 98BD +98BE 98BE EC8391 98BE +98BF 98BF EC8392 98BF +98C0 98C0 EC8393 98C0 +98C1 98C1 EC8394 98C1 +98C2 98C2 EC8395 98C2 +98C3 98C3 EC8396 98C3 +98C4 98C4 EC8397 98C4 +98C5 98C5 EC839A 98C5 +98C6 98C6 EC839E 98C6 +98C7 98C7 EC839F 98C7 +98C8 98C8 EC83A0 98C8 +98C9 98C9 EC83A1 98C9 +98CA 98CA EC83A2 98CA +98CB 98CB EC83A3 98CB +98CC 98CC EC83A6 98CC +98CD 98CD EC83A7 98CD +98CE 98CE EC83A9 98CE +98CF 98CF EC83AA 98CF +98D0 98D0 EC83AB 98D0 +98D1 98D1 EC83AD 98D1 +98D2 98D2 EC83AE 98D2 +98D3 98D3 EC83AF 98D3 +98D4 98D4 EC83B0 98D4 +98D5 98D5 EC83B1 98D5 +98D6 98D6 EC83B2 98D6 +98D7 98D7 EC83B3 98D7 +98D8 98D8 EC83B6 98D8 +98D9 98D9 EC83B8 98D9 +98DA 98DA EC83BA 98DA +98DB 98DB EC83BB 98DB +98DC 98DC EC83BC 98DC +98DD 98DD EC83BD 98DD +98DE 98DE EC83BE 98DE +98DF 98DF EC83BF 98DF +98E0 98E0 EC8481 98E0 +98E1 98E1 EC8482 98E1 +98E2 98E2 EC8483 98E2 +98E3 98E3 EC8485 98E3 +98E4 98E4 EC8486 98E4 +98E5 98E5 EC8487 98E5 +98E6 98E6 EC8489 98E6 +98E7 98E7 EC848A 98E7 +98E8 98E8 EC848B 98E8 +98E9 98E9 EC848C 98E9 +98EA 98EA EC848D 98EA +98EB 98EB EC848E 98EB +98EC 98EC EC848F 98EC +98ED 98ED EC8491 98ED +98EE 98EE EC8492 98EE +98EF 98EF EC8493 98EF +98F0 98F0 EC8494 98F0 +98F1 98F1 EC8496 98F1 +98F2 98F2 EC8497 98F2 +98F3 98F3 EC8498 98F3 +98F4 98F4 EC8499 98F4 +98F5 98F5 EC849A 98F5 +98F6 98F6 EC849B 98F6 +98F7 98F7 EC84A1 98F7 +98F8 98F8 EC84A2 98F8 +98F9 98F9 EC84A5 98F9 +98FA 98FA EC84A8 98FA +98FB 98FB EC84A9 98FB +98FC 98FC EC84AA 98FC +98FD 98FD EC84AB 98FD +98FE 98FE EC84AE 98FE +9941 9941 EC84B2 9941 +9942 9942 EC84B3 9942 +9943 9943 EC84B4 9943 +9944 9944 EC84B5 9944 +9945 9945 EC84B7 9945 +9946 9946 EC84BA 9946 +9947 9947 EC84BB 9947 +9948 9948 EC84BD 9948 +9949 9949 EC84BE 9949 +994A 994A EC84BF 994A +994B 994B EC8581 994B +994C 994C EC8582 994C +994D 994D EC8583 994D +994E 994E EC8584 994E +994F 994F EC8585 994F +9950 9950 EC8586 9950 +9951 9951 EC8587 9951 +9952 9952 EC858A 9952 +9953 9953 EC858E 9953 +9954 9954 EC858F 9954 +9955 9955 EC8590 9955 +9956 9956 EC8591 9956 +9957 9957 EC8592 9957 +9958 9958 EC8593 9958 +9959 9959 EC8596 9959 +995A 995A EC8597 995A +9961 9961 EC8599 9961 +9962 9962 EC859A 9962 +9963 9963 EC859B 9963 +9964 9964 EC859D 9964 +9965 9965 EC859E 9965 +9966 9966 EC859F 9966 +9967 9967 EC85A0 9967 +9968 9968 EC85A1 9968 +9969 9969 EC85A2 9969 +996A 996A EC85A3 996A +996B 996B EC85A6 996B +996C 996C EC85AA 996C +996D 996D EC85AB 996D +996E 996E EC85AC 996E +996F 996F EC85AD 996F +9970 9970 EC85AE 9970 +9971 9971 EC85AF 9971 +9972 9972 EC85B1 9972 +9973 9973 EC85B2 9973 +9974 9974 EC85B3 9974 +9975 9975 EC85B5 9975 +9976 9976 EC85B6 9976 +9977 9977 EC85B7 9977 +9978 9978 EC85B9 9978 +9979 9979 EC85BA 9979 +997A 997A EC85BB 997A +9981 9981 EC85BC 9981 +9982 9982 EC85BD 9982 +9983 9983 EC85BE 9983 +9984 9984 EC85BF 9984 +9985 9985 EC8680 9985 +9986 9986 EC8681 9986 +9987 9987 EC8682 9987 +9988 9988 EC8683 9988 +9989 9989 EC8684 9989 +998A 998A EC8686 998A +998B 998B EC8687 998B +998C 998C EC8688 998C +998D 998D EC8689 998D +998E 998E EC868A 998E +998F 998F EC868B 998F +9990 9990 EC868F 9990 +9991 9991 EC8691 9991 +9992 9992 EC8692 9992 +9993 9993 EC8693 9993 +9994 9994 EC8695 9994 +9995 9995 EC8697 9995 +9996 9996 EC8698 9996 +9997 9997 EC8699 9997 +9998 9998 EC869A 9998 +9999 9999 EC869B 9999 +999A 999A EC869E 999A +999B 999B EC86A0 999B +999C 999C EC86A2 999C +999D 999D EC86A3 999D +999E 999E EC86A4 999E +999F 999F EC86A6 999F +99A0 99A0 EC86A7 99A0 +99A1 99A1 EC86AA 99A1 +99A2 99A2 EC86AB 99A2 +99A3 99A3 EC86AD 99A3 +99A4 99A4 EC86AE 99A4 +99A5 99A5 EC86AF 99A5 +99A6 99A6 EC86B1 99A6 +99A7 99A7 EC86B2 99A7 +99A8 99A8 EC86B3 99A8 +99A9 99A9 EC86B4 99A9 +99AA 99AA EC86B5 99AA +99AB 99AB EC86B6 99AB +99AC 99AC EC86B7 99AC +99AD 99AD EC86B8 99AD +99AE 99AE EC86B9 99AE +99AF 99AF EC86BA 99AF +99B0 99B0 EC86BB 99B0 +99B1 99B1 EC86BC 99B1 +99B2 99B2 EC86BE 99B2 +99B3 99B3 EC86BF 99B3 +99B4 99B4 EC8780 99B4 +99B5 99B5 EC8781 99B5 +99B6 99B6 EC8782 99B6 +99B7 99B7 EC8783 99B7 +99B8 99B8 EC8785 99B8 +99B9 99B9 EC8786 99B9 +99BA 99BA EC8787 99BA +99BB 99BB EC8789 99BB +99BC 99BC EC878A 99BC +99BD 99BD EC878B 99BD +99BE 99BE EC878D 99BE +99BF 99BF EC878E 99BF +99C0 99C0 EC878F 99C0 +99C1 99C1 EC8790 99C1 +99C2 99C2 EC8791 99C2 +99C3 99C3 EC8792 99C3 +99C4 99C4 EC8793 99C4 +99C5 99C5 EC8795 99C5 +99C6 99C6 EC8796 99C6 +99C7 99C7 EC8799 99C7 +99C8 99C8 EC879A 99C8 +99C9 99C9 EC879B 99C9 +99CA 99CA EC879C 99CA +99CB 99CB EC879D 99CB +99CC 99CC EC879E 99CC +99CD 99CD EC879F 99CD +99CE 99CE EC87A1 99CE +99CF 99CF EC87A2 99CF +99D0 99D0 EC87A3 99D0 +99D1 99D1 EC87A5 99D1 +99D2 99D2 EC87A6 99D2 +99D3 99D3 EC87A7 99D3 +99D4 99D4 EC87A9 99D4 +99D5 99D5 EC87AA 99D5 +99D6 99D6 EC87AB 99D6 +99D7 99D7 EC87AC 99D7 +99D8 99D8 EC87AD 99D8 +99D9 99D9 EC87AE 99D9 +99DA 99DA EC87AF 99DA +99DB 99DB EC87B2 99DB +99DC 99DC EC87B4 99DC +99DD 99DD EC87B5 99DD +99DE 99DE EC87B6 99DE +99DF 99DF EC87B7 99DF +99E0 99E0 EC87B8 99E0 +99E1 99E1 EC87B9 99E1 +99E2 99E2 EC87BA 99E2 +99E3 99E3 EC87BB 99E3 +99E4 99E4 EC87BE 99E4 +99E5 99E5 EC87BF 99E5 +99E6 99E6 EC8881 99E6 +99E7 99E7 EC8882 99E7 +99E8 99E8 EC8883 99E8 +99E9 99E9 EC8885 99E9 +99EA 99EA EC8886 99EA +99EB 99EB EC8887 99EB +99EC 99EC EC8888 99EC +99ED 99ED EC8889 99ED +99EE 99EE EC888A 99EE +99EF 99EF EC888B 99EF +99F0 99F0 EC888E 99F0 +99F1 99F1 EC8890 99F1 +99F2 99F2 EC8892 99F2 +99F3 99F3 EC8893 99F3 +99F4 99F4 EC8894 99F4 +99F5 99F5 EC8895 99F5 +99F6 99F6 EC8896 99F6 +99F7 99F7 EC8897 99F7 +99F8 99F8 EC889A 99F8 +99F9 99F9 EC889B 99F9 +99FA 99FA EC889D 99FA +99FB 99FB EC889E 99FB +99FC 99FC EC88A1 99FC +99FD 99FD EC88A2 99FD +99FE 99FE EC88A3 99FE +9A41 9A41 EC88A4 9A41 +9A42 9A42 EC88A5 9A42 +9A43 9A43 EC88A6 9A43 +9A44 9A44 EC88A7 9A44 +9A45 9A45 EC88AA 9A45 +9A46 9A46 EC88AC 9A46 +9A47 9A47 EC88AE 9A47 +9A48 9A48 EC88B0 9A48 +9A49 9A49 EC88B3 9A49 +9A4A 9A4A EC88B5 9A4A +9A4B 9A4B EC88B6 9A4B +9A4C 9A4C EC88B7 9A4C +9A4D 9A4D EC88B8 9A4D +9A4E 9A4E EC88B9 9A4E +9A4F 9A4F EC88BA 9A4F +9A50 9A50 EC88BB 9A50 +9A51 9A51 EC88BC 9A51 +9A52 9A52 EC88BD 9A52 +9A53 9A53 EC88BE 9A53 +9A54 9A54 EC88BF 9A54 +9A55 9A55 EC8980 9A55 +9A56 9A56 EC8981 9A56 +9A57 9A57 EC8982 9A57 +9A58 9A58 EC8983 9A58 +9A59 9A59 EC8984 9A59 +9A5A 9A5A EC8985 9A5A +9A61 9A61 EC8986 9A61 +9A62 9A62 EC8987 9A62 +9A63 9A63 EC8989 9A63 +9A64 9A64 EC898A 9A64 +9A65 9A65 EC898B 9A65 +9A66 9A66 EC898C 9A66 +9A67 9A67 EC898D 9A67 +9A68 9A68 EC898E 9A68 +9A69 9A69 EC898F 9A69 +9A6A 9A6A EC8992 9A6A +9A6B 9A6B EC8993 9A6B +9A6C 9A6C EC8995 9A6C +9A6D 9A6D EC8996 9A6D +9A6E 9A6E EC8997 9A6E +9A6F 9A6F EC8999 9A6F +9A70 9A70 EC899A 9A70 +9A71 9A71 EC899B 9A71 +9A72 9A72 EC899C 9A72 +9A73 9A73 EC899D 9A73 +9A74 9A74 EC899E 9A74 +9A75 9A75 EC899F 9A75 +9A76 9A76 EC89A1 9A76 +9A77 9A77 EC89A2 9A77 +9A78 9A78 EC89A3 9A78 +9A79 9A79 EC89A4 9A79 +9A7A 9A7A EC89A6 9A7A +9A81 9A81 EC89A7 9A81 +9A82 9A82 EC89A8 9A82 +9A83 9A83 EC89A9 9A83 +9A84 9A84 EC89AA 9A84 +9A85 9A85 EC89AB 9A85 +9A86 9A86 EC89AE 9A86 +9A87 9A87 EC89AF 9A87 +9A88 9A88 EC89B1 9A88 +9A89 9A89 EC89B2 9A89 +9A8A 9A8A EC89B3 9A8A +9A8B 9A8B EC89B5 9A8B +9A8C 9A8C EC89B6 9A8C +9A8D 9A8D EC89B7 9A8D +9A8E 9A8E EC89B8 9A8E +9A8F 9A8F EC89B9 9A8F +9A90 9A90 EC89BA 9A90 +9A91 9A91 EC89BB 9A91 +9A92 9A92 EC89BE 9A92 +9A93 9A93 EC8A80 9A93 +9A94 9A94 EC8A82 9A94 +9A95 9A95 EC8A83 9A95 +9A96 9A96 EC8A84 9A96 +9A97 9A97 EC8A85 9A97 +9A98 9A98 EC8A86 9A98 +9A99 9A99 EC8A87 9A99 +9A9A 9A9A EC8A8A 9A9A +9A9B 9A9B EC8A8B 9A9B +9A9C 9A9C EC8A8C 9A9C +9A9D 9A9D EC8A8D 9A9D +9A9E 9A9E EC8A8E 9A9E +9A9F 9A9F EC8A8F 9A9F +9AA0 9AA0 EC8A91 9AA0 +9AA1 9AA1 EC8A92 9AA1 +9AA2 9AA2 EC8A93 9AA2 +9AA3 9AA3 EC8A94 9AA3 +9AA4 9AA4 EC8A95 9AA4 +9AA5 9AA5 EC8A96 9AA5 +9AA6 9AA6 EC8A97 9AA6 +9AA7 9AA7 EC8A99 9AA7 +9AA8 9AA8 EC8A9A 9AA8 +9AA9 9AA9 EC8A9C 9AA9 +9AAA 9AAA EC8A9E 9AAA +9AAB 9AAB EC8A9F 9AAB +9AAC 9AAC EC8AA0 9AAC +9AAD 9AAD EC8AA1 9AAD +9AAE 9AAE EC8AA2 9AAE +9AAF 9AAF EC8AA3 9AAF +9AB0 9AB0 EC8AA6 9AB0 +9AB1 9AB1 EC8AA7 9AB1 +9AB2 9AB2 EC8AA9 9AB2 +9AB3 9AB3 EC8AAA 9AB3 +9AB4 9AB4 EC8AAB 9AB4 +9AB5 9AB5 EC8AAE 9AB5 +9AB6 9AB6 EC8AAF 9AB6 +9AB7 9AB7 EC8AB0 9AB7 +9AB8 9AB8 EC8AB1 9AB8 +9AB9 9AB9 EC8AB2 9AB9 +9ABA 9ABA EC8AB3 9ABA +9ABB 9ABB EC8AB6 9ABB +9ABC 9ABC EC8AB8 9ABC +9ABD 9ABD EC8ABA 9ABD +9ABE 9ABE EC8ABB 9ABE +9ABF 9ABF EC8ABC 9ABF +9AC0 9AC0 EC8ABD 9AC0 +9AC1 9AC1 EC8ABE 9AC1 +9AC2 9AC2 EC8ABF 9AC2 +9AC3 9AC3 EC8B80 9AC3 +9AC4 9AC4 EC8B81 9AC4 +9AC5 9AC5 EC8B82 9AC5 +9AC6 9AC6 EC8B83 9AC6 +9AC7 9AC7 EC8B84 9AC7 +9AC8 9AC8 EC8B85 9AC8 +9AC9 9AC9 EC8B86 9AC9 +9ACA 9ACA EC8B87 9ACA +9ACB 9ACB EC8B88 9ACB +9ACC 9ACC EC8B89 9ACC +9ACD 9ACD EC8B8A 9ACD +9ACE 9ACE EC8B8B 9ACE +9ACF 9ACF EC8B8C 9ACF +9AD0 9AD0 EC8B8D 9AD0 +9AD1 9AD1 EC8B8E 9AD1 +9AD2 9AD2 EC8B8F 9AD2 +9AD3 9AD3 EC8B90 9AD3 +9AD4 9AD4 EC8B91 9AD4 +9AD5 9AD5 EC8B92 9AD5 +9AD6 9AD6 EC8B93 9AD6 +9AD7 9AD7 EC8B94 9AD7 +9AD8 9AD8 EC8B95 9AD8 +9AD9 9AD9 EC8B96 9AD9 +9ADA 9ADA EC8B97 9ADA +9ADB 9ADB EC8B98 9ADB +9ADC 9ADC EC8B99 9ADC +9ADD 9ADD EC8B9A 9ADD +9ADE 9ADE EC8B9B 9ADE +9ADF 9ADF EC8B9E 9ADF +9AE0 9AE0 EC8B9F 9AE0 +9AE1 9AE1 EC8BA1 9AE1 +9AE2 9AE2 EC8BA2 9AE2 +9AE3 9AE3 EC8BA5 9AE3 +9AE4 9AE4 EC8BA6 9AE4 +9AE5 9AE5 EC8BA7 9AE5 +9AE6 9AE6 EC8BA8 9AE6 +9AE7 9AE7 EC8BA9 9AE7 +9AE8 9AE8 EC8BAA 9AE8 +9AE9 9AE9 EC8BAE 9AE9 +9AEA 9AEA EC8BB0 9AEA +9AEB 9AEB EC8BB2 9AEB +9AEC 9AEC EC8BB3 9AEC +9AED 9AED EC8BB4 9AED +9AEE 9AEE EC8BB5 9AEE +9AEF 9AEF EC8BB7 9AEF +9AF0 9AF0 EC8BBA 9AF0 +9AF1 9AF1 EC8BBD 9AF1 +9AF2 9AF2 EC8BBE 9AF2 +9AF3 9AF3 EC8BBF 9AF3 +9AF4 9AF4 EC8C81 9AF4 +9AF5 9AF5 EC8C82 9AF5 +9AF6 9AF6 EC8C83 9AF6 +9AF7 9AF7 EC8C84 9AF7 +9AF8 9AF8 EC8C85 9AF8 +9AF9 9AF9 EC8C86 9AF9 +9AFA 9AFA EC8C87 9AFA +9AFB 9AFB EC8C8A 9AFB +9AFC 9AFC EC8C8B 9AFC +9AFD 9AFD EC8C8E 9AFD +9AFE 9AFE EC8C8F 9AFE +9B41 9B41 EC8C90 9B41 +9B42 9B42 EC8C91 9B42 +9B43 9B43 EC8C92 9B43 +9B44 9B44 EC8C96 9B44 +9B45 9B45 EC8C97 9B45 +9B46 9B46 EC8C99 9B46 +9B47 9B47 EC8C9A 9B47 +9B48 9B48 EC8C9B 9B48 +9B49 9B49 EC8C9D 9B49 +9B4A 9B4A EC8C9E 9B4A +9B4B 9B4B EC8C9F 9B4B +9B4C 9B4C EC8CA0 9B4C +9B4D 9B4D EC8CA1 9B4D +9B4E 9B4E EC8CA2 9B4E +9B4F 9B4F EC8CA3 9B4F +9B50 9B50 EC8CA6 9B50 +9B51 9B51 EC8CA7 9B51 +9B52 9B52 EC8CAA 9B52 +9B53 9B53 EC8CAB 9B53 +9B54 9B54 EC8CAC 9B54 +9B55 9B55 EC8CAD 9B55 +9B56 9B56 EC8CAE 9B56 +9B57 9B57 EC8CAF 9B57 +9B58 9B58 EC8CB0 9B58 +9B59 9B59 EC8CB1 9B59 +9B5A 9B5A EC8CB2 9B5A +9B61 9B61 EC8CB3 9B61 +9B62 9B62 EC8CB4 9B62 +9B63 9B63 EC8CB5 9B63 +9B64 9B64 EC8CB6 9B64 +9B65 9B65 EC8CB7 9B65 +9B66 9B66 EC8CB8 9B66 +9B67 9B67 EC8CB9 9B67 +9B68 9B68 EC8CBA 9B68 +9B69 9B69 EC8CBB 9B69 +9B6A 9B6A EC8CBC 9B6A +9B6B 9B6B EC8CBD 9B6B +9B6C 9B6C EC8CBE 9B6C +9B6D 9B6D EC8CBF 9B6D +9B6E 9B6E EC8D80 9B6E +9B6F 9B6F EC8D81 9B6F +9B70 9B70 EC8D82 9B70 +9B71 9B71 EC8D83 9B71 +9B72 9B72 EC8D84 9B72 +9B73 9B73 EC8D86 9B73 +9B74 9B74 EC8D87 9B74 +9B75 9B75 EC8D88 9B75 +9B76 9B76 EC8D89 9B76 +9B77 9B77 EC8D8A 9B77 +9B78 9B78 EC8D8B 9B78 +9B79 9B79 EC8D8C 9B79 +9B7A 9B7A EC8D8D 9B7A +9B81 9B81 EC8D8E 9B81 +9B82 9B82 EC8D8F 9B82 +9B83 9B83 EC8D90 9B83 +9B84 9B84 EC8D91 9B84 +9B85 9B85 EC8D92 9B85 +9B86 9B86 EC8D93 9B86 +9B87 9B87 EC8D94 9B87 +9B88 9B88 EC8D95 9B88 +9B89 9B89 EC8D96 9B89 +9B8A 9B8A EC8D97 9B8A +9B8B 9B8B EC8D98 9B8B +9B8C 9B8C EC8D99 9B8C +9B8D 9B8D EC8D9A 9B8D +9B8E 9B8E EC8D9B 9B8E +9B8F 9B8F EC8D9C 9B8F +9B90 9B90 EC8D9D 9B90 +9B91 9B91 EC8D9E 9B91 +9B92 9B92 EC8D9F 9B92 +9B93 9B93 EC8DA0 9B93 +9B94 9B94 EC8DA1 9B94 +9B95 9B95 EC8DA2 9B95 +9B96 9B96 EC8DA3 9B96 +9B97 9B97 EC8DA4 9B97 +9B98 9B98 EC8DA5 9B98 +9B99 9B99 EC8DA6 9B99 +9B9A 9B9A EC8DA7 9B9A +9B9B 9B9B EC8DAA 9B9B +9B9C 9B9C EC8DAB 9B9C +9B9D 9B9D EC8DAD 9B9D +9B9E 9B9E EC8DAE 9B9E +9B9F 9B9F EC8DAF 9B9F +9BA0 9BA0 EC8DB1 9BA0 +9BA1 9BA1 EC8DB3 9BA1 +9BA2 9BA2 EC8DB4 9BA2 +9BA3 9BA3 EC8DB5 9BA3 +9BA4 9BA4 EC8DB6 9BA4 +9BA5 9BA5 EC8DB7 9BA5 +9BA6 9BA6 EC8DBA 9BA6 +9BA7 9BA7 EC8DBB 9BA7 +9BA8 9BA8 EC8DBE 9BA8 +9BA9 9BA9 EC8DBF 9BA9 +9BAA 9BAA EC8E80 9BAA +9BAB 9BAB EC8E81 9BAB +9BAC 9BAC EC8E82 9BAC +9BAD 9BAD EC8E83 9BAD +9BAE 9BAE EC8E85 9BAE +9BAF 9BAF EC8E86 9BAF +9BB0 9BB0 EC8E87 9BB0 +9BB1 9BB1 EC8E89 9BB1 +9BB2 9BB2 EC8E8A 9BB2 +9BB3 9BB3 EC8E8B 9BB3 +9BB4 9BB4 EC8E8D 9BB4 +9BB5 9BB5 EC8E8E 9BB5 +9BB6 9BB6 EC8E8F 9BB6 +9BB7 9BB7 EC8E90 9BB7 +9BB8 9BB8 EC8E91 9BB8 +9BB9 9BB9 EC8E92 9BB9 +9BBA 9BBA EC8E93 9BBA +9BBB 9BBB EC8E94 9BBB +9BBC 9BBC EC8E95 9BBC +9BBD 9BBD EC8E96 9BBD +9BBE 9BBE EC8E97 9BBE +9BBF 9BBF EC8E98 9BBF +9BC0 9BC0 EC8E99 9BC0 +9BC1 9BC1 EC8E9A 9BC1 +9BC2 9BC2 EC8E9B 9BC2 +9BC3 9BC3 EC8E9C 9BC3 +9BC4 9BC4 EC8E9D 9BC4 +9BC5 9BC5 EC8E9E 9BC5 +9BC6 9BC6 EC8E9F 9BC6 +9BC7 9BC7 EC8EA0 9BC7 +9BC8 9BC8 EC8EA1 9BC8 +9BC9 9BC9 EC8EA2 9BC9 +9BCA 9BCA EC8EA3 9BCA +9BCB 9BCB EC8EA4 9BCB +9BCC 9BCC EC8EA5 9BCC +9BCD 9BCD EC8EA6 9BCD +9BCE 9BCE EC8EA7 9BCE +9BCF 9BCF EC8EA8 9BCF +9BD0 9BD0 EC8EA9 9BD0 +9BD1 9BD1 EC8EAA 9BD1 +9BD2 9BD2 EC8EAB 9BD2 +9BD3 9BD3 EC8EAC 9BD3 +9BD4 9BD4 EC8EAD 9BD4 +9BD5 9BD5 EC8EAE 9BD5 +9BD6 9BD6 EC8EAF 9BD6 +9BD7 9BD7 EC8EB0 9BD7 +9BD8 9BD8 EC8EB1 9BD8 +9BD9 9BD9 EC8EB2 9BD9 +9BDA 9BDA EC8EB3 9BDA +9BDB 9BDB EC8EB4 9BDB +9BDC 9BDC EC8EB5 9BDC +9BDD 9BDD EC8EB6 9BDD +9BDE 9BDE EC8EB7 9BDE +9BDF 9BDF EC8EB8 9BDF +9BE0 9BE0 EC8EB9 9BE0 +9BE1 9BE1 EC8EBA 9BE1 +9BE2 9BE2 EC8EBB 9BE2 +9BE3 9BE3 EC8EBC 9BE3 +9BE4 9BE4 EC8EBD 9BE4 +9BE5 9BE5 EC8EBE 9BE5 +9BE6 9BE6 EC8EBF 9BE6 +9BE7 9BE7 EC8F81 9BE7 +9BE8 9BE8 EC8F82 9BE8 +9BE9 9BE9 EC8F83 9BE9 +9BEA 9BEA EC8F84 9BEA +9BEB 9BEB EC8F85 9BEB +9BEC 9BEC EC8F86 9BEC +9BED 9BED EC8F87 9BED +9BEE 9BEE EC8F88 9BEE +9BEF 9BEF EC8F89 9BEF +9BF0 9BF0 EC8F8A 9BF0 +9BF1 9BF1 EC8F8B 9BF1 +9BF2 9BF2 EC8F8C 9BF2 +9BF3 9BF3 EC8F8D 9BF3 +9BF4 9BF4 EC8F8E 9BF4 +9BF5 9BF5 EC8F8F 9BF5 +9BF6 9BF6 EC8F90 9BF6 +9BF7 9BF7 EC8F91 9BF7 +9BF8 9BF8 EC8F92 9BF8 +9BF9 9BF9 EC8F93 9BF9 +9BFA 9BFA EC8F94 9BFA +9BFB 9BFB EC8F95 9BFB +9BFC 9BFC EC8F96 9BFC +9BFD 9BFD EC8F97 9BFD +9BFE 9BFE EC8F9A 9BFE +9C41 9C41 EC8F9B 9C41 +9C42 9C42 EC8F9D 9C42 +9C43 9C43 EC8F9E 9C43 +9C44 9C44 EC8FA1 9C44 +9C45 9C45 EC8FA3 9C45 +9C46 9C46 EC8FA4 9C46 +9C47 9C47 EC8FA5 9C47 +9C48 9C48 EC8FA6 9C48 +9C49 9C49 EC8FA7 9C49 +9C4A 9C4A EC8FAA 9C4A +9C4B 9C4B EC8FAB 9C4B +9C4C 9C4C EC8FAC 9C4C +9C4D 9C4D EC8FAE 9C4D +9C4E 9C4E EC8FAF 9C4E +9C4F 9C4F EC8FB0 9C4F +9C50 9C50 EC8FB1 9C50 +9C51 9C51 EC8FB2 9C51 +9C52 9C52 EC8FB3 9C52 +9C53 9C53 EC8FB6 9C53 +9C54 9C54 EC8FB7 9C54 +9C55 9C55 EC8FB9 9C55 +9C56 9C56 EC8FBA 9C56 +9C57 9C57 EC8FBB 9C57 +9C58 9C58 EC8FBC 9C58 +9C59 9C59 EC8FBD 9C59 +9C5A 9C5A EC8FBE 9C5A +9C61 9C61 EC8FBF 9C61 +9C62 9C62 EC9080 9C62 +9C63 9C63 EC9081 9C63 +9C64 9C64 EC9082 9C64 +9C65 9C65 EC9083 9C65 +9C66 9C66 EC9084 9C66 +9C67 9C67 EC9085 9C67 +9C68 9C68 EC9086 9C68 +9C69 9C69 EC9087 9C69 +9C6A 9C6A EC9089 9C6A +9C6B 9C6B EC908A 9C6B +9C6C 9C6C EC908B 9C6C +9C6D 9C6D EC908C 9C6D +9C6E 9C6E EC908D 9C6E +9C6F 9C6F EC908E 9C6F +9C70 9C70 EC908F 9C70 +9C71 9C71 EC9091 9C71 +9C72 9C72 EC9092 9C72 +9C73 9C73 EC9093 9C73 +9C74 9C74 EC9094 9C74 +9C75 9C75 EC9095 9C75 +9C76 9C76 EC9096 9C76 +9C77 9C77 EC9097 9C77 +9C78 9C78 EC9098 9C78 +9C79 9C79 EC9099 9C79 +9C7A 9C7A EC909A 9C7A +9C81 9C81 EC909B 9C81 +9C82 9C82 EC909C 9C82 +9C83 9C83 EC909D 9C83 +9C84 9C84 EC909E 9C84 +9C85 9C85 EC909F 9C85 +9C86 9C86 EC90A0 9C86 +9C87 9C87 EC90A1 9C87 +9C88 9C88 EC90A2 9C88 +9C89 9C89 EC90A3 9C89 +9C8A 9C8A EC90A5 9C8A +9C8B 9C8B EC90A6 9C8B +9C8C 9C8C EC90A7 9C8C +9C8D 9C8D EC90A8 9C8D +9C8E 9C8E EC90A9 9C8E +9C8F 9C8F EC90AA 9C8F +9C90 9C90 EC90AB 9C90 +9C91 9C91 EC90AD 9C91 +9C92 9C92 EC90AE 9C92 +9C93 9C93 EC90AF 9C93 +9C94 9C94 EC90B1 9C94 +9C95 9C95 EC90B2 9C95 +9C96 9C96 EC90B3 9C96 +9C97 9C97 EC90B5 9C97 +9C98 9C98 EC90B6 9C98 +9C99 9C99 EC90B7 9C99 +9C9A 9C9A EC90B8 9C9A +9C9B 9C9B EC90B9 9C9B +9C9C 9C9C EC90BA 9C9C +9C9D 9C9D EC90BB 9C9D +9C9E 9C9E EC90BE 9C9E +9C9F 9C9F EC90BF 9C9F +9CA0 9CA0 EC9180 9CA0 +9CA1 9CA1 EC9181 9CA1 +9CA2 9CA2 EC9182 9CA2 +9CA3 9CA3 EC9183 9CA3 +9CA4 9CA4 EC9184 9CA4 +9CA5 9CA5 EC9185 9CA5 +9CA6 9CA6 EC9186 9CA6 +9CA7 9CA7 EC9187 9CA7 +9CA8 9CA8 EC9189 9CA8 +9CA9 9CA9 EC918A 9CA9 +9CAA 9CAA EC918B 9CAA +9CAB 9CAB EC918C 9CAB +9CAC 9CAC EC918D 9CAC +9CAD 9CAD EC918E 9CAD +9CAE 9CAE EC918F 9CAE +9CAF 9CAF EC9190 9CAF +9CB0 9CB0 EC9191 9CB0 +9CB1 9CB1 EC9192 9CB1 +9CB2 9CB2 EC9193 9CB2 +9CB3 9CB3 EC9194 9CB3 +9CB4 9CB4 EC9195 9CB4 +9CB5 9CB5 EC9196 9CB5 +9CB6 9CB6 EC9197 9CB6 +9CB7 9CB7 EC9198 9CB7 +9CB8 9CB8 EC9199 9CB8 +9CB9 9CB9 EC919A 9CB9 +9CBA 9CBA EC919B 9CBA +9CBB 9CBB EC919C 9CBB +9CBC 9CBC EC919D 9CBC +9CBD 9CBD EC919E 9CBD +9CBE 9CBE EC919F 9CBE +9CBF 9CBF EC91A0 9CBF +9CC0 9CC0 EC91A1 9CC0 +9CC1 9CC1 EC91A2 9CC1 +9CC2 9CC2 EC91A3 9CC2 +9CC3 9CC3 EC91A6 9CC3 +9CC4 9CC4 EC91A7 9CC4 +9CC5 9CC5 EC91A9 9CC5 +9CC6 9CC6 EC91AA 9CC6 +9CC7 9CC7 EC91AB 9CC7 +9CC8 9CC8 EC91AD 9CC8 +9CC9 9CC9 EC91AE 9CC9 +9CCA 9CCA EC91AF 9CCA +9CCB 9CCB EC91B0 9CCB +9CCC 9CCC EC91B1 9CCC +9CCD 9CCD EC91B2 9CCD +9CCE 9CCE EC91B3 9CCE +9CCF 9CCF EC91B6 9CCF +9CD0 9CD0 EC91B7 9CD0 +9CD1 9CD1 EC91B8 9CD1 +9CD2 9CD2 EC91BA 9CD2 +9CD3 9CD3 EC91BB 9CD3 +9CD4 9CD4 EC91BC 9CD4 +9CD5 9CD5 EC91BD 9CD5 +9CD6 9CD6 EC91BE 9CD6 +9CD7 9CD7 EC91BF 9CD7 +9CD8 9CD8 EC9281 9CD8 +9CD9 9CD9 EC9282 9CD9 +9CDA 9CDA EC9283 9CDA +9CDB 9CDB EC9284 9CDB +9CDC 9CDC EC9285 9CDC +9CDD 9CDD EC9286 9CDD +9CDE 9CDE EC9287 9CDE +9CDF 9CDF EC9288 9CDF +9CE0 9CE0 EC9289 9CE0 +9CE1 9CE1 EC928A 9CE1 +9CE2 9CE2 EC928B 9CE2 +9CE3 9CE3 EC928C 9CE3 +9CE4 9CE4 EC928D 9CE4 +9CE5 9CE5 EC928E 9CE5 +9CE6 9CE6 EC928F 9CE6 +9CE7 9CE7 EC9290 9CE7 +9CE8 9CE8 EC9291 9CE8 +9CE9 9CE9 EC9292 9CE9 +9CEA 9CEA EC9293 9CEA +9CEB 9CEB EC9295 9CEB +9CEC 9CEC EC9296 9CEC +9CED 9CED EC9297 9CED +9CEE 9CEE EC9298 9CEE +9CEF 9CEF EC9299 9CEF +9CF0 9CF0 EC929A 9CF0 +9CF1 9CF1 EC929B 9CF1 +9CF2 9CF2 EC929D 9CF2 +9CF3 9CF3 EC929E 9CF3 +9CF4 9CF4 EC929F 9CF4 +9CF5 9CF5 EC92A0 9CF5 +9CF6 9CF6 EC92A1 9CF6 +9CF7 9CF7 EC92A2 9CF7 +9CF8 9CF8 EC92A3 9CF8 +9CF9 9CF9 EC92A4 9CF9 +9CFA 9CFA EC92A5 9CFA +9CFB 9CFB EC92A6 9CFB +9CFC 9CFC EC92A7 9CFC +9CFD 9CFD EC92A8 9CFD +9CFE 9CFE EC92A9 9CFE +9D41 9D41 EC92AA 9D41 +9D42 9D42 EC92AB 9D42 +9D43 9D43 EC92AC 9D43 +9D44 9D44 EC92AD 9D44 +9D45 9D45 EC92AE 9D45 +9D46 9D46 EC92AF 9D46 +9D47 9D47 EC92B0 9D47 +9D48 9D48 EC92B1 9D48 +9D49 9D49 EC92B2 9D49 +9D4A 9D4A EC92B3 9D4A +9D4B 9D4B EC92B4 9D4B +9D4C 9D4C EC92B5 9D4C +9D4D 9D4D EC92B6 9D4D +9D4E 9D4E EC92B7 9D4E +9D4F 9D4F EC92B9 9D4F +9D50 9D50 EC92BA 9D50 +9D51 9D51 EC92BB 9D51 +9D52 9D52 EC92BD 9D52 +9D53 9D53 EC92BE 9D53 +9D54 9D54 EC92BF 9D54 +9D55 9D55 EC9380 9D55 +9D56 9D56 EC9381 9D56 +9D57 9D57 EC9382 9D57 +9D58 9D58 EC9383 9D58 +9D59 9D59 EC9384 9D59 +9D5A 9D5A EC9385 9D5A +9D61 9D61 EC9386 9D61 +9D62 9D62 EC9387 9D62 +9D63 9D63 EC9388 9D63 +9D64 9D64 EC9389 9D64 +9D65 9D65 EC938A 9D65 +9D66 9D66 EC938B 9D66 +9D67 9D67 EC938C 9D67 +9D68 9D68 EC938D 9D68 +9D69 9D69 EC938E 9D69 +9D6A 9D6A EC938F 9D6A +9D6B 9D6B EC9390 9D6B +9D6C 9D6C EC9391 9D6C +9D6D 9D6D EC9392 9D6D +9D6E 9D6E EC9393 9D6E +9D6F 9D6F EC9394 9D6F +9D70 9D70 EC9395 9D70 +9D71 9D71 EC9396 9D71 +9D72 9D72 EC9397 9D72 +9D73 9D73 EC9398 9D73 +9D74 9D74 EC9399 9D74 +9D75 9D75 EC939A 9D75 +9D76 9D76 EC939B 9D76 +9D77 9D77 EC939C 9D77 +9D78 9D78 EC939D 9D78 +9D79 9D79 EC939E 9D79 +9D7A 9D7A EC939F 9D7A +9D81 9D81 EC93A0 9D81 +9D82 9D82 EC93A1 9D82 +9D83 9D83 EC93A2 9D83 +9D84 9D84 EC93A3 9D84 +9D85 9D85 EC93A4 9D85 +9D86 9D86 EC93A5 9D86 +9D87 9D87 EC93A6 9D87 +9D88 9D88 EC93A7 9D88 +9D89 9D89 EC93A8 9D89 +9D8A 9D8A EC93AA 9D8A +9D8B 9D8B EC93AB 9D8B +9D8C 9D8C EC93AC 9D8C +9D8D 9D8D EC93AD 9D8D +9D8E 9D8E EC93AE 9D8E +9D8F 9D8F EC93AF 9D8F +9D90 9D90 EC93B2 9D90 +9D91 9D91 EC93B3 9D91 +9D92 9D92 EC93B5 9D92 +9D93 9D93 EC93B6 9D93 +9D94 9D94 EC93B7 9D94 +9D95 9D95 EC93B9 9D95 +9D96 9D96 EC93BB 9D96 +9D97 9D97 EC93BC 9D97 +9D98 9D98 EC93BD 9D98 +9D99 9D99 EC93BE 9D99 +9D9A 9D9A EC9482 9D9A +9D9B 9D9B EC9483 9D9B +9D9C 9D9C EC9484 9D9C +9D9D 9D9D EC9485 9D9D +9D9E 9D9E EC9486 9D9E +9D9F 9D9F EC9487 9D9F +9DA0 9DA0 EC9488 9DA0 +9DA1 9DA1 EC9489 9DA1 +9DA2 9DA2 EC948A 9DA2 +9DA3 9DA3 EC948B 9DA3 +9DA4 9DA4 EC948D 9DA4 +9DA5 9DA5 EC948E 9DA5 +9DA6 9DA6 EC948F 9DA6 +9DA7 9DA7 EC9491 9DA7 +9DA8 9DA8 EC9492 9DA8 +9DA9 9DA9 EC9493 9DA9 +9DAA 9DAA EC9495 9DAA +9DAB 9DAB EC9496 9DAB +9DAC 9DAC EC9497 9DAC +9DAD 9DAD EC9498 9DAD +9DAE 9DAE EC9499 9DAE +9DAF 9DAF EC949A 9DAF +9DB0 9DB0 EC949B 9DB0 +9DB1 9DB1 EC949D 9DB1 +9DB2 9DB2 EC949E 9DB2 +9DB3 9DB3 EC949F 9DB3 +9DB4 9DB4 EC94A0 9DB4 +9DB5 9DB5 EC94A1 9DB5 +9DB6 9DB6 EC94A2 9DB6 +9DB7 9DB7 EC94A3 9DB7 +9DB8 9DB8 EC94A4 9DB8 +9DB9 9DB9 EC94A5 9DB9 +9DBA 9DBA EC94A6 9DBA +9DBB 9DBB EC94A7 9DBB +9DBC 9DBC EC94AA 9DBC +9DBD 9DBD EC94AB 9DBD +9DBE 9DBE EC94AD 9DBE +9DBF 9DBF EC94AE 9DBF +9DC0 9DC0 EC94AF 9DC0 +9DC1 9DC1 EC94B1 9DC1 +9DC2 9DC2 EC94B2 9DC2 +9DC3 9DC3 EC94B3 9DC3 +9DC4 9DC4 EC94B4 9DC4 +9DC5 9DC5 EC94B5 9DC5 +9DC6 9DC6 EC94B6 9DC6 +9DC7 9DC7 EC94B7 9DC7 +9DC8 9DC8 EC94BA 9DC8 +9DC9 9DC9 EC94BC 9DC9 +9DCA 9DCA EC94BE 9DCA +9DCB 9DCB EC94BF 9DCB +9DCC 9DCC EC9580 9DCC +9DCD 9DCD EC9581 9DCD +9DCE 9DCE EC9582 9DCE +9DCF 9DCF EC9583 9DCF +9DD0 9DD0 EC9586 9DD0 +9DD1 9DD1 EC9587 9DD1 +9DD2 9DD2 EC958B 9DD2 +9DD3 9DD3 EC958F 9DD3 +9DD4 9DD4 EC9590 9DD4 +9DD5 9DD5 EC9591 9DD5 +9DD6 9DD6 EC9592 9DD6 +9DD7 9DD7 EC9596 9DD7 +9DD8 9DD8 EC959A 9DD8 +9DD9 9DD9 EC959B 9DD9 +9DDA 9DDA EC959C 9DDA +9DDB 9DDB EC959F 9DDB +9DDC 9DDC EC95A2 9DDC +9DDD 9DDD EC95A3 9DDD +9DDE 9DDE EC95A5 9DDE +9DDF 9DDF EC95A6 9DDF +9DE0 9DE0 EC95A7 9DE0 +9DE1 9DE1 EC95A9 9DE1 +9DE2 9DE2 EC95AA 9DE2 +9DE3 9DE3 EC95AB 9DE3 +9DE4 9DE4 EC95AC 9DE4 +9DE5 9DE5 EC95AD 9DE5 +9DE6 9DE6 EC95AE 9DE6 +9DE7 9DE7 EC95AF 9DE7 +9DE8 9DE8 EC95B2 9DE8 +9DE9 9DE9 EC95B6 9DE9 +9DEA 9DEA EC95B7 9DEA +9DEB 9DEB EC95B8 9DEB +9DEC 9DEC EC95B9 9DEC +9DED 9DED EC95BA 9DED +9DEE 9DEE EC95BB 9DEE +9DEF 9DEF EC95BE 9DEF +9DF0 9DF0 EC95BF 9DF0 +9DF1 9DF1 EC9681 9DF1 +9DF2 9DF2 EC9682 9DF2 +9DF3 9DF3 EC9683 9DF3 +9DF4 9DF4 EC9685 9DF4 +9DF5 9DF5 EC9686 9DF5 +9DF6 9DF6 EC9688 9DF6 +9DF7 9DF7 EC9689 9DF7 +9DF8 9DF8 EC968A 9DF8 +9DF9 9DF9 EC968B 9DF9 +9DFA 9DFA EC968E 9DFA +9DFB 9DFB EC9690 9DFB +9DFC 9DFC EC9692 9DFC +9DFD 9DFD EC9693 9DFD +9DFE 9DFE EC9694 9DFE +9E41 9E41 EC9696 9E41 +9E42 9E42 EC9699 9E42 +9E43 9E43 EC969A 9E43 +9E44 9E44 EC969B 9E44 +9E45 9E45 EC969D 9E45 +9E46 9E46 EC969E 9E46 +9E47 9E47 EC969F 9E47 +9E48 9E48 EC96A1 9E48 +9E49 9E49 EC96A2 9E49 +9E4A 9E4A EC96A3 9E4A +9E4B 9E4B EC96A4 9E4B +9E4C 9E4C EC96A5 9E4C +9E4D 9E4D EC96A6 9E4D +9E4E 9E4E EC96A7 9E4E +9E4F 9E4F EC96A8 9E4F +9E50 9E50 EC96AA 9E50 +9E51 9E51 EC96AB 9E51 +9E52 9E52 EC96AC 9E52 +9E53 9E53 EC96AD 9E53 +9E54 9E54 EC96AE 9E54 +9E55 9E55 EC96AF 9E55 +9E56 9E56 EC96B0 9E56 +9E57 9E57 EC96B1 9E57 +9E58 9E58 EC96B2 9E58 +9E59 9E59 EC96B3 9E59 +9E5A 9E5A EC96B6 9E5A +9E61 9E61 EC96B7 9E61 +9E62 9E62 EC96BA 9E62 +9E63 9E63 EC96BF 9E63 +9E64 9E64 EC9780 9E64 +9E65 9E65 EC9781 9E65 +9E66 9E66 EC9782 9E66 +9E67 9E67 EC9783 9E67 +9E68 9E68 EC978B 9E68 +9E69 9E69 EC978D 9E69 +9E6A 9E6A EC978F 9E6A +9E6B 9E6B EC9792 9E6B +9E6C 9E6C EC9793 9E6C +9E6D 9E6D EC9795 9E6D +9E6E 9E6E EC9796 9E6E +9E6F 9E6F EC9797 9E6F +9E70 9E70 EC9799 9E70 +9E71 9E71 EC979A 9E71 +9E72 9E72 EC979B 9E72 +9E73 9E73 EC979C 9E73 +9E74 9E74 EC979D 9E74 +9E75 9E75 EC979E 9E75 +9E76 9E76 EC979F 9E76 +9E77 9E77 EC97A2 9E77 +9E78 9E78 EC97A4 9E78 +9E79 9E79 EC97A6 9E79 +9E7A 9E7A EC97A7 9E7A +9E81 9E81 EC97A8 9E81 +9E82 9E82 EC97A9 9E82 +9E83 9E83 EC97AA 9E83 +9E84 9E84 EC97AB 9E84 +9E85 9E85 EC97AF 9E85 +9E86 9E86 EC97B1 9E86 +9E87 9E87 EC97B2 9E87 +9E88 9E88 EC97B3 9E88 +9E89 9E89 EC97B5 9E89 +9E8A 9E8A EC97B8 9E8A +9E8B 9E8B EC97B9 9E8B +9E8C 9E8C EC97BA 9E8C +9E8D 9E8D EC97BB 9E8D +9E8E 9E8E EC9882 9E8E +9E8F 9E8F EC9883 9E8F +9E90 9E90 EC9884 9E90 +9E91 9E91 EC9889 9E91 +9E92 9E92 EC988A 9E92 +9E93 9E93 EC988B 9E93 +9E94 9E94 EC988D 9E94 +9E95 9E95 EC988E 9E95 +9E96 9E96 EC988F 9E96 +9E97 9E97 EC9891 9E97 +9E98 9E98 EC9892 9E98 +9E99 9E99 EC9893 9E99 +9E9A 9E9A EC9894 9E9A +9E9B 9E9B EC9895 9E9B +9E9C 9E9C EC9896 9E9C +9E9D 9E9D EC9897 9E9D +9E9E 9E9E EC989A 9E9E +9E9F 9E9F EC989D 9E9F +9EA0 9EA0 EC989E 9EA0 +9EA1 9EA1 EC989F 9EA1 +9EA2 9EA2 EC98A0 9EA2 +9EA3 9EA3 EC98A1 9EA3 +9EA4 9EA4 EC98A2 9EA4 +9EA5 9EA5 EC98A3 9EA5 +9EA6 9EA6 EC98A6 9EA6 +9EA7 9EA7 EC98A7 9EA7 +9EA8 9EA8 EC98A9 9EA8 +9EA9 9EA9 EC98AA 9EA9 +9EAA 9EAA EC98AB 9EAA +9EAB 9EAB EC98AF 9EAB +9EAC 9EAC EC98B1 9EAC +9EAD 9EAD EC98B2 9EAD +9EAE 9EAE EC98B6 9EAE +9EAF 9EAF EC98B8 9EAF +9EB0 9EB0 EC98BA 9EB0 +9EB1 9EB1 EC98BC 9EB1 +9EB2 9EB2 EC98BD 9EB2 +9EB3 9EB3 EC98BE 9EB3 +9EB4 9EB4 EC98BF 9EB4 +9EB5 9EB5 EC9982 9EB5 +9EB6 9EB6 EC9983 9EB6 +9EB7 9EB7 EC9985 9EB7 +9EB8 9EB8 EC9986 9EB8 +9EB9 9EB9 EC9987 9EB9 +9EBA 9EBA EC9989 9EBA +9EBB 9EBB EC998A 9EBB +9EBC 9EBC EC998B 9EBC +9EBD 9EBD EC998C 9EBD +9EBE 9EBE EC998D 9EBE +9EBF 9EBF EC998E 9EBF +9EC0 9EC0 EC998F 9EC0 +9EC1 9EC1 EC9992 9EC1 +9EC2 9EC2 EC9996 9EC2 +9EC3 9EC3 EC9997 9EC3 +9EC4 9EC4 EC9998 9EC4 +9EC5 9EC5 EC9999 9EC5 +9EC6 9EC6 EC999A 9EC6 +9EC7 9EC7 EC999B 9EC7 +9EC8 9EC8 EC999E 9EC8 +9EC9 9EC9 EC999F 9EC9 +9ECA 9ECA EC99A1 9ECA +9ECB 9ECB EC99A2 9ECB +9ECC 9ECC EC99A3 9ECC +9ECD 9ECD EC99A4 9ECD +9ECE 9ECE EC99A5 9ECE +9ECF 9ECF EC99A6 9ECF +9ED0 9ED0 EC99A7 9ED0 +9ED1 9ED1 EC99A8 9ED1 +9ED2 9ED2 EC99A9 9ED2 +9ED3 9ED3 EC99AA 9ED3 +9ED4 9ED4 EC99AB 9ED4 +9ED5 9ED5 EC99AD 9ED5 +9ED6 9ED6 EC99AE 9ED6 +9ED7 9ED7 EC99B0 9ED7 +9ED8 9ED8 EC99B2 9ED8 +9ED9 9ED9 EC99B3 9ED9 +9EDA 9EDA EC99B4 9EDA +9EDB 9EDB EC99B5 9EDB +9EDC 9EDC EC99B6 9EDC +9EDD 9EDD EC99B7 9EDD +9EDE 9EDE EC99BA 9EDE +9EDF 9EDF EC99BB 9EDF +9EE0 9EE0 EC99BD 9EE0 +9EE1 9EE1 EC99BE 9EE1 +9EE2 9EE2 EC99BF 9EE2 +9EE3 9EE3 EC9A81 9EE3 +9EE4 9EE4 EC9A82 9EE4 +9EE5 9EE5 EC9A83 9EE5 +9EE6 9EE6 EC9A84 9EE6 +9EE7 9EE7 EC9A85 9EE7 +9EE8 9EE8 EC9A86 9EE8 +9EE9 9EE9 EC9A87 9EE9 +9EEA 9EEA EC9A8A 9EEA +9EEB 9EEB EC9A8C 9EEB +9EEC 9EEC EC9A8E 9EEC +9EED 9EED EC9A8F 9EED +9EEE 9EEE EC9A90 9EEE +9EEF 9EEF EC9A91 9EEF +9EF0 9EF0 EC9A92 9EF0 +9EF1 9EF1 EC9A93 9EF1 +9EF2 9EF2 EC9A96 9EF2 +9EF3 9EF3 EC9A97 9EF3 +9EF4 9EF4 EC9A99 9EF4 +9EF5 9EF5 EC9A9A 9EF5 +9EF6 9EF6 EC9A9B 9EF6 +9EF7 9EF7 EC9A9D 9EF7 +9EF8 9EF8 EC9A9E 9EF8 +9EF9 9EF9 EC9A9F 9EF9 +9EFA 9EFA EC9AA0 9EFA +9EFB 9EFB EC9AA1 9EFB +9EFC 9EFC EC9AA2 9EFC +9EFD 9EFD EC9AA3 9EFD +9EFE 9EFE EC9AA6 9EFE +9F41 9F41 EC9AA8 9F41 +9F42 9F42 EC9AAA 9F42 +9F43 9F43 EC9AAB 9F43 +9F44 9F44 EC9AAC 9F44 +9F45 9F45 EC9AAD 9F45 +9F46 9F46 EC9AAE 9F46 +9F47 9F47 EC9AAF 9F47 +9F48 9F48 EC9AB2 9F48 +9F49 9F49 EC9AB3 9F49 +9F4A 9F4A EC9AB5 9F4A +9F4B 9F4B EC9AB6 9F4B +9F4C 9F4C EC9AB7 9F4C +9F4D 9F4D EC9ABB 9F4D +9F4E 9F4E EC9ABC 9F4E +9F4F 9F4F EC9ABD 9F4F +9F50 9F50 EC9ABE 9F50 +9F51 9F51 EC9ABF 9F51 +9F52 9F52 EC9B82 9F52 +9F53 9F53 EC9B84 9F53 +9F54 9F54 EC9B86 9F54 +9F55 9F55 EC9B87 9F55 +9F56 9F56 EC9B88 9F56 +9F57 9F57 EC9B89 9F57 +9F58 9F58 EC9B8A 9F58 +9F59 9F59 EC9B8B 9F59 +9F5A 9F5A EC9B8E 9F5A +9F61 9F61 EC9B8F 9F61 +9F62 9F62 EC9B91 9F62 +9F63 9F63 EC9B92 9F63 +9F64 9F64 EC9B93 9F64 +9F65 9F65 EC9B95 9F65 +9F66 9F66 EC9B96 9F66 +9F67 9F67 EC9B97 9F67 +9F68 9F68 EC9B98 9F68 +9F69 9F69 EC9B99 9F69 +9F6A 9F6A EC9B9A 9F6A +9F6B 9F6B EC9B9B 9F6B +9F6C 9F6C EC9B9E 9F6C +9F6D 9F6D EC9B9F 9F6D +9F6E 9F6E EC9BA2 9F6E +9F6F 9F6F EC9BA3 9F6F +9F70 9F70 EC9BA4 9F70 +9F71 9F71 EC9BA5 9F71 +9F72 9F72 EC9BA6 9F72 +9F73 9F73 EC9BA7 9F73 +9F74 9F74 EC9BAA 9F74 +9F75 9F75 EC9BAB 9F75 +9F76 9F76 EC9BAD 9F76 +9F77 9F77 EC9BAE 9F77 +9F78 9F78 EC9BAF 9F78 +9F79 9F79 EC9BB1 9F79 +9F7A 9F7A EC9BB2 9F7A +9F81 9F81 EC9BB3 9F81 +9F82 9F82 EC9BB4 9F82 +9F83 9F83 EC9BB5 9F83 +9F84 9F84 EC9BB6 9F84 +9F85 9F85 EC9BB7 9F85 +9F86 9F86 EC9BBA 9F86 +9F87 9F87 EC9BBB 9F87 +9F88 9F88 EC9BBC 9F88 +9F89 9F89 EC9BBE 9F89 +9F8A 9F8A EC9BBF 9F8A +9F8B 9F8B EC9C80 9F8B +9F8C 9F8C EC9C81 9F8C +9F8D 9F8D EC9C82 9F8D +9F8E 9F8E EC9C83 9F8E +9F8F 9F8F EC9C86 9F8F +9F90 9F90 EC9C87 9F90 +9F91 9F91 EC9C89 9F91 +9F92 9F92 EC9C8A 9F92 +9F93 9F93 EC9C8B 9F93 +9F94 9F94 EC9C8D 9F94 +9F95 9F95 EC9C8E 9F95 +9F96 9F96 EC9C8F 9F96 +9F97 9F97 EC9C90 9F97 +9F98 9F98 EC9C91 9F98 +9F99 9F99 EC9C92 9F99 +9F9A 9F9A EC9C93 9F9A +9F9B 9F9B EC9C96 9F9B +9F9C 9F9C EC9C98 9F9C +9F9D 9F9D EC9C9A 9F9D +9F9E 9F9E EC9C9B 9F9E +9F9F 9F9F EC9C9C 9F9F +9FA0 9FA0 EC9C9D 9FA0 +9FA1 9FA1 EC9C9E 9FA1 +9FA2 9FA2 EC9C9F 9FA2 +9FA3 9FA3 EC9CA2 9FA3 +9FA4 9FA4 EC9CA3 9FA4 +9FA5 9FA5 EC9CA5 9FA5 +9FA6 9FA6 EC9CA6 9FA6 +9FA7 9FA7 EC9CA7 9FA7 +9FA8 9FA8 EC9CA9 9FA8 +9FA9 9FA9 EC9CAA 9FA9 +9FAA 9FAA EC9CAB 9FAA +9FAB 9FAB EC9CAC 9FAB +9FAC 9FAC EC9CAD 9FAC +9FAD 9FAD EC9CAE 9FAD +9FAE 9FAE EC9CAF 9FAE +9FAF 9FAF EC9CB2 9FAF +9FB0 9FB0 EC9CB4 9FB0 +9FB1 9FB1 EC9CB6 9FB1 +9FB2 9FB2 EC9CB8 9FB2 +9FB3 9FB3 EC9CB9 9FB3 +9FB4 9FB4 EC9CBA 9FB4 +9FB5 9FB5 EC9CBB 9FB5 +9FB6 9FB6 EC9CBE 9FB6 +9FB7 9FB7 EC9CBF 9FB7 +9FB8 9FB8 EC9D81 9FB8 +9FB9 9FB9 EC9D82 9FB9 +9FBA 9FBA EC9D83 9FBA +9FBB 9FBB EC9D85 9FBB +9FBC 9FBC EC9D86 9FBC +9FBD 9FBD EC9D87 9FBD +9FBE 9FBE EC9D88 9FBE +9FBF 9FBF EC9D89 9FBF +9FC0 9FC0 EC9D8B 9FC0 +9FC1 9FC1 EC9D8E 9FC1 +9FC2 9FC2 EC9D90 9FC2 +9FC3 9FC3 EC9D99 9FC3 +9FC4 9FC4 EC9D9A 9FC4 +9FC5 9FC5 EC9D9B 9FC5 +9FC6 9FC6 EC9D9D 9FC6 +9FC7 9FC7 EC9D9E 9FC7 +9FC8 9FC8 EC9D9F 9FC8 +9FC9 9FC9 EC9DA1 9FC9 +9FCA 9FCA EC9DA2 9FCA +9FCB 9FCB EC9DA3 9FCB +9FCC 9FCC EC9DA4 9FCC +9FCD 9FCD EC9DA5 9FCD +9FCE 9FCE EC9DA6 9FCE +9FCF 9FCF EC9DA7 9FCF +9FD0 9FD0 EC9DA9 9FD0 +9FD1 9FD1 EC9DAA 9FD1 +9FD2 9FD2 EC9DAC 9FD2 +9FD3 9FD3 EC9DAD 9FD3 +9FD4 9FD4 EC9DAE 9FD4 +9FD5 9FD5 EC9DAF 9FD5 +9FD6 9FD6 EC9DB0 9FD6 +9FD7 9FD7 EC9DB1 9FD7 +9FD8 9FD8 EC9DB2 9FD8 +9FD9 9FD9 EC9DB3 9FD9 +9FDA 9FDA EC9DB6 9FDA +9FDB 9FDB EC9DB7 9FDB +9FDC 9FDC EC9DB9 9FDC +9FDD 9FDD EC9DBA 9FDD +9FDE 9FDE EC9DBB 9FDE +9FDF 9FDF EC9DBF 9FDF +9FE0 9FE0 EC9E80 9FE0 +9FE1 9FE1 EC9E81 9FE1 +9FE2 9FE2 EC9E82 9FE2 +9FE3 9FE3 EC9E86 9FE3 +9FE4 9FE4 EC9E8B 9FE4 +9FE5 9FE5 EC9E8C 9FE5 +9FE6 9FE6 EC9E8D 9FE6 +9FE7 9FE7 EC9E8F 9FE7 +9FE8 9FE8 EC9E92 9FE8 +9FE9 9FE9 EC9E93 9FE9 +9FEA 9FEA EC9E95 9FEA +9FEB 9FEB EC9E99 9FEB +9FEC 9FEC EC9E9B 9FEC +9FED 9FED EC9E9C 9FED +9FEE 9FEE EC9E9D 9FEE +9FEF 9FEF EC9E9E 9FEF +9FF0 9FF0 EC9E9F 9FF0 +9FF1 9FF1 EC9EA2 9FF1 +9FF2 9FF2 EC9EA7 9FF2 +9FF3 9FF3 EC9EA8 9FF3 +9FF4 9FF4 EC9EA9 9FF4 +9FF5 9FF5 EC9EAA 9FF5 +9FF6 9FF6 EC9EAB 9FF6 +9FF7 9FF7 EC9EAE 9FF7 +9FF8 9FF8 EC9EAF 9FF8 +9FF9 9FF9 EC9EB1 9FF9 +9FFA 9FFA EC9EB2 9FFA +9FFB 9FFB EC9EB3 9FFB +9FFC 9FFC EC9EB5 9FFC +9FFD 9FFD EC9EB6 9FFD +9FFE 9FFE EC9EB7 9FFE +A041 A041 EC9EB8 A041 +A042 A042 EC9EB9 A042 +A043 A043 EC9EBA A043 +A044 A044 EC9EBB A044 +A045 A045 EC9EBE A045 +A046 A046 EC9F82 A046 +A047 A047 EC9F83 A047 +A048 A048 EC9F84 A048 +A049 A049 EC9F85 A049 +A04A A04A EC9F86 A04A +A04B A04B EC9F87 A04B +A04C A04C EC9F8A A04C +A04D A04D EC9F8B A04D +A04E A04E EC9F8D A04E +A04F A04F EC9F8F A04F +A050 A050 EC9F91 A050 +A051 A051 EC9F92 A051 +A052 A052 EC9F93 A052 +A053 A053 EC9F94 A053 +A054 A054 EC9F95 A054 +A055 A055 EC9F96 A055 +A056 A056 EC9F97 A056 +A057 A057 EC9F99 A057 +A058 A058 EC9F9A A058 +A059 A059 EC9F9B A059 +A05A A05A EC9F9C A05A +A061 A061 EC9F9E A061 +A062 A062 EC9F9F A062 +A063 A063 EC9FA0 A063 +A064 A064 EC9FA1 A064 +A065 A065 EC9FA2 A065 +A066 A066 EC9FA3 A066 +A067 A067 EC9FA5 A067 +A068 A068 EC9FA6 A068 +A069 A069 EC9FA7 A069 +A06A A06A EC9FA9 A06A +A06B A06B EC9FAA A06B +A06C A06C EC9FAB A06C +A06D A06D EC9FAD A06D +A06E A06E EC9FAE A06E +A06F A06F EC9FAF A06F +A070 A070 EC9FB0 A070 +A071 A071 EC9FB1 A071 +A072 A072 EC9FB2 A072 +A073 A073 EC9FB3 A073 +A074 A074 EC9FB4 A074 +A075 A075 EC9FB5 A075 +A076 A076 EC9FB6 A076 +A077 A077 EC9FB7 A077 +A078 A078 EC9FB8 A078 +A079 A079 EC9FB9 A079 +A07A A07A EC9FBA A07A +A081 A081 EC9FBB A081 +A082 A082 EC9FBC A082 +A083 A083 EC9FBD A083 +A084 A084 EC9FBE A084 +A085 A085 EC9FBF A085 +A086 A086 ECA082 A086 +A087 A087 ECA083 A087 +A088 A088 ECA085 A088 +A089 A089 ECA086 A089 +A08A A08A ECA087 A08A +A08B A08B ECA089 A08B +A08C A08C ECA08B A08C +A08D A08D ECA08C A08D +A08E A08E ECA08D A08E +A08F A08F ECA08E A08F +A090 A090 ECA08F A090 +A091 A091 ECA092 A091 +A092 A092 ECA094 A092 +A093 A093 ECA097 A093 +A094 A094 ECA098 A094 +A095 A095 ECA099 A095 +A096 A096 ECA09A A096 +A097 A097 ECA09B A097 +A098 A098 ECA09E A098 +A099 A099 ECA09F A099 +A09A A09A ECA0A1 A09A +A09B A09B ECA0A2 A09B +A09C A09C ECA0A3 A09C +A09D A09D ECA0A5 A09D +A09E A09E ECA0A6 A09E +A09F A09F ECA0A7 A09F +A0A0 A0A0 ECA0A8 A0A0 +A0A1 A0A1 ECA0A9 A0A1 +A0A2 A0A2 ECA0AA A0A2 +A0A3 A0A3 ECA0AB A0A3 +A0A4 A0A4 ECA0AE A0A4 +A0A5 A0A5 ECA0B0 A0A5 +A0A6 A0A6 ECA0B2 A0A6 +A0A7 A0A7 ECA0B3 A0A7 +A0A8 A0A8 ECA0B4 A0A8 +A0A9 A0A9 ECA0B5 A0A9 +A0AA A0AA ECA0B6 A0AA +A0AB A0AB ECA0B7 A0AB +A0AC A0AC ECA0B9 A0AC +A0AD A0AD ECA0BA A0AD +A0AE A0AE ECA0BB A0AE +A0AF A0AF ECA0BD A0AF +A0B0 A0B0 ECA0BE A0B0 +A0B1 A0B1 ECA0BF A0B1 +A0B2 A0B2 ECA181 A0B2 +A0B3 A0B3 ECA182 A0B3 +A0B4 A0B4 ECA183 A0B4 +A0B5 A0B5 ECA184 A0B5 +A0B6 A0B6 ECA185 A0B6 +A0B7 A0B7 ECA186 A0B7 +A0B8 A0B8 ECA187 A0B8 +A0B9 A0B9 ECA18A A0B9 +A0BA A0BA ECA18B A0BA +A0BB A0BB ECA18E A0BB +A0BC A0BC ECA18F A0BC +A0BD A0BD ECA190 A0BD +A0BE A0BE ECA191 A0BE +A0BF A0BF ECA192 A0BF +A0C0 A0C0 ECA193 A0C0 +A0C1 A0C1 ECA195 A0C1 +A0C2 A0C2 ECA196 A0C2 +A0C3 A0C3 ECA197 A0C3 +A0C4 A0C4 ECA198 A0C4 +A0C5 A0C5 ECA199 A0C5 +A0C6 A0C6 ECA19A A0C6 +A0C7 A0C7 ECA19B A0C7 +A0C8 A0C8 ECA19C A0C8 +A0C9 A0C9 ECA19D A0C9 +A0CA A0CA ECA19E A0CA +A0CB A0CB ECA19F A0CB +A0CC A0CC ECA1A0 A0CC +A0CD A0CD ECA1A1 A0CD +A0CE A0CE ECA1A2 A0CE +A0CF A0CF ECA1A3 A0CF +A0D0 A0D0 ECA1A4 A0D0 +A0D1 A0D1 ECA1A5 A0D1 +A0D2 A0D2 ECA1A6 A0D2 +A0D3 A0D3 ECA1A7 A0D3 +A0D4 A0D4 ECA1A8 A0D4 +A0D5 A0D5 ECA1A9 A0D5 +A0D6 A0D6 ECA1AA A0D6 +A0D7 A0D7 ECA1AB A0D7 +A0D8 A0D8 ECA1AC A0D8 +A0D9 A0D9 ECA1AD A0D9 +A0DA A0DA ECA1AE A0DA +A0DB A0DB ECA1AF A0DB +A0DC A0DC ECA1B2 A0DC +A0DD A0DD ECA1B3 A0DD +A0DE A0DE ECA1B5 A0DE +A0DF A0DF ECA1B6 A0DF +A0E0 A0E0 ECA1B7 A0E0 +A0E1 A0E1 ECA1B9 A0E1 +A0E2 A0E2 ECA1BB A0E2 +A0E3 A0E3 ECA1BC A0E3 +A0E4 A0E4 ECA1BD A0E4 +A0E5 A0E5 ECA1BE A0E5 +A0E6 A0E6 ECA1BF A0E6 +A0E7 A0E7 ECA282 A0E7 +A0E8 A0E8 ECA284 A0E8 +A0E9 A0E9 ECA288 A0E9 +A0EA A0EA ECA289 A0EA +A0EB A0EB ECA28A A0EB +A0EC A0EC ECA28E A0EC +A0ED A0ED ECA28F A0ED +A0EE A0EE ECA290 A0EE +A0EF A0EF ECA291 A0EF +A0F0 A0F0 ECA292 A0F0 +A0F1 A0F1 ECA293 A0F1 +A0F2 A0F2 ECA295 A0F2 +A0F3 A0F3 ECA296 A0F3 +A0F4 A0F4 ECA297 A0F4 +A0F5 A0F5 ECA298 A0F5 +A0F6 A0F6 ECA299 A0F6 +A0F7 A0F7 ECA29A A0F7 +A0F8 A0F8 ECA29B A0F8 +A0F9 A0F9 ECA29C A0F9 +A0FA A0FA ECA29E A0FA +A0FB A0FB ECA2A0 A0FB +A0FC A0FC ECA2A2 A0FC +A0FD A0FD ECA2A3 A0FD +A0FE A0FE ECA2A4 A0FE +A141 A141 ECA2A5 A141 +A142 A142 ECA2A6 A142 +A143 A143 ECA2A7 A143 +A144 A144 ECA2A9 A144 +A145 A145 ECA2AA A145 +A146 A146 ECA2AB A146 +A147 A147 ECA2AC A147 +A148 A148 ECA2AD A148 +A149 A149 ECA2AE A149 +A14A A14A ECA2AF A14A +A14B A14B ECA2B0 A14B +A14C A14C ECA2B1 A14C +A14D A14D ECA2B2 A14D +A14E A14E ECA2B3 A14E +A14F A14F ECA2B4 A14F +A150 A150 ECA2B5 A150 +A151 A151 ECA2B6 A151 +A152 A152 ECA2B7 A152 +A153 A153 ECA2B8 A153 +A154 A154 ECA2B9 A154 +A155 A155 ECA2BA A155 +A156 A156 ECA2BB A156 +A157 A157 ECA2BE A157 +A158 A158 ECA2BF A158 +A159 A159 ECA380 A159 +A15A A15A ECA381 A15A +A161 A161 ECA382 A161 +A162 A162 ECA383 A162 +A163 A163 ECA385 A163 +A164 A164 ECA386 A164 +A165 A165 ECA387 A165 +A166 A166 ECA389 A166 +A167 A167 ECA38A A167 +A168 A168 ECA38B A168 +A169 A169 ECA38D A169 +A16A A16A ECA38E A16A +A16B A16B ECA38F A16B +A16C A16C ECA390 A16C +A16D A16D ECA391 A16D +A16E A16E ECA392 A16E +A16F A16F ECA393 A16F +A170 A170 ECA396 A170 +A171 A171 ECA398 A171 +A172 A172 ECA39A A172 +A173 A173 ECA39B A173 +A174 A174 ECA39C A174 +A175 A175 ECA39D A175 +A176 A176 ECA39E A176 +A177 A177 ECA39F A177 +A178 A178 ECA3A2 A178 +A179 A179 ECA3A3 A179 +A17A A17A ECA3A5 A17A +A181 A181 ECA3A6 A181 +A182 A182 ECA3A7 A182 +A183 A183 ECA3A8 A183 +A184 A184 ECA3A9 A184 +A185 A185 ECA3AA A185 +A186 A186 ECA3AB A186 +A187 A187 ECA3AC A187 +A188 A188 ECA3AD A188 +A189 A189 ECA3AE A189 +A18A A18A ECA3AF A18A +A18B A18B ECA3B0 A18B +A18C A18C ECA3B1 A18C +A18D A18D ECA3B2 A18D +A18E A18E ECA3B3 A18E +A18F A18F ECA3B4 A18F +A190 A190 ECA3B6 A190 +A191 A191 ECA3B7 A191 +A192 A192 ECA3B8 A192 +A193 A193 ECA3B9 A193 +A194 A194 ECA3BA A194 +A195 A195 ECA3BB A195 +A196 A196 ECA3BE A196 +A197 A197 ECA3BF A197 +A198 A198 ECA481 A198 +A199 A199 ECA482 A199 +A19A A19A ECA483 A19A +A19B A19B ECA487 A19B +A19C A19C ECA488 A19C +A19D A19D ECA489 A19D +A19E A19E ECA48A A19E +A19F A19F ECA48B A19F +A1A0 A1A0 ECA48E A1A0 +A1A1 A1A1 E38080 A1A1 +A1A2 A1A2 E38081 A1A2 +A1A3 A1A3 E38082 A1A3 +A1A4 A1A4 C2B7 A1A4 +A1A5 A1A5 E280A5 A1A5 +A1A6 A1A6 E280A6 A1A6 +A1A7 A1A7 C2A8 A1A7 +A1A8 A1A8 E38083 A1A8 +A1A9 A1A9 C2AD A1A9 +A1AA A1AA E28095 A1AA +A1AB A1AB E288A5 A1AB +A1AC A1AC EFBCBC A1AC +A1AD A1AD E288BC A1AD +A1AE A1AE E28098 A1AE +A1AF A1AF E28099 A1AF +A1B0 A1B0 E2809C A1B0 +A1B1 A1B1 E2809D A1B1 +A1B2 A1B2 E38094 A1B2 +A1B3 A1B3 E38095 A1B3 +A1B4 A1B4 E38088 A1B4 +A1B5 A1B5 E38089 A1B5 +A1B6 A1B6 E3808A A1B6 +A1B7 A1B7 E3808B A1B7 +A1B8 A1B8 E3808C A1B8 +A1B9 A1B9 E3808D A1B9 +A1BA A1BA E3808E A1BA +A1BB A1BB E3808F A1BB +A1BC A1BC E38090 A1BC +A1BD A1BD E38091 A1BD +A1BE A1BE C2B1 A1BE +A1BF A1BF C397 A1BF +A1C0 A1C0 C3B7 A1C0 +A1C1 A1C1 E289A0 A1C1 +A1C2 A1C2 E289A4 A1C2 +A1C3 A1C3 E289A5 A1C3 +A1C4 A1C4 E2889E A1C4 +A1C5 A1C5 E288B4 A1C5 +A1C6 A1C6 C2B0 A1C6 +A1C7 A1C7 E280B2 A1C7 +A1C8 A1C8 E280B3 A1C8 +A1C9 A1C9 E28483 A1C9 +A1CA A1CA E284AB A1CA +A1CB A1CB EFBFA0 A1CB +A1CC A1CC EFBFA1 A1CC +A1CD A1CD EFBFA5 A1CD +A1CE A1CE E29982 A1CE +A1CF A1CF E29980 A1CF +A1D0 A1D0 E288A0 A1D0 +A1D1 A1D1 E28AA5 A1D1 +A1D2 A1D2 E28C92 A1D2 +A1D3 A1D3 E28882 A1D3 +A1D4 A1D4 E28887 A1D4 +A1D5 A1D5 E289A1 A1D5 +A1D6 A1D6 E28992 A1D6 +A1D7 A1D7 C2A7 A1D7 +A1D8 A1D8 E280BB A1D8 +A1D9 A1D9 E29886 A1D9 +A1DA A1DA E29885 A1DA +A1DB A1DB E2978B A1DB +A1DC A1DC E2978F A1DC +A1DD A1DD E2978E A1DD +A1DE A1DE E29787 A1DE +A1DF A1DF E29786 A1DF +A1E0 A1E0 E296A1 A1E0 +A1E1 A1E1 E296A0 A1E1 +A1E2 A1E2 E296B3 A1E2 +A1E3 A1E3 E296B2 A1E3 +A1E4 A1E4 E296BD A1E4 +A1E5 A1E5 E296BC A1E5 +A1E6 A1E6 E28692 A1E6 +A1E7 A1E7 E28690 A1E7 +A1E8 A1E8 E28691 A1E8 +A1E9 A1E9 E28693 A1E9 +A1EA A1EA E28694 A1EA +A1EB A1EB E38093 A1EB +A1EC A1EC E289AA A1EC +A1ED A1ED E289AB A1ED +A1EE A1EE E2889A A1EE +A1EF A1EF E288BD A1EF +A1F0 A1F0 E2889D A1F0 +A1F1 A1F1 E288B5 A1F1 +A1F2 A1F2 E288AB A1F2 +A1F3 A1F3 E288AC A1F3 +A1F4 A1F4 E28888 A1F4 +A1F5 A1F5 E2888B A1F5 +A1F6 A1F6 E28A86 A1F6 +A1F7 A1F7 E28A87 A1F7 +A1F8 A1F8 E28A82 A1F8 +A1F9 A1F9 E28A83 A1F9 +A1FA A1FA E288AA A1FA +A1FB A1FB E288A9 A1FB +A1FC A1FC E288A7 A1FC +A1FD A1FD E288A8 A1FD +A1FE A1FE EFBFA2 A1FE +A241 A241 ECA490 A241 +A242 A242 ECA492 A242 +A243 A243 ECA493 A243 +A244 A244 ECA494 A244 +A245 A245 ECA495 A245 +A246 A246 ECA496 A246 +A247 A247 ECA497 A247 +A248 A248 ECA499 A248 +A249 A249 ECA49A A249 +A24A A24A ECA49B A24A +A24B A24B ECA49C A24B +A24C A24C ECA49D A24C +A24D A24D ECA49E A24D +A24E A24E ECA49F A24E +A24F A24F ECA4A0 A24F +A250 A250 ECA4A1 A250 +A251 A251 ECA4A2 A251 +A252 A252 ECA4A3 A252 +A253 A253 ECA4A4 A253 +A254 A254 ECA4A5 A254 +A255 A255 ECA4A6 A255 +A256 A256 ECA4A7 A256 +A257 A257 ECA4A8 A257 +A258 A258 ECA4A9 A258 +A259 A259 ECA4AA A259 +A25A A25A ECA4AB A25A +A261 A261 ECA4AD A261 +A262 A262 ECA4AE A262 +A263 A263 ECA4AF A263 +A264 A264 ECA4B0 A264 +A265 A265 ECA4B1 A265 +A266 A266 ECA4B2 A266 +A267 A267 ECA4B3 A267 +A268 A268 ECA4B5 A268 +A269 A269 ECA4B6 A269 +A26A A26A ECA4B7 A26A +A26B A26B ECA4B8 A26B +A26C A26C ECA4B9 A26C +A26D A26D ECA4BA A26D +A26E A26E ECA4BB A26E +A26F A26F ECA4BC A26F +A270 A270 ECA4BD A270 +A271 A271 ECA4BE A271 +A272 A272 ECA4BF A272 +A273 A273 ECA580 A273 +A274 A274 ECA581 A274 +A275 A275 ECA582 A275 +A276 A276 ECA583 A276 +A277 A277 ECA584 A277 +A278 A278 ECA585 A278 +A279 A279 ECA586 A279 +A27A A27A ECA587 A27A +A281 A281 ECA588 A281 +A282 A282 ECA589 A282 +A283 A283 ECA58A A283 +A284 A284 ECA58B A284 +A285 A285 ECA58C A285 +A286 A286 ECA58D A286 +A287 A287 ECA58E A287 +A288 A288 ECA58F A288 +A289 A289 ECA592 A289 +A28A A28A ECA593 A28A +A28B A28B ECA595 A28B +A28C A28C ECA596 A28C +A28D A28D ECA597 A28D +A28E A28E ECA599 A28E +A28F A28F ECA59A A28F +A290 A290 ECA59B A290 +A291 A291 ECA59C A291 +A292 A292 ECA59D A292 +A293 A293 ECA59E A293 +A294 A294 ECA59F A294 +A295 A295 ECA5A2 A295 +A296 A296 ECA5A4 A296 +A297 A297 ECA5A5 A297 +A298 A298 ECA5A6 A298 +A299 A299 ECA5A7 A299 +A29A A29A ECA5A8 A29A +A29B A29B ECA5A9 A29B +A29C A29C ECA5AA A29C +A29D A29D ECA5AB A29D +A29E A29E ECA5AD A29E +A29F A29F ECA5AE A29F +A2A0 A2A0 ECA5AF A2A0 +A2A1 A2A1 E28792 A2A1 +A2A2 A2A2 E28794 A2A2 +A2A3 A2A3 E28880 A2A3 +A2A4 A2A4 E28883 A2A4 +A2A5 A2A5 C2B4 A2A5 +A2A6 A2A6 EFBD9E A2A6 +A2A7 A2A7 CB87 A2A7 +A2A8 A2A8 CB98 A2A8 +A2A9 A2A9 CB9D A2A9 +A2AA A2AA CB9A A2AA +A2AB A2AB CB99 A2AB +A2AC A2AC C2B8 A2AC +A2AD A2AD CB9B A2AD +A2AE A2AE C2A1 A2AE +A2AF A2AF C2BF A2AF +A2B0 A2B0 CB90 A2B0 +A2B1 A2B1 E288AE A2B1 +A2B2 A2B2 E28891 A2B2 +A2B3 A2B3 E2888F A2B3 +A2B4 A2B4 C2A4 A2B4 +A2B5 A2B5 E28489 A2B5 +A2B6 A2B6 E280B0 A2B6 +A2B7 A2B7 E29781 A2B7 +A2B8 A2B8 E29780 A2B8 +A2B9 A2B9 E296B7 A2B9 +A2BA A2BA E296B6 A2BA +A2BB A2BB E299A4 A2BB +A2BC A2BC E299A0 A2BC +A2BD A2BD E299A1 A2BD +A2BE A2BE E299A5 A2BE +A2BF A2BF E299A7 A2BF +A2C0 A2C0 E299A3 A2C0 +A2C1 A2C1 E28A99 A2C1 +A2C2 A2C2 E29788 A2C2 +A2C3 A2C3 E296A3 A2C3 +A2C4 A2C4 E29790 A2C4 +A2C5 A2C5 E29791 A2C5 +A2C6 A2C6 E29692 A2C6 +A2C7 A2C7 E296A4 A2C7 +A2C8 A2C8 E296A5 A2C8 +A2C9 A2C9 E296A8 A2C9 +A2CA A2CA E296A7 A2CA +A2CB A2CB E296A6 A2CB +A2CC A2CC E296A9 A2CC +A2CD A2CD E299A8 A2CD +A2CE A2CE E2988F A2CE +A2CF A2CF E2988E A2CF +A2D0 A2D0 E2989C A2D0 +A2D1 A2D1 E2989E A2D1 +A2D2 A2D2 C2B6 A2D2 +A2D3 A2D3 E280A0 A2D3 +A2D4 A2D4 E280A1 A2D4 +A2D5 A2D5 E28695 A2D5 +A2D6 A2D6 E28697 A2D6 +A2D7 A2D7 E28699 A2D7 +A2D8 A2D8 E28696 A2D8 +A2D9 A2D9 E28698 A2D9 +A2DA A2DA E299AD A2DA +A2DB A2DB E299A9 A2DB +A2DC A2DC E299AA A2DC +A2DD A2DD E299AC A2DD +A2DE A2DE E389BF A2DE +A2DF A2DF E3889C A2DF +A2E0 A2E0 E28496 A2E0 +A2E1 A2E1 E38F87 A2E1 +A2E2 A2E2 E284A2 A2E2 +A2E3 A2E3 E38F82 A2E3 +A2E4 A2E4 E38F98 A2E4 +A2E5 A2E5 E284A1 A2E5 +A2E6 A2E6 E282AC A2E6 +A2E7 A2E7 C2AE A2E7 +A341 A341 ECA5B1 A341 +A342 A342 ECA5B2 A342 +A343 A343 ECA5B3 A343 +A344 A344 ECA5B5 A344 +A345 A345 ECA5B6 A345 +A346 A346 ECA5B7 A346 +A347 A347 ECA5B8 A347 +A348 A348 ECA5B9 A348 +A349 A349 ECA5BA A349 +A34A A34A ECA5BB A34A +A34B A34B ECA5BD A34B +A34C A34C ECA5BE A34C +A34D A34D ECA5BF A34D +A34E A34E ECA680 A34E +A34F A34F ECA681 A34F +A350 A350 ECA682 A350 +A351 A351 ECA683 A351 +A352 A352 ECA684 A352 +A353 A353 ECA685 A353 +A354 A354 ECA686 A354 +A355 A355 ECA687 A355 +A356 A356 ECA68A A356 +A357 A357 ECA68B A357 +A358 A358 ECA68D A358 +A359 A359 ECA68E A359 +A35A A35A ECA68F A35A +A361 A361 ECA691 A361 +A362 A362 ECA692 A362 +A363 A363 ECA693 A363 +A364 A364 ECA694 A364 +A365 A365 ECA695 A365 +A366 A366 ECA696 A366 +A367 A367 ECA697 A367 +A368 A368 ECA69A A368 +A369 A369 ECA69C A369 +A36A A36A ECA69E A36A +A36B A36B ECA69F A36B +A36C A36C ECA6A0 A36C +A36D A36D ECA6A1 A36D +A36E A36E ECA6A2 A36E +A36F A36F ECA6A3 A36F +A370 A370 ECA6A4 A370 +A371 A371 ECA6A5 A371 +A372 A372 ECA6A6 A372 +A373 A373 ECA6A7 A373 +A374 A374 ECA6A8 A374 +A375 A375 ECA6A9 A375 +A376 A376 ECA6AA A376 +A377 A377 ECA6AB A377 +A378 A378 ECA6AC A378 +A379 A379 ECA6AD A379 +A37A A37A ECA6AE A37A +A381 A381 ECA6AF A381 +A382 A382 ECA6B0 A382 +A383 A383 ECA6B1 A383 +A384 A384 ECA6B2 A384 +A385 A385 ECA6B3 A385 +A386 A386 ECA6B4 A386 +A387 A387 ECA6B5 A387 +A388 A388 ECA6B6 A388 +A389 A389 ECA6B7 A389 +A38A A38A ECA6B8 A38A +A38B A38B ECA6B9 A38B +A38C A38C ECA6BA A38C +A38D A38D ECA6BB A38D +A38E A38E ECA6BC A38E +A38F A38F ECA6BD A38F +A390 A390 ECA6BE A390 +A391 A391 ECA6BF A391 +A392 A392 ECA782 A392 +A393 A393 ECA783 A393 +A394 A394 ECA785 A394 +A395 A395 ECA786 A395 +A396 A396 ECA789 A396 +A397 A397 ECA78B A397 +A398 A398 ECA78C A398 +A399 A399 ECA78D A399 +A39A A39A ECA78E A39A +A39B A39B ECA78F A39B +A39C A39C ECA792 A39C +A39D A39D ECA794 A39D +A39E A39E ECA797 A39E +A39F A39F ECA798 A39F +A3A0 A3A0 ECA79B A3A0 +A3A1 A3A1 EFBC81 A3A1 +A3A2 A3A2 EFBC82 A3A2 +A3A3 A3A3 EFBC83 A3A3 +A3A4 A3A4 EFBC84 A3A4 +A3A5 A3A5 EFBC85 A3A5 +A3A6 A3A6 EFBC86 A3A6 +A3A7 A3A7 EFBC87 A3A7 +A3A8 A3A8 EFBC88 A3A8 +A3A9 A3A9 EFBC89 A3A9 +A3AA A3AA EFBC8A A3AA +A3AB A3AB EFBC8B A3AB +A3AC A3AC EFBC8C A3AC +A3AD A3AD EFBC8D A3AD +A3AE A3AE EFBC8E A3AE +A3AF A3AF EFBC8F A3AF +A3B0 A3B0 EFBC90 A3B0 +A3B1 A3B1 EFBC91 A3B1 +A3B2 A3B2 EFBC92 A3B2 +A3B3 A3B3 EFBC93 A3B3 +A3B4 A3B4 EFBC94 A3B4 +A3B5 A3B5 EFBC95 A3B5 +A3B6 A3B6 EFBC96 A3B6 +A3B7 A3B7 EFBC97 A3B7 +A3B8 A3B8 EFBC98 A3B8 +A3B9 A3B9 EFBC99 A3B9 +A3BA A3BA EFBC9A A3BA +A3BB A3BB EFBC9B A3BB +A3BC A3BC EFBC9C A3BC +A3BD A3BD EFBC9D A3BD +A3BE A3BE EFBC9E A3BE +A3BF A3BF EFBC9F A3BF +A3C0 A3C0 EFBCA0 A3C0 +A3C1 A3C1 EFBCA1 A3C1 +A3C2 A3C2 EFBCA2 A3C2 +A3C3 A3C3 EFBCA3 A3C3 +A3C4 A3C4 EFBCA4 A3C4 +A3C5 A3C5 EFBCA5 A3C5 +A3C6 A3C6 EFBCA6 A3C6 +A3C7 A3C7 EFBCA7 A3C7 +A3C8 A3C8 EFBCA8 A3C8 +A3C9 A3C9 EFBCA9 A3C9 +A3CA A3CA EFBCAA A3CA +A3CB A3CB EFBCAB A3CB +A3CC A3CC EFBCAC A3CC +A3CD A3CD EFBCAD A3CD +A3CE A3CE EFBCAE A3CE +A3CF A3CF EFBCAF A3CF +A3D0 A3D0 EFBCB0 A3D0 +A3D1 A3D1 EFBCB1 A3D1 +A3D2 A3D2 EFBCB2 A3D2 +A3D3 A3D3 EFBCB3 A3D3 +A3D4 A3D4 EFBCB4 A3D4 +A3D5 A3D5 EFBCB5 A3D5 +A3D6 A3D6 EFBCB6 A3D6 +A3D7 A3D7 EFBCB7 A3D7 +A3D8 A3D8 EFBCB8 A3D8 +A3D9 A3D9 EFBCB9 A3D9 +A3DA A3DA EFBCBA A3DA +A3DB A3DB EFBCBB A3DB +A3DC A3DC EFBFA6 A3DC +A3DD A3DD EFBCBD A3DD +A3DE A3DE EFBCBE A3DE +A3DF A3DF EFBCBF A3DF +A3E0 A3E0 EFBD80 A3E0 +A3E1 A3E1 EFBD81 A3E1 +A3E2 A3E2 EFBD82 A3E2 +A3E3 A3E3 EFBD83 A3E3 +A3E4 A3E4 EFBD84 A3E4 +A3E5 A3E5 EFBD85 A3E5 +A3E6 A3E6 EFBD86 A3E6 +A3E7 A3E7 EFBD87 A3E7 +A3E8 A3E8 EFBD88 A3E8 +A3E9 A3E9 EFBD89 A3E9 +A3EA A3EA EFBD8A A3EA +A3EB A3EB EFBD8B A3EB +A3EC A3EC EFBD8C A3EC +A3ED A3ED EFBD8D A3ED +A3EE A3EE EFBD8E A3EE +A3EF A3EF EFBD8F A3EF +A3F0 A3F0 EFBD90 A3F0 +A3F1 A3F1 EFBD91 A3F1 +A3F2 A3F2 EFBD92 A3F2 +A3F3 A3F3 EFBD93 A3F3 +A3F4 A3F4 EFBD94 A3F4 +A3F5 A3F5 EFBD95 A3F5 +A3F6 A3F6 EFBD96 A3F6 +A3F7 A3F7 EFBD97 A3F7 +A3F8 A3F8 EFBD98 A3F8 +A3F9 A3F9 EFBD99 A3F9 +A3FA A3FA EFBD9A A3FA +A3FB A3FB EFBD9B A3FB +A3FC A3FC EFBD9C A3FC +A3FD A3FD EFBD9D A3FD +A3FE A3FE EFBFA3 A3FE +A441 A441 ECA79E A441 +A442 A442 ECA79F A442 +A443 A443 ECA7A1 A443 +A444 A444 ECA7A3 A444 +A445 A445 ECA7A5 A445 +A446 A446 ECA7A6 A446 +A447 A447 ECA7A8 A447 +A448 A448 ECA7A9 A448 +A449 A449 ECA7AA A449 +A44A A44A ECA7AB A44A +A44B A44B ECA7AE A44B +A44C A44C ECA7B2 A44C +A44D A44D ECA7B3 A44D +A44E A44E ECA7B4 A44E +A44F A44F ECA7B5 A44F +A450 A450 ECA7B6 A450 +A451 A451 ECA7B7 A451 +A452 A452 ECA7BA A452 +A453 A453 ECA7BB A453 +A454 A454 ECA7BD A454 +A455 A455 ECA7BE A455 +A456 A456 ECA7BF A456 +A457 A457 ECA881 A457 +A458 A458 ECA882 A458 +A459 A459 ECA883 A459 +A45A A45A ECA884 A45A +A461 A461 ECA885 A461 +A462 A462 ECA886 A462 +A463 A463 ECA887 A463 +A464 A464 ECA88A A464 +A465 A465 ECA88E A465 +A466 A466 ECA88F A466 +A467 A467 ECA890 A467 +A468 A468 ECA891 A468 +A469 A469 ECA892 A469 +A46A A46A ECA893 A46A +A46B A46B ECA895 A46B +A46C A46C ECA896 A46C +A46D A46D ECA897 A46D +A46E A46E ECA899 A46E +A46F A46F ECA89A A46F +A470 A470 ECA89B A470 +A471 A471 ECA89C A471 +A472 A472 ECA89D A472 +A473 A473 ECA89E A473 +A474 A474 ECA89F A474 +A475 A475 ECA8A0 A475 +A476 A476 ECA8A1 A476 +A477 A477 ECA8A2 A477 +A478 A478 ECA8A3 A478 +A479 A479 ECA8A4 A479 +A47A A47A ECA8A5 A47A +A481 A481 ECA8A6 A481 +A482 A482 ECA8A7 A482 +A483 A483 ECA8A8 A483 +A484 A484 ECA8AA A484 +A485 A485 ECA8AB A485 +A486 A486 ECA8AC A486 +A487 A487 ECA8AD A487 +A488 A488 ECA8AE A488 +A489 A489 ECA8AF A489 +A48A A48A ECA8B0 A48A +A48B A48B ECA8B1 A48B +A48C A48C ECA8B2 A48C +A48D A48D ECA8B3 A48D +A48E A48E ECA8B4 A48E +A48F A48F ECA8B5 A48F +A490 A490 ECA8B6 A490 +A491 A491 ECA8B7 A491 +A492 A492 ECA8B8 A492 +A493 A493 ECA8B9 A493 +A494 A494 ECA8BA A494 +A495 A495 ECA8BB A495 +A496 A496 ECA8BC A496 +A497 A497 ECA8BD A497 +A498 A498 ECA8BE A498 +A499 A499 ECA8BF A499 +A49A A49A ECA980 A49A +A49B A49B ECA981 A49B +A49C A49C ECA982 A49C +A49D A49D ECA983 A49D +A49E A49E ECA984 A49E +A49F A49F ECA985 A49F +A4A0 A4A0 ECA986 A4A0 +A4A1 A4A1 E384B1 A4A1 +A4A2 A4A2 E384B2 A4A2 +A4A3 A4A3 E384B3 A4A3 +A4A4 A4A4 E384B4 A4A4 +A4A5 A4A5 E384B5 A4A5 +A4A6 A4A6 E384B6 A4A6 +A4A7 A4A7 E384B7 A4A7 +A4A8 A4A8 E384B8 A4A8 +A4A9 A4A9 E384B9 A4A9 +A4AA A4AA E384BA A4AA +A4AB A4AB E384BB A4AB +A4AC A4AC E384BC A4AC +A4AD A4AD E384BD A4AD +A4AE A4AE E384BE A4AE +A4AF A4AF E384BF A4AF +A4B0 A4B0 E38580 A4B0 +A4B1 A4B1 E38581 A4B1 +A4B2 A4B2 E38582 A4B2 +A4B3 A4B3 E38583 A4B3 +A4B4 A4B4 E38584 A4B4 +A4B5 A4B5 E38585 A4B5 +A4B6 A4B6 E38586 A4B6 +A4B7 A4B7 E38587 A4B7 +A4B8 A4B8 E38588 A4B8 +A4B9 A4B9 E38589 A4B9 +A4BA A4BA E3858A A4BA +A4BB A4BB E3858B A4BB +A4BC A4BC E3858C A4BC +A4BD A4BD E3858D A4BD +A4BE A4BE E3858E A4BE +A4BF A4BF E3858F A4BF +A4C0 A4C0 E38590 A4C0 +A4C1 A4C1 E38591 A4C1 +A4C2 A4C2 E38592 A4C2 +A4C3 A4C3 E38593 A4C3 +A4C4 A4C4 E38594 A4C4 +A4C5 A4C5 E38595 A4C5 +A4C6 A4C6 E38596 A4C6 +A4C7 A4C7 E38597 A4C7 +A4C8 A4C8 E38598 A4C8 +A4C9 A4C9 E38599 A4C9 +A4CA A4CA E3859A A4CA +A4CB A4CB E3859B A4CB +A4CC A4CC E3859C A4CC +A4CD A4CD E3859D A4CD +A4CE A4CE E3859E A4CE +A4CF A4CF E3859F A4CF +A4D0 A4D0 E385A0 A4D0 +A4D1 A4D1 E385A1 A4D1 +A4D2 A4D2 E385A2 A4D2 +A4D3 A4D3 E385A3 A4D3 +A4D4 A4D4 E385A4 A4D4 +A4D5 A4D5 E385A5 A4D5 +A4D6 A4D6 E385A6 A4D6 +A4D7 A4D7 E385A7 A4D7 +A4D8 A4D8 E385A8 A4D8 +A4D9 A4D9 E385A9 A4D9 +A4DA A4DA E385AA A4DA +A4DB A4DB E385AB A4DB +A4DC A4DC E385AC A4DC +A4DD A4DD E385AD A4DD +A4DE A4DE E385AE A4DE +A4DF A4DF E385AF A4DF +A4E0 A4E0 E385B0 A4E0 +A4E1 A4E1 E385B1 A4E1 +A4E2 A4E2 E385B2 A4E2 +A4E3 A4E3 E385B3 A4E3 +A4E4 A4E4 E385B4 A4E4 +A4E5 A4E5 E385B5 A4E5 +A4E6 A4E6 E385B6 A4E6 +A4E7 A4E7 E385B7 A4E7 +A4E8 A4E8 E385B8 A4E8 +A4E9 A4E9 E385B9 A4E9 +A4EA A4EA E385BA A4EA +A4EB A4EB E385BB A4EB +A4EC A4EC E385BC A4EC +A4ED A4ED E385BD A4ED +A4EE A4EE E385BE A4EE +A4EF A4EF E385BF A4EF +A4F0 A4F0 E38680 A4F0 +A4F1 A4F1 E38681 A4F1 +A4F2 A4F2 E38682 A4F2 +A4F3 A4F3 E38683 A4F3 +A4F4 A4F4 E38684 A4F4 +A4F5 A4F5 E38685 A4F5 +A4F6 A4F6 E38686 A4F6 +A4F7 A4F7 E38687 A4F7 +A4F8 A4F8 E38688 A4F8 +A4F9 A4F9 E38689 A4F9 +A4FA A4FA E3868A A4FA +A4FB A4FB E3868B A4FB +A4FC A4FC E3868C A4FC +A4FD A4FD E3868D A4FD +A4FE A4FE E3868E A4FE +A541 A541 ECA987 A541 +A542 A542 ECA988 A542 +A543 A543 ECA989 A543 +A544 A544 ECA98A A544 +A545 A545 ECA98B A545 +A546 A546 ECA98E A546 +A547 A547 ECA98F A547 +A548 A548 ECA991 A548 +A549 A549 ECA992 A549 +A54A A54A ECA993 A54A +A54B A54B ECA995 A54B +A54C A54C ECA996 A54C +A54D A54D ECA997 A54D +A54E A54E ECA998 A54E +A54F A54F ECA999 A54F +A550 A550 ECA99A A550 +A551 A551 ECA99B A551 +A552 A552 ECA99E A552 +A553 A553 ECA9A2 A553 +A554 A554 ECA9A3 A554 +A555 A555 ECA9A4 A555 +A556 A556 ECA9A5 A556 +A557 A557 ECA9A6 A557 +A558 A558 ECA9A7 A558 +A559 A559 ECA9A9 A559 +A55A A55A ECA9AA A55A +A561 A561 ECA9AB A561 +A562 A562 ECA9AC A562 +A563 A563 ECA9AD A563 +A564 A564 ECA9AE A564 +A565 A565 ECA9AF A565 +A566 A566 ECA9B0 A566 +A567 A567 ECA9B1 A567 +A568 A568 ECA9B2 A568 +A569 A569 ECA9B3 A569 +A56A A56A ECA9B4 A56A +A56B A56B ECA9B5 A56B +A56C A56C ECA9B6 A56C +A56D A56D ECA9B7 A56D +A56E A56E ECA9B8 A56E +A56F A56F ECA9B9 A56F +A570 A570 ECA9BA A570 +A571 A571 ECA9BB A571 +A572 A572 ECA9BC A572 +A573 A573 ECA9BE A573 +A574 A574 ECA9BF A574 +A575 A575 ECAA80 A575 +A576 A576 ECAA81 A576 +A577 A577 ECAA82 A577 +A578 A578 ECAA83 A578 +A579 A579 ECAA85 A579 +A57A A57A ECAA86 A57A +A581 A581 ECAA87 A581 +A582 A582 ECAA88 A582 +A583 A583 ECAA89 A583 +A584 A584 ECAA8A A584 +A585 A585 ECAA8B A585 +A586 A586 ECAA8C A586 +A587 A587 ECAA8D A587 +A588 A588 ECAA8E A588 +A589 A589 ECAA8F A589 +A58A A58A ECAA90 A58A +A58B A58B ECAA91 A58B +A58C A58C ECAA92 A58C +A58D A58D ECAA93 A58D +A58E A58E ECAA94 A58E +A58F A58F ECAA95 A58F +A590 A590 ECAA96 A590 +A591 A591 ECAA97 A591 +A592 A592 ECAA99 A592 +A593 A593 ECAA9A A593 +A594 A594 ECAA9B A594 +A595 A595 ECAA9C A595 +A596 A596 ECAA9D A596 +A597 A597 ECAA9E A597 +A598 A598 ECAA9F A598 +A599 A599 ECAAA0 A599 +A59A A59A ECAAA1 A59A +A59B A59B ECAAA2 A59B +A59C A59C ECAAA3 A59C +A59D A59D ECAAA4 A59D +A59E A59E ECAAA5 A59E +A59F A59F ECAAA6 A59F +A5A0 A5A0 ECAAA7 A5A0 +A5A1 A5A1 E285B0 A5A1 +A5A2 A5A2 E285B1 A5A2 +A5A3 A5A3 E285B2 A5A3 +A5A4 A5A4 E285B3 A5A4 +A5A5 A5A5 E285B4 A5A5 +A5A6 A5A6 E285B5 A5A6 +A5A7 A5A7 E285B6 A5A7 +A5A8 A5A8 E285B7 A5A8 +A5A9 A5A9 E285B8 A5A9 +A5AA A5AA E285B9 A5AA +A5B0 A5B0 E285A0 A5B0 +A5B1 A5B1 E285A1 A5B1 +A5B2 A5B2 E285A2 A5B2 +A5B3 A5B3 E285A3 A5B3 +A5B4 A5B4 E285A4 A5B4 +A5B5 A5B5 E285A5 A5B5 +A5B6 A5B6 E285A6 A5B6 +A5B7 A5B7 E285A7 A5B7 +A5B8 A5B8 E285A8 A5B8 +A5B9 A5B9 E285A9 A5B9 +A5C1 A5C1 CE91 A5C1 +A5C2 A5C2 CE92 A5C2 +A5C3 A5C3 CE93 A5C3 +A5C4 A5C4 CE94 A5C4 +A5C5 A5C5 CE95 A5C5 +A5C6 A5C6 CE96 A5C6 +A5C7 A5C7 CE97 A5C7 +A5C8 A5C8 CE98 A5C8 +A5C9 A5C9 CE99 A5C9 +A5CA A5CA CE9A A5CA +A5CB A5CB CE9B A5CB +A5CC A5CC CE9C A5CC +A5CD A5CD CE9D A5CD +A5CE A5CE CE9E A5CE +A5CF A5CF CE9F A5CF +A5D0 A5D0 CEA0 A5D0 +A5D1 A5D1 CEA1 A5D1 +A5D2 A5D2 CEA3 A5D2 +A5D3 A5D3 CEA4 A5D3 +A5D4 A5D4 CEA5 A5D4 +A5D5 A5D5 CEA6 A5D5 +A5D6 A5D6 CEA7 A5D6 +A5D7 A5D7 CEA8 A5D7 +A5D8 A5D8 CEA9 A5D8 +A5E1 A5E1 CEB1 A5E1 +A5E2 A5E2 CEB2 A5E2 +A5E3 A5E3 CEB3 A5E3 +A5E4 A5E4 CEB4 A5E4 +A5E5 A5E5 CEB5 A5E5 +A5E6 A5E6 CEB6 A5E6 +A5E7 A5E7 CEB7 A5E7 +A5E8 A5E8 CEB8 A5E8 +A5E9 A5E9 CEB9 A5E9 +A5EA A5EA CEBA A5EA +A5EB A5EB CEBB A5EB +A5EC A5EC CEBC A5EC +A5ED A5ED CEBD A5ED +A5EE A5EE CEBE A5EE +A5EF A5EF CEBF A5EF +A5F0 A5F0 CF80 A5F0 +A5F1 A5F1 CF81 A5F1 +A5F2 A5F2 CF83 A5F2 +A5F3 A5F3 CF84 A5F3 +A5F4 A5F4 CF85 A5F4 +A5F5 A5F5 CF86 A5F5 +A5F6 A5F6 CF87 A5F6 +A5F7 A5F7 CF88 A5F7 +A5F8 A5F8 CF89 A5F8 +A641 A641 ECAAA8 A641 +A642 A642 ECAAA9 A642 +A643 A643 ECAAAA A643 +A644 A644 ECAAAB A644 +A645 A645 ECAAAC A645 +A646 A646 ECAAAD A646 +A647 A647 ECAAAE A647 +A648 A648 ECAAAF A648 +A649 A649 ECAAB0 A649 +A64A A64A ECAAB1 A64A +A64B A64B ECAAB2 A64B +A64C A64C ECAAB3 A64C +A64D A64D ECAAB4 A64D +A64E A64E ECAAB5 A64E +A64F A64F ECAAB6 A64F +A650 A650 ECAAB7 A650 +A651 A651 ECAAB8 A651 +A652 A652 ECAAB9 A652 +A653 A653 ECAABA A653 +A654 A654 ECAABB A654 +A655 A655 ECAABE A655 +A656 A656 ECAABF A656 +A657 A657 ECAB81 A657 +A658 A658 ECAB82 A658 +A659 A659 ECAB83 A659 +A65A A65A ECAB85 A65A +A661 A661 ECAB86 A661 +A662 A662 ECAB87 A662 +A663 A663 ECAB88 A663 +A664 A664 ECAB89 A664 +A665 A665 ECAB8A A665 +A666 A666 ECAB8B A666 +A667 A667 ECAB8E A667 +A668 A668 ECAB90 A668 +A669 A669 ECAB92 A669 +A66A A66A ECAB94 A66A +A66B A66B ECAB95 A66B +A66C A66C ECAB96 A66C +A66D A66D ECAB97 A66D +A66E A66E ECAB9A A66E +A66F A66F ECAB9B A66F +A670 A670 ECAB9C A670 +A671 A671 ECAB9D A671 +A672 A672 ECAB9E A672 +A673 A673 ECAB9F A673 +A674 A674 ECABA1 A674 +A675 A675 ECABA2 A675 +A676 A676 ECABA3 A676 +A677 A677 ECABA4 A677 +A678 A678 ECABA5 A678 +A679 A679 ECABA6 A679 +A67A A67A ECABA7 A67A +A681 A681 ECABA8 A681 +A682 A682 ECABA9 A682 +A683 A683 ECABAA A683 +A684 A684 ECABAB A684 +A685 A685 ECABAD A685 +A686 A686 ECABAE A686 +A687 A687 ECABAF A687 +A688 A688 ECABB0 A688 +A689 A689 ECABB1 A689 +A68A A68A ECABB2 A68A +A68B A68B ECABB3 A68B +A68C A68C ECABB5 A68C +A68D A68D ECABB6 A68D +A68E A68E ECABB7 A68E +A68F A68F ECABB8 A68F +A690 A690 ECABB9 A690 +A691 A691 ECABBA A691 +A692 A692 ECABBB A692 +A693 A693 ECABBC A693 +A694 A694 ECABBD A694 +A695 A695 ECABBE A695 +A696 A696 ECABBF A696 +A697 A697 ECAC80 A697 +A698 A698 ECAC81 A698 +A699 A699 ECAC82 A699 +A69A A69A ECAC83 A69A +A69B A69B ECAC84 A69B +A69C A69C ECAC85 A69C +A69D A69D ECAC86 A69D +A69E A69E ECAC87 A69E +A69F A69F ECAC89 A69F +A6A0 A6A0 ECAC8A A6A0 +A6A1 A6A1 E29480 A6A1 +A6A2 A6A2 E29482 A6A2 +A6A3 A6A3 E2948C A6A3 +A6A4 A6A4 E29490 A6A4 +A6A5 A6A5 E29498 A6A5 +A6A6 A6A6 E29494 A6A6 +A6A7 A6A7 E2949C A6A7 +A6A8 A6A8 E294AC A6A8 +A6A9 A6A9 E294A4 A6A9 +A6AA A6AA E294B4 A6AA +A6AB A6AB E294BC A6AB +A6AC A6AC E29481 A6AC +A6AD A6AD E29483 A6AD +A6AE A6AE E2948F A6AE +A6AF A6AF E29493 A6AF +A6B0 A6B0 E2949B A6B0 +A6B1 A6B1 E29497 A6B1 +A6B2 A6B2 E294A3 A6B2 +A6B3 A6B3 E294B3 A6B3 +A6B4 A6B4 E294AB A6B4 +A6B5 A6B5 E294BB A6B5 +A6B6 A6B6 E2958B A6B6 +A6B7 A6B7 E294A0 A6B7 +A6B8 A6B8 E294AF A6B8 +A6B9 A6B9 E294A8 A6B9 +A6BA A6BA E294B7 A6BA +A6BB A6BB E294BF A6BB +A6BC A6BC E2949D A6BC +A6BD A6BD E294B0 A6BD +A6BE A6BE E294A5 A6BE +A6BF A6BF E294B8 A6BF +A6C0 A6C0 E29582 A6C0 +A6C1 A6C1 E29492 A6C1 +A6C2 A6C2 E29491 A6C2 +A6C3 A6C3 E2949A A6C3 +A6C4 A6C4 E29499 A6C4 +A6C5 A6C5 E29496 A6C5 +A6C6 A6C6 E29495 A6C6 +A6C7 A6C7 E2948E A6C7 +A6C8 A6C8 E2948D A6C8 +A6C9 A6C9 E2949E A6C9 +A6CA A6CA E2949F A6CA +A6CB A6CB E294A1 A6CB +A6CC A6CC E294A2 A6CC +A6CD A6CD E294A6 A6CD +A6CE A6CE E294A7 A6CE +A6CF A6CF E294A9 A6CF +A6D0 A6D0 E294AA A6D0 +A6D1 A6D1 E294AD A6D1 +A6D2 A6D2 E294AE A6D2 +A6D3 A6D3 E294B1 A6D3 +A6D4 A6D4 E294B2 A6D4 +A6D5 A6D5 E294B5 A6D5 +A6D6 A6D6 E294B6 A6D6 +A6D7 A6D7 E294B9 A6D7 +A6D8 A6D8 E294BA A6D8 +A6D9 A6D9 E294BD A6D9 +A6DA A6DA E294BE A6DA +A6DB A6DB E29580 A6DB +A6DC A6DC E29581 A6DC +A6DD A6DD E29583 A6DD +A6DE A6DE E29584 A6DE +A6DF A6DF E29585 A6DF +A6E0 A6E0 E29586 A6E0 +A6E1 A6E1 E29587 A6E1 +A6E2 A6E2 E29588 A6E2 +A6E3 A6E3 E29589 A6E3 +A6E4 A6E4 E2958A A6E4 +A741 A741 ECAC8B A741 +A742 A742 ECAC8C A742 +A743 A743 ECAC8D A743 +A744 A744 ECAC8E A744 +A745 A745 ECAC8F A745 +A746 A746 ECAC91 A746 +A747 A747 ECAC92 A747 +A748 A748 ECAC93 A748 +A749 A749 ECAC95 A749 +A74A A74A ECAC96 A74A +A74B A74B ECAC97 A74B +A74C A74C ECAC99 A74C +A74D A74D ECAC9A A74D +A74E A74E ECAC9B A74E +A74F A74F ECAC9C A74F +A750 A750 ECAC9D A750 +A751 A751 ECAC9E A751 +A752 A752 ECAC9F A752 +A753 A753 ECACA2 A753 +A754 A754 ECACA3 A754 +A755 A755 ECACA4 A755 +A756 A756 ECACA5 A756 +A757 A757 ECACA6 A757 +A758 A758 ECACA7 A758 +A759 A759 ECACA8 A759 +A75A A75A ECACA9 A75A +A761 A761 ECACAA A761 +A762 A762 ECACAB A762 +A763 A763 ECACAC A763 +A764 A764 ECACAD A764 +A765 A765 ECACAE A765 +A766 A766 ECACAF A766 +A767 A767 ECACB0 A767 +A768 A768 ECACB1 A768 +A769 A769 ECACB2 A769 +A76A A76A ECACB3 A76A +A76B A76B ECACB4 A76B +A76C A76C ECACB5 A76C +A76D A76D ECACB6 A76D +A76E A76E ECACB7 A76E +A76F A76F ECACB8 A76F +A770 A770 ECACB9 A770 +A771 A771 ECACBA A771 +A772 A772 ECACBB A772 +A773 A773 ECACBC A773 +A774 A774 ECACBD A774 +A775 A775 ECACBE A775 +A776 A776 ECACBF A776 +A777 A777 ECAD80 A777 +A778 A778 ECAD82 A778 +A779 A779 ECAD83 A779 +A77A A77A ECAD84 A77A +A781 A781 ECAD85 A781 +A782 A782 ECAD86 A782 +A783 A783 ECAD87 A783 +A784 A784 ECAD8A A784 +A785 A785 ECAD8B A785 +A786 A786 ECAD8D A786 +A787 A787 ECAD8E A787 +A788 A788 ECAD8F A788 +A789 A789 ECAD91 A789 +A78A A78A ECAD92 A78A +A78B A78B ECAD93 A78B +A78C A78C ECAD94 A78C +A78D A78D ECAD95 A78D +A78E A78E ECAD96 A78E +A78F A78F ECAD97 A78F +A790 A790 ECAD9A A790 +A791 A791 ECAD9B A791 +A792 A792 ECAD9C A792 +A793 A793 ECAD9E A793 +A794 A794 ECAD9F A794 +A795 A795 ECADA0 A795 +A796 A796 ECADA1 A796 +A797 A797 ECADA2 A797 +A798 A798 ECADA3 A798 +A799 A799 ECADA5 A799 +A79A A79A ECADA6 A79A +A79B A79B ECADA7 A79B +A79C A79C ECADA8 A79C +A79D A79D ECADA9 A79D +A79E A79E ECADAA A79E +A79F A79F ECADAB A79F +A7A0 A7A0 ECADAC A7A0 +A7A1 A7A1 E38E95 A7A1 +A7A2 A7A2 E38E96 A7A2 +A7A3 A7A3 E38E97 A7A3 +A7A4 A7A4 E28493 A7A4 +A7A5 A7A5 E38E98 A7A5 +A7A6 A7A6 E38F84 A7A6 +A7A7 A7A7 E38EA3 A7A7 +A7A8 A7A8 E38EA4 A7A8 +A7A9 A7A9 E38EA5 A7A9 +A7AA A7AA E38EA6 A7AA +A7AB A7AB E38E99 A7AB +A7AC A7AC E38E9A A7AC +A7AD A7AD E38E9B A7AD +A7AE A7AE E38E9C A7AE +A7AF A7AF E38E9D A7AF +A7B0 A7B0 E38E9E A7B0 +A7B1 A7B1 E38E9F A7B1 +A7B2 A7B2 E38EA0 A7B2 +A7B3 A7B3 E38EA1 A7B3 +A7B4 A7B4 E38EA2 A7B4 +A7B5 A7B5 E38F8A A7B5 +A7B6 A7B6 E38E8D A7B6 +A7B7 A7B7 E38E8E A7B7 +A7B8 A7B8 E38E8F A7B8 +A7B9 A7B9 E38F8F A7B9 +A7BA A7BA E38E88 A7BA +A7BB A7BB E38E89 A7BB +A7BC A7BC E38F88 A7BC +A7BD A7BD E38EA7 A7BD +A7BE A7BE E38EA8 A7BE +A7BF A7BF E38EB0 A7BF +A7C0 A7C0 E38EB1 A7C0 +A7C1 A7C1 E38EB2 A7C1 +A7C2 A7C2 E38EB3 A7C2 +A7C3 A7C3 E38EB4 A7C3 +A7C4 A7C4 E38EB5 A7C4 +A7C5 A7C5 E38EB6 A7C5 +A7C6 A7C6 E38EB7 A7C6 +A7C7 A7C7 E38EB8 A7C7 +A7C8 A7C8 E38EB9 A7C8 +A7C9 A7C9 E38E80 A7C9 +A7CA A7CA E38E81 A7CA +A7CB A7CB E38E82 A7CB +A7CC A7CC E38E83 A7CC +A7CD A7CD E38E84 A7CD +A7CE A7CE E38EBA A7CE +A7CF A7CF E38EBB A7CF +A7D0 A7D0 E38EBC A7D0 +A7D1 A7D1 E38EBD A7D1 +A7D2 A7D2 E38EBE A7D2 +A7D3 A7D3 E38EBF A7D3 +A7D4 A7D4 E38E90 A7D4 +A7D5 A7D5 E38E91 A7D5 +A7D6 A7D6 E38E92 A7D6 +A7D7 A7D7 E38E93 A7D7 +A7D8 A7D8 E38E94 A7D8 +A7D9 A7D9 E284A6 A7D9 +A7DA A7DA E38F80 A7DA +A7DB A7DB E38F81 A7DB +A7DC A7DC E38E8A A7DC +A7DD A7DD E38E8B A7DD +A7DE A7DE E38E8C A7DE +A7DF A7DF E38F96 A7DF +A7E0 A7E0 E38F85 A7E0 +A7E1 A7E1 E38EAD A7E1 +A7E2 A7E2 E38EAE A7E2 +A7E3 A7E3 E38EAF A7E3 +A7E4 A7E4 E38F9B A7E4 +A7E5 A7E5 E38EA9 A7E5 +A7E6 A7E6 E38EAA A7E6 +A7E7 A7E7 E38EAB A7E7 +A7E8 A7E8 E38EAC A7E8 +A7E9 A7E9 E38F9D A7E9 +A7EA A7EA E38F90 A7EA +A7EB A7EB E38F93 A7EB +A7EC A7EC E38F83 A7EC +A7ED A7ED E38F89 A7ED +A7EE A7EE E38F9C A7EE +A7EF A7EF E38F86 A7EF +A841 A841 ECADAD A841 +A842 A842 ECADAE A842 +A843 A843 ECADAF A843 +A844 A844 ECADB0 A844 +A845 A845 ECADB1 A845 +A846 A846 ECADB2 A846 +A847 A847 ECADB3 A847 +A848 A848 ECADB4 A848 +A849 A849 ECADB5 A849 +A84A A84A ECADB6 A84A +A84B A84B ECADB7 A84B +A84C A84C ECADBA A84C +A84D A84D ECADBB A84D +A84E A84E ECADBC A84E +A84F A84F ECADBD A84F +A850 A850 ECADBE A850 +A851 A851 ECADBF A851 +A852 A852 ECAE80 A852 +A853 A853 ECAE81 A853 +A854 A854 ECAE82 A854 +A855 A855 ECAE83 A855 +A856 A856 ECAE84 A856 +A857 A857 ECAE85 A857 +A858 A858 ECAE86 A858 +A859 A859 ECAE87 A859 +A85A A85A ECAE88 A85A +A861 A861 ECAE89 A861 +A862 A862 ECAE8A A862 +A863 A863 ECAE8B A863 +A864 A864 ECAE8C A864 +A865 A865 ECAE8D A865 +A866 A866 ECAE8E A866 +A867 A867 ECAE8F A867 +A868 A868 ECAE90 A868 +A869 A869 ECAE91 A869 +A86A A86A ECAE92 A86A +A86B A86B ECAE93 A86B +A86C A86C ECAE94 A86C +A86D A86D ECAE95 A86D +A86E A86E ECAE96 A86E +A86F A86F ECAE97 A86F +A870 A870 ECAE98 A870 +A871 A871 ECAE99 A871 +A872 A872 ECAE9A A872 +A873 A873 ECAE9B A873 +A874 A874 ECAE9D A874 +A875 A875 ECAE9E A875 +A876 A876 ECAE9F A876 +A877 A877 ECAEA0 A877 +A878 A878 ECAEA1 A878 +A879 A879 ECAEA2 A879 +A87A A87A ECAEA3 A87A +A881 A881 ECAEA4 A881 +A882 A882 ECAEA5 A882 +A883 A883 ECAEA6 A883 +A884 A884 ECAEA7 A884 +A885 A885 ECAEA8 A885 +A886 A886 ECAEA9 A886 +A887 A887 ECAEAA A887 +A888 A888 ECAEAB A888 +A889 A889 ECAEAC A889 +A88A A88A ECAEAD A88A +A88B A88B ECAEAE A88B +A88C A88C ECAEAF A88C +A88D A88D ECAEB0 A88D +A88E A88E ECAEB1 A88E +A88F A88F ECAEB2 A88F +A890 A890 ECAEB3 A890 +A891 A891 ECAEB4 A891 +A892 A892 ECAEB5 A892 +A893 A893 ECAEB6 A893 +A894 A894 ECAEB7 A894 +A895 A895 ECAEB9 A895 +A896 A896 ECAEBA A896 +A897 A897 ECAEBB A897 +A898 A898 ECAEBC A898 +A899 A899 ECAEBD A899 +A89A A89A ECAEBE A89A +A89B A89B ECAEBF A89B +A89C A89C ECAF80 A89C +A89D A89D ECAF81 A89D +A89E A89E ECAF82 A89E +A89F A89F ECAF83 A89F +A8A0 A8A0 ECAF84 A8A0 +A8A1 A8A1 C386 A8A1 +A8A2 A8A2 C390 A8A2 +A8A3 A8A3 C2AA A8A3 +A8A4 A8A4 C4A6 A8A4 +A8A6 A8A6 C4B2 A8A6 +A8A8 A8A8 C4BF A8A8 +A8A9 A8A9 C581 A8A9 +A8AA A8AA C398 A8AA +A8AB A8AB C592 A8AB +A8AC A8AC C2BA A8AC +A8AD A8AD C39E A8AD +A8AE A8AE C5A6 A8AE +A8AF A8AF C58A A8AF +A8B1 A8B1 E389A0 A8B1 +A8B2 A8B2 E389A1 A8B2 +A8B3 A8B3 E389A2 A8B3 +A8B4 A8B4 E389A3 A8B4 +A8B5 A8B5 E389A4 A8B5 +A8B6 A8B6 E389A5 A8B6 +A8B7 A8B7 E389A6 A8B7 +A8B8 A8B8 E389A7 A8B8 +A8B9 A8B9 E389A8 A8B9 +A8BA A8BA E389A9 A8BA +A8BB A8BB E389AA A8BB +A8BC A8BC E389AB A8BC +A8BD A8BD E389AC A8BD +A8BE A8BE E389AD A8BE +A8BF A8BF E389AE A8BF +A8C0 A8C0 E389AF A8C0 +A8C1 A8C1 E389B0 A8C1 +A8C2 A8C2 E389B1 A8C2 +A8C3 A8C3 E389B2 A8C3 +A8C4 A8C4 E389B3 A8C4 +A8C5 A8C5 E389B4 A8C5 +A8C6 A8C6 E389B5 A8C6 +A8C7 A8C7 E389B6 A8C7 +A8C8 A8C8 E389B7 A8C8 +A8C9 A8C9 E389B8 A8C9 +A8CA A8CA E389B9 A8CA +A8CB A8CB E389BA A8CB +A8CC A8CC E389BB A8CC +A8CD A8CD E29390 A8CD +A8CE A8CE E29391 A8CE +A8CF A8CF E29392 A8CF +A8D0 A8D0 E29393 A8D0 +A8D1 A8D1 E29394 A8D1 +A8D2 A8D2 E29395 A8D2 +A8D3 A8D3 E29396 A8D3 +A8D4 A8D4 E29397 A8D4 +A8D5 A8D5 E29398 A8D5 +A8D6 A8D6 E29399 A8D6 +A8D7 A8D7 E2939A A8D7 +A8D8 A8D8 E2939B A8D8 +A8D9 A8D9 E2939C A8D9 +A8DA A8DA E2939D A8DA +A8DB A8DB E2939E A8DB +A8DC A8DC E2939F A8DC +A8DD A8DD E293A0 A8DD +A8DE A8DE E293A1 A8DE +A8DF A8DF E293A2 A8DF +A8E0 A8E0 E293A3 A8E0 +A8E1 A8E1 E293A4 A8E1 +A8E2 A8E2 E293A5 A8E2 +A8E3 A8E3 E293A6 A8E3 +A8E4 A8E4 E293A7 A8E4 +A8E5 A8E5 E293A8 A8E5 +A8E6 A8E6 E293A9 A8E6 +A8E7 A8E7 E291A0 A8E7 +A8E8 A8E8 E291A1 A8E8 +A8E9 A8E9 E291A2 A8E9 +A8EA A8EA E291A3 A8EA +A8EB A8EB E291A4 A8EB +A8EC A8EC E291A5 A8EC +A8ED A8ED E291A6 A8ED +A8EE A8EE E291A7 A8EE +A8EF A8EF E291A8 A8EF +A8F0 A8F0 E291A9 A8F0 +A8F1 A8F1 E291AA A8F1 +A8F2 A8F2 E291AB A8F2 +A8F3 A8F3 E291AC A8F3 +A8F4 A8F4 E291AD A8F4 +A8F5 A8F5 E291AE A8F5 +A8F6 A8F6 C2BD A8F6 +A8F7 A8F7 E28593 A8F7 +A8F8 A8F8 E28594 A8F8 +A8F9 A8F9 C2BC A8F9 +A8FA A8FA C2BE A8FA +A8FB A8FB E2859B A8FB +A8FC A8FC E2859C A8FC +A8FD A8FD E2859D A8FD +A8FE A8FE E2859E A8FE +A941 A941 ECAF85 A941 +A942 A942 ECAF86 A942 +A943 A943 ECAF87 A943 +A944 A944 ECAF88 A944 +A945 A945 ECAF89 A945 +A946 A946 ECAF8A A946 +A947 A947 ECAF8B A947 +A948 A948 ECAF8C A948 +A949 A949 ECAF8D A949 +A94A A94A ECAF8E A94A +A94B A94B ECAF8F A94B +A94C A94C ECAF90 A94C +A94D A94D ECAF91 A94D +A94E A94E ECAF92 A94E +A94F A94F ECAF93 A94F +A950 A950 ECAF95 A950 +A951 A951 ECAF96 A951 +A952 A952 ECAF97 A952 +A953 A953 ECAF98 A953 +A954 A954 ECAF99 A954 +A955 A955 ECAF9A A955 +A956 A956 ECAF9B A956 +A957 A957 ECAF9C A957 +A958 A958 ECAF9D A958 +A959 A959 ECAF9E A959 +A95A A95A ECAF9F A95A +A961 A961 ECAFA0 A961 +A962 A962 ECAFA1 A962 +A963 A963 ECAFA2 A963 +A964 A964 ECAFA3 A964 +A965 A965 ECAFA5 A965 +A966 A966 ECAFA6 A966 +A967 A967 ECAFA8 A967 +A968 A968 ECAFAA A968 +A969 A969 ECAFAB A969 +A96A A96A ECAFAC A96A +A96B A96B ECAFAD A96B +A96C A96C ECAFAE A96C +A96D A96D ECAFAF A96D +A96E A96E ECAFB0 A96E +A96F A96F ECAFB1 A96F +A970 A970 ECAFB2 A970 +A971 A971 ECAFB3 A971 +A972 A972 ECAFB4 A972 +A973 A973 ECAFB5 A973 +A974 A974 ECAFB6 A974 +A975 A975 ECAFB7 A975 +A976 A976 ECAFB8 A976 +A977 A977 ECAFB9 A977 +A978 A978 ECAFBA A978 +A979 A979 ECAFBB A979 +A97A A97A ECAFBC A97A +A981 A981 ECAFBD A981 +A982 A982 ECAFBE A982 +A983 A983 ECAFBF A983 +A984 A984 ECB080 A984 +A985 A985 ECB081 A985 +A986 A986 ECB082 A986 +A987 A987 ECB083 A987 +A988 A988 ECB084 A988 +A989 A989 ECB085 A989 +A98A A98A ECB086 A98A +A98B A98B ECB087 A98B +A98C A98C ECB088 A98C +A98D A98D ECB089 A98D +A98E A98E ECB08A A98E +A98F A98F ECB08B A98F +A990 A990 ECB08E A990 +A991 A991 ECB08F A991 +A992 A992 ECB091 A992 +A993 A993 ECB092 A993 +A994 A994 ECB093 A994 +A995 A995 ECB095 A995 +A996 A996 ECB096 A996 +A997 A997 ECB097 A997 +A998 A998 ECB098 A998 +A999 A999 ECB099 A999 +A99A A99A ECB09A A99A +A99B A99B ECB09B A99B +A99C A99C ECB09E A99C +A99D A99D ECB09F A99D +A99E A99E ECB0A0 A99E +A99F A99F ECB0A3 A99F +A9A0 A9A0 ECB0A4 A9A0 +A9A1 A9A1 C3A6 A9A1 +A9A2 A9A2 C491 A9A2 +A9A3 A9A3 C3B0 A9A3 +A9A4 A9A4 C4A7 A9A4 +A9A5 A9A5 C4B1 A9A5 +A9A6 A9A6 C4B3 A9A6 +A9A7 A9A7 C4B8 A9A7 +A9A8 A9A8 C580 A9A8 +A9A9 A9A9 C582 A9A9 +A9AA A9AA C3B8 A9AA +A9AB A9AB C593 A9AB +A9AC A9AC C39F A9AC +A9AD A9AD C3BE A9AD +A9AE A9AE C5A7 A9AE +A9AF A9AF C58B A9AF +A9B0 A9B0 C589 A9B0 +A9B1 A9B1 E38880 A9B1 +A9B2 A9B2 E38881 A9B2 +A9B3 A9B3 E38882 A9B3 +A9B4 A9B4 E38883 A9B4 +A9B5 A9B5 E38884 A9B5 +A9B6 A9B6 E38885 A9B6 +A9B7 A9B7 E38886 A9B7 +A9B8 A9B8 E38887 A9B8 +A9B9 A9B9 E38888 A9B9 +A9BA A9BA E38889 A9BA +A9BB A9BB E3888A A9BB +A9BC A9BC E3888B A9BC +A9BD A9BD E3888C A9BD +A9BE A9BE E3888D A9BE +A9BF A9BF E3888E A9BF +A9C0 A9C0 E3888F A9C0 +A9C1 A9C1 E38890 A9C1 +A9C2 A9C2 E38891 A9C2 +A9C3 A9C3 E38892 A9C3 +A9C4 A9C4 E38893 A9C4 +A9C5 A9C5 E38894 A9C5 +A9C6 A9C6 E38895 A9C6 +A9C7 A9C7 E38896 A9C7 +A9C8 A9C8 E38897 A9C8 +A9C9 A9C9 E38898 A9C9 +A9CA A9CA E38899 A9CA +A9CB A9CB E3889A A9CB +A9CC A9CC E3889B A9CC +A9CD A9CD E2929C A9CD +A9CE A9CE E2929D A9CE +A9CF A9CF E2929E A9CF +A9D0 A9D0 E2929F A9D0 +A9D1 A9D1 E292A0 A9D1 +A9D2 A9D2 E292A1 A9D2 +A9D3 A9D3 E292A2 A9D3 +A9D4 A9D4 E292A3 A9D4 +A9D5 A9D5 E292A4 A9D5 +A9D6 A9D6 E292A5 A9D6 +A9D7 A9D7 E292A6 A9D7 +A9D8 A9D8 E292A7 A9D8 +A9D9 A9D9 E292A8 A9D9 +A9DA A9DA E292A9 A9DA +A9DB A9DB E292AA A9DB +A9DC A9DC E292AB A9DC +A9DD A9DD E292AC A9DD +A9DE A9DE E292AD A9DE +A9DF A9DF E292AE A9DF +A9E0 A9E0 E292AF A9E0 +A9E1 A9E1 E292B0 A9E1 +A9E2 A9E2 E292B1 A9E2 +A9E3 A9E3 E292B2 A9E3 +A9E4 A9E4 E292B3 A9E4 +A9E5 A9E5 E292B4 A9E5 +A9E6 A9E6 E292B5 A9E6 +A9E7 A9E7 E291B4 A9E7 +A9E8 A9E8 E291B5 A9E8 +A9E9 A9E9 E291B6 A9E9 +A9EA A9EA E291B7 A9EA +A9EB A9EB E291B8 A9EB +A9EC A9EC E291B9 A9EC +A9ED A9ED E291BA A9ED +A9EE A9EE E291BB A9EE +A9EF A9EF E291BC A9EF +A9F0 A9F0 E291BD A9F0 +A9F1 A9F1 E291BE A9F1 +A9F2 A9F2 E291BF A9F2 +A9F3 A9F3 E29280 A9F3 +A9F4 A9F4 E29281 A9F4 +A9F5 A9F5 E29282 A9F5 +A9F6 A9F6 C2B9 A9F6 +A9F7 A9F7 C2B2 A9F7 +A9F8 A9F8 C2B3 A9F8 +A9F9 A9F9 E281B4 A9F9 +A9FA A9FA E281BF A9FA +A9FB A9FB E28281 A9FB +A9FC A9FC E28282 A9FC +A9FD A9FD E28283 A9FD +A9FE A9FE E28284 A9FE +AA41 AA41 ECB0A5 AA41 +AA42 AA42 ECB0A6 AA42 +AA43 AA43 ECB0AA AA43 +AA44 AA44 ECB0AB AA44 +AA45 AA45 ECB0AD AA45 +AA46 AA46 ECB0AF AA46 +AA47 AA47 ECB0B1 AA47 +AA48 AA48 ECB0B2 AA48 +AA49 AA49 ECB0B3 AA49 +AA4A AA4A ECB0B4 AA4A +AA4B AA4B ECB0B5 AA4B +AA4C AA4C ECB0B6 AA4C +AA4D AA4D ECB0B7 AA4D +AA4E AA4E ECB0BA AA4E +AA4F AA4F ECB0BF AA4F +AA50 AA50 ECB180 AA50 +AA51 AA51 ECB181 AA51 +AA52 AA52 ECB182 AA52 +AA53 AA53 ECB183 AA53 +AA54 AA54 ECB186 AA54 +AA55 AA55 ECB187 AA55 +AA56 AA56 ECB189 AA56 +AA57 AA57 ECB18A AA57 +AA58 AA58 ECB18B AA58 +AA59 AA59 ECB18D AA59 +AA5A AA5A ECB18E AA5A +AA61 AA61 ECB18F AA61 +AA62 AA62 ECB190 AA62 +AA63 AA63 ECB191 AA63 +AA64 AA64 ECB192 AA64 +AA65 AA65 ECB193 AA65 +AA66 AA66 ECB196 AA66 +AA67 AA67 ECB19A AA67 +AA68 AA68 ECB19B AA68 +AA69 AA69 ECB19C AA69 +AA6A AA6A ECB19D AA6A +AA6B AA6B ECB19E AA6B +AA6C AA6C ECB19F AA6C +AA6D AA6D ECB1A1 AA6D +AA6E AA6E ECB1A2 AA6E +AA6F AA6F ECB1A3 AA6F +AA70 AA70 ECB1A5 AA70 +AA71 AA71 ECB1A7 AA71 +AA72 AA72 ECB1A9 AA72 +AA73 AA73 ECB1AA AA73 +AA74 AA74 ECB1AB AA74 +AA75 AA75 ECB1AC AA75 +AA76 AA76 ECB1AD AA76 +AA77 AA77 ECB1AE AA77 +AA78 AA78 ECB1AF AA78 +AA79 AA79 ECB1B1 AA79 +AA7A AA7A ECB1B2 AA7A +AA81 AA81 ECB1B3 AA81 +AA82 AA82 ECB1B4 AA82 +AA83 AA83 ECB1B6 AA83 +AA84 AA84 ECB1B7 AA84 +AA85 AA85 ECB1B8 AA85 +AA86 AA86 ECB1B9 AA86 +AA87 AA87 ECB1BA AA87 +AA88 AA88 ECB1BB AA88 +AA89 AA89 ECB1BC AA89 +AA8A AA8A ECB1BD AA8A +AA8B AA8B ECB1BE AA8B +AA8C AA8C ECB1BF AA8C +AA8D AA8D ECB280 AA8D +AA8E AA8E ECB281 AA8E +AA8F AA8F ECB282 AA8F +AA90 AA90 ECB283 AA90 +AA91 AA91 ECB284 AA91 +AA92 AA92 ECB285 AA92 +AA93 AA93 ECB286 AA93 +AA94 AA94 ECB287 AA94 +AA95 AA95 ECB288 AA95 +AA96 AA96 ECB289 AA96 +AA97 AA97 ECB28A AA97 +AA98 AA98 ECB28B AA98 +AA99 AA99 ECB28C AA99 +AA9A AA9A ECB28D AA9A +AA9B AA9B ECB28E AA9B +AA9C AA9C ECB28F AA9C +AA9D AA9D ECB290 AA9D +AA9E AA9E ECB291 AA9E +AA9F AA9F ECB292 AA9F +AAA0 AAA0 ECB293 AAA0 +AAA1 AAA1 E38181 AAA1 +AAA2 AAA2 E38182 AAA2 +AAA3 AAA3 E38183 AAA3 +AAA4 AAA4 E38184 AAA4 +AAA5 AAA5 E38185 AAA5 +AAA6 AAA6 E38186 AAA6 +AAA7 AAA7 E38187 AAA7 +AAA8 AAA8 E38188 AAA8 +AAA9 AAA9 E38189 AAA9 +AAAA AAAA E3818A AAAA +AAAB AAAB E3818B AAAB +AAAC AAAC E3818C AAAC +AAAD AAAD E3818D AAAD +AAAE AAAE E3818E AAAE +AAAF AAAF E3818F AAAF +AAB0 AAB0 E38190 AAB0 +AAB1 AAB1 E38191 AAB1 +AAB2 AAB2 E38192 AAB2 +AAB3 AAB3 E38193 AAB3 +AAB4 AAB4 E38194 AAB4 +AAB5 AAB5 E38195 AAB5 +AAB6 AAB6 E38196 AAB6 +AAB7 AAB7 E38197 AAB7 +AAB8 AAB8 E38198 AAB8 +AAB9 AAB9 E38199 AAB9 +AABA AABA E3819A AABA +AABB AABB E3819B AABB +AABC AABC E3819C AABC +AABD AABD E3819D AABD +AABE AABE E3819E AABE +AABF AABF E3819F AABF +AAC0 AAC0 E381A0 AAC0 +AAC1 AAC1 E381A1 AAC1 +AAC2 AAC2 E381A2 AAC2 +AAC3 AAC3 E381A3 AAC3 +AAC4 AAC4 E381A4 AAC4 +AAC5 AAC5 E381A5 AAC5 +AAC6 AAC6 E381A6 AAC6 +AAC7 AAC7 E381A7 AAC7 +AAC8 AAC8 E381A8 AAC8 +AAC9 AAC9 E381A9 AAC9 +AACA AACA E381AA AACA +AACB AACB E381AB AACB +AACC AACC E381AC AACC +AACD AACD E381AD AACD +AACE AACE E381AE AACE +AACF AACF E381AF AACF +AAD0 AAD0 E381B0 AAD0 +AAD1 AAD1 E381B1 AAD1 +AAD2 AAD2 E381B2 AAD2 +AAD3 AAD3 E381B3 AAD3 +AAD4 AAD4 E381B4 AAD4 +AAD5 AAD5 E381B5 AAD5 +AAD6 AAD6 E381B6 AAD6 +AAD7 AAD7 E381B7 AAD7 +AAD8 AAD8 E381B8 AAD8 +AAD9 AAD9 E381B9 AAD9 +AADA AADA E381BA AADA +AADB AADB E381BB AADB +AADC AADC E381BC AADC +AADD AADD E381BD AADD +AADE AADE E381BE AADE +AADF AADF E381BF AADF +AAE0 AAE0 E38280 AAE0 +AAE1 AAE1 E38281 AAE1 +AAE2 AAE2 E38282 AAE2 +AAE3 AAE3 E38283 AAE3 +AAE4 AAE4 E38284 AAE4 +AAE5 AAE5 E38285 AAE5 +AAE6 AAE6 E38286 AAE6 +AAE7 AAE7 E38287 AAE7 +AAE8 AAE8 E38288 AAE8 +AAE9 AAE9 E38289 AAE9 +AAEA AAEA E3828A AAEA +AAEB AAEB E3828B AAEB +AAEC AAEC E3828C AAEC +AAED AAED E3828D AAED +AAEE AAEE E3828E AAEE +AAEF AAEF E3828F AAEF +AAF0 AAF0 E38290 AAF0 +AAF1 AAF1 E38291 AAF1 +AAF2 AAF2 E38292 AAF2 +AAF3 AAF3 E38293 AAF3 +AB41 AB41 ECB294 AB41 +AB42 AB42 ECB295 AB42 +AB43 AB43 ECB296 AB43 +AB44 AB44 ECB297 AB44 +AB45 AB45 ECB29A AB45 +AB46 AB46 ECB29B AB46 +AB47 AB47 ECB29D AB47 +AB48 AB48 ECB29E AB48 +AB49 AB49 ECB29F AB49 +AB4A AB4A ECB2A1 AB4A +AB4B AB4B ECB2A2 AB4B +AB4C AB4C ECB2A3 AB4C +AB4D AB4D ECB2A4 AB4D +AB4E AB4E ECB2A5 AB4E +AB4F AB4F ECB2A6 AB4F +AB50 AB50 ECB2A7 AB50 +AB51 AB51 ECB2AA AB51 +AB52 AB52 ECB2AE AB52 +AB53 AB53 ECB2AF AB53 +AB54 AB54 ECB2B0 AB54 +AB55 AB55 ECB2B1 AB55 +AB56 AB56 ECB2B2 AB56 +AB57 AB57 ECB2B3 AB57 +AB58 AB58 ECB2B6 AB58 +AB59 AB59 ECB2B7 AB59 +AB5A AB5A ECB2B9 AB5A +AB61 AB61 ECB2BA AB61 +AB62 AB62 ECB2BB AB62 +AB63 AB63 ECB2BD AB63 +AB64 AB64 ECB2BE AB64 +AB65 AB65 ECB2BF AB65 +AB66 AB66 ECB380 AB66 +AB67 AB67 ECB381 AB67 +AB68 AB68 ECB382 AB68 +AB69 AB69 ECB383 AB69 +AB6A AB6A ECB386 AB6A +AB6B AB6B ECB388 AB6B +AB6C AB6C ECB38A AB6C +AB6D AB6D ECB38B AB6D +AB6E AB6E ECB38C AB6E +AB6F AB6F ECB38D AB6F +AB70 AB70 ECB38E AB70 +AB71 AB71 ECB38F AB71 +AB72 AB72 ECB391 AB72 +AB73 AB73 ECB392 AB73 +AB74 AB74 ECB393 AB74 +AB75 AB75 ECB395 AB75 +AB76 AB76 ECB396 AB76 +AB77 AB77 ECB397 AB77 +AB78 AB78 ECB398 AB78 +AB79 AB79 ECB399 AB79 +AB7A AB7A ECB39A AB7A +AB81 AB81 ECB39B AB81 +AB82 AB82 ECB39C AB82 +AB83 AB83 ECB39D AB83 +AB84 AB84 ECB39E AB84 +AB85 AB85 ECB39F AB85 +AB86 AB86 ECB3A0 AB86 +AB87 AB87 ECB3A1 AB87 +AB88 AB88 ECB3A2 AB88 +AB89 AB89 ECB3A3 AB89 +AB8A AB8A ECB3A5 AB8A +AB8B AB8B ECB3A6 AB8B +AB8C AB8C ECB3A7 AB8C +AB8D AB8D ECB3A8 AB8D +AB8E AB8E ECB3A9 AB8E +AB8F AB8F ECB3AA AB8F +AB90 AB90 ECB3AB AB90 +AB91 AB91 ECB3AD AB91 +AB92 AB92 ECB3AE AB92 +AB93 AB93 ECB3AF AB93 +AB94 AB94 ECB3B1 AB94 +AB95 AB95 ECB3B2 AB95 +AB96 AB96 ECB3B3 AB96 +AB97 AB97 ECB3B4 AB97 +AB98 AB98 ECB3B5 AB98 +AB99 AB99 ECB3B6 AB99 +AB9A AB9A ECB3B7 AB9A +AB9B AB9B ECB3B8 AB9B +AB9C AB9C ECB3B9 AB9C +AB9D AB9D ECB3BA AB9D +AB9E AB9E ECB3BB AB9E +AB9F AB9F ECB3BC AB9F +ABA0 ABA0 ECB3BD ABA0 +ABA1 ABA1 E382A1 ABA1 +ABA2 ABA2 E382A2 ABA2 +ABA3 ABA3 E382A3 ABA3 +ABA4 ABA4 E382A4 ABA4 +ABA5 ABA5 E382A5 ABA5 +ABA6 ABA6 E382A6 ABA6 +ABA7 ABA7 E382A7 ABA7 +ABA8 ABA8 E382A8 ABA8 +ABA9 ABA9 E382A9 ABA9 +ABAA ABAA E382AA ABAA +ABAB ABAB E382AB ABAB +ABAC ABAC E382AC ABAC +ABAD ABAD E382AD ABAD +ABAE ABAE E382AE ABAE +ABAF ABAF E382AF ABAF +ABB0 ABB0 E382B0 ABB0 +ABB1 ABB1 E382B1 ABB1 +ABB2 ABB2 E382B2 ABB2 +ABB3 ABB3 E382B3 ABB3 +ABB4 ABB4 E382B4 ABB4 +ABB5 ABB5 E382B5 ABB5 +ABB6 ABB6 E382B6 ABB6 +ABB7 ABB7 E382B7 ABB7 +ABB8 ABB8 E382B8 ABB8 +ABB9 ABB9 E382B9 ABB9 +ABBA ABBA E382BA ABBA +ABBB ABBB E382BB ABBB +ABBC ABBC E382BC ABBC +ABBD ABBD E382BD ABBD +ABBE ABBE E382BE ABBE +ABBF ABBF E382BF ABBF +ABC0 ABC0 E38380 ABC0 +ABC1 ABC1 E38381 ABC1 +ABC2 ABC2 E38382 ABC2 +ABC3 ABC3 E38383 ABC3 +ABC4 ABC4 E38384 ABC4 +ABC5 ABC5 E38385 ABC5 +ABC6 ABC6 E38386 ABC6 +ABC7 ABC7 E38387 ABC7 +ABC8 ABC8 E38388 ABC8 +ABC9 ABC9 E38389 ABC9 +ABCA ABCA E3838A ABCA +ABCB ABCB E3838B ABCB +ABCC ABCC E3838C ABCC +ABCD ABCD E3838D ABCD +ABCE ABCE E3838E ABCE +ABCF ABCF E3838F ABCF +ABD0 ABD0 E38390 ABD0 +ABD1 ABD1 E38391 ABD1 +ABD2 ABD2 E38392 ABD2 +ABD3 ABD3 E38393 ABD3 +ABD4 ABD4 E38394 ABD4 +ABD5 ABD5 E38395 ABD5 +ABD6 ABD6 E38396 ABD6 +ABD7 ABD7 E38397 ABD7 +ABD8 ABD8 E38398 ABD8 +ABD9 ABD9 E38399 ABD9 +ABDA ABDA E3839A ABDA +ABDB ABDB E3839B ABDB +ABDC ABDC E3839C ABDC +ABDD ABDD E3839D ABDD +ABDE ABDE E3839E ABDE +ABDF ABDF E3839F ABDF +ABE0 ABE0 E383A0 ABE0 +ABE1 ABE1 E383A1 ABE1 +ABE2 ABE2 E383A2 ABE2 +ABE3 ABE3 E383A3 ABE3 +ABE4 ABE4 E383A4 ABE4 +ABE5 ABE5 E383A5 ABE5 +ABE6 ABE6 E383A6 ABE6 +ABE7 ABE7 E383A7 ABE7 +ABE8 ABE8 E383A8 ABE8 +ABE9 ABE9 E383A9 ABE9 +ABEA ABEA E383AA ABEA +ABEB ABEB E383AB ABEB +ABEC ABEC E383AC ABEC +ABED ABED E383AD ABED +ABEE ABEE E383AE ABEE +ABEF ABEF E383AF ABEF +ABF0 ABF0 E383B0 ABF0 +ABF1 ABF1 E383B1 ABF1 +ABF2 ABF2 E383B2 ABF2 +ABF3 ABF3 E383B3 ABF3 +ABF4 ABF4 E383B4 ABF4 +ABF5 ABF5 E383B5 ABF5 +ABF6 ABF6 E383B6 ABF6 +AC41 AC41 ECB3BE AC41 +AC42 AC42 ECB3BF AC42 +AC43 AC43 ECB480 AC43 +AC44 AC44 ECB482 AC44 +AC45 AC45 ECB483 AC45 +AC46 AC46 ECB484 AC46 +AC47 AC47 ECB485 AC47 +AC48 AC48 ECB486 AC48 +AC49 AC49 ECB487 AC49 +AC4A AC4A ECB48A AC4A +AC4B AC4B ECB48B AC4B +AC4C AC4C ECB48D AC4C +AC4D AC4D ECB48E AC4D +AC4E AC4E ECB48F AC4E +AC4F AC4F ECB491 AC4F +AC50 AC50 ECB492 AC50 +AC51 AC51 ECB493 AC51 +AC52 AC52 ECB494 AC52 +AC53 AC53 ECB495 AC53 +AC54 AC54 ECB496 AC54 +AC55 AC55 ECB497 AC55 +AC56 AC56 ECB49A AC56 +AC57 AC57 ECB49C AC57 +AC58 AC58 ECB49E AC58 +AC59 AC59 ECB49F AC59 +AC5A AC5A ECB4A0 AC5A +AC61 AC61 ECB4A1 AC61 +AC62 AC62 ECB4A2 AC62 +AC63 AC63 ECB4A3 AC63 +AC64 AC64 ECB4A5 AC64 +AC65 AC65 ECB4A6 AC65 +AC66 AC66 ECB4A7 AC66 +AC67 AC67 ECB4A9 AC67 +AC68 AC68 ECB4AA AC68 +AC69 AC69 ECB4AB AC69 +AC6A AC6A ECB4AD AC6A +AC6B AC6B ECB4AE AC6B +AC6C AC6C ECB4AF AC6C +AC6D AC6D ECB4B0 AC6D +AC6E AC6E ECB4B1 AC6E +AC6F AC6F ECB4B2 AC6F +AC70 AC70 ECB4B3 AC70 +AC71 AC71 ECB4B4 AC71 +AC72 AC72 ECB4B5 AC72 +AC73 AC73 ECB4B6 AC73 +AC74 AC74 ECB4B7 AC74 +AC75 AC75 ECB4B8 AC75 +AC76 AC76 ECB4BA AC76 +AC77 AC77 ECB4BB AC77 +AC78 AC78 ECB4BC AC78 +AC79 AC79 ECB4BD AC79 +AC7A AC7A ECB4BE AC7A +AC81 AC81 ECB4BF AC81 +AC82 AC82 ECB580 AC82 +AC83 AC83 ECB581 AC83 +AC84 AC84 ECB582 AC84 +AC85 AC85 ECB583 AC85 +AC86 AC86 ECB584 AC86 +AC87 AC87 ECB585 AC87 +AC88 AC88 ECB586 AC88 +AC89 AC89 ECB587 AC89 +AC8A AC8A ECB588 AC8A +AC8B AC8B ECB589 AC8B +AC8C AC8C ECB58A AC8C +AC8D AC8D ECB58B AC8D +AC8E AC8E ECB58C AC8E +AC8F AC8F ECB58D AC8F +AC90 AC90 ECB58E AC90 +AC91 AC91 ECB58F AC91 +AC92 AC92 ECB590 AC92 +AC93 AC93 ECB591 AC93 +AC94 AC94 ECB592 AC94 +AC95 AC95 ECB593 AC95 +AC96 AC96 ECB594 AC96 +AC97 AC97 ECB595 AC97 +AC98 AC98 ECB596 AC98 +AC99 AC99 ECB597 AC99 +AC9A AC9A ECB598 AC9A +AC9B AC9B ECB599 AC9B +AC9C AC9C ECB59A AC9C +AC9D AC9D ECB59B AC9D +AC9E AC9E ECB59D AC9E +AC9F AC9F ECB59E AC9F +ACA0 ACA0 ECB59F ACA0 +ACA1 ACA1 D090 ACA1 +ACA2 ACA2 D091 ACA2 +ACA3 ACA3 D092 ACA3 +ACA4 ACA4 D093 ACA4 +ACA5 ACA5 D094 ACA5 +ACA6 ACA6 D095 ACA6 +ACA7 ACA7 D081 ACA7 +ACA8 ACA8 D096 ACA8 +ACA9 ACA9 D097 ACA9 +ACAA ACAA D098 ACAA +ACAB ACAB D099 ACAB +ACAC ACAC D09A ACAC +ACAD ACAD D09B ACAD +ACAE ACAE D09C ACAE +ACAF ACAF D09D ACAF +ACB0 ACB0 D09E ACB0 +ACB1 ACB1 D09F ACB1 +ACB2 ACB2 D0A0 ACB2 +ACB3 ACB3 D0A1 ACB3 +ACB4 ACB4 D0A2 ACB4 +ACB5 ACB5 D0A3 ACB5 +ACB6 ACB6 D0A4 ACB6 +ACB7 ACB7 D0A5 ACB7 +ACB8 ACB8 D0A6 ACB8 +ACB9 ACB9 D0A7 ACB9 +ACBA ACBA D0A8 ACBA +ACBB ACBB D0A9 ACBB +ACBC ACBC D0AA ACBC +ACBD ACBD D0AB ACBD +ACBE ACBE D0AC ACBE +ACBF ACBF D0AD ACBF +ACC0 ACC0 D0AE ACC0 +ACC1 ACC1 D0AF ACC1 +ACD1 ACD1 D0B0 ACD1 +ACD2 ACD2 D0B1 ACD2 +ACD3 ACD3 D0B2 ACD3 +ACD4 ACD4 D0B3 ACD4 +ACD5 ACD5 D0B4 ACD5 +ACD6 ACD6 D0B5 ACD6 +ACD7 ACD7 D191 ACD7 +ACD8 ACD8 D0B6 ACD8 +ACD9 ACD9 D0B7 ACD9 +ACDA ACDA D0B8 ACDA +ACDB ACDB D0B9 ACDB +ACDC ACDC D0BA ACDC +ACDD ACDD D0BB ACDD +ACDE ACDE D0BC ACDE +ACDF ACDF D0BD ACDF +ACE0 ACE0 D0BE ACE0 +ACE1 ACE1 D0BF ACE1 +ACE2 ACE2 D180 ACE2 +ACE3 ACE3 D181 ACE3 +ACE4 ACE4 D182 ACE4 +ACE5 ACE5 D183 ACE5 +ACE6 ACE6 D184 ACE6 +ACE7 ACE7 D185 ACE7 +ACE8 ACE8 D186 ACE8 +ACE9 ACE9 D187 ACE9 +ACEA ACEA D188 ACEA +ACEB ACEB D189 ACEB +ACEC ACEC D18A ACEC +ACED ACED D18B ACED +ACEE ACEE D18C ACEE +ACEF ACEF D18D ACEF +ACF0 ACF0 D18E ACF0 +ACF1 ACF1 D18F ACF1 +AD41 AD41 ECB5A1 AD41 +AD42 AD42 ECB5A2 AD42 +AD43 AD43 ECB5A3 AD43 +AD44 AD44 ECB5A5 AD44 +AD45 AD45 ECB5A6 AD45 +AD46 AD46 ECB5A7 AD46 +AD47 AD47 ECB5A8 AD47 +AD48 AD48 ECB5A9 AD48 +AD49 AD49 ECB5AA AD49 +AD4A AD4A ECB5AB AD4A +AD4B AD4B ECB5AE AD4B +AD4C AD4C ECB5B0 AD4C +AD4D AD4D ECB5B2 AD4D +AD4E AD4E ECB5B3 AD4E +AD4F AD4F ECB5B4 AD4F +AD50 AD50 ECB5B5 AD50 +AD51 AD51 ECB5B6 AD51 +AD52 AD52 ECB5B7 AD52 +AD53 AD53 ECB5B9 AD53 +AD54 AD54 ECB5BA AD54 +AD55 AD55 ECB5BB AD55 +AD56 AD56 ECB5BC AD56 +AD57 AD57 ECB5BD AD57 +AD58 AD58 ECB5BE AD58 +AD59 AD59 ECB5BF AD59 +AD5A AD5A ECB680 AD5A +AD61 AD61 ECB681 AD61 +AD62 AD62 ECB682 AD62 +AD63 AD63 ECB683 AD63 +AD64 AD64 ECB684 AD64 +AD65 AD65 ECB685 AD65 +AD66 AD66 ECB686 AD66 +AD67 AD67 ECB687 AD67 +AD68 AD68 ECB689 AD68 +AD69 AD69 ECB68A AD69 +AD6A AD6A ECB68B AD6A +AD6B AD6B ECB68C AD6B +AD6C AD6C ECB68D AD6C +AD6D AD6D ECB68E AD6D +AD6E AD6E ECB68F AD6E +AD6F AD6F ECB690 AD6F +AD70 AD70 ECB691 AD70 +AD71 AD71 ECB692 AD71 +AD72 AD72 ECB693 AD72 +AD73 AD73 ECB696 AD73 +AD74 AD74 ECB697 AD74 +AD75 AD75 ECB699 AD75 +AD76 AD76 ECB69A AD76 +AD77 AD77 ECB69B AD77 +AD78 AD78 ECB69D AD78 +AD79 AD79 ECB69E AD79 +AD7A AD7A ECB69F AD7A +AD81 AD81 ECB6A0 AD81 +AD82 AD82 ECB6A1 AD82 +AD83 AD83 ECB6A2 AD83 +AD84 AD84 ECB6A3 AD84 +AD85 AD85 ECB6A6 AD85 +AD86 AD86 ECB6A8 AD86 +AD87 AD87 ECB6AA AD87 +AD88 AD88 ECB6AB AD88 +AD89 AD89 ECB6AC AD89 +AD8A AD8A ECB6AD AD8A +AD8B AD8B ECB6AE AD8B +AD8C AD8C ECB6AF AD8C +AD8D AD8D ECB6B1 AD8D +AD8E AD8E ECB6B2 AD8E +AD8F AD8F ECB6B3 AD8F +AD90 AD90 ECB6B4 AD90 +AD91 AD91 ECB6B5 AD91 +AD92 AD92 ECB6B6 AD92 +AD93 AD93 ECB6B7 AD93 +AD94 AD94 ECB6B8 AD94 +AD95 AD95 ECB6B9 AD95 +AD96 AD96 ECB6BA AD96 +AD97 AD97 ECB6BB AD97 +AD98 AD98 ECB6BC AD98 +AD99 AD99 ECB6BD AD99 +AD9A AD9A ECB6BE AD9A +AD9B AD9B ECB6BF AD9B +AD9C AD9C ECB780 AD9C +AD9D AD9D ECB781 AD9D +AD9E AD9E ECB782 AD9E +AD9F AD9F ECB783 AD9F +ADA0 ADA0 ECB785 ADA0 +AE41 AE41 ECB786 AE41 +AE42 AE42 ECB787 AE42 +AE43 AE43 ECB788 AE43 +AE44 AE44 ECB789 AE44 +AE45 AE45 ECB78A AE45 +AE46 AE46 ECB78B AE46 +AE47 AE47 ECB78D AE47 +AE48 AE48 ECB78E AE48 +AE49 AE49 ECB78F AE49 +AE4A AE4A ECB791 AE4A +AE4B AE4B ECB792 AE4B +AE4C AE4C ECB793 AE4C +AE4D AE4D ECB794 AE4D +AE4E AE4E ECB795 AE4E +AE4F AE4F ECB796 AE4F +AE50 AE50 ECB797 AE50 +AE51 AE51 ECB798 AE51 +AE52 AE52 ECB799 AE52 +AE53 AE53 ECB79A AE53 +AE54 AE54 ECB79B AE54 +AE55 AE55 ECB79C AE55 +AE56 AE56 ECB79D AE56 +AE57 AE57 ECB79E AE57 +AE58 AE58 ECB79F AE58 +AE59 AE59 ECB7A0 AE59 +AE5A AE5A ECB7A1 AE5A +AE61 AE61 ECB7A2 AE61 +AE62 AE62 ECB7A3 AE62 +AE63 AE63 ECB7A4 AE63 +AE64 AE64 ECB7A5 AE64 +AE65 AE65 ECB7A6 AE65 +AE66 AE66 ECB7A7 AE66 +AE67 AE67 ECB7A9 AE67 +AE68 AE68 ECB7AA AE68 +AE69 AE69 ECB7AB AE69 +AE6A AE6A ECB7AD AE6A +AE6B AE6B ECB7AE AE6B +AE6C AE6C ECB7AF AE6C +AE6D AE6D ECB7B1 AE6D +AE6E AE6E ECB7B2 AE6E +AE6F AE6F ECB7B3 AE6F +AE70 AE70 ECB7B4 AE70 +AE71 AE71 ECB7B5 AE71 +AE72 AE72 ECB7B6 AE72 +AE73 AE73 ECB7B7 AE73 +AE74 AE74 ECB7BA AE74 +AE75 AE75 ECB7BC AE75 +AE76 AE76 ECB7BE AE76 +AE77 AE77 ECB7BF AE77 +AE78 AE78 ECB880 AE78 +AE79 AE79 ECB881 AE79 +AE7A AE7A ECB882 AE7A +AE81 AE81 ECB883 AE81 +AE82 AE82 ECB885 AE82 +AE83 AE83 ECB886 AE83 +AE84 AE84 ECB887 AE84 +AE85 AE85 ECB889 AE85 +AE86 AE86 ECB88A AE86 +AE87 AE87 ECB88B AE87 +AE88 AE88 ECB88D AE88 +AE89 AE89 ECB88E AE89 +AE8A AE8A ECB88F AE8A +AE8B AE8B ECB890 AE8B +AE8C AE8C ECB891 AE8C +AE8D AE8D ECB892 AE8D +AE8E AE8E ECB893 AE8E +AE8F AE8F ECB895 AE8F +AE90 AE90 ECB896 AE90 +AE91 AE91 ECB897 AE91 +AE92 AE92 ECB898 AE92 +AE93 AE93 ECB89A AE93 +AE94 AE94 ECB89B AE94 +AE95 AE95 ECB89C AE95 +AE96 AE96 ECB89D AE96 +AE97 AE97 ECB89E AE97 +AE98 AE98 ECB89F AE98 +AE99 AE99 ECB8A2 AE99 +AE9A AE9A ECB8A3 AE9A +AE9B AE9B ECB8A5 AE9B +AE9C AE9C ECB8A6 AE9C +AE9D AE9D ECB8A7 AE9D +AE9E AE9E ECB8A9 AE9E +AE9F AE9F ECB8AA AE9F +AEA0 AEA0 ECB8AB AEA0 +AF41 AF41 ECB8AC AF41 +AF42 AF42 ECB8AD AF42 +AF43 AF43 ECB8AE AF43 +AF44 AF44 ECB8AF AF44 +AF45 AF45 ECB8B2 AF45 +AF46 AF46 ECB8B4 AF46 +AF47 AF47 ECB8B6 AF47 +AF48 AF48 ECB8B7 AF48 +AF49 AF49 ECB8B8 AF49 +AF4A AF4A ECB8B9 AF4A +AF4B AF4B ECB8BA AF4B +AF4C AF4C ECB8BB AF4C +AF4D AF4D ECB8BC AF4D +AF4E AF4E ECB8BD AF4E +AF4F AF4F ECB8BE AF4F +AF50 AF50 ECB8BF AF50 +AF51 AF51 ECB980 AF51 +AF52 AF52 ECB981 AF52 +AF53 AF53 ECB982 AF53 +AF54 AF54 ECB983 AF54 +AF55 AF55 ECB984 AF55 +AF56 AF56 ECB985 AF56 +AF57 AF57 ECB986 AF57 +AF58 AF58 ECB987 AF58 +AF59 AF59 ECB988 AF59 +AF5A AF5A ECB989 AF5A +AF61 AF61 ECB98A AF61 +AF62 AF62 ECB98B AF62 +AF63 AF63 ECB98C AF63 +AF64 AF64 ECB98D AF64 +AF65 AF65 ECB98E AF65 +AF66 AF66 ECB98F AF66 +AF67 AF67 ECB990 AF67 +AF68 AF68 ECB991 AF68 +AF69 AF69 ECB992 AF69 +AF6A AF6A ECB993 AF6A +AF6B AF6B ECB994 AF6B +AF6C AF6C ECB995 AF6C +AF6D AF6D ECB996 AF6D +AF6E AF6E ECB997 AF6E +AF6F AF6F ECB99A AF6F +AF70 AF70 ECB99B AF70 +AF71 AF71 ECB99D AF71 +AF72 AF72 ECB99E AF72 +AF73 AF73 ECB9A2 AF73 +AF74 AF74 ECB9A3 AF74 +AF75 AF75 ECB9A4 AF75 +AF76 AF76 ECB9A5 AF76 +AF77 AF77 ECB9A6 AF77 +AF78 AF78 ECB9A7 AF78 +AF79 AF79 ECB9AA AF79 +AF7A AF7A ECB9AC AF7A +AF81 AF81 ECB9AE AF81 +AF82 AF82 ECB9AF AF82 +AF83 AF83 ECB9B0 AF83 +AF84 AF84 ECB9B1 AF84 +AF85 AF85 ECB9B2 AF85 +AF86 AF86 ECB9B3 AF86 +AF87 AF87 ECB9B6 AF87 +AF88 AF88 ECB9B7 AF88 +AF89 AF89 ECB9B9 AF89 +AF8A AF8A ECB9BA AF8A +AF8B AF8B ECB9BB AF8B +AF8C AF8C ECB9BD AF8C +AF8D AF8D ECB9BE AF8D +AF8E AF8E ECB9BF AF8E +AF8F AF8F ECBA80 AF8F +AF90 AF90 ECBA81 AF90 +AF91 AF91 ECBA82 AF91 +AF92 AF92 ECBA83 AF92 +AF93 AF93 ECBA86 AF93 +AF94 AF94 ECBA88 AF94 +AF95 AF95 ECBA8A AF95 +AF96 AF96 ECBA8B AF96 +AF97 AF97 ECBA8C AF97 +AF98 AF98 ECBA8D AF98 +AF99 AF99 ECBA8E AF99 +AF9A AF9A ECBA8F AF9A +AF9B AF9B ECBA92 AF9B +AF9C AF9C ECBA93 AF9C +AF9D AF9D ECBA95 AF9D +AF9E AF9E ECBA96 AF9E +AF9F AF9F ECBA97 AF9F +AFA0 AFA0 ECBA99 AFA0 +B041 B041 ECBA9A B041 +B042 B042 ECBA9B B042 +B043 B043 ECBA9C B043 +B044 B044 ECBA9D B044 +B045 B045 ECBA9E B045 +B046 B046 ECBA9F B046 +B047 B047 ECBAA2 B047 +B048 B048 ECBAA6 B048 +B049 B049 ECBAA7 B049 +B04A B04A ECBAA8 B04A +B04B B04B ECBAA9 B04B +B04C B04C ECBAAA B04C +B04D B04D ECBAAB B04D +B04E B04E ECBAAE B04E +B04F B04F ECBAAF B04F +B050 B050 ECBAB0 B050 +B051 B051 ECBAB1 B051 +B052 B052 ECBAB2 B052 +B053 B053 ECBAB3 B053 +B054 B054 ECBAB4 B054 +B055 B055 ECBAB5 B055 +B056 B056 ECBAB6 B056 +B057 B057 ECBAB7 B057 +B058 B058 ECBAB8 B058 +B059 B059 ECBAB9 B059 +B05A B05A ECBABA B05A +B061 B061 ECBABB B061 +B062 B062 ECBABC B062 +B063 B063 ECBABD B063 +B064 B064 ECBABE B064 +B065 B065 ECBABF B065 +B066 B066 ECBB80 B066 +B067 B067 ECBB82 B067 +B068 B068 ECBB83 B068 +B069 B069 ECBB84 B069 +B06A B06A ECBB85 B06A +B06B B06B ECBB86 B06B +B06C B06C ECBB87 B06C +B06D B06D ECBB88 B06D +B06E B06E ECBB89 B06E +B06F B06F ECBB8A B06F +B070 B070 ECBB8B B070 +B071 B071 ECBB8C B071 +B072 B072 ECBB8D B072 +B073 B073 ECBB8E B073 +B074 B074 ECBB8F B074 +B075 B075 ECBB90 B075 +B076 B076 ECBB91 B076 +B077 B077 ECBB92 B077 +B078 B078 ECBB93 B078 +B079 B079 ECBB94 B079 +B07A B07A ECBB95 B07A +B081 B081 ECBB96 B081 +B082 B082 ECBB97 B082 +B083 B083 ECBB98 B083 +B084 B084 ECBB99 B084 +B085 B085 ECBB9A B085 +B086 B086 ECBB9B B086 +B087 B087 ECBB9C B087 +B088 B088 ECBB9D B088 +B089 B089 ECBB9E B089 +B08A B08A ECBB9F B08A +B08B B08B ECBBA0 B08B +B08C B08C ECBBA1 B08C +B08D B08D ECBBA2 B08D +B08E B08E ECBBA3 B08E +B08F B08F ECBBA6 B08F +B090 B090 ECBBA7 B090 +B091 B091 ECBBA9 B091 +B092 B092 ECBBAA B092 +B093 B093 ECBBAD B093 +B094 B094 ECBBAE B094 +B095 B095 ECBBAF B095 +B096 B096 ECBBB0 B096 +B097 B097 ECBBB1 B097 +B098 B098 ECBBB2 B098 +B099 B099 ECBBB3 B099 +B09A B09A ECBBB6 B09A +B09B B09B ECBBBA B09B +B09C B09C ECBBBB B09C +B09D B09D ECBBBC B09D +B09E B09E ECBBBD B09E +B09F B09F ECBBBE B09F +B0A0 B0A0 ECBBBF B0A0 +B0A1 B0A1 EAB080 B0A1 +B0A2 B0A2 EAB081 B0A2 +B0A3 B0A3 EAB084 B0A3 +B0A4 B0A4 EAB087 B0A4 +B0A5 B0A5 EAB088 B0A5 +B0A6 B0A6 EAB089 B0A6 +B0A7 B0A7 EAB08A B0A7 +B0A8 B0A8 EAB090 B0A8 +B0A9 B0A9 EAB091 B0A9 +B0AA B0AA EAB092 B0AA +B0AB B0AB EAB093 B0AB +B0AC B0AC EAB094 B0AC +B0AD B0AD EAB095 B0AD +B0AE B0AE EAB096 B0AE +B0AF B0AF EAB097 B0AF +B0B0 B0B0 EAB099 B0B0 +B0B1 B0B1 EAB09A B0B1 +B0B2 B0B2 EAB09B B0B2 +B0B3 B0B3 EAB09C B0B3 +B0B4 B0B4 EAB09D B0B4 +B0B5 B0B5 EAB0A0 B0B5 +B0B6 B0B6 EAB0A4 B0B6 +B0B7 B0B7 EAB0AC B0B7 +B0B8 B0B8 EAB0AD B0B8 +B0B9 B0B9 EAB0AF B0B9 +B0BA B0BA EAB0B0 B0BA +B0BB B0BB EAB0B1 B0BB +B0BC B0BC EAB0B8 B0BC +B0BD B0BD EAB0B9 B0BD +B0BE B0BE EAB0BC B0BE +B0BF B0BF EAB180 B0BF +B0C0 B0C0 EAB18B B0C0 +B0C1 B0C1 EAB18D B0C1 +B0C2 B0C2 EAB194 B0C2 +B0C3 B0C3 EAB198 B0C3 +B0C4 B0C4 EAB19C B0C4 +B0C5 B0C5 EAB1B0 B0C5 +B0C6 B0C6 EAB1B1 B0C6 +B0C7 B0C7 EAB1B4 B0C7 +B0C8 B0C8 EAB1B7 B0C8 +B0C9 B0C9 EAB1B8 B0C9 +B0CA B0CA EAB1BA B0CA +B0CB B0CB EAB280 B0CB +B0CC B0CC EAB281 B0CC +B0CD B0CD EAB283 B0CD +B0CE B0CE EAB284 B0CE +B0CF B0CF EAB285 B0CF +B0D0 B0D0 EAB286 B0D0 +B0D1 B0D1 EAB289 B0D1 +B0D2 B0D2 EAB28A B0D2 +B0D3 B0D3 EAB28B B0D3 +B0D4 B0D4 EAB28C B0D4 +B0D5 B0D5 EAB290 B0D5 +B0D6 B0D6 EAB294 B0D6 +B0D7 B0D7 EAB29C B0D7 +B0D8 B0D8 EAB29D B0D8 +B0D9 B0D9 EAB29F B0D9 +B0DA B0DA EAB2A0 B0DA +B0DB B0DB EAB2A1 B0DB +B0DC B0DC EAB2A8 B0DC +B0DD B0DD EAB2A9 B0DD +B0DE B0DE EAB2AA B0DE +B0DF B0DF EAB2AC B0DF +B0E0 B0E0 EAB2AF B0E0 +B0E1 B0E1 EAB2B0 B0E1 +B0E2 B0E2 EAB2B8 B0E2 +B0E3 B0E3 EAB2B9 B0E3 +B0E4 B0E4 EAB2BB B0E4 +B0E5 B0E5 EAB2BC B0E5 +B0E6 B0E6 EAB2BD B0E6 +B0E7 B0E7 EAB381 B0E7 +B0E8 B0E8 EAB384 B0E8 +B0E9 B0E9 EAB388 B0E9 +B0EA B0EA EAB38C B0EA +B0EB B0EB EAB395 B0EB +B0EC B0EC EAB397 B0EC +B0ED B0ED EAB3A0 B0ED +B0EE B0EE EAB3A1 B0EE +B0EF B0EF EAB3A4 B0EF +B0F0 B0F0 EAB3A7 B0F0 +B0F1 B0F1 EAB3A8 B0F1 +B0F2 B0F2 EAB3AA B0F2 +B0F3 B0F3 EAB3AC B0F3 +B0F4 B0F4 EAB3AF B0F4 +B0F5 B0F5 EAB3B0 B0F5 +B0F6 B0F6 EAB3B1 B0F6 +B0F7 B0F7 EAB3B3 B0F7 +B0F8 B0F8 EAB3B5 B0F8 +B0F9 B0F9 EAB3B6 B0F9 +B0FA B0FA EAB3BC B0FA +B0FB B0FB EAB3BD B0FB +B0FC B0FC EAB480 B0FC +B0FD B0FD EAB484 B0FD +B0FE B0FE EAB486 B0FE +B141 B141 ECBC82 B141 +B142 B142 ECBC83 B142 +B143 B143 ECBC85 B143 +B144 B144 ECBC86 B144 +B145 B145 ECBC87 B145 +B146 B146 ECBC89 B146 +B147 B147 ECBC8A B147 +B148 B148 ECBC8B B148 +B149 B149 ECBC8C B149 +B14A B14A ECBC8D B14A +B14B B14B ECBC8E B14B +B14C B14C ECBC8F B14C +B14D B14D ECBC92 B14D +B14E B14E ECBC94 B14E +B14F B14F ECBC96 B14F +B150 B150 ECBC97 B150 +B151 B151 ECBC98 B151 +B152 B152 ECBC99 B152 +B153 B153 ECBC9A B153 +B154 B154 ECBC9B B154 +B155 B155 ECBC9D B155 +B156 B156 ECBC9E B156 +B157 B157 ECBC9F B157 +B158 B158 ECBCA1 B158 +B159 B159 ECBCA2 B159 +B15A B15A ECBCA3 B15A +B161 B161 ECBCA5 B161 +B162 B162 ECBCA6 B162 +B163 B163 ECBCA7 B163 +B164 B164 ECBCA8 B164 +B165 B165 ECBCA9 B165 +B166 B166 ECBCAA B166 +B167 B167 ECBCAB B167 +B168 B168 ECBCAE B168 +B169 B169 ECBCB2 B169 +B16A B16A ECBCB3 B16A +B16B B16B ECBCB4 B16B +B16C B16C ECBCB5 B16C +B16D B16D ECBCB6 B16D +B16E B16E ECBCB7 B16E +B16F B16F ECBCB9 B16F +B170 B170 ECBCBA B170 +B171 B171 ECBCBB B171 +B172 B172 ECBCBC B172 +B173 B173 ECBCBD B173 +B174 B174 ECBCBE B174 +B175 B175 ECBCBF B175 +B176 B176 ECBD80 B176 +B177 B177 ECBD81 B177 +B178 B178 ECBD82 B178 +B179 B179 ECBD83 B179 +B17A B17A ECBD84 B17A +B181 B181 ECBD85 B181 +B182 B182 ECBD86 B182 +B183 B183 ECBD87 B183 +B184 B184 ECBD88 B184 +B185 B185 ECBD89 B185 +B186 B186 ECBD8A B186 +B187 B187 ECBD8B B187 +B188 B188 ECBD8C B188 +B189 B189 ECBD8D B189 +B18A B18A ECBD8E B18A +B18B B18B ECBD8F B18B +B18C B18C ECBD90 B18C +B18D B18D ECBD91 B18D +B18E B18E ECBD92 B18E +B18F B18F ECBD93 B18F +B190 B190 ECBD96 B190 +B191 B191 ECBD97 B191 +B192 B192 ECBD99 B192 +B193 B193 ECBD9A B193 +B194 B194 ECBD9B B194 +B195 B195 ECBD9D B195 +B196 B196 ECBD9E B196 +B197 B197 ECBD9F B197 +B198 B198 ECBDA0 B198 +B199 B199 ECBDA1 B199 +B19A B19A ECBDA2 B19A +B19B B19B ECBDA3 B19B +B19C B19C ECBDA6 B19C +B19D B19D ECBDA8 B19D +B19E B19E ECBDAA B19E +B19F B19F ECBDAB B19F +B1A0 B1A0 ECBDAC B1A0 +B1A1 B1A1 EAB48C B1A1 +B1A2 B1A2 EAB48D B1A2 +B1A3 B1A3 EAB48F B1A3 +B1A4 B1A4 EAB491 B1A4 +B1A5 B1A5 EAB498 B1A5 +B1A6 B1A6 EAB49C B1A6 +B1A7 B1A7 EAB4A0 B1A7 +B1A8 B1A8 EAB4A9 B1A8 +B1A9 B1A9 EAB4AC B1A9 +B1AA B1AA EAB4AD B1AA +B1AB B1AB EAB4B4 B1AB +B1AC B1AC EAB4B5 B1AC +B1AD B1AD EAB4B8 B1AD +B1AE B1AE EAB4BC B1AE +B1AF B1AF EAB584 B1AF +B1B0 B1B0 EAB585 B1B0 +B1B1 B1B1 EAB587 B1B1 +B1B2 B1B2 EAB589 B1B2 +B1B3 B1B3 EAB590 B1B3 +B1B4 B1B4 EAB594 B1B4 +B1B5 B1B5 EAB598 B1B5 +B1B6 B1B6 EAB5A1 B1B6 +B1B7 B1B7 EAB5A3 B1B7 +B1B8 B1B8 EAB5AC B1B8 +B1B9 B1B9 EAB5AD B1B9 +B1BA B1BA EAB5B0 B1BA +B1BB B1BB EAB5B3 B1BB +B1BC B1BC EAB5B4 B1BC +B1BD B1BD EAB5B5 B1BD +B1BE B1BE EAB5B6 B1BE +B1BF B1BF EAB5BB B1BF +B1C0 B1C0 EAB5BC B1C0 +B1C1 B1C1 EAB5BD B1C1 +B1C2 B1C2 EAB5BF B1C2 +B1C3 B1C3 EAB681 B1C3 +B1C4 B1C4 EAB682 B1C4 +B1C5 B1C5 EAB688 B1C5 +B1C6 B1C6 EAB689 B1C6 +B1C7 B1C7 EAB68C B1C7 +B1C8 B1C8 EAB690 B1C8 +B1C9 B1C9 EAB69C B1C9 +B1CA B1CA EAB69D B1CA +B1CB B1CB EAB6A4 B1CB +B1CC B1CC EAB6B7 B1CC +B1CD B1CD EAB780 B1CD +B1CE B1CE EAB781 B1CE +B1CF B1CF EAB784 B1CF +B1D0 B1D0 EAB788 B1D0 +B1D1 B1D1 EAB790 B1D1 +B1D2 B1D2 EAB791 B1D2 +B1D3 B1D3 EAB793 B1D3 +B1D4 B1D4 EAB79C B1D4 +B1D5 B1D5 EAB7A0 B1D5 +B1D6 B1D6 EAB7A4 B1D6 +B1D7 B1D7 EAB7B8 B1D7 +B1D8 B1D8 EAB7B9 B1D8 +B1D9 B1D9 EAB7BC B1D9 +B1DA B1DA EAB7BF B1DA +B1DB B1DB EAB880 B1DB +B1DC B1DC EAB881 B1DC +B1DD B1DD EAB888 B1DD +B1DE B1DE EAB889 B1DE +B1DF B1DF EAB88B B1DF +B1E0 B1E0 EAB88D B1E0 +B1E1 B1E1 EAB894 B1E1 +B1E2 B1E2 EAB8B0 B1E2 +B1E3 B1E3 EAB8B1 B1E3 +B1E4 B1E4 EAB8B4 B1E4 +B1E5 B1E5 EAB8B7 B1E5 +B1E6 B1E6 EAB8B8 B1E6 +B1E7 B1E7 EAB8BA B1E7 +B1E8 B1E8 EAB980 B1E8 +B1E9 B1E9 EAB981 B1E9 +B1EA B1EA EAB983 B1EA +B1EB B1EB EAB985 B1EB +B1EC B1EC EAB986 B1EC +B1ED B1ED EAB98A B1ED +B1EE B1EE EAB98C B1EE +B1EF B1EF EAB98D B1EF +B1F0 B1F0 EAB98E B1F0 +B1F1 B1F1 EAB990 B1F1 +B1F2 B1F2 EAB994 B1F2 +B1F3 B1F3 EAB996 B1F3 +B1F4 B1F4 EAB99C B1F4 +B1F5 B1F5 EAB99D B1F5 +B1F6 B1F6 EAB99F B1F6 +B1F7 B1F7 EAB9A0 B1F7 +B1F8 B1F8 EAB9A1 B1F8 +B1F9 B1F9 EAB9A5 B1F9 +B1FA B1FA EAB9A8 B1FA +B1FB B1FB EAB9A9 B1FB +B1FC B1FC EAB9AC B1FC +B1FD B1FD EAB9B0 B1FD +B1FE B1FE EAB9B8 B1FE +B241 B241 ECBDAD B241 +B242 B242 ECBDAE B242 +B243 B243 ECBDAF B243 +B244 B244 ECBDB2 B244 +B245 B245 ECBDB3 B245 +B246 B246 ECBDB5 B246 +B247 B247 ECBDB6 B247 +B248 B248 ECBDB7 B248 +B249 B249 ECBDB9 B249 +B24A B24A ECBDBA B24A +B24B B24B ECBDBB B24B +B24C B24C ECBDBC B24C +B24D B24D ECBDBD B24D +B24E B24E ECBDBE B24E +B24F B24F ECBDBF B24F +B250 B250 ECBE81 B250 +B251 B251 ECBE82 B251 +B252 B252 ECBE83 B252 +B253 B253 ECBE84 B253 +B254 B254 ECBE86 B254 +B255 B255 ECBE87 B255 +B256 B256 ECBE88 B256 +B257 B257 ECBE89 B257 +B258 B258 ECBE8A B258 +B259 B259 ECBE8B B259 +B25A B25A ECBE8D B25A +B261 B261 ECBE8E B261 +B262 B262 ECBE8F B262 +B263 B263 ECBE90 B263 +B264 B264 ECBE91 B264 +B265 B265 ECBE92 B265 +B266 B266 ECBE93 B266 +B267 B267 ECBE94 B267 +B268 B268 ECBE95 B268 +B269 B269 ECBE96 B269 +B26A B26A ECBE97 B26A +B26B B26B ECBE98 B26B +B26C B26C ECBE99 B26C +B26D B26D ECBE9A B26D +B26E B26E ECBE9B B26E +B26F B26F ECBE9C B26F +B270 B270 ECBE9D B270 +B271 B271 ECBE9E B271 +B272 B272 ECBE9F B272 +B273 B273 ECBEA0 B273 +B274 B274 ECBEA2 B274 +B275 B275 ECBEA3 B275 +B276 B276 ECBEA4 B276 +B277 B277 ECBEA5 B277 +B278 B278 ECBEA6 B278 +B279 B279 ECBEA7 B279 +B27A B27A ECBEA9 B27A +B281 B281 ECBEAA B281 +B282 B282 ECBEAB B282 +B283 B283 ECBEAC B283 +B284 B284 ECBEAD B284 +B285 B285 ECBEAE B285 +B286 B286 ECBEAF B286 +B287 B287 ECBEB1 B287 +B288 B288 ECBEB2 B288 +B289 B289 ECBEB3 B289 +B28A B28A ECBEB4 B28A +B28B B28B ECBEB5 B28B +B28C B28C ECBEB6 B28C +B28D B28D ECBEB7 B28D +B28E B28E ECBEB8 B28E +B28F B28F ECBEB9 B28F +B290 B290 ECBEBA B290 +B291 B291 ECBEBB B291 +B292 B292 ECBEBC B292 +B293 B293 ECBEBD B293 +B294 B294 ECBEBE B294 +B295 B295 ECBEBF B295 +B296 B296 ECBF80 B296 +B297 B297 ECBF81 B297 +B298 B298 ECBF82 B298 +B299 B299 ECBF83 B299 +B29A B29A ECBF85 B29A +B29B B29B ECBF86 B29B +B29C B29C ECBF87 B29C +B29D B29D ECBF88 B29D +B29E B29E ECBF89 B29E +B29F B29F ECBF8A B29F +B2A0 B2A0 ECBF8B B2A0 +B2A1 B2A1 EAB9B9 B2A1 +B2A2 B2A2 EAB9BB B2A2 +B2A3 B2A3 EAB9BC B2A3 +B2A4 B2A4 EAB9BD B2A4 +B2A5 B2A5 EABA84 B2A5 +B2A6 B2A6 EABA85 B2A6 +B2A7 B2A7 EABA8C B2A7 +B2A8 B2A8 EABABC B2A8 +B2A9 B2A9 EABABD B2A9 +B2AA B2AA EABABE B2AA +B2AB B2AB EABB80 B2AB +B2AC B2AC EABB84 B2AC +B2AD B2AD EABB8C B2AD +B2AE B2AE EABB8D B2AE +B2AF B2AF EABB8F B2AF +B2B0 B2B0 EABB90 B2B0 +B2B1 B2B1 EABB91 B2B1 +B2B2 B2B2 EABB98 B2B2 +B2B3 B2B3 EABB99 B2B3 +B2B4 B2B4 EABB9C B2B4 +B2B5 B2B5 EABBA8 B2B5 +B2B6 B2B6 EABBAB B2B6 +B2B7 B2B7 EABBAD B2B7 +B2B8 B2B8 EABBB4 B2B8 +B2B9 B2B9 EABBB8 B2B9 +B2BA B2BA EABBBC B2BA +B2BB B2BB EABC87 B2BB +B2BC B2BC EABC88 B2BC +B2BD B2BD EABC8D B2BD +B2BE B2BE EABC90 B2BE +B2BF B2BF EABCAC B2BF +B2C0 B2C0 EABCAD B2C0 +B2C1 B2C1 EABCB0 B2C1 +B2C2 B2C2 EABCB2 B2C2 +B2C3 B2C3 EABCB4 B2C3 +B2C4 B2C4 EABCBC B2C4 +B2C5 B2C5 EABCBD B2C5 +B2C6 B2C6 EABCBF B2C6 +B2C7 B2C7 EABD81 B2C7 +B2C8 B2C8 EABD82 B2C8 +B2C9 B2C9 EABD83 B2C9 +B2CA B2CA EABD88 B2CA +B2CB B2CB EABD89 B2CB +B2CC B2CC EABD90 B2CC +B2CD B2CD EABD9C B2CD +B2CE B2CE EABD9D B2CE +B2CF B2CF EABDA4 B2CF +B2D0 B2D0 EABDA5 B2D0 +B2D1 B2D1 EABDB9 B2D1 +B2D2 B2D2 EABE80 B2D2 +B2D3 B2D3 EABE84 B2D3 +B2D4 B2D4 EABE88 B2D4 +B2D5 B2D5 EABE90 B2D5 +B2D6 B2D6 EABE91 B2D6 +B2D7 B2D7 EABE95 B2D7 +B2D8 B2D8 EABE9C B2D8 +B2D9 B2D9 EABEB8 B2D9 +B2DA B2DA EABEB9 B2DA +B2DB B2DB EABEBC B2DB +B2DC B2DC EABF80 B2DC +B2DD B2DD EABF87 B2DD +B2DE B2DE EABF88 B2DE +B2DF B2DF EABF89 B2DF +B2E0 B2E0 EABF8B B2E0 +B2E1 B2E1 EABF8D B2E1 +B2E2 B2E2 EABF8E B2E2 +B2E3 B2E3 EABF94 B2E3 +B2E4 B2E4 EABF9C B2E4 +B2E5 B2E5 EABFA8 B2E5 +B2E6 B2E6 EABFA9 B2E6 +B2E7 B2E7 EABFB0 B2E7 +B2E8 B2E8 EABFB1 B2E8 +B2E9 B2E9 EABFB4 B2E9 +B2EA B2EA EABFB8 B2EA +B2EB B2EB EB8080 B2EB +B2EC B2EC EB8081 B2EC +B2ED B2ED EB8084 B2ED +B2EE B2EE EB808C B2EE +B2EF B2EF EB8090 B2EF +B2F0 B2F0 EB8094 B2F0 +B2F1 B2F1 EB809C B2F1 +B2F2 B2F2 EB809D B2F2 +B2F3 B2F3 EB80A8 B2F3 +B2F4 B2F4 EB8184 B2F4 +B2F5 B2F5 EB8185 B2F5 +B2F6 B2F6 EB8188 B2F6 +B2F7 B2F7 EB818A B2F7 +B2F8 B2F8 EB818C B2F8 +B2F9 B2F9 EB818E B2F9 +B2FA B2FA EB8193 B2FA +B2FB B2FB EB8194 B2FB +B2FC B2FC EB8195 B2FC +B2FD B2FD EB8197 B2FD +B2FE B2FE EB8199 B2FE +B341 B341 ECBF8C B341 +B342 B342 ECBF8D B342 +B343 B343 ECBF8E B343 +B344 B344 ECBF8F B344 +B345 B345 ECBF90 B345 +B346 B346 ECBF91 B346 +B347 B347 ECBF92 B347 +B348 B348 ECBF93 B348 +B349 B349 ECBF94 B349 +B34A B34A ECBF95 B34A +B34B B34B ECBF96 B34B +B34C B34C ECBF97 B34C +B34D B34D ECBF98 B34D +B34E B34E ECBF99 B34E +B34F B34F ECBF9A B34F +B350 B350 ECBF9B B350 +B351 B351 ECBF9C B351 +B352 B352 ECBF9D B352 +B353 B353 ECBF9E B353 +B354 B354 ECBF9F B354 +B355 B355 ECBFA2 B355 +B356 B356 ECBFA3 B356 +B357 B357 ECBFA5 B357 +B358 B358 ECBFA6 B358 +B359 B359 ECBFA7 B359 +B35A B35A ECBFA9 B35A +B361 B361 ECBFAA B361 +B362 B362 ECBFAB B362 +B363 B363 ECBFAC B363 +B364 B364 ECBFAD B364 +B365 B365 ECBFAE B365 +B366 B366 ECBFAF B366 +B367 B367 ECBFB2 B367 +B368 B368 ECBFB4 B368 +B369 B369 ECBFB6 B369 +B36A B36A ECBFB7 B36A +B36B B36B ECBFB8 B36B +B36C B36C ECBFB9 B36C +B36D B36D ECBFBA B36D +B36E B36E ECBFBB B36E +B36F B36F ECBFBD B36F +B370 B370 ECBFBE B370 +B371 B371 ECBFBF B371 +B372 B372 ED8081 B372 +B373 B373 ED8082 B373 +B374 B374 ED8083 B374 +B375 B375 ED8085 B375 +B376 B376 ED8086 B376 +B377 B377 ED8087 B377 +B378 B378 ED8088 B378 +B379 B379 ED8089 B379 +B37A B37A ED808A B37A +B381 B381 ED808B B381 +B382 B382 ED808C B382 +B383 B383 ED808D B383 +B384 B384 ED808E B384 +B385 B385 ED808F B385 +B386 B386 ED8090 B386 +B387 B387 ED8092 B387 +B388 B388 ED8093 B388 +B389 B389 ED8094 B389 +B38A B38A ED8095 B38A +B38B B38B ED8096 B38B +B38C B38C ED8097 B38C +B38D B38D ED8099 B38D +B38E B38E ED809A B38E +B38F B38F ED809B B38F +B390 B390 ED809C B390 +B391 B391 ED809D B391 +B392 B392 ED809E B392 +B393 B393 ED809F B393 +B394 B394 ED80A0 B394 +B395 B395 ED80A1 B395 +B396 B396 ED80A2 B396 +B397 B397 ED80A3 B397 +B398 B398 ED80A4 B398 +B399 B399 ED80A5 B399 +B39A B39A ED80A6 B39A +B39B B39B ED80A7 B39B +B39C B39C ED80A8 B39C +B39D B39D ED80A9 B39D +B39E B39E ED80AA B39E +B39F B39F ED80AB B39F +B3A0 B3A0 ED80AC B3A0 +B3A1 B3A1 EB819D B3A1 +B3A2 B3A2 EB81BC B3A2 +B3A3 B3A3 EB81BD B3A3 +B3A4 B3A4 EB8280 B3A4 +B3A5 B3A5 EB8284 B3A5 +B3A6 B3A6 EB828C B3A6 +B3A7 B3A7 EB828D B3A7 +B3A8 B3A8 EB828F B3A8 +B3A9 B3A9 EB8291 B3A9 +B3AA B3AA EB8298 B3AA +B3AB B3AB EB8299 B3AB +B3AC B3AC EB829A B3AC +B3AD B3AD EB829C B3AD +B3AE B3AE EB829F B3AE +B3AF B3AF EB82A0 B3AF +B3B0 B3B0 EB82A1 B3B0 +B3B1 B3B1 EB82A2 B3B1 +B3B2 B3B2 EB82A8 B3B2 +B3B3 B3B3 EB82A9 B3B3 +B3B4 B3B4 EB82AB B3B4 +B3B5 B3B5 EB82AC B3B5 +B3B6 B3B6 EB82AD B3B6 +B3B7 B3B7 EB82AE B3B7 +B3B8 B3B8 EB82AF B3B8 +B3B9 B3B9 EB82B1 B3B9 +B3BA B3BA EB82B3 B3BA +B3BB B3BB EB82B4 B3BB +B3BC B3BC EB82B5 B3BC +B3BD B3BD EB82B8 B3BD +B3BE B3BE EB82BC B3BE +B3BF B3BF EB8384 B3BF +B3C0 B3C0 EB8385 B3C0 +B3C1 B3C1 EB8387 B3C1 +B3C2 B3C2 EB8388 B3C2 +B3C3 B3C3 EB8389 B3C3 +B3C4 B3C4 EB8390 B3C4 +B3C5 B3C5 EB8391 B3C5 +B3C6 B3C6 EB8394 B3C6 +B3C7 B3C7 EB8398 B3C7 +B3C8 B3C8 EB83A0 B3C8 +B3C9 B3C9 EB83A5 B3C9 +B3CA B3CA EB8488 B3CA +B3CB B3CB EB8489 B3CB +B3CC B3CC EB848B B3CC +B3CD B3CD EB848C B3CD +B3CE B3CE EB8490 B3CE +B3CF B3CF EB8492 B3CF +B3D0 B3D0 EB8493 B3D0 +B3D1 B3D1 EB8498 B3D1 +B3D2 B3D2 EB8499 B3D2 +B3D3 B3D3 EB849B B3D3 +B3D4 B3D4 EB849C B3D4 +B3D5 B3D5 EB849D B3D5 +B3D6 B3D6 EB84A3 B3D6 +B3D7 B3D7 EB84A4 B3D7 +B3D8 B3D8 EB84A5 B3D8 +B3D9 B3D9 EB84A8 B3D9 +B3DA B3DA EB84AC B3DA +B3DB B3DB EB84B4 B3DB +B3DC B3DC EB84B5 B3DC +B3DD B3DD EB84B7 B3DD +B3DE B3DE EB84B8 B3DE +B3DF B3DF EB84B9 B3DF +B3E0 B3E0 EB8580 B3E0 +B3E1 B3E1 EB8581 B3E1 +B3E2 B3E2 EB8584 B3E2 +B3E3 B3E3 EB8588 B3E3 +B3E4 B3E4 EB8590 B3E4 +B3E5 B3E5 EB8591 B3E5 +B3E6 B3E6 EB8594 B3E6 +B3E7 B3E7 EB8595 B3E7 +B3E8 B3E8 EB8598 B3E8 +B3E9 B3E9 EB859C B3E9 +B3EA B3EA EB85A0 B3EA +B3EB B3EB EB85B8 B3EB +B3EC B3EC EB85B9 B3EC +B3ED B3ED EB85BC B3ED +B3EE B3EE EB8680 B3EE +B3EF B3EF EB8682 B3EF +B3F0 B3F0 EB8688 B3F0 +B3F1 B3F1 EB8689 B3F1 +B3F2 B3F2 EB868B B3F2 +B3F3 B3F3 EB868D B3F3 +B3F4 B3F4 EB8692 B3F4 +B3F5 B3F5 EB8693 B3F5 +B3F6 B3F6 EB8694 B3F6 +B3F7 B3F7 EB8698 B3F7 +B3F8 B3F8 EB869C B3F8 +B3F9 B3F9 EB86A8 B3F9 +B3FA B3FA EB878C B3FA +B3FB B3FB EB8790 B3FB +B3FC B3FC EB8794 B3FC +B3FD B3FD EB879C B3FD +B3FE B3FE EB879D B3FE +B441 B441 ED80AE B441 +B442 B442 ED80AF B442 +B443 B443 ED80B0 B443 +B444 B444 ED80B1 B444 +B445 B445 ED80B2 B445 +B446 B446 ED80B3 B446 +B447 B447 ED80B6 B447 +B448 B448 ED80B7 B448 +B449 B449 ED80B9 B449 +B44A B44A ED80BA B44A +B44B B44B ED80BB B44B +B44C B44C ED80BD B44C +B44D B44D ED80BE B44D +B44E B44E ED80BF B44E +B44F B44F ED8180 B44F +B450 B450 ED8181 B450 +B451 B451 ED8182 B451 +B452 B452 ED8183 B452 +B453 B453 ED8186 B453 +B454 B454 ED8188 B454 +B455 B455 ED818A B455 +B456 B456 ED818B B456 +B457 B457 ED818C B457 +B458 B458 ED818D B458 +B459 B459 ED818E B459 +B45A B45A ED818F B45A +B461 B461 ED8191 B461 +B462 B462 ED8192 B462 +B463 B463 ED8193 B463 +B464 B464 ED8195 B464 +B465 B465 ED8196 B465 +B466 B466 ED8197 B466 +B467 B467 ED8199 B467 +B468 B468 ED819A B468 +B469 B469 ED819B B469 +B46A B46A ED819C B46A +B46B B46B ED819D B46B +B46C B46C ED819E B46C +B46D B46D ED819F B46D +B46E B46E ED81A1 B46E +B46F B46F ED81A2 B46F +B470 B470 ED81A3 B470 +B471 B471 ED81A4 B471 +B472 B472 ED81A5 B472 +B473 B473 ED81A6 B473 +B474 B474 ED81A7 B474 +B475 B475 ED81A8 B475 +B476 B476 ED81A9 B476 +B477 B477 ED81AA B477 +B478 B478 ED81AB B478 +B479 B479 ED81AE B479 +B47A B47A ED81AF B47A +B481 B481 ED81B1 B481 +B482 B482 ED81B2 B482 +B483 B483 ED81B3 B483 +B484 B484 ED81B5 B484 +B485 B485 ED81B6 B485 +B486 B486 ED81B7 B486 +B487 B487 ED81B8 B487 +B488 B488 ED81B9 B488 +B489 B489 ED81BA B489 +B48A B48A ED81BB B48A +B48B B48B ED81BE B48B +B48C B48C ED81BF B48C +B48D B48D ED8280 B48D +B48E B48E ED8282 B48E +B48F B48F ED8283 B48F +B490 B490 ED8284 B490 +B491 B491 ED8285 B491 +B492 B492 ED8286 B492 +B493 B493 ED8287 B493 +B494 B494 ED8288 B494 +B495 B495 ED8289 B495 +B496 B496 ED828A B496 +B497 B497 ED828B B497 +B498 B498 ED828C B498 +B499 B499 ED828D B499 +B49A B49A ED828E B49A +B49B B49B ED828F B49B +B49C B49C ED8290 B49C +B49D B49D ED8291 B49D +B49E B49E ED8292 B49E +B49F B49F ED8293 B49F +B4A0 B4A0 ED8294 B4A0 +B4A1 B4A1 EB879F B4A1 +B4A2 B4A2 EB87A8 B4A2 +B4A3 B4A3 EB87A9 B4A3 +B4A4 B4A4 EB87AC B4A4 +B4A5 B4A5 EB87B0 B4A5 +B4A6 B4A6 EB87B9 B4A6 +B4A7 B4A7 EB87BB B4A7 +B4A8 B4A8 EB87BD B4A8 +B4A9 B4A9 EB8884 B4A9 +B4AA B4AA EB8885 B4AA +B4AB B4AB EB8888 B4AB +B4AC B4AC EB888B B4AC +B4AD B4AD EB888C B4AD +B4AE B4AE EB8894 B4AE +B4AF B4AF EB8895 B4AF +B4B0 B4B0 EB8897 B4B0 +B4B1 B4B1 EB8899 B4B1 +B4B2 B4B2 EB88A0 B4B2 +B4B3 B4B3 EB88B4 B4B3 +B4B4 B4B4 EB88BC B4B4 +B4B5 B4B5 EB8998 B4B5 +B4B6 B4B6 EB899C B4B6 +B4B7 B4B7 EB89A0 B4B7 +B4B8 B4B8 EB89A8 B4B8 +B4B9 B4B9 EB89A9 B4B9 +B4BA B4BA EB89B4 B4BA +B4BB B4BB EB89B5 B4BB +B4BC B4BC EB89BC B4BC +B4BD B4BD EB8A84 B4BD +B4BE B4BE EB8A85 B4BE +B4BF B4BF EB8A89 B4BF +B4C0 B4C0 EB8A90 B4C0 +B4C1 B4C1 EB8A91 B4C1 +B4C2 B4C2 EB8A94 B4C2 +B4C3 B4C3 EB8A98 B4C3 +B4C4 B4C4 EB8A99 B4C4 +B4C5 B4C5 EB8A9A B4C5 +B4C6 B4C6 EB8AA0 B4C6 +B4C7 B4C7 EB8AA1 B4C7 +B4C8 B4C8 EB8AA3 B4C8 +B4C9 B4C9 EB8AA5 B4C9 +B4CA B4CA EB8AA6 B4CA +B4CB B4CB EB8AAA B4CB +B4CC B4CC EB8AAC B4CC +B4CD B4CD EB8AB0 B4CD +B4CE B4CE EB8AB4 B4CE +B4CF B4CF EB8B88 B4CF +B4D0 B4D0 EB8B89 B4D0 +B4D1 B4D1 EB8B8C B4D1 +B4D2 B4D2 EB8B90 B4D2 +B4D3 B4D3 EB8B92 B4D3 +B4D4 B4D4 EB8B98 B4D4 +B4D5 B4D5 EB8B99 B4D5 +B4D6 B4D6 EB8B9B B4D6 +B4D7 B4D7 EB8B9D B4D7 +B4D8 B4D8 EB8BA2 B4D8 +B4D9 B4D9 EB8BA4 B4D9 +B4DA B4DA EB8BA5 B4DA +B4DB B4DB EB8BA6 B4DB +B4DC B4DC EB8BA8 B4DC +B4DD B4DD EB8BAB B4DD +B4DE B4DE EB8BAC B4DE +B4DF B4DF EB8BAD B4DF +B4E0 B4E0 EB8BAE B4E0 +B4E1 B4E1 EB8BAF B4E1 +B4E2 B4E2 EB8BB3 B4E2 +B4E3 B4E3 EB8BB4 B4E3 +B4E4 B4E4 EB8BB5 B4E4 +B4E5 B4E5 EB8BB7 B4E5 +B4E6 B4E6 EB8BB8 B4E6 +B4E7 B4E7 EB8BB9 B4E7 +B4E8 B4E8 EB8BBA B4E8 +B4E9 B4E9 EB8BBB B4E9 +B4EA B4EA EB8BBF B4EA +B4EB B4EB EB8C80 B4EB +B4EC B4EC EB8C81 B4EC +B4ED B4ED EB8C84 B4ED +B4EE B4EE EB8C88 B4EE +B4EF B4EF EB8C90 B4EF +B4F0 B4F0 EB8C91 B4F0 +B4F1 B4F1 EB8C93 B4F1 +B4F2 B4F2 EB8C94 B4F2 +B4F3 B4F3 EB8C95 B4F3 +B4F4 B4F4 EB8C9C B4F4 +B4F5 B4F5 EB8D94 B4F5 +B4F6 B4F6 EB8D95 B4F6 +B4F7 B4F7 EB8D96 B4F7 +B4F8 B4F8 EB8D98 B4F8 +B4F9 B4F9 EB8D9B B4F9 +B4FA B4FA EB8D9C B4FA +B4FB B4FB EB8D9E B4FB +B4FC B4FC EB8D9F B4FC +B4FD B4FD EB8DA4 B4FD +B4FE B4FE EB8DA5 B4FE +B541 B541 ED8295 B541 +B542 B542 ED8296 B542 +B543 B543 ED8297 B543 +B544 B544 ED8298 B544 +B545 B545 ED8299 B545 +B546 B546 ED829A B546 +B547 B547 ED829B B547 +B548 B548 ED829C B548 +B549 B549 ED829D B549 +B54A B54A ED829E B54A +B54B B54B ED829F B54B +B54C B54C ED82A0 B54C +B54D B54D ED82A1 B54D +B54E B54E ED82A2 B54E +B54F B54F ED82A3 B54F +B550 B550 ED82A6 B550 +B551 B551 ED82A7 B551 +B552 B552 ED82A9 B552 +B553 B553 ED82AA B553 +B554 B554 ED82AB B554 +B555 B555 ED82AD B555 +B556 B556 ED82AE B556 +B557 B557 ED82AF B557 +B558 B558 ED82B0 B558 +B559 B559 ED82B1 B559 +B55A B55A ED82B2 B55A +B561 B561 ED82B3 B561 +B562 B562 ED82B6 B562 +B563 B563 ED82B8 B563 +B564 B564 ED82BA B564 +B565 B565 ED82BB B565 +B566 B566 ED82BC B566 +B567 B567 ED82BD B567 +B568 B568 ED82BE B568 +B569 B569 ED82BF B569 +B56A B56A ED8382 B56A +B56B B56B ED8383 B56B +B56C B56C ED8385 B56C +B56D B56D ED8386 B56D +B56E B56E ED8387 B56E +B56F B56F ED838A B56F +B570 B570 ED838B B570 +B571 B571 ED838C B571 +B572 B572 ED838D B572 +B573 B573 ED838E B573 +B574 B574 ED838F B574 +B575 B575 ED8392 B575 +B576 B576 ED8396 B576 +B577 B577 ED8397 B577 +B578 B578 ED8398 B578 +B579 B579 ED8399 B579 +B57A B57A ED839A B57A +B581 B581 ED839B B581 +B582 B582 ED839E B582 +B583 B583 ED839F B583 +B584 B584 ED83A1 B584 +B585 B585 ED83A2 B585 +B586 B586 ED83A3 B586 +B587 B587 ED83A5 B587 +B588 B588 ED83A6 B588 +B589 B589 ED83A7 B589 +B58A B58A ED83A8 B58A +B58B B58B ED83A9 B58B +B58C B58C ED83AA B58C +B58D B58D ED83AB B58D +B58E B58E ED83AE B58E +B58F B58F ED83B2 B58F +B590 B590 ED83B3 B590 +B591 B591 ED83B4 B591 +B592 B592 ED83B5 B592 +B593 B593 ED83B6 B593 +B594 B594 ED83B7 B594 +B595 B595 ED83B9 B595 +B596 B596 ED83BA B596 +B597 B597 ED83BB B597 +B598 B598 ED83BC B598 +B599 B599 ED83BD B599 +B59A B59A ED83BE B59A +B59B B59B ED83BF B59B +B59C B59C ED8480 B59C +B59D B59D ED8481 B59D +B59E B59E ED8482 B59E +B59F B59F ED8483 B59F +B5A0 B5A0 ED8484 B5A0 +B5A1 B5A1 EB8DA7 B5A1 +B5A2 B5A2 EB8DA9 B5A2 +B5A3 B5A3 EB8DAB B5A3 +B5A4 B5A4 EB8DAE B5A4 +B5A5 B5A5 EB8DB0 B5A5 +B5A6 B5A6 EB8DB1 B5A6 +B5A7 B5A7 EB8DB4 B5A7 +B5A8 B5A8 EB8DB8 B5A8 +B5A9 B5A9 EB8E80 B5A9 +B5AA B5AA EB8E81 B5AA +B5AB B5AB EB8E83 B5AB +B5AC B5AC EB8E84 B5AC +B5AD B5AD EB8E85 B5AD +B5AE B5AE EB8E8C B5AE +B5AF B5AF EB8E90 B5AF +B5B0 B5B0 EB8E94 B5B0 +B5B1 B5B1 EB8EA0 B5B1 +B5B2 B5B2 EB8EA1 B5B2 +B5B3 B5B3 EB8EA8 B5B3 +B5B4 B5B4 EB8EAC B5B4 +B5B5 B5B5 EB8F84 B5B5 +B5B6 B5B6 EB8F85 B5B6 +B5B7 B5B7 EB8F88 B5B7 +B5B8 B5B8 EB8F8B B5B8 +B5B9 B5B9 EB8F8C B5B9 +B5BA B5BA EB8F8E B5BA +B5BB B5BB EB8F90 B5BB +B5BC B5BC EB8F94 B5BC +B5BD B5BD EB8F95 B5BD +B5BE B5BE EB8F97 B5BE +B5BF B5BF EB8F99 B5BF +B5C0 B5C0 EB8F9B B5C0 +B5C1 B5C1 EB8F9D B5C1 +B5C2 B5C2 EB8FA0 B5C2 +B5C3 B5C3 EB8FA4 B5C3 +B5C4 B5C4 EB8FA8 B5C4 +B5C5 B5C5 EB8FBC B5C5 +B5C6 B5C6 EB9090 B5C6 +B5C7 B5C7 EB9098 B5C7 +B5C8 B5C8 EB909C B5C8 +B5C9 B5C9 EB90A0 B5C9 +B5CA B5CA EB90A8 B5CA +B5CB B5CB EB90A9 B5CB +B5CC B5CC EB90AB B5CC +B5CD B5CD EB90B4 B5CD +B5CE B5CE EB9190 B5CE +B5CF B5CF EB9191 B5CF +B5D0 B5D0 EB9194 B5D0 +B5D1 B5D1 EB9198 B5D1 +B5D2 B5D2 EB91A0 B5D2 +B5D3 B5D3 EB91A1 B5D3 +B5D4 B5D4 EB91A3 B5D4 +B5D5 B5D5 EB91A5 B5D5 +B5D6 B5D6 EB91AC B5D6 +B5D7 B5D7 EB9280 B5D7 +B5D8 B5D8 EB9288 B5D8 +B5D9 B5D9 EB929D B5D9 +B5DA B5DA EB92A4 B5DA +B5DB B5DB EB92A8 B5DB +B5DC B5DC EB92AC B5DC +B5DD B5DD EB92B5 B5DD +B5DE B5DE EB92B7 B5DE +B5DF B5DF EB92B9 B5DF +B5E0 B5E0 EB9380 B5E0 +B5E1 B5E1 EB9384 B5E1 +B5E2 B5E2 EB9388 B5E2 +B5E3 B5E3 EB9390 B5E3 +B5E4 B5E4 EB9395 B5E4 +B5E5 B5E5 EB939C B5E5 +B5E6 B5E6 EB939D B5E6 +B5E7 B5E7 EB93A0 B5E7 +B5E8 B5E8 EB93A3 B5E8 +B5E9 B5E9 EB93A4 B5E9 +B5EA B5EA EB93A6 B5EA +B5EB B5EB EB93AC B5EB +B5EC B5EC EB93AD B5EC +B5ED B5ED EB93AF B5ED +B5EE B5EE EB93B1 B5EE +B5EF B5EF EB93B8 B5EF +B5F0 B5F0 EB9494 B5F0 +B5F1 B5F1 EB9495 B5F1 +B5F2 B5F2 EB9498 B5F2 +B5F3 B5F3 EB949B B5F3 +B5F4 B5F4 EB949C B5F4 +B5F5 B5F5 EB94A4 B5F5 +B5F6 B5F6 EB94A5 B5F6 +B5F7 B5F7 EB94A7 B5F7 +B5F8 B5F8 EB94A8 B5F8 +B5F9 B5F9 EB94A9 B5F9 +B5FA B5FA EB94AA B5FA +B5FB B5FB EB94B0 B5FB +B5FC B5FC EB94B1 B5FC +B5FD B5FD EB94B4 B5FD +B5FE B5FE EB94B8 B5FE +B641 B641 ED8485 B641 +B642 B642 ED8486 B642 +B643 B643 ED8487 B643 +B644 B644 ED8488 B644 +B645 B645 ED8489 B645 +B646 B646 ED848A B646 +B647 B647 ED848B B647 +B648 B648 ED848C B648 +B649 B649 ED848E B649 +B64A B64A ED848F B64A +B64B B64B ED8490 B64B +B64C B64C ED8491 B64C +B64D B64D ED8492 B64D +B64E B64E ED8493 B64E +B64F B64F ED8494 B64F +B650 B650 ED8495 B650 +B651 B651 ED8496 B651 +B652 B652 ED8497 B652 +B653 B653 ED8498 B653 +B654 B654 ED8499 B654 +B655 B655 ED849A B655 +B656 B656 ED849B B656 +B657 B657 ED849C B657 +B658 B658 ED849D B658 +B659 B659 ED849E B659 +B65A B65A ED849F B65A +B661 B661 ED84A0 B661 +B662 B662 ED84A1 B662 +B663 B663 ED84A2 B663 +B664 B664 ED84A3 B664 +B665 B665 ED84A4 B665 +B666 B666 ED84A5 B666 +B667 B667 ED84A6 B667 +B668 B668 ED84A7 B668 +B669 B669 ED84A8 B669 +B66A B66A ED84A9 B66A +B66B B66B ED84AA B66B +B66C B66C ED84AB B66C +B66D B66D ED84AC B66D +B66E B66E ED84AD B66E +B66F B66F ED84AE B66F +B670 B670 ED84AF B670 +B671 B671 ED84B2 B671 +B672 B672 ED84B3 B672 +B673 B673 ED84B5 B673 +B674 B674 ED84B6 B674 +B675 B675 ED84B7 B675 +B676 B676 ED84B9 B676 +B677 B677 ED84BB B677 +B678 B678 ED84BC B678 +B679 B679 ED84BD B679 +B67A B67A ED84BE B67A +B681 B681 ED84BF B681 +B682 B682 ED8582 B682 +B683 B683 ED8586 B683 +B684 B684 ED8587 B684 +B685 B685 ED8588 B685 +B686 B686 ED8589 B686 +B687 B687 ED858A B687 +B688 B688 ED858B B688 +B689 B689 ED858E B689 +B68A B68A ED858F B68A +B68B B68B ED8591 B68B +B68C B68C ED8592 B68C +B68D B68D ED8593 B68D +B68E B68E ED8595 B68E +B68F B68F ED8596 B68F +B690 B690 ED8597 B690 +B691 B691 ED8598 B691 +B692 B692 ED8599 B692 +B693 B693 ED859A B693 +B694 B694 ED859B B694 +B695 B695 ED859E B695 +B696 B696 ED85A0 B696 +B697 B697 ED85A2 B697 +B698 B698 ED85A3 B698 +B699 B699 ED85A4 B699 +B69A B69A ED85A5 B69A +B69B B69B ED85A6 B69B +B69C B69C ED85A7 B69C +B69D B69D ED85A9 B69D +B69E B69E ED85AA B69E +B69F B69F ED85AB B69F +B6A0 B6A0 ED85AD B6A0 +B6A1 B6A1 EB9580 B6A1 +B6A2 B6A2 EB9581 B6A2 +B6A3 B6A3 EB9583 B6A3 +B6A4 B6A4 EB9584 B6A4 +B6A5 B6A5 EB9585 B6A5 +B6A6 B6A6 EB958B B6A6 +B6A7 B6A7 EB958C B6A7 +B6A8 B6A8 EB958D B6A8 +B6A9 B6A9 EB9590 B6A9 +B6AA B6AA EB9594 B6AA +B6AB B6AB EB959C B6AB +B6AC B6AC EB959D B6AC +B6AD B6AD EB959F B6AD +B6AE B6AE EB95A0 B6AE +B6AF B6AF EB95A1 B6AF +B6B0 B6B0 EB96A0 B6B0 +B6B1 B6B1 EB96A1 B6B1 +B6B2 B6B2 EB96A4 B6B2 +B6B3 B6B3 EB96A8 B6B3 +B6B4 B6B4 EB96AA B6B4 +B6B5 B6B5 EB96AB B6B5 +B6B6 B6B6 EB96B0 B6B6 +B6B7 B6B7 EB96B1 B6B7 +B6B8 B6B8 EB96B3 B6B8 +B6B9 B6B9 EB96B4 B6B9 +B6BA B6BA EB96B5 B6BA +B6BB B6BB EB96BB B6BB +B6BC B6BC EB96BC B6BC +B6BD B6BD EB96BD B6BD +B6BE B6BE EB9780 B6BE +B6BF B6BF EB9784 B6BF +B6C0 B6C0 EB978C B6C0 +B6C1 B6C1 EB978D B6C1 +B6C2 B6C2 EB978F B6C2 +B6C3 B6C3 EB9790 B6C3 +B6C4 B6C4 EB9791 B6C4 +B6C5 B6C5 EB9798 B6C5 +B6C6 B6C6 EB97AC B6C6 +B6C7 B6C7 EB9890 B6C7 +B6C8 B6C8 EB9891 B6C8 +B6C9 B6C9 EB9894 B6C9 +B6CA B6CA EB9898 B6CA +B6CB B6CB EB98A5 B6CB +B6CC B6CC EB98AC B6CC +B6CD B6CD EB98B4 B6CD +B6CE B6CE EB9988 B6CE +B6CF B6CF EB99A4 B6CF +B6D0 B6D0 EB99A8 B6D0 +B6D1 B6D1 EB9A9C B6D1 +B6D2 B6D2 EB9A9D B6D2 +B6D3 B6D3 EB9AA0 B6D3 +B6D4 B6D4 EB9AA4 B6D4 +B6D5 B6D5 EB9AAB B6D5 +B6D6 B6D6 EB9AAC B6D6 +B6D7 B6D7 EB9AB1 B6D7 +B6D8 B6D8 EB9B94 B6D8 +B6D9 B6D9 EB9BB0 B6D9 +B6DA B6DA EB9BB4 B6DA +B6DB B6DB EB9BB8 B6DB +B6DC B6DC EB9C80 B6DC +B6DD B6DD EB9C81 B6DD +B6DE B6DE EB9C85 B6DE +B6DF B6DF EB9CA8 B6DF +B6E0 B6E0 EB9CA9 B6E0 +B6E1 B6E1 EB9CAC B6E1 +B6E2 B6E2 EB9CAF B6E2 +B6E3 B6E3 EB9CB0 B6E3 +B6E4 B6E4 EB9CB8 B6E4 +B6E5 B6E5 EB9CB9 B6E5 +B6E6 B6E6 EB9CBB B6E6 +B6E7 B6E7 EB9D84 B6E7 +B6E8 B6E8 EB9D88 B6E8 +B6E9 B6E9 EB9D8C B6E9 +B6EA B6EA EB9D94 B6EA +B6EB B6EB EB9D95 B6EB +B6EC B6EC EB9DA0 B6EC +B6ED B6ED EB9DA4 B6ED +B6EE B6EE EB9DA8 B6EE +B6EF B6EF EB9DB0 B6EF +B6F0 B6F0 EB9DB1 B6F0 +B6F1 B6F1 EB9DB3 B6F1 +B6F2 B6F2 EB9DB5 B6F2 +B6F3 B6F3 EB9DBC B6F3 +B6F4 B6F4 EB9DBD B6F4 +B6F5 B6F5 EB9E80 B6F5 +B6F6 B6F6 EB9E84 B6F6 +B6F7 B6F7 EB9E8C B6F7 +B6F8 B6F8 EB9E8D B6F8 +B6F9 B6F9 EB9E8F B6F9 +B6FA B6FA EB9E90 B6FA +B6FB B6FB EB9E91 B6FB +B6FC B6FC EB9E92 B6FC +B6FD B6FD EB9E96 B6FD +B6FE B6FE EB9E97 B6FE +B741 B741 ED85AE B741 +B742 B742 ED85AF B742 +B743 B743 ED85B0 B743 +B744 B744 ED85B1 B744 +B745 B745 ED85B2 B745 +B746 B746 ED85B3 B746 +B747 B747 ED85B4 B747 +B748 B748 ED85B5 B748 +B749 B749 ED85B6 B749 +B74A B74A ED85B7 B74A +B74B B74B ED85B8 B74B +B74C B74C ED85B9 B74C +B74D B74D ED85BA B74D +B74E B74E ED85BB B74E +B74F B74F ED85BD B74F +B750 B750 ED85BE B750 +B751 B751 ED85BF B751 +B752 B752 ED8680 B752 +B753 B753 ED8681 B753 +B754 B754 ED8682 B754 +B755 B755 ED8683 B755 +B756 B756 ED8685 B756 +B757 B757 ED8686 B757 +B758 B758 ED8687 B758 +B759 B759 ED8689 B759 +B75A B75A ED868A B75A +B761 B761 ED868B B761 +B762 B762 ED868C B762 +B763 B763 ED868D B763 +B764 B764 ED868E B764 +B765 B765 ED868F B765 +B766 B766 ED8690 B766 +B767 B767 ED8691 B767 +B768 B768 ED8692 B768 +B769 B769 ED8693 B769 +B76A B76A ED8694 B76A +B76B B76B ED8695 B76B +B76C B76C ED8696 B76C +B76D B76D ED8697 B76D +B76E B76E ED8698 B76E +B76F B76F ED8699 B76F +B770 B770 ED869A B770 +B771 B771 ED869B B771 +B772 B772 ED869C B772 +B773 B773 ED869D B773 +B774 B774 ED869E B774 +B775 B775 ED869F B775 +B776 B776 ED86A2 B776 +B777 B777 ED86A3 B777 +B778 B778 ED86A5 B778 +B779 B779 ED86A6 B779 +B77A B77A ED86A7 B77A +B781 B781 ED86A9 B781 +B782 B782 ED86AA B782 +B783 B783 ED86AB B783 +B784 B784 ED86AC B784 +B785 B785 ED86AD B785 +B786 B786 ED86AE B786 +B787 B787 ED86AF B787 +B788 B788 ED86B2 B788 +B789 B789 ED86B4 B789 +B78A B78A ED86B6 B78A +B78B B78B ED86B7 B78B +B78C B78C ED86B8 B78C +B78D B78D ED86B9 B78D +B78E B78E ED86BB B78E +B78F B78F ED86BD B78F +B790 B790 ED86BE B790 +B791 B791 ED86BF B791 +B792 B792 ED8781 B792 +B793 B793 ED8782 B793 +B794 B794 ED8783 B794 +B795 B795 ED8784 B795 +B796 B796 ED8785 B796 +B797 B797 ED8786 B797 +B798 B798 ED8787 B798 +B799 B799 ED8788 B799 +B79A B79A ED8789 B79A +B79B B79B ED878A B79B +B79C B79C ED878B B79C +B79D B79D ED878C B79D +B79E B79E ED878D B79E +B79F B79F ED878E B79F +B7A0 B7A0 ED878F B7A0 +B7A1 B7A1 EB9E98 B7A1 +B7A2 B7A2 EB9E99 B7A2 +B7A3 B7A3 EB9E9C B7A3 +B7A4 B7A4 EB9EA0 B7A4 +B7A5 B7A5 EB9EA8 B7A5 +B7A6 B7A6 EB9EA9 B7A6 +B7A7 B7A7 EB9EAB B7A7 +B7A8 B7A8 EB9EAC B7A8 +B7A9 B7A9 EB9EAD B7A9 +B7AA B7AA EB9EB4 B7AA +B7AB B7AB EB9EB5 B7AB +B7AC B7AC EB9EB8 B7AC +B7AD B7AD EB9F87 B7AD +B7AE B7AE EB9F89 B7AE +B7AF B7AF EB9FAC B7AF +B7B0 B7B0 EB9FAD B7B0 +B7B1 B7B1 EB9FB0 B7B1 +B7B2 B7B2 EB9FB4 B7B2 +B7B3 B7B3 EB9FBC B7B3 +B7B4 B7B4 EB9FBD B7B4 +B7B5 B7B5 EB9FBF B7B5 +B7B6 B7B6 EBA080 B7B6 +B7B7 B7B7 EBA081 B7B7 +B7B8 B7B8 EBA087 B7B8 +B7B9 B7B9 EBA088 B7B9 +B7BA B7BA EBA089 B7BA +B7BB B7BB EBA08C B7BB +B7BC B7BC EBA090 B7BC +B7BD B7BD EBA098 B7BD +B7BE B7BE EBA099 B7BE +B7BF B7BF EBA09B B7BF +B7C0 B7C0 EBA09D B7C0 +B7C1 B7C1 EBA0A4 B7C1 +B7C2 B7C2 EBA0A5 B7C2 +B7C3 B7C3 EBA0A8 B7C3 +B7C4 B7C4 EBA0AC B7C4 +B7C5 B7C5 EBA0B4 B7C5 +B7C6 B7C6 EBA0B5 B7C6 +B7C7 B7C7 EBA0B7 B7C7 +B7C8 B7C8 EBA0B8 B7C8 +B7C9 B7C9 EBA0B9 B7C9 +B7CA B7CA EBA180 B7CA +B7CB B7CB EBA184 B7CB +B7CC B7CC EBA191 B7CC +B7CD B7CD EBA193 B7CD +B7CE B7CE EBA19C B7CE +B7CF B7CF EBA19D B7CF +B7D0 B7D0 EBA1A0 B7D0 +B7D1 B7D1 EBA1A4 B7D1 +B7D2 B7D2 EBA1AC B7D2 +B7D3 B7D3 EBA1AD B7D3 +B7D4 B7D4 EBA1AF B7D4 +B7D5 B7D5 EBA1B1 B7D5 +B7D6 B7D6 EBA1B8 B7D6 +B7D7 B7D7 EBA1BC B7D7 +B7D8 B7D8 EBA28D B7D8 +B7D9 B7D9 EBA2A8 B7D9 +B7DA B7DA EBA2B0 B7DA +B7DB B7DB EBA2B4 B7DB +B7DC B7DC EBA2B8 B7DC +B7DD B7DD EBA380 B7DD +B7DE B7DE EBA381 B7DE +B7DF B7DF EBA383 B7DF +B7E0 B7E0 EBA385 B7E0 +B7E1 B7E1 EBA38C B7E1 +B7E2 B7E2 EBA390 B7E2 +B7E3 B7E3 EBA394 B7E3 +B7E4 B7E4 EBA39D B7E4 +B7E5 B7E5 EBA39F B7E5 +B7E6 B7E6 EBA3A1 B7E6 +B7E7 B7E7 EBA3A8 B7E7 +B7E8 B7E8 EBA3A9 B7E8 +B7E9 B7E9 EBA3AC B7E9 +B7EA B7EA EBA3B0 B7EA +B7EB B7EB EBA3B8 B7EB +B7EC B7EC EBA3B9 B7EC +B7ED B7ED EBA3BB B7ED +B7EE B7EE EBA3BD B7EE +B7EF B7EF EBA484 B7EF +B7F0 B7F0 EBA498 B7F0 +B7F1 B7F1 EBA4A0 B7F1 +B7F2 B7F2 EBA4BC B7F2 +B7F3 B7F3 EBA4BD B7F3 +B7F4 B7F4 EBA580 B7F4 +B7F5 B7F5 EBA584 B7F5 +B7F6 B7F6 EBA58C B7F6 +B7F7 B7F7 EBA58F B7F7 +B7F8 B7F8 EBA591 B7F8 +B7F9 B7F9 EBA598 B7F9 +B7FA B7FA EBA599 B7FA +B7FB B7FB EBA59C B7FB +B7FC B7FC EBA5A0 B7FC +B7FD B7FD EBA5A8 B7FD +B7FE B7FE EBA5A9 B7FE +B841 B841 ED8790 B841 +B842 B842 ED8791 B842 +B843 B843 ED8792 B843 +B844 B844 ED8793 B844 +B845 B845 ED8794 B845 +B846 B846 ED8795 B846 +B847 B847 ED8796 B847 +B848 B848 ED8797 B848 +B849 B849 ED8799 B849 +B84A B84A ED879A B84A +B84B B84B ED879B B84B +B84C B84C ED879C B84C +B84D B84D ED879D B84D +B84E B84E ED879E B84E +B84F B84F ED879F B84F +B850 B850 ED87A0 B850 +B851 B851 ED87A1 B851 +B852 B852 ED87A2 B852 +B853 B853 ED87A3 B853 +B854 B854 ED87A4 B854 +B855 B855 ED87A5 B855 +B856 B856 ED87A6 B856 +B857 B857 ED87A7 B857 +B858 B858 ED87A8 B858 +B859 B859 ED87A9 B859 +B85A B85A ED87AA B85A +B861 B861 ED87AB B861 +B862 B862 ED87AC B862 +B863 B863 ED87AD B863 +B864 B864 ED87AE B864 +B865 B865 ED87AF B865 +B866 B866 ED87B0 B866 +B867 B867 ED87B1 B867 +B868 B868 ED87B2 B868 +B869 B869 ED87B3 B869 +B86A B86A ED87B5 B86A +B86B B86B ED87B6 B86B +B86C B86C ED87B7 B86C +B86D B86D ED87B9 B86D +B86E B86E ED87BA B86E +B86F B86F ED87BB B86F +B870 B870 ED87BC B870 +B871 B871 ED87BD B871 +B872 B872 ED87BE B872 +B873 B873 ED87BF B873 +B874 B874 ED8880 B874 +B875 B875 ED8881 B875 +B876 B876 ED8882 B876 +B877 B877 ED8883 B877 +B878 B878 ED8884 B878 +B879 B879 ED8885 B879 +B87A B87A ED8886 B87A +B881 B881 ED8888 B881 +B882 B882 ED888A B882 +B883 B883 ED888B B883 +B884 B884 ED888C B884 +B885 B885 ED888D B885 +B886 B886 ED888E B886 +B887 B887 ED888F B887 +B888 B888 ED8891 B888 +B889 B889 ED8892 B889 +B88A B88A ED8893 B88A +B88B B88B ED8894 B88B +B88C B88C ED8895 B88C +B88D B88D ED8896 B88D +B88E B88E ED8897 B88E +B88F B88F ED8898 B88F +B890 B890 ED8899 B890 +B891 B891 ED889A B891 +B892 B892 ED889B B892 +B893 B893 ED889C B893 +B894 B894 ED889D B894 +B895 B895 ED889E B895 +B896 B896 ED889F B896 +B897 B897 ED88A0 B897 +B898 B898 ED88A1 B898 +B899 B899 ED88A2 B899 +B89A B89A ED88A3 B89A +B89B B89B ED88A4 B89B +B89C B89C ED88A5 B89C +B89D B89D ED88A6 B89D +B89E B89E ED88A7 B89E +B89F B89F ED88A8 B89F +B8A0 B8A0 ED88A9 B8A0 +B8A1 B8A1 EBA5AB B8A1 +B8A2 B8A2 EBA5AD B8A2 +B8A3 B8A3 EBA5B4 B8A3 +B8A4 B8A4 EBA5B5 B8A4 +B8A5 B8A5 EBA5B8 B8A5 +B8A6 B8A6 EBA5BC B8A6 +B8A7 B8A7 EBA684 B8A7 +B8A8 B8A8 EBA685 B8A8 +B8A9 B8A9 EBA687 B8A9 +B8AA B8AA EBA689 B8AA +B8AB B8AB EBA68A B8AB +B8AC B8AC EBA68D B8AC +B8AD B8AD EBA68E B8AD +B8AE B8AE EBA6AC B8AE +B8AF B8AF EBA6AD B8AF +B8B0 B8B0 EBA6B0 B8B0 +B8B1 B8B1 EBA6B4 B8B1 +B8B2 B8B2 EBA6BC B8B2 +B8B3 B8B3 EBA6BD B8B3 +B8B4 B8B4 EBA6BF B8B4 +B8B5 B8B5 EBA781 B8B5 +B8B6 B8B6 EBA788 B8B6 +B8B7 B8B7 EBA789 B8B7 +B8B8 B8B8 EBA78C B8B8 +B8B9 B8B9 EBA78E B8B9 +B8BA B8BA EBA78F B8BA +B8BB B8BB EBA790 B8BB +B8BC B8BC EBA791 B8BC +B8BD B8BD EBA792 B8BD +B8BE B8BE EBA798 B8BE +B8BF B8BF EBA799 B8BF +B8C0 B8C0 EBA79B B8C0 +B8C1 B8C1 EBA79D B8C1 +B8C2 B8C2 EBA79E B8C2 +B8C3 B8C3 EBA7A1 B8C3 +B8C4 B8C4 EBA7A3 B8C4 +B8C5 B8C5 EBA7A4 B8C5 +B8C6 B8C6 EBA7A5 B8C6 +B8C7 B8C7 EBA7A8 B8C7 +B8C8 B8C8 EBA7AC B8C8 +B8C9 B8C9 EBA7B4 B8C9 +B8CA B8CA EBA7B5 B8CA +B8CB B8CB EBA7B7 B8CB +B8CC B8CC EBA7B8 B8CC +B8CD B8CD EBA7B9 B8CD +B8CE B8CE EBA7BA B8CE +B8CF B8CF EBA880 B8CF +B8D0 B8D0 EBA881 B8D0 +B8D1 B8D1 EBA888 B8D1 +B8D2 B8D2 EBA895 B8D2 +B8D3 B8D3 EBA8B8 B8D3 +B8D4 B8D4 EBA8B9 B8D4 +B8D5 B8D5 EBA8BC B8D5 +B8D6 B8D6 EBA980 B8D6 +B8D7 B8D7 EBA982 B8D7 +B8D8 B8D8 EBA988 B8D8 +B8D9 B8D9 EBA989 B8D9 +B8DA B8DA EBA98B B8DA +B8DB B8DB EBA98D B8DB +B8DC B8DC EBA98E B8DC +B8DD B8DD EBA993 B8DD +B8DE B8DE EBA994 B8DE +B8DF B8DF EBA995 B8DF +B8E0 B8E0 EBA998 B8E0 +B8E1 B8E1 EBA99C B8E1 +B8E2 B8E2 EBA9A4 B8E2 +B8E3 B8E3 EBA9A5 B8E3 +B8E4 B8E4 EBA9A7 B8E4 +B8E5 B8E5 EBA9A8 B8E5 +B8E6 B8E6 EBA9A9 B8E6 +B8E7 B8E7 EBA9B0 B8E7 +B8E8 B8E8 EBA9B1 B8E8 +B8E9 B8E9 EBA9B4 B8E9 +B8EA B8EA EBA9B8 B8EA +B8EB B8EB EBAA83 B8EB +B8EC B8EC EBAA84 B8EC +B8ED B8ED EBAA85 B8ED +B8EE B8EE EBAA87 B8EE +B8EF B8EF EBAA8C B8EF +B8F0 B8F0 EBAAA8 B8F0 +B8F1 B8F1 EBAAA9 B8F1 +B8F2 B8F2 EBAAAB B8F2 +B8F3 B8F3 EBAAAC B8F3 +B8F4 B8F4 EBAAB0 B8F4 +B8F5 B8F5 EBAAB2 B8F5 +B8F6 B8F6 EBAAB8 B8F6 +B8F7 B8F7 EBAAB9 B8F7 +B8F8 B8F8 EBAABB B8F8 +B8F9 B8F9 EBAABD B8F9 +B8FA B8FA EBAB84 B8FA +B8FB B8FB EBAB88 B8FB +B8FC B8FC EBAB98 B8FC +B8FD B8FD EBAB99 B8FD +B8FE B8FE EBABBC B8FE +B941 B941 ED88AA B941 +B942 B942 ED88AB B942 +B943 B943 ED88AE B943 +B944 B944 ED88AF B944 +B945 B945 ED88B1 B945 +B946 B946 ED88B2 B946 +B947 B947 ED88B3 B947 +B948 B948 ED88B5 B948 +B949 B949 ED88B6 B949 +B94A B94A ED88B7 B94A +B94B B94B ED88B8 B94B +B94C B94C ED88B9 B94C +B94D B94D ED88BA B94D +B94E B94E ED88BB B94E +B94F B94F ED88BE B94F +B950 B950 ED8980 B950 +B951 B951 ED8982 B951 +B952 B952 ED8983 B952 +B953 B953 ED8984 B953 +B954 B954 ED8985 B954 +B955 B955 ED8986 B955 +B956 B956 ED8987 B956 +B957 B957 ED8989 B957 +B958 B958 ED898A B958 +B959 B959 ED898B B959 +B95A B95A ED898C B95A +B961 B961 ED898D B961 +B962 B962 ED898E B962 +B963 B963 ED898F B963 +B964 B964 ED8990 B964 +B965 B965 ED8991 B965 +B966 B966 ED8992 B966 +B967 B967 ED8993 B967 +B968 B968 ED8994 B968 +B969 B969 ED8995 B969 +B96A B96A ED8996 B96A +B96B B96B ED8997 B96B +B96C B96C ED8998 B96C +B96D B96D ED8999 B96D +B96E B96E ED899A B96E +B96F B96F ED899B B96F +B970 B970 ED899D B970 +B971 B971 ED899E B971 +B972 B972 ED899F B972 +B973 B973 ED89A0 B973 +B974 B974 ED89A1 B974 +B975 B975 ED89A2 B975 +B976 B976 ED89A3 B976 +B977 B977 ED89A5 B977 +B978 B978 ED89A6 B978 +B979 B979 ED89A7 B979 +B97A B97A ED89A8 B97A +B981 B981 ED89A9 B981 +B982 B982 ED89AA B982 +B983 B983 ED89AB B983 +B984 B984 ED89AC B984 +B985 B985 ED89AD B985 +B986 B986 ED89AE B986 +B987 B987 ED89AF B987 +B988 B988 ED89B0 B988 +B989 B989 ED89B1 B989 +B98A B98A ED89B2 B98A +B98B B98B ED89B3 B98B +B98C B98C ED89B4 B98C +B98D B98D ED89B5 B98D +B98E B98E ED89B6 B98E +B98F B98F ED89B7 B98F +B990 B990 ED89B8 B990 +B991 B991 ED89B9 B991 +B992 B992 ED89BA B992 +B993 B993 ED89BB B993 +B994 B994 ED89BC B994 +B995 B995 ED89BD B995 +B996 B996 ED89BE B996 +B997 B997 ED89BF B997 +B998 B998 ED8A82 B998 +B999 B999 ED8A83 B999 +B99A B99A ED8A85 B99A +B99B B99B ED8A86 B99B +B99C B99C ED8A87 B99C +B99D B99D ED8A89 B99D +B99E B99E ED8A8A B99E +B99F B99F ED8A8B B99F +B9A0 B9A0 ED8A8C B9A0 +B9A1 B9A1 EBAC80 B9A1 +B9A2 B9A2 EBAC84 B9A2 +B9A3 B9A3 EBAC8D B9A3 +B9A4 B9A4 EBAC8F B9A4 +B9A5 B9A5 EBAC91 B9A5 +B9A6 B9A6 EBAC98 B9A6 +B9A7 B9A7 EBAC9C B9A7 +B9A8 B9A8 EBACA0 B9A8 +B9A9 B9A9 EBACA9 B9A9 +B9AA B9AA EBACAB B9AA +B9AB B9AB EBACB4 B9AB +B9AC B9AC EBACB5 B9AC +B9AD B9AD EBACB6 B9AD +B9AE B9AE EBACB8 B9AE +B9AF B9AF EBACBB B9AF +B9B0 B9B0 EBACBC B9B0 +B9B1 B9B1 EBACBD B9B1 +B9B2 B9B2 EBACBE B9B2 +B9B3 B9B3 EBAD84 B9B3 +B9B4 B9B4 EBAD85 B9B4 +B9B5 B9B5 EBAD87 B9B5 +B9B6 B9B6 EBAD89 B9B6 +B9B7 B9B7 EBAD8D B9B7 +B9B8 B9B8 EBAD8F B9B8 +B9B9 B9B9 EBAD90 B9B9 +B9BA B9BA EBAD94 B9BA +B9BB B9BB EBAD98 B9BB +B9BC B9BC EBADA1 B9BC +B9BD B9BD EBADA3 B9BD +B9BE B9BE EBADAC B9BE +B9BF B9BF EBAE88 B9BF +B9C0 B9C0 EBAE8C B9C0 +B9C1 B9C1 EBAE90 B9C1 +B9C2 B9C2 EBAEA4 B9C2 +B9C3 B9C3 EBAEA8 B9C3 +B9C4 B9C4 EBAEAC B9C4 +B9C5 B9C5 EBAEB4 B9C5 +B9C6 B9C6 EBAEB7 B9C6 +B9C7 B9C7 EBAF80 B9C7 +B9C8 B9C8 EBAF84 B9C8 +B9C9 B9C9 EBAF88 B9C9 +B9CA B9CA EBAF90 B9CA +B9CB B9CB EBAF93 B9CB +B9CC B9CC EBAFB8 B9CC +B9CD B9CD EBAFB9 B9CD +B9CE B9CE EBAFBC B9CE +B9CF B9CF EBAFBF B9CF +B9D0 B9D0 EBB080 B9D0 +B9D1 B9D1 EBB082 B9D1 +B9D2 B9D2 EBB088 B9D2 +B9D3 B9D3 EBB089 B9D3 +B9D4 B9D4 EBB08B B9D4 +B9D5 B9D5 EBB08C B9D5 +B9D6 B9D6 EBB08D B9D6 +B9D7 B9D7 EBB08F B9D7 +B9D8 B9D8 EBB091 B9D8 +B9D9 B9D9 EBB094 B9D9 +B9DA B9DA EBB095 B9DA +B9DB B9DB EBB096 B9DB +B9DC B9DC EBB097 B9DC +B9DD B9DD EBB098 B9DD +B9DE B9DE EBB09B B9DE +B9DF B9DF EBB09C B9DF +B9E0 B9E0 EBB09D B9E0 +B9E1 B9E1 EBB09E B9E1 +B9E2 B9E2 EBB09F B9E2 +B9E3 B9E3 EBB0A4 B9E3 +B9E4 B9E4 EBB0A5 B9E4 +B9E5 B9E5 EBB0A7 B9E5 +B9E6 B9E6 EBB0A9 B9E6 +B9E7 B9E7 EBB0AD B9E7 +B9E8 B9E8 EBB0B0 B9E8 +B9E9 B9E9 EBB0B1 B9E9 +B9EA B9EA EBB0B4 B9EA +B9EB B9EB EBB0B8 B9EB +B9EC B9EC EBB180 B9EC +B9ED B9ED EBB181 B9ED +B9EE B9EE EBB183 B9EE +B9EF B9EF EBB184 B9EF +B9F0 B9F0 EBB185 B9F0 +B9F1 B9F1 EBB189 B9F1 +B9F2 B9F2 EBB18C B9F2 +B9F3 B9F3 EBB18D B9F3 +B9F4 B9F4 EBB190 B9F4 +B9F5 B9F5 EBB19D B9F5 +B9F6 B9F6 EBB284 B9F6 +B9F7 B9F7 EBB285 B9F7 +B9F8 B9F8 EBB288 B9F8 +B9F9 B9F9 EBB28B B9F9 +B9FA B9FA EBB28C B9FA +B9FB B9FB EBB28E B9FB +B9FC B9FC EBB294 B9FC +B9FD B9FD EBB295 B9FD +B9FE B9FE EBB297 B9FE +BA41 BA41 ED8A8D BA41 +BA42 BA42 ED8A8E BA42 +BA43 BA43 ED8A8F BA43 +BA44 BA44 ED8A92 BA44 +BA45 BA45 ED8A93 BA45 +BA46 BA46 ED8A94 BA46 +BA47 BA47 ED8A96 BA47 +BA48 BA48 ED8A97 BA48 +BA49 BA49 ED8A98 BA49 +BA4A BA4A ED8A99 BA4A +BA4B BA4B ED8A9A BA4B +BA4C BA4C ED8A9B BA4C +BA4D BA4D ED8A9D BA4D +BA4E BA4E ED8A9E BA4E +BA4F BA4F ED8A9F BA4F +BA50 BA50 ED8AA1 BA50 +BA51 BA51 ED8AA2 BA51 +BA52 BA52 ED8AA3 BA52 +BA53 BA53 ED8AA5 BA53 +BA54 BA54 ED8AA6 BA54 +BA55 BA55 ED8AA7 BA55 +BA56 BA56 ED8AA8 BA56 +BA57 BA57 ED8AA9 BA57 +BA58 BA58 ED8AAA BA58 +BA59 BA59 ED8AAB BA59 +BA5A BA5A ED8AAD BA5A +BA61 BA61 ED8AAE BA61 +BA62 BA62 ED8AAF BA62 +BA63 BA63 ED8AB0 BA63 +BA64 BA64 ED8AB2 BA64 +BA65 BA65 ED8AB3 BA65 +BA66 BA66 ED8AB4 BA66 +BA67 BA67 ED8AB5 BA67 +BA68 BA68 ED8AB6 BA68 +BA69 BA69 ED8AB7 BA69 +BA6A BA6A ED8ABA BA6A +BA6B BA6B ED8ABB BA6B +BA6C BA6C ED8ABD BA6C +BA6D BA6D ED8ABE BA6D +BA6E BA6E ED8B81 BA6E +BA6F BA6F ED8B83 BA6F +BA70 BA70 ED8B84 BA70 +BA71 BA71 ED8B85 BA71 +BA72 BA72 ED8B86 BA72 +BA73 BA73 ED8B87 BA73 +BA74 BA74 ED8B8A BA74 +BA75 BA75 ED8B8C BA75 +BA76 BA76 ED8B8D BA76 +BA77 BA77 ED8B8E BA77 +BA78 BA78 ED8B8F BA78 +BA79 BA79 ED8B90 BA79 +BA7A BA7A ED8B91 BA7A +BA81 BA81 ED8B92 BA81 +BA82 BA82 ED8B93 BA82 +BA83 BA83 ED8B95 BA83 +BA84 BA84 ED8B96 BA84 +BA85 BA85 ED8B97 BA85 +BA86 BA86 ED8B99 BA86 +BA87 BA87 ED8B9A BA87 +BA88 BA88 ED8B9B BA88 +BA89 BA89 ED8B9D BA89 +BA8A BA8A ED8B9E BA8A +BA8B BA8B ED8B9F BA8B +BA8C BA8C ED8BA0 BA8C +BA8D BA8D ED8BA1 BA8D +BA8E BA8E ED8BA2 BA8E +BA8F BA8F ED8BA3 BA8F +BA90 BA90 ED8BA6 BA90 +BA91 BA91 ED8BA7 BA91 +BA92 BA92 ED8BA8 BA92 +BA93 BA93 ED8BA9 BA93 +BA94 BA94 ED8BAA BA94 +BA95 BA95 ED8BAB BA95 +BA96 BA96 ED8BAC BA96 +BA97 BA97 ED8BAD BA97 +BA98 BA98 ED8BAE BA98 +BA99 BA99 ED8BAF BA99 +BA9A BA9A ED8BB2 BA9A +BA9B BA9B ED8BB3 BA9B +BA9C BA9C ED8BB5 BA9C +BA9D BA9D ED8BB6 BA9D +BA9E BA9E ED8BB7 BA9E +BA9F BA9F ED8BB9 BA9F +BAA0 BAA0 ED8BBA BAA0 +BAA1 BAA1 EBB299 BAA1 +BAA2 BAA2 EBB29A BAA2 +BAA3 BAA3 EBB2A0 BAA3 +BAA4 BAA4 EBB2A1 BAA4 +BAA5 BAA5 EBB2A4 BAA5 +BAA6 BAA6 EBB2A7 BAA6 +BAA7 BAA7 EBB2A8 BAA7 +BAA8 BAA8 EBB2B0 BAA8 +BAA9 BAA9 EBB2B1 BAA9 +BAAA BAAA EBB2B3 BAAA +BAAB BAAB EBB2B4 BAAB +BAAC BAAC EBB2B5 BAAC +BAAD BAAD EBB2BC BAAD +BAAE BAAE EBB2BD BAAE +BAAF BAAF EBB380 BAAF +BAB0 BAB0 EBB384 BAB0 +BAB1 BAB1 EBB38D BAB1 +BAB2 BAB2 EBB38F BAB2 +BAB3 BAB3 EBB390 BAB3 +BAB4 BAB4 EBB391 BAB4 +BAB5 BAB5 EBB395 BAB5 +BAB6 BAB6 EBB398 BAB6 +BAB7 BAB7 EBB39C BAB7 +BAB8 BAB8 EBB3B4 BAB8 +BAB9 BAB9 EBB3B5 BAB9 +BABA BABA EBB3B6 BABA +BABB BABB EBB3B8 BABB +BABC BABC EBB3BC BABC +BABD BABD EBB484 BABD +BABE BABE EBB485 BABE +BABF BABF EBB487 BABF +BAC0 BAC0 EBB489 BAC0 +BAC1 BAC1 EBB490 BAC1 +BAC2 BAC2 EBB494 BAC2 +BAC3 BAC3 EBB4A4 BAC3 +BAC4 BAC4 EBB4AC BAC4 +BAC5 BAC5 EBB580 BAC5 +BAC6 BAC6 EBB588 BAC6 +BAC7 BAC7 EBB589 BAC7 +BAC8 BAC8 EBB58C BAC8 +BAC9 BAC9 EBB590 BAC9 +BACA BACA EBB598 BACA +BACB BACB EBB599 BACB +BACC BACC EBB5A4 BACC +BACD BACD EBB5A8 BACD +BACE BACE EBB680 BACE +BACF BACF EBB681 BACF +BAD0 BAD0 EBB684 BAD0 +BAD1 BAD1 EBB687 BAD1 +BAD2 BAD2 EBB688 BAD2 +BAD3 BAD3 EBB689 BAD3 +BAD4 BAD4 EBB68A BAD4 +BAD5 BAD5 EBB690 BAD5 +BAD6 BAD6 EBB691 BAD6 +BAD7 BAD7 EBB693 BAD7 +BAD8 BAD8 EBB695 BAD8 +BAD9 BAD9 EBB699 BAD9 +BADA BADA EBB69A BADA +BADB BADB EBB69C BADB +BADC BADC EBB6A4 BADC +BADD BADD EBB6B0 BADD +BADE BADE EBB6B8 BADE +BADF BADF EBB794 BADF +BAE0 BAE0 EBB795 BAE0 +BAE1 BAE1 EBB798 BAE1 +BAE2 BAE2 EBB79C BAE2 +BAE3 BAE3 EBB7A9 BAE3 +BAE4 BAE4 EBB7B0 BAE4 +BAE5 BAE5 EBB7B4 BAE5 +BAE6 BAE6 EBB7B8 BAE6 +BAE7 BAE7 EBB880 BAE7 +BAE8 BAE8 EBB883 BAE8 +BAE9 BAE9 EBB885 BAE9 +BAEA BAEA EBB88C BAEA +BAEB BAEB EBB88D BAEB +BAEC BAEC EBB890 BAEC +BAED BAED EBB894 BAED +BAEE BAEE EBB89C BAEE +BAEF BAEF EBB89D BAEF +BAF0 BAF0 EBB89F BAF0 +BAF1 BAF1 EBB984 BAF1 +BAF2 BAF2 EBB985 BAF2 +BAF3 BAF3 EBB988 BAF3 +BAF4 BAF4 EBB98C BAF4 +BAF5 BAF5 EBB98E BAF5 +BAF6 BAF6 EBB994 BAF6 +BAF7 BAF7 EBB995 BAF7 +BAF8 BAF8 EBB997 BAF8 +BAF9 BAF9 EBB999 BAF9 +BAFA BAFA EBB99A BAFA +BAFB BAFB EBB99B BAFB +BAFC BAFC EBB9A0 BAFC +BAFD BAFD EBB9A1 BAFD +BAFE BAFE EBB9A4 BAFE +BB41 BB41 ED8BBB BB41 +BB42 BB42 ED8BBC BB42 +BB43 BB43 ED8BBD BB43 +BB44 BB44 ED8BBE BB44 +BB45 BB45 ED8BBF BB45 +BB46 BB46 ED8C82 BB46 +BB47 BB47 ED8C84 BB47 +BB48 BB48 ED8C86 BB48 +BB49 BB49 ED8C87 BB49 +BB4A BB4A ED8C88 BB4A +BB4B BB4B ED8C89 BB4B +BB4C BB4C ED8C8A BB4C +BB4D BB4D ED8C8B BB4D +BB4E BB4E ED8C8F BB4E +BB4F BB4F ED8C91 BB4F +BB50 BB50 ED8C92 BB50 +BB51 BB51 ED8C93 BB51 +BB52 BB52 ED8C95 BB52 +BB53 BB53 ED8C97 BB53 +BB54 BB54 ED8C98 BB54 +BB55 BB55 ED8C99 BB55 +BB56 BB56 ED8C9A BB56 +BB57 BB57 ED8C9B BB57 +BB58 BB58 ED8C9E BB58 +BB59 BB59 ED8CA2 BB59 +BB5A BB5A ED8CA3 BB5A +BB61 BB61 ED8CA4 BB61 +BB62 BB62 ED8CA6 BB62 +BB63 BB63 ED8CA7 BB63 +BB64 BB64 ED8CAA BB64 +BB65 BB65 ED8CAB BB65 +BB66 BB66 ED8CAD BB66 +BB67 BB67 ED8CAE BB67 +BB68 BB68 ED8CAF BB68 +BB69 BB69 ED8CB1 BB69 +BB6A BB6A ED8CB2 BB6A +BB6B BB6B ED8CB3 BB6B +BB6C BB6C ED8CB4 BB6C +BB6D BB6D ED8CB5 BB6D +BB6E BB6E ED8CB6 BB6E +BB6F BB6F ED8CB7 BB6F +BB70 BB70 ED8CBA BB70 +BB71 BB71 ED8CBE BB71 +BB72 BB72 ED8CBF BB72 +BB73 BB73 ED8D80 BB73 +BB74 BB74 ED8D81 BB74 +BB75 BB75 ED8D82 BB75 +BB76 BB76 ED8D83 BB76 +BB77 BB77 ED8D86 BB77 +BB78 BB78 ED8D87 BB78 +BB79 BB79 ED8D88 BB79 +BB7A BB7A ED8D89 BB7A +BB81 BB81 ED8D8A BB81 +BB82 BB82 ED8D8B BB82 +BB83 BB83 ED8D8C BB83 +BB84 BB84 ED8D8D BB84 +BB85 BB85 ED8D8E BB85 +BB86 BB86 ED8D8F BB86 +BB87 BB87 ED8D90 BB87 +BB88 BB88 ED8D91 BB88 +BB89 BB89 ED8D92 BB89 +BB8A BB8A ED8D93 BB8A +BB8B BB8B ED8D94 BB8B +BB8C BB8C ED8D95 BB8C +BB8D BB8D ED8D96 BB8D +BB8E BB8E ED8D97 BB8E +BB8F BB8F ED8D98 BB8F +BB90 BB90 ED8D99 BB90 +BB91 BB91 ED8D9A BB91 +BB92 BB92 ED8D9B BB92 +BB93 BB93 ED8D9C BB93 +BB94 BB94 ED8D9D BB94 +BB95 BB95 ED8D9E BB95 +BB96 BB96 ED8D9F BB96 +BB97 BB97 ED8DA0 BB97 +BB98 BB98 ED8DA1 BB98 +BB99 BB99 ED8DA2 BB99 +BB9A BB9A ED8DA3 BB9A +BB9B BB9B ED8DA4 BB9B +BB9C BB9C ED8DA5 BB9C +BB9D BB9D ED8DA6 BB9D +BB9E BB9E ED8DA7 BB9E +BB9F BB9F ED8DA8 BB9F +BBA0 BBA0 ED8DA9 BBA0 +BBA1 BBA1 EBB9A8 BBA1 +BBA2 BBA2 EBB9AA BBA2 +BBA3 BBA3 EBB9B0 BBA3 +BBA4 BBA4 EBB9B1 BBA4 +BBA5 BBA5 EBB9B3 BBA5 +BBA6 BBA6 EBB9B4 BBA6 +BBA7 BBA7 EBB9B5 BBA7 +BBA8 BBA8 EBB9BB BBA8 +BBA9 BBA9 EBB9BC BBA9 +BBAA BBAA EBB9BD BBAA +BBAB BBAB EBBA80 BBAB +BBAC BBAC EBBA84 BBAC +BBAD BBAD EBBA8C BBAD +BBAE BBAE EBBA8D BBAE +BBAF BBAF EBBA8F BBAF +BBB0 BBB0 EBBA90 BBB0 +BBB1 BBB1 EBBA91 BBB1 +BBB2 BBB2 EBBA98 BBB2 +BBB3 BBB3 EBBA99 BBB3 +BBB4 BBB4 EBBAA8 BBB4 +BBB5 BBB5 EBBB90 BBB5 +BBB6 BBB6 EBBB91 BBB6 +BBB7 BBB7 EBBB94 BBB7 +BBB8 BBB8 EBBB97 BBB8 +BBB9 BBB9 EBBB98 BBB9 +BBBA BBBA EBBBA0 BBBA +BBBB BBBB EBBBA3 BBBB +BBBC BBBC EBBBA4 BBBC +BBBD BBBD EBBBA5 BBBD +BBBE BBBE EBBBAC BBBE +BBBF BBBF EBBC81 BBBF +BBC0 BBC0 EBBC88 BBC0 +BBC1 BBC1 EBBC89 BBC1 +BBC2 BBC2 EBBC98 BBC2 +BBC3 BBC3 EBBC99 BBC3 +BBC4 BBC4 EBBC9B BBC4 +BBC5 BBC5 EBBC9C BBC5 +BBC6 BBC6 EBBC9D BBC6 +BBC7 BBC7 EBBD80 BBC7 +BBC8 BBC8 EBBD81 BBC8 +BBC9 BBC9 EBBD84 BBC9 +BBCA BBCA EBBD88 BBCA +BBCB BBCB EBBD90 BBCB +BBCC BBCC EBBD91 BBCC +BBCD BBCD EBBD95 BBCD +BBCE BBCE EBBE94 BBCE +BBCF BBCF EBBEB0 BBCF +BBD0 BBD0 EBBF85 BBD0 +BBD1 BBD1 EBBF8C BBD1 +BBD2 BBD2 EBBF8D BBD2 +BBD3 BBD3 EBBF90 BBD3 +BBD4 BBD4 EBBF94 BBD4 +BBD5 BBD5 EBBF9C BBD5 +BBD6 BBD6 EBBF9F BBD6 +BBD7 BBD7 EBBFA1 BBD7 +BBD8 BBD8 EC80BC BBD8 +BBD9 BBD9 EC8191 BBD9 +BBDA BBDA EC8198 BBDA +BBDB BBDB EC819C BBDB +BBDC BBDC EC81A0 BBDC +BBDD BBDD EC81A8 BBDD +BBDE BBDE EC81A9 BBDE +BBDF BBDF EC8290 BBDF +BBE0 BBE0 EC8291 BBE0 +BBE1 BBE1 EC8294 BBE1 +BBE2 BBE2 EC8298 BBE2 +BBE3 BBE3 EC82A0 BBE3 +BBE4 BBE4 EC82A1 BBE4 +BBE5 BBE5 EC82A3 BBE5 +BBE6 BBE6 EC82A5 BBE6 +BBE7 BBE7 EC82AC BBE7 +BBE8 BBE8 EC82AD BBE8 +BBE9 BBE9 EC82AF BBE9 +BBEA BBEA EC82B0 BBEA +BBEB BBEB EC82B3 BBEB +BBEC BBEC EC82B4 BBEC +BBED BBED EC82B5 BBED +BBEE BBEE EC82B6 BBEE +BBEF BBEF EC82BC BBEF +BBF0 BBF0 EC82BD BBF0 +BBF1 BBF1 EC82BF BBF1 +BBF2 BBF2 EC8380 BBF2 +BBF3 BBF3 EC8381 BBF3 +BBF4 BBF4 EC8385 BBF4 +BBF5 BBF5 EC8388 BBF5 +BBF6 BBF6 EC8389 BBF6 +BBF7 BBF7 EC838C BBF7 +BBF8 BBF8 EC8390 BBF8 +BBF9 BBF9 EC8398 BBF9 +BBFA BBFA EC8399 BBFA +BBFB BBFB EC839B BBFB +BBFC BBFC EC839C BBFC +BBFD BBFD EC839D BBFD +BBFE BBFE EC83A4 BBFE +BC41 BC41 ED8DAA BC41 +BC42 BC42 ED8DAB BC42 +BC43 BC43 ED8DAC BC43 +BC44 BC44 ED8DAD BC44 +BC45 BC45 ED8DAE BC45 +BC46 BC46 ED8DAF BC46 +BC47 BC47 ED8DB0 BC47 +BC48 BC48 ED8DB1 BC48 +BC49 BC49 ED8DB2 BC49 +BC4A BC4A ED8DB3 BC4A +BC4B BC4B ED8DB4 BC4B +BC4C BC4C ED8DB5 BC4C +BC4D BC4D ED8DB6 BC4D +BC4E BC4E ED8DB7 BC4E +BC4F BC4F ED8DB8 BC4F +BC50 BC50 ED8DB9 BC50 +BC51 BC51 ED8DBA BC51 +BC52 BC52 ED8DBB BC52 +BC53 BC53 ED8DBE BC53 +BC54 BC54 ED8DBF BC54 +BC55 BC55 ED8E81 BC55 +BC56 BC56 ED8E82 BC56 +BC57 BC57 ED8E83 BC57 +BC58 BC58 ED8E85 BC58 +BC59 BC59 ED8E86 BC59 +BC5A BC5A ED8E87 BC5A +BC61 BC61 ED8E88 BC61 +BC62 BC62 ED8E89 BC62 +BC63 BC63 ED8E8A BC63 +BC64 BC64 ED8E8B BC64 +BC65 BC65 ED8E8E BC65 +BC66 BC66 ED8E92 BC66 +BC67 BC67 ED8E93 BC67 +BC68 BC68 ED8E94 BC68 +BC69 BC69 ED8E95 BC69 +BC6A BC6A ED8E96 BC6A +BC6B BC6B ED8E97 BC6B +BC6C BC6C ED8E9A BC6C +BC6D BC6D ED8E9B BC6D +BC6E BC6E ED8E9D BC6E +BC6F BC6F ED8E9E BC6F +BC70 BC70 ED8E9F BC70 +BC71 BC71 ED8EA1 BC71 +BC72 BC72 ED8EA2 BC72 +BC73 BC73 ED8EA3 BC73 +BC74 BC74 ED8EA4 BC74 +BC75 BC75 ED8EA5 BC75 +BC76 BC76 ED8EA6 BC76 +BC77 BC77 ED8EA7 BC77 +BC78 BC78 ED8EAA BC78 +BC79 BC79 ED8EAC BC79 +BC7A BC7A ED8EAE BC7A +BC81 BC81 ED8EAF BC81 +BC82 BC82 ED8EB0 BC82 +BC83 BC83 ED8EB1 BC83 +BC84 BC84 ED8EB2 BC84 +BC85 BC85 ED8EB3 BC85 +BC86 BC86 ED8EB5 BC86 +BC87 BC87 ED8EB6 BC87 +BC88 BC88 ED8EB7 BC88 +BC89 BC89 ED8EB9 BC89 +BC8A BC8A ED8EBA BC8A +BC8B BC8B ED8EBB BC8B +BC8C BC8C ED8EBD BC8C +BC8D BC8D ED8EBE BC8D +BC8E BC8E ED8EBF BC8E +BC8F BC8F ED8F80 BC8F +BC90 BC90 ED8F81 BC90 +BC91 BC91 ED8F82 BC91 +BC92 BC92 ED8F83 BC92 +BC93 BC93 ED8F86 BC93 +BC94 BC94 ED8F87 BC94 +BC95 BC95 ED8F8A BC95 +BC96 BC96 ED8F8B BC96 +BC97 BC97 ED8F8C BC97 +BC98 BC98 ED8F8D BC98 +BC99 BC99 ED8F8E BC99 +BC9A BC9A ED8F8F BC9A +BC9B BC9B ED8F91 BC9B +BC9C BC9C ED8F92 BC9C +BC9D BC9D ED8F93 BC9D +BC9E BC9E ED8F94 BC9E +BC9F BC9F ED8F95 BC9F +BCA0 BCA0 ED8F96 BCA0 +BCA1 BCA1 EC83A5 BCA1 +BCA2 BCA2 EC83A8 BCA2 +BCA3 BCA3 EC83AC BCA3 +BCA4 BCA4 EC83B4 BCA4 +BCA5 BCA5 EC83B5 BCA5 +BCA6 BCA6 EC83B7 BCA6 +BCA7 BCA7 EC83B9 BCA7 +BCA8 BCA8 EC8480 BCA8 +BCA9 BCA9 EC8484 BCA9 +BCAA BCAA EC8488 BCAA +BCAB BCAB EC8490 BCAB +BCAC BCAC EC8495 BCAC +BCAD BCAD EC849C BCAD +BCAE BCAE EC849D BCAE +BCAF BCAF EC849E BCAF +BCB0 BCB0 EC849F BCB0 +BCB1 BCB1 EC84A0 BCB1 +BCB2 BCB2 EC84A3 BCB2 +BCB3 BCB3 EC84A4 BCB3 +BCB4 BCB4 EC84A6 BCB4 +BCB5 BCB5 EC84A7 BCB5 +BCB6 BCB6 EC84AC BCB6 +BCB7 BCB7 EC84AD BCB7 +BCB8 BCB8 EC84AF BCB8 +BCB9 BCB9 EC84B0 BCB9 +BCBA BCBA EC84B1 BCBA +BCBB BCBB EC84B6 BCBB +BCBC BCBC EC84B8 BCBC +BCBD BCBD EC84B9 BCBD +BCBE BCBE EC84BC BCBE +BCBF BCBF EC8580 BCBF +BCC0 BCC0 EC8588 BCC0 +BCC1 BCC1 EC8589 BCC1 +BCC2 BCC2 EC858B BCC2 +BCC3 BCC3 EC858C BCC3 +BCC4 BCC4 EC858D BCC4 +BCC5 BCC5 EC8594 BCC5 +BCC6 BCC6 EC8595 BCC6 +BCC7 BCC7 EC8598 BCC7 +BCC8 BCC8 EC859C BCC8 +BCC9 BCC9 EC85A4 BCC9 +BCCA BCCA EC85A5 BCCA +BCCB BCCB EC85A7 BCCB +BCCC BCCC EC85A8 BCCC +BCCD BCCD EC85A9 BCCD +BCCE BCCE EC85B0 BCCE +BCCF BCCF EC85B4 BCCF +BCD0 BCD0 EC85B8 BCD0 +BCD1 BCD1 EC8685 BCD1 +BCD2 BCD2 EC868C BCD2 +BCD3 BCD3 EC868D BCD3 +BCD4 BCD4 EC868E BCD4 +BCD5 BCD5 EC8690 BCD5 +BCD6 BCD6 EC8694 BCD6 +BCD7 BCD7 EC8696 BCD7 +BCD8 BCD8 EC869C BCD8 +BCD9 BCD9 EC869D BCD9 +BCDA BCDA EC869F BCDA +BCDB BCDB EC86A1 BCDB +BCDC BCDC EC86A5 BCDC +BCDD BCDD EC86A8 BCDD +BCDE BCDE EC86A9 BCDE +BCDF BCDF EC86AC BCDF +BCE0 BCE0 EC86B0 BCE0 +BCE1 BCE1 EC86BD BCE1 +BCE2 BCE2 EC8784 BCE2 +BCE3 BCE3 EC8788 BCE3 +BCE4 BCE4 EC878C BCE4 +BCE5 BCE5 EC8794 BCE5 +BCE6 BCE6 EC8797 BCE6 +BCE7 BCE7 EC8798 BCE7 +BCE8 BCE8 EC87A0 BCE8 +BCE9 BCE9 EC87A4 BCE9 +BCEA BCEA EC87A8 BCEA +BCEB BCEB EC87B0 BCEB +BCEC BCEC EC87B1 BCEC +BCED BCED EC87B3 BCED +BCEE BCEE EC87BC BCEE +BCEF BCEF EC87BD BCEF +BCF0 BCF0 EC8880 BCF0 +BCF1 BCF1 EC8884 BCF1 +BCF2 BCF2 EC888C BCF2 +BCF3 BCF3 EC888D BCF3 +BCF4 BCF4 EC888F BCF4 +BCF5 BCF5 EC8891 BCF5 +BCF6 BCF6 EC8898 BCF6 +BCF7 BCF7 EC8899 BCF7 +BCF8 BCF8 EC889C BCF8 +BCF9 BCF9 EC889F BCF9 +BCFA BCFA EC88A0 BCFA +BCFB BCFB EC88A8 BCFB +BCFC BCFC EC88A9 BCFC +BCFD BCFD EC88AB BCFD +BCFE BCFE EC88AD BCFE +BD41 BD41 ED8F97 BD41 +BD42 BD42 ED8F99 BD42 +BD43 BD43 ED8F9A BD43 +BD44 BD44 ED8F9B BD44 +BD45 BD45 ED8F9C BD45 +BD46 BD46 ED8F9D BD46 +BD47 BD47 ED8F9E BD47 +BD48 BD48 ED8F9F BD48 +BD49 BD49 ED8FA0 BD49 +BD4A BD4A ED8FA2 BD4A +BD4B BD4B ED8FA4 BD4B +BD4C BD4C ED8FA5 BD4C +BD4D BD4D ED8FA6 BD4D +BD4E BD4E ED8FA7 BD4E +BD4F BD4F ED8FA8 BD4F +BD50 BD50 ED8FA9 BD50 +BD51 BD51 ED8FAA BD51 +BD52 BD52 ED8FAB BD52 +BD53 BD53 ED8FAE BD53 +BD54 BD54 ED8FAF BD54 +BD55 BD55 ED8FB1 BD55 +BD56 BD56 ED8FB2 BD56 +BD57 BD57 ED8FB3 BD57 +BD58 BD58 ED8FB5 BD58 +BD59 BD59 ED8FB6 BD59 +BD5A BD5A ED8FB7 BD5A +BD61 BD61 ED8FB8 BD61 +BD62 BD62 ED8FB9 BD62 +BD63 BD63 ED8FBA BD63 +BD64 BD64 ED8FBB BD64 +BD65 BD65 ED8FBE BD65 +BD66 BD66 ED9080 BD66 +BD67 BD67 ED9082 BD67 +BD68 BD68 ED9083 BD68 +BD69 BD69 ED9084 BD69 +BD6A BD6A ED9085 BD6A +BD6B BD6B ED9086 BD6B +BD6C BD6C ED9087 BD6C +BD6D BD6D ED9089 BD6D +BD6E BD6E ED908A BD6E +BD6F BD6F ED908B BD6F +BD70 BD70 ED908C BD70 +BD71 BD71 ED908D BD71 +BD72 BD72 ED908E BD72 +BD73 BD73 ED908F BD73 +BD74 BD74 ED9090 BD74 +BD75 BD75 ED9091 BD75 +BD76 BD76 ED9092 BD76 +BD77 BD77 ED9093 BD77 +BD78 BD78 ED9094 BD78 +BD79 BD79 ED9095 BD79 +BD7A BD7A ED9096 BD7A +BD81 BD81 ED9097 BD81 +BD82 BD82 ED9098 BD82 +BD83 BD83 ED9099 BD83 +BD84 BD84 ED909A BD84 +BD85 BD85 ED909B BD85 +BD86 BD86 ED909C BD86 +BD87 BD87 ED909E BD87 +BD88 BD88 ED909F BD88 +BD89 BD89 ED90A0 BD89 +BD8A BD8A ED90A1 BD8A +BD8B BD8B ED90A2 BD8B +BD8C BD8C ED90A3 BD8C +BD8D BD8D ED90A4 BD8D +BD8E BD8E ED90A5 BD8E +BD8F BD8F ED90A6 BD8F +BD90 BD90 ED90A7 BD90 +BD91 BD91 ED90A8 BD91 +BD92 BD92 ED90A9 BD92 +BD93 BD93 ED90AA BD93 +BD94 BD94 ED90AB BD94 +BD95 BD95 ED90AC BD95 +BD96 BD96 ED90AD BD96 +BD97 BD97 ED90AE BD97 +BD98 BD98 ED90AF BD98 +BD99 BD99 ED90B0 BD99 +BD9A BD9A ED90B1 BD9A +BD9B BD9B ED90B2 BD9B +BD9C BD9C ED90B3 BD9C +BD9D BD9D ED90B4 BD9D +BD9E BD9E ED90B5 BD9E +BD9F BD9F ED90B6 BD9F +BDA0 BDA0 ED90B7 BDA0 +BDA1 BDA1 EC88AF BDA1 +BDA2 BDA2 EC88B1 BDA2 +BDA3 BDA3 EC88B2 BDA3 +BDA4 BDA4 EC88B4 BDA4 +BDA5 BDA5 EC8988 BDA5 +BDA6 BDA6 EC8990 BDA6 +BDA7 BDA7 EC8991 BDA7 +BDA8 BDA8 EC8994 BDA8 +BDA9 BDA9 EC8998 BDA9 +BDAA BDAA EC89A0 BDAA +BDAB BDAB EC89A5 BDAB +BDAC BDAC EC89AC BDAC +BDAD BDAD EC89AD BDAD +BDAE BDAE EC89B0 BDAE +BDAF BDAF EC89B4 BDAF +BDB0 BDB0 EC89BC BDB0 +BDB1 BDB1 EC89BD BDB1 +BDB2 BDB2 EC89BF BDB2 +BDB3 BDB3 EC8A81 BDB3 +BDB4 BDB4 EC8A88 BDB4 +BDB5 BDB5 EC8A89 BDB5 +BDB6 BDB6 EC8A90 BDB6 +BDB7 BDB7 EC8A98 BDB7 +BDB8 BDB8 EC8A9B BDB8 +BDB9 BDB9 EC8A9D BDB9 +BDBA BDBA EC8AA4 BDBA +BDBB BDBB EC8AA5 BDBB +BDBC BDBC EC8AA8 BDBC +BDBD BDBD EC8AAC BDBD +BDBE BDBE EC8AAD BDBE +BDBF BDBF EC8AB4 BDBF +BDC0 BDC0 EC8AB5 BDC0 +BDC1 BDC1 EC8AB7 BDC1 +BDC2 BDC2 EC8AB9 BDC2 +BDC3 BDC3 EC8B9C BDC3 +BDC4 BDC4 EC8B9D BDC4 +BDC5 BDC5 EC8BA0 BDC5 +BDC6 BDC6 EC8BA3 BDC6 +BDC7 BDC7 EC8BA4 BDC7 +BDC8 BDC8 EC8BAB BDC8 +BDC9 BDC9 EC8BAC BDC9 +BDCA BDCA EC8BAD BDCA +BDCB BDCB EC8BAF BDCB +BDCC BDCC EC8BB1 BDCC +BDCD BDCD EC8BB6 BDCD +BDCE BDCE EC8BB8 BDCE +BDCF BDCF EC8BB9 BDCF +BDD0 BDD0 EC8BBB BDD0 +BDD1 BDD1 EC8BBC BDD1 +BDD2 BDD2 EC8C80 BDD2 +BDD3 BDD3 EC8C88 BDD3 +BDD4 BDD4 EC8C89 BDD4 +BDD5 BDD5 EC8C8C BDD5 +BDD6 BDD6 EC8C8D BDD6 +BDD7 BDD7 EC8C93 BDD7 +BDD8 BDD8 EC8C94 BDD8 +BDD9 BDD9 EC8C95 BDD9 +BDDA BDDA EC8C98 BDDA +BDDB BDDB EC8C9C BDDB +BDDC BDDC EC8CA4 BDDC +BDDD BDDD EC8CA5 BDDD +BDDE BDDE EC8CA8 BDDE +BDDF BDDF EC8CA9 BDDF +BDE0 BDE0 EC8D85 BDE0 +BDE1 BDE1 EC8DA8 BDE1 +BDE2 BDE2 EC8DA9 BDE2 +BDE3 BDE3 EC8DAC BDE3 +BDE4 BDE4 EC8DB0 BDE4 +BDE5 BDE5 EC8DB2 BDE5 +BDE6 BDE6 EC8DB8 BDE6 +BDE7 BDE7 EC8DB9 BDE7 +BDE8 BDE8 EC8DBC BDE8 +BDE9 BDE9 EC8DBD BDE9 +BDEA BDEA EC8E84 BDEA +BDEB BDEB EC8E88 BDEB +BDEC BDEC EC8E8C BDEC +BDED BDED EC8F80 BDED +BDEE BDEE EC8F98 BDEE +BDEF BDEF EC8F99 BDEF +BDF0 BDF0 EC8F9C BDF0 +BDF1 BDF1 EC8F9F BDF1 +BDF2 BDF2 EC8FA0 BDF2 +BDF3 BDF3 EC8FA2 BDF3 +BDF4 BDF4 EC8FA8 BDF4 +BDF5 BDF5 EC8FA9 BDF5 +BDF6 BDF6 EC8FAD BDF6 +BDF7 BDF7 EC8FB4 BDF7 +BDF8 BDF8 EC8FB5 BDF8 +BDF9 BDF9 EC8FB8 BDF9 +BDFA BDFA EC9088 BDFA +BDFB BDFB EC9090 BDFB +BDFC BDFC EC90A4 BDFC +BDFD BDFD EC90AC BDFD +BDFE BDFE EC90B0 BDFE +BE41 BE41 ED90B8 BE41 +BE42 BE42 ED90B9 BE42 +BE43 BE43 ED90BA BE43 +BE44 BE44 ED90BB BE44 +BE45 BE45 ED90BC BE45 +BE46 BE46 ED90BD BE46 +BE47 BE47 ED90BE BE47 +BE48 BE48 ED90BF BE48 +BE49 BE49 ED9181 BE49 +BE4A BE4A ED9182 BE4A +BE4B BE4B ED9183 BE4B +BE4C BE4C ED9185 BE4C +BE4D BE4D ED9186 BE4D +BE4E BE4E ED9187 BE4E +BE4F BE4F ED9188 BE4F +BE50 BE50 ED9189 BE50 +BE51 BE51 ED918A BE51 +BE52 BE52 ED918B BE52 +BE53 BE53 ED918C BE53 +BE54 BE54 ED918D BE54 +BE55 BE55 ED918E BE55 +BE56 BE56 ED918F BE56 +BE57 BE57 ED9190 BE57 +BE58 BE58 ED9191 BE58 +BE59 BE59 ED9192 BE59 +BE5A BE5A ED9193 BE5A +BE61 BE61 ED9194 BE61 +BE62 BE62 ED9195 BE62 +BE63 BE63 ED9196 BE63 +BE64 BE64 ED9197 BE64 +BE65 BE65 ED9198 BE65 +BE66 BE66 ED9199 BE66 +BE67 BE67 ED919A BE67 +BE68 BE68 ED919B BE68 +BE69 BE69 ED919D BE69 +BE6A BE6A ED919E BE6A +BE6B BE6B ED919F BE6B +BE6C BE6C ED91A1 BE6C +BE6D BE6D ED91A2 BE6D +BE6E BE6E ED91A3 BE6E +BE6F BE6F ED91A5 BE6F +BE70 BE70 ED91A6 BE70 +BE71 BE71 ED91A7 BE71 +BE72 BE72 ED91A8 BE72 +BE73 BE73 ED91A9 BE73 +BE74 BE74 ED91AA BE74 +BE75 BE75 ED91AB BE75 +BE76 BE76 ED91AC BE76 +BE77 BE77 ED91AE BE77 +BE78 BE78 ED91B0 BE78 +BE79 BE79 ED91B1 BE79 +BE7A BE7A ED91B2 BE7A +BE81 BE81 ED91B3 BE81 +BE82 BE82 ED91B4 BE82 +BE83 BE83 ED91B5 BE83 +BE84 BE84 ED91B6 BE84 +BE85 BE85 ED91B7 BE85 +BE86 BE86 ED91BA BE86 +BE87 BE87 ED91BB BE87 +BE88 BE88 ED91BD BE88 +BE89 BE89 ED91BE BE89 +BE8A BE8A ED9281 BE8A +BE8B BE8B ED9283 BE8B +BE8C BE8C ED9284 BE8C +BE8D BE8D ED9285 BE8D +BE8E BE8E ED9286 BE8E +BE8F BE8F ED9287 BE8F +BE90 BE90 ED928A BE90 +BE91 BE91 ED928C BE91 +BE92 BE92 ED928E BE92 +BE93 BE93 ED928F BE93 +BE94 BE94 ED9290 BE94 +BE95 BE95 ED9291 BE95 +BE96 BE96 ED9292 BE96 +BE97 BE97 ED9293 BE97 +BE98 BE98 ED9295 BE98 +BE99 BE99 ED9296 BE99 +BE9A BE9A ED9297 BE9A +BE9B BE9B ED9298 BE9B +BE9C BE9C ED9299 BE9C +BE9D BE9D ED929A BE9D +BE9E BE9E ED929B BE9E +BE9F BE9F ED929C BE9F +BEA0 BEA0 ED929D BEA0 +BEA1 BEA1 EC90B4 BEA1 +BEA2 BEA2 EC90BC BEA2 +BEA3 BEA3 EC90BD BEA3 +BEA4 BEA4 EC9188 BEA4 +BEA5 BEA5 EC91A4 BEA5 +BEA6 BEA6 EC91A5 BEA6 +BEA7 BEA7 EC91A8 BEA7 +BEA8 BEA8 EC91AC BEA8 +BEA9 BEA9 EC91B4 BEA9 +BEAA BEAA EC91B5 BEAA +BEAB BEAB EC91B9 BEAB +BEAC BEAC EC9280 BEAC +BEAD BEAD EC9294 BEAD +BEAE BEAE EC929C BEAE +BEAF BEAF EC92B8 BEAF +BEB0 BEB0 EC92BC BEB0 +BEB1 BEB1 EC93A9 BEB1 +BEB2 BEB2 EC93B0 BEB2 +BEB3 BEB3 EC93B1 BEB3 +BEB4 BEB4 EC93B4 BEB4 +BEB5 BEB5 EC93B8 BEB5 +BEB6 BEB6 EC93BA BEB6 +BEB7 BEB7 EC93BF BEB7 +BEB8 BEB8 EC9480 BEB8 +BEB9 BEB9 EC9481 BEB9 +BEBA BEBA EC948C BEBA +BEBB BEBB EC9490 BEBB +BEBC BEBC EC9494 BEBC +BEBD BEBD EC949C BEBD +BEBE BEBE EC94A8 BEBE +BEBF BEBF EC94A9 BEBF +BEC0 BEC0 EC94AC BEC0 +BEC1 BEC1 EC94B0 BEC1 +BEC2 BEC2 EC94B8 BEC2 +BEC3 BEC3 EC94B9 BEC3 +BEC4 BEC4 EC94BB BEC4 +BEC5 BEC5 EC94BD BEC5 +BEC6 BEC6 EC9584 BEC6 +BEC7 BEC7 EC9585 BEC7 +BEC8 BEC8 EC9588 BEC8 +BEC9 BEC9 EC9589 BEC9 +BECA BECA EC958A BECA +BECB BECB EC958C BECB +BECC BECC EC958D BECC +BECD BECD EC958E BECD +BECE BECE EC9593 BECE +BECF BECF EC9594 BECF +BED0 BED0 EC9595 BED0 +BED1 BED1 EC9597 BED1 +BED2 BED2 EC9598 BED2 +BED3 BED3 EC9599 BED3 +BED4 BED4 EC959D BED4 +BED5 BED5 EC959E BED5 +BED6 BED6 EC95A0 BED6 +BED7 BED7 EC95A1 BED7 +BED8 BED8 EC95A4 BED8 +BED9 BED9 EC95A8 BED9 +BEDA BEDA EC95B0 BEDA +BEDB BEDB EC95B1 BEDB +BEDC BEDC EC95B3 BEDC +BEDD BEDD EC95B4 BEDD +BEDE BEDE EC95B5 BEDE +BEDF BEDF EC95BC BEDF +BEE0 BEE0 EC95BD BEE0 +BEE1 BEE1 EC9680 BEE1 +BEE2 BEE2 EC9684 BEE2 +BEE3 BEE3 EC9687 BEE3 +BEE4 BEE4 EC968C BEE4 +BEE5 BEE5 EC968D BEE5 +BEE6 BEE6 EC968F BEE6 +BEE7 BEE7 EC9691 BEE7 +BEE8 BEE8 EC9695 BEE8 +BEE9 BEE9 EC9697 BEE9 +BEEA BEEA EC9698 BEEA +BEEB BEEB EC969C BEEB +BEEC BEEC EC96A0 BEEC +BEED BEED EC96A9 BEED +BEEE BEEE EC96B4 BEEE +BEEF BEEF EC96B5 BEEF +BEF0 BEF0 EC96B8 BEF0 +BEF1 BEF1 EC96B9 BEF1 +BEF2 BEF2 EC96BB BEF2 +BEF3 BEF3 EC96BC BEF3 +BEF4 BEF4 EC96BD BEF4 +BEF5 BEF5 EC96BE BEF5 +BEF6 BEF6 EC9784 BEF6 +BEF7 BEF7 EC9785 BEF7 +BEF8 BEF8 EC9786 BEF8 +BEF9 BEF9 EC9787 BEF9 +BEFA BEFA EC9788 BEFA +BEFB BEFB EC9789 BEFB +BEFC BEFC EC978A BEFC +BEFD BEFD EC978C BEFD +BEFE BEFE EC978E BEFE +BF41 BF41 ED929E BF41 +BF42 BF42 ED929F BF42 +BF43 BF43 ED92A0 BF43 +BF44 BF44 ED92A1 BF44 +BF45 BF45 ED92A2 BF45 +BF46 BF46 ED92A3 BF46 +BF47 BF47 ED92A4 BF47 +BF48 BF48 ED92A5 BF48 +BF49 BF49 ED92A6 BF49 +BF4A BF4A ED92A7 BF4A +BF4B BF4B ED92A8 BF4B +BF4C BF4C ED92AA BF4C +BF4D BF4D ED92AB BF4D +BF4E BF4E ED92AC BF4E +BF4F BF4F ED92AD BF4F +BF50 BF50 ED92AE BF50 +BF51 BF51 ED92AF BF51 +BF52 BF52 ED92B0 BF52 +BF53 BF53 ED92B1 BF53 +BF54 BF54 ED92B2 BF54 +BF55 BF55 ED92B3 BF55 +BF56 BF56 ED92B4 BF56 +BF57 BF57 ED92B5 BF57 +BF58 BF58 ED92B6 BF58 +BF59 BF59 ED92B7 BF59 +BF5A BF5A ED92B8 BF5A +BF61 BF61 ED92B9 BF61 +BF62 BF62 ED92BA BF62 +BF63 BF63 ED92BB BF63 +BF64 BF64 ED92BC BF64 +BF65 BF65 ED92BD BF65 +BF66 BF66 ED92BE BF66 +BF67 BF67 ED92BF BF67 +BF68 BF68 ED9380 BF68 +BF69 BF69 ED9381 BF69 +BF6A BF6A ED9382 BF6A +BF6B BF6B ED9383 BF6B +BF6C BF6C ED9384 BF6C +BF6D BF6D ED9385 BF6D +BF6E BF6E ED9386 BF6E +BF6F BF6F ED9387 BF6F +BF70 BF70 ED9388 BF70 +BF71 BF71 ED9389 BF71 +BF72 BF72 ED938A BF72 +BF73 BF73 ED938B BF73 +BF74 BF74 ED938D BF74 +BF75 BF75 ED938E BF75 +BF76 BF76 ED938F BF76 +BF77 BF77 ED9391 BF77 +BF78 BF78 ED9392 BF78 +BF79 BF79 ED9393 BF79 +BF7A BF7A ED9395 BF7A +BF81 BF81 ED9396 BF81 +BF82 BF82 ED9397 BF82 +BF83 BF83 ED9398 BF83 +BF84 BF84 ED9399 BF84 +BF85 BF85 ED939A BF85 +BF86 BF86 ED939B BF86 +BF87 BF87 ED939D BF87 +BF88 BF88 ED939E BF88 +BF89 BF89 ED93A0 BF89 +BF8A BF8A ED93A1 BF8A +BF8B BF8B ED93A2 BF8B +BF8C BF8C ED93A3 BF8C +BF8D BF8D ED93A4 BF8D +BF8E BF8E ED93A5 BF8E +BF8F BF8F ED93A6 BF8F +BF90 BF90 ED93A7 BF90 +BF91 BF91 ED93A9 BF91 +BF92 BF92 ED93AA BF92 +BF93 BF93 ED93AB BF93 +BF94 BF94 ED93AD BF94 +BF95 BF95 ED93AE BF95 +BF96 BF96 ED93AF BF96 +BF97 BF97 ED93B1 BF97 +BF98 BF98 ED93B2 BF98 +BF99 BF99 ED93B3 BF99 +BF9A BF9A ED93B4 BF9A +BF9B BF9B ED93B5 BF9B +BF9C BF9C ED93B6 BF9C +BF9D BF9D ED93B7 BF9D +BF9E BF9E ED93B9 BF9E +BF9F BF9F ED93BA BF9F +BFA0 BFA0 ED93BC BFA0 +BFA1 BFA1 EC9790 BFA1 +BFA2 BFA2 EC9791 BFA2 +BFA3 BFA3 EC9794 BFA3 +BFA4 BFA4 EC9798 BFA4 +BFA5 BFA5 EC97A0 BFA5 +BFA6 BFA6 EC97A1 BFA6 +BFA7 BFA7 EC97A3 BFA7 +BFA8 BFA8 EC97A5 BFA8 +BFA9 BFA9 EC97AC BFA9 +BFAA BFAA EC97AD BFAA +BFAB BFAB EC97AE BFAB +BFAC BFAC EC97B0 BFAC +BFAD BFAD EC97B4 BFAD +BFAE BFAE EC97B6 BFAE +BFAF BFAF EC97B7 BFAF +BFB0 BFB0 EC97BC BFB0 +BFB1 BFB1 EC97BD BFB1 +BFB2 BFB2 EC97BE BFB2 +BFB3 BFB3 EC97BF BFB3 +BFB4 BFB4 EC9880 BFB4 +BFB5 BFB5 EC9881 BFB5 +BFB6 BFB6 EC9885 BFB6 +BFB7 BFB7 EC9886 BFB7 +BFB8 BFB8 EC9887 BFB8 +BFB9 BFB9 EC9888 BFB9 +BFBA BFBA EC988C BFBA +BFBB BFBB EC9890 BFBB +BFBC BFBC EC9898 BFBC +BFBD BFBD EC9899 BFBD +BFBE BFBE EC989B BFBE +BFBF BFBF EC989C BFBF +BFC0 BFC0 EC98A4 BFC0 +BFC1 BFC1 EC98A5 BFC1 +BFC2 BFC2 EC98A8 BFC2 +BFC3 BFC3 EC98AC BFC3 +BFC4 BFC4 EC98AD BFC4 +BFC5 BFC5 EC98AE BFC5 +BFC6 BFC6 EC98B0 BFC6 +BFC7 BFC7 EC98B3 BFC7 +BFC8 BFC8 EC98B4 BFC8 +BFC9 BFC9 EC98B5 BFC9 +BFCA BFCA EC98B7 BFCA +BFCB BFCB EC98B9 BFCB +BFCC BFCC EC98BB BFCC +BFCD BFCD EC9980 BFCD +BFCE BFCE EC9981 BFCE +BFCF BFCF EC9984 BFCF +BFD0 BFD0 EC9988 BFD0 +BFD1 BFD1 EC9990 BFD1 +BFD2 BFD2 EC9991 BFD2 +BFD3 BFD3 EC9993 BFD3 +BFD4 BFD4 EC9994 BFD4 +BFD5 BFD5 EC9995 BFD5 +BFD6 BFD6 EC999C BFD6 +BFD7 BFD7 EC999D BFD7 +BFD8 BFD8 EC99A0 BFD8 +BFD9 BFD9 EC99AC BFD9 +BFDA BFDA EC99AF BFDA +BFDB BFDB EC99B1 BFDB +BFDC BFDC EC99B8 BFDC +BFDD BFDD EC99B9 BFDD +BFDE BFDE EC99BC BFDE +BFDF BFDF EC9A80 BFDF +BFE0 BFE0 EC9A88 BFE0 +BFE1 BFE1 EC9A89 BFE1 +BFE2 BFE2 EC9A8B BFE2 +BFE3 BFE3 EC9A8D BFE3 +BFE4 BFE4 EC9A94 BFE4 +BFE5 BFE5 EC9A95 BFE5 +BFE6 BFE6 EC9A98 BFE6 +BFE7 BFE7 EC9A9C BFE7 +BFE8 BFE8 EC9AA4 BFE8 +BFE9 BFE9 EC9AA5 BFE9 +BFEA BFEA EC9AA7 BFEA +BFEB BFEB EC9AA9 BFEB +BFEC BFEC EC9AB0 BFEC +BFED BFED EC9AB1 BFED +BFEE BFEE EC9AB4 BFEE +BFEF BFEF EC9AB8 BFEF +BFF0 BFF0 EC9AB9 BFF0 +BFF1 BFF1 EC9ABA BFF1 +BFF2 BFF2 EC9B80 BFF2 +BFF3 BFF3 EC9B81 BFF3 +BFF4 BFF4 EC9B83 BFF4 +BFF5 BFF5 EC9B85 BFF5 +BFF6 BFF6 EC9B8C BFF6 +BFF7 BFF7 EC9B8D BFF7 +BFF8 BFF8 EC9B90 BFF8 +BFF9 BFF9 EC9B94 BFF9 +BFFA BFFA EC9B9C BFFA +BFFB BFFB EC9B9D BFFB +BFFC BFFC EC9BA0 BFFC +BFFD BFFD EC9BA1 BFFD +BFFE BFFE EC9BA8 BFFE +C041 C041 ED93BE C041 +C042 C042 ED93BF C042 +C043 C043 ED9480 C043 +C044 C044 ED9481 C044 +C045 C045 ED9482 C045 +C046 C046 ED9483 C046 +C047 C047 ED9485 C047 +C048 C048 ED9486 C048 +C049 C049 ED9487 C049 +C04A C04A ED9489 C04A +C04B C04B ED948A C04B +C04C C04C ED948B C04C +C04D C04D ED948D C04D +C04E C04E ED948E C04E +C04F C04F ED948F C04F +C050 C050 ED9490 C050 +C051 C051 ED9491 C051 +C052 C052 ED9492 C052 +C053 C053 ED9493 C053 +C054 C054 ED9496 C054 +C055 C055 ED9498 C055 +C056 C056 ED9499 C056 +C057 C057 ED949A C057 +C058 C058 ED949B C058 +C059 C059 ED949C C059 +C05A C05A ED949D C05A +C061 C061 ED949E C061 +C062 C062 ED949F C062 +C063 C063 ED94A0 C063 +C064 C064 ED94A1 C064 +C065 C065 ED94A2 C065 +C066 C066 ED94A3 C066 +C067 C067 ED94A4 C067 +C068 C068 ED94A5 C068 +C069 C069 ED94A6 C069 +C06A C06A ED94A7 C06A +C06B C06B ED94A8 C06B +C06C C06C ED94A9 C06C +C06D C06D ED94AA C06D +C06E C06E ED94AB C06E +C06F C06F ED94AC C06F +C070 C070 ED94AD C070 +C071 C071 ED94AE C071 +C072 C072 ED94AF C072 +C073 C073 ED94B0 C073 +C074 C074 ED94B1 C074 +C075 C075 ED94B2 C075 +C076 C076 ED94B3 C076 +C077 C077 ED94B4 C077 +C078 C078 ED94B5 C078 +C079 C079 ED94B6 C079 +C07A C07A ED94B7 C07A +C081 C081 ED94B8 C081 +C082 C082 ED94B9 C082 +C083 C083 ED94BA C083 +C084 C084 ED94BB C084 +C085 C085 ED94BE C085 +C086 C086 ED94BF C086 +C087 C087 ED9581 C087 +C088 C088 ED9582 C088 +C089 C089 ED9583 C089 +C08A C08A ED9585 C08A +C08B C08B ED9586 C08B +C08C C08C ED9587 C08C +C08D C08D ED9588 C08D +C08E C08E ED9589 C08E +C08F C08F ED958A C08F +C090 C090 ED958B C090 +C091 C091 ED958E C091 +C092 C092 ED9590 C092 +C093 C093 ED9592 C093 +C094 C094 ED9593 C094 +C095 C095 ED9594 C095 +C096 C096 ED9595 C096 +C097 C097 ED9596 C097 +C098 C098 ED9597 C098 +C099 C099 ED959A C099 +C09A C09A ED959B C09A +C09B C09B ED959D C09B +C09C C09C ED959E C09C +C09D C09D ED959F C09D +C09E C09E ED95A1 C09E +C09F C09F ED95A2 C09F +C0A0 C0A0 ED95A3 C0A0 +C0A1 C0A1 EC9BA9 C0A1 +C0A2 C0A2 EC9BAC C0A2 +C0A3 C0A3 EC9BB0 C0A3 +C0A4 C0A4 EC9BB8 C0A4 +C0A5 C0A5 EC9BB9 C0A5 +C0A6 C0A6 EC9BBD C0A6 +C0A7 C0A7 EC9C84 C0A7 +C0A8 C0A8 EC9C85 C0A8 +C0A9 C0A9 EC9C88 C0A9 +C0AA C0AA EC9C8C C0AA +C0AB C0AB EC9C94 C0AB +C0AC C0AC EC9C95 C0AC +C0AD C0AD EC9C97 C0AD +C0AE C0AE EC9C99 C0AE +C0AF C0AF EC9CA0 C0AF +C0B0 C0B0 EC9CA1 C0B0 +C0B1 C0B1 EC9CA4 C0B1 +C0B2 C0B2 EC9CA8 C0B2 +C0B3 C0B3 EC9CB0 C0B3 +C0B4 C0B4 EC9CB1 C0B4 +C0B5 C0B5 EC9CB3 C0B5 +C0B6 C0B6 EC9CB5 C0B6 +C0B7 C0B7 EC9CB7 C0B7 +C0B8 C0B8 EC9CBC C0B8 +C0B9 C0B9 EC9CBD C0B9 +C0BA C0BA EC9D80 C0BA +C0BB C0BB EC9D84 C0BB +C0BC C0BC EC9D8A C0BC +C0BD C0BD EC9D8C C0BD +C0BE C0BE EC9D8D C0BE +C0BF C0BF EC9D8F C0BF +C0C0 C0C0 EC9D91 C0C0 +C0C1 C0C1 EC9D92 C0C1 +C0C2 C0C2 EC9D93 C0C2 +C0C3 C0C3 EC9D94 C0C3 +C0C4 C0C4 EC9D95 C0C4 +C0C5 C0C5 EC9D96 C0C5 +C0C6 C0C6 EC9D97 C0C6 +C0C7 C0C7 EC9D98 C0C7 +C0C8 C0C8 EC9D9C C0C8 +C0C9 C0C9 EC9DA0 C0C9 +C0CA C0CA EC9DA8 C0CA +C0CB C0CB EC9DAB C0CB +C0CC C0CC EC9DB4 C0CC +C0CD C0CD EC9DB5 C0CD +C0CE C0CE EC9DB8 C0CE +C0CF C0CF EC9DBC C0CF +C0D0 C0D0 EC9DBD C0D0 +C0D1 C0D1 EC9DBE C0D1 +C0D2 C0D2 EC9E83 C0D2 +C0D3 C0D3 EC9E84 C0D3 +C0D4 C0D4 EC9E85 C0D4 +C0D5 C0D5 EC9E87 C0D5 +C0D6 C0D6 EC9E88 C0D6 +C0D7 C0D7 EC9E89 C0D7 +C0D8 C0D8 EC9E8A C0D8 +C0D9 C0D9 EC9E8E C0D9 +C0DA C0DA EC9E90 C0DA +C0DB C0DB EC9E91 C0DB +C0DC C0DC EC9E94 C0DC +C0DD C0DD EC9E96 C0DD +C0DE C0DE EC9E97 C0DE +C0DF C0DF EC9E98 C0DF +C0E0 C0E0 EC9E9A C0E0 +C0E1 C0E1 EC9EA0 C0E1 +C0E2 C0E2 EC9EA1 C0E2 +C0E3 C0E3 EC9EA3 C0E3 +C0E4 C0E4 EC9EA4 C0E4 +C0E5 C0E5 EC9EA5 C0E5 +C0E6 C0E6 EC9EA6 C0E6 +C0E7 C0E7 EC9EAC C0E7 +C0E8 C0E8 EC9EAD C0E8 +C0E9 C0E9 EC9EB0 C0E9 +C0EA C0EA EC9EB4 C0EA +C0EB C0EB EC9EBC C0EB +C0EC C0EC EC9EBD C0EC +C0ED C0ED EC9EBF C0ED +C0EE C0EE EC9F80 C0EE +C0EF C0EF EC9F81 C0EF +C0F0 C0F0 EC9F88 C0F0 +C0F1 C0F1 EC9F89 C0F1 +C0F2 C0F2 EC9F8C C0F2 +C0F3 C0F3 EC9F8E C0F3 +C0F4 C0F4 EC9F90 C0F4 +C0F5 C0F5 EC9F98 C0F5 +C0F6 C0F6 EC9F9D C0F6 +C0F7 C0F7 EC9FA4 C0F7 +C0F8 C0F8 EC9FA8 C0F8 +C0F9 C0F9 EC9FAC C0F9 +C0FA C0FA ECA080 C0FA +C0FB C0FB ECA081 C0FB +C0FC C0FC ECA084 C0FC +C0FD C0FD ECA088 C0FD +C0FE C0FE ECA08A C0FE +C141 C141 ED95A4 C141 +C142 C142 ED95A6 C142 +C143 C143 ED95A7 C143 +C144 C144 ED95AA C144 +C145 C145 ED95AC C145 +C146 C146 ED95AE C146 +C147 C147 ED95AF C147 +C148 C148 ED95B0 C148 +C149 C149 ED95B1 C149 +C14A C14A ED95B2 C14A +C14B C14B ED95B3 C14B +C14C C14C ED95B6 C14C +C14D C14D ED95B7 C14D +C14E C14E ED95B9 C14E +C14F C14F ED95BA C14F +C150 C150 ED95BB C150 +C151 C151 ED95BD C151 +C152 C152 ED95BE C152 +C153 C153 ED95BF C153 +C154 C154 ED9680 C154 +C155 C155 ED9681 C155 +C156 C156 ED9682 C156 +C157 C157 ED9683 C157 +C158 C158 ED9686 C158 +C159 C159 ED968A C159 +C15A C15A ED968B C15A +C161 C161 ED968C C161 +C162 C162 ED968D C162 +C163 C163 ED968E C163 +C164 C164 ED968F C164 +C165 C165 ED9691 C165 +C166 C166 ED9692 C166 +C167 C167 ED9693 C167 +C168 C168 ED9694 C168 +C169 C169 ED9695 C169 +C16A C16A ED9696 C16A +C16B C16B ED9697 C16B +C16C C16C ED9698 C16C +C16D C16D ED9699 C16D +C16E C16E ED969A C16E +C16F C16F ED969B C16F +C170 C170 ED969C C170 +C171 C171 ED969D C171 +C172 C172 ED969E C172 +C173 C173 ED969F C173 +C174 C174 ED96A0 C174 +C175 C175 ED96A1 C175 +C176 C176 ED96A2 C176 +C177 C177 ED96A3 C177 +C178 C178 ED96A4 C178 +C179 C179 ED96A6 C179 +C17A C17A ED96A7 C17A +C181 C181 ED96A8 C181 +C182 C182 ED96A9 C182 +C183 C183 ED96AA C183 +C184 C184 ED96AB C184 +C185 C185 ED96AC C185 +C186 C186 ED96AD C186 +C187 C187 ED96AE C187 +C188 C188 ED96AF C188 +C189 C189 ED96B0 C189 +C18A C18A ED96B1 C18A +C18B C18B ED96B2 C18B +C18C C18C ED96B3 C18C +C18D C18D ED96B4 C18D +C18E C18E ED96B5 C18E +C18F C18F ED96B6 C18F +C190 C190 ED96B7 C190 +C191 C191 ED96B8 C191 +C192 C192 ED96B9 C192 +C193 C193 ED96BA C193 +C194 C194 ED96BB C194 +C195 C195 ED96BC C195 +C196 C196 ED96BD C196 +C197 C197 ED96BE C197 +C198 C198 ED96BF C198 +C199 C199 ED9780 C199 +C19A C19A ED9781 C19A +C19B C19B ED9782 C19B +C19C C19C ED9783 C19C +C19D C19D ED9784 C19D +C19E C19E ED9785 C19E +C19F C19F ED9786 C19F +C1A0 C1A0 ED9787 C1A0 +C1A1 C1A1 ECA090 C1A1 +C1A2 C1A2 ECA091 C1A2 +C1A3 C1A3 ECA093 C1A3 +C1A4 C1A4 ECA095 C1A4 +C1A5 C1A5 ECA096 C1A5 +C1A6 C1A6 ECA09C C1A6 +C1A7 C1A7 ECA09D C1A7 +C1A8 C1A8 ECA0A0 C1A8 +C1A9 C1A9 ECA0A4 C1A9 +C1AA C1AA ECA0AC C1AA +C1AB C1AB ECA0AD C1AB +C1AC C1AC ECA0AF C1AC +C1AD C1AD ECA0B1 C1AD +C1AE C1AE ECA0B8 C1AE +C1AF C1AF ECA0BC C1AF +C1B0 C1B0 ECA180 C1B0 +C1B1 C1B1 ECA188 C1B1 +C1B2 C1B2 ECA189 C1B2 +C1B3 C1B3 ECA18C C1B3 +C1B4 C1B4 ECA18D C1B4 +C1B5 C1B5 ECA194 C1B5 +C1B6 C1B6 ECA1B0 C1B6 +C1B7 C1B7 ECA1B1 C1B7 +C1B8 C1B8 ECA1B4 C1B8 +C1B9 C1B9 ECA1B8 C1B9 +C1BA C1BA ECA1BA C1BA +C1BB C1BB ECA280 C1BB +C1BC C1BC ECA281 C1BC +C1BD C1BD ECA283 C1BD +C1BE C1BE ECA285 C1BE +C1BF C1BF ECA286 C1BF +C1C0 C1C0 ECA287 C1C0 +C1C1 C1C1 ECA28B C1C1 +C1C2 C1C2 ECA28C C1C2 +C1C3 C1C3 ECA28D C1C3 +C1C4 C1C4 ECA294 C1C4 +C1C5 C1C5 ECA29D C1C5 +C1C6 C1C6 ECA29F C1C6 +C1C7 C1C7 ECA2A1 C1C7 +C1C8 C1C8 ECA2A8 C1C8 +C1C9 C1C9 ECA2BC C1C9 +C1CA C1CA ECA2BD C1CA +C1CB C1CB ECA384 C1CB +C1CC C1CC ECA388 C1CC +C1CD C1CD ECA38C C1CD +C1CE C1CE ECA394 C1CE +C1CF C1CF ECA395 C1CF +C1D0 C1D0 ECA397 C1D0 +C1D1 C1D1 ECA399 C1D1 +C1D2 C1D2 ECA3A0 C1D2 +C1D3 C1D3 ECA3A1 C1D3 +C1D4 C1D4 ECA3A4 C1D4 +C1D5 C1D5 ECA3B5 C1D5 +C1D6 C1D6 ECA3BC C1D6 +C1D7 C1D7 ECA3BD C1D7 +C1D8 C1D8 ECA480 C1D8 +C1D9 C1D9 ECA484 C1D9 +C1DA C1DA ECA485 C1DA +C1DB C1DB ECA486 C1DB +C1DC C1DC ECA48C C1DC +C1DD C1DD ECA48D C1DD +C1DE C1DE ECA48F C1DE +C1DF C1DF ECA491 C1DF +C1E0 C1E0 ECA498 C1E0 +C1E1 C1E1 ECA4AC C1E1 +C1E2 C1E2 ECA4B4 C1E2 +C1E3 C1E3 ECA590 C1E3 +C1E4 C1E4 ECA591 C1E4 +C1E5 C1E5 ECA594 C1E5 +C1E6 C1E6 ECA598 C1E6 +C1E7 C1E7 ECA5A0 C1E7 +C1E8 C1E8 ECA5A1 C1E8 +C1E9 C1E9 ECA5A3 C1E9 +C1EA C1EA ECA5AC C1EA +C1EB C1EB ECA5B0 C1EB +C1EC C1EC ECA5B4 C1EC +C1ED C1ED ECA5BC C1ED +C1EE C1EE ECA688 C1EE +C1EF C1EF ECA689 C1EF +C1F0 C1F0 ECA68C C1F0 +C1F1 C1F1 ECA690 C1F1 +C1F2 C1F2 ECA698 C1F2 +C1F3 C1F3 ECA699 C1F3 +C1F4 C1F4 ECA69B C1F4 +C1F5 C1F5 ECA69D C1F5 +C1F6 C1F6 ECA780 C1F6 +C1F7 C1F7 ECA781 C1F7 +C1F8 C1F8 ECA784 C1F8 +C1F9 C1F9 ECA787 C1F9 +C1FA C1FA ECA788 C1FA +C1FB C1FB ECA78A C1FB +C1FC C1FC ECA790 C1FC +C1FD C1FD ECA791 C1FD +C1FE C1FE ECA793 C1FE +C241 C241 ED978A C241 +C242 C242 ED978B C242 +C243 C243 ED978D C243 +C244 C244 ED978E C244 +C245 C245 ED978F C245 +C246 C246 ED9791 C246 +C247 C247 ED9793 C247 +C248 C248 ED9794 C248 +C249 C249 ED9795 C249 +C24A C24A ED9796 C24A +C24B C24B ED9797 C24B +C24C C24C ED979A C24C +C24D C24D ED979C C24D +C24E C24E ED979E C24E +C24F C24F ED979F C24F +C250 C250 ED97A0 C250 +C251 C251 ED97A1 C251 +C252 C252 ED97A2 C252 +C253 C253 ED97A3 C253 +C254 C254 ED97A6 C254 +C255 C255 ED97A7 C255 +C256 C256 ED97A9 C256 +C257 C257 ED97AA C257 +C258 C258 ED97AB C258 +C259 C259 ED97AD C259 +C25A C25A ED97AE C25A +C261 C261 ED97AF C261 +C262 C262 ED97B0 C262 +C263 C263 ED97B1 C263 +C264 C264 ED97B2 C264 +C265 C265 ED97B3 C265 +C266 C266 ED97B6 C266 +C267 C267 ED97B8 C267 +C268 C268 ED97BA C268 +C269 C269 ED97BB C269 +C26A C26A ED97BC C26A +C26B C26B ED97BD C26B +C26C C26C ED97BE C26C +C26D C26D ED97BF C26D +C26E C26E ED9882 C26E +C26F C26F ED9883 C26F +C270 C270 ED9885 C270 +C271 C271 ED9886 C271 +C272 C272 ED9887 C272 +C273 C273 ED9889 C273 +C274 C274 ED988A C274 +C275 C275 ED988B C275 +C276 C276 ED988C C276 +C277 C277 ED988D C277 +C278 C278 ED988E C278 +C279 C279 ED988F C279 +C27A C27A ED9892 C27A +C281 C281 ED9896 C281 +C282 C282 ED9897 C282 +C283 C283 ED9898 C283 +C284 C284 ED9899 C284 +C285 C285 ED989A C285 +C286 C286 ED989B C286 +C287 C287 ED989D C287 +C288 C288 ED989E C288 +C289 C289 ED989F C289 +C28A C28A ED98A1 C28A +C28B C28B ED98A2 C28B +C28C C28C ED98A3 C28C +C28D C28D ED98A5 C28D +C28E C28E ED98A6 C28E +C28F C28F ED98A7 C28F +C290 C290 ED98A8 C290 +C291 C291 ED98A9 C291 +C292 C292 ED98AA C292 +C293 C293 ED98AB C293 +C294 C294 ED98AC C294 +C295 C295 ED98AE C295 +C296 C296 ED98AF C296 +C297 C297 ED98B0 C297 +C298 C298 ED98B1 C298 +C299 C299 ED98B2 C299 +C29A C29A ED98B3 C29A +C29B C29B ED98B4 C29B +C29C C29C ED98B5 C29C +C29D C29D ED98B6 C29D +C29E C29E ED98B7 C29E +C29F C29F ED98BA C29F +C2A0 C2A0 ED98BB C2A0 +C2A1 C2A1 ECA795 C2A1 +C2A2 C2A2 ECA796 C2A2 +C2A3 C2A3 ECA799 C2A3 +C2A4 C2A4 ECA79A C2A4 +C2A5 C2A5 ECA79C C2A5 +C2A6 C2A6 ECA79D C2A6 +C2A7 C2A7 ECA7A0 C2A7 +C2A8 C2A8 ECA7A2 C2A8 +C2A9 C2A9 ECA7A4 C2A9 +C2AA C2AA ECA7A7 C2AA +C2AB C2AB ECA7AC C2AB +C2AC C2AC ECA7AD C2AC +C2AD C2AD ECA7AF C2AD +C2AE C2AE ECA7B0 C2AE +C2AF C2AF ECA7B1 C2AF +C2B0 C2B0 ECA7B8 C2B0 +C2B1 C2B1 ECA7B9 C2B1 +C2B2 C2B2 ECA7BC C2B2 +C2B3 C2B3 ECA880 C2B3 +C2B4 C2B4 ECA888 C2B4 +C2B5 C2B5 ECA889 C2B5 +C2B6 C2B6 ECA88B C2B6 +C2B7 C2B7 ECA88C C2B7 +C2B8 C2B8 ECA88D C2B8 +C2B9 C2B9 ECA894 C2B9 +C2BA C2BA ECA898 C2BA +C2BB C2BB ECA8A9 C2BB +C2BC C2BC ECA98C C2BC +C2BD C2BD ECA98D C2BD +C2BE C2BE ECA990 C2BE +C2BF C2BF ECA994 C2BF +C2C0 C2C0 ECA99C C2C0 +C2C1 C2C1 ECA99D C2C1 +C2C2 C2C2 ECA99F C2C2 +C2C3 C2C3 ECA9A0 C2C3 +C2C4 C2C4 ECA9A1 C2C4 +C2C5 C2C5 ECA9A8 C2C5 +C2C6 C2C6 ECA9BD C2C6 +C2C7 C2C7 ECAA84 C2C7 +C2C8 C2C8 ECAA98 C2C8 +C2C9 C2C9 ECAABC C2C9 +C2CA C2CA ECAABD C2CA +C2CB C2CB ECAB80 C2CB +C2CC C2CC ECAB84 C2CC +C2CD C2CD ECAB8C C2CD +C2CE C2CE ECAB8D C2CE +C2CF C2CF ECAB8F C2CF +C2D0 C2D0 ECAB91 C2D0 +C2D1 C2D1 ECAB93 C2D1 +C2D2 C2D2 ECAB98 C2D2 +C2D3 C2D3 ECAB99 C2D3 +C2D4 C2D4 ECABA0 C2D4 +C2D5 C2D5 ECABAC C2D5 +C2D6 C2D6 ECABB4 C2D6 +C2D7 C2D7 ECAC88 C2D7 +C2D8 C2D8 ECAC90 C2D8 +C2D9 C2D9 ECAC94 C2D9 +C2DA C2DA ECAC98 C2DA +C2DB C2DB ECACA0 C2DB +C2DC C2DC ECACA1 C2DC +C2DD C2DD ECAD81 C2DD +C2DE C2DE ECAD88 C2DE +C2DF C2DF ECAD89 C2DF +C2E0 C2E0 ECAD8C C2E0 +C2E1 C2E1 ECAD90 C2E1 +C2E2 C2E2 ECAD98 C2E2 +C2E3 C2E3 ECAD99 C2E3 +C2E4 C2E4 ECAD9D C2E4 +C2E5 C2E5 ECADA4 C2E5 +C2E6 C2E6 ECADB8 C2E6 +C2E7 C2E7 ECADB9 C2E7 +C2E8 C2E8 ECAE9C C2E8 +C2E9 C2E9 ECAEB8 C2E9 +C2EA C2EA ECAF94 C2EA +C2EB C2EB ECAFA4 C2EB +C2EC C2EC ECAFA7 C2EC +C2ED C2ED ECAFA9 C2ED +C2EE C2EE ECB08C C2EE +C2EF C2EF ECB08D C2EF +C2F0 C2F0 ECB090 C2F0 +C2F1 C2F1 ECB094 C2F1 +C2F2 C2F2 ECB09C C2F2 +C2F3 C2F3 ECB09D C2F3 +C2F4 C2F4 ECB0A1 C2F4 +C2F5 C2F5 ECB0A2 C2F5 +C2F6 C2F6 ECB0A7 C2F6 +C2F7 C2F7 ECB0A8 C2F7 +C2F8 C2F8 ECB0A9 C2F8 +C2F9 C2F9 ECB0AC C2F9 +C2FA C2FA ECB0AE C2FA +C2FB C2FB ECB0B0 C2FB +C2FC C2FC ECB0B8 C2FC +C2FD C2FD ECB0B9 C2FD +C2FE C2FE ECB0BB C2FE +C341 C341 ED98BD C341 +C342 C342 ED98BE C342 +C343 C343 ED98BF C343 +C344 C344 ED9981 C344 +C345 C345 ED9982 C345 +C346 C346 ED9983 C346 +C347 C347 ED9984 C347 +C348 C348 ED9986 C348 +C349 C349 ED9987 C349 +C34A C34A ED998A C34A +C34B C34B ED998C C34B +C34C C34C ED998E C34C +C34D C34D ED998F C34D +C34E C34E ED9990 C34E +C34F C34F ED9992 C34F +C350 C350 ED9993 C350 +C351 C351 ED9996 C351 +C352 C352 ED9997 C352 +C353 C353 ED9999 C353 +C354 C354 ED999A C354 +C355 C355 ED999B C355 +C356 C356 ED999D C356 +C357 C357 ED999E C357 +C358 C358 ED999F C358 +C359 C359 ED99A0 C359 +C35A C35A ED99A1 C35A +C361 C361 ED99A2 C361 +C362 C362 ED99A3 C362 +C363 C363 ED99A4 C363 +C364 C364 ED99A5 C364 +C365 C365 ED99A6 C365 +C366 C366 ED99A8 C366 +C367 C367 ED99AA C367 +C368 C368 ED99AB C368 +C369 C369 ED99AC C369 +C36A C36A ED99AD C36A +C36B C36B ED99AE C36B +C36C C36C ED99AF C36C +C36D C36D ED99B2 C36D +C36E C36E ED99B3 C36E +C36F C36F ED99B5 C36F +C370 C370 ED99B6 C370 +C371 C371 ED99B7 C371 +C372 C372 ED99B8 C372 +C373 C373 ED99B9 C373 +C374 C374 ED99BA C374 +C375 C375 ED99BB C375 +C376 C376 ED99BC C376 +C377 C377 ED99BD C377 +C378 C378 ED99BE C378 +C379 C379 ED99BF C379 +C37A C37A ED9A80 C37A +C381 C381 ED9A81 C381 +C382 C382 ED9A82 C382 +C383 C383 ED9A84 C383 +C384 C384 ED9A86 C384 +C385 C385 ED9A87 C385 +C386 C386 ED9A88 C386 +C387 C387 ED9A89 C387 +C388 C388 ED9A8A C388 +C389 C389 ED9A8B C389 +C38A C38A ED9A8E C38A +C38B C38B ED9A8F C38B +C38C C38C ED9A91 C38C +C38D C38D ED9A92 C38D +C38E C38E ED9A93 C38E +C38F C38F ED9A95 C38F +C390 C390 ED9A96 C390 +C391 C391 ED9A97 C391 +C392 C392 ED9A98 C392 +C393 C393 ED9A99 C393 +C394 C394 ED9A9A C394 +C395 C395 ED9A9B C395 +C396 C396 ED9A9C C396 +C397 C397 ED9A9E C397 +C398 C398 ED9AA0 C398 +C399 C399 ED9AA2 C399 +C39A C39A ED9AA3 C39A +C39B C39B ED9AA4 C39B +C39C C39C ED9AA5 C39C +C39D C39D ED9AA6 C39D +C39E C39E ED9AA7 C39E +C39F C39F ED9AA9 C39F +C3A0 C3A0 ED9AAA C3A0 +C3A1 C3A1 ECB0BC C3A1 +C3A2 C3A2 ECB0BD C3A2 +C3A3 C3A3 ECB0BE C3A3 +C3A4 C3A4 ECB184 C3A4 +C3A5 C3A5 ECB185 C3A5 +C3A6 C3A6 ECB188 C3A6 +C3A7 C3A7 ECB18C C3A7 +C3A8 C3A8 ECB194 C3A8 +C3A9 C3A9 ECB195 C3A9 +C3AA C3AA ECB197 C3AA +C3AB C3AB ECB198 C3AB +C3AC C3AC ECB199 C3AC +C3AD C3AD ECB1A0 C3AD +C3AE C3AE ECB1A4 C3AE +C3AF C3AF ECB1A6 C3AF +C3B0 C3B0 ECB1A8 C3B0 +C3B1 C3B1 ECB1B0 C3B1 +C3B2 C3B2 ECB1B5 C3B2 +C3B3 C3B3 ECB298 C3B3 +C3B4 C3B4 ECB299 C3B4 +C3B5 C3B5 ECB29C C3B5 +C3B6 C3B6 ECB2A0 C3B6 +C3B7 C3B7 ECB2A8 C3B7 +C3B8 C3B8 ECB2A9 C3B8 +C3B9 C3B9 ECB2AB C3B9 +C3BA C3BA ECB2AC C3BA +C3BB C3BB ECB2AD C3BB +C3BC C3BC ECB2B4 C3BC +C3BD C3BD ECB2B5 C3BD +C3BE C3BE ECB2B8 C3BE +C3BF C3BF ECB2BC C3BF +C3C0 C3C0 ECB384 C3C0 +C3C1 C3C1 ECB385 C3C1 +C3C2 C3C2 ECB387 C3C2 +C3C3 C3C3 ECB389 C3C3 +C3C4 C3C4 ECB390 C3C4 +C3C5 C3C5 ECB394 C3C5 +C3C6 C3C6 ECB3A4 C3C6 +C3C7 C3C7 ECB3AC C3C7 +C3C8 C3C8 ECB3B0 C3C8 +C3C9 C3C9 ECB481 C3C9 +C3CA C3CA ECB488 C3CA +C3CB C3CB ECB489 C3CB +C3CC C3CC ECB48C C3CC +C3CD C3CD ECB490 C3CD +C3CE C3CE ECB498 C3CE +C3CF C3CF ECB499 C3CF +C3D0 C3D0 ECB49B C3D0 +C3D1 C3D1 ECB49D C3D1 +C3D2 C3D2 ECB4A4 C3D2 +C3D3 C3D3 ECB4A8 C3D3 +C3D4 C3D4 ECB4AC C3D4 +C3D5 C3D5 ECB4B9 C3D5 +C3D6 C3D6 ECB59C C3D6 +C3D7 C3D7 ECB5A0 C3D7 +C3D8 C3D8 ECB5A4 C3D8 +C3D9 C3D9 ECB5AC C3D9 +C3DA C3DA ECB5AD C3DA +C3DB C3DB ECB5AF C3DB +C3DC C3DC ECB5B1 C3DC +C3DD C3DD ECB5B8 C3DD +C3DE C3DE ECB688 C3DE +C3DF C3DF ECB694 C3DF +C3E0 C3E0 ECB695 C3E0 +C3E1 C3E1 ECB698 C3E1 +C3E2 C3E2 ECB69C C3E2 +C3E3 C3E3 ECB6A4 C3E3 +C3E4 C3E4 ECB6A5 C3E4 +C3E5 C3E5 ECB6A7 C3E5 +C3E6 C3E6 ECB6A9 C3E6 +C3E7 C3E7 ECB6B0 C3E7 +C3E8 C3E8 ECB784 C3E8 +C3E9 C3E9 ECB78C C3E9 +C3EA C3EA ECB790 C3EA +C3EB C3EB ECB7A8 C3EB +C3EC C3EC ECB7AC C3EC +C3ED C3ED ECB7B0 C3ED +C3EE C3EE ECB7B8 C3EE +C3EF C3EF ECB7B9 C3EF +C3F0 C3F0 ECB7BB C3F0 +C3F1 C3F1 ECB7BD C3F1 +C3F2 C3F2 ECB884 C3F2 +C3F3 C3F3 ECB888 C3F3 +C3F4 C3F4 ECB88C C3F4 +C3F5 C3F5 ECB894 C3F5 +C3F6 C3F6 ECB899 C3F6 +C3F7 C3F7 ECB8A0 C3F7 +C3F8 C3F8 ECB8A1 C3F8 +C3F9 C3F9 ECB8A4 C3F9 +C3FA C3FA ECB8A8 C3FA +C3FB C3FB ECB8B0 C3FB +C3FC C3FC ECB8B1 C3FC +C3FD C3FD ECB8B3 C3FD +C3FE C3FE ECB8B5 C3FE +C441 C441 ED9AAB C441 +C442 C442 ED9AAD C442 +C443 C443 ED9AAE C443 +C444 C444 ED9AAF C444 +C445 C445 ED9AB1 C445 +C446 C446 ED9AB2 C446 +C447 C447 ED9AB3 C447 +C448 C448 ED9AB4 C448 +C449 C449 ED9AB5 C449 +C44A C44A ED9AB6 C44A +C44B C44B ED9AB7 C44B +C44C C44C ED9AB8 C44C +C44D C44D ED9ABA C44D +C44E C44E ED9ABC C44E +C44F C44F ED9ABD C44F +C450 C450 ED9ABE C450 +C451 C451 ED9ABF C451 +C452 C452 ED9B80 C452 +C453 C453 ED9B81 C453 +C454 C454 ED9B82 C454 +C455 C455 ED9B83 C455 +C456 C456 ED9B86 C456 +C457 C457 ED9B87 C457 +C458 C458 ED9B89 C458 +C459 C459 ED9B8A C459 +C45A C45A ED9B8B C45A +C461 C461 ED9B8D C461 +C462 C462 ED9B8E C462 +C463 C463 ED9B8F C463 +C464 C464 ED9B90 C464 +C465 C465 ED9B92 C465 +C466 C466 ED9B93 C466 +C467 C467 ED9B95 C467 +C468 C468 ED9B96 C468 +C469 C469 ED9B98 C469 +C46A C46A ED9B9A C46A +C46B C46B ED9B9B C46B +C46C C46C ED9B9C C46C +C46D C46D ED9B9D C46D +C46E C46E ED9B9E C46E +C46F C46F ED9B9F C46F +C470 C470 ED9BA1 C470 +C471 C471 ED9BA2 C471 +C472 C472 ED9BA3 C472 +C473 C473 ED9BA5 C473 +C474 C474 ED9BA6 C474 +C475 C475 ED9BA7 C475 +C476 C476 ED9BA9 C476 +C477 C477 ED9BAA C477 +C478 C478 ED9BAB C478 +C479 C479 ED9BAC C479 +C47A C47A ED9BAD C47A +C481 C481 ED9BAE C481 +C482 C482 ED9BAF C482 +C483 C483 ED9BB1 C483 +C484 C484 ED9BB2 C484 +C485 C485 ED9BB3 C485 +C486 C486 ED9BB4 C486 +C487 C487 ED9BB6 C487 +C488 C488 ED9BB7 C488 +C489 C489 ED9BB8 C489 +C48A C48A ED9BB9 C48A +C48B C48B ED9BBA C48B +C48C C48C ED9BBB C48C +C48D C48D ED9BBE C48D +C48E C48E ED9BBF C48E +C48F C48F ED9C81 C48F +C490 C490 ED9C82 C490 +C491 C491 ED9C83 C491 +C492 C492 ED9C85 C492 +C493 C493 ED9C86 C493 +C494 C494 ED9C87 C494 +C495 C495 ED9C88 C495 +C496 C496 ED9C89 C496 +C497 C497 ED9C8A C497 +C498 C498 ED9C8B C498 +C499 C499 ED9C8C C499 +C49A C49A ED9C8D C49A +C49B C49B ED9C8E C49B +C49C C49C ED9C8F C49C +C49D C49D ED9C90 C49D +C49E C49E ED9C92 C49E +C49F C49F ED9C93 C49F +C4A0 C4A0 ED9C94 C4A0 +C4A1 C4A1 ECB998 C4A1 +C4A2 C4A2 ECB999 C4A2 +C4A3 C4A3 ECB99C C4A3 +C4A4 C4A4 ECB99F C4A4 +C4A5 C4A5 ECB9A0 C4A5 +C4A6 C4A6 ECB9A1 C4A6 +C4A7 C4A7 ECB9A8 C4A7 +C4A8 C4A8 ECB9A9 C4A8 +C4A9 C4A9 ECB9AB C4A9 +C4AA C4AA ECB9AD C4AA +C4AB C4AB ECB9B4 C4AB +C4AC C4AC ECB9B5 C4AC +C4AD C4AD ECB9B8 C4AD +C4AE C4AE ECB9BC C4AE +C4AF C4AF ECBA84 C4AF +C4B0 C4B0 ECBA85 C4B0 +C4B1 C4B1 ECBA87 C4B1 +C4B2 C4B2 ECBA89 C4B2 +C4B3 C4B3 ECBA90 C4B3 +C4B4 C4B4 ECBA91 C4B4 +C4B5 C4B5 ECBA94 C4B5 +C4B6 C4B6 ECBA98 C4B6 +C4B7 C4B7 ECBAA0 C4B7 +C4B8 C4B8 ECBAA1 C4B8 +C4B9 C4B9 ECBAA3 C4B9 +C4BA C4BA ECBAA4 C4BA +C4BB C4BB ECBAA5 C4BB +C4BC C4BC ECBAAC C4BC +C4BD C4BD ECBAAD C4BD +C4BE C4BE ECBB81 C4BE +C4BF C4BF ECBBA4 C4BF +C4C0 C4C0 ECBBA5 C4C0 +C4C1 C4C1 ECBBA8 C4C1 +C4C2 C4C2 ECBBAB C4C2 +C4C3 C4C3 ECBBAC C4C3 +C4C4 C4C4 ECBBB4 C4C4 +C4C5 C4C5 ECBBB5 C4C5 +C4C6 C4C6 ECBBB7 C4C6 +C4C7 C4C7 ECBBB8 C4C7 +C4C8 C4C8 ECBBB9 C4C8 +C4C9 C4C9 ECBC80 C4C9 +C4CA C4CA ECBC81 C4CA +C4CB C4CB ECBC84 C4CB +C4CC C4CC ECBC88 C4CC +C4CD C4CD ECBC90 C4CD +C4CE C4CE ECBC91 C4CE +C4CF C4CF ECBC93 C4CF +C4D0 C4D0 ECBC95 C4D0 +C4D1 C4D1 ECBC9C C4D1 +C4D2 C4D2 ECBCA0 C4D2 +C4D3 C4D3 ECBCA4 C4D3 +C4D4 C4D4 ECBCAC C4D4 +C4D5 C4D5 ECBCAD C4D5 +C4D6 C4D6 ECBCAF C4D6 +C4D7 C4D7 ECBCB0 C4D7 +C4D8 C4D8 ECBCB1 C4D8 +C4D9 C4D9 ECBCB8 C4D9 +C4DA C4DA ECBD94 C4DA +C4DB C4DB ECBD95 C4DB +C4DC C4DC ECBD98 C4DC +C4DD C4DD ECBD9C C4DD +C4DE C4DE ECBDA4 C4DE +C4DF C4DF ECBDA5 C4DF +C4E0 C4E0 ECBDA7 C4E0 +C4E1 C4E1 ECBDA9 C4E1 +C4E2 C4E2 ECBDB0 C4E2 +C4E3 C4E3 ECBDB1 C4E3 +C4E4 C4E4 ECBDB4 C4E4 +C4E5 C4E5 ECBDB8 C4E5 +C4E6 C4E6 ECBE80 C4E6 +C4E7 C4E7 ECBE85 C4E7 +C4E8 C4E8 ECBE8C C4E8 +C4E9 C4E9 ECBEA1 C4E9 +C4EA C4EA ECBEA8 C4EA +C4EB C4EB ECBEB0 C4EB +C4EC C4EC ECBF84 C4EC +C4ED C4ED ECBFA0 C4ED +C4EE C4EE ECBFA1 C4EE +C4EF C4EF ECBFA4 C4EF +C4F0 C4F0 ECBFA8 C4F0 +C4F1 C4F1 ECBFB0 C4F1 +C4F2 C4F2 ECBFB1 C4F2 +C4F3 C4F3 ECBFB3 C4F3 +C4F4 C4F4 ECBFB5 C4F4 +C4F5 C4F5 ECBFBC C4F5 +C4F6 C4F6 ED8080 C4F6 +C4F7 C4F7 ED8084 C4F7 +C4F8 C4F8 ED8091 C4F8 +C4F9 C4F9 ED8098 C4F9 +C4FA C4FA ED80AD C4FA +C4FB C4FB ED80B4 C4FB +C4FC C4FC ED80B5 C4FC +C4FD C4FD ED80B8 C4FD +C4FE C4FE ED80BC C4FE +C541 C541 ED9C95 C541 +C542 C542 ED9C96 C542 +C543 C543 ED9C97 C543 +C544 C544 ED9C9A C544 +C545 C545 ED9C9B C545 +C546 C546 ED9C9D C546 +C547 C547 ED9C9E C547 +C548 C548 ED9C9F C548 +C549 C549 ED9CA1 C549 +C54A C54A ED9CA2 C54A +C54B C54B ED9CA3 C54B +C54C C54C ED9CA4 C54C +C54D C54D ED9CA5 C54D +C54E C54E ED9CA6 C54E +C54F C54F ED9CA7 C54F +C550 C550 ED9CAA C550 +C551 C551 ED9CAC C551 +C552 C552 ED9CAE C552 +C553 C553 ED9CAF C553 +C554 C554 ED9CB0 C554 +C555 C555 ED9CB1 C555 +C556 C556 ED9CB2 C556 +C557 C557 ED9CB3 C557 +C558 C558 ED9CB6 C558 +C559 C559 ED9CB7 C559 +C55A C55A ED9CB9 C55A +C561 C561 ED9CBA C561 +C562 C562 ED9CBB C562 +C563 C563 ED9CBD C563 +C564 C564 ED9CBE C564 +C565 C565 ED9CBF C565 +C566 C566 ED9D80 C566 +C567 C567 ED9D81 C567 +C568 C568 ED9D82 C568 +C569 C569 ED9D83 C569 +C56A C56A ED9D85 C56A +C56B C56B ED9D86 C56B +C56C C56C ED9D88 C56C +C56D C56D ED9D8A C56D +C56E C56E ED9D8B C56E +C56F C56F ED9D8C C56F +C570 C570 ED9D8D C570 +C571 C571 ED9D8E C571 +C572 C572 ED9D8F C572 +C573 C573 ED9D92 C573 +C574 C574 ED9D93 C574 +C575 C575 ED9D95 C575 +C576 C576 ED9D9A C576 +C577 C577 ED9D9B C577 +C578 C578 ED9D9C C578 +C579 C579 ED9D9D C579 +C57A C57A ED9D9E C57A +C581 C581 ED9D9F C581 +C582 C582 ED9DA2 C582 +C583 C583 ED9DA4 C583 +C584 C584 ED9DA6 C584 +C585 C585 ED9DA7 C585 +C586 C586 ED9DA8 C586 +C587 C587 ED9DAA C587 +C588 C588 ED9DAB C588 +C589 C589 ED9DAD C589 +C58A C58A ED9DAE C58A +C58B C58B ED9DAF C58B +C58C C58C ED9DB1 C58C +C58D C58D ED9DB2 C58D +C58E C58E ED9DB3 C58E +C58F C58F ED9DB5 C58F +C590 C590 ED9DB6 C590 +C591 C591 ED9DB7 C591 +C592 C592 ED9DB8 C592 +C593 C593 ED9DB9 C593 +C594 C594 ED9DBA C594 +C595 C595 ED9DBB C595 +C596 C596 ED9DBE C596 +C597 C597 ED9DBF C597 +C598 C598 ED9E80 C598 +C599 C599 ED9E82 C599 +C59A C59A ED9E83 C59A +C59B C59B ED9E84 C59B +C59C C59C ED9E85 C59C +C59D C59D ED9E86 C59D +C59E C59E ED9E87 C59E +C59F C59F ED9E8A C59F +C5A0 C5A0 ED9E8B C5A0 +C5A1 C5A1 ED8184 C5A1 +C5A2 C5A2 ED8185 C5A2 +C5A3 C5A3 ED8187 C5A3 +C5A4 C5A4 ED8189 C5A4 +C5A5 C5A5 ED8190 C5A5 +C5A6 C5A6 ED8194 C5A6 +C5A7 C5A7 ED8198 C5A7 +C5A8 C5A8 ED81A0 C5A8 +C5A9 C5A9 ED81AC C5A9 +C5AA C5AA ED81AD C5AA +C5AB C5AB ED81B0 C5AB +C5AC C5AC ED81B4 C5AC +C5AD C5AD ED81BC C5AD +C5AE C5AE ED81BD C5AE +C5AF C5AF ED8281 C5AF +C5B0 C5B0 ED82A4 C5B0 +C5B1 C5B1 ED82A5 C5B1 +C5B2 C5B2 ED82A8 C5B2 +C5B3 C5B3 ED82AC C5B3 +C5B4 C5B4 ED82B4 C5B4 +C5B5 C5B5 ED82B5 C5B5 +C5B6 C5B6 ED82B7 C5B6 +C5B7 C5B7 ED82B9 C5B7 +C5B8 C5B8 ED8380 C5B8 +C5B9 C5B9 ED8381 C5B9 +C5BA C5BA ED8384 C5BA +C5BB C5BB ED8388 C5BB +C5BC C5BC ED8389 C5BC +C5BD C5BD ED8390 C5BD +C5BE C5BE ED8391 C5BE +C5BF C5BF ED8393 C5BF +C5C0 C5C0 ED8394 C5C0 +C5C1 C5C1 ED8395 C5C1 +C5C2 C5C2 ED839C C5C2 +C5C3 C5C3 ED839D C5C3 +C5C4 C5C4 ED83A0 C5C4 +C5C5 C5C5 ED83A4 C5C5 +C5C6 C5C6 ED83AC C5C6 +C5C7 C5C7 ED83AD C5C7 +C5C8 C5C8 ED83AF C5C8 +C5C9 C5C9 ED83B0 C5C9 +C5CA C5CA ED83B1 C5CA +C5CB C5CB ED83B8 C5CB +C5CC C5CC ED848D C5CC +C5CD C5CD ED84B0 C5CD +C5CE C5CE ED84B1 C5CE +C5CF C5CF ED84B4 C5CF +C5D0 C5D0 ED84B8 C5D0 +C5D1 C5D1 ED84BA C5D1 +C5D2 C5D2 ED8580 C5D2 +C5D3 C5D3 ED8581 C5D3 +C5D4 C5D4 ED8583 C5D4 +C5D5 C5D5 ED8584 C5D5 +C5D6 C5D6 ED8585 C5D6 +C5D7 C5D7 ED858C C5D7 +C5D8 C5D8 ED858D C5D8 +C5D9 C5D9 ED8590 C5D9 +C5DA C5DA ED8594 C5DA +C5DB C5DB ED859C C5DB +C5DC C5DC ED859D C5DC +C5DD C5DD ED859F C5DD +C5DE C5DE ED85A1 C5DE +C5DF C5DF ED85A8 C5DF +C5E0 C5E0 ED85AC C5E0 +C5E1 C5E1 ED85BC C5E1 +C5E2 C5E2 ED8684 C5E2 +C5E3 C5E3 ED8688 C5E3 +C5E4 C5E4 ED86A0 C5E4 +C5E5 C5E5 ED86A1 C5E5 +C5E6 C5E6 ED86A4 C5E6 +C5E7 C5E7 ED86A8 C5E7 +C5E8 C5E8 ED86B0 C5E8 +C5E9 C5E9 ED86B1 C5E9 +C5EA C5EA ED86B3 C5EA +C5EB C5EB ED86B5 C5EB +C5EC C5EC ED86BA C5EC +C5ED C5ED ED86BC C5ED +C5EE C5EE ED8780 C5EE +C5EF C5EF ED8798 C5EF +C5F0 C5F0 ED87B4 C5F0 +C5F1 C5F1 ED87B8 C5F1 +C5F2 C5F2 ED8887 C5F2 +C5F3 C5F3 ED8889 C5F3 +C5F4 C5F4 ED8890 C5F4 +C5F5 C5F5 ED88AC C5F5 +C5F6 C5F6 ED88AD C5F6 +C5F7 C5F7 ED88B0 C5F7 +C5F8 C5F8 ED88B4 C5F8 +C5F9 C5F9 ED88BC C5F9 +C5FA C5FA ED88BD C5FA +C5FB C5FB ED88BF C5FB +C5FC C5FC ED8981 C5FC +C5FD C5FD ED8988 C5FD +C5FE C5FE ED899C C5FE +C641 C641 ED9E8D C641 +C642 C642 ED9E8E C642 +C643 C643 ED9E8F C643 +C644 C644 ED9E91 C644 +C645 C645 ED9E92 C645 +C646 C646 ED9E93 C646 +C647 C647 ED9E94 C647 +C648 C648 ED9E95 C648 +C649 C649 ED9E96 C649 +C64A C64A ED9E97 C64A +C64B C64B ED9E9A C64B +C64C C64C ED9E9C C64C +C64D C64D ED9E9E C64D +C64E C64E ED9E9F C64E +C64F C64F ED9EA0 C64F +C650 C650 ED9EA1 C650 +C651 C651 ED9EA2 C651 +C652 C652 ED9EA3 C652 +C6A1 C6A1 ED89A4 C6A1 +C6A2 C6A2 ED8A80 C6A2 +C6A3 C6A3 ED8A81 C6A3 +C6A4 C6A4 ED8A84 C6A4 +C6A5 C6A5 ED8A88 C6A5 +C6A6 C6A6 ED8A90 C6A6 +C6A7 C6A7 ED8A91 C6A7 +C6A8 C6A8 ED8A95 C6A8 +C6A9 C6A9 ED8A9C C6A9 +C6AA C6AA ED8AA0 C6AA +C6AB C6AB ED8AA4 C6AB +C6AC C6AC ED8AAC C6AC +C6AD C6AD ED8AB1 C6AD +C6AE C6AE ED8AB8 C6AE +C6AF C6AF ED8AB9 C6AF +C6B0 C6B0 ED8ABC C6B0 +C6B1 C6B1 ED8ABF C6B1 +C6B2 C6B2 ED8B80 C6B2 +C6B3 C6B3 ED8B82 C6B3 +C6B4 C6B4 ED8B88 C6B4 +C6B5 C6B5 ED8B89 C6B5 +C6B6 C6B6 ED8B8B C6B6 +C6B7 C6B7 ED8B94 C6B7 +C6B8 C6B8 ED8B98 C6B8 +C6B9 C6B9 ED8B9C C6B9 +C6BA C6BA ED8BA4 C6BA +C6BB C6BB ED8BA5 C6BB +C6BC C6BC ED8BB0 C6BC +C6BD C6BD ED8BB1 C6BD +C6BE C6BE ED8BB4 C6BE +C6BF C6BF ED8BB8 C6BF +C6C0 C6C0 ED8C80 C6C0 +C6C1 C6C1 ED8C81 C6C1 +C6C2 C6C2 ED8C83 C6C2 +C6C3 C6C3 ED8C85 C6C3 +C6C4 C6C4 ED8C8C C6C4 +C6C5 C6C5 ED8C8D C6C5 +C6C6 C6C6 ED8C8E C6C6 +C6C7 C6C7 ED8C90 C6C7 +C6C8 C6C8 ED8C94 C6C8 +C6C9 C6C9 ED8C96 C6C9 +C6CA C6CA ED8C9C C6CA +C6CB C6CB ED8C9D C6CB +C6CC C6CC ED8C9F C6CC +C6CD C6CD ED8CA0 C6CD +C6CE C6CE ED8CA1 C6CE +C6CF C6CF ED8CA5 C6CF +C6D0 C6D0 ED8CA8 C6D0 +C6D1 C6D1 ED8CA9 C6D1 +C6D2 C6D2 ED8CAC C6D2 +C6D3 C6D3 ED8CB0 C6D3 +C6D4 C6D4 ED8CB8 C6D4 +C6D5 C6D5 ED8CB9 C6D5 +C6D6 C6D6 ED8CBB C6D6 +C6D7 C6D7 ED8CBC C6D7 +C6D8 C6D8 ED8CBD C6D8 +C6D9 C6D9 ED8D84 C6D9 +C6DA C6DA ED8D85 C6DA +C6DB C6DB ED8DBC C6DB +C6DC C6DC ED8DBD C6DC +C6DD C6DD ED8E80 C6DD +C6DE C6DE ED8E84 C6DE +C6DF C6DF ED8E8C C6DF +C6E0 C6E0 ED8E8D C6E0 +C6E1 C6E1 ED8E8F C6E1 +C6E2 C6E2 ED8E90 C6E2 +C6E3 C6E3 ED8E91 C6E3 +C6E4 C6E4 ED8E98 C6E4 +C6E5 C6E5 ED8E99 C6E5 +C6E6 C6E6 ED8E9C C6E6 +C6E7 C6E7 ED8EA0 C6E7 +C6E8 C6E8 ED8EA8 C6E8 +C6E9 C6E9 ED8EA9 C6E9 +C6EA C6EA ED8EAB C6EA +C6EB C6EB ED8EAD C6EB +C6EC C6EC ED8EB4 C6EC +C6ED C6ED ED8EB8 C6ED +C6EE C6EE ED8EBC C6EE +C6EF C6EF ED8F84 C6EF +C6F0 C6F0 ED8F85 C6F0 +C6F1 C6F1 ED8F88 C6F1 +C6F2 C6F2 ED8F89 C6F2 +C6F3 C6F3 ED8F90 C6F3 +C6F4 C6F4 ED8F98 C6F4 +C6F5 C6F5 ED8FA1 C6F5 +C6F6 C6F6 ED8FA3 C6F6 +C6F7 C6F7 ED8FAC C6F7 +C6F8 C6F8 ED8FAD C6F8 +C6F9 C6F9 ED8FB0 C6F9 +C6FA C6FA ED8FB4 C6FA +C6FB C6FB ED8FBC C6FB +C6FC C6FC ED8FBD C6FC +C6FD C6FD ED8FBF C6FD +C6FE C6FE ED9081 C6FE +C7A1 C7A1 ED9088 C7A1 +C7A2 C7A2 ED909D C7A2 +C7A3 C7A3 ED9180 C7A3 +C7A4 C7A4 ED9184 C7A4 +C7A5 C7A5 ED919C C7A5 +C7A6 C7A6 ED91A0 C7A6 +C7A7 C7A7 ED91A4 C7A7 +C7A8 C7A8 ED91AD C7A8 +C7A9 C7A9 ED91AF C7A9 +C7AA C7AA ED91B8 C7AA +C7AB C7AB ED91B9 C7AB +C7AC C7AC ED91BC C7AC +C7AD C7AD ED91BF C7AD +C7AE C7AE ED9280 C7AE +C7AF C7AF ED9282 C7AF +C7B0 C7B0 ED9288 C7B0 +C7B1 C7B1 ED9289 C7B1 +C7B2 C7B2 ED928B C7B2 +C7B3 C7B3 ED928D C7B3 +C7B4 C7B4 ED9294 C7B4 +C7B5 C7B5 ED92A9 C7B5 +C7B6 C7B6 ED938C C7B6 +C7B7 C7B7 ED9390 C7B7 +C7B8 C7B8 ED9394 C7B8 +C7B9 C7B9 ED939C C7B9 +C7BA C7BA ED939F C7BA +C7BB C7BB ED93A8 C7BB +C7BC C7BC ED93AC C7BC +C7BD C7BD ED93B0 C7BD +C7BE C7BE ED93B8 C7BE +C7BF C7BF ED93BB C7BF +C7C0 C7C0 ED93BD C7C0 +C7C1 C7C1 ED9484 C7C1 +C7C2 C7C2 ED9488 C7C2 +C7C3 C7C3 ED948C C7C3 +C7C4 C7C4 ED9494 C7C4 +C7C5 C7C5 ED9495 C7C5 +C7C6 C7C6 ED9497 C7C6 +C7C7 C7C7 ED94BC C7C7 +C7C8 C7C8 ED94BD C7C8 +C7C9 C7C9 ED9580 C7C9 +C7CA C7CA ED9584 C7CA +C7CB C7CB ED958C C7CB +C7CC C7CC ED958D C7CC +C7CD C7CD ED958F C7CD +C7CE C7CE ED9591 C7CE +C7CF C7CF ED9598 C7CF +C7D0 C7D0 ED9599 C7D0 +C7D1 C7D1 ED959C C7D1 +C7D2 C7D2 ED95A0 C7D2 +C7D3 C7D3 ED95A5 C7D3 +C7D4 C7D4 ED95A8 C7D4 +C7D5 C7D5 ED95A9 C7D5 +C7D6 C7D6 ED95AB C7D6 +C7D7 C7D7 ED95AD C7D7 +C7D8 C7D8 ED95B4 C7D8 +C7D9 C7D9 ED95B5 C7D9 +C7DA C7DA ED95B8 C7DA +C7DB C7DB ED95BC C7DB +C7DC C7DC ED9684 C7DC +C7DD C7DD ED9685 C7DD +C7DE C7DE ED9687 C7DE +C7DF C7DF ED9688 C7DF +C7E0 C7E0 ED9689 C7E0 +C7E1 C7E1 ED9690 C7E1 +C7E2 C7E2 ED96A5 C7E2 +C7E3 C7E3 ED9788 C7E3 +C7E4 C7E4 ED9789 C7E4 +C7E5 C7E5 ED978C C7E5 +C7E6 C7E6 ED9790 C7E6 +C7E7 C7E7 ED9792 C7E7 +C7E8 C7E8 ED9798 C7E8 +C7E9 C7E9 ED9799 C7E9 +C7EA C7EA ED979B C7EA +C7EB C7EB ED979D C7EB +C7EC C7EC ED97A4 C7EC +C7ED C7ED ED97A5 C7ED +C7EE C7EE ED97A8 C7EE +C7EF C7EF ED97AC C7EF +C7F0 C7F0 ED97B4 C7F0 +C7F1 C7F1 ED97B5 C7F1 +C7F2 C7F2 ED97B7 C7F2 +C7F3 C7F3 ED97B9 C7F3 +C7F4 C7F4 ED9880 C7F4 +C7F5 C7F5 ED9881 C7F5 +C7F6 C7F6 ED9884 C7F6 +C7F7 C7F7 ED9888 C7F7 +C7F8 C7F8 ED9890 C7F8 +C7F9 C7F9 ED9891 C7F9 +C7FA C7FA ED9893 C7FA +C7FB C7FB ED9894 C7FB +C7FC C7FC ED9895 C7FC +C7FD C7FD ED989C C7FD +C7FE C7FE ED98A0 C7FE +C8A1 C8A1 ED98A4 C8A1 +C8A2 C8A2 ED98AD C8A2 +C8A3 C8A3 ED98B8 C8A3 +C8A4 C8A4 ED98B9 C8A4 +C8A5 C8A5 ED98BC C8A5 +C8A6 C8A6 ED9980 C8A6 +C8A7 C8A7 ED9985 C8A7 +C8A8 C8A8 ED9988 C8A8 +C8A9 C8A9 ED9989 C8A9 +C8AA C8AA ED998B C8AA +C8AB C8AB ED998D C8AB +C8AC C8AC ED9991 C8AC +C8AD C8AD ED9994 C8AD +C8AE C8AE ED9995 C8AE +C8AF C8AF ED9998 C8AF +C8B0 C8B0 ED999C C8B0 +C8B1 C8B1 ED99A7 C8B1 +C8B2 C8B2 ED99A9 C8B2 +C8B3 C8B3 ED99B0 C8B3 +C8B4 C8B4 ED99B1 C8B4 +C8B5 C8B5 ED99B4 C8B5 +C8B6 C8B6 ED9A83 C8B6 +C8B7 C8B7 ED9A85 C8B7 +C8B8 C8B8 ED9A8C C8B8 +C8B9 C8B9 ED9A8D C8B9 +C8BA C8BA ED9A90 C8BA +C8BB C8BB ED9A94 C8BB +C8BC C8BC ED9A9D C8BC +C8BD C8BD ED9A9F C8BD +C8BE C8BE ED9AA1 C8BE +C8BF C8BF ED9AA8 C8BF +C8C0 C8C0 ED9AAC C8C0 +C8C1 C8C1 ED9AB0 C8C1 +C8C2 C8C2 ED9AB9 C8C2 +C8C3 C8C3 ED9ABB C8C3 +C8C4 C8C4 ED9B84 C8C4 +C8C5 C8C5 ED9B85 C8C5 +C8C6 C8C6 ED9B88 C8C6 +C8C7 C8C7 ED9B8C C8C7 +C8C8 C8C8 ED9B91 C8C8 +C8C9 C8C9 ED9B94 C8C9 +C8CA C8CA ED9B97 C8CA +C8CB C8CB ED9B99 C8CB +C8CC C8CC ED9BA0 C8CC +C8CD C8CD ED9BA4 C8CD +C8CE C8CE ED9BA8 C8CE +C8CF C8CF ED9BB0 C8CF +C8D0 C8D0 ED9BB5 C8D0 +C8D1 C8D1 ED9BBC C8D1 +C8D2 C8D2 ED9BBD C8D2 +C8D3 C8D3 ED9C80 C8D3 +C8D4 C8D4 ED9C84 C8D4 +C8D5 C8D5 ED9C91 C8D5 +C8D6 C8D6 ED9C98 C8D6 +C8D7 C8D7 ED9C99 C8D7 +C8D8 C8D8 ED9C9C C8D8 +C8D9 C8D9 ED9CA0 C8D9 +C8DA C8DA ED9CA8 C8DA +C8DB C8DB ED9CA9 C8DB +C8DC C8DC ED9CAB C8DC +C8DD C8DD ED9CAD C8DD +C8DE C8DE ED9CB4 C8DE +C8DF C8DF ED9CB5 C8DF +C8E0 C8E0 ED9CB8 C8E0 +C8E1 C8E1 ED9CBC C8E1 +C8E2 C8E2 ED9D84 C8E2 +C8E3 C8E3 ED9D87 C8E3 +C8E4 C8E4 ED9D89 C8E4 +C8E5 C8E5 ED9D90 C8E5 +C8E6 C8E6 ED9D91 C8E6 +C8E7 C8E7 ED9D94 C8E7 +C8E8 C8E8 ED9D96 C8E8 +C8E9 C8E9 ED9D97 C8E9 +C8EA C8EA ED9D98 C8EA +C8EB C8EB ED9D99 C8EB +C8EC C8EC ED9DA0 C8EC +C8ED C8ED ED9DA1 C8ED +C8EE C8EE ED9DA3 C8EE +C8EF C8EF ED9DA5 C8EF +C8F0 C8F0 ED9DA9 C8F0 +C8F1 C8F1 ED9DAC C8F1 +C8F2 C8F2 ED9DB0 C8F2 +C8F3 C8F3 ED9DB4 C8F3 +C8F4 C8F4 ED9DBC C8F4 +C8F5 C8F5 ED9DBD C8F5 +C8F6 C8F6 ED9E81 C8F6 +C8F7 C8F7 ED9E88 C8F7 +C8F8 C8F8 ED9E89 C8F8 +C8F9 C8F9 ED9E8C C8F9 +C8FA C8FA ED9E90 C8FA +C8FB C8FB ED9E98 C8FB +C8FC C8FC ED9E99 C8FC +C8FD C8FD ED9E9B C8FD +C8FE C8FE ED9E9D C8FE +CAA1 CAA1 E4BCBD CAA1 +CAA2 CAA2 E4BDB3 CAA2 +CAA3 CAA3 E58187 CAA3 +CAA4 CAA4 E583B9 CAA4 +CAA5 CAA5 E58AA0 CAA5 +CAA6 CAA6 E58FAF CAA6 +CAA7 CAA7 E591B5 CAA7 +CAA8 CAA8 E593A5 CAA8 +CAA9 CAA9 E59889 CAA9 +CAAA CAAA E5AB81 CAAA +CAAB CAAB E5AEB6 CAAB +CAAC CAAC E69A87 CAAC +CAAD CAAD E69EB6 CAAD +CAAE CAAE E69EB7 CAAE +CAAF CAAF E69FAF CAAF +CAB0 CAB0 E6AD8C CAB0 +CAB1 CAB1 E78F82 CAB1 +CAB2 CAB2 E79782 CAB2 +CAB3 CAB3 E7A8BC CAB3 +CAB4 CAB4 E88B9B CAB4 +CAB5 CAB5 E88C84 CAB5 +CAB6 CAB6 E8A197 CAB6 +CAB7 CAB7 E8A288 CAB7 +CAB8 CAB8 E8A8B6 CAB8 +CAB9 CAB9 E8B388 CAB9 +CABA CABA E8B78F CABA +CABB CABB E8BBBB CABB +CABC CABC E8BFA6 CABC +CABD CABD E9A795 CABD +CABE CABE E588BB CABE +CABF CABF E58DB4 CABF +CAC0 CAC0 E59084 CAC0 +CAC1 CAC1 E681AA CAC1 +CAC2 CAC2 E685A4 CAC2 +CAC3 CAC3 E6AEBC CAC3 +CAC4 CAC4 E78F8F CAC4 +CAC5 CAC5 E8849A CAC5 +CAC6 CAC6 E8A6BA CAC6 +CAC7 CAC7 E8A792 CAC7 +CAC8 CAC8 E996A3 CAC8 +CAC9 CAC9 E4BE83 CAC9 +CACA CACA E5888A CACA +CACB CACB E5A2BE CACB +CACC CACC E5A5B8 CACC +CACD CACD E5A7A6 CACD +CACE CACE E5B9B2 CACE +CACF CACF E5B9B9 CACF +CAD0 CAD0 E68787 CAD0 +CAD1 CAD1 E68F80 CAD1 +CAD2 CAD2 E69D86 CAD2 +CAD3 CAD3 E69FAC CAD3 +CAD4 CAD4 E6A1BF CAD4 +CAD5 CAD5 E6BE97 CAD5 +CAD6 CAD6 E7998E CAD6 +CAD7 CAD7 E79C8B CAD7 +CAD8 CAD8 E7A3B5 CAD8 +CAD9 CAD9 E7A888 CAD9 +CADA CADA E7ABBF CADA +CADB CADB E7B0A1 CADB +CADC CADC E8829D CADC +CADD CADD E889AE CADD +CADE CADE E889B1 CADE +CADF CADF E8ABAB CADF +CAE0 CAE0 E99693 CAE0 +CAE1 CAE1 E4B9AB CAE1 +CAE2 CAE2 E5969D CAE2 +CAE3 CAE3 E69BB7 CAE3 +CAE4 CAE4 E6B8B4 CAE4 +CAE5 CAE5 E7A2A3 CAE5 +CAE6 CAE6 E7ABAD CAE6 +CAE7 CAE7 E8919B CAE7 +CAE8 CAE8 E8A490 CAE8 +CAE9 CAE9 E89D8E CAE9 +CAEA CAEA E99EA8 CAEA +CAEB CAEB E58B98 CAEB +CAEC CAEC E59D8E CAEC +CAED CAED E5A0AA CAED +CAEE CAEE E5B58C CAEE +CAEF CAEF E6849F CAEF +CAF0 CAF0 E686BE CAF0 +CAF1 CAF1 E688A1 CAF1 +CAF2 CAF2 E695A2 CAF2 +CAF3 CAF3 E69F91 CAF3 +CAF4 CAF4 E6A984 CAF4 +CAF5 CAF5 E6B89B CAF5 +CAF6 CAF6 E79498 CAF6 +CAF7 CAF7 E796B3 CAF7 +CAF8 CAF8 E79BA3 CAF8 +CAF9 CAF9 E79EB0 CAF9 +CAFA CAFA E7B4BA CAFA +CAFB CAFB E982AF CAFB +CAFC CAFC E99191 CAFC +CAFD CAFD E99192 CAFD +CAFE CAFE E9BE95 CAFE +CBA1 CBA1 E58CA3 CBA1 +CBA2 CBA2 E5B2AC CBA2 +CBA3 CBA3 E794B2 CBA3 +CBA4 CBA4 E8839B CBA4 +CBA5 CBA5 E98980 CBA5 +CBA6 CBA6 E99698 CBA6 +CBA7 CBA7 E5899B CBA7 +CBA8 CBA8 E5A088 CBA8 +CBA9 CBA9 E5A79C CBA9 +CBAA CBAA E5B2A1 CBAA +CBAB CBAB E5B497 CBAB +CBAC CBAC E5BAB7 CBAC +CBAD CBAD E5BCBA CBAD +CBAE CBAE E5BD8A CBAE +CBAF CBAF E685B7 CBAF +CBB0 CBB0 E6B19F CBB0 +CBB1 CBB1 E795BA CBB1 +CBB2 CBB2 E79686 CBB2 +CBB3 CBB3 E7B3A0 CBB3 +CBB4 CBB4 E7B5B3 CBB4 +CBB5 CBB5 E7B6B1 CBB5 +CBB6 CBB6 E7BE8C CBB6 +CBB7 CBB7 E88594 CBB7 +CBB8 CBB8 E888A1 CBB8 +CBB9 CBB9 E89691 CBB9 +CBBA CBBA E8A581 CBBA +CBBB CBBB E8AC9B CBBB +CBBC CBBC E98BBC CBBC +CBBD CBBD E9998D CBBD +CBBE CBBE E9B187 CBBE +CBBF CBBF E4BB8B CBBF +CBC0 CBC0 E4BBB7 CBC0 +CBC1 CBC1 E5808B CBC1 +CBC2 CBC2 E587B1 CBC2 +CBC3 CBC3 E5A18F CBC3 +CBC4 CBC4 E684B7 CBC4 +CBC5 CBC5 E684BE CBC5 +CBC6 CBC6 E685A8 CBC6 +CBC7 CBC7 E694B9 CBC7 +CBC8 CBC8 E6A7AA CBC8 +CBC9 CBC9 E6BC91 CBC9 +CBCA CBCA E796A5 CBCA +CBCB CBCB E79A86 CBCB +CBCC CBCC E79B96 CBCC +CBCD CBCD E7AE87 CBCD +CBCE CBCE E88AA5 CBCE +CBCF CBCF E8938B CBCF +CBD0 CBD0 EFA480 CBD0 +CBD1 CBD1 E98EA7 CBD1 +CBD2 CBD2 E9968B CBD2 +CBD3 CBD3 E59680 CBD3 +CBD4 CBD4 E5AEA2 CBD4 +CBD5 CBD5 E59D91 CBD5 +CBD6 CBD6 EFA481 CBD6 +CBD7 CBD7 E7B2B3 CBD7 +CBD8 CBD8 E7BEB9 CBD8 +CBD9 CBD9 E986B5 CBD9 +CBDA CBDA E580A8 CBDA +CBDB CBDB E58EBB CBDB +CBDC CBDC E5B185 CBDC +CBDD CBDD E5B7A8 CBDD +CBDE CBDE E68B92 CBDE +CBDF CBDF E68DAE CBDF +CBE0 CBE0 E6939A CBE0 +CBE1 CBE1 E693A7 CBE1 +CBE2 CBE2 E6B8A0 CBE2 +CBE3 CBE3 E782AC CBE3 +CBE4 CBE4 E7A59B CBE4 +CBE5 CBE5 E8B79D CBE5 +CBE6 CBE6 E8B89E CBE6 +CBE7 CBE7 EFA482 CBE7 +CBE8 CBE8 E981BD CBE8 +CBE9 CBE9 E98985 CBE9 +CBEA CBEA E98BB8 CBEA +CBEB CBEB E4B9BE CBEB +CBEC CBEC E4BBB6 CBEC +CBED CBED E581A5 CBED +CBEE CBEE E5B7BE CBEE +CBEF CBEF E5BBBA CBEF +CBF0 CBF0 E68486 CBF0 +CBF1 CBF1 E6A597 CBF1 +CBF2 CBF2 E885B1 CBF2 +CBF3 CBF3 E89994 CBF3 +CBF4 CBF4 E8B987 CBF4 +CBF5 CBF5 E98DB5 CBF5 +CBF6 CBF6 E9A8AB CBF6 +CBF7 CBF7 E4B99E CBF7 +CBF8 CBF8 E58291 CBF8 +CBF9 CBF9 E69DB0 CBF9 +CBFA CBFA E6A180 CBFA +CBFB CBFB E58489 CBFB +CBFC CBFC E58A8D CBFC +CBFD CBFD E58A92 CBFD +CBFE CBFE E6AAA2 CBFE +CCA1 CCA1 E79EBC CCA1 +CCA2 CCA2 E98890 CCA2 +CCA3 CCA3 E9BB94 CCA3 +CCA4 CCA4 E58AAB CCA4 +CCA5 CCA5 E680AF CCA5 +CCA6 CCA6 E8BFB2 CCA6 +CCA7 CCA7 E58188 CCA7 +CCA8 CCA8 E686A9 CCA8 +CCA9 CCA9 E68FAD CCA9 +CCAA CCAA E6938A CCAA +CCAB CCAB E6A0BC CCAB +CCAC CCAC E6AA84 CCAC +CCAD CCAD E6BF80 CCAD +CCAE CCAE E88688 CCAE +CCAF CCAF E8A6A1 CCAF +CCB0 CCB0 E99A94 CCB0 +CCB1 CCB1 E5A085 CCB1 +CCB2 CCB2 E789BD CCB2 +CCB3 CCB3 E78AAC CCB3 +CCB4 CCB4 E79484 CCB4 +CCB5 CCB5 E7B5B9 CCB5 +CCB6 CCB6 E7B9AD CCB6 +CCB7 CCB7 E882A9 CCB7 +CCB8 CCB8 E8A68B CCB8 +CCB9 CCB9 E8ADB4 CCB9 +CCBA CCBA E981A3 CCBA +CCBB CCBB E9B591 CCBB +CCBC CCBC E68A89 CCBC +CCBD CCBD E6B1BA CCBD +CCBE CCBE E6BD94 CCBE +CCBF CCBF E7B590 CCBF +CCC0 CCC0 E7BCBA CCC0 +CCC1 CCC1 E8A8A3 CCC1 +CCC2 CCC2 E585BC CCC2 +CCC3 CCC3 E6858A CCC3 +CCC4 CCC4 E7AE9D CCC4 +CCC5 CCC5 E8AC99 CCC5 +CCC6 CCC6 E98997 CCC6 +CCC7 CCC7 E98E8C CCC7 +CCC8 CCC8 E4BAAC CCC8 +CCC9 CCC9 E4BF93 CCC9 +CCCA CCCA E5809E CCCA +CCCB CCCB E582BE CCCB +CCCC CCCC E58486 CCCC +CCCD CCCD E58B81 CCCD +CCCE CCCE E58B8D CCCE +CCCF CCCF E58DBF CCCF +CCD0 CCD0 E59DB0 CCD0 +CCD1 CCD1 E5A283 CCD1 +CCD2 CCD2 E5BA9A CCD2 +CCD3 CCD3 E5BE91 CCD3 +CCD4 CCD4 E685B6 CCD4 +CCD5 CCD5 E686AC CCD5 +CCD6 CCD6 E6938E CCD6 +CCD7 CCD7 E695AC CCD7 +CCD8 CCD8 E699AF CCD8 +CCD9 CCD9 E69ABB CCD9 +CCDA CCDA E69BB4 CCDA +CCDB CCDB E6A297 CCDB +CCDC CCDC E6B687 CCDC +CCDD CCDD E78285 CCDD +CCDE CCDE E783B1 CCDE +CCDF CCDF E7929F CCDF +CCE0 CCE0 E792A5 CCE0 +CCE1 CCE1 E7938A CCE1 +CCE2 CCE2 E79799 CCE2 +CCE3 CCE3 E7A1AC CCE3 +CCE4 CCE4 E7A3AC CCE4 +CCE5 CCE5 E7AB9F CCE5 +CCE6 CCE6 E7ABB6 CCE6 +CCE7 CCE7 E7B585 CCE7 +CCE8 CCE8 E7B693 CCE8 +CCE9 CCE9 E88095 CCE9 +CCEA CCEA E880BF CCEA +CCEB CCEB E8849B CCEB +CCEC CCEC E88E96 CCEC +CCED CCED E8ADA6 CCED +CCEE CCEE E8BC95 CCEE +CCEF CCEF E98095 CCEF +CCF0 CCF0 E98FA1 CCF0 +CCF1 CCF1 E9A083 CCF1 +CCF2 CCF2 E9A0B8 CCF2 +CCF3 CCF3 E9A99A CCF3 +CCF4 CCF4 E9AFA8 CCF4 +CCF5 CCF5 E4BF82 CCF5 +CCF6 CCF6 E59593 CCF6 +CCF7 CCF7 E5A0BA CCF7 +CCF8 CCF8 E5A591 CCF8 +CCF9 CCF9 E5ADA3 CCF9 +CCFA CCFA E5B186 CCFA +CCFB CCFB E682B8 CCFB +CCFC CCFC E68892 CCFC +CCFD CCFD E6A182 CCFD +CCFE CCFE E6A2B0 CCFE +CDA1 CDA1 E6A3A8 CDA1 +CDA2 CDA2 E6BAAA CDA2 +CDA3 CDA3 E7958C CDA3 +CDA4 CDA4 E799B8 CDA4 +CDA5 CDA5 E7A38E CDA5 +CDA6 CDA6 E7A8BD CDA6 +CDA7 CDA7 E7B3BB CDA7 +CDA8 CDA8 E7B9AB CDA8 +CDA9 CDA9 E7B9BC CDA9 +CDAA CDAA E8A888 CDAA +CDAB CDAB E8AAA1 CDAB +CDAC CDAC E8B0BF CDAC +CDAD CDAD E99A8E CDAD +CDAE CDAE E9B784 CDAE +CDAF CDAF E58FA4 CDAF +CDB0 CDB0 E58FA9 CDB0 +CDB1 CDB1 E5918A CDB1 +CDB2 CDB2 E591B1 CDB2 +CDB3 CDB3 E59BBA CDB3 +CDB4 CDB4 E5A791 CDB4 +CDB5 CDB5 E5ADA4 CDB5 +CDB6 CDB6 E5B0BB CDB6 +CDB7 CDB7 E5BAAB CDB7 +CDB8 CDB8 E68BB7 CDB8 +CDB9 CDB9 E694B7 CDB9 +CDBA CDBA E69585 CDBA +CDBB CDBB E695B2 CDBB +CDBC CDBC E69AA0 CDBC +CDBD CDBD E69EAF CDBD +CDBE CDBE E6A781 CDBE +CDBF CDBF E6B2BD CDBF +CDC0 CDC0 E797BC CDC0 +CDC1 CDC1 E79A90 CDC1 +CDC2 CDC2 E79DBE CDC2 +CDC3 CDC3 E7A8BF CDC3 +CDC4 CDC4 E7BE94 CDC4 +CDC5 CDC5 E88083 CDC5 +CDC6 CDC6 E882A1 CDC6 +CDC7 CDC7 E8868F CDC7 +CDC8 CDC8 E88BA6 CDC8 +CDC9 CDC9 E88BBD CDC9 +CDCA CDCA E88FB0 CDCA +CDCB CDCB E89781 CDCB +CDCC CDCC E8A0B1 CDCC +CDCD CDCD E8A2B4 CDCD +CDCE CDCE E8AAA5 CDCE +CDCF CDCF EFA483 CDCF +CDD0 CDD0 E8BE9C CDD0 +CDD1 CDD1 E98CAE CDD1 +CDD2 CDD2 E99B87 CDD2 +CDD3 CDD3 E9A1A7 CDD3 +CDD4 CDD4 E9AB98 CDD4 +CDD5 CDD5 E9BC93 CDD5 +CDD6 CDD6 E593AD CDD6 +CDD7 CDD7 E6969B CDD7 +CDD8 CDD8 E69BB2 CDD8 +CDD9 CDD9 E6A28F CDD9 +CDDA CDDA E7A980 CDDA +CDDB CDDB E8B0B7 CDDB +CDDC CDDC E9B5A0 CDDC +CDDD CDDD E59BB0 CDDD +CDDE CDDE E59DA4 CDDE +CDDF CDDF E5B491 CDDF +CDE0 CDE0 E69886 CDE0 +CDE1 CDE1 E6A2B1 CDE1 +CDE2 CDE2 E6A38D CDE2 +CDE3 CDE3 E6BBBE CDE3 +CDE4 CDE4 E790A8 CDE4 +CDE5 CDE5 E8A29E CDE5 +CDE6 CDE6 E9AFA4 CDE6 +CDE7 CDE7 E6B1A8 CDE7 +CDE8 CDE8 EFA484 CDE8 +CDE9 CDE9 E9AAA8 CDE9 +CDEA CDEA E4BE9B CDEA +CDEB CDEB E585AC CDEB +CDEC CDEC E585B1 CDEC +CDED CDED E58A9F CDED +CDEE CDEE E5AD94 CDEE +CDEF CDEF E5B7A5 CDEF +CDF0 CDF0 E68190 CDF0 +CDF1 CDF1 E681AD CDF1 +CDF2 CDF2 E68BB1 CDF2 +CDF3 CDF3 E68EA7 CDF3 +CDF4 CDF4 E694BB CDF4 +CDF5 CDF5 E78F99 CDF5 +CDF6 CDF6 E7A9BA CDF6 +CDF7 CDF7 E89AA3 CDF7 +CDF8 CDF8 E8B2A2 CDF8 +CDF9 CDF9 E99E8F CDF9 +CDFA CDFA E4B8B2 CDFA +CDFB CDFB E5AFA1 CDFB +CDFC CDFC E68888 CDFC +CDFD CDFD E69E9C CDFD +CDFE CDFE E7939C CDFE +CEA1 CEA1 E7A791 CEA1 +CEA2 CEA2 E88F93 CEA2 +CEA3 CEA3 E8AA87 CEA3 +CEA4 CEA4 E8AAB2 CEA4 +CEA5 CEA5 E8B7A8 CEA5 +CEA6 CEA6 E9818E CEA6 +CEA7 CEA7 E98D8B CEA7 +CEA8 CEA8 E9A186 CEA8 +CEA9 CEA9 E5BB93 CEA9 +CEAA CEAA E6A7A8 CEAA +CEAB CEAB E897BF CEAB +CEAC CEAC E983AD CEAC +CEAD CEAD EFA485 CEAD +CEAE CEAE E586A0 CEAE +CEAF CEAF E5AE98 CEAF +CEB0 CEB0 E5AFAC CEB0 +CEB1 CEB1 E685A3 CEB1 +CEB2 CEB2 E6A3BA CEB2 +CEB3 CEB3 E6ACBE CEB3 +CEB4 CEB4 E7818C CEB4 +CEB5 CEB5 E790AF CEB5 +CEB6 CEB6 E79398 CEB6 +CEB7 CEB7 E7AEA1 CEB7 +CEB8 CEB8 E7BD90 CEB8 +CEB9 CEB9 E88F85 CEB9 +CEBA CEBA E8A780 CEBA +CEBB CEBB E8B2AB CEBB +CEBC CEBC E9979C CEBC +CEBD CEBD E9A4A8 CEBD +CEBE CEBE E588AE CEBE +CEBF CEBF E6819D CEBF +CEC0 CEC0 E68BAC CEC0 +CEC1 CEC1 E98082 CEC1 +CEC2 CEC2 E4BE8A CEC2 +CEC3 CEC3 E58589 CEC3 +CEC4 CEC4 E58CA1 CEC4 +CEC5 CEC5 E5A399 CEC5 +CEC6 CEC6 E5BBA3 CEC6 +CEC7 CEC7 E69BA0 CEC7 +CEC8 CEC8 E6B4B8 CEC8 +CEC9 CEC9 E7829A CEC9 +CECA CECA E78B82 CECA +CECB CECB E78F96 CECB +CECC CECC E7AD90 CECC +CECD CECD E883B1 CECD +CECE CECE E9919B CECE +CECF CECF E58DA6 CECF +CED0 CED0 E68E9B CED0 +CED1 CED1 E7BDAB CED1 +CED2 CED2 E4B996 CED2 +CED3 CED3 E58280 CED3 +CED4 CED4 E5A18A CED4 +CED5 CED5 E5A39E CED5 +CED6 CED6 E680AA CED6 +CED7 CED7 E684A7 CED7 +CED8 CED8 E68B90 CED8 +CED9 CED9 E6A790 CED9 +CEDA CEDA E9AD81 CEDA +CEDB CEDB E5AE8F CEDB +CEDC CEDC E7B498 CEDC +CEDD CEDD E882B1 CEDD +CEDE CEDE E8BD9F CEDE +CEDF CEDF E4BAA4 CEDF +CEE0 CEE0 E58391 CEE0 +CEE1 CEE1 E592AC CEE1 +CEE2 CEE2 E596AC CEE2 +CEE3 CEE3 E5AC8C CEE3 +CEE4 CEE4 E5B6A0 CEE4 +CEE5 CEE5 E5B7A7 CEE5 +CEE6 CEE6 E694AA CEE6 +CEE7 CEE7 E6958E CEE7 +CEE8 CEE8 E6A0A1 CEE8 +CEE9 CEE9 E6A98B CEE9 +CEEA CEEA E78BA1 CEEA +CEEB CEEB E79A8E CEEB +CEEC CEEC E79FAF CEEC +CEED CEED E7B59E CEED +CEEE CEEE E7BFB9 CEEE +CEEF CEEF E886A0 CEEF +CEF0 CEF0 E8958E CEF0 +CEF1 CEF1 E89B9F CEF1 +CEF2 CEF2 E8BC83 CEF2 +CEF3 CEF3 E8BD8E CEF3 +CEF4 CEF4 E9838A CEF4 +CEF5 CEF5 E9A483 CEF5 +CEF6 CEF6 E9A995 CEF6 +CEF7 CEF7 E9AEAB CEF7 +CEF8 CEF8 E4B898 CEF8 +CEF9 CEF9 E4B985 CEF9 +CEFA CEFA E4B99D CEFA +CEFB CEFB E4BB87 CEFB +CEFC CEFC E4BFB1 CEFC +CEFD CEFD E585B7 CEFD +CEFE CEFE E58BBE CEFE +CFA1 CFA1 E58D80 CFA1 +CFA2 CFA2 E58FA3 CFA2 +CFA3 CFA3 E58FA5 CFA3 +CFA4 CFA4 E5928E CFA4 +CFA5 CFA5 E59894 CFA5 +CFA6 CFA6 E59DB5 CFA6 +CFA7 CFA7 E59EA2 CFA7 +CFA8 CFA8 E5AF87 CFA8 +CFA9 CFA9 E5B687 CFA9 +CFAA CFAA E5BB90 CFAA +CFAB CFAB E687BC CFAB +CFAC CFAC E68B98 CFAC +CFAD CFAD E69591 CFAD +CFAE CFAE E69EB8 CFAE +CFAF CFAF E69FA9 CFAF +CFB0 CFB0 E6A78B CFB0 +CFB1 CFB1 E6AD90 CFB1 +CFB2 CFB2 E6AF86 CFB2 +CFB3 CFB3 E6AFAC CFB3 +CFB4 CFB4 E6B182 CFB4 +CFB5 CFB5 E6BA9D CFB5 +CFB6 CFB6 E781B8 CFB6 +CFB7 CFB7 E78B97 CFB7 +CFB8 CFB8 E78E96 CFB8 +CFB9 CFB9 E79083 CFB9 +CFBA CFBA E79EBF CFBA +CFBB CFBB E79FA9 CFBB +CFBC CFBC E7A9B6 CFBC +CFBD CFBD E7B5BF CFBD +CFBE CFBE E88089 CFBE +CFBF CFBF E887BC CFBF +CFC0 CFC0 E88885 CFC0 +CFC1 CFC1 E8888A CFC1 +CFC2 CFC2 E88B9F CFC2 +CFC3 CFC3 E8A1A2 CFC3 +CFC4 CFC4 E8ACB3 CFC4 +CFC5 CFC5 E8B3BC CFC5 +CFC6 CFC6 E8BB80 CFC6 +CFC7 CFC7 E98091 CFC7 +CFC8 CFC8 E982B1 CFC8 +CFC9 CFC9 E989A4 CFC9 +CFCA CFCA E98AB6 CFCA +CFCB CFCB E9A792 CFCB +CFCC CFCC E9A985 CFCC +CFCD CFCD E9B3A9 CFCD +CFCE CFCE E9B797 CFCE +CFCF CFCF E9BE9C CFCF +CFD0 CFD0 E59C8B CFD0 +CFD1 CFD1 E5B180 CFD1 +CFD2 CFD2 E88F8A CFD2 +CFD3 CFD3 E99EA0 CFD3 +CFD4 CFD4 E99EAB CFD4 +CFD5 CFD5 E9BAB4 CFD5 +CFD6 CFD6 E5909B CFD6 +CFD7 CFD7 E7AA98 CFD7 +CFD8 CFD8 E7BEA4 CFD8 +CFD9 CFD9 E8A399 CFD9 +CFDA CFDA E8BB8D CFDA +CFDB CFDB E983A1 CFDB +CFDC CFDC E5A080 CFDC +CFDD CFDD E5B188 CFDD +CFDE CFDE E68E98 CFDE +CFDF CFDF E7AA9F CFDF +CFE0 CFE0 E5AEAE CFE0 +CFE1 CFE1 E5BC93 CFE1 +CFE2 CFE2 E7A9B9 CFE2 +CFE3 CFE3 E7AAAE CFE3 +CFE4 CFE4 E88A8E CFE4 +CFE5 CFE5 E8BAAC CFE5 +CFE6 CFE6 E580A6 CFE6 +CFE7 CFE7 E588B8 CFE7 +CFE8 CFE8 E58BB8 CFE8 +CFE9 CFE9 E58DB7 CFE9 +CFEA CFEA E59C88 CFEA +CFEB CFEB E68BB3 CFEB +CFEC CFEC E68DB2 CFEC +CFED CFED E6AC8A CFED +CFEE CFEE E6B783 CFEE +CFEF CFEF E79CB7 CFEF +CFF0 CFF0 E58EA5 CFF0 +CFF1 CFF1 E78D97 CFF1 +CFF2 CFF2 E895A8 CFF2 +CFF3 CFF3 E8B9B6 CFF3 +CFF4 CFF4 E99795 CFF4 +CFF5 CFF5 E69CBA CFF5 +CFF6 CFF6 E6AB83 CFF6 +CFF7 CFF7 E6BDB0 CFF7 +CFF8 CFF8 E8A9AD CFF8 +CFF9 CFF9 E8BB8C CFF9 +CFFA CFFA E9A58B CFFA +CFFB CFFB EFA486 CFFB +CFFC CFFC E699B7 CFFC +CFFD CFFD E6ADB8 CFFD +CFFE CFFE E8B2B4 CFFE +D0A1 D0A1 E9ACBC D0A1 +D0A2 D0A2 EFA487 D0A2 +D0A3 D0A3 E58FAB D0A3 +D0A4 D0A4 E59CAD D0A4 +D0A5 D0A5 E5A58E D0A5 +D0A6 D0A6 E68F86 D0A6 +D0A7 D0A7 E6A7BB D0A7 +D0A8 D0A8 E78FAA D0A8 +D0A9 D0A9 E7A185 D0A9 +D0AA D0AA E7AABA D0AA +D0AB D0AB E7AB85 D0AB +D0AC D0AC E7B3BE D0AC +D0AD D0AD E891B5 D0AD +D0AE D0AE E8A68F D0AE +D0AF D0AF E8B5B3 D0AF +D0B0 D0B0 E980B5 D0B0 +D0B1 D0B1 E996A8 D0B1 +D0B2 D0B2 E58BBB D0B2 +D0B3 D0B3 E59D87 D0B3 +D0B4 D0B4 E79587 D0B4 +D0B5 D0B5 E7ADA0 D0B5 +D0B6 D0B6 E88F8C D0B6 +D0B7 D0B7 E9889E D0B7 +D0B8 D0B8 EFA488 D0B8 +D0B9 D0B9 E6A998 D0B9 +D0BA D0BA E5858B D0BA +D0BB D0BB E5898B D0BB +D0BC D0BC E58A87 D0BC +D0BD D0BD E6889F D0BD +D0BE D0BE E6A398 D0BE +D0BF D0BF E6A5B5 D0BF +D0C0 D0C0 E99A99 D0C0 +D0C1 D0C1 E58385 D0C1 +D0C2 D0C2 E58AA4 D0C2 +D0C3 D0C3 E58BA4 D0C3 +D0C4 D0C4 E68783 D0C4 +D0C5 D0C5 E696A4 D0C5 +D0C6 D0C6 E6A0B9 D0C6 +D0C7 D0C7 E6A7BF D0C7 +D0C8 D0C8 E791BE D0C8 +D0C9 D0C9 E7AD8B D0C9 +D0CA D0CA E88AB9 D0CA +D0CB D0CB E88FAB D0CB +D0CC D0CC E8A6B2 D0CC +D0CD D0CD E8ACB9 D0CD +D0CE D0CE E8BF91 D0CE +D0CF D0CF E9A589 D0CF +D0D0 D0D0 EFA489 D0D0 +D0D1 D0D1 E4BB8A D0D1 +D0D2 D0D2 E5A697 D0D2 +D0D3 D0D3 E69392 D0D3 +D0D4 D0D4 E69891 D0D4 +D0D5 D0D5 E6AA8E D0D5 +D0D6 D0D6 E790B4 D0D6 +D0D7 D0D7 E7A681 D0D7 +D0D8 D0D8 E7A6BD D0D8 +D0D9 D0D9 E88AA9 D0D9 +D0DA D0DA E8A1BE D0DA +D0DB D0DB E8A1BF D0DB +D0DC D0DC E8A59F D0DC +D0DD D0DD EFA48A D0DD +D0DE D0DE E98CA6 D0DE +D0DF D0DF E4BC8B D0DF +D0E0 D0E0 E58F8A D0E0 +D0E1 D0E1 E680A5 D0E1 +D0E2 D0E2 E689B1 D0E2 +D0E3 D0E3 E6B1B2 D0E3 +D0E4 D0E4 E7B49A D0E4 +D0E5 D0E5 E7B5A6 D0E5 +D0E6 D0E6 E4BA98 D0E6 +D0E7 D0E7 E585A2 D0E7 +D0E8 D0E8 E79F9C D0E8 +D0E9 D0E9 E882AF D0E9 +D0EA D0EA E4BC81 D0EA +D0EB D0EB E4BC8E D0EB +D0EC D0EC E585B6 D0EC +D0ED D0ED E58680 D0ED +D0EE D0EE E5979C D0EE +D0EF D0EF E599A8 D0EF +D0F0 D0F0 E59CBB D0F0 +D0F1 D0F1 E59FBA D0F1 +D0F2 D0F2 E59FBC D0F2 +D0F3 D0F3 E5A494 D0F3 +D0F4 D0F4 E5A587 D0F4 +D0F5 D0F5 E5A693 D0F5 +D0F6 D0F6 E5AF84 D0F6 +D0F7 D0F7 E5B290 D0F7 +D0F8 D0F8 E5B48E D0F8 +D0F9 D0F9 E5B7B1 D0F9 +D0FA D0FA E5B9BE D0FA +D0FB D0FB E5BF8C D0FB +D0FC D0FC E68A80 D0FC +D0FD D0FD E69797 D0FD +D0FE D0FE E697A3 D0FE +D1A1 D1A1 E69C9E D1A1 +D1A2 D1A2 E69C9F D1A2 +D1A3 D1A3 E69D9E D1A3 +D1A4 D1A4 E6A38B D1A4 +D1A5 D1A5 E6A384 D1A5 +D1A6 D1A6 E6A99F D1A6 +D1A7 D1A7 E6ACBA D1A7 +D1A8 D1A8 E6B0A3 D1A8 +D1A9 D1A9 E6B1BD D1A9 +D1AA D1AA E6B282 D1AA +D1AB D1AB E6B787 D1AB +D1AC D1AC E78E98 D1AC +D1AD D1AD E790A6 D1AD +D1AE D1AE E790AA D1AE +D1AF D1AF E79282 D1AF +D1B0 D1B0 E792A3 D1B0 +D1B1 D1B1 E795B8 D1B1 +D1B2 D1B2 E795BF D1B2 +D1B3 D1B3 E7A281 D1B3 +D1B4 D1B4 E7A3AF D1B4 +D1B5 D1B5 E7A581 D1B5 +D1B6 D1B6 E7A587 D1B6 +D1B7 D1B7 E7A588 D1B7 +D1B8 D1B8 E7A5BA D1B8 +D1B9 D1B9 E7AE95 D1B9 +D1BA D1BA E7B480 D1BA +D1BB D1BB E7B6BA D1BB +D1BC D1BC E7BE88 D1BC +D1BD D1BD E88086 D1BD +D1BE D1BE E880AD D1BE +D1BF D1BF E8828C D1BF +D1C0 D1C0 E8A898 D1C0 +D1C1 D1C1 E8AD8F D1C1 +D1C2 D1C2 E8B188 D1C2 +D1C3 D1C3 E8B5B7 D1C3 +D1C4 D1C4 E98CA1 D1C4 +D1C5 D1C5 E98CA4 D1C5 +D1C6 D1C6 E9A3A2 D1C6 +D1C7 D1C7 E9A591 D1C7 +D1C8 D1C8 E9A88E D1C8 +D1C9 D1C9 E9A88F D1C9 +D1CA D1CA E9A9A5 D1CA +D1CB D1CB E9BA92 D1CB +D1CC D1CC E7B78A D1CC +D1CD D1CD E4BDB6 D1CD +D1CE D1CE E59089 D1CE +D1CF D1CF E68BAE D1CF +D1D0 D1D0 E6A194 D1D0 +D1D1 D1D1 E98791 D1D1 +D1D2 D1D2 E596AB D1D2 +D1D3 D1D3 E584BA D1D3 +D1D4 D1D4 EFA48B D1D4 +D1D5 D1D5 EFA48C D1D5 +D1D6 D1D6 E5A89C D1D6 +D1D7 D1D7 E687A6 D1D7 +D1D8 D1D8 EFA48D D1D8 +D1D9 D1D9 E68B8F D1D9 +D1DA D1DA E68BBF D1DA +D1DB D1DB EFA48E D1DB +D1DC D1DC EFA48F D1DC +D1DD D1DD EFA490 D1DD +D1DE D1DE EFA491 D1DE +D1DF D1DF EFA492 D1DF +D1E0 D1E0 EFA493 D1E0 +D1E1 D1E1 E982A3 D1E1 +D1E2 D1E2 EFA494 D1E2 +D1E3 D1E3 EFA495 D1E3 +D1E4 D1E4 EFA496 D1E4 +D1E5 D1E5 EFA497 D1E5 +D1E6 D1E6 EFA498 D1E6 +D1E7 D1E7 E8ABBE D1E7 +D1E8 D1E8 EFA499 D1E8 +D1E9 D1E9 EFA49A D1E9 +D1EA D1EA EFA49B D1EA +D1EB D1EB EFA49C D1EB +D1EC D1EC E69A96 D1EC +D1ED D1ED EFA49D D1ED +D1EE D1EE E78596 D1EE +D1EF D1EF EFA49E D1EF +D1F0 D1F0 EFA49F D1F0 +D1F1 D1F1 E99BA3 D1F1 +D1F2 D1F2 EFA4A0 D1F2 +D1F3 D1F3 E68D8F D1F3 +D1F4 D1F4 E68DBA D1F4 +D1F5 D1F5 E58D97 D1F5 +D1F6 D1F6 EFA4A1 D1F6 +D1F7 D1F7 E69E8F D1F7 +D1F8 D1F8 E6A5A0 D1F8 +D1F9 D1F9 E6B9B3 D1F9 +D1FA D1FA EFA4A2 D1FA +D1FB D1FB E794B7 D1FB +D1FC D1FC EFA4A3 D1FC +D1FD D1FD EFA4A4 D1FD +D1FE D1FE EFA4A5 D1FE +D2A1 D2A1 E7B48D D2A1 +D2A2 D2A2 EFA4A6 D2A2 +D2A3 D2A3 EFA4A7 D2A3 +D2A4 D2A4 E8A1B2 D2A4 +D2A5 D2A5 E59B8A D2A5 +D2A6 D2A6 E5A898 D2A6 +D2A7 D2A7 EFA4A8 D2A7 +D2A8 D2A8 EFA4A9 D2A8 +D2A9 D2A9 EFA4AA D2A9 +D2AA D2AA EFA4AB D2AA +D2AB D2AB EFA4AC D2AB +D2AC D2AC E4B983 D2AC +D2AD D2AD EFA4AD D2AD +D2AE D2AE E585A7 D2AE +D2AF D2AF E5A588 D2AF +D2B0 D2B0 E69FB0 D2B0 +D2B1 D2B1 E88090 D2B1 +D2B2 D2B2 EFA4AE D2B2 +D2B3 D2B3 E5A5B3 D2B3 +D2B4 D2B4 E5B9B4 D2B4 +D2B5 D2B5 E6929A D2B5 +D2B6 D2B6 E7A78A D2B6 +D2B7 D2B7 E5BFB5 D2B7 +D2B8 D2B8 E681AC D2B8 +D2B9 D2B9 E68B88 D2B9 +D2BA D2BA E68DBB D2BA +D2BB D2BB E5AFA7 D2BB +D2BC D2BC E5AF97 D2BC +D2BD D2BD E58AAA D2BD +D2BE D2BE EFA4AF D2BE +D2BF D2BF E5A5B4 D2BF +D2C0 D2C0 E5BCA9 D2C0 +D2C1 D2C1 E68092 D2C1 +D2C2 D2C2 EFA4B0 D2C2 +D2C3 D2C3 EFA4B1 D2C3 +D2C4 D2C4 EFA4B2 D2C4 +D2C5 D2C5 E79199 D2C5 +D2C6 D2C6 EFA4B3 D2C6 +D2C7 D2C7 EFA4B4 D2C7 +D2C8 D2C8 EFA4B5 D2C8 +D2C9 D2C9 EFA4B6 D2C9 +D2CA D2CA EFA4B7 D2CA +D2CB D2CB EFA4B8 D2CB +D2CC D2CC E9A791 D2CC +D2CD D2CD EFA4B9 D2CD +D2CE D2CE EFA4BA D2CE +D2CF D2CF EFA4BB D2CF +D2D0 D2D0 EFA4BC D2D0 +D2D1 D2D1 EFA4BD D2D1 +D2D2 D2D2 EFA4BE D2D2 +D2D3 D2D3 EFA4BF D2D3 +D2D4 D2D4 EFA580 D2D4 +D2D5 D2D5 EFA581 D2D5 +D2D6 D2D6 EFA582 D2D6 +D2D7 D2D7 EFA583 D2D7 +D2D8 D2D8 E6BF83 D2D8 +D2D9 D2D9 EFA584 D2D9 +D2DA D2DA EFA585 D2DA +D2DB D2DB E886BF D2DB +D2DC D2DC E8BEB2 D2DC +D2DD D2DD E683B1 D2DD +D2DE D2DE EFA586 D2DE +D2DF D2DF EFA587 D2DF +D2E0 D2E0 E885A6 D2E0 +D2E1 D2E1 EFA588 D2E1 +D2E2 D2E2 EFA589 D2E2 +D2E3 D2E3 E5B0BF D2E3 +D2E4 D2E4 EFA58A D2E4 +D2E5 D2E5 EFA58B D2E5 +D2E6 D2E6 EFA58C D2E6 +D2E7 D2E7 EFA58D D2E7 +D2E8 D2E8 EFA58E D2E8 +D2E9 D2E9 EFA58F D2E9 +D2EA D2EA EFA590 D2EA +D2EB D2EB EFA591 D2EB +D2EC D2EC E5ABA9 D2EC +D2ED D2ED E8A8A5 D2ED +D2EE D2EE E69DBB D2EE +D2EF D2EF E7B490 D2EF +D2F0 D2F0 EFA592 D2F0 +D2F1 D2F1 EFA593 D2F1 +D2F2 D2F2 EFA594 D2F2 +D2F3 D2F3 EFA595 D2F3 +D2F4 D2F4 EFA596 D2F4 +D2F5 D2F5 EFA597 D2F5 +D2F6 D2F6 E883BD D2F6 +D2F7 D2F7 EFA598 D2F7 +D2F8 D2F8 EFA599 D2F8 +D2F9 D2F9 E5B0BC D2F9 +D2FA D2FA E6B3A5 D2FA +D2FB D2FB E58CBF D2FB +D2FC D2FC E6BABA D2FC +D2FD D2FD E5A49A D2FD +D2FE D2FE E88CB6 D2FE +D3A1 D3A1 E4B8B9 D3A1 +D3A2 D3A2 E4BAB6 D3A2 +D3A3 D3A3 E4BD86 D3A3 +D3A4 D3A4 E596AE D3A4 +D3A5 D3A5 E59C98 D3A5 +D3A6 D3A6 E5A387 D3A6 +D3A7 D3A7 E5BD96 D3A7 +D3A8 D3A8 E696B7 D3A8 +D3A9 D3A9 E697A6 D3A9 +D3AA D3AA E6AA80 D3AA +D3AB D3AB E6AEB5 D3AB +D3AC D3AC E6B98D D3AC +D3AD D3AD E79FAD D3AD +D3AE D3AE E7ABAF D3AE +D3AF D3AF E7B09E D3AF +D3B0 D3B0 E7B79E D3B0 +D3B1 D3B1 E89B8B D3B1 +D3B2 D3B2 E8A292 D3B2 +D3B3 D3B3 E984B2 D3B3 +D3B4 D3B4 E98D9B D3B4 +D3B5 D3B5 E692BB D3B5 +D3B6 D3B6 E6BEBE D3B6 +D3B7 D3B7 E78DBA D3B7 +D3B8 D3B8 E796B8 D3B8 +D3B9 D3B9 E98194 D3B9 +D3BA D3BA E59596 D3BA +D3BB D3BB E59D8D D3BB +D3BC D3BC E686BA D3BC +D3BD D3BD E69394 D3BD +D3BE D3BE E69B87 D3BE +D3BF D3BF E6B7A1 D3BF +D3C0 D3C0 E6B99B D3C0 +D3C1 D3C1 E6BDAD D3C1 +D3C2 D3C2 E6BEB9 D3C2 +D3C3 D3C3 E797B0 D3C3 +D3C4 D3C4 E88183 D3C4 +D3C5 D3C5 E886BD D3C5 +D3C6 D3C6 E89581 D3C6 +D3C7 D3C7 E8A683 D3C7 +D3C8 D3C8 E8AB87 D3C8 +D3C9 D3C9 E8AD9A D3C9 +D3CA D3CA E98C9F D3CA +D3CB D3CB E6B293 D3CB +D3CC D3CC E79593 D3CC +D3CD D3CD E7AD94 D3CD +D3CE D3CE E8B88F D3CE +D3CF D3CF E9819D D3CF +D3D0 D3D0 E59490 D3D0 +D3D1 D3D1 E5A082 D3D1 +D3D2 D3D2 E5A198 D3D2 +D3D3 D3D3 E5B9A2 D3D3 +D3D4 D3D4 E68887 D3D4 +D3D5 D3D5 E6929E D3D5 +D3D6 D3D6 E6A3A0 D3D6 +D3D7 D3D7 E795B6 D3D7 +D3D8 D3D8 E7B396 D3D8 +D3D9 D3D9 E89EB3 D3D9 +D3DA D3DA E9BBA8 D3DA +D3DB D3DB E4BBA3 D3DB +D3DC D3DC E59E88 D3DC +D3DD D3DD E59DAE D3DD +D3DE D3DE E5A4A7 D3DE +D3DF D3DF E5B08D D3DF +D3E0 D3E0 E5B2B1 D3E0 +D3E1 D3E1 E5B8B6 D3E1 +D3E2 D3E2 E5BE85 D3E2 +D3E3 D3E3 E688B4 D3E3 +D3E4 D3E4 E693A1 D3E4 +D3E5 D3E5 E78EB3 D3E5 +D3E6 D3E6 E887BA D3E6 +D3E7 D3E7 E8A28B D3E7 +D3E8 D3E8 E8B2B8 D3E8 +D3E9 D3E9 E99A8A D3E9 +D3EA D3EA E9BB9B D3EA +D3EB D3EB E5AE85 D3EB +D3EC D3EC E5BEB7 D3EC +D3ED D3ED E682B3 D3ED +D3EE D3EE E58092 D3EE +D3EF D3EF E58880 D3EF +D3F0 D3F0 E588B0 D3F0 +D3F1 D3F1 E59C96 D3F1 +D3F2 D3F2 E5A0B5 D3F2 +D3F3 D3F3 E5A197 D3F3 +D3F4 D3F4 E5B08E D3F4 +D3F5 D3F5 E5B1A0 D3F5 +D3F6 D3F6 E5B3B6 D3F6 +D3F7 D3F7 E5B68B D3F7 +D3F8 D3F8 E5BAA6 D3F8 +D3F9 D3F9 E5BE92 D3F9 +D3FA D3FA E682BC D3FA +D3FB D3FB E68C91 D3FB +D3FC D3FC E68E89 D3FC +D3FD D3FD E69097 D3FD +D3FE D3FE E6A183 D3FE +D4A1 D4A1 E6A3B9 D4A1 +D4A2 D4A2 E6AB82 D4A2 +D4A3 D4A3 E6B798 D4A3 +D4A4 D4A4 E6B8A1 D4A4 +D4A5 D4A5 E6BB94 D4A5 +D4A6 D4A6 E6BFA4 D4A6 +D4A7 D4A7 E787BE D4A7 +D4A8 D4A8 E79B9C D4A8 +D4A9 D4A9 E79DB9 D4A9 +D4AA D4AA E7A6B1 D4AA +D4AB D4AB E7A8BB D4AB +D4AC D4AC E89084 D4AC +D4AD D4AD E8A6A9 D4AD +D4AE D4AE E8B3AD D4AE +D4AF D4AF E8B7B3 D4AF +D4B0 D4B0 E8B988 D4B0 +D4B1 D4B1 E98083 D4B1 +D4B2 D4B2 E98094 D4B2 +D4B3 D4B3 E98193 D4B3 +D4B4 D4B4 E983BD D4B4 +D4B5 D4B5 E98D8D D4B5 +D4B6 D4B6 E999B6 D4B6 +D4B7 D4B7 E99F9C D4B7 +D4B8 D4B8 E6AF92 D4B8 +D4B9 D4B9 E78086 D4B9 +D4BA D4BA E78998 D4BA +D4BB D4BB E78AA2 D4BB +D4BC D4BC E78DA8 D4BC +D4BD D4BD E79DA3 D4BD +D4BE D4BE E7A6BF D4BE +D4BF D4BF E7AFA4 D4BF +D4C0 D4C0 E7BA9B D4C0 +D4C1 D4C1 E8AE80 D4C1 +D4C2 D4C2 E5A2A9 D4C2 +D4C3 D4C3 E68387 D4C3 +D4C4 D4C4 E695A6 D4C4 +D4C5 D4C5 E697BD D4C5 +D4C6 D4C6 E69ABE D4C6 +D4C7 D4C7 E6B28C D4C7 +D4C8 D4C8 E7849E D4C8 +D4C9 D4C9 E78789 D4C9 +D4CA D4CA E8B19A D4CA +D4CB D4CB E9A093 D4CB +D4CC D4CC E4B9AD D4CC +D4CD D4CD E7AA81 D4CD +D4CE D4CE E4BB9D D4CE +D4CF D4CF E586AC D4CF +D4D0 D4D0 E5878D D4D0 +D4D1 D4D1 E58B95 D4D1 +D4D2 D4D2 E5908C D4D2 +D4D3 D4D3 E686A7 D4D3 +D4D4 D4D4 E69DB1 D4D4 +D4D5 D4D5 E6A190 D4D5 +D4D6 D4D6 E6A39F D4D6 +D4D7 D4D7 E6B49E D4D7 +D4D8 D4D8 E6BDBC D4D8 +D4D9 D4D9 E796BC D4D9 +D4DA D4DA E79EB3 D4DA +D4DB D4DB E7ABA5 D4DB +D4DC D4DC E883B4 D4DC +D4DD D4DD E891A3 D4DD +D4DE D4DE E98A85 D4DE +D4DF D4DF E5859C D4DF +D4E0 D4E0 E69697 D4E0 +D4E1 D4E1 E69D9C D4E1 +D4E2 D4E2 E69E93 D4E2 +D4E3 D4E3 E79798 D4E3 +D4E4 D4E4 E7AB87 D4E4 +D4E5 D4E5 E88DB3 D4E5 +D4E6 D4E6 EFA59A D4E6 +D4E7 D4E7 E8B186 D4E7 +D4E8 D4E8 E98097 D4E8 +D4E9 D4E9 E9A0AD D4E9 +D4EA D4EA E5B1AF D4EA +D4EB D4EB E88780 D4EB +D4EC D4EC E88A9A D4EC +D4ED D4ED E98181 D4ED +D4EE D4EE E981AF D4EE +D4EF D4EF E9888D D4EF +D4F0 D4F0 E5BE97 D4F0 +D4F1 D4F1 E5B69D D4F1 +D4F2 D4F2 E6A999 D4F2 +D4F3 D4F3 E78788 D4F3 +D4F4 D4F4 E799BB D4F4 +D4F5 D4F5 E7AD89 D4F5 +D4F6 D4F6 E897A4 D4F6 +D4F7 D4F7 E8AC84 D4F7 +D4F8 D4F8 E984A7 D4F8 +D4F9 D4F9 E9A8B0 D4F9 +D4FA D4FA E59687 D4FA +D4FB D4FB E687B6 D4FB +D4FC D4FC EFA59B D4FC +D4FD D4FD E799A9 D4FD +D4FE D4FE E7BE85 D4FE +D5A1 D5A1 E898BF D5A1 +D5A2 D5A2 E89EBA D5A2 +D5A3 D5A3 E8A3B8 D5A3 +D5A4 D5A4 E9828F D5A4 +D5A5 D5A5 EFA59C D5A5 +D5A6 D5A6 E6B49B D5A6 +D5A7 D5A7 E78399 D5A7 +D5A8 D5A8 E78F9E D5A8 +D5A9 D5A9 E7B5A1 D5A9 +D5AA D5AA E890BD D5AA +D5AB D5AB EFA59D D5AB +D5AC D5AC E985AA D5AC +D5AD D5AD E9A7B1 D5AD +D5AE D5AE EFA59E D5AE +D5AF D5AF E4BA82 D5AF +D5B0 D5B0 E58DB5 D5B0 +D5B1 D5B1 E6AC84 D5B1 +D5B2 D5B2 E6AC92 D5B2 +D5B3 D5B3 E780BE D5B3 +D5B4 D5B4 E7889B D5B4 +D5B5 D5B5 E898AD D5B5 +D5B6 D5B6 E9B89E D5B6 +D5B7 D5B7 E5898C D5B7 +D5B8 D5B8 E8BEA3 D5B8 +D5B9 D5B9 E5B590 D5B9 +D5BA D5BA E693A5 D5BA +D5BB D5BB E694AC D5BB +D5BC D5BC E6AC96 D5BC +D5BD D5BD E6BFAB D5BD +D5BE D5BE E7B183 D5BE +D5BF D5BF E7BA9C D5BF +D5C0 D5C0 E8978D D5C0 +D5C1 D5C1 E8A5A4 D5C1 +D5C2 D5C2 E8A6BD D5C2 +D5C3 D5C3 E68B89 D5C3 +D5C4 D5C4 E88798 D5C4 +D5C5 D5C5 E8A09F D5C5 +D5C6 D5C6 E5BB8A D5C6 +D5C7 D5C7 E69C97 D5C7 +D5C8 D5C8 E6B5AA D5C8 +D5C9 D5C9 E78BBC D5C9 +D5CA D5CA E79085 D5CA +D5CB D5CB E791AF D5CB +D5CC D5CC E89E82 D5CC +D5CD D5CD E9839E D5CD +D5CE D5CE E4BE86 D5CE +D5CF D5CF E5B48D D5CF +D5D0 D5D0 E5BEA0 D5D0 +D5D1 D5D1 E8908A D5D1 +D5D2 D5D2 E586B7 D5D2 +D5D3 D5D3 E68EA0 D5D3 +D5D4 D5D4 E795A5 D5D4 +D5D5 D5D5 E4BAAE D5D5 +D5D6 D5D6 E58086 D5D6 +D5D7 D5D7 E585A9 D5D7 +D5D8 D5D8 E58789 D5D8 +D5D9 D5D9 E6A281 D5D9 +D5DA D5DA E6A891 D5DA +D5DB D5DB E7B2AE D5DB +D5DC D5DC E7B2B1 D5DC +D5DD D5DD E7B3A7 D5DD +D5DE D5DE E889AF D5DE +D5DF D5DF E8AB92 D5DF +D5E0 D5E0 E8BC9B D5E0 +D5E1 D5E1 E9878F D5E1 +D5E2 D5E2 E4BEB6 D5E2 +D5E3 D5E3 E584B7 D5E3 +D5E4 D5E4 E58BB5 D5E4 +D5E5 D5E5 E59182 D5E5 +D5E6 D5E6 E5BBAC D5E6 +D5E7 D5E7 E685AE D5E7 +D5E8 D5E8 E688BE D5E8 +D5E9 D5E9 E69785 D5E9 +D5EA D5EA E6AB9A D5EA +D5EB D5EB E6BFBE D5EB +D5EC D5EC E7A4AA D5EC +D5ED D5ED E8979C D5ED +D5EE D5EE E8A0A3 D5EE +D5EF D5EF E996AD D5EF +D5F0 D5F0 E9A9A2 D5F0 +D5F1 D5F1 E9A9AA D5F1 +D5F2 D5F2 E9BA97 D5F2 +D5F3 D5F3 E9BB8E D5F3 +D5F4 D5F4 E58A9B D5F4 +D5F5 D5F5 E69B86 D5F5 +D5F6 D5F6 E6ADB7 D5F6 +D5F7 D5F7 E7809D D5F7 +D5F8 D5F8 E7A4AB D5F8 +D5F9 D5F9 E8BDA2 D5F9 +D5FA D5FA E99D82 D5FA +D5FB D5FB E68690 D5FB +D5FC D5FC E68880 D5FC +D5FD D5FD E694A3 D5FD +D5FE D5FE E6BCA3 D5FE +D6A1 D6A1 E78589 D6A1 +D6A2 D6A2 E79289 D6A2 +D6A3 D6A3 E7B7B4 D6A3 +D6A4 D6A4 E881AF D6A4 +D6A5 D6A5 E893AE D6A5 +D6A6 D6A6 E8BCA6 D6A6 +D6A7 D6A7 E980A3 D6A7 +D6A8 D6A8 E98D8A D6A8 +D6A9 D6A9 E586BD D6A9 +D6AA D6AA E58897 D6AA +D6AB D6AB E58AA3 D6AB +D6AC D6AC E6B48C D6AC +D6AD D6AD E78388 D6AD +D6AE D6AE E8A382 D6AE +D6AF D6AF E5BB89 D6AF +D6B0 D6B0 E69682 D6B0 +D6B1 D6B1 E6AEAE D6B1 +D6B2 D6B2 E6BF82 D6B2 +D6B3 D6B3 E7B0BE D6B3 +D6B4 D6B4 E78DB5 D6B4 +D6B5 D6B5 E4BBA4 D6B5 +D6B6 D6B6 E4BCB6 D6B6 +D6B7 D6B7 E59BB9 D6B7 +D6B8 D6B8 EFA59F D6B8 +D6B9 D6B9 E5B2BA D6B9 +D6BA D6BA E5B6BA D6BA +D6BB D6BB E6809C D6BB +D6BC D6BC E78EB2 D6BC +D6BD D6BD E7ACAD D6BD +D6BE D6BE E7BE9A D6BE +D6BF D6BF E7BF8E D6BF +D6C0 D6C0 E88186 D6C0 +D6C1 D6C1 E9809E D6C1 +D6C2 D6C2 E988B4 D6C2 +D6C3 D6C3 E99BB6 D6C3 +D6C4 D6C4 E99D88 D6C4 +D6C5 D6C5 E9A098 D6C5 +D6C6 D6C6 E9BDA1 D6C6 +D6C7 D6C7 E4BE8B D6C7 +D6C8 D6C8 E6BEA7 D6C8 +D6C9 D6C9 E7A6AE D6C9 +D6CA D6CA E986B4 D6CA +D6CB D6CB E99AB7 D6CB +D6CC D6CC E58B9E D6CC +D6CD D6CD EFA5A0 D6CD +D6CE D6CE E69288 D6CE +D6CF D6CF E69384 D6CF +D6D0 D6D0 E6AB93 D6D0 +D6D1 D6D1 E6BD9E D6D1 +D6D2 D6D2 E78098 D6D2 +D6D3 D6D3 E78890 D6D3 +D6D4 D6D4 E79BA7 D6D4 +D6D5 D6D5 E88081 D6D5 +D6D6 D6D6 E89886 D6D6 +D6D7 D6D7 E8999C D6D7 +D6D8 D6D8 E8B7AF D6D8 +D6D9 D6D9 E8BC85 D6D9 +D6DA D6DA E99CB2 D6DA +D6DB D6DB E9ADAF D6DB +D6DC D6DC E9B7BA D6DC +D6DD D6DD E9B9B5 D6DD +D6DE D6DE E7A28C D6DE +D6DF D6DF E7A5BF D6DF +D6E0 D6E0 E7B6A0 D6E0 +D6E1 D6E1 E88F89 D6E1 +D6E2 D6E2 E98C84 D6E2 +D6E3 D6E3 E9B9BF D6E3 +D6E4 D6E4 E9BA93 D6E4 +D6E5 D6E5 E8AB96 D6E5 +D6E6 D6E6 E5A39F D6E6 +D6E7 D6E7 E5BC84 D6E7 +D6E8 D6E8 E69CA7 D6E8 +D6E9 D6E9 E780A7 D6E9 +D6EA D6EA E7938F D6EA +D6EB D6EB E7B1A0 D6EB +D6EC D6EC E881BE D6EC +D6ED D6ED E584A1 D6ED +D6EE D6EE E780A8 D6EE +D6EF D6EF E789A2 D6EF +D6F0 D6F0 E7A38A D6F0 +D6F1 D6F1 E8B382 D6F1 +D6F2 D6F2 E8B39A D6F2 +D6F3 D6F3 E8B3B4 D6F3 +D6F4 D6F4 E99BB7 D6F4 +D6F5 D6F5 E4BA86 D6F5 +D6F6 D6F6 E5839A D6F6 +D6F7 D6F7 E5AFAE D6F7 +D6F8 D6F8 E5BB96 D6F8 +D6F9 D6F9 E69699 D6F9 +D6FA D6FA E7878E D6FA +D6FB D6FB E79982 D6FB +D6FC D6FC E79EAD D6FC +D6FD D6FD E8818A D6FD +D6FE D6FE E893BC D6FE +D7A1 D7A1 E981BC D7A1 +D7A2 D7A2 E9ACA7 D7A2 +D7A3 D7A3 E9BE8D D7A3 +D7A4 D7A4 E5A398 D7A4 +D7A5 D7A5 E5A981 D7A5 +D7A6 D7A6 E5B1A2 D7A6 +D7A7 D7A7 E6A893 D7A7 +D7A8 D7A8 E6B79A D7A8 +D7A9 D7A9 E6BC8F D7A9 +D7AA D7AA E798BB D7AA +D7AB D7AB E7B4AF D7AB +D7AC D7AC E7B8B7 D7AC +D7AD D7AD E8949E D7AD +D7AE D7AE E8A4B8 D7AE +D7AF D7AF E98FA4 D7AF +D7B0 D7B0 E9998B D7B0 +D7B1 D7B1 E58A89 D7B1 +D7B2 D7B2 E69792 D7B2 +D7B3 D7B3 E69FB3 D7B3 +D7B4 D7B4 E6A6B4 D7B4 +D7B5 D7B5 E6B581 D7B5 +D7B6 D7B6 E6BA9C D7B6 +D7B7 D7B7 E7808F D7B7 +D7B8 D7B8 E79089 D7B8 +D7B9 D7B9 E791A0 D7B9 +D7BA D7BA E79599 D7BA +D7BB D7BB E798A4 D7BB +D7BC D7BC E7A1AB D7BC +D7BD D7BD E8ACAC D7BD +D7BE D7BE E9A19E D7BE +D7BF D7BF E585AD D7BF +D7C0 D7C0 E688AE D7C0 +D7C1 D7C1 E999B8 D7C1 +D7C2 D7C2 E4BE96 D7C2 +D7C3 D7C3 E580AB D7C3 +D7C4 D7C4 E5B499 D7C4 +D7C5 D7C5 E6B7AA D7C5 +D7C6 D7C6 E7B6B8 D7C6 +D7C7 D7C7 E8BCAA D7C7 +D7C8 D7C8 E5BE8B D7C8 +D7C9 D7C9 E68584 D7C9 +D7CA D7CA E6A097 D7CA +D7CB D7CB EFA5A1 D7CB +D7CC D7CC E99A86 D7CC +D7CD D7CD E58B92 D7CD +D7CE D7CE E8828B D7CE +D7CF D7CF E5879C D7CF +D7D0 D7D0 E5878C D7D0 +D7D1 D7D1 E6A59E D7D1 +D7D2 D7D2 E7A89C D7D2 +D7D3 D7D3 E7B6BE D7D3 +D7D4 D7D4 E88FB1 D7D4 +D7D5 D7D5 E999B5 D7D5 +D7D6 D7D6 E4BF9A D7D6 +D7D7 D7D7 E588A9 D7D7 +D7D8 D7D8 E58E98 D7D8 +D7D9 D7D9 E5908F D7D9 +D7DA D7DA E5948E D7DA +D7DB D7DB E5B1A5 D7DB +D7DC D7DC E682A7 D7DC +D7DD D7DD E69D8E D7DD +D7DE D7DE E6A2A8 D7DE +D7DF D7DF E6B5AC D7DF +D7E0 D7E0 E78A81 D7E0 +D7E1 D7E1 E78BB8 D7E1 +D7E2 D7E2 E79086 D7E2 +D7E3 D7E3 E79283 D7E3 +D7E4 D7E4 EFA5A2 D7E4 +D7E5 D7E5 E797A2 D7E5 +D7E6 D7E6 E7B1AC D7E6 +D7E7 D7E7 E7BDB9 D7E7 +D7E8 D7E8 E7BEB8 D7E8 +D7E9 D7E9 E88E89 D7E9 +D7EA D7EA E8A38F D7EA +D7EB D7EB E8A3A1 D7EB +D7EC D7EC E9878C D7EC +D7ED D7ED E98790 D7ED +D7EE D7EE E99BA2 D7EE +D7EF D7EF E9AF89 D7EF +D7F0 D7F0 E5909D D7F0 +D7F1 D7F1 E6BDBE D7F1 +D7F2 D7F2 E78790 D7F2 +D7F3 D7F3 E79298 D7F3 +D7F4 D7F4 E897BA D7F4 +D7F5 D7F5 E8BAAA D7F5 +D7F6 D7F6 E99AA3 D7F6 +D7F7 D7F7 E9B197 D7F7 +D7F8 D7F8 E9BA9F D7F8 +D7F9 D7F9 E69E97 D7F9 +D7FA D7FA E6B78B D7FA +D7FB D7FB E790B3 D7FB +D7FC D7FC E887A8 D7FC +D7FD D7FD E99C96 D7FD +D7FE D7FE E7A0AC D7FE +D8A1 D8A1 E7AB8B D8A1 +D8A2 D8A2 E7ACA0 D8A2 +D8A3 D8A3 E7B292 D8A3 +D8A4 D8A4 E691A9 D8A4 +D8A5 D8A5 E791AA D8A5 +D8A6 D8A6 E797B2 D8A6 +D8A7 D8A7 E7A2BC D8A7 +D8A8 D8A8 E7A3A8 D8A8 +D8A9 D8A9 E9A6AC D8A9 +D8AA D8AA E9AD94 D8AA +D8AB D8AB E9BABB D8AB +D8AC D8AC E5AF9E D8AC +D8AD D8AD E5B995 D8AD +D8AE D8AE E6BCA0 D8AE +D8AF D8AF E8869C D8AF +D8B0 D8B0 E88EAB D8B0 +D8B1 D8B1 E98288 D8B1 +D8B2 D8B2 E4B887 D8B2 +D8B3 D8B3 E58D8D D8B3 +D8B4 D8B4 E5A8A9 D8B4 +D8B5 D8B5 E5B792 D8B5 +D8B6 D8B6 E5BD8E D8B6 +D8B7 D8B7 E685A2 D8B7 +D8B8 D8B8 E68CBD D8B8 +D8B9 D8B9 E699A9 D8B9 +D8BA D8BA E69BBC D8BA +D8BB D8BB E6BBBF D8BB +D8BC D8BC E6BCAB D8BC +D8BD D8BD E781A3 D8BD +D8BE D8BE E79E9E D8BE +D8BF D8BF E890AC D8BF +D8C0 D8C0 E89493 D8C0 +D8C1 D8C1 E8A0BB D8C1 +D8C2 D8C2 E8BC93 D8C2 +D8C3 D8C3 E9A585 D8C3 +D8C4 D8C4 E9B0BB D8C4 +D8C5 D8C5 E5949C D8C5 +D8C6 D8C6 E68AB9 D8C6 +D8C7 D8C7 E69CAB D8C7 +D8C8 D8C8 E6B2AB D8C8 +D8C9 D8C9 E88C89 D8C9 +D8CA D8CA E8A5AA D8CA +D8CB D8CB E99DBA D8CB +D8CC D8CC E4BAA1 D8CC +D8CD D8CD E5A684 D8CD +D8CE D8CE E5BF98 D8CE +D8CF D8CF E5BF99 D8CF +D8D0 D8D0 E69C9B D8D0 +D8D1 D8D1 E7B6B2 D8D1 +D8D2 D8D2 E7BD94 D8D2 +D8D3 D8D3 E88A92 D8D3 +D8D4 D8D4 E88CAB D8D4 +D8D5 D8D5 E88EBD D8D5 +D8D6 D8D6 E8BC9E D8D6 +D8D7 D8D7 E98299 D8D7 +D8D8 D8D8 E59F8B D8D8 +D8D9 D8D9 E5A6B9 D8D9 +D8DA D8DA E5AA92 D8DA +D8DB D8DB E5AF90 D8DB +D8DC D8DC E698A7 D8DC +D8DD D8DD E69E9A D8DD +D8DE D8DE E6A285 D8DE +D8DF D8DF E6AF8F D8DF +D8E0 D8E0 E785A4 D8E0 +D8E1 D8E1 E7BDB5 D8E1 +D8E2 D8E2 E8B2B7 D8E2 +D8E3 D8E3 E8B3A3 D8E3 +D8E4 D8E4 E98281 D8E4 +D8E5 D8E5 E9AD85 D8E5 +D8E6 D8E6 E88488 D8E6 +D8E7 D8E7 E8B28A D8E7 +D8E8 D8E8 E9998C D8E8 +D8E9 D8E9 E9A980 D8E9 +D8EA D8EA E9BAA5 D8EA +D8EB D8EB E5AD9F D8EB +D8EC D8EC E6B093 D8EC +D8ED D8ED E78C9B D8ED +D8EE D8EE E79BB2 D8EE +D8EF D8EF E79B9F D8EF +D8F0 D8F0 E8908C D8F0 +D8F1 D8F1 E586AA D8F1 +D8F2 D8F2 E8A693 D8F2 +D8F3 D8F3 E5858D D8F3 +D8F4 D8F4 E58695 D8F4 +D8F5 D8F5 E58B89 D8F5 +D8F6 D8F6 E6A389 D8F6 +D8F7 D8F7 E6B294 D8F7 +D8F8 D8F8 E79C84 D8F8 +D8F9 D8F9 E79CA0 D8F9 +D8FA D8FA E7B6BF D8FA +D8FB D8FB E7B7AC D8FB +D8FC D8FC E99DA2 D8FC +D8FD D8FD E9BAB5 D8FD +D8FE D8FE E6BB85 D8FE +D9A1 D9A1 E89491 D9A1 +D9A2 D9A2 E586A5 D9A2 +D9A3 D9A3 E5908D D9A3 +D9A4 D9A4 E591BD D9A4 +D9A5 D9A5 E6988E D9A5 +D9A6 D9A6 E69A9D D9A6 +D9A7 D9A7 E6A4A7 D9A7 +D9A8 D9A8 E6BA9F D9A8 +D9A9 D9A9 E79ABF D9A9 +D9AA D9AA E79E91 D9AA +D9AB D9AB E88C97 D9AB +D9AC D9AC E89382 D9AC +D9AD D9AD E89E9F D9AD +D9AE D9AE E985A9 D9AE +D9AF D9AF E98A98 D9AF +D9B0 D9B0 E9B3B4 D9B0 +D9B1 D9B1 E8A282 D9B1 +D9B2 D9B2 E4BEAE D9B2 +D9B3 D9B3 E58692 D9B3 +D9B4 D9B4 E58B9F D9B4 +D9B5 D9B5 E5A786 D9B5 +D9B6 D9B6 E5B8BD D9B6 +D9B7 D9B7 E68595 D9B7 +D9B8 D9B8 E691B8 D9B8 +D9B9 D9B9 E691B9 D9B9 +D9BA D9BA E69AAE D9BA +D9BB D9BB E69F90 D9BB +D9BC D9BC E6A8A1 D9BC +D9BD D9BD E6AF8D D9BD +D9BE D9BE E6AF9B D9BE +D9BF D9BF E7899F D9BF +D9C0 D9C0 E789A1 D9C0 +D9C1 D9C1 E79181 D9C1 +D9C2 D9C2 E79CB8 D9C2 +D9C3 D9C3 E79F9B D9C3 +D9C4 D9C4 E88097 D9C4 +D9C5 D9C5 E88ABC D9C5 +D9C6 D9C6 E88C85 D9C6 +D9C7 D9C7 E8AC80 D9C7 +D9C8 D9C8 E8ACA8 D9C8 +D9C9 D9C9 E8B28C D9C9 +D9CA D9CA E69CA8 D9CA +D9CB D9CB E6B290 D9CB +D9CC D9CC E789A7 D9CC +D9CD D9CD E79BAE D9CD +D9CE D9CE E79DA6 D9CE +D9CF D9CF E7A986 D9CF +D9D0 D9D0 E9B6A9 D9D0 +D9D1 D9D1 E6ADBF D9D1 +D9D2 D9D2 E6B292 D9D2 +D9D3 D9D3 E5A4A2 D9D3 +D9D4 D9D4 E69CA6 D9D4 +D9D5 D9D5 E89299 D9D5 +D9D6 D9D6 E58DAF D9D6 +D9D7 D9D7 E5A293 D9D7 +D9D8 D9D8 E5A699 D9D8 +D9D9 D9D9 E5BB9F D9D9 +D9DA D9DA E68F8F D9DA +D9DB D9DB E698B4 D9DB +D9DC D9DC E69DB3 D9DC +D9DD D9DD E6B8BA D9DD +D9DE D9DE E78CAB D9DE +D9DF D9DF E7AB97 D9DF +D9E0 D9E0 E88B97 D9E0 +D9E1 D9E1 E98CA8 D9E1 +D9E2 D9E2 E58B99 D9E2 +D9E3 D9E3 E5B7AB D9E3 +D9E4 D9E4 E686AE D9E4 +D9E5 D9E5 E6878B D9E5 +D9E6 D9E6 E6888A D9E6 +D9E7 D9E7 E68B87 D9E7 +D9E8 D9E8 E692AB D9E8 +D9E9 D9E9 E697A0 D9E9 +D9EA D9EA E6A599 D9EA +D9EB D9EB E6ADA6 D9EB +D9EC D9EC E6AF8B D9EC +D9ED D9ED E784A1 D9ED +D9EE D9EE E78FB7 D9EE +D9EF D9EF E7959D D9EF +D9F0 D9F0 E7B986 D9F0 +D9F1 D9F1 E8889E D9F1 +D9F2 D9F2 E88C82 D9F2 +D9F3 D9F3 E895AA D9F3 +D9F4 D9F4 E8AAA3 D9F4 +D9F5 D9F5 E8B2BF D9F5 +D9F6 D9F6 E99CA7 D9F6 +D9F7 D9F7 E9B5A1 D9F7 +D9F8 D9F8 E5A2A8 D9F8 +D9F9 D9F9 E9BB98 D9F9 +D9FA D9FA E58091 D9FA +D9FB D9FB E5888E D9FB +D9FC D9FC E590BB D9FC +D9FD D9FD E5958F D9FD +D9FE D9FE E69687 D9FE +DAA1 DAA1 E6B1B6 DAA1 +DAA2 DAA2 E7B48A DAA2 +DAA3 DAA3 E7B48B DAA3 +DAA4 DAA4 E8819E DAA4 +DAA5 DAA5 E89A8A DAA5 +DAA6 DAA6 E99680 DAA6 +DAA7 DAA7 E99BAF DAA7 +DAA8 DAA8 E58BBF DAA8 +DAA9 DAA9 E6B295 DAA9 +DAAA DAAA E789A9 DAAA +DAAB DAAB E591B3 DAAB +DAAC DAAC E5AA9A DAAC +DAAD DAAD E5B0BE DAAD +DAAE DAAE E5B58B DAAE +DAAF DAAF E5BD8C DAAF +DAB0 DAB0 E5BEAE DAB0 +DAB1 DAB1 E69CAA DAB1 +DAB2 DAB2 E6A2B6 DAB2 +DAB3 DAB3 E6A5A3 DAB3 +DAB4 DAB4 E6B8BC DAB4 +DAB5 DAB5 E6B984 DAB5 +DAB6 DAB6 E79C89 DAB6 +DAB7 DAB7 E7B1B3 DAB7 +DAB8 DAB8 E7BE8E DAB8 +DAB9 DAB9 E89687 DAB9 +DABA DABA E8AC8E DABA +DABB DABB E8BFB7 DABB +DABC DABC E99DA1 DABC +DABD DABD E9BBB4 DABD +DABE DABE E5B2B7 DABE +DABF DABF E682B6 DABF +DAC0 DAC0 E6848D DAC0 +DAC1 DAC1 E686AB DAC1 +DAC2 DAC2 E6958F DAC2 +DAC3 DAC3 E697BB DAC3 +DAC4 DAC4 E697BC DAC4 +DAC5 DAC5 E6B091 DAC5 +DAC6 DAC6 E6B3AF DAC6 +DAC7 DAC7 E78E9F DAC7 +DAC8 DAC8 E78F89 DAC8 +DAC9 DAC9 E7B7A1 DAC9 +DACA DACA E99694 DACA +DACB DACB E5AF86 DACB +DACC DACC E89C9C DACC +DACD DACD E8AC90 DACD +DACE DACE E5899D DACE +DACF DACF E58D9A DACF +DAD0 DAD0 E68B8D DAD0 +DAD1 DAD1 E6908F DAD1 +DAD2 DAD2 E692B2 DAD2 +DAD3 DAD3 E69CB4 DAD3 +DAD4 DAD4 E6A8B8 DAD4 +DAD5 DAD5 E6B38A DAD5 +DAD6 DAD6 E78F80 DAD6 +DAD7 DAD7 E7929E DAD7 +DAD8 DAD8 E7AE94 DAD8 +DAD9 DAD9 E7B295 DAD9 +DADA DADA E7B89B DADA +DADB DADB E8868A DADB +DADC DADC E888B6 DADC +DADD DADD E89684 DADD +DADE DADE E8BFAB DADE +DADF DADF E99BB9 DADF +DAE0 DAE0 E9A781 DAE0 +DAE1 DAE1 E4BCB4 DAE1 +DAE2 DAE2 E58D8A DAE2 +DAE3 DAE3 E58F8D DAE3 +DAE4 DAE4 E58F9B DAE4 +DAE5 DAE5 E68B8C DAE5 +DAE6 DAE6 E690AC DAE6 +DAE7 DAE7 E69480 DAE7 +DAE8 DAE8 E69691 DAE8 +DAE9 DAE9 E6A783 DAE9 +DAEA DAEA E6B3AE DAEA +DAEB DAEB E6BD98 DAEB +DAEC DAEC E78FAD DAEC +DAED DAED E79594 DAED +DAEE DAEE E798A2 DAEE +DAEF DAEF E79BA4 DAEF +DAF0 DAF0 E79BBC DAF0 +DAF1 DAF1 E7A390 DAF1 +DAF2 DAF2 E7A3BB DAF2 +DAF3 DAF3 E7A4AC DAF3 +DAF4 DAF4 E7B586 DAF4 +DAF5 DAF5 E888AC DAF5 +DAF6 DAF6 E89FA0 DAF6 +DAF7 DAF7 E8BF94 DAF7 +DAF8 DAF8 E9A092 DAF8 +DAF9 DAF9 E9A3AF DAF9 +DAFA DAFA E58B83 DAFA +DAFB DAFB E68B94 DAFB +DAFC DAFC E692A5 DAFC +DAFD DAFD E6B8A4 DAFD +DAFE DAFE E6BD91 DAFE +DBA1 DBA1 E799BC DBA1 +DBA2 DBA2 E8B78B DBA2 +DBA3 DBA3 E986B1 DBA3 +DBA4 DBA4 E989A2 DBA4 +DBA5 DBA5 E9ABAE DBA5 +DBA6 DBA6 E9AD83 DBA6 +DBA7 DBA7 E580A3 DBA7 +DBA8 DBA8 E5828D DBA8 +DBA9 DBA9 E59D8A DBA9 +DBAA DBAA E5A6A8 DBAA +DBAB DBAB E5B0A8 DBAB +DBAC DBAC E5B987 DBAC +DBAD DBAD E5BDB7 DBAD +DBAE DBAE E688BF DBAE +DBAF DBAF E694BE DBAF +DBB0 DBB0 E696B9 DBB0 +DBB1 DBB1 E69781 DBB1 +DBB2 DBB2 E69889 DBB2 +DBB3 DBB3 E69E8B DBB3 +DBB4 DBB4 E6A69C DBB4 +DBB5 DBB5 E6BB82 DBB5 +DBB6 DBB6 E7A385 DBB6 +DBB7 DBB7 E7B4A1 DBB7 +DBB8 DBB8 E882AA DBB8 +DBB9 DBB9 E88680 DBB9 +DBBA DBBA E888AB DBBA +DBBB DBBB E88AB3 DBBB +DBBC DBBC E892A1 DBBC +DBBD DBBD E89A8C DBBD +DBBE DBBE E8A8AA DBBE +DBBF DBBF E8AC97 DBBF +DBC0 DBC0 E982A6 DBC0 +DBC1 DBC1 E998B2 DBC1 +DBC2 DBC2 E9BE90 DBC2 +DBC3 DBC3 E5808D DBC3 +DBC4 DBC4 E4BFB3 DBC4 +DBC5 DBC5 EFA5A3 DBC5 +DBC6 DBC6 E59FB9 DBC6 +DBC7 DBC7 E5BE98 DBC7 +DBC8 DBC8 E68B9C DBC8 +DBC9 DBC9 E68E92 DBC9 +DBCA DBCA E69DAF DBCA +DBCB DBCB E6B983 DBCB +DBCC DBCC E78499 DBCC +DBCD DBCD E79B83 DBCD +DBCE DBCE E8838C DBCE +DBCF DBCF E8839A DBCF +DBD0 DBD0 E8A3B4 DBD0 +DBD1 DBD1 E8A3B5 DBD1 +DBD2 DBD2 E8A499 DBD2 +DBD3 DBD3 E8B3A0 DBD3 +DBD4 DBD4 E8BCA9 DBD4 +DBD5 DBD5 E9858D DBD5 +DBD6 DBD6 E999AA DBD6 +DBD7 DBD7 E4BCAF DBD7 +DBD8 DBD8 E4BDB0 DBD8 +DBD9 DBD9 E5B89B DBD9 +DBDA DBDA E69F8F DBDA +DBDB DBDB E6A0A2 DBDB +DBDC DBDC E799BD DBDC +DBDD DBDD E799BE DBDD +DBDE DBDE E9AD84 DBDE +DBDF DBDF E5B9A1 DBDF +DBE0 DBE0 E6A88A DBE0 +DBE1 DBE1 E785A9 DBE1 +DBE2 DBE2 E78794 DBE2 +DBE3 DBE3 E795AA DBE3 +DBE4 DBE4 EFA5A4 DBE4 +DBE5 DBE5 E7B981 DBE5 +DBE6 DBE6 E89583 DBE6 +DBE7 DBE7 E897A9 DBE7 +DBE8 DBE8 E9A39C DBE8 +DBE9 DBE9 E4BC90 DBE9 +DBEA DBEA E7AD8F DBEA +DBEB DBEB E7BDB0 DBEB +DBEC DBEC E996A5 DBEC +DBED DBED E587A1 DBED +DBEE DBEE E5B886 DBEE +DBEF DBEF E6A2B5 DBEF +DBF0 DBF0 E6B0BE DBF0 +DBF1 DBF1 E6B18E DBF1 +DBF2 DBF2 E6B39B DBF2 +DBF3 DBF3 E78AAF DBF3 +DBF4 DBF4 E7AF84 DBF4 +DBF5 DBF5 E88C83 DBF5 +DBF6 DBF6 E6B395 DBF6 +DBF7 DBF7 E790BA DBF7 +DBF8 DBF8 E583BB DBF8 +DBF9 DBF9 E58A88 DBF9 +DBFA DBFA E5A381 DBFA +DBFB DBFB E69398 DBFB +DBFC DBFC E6AA97 DBFC +DBFD DBFD E792A7 DBFD +DBFE DBFE E79996 DBFE +DCA1 DCA1 E7A2A7 DCA1 +DCA2 DCA2 E89897 DCA2 +DCA3 DCA3 E997A2 DCA3 +DCA4 DCA4 E99CB9 DCA4 +DCA5 DCA5 EFA5A5 DCA5 +DCA6 DCA6 E58D9E DCA6 +DCA7 DCA7 E5BC81 DCA7 +DCA8 DCA8 E8AE8A DCA8 +DCA9 DCA9 E8BEA8 DCA9 +DCAA DCAA E8BEAF DCAA +DCAB DCAB E9828A DCAB +DCAC DCAC E588A5 DCAC +DCAD DCAD E79EA5 DCAD +DCAE DCAE E9B189 DCAE +DCAF DCAF E9BC88 DCAF +DCB0 DCB0 E4B899 DCB0 +DCB1 DCB1 E58082 DCB1 +DCB2 DCB2 E585B5 DCB2 +DCB3 DCB3 E5B19B DCB3 +DCB4 DCB4 E5B9B7 DCB4 +DCB5 DCB5 E6989E DCB5 +DCB6 DCB6 E698BA DCB6 +DCB7 DCB7 E69F84 DCB7 +DCB8 DCB8 E6A385 DCB8 +DCB9 DCB9 E782B3 DCB9 +DCBA DCBA E79481 DCBA +DCBB DCBB E79785 DCBB +DCBC DCBC E7A789 DCBC +DCBD DCBD E7AB9D DCBD +DCBE DCBE E8BCA7 DCBE +DCBF DCBF E9A4A0 DCBF +DCC0 DCC0 E9A888 DCC0 +DCC1 DCC1 E4BF9D DCC1 +DCC2 DCC2 E5A0A1 DCC2 +DCC3 DCC3 E5A0B1 DCC3 +DCC4 DCC4 E5AFB6 DCC4 +DCC5 DCC5 E699AE DCC5 +DCC6 DCC6 E6ADA5 DCC6 +DCC7 DCC7 E6B491 DCC7 +DCC8 DCC8 E6B9BA DCC8 +DCC9 DCC9 E6BDBD DCC9 +DCCA DCCA E78FA4 DCCA +DCCB DCCB E794AB DCCB +DCCC DCCC E88FA9 DCCC +DCCD DCCD E8A39C DCCD +DCCE DCCE E8A493 DCCE +DCCF DCCF E8AD9C DCCF +DCD0 DCD0 E8BC94 DCD0 +DCD1 DCD1 E4BC8F DCD1 +DCD2 DCD2 E58395 DCD2 +DCD3 DCD3 E58C90 DCD3 +DCD4 DCD4 E58D9C DCD4 +DCD5 DCD5 E5AE93 DCD5 +DCD6 DCD6 E5BEA9 DCD6 +DCD7 DCD7 E69C8D DCD7 +DCD8 DCD8 E7A68F DCD8 +DCD9 DCD9 E885B9 DCD9 +DCDA DCDA E88CAF DCDA +DCDB DCDB E89494 DCDB +DCDC DCDC E8A487 DCDC +DCDD DCDD E8A686 DCDD +DCDE DCDE E8BCB9 DCDE +DCDF DCDF E8BCBB DCDF +DCE0 DCE0 E9A6A5 DCE0 +DCE1 DCE1 E9B092 DCE1 +DCE2 DCE2 E69CAC DCE2 +DCE3 DCE3 E4B9B6 DCE3 +DCE4 DCE4 E4BFB8 DCE4 +DCE5 DCE5 E5A589 DCE5 +DCE6 DCE6 E5B081 DCE6 +DCE7 DCE7 E5B3AF DCE7 +DCE8 DCE8 E5B3B0 DCE8 +DCE9 DCE9 E68DA7 DCE9 +DCEA DCEA E6A392 DCEA +DCEB DCEB E783BD DCEB +DCEC DCEC E786A2 DCEC +DCED DCED E790AB DCED +DCEE DCEE E7B8AB DCEE +DCEF DCEF E893AC DCEF +DCF0 DCF0 E89C82 DCF0 +DCF1 DCF1 E980A2 DCF1 +DCF2 DCF2 E98B92 DCF2 +DCF3 DCF3 E9B3B3 DCF3 +DCF4 DCF4 E4B88D DCF4 +DCF5 DCF5 E4BB98 DCF5 +DCF6 DCF6 E4BFAF DCF6 +DCF7 DCF7 E58285 DCF7 +DCF8 DCF8 E58996 DCF8 +DCF9 DCF9 E589AF DCF9 +DCFA DCFA E590A6 DCFA +DCFB DCFB E59290 DCFB +DCFC DCFC E59FA0 DCFC +DCFD DCFD E5A4AB DCFD +DCFE DCFE E5A9A6 DCFE +DDA1 DDA1 E5AD9A DDA1 +DDA2 DDA2 E5ADB5 DDA2 +DDA3 DDA3 E5AF8C DDA3 +DDA4 DDA4 E5BA9C DDA4 +DDA5 DDA5 EFA5A6 DDA5 +DDA6 DDA6 E689B6 DDA6 +DDA7 DDA7 E695B7 DDA7 +DDA8 DDA8 E696A7 DDA8 +DDA9 DDA9 E6B5AE DDA9 +DDAA DDAA E6BAA5 DDAA +DDAB DDAB E788B6 DDAB +DDAC DDAC E7ACA6 DDAC +DDAD DDAD E7B0BF DDAD +DDAE DDAE E7BCB6 DDAE +DDAF DDAF E88590 DDAF +DDB0 DDB0 E88591 DDB0 +DDB1 DDB1 E8869A DDB1 +DDB2 DDB2 E88980 DDB2 +DDB3 DDB3 E88A99 DDB3 +DDB4 DDB4 E88EA9 DDB4 +DDB5 DDB5 E8A883 DDB5 +DDB6 DDB6 E8B2A0 DDB6 +DDB7 DDB7 E8B3A6 DDB7 +DDB8 DDB8 E8B3BB DDB8 +DDB9 DDB9 E8B5B4 DDB9 +DDBA DDBA E8B6BA DDBA +DDBB DDBB E983A8 DDBB +DDBC DDBC E9879C DDBC +DDBD DDBD E9989C DDBD +DDBE DDBE E99984 DDBE +DDBF DDBF E9A799 DDBF +DDC0 DDC0 E9B3A7 DDC0 +DDC1 DDC1 E58C97 DDC1 +DDC2 DDC2 E58886 DDC2 +DDC3 DDC3 E590A9 DDC3 +DDC4 DDC4 E599B4 DDC4 +DDC5 DDC5 E5A2B3 DDC5 +DDC6 DDC6 E5A594 DDC6 +DDC7 DDC7 E5A5AE DDC7 +DDC8 DDC8 E5BFBF DDC8 +DDC9 DDC9 E686A4 DDC9 +DDCA DDCA E689AE DDCA +DDCB DDCB E69890 DDCB +DDCC DDCC E6B1BE DDCC +DDCD DDCD E7849A DDCD +DDCE DDCE E79B86 DDCE +DDCF DDCF E7B289 DDCF +DDD0 DDD0 E7B39E DDD0 +DDD1 DDD1 E7B49B DDD1 +DDD2 DDD2 E88AAC DDD2 +DDD3 DDD3 E8B381 DDD3 +DDD4 DDD4 E99BB0 DDD4 +DDD5 DDD5 EFA5A7 DDD5 +DDD6 DDD6 E4BD9B DDD6 +DDD7 DDD7 E5BC97 DDD7 +DDD8 DDD8 E5BDBF DDD8 +DDD9 DDD9 E68B82 DDD9 +DDDA DDDA E5B4A9 DDDA +DDDB DDDB E69C8B DDDB +DDDC DDDC E6A39A DDDC +DDDD DDDD E7A1BC DDDD +DDDE DDDE E7B983 DDDE +DDDF DDDF E9B5AC DDDF +DDE0 DDE0 E4B895 DDE0 +DDE1 DDE1 E58299 DDE1 +DDE2 DDE2 E58C95 DDE2 +DDE3 DDE3 E58CAA DDE3 +DDE4 DDE4 E58D91 DDE4 +DDE5 DDE5 E5A683 DDE5 +DDE6 DDE6 E5A9A2 DDE6 +DDE7 DDE7 E5BA87 DDE7 +DDE8 DDE8 E682B2 DDE8 +DDE9 DDE9 E6868A DDE9 +DDEA DDEA E68989 DDEA +DDEB DDEB E689B9 DDEB +DDEC DDEC E69690 DDEC +DDED DDED E69E87 DDED +DDEE DDEE E6A6A7 DDEE +DDEF DDEF E6AF94 DDEF +DDF0 DDF0 E6AF96 DDF0 +DDF1 DDF1 E6AF97 DDF1 +DDF2 DDF2 E6AF98 DDF2 +DDF3 DDF3 E6B2B8 DDF3 +DDF4 DDF4 EFA5A8 DDF4 +DDF5 DDF5 E790B5 DDF5 +DDF6 DDF6 E797BA DDF6 +DDF7 DDF7 E7A092 DDF7 +DDF8 DDF8 E7A291 DDF8 +DDF9 DDF9 E7A795 DDF9 +DDFA DDFA E7A798 DDFA +DDFB DDFB E7B283 DDFB +DDFC DDFC E7B78B DDFC +DDFD DDFD E7BFA1 DDFD +DDFE DDFE E882A5 DDFE +DEA1 DEA1 E884BE DEA1 +DEA2 DEA2 E88782 DEA2 +DEA3 DEA3 E88FB2 DEA3 +DEA4 DEA4 E89C9A DEA4 +DEA5 DEA5 E8A3A8 DEA5 +DEA6 DEA6 E8AAB9 DEA6 +DEA7 DEA7 E8ADAC DEA7 +DEA8 DEA8 E8B2BB DEA8 +DEA9 DEA9 E98499 DEA9 +DEAA DEAA E99D9E DEAA +DEAB DEAB E9A39B DEAB +DEAC DEAC E9BCBB DEAC +DEAD DEAD E59AAC DEAD +DEAE DEAE E5ACAA DEAE +DEAF DEAF E5BDAC DEAF +DEB0 DEB0 E6968C DEB0 +DEB1 DEB1 E6AAB3 DEB1 +DEB2 DEB2 E6AEAF DEB2 +DEB3 DEB3 E6B59C DEB3 +DEB4 DEB4 E6BFB1 DEB4 +DEB5 DEB5 E78095 DEB5 +DEB6 DEB6 E7899D DEB6 +DEB7 DEB7 E78EAD DEB7 +DEB8 DEB8 E8B2A7 DEB8 +DEB9 DEB9 E8B393 DEB9 +DEBA DEBA E9A0BB DEBA +DEBB DEBB E68691 DEBB +DEBC DEBC E6B0B7 DEBC +DEBD DEBD E88198 DEBD +DEBE DEBE E9A881 DEBE +DEBF DEBF E4B98D DEBF +DEC0 DEC0 E4BA8B DEC0 +DEC1 DEC1 E4BA9B DEC1 +DEC2 DEC2 E4BB95 DEC2 +DEC3 DEC3 E4BCBA DEC3 +DEC4 DEC4 E4BCBC DEC4 +DEC5 DEC5 E4BDBF DEC5 +DEC6 DEC6 E4BF9F DEC6 +DEC7 DEC7 E583BF DEC7 +DEC8 DEC8 E58FB2 DEC8 +DEC9 DEC9 E58FB8 DEC9 +DECA DECA E59486 DECA +DECB DECB E597A3 DECB +DECC DECC E59B9B DECC +DECD DECD E5A3AB DECD +DECE DECE E5A5A2 DECE +DECF DECF E5A891 DECF +DED0 DED0 E5AFAB DED0 +DED1 DED1 E5AFBA DED1 +DED2 DED2 E5B084 DED2 +DED3 DED3 E5B7B3 DED3 +DED4 DED4 E5B8AB DED4 +DED5 DED5 E5BE99 DED5 +DED6 DED6 E6809D DED6 +DED7 DED7 E68DA8 DED7 +DED8 DED8 E6969C DED8 +DED9 DED9 E696AF DED9 +DEDA DEDA E69FB6 DEDA +DEDB DEDB E69FBB DEDB +DEDC DEDC E6A2AD DEDC +DEDD DEDD E6ADBB DEDD +DEDE DEDE E6B299 DEDE +DEDF DEDF E6B397 DEDF +DEE0 DEE0 E6B8A3 DEE0 +DEE1 DEE1 E78089 DEE1 +DEE2 DEE2 E78D85 DEE2 +DEE3 DEE3 E7A082 DEE3 +DEE4 DEE4 E7A4BE DEE4 +DEE5 DEE5 E7A580 DEE5 +DEE6 DEE6 E7A5A0 DEE6 +DEE7 DEE7 E7A781 DEE7 +DEE8 DEE8 E7AFA9 DEE8 +DEE9 DEE9 E7B497 DEE9 +DEEA DEEA E7B5B2 DEEA +DEEB DEEB E88286 DEEB +DEEC DEEC E8888D DEEC +DEED DEED E88E8E DEED +DEEE DEEE E89391 DEEE +DEEF DEEF E89B87 DEEF +DEF0 DEF0 E8A39F DEF0 +DEF1 DEF1 E8A990 DEF1 +DEF2 DEF2 E8A99E DEF2 +DEF3 DEF3 E8AC9D DEF3 +DEF4 DEF4 E8B39C DEF4 +DEF5 DEF5 E8B5A6 DEF5 +DEF6 DEF6 E8BEAD DEF6 +DEF7 DEF7 E982AA DEF7 +DEF8 DEF8 E9A3BC DEF8 +DEF9 DEF9 E9A79F DEF9 +DEFA DEFA E9BA9D DEFA +DEFB DEFB E5898A DEFB +DEFC DEFC EFA5A9 DEFC +DEFD DEFD E69C94 DEFD +DEFE DEFE EFA5AA DEFE +DFA1 DFA1 E58298 DFA1 +DFA2 DFA2 E588AA DFA2 +DFA3 DFA3 E5B1B1 DFA3 +DFA4 DFA4 E695A3 DFA4 +DFA5 DFA5 E6B195 DFA5 +DFA6 DFA6 E78F8A DFA6 +DFA7 DFA7 E794A3 DFA7 +DFA8 DFA8 E7969D DFA8 +DFA9 DFA9 E7AE97 DFA9 +DFAA DFAA E8929C DFAA +DFAB DFAB E985B8 DFAB +DFAC DFAC E99CB0 DFAC +DFAD DFAD E4B9B7 DFAD +DFAE DFAE E69292 DFAE +DFAF DFAF E6AEBA DFAF +DFB0 DFB0 E7859E DFB0 +DFB1 DFB1 E896A9 DFB1 +DFB2 DFB2 E4B889 DFB2 +DFB3 DFB3 EFA5AB DFB3 +DFB4 DFB4 E69D89 DFB4 +DFB5 DFB5 E6A3AE DFB5 +DFB6 DFB6 E6B897 DFB6 +DFB7 DFB7 E88A9F DFB7 +DFB8 DFB8 E89498 DFB8 +DFB9 DFB9 E8A1AB DFB9 +DFBA DFBA E68FB7 DFBA +DFBB DFBB E6BE81 DFBB +DFBC DFBC E98892 DFBC +DFBD DFBD E9A2AF DFBD +DFBE DFBE E4B88A DFBE +DFBF DFBF E582B7 DFBF +DFC0 DFC0 E5838F DFC0 +DFC1 DFC1 E5849F DFC1 +DFC2 DFC2 E59586 DFC2 +DFC3 DFC3 E596AA DFC3 +DFC4 DFC4 E59897 DFC4 +DFC5 DFC5 E5AD80 DFC5 +DFC6 DFC6 E5B099 DFC6 +DFC7 DFC7 E5B3A0 DFC7 +DFC8 DFC8 E5B8B8 DFC8 +DFC9 DFC9 E5BA8A DFC9 +DFCA DFCA E5BAA0 DFCA +DFCB DFCB E5BB82 DFCB +DFCC DFCC E683B3 DFCC +DFCD DFCD E6A191 DFCD +DFCE DFCE E6A9A1 DFCE +DFCF DFCF E6B998 DFCF +DFD0 DFD0 E788BD DFD0 +DFD1 DFD1 E78980 DFD1 +DFD2 DFD2 E78B80 DFD2 +DFD3 DFD3 E79BB8 DFD3 +DFD4 DFD4 E7A5A5 DFD4 +DFD5 DFD5 E7AEB1 DFD5 +DFD6 DFD6 E7BF94 DFD6 +DFD7 DFD7 E8A3B3 DFD7 +DFD8 DFD8 E8A7B4 DFD8 +DFD9 DFD9 E8A9B3 DFD9 +DFDA DFDA E8B1A1 DFDA +DFDB DFDB E8B39E DFDB +DFDC DFDC E99C9C DFDC +DFDD DFDD E5A19E DFDD +DFDE DFDE E792BD DFDE +DFDF DFDF E8B3BD DFDF +DFE0 DFE0 E59787 DFE0 +DFE1 DFE1 EFA5AC DFE1 +DFE2 DFE2 E7A9A1 DFE2 +DFE3 DFE3 E7B4A2 DFE3 +DFE4 DFE4 E889B2 DFE4 +DFE5 DFE5 E789B2 DFE5 +DFE6 DFE6 E7949F DFE6 +DFE7 DFE7 E794A5 DFE7 +DFE8 DFE8 EFA5AD DFE8 +DFE9 DFE9 E7AC99 DFE9 +DFEA DFEA E5A285 DFEA +DFEB DFEB E5A3BB DFEB +DFEC DFEC E5B6BC DFEC +DFED DFED E5BA8F DFED +DFEE DFEE E5BAB6 DFEE +DFEF DFEF E5BE90 DFEF +DFF0 DFF0 E68195 DFF0 +DFF1 DFF1 E68A92 DFF1 +DFF2 DFF2 E68DBF DFF2 +DFF3 DFF3 E6958D DFF3 +DFF4 DFF4 E69A91 DFF4 +DFF5 DFF5 E69B99 DFF5 +DFF6 DFF6 E69BB8 DFF6 +DFF7 DFF7 E6A096 DFF7 +DFF8 DFF8 E6A3B2 DFF8 +DFF9 DFF9 E78A80 DFF9 +DFFA DFFA E7919E DFFA +DFFB DFFB E7ADAE DFFB +DFFC DFFC E7B5AE DFFC +DFFD DFFD E7B796 DFFD +DFFE DFFE E7BDB2 DFFE +E0A1 E0A1 E883A5 E0A1 +E0A2 E0A2 E88892 E0A2 +E0A3 E0A3 E896AF E0A3 +E0A4 E0A4 E8A5BF E0A4 +E0A5 E0A5 E8AA93 E0A5 +E0A6 E0A6 E9809D E0A6 +E0A7 E0A7 E98BA4 E0A7 +E0A8 E0A8 E9BB8D E0A8 +E0A9 E0A9 E9BCA0 E0A9 +E0AA E0AA E5A495 E0AA +E0AB E0AB E5A5AD E0AB +E0AC E0AC E5B8AD E0AC +E0AD E0AD E6839C E0AD +E0AE E0AE E69894 E0AE +E0AF E0AF E699B3 E0AF +E0B0 E0B0 E69E90 E0B0 +E0B1 E0B1 E6B190 E0B1 +E0B2 E0B2 E6B785 E0B2 +E0B3 E0B3 E6BD9F E0B3 +E0B4 E0B4 E79FB3 E0B4 +E0B5 E0B5 E7A2A9 E0B5 +E0B6 E0B6 E89386 E0B6 +E0B7 E0B7 E9878B E0B7 +E0B8 E0B8 E98CAB E0B8 +E0B9 E0B9 E4BB99 E0B9 +E0BA E0BA E5838A E0BA +E0BB E0BB E58588 E0BB +E0BC E0BC E59684 E0BC +E0BD E0BD E5AC8B E0BD +E0BE E0BE E5AEA3 E0BE +E0BF E0BF E68987 E0BF +E0C0 E0C0 E695BE E0C0 +E0C1 E0C1 E6978B E0C1 +E0C2 E0C2 E6B8B2 E0C2 +E0C3 E0C3 E785BD E0C3 +E0C4 E0C4 E79081 E0C4 +E0C5 E0C5 E79184 E0C5 +E0C6 E0C6 E79287 E0C6 +E0C7 E0C7 E792BF E0C7 +E0C8 E0C8 E799AC E0C8 +E0C9 E0C9 E7A6AA E0C9 +E0CA E0CA E7B79A E0CA +E0CB E0CB E7B995 E0CB +E0CC E0CC E7BEA8 E0CC +E0CD E0CD E885BA E0CD +E0CE E0CE E886B3 E0CE +E0CF E0CF E888B9 E0CF +E0D0 E0D0 E8989A E0D0 +E0D1 E0D1 E89FAC E0D1 +E0D2 E0D2 E8A9B5 E0D2 +E0D3 E0D3 E8B7A3 E0D3 +E0D4 E0D4 E981B8 E0D4 +E0D5 E0D5 E98A91 E0D5 +E0D6 E0D6 E990A5 E0D6 +E0D7 E0D7 E9A58D E0D7 +E0D8 E0D8 E9AEAE E0D8 +E0D9 E0D9 E58DA8 E0D9 +E0DA E0DA E5B191 E0DA +E0DB E0DB E6A594 E0DB +E0DC E0DC E6B384 E0DC +E0DD E0DD E6B4A9 E0DD +E0DE E0DE E6B8AB E0DE +E0DF E0DF E8888C E0DF +E0E0 E0E0 E8969B E0E0 +E0E1 E0E1 E8A4BB E0E1 +E0E2 E0E2 E8A8AD E0E2 +E0E3 E0E3 E8AAAA E0E3 +E0E4 E0E4 E99BAA E0E4 +E0E5 E0E5 E9BDA7 E0E5 +E0E6 E0E6 E589A1 E0E6 +E0E7 E0E7 E69AB9 E0E7 +E0E8 E0E8 E6AEB2 E0E8 +E0E9 E0E9 E7BA96 E0E9 +E0EA E0EA E89FBE E0EA +E0EB E0EB E8B48D E0EB +E0EC E0EC E99683 E0EC +E0ED E0ED E9999D E0ED +E0EE E0EE E6949D E0EE +E0EF E0EF E6B689 E0EF +E0F0 E0F0 E787AE E0F0 +E0F1 E0F1 EFA5AE E0F1 +E0F2 E0F2 E59F8E E0F2 +E0F3 E0F3 E5A793 E0F3 +E0F4 E0F4 E5AEAC E0F4 +E0F5 E0F5 E680A7 E0F5 +E0F6 E0F6 E683BA E0F6 +E0F7 E0F7 E68890 E0F7 +E0F8 E0F8 E6989F E0F8 +E0F9 E0F9 E6999F E0F9 +E0FA E0FA E78CA9 E0FA +E0FB E0FB E78FB9 E0FB +E0FC E0FC E79B9B E0FC +E0FD E0FD E79C81 E0FD +E0FE E0FE E7ADAC E0FE +E1A1 E1A1 E88196 E1A1 +E1A2 E1A2 E881B2 E1A2 +E1A3 E1A3 E885A5 E1A3 +E1A4 E1A4 E8AAA0 E1A4 +E1A5 E1A5 E98692 E1A5 +E1A6 E1A6 E4B896 E1A6 +E1A7 E1A7 E58BA2 E1A7 +E1A8 E1A8 E6ADB2 E1A8 +E1A9 E1A9 E6B497 E1A9 +E1AA E1AA E7A885 E1AA +E1AB E1AB E7ACB9 E1AB +E1AC E1AC E7B4B0 E1AC +E1AD E1AD EFA5AF E1AD +E1AE E1AE E8B2B0 E1AE +E1AF E1AF E58FAC E1AF +E1B0 E1B0 E598AF E1B0 +E1B1 E1B1 E5A191 E1B1 +E1B2 E1B2 E5AEB5 E1B2 +E1B3 E1B3 E5B08F E1B3 +E1B4 E1B4 E5B091 E1B4 +E1B5 E1B5 E5B7A2 E1B5 +E1B6 E1B6 E68980 E1B6 +E1B7 E1B7 E68E83 E1B7 +E1B8 E1B8 E69094 E1B8 +E1B9 E1B9 E698AD E1B9 +E1BA E1BA E6A2B3 E1BA +E1BB E1BB E6B2BC E1BB +E1BC E1BC E6B688 E1BC +E1BD E1BD E6BAAF E1BD +E1BE E1BE E7809F E1BE +E1BF E1BF E782A4 E1BF +E1C0 E1C0 E78792 E1C0 +E1C1 E1C1 E794A6 E1C1 +E1C2 E1C2 E7968F E1C2 +E1C3 E1C3 E7968E E1C3 +E1C4 E1C4 E79899 E1C4 +E1C5 E1C5 E7AC91 E1C5 +E1C6 E1C6 E7AFA0 E1C6 +E1C7 E1C7 E7B0AB E1C7 +E1C8 E1C8 E7B4A0 E1C8 +E1C9 E1C9 E7B4B9 E1C9 +E1CA E1CA E894AC E1CA +E1CB E1CB E895AD E1CB +E1CC E1CC E89887 E1CC +E1CD E1CD E8A8B4 E1CD +E1CE E1CE E9808D E1CE +E1CF E1CF E981A1 E1CF +E1D0 E1D0 E982B5 E1D0 +E1D1 E1D1 E98AB7 E1D1 +E1D2 E1D2 E99FB6 E1D2 +E1D3 E1D3 E9A8B7 E1D3 +E1D4 E1D4 E4BF97 E1D4 +E1D5 E1D5 E5B1AC E1D5 +E1D6 E1D6 E69D9F E1D6 +E1D7 E1D7 E6B691 E1D7 +E1D8 E1D8 E7B29F E1D8 +E1D9 E1D9 E7BA8C E1D9 +E1DA E1DA E8AC96 E1DA +E1DB E1DB E8B496 E1DB +E1DC E1DC E9809F E1DC +E1DD E1DD E5ADAB E1DD +E1DE E1DE E5B7BD E1DE +E1DF E1DF E6908D E1DF +E1E0 E1E0 E89380 E1E0 +E1E1 E1E1 E9819C E1E1 +E1E2 E1E2 E9A3A1 E1E2 +E1E3 E1E3 E78E87 E1E3 +E1E4 E1E4 E5AE8B E1E4 +E1E5 E1E5 E6829A E1E5 +E1E6 E1E6 E69DBE E1E6 +E1E7 E1E7 E6B79E E1E7 +E1E8 E1E8 E8A89F E1E8 +E1E9 E1E9 E8AAA6 E1E9 +E1EA E1EA E98081 E1EA +E1EB E1EB E9A08C E1EB +E1EC E1EC E588B7 E1EC +E1ED E1ED EFA5B0 E1ED +E1EE E1EE E78191 E1EE +E1EF E1EF E7A28E E1EF +E1F0 E1F0 E98E96 E1F0 +E1F1 E1F1 E8A1B0 E1F1 +E1F2 E1F2 E98797 E1F2 +E1F3 E1F3 E4BFAE E1F3 +E1F4 E1F4 E58F97 E1F4 +E1F5 E1F5 E597BD E1F5 +E1F6 E1F6 E59B9A E1F6 +E1F7 E1F7 E59E82 E1F7 +E1F8 E1F8 E5A3BD E1F8 +E1F9 E1F9 E5AB82 E1F9 +E1FA E1FA E5AE88 E1FA +E1FB E1FB E5B2AB E1FB +E1FC E1FC E5B380 E1FC +E1FD E1FD E5B8A5 E1FD +E1FE E1FE E68481 E1FE +E2A1 E2A1 E6888D E2A1 +E2A2 E2A2 E6898B E2A2 +E2A3 E2A3 E68E88 E2A3 +E2A4 E2A4 E6909C E2A4 +E2A5 E2A5 E694B6 E2A5 +E2A6 E2A6 E695B8 E2A6 +E2A7 E2A7 E6A8B9 E2A7 +E2A8 E2A8 E6AE8A E2A8 +E2A9 E2A9 E6B0B4 E2A9 +E2AA E2AA E6B499 E2AA +E2AB E2AB E6BCB1 E2AB +E2AC E2AC E787A7 E2AC +E2AD E2AD E78BA9 E2AD +E2AE E2AE E78DB8 E2AE +E2AF E2AF E79087 E2AF +E2B0 E2B0 E792B2 E2B0 +E2B1 E2B1 E798A6 E2B1 +E2B2 E2B2 E79DA1 E2B2 +E2B3 E2B3 E7A780 E2B3 +E2B4 E2B4 E7A997 E2B4 +E2B5 E2B5 E7ABAA E2B5 +E2B6 E2B6 E7B2B9 E2B6 +E2B7 E2B7 E7B68F E2B7 +E2B8 E2B8 E7B6AC E2B8 +E2B9 E2B9 E7B9A1 E2B9 +E2BA E2BA E7BE9E E2BA +E2BB E2BB E884A9 E2BB +E2BC E2BC E88CB1 E2BC +E2BD E2BD E89290 E2BD +E2BE E2BE E8939A E2BE +E2BF E2BF E897AA E2BF +E2C0 E2C0 E8A296 E2C0 +E2C1 E2C1 E8AAB0 E2C1 +E2C2 E2C2 E8AE90 E2C2 +E2C3 E2C3 E8BCB8 E2C3 +E2C4 E2C4 E98182 E2C4 +E2C5 E2C5 E98283 E2C5 +E2C6 E2C6 E985AC E2C6 +E2C7 E2C7 E98A96 E2C7 +E2C8 E2C8 E98AB9 E2C8 +E2C9 E2C9 E99A8B E2C9 +E2CA E2CA E99AA7 E2CA +E2CB E2CB E99AA8 E2CB +E2CC E2CC E99B96 E2CC +E2CD E2CD E99C80 E2CD +E2CE E2CE E9A088 E2CE +E2CF E2CF E9A696 E2CF +E2D0 E2D0 E9AB93 E2D0 +E2D1 E2D1 E9AC9A E2D1 +E2D2 E2D2 E58F94 E2D2 +E2D3 E2D3 E5A1BE E2D3 +E2D4 E2D4 E5A499 E2D4 +E2D5 E2D5 E5ADB0 E2D5 +E2D6 E2D6 E5AEBF E2D6 +E2D7 E2D7 E6B791 E2D7 +E2D8 E2D8 E6BD9A E2D8 +E2D9 E2D9 E7869F E2D9 +E2DA E2DA E790A1 E2DA +E2DB E2DB E792B9 E2DB +E2DC E2DC E88285 E2DC +E2DD E2DD E88FBD E2DD +E2DE E2DE E5B7A1 E2DE +E2DF E2DF E5BE87 E2DF +E2E0 E2E0 E5BEAA E2E0 +E2E1 E2E1 E68182 E2E1 +E2E2 E2E2 E697AC E2E2 +E2E3 E2E3 E6A092 E2E3 +E2E4 E2E4 E6A5AF E2E4 +E2E5 E2E5 E6A993 E2E5 +E2E6 E2E6 E6AE89 E2E6 +E2E7 E2E7 E6B4B5 E2E7 +E2E8 E2E8 E6B7B3 E2E8 +E2E9 E2E9 E78FA3 E2E9 +E2EA E2EA E79BBE E2EA +E2EB E2EB E79EAC E2EB +E2EC E2EC E7AD8D E2EC +E2ED E2ED E7B494 E2ED +E2EE E2EE E884A3 E2EE +E2EF E2EF E8889C E2EF +E2F0 E2F0 E88D80 E2F0 +E2F1 E2F1 E893B4 E2F1 +E2F2 E2F2 E895A3 E2F2 +E2F3 E2F3 E8A9A2 E2F3 +E2F4 E2F4 E8AB84 E2F4 +E2F5 E2F5 E98687 E2F5 +E2F6 E2F6 E98C9E E2F6 +E2F7 E2F7 E9A086 E2F7 +E2F8 E2F8 E9A6B4 E2F8 +E2F9 E2F9 E6888C E2F9 +E2FA E2FA E8A193 E2FA +E2FB E2FB E8BFB0 E2FB +E2FC E2FC E989A5 E2FC +E2FD E2FD E5B487 E2FD +E2FE E2FE E5B4A7 E2FE +E3A1 E3A1 E5B5A9 E3A1 +E3A2 E3A2 E7919F E3A2 +E3A3 E3A3 E8869D E3A3 +E3A4 E3A4 E89DA8 E3A4 +E3A5 E3A5 E6BF95 E3A5 +E3A6 E3A6 E68BBE E3A6 +E3A7 E3A7 E7BF92 E3A7 +E3A8 E3A8 E8A4B6 E3A8 +E3A9 E3A9 E8A5B2 E3A9 +E3AA E3AA E4B89E E3AA +E3AB E3AB E4B998 E3AB +E3AC E3AC E583A7 E3AC +E3AD E3AD E58B9D E3AD +E3AE E3AE E58D87 E3AE +E3AF E3AF E689BF E3AF +E3B0 E3B0 E69887 E3B0 +E3B1 E3B1 E7B9A9 E3B1 +E3B2 E3B2 E8A085 E3B2 +E3B3 E3B3 E9999E E3B3 +E3B4 E3B4 E4BE8D E3B4 +E3B5 E3B5 E58C99 E3B5 +E3B6 E3B6 E598B6 E3B6 +E3B7 E3B7 E5A78B E3B7 +E3B8 E3B8 E5AAA4 E3B8 +E3B9 E3B9 E5B0B8 E3B9 +E3BA E3BA E5B18E E3BA +E3BB E3BB E5B18D E3BB +E3BC E3BC E5B882 E3BC +E3BD E3BD E5BC91 E3BD +E3BE E3BE E68183 E3BE +E3BF E3BF E696BD E3BF +E3C0 E3C0 E698AF E3C0 +E3C1 E3C1 E69982 E3C1 +E3C2 E3C2 E69EBE E3C2 +E3C3 E3C3 E69FB4 E3C3 +E3C4 E3C4 E78C9C E3C4 +E3C5 E3C5 E79FA2 E3C5 +E3C6 E3C6 E7A4BA E3C6 +E3C7 E3C7 E7BF85 E3C7 +E3C8 E3C8 E89294 E3C8 +E3C9 E3C9 E8938D E3C9 +E3CA E3CA E8A696 E3CA +E3CB E3CB E8A9A6 E3CB +E3CC E3CC E8A9A9 E3CC +E3CD E3CD E8ABA1 E3CD +E3CE E3CE E8B195 E3CE +E3CF E3CF E8B1BA E3CF +E3D0 E3D0 E59FB4 E3D0 +E3D1 E3D1 E5AF94 E3D1 +E3D2 E3D2 E5BC8F E3D2 +E3D3 E3D3 E681AF E3D3 +E3D4 E3D4 E68BAD E3D4 +E3D5 E3D5 E6A48D E3D5 +E3D6 E3D6 E6AE96 E3D6 +E3D7 E3D7 E6B99C E3D7 +E3D8 E3D8 E78684 E3D8 +E3D9 E3D9 E7AF92 E3D9 +E3DA E3DA E89D95 E3DA +E3DB E3DB E8AD98 E3DB +E3DC E3DC E8BBBE E3DC +E3DD E3DD E9A39F E3DD +E3DE E3DE E9A3BE E3DE +E3DF E3DF E4BCB8 E3DF +E3E0 E3E0 E4BE81 E3E0 +E3E1 E3E1 E4BFA1 E3E1 +E3E2 E3E2 E591BB E3E2 +E3E3 E3E3 E5A8A0 E3E3 +E3E4 E3E4 E5AEB8 E3E4 +E3E5 E3E5 E684BC E3E5 +E3E6 E3E6 E696B0 E3E6 +E3E7 E3E7 E699A8 E3E7 +E3E8 E3E8 E787BC E3E8 +E3E9 E3E9 E794B3 E3E9 +E3EA E3EA E7A59E E3EA +E3EB E3EB E7B4B3 E3EB +E3EC E3EC E8858E E3EC +E3ED E3ED E887A3 E3ED +E3EE E3EE E88E98 E3EE +E3EF E3EF E896AA E3EF +E3F0 E3F0 E8978E E3F0 +E3F1 E3F1 E89C83 E3F1 +E3F2 E3F2 E8A88A E3F2 +E3F3 E3F3 E8BAAB E3F3 +E3F4 E3F4 E8BE9B E3F4 +E3F5 E3F5 EFA5B1 E3F5 +E3F6 E3F6 E8BF85 E3F6 +E3F7 E3F7 E5A4B1 E3F7 +E3F8 E3F8 E5AEA4 E3F8 +E3F9 E3F9 E5AFA6 E3F9 +E3FA E3FA E68289 E3FA +E3FB E3FB E5AFA9 E3FB +E3FC E3FC E5B08B E3FC +E3FD E3FD E5BF83 E3FD +E3FE E3FE E6B281 E3FE +E4A1 E4A1 EFA5B2 E4A1 +E4A2 E4A2 E6B7B1 E4A2 +E4A3 E4A3 E7808B E4A3 +E4A4 E4A4 E7949A E4A4 +E4A5 E4A5 E88AAF E4A5 +E4A6 E4A6 E8ABB6 E4A6 +E4A7 E4A7 E4BB80 E4A7 +E4A8 E4A8 E58D81 E4A8 +E4A9 E4A9 EFA5B3 E4A9 +E4AA E4AA E99B99 E4AA +E4AB E4AB E6B08F E4AB +E4AC E4AC E4BA9E E4AC +E4AD E4AD E4BF84 E4AD +E4AE E4AE E58592 E4AE +E4AF E4AF E5959E E4AF +E4B0 E4B0 E5A8A5 E4B0 +E4B1 E4B1 E5B3A8 E4B1 +E4B2 E4B2 E68891 E4B2 +E4B3 E4B3 E78999 E4B3 +E4B4 E4B4 E88ABD E4B4 +E4B5 E4B5 E88EAA E4B5 +E4B6 E4B6 E89BBE E4B6 +E4B7 E4B7 E8A199 E4B7 +E4B8 E4B8 E8A89D E4B8 +E4B9 E4B9 E998BF E4B9 +E4BA E4BA E99B85 E4BA +E4BB E4BB E9A493 E4BB +E4BC E4BC E9B489 E4BC +E4BD E4BD E9B59D E4BD +E4BE E4BE E5A08A E4BE +E4BF E4BF E5B2B3 E4BF +E4C0 E4C0 E5B6BD E4C0 +E4C1 E4C1 E5B984 E4C1 +E4C2 E4C2 E683A1 E4C2 +E4C3 E4C3 E68495 E4C3 +E4C4 E4C4 E68FA1 E4C4 +E4C5 E4C5 E6A882 E4C5 +E4C6 E4C6 E6B8A5 E4C6 +E4C7 E4C7 E98482 E4C7 +E4C8 E4C8 E98D94 E4C8 +E4C9 E4C9 E9A18E E4C9 +E4CA E4CA E9B090 E4CA +E4CB E4CB E9BDB7 E4CB +E4CC E4CC E5AE89 E4CC +E4CD E4CD E5B2B8 E4CD +E4CE E4CE E68C89 E4CE +E4CF E4CF E6998F E4CF +E4D0 E4D0 E6A188 E4D0 +E4D1 E4D1 E79CBC E4D1 +E4D2 E4D2 E99B81 E4D2 +E4D3 E4D3 E99E8D E4D3 +E4D4 E4D4 E9A194 E4D4 +E4D5 E4D5 E9AE9F E4D5 +E4D6 E4D6 E696A1 E4D6 +E4D7 E4D7 E8AC81 E4D7 +E4D8 E4D8 E8BB8B E4D8 +E4D9 E4D9 E996BC E4D9 +E4DA E4DA E594B5 E4DA +E4DB E4DB E5B2A9 E4DB +E4DC E4DC E5B796 E4DC +E4DD E4DD E5BAB5 E4DD +E4DE E4DE E69A97 E4DE +E4DF E4DF E7998C E4DF +E4E0 E4E0 E88FB4 E4E0 +E4E1 E4E1 E99787 E4E1 +E4E2 E4E2 E5A393 E4E2 +E4E3 E4E3 E68ABC E4E3 +E4E4 E4E4 E78B8E E4E4 +E4E5 E4E5 E9B4A8 E4E5 +E4E6 E4E6 E4BBB0 E4E6 +E4E7 E4E7 E5A4AE E4E7 +E4E8 E4E8 E6808F E4E8 +E4E9 E4E9 E698BB E4E9 +E4EA E4EA E6AE83 E4EA +E4EB E4EB E7A7A7 E4EB +E4EC E4EC E9B4A6 E4EC +E4ED E4ED E58E93 E4ED +E4EE E4EE E59380 E4EE +E4EF E4EF E59F83 E4EF +E4F0 E4F0 E5B496 E4F0 +E4F1 E4F1 E6849B E4F1 +E4F2 E4F2 E69B96 E4F2 +E4F3 E4F3 E6B6AF E4F3 +E4F4 E4F4 E7A28D E4F4 +E4F5 E4F5 E889BE E4F5 +E4F6 E4F6 E99A98 E4F6 +E4F7 E4F7 E99D84 E4F7 +E4F8 E4F8 E58E84 E4F8 +E4F9 E4F9 E689BC E4F9 +E4FA E4FA E68E96 E4FA +E4FB E4FB E6B6B2 E4FB +E4FC E4FC E7B88A E4FC +E4FD E4FD E8858B E4FD +E4FE E4FE E9A18D E4FE +E5A1 E5A1 E6ABBB E5A1 +E5A2 E5A2 E7BD8C E5A2 +E5A3 E5A3 E9B6AF E5A3 +E5A4 E5A4 E9B89A E5A4 +E5A5 E5A5 E4B99F E5A5 +E5A6 E5A6 E580BB E5A6 +E5A7 E5A7 E586B6 E5A7 +E5A8 E5A8 E5A49C E5A8 +E5A9 E5A9 E683B9 E5A9 +E5AA E5AA E68FB6 E5AA +E5AB E5AB E6A4B0 E5AB +E5AC E5AC E788BA E5AC +E5AD E5AD E880B6 E5AD +E5AE E5AE EFA5B4 E5AE +E5AF E5AF E9878E E5AF +E5B0 E5B0 E5BCB1 E5B0 +E5B1 E5B1 EFA5B5 E5B1 +E5B2 E5B2 EFA5B6 E5B2 +E5B3 E5B3 E7B484 E5B3 +E5B4 E5B4 E88BA5 E5B4 +E5B5 E5B5 E891AF E5B5 +E5B6 E5B6 E892BB E5B6 +E5B7 E5B7 E897A5 E5B7 +E5B8 E5B8 E8BA8D E5B8 +E5B9 E5B9 EFA5B7 E5B9 +E5BA E5BA E4BDAF E5BA +E5BB E5BB EFA5B8 E5BB +E5BC E5BC EFA5B9 E5BC +E5BD E5BD E5A3A4 E5BD +E5BE E5BE E5AD83 E5BE +E5BF E5BF E68199 E5BF +E5C0 E5C0 E68F9A E5C0 +E5C1 E5C1 E69498 E5C1 +E5C2 E5C2 E695AD E5C2 +E5C3 E5C3 E69A98 E5C3 +E5C4 E5C4 EFA5BA E5C4 +E5C5 E5C5 E6A58A E5C5 +E5C6 E5C6 E6A8A3 E5C6 +E5C7 E5C7 E6B48B E5C7 +E5C8 E5C8 E78081 E5C8 +E5C9 E5C9 E785AC E5C9 +E5CA E5CA E79792 E5CA +E5CB E5CB E7988D E5CB +E5CC E5CC E7A6B3 E5CC +E5CD E5CD E7A9B0 E5CD +E5CE E5CE EFA5BB E5CE +E5CF E5CF E7BE8A E5CF +E5D0 E5D0 EFA5BC E5D0 +E5D1 E5D1 E8A584 E5D1 +E5D2 E5D2 EFA5BD E5D2 +E5D3 E5D3 E8AE93 E5D3 +E5D4 E5D4 E98780 E5D4 +E5D5 E5D5 E999BD E5D5 +E5D6 E5D6 EFA5BE E5D6 +E5D7 E5D7 E9A48A E5D7 +E5D8 E5D8 E59C84 E5D8 +E5D9 E5D9 E5BEA1 E5D9 +E5DA E5DA E696BC E5DA +E5DB E5DB E6BC81 E5DB +E5DC E5DC E79880 E5DC +E5DD E5DD E7A6A6 E5DD +E5DE E5DE E8AA9E E5DE +E5DF E5DF E9A6AD E5DF +E5E0 E5E0 E9AD9A E5E0 +E5E1 E5E1 E9BDAC E5E1 +E5E2 E5E2 E58484 E5E2 +E5E3 E5E3 E686B6 E5E3 +E5E4 E5E4 E68A91 E5E4 +E5E5 E5E5 E6AA8D E5E5 +E5E6 E5E6 E88786 E5E6 +E5E7 E5E7 E58183 E5E7 +E5E8 E5E8 E5A0B0 E5E8 +E5E9 E5E9 E5BDA6 E5E9 +E5EA E5EA E78489 E5EA +E5EB E5EB E8A880 E5EB +E5EC E5EC E8ABBA E5EC +E5ED E5ED E5ADBC E5ED +E5EE E5EE E89896 E5EE +E5EF E5EF E4BFBA E5EF +E5F0 E5F0 E584BC E5F0 +E5F1 E5F1 E59AB4 E5F1 +E5F2 E5F2 E5A584 E5F2 +E5F3 E5F3 E68EA9 E5F3 +E5F4 E5F4 E6B7B9 E5F4 +E5F5 E5F5 E5B6AA E5F5 +E5F6 E5F6 E6A5AD E5F6 +E5F7 E5F7 E58686 E5F7 +E5F8 E5F8 E4BA88 E5F8 +E5F9 E5F9 E4BD99 E5F9 +E5FA E5FA EFA5BF E5FA +E5FB E5FB EFA680 E5FB +E5FC E5FC EFA681 E5FC +E5FD E5FD E5A682 E5FD +E5FE E5FE EFA682 E5FE +E6A1 E6A1 EFA683 E6A1 +E6A2 E6A2 E6AD9F E6A2 +E6A3 E6A3 E6B19D E6A3 +E6A4 E6A4 EFA684 E6A4 +E6A5 E6A5 E792B5 E6A5 +E6A6 E6A6 E7A496 E6A6 +E6A7 E6A7 EFA685 E6A7 +E6A8 E6A8 E88887 E6A8 +E6A9 E6A9 E88985 E6A9 +E6AA E6AA E88CB9 E6AA +E6AB E6AB E8BCBF E6AB +E6AC E6AC E8BD9D E6AC +E6AD E6AD EFA686 E6AD +E6AE E6AE E9A498 E6AE +E6AF E6AF EFA687 E6AF +E6B0 E6B0 EFA688 E6B0 +E6B1 E6B1 EFA689 E6B1 +E6B2 E6B2 E4BAA6 E6B2 +E6B3 E6B3 EFA68A E6B3 +E6B4 E6B4 E59F9F E6B4 +E6B5 E6B5 E5BDB9 E6B5 +E6B6 E6B6 E69893 E6B6 +E6B7 E6B7 EFA68B E6B7 +E6B8 E6B8 EFA68C E6B8 +E6B9 E6B9 E796AB E6B9 +E6BA E6BA E7B9B9 E6BA +E6BB E6BB E8ADAF E6BB +E6BC E6BC EFA68D E6BC +E6BD E6BD E98086 E6BD +E6BE E6BE E9A99B E6BE +E6BF E6BF E59AA5 E6BF +E6C0 E6C0 E5A0A7 E6C0 +E6C1 E6C1 E5A7B8 E6C1 +E6C2 E6C2 E5A89F E6C2 +E6C3 E6C3 E5AEB4 E6C3 +E6C4 E6C4 EFA68E E6C4 +E6C5 E6C5 E5BBB6 E6C5 +E6C6 E6C6 EFA68F E6C6 +E6C7 E6C7 EFA690 E6C7 +E6C8 E6C8 E68D90 E6C8 +E6C9 E6C9 E68CBB E6C9 +E6CA E6CA EFA691 E6CA +E6CB E6CB E6A4BD E6CB +E6CC E6CC E6B287 E6CC +E6CD E6CD E6B2BF E6CD +E6CE E6CE E6B68E E6CE +E6CF E6CF E6B693 E6CF +E6D0 E6D0 E6B7B5 E6D0 +E6D1 E6D1 E6BC94 E6D1 +E6D2 E6D2 EFA692 E6D2 +E6D3 E6D3 E7839F E6D3 +E6D4 E6D4 E784B6 E6D4 +E6D5 E6D5 E78599 E6D5 +E6D6 E6D6 EFA693 E6D6 +E6D7 E6D7 E78783 E6D7 +E6D8 E6D8 E78795 E6D8 +E6D9 E6D9 EFA694 E6D9 +E6DA E6DA E7A18F E6DA +E6DB E6DB E7A1AF E6DB +E6DC E6DC EFA695 E6DC +E6DD E6DD E7ADB5 E6DD +E6DE E6DE E7B7A3 E6DE +E6DF E6DF EFA696 E6DF +E6E0 E6E0 E7B8AF E6E0 +E6E1 E6E1 EFA697 E6E1 +E6E2 E6E2 E8A18D E6E2 +E6E3 E6E3 E8BB9F E6E3 +E6E4 E6E4 EFA698 E6E4 +E6E5 E6E5 EFA699 E6E5 +E6E6 E6E6 EFA69A E6E6 +E6E7 E6E7 E9899B E6E7 +E6E8 E6E8 EFA69B E6E8 +E6E9 E6E9 E9B3B6 E6E9 +E6EA E6EA EFA69C E6EA +E6EB E6EB EFA69D E6EB +E6EC E6EC EFA69E E6EC +E6ED E6ED E68285 E6ED +E6EE E6EE E6B685 E6EE +E6EF E6EF EFA69F E6EF +E6F0 E6F0 E786B1 E6F0 +E6F1 E6F1 EFA6A0 E6F1 +E6F2 E6F2 EFA6A1 E6F2 +E6F3 E6F3 E996B1 E6F3 +E6F4 E6F4 E58EAD E6F4 +E6F5 E6F5 EFA6A2 E6F5 +E6F6 E6F6 EFA6A3 E6F6 +E6F7 E6F7 EFA6A4 E6F7 +E6F8 E6F8 E69F93 E6F8 +E6F9 E6F9 EFA6A5 E6F9 +E6FA E6FA E7828E E6FA +E6FB E6FB E784B0 E6FB +E6FC E6FC E790B0 E6FC +E6FD E6FD E889B6 E6FD +E6FE E6FE E88B92 E6FE +E7A1 E7A1 EFA6A6 E7A1 +E7A2 E7A2 E996BB E7A2 +E7A3 E7A3 E9ABA5 E7A3 +E7A4 E7A4 E9B9BD E7A4 +E7A5 E7A5 E69B84 E7A5 +E7A6 E7A6 EFA6A7 E7A6 +E7A7 E7A7 E78781 E7A7 +E7A8 E7A8 E89189 E7A8 +E7A9 E7A9 EFA6A8 E7A9 +E7AA E7AA EFA6A9 E7AA +E7AB E7AB E5A18B E7AB +E7AC E7AC EFA6AA E7AC +E7AD E7AD EFA6AB E7AD +E7AE E7AE E5B6B8 E7AE +E7AF E7AF E5BDB1 E7AF +E7B0 E7B0 EFA6AC E7B0 +E7B1 E7B1 E698A0 E7B1 +E7B2 E7B2 E69A8E E7B2 +E7B3 E7B3 E6A5B9 E7B3 +E7B4 E7B4 E6A6AE E7B4 +E7B5 E7B5 E6B0B8 E7B5 +E7B6 E7B6 E6B3B3 E7B6 +E7B7 E7B7 E6B8B6 E7B7 +E7B8 E7B8 E6BD81 E7B8 +E7B9 E7B9 E6BF9A E7B9 +E7BA E7BA E7809B E7BA +E7BB E7BB E780AF E7BB +E7BC E7BC E78590 E7BC +E7BD E7BD E7879F E7BD +E7BE E7BE E78DB0 E7BE +E7BF E7BF EFA6AD E7BF +E7C0 E7C0 E7919B E7C0 +E7C1 E7C1 EFA6AE E7C1 +E7C2 E7C2 E79394 E7C2 +E7C3 E7C3 E79B88 E7C3 +E7C4 E7C4 E7A98E E7C4 +E7C5 E7C5 E7BA93 E7C5 +E7C6 E7C6 EFA6AF E7C6 +E7C7 E7C7 EFA6B0 E7C7 +E7C8 E7C8 E88BB1 E7C8 +E7C9 E7C9 E8A9A0 E7C9 +E7CA E7CA E8BF8E E7CA +E7CB E7CB EFA6B1 E7CB +E7CC E7CC E98D88 E7CC +E7CD E7CD EFA6B2 E7CD +E7CE E7CE E99C99 E7CE +E7CF E7CF EFA6B3 E7CF +E7D0 E7D0 EFA6B4 E7D0 +E7D1 E7D1 E4B982 E7D1 +E7D2 E7D2 E580AA E7D2 +E7D3 E7D3 EFA6B5 E7D3 +E7D4 E7D4 E58888 E7D4 +E7D5 E7D5 E58FA1 E7D5 +E7D6 E7D6 E69BB3 E7D6 +E7D7 E7D7 E6B1AD E7D7 +E7D8 E7D8 E6BF8A E7D8 +E7D9 E7D9 E78C8A E7D9 +E7DA E7DA E79DBF E7DA +E7DB E7DB E7A9A2 E7DB +E7DC E7DC E88AAE E7DC +E7DD E7DD E8979D E7DD +E7DE E7DE E89882 E7DE +E7DF E7DF EFA6B6 E7DF +E7E0 E7E0 E8A394 E7E0 +E7E1 E7E1 E8A9A3 E7E1 +E7E2 E7E2 E8ADBD E7E2 +E7E3 E7E3 E8B1AB E7E3 +E7E4 E7E4 EFA6B7 E7E4 +E7E5 E7E5 E98AB3 E7E5 +E7E6 E7E6 EFA6B8 E7E6 +E7E7 E7E7 E99C93 E7E7 +E7E8 E7E8 E9A090 E7E8 +E7E9 E7E9 E4BA94 E7E9 +E7EA E7EA E4BC8D E7EA +E7EB E7EB E4BF89 E7EB +E7EC E7EC E582B2 E7EC +E7ED E7ED E58D88 E7ED +E7EE E7EE E590BE E7EE +E7EF E7EF E590B3 E7EF +E7F0 E7F0 E5979A E7F0 +E7F1 E7F1 E5A1A2 E7F1 +E7F2 E7F2 E5A2BA E7F2 +E7F3 E7F3 E5A5A7 E7F3 +E7F4 E7F4 E5A89B E7F4 +E7F5 E7F5 E5AFA4 E7F5 +E7F6 E7F6 E6829F E7F6 +E7F7 E7F7 EFA6B9 E7F7 +E7F8 E7F8 E6878A E7F8 +E7F9 E7F9 E69596 E7F9 +E7FA E7FA E697BF E7FA +E7FB E7FB E699A4 E7FB +E7FC E7FC E6A2A7 E7FC +E7FD E7FD E6B19A E7FD +E7FE E7FE E6BEB3 E7FE +E8A1 E8A1 E7838F E8A1 +E8A2 E8A2 E786AC E8A2 +E8A3 E8A3 E78D92 E8A3 +E8A4 E8A4 E7ADBD E8A4 +E8A5 E8A5 E89C88 E8A5 +E8A6 E8A6 E8AAA4 E8A6 +E8A7 E8A7 E9B0B2 E8A7 +E8A8 E8A8 E9BC87 E8A8 +E8A9 E8A9 E5B18B E8A9 +E8AA E8AA E6B283 E8AA +E8AB E8AB E78D84 E8AB +E8AC E8AC E78E89 E8AC +E8AD E8AD E988BA E8AD +E8AE E8AE E6BAAB E8AE +E8AF E8AF E791A5 E8AF +E8B0 E8B0 E7989F E8B0 +E8B1 E8B1 E7A9A9 E8B1 +E8B2 E8B2 E7B895 E8B2 +E8B3 E8B3 E8988A E8B3 +E8B4 E8B4 E58580 E8B4 +E8B5 E8B5 E5A385 E8B5 +E8B6 E8B6 E69381 E8B6 +E8B7 E8B7 E793AE E8B7 +E8B8 E8B8 E79495 E8B8 +E8B9 E8B9 E799B0 E8B9 +E8BA E8BA E7BF81 E8BA +E8BB E8BB E98295 E8BB +E8BC E8BC E99B8D E8BC +E8BD E8BD E9A594 E8BD +E8BE E8BE E6B8A6 E8BE +E8BF E8BF E793A6 E8BF +E8C0 E8C0 E7AAA9 E8C0 +E8C1 E8C1 E7AAAA E8C1 +E8C2 E8C2 E887A5 E8C2 +E8C3 E8C3 E89B99 E8C3 +E8C4 E8C4 E89DB8 E8C4 +E8C5 E8C5 E8A89B E8C5 +E8C6 E8C6 E5A989 E8C6 +E8C7 E8C7 E5AE8C E8C7 +E8C8 E8C8 E5AE9B E8C8 +E8C9 E8C9 E6A2A1 E8C9 +E8CA E8CA E6A480 E8CA +E8CB E8CB E6B5A3 E8CB +E8CC E8CC E78EA9 E8CC +E8CD E8CD E79093 E8CD +E8CE E8CE E790AC E8CE +E8CF E8CF E7A297 E8CF +E8D0 E8D0 E7B7A9 E8D0 +E8D1 E8D1 E7BFAB E8D1 +E8D2 E8D2 E88498 E8D2 +E8D3 E8D3 E88595 E8D3 +E8D4 E8D4 E88E9E E8D4 +E8D5 E8D5 E8B18C E8D5 +E8D6 E8D6 E998AE E8D6 +E8D7 E8D7 E9A091 E8D7 +E8D8 E8D8 E69BB0 E8D8 +E8D9 E8D9 E5BE80 E8D9 +E8DA E8DA E697BA E8DA +E8DB E8DB E69E89 E8DB +E8DC E8DC E6B1AA E8DC +E8DD E8DD E78E8B E8DD +E8DE E8DE E580AD E8DE +E8DF E8DF E5A883 E8DF +E8E0 E8E0 E6ADAA E8E0 +E8E1 E8E1 E79FAE E8E1 +E8E2 E8E2 E5A496 E8E2 +E8E3 E8E3 E5B5AC E8E3 +E8E4 E8E4 E5B78D E8E4 +E8E5 E8E5 E78CA5 E8E5 +E8E6 E8E6 E7958F E8E6 +E8E7 E8E7 EFA6BA E8E7 +E8E8 E8E8 EFA6BB E8E8 +E8E9 E8E9 E583A5 E8E9 +E8EA E8EA E587B9 E8EA +E8EB E8EB E5A0AF E8EB +E8EC E8EC E5A4AD E8EC +E8ED E8ED E5A696 E8ED +E8EE E8EE E5A79A E8EE +E8EF E8EF E5AFA5 E8EF +E8F0 E8F0 EFA6BC E8F0 +E8F1 E8F1 EFA6BD E8F1 +E8F2 E8F2 E5B6A2 E8F2 +E8F3 E8F3 E68B97 E8F3 +E8F4 E8F4 E69096 E8F4 +E8F5 E8F5 E69293 E8F5 +E8F6 E8F6 E693BE E8F6 +E8F7 E8F7 EFA6BE E8F7 +E8F8 E8F8 E69B9C E8F8 +E8F9 E8F9 EFA6BF E8F9 +E8FA E8FA E6A988 E8FA +E8FB E8FB EFA780 E8FB +E8FC E8FC E787BF E8FC +E8FD E8FD E791A4 E8FD +E8FE E8FE EFA781 E8FE +E9A1 E9A1 E7AA88 E9A1 +E9A2 E9A2 E7AAAF E9A2 +E9A3 E9A3 E7B987 E9A3 +E9A4 E9A4 E7B99E E9A4 +E9A5 E9A5 E88080 E9A5 +E9A6 E9A6 E885B0 E9A6 +E9A7 E9A7 EFA782 E9A7 +E9A8 E9A8 E89FAF E9A8 +E9A9 E9A9 E8A681 E9A9 +E9AA E9AA E8ACA0 E9AA +E9AB E9AB E98199 E9AB +E9AC E9AC EFA783 E9AC +E9AD E9AD E98280 E9AD +E9AE E9AE E9A592 E9AE +E9AF E9AF E685BE E9AF +E9B0 E9B0 E6ACB2 E9B0 +E9B1 E9B1 E6B5B4 E9B1 +E9B2 E9B2 E7B89F E9B2 +E9B3 E9B3 E8A4A5 E9B3 +E9B4 E9B4 E8BEB1 E9B4 +E9B5 E9B5 E4BF91 E9B5 +E9B6 E9B6 E582AD E9B6 +E9B7 E9B7 E58697 E9B7 +E9B8 E9B8 E58B87 E9B8 +E9B9 E9B9 E59F87 E9B9 +E9BA E9BA E5A289 E9BA +E9BB E9BB E5AEB9 E9BB +E9BC E9BC E5BAB8 E9BC +E9BD E9BD E68582 E9BD +E9BE E9BE E6A695 E9BE +E9BF E9BF E6B68C E9BF +E9C0 E9C0 E6B9A7 E9C0 +E9C1 E9C1 E6BAB6 E9C1 +E9C2 E9C2 E78694 E9C2 +E9C3 E9C3 E791A2 E9C3 +E9C4 E9C4 E794A8 E9C4 +E9C5 E9C5 E794AC E9C5 +E9C6 E9C6 E881B3 E9C6 +E9C7 E9C7 E88CB8 E9C7 +E9C8 E9C8 E89389 E9C8 +E9C9 E9C9 E8B88A E9C9 +E9CA E9CA E98E94 E9CA +E9CB E9CB E98F9E E9CB +E9CC E9CC EFA784 E9CC +E9CD E9CD E4BA8E E9CD +E9CE E9CE E4BD91 E9CE +E9CF E9CF E581B6 E9CF +E9D0 E9D0 E584AA E9D0 +E9D1 E9D1 E58F88 E9D1 +E9D2 E9D2 E58F8B E9D2 +E9D3 E9D3 E58FB3 E9D3 +E9D4 E9D4 E5AE87 E9D4 +E9D5 E9D5 E5AF93 E9D5 +E9D6 E9D6 E5B0A4 E9D6 +E9D7 E9D7 E6849A E9D7 +E9D8 E9D8 E68682 E9D8 +E9D9 E9D9 E697B4 E9D9 +E9DA E9DA E7899B E9DA +E9DB E9DB E78E97 E9DB +E9DC E9DC E79180 E9DC +E9DD E9DD E79B82 E9DD +E9DE E9DE E7A590 E9DE +E9DF E9DF E7A691 E9DF +E9E0 E9E0 E7A6B9 E9E0 +E9E1 E9E1 E7B486 E9E1 +E9E2 E9E2 E7BEBD E9E2 +E9E3 E9E3 E88A8B E9E3 +E9E4 E9E4 E89795 E9E4 +E9E5 E9E5 E8999E E9E5 +E9E6 E9E6 E8BF82 E9E6 +E9E7 E9E7 E98187 E9E7 +E9E8 E9E8 E983B5 E9E8 +E9E9 E9E9 E987AA E9E9 +E9EA E9EA E99A85 E9EA +E9EB E9EB E99BA8 E9EB +E9EC E9EC E99BA9 E9EC +E9ED E9ED E58B96 E9ED +E9EE E9EE E5BDA7 E9EE +E9EF E9EF E697AD E9EF +E9F0 E9F0 E698B1 E9F0 +E9F1 E9F1 E6A0AF E9F1 +E9F2 E9F2 E7859C E9F2 +E9F3 E9F3 E7A8B6 E9F3 +E9F4 E9F4 E98381 E9F4 +E9F5 E9F5 E9A08A E9F5 +E9F6 E9F6 E4BA91 E9F6 +E9F7 E9F7 EFA785 E9F7 +E9F8 E9F8 E6A992 E9F8 +E9F9 E9F9 E6AE9E E9F9 +E9FA E9FA E6BE90 E9FA +E9FB E9FB E78689 E9FB +E9FC E9FC E88098 E9FC +E9FD E9FD E88AB8 E9FD +E9FE E9FE E89593 E9FE +EAA1 EAA1 E9818B EAA1 +EAA2 EAA2 E99A95 EAA2 +EAA3 EAA3 E99BB2 EAA3 +EAA4 EAA4 E99FBB EAA4 +EAA5 EAA5 E8949A EAA5 +EAA6 EAA6 E9ACB1 EAA6 +EAA7 EAA7 E4BA90 EAA7 +EAA8 EAA8 E7868A EAA8 +EAA9 EAA9 E99B84 EAA9 +EAAA EAAA E58583 EAAA +EAAB EAAB E58E9F EAAB +EAAC EAAC E593A1 EAAC +EAAD EAAD E59C93 EAAD +EAAE EAAE E59C92 EAAE +EAAF EAAF E59EA3 EAAF +EAB0 EAB0 E5AA9B EAB0 +EAB1 EAB1 E5AB84 EAB1 +EAB2 EAB2 E5AF83 EAB2 +EAB3 EAB3 E680A8 EAB3 +EAB4 EAB4 E684BF EAB4 +EAB5 EAB5 E68FB4 EAB5 +EAB6 EAB6 E6B285 EAB6 +EAB7 EAB7 E6B4B9 EAB7 +EAB8 EAB8 E6B9B2 EAB8 +EAB9 EAB9 E6BA90 EAB9 +EABA EABA E788B0 EABA +EABB EABB E78CBF EABB +EABC EABC E79197 EABC +EABD EABD E88B91 EABD +EABE EABE E8A281 EABE +EABF EABF E8BD85 EABF +EAC0 EAC0 E981A0 EAC0 +EAC1 EAC1 EFA786 EAC1 +EAC2 EAC2 E999A2 EAC2 +EAC3 EAC3 E9A198 EAC3 +EAC4 EAC4 E9B49B EAC4 +EAC5 EAC5 E69C88 EAC5 +EAC6 EAC6 E8B68A EAC6 +EAC7 EAC7 E9899E EAC7 +EAC8 EAC8 E4BD8D EAC8 +EAC9 EAC9 E58189 EAC9 +EACA EACA E5839E EACA +EACB EACB E58DB1 EACB +EACC EACC E59C8D EACC +EACD EACD E5A794 EACD +EACE EACE E5A881 EACE +EACF EACF E5B089 EACF +EAD0 EAD0 E685B0 EAD0 +EAD1 EAD1 E69A90 EAD1 +EAD2 EAD2 E6B8AD EAD2 +EAD3 EAD3 E788B2 EAD3 +EAD4 EAD4 E7918B EAD4 +EAD5 EAD5 E7B7AF EAD5 +EAD6 EAD6 E88383 EAD6 +EAD7 EAD7 E8908E EAD7 +EAD8 EAD8 E891A6 EAD8 +EAD9 EAD9 E894BF EAD9 +EADA EADA E89D9F EADA +EADB EADB E8A19B EADB +EADC EADC E8A498 EADC +EADD EADD E8AC82 EADD +EADE EADE E98195 EADE +EADF EADF E99F8B EADF +EAE0 EAE0 E9AD8F EAE0 +EAE1 EAE1 E4B9B3 EAE1 +EAE2 EAE2 E4BE91 EAE2 +EAE3 EAE3 E58492 EAE3 +EAE4 EAE4 E585AA EAE4 +EAE5 EAE5 EFA787 EAE5 +EAE6 EAE6 E594AF EAE6 +EAE7 EAE7 E596A9 EAE7 +EAE8 EAE8 E5ADBA EAE8 +EAE9 EAE9 E5AEA5 EAE9 +EAEA EAEA E5B9BC EAEA +EAEB EAEB E5B9BD EAEB +EAEC EAEC E5BABE EAEC +EAED EAED E682A0 EAED +EAEE EAEE E6839F EAEE +EAEF EAEF E68488 EAEF +EAF0 EAF0 E68489 EAF0 +EAF1 EAF1 E68F84 EAF1 +EAF2 EAF2 E694B8 EAF2 +EAF3 EAF3 E69C89 EAF3 +EAF4 EAF4 EFA788 EAF4 +EAF5 EAF5 E69F94 EAF5 +EAF6 EAF6 E69F9A EAF6 +EAF7 EAF7 EFA789 EAF7 +EAF8 EAF8 E6A5A1 EAF8 +EAF9 EAF9 E6A5A2 EAF9 +EAFA EAFA E6B2B9 EAFA +EAFB EAFB E6B4A7 EAFB +EAFC EAFC EFA78A EAFC +EAFD EAFD E6B8B8 EAFD +EAFE EAFE EFA78B EAFE +EBA1 EBA1 E6BFA1 EBA1 +EBA2 EBA2 E78CB6 EBA2 +EBA3 EBA3 E78CB7 EBA3 +EBA4 EBA4 EFA78C EBA4 +EBA5 EBA5 E7919C EBA5 +EBA6 EBA6 E794B1 EBA6 +EBA7 EBA7 EFA78D EBA7 +EBA8 EBA8 E79992 EBA8 +EBA9 EBA9 EFA78E EBA9 +EBAA EBAA EFA78F EBAA +EBAB EBAB E7B6AD EBAB +EBAC EBAC E887BE EBAC +EBAD EBAD E890B8 EBAD +EBAE EBAE E8A395 EBAE +EBAF EBAF E8AA98 EBAF +EBB0 EBB0 E8AB9B EBB0 +EBB1 EBB1 E8ABAD EBB1 +EBB2 EBB2 E8B8B0 EBB2 +EBB3 EBB3 E8B982 EBB3 +EBB4 EBB4 E9818A EBB4 +EBB5 EBB5 E980BE EBB5 +EBB6 EBB6 E981BA EBB6 +EBB7 EBB7 E98589 EBB7 +EBB8 EBB8 E98789 EBB8 +EBB9 EBB9 E98DAE EBB9 +EBBA EBBA EFA790 EBBA +EBBB EBBB EFA791 EBBB +EBBC EBBC E5A089 EBBC +EBBD EBBD EFA792 EBBD +EBBE EBBE E6AF93 EBBE +EBBF EBBF E88289 EBBF +EBC0 EBC0 E882B2 EBC0 +EBC1 EBC1 EFA793 EBC1 +EBC2 EBC2 EFA794 EBC2 +EBC3 EBC3 E58581 EBC3 +EBC4 EBC4 E5A5AB EBC4 +EBC5 EBC5 E5B0B9 EBC5 +EBC6 EBC6 EFA795 EBC6 +EBC7 EBC7 EFA796 EBC7 +EBC8 EBC8 E6BDA4 EBC8 +EBC9 EBC9 E78EA7 EBC9 +EBCA EBCA E883A4 EBCA +EBCB EBCB E8B487 EBCB +EBCC EBCC EFA797 EBCC +EBCD EBCD E98897 EBCD +EBCE EBCE E9968F EBCE +EBCF EBCF EFA798 EBCF +EBD0 EBD0 EFA799 EBD0 +EBD1 EBD1 EFA79A EBD1 +EBD2 EBD2 EFA79B EBD2 +EBD3 EBD3 E881BF EBD3 +EBD4 EBD4 E6888E EBD4 +EBD5 EBD5 E7809C EBD5 +EBD6 EBD6 E7B5A8 EBD6 +EBD7 EBD7 E89E8D EBD7 +EBD8 EBD8 EFA79C EBD8 +EBD9 EBD9 E59EA0 EBD9 +EBDA EBDA E681A9 EBDA +EBDB EBDB E68587 EBDB +EBDC EBDC E6AEB7 EBDC +EBDD EBDD E8AABE EBDD +EBDE EBDE E98A80 EBDE +EBDF EBDF E99AB1 EBDF +EBE0 EBE0 E4B999 EBE0 +EBE1 EBE1 E5909F EBE1 +EBE2 EBE2 E6B7AB EBE2 +EBE3 EBE3 E894AD EBE3 +EBE4 EBE4 E999B0 EBE4 +EBE5 EBE5 E99FB3 EBE5 +EBE6 EBE6 E9A3AE EBE6 +EBE7 EBE7 E68F96 EBE7 +EBE8 EBE8 E6B3A3 EBE8 +EBE9 EBE9 E98291 EBE9 +EBEA EBEA E5879D EBEA +EBEB EBEB E68789 EBEB +EBEC EBEC E886BA EBEC +EBED EBED E9B7B9 EBED +EBEE EBEE E4BE9D EBEE +EBEF EBEF E5809A EBEF +EBF0 EBF0 E58480 EBF0 +EBF1 EBF1 E5AE9C EBF1 +EBF2 EBF2 E6848F EBF2 +EBF3 EBF3 E687BF EBF3 +EBF4 EBF4 E693AC EBF4 +EBF5 EBF5 E6A485 EBF5 +EBF6 EBF6 E6AF85 EBF6 +EBF7 EBF7 E79691 EBF7 +EBF8 EBF8 E79FA3 EBF8 +EBF9 EBF9 E7BEA9 EBF9 +EBFA EBFA E889A4 EBFA +EBFB EBFB E8968F EBFB +EBFC EBFC E89FBB EBFC +EBFD EBFD E8A1A3 EBFD +EBFE EBFE E8AABC EBFE +ECA1 ECA1 E8ADB0 ECA1 +ECA2 ECA2 E986AB ECA2 +ECA3 ECA3 E4BA8C ECA3 +ECA4 ECA4 E4BBA5 ECA4 +ECA5 ECA5 E4BC8A ECA5 +ECA6 ECA6 EFA79D ECA6 +ECA7 ECA7 EFA79E ECA7 +ECA8 ECA8 E5A4B7 ECA8 +ECA9 ECA9 E5A7A8 ECA9 +ECAA ECAA EFA79F ECAA +ECAB ECAB E5B7B2 ECAB +ECAC ECAC E5BC9B ECAC +ECAD ECAD E5BD9B ECAD +ECAE ECAE E680A1 ECAE +ECAF ECAF EFA7A0 ECAF +ECB0 ECB0 EFA7A1 ECB0 +ECB1 ECB1 EFA7A2 ECB1 +ECB2 ECB2 EFA7A3 ECB2 +ECB3 ECB3 E788BE ECB3 +ECB4 ECB4 E78FA5 ECB4 +ECB5 ECB5 EFA7A4 ECB5 +ECB6 ECB6 E795B0 ECB6 +ECB7 ECB7 E7978D ECB7 +ECB8 ECB8 EFA7A5 ECB8 +ECB9 ECB9 E7A7BB ECB9 +ECBA ECBA EFA7A6 ECBA +ECBB ECBB E8808C ECBB +ECBC ECBC E880B3 ECBC +ECBD ECBD E88284 ECBD +ECBE ECBE E88BA1 ECBE +ECBF ECBF E88D91 ECBF +ECC0 ECC0 EFA7A7 ECC0 +ECC1 ECC1 EFA7A8 ECC1 +ECC2 ECC2 E8B2BD ECC2 +ECC3 ECC3 E8B2B3 ECC3 +ECC4 ECC4 E98287 ECC4 +ECC5 ECC5 EFA7A9 ECC5 +ECC6 ECC6 EFA7AA ECC6 +ECC7 ECC7 E9A3B4 ECC7 +ECC8 ECC8 E9A48C ECC8 +ECC9 ECC9 EFA7AB ECC9 +ECCA ECCA EFA7AC ECCA +ECCB ECCB E780B7 ECCB +ECCC ECCC E79B8A ECCC +ECCD ECCD E7BF8A ECCD +ECCE ECCE E7BF8C ECCE +ECCF ECCF E7BFBC ECCF +ECD0 ECD0 E8AC9A ECD0 +ECD1 ECD1 E4BABA ECD1 +ECD2 ECD2 E4BB81 ECD2 +ECD3 ECD3 E58883 ECD3 +ECD4 ECD4 E58DB0 ECD4 +ECD5 ECD5 EFA7AD ECD5 +ECD6 ECD6 E592BD ECD6 +ECD7 ECD7 E59BA0 ECD7 +ECD8 ECD8 E5A7BB ECD8 +ECD9 ECD9 E5AF85 ECD9 +ECDA ECDA E5BC95 ECDA +ECDB ECDB E5BF8D ECDB +ECDC ECDC E6B9AE ECDC +ECDD ECDD EFA7AE ECDD +ECDE ECDE EFA7AF ECDE +ECDF ECDF E7B5AA ECDF +ECE0 ECE0 E88CB5 ECE0 +ECE1 ECE1 EFA7B0 ECE1 +ECE2 ECE2 E89A93 ECE2 +ECE3 ECE3 E8AA8D ECE3 +ECE4 ECE4 EFA7B1 ECE4 +ECE5 ECE5 E99DAD ECE5 +ECE6 ECE6 E99DB7 ECE6 +ECE7 ECE7 EFA7B2 ECE7 +ECE8 ECE8 EFA7B3 ECE8 +ECE9 ECE9 E4B880 ECE9 +ECEA ECEA E4BD9A ECEA +ECEB ECEB E4BDBE ECEB +ECEC ECEC E5A3B9 ECEC +ECED ECED E697A5 ECED +ECEE ECEE E6BAA2 ECEE +ECEF ECEF E980B8 ECEF +ECF0 ECF0 E98EB0 ECF0 +ECF1 ECF1 E9A6B9 ECF1 +ECF2 ECF2 E4BBBB ECF2 +ECF3 ECF3 E5A3AC ECF3 +ECF4 ECF4 E5A68A ECF4 +ECF5 ECF5 E5A799 ECF5 +ECF6 ECF6 E68181 ECF6 +ECF7 ECF7 EFA7B4 ECF7 +ECF8 ECF8 EFA7B5 ECF8 +ECF9 ECF9 E7A894 ECF9 +ECFA ECFA EFA7B6 ECFA +ECFB ECFB E88D8F ECFB +ECFC ECFC E8B383 ECFC +ECFD ECFD E585A5 ECFD +ECFE ECFE E58D84 ECFE +EDA1 EDA1 EFA7B7 EDA1 +EDA2 EDA2 EFA7B8 EDA2 +EDA3 EDA3 EFA7B9 EDA3 +EDA4 EDA4 E4BB8D EDA4 +EDA5 EDA5 E589A9 EDA5 +EDA6 EDA6 E5AD95 EDA6 +EDA7 EDA7 E88ABF EDA7 +EDA8 EDA8 E4BB94 EDA8 +EDA9 EDA9 E588BA EDA9 +EDAA EDAA E592A8 EDAA +EDAB EDAB E5A789 EDAB +EDAC EDAC E5A7BF EDAC +EDAD EDAD E5AD90 EDAD +EDAE EDAE E5AD97 EDAE +EDAF EDAF E5AD9C EDAF +EDB0 EDB0 E681A3 EDB0 +EDB1 EDB1 E68588 EDB1 +EDB2 EDB2 E6BB8B EDB2 +EDB3 EDB3 E78299 EDB3 +EDB4 EDB4 E785AE EDB4 +EDB5 EDB5 E78E86 EDB5 +EDB6 EDB6 E793B7 EDB6 +EDB7 EDB7 E796B5 EDB7 +EDB8 EDB8 E7A381 EDB8 +EDB9 EDB9 E7B4AB EDB9 +EDBA EDBA E88085 EDBA +EDBB EDBB E887AA EDBB +EDBC EDBC E88CA8 EDBC +EDBD EDBD E89497 EDBD +EDBE EDBE E89789 EDBE +EDBF EDBF E8ABAE EDBF +EDC0 EDC0 E8B387 EDC0 +EDC1 EDC1 E99B8C EDC1 +EDC2 EDC2 E4BD9C EDC2 +EDC3 EDC3 E58BBA EDC3 +EDC4 EDC4 E59ABC EDC4 +EDC5 EDC5 E696AB EDC5 +EDC6 EDC6 E698A8 EDC6 +EDC7 EDC7 E781BC EDC7 +EDC8 EDC8 E782B8 EDC8 +EDC9 EDC9 E788B5 EDC9 +EDCA EDCA E7B6BD EDCA +EDCB EDCB E88A8D EDCB +EDCC EDCC E9858C EDCC +EDCD EDCD E99B80 EDCD +EDCE EDCE E9B5B2 EDCE +EDCF EDCF E5ADB1 EDCF +EDD0 EDD0 E6A3A7 EDD0 +EDD1 EDD1 E6AE98 EDD1 +EDD2 EDD2 E6BDBA EDD2 +EDD3 EDD3 E79B9E EDD3 +EDD4 EDD4 E5B291 EDD4 +EDD5 EDD5 E69AAB EDD5 +EDD6 EDD6 E6BD9B EDD6 +EDD7 EDD7 E7AEB4 EDD7 +EDD8 EDD8 E7B0AA EDD8 +EDD9 EDD9 E8A0B6 EDD9 +EDDA EDDA E99B9C EDDA +EDDB EDDB E4B888 EDDB +EDDC EDDC E4BB97 EDDC +EDDD EDDD E58CA0 EDDD +EDDE EDDE E5A0B4 EDDE +EDDF EDDF E5A2BB EDDF +EDE0 EDE0 E5A3AF EDE0 +EDE1 EDE1 E5A5AC EDE1 +EDE2 EDE2 E5B087 EDE2 +EDE3 EDE3 E5B8B3 EDE3 +EDE4 EDE4 E5BA84 EDE4 +EDE5 EDE5 E5BCB5 EDE5 +EDE6 EDE6 E68E8C EDE6 +EDE7 EDE7 E69AB2 EDE7 +EDE8 EDE8 E69D96 EDE8 +EDE9 EDE9 E6A89F EDE9 +EDEA EDEA E6AAA3 EDEA +EDEB EDEB E6AC8C EDEB +EDEC EDEC E6BCBF EDEC +EDED EDED E78986 EDED +EDEE EDEE EFA7BA EDEE +EDEF EDEF E78D90 EDEF +EDF0 EDF0 E7928B EDF0 +EDF1 EDF1 E7ABA0 EDF1 +EDF2 EDF2 E7B2A7 EDF2 +EDF3 EDF3 E885B8 EDF3 +EDF4 EDF4 E8879F EDF4 +EDF5 EDF5 E887A7 EDF5 +EDF6 EDF6 E88E8A EDF6 +EDF7 EDF7 E891AC EDF7 +EDF8 EDF8 E894A3 EDF8 +EDF9 EDF9 E89694 EDF9 +EDFA EDFA E8978F EDFA +EDFB EDFB E8A39D EDFB +EDFC EDFC E8B493 EDFC +EDFD EDFD E986AC EDFD +EDFE EDFE E995B7 EDFE +EEA1 EEA1 E99A9C EEA1 +EEA2 EEA2 E5868D EEA2 +EEA3 EEA3 E59389 EEA3 +EEA4 EEA4 E59CA8 EEA4 +EEA5 EEA5 E5AEB0 EEA5 +EEA6 EEA6 E6898D EEA6 +EEA7 EEA7 E69D90 EEA7 +EEA8 EEA8 E6A0BD EEA8 +EEA9 EEA9 E6A293 EEA9 +EEAA EEAA E6B8BD EEAA +EEAB EEAB E6BB93 EEAB +EEAC EEAC E781BD EEAC +EEAD EEAD E7B8A1 EEAD +EEAE EEAE E8A381 EEAE +EEAF EEAF E8B2A1 EEAF +EEB0 EEB0 E8BC89 EEB0 +EEB1 EEB1 E9BD8B EEB1 +EEB2 EEB2 E9BD8E EEB2 +EEB3 EEB3 E788AD EEB3 +EEB4 EEB4 E7AE8F EEB4 +EEB5 EEB5 E8AB8D EEB5 +EEB6 EEB6 E98C9A EEB6 +EEB7 EEB7 E4BD87 EEB7 +EEB8 EEB8 E4BD8E EEB8 +EEB9 EEB9 E584B2 EEB9 +EEBA EEBA E59280 EEBA +EEBB EEBB E5A790 EEBB +EEBC EEBC E5BA95 EEBC +EEBD EEBD E68AB5 EEBD +EEBE EEBE E69DB5 EEBE +EEBF EEBF E6A5AE EEBF +EEC0 EEC0 E6A897 EEC0 +EEC1 EEC1 E6B2AE EEC1 +EEC2 EEC2 E6B89A EEC2 +EEC3 EEC3 E78B99 EEC3 +EEC4 EEC4 E78CAA EEC4 +EEC5 EEC5 E796BD EEC5 +EEC6 EEC6 E7AEB8 EEC6 +EEC7 EEC7 E7B4B5 EEC7 +EEC8 EEC8 E88BA7 EEC8 +EEC9 EEC9 E88FB9 EEC9 +EECA EECA E89197 EECA +EECB EECB E897B7 EECB +EECC EECC E8A99B EECC +EECD EECD E8B2AF EECD +EECE EECE E8BA87 EECE +EECF EECF E98099 EECF +EED0 EED0 E982B8 EED0 +EED1 EED1 E99B8E EED1 +EED2 EED2 E9BD9F EED2 +EED3 EED3 E58BA3 EED3 +EED4 EED4 E5908A EED4 +EED5 EED5 E5ABA1 EED5 +EED6 EED6 E5AF82 EED6 +EED7 EED7 E69198 EED7 +EED8 EED8 E695B5 EED8 +EED9 EED9 E6BBB4 EED9 +EEDA EEDA E78B84 EEDA +EEDB EEDB EFA7BB EEDB +EEDC EEDC E79A84 EEDC +EEDD EEDD E7A98D EEDD +EEDE EEDE E7AC9B EEDE +EEDF EEDF E7B18D EEDF +EEE0 EEE0 E7B8BE EEE0 +EEE1 EEE1 E7BF9F EEE1 +EEE2 EEE2 E88DBB EEE2 +EEE3 EEE3 E8ACAB EEE3 +EEE4 EEE4 E8B38A EEE4 +EEE5 EEE5 E8B5A4 EEE5 +EEE6 EEE6 E8B7A1 EEE6 +EEE7 EEE7 E8B99F EEE7 +EEE8 EEE8 E8BFAA EEE8 +EEE9 EEE9 E8BFB9 EEE9 +EEEA EEEA E981A9 EEEA +EEEB EEEB E98F91 EEEB +EEEC EEEC E4BD83 EEEC +EEED EEED E4BDBA EEED +EEEE EEEE E582B3 EEEE +EEEF EEEF E585A8 EEEF +EEF0 EEF0 E585B8 EEF0 +EEF1 EEF1 E5898D EEF1 +EEF2 EEF2 E589AA EEF2 +EEF3 EEF3 E5A1A1 EEF3 +EEF4 EEF4 E5A1BC EEF4 +EEF5 EEF5 E5A5A0 EEF5 +EEF6 EEF6 E5B088 EEF6 +EEF7 EEF7 E5B195 EEF7 +EEF8 EEF8 E5BB9B EEF8 +EEF9 EEF9 E6829B EEF9 +EEFA EEFA E688B0 EEFA +EEFB EEFB E6A093 EEFB +EEFC EEFC E6AEBF EEFC +EEFD EEFD E6B088 EEFD +EEFE EEFE E6BEB1 EEFE +EFA1 EFA1 E7858E EFA1 +EFA2 EFA2 E790A0 EFA2 +EFA3 EFA3 E794B0 EFA3 +EFA4 EFA4 E794B8 EFA4 +EFA5 EFA5 E79591 EFA5 +EFA6 EFA6 E799B2 EFA6 +EFA7 EFA7 E7AD8C EFA7 +EFA8 EFA8 E7AE8B EFA8 +EFA9 EFA9 E7AEAD EFA9 +EFAA EFAA E7AF86 EFAA +EFAB EFAB E7BA8F EFAB +EFAC EFAC E8A9AE EFAC +EFAD EFAD E8BCBE EFAD +EFAE EFAE E8BD89 EFAE +EFAF EFAF E988BF EFAF +EFB0 EFB0 E98A93 EFB0 +EFB1 EFB1 E98CA2 EFB1 +EFB2 EFB2 E990AB EFB2 +EFB3 EFB3 E99BBB EFB3 +EFB4 EFB4 E9A19A EFB4 +EFB5 EFB5 E9A1AB EFB5 +EFB6 EFB6 E9A49E EFB6 +EFB7 EFB7 E58887 EFB7 +EFB8 EFB8 E688AA EFB8 +EFB9 EFB9 E68A98 EFB9 +EFBA EFBA E6B599 EFBA +EFBB EFBB E799A4 EFBB +EFBC EFBC E7AB8A EFBC +EFBD EFBD E7AF80 EFBD +EFBE EFBE E7B5B6 EFBE +EFBF EFBF E58DA0 EFBF +EFC0 EFC0 E5B2BE EFC0 +EFC1 EFC1 E5BA97 EFC1 +EFC2 EFC2 E6BCB8 EFC2 +EFC3 EFC3 E782B9 EFC3 +EFC4 EFC4 E7B298 EFC4 +EFC5 EFC5 E99C91 EFC5 +EFC6 EFC6 E9AE8E EFC6 +EFC7 EFC7 E9BB9E EFC7 +EFC8 EFC8 E68EA5 EFC8 +EFC9 EFC9 E691BA EFC9 +EFCA EFCA E89DB6 EFCA +EFCB EFCB E4B881 EFCB +EFCC EFCC E4BA95 EFCC +EFCD EFCD E4BAAD EFCD +EFCE EFCE E5819C EFCE +EFCF EFCF E581B5 EFCF +EFD0 EFD0 E59188 EFD0 +EFD1 EFD1 E5A783 EFD1 +EFD2 EFD2 E5AE9A EFD2 +EFD3 EFD3 E5B980 EFD3 +EFD4 EFD4 E5BAAD EFD4 +EFD5 EFD5 E5BBB7 EFD5 +EFD6 EFD6 E5BE81 EFD6 +EFD7 EFD7 E68385 EFD7 +EFD8 EFD8 E68CBA EFD8 +EFD9 EFD9 E694BF EFD9 +EFDA EFDA E695B4 EFDA +EFDB EFDB E6978C EFDB +EFDC EFDC E699B6 EFDC +EFDD EFDD E699B8 EFDD +EFDE EFDE E69FBE EFDE +EFDF EFDF E6A5A8 EFDF +EFE0 EFE0 E6AA89 EFE0 +EFE1 EFE1 E6ADA3 EFE1 +EFE2 EFE2 E6B180 EFE2 +EFE3 EFE3 E6B780 EFE3 +EFE4 EFE4 E6B7A8 EFE4 +EFE5 EFE5 E6B89F EFE5 +EFE6 EFE6 E6B99E EFE6 +EFE7 EFE7 E7809E EFE7 +EFE8 EFE8 E782A1 EFE8 +EFE9 EFE9 E78E8E EFE9 +EFEA EFEA E78FBD EFEA +EFEB EFEB E794BA EFEB +EFEC EFEC E79D9B EFEC +EFED EFED E7A287 EFED +EFEE EFEE E7A68E EFEE +EFEF EFEF E7A88B EFEF +EFF0 EFF0 E7A9BD EFF0 +EFF1 EFF1 E7B2BE EFF1 +EFF2 EFF2 E7B68E EFF2 +EFF3 EFF3 E88987 EFF3 +EFF4 EFF4 E8A882 EFF4 +EFF5 EFF5 E8ABAA EFF5 +EFF6 EFF6 E8B29E EFF6 +EFF7 EFF7 E984AD EFF7 +EFF8 EFF8 E9858A EFF8 +EFF9 EFF9 E98798 EFF9 +EFFA EFFA E989A6 EFFA +EFFB EFFB E98B8C EFFB +EFFC EFFC E98CA0 EFFC +EFFD EFFD E99C86 EFFD +EFFE EFFE E99D96 EFFE +F0A1 F0A1 E99D9C F0A1 +F0A2 F0A2 E9A082 F0A2 +F0A3 F0A3 E9BC8E F0A3 +F0A4 F0A4 E588B6 F0A4 +F0A5 F0A5 E58A91 F0A5 +F0A6 F0A6 E595BC F0A6 +F0A7 F0A7 E5A0A4 F0A7 +F0A8 F0A8 E5B89D F0A8 +F0A9 F0A9 E5BC9F F0A9 +F0AA F0AA E6828C F0AA +F0AB F0AB E68F90 F0AB +F0AC F0AC E6A2AF F0AC +F0AD F0AD E6BF9F F0AD +F0AE F0AE E7A5AD F0AE +F0AF F0AF E7ACAC F0AF +F0B0 F0B0 E8878D F0B0 +F0B1 F0B1 E896BA F0B1 +F0B2 F0B2 E8A3BD F0B2 +F0B3 F0B3 E8ABB8 F0B3 +F0B4 F0B4 E8B984 F0B4 +F0B5 F0B5 E9868D F0B5 +F0B6 F0B6 E999A4 F0B6 +F0B7 F0B7 E99A9B F0B7 +F0B8 F0B8 E99CBD F0B8 +F0B9 F0B9 E9A18C F0B9 +F0BA F0BA E9BD8A F0BA +F0BB F0BB E4BF8E F0BB +F0BC F0BC E58586 F0BC +F0BD F0BD E5878B F0BD +F0BE F0BE E58AA9 F0BE +F0BF F0BF E598B2 F0BF +F0C0 F0C0 E5BC94 F0C0 +F0C1 F0C1 E5BDAB F0C1 +F0C2 F0C2 E68EAA F0C2 +F0C3 F0C3 E6938D F0C3 +F0C4 F0C4 E697A9 F0C4 +F0C5 F0C5 E69981 F0C5 +F0C6 F0C6 E69BBA F0C6 +F0C7 F0C7 E69BB9 F0C7 +F0C8 F0C8 E69C9D F0C8 +F0C9 F0C9 E6A29D F0C9 +F0CA F0CA E6A397 F0CA +F0CB F0CB E6A7BD F0CB +F0CC F0CC E6BC95 F0CC +F0CD F0CD E6BDAE F0CD +F0CE F0CE E785A7 F0CE +F0CF F0CF E787A5 F0CF +F0D0 F0D0 E788AA F0D0 +F0D1 F0D1 E792AA F0D1 +F0D2 F0D2 E79CBA F0D2 +F0D3 F0D3 E7A596 F0D3 +F0D4 F0D4 E7A59A F0D4 +F0D5 F0D5 E7A79F F0D5 +F0D6 F0D6 E7A8A0 F0D6 +F0D7 F0D7 E7AA95 F0D7 +F0D8 F0D8 E7B297 F0D8 +F0D9 F0D9 E7B39F F0D9 +F0DA F0DA E7B584 F0DA +F0DB F0DB E7B9B0 F0DB +F0DC F0DC E88287 F0DC +F0DD F0DD E897BB F0DD +F0DE F0DE E89AA4 F0DE +F0DF F0DF E8A994 F0DF +F0E0 F0E0 E8AABF F0E0 +F0E1 F0E1 E8B699 F0E1 +F0E2 F0E2 E8BA81 F0E2 +F0E3 F0E3 E980A0 F0E3 +F0E4 F0E4 E981AD F0E4 +F0E5 F0E5 E987A3 F0E5 +F0E6 F0E6 E998BB F0E6 +F0E7 F0E7 E99B95 F0E7 +F0E8 F0E8 E9B3A5 F0E8 +F0E9 F0E9 E6978F F0E9 +F0EA F0EA E7B087 F0EA +F0EB F0EB E8B6B3 F0EB +F0EC F0EC E98F83 F0EC +F0ED F0ED E5AD98 F0ED +F0EE F0EE E5B08A F0EE +F0EF F0EF E58D92 F0EF +F0F0 F0F0 E68B99 F0F0 +F0F1 F0F1 E78C9D F0F1 +F0F2 F0F2 E580A7 F0F2 +F0F3 F0F3 E5AE97 F0F3 +F0F4 F0F4 E5BE9E F0F4 +F0F5 F0F5 E682B0 F0F5 +F0F6 F0F6 E685AB F0F6 +F0F7 F0F7 E6A395 F0F7 +F0F8 F0F8 E6B799 F0F8 +F0F9 F0F9 E790AE F0F9 +F0FA F0FA E7A8AE F0FA +F0FB F0FB E7B582 F0FB +F0FC F0FC E7B69C F0FC +F0FD F0FD E7B8B1 F0FD +F0FE F0FE E885AB F0FE +F1A1 F1A1 E8B8AA F1A1 +F1A2 F1A2 E8B8B5 F1A2 +F1A3 F1A3 E98DBE F1A3 +F1A4 F1A4 E99098 F1A4 +F1A5 F1A5 E4BD90 F1A5 +F1A6 F1A6 E59D90 F1A6 +F1A7 F1A7 E5B7A6 F1A7 +F1A8 F1A8 E5BAA7 F1A8 +F1A9 F1A9 E68CAB F1A9 +F1AA F1AA E7BDAA F1AA +F1AB F1AB E4B8BB F1AB +F1AC F1AC E4BD8F F1AC +F1AD F1AD E4BE8F F1AD +F1AE F1AE E5819A F1AE +F1AF F1AF E5A79D F1AF +F1B0 F1B0 E88384 F1B0 +F1B1 F1B1 E591AA F1B1 +F1B2 F1B2 E591A8 F1B2 +F1B3 F1B3 E597BE F1B3 +F1B4 F1B4 E5A58F F1B4 +F1B5 F1B5 E5AE99 F1B5 +F1B6 F1B6 E5B79E F1B6 +F1B7 F1B7 E5BB9A F1B7 +F1B8 F1B8 E6999D F1B8 +F1B9 F1B9 E69CB1 F1B9 +F1BA F1BA E69FB1 F1BA +F1BB F1BB E6A0AA F1BB +F1BC F1BC E6B3A8 F1BC +F1BD F1BD E6B4B2 F1BD +F1BE F1BE E6B98A F1BE +F1BF F1BF E6BE8D F1BF +F1C0 F1C0 E782B7 F1C0 +F1C1 F1C1 E78FA0 F1C1 +F1C2 F1C2 E79687 F1C2 +F1C3 F1C3 E7B18C F1C3 +F1C4 F1C4 E7B482 F1C4 +F1C5 F1C5 E7B4AC F1C5 +F1C6 F1C6 E7B6A2 F1C6 +F1C7 F1C7 E8889F F1C7 +F1C8 F1C8 E89B9B F1C8 +F1C9 F1C9 E8A8BB F1C9 +F1CA F1CA E8AA85 F1CA +F1CB F1CB E8B5B0 F1CB +F1CC F1CC E8BA8A F1CC +F1CD F1CD E8BCB3 F1CD +F1CE F1CE E980B1 F1CE +F1CF F1CF E9858E F1CF +F1D0 F1D0 E98592 F1D0 +F1D1 F1D1 E99184 F1D1 +F1D2 F1D2 E9A790 F1D2 +F1D3 F1D3 E7ABB9 F1D3 +F1D4 F1D4 E7B2A5 F1D4 +F1D5 F1D5 E4BF8A F1D5 +F1D6 F1D6 E58481 F1D6 +F1D7 F1D7 E58786 F1D7 +F1D8 F1D8 E59F88 F1D8 +F1D9 F1D9 E5AFAF F1D9 +F1DA F1DA E5B3BB F1DA +F1DB F1DB E69999 F1DB +F1DC F1DC E6A8BD F1DC +F1DD F1DD E6B59A F1DD +F1DE F1DE E6BA96 F1DE +F1DF F1DF E6BFAC F1DF +F1E0 F1E0 E7848C F1E0 +F1E1 F1E1 E795AF F1E1 +F1E2 F1E2 E7ABA3 F1E2 +F1E3 F1E3 E8A0A2 F1E3 +F1E4 F1E4 E980A1 F1E4 +F1E5 F1E5 E981B5 F1E5 +F1E6 F1E6 E99B8B F1E6 +F1E7 F1E7 E9A7BF F1E7 +F1E8 F1E8 E88C81 F1E8 +F1E9 F1E9 E4B8AD F1E9 +F1EA F1EA E4BBB2 F1EA +F1EB F1EB E8A186 F1EB +F1EC F1EC E9878D F1EC +F1ED F1ED E58DBD F1ED +F1EE F1EE E6AB9B F1EE +F1EF F1EF E6A5AB F1EF +F1F0 F1F0 E6B181 F1F0 +F1F1 F1F1 E891BA F1F1 +F1F2 F1F2 E5A29E F1F2 +F1F3 F1F3 E6868E F1F3 +F1F4 F1F4 E69BBE F1F4 +F1F5 F1F5 E68BAF F1F5 +F1F6 F1F6 E7839D F1F6 +F1F7 F1F7 E79491 F1F7 +F1F8 F1F8 E79787 F1F8 +F1F9 F1F9 E7B992 F1F9 +F1FA F1FA E892B8 F1FA +F1FB F1FB E8AD89 F1FB +F1FC F1FC E8B488 F1FC +F1FD F1FD E4B98B F1FD +F1FE F1FE E58FAA F1FE +F2A1 F2A1 E592AB F2A1 +F2A2 F2A2 E59CB0 F2A2 +F2A3 F2A3 E59D80 F2A3 +F2A4 F2A4 E5BF97 F2A4 +F2A5 F2A5 E68C81 F2A5 +F2A6 F2A6 E68C87 F2A6 +F2A7 F2A7 E691AF F2A7 +F2A8 F2A8 E694AF F2A8 +F2A9 F2A9 E697A8 F2A9 +F2AA F2AA E699BA F2AA +F2AB F2AB E69E9D F2AB +F2AC F2AC E69EB3 F2AC +F2AD F2AD E6ADA2 F2AD +F2AE F2AE E6B1A0 F2AE +F2AF F2AF E6B29A F2AF +F2B0 F2B0 E6BCAC F2B0 +F2B1 F2B1 E79FA5 F2B1 +F2B2 F2B2 E7A0A5 F2B2 +F2B3 F2B3 E7A589 F2B3 +F2B4 F2B4 E7A597 F2B4 +F2B5 F2B5 E7B499 F2B5 +F2B6 F2B6 E882A2 F2B6 +F2B7 F2B7 E88482 F2B7 +F2B8 F2B8 E887B3 F2B8 +F2B9 F2B9 E88A9D F2B9 +F2BA F2BA E88AB7 F2BA +F2BB F2BB E89C98 F2BB +F2BC F2BC E8AA8C F2BC +F2BD F2BD EFA7BC F2BD +F2BE F2BE E8B484 F2BE +F2BF F2BF E8B6BE F2BF +F2C0 F2C0 E981B2 F2C0 +F2C1 F2C1 E79BB4 F2C1 +F2C2 F2C2 E7A899 F2C2 +F2C3 F2C3 E7A8B7 F2C3 +F2C4 F2C4 E7B994 F2C4 +F2C5 F2C5 E881B7 F2C5 +F2C6 F2C6 E59487 F2C6 +F2C7 F2C7 E59794 F2C7 +F2C8 F2C8 E5A1B5 F2C8 +F2C9 F2C9 E68CAF F2C9 +F2CA F2CA E690A2 F2CA +F2CB F2CB E69989 F2CB +F2CC F2CC E6998B F2CC +F2CD F2CD E6A1AD F2CD +F2CE F2CE E6A69B F2CE +F2CF F2CF E6AE84 F2CF +F2D0 F2D0 E6B4A5 F2D0 +F2D1 F2D1 E6BAB1 F2D1 +F2D2 F2D2 E78F8D F2D2 +F2D3 F2D3 E791A8 F2D3 +F2D4 F2D4 E792A1 F2D4 +F2D5 F2D5 E7959B F2D5 +F2D6 F2D6 E796B9 F2D6 +F2D7 F2D7 E79BA1 F2D7 +F2D8 F2D8 E79C9E F2D8 +F2D9 F2D9 E79E8B F2D9 +F2DA F2DA E7A7A6 F2DA +F2DB F2DB E7B889 F2DB +F2DC F2DC E7B89D F2DC +F2DD F2DD E887BB F2DD +F2DE F2DE E894AF F2DE +F2DF F2DF E8A297 F2DF +F2E0 F2E0 E8A8BA F2E0 +F2E1 F2E1 E8B391 F2E1 +F2E2 F2E2 E8BBAB F2E2 +F2E3 F2E3 E8BEB0 F2E3 +F2E4 F2E4 E980B2 F2E4 +F2E5 F2E5 E98EAD F2E5 +F2E6 F2E6 E999A3 F2E6 +F2E7 F2E7 E999B3 F2E7 +F2E8 F2E8 E99C87 F2E8 +F2E9 F2E9 E4BE84 F2E9 +F2EA F2EA E58FB1 F2EA +F2EB F2EB E5A7AA F2EB +F2EC F2EC E5AB89 F2EC +F2ED F2ED E5B899 F2ED +F2EE F2EE E6A18E F2EE +F2EF F2EF E79386 F2EF +F2F0 F2F0 E796BE F2F0 +F2F1 F2F1 E7A7A9 F2F1 +F2F2 F2F2 E7AA92 F2F2 +F2F3 F2F3 E886A3 F2F3 +F2F4 F2F4 E89BAD F2F4 +F2F5 F2F5 E8B3AA F2F5 +F2F6 F2F6 E8B78C F2F6 +F2F7 F2F7 E8BFAD F2F7 +F2F8 F2F8 E6969F F2F8 +F2F9 F2F9 E69C95 F2F9 +F2FA F2FA EFA7BD F2FA +F2FB F2FB E59FB7 F2FB +F2FC F2FC E6BD97 F2FC +F2FD F2FD E7B79D F2FD +F2FE F2FE E8BCAF F2FE +F3A1 F3A1 E98FB6 F3A1 +F3A2 F3A2 E99B86 F3A2 +F3A3 F3A3 E5BEB5 F3A3 +F3A4 F3A4 E687B2 F3A4 +F3A5 F3A5 E6BE84 F3A5 +F3A6 F3A6 E4B894 F3A6 +F3A7 F3A7 E4BE98 F3A7 +F3A8 F3A8 E5809F F3A8 +F3A9 F3A9 E58F89 F3A9 +F3AA F3AA E5979F F3AA +F3AB F3AB E5B5AF F3AB +F3AC F3AC E5B7AE F3AC +F3AD F3AD E6ACA1 F3AD +F3AE F3AE E6ADA4 F3AE +F3AF F3AF E7A38B F3AF +F3B0 F3B0 E7AE9A F3B0 +F3B1 F3B1 EFA7BE F3B1 +F3B2 F3B2 E8B989 F3B2 +F3B3 F3B3 E8BB8A F3B3 +F3B4 F3B4 E981AE F3B4 +F3B5 F3B5 E68D89 F3B5 +F3B6 F3B6 E690BE F3B6 +F3B7 F3B7 E79D80 F3B7 +F3B8 F3B8 E7AA84 F3B8 +F3B9 F3B9 E98CAF F3B9 +F3BA F3BA E991BF F3BA +F3BB F3BB E9BDAA F3BB +F3BC F3BC E692B0 F3BC +F3BD F3BD E6BEAF F3BD +F3BE F3BE E787A6 F3BE +F3BF F3BF E792A8 F3BF +F3C0 F3C0 E7939A F3C0 +F3C1 F3C1 E7AB84 F3C1 +F3C2 F3C2 E7B092 F3C2 +F3C3 F3C3 E7BA82 F3C3 +F3C4 F3C4 E7B2B2 F3C4 +F3C5 F3C5 E7BA98 F3C5 +F3C6 F3C6 E8AE9A F3C6 +F3C7 F3C7 E8B48A F3C7 +F3C8 F3C8 E991BD F3C8 +F3C9 F3C9 E9A490 F3C9 +F3CA F3CA E9A58C F3CA +F3CB F3CB E588B9 F3CB +F3CC F3CC E5AF9F F3CC +F3CD F3CD E693A6 F3CD +F3CE F3CE E69CAD F3CE +F3CF F3CF E7B4AE F3CF +F3D0 F3D0 E583AD F3D0 +F3D1 F3D1 E58F83 F3D1 +F3D2 F3D2 E5A1B9 F3D2 +F3D3 F3D3 E68598 F3D3 +F3D4 F3D4 E68599 F3D4 +F3D5 F3D5 E687BA F3D5 +F3D6 F3D6 E696AC F3D6 +F3D7 F3D7 E7AB99 F3D7 +F3D8 F3D8 E8AE92 F3D8 +F3D9 F3D9 E8AE96 F3D9 +F3DA F3DA E58089 F3DA +F3DB F3DB E580A1 F3DB +F3DC F3DC E589B5 F3DC +F3DD F3DD E594B1 F3DD +F3DE F3DE E5A8BC F3DE +F3DF F3DF E5BBA0 F3DF +F3E0 F3E0 E5BDB0 F3E0 +F3E1 F3E1 E684B4 F3E1 +F3E2 F3E2 E6959E F3E2 +F3E3 F3E3 E6988C F3E3 +F3E4 F3E4 E698B6 F3E4 +F3E5 F3E5 E69AA2 F3E5 +F3E6 F3E6 E6A78D F3E6 +F3E7 F3E7 E6BB84 F3E7 +F3E8 F3E8 E6BCB2 F3E8 +F3E9 F3E9 E78C96 F3E9 +F3EA F3EA E798A1 F3EA +F3EB F3EB E7AA93 F3EB +F3EC F3EC E884B9 F3EC +F3ED F3ED E88999 F3ED +F3EE F3EE E88F96 F3EE +F3EF F3EF E892BC F3EF +F3F0 F3F0 E582B5 F3F0 +F3F1 F3F1 E59FB0 F3F1 +F3F2 F3F2 E5AF80 F3F2 +F3F3 F3F3 E5AFA8 F3F3 +F3F4 F3F4 E5BDA9 F3F4 +F3F5 F3F5 E68EA1 F3F5 +F3F6 F3F6 E7A0A6 F3F6 +F3F7 F3F7 E7B6B5 F3F7 +F3F8 F3F8 E88F9C F3F8 +F3F9 F3F9 E894A1 F3F9 +F3FA F3FA E98787 F3FA +F3FB F3FB E987B5 F3FB +F3FC F3FC E5868A F3FC +F3FD F3FD E69FB5 F3FD +F3FE F3FE E7AD96 F3FE +F4A1 F4A1 E8B2AC F4A1 +F4A2 F4A2 E58784 F4A2 +F4A3 F4A3 E5A6BB F4A3 +F4A4 F4A4 E682BD F4A4 +F4A5 F4A5 E89995 F4A5 +F4A6 F4A6 E5809C F4A6 +F4A7 F4A7 EFA7BF F4A7 +F4A8 F4A8 E58994 F4A8 +F4A9 F4A9 E5B0BA F4A9 +F4AA F4AA E685BD F4AA +F4AB F4AB E6889A F4AB +F4AC F4AC E68B93 F4AC +F4AD F4AD E693B2 F4AD +F4AE F4AE E696A5 F4AE +F4AF F4AF E6BB8C F4AF +F4B0 F4B0 E798A0 F4B0 +F4B1 F4B1 E8848A F4B1 +F4B2 F4B2 E8B9A0 F4B2 +F4B3 F4B3 E9999F F4B3 +F4B4 F4B4 E99ABB F4B4 +F4B5 F4B5 E4BB9F F4B5 +F4B6 F4B6 E58D83 F4B6 +F4B7 F4B7 E59698 F4B7 +F4B8 F4B8 E5A4A9 F4B8 +F4B9 F4B9 E5B79D F4B9 +F4BA F4BA E69385 F4BA +F4BB F4BB E6B389 F4BB +F4BC F4BC E6B7BA F4BC +F4BD F4BD E78E94 F4BD +F4BE F4BE E7A9BF F4BE +F4BF F4BF E8889B F4BF +F4C0 F4C0 E896A6 F4C0 +F4C1 F4C1 E8B3A4 F4C1 +F4C2 F4C2 E8B890 F4C2 +F4C3 F4C3 E981B7 F4C3 +F4C4 F4C4 E987A7 F4C4 +F4C5 F4C5 E997A1 F4C5 +F4C6 F4C6 E998A1 F4C6 +F4C7 F4C7 E99F86 F4C7 +F4C8 F4C8 E587B8 F4C8 +F4C9 F4C9 E593B2 F4C9 +F4CA F4CA E59686 F4CA +F4CB F4CB E5BEB9 F4CB +F4CC F4CC E692A4 F4CC +F4CD F4CD E6BE88 F4CD +F4CE F4CE E7B6B4 F4CE +F4CF F4CF E8BC9F F4CF +F4D0 F4D0 E8BD8D F4D0 +F4D1 F4D1 E990B5 F4D1 +F4D2 F4D2 E58389 F4D2 +F4D3 F4D3 E5B096 F4D3 +F4D4 F4D4 E6B2BE F4D4 +F4D5 F4D5 E6B7BB F4D5 +F4D6 F4D6 E7949B F4D6 +F4D7 F4D7 E79EBB F4D7 +F4D8 F4D8 E7B0BD F4D8 +F4D9 F4D9 E7B1A4 F4D9 +F4DA F4DA E8A9B9 F4DA +F4DB F4DB E8AB82 F4DB +F4DC F4DC E5A09E F4DC +F4DD F4DD E5A6BE F4DD +F4DE F4DE E5B896 F4DE +F4DF F4DF E68DB7 F4DF +F4E0 F4E0 E78992 F4E0 +F4E1 F4E1 E7968A F4E1 +F4E2 F4E2 E79DAB F4E2 +F4E3 F4E3 E8AB9C F4E3 +F4E4 F4E4 E8B2BC F4E4 +F4E5 F4E5 E8BC92 F4E5 +F4E6 F4E6 E5BBB3 F4E6 +F4E7 F4E7 E699B4 F4E7 +F4E8 F4E8 E6B7B8 F4E8 +F4E9 F4E9 E881BD F4E9 +F4EA F4EA E88F81 F4EA +F4EB F4EB E8AB8B F4EB +F4EC F4EC E99D91 F4EC +F4ED F4ED E9AF96 F4ED +F4EE F4EE EFA880 F4EE +F4EF F4EF E58983 F4EF +F4F0 F4F0 E69BBF F4F0 +F4F1 F4F1 E6B695 F4F1 +F4F2 F4F2 E6BBAF F4F2 +F4F3 F4F3 E7B7A0 F4F3 +F4F4 F4F4 E8ABA6 F4F4 +F4F5 F4F5 E980AE F4F5 +F4F6 F4F6 E9819E F4F6 +F4F7 F4F7 E9AB94 F4F7 +F4F8 F4F8 E5889D F4F8 +F4F9 F4F9 E589BF F4F9 +F4FA F4FA E593A8 F4FA +F4FB F4FB E68694 F4FB +F4FC F4FC E68A84 F4FC +F4FD F4FD E68B9B F4FD +F4FE F4FE E6A2A2 F4FE +F5A1 F5A1 E6A492 F5A1 +F5A2 F5A2 E6A59A F5A2 +F5A3 F5A3 E6A8B5 F5A3 +F5A4 F5A4 E78292 F5A4 +F5A5 F5A5 E784A6 F5A5 +F5A6 F5A6 E7A19D F5A6 +F5A7 F5A7 E7A481 F5A7 +F5A8 F5A8 E7A48E F5A8 +F5A9 F5A9 E7A792 F5A9 +F5AA F5AA E7A88D F5AA +F5AB F5AB E88296 F5AB +F5AC F5AC E889B8 F5AC +F5AD F5AD E88B95 F5AD +F5AE F5AE E88D89 F5AE +F5AF F5AF E89589 F5AF +F5B0 F5B0 E8B282 F5B0 +F5B1 F5B1 E8B685 F5B1 +F5B2 F5B2 E985A2 F5B2 +F5B3 F5B3 E9868B F5B3 +F5B4 F5B4 E986AE F5B4 +F5B5 F5B5 E4BF83 F5B5 +F5B6 F5B6 E59B91 F5B6 +F5B7 F5B7 E787AD F5B7 +F5B8 F5B8 E79F97 F5B8 +F5B9 F5B9 E89C80 F5B9 +F5BA F5BA E8A7B8 F5BA +F5BB F5BB E5AFB8 F5BB +F5BC F5BC E5BF96 F5BC +F5BD F5BD E69D91 F5BD +F5BE F5BE E982A8 F5BE +F5BF F5BF E58FA2 F5BF +F5C0 F5C0 E5A19A F5C0 +F5C1 F5C1 E5AFB5 F5C1 +F5C2 F5C2 E682A4 F5C2 +F5C3 F5C3 E68681 F5C3 +F5C4 F5C4 E691A0 F5C4 +F5C5 F5C5 E7B8BD F5C5 +F5C6 F5C6 E881B0 F5C6 +F5C7 F5C7 E894A5 F5C7 +F5C8 F5C8 E98A83 F5C8 +F5C9 F5C9 E692AE F5C9 +F5CA F5CA E582AC F5CA +F5CB F5CB E5B494 F5CB +F5CC F5CC E69C80 F5CC +F5CD F5CD E5A29C F5CD +F5CE F5CE E68ABD F5CE +F5CF F5CF E68EA8 F5CF +F5D0 F5D0 E6A48E F5D0 +F5D1 F5D1 E6A5B8 F5D1 +F5D2 F5D2 E6A89E F5D2 +F5D3 F5D3 E6B9AB F5D3 +F5D4 F5D4 E79ABA F5D4 +F5D5 F5D5 E7A78B F5D5 +F5D6 F5D6 E88ABB F5D6 +F5D7 F5D7 E890A9 F5D7 +F5D8 F5D8 E8AB8F F5D8 +F5D9 F5D9 E8B6A8 F5D9 +F5DA F5DA E8BFBD F5DA +F5DB F5DB E98492 F5DB +F5DC F5DC E9858B F5DC +F5DD F5DD E9869C F5DD +F5DE F5DE E98C90 F5DE +F5DF F5DF E98C98 F5DF +F5E0 F5E0 E98E9A F5E0 +F5E1 F5E1 E99B9B F5E1 +F5E2 F5E2 E9A8B6 F5E2 +F5E3 F5E3 E9B08D F5E3 +F5E4 F5E4 E4B891 F5E4 +F5E5 F5E5 E7959C F5E5 +F5E6 F5E6 E7A59D F5E6 +F5E7 F5E7 E7ABBA F5E7 +F5E8 F5E8 E7AD91 F5E8 +F5E9 F5E9 E7AF89 F5E9 +F5EA F5EA E7B8AE F5EA +F5EB F5EB E89384 F5EB +F5EC F5EC E8B999 F5EC +F5ED F5ED E8B9B4 F5ED +F5EE F5EE E8BBB8 F5EE +F5EF F5EF E98090 F5EF +F5F0 F5F0 E698A5 F5F0 +F5F1 F5F1 E6A4BF F5F1 +F5F2 F5F2 E79183 F5F2 +F5F3 F5F3 E587BA F5F3 +F5F4 F5F4 E69CAE F5F4 +F5F5 F5F5 E9BB9C F5F5 +F5F6 F5F6 E58585 F5F6 +F5F7 F5F7 E5BFA0 F5F7 +F5F8 F5F8 E6B296 F5F8 +F5F9 F5F9 E89FB2 F5F9 +F5FA F5FA E8A19D F5FA +F5FB F5FB E8A1B7 F5FB +F5FC F5FC E682B4 F5FC +F5FD F5FD E886B5 F5FD +F5FE F5FE E89083 F5FE +F6A1 F6A1 E8B485 F6A1 +F6A2 F6A2 E58F96 F6A2 +F6A3 F6A3 E590B9 F6A3 +F6A4 F6A4 E598B4 F6A4 +F6A5 F6A5 E5A8B6 F6A5 +F6A6 F6A6 E5B0B1 F6A6 +F6A7 F6A7 E7828A F6A7 +F6A8 F6A8 E7BFA0 F6A8 +F6A9 F6A9 E8819A F6A9 +F6AA F6AA E88486 F6AA +F6AB F6AB E887AD F6AB +F6AC F6AC E8B6A3 F6AC +F6AD F6AD E98689 F6AD +F6AE F6AE E9A99F F6AE +F6AF F6AF E9B7B2 F6AF +F6B0 F6B0 E581B4 F6B0 +F6B1 F6B1 E4BB84 F6B1 +F6B2 F6B2 E58EA0 F6B2 +F6B3 F6B3 E683BB F6B3 +F6B4 F6B4 E6B8AC F6B4 +F6B5 F6B5 E5B1A4 F6B5 +F6B6 F6B6 E4BE88 F6B6 +F6B7 F6B7 E580A4 F6B7 +F6B8 F6B8 E597A4 F6B8 +F6B9 F6B9 E5B399 F6B9 +F6BA F6BA E5B99F F6BA +F6BB F6BB E681A5 F6BB +F6BC F6BC E6A294 F6BC +F6BD F6BD E6B2BB F6BD +F6BE F6BE E6B784 F6BE +F6BF F6BF E786BE F6BF +F6C0 F6C0 E79794 F6C0 +F6C1 F6C1 E797B4 F6C1 +F6C2 F6C2 E799A1 F6C2 +F6C3 F6C3 E7A89A F6C3 +F6C4 F6C4 E7A989 F6C4 +F6C5 F6C5 E7B787 F6C5 +F6C6 F6C6 E7B7BB F6C6 +F6C7 F6C7 E7BDAE F6C7 +F6C8 F6C8 E887B4 F6C8 +F6C9 F6C9 E89AA9 F6C9 +F6CA F6CA E8BC9C F6CA +F6CB F6CB E99B89 F6CB +F6CC F6CC E9A6B3 F6CC +F6CD F6CD E9BD92 F6CD +F6CE F6CE E58987 F6CE +F6CF F6CF E58B85 F6CF +F6D0 F6D0 E9A3AD F6D0 +F6D1 F6D1 E8A6AA F6D1 +F6D2 F6D2 E4B883 F6D2 +F6D3 F6D3 E69F92 F6D3 +F6D4 F6D4 E6BC86 F6D4 +F6D5 F6D5 E4BEB5 F6D5 +F6D6 F6D6 E5AFA2 F6D6 +F6D7 F6D7 E69E95 F6D7 +F6D8 F6D8 E6B288 F6D8 +F6D9 F6D9 E6B5B8 F6D9 +F6DA F6DA E7909B F6DA +F6DB F6DB E7A0A7 F6DB +F6DC F6DC E9879D F6DC +F6DD F6DD E98DBC F6DD +F6DE F6DE E89F84 F6DE +F6DF F6DF E7A7A4 F6DF +F6E0 F6E0 E7A8B1 F6E0 +F6E1 F6E1 E5BFAB F6E1 +F6E2 F6E2 E4BB96 F6E2 +F6E3 F6E3 E592A4 F6E3 +F6E4 F6E4 E594BE F6E4 +F6E5 F6E5 E5A2AE F6E5 +F6E6 F6E6 E5A6A5 F6E6 +F6E7 F6E7 E683B0 F6E7 +F6E8 F6E8 E68993 F6E8 +F6E9 F6E9 E68B96 F6E9 +F6EA F6EA E69CB6 F6EA +F6EB F6EB E6A595 F6EB +F6EC F6EC E888B5 F6EC +F6ED F6ED E99980 F6ED +F6EE F6EE E9A6B1 F6EE +F6EF F6EF E9A79D F6EF +F6F0 F6F0 E580AC F6F0 +F6F1 F6F1 E58D93 F6F1 +F6F2 F6F2 E59584 F6F2 +F6F3 F6F3 E59DBC F6F3 +F6F4 F6F4 EFA881 F6F4 +F6F5 F6F5 E68998 F6F5 +F6F6 F6F6 EFA882 F6F6 +F6F7 F6F7 E693A2 F6F7 +F6F8 F6F8 E699AB F6F8 +F6F9 F6F9 E69F9D F6F9 +F6FA F6FA E6BF81 F6FA +F6FB F6FB E6BFAF F6FB +F6FC F6FC E790A2 F6FC +F6FD F6FD E790B8 F6FD +F6FE F6FE E8A897 F6FE +F7A1 F7A1 E990B8 F7A1 +F7A2 F7A2 E59191 F7A2 +F7A3 F7A3 E59886 F7A3 +F7A4 F7A4 E59DA6 F7A4 +F7A5 F7A5 E5BD88 F7A5 +F7A6 F7A6 E6869A F7A6 +F7A7 F7A7 E6AD8E F7A7 +F7A8 F7A8 E78198 F7A8 +F7A9 F7A9 E782AD F7A9 +F7AA F7AA E7B6BB F7AA +F7AB F7AB E8AA95 F7AB +F7AC F7AC E5A5AA F7AC +F7AD F7AD E884AB F7AD +F7AE F7AE E68EA2 F7AE +F7AF F7AF E79C88 F7AF +F7B0 F7B0 E880BD F7B0 +F7B1 F7B1 E8B2AA F7B1 +F7B2 F7B2 E5A194 F7B2 +F7B3 F7B3 E690AD F7B3 +F7B4 F7B4 E6A6BB F7B4 +F7B5 F7B5 E5AE95 F7B5 +F7B6 F7B6 E5B891 F7B6 +F7B7 F7B7 E6B9AF F7B7 +F7B8 F7B8 EFA883 F7B8 +F7B9 F7B9 E895A9 F7B9 +F7BA F7BA E5858C F7BA +F7BB F7BB E58FB0 F7BB +F7BC F7BC E5A4AA F7BC +F7BD F7BD E680A0 F7BD +F7BE F7BE E6858B F7BE +F7BF F7BF E6AE86 F7BF +F7C0 F7C0 E6B1B0 F7C0 +F7C1 F7C1 E6B3B0 F7C1 +F7C2 F7C2 E7AC9E F7C2 +F7C3 F7C3 E8838E F7C3 +F7C4 F7C4 E88B94 F7C4 +F7C5 F7C5 E8B786 F7C5 +F7C6 F7C6 E982B0 F7C6 +F7C7 F7C7 E9A2B1 F7C7 +F7C8 F7C8 EFA884 F7C8 +F7C9 F7C9 E69387 F7C9 +F7CA F7CA E6BEA4 F7CA +F7CB F7CB E69291 F7CB +F7CC F7CC E69484 F7CC +F7CD F7CD E5858E F7CD +F7CE F7CE E59090 F7CE +F7CF F7CF E59C9F F7CF +F7D0 F7D0 E8A88E F7D0 +F7D1 F7D1 E6859F F7D1 +F7D2 F7D2 E6A1B6 F7D2 +F7D3 F7D3 EFA885 F7D3 +F7D4 F7D4 E7979B F7D4 +F7D5 F7D5 E7AD92 F7D5 +F7D6 F7D6 E7B5B1 F7D6 +F7D7 F7D7 E9809A F7D7 +F7D8 F7D8 E5A086 F7D8 +F7D9 F7D9 E6A78C F7D9 +F7DA F7DA E885BF F7DA +F7DB F7DB E8A4AA F7DB +F7DC F7DC E98080 F7DC +F7DD F7DD E9A0B9 F7DD +F7DE F7DE E581B8 F7DE +F7DF F7DF E5A597 F7DF +F7E0 F7E0 E5A6AC F7E0 +F7E1 F7E1 E68A95 F7E1 +F7E2 F7E2 E9808F F7E2 +F7E3 F7E3 E9ACAA F7E3 +F7E4 F7E4 E6859D F7E4 +F7E5 F7E5 E789B9 F7E5 +F7E6 F7E6 E99796 F7E6 +F7E7 F7E7 E59DA1 F7E7 +F7E8 F7E8 E5A986 F7E8 +F7E9 F7E9 E5B7B4 F7E9 +F7EA F7EA E68A8A F7EA +F7EB F7EB E692AD F7EB +F7EC F7EC E693BA F7EC +F7ED F7ED E69DB7 F7ED +F7EE F7EE E6B3A2 F7EE +F7EF F7EF E6B4BE F7EF +F7F0 F7F0 E788AC F7F0 +F7F1 F7F1 E790B6 F7F1 +F7F2 F7F2 E7A0B4 F7F2 +F7F3 F7F3 E7BDB7 F7F3 +F7F4 F7F4 E88AAD F7F4 +F7F5 F7F5 E8B79B F7F5 +F7F6 F7F6 E9A097 F7F6 +F7F7 F7F7 E588A4 F7F7 +F7F8 F7F8 E59D82 F7F8 +F7F9 F7F9 E69DBF F7F9 +F7FA F7FA E78988 F7FA +F7FB F7FB E793A3 F7FB +F7FC F7FC E8B2A9 F7FC +F7FD F7FD E8BEA6 F7FD +F7FE F7FE E98891 F7FE +F8A1 F8A1 E998AA F8A1 +F8A2 F8A2 E585AB F8A2 +F8A3 F8A3 E58FAD F8A3 +F8A4 F8A4 E68D8C F8A4 +F8A5 F8A5 E4BDA9 F8A5 +F8A6 F8A6 E59484 F8A6 +F8A7 F8A7 E68296 F8A7 +F8A8 F8A8 E69597 F8A8 +F8A9 F8A9 E6B29B F8A9 +F8AA F8AA E6B5BF F8AA +F8AB F8AB E7898C F8AB +F8AC F8AC E78BBD F8AC +F8AD F8AD E7A897 F8AD +F8AE F8AE E8A687 F8AE +F8AF F8AF E8B29D F8AF +F8B0 F8B0 E5BDAD F8B0 +F8B1 F8B1 E6BE8E F8B1 +F8B2 F8B2 E783B9 F8B2 +F8B3 F8B3 E886A8 F8B3 +F8B4 F8B4 E6848E F8B4 +F8B5 F8B5 E4BEBF F8B5 +F8B6 F8B6 E5818F F8B6 +F8B7 F8B7 E68981 F8B7 +F8B8 F8B8 E78987 F8B8 +F8B9 F8B9 E7AF87 F8B9 +F8BA F8BA E7B7A8 F8BA +F8BB F8BB E7BFA9 F8BB +F8BC F8BC E9818D F8BC +F8BD F8BD E99EAD F8BD +F8BE F8BE E9A899 F8BE +F8BF F8BF E8B2B6 F8BF +F8C0 F8C0 E59DAA F8C0 +F8C1 F8C1 E5B9B3 F8C1 +F8C2 F8C2 E69EB0 F8C2 +F8C3 F8C3 E8908D F8C3 +F8C4 F8C4 E8A995 F8C4 +F8C5 F8C5 E590A0 F8C5 +F8C6 F8C6 E5AC96 F8C6 +F8C7 F8C7 E5B9A3 F8C7 +F8C8 F8C8 E5BBA2 F8C8 +F8C9 F8C9 E5BC8A F8C9 +F8CA F8CA E69683 F8CA +F8CB F8CB E882BA F8CB +F8CC F8CC E894BD F8CC +F8CD F8CD E99689 F8CD +F8CE F8CE E9999B F8CE +F8CF F8CF E4BD88 F8CF +F8D0 F8D0 E58C85 F8D0 +F8D1 F8D1 E58C8D F8D1 +F8D2 F8D2 E58C8F F8D2 +F8D3 F8D3 E59286 F8D3 +F8D4 F8D4 E593BA F8D4 +F8D5 F8D5 E59C83 F8D5 +F8D6 F8D6 E5B883 F8D6 +F8D7 F8D7 E68096 F8D7 +F8D8 F8D8 E68A9B F8D8 +F8D9 F8D9 E68AB1 F8D9 +F8DA F8DA E68D95 F8DA +F8DB F8DB EFA886 F8DB +F8DC F8DC E6B3A1 F8DC +F8DD F8DD E6B5A6 F8DD +F8DE F8DE E796B1 F8DE +F8DF F8DF E7A0B2 F8DF +F8E0 F8E0 E8839E F8E0 +F8E1 F8E1 E884AF F8E1 +F8E2 F8E2 E88B9E F8E2 +F8E3 F8E3 E891A1 F8E3 +F8E4 F8E4 E892B2 F8E4 +F8E5 F8E5 E8A28D F8E5 +F8E6 F8E6 E8A492 F8E6 +F8E7 F8E7 E9808B F8E7 +F8E8 F8E8 E98BAA F8E8 +F8E9 F8E9 E9A3BD F8E9 +F8EA F8EA E9AE91 F8EA +F8EB F8EB E5B985 F8EB +F8EC F8EC E69AB4 F8EC +F8ED F8ED E69B9D F8ED +F8EE F8EE E78091 F8EE +F8EF F8EF E78886 F8EF +F8F0 F8F0 EFA887 F8F0 +F8F1 F8F1 E4BFB5 F8F1 +F8F2 F8F2 E589BD F8F2 +F8F3 F8F3 E5BDAA F8F3 +F8F4 F8F4 E68593 F8F4 +F8F5 F8F5 E69D93 F8F5 +F8F6 F8F6 E6A899 F8F6 +F8F7 F8F7 E6BC82 F8F7 +F8F8 F8F8 E793A2 F8F8 +F8F9 F8F9 E7A5A8 F8F9 +F8FA F8FA E8A1A8 F8FA +F8FB F8FB E8B1B9 F8FB +F8FC F8FC E9A387 F8FC +F8FD F8FD E9A384 F8FD +F8FE F8FE E9A983 F8FE +F9A1 F9A1 E59381 F9A1 +F9A2 F9A2 E7A89F F9A2 +F9A3 F9A3 E6A593 F9A3 +F9A4 F9A4 E8ABB7 F9A4 +F9A5 F9A5 E8B18A F9A5 +F9A6 F9A6 E9A2A8 F9A6 +F9A7 F9A7 E9A6AE F9A7 +F9A8 F9A8 E5BDBC F9A8 +F9A9 F9A9 E68AAB F9A9 +F9AA F9AA E796B2 F9AA +F9AB F9AB E79AAE F9AB +F9AC F9AC E8A2AB F9AC +F9AD F9AD E981BF F9AD +F9AE F9AE E99982 F9AE +F9AF F9AF E58CB9 F9AF +F9B0 F9B0 E5BCBC F9B0 +F9B1 F9B1 E5BF85 F9B1 +F9B2 F9B2 E6B38C F9B2 +F9B3 F9B3 E78F8C F9B3 +F9B4 F9B4 E795A2 F9B4 +F9B5 F9B5 E7968B F9B5 +F9B6 F9B6 E7AD86 F9B6 +F9B7 F9B7 E88BBE F9B7 +F9B8 F9B8 E9A69D F9B8 +F9B9 F9B9 E4B98F F9B9 +F9BA F9BA E980BC F9BA +F9BB F9BB E4B88B F9BB +F9BC F9BC E4BD95 F9BC +F9BD F9BD E58EA6 F9BD +F9BE F9BE E5A48F F9BE +F9BF F9BF E5BB88 F9BF +F9C0 F9C0 E698B0 F9C0 +F9C1 F9C1 E6B2B3 F9C1 +F9C2 F9C2 E79195 F9C2 +F9C3 F9C3 E88DB7 F9C3 +F9C4 F9C4 E89DA6 F9C4 +F9C5 F9C5 E8B380 F9C5 +F9C6 F9C6 E98190 F9C6 +F9C7 F9C7 E99C9E F9C7 +F9C8 F9C8 E9B095 F9C8 +F9C9 F9C9 E5A391 F9C9 +F9CA F9CA E5ADB8 F9CA +F9CB F9CB E89990 F9CB +F9CC F9CC E8AC94 F9CC +F9CD F9CD E9B6B4 F9CD +F9CE F9CE E5AF92 F9CE +F9CF F9CF E681A8 F9CF +F9D0 F9D0 E6828D F9D0 +F9D1 F9D1 E697B1 F9D1 +F9D2 F9D2 E6B197 F9D2 +F9D3 F9D3 E6BCA2 F9D3 +F9D4 F9D4 E6BEA3 F9D4 +F9D5 F9D5 E7809A F9D5 +F9D6 F9D6 E7BD95 F9D6 +F9D7 F9D7 E7BFB0 F9D7 +F9D8 F9D8 E99691 F9D8 +F9D9 F9D9 E99692 F9D9 +F9DA F9DA E99990 F9DA +F9DB F9DB E99F93 F9DB +F9DC F9DC E589B2 F9DC +F9DD F9DD E8BD84 F9DD +F9DE F9DE E587BD F9DE +F9DF F9DF E590AB F9DF +F9E0 F9E0 E592B8 F9E0 +F9E1 F9E1 E595A3 F9E1 +F9E2 F9E2 E5968A F9E2 +F9E3 F9E3 E6AABB F9E3 +F9E4 F9E4 E6B6B5 F9E4 +F9E5 F9E5 E7B798 F9E5 +F9E6 F9E6 E889A6 F9E6 +F9E7 F9E7 E98A9C F9E7 +F9E8 F9E8 E999B7 F9E8 +F9E9 F9E9 E9B9B9 F9E9 +F9EA F9EA E59088 F9EA +F9EB F9EB E59388 F9EB +F9EC F9EC E79B92 F9EC +F9ED F9ED E89BA4 F9ED +F9EE F9EE E996A4 F9EE +F9EF F9EF E99794 F9EF +F9F0 F9F0 E9999C F9F0 +F9F1 F9F1 E4BAA2 F9F1 +F9F2 F9F2 E4BC89 F9F2 +F9F3 F9F3 E5A7AE F9F3 +F9F4 F9F4 E5ABA6 F9F4 +F9F5 F9F5 E5B7B7 F9F5 +F9F6 F9F6 E68192 F9F6 +F9F7 F9F7 E68A97 F9F7 +F9F8 F9F8 E69DAD F9F8 +F9F9 F9F9 E6A181 F9F9 +F9FA F9FA E6B286 F9FA +F9FB F9FB E6B8AF F9FB +F9FC F9FC E7BCB8 F9FC +F9FD F9FD E8829B F9FD +F9FE F9FE E888AA F9FE +FAA1 FAA1 EFA888 FAA1 +FAA2 FAA2 EFA889 FAA2 +FAA3 FAA3 E9A085 FAA3 +FAA4 FAA4 E4BAA5 FAA4 +FAA5 FAA5 E58195 FAA5 +FAA6 FAA6 E592B3 FAA6 +FAA7 FAA7 E59E93 FAA7 +FAA8 FAA8 E5A59A FAA8 +FAA9 FAA9 E5ADA9 FAA9 +FAAA FAAA E5AEB3 FAAA +FAAB FAAB E68788 FAAB +FAAC FAAC E6A5B7 FAAC +FAAD FAAD E6B5B7 FAAD +FAAE FAAE E780A3 FAAE +FAAF FAAF E89FB9 FAAF +FAB0 FAB0 E8A7A3 FAB0 +FAB1 FAB1 E8A9B2 FAB1 +FAB2 FAB2 E8ABA7 FAB2 +FAB3 FAB3 E98282 FAB3 +FAB4 FAB4 E9A7AD FAB4 +FAB5 FAB5 E9AAB8 FAB5 +FAB6 FAB6 E58ABE FAB6 +FAB7 FAB7 E6A0B8 FAB7 +FAB8 FAB8 E58096 FAB8 +FAB9 FAB9 E5B9B8 FAB9 +FABA FABA E69D8F FABA +FABB FABB E88D87 FABB +FABC FABC E8A18C FABC +FABD FABD E4BAAB FABD +FABE FABE E59091 FABE +FABF FABF E59AAE FABF +FAC0 FAC0 E78FA6 FAC0 +FAC1 FAC1 E98495 FAC1 +FAC2 FAC2 E99FBF FAC2 +FAC3 FAC3 E9A489 FAC3 +FAC4 FAC4 E9A597 FAC4 +FAC5 FAC5 E9A699 FAC5 +FAC6 FAC6 E59993 FAC6 +FAC7 FAC7 E5A29F FAC7 +FAC8 FAC8 E8999B FAC8 +FAC9 FAC9 E8A8B1 FAC9 +FACA FACA E686B2 FACA +FACB FACB E6ABB6 FACB +FACC FACC E78DBB FACC +FACD FACD E8BB92 FACD +FACE FACE E6AD87 FACE +FACF FACF E99AAA FACF +FAD0 FAD0 E9A997 FAD0 +FAD1 FAD1 E5A595 FAD1 +FAD2 FAD2 E78880 FAD2 +FAD3 FAD3 E8B5AB FAD3 +FAD4 FAD4 E99DA9 FAD4 +FAD5 FAD5 E4BF94 FAD5 +FAD6 FAD6 E5B3B4 FAD6 +FAD7 FAD7 E5BCA6 FAD7 +FAD8 FAD8 E687B8 FAD8 +FAD9 FAD9 E6999B FAD9 +FADA FADA E6B3AB FADA +FADB FADB E782AB FADB +FADC FADC E78E84 FADC +FADD FADD E78EB9 FADD +FADE FADE E78FBE FADE +FADF FADF E79CA9 FADF +FAE0 FAE0 E79D8D FAE0 +FAE1 FAE1 E7B583 FAE1 +FAE2 FAE2 E7B5A2 FAE2 +FAE3 FAE3 E7B8A3 FAE3 +FAE4 FAE4 E888B7 FAE4 +FAE5 FAE5 E8A192 FAE5 +FAE6 FAE6 EFA88A FAE6 +FAE7 FAE7 E8B3A2 FAE7 +FAE8 FAE8 E98989 FAE8 +FAE9 FAE9 E9A1AF FAE9 +FAEA FAEA E5AD91 FAEA +FAEB FAEB E7A9B4 FAEB +FAEC FAEC E8A180 FAEC +FAED FAED E9A081 FAED +FAEE FAEE E5AB8C FAEE +FAEF FAEF E4BFA0 FAEF +FAF0 FAF0 E58D94 FAF0 +FAF1 FAF1 E5A4BE FAF1 +FAF2 FAF2 E5B3BD FAF2 +FAF3 FAF3 E68CBE FAF3 +FAF4 FAF4 E6B5B9 FAF4 +FAF5 FAF5 E78BB9 FAF5 +FAF6 FAF6 E88485 FAF6 +FAF7 FAF7 E88487 FAF7 +FAF8 FAF8 E88EA2 FAF8 +FAF9 FAF9 E98B8F FAF9 +FAFA FAFA E9A0B0 FAFA +FAFB FAFB E4BAA8 FAFB +FAFC FAFC E58584 FAFC +FAFD FAFD E58891 FAFD +FAFE FAFE E59E8B FAFE +FBA1 FBA1 E5BDA2 FBA1 +FBA2 FBA2 E6B382 FBA2 +FBA3 FBA3 E6BB8E FBA3 +FBA4 FBA4 E78085 FBA4 +FBA5 FBA5 E78190 FBA5 +FBA6 FBA6 E782AF FBA6 +FBA7 FBA7 E78692 FBA7 +FBA8 FBA8 E78FA9 FBA8 +FBA9 FBA9 E791A9 FBA9 +FBAA FBAA E88D8A FBAA +FBAB FBAB E89EA2 FBAB +FBAC FBAC E8A1A1 FBAC +FBAD FBAD E98088 FBAD +FBAE FBAE E982A2 FBAE +FBAF FBAF E98EA3 FBAF +FBB0 FBB0 E9A6A8 FBB0 +FBB1 FBB1 E585AE FBB1 +FBB2 FBB2 E5BD97 FBB2 +FBB3 FBB3 E683A0 FBB3 +FBB4 FBB4 E685A7 FBB4 +FBB5 FBB5 E69AB3 FBB5 +FBB6 FBB6 E89599 FBB6 +FBB7 FBB7 E8B98A FBB7 +FBB8 FBB8 E986AF FBB8 +FBB9 FBB9 E99E8B FBB9 +FBBA FBBA E4B98E FBBA +FBBB FBBB E4BA92 FBBB +FBBC FBBC E591BC FBBC +FBBD FBBD E5A395 FBBD +FBBE FBBE E5A3BA FBBE +FBBF FBBF E5A5BD FBBF +FBC0 FBC0 E5B2B5 FBC0 +FBC1 FBC1 E5BCA7 FBC1 +FBC2 FBC2 E688B6 FBC2 +FBC3 FBC3 E68988 FBC3 +FBC4 FBC4 E6988A FBC4 +FBC5 FBC5 E699A7 FBC5 +FBC6 FBC6 E6AFAB FBC6 +FBC7 FBC7 E6B5A9 FBC7 +FBC8 FBC8 E6B78F FBC8 +FBC9 FBC9 E6B996 FBC9 +FBCA FBCA E6BBB8 FBCA +FBCB FBCB E6BE94 FBCB +FBCC FBCC E6BFA0 FBCC +FBCD FBCD E6BFA9 FBCD +FBCE FBCE E7819D FBCE +FBCF FBCF E78B90 FBCF +FBD0 FBD0 E790A5 FBD0 +FBD1 FBD1 E7919A FBD1 +FBD2 FBD2 E793A0 FBD2 +FBD3 FBD3 E79A93 FBD3 +FBD4 FBD4 E7A59C FBD4 +FBD5 FBD5 E7B38A FBD5 +FBD6 FBD6 E7B89E FBD6 +FBD7 FBD7 E883A1 FBD7 +FBD8 FBD8 E88AA6 FBD8 +FBD9 FBD9 E891AB FBD9 +FBDA FBDA E892BF FBDA +FBDB FBDB E8998E FBDB +FBDC FBDC E8999F FBDC +FBDD FBDD E89DB4 FBDD +FBDE FBDE E8ADB7 FBDE +FBDF FBDF E8B1AA FBDF +FBE0 FBE0 E98EAC FBE0 +FBE1 FBE1 E9A080 FBE1 +FBE2 FBE2 E9A1A5 FBE2 +FBE3 FBE3 E68391 FBE3 +FBE4 FBE4 E68896 FBE4 +FBE5 FBE5 E985B7 FBE5 +FBE6 FBE6 E5A99A FBE6 +FBE7 FBE7 E6988F FBE7 +FBE8 FBE8 E6B7B7 FBE8 +FBE9 FBE9 E6B8BE FBE9 +FBEA FBEA E790BF FBEA +FBEB FBEB E9AD82 FBEB +FBEC FBEC E5BFBD FBEC +FBED FBED E6839A FBED +FBEE FBEE E7AC8F FBEE +FBEF FBEF E59384 FBEF +FBF0 FBF0 E5BC98 FBF0 +FBF1 FBF1 E6B19E FBF1 +FBF2 FBF2 E6B393 FBF2 +FBF3 FBF3 E6B4AA FBF3 +FBF4 FBF4 E78398 FBF4 +FBF5 FBF5 E7B485 FBF5 +FBF6 FBF6 E899B9 FBF6 +FBF7 FBF7 E8A88C FBF7 +FBF8 FBF8 E9B4BB FBF8 +FBF9 FBF9 E58C96 FBF9 +FBFA FBFA E5928C FBFA +FBFB FBFB E5AC85 FBFB +FBFC FBFC E6A8BA FBFC +FBFD FBFD E781AB FBFD +FBFE FBFE E795B5 FBFE +FCA1 FCA1 E7A68D FCA1 +FCA2 FCA2 E7A6BE FCA2 +FCA3 FCA3 E88AB1 FCA3 +FCA4 FCA4 E88FAF FCA4 +FCA5 FCA5 E8A9B1 FCA5 +FCA6 FCA6 E8AD81 FCA6 +FCA7 FCA7 E8B2A8 FCA7 +FCA8 FCA8 E99DB4 FCA8 +FCA9 FCA9 EFA88B FCA9 +FCAA FCAA E693B4 FCAA +FCAB FCAB E694AB FCAB +FCAC FCAC E7A2BA FCAC +FCAD FCAD E7A2BB FCAD +FCAE FCAE E7A9AB FCAE +FCAF FCAF E4B8B8 FCAF +FCB0 FCB0 E5969A FCB0 +FCB1 FCB1 E5A590 FCB1 +FCB2 FCB2 E5AEA6 FCB2 +FCB3 FCB3 E5B9BB FCB3 +FCB4 FCB4 E682A3 FCB4 +FCB5 FCB5 E68F9B FCB5 +FCB6 FCB6 E6ADA1 FCB6 +FCB7 FCB7 E699A5 FCB7 +FCB8 FCB8 E6A193 FCB8 +FCB9 FCB9 E6B899 FCB9 +FCBA FCBA E785A5 FCBA +FCBB FCBB E792B0 FCBB +FCBC FCBC E7B488 FCBC +FCBD FCBD E98284 FCBD +FCBE FCBE E9A9A9 FCBE +FCBF FCBF E9B0A5 FCBF +FCC0 FCC0 E6B4BB FCC0 +FCC1 FCC1 E6BB91 FCC1 +FCC2 FCC2 E78CBE FCC2 +FCC3 FCC3 E8B181 FCC3 +FCC4 FCC4 E9978A FCC4 +FCC5 FCC5 E587B0 FCC5 +FCC6 FCC6 E5B98C FCC6 +FCC7 FCC7 E5BEA8 FCC7 +FCC8 FCC8 E6818D FCC8 +FCC9 FCC9 E683B6 FCC9 +FCCA FCCA E684B0 FCCA +FCCB FCCB E6858C FCCB +FCCC FCCC E69983 FCCC +FCCD FCCD E69984 FCCD +FCCE FCCE E6A6A5 FCCE +FCCF FCCF E6B381 FCCF +FCD0 FCD0 E6B99F FCD0 +FCD1 FCD1 E6BB89 FCD1 +FCD2 FCD2 E6BDA2 FCD2 +FCD3 FCD3 E7858C FCD3 +FCD4 FCD4 E7929C FCD4 +FCD5 FCD5 E79A87 FCD5 +FCD6 FCD6 E7AF81 FCD6 +FCD7 FCD7 E7B0A7 FCD7 +FCD8 FCD8 E88D92 FCD8 +FCD9 FCD9 E89D97 FCD9 +FCDA FCDA E98191 FCDA +FCDB FCDB E99A8D FCDB +FCDC FCDC E9BB83 FCDC +FCDD FCDD E58CAF FCDD +FCDE FCDE E59B9E FCDE +FCDF FCDF E5BBBB FCDF +FCE0 FCE0 E5BE8A FCE0 +FCE1 FCE1 E681A2 FCE1 +FCE2 FCE2 E68294 FCE2 +FCE3 FCE3 E687B7 FCE3 +FCE4 FCE4 E699A6 FCE4 +FCE5 FCE5 E69C83 FCE5 +FCE6 FCE6 E6AA9C FCE6 +FCE7 FCE7 E6B7AE FCE7 +FCE8 FCE8 E6BEAE FCE8 +FCE9 FCE9 E781B0 FCE9 +FCEA FCEA E78DAA FCEA +FCEB FCEB E7B9AA FCEB +FCEC FCEC E886BE FCEC +FCED FCED E88CB4 FCED +FCEE FCEE E89B94 FCEE +FCEF FCEF E8AAA8 FCEF +FCF0 FCF0 E8B384 FCF0 +FCF1 FCF1 E58A83 FCF1 +FCF2 FCF2 E78DB2 FCF2 +FCF3 FCF3 E5AE96 FCF3 +FCF4 FCF4 E6A9AB FCF4 +FCF5 FCF5 E99084 FCF5 +FCF6 FCF6 E593AE FCF6 +FCF7 FCF7 E59A86 FCF7 +FCF8 FCF8 E5AD9D FCF8 +FCF9 FCF9 E69588 FCF9 +FCFA FCFA E69685 FCFA +FCFB FCFB E69B89 FCFB +FCFC FCFC E6A29F FCFC +FCFD FCFD E6B68D FCFD +FCFE FCFE E6B786 FCFE +FDA1 FDA1 E788BB FDA1 +FDA2 FDA2 E882B4 FDA2 +FDA3 FDA3 E985B5 FDA3 +FDA4 FDA4 E9A98D FDA4 +FDA5 FDA5 E4BEAF FDA5 +FDA6 FDA6 E58099 FDA6 +FDA7 FDA7 E58E9A FDA7 +FDA8 FDA8 E5908E FDA8 +FDA9 FDA9 E590BC FDA9 +FDAA FDAA E59689 FDAA +FDAB FDAB E59785 FDAB +FDAC FDAC E5B8BF FDAC +FDAD FDAD E5BE8C FDAD +FDAE FDAE E69CBD FDAE +FDAF FDAF E785A6 FDAF +FDB0 FDB0 E78F9D FDB0 +FDB1 FDB1 E98085 FDB1 +FDB2 FDB2 E58B9B FDB2 +FDB3 FDB3 E58BB3 FDB3 +FDB4 FDB4 E5A1A4 FDB4 +FDB5 FDB5 E5A38E FDB5 +FDB6 FDB6 E78484 FDB6 +FDB7 FDB7 E7868F FDB7 +FDB8 FDB8 E787BB FDB8 +FDB9 FDB9 E896B0 FDB9 +FDBA FDBA E8A893 FDBA +FDBB FDBB E69A88 FDBB +FDBC FDBC E896A8 FDBC +FDBD FDBD E596A7 FDBD +FDBE FDBE E69A84 FDBE +FDBF FDBF E7858A FDBF +FDC0 FDC0 E890B1 FDC0 +FDC1 FDC1 E58D89 FDC1 +FDC2 FDC2 E59699 FDC2 +FDC3 FDC3 E6AF81 FDC3 +FDC4 FDC4 E5BD99 FDC4 +FDC5 FDC5 E5BEBD FDC5 +FDC6 FDC6 E68FAE FDC6 +FDC7 FDC7 E69A89 FDC7 +FDC8 FDC8 E78587 FDC8 +FDC9 FDC9 E8ABB1 FDC9 +FDCA FDCA E8BC9D FDCA +FDCB FDCB E9BABE FDCB +FDCC FDCC E4BC91 FDCC +FDCD FDCD E690BA FDCD +FDCE FDCE E7838B FDCE +FDCF FDCF E795A6 FDCF +FDD0 FDD0 E899A7 FDD0 +FDD1 FDD1 E681A4 FDD1 +FDD2 FDD2 E8AD8E FDD2 +FDD3 FDD3 E9B7B8 FDD3 +FDD4 FDD4 E58587 FDD4 +FDD5 FDD5 E587B6 FDD5 +FDD6 FDD6 E58C88 FDD6 +FDD7 FDD7 E6B4B6 FDD7 +FDD8 FDD8 E883B8 FDD8 +FDD9 FDD9 E9BB91 FDD9 +FDDA FDDA E69895 FDDA +FDDB FDDB E6ACA3 FDDB +FDDC FDDC E78298 FDDC +FDDD FDDD E79795 FDDD +FDDE FDDE E59083 FDDE +FDDF FDDF E5B1B9 FDDF +FDE0 FDE0 E7B487 FDE0 +FDE1 FDE1 E8A896 FDE1 +FDE2 FDE2 E6ACA0 FDE2 +FDE3 FDE3 E6ACBD FDE3 +FDE4 FDE4 E6AD86 FDE4 +FDE5 FDE5 E590B8 FDE5 +FDE6 FDE6 E681B0 FDE6 +FDE7 FDE7 E6B4BD FDE7 +FDE8 FDE8 E7BF95 FDE8 +FDE9 FDE9 E88888 FDE9 +FDEA FDEA E58396 FDEA +FDEB FDEB E5879E FDEB +FDEC FDEC E5969C FDEC +FDED FDED E599AB FDED +FDEE FDEE E59B8D FDEE +FDEF FDEF E5A7AC FDEF +FDF0 FDF0 E5AC89 FDF0 +FDF1 FDF1 E5B88C FDF1 +FDF2 FDF2 E68699 FDF2 +FDF3 FDF3 E68698 FDF3 +FDF4 FDF4 E688B1 FDF4 +FDF5 FDF5 E6999E FDF5 +FDF6 FDF6 E69BA6 FDF6 +FDF7 FDF7 E78699 FDF7 +FDF8 FDF8 E786B9 FDF8 +FDF9 FDF9 E786BA FDF9 +FDFA FDFA E78AA7 FDFA +FDFB FDFB E7A6A7 FDFB +FDFC FDFC E7A880 FDFC +FDFD FDFD E7BEB2 FDFD +FDFE FDFE E8A9B0 FDFE +DROP TABLE t1, t2; +SET sql_mode = default; +End of 5.4 tests +CREATE TABLE t1 (a int, b int); +select * from t1; +a b +4 64 +4 63 +4 62 +4 61 +4 60 +4 59 +4 58 +4 57 +4 56 +4 55 +4 54 +4 53 +4 52 +4 51 +4 50 +4 49 +4 48 +4 47 +4 46 +4 45 +4 44 +4 43 +4 42 +4 41 +4 40 +4 39 +4 38 +4 37 +4 36 +4 35 +4 34 +4 33 +4 32 +4 31 +4 30 +4 29 +4 28 +4 27 +4 26 +4 25 +4 24 +4 23 +4 22 +4 21 +4 20 +4 19 +4 18 +4 17 +4 16 +4 15 +4 14 +4 13 +4 12 +4 11 +4 10 +4 9 +4 8 +4 7 +4 6 +4 5 +4 4 +4 3 +4 2 +4 1 +select * from t1 limit 1; +a b +4 64 +select * from t1 limit 10; +a b +4 64 +4 63 +4 62 +4 61 +4 60 +4 59 +4 58 +4 57 +4 56 +4 55 +select * from t1 limit 100; +a b +4 64 +4 63 +4 62 +4 61 +4 60 +4 59 +4 58 +4 57 +4 56 +4 55 +4 54 +4 53 +4 52 +4 51 +4 50 +4 49 +4 48 +4 47 +4 46 +4 45 +4 44 +4 43 +4 42 +4 41 +4 40 +4 39 +4 38 +4 37 +4 36 +4 35 +4 34 +4 33 +4 32 +4 31 +4 30 +4 29 +4 28 +4 27 +4 26 +4 25 +4 24 +4 23 +4 22 +4 21 +4 20 +4 19 +4 18 +4 17 +4 16 +4 15 +4 14 +4 13 +4 12 +4 11 +4 10 +4 9 +4 8 +4 7 +4 6 +4 5 +4 4 +4 3 +4 2 +4 1 +select b, a from t1 limit 50; +b a +64 4 +63 4 +62 4 +61 4 +60 4 +59 4 +58 4 +57 4 +56 4 +55 4 +54 4 +53 4 +52 4 +51 4 +50 4 +49 4 +48 4 +47 4 +46 4 +45 4 +44 4 +43 4 +42 4 +41 4 +40 4 +39 4 +38 4 +37 4 +36 4 +35 4 +34 4 +33 4 +32 4 +31 4 +30 4 +29 4 +28 4 +27 4 +26 4 +25 4 +24 4 +23 4 +22 4 +21 4 +20 4 +19 4 +18 4 +17 4 +16 4 +15 4 +select * from t1 limit 100, 10; +a b +select * from t1 limit 500, 10; +a b +select * from t1 limit 3000, 50; +a b +select b, a from t1 limit 2000, 50; +b a +select b, a from t1 limit 4000, 50; +b a +drop table t1; +CREATE TABLE t1 (a int, b int, c int); +SELECT * FROM t1 ORDER BY a; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +2 6 6 +2 6 5 +2 6 4 +2 6 3 +2 6 2 +2 6 1 +SELECT * FROM t1 ORDER BY b, a; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +2 6 6 +2 6 5 +2 6 4 +2 6 3 +2 6 2 +2 6 1 +SELECT * FROM t1 ORDER BY a, c; +a b c +2 6 1 +2 6 2 +2 6 3 +2 6 4 +2 6 5 +2 6 6 +2 6 7 +2 6 8 +2 6 9 +2 6 10 +2 6 11 +2 6 12 +2 6 13 +2 6 14 +2 6 15 +2 6 16 +SELECT * FROM t1 ORDER BY a desc, b asc; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +2 6 6 +2 6 5 +2 6 4 +2 6 3 +2 6 2 +2 6 1 +SELECT * FROM t1 ORDER BY b desc, c asc, a desc; +a b c +2 6 1 +2 6 2 +2 6 3 +2 6 4 +2 6 5 +2 6 6 +2 6 7 +2 6 8 +2 6 9 +2 6 10 +2 6 11 +2 6 12 +2 6 13 +2 6 14 +2 6 15 +2 6 16 +SELECT * FROM t1 ORDER BY c asc, a desc; +a b c +2 6 1 +2 6 2 +2 6 3 +2 6 4 +2 6 5 +2 6 6 +2 6 7 +2 6 8 +2 6 9 +2 6 10 +2 6 11 +2 6 12 +2 6 13 +2 6 14 +2 6 15 +2 6 16 +SELECT * FROM t1 ORDER BY NULL, a desc, b; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +2 6 6 +2 6 5 +2 6 4 +2 6 3 +2 6 2 +2 6 1 +SELECT * FROM t1 ORDER BY a limit 10; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +SELECT * FROM t1 ORDER BY a desc, b asc limit 50; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +2 6 6 +2 6 5 +2 6 4 +2 6 3 +2 6 2 +2 6 1 +SELECT * FROM t1 ORDER BY NULL, a desc, b asc limit 50; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +2 6 6 +2 6 5 +2 6 4 +2 6 3 +2 6 2 +2 6 1 +SELECT * FROM t1 ORDER BY NULL, a desc, b asc, NULL limit 50; +a b c +2 6 16 +2 6 15 +2 6 14 +2 6 13 +2 6 12 +2 6 11 +2 6 10 +2 6 9 +2 6 8 +2 6 7 +2 6 6 +2 6 5 +2 6 4 +2 6 3 +2 6 2 +2 6 1 +drop table t1; +CREATE TABLE t2 ( +id int(6) NOT NULL auto_increment, +description varchar(40) NOT NULL, +idform varchar(40), +ordre int(6) unsigned DEFAULT '0' NOT NULL, +image varchar(60), +PRIMARY KEY (id), +KEY id (id, ordre) +); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre un appel d offres','en_construction.html',10,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre des soumissions','en_construction.html',20,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Liste des t2','t2_liste_form.phtml',51060,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Consulter les soumissions','consulter_soumissions.phtml',200,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Modifier des clients','en_construction.html',40010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Effacer des clients','en_construction.html',40020,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Effacer des clients','en_construction.html',40020,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre un appel d offres','en_construction.html',10,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre des soumissions','en_construction.html',20,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Liste des t2','t2_liste_form.phtml',51060,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Modifier des clients','en_construction.html',40010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +SELECT * FROM t2 ORDER BY id; +id description idform ordre image +1 Emettre un appel d offres en_construction.html 10 emettre.gif +2 Emettre des soumissions en_construction.html 20 emettre.gif +3 Liste des t2 t2_liste_form.phtml 51060 link.gif +4 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +5 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +6 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +7 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +8 Modifier des clients en_construction.html 40010 link.gif +9 Effacer des clients en_construction.html 40020 link.gif +10 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +11 Emettre un appel d offres en_construction.html 10 emettre.gif +12 Emettre des soumissions en_construction.html 20 emettre.gif +13 Liste des t2 t2_liste_form.phtml 51060 link.gif +14 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +15 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +16 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +17 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +18 Modifier des clients en_construction.html 40010 link.gif +19 Effacer des clients en_construction.html 40020 link.gif +20 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +26 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +27 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +28 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +29 Emettre un appel d offres en_construction.html 10 emettre.gif +30 Emettre des soumissions en_construction.html 20 emettre.gif +31 Liste des t2 t2_liste_form.phtml 51060 link.gif +32 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +33 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +34 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +35 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +36 Modifier des clients en_construction.html 40010 link.gif +37 Effacer des clients en_construction.html 40020 link.gif +38 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +39 Emettre un appel d offres en_construction.html 10 emettre.gif +40 Emettre des soumissions en_construction.html 20 emettre.gif +41 Liste des t2 t2_liste_form.phtml 51060 link.gif +42 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +43 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +44 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +45 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +46 Modifier des clients en_construction.html 40010 link.gif +47 Effacer des clients en_construction.html 40020 link.gif +48 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +49 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +50 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +51 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +60 Effacer des clients en_construction.html 40020 link.gif +61 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +62 Emettre un appel d offres en_construction.html 10 emettre.gif +63 Emettre des soumissions en_construction.html 20 emettre.gif +64 Liste des t2 t2_liste_form.phtml 51060 link.gif +65 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +66 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +67 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +68 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +69 Modifier des clients en_construction.html 40010 link.gif +70 Effacer des clients en_construction.html 40020 link.gif +71 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +72 Emettre un appel d offres en_construction.html 10 emettre.gif +73 Emettre des soumissions en_construction.html 20 emettre.gif +74 Liste des t2 t2_liste_form.phtml 51060 link.gif +75 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +76 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +77 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +78 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +79 Modifier des clients en_construction.html 40010 link.gif +80 Effacer des clients en_construction.html 40020 link.gif +81 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +82 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +83 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +84 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +85 Emettre un appel d offres en_construction.html 10 emettre.gif +86 Emettre des soumissions en_construction.html 20 emettre.gif +87 Liste des t2 t2_liste_form.phtml 51060 link.gif +88 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +89 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +90 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +91 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +92 Modifier des clients en_construction.html 40010 link.gif +93 Effacer des clients en_construction.html 40020 link.gif +94 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +95 Emettre un appel d offres en_construction.html 10 emettre.gif +96 Emettre des soumissions en_construction.html 20 emettre.gif +97 Liste des t2 t2_liste_form.phtml 51060 link.gif +98 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +99 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +100 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +101 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +102 Modifier des clients en_construction.html 40010 link.gif +103 Effacer des clients en_construction.html 40020 link.gif +104 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +105 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +106 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +107 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +108 Effacer des clients en_construction.html 40020 link.gif +109 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +125 Emettre un appel d offres en_construction.html 10 emettre.gif +126 Emettre des soumissions en_construction.html 20 emettre.gif +127 Liste des t2 t2_liste_form.phtml 51060 link.gif +128 Emettre un appel d offres en_construction.html 10 emettre.gif +129 Emettre des soumissions en_construction.html 20 emettre.gif +130 Liste des t2 t2_liste_form.phtml 51060 link.gif +131 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +132 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +133 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +134 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +135 Modifier des clients en_construction.html 40010 link.gif +136 Effacer des clients en_construction.html 40020 link.gif +137 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +138 Emettre un appel d offres en_construction.html 10 emettre.gif +139 Emettre des soumissions en_construction.html 20 emettre.gif +140 Liste des t2 t2_liste_form.phtml 51060 link.gif +141 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +142 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +143 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +144 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +145 Modifier des clients en_construction.html 40010 link.gif +146 Effacer des clients en_construction.html 40020 link.gif +147 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +148 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +149 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +150 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +151 Emettre un appel d offres en_construction.html 10 emettre.gif +152 Emettre des soumissions en_construction.html 20 emettre.gif +153 Liste des t2 t2_liste_form.phtml 51060 link.gif +154 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +155 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +156 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +157 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +158 Modifier des clients en_construction.html 40010 link.gif +159 Effacer des clients en_construction.html 40020 link.gif +160 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +161 Emettre un appel d offres en_construction.html 10 emettre.gif +162 Emettre des soumissions en_construction.html 20 emettre.gif +163 Liste des t2 t2_liste_form.phtml 51060 link.gif +164 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +165 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +166 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +167 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +168 Modifier des clients en_construction.html 40010 link.gif +169 Effacer des clients en_construction.html 40020 link.gif +170 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +171 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +172 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +173 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +174 Effacer des clients en_construction.html 40020 link.gif +175 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +176 Emettre un appel d offres en_construction.html 10 emettre.gif +177 Emettre des soumissions en_construction.html 20 emettre.gif +178 Liste des t2 t2_liste_form.phtml 51060 link.gif +179 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +180 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +181 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +182 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +183 Modifier des clients en_construction.html 40010 link.gif +184 Effacer des clients en_construction.html 40020 link.gif +185 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +186 Emettre un appel d offres en_construction.html 10 emettre.gif +187 Emettre des soumissions en_construction.html 20 emettre.gif +188 Liste des t2 t2_liste_form.phtml 51060 link.gif +189 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +190 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +191 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +192 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +193 Modifier des clients en_construction.html 40010 link.gif +194 Effacer des clients en_construction.html 40020 link.gif +195 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +196 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +197 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +198 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +199 Emettre un appel d offres en_construction.html 10 emettre.gif +200 Emettre des soumissions en_construction.html 20 emettre.gif +201 Liste des t2 t2_liste_form.phtml 51060 link.gif +202 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +203 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +204 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +205 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +206 Modifier des clients en_construction.html 40010 link.gif +207 Effacer des clients en_construction.html 40020 link.gif +208 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +209 Emettre un appel d offres en_construction.html 10 emettre.gif +210 Emettre des soumissions en_construction.html 20 emettre.gif +211 Liste des t2 t2_liste_form.phtml 51060 link.gif +212 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +213 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +214 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +215 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +216 Modifier des clients en_construction.html 40010 link.gif +217 Effacer des clients en_construction.html 40020 link.gif +218 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +219 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +220 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +221 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +222 Effacer des clients en_construction.html 40020 link.gif +223 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +224 Emettre un appel d offres en_construction.html 10 emettre.gif +225 Emettre des soumissions en_construction.html 20 emettre.gif +226 Liste des t2 t2_liste_form.phtml 51060 link.gif +255 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +256 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +257 Modifier des clients en_construction.html 40010 link.gif +258 Emettre un appel d offres en_construction.html 10 emettre.gif +259 Emettre des soumissions en_construction.html 20 emettre.gif +260 Liste des t2 t2_liste_form.phtml 51060 link.gif +261 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +262 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +263 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +264 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +265 Modifier des clients en_construction.html 40010 link.gif +266 Effacer des clients en_construction.html 40020 link.gif +267 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +268 Emettre un appel d offres en_construction.html 10 emettre.gif +269 Emettre des soumissions en_construction.html 20 emettre.gif +270 Liste des t2 t2_liste_form.phtml 51060 link.gif +271 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +272 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +273 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +274 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +275 Modifier des clients en_construction.html 40010 link.gif +276 Effacer des clients en_construction.html 40020 link.gif +277 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +278 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +279 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +280 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +281 Emettre un appel d offres en_construction.html 10 emettre.gif +282 Emettre des soumissions en_construction.html 20 emettre.gif +283 Liste des t2 t2_liste_form.phtml 51060 link.gif +284 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +285 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +286 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +287 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +288 Modifier des clients en_construction.html 40010 link.gif +289 Effacer des clients en_construction.html 40020 link.gif +290 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +291 Emettre un appel d offres en_construction.html 10 emettre.gif +292 Emettre des soumissions en_construction.html 20 emettre.gif +293 Liste des t2 t2_liste_form.phtml 51060 link.gif +294 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +295 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +296 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +297 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +298 Modifier des clients en_construction.html 40010 link.gif +299 Effacer des clients en_construction.html 40020 link.gif +300 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +301 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +302 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +303 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +304 Effacer des clients en_construction.html 40020 link.gif +305 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +306 Emettre un appel d offres en_construction.html 10 emettre.gif +307 Emettre des soumissions en_construction.html 20 emettre.gif +308 Liste des t2 t2_liste_form.phtml 51060 link.gif +309 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +310 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +311 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +312 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +313 Modifier des clients en_construction.html 40010 link.gif +314 Effacer des clients en_construction.html 40020 link.gif +315 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +316 Emettre un appel d offres en_construction.html 10 emettre.gif +317 Emettre des soumissions en_construction.html 20 emettre.gif +318 Liste des t2 t2_liste_form.phtml 51060 link.gif +319 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +320 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +321 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +322 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +323 Modifier des clients en_construction.html 40010 link.gif +324 Effacer des clients en_construction.html 40020 link.gif +325 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +326 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +327 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +328 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +329 Emettre un appel d offres en_construction.html 10 emettre.gif +330 Emettre des soumissions en_construction.html 20 emettre.gif +331 Liste des t2 t2_liste_form.phtml 51060 link.gif +332 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +333 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +334 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +335 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +336 Modifier des clients en_construction.html 40010 link.gif +337 Effacer des clients en_construction.html 40020 link.gif +338 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +339 Emettre un appel d offres en_construction.html 10 emettre.gif +340 Emettre des soumissions en_construction.html 20 emettre.gif +341 Liste des t2 t2_liste_form.phtml 51060 link.gif +342 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +343 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +344 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +345 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +346 Modifier des clients en_construction.html 40010 link.gif +347 Effacer des clients en_construction.html 40020 link.gif +348 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +349 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +350 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +351 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +352 Effacer des clients en_construction.html 40020 link.gif +353 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +354 Emettre un appel d offres en_construction.html 10 emettre.gif +355 Emettre des soumissions en_construction.html 20 emettre.gif +356 Liste des t2 t2_liste_form.phtml 51060 link.gif +357 Emettre un appel d offres en_construction.html 10 emettre.gif +358 Emettre des soumissions en_construction.html 20 emettre.gif +359 Liste des t2 t2_liste_form.phtml 51060 link.gif +360 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +361 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +362 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +363 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +364 Modifier des clients en_construction.html 40010 link.gif +365 Effacer des clients en_construction.html 40020 link.gif +366 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +367 Emettre un appel d offres en_construction.html 10 emettre.gif +368 Emettre des soumissions en_construction.html 20 emettre.gif +369 Liste des t2 t2_liste_form.phtml 51060 link.gif +370 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +371 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +372 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +373 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +374 Modifier des clients en_construction.html 40010 link.gif +375 Effacer des clients en_construction.html 40020 link.gif +376 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +377 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +378 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +379 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +380 Emettre un appel d offres en_construction.html 10 emettre.gif +381 Emettre des soumissions en_construction.html 20 emettre.gif +382 Liste des t2 t2_liste_form.phtml 51060 link.gif +383 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +384 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +385 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +386 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +387 Modifier des clients en_construction.html 40010 link.gif +388 Effacer des clients en_construction.html 40020 link.gif +389 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +390 Emettre un appel d offres en_construction.html 10 emettre.gif +391 Emettre des soumissions en_construction.html 20 emettre.gif +392 Liste des t2 t2_liste_form.phtml 51060 link.gif +393 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +394 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +395 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +396 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +397 Modifier des clients en_construction.html 40010 link.gif +398 Effacer des clients en_construction.html 40020 link.gif +399 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +400 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +401 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +402 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +403 Effacer des clients en_construction.html 40020 link.gif +404 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +405 Emettre un appel d offres en_construction.html 10 emettre.gif +406 Emettre des soumissions en_construction.html 20 emettre.gif +407 Liste des t2 t2_liste_form.phtml 51060 link.gif +408 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +409 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +410 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +411 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +412 Modifier des clients en_construction.html 40010 link.gif +413 Effacer des clients en_construction.html 40020 link.gif +414 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +415 Emettre un appel d offres en_construction.html 10 emettre.gif +416 Emettre des soumissions en_construction.html 20 emettre.gif +417 Liste des t2 t2_liste_form.phtml 51060 link.gif +418 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +419 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +420 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +421 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +422 Modifier des clients en_construction.html 40010 link.gif +423 Effacer des clients en_construction.html 40020 link.gif +424 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +425 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +426 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +427 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +428 Emettre un appel d offres en_construction.html 10 emettre.gif +429 Emettre des soumissions en_construction.html 20 emettre.gif +430 Liste des t2 t2_liste_form.phtml 51060 link.gif +431 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +432 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +433 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +434 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +435 Modifier des clients en_construction.html 40010 link.gif +436 Effacer des clients en_construction.html 40020 link.gif +437 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +438 Emettre un appel d offres en_construction.html 10 emettre.gif +439 Emettre des soumissions en_construction.html 20 emettre.gif +440 Liste des t2 t2_liste_form.phtml 51060 link.gif +441 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +442 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +443 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +444 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +445 Modifier des clients en_construction.html 40010 link.gif +446 Effacer des clients en_construction.html 40020 link.gif +447 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +448 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +449 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +450 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +451 Effacer des clients en_construction.html 40020 link.gif +452 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +453 Emettre un appel d offres en_construction.html 10 emettre.gif +454 Emettre des soumissions en_construction.html 20 emettre.gif +455 Liste des t2 t2_liste_form.phtml 51060 link.gif +456 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +457 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +458 Modifier des clients en_construction.html 40010 link.gif +513 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +514 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +515 Emettre un appel d offres en_construction.html 10 emettre.gif +516 Emettre des soumissions en_construction.html 20 emettre.gif +517 Liste des t2 t2_liste_form.phtml 51060 link.gif +518 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +519 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +520 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +521 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +522 Modifier des clients en_construction.html 40010 link.gif +523 Effacer des clients en_construction.html 40020 link.gif +524 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +525 Emettre un appel d offres en_construction.html 10 emettre.gif +526 Emettre des soumissions en_construction.html 20 emettre.gif +527 Liste des t2 t2_liste_form.phtml 51060 link.gif +528 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +529 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +530 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +531 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +532 Modifier des clients en_construction.html 40010 link.gif +533 Effacer des clients en_construction.html 40020 link.gif +534 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +535 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +536 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +537 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +538 Emettre un appel d offres en_construction.html 10 emettre.gif +539 Emettre des soumissions en_construction.html 20 emettre.gif +540 Liste des t2 t2_liste_form.phtml 51060 link.gif +541 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +542 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +543 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +544 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +545 Modifier des clients en_construction.html 40010 link.gif +546 Effacer des clients en_construction.html 40020 link.gif +547 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +548 Emettre un appel d offres en_construction.html 10 emettre.gif +549 Emettre des soumissions en_construction.html 20 emettre.gif +550 Liste des t2 t2_liste_form.phtml 51060 link.gif +551 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +552 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +553 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +554 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +555 Modifier des clients en_construction.html 40010 link.gif +556 Effacer des clients en_construction.html 40020 link.gif +557 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +558 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +559 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +560 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +561 Effacer des clients en_construction.html 40020 link.gif +562 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +563 Emettre un appel d offres en_construction.html 10 emettre.gif +564 Emettre des soumissions en_construction.html 20 emettre.gif +565 Liste des t2 t2_liste_form.phtml 51060 link.gif +566 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +567 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +568 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +569 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +570 Modifier des clients en_construction.html 40010 link.gif +571 Effacer des clients en_construction.html 40020 link.gif +572 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +573 Emettre un appel d offres en_construction.html 10 emettre.gif +574 Emettre des soumissions en_construction.html 20 emettre.gif +575 Liste des t2 t2_liste_form.phtml 51060 link.gif +576 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +577 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +578 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +579 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +580 Modifier des clients en_construction.html 40010 link.gif +581 Effacer des clients en_construction.html 40020 link.gif +582 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +583 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +584 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +585 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +586 Emettre un appel d offres en_construction.html 10 emettre.gif +587 Emettre des soumissions en_construction.html 20 emettre.gif +588 Liste des t2 t2_liste_form.phtml 51060 link.gif +589 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +590 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +591 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +592 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +593 Modifier des clients en_construction.html 40010 link.gif +594 Effacer des clients en_construction.html 40020 link.gif +595 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +596 Emettre un appel d offres en_construction.html 10 emettre.gif +597 Emettre des soumissions en_construction.html 20 emettre.gif +598 Liste des t2 t2_liste_form.phtml 51060 link.gif +599 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +600 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +601 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +602 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +603 Modifier des clients en_construction.html 40010 link.gif +604 Effacer des clients en_construction.html 40020 link.gif +605 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +606 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +607 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +608 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +609 Effacer des clients en_construction.html 40020 link.gif +610 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +611 Emettre un appel d offres en_construction.html 10 emettre.gif +612 Emettre des soumissions en_construction.html 20 emettre.gif +613 Liste des t2 t2_liste_form.phtml 51060 link.gif +614 Emettre un appel d offres en_construction.html 10 emettre.gif +615 Emettre des soumissions en_construction.html 20 emettre.gif +616 Liste des t2 t2_liste_form.phtml 51060 link.gif +617 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +618 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +619 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +620 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +621 Modifier des clients en_construction.html 40010 link.gif +622 Effacer des clients en_construction.html 40020 link.gif +623 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +624 Emettre un appel d offres en_construction.html 10 emettre.gif +625 Emettre des soumissions en_construction.html 20 emettre.gif +626 Liste des t2 t2_liste_form.phtml 51060 link.gif +627 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +628 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +629 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +630 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +631 Modifier des clients en_construction.html 40010 link.gif +632 Effacer des clients en_construction.html 40020 link.gif +633 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +634 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +635 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +636 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +637 Emettre un appel d offres en_construction.html 10 emettre.gif +638 Emettre des soumissions en_construction.html 20 emettre.gif +639 Liste des t2 t2_liste_form.phtml 51060 link.gif +640 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +641 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +642 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +643 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +644 Modifier des clients en_construction.html 40010 link.gif +645 Effacer des clients en_construction.html 40020 link.gif +646 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +647 Emettre un appel d offres en_construction.html 10 emettre.gif +648 Emettre des soumissions en_construction.html 20 emettre.gif +649 Liste des t2 t2_liste_form.phtml 51060 link.gif +650 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +651 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +652 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +653 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +654 Modifier des clients en_construction.html 40010 link.gif +655 Effacer des clients en_construction.html 40020 link.gif +656 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +657 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +658 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +659 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +660 Effacer des clients en_construction.html 40020 link.gif +661 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +662 Emettre un appel d offres en_construction.html 10 emettre.gif +663 Emettre des soumissions en_construction.html 20 emettre.gif +664 Liste des t2 t2_liste_form.phtml 51060 link.gif +665 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +666 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +667 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +668 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +669 Modifier des clients en_construction.html 40010 link.gif +670 Effacer des clients en_construction.html 40020 link.gif +671 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +672 Emettre un appel d offres en_construction.html 10 emettre.gif +673 Emettre des soumissions en_construction.html 20 emettre.gif +674 Liste des t2 t2_liste_form.phtml 51060 link.gif +675 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +676 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +677 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +678 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +679 Modifier des clients en_construction.html 40010 link.gif +680 Effacer des clients en_construction.html 40020 link.gif +681 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +682 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +683 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +684 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +685 Emettre un appel d offres en_construction.html 10 emettre.gif +686 Emettre des soumissions en_construction.html 20 emettre.gif +687 Liste des t2 t2_liste_form.phtml 51060 link.gif +688 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +689 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +690 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +691 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +692 Modifier des clients en_construction.html 40010 link.gif +693 Effacer des clients en_construction.html 40020 link.gif +694 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +695 Emettre un appel d offres en_construction.html 10 emettre.gif +696 Emettre des soumissions en_construction.html 20 emettre.gif +697 Liste des t2 t2_liste_form.phtml 51060 link.gif +698 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +699 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +700 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +701 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +702 Modifier des clients en_construction.html 40010 link.gif +703 Effacer des clients en_construction.html 40020 link.gif +704 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +705 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +706 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +707 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +708 Effacer des clients en_construction.html 40020 link.gif +709 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +710 Emettre un appel d offres en_construction.html 10 emettre.gif +711 Emettre des soumissions en_construction.html 20 emettre.gif +712 Liste des t2 t2_liste_form.phtml 51060 link.gif +713 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +714 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +715 Modifier des clients en_construction.html 40010 link.gif +716 Emettre un appel d offres en_construction.html 10 emettre.gif +717 Emettre des soumissions en_construction.html 20 emettre.gif +718 Liste des t2 t2_liste_form.phtml 51060 link.gif +719 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +720 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +721 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +722 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +723 Modifier des clients en_construction.html 40010 link.gif +724 Effacer des clients en_construction.html 40020 link.gif +725 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +726 Emettre un appel d offres en_construction.html 10 emettre.gif +727 Emettre des soumissions en_construction.html 20 emettre.gif +728 Liste des t2 t2_liste_form.phtml 51060 link.gif +729 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +730 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +731 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +732 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +733 Modifier des clients en_construction.html 40010 link.gif +734 Effacer des clients en_construction.html 40020 link.gif +735 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +736 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +737 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +738 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +739 Emettre un appel d offres en_construction.html 10 emettre.gif +740 Emettre des soumissions en_construction.html 20 emettre.gif +741 Liste des t2 t2_liste_form.phtml 51060 link.gif +742 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +743 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +744 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +745 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +746 Modifier des clients en_construction.html 40010 link.gif +747 Effacer des clients en_construction.html 40020 link.gif +748 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +749 Emettre un appel d offres en_construction.html 10 emettre.gif +750 Emettre des soumissions en_construction.html 20 emettre.gif +751 Liste des t2 t2_liste_form.phtml 51060 link.gif +752 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +753 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +754 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +755 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +756 Modifier des clients en_construction.html 40010 link.gif +757 Effacer des clients en_construction.html 40020 link.gif +758 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +759 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +760 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +761 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +762 Effacer des clients en_construction.html 40020 link.gif +763 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +764 Emettre un appel d offres en_construction.html 10 emettre.gif +765 Emettre des soumissions en_construction.html 20 emettre.gif +766 Liste des t2 t2_liste_form.phtml 51060 link.gif +767 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +768 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +769 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +770 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +771 Modifier des clients en_construction.html 40010 link.gif +772 Effacer des clients en_construction.html 40020 link.gif +773 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +774 Emettre un appel d offres en_construction.html 10 emettre.gif +775 Emettre des soumissions en_construction.html 20 emettre.gif +776 Liste des t2 t2_liste_form.phtml 51060 link.gif +777 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +778 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +779 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +780 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +781 Modifier des clients en_construction.html 40010 link.gif +782 Effacer des clients en_construction.html 40020 link.gif +783 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +784 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +785 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +786 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +787 Emettre un appel d offres en_construction.html 10 emettre.gif +788 Emettre des soumissions en_construction.html 20 emettre.gif +789 Liste des t2 t2_liste_form.phtml 51060 link.gif +790 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +791 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +792 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +793 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +794 Modifier des clients en_construction.html 40010 link.gif +795 Effacer des clients en_construction.html 40020 link.gif +796 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +797 Emettre un appel d offres en_construction.html 10 emettre.gif +798 Emettre des soumissions en_construction.html 20 emettre.gif +799 Liste des t2 t2_liste_form.phtml 51060 link.gif +800 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +801 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +802 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +803 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +804 Modifier des clients en_construction.html 40010 link.gif +805 Effacer des clients en_construction.html 40020 link.gif +806 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +807 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +808 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +809 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +810 Effacer des clients en_construction.html 40020 link.gif +811 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +812 Emettre un appel d offres en_construction.html 10 emettre.gif +813 Emettre des soumissions en_construction.html 20 emettre.gif +814 Liste des t2 t2_liste_form.phtml 51060 link.gif +815 Emettre un appel d offres en_construction.html 10 emettre.gif +816 Emettre des soumissions en_construction.html 20 emettre.gif +817 Liste des t2 t2_liste_form.phtml 51060 link.gif +818 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +819 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +820 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +821 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +822 Modifier des clients en_construction.html 40010 link.gif +823 Effacer des clients en_construction.html 40020 link.gif +824 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +825 Emettre un appel d offres en_construction.html 10 emettre.gif +826 Emettre des soumissions en_construction.html 20 emettre.gif +827 Liste des t2 t2_liste_form.phtml 51060 link.gif +828 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +829 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +830 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +831 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +832 Modifier des clients en_construction.html 40010 link.gif +833 Effacer des clients en_construction.html 40020 link.gif +834 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +835 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +836 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +837 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +838 Emettre un appel d offres en_construction.html 10 emettre.gif +839 Emettre des soumissions en_construction.html 20 emettre.gif +840 Liste des t2 t2_liste_form.phtml 51060 link.gif +841 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +842 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +843 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +844 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +845 Modifier des clients en_construction.html 40010 link.gif +846 Effacer des clients en_construction.html 40020 link.gif +847 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +848 Emettre un appel d offres en_construction.html 10 emettre.gif +849 Emettre des soumissions en_construction.html 20 emettre.gif +850 Liste des t2 t2_liste_form.phtml 51060 link.gif +851 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +852 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +853 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +854 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +855 Modifier des clients en_construction.html 40010 link.gif +856 Effacer des clients en_construction.html 40020 link.gif +857 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +858 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +859 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +860 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +861 Effacer des clients en_construction.html 40020 link.gif +862 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +863 Emettre un appel d offres en_construction.html 10 emettre.gif +864 Emettre des soumissions en_construction.html 20 emettre.gif +865 Liste des t2 t2_liste_form.phtml 51060 link.gif +866 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +867 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +868 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +869 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +870 Modifier des clients en_construction.html 40010 link.gif +871 Effacer des clients en_construction.html 40020 link.gif +872 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +873 Emettre un appel d offres en_construction.html 10 emettre.gif +874 Emettre des soumissions en_construction.html 20 emettre.gif +875 Liste des t2 t2_liste_form.phtml 51060 link.gif +876 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +877 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +878 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +879 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +880 Modifier des clients en_construction.html 40010 link.gif +881 Effacer des clients en_construction.html 40020 link.gif +882 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +883 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +884 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +885 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +886 Emettre un appel d offres en_construction.html 10 emettre.gif +887 Emettre des soumissions en_construction.html 20 emettre.gif +888 Liste des t2 t2_liste_form.phtml 51060 link.gif +889 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +890 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +891 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +892 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +893 Modifier des clients en_construction.html 40010 link.gif +894 Effacer des clients en_construction.html 40020 link.gif +895 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +896 Emettre un appel d offres en_construction.html 10 emettre.gif +897 Emettre des soumissions en_construction.html 20 emettre.gif +898 Liste des t2 t2_liste_form.phtml 51060 link.gif +899 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +900 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +901 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +902 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +903 Modifier des clients en_construction.html 40010 link.gif +904 Effacer des clients en_construction.html 40020 link.gif +905 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +906 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +907 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +908 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +909 Effacer des clients en_construction.html 40020 link.gif +910 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +911 Emettre un appel d offres en_construction.html 10 emettre.gif +912 Emettre des soumissions en_construction.html 20 emettre.gif +913 Liste des t2 t2_liste_form.phtml 51060 link.gif +914 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +915 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +916 Modifier des clients en_construction.html 40010 link.gif +917 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +918 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +SELECT * FROM t2 ORDER BY id, ordre; +id description idform ordre image +1 Emettre un appel d offres en_construction.html 10 emettre.gif +2 Emettre des soumissions en_construction.html 20 emettre.gif +3 Liste des t2 t2_liste_form.phtml 51060 link.gif +4 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +5 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +6 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +7 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +8 Modifier des clients en_construction.html 40010 link.gif +9 Effacer des clients en_construction.html 40020 link.gif +10 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +11 Emettre un appel d offres en_construction.html 10 emettre.gif +12 Emettre des soumissions en_construction.html 20 emettre.gif +13 Liste des t2 t2_liste_form.phtml 51060 link.gif +14 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +15 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +16 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +17 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +18 Modifier des clients en_construction.html 40010 link.gif +19 Effacer des clients en_construction.html 40020 link.gif +20 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +26 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +27 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +28 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +29 Emettre un appel d offres en_construction.html 10 emettre.gif +30 Emettre des soumissions en_construction.html 20 emettre.gif +31 Liste des t2 t2_liste_form.phtml 51060 link.gif +32 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +33 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +34 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +35 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +36 Modifier des clients en_construction.html 40010 link.gif +37 Effacer des clients en_construction.html 40020 link.gif +38 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +39 Emettre un appel d offres en_construction.html 10 emettre.gif +40 Emettre des soumissions en_construction.html 20 emettre.gif +41 Liste des t2 t2_liste_form.phtml 51060 link.gif +42 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +43 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +44 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +45 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +46 Modifier des clients en_construction.html 40010 link.gif +47 Effacer des clients en_construction.html 40020 link.gif +48 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +49 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +50 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +51 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +60 Effacer des clients en_construction.html 40020 link.gif +61 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +62 Emettre un appel d offres en_construction.html 10 emettre.gif +63 Emettre des soumissions en_construction.html 20 emettre.gif +64 Liste des t2 t2_liste_form.phtml 51060 link.gif +65 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +66 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +67 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +68 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +69 Modifier des clients en_construction.html 40010 link.gif +70 Effacer des clients en_construction.html 40020 link.gif +71 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +72 Emettre un appel d offres en_construction.html 10 emettre.gif +73 Emettre des soumissions en_construction.html 20 emettre.gif +74 Liste des t2 t2_liste_form.phtml 51060 link.gif +75 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +76 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +77 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +78 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +79 Modifier des clients en_construction.html 40010 link.gif +80 Effacer des clients en_construction.html 40020 link.gif +81 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +82 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +83 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +84 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +85 Emettre un appel d offres en_construction.html 10 emettre.gif +86 Emettre des soumissions en_construction.html 20 emettre.gif +87 Liste des t2 t2_liste_form.phtml 51060 link.gif +88 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +89 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +90 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +91 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +92 Modifier des clients en_construction.html 40010 link.gif +93 Effacer des clients en_construction.html 40020 link.gif +94 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +95 Emettre un appel d offres en_construction.html 10 emettre.gif +96 Emettre des soumissions en_construction.html 20 emettre.gif +97 Liste des t2 t2_liste_form.phtml 51060 link.gif +98 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +99 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +100 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +101 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +102 Modifier des clients en_construction.html 40010 link.gif +103 Effacer des clients en_construction.html 40020 link.gif +104 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +105 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +106 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +107 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +108 Effacer des clients en_construction.html 40020 link.gif +109 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +125 Emettre un appel d offres en_construction.html 10 emettre.gif +126 Emettre des soumissions en_construction.html 20 emettre.gif +127 Liste des t2 t2_liste_form.phtml 51060 link.gif +128 Emettre un appel d offres en_construction.html 10 emettre.gif +129 Emettre des soumissions en_construction.html 20 emettre.gif +130 Liste des t2 t2_liste_form.phtml 51060 link.gif +131 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +132 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +133 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +134 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +135 Modifier des clients en_construction.html 40010 link.gif +136 Effacer des clients en_construction.html 40020 link.gif +137 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +138 Emettre un appel d offres en_construction.html 10 emettre.gif +139 Emettre des soumissions en_construction.html 20 emettre.gif +140 Liste des t2 t2_liste_form.phtml 51060 link.gif +141 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +142 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +143 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +144 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +145 Modifier des clients en_construction.html 40010 link.gif +146 Effacer des clients en_construction.html 40020 link.gif +147 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +148 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +149 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +150 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +151 Emettre un appel d offres en_construction.html 10 emettre.gif +152 Emettre des soumissions en_construction.html 20 emettre.gif +153 Liste des t2 t2_liste_form.phtml 51060 link.gif +154 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +155 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +156 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +157 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +158 Modifier des clients en_construction.html 40010 link.gif +159 Effacer des clients en_construction.html 40020 link.gif +160 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +161 Emettre un appel d offres en_construction.html 10 emettre.gif +162 Emettre des soumissions en_construction.html 20 emettre.gif +163 Liste des t2 t2_liste_form.phtml 51060 link.gif +164 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +165 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +166 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +167 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +168 Modifier des clients en_construction.html 40010 link.gif +169 Effacer des clients en_construction.html 40020 link.gif +170 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +171 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +172 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +173 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +174 Effacer des clients en_construction.html 40020 link.gif +175 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +176 Emettre un appel d offres en_construction.html 10 emettre.gif +177 Emettre des soumissions en_construction.html 20 emettre.gif +178 Liste des t2 t2_liste_form.phtml 51060 link.gif +179 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +180 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +181 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +182 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +183 Modifier des clients en_construction.html 40010 link.gif +184 Effacer des clients en_construction.html 40020 link.gif +185 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +186 Emettre un appel d offres en_construction.html 10 emettre.gif +187 Emettre des soumissions en_construction.html 20 emettre.gif +188 Liste des t2 t2_liste_form.phtml 51060 link.gif +189 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +190 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +191 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +192 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +193 Modifier des clients en_construction.html 40010 link.gif +194 Effacer des clients en_construction.html 40020 link.gif +195 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +196 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +197 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +198 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +199 Emettre un appel d offres en_construction.html 10 emettre.gif +200 Emettre des soumissions en_construction.html 20 emettre.gif +201 Liste des t2 t2_liste_form.phtml 51060 link.gif +202 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +203 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +204 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +205 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +206 Modifier des clients en_construction.html 40010 link.gif +207 Effacer des clients en_construction.html 40020 link.gif +208 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +209 Emettre un appel d offres en_construction.html 10 emettre.gif +210 Emettre des soumissions en_construction.html 20 emettre.gif +211 Liste des t2 t2_liste_form.phtml 51060 link.gif +212 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +213 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +214 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +215 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +216 Modifier des clients en_construction.html 40010 link.gif +217 Effacer des clients en_construction.html 40020 link.gif +218 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +219 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +220 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +221 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +222 Effacer des clients en_construction.html 40020 link.gif +223 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +224 Emettre un appel d offres en_construction.html 10 emettre.gif +225 Emettre des soumissions en_construction.html 20 emettre.gif +226 Liste des t2 t2_liste_form.phtml 51060 link.gif +255 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +256 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +257 Modifier des clients en_construction.html 40010 link.gif +258 Emettre un appel d offres en_construction.html 10 emettre.gif +259 Emettre des soumissions en_construction.html 20 emettre.gif +260 Liste des t2 t2_liste_form.phtml 51060 link.gif +261 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +262 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +263 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +264 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +265 Modifier des clients en_construction.html 40010 link.gif +266 Effacer des clients en_construction.html 40020 link.gif +267 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +268 Emettre un appel d offres en_construction.html 10 emettre.gif +269 Emettre des soumissions en_construction.html 20 emettre.gif +270 Liste des t2 t2_liste_form.phtml 51060 link.gif +271 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +272 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +273 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +274 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +275 Modifier des clients en_construction.html 40010 link.gif +276 Effacer des clients en_construction.html 40020 link.gif +277 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +278 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +279 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +280 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +281 Emettre un appel d offres en_construction.html 10 emettre.gif +282 Emettre des soumissions en_construction.html 20 emettre.gif +283 Liste des t2 t2_liste_form.phtml 51060 link.gif +284 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +285 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +286 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +287 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +288 Modifier des clients en_construction.html 40010 link.gif +289 Effacer des clients en_construction.html 40020 link.gif +290 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +291 Emettre un appel d offres en_construction.html 10 emettre.gif +292 Emettre des soumissions en_construction.html 20 emettre.gif +293 Liste des t2 t2_liste_form.phtml 51060 link.gif +294 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +295 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +296 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +297 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +298 Modifier des clients en_construction.html 40010 link.gif +299 Effacer des clients en_construction.html 40020 link.gif +300 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +301 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +302 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +303 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +304 Effacer des clients en_construction.html 40020 link.gif +305 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +306 Emettre un appel d offres en_construction.html 10 emettre.gif +307 Emettre des soumissions en_construction.html 20 emettre.gif +308 Liste des t2 t2_liste_form.phtml 51060 link.gif +309 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +310 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +311 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +312 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +313 Modifier des clients en_construction.html 40010 link.gif +314 Effacer des clients en_construction.html 40020 link.gif +315 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +316 Emettre un appel d offres en_construction.html 10 emettre.gif +317 Emettre des soumissions en_construction.html 20 emettre.gif +318 Liste des t2 t2_liste_form.phtml 51060 link.gif +319 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +320 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +321 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +322 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +323 Modifier des clients en_construction.html 40010 link.gif +324 Effacer des clients en_construction.html 40020 link.gif +325 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +326 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +327 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +328 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +329 Emettre un appel d offres en_construction.html 10 emettre.gif +330 Emettre des soumissions en_construction.html 20 emettre.gif +331 Liste des t2 t2_liste_form.phtml 51060 link.gif +332 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +333 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +334 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +335 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +336 Modifier des clients en_construction.html 40010 link.gif +337 Effacer des clients en_construction.html 40020 link.gif +338 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +339 Emettre un appel d offres en_construction.html 10 emettre.gif +340 Emettre des soumissions en_construction.html 20 emettre.gif +341 Liste des t2 t2_liste_form.phtml 51060 link.gif +342 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +343 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +344 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +345 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +346 Modifier des clients en_construction.html 40010 link.gif +347 Effacer des clients en_construction.html 40020 link.gif +348 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +349 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +350 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +351 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +352 Effacer des clients en_construction.html 40020 link.gif +353 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +354 Emettre un appel d offres en_construction.html 10 emettre.gif +355 Emettre des soumissions en_construction.html 20 emettre.gif +356 Liste des t2 t2_liste_form.phtml 51060 link.gif +357 Emettre un appel d offres en_construction.html 10 emettre.gif +358 Emettre des soumissions en_construction.html 20 emettre.gif +359 Liste des t2 t2_liste_form.phtml 51060 link.gif +360 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +361 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +362 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +363 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +364 Modifier des clients en_construction.html 40010 link.gif +365 Effacer des clients en_construction.html 40020 link.gif +366 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +367 Emettre un appel d offres en_construction.html 10 emettre.gif +368 Emettre des soumissions en_construction.html 20 emettre.gif +369 Liste des t2 t2_liste_form.phtml 51060 link.gif +370 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +371 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +372 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +373 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +374 Modifier des clients en_construction.html 40010 link.gif +375 Effacer des clients en_construction.html 40020 link.gif +376 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +377 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +378 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +379 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +380 Emettre un appel d offres en_construction.html 10 emettre.gif +381 Emettre des soumissions en_construction.html 20 emettre.gif +382 Liste des t2 t2_liste_form.phtml 51060 link.gif +383 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +384 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +385 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +386 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +387 Modifier des clients en_construction.html 40010 link.gif +388 Effacer des clients en_construction.html 40020 link.gif +389 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +390 Emettre un appel d offres en_construction.html 10 emettre.gif +391 Emettre des soumissions en_construction.html 20 emettre.gif +392 Liste des t2 t2_liste_form.phtml 51060 link.gif +393 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +394 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +395 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +396 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +397 Modifier des clients en_construction.html 40010 link.gif +398 Effacer des clients en_construction.html 40020 link.gif +399 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +400 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +401 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +402 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +403 Effacer des clients en_construction.html 40020 link.gif +404 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +405 Emettre un appel d offres en_construction.html 10 emettre.gif +406 Emettre des soumissions en_construction.html 20 emettre.gif +407 Liste des t2 t2_liste_form.phtml 51060 link.gif +408 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +409 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +410 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +411 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +412 Modifier des clients en_construction.html 40010 link.gif +413 Effacer des clients en_construction.html 40020 link.gif +414 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +415 Emettre un appel d offres en_construction.html 10 emettre.gif +416 Emettre des soumissions en_construction.html 20 emettre.gif +417 Liste des t2 t2_liste_form.phtml 51060 link.gif +418 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +419 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +420 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +421 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +422 Modifier des clients en_construction.html 40010 link.gif +423 Effacer des clients en_construction.html 40020 link.gif +424 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +425 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +426 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +427 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +428 Emettre un appel d offres en_construction.html 10 emettre.gif +429 Emettre des soumissions en_construction.html 20 emettre.gif +430 Liste des t2 t2_liste_form.phtml 51060 link.gif +431 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +432 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +433 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +434 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +435 Modifier des clients en_construction.html 40010 link.gif +436 Effacer des clients en_construction.html 40020 link.gif +437 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +438 Emettre un appel d offres en_construction.html 10 emettre.gif +439 Emettre des soumissions en_construction.html 20 emettre.gif +440 Liste des t2 t2_liste_form.phtml 51060 link.gif +441 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +442 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +443 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +444 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +445 Modifier des clients en_construction.html 40010 link.gif +446 Effacer des clients en_construction.html 40020 link.gif +447 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +448 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +449 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +450 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +451 Effacer des clients en_construction.html 40020 link.gif +452 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +453 Emettre un appel d offres en_construction.html 10 emettre.gif +454 Emettre des soumissions en_construction.html 20 emettre.gif +455 Liste des t2 t2_liste_form.phtml 51060 link.gif +456 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +457 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +458 Modifier des clients en_construction.html 40010 link.gif +513 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +514 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +515 Emettre un appel d offres en_construction.html 10 emettre.gif +516 Emettre des soumissions en_construction.html 20 emettre.gif +517 Liste des t2 t2_liste_form.phtml 51060 link.gif +518 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +519 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +520 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +521 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +522 Modifier des clients en_construction.html 40010 link.gif +523 Effacer des clients en_construction.html 40020 link.gif +524 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +525 Emettre un appel d offres en_construction.html 10 emettre.gif +526 Emettre des soumissions en_construction.html 20 emettre.gif +527 Liste des t2 t2_liste_form.phtml 51060 link.gif +528 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +529 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +530 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +531 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +532 Modifier des clients en_construction.html 40010 link.gif +533 Effacer des clients en_construction.html 40020 link.gif +534 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +535 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +536 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +537 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +538 Emettre un appel d offres en_construction.html 10 emettre.gif +539 Emettre des soumissions en_construction.html 20 emettre.gif +540 Liste des t2 t2_liste_form.phtml 51060 link.gif +541 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +542 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +543 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +544 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +545 Modifier des clients en_construction.html 40010 link.gif +546 Effacer des clients en_construction.html 40020 link.gif +547 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +548 Emettre un appel d offres en_construction.html 10 emettre.gif +549 Emettre des soumissions en_construction.html 20 emettre.gif +550 Liste des t2 t2_liste_form.phtml 51060 link.gif +551 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +552 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +553 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +554 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +555 Modifier des clients en_construction.html 40010 link.gif +556 Effacer des clients en_construction.html 40020 link.gif +557 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +558 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +559 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +560 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +561 Effacer des clients en_construction.html 40020 link.gif +562 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +563 Emettre un appel d offres en_construction.html 10 emettre.gif +564 Emettre des soumissions en_construction.html 20 emettre.gif +565 Liste des t2 t2_liste_form.phtml 51060 link.gif +566 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +567 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +568 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +569 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +570 Modifier des clients en_construction.html 40010 link.gif +571 Effacer des clients en_construction.html 40020 link.gif +572 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +573 Emettre un appel d offres en_construction.html 10 emettre.gif +574 Emettre des soumissions en_construction.html 20 emettre.gif +575 Liste des t2 t2_liste_form.phtml 51060 link.gif +576 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +577 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +578 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +579 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +580 Modifier des clients en_construction.html 40010 link.gif +581 Effacer des clients en_construction.html 40020 link.gif +582 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +583 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +584 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +585 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +586 Emettre un appel d offres en_construction.html 10 emettre.gif +587 Emettre des soumissions en_construction.html 20 emettre.gif +588 Liste des t2 t2_liste_form.phtml 51060 link.gif +589 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +590 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +591 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +592 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +593 Modifier des clients en_construction.html 40010 link.gif +594 Effacer des clients en_construction.html 40020 link.gif +595 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +596 Emettre un appel d offres en_construction.html 10 emettre.gif +597 Emettre des soumissions en_construction.html 20 emettre.gif +598 Liste des t2 t2_liste_form.phtml 51060 link.gif +599 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +600 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +601 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +602 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +603 Modifier des clients en_construction.html 40010 link.gif +604 Effacer des clients en_construction.html 40020 link.gif +605 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +606 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +607 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +608 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +609 Effacer des clients en_construction.html 40020 link.gif +610 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +611 Emettre un appel d offres en_construction.html 10 emettre.gif +612 Emettre des soumissions en_construction.html 20 emettre.gif +613 Liste des t2 t2_liste_form.phtml 51060 link.gif +614 Emettre un appel d offres en_construction.html 10 emettre.gif +615 Emettre des soumissions en_construction.html 20 emettre.gif +616 Liste des t2 t2_liste_form.phtml 51060 link.gif +617 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +618 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +619 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +620 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +621 Modifier des clients en_construction.html 40010 link.gif +622 Effacer des clients en_construction.html 40020 link.gif +623 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +624 Emettre un appel d offres en_construction.html 10 emettre.gif +625 Emettre des soumissions en_construction.html 20 emettre.gif +626 Liste des t2 t2_liste_form.phtml 51060 link.gif +627 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +628 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +629 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +630 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +631 Modifier des clients en_construction.html 40010 link.gif +632 Effacer des clients en_construction.html 40020 link.gif +633 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +634 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +635 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +636 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +637 Emettre un appel d offres en_construction.html 10 emettre.gif +638 Emettre des soumissions en_construction.html 20 emettre.gif +639 Liste des t2 t2_liste_form.phtml 51060 link.gif +640 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +641 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +642 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +643 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +644 Modifier des clients en_construction.html 40010 link.gif +645 Effacer des clients en_construction.html 40020 link.gif +646 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +647 Emettre un appel d offres en_construction.html 10 emettre.gif +648 Emettre des soumissions en_construction.html 20 emettre.gif +649 Liste des t2 t2_liste_form.phtml 51060 link.gif +650 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +651 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +652 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +653 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +654 Modifier des clients en_construction.html 40010 link.gif +655 Effacer des clients en_construction.html 40020 link.gif +656 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +657 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +658 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +659 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +660 Effacer des clients en_construction.html 40020 link.gif +661 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +662 Emettre un appel d offres en_construction.html 10 emettre.gif +663 Emettre des soumissions en_construction.html 20 emettre.gif +664 Liste des t2 t2_liste_form.phtml 51060 link.gif +665 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +666 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +667 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +668 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +669 Modifier des clients en_construction.html 40010 link.gif +670 Effacer des clients en_construction.html 40020 link.gif +671 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +672 Emettre un appel d offres en_construction.html 10 emettre.gif +673 Emettre des soumissions en_construction.html 20 emettre.gif +674 Liste des t2 t2_liste_form.phtml 51060 link.gif +675 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +676 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +677 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +678 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +679 Modifier des clients en_construction.html 40010 link.gif +680 Effacer des clients en_construction.html 40020 link.gif +681 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +682 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +683 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +684 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +685 Emettre un appel d offres en_construction.html 10 emettre.gif +686 Emettre des soumissions en_construction.html 20 emettre.gif +687 Liste des t2 t2_liste_form.phtml 51060 link.gif +688 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +689 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +690 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +691 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +692 Modifier des clients en_construction.html 40010 link.gif +693 Effacer des clients en_construction.html 40020 link.gif +694 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +695 Emettre un appel d offres en_construction.html 10 emettre.gif +696 Emettre des soumissions en_construction.html 20 emettre.gif +697 Liste des t2 t2_liste_form.phtml 51060 link.gif +698 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +699 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +700 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +701 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +702 Modifier des clients en_construction.html 40010 link.gif +703 Effacer des clients en_construction.html 40020 link.gif +704 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +705 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +706 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +707 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +708 Effacer des clients en_construction.html 40020 link.gif +709 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +710 Emettre un appel d offres en_construction.html 10 emettre.gif +711 Emettre des soumissions en_construction.html 20 emettre.gif +712 Liste des t2 t2_liste_form.phtml 51060 link.gif +713 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +714 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +715 Modifier des clients en_construction.html 40010 link.gif +716 Emettre un appel d offres en_construction.html 10 emettre.gif +717 Emettre des soumissions en_construction.html 20 emettre.gif +718 Liste des t2 t2_liste_form.phtml 51060 link.gif +719 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +720 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +721 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +722 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +723 Modifier des clients en_construction.html 40010 link.gif +724 Effacer des clients en_construction.html 40020 link.gif +725 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +726 Emettre un appel d offres en_construction.html 10 emettre.gif +727 Emettre des soumissions en_construction.html 20 emettre.gif +728 Liste des t2 t2_liste_form.phtml 51060 link.gif +729 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +730 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +731 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +732 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +733 Modifier des clients en_construction.html 40010 link.gif +734 Effacer des clients en_construction.html 40020 link.gif +735 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +736 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +737 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +738 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +739 Emettre un appel d offres en_construction.html 10 emettre.gif +740 Emettre des soumissions en_construction.html 20 emettre.gif +741 Liste des t2 t2_liste_form.phtml 51060 link.gif +742 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +743 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +744 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +745 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +746 Modifier des clients en_construction.html 40010 link.gif +747 Effacer des clients en_construction.html 40020 link.gif +748 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +749 Emettre un appel d offres en_construction.html 10 emettre.gif +750 Emettre des soumissions en_construction.html 20 emettre.gif +751 Liste des t2 t2_liste_form.phtml 51060 link.gif +752 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +753 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +754 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +755 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +756 Modifier des clients en_construction.html 40010 link.gif +757 Effacer des clients en_construction.html 40020 link.gif +758 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +759 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +760 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +761 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +762 Effacer des clients en_construction.html 40020 link.gif +763 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +764 Emettre un appel d offres en_construction.html 10 emettre.gif +765 Emettre des soumissions en_construction.html 20 emettre.gif +766 Liste des t2 t2_liste_form.phtml 51060 link.gif +767 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +768 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +769 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +770 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +771 Modifier des clients en_construction.html 40010 link.gif +772 Effacer des clients en_construction.html 40020 link.gif +773 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +774 Emettre un appel d offres en_construction.html 10 emettre.gif +775 Emettre des soumissions en_construction.html 20 emettre.gif +776 Liste des t2 t2_liste_form.phtml 51060 link.gif +777 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +778 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +779 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +780 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +781 Modifier des clients en_construction.html 40010 link.gif +782 Effacer des clients en_construction.html 40020 link.gif +783 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +784 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +785 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +786 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +787 Emettre un appel d offres en_construction.html 10 emettre.gif +788 Emettre des soumissions en_construction.html 20 emettre.gif +789 Liste des t2 t2_liste_form.phtml 51060 link.gif +790 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +791 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +792 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +793 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +794 Modifier des clients en_construction.html 40010 link.gif +795 Effacer des clients en_construction.html 40020 link.gif +796 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +797 Emettre un appel d offres en_construction.html 10 emettre.gif +798 Emettre des soumissions en_construction.html 20 emettre.gif +799 Liste des t2 t2_liste_form.phtml 51060 link.gif +800 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +801 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +802 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +803 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +804 Modifier des clients en_construction.html 40010 link.gif +805 Effacer des clients en_construction.html 40020 link.gif +806 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +807 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +808 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +809 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +810 Effacer des clients en_construction.html 40020 link.gif +811 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +812 Emettre un appel d offres en_construction.html 10 emettre.gif +813 Emettre des soumissions en_construction.html 20 emettre.gif +814 Liste des t2 t2_liste_form.phtml 51060 link.gif +815 Emettre un appel d offres en_construction.html 10 emettre.gif +816 Emettre des soumissions en_construction.html 20 emettre.gif +817 Liste des t2 t2_liste_form.phtml 51060 link.gif +818 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +819 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +820 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +821 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +822 Modifier des clients en_construction.html 40010 link.gif +823 Effacer des clients en_construction.html 40020 link.gif +824 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +825 Emettre un appel d offres en_construction.html 10 emettre.gif +826 Emettre des soumissions en_construction.html 20 emettre.gif +827 Liste des t2 t2_liste_form.phtml 51060 link.gif +828 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +829 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +830 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +831 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +832 Modifier des clients en_construction.html 40010 link.gif +833 Effacer des clients en_construction.html 40020 link.gif +834 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +835 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +836 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +837 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +838 Emettre un appel d offres en_construction.html 10 emettre.gif +839 Emettre des soumissions en_construction.html 20 emettre.gif +840 Liste des t2 t2_liste_form.phtml 51060 link.gif +841 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +842 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +843 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +844 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +845 Modifier des clients en_construction.html 40010 link.gif +846 Effacer des clients en_construction.html 40020 link.gif +847 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +848 Emettre un appel d offres en_construction.html 10 emettre.gif +849 Emettre des soumissions en_construction.html 20 emettre.gif +850 Liste des t2 t2_liste_form.phtml 51060 link.gif +851 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +852 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +853 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +854 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +855 Modifier des clients en_construction.html 40010 link.gif +856 Effacer des clients en_construction.html 40020 link.gif +857 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +858 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +859 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +860 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +861 Effacer des clients en_construction.html 40020 link.gif +862 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +863 Emettre un appel d offres en_construction.html 10 emettre.gif +864 Emettre des soumissions en_construction.html 20 emettre.gif +865 Liste des t2 t2_liste_form.phtml 51060 link.gif +866 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +867 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +868 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +869 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +870 Modifier des clients en_construction.html 40010 link.gif +871 Effacer des clients en_construction.html 40020 link.gif +872 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +873 Emettre un appel d offres en_construction.html 10 emettre.gif +874 Emettre des soumissions en_construction.html 20 emettre.gif +875 Liste des t2 t2_liste_form.phtml 51060 link.gif +876 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +877 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +878 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +879 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +880 Modifier des clients en_construction.html 40010 link.gif +881 Effacer des clients en_construction.html 40020 link.gif +882 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +883 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +884 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +885 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +886 Emettre un appel d offres en_construction.html 10 emettre.gif +887 Emettre des soumissions en_construction.html 20 emettre.gif +888 Liste des t2 t2_liste_form.phtml 51060 link.gif +889 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +890 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +891 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +892 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +893 Modifier des clients en_construction.html 40010 link.gif +894 Effacer des clients en_construction.html 40020 link.gif +895 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +896 Emettre un appel d offres en_construction.html 10 emettre.gif +897 Emettre des soumissions en_construction.html 20 emettre.gif +898 Liste des t2 t2_liste_form.phtml 51060 link.gif +899 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +900 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +901 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +902 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +903 Modifier des clients en_construction.html 40010 link.gif +904 Effacer des clients en_construction.html 40020 link.gif +905 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +906 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +907 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +908 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +909 Effacer des clients en_construction.html 40020 link.gif +910 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +911 Emettre un appel d offres en_construction.html 10 emettre.gif +912 Emettre des soumissions en_construction.html 20 emettre.gif +913 Liste des t2 t2_liste_form.phtml 51060 link.gif +914 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +915 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +916 Modifier des clients en_construction.html 40010 link.gif +917 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +918 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +SELECT * FROM t2 ORDER BY id, ordre desc; +id description idform ordre image +1 Emettre un appel d offres en_construction.html 10 emettre.gif +2 Emettre des soumissions en_construction.html 20 emettre.gif +3 Liste des t2 t2_liste_form.phtml 51060 link.gif +4 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +5 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +6 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +7 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +8 Modifier des clients en_construction.html 40010 link.gif +9 Effacer des clients en_construction.html 40020 link.gif +10 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +11 Emettre un appel d offres en_construction.html 10 emettre.gif +12 Emettre des soumissions en_construction.html 20 emettre.gif +13 Liste des t2 t2_liste_form.phtml 51060 link.gif +14 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +15 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +16 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +17 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +18 Modifier des clients en_construction.html 40010 link.gif +19 Effacer des clients en_construction.html 40020 link.gif +20 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +26 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +27 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +28 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +29 Emettre un appel d offres en_construction.html 10 emettre.gif +30 Emettre des soumissions en_construction.html 20 emettre.gif +31 Liste des t2 t2_liste_form.phtml 51060 link.gif +32 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +33 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +34 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +35 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +36 Modifier des clients en_construction.html 40010 link.gif +37 Effacer des clients en_construction.html 40020 link.gif +38 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +39 Emettre un appel d offres en_construction.html 10 emettre.gif +40 Emettre des soumissions en_construction.html 20 emettre.gif +41 Liste des t2 t2_liste_form.phtml 51060 link.gif +42 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +43 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +44 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +45 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +46 Modifier des clients en_construction.html 40010 link.gif +47 Effacer des clients en_construction.html 40020 link.gif +48 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +49 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +50 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +51 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +60 Effacer des clients en_construction.html 40020 link.gif +61 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +62 Emettre un appel d offres en_construction.html 10 emettre.gif +63 Emettre des soumissions en_construction.html 20 emettre.gif +64 Liste des t2 t2_liste_form.phtml 51060 link.gif +65 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +66 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +67 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +68 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +69 Modifier des clients en_construction.html 40010 link.gif +70 Effacer des clients en_construction.html 40020 link.gif +71 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +72 Emettre un appel d offres en_construction.html 10 emettre.gif +73 Emettre des soumissions en_construction.html 20 emettre.gif +74 Liste des t2 t2_liste_form.phtml 51060 link.gif +75 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +76 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +77 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +78 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +79 Modifier des clients en_construction.html 40010 link.gif +80 Effacer des clients en_construction.html 40020 link.gif +81 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +82 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +83 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +84 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +85 Emettre un appel d offres en_construction.html 10 emettre.gif +86 Emettre des soumissions en_construction.html 20 emettre.gif +87 Liste des t2 t2_liste_form.phtml 51060 link.gif +88 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +89 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +90 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +91 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +92 Modifier des clients en_construction.html 40010 link.gif +93 Effacer des clients en_construction.html 40020 link.gif +94 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +95 Emettre un appel d offres en_construction.html 10 emettre.gif +96 Emettre des soumissions en_construction.html 20 emettre.gif +97 Liste des t2 t2_liste_form.phtml 51060 link.gif +98 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +99 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +100 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +101 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +102 Modifier des clients en_construction.html 40010 link.gif +103 Effacer des clients en_construction.html 40020 link.gif +104 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +105 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +106 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +107 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +108 Effacer des clients en_construction.html 40020 link.gif +109 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +125 Emettre un appel d offres en_construction.html 10 emettre.gif +126 Emettre des soumissions en_construction.html 20 emettre.gif +127 Liste des t2 t2_liste_form.phtml 51060 link.gif +128 Emettre un appel d offres en_construction.html 10 emettre.gif +129 Emettre des soumissions en_construction.html 20 emettre.gif +130 Liste des t2 t2_liste_form.phtml 51060 link.gif +131 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +132 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +133 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +134 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +135 Modifier des clients en_construction.html 40010 link.gif +136 Effacer des clients en_construction.html 40020 link.gif +137 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +138 Emettre un appel d offres en_construction.html 10 emettre.gif +139 Emettre des soumissions en_construction.html 20 emettre.gif +140 Liste des t2 t2_liste_form.phtml 51060 link.gif +141 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +142 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +143 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +144 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +145 Modifier des clients en_construction.html 40010 link.gif +146 Effacer des clients en_construction.html 40020 link.gif +147 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +148 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +149 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +150 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +151 Emettre un appel d offres en_construction.html 10 emettre.gif +152 Emettre des soumissions en_construction.html 20 emettre.gif +153 Liste des t2 t2_liste_form.phtml 51060 link.gif +154 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +155 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +156 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +157 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +158 Modifier des clients en_construction.html 40010 link.gif +159 Effacer des clients en_construction.html 40020 link.gif +160 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +161 Emettre un appel d offres en_construction.html 10 emettre.gif +162 Emettre des soumissions en_construction.html 20 emettre.gif +163 Liste des t2 t2_liste_form.phtml 51060 link.gif +164 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +165 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +166 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +167 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +168 Modifier des clients en_construction.html 40010 link.gif +169 Effacer des clients en_construction.html 40020 link.gif +170 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +171 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +172 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +173 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +174 Effacer des clients en_construction.html 40020 link.gif +175 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +176 Emettre un appel d offres en_construction.html 10 emettre.gif +177 Emettre des soumissions en_construction.html 20 emettre.gif +178 Liste des t2 t2_liste_form.phtml 51060 link.gif +179 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +180 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +181 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +182 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +183 Modifier des clients en_construction.html 40010 link.gif +184 Effacer des clients en_construction.html 40020 link.gif +185 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +186 Emettre un appel d offres en_construction.html 10 emettre.gif +187 Emettre des soumissions en_construction.html 20 emettre.gif +188 Liste des t2 t2_liste_form.phtml 51060 link.gif +189 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +190 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +191 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +192 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +193 Modifier des clients en_construction.html 40010 link.gif +194 Effacer des clients en_construction.html 40020 link.gif +195 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +196 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +197 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +198 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +199 Emettre un appel d offres en_construction.html 10 emettre.gif +200 Emettre des soumissions en_construction.html 20 emettre.gif +201 Liste des t2 t2_liste_form.phtml 51060 link.gif +202 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +203 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +204 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +205 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +206 Modifier des clients en_construction.html 40010 link.gif +207 Effacer des clients en_construction.html 40020 link.gif +208 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +209 Emettre un appel d offres en_construction.html 10 emettre.gif +210 Emettre des soumissions en_construction.html 20 emettre.gif +211 Liste des t2 t2_liste_form.phtml 51060 link.gif +212 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +213 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +214 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +215 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +216 Modifier des clients en_construction.html 40010 link.gif +217 Effacer des clients en_construction.html 40020 link.gif +218 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +219 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +220 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +221 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +222 Effacer des clients en_construction.html 40020 link.gif +223 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +224 Emettre un appel d offres en_construction.html 10 emettre.gif +225 Emettre des soumissions en_construction.html 20 emettre.gif +226 Liste des t2 t2_liste_form.phtml 51060 link.gif +255 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +256 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +257 Modifier des clients en_construction.html 40010 link.gif +258 Emettre un appel d offres en_construction.html 10 emettre.gif +259 Emettre des soumissions en_construction.html 20 emettre.gif +260 Liste des t2 t2_liste_form.phtml 51060 link.gif +261 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +262 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +263 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +264 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +265 Modifier des clients en_construction.html 40010 link.gif +266 Effacer des clients en_construction.html 40020 link.gif +267 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +268 Emettre un appel d offres en_construction.html 10 emettre.gif +269 Emettre des soumissions en_construction.html 20 emettre.gif +270 Liste des t2 t2_liste_form.phtml 51060 link.gif +271 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +272 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +273 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +274 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +275 Modifier des clients en_construction.html 40010 link.gif +276 Effacer des clients en_construction.html 40020 link.gif +277 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +278 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +279 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +280 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +281 Emettre un appel d offres en_construction.html 10 emettre.gif +282 Emettre des soumissions en_construction.html 20 emettre.gif +283 Liste des t2 t2_liste_form.phtml 51060 link.gif +284 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +285 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +286 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +287 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +288 Modifier des clients en_construction.html 40010 link.gif +289 Effacer des clients en_construction.html 40020 link.gif +290 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +291 Emettre un appel d offres en_construction.html 10 emettre.gif +292 Emettre des soumissions en_construction.html 20 emettre.gif +293 Liste des t2 t2_liste_form.phtml 51060 link.gif +294 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +295 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +296 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +297 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +298 Modifier des clients en_construction.html 40010 link.gif +299 Effacer des clients en_construction.html 40020 link.gif +300 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +301 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +302 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +303 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +304 Effacer des clients en_construction.html 40020 link.gif +305 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +306 Emettre un appel d offres en_construction.html 10 emettre.gif +307 Emettre des soumissions en_construction.html 20 emettre.gif +308 Liste des t2 t2_liste_form.phtml 51060 link.gif +309 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +310 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +311 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +312 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +313 Modifier des clients en_construction.html 40010 link.gif +314 Effacer des clients en_construction.html 40020 link.gif +315 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +316 Emettre un appel d offres en_construction.html 10 emettre.gif +317 Emettre des soumissions en_construction.html 20 emettre.gif +318 Liste des t2 t2_liste_form.phtml 51060 link.gif +319 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +320 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +321 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +322 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +323 Modifier des clients en_construction.html 40010 link.gif +324 Effacer des clients en_construction.html 40020 link.gif +325 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +326 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +327 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +328 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +329 Emettre un appel d offres en_construction.html 10 emettre.gif +330 Emettre des soumissions en_construction.html 20 emettre.gif +331 Liste des t2 t2_liste_form.phtml 51060 link.gif +332 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +333 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +334 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +335 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +336 Modifier des clients en_construction.html 40010 link.gif +337 Effacer des clients en_construction.html 40020 link.gif +338 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +339 Emettre un appel d offres en_construction.html 10 emettre.gif +340 Emettre des soumissions en_construction.html 20 emettre.gif +341 Liste des t2 t2_liste_form.phtml 51060 link.gif +342 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +343 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +344 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +345 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +346 Modifier des clients en_construction.html 40010 link.gif +347 Effacer des clients en_construction.html 40020 link.gif +348 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +349 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +350 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +351 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +352 Effacer des clients en_construction.html 40020 link.gif +353 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +354 Emettre un appel d offres en_construction.html 10 emettre.gif +355 Emettre des soumissions en_construction.html 20 emettre.gif +356 Liste des t2 t2_liste_form.phtml 51060 link.gif +357 Emettre un appel d offres en_construction.html 10 emettre.gif +358 Emettre des soumissions en_construction.html 20 emettre.gif +359 Liste des t2 t2_liste_form.phtml 51060 link.gif +360 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +361 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +362 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +363 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +364 Modifier des clients en_construction.html 40010 link.gif +365 Effacer des clients en_construction.html 40020 link.gif +366 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +367 Emettre un appel d offres en_construction.html 10 emettre.gif +368 Emettre des soumissions en_construction.html 20 emettre.gif +369 Liste des t2 t2_liste_form.phtml 51060 link.gif +370 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +371 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +372 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +373 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +374 Modifier des clients en_construction.html 40010 link.gif +375 Effacer des clients en_construction.html 40020 link.gif +376 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +377 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +378 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +379 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +380 Emettre un appel d offres en_construction.html 10 emettre.gif +381 Emettre des soumissions en_construction.html 20 emettre.gif +382 Liste des t2 t2_liste_form.phtml 51060 link.gif +383 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +384 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +385 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +386 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +387 Modifier des clients en_construction.html 40010 link.gif +388 Effacer des clients en_construction.html 40020 link.gif +389 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +390 Emettre un appel d offres en_construction.html 10 emettre.gif +391 Emettre des soumissions en_construction.html 20 emettre.gif +392 Liste des t2 t2_liste_form.phtml 51060 link.gif +393 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +394 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +395 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +396 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +397 Modifier des clients en_construction.html 40010 link.gif +398 Effacer des clients en_construction.html 40020 link.gif +399 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +400 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +401 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +402 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +403 Effacer des clients en_construction.html 40020 link.gif +404 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +405 Emettre un appel d offres en_construction.html 10 emettre.gif +406 Emettre des soumissions en_construction.html 20 emettre.gif +407 Liste des t2 t2_liste_form.phtml 51060 link.gif +408 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +409 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +410 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +411 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +412 Modifier des clients en_construction.html 40010 link.gif +413 Effacer des clients en_construction.html 40020 link.gif +414 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +415 Emettre un appel d offres en_construction.html 10 emettre.gif +416 Emettre des soumissions en_construction.html 20 emettre.gif +417 Liste des t2 t2_liste_form.phtml 51060 link.gif +418 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +419 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +420 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +421 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +422 Modifier des clients en_construction.html 40010 link.gif +423 Effacer des clients en_construction.html 40020 link.gif +424 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +425 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +426 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +427 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +428 Emettre un appel d offres en_construction.html 10 emettre.gif +429 Emettre des soumissions en_construction.html 20 emettre.gif +430 Liste des t2 t2_liste_form.phtml 51060 link.gif +431 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +432 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +433 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +434 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +435 Modifier des clients en_construction.html 40010 link.gif +436 Effacer des clients en_construction.html 40020 link.gif +437 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +438 Emettre un appel d offres en_construction.html 10 emettre.gif +439 Emettre des soumissions en_construction.html 20 emettre.gif +440 Liste des t2 t2_liste_form.phtml 51060 link.gif +441 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +442 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +443 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +444 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +445 Modifier des clients en_construction.html 40010 link.gif +446 Effacer des clients en_construction.html 40020 link.gif +447 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +448 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +449 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +450 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +451 Effacer des clients en_construction.html 40020 link.gif +452 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +453 Emettre un appel d offres en_construction.html 10 emettre.gif +454 Emettre des soumissions en_construction.html 20 emettre.gif +455 Liste des t2 t2_liste_form.phtml 51060 link.gif +456 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +457 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +458 Modifier des clients en_construction.html 40010 link.gif +513 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +514 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +515 Emettre un appel d offres en_construction.html 10 emettre.gif +516 Emettre des soumissions en_construction.html 20 emettre.gif +517 Liste des t2 t2_liste_form.phtml 51060 link.gif +518 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +519 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +520 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +521 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +522 Modifier des clients en_construction.html 40010 link.gif +523 Effacer des clients en_construction.html 40020 link.gif +524 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +525 Emettre un appel d offres en_construction.html 10 emettre.gif +526 Emettre des soumissions en_construction.html 20 emettre.gif +527 Liste des t2 t2_liste_form.phtml 51060 link.gif +528 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +529 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +530 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +531 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +532 Modifier des clients en_construction.html 40010 link.gif +533 Effacer des clients en_construction.html 40020 link.gif +534 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +535 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +536 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +537 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +538 Emettre un appel d offres en_construction.html 10 emettre.gif +539 Emettre des soumissions en_construction.html 20 emettre.gif +540 Liste des t2 t2_liste_form.phtml 51060 link.gif +541 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +542 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +543 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +544 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +545 Modifier des clients en_construction.html 40010 link.gif +546 Effacer des clients en_construction.html 40020 link.gif +547 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +548 Emettre un appel d offres en_construction.html 10 emettre.gif +549 Emettre des soumissions en_construction.html 20 emettre.gif +550 Liste des t2 t2_liste_form.phtml 51060 link.gif +551 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +552 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +553 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +554 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +555 Modifier des clients en_construction.html 40010 link.gif +556 Effacer des clients en_construction.html 40020 link.gif +557 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +558 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +559 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +560 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +561 Effacer des clients en_construction.html 40020 link.gif +562 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +563 Emettre un appel d offres en_construction.html 10 emettre.gif +564 Emettre des soumissions en_construction.html 20 emettre.gif +565 Liste des t2 t2_liste_form.phtml 51060 link.gif +566 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +567 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +568 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +569 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +570 Modifier des clients en_construction.html 40010 link.gif +571 Effacer des clients en_construction.html 40020 link.gif +572 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +573 Emettre un appel d offres en_construction.html 10 emettre.gif +574 Emettre des soumissions en_construction.html 20 emettre.gif +575 Liste des t2 t2_liste_form.phtml 51060 link.gif +576 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +577 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +578 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +579 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +580 Modifier des clients en_construction.html 40010 link.gif +581 Effacer des clients en_construction.html 40020 link.gif +582 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +583 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +584 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +585 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +586 Emettre un appel d offres en_construction.html 10 emettre.gif +587 Emettre des soumissions en_construction.html 20 emettre.gif +588 Liste des t2 t2_liste_form.phtml 51060 link.gif +589 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +590 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +591 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +592 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +593 Modifier des clients en_construction.html 40010 link.gif +594 Effacer des clients en_construction.html 40020 link.gif +595 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +596 Emettre un appel d offres en_construction.html 10 emettre.gif +597 Emettre des soumissions en_construction.html 20 emettre.gif +598 Liste des t2 t2_liste_form.phtml 51060 link.gif +599 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +600 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +601 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +602 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +603 Modifier des clients en_construction.html 40010 link.gif +604 Effacer des clients en_construction.html 40020 link.gif +605 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +606 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +607 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +608 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +609 Effacer des clients en_construction.html 40020 link.gif +610 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +611 Emettre un appel d offres en_construction.html 10 emettre.gif +612 Emettre des soumissions en_construction.html 20 emettre.gif +613 Liste des t2 t2_liste_form.phtml 51060 link.gif +614 Emettre un appel d offres en_construction.html 10 emettre.gif +615 Emettre des soumissions en_construction.html 20 emettre.gif +616 Liste des t2 t2_liste_form.phtml 51060 link.gif +617 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +618 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +619 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +620 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +621 Modifier des clients en_construction.html 40010 link.gif +622 Effacer des clients en_construction.html 40020 link.gif +623 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +624 Emettre un appel d offres en_construction.html 10 emettre.gif +625 Emettre des soumissions en_construction.html 20 emettre.gif +626 Liste des t2 t2_liste_form.phtml 51060 link.gif +627 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +628 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +629 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +630 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +631 Modifier des clients en_construction.html 40010 link.gif +632 Effacer des clients en_construction.html 40020 link.gif +633 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +634 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +635 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +636 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +637 Emettre un appel d offres en_construction.html 10 emettre.gif +638 Emettre des soumissions en_construction.html 20 emettre.gif +639 Liste des t2 t2_liste_form.phtml 51060 link.gif +640 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +641 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +642 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +643 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +644 Modifier des clients en_construction.html 40010 link.gif +645 Effacer des clients en_construction.html 40020 link.gif +646 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +647 Emettre un appel d offres en_construction.html 10 emettre.gif +648 Emettre des soumissions en_construction.html 20 emettre.gif +649 Liste des t2 t2_liste_form.phtml 51060 link.gif +650 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +651 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +652 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +653 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +654 Modifier des clients en_construction.html 40010 link.gif +655 Effacer des clients en_construction.html 40020 link.gif +656 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +657 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +658 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +659 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +660 Effacer des clients en_construction.html 40020 link.gif +661 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +662 Emettre un appel d offres en_construction.html 10 emettre.gif +663 Emettre des soumissions en_construction.html 20 emettre.gif +664 Liste des t2 t2_liste_form.phtml 51060 link.gif +665 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +666 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +667 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +668 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +669 Modifier des clients en_construction.html 40010 link.gif +670 Effacer des clients en_construction.html 40020 link.gif +671 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +672 Emettre un appel d offres en_construction.html 10 emettre.gif +673 Emettre des soumissions en_construction.html 20 emettre.gif +674 Liste des t2 t2_liste_form.phtml 51060 link.gif +675 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +676 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +677 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +678 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +679 Modifier des clients en_construction.html 40010 link.gif +680 Effacer des clients en_construction.html 40020 link.gif +681 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +682 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +683 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +684 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +685 Emettre un appel d offres en_construction.html 10 emettre.gif +686 Emettre des soumissions en_construction.html 20 emettre.gif +687 Liste des t2 t2_liste_form.phtml 51060 link.gif +688 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +689 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +690 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +691 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +692 Modifier des clients en_construction.html 40010 link.gif +693 Effacer des clients en_construction.html 40020 link.gif +694 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +695 Emettre un appel d offres en_construction.html 10 emettre.gif +696 Emettre des soumissions en_construction.html 20 emettre.gif +697 Liste des t2 t2_liste_form.phtml 51060 link.gif +698 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +699 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +700 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +701 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +702 Modifier des clients en_construction.html 40010 link.gif +703 Effacer des clients en_construction.html 40020 link.gif +704 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +705 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +706 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +707 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +708 Effacer des clients en_construction.html 40020 link.gif +709 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +710 Emettre un appel d offres en_construction.html 10 emettre.gif +711 Emettre des soumissions en_construction.html 20 emettre.gif +712 Liste des t2 t2_liste_form.phtml 51060 link.gif +713 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +714 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +715 Modifier des clients en_construction.html 40010 link.gif +716 Emettre un appel d offres en_construction.html 10 emettre.gif +717 Emettre des soumissions en_construction.html 20 emettre.gif +718 Liste des t2 t2_liste_form.phtml 51060 link.gif +719 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +720 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +721 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +722 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +723 Modifier des clients en_construction.html 40010 link.gif +724 Effacer des clients en_construction.html 40020 link.gif +725 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +726 Emettre un appel d offres en_construction.html 10 emettre.gif +727 Emettre des soumissions en_construction.html 20 emettre.gif +728 Liste des t2 t2_liste_form.phtml 51060 link.gif +729 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +730 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +731 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +732 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +733 Modifier des clients en_construction.html 40010 link.gif +734 Effacer des clients en_construction.html 40020 link.gif +735 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +736 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +737 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +738 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +739 Emettre un appel d offres en_construction.html 10 emettre.gif +740 Emettre des soumissions en_construction.html 20 emettre.gif +741 Liste des t2 t2_liste_form.phtml 51060 link.gif +742 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +743 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +744 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +745 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +746 Modifier des clients en_construction.html 40010 link.gif +747 Effacer des clients en_construction.html 40020 link.gif +748 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +749 Emettre un appel d offres en_construction.html 10 emettre.gif +750 Emettre des soumissions en_construction.html 20 emettre.gif +751 Liste des t2 t2_liste_form.phtml 51060 link.gif +752 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +753 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +754 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +755 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +756 Modifier des clients en_construction.html 40010 link.gif +757 Effacer des clients en_construction.html 40020 link.gif +758 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +759 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +760 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +761 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +762 Effacer des clients en_construction.html 40020 link.gif +763 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +764 Emettre un appel d offres en_construction.html 10 emettre.gif +765 Emettre des soumissions en_construction.html 20 emettre.gif +766 Liste des t2 t2_liste_form.phtml 51060 link.gif +767 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +768 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +769 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +770 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +771 Modifier des clients en_construction.html 40010 link.gif +772 Effacer des clients en_construction.html 40020 link.gif +773 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +774 Emettre un appel d offres en_construction.html 10 emettre.gif +775 Emettre des soumissions en_construction.html 20 emettre.gif +776 Liste des t2 t2_liste_form.phtml 51060 link.gif +777 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +778 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +779 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +780 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +781 Modifier des clients en_construction.html 40010 link.gif +782 Effacer des clients en_construction.html 40020 link.gif +783 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +784 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +785 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +786 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +787 Emettre un appel d offres en_construction.html 10 emettre.gif +788 Emettre des soumissions en_construction.html 20 emettre.gif +789 Liste des t2 t2_liste_form.phtml 51060 link.gif +790 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +791 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +792 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +793 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +794 Modifier des clients en_construction.html 40010 link.gif +795 Effacer des clients en_construction.html 40020 link.gif +796 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +797 Emettre un appel d offres en_construction.html 10 emettre.gif +798 Emettre des soumissions en_construction.html 20 emettre.gif +799 Liste des t2 t2_liste_form.phtml 51060 link.gif +800 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +801 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +802 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +803 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +804 Modifier des clients en_construction.html 40010 link.gif +805 Effacer des clients en_construction.html 40020 link.gif +806 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +807 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +808 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +809 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +810 Effacer des clients en_construction.html 40020 link.gif +811 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +812 Emettre un appel d offres en_construction.html 10 emettre.gif +813 Emettre des soumissions en_construction.html 20 emettre.gif +814 Liste des t2 t2_liste_form.phtml 51060 link.gif +815 Emettre un appel d offres en_construction.html 10 emettre.gif +816 Emettre des soumissions en_construction.html 20 emettre.gif +817 Liste des t2 t2_liste_form.phtml 51060 link.gif +818 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +819 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +820 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +821 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +822 Modifier des clients en_construction.html 40010 link.gif +823 Effacer des clients en_construction.html 40020 link.gif +824 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +825 Emettre un appel d offres en_construction.html 10 emettre.gif +826 Emettre des soumissions en_construction.html 20 emettre.gif +827 Liste des t2 t2_liste_form.phtml 51060 link.gif +828 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +829 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +830 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +831 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +832 Modifier des clients en_construction.html 40010 link.gif +833 Effacer des clients en_construction.html 40020 link.gif +834 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +835 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +836 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +837 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +838 Emettre un appel d offres en_construction.html 10 emettre.gif +839 Emettre des soumissions en_construction.html 20 emettre.gif +840 Liste des t2 t2_liste_form.phtml 51060 link.gif +841 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +842 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +843 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +844 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +845 Modifier des clients en_construction.html 40010 link.gif +846 Effacer des clients en_construction.html 40020 link.gif +847 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +848 Emettre un appel d offres en_construction.html 10 emettre.gif +849 Emettre des soumissions en_construction.html 20 emettre.gif +850 Liste des t2 t2_liste_form.phtml 51060 link.gif +851 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +852 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +853 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +854 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +855 Modifier des clients en_construction.html 40010 link.gif +856 Effacer des clients en_construction.html 40020 link.gif +857 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +858 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +859 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +860 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +861 Effacer des clients en_construction.html 40020 link.gif +862 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +863 Emettre un appel d offres en_construction.html 10 emettre.gif +864 Emettre des soumissions en_construction.html 20 emettre.gif +865 Liste des t2 t2_liste_form.phtml 51060 link.gif +866 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +867 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +868 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +869 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +870 Modifier des clients en_construction.html 40010 link.gif +871 Effacer des clients en_construction.html 40020 link.gif +872 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +873 Emettre un appel d offres en_construction.html 10 emettre.gif +874 Emettre des soumissions en_construction.html 20 emettre.gif +875 Liste des t2 t2_liste_form.phtml 51060 link.gif +876 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +877 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +878 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +879 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +880 Modifier des clients en_construction.html 40010 link.gif +881 Effacer des clients en_construction.html 40020 link.gif +882 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +883 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +884 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +885 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +886 Emettre un appel d offres en_construction.html 10 emettre.gif +887 Emettre des soumissions en_construction.html 20 emettre.gif +888 Liste des t2 t2_liste_form.phtml 51060 link.gif +889 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +890 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +891 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +892 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +893 Modifier des clients en_construction.html 40010 link.gif +894 Effacer des clients en_construction.html 40020 link.gif +895 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +896 Emettre un appel d offres en_construction.html 10 emettre.gif +897 Emettre des soumissions en_construction.html 20 emettre.gif +898 Liste des t2 t2_liste_form.phtml 51060 link.gif +899 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +900 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +901 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +902 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +903 Modifier des clients en_construction.html 40010 link.gif +904 Effacer des clients en_construction.html 40020 link.gif +905 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +906 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +907 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +908 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +909 Effacer des clients en_construction.html 40020 link.gif +910 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +911 Emettre un appel d offres en_construction.html 10 emettre.gif +912 Emettre des soumissions en_construction.html 20 emettre.gif +913 Liste des t2 t2_liste_form.phtml 51060 link.gif +914 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +915 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +916 Modifier des clients en_construction.html 40010 link.gif +917 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +918 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +SELECT description, idform FROM t2 ORDER BY id desc; +description idform +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +Ajouter un service t2_ajoute_form.phtml +Effacer des clients en_construction.html +Modifier des clients en_construction.html +Créer une fiche de client clients_ajoute_form.phtml +Lister/modifier un type de materiel typeMateriel_liste_form.phtml +Ajouter un type de materiel typeMateriel_ajoute_form.phtml +Consulter les soumissions consulter_soumissions.phtml +Liste des t2 t2_liste_form.phtml +Emettre des soumissions en_construction.html +Emettre un appel d offres en_construction.html +SELECT * FROM t2 ORDER BY id limit 15; +id description idform ordre image +1 Emettre un appel d offres en_construction.html 10 emettre.gif +2 Emettre des soumissions en_construction.html 20 emettre.gif +3 Liste des t2 t2_liste_form.phtml 51060 link.gif +4 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +5 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +6 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +7 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +8 Modifier des clients en_construction.html 40010 link.gif +9 Effacer des clients en_construction.html 40020 link.gif +10 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +11 Emettre un appel d offres en_construction.html 10 emettre.gif +12 Emettre des soumissions en_construction.html 20 emettre.gif +13 Liste des t2 t2_liste_form.phtml 51060 link.gif +14 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +15 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +SELECT * FROM t2 ORDER BY id, ordre limit 15; +id description idform ordre image +1 Emettre un appel d offres en_construction.html 10 emettre.gif +2 Emettre des soumissions en_construction.html 20 emettre.gif +3 Liste des t2 t2_liste_form.phtml 51060 link.gif +4 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +5 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +6 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +7 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +8 Modifier des clients en_construction.html 40010 link.gif +9 Effacer des clients en_construction.html 40020 link.gif +10 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +11 Emettre un appel d offres en_construction.html 10 emettre.gif +12 Emettre des soumissions en_construction.html 20 emettre.gif +13 Liste des t2 t2_liste_form.phtml 51060 link.gif +14 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +15 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +SELECT * FROM t2 ORDER BY id, ordre desc limit 15; +id description idform ordre image +1 Emettre un appel d offres en_construction.html 10 emettre.gif +2 Emettre des soumissions en_construction.html 20 emettre.gif +3 Liste des t2 t2_liste_form.phtml 51060 link.gif +4 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +5 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +6 Lister/modifier un type de materiel typeMateriel_liste_form.phtml 51010 link.gif +7 Créer une fiche de client clients_ajoute_form.phtml 40000 link.gif +8 Modifier des clients en_construction.html 40010 link.gif +9 Effacer des clients en_construction.html 40020 link.gif +10 Ajouter un service t2_ajoute_form.phtml 51050 link.gif +11 Emettre un appel d offres en_construction.html 10 emettre.gif +12 Emettre des soumissions en_construction.html 20 emettre.gif +13 Liste des t2 t2_liste_form.phtml 51060 link.gif +14 Consulter les soumissions consulter_soumissions.phtml 200 link.gif +15 Ajouter un type de materiel typeMateriel_ajoute_form.phtml 51000 link.gif +DROP TABLE t2; +CREATE TABLE t1( +f0 int auto_increment PRIMARY KEY, +f1 int, +f2 varchar(200) +) charset latin1; +SELECT * FROM t1 ORDER BY f0; +f0 f1 f2 +1 2 72 0 +2 1 71 0 +3 0 70 0 +4 510 69 0 +5 509 68 0 +6 508 67 0 +7 507 66 0 +8 506 65 0 +9 505 64 0 +10 504 63 0 +11 503 62 0 +12 502 61 0 +13 501 60 0 +14 500 59 0 +15 499 58 0 +16 498 57 0 +17 497 56 0 +18 496 55 0 +19 495 54 0 +20 494 53 0 +21 493 52 0 +22 492 51 0 +23 491 50 0 +24 490 49 0 +25 489 48 0 +26 488 47 0 +27 487 46 0 +28 486 45 0 +29 485 44 0 +30 484 43 0 +31 483 42 0 +32 482 41 0 +33 481 40 0 +34 480 39 0 +35 479 38 0 +36 478 37 0 +37 477 36 0 +38 476 35 0 +39 475 34 0 +40 474 33 0 +41 473 32 0 +42 472 31 0 +43 471 30 0 +44 470 29 0 +45 469 28 0 +46 468 27 0 +47 467 26 0 +48 466 25 0 +49 465 24 0 +50 464 23 0 +51 463 22 0 +52 462 21 0 +53 461 20 0 +54 460 19 0 +55 459 18 0 +56 458 17 0 +57 457 16 0 +58 456 15 0 +59 455 14 0 +60 454 13 0 +61 453 12 0 +62 452 11 0 +63 451 10 0 +64 450 9 0 +65 449 8 0 +66 448 7 0 +67 447 6 0 +68 446 5 0 +69 445 4 0 +70 444 3 0 +71 443 2 0 +72 442 1 0 +73 441 0 0 +74 440 118 0 +75 439 117 0 +76 438 116 0 +77 437 115 0 +78 436 114 0 +79 435 113 0 +80 434 112 0 +81 433 111 0 +82 432 110 0 +83 431 109 0 +84 430 108 0 +85 429 107 0 +86 428 106 0 +87 427 105 0 +88 426 104 0 +89 425 103 0 +90 424 102 0 +91 423 101 0 +92 422 100 0 +93 421 99 0 +94 420 98 0 +95 419 97 0 +96 418 96 0 +97 417 95 0 +98 416 94 0 +99 415 93 0 +100 414 92 0 +101 413 91 0 +102 412 90 0 +103 411 89 0 +104 410 88 0 +105 409 87 0 +106 408 86 0 +107 407 85 0 +108 406 84 0 +109 405 83 0 +110 404 82 0 +111 403 81 0 +112 402 80 0 +113 401 79 0 +114 400 78 0 +115 399 77 0 +116 398 76 0 +117 397 75 0 +118 396 74 0 +119 395 73 0 +120 394 72 0 +121 393 71 0 +122 392 70 0 +123 391 69 0 +124 390 68 0 +125 389 67 0 +126 388 66 0 +127 387 65 0 +128 386 64 0 +129 385 63 0 +130 384 62 0 +131 383 61 0 +132 382 60 0 +133 381 59 0 +134 380 58 0 +135 379 57 0 +136 378 56 0 +137 377 55 0 +138 376 54 0 +139 375 53 0 +140 374 52 0 +141 373 51 0 +142 372 50 0 +143 371 49 0 +144 370 48 0 +145 369 47 0 +146 368 46 0 +147 367 45 0 +148 366 44 0 +149 365 43 0 +150 364 42 0 +151 363 41 0 +152 362 40 0 +153 361 39 0 +154 360 38 0 +155 359 37 0 +156 358 36 0 +157 357 35 0 +158 356 34 0 +159 355 33 0 +160 354 32 0 +161 353 31 0 +162 352 30 0 +163 351 29 0 +164 350 28 0 +165 349 27 0 +166 348 26 0 +167 347 25 0 +168 346 24 0 +169 345 23 0 +170 344 22 0 +171 343 21 0 +172 342 20 0 +173 341 19 0 +174 340 18 0 +175 339 17 0 +176 338 16 0 +177 337 15 0 +178 336 14 0 +179 335 13 0 +180 334 12 0 +181 333 11 0 +182 332 10 0 +183 331 9 0 +184 330 8 0 +185 329 7 0 +186 328 6 0 +187 327 5 0 +188 326 4 0 +189 325 3 0 +190 324 2 0 +191 323 1 0 +192 322 0 0 +193 321 118 0 +194 320 117 0 +195 319 116 0 +196 318 115 0 +197 317 114 0 +198 316 113 0 +199 315 112 0 +200 314 111 0 +201 313 110 0 +202 312 109 0 +203 311 108 0 +204 310 107 0 +205 309 106 0 +206 308 105 0 +207 307 104 0 +208 306 103 0 +209 305 102 0 +210 304 101 0 +211 303 100 0 +212 302 99 0 +213 301 98 0 +214 300 97 0 +215 299 96 0 +216 298 95 0 +217 297 94 0 +218 296 93 0 +219 295 92 0 +220 294 91 0 +221 293 90 0 +222 292 89 0 +223 291 88 0 +224 290 87 0 +225 289 86 0 +226 288 85 0 +227 287 84 0 +228 286 83 0 +229 285 82 0 +230 284 81 0 +231 283 80 0 +232 282 79 0 +233 281 78 0 +234 280 77 0 +235 279 76 0 +236 278 75 0 +237 277 74 0 +238 276 73 0 +239 275 72 0 +240 274 71 0 +241 273 70 0 +242 272 69 0 +243 271 68 0 +244 270 67 0 +245 269 66 0 +246 268 65 0 +247 267 64 0 +248 266 63 0 +249 265 62 0 +250 264 61 0 +251 263 60 0 +252 262 59 0 +253 261 58 0 +254 260 57 0 +255 259 56 0 +256 258 55 0 +257 257 54 0 +258 256 53 0 +259 255 52 0 +260 254 51 0 +261 253 50 0 +262 252 49 0 +263 251 48 0 +264 250 47 0 +265 249 46 0 +266 248 45 0 +267 247 44 0 +268 246 43 0 +269 245 42 0 +270 244 41 0 +271 243 40 0 +272 242 39 0 +273 241 38 0 +274 240 37 0 +275 239 36 0 +276 238 35 0 +277 237 34 0 +278 236 33 0 +279 235 32 0 +280 234 31 0 +281 233 30 0 +282 232 29 0 +283 231 28 0 +284 230 27 0 +285 229 26 0 +286 228 25 0 +287 227 24 0 +288 226 23 0 +289 225 22 0 +290 224 21 0 +291 223 20 0 +292 222 19 0 +293 221 18 0 +294 220 17 0 +295 219 16 0 +296 218 15 0 +297 217 14 0 +298 216 13 0 +299 215 12 0 +300 214 11 0 +301 213 10 0 +302 212 9 0 +303 211 8 0 +304 210 7 0 +305 209 6 0 +306 208 5 0 +307 207 4 0 +308 206 3 0 +309 205 2 0 +310 204 1 0 +311 203 0 0 +312 202 118 0 +313 201 117 0 +314 200 116 0 +315 199 115 0 +316 198 114 0 +317 197 113 0 +318 196 112 0 +319 195 111 0 +320 194 110 0 +321 193 109 0 +322 192 108 0 +323 191 107 0 +324 190 106 0 +325 189 105 0 +326 188 104 0 +327 187 103 0 +328 186 102 0 +329 185 101 0 +330 184 100 0 +331 183 99 0 +332 182 98 0 +333 181 97 0 +334 180 96 0 +335 179 95 0 +336 178 94 0 +337 177 93 0 +338 176 92 0 +339 175 91 0 +340 174 90 0 +341 173 89 0 +342 172 88 0 +343 171 87 0 +344 170 86 0 +345 169 85 0 +346 168 84 0 +347 167 83 0 +348 166 82 0 +349 165 81 0 +350 164 80 0 +351 163 79 0 +352 162 78 0 +353 161 77 0 +354 160 76 0 +355 159 75 0 +356 158 74 0 +357 157 73 0 +358 156 72 0 +359 155 71 0 +360 154 70 0 +361 153 69 0 +362 152 68 0 +363 151 67 0 +364 150 66 0 +365 149 65 0 +366 148 64 0 +367 147 63 0 +368 146 62 0 +369 145 61 0 +370 144 60 0 +371 143 59 0 +372 142 58 0 +373 141 57 0 +374 140 56 0 +375 139 55 0 +376 138 54 0 +377 137 53 0 +378 136 52 0 +379 135 51 0 +380 134 50 0 +381 133 49 0 +382 132 48 0 +383 131 47 0 +384 130 46 0 +385 129 45 0 +386 128 44 0 +387 127 43 0 +388 126 42 0 +389 125 41 0 +390 124 40 0 +391 123 39 0 +392 122 38 0 +393 121 37 0 +394 120 36 0 +395 119 35 0 +396 118 34 0 +397 117 33 0 +398 116 32 0 +399 115 31 0 +400 114 30 0 +401 113 29 0 +402 112 28 0 +403 111 27 0 +404 110 26 0 +405 109 25 0 +406 108 24 0 +407 107 23 0 +408 106 22 0 +409 105 21 0 +410 104 20 0 +411 103 19 0 +412 102 18 0 +413 101 17 0 +414 100 16 0 +415 99 15 0 +416 98 14 0 +417 97 13 0 +418 96 12 0 +419 95 11 0 +420 94 10 0 +421 93 9 0 +422 92 8 0 +423 91 7 0 +424 90 6 0 +425 89 5 0 +426 88 4 0 +427 87 3 0 +428 86 2 0 +429 85 1 0 +430 84 0 0 +431 83 118 0 +432 82 117 0 +433 81 116 0 +434 80 115 0 +435 79 114 0 +436 78 113 0 +437 77 112 0 +438 76 111 0 +439 75 110 0 +440 74 109 0 +441 73 108 0 +442 72 107 0 +443 71 106 0 +444 70 105 0 +445 69 104 0 +446 68 103 0 +447 67 102 0 +448 66 101 0 +449 65 100 0 +450 64 99 0 +451 63 98 0 +452 62 97 0 +453 61 96 0 +454 60 95 0 +455 59 94 0 +456 58 93 0 +457 57 92 0 +458 56 91 0 +459 55 90 0 +460 54 89 0 +461 53 88 0 +462 52 87 0 +463 51 86 0 +464 50 85 0 +465 49 84 0 +466 48 83 0 +467 47 82 0 +468 46 81 0 +469 45 80 0 +470 44 79 0 +471 43 78 0 +472 42 77 0 +473 41 76 0 +474 40 75 0 +475 39 74 0 +476 38 73 0 +477 37 72 0 +478 36 71 0 +479 35 70 0 +480 34 69 0 +481 33 68 0 +482 32 67 0 +483 31 66 0 +484 30 65 0 +485 29 64 0 +486 28 63 0 +487 27 62 0 +488 26 61 0 +489 25 60 0 +490 24 59 0 +491 23 58 0 +492 22 57 0 +493 21 56 0 +494 20 55 0 +495 19 54 0 +496 18 53 0 +497 17 52 0 +498 16 51 0 +499 15 50 0 +500 14 49 0 +501 13 48 0 +502 12 47 0 +503 11 46 0 +504 10 45 0 +505 9 44 0 +506 8 43 0 +507 7 42 0 +508 6 41 0 +509 5 40 0 +510 4 39 0 +511 3 38 0 +512 2 37 0 +513 1 36 0 +514 0 35 0 +515 510 34 0 +516 509 33 0 +517 508 32 0 +518 507 31 0 +519 506 30 0 +520 505 29 0 +521 504 28 0 +522 503 27 0 +523 502 26 0 +524 501 25 0 +525 500 24 0 +526 499 23 0 +527 498 22 0 +528 497 21 0 +529 496 20 0 +530 495 19 0 +531 494 18 0 +532 493 17 0 +533 492 16 0 +534 491 15 0 +535 490 14 0 +536 489 13 0 +537 488 12 0 +538 487 11 0 +539 486 10 0 +540 485 9 0 +541 484 8 0 +542 483 7 0 +543 482 6 0 +544 481 5 0 +545 480 4 0 +546 479 3 0 +547 478 2 0 +548 477 1 0 +549 476 0 0 +550 475 118 0 +551 474 117 0 +552 473 116 0 +553 472 115 0 +554 471 114 0 +555 470 113 0 +556 469 112 0 +557 468 111 0 +558 467 110 0 +559 466 109 0 +560 465 108 0 +561 464 107 0 +562 463 106 0 +563 462 105 0 +564 461 104 0 +565 460 103 0 +566 459 102 0 +567 458 101 0 +568 457 100 0 +569 456 99 0 +570 455 98 0 +571 454 97 0 +572 453 96 0 +573 452 95 0 +574 451 94 0 +575 450 93 0 +576 449 92 0 +577 448 91 0 +578 447 90 0 +579 446 89 0 +580 445 88 0 +581 444 87 0 +582 443 86 0 +583 442 85 0 +584 441 84 0 +585 440 83 0 +586 439 82 0 +587 438 81 0 +588 437 80 0 +589 436 79 0 +590 435 78 0 +591 434 77 0 +592 433 76 0 +593 432 75 0 +594 431 74 0 +595 430 73 0 +596 429 72 0 +597 428 71 0 +598 427 70 0 +599 426 69 0 +600 425 68 0 +601 424 67 0 +602 423 66 0 +603 422 65 0 +604 421 64 0 +605 420 63 0 +606 419 62 0 +607 418 61 0 +608 417 60 0 +609 416 59 0 +610 415 58 0 +611 414 57 0 +612 413 56 0 +613 412 55 0 +614 411 54 0 +615 410 53 0 +616 409 52 0 +617 408 51 0 +618 407 50 0 +619 406 49 0 +620 405 48 0 +621 404 47 0 +622 403 46 0 +623 402 45 0 +624 401 44 0 +625 400 43 0 +626 399 42 0 +627 398 41 0 +628 397 40 0 +629 396 39 0 +630 395 38 0 +631 394 37 0 +632 393 36 0 +633 392 35 0 +634 391 34 0 +635 390 33 0 +636 389 32 0 +637 388 31 0 +638 387 30 0 +639 386 29 0 +640 385 28 0 +641 384 27 0 +642 383 26 0 +643 382 25 0 +644 381 24 0 +645 380 23 0 +646 379 22 0 +647 378 21 0 +648 377 20 0 +649 376 19 0 +650 375 18 0 +651 374 17 0 +652 373 16 0 +653 372 15 0 +654 371 14 0 +655 370 13 0 +656 369 12 0 +657 368 11 0 +658 367 10 0 +659 366 9 0 +660 365 8 0 +661 364 7 0 +662 363 6 0 +663 362 5 0 +664 361 4 0 +665 360 3 0 +666 359 2 0 +667 358 1 0 +668 357 0 0 +669 356 118 0 +670 355 117 0 +671 354 116 0 +672 353 115 0 +673 352 114 0 +674 351 113 0 +675 350 112 0 +676 349 111 0 +677 348 110 0 +678 347 109 0 +679 346 108 0 +680 345 107 0 +681 344 106 0 +682 343 105 0 +683 342 104 0 +684 341 103 0 +685 340 102 0 +686 339 101 0 +687 338 100 0 +688 337 99 0 +689 336 98 0 +690 335 97 0 +691 334 96 0 +692 333 95 0 +693 332 94 0 +694 331 93 0 +695 330 92 0 +696 329 91 0 +697 328 90 0 +698 327 89 0 +699 326 88 0 +700 325 87 0 +701 324 86 0 +702 323 85 0 +703 322 84 0 +704 321 83 0 +705 320 82 0 +706 319 81 0 +707 318 80 0 +708 317 79 0 +709 316 78 0 +710 315 77 0 +711 314 76 0 +712 313 75 0 +713 312 74 0 +714 311 73 0 +715 310 72 0 +716 309 71 0 +717 308 70 0 +718 307 69 0 +719 306 68 0 +720 305 67 0 +721 304 66 0 +722 303 65 0 +723 302 64 0 +724 301 63 0 +725 300 62 0 +726 299 61 0 +727 298 60 0 +728 297 59 0 +729 296 58 0 +730 295 57 0 +731 294 56 0 +732 293 55 0 +733 292 54 0 +734 291 53 0 +735 290 52 0 +736 289 51 0 +737 288 50 0 +738 287 49 0 +739 286 48 0 +740 285 47 0 +741 284 46 0 +742 283 45 0 +743 282 44 0 +744 281 43 0 +745 280 42 0 +746 279 41 0 +747 278 40 0 +748 277 39 0 +749 276 38 0 +750 275 37 0 +751 274 36 0 +752 273 35 0 +753 272 34 0 +754 271 33 0 +755 270 32 0 +756 269 31 0 +757 268 30 0 +758 267 29 0 +759 266 28 0 +760 265 27 0 +761 264 26 0 +762 263 25 0 +763 262 24 0 +764 261 23 0 +765 260 22 0 +766 259 21 0 +767 258 20 0 +768 257 19 0 +769 256 18 0 +770 255 17 0 +771 254 16 0 +772 253 15 0 +773 252 14 0 +774 251 13 0 +775 250 12 0 +776 249 11 0 +777 248 10 0 +778 247 9 0 +779 246 8 0 +780 245 7 0 +781 244 6 0 +782 243 5 0 +783 242 4 0 +784 241 3 0 +785 240 2 0 +786 239 1 0 +787 238 0 0 +788 237 118 0 +789 236 117 0 +790 235 116 0 +791 234 115 0 +792 233 114 0 +793 232 113 0 +794 231 112 0 +795 230 111 0 +796 229 110 0 +797 228 109 0 +798 227 108 0 +799 226 107 0 +800 225 106 0 +801 224 105 0 +802 223 104 0 +803 222 103 0 +804 221 102 0 +805 220 101 0 +806 219 100 0 +807 218 99 0 +808 217 98 0 +809 216 97 0 +810 215 96 0 +811 214 95 0 +812 213 94 0 +813 212 93 0 +814 211 92 0 +815 210 91 0 +816 209 90 0 +817 208 89 0 +818 207 88 0 +819 206 87 0 +820 205 86 0 +821 204 85 0 +822 203 84 0 +823 202 83 0 +824 201 82 0 +825 200 81 0 +826 199 80 0 +827 198 79 0 +828 197 78 0 +829 196 77 0 +830 195 76 0 +831 194 75 0 +832 193 74 0 +833 192 73 0 +834 191 72 0 +835 190 71 0 +836 189 70 0 +837 188 69 0 +838 187 68 0 +839 186 67 0 +840 185 66 0 +841 184 65 0 +842 183 64 0 +843 182 63 0 +844 181 62 0 +845 180 61 0 +846 179 60 0 +847 178 59 0 +848 177 58 0 +849 176 57 0 +850 175 56 0 +851 174 55 0 +852 173 54 0 +853 172 53 0 +854 171 52 0 +855 170 51 0 +856 169 50 0 +857 168 49 0 +858 167 48 0 +859 166 47 0 +860 165 46 0 +861 164 45 0 +862 163 44 0 +863 162 43 0 +864 161 42 0 +865 160 41 0 +866 159 40 0 +867 158 39 0 +868 157 38 0 +869 156 37 0 +870 155 36 0 +871 154 35 0 +872 153 34 0 +873 152 33 0 +874 151 32 0 +875 150 31 0 +876 149 30 0 +877 148 29 0 +878 147 28 0 +879 146 27 0 +880 145 26 0 +881 144 25 0 +882 143 24 0 +883 142 23 0 +884 141 22 0 +885 140 21 0 +886 139 20 0 +887 138 19 0 +888 137 18 0 +889 136 17 0 +890 135 16 0 +891 134 15 0 +892 133 14 0 +893 132 13 0 +894 131 12 0 +895 130 11 0 +896 129 10 0 +897 128 9 0 +898 127 8 0 +899 126 7 0 +900 125 6 0 +901 124 5 0 +902 123 4 0 +903 122 3 0 +904 121 2 0 +905 120 1 0 +906 119 0 0 +907 118 118 0 +908 117 117 0 +909 116 116 0 +910 115 115 0 +911 114 114 0 +912 113 113 0 +913 112 112 0 +914 111 111 0 +915 110 110 0 +916 109 109 0 +917 108 108 0 +918 107 107 0 +919 106 106 0 +920 105 105 0 +921 104 104 0 +922 103 103 0 +923 102 102 0 +924 101 101 0 +925 100 100 0 +926 99 99 0 +927 98 98 0 +928 97 97 0 +929 96 96 0 +930 95 95 0 +931 94 94 0 +932 93 93 0 +933 92 92 0 +934 91 91 0 +935 90 90 0 +936 89 89 0 +937 88 88 0 +938 87 87 0 +939 86 86 0 +940 85 85 0 +941 84 84 0 +942 83 83 0 +943 82 82 0 +944 81 81 0 +945 80 80 0 +946 79 79 0 +947 78 78 0 +948 77 77 0 +949 76 76 0 +950 75 75 0 +951 74 74 0 +952 73 73 0 +953 72 72 0 +954 71 71 0 +955 70 70 0 +956 69 69 0 +957 68 68 0 +958 67 67 0 +959 66 66 0 +960 65 65 0 +961 64 64 0 +962 63 63 0 +963 62 62 0 +964 61 61 0 +965 60 60 0 +966 59 59 0 +967 58 58 0 +968 57 57 0 +969 56 56 0 +970 55 55 0 +971 54 54 0 +972 53 53 0 +973 52 52 0 +974 51 51 0 +975 50 50 0 +976 49 49 0 +977 48 48 0 +978 47 47 0 +979 46 46 0 +980 45 45 0 +981 44 44 0 +982 43 43 0 +983 42 42 0 +984 41 41 0 +985 40 40 0 +986 39 39 0 +987 38 38 0 +988 37 37 0 +989 36 36 0 +990 35 35 0 +991 34 34 0 +992 33 33 0 +993 32 32 0 +994 31 31 0 +995 30 30 0 +996 29 29 0 +997 28 28 0 +998 27 27 0 +999 26 26 0 +1000 25 25 0 +1001 24 24 0 +1002 23 23 0 +1003 22 22 0 +1004 21 21 0 +1005 20 20 0 +1006 19 19 0 +1007 18 18 0 +1008 17 17 0 +1009 16 16 0 +1010 15 15 0 +1011 14 14 0 +1012 13 13 0 +1013 12 12 0 +1014 11 11 0 +1015 10 10 0 +1016 9 9 0 +1017 8 8 0 +1018 7 7 0 +1019 6 6 0 +1020 5 5 0 +1021 4 4 0 +1022 3 3 0 +1023 2 2 0 +1024 1 1 0 +SELECT * FROM t1 ORDER BY f0 desc; +f0 f1 f2 +1024 1 1 0 +1023 2 2 0 +1022 3 3 0 +1021 4 4 0 +1020 5 5 0 +1019 6 6 0 +1018 7 7 0 +1017 8 8 0 +1016 9 9 0 +1015 10 10 0 +1014 11 11 0 +1013 12 12 0 +1012 13 13 0 +1011 14 14 0 +1010 15 15 0 +1009 16 16 0 +1008 17 17 0 +1007 18 18 0 +1006 19 19 0 +1005 20 20 0 +1004 21 21 0 +1003 22 22 0 +1002 23 23 0 +1001 24 24 0 +1000 25 25 0 +999 26 26 0 +998 27 27 0 +997 28 28 0 +996 29 29 0 +995 30 30 0 +994 31 31 0 +993 32 32 0 +992 33 33 0 +991 34 34 0 +990 35 35 0 +989 36 36 0 +988 37 37 0 +987 38 38 0 +986 39 39 0 +985 40 40 0 +984 41 41 0 +983 42 42 0 +982 43 43 0 +981 44 44 0 +980 45 45 0 +979 46 46 0 +978 47 47 0 +977 48 48 0 +976 49 49 0 +975 50 50 0 +974 51 51 0 +973 52 52 0 +972 53 53 0 +971 54 54 0 +970 55 55 0 +969 56 56 0 +968 57 57 0 +967 58 58 0 +966 59 59 0 +965 60 60 0 +964 61 61 0 +963 62 62 0 +962 63 63 0 +961 64 64 0 +960 65 65 0 +959 66 66 0 +958 67 67 0 +957 68 68 0 +956 69 69 0 +955 70 70 0 +954 71 71 0 +953 72 72 0 +952 73 73 0 +951 74 74 0 +950 75 75 0 +949 76 76 0 +948 77 77 0 +947 78 78 0 +946 79 79 0 +945 80 80 0 +944 81 81 0 +943 82 82 0 +942 83 83 0 +941 84 84 0 +940 85 85 0 +939 86 86 0 +938 87 87 0 +937 88 88 0 +936 89 89 0 +935 90 90 0 +934 91 91 0 +933 92 92 0 +932 93 93 0 +931 94 94 0 +930 95 95 0 +929 96 96 0 +928 97 97 0 +927 98 98 0 +926 99 99 0 +925 100 100 0 +924 101 101 0 +923 102 102 0 +922 103 103 0 +921 104 104 0 +920 105 105 0 +919 106 106 0 +918 107 107 0 +917 108 108 0 +916 109 109 0 +915 110 110 0 +914 111 111 0 +913 112 112 0 +912 113 113 0 +911 114 114 0 +910 115 115 0 +909 116 116 0 +908 117 117 0 +907 118 118 0 +906 119 0 0 +905 120 1 0 +904 121 2 0 +903 122 3 0 +902 123 4 0 +901 124 5 0 +900 125 6 0 +899 126 7 0 +898 127 8 0 +897 128 9 0 +896 129 10 0 +895 130 11 0 +894 131 12 0 +893 132 13 0 +892 133 14 0 +891 134 15 0 +890 135 16 0 +889 136 17 0 +888 137 18 0 +887 138 19 0 +886 139 20 0 +885 140 21 0 +884 141 22 0 +883 142 23 0 +882 143 24 0 +881 144 25 0 +880 145 26 0 +879 146 27 0 +878 147 28 0 +877 148 29 0 +876 149 30 0 +875 150 31 0 +874 151 32 0 +873 152 33 0 +872 153 34 0 +871 154 35 0 +870 155 36 0 +869 156 37 0 +868 157 38 0 +867 158 39 0 +866 159 40 0 +865 160 41 0 +864 161 42 0 +863 162 43 0 +862 163 44 0 +861 164 45 0 +860 165 46 0 +859 166 47 0 +858 167 48 0 +857 168 49 0 +856 169 50 0 +855 170 51 0 +854 171 52 0 +853 172 53 0 +852 173 54 0 +851 174 55 0 +850 175 56 0 +849 176 57 0 +848 177 58 0 +847 178 59 0 +846 179 60 0 +845 180 61 0 +844 181 62 0 +843 182 63 0 +842 183 64 0 +841 184 65 0 +840 185 66 0 +839 186 67 0 +838 187 68 0 +837 188 69 0 +836 189 70 0 +835 190 71 0 +834 191 72 0 +833 192 73 0 +832 193 74 0 +831 194 75 0 +830 195 76 0 +829 196 77 0 +828 197 78 0 +827 198 79 0 +826 199 80 0 +825 200 81 0 +824 201 82 0 +823 202 83 0 +822 203 84 0 +821 204 85 0 +820 205 86 0 +819 206 87 0 +818 207 88 0 +817 208 89 0 +816 209 90 0 +815 210 91 0 +814 211 92 0 +813 212 93 0 +812 213 94 0 +811 214 95 0 +810 215 96 0 +809 216 97 0 +808 217 98 0 +807 218 99 0 +806 219 100 0 +805 220 101 0 +804 221 102 0 +803 222 103 0 +802 223 104 0 +801 224 105 0 +800 225 106 0 +799 226 107 0 +798 227 108 0 +797 228 109 0 +796 229 110 0 +795 230 111 0 +794 231 112 0 +793 232 113 0 +792 233 114 0 +791 234 115 0 +790 235 116 0 +789 236 117 0 +788 237 118 0 +787 238 0 0 +786 239 1 0 +785 240 2 0 +784 241 3 0 +783 242 4 0 +782 243 5 0 +781 244 6 0 +780 245 7 0 +779 246 8 0 +778 247 9 0 +777 248 10 0 +776 249 11 0 +775 250 12 0 +774 251 13 0 +773 252 14 0 +772 253 15 0 +771 254 16 0 +770 255 17 0 +769 256 18 0 +768 257 19 0 +767 258 20 0 +766 259 21 0 +765 260 22 0 +764 261 23 0 +763 262 24 0 +762 263 25 0 +761 264 26 0 +760 265 27 0 +759 266 28 0 +758 267 29 0 +757 268 30 0 +756 269 31 0 +755 270 32 0 +754 271 33 0 +753 272 34 0 +752 273 35 0 +751 274 36 0 +750 275 37 0 +749 276 38 0 +748 277 39 0 +747 278 40 0 +746 279 41 0 +745 280 42 0 +744 281 43 0 +743 282 44 0 +742 283 45 0 +741 284 46 0 +740 285 47 0 +739 286 48 0 +738 287 49 0 +737 288 50 0 +736 289 51 0 +735 290 52 0 +734 291 53 0 +733 292 54 0 +732 293 55 0 +731 294 56 0 +730 295 57 0 +729 296 58 0 +728 297 59 0 +727 298 60 0 +726 299 61 0 +725 300 62 0 +724 301 63 0 +723 302 64 0 +722 303 65 0 +721 304 66 0 +720 305 67 0 +719 306 68 0 +718 307 69 0 +717 308 70 0 +716 309 71 0 +715 310 72 0 +714 311 73 0 +713 312 74 0 +712 313 75 0 +711 314 76 0 +710 315 77 0 +709 316 78 0 +708 317 79 0 +707 318 80 0 +706 319 81 0 +705 320 82 0 +704 321 83 0 +703 322 84 0 +702 323 85 0 +701 324 86 0 +700 325 87 0 +699 326 88 0 +698 327 89 0 +697 328 90 0 +696 329 91 0 +695 330 92 0 +694 331 93 0 +693 332 94 0 +692 333 95 0 +691 334 96 0 +690 335 97 0 +689 336 98 0 +688 337 99 0 +687 338 100 0 +686 339 101 0 +685 340 102 0 +684 341 103 0 +683 342 104 0 +682 343 105 0 +681 344 106 0 +680 345 107 0 +679 346 108 0 +678 347 109 0 +677 348 110 0 +676 349 111 0 +675 350 112 0 +674 351 113 0 +673 352 114 0 +672 353 115 0 +671 354 116 0 +670 355 117 0 +669 356 118 0 +668 357 0 0 +667 358 1 0 +666 359 2 0 +665 360 3 0 +664 361 4 0 +663 362 5 0 +662 363 6 0 +661 364 7 0 +660 365 8 0 +659 366 9 0 +658 367 10 0 +657 368 11 0 +656 369 12 0 +655 370 13 0 +654 371 14 0 +653 372 15 0 +652 373 16 0 +651 374 17 0 +650 375 18 0 +649 376 19 0 +648 377 20 0 +647 378 21 0 +646 379 22 0 +645 380 23 0 +644 381 24 0 +643 382 25 0 +642 383 26 0 +641 384 27 0 +640 385 28 0 +639 386 29 0 +638 387 30 0 +637 388 31 0 +636 389 32 0 +635 390 33 0 +634 391 34 0 +633 392 35 0 +632 393 36 0 +631 394 37 0 +630 395 38 0 +629 396 39 0 +628 397 40 0 +627 398 41 0 +626 399 42 0 +625 400 43 0 +624 401 44 0 +623 402 45 0 +622 403 46 0 +621 404 47 0 +620 405 48 0 +619 406 49 0 +618 407 50 0 +617 408 51 0 +616 409 52 0 +615 410 53 0 +614 411 54 0 +613 412 55 0 +612 413 56 0 +611 414 57 0 +610 415 58 0 +609 416 59 0 +608 417 60 0 +607 418 61 0 +606 419 62 0 +605 420 63 0 +604 421 64 0 +603 422 65 0 +602 423 66 0 +601 424 67 0 +600 425 68 0 +599 426 69 0 +598 427 70 0 +597 428 71 0 +596 429 72 0 +595 430 73 0 +594 431 74 0 +593 432 75 0 +592 433 76 0 +591 434 77 0 +590 435 78 0 +589 436 79 0 +588 437 80 0 +587 438 81 0 +586 439 82 0 +585 440 83 0 +584 441 84 0 +583 442 85 0 +582 443 86 0 +581 444 87 0 +580 445 88 0 +579 446 89 0 +578 447 90 0 +577 448 91 0 +576 449 92 0 +575 450 93 0 +574 451 94 0 +573 452 95 0 +572 453 96 0 +571 454 97 0 +570 455 98 0 +569 456 99 0 +568 457 100 0 +567 458 101 0 +566 459 102 0 +565 460 103 0 +564 461 104 0 +563 462 105 0 +562 463 106 0 +561 464 107 0 +560 465 108 0 +559 466 109 0 +558 467 110 0 +557 468 111 0 +556 469 112 0 +555 470 113 0 +554 471 114 0 +553 472 115 0 +552 473 116 0 +551 474 117 0 +550 475 118 0 +549 476 0 0 +548 477 1 0 +547 478 2 0 +546 479 3 0 +545 480 4 0 +544 481 5 0 +543 482 6 0 +542 483 7 0 +541 484 8 0 +540 485 9 0 +539 486 10 0 +538 487 11 0 +537 488 12 0 +536 489 13 0 +535 490 14 0 +534 491 15 0 +533 492 16 0 +532 493 17 0 +531 494 18 0 +530 495 19 0 +529 496 20 0 +528 497 21 0 +527 498 22 0 +526 499 23 0 +525 500 24 0 +524 501 25 0 +523 502 26 0 +522 503 27 0 +521 504 28 0 +520 505 29 0 +519 506 30 0 +518 507 31 0 +517 508 32 0 +516 509 33 0 +515 510 34 0 +514 0 35 0 +513 1 36 0 +512 2 37 0 +511 3 38 0 +510 4 39 0 +509 5 40 0 +508 6 41 0 +507 7 42 0 +506 8 43 0 +505 9 44 0 +504 10 45 0 +503 11 46 0 +502 12 47 0 +501 13 48 0 +500 14 49 0 +499 15 50 0 +498 16 51 0 +497 17 52 0 +496 18 53 0 +495 19 54 0 +494 20 55 0 +493 21 56 0 +492 22 57 0 +491 23 58 0 +490 24 59 0 +489 25 60 0 +488 26 61 0 +487 27 62 0 +486 28 63 0 +485 29 64 0 +484 30 65 0 +483 31 66 0 +482 32 67 0 +481 33 68 0 +480 34 69 0 +479 35 70 0 +478 36 71 0 +477 37 72 0 +476 38 73 0 +475 39 74 0 +474 40 75 0 +473 41 76 0 +472 42 77 0 +471 43 78 0 +470 44 79 0 +469 45 80 0 +468 46 81 0 +467 47 82 0 +466 48 83 0 +465 49 84 0 +464 50 85 0 +463 51 86 0 +462 52 87 0 +461 53 88 0 +460 54 89 0 +459 55 90 0 +458 56 91 0 +457 57 92 0 +456 58 93 0 +455 59 94 0 +454 60 95 0 +453 61 96 0 +452 62 97 0 +451 63 98 0 +450 64 99 0 +449 65 100 0 +448 66 101 0 +447 67 102 0 +446 68 103 0 +445 69 104 0 +444 70 105 0 +443 71 106 0 +442 72 107 0 +441 73 108 0 +440 74 109 0 +439 75 110 0 +438 76 111 0 +437 77 112 0 +436 78 113 0 +435 79 114 0 +434 80 115 0 +433 81 116 0 +432 82 117 0 +431 83 118 0 +430 84 0 0 +429 85 1 0 +428 86 2 0 +427 87 3 0 +426 88 4 0 +425 89 5 0 +424 90 6 0 +423 91 7 0 +422 92 8 0 +421 93 9 0 +420 94 10 0 +419 95 11 0 +418 96 12 0 +417 97 13 0 +416 98 14 0 +415 99 15 0 +414 100 16 0 +413 101 17 0 +412 102 18 0 +411 103 19 0 +410 104 20 0 +409 105 21 0 +408 106 22 0 +407 107 23 0 +406 108 24 0 +405 109 25 0 +404 110 26 0 +403 111 27 0 +402 112 28 0 +401 113 29 0 +400 114 30 0 +399 115 31 0 +398 116 32 0 +397 117 33 0 +396 118 34 0 +395 119 35 0 +394 120 36 0 +393 121 37 0 +392 122 38 0 +391 123 39 0 +390 124 40 0 +389 125 41 0 +388 126 42 0 +387 127 43 0 +386 128 44 0 +385 129 45 0 +384 130 46 0 +383 131 47 0 +382 132 48 0 +381 133 49 0 +380 134 50 0 +379 135 51 0 +378 136 52 0 +377 137 53 0 +376 138 54 0 +375 139 55 0 +374 140 56 0 +373 141 57 0 +372 142 58 0 +371 143 59 0 +370 144 60 0 +369 145 61 0 +368 146 62 0 +367 147 63 0 +366 148 64 0 +365 149 65 0 +364 150 66 0 +363 151 67 0 +362 152 68 0 +361 153 69 0 +360 154 70 0 +359 155 71 0 +358 156 72 0 +357 157 73 0 +356 158 74 0 +355 159 75 0 +354 160 76 0 +353 161 77 0 +352 162 78 0 +351 163 79 0 +350 164 80 0 +349 165 81 0 +348 166 82 0 +347 167 83 0 +346 168 84 0 +345 169 85 0 +344 170 86 0 +343 171 87 0 +342 172 88 0 +341 173 89 0 +340 174 90 0 +339 175 91 0 +338 176 92 0 +337 177 93 0 +336 178 94 0 +335 179 95 0 +334 180 96 0 +333 181 97 0 +332 182 98 0 +331 183 99 0 +330 184 100 0 +329 185 101 0 +328 186 102 0 +327 187 103 0 +326 188 104 0 +325 189 105 0 +324 190 106 0 +323 191 107 0 +322 192 108 0 +321 193 109 0 +320 194 110 0 +319 195 111 0 +318 196 112 0 +317 197 113 0 +316 198 114 0 +315 199 115 0 +314 200 116 0 +313 201 117 0 +312 202 118 0 +311 203 0 0 +310 204 1 0 +309 205 2 0 +308 206 3 0 +307 207 4 0 +306 208 5 0 +305 209 6 0 +304 210 7 0 +303 211 8 0 +302 212 9 0 +301 213 10 0 +300 214 11 0 +299 215 12 0 +298 216 13 0 +297 217 14 0 +296 218 15 0 +295 219 16 0 +294 220 17 0 +293 221 18 0 +292 222 19 0 +291 223 20 0 +290 224 21 0 +289 225 22 0 +288 226 23 0 +287 227 24 0 +286 228 25 0 +285 229 26 0 +284 230 27 0 +283 231 28 0 +282 232 29 0 +281 233 30 0 +280 234 31 0 +279 235 32 0 +278 236 33 0 +277 237 34 0 +276 238 35 0 +275 239 36 0 +274 240 37 0 +273 241 38 0 +272 242 39 0 +271 243 40 0 +270 244 41 0 +269 245 42 0 +268 246 43 0 +267 247 44 0 +266 248 45 0 +265 249 46 0 +264 250 47 0 +263 251 48 0 +262 252 49 0 +261 253 50 0 +260 254 51 0 +259 255 52 0 +258 256 53 0 +257 257 54 0 +256 258 55 0 +255 259 56 0 +254 260 57 0 +253 261 58 0 +252 262 59 0 +251 263 60 0 +250 264 61 0 +249 265 62 0 +248 266 63 0 +247 267 64 0 +246 268 65 0 +245 269 66 0 +244 270 67 0 +243 271 68 0 +242 272 69 0 +241 273 70 0 +240 274 71 0 +239 275 72 0 +238 276 73 0 +237 277 74 0 +236 278 75 0 +235 279 76 0 +234 280 77 0 +233 281 78 0 +232 282 79 0 +231 283 80 0 +230 284 81 0 +229 285 82 0 +228 286 83 0 +227 287 84 0 +226 288 85 0 +225 289 86 0 +224 290 87 0 +223 291 88 0 +222 292 89 0 +221 293 90 0 +220 294 91 0 +219 295 92 0 +218 296 93 0 +217 297 94 0 +216 298 95 0 +215 299 96 0 +214 300 97 0 +213 301 98 0 +212 302 99 0 +211 303 100 0 +210 304 101 0 +209 305 102 0 +208 306 103 0 +207 307 104 0 +206 308 105 0 +205 309 106 0 +204 310 107 0 +203 311 108 0 +202 312 109 0 +201 313 110 0 +200 314 111 0 +199 315 112 0 +198 316 113 0 +197 317 114 0 +196 318 115 0 +195 319 116 0 +194 320 117 0 +193 321 118 0 +192 322 0 0 +191 323 1 0 +190 324 2 0 +189 325 3 0 +188 326 4 0 +187 327 5 0 +186 328 6 0 +185 329 7 0 +184 330 8 0 +183 331 9 0 +182 332 10 0 +181 333 11 0 +180 334 12 0 +179 335 13 0 +178 336 14 0 +177 337 15 0 +176 338 16 0 +175 339 17 0 +174 340 18 0 +173 341 19 0 +172 342 20 0 +171 343 21 0 +170 344 22 0 +169 345 23 0 +168 346 24 0 +167 347 25 0 +166 348 26 0 +165 349 27 0 +164 350 28 0 +163 351 29 0 +162 352 30 0 +161 353 31 0 +160 354 32 0 +159 355 33 0 +158 356 34 0 +157 357 35 0 +156 358 36 0 +155 359 37 0 +154 360 38 0 +153 361 39 0 +152 362 40 0 +151 363 41 0 +150 364 42 0 +149 365 43 0 +148 366 44 0 +147 367 45 0 +146 368 46 0 +145 369 47 0 +144 370 48 0 +143 371 49 0 +142 372 50 0 +141 373 51 0 +140 374 52 0 +139 375 53 0 +138 376 54 0 +137 377 55 0 +136 378 56 0 +135 379 57 0 +134 380 58 0 +133 381 59 0 +132 382 60 0 +131 383 61 0 +130 384 62 0 +129 385 63 0 +128 386 64 0 +127 387 65 0 +126 388 66 0 +125 389 67 0 +124 390 68 0 +123 391 69 0 +122 392 70 0 +121 393 71 0 +120 394 72 0 +119 395 73 0 +118 396 74 0 +117 397 75 0 +116 398 76 0 +115 399 77 0 +114 400 78 0 +113 401 79 0 +112 402 80 0 +111 403 81 0 +110 404 82 0 +109 405 83 0 +108 406 84 0 +107 407 85 0 +106 408 86 0 +105 409 87 0 +104 410 88 0 +103 411 89 0 +102 412 90 0 +101 413 91 0 +100 414 92 0 +99 415 93 0 +98 416 94 0 +97 417 95 0 +96 418 96 0 +95 419 97 0 +94 420 98 0 +93 421 99 0 +92 422 100 0 +91 423 101 0 +90 424 102 0 +89 425 103 0 +88 426 104 0 +87 427 105 0 +86 428 106 0 +85 429 107 0 +84 430 108 0 +83 431 109 0 +82 432 110 0 +81 433 111 0 +80 434 112 0 +79 435 113 0 +78 436 114 0 +77 437 115 0 +76 438 116 0 +75 439 117 0 +74 440 118 0 +73 441 0 0 +72 442 1 0 +71 443 2 0 +70 444 3 0 +69 445 4 0 +68 446 5 0 +67 447 6 0 +66 448 7 0 +65 449 8 0 +64 450 9 0 +63 451 10 0 +62 452 11 0 +61 453 12 0 +60 454 13 0 +59 455 14 0 +58 456 15 0 +57 457 16 0 +56 458 17 0 +55 459 18 0 +54 460 19 0 +53 461 20 0 +52 462 21 0 +51 463 22 0 +50 464 23 0 +49 465 24 0 +48 466 25 0 +47 467 26 0 +46 468 27 0 +45 469 28 0 +44 470 29 0 +43 471 30 0 +42 472 31 0 +41 473 32 0 +40 474 33 0 +39 475 34 0 +38 476 35 0 +37 477 36 0 +36 478 37 0 +35 479 38 0 +34 480 39 0 +33 481 40 0 +32 482 41 0 +31 483 42 0 +30 484 43 0 +29 485 44 0 +28 486 45 0 +27 487 46 0 +26 488 47 0 +25 489 48 0 +24 490 49 0 +23 491 50 0 +22 492 51 0 +21 493 52 0 +20 494 53 0 +19 495 54 0 +18 496 55 0 +17 497 56 0 +16 498 57 0 +15 499 58 0 +14 500 59 0 +13 501 60 0 +12 502 61 0 +11 503 62 0 +10 504 63 0 +9 505 64 0 +8 506 65 0 +7 507 66 0 +6 508 67 0 +5 509 68 0 +4 510 69 0 +3 0 70 0 +2 1 71 0 +1 2 72 0 +SELECT * FROM t1 ORDER BY f0, f1 limit 100, 20; +f0 f1 f2 +101 413 91 0 +102 412 90 0 +103 411 89 0 +104 410 88 0 +105 409 87 0 +106 408 86 0 +107 407 85 0 +108 406 84 0 +109 405 83 0 +110 404 82 0 +111 403 81 0 +112 402 80 0 +113 401 79 0 +114 400 78 0 +115 399 77 0 +116 398 76 0 +117 397 75 0 +118 396 74 0 +119 395 73 0 +120 394 72 0 +SELECT * FROM t1 ORDER BY f0, f1 desc limit 100, 25; +f0 f1 f2 +101 413 91 0 +102 412 90 0 +103 411 89 0 +104 410 88 0 +105 409 87 0 +106 408 86 0 +107 407 85 0 +108 406 84 0 +109 405 83 0 +110 404 82 0 +111 403 81 0 +112 402 80 0 +113 401 79 0 +114 400 78 0 +115 399 77 0 +116 398 76 0 +117 397 75 0 +118 396 74 0 +119 395 73 0 +120 394 72 0 +121 393 71 0 +122 392 70 0 +123 391 69 0 +124 390 68 0 +125 389 67 0 +DROP TABLE t1; +CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, +UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)) charset utf8mb4; +Warnings: +Warning 1681 Integer display width is deprecated and will be removed in a future release. +SELECT * FROM t2 ORDER BY a, b, c; +a b c d +all 1 10000 0 +all 2 10000 0 +all 32 10000 23.2342007434944 +domestic 3 100 59 +domestic 4 500 0 +domestic 5 500 0 +domestic 6 500 0 +domestic 7 500 0 +domestic 8 500 0 +domestic 9 10000 0 +domestic 17 2 7.2 +domestic 17 5 8.43 +domestic 17 10 11.15 +domestic 17 20 15.83 +domestic 17 30 22.02 +domestic 18 2 8.2 +domestic 18 5 9.43 +domestic 18 10 12.15 +domestic 18 20 16.83 +domestic 18 30 23.02 +domestic 19 2 6.3 +domestic 19 5 7.77 +domestic 19 10 10.3 +domestic 19 20 14.83 +domestic 19 30 20.88 +domestic 20 2 7.3 +domestic 20 5 8.77 +domestic 20 10 11.3 +domestic 20 20 15.83 +domestic 20 30 21.88 +domestic 21 3.9 10.8 +domestic 21 4.9 12.2 +domestic 21 9.9 15.3 +domestic 21 19.9 20.6 +domestic 21 30 28.1 +domestic 23 2 18.8 +domestic 23 5 20.8 +domestic 23 10 24.8 +domestic 23 20 27.8 +domestic 23 30 30.8 +domestic 24 2 21.1405 +domestic 24 5 22.3705 +domestic 24 10 25.0905 +domestic 24 20 29.7705 +domestic 24 30 35.9605 +domestic 26 0.25 4.7 +domestic 27 0.25 6 +domestic 28 2 17 +domestic 28 5 19 +domestic 28 10 22 +domestic 28 20 28 +domestic 28 30 35 +domestic 29 30 29.5 +foreign 10 30 0 +foreign 11 30 0 +foreign 12 30 0 +foreign 13 30 0 +foreign 22 0 0 +foreign 25 200 0 +plfcz1 16 0.5 19 +plfcz2 16 0.5 25 +ppfcz1 14 2 37.5 +ppfcz1 14 3 41.5 +ppfcz1 14 4 45.5 +ppfcz1 14 5 48.5 +ppfcz1 14 6 52.5 +ppfcz1 14 7 55.5 +ppfcz1 14 8 57.5 +ppfcz1 14 9 59.5 +ppfcz1 14 10 61.5 +ppfcz1 14 11 62.5 +ppfcz1 14 12 63.5 +ppfcz1 14 13 64.5 +ppfcz1 14 14 65.5 +ppfcz1 14 15 66.5 +ppfcz1 14 16 67.5 +ppfcz1 14 17 68.5 +ppfcz1 14 18 69.5 +ppfcz1 14 19 70.5 +ppfcz1 14 20 71.5 +ppfcz1 14 21 72.5 +ppfcz1 14 22 73.5 +ppfcz1 14 23 74.5 +ppfcz1 14 24 75.5 +ppfcz1 14 25 76.5 +ppfcz1 14 26 77.5 +ppfcz1 14 27 78.5 +ppfcz1 14 28 79.5 +ppfcz1 14 29 80.5 +ppfcz1 14 30 81.5 +ppfcz1 15 2 33.5 +ppfcz1 15 3 36.5 +ppfcz1 15 4 39.5 +ppfcz1 15 5 41.5 +ppfcz1 15 6 42.5 +ppfcz1 15 7 43.5 +ppfcz1 15 8 44.5 +ppfcz1 15 9 45.5 +ppfcz1 15 10 46.5 +ppfcz1 15 11 47.5 +ppfcz1 15 12 48.5 +ppfcz1 15 13 49.5 +ppfcz1 15 14 50.5 +ppfcz1 15 15 51.5 +ppfcz1 15 16 52.5 +ppfcz1 15 17 53.5 +ppfcz1 15 18 54.5 +ppfcz1 15 19 55.5 +ppfcz1 15 20 56.5 +ppfcz1 15 21 57.5 +ppfcz1 15 22 58.5 +ppfcz1 15 23 59.5 +ppfcz1 15 24 60.5 +ppfcz1 15 25 61.5 +ppfcz1 15 26 62.5 +ppfcz1 15 27 63.5 +ppfcz1 15 28 64.5 +ppfcz1 15 29 65.5 +ppfcz1 15 30 66.5 +ppfcz1 30 0.5 56.5 +ppfcz1 30 1 63.5 +ppfcz1 30 1.5 69.5 +ppfcz1 30 2 75.5 +ppfcz1 30 2.5 80.5 +ppfcz1 30 3 86.5 +ppfcz1 30 3.5 92.5 +ppfcz1 30 4 99.5 +ppfcz1 30 4.5 105.5 +ppfcz1 30 5 111.5 +ppfcz1 30 6 118.5 +ppfcz1 30 7 126.5 +ppfcz1 30 8 133.5 +ppfcz1 30 9 141.5 +ppfcz1 30 10 148.5 +ppfcz1 30 11 156.5 +ppfcz1 30 12 163.5 +ppfcz1 30 13 171.5 +ppfcz1 30 14 178.5 +ppfcz1 30 15 186.5 +ppfcz1 30 16 193.5 +ppfcz1 30 17 201.5 +ppfcz1 30 18 209.5 +ppfcz1 30 19 216.5 +ppfcz1 30 20 224.5 +ppfcz1 30 21 231.5 +ppfcz1 30 22 239.5 +ppfcz1 30 23 246.5 +ppfcz1 30 24 254.5 +ppfcz1 30 25 261.5 +ppfcz1 30 26 269.5 +ppfcz1 30 27 276.5 +ppfcz1 30 28 284.5 +ppfcz1 30 29 291.5 +ppfcz1 30 30 299.5 +ppfcz2 14 2 43.5 +ppfcz2 14 3 48.5 +ppfcz2 14 4 53.5 +ppfcz2 14 5 57.5 +ppfcz2 14 6 61.5 +ppfcz2 14 7 65.5 +ppfcz2 14 8 69.5 +ppfcz2 14 9 73.5 +ppfcz2 14 10 77.5 +ppfcz2 14 11 80.5 +ppfcz2 14 12 83.5 +ppfcz2 14 13 86.5 +ppfcz2 14 14 89.5 +ppfcz2 14 15 92.5 +ppfcz2 14 16 94.5 +ppfcz2 14 17 96.5 +ppfcz2 14 18 98.5 +ppfcz2 14 19 99.5 +ppfcz2 14 20 100.5 +ppfcz2 14 21 101.5 +ppfcz2 14 22 102.5 +ppfcz2 14 23 103.5 +ppfcz2 14 24 104.5 +ppfcz2 14 25 105.5 +ppfcz2 14 26 106.5 +ppfcz2 14 27 107.5 +ppfcz2 14 28 108.5 +ppfcz2 14 29 109.5 +ppfcz2 14 30 110.5 +ppfcz2 15 2 38.5 +ppfcz2 15 3 42.5 +ppfcz2 15 4 46.5 +ppfcz2 15 5 50.5 +ppfcz2 15 6 53.5 +ppfcz2 15 7 56.5 +ppfcz2 15 8 59.5 +ppfcz2 15 9 62.5 +ppfcz2 15 10 65.5 +ppfcz2 15 11 67.5 +ppfcz2 15 12 69.5 +ppfcz2 15 13 71.5 +ppfcz2 15 14 73.5 +ppfcz2 15 15 75.5 +ppfcz2 15 16 76.5 +ppfcz2 15 17 77.5 +ppfcz2 15 18 78.5 +ppfcz2 15 19 79.5 +ppfcz2 15 20 80.5 +ppfcz2 15 21 81.5 +ppfcz2 15 22 82.5 +ppfcz2 15 23 83.5 +ppfcz2 15 24 84.5 +ppfcz2 15 25 85.5 +ppfcz2 15 26 86.5 +ppfcz2 15 27 87.5 +ppfcz2 15 28 88.5 +ppfcz2 15 29 89.5 +ppfcz2 15 30 90.5 +ppfcz2 30 0.5 61.5 +ppfcz2 30 1 65.5 +ppfcz2 30 1.5 75.5 +ppfcz2 30 2 80.5 +ppfcz2 30 2.5 86.5 +ppfcz2 30 3 99.5 +ppfcz2 30 3.5 109.5 +ppfcz2 30 4 113.5 +ppfcz2 30 4.5 121.5 +ppfcz2 30 5 129.5 +ppfcz2 30 6 139.5 +ppfcz2 30 7 149.5 +ppfcz2 30 8 159.5 +ppfcz2 30 9 169.5 +ppfcz2 30 10 180.5 +ppfcz2 30 11 189.5 +ppfcz2 30 12 199.5 +ppfcz2 30 13 210.5 +ppfcz2 30 14 219.5 +ppfcz2 30 15 229.5 +ppfcz2 30 16 240.5 +ppfcz2 30 17 249.5 +ppfcz2 30 18 259.5 +ppfcz2 30 19 270.5 +ppfcz2 30 20 280.5 +ppfcz2 30 21 289.5 +ppfcz2 30 22 300.5 +ppfcz2 30 23 310.5 +ppfcz2 30 24 320.5 +ppfcz2 30 25 330.5 +ppfcz2 30 26 340.5 +ppfcz2 30 27 350.5 +ppfcz2 30 28 360.5 +ppfcz2 30 29 370.5 +ppfcz2 30 30 381.5 +ppfcz3 14 2 47.5 +ppfcz3 14 3 56.5 +ppfcz3 14 4 67.5 +ppfcz3 14 5 78.5 +ppfcz3 14 6 87.5 +ppfcz3 14 7 96.5 +ppfcz3 14 8 105.5 +ppfcz3 14 9 114.5 +ppfcz3 14 10 123.5 +ppfcz3 14 11 131.5 +ppfcz3 14 12 139.5 +ppfcz3 14 13 147.5 +ppfcz3 14 14 155.5 +ppfcz3 14 15 163.5 +ppfcz3 14 16 171.5 +ppfcz3 14 17 179.5 +ppfcz3 14 18 187.5 +ppfcz3 14 19 195.5 +ppfcz3 14 20 203.5 +ppfcz3 14 21 210.5 +ppfcz3 14 22 217.5 +ppfcz3 14 23 224.5 +ppfcz3 14 24 231.5 +ppfcz3 14 25 238.5 +ppfcz3 14 26 245.5 +ppfcz3 14 27 252.5 +ppfcz3 14 28 259.5 +ppfcz3 14 29 266.5 +ppfcz3 14 30 273.5 +ppfcz3 15 2 39.5 +ppfcz3 15 3 45.5 +ppfcz3 15 4 51.5 +ppfcz3 15 5 57.5 +ppfcz3 15 6 63.5 +ppfcz3 15 7 69.5 +ppfcz3 15 8 75.5 +ppfcz3 15 9 81.5 +ppfcz3 15 10 87.5 +ppfcz3 15 11 93.5 +ppfcz3 15 12 99.5 +ppfcz3 15 13 105.5 +ppfcz3 15 14 111.5 +ppfcz3 15 15 117.5 +ppfcz3 15 16 122.5 +ppfcz3 15 17 127.5 +ppfcz3 15 18 132.5 +ppfcz3 15 19 137.5 +ppfcz3 15 20 142.5 +ppfcz3 15 21 146.5 +ppfcz3 15 22 150.5 +ppfcz3 15 23 154.5 +ppfcz3 15 24 158.5 +ppfcz3 15 25 162.5 +ppfcz3 15 26 166.5 +ppfcz3 15 27 170.5 +ppfcz3 15 28 174.5 +ppfcz3 15 29 178.5 +ppfcz3 15 30 182.5 +ppfcz3 30 0.5 74.5 +ppfcz3 30 1 83.5 +ppfcz3 30 1.5 90.5 +ppfcz3 30 2 99.5 +ppfcz3 30 2.5 107.5 +ppfcz3 30 3 114.5 +ppfcz3 30 3.5 122.5 +ppfcz3 30 4 130.5 +ppfcz3 30 4.5 140.5 +ppfcz3 30 5 147.5 +ppfcz3 30 6 162.5 +ppfcz3 30 7 174.5 +ppfcz3 30 8 188.5 +ppfcz3 30 9 201.5 +ppfcz3 30 10 213.5 +ppfcz3 30 11 227.5 +ppfcz3 30 12 240.5 +ppfcz3 30 13 252.5 +ppfcz3 30 14 266.5 +ppfcz3 30 15 278.5 +ppfcz3 30 16 290.5 +ppfcz3 30 17 304.5 +ppfcz3 30 18 317.5 +ppfcz3 30 19 330.5 +ppfcz3 30 20 343.5 +ppfcz3 30 21 354.5 +ppfcz3 30 22 363.5 +ppfcz3 30 23 375.5 +ppfcz3 30 24 385.5 +ppfcz3 30 25 396.5 +ppfcz3 30 26 405.5 +ppfcz3 30 27 417.5 +ppfcz3 30 28 428.5 +ppfcz3 30 29 438.5 +ppfcz3 30 30 448.5 +ppfcz4 14 2 54.5 +ppfcz4 14 3 68.5 +ppfcz4 14 4 81.5 +ppfcz4 14 5 95.5 +ppfcz4 14 6 108.5 +ppfcz4 14 7 121.5 +ppfcz4 14 8 134.5 +ppfcz4 14 9 147.5 +ppfcz4 14 10 160.5 +ppfcz4 14 11 168.5 +ppfcz4 14 12 178.5 +ppfcz4 14 13 188.5 +ppfcz4 14 14 198.5 +ppfcz4 14 15 208.5 +ppfcz4 14 16 216.5 +ppfcz4 14 17 224.5 +ppfcz4 14 18 232.5 +ppfcz4 14 19 240.5 +ppfcz4 14 20 248.5 +ppfcz4 14 21 256.5 +ppfcz4 14 22 264.5 +ppfcz4 14 23 272.5 +ppfcz4 14 24 280.5 +ppfcz4 14 25 288.5 +ppfcz4 14 26 296.5 +ppfcz4 14 27 304.5 +ppfcz4 14 28 312.5 +ppfcz4 14 29 320.5 +ppfcz4 14 30 328.5 +ppfcz4 15 2 44.5 +ppfcz4 15 3 51.5 +ppfcz4 15 4 58.5 +ppfcz4 15 5 65.5 +ppfcz4 15 6 72.5 +ppfcz4 15 7 79.5 +ppfcz4 15 8 86.5 +ppfcz4 15 9 93.5 +ppfcz4 15 10 100.5 +ppfcz4 15 11 105.5 +ppfcz4 15 12 110.5 +ppfcz4 15 13 115.5 +ppfcz4 15 14 120.5 +ppfcz4 15 15 125.5 +ppfcz4 15 16 130.5 +ppfcz4 15 17 135.5 +ppfcz4 15 18 140.5 +ppfcz4 15 19 145.5 +ppfcz4 15 20 150.5 +ppfcz4 15 21 154.5 +ppfcz4 15 22 158.5 +ppfcz4 15 23 162.5 +ppfcz4 15 24 166.5 +ppfcz4 15 25 170.5 +ppfcz4 15 26 174.5 +ppfcz4 15 27 178.5 +ppfcz4 15 28 182.5 +ppfcz4 15 29 186.5 +ppfcz4 15 30 190.5 +ppfcz4 30 0.5 90.5 +ppfcz4 30 1 104.5 +ppfcz4 30 1.5 118.5 +ppfcz4 30 2 134.5 +ppfcz4 30 2.5 146.5 +ppfcz4 30 3 163.5 +ppfcz4 30 3.5 179.5 +ppfcz4 30 4 195.5 +ppfcz4 30 4.5 211.5 +ppfcz4 30 5 232.5 +ppfcz4 30 6 257.5 +ppfcz4 30 7 278.5 +ppfcz4 30 8 300.5 +ppfcz4 30 9 321.5 +ppfcz4 30 10 343.5 +ppfcz4 30 11 364.5 +ppfcz4 30 12 386.5 +ppfcz4 30 13 407.5 +ppfcz4 30 14 429.5 +ppfcz4 30 15 450.5 +ppfcz4 30 16 472.5 +ppfcz4 30 17 493.5 +ppfcz4 30 18 515.5 +ppfcz4 30 19 536.5 +ppfcz4 30 20 558.5 +ppfcz4 30 21 579.5 +ppfcz4 30 22 601.5 +ppfcz4 30 23 622.5 +ppfcz4 30 24 644.5 +ppfcz4 30 25 665.5 +ppfcz4 30 26 687.5 +ppfcz4 30 27 708.5 +ppfcz4 30 28 730.5 +ppfcz4 30 29 751.5 +ppfcz4 30 30 773.5 +ppfcz5 14 2 66.5 +ppfcz5 14 3 84.5 +ppfcz5 14 4 102.5 +ppfcz5 14 5 120.5 +ppfcz5 14 6 137.5 +ppfcz5 14 7 154.5 +ppfcz5 14 8 171.5 +ppfcz5 14 9 188.5 +ppfcz5 14 10 205.5 +ppfcz5 14 11 220.5 +ppfcz5 14 12 235.5 +ppfcz5 14 13 250.5 +ppfcz5 14 14 265.5 +ppfcz5 14 15 280.5 +ppfcz5 14 16 295.5 +ppfcz5 14 17 310.5 +ppfcz5 14 18 325.5 +ppfcz5 14 19 340.5 +ppfcz5 14 20 355.5 +ppfcz5 14 21 368.5 +ppfcz5 14 22 381.5 +ppfcz5 14 23 394.5 +ppfcz5 14 24 407.5 +ppfcz5 14 25 420.5 +ppfcz5 14 26 433.5 +ppfcz5 14 27 446.5 +ppfcz5 14 28 459.5 +ppfcz5 14 29 472.5 +ppfcz5 14 30 485.5 +ppfcz5 15 2 48.5 +ppfcz5 15 3 56.5 +ppfcz5 15 4 64.5 +ppfcz5 15 5 72.5 +ppfcz5 15 6 80.5 +ppfcz5 15 7 88.5 +ppfcz5 15 8 96.5 +ppfcz5 15 9 104.5 +ppfcz5 15 10 112.5 +ppfcz5 15 11 119.5 +ppfcz5 15 12 126.5 +ppfcz5 15 13 133.5 +ppfcz5 15 14 140.5 +ppfcz5 15 15 147.5 +ppfcz5 15 16 153.5 +ppfcz5 15 17 161.5 +ppfcz5 15 18 167.5 +ppfcz5 15 19 173.5 +ppfcz5 15 20 179.5 +ppfcz5 15 21 185.5 +ppfcz5 15 22 191.5 +ppfcz5 15 23 197.5 +ppfcz5 15 24 203.5 +ppfcz5 15 25 207.5 +ppfcz5 15 26 212.5 +ppfcz5 15 27 217.5 +ppfcz5 15 28 222.5 +ppfcz5 15 29 227.5 +ppfcz5 15 30 232.5 +ppfcz5 30 0.5 97.5 +ppfcz5 30 1 114.5 +ppfcz5 30 1.5 131.5 +ppfcz5 30 2 148.5 +ppfcz5 30 2.5 165.5 +ppfcz5 30 3 183.5 +ppfcz5 30 3.5 200.5 +ppfcz5 30 4 221.5 +ppfcz5 30 4.5 243.5 +ppfcz5 30 5 264.5 +ppfcz5 30 6 289.5 +ppfcz5 30 7 313.5 +ppfcz5 30 8 336.5 +ppfcz5 30 9 360.5 +ppfcz5 30 10 384.5 +ppfcz5 30 11 407.5 +ppfcz5 30 12 431.5 +ppfcz5 30 13 455.5 +ppfcz5 30 14 478.5 +ppfcz5 30 15 502.5 +ppfcz5 30 16 526.5 +ppfcz5 30 17 549.5 +ppfcz5 30 18 573.5 +ppfcz5 30 19 597.5 +ppfcz5 30 20 620.5 +ppfcz5 30 21 644.5 +ppfcz5 30 22 668.5 +ppfcz5 30 23 691.5 +ppfcz5 30 24 715.5 +ppfcz5 30 25 738.5 +ppfcz5 30 26 762.5 +ppfcz5 30 27 786.5 +ppfcz5 30 28 809.5 +ppfcz5 30 29 833.5 +ppfcz5 30 30 857.5 +SELECT * FROM t2 ORDER BY a, b, c limit 10; +a b c d +all 1 10000 0 +all 2 10000 0 +all 32 10000 23.2342007434944 +domestic 3 100 59 +domestic 4 500 0 +domestic 5 500 0 +domestic 6 500 0 +domestic 7 500 0 +domestic 8 500 0 +domestic 9 10000 0 +SELECT * FROM t2 ORDER BY a, b, c limit 1000, 20; +a b c d +SELECT * FROM t2 ORDER BY a, b, d limit 200, 20; +a b c d +ppfcz2 15 19 79.5 +ppfcz2 15 20 80.5 +ppfcz2 15 21 81.5 +ppfcz2 15 22 82.5 +ppfcz2 15 23 83.5 +ppfcz2 15 24 84.5 +ppfcz2 15 25 85.5 +ppfcz2 15 26 86.5 +ppfcz2 15 27 87.5 +ppfcz2 15 28 88.5 +ppfcz2 15 29 89.5 +ppfcz2 15 30 90.5 +ppfcz2 30 0.5 61.5 +ppfcz2 30 1 65.5 +ppfcz2 30 1.5 75.5 +ppfcz2 30 2 80.5 +ppfcz2 30 2.5 86.5 +ppfcz2 30 3 99.5 +ppfcz2 30 3.5 109.5 +ppfcz2 30 4 113.5 +SELECT * FROM t2 ORDER BY a asc, b asc, c desc; +a b c d +all 1 10000 0 +all 2 10000 0 +all 32 10000 23.2342007434944 +domestic 3 100 59 +domestic 4 500 0 +domestic 5 500 0 +domestic 6 500 0 +domestic 7 500 0 +domestic 8 500 0 +domestic 9 10000 0 +domestic 17 30 22.02 +domestic 17 20 15.83 +domestic 17 10 11.15 +domestic 17 5 8.43 +domestic 17 2 7.2 +domestic 18 30 23.02 +domestic 18 20 16.83 +domestic 18 10 12.15 +domestic 18 5 9.43 +domestic 18 2 8.2 +domestic 19 30 20.88 +domestic 19 20 14.83 +domestic 19 10 10.3 +domestic 19 5 7.77 +domestic 19 2 6.3 +domestic 20 30 21.88 +domestic 20 20 15.83 +domestic 20 10 11.3 +domestic 20 5 8.77 +domestic 20 2 7.3 +domestic 21 30 28.1 +domestic 21 19.9 20.6 +domestic 21 9.9 15.3 +domestic 21 4.9 12.2 +domestic 21 3.9 10.8 +domestic 23 30 30.8 +domestic 23 20 27.8 +domestic 23 10 24.8 +domestic 23 5 20.8 +domestic 23 2 18.8 +domestic 24 30 35.9605 +domestic 24 20 29.7705 +domestic 24 10 25.0905 +domestic 24 5 22.3705 +domestic 24 2 21.1405 +domestic 26 0.25 4.7 +domestic 27 0.25 6 +domestic 28 30 35 +domestic 28 20 28 +domestic 28 10 22 +domestic 28 5 19 +domestic 28 2 17 +domestic 29 30 29.5 +foreign 10 30 0 +foreign 11 30 0 +foreign 12 30 0 +foreign 13 30 0 +foreign 22 0 0 +foreign 25 200 0 +plfcz1 16 0.5 19 +plfcz2 16 0.5 25 +ppfcz1 14 30 81.5 +ppfcz1 14 29 80.5 +ppfcz1 14 28 79.5 +ppfcz1 14 27 78.5 +ppfcz1 14 26 77.5 +ppfcz1 14 25 76.5 +ppfcz1 14 24 75.5 +ppfcz1 14 23 74.5 +ppfcz1 14 22 73.5 +ppfcz1 14 21 72.5 +ppfcz1 14 20 71.5 +ppfcz1 14 19 70.5 +ppfcz1 14 18 69.5 +ppfcz1 14 17 68.5 +ppfcz1 14 16 67.5 +ppfcz1 14 15 66.5 +ppfcz1 14 14 65.5 +ppfcz1 14 13 64.5 +ppfcz1 14 12 63.5 +ppfcz1 14 11 62.5 +ppfcz1 14 10 61.5 +ppfcz1 14 9 59.5 +ppfcz1 14 8 57.5 +ppfcz1 14 7 55.5 +ppfcz1 14 6 52.5 +ppfcz1 14 5 48.5 +ppfcz1 14 4 45.5 +ppfcz1 14 3 41.5 +ppfcz1 14 2 37.5 +ppfcz1 15 30 66.5 +ppfcz1 15 29 65.5 +ppfcz1 15 28 64.5 +ppfcz1 15 27 63.5 +ppfcz1 15 26 62.5 +ppfcz1 15 25 61.5 +ppfcz1 15 24 60.5 +ppfcz1 15 23 59.5 +ppfcz1 15 22 58.5 +ppfcz1 15 21 57.5 +ppfcz1 15 20 56.5 +ppfcz1 15 19 55.5 +ppfcz1 15 18 54.5 +ppfcz1 15 17 53.5 +ppfcz1 15 16 52.5 +ppfcz1 15 15 51.5 +ppfcz1 15 14 50.5 +ppfcz1 15 13 49.5 +ppfcz1 15 12 48.5 +ppfcz1 15 11 47.5 +ppfcz1 15 10 46.5 +ppfcz1 15 9 45.5 +ppfcz1 15 8 44.5 +ppfcz1 15 7 43.5 +ppfcz1 15 6 42.5 +ppfcz1 15 5 41.5 +ppfcz1 15 4 39.5 +ppfcz1 15 3 36.5 +ppfcz1 15 2 33.5 +ppfcz1 30 30 299.5 +ppfcz1 30 29 291.5 +ppfcz1 30 28 284.5 +ppfcz1 30 27 276.5 +ppfcz1 30 26 269.5 +ppfcz1 30 25 261.5 +ppfcz1 30 24 254.5 +ppfcz1 30 23 246.5 +ppfcz1 30 22 239.5 +ppfcz1 30 21 231.5 +ppfcz1 30 20 224.5 +ppfcz1 30 19 216.5 +ppfcz1 30 18 209.5 +ppfcz1 30 17 201.5 +ppfcz1 30 16 193.5 +ppfcz1 30 15 186.5 +ppfcz1 30 14 178.5 +ppfcz1 30 13 171.5 +ppfcz1 30 12 163.5 +ppfcz1 30 11 156.5 +ppfcz1 30 10 148.5 +ppfcz1 30 9 141.5 +ppfcz1 30 8 133.5 +ppfcz1 30 7 126.5 +ppfcz1 30 6 118.5 +ppfcz1 30 5 111.5 +ppfcz1 30 4.5 105.5 +ppfcz1 30 4 99.5 +ppfcz1 30 3.5 92.5 +ppfcz1 30 3 86.5 +ppfcz1 30 2.5 80.5 +ppfcz1 30 2 75.5 +ppfcz1 30 1.5 69.5 +ppfcz1 30 1 63.5 +ppfcz1 30 0.5 56.5 +ppfcz2 14 30 110.5 +ppfcz2 14 29 109.5 +ppfcz2 14 28 108.5 +ppfcz2 14 27 107.5 +ppfcz2 14 26 106.5 +ppfcz2 14 25 105.5 +ppfcz2 14 24 104.5 +ppfcz2 14 23 103.5 +ppfcz2 14 22 102.5 +ppfcz2 14 21 101.5 +ppfcz2 14 20 100.5 +ppfcz2 14 19 99.5 +ppfcz2 14 18 98.5 +ppfcz2 14 17 96.5 +ppfcz2 14 16 94.5 +ppfcz2 14 15 92.5 +ppfcz2 14 14 89.5 +ppfcz2 14 13 86.5 +ppfcz2 14 12 83.5 +ppfcz2 14 11 80.5 +ppfcz2 14 10 77.5 +ppfcz2 14 9 73.5 +ppfcz2 14 8 69.5 +ppfcz2 14 7 65.5 +ppfcz2 14 6 61.5 +ppfcz2 14 5 57.5 +ppfcz2 14 4 53.5 +ppfcz2 14 3 48.5 +ppfcz2 14 2 43.5 +ppfcz2 15 30 90.5 +ppfcz2 15 29 89.5 +ppfcz2 15 28 88.5 +ppfcz2 15 27 87.5 +ppfcz2 15 26 86.5 +ppfcz2 15 25 85.5 +ppfcz2 15 24 84.5 +ppfcz2 15 23 83.5 +ppfcz2 15 22 82.5 +ppfcz2 15 21 81.5 +ppfcz2 15 20 80.5 +ppfcz2 15 19 79.5 +ppfcz2 15 18 78.5 +ppfcz2 15 17 77.5 +ppfcz2 15 16 76.5 +ppfcz2 15 15 75.5 +ppfcz2 15 14 73.5 +ppfcz2 15 13 71.5 +ppfcz2 15 12 69.5 +ppfcz2 15 11 67.5 +ppfcz2 15 10 65.5 +ppfcz2 15 9 62.5 +ppfcz2 15 8 59.5 +ppfcz2 15 7 56.5 +ppfcz2 15 6 53.5 +ppfcz2 15 5 50.5 +ppfcz2 15 4 46.5 +ppfcz2 15 3 42.5 +ppfcz2 15 2 38.5 +ppfcz2 30 30 381.5 +ppfcz2 30 29 370.5 +ppfcz2 30 28 360.5 +ppfcz2 30 27 350.5 +ppfcz2 30 26 340.5 +ppfcz2 30 25 330.5 +ppfcz2 30 24 320.5 +ppfcz2 30 23 310.5 +ppfcz2 30 22 300.5 +ppfcz2 30 21 289.5 +ppfcz2 30 20 280.5 +ppfcz2 30 19 270.5 +ppfcz2 30 18 259.5 +ppfcz2 30 17 249.5 +ppfcz2 30 16 240.5 +ppfcz2 30 15 229.5 +ppfcz2 30 14 219.5 +ppfcz2 30 13 210.5 +ppfcz2 30 12 199.5 +ppfcz2 30 11 189.5 +ppfcz2 30 10 180.5 +ppfcz2 30 9 169.5 +ppfcz2 30 8 159.5 +ppfcz2 30 7 149.5 +ppfcz2 30 6 139.5 +ppfcz2 30 5 129.5 +ppfcz2 30 4.5 121.5 +ppfcz2 30 4 113.5 +ppfcz2 30 3.5 109.5 +ppfcz2 30 3 99.5 +ppfcz2 30 2.5 86.5 +ppfcz2 30 2 80.5 +ppfcz2 30 1.5 75.5 +ppfcz2 30 1 65.5 +ppfcz2 30 0.5 61.5 +ppfcz3 14 30 273.5 +ppfcz3 14 29 266.5 +ppfcz3 14 28 259.5 +ppfcz3 14 27 252.5 +ppfcz3 14 26 245.5 +ppfcz3 14 25 238.5 +ppfcz3 14 24 231.5 +ppfcz3 14 23 224.5 +ppfcz3 14 22 217.5 +ppfcz3 14 21 210.5 +ppfcz3 14 20 203.5 +ppfcz3 14 19 195.5 +ppfcz3 14 18 187.5 +ppfcz3 14 17 179.5 +ppfcz3 14 16 171.5 +ppfcz3 14 15 163.5 +ppfcz3 14 14 155.5 +ppfcz3 14 13 147.5 +ppfcz3 14 12 139.5 +ppfcz3 14 11 131.5 +ppfcz3 14 10 123.5 +ppfcz3 14 9 114.5 +ppfcz3 14 8 105.5 +ppfcz3 14 7 96.5 +ppfcz3 14 6 87.5 +ppfcz3 14 5 78.5 +ppfcz3 14 4 67.5 +ppfcz3 14 3 56.5 +ppfcz3 14 2 47.5 +ppfcz3 15 30 182.5 +ppfcz3 15 29 178.5 +ppfcz3 15 28 174.5 +ppfcz3 15 27 170.5 +ppfcz3 15 26 166.5 +ppfcz3 15 25 162.5 +ppfcz3 15 24 158.5 +ppfcz3 15 23 154.5 +ppfcz3 15 22 150.5 +ppfcz3 15 21 146.5 +ppfcz3 15 20 142.5 +ppfcz3 15 19 137.5 +ppfcz3 15 18 132.5 +ppfcz3 15 17 127.5 +ppfcz3 15 16 122.5 +ppfcz3 15 15 117.5 +ppfcz3 15 14 111.5 +ppfcz3 15 13 105.5 +ppfcz3 15 12 99.5 +ppfcz3 15 11 93.5 +ppfcz3 15 10 87.5 +ppfcz3 15 9 81.5 +ppfcz3 15 8 75.5 +ppfcz3 15 7 69.5 +ppfcz3 15 6 63.5 +ppfcz3 15 5 57.5 +ppfcz3 15 4 51.5 +ppfcz3 15 3 45.5 +ppfcz3 15 2 39.5 +ppfcz3 30 30 448.5 +ppfcz3 30 29 438.5 +ppfcz3 30 28 428.5 +ppfcz3 30 27 417.5 +ppfcz3 30 26 405.5 +ppfcz3 30 25 396.5 +ppfcz3 30 24 385.5 +ppfcz3 30 23 375.5 +ppfcz3 30 22 363.5 +ppfcz3 30 21 354.5 +ppfcz3 30 20 343.5 +ppfcz3 30 19 330.5 +ppfcz3 30 18 317.5 +ppfcz3 30 17 304.5 +ppfcz3 30 16 290.5 +ppfcz3 30 15 278.5 +ppfcz3 30 14 266.5 +ppfcz3 30 13 252.5 +ppfcz3 30 12 240.5 +ppfcz3 30 11 227.5 +ppfcz3 30 10 213.5 +ppfcz3 30 9 201.5 +ppfcz3 30 8 188.5 +ppfcz3 30 7 174.5 +ppfcz3 30 6 162.5 +ppfcz3 30 5 147.5 +ppfcz3 30 4.5 140.5 +ppfcz3 30 4 130.5 +ppfcz3 30 3.5 122.5 +ppfcz3 30 3 114.5 +ppfcz3 30 2.5 107.5 +ppfcz3 30 2 99.5 +ppfcz3 30 1.5 90.5 +ppfcz3 30 1 83.5 +ppfcz3 30 0.5 74.5 +ppfcz4 14 30 328.5 +ppfcz4 14 29 320.5 +ppfcz4 14 28 312.5 +ppfcz4 14 27 304.5 +ppfcz4 14 26 296.5 +ppfcz4 14 25 288.5 +ppfcz4 14 24 280.5 +ppfcz4 14 23 272.5 +ppfcz4 14 22 264.5 +ppfcz4 14 21 256.5 +ppfcz4 14 20 248.5 +ppfcz4 14 19 240.5 +ppfcz4 14 18 232.5 +ppfcz4 14 17 224.5 +ppfcz4 14 16 216.5 +ppfcz4 14 15 208.5 +ppfcz4 14 14 198.5 +ppfcz4 14 13 188.5 +ppfcz4 14 12 178.5 +ppfcz4 14 11 168.5 +ppfcz4 14 10 160.5 +ppfcz4 14 9 147.5 +ppfcz4 14 8 134.5 +ppfcz4 14 7 121.5 +ppfcz4 14 6 108.5 +ppfcz4 14 5 95.5 +ppfcz4 14 4 81.5 +ppfcz4 14 3 68.5 +ppfcz4 14 2 54.5 +ppfcz4 15 30 190.5 +ppfcz4 15 29 186.5 +ppfcz4 15 28 182.5 +ppfcz4 15 27 178.5 +ppfcz4 15 26 174.5 +ppfcz4 15 25 170.5 +ppfcz4 15 24 166.5 +ppfcz4 15 23 162.5 +ppfcz4 15 22 158.5 +ppfcz4 15 21 154.5 +ppfcz4 15 20 150.5 +ppfcz4 15 19 145.5 +ppfcz4 15 18 140.5 +ppfcz4 15 17 135.5 +ppfcz4 15 16 130.5 +ppfcz4 15 15 125.5 +ppfcz4 15 14 120.5 +ppfcz4 15 13 115.5 +ppfcz4 15 12 110.5 +ppfcz4 15 11 105.5 +ppfcz4 15 10 100.5 +ppfcz4 15 9 93.5 +ppfcz4 15 8 86.5 +ppfcz4 15 7 79.5 +ppfcz4 15 6 72.5 +ppfcz4 15 5 65.5 +ppfcz4 15 4 58.5 +ppfcz4 15 3 51.5 +ppfcz4 15 2 44.5 +ppfcz4 30 30 773.5 +ppfcz4 30 29 751.5 +ppfcz4 30 28 730.5 +ppfcz4 30 27 708.5 +ppfcz4 30 26 687.5 +ppfcz4 30 25 665.5 +ppfcz4 30 24 644.5 +ppfcz4 30 23 622.5 +ppfcz4 30 22 601.5 +ppfcz4 30 21 579.5 +ppfcz4 30 20 558.5 +ppfcz4 30 19 536.5 +ppfcz4 30 18 515.5 +ppfcz4 30 17 493.5 +ppfcz4 30 16 472.5 +ppfcz4 30 15 450.5 +ppfcz4 30 14 429.5 +ppfcz4 30 13 407.5 +ppfcz4 30 12 386.5 +ppfcz4 30 11 364.5 +ppfcz4 30 10 343.5 +ppfcz4 30 9 321.5 +ppfcz4 30 8 300.5 +ppfcz4 30 7 278.5 +ppfcz4 30 6 257.5 +ppfcz4 30 5 232.5 +ppfcz4 30 4.5 211.5 +ppfcz4 30 4 195.5 +ppfcz4 30 3.5 179.5 +ppfcz4 30 3 163.5 +ppfcz4 30 2.5 146.5 +ppfcz4 30 2 134.5 +ppfcz4 30 1.5 118.5 +ppfcz4 30 1 104.5 +ppfcz4 30 0.5 90.5 +ppfcz5 14 30 485.5 +ppfcz5 14 29 472.5 +ppfcz5 14 28 459.5 +ppfcz5 14 27 446.5 +ppfcz5 14 26 433.5 +ppfcz5 14 25 420.5 +ppfcz5 14 24 407.5 +ppfcz5 14 23 394.5 +ppfcz5 14 22 381.5 +ppfcz5 14 21 368.5 +ppfcz5 14 20 355.5 +ppfcz5 14 19 340.5 +ppfcz5 14 18 325.5 +ppfcz5 14 17 310.5 +ppfcz5 14 16 295.5 +ppfcz5 14 15 280.5 +ppfcz5 14 14 265.5 +ppfcz5 14 13 250.5 +ppfcz5 14 12 235.5 +ppfcz5 14 11 220.5 +ppfcz5 14 10 205.5 +ppfcz5 14 9 188.5 +ppfcz5 14 8 171.5 +ppfcz5 14 7 154.5 +ppfcz5 14 6 137.5 +ppfcz5 14 5 120.5 +ppfcz5 14 4 102.5 +ppfcz5 14 3 84.5 +ppfcz5 14 2 66.5 +ppfcz5 15 30 232.5 +ppfcz5 15 29 227.5 +ppfcz5 15 28 222.5 +ppfcz5 15 27 217.5 +ppfcz5 15 26 212.5 +ppfcz5 15 25 207.5 +ppfcz5 15 24 203.5 +ppfcz5 15 23 197.5 +ppfcz5 15 22 191.5 +ppfcz5 15 21 185.5 +ppfcz5 15 20 179.5 +ppfcz5 15 19 173.5 +ppfcz5 15 18 167.5 +ppfcz5 15 17 161.5 +ppfcz5 15 16 153.5 +ppfcz5 15 15 147.5 +ppfcz5 15 14 140.5 +ppfcz5 15 13 133.5 +ppfcz5 15 12 126.5 +ppfcz5 15 11 119.5 +ppfcz5 15 10 112.5 +ppfcz5 15 9 104.5 +ppfcz5 15 8 96.5 +ppfcz5 15 7 88.5 +ppfcz5 15 6 80.5 +ppfcz5 15 5 72.5 +ppfcz5 15 4 64.5 +ppfcz5 15 3 56.5 +ppfcz5 15 2 48.5 +ppfcz5 30 30 857.5 +ppfcz5 30 29 833.5 +ppfcz5 30 28 809.5 +ppfcz5 30 27 786.5 +ppfcz5 30 26 762.5 +ppfcz5 30 25 738.5 +ppfcz5 30 24 715.5 +ppfcz5 30 23 691.5 +ppfcz5 30 22 668.5 +ppfcz5 30 21 644.5 +ppfcz5 30 20 620.5 +ppfcz5 30 19 597.5 +ppfcz5 30 18 573.5 +ppfcz5 30 17 549.5 +ppfcz5 30 16 526.5 +ppfcz5 30 15 502.5 +ppfcz5 30 14 478.5 +ppfcz5 30 13 455.5 +ppfcz5 30 12 431.5 +ppfcz5 30 11 407.5 +ppfcz5 30 10 384.5 +ppfcz5 30 9 360.5 +ppfcz5 30 8 336.5 +ppfcz5 30 7 313.5 +ppfcz5 30 6 289.5 +ppfcz5 30 5 264.5 +ppfcz5 30 4.5 243.5 +ppfcz5 30 4 221.5 +ppfcz5 30 3.5 200.5 +ppfcz5 30 3 183.5 +ppfcz5 30 2.5 165.5 +ppfcz5 30 2 148.5 +ppfcz5 30 1.5 131.5 +ppfcz5 30 1 114.5 +ppfcz5 30 0.5 97.5 +SELECT * FROM t2 ORDER BY b, c, d; +a b c d +all 1 10000 0 +all 2 10000 0 +domestic 3 100 59 +domestic 4 500 0 +domestic 5 500 0 +domestic 6 500 0 +domestic 7 500 0 +domestic 8 500 0 +domestic 9 10000 0 +foreign 10 30 0 +foreign 11 30 0 +foreign 12 30 0 +foreign 13 30 0 +ppfcz1 14 2 37.5 +ppfcz2 14 2 43.5 +ppfcz3 14 2 47.5 +ppfcz4 14 2 54.5 +ppfcz5 14 2 66.5 +ppfcz1 14 3 41.5 +ppfcz2 14 3 48.5 +ppfcz3 14 3 56.5 +ppfcz4 14 3 68.5 +ppfcz5 14 3 84.5 +ppfcz1 14 4 45.5 +ppfcz2 14 4 53.5 +ppfcz3 14 4 67.5 +ppfcz4 14 4 81.5 +ppfcz5 14 4 102.5 +ppfcz1 14 5 48.5 +ppfcz2 14 5 57.5 +ppfcz3 14 5 78.5 +ppfcz4 14 5 95.5 +ppfcz5 14 5 120.5 +ppfcz1 14 6 52.5 +ppfcz2 14 6 61.5 +ppfcz3 14 6 87.5 +ppfcz4 14 6 108.5 +ppfcz5 14 6 137.5 +ppfcz1 14 7 55.5 +ppfcz2 14 7 65.5 +ppfcz3 14 7 96.5 +ppfcz4 14 7 121.5 +ppfcz5 14 7 154.5 +ppfcz1 14 8 57.5 +ppfcz2 14 8 69.5 +ppfcz3 14 8 105.5 +ppfcz4 14 8 134.5 +ppfcz5 14 8 171.5 +ppfcz1 14 9 59.5 +ppfcz2 14 9 73.5 +ppfcz3 14 9 114.5 +ppfcz4 14 9 147.5 +ppfcz5 14 9 188.5 +ppfcz1 14 10 61.5 +ppfcz2 14 10 77.5 +ppfcz3 14 10 123.5 +ppfcz4 14 10 160.5 +ppfcz5 14 10 205.5 +ppfcz1 14 11 62.5 +ppfcz2 14 11 80.5 +ppfcz3 14 11 131.5 +ppfcz4 14 11 168.5 +ppfcz5 14 11 220.5 +ppfcz1 14 12 63.5 +ppfcz2 14 12 83.5 +ppfcz3 14 12 139.5 +ppfcz4 14 12 178.5 +ppfcz5 14 12 235.5 +ppfcz1 14 13 64.5 +ppfcz2 14 13 86.5 +ppfcz3 14 13 147.5 +ppfcz4 14 13 188.5 +ppfcz5 14 13 250.5 +ppfcz1 14 14 65.5 +ppfcz2 14 14 89.5 +ppfcz3 14 14 155.5 +ppfcz4 14 14 198.5 +ppfcz5 14 14 265.5 +ppfcz1 14 15 66.5 +ppfcz2 14 15 92.5 +ppfcz3 14 15 163.5 +ppfcz4 14 15 208.5 +ppfcz5 14 15 280.5 +ppfcz1 14 16 67.5 +ppfcz2 14 16 94.5 +ppfcz3 14 16 171.5 +ppfcz4 14 16 216.5 +ppfcz5 14 16 295.5 +ppfcz1 14 17 68.5 +ppfcz2 14 17 96.5 +ppfcz3 14 17 179.5 +ppfcz4 14 17 224.5 +ppfcz5 14 17 310.5 +ppfcz1 14 18 69.5 +ppfcz2 14 18 98.5 +ppfcz3 14 18 187.5 +ppfcz4 14 18 232.5 +ppfcz5 14 18 325.5 +ppfcz1 14 19 70.5 +ppfcz2 14 19 99.5 +ppfcz3 14 19 195.5 +ppfcz4 14 19 240.5 +ppfcz5 14 19 340.5 +ppfcz1 14 20 71.5 +ppfcz2 14 20 100.5 +ppfcz3 14 20 203.5 +ppfcz4 14 20 248.5 +ppfcz5 14 20 355.5 +ppfcz1 14 21 72.5 +ppfcz2 14 21 101.5 +ppfcz3 14 21 210.5 +ppfcz4 14 21 256.5 +ppfcz5 14 21 368.5 +ppfcz1 14 22 73.5 +ppfcz2 14 22 102.5 +ppfcz3 14 22 217.5 +ppfcz4 14 22 264.5 +ppfcz5 14 22 381.5 +ppfcz1 14 23 74.5 +ppfcz2 14 23 103.5 +ppfcz3 14 23 224.5 +ppfcz4 14 23 272.5 +ppfcz5 14 23 394.5 +ppfcz1 14 24 75.5 +ppfcz2 14 24 104.5 +ppfcz3 14 24 231.5 +ppfcz4 14 24 280.5 +ppfcz5 14 24 407.5 +ppfcz1 14 25 76.5 +ppfcz2 14 25 105.5 +ppfcz3 14 25 238.5 +ppfcz4 14 25 288.5 +ppfcz5 14 25 420.5 +ppfcz1 14 26 77.5 +ppfcz2 14 26 106.5 +ppfcz3 14 26 245.5 +ppfcz4 14 26 296.5 +ppfcz5 14 26 433.5 +ppfcz1 14 27 78.5 +ppfcz2 14 27 107.5 +ppfcz3 14 27 252.5 +ppfcz4 14 27 304.5 +ppfcz5 14 27 446.5 +ppfcz1 14 28 79.5 +ppfcz2 14 28 108.5 +ppfcz3 14 28 259.5 +ppfcz4 14 28 312.5 +ppfcz5 14 28 459.5 +ppfcz1 14 29 80.5 +ppfcz2 14 29 109.5 +ppfcz3 14 29 266.5 +ppfcz4 14 29 320.5 +ppfcz5 14 29 472.5 +ppfcz1 14 30 81.5 +ppfcz2 14 30 110.5 +ppfcz3 14 30 273.5 +ppfcz4 14 30 328.5 +ppfcz5 14 30 485.5 +ppfcz1 15 2 33.5 +ppfcz2 15 2 38.5 +ppfcz3 15 2 39.5 +ppfcz4 15 2 44.5 +ppfcz5 15 2 48.5 +ppfcz1 15 3 36.5 +ppfcz2 15 3 42.5 +ppfcz3 15 3 45.5 +ppfcz4 15 3 51.5 +ppfcz5 15 3 56.5 +ppfcz1 15 4 39.5 +ppfcz2 15 4 46.5 +ppfcz3 15 4 51.5 +ppfcz4 15 4 58.5 +ppfcz5 15 4 64.5 +ppfcz1 15 5 41.5 +ppfcz2 15 5 50.5 +ppfcz3 15 5 57.5 +ppfcz4 15 5 65.5 +ppfcz5 15 5 72.5 +ppfcz1 15 6 42.5 +ppfcz2 15 6 53.5 +ppfcz3 15 6 63.5 +ppfcz4 15 6 72.5 +ppfcz5 15 6 80.5 +ppfcz1 15 7 43.5 +ppfcz2 15 7 56.5 +ppfcz3 15 7 69.5 +ppfcz4 15 7 79.5 +ppfcz5 15 7 88.5 +ppfcz1 15 8 44.5 +ppfcz2 15 8 59.5 +ppfcz3 15 8 75.5 +ppfcz4 15 8 86.5 +ppfcz5 15 8 96.5 +ppfcz1 15 9 45.5 +ppfcz2 15 9 62.5 +ppfcz3 15 9 81.5 +ppfcz4 15 9 93.5 +ppfcz5 15 9 104.5 +ppfcz1 15 10 46.5 +ppfcz2 15 10 65.5 +ppfcz3 15 10 87.5 +ppfcz4 15 10 100.5 +ppfcz5 15 10 112.5 +ppfcz1 15 11 47.5 +ppfcz2 15 11 67.5 +ppfcz3 15 11 93.5 +ppfcz4 15 11 105.5 +ppfcz5 15 11 119.5 +ppfcz1 15 12 48.5 +ppfcz2 15 12 69.5 +ppfcz3 15 12 99.5 +ppfcz4 15 12 110.5 +ppfcz5 15 12 126.5 +ppfcz1 15 13 49.5 +ppfcz2 15 13 71.5 +ppfcz3 15 13 105.5 +ppfcz4 15 13 115.5 +ppfcz5 15 13 133.5 +ppfcz1 15 14 50.5 +ppfcz2 15 14 73.5 +ppfcz3 15 14 111.5 +ppfcz4 15 14 120.5 +ppfcz5 15 14 140.5 +ppfcz1 15 15 51.5 +ppfcz2 15 15 75.5 +ppfcz3 15 15 117.5 +ppfcz4 15 15 125.5 +ppfcz5 15 15 147.5 +ppfcz1 15 16 52.5 +ppfcz2 15 16 76.5 +ppfcz3 15 16 122.5 +ppfcz4 15 16 130.5 +ppfcz5 15 16 153.5 +ppfcz1 15 17 53.5 +ppfcz2 15 17 77.5 +ppfcz3 15 17 127.5 +ppfcz4 15 17 135.5 +ppfcz5 15 17 161.5 +ppfcz1 15 18 54.5 +ppfcz2 15 18 78.5 +ppfcz3 15 18 132.5 +ppfcz4 15 18 140.5 +ppfcz5 15 18 167.5 +ppfcz1 15 19 55.5 +ppfcz2 15 19 79.5 +ppfcz3 15 19 137.5 +ppfcz4 15 19 145.5 +ppfcz5 15 19 173.5 +ppfcz1 15 20 56.5 +ppfcz2 15 20 80.5 +ppfcz3 15 20 142.5 +ppfcz4 15 20 150.5 +ppfcz5 15 20 179.5 +ppfcz1 15 21 57.5 +ppfcz2 15 21 81.5 +ppfcz3 15 21 146.5 +ppfcz4 15 21 154.5 +ppfcz5 15 21 185.5 +ppfcz1 15 22 58.5 +ppfcz2 15 22 82.5 +ppfcz3 15 22 150.5 +ppfcz4 15 22 158.5 +ppfcz5 15 22 191.5 +ppfcz1 15 23 59.5 +ppfcz2 15 23 83.5 +ppfcz3 15 23 154.5 +ppfcz4 15 23 162.5 +ppfcz5 15 23 197.5 +ppfcz1 15 24 60.5 +ppfcz2 15 24 84.5 +ppfcz3 15 24 158.5 +ppfcz4 15 24 166.5 +ppfcz5 15 24 203.5 +ppfcz1 15 25 61.5 +ppfcz2 15 25 85.5 +ppfcz3 15 25 162.5 +ppfcz4 15 25 170.5 +ppfcz5 15 25 207.5 +ppfcz1 15 26 62.5 +ppfcz2 15 26 86.5 +ppfcz3 15 26 166.5 +ppfcz4 15 26 174.5 +ppfcz5 15 26 212.5 +ppfcz1 15 27 63.5 +ppfcz2 15 27 87.5 +ppfcz3 15 27 170.5 +ppfcz4 15 27 178.5 +ppfcz5 15 27 217.5 +ppfcz1 15 28 64.5 +ppfcz2 15 28 88.5 +ppfcz3 15 28 174.5 +ppfcz4 15 28 182.5 +ppfcz5 15 28 222.5 +ppfcz1 15 29 65.5 +ppfcz2 15 29 89.5 +ppfcz3 15 29 178.5 +ppfcz4 15 29 186.5 +ppfcz5 15 29 227.5 +ppfcz1 15 30 66.5 +ppfcz2 15 30 90.5 +ppfcz3 15 30 182.5 +ppfcz4 15 30 190.5 +ppfcz5 15 30 232.5 +plfcz1 16 0.5 19 +plfcz2 16 0.5 25 +domestic 17 2 7.2 +domestic 17 5 8.43 +domestic 17 10 11.15 +domestic 17 20 15.83 +domestic 17 30 22.02 +domestic 18 2 8.2 +domestic 18 5 9.43 +domestic 18 10 12.15 +domestic 18 20 16.83 +domestic 18 30 23.02 +domestic 19 2 6.3 +domestic 19 5 7.77 +domestic 19 10 10.3 +domestic 19 20 14.83 +domestic 19 30 20.88 +domestic 20 2 7.3 +domestic 20 5 8.77 +domestic 20 10 11.3 +domestic 20 20 15.83 +domestic 20 30 21.88 +domestic 21 3.9 10.8 +domestic 21 4.9 12.2 +domestic 21 9.9 15.3 +domestic 21 19.9 20.6 +domestic 21 30 28.1 +foreign 22 0 0 +domestic 23 2 18.8 +domestic 23 5 20.8 +domestic 23 10 24.8 +domestic 23 20 27.8 +domestic 23 30 30.8 +domestic 24 2 21.1405 +domestic 24 5 22.3705 +domestic 24 10 25.0905 +domestic 24 20 29.7705 +domestic 24 30 35.9605 +foreign 25 200 0 +domestic 26 0.25 4.7 +domestic 27 0.25 6 +domestic 28 2 17 +domestic 28 5 19 +domestic 28 10 22 +domestic 28 20 28 +domestic 28 30 35 +domestic 29 30 29.5 +ppfcz1 30 0.5 56.5 +ppfcz2 30 0.5 61.5 +ppfcz3 30 0.5 74.5 +ppfcz4 30 0.5 90.5 +ppfcz5 30 0.5 97.5 +ppfcz1 30 1 63.5 +ppfcz2 30 1 65.5 +ppfcz3 30 1 83.5 +ppfcz4 30 1 104.5 +ppfcz5 30 1 114.5 +ppfcz1 30 1.5 69.5 +ppfcz2 30 1.5 75.5 +ppfcz3 30 1.5 90.5 +ppfcz4 30 1.5 118.5 +ppfcz5 30 1.5 131.5 +ppfcz1 30 2 75.5 +ppfcz2 30 2 80.5 +ppfcz3 30 2 99.5 +ppfcz4 30 2 134.5 +ppfcz5 30 2 148.5 +ppfcz1 30 2.5 80.5 +ppfcz2 30 2.5 86.5 +ppfcz3 30 2.5 107.5 +ppfcz4 30 2.5 146.5 +ppfcz5 30 2.5 165.5 +ppfcz1 30 3 86.5 +ppfcz2 30 3 99.5 +ppfcz3 30 3 114.5 +ppfcz4 30 3 163.5 +ppfcz5 30 3 183.5 +ppfcz1 30 3.5 92.5 +ppfcz2 30 3.5 109.5 +ppfcz3 30 3.5 122.5 +ppfcz4 30 3.5 179.5 +ppfcz5 30 3.5 200.5 +ppfcz1 30 4 99.5 +ppfcz2 30 4 113.5 +ppfcz3 30 4 130.5 +ppfcz4 30 4 195.5 +ppfcz5 30 4 221.5 +ppfcz1 30 4.5 105.5 +ppfcz2 30 4.5 121.5 +ppfcz3 30 4.5 140.5 +ppfcz4 30 4.5 211.5 +ppfcz5 30 4.5 243.5 +ppfcz1 30 5 111.5 +ppfcz2 30 5 129.5 +ppfcz3 30 5 147.5 +ppfcz4 30 5 232.5 +ppfcz5 30 5 264.5 +ppfcz1 30 6 118.5 +ppfcz2 30 6 139.5 +ppfcz3 30 6 162.5 +ppfcz4 30 6 257.5 +ppfcz5 30 6 289.5 +ppfcz1 30 7 126.5 +ppfcz2 30 7 149.5 +ppfcz3 30 7 174.5 +ppfcz4 30 7 278.5 +ppfcz5 30 7 313.5 +ppfcz1 30 8 133.5 +ppfcz2 30 8 159.5 +ppfcz3 30 8 188.5 +ppfcz4 30 8 300.5 +ppfcz5 30 8 336.5 +ppfcz1 30 9 141.5 +ppfcz2 30 9 169.5 +ppfcz3 30 9 201.5 +ppfcz4 30 9 321.5 +ppfcz5 30 9 360.5 +ppfcz1 30 10 148.5 +ppfcz2 30 10 180.5 +ppfcz3 30 10 213.5 +ppfcz4 30 10 343.5 +ppfcz5 30 10 384.5 +ppfcz1 30 11 156.5 +ppfcz2 30 11 189.5 +ppfcz3 30 11 227.5 +ppfcz4 30 11 364.5 +ppfcz5 30 11 407.5 +ppfcz1 30 12 163.5 +ppfcz2 30 12 199.5 +ppfcz3 30 12 240.5 +ppfcz4 30 12 386.5 +ppfcz5 30 12 431.5 +ppfcz1 30 13 171.5 +ppfcz2 30 13 210.5 +ppfcz3 30 13 252.5 +ppfcz4 30 13 407.5 +ppfcz5 30 13 455.5 +ppfcz1 30 14 178.5 +ppfcz2 30 14 219.5 +ppfcz3 30 14 266.5 +ppfcz4 30 14 429.5 +ppfcz5 30 14 478.5 +ppfcz1 30 15 186.5 +ppfcz2 30 15 229.5 +ppfcz3 30 15 278.5 +ppfcz4 30 15 450.5 +ppfcz5 30 15 502.5 +ppfcz1 30 16 193.5 +ppfcz2 30 16 240.5 +ppfcz3 30 16 290.5 +ppfcz4 30 16 472.5 +ppfcz5 30 16 526.5 +ppfcz1 30 17 201.5 +ppfcz2 30 17 249.5 +ppfcz3 30 17 304.5 +ppfcz4 30 17 493.5 +ppfcz5 30 17 549.5 +ppfcz1 30 18 209.5 +ppfcz2 30 18 259.5 +ppfcz3 30 18 317.5 +ppfcz4 30 18 515.5 +ppfcz5 30 18 573.5 +ppfcz1 30 19 216.5 +ppfcz2 30 19 270.5 +ppfcz3 30 19 330.5 +ppfcz4 30 19 536.5 +ppfcz5 30 19 597.5 +ppfcz1 30 20 224.5 +ppfcz2 30 20 280.5 +ppfcz3 30 20 343.5 +ppfcz4 30 20 558.5 +ppfcz5 30 20 620.5 +ppfcz1 30 21 231.5 +ppfcz2 30 21 289.5 +ppfcz3 30 21 354.5 +ppfcz4 30 21 579.5 +ppfcz5 30 21 644.5 +ppfcz1 30 22 239.5 +ppfcz2 30 22 300.5 +ppfcz3 30 22 363.5 +ppfcz4 30 22 601.5 +ppfcz5 30 22 668.5 +ppfcz1 30 23 246.5 +ppfcz2 30 23 310.5 +ppfcz3 30 23 375.5 +ppfcz4 30 23 622.5 +ppfcz5 30 23 691.5 +ppfcz1 30 24 254.5 +ppfcz2 30 24 320.5 +ppfcz3 30 24 385.5 +ppfcz4 30 24 644.5 +ppfcz5 30 24 715.5 +ppfcz1 30 25 261.5 +ppfcz2 30 25 330.5 +ppfcz3 30 25 396.5 +ppfcz4 30 25 665.5 +ppfcz5 30 25 738.5 +ppfcz1 30 26 269.5 +ppfcz2 30 26 340.5 +ppfcz3 30 26 405.5 +ppfcz4 30 26 687.5 +ppfcz5 30 26 762.5 +ppfcz1 30 27 276.5 +ppfcz2 30 27 350.5 +ppfcz3 30 27 417.5 +ppfcz4 30 27 708.5 +ppfcz5 30 27 786.5 +ppfcz1 30 28 284.5 +ppfcz2 30 28 360.5 +ppfcz3 30 28 428.5 +ppfcz4 30 28 730.5 +ppfcz5 30 28 809.5 +ppfcz1 30 29 291.5 +ppfcz2 30 29 370.5 +ppfcz3 30 29 438.5 +ppfcz4 30 29 751.5 +ppfcz5 30 29 833.5 +ppfcz1 30 30 299.5 +ppfcz2 30 30 381.5 +ppfcz3 30 30 448.5 +ppfcz4 30 30 773.5 +ppfcz5 30 30 857.5 +all 32 10000 23.2342007434944 +SELECT * FROM t2 ORDER BY b, d limit 1000, 50; +a b c d +SELECT * FROM t2 ORDER BY c desc, d limit 500, 20; +a b c d +ppfcz5 14 2 66.5 +ppfcz1 30 2 75.5 +ppfcz2 30 2 80.5 +ppfcz3 30 2 99.5 +ppfcz4 30 2 134.5 +ppfcz5 30 2 148.5 +ppfcz1 30 1.5 69.5 +ppfcz2 30 1.5 75.5 +ppfcz3 30 1.5 90.5 +ppfcz4 30 1.5 118.5 +ppfcz5 30 1.5 131.5 +ppfcz1 30 1 63.5 +ppfcz2 30 1 65.5 +ppfcz3 30 1 83.5 +ppfcz4 30 1 104.5 +ppfcz5 30 1 114.5 +plfcz1 16 0.5 19 +plfcz2 16 0.5 25 +ppfcz1 30 0.5 56.5 +ppfcz2 30 0.5 61.5 +SELECT d FROM t2 WHERE t2.b=14 ORDER BY t2.c; +d +37.5 +43.5 +47.5 +54.5 +66.5 +41.5 +48.5 +56.5 +68.5 +84.5 +45.5 +53.5 +67.5 +81.5 +102.5 +48.5 +57.5 +78.5 +95.5 +120.5 +52.5 +61.5 +87.5 +108.5 +137.5 +55.5 +65.5 +96.5 +121.5 +154.5 +57.5 +69.5 +105.5 +134.5 +171.5 +59.5 +73.5 +114.5 +147.5 +188.5 +61.5 +77.5 +123.5 +160.5 +205.5 +62.5 +80.5 +131.5 +168.5 +220.5 +63.5 +83.5 +139.5 +178.5 +235.5 +64.5 +86.5 +147.5 +188.5 +250.5 +65.5 +89.5 +155.5 +198.5 +265.5 +66.5 +92.5 +163.5 +208.5 +280.5 +67.5 +94.5 +171.5 +216.5 +295.5 +68.5 +96.5 +179.5 +224.5 +310.5 +69.5 +98.5 +187.5 +232.5 +325.5 +70.5 +99.5 +195.5 +240.5 +340.5 +71.5 +100.5 +203.5 +248.5 +355.5 +72.5 +101.5 +210.5 +256.5 +368.5 +73.5 +102.5 +217.5 +264.5 +381.5 +74.5 +103.5 +224.5 +272.5 +394.5 +75.5 +104.5 +231.5 +280.5 +407.5 +76.5 +105.5 +238.5 +288.5 +420.5 +77.5 +106.5 +245.5 +296.5 +433.5 +78.5 +107.5 +252.5 +304.5 +446.5 +79.5 +108.5 +259.5 +312.5 +459.5 +80.5 +109.5 +266.5 +320.5 +472.5 +81.5 +110.5 +273.5 +328.5 +485.5 +DROP TABLE t2; diff --git a/mysql-test/suite/parallel_query/r/pq_tempory_table_release.result-pq b/mysql-test/suite/parallel_query/r/pq_tempory_table_release.result-pq new file mode 100644 index 000000000..954936d45 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_tempory_table_release.result-pq @@ -0,0 +1,26 @@ +create table t1(a int primary key, b varchar(10), c decimal(5,2)); +insert into t1 values (1, 'The', '3.14'); +insert into t1 values (2, 'quick', '4.25'); +insert into t1 values (3, 'brown', '5.36'); +insert into t1 values (4, 'fox', '6.47'); +insert into t1 values (5, 'jumps', '3.14'); +insert into t1 values (6, 'over', '4.25'); +insert into t1 values (7, 'the', '5.36'); +insert into t1 values (8, 'lazy', '6.47'); +insert into t1 values (9, 'dog', '7.58'); +set session force_parallel_execute=1; +explain select c,sum(a) from t1 group by(c); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 9 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 Using temporary +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c`,sum(`test`.`t1`.`a`) AS `sum(a)` from `test`.`t1` group by `test`.`t1`.`c` +select c,sum(a) from t1 group by(c); +c sum(a) +3.14 6 +4.25 8 +5.36 10 +6.47 12 +7.58 9 +drop table t1; +# restart diff --git a/mysql-test/suite/parallel_query/r/pq_tpch.result-pq b/mysql-test/suite/parallel_query/r/pq_tpch.result-pq new file mode 100644 index 000000000..7137a8a16 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_tpch.result-pq @@ -0,0 +1,909 @@ +drop database if exists pq_database; +create database pq_database; +use pq_database; +DROP TABLE IF EXISTS `nation`; +CREATE TABLE `nation` ( +`n_nationkey` int NOT NULL, +`N_NAME` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`N_REGIONKEY` int NOT NULL, +`N_COMMENT` varchar(152) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, +PRIMARY KEY (`n_nationkey`) USING BTREE, +INDEX `NATION_FK1`(`N_REGIONKEY`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO nation VALUES(0, 'ALGERIA', 0, 'haggle. carefully final deposits detect slyly agai'); +INSERT INTO nation VALUES(1, 'ARGENTINA', 1, 'al foxes promise slyly according to the regular accounts. bold requests alon'); +INSERT INTO nation VALUES(2, 'BRAZIL', 1, 'y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special'); +INSERT INTO nation VALUES(3, 'CANADA', 1, 'eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold'); +INSERT INTO nation VALUES(18, 'CHINA', 2, 'c dependencies. furiously express notornis sleep slyly regular accounts. ideas sleep. depos'); +INSERT INTO nation VALUES(4, 'EGYPT', 4, 'y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d'); +INSERT INTO nation VALUES(5, 'ETHIOPIA', 0, 'ven packages wake quickly. regu'); +INSERT INTO nation VALUES(6, 'FRANCE', 3, 'refully final requests. regular, ironi'); +INSERT INTO nation VALUES(7, 'GERMANY', 3, 'l platelets. regular accounts x-ray: unusual, regular acco'); +INSERT INTO nation VALUES(8, 'INDIA', 2, 'ss excuses cajole slyly across the packages. deposits print aroun'); +INSERT INTO nation VALUES(9, 'INDONESIA', 2, 'slyly express asymptotes. regular deposits haggle slyly. carefully ironic hockey players sleep blithely. carefull'); +INSERT INTO nation VALUES(10, 'IRAN', 4, 'efully alongside of the slyly final dependencies.'); +INSERT INTO nation VALUES(11, 'IRAQ', 4, 'nic deposits boost atop the quickly final requests? quickly regula'); +INSERT INTO nation VALUES(12, 'JAPAN', 2, 'ously. final, express gifts cajole a'); +INSERT INTO nation VALUES(13, 'JORDAN', 4, 'ic deposits are blithely about the carefully regular pa'); +INSERT INTO nation VALUES(14, 'KENYA', 0, 'pending excuses haggle furiously deposits. pending, express pinto beans wake fluffily past t'); +INSERT INTO nation VALUES(15, 'MOROCCO',0, 'rns. blithely bold courts among the closely regular packages use furiously bold platelets?'); +INSERT INTO nation VALUES(16, 'MOZAMBIQUE', 0, 's. ironic, unusual asymptotes wake blithely r'); +INSERT INTO nation VALUES(17, 'PERU', 1, 'platelets. blithely pending dependencies use fluffily across the even pinto beans. carefully silent accoun'); +INSERT INTO nation VALUES(19, 'ROMANIA', 3, 'ular asymptotes are about the furious multipliers. express dependencies nag above the ironically ironic account'); +INSERT INTO nation VALUES(22, 'RUSSIA', 3, 'requests against the platelets use never according to the quickly regular pint'); +INSERT INTO nation VALUES(20, 'SAUDI ARABIA', 4, 'ts. silent requests haggle. closely express packages sleep across the blithely'); +INSERT INTO nation VALUES(23, 'UNITED KINGDOM', 3, 'eans boost carefully special requests. accounts are. carefull'); +INSERT INTO nation VALUES(24, 'UNITED STATES', 1, 'y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be'); +INSERT INTO nation VALUES(21, 'VIETNAM', 2, 'hely enticingly express accounts. even, final'); +DROP TABLE IF EXISTS `supplier`; +CREATE TABLE `supplier` ( +`s_suppkey` int NOT NULL, +`S_NAME` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`S_ADDRESS` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`S_NATIONKEY` int NOT NULL, +`S_PHONE` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`S_ACCTBAL` decimal(15, 2) NOT NULL, +`S_COMMENT` varchar(101) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +PRIMARY KEY (`s_suppkey`) USING BTREE, +INDEX `SUPPLIER_FK1`(`S_NATIONKEY`) USING BTREE, +CONSTRAINT `supplier_ibfk_1` FOREIGN KEY (`S_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `supplier_ibfk_2` FOREIGN KEY (`S_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `supplier_ibfk_3` FOREIGN KEY (`S_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO supplier VALUES (605, 'Supplier#000000605', 'wdwiNoNT8pVHOTHQ8jhVzaOTkU', 6, '16-835-870-9488', 6071.58,'foxes poach blithely beneath the excuses: ironic multipliers haggle quickly furiously unu'); +INSERT INTO supplier VALUES (839, 'Supplier#000000839', '1fSx9Sv6LraqnVP3u', 6, '16-845-687-7291',2761.59, 'ess, regular accounts haggle slyly across the carefully'); +INSERT INTO supplier VALUES (996, 'Supplier#000000996', 'Wx4dQwOAwWjfSCGupfrM', 7, '17-447-811-3282', 6329.90, 'ironic forges cajole blithely agai'); +INSERT INTO supplier VALUES (741, 'Supplier#000000741', 'BLP6zAc29lDLOvSE3 h2', 7, '17-292-821-2297', 824.94, 'even, unusual instructions b'); +INSERT INTO `supplier` VALUES (800, 'Supplier#000000800', 'Z4 hpmBjpjBXREqzixsBCIaF', 0, '10-497-654-8607', 7956.80, 'he bold foxes boost blithely about the blithely final epitaphs. slyly'); +INSERT INTO `supplier` VALUES (817, 'Supplier#000000817', '0GTKh7JybR8sVahPoJT8kbNtDV0TzA79Q', 0, '10-282-124-6047', 4468.89, ' blithely even requests. blithely ironic deposits wake slyly. ideas haggle! quickly i'); +INSERT INTO `supplier` VALUES (370, 'Supplier#000000370', 'yyNSJAG9UXcWit4SeMkEIrNcdVq5', 0, '10-602-768-3758', 8515.99, 'ound the unusual foxes sleep finally within the furiously unusual requests. sl'); +INSERT INTO `supplier` VALUES (567, 'Supplier#000000567', 'fvuRpAap0MvoBguGKBfp', 1, '11-390-878-2811', 5264.91, 'ke fluffily furiously ironic ideas. qu'); +INSERT INTO `supplier` VALUES (678, 'Supplier#000000678', 'SLpBfeoHSImv', 1, '11-465-565-3513', -58.41, 'he blithely even requests. blithely unusual theodolites sleep furiously against the'); +INSERT INTO `supplier` VALUES (801, 'Supplier#000000801', 'zohVF4 4GHOJpWy9kdytvYwm27mJEBhk', 1, '11-673-791-6926', 976.53, 'ckly final accounts wake since the even instructions. regular, permanent accounts are against t'); +INSERT INTO `supplier` VALUES (300, 'Supplier#000000300', 'YU QZvXHJC7,ZspUPGwaIOa', 2, '12-468-732-4623', 811.42, 'furiously even theodolites haggle along the final, ironic foxes. bold deposits are.'); +INSERT INTO `supplier` VALUES (743, 'Supplier#000000743', 'ccFQShf qHch yPwbryx12DfnIYAp83,F', 2, '12-841-918-5889', 4384.23, 'e slyly after the quickly final platelets? special, special foxes nag slyl'); +INSERT INTO `supplier` VALUES (993, 'Supplier#000000993', 'z2NwUJ TPfd9MP8K3Blp1prYQ116 ', 2, '12-316-384-2073', 2336.52, ' asymptotes haggle slowly above the'); +INSERT INTO `supplier` VALUES (887, 'Supplier#000000887', 'urEaTejH5POADP2ARrf', 3, '13-738-297-6117', 3113.73, 's. regular realms haggle. special, unusual accounts wake furiously. bold pearls play c'); +INSERT INTO `supplier` VALUES (475, 'Supplier#000000475', 'xw4V6,4QQW LI5Qg EOKy4JD B4Cq1tjzaOma9Y', 3, '13-397-755-1516', -115.01, 'among the slyly regular deposits cajole after the even theodolites. carefully unusua'); +INSERT INTO `supplier` VALUES (402, 'Supplier#000000402', 'i9Sw4DoyMhzhKXCH9By,AYSgmD', 3, '13-109-731-3195', 4943.01, 'around the carefully pending dolp'); +INSERT INTO `supplier` VALUES (378, 'Supplier#000000378', 'FfbhyCxWvcPrO8ltp9', 3, '13-930-567-5190', 4429.27, ' among the furiously pending excuses. fluffily express deposits except the slyly final packages'); +INSERT INTO `supplier` VALUES (928, 'Supplier#000000928', 'VL,J8Fq0GI0BnVTaTU9Dcp9Z', 18, '28-382-849-1505', 8512.48, 'equests are. slyly specia'); +INSERT INTO `supplier` VALUES (255, 'Supplier#000000255', 'qx16XyCEUh9OawVeQWOlGlhAU32iHFPNkO', 18, '28-629-327-4139', 4663.08, 's boost. ironic pinto beans along the slyly unusual foxes haggle regular, final asymptotes. reque'); +INSERT INTO `supplier` VALUES (584, 'Supplier#000000584', 'XvDYsHYpmY5AkX60fj0bZo4WW', 18, '28-223-704-2186', 6912.86, 'e requests haggle carefully even ideas. express, bold requests integrate quickly furiously '); +INSERT INTO `supplier` VALUES (301, 'Supplier#000000301', 'YPFTsQOPRAGIlBw', 4, '14-434-699-9741', 6472.62, 'express foxes sleep carefully even packages. carefully special ideas cajole slyly. carefully r'); +INSERT INTO `supplier` VALUES (67, 'Supplier#000000067', '7YrEKJncHFk5D W7ZaqfAXV', 4, '14-563-538-1657', 3576.55, 'ray slyly final foxes. furio'); +INSERT INTO `supplier` VALUES (78, 'Supplier#000000078', '9y3OZ2CV hGrsrQxzB7V3zTtygHVHlG3SD6yrz', 5, '15-670-998-6860', 1044.10, ', regular packages wake quickly bold requests. carefully unusual requests about the unusual request'); +INSERT INTO `supplier` VALUES (243, 'Supplier#000000243', '8aQ3HGeOXxgYeMAXZQe B5y2RKEF5jdmN3Qb', 6, '16-554-376-5494', 747.88, 'kly silent requests among the blithely regular foxes use fu'); +INSERT INTO `supplier` VALUES (417, 'Supplier#000000417', 'b3CbQxCMWWu,YyeQU 51fccuv7Mt', 6, '16-563-597-5520', -113.45, 'equests hinder quiet courts. carefully'); +INSERT INTO `supplier` VALUES (451, 'Supplier#000000451', 'cqMKQiLjokvIFG', 6, '16-328-146-7253', 2503.45, 'cial packages. pinto beans '); +INSERT INTO `supplier` VALUES (254, 'Supplier#000000254', 'c6h4mizJAVT0Oz', 7, '17-100-212-8737', 6230.48, 'nos. bold ideas wake carefully among the furiously '); +INSERT INTO `supplier` VALUES (786, 'Supplier#000000786', 'QiKBtsiRdDZ2xGcwZgOSoMaKSH4HQ360,88L', 8, '18-280-624-2919', 406.37, 'uests. regular warthogs across the blithely express'); +INSERT INTO `supplier` VALUES (878, 'Supplier#000000878', 'cennOpnejXFuwxsxrfoz6U,WN TC7', 8, '18-462-213-5795', 4140.02, 'gular theodolites wake. blithely bold deposit'); +INSERT INTO `supplier` VALUES (551, 'Supplier#000000551', 'ZNiqP1w6Z SGZsLllIhaicTnLCCuAepdNbkm6pJ', 8, '18-297-775-8421', 9364.67, 'lithely even instructions poach quickly. furiously bold accounts sleep final, final accoun'); +INSERT INTO `supplier` VALUES (702, 'Supplier#000000702', '1IfvvCrOk6tDle1AjJisjgmZTSrf6Y 2t,Mdv', 9, '19-354-412-3179', 7655.97, 'about the unusual, bold foxes. quickl'); +INSERT INTO `supplier` VALUES (505, 'Supplier#000000505', 'aqcYZYQD5TYlLDgIxhKZyFCzL3Ch5qKOxj', 9, '19-480-691-1853', 6399.78, ' requests engage slyly regular ideas. fina'); +INSERT INTO `supplier` VALUES (676, 'Supplier#000000676', 'USGIdhKusoe8dcvWdBbZWUfxnVxNnsgY mG', 9, '19-833-604-9178', 5783.61, 's use deposits. quickly even packages haggle quickl'); +INSERT INTO `supplier` VALUES (834, 'Supplier#000000834', 'fwX0Z5,PgFaauaEXlVQX6UmHM0RDKS4EXe,Tn3nJ', 9, '19-419-490-3356', 3732.75, ' express foxes nag slyly after the regular pinto beans. regul'); +INSERT INTO `supplier` VALUES (504, 'Supplier#000000504', 'P8k2mjRiRUFCJfxw7KrEdRpNNQPDxiI', 10, '20-322-544-5770', 9050.12, 'y final pinto beans. blithely regular instructions wake abo'); +INSERT INTO `supplier` VALUES (240, 'Supplier#000000240', 'yMzL86zw28z6sMa', 10, '20-843-630-4161', 6537.07, 'sly. final, regular pinto beans unwind slyl'); +INSERT INTO `supplier` VALUES (286, 'Supplier#000000286', 'o80iAPvmwqM3WOA93pqBHT4Dsgy1rwG', 10, '20-459-893-8984', 7517.31, 'iously regular pinto beans sleep carefully slyly even accounts. packages cajol'); +INSERT INTO `supplier` VALUES (176, 'Supplier#000000176', 'OLVnGuOx8m6NfApzODj4 JP01JJIm,qI53BChmgQ', 10, '20-970-245-2712', 6387.89, 's according to the carefully expr'); +INSERT INTO `supplier` VALUES (613, 'Supplier#000000613', 'DYwZjMQj26Es8D8pxn2zx', 11, '21-796-340-9401', 2201.94, 'e furiously. final foxes haggle carefully quickly express theodolites. regular deposits affix bli'); +INSERT INTO `supplier` VALUES (5, 'Supplier#000000005', 'Gcdm2rJRzl5qlTVzc', 11, '21-151-690-3663', -283.84, '. slyly regular pinto bea'); +INSERT INTO `supplier` VALUES (493, 'Supplier#000000493', '7tdI3AtlDll57sj5K48WLX j5RDbc', 11, '21-252-702-2543', 4999.17, 'gular foxes. slyly pending requests hang along'); +INSERT INTO `supplier` VALUES (113, 'Supplier#000000113', '5 YOpqbaHs7dR gG4EmXrI7XtA7DcnRMsWPU1z2D', 11, '21-211-117-1937', 1882.05, 'blithely regular courts wake quickly even pl'); +INSERT INTO `supplier` VALUES (337, 'Supplier#000000337', 'IRrbCdIS,GB4YYhr', 12, '22-951-643-8793', 9029.85, 'en theodolites-- special, final deposits should have to boost ca'); +INSERT INTO `supplier` VALUES (550, 'Supplier#000000550', 'QQavssDXnYHbvOrg', 12, '22-648-743-9295', 9238.79, 'en, bold ideas. ironic, unusual deposits boost carefully quick accounts. slyly e'); +INSERT INTO `supplier` VALUES (837, 'Supplier#000000837', '717LGrDM2ChnIS91,PE4 ycp4mu4HPdcX', 12, '22-626-153-5392', 5167.00, 'gular instructions are furiously a'); +INSERT INTO `supplier` VALUES (36, 'Supplier#000000036', 'mzSpBBJvbjdx3UKTW3bLFewRD78D91lAC879', 13, '23-273-493-3679', 2371.51, 'ular theodolites must haggle regular, bold accounts. slyly final pinto beans bo'); +INSERT INTO `supplier` VALUES (577, 'Supplier#000000577', 'kn5oGAnFD1CQjet8awWorC,UMf37MP71yNcVD', 13, '23-973-363-7797', 5593.17, 'olites along the quick accounts cajole throughout the regular asymptotes. accounts maintain'); +INSERT INTO `supplier` VALUES (508, 'Supplier#000000508', 'F9,suuHYbe6kCRCPZaeSHSPAFBk9vOcFX8TUx', 14, '24-179-400-2422', 3878.22, 'sits. blithely furious requests boost slyly about the quickly even packages. closely'); +INSERT INTO `supplier` VALUES (808, 'Supplier#000000808', 'B3zlGM54ECUk5MgRzKI9f7F bB8', 15, '25-297-954-4894', 9438.28, 'y even packages. requests sleep quickly fo'); +INSERT INTO `supplier` VALUES (4, 'Supplier#000000004', 'Bk7ah4CK8SYQTepEmvMkkgMwg', 15, '25-843-787-7479', 4641.08, 'riously even requests above the exp'); +INSERT INTO `supplier` VALUES (755, 'Supplier#000000755', 'IRW3Y6qorkh4GBy4gHSpVTF5L', 15, '25-750-724-4757', 9046.17, 'ding accounts was. carefully express ac'); +INSERT INTO `supplier` VALUES (178, 'Supplier#000000178', 'VJ9DInoVjbDg', 16, '26-471-122-2582', 4693.27, 'hely final foxes instead of the express, expres'); +INSERT INTO `supplier` VALUES (8, 'Supplier#000000008', '9Sq4bBH2FQEmaFOocY45sRTxo6yuoG', 17, '27-498-742-3860', 7627.85, 'al pinto beans. asymptotes haggl'); +INSERT INTO `supplier` VALUES (754, 'Supplier#000000754', 'GLSmwjGddmyMx2D BlOKJm1Ji', 17, '27-971-371-9417', 7425.83, 'leep. pinto beans haggle according to the unusual, e'); +INSERT INTO `supplier` VALUES (656, 'Supplier#000000656', 'mQXqRMgstvOI', 19, '29-633-362-8481', 8069.74, 'ronic packages integrate. even excuses integrate carefully ruthlessly bold packages. regular ideas a'); +INSERT INTO `supplier` VALUES (925, 'Supplier#000000925', 'x3n4pg,q28EckYO,613G7seoAmTPSX0jTvDvM2U', 19, '29-398-723-8226', 406.59, 'regular packages can haggle acro'); +INSERT INTO `supplier` VALUES (123, 'Supplier#000000123', 'IqRn20xsj5ibqAQjb6YNQf0xah', 19, '29-602-688-1506', 5726.19, 'nts x-ray quickly according to t'); +INSERT INTO `supplier` VALUES (952, 'Supplier#000000952', 'n8W6MbJdih Ckh6wDvYJz84ZmabvK4yQDz', 22, '32-276-558-4960', 8621.52, 'cajole permanently? carefully slow deposits cajole quickly. regular'); +INSERT INTO `supplier` VALUES (578, 'Supplier#000000578', 'bn5J0A4426DpcW7m rQ9,qxqJ1KN', 20, '30-105-334-1726', 7428.76, 'carefully about the slyly regular warthogs. special packages above the regular pa'); +INSERT INTO `supplier` VALUES (426, 'Supplier#000000426', 'zjIHPRMAI8vF', 23, '33-576-289-4702', 8621.42, ' requests nag. slyly regular ideas '); +INSERT INTO `supplier` VALUES (939, 'Supplier#000000939', 'mWBKbdzDn3yJNpOT8p', 23, '33-487-125-3117', 7815.06, 'efully. final requests after the unusual requests wake fluffily after the furiously r'); +INSERT INTO `supplier` VALUES (202, 'Supplier#000000202', 'NALZjSfea6SY zB1,I09OJYGrA8bwR4pU', 23, '33-549-918-5721', 6739.52, 'courts cajole bold, special accounts. bold packages haggle re'); +INSERT INTO `supplier` VALUES (84, 'Supplier#000000084', 'DcYjWMiZGQqEKOJi4wAmIV08ikx', 24, '34-869-118-7803', 4780.93, 'even depths. regular foxes use slyly. theod'); +INSERT INTO `supplier` VALUES (87, 'Supplier#000000087', 'WCw7URDj8zoZ7tqC3cpm7', 24, '34-860-229-1674', 4746.66, 'all are quickly after the ironic platelets. pending dolphins are. final the'); +INSERT INTO `supplier` VALUES (828, 'Supplier#000000828', '0B2aPqJ6KTEr2fqxuC7z ', 21, '31-911-715-8972', 289.32, 'ions are carefully along the regular, pending pinto beans. special '); +INSERT INTO `supplier` VALUES (870, 'Supplier#000000870', 'QIgRinpKvCLPG', 21, '31-675-338-9417', 3689.14, 'ronic accounts. quickly pending pinto beans after the regular asymptotes sleep furiously'); +INSERT INTO `supplier` VALUES (863, 'Supplier#000000863', 'TsC9OuodnybJhWXq4PFNdEJf9jx2y181N3ilV', 21, '31-589-608-3508', 487.31, 'ounts. fluffily special platelets along the even pinto beans boost'); +DROP TABLE IF EXISTS `customer`; +CREATE TABLE `customer` ( +`c_custkey` int NOT NULL, +`C_NAME` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`C_ADDRESS` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`C_NATIONKEY` int NOT NULL, +`C_PHONE` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`C_ACCTBAL` decimal(15, 2) NOT NULL, +`C_MKTSEGMENT` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`C_COMMENT` varchar(117) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +PRIMARY KEY (`c_custkey`) USING BTREE, +INDEX `CUSTOMER_FK1`(`C_NATIONKEY`) USING BTREE, +CONSTRAINT `customer_ibfk_1` FOREIGN KEY (`C_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `customer_ibfk_2` FOREIGN KEY (`C_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `customer_ibfk_3` FOREIGN KEY (`C_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO customer VALUES (301, 'Customer#000000301', 'FtFq9Cgg5UAzUL', 7, '17-265-345-9265', +9305.05, 'HOUSEHOLD', 'ular, regular notornis sleep along the furiously pending foxes'); +INSERT INTO customer VALUES (71, 'Customer#000000071', 'TlGalgdXWBmMV,6agLyWYDyIz9MKzcY8gl,w6t1B', +7, '17-710-812-5403', -611.19, 'HOUSEHOLD', 'g courts across the regular, final pinto beans are blithely pending ac'); +INSERT INTO customer VALUES (46, 'Customer#000000046', 'eaTXWWm10L9', 6, '16-357-681-2007', +5744.59, 'AUTOMOBILE', 'ctions. accounts sleep furiously even requests. regular, regular accounts cajole blithely around the final pa'); +INSERT INTO customer VALUES (281, 'Customer#000000281', 'x5gJ8IGm2Fo9Jigt', 6, '16-809-382-6446', +4361.70, 'BUILDING', 'fully quiet ideas detect quickly even packages. regular instructions accor'); +DROP TABLE IF EXISTS `orders`; +CREATE TABLE `orders` ( +`o_orderkey` int NOT NULL, +`O_CUSTKEY` int NOT NULL, +`O_ORDERSTATUS` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`O_TOTALPRICE` decimal(15, 2) NOT NULL, +`O_ORDERDATE` date NOT NULL, +`O_ORDERPRIORITY` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`O_CLERK` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`O_SHIPPRIORITY` int NOT NULL, +`O_COMMENT` varchar(79) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +PRIMARY KEY (`o_orderkey`) USING BTREE, +INDEX `ORDERS_FK1`(`O_CUSTKEY`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO `orders` VALUES (118370, 301, 'P', 168147.19, '1995-04-29', '5-LOW', 'Clerk#000000272', 0, 'ickly. regular requests play furiously. slyly express accounts a'); +INSERT INTO `orders` VALUES (520707, 71, 'O', 116317.26, '1996-06-01', '3-MEDIUM', 'Clerk#000000381', 0, 'blithely permanent'); +INSERT INTO `orders` VALUES (584192, 46, 'P', 180239.21, '1995-03-19', '1-URGENT', 'Clerk#000000844', 0, 'to the final requests. quickl'); +INSERT INTO `orders` VALUES (479207, 281, 'O ', 169385.50, '1996-02-22', '2-HIGH', 'Clerk#000000930', 0, 'yly. carefully express deposits poach regular re'); +INSERT INTO `orders` VALUES (554307, 2915, 'O', 206510.07, '1998-06-13', '2-HIGH', 'Clerk#000000524', 0, 'ely about the ironic, final foxes. quickly bold accou'); +INSERT INTO `orders` VALUES (111521, 7412, 'O', 182164.10, '1997-02-15', '4-NOT SPECIFIED', 'Clerk#000000329', 0, 'ites are carefully among the furiously ironic acco'); +INSERT INTO `orders` VALUES (444225, 10408, 'O', 306687.42, '1996-06-20', '1-URGENT', 'Clerk#000000096', 0, 'kages use slyly over the slyly blithe dolph'); +INSERT INTO `orders` VALUES (245857, 8044, 'O', 318891.86, '1995-12-24', '5-LOW', 'Clerk#000000721', 0, 'ajole slyly furiously final packages. blithely final ex'); +INSERT INTO `orders` VALUES (132321, 12107, 'F', 243124.18, '1994-02-07', '1-URGENT', 'Clerk#000000853', 0, 'fily final asymptotes sleep furiously across the regul'); +INSERT INTO `orders` VALUES (438816, 6655, 'F', 221287.80, '1993-02-24', '5-LOW', 'Clerk#000000276', 0, 'blithely quickly express pac'); +INSERT INTO `orders` VALUES (74497, 3776, 'F', 191392.39, '1992-12-14', '3-MEDIUM', 'Clerk#000000444', 0, 'fully near the pending, even requests. blithe'); +INSERT INTO `orders` VALUES (89510, 5669, 'O', 216768.31, '1998-05-06', '1-URGENT', 'Clerk#000000190', 0, 'oxes. furiously pending d'); +INSERT INTO `orders` VALUES (157444, 12382, 'O', 215961.16, '1997-02-05', '5-LOW', 'Clerk#000000322', 0, 'carefully silent instructions. carefully thin t'); +INSERT INTO `orders` VALUES (233090, 13514, 'O', 278845.12, '1996-03-24', '3-MEDIUM', 'Clerk#000000736', 0, 'ts above the slyly ruthless requests boost furiously fi'); +INSERT INTO `orders` VALUES (287744, 2327, 'F', 41484.05, '1995-02-04', '1-URGENT', 'Clerk#000000176', 0, 'asymptotes are. furiously regular excuses detect across the blithely fi'); +INSERT INTO `orders` VALUES (91747, 12295, 'F', 157138.78, '1994-09-18', '4-NOT SPECIFIED', 'Clerk#000000591', 0, 'ggle among the blithely unusual instructions. furiously unusual reque'); +INSERT INTO `orders` VALUES (54277, 3023, 'F', 253275.46, '1993-01-03', '1-URGENT', 'Clerk#000000163', 0, 'bove the deposits. carefully unusual sheaves cajole bli'); +INSERT INTO `orders` VALUES (75299, 11546, 'F', 200783.02, '1992-12-19', '2-HIGH', 'Clerk#000000117', 0, 'riously ironic deposits. silent accounts nag. carefully permanent not'); +INSERT INTO `orders` VALUES (529379, 7471, 'O', 274221.23, '1998-04-16', '5-LOW', 'Clerk#000000698', 0, 'usly bold ideas run furiously along the blithely unusual requests'); +INSERT INTO `orders` VALUES (32005, 10379, 'O', 207579.11, '1997-06-01', '4-NOT SPECIFIED', 'Clerk#000000765', 0, 'fily even foxes are slyly requests: careful theodolites haggle slyly '); +INSERT INTO `orders` VALUES (7907, 5645, 'O', 157133.02, '1996-10-10', '5-LOW', 'Clerk#000000418', 0, 'ly even requests wake slyly along the blithely regular packages. sl'); +INSERT INTO `orders` VALUES (196260, 9337, 'O', 200452.87, '1995-12-14', '5-LOW', 'Clerk#000000890', 0, 'sts integrate. furiously special instructions believe quickly amo'); +INSERT INTO `orders` VALUES (346592, 13015, 'F', 182905.27, '1994-08-16', '1-URGENT', 'Clerk#000000849', 0, 'lly. blithely ironic packages are furiously ironic accounts. ca'); +INSERT INTO `orders` VALUES (388736, 8510, 'F', 56404.94, '1993-03-11', '3-MEDIUM', 'Clerk#000000617', 0, 'o beans sleep blithely alongs'); +INSERT INTO `orders` VALUES (552771, 7894, 'F', 334693.22, '1992-04-25', '2-HIGH', 'Clerk#000000691', 0, 'yly unusual dependencies nag blithely among the flu'); +INSERT INTO `orders` VALUES (56134, 11779, 'O', 243929.66, '1998-04-01', '2-HIGH', 'Clerk#000000404', 0, 'uriously ironic requests cajole ideas. blithely r'); +INSERT INTO `orders` VALUES (226145, 7430, 'O', 60709.47, '1997-10-27', '4-NOT SPECIFIED', 'Clerk#000000644', 0, 'pinto beans. regular p'); +INSERT INTO `orders` VALUES (35427, 3022, 'O', 65591.02, '1996-02-25', '4-NOT SPECIFIED', 'Clerk#000000321', 0, 'onic asymptotes! stealthily ruthless Tiresias nag. carefully e'); +INSERT INTO `orders` VALUES (183524, 11161, 'O', 278859.04, '1995-07-07', '5-LOW', 'Clerk#000000879', 0, ' affix furiously. stealthy, regular accounts haggle carefully express package'); +INSERT INTO `orders` VALUES (247297, 2053, 'F', 278670.11, '1994-09-04', '1-URGENT', 'Clerk#000000213', 0, 'rint furiously ironic, unusua'); +INSERT INTO `orders` VALUES (201607, 14615, 'F', 137139.20, '1993-01-09', '3-MEDIUM', 'Clerk#000000008', 0, ' accounts breach slyly. entic'); +INSERT INTO `orders` VALUES (10948, 6694, 'F', 227941.08, '1992-08-14', '3-MEDIUM', 'Clerk#000000489', 0, 'nic grouches detect stealthily fluffily even de'); +INSERT INTO `orders` VALUES (519911, 2474, 'O', 85447.40, '1998-05-09', '5-LOW', 'Clerk#000000901', 0, 'ld, final instructions cajole slyly of the slyly ironi'); +INSERT INTO `orders` VALUES (292454, 6178, 'O', 237065.90, '1997-07-28', '5-LOW', 'Clerk#000000570', 0, 'ites. final, sly requests boost slyly. furiously even shea'); +INSERT INTO `orders` VALUES (233921, 2129, 'O', 163162.77, '1996-02-09', '2-HIGH', 'Clerk#000000382', 0, 'fluffy packages: carefully speci'); +INSERT INTO `orders` VALUES (562599, 14189, 'P', 246108.56, '1995-05-17', '3-MEDIUM', 'Clerk#000000899', 0, 'ding packages. quickly ironic pinto beans above the blithely fl'); +INSERT INTO `orders` VALUES (20199, 2923, 'F', 208687.85, '1994-04-27', '1-URGENT', 'Clerk#000000933', 0, 'lar foxes alongside of the quickly even dolphi'); +INSERT INTO `orders` VALUES (375971, 5954, 'F', 319538.48, '1993-03-26', '5-LOW', 'Clerk#000000129', 0, 'ts hang. slyly regular requests haggle furi'); +INSERT INTO `orders` VALUES (156774, 9308, 'F', 171093.18, '1992-09-11', '2-HIGH', 'Clerk#000000564', 0, 'ans. warhorses sleep. bold accounts promise'); +INSERT INTO `orders` VALUES (281319, 10241, 'O', 94440.21, '1998-04-03', '3-MEDIUM', 'Clerk#000000569', 0, 'en theodolites. blithely express accounts are furiously. stealthil'); +INSERT INTO `orders` VALUES (25029, 13751, 'O', 49638.36, '1997-11-15', '2-HIGH', 'Clerk#000000284', 0, 'ar foxes. blithely even e'); +INSERT INTO `orders` VALUES (180997, 7627, 'O', 164460.51, '1996-08-28', '3-MEDIUM', 'Clerk#000000989', 0, ' furiously ironic deco'); +INSERT INTO `orders` VALUES (545542, 11422, 'O', 269307.75, '1995-07-27', '5-LOW', 'Clerk#000000788', 0, 'ptotes sleep slyly ironic foxes. pending requests integrate fu'); +INSERT INTO `orders` VALUES (111235, 979, 'F', 242840.39, '1994-06-12', '2-HIGH', 'Clerk#000000464', 0, 'old, pending theodolites. q'); +INSERT INTO `orders` VALUES (71975, 12628, 'F', 206803.03, '1993-10-14', '2-HIGH', 'Clerk#000000948', 0, 'onically ironic instructions'); +INSERT INTO `orders` VALUES (284743, 1295, 'F', 89977.99, '1992-02-28', '5-LOW', 'Clerk#000000088', 0, 'ly special requests dazzle blithely. silent packages are quickly r'); +INSERT INTO `orders` VALUES (239905, 6661, 'O', 222791.73, '1998-01-17', '5-LOW', 'Clerk#000000574', 0, ' final dinos according to the carefully un'); +INSERT INTO `orders` VALUES (77026, 3913, 'O', 174749.79, '1997-01-16', '1-URGENT', 'Clerk#000000807', 0, 'equests at the slyly special instructions use furiously after the regular i'); +INSERT INTO `orders` VALUES (56902, 8291, 'O', 150428.22, '1996-11-10', '4-NOT SPECIFIED', 'Clerk#000000788', 0, 'deposits wake never among the regular courts. bold, express asympt'); +INSERT INTO `orders` VALUES (591970, 14726, 'P', 270683.83, '1995-05-10', '5-LOW', 'Clerk#000000408', 0, 'bold accounts. express, regular accounts engage furiously even, ir'); +INSERT INTO `orders` VALUES (290081, 8926, 'F', 159281.61, '1994-07-23', '4-NOT SPECIFIED', 'Clerk#000000530', 0, 'y special deposits alongside of the'); +INSERT INTO `orders` VALUES (240676, 7609, 'F', 149107.47, '1993-09-13', '5-LOW', 'Clerk#000000803', 0, 'mptotes lose about the fluffily regular requ'); +INSERT INTO `orders` VALUES (543332, 11716, 'F', 251043.20, '1992-11-25', '5-LOW', 'Clerk#000000635', 0, 's use slyly final requests.'); +INSERT INTO `orders` VALUES (60162, 8227, 'O', 27699.32, '1998-07-21', '3-MEDIUM', 'Clerk#000000381', 0, 're. furiously ironic acc'); +INSERT INTO `orders` VALUES (28391, 5416, 'O', 177042.21, '1997-12-31', '4-NOT SPECIFIED', 'Clerk#000000302', 0, 'ts. express, regular p'); +INSERT INTO `orders` VALUES (143237, 12463, 'O', 137599.97, '1996-06-17', '3-MEDIUM', 'Clerk#000000054', 0, 't carefully packages. quickly regular do'); +INSERT INTO `orders` VALUES (184738, 2479, 'F', 264759.05, '1995-02-24', '2-HIGH', 'Clerk#000000116', 0, '. furiously even ideas wake carefully. furiously final'); +INSERT INTO `orders` VALUES (355009, 10513, 'F', 258908.67, '1994-10-11', '2-HIGH', 'Clerk#000000090', 0, ' the regular, final packages sleep among the regular cour'); +INSERT INTO `orders` VALUES (267012, 5912, 'F', 140872.95, '1993-05-16', '4-NOT SPECIFIED', 'Clerk#000000004', 0, 'onic theodolites wake slyly after the carefully regular ideas. quickl'); +INSERT INTO `orders` VALUES (463459, 13636, 'F', 166984.44, '1992-09-18', '3-MEDIUM', 'Clerk#000000346', 0, 'blithely above the bu'); +INSERT INTO `orders` VALUES (158240, 2822, 'O', 198647.49, '1998-04-02', '4-NOT SPECIFIED', 'Clerk#000000923', 0, 'ymptotes nag fluffily regular theodolites. enticingl'); +INSERT INTO `orders` VALUES (101056, 11518, 'O', 243377.30, '1997-04-24', '2-HIGH', 'Clerk#000000380', 0, ' warhorses cajole bold, special deposits. blithely exp'); +INSERT INTO `orders` VALUES (374149, 451, 'O', 81750.52, '1996-04-12', '4-NOT SPECIFIED', 'Clerk#000000866', 0, 'ts are furiously. carefully special pac'); +INSERT INTO `orders` VALUES (561857, 13111, 'O', 249337.85, '1995-12-13', '1-URGENT', 'Clerk#000000555', 0, 'ly ironic deposits. fin'); +INSERT INTO `orders` VALUES (422529, 1943, 'F', 158004.97, '1994-04-10', '5-LOW', 'Clerk#000000238', 0, 's wake slyly among the always regular ideas. pending,'); +INSERT INTO `orders` VALUES (186275, 12335, 'F', 277388.41, '1993-08-25', '3-MEDIUM', 'Clerk#000000370', 0, 'y final packages. carefully ironic requests nag silently reg'); +INSERT INTO `orders` VALUES (203457, 8491, 'F', 210610.26, '1992-07-09', '2-HIGH', 'Clerk#000000864', 0, 'ronic requests. instructions wake al'); +INSERT INTO `orders` VALUES (413282, 11311, 'O', 90313.25, '1998-04-18', '3-MEDIUM', 'Clerk#000000435', 0, 'e silent asymptotes grow fluffily carefully final cou'); +INSERT INTO `orders` VALUES (93794, 232, 'O', 228122.85, '1997-08-08', '2-HIGH', 'Clerk#000000480', 0, 'elets cajole quickly about the blithely busy pinto be'); +INSERT INTO `orders` VALUES (550241, 4813, 'O', 218976.24, '1996-01-13', '5-LOW', 'Clerk#000000043', 0, 'usly even dependencies affix deposits. furiously regular excu'); +INSERT INTO `orders` VALUES (340576, 12532, 'O', 316138.21, '1995-12-23', '5-LOW', 'Clerk#000000806', 0, 'gular requests detect furiously. enticing, special accounts will have to cajo'); +INSERT INTO `orders` VALUES (36896, 6136, 'F', 214441.63, '1994-11-04', '1-URGENT', 'Clerk#000000699', 0, 's cajole fluffily brave theodolites. express requests sleep furi'); +INSERT INTO `orders` VALUES (71269, 10151, 'F', 114358.27, '1993-01-20', '5-LOW', 'Clerk#000000766', 0, ' even packages haggle sl'); +INSERT INTO `orders` VALUES (391013, 6413, 'F', 305358.46, '1992-03-28', '4-NOT SPECIFIED', 'Clerk#000000729', 0, '. fluffily special asymptotes haggle blithe'); +INSERT INTO `orders` VALUES (108838, 4615, 'O', 255956.94, '1998-01-14', '1-URGENT', 'Clerk#000000374', 0, 'ckly bold packages sle'); +INSERT INTO `orders` VALUES (440067, 11368, 'O', 105309.92, '1997-03-10', '4-NOT SPECIFIED', 'Clerk#000000394', 0, 'final realms sleep. blithely unusual '); +INSERT INTO `orders` VALUES (79333, 5875, 'O', 193685.31, '1996-05-24', '4-NOT SPECIFIED', 'Clerk#000000486', 0, 'iously pending requests affix fluffily. blith'); +INSERT INTO `orders` VALUES (248417, 12583, 'O', 81229.81, '1995-09-14', '5-LOW', 'Clerk#000000554', 0, 'ly silent packages use pend'); +INSERT INTO `orders` VALUES (247557, 203, 'F', 221236.41, '1994-10-28', '2-HIGH', 'Clerk#000000062', 0, 'hely ironic packages are. ironic deposits haggle. packages boost slyly a'); +INSERT INTO `orders` VALUES (24866, 7361, 'F', 119100.11, '1993-12-05', '4-NOT SPECIFIED', 'Clerk#000000941', 0, 'ajole blithely slyly final deposits. furiously regul'); +INSERT INTO `orders` VALUES (439175, 9439, 'F', 119521.71, '1992-06-22', '4-NOT SPECIFIED', 'Clerk#000000622', 0, 'ial accounts use across the deposits.'); +INSERT INTO `orders` VALUES (442278, 5485, 'O', 138815.96, '1998-04-07', '2-HIGH', 'Clerk#000000901', 0, 'y above the even, pend'); +INSERT INTO `orders` VALUES (498596, 11428, 'O', 207055.52, '1997-05-06', '1-URGENT', 'Clerk#000000413', 0, 'e quickly quickly special foxes. special accounts sleep'); +INSERT INTO `orders` VALUES (359047, 9205, 'O', 147075.49, '1996-08-17', '2-HIGH', 'Clerk#000000643', 0, 'ven deposits on the furiously ironic platelets sleep never carefully ironi'); +INSERT INTO `orders` VALUES (480391, 14464, 'O', 228575.29, '1995-07-23', '3-MEDIUM', 'Clerk#000000653', 0, 'ar instructions nag slyly slyly express dolphins. unusual, ironic foxes hag'); +INSERT INTO `orders` VALUES (358918, 5815, 'F', 130495.07, '1994-05-06', '2-HIGH', 'Clerk#000000008', 0, 'thely express deposits. bli'); +INSERT INTO `orders` VALUES (408641, 8767, 'F', 103243.69, '1993-08-04', '4-NOT SPECIFIED', 'Clerk#000000167', 0, 'le furiously blithely pending pinto beans. furiously'); +INSERT INTO `orders` VALUES (117221, 7189, 'F', 155260.65, '1992-12-14', '3-MEDIUM', 'Clerk#000000352', 0, 'ncies haggle evenly. quickly ironic deposits haggle blithely a'); +INSERT INTO `orders` VALUES (204871, 1828, 'O', 106488.18, '1998-03-22', '4-NOT SPECIFIED', 'Clerk#000000783', 0, 'ithely fluffily bold ide'); +INSERT INTO `orders` VALUES (67426, 8593, 'O', 295962.76, '1997-03-08', '3-MEDIUM', 'Clerk#000000699', 0, 'ake always carefully final foxes. finally unusual requests affix a'); +INSERT INTO `orders` VALUES (156000, 8777, 'O', 132256.74, '1996-10-12', '3-MEDIUM', 'Clerk#000000505', 0, 'olites use quickly against the carefully ironic warhors'); +INSERT INTO `orders` VALUES (68322, 9095, 'O', 227844.86, '1995-10-08', '2-HIGH', 'Clerk#000000930', 0, 'uiet hockey players. blithely regular packages sleep above the fina'); +INSERT INTO `orders` VALUES (185315, 7027, 'F', 165274.21, '1994-08-24', '2-HIGH', 'Clerk#000000762', 0, 'es at the quickly special '); +INSERT INTO `orders` VALUES (380708, 796, 'F', 136913.45, '1993-03-09', '3-MEDIUM', 'Clerk#000000473', 0, 'y special courts detect ironically accounts?'); +INSERT INTO `orders` VALUES (214951, 535, 'F', 182746.71, '1992-04-12', '1-URGENT', 'Clerk#000000816', 0, 'yly at the excuses. f'); +INSERT INTO `orders` VALUES (370689, 10045, 'O', 94356.50, '1998-07-09', '3-MEDIUM', 'Clerk#000000159', 0, 'ep. quickly special requests cajole slyly along the closel'); +INSERT INTO `orders` VALUES (408548, 12508, 'O', 196969.96, '1997-04-29', '1-URGENT', 'Clerk#000000591', 0, 'ic attainments cajole abo'); +INSERT INTO `orders` VALUES (455750, 8741, 'O', 70777.01, '1996-05-26', '5-LOW', 'Clerk#000000159', 0, 'along the final requests. fluffily bold dolphins at the ca'); +INSERT INTO `orders` VALUES (283046, 4640, 'O', 279900.46, '1995-11-21', '3-MEDIUM', 'Clerk#000000280', 0, ' pending, unusual packages. pinto b'); +INSERT INTO `orders` VALUES (92258, 5122, 'F', 165050.88, '1994-04-14', '4-NOT SPECIFIED', 'Clerk#000000926', 0, 'al requests sleep-- finally regular wa'); +INSERT INTO `orders` VALUES (206208, 656, 'F', 76543.28, '1993-10-13', '1-URGENT', 'Clerk#000000245', 0, 'tions wake. even attainments nag'); +INSERT INTO `orders` VALUES (145507, 4564, 'F', 193243.57, '1992-07-06', '1-URGENT', 'Clerk#000000794', 0, 'lyly final deposits cajole quickly among the fina'); +INSERT INTO `orders` VALUES (153351, 5620, 'O', 255270.94, '1998-04-21', '4-NOT SPECIFIED', 'Clerk#000000450', 0, 'nal dependencies. carefully enticing asymptotes until the never ironic theodol'); +INSERT INTO `orders` VALUES (466977, 2878, 'O', 262631.99, '1997-09-03', '2-HIGH', 'Clerk#000000643', 0, 'thely. unusual accounts about the fluffily even deposits'); +INSERT INTO `orders` VALUES (103810, 8923, 'O', 245711.92, '1996-05-15', '1-URGENT', 'Clerk#000000840', 0, 'e deposits. furiously pending foxes detect final, sly forges. caref'); +INSERT INTO `orders` VALUES (110178, 5164, 'O', 205720.59, '1995-06-15', '3-MEDIUM', 'Clerk#000000299', 0, ' against the blithely regular requests. furiously final deposi'); +INSERT INTO `orders` VALUES (13698, 14821, 'F', 175122.99, '1994-08-05', '4-NOT SPECIFIED', 'Clerk#000000640', 0, 'iously bold deposits are carefully blithely unusual '); +INSERT INTO `orders` VALUES (172710, 2641, 'F', 210749.12, '1993-10-31', '5-LOW', 'Clerk#000000500', 0, 'ly bold pearls. quickly ironic requests affix accounts: blithely final i'); +INSERT INTO `orders` VALUES (528513, 11021, 'F', 164509.80, '1992-05-22', '2-HIGH', 'Clerk#000000599', 0, ' the decoys. furiously bold packages cajole slyly. even, bold deposits '); +INSERT INTO `orders` VALUES (420295, 298, 'O', 170798.06, '1998-01-06', '2-HIGH', 'Clerk#000000056', 0, 'deas cajole blithely. asymptotes boost furiously ar'); +INSERT INTO `orders` VALUES (150465, 12545, 'O', 192854.70, '1997-01-13', '2-HIGH', 'Clerk#000000638', 0, ', unusual pinto beans are slyly final epitaphs. furiously regular requests af'); +INSERT INTO `orders` VALUES (139616, 9278, 'O', 156706.85, '1996-11-04', '4-NOT SPECIFIED', 'Clerk#000000608', 0, 'l accounts about the ironic, regular packages snooze car'); +INSERT INTO `orders` VALUES (180832, 12367, 'O', 365903.02, '1995-11-04', '2-HIGH', 'Clerk#000000106', 0, 'nal accounts. grouches breach against the furiously fluffy theo'); +INSERT INTO `orders` VALUES (312962, 10448, 'F', 76205.53, '1994-03-03', '1-URGENT', 'Clerk#000000131', 0, ', special deposits sleep instru'); +INSERT INTO `orders` VALUES (111942, 5354, 'F', 142010.74, '1993-01-26', '2-HIGH', 'Clerk#000000831', 0, 'nic requests. carefully bold theodolites sleep. blithely special package'); +INSERT INTO `orders` VALUES (188032, 3595, 'F', 231980.13, '1992-06-17', '5-LOW', 'Clerk#000000584', 0, 'counts boost blithely against the slyly ironic notornis-- regular'); +INSERT INTO `orders` VALUES (315844, 9257, 'O', 80492.03, '1998-07-28', '5-LOW', 'Clerk#000000788', 0, 'n sublate. fluffily'); +INSERT INTO `orders` VALUES (324771, 2933, 'O', 231373.80, '1997-01-31', '5-LOW', 'Clerk#000000698', 0, 'l, blithe requests boost quickly even plat'); +INSERT INTO `orders` VALUES (323234, 12136, 'O', 226785.51, '1996-11-05', '5-LOW', 'Clerk#000000685', 0, 's. ideas use. sentiments do wake among the ironic re'); +INSERT INTO `orders` VALUES (229475, 9820, 'O', 245629.36, '1995-12-21', '5-LOW', 'Clerk#000000761', 0, 's. final, unusual packages affix against'); +INSERT INTO `orders` VALUES (364805, 8956, 'F', 23880.77, '1994-05-19', '3-MEDIUM', 'Clerk#000000275', 0, 'n carefully above the carefully even instructions. quickly final pa'); +INSERT INTO `orders` VALUES (246052, 9604, 'F', 65364.61, '1993-08-15', '2-HIGH', 'Clerk#000000205', 0, 'ticing, special platelets. ironic, ironic packages can was'); +INSERT INTO `orders` VALUES (159940, 9760, 'F', 57327.04, '1992-10-22', '5-LOW', 'Clerk#000000941', 0, ' are quietly above the furiously express packages. qui'); +INSERT INTO `orders` VALUES (88773, 2074, 'O', 193398.58, '1998-04-29', '4-NOT SPECIFIED', 'Clerk#000000568', 0, 'asymptotes. even, final ideas a'); +INSERT INTO `orders` VALUES (61059, 12005, 'O', 163479.86, '1997-12-02', '4-NOT SPECIFIED', 'Clerk#000000155', 0, 'le quickly even package'); +INSERT INTO `orders` VALUES (75712, 12296, 'O', 97092.35, '1996-01-04', '3-MEDIUM', 'Clerk#000000285', 0, 'nic deposits wake furiously '); +INSERT INTO `orders` VALUES (502210, 12883, 'O', 30929.99, '1995-07-11', '4-NOT SPECIFIED', 'Clerk#000000717', 0, ' the quickly pending foxes breach sp'); +INSERT INTO `orders` VALUES (581318, 6445, 'F', 229949.49, '1994-09-20', '3-MEDIUM', 'Clerk#000000850', 0, 'ourts across the carefully final requests use quickly slyly '); +INSERT INTO `orders` VALUES (262180, 10639, 'F', 35438.89, '1993-01-24', '2-HIGH', 'Clerk#000000735', 0, 'express, regular dep'); +INSERT INTO `orders` VALUES (442529, 7211, 'F', 100580.86, '1992-09-04', '1-URGENT', 'Clerk#000000376', 0, 'hely bold requests. regular, ironic deposits '); +INSERT INTO `orders` VALUES (393062, 6769, 'O', 124823.56, '1998-05-28', '2-HIGH', 'Clerk#000000072', 0, 'the packages. furiously regular deposits about the ironic packages sleep '); +INSERT INTO `orders` VALUES (440802, 3157, 'O', 98539.44, '1997-07-20', '5-LOW', 'Clerk#000000501', 0, 'kages haggle blithely. asymptotes use slyly. furi'); +INSERT INTO `orders` VALUES (129282, 2881, 'O', 214294.02, '1996-07-14', '1-URGENT', 'Clerk#000000962', 0, 'eas wake even, regular instructions: s'); +INSERT INTO `orders` VALUES (53189, 7924, 'O', 36320.43, '1995-08-24', '1-URGENT', 'Clerk#000000127', 0, 'blithely regular de'); +INSERT INTO `orders` VALUES (220419, 2569, 'F', 118619.37, '1994-04-07', '4-NOT SPECIFIED', 'Clerk#000000208', 0, 'tain. bold deposits about t'); +INSERT INTO `orders` VALUES (235171, 7286, 'F', 339797.80, '1993-06-11', '2-HIGH', 'Clerk#000000801', 0, 'fully silent excuses about the special requests wake against the instru'); +INSERT INTO `orders` VALUES (406339, 14738, 'F', 218329.22, '1992-06-16', '1-URGENT', 'Clerk#000000154', 0, ' dinos. special, even excuses along the bold excuses grow carefully even, un'); +INSERT INTO `orders` VALUES (78567, 8092, 'O', 179276.82, '1998-05-26', '5-LOW', 'Clerk#000000281', 0, 'are quickly even, unusual pinto beans. fi'); +INSERT INTO `orders` VALUES (451809, 10708, 'O', 65517.87, '1997-09-16', '2-HIGH', 'Clerk#000000580', 0, 'y after the blithely ironic accounts. slyly regular ac'); +INSERT INTO `orders` VALUES (133601, 12047, 'O', 203661.30, '1996-05-10', '2-HIGH', 'Clerk#000000520', 0, 'regular packages bo'); +INSERT INTO `orders` VALUES (467232, 353, 'F', 74983.09, '1995-01-26', '5-LOW', 'Clerk#000000458', 0, 'dolphins play blithely final, regular foxes. dogg'); +INSERT INTO `orders` VALUES (208480, 5143, 'F', 222813.18, '1994-12-29', '4-NOT SPECIFIED', 'Clerk#000000883', 0, 'ress hockey players ca'); +INSERT INTO `orders` VALUES (487680, 2024, 'F', 149428.95, '1993-09-25', '3-MEDIUM', 'Clerk#000000047', 0, 'regular, final instructions boost even,'); +INSERT INTO `orders` VALUES (363841, 4426, 'F', 169547.16, '1992-03-21', '5-LOW', 'Clerk#000000827', 0, 'e blithely bold, bold deposits. furiously even soma'); +INSERT INTO `orders` VALUES (216454, 10072, 'O', 214680.26, '1998-01-18', '3-MEDIUM', 'Clerk#000000322', 0, 'platelets after the regular '); +INSERT INTO `orders` VALUES (61954, 8164, 'O', 164853.36, '1997-01-14', '2-HIGH', 'Clerk#000000562', 0, 'press platelets cajole fluffily'); +INSERT INTO `orders` VALUES (150531, 2335, 'O', 63449.78, '1996-08-28', '1-URGENT', 'Clerk#000000516', 0, 'regular courts. orbits detect furiously. p'); +INSERT INTO `orders` VALUES (265476, 4067, 'P', 78738.68, '1995-04-16', '2-HIGH', 'Clerk#000000375', 0, 'ular, final deposits. furiously pending platelets boost a'); +INSERT INTO `orders` VALUES (205574, 13831, 'F', 95856.59, '1994-03-08', '1-URGENT', 'Clerk#000000033', 0, 'ording to the closely unusual accounts. ironic accounts are carefully amo'); +INSERT INTO `orders` VALUES (474403, 3341, 'F', 57130.19, '1993-05-17', '3-MEDIUM', 'Clerk#000000413', 0, 'ess realms are fluffily even i'); +INSERT INTO `orders` VALUES (94338, 10078, 'F', 132893.14, '1992-10-11', '3-MEDIUM', 'Clerk#000000391', 0, 'counts. slyly regular asymptotes agains'); +INSERT INTO `orders` VALUES (126337, 4126, 'O', 349901.54, '1998-02-22', '1-URGENT', 'Clerk#000000124', 0, 'ckages. slyly stealthy requests i'); +INSERT INTO `orders` VALUES (121606, 13733, 'O', 326252.88, '1997-02-25', '5-LOW', 'Clerk#000000517', 0, 'ously special packages against the pending instructions cajole fluffi'); +INSERT INTO `orders` VALUES (509413, 7315, 'O', 202720.54, '1996-04-16', '1-URGENT', 'Clerk#000000580', 0, 'ackages wake slyly. bold, unusual packages breach. blithely'); +INSERT INTO `orders` VALUES (192197, 6175, 'O', 2453.65, '1995-08-07', '1-URGENT', 'Clerk#000000126', 0, 'ily express platelets. furiously final sentiments are b'); +INSERT INTO `orders` VALUES (32358, 14771, 'F', 245782.82, '1994-06-10', '2-HIGH', 'Clerk#000000174', 0, 'final foxes sleep furi'); +INSERT INTO `orders` VALUES (42375, 3332, 'F', 188459.13, '1993-10-02', '2-HIGH', 'Clerk#000000728', 0, ' enticing deposits. blithely final theodolites ar'); +INSERT INTO `orders` VALUES (53984, 4147, 'F', 59589.68, '1992-12-11', '3-MEDIUM', 'Clerk#000000040', 0, 's wake about the blithely final'); +INSERT INTO `orders` VALUES (52167, 12748, 'O', 253368.62, '1998-07-11', '1-URGENT', 'Clerk#000000971', 0, 'slyly special deposits cajole orbi'); +INSERT INTO `orders` VALUES (350083, 7954, 'O', 31094.84, '1997-06-06', '1-URGENT', 'Clerk#000000516', 0, 'ress dinos are quickly. slyly ironic acco'); +INSERT INTO `orders` VALUES (407073, 11647, 'O', 152916.08, '1996-04-03', '3-MEDIUM', 'Clerk#000000793', 0, 'cies. special, regular deposits among the slyly ironic packages b'); +INSERT INTO `orders` VALUES (22532, 5971, 'F', 54887.64, '1995-02-09', '1-URGENT', 'Clerk#000000907', 0, 'ust have to sleep about th'); +INSERT INTO `orders` VALUES (19047, 5740, 'F', 236935.71, '1994-01-29', '2-HIGH', 'Clerk#000000036', 0, 'ake. instructions integrate along the furiously unus'); +INSERT INTO `orders` VALUES (166243, 8321, 'F', 248901.42, '1993-12-27', '3-MEDIUM', 'Clerk#000000340', 0, 't furiously slyly unusual asymptotes. careful'); +INSERT INTO `orders` VALUES (220421, 340, 'F', 94461.44, '1992-02-14', '4-NOT SPECIFIED', 'Clerk#000000323', 0, ' nag carefully after the even p'); +INSERT INTO `orders` VALUES (9287, 7897, 'O', 14628.23, '1998-01-02', '4-NOT SPECIFIED', 'Clerk#000000636', 0, 'ously unusual packages. regular foxes detect. blithely slow ideas sl'); +INSERT INTO `orders` VALUES (45862, 9674, 'O', 46102.50, '1997-07-02', '4-NOT SPECIFIED', 'Clerk#000000850', 0, 'erns. final requests haggle slyly. theodolites wake after the furio'); +INSERT INTO `orders` VALUES (92002, 131, 'O', 121046.69, '1996-09-09', '2-HIGH', 'Clerk#000000353', 0, 's. regular theodolit'); +INSERT INTO `orders` VALUES (389633, 8653, 'P', 161208.66, '1995-03-19', '1-URGENT', 'Clerk#000000457', 0, 'ites are carefully silent deposits. fluffily ironic request'); +INSERT INTO `orders` VALUES (96739, 8362, 'F', 175525.87, '1994-07-12', '2-HIGH', 'Clerk#000000596', 0, 's was carefully unusual sauternes. furiou'); +INSERT INTO `orders` VALUES (575109, 4259, 'F', 181707.71, '1993-03-25', '3-MEDIUM', 'Clerk#000000461', 0, 'ans. ironic, express platelets use regularly. fluffily regular instru'); +INSERT INTO `orders` VALUES (284578, 2647, 'F', 22278.93, '1992-03-06', '2-HIGH', 'Clerk#000000531', 0, 'ake quickly. final plate'); +INSERT INTO `orders` VALUES (351843, 7504, 'O', 72209.48, '1998-03-01', '2-HIGH', 'Clerk#000000663', 0, 'phins. furiously final theodolites boost daringly care'); +INSERT INTO `orders` VALUES (19014, 10459, 'O', 259321.32, '1997-09-23', '5-LOW', 'Clerk#000000340', 0, 'r dependencies haggle quickly bold accounts; pending dependencies '); +INSERT INTO `orders` VALUES (22436, 7495, 'O', 191816.91, '1996-05-24', '1-URGENT', 'Clerk#000000068', 0, 'ar packages. even, bold foxes wake. dependencies cajole carefully iron'); +INSERT INTO `orders` VALUES (59108, 6067, 'O', 271402.46, '1995-10-08', '5-LOW', 'Clerk#000000259', 0, ' deposits cajole above the quickly ironic deposits. carefully express '); +INSERT INTO `orders` VALUES (593637, 7817, 'F', 208444.44, '1994-11-17', '3-MEDIUM', 'Clerk#000000249', 0, 'ously multipliers. regular requests cajol'); +INSERT INTO `orders` VALUES (15744, 12130, 'F', 48861.07, '1993-03-22', '1-URGENT', 'Clerk#000000939', 0, 'ily ironic pinto beans. ironic, unusual instructions n'); +INSERT INTO `orders` VALUES (303877, 4105, 'F', 201610.61, '1992-11-18', '4-NOT SPECIFIED', 'Clerk#000000745', 0, 'dolites sleep furiously after the even, ironi'); +DROP TABLE IF EXISTS `part`; +CREATE TABLE `part` ( +`p_partkey` int NOT NULL, +`P_NAME` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`P_MFGR` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`P_BRAND` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`P_TYPE` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`P_SIZE` int NOT NULL, +`P_CONTAINER` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`P_RETAILPRICE` decimal(15, 2) NOT NULL, +`P_COMMENT` varchar(23) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +PRIMARY KEY (`p_partkey`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO `part` VALUES (299, 'deep coral dodger green peach', 'Manufacturer#4', 'Brand#41', 'STANDARD ANODIZED COPPER', 26, 'WRAP PKG', 1199.29, 'regular dol'); +INSERT INTO `part` VALUES (316, 'almond rosy green hot midnight', 'Manufacturer#4', 'Brand#41', 'MEDIUM BRUSHED TIN', 9, 'MED CASE', 1216.31, 'deposits haggle'); +INSERT INTO `part` VALUES (119, 'olive metallic slate peach green', 'Manufacturer#4', 'Brand#43', 'LARGE POLISHED STEEL', 30, 'WRAP CASE', 1019.11, 'out the quickly r'); +INSERT INTO `part` VALUES (177, 'indian turquoise purple green spring', 'Manufacturer#2', 'Brand#21', 'MEDIUM BRUSHED STEEL', 42, 'LG BAG', 1077.17, 'ermanently eve'); +INSERT INTO `part` VALUES (300, 'light goldenrod green lime papaya', 'Manufacturer#4', 'Brand#44', 'PROMO ANODIZED BRASS', 1, 'WRAP PACK', 1200.30, 'tructions int'); +INSERT INTO `part` VALUES (242, 'spring green lemon medium olive', 'Manufacturer#3', 'Brand#35', 'SMALL POLISHED STEEL', 42, 'LG BAG', 1142.24, 'ously final theodo'); +INSERT INTO `part` VALUES (886, 'turquoise dodger lemon antique green', 'Manufacturer#5', 'Brand#55', 'LARGE BRUSHED COPPER', 46, 'MED BAG', 1786.88, 'tornis haggle! '); +INSERT INTO `part` VALUES (474, 'papaya green royal burlywood saddle', 'Manufacturer#1', 'Brand#14', 'ECONOMY PLATED STEEL', 45, 'LG PACK', 1374.47, 'ously even reques'); +INSERT INTO `part` VALUES (401, 'almond chiffon indian green dim', 'Manufacturer#2', 'Brand#21', 'ECONOMY POLISHED STEEL', 10, 'SM PKG', 1301.40, 'ideas cajole '); +INSERT INTO `part` VALUES (377, 'green forest rose slate cornflower', 'Manufacturer#4', 'Brand#44', 'STANDARD BURNISHED COPPER', 16, 'WRAP BOX', 1277.37, 'ly regula'); +INSERT INTO `part` VALUES (4, 'cornflower chocolate smoke green pink', 'Manufacturer#3', 'Brand#34', 'SMALL PLATED BRASS', 14, 'MED DRUM', 904.00, 'p furiously r'); +INSERT INTO `part` VALUES (83, 'blush green dim lawn peru', 'Manufacturer#1', 'Brand#12', 'PROMO BURNISHED NICKEL', 47, 'SM CAN', 983.08, 'ly regul'); +INSERT INTO `part` VALUES (577, 'lime green dark misty chiffon', 'Manufacturer#2', 'Brand#22', 'LARGE BRUSHED STEEL', 34, 'JUMBO BAG', 1477.57, 'ding, fur'); +INSERT INTO `part` VALUES (327, 'metallic lavender green firebrick ghost', 'Manufacturer#2', 'Brand#23', 'PROMO POLISHED BRASS', 14, 'SM PACK', 1227.32, 'regular'); +INSERT INTO `part` VALUES (416, 'ghost misty chocolate peach green', 'Manufacturer#1', 'Brand#13', 'MEDIUM POLISHED STEEL', 11, 'WRAP JAR', 1316.41, 'yly pending deposit'); +INSERT INTO `part` VALUES (450, 'sky lace green pale lime', 'Manufacturer#4', 'Brand#43', 'MEDIUM BURNISHED TIN', 23, 'SM CASE', 1350.45, 'slyly'); +INSERT INTO `part` VALUES (3, 'spring green yellow purple cornsilk', 'Manufacturer#4', 'Brand#42', 'STANDARD POLISHED BRASS', 21, 'WRAP CASE', 903.00, 'egular deposits hag'); +INSERT INTO `part` VALUES (35, 'green blush tomato burlywood seashell', 'Manufacturer#4', 'Brand#43', 'MEDIUM ANODIZED BRASS', 14, 'JUMBO PACK', 935.03, 'e carefully furi'); +INSERT INTO `part` VALUES (201, 'dodger white chiffon moccasin green', 'Manufacturer#4', 'Brand#42', 'SMALL POLISHED STEEL', 18, 'JUMBO BAG', 1101.20, ' courts sl'); +INSERT INTO `part` VALUES (175, 'magenta blue chartreuse tan green', 'Manufacturer#1', 'Brand#11', 'PROMO ANODIZED TIN', 45, 'JUMBO JAR', 1075.17, 'ole against the'); +INSERT INTO `part` VALUES (489, 'smoke green blush deep royal', 'Manufacturer#2', 'Brand#22', 'LARGE BURNISHED TIN', 36, 'LG CAN', 1389.48, 'unts. quickly bold id'); +INSERT INTO `part` VALUES (362, 'sienna green ghost rose lawn', 'Manufacturer#1', 'Brand#13', 'ECONOMY POLISHED COPPER', 9, 'JUMBO BAG', 1262.36, 'accounts. furi'); +INSERT INTO `part` VALUES (86, 'green blanched firebrick dim cream', 'Manufacturer#4', 'Brand#44', 'STANDARD PLATED TIN', 37, 'LG CASE', 986.08, ' daring sheaves '); +INSERT INTO `part` VALUES (326, 'sky papaya green azure chiffon', 'Manufacturer#3', 'Brand#34', 'LARGE ANODIZED STEEL', 48, 'JUMBO CAN', 1226.32, 'aggle slyly special f'); +INSERT INTO `part` VALUES (7, 'moccasin green thistle khaki floral', 'Manufacturer#1', 'Brand#11', 'SMALL PLATED COPPER', 45, 'SM BAG', 907.00, 'lyly. ex'); +INSERT INTO `part` VALUES (257, 'blue gainsboro maroon green burnished', 'Manufacturer#4', 'Brand#41', 'ECONOMY POLISHED COPPER', 11, 'SM JAR', 1157.25, 'riously final foxes'); +INSERT INTO `part` VALUES (557, 'firebrick ghost steel green chartreuse', 'Manufacturer#3', 'Brand#35', 'LARGE BURNISHED TIN', 8, 'JUMBO PKG', 1457.55, 'ccounts im'); +INSERT INTO `part` VALUES (905, 'burlywood honeydew cornsilk indian green', 'Manufacturer#2', 'Brand#25', 'PROMO BRUSHED BRASS', 27, 'MED CASE', 1805.90, 'es. furiously ir'); +INSERT INTO `part` VALUES (674, 'tomato chartreuse cornflower green pale', 'Manufacturer#3', 'Brand#35', 'SMALL BRUSHED TIN', 5, 'LG PKG', 1574.67, 'unts use slyly bold'); +INSERT INTO `part` VALUES (872, 'papaya frosted cornflower green almond', 'Manufacturer#1', 'Brand#15', 'MEDIUM PLATED STEEL', 41, 'LG CASE', 1772.87, 'gular inst'); +INSERT INTO `part` VALUES (1436, 'smoke floral green medium blush', 'Manufacturer#5', 'Brand#54', 'ECONOMY ANODIZED COPPER', 10, 'LG BAG', 1337.43, 'sily pending inst'); +INSERT INTO `part` VALUES (336, 'maroon medium green tomato rosy', 'Manufacturer#2', 'Brand#25', 'PROMO ANODIZED TIN', 3, 'WRAP JAR', 1236.33, 'nto beans.'); +DROP TABLE IF EXISTS `partsupp`; +CREATE TABLE `partsupp` ( +`ps_partkey` int NOT NULL, +`PS_SUPPKEY` int NOT NULL, +`PS_AVAILQTY` int NOT NULL, +`PS_SUPPLYCOST` decimal(15, 2) NOT NULL, +`PS_COMMENT` varchar(199) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +PRIMARY KEY (`ps_partkey`, `PS_SUPPKEY`) USING BTREE, +INDEX `PARTSUPP_FK1`(`PS_SUPPKEY`) USING BTREE, +CONSTRAINT `partsupp_ibfk_1` FOREIGN KEY (`PS_SUPPKEY`) REFERENCES `supplier` (`s_suppkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `partsupp_ibfk_2` FOREIGN KEY (`ps_partkey`) REFERENCES `part` (`p_partkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `partsupp_ibfk_3` FOREIGN KEY (`PS_SUPPKEY`) REFERENCES `supplier` (`s_suppkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `partsupp_ibfk_4` FOREIGN KEY (`ps_partkey`) REFERENCES `part` (`p_partkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `partsupp_ibfk_5` FOREIGN KEY (`PS_SUPPKEY`) REFERENCES `supplier` (`s_suppkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `partsupp_ibfk_6` FOREIGN KEY (`ps_partkey`) REFERENCES `part` (`p_partkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO `partsupp` VALUES (299, 800, 2035, 248.11, 'ithely final foxes cajole. blithely pending packages grow slyly special, ironic platelets. fluffily pending dept'); +INSERT INTO `partsupp` VALUES (316, 817, 8752, 591.79, 'sts hinder carefully. furiously unusual deposits haggle fluffily '); +INSERT INTO `partsupp` VALUES (119, 370, 1452, 676.92, 'ular instructions was slyly. furiously bold gifts boost f'); +INSERT INTO `partsupp` VALUES (177, 678, 9872, 252.42, 'sual platelets. bold foxes affix furiously. pending, pending accounts lose furiously. pending platelets along the unusual, even foxes wake regular, even theo'); +INSERT INTO `partsupp` VALUES (300, 801, 7118, 743.78, 'sts wake carefully regular, pending pinto beans. unusual foxes wake slyly among the ironic, reg'); +INSERT INTO `partsupp` VALUES (242, 743, 2514, 208.39, 'ckages. permanent, even warhorses cajole blithely after the final accounts. quickly pending packag'); +INSERT INTO `partsupp` VALUES (886, 887, 4069, 19.56, 'r requests across the carefully final deposits nag ironic ideas. unusual dolphins nag furiously near the furiou'); +INSERT INTO `partsupp` VALUES (474, 475, 3200, 728.15, 'ding to the express courts. furiously ironic deposits nod accounts. bold deposits cajole throughout the carefully close accounts. fluffily final attainments will cajole blithely even foxes. slyl'); +INSERT INTO `partsupp` VALUES (401, 402, 3408, 214.06, 'eep slyly-- slyly fluffy deposits thrash fluffily fluffily even deposits. final accounts are slyly among the final ideas. unusual packages print slyly carefully iro'); +INSERT INTO `partsupp` VALUES (377, 378, 9022, 665.73, 'hely pending deposits integrate according to the regular foxes. furiously ironic ideas sleep about the ironic'); +INSERT INTO `partsupp` VALUES (4, 255, 6377, 591.18, 'ly final courts haggle carefully regular accounts. carefully regular accounts could integrate slyly. slyly express packages about the accounts wake slyly'); +INSERT INTO `partsupp` VALUES (83, 584, 5974, 657.22, ' even packages boost furiously. slyly regular gifts above the accounts are quickly express packages. slyly pending deposits besides the express, even asymptotes haggle after the ironic ins'); +INSERT INTO `partsupp` VALUES (577, 78, 9072, 373.75, 'ges detect quickly final requests. unusual pinto beans sleep furiously'); +INSERT INTO `partsupp` VALUES (327, 78, 7862, 290.17, 'uests. regular requests haggle. blithely bold requests l'); +INSERT INTO `partsupp` VALUES (416, 417, 4241, 813.99, 'of the pending, even requests could lose slyly regular ideas. slyly final dependencies use-- furiousl'); +INSERT INTO `partsupp` VALUES (450, 451, 1191, 118.60, 'cording to the pending requests. ironic ideas use slyly against the final requests. regular accoun'); +INSERT INTO `partsupp` VALUES (3, 254, 4093, 498.13, 'ending dependencies haggle fluffily. regular deposits boost quickly carefully regular requests. deposits affix furiously around the pinto beans. ironic, unusual platelets across the p'); +INSERT INTO `partsupp` VALUES (35, 786, 2025, 411.17, 's cajole fluffily final deposits. furiously express packages after the blithely special realms boost evenly even requests. slow requests use above the unusual accoun'); +INSERT INTO `partsupp` VALUES (201, 702, 4125, 534.11, 'uctions sleep slyly final theodolites. ironic, regular pinto beans along the sly'); +INSERT INTO `partsupp` VALUES (175, 676, 8501, 706.61, 'int above the instructions. furiously regular requests integrate blithely according to the instructions. slyly pending foxes are asymptotes. slyly ruthless accounts wake. r'); +INSERT INTO `partsupp` VALUES (489, 240, 3471, 937.30, 'dogged pinto beans above the silent, bold requests wake slyly about the regular accounts. blithely ironic deposits wake. even, express sheaves haggle carefully deposits. specia'); +INSERT INTO `partsupp` VALUES (362, 613, 6711, 357.00, 'ss the blithely express ideas integrate furiously alongside of the requests. silent instructions engage. furiously special pa'); +INSERT INTO `partsupp` VALUES (86, 337, 2773, 250.04, 'ding accounts. slyly special requests will have to affix carefully along the furiously unusual packages. regular theodol'); +INSERT INTO `partsupp` VALUES (326, 577, 7160, 592.60, 'ronic deposits wake slyly regular ideas. pinto beans across the carefully even ideas affix furiously fluffily final accounts. packages are blithely above the r'); +INSERT INTO `partsupp` VALUES (7, 508, 3377, 68.77, 'usly against the daring asymptotes. slyly regular platelets sleep quickly blithely regular deposits. boldly regular deposits wake blithely ironic accounts'); +INSERT INTO `partsupp` VALUES (257, 508, 276, 612.44, 'among the packages. thinly special packages sleep. blithely ironic packages are furiously around the furiously even packages. carefully unusual accounts nag bold dolphins. blithely ironic depend'); +INSERT INTO `partsupp` VALUES (557, 808, 106, 823.28, 'ns. slyly final packages wake. carefully ironic packages affix. even, final accounts according to the fluffily final pinto beans use slyl'); +INSERT INTO `partsupp` VALUES (905, 656, 5818, 118.80, 'closely bold packages haggle furiously final requests. regular requests cajole slyly. carefully final asymptote'); +INSERT INTO `partsupp` VALUES (674, 925, 2476, 726.52, 'e furiously even dolphins use across the final, bold deposits. regular pinto beans doubt thinly furiously pending dolphins. theodolites cajole slyly. blithely special deposits are furiously. s'); +INSERT INTO `partsupp` VALUES (872, 123, 8098, 669.74, 'ly pending packages. requests wake carefully ironic, unusual dependencies. carefully pending pinto beans wake after the blithely special instructions. fluffily quiet requests'); +INSERT INTO `partsupp` VALUES (1436, 939, 2379, 231.49, 'pending pinto beans play furiously furiously unusual requests. '); +INSERT INTO `partsupp` VALUES (336, 87, 1661, 339.32, 'ntain along the furiously ironic packages. express accounts sleep quickly. deposits cajole slyly regular ideas. final excus'); +DROP TABLE IF EXISTS `lineitem`; +CREATE TABLE `lineitem` ( +`l_orderkey` int NOT NULL, +`L_PARTKEY` int NOT NULL, +`L_SUPPKEY` int NOT NULL, +`L_LINENUMBER` int NOT NULL, +`L_QUANTITY` decimal(15, 2) NOT NULL, +`L_EXTENDEDPRICE` decimal(15, 2) NOT NULL, +`L_DISCOUNT` decimal(15, 2) NOT NULL, +`L_TAX` decimal(15, 2) NOT NULL, +`L_RETURNFLAG` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`L_LINESTATUS` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`L_SHIPDATE` date NOT NULL, +`L_COMMITDATE` date NOT NULL, +`L_RECEIPTDATE` date NOT NULL, +`L_SHIPINSTRUCT` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`L_SHIPMODE` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +`L_COMMENT` varchar(44) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, +PRIMARY KEY (`l_orderkey`, `L_LINENUMBER`) USING BTREE, +INDEX `LINEITEM_FK2`(`L_PARTKEY`, `L_SUPPKEY`) USING BTREE, +CONSTRAINT `lineitem_ibfk_1` FOREIGN KEY (`l_orderkey`) REFERENCES `orders` (`o_orderkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `lineitem_ibfk_3` FOREIGN KEY (`l_orderkey`) REFERENCES `orders` (`o_orderkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, +CONSTRAINT `lineitem_ibfk_5` FOREIGN KEY (`l_orderkey`) REFERENCES `orders` (`o_orderkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; +INSERT INTO lineitem VALUES(118370, 5349, 605, 2, 42.00, 52682.28, 0.08, 0.07, +'R', 'F', '1995-05-30', '1995-06-20', '1995-06-04', 'NONE', 'AIR', 'carefully final requests. furiously final'); +INSERT INTO lineitem VALUES(520707, 19569 , 839, 2, 31.00, 46145.36, 0.08, 0.03, +'N', 'O', '1996-07-20', '1996-07-02', '1996-07-30', 'NONE', 'AIR' , 'y pending shea'); +INSERT INTO lineitem VALUES(584192, 5740, 996, 1, 28.00, 46080.72, 0.09, 0.03, +'N', 'O', '1995-06-28', '1995-06-14', '1995-07-28', 'TAKE BACK RETURN', 'AIR', 'ual ideas. blithely special acco'); +INSERT INTO lineitem VALUES( 479207, 1238, 741, 5, 30.00, 34176.90, 0.06, 0.03, +'N', 'O', '1996-03-07', '1996-05-21', '1996-03-20', 'DELIVER IN PERSON', 'RAIL', 'ons. special, pending accounts wake care'); +INSERT INTO `lineitem` VALUES (554307, 299, 800, 5, 31.00, 37177.99, 0.10, 0.03, 'N', 'O', '1998-09-17', '1998-07-20', '1998-09-24', 'TAKE BACK RETURN', 'RAIL', 'carefully regul'); +INSERT INTO `lineitem` VALUES (111521, 316, 817, 2, 27.00, 32840.37, 0.04, 0.05, 'N', 'O', '1997-03-30', '1997-05-09', '1997-04-04', 'DELIVER IN PERSON', 'REG AIR', 'old deposits doubt '); +INSERT INTO `lineitem` VALUES (444225, 119, 370, 1, 44.00, 44840.84, 0.01, 0.01, 'N', 'O', '1996-08-28', '1996-09-06', '1996-09-27', 'COLLECT COD', 'FOB', 'uriously special '); +INSERT INTO `lineitem` VALUES (245857, 119, 370, 4, 42.00, 42802.62, 0.03, 0.08, 'N', 'O', '1996-02-12', '1996-02-12', '1996-02-13', 'TAKE BACK RETURN', 'SHIP', 'tions along the reg'); +INSERT INTO `lineitem` VALUES (132321, 119, 370, 2, 43.00, 43821.73, 0.04, 0.00, 'A', 'F', '1994-03-09', '1994-04-24', '1994-03-12', 'NONE', 'MAIL', 'ickly pendin'); +INSERT INTO `lineitem` VALUES (438816, 119, 370, 1, 39.00, 39745.29, 0.06, 0.07, 'A', 'F', '1993-05-11', '1993-04-22', '1993-05-24', 'TAKE BACK RETURN', 'TRUCK', ' special accounts nag '); +INSERT INTO `lineitem` VALUES (74497, 119, 370, 4, 38.00, 38726.18, 0.09, 0.01, 'A', 'F', '1993-02-24', '1993-01-31', '1993-03-04', 'DELIVER IN PERSON', 'REG AIR', 'ckages among the car'); +INSERT INTO `lineitem` VALUES (89510, 316, 567, 2, 46.00, 55950.26, 0.05, 0.07, 'N', 'O', '1998-08-01', '1998-06-29', '1998-08-13', 'NONE', 'SHIP', 'packages are blithely final requests. car'); +INSERT INTO `lineitem` VALUES (157444, 177, 678, 7, 6.00, 6463.02, 0.01, 0.08, 'N', 'O', '1997-03-06', '1997-03-25', '1997-03-28', 'NONE', 'TRUCK', 'es against the regular instr'); +INSERT INTO `lineitem` VALUES (233090, 177, 678, 2, 1.00, 1077.17, 0.07, 0.06, 'N', 'O', '1996-05-03', '1996-06-19', '1996-05-23', 'NONE', 'MAIL', 'stealthily slyly idle dolphins. regular i'); +INSERT INTO `lineitem` VALUES (287744, 316, 567, 3, 6.00, 7297.86, 0.07, 0.06, 'R', 'F', '1995-04-14', '1995-03-15', '1995-04-16', 'TAKE BACK RETURN', 'REG AIR', ' express foxes. dep'); +INSERT INTO `lineitem` VALUES (91747, 300, 801, 7, 9.00, 10802.70, 0.04, 0.06, 'R', 'F', '1994-09-28', '1994-12-10', '1994-10-19', 'NONE', 'MAIL', 'detect slyly plat'); +INSERT INTO `lineitem` VALUES (54277, 177, 678, 3, 32.00, 34469.44, 0.02, 0.03, 'A', 'F', '1993-02-17', '1993-03-05', '1993-02-28', 'DELIVER IN PERSON', 'AIR', ' fluffy, ironic packages. furiou'); +INSERT INTO `lineitem` VALUES (75299, 177, 678, 2, 32.00, 34469.44, 0.04, 0.07, 'R', 'F', '1993-04-15', '1993-01-19', '1993-04-25', 'TAKE BACK RETURN', 'SHIP', 'ding decoys cajole slyly. bravely bold'); +INSERT INTO `lineitem` VALUES (529379, 299, 300, 2, 18.00, 21587.22, 0.08, 0.02, 'N', 'O', '1998-07-06', '1998-06-18', '1998-08-01', 'TAKE BACK RETURN', 'AIR', 'es are furiously across the fi'); +INSERT INTO `lineitem` VALUES (32005, 242, 743, 1, 48.00, 54827.52, 0.05, 0.06, 'N', 'O', '1997-08-07', '1997-07-01', '1997-08-30', 'TAKE BACK RETURN', 'TRUCK', ' slyly along the furiously express'); +INSERT INTO `lineitem` VALUES (7907, 242, 743, 3, 42.00, 47974.08, 0.01, 0.04, 'N', 'O', '1996-12-02', '1996-11-22', '1996-12-08', 'DELIVER IN PERSON', 'SHIP', 'nst the sometimes pending pa'); +INSERT INTO `lineitem` VALUES (196260, 242, 993, 2, 20.00, 22844.80, 0.07, 0.00, 'N', 'O', '1996-02-19', '1996-03-01', '1996-03-01', 'TAKE BACK RETURN', 'AIR', 'al ideas wake carefully quickly unusu'); +INSERT INTO `lineitem` VALUES (346592, 242, 743, 5, 18.00, 20560.32, 0.10, 0.03, 'A', 'F', '1994-12-05', '1994-10-17', '1994-12-26', 'DELIVER IN PERSON', 'RAIL', 'y alongside of the furious'); +INSERT INTO `lineitem` VALUES (388736, 242, 743, 2, 43.00, 49116.32, 0.06, 0.04, 'A', 'F', '1993-05-11', '1993-04-27', '1993-05-15', 'COLLECT COD', 'TRUCK', 'blithely special dolphi'); +INSERT INTO `lineitem` VALUES (552771, 242, 743, 2, 1.00, 1142.24, 0.06, 0.01, 'A', 'F', '1992-08-09', '1992-07-02', '1992-08-25', 'TAKE BACK RETURN', 'TRUCK', 'unusual deposits. slyly express i'); +INSERT INTO `lineitem` VALUES (56134, 886, 887, 4, 24.00, 42885.12, 0.07, 0.02, 'N', 'O', '1998-05-31', '1998-06-29', '1998-06-23', 'COLLECT COD', 'TRUCK', 'l packages maintain about '); +INSERT INTO `lineitem` VALUES (226145, 474, 475, 4, 16.00, 21991.52, 0.08, 0.00, 'N', 'O', '1997-11-09', '1998-01-01', '1997-11-22', 'NONE', 'TRUCK', 'arefully final foxes boost furiou'); +INSERT INTO `lineitem` VALUES (35427, 401, 402, 3, 5.00, 6507.00, 0.05, 0.07, 'N', 'O', '1996-05-23', '1996-05-19', '1996-05-24', 'TAKE BACK RETURN', 'REG AIR', 'ully across the quickly '); +INSERT INTO `lineitem` VALUES (183524, 377, 378, 1, 11.00, 14051.07, 0.00, 0.07, 'N', 'O', '1995-09-15', '1995-08-12', '1995-10-10', 'COLLECT COD', 'RAIL', 'sily accor'); +INSERT INTO `lineitem` VALUES (247297, 377, 378, 2, 46.00, 58759.02, 0.07, 0.02, 'R', 'F', '1994-09-18', '1994-10-17', '1994-09-24', 'NONE', 'SHIP', ' deposits. boldly pending deposits'); +INSERT INTO `lineitem` VALUES (201607, 401, 402, 6, 1.00, 1301.40, 0.02, 0.02, 'R', 'F', '1993-02-11', '1993-02-12', '1993-03-10', 'COLLECT COD', 'AIR', 'y unusual packages. blithely regular dino'); +INSERT INTO `lineitem` VALUES (10948, 377, 378, 1, 44.00, 56204.28, 0.09, 0.01, 'A', 'F', '1992-10-24', '1992-10-16', '1992-11-01', 'TAKE BACK RETURN', 'SHIP', 'leep blithely deposits. foxes n'); +INSERT INTO `lineitem` VALUES (519911, 177, 928, 3, 5.00, 5385.85, 0.08, 0.04, 'N', 'O', '1998-06-06', '1998-06-26', '1998-06-10', 'COLLECT COD', 'MAIL', ' fluffily even foxes integrate the'); +INSERT INTO `lineitem` VALUES (292454, 4, 255, 2, 15.00, 13560.00, 0.05, 0.02, 'N', 'O', '1997-11-04', '1997-09-03', '1997-11-09', 'TAKE BACK RETURN', 'MAIL', 'fluffily unusual instructions '); +INSERT INTO `lineitem` VALUES (233921, 83, 584, 2, 45.00, 44238.60, 0.04, 0.04, 'N', 'O', '1996-05-06', '1996-04-14', '1996-05-20', 'COLLECT COD', 'AIR', 't the sauternes wake fluffily alon'); +INSERT INTO `lineitem` VALUES (562599, 4, 255, 4, 19.00, 17176.00, 0.09, 0.00, 'N', 'O', '1995-07-06', '1995-07-08', '1995-08-03', 'TAKE BACK RETURN', 'AIR', 'eposits are acro'); +INSERT INTO `lineitem` VALUES (20199, 4, 255, 1, 29.00, 26216.00, 0.09, 0.01, 'A', 'F', '1994-07-12', '1994-05-28', '1994-07-18', 'COLLECT COD', 'AIR', 'osits use after the furiously express '); +INSERT INTO `lineitem` VALUES (375971, 4, 255, 7, 16.00, 14464.00, 0.10, 0.08, 'A', 'F', '1993-05-02', '1993-06-22', '1993-05-29', 'COLLECT COD', 'MAIL', ' slyly instead of'); +INSERT INTO `lineitem` VALUES (156774, 4, 255, 1, 20.00, 18080.00, 0.07, 0.01, 'A', 'F', '1992-10-21', '1992-10-31', '1992-10-27', 'COLLECT COD', 'MAIL', 't the special package'); +INSERT INTO `lineitem` VALUES (281319, 300, 301, 2, 22.00, 26406.60, 0.10, 0.05, 'N', 'O', '1998-05-27', '1998-05-22', '1998-06-13', 'DELIVER IN PERSON', 'REG AIR', 'theodolites. unusual foxes integrate boldl'); +INSERT INTO `lineitem` VALUES (25029, 300, 301, 2, 12.00, 14403.60, 0.08, 0.04, 'N', 'O', '1998-02-09', '1998-01-18', '1998-02-22', 'COLLECT COD', 'AIR', 's affix blithely regular waters.'); +INSERT INTO `lineitem` VALUES (180997, 316, 67, 4, 22.00, 26758.82, 0.02, 0.06, 'N', 'O', '1996-10-06', '1996-11-17', '1996-11-02', 'DELIVER IN PERSON', 'MAIL', 'counts integrate. carefully even ideas a'); +INSERT INTO `lineitem` VALUES (545542, 300, 301, 1, 43.00, 51612.90, 0.01, 0.06, 'N', 'O', '1995-10-06', '1995-09-11', '1995-10-26', 'NONE', 'TRUCK', 'ts sleep blithely abov'); +INSERT INTO `lineitem` VALUES (111235, 300, 301, 1, 40.00, 48012.00, 0.00, 0.04, 'A', 'F', '1994-06-27', '1994-07-23', '1994-07-11', 'COLLECT COD', 'FOB', 'unusual ideas boost around the blithely fin'); +INSERT INTO `lineitem` VALUES (71975, 316, 67, 4, 50.00, 60815.50, 0.08, 0.03, 'R', 'F', '1993-10-30', '1993-12-06', '1993-11-27', 'DELIVER IN PERSON', 'SHIP', ' haggle quickly against the bl'); +INSERT INTO `lineitem` VALUES (284743, 316, 67, 1, 40.00, 48652.40, 0.09, 0.00, 'R', 'F', '1992-05-18', '1992-04-02', '1992-05-24', 'DELIVER IN PERSON', 'SHIP', 'xcuses. blith'); +INSERT INTO `lineitem` VALUES (239905, 577, 78, 4, 27.00, 39894.39, 0.05, 0.08, 'N', 'O', '1998-05-04', '1998-04-03', '1998-05-16', 'DELIVER IN PERSON', 'REG AIR', 'ously regular '); +INSERT INTO `lineitem` VALUES (77026, 327, 78, 5, 33.00, 40501.56, 0.10, 0.05, 'N', 'O', '1997-04-22', '1997-03-08', '1997-05-03', 'COLLECT COD', 'TRUCK', 'ully even deposits. '); +INSERT INTO `lineitem` VALUES (56902, 577, 78, 5, 45.00, 66490.65, 0.05, 0.01, 'N', 'O', '1996-11-13', '1996-12-17', '1996-11-14', 'DELIVER IN PERSON', 'FOB', ' quickly regular accounts. instructions'); +INSERT INTO `lineitem` VALUES (591970, 327, 78, 3, 40.00, 49092.80, 0.09, 0.08, 'N', 'O', '1995-07-21', '1995-07-08', '1995-08-01', 'NONE', 'MAIL', 's use carefully finally'); +INSERT INTO `lineitem` VALUES (290081, 577, 78, 3, 17.00, 25118.69, 0.04, 0.06, 'R', 'F', '1994-10-01', '1994-09-05', '1994-10-27', 'NONE', 'TRUCK', 'carefully even requests. request'); +INSERT INTO `lineitem` VALUES (240676, 577, 78, 1, 7.00, 10342.99, 0.01, 0.00, 'R', 'F', '1993-10-14', '1993-11-25', '1993-11-12', 'DELIVER IN PERSON', 'RAIL', ' deposits. pending foxes nag. p'); +INSERT INTO `lineitem` VALUES (543332, 327, 78, 3, 33.00, 40501.56, 0.04, 0.02, 'R', 'F', '1993-03-07', '1993-02-04', '1993-03-25', 'NONE', 'REG AIR', 'ically ironic requests. silently sp'); +INSERT INTO `lineitem` VALUES (60162, 242, 243, 1, 25.00, 28556.00, 0.03, 0.00, 'N', 'O', '1998-08-16', '1998-09-06', '1998-08-23', 'COLLECT COD', 'FOB', 'ly. furiously ironic attainments h'); +INSERT INTO `lineitem` VALUES (28391, 242, 243, 3, 12.00, 13706.88, 0.06, 0.04, 'N', 'O', '1998-01-12', '1998-03-16', '1998-01-30', 'COLLECT COD', 'AIR', 'ic ideas. blithely even ideas wak'); +INSERT INTO `lineitem` VALUES (143237, 416, 417, 1, 14.00, 18429.74, 0.10, 0.03, 'N', 'O', '1996-08-26', '1996-07-17', '1996-09-04', 'NONE', 'MAIL', 'y even accoun'); +INSERT INTO `lineitem` VALUES (184738, 416, 417, 5, 28.00, 36859.48, 0.04, 0.07, 'R', 'F', '1995-05-08', '1995-05-23', '1995-05-27', 'DELIVER IN PERSON', 'MAIL', 'slyly bold '); +INSERT INTO `lineitem` VALUES (355009, 450, 451, 5, 30.00, 40513.50, 0.00, 0.05, 'R', 'F', '1995-02-09', '1994-11-15', '1995-02-28', 'NONE', 'SHIP', 'ajole blithely pending requests'); +INSERT INTO `lineitem` VALUES (267012, 242, 243, 2, 9.00, 10280.16, 0.01, 0.04, 'A', 'F', '1993-09-11', '1993-07-04', '1993-09-26', 'NONE', 'RAIL', 'le fluffily. blithely unusual '); +INSERT INTO `lineitem` VALUES (463459, 242, 243, 4, 13.00, 14849.12, 0.05, 0.06, 'R', 'F', '1992-10-06', '1992-12-05', '1992-10-19', 'TAKE BACK RETURN', 'RAIL', 'ounts affix quickly care'); +INSERT INTO `lineitem` VALUES (158240, 3, 254, 6, 23.00, 20769.00, 0.02, 0.08, 'N', 'O', '1998-07-01', '1998-06-17', '1998-07-20', 'COLLECT COD', 'AIR', 'ounts. quietly ironic '); +INSERT INTO `lineitem` VALUES (101056, 3, 254, 7, 24.00, 21672.00, 0.04, 0.01, 'N', 'O', '1997-06-08', '1997-06-09', '1997-06-27', 'DELIVER IN PERSON', 'FOB', ' the blithely final accounts. silent'); +INSERT INTO `lineitem` VALUES (374149, 3, 254, 1, 39.00, 35217.00, 0.10, 0.08, 'N', 'O', '1996-06-24', '1996-06-25', '1996-07-13', 'TAKE BACK RETURN', 'RAIL', 'iresias boost'); +INSERT INTO `lineitem` VALUES (561857, 3, 254, 3, 44.00, 39732.00, 0.06, 0.00, 'N', 'O', '1996-01-01', '1996-02-23', '1996-01-16', 'COLLECT COD', 'SHIP', 'thely unusual gifts after'); +INSERT INTO `lineitem` VALUES (422529, 3, 254, 2, 45.00, 40635.00, 0.07, 0.03, 'A', 'F', '1994-06-12', '1994-05-19', '1994-07-11', 'TAKE BACK RETURN', 'REG AIR', 'y pending accounts impress acros'); +INSERT INTO `lineitem` VALUES (186275, 3, 254, 5, 10.00, 9030.00, 0.01, 0.03, 'A', 'F', '1993-12-09', '1993-10-15', '1993-12-14', 'COLLECT COD', 'MAIL', 'yly against the express accounts. even re'); +INSERT INTO `lineitem` VALUES (203457, 3, 254, 3, 39.00, 35217.00, 0.00, 0.05, 'R', 'F', '1992-11-01', '1992-09-08', '1992-11-05', 'DELIVER IN PERSON', 'FOB', ' boost quickly even pinto beans! slyly s'); +INSERT INTO `lineitem` VALUES (413282, 35, 786, 2, 17.00, 15895.51, 0.10, 0.08, 'N', 'O', '1998-07-16', '1998-06-16', '1998-07-26', 'TAKE BACK RETURN', 'RAIL', 'lar requests wake blithely ironic, regular '); +INSERT INTO `lineitem` VALUES (93794, 35, 786, 6, 9.00, 8415.27, 0.07, 0.07, 'N', 'O', '1997-11-08', '1997-10-14', '1997-12-08', 'NONE', 'FOB', 'ideas along the always expr'); +INSERT INTO `lineitem` VALUES (550241, 35, 786, 4, 12.00, 11220.36, 0.01, 0.06, 'N', 'O', '1996-01-26', '1996-03-19', '1996-02-12', 'NONE', 'RAIL', 'carefully daring deposits. fluffil'); +INSERT INTO `lineitem` VALUES (340576, 377, 878, 2, 29.00, 37043.73, 0.07, 0.00, 'N', 'O', '1996-03-05', '1996-02-29', '1996-03-20', 'DELIVER IN PERSON', 'RAIL', 'pecial warthogs cajole above t'); +INSERT INTO `lineitem` VALUES (36896, 35, 786, 2, 7.00, 6545.21, 0.08, 0.00, 'R', 'F', '1994-11-10', '1994-12-30', '1994-11-23', 'TAKE BACK RETURN', 'AIR', 's are inside the even, bold accounts. ca'); +INSERT INTO `lineitem` VALUES (71269, 300, 551, 1, 6.00, 7201.80, 0.05, 0.04, 'A', 'F', '1993-03-14', '1993-02-21', '1993-03-27', 'COLLECT COD', 'RAIL', 'ual, ironic requests are regular, even dep'); +INSERT INTO `lineitem` VALUES (391013, 35, 786, 4, 28.00, 26180.84, 0.03, 0.04, 'R', 'F', '1992-05-15', '1992-05-16', '1992-05-21', 'NONE', 'MAIL', 'te according to the instructions. b'); +INSERT INTO `lineitem` VALUES (108838, 201, 702, 5, 15.00, 16518.00, 0.01, 0.06, 'N', 'O', '1998-01-22', '1998-04-03', '1998-02-07', 'DELIVER IN PERSON', 'SHIP', 'equests? q'); +INSERT INTO `lineitem` VALUES (440067, 4, 505, 4, 45.00, 40680.00, 0.02, 0.03, 'N', 'O', '1997-03-20', '1997-05-18', '1997-04-02', 'TAKE BACK RETURN', 'FOB', 'tect atop the slyly fina'); +INSERT INTO `lineitem` VALUES (79333, 175, 676, 5, 31.00, 33330.27, 0.02, 0.00, 'N', 'O', '1996-06-21', '1996-07-11', '1996-06-28', 'NONE', 'SHIP', 'requests agai'); +INSERT INTO `lineitem` VALUES (248417, 4, 505, 3, 41.00, 37064.00, 0.08, 0.02, 'N', 'O', '1995-10-13', '1995-11-05', '1995-10-24', 'DELIVER IN PERSON', 'FOB', 'ag furiously. carefully even deposit'); +INSERT INTO `lineitem` VALUES (247557, 83, 834, 3, 4.00, 3932.32, 0.10, 0.07, 'A', 'F', '1994-12-31', '1995-01-09', '1995-01-19', 'COLLECT COD', 'REG AIR', ' pinto beans sublate. epitaphs h'); +INSERT INTO `lineitem` VALUES (24866, 4, 505, 4, 22.00, 19888.00, 0.09, 0.03, 'A', 'F', '1994-01-14', '1994-02-06', '1994-01-31', 'NONE', 'SHIP', 'rts. requests nag quickly to the'); +INSERT INTO `lineitem` VALUES (439175, 83, 834, 1, 47.00, 46204.76, 0.07, 0.03, 'A', 'F', '1992-10-02', '1992-08-06', '1992-10-17', 'TAKE BACK RETURN', 'FOB', ' after the quickly'); +INSERT INTO `lineitem` VALUES (442278, 3, 504, 2, 12.00, 10836.00, 0.08, 0.05, 'N', 'O', '1998-05-28', '1998-05-15', '1998-06-18', 'TAKE BACK RETURN', 'SHIP', 'requests sleep blithely f'); +INSERT INTO `lineitem` VALUES (498596, 3, 504, 5, 46.00, 41538.00, 0.07, 0.03, 'N', 'O', '1997-06-22', '1997-07-17', '1997-07-11', 'COLLECT COD', 'REG AIR', 'efully regular instructions. slyly'); +INSERT INTO `lineitem` VALUES (359047, 489, 240, 6, 31.00, 43073.88, 0.07, 0.03, 'N', 'O', '1996-12-14', '1996-11-08', '1996-12-15', 'DELIVER IN PERSON', 'AIR', 's! silent packages sleep fluf'); +INSERT INTO `lineitem` VALUES (480391, 3, 504, 5, 38.00, 34314.00, 0.06, 0.00, 'N', 'O', '1995-10-03', '1995-09-25', '1995-10-16', 'NONE', 'TRUCK', 'r packages. quickly ironic pinto beans was'); +INSERT INTO `lineitem` VALUES (358918, 35, 286, 2, 41.00, 38336.23, 0.05, 0.04, 'A', 'F', '1994-05-23', '1994-07-21', '1994-05-31', 'DELIVER IN PERSON', 'FOB', 'ular accounts. quickly silent ideas use sl'); +INSERT INTO `lineitem` VALUES (408641, 3, 504, 3, 15.00, 13545.00, 0.09, 0.01, 'R', 'F', '1993-09-17', '1993-09-23', '1993-10-13', 'TAKE BACK RETURN', 'REG AIR', 'lets sleep: furiou'); +INSERT INTO `lineitem` VALUES (117221, 175, 176, 3, 34.00, 36555.78, 0.02, 0.05, 'A', 'F', '1993-01-11', '1993-01-22', '1993-01-30', 'COLLECT COD', 'AIR', 'e quickly even f'); +INSERT INTO `lineitem` VALUES (204871, 362, 613, 1, 6.00, 7574.16, 0.09, 0.02, 'N', 'O', '1998-04-05', '1998-05-20', '1998-04-17', 'NONE', 'AIR', ' blithely furiously bold ideas. regular,'); +INSERT INTO `lineitem` VALUES (67426, 4, 5, 4, 17.00, 15368.00, 0.07, 0.08, 'N', 'O', '1997-04-09', '1997-04-15', '1997-04-24', 'DELIVER IN PERSON', 'AIR', 'er the even excuses are furiously regula'); +INSERT INTO `lineitem` VALUES (156000, 4, 5, 3, 16.00, 14464.00, 0.09, 0.04, 'N', 'O', '1996-11-20', '1997-01-05', '1996-12-17', 'DELIVER IN PERSON', 'FOB', 'ronic ideas sleep'); +INSERT INTO `lineitem` VALUES (68322, 242, 493, 1, 41.00, 46831.84, 0.02, 0.06, 'N', 'O', '1996-02-02', '1996-01-02', '1996-02-05', 'NONE', 'AIR', 'imes final the'); +INSERT INTO `lineitem` VALUES (185315, 4, 5, 2, 28.00, 25312.00, 0.08, 0.01, 'A', 'F', '1994-09-08', '1994-10-31', '1994-10-05', 'TAKE BACK RETURN', 'AIR', ' express instructions'); +INSERT INTO `lineitem` VALUES (380708, 4, 5, 3, 14.00, 12656.00, 0.10, 0.07, 'R', 'F', '1993-05-14', '1993-05-23', '1993-06-07', 'DELIVER IN PERSON', 'FOB', 'olve blithely regular plat'); +INSERT INTO `lineitem` VALUES (214951, 362, 113, 4, 24.00, 30296.64, 0.09, 0.04, 'A', 'F', '1992-08-11', '1992-07-06', '1992-08-23', 'NONE', 'SHIP', 're against the regular re'); +INSERT INTO `lineitem` VALUES (370689, 86, 337, 2, 6.00, 5916.48, 0.01, 0.06, 'N', 'O', '1998-07-16', '1998-08-19', '1998-07-26', 'DELIVER IN PERSON', 'AIR', 'n enticingly '); +INSERT INTO `lineitem` VALUES (408548, 299, 550, 2, 14.00, 16790.06, 0.09, 0.08, 'N', 'O', '1997-05-23', '1997-06-21', '1997-06-03', 'NONE', 'AIR', 'y according to '); +INSERT INTO `lineitem` VALUES (455750, 86, 837, 1, 2.00, 1972.16, 0.08, 0.04, 'N', 'O', '1996-09-17', '1996-08-16', '1996-09-19', 'NONE', 'RAIL', 'r accounts dazzle clo'); +INSERT INTO `lineitem` VALUES (283046, 86, 837, 5, 37.00, 36484.96, 0.05, 0.08, 'N', 'O', '1995-12-09', '1996-02-10', '1995-12-30', 'TAKE BACK RETURN', 'MAIL', 'uriously carefully p'); +INSERT INTO `lineitem` VALUES (92258, 86, 837, 5, 19.00, 18735.52, 0.08, 0.05, 'A', 'F', '1994-05-22', '1994-06-01', '1994-06-13', 'COLLECT COD', 'FOB', 'pinto beans'); +INSERT INTO `lineitem` VALUES (206208, 86, 337, 1, 21.00, 20707.68, 0.06, 0.02, 'A', 'F', '1993-12-16', '1993-11-16', '1994-01-15', 'TAKE BACK RETURN', 'FOB', 'ndencies. blit'); +INSERT INTO `lineitem` VALUES (145507, 86, 837, 1, 17.00, 16763.36, 0.07, 0.05, 'R', 'F', '1992-10-12', '1992-09-15', '1992-11-09', 'TAKE BACK RETURN', 'AIR', 'regular dolphins. furiously'); +INSERT INTO `lineitem` VALUES (153351, 35, 36, 3, 33.00, 30855.99, 0.05, 0.08, 'N', 'O', '1998-05-16', '1998-05-23', '1998-05-24', 'COLLECT COD', 'AIR', 'e quickly above'); +INSERT INTO `lineitem` VALUES (466977, 35, 36, 5, 42.00, 39271.26, 0.07, 0.04, 'N', 'O', '1997-10-04', '1997-10-16', '1997-10-28', 'COLLECT COD', 'REG AIR', 'tes are blithely final pa'); +INSERT INTO `lineitem` VALUES (103810, 35, 36, 1, 38.00, 35531.14, 0.06, 0.02, 'N', 'O', '1996-06-13', '1996-08-13', '1996-06-25', 'NONE', 'RAIL', 'le on the requ'); +INSERT INTO `lineitem` VALUES (110178, 35, 36, 2, 41.00, 38336.23, 0.07, 0.02, 'N', 'O', '1995-08-04', '1995-07-20', '1995-09-03', 'DELIVER IN PERSON', 'REG AIR', 'yly regular'); +INSERT INTO `lineitem` VALUES (13698, 35, 36, 1, 50.00, 46751.50, 0.03, 0.03, 'A', 'F', '1994-09-23', '1994-11-01', '1994-09-26', 'TAKE BACK RETURN', 'MAIL', 'ffily express accounts use after th'); +INSERT INTO `lineitem` VALUES (172710, 35, 36, 1, 45.00, 42076.35, 0.10, 0.07, 'A', 'F', '1993-11-15', '1994-01-13', '1993-12-13', 'NONE', 'SHIP', 'ges wake after the furious'); +INSERT INTO `lineitem` VALUES (528513, 326, 577, 4, 24.00, 29431.68, 0.09, 0.00, 'R', 'F', '1992-08-27', '1992-07-31', '1992-09-21', 'DELIVER IN PERSON', 'RAIL', 'integrate carefully aft'); +INSERT INTO `lineitem` VALUES (420295, 7, 508, 2, 49.00, 44443.00, 0.09, 0.04, 'N', 'O', '1998-03-09', '1998-03-30', '1998-03-11', 'TAKE BACK RETURN', 'RAIL', 'al deposits. thinly exp'); +INSERT INTO `lineitem` VALUES (150465, 257, 508, 4, 1.00, 1157.25, 0.01, 0.06, 'N', 'O', '1997-03-12', '1997-02-26', '1997-04-06', 'COLLECT COD', 'RAIL', 'yly final packages are furiously. '); +INSERT INTO `lineitem` VALUES (139616, 257, 508, 1, 32.00, 37032.00, 0.00, 0.04, 'N', 'O', '1997-03-05', '1997-01-20', '1997-03-28', 'DELIVER IN PERSON', 'TRUCK', 'ainst the fu'); +INSERT INTO `lineitem` VALUES (180832, 7, 508, 4, 13.00, 11791.00, 0.06, 0.08, 'N', 'O', '1996-02-22', '1996-01-18', '1996-02-25', 'COLLECT COD', 'TRUCK', 'ross the slyly silent accoun'); +INSERT INTO `lineitem` VALUES (312962, 257, 508, 1, 6.00, 6943.50, 0.02, 0.02, 'R', 'F', '1994-05-19', '1994-04-11', '1994-06-08', 'NONE', 'REG AIR', ' regular ideas haggle blithely slyly iron'); +INSERT INTO `lineitem` VALUES (111942, 7, 508, 1, 19.00, 17233.00, 0.00, 0.02, 'R', 'F', '1993-05-05', '1993-04-03', '1993-05-23', 'DELIVER IN PERSON', 'REG AIR', 'usual ideas nag ruthlessly slyl'); +INSERT INTO `lineitem` VALUES (188032, 257, 508, 4, 12.00, 13887.00, 0.00, 0.05, 'R', 'F', '1992-09-18', '1992-07-21', '1992-10-16', 'NONE', 'TRUCK', 'e slyly. quickly special '); +INSERT INTO `lineitem` VALUES (315844, 557, 808, 2, 49.00, 71419.95, 0.00, 0.03, 'N', 'O', '1998-11-24', '1998-08-28', '1998-12-16', 'NONE', 'MAIL', 'efully. slyly ruthless ideas use fluffily '); +INSERT INTO `lineitem` VALUES (324771, 3, 4, 3, 21.00, 18963.00, 0.09, 0.00, 'N', 'O', '1997-03-07', '1997-04-06', '1997-03-20', 'NONE', 'SHIP', 'uriously acro'); +INSERT INTO `lineitem` VALUES (323234, 3, 4, 1, 3.00, 2709.00, 0.03, 0.04, 'N', 'O', '1996-12-24', '1997-02-03', '1997-01-12', 'COLLECT COD', 'REG AIR', 'es cajole sl'); +INSERT INTO `lineitem` VALUES (229475, 3, 4, 2, 43.00, 38829.00, 0.04, 0.03, 'N', 'O', '1996-03-10', '1996-02-12', '1996-03-26', 'DELIVER IN PERSON', 'AIR', 'counts use fluffily final dependencies. re'); +INSERT INTO `lineitem` VALUES (364805, 3, 4, 2, 7.00, 6321.00, 0.10, 0.02, 'A', 'F', '1994-09-11', '1994-07-01', '1994-10-06', 'COLLECT COD', 'FOB', 's are quickly according to the reque'); +INSERT INTO `lineitem` VALUES (246052, 4, 755, 1, 22.00, 19888.00, 0.07, 0.06, 'A', 'F', '1993-11-04', '1993-09-17', '1993-11-17', 'NONE', 'REG AIR', 'egular idea'); +INSERT INTO `lineitem` VALUES (159940, 3, 4, 2, 27.00, 24381.00, 0.02, 0.02, 'A', 'F', '1992-10-28', '1993-01-10', '1992-11-20', 'NONE', 'RAIL', ' boldly silent asymptotes a'); +INSERT INTO `lineitem` VALUES (88773, 177, 178, 1, 27.00, 29083.59, 0.03, 0.06, 'N', 'O', '1998-05-10', '1998-06-09', '1998-05-28', 'NONE', 'REG AIR', 'es. blithely even requests s'); +INSERT INTO `lineitem` VALUES (61059, 177, 178, 3, 19.00, 20466.23, 0.00, 0.06, 'N', 'O', '1998-03-31', '1998-01-24', '1998-04-15', 'NONE', 'TRUCK', 'aintain. expre'); +INSERT INTO `lineitem` VALUES (75712, 177, 178, 3, 7.00, 7540.19, 0.02, 0.03, 'N', 'O', '1996-04-19', '1996-03-30', '1996-04-25', 'COLLECT COD', 'AIR', ' furiously according to the special fox'); +INSERT INTO `lineitem` VALUES (502210, 177, 178, 1, 12.00, 12926.04, 0.09, 0.00, 'N', 'O', '1995-11-07', '1995-09-16', '1995-11-27', 'TAKE BACK RETURN', 'RAIL', 'es poach. blithely '); +INSERT INTO `lineitem` VALUES (581318, 177, 178, 7, 10.00, 10771.70, 0.10, 0.03, 'R', 'F', '1994-11-02', '1994-12-09', '1994-11-08', 'DELIVER IN PERSON', 'REG AIR', 'ets. blithely regular excuses boost flu'); +INSERT INTO `lineitem` VALUES (262180, 177, 178, 1, 35.00, 37700.95, 0.06, 0.00, 'R', 'F', '1993-03-23', '1993-04-23', '1993-03-26', 'COLLECT COD', 'TRUCK', 'lar ideas. fluff'); +INSERT INTO `lineitem` VALUES (442529, 177, 178, 3, 17.00, 18311.89, 0.07, 0.03, 'R', 'F', '1992-10-22', '1992-10-27', '1992-11-17', 'TAKE BACK RETURN', 'RAIL', 'wake carefu'); +INSERT INTO `lineitem` VALUES (393062, 7, 8, 1, 47.00, 42629.00, 0.02, 0.02, 'N', 'O', '1998-07-19', '1998-06-30', '1998-07-20', 'DELIVER IN PERSON', 'FOB', 'quests. request'); +INSERT INTO `lineitem` VALUES (440802, 7, 8, 2, 49.00, 44443.00, 0.07, 0.06, 'N', 'O', '1997-08-06', '1997-08-20', '1997-08-18', 'TAKE BACK RETURN', 'TRUCK', 's engage. re'); +INSERT INTO `lineitem` VALUES (129282, 3, 754, 5, 45.00, 40635.00, 0.02, 0.02, 'N', 'O', '1996-11-03', '1996-08-15', '1996-11-18', 'DELIVER IN PERSON', 'SHIP', 's haggle above the blithely '); +INSERT INTO `lineitem` VALUES (53189, 3, 754, 2, 3.00, 2709.00, 0.03, 0.01, 'N', 'O', '1995-09-30', '1995-11-07', '1995-10-30', 'COLLECT COD', 'FOB', 'regular ideas. iron'); +INSERT INTO `lineitem` VALUES (220419, 7, 8, 5, 27.00, 24489.00, 0.08, 0.01, 'A', 'F', '1994-04-22', '1994-06-03', '1994-05-11', 'DELIVER IN PERSON', 'REG AIR', 's haggle carefully against the furio'); +INSERT INTO `lineitem` VALUES (235171, 3, 754, 2, 36.00, 32508.00, 0.08, 0.07, 'R', 'F', '1993-06-28', '1993-08-13', '1993-07-21', 'COLLECT COD', 'FOB', 's nag around the special packag'); +INSERT INTO `lineitem` VALUES (406339, 3, 754, 1, 36.00, 32508.00, 0.05, 0.05, 'A', 'F', '1992-10-03', '1992-08-27', '1992-10-21', 'COLLECT COD', 'FOB', 'ly ironic id'); +INSERT INTO `lineitem` VALUES (78567, 905, 656, 4, 44.00, 79459.60, 0.08, 0.06, 'N', 'O', '1998-08-20', '1998-08-23', '1998-08-21', 'NONE', 'RAIL', 'onic requests haggle fl'); +INSERT INTO `lineitem` VALUES (451809, 674, 925, 3, 6.00, 9448.02, 0.03, 0.04, 'N', 'O', '1997-12-10', '1997-11-02', '1997-12-16', 'TAKE BACK RETURN', 'REG AIR', 'lly ironicall'); +INSERT INTO `lineitem` VALUES (133601, 674, 925, 5, 7.00, 11022.69, 0.02, 0.06, 'N', 'O', '1996-08-22', '1996-08-01', '1996-08-26', 'COLLECT COD', 'SHIP', 'ggle quickly against the bravely unusual a'); +INSERT INTO `lineitem` VALUES (467232, 872, 123, 2, 7.00, 12410.09, 0.01, 0.03, 'R', 'F', '1995-03-22', '1995-03-25', '1995-03-27', 'NONE', 'REG AIR', 'ound the iron'); +INSERT INTO `lineitem` VALUES (208480, 872, 123, 6, 28.00, 49640.36, 0.02, 0.05, 'R', 'F', '1995-02-20', '1995-02-10', '1995-03-14', 'TAKE BACK RETURN', 'FOB', 'ites might hinder alongside of the slo'); +INSERT INTO `lineitem` VALUES (487680, 872, 123, 5, 17.00, 30138.79, 0.02, 0.06, 'R', 'F', '1993-10-04', '1993-12-23', '1993-10-13', 'DELIVER IN PERSON', 'AIR', 's wake blithely final ideas. regul'); +INSERT INTO `lineitem` VALUES (363841, 674, 925, 4, 19.00, 29918.73, 0.10, 0.08, 'A', 'F', '1992-07-10', '1992-06-09', '1992-07-19', 'NONE', 'RAIL', 'ongside of the fluffily regular accounts.'); +INSERT INTO `lineitem` VALUES (216454, 201, 952, 7, 35.00, 38542.00, 0.07, 0.04, 'N', 'O', '1998-03-15', '1998-04-07', '1998-03-27', 'COLLECT COD', 'AIR', 'ly furiously unusual foxes. '); +INSERT INTO `lineitem` VALUES (61954, 201, 952, 2, 30.00, 33036.00, 0.03, 0.06, 'N', 'O', '1997-04-07', '1997-03-30', '1997-04-12', 'TAKE BACK RETURN', 'RAIL', 'lieve at the'); +INSERT INTO `lineitem` VALUES (150531, 201, 952, 2, 9.00, 9910.80, 0.07, 0.05, 'N', 'O', '1996-11-13', '1996-10-04', '1996-12-07', 'DELIVER IN PERSON', 'SHIP', 'efully express packages. slyl'); +INSERT INTO `lineitem` VALUES (265476, 201, 952, 1, 27.00, 29732.40, 0.09, 0.03, 'N', 'F', '1995-05-28', '1995-05-19', '1995-06-25', 'DELIVER IN PERSON', 'RAIL', ' pending theodolites wake. furiously reg'); +INSERT INTO `lineitem` VALUES (205574, 201, 952, 2, 32.00, 35238.40, 0.03, 0.05, 'A', 'F', '1994-06-26', '1994-05-01', '1994-07-03', 'COLLECT COD', 'TRUCK', ' carefully bold pinto beans wake sl'); +INSERT INTO `lineitem` VALUES (474403, 201, 952, 2, 48.00, 52857.60, 0.01, 0.06, 'R', 'F', '1993-08-14', '1993-07-30', '1993-09-13', 'DELIVER IN PERSON', 'TRUCK', 'permanent, even ideas integrate c'); +INSERT INTO `lineitem` VALUES (94338, 201, 952, 5, 38.00, 41845.60, 0.01, 0.03, 'A', 'F', '1992-12-26', '1992-12-13', '1993-01-14', 'DELIVER IN PERSON', 'RAIL', 'ironic asymptotes sleep ab'); +INSERT INTO `lineitem` VALUES (126337, 327, 578, 3, 47.00, 57684.04, 0.10, 0.01, 'N', 'O', '1998-05-26', '1998-04-27', '1998-06-17', 'COLLECT COD', 'SHIP', 'ng to the '); +INSERT INTO `lineitem` VALUES (121606, 327, 578, 1, 48.00, 58911.36, 0.00, 0.07, 'N', 'O', '1997-03-15', '1997-05-09', '1997-03-26', 'DELIVER IN PERSON', 'RAIL', 'its. ironic requests was. ironic acc'); +INSERT INTO `lineitem` VALUES (509413, 327, 578, 5, 10.00, 12273.20, 0.07, 0.06, 'N', 'O', '1996-05-14', '1996-07-11', '1996-06-02', 'NONE', 'AIR', 'r theodoli'); +INSERT INTO `lineitem` VALUES (192197, 327, 578, 1, 2.00, 2454.64, 0.02, 0.02, 'N', 'O', '1995-11-13', '1995-10-02', '1995-11-29', 'COLLECT COD', 'RAIL', ', regular epitaphs haggle slyly final dep'); +INSERT INTO `lineitem` VALUES (32358, 327, 578, 6, 38.00, 46638.16, 0.07, 0.07, 'A', 'F', '1994-08-01', '1994-07-30', '1994-08-20', 'DELIVER IN PERSON', 'REG AIR', 'unts are care'); +INSERT INTO `lineitem` VALUES (42375, 327, 578, 3, 49.00, 60138.68, 0.06, 0.02, 'A', 'F', '1993-11-11', '1993-12-24', '1993-12-07', 'NONE', 'REG AIR', ' x-ray carefully bold instru'); +INSERT INTO `lineitem` VALUES (53984, 327, 578, 1, 18.00, 22091.76, 0.03, 0.08, 'A', 'F', '1993-01-19', '1993-02-10', '1993-01-24', 'COLLECT COD', 'TRUCK', 'thy deposits. silent requests agains'); +INSERT INTO `lineitem` VALUES (52167, 175, 426, 2, 22.00, 23653.74, 0.09, 0.04, 'N', 'O', '1998-08-03', '1998-08-23', '1998-08-08', 'TAKE BACK RETURN', 'TRUCK', 'ess deposits eat blithely. brave '); +INSERT INTO `lineitem` VALUES (350083, 175, 426, 2, 23.00, 24728.91, 0.10, 0.07, 'N', 'O', '1997-09-15', '1997-08-01', '1997-10-12', 'NONE', 'TRUCK', 'accounts wake accounts. packages wake fi'); +INSERT INTO `lineitem` VALUES (407073, 1436, 939, 3, 38.00, 50822.34, 0.07, 0.01, 'N', 'O', '1996-06-07', '1996-05-05', '1996-06-13', 'NONE', 'TRUCK', ' bold accounts. final acco'); +INSERT INTO `lineitem` VALUES (22532, 201, 202, 1, 9.00, 9910.80, 0.08, 0.00, 'R', 'F', '1995-06-07', '1995-04-22', '1995-06-08', 'TAKE BACK RETURN', 'AIR', ' the express, slow theodoli'); +INSERT INTO `lineitem` VALUES (19047, 175, 426, 2, 45.00, 48382.65, 0.03, 0.01, 'A', 'F', '1994-03-20', '1994-03-09', '1994-03-22', 'DELIVER IN PERSON', 'FOB', 'pending, daring '); +INSERT INTO `lineitem` VALUES (166243, 201, 202, 2, 25.00, 27530.00, 0.06, 0.03, 'R', 'F', '1994-02-09', '1994-03-17', '1994-02-15', 'NONE', 'TRUCK', 'ogs breach blithely ideas. unusual reques'); +INSERT INTO `lineitem` VALUES (220421, 175, 426, 3, 23.00, 24728.91, 0.06, 0.05, 'R', 'F', '1992-06-10', '1992-04-02', '1992-06-18', 'TAKE BACK RETURN', 'RAIL', 'unusual deposits accordin'); +INSERT INTO `lineitem` VALUES (9287, 83, 84, 1, 16.00, 15729.28, 0.07, 0.00, 'N', 'O', '1998-03-25', '1998-02-10', '1998-04-16', 'DELIVER IN PERSON', 'FOB', 'ironic accounts sl'); +INSERT INTO `lineitem` VALUES (45862, 83, 84, 3, 1.00, 983.08, 0.00, 0.02, 'N', 'O', '1997-07-17', '1997-08-19', '1997-07-22', 'COLLECT COD', 'SHIP', 'accounts-- fluffily pending deposits a'); +INSERT INTO `lineitem` VALUES (92002, 83, 84, 1, 45.00, 44238.60, 0.01, 0.06, 'N', 'O', '1996-12-26', '1996-10-17', '1996-12-28', 'COLLECT COD', 'SHIP', 'ts. blithely even '); +INSERT INTO `lineitem` VALUES (389633, 336, 87, 2, 2.00, 2472.66, 0.09, 0.06, 'N', 'O', '1995-07-14', '1995-04-21', '1995-07-23', 'DELIVER IN PERSON', 'AIR', 'thely about the carefully'); +INSERT INTO `lineitem` VALUES (96739, 83, 84, 1, 48.00, 47187.84, 0.04, 0.00, 'R', 'F', '1994-08-24', '1994-08-14', '1994-09-22', 'NONE', 'REG AIR', 'sual accounts sle'); +INSERT INTO `lineitem` VALUES (575109, 83, 84, 2, 35.00, 34407.80, 0.09, 0.02, 'R', 'F', '1993-05-21', '1993-06-19', '1993-06-11', 'TAKE BACK RETURN', 'FOB', '. blithely ironic ideas after the carefull'); +INSERT INTO `lineitem` VALUES (284578, 83, 84, 2, 14.00, 13763.12, 0.03, 0.08, 'R', 'F', '1992-03-13', '1992-05-14', '1992-03-29', 'TAKE BACK RETURN', 'SHIP', 'lar requests. ironic packages nag '); +INSERT INTO `lineitem` VALUES (351843, 327, 828, 4, 11.00, 13500.52, 0.02, 0.04, 'N', 'O', '1998-03-21', '1998-04-30', '1998-04-05', 'NONE', 'TRUCK', 'ly silent requests-- fina'); +INSERT INTO `lineitem` VALUES (19014, 119, 870, 5, 38.00, 38726.18, 0.10, 0.05, 'N', 'O', '1997-10-08', '1997-11-23', '1997-10-26', 'NONE', 'REG AIR', 'sual theodol'); +INSERT INTO `lineitem` VALUES (22436, 362, 863, 3, 27.00, 34083.72, 0.10, 0.00, 'N', 'O', '1996-06-17', '1996-06-23', '1996-06-23', 'TAKE BACK RETURN', 'REG AIR', 'ackages haggle slyly '); +INSERT INTO `lineitem` VALUES (59108, 119, 870, 6, 21.00, 21401.31, 0.00, 0.06, 'N', 'O', '1995-11-16', '1995-12-13', '1995-11-27', 'DELIVER IN PERSON', 'SHIP', ' slyly. stealthily slow requests solve'); +INSERT INTO `lineitem` VALUES (593637, 327, 828, 6, 11.00, 13500.52, 0.03, 0.06, 'R', 'F', '1994-11-22', '1994-12-23', '1994-12-02', 'DELIVER IN PERSON', 'AIR', 'sly regular instructions.'); +INSERT INTO `lineitem` VALUES (15744, 119, 870, 1, 17.00, 17324.87, 0.10, 0.05, 'R', 'F', '1993-06-20', '1993-05-29', '1993-07-09', 'DELIVER IN PERSON', 'RAIL', 'quickly final requests sle'); +INSERT INTO `lineitem` VALUES (303877, 362, 863, 3, 39.00, 49232.04, 0.00, 0.01, 'A', 'F', '1992-11-28', '1992-12-18', '1992-11-29', 'DELIVER IN PERSON', 'MAIL', 'furiously.'); +ANALYZE TABLE supplier; +Table Op Msg_type Msg_text +pq_database.supplier analyze status OK +ANALYZE TABLE lineitem; +Table Op Msg_type Msg_text +pq_database.lineitem analyze status OK +ANALYZE TABLE orders; +Table Op Msg_type Msg_text +pq_database.orders analyze status OK +ANALYZE TABLE customer; +Table Op Msg_type Msg_text +pq_database.customer analyze status OK +ANALYZE TABLE nation; +Table Op Msg_type Msg_text +pq_database.nation analyze status OK +ANALYZE TABLE part; +Table Op Msg_type Msg_text +pq_database.part analyze status OK +ANALYZE TABLE partsupp; +Table Op Msg_type Msg_text +pq_database.partsupp analyze status OK +explain select +supp_nation, +cust_nation, +l_year, +sum(volume) as revenue +from +( +select +n1.n_name as supp_nation, +n2.n_name as cust_nation, +extract(year from l_shipdate) as l_year, +l_extendedprice * (1 - l_discount) as volume +from +supplier, +lineitem, +orders, +customer, +nation n1, +nation n2 +where +s_suppkey = l_suppkey +and o_orderkey = l_orderkey +and c_custkey = o_custkey +and s_nationkey = n1.n_nationkey +and c_nationkey = n2.n_nationkey +and ( +(n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') +or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE') +) +and l_shipdate between date '1995-01-01' and date '1996-12-31' + ) as shipping +group by +supp_nation, +cust_nation, +l_year +order by +supp_nation, +cust_nation, +l_year; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE customer NULL index PRIMARY,CUSTOMER_FK1 CUSTOMER_FK1 4 NULL 4 100.00 Using index; Using temporary; Using filesort +2 SIMPLE n2 NULL eq_ref PRIMARY PRIMARY 4 pq_database.customer.C_NATIONKEY 1 19.00 Using where +2 SIMPLE orders NULL ref PRIMARY,ORDERS_FK1 ORDERS_FK1 4 pq_database.customer.c_custkey 1 100.00 Using index +2 SIMPLE lineitem NULL ref PRIMARY PRIMARY 4 pq_database.orders.o_orderkey 1 11.11 Using where +2 SIMPLE supplier NULL eq_ref PRIMARY,SUPPLIER_FK1 PRIMARY 4 pq_database.lineitem.L_SUPPKEY 1 100.00 NULL +2 SIMPLE n1 NULL eq_ref PRIMARY PRIMARY 4 pq_database.supplier.S_NATIONKEY 1 19.00 Using where +Warnings: +Note 1003 /* select#1 */ select `pq_database`.`n1`.`N_NAME` AS `supp_nation`,`pq_database`.`n2`.`N_NAME` AS `cust_nation`,extract(year from `pq_database`.`lineitem`.`L_SHIPDATE`) AS `l_year`,sum((`pq_database`.`lineitem`.`L_EXTENDEDPRICE` * (1 - `pq_database`.`lineitem`.`L_DISCOUNT`))) AS `revenue` from `pq_database`.`supplier` join `pq_database`.`lineitem` join `pq_database`.`orders` join `pq_database`.`customer` join `pq_database`.`nation` `n1` join `pq_database`.`nation` `n2` where ((`pq_database`.`n2`.`n_nationkey` = `pq_database`.`customer`.`C_NATIONKEY`) and (`pq_database`.`n1`.`n_nationkey` = `pq_database`.`supplier`.`S_NATIONKEY`) and (`pq_database`.`orders`.`O_CUSTKEY` = `pq_database`.`customer`.`c_custkey`) and (`pq_database`.`lineitem`.`l_orderkey` = `pq_database`.`orders`.`o_orderkey`) and (`pq_database`.`supplier`.`s_suppkey` = `pq_database`.`lineitem`.`L_SUPPKEY`) and (((`pq_database`.`n2`.`N_NAME` = 'GERMANY') and (`pq_database`.`n1`.`N_NAME` = 'FRANCE')) or ((`pq_database`.`n2`.`N_NAME` = 'FRANCE') and (`pq_database`.`n1`.`N_NAME` = 'GERMANY'))) and (`pq_database`.`lineitem`.`L_SHIPDATE` between DATE'1995-01-01' and DATE'1996-12-31')) group by `shipping`.`supp_nation`,`shipping`.`cust_nation`,`shipping`.`l_year` order by `shipping`.`supp_nation`,`shipping`.`cust_nation`,`l_year` +select +supp_nation, +cust_nation, +l_year, +sum(volume) as revenue +from +( +select +n1.n_name as supp_nation, +n2.n_name as cust_nation, +extract(year from l_shipdate) as l_year, +l_extendedprice * (1 - l_discount) as volume +from +supplier, +lineitem, +orders, +customer, +nation n1, +nation n2 +where +s_suppkey = l_suppkey +and o_orderkey = l_orderkey +and c_custkey = o_custkey +and s_nationkey = n1.n_nationkey +and c_nationkey = n2.n_nationkey +and ( +(n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') +or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE') +) +and l_shipdate between date '1995-01-01' and date '1996-12-31' + ) as shipping +group by +supp_nation, +cust_nation, +l_year +order by +supp_nation, +cust_nation, +l_year; +supp_nation cust_nation l_year revenue +FRANCE GERMANY 1995 48467.6976 +FRANCE GERMANY 1996 42453.7312 +GERMANY FRANCE 1995 41933.4552 +GERMANY FRANCE 1996 32126.2860 +explain select +nation, +o_year, +sum(amount) as sum_profit +from +( +select +n_name as nation, +extract(year from o_orderdate) as o_year, +l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount +from +part, +supplier, +lineitem, +partsupp, +orders, +nation +where +s_suppkey = l_suppkey +and ps_suppkey = l_suppkey +and ps_partkey = l_partkey +and p_partkey = l_partkey +and o_orderkey = l_orderkey +and s_nationkey = n_nationkey +and p_name like '%green%' + ) as profit +group by +nation, +o_year +order by +nation, +o_year desc; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 32 11.11 Parallel execute (1 workers) +2 SIMPLE part NULL ALL PRIMARY NULL NULL NULL 32 11.11 Using where; Using temporary; Using filesort +2 SIMPLE partsupp NULL ref PRIMARY,PARTSUPP_FK1 PRIMARY 4 pq_database.part.p_partkey 1 100.00 NULL +2 SIMPLE supplier NULL eq_ref PRIMARY,SUPPLIER_FK1 PRIMARY 4 pq_database.partsupp.PS_SUPPKEY 1 100.00 NULL +2 SIMPLE nation NULL eq_ref PRIMARY PRIMARY 4 pq_database.supplier.S_NATIONKEY 1 100.00 NULL +2 SIMPLE lineitem NULL ref PRIMARY,LINEITEM_FK2 LINEITEM_FK2 8 pq_database.part.p_partkey,pq_database.partsupp.PS_SUPPKEY 2 100.00 NULL +2 SIMPLE orders NULL eq_ref PRIMARY PRIMARY 4 pq_database.lineitem.l_orderkey 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `pq_database`.`nation`.`N_NAME` AS `nation`,extract(year from `pq_database`.`orders`.`O_ORDERDATE`) AS `o_year`,sum(((`pq_database`.`lineitem`.`L_EXTENDEDPRICE` * (1 - `pq_database`.`lineitem`.`L_DISCOUNT`)) - (`pq_database`.`partsupp`.`PS_SUPPLYCOST` * `pq_database`.`lineitem`.`L_QUANTITY`))) AS `sum_profit` from `pq_database`.`part` join `pq_database`.`supplier` join `pq_database`.`lineitem` join `pq_database`.`partsupp` join `pq_database`.`orders` join `pq_database`.`nation` where ((`pq_database`.`nation`.`n_nationkey` = `pq_database`.`supplier`.`S_NATIONKEY`) and (`pq_database`.`orders`.`o_orderkey` = `pq_database`.`lineitem`.`l_orderkey`) and (`pq_database`.`partsupp`.`ps_partkey` = `pq_database`.`part`.`p_partkey`) and (`pq_database`.`lineitem`.`L_PARTKEY` = `pq_database`.`part`.`p_partkey`) and (`pq_database`.`supplier`.`s_suppkey` = `pq_database`.`partsupp`.`PS_SUPPKEY`) and (`pq_database`.`lineitem`.`L_SUPPKEY` = `pq_database`.`partsupp`.`PS_SUPPKEY`) and (`pq_database`.`part`.`P_NAME` like '%green%')) group by `profit`.`nation`,`profit`.`o_year` desc order by `profit`.`nation`,`o_year` desc +select +nation, +o_year, +sum(amount) as sum_profit +from +( +select +n_name as nation, +extract(year from o_orderdate) as o_year, +l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount +from +part, +supplier, +lineitem, +partsupp, +orders, +nation +where +s_suppkey = l_suppkey +and ps_suppkey = l_suppkey +and ps_partkey = l_partkey +and p_partkey = l_partkey +and o_orderkey = l_orderkey +and s_nationkey = n_nationkey +and p_name like '%green%' + ) as profit +group by +nation, +o_year +order by +nation, +o_year desc; +nation o_year sum_profit +ALGERIA 1998 25768.7810 +ALGERIA 1997 15548.4252 +ALGERIA 1996 14607.9516 +ALGERIA 1995 13087.9014 +ALGERIA 1994 12961.3008 +ALGERIA 1993 10960.6926 +ALGERIA 1992 9517.8638 +ARGENTINA 1997 4883.8698 +ARGENTINA 1996 749.3481 +ARGENTINA 1994 3676.5720 +ARGENTINA 1993 25702.6112 +ARGENTINA 1992 25013.2224 +BRAZIL 1997 42083.4240 +BRAZIL 1996 38741.9592 +BRAZIL 1994 14753.2680 +BRAZIL 1993 37208.5708 +BRAZIL 1992 865.3156 +CANADA 1998 39413.7216 +CANADA 1997 8581.7984 +CANADA 1996 5111.3500 +CANADA 1995 6728.0400 +CANADA 1994 24022.3086 +CANADA 1993 1061.3120 +CANADA 1992 21853.7748 +CHINA 1997 4014.3000 +CHINA 1996 12894.1560 +CHINA 1995 4397.7400 +CHINA 1994 6712.3400 +CHINA 1993 3558.7200 +CHINA 1992 4990.8000 +ETHIOPIA 1998 27808.4205 +ETHIOPIA 1997 26875.7940 +ETHIOPIA 1996 46347.3675 +ETHIOPIA 1995 33067.6480 +ETHIOPIA 1994 17760.1924 +ETHIOPIA 1993 7623.3101 +ETHIOPIA 1992 29305.8876 +FRANCE 1996 5190.9060 +FRANCE 1995 12593.3808 +FRANCE 1994 36955.5000 +GERMANY 1998 8896.6300 +GERMANY 1997 8850.0000 +GERMANY 1996 12268.2300 +GERMANY 1995 15430.3600 +GERMANY 1994 15374.7000 +GERMANY 1993 3958.4000 +GERMANY 1992 15789.9300 +INDIA 1998 7316.0690 +INDIA 1997 4125.6711 +INDIA 1996 6174.1164 +INDIA 1994 3143.4032 +INDIA 1992 13882.6548 +INDONESIA 1998 8341.1700 +INDONESIA 1996 10758.7546 +IRAN 1996 11002.4084 +IRAQ 1998 4750.4856 +JAPAN 1998 4357.0752 +JAPAN 1993 14214.3792 +JORDAN 1992 12560.4288 +KENYA 1998 37073.4000 +KENYA 1997 533.2375 +KENYA 1996 17433.9200 +KENYA 1995 10189.5300 +KENYA 1994 3129.9900 +KENYA 1993 15926.3700 +KENYA 1992 6537.7200 +MOROCCO 1998 31079.2300 +ROMANIA 1998 67875.6320 +ROMANIA 1997 4805.4594 +ROMANIA 1996 5716.5962 +ROMANIA 1995 7597.8091 +ROMANIA 1994 29894.8328 +ROMANIA 1993 18150.4342 +ROMANIA 1992 13122.9770 +UNITED KINGDOM 1996 38468.1562 +UNITED STATES 1995 1571.4806 +drop table partsupp; +drop table supplier; +drop table lineitem; +drop table orders; +drop table customer; +drop table nation; +drop table part; +drop database pq_database; diff --git a/mysql-test/suite/parallel_query/r/pq_variables.result-pq b/mysql-test/suite/parallel_query/r/pq_variables.result-pq new file mode 100644 index 000000000..a8d55b1e8 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_variables.result-pq @@ -0,0 +1,142 @@ +set @saved_force_parallel_execute = @@force_parallel_execute; +set @saved_parallel_cost_threshold = @@parallel_cost_threshold; +set @saved_parallel_default_dop = @@parallel_default_dop; +set @saved_parallel_max_threads = @@parallel_max_threads; +create table t1(id int); +insert into t1 select 1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +insert into t1 select id + 1 from t1; +set session force_parallel_execute = true; +### test parallel_cost_threadhold +set session parallel_cost_threshold = 0; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set session parallel_cost_threshold = 99999; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +### test parallel_default_dop +set session parallel_cost_threshold = 0; +set session parallel_default_dop=10; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set session parallel_default_dop=2; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (2 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set session parallel_default_dop=0; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +### test parallel hint +set session parallel_default_dop=4; +set session force_parallel_execute = false; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +explain select/*+ PQ */ sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +explain select/*+ PQ(10) */ sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +### test force_parallel query +set session parallel_default_dop=4; +set session force_parallel_execute = false; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set session force_parallel_execute = true; +explain select sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +### test parallel max_threads +set session force_parallel_execute = true; +set session parallel_default_dop=4; +set global parallel_max_threads = 64; +explain select/*+ PQ(32) */ sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set global parallel_max_threads = 16; +explain select/*+ PQ(32) */ sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set global parallel_max_threads = 64; +explain select/*+ NO_PQ */ sum(id) from t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ NO_PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +### test parallel queue_timeout +set global parallel_max_threads=8; +set global debug_pq_worker_stall = true; +select/*+ PQ(8) */ sum(id) from t1;; +show status like "PQ_threads_running"; +Variable_name Value +PQ_threads_running 7 +----con2 wait parallel threads 5s----- +set session parallel_queue_timeout=5000; +explain select/*+ PQ(8) */ sum(id) from t1;; +----con3 no wait for parallel threads----- +set session parallel_queue_timeout=0; +explain select/*+ PQ(8) */ sum(id) from t1;; +set global debug_pq_worker_stall = false; +sum(id) +6144 +----con2 parallel query----- +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1024 100.00 Parallel execute (3 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +----con3 no parallel query----- +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1024 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select /*+ PQ(@`select#1`) */ sum(`test`.`t1`.`id`) AS `sum(id)` from `test`.`t1` +set session parallel_default_dop = @saved_parallel_default_dop; +set global parallel_max_threads = @saved_parallel_max_threads; +set session parallel_cost_threshold = @saved_parallel_cost_threshold; +set session force_parallel_execute = @saved_force_parallel_execute; +drop table t1; diff --git a/mysql-test/suite/parallel_query/r/pq_worker_error.result-pq b/mysql-test/suite/parallel_query/r/pq_worker_error.result-pq new file mode 100644 index 000000000..8aa5aab15 --- /dev/null +++ b/mysql-test/suite/parallel_query/r/pq_worker_error.result-pq @@ -0,0 +1,168 @@ +create table t1(id int, a varchar(10)); +insert into t1 values(1, 'aa'), (2, 'bb'); +set @saved_force_parallel_execute = @@force_parallel_execute; +set session force_parallel_execute = 1; +set session sql_mode = ''; +set session debug=""; +set session debug="+d, pq_worker_abort1"; +select * from t1; +ERROR HY000: Parallel execution error +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +set session debug="+d, pq_worker_abort2"; +select a, sum(a) from t1 group by a order by a desc, id; +ERROR HY000: Parallel execution error +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id; +a sum(a) +cc 0 +bb 0 +aa 0 +show status like "PQ_memory_used"; +Variable_name Value +PQ_memory_used 0 +set @@parallel_default_dop = 8; +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id; +a sum(a) +cc 0 +bb 0 +aa 0 +set session debug=""; +set session debug="+d, pq_worker_error1"; +select a, sum(a) from t1 group by a order by a desc, id; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error2"; +select a, sum(a) from t1 group by a order by a desc, id; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error3"; +select * from t1 order by id desc, a; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error4"; +select * from t1 order by id desc, a; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error5"; +select * from t1 order by id desc, a; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error6"; +select * from t1; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error7"; +select * from t1; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error8"; +select * from t1; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_worker_error9"; +select * from t1 limit 15; +id a +1 aa +2 bb +27 cc +26 cc +25 cc +24 cc +23 cc +22 cc +21 cc +20 cc +19 cc +18 cc +17 cc +16 cc +15 cc +set session debug=""; +set session force_parallel_execute = 0; +select * from t1 limit 15; +id a +1 aa +2 bb +27 cc +26 cc +25 cc +24 cc +23 cc +22 cc +21 cc +20 cc +19 cc +18 cc +17 cc +16 cc +15 cc +set session force_parallel_execute = 1; +set @@parallel_default_dop = 8; +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id; +a sum(a) +cc 0 +bb 0 +aa 0 +DROP TABLE t1; +create table t3( +a int NOT NULL, +b int NOT NULL, +c int NOT NULL, +primary key (a, b), +unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; +insert into t3 values (1, 1, 2); +insert into t3 values (1, 2, 1); +insert into t3 values (0, 1, 3); +insert into t3 values (1, 0, 4); +explain select * from t3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t3 NULL index NULL c 4 NULL 4 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t3` +set session debug=""; +set session debug="+d, pq_msort_error1"; +select * from t3; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_msort_error2"; +select * from t3; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_msort_error3"; +select * from t3; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_msort_error4"; +select * from t3; +ERROR HY000: Parallel execution error +set session debug=""; +set session debug="+d, pq_msort_error5"; +select * from t3 order by a; +ERROR HY000: Memory allocation error: in function (MSort::store_mq_record). +DROP TABLE t3; +CREATE TABLE t(a varbinary(10)); +INSERT INTO t VALUES(0xFF00F0F0), (0xF0F0FF); +INSERT INTO t VALUES(0xFF00F0F0), (0xF0F000); +set session debug=""; +SELECT BIT_AND(a) FROM t; +ERROR HY000: Binary operands of bitwise operators must be of equal length +DROP TABLE t; +create table t1(a int) ; +insert into t1 values(1),(2),(3); +set session debug=""; +set session debug='+d,ha_pq_next_deadlock'; +select * from t1 order by a; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +drop table t1; +SET debug= DEFAULT; +# restart diff --git a/mysql-test/suite/parallel_query/t/pq_abort.test b/mysql-test/suite/parallel_query/t/pq_abort.test new file mode 100644 index 000000000..e9fe02434 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_abort.test @@ -0,0 +1,115 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create table t1(id int, a varchar(10)); +insert into t1 values(1, 'aa'), (2, 'bb'); + +set @saved_force_parallel_execute = @@force_parallel_execute; + +set session force_parallel_execute = 1; +explain select * from t1 limit 1; +select * from t1 limit 1; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, dup_thd_abort"; + +--error ER_PARALLEL_FAIL_INIT +explain select * from t1 limit 1; + +--error ER_PARALLEL_FAIL_INIT +select * from t1 limit 1; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, dup_join_abort"; + +--error ER_PARALLEL_FAIL_INIT +explain select * from t1 limit 1; + +--error ER_PARALLEL_FAIL_INIT +select * from t1 limit 1; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, dup_select_abort1"; + +--error ER_PARALLEL_FAIL_INIT +explain select * from t1 limit 1; + +--error ER_PARALLEL_FAIL_INIT +select * from t1 limit 1; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, dup_select_abort2"; +--error ER_PARALLEL_FAIL_INIT +explain select * from t1 limit 1; + +--error ER_PARALLEL_FAIL_INIT +select * from t1 limit 1; +show status like "PQ_memory_used"; + +set session debug="+d, pq_leader_abort1"; +--error ER_PARALLEL_FAIL_INIT +explain select * from t1 limit 1; + +--error ER_PARALLEL_FAIL_INIT +select * from t1 limit 1; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, pq_leader_abort2"; + +--error ER_PARALLEL_FAIL_INIT +explain select * from t1 limit 1; + +--error ER_PARALLEL_FAIL_INIT +select * from t1 limit 1; + +show status like "PQ_memory_used"; + +set session debug=""; +explain select * from t1 limit 1; +select * from t1 limit 1; +show status like "PQ_memory_used"; + +drop table t1; + +# Case from opt_hints.test. +# BUG: this query has two tables, which cannot run parallelly, +# but dsmrr_init don't know pq is disabled. +CREATE TABLE t1(f1 INT, f2 INT); +INSERT INTO t1 VALUES +(1,1),(2,2),(3,3); + +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, f3 CHAR(200), KEY(f1, f2)); +INSERT INTO t2 VALUES +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'), +(1,1, 'qwerty'),(1,2, 'qwerty'),(1,3, 'qwerty'), +(2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'), (2,4, 'qwerty'),(2,5, 'qwerty'), +(3,1, 'qwerty'),(3,4, 'qwerty'), +(4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'), (4,4, 'qwerty'); + +CREATE TABLE t3 (f1 INT NOT NULL, f2 INT, f3 VARCHAR(32), + PRIMARY KEY(f1), KEY f2_idx(f1), KEY f3_idx(f3)); +INSERT INTO t3 VALUES +(1, 1, 'qwerty'), (2, 1, 'ytrewq'), +(3, 2, 'uiop'), (4, 2, 'poiu'), (5, 2, 'lkjh'), +(6, 2, 'uiop'), (7, 2, 'poiu'), (8, 2, 'lkjh'), +(9, 2, 'uiop'), (10, 2, 'poiu'), (11, 2, 'lkjh'), +(12, 2, 'uiop'), (13, 2, 'poiu'), (14, 2, 'lkjh'); +INSERT INTO t3 SELECT f1 + 20, f2, f3 FROM t3; +INSERT INTO t3 SELECT f1 + 40, f2, f3 FROM t3; + +SELECT /*+ BKA() */ t2.f1, t2.f2, t2.f3 FROM t1,t2 +WHERE t1.f1=t2.f1 AND t2.f2 BETWEEN t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1; + +drop table t1, t2, t3; +set session force_parallel_execute = @saved_force_parallel_execute; + +--let $wait_counter= 10000 +--source include/restart_mysqld.inc diff --git a/mysql-test/suite/parallel_query/t/pq_aggr_no_record.test b/mysql-test/suite/parallel_query/t/pq_aggr_no_record.test new file mode 100644 index 000000000..25485f0f1 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_aggr_no_record.test @@ -0,0 +1,38 @@ +-- source include/pq_test.inc + +-- echo # check aggregation when innodb return zero line + +CREATE TABLE records_in_range_test ( + c1 VARCHAR(16), + c2 VARCHAR(512), + PRIMARY KEY (c1) +) ENGINE=INNODB; + +# Insert some records so that they cannot fit in one page for some page sizes +# in order to exercise records_in_range() where 1, 2 or more pages are sampled +INSERT INTO records_in_range_test VALUES +('ccc', REPEAT('v', 512)), +('kkk01', REPEAT('v', 512)), +('kkk02', REPEAT('v', 512)), +('kkk03', REPEAT('v', 512)), +('kkk04', REPEAT('v', 512)), +('kkk05', REPEAT('v', 512)), +('kkk06', REPEAT('v', 512)), +('kkk07', REPEAT('v', 512)), +('kkk08', REPEAT('v', 512)), +('mmm', REPEAT('v', 512)), +('nnn', REPEAT('v', 512)), +('uuu01', REPEAT('v', 512)), +('uuu02', REPEAT('v', 512)), +('uuu03', REPEAT('v', 512)), +('uuu04', REPEAT('v', 512)), +('uuu05', REPEAT('v', 512)), +('uuu06', REPEAT('v', 512)), +('uuu07', REPEAT('v', 512)), +('uuu08', REPEAT('v', 512)), +('xxx', REPEAT('v', 512)); + +SELECT COUNT(*) FROM records_in_range_test WHERE c1 < 'ccc'; +SELECT COUNT(*) FROM records_in_range_test WHERE c1 < 'xxx'; + +drop table records_in_range_test; diff --git a/mysql-test/suite/parallel_query/t/pq_blob.test b/mysql-test/suite/parallel_query/t/pq_blob.test new file mode 100644 index 000000000..1aa6579b9 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_blob.test @@ -0,0 +1,27 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t2(d varchar(17) PRIMARY KEY) ENGINE=innodb DEFAULT CHARSET=utf8; +CREATE TABLE t3(a int PRIMARY KEY) ENGINE=innodb; +INSERT INTO t3 VALUES (22),(44),(33),(55),(66); +INSERT INTO t2 VALUES ('jejdkrun87'),('adfd72nh9k'), ('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik'); +CREATE TABLE t1(a int, b blob, c text, d text NOT NULL) ENGINE=innodb DEFAULT CHARSET=utf8 STATS_PERSISTENT=0; +INSERT INTO t1 SELECT a,LEFT(REPEAT(d,100*a),65535),REPEAT(d,20*a),d FROM t2,t3 order by a, d; +DROP TABLE t2, t3; +DELETE FROM t1 WHERE d='null'; +DELETE FROM t1 WHERE a%2; +CHECK TABLE t1; +ALTER TABLE t1 ADD PRIMARY KEY (a,b(255),c(255)), ADD KEY (b(767)); +set force_parallel_execute=1; +set parallel_cost_threshold=0; +SELECT COUNT(*) FROM t1 WHERE a=44; + +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_charset.test b/mysql-test/suite/parallel_query/t/pq_charset.test new file mode 100644 index 000000000..d5922c7a8 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_charset.test @@ -0,0 +1,168 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +## Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT ## +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 +(a INT, + b INT, + PRIMARY KEY (a)) +ENGINE = InnoDB; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +--echo # con1 +--connect (con1, localhost, root,,) +use pq_test; + +ALTER TABLE t1 ADD INDEX idx1 (b); +--connection default +--echo # con default +--error ER_TABLE_DEF_CHANGED +SELECT b FROM t1 WHERE b = 0; +--error ER_TABLE_DEF_CHANGED +SELECT b FROM t1 WHERE b = 0; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t1; +--disconnect con1 + +drop table pq_test.t1; + +--connection default +create table t1(a int) charset utf8mb4; +show create table t1; +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; + + +create table t3 ( + a char(8) not null, b char(8) not null, filler char(200), + key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), + 'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), + 'filler-2' from t2 A; + +# Test empty result set +select a,filler from t3 where a >= 'c-9011=w'; + +# Ok, t3.ref_length=6, limit is 64 => 10 elements fit into the buffer +# Test the cases when buffer gets exhausted at different points in source +# intervals: + +# 1. Split is in the middle of the range +--sorted_result +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; +set optimizer_switch='mrr=on,mrr_cost_based=off'; +select a,filler from t3 where a >= 'c-9011=w'; + +drop table pq_test.t1; +set optimizer_switch='mrr=on,mrr_cost_based=on'; +create table t1 (a int, key (a)); +insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); +analyze table t1; + +explain select * from t1 where not(a < 5 or a > 15); +select * from t1 where not(a < 5 or a > 15); + +explain select * from t1 where a = 2 or not(a < 10); +select * from t1 where a = 2 or not(a < 10); + +explain select * from t1 where a = 7 or not(a < 15 and a > 5); +select * from t1 where a = 7 or not(a < 15 and a > 5); + +delete from t1 where a > 3; +select a from t1; + +analyze table t1; + +explain select * from t1 force index(a) where not(a >0 and a < 1); +select * from t1 force index(a) where not(a >0 and a < 1); + +select * from t1 where a < 3; +select * from t1 where a is null; + +drop table pq_test.t1; +create table t1 (id int, id2 int, index (id)); +insert into t1 values(2,2); +analyze table t1; +select * from t1 where id is null or id > 1; + +insert into t1 values(null,2); +select * from t1; +select * from t1 where id is null or id > 1; + + +drop table pq_test.t1; +create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10))) +stats_persistent=0; + +insert into t1 values(concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' ')); +insert into t1 values(concat(char(ascii('a')),' '),concat(char(ascii('a')),' '),concat(char(ascii('a')),' ')); +insert into t1 values(concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' '),concat(char(ascii('a')+1),' ')); +insert into t1 values(concat(char(ascii('a')),' '),concat(char(ascii('a')),' '),concat(char(ascii('a')),' ')); + +select * from t1; + +alter table t1 add key(v); +alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); +select count(*) from t1 where v like 'a%'; +select count(*) from t1 where v like 'a %'; +alter table t1 drop key v, add key v (v(30)); +#select count(*) from t1 where v like 'a%'; +#select count(*) from t1 where v like 'a %'; +select 1 from t1 where v like 'a%'; +select 1 from t1 where v like 'a %'; +drop table pq_test.t1; + +set names utf8mb4; +--disable_warnings +eval create table t1 ( + a int primary key, + b varchar(6), + index b3(b(3)) +) engine=innodb character set=utf8mb4; +--enable_warnings +insert into t1 values(1,'foo'),(2,'foobar'); +--sorted_result +select * from t1 where b like 'foob%'; +drop table pq_test.t1; +CREATE TABLE t1 ( + a char(255) DEFAULT '', + KEY(a(10)) +) ENGINE=innodb DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; + +drop table pq_test.t1; +SET time_zone='+00:00'; +CREATE TABLE t1 (a DECIMAL(20,7)); +INSERT INTO t1 VALUES +(2147483647.999999), +(2147483647.9999990), +(2147483647.9999991), +(2147483647.9999992), +(2147483647.9999993), +(2147483647.9999994), +(2147483647.9999995), +(2147483647.9999996), +(2147483647.9999997), +(2147483647.9999998), +(2147483647.9999999); +SELECT a, FROM_UNIXTIME(a) FROM t1; + + +drop table pq_test.t1; +drop table pq_test.t2; +drop table pq_test.t3; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_check_first_rewritten_tab.test b/mysql-test/suite/parallel_query/t/pq_check_first_rewritten_tab.test new file mode 100644 index 000000000..7ce881be6 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_check_first_rewritten_tab.test @@ -0,0 +1,45 @@ +--source include/pq_test.inc +--source include/have_debug.inc +# normal data +create table t1( + a int NOT NULL, + b varchar(50) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; + +insert into t1 values (2, 'mysql'), (1, NULL), (0, 'hwsql'); +select * from t1; + + +# blob +drop table if exists `t1`; +SET NAMES utf8mb4; +SET collation_connection='gb18030_chinese_ci'; +CREATE TABLE t1(C VARCHAR(100) CHARACTER SET gb18030, KEY(c(20))); +INSERT INTO t1 VALUES(0xD2A3CFEBB9ABE8AAB5B1C4EAA3ACD0A1C7C7B3F5BCDEC1CBA3ACD0DBD7CBD3A2B7A2A1A3); +INSERT INTO t1 VALUES(0xD3F0C9C8C2DABDEDA3ACCCB8D0A6BCE4A1A2E9C9E9D6BBD2B7C9D1CCC3F0A1A3); +INSERT INTO t1 VALUES(0xB9CAB9FAC9F1D3CEA3ACB6E0C7E9D3A6D0A6CED2A1A2D4E7C9FABBAAB7A2A1A3); +INSERT INTO t1 VALUES(0xC8CBBCE4C8E7C3CEA3ACD2BBE9D7BBB9F5AABDADD4C2A1A3); +SELECT c, HEX(c), CONVERT(c USING utf8mb4) FROM t1; + +# json +drop table if exists `t1`; +create table t1 ( + id int, + a varchar(100), + b varchar(512), + c JSON, + d geometry) Engine = InnoDB DEFAULT CHARSET=utf8mb4; + +insert into t1 values (1, 'hello', 'At the time of granting a lock to a transaction', '{"NAME": "Brett", "email": "brett@xxx.com"}', ST_GeomFromText('point(108.9498710632 34.2588125935)')); +insert into t1 values (2, 'Dependencies', 'these dependencies can be quite complex', '{"time":"2015-01-01 13:00:00","ip":"192.168.1.1","result":"fail"}', ST_GeomFromText('point(108.9465236664 34.2598766768)')); +insert into t1 values (null, 'At the time of granting', 'the database are equally popular', '{"time":"2015-10-07 06:44:00","ip":"192.168.1.0","result":"success"}', ST_GeomFromText('point(108.9477252960 34.2590342786)')); +insert into t1 values (4, 'Not all objects in the database', 'Locks are the most commonly used mechanism', '{"NAME": "Brett", "email": "126@xxx.com"}',null); +insert into t1 values (6, 'transaction', null, null, ST_GeomFromText('point(108.9443349838 34.2595663206)')); + +select * from t1; +select id, a, b from t1; +select id, b, c from t1; +select b, d from t1; +select a, d from t1; + +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_coverage.test b/mysql-test/suite/parallel_query/t/pq_coverage.test new file mode 100644 index 000000000..1c88f61dd --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_coverage.test @@ -0,0 +1,170 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +--disable_query_log +CALL mtr.add_suppression("[Parallel query]*"); +--enable_query_log + +CREATE TABLE t1(id int, name varchar(10), primary key(id)); +INSERT INTO t1 VALUES(1,'AAAA'); +INSERT INTO t1 VALUES(2,'BBBB'); +INSERT INTO t1 VALUES(3,'CCCC'); + +#------------ TEST pq_clone_error1 ------# +EXPLAIN SELECT * FROM t1 WHERE id > 1; +SELECT * FROM t1 WHERE id > 1; + +SET session debug="+d, pq_clone_error1"; +--error ER_PARALLEL_FAIL_INIT +SELECT * FROM t1 WHERE id > 1; +SET session debug="-d, pq_clone_error1"; + +#------------ TEST LOCATE_FUNC ------# +SELECT LOCATE("A", name, 2) FROM t1; + +#------------ TEST parallel_threads_running ---------# +set @saved_parallel_max_threads = @@parallel_max_threads; +SET GLOBAL parallel_max_threads = 5; + +DELIMITER //; +CREATE PROCEDURE pro_insert(cnt int) +BEGIN +DECLARE i int DEFAULT 0; +START TRANSACTION; +WHILE i b; +SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b; +drop table t1; + + diff --git a/mysql-test/suite/parallel_query/t/pq_coverage_index.test b/mysql-test/suite/parallel_query/t/pq_coverage_index.test new file mode 100644 index 000000000..5fa7ffa65 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_coverage_index.test @@ -0,0 +1,64 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +-- disable_query_log +SET @transaction_isolation_orig = @@transaction_isolation; +SET @innodb_file_per_table_orig = @@innodb_file_per_table; +# The flag innodb_change_buffering_debug is only available in debug builds. +# It instructs InnoDB to try to evict pages from the buffer pool when +# change buffering is possible, so that the change buffer will be used +# whenever possible. +-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; +-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_change_buffering_debug = 1; +-- enable_query_log + +SET GLOBAL transaction_isolation='REPEATABLE-READ'; +SET GLOBAL innodb_file_per_table=on; + +CREATE TABLE bug56680( + a INT AUTO_INCREMENT PRIMARY KEY, + b CHAR(1), + c INT, + INDEX(b)) +ENGINE=InnoDB STATS_PERSISTENT=0; + +INSERT INTO bug56680 VALUES(0,'x',1); +BEGIN; +SELECT b FROM bug56680; + +connect (con1,localhost,root,,); +connection con1; +use pq_test; +BEGIN; +UPDATE bug56680 SET b='X'; + +connection default; +# This should return the last committed value 'x', but would return 'X' +# due to a bug in row_search_for_mysql(). +SELECT b FROM bug56680; +# This would always return the last committed value 'x'. +SELECT * FROM bug56680; + +connection con1; +ROLLBACK; +disconnect con1; + +connection default; + +SELECT b FROM bug56680; +COMMIT; + +-- disable_query_log +SET GLOBAL transaction_isolation = @transaction_isolation_orig; +SET GLOBAL innodb_file_per_table = @innodb_file_per_table_orig; +-- error 0, ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_change_buffering_debug = @innodb_change_buffering_debug_orig; +-- enable_query_log + +drop table pq_test.bug56680; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_demon.test b/mysql-test/suite/parallel_query/t/pq_demon.test new file mode 100644 index 000000000..9f98d7feb --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_demon.test @@ -0,0 +1,5 @@ +--source include/pq_test.inc + +create table t1(a int); + +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_explain.test b/mysql-test/suite/parallel_query/t/pq_explain.test new file mode 100644 index 000000000..2cc643eb4 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_explain.test @@ -0,0 +1,406 @@ +--source include/pq_test.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +set @saved_force_parallel_execute = @@force_parallel_execute; + +## index condition pushdown ## + + CREATE TABLE `cast_info` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `person_id` int(11) NOT NULL, + `movie_id` int(11) NOT NULL, + `person_role_id` int(11) DEFAULT NULL, + `note` varchar(250) DEFAULT NULL, + `nr_order` int(11) DEFAULT NULL, + `role_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `role_id_note` (`role_id`,`note`) +) ENGINE=InnoDB; + +set session force_parallel_execute=0; +explain SELECT * FROM cast_info WHERE role_id = 1 and note like '%Jaime%'; + +set session force_parallel_execute=1; +explain SELECT * FROM cast_info WHERE role_id = 1 and note like '%Jaime%'; + +drop table cast_info; + +## index scan ## + +create database pq_test; +use pq_test; + +create table t1( + id int primary key auto_increment, + col1 varchar(100), + col2 int, + key idx_col2(col2) + )engine= innodb; + +--disable_query_log + let $loop=10; + while($loop) + { + eval insert into pq_test.t1(col1, col2) values(repeat('test', 4), $loop); + dec $loop; + } +--enable_query_log + +set session force_parallel_execute = 0; +explain select count(*) from pq_test.t1; + +set session force_parallel_execute = 1; +explain select count(*) from pq_test.t1; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1 limit 1; + +set session force_parallel_execute = 1; +explain select * from pq_test.t1 limit 1; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1; + +set session force_parallel_execute = 1; +explain select * from pq_test.t1; + +set session force_parallel_execute = 0; +explain select id, col2 from pq_test.t1 force index(idx_col2); + +set session force_parallel_execute = 1; +explain select id, col2 from pq_test.t1 force index(idx_col2); + +## explain other connection + +connect (con1, localhost, root); + +--connection con1 + +set session force_parallel_execute = 1; +let $qid= `SELECT CONNECTION_ID()`; + +set DEBUG_SYNC='after_pq_leader_plan SIGNAL ready WAIT_FOR continue'; +--send select * from pq_test.t1 limit 1; + +--connection default +set DEBUG_SYNC='now WAIT_FOR ready'; + +--replace_regex /[0-9]+/#/ +--eval EXPLAIN FOR CONNECTION $qid; +set DEBUG_SYNC='now SIGNAL continue'; + +connection con1; +reap; +set DEBUG_SYNC="reset"; + +connection default; +set DEBUG_SYNC="reset"; + +## explain format=tree/json + +set session force_parallel_execute = 1; +explain format=tree select * from pq_test.t1; +explain format=json select * from pq_test.t1; + +set session force_parallel_execute = @saved_force_parallel_execute; + +drop table pq_test.t1; +drop database pq_test; + +## ----- range clust ------ + +create database pq_test; +use pq_test; + +create table t1( + id int primary key auto_increment, + col1 varchar(100), + col2 int, + key idx_col2(col2) + )engine= innodb; + +--disable_query_log + let $loop=100; + while($loop) + { + eval insert into pq_test.t1(col1, col2) values(repeat('test', 4), $loop); + dec $loop; + } +--enable_query_log + +show variables like 'force_parallel_execute'; +select count(*) from pq_test.t1; + +select * from pq_test.t1 limit 1; +select * from pq_test.t1 order by id desc limit 1; + +explain select * from pq_test.t1; +explain select * from pq_test.t1 for share; +explain select * from pq_test.t1 for update; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30; + +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id <= 30; + +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id <= 30; + +set session force_parallel_execute = 0; +explain select id from pq_test.t1 ignore index(idx_col2) where id > 20; + +set session force_parallel_execute = 1; +explain select id from pq_test.t1 ignore index(idx_col2) where id > 20; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id >= 20; + +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id > 10 and id < 80; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id >= 10 and id <= 80; + +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id >= 10 and id <= 80; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30 or id > 50; + +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where id < 30 or id > 50; + +set session force_parallel_execute = 0; +explain select * from pq_test.t1 ignore index(idx_col2) where (id > 10 and id < 50) or (id > 60 and id < 90); + +set session force_parallel_execute = 1; +explain select * from pq_test.t1 ignore index(idx_col2) where (id > 10 and id < 50) or (id > 60 and id < 90); + +set session force_parallel_execute = @saved_force_parallel_execute; + +drop table pq_test.t1; +drop database pq_test; + +## range second ## + +create database pq_test; +use pq_test; + +create table t1( + id int primary key auto_increment, + col1 varchar(100), + col2 int, + key idx_col2(col2) + )engine= innodb; + +--disable_query_log + let $loop=100; + while($loop) + { + eval insert into pq_test.t1(col1, col2) values(repeat('test', 4), $loop); + dec $loop; + } +--enable_query_log + +show variables like 'force_parallel_execute'; +select count(*) from pq_test.t1; + +select * from pq_test.t1 limit 1; +select * from pq_test.t1 order by id desc limit 1; + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30; + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30; + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 <= 30; + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 <= 30; + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 20; + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 20; + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 20; + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 20; + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 10 and col2 < 80; + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 10 and col2 < 80; + + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 10 and col2 <= 80; + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 10 and col2 <= 80; + + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30 or col2 > 50; + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 30 or col2 > 50; + + +set session force_parallel_execute = 0; +explain select id,col2 from pq_test.t1 force index(idx_col2) where (col2 > 10 and col2 < 50) or (col2 > 60 and col2 < 90); + +set session force_parallel_execute = 1; +explain select id,col2 from pq_test.t1 force index(idx_col2) where (col2 > 10 and col2 < 50) or (col2 > 60 and col2 < 90); + +set session force_parallel_execute = @saved_force_parallel_execute; + +drop table pq_test.t1; +drop database pq_test; + +## aggr group by ## +create database pq_test; +use pq_test; + +create table t1(a int primary key, b varchar(10), c decimal(5,2)); + +insert into t1 values (1, 'The', '3.14'); +insert into t1 values (2, 'quick', '4.25'); +insert into t1 values (3, 'brown', '5.36'); +insert into t1 values (4, 'fox', '6.47'); +insert into t1 values (5, 'jumps', '3.14'); +insert into t1 values (6, 'over', '4.25'); +insert into t1 values (7, 'the', '5.36'); +insert into t1 values (8, 'lazy', '6.47'); +insert into t1 values (9, 'dog', '7.58'); + +set session force_parallel_execute=0; +explain select count(*) from t1; +explain select count(c) from t1; +explain select sum(a) from t1; +explain select sum(c) from t1; +explain select avg(a) from t1; +explain select avg(c) from t1; + +set session force_parallel_execute=1; +explain select count(*) from t1; +explain select count(c) from t1; +explain select sum(a) from t1; +explain select sum(c) from t1; +explain select avg(a) from t1; +explain select avg(c) from t1; + +set session force_parallel_execute=0; +explain select sum(c) from t1 where a > 5; +explain select sum(a) from t1 where c > 5.0; +explain select avg(c) from t1 where a > 5; +explain select avg(a) from t1 where c > 5.0; +explain select count(*) from t1 where c > 5.0; +explain select count(c) from t1 where a > 5; + +set session force_parallel_execute=1; +explain select sum(c) from t1 where a > 5; +explain select sum(a) from t1 where c > 5.0; +explain select avg(c) from t1 where a > 5; +explain select avg(a) from t1 where c > 5.0; +explain select count(*) from t1 where c > 5.0; +explain select count(c) from t1 where a > 5; + +set session force_parallel_execute=0; +explain select c,sum(a) from t1 group by(c); +explain select b,sum(c) from t1 group by(b); +explain select c,avg(a) from t1 group by(c); +explain select b,avg(c) from t1 group by(b); +explain select count(*) from t1 group by(c); +explain select count(c) from t1 group by(b); + +set session force_parallel_execute=1; +explain select c,sum(a) from t1 group by(c); +explain select b,sum(c) from t1 group by(b); +explain select c,avg(a) from t1 group by(c); +explain select b,avg(c) from t1 group by(b); +explain select count(*) from t1 group by(c); +explain select count(c) from t1 group by(b); + +CREATE TABLE `t2` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `a` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +); + +insert into t2 values(1, 'a'), (2, 'b'); + +set session force_parallel_execute=0; +explain select sum(id) from t2 group by id; +explain select avg(id) from t2 group by id; +explain select count(id) from t2 group by id; + +set session force_parallel_execute=1; +explain select sum(id) from t2 group by id; +explain select avg(id) from t2 group by id; +explain select count(id) from t2 group by id; + +drop table t1; +drop table t2; + + +## explain cast ## +CREATE TABLE t1 (spID int, userID int, date date); + +INSERT INTO t1 VALUES (1,1,'1998-01-01'); +INSERT INTO t1 VALUES (2,2,'2001-02-03'); +INSERT INTO t1 VALUES (3,1,'1988-12-20'); +INSERT INTO t1 VALUES (4,2,'1972-12-12'); + +EXPLAIN SELECT MIN(t1.userID) = MIN(date) FROM t1 GROUP BY userid; +EXPLAIN SELECT FIRST_VALUE(date) OVER (ORDER BY spID = date) FROM t1; +EXPLAIN SELECT date, spid = FIRST_VALUE(date) OVER (ORDER BY date ) FROM t1; + +--echo # +--echo # No casts when constants or constant functions are involved +--echo # +EXPLAIN SELECT * from t1 WHERE userID = DATE'2012-02-20'; +EXPLAIN SELECT * FROM t1 WHERE date = NULL; +EXPLAIN SELECT * FROM t1 WHERE date = CAST('20:21:22' AS TIME); + +## test other cases for coverage ## +EXPLAIN SELECT date, to_seconds(date) FROM t1; +EXPLAIN SELECT date, period_add(concat(year(date), month(date)), 1) FROM t1; +EXPLAIN SELECT date, period_diff(concat(year(date), month(date)), 197001) FROM t1; +EXPLAIN SELECT concat(spID, space(2)) FROM t1; + +CREATE TABLE t2 (c1 int, c2 varchar(3)); + +INSERT INTO t2 VALUES (1, 'aaa'); +INSERT INTO t2 VALUES (2, 'bbb'); +INSERT INTO t2 VALUES (3, 'ccc'); + +EXPLAIN SELECT c2, AES_ENCRYPT(c2, 'a') FROM t2; +EXPLAIN SELECT c2, BIT_LENGTH(c2) FROM t2; +EXPLAIN SELECT c1, c2, NULLIF(c1, 1) FROM t2; +EXPLAIN SELECT c2, compress(c2) FROM t2; +EXPLAIN SELECT c2, uncompressed_length(c2) FROM t2; +EXPLAIN SELECT export_set(5, c2, upper(c2)) FROM t2; +EXPLAIN SELECT export_set(5, c2, upper(c2), ",") FROM t2; +EXPLAIN SELECT export_set(5, c2, upper(c2), ",", 5) FROM t2; +EXPLAIN SELECT SHA2(c2, 5) FROM t2; +EXPLAIN SELECT * FROM t2 WHERE c1 IN (1, 2, 4); + +DROP TABLE t1, t2; + + + + +set session force_parallel_execute = @saved_force_parallel_execute; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_flush.test b/mysql-test/suite/parallel_query/t/pq_flush.test new file mode 100644 index 000000000..d643a0571 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_flush.test @@ -0,0 +1,55 @@ +--source include/pq_test.inc + +--echo # Test pq select while flush tables + +--disable_warnings +drop table if exists t1; +--enable_warnings + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +--echo # --> connect default +connection default; + +create table t1 (a int); +insert into t1 values(1),(2),(3); + +select * from t1; + +--echo # sending lock table t1 read ... +lock table t1 read; + +--echo # --> connect con1 +connection con1; +--echo # sending flush table t1 ... +send flush table t1; + +connection default; +--echo # Let flush table sync in. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table flush" + and info = "flush table t1"; +--source include/wait_condition.inc + +select * from t1; + +--echo #--> connection con2 +connection con2; + +send select * from t1; + +--echo # --> connection default +--echo # con2 cannot do select while flushing +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table flush" + and info = "select * from t1"; + +--source include/wait_condition.inc + +select * from t1; +unlock tables; +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_fullscan.test b/mysql-test/suite/parallel_query/t/pq_fullscan.test new file mode 100644 index 000000000..9a5f5ad7b --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_fullscan.test @@ -0,0 +1,48 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +create table t1( + id int primary key auto_increment, + col1 varchar(100), + col2 int, + key idx_col2(col2) + )engine= innodb; + +--disable_query_log + let $loop=100; + while($loop) + { + eval insert into pq_test.t1(col1, col2) values(repeat('test', 4), $loop); + dec $loop; + } +--enable_query_log + +show variables like 'force_parallel_execute'; +select count(*) from pq_test.t1; + +select * from pq_test.t1 limit 1; + +--disable_result_log +select * from pq_test.t1; +--enable_result_log + +--disable_result_log +select id, col2 from pq_test.t1 force index(idx_col2); +--enable_result_log + +SELECT * FROM t1 WHERE id IN (1, 10, 20, 80, 90, 100, 30, 40, 50, 60, 70); + +drop table pq_test.t1; +drop database pq_test; + +## typecast ## +use test; + +create table t1( firstname char(20), lastname char(20)); +insert into t1 values ("john","doe"),("John","Doe"); +select * from t1 where firstname='john' and binary 'john' = firstname; + +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_group_by.test b/mysql-test/suite/parallel_query/t/pq_group_by.test new file mode 100644 index 000000000..886911a5b --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_group_by.test @@ -0,0 +1,262 @@ +--source include/have_debug.inc + +create table t1(a int primary key, b varchar(10), c decimal(5,2), d double); + +SELECT COUNT(a) FROM t1; +SELECT SUM(a) FROM t1; +SELECT AVG(a) FROM t1; + +insert into t1 values (1, 'The', '3.14', '3.14'); +insert into t1 values (2, 'quick', '4.25', '3.14'); +insert into t1 values (3, 'brown', '5.36', '3.14'); +insert into t1 values (4, 'fox', '6.47', '3.14'); +insert into t1 values (5, 'jumps', '3.14', '6.28'); +insert into t1 values (6, 'over', '4.25', '6.28'); +insert into t1 values (7, 'the', '5.36', '6.28'); +insert into t1 values (8, 'lazy', '6.47', '6.28'); +insert into t1 values (9, 'dog', '7.58', '6.28'); + +select count(*) from t1; +select count(a) from t1; +select count(b) from t1; +select count(c) from t1; +select count(d) from t1; +select sum(a) from t1; +select sum(c) from t1; +select sum(d) from t1; +select avg(a) from t1; +select avg(c) from t1; +select avg(d) from t1; +select std(d) from t1; +select variance(d) from t1; + +select sum(a) from t1 where c > 5.0; +select sum(c) from t1 where a > 5; +select sum(d) from t1 where c > 5.0; +select avg(a) from t1 where c > 5.0; +select avg(c) from t1 where a > 5; +select avg(d) from t1 where c > 5.0; +select count(*) from t1 where c > 5.0; +select count(a) from t1 where a > 5; +select count(b) from t1 where c > 5.0; +select count(c) from t1 where d > 6.0; +select count(d) from t1 where a > 5; + +select c,sum(a) from t1 group by(c); +select b,sum(c) from t1 group by(b); +select c,sum(d) from t1 group by(c); +select c,avg(a) from t1 group by(c); +select b,avg(c) from t1 group by(b); +select c,avg(d) from t1 group by(c); +select count(*) from t1 group by(c); +select count(a) from t1 group by(a); +select count(b) from t1 group by(c); +select count(c) from t1 group by(b); +select count(d) from t1 group by(c); + +drop table t1; + +--disable_warnings + +CREATE TABLE `t2` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `a` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +); + +--enable_warnings + +insert into t2 values(1, 'a'), (2, 'b'); + +select sum(id) from t2 group by id; +select avg(id) from t2 group by id; +select count(id) from t2 group by id; + +drop table t2; + +## sum_max/sum/min ## + +create table t1 (a char(2), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP); +insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), ('b', '2004-02-01 00:00:00'); + +select max(t) from t1 group by a; +explain select max(t) from t1 group by a; + +select min(t) from t1 group by a; +explain select min(t) from t1 group by a; + +drop table t1; + +## optimized with key + +set sql_mode = ''; +set big_tables = 1; +CREATE TABLE t1( + id INT AUTO_INCREMENT PRIMARY KEY, + c1 INT NOT NULL, + c2 INT NOT NULL, + UNIQUE KEY (c2,c1)); + +INSERT INTO t1(c1,c2) VALUES (5,1), (4,1), (3,5), (2,3), (1,3); + +SELECT * FROM t1 ORDER BY c1; +SELECT * FROM t1 GROUP BY id ORDER BY c1; + +## desc +SELECT * FROM t1 GROUP BY id ORDER BY id DESC; + +drop table t1; + +--disable_warnings + +CREATE TABLE t1 ( + spID int(10) unsigned, + userID int(10) unsigned, + score smallint(5) unsigned, + key (spid), + key (score) +); + +--enable_warnings + +INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3); +ANALYZE TABLE t1; +select userid,count(*) from t1 group by userid order by userid; +select userid,count(*) from t1 group by userid order by null; +select userid,count(*) from t1 group by userid order by userid desc; +select spid,count(*) from t1 group by spid; +select spid,count(*) from t1 group by spid order by spid; +select spid,count(*) from t1 group by spid order by spid desc; + +drop table t1; + +## optimized-group-by +set sql_mode = ''; + +create table t3 ( + period int not null, + name char(32) not null, + companynr int not null, + price double(11,0), + price2 double(11,0), + key (period), + key (name) +); + +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392); +INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234); + +create temporary table tmp select * from t3; + +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; +insert into tmp select * from t3; +insert into t3 select * from tmp; + +alter table t3 add t2nr int not null auto_increment primary key first; + +drop table tmp; + +select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 +group by companynr,t2nr order by companynr,t2nr limit 10; + +drop table t3; + +## Aggr. limit +CREATE TABLE t1 (a int, b int); + +let $1=64; +--disable_query_log + +while($1) +{ + let $2=32; + while($2) + { + eval INSERT INTO t1 VALUES (MOD($1, 23), MOD(133, $2)); + dec $2; + } + dec $1; +} + +--enable_query_log + +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a; +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a desc; +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a limit 10; +SELECT a, sum(a) FROM t1 GROUP BY a ORDER BY a limit 10, 10; + +SELECT b, avg(a) FROM t1 GROUP BY a, b ORDER BY b, NULL limit 10; +SELECT b, sum(a) FROM t1 GROUP BY a, b ORDER BY NULL, a, b, NULL, a, NULL; +SELECT b, sum(a) FROM t1 GROUP BY a, b ORDER BY NULL, a, b, NULL, a, NULL limit 10, 5; + +DROP TABLE t1; + +## Normal group by + +CREATE TABLE t1 (a int, b int); + +let $1=64; + +--disable_query_log + +while($1) +{ + let $2=32; + while($2) + { + eval INSERT INTO t1 VALUES (MOD($1, 31), MOD($2, 11)); + dec $2; + } + dec $1; +} + +--enable_query_log + +## having normal item + +SELECT a FROM t1 GROUP BY a ORDER by a Limit 10; +SELECT a FROM t1 GROUP BY a HAVING a > 1 ORDER by a Limit 10; +SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1 ORDER by a Limit 10; +SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1 ORDER by a Limit 10; + +## having item func + +SELECT a FROM t1 GROUP BY a HAVING (a % 11) > 1 ORDER by a Limit 10; +SELECT a, b FROM t1 GROUP BY a, b HAVING a + b > 31 ORDER by a, b Limit 10; +SELECT a, b FROM t1 GROUP BY a, b HAVING a * b > 61 ORDER by a, b Limit 10, 10; +SELECT a, b FROM t1 GROUP BY a, b HAVING sin(a % 11) > 0.5 and cos(b % 7) < 0.5 ORDER by a, b Limit 10, 10; + +## having aggr +EXPLAIN SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; + +EXPLAIN SELECT a, sum(b) from t1 GROUP BY a, b HAVING sum(b) > 5 ORDER BY a, b LIMIT 10; +SELECT a, b from t1 GROUP BY a, b HAVING avg(b) > 5 ORDER BY a, b LIMIT 10; +SELECT sum(a), avg(b) from t1 GROUP BY a, b HAVING sum(a) * avg(b) > 25 ORDER BY a, b LIMIT 10; + +DROP TABLE t1; + + + diff --git a/mysql-test/suite/parallel_query/t/pq_having.test b/mysql-test/suite/parallel_query/t/pq_having.test new file mode 100644 index 000000000..314b4ad38 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_having.test @@ -0,0 +1,97 @@ +--source include/pq_test.inc +--disable_warnings +drop database if exists pq_having_database; +--enable_warnings +create database pq_having_database; +use pq_having_database; + +--disable_warnings +DROP TABLE IF EXISTS `t1`; +--enable_warnings +CREATE TABLE `t1` ( + `fd1` int NOT NULL, + `fd2` int NOT NULL +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO t1 VALUES(1, 1); +INSERT INTO t1 VALUES(2, 2); +INSERT INTO t1 VALUES(3, 3); +analyze table t1; + +explain select fd1, avg(fd2) from t1 group by fd1 having avg(fd1) > 0; +select fd1, avg(fd2) from t1 group by fd1 having avg(fd1) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having bit_and(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having bit_and(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having bit_or(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having bit_or(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having bit_xor(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having bit_xor(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having count(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having count(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having count(distinct fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having count(distinct fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having group_concat(distinct fd2) is not null; +select fd1, avg(fd2) from t1 group by fd1 having group_concat(distinct fd2) is not null; + +explain select fd1, fd2, avg(fd2) from t1 group by fd1, fd2 having json_arrayagg(fd2); +select fd1, fd2, avg(fd2) from t1 group by fd1, fd2 having json_arrayagg(fd2); + +explain select fd1, avg(fd2) from t1 group by fd1, fd2 having json_object(fd1, fd2) is not null; +select fd1, avg(fd2) from t1 group by fd1, fd2 having json_object(fd1, fd2) is not null; + +explain select fd1, avg(fd2) from t1 group by fd1 having std(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having std(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having stddev(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having stddev(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having stddev_pop(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having stddev_pop(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having stddev_samp(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having stddev_samp(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having max(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having max(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having min(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having min(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having sum(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having sum(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having var_pop(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having var_pop(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having var_samp(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having var_samp(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having variance(fd2) > 0; +select fd1, avg(fd2) from t1 group by fd1 having variance(fd2) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having max(fd1)/min(fd1) > 0; +select fd1, avg(fd2) from t1 group by fd1 having max(fd1)/min(fd1) > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having max(fd1) + 1 > 0; +select fd1, avg(fd2) from t1 group by fd1 having max(fd1) + 1 > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having fd1 + 1 > 0; +select fd1, avg(fd2) from t1 group by fd1 having fd1 + 1 > 0; + +explain select fd1, avg(fd2) from t1 group by fd1 having fd1 > 0; +select fd1, avg(fd2) from t1 group by fd1 having fd1 > 0; + +explain select fd1, avg(fd2), max(fd1) from t1 group by fd1 having fd1 > 0; +select fd1, avg(fd2), max(fd1) from t1 group by fd1 having fd1 > 0; + +explain select fd1, avg(fd2), avg(fd1) as avg from t1 group by fd1 having avg > 0; +select fd1, avg(fd2), avg(fd1) as avg from t1 group by fd1 having avg > 0; + +drop table t1; +drop database pq_having_database; diff --git a/mysql-test/suite/parallel_query/t/pq_instant_add_column.test b/mysql-test/suite/parallel_query/t/pq_instant_add_column.test new file mode 100644 index 000000000..0c23fc704 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_instant_add_column.test @@ -0,0 +1,33 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ROW_FORMAT=REDUNDANT; + +INSERT INTO t1 VALUES(0, 1), (0, 2), (0, 3), (0, 4), (0, 5); + +ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 100, ADD COLUMN d INT GENERATED ALWAYS AS ((c * 2 + b)) VIRTUAL, ADD COLUMN e VARCHAR(100) DEFAULT 'Hello world'; + +CHECK TABLE t1; + +START TRANSACTION; +INSERT INTO t1(a, b) VALUES(0, 6); +SELECT * FROM t1; +ROLLBACK; +SELECT * FROM t1; + +START TRANSACTION; +UPDATE t1 SET c = 500 WHERE a = 1; +UPDATE t1 SET b = 1000 WHERE a = 2; +SELECT a, b, c FROM t1 WHERE a = 1 OR a = 2; + +drop table pq_test.t1; +drop database pq_test; + + diff --git a/mysql-test/suite/parallel_query/t/pq_join.test b/mysql-test/suite/parallel_query/t/pq_join.test new file mode 100644 index 000000000..3c0e69b9a --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_join.test @@ -0,0 +1,193 @@ +--source include/pq_test.inc +--source include/have_debug.inc +--disable_warnings +drop database if exists pq_database; +--enable_warnings +create database pq_database; +use pq_database; + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +create table t1(f1 TIME, f2 VARCHAR(1)); +insert into t1 values('08:35:24', 'X'); +insert into t1 values('14:51:13', 'S'); +insert into t1 values('11:22:33', 'Q'); + +create table t2(pk integer); +insert into t2 values(1); +insert into t2 values(2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +insert into t2 (select * from t2); +analyze table t1; +analyze table t2; + +explain select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2); +select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2); + +explain select * from t1 where exists (select /*+ semijoin(DUPSWEEDOUT)*/* from t2); +select * from t1 where exists (select /*+ semijoin(DUPSWEEDOUT)*/* from t2); + +drop table t1; +drop table t2; + +CREATE TABLE t1 (a INTEGER NOT NULL, b INT, PRIMARY KEY (a)); +CREATE TABLE t2 (a INTEGER NOT NULL); +CREATE TABLE t3 (a INTEGER NOT NULL, b INT, key(a)); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +set global innodb_limit_optimistic_insert_debug = 3; +INSERT INTO t2 VALUES (2), (3), (4), (5); +INSERT INTO t3 VALUES (2,3), (3,4), (4,5), (5,6), (2,7), (3,8), (4,3), (50,4); +set global innodb_limit_optimistic_insert_debug = 0; +ANALYZE TABLE t1, t2, t3; + +explain select /*+ semijoin(@subq1 LOOSESCAN) */ * from t1 where t1.a in (select /*+ QB_NAME(subq1) */ a from t3) and +t1.b in (select a from t2); +select /*+ semijoin(@subq1 LOOSESCAN) */ * from t1 where t1.a in (select /*+ QB_NAME(subq1) */ a from t3) and +t1.b in (select a from t2); + +drop table t1; +drop table t2; +drop table t3; + +create table t1(a varchar(10), primary key (a)); +create table t2(a varchar(10), b int); +insert into t1 values('t1'); +set global innodb_limit_optimistic_insert_debug = 3; +insert into t2 values('t1', 1); +insert into t2 values('t1', 2); +insert into t2 values('t1', 3); +insert into t2 values('t1', 4); +insert into t2 values('t1', 5); +insert into t2 values('t1', 6); +insert into t2 values('t1', 7); +insert into t2 values('t1', 8); +insert into t2 values('t1', 9); +insert into t2 values('t1', 10); +insert into t2 values('t1', 11); +insert into t2 values('t1', 12); +insert into t2 values('t1', 13); +insert into t2 values('t1', 14); +insert into t2 values('t1', 15); +set global innodb_limit_optimistic_insert_debug = 0; + +analyze table t1; +analyze table t2; + +explain select * from t1 left join t2 on t2.a = 't1' and t2.b = 1 where t1.a = 't1'; +select * from t1 left join t2 on t2.a = 't1' and t2.b = 1 where t1.a = 't1'; + +explain select * from t1 left join t2 on 1; +select * from t1 left join t2 on 1; + +drop table t1; +drop table t2; + +create table t1(a int); +create table t2(b int, primary key (b)); +insert into t1 values(1); +insert into t1 values(2); +insert into t1 values(3); +insert into t2 values(1); +insert into t2 values(2); +insert into t2 values(3); +analyze table t1; +analyze table t2; +explain select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2 left join t1 on 1 ); +select * from t1 where exists (select /*+ semijoin(firstmatch)*/ * from t2 left join t1 on 1); + +drop table t1; +drop table t2; + +create table t1 (a int, b int, index a (a,b)); +create table t2 (a int, index a (a)); +insert into t1 values (1, 10), (2,20), (3, 30), (4, 40); +insert into t2 values (2), (3), (4), (5); +analyze table t1; +analyze table t2; +explain select * from t2 where t2.a in (select /*+ semijoin(DUPSWEEDOUT)*/ a from t1); +select * from t2 where t2.a in (select /*+ semijoin(DUPSWEEDOUT)*/ a from t1); +drop table t1; +drop table t2; + +CREATE TABLE t0 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +INSERT INTO t0 VALUES +(1,'m','m'), +(40,'h','h'), +(1,'r','r'), +(1,'h','h'), +(9,'x','x'), +(NULL,'q','q'), +(NULL,'k','k'), +(7,'l','l'), +(182,'k','k'), +(202,'a','a'), +(7,'x','x'), +(6,'j','j'), +(119,'z','z'), +(4,'d','d'), +(5,'h','h'), +(1,'u','u'), +(3,'q','q'), +(7,'a','a'), +(3,'e','e'), +(6,'l','l'); +CREATE TABLE t1 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; + +INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); +CREATE TABLE t2 ( +int_key int(11) DEFAULT NULL, +varchar_key varchar(1) DEFAULT NULL, +varchar_nokey varchar(1) DEFAULT NULL, +KEY int_key (int_key), +KEY varchar_key (varchar_key,int_key) +) charset utf8mb4; +INSERT INTO t2 VALUES (123,NULL,NULL); +analyze table t0; +analyze table t1; +analyze table t2; + +EXPLAIN +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT /*+ semijoin(LOOSESCAN) */ t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); + +SELECT t0.int_key +FROM t0, t2 +WHERE t0.varchar_nokey IN ( +SELECT /*+ semijoin(LOOSESCAN) */ t1_1 .varchar_key +FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key +); + +drop table t0; +drop table t1; +drop table t2; +drop database pq_database; \ No newline at end of file diff --git a/mysql-test/suite/parallel_query/t/pq_jt_ref.test b/mysql-test/suite/parallel_query/t/pq_jt_ref.test new file mode 100644 index 000000000..9365ebf9e --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_jt_ref.test @@ -0,0 +1,39 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +--disable_warnings +DROP TABLE IF EXISTS t2; +--enable_warnings + +CREATE TABLE `t2` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` varchar(100) DEFAULT NULL, + `d` varchar(100) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_abc` (`a`,`b`,`c`) +) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); +insert into t2(a, b, c, d) values(6,4,'bcabcabcabca','bcabcabcabca'); + +select * from t2; + +explain select * from t2 where a = 6; +select * from t2 where a = 6; + +explain select * from t2 where a = 8; +select * from t2 where a = 8; + +explain select * from t2 where a = 4; +select * from t2 where a = 4; + +drop table pq_test.t2; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_kill_query.test b/mysql-test/suite/parallel_query/t/pq_kill_query.test new file mode 100644 index 000000000..6840a3f66 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_kill_query.test @@ -0,0 +1,58 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +CALL mtr.add_suppression("send message to MQ error"); + +set @saved_debug_pq_worker_stall = @@debug_pq_worker_stall; + +create table t1(id int, a varchar(10)); + +--disable_query_log + let $loop=1000; + while($loop) + { + eval insert into t1 values($loop, 'aa'); + dec $loop; + } +--enable_query_log + +set global debug_pq_worker_stall = true; + +connect (con1, localhost, root); + +--connection con1 +select @@force_parallel_execute; +let $qid= `SELECT CONNECTION_ID()`; + +explain select sum(id) from t1; +--send select sum(id) from t1; + +--connection default + +--sleep 1 +show status like "PQ_threads_running"; + +--replace_regex /[0-9]/#/ +show status like "PQ_memory_used"; + +--replace_regex /[0-9]+/#/ +--eval KILL query $qid + +connection con1; +--error ER_QUERY_INTERRUPTED +--reap + +--sleep 1 +show status like "PQ_threads_running"; +show status like "PQ_memory_used"; + +connection default; +set global debug_pq_worker_stall = @saved_debug_pq_worker_stall; + +SET @@SESSION.max_execution_time= 2; + +# Following select should timeout +--error ER_QUERY_TIMEOUT +SELECT *, SLEEP(0.5) from t1; + +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_mdl_lock.test b/mysql-test/suite/parallel_query/t/pq_mdl_lock.test new file mode 100644 index 000000000..3ff094e8c --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_mdl_lock.test @@ -0,0 +1,32 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +set @saved_autocommit = @@autocommit; +SET session autocommit=0; + +CREATE TABLE t1 (f1 INT) ENGINE="InnoDB"; + +SELECT 1 FROM DUAL; +SELECT f1 FROM t1; + +UNLOCK TABLES; +LOCK TABLES t1 WRITE; +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (2); + +explain SELECT f1 FROM t1; +SELECT f1 FROM t1; + +COMMIT; + +UNLOCK TABLES; + +SET session autocommit = @saved_autocommit; +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_memory_limit.test b/mysql-test/suite/parallel_query/t/pq_memory_limit.test new file mode 100644 index 000000000..f53eca16d --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_memory_limit.test @@ -0,0 +1,75 @@ +--source include/pq_test.inc +--source include/have_debug.inc +## explain other connection + +set @saved_debug_pq_worker_stall = @@debug_pq_worker_stall; +set @saved_pq_memory_limit = @@parallel_memory_limit; + +create table t1(id int, a varchar(10)); + +--disable_query_log + let $loop=1000; + while($loop) + { + eval insert into t1 values($loop, 'aa'); + dec $loop; + } +--enable_query_log + +set global debug_pq_worker_stall = true; + +connect (con1, localhost, root); + +--connection con1 +select @@force_parallel_execute; +let $qid= `SELECT CONNECTION_ID()`; + +--send select sum(id) from t1; + +--connection default + +--sleep 1 +show status like "PQ_threads_running"; +--replace_regex /[0-9]/#/ +show status like "PQ_memory_used"; +show status like "PQ_memory_refused"; + +--replace_regex /[0-9]+/#/ +--eval EXPLAIN FOR CONNECTION $qid; + +## 40960 is less than memory used by connection conn1 +set global parallel_memory_limit=40960; +explain select sum(id) from t1; + +set global debug_pq_worker_stall = false; + +connection con1; +--reap + +--sleep 1 +show status like "PQ_threads_running"; +show status like "PQ_memory_used"; +show status like "PQ_memory_refused"; + +connection default; +set global debug_pq_worker_stall = @saved_debug_pq_worker_stall; +set global parallel_memory_limit = @saved_pq_memory_limit; + +drop table t1; + +## coredump of main.parser ## +CREATE TABLE t1 (i INT); + +SELECT 1 FROM t1 INTO @var17727401; +SELECT 1 FROM DUAL INTO @var17727401; +SELECT 1 INTO @var17727401; + +SELECT 1 INTO @var17727401 FROM t1; +SELECT 1 INTO @var17727401 FROM DUAL; + +SELECT 1 INTO @var17727401 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1; +SELECT 1 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1 INTO @var17727401; + +SELECT 1 FROM t1 UNION SELECT 1 FROM t1 INTO @var17727401; + +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_mq_error.test b/mysql-test/suite/parallel_query/t/pq_mq_error.test new file mode 100644 index 000000000..413ac9dc5 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_mq_error.test @@ -0,0 +1,72 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +--disable_query_log +CALL mtr.add_suppression("alloc space for exchange_record_pq error*"); +CALL mtr.add_suppression("alloc space for exchange_record_reader error*"); +CALL mtr.add_suppression("alloc space for sending m_buffer error*"); +CALL mtr.add_suppression("not supported field*"); +CALL mtr.add_suppression("send message to MQ error*"); +CALL mtr.add_suppression("[Parallel query]*"); +--enable_query_log + +create table t1(id int, a varchar(10)); +insert into t1 values(1, 'aa'), (2, 'bb'); + +set @saved_force_parallel_execute = @@force_parallel_execute; +set session force_parallel_execute = 1; +set session sql_mode = ''; + +--disable_query_log +let $1=500; +while ($1) +{ + eval INSERT INTO t1 VALUES (MOD($1, 43), 'cc'); + dec $1; +} +--enable_query_log + +set session debug=""; +set session debug="+d, pq_mq_error1"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, pq_mq_error2"; +--error ER_PARALLEL_EXEC_ERROR +select a, sum(a) from t1 group by a order by a desc, id; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, pq_mq_error3"; +--error ER_STD_BAD_ALLOC_ERROR +select a from t1 order by a desc, id; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, pq_mq_error4"; +--error ER_PARALLEL_EXEC_ERROR +select a from t1 order by a desc, id; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, pq_mq_error5"; +--error ER_PARALLEL_EXEC_ERROR +select a from t1 order by a desc, id; +show status like "PQ_memory_used"; + +set session debug="+d, pq_mq_error6"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1 limit 20; +show status like "PQ_memory_used"; + +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id limit 20; +show status like "PQ_memory_used"; + +drop table t1; +SET debug= DEFAULT; + +--let $wait_counter= 10000 +--source include/restart_mysqld.inc diff --git a/mysql-test/suite/parallel_query/t/pq_not_equal.test b/mysql-test/suite/parallel_query/t/pq_not_equal.test new file mode 100644 index 000000000..0d2db3c3f --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_not_equal.test @@ -0,0 +1,30 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +--disable_warnings +DROP TABLE IF EXISTS actor; +--enable_warnings + +CREATE TABLE actor ( + actor_id int unsigned NOT NULL AUTO_INCREMENT, + first_name varchar(45) NOT NULL, + last_name varchar(45) NOT NULL, + is_active bit(1) NOT NULL, + PRIMARY KEY (actor_id) +); + +INSERT INTO actor VALUES +(NULL,'Victor','Otero',true), +(NULL,'Gonzalo','Crhystens',false), +(NULL,'Abraham','Vega',true), +(NULL,'Jennifer','Leon',false), +(NULL,'Jhonny','Test',true); + +SELECT * FROM `actor` WHERE `actor_id` != 1; + +drop table pq_test.actor; +drop database pq_test; + diff --git a/mysql-test/suite/parallel_query/t/pq_not_support.test b/mysql-test/suite/parallel_query/t/pq_not_support.test new file mode 100644 index 000000000..79a346771 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_not_support.test @@ -0,0 +1,51 @@ +# this test case include sql that cannot run parallelly + +--source include/pq_test.inc + +CREATE TABLE t0 ( col1 INT NOT NULL, col2 INT ) ENGINE=InnoDB; +insert into t0 values(0,1),(1,2),(2,3); +CREATE TABLE t1 (col3 DECIMAL(35,0) DEFAULT NULL, col1 INT NOT NULL, col2 INT NOT NULL DEFAULT '0', PRIMARY KEY (col1)) ENGINE=MyISAM; +REPLACE INTO t1 ( col1,col2) SELECT col1,col2 FROM t0; +select * from t1; +drop table t0, t1; +--disable_warnings +drop database if exists pq_bit_database; +--enable_warnings +create database pq_bit_database; +use pq_bit_database; + +CREATE TABLE t1 (a char(1), b VARBINARY(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('a', null); +INSERT INTO t1 VALUES ('a', null); +INSERT INTO t1 VALUES ('b', null); +INSERT INTO t1 VALUES ('b', 0x12); +INSERT INTO t1 VALUES ('c', 0x12); +INSERT INTO t1 VALUES ('b', 0x02); +INSERT INTO t1 VALUES ('c', 0x40); +ANALYZE TABLE t1; +SET @orig_sql_mode = @@sql_mode; +set sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; +EXPLAIN SELECT a, BIT_AND(b) FROM t1; +EXPLAIN SELECT a, BIT_OR(b) FROM t1; +EXPLAIN SELECT a, BIT_XOR(b) FROM t1; +EXPLAIN SELECT a, 1 + BIT_AND(b) FROM t1; +EXPLAIN SELECT a, 1 + BIT_OR(b) FROM t1; +EXPLAIN SELECT a, 1 + BIT_XOR(b) FROM t1; +EXPLAIN SELECT a, SUM(b) + BIT_AND(b) FROM t1; +EXPLAIN SELECT a, SUM(b) + BIT_OR(b) FROM t1; +EXPLAIN SELECT a, SUM(b) + BIT_XOR(b) FROM t1; +EXPLAIN SELECT a, 1 + BIT_AND(b) FROM t1 GROUP BY a; +EXPLAIN SELECT a, 1 + BIT_OR(b) FROM t1 GROUP BY a; +EXPLAIN SELECT a, 1 + BIT_XOR(b) FROM t1 GROUP BY a; +EXPLAIN SELECT a, b FROM t1 having BIT_AND(b) > 0; +EXPLAIN SELECT a, b FROM t1 having BIT_OR(b) > 0; +EXPLAIN SELECT a, b FROM t1 having BIT_XOR(b) > 0; +EXPLAIN SELECT a, BIT_AND(b) FROM t1 GROUP BY a ORDER BY BIT_AND(b); +EXPLAIN SELECT a, BIT_AND(b) FROM t1 GROUP BY a ORDER BY BIT_OR(b); +EXPLAIN SELECT a, BIT_AND(b) FROM t1 GROUP BY a ORDER BY BIT_XOR(b); +SELECT a, BIT_AND(b) FROM t1; +SELECT a, BIT_OR(b) FROM t1; +SELECT a, BIT_XOR(b) FROM t1; +DROP TABLE t1; +SET sql_mode = @orig_sql_mode; +drop database pq_bit_database; diff --git a/mysql-test/suite/parallel_query/t/pq_opt_trace.test b/mysql-test/suite/parallel_query/t/pq_opt_trace.test new file mode 100644 index 000000000..e9b362854 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_opt_trace.test @@ -0,0 +1,21 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create table t1(id int, a varchar(10)); + +--disable_query_log + let $loop=1000; + while($loop) + { + eval insert into t1 values($loop, 'aa'); + dec $loop; + } +--enable_query_log + +set session optimizer_trace="enabled=on"; +select * from t1 limit 1; + +Select locate("make_parallel_query_plan", trace) > 1 From Information_Schema.Optimizer_Trace; + +set session optimizer_trace="enabled=on"; +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_order_aggregation.test b/mysql-test/suite/parallel_query/t/pq_order_aggregation.test new file mode 100644 index 000000000..f36d07e2c --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_order_aggregation.test @@ -0,0 +1,163 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +--disable_warnings +drop database if exists pq_database; +--enable_warnings +create database pq_database; +use pq_database; + +--disable_warnings +drop table if exists t1; +--enable_warnings + +set global innodb_limit_optimistic_insert_debug = 3; +show variables like "innodb_limit_optimistic_insert_debug"; + +create table t1 ( + a int not null, + b int not null, + c int not null +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; + +insert into t1 values(1, 2, 3); +insert into t1 values(1, 5, 5); +insert into t1 values(1, 2, 4); +insert into t1 values(2, 4, 2); +insert into t1 values(2, 1, 3); +insert into t1 values(3, 5, 1); +insert into t1 values(3, 2, 3); +insert into t1 values(3, 2, 4); +insert into t1 values(4, 6, 8); +insert into t1 values(5, 8, 6); +insert into t1 values(5, 3, 9); +insert into t1 values(6, 9, 2); +analyze table t1; + +# test order by sum +explain select a, sum(a) from t1 group by a order by sum(a); +select a, sum(a) from t1 group by a order by sum(a); + +select a, sum(a) from t1 group by a order by sum(b); + +select a, sum(a) from t1 group by a order by sum(b) + 2; + +select a, sum(a) from t1 group by a order by sum(b) - 2; + +select a, sum(a) from t1 group by a order by sum(b) * 2; + +select a, sum(a) from t1 group by a order by sum(b) / 2; + +select a, sum(a) from t1 group by a order by sum(b + 2), a; + +select a, sum(a) from t1 group by a order by sum(b - 2), a; + +select a, sum(a) from t1 group by a order by sum(b * 2), a; + +select a, sum(a) from t1 group by a order by sum(b / 2), a; + +select a, sum(a) from t1 group by a order by sum(b + 2) + sum(a); + +# test order by avg +select a, avg(a) from t1 group by a order by avg(a); + +select a, avg(a) from t1 group by a order by avg(b); + +select a, avg(a) from t1 group by a order by avg(b) + 2; + +select a, avg(a) from t1 group by a order by avg(b) - 2; + +select a, avg(a) from t1 group by a order by avg(b) * 2; + +select a, avg(a) from t1 group by a order by avg(b) / 2; + +select a, avg(a) from t1 group by a order by avg(b + 2), a; + +select a, avg(a) from t1 group by a order by avg(b - 2), a; + +select a, avg(a) from t1 group by a order by avg(b * 2), a; + +select a, avg(a) from t1 group by a order by avg(b / 2), a; + +select a, avg(a) from t1 group by a order by avg(b + 2) + avg(a); + +# test order by count +select a, count(a) from t1 group by a order by count(a), a; + +select a, count(a) from t1 group by a order by count(b), a; + +select a, count(a) from t1 group by a order by count(b) + 2, a; + +select a, count(a) from t1 group by a order by count(b) - 2, a; + +select a, count(a) from t1 group by a order by count(b) * 2, a; + +select a, count(a) from t1 group by a order by count(b) / 2, a; + +select a, count(a) from t1 group by a order by count(b + 2), a; + +select a, count(a) from t1 group by a order by count(b - 2), a; + +select a, count(a) from t1 group by a order by count(b * 2), a; + +select a, count(a) from t1 group by a order by count(b / 2), a; + +select a, count(a) from t1 group by a order by count(b + 2) + count(a), a; + +# test order by max +select a, max(a) from t1 group by a order by max(a), a; + +select a, max(a) from t1 group by a order by max(b), a; + +select a, max(a) from t1 group by a order by max(b) + 2, a; + +select a, max(a) from t1 group by a order by max(b) - 2, a; + +select a, max(a) from t1 group by a order by max(b) * 2, a; + +select a, max(a) from t1 group by a order by max(b) / 2, a; + +select a, max(a) from t1 group by a order by max(b + 2), a; + +select a, max(a) from t1 group by a order by max(b - 2), a; + +select a, max(a) from t1 group by a order by max(b * 2), a; + +select a, max(a) from t1 group by a order by max(b / 2), a; + +select a, max(a) from t1 group by a order by max(b + 2) + max(a), a; + +# test order by min +select a, min(a) from t1 group by a order by min(a), a; + +select a, min(a) from t1 group by a order by min(b), a; + +select a, min(a) from t1 group by a order by min(b) + 2, a; + +select a, min(a) from t1 group by a order by min(b) - 2, a; + +select a, min(a) from t1 group by a order by min(b) * 2, a; + +select a, min(a) from t1 group by a order by min(b) / 2, a; + +select a, min(a) from t1 group by a order by min(b + 2), a; + +select a, min(a) from t1 group by a order by min(b - 2), a; + +select a, min(a) from t1 group by a order by min(b * 2), a; + +select a, min(a) from t1 group by a order by min(b / 2), a; + +select a, min(a) from t1 group by a order by min(b + 2) + min(a), a; + +# test order by hybrid aggregation +select a, sum(a) from t1 group by a order by max(b) + min(c); + +select a, sum(a) from t1 group by a order by count(b + 1) + max(c * 2); + + +set global innodb_limit_optimistic_insert_debug = 0; +show variables like "innodb_limit_optimistic_insert_debug"; + +drop table t1; +drop database pq_database; diff --git a/mysql-test/suite/parallel_query/t/pq_order_by.test b/mysql-test/suite/parallel_query/t/pq_order_by.test new file mode 100644 index 000000000..1b03904e2 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_order_by.test @@ -0,0 +1,233 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create table t1( + a tinyint NOT NULL, + b smallint, + c mediumint not null, + d int, + e bigint not null, + f float, + g double, + h decimal (6, 2)) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; + +insert into t1 values (1, 10, 20, 11, 101, 0.1, 1.1, 5.21); +insert into t1 values (28, 11, 21, 14, 49, 10.11, 29.12, 405.43); +insert into t1 values (-7, 4, 198, 20081, 109992784, -1004.22, 49727648.11, 8857.29); +insert into t1 values (88, -22, 9847, null, 91001544, null, 298847.91, null); +insert into t1 values (09, null, 18837, 105, 8475291, 1746.11, -1837491.90, -472.11); + +# asc sorting +select * from t1 order by a, b; +select a, c, e, f from t1 order by g; + +# desc sorting +select * from t1 order by a, b desc; +select h, e, g, a from t1 order by a, b desc; + +# asc/desc sorting +select * from t1 order by a, b desc; +select * from t1 order by a desc, b asc; +select a, c, e, f from t1 order by g, a desc, c asc; + +# explicitly use key + +create table t2( + a int NOT NULL, + b int NOT NULL, + c int, + primary key(a), + unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; + +insert into t2 values (1, 1, 2); +insert into t2 values (0, 1, 4); +insert into t2 values (2, 0, 3); + +# normal order by +select * from t2 order by a, c; +select * from t2 order by b; +select * from t2 order by a desc, c asc; + +# optimized-order-by +select * from t2 order by a; +select * from t2 order by c; + +# optimized-order-by-desc +select * from t2 order by a desc; +select * from t2 order by c desc; + +# implicitly use key + +select * from t2; +select a, c from t2; +select a, b from t2; +select b, c from t2; + +create table t3( + a int NOT NULL, + b int NOT NULL, + c int NOT NULL, + primary key (a, b), + unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; + +insert into t3 values (1, 1, 2); +insert into t3 values (1, 2, 1); +insert into t3 values (0, 1, 3); +insert into t3 values (1, 0, 4); + +select * from t3; +select * from t3 order by a; +select * from t3 order by a, b; +select * from t3 order by b, a; +select * from t3 order by a, c; +select * from t3 order by a desc, b asc; + +# order by 'expression' + +select * from t3 order by a + b; +select * from t3 order by a + b desc; +select * from t3 order by a + b * c; +select c from t3 order by a desc, b + c asc; + + +# ordered-group-by +CREATE TABLE `t4` ( + `id` int NOT NULL AUTO_INCREMENT, + `a` int DEFAULT NULL, + `b` int DEFAULT NULL, + `c` varchar(100) DEFAULT NULL, + `d` varchar(100) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_abc` (`a`,`b`,`c`) +) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +INSERT INTO `t4` VALUES +(1,1,2,'abcabc', 'cbacbacbacba'), +(2,1,2,'abcabca', 'cbacbacbacba'), +(3,1,2,'abca', 'cbacbacbacba'), +(4,1,2,'abcabca', 'cbacbacbacba'), +(5,1,2,'abcabcabc', 'cbacbacbacba'), +(6,1,2,'cabcabcabc','cbacbacbacba'), +(7,1,2,'abc', 'cbacbacbacba'), +(8,1,2,'abcabd', 'cbacbacbacba'), +(9,1,2,'xabcabcad', 'cbacbacbacba'), +(10,1,2,'xycabcab', 'cbacbacbacba'); + +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; +INSERT INTO t4(a, b, c, d) SELECT a, b, c, d FROM t4; + +select count(*), a from t4 group by a; + +# orderd-aggregation +select sum(b), a from t4 group by a order by sum(b); +select avg(b), a from t4 group by a order by avg(b); +SELECT c, d FROM t4 ORDER BY c LIMIT 10; +SELECT c, d FROM t4 ORDER BY c desc LIMIT 10; + +set session debug=""; +set session debug="+d, pq_msort_error6"; +--error ER_PARALLEL_EXEC_ERROR +select c, d from t4 order by c, d LIMIT 10; + +set session debug=""; +set session debug="+d, pq_msort_error7"; +--error ER_PARALLEL_EXEC_ERROR +select c, d from t4 order by c, d LIMIT 10; + +set session debug=""; +set session debug="+d, pq_msort_error8"; +--error ER_STD_BAD_ALLOC_ERROR +select c, d from t4 order by c, d LIMIT 10; + +set session debug=""; +SELECT * FROM t4 ORDER BY c, id LIMIT 10; + + +drop table t1; +drop table t2; +drop table t3; +drop table t4; + + +## optimized-order-by with second index + +CREATE TABLE t3(c1 DATETIME NOT NULL, c2 DATETIME NULL, c3 DATE, + c4 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNIQUE INDEX idx(c1,c2)); + +--disable_warnings + +INSERT INTO t3 VALUES('98-12-31 11:30:45','98.12.31 11+30+45','98-12-31 11:30:45','98.12.31 11+30+45'),('98/12/30 11*30*45','98@12@30 11^30^45','98/12/30 11*30*45','98@12@30 11^30^45'),('98-12-29','98.12.29','98-12-29','98.12.29'),('98/12/28','98@12@28','98/12/28','98@12@28'); +INSERT INTO t3 VALUES('20070523091528','070523091528','20070524091528','070524091528'),('20070525','070525','20070526','070526'); +INSERT INTO t3 VALUES(19830905132800,830905132800,19830906132800,830906132800),(19830907,830907,19830908,830908); +SET TIMESTAMP=1233216687; # 2009-01-29 13:41:27 +INSERT INTO t3 VALUES(NOW(),CURRENT_DATE,NOW(),CURRENT_DATE); +INSERT INTO t3 VALUES('98-12-31 11:30:45','98@12@30 11^30^45','98-12-31 11:30:45','98.12.31 11+30+45'),('98-12-29','98@12@30 11^30^45','98/12/30 11*30*45','98@12@30 11^30^45'); +INSERT INTO t3 VALUES('2008-01-01',NULL,'08-01-02','08/01/03'); + +--enable_warnings + +set @saved_sql_mode = @@SQL_MODE; +set SQL_MODE = ''; + +ANALYZE TABLE t3; +EXPLAIN SELECT * FROM t3 WHERE c1 >= '0000-00-00' AND c1 < '2009-01-29' AND c2 = '1998-12-30 11:30:45'; +SELECT * FROM t3 WHERE c1 >= '0000-00-00' AND c1 < '2009-01-29' AND c2 = '1998-12-30 11:30:45' ORDER BY c1,c2 LIMIT 2; + +DROP TABLE t3; + + +set session SQL_MODE = @saved_sql_mode; +## sort on tmp table + +--disable_warnings + +CREATE TABLE t1 ( + userid int(10) unsigned, + score smallint(5) unsigned, + key (score) +); + +--enable_warnings + +INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3); +ANALYZE TABLE t1; +set big_tables=1; + +SELECT userid,count(*) FROM t1 GROUP BY userid ORDER BY userid DESC; +DROP TABLE t1; + +--disable_warnings + +CREATE TABLE `t2` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` varchar(100) DEFAULT NULL, + `d` varchar(100) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_abc` (`a`,`b`,`c`) +) ENGINE=InnoDB AUTO_INCREMENT=16384 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +--enable_warnings + +--disable_query_log +INSERT INTO `t2` VALUES (1,1,2,'abcabcabcabc','cbacbacbacba'),(2,1,2,'abcabcabcabc','cbacbacbacba'),(3,1,2,'abcabcabcabc','cbacbacbacba'),(4,1,2,'abcabcabcabc','cbacbacbacba'),(5,1,2,'abcabcabcabc','cbacbacbacba'),(6,1,2,'abcabcabcabc','cbacbacbacba'),(7,1,2,'abcabcabcabc','cbacbacbacba'),(8,1,2,'abcabcabcabc','cbacbacbacba'),(9,1,2,'abcabcabcabc','cbacbacbacba'),(10,1,2,'abcabcabcabc','cbacbacbacba'),(11,1,2,'abcabcabcabc','cbacbacbacba'),(12,1,2,'abcabcabcabc','cbacbacbacba'),(13,1,2,'abcabcabcabc','cbacbacbacba'),(14,1,2,'abcabcabcabc','cbacbacbacba'),(15,1,2,'abcabcabcabc','cbacbacbacba'),(16,1,2,'abcabcabcabc','cbacbacbacba'),(17,1,2,'abcabcabcabc','cbacbacbacba'),(18,1,2,'abcabcabcabc','cbacbacbacba'),(19,1,2,'abcabcabcabc','cbacbacbacba'),(20,1,2,'abcabcabcabc','cbacbacbacba'),(21,1,2,'abcabcabcabc','cbacbacbacba'),(22,1,2,'abcabcabcabc','cbacbacbacba'),(23,1,2,'abcabcabcabc','cbacbacbacba'),(24,1,2,'abcabcabcabc','cbacbacbacba'),(25,1,2,'abcabcabcabc','cbacbacbacba'),(26,1,2,'abcabcabcabc','cbacbacbacba'),(27,1,2,'abcabcabcabc','cbacbacbacba'),(28,1,2,'abcabcabcabc','cbacbacbacba'),(29,1,2,'abcabcabcabc','cbacbacbacba'),(30,1,2,'abcabcabcabc','cbacbacbacba'),(31,1,2,'abcabcabcabc','cbacbacbacba'),(32,1,2,'abcabcabcabc','cbacbacbacba'),(33,1,2,'abcabcabcabc','cbacbacbacba'),(34,1,2,'abcabcabcabc','cbacbacbacba'),(35,1,2,'abcabcabcabc','cbacbacbacba'),(36,1,2,'abcabcabcabc','cbacbacbacba'),(37,1,2,'abcabcabcabc','cbacbacbacba'),(38,1,2,'abcabcabcabc','cbacbacbacba'),(39,1,2,'abcabcabcabc','cbacbacbacba'),(40,1,2,'abcabcabcabc','cbacbacbacba'),(41,1,2,'abcabcabcabc','cbacbacbacba'),(42,1,2,'abcabcabcabc','cbacbacbacba'),(43,1,2,'abcabcabcabc','cbacbacbacba'),(44,1,2,'abcabcabcabc','cbacbacbacba'),(45,1,2,'abcabcabcabc','cbacbacbacba'),(46,1,2,'abcabcabcabc','cbacbacbacba'),(47,1,2,'abcabcabcabc','cbacbacbacba'),(48,1,2,'abcabcabcabc','cbacbacbacba'),(49,1,2,'abcabcabcabc','cbacbacbacba'),(50,1,2,'abcabcabcabc','cbacbacbacba'),(51,1,2,'abcabcabcabc','cbacbacbacba'),(52,1,2,'abcabcabcabc','cbacbacbacba'),(53,1,2,'abcabcabcabc','cbacbacbacba'),(54,1,2,'abcabcabcabc','cbacbacbacba'),(55,1,2,'abcabcabcabc','cbacbacbacba'),(56,1,2,'abcabcabcabc','cbacbacbacba'),(57,1,2,'abcabcabcabc','cbacbacbacba'),(58,1,2,'abcabcabcabc','cbacbacbacba'),(59,1,2,'abcabcabcabc','cbacbacbacba'),(60,1,2,'abcabcabcabc','cbacbacbacba'),(61,1,2,'abcabcabcabc','cbacbacbacba'),(62,1,2,'abcabcabcabc','cbacbacbacba'),(63,1,2,'abcabcabcabc','cbacbacbacba'),(64,1,2,'abcabcabcabc','cbacbacbacba'),(65,1,2,'abcabcabcabc','cbacbacbacba'),(66,1,2,'abcabcabcabc','cbacbacbacba'),(67,1,2,'abcabcabcabc','cbacbacbacba'),(68,1,2,'abcabcabcabc','cbacbacbacba'),(69,1,2,'abcabcabcabc','cbacbacbacba'),(70,1,2,'abcabcabcabc','cbacbacbacba'),(71,1,2,'abcabcabcabc','cbacbacbacba'),(72,1,2,'abcabcabcabc','cbacbacbacba'),(73,1,2,'abcabcabcabc','cbacbacbacba'),(74,1,2,'abcabcabcabc','cbacbacbacba'),(75,1,2,'abcabcabcabc','cbacbacbacba'),(76,1,2,'abcabcabcabc','cbacbacbacba'),(77,1,2,'abcabcabcabc','cbacbacbacba'),(78,1,2,'abcabcabcabc','cbacbacbacba'),(79,1,2,'abcabcabcabc','cbacbacbacba'),(80,1,2,'abcabcabcabc','cbacbacbacba'),(81,1,2,'abcabcabcabc','cbacbacbacba'),(82,1,2,'abcabcabcabc','cbacbacbacba'),(83,1,2,'abcabcabcabc','cbacbacbacba'),(84,1,2,'abcabcabcabc','cbacbacbacba'),(85,1,2,'abcabcabcabc','cbacbacbacba'),(86,1,2,'abcabcabcabc','cbacbacbacba'),(87,1,2,'abcabcabcabc','cbacbacbacba'),(88,1,2,'abcabcabcabc','cbacbacbacba'),(89,1,2,'abcabcabcabc','cbacbacbacba'),(90,1,2,'abcabcabcabc','cbacbacbacba'),(91,1,2,'abcabcabcabc','cbacbacbacba'),(92,1,2,'abcabcabcabc','cbacbacbacba'),(93,1,2,'abcabcabcabc','cbacbacbacba'),(94,1,2,'abcabcabcabc','cbacbacbacba'),(95,1,2,'abcabcabcabc','cbacbacbacba'),(96,1,2,'abcabcabcabc','cbacbacbacba'),(97,1,2,'abcabcabcabc','cbacbacbacba'),(98,1,2,'abcabcabcabc','cbacbacbacba'),(99,1,2,'abcabcabcabc','cbacbacbacba'),(100,1,2,'abcabcabcabc','cbacbacbacba'),(101,1,2,'abcabcabcabc','cbacbacbacba'),(102,1,2,'abcabcabcabc','cbacbacbacba'),(103,1,2,'abcabcabcabc','cbacbacbacba'),(104,1,2,'abcabcabcabc','cbacbacbacba'),(105,1,2,'abcabcabcabc','cbacbacbacba'),(106,1,2,'abcabcabcabc','cbacbacbacba'),(107,1,2,'abcabcabcabc','cbacbacbacba'),(108,1,2,'abcabcabcabc','cbacbacbacba'),(109,1,2,'abcabcabcabc','cbacbacbacba'),(110,1,2,'abcabcabcabc','cbacbacbacba'),(111,1,2,'abcabcabcabc','cbacbacbacba'),(112,1,2,'abcabcabcabc','cbacbacbacba'),(113,1,2,'abcabcabcabc','cbacbacbacba'),(114,1,2,'abcabcabcabc','cbacbacbacba'),(115,1,2,'abcabcabcabc','cbacbacbacba'),(116,1,2,'abcabcabcabc','cbacbacbacba'),(117,1,2,'abcabcabcabc','cbacbacbacba'),(118,1,2,'abcabcabcabc','cbacbacbacba'),(119,1,2,'abcabcabcabc','cbacbacbacba'),(120,1,2,'abcabcabcabc','cbacbacbacba'),(121,1,2,'abcabcabcabc','cbacbacbacba'),(122,1,2,'abcabcabcabc','cbacbacbacba'),(123,1,2,'abcabcabcabc','cbacbacbacba'),(124,1,2,'abcabcabcabc','cbacbacbacba'),(125,1,2,'abcabcabcabc','cbacbacbacba'),(126,1,2,'abcabcabcabc','cbacbacbacba'),(127,1,2,'abcabcabcabc','cbacbacbacba'),(128,1,2,'abcabcabcabc','cbacbacbacba'),(129,1,2,'abcabcabcabc','cbacbacbacba'),(130,1,2,'abcabcabcabc','cbacbacbacba'),(131,1,2,'abcabcabcabc','cbacbacbacba'),(132,1,2,'abcabcabcabc','cbacbacbacba'),(133,1,2,'abcabcabcabc','cbacbacbacba'),(134,1,2,'abcabcabcabc','cbacbacbacba'),(135,1,2,'abcabcabcabc','cbacbacbacba'),(136,1,2,'abcabcabcabc','cbacbacbacba'),(137,1,2,'abcabcabcabc','cbacbacbacba'),(138,1,2,'abcabcabcabc','cbacbacbacba'),(139,1,2,'abcabcabcabc','cbacbacbacba'),(140,1,2,'abcabcabcabc','cbacbacbacba'),(141,1,2,'abcabcabcabc','cbacbacbacba'),(142,1,2,'abcabcabcabc','cbacbacbacba'),(143,1,2,'abcabcabcabc','cbacbacbacba'),(144,1,2,'abcabcabcabc','cbacbacbacba'),(145,1,2,'abcabcabcabc','cbacbacbacba'),(146,1,2,'abcabcabcabc','cbacbacbacba'),(147,1,2,'abcabcabcabc','cbacbacbacba'),(148,1,2,'abcabcabcabc','cbacbacbacba'),(149,1,2,'abcabcabcabc','cbacbacbacba'),(150,1,2,'abcabcabcabc','cbacbacbacba'),(151,1,2,'abcabcabcabc','cbacbacbacba'),(152,1,2,'abcabcabcabc','cbacbacbacba'),(153,1,2,'abcabcabcabc','cbacbacbacba'),(154,1,2,'abcabcabcabc','cbacbacbacba'),(155,1,2,'abcabcabcabc','cbacbacbacba'),(156,1,2,'abcabcabcabc','cbacbacbacba'),(157,1,2,'abcabcabcabc','cbacbacbacba'),(158,1,2,'abcabcabcabc','cbacbacbacba'),(159,1,2,'abcabcabcabc','cbacbacbacba'),(160,1,2,'abcabcabcabc','cbacbacbacba'),(161,1,2,'abcabcabcabc','cbacbacbacba'),(162,1,2,'abcabcabcabc','cbacbacbacba'),(163,1,2,'abcabcabcabc','cbacbacbacba'),(164,1,2,'abcabcabcabc','cbacbacbacba'),(165,1,2,'abcabcabcabc','cbacbacbacba'),(166,1,2,'abcabcabcabc','cbacbacbacba'),(167,1,2,'abcabcabcabc','cbacbacbacba'),(168,1,2,'abcabcabcabc','cbacbacbacba'),(169,1,2,'abcabcabcabc','cbacbacbacba'),(170,1,2,'abcabcabcabc','cbacbacbacba'),(171,1,2,'abcabcabcabc','cbacbacbacba'),(172,1,2,'abcabcabcabc','cbacbacbacba'),(173,1,2,'abcabcabcabc','cbacbacbacba'),(174,1,2,'abcabcabcabc','cbacbacbacba'),(175,1,2,'abcabcabcabc','cbacbacbacba'),(176,1,2,'abcabcabcabc','cbacbacbacba'),(177,1,2,'abcabcabcabc','cbacbacbacba'),(178,1,2,'abcabcabcabc','cbacbacbacba'),(179,1,2,'abcabcabcabc','cbacbacbacba'),(180,1,2,'abcabcabcabc','cbacbacbacba'),(181,1,2,'abcabcabcabc','cbacbacbacba'),(182,1,2,'abcabcabcabc','cbacbacbacba'),(183,1,2,'abcabcabcabc','cbacbacbacba'),(184,1,2,'abcabcabcabc','cbacbacbacba'),(185,1,2,'abcabcabcabc','cbacbacbacba'),(186,1,2,'abcabcabcabc','cbacbacbacba'),(187,1,2,'abcabcabcabc','cbacbacbacba'),(188,1,2,'abcabcabcabc','cbacbacbacba'),(189,1,2,'abcabcabcabc','cbacbacbacba'),(190,1,2,'abcabcabcabc','cbacbacbacba'),(191,1,2,'abcabcabcabc','cbacbacbacba'),(192,1,2,'abcabcabcabc','cbacbacbacba'),(193,1,2,'abcabcabcabc','cbacbacbacba'),(194,1,2,'abcabcabcabc','cbacbacbacba'),(195,1,2,'abcabcabcabc','cbacbacbacba'),(196,1,2,'abcabcabcabc','cbacbacbacba'),(197,1,2,'abcabcabcabc','cbacbacbacba'),(198,1,2,'abcabcabcabc','cbacbacbacba'),(199,1,2,'abcabcabcabc','cbacbacbacba'),(200,1,2,'abcabcabcabc','cbacbacbacba'),(201,1,2,'abcabcabcabc','cbacbacbacba'),(202,1,2,'abcabcabcabc','cbacbacbacba'),(203,1,2,'abcabcabcabc','cbacbacbacba'),(204,1,2,'abcabcabcabc','cbacbacbacba'),(205,1,2,'abcabcabcabc','cbacbacbacba'),(206,1,2,'abcabcabcabc','cbacbacbacba'),(207,1,2,'abcabcabcabc','cbacbacbacba'),(208,1,2,'abcabcabcabc','cbacbacbacba'),(209,1,2,'abcabcabcabc','cbacbacbacba'),(210,1,2,'abcabcabcabc','cbacbacbacba'),(211,1,2,'abcabcabcabc','cbacbacbacba'),(212,1,2,'abcabcabcabc','cbacbacbacba'),(213,1,2,'abcabcabcabc','cbacbacbacba'),(214,1,2,'abcabcabcabc','cbacbacbacba'),(215,1,2,'abcabcabcabc','cbacbacbacba'),(216,1,2,'abcabcabcabc','cbacbacbacba'),(217,1,2,'abcabcabcabc','cbacbacbacba'),(218,1,2,'abcabcabcabc','cbacbacbacba'),(219,1,2,'abcabcabcabc','cbacbacbacba'),(220,1,2,'abcabcabcabc','cbacbacbacba'),(221,1,2,'abcabcabcabc','cbacbacbacba'),(222,1,2,'abcabcabcabc','cbacbacbacba'),(223,1,2,'abcabcabcabc','cbacbacbacba'),(224,1,2,'abcabcabcabc','cbacbacbacba'),(225,1,2,'abcabcabcabc','cbacbacbacba'),(226,1,2,'abcabcabcabc','cbacbacbacba'),(227,1,2,'abcabcabcabc','cbacbacbacba'),(228,1,2,'abcabcabcabc','cbacbacbacba'),(229,1,2,'abcabcabcabc','cbacbacbacba'),(230,1,2,'abcabcabcabc','cbacbacbacba'),(231,1,2,'abcabcabcabc','cbacbacbacba'),(232,1,2,'abcabcabcabc','cbacbacbacba'),(233,1,2,'abcabcabcabc','cbacbacbacba'),(234,1,2,'abcabcabcabc','cbacbacbacba'),(235,1,2,'abcabcabcabc','cbacbacbacba'),(236,1,2,'abcabcabcabc','cbacbacbacba'),(237,1,2,'abcabcabcabc','cbacbacbacba'),(238,1,2,'abcabcabcabc','cbacbacbacba'),(239,1,2,'abcabcabcabc','cbacbacbacba'),(240,1,2,'abcabcabcabc','cbacbacbacba'),(241,1,2,'abcabcabcabc','cbacbacbacba'),(242,1,2,'abcabcabcabc','cbacbacbacba'),(243,1,2,'abcabcabcabc','cbacbacbacba'),(244,1,2,'abcabcabcabc','cbacbacbacba'),(245,1,2,'abcabcabcabc','cbacbacbacba'),(246,1,2,'abcabcabcabc','cbacbacbacba'),(247,1,2,'abcabcabcabc','cbacbacbacba'),(248,1,2,'abcabcabcabc','cbacbacbacba'),(249,1,2,'abcabcabcabc','cbacbacbacba'),(250,1,2,'abcabcabcabc','cbacbacbacba'),(251,1,2,'abcabcabcabc','cbacbacbacba'),(252,1,2,'abcabcabcabc','cbacbacbacba'),(253,1,2,'abcabcabcabc','cbacbacbacba'),(254,1,2,'abcabcabcabc','cbacbacbacba'),(255,1,2,'abcabcabcabc','cbacbacbacba'),(256,1,2,'abcabcabcabc','cbacbacbacba'),(257,1,2,'abcabcabcabc','cbacbacbacba'),(258,1,2,'abcabcabcabc','cbacbacbacba'),(259,1,2,'abcabcabcabc','cbacbacbacba'),(260,1,2,'abcabcabcabc','cbacbacbacba'),(261,1,2,'abcabcabcabc','cbacbacbacba'),(262,1,2,'abcabcabcabc','cbacbacbacba'),(263,1,2,'abcabcabcabc','cbacbacbacba'),(264,1,2,'abcabcabcabc','cbacbacbacba'),(265,1,2,'abcabcabcabc','cbacbacbacba'),(266,1,2,'abcabcabcabc','cbacbacbacba'),(267,1,2,'abcabcabcabc','cbacbacbacba'),(268,1,2,'abcabcabcabc','cbacbacbacba'),(269,1,2,'abcabcabcabc','cbacbacbacba'),(270,1,2,'abcabcabcabc','cbacbacbacba'),(271,1,2,'abcabcabcabc','cbacbacbacba'),(272,1,2,'abcabcabcabc','cbacbacbacba'),(273,1,2,'abcabcabcabc','cbacbacbacba'),(274,1,2,'abcabcabcabc','cbacbacbacba'),(275,1,2,'abcabcabcabc','cbacbacbacba'),(276,1,2,'abcabcabcabc','cbacbacbacba'),(277,1,2,'abcabcabcabc','cbacbacbacba'),(278,1,2,'abcabcabcabc','cbacbacbacba'),(279,1,2,'abcabcabcabc','cbacbacbacba'),(280,1,2,'abcabcabcabc','cbacbacbacba'),(281,1,2,'abcabcabcabc','cbacbacbacba'),(282,1,2,'abcabcabcabc','cbacbacbacba'),(283,1,2,'abcabcabcabc','cbacbacbacba'),(284,1,2,'abcabcabcabc','cbacbacbacba'),(285,1,2,'abcabcabcabc','cbacbacbacba'),(286,1,2,'abcabcabcabc','cbacbacbacba'),(287,1,2,'abcabcabcabc','cbacbacbacba'),(288,1,2,'abcabcabcabc','cbacbacbacba'),(289,1,2,'abcabcabcabc','cbacbacbacba'),(290,1,2,'abcabcabcabc','cbacbacbacba'),(291,1,2,'abcabcabcabc','cbacbacbacba'),(292,1,2,'abcabcabcabc','cbacbacbacba'),(293,1,2,'abcabcabcabc','cbacbacbacba'),(294,1,2,'abcabcabcabc','cbacbacbacba'),(295,1,2,'abcabcabcabc','cbacbacbacba'),(296,1,2,'abcabcabcabc','cbacbacbacba'),(297,1,2,'abcabcabcabc','cbacbacbacba'),(298,1,2,'abcabcabcabc','cbacbacbacba'),(299,1,2,'abcabcabcabc','cbacbacbacba'),(300,1,2,'abcabcabcabc','cbacbacbacba'),(301,1,2,'abcabcabcabc','cbacbacbacba'),(302,1,2,'abcabcabcabc','cbacbacbacba'),(303,1,2,'abcabcabcabc','cbacbacbacba'),(304,1,2,'abcabcabcabc','cbacbacbacba'),(305,1,2,'abcabcabcabc','cbacbacbacba'),(306,1,2,'abcabcabcabc','cbacbacbacba'),(307,1,2,'abcabcabcabc','cbacbacbacba'),(308,1,2,'abcabcabcabc','cbacbacbacba'),(309,1,2,'abcabcabcabc','cbacbacbacba'),(310,1,2,'abcabcabcabc','cbacbacbacba'),(311,1,2,'abcabcabcabc','cbacbacbacba'),(312,1,2,'abcabcabcabc','cbacbacbacba'),(313,1,2,'abcabcabcabc','cbacbacbacba'),(314,1,2,'abcabcabcabc','cbacbacbacba'),(315,1,2,'abcabcabcabc','cbacbacbacba'),(316,1,2,'abcabcabcabc','cbacbacbacba'),(317,1,2,'abcabcabcabc','cbacbacbacba'),(318,1,2,'abcabcabcabc','cbacbacbacba'),(319,1,2,'abcabcabcabc','cbacbacbacba'),(320,1,2,'abcabcabcabc','cbacbacbacba'),(321,1,2,'abcabcabcabc','cbacbacbacba'),(322,1,2,'abcabcabcabc','cbacbacbacba'),(323,1,2,'abcabcabcabc','cbacbacbacba'),(324,1,2,'abcabcabcabc','cbacbacbacba'),(325,1,2,'abcabcabcabc','cbacbacbacba'),(326,1,2,'abcabcabcabc','cbacbacbacba'),(327,1,2,'abcabcabcabc','cbacbacbacba'),(328,1,2,'abcabcabcabc','cbacbacbacba'),(329,1,2,'abcabcabcabc','cbacbacbacba'),(330,1,2,'abcabcabcabc','cbacbacbacba'),(331,1,2,'abcabcabcabc','cbacbacbacba'),(332,1,2,'abcabcabcabc','cbacbacbacba'),(333,1,2,'abcabcabcabc','cbacbacbacba'),(334,1,2,'abcabcabcabc','cbacbacbacba'),(335,1,2,'abcabcabcabc','cbacbacbacba'),(336,1,2,'abcabcabcabc','cbacbacbacba'),(337,1,2,'abcabcabcabc','cbacbacbacba'),(338,1,2,'abcabcabcabc','cbacbacbacba'),(339,1,2,'abcabcabcabc','cbacbacbacba'),(340,1,2,'abcabcabcabc','cbacbacbacba'),(341,1,2,'abcabcabcabc','cbacbacbacba'),(342,1,2,'abcabcabcabc','cbacbacbacba'),(343,1,2,'abcabcabcabc','cbacbacbacba'),(344,1,2,'abcabcabcabc','cbacbacbacba'),(345,1,2,'abcabcabcabc','cbacbacbacba'),(346,1,2,'abcabcabcabc','cbacbacbacba'),(347,1,2,'abcabcabcabc','cbacbacbacba'),(348,1,2,'abcabcabcabc','cbacbacbacba'),(349,1,2,'abcabcabcabc','cbacbacbacba'),(350,1,2,'abcabcabcabc','cbacbacbacba'),(351,1,2,'abcabcabcabc','cbacbacbacba'),(352,1,2,'abcabcabcabc','cbacbacbacba'),(353,1,2,'abcabcabcabc','cbacbacbacba'),(354,1,2,'abcabcabcabc','cbacbacbacba'),(355,1,2,'abcabcabcabc','cbacbacbacba'),(356,1,2,'abcabcabcabc','cbacbacbacba'),(357,1,2,'abcabcabcabc','cbacbacbacba'),(358,1,2,'abcabcabcabc','cbacbacbacba'),(359,1,2,'abcabcabcabc','cbacbacbacba'),(360,1,2,'abcabcabcabc','cbacbacbacba'),(361,1,2,'abcabcabcabc','cbacbacbacba'),(362,1,2,'abcabcabcabc','cbacbacbacba'),(363,1,2,'abcabcabcabc','cbacbacbacba'),(364,1,2,'abcabcabcabc','cbacbacbacba'),(365,1,2,'abcabcabcabc','cbacbacbacba'),(366,1,2,'abcabcabcabc','cbacbacbacba'),(367,1,2,'abcabcabcabc','cbacbacbacba'),(368,1,2,'abcabcabcabc','cbacbacbacba'),(369,1,2,'abcabcabcabc','cbacbacbacba'),(370,1,2,'abcabcabcabc','cbacbacbacba'),(371,1,2,'abcabcabcabc','cbacbacbacba'),(372,1,2,'abcabcabcabc','cbacbacbacba'),(373,1,2,'abcabcabcabc','cbacbacbacba'),(374,1,2,'abcabcabcabc','cbacbacbacba'),(375,1,2,'abcabcabcabc','cbacbacbacba'),(376,1,2,'abcabcabcabc','cbacbacbacba'),(377,1,2,'abcabcabcabc','cbacbacbacba'),(378,1,2,'abcabcabcabc','cbacbacbacba'),(379,1,2,'abcabcabcabc','cbacbacbacba'),(380,1,2,'abcabcabcabc','cbacbacbacba'),(381,1,2,'abcabcabcabc','cbacbacbacba'),(382,1,2,'abcabcabcabc','cbacbacbacba'),(383,1,2,'abcabcabcabc','cbacbacbacba'),(384,1,2,'abcabcabcabc','cbacbacbacba'),(385,1,2,'abcabcabcabc','cbacbacbacba'),(386,1,2,'abcabcabcabc','cbacbacbacba'),(387,1,2,'abcabcabcabc','cbacbacbacba'),(388,1,2,'abcabcabcabc','cbacbacbacba'),(389,1,2,'abcabcabcabc','cbacbacbacba'),(390,1,2,'abcabcabcabc','cbacbacbacba'),(391,1,2,'abcabcabcabc','cbacbacbacba'),(392,1,2,'abcabcabcabc','cbacbacbacba'),(393,1,2,'abcabcabcabc','cbacbacbacba'),(394,1,2,'abcabcabcabc','cbacbacbacba'),(395,1,2,'abcabcabcabc','cbacbacbacba'),(396,1,2,'abcabcabcabc','cbacbacbacba'),(397,1,2,'abcabcabcabc','cbacbacbacba'),(398,1,2,'abcabcabcabc','cbacbacbacba'),(399,1,2,'abcabcabcabc','cbacbacbacba'),(400,1,2,'abcabcabcabc','cbacbacbacba'),(401,1,2,'abcabcabcabc','cbacbacbacba'),(402,1,2,'abcabcabcabc','cbacbacbacba'),(403,1,2,'abcabcabcabc','cbacbacbacba'),(404,1,2,'abcabcabcabc','cbacbacbacba'),(405,1,2,'abcabcabcabc','cbacbacbacba'),(406,1,2,'abcabcabcabc','cbacbacbacba'),(407,1,2,'abcabcabcabc','cbacbacbacba'),(408,1,2,'abcabcabcabc','cbacbacbacba'),(409,1,2,'abcabcabcabc','cbacbacbacba'),(410,1,2,'abcabcabcabc','cbacbacbacba'),(411,1,2,'abcabcabcabc','cbacbacbacba'),(412,1,2,'abcabcabcabc','cbacbacbacba'),(413,1,2,'abcabcabcabc','cbacbacbacba'),(414,1,2,'abcabcabcabc','cbacbacbacba'),(415,1,2,'abcabcabcabc','cbacbacbacba'),(416,1,2,'abcabcabcabc','cbacbacbacba'),(417,1,2,'abcabcabcabc','cbacbacbacba'),(418,1,2,'abcabcabcabc','cbacbacbacba'),(419,1,2,'abcabcabcabc','cbacbacbacba'),(420,1,2,'abcabcabcabc','cbacbacbacba'),(421,1,2,'abcabcabcabc','cbacbacbacba'),(422,1,2,'abcabcabcabc','cbacbacbacba'),(423,1,2,'abcabcabcabc','cbacbacbacba'),(424,1,2,'abcabcabcabc','cbacbacbacba'),(425,1,2,'abcabcabcabc','cbacbacbacba'),(426,1,2,'abcabcabcabc','cbacbacbacba'),(427,1,2,'abcabcabcabc','cbacbacbacba'),(428,1,2,'abcabcabcabc','cbacbacbacba'),(429,1,2,'abcabcabcabc','cbacbacbacba'),(430,1,2,'abcabcabcabc','cbacbacbacba'),(431,1,2,'abcabcabcabc','cbacbacbacba'),(432,1,2,'abcabcabcabc','cbacbacbacba'),(433,1,2,'abcabcabcabc','cbacbacbacba'),(434,1,2,'abcabcabcabc','cbacbacbacba'),(435,1,2,'abcabcabcabc','cbacbacbacba'),(436,1,2,'abcabcabcabc','cbacbacbacba'),(437,1,2,'abcabcabcabc','cbacbacbacba'),(438,1,2,'abcabcabcabc','cbacbacbacba'),(439,1,2,'abcabcabcabc','cbacbacbacba'),(440,1,2,'abcabcabcabc','cbacbacbacba'),(441,1,2,'abcabcabcabc','cbacbacbacba'),(442,1,2,'abcabcabcabc','cbacbacbacba'),(443,1,2,'abcabcabcabc','cbacbacbacba'),(444,1,2,'abcabcabcabc','cbacbacbacba'),(445,1,2,'abcabcabcabc','cbacbacbacba'),(446,1,2,'abcabcabcabc','cbacbacbacba'),(447,1,2,'abcabcabcabc','cbacbacbacba'),(448,1,2,'abcabcabcabc','cbacbacbacba'),(449,1,2,'abcabcabcabc','cbacbacbacba'),(450,1,2,'abcabcabcabc','cbacbacbacba'),(451,1,2,'abcabcabcabc','cbacbacbacba'),(452,1,2,'abcabcabcabc','cbacbacbacba'),(453,1,2,'abcabcabcabc','cbacbacbacba'),(454,1,2,'abcabcabcabc','cbacbacbacba'),(455,1,2,'abcabcabcabc','cbacbacbacba'),(456,1,2,'abcabcabcabc','cbacbacbacba'),(457,1,2,'abcabcabcabc','cbacbacbacba'),(458,1,2,'abcabcabcabc','cbacbacbacba'),(459,1,2,'abcabcabcabc','cbacbacbacba'),(460,1,2,'abcabcabcabc','cbacbacbacba'),(461,1,2,'abcabcabcabc','cbacbacbacba'),(462,1,2,'abcabcabcabc','cbacbacbacba'),(463,1,2,'abcabcabcabc','cbacbacbacba'),(464,1,2,'abcabcabcabc','cbacbacbacba'),(465,1,2,'abcabcabcabc','cbacbacbacba'),(466,1,2,'abcabcabcabc','cbacbacbacba'),(467,1,2,'abcabcabcabc','cbacbacbacba'),(468,1,2,'abcabcabcabc','cbacbacbacba'),(469,1,2,'abcabcabcabc','cbacbacbacba'),(470,1,2,'abcabcabcabc','cbacbacbacba'),(471,1,2,'abcabcabcabc','cbacbacbacba'),(472,1,2,'abcabcabcabc','cbacbacbacba'),(473,1,2,'abcabcabcabc','cbacbacbacba'),(474,1,2,'abcabcabcabc','cbacbacbacba'),(475,1,2,'abcabcabcabc','cbacbacbacba'),(476,1,2,'abcabcabcabc','cbacbacbacba'),(477,1,2,'abcabcabcabc','cbacbacbacba'),(478,1,2,'abcabcabcabc','cbacbacbacba'),(479,1,2,'abcabcabcabc','cbacbacbacba'),(480,1,2,'abcabcabcabc','cbacbacbacba'),(481,1,2,'abcabcabcabc','cbacbacbacba'),(482,1,2,'abcabcabcabc','cbacbacbacba'),(483,1,2,'abcabcabcabc','cbacbacbacba'),(484,1,2,'abcabcabcabc','cbacbacbacba'),(485,1,2,'abcabcabcabc','cbacbacbacba'),(486,1,2,'abcabcabcabc','cbacbacbacba'),(487,1,2,'abcabcabcabc','cbacbacbacba'),(488,1,2,'abcabcabcabc','cbacbacbacba'),(489,1,2,'abcabcabcabc','cbacbacbacba'),(490,1,2,'abcabcabcabc','cbacbacbacba'),(491,1,2,'abcabcabcabc','cbacbacbacba'),(492,1,2,'abcabcabcabc','cbacbacbacba'),(493,1,2,'abcabcabcabc','cbacbacbacba'),(494,1,2,'abcabcabcabc','cbacbacbacba'),(495,1,2,'abcabcabcabc','cbacbacbacba'),(496,1,2,'abcabcabcabc','cbacbacbacba'),(497,1,2,'abcabcabcabc','cbacbacbacba'),(498,1,2,'abcabcabcabc','cbacbacbacba'),(499,1,2,'abcabcabcabc','cbacbacbacba'),(500,1,2,'abcabcabcabc','cbacbacbacba'),(501,1,2,'abcabcabcabc','cbacbacbacba'),(502,1,2,'abcabcabcabc','cbacbacbacba'),(503,1,2,'abcabcabcabc','cbacbacbacba'),(504,1,2,'abcabcabcabc','cbacbacbacba'),(505,1,2,'abcabcabcabc','cbacbacbacba'),(506,1,2,'abcabcabcabc','cbacbacbacba'),(507,1,2,'abcabcabcabc','cbacbacbacba'),(508,1,2,'abcabcabcabc','cbacbacbacba'),(509,1,2,'abcabcabcabc','cbacbacbacba'),(510,1,2,'abcabcabcabc','cbacbacbacba'),(511,1,2,'abcabcabcabc','cbacbacbacba'),(512,1,2,'abcabcabcabc','cbacbacbacba'),(513,1,2,'abcabcabcabc','cbacbacbacba'),(514,1,2,'abcabcabcabc','cbacbacbacba'),(515,1,2,'abcabcabcabc','cbacbacbacba'),(516,1,2,'abcabcabcabc','cbacbacbacba'),(517,1,2,'abcabcabcabc','cbacbacbacba'),(518,1,2,'abcabcabcabc','cbacbacbacba'),(519,1,2,'abcabcabcabc','cbacbacbacba'),(520,1,2,'abcabcabcabc','cbacbacbacba'),(521,1,2,'abcabcabcabc','cbacbacbacba'),(522,1,2,'abcabcabcabc','cbacbacbacba'),(523,1,2,'abcabcabcabc','cbacbacbacba'),(524,1,2,'abcabcabcabc','cbacbacbacba'),(525,1,2,'abcabcabcabc','cbacbacbacba'),(526,1,2,'abcabcabcabc','cbacbacbacba'),(527,1,2,'abcabcabcabc','cbacbacbacba'),(528,1,2,'abcabcabcabc','cbacbacbacba'),(529,1,2,'abcabcabcabc','cbacbacbacba'),(530,1,2,'abcabcabcabc','cbacbacbacba'),(531,1,2,'abcabcabcabc','cbacbacbacba'),(532,1,2,'abcabcabcabc','cbacbacbacba'),(533,1,2,'abcabcabcabc','cbacbacbacba'),(534,1,2,'abcabcabcabc','cbacbacbacba'),(535,1,2,'abcabcabcabc','cbacbacbacba'),(536,1,2,'abcabcabcabc','cbacbacbacba'),(537,1,2,'abcabcabcabc','cbacbacbacba'),(538,1,2,'abcabcabcabc','cbacbacbacba'),(539,1,2,'abcabcabcabc','cbacbacbacba'),(540,1,2,'abcabcabcabc','cbacbacbacba'),(541,1,2,'abcabcabcabc','cbacbacbacba'),(542,1,2,'abcabcabcabc','cbacbacbacba'),(543,1,2,'abcabcabcabc','cbacbacbacba'),(544,1,2,'abcabcabcabc','cbacbacbacba'),(545,1,2,'abcabcabcabc','cbacbacbacba'),(546,1,2,'abcabcabcabc','cbacbacbacba'),(547,1,2,'abcabcabcabc','cbacbacbacba'),(548,1,2,'abcabcabcabc','cbacbacbacba'),(549,1,2,'abcabcabcabc','cbacbacbacba'),(550,1,2,'abcabcabcabc','cbacbacbacba'),(551,1,2,'abcabcabcabc','cbacbacbacba'),(552,1,2,'abcabcabcabc','cbacbacbacba'),(553,1,2,'abcabcabcabc','cbacbacbacba'),(554,1,2,'abcabcabcabc','cbacbacbacba'),(555,1,2,'abcabcabcabc','cbacbacbacba'),(556,1,2,'abcabcabcabc','cbacbacbacba'),(557,1,2,'abcabcabcabc','cbacbacbacba'),(558,1,2,'abcabcabcabc','cbacbacbacba'),(559,1,2,'abcabcabcabc','cbacbacbacba'),(560,1,2,'abcabcabcabc','cbacbacbacba'),(561,1,2,'abcabcabcabc','cbacbacbacba'),(562,1,2,'abcabcabcabc','cbacbacbacba'),(563,1,2,'abcabcabcabc','cbacbacbacba'),(564,1,2,'abcabcabcabc','cbacbacbacba'),(565,1,2,'abcabcabcabc','cbacbacbacba'),(566,1,2,'abcabcabcabc','cbacbacbacba'),(567,1,2,'abcabcabcabc','cbacbacbacba'),(568,1,2,'abcabcabcabc','cbacbacbacba'),(569,1,2,'abcabcabcabc','cbacbacbacba'),(570,1,2,'abcabcabcabc','cbacbacbacba'),(571,1,2,'abcabcabcabc','cbacbacbacba'),(572,1,2,'abcabcabcabc','cbacbacbacba'),(573,1,2,'abcabcabcabc','cbacbacbacba'),(574,1,2,'abcabcabcabc','cbacbacbacba'),(575,1,2,'abcabcabcabc','cbacbacbacba'),(576,1,2,'abcabcabcabc','cbacbacbacba'),(577,1,2,'abcabcabcabc','cbacbacbacba'),(578,1,2,'abcabcabcabc','cbacbacbacba'),(579,1,2,'abcabcabcabc','cbacbacbacba'),(580,1,2,'abcabcabcabc','cbacbacbacba'),(581,1,2,'abcabcabcabc','cbacbacbacba'),(582,1,2,'abcabcabcabc','cbacbacbacba'),(583,1,2,'abcabcabcabc','cbacbacbacba'),(584,1,2,'abcabcabcabc','cbacbacbacba'),(585,1,2,'abcabcabcabc','cbacbacbacba'),(586,1,2,'abcabcabcabc','cbacbacbacba'),(587,1,2,'abcabcabcabc','cbacbacbacba'),(588,1,2,'abcabcabcabc','cbacbacbacba'),(589,1,2,'abcabcabcabc','cbacbacbacba'),(590,1,2,'abcabcabcabc','cbacbacbacba'),(591,1,2,'abcabcabcabc','cbacbacbacba'),(592,1,2,'abcabcabcabc','cbacbacbacba'),(593,1,2,'abcabcabcabc','cbacbacbacba'),(594,1,2,'abcabcabcabc','cbacbacbacba'),(595,1,2,'abcabcabcabc','cbacbacbacba'),(596,1,2,'abcabcabcabc','cbacbacbacba'),(597,1,2,'abcabcabcabc','cbacbacbacba'),(598,1,2,'abcabcabcabc','cbacbacbacba'),(599,1,2,'abcabcabcabc','cbacbacbacba'),(600,1,2,'abcabcabcabc','cbacbacbacba'),(601,1,2,'abcabcabcabc','cbacbacbacba'),(602,1,2,'abcabcabcabc','cbacbacbacba'),(603,1,2,'abcabcabcabc','cbacbacbacba'),(604,1,2,'abcabcabcabc','cbacbacbacba'),(605,1,2,'abcabcabcabc','cbacbacbacba'),(606,1,2,'abcabcabcabc','cbacbacbacba'),(607,1,2,'abcabcabcabc','cbacbacbacba'),(608,1,2,'abcabcabcabc','cbacbacbacba'),(609,1,2,'abcabcabcabc','cbacbacbacba'),(610,1,2,'abcabcabcabc','cbacbacbacba'),(611,1,2,'abcabcabcabc','cbacbacbacba'),(612,1,2,'abcabcabcabc','cbacbacbacba'),(613,1,2,'abcabcabcabc','cbacbacbacba'),(614,1,2,'abcabcabcabc','cbacbacbacba'),(615,1,2,'abcabcabcabc','cbacbacbacba'),(616,1,2,'abcabcabcabc','cbacbacbacba'),(617,1,2,'abcabcabcabc','cbacbacbacba'),(618,1,2,'abcabcabcabc','cbacbacbacba'),(619,1,2,'abcabcabcabc','cbacbacbacba'),(620,1,2,'abcabcabcabc','cbacbacbacba'),(621,1,2,'abcabcabcabc','cbacbacbacba'),(622,1,2,'abcabcabcabc','cbacbacbacba'),(623,1,2,'abcabcabcabc','cbacbacbacba'),(624,1,2,'abcabcabcabc','cbacbacbacba'),(625,1,2,'abcabcabcabc','cbacbacbacba'),(626,1,2,'abcabcabcabc','cbacbacbacba'),(627,1,2,'abcabcabcabc','cbacbacbacba'),(628,1,2,'abcabcabcabc','cbacbacbacba'),(629,1,2,'abcabcabcabc','cbacbacbacba'),(630,1,2,'abcabcabcabc','cbacbacbacba'),(631,1,2,'abcabcabcabc','cbacbacbacba'),(632,1,2,'abcabcabcabc','cbacbacbacba'),(633,1,2,'abcabcabcabc','cbacbacbacba'),(634,1,2,'abcabcabcabc','cbacbacbacba'),(635,1,2,'abcabcabcabc','cbacbacbacba'),(636,1,2,'abcabcabcabc','cbacbacbacba'),(637,1,2,'abcabcabcabc','cbacbacbacba'),(638,1,2,'abcabcabcabc','cbacbacbacba'),(639,1,2,'abcabcabcabc','cbacbacbacba'),(640,1,2,'abcabcabcabc','cbacbacbacba'),(641,1,2,'abcabcabcabc','cbacbacbacba'),(642,1,2,'abcabcabcabc','cbacbacbacba'),(643,1,2,'abcabcabcabc','cbacbacbacba'),(644,1,2,'abcabcabcabc','cbacbacbacba'),(645,1,2,'abcabcabcabc','cbacbacbacba'),(646,1,2,'abcabcabcabc','cbacbacbacba'),(647,1,2,'abcabcabcabc','cbacbacbacba'),(648,1,2,'abcabcabcabc','cbacbacbacba'),(649,1,2,'abcabcabcabc','cbacbacbacba'),(650,1,2,'abcabcabcabc','cbacbacbacba'),(651,1,2,'abcabcabcabc','cbacbacbacba'),(652,1,2,'abcabcabcabc','cbacbacbacba'),(653,1,2,'abcabcabcabc','cbacbacbacba'),(654,1,2,'abcabcabcabc','cbacbacbacba'),(655,1,2,'abcabcabcabc','cbacbacbacba'),(656,1,2,'abcabcabcabc','cbacbacbacba'),(657,1,2,'abcabcabcabc','cbacbacbacba'),(658,1,2,'abcabcabcabc','cbacbacbacba'),(659,1,2,'abcabcabcabc','cbacbacbacba'),(660,1,2,'abcabcabcabc','cbacbacbacba'),(661,1,2,'abcabcabcabc','cbacbacbacba'),(662,1,2,'abcabcabcabc','cbacbacbacba'),(663,1,2,'abcabcabcabc','cbacbacbacba'),(664,1,2,'abcabcabcabc','cbacbacbacba'),(665,1,2,'abcabcabcabc','cbacbacbacba'),(666,1,2,'abcabcabcabc','cbacbacbacba'),(667,1,2,'abcabcabcabc','cbacbacbacba'),(668,1,2,'abcabcabcabc','cbacbacbacba'),(669,1,2,'abcabcabcabc','cbacbacbacba'),(670,1,2,'abcabcabcabc','cbacbacbacba'),(671,1,2,'abcabcabcabc','cbacbacbacba'),(672,1,2,'abcabcabcabc','cbacbacbacba'),(673,1,2,'abcabcabcabc','cbacbacbacba'),(674,1,2,'abcabcabcabc','cbacbacbacba'),(675,1,2,'abcabcabcabc','cbacbacbacba'),(676,1,2,'abcabcabcabc','cbacbacbacba'),(677,1,2,'abcabcabcabc','cbacbacbacba'),(678,1,2,'abcabcabcabc','cbacbacbacba'),(679,1,2,'abcabcabcabc','cbacbacbacba'),(680,1,2,'abcabcabcabc','cbacbacbacba'),(681,1,2,'abcabcabcabc','cbacbacbacba'),(682,1,2,'abcabcabcabc','cbacbacbacba'),(683,1,2,'abcabcabcabc','cbacbacbacba'),(684,1,2,'abcabcabcabc','cbacbacbacba'),(685,1,2,'abcabcabcabc','cbacbacbacba'),(686,1,2,'abcabcabcabc','cbacbacbacba'),(687,1,2,'abcabcabcabc','cbacbacbacba'),(688,1,2,'abcabcabcabc','cbacbacbacba'),(689,1,2,'abcabcabcabc','cbacbacbacba'),(690,1,2,'abcabcabcabc','cbacbacbacba'),(691,1,2,'abcabcabcabc','cbacbacbacba'),(692,1,2,'abcabcabcabc','cbacbacbacba'),(693,1,2,'abcabcabcabc','cbacbacbacba'),(694,1,2,'abcabcabcabc','cbacbacbacba'),(695,1,2,'abcabcabcabc','cbacbacbacba'),(696,1,2,'abcabcabcabc','cbacbacbacba'),(697,1,2,'abcabcabcabc','cbacbacbacba'),(698,1,2,'abcabcabcabc','cbacbacbacba'),(699,1,2,'abcabcabcabc','cbacbacbacba'),(700,1,2,'abcabcabcabc','cbacbacbacba'),(701,1,2,'abcabcabcabc','cbacbacbacba'),(702,1,2,'abcabcabcabc','cbacbacbacba'),(703,1,2,'abcabcabcabc','cbacbacbacba'),(704,1,2,'abcabcabcabc','cbacbacbacba'),(705,1,2,'abcabcabcabc','cbacbacbacba'),(706,1,2,'abcabcabcabc','cbacbacbacba'),(707,1,2,'abcabcabcabc','cbacbacbacba'),(708,1,2,'abcabcabcabc','cbacbacbacba'),(709,1,2,'abcabcabcabc','cbacbacbacba'),(710,1,2,'abcabcabcabc','cbacbacbacba'),(711,1,2,'abcabcabcabc','cbacbacbacba'),(712,1,2,'abcabcabcabc','cbacbacbacba'),(713,1,2,'abcabcabcabc','cbacbacbacba'),(714,1,2,'abcabcabcabc','cbacbacbacba'),(715,1,2,'abcabcabcabc','cbacbacbacba'),(716,1,2,'abcabcabcabc','cbacbacbacba'),(717,1,2,'abcabcabcabc','cbacbacbacba'),(718,1,2,'abcabcabcabc','cbacbacbacba'),(719,1,2,'abcabcabcabc','cbacbacbacba'),(720,1,2,'abcabcabcabc','cbacbacbacba'),(721,1,2,'abcabcabcabc','cbacbacbacba'),(722,1,2,'abcabcabcabc','cbacbacbacba'),(723,1,2,'abcabcabcabc','cbacbacbacba'),(724,1,2,'abcabcabcabc','cbacbacbacba'),(725,1,2,'abcabcabcabc','cbacbacbacba'),(726,1,2,'abcabcabcabc','cbacbacbacba'),(727,1,2,'abcabcabcabc','cbacbacbacba'),(728,1,2,'abcabcabcabc','cbacbacbacba'),(729,1,2,'abcabcabcabc','cbacbacbacba'),(730,1,2,'abcabcabcabc','cbacbacbacba'),(731,1,2,'abcabcabcabc','cbacbacbacba'),(732,1,2,'abcabcabcabc','cbacbacbacba'),(733,1,2,'abcabcabcabc','cbacbacbacba'),(734,1,2,'abcabcabcabc','cbacbacbacba'),(735,1,2,'abcabcabcabc','cbacbacbacba'),(736,1,2,'abcabcabcabc','cbacbacbacba'),(737,1,2,'abcabcabcabc','cbacbacbacba'),(738,1,2,'abcabcabcabc','cbacbacbacba'),(739,1,2,'abcabcabcabc','cbacbacbacba'),(740,1,2,'abcabcabcabc','cbacbacbacba'),(741,1,2,'abcabcabcabc','cbacbacbacba'),(742,1,2,'abcabcabcabc','cbacbacbacba'),(743,1,2,'abcabcabcabc','cbacbacbacba'),(744,1,2,'abcabcabcabc','cbacbacbacba'),(745,1,2,'abcabcabcabc','cbacbacbacba'),(746,1,2,'abcabcabcabc','cbacbacbacba'),(747,1,2,'abcabcabcabc','cbacbacbacba'),(748,1,2,'abcabcabcabc','cbacbacbacba'),(749,1,2,'abcabcabcabc','cbacbacbacba'),(750,1,2,'abcabcabcabc','cbacbacbacba'),(751,1,2,'abcabcabcabc','cbacbacbacba'),(752,1,2,'abcabcabcabc','cbacbacbacba'),(753,1,2,'abcabcabcabc','cbacbacbacba'),(754,1,2,'abcabcabcabc','cbacbacbacba'),(755,1,2,'abcabcabcabc','cbacbacbacba'),(756,1,2,'abcabcabcabc','cbacbacbacba'),(757,1,2,'abcabcabcabc','cbacbacbacba'),(758,1,2,'abcabcabcabc','cbacbacbacba'),(759,1,2,'abcabcabcabc','cbacbacbacba'),(760,1,2,'abcabcabcabc','cbacbacbacba'),(761,1,2,'abcabcabcabc','cbacbacbacba'),(762,1,2,'abcabcabcabc','cbacbacbacba'),(763,1,2,'abcabcabcabc','cbacbacbacba'),(764,1,2,'abcabcabcabc','cbacbacbacba'),(765,1,2,'abcabcabcabc','cbacbacbacba'),(766,1,2,'abcabcabcabc','cbacbacbacba'),(767,1,2,'abcabcabcabc','cbacbacbacba'),(768,1,2,'abcabcabcabc','cbacbacbacba'),(769,1,2,'abcabcabcabc','cbacbacbacba'),(770,1,2,'abcabcabcabc','cbacbacbacba'),(771,1,2,'abcabcabcabc','cbacbacbacba'),(772,1,2,'abcabcabcabc','cbacbacbacba'),(773,1,2,'abcabcabcabc','cbacbacbacba'),(774,1,2,'abcabcabcabc','cbacbacbacba'),(775,1,2,'abcabcabcabc','cbacbacbacba'),(776,1,2,'abcabcabcabc','cbacbacbacba'),(777,1,2,'abcabcabcabc','cbacbacbacba'),(778,1,2,'abcabcabcabc','cbacbacbacba'),(779,1,2,'abcabcabcabc','cbacbacbacba'),(780,1,2,'abcabcabcabc','cbacbacbacba'),(781,1,2,'abcabcabcabc','cbacbacbacba'),(782,1,2,'abcabcabcabc','cbacbacbacba'),(783,1,2,'abcabcabcabc','cbacbacbacba'),(784,1,2,'abcabcabcabc','cbacbacbacba'),(785,1,2,'abcabcabcabc','cbacbacbacba'),(786,1,2,'abcabcabcabc','cbacbacbacba'),(787,1,2,'abcabcabcabc','cbacbacbacba'),(788,1,2,'abcabcabcabc','cbacbacbacba'),(789,1,2,'abcabcabcabc','cbacbacbacba'),(790,1,2,'abcabcabcabc','cbacbacbacba'),(791,1,2,'abcabcabcabc','cbacbacbacba'),(792,1,2,'abcabcabcabc','cbacbacbacba'),(793,1,2,'abcabcabcabc','cbacbacbacba'),(794,1,2,'abcabcabcabc','cbacbacbacba'),(795,1,2,'abcabcabcabc','cbacbacbacba'),(796,1,2,'abcabcabcabc','cbacbacbacba'),(797,1,2,'abcabcabcabc','cbacbacbacba'),(798,1,2,'abcabcabcabc','cbacbacbacba'),(799,1,2,'abcabcabcabc','cbacbacbacba'),(800,1,2,'abcabcabcabc','cbacbacbacba'),(801,1,2,'abcabcabcabc','cbacbacbacba'),(802,1,2,'abcabcabcabc','cbacbacbacba'),(803,1,2,'abcabcabcabc','cbacbacbacba'),(804,1,2,'abcabcabcabc','cbacbacbacba'),(805,1,2,'abcabcabcabc','cbacbacbacba'),(806,1,2,'abcabcabcabc','cbacbacbacba'),(807,1,2,'abcabcabcabc','cbacbacbacba'),(808,1,2,'abcabcabcabc','cbacbacbacba'),(809,1,2,'abcabcabcabc','cbacbacbacba'),(810,1,2,'abcabcabcabc','cbacbacbacba'),(811,1,2,'abcabcabcabc','cbacbacbacba'),(812,1,2,'abcabcabcabc','cbacbacbacba'),(813,1,2,'abcabcabcabc','cbacbacbacba'),(814,1,2,'abcabcabcabc','cbacbacbacba'),(815,1,2,'abcabcabcabc','cbacbacbacba'),(816,1,2,'abcabcabcabc','cbacbacbacba'),(817,1,2,'abcabcabcabc','cbacbacbacba'),(818,1,2,'abcabcabcabc','cbacbacbacba'),(819,1,2,'abcabcabcabc','cbacbacbacba'),(820,1,2,'abcabcabcabc','cbacbacbacba'),(821,1,2,'abcabcabcabc','cbacbacbacba'),(822,1,2,'abcabcabcabc','cbacbacbacba'),(823,1,2,'abcabcabcabc','cbacbacbacba'),(824,1,2,'abcabcabcabc','cbacbacbacba'),(825,1,2,'abcabcabcabc','cbacbacbacba'),(826,1,2,'abcabcabcabc','cbacbacbacba'),(827,1,2,'abcabcabcabc','cbacbacbacba'),(828,1,2,'abcabcabcabc','cbacbacbacba'),(829,1,2,'abcabcabcabc','cbacbacbacba'),(830,1,2,'abcabcabcabc','cbacbacbacba'),(831,1,2,'abcabcabcabc','cbacbacbacba'),(832,1,2,'abcabcabcabc','cbacbacbacba'),(833,1,2,'abcabcabcabc','cbacbacbacba'),(834,1,2,'abcabcabcabc','cbacbacbacba'),(835,1,2,'abcabcabcabc','cbacbacbacba'),(836,1,2,'abcabcabcabc','cbacbacbacba'),(837,1,2,'abcabcabcabc','cbacbacbacba'),(838,1,2,'abcabcabcabc','cbacbacbacba'),(839,1,2,'abcabcabcabc','cbacbacbacba'),(840,1,2,'abcabcabcabc','cbacbacbacba'),(841,1,2,'abcabcabcabc','cbacbacbacba'),(842,1,2,'abcabcabcabc','cbacbacbacba'),(843,1,2,'abcabcabcabc','cbacbacbacba'),(844,1,2,'abcabcabcabc','cbacbacbacba'),(845,1,2,'abcabcabcabc','cbacbacbacba'),(846,1,2,'abcabcabcabc','cbacbacbacba'),(847,1,2,'abcabcabcabc','cbacbacbacba'),(848,1,2,'abcabcabcabc','cbacbacbacba'),(849,1,2,'abcabcabcabc','cbacbacbacba'),(850,1,2,'abcabcabcabc','cbacbacbacba'),(851,1,2,'abcabcabcabc','cbacbacbacba'),(852,1,2,'abcabcabcabc','cbacbacbacba'),(853,1,2,'abcabcabcabc','cbacbacbacba'),(854,1,2,'abcabcabcabc','cbacbacbacba'),(855,1,2,'abcabcabcabc','cbacbacbacba'),(856,1,2,'abcabcabcabc','cbacbacbacba'),(857,1,2,'abcabcabcabc','cbacbacbacba'),(858,1,2,'abcabcabcabc','cbacbacbacba'),(859,1,2,'abcabcabcabc','cbacbacbacba'),(860,1,2,'abcabcabcabc','cbacbacbacba'),(861,1,2,'abcabcabcabc','cbacbacbacba'),(862,1,2,'abcabcabcabc','cbacbacbacba'),(863,1,2,'abcabcabcabc','cbacbacbacba'),(864,1,2,'abcabcabcabc','cbacbacbacba'),(865,1,2,'abcabcabcabc','cbacbacbacba'),(866,1,2,'abcabcabcabc','cbacbacbacba'),(867,1,2,'abcabcabcabc','cbacbacbacba'),(868,1,2,'abcabcabcabc','cbacbacbacba'),(869,1,2,'abcabcabcabc','cbacbacbacba'),(870,1,2,'abcabcabcabc','cbacbacbacba'),(871,1,2,'abcabcabcabc','cbacbacbacba'),(872,1,2,'abcabcabcabc','cbacbacbacba'),(873,1,2,'abcabcabcabc','cbacbacbacba'),(874,1,2,'abcabcabcabc','cbacbacbacba'),(875,1,2,'abcabcabcabc','cbacbacbacba'),(876,1,2,'abcabcabcabc','cbacbacbacba'),(877,1,2,'abcabcabcabc','cbacbacbacba'),(878,1,2,'abcabcabcabc','cbacbacbacba'),(879,1,2,'abcabcabcabc','cbacbacbacba'),(880,1,2,'abcabcabcabc','cbacbacbacba'),(881,1,2,'abcabcabcabc','cbacbacbacba'),(882,1,2,'abcabcabcabc','cbacbacbacba'),(883,1,2,'abcabcabcabc','cbacbacbacba'),(884,1,2,'abcabcabcabc','cbacbacbacba'),(885,1,2,'abcabcabcabc','cbacbacbacba'),(886,1,2,'abcabcabcabc','cbacbacbacba'),(887,1,2,'abcabcabcabc','cbacbacbacba'),(888,1,2,'abcabcabcabc','cbacbacbacba'),(889,1,2,'abcabcabcabc','cbacbacbacba'),(890,1,2,'abcabcabcabc','cbacbacbacba'),(891,1,2,'abcabcabcabc','cbacbacbacba'),(892,1,2,'abcabcabcabc','cbacbacbacba'),(893,1,2,'abcabcabcabc','cbacbacbacba'),(894,1,2,'abcabcabcabc','cbacbacbacba'),(895,1,2,'abcabcabcabc','cbacbacbacba'),(896,1,2,'abcabcabcabc','cbacbacbacba'),(897,1,2,'abcabcabcabc','cbacbacbacba'),(898,1,2,'abcabcabcabc','cbacbacbacba'),(899,1,2,'abcabcabcabc','cbacbacbacba'),(900,1,2,'abcabcabcabc','cbacbacbacba'),(901,1,2,'abcabcabcabc','cbacbacbacba'),(902,1,2,'abcabcabcabc','cbacbacbacba'),(903,1,2,'abcabcabcabc','cbacbacbacba'),(904,1,2,'abcabcabcabc','cbacbacbacba'),(905,1,2,'abcabcabcabc','cbacbacbacba'),(906,1,2,'abcabcabcabc','cbacbacbacba'),(907,1,2,'abcabcabcabc','cbacbacbacba'),(908,1,2,'abcabcabcabc','cbacbacbacba'),(909,1,2,'abcabcabcabc','cbacbacbacba'),(910,1,2,'abcabcabcabc','cbacbacbacba'),(911,1,2,'abcabcabcabc','cbacbacbacba'),(912,1,2,'abcabcabcabc','cbacbacbacba'),(913,1,2,'abcabcabcabc','cbacbacbacba'),(914,1,2,'abcabcabcabc','cbacbacbacba'),(915,1,2,'abcabcabcabc','cbacbacbacba'),(916,1,2,'abcabcabcabc','cbacbacbacba'),(917,1,2,'abcabcabcabc','cbacbacbacba'),(918,1,2,'abcabcabcabc','cbacbacbacba'),(919,1,2,'abcabcabcabc','cbacbacbacba'),(920,1,2,'abcabcabcabc','cbacbacbacba'),(921,1,2,'abcabcabcabc','cbacbacbacba'),(922,1,2,'abcabcabcabc','cbacbacbacba'),(923,1,2,'abcabcabcabc','cbacbacbacba'),(924,1,2,'abcabcabcabc','cbacbacbacba'),(925,1,2,'abcabcabcabc','cbacbacbacba'),(926,1,2,'abcabcabcabc','cbacbacbacba'),(927,1,2,'abcabcabcabc','cbacbacbacba'),(928,1,2,'abcabcabcabc','cbacbacbacba'),(929,1,2,'abcabcabcabc','cbacbacbacba'),(930,1,2,'abcabcabcabc','cbacbacbacba'),(931,1,2,'abcabcabcabc','cbacbacbacba'),(932,1,2,'abcabcabcabc','cbacbacbacba'),(933,1,2,'abcabcabcabc','cbacbacbacba'),(934,1,2,'abcabcabcabc','cbacbacbacba'),(935,1,2,'abcabcabcabc','cbacbacbacba'),(936,1,2,'abcabcabcabc','cbacbacbacba'),(937,1,2,'abcabcabcabc','cbacbacbacba'),(938,1,2,'abcabcabcabc','cbacbacbacba'),(939,1,2,'abcabcabcabc','cbacbacbacba'),(940,1,2,'abcabcabcabc','cbacbacbacba'),(941,1,2,'abcabcabcabc','cbacbacbacba'),(942,1,2,'abcabcabcabc','cbacbacbacba'),(943,1,2,'abcabcabcabc','cbacbacbacba'),(944,1,2,'abcabcabcabc','cbacbacbacba'),(945,1,2,'abcabcabcabc','cbacbacbacba'),(946,1,2,'abcabcabcabc','cbacbacbacba'),(947,1,2,'abcabcabcabc','cbacbacbacba'),(948,1,2,'abcabcabcabc','cbacbacbacba'),(949,1,2,'abcabcabcabc','cbacbacbacba'),(950,1,2,'abcabcabcabc','cbacbacbacba'),(951,1,2,'abcabcabcabc','cbacbacbacba'),(952,1,2,'abcabcabcabc','cbacbacbacba'),(953,1,2,'abcabcabcabc','cbacbacbacba'),(954,1,2,'abcabcabcabc','cbacbacbacba'),(955,1,2,'abcabcabcabc','cbacbacbacba'),(956,1,2,'abcabcabcabc','cbacbacbacba'),(957,1,2,'abcabcabcabc','cbacbacbacba'),(958,1,2,'abcabcabcabc','cbacbacbacba'),(959,1,2,'abcabcabcabc','cbacbacbacba'),(960,1,2,'abcabcabcabc','cbacbacbacba'),(961,1,2,'abcabcabcabc','cbacbacbacba'),(962,1,2,'abcabcabcabc','cbacbacbacba'),(963,1,2,'abcabcabcabc','cbacbacbacba'),(964,1,2,'abcabcabcabc','cbacbacbacba'),(965,1,2,'abcabcabcabc','cbacbacbacba'),(966,1,2,'abcabcabcabc','cbacbacbacba'),(967,1,2,'abcabcabcabc','cbacbacbacba'),(968,1,2,'abcabcabcabc','cbacbacbacba'),(969,1,2,'abcabcabcabc','cbacbacbacba'),(970,1,2,'abcabcabcabc','cbacbacbacba'),(971,1,2,'abcabcabcabc','cbacbacbacba'),(972,1,2,'abcabcabcabc','cbacbacbacba'),(973,1,2,'abcabcabcabc','cbacbacbacba'),(974,1,2,'abcabcabcabc','cbacbacbacba'),(975,1,2,'abcabcabcabc','cbacbacbacba'),(976,1,2,'abcabcabcabc','cbacbacbacba'),(977,1,2,'abcabcabcabc','cbacbacbacba'),(978,1,2,'abcabcabcabc','cbacbacbacba'),(979,1,2,'abcabcabcabc','cbacbacbacba'),(980,1,2,'abcabcabcabc','cbacbacbacba'),(981,1,2,'abcabcabcabc','cbacbacbacba'),(982,1,2,'abcabcabcabc','cbacbacbacba'),(983,1,2,'abcabcabcabc','cbacbacbacba'),(984,1,2,'abcabcabcabc','cbacbacbacba'),(985,1,2,'abcabcabcabc','cbacbacbacba'),(986,1,2,'abcabcabcabc','cbacbacbacba'),(987,1,2,'abcabcabcabc','cbacbacbacba'),(988,1,2,'abcabcabcabc','cbacbacbacba'),(989,1,2,'abcabcabcabc','cbacbacbacba'),(990,1,2,'abcabcabcabc','cbacbacbacba'),(991,1,2,'abcabcabcabc','cbacbacbacba'),(992,1,2,'abcabcabcabc','cbacbacbacba'),(993,1,2,'abcabcabcabc','cbacbacbacba'),(994,1,2,'abcabcabcabc','cbacbacbacba'),(995,1,2,'abcabcabcabc','cbacbacbacba'),(996,1,2,'abcabcabcabc','cbacbacbacba'),(997,1,2,'abcabcabcabc','cbacbacbacba'),(998,1,2,'abcabcabcabc','cbacbacbacba'),(999,1,2,'abcabcabcabc','cbacbacbacba'),(1000,1,2,'abcabcabcabc','cbacbacbacba'),(1001,1,2,'abcabcabcabc','cbacbacbacba'),(1002,1,2,'abcabcabcabc','cbacbacbacba'),(1003,1,2,'abcabcabcabc','cbacbacbacba'),(1004,1,2,'abcabcabcabc','cbacbacbacba'),(1005,1,2,'abcabcabcabc','cbacbacbacba'),(1006,1,2,'abcabcabcabc','cbacbacbacba'),(1007,1,2,'abcabcabcabc','cbacbacbacba'),(1008,1,2,'abcabcabcabc','cbacbacbacba'),(1009,1,2,'abcabcabcabc','cbacbacbacba'),(1010,1,2,'abcabcabcabc','cbacbacbacba'),(1011,1,2,'abcabcabcabc','cbacbacbacba'),(1012,1,2,'abcabcabcabc','cbacbacbacba'),(1013,1,2,'abcabcabcabc','cbacbacbacba'),(1014,1,2,'abcabcabcabc','cbacbacbacba'),(1015,1,2,'abcabcabcabc','cbacbacbacba'),(1016,1,2,'abcabcabcabc','cbacbacbacba'),(1017,1,2,'abcabcabcabc','cbacbacbacba'),(1018,1,2,'abcabcabcabc','cbacbacbacba'),(1019,1,2,'abcabcabcabc','cbacbacbacba'),(1020,1,2,'abcabcabcabc','cbacbacbacba'),(1021,1,2,'abcabcabcabc','cbacbacbacba'),(1022,1,2,'abcabcabcabc','cbacbacbacba'),(1023,1,2,'abcabcabcabc','cbacbacbacba'),(1024,1,2,'abcabcabcabc','cbacbacbacba'),(1025,2,1,'bcabcabcabca','acbacbacbacb'),(1026,2,1,'bcabcabcabca','acbacbacbacb'),(1027,2,1,'bcabcabcabca','acbacbacbacb'),(1028,2,1,'bcabcabcabca','acbacbacbacb'),(1029,2,1,'bcabcabcabca','acbacbacbacb'),(1030,2,1,'bcabcabcabca','acbacbacbacb'),(1031,2,1,'bcabcabcabca','acbacbacbacb'),(1032,2,1,'bcabcabcabca','acbacbacbacb'),(1033,2,1,'bcabcabcabca','acbacbacbacb'),(1034,2,1,'bcabcabcabca','acbacbacbacb'),(1035,2,1,'bcabcabcabca','acbacbacbacb'),(1036,2,1,'bcabcabcabca','acbacbacbacb'),(1037,2,1,'bcabcabcabca','acbacbacbacb'),(1038,2,1,'bcabcabcabca','acbacbacbacb'),(1039,2,1,'bcabcabcabca','acbacbacbacb'),(1040,2,1,'bcabcabcabca','acbacbacbacb'),(1041,2,1,'bcabcabcabca','acbacbacbacb'),(1042,2,1,'bcabcabcabca','acbacbacbacb'),(1043,2,1,'bcabcabcabca','acbacbacbacb'),(1044,2,1,'bcabcabcabca','acbacbacbacb'),(1045,2,1,'bcabcabcabca','acbacbacbacb'),(1046,2,1,'bcabcabcabca','acbacbacbacb'),(1047,2,1,'bcabcabcabca','acbacbacbacb'),(1048,2,1,'bcabcabcabca','acbacbacbacb'),(1049,2,1,'bcabcabcabca','acbacbacbacb'),(1050,2,1,'bcabcabcabca','acbacbacbacb'),(1051,2,1,'bcabcabcabca','acbacbacbacb'),(1052,2,1,'bcabcabcabca','acbacbacbacb'),(1053,2,1,'bcabcabcabca','acbacbacbacb'),(1054,2,1,'bcabcabcabca','acbacbacbacb'),(1055,2,1,'bcabcabcabca','acbacbacbacb'),(1056,2,1,'bcabcabcabca','acbacbacbacb'),(1057,2,1,'bcabcabcabca','acbacbacbacb'),(1058,2,1,'bcabcabcabca','acbacbacbacb'),(1059,2,1,'bcabcabcabca','acbacbacbacb'),(1060,2,1,'bcabcabcabca','acbacbacbacb'),(1061,2,1,'bcabcabcabca','acbacbacbacb'),(1062,2,1,'bcabcabcabca','acbacbacbacb'),(1063,2,1,'bcabcabcabca','acbacbacbacb'),(1064,2,1,'bcabcabcabca','acbacbacbacb'),(1065,2,1,'bcabcabcabca','acbacbacbacb'),(1066,2,1,'bcabcabcabca','acbacbacbacb'),(1067,2,1,'bcabcabcabca','acbacbacbacb'),(1068,2,1,'bcabcabcabca','acbacbacbacb'),(1069,2,1,'bcabcabcabca','acbacbacbacb'),(1070,2,1,'bcabcabcabca','acbacbacbacb'),(1071,2,1,'bcabcabcabca','acbacbacbacb'),(1072,2,1,'bcabcabcabca','acbacbacbacb'),(1073,2,1,'bcabcabcabca','acbacbacbacb'),(1074,2,1,'bcabcabcabca','acbacbacbacb'),(1075,2,1,'bcabcabcabca','acbacbacbacb'),(1076,2,1,'bcabcabcabca','acbacbacbacb'),(1077,2,1,'bcabcabcabca','acbacbacbacb'),(1078,2,1,'bcabcabcabca','acbacbacbacb'),(1079,2,1,'bcabcabcabca','acbacbacbacb'),(1080,2,1,'bcabcabcabca','acbacbacbacb'),(1081,2,1,'bcabcabcabca','acbacbacbacb'),(1082,2,1,'bcabcabcabca','acbacbacbacb'),(1083,2,1,'bcabcabcabca','acbacbacbacb'),(1084,2,1,'bcabcabcabca','acbacbacbacb'),(1085,2,1,'bcabcabcabca','acbacbacbacb'),(1086,2,1,'bcabcabcabca','acbacbacbacb'),(1087,2,1,'bcabcabcabca','acbacbacbacb'),(1088,2,1,'bcabcabcabca','acbacbacbacb'),(1089,2,1,'bcabcabcabca','acbacbacbacb'),(1090,2,1,'bcabcabcabca','acbacbacbacb'),(1091,2,1,'bcabcabcabca','acbacbacbacb'),(1092,2,1,'bcabcabcabca','acbacbacbacb'),(1093,2,1,'bcabcabcabca','acbacbacbacb'),(1094,2,1,'bcabcabcabca','acbacbacbacb'),(1095,2,1,'bcabcabcabca','acbacbacbacb'),(1096,2,1,'bcabcabcabca','acbacbacbacb'),(1097,2,1,'bcabcabcabca','acbacbacbacb'),(1098,2,1,'bcabcabcabca','acbacbacbacb'),(1099,2,1,'bcabcabcabca','acbacbacbacb'),(1100,2,1,'bcabcabcabca','acbacbacbacb'),(1101,2,1,'bcabcabcabca','acbacbacbacb'),(1102,2,1,'bcabcabcabca','acbacbacbacb'),(1103,2,1,'bcabcabcabca','acbacbacbacb'),(1104,2,1,'bcabcabcabca','acbacbacbacb'),(1105,2,1,'bcabcabcabca','acbacbacbacb'),(1106,2,1,'bcabcabcabca','acbacbacbacb'),(1107,2,1,'bcabcabcabca','acbacbacbacb'),(1108,2,1,'bcabcabcabca','acbacbacbacb'),(1109,2,1,'bcabcabcabca','acbacbacbacb'),(1110,2,1,'bcabcabcabca','acbacbacbacb'),(1111,2,1,'bcabcabcabca','acbacbacbacb'),(1112,2,1,'bcabcabcabca','acbacbacbacb'),(1113,2,1,'bcabcabcabca','acbacbacbacb'),(1114,2,1,'bcabcabcabca','acbacbacbacb'),(1115,2,1,'bcabcabcabca','acbacbacbacb'),(1116,2,1,'bcabcabcabca','acbacbacbacb'),(1117,2,1,'bcabcabcabca','acbacbacbacb'),(1118,2,1,'bcabcabcabca','acbacbacbacb'),(1119,2,1,'bcabcabcabca','acbacbacbacb'),(1120,2,1,'bcabcabcabca','acbacbacbacb'),(1121,2,1,'bcabcabcabca','acbacbacbacb'),(1122,2,1,'bcabcabcabca','acbacbacbacb'),(1123,2,1,'bcabcabcabca','acbacbacbacb'),(1124,2,1,'bcabcabcabca','acbacbacbacb'),(1125,2,1,'bcabcabcabca','acbacbacbacb'),(1126,2,1,'bcabcabcabca','acbacbacbacb'),(1127,2,1,'bcabcabcabca','acbacbacbacb'),(1128,2,1,'bcabcabcabca','acbacbacbacb'),(1129,2,1,'bcabcabcabca','acbacbacbacb'),(1130,2,1,'bcabcabcabca','acbacbacbacb'),(1131,2,1,'bcabcabcabca','acbacbacbacb'),(1132,2,1,'bcabcabcabca','acbacbacbacb'),(1133,2,1,'bcabcabcabca','acbacbacbacb'),(1134,2,1,'bcabcabcabca','acbacbacbacb'),(1135,2,1,'bcabcabcabca','acbacbacbacb'),(1136,2,1,'bcabcabcabca','acbacbacbacb'),(1137,2,1,'bcabcabcabca','acbacbacbacb'),(1138,2,1,'bcabcabcabca','acbacbacbacb'),(1139,2,1,'bcabcabcabca','acbacbacbacb'),(1140,2,1,'bcabcabcabca','acbacbacbacb'),(1141,2,1,'bcabcabcabca','acbacbacbacb'),(1142,2,1,'bcabcabcabca','acbacbacbacb'),(1143,2,1,'bcabcabcabca','acbacbacbacb'),(1144,2,1,'bcabcabcabca','acbacbacbacb'),(1145,2,1,'bcabcabcabca','acbacbacbacb'),(1146,2,1,'bcabcabcabca','acbacbacbacb'),(1147,2,1,'bcabcabcabca','acbacbacbacb'),(1148,2,1,'bcabcabcabca','acbacbacbacb'),(1149,2,1,'bcabcabcabca','acbacbacbacb'),(1150,2,1,'bcabcabcabca','acbacbacbacb'),(1151,2,1,'bcabcabcabca','acbacbacbacb'),(1152,2,1,'bcabcabcabca','acbacbacbacb'),(1153,2,1,'bcabcabcabca','acbacbacbacb'),(1154,2,1,'bcabcabcabca','acbacbacbacb'),(1155,2,1,'bcabcabcabca','acbacbacbacb'),(1156,2,1,'bcabcabcabca','acbacbacbacb'),(1157,2,1,'bcabcabcabca','acbacbacbacb'),(1158,2,1,'bcabcabcabca','acbacbacbacb'),(1159,2,1,'bcabcabcabca','acbacbacbacb'),(1160,2,1,'bcabcabcabca','acbacbacbacb'),(1161,2,1,'bcabcabcabca','acbacbacbacb'),(1162,2,1,'bcabcabcabca','acbacbacbacb'),(1163,2,1,'bcabcabcabca','acbacbacbacb'),(1164,2,1,'bcabcabcabca','acbacbacbacb'),(1165,2,1,'bcabcabcabca','acbacbacbacb'),(1166,2,1,'bcabcabcabca','acbacbacbacb'),(1167,2,1,'bcabcabcabca','acbacbacbacb'),(1168,2,1,'bcabcabcabca','acbacbacbacb'),(1169,2,1,'bcabcabcabca','acbacbacbacb'),(1170,2,1,'bcabcabcabca','acbacbacbacb'),(1171,2,1,'bcabcabcabca','acbacbacbacb'),(1172,2,1,'bcabcabcabca','acbacbacbacb'),(1173,2,1,'bcabcabcabca','acbacbacbacb'),(1174,2,1,'bcabcabcabca','acbacbacbacb'),(1175,2,1,'bcabcabcabca','acbacbacbacb'),(1176,2,1,'bcabcabcabca','acbacbacbacb'),(1177,2,1,'bcabcabcabca','acbacbacbacb'),(1178,2,1,'bcabcabcabca','acbacbacbacb'),(1179,2,1,'bcabcabcabca','acbacbacbacb'),(1180,2,1,'bcabcabcabca','acbacbacbacb'),(1181,2,1,'bcabcabcabca','acbacbacbacb'),(1182,2,1,'bcabcabcabca','acbacbacbacb'),(1183,2,1,'bcabcabcabca','acbacbacbacb'),(1184,2,1,'bcabcabcabca','acbacbacbacb'),(1185,2,1,'bcabcabcabca','acbacbacbacb'),(1186,2,1,'bcabcabcabca','acbacbacbacb'),(1187,2,1,'bcabcabcabca','acbacbacbacb'),(1188,2,1,'bcabcabcabca','acbacbacbacb'),(1189,2,1,'bcabcabcabca','acbacbacbacb'),(1190,2,1,'bcabcabcabca','acbacbacbacb'),(1191,2,1,'bcabcabcabca','acbacbacbacb'),(1192,2,1,'bcabcabcabca','acbacbacbacb'),(1193,2,1,'bcabcabcabca','acbacbacbacb'),(1194,2,1,'bcabcabcabca','acbacbacbacb'),(1195,2,1,'bcabcabcabca','acbacbacbacb'),(1196,2,1,'bcabcabcabca','acbacbacbacb'),(1197,2,1,'bcabcabcabca','acbacbacbacb'),(1198,2,1,'bcabcabcabca','acbacbacbacb'),(1199,2,1,'bcabcabcabca','acbacbacbacb'),(1200,2,1,'bcabcabcabca','acbacbacbacb'),(1201,2,1,'bcabcabcabca','acbacbacbacb'),(1202,2,1,'bcabcabcabca','acbacbacbacb'),(1203,2,1,'bcabcabcabca','acbacbacbacb'),(1204,2,1,'bcabcabcabca','acbacbacbacb'),(1205,2,1,'bcabcabcabca','acbacbacbacb'),(1206,2,1,'bcabcabcabca','acbacbacbacb'),(1207,2,1,'bcabcabcabca','acbacbacbacb'),(1208,2,1,'bcabcabcabca','acbacbacbacb'),(1209,2,1,'bcabcabcabca','acbacbacbacb'),(1210,2,1,'bcabcabcabca','acbacbacbacb'),(1211,2,1,'bcabcabcabca','acbacbacbacb'),(1212,2,1,'bcabcabcabca','acbacbacbacb'),(1213,2,1,'bcabcabcabca','acbacbacbacb'),(1214,2,1,'bcabcabcabca','acbacbacbacb'),(1215,2,1,'bcabcabcabca','acbacbacbacb'),(1216,2,1,'bcabcabcabca','acbacbacbacb'),(1217,2,1,'bcabcabcabca','acbacbacbacb'),(1218,2,1,'bcabcabcabca','acbacbacbacb'),(1219,2,1,'bcabcabcabca','acbacbacbacb'),(1220,2,1,'bcabcabcabca','acbacbacbacb'),(1221,2,1,'bcabcabcabca','acbacbacbacb'),(1222,2,1,'bcabcabcabca','acbacbacbacb'),(1223,2,1,'bcabcabcabca','acbacbacbacb'),(1224,2,1,'bcabcabcabca','acbacbacbacb'),(1225,2,1,'bcabcabcabca','acbacbacbacb'),(1226,2,1,'bcabcabcabca','acbacbacbacb'),(1227,2,1,'bcabcabcabca','acbacbacbacb'),(1228,2,1,'bcabcabcabca','acbacbacbacb'),(1229,2,1,'bcabcabcabca','acbacbacbacb'),(1230,2,1,'bcabcabcabca','acbacbacbacb'),(1231,2,1,'bcabcabcabca','acbacbacbacb'),(1232,2,1,'bcabcabcabca','acbacbacbacb'),(1233,2,1,'bcabcabcabca','acbacbacbacb'),(1234,2,1,'bcabcabcabca','acbacbacbacb'),(1235,2,1,'bcabcabcabca','acbacbacbacb'),(1236,2,1,'bcabcabcabca','acbacbacbacb'),(1237,2,1,'bcabcabcabca','acbacbacbacb'),(1238,2,1,'bcabcabcabca','acbacbacbacb'),(1239,2,1,'bcabcabcabca','acbacbacbacb'),(1240,2,1,'bcabcabcabca','acbacbacbacb'),(1241,2,1,'bcabcabcabca','acbacbacbacb'),(1242,2,1,'bcabcabcabca','acbacbacbacb'),(1243,2,1,'bcabcabcabca','acbacbacbacb'),(1244,2,1,'bcabcabcabca','acbacbacbacb'),(1245,2,1,'bcabcabcabca','acbacbacbacb'),(1246,2,1,'bcabcabcabca','acbacbacbacb'),(1247,2,1,'bcabcabcabca','acbacbacbacb'),(1248,2,1,'bcabcabcabca','acbacbacbacb'),(1249,2,1,'bcabcabcabca','acbacbacbacb'),(1250,2,1,'bcabcabcabca','acbacbacbacb'),(1251,2,1,'bcabcabcabca','acbacbacbacb'),(1252,2,1,'bcabcabcabca','acbacbacbacb'),(1253,2,1,'bcabcabcabca','acbacbacbacb'),(1254,2,1,'bcabcabcabca','acbacbacbacb'),(1255,2,1,'bcabcabcabca','acbacbacbacb'),(1256,2,1,'bcabcabcabca','acbacbacbacb'),(1257,2,1,'bcabcabcabca','acbacbacbacb'),(1258,2,1,'bcabcabcabca','acbacbacbacb'),(1259,2,1,'bcabcabcabca','acbacbacbacb'),(1260,2,1,'bcabcabcabca','acbacbacbacb'),(1261,2,1,'bcabcabcabca','acbacbacbacb'),(1262,2,1,'bcabcabcabca','acbacbacbacb'),(1263,2,1,'bcabcabcabca','acbacbacbacb'),(1264,2,1,'bcabcabcabca','acbacbacbacb'),(1265,2,1,'bcabcabcabca','acbacbacbacb'),(1266,2,1,'bcabcabcabca','acbacbacbacb'),(1267,2,1,'bcabcabcabca','acbacbacbacb'),(1268,2,1,'bcabcabcabca','acbacbacbacb'),(1269,2,1,'bcabcabcabca','acbacbacbacb'),(1270,2,1,'bcabcabcabca','acbacbacbacb'),(1271,2,1,'bcabcabcabca','acbacbacbacb'),(1272,2,1,'bcabcabcabca','acbacbacbacb'),(1273,2,1,'bcabcabcabca','acbacbacbacb'),(1274,2,1,'bcabcabcabca','acbacbacbacb'),(1275,2,1,'bcabcabcabca','acbacbacbacb'),(1276,2,1,'bcabcabcabca','acbacbacbacb'),(1277,2,1,'bcabcabcabca','acbacbacbacb'),(1278,2,1,'bcabcabcabca','acbacbacbacb'),(1279,2,1,'bcabcabcabca','acbacbacbacb'),(1280,2,1,'bcabcabcabca','acbacbacbacb'),(1281,2,1,'bcabcabcabca','acbacbacbacb'),(1282,2,1,'bcabcabcabca','acbacbacbacb'),(1283,2,1,'bcabcabcabca','acbacbacbacb'),(1284,2,1,'bcabcabcabca','acbacbacbacb'),(1285,2,1,'bcabcabcabca','acbacbacbacb'),(1286,2,1,'bcabcabcabca','acbacbacbacb'),(1287,2,1,'bcabcabcabca','acbacbacbacb'),(1288,2,1,'bcabcabcabca','acbacbacbacb'),(1289,2,1,'bcabcabcabca','acbacbacbacb'),(1290,2,1,'bcabcabcabca','acbacbacbacb'),(1291,2,1,'bcabcabcabca','acbacbacbacb'),(1292,2,1,'bcabcabcabca','acbacbacbacb'),(1293,2,1,'bcabcabcabca','acbacbacbacb'),(1294,2,1,'bcabcabcabca','acbacbacbacb'),(1295,2,1,'bcabcabcabca','acbacbacbacb'),(1296,2,1,'bcabcabcabca','acbacbacbacb'),(1297,2,1,'bcabcabcabca','acbacbacbacb'),(1298,2,1,'bcabcabcabca','acbacbacbacb'),(1299,2,1,'bcabcabcabca','acbacbacbacb'),(1300,2,1,'bcabcabcabca','acbacbacbacb'),(1301,2,1,'bcabcabcabca','acbacbacbacb'),(1302,2,1,'bcabcabcabca','acbacbacbacb'),(1303,2,1,'bcabcabcabca','acbacbacbacb'),(1304,2,1,'bcabcabcabca','acbacbacbacb'),(1305,2,1,'bcabcabcabca','acbacbacbacb'),(1306,2,1,'bcabcabcabca','acbacbacbacb'),(1307,2,1,'bcabcabcabca','acbacbacbacb'),(1308,2,1,'bcabcabcabca','acbacbacbacb'),(1309,2,1,'bcabcabcabca','acbacbacbacb'),(1310,2,1,'bcabcabcabca','acbacbacbacb'),(1311,2,1,'bcabcabcabca','acbacbacbacb'),(1312,2,1,'bcabcabcabca','acbacbacbacb'),(1313,2,1,'bcabcabcabca','acbacbacbacb'),(1314,2,1,'bcabcabcabca','acbacbacbacb'),(1315,2,1,'bcabcabcabca','acbacbacbacb'),(1316,2,1,'bcabcabcabca','acbacbacbacb'),(1317,2,1,'bcabcabcabca','acbacbacbacb'),(1318,2,1,'bcabcabcabca','acbacbacbacb'),(1319,2,1,'bcabcabcabca','acbacbacbacb'),(1320,2,1,'bcabcabcabca','acbacbacbacb'),(1321,2,1,'bcabcabcabca','acbacbacbacb'),(1322,2,1,'bcabcabcabca','acbacbacbacb'),(1323,2,1,'bcabcabcabca','acbacbacbacb'),(1324,2,1,'bcabcabcabca','acbacbacbacb'),(1325,2,1,'bcabcabcabca','acbacbacbacb'),(1326,2,1,'bcabcabcabca','acbacbacbacb'),(1327,2,1,'bcabcabcabca','acbacbacbacb'),(1328,2,1,'bcabcabcabca','acbacbacbacb'),(1329,2,1,'bcabcabcabca','acbacbacbacb'),(1330,2,1,'bcabcabcabca','acbacbacbacb'),(1331,2,1,'bcabcabcabca','acbacbacbacb'),(1332,2,1,'bcabcabcabca','acbacbacbacb'),(1333,2,1,'bcabcabcabca','acbacbacbacb'),(1334,2,1,'bcabcabcabca','acbacbacbacb'),(1335,2,1,'bcabcabcabca','acbacbacbacb'),(1336,2,1,'bcabcabcabca','acbacbacbacb'),(1337,2,1,'bcabcabcabca','acbacbacbacb'),(1338,2,1,'bcabcabcabca','acbacbacbacb'),(1339,2,1,'bcabcabcabca','acbacbacbacb'),(1340,2,1,'bcabcabcabca','acbacbacbacb'),(1341,2,1,'bcabcabcabca','acbacbacbacb'),(1342,2,1,'bcabcabcabca','acbacbacbacb'),(1343,2,1,'bcabcabcabca','acbacbacbacb'),(1344,2,1,'bcabcabcabca','acbacbacbacb'),(1345,2,1,'bcabcabcabca','acbacbacbacb'),(1346,2,1,'bcabcabcabca','acbacbacbacb'),(1347,2,1,'bcabcabcabca','acbacbacbacb'),(1348,2,1,'bcabcabcabca','acbacbacbacb'),(1349,2,1,'bcabcabcabca','acbacbacbacb'),(1350,2,1,'bcabcabcabca','acbacbacbacb'),(1351,2,1,'bcabcabcabca','acbacbacbacb'),(1352,2,1,'bcabcabcabca','acbacbacbacb'),(1353,2,1,'bcabcabcabca','acbacbacbacb'),(1354,2,1,'bcabcabcabca','acbacbacbacb'),(1355,2,1,'bcabcabcabca','acbacbacbacb'),(1356,2,1,'bcabcabcabca','acbacbacbacb'),(1357,2,1,'bcabcabcabca','acbacbacbacb'),(1358,2,1,'bcabcabcabca','acbacbacbacb'),(1359,2,1,'bcabcabcabca','acbacbacbacb'),(1360,2,1,'bcabcabcabca','acbacbacbacb'),(1361,2,1,'bcabcabcabca','acbacbacbacb'),(1362,2,1,'bcabcabcabca','acbacbacbacb'),(1363,2,1,'bcabcabcabca','acbacbacbacb'),(1364,2,1,'bcabcabcabca','acbacbacbacb'),(1365,2,1,'bcabcabcabca','acbacbacbacb'),(1366,2,1,'bcabcabcabca','acbacbacbacb'),(1367,2,1,'bcabcabcabca','acbacbacbacb'),(1368,2,1,'bcabcabcabca','acbacbacbacb'),(1369,2,1,'bcabcabcabca','acbacbacbacb'),(1370,2,1,'bcabcabcabca','acbacbacbacb'),(1371,2,1,'bcabcabcabca','acbacbacbacb'),(1372,2,1,'bcabcabcabca','acbacbacbacb'),(1373,2,1,'bcabcabcabca','acbacbacbacb'),(1374,2,1,'bcabcabcabca','acbacbacbacb'),(1375,2,1,'bcabcabcabca','acbacbacbacb'),(1376,2,1,'bcabcabcabca','acbacbacbacb'),(1377,2,1,'bcabcabcabca','acbacbacbacb'),(1378,2,1,'bcabcabcabca','acbacbacbacb'),(1379,2,1,'bcabcabcabca','acbacbacbacb'),(1380,2,1,'bcabcabcabca','acbacbacbacb'),(1381,2,1,'bcabcabcabca','acbacbacbacb'),(1382,2,1,'bcabcabcabca','acbacbacbacb'),(1383,2,1,'bcabcabcabca','acbacbacbacb'),(1384,2,1,'bcabcabcabca','acbacbacbacb'),(1385,2,1,'bcabcabcabca','acbacbacbacb'),(1386,2,1,'bcabcabcabca','acbacbacbacb'),(1387,2,1,'bcabcabcabca','acbacbacbacb'),(1388,2,1,'bcabcabcabca','acbacbacbacb'),(1389,2,1,'bcabcabcabca','acbacbacbacb'),(1390,2,1,'bcabcabcabca','acbacbacbacb'),(1391,2,1,'bcabcabcabca','acbacbacbacb'),(1392,2,1,'bcabcabcabca','acbacbacbacb'),(1393,2,1,'bcabcabcabca','acbacbacbacb'),(1394,2,1,'bcabcabcabca','acbacbacbacb'),(1395,2,1,'bcabcabcabca','acbacbacbacb'),(1396,2,1,'bcabcabcabca','acbacbacbacb'),(1397,2,1,'bcabcabcabca','acbacbacbacb'),(1398,2,1,'bcabcabcabca','acbacbacbacb'),(1399,2,1,'bcabcabcabca','acbacbacbacb'),(1400,2,1,'bcabcabcabca','acbacbacbacb'),(1401,2,1,'bcabcabcabca','acbacbacbacb'),(1402,2,1,'bcabcabcabca','acbacbacbacb'),(1403,2,1,'bcabcabcabca','acbacbacbacb'),(1404,2,1,'bcabcabcabca','acbacbacbacb'),(1405,2,1,'bcabcabcabca','acbacbacbacb'),(1406,2,1,'bcabcabcabca','acbacbacbacb'),(1407,2,1,'bcabcabcabca','acbacbacbacb'),(1408,2,1,'bcabcabcabca','acbacbacbacb'),(1409,2,1,'bcabcabcabca','acbacbacbacb'),(1410,2,1,'bcabcabcabca','acbacbacbacb'),(1411,2,1,'bcabcabcabca','acbacbacbacb'),(1412,2,1,'bcabcabcabca','acbacbacbacb'),(1413,2,1,'bcabcabcabca','acbacbacbacb'),(1414,2,1,'bcabcabcabca','acbacbacbacb'),(1415,2,1,'bcabcabcabca','acbacbacbacb'),(1416,2,1,'bcabcabcabca','acbacbacbacb'),(1417,2,1,'bcabcabcabca','acbacbacbacb'),(1418,2,1,'bcabcabcabca','acbacbacbacb'),(1419,2,1,'bcabcabcabca','acbacbacbacb'),(1420,2,1,'bcabcabcabca','acbacbacbacb'),(1421,2,1,'bcabcabcabca','acbacbacbacb'),(1422,2,1,'bcabcabcabca','acbacbacbacb'),(1423,2,1,'bcabcabcabca','acbacbacbacb'),(1424,2,1,'bcabcabcabca','acbacbacbacb'),(1425,2,1,'bcabcabcabca','acbacbacbacb'),(1426,2,1,'bcabcabcabca','acbacbacbacb'),(1427,2,1,'bcabcabcabca','acbacbacbacb'),(1428,2,1,'bcabcabcabca','acbacbacbacb'),(1429,2,1,'bcabcabcabca','acbacbacbacb'),(1430,2,1,'bcabcabcabca','acbacbacbacb'),(1431,2,1,'bcabcabcabca','acbacbacbacb'),(1432,2,1,'bcabcabcabca','acbacbacbacb'),(1433,2,1,'bcabcabcabca','acbacbacbacb'),(1434,2,1,'bcabcabcabca','acbacbacbacb'),(1435,2,1,'bcabcabcabca','acbacbacbacb'),(1436,2,1,'bcabcabcabca','acbacbacbacb'),(1437,2,1,'bcabcabcabca','acbacbacbacb'),(1438,2,1,'bcabcabcabca','acbacbacbacb'),(1439,2,1,'bcabcabcabca','acbacbacbacb'),(1440,2,1,'bcabcabcabca','acbacbacbacb'),(1441,2,1,'bcabcabcabca','acbacbacbacb'),(1442,2,1,'bcabcabcabca','acbacbacbacb'),(1443,2,1,'bcabcabcabca','acbacbacbacb'),(1444,2,1,'bcabcabcabca','acbacbacbacb'),(1445,2,1,'bcabcabcabca','acbacbacbacb'),(1446,2,1,'bcabcabcabca','acbacbacbacb'),(1447,2,1,'bcabcabcabca','acbacbacbacb'),(1448,2,1,'bcabcabcabca','acbacbacbacb'),(1449,2,1,'bcabcabcabca','acbacbacbacb'),(1450,2,1,'bcabcabcabca','acbacbacbacb'),(1451,2,1,'bcabcabcabca','acbacbacbacb'),(1452,2,1,'bcabcabcabca','acbacbacbacb'),(1453,2,1,'bcabcabcabca','acbacbacbacb'),(1454,2,1,'bcabcabcabca','acbacbacbacb'),(1455,2,1,'bcabcabcabca','acbacbacbacb'),(1456,2,1,'bcabcabcabca','acbacbacbacb'),(1457,2,1,'bcabcabcabca','acbacbacbacb'),(1458,2,1,'bcabcabcabca','acbacbacbacb'),(1459,2,1,'bcabcabcabca','acbacbacbacb'),(1460,2,1,'bcabcabcabca','acbacbacbacb'),(1461,2,1,'bcabcabcabca','acbacbacbacb'),(1462,2,1,'bcabcabcabca','acbacbacbacb'),(1463,2,1,'bcabcabcabca','acbacbacbacb'),(1464,2,1,'bcabcabcabca','acbacbacbacb'),(1465,2,1,'bcabcabcabca','acbacbacbacb'),(1466,2,1,'bcabcabcabca','acbacbacbacb'),(1467,2,1,'bcabcabcabca','acbacbacbacb'),(1468,2,1,'bcabcabcabca','acbacbacbacb'),(1469,2,1,'bcabcabcabca','acbacbacbacb'),(1470,2,1,'bcabcabcabca','acbacbacbacb'),(1471,2,1,'bcabcabcabca','acbacbacbacb'),(1472,2,1,'bcabcabcabca','acbacbacbacb'),(1473,2,1,'bcabcabcabca','acbacbacbacb'),(1474,2,1,'bcabcabcabca','acbacbacbacb'),(1475,2,1,'bcabcabcabca','acbacbacbacb'),(1476,2,1,'bcabcabcabca','acbacbacbacb'),(1477,2,1,'bcabcabcabca','acbacbacbacb'),(1478,2,1,'bcabcabcabca','acbacbacbacb'),(1479,2,1,'bcabcabcabca','acbacbacbacb'),(1480,2,1,'bcabcabcabca','acbacbacbacb'),(1481,2,1,'bcabcabcabca','acbacbacbacb'),(1482,2,1,'bcabcabcabca','acbacbacbacb'),(1483,2,1,'bcabcabcabca','acbacbacbacb'),(1484,2,1,'bcabcabcabca','acbacbacbacb'),(1485,2,1,'bcabcabcabca','acbacbacbacb'),(1486,2,1,'bcabcabcabca','acbacbacbacb'),(1487,2,1,'bcabcabcabca','acbacbacbacb'),(1488,2,1,'bcabcabcabca','acbacbacbacb'),(1489,2,1,'bcabcabcabca','acbacbacbacb'),(1490,2,1,'bcabcabcabca','acbacbacbacb'),(1491,2,1,'bcabcabcabca','acbacbacbacb'),(1492,2,1,'bcabcabcabca','acbacbacbacb'),(1493,2,1,'bcabcabcabca','acbacbacbacb'),(1494,2,1,'bcabcabcabca','acbacbacbacb'),(1495,2,1,'bcabcabcabca','acbacbacbacb'),(1496,2,1,'bcabcabcabca','acbacbacbacb'),(1497,2,1,'bcabcabcabca','acbacbacbacb'),(1498,2,1,'bcabcabcabca','acbacbacbacb'),(1499,2,1,'bcabcabcabca','acbacbacbacb'),(1500,2,1,'bcabcabcabca','acbacbacbacb'),(1501,2,1,'bcabcabcabca','acbacbacbacb'),(1502,2,1,'bcabcabcabca','acbacbacbacb'),(1503,2,1,'bcabcabcabca','acbacbacbacb'),(1504,2,1,'bcabcabcabca','acbacbacbacb'),(1505,2,1,'bcabcabcabca','acbacbacbacb'),(1506,2,1,'bcabcabcabca','acbacbacbacb'),(1507,2,1,'bcabcabcabca','acbacbacbacb'),(1508,2,1,'bcabcabcabca','acbacbacbacb'),(1509,2,1,'bcabcabcabca','acbacbacbacb'),(1510,2,1,'bcabcabcabca','acbacbacbacb'),(1511,2,1,'bcabcabcabca','acbacbacbacb'),(1512,2,1,'bcabcabcabca','acbacbacbacb'),(1513,2,1,'bcabcabcabca','acbacbacbacb'),(1514,2,1,'bcabcabcabca','acbacbacbacb'),(1515,2,1,'bcabcabcabca','acbacbacbacb'),(1516,2,1,'bcabcabcabca','acbacbacbacb'),(1517,2,1,'bcabcabcabca','acbacbacbacb'),(1518,2,1,'bcabcabcabca','acbacbacbacb'),(1519,2,1,'bcabcabcabca','acbacbacbacb'),(1520,2,1,'bcabcabcabca','acbacbacbacb'),(1521,2,1,'bcabcabcabca','acbacbacbacb'),(1522,2,1,'bcabcabcabca','acbacbacbacb'),(1523,2,1,'bcabcabcabca','acbacbacbacb'),(1524,2,1,'bcabcabcabca','acbacbacbacb'),(1525,2,1,'bcabcabcabca','acbacbacbacb'),(1526,2,1,'bcabcabcabca','acbacbacbacb'),(1527,2,1,'bcabcabcabca','acbacbacbacb'),(1528,2,1,'bcabcabcabca','acbacbacbacb'),(1529,2,1,'bcabcabcabca','acbacbacbacb'),(1530,2,1,'bcabcabcabca','acbacbacbacb'),(1531,2,1,'bcabcabcabca','acbacbacbacb'),(1532,2,1,'bcabcabcabca','acbacbacbacb'),(1533,2,1,'bcabcabcabca','acbacbacbacb'),(1534,2,1,'bcabcabcabca','acbacbacbacb'),(1535,2,1,'bcabcabcabca','acbacbacbacb'),(1536,2,1,'bcabcabcabca','acbacbacbacb'),(1537,2,1,'bcabcabcabca','acbacbacbacb'),(1538,2,1,'bcabcabcabca','acbacbacbacb'),(1539,2,1,'bcabcabcabca','acbacbacbacb'),(1540,2,1,'bcabcabcabca','acbacbacbacb'),(1541,2,1,'bcabcabcabca','acbacbacbacb'),(1542,2,1,'bcabcabcabca','acbacbacbacb'),(1543,2,1,'bcabcabcabca','acbacbacbacb'),(1544,2,1,'bcabcabcabca','acbacbacbacb'),(1545,2,1,'bcabcabcabca','acbacbacbacb'),(1546,2,1,'bcabcabcabca','acbacbacbacb'),(1547,2,1,'bcabcabcabca','acbacbacbacb'),(1548,2,1,'bcabcabcabca','acbacbacbacb'),(1549,2,1,'bcabcabcabca','acbacbacbacb'),(1550,2,1,'bcabcabcabca','acbacbacbacb'),(1551,2,1,'bcabcabcabca','acbacbacbacb'),(1552,2,1,'bcabcabcabca','acbacbacbacb'),(1553,2,1,'bcabcabcabca','acbacbacbacb'),(1554,2,1,'bcabcabcabca','acbacbacbacb'),(1555,2,1,'bcabcabcabca','acbacbacbacb'),(1556,2,1,'bcabcabcabca','acbacbacbacb'),(1557,2,1,'bcabcabcabca','acbacbacbacb'),(1558,2,1,'bcabcabcabca','acbacbacbacb'),(1559,2,1,'bcabcabcabca','acbacbacbacb'),(1560,2,1,'bcabcabcabca','acbacbacbacb'),(1561,2,1,'bcabcabcabca','acbacbacbacb'),(1562,2,1,'bcabcabcabca','acbacbacbacb'),(1563,2,1,'bcabcabcabca','acbacbacbacb'),(1564,2,1,'bcabcabcabca','acbacbacbacb'),(1565,2,1,'bcabcabcabca','acbacbacbacb'),(1566,2,1,'bcabcabcabca','acbacbacbacb'),(1567,2,1,'bcabcabcabca','acbacbacbacb'),(1568,2,1,'bcabcabcabca','acbacbacbacb'),(1569,2,1,'bcabcabcabca','acbacbacbacb'),(1570,2,1,'bcabcabcabca','acbacbacbacb'),(1571,2,1,'bcabcabcabca','acbacbacbacb'),(1572,2,1,'bcabcabcabca','acbacbacbacb'),(1573,2,1,'bcabcabcabca','acbacbacbacb'),(1574,2,1,'bcabcabcabca','acbacbacbacb'),(1575,2,1,'bcabcabcabca','acbacbacbacb'),(1576,2,1,'bcabcabcabca','acbacbacbacb'),(1577,2,1,'bcabcabcabca','acbacbacbacb'),(1578,2,1,'bcabcabcabca','acbacbacbacb'),(1579,2,1,'bcabcabcabca','acbacbacbacb'),(1580,2,1,'bcabcabcabca','acbacbacbacb'),(1581,2,1,'bcabcabcabca','acbacbacbacb'),(1582,2,1,'bcabcabcabca','acbacbacbacb'),(1583,2,1,'bcabcabcabca','acbacbacbacb'),(1584,2,1,'bcabcabcabca','acbacbacbacb'),(1585,2,1,'bcabcabcabca','acbacbacbacb'),(1586,2,1,'bcabcabcabca','acbacbacbacb'),(1587,2,1,'bcabcabcabca','acbacbacbacb'),(1588,2,1,'bcabcabcabca','acbacbacbacb'),(1589,2,1,'bcabcabcabca','acbacbacbacb'),(1590,2,1,'bcabcabcabca','acbacbacbacb'),(1591,2,1,'bcabcabcabca','acbacbacbacb'),(1592,2,1,'bcabcabcabca','acbacbacbacb'),(1593,2,1,'bcabcabcabca','acbacbacbacb'),(1594,2,1,'bcabcabcabca','acbacbacbacb'),(1595,2,1,'bcabcabcabca','acbacbacbacb'),(1596,2,1,'bcabcabcabca','acbacbacbacb'),(1597,2,1,'bcabcabcabca','acbacbacbacb'),(1598,2,1,'bcabcabcabca','acbacbacbacb'),(1599,2,1,'bcabcabcabca','acbacbacbacb'),(1600,2,1,'bcabcabcabca','acbacbacbacb'),(1601,2,1,'bcabcabcabca','acbacbacbacb'),(1602,2,1,'bcabcabcabca','acbacbacbacb'),(1603,2,1,'bcabcabcabca','acbacbacbacb'),(1604,2,1,'bcabcabcabca','acbacbacbacb'),(1605,2,1,'bcabcabcabca','acbacbacbacb'),(1606,2,1,'bcabcabcabca','acbacbacbacb'),(1607,2,1,'bcabcabcabca','acbacbacbacb'),(1608,2,1,'bcabcabcabca','acbacbacbacb'),(1609,2,1,'bcabcabcabca','acbacbacbacb'),(1610,2,1,'bcabcabcabca','acbacbacbacb'),(1611,2,1,'bcabcabcabca','acbacbacbacb'),(1612,2,1,'bcabcabcabca','acbacbacbacb'),(1613,2,1,'bcabcabcabca','acbacbacbacb'),(1614,2,1,'bcabcabcabca','acbacbacbacb'),(1615,2,1,'bcabcabcabca','acbacbacbacb'),(1616,2,1,'bcabcabcabca','acbacbacbacb'),(1617,2,1,'bcabcabcabca','acbacbacbacb'),(1618,2,1,'bcabcabcabca','acbacbacbacb'),(1619,2,1,'bcabcabcabca','acbacbacbacb'),(1620,2,1,'bcabcabcabca','acbacbacbacb'),(1621,2,1,'bcabcabcabca','acbacbacbacb'),(1622,2,1,'bcabcabcabca','acbacbacbacb'),(1623,2,1,'bcabcabcabca','acbacbacbacb'),(1624,2,1,'bcabcabcabca','acbacbacbacb'),(1625,2,1,'bcabcabcabca','acbacbacbacb'),(1626,2,1,'bcabcabcabca','acbacbacbacb'),(1627,2,1,'bcabcabcabca','acbacbacbacb'),(1628,2,1,'bcabcabcabca','acbacbacbacb'),(1629,2,1,'bcabcabcabca','acbacbacbacb'),(1630,2,1,'bcabcabcabca','acbacbacbacb'),(1631,2,1,'bcabcabcabca','acbacbacbacb'),(1632,2,1,'bcabcabcabca','acbacbacbacb'),(1633,2,1,'bcabcabcabca','acbacbacbacb'),(1634,2,1,'bcabcabcabca','acbacbacbacb'),(1635,2,1,'bcabcabcabca','acbacbacbacb'),(1636,2,1,'bcabcabcabca','acbacbacbacb'),(1637,2,1,'bcabcabcabca','acbacbacbacb'),(1638,2,1,'bcabcabcabca','acbacbacbacb'),(1639,2,1,'bcabcabcabca','acbacbacbacb'),(1640,2,1,'bcabcabcabca','acbacbacbacb'),(1641,2,1,'bcabcabcabca','acbacbacbacb'),(1642,2,1,'bcabcabcabca','acbacbacbacb'),(1643,2,1,'bcabcabcabca','acbacbacbacb'),(1644,2,1,'bcabcabcabca','acbacbacbacb'),(1645,2,1,'bcabcabcabca','acbacbacbacb'),(1646,2,1,'bcabcabcabca','acbacbacbacb'),(1647,2,1,'bcabcabcabca','acbacbacbacb'),(1648,2,1,'bcabcabcabca','acbacbacbacb'),(1649,2,1,'bcabcabcabca','acbacbacbacb'),(1650,2,1,'bcabcabcabca','acbacbacbacb'),(1651,2,1,'bcabcabcabca','acbacbacbacb'),(1652,2,1,'bcabcabcabca','acbacbacbacb'),(1653,2,1,'bcabcabcabca','acbacbacbacb'),(1654,2,1,'bcabcabcabca','acbacbacbacb'),(1655,2,1,'bcabcabcabca','acbacbacbacb'),(1656,2,1,'bcabcabcabca','acbacbacbacb'),(1657,2,1,'bcabcabcabca','acbacbacbacb'),(1658,2,1,'bcabcabcabca','acbacbacbacb'),(1659,2,1,'bcabcabcabca','acbacbacbacb'),(1660,2,1,'bcabcabcabca','acbacbacbacb'),(1661,2,1,'bcabcabcabca','acbacbacbacb'),(1662,2,1,'bcabcabcabca','acbacbacbacb'),(1663,2,1,'bcabcabcabca','acbacbacbacb'),(1664,2,1,'bcabcabcabca','acbacbacbacb'),(1665,2,1,'bcabcabcabca','acbacbacbacb'),(1666,2,1,'bcabcabcabca','acbacbacbacb'),(1667,2,1,'bcabcabcabca','acbacbacbacb'),(1668,2,1,'bcabcabcabca','acbacbacbacb'),(1669,2,1,'bcabcabcabca','acbacbacbacb'),(1670,2,1,'bcabcabcabca','acbacbacbacb'),(1671,2,1,'bcabcabcabca','acbacbacbacb'),(1672,2,1,'bcabcabcabca','acbacbacbacb'),(1673,2,1,'bcabcabcabca','acbacbacbacb'),(1674,2,1,'bcabcabcabca','acbacbacbacb'),(1675,2,1,'bcabcabcabca','acbacbacbacb'),(1676,2,1,'bcabcabcabca','acbacbacbacb'),(1677,2,1,'bcabcabcabca','acbacbacbacb'),(1678,2,1,'bcabcabcabca','acbacbacbacb'),(1679,2,1,'bcabcabcabca','acbacbacbacb'),(1680,2,1,'bcabcabcabca','acbacbacbacb'),(1681,2,1,'bcabcabcabca','acbacbacbacb'),(1682,2,1,'bcabcabcabca','acbacbacbacb'),(1683,2,1,'bcabcabcabca','acbacbacbacb'),(1684,2,1,'bcabcabcabca','acbacbacbacb'),(1685,2,1,'bcabcabcabca','acbacbacbacb'),(1686,2,1,'bcabcabcabca','acbacbacbacb'),(1687,2,1,'bcabcabcabca','acbacbacbacb'),(1688,2,1,'bcabcabcabca','acbacbacbacb'),(1689,2,1,'bcabcabcabca','acbacbacbacb'),(1690,2,1,'bcabcabcabca','acbacbacbacb'),(1691,2,1,'bcabcabcabca','acbacbacbacb'),(1692,2,1,'bcabcabcabca','acbacbacbacb'),(1693,2,1,'bcabcabcabca','acbacbacbacb'),(1694,2,1,'bcabcabcabca','acbacbacbacb'),(1695,2,1,'bcabcabcabca','acbacbacbacb'),(1696,2,1,'bcabcabcabca','acbacbacbacb'),(1697,2,1,'bcabcabcabca','acbacbacbacb'),(1698,2,1,'bcabcabcabca','acbacbacbacb'),(1699,2,1,'bcabcabcabca','acbacbacbacb'),(1700,2,1,'bcabcabcabca','acbacbacbacb'),(1701,2,1,'bcabcabcabca','acbacbacbacb'),(1702,2,1,'bcabcabcabca','acbacbacbacb'),(1703,2,1,'bcabcabcabca','acbacbacbacb'),(1704,2,1,'bcabcabcabca','acbacbacbacb'),(1705,2,1,'bcabcabcabca','acbacbacbacb'),(1706,2,1,'bcabcabcabca','acbacbacbacb'),(1707,2,1,'bcabcabcabca','acbacbacbacb'),(1708,2,1,'bcabcabcabca','acbacbacbacb'),(1709,2,1,'bcabcabcabca','acbacbacbacb'),(1710,2,1,'bcabcabcabca','acbacbacbacb'),(1711,2,1,'bcabcabcabca','acbacbacbacb'),(1712,2,1,'bcabcabcabca','acbacbacbacb'),(1713,2,1,'bcabcabcabca','acbacbacbacb'),(1714,2,1,'bcabcabcabca','acbacbacbacb'),(1715,2,1,'bcabcabcabca','acbacbacbacb'),(1716,2,1,'bcabcabcabca','acbacbacbacb'),(1717,2,1,'bcabcabcabca','acbacbacbacb'),(1718,2,1,'bcabcabcabca','acbacbacbacb'),(1719,2,1,'bcabcabcabca','acbacbacbacb'),(1720,2,1,'bcabcabcabca','acbacbacbacb'),(1721,2,1,'bcabcabcabca','acbacbacbacb'),(1722,2,1,'bcabcabcabca','acbacbacbacb'),(1723,2,1,'bcabcabcabca','acbacbacbacb'),(1724,2,1,'bcabcabcabca','acbacbacbacb'),(1725,2,1,'bcabcabcabca','acbacbacbacb'),(1726,2,1,'bcabcabcabca','acbacbacbacb'),(1727,2,1,'bcabcabcabca','acbacbacbacb'),(1728,2,1,'bcabcabcabca','acbacbacbacb'),(1729,2,1,'bcabcabcabca','acbacbacbacb'),(1730,2,1,'bcabcabcabca','acbacbacbacb'),(1731,2,1,'bcabcabcabca','acbacbacbacb'),(1732,2,1,'bcabcabcabca','acbacbacbacb'),(1733,2,1,'bcabcabcabca','acbacbacbacb'),(1734,2,1,'bcabcabcabca','acbacbacbacb'),(1735,2,1,'bcabcabcabca','acbacbacbacb'),(1736,2,1,'bcabcabcabca','acbacbacbacb'),(1737,2,1,'bcabcabcabca','acbacbacbacb'),(1738,2,1,'bcabcabcabca','acbacbacbacb'),(1739,2,1,'bcabcabcabca','acbacbacbacb'),(1740,2,1,'bcabcabcabca','acbacbacbacb'),(1741,2,1,'bcabcabcabca','acbacbacbacb'),(1742,2,1,'bcabcabcabca','acbacbacbacb'),(1743,2,1,'bcabcabcabca','acbacbacbacb'),(1744,2,1,'bcabcabcabca','acbacbacbacb'),(1745,2,1,'bcabcabcabca','acbacbacbacb'),(1746,2,1,'bcabcabcabca','acbacbacbacb'),(1747,2,1,'bcabcabcabca','acbacbacbacb'),(1748,2,1,'bcabcabcabca','acbacbacbacb'),(1749,2,1,'bcabcabcabca','acbacbacbacb'),(1750,2,1,'bcabcabcabca','acbacbacbacb'),(1751,2,1,'bcabcabcabca','acbacbacbacb'),(1752,2,1,'bcabcabcabca','acbacbacbacb'),(1753,2,1,'bcabcabcabca','acbacbacbacb'),(1754,2,1,'bcabcabcabca','acbacbacbacb'),(1755,2,1,'bcabcabcabca','acbacbacbacb'),(1756,2,1,'bcabcabcabca','acbacbacbacb'),(1757,2,1,'bcabcabcabca','acbacbacbacb'),(1758,2,1,'bcabcabcabca','acbacbacbacb'),(1759,2,1,'bcabcabcabca','acbacbacbacb'),(1760,2,1,'bcabcabcabca','acbacbacbacb'),(1761,2,1,'bcabcabcabca','acbacbacbacb'),(1762,2,1,'bcabcabcabca','acbacbacbacb'),(1763,2,1,'bcabcabcabca','acbacbacbacb'),(1764,2,1,'bcabcabcabca','acbacbacbacb'),(1765,2,1,'bcabcabcabca','acbacbacbacb'),(1766,2,1,'bcabcabcabca','acbacbacbacb'),(1767,2,1,'bcabcabcabca','acbacbacbacb'),(1768,2,1,'bcabcabcabca','acbacbacbacb'),(1769,2,1,'bcabcabcabca','acbacbacbacb'),(1770,2,1,'bcabcabcabca','acbacbacbacb'),(1771,2,1,'bcabcabcabca','acbacbacbacb'),(1772,2,1,'bcabcabcabca','acbacbacbacb'),(1773,2,1,'bcabcabcabca','acbacbacbacb'),(1774,2,1,'bcabcabcabca','acbacbacbacb'),(1775,2,1,'bcabcabcabca','acbacbacbacb'),(1776,2,1,'bcabcabcabca','acbacbacbacb'),(1777,2,1,'bcabcabcabca','acbacbacbacb'),(1778,2,1,'bcabcabcabca','acbacbacbacb'),(1779,2,1,'bcabcabcabca','acbacbacbacb'),(1780,2,1,'bcabcabcabca','acbacbacbacb'),(1781,2,1,'bcabcabcabca','acbacbacbacb'),(1782,2,1,'bcabcabcabca','acbacbacbacb'),(1783,2,1,'bcabcabcabca','acbacbacbacb'),(1784,2,1,'bcabcabcabca','acbacbacbacb'),(1785,2,1,'bcabcabcabca','acbacbacbacb'),(1786,2,1,'bcabcabcabca','acbacbacbacb'),(1787,2,1,'bcabcabcabca','acbacbacbacb'),(1788,2,1,'bcabcabcabca','acbacbacbacb'),(1789,2,1,'bcabcabcabca','acbacbacbacb'),(1790,2,1,'bcabcabcabca','acbacbacbacb'),(1791,2,1,'bcabcabcabca','acbacbacbacb'),(1792,2,1,'bcabcabcabca','acbacbacbacb'),(1793,2,1,'bcabcabcabca','acbacbacbacb'),(1794,2,1,'bcabcabcabca','acbacbacbacb'),(1795,2,1,'bcabcabcabca','acbacbacbacb'),(1796,2,1,'bcabcabcabca','acbacbacbacb'),(1797,2,1,'bcabcabcabca','acbacbacbacb'),(1798,2,1,'bcabcabcabca','acbacbacbacb'),(1799,2,1,'bcabcabcabca','acbacbacbacb'),(1800,2,1,'bcabcabcabca','acbacbacbacb'),(1801,2,1,'bcabcabcabca','acbacbacbacb'),(1802,2,1,'bcabcabcabca','acbacbacbacb'),(1803,2,1,'bcabcabcabca','acbacbacbacb'),(1804,2,1,'bcabcabcabca','acbacbacbacb'),(1805,2,1,'bcabcabcabca','acbacbacbacb'),(1806,2,1,'bcabcabcabca','acbacbacbacb'),(1807,2,1,'bcabcabcabca','acbacbacbacb'),(1808,2,1,'bcabcabcabca','acbacbacbacb'),(1809,2,1,'bcabcabcabca','acbacbacbacb'),(1810,2,1,'bcabcabcabca','acbacbacbacb'),(1811,2,1,'bcabcabcabca','acbacbacbacb'),(1812,2,1,'bcabcabcabca','acbacbacbacb'),(1813,2,1,'bcabcabcabca','acbacbacbacb'),(1814,2,1,'bcabcabcabca','acbacbacbacb'),(1815,2,1,'bcabcabcabca','acbacbacbacb'),(1816,2,1,'bcabcabcabca','acbacbacbacb'),(1817,2,1,'bcabcabcabca','acbacbacbacb'),(1818,2,1,'bcabcabcabca','acbacbacbacb'),(1819,2,1,'bcabcabcabca','acbacbacbacb'),(1820,2,1,'bcabcabcabca','acbacbacbacb'),(1821,2,1,'bcabcabcabca','acbacbacbacb'),(1822,2,1,'bcabcabcabca','acbacbacbacb'),(1823,2,1,'bcabcabcabca','acbacbacbacb'),(1824,2,1,'bcabcabcabca','acbacbacbacb'),(1825,2,1,'bcabcabcabca','acbacbacbacb'),(1826,2,1,'bcabcabcabca','acbacbacbacb'),(1827,2,1,'bcabcabcabca','acbacbacbacb'),(1828,2,1,'bcabcabcabca','acbacbacbacb'),(1829,2,1,'bcabcabcabca','acbacbacbacb'),(1830,2,1,'bcabcabcabca','acbacbacbacb'),(1831,2,1,'bcabcabcabca','acbacbacbacb'),(1832,2,1,'bcabcabcabca','acbacbacbacb'),(1833,2,1,'bcabcabcabca','acbacbacbacb'),(1834,2,1,'bcabcabcabca','acbacbacbacb'),(1835,2,1,'bcabcabcabca','acbacbacbacb'),(1836,2,1,'bcabcabcabca','acbacbacbacb'),(1837,2,1,'bcabcabcabca','acbacbacbacb'),(1838,2,1,'bcabcabcabca','acbacbacbacb'),(1839,2,1,'bcabcabcabca','acbacbacbacb'),(1840,2,1,'bcabcabcabca','acbacbacbacb'),(1841,2,1,'bcabcabcabca','acbacbacbacb'),(1842,2,1,'bcabcabcabca','acbacbacbacb'),(1843,2,1,'bcabcabcabca','acbacbacbacb'),(1844,2,1,'bcabcabcabca','acbacbacbacb'),(1845,2,1,'bcabcabcabca','acbacbacbacb'),(1846,2,1,'bcabcabcabca','acbacbacbacb'),(1847,2,1,'bcabcabcabca','acbacbacbacb'),(1848,2,1,'bcabcabcabca','acbacbacbacb'),(1849,2,1,'bcabcabcabca','acbacbacbacb'),(1850,2,1,'bcabcabcabca','acbacbacbacb'),(1851,2,1,'bcabcabcabca','acbacbacbacb'),(1852,2,1,'bcabcabcabca','acbacbacbacb'),(1853,2,1,'bcabcabcabca','acbacbacbacb'),(1854,2,1,'bcabcabcabca','acbacbacbacb'),(1855,2,1,'bcabcabcabca','acbacbacbacb'),(1856,2,1,'bcabcabcabca','acbacbacbacb'),(1857,2,1,'bcabcabcabca','acbacbacbacb'),(1858,2,1,'bcabcabcabca','acbacbacbacb'),(1859,2,1,'bcabcabcabca','acbacbacbacb'),(1860,2,1,'bcabcabcabca','acbacbacbacb'),(1861,2,1,'bcabcabcabca','acbacbacbacb'),(1862,2,1,'bcabcabcabca','acbacbacbacb'),(1863,2,1,'bcabcabcabca','acbacbacbacb'),(1864,2,1,'bcabcabcabca','acbacbacbacb'),(1865,2,1,'bcabcabcabca','acbacbacbacb'),(1866,2,1,'bcabcabcabca','acbacbacbacb'),(1867,2,1,'bcabcabcabca','acbacbacbacb'),(1868,2,1,'bcabcabcabca','acbacbacbacb'),(1869,2,1,'bcabcabcabca','acbacbacbacb'),(1870,2,1,'bcabcabcabca','acbacbacbacb'),(1871,2,1,'bcabcabcabca','acbacbacbacb'),(1872,2,1,'bcabcabcabca','acbacbacbacb'),(1873,2,1,'bcabcabcabca','acbacbacbacb'),(1874,2,1,'bcabcabcabca','acbacbacbacb'),(1875,2,1,'bcabcabcabca','acbacbacbacb'),(1876,2,1,'bcabcabcabca','acbacbacbacb'),(1877,2,1,'bcabcabcabca','acbacbacbacb'),(1878,2,1,'bcabcabcabca','acbacbacbacb'),(1879,2,1,'bcabcabcabca','acbacbacbacb'),(1880,2,1,'bcabcabcabca','acbacbacbacb'),(1881,2,1,'bcabcabcabca','acbacbacbacb'),(1882,2,1,'bcabcabcabca','acbacbacbacb'),(1883,2,1,'bcabcabcabca','acbacbacbacb'),(1884,2,1,'bcabcabcabca','acbacbacbacb'),(1885,2,1,'bcabcabcabca','acbacbacbacb'),(1886,2,1,'bcabcabcabca','acbacbacbacb'),(1887,2,1,'bcabcabcabca','acbacbacbacb'),(1888,2,1,'bcabcabcabca','acbacbacbacb'),(1889,2,1,'bcabcabcabca','acbacbacbacb'),(1890,2,1,'bcabcabcabca','acbacbacbacb'),(1891,2,1,'bcabcabcabca','acbacbacbacb'),(1892,2,1,'bcabcabcabca','acbacbacbacb'),(1893,2,1,'bcabcabcabca','acbacbacbacb'),(1894,2,1,'bcabcabcabca','acbacbacbacb'),(1895,2,1,'bcabcabcabca','acbacbacbacb'),(1896,2,1,'bcabcabcabca','acbacbacbacb'),(1897,2,1,'bcabcabcabca','acbacbacbacb'),(1898,2,1,'bcabcabcabca','acbacbacbacb'),(1899,2,1,'bcabcabcabca','acbacbacbacb'),(1900,2,1,'bcabcabcabca','acbacbacbacb'),(1901,2,1,'bcabcabcabca','acbacbacbacb'),(1902,2,1,'bcabcabcabca','acbacbacbacb'),(1903,2,1,'bcabcabcabca','acbacbacbacb'),(1904,2,1,'bcabcabcabca','acbacbacbacb'),(1905,2,1,'bcabcabcabca','acbacbacbacb'),(1906,2,1,'bcabcabcabca','acbacbacbacb'),(1907,2,1,'bcabcabcabca','acbacbacbacb'),(1908,2,1,'bcabcabcabca','acbacbacbacb'),(1909,2,1,'bcabcabcabca','acbacbacbacb'),(1910,2,1,'bcabcabcabca','acbacbacbacb'),(1911,2,1,'bcabcabcabca','acbacbacbacb'),(1912,2,1,'bcabcabcabca','acbacbacbacb'),(1913,2,1,'bcabcabcabca','acbacbacbacb'),(1914,2,1,'bcabcabcabca','acbacbacbacb'),(1915,2,1,'bcabcabcabca','acbacbacbacb'),(1916,2,1,'bcabcabcabca','acbacbacbacb'),(1917,2,1,'bcabcabcabca','acbacbacbacb'),(1918,2,1,'bcabcabcabca','acbacbacbacb'),(1919,2,1,'bcabcabcabca','acbacbacbacb'),(1920,2,1,'bcabcabcabca','acbacbacbacb'),(1921,2,1,'bcabcabcabca','acbacbacbacb'),(1922,2,1,'bcabcabcabca','acbacbacbacb'),(1923,2,1,'bcabcabcabca','acbacbacbacb'),(1924,2,1,'bcabcabcabca','acbacbacbacb'),(1925,2,1,'bcabcabcabca','acbacbacbacb'),(1926,2,1,'bcabcabcabca','acbacbacbacb'),(1927,2,1,'bcabcabcabca','acbacbacbacb'),(1928,2,1,'bcabcabcabca','acbacbacbacb'),(1929,2,1,'bcabcabcabca','acbacbacbacb'),(1930,2,1,'bcabcabcabca','acbacbacbacb'),(1931,2,1,'bcabcabcabca','acbacbacbacb'),(1932,2,1,'bcabcabcabca','acbacbacbacb'),(1933,2,1,'bcabcabcabca','acbacbacbacb'),(1934,2,1,'bcabcabcabca','acbacbacbacb'),(1935,2,1,'bcabcabcabca','acbacbacbacb'),(1936,2,1,'bcabcabcabca','acbacbacbacb'),(1937,2,1,'bcabcabcabca','acbacbacbacb'),(1938,2,1,'bcabcabcabca','acbacbacbacb'),(1939,2,1,'bcabcabcabca','acbacbacbacb'),(1940,2,1,'bcabcabcabca','acbacbacbacb'),(1941,2,1,'bcabcabcabca','acbacbacbacb'),(1942,2,1,'bcabcabcabca','acbacbacbacb'),(1943,2,1,'bcabcabcabca','acbacbacbacb'),(1944,2,1,'bcabcabcabca','acbacbacbacb'),(1945,2,1,'bcabcabcabca','acbacbacbacb'),(1946,2,1,'bcabcabcabca','acbacbacbacb'),(1947,2,1,'bcabcabcabca','acbacbacbacb'),(1948,2,1,'bcabcabcabca','acbacbacbacb'),(1949,2,1,'bcabcabcabca','acbacbacbacb'),(1950,2,1,'bcabcabcabca','acbacbacbacb'),(1951,2,1,'bcabcabcabca','acbacbacbacb'),(1952,2,1,'bcabcabcabca','acbacbacbacb'),(1953,2,1,'bcabcabcabca','acbacbacbacb'),(1954,2,1,'bcabcabcabca','acbacbacbacb'),(1955,2,1,'bcabcabcabca','acbacbacbacb'),(1956,2,1,'bcabcabcabca','acbacbacbacb'),(1957,2,1,'bcabcabcabca','acbacbacbacb'),(1958,2,1,'bcabcabcabca','acbacbacbacb'),(1959,2,1,'bcabcabcabca','acbacbacbacb'),(1960,2,1,'bcabcabcabca','acbacbacbacb'),(1961,2,1,'bcabcabcabca','acbacbacbacb'),(1962,2,1,'bcabcabcabca','acbacbacbacb'),(1963,2,1,'bcabcabcabca','acbacbacbacb'),(1964,2,1,'bcabcabcabca','acbacbacbacb'),(1965,2,1,'bcabcabcabca','acbacbacbacb'),(1966,2,1,'bcabcabcabca','acbacbacbacb'),(1967,2,1,'bcabcabcabca','acbacbacbacb'),(1968,2,1,'bcabcabcabca','acbacbacbacb'),(1969,2,1,'bcabcabcabca','acbacbacbacb'),(1970,2,1,'bcabcabcabca','acbacbacbacb'),(1971,2,1,'bcabcabcabca','acbacbacbacb'),(1972,2,1,'bcabcabcabca','acbacbacbacb'),(1973,2,1,'bcabcabcabca','acbacbacbacb'),(1974,2,1,'bcabcabcabca','acbacbacbacb'),(1975,2,1,'bcabcabcabca','acbacbacbacb'),(1976,2,1,'bcabcabcabca','acbacbacbacb'),(1977,2,1,'bcabcabcabca','acbacbacbacb'),(1978,2,1,'bcabcabcabca','acbacbacbacb'),(1979,2,1,'bcabcabcabca','acbacbacbacb'),(1980,2,1,'bcabcabcabca','acbacbacbacb'),(1981,2,1,'bcabcabcabca','acbacbacbacb'),(1982,2,1,'bcabcabcabca','acbacbacbacb'),(1983,2,1,'bcabcabcabca','acbacbacbacb'),(1984,2,1,'bcabcabcabca','acbacbacbacb'),(1985,2,1,'bcabcabcabca','acbacbacbacb'),(1986,2,1,'bcabcabcabca','acbacbacbacb'),(1987,2,1,'bcabcabcabca','acbacbacbacb'),(1988,2,1,'bcabcabcabca','acbacbacbacb'),(1989,2,1,'bcabcabcabca','acbacbacbacb'),(1990,2,1,'bcabcabcabca','acbacbacbacb'),(1991,2,1,'bcabcabcabca','acbacbacbacb'),(1992,2,1,'bcabcabcabca','acbacbacbacb'),(1993,2,1,'bcabcabcabca','acbacbacbacb'),(1994,2,1,'bcabcabcabca','acbacbacbacb'),(1995,2,1,'bcabcabcabca','acbacbacbacb'),(1996,2,1,'bcabcabcabca','acbacbacbacb'),(1997,2,1,'bcabcabcabca','acbacbacbacb'),(1998,2,1,'bcabcabcabca','acbacbacbacb'),(1999,2,1,'bcabcabcabca','acbacbacbacb'),(2000,2,1,'bcabcabcabca','acbacbacbacb'),(2001,2,1,'bcabcabcabca','acbacbacbacb'),(2002,2,1,'bcabcabcabca','acbacbacbacb'),(2003,2,1,'bcabcabcabca','acbacbacbacb'),(2004,2,1,'bcabcabcabca','acbacbacbacb'),(2005,2,1,'bcabcabcabca','acbacbacbacb'),(2006,2,1,'bcabcabcabca','acbacbacbacb'),(2007,2,1,'bcabcabcabca','acbacbacbacb'),(2008,2,1,'bcabcabcabca','acbacbacbacb'),(2009,2,1,'bcabcabcabca','acbacbacbacb'),(2010,2,1,'bcabcabcabca','acbacbacbacb'),(2011,2,1,'bcabcabcabca','acbacbacbacb'),(2012,2,1,'bcabcabcabca','acbacbacbacb'),(2013,2,1,'bcabcabcabca','acbacbacbacb'),(2014,2,1,'bcabcabcabca','acbacbacbacb'),(2015,2,1,'bcabcabcabca','acbacbacbacb'),(2016,2,1,'bcabcabcabca','acbacbacbacb'),(2017,2,1,'bcabcabcabca','acbacbacbacb'),(2018,2,1,'bcabcabcabca','acbacbacbacb'),(2019,2,1,'bcabcabcabca','acbacbacbacb'),(2020,2,1,'bcabcabcabca','acbacbacbacb'),(2021,2,1,'bcabcabcabca','acbacbacbacb'),(2022,2,1,'bcabcabcabca','acbacbacbacb'),(2023,2,1,'bcabcabcabca','acbacbacbacb'),(2024,2,1,'bcabcabcabca','acbacbacbacb'),(2025,2,1,'bcabcabcabca','acbacbacbacb'),(2026,2,1,'bcabcabcabca','acbacbacbacb'),(2027,2,1,'bcabcabcabca','acbacbacbacb'),(2028,2,1,'bcabcabcabca','acbacbacbacb'),(2029,2,1,'bcabcabcabca','acbacbacbacb'),(2030,2,1,'bcabcabcabca','acbacbacbacb'),(2031,2,1,'bcabcabcabca','acbacbacbacb'),(2032,2,1,'bcabcabcabca','acbacbacbacb'),(2033,2,1,'bcabcabcabca','acbacbacbacb'),(2034,2,1,'bcabcabcabca','acbacbacbacb'),(2035,2,1,'bcabcabcabca','acbacbacbacb'),(2036,2,1,'bcabcabcabca','acbacbacbacb'),(2037,2,1,'bcabcabcabca','acbacbacbacb'),(2038,2,1,'bcabcabcabca','acbacbacbacb'),(2039,2,3,'bcabcabcabca','acbacbacbacb'),(2040,2,3,'bcabcabcabca','acbacbacbacb'),(2041,2,3,'bcabcabcabca','acbacbacbacb'),(2042,2,3,'bcabcabcabca','acbacbacbacb'),(2043,2,3,'bcabcabcabca','acbacbacbacb'),(2044,2,3,'bcabcabcabca','acbacbacbacb'),(2045,2,3,'bcabcabcabca','acbacbacbacb'),(2046,2,3,'bcabcabcabca','acbacbacbacb'),(2047,2,3,'bcabcabcabca','acbacbacbacb'),(2048,2,3,'bcabcabcabca','acbacbacbacb'),(2049,2,3,'bcabcabcabca','acbacbacbacb'),(2050,2,3,'bcabcabcabca','acbacbacbacb'),(2051,2,3,'bcabcabcabca','acbacbacbacb'),(2052,2,3,'bcabcabcabca','acbacbacbacb'),(2053,2,3,'bcabcabcabca','acbacbacbacb'),(2054,2,3,'bcabcabcabca','acbacbacbacb'),(2055,2,3,'bcabcabcabca','acbacbacbacb'),(2056,2,3,'bcabcabcabca','acbacbacbacb'),(2057,2,3,'bcabcabcabca','acbacbacbacb'),(2058,2,3,'bcabcabcabca','acbacbacbacb'),(2059,2,3,'bcabcabcabca','acbacbacbacb'),(2060,2,3,'bcabcabcabca','acbacbacbacb'),(2061,2,3,'bcabcabcabca','acbacbacbacb'),(2062,2,3,'bcabcabcabca','acbacbacbacb'),(2063,2,3,'bcabcabcabca','acbacbacbacb'),(2064,2,3,'bcabcabcabca','acbacbacbacb'),(2065,2,3,'bcabcabcabca','acbacbacbacb'),(2066,2,3,'bcabcabcabca','acbacbacbacb'),(2067,2,3,'bcabcabcabca','acbacbacbacb'),(2068,2,3,'bcabcabcabca','acbacbacbacb'),(2069,2,3,'bcabcabcabca','acbacbacbacb'),(2070,2,3,'bcabcabcabca','acbacbacbacb'),(2071,2,3,'bcabcabcabca','acbacbacbacb'),(2072,2,3,'bcabcabcabca','acbacbacbacb'),(2073,2,3,'bcabcabcabca','acbacbacbacb'),(2074,2,3,'bcabcabcabca','acbacbacbacb'),(2075,2,3,'bcabcabcabca','acbacbacbacb'),(2076,2,3,'bcabcabcabca','acbacbacbacb'),(2077,2,3,'bcabcabcabca','acbacbacbacb'),(2078,2,3,'bcabcabcabca','acbacbacbacb'),(2079,2,3,'bcabcabcabca','acbacbacbacb'),(2080,2,3,'bcabcabcabca','acbacbacbacb'),(2081,2,3,'bcabcabcabca','acbacbacbacb'),(2082,2,3,'bcabcabcabca','acbacbacbacb'),(2083,2,3,'bcabcabcabca','acbacbacbacb'),(2084,2,3,'bcabcabcabca','acbacbacbacb'),(2085,2,3,'bcabcabcabca','acbacbacbacb'),(2086,2,3,'bcabcabcabca','acbacbacbacb'),(2087,2,3,'bcabcabcabca','acbacbacbacb'),(2088,2,3,'bcabcabcabca','acbacbacbacb'),(2089,2,3,'bcabcabcabca','acbacbacbacb'),(2090,2,3,'bcabcabcabca','acbacbacbacb'),(2091,2,3,'bcabcabcabca','acbacbacbacb'),(2092,2,3,'bcabcabcabca','acbacbacbacb'),(2093,2,3,'bcabcabcabca','acbacbacbacb'),(2094,2,3,'bcabcabcabca','acbacbacbacb'),(2095,2,3,'bcabcabcabca','acbacbacbacb'),(2096,2,3,'bcabcabcabca','acbacbacbacb'),(2097,2,3,'bcabcabcabca','acbacbacbacb'),(2098,2,3,'bcabcabcabca','acbacbacbacb'),(2099,2,3,'bcabcabcabca','acbacbacbacb'),(2100,2,3,'bcabcabcabca','acbacbacbacb'),(2101,2,3,'bcabcabcabca','acbacbacbacb'),(2102,2,3,'bcabcabcabca','acbacbacbacb'),(2103,2,3,'bcabcabcabca','acbacbacbacb'),(2104,2,3,'bcabcabcabca','acbacbacbacb'),(2105,2,3,'bcabcabcabca','acbacbacbacb'),(2106,2,3,'bcabcabcabca','acbacbacbacb'),(2107,2,3,'bcabcabcabca','acbacbacbacb'),(2108,2,3,'bcabcabcabca','acbacbacbacb'),(2109,2,3,'bcabcabcabca','acbacbacbacb'),(2110,2,3,'bcabcabcabca','acbacbacbacb'),(2111,2,3,'bcabcabcabca','acbacbacbacb'),(2112,2,3,'bcabcabcabca','acbacbacbacb'),(2113,2,3,'bcabcabcabca','acbacbacbacb'),(2114,2,3,'bcabcabcabca','acbacbacbacb'),(2115,2,3,'bcabcabcabca','acbacbacbacb'),(2116,2,3,'bcabcabcabca','acbacbacbacb'),(2117,2,3,'bcabcabcabca','acbacbacbacb'),(2118,2,3,'bcabcabcabca','acbacbacbacb'),(2119,2,3,'bcabcabcabca','acbacbacbacb'),(2120,2,3,'bcabcabcabca','acbacbacbacb'),(2121,2,3,'bcabcabcabca','acbacbacbacb'),(2122,2,3,'bcabcabcabca','acbacbacbacb'),(2123,2,3,'bcabcabcabca','acbacbacbacb'),(2124,2,3,'bcabcabcabca','acbacbacbacb'),(2125,2,3,'bcabcabcabca','acbacbacbacb'),(2126,2,3,'bcabcabcabca','acbacbacbacb'),(2127,2,3,'bcabcabcabca','acbacbacbacb'),(2128,2,3,'bcabcabcabca','acbacbacbacb'),(2129,2,3,'bcabcabcabca','acbacbacbacb'),(2130,2,3,'bcabcabcabca','acbacbacbacb'),(2131,2,3,'bcabcabcabca','acbacbacbacb'),(2132,2,3,'bcabcabcabca','acbacbacbacb'),(2133,2,3,'bcabcabcabca','acbacbacbacb'),(2134,2,3,'bcabcabcabca','acbacbacbacb'),(2135,2,3,'bcabcabcabca','acbacbacbacb'),(2136,2,3,'bcabcabcabca','acbacbacbacb'),(2137,2,3,'bcabcabcabca','acbacbacbacb'),(2138,2,3,'bcabcabcabca','acbacbacbacb'),(2139,2,3,'bcabcabcabca','acbacbacbacb'),(2140,2,3,'bcabcabcabca','acbacbacbacb'),(2141,2,3,'bcabcabcabca','acbacbacbacb'),(2142,2,3,'bcabcabcabca','acbacbacbacb'),(2143,2,3,'bcabcabcabca','acbacbacbacb'),(2144,2,3,'bcabcabcabca','acbacbacbacb'),(2145,2,3,'bcabcabcabca','acbacbacbacb'),(2146,2,3,'bcabcabcabca','acbacbacbacb'),(2147,2,3,'bcabcabcabca','acbacbacbacb'),(2148,2,3,'bcabcabcabca','acbacbacbacb'),(2149,2,3,'bcabcabcabca','acbacbacbacb'),(2150,2,3,'bcabcabcabca','acbacbacbacb'),(2151,2,3,'bcabcabcabca','acbacbacbacb'),(2152,2,3,'bcabcabcabca','acbacbacbacb'),(2153,2,3,'bcabcabcabca','acbacbacbacb'),(2154,2,3,'bcabcabcabca','acbacbacbacb'),(2155,2,3,'bcabcabcabca','acbacbacbacb'),(2156,2,3,'bcabcabcabca','acbacbacbacb'),(2157,2,3,'bcabcabcabca','acbacbacbacb'),(2158,2,3,'bcabcabcabca','acbacbacbacb'),(2159,2,3,'bcabcabcabca','acbacbacbacb'),(2160,2,3,'bcabcabcabca','acbacbacbacb'),(2161,2,3,'bcabcabcabca','acbacbacbacb'),(2162,2,3,'bcabcabcabca','acbacbacbacb'),(2163,2,3,'bcabcabcabca','acbacbacbacb'),(2164,2,3,'bcabcabcabca','acbacbacbacb'),(2165,2,3,'bcabcabcabca','acbacbacbacb'),(2166,2,3,'bcabcabcabca','acbacbacbacb'),(2167,2,3,'bcabcabcabca','acbacbacbacb'),(2168,2,3,'bcabcabcabca','acbacbacbacb'),(2169,2,3,'bcabcabcabca','acbacbacbacb'),(2170,2,3,'bcabcabcabca','acbacbacbacb'),(2171,2,3,'bcabcabcabca','acbacbacbacb'),(2172,2,3,'bcabcabcabca','acbacbacbacb'),(2173,2,3,'bcabcabcabca','acbacbacbacb'),(2174,2,3,'bcabcabcabca','acbacbacbacb'),(2175,2,3,'bcabcabcabca','acbacbacbacb'),(2176,2,3,'bcabcabcabca','acbacbacbacb'),(2177,2,3,'bcabcabcabca','acbacbacbacb'),(2178,2,3,'bcabcabcabca','acbacbacbacb'),(2179,2,3,'bcabcabcabca','acbacbacbacb'),(2180,2,3,'bcabcabcabca','acbacbacbacb'),(2181,2,3,'bcabcabcabca','acbacbacbacb'),(2182,2,3,'bcabcabcabca','acbacbacbacb'),(2183,2,3,'bcabcabcabca','acbacbacbacb'),(2184,2,3,'bcabcabcabca','acbacbacbacb'),(2185,2,3,'bcabcabcabca','acbacbacbacb'),(2186,2,3,'bcabcabcabca','acbacbacbacb'),(2187,2,3,'bcabcabcabca','acbacbacbacb'),(2188,2,3,'bcabcabcabca','acbacbacbacb'),(2189,2,3,'bcabcabcabca','acbacbacbacb'),(2190,2,3,'bcabcabcabca','acbacbacbacb'),(2191,2,3,'bcabcabcabca','acbacbacbacb'),(2192,2,3,'bcabcabcabca','acbacbacbacb'),(2193,2,3,'bcabcabcabca','acbacbacbacb'),(2194,2,3,'bcabcabcabca','acbacbacbacb'),(2195,2,3,'bcabcabcabca','acbacbacbacb'),(2196,2,3,'bcabcabcabca','acbacbacbacb'),(2197,2,3,'bcabcabcabca','acbacbacbacb'),(2198,2,3,'bcabcabcabca','acbacbacbacb'),(2199,2,3,'bcabcabcabca','acbacbacbacb'),(2200,2,3,'bcabcabcabca','acbacbacbacb'),(2201,2,3,'bcabcabcabca','acbacbacbacb'),(2202,2,3,'bcabcabcabca','acbacbacbacb'),(2203,2,3,'bcabcabcabca','acbacbacbacb'),(2204,2,3,'bcabcabcabca','acbacbacbacb'),(2205,2,3,'bcabcabcabca','acbacbacbacb'),(2206,2,3,'bcabcabcabca','acbacbacbacb'),(2207,2,3,'bcabcabcabca','acbacbacbacb'),(2208,2,3,'bcabcabcabca','acbacbacbacb'),(2209,2,3,'bcabcabcabca','acbacbacbacb'),(2210,2,3,'bcabcabcabca','acbacbacbacb'),(2211,2,3,'bcabcabcabca','acbacbacbacb'),(2212,2,3,'bcabcabcabca','acbacbacbacb'),(2213,2,3,'bcabcabcabca','acbacbacbacb'),(2214,2,3,'bcabcabcabca','acbacbacbacb'),(2215,2,3,'bcabcabcabca','acbacbacbacb'),(2216,2,3,'bcabcabcabca','acbacbacbacb'),(2217,2,3,'bcabcabcabca','acbacbacbacb'),(2218,2,3,'bcabcabcabca','acbacbacbacb'),(2219,2,3,'bcabcabcabca','acbacbacbacb'),(2220,2,3,'bcabcabcabca','acbacbacbacb'),(2221,2,3,'bcabcabcabca','acbacbacbacb'),(2222,2,3,'bcabcabcabca','acbacbacbacb'),(2223,2,3,'bcabcabcabca','acbacbacbacb'),(2224,2,3,'bcabcabcabca','acbacbacbacb'),(2225,2,3,'bcabcabcabca','acbacbacbacb'),(2226,2,3,'bcabcabcabca','acbacbacbacb'),(2227,2,3,'bcabcabcabca','acbacbacbacb'),(2228,2,3,'bcabcabcabca','acbacbacbacb'),(2229,2,3,'bcabcabcabca','acbacbacbacb'),(2230,2,3,'bcabcabcabca','acbacbacbacb'),(2231,2,3,'bcabcabcabca','acbacbacbacb'),(2232,2,3,'bcabcabcabca','acbacbacbacb'),(2233,2,3,'bcabcabcabca','acbacbacbacb'),(2234,2,3,'bcabcabcabca','acbacbacbacb'),(2235,2,3,'bcabcabcabca','acbacbacbacb'),(2236,2,3,'bcabcabcabca','acbacbacbacb'),(2237,2,3,'bcabcabcabca','acbacbacbacb'),(2238,2,3,'bcabcabcabca','acbacbacbacb'),(2239,2,3,'bcabcabcabca','acbacbacbacb'),(2240,2,3,'bcabcabcabca','acbacbacbacb'),(2241,2,3,'bcabcabcabca','acbacbacbacb'),(2242,2,3,'bcabcabcabca','acbacbacbacb'),(2243,2,3,'bcabcabcabca','acbacbacbacb'),(2244,2,3,'bcabcabcabca','acbacbacbacb'),(2245,2,3,'bcabcabcabca','acbacbacbacb'),(2246,2,3,'bcabcabcabca','acbacbacbacb'),(2247,2,3,'bcabcabcabca','acbacbacbacb'),(2248,2,3,'bcabcabcabca','acbacbacbacb'),(2249,2,3,'bcabcabcabca','acbacbacbacb'),(2250,2,3,'bcabcabcabca','acbacbacbacb'),(2251,2,3,'bcabcabcabca','acbacbacbacb'),(2252,2,3,'bcabcabcabca','acbacbacbacb'),(2253,2,3,'bcabcabcabca','acbacbacbacb'),(2254,2,3,'bcabcabcabca','acbacbacbacb'),(2255,2,3,'bcabcabcabca','acbacbacbacb'),(2256,2,3,'bcabcabcabca','acbacbacbacb'),(2257,2,3,'bcabcabcabca','acbacbacbacb'),(2258,2,3,'bcabcabcabca','acbacbacbacb'),(2259,2,3,'bcabcabcabca','acbacbacbacb'),(2260,2,3,'bcabcabcabca','acbacbacbacb'),(2261,2,3,'bcabcabcabca','acbacbacbacb'),(2262,2,3,'bcabcabcabca','acbacbacbacb'),(2263,2,3,'bcabcabcabca','acbacbacbacb'),(2264,2,3,'bcabcabcabca','acbacbacbacb'),(2265,2,3,'bcabcabcabca','acbacbacbacb'),(2266,2,3,'bcabcabcabca','acbacbacbacb'),(2267,2,3,'bcabcabcabca','acbacbacbacb'),(2268,2,3,'bcabcabcabca','acbacbacbacb'),(2269,2,3,'bcabcabcabca','acbacbacbacb'),(2270,2,3,'bcabcabcabca','acbacbacbacb'),(2271,2,3,'bcabcabcabca','acbacbacbacb'),(2272,2,3,'bcabcabcabca','acbacbacbacb'),(2273,2,3,'bcabcabcabca','acbacbacbacb'),(2274,2,3,'bcabcabcabca','acbacbacbacb'),(2275,2,3,'bcabcabcabca','acbacbacbacb'),(2276,2,3,'bcabcabcabca','acbacbacbacb'),(2277,2,3,'bcabcabcabca','acbacbacbacb'),(2278,2,3,'bcabcabcabca','acbacbacbacb'),(2279,2,3,'bcabcabcabca','acbacbacbacb'),(2280,2,3,'bcabcabcabca','acbacbacbacb'),(2281,2,3,'bcabcabcabca','acbacbacbacb'),(2282,2,3,'bcabcabcabca','acbacbacbacb'),(2283,2,3,'bcabcabcabca','acbacbacbacb'),(2284,2,3,'bcabcabcabca','acbacbacbacb'),(2285,2,3,'bcabcabcabca','acbacbacbacb'),(2286,2,3,'bcabcabcabca','acbacbacbacb'),(2287,2,3,'bcabcabcabca','acbacbacbacb'),(2288,2,3,'bcabcabcabca','acbacbacbacb'),(2289,2,3,'bcabcabcabca','acbacbacbacb'),(2290,2,3,'bcabcabcabca','acbacbacbacb'),(2291,2,3,'bcabcabcabca','acbacbacbacb'),(2292,2,3,'bcabcabcabca','acbacbacbacb'),(2293,2,3,'bcabcabcabca','acbacbacbacb'),(2294,2,3,'bcabcabcabca','acbacbacbacb'),(2295,2,3,'bcabcabcabca','acbacbacbacb'),(2296,2,3,'bcabcabcabca','acbacbacbacb'),(2297,2,3,'bcabcabcabca','acbacbacbacb'),(2298,2,3,'bcabcabcabca','acbacbacbacb'),(2299,2,3,'bcabcabcabca','acbacbacbacb'),(2300,2,3,'bcabcabcabca','acbacbacbacb'),(2301,2,3,'bcabcabcabca','acbacbacbacb'),(2302,2,3,'bcabcabcabca','acbacbacbacb'),(2303,2,3,'bcabcabcabca','acbacbacbacb'),(2304,2,3,'bcabcabcabca','acbacbacbacb'),(2305,2,3,'bcabcabcabca','acbacbacbacb'),(2306,2,3,'bcabcabcabca','acbacbacbacb'),(2307,2,3,'bcabcabcabca','acbacbacbacb'),(2308,2,3,'bcabcabcabca','acbacbacbacb'),(2309,2,3,'bcabcabcabca','acbacbacbacb'),(2310,2,3,'bcabcabcabca','acbacbacbacb'),(2311,2,3,'bcabcabcabca','acbacbacbacb'),(2312,2,3,'bcabcabcabca','acbacbacbacb'),(2313,2,3,'bcabcabcabca','acbacbacbacb'),(2314,2,3,'bcabcabcabca','acbacbacbacb'),(2315,2,3,'bcabcabcabca','acbacbacbacb'),(2316,2,3,'bcabcabcabca','acbacbacbacb'),(2317,2,3,'bcabcabcabca','acbacbacbacb'),(2318,2,3,'bcabcabcabca','acbacbacbacb'),(2319,2,3,'bcabcabcabca','acbacbacbacb'),(2320,2,3,'bcabcabcabca','acbacbacbacb'),(2321,2,3,'bcabcabcabca','acbacbacbacb'),(2322,2,3,'bcabcabcabca','acbacbacbacb'),(2323,2,3,'bcabcabcabca','acbacbacbacb'),(2324,2,3,'bcabcabcabca','acbacbacbacb'),(2325,2,3,'bcabcabcabca','acbacbacbacb'),(2326,2,3,'bcabcabcabca','acbacbacbacb'),(2327,2,3,'bcabcabcabca','acbacbacbacb'),(2328,2,3,'bcabcabcabca','acbacbacbacb'),(2329,2,3,'bcabcabcabca','acbacbacbacb'),(2330,2,3,'bcabcabcabca','acbacbacbacb'),(2331,2,3,'bcabcabcabca','acbacbacbacb'),(2332,2,3,'bcabcabcabca','acbacbacbacb'),(2333,2,3,'bcabcabcabca','acbacbacbacb'),(2334,2,3,'bcabcabcabca','acbacbacbacb'),(2335,2,3,'bcabcabcabca','acbacbacbacb'),(2336,2,3,'bcabcabcabca','acbacbacbacb'),(2337,2,3,'bcabcabcabca','acbacbacbacb'),(2338,2,3,'bcabcabcabca','acbacbacbacb'),(2339,2,3,'bcabcabcabca','acbacbacbacb'),(2340,2,3,'bcabcabcabca','acbacbacbacb'),(2341,2,3,'bcabcabcabca','acbacbacbacb'),(2342,2,3,'bcabcabcabca','acbacbacbacb'),(2343,2,3,'bcabcabcabca','acbacbacbacb'),(2344,2,3,'bcabcabcabca','acbacbacbacb'),(2345,2,3,'bcabcabcabca','acbacbacbacb'),(2346,2,3,'bcabcabcabca','acbacbacbacb'),(2347,2,3,'bcabcabcabca','acbacbacbacb'),(2348,2,3,'bcabcabcabca','acbacbacbacb'),(2349,2,3,'bcabcabcabca','acbacbacbacb'),(2350,2,3,'bcabcabcabca','acbacbacbacb'),(2351,2,3,'bcabcabcabca','acbacbacbacb'),(2352,2,3,'bcabcabcabca','acbacbacbacb'),(2353,2,3,'bcabcabcabca','acbacbacbacb'),(2354,2,3,'bcabcabcabca','acbacbacbacb'),(2355,2,3,'bcabcabcabca','acbacbacbacb'),(2356,2,3,'bcabcabcabca','acbacbacbacb'),(2357,2,3,'bcabcabcabca','acbacbacbacb'),(2358,2,3,'bcabcabcabca','acbacbacbacb'),(2359,2,3,'bcabcabcabca','acbacbacbacb'),(2360,2,3,'bcabcabcabca','acbacbacbacb'),(2361,2,3,'bcabcabcabca','acbacbacbacb'),(2362,2,3,'bcabcabcabca','acbacbacbacb'),(2363,2,3,'bcabcabcabca','acbacbacbacb'),(2364,2,3,'bcabcabcabca','acbacbacbacb'),(2365,2,3,'bcabcabcabca','acbacbacbacb'),(2366,2,3,'bcabcabcabca','acbacbacbacb'),(2367,2,3,'bcabcabcabca','acbacbacbacb'),(2368,2,3,'bcabcabcabca','acbacbacbacb'),(2369,2,3,'bcabcabcabca','acbacbacbacb'),(2370,2,3,'bcabcabcabca','acbacbacbacb'),(2371,2,3,'bcabcabcabca','acbacbacbacb'),(2372,2,3,'bcabcabcabca','acbacbacbacb'),(2373,2,3,'bcabcabcabca','acbacbacbacb'),(2374,2,3,'bcabcabcabca','acbacbacbacb'),(2375,2,3,'bcabcabcabca','acbacbacbacb'),(2376,2,3,'bcabcabcabca','acbacbacbacb'),(2377,2,3,'bcabcabcabca','acbacbacbacb'),(2378,2,3,'bcabcabcabca','acbacbacbacb'),(2379,2,3,'bcabcabcabca','acbacbacbacb'),(2380,2,3,'bcabcabcabca','acbacbacbacb'),(2381,2,3,'bcabcabcabca','acbacbacbacb'),(2382,2,3,'bcabcabcabca','acbacbacbacb'),(2383,2,3,'bcabcabcabca','acbacbacbacb'),(2384,2,3,'bcabcabcabca','acbacbacbacb'),(2385,2,3,'bcabcabcabca','acbacbacbacb'),(2386,2,3,'bcabcabcabca','acbacbacbacb'),(2387,2,3,'bcabcabcabca','acbacbacbacb'),(2388,2,3,'bcabcabcabca','acbacbacbacb'),(2389,2,3,'bcabcabcabca','acbacbacbacb'),(2390,2,3,'bcabcabcabca','acbacbacbacb'),(2391,2,3,'bcabcabcabca','acbacbacbacb'),(2392,2,3,'bcabcabcabca','acbacbacbacb'),(2393,2,3,'bcabcabcabca','acbacbacbacb'),(2394,2,3,'bcabcabcabca','acbacbacbacb'),(2395,2,3,'bcabcabcabca','acbacbacbacb'),(2396,2,3,'bcabcabcabca','acbacbacbacb'),(2397,2,3,'bcabcabcabca','acbacbacbacb'),(2398,2,3,'bcabcabcabca','acbacbacbacb'),(2399,2,3,'bcabcabcabca','acbacbacbacb'),(2400,2,3,'bcabcabcabca','acbacbacbacb'),(2401,2,3,'bcabcabcabca','acbacbacbacb'),(2402,2,3,'bcabcabcabca','acbacbacbacb'),(2403,2,3,'bcabcabcabca','acbacbacbacb'),(2404,2,3,'bcabcabcabca','acbacbacbacb'),(2405,2,3,'bcabcabcabca','acbacbacbacb'),(2406,2,3,'bcabcabcabca','acbacbacbacb'),(2407,2,3,'bcabcabcabca','acbacbacbacb'),(2408,2,3,'bcabcabcabca','acbacbacbacb'),(2409,2,3,'bcabcabcabca','acbacbacbacb'),(2410,2,3,'bcabcabcabca','acbacbacbacb'),(2411,2,3,'bcabcabcabca','acbacbacbacb'),(2412,2,3,'bcabcabcabca','acbacbacbacb'),(2413,2,3,'bcabcabcabca','acbacbacbacb'),(2414,2,3,'bcabcabcabca','acbacbacbacb'),(2415,2,3,'bcabcabcabca','acbacbacbacb'),(2416,2,3,'bcabcabcabca','acbacbacbacb'),(2417,2,3,'bcabcabcabca','acbacbacbacb'),(2418,2,3,'bcabcabcabca','acbacbacbacb'),(2419,2,3,'bcabcabcabca','acbacbacbacb'),(2420,2,3,'bcabcabcabca','acbacbacbacb'),(2421,2,3,'bcabcabcabca','acbacbacbacb'),(2422,2,3,'bcabcabcabca','acbacbacbacb'),(2423,2,3,'bcabcabcabca','acbacbacbacb'),(2424,2,3,'bcabcabcabca','acbacbacbacb'),(2425,2,3,'bcabcabcabca','acbacbacbacb'),(2426,2,3,'bcabcabcabca','acbacbacbacb'),(2427,2,3,'bcabcabcabca','acbacbacbacb'),(2428,2,3,'bcabcabcabca','acbacbacbacb'),(2429,2,3,'bcabcabcabca','acbacbacbacb'),(2430,2,3,'bcabcabcabca','acbacbacbacb'),(2431,2,3,'bcabcabcabca','acbacbacbacb'),(2432,2,3,'bcabcabcabca','acbacbacbacb'),(2433,2,3,'bcabcabcabca','acbacbacbacb'),(2434,2,3,'bcabcabcabca','acbacbacbacb'),(2435,2,3,'bcabcabcabca','acbacbacbacb'),(2436,2,3,'bcabcabcabca','acbacbacbacb'),(2437,2,3,'bcabcabcabca','acbacbacbacb'),(2438,2,3,'bcabcabcabca','acbacbacbacb'),(2439,2,3,'bcabcabcabca','acbacbacbacb'),(2440,2,3,'bcabcabcabca','acbacbacbacb'),(2441,2,3,'bcabcabcabca','acbacbacbacb'),(2442,2,3,'bcabcabcabca','acbacbacbacb'),(2443,2,3,'bcabcabcabca','acbacbacbacb'),(2444,2,3,'bcabcabcabca','acbacbacbacb'),(2445,2,3,'bcabcabcabca','acbacbacbacb'),(2446,2,3,'bcabcabcabca','acbacbacbacb'),(2447,2,3,'bcabcabcabca','acbacbacbacb'),(2448,2,3,'bcabcabcabca','acbacbacbacb'),(2449,2,3,'bcabcabcabca','acbacbacbacb'),(2450,2,3,'bcabcabcabca','acbacbacbacb'),(2451,2,3,'bcabcabcabca','acbacbacbacb'),(2452,2,3,'bcabcabcabca','acbacbacbacb'),(2453,2,3,'bcabcabcabca','acbacbacbacb'),(2454,2,3,'bcabcabcabca','acbacbacbacb'),(2455,2,3,'bcabcabcabca','acbacbacbacb'),(2456,2,3,'bcabcabcabca','acbacbacbacb'),(2457,2,3,'bcabcabcabca','acbacbacbacb'),(2458,2,3,'bcabcabcabca','acbacbacbacb'),(2459,2,3,'bcabcabcabca','acbacbacbacb'),(2460,2,3,'bcabcabcabca','acbacbacbacb'),(2461,2,3,'bcabcabcabca','acbacbacbacb'),(2462,2,3,'bcabcabcabca','acbacbacbacb'),(2463,2,3,'bcabcabcabca','acbacbacbacb'),(2464,2,3,'bcabcabcabca','acbacbacbacb'),(2465,2,3,'bcabcabcabca','acbacbacbacb'),(2466,2,3,'bcabcabcabca','acbacbacbacb'),(2467,2,3,'bcabcabcabca','acbacbacbacb'),(2468,2,3,'bcabcabcabca','acbacbacbacb'),(2469,2,3,'bcabcabcabca','acbacbacbacb'),(2470,2,3,'bcabcabcabca','acbacbacbacb'),(2471,2,3,'bcabcabcabca','acbacbacbacb'),(2472,2,3,'bcabcabcabca','acbacbacbacb'),(2473,2,3,'bcabcabcabca','acbacbacbacb'),(2474,2,3,'bcabcabcabca','acbacbacbacb'),(2475,2,3,'bcabcabcabca','acbacbacbacb'),(2476,2,3,'bcabcabcabca','acbacbacbacb'),(2477,2,3,'bcabcabcabca','acbacbacbacb'),(2478,2,3,'bcabcabcabca','acbacbacbacb'),(2479,2,3,'bcabcabcabca','acbacbacbacb'),(2480,2,3,'bcabcabcabca','acbacbacbacb'),(2481,2,3,'bcabcabcabca','acbacbacbacb'),(2482,2,3,'bcabcabcabca','acbacbacbacb'),(2483,2,3,'bcabcabcabca','acbacbacbacb'),(2484,2,3,'bcabcabcabca','acbacbacbacb'),(2485,2,3,'bcabcabcabca','acbacbacbacb'),(2486,2,3,'bcabcabcabca','acbacbacbacb'),(2487,2,3,'bcabcabcabca','acbacbacbacb'),(2488,2,3,'bcabcabcabca','acbacbacbacb'),(2489,2,3,'bcabcabcabca','acbacbacbacb'),(2490,2,3,'bcabcabcabca','acbacbacbacb'),(2491,2,3,'bcabcabcabca','acbacbacbacb'),(2492,2,3,'bcabcabcabca','acbacbacbacb'),(2493,2,3,'bcabcabcabca','acbacbacbacb'),(2494,2,3,'bcabcabcabca','acbacbacbacb'),(2495,2,3,'bcabcabcabca','acbacbacbacb'),(2496,2,3,'bcabcabcabca','acbacbacbacb'),(2497,2,3,'bcabcabcabca','acbacbacbacb'),(2498,2,3,'bcabcabcabca','acbacbacbacb'),(2499,2,3,'bcabcabcabca','acbacbacbacb'),(2500,2,3,'bcabcabcabca','acbacbacbacb'),(2501,2,3,'bcabcabcabca','acbacbacbacb'),(2502,2,3,'bcabcabcabca','acbacbacbacb'),(2503,2,3,'bcabcabcabca','acbacbacbacb'),(2504,2,3,'bcabcabcabca','acbacbacbacb'),(2505,2,3,'bcabcabcabca','acbacbacbacb'),(2506,2,3,'bcabcabcabca','acbacbacbacb'),(2507,2,3,'bcabcabcabca','acbacbacbacb'),(2508,2,3,'bcabcabcabca','acbacbacbacb'),(2509,2,3,'bcabcabcabca','acbacbacbacb'),(2510,2,3,'bcabcabcabca','acbacbacbacb'),(2511,2,3,'bcabcabcabca','acbacbacbacb'),(2512,2,3,'bcabcabcabca','acbacbacbacb'),(2513,2,3,'bcabcabcabca','acbacbacbacb'),(2514,2,3,'bcabcabcabca','acbacbacbacb'),(2515,2,3,'bcabcabcabca','acbacbacbacb'),(2516,2,3,'bcabcabcabca','acbacbacbacb'),(2517,2,3,'bcabcabcabca','acbacbacbacb'),(2518,2,3,'bcabcabcabca','acbacbacbacb'),(2519,2,3,'bcabcabcabca','acbacbacbacb'),(2520,2,3,'bcabcabcabca','acbacbacbacb'),(2521,2,3,'bcabcabcabca','acbacbacbacb'),(2522,2,3,'bcabcabcabca','acbacbacbacb'),(2523,2,3,'bcabcabcabca','acbacbacbacb'),(2524,2,3,'bcabcabcabca','acbacbacbacb'),(2525,2,3,'bcabcabcabca','acbacbacbacb'),(2526,2,3,'bcabcabcabca','acbacbacbacb'),(2527,2,3,'bcabcabcabca','acbacbacbacb'),(2528,2,3,'bcabcabcabca','acbacbacbacb'),(2529,2,3,'bcabcabcabca','acbacbacbacb'),(2530,2,3,'bcabcabcabca','acbacbacbacb'),(2531,2,3,'bcabcabcabca','acbacbacbacb'),(2532,2,3,'bcabcabcabca','acbacbacbacb'),(2533,2,3,'bcabcabcabca','acbacbacbacb'),(2534,2,3,'bcabcabcabca','acbacbacbacb'),(2535,2,3,'bcabcabcabca','acbacbacbacb'),(2536,2,3,'bcabcabcabca','acbacbacbacb'),(2537,2,3,'bcabcabcabca','acbacbacbacb'),(2538,2,3,'bcabcabcabca','acbacbacbacb'),(2539,2,3,'bcabcabcabca','acbacbacbacb'),(2540,2,3,'bcabcabcabca','acbacbacbacb'),(2541,2,3,'bcabcabcabca','acbacbacbacb'),(2542,2,3,'bcabcabcabca','acbacbacbacb'),(2543,2,3,'bcabcabcabca','acbacbacbacb'),(2544,2,3,'bcabcabcabca','acbacbacbacb'),(2545,2,3,'bcabcabcabca','acbacbacbacb'),(2546,2,3,'bcabcabcabca','acbacbacbacb'),(2547,2,3,'bcabcabcabca','acbacbacbacb'),(2548,2,3,'bcabcabcabca','acbacbacbacb'),(2549,2,3,'bcabcabcabca','acbacbacbacb'),(2550,2,3,'bcabcabcabca','acbacbacbacb'),(2551,2,3,'bcabcabcabca','acbacbacbacb'),(2552,2,3,'bcabcabcabca','acbacbacbacb'),(2553,2,3,'bcabcabcabca','acbacbacbacb'),(2554,2,3,'bcabcabcabca','acbacbacbacb'),(2555,2,3,'bcabcabcabca','acbacbacbacb'),(2556,2,3,'bcabcabcabca','acbacbacbacb'),(2557,2,3,'bcabcabcabca','acbacbacbacb'),(2558,2,3,'bcabcabcabca','acbacbacbacb'),(2559,2,3,'bcabcabcabca','acbacbacbacb'),(2560,2,3,'bcabcabcabca','acbacbacbacb'),(2561,2,3,'bcabcabcabca','acbacbacbacb'),(2562,2,3,'bcabcabcabca','acbacbacbacb'),(2563,2,3,'bcabcabcabca','acbacbacbacb'),(2564,2,3,'bcabcabcabca','acbacbacbacb'),(2565,2,3,'bcabcabcabca','acbacbacbacb'),(2566,2,3,'bcabcabcabca','acbacbacbacb'),(2567,2,3,'bcabcabcabca','acbacbacbacb'),(2568,2,3,'bcabcabcabca','acbacbacbacb'),(2569,2,3,'bcabcabcabca','acbacbacbacb'),(2570,2,3,'bcabcabcabca','acbacbacbacb'),(2571,2,3,'bcabcabcabca','acbacbacbacb'),(2572,2,3,'bcabcabcabca','acbacbacbacb'),(2573,2,3,'bcabcabcabca','acbacbacbacb'),(2574,2,3,'bcabcabcabca','acbacbacbacb'),(2575,2,3,'bcabcabcabca','acbacbacbacb'),(2576,2,3,'bcabcabcabca','acbacbacbacb'),(2577,2,3,'bcabcabcabca','acbacbacbacb'),(2578,2,3,'bcabcabcabca','acbacbacbacb'),(2579,2,3,'bcabcabcabca','acbacbacbacb'),(2580,2,3,'bcabcabcabca','acbacbacbacb'),(2581,2,3,'bcabcabcabca','acbacbacbacb'),(2582,2,3,'bcabcabcabca','acbacbacbacb'),(2583,2,3,'bcabcabcabca','acbacbacbacb'),(2584,2,3,'bcabcabcabca','acbacbacbacb'),(2585,2,3,'bcabcabcabca','acbacbacbacb'),(2586,2,3,'bcabcabcabca','acbacbacbacb'),(2587,2,3,'bcabcabcabca','acbacbacbacb'),(2588,2,3,'bcabcabcabca','acbacbacbacb'),(2589,2,3,'bcabcabcabca','acbacbacbacb'),(2590,2,3,'bcabcabcabca','acbacbacbacb'),(2591,2,3,'bcabcabcabca','acbacbacbacb'),(2592,2,3,'bcabcabcabca','acbacbacbacb'),(2593,2,3,'bcabcabcabca','acbacbacbacb'),(2594,2,3,'bcabcabcabca','acbacbacbacb'),(2595,2,3,'bcabcabcabca','acbacbacbacb'),(2596,2,3,'bcabcabcabca','acbacbacbacb'),(2597,2,3,'bcabcabcabca','acbacbacbacb'),(2598,2,3,'bcabcabcabca','acbacbacbacb'),(2599,2,3,'bcabcabcabca','acbacbacbacb'),(2600,2,3,'bcabcabcabca','acbacbacbacb'),(2601,2,3,'bcabcabcabca','acbacbacbacb'),(2602,2,3,'bcabcabcabca','acbacbacbacb'),(2603,2,3,'bcabcabcabca','acbacbacbacb'),(2604,2,3,'bcabcabcabca','acbacbacbacb'),(2605,2,3,'bcabcabcabca','acbacbacbacb'),(2606,2,3,'bcabcabcabca','acbacbacbacb'),(2607,2,3,'bcabcabcabca','acbacbacbacb'),(2608,2,3,'bcabcabcabca','acbacbacbacb'),(2609,2,3,'bcabcabcabca','acbacbacbacb'),(2610,2,3,'bcabcabcabca','acbacbacbacb'),(2611,2,3,'bcabcabcabca','acbacbacbacb'),(2612,2,3,'bcabcabcabca','acbacbacbacb'),(2613,2,3,'bcabcabcabca','acbacbacbacb'),(2614,2,3,'bcabcabcabca','acbacbacbacb'),(2615,2,3,'bcabcabcabca','acbacbacbacb'),(2616,2,3,'bcabcabcabca','acbacbacbacb'),(2617,2,3,'bcabcabcabca','acbacbacbacb'),(2618,2,3,'bcabcabcabca','acbacbacbacb'),(2619,2,3,'bcabcabcabca','acbacbacbacb'),(2620,2,3,'bcabcabcabca','acbacbacbacb'),(2621,2,3,'bcabcabcabca','acbacbacbacb'),(2622,2,3,'bcabcabcabca','acbacbacbacb'),(2623,2,3,'bcabcabcabca','acbacbacbacb'),(2624,2,3,'bcabcabcabca','acbacbacbacb'),(2625,2,3,'bcabcabcabca','acbacbacbacb'),(2626,2,3,'bcabcabcabca','acbacbacbacb'),(2627,2,3,'bcabcabcabca','acbacbacbacb'),(2628,2,3,'bcabcabcabca','acbacbacbacb'),(2629,2,3,'bcabcabcabca','acbacbacbacb'),(2630,2,3,'bcabcabcabca','acbacbacbacb'),(2631,2,3,'bcabcabcabca','acbacbacbacb'),(2632,2,3,'bcabcabcabca','acbacbacbacb'),(2633,2,3,'bcabcabcabca','acbacbacbacb'),(2634,2,3,'bcabcabcabca','acbacbacbacb'),(2635,2,3,'bcabcabcabca','acbacbacbacb'),(2636,2,3,'bcabcabcabca','acbacbacbacb'),(2637,2,3,'bcabcabcabca','acbacbacbacb'),(2638,2,3,'bcabcabcabca','acbacbacbacb'),(2639,2,3,'bcabcabcabca','acbacbacbacb'),(2640,2,3,'bcabcabcabca','acbacbacbacb'),(2641,2,3,'bcabcabcabca','acbacbacbacb'),(2642,2,3,'bcabcabcabca','acbacbacbacb'),(2643,2,3,'bcabcabcabca','acbacbacbacb'),(2644,2,3,'bcabcabcabca','acbacbacbacb'),(2645,2,3,'bcabcabcabca','acbacbacbacb'),(2646,2,3,'bcabcabcabca','acbacbacbacb'),(2647,2,3,'bcabcabcabca','acbacbacbacb'),(2648,2,3,'bcabcabcabca','acbacbacbacb'),(2649,2,3,'bcabcabcabca','acbacbacbacb'),(2650,2,3,'bcabcabcabca','acbacbacbacb'),(2651,2,3,'bcabcabcabca','acbacbacbacb'),(2652,2,3,'bcabcabcabca','acbacbacbacb'),(2653,2,3,'bcabcabcabca','acbacbacbacb'),(2654,2,3,'bcabcabcabca','acbacbacbacb'),(2655,2,3,'bcabcabcabca','acbacbacbacb'),(2656,2,3,'bcabcabcabca','acbacbacbacb'),(2657,2,3,'bcabcabcabca','acbacbacbacb'),(2658,2,3,'bcabcabcabca','acbacbacbacb'),(2659,2,3,'bcabcabcabca','acbacbacbacb'),(2660,2,3,'bcabcabcabca','acbacbacbacb'),(2661,2,3,'bcabcabcabca','acbacbacbacb'),(2662,2,3,'bcabcabcabca','acbacbacbacb'),(2663,2,3,'bcabcabcabca','acbacbacbacb'),(2664,2,3,'bcabcabcabca','acbacbacbacb'),(2665,2,3,'bcabcabcabca','acbacbacbacb'),(2666,2,3,'bcabcabcabca','acbacbacbacb'),(2667,2,3,'bcabcabcabca','acbacbacbacb'),(2668,2,3,'bcabcabcabca','acbacbacbacb'),(2669,2,3,'bcabcabcabca','acbacbacbacb'),(2670,2,3,'bcabcabcabca','acbacbacbacb'),(2671,2,3,'bcabcabcabca','acbacbacbacb'),(2672,2,3,'bcabcabcabca','acbacbacbacb'),(2673,2,3,'bcabcabcabca','acbacbacbacb'),(2674,2,3,'bcabcabcabca','acbacbacbacb'),(2675,2,3,'bcabcabcabca','acbacbacbacb'),(2676,2,3,'bcabcabcabca','acbacbacbacb'),(2677,2,3,'bcabcabcabca','acbacbacbacb'),(2678,2,3,'bcabcabcabca','acbacbacbacb'),(2679,2,3,'bcabcabcabca','acbacbacbacb'),(2680,2,3,'bcabcabcabca','acbacbacbacb'),(2681,2,3,'bcabcabcabca','acbacbacbacb'),(2682,2,3,'bcabcabcabca','acbacbacbacb'),(2683,2,3,'bcabcabcabca','acbacbacbacb'),(2684,2,3,'bcabcabcabca','acbacbacbacb'),(2685,2,3,'bcabcabcabca','acbacbacbacb'),(2686,2,3,'bcabcabcabca','acbacbacbacb'),(2687,2,3,'bcabcabcabca','acbacbacbacb'),(2688,2,3,'bcabcabcabca','acbacbacbacb'),(2689,2,3,'bcabcabcabca','acbacbacbacb'),(2690,2,3,'bcabcabcabca','acbacbacbacb'),(2691,2,3,'bcabcabcabca','acbacbacbacb'),(2692,2,3,'bcabcabcabca','acbacbacbacb'),(2693,2,3,'bcabcabcabca','acbacbacbacb'),(2694,2,3,'bcabcabcabca','acbacbacbacb'),(2695,2,3,'bcabcabcabca','acbacbacbacb'),(2696,2,3,'bcabcabcabca','acbacbacbacb'),(2697,2,3,'bcabcabcabca','acbacbacbacb'),(2698,2,3,'bcabcabcabca','acbacbacbacb'),(2699,2,3,'bcabcabcabca','acbacbacbacb'),(2700,2,3,'bcabcabcabca','acbacbacbacb'),(2701,2,3,'bcabcabcabca','acbacbacbacb'),(2702,2,3,'bcabcabcabca','acbacbacbacb'),(2703,2,3,'bcabcabcabca','acbacbacbacb'),(2704,2,3,'bcabcabcabca','acbacbacbacb'),(2705,2,3,'bcabcabcabca','acbacbacbacb'),(2706,2,3,'bcabcabcabca','acbacbacbacb'),(2707,2,3,'bcabcabcabca','acbacbacbacb'),(2708,2,3,'bcabcabcabca','acbacbacbacb'),(2709,2,3,'bcabcabcabca','acbacbacbacb'),(2710,2,3,'bcabcabcabca','acbacbacbacb'),(2711,2,3,'bcabcabcabca','acbacbacbacb'),(2712,2,3,'bcabcabcabca','acbacbacbacb'),(2713,2,3,'bcabcabcabca','acbacbacbacb'),(2714,2,3,'bcabcabcabca','acbacbacbacb'),(2715,2,3,'bcabcabcabca','acbacbacbacb'),(2716,2,3,'bcabcabcabca','acbacbacbacb'),(2717,2,3,'bcabcabcabca','acbacbacbacb'),(2718,2,3,'bcabcabcabca','acbacbacbacb'),(2719,2,3,'bcabcabcabca','acbacbacbacb'),(2720,2,3,'bcabcabcabca','acbacbacbacb'),(2721,2,3,'bcabcabcabca','acbacbacbacb'),(2722,2,3,'bcabcabcabca','acbacbacbacb'),(2723,2,3,'bcabcabcabca','acbacbacbacb'),(2724,2,3,'bcabcabcabca','acbacbacbacb'),(2725,2,3,'bcabcabcabca','acbacbacbacb'),(2726,2,3,'bcabcabcabca','acbacbacbacb'),(2727,2,3,'bcabcabcabca','acbacbacbacb'),(2728,2,3,'bcabcabcabca','acbacbacbacb'),(2729,2,3,'bcabcabcabca','acbacbacbacb'),(2730,2,3,'bcabcabcabca','acbacbacbacb'),(2731,2,3,'bcabcabcabca','acbacbacbacb'),(2732,2,3,'bcabcabcabca','acbacbacbacb'),(2733,2,3,'bcabcabcabca','acbacbacbacb'),(2734,2,3,'bcabcabcabca','acbacbacbacb'),(2735,2,3,'bcabcabcabca','acbacbacbacb'),(2736,2,3,'bcabcabcabca','acbacbacbacb'),(2737,2,3,'bcabcabcabca','acbacbacbacb'),(2738,2,3,'bcabcabcabca','acbacbacbacb'),(2739,2,3,'bcabcabcabca','acbacbacbacb'),(2740,2,3,'bcabcabcabca','acbacbacbacb'),(2741,2,3,'bcabcabcabca','acbacbacbacb'),(2742,2,3,'bcabcabcabca','acbacbacbacb'),(2743,2,3,'bcabcabcabca','acbacbacbacb'),(2744,2,3,'bcabcabcabca','acbacbacbacb'),(2745,2,3,'bcabcabcabca','acbacbacbacb'),(2746,2,3,'bcabcabcabca','acbacbacbacb'),(2747,2,3,'bcabcabcabca','acbacbacbacb'),(2748,2,3,'bcabcabcabca','acbacbacbacb'),(2749,2,3,'bcabcabcabca','acbacbacbacb'),(2750,2,3,'bcabcabcabca','acbacbacbacb'),(2751,2,3,'bcabcabcabca','acbacbacbacb'),(2752,2,3,'bcabcabcabca','acbacbacbacb'),(2753,2,3,'bcabcabcabca','acbacbacbacb'),(2754,2,3,'bcabcabcabca','acbacbacbacb'),(2755,2,3,'bcabcabcabca','acbacbacbacb'),(2756,2,3,'bcabcabcabca','acbacbacbacb'),(2757,2,3,'bcabcabcabca','acbacbacbacb'),(2758,2,3,'bcabcabcabca','acbacbacbacb'),(2759,2,3,'bcabcabcabca','acbacbacbacb'),(2760,2,3,'bcabcabcabca','acbacbacbacb'),(2761,2,3,'bcabcabcabca','acbacbacbacb'),(2762,2,3,'bcabcabcabca','acbacbacbacb'),(2763,2,3,'bcabcabcabca','acbacbacbacb'),(2764,2,3,'bcabcabcabca','acbacbacbacb'),(2765,2,3,'bcabcabcabca','acbacbacbacb'),(2766,2,3,'bcabcabcabca','acbacbacbacb'),(2767,2,3,'bcabcabcabca','acbacbacbacb'),(2768,2,3,'bcabcabcabca','acbacbacbacb'),(2769,2,3,'bcabcabcabca','acbacbacbacb'),(2770,2,3,'bcabcabcabca','acbacbacbacb'),(2771,2,3,'bcabcabcabca','acbacbacbacb'),(2772,2,3,'bcabcabcabca','acbacbacbacb'),(2773,2,3,'bcabcabcabca','acbacbacbacb'),(2774,2,3,'bcabcabcabca','acbacbacbacb'),(2775,2,3,'bcabcabcabca','acbacbacbacb'),(2776,2,3,'bcabcabcabca','acbacbacbacb'),(2777,2,3,'bcabcabcabca','acbacbacbacb'),(2778,2,3,'bcabcabcabca','acbacbacbacb'),(2779,2,3,'bcabcabcabca','acbacbacbacb'),(2780,2,3,'bcabcabcabca','acbacbacbacb'),(2781,2,3,'bcabcabcabca','acbacbacbacb'),(2782,2,3,'bcabcabcabca','acbacbacbacb'),(2783,2,3,'bcabcabcabca','acbacbacbacb'),(2784,2,3,'bcabcabcabca','acbacbacbacb'),(2785,2,3,'bcabcabcabca','acbacbacbacb'),(2786,2,3,'bcabcabcabca','acbacbacbacb'),(2787,2,3,'bcabcabcabca','acbacbacbacb'),(2788,2,3,'bcabcabcabca','acbacbacbacb'),(2789,2,3,'bcabcabcabca','acbacbacbacb'),(2790,2,3,'bcabcabcabca','acbacbacbacb'),(2791,2,3,'bcabcabcabca','acbacbacbacb'),(2792,2,3,'bcabcabcabca','acbacbacbacb'),(2793,2,3,'bcabcabcabca','acbacbacbacb'),(2794,2,3,'bcabcabcabca','acbacbacbacb'),(2795,2,3,'bcabcabcabca','acbacbacbacb'),(2796,2,3,'bcabcabcabca','acbacbacbacb'),(2797,2,3,'bcabcabcabca','acbacbacbacb'),(2798,2,3,'bcabcabcabca','acbacbacbacb'),(2799,2,3,'bcabcabcabca','acbacbacbacb'),(2800,2,3,'bcabcabcabca','acbacbacbacb'),(2801,2,3,'bcabcabcabca','acbacbacbacb'),(2802,2,3,'bcabcabcabca','acbacbacbacb'),(2803,2,3,'bcabcabcabca','acbacbacbacb'),(2804,2,3,'bcabcabcabca','acbacbacbacb'),(2805,2,3,'bcabcabcabca','acbacbacbacb'),(2806,2,3,'bcabcabcabca','acbacbacbacb'),(2807,2,3,'bcabcabcabca','acbacbacbacb'),(2808,2,3,'bcabcabcabca','acbacbacbacb'),(2809,2,3,'bcabcabcabca','acbacbacbacb'),(2810,2,3,'bcabcabcabca','acbacbacbacb'),(2811,2,3,'bcabcabcabca','acbacbacbacb'),(2812,2,3,'bcabcabcabca','acbacbacbacb'),(2813,2,3,'bcabcabcabca','acbacbacbacb'),(2814,2,3,'bcabcabcabca','acbacbacbacb'),(2815,2,3,'bcabcabcabca','acbacbacbacb'),(2816,2,3,'bcabcabcabca','acbacbacbacb'),(2817,2,3,'bcabcabcabca','acbacbacbacb'),(2818,2,3,'bcabcabcabca','acbacbacbacb'),(2819,2,3,'bcabcabcabca','acbacbacbacb'),(2820,2,3,'bcabcabcabca','acbacbacbacb'),(2821,2,3,'bcabcabcabca','acbacbacbacb'),(2822,2,3,'bcabcabcabca','acbacbacbacb'),(2823,2,3,'bcabcabcabca','acbacbacbacb'),(2824,2,3,'bcabcabcabca','acbacbacbacb'),(2825,2,3,'bcabcabcabca','acbacbacbacb'),(2826,2,3,'bcabcabcabca','acbacbacbacb'),(2827,2,3,'bcabcabcabca','acbacbacbacb'),(2828,2,3,'bcabcabcabca','acbacbacbacb'),(2829,2,3,'bcabcabcabca','acbacbacbacb'),(2830,2,3,'bcabcabcabca','acbacbacbacb'),(2831,2,3,'bcabcabcabca','acbacbacbacb'),(2832,2,3,'bcabcabcabca','acbacbacbacb'),(2833,2,3,'bcabcabcabca','acbacbacbacb'),(2834,2,3,'bcabcabcabca','acbacbacbacb'),(2835,2,3,'bcabcabcabca','acbacbacbacb'),(2836,2,3,'bcabcabcabca','acbacbacbacb'),(2837,2,3,'bcabcabcabca','acbacbacbacb'),(2838,2,3,'bcabcabcabca','acbacbacbacb'),(2839,2,3,'bcabcabcabca','acbacbacbacb'),(2840,2,3,'bcabcabcabca','acbacbacbacb'),(2841,2,3,'bcabcabcabca','acbacbacbacb'),(2842,2,3,'bcabcabcabca','acbacbacbacb'),(2843,2,3,'bcabcabcabca','acbacbacbacb'),(2844,2,3,'bcabcabcabca','acbacbacbacb'),(2845,2,3,'bcabcabcabca','acbacbacbacb'),(2846,2,3,'bcabcabcabca','acbacbacbacb'),(2847,2,3,'bcabcabcabca','acbacbacbacb'),(2848,2,3,'bcabcabcabca','acbacbacbacb'),(2849,2,3,'bcabcabcabca','acbacbacbacb'),(2850,2,3,'bcabcabcabca','acbacbacbacb'),(2851,2,3,'bcabcabcabca','acbacbacbacb'),(2852,2,3,'bcabcabcabca','acbacbacbacb'),(2853,2,3,'bcabcabcabca','acbacbacbacb'),(2854,2,3,'bcabcabcabca','acbacbacbacb'),(2855,2,3,'bcabcabcabca','acbacbacbacb'),(2856,2,3,'bcabcabcabca','acbacbacbacb'),(2857,2,3,'bcabcabcabca','acbacbacbacb'),(2858,2,3,'bcabcabcabca','acbacbacbacb'),(2859,2,3,'bcabcabcabca','acbacbacbacb'),(2860,2,3,'bcabcabcabca','acbacbacbacb'),(2861,2,3,'bcabcabcabca','acbacbacbacb'),(2862,2,3,'bcabcabcabca','acbacbacbacb'),(2863,2,3,'bcabcabcabca','acbacbacbacb'),(2864,2,3,'bcabcabcabca','acbacbacbacb'),(2865,2,3,'bcabcabcabca','acbacbacbacb'),(2866,2,3,'bcabcabcabca','acbacbacbacb'),(2867,2,3,'bcabcabcabca','acbacbacbacb'),(2868,2,3,'bcabcabcabca','acbacbacbacb'),(2869,2,3,'bcabcabcabca','acbacbacbacb'),(2870,2,3,'bcabcabcabca','acbacbacbacb'),(2871,2,3,'bcabcabcabca','acbacbacbacb'),(2872,2,3,'bcabcabcabca','acbacbacbacb'),(2873,2,3,'bcabcabcabca','acbacbacbacb'),(2874,2,3,'bcabcabcabca','acbacbacbacb'),(2875,2,3,'bcabcabcabca','acbacbacbacb'),(2876,2,3,'bcabcabcabca','acbacbacbacb'),(2877,2,3,'bcabcabcabca','acbacbacbacb'),(2878,2,3,'bcabcabcabca','acbacbacbacb'),(2879,2,3,'bcabcabcabca','acbacbacbacb'),(2880,2,3,'bcabcabcabca','acbacbacbacb'),(2881,2,3,'bcabcabcabca','acbacbacbacb'),(2882,2,3,'bcabcabcabca','acbacbacbacb'),(2883,2,3,'bcabcabcabca','acbacbacbacb'),(2884,2,3,'bcabcabcabca','acbacbacbacb'),(2885,2,3,'bcabcabcabca','acbacbacbacb'),(2886,2,3,'bcabcabcabca','acbacbacbacb'),(2887,2,3,'bcabcabcabca','acbacbacbacb'),(2888,2,3,'bcabcabcabca','acbacbacbacb'),(2889,2,3,'bcabcabcabca','acbacbacbacb'),(2890,2,3,'bcabcabcabca','acbacbacbacb'),(2891,2,3,'bcabcabcabca','acbacbacbacb'),(2892,2,3,'bcabcabcabca','acbacbacbacb'),(2893,2,3,'bcabcabcabca','acbacbacbacb'),(2894,2,3,'bcabcabcabca','acbacbacbacb'),(2895,2,3,'bcabcabcabca','acbacbacbacb'),(2896,2,3,'bcabcabcabca','acbacbacbacb'),(2897,2,3,'bcabcabcabca','acbacbacbacb'),(2898,2,3,'bcabcabcabca','acbacbacbacb'),(2899,2,3,'bcabcabcabca','acbacbacbacb'),(2900,2,3,'bcabcabcabca','acbacbacbacb'),(2901,2,3,'bcabcabcabca','acbacbacbacb'),(2902,2,3,'bcabcabcabca','acbacbacbacb'),(2903,2,3,'bcabcabcabca','acbacbacbacb'),(2904,2,3,'bcabcabcabca','acbacbacbacb'),(2905,2,3,'bcabcabcabca','acbacbacbacb'),(2906,2,3,'bcabcabcabca','acbacbacbacb'),(2907,2,3,'bcabcabcabca','acbacbacbacb'),(2908,2,3,'bcabcabcabca','acbacbacbacb'),(2909,2,3,'bcabcabcabca','acbacbacbacb'),(2910,2,3,'bcabcabcabca','acbacbacbacb'),(2911,2,3,'bcabcabcabca','acbacbacbacb'),(2912,2,3,'bcabcabcabca','acbacbacbacb'),(2913,2,3,'bcabcabcabca','acbacbacbacb'),(2914,2,3,'bcabcabcabca','acbacbacbacb'),(2915,2,3,'bcabcabcabca','acbacbacbacb'),(2916,2,3,'bcabcabcabca','acbacbacbacb'),(2917,2,3,'bcabcabcabca','acbacbacbacb'),(2918,2,3,'bcabcabcabca','acbacbacbacb'),(2919,2,3,'bcabcabcabca','acbacbacbacb'),(2920,2,3,'bcabcabcabca','acbacbacbacb'),(2921,2,3,'bcabcabcabca','acbacbacbacb'),(2922,2,3,'bcabcabcabca','acbacbacbacb'),(2923,2,3,'bcabcabcabca','acbacbacbacb'),(2924,2,3,'bcabcabcabca','acbacbacbacb'),(2925,2,3,'bcabcabcabca','acbacbacbacb'),(2926,2,3,'bcabcabcabca','acbacbacbacb'),(2927,2,3,'bcabcabcabca','acbacbacbacb'),(2928,2,3,'bcabcabcabca','acbacbacbacb'),(2929,2,3,'bcabcabcabca','acbacbacbacb'),(2930,2,3,'bcabcabcabca','acbacbacbacb'),(2931,2,3,'bcabcabcabca','acbacbacbacb'),(2932,2,3,'bcabcabcabca','acbacbacbacb'),(2933,2,3,'bcabcabcabca','acbacbacbacb'),(2934,2,3,'bcabcabcabca','acbacbacbacb'),(2935,2,3,'bcabcabcabca','acbacbacbacb'),(2936,2,3,'bcabcabcabca','acbacbacbacb'),(2937,2,3,'bcabcabcabca','acbacbacbacb'),(2938,2,3,'bcabcabcabca','acbacbacbacb'),(2939,2,3,'bcabcabcabca','acbacbacbacb'),(2940,2,3,'bcabcabcabca','acbacbacbacb'),(2941,2,3,'bcabcabcabca','acbacbacbacb'),(2942,2,3,'bcabcabcabca','acbacbacbacb'),(2943,2,3,'bcabcabcabca','acbacbacbacb'),(2944,2,3,'bcabcabcabca','acbacbacbacb'),(2945,2,3,'bcabcabcabca','acbacbacbacb'),(2946,2,3,'bcabcabcabca','acbacbacbacb'),(2947,2,3,'bcabcabcabca','acbacbacbacb'),(2948,2,3,'bcabcabcabca','acbacbacbacb'),(2949,2,3,'bcabcabcabca','acbacbacbacb'),(2950,2,3,'bcabcabcabca','acbacbacbacb'),(2951,2,3,'bcabcabcabca','acbacbacbacb'),(2952,2,3,'bcabcabcabca','acbacbacbacb'),(2953,2,3,'bcabcabcabca','acbacbacbacb'),(2954,2,3,'bcabcabcabca','acbacbacbacb'),(2955,2,3,'bcabcabcabca','acbacbacbacb'),(2956,2,3,'bcabcabcabca','acbacbacbacb'),(2957,2,3,'bcabcabcabca','acbacbacbacb'),(2958,2,3,'bcabcabcabca','acbacbacbacb'),(2959,2,3,'bcabcabcabca','acbacbacbacb'),(2960,2,3,'bcabcabcabca','acbacbacbacb'),(2961,2,3,'bcabcabcabca','acbacbacbacb'),(2962,2,3,'bcabcabcabca','acbacbacbacb'),(2963,2,3,'bcabcabcabca','acbacbacbacb'),(2964,2,3,'bcabcabcabca','acbacbacbacb'),(2965,2,3,'bcabcabcabca','acbacbacbacb'),(2966,2,3,'bcabcabcabca','acbacbacbacb'),(2967,2,3,'bcabcabcabca','acbacbacbacb'),(2968,2,3,'bcabcabcabca','acbacbacbacb'),(2969,2,3,'bcabcabcabca','acbacbacbacb'),(2970,2,3,'bcabcabcabca','acbacbacbacb'),(2971,2,3,'bcabcabcabca','acbacbacbacb'),(2972,2,3,'bcabcabcabca','acbacbacbacb'),(2973,2,3,'bcabcabcabca','acbacbacbacb'),(2974,2,3,'bcabcabcabca','acbacbacbacb'),(2975,2,3,'bcabcabcabca','acbacbacbacb'),(2976,2,3,'bcabcabcabca','acbacbacbacb'),(2977,2,3,'bcabcabcabca','acbacbacbacb'),(2978,2,3,'bcabcabcabca','acbacbacbacb'),(2979,2,3,'bcabcabcabca','acbacbacbacb'),(2980,2,3,'bcabcabcabca','acbacbacbacb'),(2981,2,3,'bcabcabcabca','acbacbacbacb'),(2982,2,3,'bcabcabcabca','acbacbacbacb'),(2983,2,3,'bcabcabcabca','acbacbacbacb'),(2984,2,3,'bcabcabcabca','acbacbacbacb'),(2985,2,3,'bcabcabcabca','acbacbacbacb'),(2986,2,3,'bcabcabcabca','acbacbacbacb'),(2987,2,3,'bcabcabcabca','acbacbacbacb'),(2988,2,3,'bcabcabcabca','acbacbacbacb'),(2989,2,3,'bcabcabcabca','acbacbacbacb'),(2990,2,3,'bcabcabcabca','acbacbacbacb'),(2991,2,3,'bcabcabcabca','acbacbacbacb'),(2992,2,3,'bcabcabcabca','acbacbacbacb'),(2993,2,3,'bcabcabcabca','acbacbacbacb'),(2994,2,3,'bcabcabcabca','acbacbacbacb'),(2995,2,3,'bcabcabcabca','acbacbacbacb'),(2996,2,3,'bcabcabcabca','acbacbacbacb'),(2997,2,3,'bcabcabcabca','acbacbacbacb'),(2998,2,3,'bcabcabcabca','acbacbacbacb'),(2999,2,3,'bcabcabcabca','acbacbacbacb'),(3000,2,3,'bcabcabcabca','acbacbacbacb'),(3001,2,3,'bcabcabcabca','acbacbacbacb'),(3002,2,3,'bcabcabcabca','acbacbacbacb'),(3003,2,3,'bcabcabcabca','acbacbacbacb'),(3004,2,3,'bcabcabcabca','acbacbacbacb'),(3005,2,3,'bcabcabcabca','acbacbacbacb'),(3006,2,3,'bcabcabcabca','acbacbacbacb'),(3007,2,3,'bcabcabcabca','acbacbacbacb'),(3008,2,3,'bcabcabcabca','acbacbacbacb'),(3009,2,3,'bcabcabcabca','acbacbacbacb'),(3010,2,3,'bcabcabcabca','acbacbacbacb'),(3011,2,3,'bcabcabcabca','acbacbacbacb'),(3012,2,3,'bcabcabcabca','acbacbacbacb'),(3013,2,3,'bcabcabcabca','acbacbacbacb'),(3014,2,3,'bcabcabcabca','acbacbacbacb'),(3015,2,3,'bcabcabcabca','acbacbacbacb'),(3016,2,3,'bcabcabcabca','acbacbacbacb'),(3017,2,3,'bcabcabcabca','acbacbacbacb'),(3018,2,3,'bcabcabcabca','acbacbacbacb'),(3019,2,3,'bcabcabcabca','acbacbacbacb'),(3020,2,3,'bcabcabcabca','acbacbacbacb'),(3021,2,3,'bcabcabcabca','acbacbacbacb'),(3022,2,3,'bcabcabcabca','acbacbacbacb'),(3023,2,3,'bcabcabcabca','acbacbacbacb'),(3024,2,3,'bcabcabcabca','acbacbacbacb'),(3025,2,3,'bcabcabcabca','acbacbacbacb'),(3026,2,3,'bcabcabcabca','acbacbacbacb'),(3027,2,3,'bcabcabcabca','acbacbacbacb'),(3028,2,3,'bcabcabcabca','acbacbacbacb'),(3029,2,3,'bcabcabcabca','acbacbacbacb'),(3030,2,3,'bcabcabcabca','acbacbacbacb'),(3031,2,3,'bcabcabcabca','acbacbacbacb'),(3032,2,3,'bcabcabcabca','acbacbacbacb'),(3033,2,3,'bcabcabcabca','acbacbacbacb'),(3034,2,3,'bcabcabcabca','acbacbacbacb'),(3035,2,3,'bcabcabcabca','acbacbacbacb'),(3036,2,3,'bcabcabcabca','acbacbacbacb'),(3037,2,3,'bcabcabcabca','acbacbacbacb'),(3038,2,3,'bcabcabcabca','acbacbacbacb'),(3039,2,3,'bcabcabcabca','acbacbacbacb'),(3040,2,3,'bcabcabcabca','acbacbacbacb'),(3041,2,3,'bcabcabcabca','acbacbacbacb'),(3042,2,3,'bcabcabcabca','acbacbacbacb'),(3043,2,3,'bcabcabcabca','acbacbacbacb'),(3044,2,3,'bcabcabcabca','acbacbacbacb'),(3045,2,3,'bcabcabcabca','acbacbacbacb'),(3046,2,3,'bcabcabcabca','acbacbacbacb'),(3047,2,3,'bcabcabcabca','acbacbacbacb'),(3048,2,3,'bcabcabcabca','acbacbacbacb'),(3049,2,3,'bcabcabcabca','acbacbacbacb'),(3050,2,3,'bcabcabcabca','acbacbacbacb'),(3051,2,3,'bcabcabcabca','acbacbacbacb'),(3052,2,3,'bcabcabcabca','acbacbacbacb'),(3053,2,3,'bcabcabcabca','acbacbacbacb'),(3054,2,3,'bcabcabcabca','acbacbacbacb'),(3055,2,3,'bcabcabcabca','acbacbacbacb'),(3056,2,3,'bcabcabcabca','acbacbacbacb'),(3057,2,3,'bcabcabcabca','acbacbacbacb'),(3058,2,3,'bcabcabcabca','acbacbacbacb'),(3059,2,3,'bcabcabcabca','acbacbacbacb'),(3060,2,3,'bcabcabcabca','acbacbacbacb'),(3061,2,3,'bcabcabcabca','acbacbacbacb'),(3062,2,3,'bcabcabcabca','acbacbacbacb'),(3063,3,1,'bcabcabcabca','acbacbacbacb'),(3064,3,1,'bcabcabcabca','acbacbacbacb'),(3065,3,1,'bcabcabcabca','acbacbacbacb'),(3066,3,1,'bcabcabcabca','acbacbacbacb'),(3067,3,1,'bcabcabcabca','acbacbacbacb'),(3068,3,1,'bcabcabcabca','acbacbacbacb'),(3069,3,1,'bcabcabcabca','acbacbacbacb'),(3070,3,1,'bcabcabcabca','acbacbacbacb'),(3071,3,1,'bcabcabcabca','acbacbacbacb'),(3072,3,1,'bcabcabcabca','acbacbacbacb'),(3073,3,2,'bcabcabcabca','acbacbacbacb'),(3074,3,2,'bcabcabcabca','acbacbacbacb'),(3075,3,2,'bcabcabcabca','acbacbacbacb'),(3076,3,2,'bcabcabcabca','acbacbacbacb'),(3077,3,2,'bcabcabcabca','acbacbacbacb'),(3078,3,2,'bcabcabcabca','acbacbacbacb'),(3079,3,2,'bcabcabcabca','acbacbacbacb'),(3080,3,2,'bcabcabcabca','acbacbacbacb'),(3081,3,2,'bcabcabcabca','acbacbacbacb'),(3082,3,2,'bcabcabcabca','acbacbacbacb'),(3083,3,2,'bcabcabcabca','acbacbacbacb'),(3084,3,2,'bcabcabcabca','acbacbacbacb'),(3085,3,2,'bcabcabcabca','acbacbacbacb'),(3086,3,2,'bcabcabcabca','acbacbacbacb'),(3087,3,2,'bcabcabcabca','acbacbacbacb'),(3088,3,2,'bcabcabcabca','acbacbacbacb'),(3089,3,2,'bcabcabcabca','acbacbacbacb'),(3090,3,2,'bcabcabcabca','acbacbacbacb'),(3091,3,2,'bcabcabcabca','acbacbacbacb'),(3092,3,2,'bcabcabcabca','acbacbacbacb'),(3093,3,2,'bcabcabcabca','acbacbacbacb'),(3094,3,2,'bcabcabcabca','acbacbacbacb'),(3095,3,2,'bcabcabcabca','acbacbacbacb'),(3096,3,2,'bcabcabcabca','acbacbacbacb'),(3097,3,2,'bcabcabcabca','acbacbacbacb'),(3098,3,2,'bcabcabcabca','acbacbacbacb'),(3099,3,2,'bcabcabcabca','acbacbacbacb'),(3100,3,2,'bcabcabcabca','acbacbacbacb'),(3101,3,2,'bcabcabcabca','acbacbacbacb'),(3102,3,2,'bcabcabcabca','acbacbacbacb'),(3103,3,2,'bcabcabcabca','acbacbacbacb'),(3104,3,2,'bcabcabcabca','acbacbacbacb'),(3105,3,2,'bcabcabcabca','acbacbacbacb'),(3106,3,2,'bcabcabcabca','acbacbacbacb'),(3107,3,2,'bcabcabcabca','acbacbacbacb'),(3108,3,2,'bcabcabcabca','acbacbacbacb'),(3109,3,2,'bcabcabcabca','acbacbacbacb'),(3110,3,2,'bcabcabcabca','acbacbacbacb'),(3111,3,2,'bcabcabcabca','acbacbacbacb'),(3112,3,2,'bcabcabcabca','acbacbacbacb'),(3113,3,2,'bcabcabcabca','acbacbacbacb'),(3114,3,2,'bcabcabcabca','acbacbacbacb'),(3115,3,2,'bcabcabcabca','acbacbacbacb'),(3116,3,2,'bcabcabcabca','acbacbacbacb'),(3117,3,2,'bcabcabcabca','acbacbacbacb'),(3118,3,2,'bcabcabcabca','acbacbacbacb'),(3119,3,2,'bcabcabcabca','acbacbacbacb'),(3120,3,2,'bcabcabcabca','acbacbacbacb'),(3121,3,2,'bcabcabcabca','acbacbacbacb'),(3122,3,2,'bcabcabcabca','acbacbacbacb'),(3123,3,2,'bcabcabcabca','acbacbacbacb'),(3124,3,2,'bcabcabcabca','acbacbacbacb'),(3125,3,2,'bcabcabcabca','acbacbacbacb'),(3126,3,2,'bcabcabcabca','acbacbacbacb'),(3127,3,2,'bcabcabcabca','acbacbacbacb'),(3128,3,2,'bcabcabcabca','acbacbacbacb'),(3129,3,2,'bcabcabcabca','acbacbacbacb'),(3130,3,2,'bcabcabcabca','acbacbacbacb'),(3131,3,2,'bcabcabcabca','acbacbacbacb'),(3132,3,2,'bcabcabcabca','acbacbacbacb'),(3133,3,2,'bcabcabcabca','acbacbacbacb'),(3134,3,2,'bcabcabcabca','acbacbacbacb'),(3135,3,2,'bcabcabcabca','acbacbacbacb'),(3136,3,2,'bcabcabcabca','acbacbacbacb'),(3137,3,2,'bcabcabcabca','acbacbacbacb'),(3138,3,2,'bcabcabcabca','acbacbacbacb'),(3139,3,2,'bcabcabcabca','acbacbacbacb'),(3140,3,2,'bcabcabcabca','acbacbacbacb'),(3141,3,2,'bcabcabcabca','acbacbacbacb'),(3142,3,2,'bcabcabcabca','acbacbacbacb'),(3143,3,2,'bcabcabcabca','acbacbacbacb'),(3144,3,2,'bcabcabcabca','acbacbacbacb'),(3145,3,2,'bcabcabcabca','acbacbacbacb'),(3146,3,2,'bcabcabcabca','acbacbacbacb'),(3147,3,2,'bcabcabcabca','acbacbacbacb'),(3148,3,2,'bcabcabcabca','acbacbacbacb'),(3149,3,2,'bcabcabcabca','acbacbacbacb'),(3150,3,2,'bcabcabcabca','acbacbacbacb'),(3151,3,2,'bcabcabcabca','acbacbacbacb'),(3152,3,2,'bcabcabcabca','acbacbacbacb'),(3153,3,2,'bcabcabcabca','acbacbacbacb'),(3154,3,2,'bcabcabcabca','acbacbacbacb'),(3155,3,2,'bcabcabcabca','acbacbacbacb'),(3156,3,2,'bcabcabcabca','acbacbacbacb'),(3157,3,2,'bcabcabcabca','acbacbacbacb'),(3158,3,2,'bcabcabcabca','acbacbacbacb'),(3159,3,2,'bcabcabcabca','acbacbacbacb'),(3160,3,2,'bcabcabcabca','acbacbacbacb'),(3161,3,2,'bcabcabcabca','acbacbacbacb'),(3162,3,2,'bcabcabcabca','acbacbacbacb'),(3163,3,2,'bcabcabcabca','acbacbacbacb'),(3164,3,2,'bcabcabcabca','acbacbacbacb'),(3165,3,2,'bcabcabcabca','acbacbacbacb'),(3166,3,2,'bcabcabcabca','acbacbacbacb'),(3167,3,2,'bcabcabcabca','acbacbacbacb'),(3168,3,2,'bcabcabcabca','acbacbacbacb'),(3169,3,2,'bcabcabcabca','acbacbacbacb'),(3170,3,2,'bcabcabcabca','acbacbacbacb'),(3171,3,2,'bcabcabcabca','acbacbacbacb'),(3172,3,2,'bcabcabcabca','acbacbacbacb'),(3173,3,2,'bcabcabcabca','acbacbacbacb'),(3174,3,2,'bcabcabcabca','acbacbacbacb'),(3175,3,2,'bcabcabcabca','acbacbacbacb'),(3176,3,2,'bcabcabcabca','acbacbacbacb'),(3177,3,2,'bcabcabcabca','acbacbacbacb'),(3178,3,2,'bcabcabcabca','acbacbacbacb'),(3179,3,2,'bcabcabcabca','acbacbacbacb'),(3180,3,2,'bcabcabcabca','acbacbacbacb'),(3181,3,2,'bcabcabcabca','acbacbacbacb'),(3182,3,2,'bcabcabcabca','acbacbacbacb'),(3183,3,2,'bcabcabcabca','acbacbacbacb'),(3184,3,2,'bcabcabcabca','acbacbacbacb'),(3185,3,2,'bcabcabcabca','acbacbacbacb'),(3186,3,2,'bcabcabcabca','acbacbacbacb'),(3187,3,2,'bcabcabcabca','acbacbacbacb'),(3188,3,2,'bcabcabcabca','acbacbacbacb'),(3189,3,2,'bcabcabcabca','acbacbacbacb'),(3190,3,2,'bcabcabcabca','acbacbacbacb'),(3191,3,2,'bcabcabcabca','acbacbacbacb'),(3192,3,2,'bcabcabcabca','acbacbacbacb'),(3193,3,2,'bcabcabcabca','acbacbacbacb'),(3194,3,2,'bcabcabcabca','acbacbacbacb'),(3195,3,2,'bcabcabcabca','acbacbacbacb'),(3196,3,2,'bcabcabcabca','acbacbacbacb'),(3197,3,2,'bcabcabcabca','acbacbacbacb'),(3198,3,2,'bcabcabcabca','acbacbacbacb'),(3199,3,2,'bcabcabcabca','acbacbacbacb'),(3200,3,2,'bcabcabcabca','acbacbacbacb'),(3201,3,2,'bcabcabcabca','acbacbacbacb'),(3202,3,2,'bcabcabcabca','acbacbacbacb'),(3203,3,2,'bcabcabcabca','acbacbacbacb'),(3204,3,2,'bcabcabcabca','acbacbacbacb'),(3205,3,2,'bcabcabcabca','acbacbacbacb'),(3206,3,2,'bcabcabcabca','acbacbacbacb'),(3207,3,2,'bcabcabcabca','acbacbacbacb'),(3208,3,2,'bcabcabcabca','acbacbacbacb'),(3209,3,2,'bcabcabcabca','acbacbacbacb'),(3210,3,2,'bcabcabcabca','acbacbacbacb'),(3211,3,2,'bcabcabcabca','acbacbacbacb'),(3212,3,2,'bcabcabcabca','acbacbacbacb'),(3213,3,2,'bcabcabcabca','acbacbacbacb'),(3214,3,2,'bcabcabcabca','acbacbacbacb'),(3215,3,2,'bcabcabcabca','acbacbacbacb'),(3216,3,2,'bcabcabcabca','acbacbacbacb'),(3217,3,2,'bcabcabcabca','acbacbacbacb'),(3218,3,2,'bcabcabcabca','acbacbacbacb'),(3219,3,2,'bcabcabcabca','acbacbacbacb'),(3220,3,2,'bcabcabcabca','acbacbacbacb'),(3221,3,2,'bcabcabcabca','acbacbacbacb'),(3222,3,2,'bcabcabcabca','acbacbacbacb'),(3223,3,2,'bcabcabcabca','acbacbacbacb'),(3224,3,2,'bcabcabcabca','acbacbacbacb'),(3225,3,2,'bcabcabcabca','acbacbacbacb'),(3226,3,2,'bcabcabcabca','acbacbacbacb'),(3227,3,2,'bcabcabcabca','acbacbacbacb'),(3228,3,2,'bcabcabcabca','acbacbacbacb'),(3229,3,2,'bcabcabcabca','acbacbacbacb'),(3230,3,2,'bcabcabcabca','acbacbacbacb'),(3231,3,2,'bcabcabcabca','acbacbacbacb'),(3232,3,2,'bcabcabcabca','acbacbacbacb'),(3233,3,2,'bcabcabcabca','acbacbacbacb'),(3234,3,2,'bcabcabcabca','acbacbacbacb'),(3235,3,2,'bcabcabcabca','acbacbacbacb'),(3236,3,2,'bcabcabcabca','acbacbacbacb'),(3237,3,2,'bcabcabcabca','acbacbacbacb'),(3238,3,2,'bcabcabcabca','acbacbacbacb'),(3239,3,2,'bcabcabcabca','acbacbacbacb'),(3240,3,2,'bcabcabcabca','acbacbacbacb'),(3241,3,2,'bcabcabcabca','acbacbacbacb'),(3242,3,2,'bcabcabcabca','acbacbacbacb'),(3243,3,2,'bcabcabcabca','acbacbacbacb'),(3244,3,2,'bcabcabcabca','acbacbacbacb'),(3245,3,2,'bcabcabcabca','acbacbacbacb'),(3246,3,2,'bcabcabcabca','acbacbacbacb'),(3247,3,2,'bcabcabcabca','acbacbacbacb'),(3248,3,2,'bcabcabcabca','acbacbacbacb'),(3249,3,2,'bcabcabcabca','acbacbacbacb'),(3250,3,2,'bcabcabcabca','acbacbacbacb'),(3251,3,2,'bcabcabcabca','acbacbacbacb'),(3252,3,2,'bcabcabcabca','acbacbacbacb'),(3253,3,2,'bcabcabcabca','acbacbacbacb'),(3254,3,2,'bcabcabcabca','acbacbacbacb'),(3255,3,2,'bcabcabcabca','acbacbacbacb'),(3256,3,2,'bcabcabcabca','acbacbacbacb'),(3257,3,2,'bcabcabcabca','acbacbacbacb'),(3258,3,2,'bcabcabcabca','acbacbacbacb'),(3259,3,2,'bcabcabcabca','acbacbacbacb'),(3260,3,2,'bcabcabcabca','acbacbacbacb'),(3261,3,2,'bcabcabcabca','acbacbacbacb'),(3262,3,2,'bcabcabcabca','acbacbacbacb'),(3263,3,2,'bcabcabcabca','acbacbacbacb'),(3264,3,2,'bcabcabcabca','acbacbacbacb'),(3265,3,2,'bcabcabcabca','acbacbacbacb'),(3266,3,2,'bcabcabcabca','acbacbacbacb'),(3267,3,2,'bcabcabcabca','acbacbacbacb'),(3268,3,2,'bcabcabcabca','acbacbacbacb'),(3269,3,2,'bcabcabcabca','acbacbacbacb'),(3270,3,2,'bcabcabcabca','acbacbacbacb'),(3271,3,2,'bcabcabcabca','acbacbacbacb'),(3272,3,2,'bcabcabcabca','acbacbacbacb'),(3273,3,2,'bcabcabcabca','acbacbacbacb'),(3274,3,2,'bcabcabcabca','acbacbacbacb'),(3275,3,2,'bcabcabcabca','acbacbacbacb'),(3276,3,2,'bcabcabcabca','acbacbacbacb'),(3277,3,2,'bcabcabcabca','acbacbacbacb'),(3278,3,2,'bcabcabcabca','acbacbacbacb'),(3279,3,2,'bcabcabcabca','acbacbacbacb'),(3280,3,2,'bcabcabcabca','acbacbacbacb'),(3281,3,2,'bcabcabcabca','acbacbacbacb'),(3282,3,2,'bcabcabcabca','acbacbacbacb'),(3283,3,2,'bcabcabcabca','acbacbacbacb'),(3284,3,2,'bcabcabcabca','acbacbacbacb'),(3285,3,2,'bcabcabcabca','acbacbacbacb'),(3286,3,2,'bcabcabcabca','acbacbacbacb'),(3287,3,2,'bcabcabcabca','acbacbacbacb'),(3288,3,2,'bcabcabcabca','acbacbacbacb'),(3289,3,2,'bcabcabcabca','acbacbacbacb'),(3290,3,2,'bcabcabcabca','acbacbacbacb'),(3291,3,2,'bcabcabcabca','acbacbacbacb'),(3292,3,2,'bcabcabcabca','acbacbacbacb'),(3293,3,2,'bcabcabcabca','acbacbacbacb'),(3294,3,2,'bcabcabcabca','acbacbacbacb'),(3295,3,2,'bcabcabcabca','acbacbacbacb'),(3296,3,2,'bcabcabcabca','acbacbacbacb'),(3297,3,2,'bcabcabcabca','acbacbacbacb'),(3298,3,2,'bcabcabcabca','acbacbacbacb'),(3299,3,2,'bcabcabcabca','acbacbacbacb'),(3300,3,2,'bcabcabcabca','acbacbacbacb'),(3301,3,2,'bcabcabcabca','acbacbacbacb'),(3302,3,2,'bcabcabcabca','acbacbacbacb'),(3303,3,2,'bcabcabcabca','acbacbacbacb'),(3304,3,2,'bcabcabcabca','acbacbacbacb'),(3305,3,2,'bcabcabcabca','acbacbacbacb'),(3306,3,2,'bcabcabcabca','acbacbacbacb'),(3307,3,2,'bcabcabcabca','acbacbacbacb'),(3308,3,2,'bcabcabcabca','acbacbacbacb'),(3309,3,2,'bcabcabcabca','acbacbacbacb'),(3310,3,2,'bcabcabcabca','acbacbacbacb'),(3311,3,2,'bcabcabcabca','acbacbacbacb'),(3312,3,2,'bcabcabcabca','acbacbacbacb'),(3313,3,2,'bcabcabcabca','acbacbacbacb'),(3314,3,2,'bcabcabcabca','acbacbacbacb'),(3315,3,2,'bcabcabcabca','acbacbacbacb'),(3316,3,2,'bcabcabcabca','acbacbacbacb'),(3317,3,2,'bcabcabcabca','acbacbacbacb'),(3318,3,2,'bcabcabcabca','acbacbacbacb'),(3319,3,2,'bcabcabcabca','acbacbacbacb'),(3320,3,2,'bcabcabcabca','acbacbacbacb'),(3321,3,2,'bcabcabcabca','acbacbacbacb'),(3322,3,2,'bcabcabcabca','acbacbacbacb'),(3323,3,2,'bcabcabcabca','acbacbacbacb'),(3324,3,2,'bcabcabcabca','acbacbacbacb'),(3325,3,2,'bcabcabcabca','acbacbacbacb'),(3326,3,2,'bcabcabcabca','acbacbacbacb'),(3327,3,2,'bcabcabcabca','acbacbacbacb'),(3328,3,2,'bcabcabcabca','acbacbacbacb'),(3329,3,2,'bcabcabcabca','acbacbacbacb'),(3330,3,2,'bcabcabcabca','acbacbacbacb'),(3331,3,2,'bcabcabcabca','acbacbacbacb'),(3332,3,2,'bcabcabcabca','acbacbacbacb'),(3333,3,2,'bcabcabcabca','acbacbacbacb'),(3334,3,2,'bcabcabcabca','acbacbacbacb'),(3335,3,2,'bcabcabcabca','acbacbacbacb'),(3336,3,2,'bcabcabcabca','acbacbacbacb'),(3337,3,2,'bcabcabcabca','acbacbacbacb'),(3338,3,2,'bcabcabcabca','acbacbacbacb'),(3339,3,2,'bcabcabcabca','acbacbacbacb'),(3340,3,2,'bcabcabcabca','acbacbacbacb'),(3341,3,2,'bcabcabcabca','acbacbacbacb'),(3342,3,2,'bcabcabcabca','acbacbacbacb'),(3343,3,2,'bcabcabcabca','acbacbacbacb'),(3344,3,2,'bcabcabcabca','acbacbacbacb'),(3345,3,2,'bcabcabcabca','acbacbacbacb'),(3346,3,2,'bcabcabcabca','acbacbacbacb'),(3347,3,2,'bcabcabcabca','acbacbacbacb'),(3348,3,2,'bcabcabcabca','acbacbacbacb'),(3349,3,2,'bcabcabcabca','acbacbacbacb'),(3350,3,2,'bcabcabcabca','acbacbacbacb'),(3351,3,2,'bcabcabcabca','acbacbacbacb'),(3352,3,2,'bcabcabcabca','acbacbacbacb'),(3353,3,2,'bcabcabcabca','acbacbacbacb'),(3354,3,2,'bcabcabcabca','acbacbacbacb'),(3355,3,2,'bcabcabcabca','acbacbacbacb'),(3356,3,2,'bcabcabcabca','acbacbacbacb'),(3357,3,2,'bcabcabcabca','acbacbacbacb'),(3358,3,2,'bcabcabcabca','acbacbacbacb'),(3359,3,2,'bcabcabcabca','acbacbacbacb'),(3360,3,2,'bcabcabcabca','acbacbacbacb'),(3361,3,2,'bcabcabcabca','acbacbacbacb'),(3362,3,2,'bcabcabcabca','acbacbacbacb'),(3363,3,2,'bcabcabcabca','acbacbacbacb'),(3364,3,2,'bcabcabcabca','acbacbacbacb'),(3365,3,2,'bcabcabcabca','acbacbacbacb'),(3366,3,2,'bcabcabcabca','acbacbacbacb'),(3367,3,2,'bcabcabcabca','acbacbacbacb'),(3368,3,2,'bcabcabcabca','acbacbacbacb'),(3369,3,2,'bcabcabcabca','acbacbacbacb'),(3370,3,2,'bcabcabcabca','acbacbacbacb'),(3371,3,2,'bcabcabcabca','acbacbacbacb'),(3372,3,2,'bcabcabcabca','acbacbacbacb'),(3373,3,2,'bcabcabcabca','acbacbacbacb'),(3374,3,2,'bcabcabcabca','acbacbacbacb'),(3375,3,2,'bcabcabcabca','acbacbacbacb'),(3376,3,2,'bcabcabcabca','acbacbacbacb'),(3377,3,2,'bcabcabcabca','acbacbacbacb'),(3378,3,2,'bcabcabcabca','acbacbacbacb'),(3379,3,2,'bcabcabcabca','acbacbacbacb'),(3380,3,2,'bcabcabcabca','acbacbacbacb'),(3381,3,2,'bcabcabcabca','acbacbacbacb'),(3382,3,2,'bcabcabcabca','acbacbacbacb'),(3383,3,2,'bcabcabcabca','acbacbacbacb'),(3384,3,2,'bcabcabcabca','acbacbacbacb'),(3385,3,2,'bcabcabcabca','acbacbacbacb'),(3386,3,2,'bcabcabcabca','acbacbacbacb'),(3387,3,2,'bcabcabcabca','acbacbacbacb'),(3388,3,2,'bcabcabcabca','acbacbacbacb'),(3389,3,2,'bcabcabcabca','acbacbacbacb'),(3390,3,2,'bcabcabcabca','acbacbacbacb'),(3391,3,2,'bcabcabcabca','acbacbacbacb'),(3392,3,2,'bcabcabcabca','acbacbacbacb'),(3393,3,2,'bcabcabcabca','acbacbacbacb'),(3394,3,2,'bcabcabcabca','acbacbacbacb'),(3395,3,2,'bcabcabcabca','acbacbacbacb'),(3396,3,2,'bcabcabcabca','acbacbacbacb'),(3397,3,2,'bcabcabcabca','acbacbacbacb'),(3398,3,2,'bcabcabcabca','acbacbacbacb'),(3399,3,2,'bcabcabcabca','acbacbacbacb'),(3400,3,2,'bcabcabcabca','acbacbacbacb'),(3401,3,2,'bcabcabcabca','acbacbacbacb'),(3402,3,2,'bcabcabcabca','acbacbacbacb'),(3403,3,2,'bcabcabcabca','acbacbacbacb'),(3404,3,2,'bcabcabcabca','acbacbacbacb'),(3405,3,2,'bcabcabcabca','acbacbacbacb'),(3406,3,2,'bcabcabcabca','acbacbacbacb'),(3407,3,2,'bcabcabcabca','acbacbacbacb'),(3408,3,2,'bcabcabcabca','acbacbacbacb'),(3409,3,2,'bcabcabcabca','acbacbacbacb'),(3410,3,2,'bcabcabcabca','acbacbacbacb'),(3411,3,2,'bcabcabcabca','acbacbacbacb'),(3412,3,2,'bcabcabcabca','acbacbacbacb'),(3413,3,2,'bcabcabcabca','acbacbacbacb'),(3414,3,2,'bcabcabcabca','acbacbacbacb'),(3415,3,2,'bcabcabcabca','acbacbacbacb'),(3416,3,2,'bcabcabcabca','acbacbacbacb'),(3417,3,2,'bcabcabcabca','acbacbacbacb'),(3418,3,2,'bcabcabcabca','acbacbacbacb'),(3419,3,2,'bcabcabcabca','acbacbacbacb'),(3420,3,2,'bcabcabcabca','acbacbacbacb'),(3421,3,2,'bcabcabcabca','acbacbacbacb'),(3422,3,2,'bcabcabcabca','acbacbacbacb'),(3423,3,2,'bcabcabcabca','acbacbacbacb'),(3424,3,2,'bcabcabcabca','acbacbacbacb'),(3425,3,2,'bcabcabcabca','acbacbacbacb'),(3426,3,2,'bcabcabcabca','acbacbacbacb'),(3427,3,2,'bcabcabcabca','acbacbacbacb'),(3428,3,2,'bcabcabcabca','acbacbacbacb'),(3429,3,2,'bcabcabcabca','acbacbacbacb'),(3430,3,2,'bcabcabcabca','acbacbacbacb'),(3431,3,2,'bcabcabcabca','acbacbacbacb'),(3432,3,2,'bcabcabcabca','acbacbacbacb'),(3433,3,2,'bcabcabcabca','acbacbacbacb'),(3434,3,2,'bcabcabcabca','acbacbacbacb'),(3435,3,2,'bcabcabcabca','acbacbacbacb'),(3436,3,2,'bcabcabcabca','acbacbacbacb'),(3437,3,2,'bcabcabcabca','acbacbacbacb'),(3438,3,2,'bcabcabcabca','acbacbacbacb'),(3439,3,2,'bcabcabcabca','acbacbacbacb'),(3440,3,2,'bcabcabcabca','acbacbacbacb'),(3441,3,2,'bcabcabcabca','acbacbacbacb'),(3442,3,2,'bcabcabcabca','acbacbacbacb'),(3443,3,2,'bcabcabcabca','acbacbacbacb'),(3444,3,2,'bcabcabcabca','acbacbacbacb'),(3445,3,2,'bcabcabcabca','acbacbacbacb'),(3446,3,2,'bcabcabcabca','acbacbacbacb'),(3447,3,2,'bcabcabcabca','acbacbacbacb'),(3448,3,2,'bcabcabcabca','acbacbacbacb'),(3449,3,2,'bcabcabcabca','acbacbacbacb'),(3450,3,2,'bcabcabcabca','acbacbacbacb'),(3451,3,2,'bcabcabcabca','acbacbacbacb'),(3452,3,2,'bcabcabcabca','acbacbacbacb'),(3453,3,2,'bcabcabcabca','acbacbacbacb'),(3454,3,2,'bcabcabcabca','acbacbacbacb'),(3455,3,2,'bcabcabcabca','acbacbacbacb'),(3456,3,2,'bcabcabcabca','acbacbacbacb'),(3457,3,2,'bcabcabcabca','acbacbacbacb'),(3458,3,2,'bcabcabcabca','acbacbacbacb'),(3459,3,2,'bcabcabcabca','acbacbacbacb'),(3460,3,2,'bcabcabcabca','acbacbacbacb'),(3461,3,2,'bcabcabcabca','acbacbacbacb'),(3462,3,2,'bcabcabcabca','acbacbacbacb'),(3463,3,2,'bcabcabcabca','acbacbacbacb'),(3464,3,2,'bcabcabcabca','acbacbacbacb'),(3465,3,2,'bcabcabcabca','acbacbacbacb'),(3466,3,2,'bcabcabcabca','acbacbacbacb'),(3467,3,2,'bcabcabcabca','acbacbacbacb'),(3468,3,2,'bcabcabcabca','acbacbacbacb'),(3469,3,2,'bcabcabcabca','acbacbacbacb'),(3470,3,2,'bcabcabcabca','acbacbacbacb'),(3471,3,2,'bcabcabcabca','acbacbacbacb'),(3472,3,2,'bcabcabcabca','acbacbacbacb'),(3473,3,2,'bcabcabcabca','acbacbacbacb'),(3474,3,2,'bcabcabcabca','acbacbacbacb'),(3475,3,2,'bcabcabcabca','acbacbacbacb'),(3476,3,2,'bcabcabcabca','acbacbacbacb'),(3477,3,2,'bcabcabcabca','acbacbacbacb'),(3478,3,2,'bcabcabcabca','acbacbacbacb'),(3479,3,2,'bcabcabcabca','acbacbacbacb'),(3480,3,2,'bcabcabcabca','acbacbacbacb'),(3481,3,2,'bcabcabcabca','acbacbacbacb'),(3482,3,2,'bcabcabcabca','acbacbacbacb'),(3483,3,2,'bcabcabcabca','acbacbacbacb'),(3484,3,2,'bcabcabcabca','acbacbacbacb'),(3485,3,2,'bcabcabcabca','acbacbacbacb'),(3486,3,2,'bcabcabcabca','acbacbacbacb'),(3487,3,2,'bcabcabcabca','acbacbacbacb'),(3488,3,2,'bcabcabcabca','acbacbacbacb'),(3489,3,2,'bcabcabcabca','acbacbacbacb'),(3490,3,2,'bcabcabcabca','acbacbacbacb'),(3491,3,2,'bcabcabcabca','acbacbacbacb'),(3492,3,2,'bcabcabcabca','acbacbacbacb'),(3493,3,2,'bcabcabcabca','acbacbacbacb'),(3494,3,2,'bcabcabcabca','acbacbacbacb'),(3495,3,2,'bcabcabcabca','acbacbacbacb'),(3496,3,2,'bcabcabcabca','acbacbacbacb'),(3497,3,2,'bcabcabcabca','acbacbacbacb'),(3498,3,2,'bcabcabcabca','acbacbacbacb'),(3499,3,2,'bcabcabcabca','acbacbacbacb'),(3500,3,2,'bcabcabcabca','acbacbacbacb'),(3501,3,2,'bcabcabcabca','acbacbacbacb'),(3502,3,2,'bcabcabcabca','acbacbacbacb'),(3503,3,2,'bcabcabcabca','acbacbacbacb'),(3504,3,2,'bcabcabcabca','acbacbacbacb'),(3505,3,2,'bcabcabcabca','acbacbacbacb'),(3506,3,2,'bcabcabcabca','acbacbacbacb'),(3507,3,2,'bcabcabcabca','acbacbacbacb'),(3508,3,2,'bcabcabcabca','acbacbacbacb'),(3509,3,2,'bcabcabcabca','acbacbacbacb'),(3510,3,2,'bcabcabcabca','acbacbacbacb'),(3511,3,2,'bcabcabcabca','acbacbacbacb'),(3512,3,2,'bcabcabcabca','acbacbacbacb'),(3513,3,2,'bcabcabcabca','acbacbacbacb'),(3514,3,2,'bcabcabcabca','acbacbacbacb'),(3515,3,2,'bcabcabcabca','acbacbacbacb'),(3516,3,2,'bcabcabcabca','acbacbacbacb'),(3517,3,2,'bcabcabcabca','acbacbacbacb'),(3518,3,2,'bcabcabcabca','acbacbacbacb'),(3519,3,2,'bcabcabcabca','acbacbacbacb'),(3520,3,2,'bcabcabcabca','acbacbacbacb'),(3521,3,2,'bcabcabcabca','acbacbacbacb'),(3522,3,2,'bcabcabcabca','acbacbacbacb'),(3523,3,2,'bcabcabcabca','acbacbacbacb'),(3524,3,2,'bcabcabcabca','acbacbacbacb'),(3525,3,2,'bcabcabcabca','acbacbacbacb'),(3526,3,2,'bcabcabcabca','acbacbacbacb'),(3527,3,2,'bcabcabcabca','acbacbacbacb'),(3528,3,2,'bcabcabcabca','acbacbacbacb'),(3529,3,2,'bcabcabcabca','acbacbacbacb'),(3530,3,2,'bcabcabcabca','acbacbacbacb'),(3531,3,2,'bcabcabcabca','acbacbacbacb'),(3532,3,2,'bcabcabcabca','acbacbacbacb'),(3533,3,2,'bcabcabcabca','acbacbacbacb'),(3534,3,2,'bcabcabcabca','acbacbacbacb'),(3535,3,2,'bcabcabcabca','acbacbacbacb'),(3536,3,2,'bcabcabcabca','acbacbacbacb'),(3537,3,2,'bcabcabcabca','acbacbacbacb'),(3538,3,2,'bcabcabcabca','acbacbacbacb'),(3539,3,2,'bcabcabcabca','acbacbacbacb'),(3540,3,2,'bcabcabcabca','acbacbacbacb'),(3541,3,2,'bcabcabcabca','acbacbacbacb'),(3542,3,2,'bcabcabcabca','acbacbacbacb'),(3543,3,2,'bcabcabcabca','acbacbacbacb'),(3544,3,2,'bcabcabcabca','acbacbacbacb'),(3545,3,2,'bcabcabcabca','acbacbacbacb'),(3546,3,2,'bcabcabcabca','acbacbacbacb'),(3547,3,2,'bcabcabcabca','acbacbacbacb'),(3548,3,2,'bcabcabcabca','acbacbacbacb'),(3549,3,2,'bcabcabcabca','acbacbacbacb'),(3550,3,2,'bcabcabcabca','acbacbacbacb'),(3551,3,2,'bcabcabcabca','acbacbacbacb'),(3552,3,2,'bcabcabcabca','acbacbacbacb'),(3553,3,2,'bcabcabcabca','acbacbacbacb'),(3554,3,2,'bcabcabcabca','acbacbacbacb'),(3555,3,2,'bcabcabcabca','acbacbacbacb'),(3556,3,2,'bcabcabcabca','acbacbacbacb'),(3557,3,2,'bcabcabcabca','acbacbacbacb'),(3558,3,2,'bcabcabcabca','acbacbacbacb'),(3559,3,2,'bcabcabcabca','acbacbacbacb'),(3560,3,2,'bcabcabcabca','acbacbacbacb'),(3561,3,2,'bcabcabcabca','acbacbacbacb'),(3562,3,2,'bcabcabcabca','acbacbacbacb'),(3563,3,2,'bcabcabcabca','acbacbacbacb'),(3564,3,2,'bcabcabcabca','acbacbacbacb'),(3565,3,2,'bcabcabcabca','acbacbacbacb'),(3566,3,2,'bcabcabcabca','acbacbacbacb'),(3567,3,2,'bcabcabcabca','acbacbacbacb'),(3568,3,2,'bcabcabcabca','acbacbacbacb'),(3569,3,2,'bcabcabcabca','acbacbacbacb'),(3570,3,2,'bcabcabcabca','acbacbacbacb'),(3571,3,2,'bcabcabcabca','acbacbacbacb'),(3572,3,2,'bcabcabcabca','acbacbacbacb'),(3573,3,2,'bcabcabcabca','acbacbacbacb'),(3574,3,2,'bcabcabcabca','acbacbacbacb'),(3575,3,2,'bcabcabcabca','acbacbacbacb'),(3576,3,2,'bcabcabcabca','acbacbacbacb'),(3577,3,2,'bcabcabcabca','acbacbacbacb'),(3578,3,2,'bcabcabcabca','acbacbacbacb'),(3579,3,2,'bcabcabcabca','acbacbacbacb'),(3580,3,2,'bcabcabcabca','acbacbacbacb'),(3581,3,2,'bcabcabcabca','acbacbacbacb'),(3582,3,2,'bcabcabcabca','acbacbacbacb'),(3583,3,2,'bcabcabcabca','acbacbacbacb'),(3584,3,2,'bcabcabcabca','acbacbacbacb'),(3585,3,2,'bcabcabcabca','acbacbacbacb'),(3586,3,2,'bcabcabcabca','acbacbacbacb'),(3587,3,2,'bcabcabcabca','acbacbacbacb'),(3588,3,2,'bcabcabcabca','acbacbacbacb'),(3589,3,2,'bcabcabcabca','acbacbacbacb'),(3590,3,2,'bcabcabcabca','acbacbacbacb'),(3591,3,2,'bcabcabcabca','acbacbacbacb'),(3592,3,2,'bcabcabcabca','acbacbacbacb'),(3593,3,2,'bcabcabcabca','acbacbacbacb'),(3594,3,2,'bcabcabcabca','acbacbacbacb'),(3595,3,2,'bcabcabcabca','acbacbacbacb'),(3596,3,2,'bcabcabcabca','acbacbacbacb'),(3597,3,2,'bcabcabcabca','acbacbacbacb'),(3598,3,2,'bcabcabcabca','acbacbacbacb'),(3599,3,2,'bcabcabcabca','acbacbacbacb'),(3600,3,2,'bcabcabcabca','acbacbacbacb'),(3601,3,2,'bcabcabcabca','acbacbacbacb'),(3602,3,2,'bcabcabcabca','acbacbacbacb'),(3603,3,2,'bcabcabcabca','acbacbacbacb'),(3604,3,2,'bcabcabcabca','acbacbacbacb'),(3605,3,2,'bcabcabcabca','acbacbacbacb'),(3606,3,2,'bcabcabcabca','acbacbacbacb'),(3607,3,2,'bcabcabcabca','acbacbacbacb'),(3608,3,2,'bcabcabcabca','acbacbacbacb'),(3609,3,2,'bcabcabcabca','acbacbacbacb'),(3610,3,2,'bcabcabcabca','acbacbacbacb'),(3611,3,2,'bcabcabcabca','acbacbacbacb'),(3612,3,2,'bcabcabcabca','acbacbacbacb'),(3613,3,2,'bcabcabcabca','acbacbacbacb'),(3614,3,2,'bcabcabcabca','acbacbacbacb'),(3615,3,2,'bcabcabcabca','acbacbacbacb'),(3616,3,2,'bcabcabcabca','acbacbacbacb'),(3617,3,2,'bcabcabcabca','acbacbacbacb'),(3618,3,2,'bcabcabcabca','acbacbacbacb'),(3619,3,2,'bcabcabcabca','acbacbacbacb'),(3620,3,2,'bcabcabcabca','acbacbacbacb'),(3621,3,2,'bcabcabcabca','acbacbacbacb'),(3622,3,2,'bcabcabcabca','acbacbacbacb'),(3623,3,2,'bcabcabcabca','acbacbacbacb'),(3624,3,2,'bcabcabcabca','acbacbacbacb'),(3625,3,2,'bcabcabcabca','acbacbacbacb'),(3626,3,2,'bcabcabcabca','acbacbacbacb'),(3627,3,2,'bcabcabcabca','acbacbacbacb'),(3628,3,2,'bcabcabcabca','acbacbacbacb'),(3629,3,2,'bcabcabcabca','acbacbacbacb'),(3630,3,2,'bcabcabcabca','acbacbacbacb'),(3631,3,2,'bcabcabcabca','acbacbacbacb'),(3632,3,2,'bcabcabcabca','acbacbacbacb'),(3633,3,2,'bcabcabcabca','acbacbacbacb'),(3634,3,2,'bcabcabcabca','acbacbacbacb'),(3635,3,2,'bcabcabcabca','acbacbacbacb'),(3636,3,2,'bcabcabcabca','acbacbacbacb'),(3637,3,2,'bcabcabcabca','acbacbacbacb'),(3638,3,2,'bcabcabcabca','acbacbacbacb'),(3639,3,2,'bcabcabcabca','acbacbacbacb'),(3640,3,2,'bcabcabcabca','acbacbacbacb'),(3641,3,2,'bcabcabcabca','acbacbacbacb'),(3642,3,2,'bcabcabcabca','acbacbacbacb'),(3643,3,2,'bcabcabcabca','acbacbacbacb'),(3644,3,2,'bcabcabcabca','acbacbacbacb'),(3645,3,2,'bcabcabcabca','acbacbacbacb'),(3646,3,2,'bcabcabcabca','acbacbacbacb'),(3647,3,2,'bcabcabcabca','acbacbacbacb'),(3648,3,2,'bcabcabcabca','acbacbacbacb'),(3649,3,2,'bcabcabcabca','acbacbacbacb'),(3650,3,2,'bcabcabcabca','acbacbacbacb'),(3651,3,2,'bcabcabcabca','acbacbacbacb'),(3652,3,2,'bcabcabcabca','acbacbacbacb'),(3653,3,2,'bcabcabcabca','acbacbacbacb'),(3654,3,2,'bcabcabcabca','acbacbacbacb'),(3655,3,2,'bcabcabcabca','acbacbacbacb'),(3656,3,2,'bcabcabcabca','acbacbacbacb'),(3657,3,2,'bcabcabcabca','acbacbacbacb'),(3658,3,2,'bcabcabcabca','acbacbacbacb'),(3659,3,2,'bcabcabcabca','acbacbacbacb'),(3660,3,2,'bcabcabcabca','acbacbacbacb'),(3661,3,2,'bcabcabcabca','acbacbacbacb'),(3662,3,2,'bcabcabcabca','acbacbacbacb'),(3663,3,2,'bcabcabcabca','acbacbacbacb'),(3664,3,2,'bcabcabcabca','acbacbacbacb'),(3665,3,2,'bcabcabcabca','acbacbacbacb'),(3666,3,2,'bcabcabcabca','acbacbacbacb'),(3667,3,2,'bcabcabcabca','acbacbacbacb'),(3668,3,2,'bcabcabcabca','acbacbacbacb'),(3669,3,2,'bcabcabcabca','acbacbacbacb'),(3670,3,2,'bcabcabcabca','acbacbacbacb'),(3671,3,2,'bcabcabcabca','acbacbacbacb'),(3672,3,2,'bcabcabcabca','acbacbacbacb'),(3673,3,2,'bcabcabcabca','acbacbacbacb'),(3674,3,2,'bcabcabcabca','acbacbacbacb'),(3675,3,2,'bcabcabcabca','acbacbacbacb'),(3676,3,2,'bcabcabcabca','acbacbacbacb'),(3677,3,2,'bcabcabcabca','acbacbacbacb'),(3678,3,2,'bcabcabcabca','acbacbacbacb'),(3679,3,2,'bcabcabcabca','acbacbacbacb'),(3680,3,2,'bcabcabcabca','acbacbacbacb'),(3681,3,2,'bcabcabcabca','acbacbacbacb'),(3682,3,2,'bcabcabcabca','acbacbacbacb'),(3683,3,2,'bcabcabcabca','acbacbacbacb'),(3684,3,2,'bcabcabcabca','acbacbacbacb'),(3685,3,2,'bcabcabcabca','acbacbacbacb'),(3686,3,2,'bcabcabcabca','acbacbacbacb'),(3687,3,2,'bcabcabcabca','acbacbacbacb'),(3688,3,2,'bcabcabcabca','acbacbacbacb'),(3689,3,2,'bcabcabcabca','acbacbacbacb'),(3690,3,2,'bcabcabcabca','acbacbacbacb'),(3691,3,2,'bcabcabcabca','acbacbacbacb'),(3692,3,2,'bcabcabcabca','acbacbacbacb'),(3693,3,2,'bcabcabcabca','acbacbacbacb'),(3694,3,2,'bcabcabcabca','acbacbacbacb'),(3695,3,2,'bcabcabcabca','acbacbacbacb'),(3696,3,2,'bcabcabcabca','acbacbacbacb'),(3697,3,2,'bcabcabcabca','acbacbacbacb'),(3698,3,2,'bcabcabcabca','acbacbacbacb'),(3699,3,2,'bcabcabcabca','acbacbacbacb'),(3700,3,2,'bcabcabcabca','acbacbacbacb'),(3701,3,2,'bcabcabcabca','acbacbacbacb'),(3702,3,2,'bcabcabcabca','acbacbacbacb'),(3703,3,2,'bcabcabcabca','acbacbacbacb'),(3704,3,2,'bcabcabcabca','acbacbacbacb'),(3705,3,2,'bcabcabcabca','acbacbacbacb'),(3706,3,2,'bcabcabcabca','acbacbacbacb'),(3707,3,2,'bcabcabcabca','acbacbacbacb'),(3708,3,2,'bcabcabcabca','acbacbacbacb'),(3709,3,2,'bcabcabcabca','acbacbacbacb'),(3710,3,2,'bcabcabcabca','acbacbacbacb'),(3711,3,2,'bcabcabcabca','acbacbacbacb'),(3712,3,2,'bcabcabcabca','acbacbacbacb'),(3713,3,2,'bcabcabcabca','acbacbacbacb'),(3714,3,2,'bcabcabcabca','acbacbacbacb'),(3715,3,2,'bcabcabcabca','acbacbacbacb'),(3716,3,2,'bcabcabcabca','acbacbacbacb'),(3717,3,2,'bcabcabcabca','acbacbacbacb'),(3718,3,2,'bcabcabcabca','acbacbacbacb'),(3719,3,2,'bcabcabcabca','acbacbacbacb'),(3720,3,2,'bcabcabcabca','acbacbacbacb'),(3721,3,2,'bcabcabcabca','acbacbacbacb'),(3722,3,2,'bcabcabcabca','acbacbacbacb'),(3723,3,2,'bcabcabcabca','acbacbacbacb'),(3724,3,2,'bcabcabcabca','acbacbacbacb'),(3725,3,2,'bcabcabcabca','acbacbacbacb'),(3726,3,2,'bcabcabcabca','acbacbacbacb'),(3727,3,2,'bcabcabcabca','acbacbacbacb'),(3728,3,2,'bcabcabcabca','acbacbacbacb'),(3729,3,2,'bcabcabcabca','acbacbacbacb'),(3730,3,2,'bcabcabcabca','acbacbacbacb'),(3731,3,2,'bcabcabcabca','acbacbacbacb'),(3732,3,2,'bcabcabcabca','acbacbacbacb'),(3733,3,2,'bcabcabcabca','acbacbacbacb'),(3734,3,2,'bcabcabcabca','acbacbacbacb'),(3735,3,2,'bcabcabcabca','acbacbacbacb'),(3736,3,2,'bcabcabcabca','acbacbacbacb'),(3737,3,2,'bcabcabcabca','acbacbacbacb'),(3738,3,2,'bcabcabcabca','acbacbacbacb'),(3739,3,2,'bcabcabcabca','acbacbacbacb'),(3740,3,2,'bcabcabcabca','acbacbacbacb'),(3741,3,2,'bcabcabcabca','acbacbacbacb'),(3742,3,2,'bcabcabcabca','acbacbacbacb'),(3743,3,2,'bcabcabcabca','acbacbacbacb'),(3744,3,2,'bcabcabcabca','acbacbacbacb'),(3745,3,2,'bcabcabcabca','acbacbacbacb'),(3746,3,2,'bcabcabcabca','acbacbacbacb'),(3747,3,2,'bcabcabcabca','acbacbacbacb'),(3748,3,2,'bcabcabcabca','acbacbacbacb'),(3749,3,2,'bcabcabcabca','acbacbacbacb'),(3750,3,2,'bcabcabcabca','acbacbacbacb'),(3751,3,2,'bcabcabcabca','acbacbacbacb'),(3752,3,2,'bcabcabcabca','acbacbacbacb'),(3753,3,2,'bcabcabcabca','acbacbacbacb'),(3754,3,2,'bcabcabcabca','acbacbacbacb'),(3755,3,2,'bcabcabcabca','acbacbacbacb'),(3756,3,2,'bcabcabcabca','acbacbacbacb'),(3757,3,2,'bcabcabcabca','acbacbacbacb'),(3758,3,2,'bcabcabcabca','acbacbacbacb'),(3759,3,2,'bcabcabcabca','acbacbacbacb'),(3760,3,2,'bcabcabcabca','acbacbacbacb'),(3761,3,2,'bcabcabcabca','acbacbacbacb'),(3762,3,2,'bcabcabcabca','acbacbacbacb'),(3763,3,2,'bcabcabcabca','acbacbacbacb'),(3764,3,2,'bcabcabcabca','acbacbacbacb'),(3765,3,2,'bcabcabcabca','acbacbacbacb'),(3766,3,2,'bcabcabcabca','acbacbacbacb'),(3767,3,2,'bcabcabcabca','acbacbacbacb'),(3768,3,2,'bcabcabcabca','acbacbacbacb'),(3769,3,2,'bcabcabcabca','acbacbacbacb'),(3770,3,2,'bcabcabcabca','acbacbacbacb'),(3771,3,2,'bcabcabcabca','acbacbacbacb'),(3772,3,2,'bcabcabcabca','acbacbacbacb'),(3773,3,2,'bcabcabcabca','acbacbacbacb'),(3774,3,2,'bcabcabcabca','acbacbacbacb'),(3775,3,2,'bcabcabcabca','acbacbacbacb'),(3776,3,2,'bcabcabcabca','acbacbacbacb'),(3777,3,2,'bcabcabcabca','acbacbacbacb'),(3778,3,2,'bcabcabcabca','acbacbacbacb'),(3779,3,2,'bcabcabcabca','acbacbacbacb'),(3780,3,2,'bcabcabcabca','acbacbacbacb'),(3781,3,2,'bcabcabcabca','acbacbacbacb'),(3782,3,2,'bcabcabcabca','acbacbacbacb'),(3783,3,2,'bcabcabcabca','acbacbacbacb'),(3784,3,2,'bcabcabcabca','acbacbacbacb'),(3785,3,2,'bcabcabcabca','acbacbacbacb'),(3786,3,2,'bcabcabcabca','acbacbacbacb'),(3787,3,2,'bcabcabcabca','acbacbacbacb'),(3788,3,2,'bcabcabcabca','acbacbacbacb'),(3789,3,2,'bcabcabcabca','acbacbacbacb'),(3790,3,2,'bcabcabcabca','acbacbacbacb'),(3791,3,2,'bcabcabcabca','acbacbacbacb'),(3792,3,2,'bcabcabcabca','acbacbacbacb'),(3793,3,2,'bcabcabcabca','acbacbacbacb'),(3794,3,2,'bcabcabcabca','acbacbacbacb'),(3795,3,2,'bcabcabcabca','acbacbacbacb'),(3796,3,2,'bcabcabcabca','acbacbacbacb'),(3797,3,2,'bcabcabcabca','acbacbacbacb'),(3798,3,2,'bcabcabcabca','acbacbacbacb'),(3799,3,2,'bcabcabcabca','acbacbacbacb'),(3800,3,2,'bcabcabcabca','acbacbacbacb'),(3801,3,2,'bcabcabcabca','acbacbacbacb'),(3802,3,2,'bcabcabcabca','acbacbacbacb'),(3803,3,2,'bcabcabcabca','acbacbacbacb'),(3804,3,2,'bcabcabcabca','acbacbacbacb'),(3805,3,2,'bcabcabcabca','acbacbacbacb'),(3806,3,2,'bcabcabcabca','acbacbacbacb'),(3807,3,2,'bcabcabcabca','acbacbacbacb'),(3808,3,2,'bcabcabcabca','acbacbacbacb'),(3809,3,2,'bcabcabcabca','acbacbacbacb'),(3810,3,2,'bcabcabcabca','acbacbacbacb'),(3811,3,2,'bcabcabcabca','acbacbacbacb'),(3812,3,2,'bcabcabcabca','acbacbacbacb'),(3813,3,2,'bcabcabcabca','acbacbacbacb'),(3814,3,2,'bcabcabcabca','acbacbacbacb'),(3815,3,2,'bcabcabcabca','acbacbacbacb'),(3816,3,2,'bcabcabcabca','acbacbacbacb'),(3817,3,2,'bcabcabcabca','acbacbacbacb'),(3818,3,2,'bcabcabcabca','acbacbacbacb'),(3819,3,2,'bcabcabcabca','acbacbacbacb'),(3820,3,2,'bcabcabcabca','acbacbacbacb'),(3821,3,2,'bcabcabcabca','acbacbacbacb'),(3822,3,2,'bcabcabcabca','acbacbacbacb'),(3823,3,2,'bcabcabcabca','acbacbacbacb'),(3824,3,2,'bcabcabcabca','acbacbacbacb'),(3825,3,2,'bcabcabcabca','acbacbacbacb'),(3826,3,2,'bcabcabcabca','acbacbacbacb'),(3827,3,2,'bcabcabcabca','acbacbacbacb'),(3828,3,2,'bcabcabcabca','acbacbacbacb'),(3829,3,2,'bcabcabcabca','acbacbacbacb'),(3830,3,2,'bcabcabcabca','acbacbacbacb'),(3831,3,2,'bcabcabcabca','acbacbacbacb'),(3832,3,2,'bcabcabcabca','acbacbacbacb'),(3833,3,2,'bcabcabcabca','acbacbacbacb'),(3834,3,2,'bcabcabcabca','acbacbacbacb'),(3835,3,2,'bcabcabcabca','acbacbacbacb'),(3836,3,2,'bcabcabcabca','acbacbacbacb'),(3837,3,2,'bcabcabcabca','acbacbacbacb'),(3838,3,2,'bcabcabcabca','acbacbacbacb'),(3839,3,2,'bcabcabcabca','acbacbacbacb'),(3840,3,2,'bcabcabcabca','acbacbacbacb'),(3841,3,2,'bcabcabcabca','acbacbacbacb'),(3842,3,2,'bcabcabcabca','acbacbacbacb'),(3843,3,2,'bcabcabcabca','acbacbacbacb'),(3844,3,2,'bcabcabcabca','acbacbacbacb'),(3845,3,2,'bcabcabcabca','acbacbacbacb'),(3846,3,2,'bcabcabcabca','acbacbacbacb'),(3847,3,2,'bcabcabcabca','acbacbacbacb'),(3848,3,2,'bcabcabcabca','acbacbacbacb'),(3849,3,2,'bcabcabcabca','acbacbacbacb'),(3850,3,2,'bcabcabcabca','acbacbacbacb'),(3851,3,2,'bcabcabcabca','acbacbacbacb'),(3852,3,2,'bcabcabcabca','acbacbacbacb'),(3853,3,2,'bcabcabcabca','acbacbacbacb'),(3854,3,2,'bcabcabcabca','acbacbacbacb'),(3855,3,2,'bcabcabcabca','acbacbacbacb'),(3856,3,2,'bcabcabcabca','acbacbacbacb'),(3857,3,2,'bcabcabcabca','acbacbacbacb'),(3858,3,2,'bcabcabcabca','acbacbacbacb'),(3859,3,2,'bcabcabcabca','acbacbacbacb'),(3860,3,2,'bcabcabcabca','acbacbacbacb'),(3861,3,2,'bcabcabcabca','acbacbacbacb'),(3862,3,2,'bcabcabcabca','acbacbacbacb'),(3863,3,2,'bcabcabcabca','acbacbacbacb'),(3864,3,2,'bcabcabcabca','acbacbacbacb'),(3865,3,2,'bcabcabcabca','acbacbacbacb'),(3866,3,2,'bcabcabcabca','acbacbacbacb'),(3867,3,2,'bcabcabcabca','acbacbacbacb'),(3868,3,2,'bcabcabcabca','acbacbacbacb'),(3869,3,2,'bcabcabcabca','acbacbacbacb'),(3870,3,2,'bcabcabcabca','acbacbacbacb'),(3871,3,2,'bcabcabcabca','acbacbacbacb'),(3872,3,2,'bcabcabcabca','acbacbacbacb'),(3873,3,2,'bcabcabcabca','acbacbacbacb'),(3874,3,2,'bcabcabcabca','acbacbacbacb'),(3875,3,2,'bcabcabcabca','acbacbacbacb'),(3876,3,2,'bcabcabcabca','acbacbacbacb'),(3877,3,2,'bcabcabcabca','acbacbacbacb'),(3878,3,2,'bcabcabcabca','acbacbacbacb'),(3879,3,2,'bcabcabcabca','acbacbacbacb'),(3880,3,2,'bcabcabcabca','acbacbacbacb'),(3881,3,2,'bcabcabcabca','acbacbacbacb'),(3882,3,2,'bcabcabcabca','acbacbacbacb'),(3883,3,2,'bcabcabcabca','acbacbacbacb'),(3884,3,2,'bcabcabcabca','acbacbacbacb'),(3885,3,2,'bcabcabcabca','acbacbacbacb'),(3886,3,2,'bcabcabcabca','acbacbacbacb'),(3887,3,2,'bcabcabcabca','acbacbacbacb'),(3888,3,2,'bcabcabcabca','acbacbacbacb'),(3889,3,2,'bcabcabcabca','acbacbacbacb'),(3890,3,2,'bcabcabcabca','acbacbacbacb'),(3891,3,2,'bcabcabcabca','acbacbacbacb'),(3892,3,2,'bcabcabcabca','acbacbacbacb'),(3893,3,2,'bcabcabcabca','acbacbacbacb'),(3894,3,2,'bcabcabcabca','acbacbacbacb'),(3895,3,2,'bcabcabcabca','acbacbacbacb'),(3896,3,2,'bcabcabcabca','acbacbacbacb'),(3897,3,2,'bcabcabcabca','acbacbacbacb'),(3898,3,2,'bcabcabcabca','acbacbacbacb'),(3899,3,2,'bcabcabcabca','acbacbacbacb'),(3900,3,2,'bcabcabcabca','acbacbacbacb'),(3901,3,2,'bcabcabcabca','acbacbacbacb'),(3902,3,2,'bcabcabcabca','acbacbacbacb'),(3903,3,2,'bcabcabcabca','acbacbacbacb'),(3904,3,2,'bcabcabcabca','acbacbacbacb'),(3905,3,2,'bcabcabcabca','acbacbacbacb'),(3906,3,2,'bcabcabcabca','acbacbacbacb'),(3907,3,2,'bcabcabcabca','acbacbacbacb'),(3908,3,2,'bcabcabcabca','acbacbacbacb'),(3909,3,2,'bcabcabcabca','acbacbacbacb'),(3910,3,2,'bcabcabcabca','acbacbacbacb'),(3911,3,2,'bcabcabcabca','acbacbacbacb'),(3912,3,2,'bcabcabcabca','acbacbacbacb'),(3913,3,2,'bcabcabcabca','acbacbacbacb'),(3914,3,2,'bcabcabcabca','acbacbacbacb'),(3915,3,2,'bcabcabcabca','acbacbacbacb'),(3916,3,2,'bcabcabcabca','acbacbacbacb'),(3917,3,2,'bcabcabcabca','acbacbacbacb'),(3918,3,2,'bcabcabcabca','acbacbacbacb'),(3919,3,2,'bcabcabcabca','acbacbacbacb'),(3920,3,2,'bcabcabcabca','acbacbacbacb'),(3921,3,2,'bcabcabcabca','acbacbacbacb'),(3922,3,2,'bcabcabcabca','acbacbacbacb'),(3923,3,2,'bcabcabcabca','acbacbacbacb'),(3924,3,2,'bcabcabcabca','acbacbacbacb'),(3925,3,2,'bcabcabcabca','acbacbacbacb'),(3926,3,2,'bcabcabcabca','acbacbacbacb'),(3927,3,2,'bcabcabcabca','acbacbacbacb'),(3928,3,2,'bcabcabcabca','acbacbacbacb'),(3929,3,2,'bcabcabcabca','acbacbacbacb'),(3930,3,2,'bcabcabcabca','acbacbacbacb'),(3931,3,2,'bcabcabcabca','acbacbacbacb'),(3932,3,2,'bcabcabcabca','acbacbacbacb'),(3933,3,2,'bcabcabcabca','acbacbacbacb'),(3934,3,2,'bcabcabcabca','acbacbacbacb'),(3935,3,2,'bcabcabcabca','acbacbacbacb'),(3936,3,2,'bcabcabcabca','acbacbacbacb'),(3937,3,2,'bcabcabcabca','acbacbacbacb'),(3938,3,2,'bcabcabcabca','acbacbacbacb'),(3939,3,2,'bcabcabcabca','acbacbacbacb'),(3940,3,2,'bcabcabcabca','acbacbacbacb'),(3941,3,2,'bcabcabcabca','acbacbacbacb'),(3942,3,2,'bcabcabcabca','acbacbacbacb'),(3943,3,2,'bcabcabcabca','acbacbacbacb'),(3944,3,2,'bcabcabcabca','acbacbacbacb'),(3945,3,2,'bcabcabcabca','acbacbacbacb'),(3946,3,2,'bcabcabcabca','acbacbacbacb'),(3947,3,2,'bcabcabcabca','acbacbacbacb'),(3948,3,2,'bcabcabcabca','acbacbacbacb'),(3949,3,2,'bcabcabcabca','acbacbacbacb'),(3950,3,2,'bcabcabcabca','acbacbacbacb'),(3951,3,2,'bcabcabcabca','acbacbacbacb'),(3952,3,2,'bcabcabcabca','acbacbacbacb'),(3953,3,2,'bcabcabcabca','acbacbacbacb'),(3954,3,2,'bcabcabcabca','acbacbacbacb'),(3955,3,2,'bcabcabcabca','acbacbacbacb'),(3956,3,2,'bcabcabcabca','acbacbacbacb'),(3957,3,2,'bcabcabcabca','acbacbacbacb'),(3958,3,2,'bcabcabcabca','acbacbacbacb'),(3959,3,2,'bcabcabcabca','acbacbacbacb'),(3960,3,2,'bcabcabcabca','acbacbacbacb'),(3961,3,2,'bcabcabcabca','acbacbacbacb'),(3962,3,2,'bcabcabcabca','acbacbacbacb'),(3963,3,2,'bcabcabcabca','acbacbacbacb'),(3964,3,2,'bcabcabcabca','acbacbacbacb'),(3965,3,2,'bcabcabcabca','acbacbacbacb'),(3966,3,2,'bcabcabcabca','acbacbacbacb'),(3967,3,2,'bcabcabcabca','acbacbacbacb'),(3968,3,2,'bcabcabcabca','acbacbacbacb'),(3969,3,2,'bcabcabcabca','acbacbacbacb'),(3970,3,2,'bcabcabcabca','acbacbacbacb'),(3971,3,2,'bcabcabcabca','acbacbacbacb'),(3972,3,2,'bcabcabcabca','acbacbacbacb'),(3973,3,2,'bcabcabcabca','acbacbacbacb'),(3974,3,2,'bcabcabcabca','acbacbacbacb'),(3975,3,2,'bcabcabcabca','acbacbacbacb'),(3976,3,2,'bcabcabcabca','acbacbacbacb'),(3977,3,2,'bcabcabcabca','acbacbacbacb'),(3978,3,2,'bcabcabcabca','acbacbacbacb'),(3979,3,2,'bcabcabcabca','acbacbacbacb'),(3980,3,2,'bcabcabcabca','acbacbacbacb'),(3981,3,2,'bcabcabcabca','acbacbacbacb'),(3982,3,2,'bcabcabcabca','acbacbacbacb'),(3983,3,2,'bcabcabcabca','acbacbacbacb'),(3984,3,2,'bcabcabcabca','acbacbacbacb'),(3985,3,2,'bcabcabcabca','acbacbacbacb'),(3986,3,2,'bcabcabcabca','acbacbacbacb'),(3987,3,2,'bcabcabcabca','acbacbacbacb'),(3988,3,2,'bcabcabcabca','acbacbacbacb'),(3989,3,2,'bcabcabcabca','acbacbacbacb'),(3990,3,2,'bcabcabcabca','acbacbacbacb'),(3991,3,2,'bcabcabcabca','acbacbacbacb'),(3992,3,2,'bcabcabcabca','acbacbacbacb'),(3993,3,2,'bcabcabcabca','acbacbacbacb'),(3994,3,2,'bcabcabcabca','acbacbacbacb'),(3995,3,2,'bcabcabcabca','acbacbacbacb'),(3996,3,2,'bcabcabcabca','acbacbacbacb'),(3997,3,2,'bcabcabcabca','acbacbacbacb'),(3998,3,2,'bcabcabcabca','acbacbacbacb'),(3999,3,2,'bcabcabcabca','acbacbacbacb'),(4000,3,2,'bcabcabcabca','acbacbacbacb'),(4001,3,2,'bcabcabcabca','acbacbacbacb'),(4002,3,2,'bcabcabcabca','acbacbacbacb'),(4003,3,2,'bcabcabcabca','acbacbacbacb'),(4004,3,2,'bcabcabcabca','acbacbacbacb'),(4005,3,2,'bcabcabcabca','acbacbacbacb'),(4006,3,2,'bcabcabcabca','acbacbacbacb'),(4007,3,2,'bcabcabcabca','acbacbacbacb'),(4008,3,2,'bcabcabcabca','acbacbacbacb'),(4009,3,2,'bcabcabcabca','acbacbacbacb'),(4010,3,2,'bcabcabcabca','acbacbacbacb'),(4011,3,2,'bcabcabcabca','acbacbacbacb'),(4012,3,2,'bcabcabcabca','acbacbacbacb'),(4013,3,2,'bcabcabcabca','acbacbacbacb'),(4014,3,2,'bcabcabcabca','acbacbacbacb'),(4015,3,2,'bcabcabcabca','acbacbacbacb'),(4016,3,2,'bcabcabcabca','acbacbacbacb'),(4017,3,2,'bcabcabcabca','acbacbacbacb'),(4018,3,2,'bcabcabcabca','acbacbacbacb'),(4019,3,2,'bcabcabcabca','acbacbacbacb'),(4020,3,2,'bcabcabcabca','acbacbacbacb'),(4021,3,2,'bcabcabcabca','acbacbacbacb'),(4022,3,2,'bcabcabcabca','acbacbacbacb'),(4023,3,2,'bcabcabcabca','acbacbacbacb'),(4024,3,2,'bcabcabcabca','acbacbacbacb'),(4025,3,2,'bcabcabcabca','acbacbacbacb'),(4026,3,2,'bcabcabcabca','acbacbacbacb'),(4027,3,2,'bcabcabcabca','acbacbacbacb'),(4028,3,2,'bcabcabcabca','acbacbacbacb'),(4029,3,2,'bcabcabcabca','acbacbacbacb'),(4030,3,2,'bcabcabcabca','acbacbacbacb'),(4031,3,2,'bcabcabcabca','acbacbacbacb'),(4032,3,2,'bcabcabcabca','acbacbacbacb'),(4033,3,2,'bcabcabcabca','acbacbacbacb'),(4034,3,2,'bcabcabcabca','acbacbacbacb'),(4035,3,2,'bcabcabcabca','acbacbacbacb'),(4036,3,2,'bcabcabcabca','acbacbacbacb'),(4037,3,2,'bcabcabcabca','acbacbacbacb'),(4038,3,2,'bcabcabcabca','acbacbacbacb'),(4039,3,2,'bcabcabcabca','acbacbacbacb'),(4040,3,2,'bcabcabcabca','acbacbacbacb'),(4041,3,2,'bcabcabcabca','acbacbacbacb'),(4042,3,2,'bcabcabcabca','acbacbacbacb'),(4043,3,2,'bcabcabcabca','acbacbacbacb'),(4044,3,2,'bcabcabcabca','acbacbacbacb'),(4045,3,2,'bcabcabcabca','acbacbacbacb'),(4046,3,2,'bcabcabcabca','acbacbacbacb'),(4047,3,2,'bcabcabcabca','acbacbacbacb'),(4048,3,2,'bcabcabcabca','acbacbacbacb'),(4049,3,2,'bcabcabcabca','acbacbacbacb'),(4050,3,2,'bcabcabcabca','acbacbacbacb'),(4051,3,2,'bcabcabcabca','acbacbacbacb'),(4052,3,2,'bcabcabcabca','acbacbacbacb'),(4053,3,2,'bcabcabcabca','acbacbacbacb'),(4054,3,2,'bcabcabcabca','acbacbacbacb'),(4055,3,2,'bcabcabcabca','acbacbacbacb'),(4056,3,2,'bcabcabcabca','acbacbacbacb'),(4057,3,2,'bcabcabcabca','acbacbacbacb'),(4058,3,2,'bcabcabcabca','acbacbacbacb'),(4059,3,2,'bcabcabcabca','acbacbacbacb'),(4060,3,2,'bcabcabcabca','acbacbacbacb'),(4061,3,2,'bcabcabcabca','acbacbacbacb'),(4062,3,2,'bcabcabcabca','acbacbacbacb'),(4063,3,2,'bcabcabcabca','acbacbacbacb'),(4064,3,2,'bcabcabcabca','acbacbacbacb'),(4065,3,2,'bcabcabcabca','acbacbacbacb'),(4066,3,2,'bcabcabcabca','acbacbacbacb'),(4067,3,2,'bcabcabcabca','acbacbacbacb'),(4068,3,2,'bcabcabcabca','acbacbacbacb'),(4069,3,2,'bcabcabcabca','acbacbacbacb'),(4070,3,2,'bcabcabcabca','acbacbacbacb'),(4071,3,2,'bcabcabcabca','acbacbacbacb'),(4072,3,2,'bcabcabcabca','acbacbacbacb'),(4073,3,2,'bcabcabcabca','acbacbacbacb'),(4074,3,2,'bcabcabcabca','acbacbacbacb'),(4075,3,2,'bcabcabcabca','acbacbacbacb'),(4076,3,2,'bcabcabcabca','acbacbacbacb'),(4077,3,2,'bcabcabcabca','acbacbacbacb'),(4078,3,2,'bcabcabcabca','acbacbacbacb'),(4079,3,2,'bcabcabcabca','acbacbacbacb'),(4080,3,2,'bcabcabcabca','acbacbacbacb'),(4081,3,2,'bcabcabcabca','acbacbacbacb'),(4082,3,2,'bcabcabcabca','acbacbacbacb'),(4083,3,2,'bcabcabcabca','acbacbacbacb'),(4084,3,2,'bcabcabcabca','acbacbacbacb'),(4085,3,2,'bcabcabcabca','acbacbacbacb'),(4086,3,2,'bcabcabcabca','acbacbacbacb'),(4087,3,4,'cbacbacbacba','abcabcabcabc'),(4088,3,4,'cbacbacbacba','abcabcabcabc'),(4089,3,4,'cbacbacbacba','abcabcabcabc'),(4090,3,4,'cbacbacbacba','abcabcabcabc'),(4091,3,4,'cbacbacbacba','abcabcabcabc'),(4092,3,4,'cbacbacbacba','abcabcabcabc'),(4093,3,4,'cbacbacbacba','abcabcabcabc'),(4094,3,4,'cbacbacbacba','abcabcabcabc'),(4095,3,4,'cbacbacbacba','abcabcabcabc'),(4096,3,4,'cbacbacbacba','abcabcabcabc'),(4097,3,4,'cbacbacbacba','abcabcabcabc'),(4098,3,4,'cbacbacbacba','abcabcabcabc'),(4099,3,4,'cbacbacbacba','abcabcabcabc'),(4100,3,4,'cbacbacbacba','abcabcabcabc'),(4101,3,4,'cbacbacbacba','abcabcabcabc'),(4102,3,4,'cbacbacbacba','abcabcabcabc'),(4103,3,4,'cbacbacbacba','abcabcabcabc'),(4104,3,4,'cbacbacbacba','abcabcabcabc'),(4105,3,4,'cbacbacbacba','abcabcabcabc'),(4106,3,4,'cbacbacbacba','abcabcabcabc'),(4107,3,4,'cbacbacbacba','abcabcabcabc'),(4108,3,4,'cbacbacbacba','abcabcabcabc'),(4109,3,4,'cbacbacbacba','abcabcabcabc'),(4110,3,4,'cbacbacbacba','abcabcabcabc'),(4111,3,4,'cbacbacbacba','abcabcabcabc'),(4112,3,4,'cbacbacbacba','abcabcabcabc'),(4113,3,4,'cbacbacbacba','abcabcabcabc'),(4114,3,4,'cbacbacbacba','abcabcabcabc'),(4115,3,4,'cbacbacbacba','abcabcabcabc'),(4116,3,4,'cbacbacbacba','abcabcabcabc'),(4117,3,4,'cbacbacbacba','abcabcabcabc'),(4118,3,4,'cbacbacbacba','abcabcabcabc'),(4119,3,4,'cbacbacbacba','abcabcabcabc'),(4120,3,4,'cbacbacbacba','abcabcabcabc'),(4121,3,4,'cbacbacbacba','abcabcabcabc'),(4122,3,4,'cbacbacbacba','abcabcabcabc'),(4123,3,4,'cbacbacbacba','abcabcabcabc'),(4124,3,4,'cbacbacbacba','abcabcabcabc'),(4125,3,4,'cbacbacbacba','abcabcabcabc'),(4126,3,4,'cbacbacbacba','abcabcabcabc'),(4127,3,4,'cbacbacbacba','abcabcabcabc'),(4128,3,4,'cbacbacbacba','abcabcabcabc'),(4129,3,4,'cbacbacbacba','abcabcabcabc'),(4130,3,4,'cbacbacbacba','abcabcabcabc'),(4131,3,4,'cbacbacbacba','abcabcabcabc'),(4132,3,4,'cbacbacbacba','abcabcabcabc'),(4133,3,4,'cbacbacbacba','abcabcabcabc'),(4134,3,4,'cbacbacbacba','abcabcabcabc'),(4135,3,4,'cbacbacbacba','abcabcabcabc'),(4136,3,4,'cbacbacbacba','abcabcabcabc'),(4137,3,4,'cbacbacbacba','abcabcabcabc'),(4138,3,4,'cbacbacbacba','abcabcabcabc'),(4139,3,4,'cbacbacbacba','abcabcabcabc'),(4140,3,4,'cbacbacbacba','abcabcabcabc'),(4141,3,4,'cbacbacbacba','abcabcabcabc'),(4142,3,4,'cbacbacbacba','abcabcabcabc'),(4143,3,4,'cbacbacbacba','abcabcabcabc'),(4144,3,4,'cbacbacbacba','abcabcabcabc'),(4145,3,4,'cbacbacbacba','abcabcabcabc'),(4146,3,4,'cbacbacbacba','abcabcabcabc'),(4147,3,4,'cbacbacbacba','abcabcabcabc'),(4148,3,4,'cbacbacbacba','abcabcabcabc'),(4149,3,4,'cbacbacbacba','abcabcabcabc'),(4150,3,4,'cbacbacbacba','abcabcabcabc'),(4151,3,4,'cbacbacbacba','abcabcabcabc'),(4152,3,4,'cbacbacbacba','abcabcabcabc'),(4153,3,4,'cbacbacbacba','abcabcabcabc'),(4154,3,4,'cbacbacbacba','abcabcabcabc'),(4155,3,4,'cbacbacbacba','abcabcabcabc'),(4156,3,4,'cbacbacbacba','abcabcabcabc'),(4157,3,4,'cbacbacbacba','abcabcabcabc'),(4158,3,4,'cbacbacbacba','abcabcabcabc'),(4159,3,4,'cbacbacbacba','abcabcabcabc'),(4160,3,4,'cbacbacbacba','abcabcabcabc'),(4161,3,4,'cbacbacbacba','abcabcabcabc'),(4162,3,4,'cbacbacbacba','abcabcabcabc'),(4163,3,4,'cbacbacbacba','abcabcabcabc'),(4164,3,4,'cbacbacbacba','abcabcabcabc'),(4165,3,4,'cbacbacbacba','abcabcabcabc'),(4166,3,4,'cbacbacbacba','abcabcabcabc'),(4167,3,4,'cbacbacbacba','abcabcabcabc'),(4168,3,4,'cbacbacbacba','abcabcabcabc'),(4169,3,4,'cbacbacbacba','abcabcabcabc'),(4170,3,4,'cbacbacbacba','abcabcabcabc'),(4171,3,4,'cbacbacbacba','abcabcabcabc'),(4172,3,4,'cbacbacbacba','abcabcabcabc'),(4173,3,4,'cbacbacbacba','abcabcabcabc'),(4174,3,4,'cbacbacbacba','abcabcabcabc'),(4175,3,4,'cbacbacbacba','abcabcabcabc'),(4176,3,4,'cbacbacbacba','abcabcabcabc'),(4177,3,4,'cbacbacbacba','abcabcabcabc'),(4178,3,4,'cbacbacbacba','abcabcabcabc'),(4179,3,4,'cbacbacbacba','abcabcabcabc'),(4180,3,4,'cbacbacbacba','abcabcabcabc'),(4181,3,4,'cbacbacbacba','abcabcabcabc'),(4182,3,4,'cbacbacbacba','abcabcabcabc'),(4183,3,4,'cbacbacbacba','abcabcabcabc'),(4184,3,4,'cbacbacbacba','abcabcabcabc'),(4185,3,4,'cbacbacbacba','abcabcabcabc'),(4186,3,4,'cbacbacbacba','abcabcabcabc'),(4187,3,4,'cbacbacbacba','abcabcabcabc'),(4188,3,4,'cbacbacbacba','abcabcabcabc'),(4189,3,4,'cbacbacbacba','abcabcabcabc'),(4190,3,4,'cbacbacbacba','abcabcabcabc'),(4191,3,4,'cbacbacbacba','abcabcabcabc'),(4192,3,4,'cbacbacbacba','abcabcabcabc'),(4193,3,4,'cbacbacbacba','abcabcabcabc'),(4194,3,4,'cbacbacbacba','abcabcabcabc'),(4195,3,4,'cbacbacbacba','abcabcabcabc'),(4196,3,4,'cbacbacbacba','abcabcabcabc'),(4197,3,4,'cbacbacbacba','abcabcabcabc'),(4198,3,4,'cbacbacbacba','abcabcabcabc'),(4199,3,4,'cbacbacbacba','abcabcabcabc'),(4200,3,4,'cbacbacbacba','abcabcabcabc'),(4201,3,4,'cbacbacbacba','abcabcabcabc'),(4202,3,4,'cbacbacbacba','abcabcabcabc'),(4203,3,4,'cbacbacbacba','abcabcabcabc'),(4204,3,4,'cbacbacbacba','abcabcabcabc'),(4205,3,4,'cbacbacbacba','abcabcabcabc'),(4206,3,4,'cbacbacbacba','abcabcabcabc'),(4207,3,4,'cbacbacbacba','abcabcabcabc'),(4208,3,4,'cbacbacbacba','abcabcabcabc'),(4209,3,4,'cbacbacbacba','abcabcabcabc'),(4210,3,4,'cbacbacbacba','abcabcabcabc'),(4211,3,4,'cbacbacbacba','abcabcabcabc'),(4212,3,4,'cbacbacbacba','abcabcabcabc'),(4213,3,4,'cbacbacbacba','abcabcabcabc'),(4214,3,4,'cbacbacbacba','abcabcabcabc'),(4215,3,4,'cbacbacbacba','abcabcabcabc'),(4216,3,4,'cbacbacbacba','abcabcabcabc'),(4217,3,4,'cbacbacbacba','abcabcabcabc'),(4218,3,4,'cbacbacbacba','abcabcabcabc'),(4219,3,4,'cbacbacbacba','abcabcabcabc'),(4220,3,4,'cbacbacbacba','abcabcabcabc'),(4221,3,4,'cbacbacbacba','abcabcabcabc'),(4222,3,4,'cbacbacbacba','abcabcabcabc'),(4223,3,4,'cbacbacbacba','abcabcabcabc'),(4224,3,4,'cbacbacbacba','abcabcabcabc'),(4225,3,4,'cbacbacbacba','abcabcabcabc'),(4226,3,4,'cbacbacbacba','abcabcabcabc'),(4227,3,4,'cbacbacbacba','abcabcabcabc'),(4228,3,4,'cbacbacbacba','abcabcabcabc'),(4229,3,4,'cbacbacbacba','abcabcabcabc'),(4230,3,4,'cbacbacbacba','abcabcabcabc'),(4231,3,4,'cbacbacbacba','abcabcabcabc'),(4232,3,4,'cbacbacbacba','abcabcabcabc'),(4233,3,4,'cbacbacbacba','abcabcabcabc'),(4234,3,4,'cbacbacbacba','abcabcabcabc'),(4235,3,4,'cbacbacbacba','abcabcabcabc'),(4236,3,4,'cbacbacbacba','abcabcabcabc'),(4237,3,4,'cbacbacbacba','abcabcabcabc'),(4238,3,4,'cbacbacbacba','abcabcabcabc'),(4239,3,4,'cbacbacbacba','abcabcabcabc'),(4240,3,4,'cbacbacbacba','abcabcabcabc'),(4241,3,4,'cbacbacbacba','abcabcabcabc'),(4242,3,4,'cbacbacbacba','abcabcabcabc'),(4243,3,4,'cbacbacbacba','abcabcabcabc'),(4244,3,4,'cbacbacbacba','abcabcabcabc'),(4245,3,4,'cbacbacbacba','abcabcabcabc'),(4246,3,4,'cbacbacbacba','abcabcabcabc'),(4247,3,4,'cbacbacbacba','abcabcabcabc'),(4248,3,4,'cbacbacbacba','abcabcabcabc'),(4249,3,4,'cbacbacbacba','abcabcabcabc'),(4250,3,4,'cbacbacbacba','abcabcabcabc'),(4251,3,4,'cbacbacbacba','abcabcabcabc'),(4252,3,4,'cbacbacbacba','abcabcabcabc'),(4253,3,4,'cbacbacbacba','abcabcabcabc'),(4254,3,4,'cbacbacbacba','abcabcabcabc'),(4255,3,4,'cbacbacbacba','abcabcabcabc'),(4256,3,4,'cbacbacbacba','abcabcabcabc'),(4257,3,4,'cbacbacbacba','abcabcabcabc'),(4258,3,4,'cbacbacbacba','abcabcabcabc'),(4259,3,4,'cbacbacbacba','abcabcabcabc'),(4260,3,4,'cbacbacbacba','abcabcabcabc'),(4261,3,4,'cbacbacbacba','abcabcabcabc'),(4262,3,4,'cbacbacbacba','abcabcabcabc'),(4263,3,4,'cbacbacbacba','abcabcabcabc'),(4264,3,4,'cbacbacbacba','abcabcabcabc'),(4265,3,4,'cbacbacbacba','abcabcabcabc'),(4266,3,4,'cbacbacbacba','abcabcabcabc'),(4267,3,4,'cbacbacbacba','abcabcabcabc'),(4268,3,4,'cbacbacbacba','abcabcabcabc'),(4269,3,4,'cbacbacbacba','abcabcabcabc'),(4270,3,4,'cbacbacbacba','abcabcabcabc'),(4271,3,4,'cbacbacbacba','abcabcabcabc'),(4272,3,4,'cbacbacbacba','abcabcabcabc'),(4273,3,4,'cbacbacbacba','abcabcabcabc'),(4274,3,4,'cbacbacbacba','abcabcabcabc'),(4275,3,4,'cbacbacbacba','abcabcabcabc'),(4276,3,4,'cbacbacbacba','abcabcabcabc'),(4277,3,4,'cbacbacbacba','abcabcabcabc'),(4278,3,4,'cbacbacbacba','abcabcabcabc'),(4279,3,4,'cbacbacbacba','abcabcabcabc'),(4280,3,4,'cbacbacbacba','abcabcabcabc'),(4281,3,4,'cbacbacbacba','abcabcabcabc'),(4282,3,4,'cbacbacbacba','abcabcabcabc'),(4283,3,4,'cbacbacbacba','abcabcabcabc'),(4284,3,4,'cbacbacbacba','abcabcabcabc'),(4285,3,4,'cbacbacbacba','abcabcabcabc'),(4286,3,4,'cbacbacbacba','abcabcabcabc'),(4287,3,4,'cbacbacbacba','abcabcabcabc'),(4288,3,4,'cbacbacbacba','abcabcabcabc'),(4289,3,4,'cbacbacbacba','abcabcabcabc'),(4290,3,4,'cbacbacbacba','abcabcabcabc'),(4291,3,4,'cbacbacbacba','abcabcabcabc'),(4292,3,4,'cbacbacbacba','abcabcabcabc'),(4293,3,4,'cbacbacbacba','abcabcabcabc'),(4294,3,4,'cbacbacbacba','abcabcabcabc'),(4295,3,4,'cbacbacbacba','abcabcabcabc'),(4296,3,4,'cbacbacbacba','abcabcabcabc'),(4297,3,4,'cbacbacbacba','abcabcabcabc'),(4298,3,4,'cbacbacbacba','abcabcabcabc'),(4299,3,4,'cbacbacbacba','abcabcabcabc'),(4300,3,4,'cbacbacbacba','abcabcabcabc'),(4301,3,4,'cbacbacbacba','abcabcabcabc'),(4302,3,4,'cbacbacbacba','abcabcabcabc'),(4303,3,4,'cbacbacbacba','abcabcabcabc'),(4304,3,4,'cbacbacbacba','abcabcabcabc'),(4305,3,4,'cbacbacbacba','abcabcabcabc'),(4306,3,4,'cbacbacbacba','abcabcabcabc'),(4307,3,4,'cbacbacbacba','abcabcabcabc'),(4308,3,4,'cbacbacbacba','abcabcabcabc'),(4309,3,4,'cbacbacbacba','abcabcabcabc'),(4310,3,4,'cbacbacbacba','abcabcabcabc'),(4311,3,4,'cbacbacbacba','abcabcabcabc'),(4312,3,4,'cbacbacbacba','abcabcabcabc'),(4313,3,4,'cbacbacbacba','abcabcabcabc'),(4314,3,4,'cbacbacbacba','abcabcabcabc'),(4315,3,4,'cbacbacbacba','abcabcabcabc'),(4316,3,4,'cbacbacbacba','abcabcabcabc'),(4317,3,4,'cbacbacbacba','abcabcabcabc'),(4318,3,4,'cbacbacbacba','abcabcabcabc'),(4319,3,4,'cbacbacbacba','abcabcabcabc'),(4320,3,4,'cbacbacbacba','abcabcabcabc'),(4321,3,4,'cbacbacbacba','abcabcabcabc'),(4322,3,4,'cbacbacbacba','abcabcabcabc'),(4323,3,4,'cbacbacbacba','abcabcabcabc'),(4324,3,4,'cbacbacbacba','abcabcabcabc'),(4325,3,4,'cbacbacbacba','abcabcabcabc'),(4326,3,4,'cbacbacbacba','abcabcabcabc'),(4327,3,4,'cbacbacbacba','abcabcabcabc'),(4328,3,4,'cbacbacbacba','abcabcabcabc'),(4329,3,4,'cbacbacbacba','abcabcabcabc'),(4330,3,4,'cbacbacbacba','abcabcabcabc'),(4331,3,4,'cbacbacbacba','abcabcabcabc'),(4332,3,4,'cbacbacbacba','abcabcabcabc'),(4333,3,4,'cbacbacbacba','abcabcabcabc'),(4334,3,4,'cbacbacbacba','abcabcabcabc'),(4335,3,4,'cbacbacbacba','abcabcabcabc'),(4336,3,4,'cbacbacbacba','abcabcabcabc'),(4337,3,4,'cbacbacbacba','abcabcabcabc'),(4338,3,4,'cbacbacbacba','abcabcabcabc'),(4339,3,4,'cbacbacbacba','abcabcabcabc'),(4340,3,4,'cbacbacbacba','abcabcabcabc'),(4341,3,4,'cbacbacbacba','abcabcabcabc'),(4342,3,4,'cbacbacbacba','abcabcabcabc'),(4343,3,4,'cbacbacbacba','abcabcabcabc'),(4344,3,4,'cbacbacbacba','abcabcabcabc'),(4345,3,4,'cbacbacbacba','abcabcabcabc'),(4346,3,4,'cbacbacbacba','abcabcabcabc'),(4347,3,4,'cbacbacbacba','abcabcabcabc'),(4348,3,4,'cbacbacbacba','abcabcabcabc'),(4349,3,4,'cbacbacbacba','abcabcabcabc'),(4350,3,4,'cbacbacbacba','abcabcabcabc'),(4351,3,4,'cbacbacbacba','abcabcabcabc'),(4352,3,4,'cbacbacbacba','abcabcabcabc'),(4353,3,4,'cbacbacbacba','abcabcabcabc'),(4354,3,4,'cbacbacbacba','abcabcabcabc'),(4355,3,4,'cbacbacbacba','abcabcabcabc'),(4356,3,4,'cbacbacbacba','abcabcabcabc'),(4357,3,4,'cbacbacbacba','abcabcabcabc'),(4358,3,4,'cbacbacbacba','abcabcabcabc'),(4359,3,4,'cbacbacbacba','abcabcabcabc'),(4360,3,4,'cbacbacbacba','abcabcabcabc'),(4361,3,4,'cbacbacbacba','abcabcabcabc'),(4362,3,4,'cbacbacbacba','abcabcabcabc'),(4363,3,4,'cbacbacbacba','abcabcabcabc'),(4364,3,4,'cbacbacbacba','abcabcabcabc'),(4365,3,4,'cbacbacbacba','abcabcabcabc'),(4366,3,4,'cbacbacbacba','abcabcabcabc'),(4367,3,4,'cbacbacbacba','abcabcabcabc'),(4368,3,4,'cbacbacbacba','abcabcabcabc'),(4369,3,4,'cbacbacbacba','abcabcabcabc'),(4370,3,4,'cbacbacbacba','abcabcabcabc'),(4371,3,4,'cbacbacbacba','abcabcabcabc'),(4372,3,4,'cbacbacbacba','abcabcabcabc'),(4373,3,4,'cbacbacbacba','abcabcabcabc'),(4374,3,4,'cbacbacbacba','abcabcabcabc'),(4375,3,4,'cbacbacbacba','abcabcabcabc'),(4376,3,4,'cbacbacbacba','abcabcabcabc'),(4377,3,4,'cbacbacbacba','abcabcabcabc'),(4378,3,4,'cbacbacbacba','abcabcabcabc'),(4379,3,4,'cbacbacbacba','abcabcabcabc'),(4380,3,4,'cbacbacbacba','abcabcabcabc'),(4381,3,4,'cbacbacbacba','abcabcabcabc'),(4382,3,4,'cbacbacbacba','abcabcabcabc'),(4383,3,4,'cbacbacbacba','abcabcabcabc'),(4384,3,4,'cbacbacbacba','abcabcabcabc'),(4385,3,4,'cbacbacbacba','abcabcabcabc'),(4386,3,4,'cbacbacbacba','abcabcabcabc'),(4387,3,4,'cbacbacbacba','abcabcabcabc'),(4388,3,4,'cbacbacbacba','abcabcabcabc'),(4389,3,4,'cbacbacbacba','abcabcabcabc'),(4390,3,4,'cbacbacbacba','abcabcabcabc'),(4391,3,4,'cbacbacbacba','abcabcabcabc'),(4392,3,4,'cbacbacbacba','abcabcabcabc'),(4393,3,4,'cbacbacbacba','abcabcabcabc'),(4394,3,4,'cbacbacbacba','abcabcabcabc'),(4395,3,4,'cbacbacbacba','abcabcabcabc'),(4396,3,4,'cbacbacbacba','abcabcabcabc'),(4397,3,4,'cbacbacbacba','abcabcabcabc'),(4398,3,4,'cbacbacbacba','abcabcabcabc'),(4399,3,4,'cbacbacbacba','abcabcabcabc'),(4400,3,4,'cbacbacbacba','abcabcabcabc'),(4401,3,4,'cbacbacbacba','abcabcabcabc'),(4402,3,4,'cbacbacbacba','abcabcabcabc'),(4403,3,4,'cbacbacbacba','abcabcabcabc'),(4404,3,4,'cbacbacbacba','abcabcabcabc'),(4405,3,4,'cbacbacbacba','abcabcabcabc'),(4406,3,4,'cbacbacbacba','abcabcabcabc'),(4407,3,4,'cbacbacbacba','abcabcabcabc'),(4408,3,4,'cbacbacbacba','abcabcabcabc'),(4409,3,4,'cbacbacbacba','abcabcabcabc'),(4410,3,4,'cbacbacbacba','abcabcabcabc'),(4411,3,4,'cbacbacbacba','abcabcabcabc'),(4412,3,4,'cbacbacbacba','abcabcabcabc'),(4413,3,4,'cbacbacbacba','abcabcabcabc'),(4414,3,4,'cbacbacbacba','abcabcabcabc'),(4415,3,4,'cbacbacbacba','abcabcabcabc'),(4416,3,4,'cbacbacbacba','abcabcabcabc'),(4417,3,4,'cbacbacbacba','abcabcabcabc'),(4418,3,4,'cbacbacbacba','abcabcabcabc'),(4419,3,4,'cbacbacbacba','abcabcabcabc'),(4420,3,4,'cbacbacbacba','abcabcabcabc'),(4421,3,4,'cbacbacbacba','abcabcabcabc'),(4422,3,4,'cbacbacbacba','abcabcabcabc'),(4423,3,4,'cbacbacbacba','abcabcabcabc'),(4424,3,4,'cbacbacbacba','abcabcabcabc'),(4425,3,4,'cbacbacbacba','abcabcabcabc'),(4426,3,4,'cbacbacbacba','abcabcabcabc'),(4427,3,4,'cbacbacbacba','abcabcabcabc'),(4428,3,4,'cbacbacbacba','abcabcabcabc'),(4429,3,4,'cbacbacbacba','abcabcabcabc'),(4430,3,4,'cbacbacbacba','abcabcabcabc'),(4431,3,4,'cbacbacbacba','abcabcabcabc'),(4432,3,4,'cbacbacbacba','abcabcabcabc'),(4433,3,4,'cbacbacbacba','abcabcabcabc'),(4434,3,4,'cbacbacbacba','abcabcabcabc'),(4435,3,4,'cbacbacbacba','abcabcabcabc'),(4436,3,4,'cbacbacbacba','abcabcabcabc'),(4437,3,4,'cbacbacbacba','abcabcabcabc'),(4438,3,4,'cbacbacbacba','abcabcabcabc'),(4439,3,4,'cbacbacbacba','abcabcabcabc'),(4440,3,4,'cbacbacbacba','abcabcabcabc'),(4441,3,4,'cbacbacbacba','abcabcabcabc'),(4442,3,4,'cbacbacbacba','abcabcabcabc'),(4443,3,4,'cbacbacbacba','abcabcabcabc'),(4444,3,4,'cbacbacbacba','abcabcabcabc'),(4445,3,4,'cbacbacbacba','abcabcabcabc'),(4446,3,4,'cbacbacbacba','abcabcabcabc'),(4447,3,4,'cbacbacbacba','abcabcabcabc'),(4448,3,4,'cbacbacbacba','abcabcabcabc'),(4449,3,4,'cbacbacbacba','abcabcabcabc'),(4450,3,4,'cbacbacbacba','abcabcabcabc'),(4451,3,4,'cbacbacbacba','abcabcabcabc'),(4452,3,4,'cbacbacbacba','abcabcabcabc'),(4453,3,4,'cbacbacbacba','abcabcabcabc'),(4454,3,4,'cbacbacbacba','abcabcabcabc'),(4455,3,4,'cbacbacbacba','abcabcabcabc'),(4456,3,4,'cbacbacbacba','abcabcabcabc'),(4457,3,4,'cbacbacbacba','abcabcabcabc'),(4458,3,4,'cbacbacbacba','abcabcabcabc'),(4459,3,4,'cbacbacbacba','abcabcabcabc'),(4460,3,4,'cbacbacbacba','abcabcabcabc'),(4461,3,4,'cbacbacbacba','abcabcabcabc'),(4462,3,4,'cbacbacbacba','abcabcabcabc'),(4463,3,4,'cbacbacbacba','abcabcabcabc'),(4464,3,4,'cbacbacbacba','abcabcabcabc'),(4465,3,4,'cbacbacbacba','abcabcabcabc'),(4466,3,4,'cbacbacbacba','abcabcabcabc'),(4467,3,4,'cbacbacbacba','abcabcabcabc'),(4468,3,4,'cbacbacbacba','abcabcabcabc'),(4469,3,4,'cbacbacbacba','abcabcabcabc'),(4470,3,4,'cbacbacbacba','abcabcabcabc'),(4471,3,4,'cbacbacbacba','abcabcabcabc'),(4472,3,4,'cbacbacbacba','abcabcabcabc'),(4473,3,4,'cbacbacbacba','abcabcabcabc'),(4474,3,4,'cbacbacbacba','abcabcabcabc'),(4475,3,4,'cbacbacbacba','abcabcabcabc'),(4476,3,4,'cbacbacbacba','abcabcabcabc'),(4477,3,4,'cbacbacbacba','abcabcabcabc'),(4478,3,4,'cbacbacbacba','abcabcabcabc'),(4479,3,4,'cbacbacbacba','abcabcabcabc'),(4480,3,4,'cbacbacbacba','abcabcabcabc'),(4481,3,4,'cbacbacbacba','abcabcabcabc'),(4482,3,4,'cbacbacbacba','abcabcabcabc'),(4483,3,4,'cbacbacbacba','abcabcabcabc'),(4484,3,4,'cbacbacbacba','abcabcabcabc'),(4485,3,4,'cbacbacbacba','abcabcabcabc'),(4486,3,4,'cbacbacbacba','abcabcabcabc'),(4487,3,4,'cbacbacbacba','abcabcabcabc'),(4488,3,4,'cbacbacbacba','abcabcabcabc'),(4489,3,4,'cbacbacbacba','abcabcabcabc'),(4490,3,4,'cbacbacbacba','abcabcabcabc'),(4491,3,4,'cbacbacbacba','abcabcabcabc'),(4492,3,4,'cbacbacbacba','abcabcabcabc'),(4493,3,4,'cbacbacbacba','abcabcabcabc'),(4494,3,4,'cbacbacbacba','abcabcabcabc'),(4495,3,4,'cbacbacbacba','abcabcabcabc'),(4496,3,4,'cbacbacbacba','abcabcabcabc'),(4497,3,4,'cbacbacbacba','abcabcabcabc'),(4498,3,4,'cbacbacbacba','abcabcabcabc'),(4499,3,4,'cbacbacbacba','abcabcabcabc'),(4500,3,4,'cbacbacbacba','abcabcabcabc'),(4501,3,4,'cbacbacbacba','abcabcabcabc'),(4502,3,4,'cbacbacbacba','abcabcabcabc'),(4503,3,4,'cbacbacbacba','abcabcabcabc'),(4504,3,4,'cbacbacbacba','abcabcabcabc'),(4505,3,4,'cbacbacbacba','abcabcabcabc'),(4506,3,4,'cbacbacbacba','abcabcabcabc'),(4507,3,4,'cbacbacbacba','abcabcabcabc'),(4508,3,4,'cbacbacbacba','abcabcabcabc'),(4509,3,4,'cbacbacbacba','abcabcabcabc'),(4510,3,4,'cbacbacbacba','abcabcabcabc'),(4511,3,4,'cbacbacbacba','abcabcabcabc'),(4512,3,4,'cbacbacbacba','abcabcabcabc'),(4513,3,4,'cbacbacbacba','abcabcabcabc'),(4514,3,4,'cbacbacbacba','abcabcabcabc'),(4515,3,4,'cbacbacbacba','abcabcabcabc'),(4516,3,4,'cbacbacbacba','abcabcabcabc'),(4517,3,4,'cbacbacbacba','abcabcabcabc'),(4518,3,4,'cbacbacbacba','abcabcabcabc'),(4519,3,4,'cbacbacbacba','abcabcabcabc'),(4520,3,4,'cbacbacbacba','abcabcabcabc'),(4521,3,4,'cbacbacbacba','abcabcabcabc'),(4522,3,4,'cbacbacbacba','abcabcabcabc'),(4523,3,4,'cbacbacbacba','abcabcabcabc'),(4524,3,4,'cbacbacbacba','abcabcabcabc'),(4525,3,4,'cbacbacbacba','abcabcabcabc'),(4526,3,4,'cbacbacbacba','abcabcabcabc'),(4527,3,4,'cbacbacbacba','abcabcabcabc'),(4528,3,4,'cbacbacbacba','abcabcabcabc'),(4529,3,4,'cbacbacbacba','abcabcabcabc'),(4530,3,4,'cbacbacbacba','abcabcabcabc'),(4531,3,4,'cbacbacbacba','abcabcabcabc'),(4532,3,4,'cbacbacbacba','abcabcabcabc'),(4533,3,4,'cbacbacbacba','abcabcabcabc'),(4534,3,4,'cbacbacbacba','abcabcabcabc'),(4535,3,4,'cbacbacbacba','abcabcabcabc'),(4536,3,4,'cbacbacbacba','abcabcabcabc'),(4537,3,4,'cbacbacbacba','abcabcabcabc'),(4538,3,4,'cbacbacbacba','abcabcabcabc'),(4539,3,4,'cbacbacbacba','abcabcabcabc'),(4540,3,4,'cbacbacbacba','abcabcabcabc'),(4541,3,4,'cbacbacbacba','abcabcabcabc'),(4542,3,4,'cbacbacbacba','abcabcabcabc'),(4543,3,4,'cbacbacbacba','abcabcabcabc'),(4544,3,4,'cbacbacbacba','abcabcabcabc'),(4545,3,4,'cbacbacbacba','abcabcabcabc'),(4546,3,4,'cbacbacbacba','abcabcabcabc'),(4547,3,4,'cbacbacbacba','abcabcabcabc'),(4548,3,4,'cbacbacbacba','abcabcabcabc'),(4549,3,4,'cbacbacbacba','abcabcabcabc'),(4550,3,4,'cbacbacbacba','abcabcabcabc'),(4551,3,4,'cbacbacbacba','abcabcabcabc'),(4552,3,4,'cbacbacbacba','abcabcabcabc'),(4553,3,4,'cbacbacbacba','abcabcabcabc'),(4554,3,4,'cbacbacbacba','abcabcabcabc'),(4555,3,4,'cbacbacbacba','abcabcabcabc'),(4556,3,4,'cbacbacbacba','abcabcabcabc'),(4557,3,4,'cbacbacbacba','abcabcabcabc'),(4558,3,4,'cbacbacbacba','abcabcabcabc'),(4559,3,4,'cbacbacbacba','abcabcabcabc'),(4560,3,4,'cbacbacbacba','abcabcabcabc'),(4561,3,4,'cbacbacbacba','abcabcabcabc'),(4562,3,4,'cbacbacbacba','abcabcabcabc'),(4563,3,4,'cbacbacbacba','abcabcabcabc'),(4564,3,4,'cbacbacbacba','abcabcabcabc'),(4565,3,4,'cbacbacbacba','abcabcabcabc'),(4566,3,4,'cbacbacbacba','abcabcabcabc'),(4567,3,4,'cbacbacbacba','abcabcabcabc'),(4568,3,4,'cbacbacbacba','abcabcabcabc'),(4569,3,4,'cbacbacbacba','abcabcabcabc'),(4570,3,4,'cbacbacbacba','abcabcabcabc'),(4571,3,4,'cbacbacbacba','abcabcabcabc'),(4572,3,4,'cbacbacbacba','abcabcabcabc'),(4573,3,4,'cbacbacbacba','abcabcabcabc'),(4574,3,4,'cbacbacbacba','abcabcabcabc'),(4575,3,4,'cbacbacbacba','abcabcabcabc'),(4576,3,4,'cbacbacbacba','abcabcabcabc'),(4577,3,4,'cbacbacbacba','abcabcabcabc'),(4578,3,4,'cbacbacbacba','abcabcabcabc'),(4579,3,4,'cbacbacbacba','abcabcabcabc'),(4580,3,4,'cbacbacbacba','abcabcabcabc'),(4581,3,4,'cbacbacbacba','abcabcabcabc'),(4582,3,4,'cbacbacbacba','abcabcabcabc'),(4583,3,4,'cbacbacbacba','abcabcabcabc'),(4584,3,4,'cbacbacbacba','abcabcabcabc'),(4585,3,4,'cbacbacbacba','abcabcabcabc'),(4586,3,4,'cbacbacbacba','abcabcabcabc'),(4587,3,4,'cbacbacbacba','abcabcabcabc'),(4588,3,4,'cbacbacbacba','abcabcabcabc'),(4589,3,4,'cbacbacbacba','abcabcabcabc'),(4590,3,4,'cbacbacbacba','abcabcabcabc'),(4591,3,4,'cbacbacbacba','abcabcabcabc'),(4592,3,4,'cbacbacbacba','abcabcabcabc'),(4593,3,4,'cbacbacbacba','abcabcabcabc'),(4594,3,4,'cbacbacbacba','abcabcabcabc'),(4595,3,4,'cbacbacbacba','abcabcabcabc'),(4596,3,4,'cbacbacbacba','abcabcabcabc'),(4597,3,4,'cbacbacbacba','abcabcabcabc'),(4598,3,4,'cbacbacbacba','abcabcabcabc'),(4599,3,4,'cbacbacbacba','abcabcabcabc'),(4600,3,4,'cbacbacbacba','abcabcabcabc'),(4601,3,4,'cbacbacbacba','abcabcabcabc'),(4602,3,4,'cbacbacbacba','abcabcabcabc'),(4603,3,4,'cbacbacbacba','abcabcabcabc'),(4604,3,4,'cbacbacbacba','abcabcabcabc'),(4605,3,4,'cbacbacbacba','abcabcabcabc'),(4606,3,4,'cbacbacbacba','abcabcabcabc'),(4607,3,4,'cbacbacbacba','abcabcabcabc'),(4608,3,4,'cbacbacbacba','abcabcabcabc'),(4609,3,4,'cbacbacbacba','abcabcabcabc'),(4610,3,4,'cbacbacbacba','abcabcabcabc'),(4611,3,4,'cbacbacbacba','abcabcabcabc'),(4612,3,4,'cbacbacbacba','abcabcabcabc'),(4613,3,4,'cbacbacbacba','abcabcabcabc'),(4614,3,4,'cbacbacbacba','abcabcabcabc'),(4615,3,4,'cbacbacbacba','abcabcabcabc'),(4616,3,4,'cbacbacbacba','abcabcabcabc'),(4617,3,4,'cbacbacbacba','abcabcabcabc'),(4618,3,4,'cbacbacbacba','abcabcabcabc'),(4619,3,4,'cbacbacbacba','abcabcabcabc'),(4620,3,4,'cbacbacbacba','abcabcabcabc'),(4621,3,4,'cbacbacbacba','abcabcabcabc'),(4622,3,4,'cbacbacbacba','abcabcabcabc'),(4623,3,4,'cbacbacbacba','abcabcabcabc'),(4624,3,4,'cbacbacbacba','abcabcabcabc'),(4625,3,4,'cbacbacbacba','abcabcabcabc'),(4626,3,4,'cbacbacbacba','abcabcabcabc'),(4627,3,4,'cbacbacbacba','abcabcabcabc'),(4628,3,4,'cbacbacbacba','abcabcabcabc'),(4629,3,4,'cbacbacbacba','abcabcabcabc'),(4630,3,4,'cbacbacbacba','abcabcabcabc'),(4631,3,4,'cbacbacbacba','abcabcabcabc'),(4632,3,4,'cbacbacbacba','abcabcabcabc'),(4633,3,4,'cbacbacbacba','abcabcabcabc'),(4634,3,4,'cbacbacbacba','abcabcabcabc'),(4635,3,4,'cbacbacbacba','abcabcabcabc'),(4636,3,4,'cbacbacbacba','abcabcabcabc'),(4637,3,4,'cbacbacbacba','abcabcabcabc'),(4638,3,4,'cbacbacbacba','abcabcabcabc'),(4639,3,4,'cbacbacbacba','abcabcabcabc'),(4640,3,4,'cbacbacbacba','abcabcabcabc'),(4641,3,4,'cbacbacbacba','abcabcabcabc'),(4642,3,4,'cbacbacbacba','abcabcabcabc'),(4643,3,4,'cbacbacbacba','abcabcabcabc'),(4644,3,4,'cbacbacbacba','abcabcabcabc'),(4645,3,4,'cbacbacbacba','abcabcabcabc'),(4646,3,4,'cbacbacbacba','abcabcabcabc'),(4647,3,4,'cbacbacbacba','abcabcabcabc'),(4648,3,4,'cbacbacbacba','abcabcabcabc'),(4649,3,4,'cbacbacbacba','abcabcabcabc'),(4650,3,4,'cbacbacbacba','abcabcabcabc'),(4651,3,4,'cbacbacbacba','abcabcabcabc'),(4652,3,4,'cbacbacbacba','abcabcabcabc'),(4653,3,4,'cbacbacbacba','abcabcabcabc'),(4654,3,4,'cbacbacbacba','abcabcabcabc'),(4655,3,4,'cbacbacbacba','abcabcabcabc'),(4656,3,4,'cbacbacbacba','abcabcabcabc'),(4657,3,4,'cbacbacbacba','abcabcabcabc'),(4658,3,4,'cbacbacbacba','abcabcabcabc'),(4659,3,4,'cbacbacbacba','abcabcabcabc'),(4660,3,4,'cbacbacbacba','abcabcabcabc'),(4661,3,4,'cbacbacbacba','abcabcabcabc'),(4662,3,4,'cbacbacbacba','abcabcabcabc'),(4663,3,4,'cbacbacbacba','abcabcabcabc'),(4664,3,4,'cbacbacbacba','abcabcabcabc'),(4665,3,4,'cbacbacbacba','abcabcabcabc'),(4666,3,4,'cbacbacbacba','abcabcabcabc'),(4667,3,4,'cbacbacbacba','abcabcabcabc'),(4668,3,4,'cbacbacbacba','abcabcabcabc'),(4669,3,4,'cbacbacbacba','abcabcabcabc'),(4670,3,4,'cbacbacbacba','abcabcabcabc'),(4671,3,4,'cbacbacbacba','abcabcabcabc'),(4672,3,4,'cbacbacbacba','abcabcabcabc'),(4673,3,4,'cbacbacbacba','abcabcabcabc'),(4674,3,4,'cbacbacbacba','abcabcabcabc'),(4675,3,4,'cbacbacbacba','abcabcabcabc'),(4676,3,4,'cbacbacbacba','abcabcabcabc'),(4677,3,4,'cbacbacbacba','abcabcabcabc'),(4678,3,4,'cbacbacbacba','abcabcabcabc'),(4679,3,4,'cbacbacbacba','abcabcabcabc'),(4680,3,4,'cbacbacbacba','abcabcabcabc'),(4681,3,4,'cbacbacbacba','abcabcabcabc'),(4682,3,4,'cbacbacbacba','abcabcabcabc'),(4683,3,4,'cbacbacbacba','abcabcabcabc'),(4684,3,4,'cbacbacbacba','abcabcabcabc'),(4685,3,4,'cbacbacbacba','abcabcabcabc'),(4686,3,4,'cbacbacbacba','abcabcabcabc'),(4687,3,4,'cbacbacbacba','abcabcabcabc'),(4688,3,4,'cbacbacbacba','abcabcabcabc'),(4689,3,4,'cbacbacbacba','abcabcabcabc'),(4690,3,4,'cbacbacbacba','abcabcabcabc'),(4691,3,4,'cbacbacbacba','abcabcabcabc'),(4692,3,4,'cbacbacbacba','abcabcabcabc'),(4693,3,4,'cbacbacbacba','abcabcabcabc'),(4694,3,4,'cbacbacbacba','abcabcabcabc'),(4695,3,4,'cbacbacbacba','abcabcabcabc'),(4696,3,4,'cbacbacbacba','abcabcabcabc'),(4697,3,4,'cbacbacbacba','abcabcabcabc'),(4698,3,4,'cbacbacbacba','abcabcabcabc'),(4699,3,4,'cbacbacbacba','abcabcabcabc'),(4700,3,4,'cbacbacbacba','abcabcabcabc'),(4701,3,4,'cbacbacbacba','abcabcabcabc'),(4702,3,4,'cbacbacbacba','abcabcabcabc'),(4703,3,4,'cbacbacbacba','abcabcabcabc'),(4704,3,4,'cbacbacbacba','abcabcabcabc'),(4705,3,4,'cbacbacbacba','abcabcabcabc'),(4706,3,4,'cbacbacbacba','abcabcabcabc'),(4707,3,4,'cbacbacbacba','abcabcabcabc'),(4708,3,4,'cbacbacbacba','abcabcabcabc'),(4709,3,4,'cbacbacbacba','abcabcabcabc'),(4710,3,4,'cbacbacbacba','abcabcabcabc'),(4711,3,4,'cbacbacbacba','abcabcabcabc'),(4712,3,4,'cbacbacbacba','abcabcabcabc'),(4713,3,4,'cbacbacbacba','abcabcabcabc'),(4714,3,4,'cbacbacbacba','abcabcabcabc'),(4715,3,4,'cbacbacbacba','abcabcabcabc'),(4716,3,4,'cbacbacbacba','abcabcabcabc'),(4717,3,4,'cbacbacbacba','abcabcabcabc'),(4718,3,4,'cbacbacbacba','abcabcabcabc'),(4719,3,4,'cbacbacbacba','abcabcabcabc'),(4720,3,4,'cbacbacbacba','abcabcabcabc'),(4721,3,4,'cbacbacbacba','abcabcabcabc'),(4722,3,4,'cbacbacbacba','abcabcabcabc'),(4723,3,4,'cbacbacbacba','abcabcabcabc'),(4724,3,4,'cbacbacbacba','abcabcabcabc'),(4725,3,4,'cbacbacbacba','abcabcabcabc'),(4726,3,4,'cbacbacbacba','abcabcabcabc'),(4727,3,4,'cbacbacbacba','abcabcabcabc'),(4728,3,4,'cbacbacbacba','abcabcabcabc'),(4729,3,4,'cbacbacbacba','abcabcabcabc'),(4730,3,4,'cbacbacbacba','abcabcabcabc'),(4731,3,4,'cbacbacbacba','abcabcabcabc'),(4732,3,4,'cbacbacbacba','abcabcabcabc'),(4733,3,4,'cbacbacbacba','abcabcabcabc'),(4734,3,4,'cbacbacbacba','abcabcabcabc'),(4735,3,4,'cbacbacbacba','abcabcabcabc'),(4736,3,4,'cbacbacbacba','abcabcabcabc'),(4737,3,4,'cbacbacbacba','abcabcabcabc'),(4738,3,4,'cbacbacbacba','abcabcabcabc'),(4739,3,4,'cbacbacbacba','abcabcabcabc'),(4740,3,4,'cbacbacbacba','abcabcabcabc'),(4741,3,4,'cbacbacbacba','abcabcabcabc'),(4742,3,4,'cbacbacbacba','abcabcabcabc'),(4743,3,4,'cbacbacbacba','abcabcabcabc'),(4744,3,4,'cbacbacbacba','abcabcabcabc'),(4745,3,4,'cbacbacbacba','abcabcabcabc'),(4746,3,4,'cbacbacbacba','abcabcabcabc'),(4747,3,4,'cbacbacbacba','abcabcabcabc'),(4748,3,4,'cbacbacbacba','abcabcabcabc'),(4749,3,4,'cbacbacbacba','abcabcabcabc'),(4750,3,4,'cbacbacbacba','abcabcabcabc'),(4751,3,4,'cbacbacbacba','abcabcabcabc'),(4752,3,4,'cbacbacbacba','abcabcabcabc'),(4753,3,4,'cbacbacbacba','abcabcabcabc'),(4754,3,4,'cbacbacbacba','abcabcabcabc'),(4755,3,4,'cbacbacbacba','abcabcabcabc'),(4756,3,4,'cbacbacbacba','abcabcabcabc'),(4757,3,4,'cbacbacbacba','abcabcabcabc'),(4758,3,4,'cbacbacbacba','abcabcabcabc'),(4759,3,4,'cbacbacbacba','abcabcabcabc'),(4760,3,4,'cbacbacbacba','abcabcabcabc'),(4761,3,4,'cbacbacbacba','abcabcabcabc'),(4762,3,4,'cbacbacbacba','abcabcabcabc'),(4763,3,4,'cbacbacbacba','abcabcabcabc'),(4764,3,4,'cbacbacbacba','abcabcabcabc'),(4765,3,4,'cbacbacbacba','abcabcabcabc'),(4766,3,4,'cbacbacbacba','abcabcabcabc'),(4767,3,4,'cbacbacbacba','abcabcabcabc'),(4768,3,4,'cbacbacbacba','abcabcabcabc'),(4769,3,4,'cbacbacbacba','abcabcabcabc'),(4770,3,4,'cbacbacbacba','abcabcabcabc'),(4771,3,4,'cbacbacbacba','abcabcabcabc'),(4772,3,4,'cbacbacbacba','abcabcabcabc'),(4773,3,4,'cbacbacbacba','abcabcabcabc'),(4774,3,4,'cbacbacbacba','abcabcabcabc'),(4775,3,4,'cbacbacbacba','abcabcabcabc'),(4776,3,4,'cbacbacbacba','abcabcabcabc'),(4777,3,4,'cbacbacbacba','abcabcabcabc'),(4778,3,4,'cbacbacbacba','abcabcabcabc'),(4779,3,4,'cbacbacbacba','abcabcabcabc'),(4780,3,4,'cbacbacbacba','abcabcabcabc'),(4781,3,4,'cbacbacbacba','abcabcabcabc'),(4782,3,4,'cbacbacbacba','abcabcabcabc'),(4783,3,4,'cbacbacbacba','abcabcabcabc'),(4784,3,4,'cbacbacbacba','abcabcabcabc'),(4785,3,4,'cbacbacbacba','abcabcabcabc'),(4786,3,4,'cbacbacbacba','abcabcabcabc'),(4787,3,4,'cbacbacbacba','abcabcabcabc'),(4788,3,4,'cbacbacbacba','abcabcabcabc'),(4789,3,4,'cbacbacbacba','abcabcabcabc'),(4790,3,4,'cbacbacbacba','abcabcabcabc'),(4791,3,4,'cbacbacbacba','abcabcabcabc'),(4792,3,4,'cbacbacbacba','abcabcabcabc'),(4793,3,4,'cbacbacbacba','abcabcabcabc'),(4794,3,4,'cbacbacbacba','abcabcabcabc'),(4795,3,4,'cbacbacbacba','abcabcabcabc'),(4796,3,4,'cbacbacbacba','abcabcabcabc'),(4797,3,4,'cbacbacbacba','abcabcabcabc'),(4798,3,4,'cbacbacbacba','abcabcabcabc'),(4799,3,4,'cbacbacbacba','abcabcabcabc'),(4800,3,4,'cbacbacbacba','abcabcabcabc'),(4801,3,4,'cbacbacbacba','abcabcabcabc'),(4802,3,4,'cbacbacbacba','abcabcabcabc'),(4803,3,4,'cbacbacbacba','abcabcabcabc'),(4804,3,4,'cbacbacbacba','abcabcabcabc'),(4805,3,4,'cbacbacbacba','abcabcabcabc'),(4806,3,4,'cbacbacbacba','abcabcabcabc'),(4807,3,4,'cbacbacbacba','abcabcabcabc'),(4808,3,4,'cbacbacbacba','abcabcabcabc'),(4809,3,4,'cbacbacbacba','abcabcabcabc'),(4810,3,4,'cbacbacbacba','abcabcabcabc'),(4811,3,4,'cbacbacbacba','abcabcabcabc'),(4812,3,4,'cbacbacbacba','abcabcabcabc'),(4813,3,4,'cbacbacbacba','abcabcabcabc'),(4814,3,4,'cbacbacbacba','abcabcabcabc'),(4815,3,4,'cbacbacbacba','abcabcabcabc'),(4816,3,4,'cbacbacbacba','abcabcabcabc'),(4817,3,4,'cbacbacbacba','abcabcabcabc'),(4818,3,4,'cbacbacbacba','abcabcabcabc'),(4819,3,4,'cbacbacbacba','abcabcabcabc'),(4820,3,4,'cbacbacbacba','abcabcabcabc'),(4821,3,4,'cbacbacbacba','abcabcabcabc'),(4822,3,4,'cbacbacbacba','abcabcabcabc'),(4823,3,4,'cbacbacbacba','abcabcabcabc'),(4824,3,4,'cbacbacbacba','abcabcabcabc'),(4825,3,4,'cbacbacbacba','abcabcabcabc'),(4826,3,4,'cbacbacbacba','abcabcabcabc'),(4827,3,4,'cbacbacbacba','abcabcabcabc'),(4828,3,4,'cbacbacbacba','abcabcabcabc'),(4829,3,4,'cbacbacbacba','abcabcabcabc'),(4830,3,4,'cbacbacbacba','abcabcabcabc'),(4831,3,4,'cbacbacbacba','abcabcabcabc'),(4832,3,4,'cbacbacbacba','abcabcabcabc'),(4833,3,4,'cbacbacbacba','abcabcabcabc'),(4834,3,4,'cbacbacbacba','abcabcabcabc'),(4835,3,4,'cbacbacbacba','abcabcabcabc'),(4836,3,4,'cbacbacbacba','abcabcabcabc'),(4837,3,4,'cbacbacbacba','abcabcabcabc'),(4838,3,4,'cbacbacbacba','abcabcabcabc'),(4839,3,4,'cbacbacbacba','abcabcabcabc'),(4840,3,4,'cbacbacbacba','abcabcabcabc'),(4841,3,4,'cbacbacbacba','abcabcabcabc'),(4842,3,4,'cbacbacbacba','abcabcabcabc'),(4843,3,4,'cbacbacbacba','abcabcabcabc'),(4844,3,4,'cbacbacbacba','abcabcabcabc'),(4845,3,4,'cbacbacbacba','abcabcabcabc'),(4846,3,4,'cbacbacbacba','abcabcabcabc'),(4847,3,4,'cbacbacbacba','abcabcabcabc'),(4848,3,4,'cbacbacbacba','abcabcabcabc'),(4849,3,4,'cbacbacbacba','abcabcabcabc'),(4850,3,4,'cbacbacbacba','abcabcabcabc'),(4851,3,4,'cbacbacbacba','abcabcabcabc'),(4852,3,4,'cbacbacbacba','abcabcabcabc'),(4853,3,4,'cbacbacbacba','abcabcabcabc'),(4854,3,4,'cbacbacbacba','abcabcabcabc'),(4855,3,4,'cbacbacbacba','abcabcabcabc'),(4856,3,4,'cbacbacbacba','abcabcabcabc'),(4857,3,4,'cbacbacbacba','abcabcabcabc'),(4858,3,4,'cbacbacbacba','abcabcabcabc'),(4859,3,4,'cbacbacbacba','abcabcabcabc'),(4860,3,4,'cbacbacbacba','abcabcabcabc'),(4861,3,4,'cbacbacbacba','abcabcabcabc'),(4862,3,4,'cbacbacbacba','abcabcabcabc'),(4863,3,4,'cbacbacbacba','abcabcabcabc'),(4864,3,4,'cbacbacbacba','abcabcabcabc'),(4865,3,4,'cbacbacbacba','abcabcabcabc'),(4866,3,4,'cbacbacbacba','abcabcabcabc'),(4867,3,4,'cbacbacbacba','abcabcabcabc'),(4868,3,4,'cbacbacbacba','abcabcabcabc'),(4869,3,4,'cbacbacbacba','abcabcabcabc'),(4870,3,4,'cbacbacbacba','abcabcabcabc'),(4871,3,4,'cbacbacbacba','abcabcabcabc'),(4872,3,4,'cbacbacbacba','abcabcabcabc'),(4873,3,4,'cbacbacbacba','abcabcabcabc'),(4874,3,4,'cbacbacbacba','abcabcabcabc'),(4875,3,4,'cbacbacbacba','abcabcabcabc'),(4876,3,4,'cbacbacbacba','abcabcabcabc'),(4877,3,4,'cbacbacbacba','abcabcabcabc'),(4878,3,4,'cbacbacbacba','abcabcabcabc'),(4879,3,4,'cbacbacbacba','abcabcabcabc'),(4880,3,4,'cbacbacbacba','abcabcabcabc'),(4881,3,4,'cbacbacbacba','abcabcabcabc'),(4882,3,4,'cbacbacbacba','abcabcabcabc'),(4883,3,4,'cbacbacbacba','abcabcabcabc'),(4884,3,4,'cbacbacbacba','abcabcabcabc'),(4885,3,4,'cbacbacbacba','abcabcabcabc'),(4886,3,4,'cbacbacbacba','abcabcabcabc'),(4887,3,4,'cbacbacbacba','abcabcabcabc'),(4888,3,4,'cbacbacbacba','abcabcabcabc'),(4889,3,4,'cbacbacbacba','abcabcabcabc'),(4890,3,4,'cbacbacbacba','abcabcabcabc'),(4891,3,4,'cbacbacbacba','abcabcabcabc'),(4892,3,4,'cbacbacbacba','abcabcabcabc'),(4893,3,4,'cbacbacbacba','abcabcabcabc'),(4894,3,4,'cbacbacbacba','abcabcabcabc'),(4895,3,4,'cbacbacbacba','abcabcabcabc'),(4896,3,4,'cbacbacbacba','abcabcabcabc'),(4897,3,4,'cbacbacbacba','abcabcabcabc'),(4898,3,4,'cbacbacbacba','abcabcabcabc'),(4899,3,4,'cbacbacbacba','abcabcabcabc'),(4900,3,4,'cbacbacbacba','abcabcabcabc'),(4901,3,4,'cbacbacbacba','abcabcabcabc'),(4902,3,4,'cbacbacbacba','abcabcabcabc'),(4903,3,4,'cbacbacbacba','abcabcabcabc'),(4904,3,4,'cbacbacbacba','abcabcabcabc'),(4905,3,4,'cbacbacbacba','abcabcabcabc'),(4906,3,4,'cbacbacbacba','abcabcabcabc'),(4907,3,4,'cbacbacbacba','abcabcabcabc'),(4908,3,4,'cbacbacbacba','abcabcabcabc'),(4909,3,4,'cbacbacbacba','abcabcabcabc'),(4910,3,4,'cbacbacbacba','abcabcabcabc'),(4911,3,4,'cbacbacbacba','abcabcabcabc'),(4912,3,4,'cbacbacbacba','abcabcabcabc'),(4913,3,4,'cbacbacbacba','abcabcabcabc'),(4914,3,4,'cbacbacbacba','abcabcabcabc'),(4915,3,4,'cbacbacbacba','abcabcabcabc'),(4916,3,4,'cbacbacbacba','abcabcabcabc'),(4917,3,4,'cbacbacbacba','abcabcabcabc'),(4918,3,4,'cbacbacbacba','abcabcabcabc'),(4919,3,4,'cbacbacbacba','abcabcabcabc'),(4920,3,4,'cbacbacbacba','abcabcabcabc'),(4921,3,4,'cbacbacbacba','abcabcabcabc'),(4922,3,4,'cbacbacbacba','abcabcabcabc'),(4923,3,4,'cbacbacbacba','abcabcabcabc'),(4924,3,4,'cbacbacbacba','abcabcabcabc'),(4925,3,4,'cbacbacbacba','abcabcabcabc'),(4926,3,4,'cbacbacbacba','abcabcabcabc'),(4927,3,4,'cbacbacbacba','abcabcabcabc'),(4928,3,4,'cbacbacbacba','abcabcabcabc'),(4929,3,4,'cbacbacbacba','abcabcabcabc'),(4930,3,4,'cbacbacbacba','abcabcabcabc'),(4931,3,4,'cbacbacbacba','abcabcabcabc'),(4932,3,4,'cbacbacbacba','abcabcabcabc'),(4933,3,4,'cbacbacbacba','abcabcabcabc'),(4934,3,4,'cbacbacbacba','abcabcabcabc'),(4935,3,4,'cbacbacbacba','abcabcabcabc'),(4936,3,4,'cbacbacbacba','abcabcabcabc'),(4937,3,4,'cbacbacbacba','abcabcabcabc'),(4938,3,4,'cbacbacbacba','abcabcabcabc'),(4939,3,4,'cbacbacbacba','abcabcabcabc'),(4940,3,4,'cbacbacbacba','abcabcabcabc'),(4941,3,4,'cbacbacbacba','abcabcabcabc'),(4942,3,4,'cbacbacbacba','abcabcabcabc'),(4943,3,4,'cbacbacbacba','abcabcabcabc'),(4944,3,4,'cbacbacbacba','abcabcabcabc'),(4945,3,4,'cbacbacbacba','abcabcabcabc'),(4946,3,4,'cbacbacbacba','abcabcabcabc'),(4947,3,4,'cbacbacbacba','abcabcabcabc'),(4948,3,4,'cbacbacbacba','abcabcabcabc'),(4949,3,4,'cbacbacbacba','abcabcabcabc'),(4950,3,4,'cbacbacbacba','abcabcabcabc'),(4951,3,4,'cbacbacbacba','abcabcabcabc'),(4952,3,4,'cbacbacbacba','abcabcabcabc'),(4953,3,4,'cbacbacbacba','abcabcabcabc'),(4954,3,4,'cbacbacbacba','abcabcabcabc'),(4955,3,4,'cbacbacbacba','abcabcabcabc'),(4956,3,4,'cbacbacbacba','abcabcabcabc'),(4957,3,4,'cbacbacbacba','abcabcabcabc'),(4958,3,4,'cbacbacbacba','abcabcabcabc'),(4959,3,4,'cbacbacbacba','abcabcabcabc'),(4960,3,4,'cbacbacbacba','abcabcabcabc'),(4961,3,4,'cbacbacbacba','abcabcabcabc'),(4962,3,4,'cbacbacbacba','abcabcabcabc'),(4963,3,4,'cbacbacbacba','abcabcabcabc'),(4964,3,4,'cbacbacbacba','abcabcabcabc'),(4965,3,4,'cbacbacbacba','abcabcabcabc'),(4966,3,4,'cbacbacbacba','abcabcabcabc'),(4967,3,4,'cbacbacbacba','abcabcabcabc'),(4968,3,4,'cbacbacbacba','abcabcabcabc'),(4969,3,4,'cbacbacbacba','abcabcabcabc'),(4970,3,4,'cbacbacbacba','abcabcabcabc'),(4971,3,4,'cbacbacbacba','abcabcabcabc'),(4972,3,4,'cbacbacbacba','abcabcabcabc'),(4973,3,4,'cbacbacbacba','abcabcabcabc'),(4974,3,4,'cbacbacbacba','abcabcabcabc'),(4975,3,4,'cbacbacbacba','abcabcabcabc'),(4976,3,4,'cbacbacbacba','abcabcabcabc'),(4977,3,4,'cbacbacbacba','abcabcabcabc'),(4978,3,4,'cbacbacbacba','abcabcabcabc'),(4979,3,4,'cbacbacbacba','abcabcabcabc'),(4980,3,4,'cbacbacbacba','abcabcabcabc'),(4981,3,4,'cbacbacbacba','abcabcabcabc'),(4982,3,4,'cbacbacbacba','abcabcabcabc'),(4983,3,4,'cbacbacbacba','abcabcabcabc'),(4984,3,4,'cbacbacbacba','abcabcabcabc'),(4985,3,4,'cbacbacbacba','abcabcabcabc'),(4986,3,4,'cbacbacbacba','abcabcabcabc'),(4987,3,4,'cbacbacbacba','abcabcabcabc'),(4988,3,4,'cbacbacbacba','abcabcabcabc'),(4989,3,4,'cbacbacbacba','abcabcabcabc'),(4990,3,4,'cbacbacbacba','abcabcabcabc'),(4991,3,4,'cbacbacbacba','abcabcabcabc'),(4992,3,4,'cbacbacbacba','abcabcabcabc'),(4993,3,4,'cbacbacbacba','abcabcabcabc'),(4994,3,4,'cbacbacbacba','abcabcabcabc'),(4995,3,4,'cbacbacbacba','abcabcabcabc'),(4996,3,4,'cbacbacbacba','abcabcabcabc'),(4997,3,4,'cbacbacbacba','abcabcabcabc'),(4998,3,4,'cbacbacbacba','abcabcabcabc'),(4999,3,4,'cbacbacbacba','abcabcabcabc'),(5000,3,4,'cbacbacbacba','abcabcabcabc'),(5001,3,4,'cbacbacbacba','abcabcabcabc'),(5002,3,4,'cbacbacbacba','abcabcabcabc'),(5003,3,4,'cbacbacbacba','abcabcabcabc'),(5004,3,4,'cbacbacbacba','abcabcabcabc'),(5005,3,4,'cbacbacbacba','abcabcabcabc'),(5006,3,4,'cbacbacbacba','abcabcabcabc'),(5007,3,4,'cbacbacbacba','abcabcabcabc'),(5008,3,4,'cbacbacbacba','abcabcabcabc'),(5009,3,4,'cbacbacbacba','abcabcabcabc'),(5010,3,4,'cbacbacbacba','abcabcabcabc'),(5011,3,4,'cbacbacbacba','abcabcabcabc'),(5012,3,4,'cbacbacbacba','abcabcabcabc'),(5013,3,4,'cbacbacbacba','abcabcabcabc'),(5014,3,4,'cbacbacbacba','abcabcabcabc'),(5015,3,4,'cbacbacbacba','abcabcabcabc'),(5016,3,4,'cbacbacbacba','abcabcabcabc'),(5017,3,4,'cbacbacbacba','abcabcabcabc'),(5018,3,4,'cbacbacbacba','abcabcabcabc'),(5019,3,4,'cbacbacbacba','abcabcabcabc'),(5020,3,4,'cbacbacbacba','abcabcabcabc'),(5021,3,4,'cbacbacbacba','abcabcabcabc'),(5022,3,4,'cbacbacbacba','abcabcabcabc'),(5023,3,4,'cbacbacbacba','abcabcabcabc'),(5024,3,4,'cbacbacbacba','abcabcabcabc'),(5025,3,4,'cbacbacbacba','abcabcabcabc'),(5026,3,4,'cbacbacbacba','abcabcabcabc'),(5027,3,4,'cbacbacbacba','abcabcabcabc'),(5028,3,4,'cbacbacbacba','abcabcabcabc'),(5029,3,4,'cbacbacbacba','abcabcabcabc'),(5030,3,4,'cbacbacbacba','abcabcabcabc'),(5031,3,4,'cbacbacbacba','abcabcabcabc'),(5032,3,4,'cbacbacbacba','abcabcabcabc'),(5033,3,4,'cbacbacbacba','abcabcabcabc'),(5034,3,4,'cbacbacbacba','abcabcabcabc'),(5035,3,4,'cbacbacbacba','abcabcabcabc'),(5036,3,4,'cbacbacbacba','abcabcabcabc'),(5037,3,4,'cbacbacbacba','abcabcabcabc'),(5038,3,4,'cbacbacbacba','abcabcabcabc'),(5039,3,4,'cbacbacbacba','abcabcabcabc'),(5040,3,4,'cbacbacbacba','abcabcabcabc'),(5041,3,4,'cbacbacbacba','abcabcabcabc'),(5042,3,4,'cbacbacbacba','abcabcabcabc'),(5043,3,4,'cbacbacbacba','abcabcabcabc'),(5044,3,4,'cbacbacbacba','abcabcabcabc'),(5045,3,4,'cbacbacbacba','abcabcabcabc'),(5046,3,4,'cbacbacbacba','abcabcabcabc'),(5047,3,4,'cbacbacbacba','abcabcabcabc'),(5048,3,4,'cbacbacbacba','abcabcabcabc'),(5049,3,4,'cbacbacbacba','abcabcabcabc'),(5050,3,4,'cbacbacbacba','abcabcabcabc'),(5051,3,4,'cbacbacbacba','abcabcabcabc'),(5052,3,4,'cbacbacbacba','abcabcabcabc'),(5053,3,4,'cbacbacbacba','abcabcabcabc'),(5054,3,4,'cbacbacbacba','abcabcabcabc'),(5055,3,4,'cbacbacbacba','abcabcabcabc'),(5056,3,4,'cbacbacbacba','abcabcabcabc'),(5057,3,4,'cbacbacbacba','abcabcabcabc'),(5058,3,4,'cbacbacbacba','abcabcabcabc'),(5059,3,4,'cbacbacbacba','abcabcabcabc'),(5060,3,4,'cbacbacbacba','abcabcabcabc'),(5061,3,4,'cbacbacbacba','abcabcabcabc'),(5062,3,4,'cbacbacbacba','abcabcabcabc'),(5063,3,4,'cbacbacbacba','abcabcabcabc'),(5064,3,4,'cbacbacbacba','abcabcabcabc'),(5065,3,4,'cbacbacbacba','abcabcabcabc'),(5066,3,4,'cbacbacbacba','abcabcabcabc'),(5067,3,4,'cbacbacbacba','abcabcabcabc'),(5068,3,4,'cbacbacbacba','abcabcabcabc'),(5069,3,4,'cbacbacbacba','abcabcabcabc'),(5070,3,4,'cbacbacbacba','abcabcabcabc'),(5071,3,4,'cbacbacbacba','abcabcabcabc'),(5072,3,4,'cbacbacbacba','abcabcabcabc'),(5073,3,4,'cbacbacbacba','abcabcabcabc'),(5074,3,4,'cbacbacbacba','abcabcabcabc'),(5075,3,4,'cbacbacbacba','abcabcabcabc'),(5076,3,4,'cbacbacbacba','abcabcabcabc'),(5077,3,4,'cbacbacbacba','abcabcabcabc'),(5078,3,4,'cbacbacbacba','abcabcabcabc'),(5079,3,4,'cbacbacbacba','abcabcabcabc'),(5080,3,4,'cbacbacbacba','abcabcabcabc'),(5081,3,4,'cbacbacbacba','abcabcabcabc'),(5082,3,4,'cbacbacbacba','abcabcabcabc'),(5083,3,4,'cbacbacbacba','abcabcabcabc'),(5084,3,4,'cbacbacbacba','abcabcabcabc'),(5085,3,4,'cbacbacbacba','abcabcabcabc'),(5086,3,4,'cbacbacbacba','abcabcabcabc'),(5087,3,4,'cbacbacbacba','abcabcabcabc'),(5088,3,4,'cbacbacbacba','abcabcabcabc'),(5089,3,4,'cbacbacbacba','abcabcabcabc'),(5090,3,4,'cbacbacbacba','abcabcabcabc'),(5091,3,4,'cbacbacbacba','abcabcabcabc'),(5092,3,4,'cbacbacbacba','abcabcabcabc'),(5093,3,4,'cbacbacbacba','abcabcabcabc'),(5094,3,4,'cbacbacbacba','abcabcabcabc'),(5095,3,4,'cbacbacbacba','abcabcabcabc'),(5096,3,4,'cbacbacbacba','abcabcabcabc'),(5097,3,4,'cbacbacbacba','abcabcabcabc'),(5098,3,4,'cbacbacbacba','abcabcabcabc'),(5099,3,4,'cbacbacbacba','abcabcabcabc'),(5100,3,4,'cbacbacbacba','abcabcabcabc'),(5101,3,4,'cbacbacbacba','abcabcabcabc'),(5102,3,4,'cbacbacbacba','abcabcabcabc'),(5103,3,4,'cbacbacbacba','abcabcabcabc'),(5104,3,4,'cbacbacbacba','abcabcabcabc'),(5105,3,4,'cbacbacbacba','abcabcabcabc'),(5106,3,4,'cbacbacbacba','abcabcabcabc'),(5107,3,4,'cbacbacbacba','abcabcabcabc'),(5108,3,4,'cbacbacbacba','abcabcabcabc'),(5109,3,4,'cbacbacbacba','abcabcabcabc'),(5110,3,4,'cbacbacbacba','abcabcabcabc'),(5111,4,2,'bcabcabcabca','acbacbacbacb'),(5112,4,2,'bcabcabcabca','acbacbacbacb'),(5113,4,2,'bcabcabcabca','acbacbacbacb'),(5114,4,2,'bcabcabcabca','acbacbacbacb'),(5115,4,2,'bcabcabcabca','acbacbacbacb'),(5116,4,2,'bcabcabcabca','acbacbacbacb'),(5117,4,2,'bcabcabcabca','acbacbacbacb'),(5118,4,2,'bcabcabcabca','acbacbacbacb'),(5119,4,2,'bcabcabcabca','acbacbacbacb'),(5120,4,2,'bcabcabcabca','acbacbacbacb'),(5121,4,3,'bcabcabcabca','acbacbacbacb'),(5122,4,3,'bcabcabcabca','acbacbacbacb'),(5123,4,3,'bcabcabcabca','acbacbacbacb'),(5124,4,3,'bcabcabcabca','acbacbacbacb'),(5125,4,3,'bcabcabcabca','acbacbacbacb'),(5126,4,3,'bcabcabcabca','acbacbacbacb'),(5127,4,3,'bcabcabcabca','acbacbacbacb'),(5128,4,3,'bcabcabcabca','acbacbacbacb'),(5129,4,3,'bcabcabcabca','acbacbacbacb'),(5130,4,3,'bcabcabcabca','acbacbacbacb'),(5131,4,3,'bcabcabcabca','acbacbacbacb'),(5132,4,3,'bcabcabcabca','acbacbacbacb'),(5133,4,3,'bcabcabcabca','acbacbacbacb'),(5134,4,3,'bcabcabcabca','acbacbacbacb'),(5135,4,3,'bcabcabcabca','acbacbacbacb'),(5136,4,3,'bcabcabcabca','acbacbacbacb'),(5137,4,3,'bcabcabcabca','acbacbacbacb'),(5138,4,3,'bcabcabcabca','acbacbacbacb'),(5139,4,3,'bcabcabcabca','acbacbacbacb'),(5140,4,3,'bcabcabcabca','acbacbacbacb'),(5141,4,3,'bcabcabcabca','acbacbacbacb'),(5142,4,3,'bcabcabcabca','acbacbacbacb'),(5143,4,3,'bcabcabcabca','acbacbacbacb'),(5144,4,3,'bcabcabcabca','acbacbacbacb'),(5145,4,3,'bcabcabcabca','acbacbacbacb'),(5146,4,3,'bcabcabcabca','acbacbacbacb'),(5147,4,3,'bcabcabcabca','acbacbacbacb'),(5148,4,3,'bcabcabcabca','acbacbacbacb'),(5149,4,3,'bcabcabcabca','acbacbacbacb'),(5150,4,3,'bcabcabcabca','acbacbacbacb'),(5151,4,3,'bcabcabcabca','acbacbacbacb'),(5152,4,3,'bcabcabcabca','acbacbacbacb'),(5153,4,3,'bcabcabcabca','acbacbacbacb'),(5154,4,3,'bcabcabcabca','acbacbacbacb'),(5155,4,3,'bcabcabcabca','acbacbacbacb'),(5156,4,3,'bcabcabcabca','acbacbacbacb'),(5157,4,3,'bcabcabcabca','acbacbacbacb'),(5158,4,3,'bcabcabcabca','acbacbacbacb'),(5159,4,3,'bcabcabcabca','acbacbacbacb'),(5160,4,3,'bcabcabcabca','acbacbacbacb'),(5161,4,3,'bcabcabcabca','acbacbacbacb'),(5162,4,3,'bcabcabcabca','acbacbacbacb'),(5163,4,3,'bcabcabcabca','acbacbacbacb'),(5164,4,3,'bcabcabcabca','acbacbacbacb'),(5165,4,3,'bcabcabcabca','acbacbacbacb'),(5166,4,3,'bcabcabcabca','acbacbacbacb'),(5167,4,3,'bcabcabcabca','acbacbacbacb'),(5168,4,3,'bcabcabcabca','acbacbacbacb'),(5169,4,3,'bcabcabcabca','acbacbacbacb'),(5170,4,3,'bcabcabcabca','acbacbacbacb'),(5171,4,3,'bcabcabcabca','acbacbacbacb'),(5172,4,3,'bcabcabcabca','acbacbacbacb'),(5173,4,3,'bcabcabcabca','acbacbacbacb'),(5174,4,3,'bcabcabcabca','acbacbacbacb'),(5175,4,3,'bcabcabcabca','acbacbacbacb'),(5176,4,3,'bcabcabcabca','acbacbacbacb'),(5177,4,3,'bcabcabcabca','acbacbacbacb'),(5178,4,3,'bcabcabcabca','acbacbacbacb'),(5179,4,3,'bcabcabcabca','acbacbacbacb'),(5180,4,3,'bcabcabcabca','acbacbacbacb'),(5181,4,3,'bcabcabcabca','acbacbacbacb'),(5182,4,3,'bcabcabcabca','acbacbacbacb'),(5183,4,3,'bcabcabcabca','acbacbacbacb'),(5184,4,3,'bcabcabcabca','acbacbacbacb'),(5185,4,3,'bcabcabcabca','acbacbacbacb'),(5186,4,3,'bcabcabcabca','acbacbacbacb'),(5187,4,3,'bcabcabcabca','acbacbacbacb'),(5188,4,3,'bcabcabcabca','acbacbacbacb'),(5189,4,3,'bcabcabcabca','acbacbacbacb'),(5190,4,3,'bcabcabcabca','acbacbacbacb'),(5191,4,3,'bcabcabcabca','acbacbacbacb'),(5192,4,3,'bcabcabcabca','acbacbacbacb'),(5193,4,3,'bcabcabcabca','acbacbacbacb'),(5194,4,3,'bcabcabcabca','acbacbacbacb'),(5195,4,3,'bcabcabcabca','acbacbacbacb'),(5196,4,3,'bcabcabcabca','acbacbacbacb'),(5197,4,3,'bcabcabcabca','acbacbacbacb'),(5198,4,3,'bcabcabcabca','acbacbacbacb'),(5199,4,3,'bcabcabcabca','acbacbacbacb'),(5200,4,3,'bcabcabcabca','acbacbacbacb'),(5201,4,3,'bcabcabcabca','acbacbacbacb'),(5202,4,3,'bcabcabcabca','acbacbacbacb'),(5203,4,3,'bcabcabcabca','acbacbacbacb'),(5204,4,3,'bcabcabcabca','acbacbacbacb'),(5205,4,3,'bcabcabcabca','acbacbacbacb'),(5206,4,3,'bcabcabcabca','acbacbacbacb'),(5207,4,3,'bcabcabcabca','acbacbacbacb'),(5208,4,3,'bcabcabcabca','acbacbacbacb'),(5209,4,3,'bcabcabcabca','acbacbacbacb'),(5210,4,3,'bcabcabcabca','acbacbacbacb'),(5211,4,3,'bcabcabcabca','acbacbacbacb'),(5212,4,3,'bcabcabcabca','acbacbacbacb'),(5213,4,3,'bcabcabcabca','acbacbacbacb'),(5214,4,3,'bcabcabcabca','acbacbacbacb'),(5215,4,3,'bcabcabcabca','acbacbacbacb'),(5216,4,3,'bcabcabcabca','acbacbacbacb'),(5217,4,3,'bcabcabcabca','acbacbacbacb'),(5218,4,3,'bcabcabcabca','acbacbacbacb'),(5219,4,3,'bcabcabcabca','acbacbacbacb'),(5220,4,3,'bcabcabcabca','acbacbacbacb'),(5221,4,3,'bcabcabcabca','acbacbacbacb'),(5222,4,3,'bcabcabcabca','acbacbacbacb'),(5223,4,3,'bcabcabcabca','acbacbacbacb'),(5224,4,3,'bcabcabcabca','acbacbacbacb'),(5225,4,3,'bcabcabcabca','acbacbacbacb'),(5226,4,3,'bcabcabcabca','acbacbacbacb'),(5227,4,3,'bcabcabcabca','acbacbacbacb'),(5228,4,3,'bcabcabcabca','acbacbacbacb'),(5229,4,3,'bcabcabcabca','acbacbacbacb'),(5230,4,3,'bcabcabcabca','acbacbacbacb'),(5231,4,3,'bcabcabcabca','acbacbacbacb'),(5232,4,3,'bcabcabcabca','acbacbacbacb'),(5233,4,3,'bcabcabcabca','acbacbacbacb'),(5234,4,3,'bcabcabcabca','acbacbacbacb'),(5235,4,3,'bcabcabcabca','acbacbacbacb'),(5236,4,3,'bcabcabcabca','acbacbacbacb'),(5237,4,3,'bcabcabcabca','acbacbacbacb'),(5238,4,3,'bcabcabcabca','acbacbacbacb'),(5239,4,3,'bcabcabcabca','acbacbacbacb'),(5240,4,3,'bcabcabcabca','acbacbacbacb'),(5241,4,3,'bcabcabcabca','acbacbacbacb'),(5242,4,3,'bcabcabcabca','acbacbacbacb'),(5243,4,3,'bcabcabcabca','acbacbacbacb'),(5244,4,3,'bcabcabcabca','acbacbacbacb'),(5245,4,3,'bcabcabcabca','acbacbacbacb'),(5246,4,3,'bcabcabcabca','acbacbacbacb'),(5247,4,3,'bcabcabcabca','acbacbacbacb'),(5248,4,3,'bcabcabcabca','acbacbacbacb'),(5249,4,3,'bcabcabcabca','acbacbacbacb'),(5250,4,3,'bcabcabcabca','acbacbacbacb'),(5251,4,3,'bcabcabcabca','acbacbacbacb'),(5252,4,3,'bcabcabcabca','acbacbacbacb'),(5253,4,3,'bcabcabcabca','acbacbacbacb'),(5254,4,3,'bcabcabcabca','acbacbacbacb'),(5255,4,3,'bcabcabcabca','acbacbacbacb'),(5256,4,3,'bcabcabcabca','acbacbacbacb'),(5257,4,3,'bcabcabcabca','acbacbacbacb'),(5258,4,3,'bcabcabcabca','acbacbacbacb'),(5259,4,3,'bcabcabcabca','acbacbacbacb'),(5260,4,3,'bcabcabcabca','acbacbacbacb'),(5261,4,3,'bcabcabcabca','acbacbacbacb'),(5262,4,3,'bcabcabcabca','acbacbacbacb'),(5263,4,3,'bcabcabcabca','acbacbacbacb'),(5264,4,3,'bcabcabcabca','acbacbacbacb'),(5265,4,3,'bcabcabcabca','acbacbacbacb'),(5266,4,3,'bcabcabcabca','acbacbacbacb'),(5267,4,3,'bcabcabcabca','acbacbacbacb'),(5268,4,3,'bcabcabcabca','acbacbacbacb'),(5269,4,3,'bcabcabcabca','acbacbacbacb'),(5270,4,3,'bcabcabcabca','acbacbacbacb'),(5271,4,3,'bcabcabcabca','acbacbacbacb'),(5272,4,3,'bcabcabcabca','acbacbacbacb'),(5273,4,3,'bcabcabcabca','acbacbacbacb'),(5274,4,3,'bcabcabcabca','acbacbacbacb'),(5275,4,3,'bcabcabcabca','acbacbacbacb'),(5276,4,3,'bcabcabcabca','acbacbacbacb'),(5277,4,3,'bcabcabcabca','acbacbacbacb'),(5278,4,3,'bcabcabcabca','acbacbacbacb'),(5279,4,3,'bcabcabcabca','acbacbacbacb'),(5280,4,3,'bcabcabcabca','acbacbacbacb'),(5281,4,3,'bcabcabcabca','acbacbacbacb'),(5282,4,3,'bcabcabcabca','acbacbacbacb'),(5283,4,3,'bcabcabcabca','acbacbacbacb'),(5284,4,3,'bcabcabcabca','acbacbacbacb'),(5285,4,3,'bcabcabcabca','acbacbacbacb'),(5286,4,3,'bcabcabcabca','acbacbacbacb'),(5287,4,3,'bcabcabcabca','acbacbacbacb'),(5288,4,3,'bcabcabcabca','acbacbacbacb'),(5289,4,3,'bcabcabcabca','acbacbacbacb'),(5290,4,3,'bcabcabcabca','acbacbacbacb'),(5291,4,3,'bcabcabcabca','acbacbacbacb'),(5292,4,3,'bcabcabcabca','acbacbacbacb'),(5293,4,3,'bcabcabcabca','acbacbacbacb'),(5294,4,3,'bcabcabcabca','acbacbacbacb'),(5295,4,3,'bcabcabcabca','acbacbacbacb'),(5296,4,3,'bcabcabcabca','acbacbacbacb'),(5297,4,3,'bcabcabcabca','acbacbacbacb'),(5298,4,3,'bcabcabcabca','acbacbacbacb'),(5299,4,3,'bcabcabcabca','acbacbacbacb'),(5300,4,3,'bcabcabcabca','acbacbacbacb'),(5301,4,3,'bcabcabcabca','acbacbacbacb'),(5302,4,3,'bcabcabcabca','acbacbacbacb'),(5303,4,3,'bcabcabcabca','acbacbacbacb'),(5304,4,3,'bcabcabcabca','acbacbacbacb'),(5305,4,3,'bcabcabcabca','acbacbacbacb'),(5306,4,3,'bcabcabcabca','acbacbacbacb'),(5307,4,3,'bcabcabcabca','acbacbacbacb'),(5308,4,3,'bcabcabcabca','acbacbacbacb'),(5309,4,3,'bcabcabcabca','acbacbacbacb'),(5310,4,3,'bcabcabcabca','acbacbacbacb'),(5311,4,3,'bcabcabcabca','acbacbacbacb'),(5312,4,3,'bcabcabcabca','acbacbacbacb'),(5313,4,3,'bcabcabcabca','acbacbacbacb'),(5314,4,3,'bcabcabcabca','acbacbacbacb'),(5315,4,3,'bcabcabcabca','acbacbacbacb'),(5316,4,3,'bcabcabcabca','acbacbacbacb'),(5317,4,3,'bcabcabcabca','acbacbacbacb'),(5318,4,3,'bcabcabcabca','acbacbacbacb'),(5319,4,3,'bcabcabcabca','acbacbacbacb'),(5320,4,3,'bcabcabcabca','acbacbacbacb'),(5321,4,3,'bcabcabcabca','acbacbacbacb'),(5322,4,3,'bcabcabcabca','acbacbacbacb'),(5323,4,3,'bcabcabcabca','acbacbacbacb'),(5324,4,3,'bcabcabcabca','acbacbacbacb'),(5325,4,3,'bcabcabcabca','acbacbacbacb'),(5326,4,3,'bcabcabcabca','acbacbacbacb'),(5327,4,3,'bcabcabcabca','acbacbacbacb'),(5328,4,3,'bcabcabcabca','acbacbacbacb'),(5329,4,3,'bcabcabcabca','acbacbacbacb'),(5330,4,3,'bcabcabcabca','acbacbacbacb'),(5331,4,3,'bcabcabcabca','acbacbacbacb'),(5332,4,3,'bcabcabcabca','acbacbacbacb'),(5333,4,3,'bcabcabcabca','acbacbacbacb'),(5334,4,3,'bcabcabcabca','acbacbacbacb'),(5335,4,3,'bcabcabcabca','acbacbacbacb'),(5336,4,3,'bcabcabcabca','acbacbacbacb'),(5337,4,3,'bcabcabcabca','acbacbacbacb'),(5338,4,3,'bcabcabcabca','acbacbacbacb'),(5339,4,3,'bcabcabcabca','acbacbacbacb'),(5340,4,3,'bcabcabcabca','acbacbacbacb'),(5341,4,3,'bcabcabcabca','acbacbacbacb'),(5342,4,3,'bcabcabcabca','acbacbacbacb'),(5343,4,3,'bcabcabcabca','acbacbacbacb'),(5344,4,3,'bcabcabcabca','acbacbacbacb'),(5345,4,3,'bcabcabcabca','acbacbacbacb'),(5346,4,3,'bcabcabcabca','acbacbacbacb'),(5347,4,3,'bcabcabcabca','acbacbacbacb'),(5348,4,3,'bcabcabcabca','acbacbacbacb'),(5349,4,3,'bcabcabcabca','acbacbacbacb'),(5350,4,3,'bcabcabcabca','acbacbacbacb'),(5351,4,3,'bcabcabcabca','acbacbacbacb'),(5352,4,3,'bcabcabcabca','acbacbacbacb'),(5353,4,3,'bcabcabcabca','acbacbacbacb'),(5354,4,3,'bcabcabcabca','acbacbacbacb'),(5355,4,3,'bcabcabcabca','acbacbacbacb'),(5356,4,3,'bcabcabcabca','acbacbacbacb'),(5357,4,3,'bcabcabcabca','acbacbacbacb'),(5358,4,3,'bcabcabcabca','acbacbacbacb'),(5359,4,3,'bcabcabcabca','acbacbacbacb'),(5360,4,3,'bcabcabcabca','acbacbacbacb'),(5361,4,3,'bcabcabcabca','acbacbacbacb'),(5362,4,3,'bcabcabcabca','acbacbacbacb'),(5363,4,3,'bcabcabcabca','acbacbacbacb'),(5364,4,3,'bcabcabcabca','acbacbacbacb'),(5365,4,3,'bcabcabcabca','acbacbacbacb'),(5366,4,3,'bcabcabcabca','acbacbacbacb'),(5367,4,3,'bcabcabcabca','acbacbacbacb'),(5368,4,3,'bcabcabcabca','acbacbacbacb'),(5369,4,3,'bcabcabcabca','acbacbacbacb'),(5370,4,3,'bcabcabcabca','acbacbacbacb'),(5371,4,3,'bcabcabcabca','acbacbacbacb'),(5372,4,3,'bcabcabcabca','acbacbacbacb'),(5373,4,3,'bcabcabcabca','acbacbacbacb'),(5374,4,3,'bcabcabcabca','acbacbacbacb'),(5375,4,3,'bcabcabcabca','acbacbacbacb'),(5376,4,3,'bcabcabcabca','acbacbacbacb'),(5377,4,3,'bcabcabcabca','acbacbacbacb'),(5378,4,3,'bcabcabcabca','acbacbacbacb'),(5379,4,3,'bcabcabcabca','acbacbacbacb'),(5380,4,3,'bcabcabcabca','acbacbacbacb'),(5381,4,3,'bcabcabcabca','acbacbacbacb'),(5382,4,3,'bcabcabcabca','acbacbacbacb'),(5383,4,3,'bcabcabcabca','acbacbacbacb'),(5384,4,3,'bcabcabcabca','acbacbacbacb'),(5385,4,3,'bcabcabcabca','acbacbacbacb'),(5386,4,3,'bcabcabcabca','acbacbacbacb'),(5387,4,3,'bcabcabcabca','acbacbacbacb'),(5388,4,3,'bcabcabcabca','acbacbacbacb'),(5389,4,3,'bcabcabcabca','acbacbacbacb'),(5390,4,3,'bcabcabcabca','acbacbacbacb'),(5391,4,3,'bcabcabcabca','acbacbacbacb'),(5392,4,3,'bcabcabcabca','acbacbacbacb'),(5393,4,3,'bcabcabcabca','acbacbacbacb'),(5394,4,3,'bcabcabcabca','acbacbacbacb'),(5395,4,3,'bcabcabcabca','acbacbacbacb'),(5396,4,3,'bcabcabcabca','acbacbacbacb'),(5397,4,3,'bcabcabcabca','acbacbacbacb'),(5398,4,3,'bcabcabcabca','acbacbacbacb'),(5399,4,3,'bcabcabcabca','acbacbacbacb'),(5400,4,3,'bcabcabcabca','acbacbacbacb'),(5401,4,3,'bcabcabcabca','acbacbacbacb'),(5402,4,3,'bcabcabcabca','acbacbacbacb'),(5403,4,3,'bcabcabcabca','acbacbacbacb'),(5404,4,3,'bcabcabcabca','acbacbacbacb'),(5405,4,3,'bcabcabcabca','acbacbacbacb'),(5406,4,3,'bcabcabcabca','acbacbacbacb'),(5407,4,3,'bcabcabcabca','acbacbacbacb'),(5408,4,3,'bcabcabcabca','acbacbacbacb'),(5409,4,3,'bcabcabcabca','acbacbacbacb'),(5410,4,3,'bcabcabcabca','acbacbacbacb'),(5411,4,3,'bcabcabcabca','acbacbacbacb'),(5412,4,3,'bcabcabcabca','acbacbacbacb'),(5413,4,3,'bcabcabcabca','acbacbacbacb'),(5414,4,3,'bcabcabcabca','acbacbacbacb'),(5415,4,3,'bcabcabcabca','acbacbacbacb'),(5416,4,3,'bcabcabcabca','acbacbacbacb'),(5417,4,3,'bcabcabcabca','acbacbacbacb'),(5418,4,3,'bcabcabcabca','acbacbacbacb'),(5419,4,3,'bcabcabcabca','acbacbacbacb'),(5420,4,3,'bcabcabcabca','acbacbacbacb'),(5421,4,3,'bcabcabcabca','acbacbacbacb'),(5422,4,3,'bcabcabcabca','acbacbacbacb'),(5423,4,3,'bcabcabcabca','acbacbacbacb'),(5424,4,3,'bcabcabcabca','acbacbacbacb'),(5425,4,3,'bcabcabcabca','acbacbacbacb'),(5426,4,3,'bcabcabcabca','acbacbacbacb'),(5427,4,3,'bcabcabcabca','acbacbacbacb'),(5428,4,3,'bcabcabcabca','acbacbacbacb'),(5429,4,3,'bcabcabcabca','acbacbacbacb'),(5430,4,3,'bcabcabcabca','acbacbacbacb'),(5431,4,3,'bcabcabcabca','acbacbacbacb'),(5432,4,3,'bcabcabcabca','acbacbacbacb'),(5433,4,3,'bcabcabcabca','acbacbacbacb'),(5434,4,3,'bcabcabcabca','acbacbacbacb'),(5435,4,3,'bcabcabcabca','acbacbacbacb'),(5436,4,3,'bcabcabcabca','acbacbacbacb'),(5437,4,3,'bcabcabcabca','acbacbacbacb'),(5438,4,3,'bcabcabcabca','acbacbacbacb'),(5439,4,3,'bcabcabcabca','acbacbacbacb'),(5440,4,3,'bcabcabcabca','acbacbacbacb'),(5441,4,3,'bcabcabcabca','acbacbacbacb'),(5442,4,3,'bcabcabcabca','acbacbacbacb'),(5443,4,3,'bcabcabcabca','acbacbacbacb'),(5444,4,3,'bcabcabcabca','acbacbacbacb'),(5445,4,3,'bcabcabcabca','acbacbacbacb'),(5446,4,3,'bcabcabcabca','acbacbacbacb'),(5447,4,3,'bcabcabcabca','acbacbacbacb'),(5448,4,3,'bcabcabcabca','acbacbacbacb'),(5449,4,3,'bcabcabcabca','acbacbacbacb'),(5450,4,3,'bcabcabcabca','acbacbacbacb'),(5451,4,3,'bcabcabcabca','acbacbacbacb'),(5452,4,3,'bcabcabcabca','acbacbacbacb'),(5453,4,3,'bcabcabcabca','acbacbacbacb'),(5454,4,3,'bcabcabcabca','acbacbacbacb'),(5455,4,3,'bcabcabcabca','acbacbacbacb'),(5456,4,3,'bcabcabcabca','acbacbacbacb'),(5457,4,3,'bcabcabcabca','acbacbacbacb'),(5458,4,3,'bcabcabcabca','acbacbacbacb'),(5459,4,3,'bcabcabcabca','acbacbacbacb'),(5460,4,3,'bcabcabcabca','acbacbacbacb'),(5461,4,3,'bcabcabcabca','acbacbacbacb'),(5462,4,3,'bcabcabcabca','acbacbacbacb'),(5463,4,3,'bcabcabcabca','acbacbacbacb'),(5464,4,3,'bcabcabcabca','acbacbacbacb'),(5465,4,3,'bcabcabcabca','acbacbacbacb'),(5466,4,3,'bcabcabcabca','acbacbacbacb'),(5467,4,3,'bcabcabcabca','acbacbacbacb'),(5468,4,3,'bcabcabcabca','acbacbacbacb'),(5469,4,3,'bcabcabcabca','acbacbacbacb'),(5470,4,3,'bcabcabcabca','acbacbacbacb'),(5471,4,3,'bcabcabcabca','acbacbacbacb'),(5472,4,3,'bcabcabcabca','acbacbacbacb'),(5473,4,3,'bcabcabcabca','acbacbacbacb'),(5474,4,3,'bcabcabcabca','acbacbacbacb'),(5475,4,3,'bcabcabcabca','acbacbacbacb'),(5476,4,3,'bcabcabcabca','acbacbacbacb'),(5477,4,3,'bcabcabcabca','acbacbacbacb'),(5478,4,3,'bcabcabcabca','acbacbacbacb'),(5479,4,3,'bcabcabcabca','acbacbacbacb'),(5480,4,3,'bcabcabcabca','acbacbacbacb'),(5481,4,3,'bcabcabcabca','acbacbacbacb'),(5482,4,3,'bcabcabcabca','acbacbacbacb'),(5483,4,3,'bcabcabcabca','acbacbacbacb'),(5484,4,3,'bcabcabcabca','acbacbacbacb'),(5485,4,3,'bcabcabcabca','acbacbacbacb'),(5486,4,3,'bcabcabcabca','acbacbacbacb'),(5487,4,3,'bcabcabcabca','acbacbacbacb'),(5488,4,3,'bcabcabcabca','acbacbacbacb'),(5489,4,3,'bcabcabcabca','acbacbacbacb'),(5490,4,3,'bcabcabcabca','acbacbacbacb'),(5491,4,3,'bcabcabcabca','acbacbacbacb'),(5492,4,3,'bcabcabcabca','acbacbacbacb'),(5493,4,3,'bcabcabcabca','acbacbacbacb'),(5494,4,3,'bcabcabcabca','acbacbacbacb'),(5495,4,3,'bcabcabcabca','acbacbacbacb'),(5496,4,3,'bcabcabcabca','acbacbacbacb'),(5497,4,3,'bcabcabcabca','acbacbacbacb'),(5498,4,3,'bcabcabcabca','acbacbacbacb'),(5499,4,3,'bcabcabcabca','acbacbacbacb'),(5500,4,3,'bcabcabcabca','acbacbacbacb'),(5501,4,3,'bcabcabcabca','acbacbacbacb'),(5502,4,3,'bcabcabcabca','acbacbacbacb'),(5503,4,3,'bcabcabcabca','acbacbacbacb'),(5504,4,3,'bcabcabcabca','acbacbacbacb'),(5505,4,3,'bcabcabcabca','acbacbacbacb'),(5506,4,3,'bcabcabcabca','acbacbacbacb'),(5507,4,3,'bcabcabcabca','acbacbacbacb'),(5508,4,3,'bcabcabcabca','acbacbacbacb'),(5509,4,3,'bcabcabcabca','acbacbacbacb'),(5510,4,3,'bcabcabcabca','acbacbacbacb'),(5511,4,3,'bcabcabcabca','acbacbacbacb'),(5512,4,3,'bcabcabcabca','acbacbacbacb'),(5513,4,3,'bcabcabcabca','acbacbacbacb'),(5514,4,3,'bcabcabcabca','acbacbacbacb'),(5515,4,3,'bcabcabcabca','acbacbacbacb'),(5516,4,3,'bcabcabcabca','acbacbacbacb'),(5517,4,3,'bcabcabcabca','acbacbacbacb'),(5518,4,3,'bcabcabcabca','acbacbacbacb'),(5519,4,3,'bcabcabcabca','acbacbacbacb'),(5520,4,3,'bcabcabcabca','acbacbacbacb'),(5521,4,3,'bcabcabcabca','acbacbacbacb'),(5522,4,3,'bcabcabcabca','acbacbacbacb'),(5523,4,3,'bcabcabcabca','acbacbacbacb'),(5524,4,3,'bcabcabcabca','acbacbacbacb'),(5525,4,3,'bcabcabcabca','acbacbacbacb'),(5526,4,3,'bcabcabcabca','acbacbacbacb'),(5527,4,3,'bcabcabcabca','acbacbacbacb'),(5528,4,3,'bcabcabcabca','acbacbacbacb'),(5529,4,3,'bcabcabcabca','acbacbacbacb'),(5530,4,3,'bcabcabcabca','acbacbacbacb'),(5531,4,3,'bcabcabcabca','acbacbacbacb'),(5532,4,3,'bcabcabcabca','acbacbacbacb'),(5533,4,3,'bcabcabcabca','acbacbacbacb'),(5534,4,3,'bcabcabcabca','acbacbacbacb'),(5535,4,3,'bcabcabcabca','acbacbacbacb'),(5536,4,3,'bcabcabcabca','acbacbacbacb'),(5537,4,3,'bcabcabcabca','acbacbacbacb'),(5538,4,3,'bcabcabcabca','acbacbacbacb'),(5539,4,3,'bcabcabcabca','acbacbacbacb'),(5540,4,3,'bcabcabcabca','acbacbacbacb'),(5541,4,3,'bcabcabcabca','acbacbacbacb'),(5542,4,3,'bcabcabcabca','acbacbacbacb'),(5543,4,3,'bcabcabcabca','acbacbacbacb'),(5544,4,3,'bcabcabcabca','acbacbacbacb'),(5545,4,3,'bcabcabcabca','acbacbacbacb'),(5546,4,3,'bcabcabcabca','acbacbacbacb'),(5547,4,3,'bcabcabcabca','acbacbacbacb'),(5548,4,3,'bcabcabcabca','acbacbacbacb'),(5549,4,3,'bcabcabcabca','acbacbacbacb'),(5550,4,3,'bcabcabcabca','acbacbacbacb'),(5551,4,3,'bcabcabcabca','acbacbacbacb'),(5552,4,3,'bcabcabcabca','acbacbacbacb'),(5553,4,3,'bcabcabcabca','acbacbacbacb'),(5554,4,3,'bcabcabcabca','acbacbacbacb'),(5555,4,3,'bcabcabcabca','acbacbacbacb'),(5556,4,3,'bcabcabcabca','acbacbacbacb'),(5557,4,3,'bcabcabcabca','acbacbacbacb'),(5558,4,3,'bcabcabcabca','acbacbacbacb'),(5559,4,3,'bcabcabcabca','acbacbacbacb'),(5560,4,3,'bcabcabcabca','acbacbacbacb'),(5561,4,3,'bcabcabcabca','acbacbacbacb'),(5562,4,3,'bcabcabcabca','acbacbacbacb'),(5563,4,3,'bcabcabcabca','acbacbacbacb'),(5564,4,3,'bcabcabcabca','acbacbacbacb'),(5565,4,3,'bcabcabcabca','acbacbacbacb'),(5566,4,3,'bcabcabcabca','acbacbacbacb'),(5567,4,3,'bcabcabcabca','acbacbacbacb'),(5568,4,3,'bcabcabcabca','acbacbacbacb'),(5569,4,3,'bcabcabcabca','acbacbacbacb'),(5570,4,3,'bcabcabcabca','acbacbacbacb'),(5571,4,3,'bcabcabcabca','acbacbacbacb'),(5572,4,3,'bcabcabcabca','acbacbacbacb'),(5573,4,3,'bcabcabcabca','acbacbacbacb'),(5574,4,3,'bcabcabcabca','acbacbacbacb'),(5575,4,3,'bcabcabcabca','acbacbacbacb'),(5576,4,3,'bcabcabcabca','acbacbacbacb'),(5577,4,3,'bcabcabcabca','acbacbacbacb'),(5578,4,3,'bcabcabcabca','acbacbacbacb'),(5579,4,3,'bcabcabcabca','acbacbacbacb'),(5580,4,3,'bcabcabcabca','acbacbacbacb'),(5581,4,3,'bcabcabcabca','acbacbacbacb'),(5582,4,3,'bcabcabcabca','acbacbacbacb'),(5583,4,3,'bcabcabcabca','acbacbacbacb'),(5584,4,3,'bcabcabcabca','acbacbacbacb'),(5585,4,3,'bcabcabcabca','acbacbacbacb'),(5586,4,3,'bcabcabcabca','acbacbacbacb'),(5587,4,3,'bcabcabcabca','acbacbacbacb'),(5588,4,3,'bcabcabcabca','acbacbacbacb'),(5589,4,3,'bcabcabcabca','acbacbacbacb'),(5590,4,3,'bcabcabcabca','acbacbacbacb'),(5591,4,3,'bcabcabcabca','acbacbacbacb'),(5592,4,3,'bcabcabcabca','acbacbacbacb'),(5593,4,3,'bcabcabcabca','acbacbacbacb'),(5594,4,3,'bcabcabcabca','acbacbacbacb'),(5595,4,3,'bcabcabcabca','acbacbacbacb'),(5596,4,3,'bcabcabcabca','acbacbacbacb'),(5597,4,3,'bcabcabcabca','acbacbacbacb'),(5598,4,3,'bcabcabcabca','acbacbacbacb'),(5599,4,3,'bcabcabcabca','acbacbacbacb'),(5600,4,3,'bcabcabcabca','acbacbacbacb'),(5601,4,3,'bcabcabcabca','acbacbacbacb'),(5602,4,3,'bcabcabcabca','acbacbacbacb'),(5603,4,3,'bcabcabcabca','acbacbacbacb'),(5604,4,3,'bcabcabcabca','acbacbacbacb'),(5605,4,3,'bcabcabcabca','acbacbacbacb'),(5606,4,3,'bcabcabcabca','acbacbacbacb'),(5607,4,3,'bcabcabcabca','acbacbacbacb'),(5608,4,3,'bcabcabcabca','acbacbacbacb'),(5609,4,3,'bcabcabcabca','acbacbacbacb'),(5610,4,3,'bcabcabcabca','acbacbacbacb'),(5611,4,3,'bcabcabcabca','acbacbacbacb'),(5612,4,3,'bcabcabcabca','acbacbacbacb'),(5613,4,3,'bcabcabcabca','acbacbacbacb'),(5614,4,3,'bcabcabcabca','acbacbacbacb'),(5615,4,3,'bcabcabcabca','acbacbacbacb'),(5616,4,3,'bcabcabcabca','acbacbacbacb'),(5617,4,3,'bcabcabcabca','acbacbacbacb'),(5618,4,3,'bcabcabcabca','acbacbacbacb'),(5619,4,3,'bcabcabcabca','acbacbacbacb'),(5620,4,3,'bcabcabcabca','acbacbacbacb'),(5621,4,3,'bcabcabcabca','acbacbacbacb'),(5622,4,3,'bcabcabcabca','acbacbacbacb'),(5623,4,3,'bcabcabcabca','acbacbacbacb'),(5624,4,3,'bcabcabcabca','acbacbacbacb'),(5625,4,3,'bcabcabcabca','acbacbacbacb'),(5626,4,3,'bcabcabcabca','acbacbacbacb'),(5627,4,3,'bcabcabcabca','acbacbacbacb'),(5628,4,3,'bcabcabcabca','acbacbacbacb'),(5629,4,3,'bcabcabcabca','acbacbacbacb'),(5630,4,3,'bcabcabcabca','acbacbacbacb'),(5631,4,3,'bcabcabcabca','acbacbacbacb'),(5632,4,3,'bcabcabcabca','acbacbacbacb'),(5633,4,3,'bcabcabcabca','acbacbacbacb'),(5634,4,3,'bcabcabcabca','acbacbacbacb'),(5635,4,3,'bcabcabcabca','acbacbacbacb'),(5636,4,3,'bcabcabcabca','acbacbacbacb'),(5637,4,3,'bcabcabcabca','acbacbacbacb'),(5638,4,3,'bcabcabcabca','acbacbacbacb'),(5639,4,3,'bcabcabcabca','acbacbacbacb'),(5640,4,3,'bcabcabcabca','acbacbacbacb'),(5641,4,3,'bcabcabcabca','acbacbacbacb'),(5642,4,3,'bcabcabcabca','acbacbacbacb'),(5643,4,3,'bcabcabcabca','acbacbacbacb'),(5644,4,3,'bcabcabcabca','acbacbacbacb'),(5645,4,3,'bcabcabcabca','acbacbacbacb'),(5646,4,3,'bcabcabcabca','acbacbacbacb'),(5647,4,3,'bcabcabcabca','acbacbacbacb'),(5648,4,3,'bcabcabcabca','acbacbacbacb'),(5649,4,3,'bcabcabcabca','acbacbacbacb'),(5650,4,3,'bcabcabcabca','acbacbacbacb'),(5651,4,3,'bcabcabcabca','acbacbacbacb'),(5652,4,3,'bcabcabcabca','acbacbacbacb'),(5653,4,3,'bcabcabcabca','acbacbacbacb'),(5654,4,3,'bcabcabcabca','acbacbacbacb'),(5655,4,3,'bcabcabcabca','acbacbacbacb'),(5656,4,3,'bcabcabcabca','acbacbacbacb'),(5657,4,3,'bcabcabcabca','acbacbacbacb'),(5658,4,3,'bcabcabcabca','acbacbacbacb'),(5659,4,3,'bcabcabcabca','acbacbacbacb'),(5660,4,3,'bcabcabcabca','acbacbacbacb'),(5661,4,3,'bcabcabcabca','acbacbacbacb'),(5662,4,3,'bcabcabcabca','acbacbacbacb'),(5663,4,3,'bcabcabcabca','acbacbacbacb'),(5664,4,3,'bcabcabcabca','acbacbacbacb'),(5665,4,3,'bcabcabcabca','acbacbacbacb'),(5666,4,3,'bcabcabcabca','acbacbacbacb'),(5667,4,3,'bcabcabcabca','acbacbacbacb'),(5668,4,3,'bcabcabcabca','acbacbacbacb'),(5669,4,3,'bcabcabcabca','acbacbacbacb'),(5670,4,3,'bcabcabcabca','acbacbacbacb'),(5671,4,3,'bcabcabcabca','acbacbacbacb'),(5672,4,3,'bcabcabcabca','acbacbacbacb'),(5673,4,3,'bcabcabcabca','acbacbacbacb'),(5674,4,3,'bcabcabcabca','acbacbacbacb'),(5675,4,3,'bcabcabcabca','acbacbacbacb'),(5676,4,3,'bcabcabcabca','acbacbacbacb'),(5677,4,3,'bcabcabcabca','acbacbacbacb'),(5678,4,3,'bcabcabcabca','acbacbacbacb'),(5679,4,3,'bcabcabcabca','acbacbacbacb'),(5680,4,3,'bcabcabcabca','acbacbacbacb'),(5681,4,3,'bcabcabcabca','acbacbacbacb'),(5682,4,3,'bcabcabcabca','acbacbacbacb'),(5683,4,3,'bcabcabcabca','acbacbacbacb'),(5684,4,3,'bcabcabcabca','acbacbacbacb'),(5685,4,3,'bcabcabcabca','acbacbacbacb'),(5686,4,3,'bcabcabcabca','acbacbacbacb'),(5687,4,3,'bcabcabcabca','acbacbacbacb'),(5688,4,3,'bcabcabcabca','acbacbacbacb'),(5689,4,3,'bcabcabcabca','acbacbacbacb'),(5690,4,3,'bcabcabcabca','acbacbacbacb'),(5691,4,3,'bcabcabcabca','acbacbacbacb'),(5692,4,3,'bcabcabcabca','acbacbacbacb'),(5693,4,3,'bcabcabcabca','acbacbacbacb'),(5694,4,3,'bcabcabcabca','acbacbacbacb'),(5695,4,3,'bcabcabcabca','acbacbacbacb'),(5696,4,3,'bcabcabcabca','acbacbacbacb'),(5697,4,3,'bcabcabcabca','acbacbacbacb'),(5698,4,3,'bcabcabcabca','acbacbacbacb'),(5699,4,3,'bcabcabcabca','acbacbacbacb'),(5700,4,3,'bcabcabcabca','acbacbacbacb'),(5701,4,3,'bcabcabcabca','acbacbacbacb'),(5702,4,3,'bcabcabcabca','acbacbacbacb'),(5703,4,3,'bcabcabcabca','acbacbacbacb'),(5704,4,3,'bcabcabcabca','acbacbacbacb'),(5705,4,3,'bcabcabcabca','acbacbacbacb'),(5706,4,3,'bcabcabcabca','acbacbacbacb'),(5707,4,3,'bcabcabcabca','acbacbacbacb'),(5708,4,3,'bcabcabcabca','acbacbacbacb'),(5709,4,3,'bcabcabcabca','acbacbacbacb'),(5710,4,3,'bcabcabcabca','acbacbacbacb'),(5711,4,3,'bcabcabcabca','acbacbacbacb'),(5712,4,3,'bcabcabcabca','acbacbacbacb'),(5713,4,3,'bcabcabcabca','acbacbacbacb'),(5714,4,3,'bcabcabcabca','acbacbacbacb'),(5715,4,3,'bcabcabcabca','acbacbacbacb'),(5716,4,3,'bcabcabcabca','acbacbacbacb'),(5717,4,3,'bcabcabcabca','acbacbacbacb'),(5718,4,3,'bcabcabcabca','acbacbacbacb'),(5719,4,3,'bcabcabcabca','acbacbacbacb'),(5720,4,3,'bcabcabcabca','acbacbacbacb'),(5721,4,3,'bcabcabcabca','acbacbacbacb'),(5722,4,3,'bcabcabcabca','acbacbacbacb'),(5723,4,3,'bcabcabcabca','acbacbacbacb'),(5724,4,3,'bcabcabcabca','acbacbacbacb'),(5725,4,3,'bcabcabcabca','acbacbacbacb'),(5726,4,3,'bcabcabcabca','acbacbacbacb'),(5727,4,3,'bcabcabcabca','acbacbacbacb'),(5728,4,3,'bcabcabcabca','acbacbacbacb'),(5729,4,3,'bcabcabcabca','acbacbacbacb'),(5730,4,3,'bcabcabcabca','acbacbacbacb'),(5731,4,3,'bcabcabcabca','acbacbacbacb'),(5732,4,3,'bcabcabcabca','acbacbacbacb'),(5733,4,3,'bcabcabcabca','acbacbacbacb'),(5734,4,3,'bcabcabcabca','acbacbacbacb'),(5735,4,3,'bcabcabcabca','acbacbacbacb'),(5736,4,3,'bcabcabcabca','acbacbacbacb'),(5737,4,3,'bcabcabcabca','acbacbacbacb'),(5738,4,3,'bcabcabcabca','acbacbacbacb'),(5739,4,3,'bcabcabcabca','acbacbacbacb'),(5740,4,3,'bcabcabcabca','acbacbacbacb'),(5741,4,3,'bcabcabcabca','acbacbacbacb'),(5742,4,3,'bcabcabcabca','acbacbacbacb'),(5743,4,3,'bcabcabcabca','acbacbacbacb'),(5744,4,3,'bcabcabcabca','acbacbacbacb'),(5745,4,3,'bcabcabcabca','acbacbacbacb'),(5746,4,3,'bcabcabcabca','acbacbacbacb'),(5747,4,3,'bcabcabcabca','acbacbacbacb'),(5748,4,3,'bcabcabcabca','acbacbacbacb'),(5749,4,3,'bcabcabcabca','acbacbacbacb'),(5750,4,3,'bcabcabcabca','acbacbacbacb'),(5751,4,3,'bcabcabcabca','acbacbacbacb'),(5752,4,3,'bcabcabcabca','acbacbacbacb'),(5753,4,3,'bcabcabcabca','acbacbacbacb'),(5754,4,3,'bcabcabcabca','acbacbacbacb'),(5755,4,3,'bcabcabcabca','acbacbacbacb'),(5756,4,3,'bcabcabcabca','acbacbacbacb'),(5757,4,3,'bcabcabcabca','acbacbacbacb'),(5758,4,3,'bcabcabcabca','acbacbacbacb'),(5759,4,3,'bcabcabcabca','acbacbacbacb'),(5760,4,3,'bcabcabcabca','acbacbacbacb'),(5761,4,3,'bcabcabcabca','acbacbacbacb'),(5762,4,3,'bcabcabcabca','acbacbacbacb'),(5763,4,3,'bcabcabcabca','acbacbacbacb'),(5764,4,3,'bcabcabcabca','acbacbacbacb'),(5765,4,3,'bcabcabcabca','acbacbacbacb'),(5766,4,3,'bcabcabcabca','acbacbacbacb'),(5767,4,3,'bcabcabcabca','acbacbacbacb'),(5768,4,3,'bcabcabcabca','acbacbacbacb'),(5769,4,3,'bcabcabcabca','acbacbacbacb'),(5770,4,3,'bcabcabcabca','acbacbacbacb'),(5771,4,3,'bcabcabcabca','acbacbacbacb'),(5772,4,3,'bcabcabcabca','acbacbacbacb'),(5773,4,3,'bcabcabcabca','acbacbacbacb'),(5774,4,3,'bcabcabcabca','acbacbacbacb'),(5775,4,3,'bcabcabcabca','acbacbacbacb'),(5776,4,3,'bcabcabcabca','acbacbacbacb'),(5777,4,3,'bcabcabcabca','acbacbacbacb'),(5778,4,3,'bcabcabcabca','acbacbacbacb'),(5779,4,3,'bcabcabcabca','acbacbacbacb'),(5780,4,3,'bcabcabcabca','acbacbacbacb'),(5781,4,3,'bcabcabcabca','acbacbacbacb'),(5782,4,3,'bcabcabcabca','acbacbacbacb'),(5783,4,3,'bcabcabcabca','acbacbacbacb'),(5784,4,3,'bcabcabcabca','acbacbacbacb'),(5785,4,3,'bcabcabcabca','acbacbacbacb'),(5786,4,3,'bcabcabcabca','acbacbacbacb'),(5787,4,3,'bcabcabcabca','acbacbacbacb'),(5788,4,3,'bcabcabcabca','acbacbacbacb'),(5789,4,3,'bcabcabcabca','acbacbacbacb'),(5790,4,3,'bcabcabcabca','acbacbacbacb'),(5791,4,3,'bcabcabcabca','acbacbacbacb'),(5792,4,3,'bcabcabcabca','acbacbacbacb'),(5793,4,3,'bcabcabcabca','acbacbacbacb'),(5794,4,3,'bcabcabcabca','acbacbacbacb'),(5795,4,3,'bcabcabcabca','acbacbacbacb'),(5796,4,3,'bcabcabcabca','acbacbacbacb'),(5797,4,3,'bcabcabcabca','acbacbacbacb'),(5798,4,3,'bcabcabcabca','acbacbacbacb'),(5799,4,3,'bcabcabcabca','acbacbacbacb'),(5800,4,3,'bcabcabcabca','acbacbacbacb'),(5801,4,3,'bcabcabcabca','acbacbacbacb'),(5802,4,3,'bcabcabcabca','acbacbacbacb'),(5803,4,3,'bcabcabcabca','acbacbacbacb'),(5804,4,3,'bcabcabcabca','acbacbacbacb'),(5805,4,3,'bcabcabcabca','acbacbacbacb'),(5806,4,3,'bcabcabcabca','acbacbacbacb'),(5807,4,3,'bcabcabcabca','acbacbacbacb'),(5808,4,3,'bcabcabcabca','acbacbacbacb'),(5809,4,3,'bcabcabcabca','acbacbacbacb'),(5810,4,3,'bcabcabcabca','acbacbacbacb'),(5811,4,3,'bcabcabcabca','acbacbacbacb'),(5812,4,3,'bcabcabcabca','acbacbacbacb'),(5813,4,3,'bcabcabcabca','acbacbacbacb'),(5814,4,3,'bcabcabcabca','acbacbacbacb'),(5815,4,3,'bcabcabcabca','acbacbacbacb'),(5816,4,3,'bcabcabcabca','acbacbacbacb'),(5817,4,3,'bcabcabcabca','acbacbacbacb'),(5818,4,3,'bcabcabcabca','acbacbacbacb'),(5819,4,3,'bcabcabcabca','acbacbacbacb'),(5820,4,3,'bcabcabcabca','acbacbacbacb'),(5821,4,3,'bcabcabcabca','acbacbacbacb'),(5822,4,3,'bcabcabcabca','acbacbacbacb'),(5823,4,3,'bcabcabcabca','acbacbacbacb'),(5824,4,3,'bcabcabcabca','acbacbacbacb'),(5825,4,3,'bcabcabcabca','acbacbacbacb'),(5826,4,3,'bcabcabcabca','acbacbacbacb'),(5827,4,3,'bcabcabcabca','acbacbacbacb'),(5828,4,3,'bcabcabcabca','acbacbacbacb'),(5829,4,3,'bcabcabcabca','acbacbacbacb'),(5830,4,3,'bcabcabcabca','acbacbacbacb'),(5831,4,3,'bcabcabcabca','acbacbacbacb'),(5832,4,3,'bcabcabcabca','acbacbacbacb'),(5833,4,3,'bcabcabcabca','acbacbacbacb'),(5834,4,3,'bcabcabcabca','acbacbacbacb'),(5835,4,3,'bcabcabcabca','acbacbacbacb'),(5836,4,3,'bcabcabcabca','acbacbacbacb'),(5837,4,3,'bcabcabcabca','acbacbacbacb'),(5838,4,3,'bcabcabcabca','acbacbacbacb'),(5839,4,3,'bcabcabcabca','acbacbacbacb'),(5840,4,3,'bcabcabcabca','acbacbacbacb'),(5841,4,3,'bcabcabcabca','acbacbacbacb'),(5842,4,3,'bcabcabcabca','acbacbacbacb'),(5843,4,3,'bcabcabcabca','acbacbacbacb'),(5844,4,3,'bcabcabcabca','acbacbacbacb'),(5845,4,3,'bcabcabcabca','acbacbacbacb'),(5846,4,3,'bcabcabcabca','acbacbacbacb'),(5847,4,3,'bcabcabcabca','acbacbacbacb'),(5848,4,3,'bcabcabcabca','acbacbacbacb'),(5849,4,3,'bcabcabcabca','acbacbacbacb'),(5850,4,3,'bcabcabcabca','acbacbacbacb'),(5851,4,3,'bcabcabcabca','acbacbacbacb'),(5852,4,3,'bcabcabcabca','acbacbacbacb'),(5853,4,3,'bcabcabcabca','acbacbacbacb'),(5854,4,3,'bcabcabcabca','acbacbacbacb'),(5855,4,3,'bcabcabcabca','acbacbacbacb'),(5856,4,3,'bcabcabcabca','acbacbacbacb'),(5857,4,3,'bcabcabcabca','acbacbacbacb'),(5858,4,3,'bcabcabcabca','acbacbacbacb'),(5859,4,3,'bcabcabcabca','acbacbacbacb'),(5860,4,3,'bcabcabcabca','acbacbacbacb'),(5861,4,3,'bcabcabcabca','acbacbacbacb'),(5862,4,3,'bcabcabcabca','acbacbacbacb'),(5863,4,3,'bcabcabcabca','acbacbacbacb'),(5864,4,3,'bcabcabcabca','acbacbacbacb'),(5865,4,3,'bcabcabcabca','acbacbacbacb'),(5866,4,3,'bcabcabcabca','acbacbacbacb'),(5867,4,3,'bcabcabcabca','acbacbacbacb'),(5868,4,3,'bcabcabcabca','acbacbacbacb'),(5869,4,3,'bcabcabcabca','acbacbacbacb'),(5870,4,3,'bcabcabcabca','acbacbacbacb'),(5871,4,3,'bcabcabcabca','acbacbacbacb'),(5872,4,3,'bcabcabcabca','acbacbacbacb'),(5873,4,3,'bcabcabcabca','acbacbacbacb'),(5874,4,3,'bcabcabcabca','acbacbacbacb'),(5875,4,3,'bcabcabcabca','acbacbacbacb'),(5876,4,3,'bcabcabcabca','acbacbacbacb'),(5877,4,3,'bcabcabcabca','acbacbacbacb'),(5878,4,3,'bcabcabcabca','acbacbacbacb'),(5879,4,3,'bcabcabcabca','acbacbacbacb'),(5880,4,3,'bcabcabcabca','acbacbacbacb'),(5881,4,3,'bcabcabcabca','acbacbacbacb'),(5882,4,3,'bcabcabcabca','acbacbacbacb'),(5883,4,3,'bcabcabcabca','acbacbacbacb'),(5884,4,3,'bcabcabcabca','acbacbacbacb'),(5885,4,3,'bcabcabcabca','acbacbacbacb'),(5886,4,3,'bcabcabcabca','acbacbacbacb'),(5887,4,3,'bcabcabcabca','acbacbacbacb'),(5888,4,3,'bcabcabcabca','acbacbacbacb'),(5889,4,3,'bcabcabcabca','acbacbacbacb'),(5890,4,3,'bcabcabcabca','acbacbacbacb'),(5891,4,3,'bcabcabcabca','acbacbacbacb'),(5892,4,3,'bcabcabcabca','acbacbacbacb'),(5893,4,3,'bcabcabcabca','acbacbacbacb'),(5894,4,3,'bcabcabcabca','acbacbacbacb'),(5895,4,3,'bcabcabcabca','acbacbacbacb'),(5896,4,3,'bcabcabcabca','acbacbacbacb'),(5897,4,3,'bcabcabcabca','acbacbacbacb'),(5898,4,3,'bcabcabcabca','acbacbacbacb'),(5899,4,3,'bcabcabcabca','acbacbacbacb'),(5900,4,3,'bcabcabcabca','acbacbacbacb'),(5901,4,3,'bcabcabcabca','acbacbacbacb'),(5902,4,3,'bcabcabcabca','acbacbacbacb'),(5903,4,3,'bcabcabcabca','acbacbacbacb'),(5904,4,3,'bcabcabcabca','acbacbacbacb'),(5905,4,3,'bcabcabcabca','acbacbacbacb'),(5906,4,3,'bcabcabcabca','acbacbacbacb'),(5907,4,3,'bcabcabcabca','acbacbacbacb'),(5908,4,3,'bcabcabcabca','acbacbacbacb'),(5909,4,3,'bcabcabcabca','acbacbacbacb'),(5910,4,3,'bcabcabcabca','acbacbacbacb'),(5911,4,3,'bcabcabcabca','acbacbacbacb'),(5912,4,3,'bcabcabcabca','acbacbacbacb'),(5913,4,3,'bcabcabcabca','acbacbacbacb'),(5914,4,3,'bcabcabcabca','acbacbacbacb'),(5915,4,3,'bcabcabcabca','acbacbacbacb'),(5916,4,3,'bcabcabcabca','acbacbacbacb'),(5917,4,3,'bcabcabcabca','acbacbacbacb'),(5918,4,3,'bcabcabcabca','acbacbacbacb'),(5919,4,3,'bcabcabcabca','acbacbacbacb'),(5920,4,3,'bcabcabcabca','acbacbacbacb'),(5921,4,3,'bcabcabcabca','acbacbacbacb'),(5922,4,3,'bcabcabcabca','acbacbacbacb'),(5923,4,3,'bcabcabcabca','acbacbacbacb'),(5924,4,3,'bcabcabcabca','acbacbacbacb'),(5925,4,3,'bcabcabcabca','acbacbacbacb'),(5926,4,3,'bcabcabcabca','acbacbacbacb'),(5927,4,3,'bcabcabcabca','acbacbacbacb'),(5928,4,3,'bcabcabcabca','acbacbacbacb'),(5929,4,3,'bcabcabcabca','acbacbacbacb'),(5930,4,3,'bcabcabcabca','acbacbacbacb'),(5931,4,3,'bcabcabcabca','acbacbacbacb'),(5932,4,3,'bcabcabcabca','acbacbacbacb'),(5933,4,3,'bcabcabcabca','acbacbacbacb'),(5934,4,3,'bcabcabcabca','acbacbacbacb'),(5935,4,3,'bcabcabcabca','acbacbacbacb'),(5936,4,3,'bcabcabcabca','acbacbacbacb'),(5937,4,3,'bcabcabcabca','acbacbacbacb'),(5938,4,3,'bcabcabcabca','acbacbacbacb'),(5939,4,3,'bcabcabcabca','acbacbacbacb'),(5940,4,3,'bcabcabcabca','acbacbacbacb'),(5941,4,3,'bcabcabcabca','acbacbacbacb'),(5942,4,3,'bcabcabcabca','acbacbacbacb'),(5943,4,3,'bcabcabcabca','acbacbacbacb'),(5944,4,3,'bcabcabcabca','acbacbacbacb'),(5945,4,3,'bcabcabcabca','acbacbacbacb'),(5946,4,3,'bcabcabcabca','acbacbacbacb'),(5947,4,3,'bcabcabcabca','acbacbacbacb'),(5948,4,3,'bcabcabcabca','acbacbacbacb'),(5949,4,3,'bcabcabcabca','acbacbacbacb'),(5950,4,3,'bcabcabcabca','acbacbacbacb'),(5951,4,3,'bcabcabcabca','acbacbacbacb'),(5952,4,3,'bcabcabcabca','acbacbacbacb'),(5953,4,3,'bcabcabcabca','acbacbacbacb'),(5954,4,3,'bcabcabcabca','acbacbacbacb'),(5955,4,3,'bcabcabcabca','acbacbacbacb'),(5956,4,3,'bcabcabcabca','acbacbacbacb'),(5957,4,3,'bcabcabcabca','acbacbacbacb'),(5958,4,3,'bcabcabcabca','acbacbacbacb'),(5959,4,3,'bcabcabcabca','acbacbacbacb'),(5960,4,3,'bcabcabcabca','acbacbacbacb'),(5961,4,3,'bcabcabcabca','acbacbacbacb'),(5962,4,3,'bcabcabcabca','acbacbacbacb'),(5963,4,3,'bcabcabcabca','acbacbacbacb'),(5964,4,3,'bcabcabcabca','acbacbacbacb'),(5965,4,3,'bcabcabcabca','acbacbacbacb'),(5966,4,3,'bcabcabcabca','acbacbacbacb'),(5967,4,3,'bcabcabcabca','acbacbacbacb'),(5968,4,3,'bcabcabcabca','acbacbacbacb'),(5969,4,3,'bcabcabcabca','acbacbacbacb'),(5970,4,3,'bcabcabcabca','acbacbacbacb'),(5971,4,3,'bcabcabcabca','acbacbacbacb'),(5972,4,3,'bcabcabcabca','acbacbacbacb'),(5973,4,3,'bcabcabcabca','acbacbacbacb'),(5974,4,3,'bcabcabcabca','acbacbacbacb'),(5975,4,3,'bcabcabcabca','acbacbacbacb'),(5976,4,3,'bcabcabcabca','acbacbacbacb'),(5977,4,3,'bcabcabcabca','acbacbacbacb'),(5978,4,3,'bcabcabcabca','acbacbacbacb'),(5979,4,3,'bcabcabcabca','acbacbacbacb'),(5980,4,3,'bcabcabcabca','acbacbacbacb'),(5981,4,3,'bcabcabcabca','acbacbacbacb'),(5982,4,3,'bcabcabcabca','acbacbacbacb'),(5983,4,3,'bcabcabcabca','acbacbacbacb'),(5984,4,3,'bcabcabcabca','acbacbacbacb'),(5985,4,3,'bcabcabcabca','acbacbacbacb'),(5986,4,3,'bcabcabcabca','acbacbacbacb'),(5987,4,3,'bcabcabcabca','acbacbacbacb'),(5988,4,3,'bcabcabcabca','acbacbacbacb'),(5989,4,3,'bcabcabcabca','acbacbacbacb'),(5990,4,3,'bcabcabcabca','acbacbacbacb'),(5991,4,3,'bcabcabcabca','acbacbacbacb'),(5992,4,3,'bcabcabcabca','acbacbacbacb'),(5993,4,3,'bcabcabcabca','acbacbacbacb'),(5994,4,3,'bcabcabcabca','acbacbacbacb'),(5995,4,3,'bcabcabcabca','acbacbacbacb'),(5996,4,3,'bcabcabcabca','acbacbacbacb'),(5997,4,3,'bcabcabcabca','acbacbacbacb'),(5998,4,3,'bcabcabcabca','acbacbacbacb'),(5999,4,3,'bcabcabcabca','acbacbacbacb'),(6000,4,3,'bcabcabcabca','acbacbacbacb'),(6001,4,3,'bcabcabcabca','acbacbacbacb'),(6002,4,3,'bcabcabcabca','acbacbacbacb'),(6003,4,3,'bcabcabcabca','acbacbacbacb'),(6004,4,3,'bcabcabcabca','acbacbacbacb'),(6005,4,3,'bcabcabcabca','acbacbacbacb'),(6006,4,3,'bcabcabcabca','acbacbacbacb'),(6007,4,3,'bcabcabcabca','acbacbacbacb'),(6008,4,3,'bcabcabcabca','acbacbacbacb'),(6009,4,3,'bcabcabcabca','acbacbacbacb'),(6010,4,3,'bcabcabcabca','acbacbacbacb'),(6011,4,3,'bcabcabcabca','acbacbacbacb'),(6012,4,3,'bcabcabcabca','acbacbacbacb'),(6013,4,3,'bcabcabcabca','acbacbacbacb'),(6014,4,3,'bcabcabcabca','acbacbacbacb'),(6015,4,3,'bcabcabcabca','acbacbacbacb'),(6016,4,3,'bcabcabcabca','acbacbacbacb'),(6017,4,3,'bcabcabcabca','acbacbacbacb'),(6018,4,3,'bcabcabcabca','acbacbacbacb'),(6019,4,3,'bcabcabcabca','acbacbacbacb'),(6020,4,3,'bcabcabcabca','acbacbacbacb'),(6021,4,3,'bcabcabcabca','acbacbacbacb'),(6022,4,3,'bcabcabcabca','acbacbacbacb'),(6023,4,3,'bcabcabcabca','acbacbacbacb'),(6024,4,3,'bcabcabcabca','acbacbacbacb'),(6025,4,3,'bcabcabcabca','acbacbacbacb'),(6026,4,3,'bcabcabcabca','acbacbacbacb'),(6027,4,3,'bcabcabcabca','acbacbacbacb'),(6028,4,3,'bcabcabcabca','acbacbacbacb'),(6029,4,3,'bcabcabcabca','acbacbacbacb'),(6030,4,3,'bcabcabcabca','acbacbacbacb'),(6031,4,3,'bcabcabcabca','acbacbacbacb'),(6032,4,3,'bcabcabcabca','acbacbacbacb'),(6033,4,3,'bcabcabcabca','acbacbacbacb'),(6034,4,3,'bcabcabcabca','acbacbacbacb'),(6035,4,3,'bcabcabcabca','acbacbacbacb'),(6036,4,3,'bcabcabcabca','acbacbacbacb'),(6037,4,3,'bcabcabcabca','acbacbacbacb'),(6038,4,3,'bcabcabcabca','acbacbacbacb'),(6039,4,3,'bcabcabcabca','acbacbacbacb'),(6040,4,3,'bcabcabcabca','acbacbacbacb'),(6041,4,3,'bcabcabcabca','acbacbacbacb'),(6042,4,3,'bcabcabcabca','acbacbacbacb'),(6043,4,3,'bcabcabcabca','acbacbacbacb'),(6044,4,3,'bcabcabcabca','acbacbacbacb'),(6045,4,3,'bcabcabcabca','acbacbacbacb'),(6046,4,3,'bcabcabcabca','acbacbacbacb'),(6047,4,3,'bcabcabcabca','acbacbacbacb'),(6048,4,3,'bcabcabcabca','acbacbacbacb'),(6049,4,3,'bcabcabcabca','acbacbacbacb'),(6050,4,3,'bcabcabcabca','acbacbacbacb'),(6051,4,3,'bcabcabcabca','acbacbacbacb'),(6052,4,3,'bcabcabcabca','acbacbacbacb'),(6053,4,3,'bcabcabcabca','acbacbacbacb'),(6054,4,3,'bcabcabcabca','acbacbacbacb'),(6055,4,3,'bcabcabcabca','acbacbacbacb'),(6056,4,3,'bcabcabcabca','acbacbacbacb'),(6057,4,3,'bcabcabcabca','acbacbacbacb'),(6058,4,3,'bcabcabcabca','acbacbacbacb'),(6059,4,3,'bcabcabcabca','acbacbacbacb'),(6060,4,3,'bcabcabcabca','acbacbacbacb'),(6061,4,3,'bcabcabcabca','acbacbacbacb'),(6062,4,3,'bcabcabcabca','acbacbacbacb'),(6063,4,3,'bcabcabcabca','acbacbacbacb'),(6064,4,3,'bcabcabcabca','acbacbacbacb'),(6065,4,3,'bcabcabcabca','acbacbacbacb'),(6066,4,3,'bcabcabcabca','acbacbacbacb'),(6067,4,3,'bcabcabcabca','acbacbacbacb'),(6068,4,3,'bcabcabcabca','acbacbacbacb'),(6069,4,3,'bcabcabcabca','acbacbacbacb'),(6070,4,3,'bcabcabcabca','acbacbacbacb'),(6071,4,3,'bcabcabcabca','acbacbacbacb'),(6072,4,3,'bcabcabcabca','acbacbacbacb'),(6073,4,3,'bcabcabcabca','acbacbacbacb'),(6074,4,3,'bcabcabcabca','acbacbacbacb'),(6075,4,3,'bcabcabcabca','acbacbacbacb'),(6076,4,3,'bcabcabcabca','acbacbacbacb'),(6077,4,3,'bcabcabcabca','acbacbacbacb'),(6078,4,3,'bcabcabcabca','acbacbacbacb'),(6079,4,3,'bcabcabcabca','acbacbacbacb'),(6080,4,3,'bcabcabcabca','acbacbacbacb'),(6081,4,3,'bcabcabcabca','acbacbacbacb'),(6082,4,3,'bcabcabcabca','acbacbacbacb'),(6083,4,3,'bcabcabcabca','acbacbacbacb'),(6084,4,3,'bcabcabcabca','acbacbacbacb'),(6085,4,3,'bcabcabcabca','acbacbacbacb'),(6086,4,3,'bcabcabcabca','acbacbacbacb'),(6087,4,3,'bcabcabcabca','acbacbacbacb'),(6088,4,3,'bcabcabcabca','acbacbacbacb'),(6089,4,3,'bcabcabcabca','acbacbacbacb'),(6090,4,3,'bcabcabcabca','acbacbacbacb'),(6091,4,3,'bcabcabcabca','acbacbacbacb'),(6092,4,3,'bcabcabcabca','acbacbacbacb'),(6093,4,3,'bcabcabcabca','acbacbacbacb'),(6094,4,3,'bcabcabcabca','acbacbacbacb'),(6095,4,3,'bcabcabcabca','acbacbacbacb'),(6096,4,3,'bcabcabcabca','acbacbacbacb'),(6097,4,3,'bcabcabcabca','acbacbacbacb'),(6098,4,3,'bcabcabcabca','acbacbacbacb'),(6099,4,3,'bcabcabcabca','acbacbacbacb'),(6100,4,3,'bcabcabcabca','acbacbacbacb'),(6101,4,3,'bcabcabcabca','acbacbacbacb'),(6102,4,3,'bcabcabcabca','acbacbacbacb'),(6103,4,3,'bcabcabcabca','acbacbacbacb'),(6104,4,3,'bcabcabcabca','acbacbacbacb'),(6105,4,3,'bcabcabcabca','acbacbacbacb'),(6106,4,3,'bcabcabcabca','acbacbacbacb'),(6107,4,3,'bcabcabcabca','acbacbacbacb'),(6108,4,3,'bcabcabcabca','acbacbacbacb'),(6109,4,3,'bcabcabcabca','acbacbacbacb'),(6110,4,3,'bcabcabcabca','acbacbacbacb'),(6111,4,3,'bcabcabcabca','acbacbacbacb'),(6112,4,3,'bcabcabcabca','acbacbacbacb'),(6113,4,3,'bcabcabcabca','acbacbacbacb'),(6114,4,3,'bcabcabcabca','acbacbacbacb'),(6115,4,3,'bcabcabcabca','acbacbacbacb'),(6116,4,3,'bcabcabcabca','acbacbacbacb'),(6117,4,3,'bcabcabcabca','acbacbacbacb'),(6118,4,3,'bcabcabcabca','acbacbacbacb'),(6119,4,3,'bcabcabcabca','acbacbacbacb'),(6120,4,3,'bcabcabcabca','acbacbacbacb'),(6121,4,3,'bcabcabcabca','acbacbacbacb'),(6122,4,3,'bcabcabcabca','acbacbacbacb'),(6123,4,3,'bcabcabcabca','acbacbacbacb'),(6124,4,3,'bcabcabcabca','acbacbacbacb'),(6125,4,3,'bcabcabcabca','acbacbacbacb'),(6126,4,3,'bcabcabcabca','acbacbacbacb'),(6127,4,3,'bcabcabcabca','acbacbacbacb'),(6128,4,3,'bcabcabcabca','acbacbacbacb'),(6129,4,3,'bcabcabcabca','acbacbacbacb'),(6130,4,3,'bcabcabcabca','acbacbacbacb'),(6131,4,3,'bcabcabcabca','acbacbacbacb'),(6132,4,3,'bcabcabcabca','acbacbacbacb'),(6133,4,3,'bcabcabcabca','acbacbacbacb'),(6134,4,3,'bcabcabcabca','acbacbacbacb'),(6135,4,5,'bcabcabcabca','acbacbacbacb'),(6136,4,5,'bcabcabcabca','acbacbacbacb'),(6137,4,5,'bcabcabcabca','acbacbacbacb'),(6138,4,5,'bcabcabcabca','acbacbacbacb'),(6139,4,5,'bcabcabcabca','acbacbacbacb'),(6140,4,5,'bcabcabcabca','acbacbacbacb'),(6141,4,5,'bcabcabcabca','acbacbacbacb'),(6142,4,5,'bcabcabcabca','acbacbacbacb'),(6143,4,5,'bcabcabcabca','acbacbacbacb'),(6144,4,5,'bcabcabcabca','acbacbacbacb'),(6145,4,5,'bcabcabcabca','acbacbacbacb'),(6146,4,5,'bcabcabcabca','acbacbacbacb'),(6147,4,5,'bcabcabcabca','acbacbacbacb'),(6148,4,5,'bcabcabcabca','acbacbacbacb'),(6149,4,5,'bcabcabcabca','acbacbacbacb'),(6150,4,5,'bcabcabcabca','acbacbacbacb'),(6151,4,5,'bcabcabcabca','acbacbacbacb'),(6152,4,5,'bcabcabcabca','acbacbacbacb'),(6153,4,5,'bcabcabcabca','acbacbacbacb'),(6154,4,5,'bcabcabcabca','acbacbacbacb'),(6155,4,5,'bcabcabcabca','acbacbacbacb'),(6156,4,5,'bcabcabcabca','acbacbacbacb'),(6157,4,5,'bcabcabcabca','acbacbacbacb'),(6158,4,5,'bcabcabcabca','acbacbacbacb'),(6159,4,5,'bcabcabcabca','acbacbacbacb'),(6160,4,5,'bcabcabcabca','acbacbacbacb'),(6161,4,5,'bcabcabcabca','acbacbacbacb'),(6162,4,5,'bcabcabcabca','acbacbacbacb'),(6163,4,5,'bcabcabcabca','acbacbacbacb'),(6164,4,5,'bcabcabcabca','acbacbacbacb'),(6165,4,5,'bcabcabcabca','acbacbacbacb'),(6166,4,5,'bcabcabcabca','acbacbacbacb'),(6167,4,5,'bcabcabcabca','acbacbacbacb'),(6168,4,5,'bcabcabcabca','acbacbacbacb'),(6169,4,5,'bcabcabcabca','acbacbacbacb'),(6170,4,5,'bcabcabcabca','acbacbacbacb'),(6171,4,5,'bcabcabcabca','acbacbacbacb'),(6172,4,5,'bcabcabcabca','acbacbacbacb'),(6173,4,5,'bcabcabcabca','acbacbacbacb'),(6174,4,5,'bcabcabcabca','acbacbacbacb'),(6175,4,5,'bcabcabcabca','acbacbacbacb'),(6176,4,5,'bcabcabcabca','acbacbacbacb'),(6177,4,5,'bcabcabcabca','acbacbacbacb'),(6178,4,5,'bcabcabcabca','acbacbacbacb'),(6179,4,5,'bcabcabcabca','acbacbacbacb'),(6180,4,5,'bcabcabcabca','acbacbacbacb'),(6181,4,5,'bcabcabcabca','acbacbacbacb'),(6182,4,5,'bcabcabcabca','acbacbacbacb'),(6183,4,5,'bcabcabcabca','acbacbacbacb'),(6184,4,5,'bcabcabcabca','acbacbacbacb'),(6185,4,5,'bcabcabcabca','acbacbacbacb'),(6186,4,5,'bcabcabcabca','acbacbacbacb'),(6187,4,5,'bcabcabcabca','acbacbacbacb'),(6188,4,5,'bcabcabcabca','acbacbacbacb'),(6189,4,5,'bcabcabcabca','acbacbacbacb'),(6190,4,5,'bcabcabcabca','acbacbacbacb'),(6191,4,5,'bcabcabcabca','acbacbacbacb'),(6192,4,5,'bcabcabcabca','acbacbacbacb'),(6193,4,5,'bcabcabcabca','acbacbacbacb'),(6194,4,5,'bcabcabcabca','acbacbacbacb'),(6195,4,5,'bcabcabcabca','acbacbacbacb'),(6196,4,5,'bcabcabcabca','acbacbacbacb'),(6197,4,5,'bcabcabcabca','acbacbacbacb'),(6198,4,5,'bcabcabcabca','acbacbacbacb'),(6199,4,5,'bcabcabcabca','acbacbacbacb'),(6200,4,5,'bcabcabcabca','acbacbacbacb'),(6201,4,5,'bcabcabcabca','acbacbacbacb'),(6202,4,5,'bcabcabcabca','acbacbacbacb'),(6203,4,5,'bcabcabcabca','acbacbacbacb'),(6204,4,5,'bcabcabcabca','acbacbacbacb'),(6205,4,5,'bcabcabcabca','acbacbacbacb'),(6206,4,5,'bcabcabcabca','acbacbacbacb'),(6207,4,5,'bcabcabcabca','acbacbacbacb'),(6208,4,5,'bcabcabcabca','acbacbacbacb'),(6209,4,5,'bcabcabcabca','acbacbacbacb'),(6210,4,5,'bcabcabcabca','acbacbacbacb'),(6211,4,5,'bcabcabcabca','acbacbacbacb'),(6212,4,5,'bcabcabcabca','acbacbacbacb'),(6213,4,5,'bcabcabcabca','acbacbacbacb'),(6214,4,5,'bcabcabcabca','acbacbacbacb'),(6215,4,5,'bcabcabcabca','acbacbacbacb'),(6216,4,5,'bcabcabcabca','acbacbacbacb'),(6217,4,5,'bcabcabcabca','acbacbacbacb'),(6218,4,5,'bcabcabcabca','acbacbacbacb'),(6219,4,5,'bcabcabcabca','acbacbacbacb'),(6220,4,5,'bcabcabcabca','acbacbacbacb'),(6221,4,5,'bcabcabcabca','acbacbacbacb'),(6222,4,5,'bcabcabcabca','acbacbacbacb'),(6223,4,5,'bcabcabcabca','acbacbacbacb'),(6224,4,5,'bcabcabcabca','acbacbacbacb'),(6225,4,5,'bcabcabcabca','acbacbacbacb'),(6226,4,5,'bcabcabcabca','acbacbacbacb'),(6227,4,5,'bcabcabcabca','acbacbacbacb'),(6228,4,5,'bcabcabcabca','acbacbacbacb'),(6229,4,5,'bcabcabcabca','acbacbacbacb'),(6230,4,5,'bcabcabcabca','acbacbacbacb'),(6231,4,5,'bcabcabcabca','acbacbacbacb'),(6232,4,5,'bcabcabcabca','acbacbacbacb'),(6233,4,5,'bcabcabcabca','acbacbacbacb'),(6234,4,5,'bcabcabcabca','acbacbacbacb'),(6235,4,5,'bcabcabcabca','acbacbacbacb'),(6236,4,5,'bcabcabcabca','acbacbacbacb'),(6237,4,5,'bcabcabcabca','acbacbacbacb'),(6238,4,5,'bcabcabcabca','acbacbacbacb'),(6239,4,5,'bcabcabcabca','acbacbacbacb'),(6240,4,5,'bcabcabcabca','acbacbacbacb'),(6241,4,5,'bcabcabcabca','acbacbacbacb'),(6242,4,5,'bcabcabcabca','acbacbacbacb'),(6243,4,5,'bcabcabcabca','acbacbacbacb'),(6244,4,5,'bcabcabcabca','acbacbacbacb'),(6245,4,5,'bcabcabcabca','acbacbacbacb'),(6246,4,5,'bcabcabcabca','acbacbacbacb'),(6247,4,5,'bcabcabcabca','acbacbacbacb'),(6248,4,5,'bcabcabcabca','acbacbacbacb'),(6249,4,5,'bcabcabcabca','acbacbacbacb'),(6250,4,5,'bcabcabcabca','acbacbacbacb'),(6251,4,5,'bcabcabcabca','acbacbacbacb'),(6252,4,5,'bcabcabcabca','acbacbacbacb'),(6253,4,5,'bcabcabcabca','acbacbacbacb'),(6254,4,5,'bcabcabcabca','acbacbacbacb'),(6255,4,5,'bcabcabcabca','acbacbacbacb'),(6256,4,5,'bcabcabcabca','acbacbacbacb'),(6257,4,5,'bcabcabcabca','acbacbacbacb'),(6258,4,5,'bcabcabcabca','acbacbacbacb'),(6259,4,5,'bcabcabcabca','acbacbacbacb'),(6260,4,5,'bcabcabcabca','acbacbacbacb'),(6261,4,5,'bcabcabcabca','acbacbacbacb'),(6262,4,5,'bcabcabcabca','acbacbacbacb'),(6263,4,5,'bcabcabcabca','acbacbacbacb'),(6264,4,5,'bcabcabcabca','acbacbacbacb'),(6265,4,5,'bcabcabcabca','acbacbacbacb'),(6266,4,5,'bcabcabcabca','acbacbacbacb'),(6267,4,5,'bcabcabcabca','acbacbacbacb'),(6268,4,5,'bcabcabcabca','acbacbacbacb'),(6269,4,5,'bcabcabcabca','acbacbacbacb'),(6270,4,5,'bcabcabcabca','acbacbacbacb'),(6271,4,5,'bcabcabcabca','acbacbacbacb'),(6272,4,5,'bcabcabcabca','acbacbacbacb'),(6273,4,5,'bcabcabcabca','acbacbacbacb'),(6274,4,5,'bcabcabcabca','acbacbacbacb'),(6275,4,5,'bcabcabcabca','acbacbacbacb'),(6276,4,5,'bcabcabcabca','acbacbacbacb'),(6277,4,5,'bcabcabcabca','acbacbacbacb'),(6278,4,5,'bcabcabcabca','acbacbacbacb'),(6279,4,5,'bcabcabcabca','acbacbacbacb'),(6280,4,5,'bcabcabcabca','acbacbacbacb'),(6281,4,5,'bcabcabcabca','acbacbacbacb'),(6282,4,5,'bcabcabcabca','acbacbacbacb'),(6283,4,5,'bcabcabcabca','acbacbacbacb'),(6284,4,5,'bcabcabcabca','acbacbacbacb'),(6285,4,5,'bcabcabcabca','acbacbacbacb'),(6286,4,5,'bcabcabcabca','acbacbacbacb'),(6287,4,5,'bcabcabcabca','acbacbacbacb'),(6288,4,5,'bcabcabcabca','acbacbacbacb'),(6289,4,5,'bcabcabcabca','acbacbacbacb'),(6290,4,5,'bcabcabcabca','acbacbacbacb'),(6291,4,5,'bcabcabcabca','acbacbacbacb'),(6292,4,5,'bcabcabcabca','acbacbacbacb'),(6293,4,5,'bcabcabcabca','acbacbacbacb'),(6294,4,5,'bcabcabcabca','acbacbacbacb'),(6295,4,5,'bcabcabcabca','acbacbacbacb'),(6296,4,5,'bcabcabcabca','acbacbacbacb'),(6297,4,5,'bcabcabcabca','acbacbacbacb'),(6298,4,5,'bcabcabcabca','acbacbacbacb'),(6299,4,5,'bcabcabcabca','acbacbacbacb'),(6300,4,5,'bcabcabcabca','acbacbacbacb'),(6301,4,5,'bcabcabcabca','acbacbacbacb'),(6302,4,5,'bcabcabcabca','acbacbacbacb'),(6303,4,5,'bcabcabcabca','acbacbacbacb'),(6304,4,5,'bcabcabcabca','acbacbacbacb'),(6305,4,5,'bcabcabcabca','acbacbacbacb'),(6306,4,5,'bcabcabcabca','acbacbacbacb'),(6307,4,5,'bcabcabcabca','acbacbacbacb'),(6308,4,5,'bcabcabcabca','acbacbacbacb'),(6309,4,5,'bcabcabcabca','acbacbacbacb'),(6310,4,5,'bcabcabcabca','acbacbacbacb'),(6311,4,5,'bcabcabcabca','acbacbacbacb'),(6312,4,5,'bcabcabcabca','acbacbacbacb'),(6313,4,5,'bcabcabcabca','acbacbacbacb'),(6314,4,5,'bcabcabcabca','acbacbacbacb'),(6315,4,5,'bcabcabcabca','acbacbacbacb'),(6316,4,5,'bcabcabcabca','acbacbacbacb'),(6317,4,5,'bcabcabcabca','acbacbacbacb'),(6318,4,5,'bcabcabcabca','acbacbacbacb'),(6319,4,5,'bcabcabcabca','acbacbacbacb'),(6320,4,5,'bcabcabcabca','acbacbacbacb'),(6321,4,5,'bcabcabcabca','acbacbacbacb'),(6322,4,5,'bcabcabcabca','acbacbacbacb'),(6323,4,5,'bcabcabcabca','acbacbacbacb'),(6324,4,5,'bcabcabcabca','acbacbacbacb'),(6325,4,5,'bcabcabcabca','acbacbacbacb'),(6326,4,5,'bcabcabcabca','acbacbacbacb'),(6327,4,5,'bcabcabcabca','acbacbacbacb'),(6328,4,5,'bcabcabcabca','acbacbacbacb'),(6329,4,5,'bcabcabcabca','acbacbacbacb'),(6330,4,5,'bcabcabcabca','acbacbacbacb'),(6331,4,5,'bcabcabcabca','acbacbacbacb'),(6332,4,5,'bcabcabcabca','acbacbacbacb'),(6333,4,5,'bcabcabcabca','acbacbacbacb'),(6334,4,5,'bcabcabcabca','acbacbacbacb'),(6335,4,5,'bcabcabcabca','acbacbacbacb'),(6336,4,5,'bcabcabcabca','acbacbacbacb'),(6337,4,5,'bcabcabcabca','acbacbacbacb'),(6338,4,5,'bcabcabcabca','acbacbacbacb'),(6339,4,5,'bcabcabcabca','acbacbacbacb'),(6340,4,5,'bcabcabcabca','acbacbacbacb'),(6341,4,5,'bcabcabcabca','acbacbacbacb'),(6342,4,5,'bcabcabcabca','acbacbacbacb'),(6343,4,5,'bcabcabcabca','acbacbacbacb'),(6344,4,5,'bcabcabcabca','acbacbacbacb'),(6345,4,5,'bcabcabcabca','acbacbacbacb'),(6346,4,5,'bcabcabcabca','acbacbacbacb'),(6347,4,5,'bcabcabcabca','acbacbacbacb'),(6348,4,5,'bcabcabcabca','acbacbacbacb'),(6349,4,5,'bcabcabcabca','acbacbacbacb'),(6350,4,5,'bcabcabcabca','acbacbacbacb'),(6351,4,5,'bcabcabcabca','acbacbacbacb'),(6352,4,5,'bcabcabcabca','acbacbacbacb'),(6353,4,5,'bcabcabcabca','acbacbacbacb'),(6354,4,5,'bcabcabcabca','acbacbacbacb'),(6355,4,5,'bcabcabcabca','acbacbacbacb'),(6356,4,5,'bcabcabcabca','acbacbacbacb'),(6357,4,5,'bcabcabcabca','acbacbacbacb'),(6358,4,5,'bcabcabcabca','acbacbacbacb'),(6359,4,5,'bcabcabcabca','acbacbacbacb'),(6360,4,5,'bcabcabcabca','acbacbacbacb'),(6361,4,5,'bcabcabcabca','acbacbacbacb'),(6362,4,5,'bcabcabcabca','acbacbacbacb'),(6363,4,5,'bcabcabcabca','acbacbacbacb'),(6364,4,5,'bcabcabcabca','acbacbacbacb'),(6365,4,5,'bcabcabcabca','acbacbacbacb'),(6366,4,5,'bcabcabcabca','acbacbacbacb'),(6367,4,5,'bcabcabcabca','acbacbacbacb'),(6368,4,5,'bcabcabcabca','acbacbacbacb'),(6369,4,5,'bcabcabcabca','acbacbacbacb'),(6370,4,5,'bcabcabcabca','acbacbacbacb'),(6371,4,5,'bcabcabcabca','acbacbacbacb'),(6372,4,5,'bcabcabcabca','acbacbacbacb'),(6373,4,5,'bcabcabcabca','acbacbacbacb'),(6374,4,5,'bcabcabcabca','acbacbacbacb'),(6375,4,5,'bcabcabcabca','acbacbacbacb'),(6376,4,5,'bcabcabcabca','acbacbacbacb'),(6377,4,5,'bcabcabcabca','acbacbacbacb'),(6378,4,5,'bcabcabcabca','acbacbacbacb'),(6379,4,5,'bcabcabcabca','acbacbacbacb'),(6380,4,5,'bcabcabcabca','acbacbacbacb'),(6381,4,5,'bcabcabcabca','acbacbacbacb'),(6382,4,5,'bcabcabcabca','acbacbacbacb'),(6383,4,5,'bcabcabcabca','acbacbacbacb'),(6384,4,5,'bcabcabcabca','acbacbacbacb'),(6385,4,5,'bcabcabcabca','acbacbacbacb'),(6386,4,5,'bcabcabcabca','acbacbacbacb'),(6387,4,5,'bcabcabcabca','acbacbacbacb'),(6388,4,5,'bcabcabcabca','acbacbacbacb'),(6389,4,5,'bcabcabcabca','acbacbacbacb'),(6390,4,5,'bcabcabcabca','acbacbacbacb'),(6391,4,5,'bcabcabcabca','acbacbacbacb'),(6392,4,5,'bcabcabcabca','acbacbacbacb'),(6393,4,5,'bcabcabcabca','acbacbacbacb'),(6394,4,5,'bcabcabcabca','acbacbacbacb'),(6395,4,5,'bcabcabcabca','acbacbacbacb'),(6396,4,5,'bcabcabcabca','acbacbacbacb'),(6397,4,5,'bcabcabcabca','acbacbacbacb'),(6398,4,5,'bcabcabcabca','acbacbacbacb'),(6399,4,5,'bcabcabcabca','acbacbacbacb'),(6400,4,5,'bcabcabcabca','acbacbacbacb'),(6401,4,5,'bcabcabcabca','acbacbacbacb'),(6402,4,5,'bcabcabcabca','acbacbacbacb'),(6403,4,5,'bcabcabcabca','acbacbacbacb'),(6404,4,5,'bcabcabcabca','acbacbacbacb'),(6405,4,5,'bcabcabcabca','acbacbacbacb'),(6406,4,5,'bcabcabcabca','acbacbacbacb'),(6407,4,5,'bcabcabcabca','acbacbacbacb'),(6408,4,5,'bcabcabcabca','acbacbacbacb'),(6409,4,5,'bcabcabcabca','acbacbacbacb'),(6410,4,5,'bcabcabcabca','acbacbacbacb'),(6411,4,5,'bcabcabcabca','acbacbacbacb'),(6412,4,5,'bcabcabcabca','acbacbacbacb'),(6413,4,5,'bcabcabcabca','acbacbacbacb'),(6414,4,5,'bcabcabcabca','acbacbacbacb'),(6415,4,5,'bcabcabcabca','acbacbacbacb'),(6416,4,5,'bcabcabcabca','acbacbacbacb'),(6417,4,5,'bcabcabcabca','acbacbacbacb'),(6418,4,5,'bcabcabcabca','acbacbacbacb'),(6419,4,5,'bcabcabcabca','acbacbacbacb'),(6420,4,5,'bcabcabcabca','acbacbacbacb'),(6421,4,5,'bcabcabcabca','acbacbacbacb'),(6422,4,5,'bcabcabcabca','acbacbacbacb'),(6423,4,5,'bcabcabcabca','acbacbacbacb'),(6424,4,5,'bcabcabcabca','acbacbacbacb'),(6425,4,5,'bcabcabcabca','acbacbacbacb'),(6426,4,5,'bcabcabcabca','acbacbacbacb'),(6427,4,5,'bcabcabcabca','acbacbacbacb'),(6428,4,5,'bcabcabcabca','acbacbacbacb'),(6429,4,5,'bcabcabcabca','acbacbacbacb'),(6430,4,5,'bcabcabcabca','acbacbacbacb'),(6431,4,5,'bcabcabcabca','acbacbacbacb'),(6432,4,5,'bcabcabcabca','acbacbacbacb'),(6433,4,5,'bcabcabcabca','acbacbacbacb'),(6434,4,5,'bcabcabcabca','acbacbacbacb'),(6435,4,5,'bcabcabcabca','acbacbacbacb'),(6436,4,5,'bcabcabcabca','acbacbacbacb'),(6437,4,5,'bcabcabcabca','acbacbacbacb'),(6438,4,5,'bcabcabcabca','acbacbacbacb'),(6439,4,5,'bcabcabcabca','acbacbacbacb'),(6440,4,5,'bcabcabcabca','acbacbacbacb'),(6441,4,5,'bcabcabcabca','acbacbacbacb'),(6442,4,5,'bcabcabcabca','acbacbacbacb'),(6443,4,5,'bcabcabcabca','acbacbacbacb'),(6444,4,5,'bcabcabcabca','acbacbacbacb'),(6445,4,5,'bcabcabcabca','acbacbacbacb'),(6446,4,5,'bcabcabcabca','acbacbacbacb'),(6447,4,5,'bcabcabcabca','acbacbacbacb'),(6448,4,5,'bcabcabcabca','acbacbacbacb'),(6449,4,5,'bcabcabcabca','acbacbacbacb'),(6450,4,5,'bcabcabcabca','acbacbacbacb'),(6451,4,5,'bcabcabcabca','acbacbacbacb'),(6452,4,5,'bcabcabcabca','acbacbacbacb'),(6453,4,5,'bcabcabcabca','acbacbacbacb'),(6454,4,5,'bcabcabcabca','acbacbacbacb'),(6455,4,5,'bcabcabcabca','acbacbacbacb'),(6456,4,5,'bcabcabcabca','acbacbacbacb'),(6457,4,5,'bcabcabcabca','acbacbacbacb'),(6458,4,5,'bcabcabcabca','acbacbacbacb'),(6459,4,5,'bcabcabcabca','acbacbacbacb'),(6460,4,5,'bcabcabcabca','acbacbacbacb'),(6461,4,5,'bcabcabcabca','acbacbacbacb'),(6462,4,5,'bcabcabcabca','acbacbacbacb'),(6463,4,5,'bcabcabcabca','acbacbacbacb'),(6464,4,5,'bcabcabcabca','acbacbacbacb'),(6465,4,5,'bcabcabcabca','acbacbacbacb'),(6466,4,5,'bcabcabcabca','acbacbacbacb'),(6467,4,5,'bcabcabcabca','acbacbacbacb'),(6468,4,5,'bcabcabcabca','acbacbacbacb'),(6469,4,5,'bcabcabcabca','acbacbacbacb'),(6470,4,5,'bcabcabcabca','acbacbacbacb'),(6471,4,5,'bcabcabcabca','acbacbacbacb'),(6472,4,5,'bcabcabcabca','acbacbacbacb'),(6473,4,5,'bcabcabcabca','acbacbacbacb'),(6474,4,5,'bcabcabcabca','acbacbacbacb'),(6475,4,5,'bcabcabcabca','acbacbacbacb'),(6476,4,5,'bcabcabcabca','acbacbacbacb'),(6477,4,5,'bcabcabcabca','acbacbacbacb'),(6478,4,5,'bcabcabcabca','acbacbacbacb'),(6479,4,5,'bcabcabcabca','acbacbacbacb'),(6480,4,5,'bcabcabcabca','acbacbacbacb'),(6481,4,5,'bcabcabcabca','acbacbacbacb'),(6482,4,5,'bcabcabcabca','acbacbacbacb'),(6483,4,5,'bcabcabcabca','acbacbacbacb'),(6484,4,5,'bcabcabcabca','acbacbacbacb'),(6485,4,5,'bcabcabcabca','acbacbacbacb'),(6486,4,5,'bcabcabcabca','acbacbacbacb'),(6487,4,5,'bcabcabcabca','acbacbacbacb'),(6488,4,5,'bcabcabcabca','acbacbacbacb'),(6489,4,5,'bcabcabcabca','acbacbacbacb'),(6490,4,5,'bcabcabcabca','acbacbacbacb'),(6491,4,5,'bcabcabcabca','acbacbacbacb'),(6492,4,5,'bcabcabcabca','acbacbacbacb'),(6493,4,5,'bcabcabcabca','acbacbacbacb'),(6494,4,5,'bcabcabcabca','acbacbacbacb'),(6495,4,5,'bcabcabcabca','acbacbacbacb'),(6496,4,5,'bcabcabcabca','acbacbacbacb'),(6497,4,5,'bcabcabcabca','acbacbacbacb'),(6498,4,5,'bcabcabcabca','acbacbacbacb'),(6499,4,5,'bcabcabcabca','acbacbacbacb'),(6500,4,5,'bcabcabcabca','acbacbacbacb'),(6501,4,5,'bcabcabcabca','acbacbacbacb'),(6502,4,5,'bcabcabcabca','acbacbacbacb'),(6503,4,5,'bcabcabcabca','acbacbacbacb'),(6504,4,5,'bcabcabcabca','acbacbacbacb'),(6505,4,5,'bcabcabcabca','acbacbacbacb'),(6506,4,5,'bcabcabcabca','acbacbacbacb'),(6507,4,5,'bcabcabcabca','acbacbacbacb'),(6508,4,5,'bcabcabcabca','acbacbacbacb'),(6509,4,5,'bcabcabcabca','acbacbacbacb'),(6510,4,5,'bcabcabcabca','acbacbacbacb'),(6511,4,5,'bcabcabcabca','acbacbacbacb'),(6512,4,5,'bcabcabcabca','acbacbacbacb'),(6513,4,5,'bcabcabcabca','acbacbacbacb'),(6514,4,5,'bcabcabcabca','acbacbacbacb'),(6515,4,5,'bcabcabcabca','acbacbacbacb'),(6516,4,5,'bcabcabcabca','acbacbacbacb'),(6517,4,5,'bcabcabcabca','acbacbacbacb'),(6518,4,5,'bcabcabcabca','acbacbacbacb'),(6519,4,5,'bcabcabcabca','acbacbacbacb'),(6520,4,5,'bcabcabcabca','acbacbacbacb'),(6521,4,5,'bcabcabcabca','acbacbacbacb'),(6522,4,5,'bcabcabcabca','acbacbacbacb'),(6523,4,5,'bcabcabcabca','acbacbacbacb'),(6524,4,5,'bcabcabcabca','acbacbacbacb'),(6525,4,5,'bcabcabcabca','acbacbacbacb'),(6526,4,5,'bcabcabcabca','acbacbacbacb'),(6527,4,5,'bcabcabcabca','acbacbacbacb'),(6528,4,5,'bcabcabcabca','acbacbacbacb'),(6529,4,5,'bcabcabcabca','acbacbacbacb'),(6530,4,5,'bcabcabcabca','acbacbacbacb'),(6531,4,5,'bcabcabcabca','acbacbacbacb'),(6532,4,5,'bcabcabcabca','acbacbacbacb'),(6533,4,5,'bcabcabcabca','acbacbacbacb'),(6534,4,5,'bcabcabcabca','acbacbacbacb'),(6535,4,5,'bcabcabcabca','acbacbacbacb'),(6536,4,5,'bcabcabcabca','acbacbacbacb'),(6537,4,5,'bcabcabcabca','acbacbacbacb'),(6538,4,5,'bcabcabcabca','acbacbacbacb'),(6539,4,5,'bcabcabcabca','acbacbacbacb'),(6540,4,5,'bcabcabcabca','acbacbacbacb'),(6541,4,5,'bcabcabcabca','acbacbacbacb'),(6542,4,5,'bcabcabcabca','acbacbacbacb'),(6543,4,5,'bcabcabcabca','acbacbacbacb'),(6544,4,5,'bcabcabcabca','acbacbacbacb'),(6545,4,5,'bcabcabcabca','acbacbacbacb'),(6546,4,5,'bcabcabcabca','acbacbacbacb'),(6547,4,5,'bcabcabcabca','acbacbacbacb'),(6548,4,5,'bcabcabcabca','acbacbacbacb'),(6549,4,5,'bcabcabcabca','acbacbacbacb'),(6550,4,5,'bcabcabcabca','acbacbacbacb'),(6551,4,5,'bcabcabcabca','acbacbacbacb'),(6552,4,5,'bcabcabcabca','acbacbacbacb'),(6553,4,5,'bcabcabcabca','acbacbacbacb'),(6554,4,5,'bcabcabcabca','acbacbacbacb'),(6555,4,5,'bcabcabcabca','acbacbacbacb'),(6556,4,5,'bcabcabcabca','acbacbacbacb'),(6557,4,5,'bcabcabcabca','acbacbacbacb'),(6558,4,5,'bcabcabcabca','acbacbacbacb'),(6559,4,5,'bcabcabcabca','acbacbacbacb'),(6560,4,5,'bcabcabcabca','acbacbacbacb'),(6561,4,5,'bcabcabcabca','acbacbacbacb'),(6562,4,5,'bcabcabcabca','acbacbacbacb'),(6563,4,5,'bcabcabcabca','acbacbacbacb'),(6564,4,5,'bcabcabcabca','acbacbacbacb'),(6565,4,5,'bcabcabcabca','acbacbacbacb'),(6566,4,5,'bcabcabcabca','acbacbacbacb'),(6567,4,5,'bcabcabcabca','acbacbacbacb'),(6568,4,5,'bcabcabcabca','acbacbacbacb'),(6569,4,5,'bcabcabcabca','acbacbacbacb'),(6570,4,5,'bcabcabcabca','acbacbacbacb'),(6571,4,5,'bcabcabcabca','acbacbacbacb'),(6572,4,5,'bcabcabcabca','acbacbacbacb'),(6573,4,5,'bcabcabcabca','acbacbacbacb'),(6574,4,5,'bcabcabcabca','acbacbacbacb'),(6575,4,5,'bcabcabcabca','acbacbacbacb'),(6576,4,5,'bcabcabcabca','acbacbacbacb'),(6577,4,5,'bcabcabcabca','acbacbacbacb'),(6578,4,5,'bcabcabcabca','acbacbacbacb'),(6579,4,5,'bcabcabcabca','acbacbacbacb'),(6580,4,5,'bcabcabcabca','acbacbacbacb'),(6581,4,5,'bcabcabcabca','acbacbacbacb'),(6582,4,5,'bcabcabcabca','acbacbacbacb'),(6583,4,5,'bcabcabcabca','acbacbacbacb'),(6584,4,5,'bcabcabcabca','acbacbacbacb'),(6585,4,5,'bcabcabcabca','acbacbacbacb'),(6586,4,5,'bcabcabcabca','acbacbacbacb'),(6587,4,5,'bcabcabcabca','acbacbacbacb'),(6588,4,5,'bcabcabcabca','acbacbacbacb'),(6589,4,5,'bcabcabcabca','acbacbacbacb'),(6590,4,5,'bcabcabcabca','acbacbacbacb'),(6591,4,5,'bcabcabcabca','acbacbacbacb'),(6592,4,5,'bcabcabcabca','acbacbacbacb'),(6593,4,5,'bcabcabcabca','acbacbacbacb'),(6594,4,5,'bcabcabcabca','acbacbacbacb'),(6595,4,5,'bcabcabcabca','acbacbacbacb'),(6596,4,5,'bcabcabcabca','acbacbacbacb'),(6597,4,5,'bcabcabcabca','acbacbacbacb'),(6598,4,5,'bcabcabcabca','acbacbacbacb'),(6599,4,5,'bcabcabcabca','acbacbacbacb'),(6600,4,5,'bcabcabcabca','acbacbacbacb'),(6601,4,5,'bcabcabcabca','acbacbacbacb'),(6602,4,5,'bcabcabcabca','acbacbacbacb'),(6603,4,5,'bcabcabcabca','acbacbacbacb'),(6604,4,5,'bcabcabcabca','acbacbacbacb'),(6605,4,5,'bcabcabcabca','acbacbacbacb'),(6606,4,5,'bcabcabcabca','acbacbacbacb'),(6607,4,5,'bcabcabcabca','acbacbacbacb'),(6608,4,5,'bcabcabcabca','acbacbacbacb'),(6609,4,5,'bcabcabcabca','acbacbacbacb'),(6610,4,5,'bcabcabcabca','acbacbacbacb'),(6611,4,5,'bcabcabcabca','acbacbacbacb'),(6612,4,5,'bcabcabcabca','acbacbacbacb'),(6613,4,5,'bcabcabcabca','acbacbacbacb'),(6614,4,5,'bcabcabcabca','acbacbacbacb'),(6615,4,5,'bcabcabcabca','acbacbacbacb'),(6616,4,5,'bcabcabcabca','acbacbacbacb'),(6617,4,5,'bcabcabcabca','acbacbacbacb'),(6618,4,5,'bcabcabcabca','acbacbacbacb'),(6619,4,5,'bcabcabcabca','acbacbacbacb'),(6620,4,5,'bcabcabcabca','acbacbacbacb'),(6621,4,5,'bcabcabcabca','acbacbacbacb'),(6622,4,5,'bcabcabcabca','acbacbacbacb'),(6623,4,5,'bcabcabcabca','acbacbacbacb'),(6624,4,5,'bcabcabcabca','acbacbacbacb'),(6625,4,5,'bcabcabcabca','acbacbacbacb'),(6626,4,5,'bcabcabcabca','acbacbacbacb'),(6627,4,5,'bcabcabcabca','acbacbacbacb'),(6628,4,5,'bcabcabcabca','acbacbacbacb'),(6629,4,5,'bcabcabcabca','acbacbacbacb'),(6630,4,5,'bcabcabcabca','acbacbacbacb'),(6631,4,5,'bcabcabcabca','acbacbacbacb'),(6632,4,5,'bcabcabcabca','acbacbacbacb'),(6633,4,5,'bcabcabcabca','acbacbacbacb'),(6634,4,5,'bcabcabcabca','acbacbacbacb'),(6635,4,5,'bcabcabcabca','acbacbacbacb'),(6636,4,5,'bcabcabcabca','acbacbacbacb'),(6637,4,5,'bcabcabcabca','acbacbacbacb'),(6638,4,5,'bcabcabcabca','acbacbacbacb'),(6639,4,5,'bcabcabcabca','acbacbacbacb'),(6640,4,5,'bcabcabcabca','acbacbacbacb'),(6641,4,5,'bcabcabcabca','acbacbacbacb'),(6642,4,5,'bcabcabcabca','acbacbacbacb'),(6643,4,5,'bcabcabcabca','acbacbacbacb'),(6644,4,5,'bcabcabcabca','acbacbacbacb'),(6645,4,5,'bcabcabcabca','acbacbacbacb'),(6646,4,5,'bcabcabcabca','acbacbacbacb'),(6647,4,5,'bcabcabcabca','acbacbacbacb'),(6648,4,5,'bcabcabcabca','acbacbacbacb'),(6649,4,5,'bcabcabcabca','acbacbacbacb'),(6650,4,5,'bcabcabcabca','acbacbacbacb'),(6651,4,5,'bcabcabcabca','acbacbacbacb'),(6652,4,5,'bcabcabcabca','acbacbacbacb'),(6653,4,5,'bcabcabcabca','acbacbacbacb'),(6654,4,5,'bcabcabcabca','acbacbacbacb'),(6655,4,5,'bcabcabcabca','acbacbacbacb'),(6656,4,5,'bcabcabcabca','acbacbacbacb'),(6657,4,5,'bcabcabcabca','acbacbacbacb'),(6658,4,5,'bcabcabcabca','acbacbacbacb'),(6659,4,5,'bcabcabcabca','acbacbacbacb'),(6660,4,5,'bcabcabcabca','acbacbacbacb'),(6661,4,5,'bcabcabcabca','acbacbacbacb'),(6662,4,5,'bcabcabcabca','acbacbacbacb'),(6663,4,5,'bcabcabcabca','acbacbacbacb'),(6664,4,5,'bcabcabcabca','acbacbacbacb'),(6665,4,5,'bcabcabcabca','acbacbacbacb'),(6666,4,5,'bcabcabcabca','acbacbacbacb'),(6667,4,5,'bcabcabcabca','acbacbacbacb'),(6668,4,5,'bcabcabcabca','acbacbacbacb'),(6669,4,5,'bcabcabcabca','acbacbacbacb'),(6670,4,5,'bcabcabcabca','acbacbacbacb'),(6671,4,5,'bcabcabcabca','acbacbacbacb'),(6672,4,5,'bcabcabcabca','acbacbacbacb'),(6673,4,5,'bcabcabcabca','acbacbacbacb'),(6674,4,5,'bcabcabcabca','acbacbacbacb'),(6675,4,5,'bcabcabcabca','acbacbacbacb'),(6676,4,5,'bcabcabcabca','acbacbacbacb'),(6677,4,5,'bcabcabcabca','acbacbacbacb'),(6678,4,5,'bcabcabcabca','acbacbacbacb'),(6679,4,5,'bcabcabcabca','acbacbacbacb'),(6680,4,5,'bcabcabcabca','acbacbacbacb'),(6681,4,5,'bcabcabcabca','acbacbacbacb'),(6682,4,5,'bcabcabcabca','acbacbacbacb'),(6683,4,5,'bcabcabcabca','acbacbacbacb'),(6684,4,5,'bcabcabcabca','acbacbacbacb'),(6685,4,5,'bcabcabcabca','acbacbacbacb'),(6686,4,5,'bcabcabcabca','acbacbacbacb'),(6687,4,5,'bcabcabcabca','acbacbacbacb'),(6688,4,5,'bcabcabcabca','acbacbacbacb'),(6689,4,5,'bcabcabcabca','acbacbacbacb'),(6690,4,5,'bcabcabcabca','acbacbacbacb'),(6691,4,5,'bcabcabcabca','acbacbacbacb'),(6692,4,5,'bcabcabcabca','acbacbacbacb'),(6693,4,5,'bcabcabcabca','acbacbacbacb'),(6694,4,5,'bcabcabcabca','acbacbacbacb'),(6695,4,5,'bcabcabcabca','acbacbacbacb'),(6696,4,5,'bcabcabcabca','acbacbacbacb'),(6697,4,5,'bcabcabcabca','acbacbacbacb'),(6698,4,5,'bcabcabcabca','acbacbacbacb'),(6699,4,5,'bcabcabcabca','acbacbacbacb'),(6700,4,5,'bcabcabcabca','acbacbacbacb'),(6701,4,5,'bcabcabcabca','acbacbacbacb'),(6702,4,5,'bcabcabcabca','acbacbacbacb'),(6703,4,5,'bcabcabcabca','acbacbacbacb'),(6704,4,5,'bcabcabcabca','acbacbacbacb'),(6705,4,5,'bcabcabcabca','acbacbacbacb'),(6706,4,5,'bcabcabcabca','acbacbacbacb'),(6707,4,5,'bcabcabcabca','acbacbacbacb'),(6708,4,5,'bcabcabcabca','acbacbacbacb'),(6709,4,5,'bcabcabcabca','acbacbacbacb'),(6710,4,5,'bcabcabcabca','acbacbacbacb'),(6711,4,5,'bcabcabcabca','acbacbacbacb'),(6712,4,5,'bcabcabcabca','acbacbacbacb'),(6713,4,5,'bcabcabcabca','acbacbacbacb'),(6714,4,5,'bcabcabcabca','acbacbacbacb'),(6715,4,5,'bcabcabcabca','acbacbacbacb'),(6716,4,5,'bcabcabcabca','acbacbacbacb'),(6717,4,5,'bcabcabcabca','acbacbacbacb'),(6718,4,5,'bcabcabcabca','acbacbacbacb'),(6719,4,5,'bcabcabcabca','acbacbacbacb'),(6720,4,5,'bcabcabcabca','acbacbacbacb'),(6721,4,5,'bcabcabcabca','acbacbacbacb'),(6722,4,5,'bcabcabcabca','acbacbacbacb'),(6723,4,5,'bcabcabcabca','acbacbacbacb'),(6724,4,5,'bcabcabcabca','acbacbacbacb'),(6725,4,5,'bcabcabcabca','acbacbacbacb'),(6726,4,5,'bcabcabcabca','acbacbacbacb'),(6727,4,5,'bcabcabcabca','acbacbacbacb'),(6728,4,5,'bcabcabcabca','acbacbacbacb'),(6729,4,5,'bcabcabcabca','acbacbacbacb'),(6730,4,5,'bcabcabcabca','acbacbacbacb'),(6731,4,5,'bcabcabcabca','acbacbacbacb'),(6732,4,5,'bcabcabcabca','acbacbacbacb'),(6733,4,5,'bcabcabcabca','acbacbacbacb'),(6734,4,5,'bcabcabcabca','acbacbacbacb'),(6735,4,5,'bcabcabcabca','acbacbacbacb'),(6736,4,5,'bcabcabcabca','acbacbacbacb'),(6737,4,5,'bcabcabcabca','acbacbacbacb'),(6738,4,5,'bcabcabcabca','acbacbacbacb'),(6739,4,5,'bcabcabcabca','acbacbacbacb'),(6740,4,5,'bcabcabcabca','acbacbacbacb'),(6741,4,5,'bcabcabcabca','acbacbacbacb'),(6742,4,5,'bcabcabcabca','acbacbacbacb'),(6743,4,5,'bcabcabcabca','acbacbacbacb'),(6744,4,5,'bcabcabcabca','acbacbacbacb'),(6745,4,5,'bcabcabcabca','acbacbacbacb'),(6746,4,5,'bcabcabcabca','acbacbacbacb'),(6747,4,5,'bcabcabcabca','acbacbacbacb'),(6748,4,5,'bcabcabcabca','acbacbacbacb'),(6749,4,5,'bcabcabcabca','acbacbacbacb'),(6750,4,5,'bcabcabcabca','acbacbacbacb'),(6751,4,5,'bcabcabcabca','acbacbacbacb'),(6752,4,5,'bcabcabcabca','acbacbacbacb'),(6753,4,5,'bcabcabcabca','acbacbacbacb'),(6754,4,5,'bcabcabcabca','acbacbacbacb'),(6755,4,5,'bcabcabcabca','acbacbacbacb'),(6756,4,5,'bcabcabcabca','acbacbacbacb'),(6757,4,5,'bcabcabcabca','acbacbacbacb'),(6758,4,5,'bcabcabcabca','acbacbacbacb'),(6759,4,5,'bcabcabcabca','acbacbacbacb'),(6760,4,5,'bcabcabcabca','acbacbacbacb'),(6761,4,5,'bcabcabcabca','acbacbacbacb'),(6762,4,5,'bcabcabcabca','acbacbacbacb'),(6763,4,5,'bcabcabcabca','acbacbacbacb'),(6764,4,5,'bcabcabcabca','acbacbacbacb'),(6765,4,5,'bcabcabcabca','acbacbacbacb'),(6766,4,5,'bcabcabcabca','acbacbacbacb'),(6767,4,5,'bcabcabcabca','acbacbacbacb'),(6768,4,5,'bcabcabcabca','acbacbacbacb'),(6769,4,5,'bcabcabcabca','acbacbacbacb'),(6770,4,5,'bcabcabcabca','acbacbacbacb'),(6771,4,5,'bcabcabcabca','acbacbacbacb'),(6772,4,5,'bcabcabcabca','acbacbacbacb'),(6773,4,5,'bcabcabcabca','acbacbacbacb'),(6774,4,5,'bcabcabcabca','acbacbacbacb'),(6775,4,5,'bcabcabcabca','acbacbacbacb'),(6776,4,5,'bcabcabcabca','acbacbacbacb'),(6777,4,5,'bcabcabcabca','acbacbacbacb'),(6778,4,5,'bcabcabcabca','acbacbacbacb'),(6779,4,5,'bcabcabcabca','acbacbacbacb'),(6780,4,5,'bcabcabcabca','acbacbacbacb'),(6781,4,5,'bcabcabcabca','acbacbacbacb'),(6782,4,5,'bcabcabcabca','acbacbacbacb'),(6783,4,5,'bcabcabcabca','acbacbacbacb'),(6784,4,5,'bcabcabcabca','acbacbacbacb'),(6785,4,5,'bcabcabcabca','acbacbacbacb'),(6786,4,5,'bcabcabcabca','acbacbacbacb'),(6787,4,5,'bcabcabcabca','acbacbacbacb'),(6788,4,5,'bcabcabcabca','acbacbacbacb'),(6789,4,5,'bcabcabcabca','acbacbacbacb'),(6790,4,5,'bcabcabcabca','acbacbacbacb'),(6791,4,5,'bcabcabcabca','acbacbacbacb'),(6792,4,5,'bcabcabcabca','acbacbacbacb'),(6793,4,5,'bcabcabcabca','acbacbacbacb'),(6794,4,5,'bcabcabcabca','acbacbacbacb'),(6795,4,5,'bcabcabcabca','acbacbacbacb'),(6796,4,5,'bcabcabcabca','acbacbacbacb'),(6797,4,5,'bcabcabcabca','acbacbacbacb'),(6798,4,5,'bcabcabcabca','acbacbacbacb'),(6799,4,5,'bcabcabcabca','acbacbacbacb'),(6800,4,5,'bcabcabcabca','acbacbacbacb'),(6801,4,5,'bcabcabcabca','acbacbacbacb'),(6802,4,5,'bcabcabcabca','acbacbacbacb'),(6803,4,5,'bcabcabcabca','acbacbacbacb'),(6804,4,5,'bcabcabcabca','acbacbacbacb'),(6805,4,5,'bcabcabcabca','acbacbacbacb'),(6806,4,5,'bcabcabcabca','acbacbacbacb'),(6807,4,5,'bcabcabcabca','acbacbacbacb'),(6808,4,5,'bcabcabcabca','acbacbacbacb'),(6809,4,5,'bcabcabcabca','acbacbacbacb'),(6810,4,5,'bcabcabcabca','acbacbacbacb'),(6811,4,5,'bcabcabcabca','acbacbacbacb'),(6812,4,5,'bcabcabcabca','acbacbacbacb'),(6813,4,5,'bcabcabcabca','acbacbacbacb'),(6814,4,5,'bcabcabcabca','acbacbacbacb'),(6815,4,5,'bcabcabcabca','acbacbacbacb'),(6816,4,5,'bcabcabcabca','acbacbacbacb'),(6817,4,5,'bcabcabcabca','acbacbacbacb'),(6818,4,5,'bcabcabcabca','acbacbacbacb'),(6819,4,5,'bcabcabcabca','acbacbacbacb'),(6820,4,5,'bcabcabcabca','acbacbacbacb'),(6821,4,5,'bcabcabcabca','acbacbacbacb'),(6822,4,5,'bcabcabcabca','acbacbacbacb'),(6823,4,5,'bcabcabcabca','acbacbacbacb'),(6824,4,5,'bcabcabcabca','acbacbacbacb'),(6825,4,5,'bcabcabcabca','acbacbacbacb'),(6826,4,5,'bcabcabcabca','acbacbacbacb'),(6827,4,5,'bcabcabcabca','acbacbacbacb'),(6828,4,5,'bcabcabcabca','acbacbacbacb'),(6829,4,5,'bcabcabcabca','acbacbacbacb'),(6830,4,5,'bcabcabcabca','acbacbacbacb'),(6831,4,5,'bcabcabcabca','acbacbacbacb'),(6832,4,5,'bcabcabcabca','acbacbacbacb'),(6833,4,5,'bcabcabcabca','acbacbacbacb'),(6834,4,5,'bcabcabcabca','acbacbacbacb'),(6835,4,5,'bcabcabcabca','acbacbacbacb'),(6836,4,5,'bcabcabcabca','acbacbacbacb'),(6837,4,5,'bcabcabcabca','acbacbacbacb'),(6838,4,5,'bcabcabcabca','acbacbacbacb'),(6839,4,5,'bcabcabcabca','acbacbacbacb'),(6840,4,5,'bcabcabcabca','acbacbacbacb'),(6841,4,5,'bcabcabcabca','acbacbacbacb'),(6842,4,5,'bcabcabcabca','acbacbacbacb'),(6843,4,5,'bcabcabcabca','acbacbacbacb'),(6844,4,5,'bcabcabcabca','acbacbacbacb'),(6845,4,5,'bcabcabcabca','acbacbacbacb'),(6846,4,5,'bcabcabcabca','acbacbacbacb'),(6847,4,5,'bcabcabcabca','acbacbacbacb'),(6848,4,5,'bcabcabcabca','acbacbacbacb'),(6849,4,5,'bcabcabcabca','acbacbacbacb'),(6850,4,5,'bcabcabcabca','acbacbacbacb'),(6851,4,5,'bcabcabcabca','acbacbacbacb'),(6852,4,5,'bcabcabcabca','acbacbacbacb'),(6853,4,5,'bcabcabcabca','acbacbacbacb'),(6854,4,5,'bcabcabcabca','acbacbacbacb'),(6855,4,5,'bcabcabcabca','acbacbacbacb'),(6856,4,5,'bcabcabcabca','acbacbacbacb'),(6857,4,5,'bcabcabcabca','acbacbacbacb'),(6858,4,5,'bcabcabcabca','acbacbacbacb'),(6859,4,5,'bcabcabcabca','acbacbacbacb'),(6860,4,5,'bcabcabcabca','acbacbacbacb'),(6861,4,5,'bcabcabcabca','acbacbacbacb'),(6862,4,5,'bcabcabcabca','acbacbacbacb'),(6863,4,5,'bcabcabcabca','acbacbacbacb'),(6864,4,5,'bcabcabcabca','acbacbacbacb'),(6865,4,5,'bcabcabcabca','acbacbacbacb'),(6866,4,5,'bcabcabcabca','acbacbacbacb'),(6867,4,5,'bcabcabcabca','acbacbacbacb'),(6868,4,5,'bcabcabcabca','acbacbacbacb'),(6869,4,5,'bcabcabcabca','acbacbacbacb'),(6870,4,5,'bcabcabcabca','acbacbacbacb'),(6871,4,5,'bcabcabcabca','acbacbacbacb'),(6872,4,5,'bcabcabcabca','acbacbacbacb'),(6873,4,5,'bcabcabcabca','acbacbacbacb'),(6874,4,5,'bcabcabcabca','acbacbacbacb'),(6875,4,5,'bcabcabcabca','acbacbacbacb'),(6876,4,5,'bcabcabcabca','acbacbacbacb'),(6877,4,5,'bcabcabcabca','acbacbacbacb'),(6878,4,5,'bcabcabcabca','acbacbacbacb'),(6879,4,5,'bcabcabcabca','acbacbacbacb'),(6880,4,5,'bcabcabcabca','acbacbacbacb'),(6881,4,5,'bcabcabcabca','acbacbacbacb'),(6882,4,5,'bcabcabcabca','acbacbacbacb'),(6883,4,5,'bcabcabcabca','acbacbacbacb'),(6884,4,5,'bcabcabcabca','acbacbacbacb'),(6885,4,5,'bcabcabcabca','acbacbacbacb'),(6886,4,5,'bcabcabcabca','acbacbacbacb'),(6887,4,5,'bcabcabcabca','acbacbacbacb'),(6888,4,5,'bcabcabcabca','acbacbacbacb'),(6889,4,5,'bcabcabcabca','acbacbacbacb'),(6890,4,5,'bcabcabcabca','acbacbacbacb'),(6891,4,5,'bcabcabcabca','acbacbacbacb'),(6892,4,5,'bcabcabcabca','acbacbacbacb'),(6893,4,5,'bcabcabcabca','acbacbacbacb'),(6894,4,5,'bcabcabcabca','acbacbacbacb'),(6895,4,5,'bcabcabcabca','acbacbacbacb'),(6896,4,5,'bcabcabcabca','acbacbacbacb'),(6897,4,5,'bcabcabcabca','acbacbacbacb'),(6898,4,5,'bcabcabcabca','acbacbacbacb'),(6899,4,5,'bcabcabcabca','acbacbacbacb'),(6900,4,5,'bcabcabcabca','acbacbacbacb'),(6901,4,5,'bcabcabcabca','acbacbacbacb'),(6902,4,5,'bcabcabcabca','acbacbacbacb'),(6903,4,5,'bcabcabcabca','acbacbacbacb'),(6904,4,5,'bcabcabcabca','acbacbacbacb'),(6905,4,5,'bcabcabcabca','acbacbacbacb'),(6906,4,5,'bcabcabcabca','acbacbacbacb'),(6907,4,5,'bcabcabcabca','acbacbacbacb'),(6908,4,5,'bcabcabcabca','acbacbacbacb'),(6909,4,5,'bcabcabcabca','acbacbacbacb'),(6910,4,5,'bcabcabcabca','acbacbacbacb'),(6911,4,5,'bcabcabcabca','acbacbacbacb'),(6912,4,5,'bcabcabcabca','acbacbacbacb'),(6913,4,5,'bcabcabcabca','acbacbacbacb'),(6914,4,5,'bcabcabcabca','acbacbacbacb'),(6915,4,5,'bcabcabcabca','acbacbacbacb'),(6916,4,5,'bcabcabcabca','acbacbacbacb'),(6917,4,5,'bcabcabcabca','acbacbacbacb'),(6918,4,5,'bcabcabcabca','acbacbacbacb'),(6919,4,5,'bcabcabcabca','acbacbacbacb'),(6920,4,5,'bcabcabcabca','acbacbacbacb'),(6921,4,5,'bcabcabcabca','acbacbacbacb'),(6922,4,5,'bcabcabcabca','acbacbacbacb'),(6923,4,5,'bcabcabcabca','acbacbacbacb'),(6924,4,5,'bcabcabcabca','acbacbacbacb'),(6925,4,5,'bcabcabcabca','acbacbacbacb'),(6926,4,5,'bcabcabcabca','acbacbacbacb'),(6927,4,5,'bcabcabcabca','acbacbacbacb'),(6928,4,5,'bcabcabcabca','acbacbacbacb'),(6929,4,5,'bcabcabcabca','acbacbacbacb'),(6930,4,5,'bcabcabcabca','acbacbacbacb'),(6931,4,5,'bcabcabcabca','acbacbacbacb'),(6932,4,5,'bcabcabcabca','acbacbacbacb'),(6933,4,5,'bcabcabcabca','acbacbacbacb'),(6934,4,5,'bcabcabcabca','acbacbacbacb'),(6935,4,5,'bcabcabcabca','acbacbacbacb'),(6936,4,5,'bcabcabcabca','acbacbacbacb'),(6937,4,5,'bcabcabcabca','acbacbacbacb'),(6938,4,5,'bcabcabcabca','acbacbacbacb'),(6939,4,5,'bcabcabcabca','acbacbacbacb'),(6940,4,5,'bcabcabcabca','acbacbacbacb'),(6941,4,5,'bcabcabcabca','acbacbacbacb'),(6942,4,5,'bcabcabcabca','acbacbacbacb'),(6943,4,5,'bcabcabcabca','acbacbacbacb'),(6944,4,5,'bcabcabcabca','acbacbacbacb'),(6945,4,5,'bcabcabcabca','acbacbacbacb'),(6946,4,5,'bcabcabcabca','acbacbacbacb'),(6947,4,5,'bcabcabcabca','acbacbacbacb'),(6948,4,5,'bcabcabcabca','acbacbacbacb'),(6949,4,5,'bcabcabcabca','acbacbacbacb'),(6950,4,5,'bcabcabcabca','acbacbacbacb'),(6951,4,5,'bcabcabcabca','acbacbacbacb'),(6952,4,5,'bcabcabcabca','acbacbacbacb'),(6953,4,5,'bcabcabcabca','acbacbacbacb'),(6954,4,5,'bcabcabcabca','acbacbacbacb'),(6955,4,5,'bcabcabcabca','acbacbacbacb'),(6956,4,5,'bcabcabcabca','acbacbacbacb'),(6957,4,5,'bcabcabcabca','acbacbacbacb'),(6958,4,5,'bcabcabcabca','acbacbacbacb'),(6959,4,5,'bcabcabcabca','acbacbacbacb'),(6960,4,5,'bcabcabcabca','acbacbacbacb'),(6961,4,5,'bcabcabcabca','acbacbacbacb'),(6962,4,5,'bcabcabcabca','acbacbacbacb'),(6963,4,5,'bcabcabcabca','acbacbacbacb'),(6964,4,5,'bcabcabcabca','acbacbacbacb'),(6965,4,5,'bcabcabcabca','acbacbacbacb'),(6966,4,5,'bcabcabcabca','acbacbacbacb'),(6967,4,5,'bcabcabcabca','acbacbacbacb'),(6968,4,5,'bcabcabcabca','acbacbacbacb'),(6969,4,5,'bcabcabcabca','acbacbacbacb'),(6970,4,5,'bcabcabcabca','acbacbacbacb'),(6971,4,5,'bcabcabcabca','acbacbacbacb'),(6972,4,5,'bcabcabcabca','acbacbacbacb'),(6973,4,5,'bcabcabcabca','acbacbacbacb'),(6974,4,5,'bcabcabcabca','acbacbacbacb'),(6975,4,5,'bcabcabcabca','acbacbacbacb'),(6976,4,5,'bcabcabcabca','acbacbacbacb'),(6977,4,5,'bcabcabcabca','acbacbacbacb'),(6978,4,5,'bcabcabcabca','acbacbacbacb'),(6979,4,5,'bcabcabcabca','acbacbacbacb'),(6980,4,5,'bcabcabcabca','acbacbacbacb'),(6981,4,5,'bcabcabcabca','acbacbacbacb'),(6982,4,5,'bcabcabcabca','acbacbacbacb'),(6983,4,5,'bcabcabcabca','acbacbacbacb'),(6984,4,5,'bcabcabcabca','acbacbacbacb'),(6985,4,5,'bcabcabcabca','acbacbacbacb'),(6986,4,5,'bcabcabcabca','acbacbacbacb'),(6987,4,5,'bcabcabcabca','acbacbacbacb'),(6988,4,5,'bcabcabcabca','acbacbacbacb'),(6989,4,5,'bcabcabcabca','acbacbacbacb'),(6990,4,5,'bcabcabcabca','acbacbacbacb'),(6991,4,5,'bcabcabcabca','acbacbacbacb'),(6992,4,5,'bcabcabcabca','acbacbacbacb'),(6993,4,5,'bcabcabcabca','acbacbacbacb'),(6994,4,5,'bcabcabcabca','acbacbacbacb'),(6995,4,5,'bcabcabcabca','acbacbacbacb'),(6996,4,5,'bcabcabcabca','acbacbacbacb'),(6997,4,5,'bcabcabcabca','acbacbacbacb'),(6998,4,5,'bcabcabcabca','acbacbacbacb'),(6999,4,5,'bcabcabcabca','acbacbacbacb'),(7000,4,5,'bcabcabcabca','acbacbacbacb'),(7001,4,5,'bcabcabcabca','acbacbacbacb'),(7002,4,5,'bcabcabcabca','acbacbacbacb'),(7003,4,5,'bcabcabcabca','acbacbacbacb'),(7004,4,5,'bcabcabcabca','acbacbacbacb'),(7005,4,5,'bcabcabcabca','acbacbacbacb'),(7006,4,5,'bcabcabcabca','acbacbacbacb'),(7007,4,5,'bcabcabcabca','acbacbacbacb'),(7008,4,5,'bcabcabcabca','acbacbacbacb'),(7009,4,5,'bcabcabcabca','acbacbacbacb'),(7010,4,5,'bcabcabcabca','acbacbacbacb'),(7011,4,5,'bcabcabcabca','acbacbacbacb'),(7012,4,5,'bcabcabcabca','acbacbacbacb'),(7013,4,5,'bcabcabcabca','acbacbacbacb'),(7014,4,5,'bcabcabcabca','acbacbacbacb'),(7015,4,5,'bcabcabcabca','acbacbacbacb'),(7016,4,5,'bcabcabcabca','acbacbacbacb'),(7017,4,5,'bcabcabcabca','acbacbacbacb'),(7018,4,5,'bcabcabcabca','acbacbacbacb'),(7019,4,5,'bcabcabcabca','acbacbacbacb'),(7020,4,5,'bcabcabcabca','acbacbacbacb'),(7021,4,5,'bcabcabcabca','acbacbacbacb'),(7022,4,5,'bcabcabcabca','acbacbacbacb'),(7023,4,5,'bcabcabcabca','acbacbacbacb'),(7024,4,5,'bcabcabcabca','acbacbacbacb'),(7025,4,5,'bcabcabcabca','acbacbacbacb'),(7026,4,5,'bcabcabcabca','acbacbacbacb'),(7027,4,5,'bcabcabcabca','acbacbacbacb'),(7028,4,5,'bcabcabcabca','acbacbacbacb'),(7029,4,5,'bcabcabcabca','acbacbacbacb'),(7030,4,5,'bcabcabcabca','acbacbacbacb'),(7031,4,5,'bcabcabcabca','acbacbacbacb'),(7032,4,5,'bcabcabcabca','acbacbacbacb'),(7033,4,5,'bcabcabcabca','acbacbacbacb'),(7034,4,5,'bcabcabcabca','acbacbacbacb'),(7035,4,5,'bcabcabcabca','acbacbacbacb'),(7036,4,5,'bcabcabcabca','acbacbacbacb'),(7037,4,5,'bcabcabcabca','acbacbacbacb'),(7038,4,5,'bcabcabcabca','acbacbacbacb'),(7039,4,5,'bcabcabcabca','acbacbacbacb'),(7040,4,5,'bcabcabcabca','acbacbacbacb'),(7041,4,5,'bcabcabcabca','acbacbacbacb'),(7042,4,5,'bcabcabcabca','acbacbacbacb'),(7043,4,5,'bcabcabcabca','acbacbacbacb'),(7044,4,5,'bcabcabcabca','acbacbacbacb'),(7045,4,5,'bcabcabcabca','acbacbacbacb'),(7046,4,5,'bcabcabcabca','acbacbacbacb'),(7047,4,5,'bcabcabcabca','acbacbacbacb'),(7048,4,5,'bcabcabcabca','acbacbacbacb'),(7049,4,5,'bcabcabcabca','acbacbacbacb'),(7050,4,5,'bcabcabcabca','acbacbacbacb'),(7051,4,5,'bcabcabcabca','acbacbacbacb'),(7052,4,5,'bcabcabcabca','acbacbacbacb'),(7053,4,5,'bcabcabcabca','acbacbacbacb'),(7054,4,5,'bcabcabcabca','acbacbacbacb'),(7055,4,5,'bcabcabcabca','acbacbacbacb'),(7056,4,5,'bcabcabcabca','acbacbacbacb'),(7057,4,5,'bcabcabcabca','acbacbacbacb'),(7058,4,5,'bcabcabcabca','acbacbacbacb'),(7059,4,5,'bcabcabcabca','acbacbacbacb'),(7060,4,5,'bcabcabcabca','acbacbacbacb'),(7061,4,5,'bcabcabcabca','acbacbacbacb'),(7062,4,5,'bcabcabcabca','acbacbacbacb'),(7063,4,5,'bcabcabcabca','acbacbacbacb'),(7064,4,5,'bcabcabcabca','acbacbacbacb'),(7065,4,5,'bcabcabcabca','acbacbacbacb'),(7066,4,5,'bcabcabcabca','acbacbacbacb'),(7067,4,5,'bcabcabcabca','acbacbacbacb'),(7068,4,5,'bcabcabcabca','acbacbacbacb'),(7069,4,5,'bcabcabcabca','acbacbacbacb'),(7070,4,5,'bcabcabcabca','acbacbacbacb'),(7071,4,5,'bcabcabcabca','acbacbacbacb'),(7072,4,5,'bcabcabcabca','acbacbacbacb'),(7073,4,5,'bcabcabcabca','acbacbacbacb'),(7074,4,5,'bcabcabcabca','acbacbacbacb'),(7075,4,5,'bcabcabcabca','acbacbacbacb'),(7076,4,5,'bcabcabcabca','acbacbacbacb'),(7077,4,5,'bcabcabcabca','acbacbacbacb'),(7078,4,5,'bcabcabcabca','acbacbacbacb'),(7079,4,5,'bcabcabcabca','acbacbacbacb'),(7080,4,5,'bcabcabcabca','acbacbacbacb'),(7081,4,5,'bcabcabcabca','acbacbacbacb'),(7082,4,5,'bcabcabcabca','acbacbacbacb'),(7083,4,5,'bcabcabcabca','acbacbacbacb'),(7084,4,5,'bcabcabcabca','acbacbacbacb'),(7085,4,5,'bcabcabcabca','acbacbacbacb'),(7086,4,5,'bcabcabcabca','acbacbacbacb'),(7087,4,5,'bcabcabcabca','acbacbacbacb'),(7088,4,5,'bcabcabcabca','acbacbacbacb'),(7089,4,5,'bcabcabcabca','acbacbacbacb'),(7090,4,5,'bcabcabcabca','acbacbacbacb'),(7091,4,5,'bcabcabcabca','acbacbacbacb'),(7092,4,5,'bcabcabcabca','acbacbacbacb'),(7093,4,5,'bcabcabcabca','acbacbacbacb'),(7094,4,5,'bcabcabcabca','acbacbacbacb'),(7095,4,5,'bcabcabcabca','acbacbacbacb'),(7096,4,5,'bcabcabcabca','acbacbacbacb'),(7097,4,5,'bcabcabcabca','acbacbacbacb'),(7098,4,5,'bcabcabcabca','acbacbacbacb'),(7099,4,5,'bcabcabcabca','acbacbacbacb'),(7100,4,5,'bcabcabcabca','acbacbacbacb'),(7101,4,5,'bcabcabcabca','acbacbacbacb'),(7102,4,5,'bcabcabcabca','acbacbacbacb'),(7103,4,5,'bcabcabcabca','acbacbacbacb'),(7104,4,5,'bcabcabcabca','acbacbacbacb'),(7105,4,5,'bcabcabcabca','acbacbacbacb'),(7106,4,5,'bcabcabcabca','acbacbacbacb'),(7107,4,5,'bcabcabcabca','acbacbacbacb'),(7108,4,5,'bcabcabcabca','acbacbacbacb'),(7109,4,5,'bcabcabcabca','acbacbacbacb'),(7110,4,5,'bcabcabcabca','acbacbacbacb'),(7111,4,5,'bcabcabcabca','acbacbacbacb'),(7112,4,5,'bcabcabcabca','acbacbacbacb'),(7113,4,5,'bcabcabcabca','acbacbacbacb'),(7114,4,5,'bcabcabcabca','acbacbacbacb'),(7115,4,5,'bcabcabcabca','acbacbacbacb'),(7116,4,5,'bcabcabcabca','acbacbacbacb'),(7117,4,5,'bcabcabcabca','acbacbacbacb'),(7118,4,5,'bcabcabcabca','acbacbacbacb'),(7119,4,5,'bcabcabcabca','acbacbacbacb'),(7120,4,5,'bcabcabcabca','acbacbacbacb'),(7121,4,5,'bcabcabcabca','acbacbacbacb'),(7122,4,5,'bcabcabcabca','acbacbacbacb'),(7123,4,5,'bcabcabcabca','acbacbacbacb'),(7124,4,5,'bcabcabcabca','acbacbacbacb'),(7125,4,5,'bcabcabcabca','acbacbacbacb'),(7126,4,5,'bcabcabcabca','acbacbacbacb'),(7127,4,5,'bcabcabcabca','acbacbacbacb'),(7128,4,5,'bcabcabcabca','acbacbacbacb'),(7129,4,5,'bcabcabcabca','acbacbacbacb'),(7130,4,5,'bcabcabcabca','acbacbacbacb'),(7131,4,5,'bcabcabcabca','acbacbacbacb'),(7132,4,5,'bcabcabcabca','acbacbacbacb'),(7133,4,5,'bcabcabcabca','acbacbacbacb'),(7134,4,5,'bcabcabcabca','acbacbacbacb'),(7135,4,5,'bcabcabcabca','acbacbacbacb'),(7136,4,5,'bcabcabcabca','acbacbacbacb'),(7137,4,5,'bcabcabcabca','acbacbacbacb'),(7138,4,5,'bcabcabcabca','acbacbacbacb'),(7139,4,5,'bcabcabcabca','acbacbacbacb'),(7140,4,5,'bcabcabcabca','acbacbacbacb'),(7141,4,5,'bcabcabcabca','acbacbacbacb'),(7142,4,5,'bcabcabcabca','acbacbacbacb'),(7143,4,5,'bcabcabcabca','acbacbacbacb'),(7144,4,5,'bcabcabcabca','acbacbacbacb'),(7145,4,5,'bcabcabcabca','acbacbacbacb'),(7146,4,5,'bcabcabcabca','acbacbacbacb'),(7147,4,5,'bcabcabcabca','acbacbacbacb'),(7148,4,5,'bcabcabcabca','acbacbacbacb'),(7149,4,5,'bcabcabcabca','acbacbacbacb'),(7150,4,5,'bcabcabcabca','acbacbacbacb'),(7151,4,5,'bcabcabcabca','acbacbacbacb'),(7152,4,5,'bcabcabcabca','acbacbacbacb'),(7153,4,5,'bcabcabcabca','acbacbacbacb'),(7154,4,5,'bcabcabcabca','acbacbacbacb'),(7155,4,5,'bcabcabcabca','acbacbacbacb'),(7156,4,5,'bcabcabcabca','acbacbacbacb'),(7157,4,5,'bcabcabcabca','acbacbacbacb'),(7158,4,5,'bcabcabcabca','acbacbacbacb'),(7159,5,3,'bcabcabcabca','acbacbacbacb'),(7160,5,3,'bcabcabcabca','acbacbacbacb'),(7161,5,3,'bcabcabcabca','acbacbacbacb'),(7162,5,3,'bcabcabcabca','acbacbacbacb'),(7163,5,3,'bcabcabcabca','acbacbacbacb'),(7164,5,3,'bcabcabcabca','acbacbacbacb'),(7165,5,3,'bcabcabcabca','acbacbacbacb'),(7166,5,3,'bcabcabcabca','acbacbacbacb'),(7167,5,3,'bcabcabcabca','acbacbacbacb'),(7168,5,3,'bcabcabcabca','acbacbacbacb'),(7169,5,4,'bcabcabcabca','acbacbacbacb'),(7170,5,4,'bcabcabcabca','acbacbacbacb'),(7171,5,4,'bcabcabcabca','acbacbacbacb'),(7172,5,4,'bcabcabcabca','acbacbacbacb'),(7173,5,4,'bcabcabcabca','acbacbacbacb'),(7174,5,4,'bcabcabcabca','acbacbacbacb'),(7175,5,4,'bcabcabcabca','acbacbacbacb'),(7176,5,4,'bcabcabcabca','acbacbacbacb'),(7177,5,4,'bcabcabcabca','acbacbacbacb'),(7178,5,4,'bcabcabcabca','acbacbacbacb'),(7179,5,4,'bcabcabcabca','acbacbacbacb'),(7180,5,4,'bcabcabcabca','acbacbacbacb'),(7181,5,4,'bcabcabcabca','acbacbacbacb'),(7182,5,4,'bcabcabcabca','acbacbacbacb'),(7183,5,4,'bcabcabcabca','acbacbacbacb'),(7184,5,4,'bcabcabcabca','acbacbacbacb'),(7185,5,4,'bcabcabcabca','acbacbacbacb'),(7186,5,4,'bcabcabcabca','acbacbacbacb'),(7187,5,4,'bcabcabcabca','acbacbacbacb'),(7188,5,4,'bcabcabcabca','acbacbacbacb'),(7189,5,4,'bcabcabcabca','acbacbacbacb'),(7190,5,4,'bcabcabcabca','acbacbacbacb'),(7191,5,4,'bcabcabcabca','acbacbacbacb'),(7192,5,4,'bcabcabcabca','acbacbacbacb'),(7193,5,4,'bcabcabcabca','acbacbacbacb'),(7194,5,4,'bcabcabcabca','acbacbacbacb'),(7195,5,4,'bcabcabcabca','acbacbacbacb'),(7196,5,4,'bcabcabcabca','acbacbacbacb'),(7197,5,4,'bcabcabcabca','acbacbacbacb'),(7198,5,4,'bcabcabcabca','acbacbacbacb'),(7199,5,4,'bcabcabcabca','acbacbacbacb'),(7200,5,4,'bcabcabcabca','acbacbacbacb'),(7201,5,4,'bcabcabcabca','acbacbacbacb'),(7202,5,4,'bcabcabcabca','acbacbacbacb'),(7203,5,4,'bcabcabcabca','acbacbacbacb'),(7204,5,4,'bcabcabcabca','acbacbacbacb'),(7205,5,4,'bcabcabcabca','acbacbacbacb'),(7206,5,4,'bcabcabcabca','acbacbacbacb'),(7207,5,4,'bcabcabcabca','acbacbacbacb'),(7208,5,4,'bcabcabcabca','acbacbacbacb'),(7209,5,4,'bcabcabcabca','acbacbacbacb'),(7210,5,4,'bcabcabcabca','acbacbacbacb'),(7211,5,4,'bcabcabcabca','acbacbacbacb'),(7212,5,4,'bcabcabcabca','acbacbacbacb'),(7213,5,4,'bcabcabcabca','acbacbacbacb'),(7214,5,4,'bcabcabcabca','acbacbacbacb'),(7215,5,4,'bcabcabcabca','acbacbacbacb'),(7216,5,4,'bcabcabcabca','acbacbacbacb'),(7217,5,4,'bcabcabcabca','acbacbacbacb'),(7218,5,4,'bcabcabcabca','acbacbacbacb'),(7219,5,4,'bcabcabcabca','acbacbacbacb'),(7220,5,4,'bcabcabcabca','acbacbacbacb'),(7221,5,4,'bcabcabcabca','acbacbacbacb'),(7222,5,4,'bcabcabcabca','acbacbacbacb'),(7223,5,4,'bcabcabcabca','acbacbacbacb'),(7224,5,4,'bcabcabcabca','acbacbacbacb'),(7225,5,4,'bcabcabcabca','acbacbacbacb'),(7226,5,4,'bcabcabcabca','acbacbacbacb'),(7227,5,4,'bcabcabcabca','acbacbacbacb'),(7228,5,4,'bcabcabcabca','acbacbacbacb'),(7229,5,4,'bcabcabcabca','acbacbacbacb'),(7230,5,4,'bcabcabcabca','acbacbacbacb'),(7231,5,4,'bcabcabcabca','acbacbacbacb'),(7232,5,4,'bcabcabcabca','acbacbacbacb'),(7233,5,4,'bcabcabcabca','acbacbacbacb'),(7234,5,4,'bcabcabcabca','acbacbacbacb'),(7235,5,4,'bcabcabcabca','acbacbacbacb'),(7236,5,4,'bcabcabcabca','acbacbacbacb'),(7237,5,4,'bcabcabcabca','acbacbacbacb'),(7238,5,4,'bcabcabcabca','acbacbacbacb'),(7239,5,4,'bcabcabcabca','acbacbacbacb'),(7240,5,4,'bcabcabcabca','acbacbacbacb'),(7241,5,4,'bcabcabcabca','acbacbacbacb'),(7242,5,4,'bcabcabcabca','acbacbacbacb'),(7243,5,4,'bcabcabcabca','acbacbacbacb'),(7244,5,4,'bcabcabcabca','acbacbacbacb'),(7245,5,4,'bcabcabcabca','acbacbacbacb'),(7246,5,4,'bcabcabcabca','acbacbacbacb'),(7247,5,4,'bcabcabcabca','acbacbacbacb'),(7248,5,4,'bcabcabcabca','acbacbacbacb'),(7249,5,4,'bcabcabcabca','acbacbacbacb'),(7250,5,4,'bcabcabcabca','acbacbacbacb'),(7251,5,4,'bcabcabcabca','acbacbacbacb'),(7252,5,4,'bcabcabcabca','acbacbacbacb'),(7253,5,4,'bcabcabcabca','acbacbacbacb'),(7254,5,4,'bcabcabcabca','acbacbacbacb'),(7255,5,4,'bcabcabcabca','acbacbacbacb'),(7256,5,4,'bcabcabcabca','acbacbacbacb'),(7257,5,4,'bcabcabcabca','acbacbacbacb'),(7258,5,4,'bcabcabcabca','acbacbacbacb'),(7259,5,4,'bcabcabcabca','acbacbacbacb'),(7260,5,4,'bcabcabcabca','acbacbacbacb'),(7261,5,4,'bcabcabcabca','acbacbacbacb'),(7262,5,4,'bcabcabcabca','acbacbacbacb'),(7263,5,4,'bcabcabcabca','acbacbacbacb'),(7264,5,4,'bcabcabcabca','acbacbacbacb'),(7265,5,4,'bcabcabcabca','acbacbacbacb'),(7266,5,4,'bcabcabcabca','acbacbacbacb'),(7267,5,4,'bcabcabcabca','acbacbacbacb'),(7268,5,4,'bcabcabcabca','acbacbacbacb'),(7269,5,4,'bcabcabcabca','acbacbacbacb'),(7270,5,4,'bcabcabcabca','acbacbacbacb'),(7271,5,4,'bcabcabcabca','acbacbacbacb'),(7272,5,4,'bcabcabcabca','acbacbacbacb'),(7273,5,4,'bcabcabcabca','acbacbacbacb'),(7274,5,4,'bcabcabcabca','acbacbacbacb'),(7275,5,4,'bcabcabcabca','acbacbacbacb'),(7276,5,4,'bcabcabcabca','acbacbacbacb'),(7277,5,4,'bcabcabcabca','acbacbacbacb'),(7278,5,4,'bcabcabcabca','acbacbacbacb'),(7279,5,4,'bcabcabcabca','acbacbacbacb'),(7280,5,4,'bcabcabcabca','acbacbacbacb'),(7281,5,4,'bcabcabcabca','acbacbacbacb'),(7282,5,4,'bcabcabcabca','acbacbacbacb'),(7283,5,4,'bcabcabcabca','acbacbacbacb'),(7284,5,4,'bcabcabcabca','acbacbacbacb'),(7285,5,4,'bcabcabcabca','acbacbacbacb'),(7286,5,4,'bcabcabcabca','acbacbacbacb'),(7287,5,4,'bcabcabcabca','acbacbacbacb'),(7288,5,4,'bcabcabcabca','acbacbacbacb'),(7289,5,4,'bcabcabcabca','acbacbacbacb'),(7290,5,4,'bcabcabcabca','acbacbacbacb'),(7291,5,4,'bcabcabcabca','acbacbacbacb'),(7292,5,4,'bcabcabcabca','acbacbacbacb'),(7293,5,4,'bcabcabcabca','acbacbacbacb'),(7294,5,4,'bcabcabcabca','acbacbacbacb'),(7295,5,4,'bcabcabcabca','acbacbacbacb'),(7296,5,4,'bcabcabcabca','acbacbacbacb'),(7297,5,4,'bcabcabcabca','acbacbacbacb'),(7298,5,4,'bcabcabcabca','acbacbacbacb'),(7299,5,4,'bcabcabcabca','acbacbacbacb'),(7300,5,4,'bcabcabcabca','acbacbacbacb'),(7301,5,4,'bcabcabcabca','acbacbacbacb'),(7302,5,4,'bcabcabcabca','acbacbacbacb'),(7303,5,4,'bcabcabcabca','acbacbacbacb'),(7304,5,4,'bcabcabcabca','acbacbacbacb'),(7305,5,4,'bcabcabcabca','acbacbacbacb'),(7306,5,4,'bcabcabcabca','acbacbacbacb'),(7307,5,4,'bcabcabcabca','acbacbacbacb'),(7308,5,4,'bcabcabcabca','acbacbacbacb'),(7309,5,4,'bcabcabcabca','acbacbacbacb'),(7310,5,4,'bcabcabcabca','acbacbacbacb'),(7311,5,4,'bcabcabcabca','acbacbacbacb'),(7312,5,4,'bcabcabcabca','acbacbacbacb'),(7313,5,4,'bcabcabcabca','acbacbacbacb'),(7314,5,4,'bcabcabcabca','acbacbacbacb'),(7315,5,4,'bcabcabcabca','acbacbacbacb'),(7316,5,4,'bcabcabcabca','acbacbacbacb'),(7317,5,4,'bcabcabcabca','acbacbacbacb'),(7318,5,4,'bcabcabcabca','acbacbacbacb'),(7319,5,4,'bcabcabcabca','acbacbacbacb'),(7320,5,4,'bcabcabcabca','acbacbacbacb'),(7321,5,4,'bcabcabcabca','acbacbacbacb'),(7322,5,4,'bcabcabcabca','acbacbacbacb'),(7323,5,4,'bcabcabcabca','acbacbacbacb'),(7324,5,4,'bcabcabcabca','acbacbacbacb'),(7325,5,4,'bcabcabcabca','acbacbacbacb'),(7326,5,4,'bcabcabcabca','acbacbacbacb'),(7327,5,4,'bcabcabcabca','acbacbacbacb'),(7328,5,4,'bcabcabcabca','acbacbacbacb'),(7329,5,4,'bcabcabcabca','acbacbacbacb'),(7330,5,4,'bcabcabcabca','acbacbacbacb'),(7331,5,4,'bcabcabcabca','acbacbacbacb'),(7332,5,4,'bcabcabcabca','acbacbacbacb'),(7333,5,4,'bcabcabcabca','acbacbacbacb'),(7334,5,4,'bcabcabcabca','acbacbacbacb'),(7335,5,4,'bcabcabcabca','acbacbacbacb'),(7336,5,4,'bcabcabcabca','acbacbacbacb'),(7337,5,4,'bcabcabcabca','acbacbacbacb'),(7338,5,4,'bcabcabcabca','acbacbacbacb'),(7339,5,4,'bcabcabcabca','acbacbacbacb'),(7340,5,4,'bcabcabcabca','acbacbacbacb'),(7341,5,4,'bcabcabcabca','acbacbacbacb'),(7342,5,4,'bcabcabcabca','acbacbacbacb'),(7343,5,4,'bcabcabcabca','acbacbacbacb'),(7344,5,4,'bcabcabcabca','acbacbacbacb'),(7345,5,4,'bcabcabcabca','acbacbacbacb'),(7346,5,4,'bcabcabcabca','acbacbacbacb'),(7347,5,4,'bcabcabcabca','acbacbacbacb'),(7348,5,4,'bcabcabcabca','acbacbacbacb'),(7349,5,4,'bcabcabcabca','acbacbacbacb'),(7350,5,4,'bcabcabcabca','acbacbacbacb'),(7351,5,4,'bcabcabcabca','acbacbacbacb'),(7352,5,4,'bcabcabcabca','acbacbacbacb'),(7353,5,4,'bcabcabcabca','acbacbacbacb'),(7354,5,4,'bcabcabcabca','acbacbacbacb'),(7355,5,4,'bcabcabcabca','acbacbacbacb'),(7356,5,4,'bcabcabcabca','acbacbacbacb'),(7357,5,4,'bcabcabcabca','acbacbacbacb'),(7358,5,4,'bcabcabcabca','acbacbacbacb'),(7359,5,4,'bcabcabcabca','acbacbacbacb'),(7360,5,4,'bcabcabcabca','acbacbacbacb'),(7361,5,4,'bcabcabcabca','acbacbacbacb'),(7362,5,4,'bcabcabcabca','acbacbacbacb'),(7363,5,4,'bcabcabcabca','acbacbacbacb'),(7364,5,4,'bcabcabcabca','acbacbacbacb'),(7365,5,4,'bcabcabcabca','acbacbacbacb'),(7366,5,4,'bcabcabcabca','acbacbacbacb'),(7367,5,4,'bcabcabcabca','acbacbacbacb'),(7368,5,4,'bcabcabcabca','acbacbacbacb'),(7369,5,4,'bcabcabcabca','acbacbacbacb'),(7370,5,4,'bcabcabcabca','acbacbacbacb'),(7371,5,4,'bcabcabcabca','acbacbacbacb'),(7372,5,4,'bcabcabcabca','acbacbacbacb'),(7373,5,4,'bcabcabcabca','acbacbacbacb'),(7374,5,4,'bcabcabcabca','acbacbacbacb'),(7375,5,4,'bcabcabcabca','acbacbacbacb'),(7376,5,4,'bcabcabcabca','acbacbacbacb'),(7377,5,4,'bcabcabcabca','acbacbacbacb'),(7378,5,4,'bcabcabcabca','acbacbacbacb'),(7379,5,4,'bcabcabcabca','acbacbacbacb'),(7380,5,4,'bcabcabcabca','acbacbacbacb'),(7381,5,4,'bcabcabcabca','acbacbacbacb'),(7382,5,4,'bcabcabcabca','acbacbacbacb'),(7383,5,4,'bcabcabcabca','acbacbacbacb'),(7384,5,4,'bcabcabcabca','acbacbacbacb'),(7385,5,4,'bcabcabcabca','acbacbacbacb'),(7386,5,4,'bcabcabcabca','acbacbacbacb'),(7387,5,4,'bcabcabcabca','acbacbacbacb'),(7388,5,4,'bcabcabcabca','acbacbacbacb'),(7389,5,4,'bcabcabcabca','acbacbacbacb'),(7390,5,4,'bcabcabcabca','acbacbacbacb'),(7391,5,4,'bcabcabcabca','acbacbacbacb'),(7392,5,4,'bcabcabcabca','acbacbacbacb'),(7393,5,4,'bcabcabcabca','acbacbacbacb'),(7394,5,4,'bcabcabcabca','acbacbacbacb'),(7395,5,4,'bcabcabcabca','acbacbacbacb'),(7396,5,4,'bcabcabcabca','acbacbacbacb'),(7397,5,4,'bcabcabcabca','acbacbacbacb'),(7398,5,4,'bcabcabcabca','acbacbacbacb'),(7399,5,4,'bcabcabcabca','acbacbacbacb'),(7400,5,4,'bcabcabcabca','acbacbacbacb'),(7401,5,4,'bcabcabcabca','acbacbacbacb'),(7402,5,4,'bcabcabcabca','acbacbacbacb'),(7403,5,4,'bcabcabcabca','acbacbacbacb'),(7404,5,4,'bcabcabcabca','acbacbacbacb'),(7405,5,4,'bcabcabcabca','acbacbacbacb'),(7406,5,4,'bcabcabcabca','acbacbacbacb'),(7407,5,4,'bcabcabcabca','acbacbacbacb'),(7408,5,4,'bcabcabcabca','acbacbacbacb'),(7409,5,4,'bcabcabcabca','acbacbacbacb'),(7410,5,4,'bcabcabcabca','acbacbacbacb'),(7411,5,4,'bcabcabcabca','acbacbacbacb'),(7412,5,4,'bcabcabcabca','acbacbacbacb'),(7413,5,4,'bcabcabcabca','acbacbacbacb'),(7414,5,4,'bcabcabcabca','acbacbacbacb'),(7415,5,4,'bcabcabcabca','acbacbacbacb'),(7416,5,4,'bcabcabcabca','acbacbacbacb'),(7417,5,4,'bcabcabcabca','acbacbacbacb'),(7418,5,4,'bcabcabcabca','acbacbacbacb'),(7419,5,4,'bcabcabcabca','acbacbacbacb'),(7420,5,4,'bcabcabcabca','acbacbacbacb'),(7421,5,4,'bcabcabcabca','acbacbacbacb'),(7422,5,4,'bcabcabcabca','acbacbacbacb'),(7423,5,4,'bcabcabcabca','acbacbacbacb'),(7424,5,4,'bcabcabcabca','acbacbacbacb'),(7425,5,4,'bcabcabcabca','acbacbacbacb'),(7426,5,4,'bcabcabcabca','acbacbacbacb'),(7427,5,4,'bcabcabcabca','acbacbacbacb'),(7428,5,4,'bcabcabcabca','acbacbacbacb'),(7429,5,4,'bcabcabcabca','acbacbacbacb'),(7430,5,4,'bcabcabcabca','acbacbacbacb'),(7431,5,4,'bcabcabcabca','acbacbacbacb'),(7432,5,4,'bcabcabcabca','acbacbacbacb'),(7433,5,4,'bcabcabcabca','acbacbacbacb'),(7434,5,4,'bcabcabcabca','acbacbacbacb'),(7435,5,4,'bcabcabcabca','acbacbacbacb'),(7436,5,4,'bcabcabcabca','acbacbacbacb'),(7437,5,4,'bcabcabcabca','acbacbacbacb'),(7438,5,4,'bcabcabcabca','acbacbacbacb'),(7439,5,4,'bcabcabcabca','acbacbacbacb'),(7440,5,4,'bcabcabcabca','acbacbacbacb'),(7441,5,4,'bcabcabcabca','acbacbacbacb'),(7442,5,4,'bcabcabcabca','acbacbacbacb'),(7443,5,4,'bcabcabcabca','acbacbacbacb'),(7444,5,4,'bcabcabcabca','acbacbacbacb'),(7445,5,4,'bcabcabcabca','acbacbacbacb'),(7446,5,4,'bcabcabcabca','acbacbacbacb'),(7447,5,4,'bcabcabcabca','acbacbacbacb'),(7448,5,4,'bcabcabcabca','acbacbacbacb'),(7449,5,4,'bcabcabcabca','acbacbacbacb'),(7450,5,4,'bcabcabcabca','acbacbacbacb'),(7451,5,4,'bcabcabcabca','acbacbacbacb'),(7452,5,4,'bcabcabcabca','acbacbacbacb'),(7453,5,4,'bcabcabcabca','acbacbacbacb'),(7454,5,4,'bcabcabcabca','acbacbacbacb'),(7455,5,4,'bcabcabcabca','acbacbacbacb'),(7456,5,4,'bcabcabcabca','acbacbacbacb'),(7457,5,4,'bcabcabcabca','acbacbacbacb'),(7458,5,4,'bcabcabcabca','acbacbacbacb'),(7459,5,4,'bcabcabcabca','acbacbacbacb'),(7460,5,4,'bcabcabcabca','acbacbacbacb'),(7461,5,4,'bcabcabcabca','acbacbacbacb'),(7462,5,4,'bcabcabcabca','acbacbacbacb'),(7463,5,4,'bcabcabcabca','acbacbacbacb'),(7464,5,4,'bcabcabcabca','acbacbacbacb'),(7465,5,4,'bcabcabcabca','acbacbacbacb'),(7466,5,4,'bcabcabcabca','acbacbacbacb'),(7467,5,4,'bcabcabcabca','acbacbacbacb'),(7468,5,4,'bcabcabcabca','acbacbacbacb'),(7469,5,4,'bcabcabcabca','acbacbacbacb'),(7470,5,4,'bcabcabcabca','acbacbacbacb'),(7471,5,4,'bcabcabcabca','acbacbacbacb'),(7472,5,4,'bcabcabcabca','acbacbacbacb'),(7473,5,4,'bcabcabcabca','acbacbacbacb'),(7474,5,4,'bcabcabcabca','acbacbacbacb'),(7475,5,4,'bcabcabcabca','acbacbacbacb'),(7476,5,4,'bcabcabcabca','acbacbacbacb'),(7477,5,4,'bcabcabcabca','acbacbacbacb'),(7478,5,4,'bcabcabcabca','acbacbacbacb'),(7479,5,4,'bcabcabcabca','acbacbacbacb'),(7480,5,4,'bcabcabcabca','acbacbacbacb'),(7481,5,4,'bcabcabcabca','acbacbacbacb'),(7482,5,4,'bcabcabcabca','acbacbacbacb'),(7483,5,4,'bcabcabcabca','acbacbacbacb'),(7484,5,4,'bcabcabcabca','acbacbacbacb'),(7485,5,4,'bcabcabcabca','acbacbacbacb'),(7486,5,4,'bcabcabcabca','acbacbacbacb'),(7487,5,4,'bcabcabcabca','acbacbacbacb'),(7488,5,4,'bcabcabcabca','acbacbacbacb'),(7489,5,4,'bcabcabcabca','acbacbacbacb'),(7490,5,4,'bcabcabcabca','acbacbacbacb'),(7491,5,4,'bcabcabcabca','acbacbacbacb'),(7492,5,4,'bcabcabcabca','acbacbacbacb'),(7493,5,4,'bcabcabcabca','acbacbacbacb'),(7494,5,4,'bcabcabcabca','acbacbacbacb'),(7495,5,4,'bcabcabcabca','acbacbacbacb'),(7496,5,4,'bcabcabcabca','acbacbacbacb'),(7497,5,4,'bcabcabcabca','acbacbacbacb'),(7498,5,4,'bcabcabcabca','acbacbacbacb'),(7499,5,4,'bcabcabcabca','acbacbacbacb'),(7500,5,4,'bcabcabcabca','acbacbacbacb'),(7501,5,4,'bcabcabcabca','acbacbacbacb'),(7502,5,4,'bcabcabcabca','acbacbacbacb'),(7503,5,4,'bcabcabcabca','acbacbacbacb'),(7504,5,4,'bcabcabcabca','acbacbacbacb'),(7505,5,4,'bcabcabcabca','acbacbacbacb'),(7506,5,4,'bcabcabcabca','acbacbacbacb'),(7507,5,4,'bcabcabcabca','acbacbacbacb'),(7508,5,4,'bcabcabcabca','acbacbacbacb'),(7509,5,4,'bcabcabcabca','acbacbacbacb'),(7510,5,4,'bcabcabcabca','acbacbacbacb'),(7511,5,4,'bcabcabcabca','acbacbacbacb'),(7512,5,4,'bcabcabcabca','acbacbacbacb'),(7513,5,4,'bcabcabcabca','acbacbacbacb'),(7514,5,4,'bcabcabcabca','acbacbacbacb'),(7515,5,4,'bcabcabcabca','acbacbacbacb'),(7516,5,4,'bcabcabcabca','acbacbacbacb'),(7517,5,4,'bcabcabcabca','acbacbacbacb'),(7518,5,4,'bcabcabcabca','acbacbacbacb'),(7519,5,4,'bcabcabcabca','acbacbacbacb'),(7520,5,4,'bcabcabcabca','acbacbacbacb'),(7521,5,4,'bcabcabcabca','acbacbacbacb'),(7522,5,4,'bcabcabcabca','acbacbacbacb'),(7523,5,4,'bcabcabcabca','acbacbacbacb'),(7524,5,4,'bcabcabcabca','acbacbacbacb'),(7525,5,4,'bcabcabcabca','acbacbacbacb'),(7526,5,4,'bcabcabcabca','acbacbacbacb'),(7527,5,4,'bcabcabcabca','acbacbacbacb'),(7528,5,4,'bcabcabcabca','acbacbacbacb'),(7529,5,4,'bcabcabcabca','acbacbacbacb'),(7530,5,4,'bcabcabcabca','acbacbacbacb'),(7531,5,4,'bcabcabcabca','acbacbacbacb'),(7532,5,4,'bcabcabcabca','acbacbacbacb'),(7533,5,4,'bcabcabcabca','acbacbacbacb'),(7534,5,4,'bcabcabcabca','acbacbacbacb'),(7535,5,4,'bcabcabcabca','acbacbacbacb'),(7536,5,4,'bcabcabcabca','acbacbacbacb'),(7537,5,4,'bcabcabcabca','acbacbacbacb'),(7538,5,4,'bcabcabcabca','acbacbacbacb'),(7539,5,4,'bcabcabcabca','acbacbacbacb'),(7540,5,4,'bcabcabcabca','acbacbacbacb'),(7541,5,4,'bcabcabcabca','acbacbacbacb'),(7542,5,4,'bcabcabcabca','acbacbacbacb'),(7543,5,4,'bcabcabcabca','acbacbacbacb'),(7544,5,4,'bcabcabcabca','acbacbacbacb'),(7545,5,4,'bcabcabcabca','acbacbacbacb'),(7546,5,4,'bcabcabcabca','acbacbacbacb'),(7547,5,4,'bcabcabcabca','acbacbacbacb'),(7548,5,4,'bcabcabcabca','acbacbacbacb'),(7549,5,4,'bcabcabcabca','acbacbacbacb'),(7550,5,4,'bcabcabcabca','acbacbacbacb'),(7551,5,4,'bcabcabcabca','acbacbacbacb'),(7552,5,4,'bcabcabcabca','acbacbacbacb'),(7553,5,4,'bcabcabcabca','acbacbacbacb'),(7554,5,4,'bcabcabcabca','acbacbacbacb'),(7555,5,4,'bcabcabcabca','acbacbacbacb'),(7556,5,4,'bcabcabcabca','acbacbacbacb'),(7557,5,4,'bcabcabcabca','acbacbacbacb'),(7558,5,4,'bcabcabcabca','acbacbacbacb'),(7559,5,4,'bcabcabcabca','acbacbacbacb'),(7560,5,4,'bcabcabcabca','acbacbacbacb'),(7561,5,4,'bcabcabcabca','acbacbacbacb'),(7562,5,4,'bcabcabcabca','acbacbacbacb'),(7563,5,4,'bcabcabcabca','acbacbacbacb'),(7564,5,4,'bcabcabcabca','acbacbacbacb'),(7565,5,4,'bcabcabcabca','acbacbacbacb'),(7566,5,4,'bcabcabcabca','acbacbacbacb'),(7567,5,4,'bcabcabcabca','acbacbacbacb'),(7568,5,4,'bcabcabcabca','acbacbacbacb'),(7569,5,4,'bcabcabcabca','acbacbacbacb'),(7570,5,4,'bcabcabcabca','acbacbacbacb'),(7571,5,4,'bcabcabcabca','acbacbacbacb'),(7572,5,4,'bcabcabcabca','acbacbacbacb'),(7573,5,4,'bcabcabcabca','acbacbacbacb'),(7574,5,4,'bcabcabcabca','acbacbacbacb'),(7575,5,4,'bcabcabcabca','acbacbacbacb'),(7576,5,4,'bcabcabcabca','acbacbacbacb'),(7577,5,4,'bcabcabcabca','acbacbacbacb'),(7578,5,4,'bcabcabcabca','acbacbacbacb'),(7579,5,4,'bcabcabcabca','acbacbacbacb'),(7580,5,4,'bcabcabcabca','acbacbacbacb'),(7581,5,4,'bcabcabcabca','acbacbacbacb'),(7582,5,4,'bcabcabcabca','acbacbacbacb'),(7583,5,4,'bcabcabcabca','acbacbacbacb'),(7584,5,4,'bcabcabcabca','acbacbacbacb'),(7585,5,4,'bcabcabcabca','acbacbacbacb'),(7586,5,4,'bcabcabcabca','acbacbacbacb'),(7587,5,4,'bcabcabcabca','acbacbacbacb'),(7588,5,4,'bcabcabcabca','acbacbacbacb'),(7589,5,4,'bcabcabcabca','acbacbacbacb'),(7590,5,4,'bcabcabcabca','acbacbacbacb'),(7591,5,4,'bcabcabcabca','acbacbacbacb'),(7592,5,4,'bcabcabcabca','acbacbacbacb'),(7593,5,4,'bcabcabcabca','acbacbacbacb'),(7594,5,4,'bcabcabcabca','acbacbacbacb'),(7595,5,4,'bcabcabcabca','acbacbacbacb'),(7596,5,4,'bcabcabcabca','acbacbacbacb'),(7597,5,4,'bcabcabcabca','acbacbacbacb'),(7598,5,4,'bcabcabcabca','acbacbacbacb'),(7599,5,4,'bcabcabcabca','acbacbacbacb'),(7600,5,4,'bcabcabcabca','acbacbacbacb'),(7601,5,4,'bcabcabcabca','acbacbacbacb'),(7602,5,4,'bcabcabcabca','acbacbacbacb'),(7603,5,4,'bcabcabcabca','acbacbacbacb'),(7604,5,4,'bcabcabcabca','acbacbacbacb'),(7605,5,4,'bcabcabcabca','acbacbacbacb'),(7606,5,4,'bcabcabcabca','acbacbacbacb'),(7607,5,4,'bcabcabcabca','acbacbacbacb'),(7608,5,4,'bcabcabcabca','acbacbacbacb'),(7609,5,4,'bcabcabcabca','acbacbacbacb'),(7610,5,4,'bcabcabcabca','acbacbacbacb'),(7611,5,4,'bcabcabcabca','acbacbacbacb'),(7612,5,4,'bcabcabcabca','acbacbacbacb'),(7613,5,4,'bcabcabcabca','acbacbacbacb'),(7614,5,4,'bcabcabcabca','acbacbacbacb'),(7615,5,4,'bcabcabcabca','acbacbacbacb'),(7616,5,4,'bcabcabcabca','acbacbacbacb'),(7617,5,4,'bcabcabcabca','acbacbacbacb'),(7618,5,4,'bcabcabcabca','acbacbacbacb'),(7619,5,4,'bcabcabcabca','acbacbacbacb'),(7620,5,4,'bcabcabcabca','acbacbacbacb'),(7621,5,4,'bcabcabcabca','acbacbacbacb'),(7622,5,4,'bcabcabcabca','acbacbacbacb'),(7623,5,4,'bcabcabcabca','acbacbacbacb'),(7624,5,4,'bcabcabcabca','acbacbacbacb'),(7625,5,4,'bcabcabcabca','acbacbacbacb'),(7626,5,4,'bcabcabcabca','acbacbacbacb'),(7627,5,4,'bcabcabcabca','acbacbacbacb'),(7628,5,4,'bcabcabcabca','acbacbacbacb'),(7629,5,4,'bcabcabcabca','acbacbacbacb'),(7630,5,4,'bcabcabcabca','acbacbacbacb'),(7631,5,4,'bcabcabcabca','acbacbacbacb'),(7632,5,4,'bcabcabcabca','acbacbacbacb'),(7633,5,4,'bcabcabcabca','acbacbacbacb'),(7634,5,4,'bcabcabcabca','acbacbacbacb'),(7635,5,4,'bcabcabcabca','acbacbacbacb'),(7636,5,4,'bcabcabcabca','acbacbacbacb'),(7637,5,4,'bcabcabcabca','acbacbacbacb'),(7638,5,4,'bcabcabcabca','acbacbacbacb'),(7639,5,4,'bcabcabcabca','acbacbacbacb'),(7640,5,4,'bcabcabcabca','acbacbacbacb'),(7641,5,4,'bcabcabcabca','acbacbacbacb'),(7642,5,4,'bcabcabcabca','acbacbacbacb'),(7643,5,4,'bcabcabcabca','acbacbacbacb'),(7644,5,4,'bcabcabcabca','acbacbacbacb'),(7645,5,4,'bcabcabcabca','acbacbacbacb'),(7646,5,4,'bcabcabcabca','acbacbacbacb'),(7647,5,4,'bcabcabcabca','acbacbacbacb'),(7648,5,4,'bcabcabcabca','acbacbacbacb'),(7649,5,4,'bcabcabcabca','acbacbacbacb'),(7650,5,4,'bcabcabcabca','acbacbacbacb'),(7651,5,4,'bcabcabcabca','acbacbacbacb'),(7652,5,4,'bcabcabcabca','acbacbacbacb'),(7653,5,4,'bcabcabcabca','acbacbacbacb'),(7654,5,4,'bcabcabcabca','acbacbacbacb'),(7655,5,4,'bcabcabcabca','acbacbacbacb'),(7656,5,4,'bcabcabcabca','acbacbacbacb'),(7657,5,4,'bcabcabcabca','acbacbacbacb'),(7658,5,4,'bcabcabcabca','acbacbacbacb'),(7659,5,4,'bcabcabcabca','acbacbacbacb'),(7660,5,4,'bcabcabcabca','acbacbacbacb'),(7661,5,4,'bcabcabcabca','acbacbacbacb'),(7662,5,4,'bcabcabcabca','acbacbacbacb'),(7663,5,4,'bcabcabcabca','acbacbacbacb'),(7664,5,4,'bcabcabcabca','acbacbacbacb'),(7665,5,4,'bcabcabcabca','acbacbacbacb'),(7666,5,4,'bcabcabcabca','acbacbacbacb'),(7667,5,4,'bcabcabcabca','acbacbacbacb'),(7668,5,4,'bcabcabcabca','acbacbacbacb'),(7669,5,4,'bcabcabcabca','acbacbacbacb'),(7670,5,4,'bcabcabcabca','acbacbacbacb'),(7671,5,4,'bcabcabcabca','acbacbacbacb'),(7672,5,4,'bcabcabcabca','acbacbacbacb'),(7673,5,4,'bcabcabcabca','acbacbacbacb'),(7674,5,4,'bcabcabcabca','acbacbacbacb'),(7675,5,4,'bcabcabcabca','acbacbacbacb'),(7676,5,4,'bcabcabcabca','acbacbacbacb'),(7677,5,4,'bcabcabcabca','acbacbacbacb'),(7678,5,4,'bcabcabcabca','acbacbacbacb'),(7679,5,4,'bcabcabcabca','acbacbacbacb'),(7680,5,4,'bcabcabcabca','acbacbacbacb'),(7681,5,4,'bcabcabcabca','acbacbacbacb'),(7682,5,4,'bcabcabcabca','acbacbacbacb'),(7683,5,4,'bcabcabcabca','acbacbacbacb'),(7684,5,4,'bcabcabcabca','acbacbacbacb'),(7685,5,4,'bcabcabcabca','acbacbacbacb'),(7686,5,4,'bcabcabcabca','acbacbacbacb'),(7687,5,4,'bcabcabcabca','acbacbacbacb'),(7688,5,4,'bcabcabcabca','acbacbacbacb'),(7689,5,4,'bcabcabcabca','acbacbacbacb'),(7690,5,4,'bcabcabcabca','acbacbacbacb'),(7691,5,4,'bcabcabcabca','acbacbacbacb'),(7692,5,4,'bcabcabcabca','acbacbacbacb'),(7693,5,4,'bcabcabcabca','acbacbacbacb'),(7694,5,4,'bcabcabcabca','acbacbacbacb'),(7695,5,4,'bcabcabcabca','acbacbacbacb'),(7696,5,4,'bcabcabcabca','acbacbacbacb'),(7697,5,4,'bcabcabcabca','acbacbacbacb'),(7698,5,4,'bcabcabcabca','acbacbacbacb'),(7699,5,4,'bcabcabcabca','acbacbacbacb'),(7700,5,4,'bcabcabcabca','acbacbacbacb'),(7701,5,4,'bcabcabcabca','acbacbacbacb'),(7702,5,4,'bcabcabcabca','acbacbacbacb'),(7703,5,4,'bcabcabcabca','acbacbacbacb'),(7704,5,4,'bcabcabcabca','acbacbacbacb'),(7705,5,4,'bcabcabcabca','acbacbacbacb'),(7706,5,4,'bcabcabcabca','acbacbacbacb'),(7707,5,4,'bcabcabcabca','acbacbacbacb'),(7708,5,4,'bcabcabcabca','acbacbacbacb'),(7709,5,4,'bcabcabcabca','acbacbacbacb'),(7710,5,4,'bcabcabcabca','acbacbacbacb'),(7711,5,4,'bcabcabcabca','acbacbacbacb'),(7712,5,4,'bcabcabcabca','acbacbacbacb'),(7713,5,4,'bcabcabcabca','acbacbacbacb'),(7714,5,4,'bcabcabcabca','acbacbacbacb'),(7715,5,4,'bcabcabcabca','acbacbacbacb'),(7716,5,4,'bcabcabcabca','acbacbacbacb'),(7717,5,4,'bcabcabcabca','acbacbacbacb'),(7718,5,4,'bcabcabcabca','acbacbacbacb'),(7719,5,4,'bcabcabcabca','acbacbacbacb'),(7720,5,4,'bcabcabcabca','acbacbacbacb'),(7721,5,4,'bcabcabcabca','acbacbacbacb'),(7722,5,4,'bcabcabcabca','acbacbacbacb'),(7723,5,4,'bcabcabcabca','acbacbacbacb'),(7724,5,4,'bcabcabcabca','acbacbacbacb'),(7725,5,4,'bcabcabcabca','acbacbacbacb'),(7726,5,4,'bcabcabcabca','acbacbacbacb'),(7727,5,4,'bcabcabcabca','acbacbacbacb'),(7728,5,4,'bcabcabcabca','acbacbacbacb'),(7729,5,4,'bcabcabcabca','acbacbacbacb'),(7730,5,4,'bcabcabcabca','acbacbacbacb'),(7731,5,4,'bcabcabcabca','acbacbacbacb'),(7732,5,4,'bcabcabcabca','acbacbacbacb'),(7733,5,4,'bcabcabcabca','acbacbacbacb'),(7734,5,4,'bcabcabcabca','acbacbacbacb'),(7735,5,4,'bcabcabcabca','acbacbacbacb'),(7736,5,4,'bcabcabcabca','acbacbacbacb'),(7737,5,4,'bcabcabcabca','acbacbacbacb'),(7738,5,4,'bcabcabcabca','acbacbacbacb'),(7739,5,4,'bcabcabcabca','acbacbacbacb'),(7740,5,4,'bcabcabcabca','acbacbacbacb'),(7741,5,4,'bcabcabcabca','acbacbacbacb'),(7742,5,4,'bcabcabcabca','acbacbacbacb'),(7743,5,4,'bcabcabcabca','acbacbacbacb'),(7744,5,4,'bcabcabcabca','acbacbacbacb'),(7745,5,4,'bcabcabcabca','acbacbacbacb'),(7746,5,4,'bcabcabcabca','acbacbacbacb'),(7747,5,4,'bcabcabcabca','acbacbacbacb'),(7748,5,4,'bcabcabcabca','acbacbacbacb'),(7749,5,4,'bcabcabcabca','acbacbacbacb'),(7750,5,4,'bcabcabcabca','acbacbacbacb'),(7751,5,4,'bcabcabcabca','acbacbacbacb'),(7752,5,4,'bcabcabcabca','acbacbacbacb'),(7753,5,4,'bcabcabcabca','acbacbacbacb'),(7754,5,4,'bcabcabcabca','acbacbacbacb'),(7755,5,4,'bcabcabcabca','acbacbacbacb'),(7756,5,4,'bcabcabcabca','acbacbacbacb'),(7757,5,4,'bcabcabcabca','acbacbacbacb'),(7758,5,4,'bcabcabcabca','acbacbacbacb'),(7759,5,4,'bcabcabcabca','acbacbacbacb'),(7760,5,4,'bcabcabcabca','acbacbacbacb'),(7761,5,4,'bcabcabcabca','acbacbacbacb'),(7762,5,4,'bcabcabcabca','acbacbacbacb'),(7763,5,4,'bcabcabcabca','acbacbacbacb'),(7764,5,4,'bcabcabcabca','acbacbacbacb'),(7765,5,4,'bcabcabcabca','acbacbacbacb'),(7766,5,4,'bcabcabcabca','acbacbacbacb'),(7767,5,4,'bcabcabcabca','acbacbacbacb'),(7768,5,4,'bcabcabcabca','acbacbacbacb'),(7769,5,4,'bcabcabcabca','acbacbacbacb'),(7770,5,4,'bcabcabcabca','acbacbacbacb'),(7771,5,4,'bcabcabcabca','acbacbacbacb'),(7772,5,4,'bcabcabcabca','acbacbacbacb'),(7773,5,4,'bcabcabcabca','acbacbacbacb'),(7774,5,4,'bcabcabcabca','acbacbacbacb'),(7775,5,4,'bcabcabcabca','acbacbacbacb'),(7776,5,4,'bcabcabcabca','acbacbacbacb'),(7777,5,4,'bcabcabcabca','acbacbacbacb'),(7778,5,4,'bcabcabcabca','acbacbacbacb'),(7779,5,4,'bcabcabcabca','acbacbacbacb'),(7780,5,4,'bcabcabcabca','acbacbacbacb'),(7781,5,4,'bcabcabcabca','acbacbacbacb'),(7782,5,4,'bcabcabcabca','acbacbacbacb'),(7783,5,4,'bcabcabcabca','acbacbacbacb'),(7784,5,4,'bcabcabcabca','acbacbacbacb'),(7785,5,4,'bcabcabcabca','acbacbacbacb'),(7786,5,4,'bcabcabcabca','acbacbacbacb'),(7787,5,4,'bcabcabcabca','acbacbacbacb'),(7788,5,4,'bcabcabcabca','acbacbacbacb'),(7789,5,4,'bcabcabcabca','acbacbacbacb'),(7790,5,4,'bcabcabcabca','acbacbacbacb'),(7791,5,4,'bcabcabcabca','acbacbacbacb'),(7792,5,4,'bcabcabcabca','acbacbacbacb'),(7793,5,4,'bcabcabcabca','acbacbacbacb'),(7794,5,4,'bcabcabcabca','acbacbacbacb'),(7795,5,4,'bcabcabcabca','acbacbacbacb'),(7796,5,4,'bcabcabcabca','acbacbacbacb'),(7797,5,4,'bcabcabcabca','acbacbacbacb'),(7798,5,4,'bcabcabcabca','acbacbacbacb'),(7799,5,4,'bcabcabcabca','acbacbacbacb'),(7800,5,4,'bcabcabcabca','acbacbacbacb'),(7801,5,4,'bcabcabcabca','acbacbacbacb'),(7802,5,4,'bcabcabcabca','acbacbacbacb'),(7803,5,4,'bcabcabcabca','acbacbacbacb'),(7804,5,4,'bcabcabcabca','acbacbacbacb'),(7805,5,4,'bcabcabcabca','acbacbacbacb'),(7806,5,4,'bcabcabcabca','acbacbacbacb'),(7807,5,4,'bcabcabcabca','acbacbacbacb'),(7808,5,4,'bcabcabcabca','acbacbacbacb'),(7809,5,4,'bcabcabcabca','acbacbacbacb'),(7810,5,4,'bcabcabcabca','acbacbacbacb'),(7811,5,4,'bcabcabcabca','acbacbacbacb'),(7812,5,4,'bcabcabcabca','acbacbacbacb'),(7813,5,4,'bcabcabcabca','acbacbacbacb'),(7814,5,4,'bcabcabcabca','acbacbacbacb'),(7815,5,4,'bcabcabcabca','acbacbacbacb'),(7816,5,4,'bcabcabcabca','acbacbacbacb'),(7817,5,4,'bcabcabcabca','acbacbacbacb'),(7818,5,4,'bcabcabcabca','acbacbacbacb'),(7819,5,4,'bcabcabcabca','acbacbacbacb'),(7820,5,4,'bcabcabcabca','acbacbacbacb'),(7821,5,4,'bcabcabcabca','acbacbacbacb'),(7822,5,4,'bcabcabcabca','acbacbacbacb'),(7823,5,4,'bcabcabcabca','acbacbacbacb'),(7824,5,4,'bcabcabcabca','acbacbacbacb'),(7825,5,4,'bcabcabcabca','acbacbacbacb'),(7826,5,4,'bcabcabcabca','acbacbacbacb'),(7827,5,4,'bcabcabcabca','acbacbacbacb'),(7828,5,4,'bcabcabcabca','acbacbacbacb'),(7829,5,4,'bcabcabcabca','acbacbacbacb'),(7830,5,4,'bcabcabcabca','acbacbacbacb'),(7831,5,4,'bcabcabcabca','acbacbacbacb'),(7832,5,4,'bcabcabcabca','acbacbacbacb'),(7833,5,4,'bcabcabcabca','acbacbacbacb'),(7834,5,4,'bcabcabcabca','acbacbacbacb'),(7835,5,4,'bcabcabcabca','acbacbacbacb'),(7836,5,4,'bcabcabcabca','acbacbacbacb'),(7837,5,4,'bcabcabcabca','acbacbacbacb'),(7838,5,4,'bcabcabcabca','acbacbacbacb'),(7839,5,4,'bcabcabcabca','acbacbacbacb'),(7840,5,4,'bcabcabcabca','acbacbacbacb'),(7841,5,4,'bcabcabcabca','acbacbacbacb'),(7842,5,4,'bcabcabcabca','acbacbacbacb'),(7843,5,4,'bcabcabcabca','acbacbacbacb'),(7844,5,4,'bcabcabcabca','acbacbacbacb'),(7845,5,4,'bcabcabcabca','acbacbacbacb'),(7846,5,4,'bcabcabcabca','acbacbacbacb'),(7847,5,4,'bcabcabcabca','acbacbacbacb'),(7848,5,4,'bcabcabcabca','acbacbacbacb'),(7849,5,4,'bcabcabcabca','acbacbacbacb'),(7850,5,4,'bcabcabcabca','acbacbacbacb'),(7851,5,4,'bcabcabcabca','acbacbacbacb'),(7852,5,4,'bcabcabcabca','acbacbacbacb'),(7853,5,4,'bcabcabcabca','acbacbacbacb'),(7854,5,4,'bcabcabcabca','acbacbacbacb'),(7855,5,4,'bcabcabcabca','acbacbacbacb'),(7856,5,4,'bcabcabcabca','acbacbacbacb'),(7857,5,4,'bcabcabcabca','acbacbacbacb'),(7858,5,4,'bcabcabcabca','acbacbacbacb'),(7859,5,4,'bcabcabcabca','acbacbacbacb'),(7860,5,4,'bcabcabcabca','acbacbacbacb'),(7861,5,4,'bcabcabcabca','acbacbacbacb'),(7862,5,4,'bcabcabcabca','acbacbacbacb'),(7863,5,4,'bcabcabcabca','acbacbacbacb'),(7864,5,4,'bcabcabcabca','acbacbacbacb'),(7865,5,4,'bcabcabcabca','acbacbacbacb'),(7866,5,4,'bcabcabcabca','acbacbacbacb'),(7867,5,4,'bcabcabcabca','acbacbacbacb'),(7868,5,4,'bcabcabcabca','acbacbacbacb'),(7869,5,4,'bcabcabcabca','acbacbacbacb'),(7870,5,4,'bcabcabcabca','acbacbacbacb'),(7871,5,4,'bcabcabcabca','acbacbacbacb'),(7872,5,4,'bcabcabcabca','acbacbacbacb'),(7873,5,4,'bcabcabcabca','acbacbacbacb'),(7874,5,4,'bcabcabcabca','acbacbacbacb'),(7875,5,4,'bcabcabcabca','acbacbacbacb'),(7876,5,4,'bcabcabcabca','acbacbacbacb'),(7877,5,4,'bcabcabcabca','acbacbacbacb'),(7878,5,4,'bcabcabcabca','acbacbacbacb'),(7879,5,4,'bcabcabcabca','acbacbacbacb'),(7880,5,4,'bcabcabcabca','acbacbacbacb'),(7881,5,4,'bcabcabcabca','acbacbacbacb'),(7882,5,4,'bcabcabcabca','acbacbacbacb'),(7883,5,4,'bcabcabcabca','acbacbacbacb'),(7884,5,4,'bcabcabcabca','acbacbacbacb'),(7885,5,4,'bcabcabcabca','acbacbacbacb'),(7886,5,4,'bcabcabcabca','acbacbacbacb'),(7887,5,4,'bcabcabcabca','acbacbacbacb'),(7888,5,4,'bcabcabcabca','acbacbacbacb'),(7889,5,4,'bcabcabcabca','acbacbacbacb'),(7890,5,4,'bcabcabcabca','acbacbacbacb'),(7891,5,4,'bcabcabcabca','acbacbacbacb'),(7892,5,4,'bcabcabcabca','acbacbacbacb'),(7893,5,4,'bcabcabcabca','acbacbacbacb'),(7894,5,4,'bcabcabcabca','acbacbacbacb'),(7895,5,4,'bcabcabcabca','acbacbacbacb'),(7896,5,4,'bcabcabcabca','acbacbacbacb'),(7897,5,4,'bcabcabcabca','acbacbacbacb'),(7898,5,4,'bcabcabcabca','acbacbacbacb'),(7899,5,4,'bcabcabcabca','acbacbacbacb'),(7900,5,4,'bcabcabcabca','acbacbacbacb'),(7901,5,4,'bcabcabcabca','acbacbacbacb'),(7902,5,4,'bcabcabcabca','acbacbacbacb'),(7903,5,4,'bcabcabcabca','acbacbacbacb'),(7904,5,4,'bcabcabcabca','acbacbacbacb'),(7905,5,4,'bcabcabcabca','acbacbacbacb'),(7906,5,4,'bcabcabcabca','acbacbacbacb'),(7907,5,4,'bcabcabcabca','acbacbacbacb'),(7908,5,4,'bcabcabcabca','acbacbacbacb'),(7909,5,4,'bcabcabcabca','acbacbacbacb'),(7910,5,4,'bcabcabcabca','acbacbacbacb'),(7911,5,4,'bcabcabcabca','acbacbacbacb'),(7912,5,4,'bcabcabcabca','acbacbacbacb'),(7913,5,4,'bcabcabcabca','acbacbacbacb'),(7914,5,4,'bcabcabcabca','acbacbacbacb'),(7915,5,4,'bcabcabcabca','acbacbacbacb'),(7916,5,4,'bcabcabcabca','acbacbacbacb'),(7917,5,4,'bcabcabcabca','acbacbacbacb'),(7918,5,4,'bcabcabcabca','acbacbacbacb'),(7919,5,4,'bcabcabcabca','acbacbacbacb'),(7920,5,4,'bcabcabcabca','acbacbacbacb'),(7921,5,4,'bcabcabcabca','acbacbacbacb'),(7922,5,4,'bcabcabcabca','acbacbacbacb'),(7923,5,4,'bcabcabcabca','acbacbacbacb'),(7924,5,4,'bcabcabcabca','acbacbacbacb'),(7925,5,4,'bcabcabcabca','acbacbacbacb'),(7926,5,4,'bcabcabcabca','acbacbacbacb'),(7927,5,4,'bcabcabcabca','acbacbacbacb'),(7928,5,4,'bcabcabcabca','acbacbacbacb'),(7929,5,4,'bcabcabcabca','acbacbacbacb'),(7930,5,4,'bcabcabcabca','acbacbacbacb'),(7931,5,4,'bcabcabcabca','acbacbacbacb'),(7932,5,4,'bcabcabcabca','acbacbacbacb'),(7933,5,4,'bcabcabcabca','acbacbacbacb'),(7934,5,4,'bcabcabcabca','acbacbacbacb'),(7935,5,4,'bcabcabcabca','acbacbacbacb'),(7936,5,4,'bcabcabcabca','acbacbacbacb'),(7937,5,4,'bcabcabcabca','acbacbacbacb'),(7938,5,4,'bcabcabcabca','acbacbacbacb'),(7939,5,4,'bcabcabcabca','acbacbacbacb'),(7940,5,4,'bcabcabcabca','acbacbacbacb'),(7941,5,4,'bcabcabcabca','acbacbacbacb'),(7942,5,4,'bcabcabcabca','acbacbacbacb'),(7943,5,4,'bcabcabcabca','acbacbacbacb'),(7944,5,4,'bcabcabcabca','acbacbacbacb'),(7945,5,4,'bcabcabcabca','acbacbacbacb'),(7946,5,4,'bcabcabcabca','acbacbacbacb'),(7947,5,4,'bcabcabcabca','acbacbacbacb'),(7948,5,4,'bcabcabcabca','acbacbacbacb'),(7949,5,4,'bcabcabcabca','acbacbacbacb'),(7950,5,4,'bcabcabcabca','acbacbacbacb'),(7951,5,4,'bcabcabcabca','acbacbacbacb'),(7952,5,4,'bcabcabcabca','acbacbacbacb'),(7953,5,4,'bcabcabcabca','acbacbacbacb'),(7954,5,4,'bcabcabcabca','acbacbacbacb'),(7955,5,4,'bcabcabcabca','acbacbacbacb'),(7956,5,4,'bcabcabcabca','acbacbacbacb'),(7957,5,4,'bcabcabcabca','acbacbacbacb'),(7958,5,4,'bcabcabcabca','acbacbacbacb'),(7959,5,4,'bcabcabcabca','acbacbacbacb'),(7960,5,4,'bcabcabcabca','acbacbacbacb'),(7961,5,4,'bcabcabcabca','acbacbacbacb'),(7962,5,4,'bcabcabcabca','acbacbacbacb'),(7963,5,4,'bcabcabcabca','acbacbacbacb'),(7964,5,4,'bcabcabcabca','acbacbacbacb'),(7965,5,4,'bcabcabcabca','acbacbacbacb'),(7966,5,4,'bcabcabcabca','acbacbacbacb'),(7967,5,4,'bcabcabcabca','acbacbacbacb'),(7968,5,4,'bcabcabcabca','acbacbacbacb'),(7969,5,4,'bcabcabcabca','acbacbacbacb'),(7970,5,4,'bcabcabcabca','acbacbacbacb'),(7971,5,4,'bcabcabcabca','acbacbacbacb'),(7972,5,4,'bcabcabcabca','acbacbacbacb'),(7973,5,4,'bcabcabcabca','acbacbacbacb'),(7974,5,4,'bcabcabcabca','acbacbacbacb'),(7975,5,4,'bcabcabcabca','acbacbacbacb'),(7976,5,4,'bcabcabcabca','acbacbacbacb'),(7977,5,4,'bcabcabcabca','acbacbacbacb'),(7978,5,4,'bcabcabcabca','acbacbacbacb'),(7979,5,4,'bcabcabcabca','acbacbacbacb'),(7980,5,4,'bcabcabcabca','acbacbacbacb'),(7981,5,4,'bcabcabcabca','acbacbacbacb'),(7982,5,4,'bcabcabcabca','acbacbacbacb'),(7983,5,4,'bcabcabcabca','acbacbacbacb'),(7984,5,4,'bcabcabcabca','acbacbacbacb'),(7985,5,4,'bcabcabcabca','acbacbacbacb'),(7986,5,4,'bcabcabcabca','acbacbacbacb'),(7987,5,4,'bcabcabcabca','acbacbacbacb'),(7988,5,4,'bcabcabcabca','acbacbacbacb'),(7989,5,4,'bcabcabcabca','acbacbacbacb'),(7990,5,4,'bcabcabcabca','acbacbacbacb'),(7991,5,4,'bcabcabcabca','acbacbacbacb'),(7992,5,4,'bcabcabcabca','acbacbacbacb'),(7993,5,4,'bcabcabcabca','acbacbacbacb'),(7994,5,4,'bcabcabcabca','acbacbacbacb'),(7995,5,4,'bcabcabcabca','acbacbacbacb'),(7996,5,4,'bcabcabcabca','acbacbacbacb'),(7997,5,4,'bcabcabcabca','acbacbacbacb'),(7998,5,4,'bcabcabcabca','acbacbacbacb'),(7999,5,4,'bcabcabcabca','acbacbacbacb'),(8000,5,4,'bcabcabcabca','acbacbacbacb'),(8001,5,4,'bcabcabcabca','acbacbacbacb'),(8002,5,4,'bcabcabcabca','acbacbacbacb'),(8003,5,4,'bcabcabcabca','acbacbacbacb'),(8004,5,4,'bcabcabcabca','acbacbacbacb'),(8005,5,4,'bcabcabcabca','acbacbacbacb'),(8006,5,4,'bcabcabcabca','acbacbacbacb'),(8007,5,4,'bcabcabcabca','acbacbacbacb'),(8008,5,4,'bcabcabcabca','acbacbacbacb'),(8009,5,4,'bcabcabcabca','acbacbacbacb'),(8010,5,4,'bcabcabcabca','acbacbacbacb'),(8011,5,4,'bcabcabcabca','acbacbacbacb'),(8012,5,4,'bcabcabcabca','acbacbacbacb'),(8013,5,4,'bcabcabcabca','acbacbacbacb'),(8014,5,4,'bcabcabcabca','acbacbacbacb'),(8015,5,4,'bcabcabcabca','acbacbacbacb'),(8016,5,4,'bcabcabcabca','acbacbacbacb'),(8017,5,4,'bcabcabcabca','acbacbacbacb'),(8018,5,4,'bcabcabcabca','acbacbacbacb'),(8019,5,4,'bcabcabcabca','acbacbacbacb'),(8020,5,4,'bcabcabcabca','acbacbacbacb'),(8021,5,4,'bcabcabcabca','acbacbacbacb'),(8022,5,4,'bcabcabcabca','acbacbacbacb'),(8023,5,4,'bcabcabcabca','acbacbacbacb'),(8024,5,4,'bcabcabcabca','acbacbacbacb'),(8025,5,4,'bcabcabcabca','acbacbacbacb'),(8026,5,4,'bcabcabcabca','acbacbacbacb'),(8027,5,4,'bcabcabcabca','acbacbacbacb'),(8028,5,4,'bcabcabcabca','acbacbacbacb'),(8029,5,4,'bcabcabcabca','acbacbacbacb'),(8030,5,4,'bcabcabcabca','acbacbacbacb'),(8031,5,4,'bcabcabcabca','acbacbacbacb'),(8032,5,4,'bcabcabcabca','acbacbacbacb'),(8033,5,4,'bcabcabcabca','acbacbacbacb'),(8034,5,4,'bcabcabcabca','acbacbacbacb'),(8035,5,4,'bcabcabcabca','acbacbacbacb'),(8036,5,4,'bcabcabcabca','acbacbacbacb'),(8037,5,4,'bcabcabcabca','acbacbacbacb'),(8038,5,4,'bcabcabcabca','acbacbacbacb'),(8039,5,4,'bcabcabcabca','acbacbacbacb'),(8040,5,4,'bcabcabcabca','acbacbacbacb'),(8041,5,4,'bcabcabcabca','acbacbacbacb'),(8042,5,4,'bcabcabcabca','acbacbacbacb'),(8043,5,4,'bcabcabcabca','acbacbacbacb'),(8044,5,4,'bcabcabcabca','acbacbacbacb'),(8045,5,4,'bcabcabcabca','acbacbacbacb'),(8046,5,4,'bcabcabcabca','acbacbacbacb'),(8047,5,4,'bcabcabcabca','acbacbacbacb'),(8048,5,4,'bcabcabcabca','acbacbacbacb'),(8049,5,4,'bcabcabcabca','acbacbacbacb'),(8050,5,4,'bcabcabcabca','acbacbacbacb'),(8051,5,4,'bcabcabcabca','acbacbacbacb'),(8052,5,4,'bcabcabcabca','acbacbacbacb'),(8053,5,4,'bcabcabcabca','acbacbacbacb'),(8054,5,4,'bcabcabcabca','acbacbacbacb'),(8055,5,4,'bcabcabcabca','acbacbacbacb'),(8056,5,4,'bcabcabcabca','acbacbacbacb'),(8057,5,4,'bcabcabcabca','acbacbacbacb'),(8058,5,4,'bcabcabcabca','acbacbacbacb'),(8059,5,4,'bcabcabcabca','acbacbacbacb'),(8060,5,4,'bcabcabcabca','acbacbacbacb'),(8061,5,4,'bcabcabcabca','acbacbacbacb'),(8062,5,4,'bcabcabcabca','acbacbacbacb'),(8063,5,4,'bcabcabcabca','acbacbacbacb'),(8064,5,4,'bcabcabcabca','acbacbacbacb'),(8065,5,4,'bcabcabcabca','acbacbacbacb'),(8066,5,4,'bcabcabcabca','acbacbacbacb'),(8067,5,4,'bcabcabcabca','acbacbacbacb'),(8068,5,4,'bcabcabcabca','acbacbacbacb'),(8069,5,4,'bcabcabcabca','acbacbacbacb'),(8070,5,4,'bcabcabcabca','acbacbacbacb'),(8071,5,4,'bcabcabcabca','acbacbacbacb'),(8072,5,4,'bcabcabcabca','acbacbacbacb'),(8073,5,4,'bcabcabcabca','acbacbacbacb'),(8074,5,4,'bcabcabcabca','acbacbacbacb'),(8075,5,4,'bcabcabcabca','acbacbacbacb'),(8076,5,4,'bcabcabcabca','acbacbacbacb'),(8077,5,4,'bcabcabcabca','acbacbacbacb'),(8078,5,4,'bcabcabcabca','acbacbacbacb'),(8079,5,4,'bcabcabcabca','acbacbacbacb'),(8080,5,4,'bcabcabcabca','acbacbacbacb'),(8081,5,4,'bcabcabcabca','acbacbacbacb'),(8082,5,4,'bcabcabcabca','acbacbacbacb'),(8083,5,4,'bcabcabcabca','acbacbacbacb'),(8084,5,4,'bcabcabcabca','acbacbacbacb'),(8085,5,4,'bcabcabcabca','acbacbacbacb'),(8086,5,4,'bcabcabcabca','acbacbacbacb'),(8087,5,4,'bcabcabcabca','acbacbacbacb'),(8088,5,4,'bcabcabcabca','acbacbacbacb'),(8089,5,4,'bcabcabcabca','acbacbacbacb'),(8090,5,4,'bcabcabcabca','acbacbacbacb'),(8091,5,4,'bcabcabcabca','acbacbacbacb'),(8092,5,4,'bcabcabcabca','acbacbacbacb'),(8093,5,4,'bcabcabcabca','acbacbacbacb'),(8094,5,4,'bcabcabcabca','acbacbacbacb'),(8095,5,4,'bcabcabcabca','acbacbacbacb'),(8096,5,4,'bcabcabcabca','acbacbacbacb'),(8097,5,4,'bcabcabcabca','acbacbacbacb'),(8098,5,4,'bcabcabcabca','acbacbacbacb'),(8099,5,4,'bcabcabcabca','acbacbacbacb'),(8100,5,4,'bcabcabcabca','acbacbacbacb'),(8101,5,4,'bcabcabcabca','acbacbacbacb'),(8102,5,4,'bcabcabcabca','acbacbacbacb'),(8103,5,4,'bcabcabcabca','acbacbacbacb'),(8104,5,4,'bcabcabcabca','acbacbacbacb'),(8105,5,4,'bcabcabcabca','acbacbacbacb'),(8106,5,4,'bcabcabcabca','acbacbacbacb'),(8107,5,4,'bcabcabcabca','acbacbacbacb'),(8108,5,4,'bcabcabcabca','acbacbacbacb'),(8109,5,4,'bcabcabcabca','acbacbacbacb'),(8110,5,4,'bcabcabcabca','acbacbacbacb'),(8111,5,4,'bcabcabcabca','acbacbacbacb'),(8112,5,4,'bcabcabcabca','acbacbacbacb'),(8113,5,4,'bcabcabcabca','acbacbacbacb'),(8114,5,4,'bcabcabcabca','acbacbacbacb'),(8115,5,4,'bcabcabcabca','acbacbacbacb'),(8116,5,4,'bcabcabcabca','acbacbacbacb'),(8117,5,4,'bcabcabcabca','acbacbacbacb'),(8118,5,4,'bcabcabcabca','acbacbacbacb'),(8119,5,4,'bcabcabcabca','acbacbacbacb'),(8120,5,4,'bcabcabcabca','acbacbacbacb'),(8121,5,4,'bcabcabcabca','acbacbacbacb'),(8122,5,4,'bcabcabcabca','acbacbacbacb'),(8123,5,4,'bcabcabcabca','acbacbacbacb'),(8124,5,4,'bcabcabcabca','acbacbacbacb'),(8125,5,4,'bcabcabcabca','acbacbacbacb'),(8126,5,4,'bcabcabcabca','acbacbacbacb'),(8127,5,4,'bcabcabcabca','acbacbacbacb'),(8128,5,4,'bcabcabcabca','acbacbacbacb'),(8129,5,4,'bcabcabcabca','acbacbacbacb'),(8130,5,4,'bcabcabcabca','acbacbacbacb'),(8131,5,4,'bcabcabcabca','acbacbacbacb'),(8132,5,4,'bcabcabcabca','acbacbacbacb'),(8133,5,4,'bcabcabcabca','acbacbacbacb'),(8134,5,4,'bcabcabcabca','acbacbacbacb'),(8135,5,4,'bcabcabcabca','acbacbacbacb'),(8136,5,4,'bcabcabcabca','acbacbacbacb'),(8137,5,4,'bcabcabcabca','acbacbacbacb'),(8138,5,4,'bcabcabcabca','acbacbacbacb'),(8139,5,4,'bcabcabcabca','acbacbacbacb'),(8140,5,4,'bcabcabcabca','acbacbacbacb'),(8141,5,4,'bcabcabcabca','acbacbacbacb'),(8142,5,4,'bcabcabcabca','acbacbacbacb'),(8143,5,4,'bcabcabcabca','acbacbacbacb'),(8144,5,4,'bcabcabcabca','acbacbacbacb'),(8145,5,4,'bcabcabcabca','acbacbacbacb'),(8146,5,4,'bcabcabcabca','acbacbacbacb'),(8147,5,4,'bcabcabcabca','acbacbacbacb'),(8148,5,4,'bcabcabcabca','acbacbacbacb'),(8149,5,4,'bcabcabcabca','acbacbacbacb'),(8150,5,4,'bcabcabcabca','acbacbacbacb'),(8151,5,4,'bcabcabcabca','acbacbacbacb'),(8152,5,4,'bcabcabcabca','acbacbacbacb'),(8153,5,4,'bcabcabcabca','acbacbacbacb'),(8154,5,4,'bcabcabcabca','acbacbacbacb'),(8155,5,4,'bcabcabcabca','acbacbacbacb'),(8156,5,4,'bcabcabcabca','acbacbacbacb'),(8157,5,4,'bcabcabcabca','acbacbacbacb'),(8158,5,4,'bcabcabcabca','acbacbacbacb'),(8159,5,4,'bcabcabcabca','acbacbacbacb'),(8160,5,4,'bcabcabcabca','acbacbacbacb'),(8161,5,4,'bcabcabcabca','acbacbacbacb'),(8162,5,4,'bcabcabcabca','acbacbacbacb'),(8163,5,4,'bcabcabcabca','acbacbacbacb'),(8164,5,4,'bcabcabcabca','acbacbacbacb'),(8165,5,4,'bcabcabcabca','acbacbacbacb'),(8166,5,4,'bcabcabcabca','acbacbacbacb'),(8167,5,4,'bcabcabcabca','acbacbacbacb'),(8168,5,4,'bcabcabcabca','acbacbacbacb'),(8169,5,4,'bcabcabcabca','acbacbacbacb'),(8170,5,4,'bcabcabcabca','acbacbacbacb'),(8171,5,4,'bcabcabcabca','acbacbacbacb'),(8172,5,4,'bcabcabcabca','acbacbacbacb'),(8173,5,4,'bcabcabcabca','acbacbacbacb'),(8174,5,4,'bcabcabcabca','acbacbacbacb'),(8175,5,4,'bcabcabcabca','acbacbacbacb'),(8176,5,4,'bcabcabcabca','acbacbacbacb'),(8177,5,4,'bcabcabcabca','acbacbacbacb'),(8178,5,4,'bcabcabcabca','acbacbacbacb'),(8179,5,4,'bcabcabcabca','acbacbacbacb'),(8180,5,4,'bcabcabcabca','acbacbacbacb'),(8181,5,4,'bcabcabcabca','acbacbacbacb'),(8182,5,4,'bcabcabcabca','acbacbacbacb'),(8183,6,4,'bcabcabcabca','acbacbacbacb'),(8184,6,4,'bcabcabcabca','acbacbacbacb'),(8185,6,4,'bcabcabcabca','acbacbacbacb'),(8186,6,4,'bcabcabcabca','acbacbacbacb'),(8187,6,4,'bcabcabcabca','acbacbacbacb'),(8188,6,4,'bcabcabcabca','acbacbacbacb'),(8189,6,4,'bcabcabcabca','acbacbacbacb'),(8190,6,4,'bcabcabcabca','acbacbacbacb'),(8191,6,4,'bcabcabcabca','acbacbacbacb'),(8192,6,4,'bcabcabcabca','acbacbacbacb'); +--enable_query_log + +explain select * from t2 where a < 5 limit 10; +select * from t2 where a < 5 limit 10; + +DROP TABLE t2; + diff --git a/mysql-test/suite/parallel_query/t/pq_order_const.test b/mysql-test/suite/parallel_query/t/pq_order_const.test new file mode 100644 index 000000000..0573886ad --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_order_const.test @@ -0,0 +1,80 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create table t1( + a int NOT NULL, + b varchar(50) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; + +insert into t1 values (2, 'mysql'), (1, NULL), (0, 'hwsql'); +select * from t1; + +# group-by-prue-const + +select 1 from t1 group by 1; +select 1+1 as summa from t1 group by summa; +select 1+1 as summa from t1 group by 1+2; +select 1 from t1 group by "HWSQL"; +select 1+1 from t1 group by "HWSQL"; +select 1, "HWSQL" from t1 group by 1; +select 1, "HWSQL" from t1 group by "HWSQL"; + +# group-by-hybrid-with-other-items + +select a from t1 group by 1; + +set sql_mode=''; +select 1, a from t1 group by 1; +select 1, a from t1 group by "HWSQL"; +select 1+1 as summa, a from t1 group by summa; +select 1+1 as summa, a from t1 group by 1+2; +select 1+1 as summa, a from t1 group by "HWSQL"; + + +# order-by-prue-const + +select 1 from t1 order by 1; +select 1+1 as summa from t1 order by summa; +select 1+1 as summa from t1 order by 1+2; +select 1 from t1 order by "HWSQL"; +select 1+1 from t1 order by "HWSQL"; +select 1, "HWSQL" from t1 order by 1; +select 1, "HWSQL" from t1 order by "HWSQL"; + +# order-by-hybrid-with-other-items + +select a from t1 order by 1; +select 1, a from t1 order by 1; +select 1, a from t1 order by "HWSQL"; +select 1+1 as summa, a from t1 order by summa; +select 1+1 as summa, a from t1 order by 1+2; +select 1+1 as summa, a from t1 order by "HWSQL"; + + +# group-order-by + +select sum(a) from t1 group by 1 + 2; +select 1, sum(a) from t1 group by 1; +select 1, sum(a) from t1 group by 1+2; +select 1+1, sum(a) from t1 group by a; + +select 1, sum(a) from t1 group by 1 order by 1; +select a, sum(a) from t1 group by a order by 1; +select avg(a) from t1 group by b order by 1; +select avg(a) from t1 group by b order by a; + + +# group/order by NULL +select 1, a from t1 group by NULL; +select 1, a from t1 group by a order by NULL; +select 1, a from t1 group by 1 + 1, NULL; +select 1, sum(a) from t1 group by 1 order by 1+1, NULL; +select 1, sum(a) from t1 group by 1+1, NULL order by 1; +select 1, sum(a) from t1 group by 1, NULL order by 1+1, 1, NULL; +select 1, sum(a) from t1 group by a, NULL order by 1, a, NULL; +select 1, sum(a) from t1 group by NULL, a, NULL order by 1, a, NULL, NULL, a; + +drop table t1; + +--let $wait_counter= 10000 +--source include/restart_mysqld.inc diff --git a/mysql-test/suite/parallel_query/t/pq_range_clust.test b/mysql-test/suite/parallel_query/t/pq_range_clust.test new file mode 100644 index 000000000..da021d41a --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_range_clust.test @@ -0,0 +1,62 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +create table t1( + id int primary key auto_increment, + col1 varchar(100), + col2 int, + key idx_col2(col2) + )engine= innodb; + +--disable_query_log + let $loop=1000; + while($loop) + { + eval insert into pq_test.t1(col1, col2) values(repeat('test', 4), $loop); + dec $loop; + } +--enable_query_log + +show variables like 'force_parallel_execute'; +select count(*) from pq_test.t1; + +select * from pq_test.t1 limit 1; +select * from pq_test.t1 order by id desc limit 1; + +--disable_result_log +select * from pq_test.t1 ignore index(idx_col2) where id < 300; +--enable_result_log + +--disable_result_log +select * from pq_test.t1 ignore index(idx_col2) where id <= 300; +--enable_result_log + +--disable_result_log +select id from pq_test.t1 ignore index(idx_col2) where id > 200; +--enable_result_log + +--disable_result_log +select * from pq_test.t1 ignore index(idx_col2) where id >= 200; +--enable_result_log + +--disable_result_log +select * from pq_test.t1 ignore index(idx_col2) where id > 100 and id < 800; +--enable_result_log + +--disable_result_log +select * from pq_test.t1 ignore index(idx_col2) where id >= 100 and id <= 800; +--enable_result_log + +--disable_result_log +select * from pq_test.t1 ignore index(idx_col2) where id < 300 or id > 500; +--enable_result_log + +--disable_result_log +select * from pq_test.t1 ignore index(idx_col2) where (id > 100 and id < 500) or (id > 600 and id < 900); +--enable_result_log + +drop table pq_test.t1; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_range_scan_reverse.test b/mysql-test/suite/parallel_query/t/pq_range_scan_reverse.test new file mode 100644 index 000000000..76c0361a3 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_range_scan_reverse.test @@ -0,0 +1,39 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +create table t1 (a int, key(a desc)); +insert into t1 values(1),(2),(3),(4),(5),(6),(7); + +ANALYZE TABLE t1; + +explain select a from t1; +select a from t1; + +explain select * from t1 where a < 4; +select * from t1 where a < 4; + +explain select * from t1 where a < 4 order by a; +select * from t1 where a < 4 order by a; + +explain select * from t1 where a < 4 order by a desc; +select * from t1 where a < 4 order by a desc; + +drop table pq_test.t1; + +create table t2(a int not null, b int , primary key(a), key(b)); +insert into t2 values (1,1),(2,2),(3,3),(4,4); + +explain select * from t2 where b < 3; +select * from t2 where b < 3; + +explain select * from t2 where b < 3 order by b; +select * from t2 where b < 3 order by b; + +explain select * from t2 where b < 3 order by b desc; +select * from t2 where b < 3 order by b desc; + +drop table pq_test.t2; +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_range_sec.test b/mysql-test/suite/parallel_query/t/pq_range_sec.test new file mode 100644 index 000000000..b44657047 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_range_sec.test @@ -0,0 +1,360 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +create table t1( + id int primary key auto_increment, + col1 varchar(100), + col2 int, + key idx_col2(col2) + )engine= innodb; + +--disable_query_log + let $loop=1000; + while($loop) + { + eval insert into pq_test.t1(col1, col2) values(repeat('test', 4), $loop); + dec $loop; + } +--enable_query_log + +show variables like 'force_parallel_execute'; +select count(*) from pq_test.t1; + +select * from pq_test.t1 limit 1; +select * from pq_test.t1 order by id desc limit 1; + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 300; +--enable_result_log + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where col2 <= 300; +--enable_result_log + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 200; +--enable_result_log + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 200; +--enable_result_log + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where col2 > 100 and col2 < 800; +--enable_result_log + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where col2 >= 100 and col2 <= 800; +--enable_result_log + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where col2 < 300 or col2 > 500; +--enable_result_log + +--disable_result_log +select id,col2 from pq_test.t1 force index(idx_col2) where (col2 > 100 and col2 < 500) or (col2 > 600 and col2 < 900); +--enable_result_log + +drop table pq_test.t1; + +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +create table t1 ( + id integer, + id2 integer not null, + index (id), + index (id2) +); +insert into t1 values(null,null),(1,1); +select * from t1 where id <=> null or id > 0; + +drop table t1; + +CREATE TABLE t1 AS +SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d; +ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b); + +INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5)); +INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); +INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); +INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); + +# Check pattern (important for ucs2, utf16, utf32) +SELECT hex(concat(repeat(0xF1F2, 10), '%')); + +--echo 3 rows expected +SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); + +drop table t1; + +CREATE TABLE t1 ( + v1 VARCHAR(20) CHARACTER SET utf8 NOT NULL, + pk INTEGER NOT NULL, + PRIMARY KEY (pk), + KEY v1_key (v1(10)) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES ('ABCDE',19), ('JLVGO',14); + +Let query1= SELECT * FROM t1 WHERE t1.v1 < CHAR(127); +Let query2= SELECT * FROM t1 WHERE t1.v1 = CHAR(127); +Let query3= SELECT * FROM t1 WHERE t1.v1 BETWEEN 'f' AND CHAR(127); + +eval EXPLAIN $query1; +eval EXPLAIN $query2; +eval EXPLAIN $query3; + +eval $query1; +eval $query2; +eval $query3; + +DROP TABLE t1; + +--disable_warnings +CREATE TABLE t2 ( + auto int not null auto_increment, + fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, + companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, + fld3 char(30) DEFAULT '' NOT NULL, + fld4 char(35) DEFAULT '' NOT NULL, + fld5 char(35) DEFAULT '' NOT NULL, + fld6 char(4) DEFAULT '' NOT NULL, + UNIQUE fld1 (fld1), + KEY fld3 (fld3), + PRIMARY KEY (auto) +) charset utf8mb4; +--enable_warnings + +# +# Populate table +# + +--disable_query_log +INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat',''); +INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W'); +INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring',''); +INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +INSERT INTO t2 VALUES (5,011501,37,'bewilderingly','wallet','balled',''); +INSERT INTO t2 VALUES (6,011701,37,'astound','parters','persist','W'); +INSERT INTO t2 VALUES (7,011702,37,'admonishing','eschew','attainments',''); +INSERT INTO t2 VALUES (8,011703,37,'sumac','quitter','fanatic',''); +INSERT INTO t2 VALUES (9,012001,37,'flanking','neat','measures','FAS'); +INSERT INTO t2 VALUES (10,012003,37,'combed','Steinberg','rightfulness',''); +INSERT INTO t2 VALUES (11,012004,37,'subjective','jarring','capably',''); +INSERT INTO t2 VALUES (12,012005,37,'scatterbrain','tinily','impulsive',''); +INSERT INTO t2 VALUES (13,012301,37,'Eulerian','balled','starlet',''); +INSERT INTO t2 VALUES (14,012302,36,'dubbed','persist','terminators',''); +INSERT INTO t2 VALUES (15,012303,37,'Kane','attainments','untying',''); +INSERT INTO t2 VALUES (16,012304,37,'overlay','fanatic','announces','FAS'); +INSERT INTO t2 VALUES (17,012305,37,'perturb','measures','featherweight','FAS'); +INSERT INTO t2 VALUES (18,012306,37,'goblins','rightfulness','pessimist','FAS'); +INSERT INTO t2 VALUES (19,012501,37,'annihilates','capably','daughter',''); +INSERT INTO t2 VALUES (20,012602,37,'Wotan','impulsive','decliner','FAS'); +INSERT INTO t2 VALUES (21,012603,37,'snatching','starlet','lawgiver',''); +INSERT INTO t2 VALUES (22,012604,37,'concludes','terminators','stated',''); +INSERT INTO t2 VALUES (23,012605,37,'laterally','untying','readable',''); +INSERT INTO t2 VALUES (24,012606,37,'yelped','announces','attrition',''); +INSERT INTO t2 VALUES (25,012701,37,'grazing','featherweight','cascade','FAS'); +INSERT INTO t2 VALUES (26,012702,37,'Baird','pessimist','motors','FAS'); +INSERT INTO t2 VALUES (27,012703,37,'celery','daughter','interrogate',''); +INSERT INTO t2 VALUES (28,012704,37,'misunderstander','decliner','pests','W'); +INSERT INTO t2 VALUES (29,013601,37,'handgun','lawgiver','stairway',''); +INSERT INTO t2 VALUES (30,013602,37,'foldout','stated','dopers','FAS'); +INSERT INTO t2 VALUES (31,013603,37,'mystic','readable','testicle','W'); +INSERT INTO t2 VALUES (32,013604,37,'succumbed','attrition','Parsifal','W'); +INSERT INTO t2 VALUES (33,013605,37,'Nabisco','cascade','leavings',''); +INSERT INTO t2 VALUES (34,013606,37,'fingerings','motors','postulation','W'); +INSERT INTO t2 VALUES (35,013607,37,'aging','interrogate','squeaking',''); +INSERT INTO t2 VALUES (36,013608,37,'afield','pests','contrasted',''); +INSERT INTO t2 VALUES (37,013609,37,'ammonium','stairway','leftover',''); +INSERT INTO t2 VALUES (38,013610,37,'boat','dopers','whiteners',''); +INSERT INTO t2 VALUES (39,013801,37,'intelligibility','testicle','erases','W'); +INSERT INTO t2 VALUES (40,013802,37,'Augustine','Parsifal','Punjab','W'); +INSERT INTO t2 VALUES (41,013803,37,'teethe','leavings','Merritt',''); +INSERT INTO t2 VALUES (42,013804,37,'dreaded','postulation','Quixotism',''); +INSERT INTO t2 VALUES (43,013901,37,'scholastics','squeaking','sweetish','FAS'); +INSERT INTO t2 VALUES (44,016001,37,'audiology','contrasted','dogging','FAS'); +INSERT INTO t2 VALUES (45,016201,37,'wallet','leftover','scornfully','FAS'); +INSERT INTO t2 VALUES (46,016202,37,'parters','whiteners','bellow',''); +INSERT INTO t2 VALUES (47,016301,37,'eschew','erases','bills',''); +INSERT INTO t2 VALUES (48,016302,37,'quitter','Punjab','cupboard','FAS'); +INSERT INTO t2 VALUES (49,016303,37,'neat','Merritt','sureties','FAS'); +INSERT INTO t2 VALUES (50,016304,37,'Steinberg','Quixotism','puddings',''); +INSERT INTO t2 VALUES (51,018001,37,'jarring','sweetish','tapestry',''); +INSERT INTO t2 VALUES (52,018002,37,'tinily','dogging','fetters',''); +INSERT INTO t2 VALUES (53,018003,37,'balled','scornfully','bivalves',''); +INSERT INTO t2 VALUES (54,018004,37,'persist','bellow','incurring',''); +INSERT INTO t2 VALUES (55,018005,37,'attainments','bills','Adolph',''); +INSERT INTO t2 VALUES (56,018007,37,'fanatic','cupboard','pithed',''); +INSERT INTO t2 VALUES (57,018008,37,'measures','sureties','emergency',''); +INSERT INTO t2 VALUES (58,018009,37,'rightfulness','puddings','Miles',''); +INSERT INTO t2 VALUES (59,018010,37,'capably','tapestry','trimmings',''); +INSERT INTO t2 VALUES (60,018012,37,'impulsive','fetters','tragedies','W'); + +# +# Search with a key +# + +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +select fld3 from t2 where fld3 like "%cultivation" ; + +# +# Search with a key using sorting and limit the same time +# + +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +select fld3,companynr from t2 where companynr = 58 order by fld3; + +select fld3 from t2 order by fld3 desc limit 10; +select fld3 from t2 order by fld3 desc limit 5; +select fld3 from t2 order by fld3 desc limit 5,5; + +# +# Search with a key having a constant with each unique key. +# The table is read directly with read-next on fld3 +# + +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +select t2.fld3 from t2 where fld3 LIKE 'h%le'; + +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; + +drop table t2; + +create table t1(a int) charset utf8mb4; +show create table t1; +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C; + +create table t3 ( + a char(8) not null, b char(8) not null, filler char(200), + key(a) +); +insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), + 'filler-1' from t2 A; +insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), + 'filler-2' from t2 A; + +# Test empty result set +select a,filler from t3 where a >= 'c-9011=w'; + +# Ok, t3.ref_length=6, limit is 64 => 10 elements fit into the buffer +# Test the cases when buffer gets exhausted at different points in source +# intervals: + +# 1. Split is in the middle of the range +--sorted_result +select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; + +# 2. Split is at range edge +--sorted_result +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or + (a>='c-1014=w' and a <= 'c-1015=w'); + +# 3. Split is at range edge, with some rows between ranges. +insert into t3 values ('c-1013=z', 'c-1013=z', 'err'); +insert into t3 values ('a-1014=w', 'a-1014=w', 'err'); + +--sorted_result +select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or + (a>='c-1014=w' and a <= 'c-1015=w'); +delete from t3 where b in ('c-1013=z', 'a-1014=w'); + +# 4. Split is within the equality range. +--sorted_result +select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or + a='c-1014=w' or a='c-1015=w'; +drop table t1; +drop table t2; +drop table t3; + +--disable_warnings +CREATE TABLE t1 +( + pk_1 INT, + pk_2 INT, + f1 DATETIME, + f2 INT, + PRIMARY KEY(pk_1, pk_2), + KEY k1(f1), + KEY k2(f2) +) ENGINE = InnoDB; +--enable_warnings + + +--disable_query_log +INSERT INTO t1 VALUES +(1, 1, '2000-01-01', 1), (1, 2, '2000-01-02', 2), (1, 3, '2000-01-03', 3), (1, 4, '2000-01-04', 4), (1, 5, '2000-01-05', 5), +(2, 1, '2000-01-01', 6), (2, 2, '2000-01-02', 7), (2, 3, '2000-01-03', 8), (2, 4, '2000-01-04', 9), (2, 5, '2000-01-05', 10), +(3, 1, '2000-01-01', 11), (3, 2, '2000-01-02', 12), (3, 3, '2000-01-03', 13), (3, 4, '2000-01-04', 14), (3, 5, '2000-01-05', 15), +(4, 1, '2000-01-01', 16), (4, 2, '2000-01-02', 17), (4, 3, '2000-01-03', 18), (4, 4, '2000-01-04', 19), (4, 5, '2000-01-05', 20), +(5, 1, '2000-01-01', 21), (5, 2, '2000-01-02', 22), (5, 3, '2000-01-03', 23), (5, 4, '2000-01-04', 24), (5, 5, '2000-01-05', 25), +(6, 1, '2000-01-06', 26), (6, 2, '2000-01-06', 27), (6, 3, '2000-01-03', 28), (6, 4, '2000-01-06', 29), (6, 5, '2000-01-06', 30), +(7, 1, '2000-01-06', 31), (7, 2, '2000-01-06', 32), (7, 3, '2000-01-03', 33), (7, 4, '2000-01-06', 34), (7, 5, '2000-01-06', 35), +(8, 1, '2000-01-06', 36), (8, 2, '2000-01-06', 37), (8, 3, '2000-01-03', 38), (8, 4, '2000-01-06', 39), (8, 5, '2000-01-06', 40), +(9, 1, '2000-01-06', 41), (9, 2, '2000-01-06', 42), (9, 3, '2000-01-03', 43), (9, 4, '2000-01-06', 44), (9, 5, '2000-01-06', 45); + +INSERT INTO t1 VALUES +(11, 1, '2000-01-01', 1), (11, 2, '2000-01-02', 2), (11, 3, '2000-01-03', 3), (11, 4, '2000-01-04', 4), (11, 5, '2000-01-05', 5), +(12, 1, '2000-01-01', 6), (12, 2, '2000-01-02', 7), (12, 3, '2000-01-03', 8), (12, 4, '2000-01-04', 9), (12, 5, '2000-01-05', 10), +(13, 1, '2000-01-01', 11), (13, 2, '2000-01-02', 12), (13, 3, '2000-01-03', 13), (13, 4, '2000-01-04', 14), (13, 5, '2000-01-05', 15), +(14, 1, '2000-01-01', 16), (14, 2, '2000-01-02', 17), (14, 3, '2000-01-03', 18), (14, 4, '2000-01-04', 19), (14, 5, '2000-01-05', 20), +(15, 1, '2000-01-01', 1), (15, 2, '2000-01-02', 2), (15, 3, '2000-01-03', 3), (15, 4, '2000-01-04', 4), (15, 5, '2000-01-05', 5), +(16, 1, '2000-01-06', 6), (16, 2, '2000-01-06', 7), (16, 3, '2000-01-03', 8), (16, 4, '2000-01-06', 9), (16, 5, '2000-01-06', 10), +(17, 1, '2000-01-06', 31), (17, 2, '2000-01-06', 32), (17, 3, '2000-01-03', 33), (17, 4, '2000-01-06', 34), (17, 5, '2000-01-06', 35), +(18, 1, '2000-01-06', 36), (18, 2, '2000-01-06', 37), (18, 3, '2000-01-03', 38), (18, 4, '2000-01-06', 39), (18, 5, '2000-01-06', 40), +(19, 1, '2000-01-06', 1), (19, 2, '2000-01-06', 2), (19, 3, '2000-01-03', 3), (19, 4, '2000-01-06', 4), (19, 5, '2000-01-06', 5); + + +INSERT INTO t1 VALUES +(21, 1, '2000-01-01', 1), (21, 2, '2000-01-02', 2), (31, 3, '2000-01-03', 3), (41, 4, '2000-01-04', 4), (51, 5, '2000-01-05', 5), +(22, 1, '2000-01-01', 6), (22, 2, '2000-01-02', 7), (32, 3, '2000-01-03', 8), (42, 4, '2000-01-04', 9), (52, 5, '2000-01-05', 10), +(23, 1, '2000-01-01', 11), (23, 2, '2000-01-02', 12), (33, 3, '2000-01-03', 13), (43, 4, '2000-01-04', 14), (53, 5, '2000-01-05', 15), +(24, 1, '2000-01-01', 16), (24, 2, '2000-01-02', 17), (34, 3, '2000-01-03', 18), (44, 4, '2000-01-04', 19), (54, 5, '2000-01-05', 20), +(25, 1, '2000-01-01', 1), (25, 2, '2000-01-02', 2), (35, 3, '2000-01-03', 3), (45, 4, '2000-01-04', 4), (55, 5, '2000-01-05', 5), +(26, 1, '2000-01-06', 6), (26, 2, '2000-01-06', 7), (36, 3, '2000-01-03', 8), (46, 4, '2000-01-06', 9), (56, 5, '2000-01-06', 10), +(27, 1, '2000-01-06', 31), (27, 2, '2000-01-06', 32), (37, 3, '2000-01-03', 33), (47, 4, '2000-01-06', 34), (57, 5, '2000-01-06', 35), +(28, 1, '2000-01-06', 36), (28, 2, '2000-01-06', 37), (38, 3, '2000-01-03', 38), (48, 4, '2000-01-06', 39), (58, 5, '2000-01-06', 40), +(29, 1, '2000-01-06', 1), (29, 2, '2000-01-06', 2), (39, 3, '2000-01-03', 3), (49, 4, '2000-01-06', 4), (59, 5, '2000-01-06', 5); + +INSERT INTO t1 SELECT pk_1 + 60, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 120, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1 + 240, pk_2, f1, f2 FROM t1; +INSERT INTO t1 SELECT pk_1, pk_2 + 10, f1, f2 FROM t1; +--enable_query_log + +ANALYZE TABLE t1; + +--echo # +--echo # REF access optimization +--echo # + +--replace_column 10 # +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; + +--replace_column 10 # +EXPLAIN SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; +FLUSH STATUS; +SELECT pk_2 FROM t1 WHERE pk_1 = 3 and f1 = '2000-01-03'; + +--echo # +--echo # RANGE access optimization +--echo # + +--replace_column 10 # +EXPLAIN SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +FLUSH STATUS; +SELECT count(*) FROM t1 WHERE pk_1 BETWEEN 3 AND 5 AND f1 = '2000-01-03'; +drop table t1; + +drop database pq_test; diff --git a/mysql-test/suite/parallel_query/t/pq_rec_visible.test b/mysql-test/suite/parallel_query/t/pq_rec_visible.test new file mode 100644 index 000000000..b93d4c3b4 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_rec_visible.test @@ -0,0 +1,34 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +CREATE TABLE t1 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, +c3 INT, +c4 INT, +INDEX k2(c2) +) Engine=InnoDB; +INSERT INTO t1(c2,c3,c4) VALUES (1, 1, 1); +INSERT INTO t1(c2,c3,c4) VALUES (2, 2, 2); +INSERT INTO t1(c2,c3,c4) VALUES (3, 3, 3); +INSERT INTO t1(c2,c3,c4) VALUES (4, 4, 4); +INSERT INTO t1(c2,c3,c4) VALUES (5, 5, 5); +INSERT INTO t1(c2,c3,c4) VALUES (6, 6, 6); +INSERT INTO t1(c2,c3,c4) VALUES (7, 7, 7); +INSERT INTO t1(c2,c3,c4) VALUES (8, 8, 8); +INSERT INTO t1(c2,c3,c4) VALUES (9, 9, 9); +INSERT INTO t1(c2,c3,c4) VALUES (10, 10, 10); + +BEGIN; +UPDATE t1 SET c2 = c2 * 3 WHERE c1 = 1; +DELETE FROM t1 WHERE c1 = 6; +SELECT COUNT(c2) FROM t1; + +connect (con1,localhost,root,,); +BEGIN; +SELECT COUNT(c2) FROM t1; +COMMIT; + +connection default; +COMMIT; +DROP TABLE t1; diff --git a/mysql-test/suite/parallel_query/t/pq_ref_reverse_scan.test b/mysql-test/suite/parallel_query/t/pq_ref_reverse_scan.test new file mode 100644 index 000000000..a04428550 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_ref_reverse_scan.test @@ -0,0 +1,26 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +CREATE TABLE t1 ( +pk INT NOT NULL AUTO_INCREMENT, +c1_idx CHAR(1) DEFAULT 'y', +c2 INT, +PRIMARY KEY (pk), +INDEX c1_idx (c1_idx) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (), (), (), (); + +ANALYZE TABLE t1; + +explain select * from t1 where c1_idx = 'y' order by pk desc; +select * from t1 where c1_idx = 'y' order by pk desc; + + + +drop table pq_test.t1; +drop database pq_test; + diff --git a/mysql-test/suite/parallel_query/t/pq_restart_after_select.test b/mysql-test/suite/parallel_query/t/pq_restart_after_select.test new file mode 100644 index 000000000..a3e6d78d7 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_restart_after_select.test @@ -0,0 +1,14 @@ +# +# Describe: +# Previously, encountered various cores after restarting the database +# after parallel queries because some resources were not released. +# The purpose of this test case is to guard this scenario. +# + +create table t(id int); +insert into t values(1),(2),(3),(4),(5); +select * from t; +drop table t; + +--let $wait_counter= 10000 +--source include/restart_mysqld.inc diff --git a/mysql-test/suite/parallel_query/t/pq_reverse_index_scan.test b/mysql-test/suite/parallel_query/t/pq_reverse_index_scan.test new file mode 100644 index 000000000..b9f8484ed --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_reverse_index_scan.test @@ -0,0 +1,23 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +create database pq_test; +use pq_test; + +create table t1 (a int, key(a desc)); +insert into t1 values(1),(2),(3),(4),(5),(6),(7); + +ANALYZE TABLE t1; + +explain select a from t1; +select a from t1; + +explain select a from t1 order by a; +select a from t1 order by a; + +explain select a from t1 order by a desc; +select a from t1 order by a desc; + +drop table pq_test.t1; +drop database pq_test; + diff --git a/mysql-test/suite/parallel_query/t/pq_sec_index_min.test b/mysql-test/suite/parallel_query/t/pq_sec_index_min.test new file mode 100644 index 000000000..567646939 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_sec_index_min.test @@ -0,0 +1,19 @@ +--source include/pq_test.inc + +CREATE TABLE t1 (i INT, j INT, INDEX (i), INDEX (j)); +INSERT INTO t1 (i,j) VALUES (1,1); +SELECT * FROM t1 WHERE i<3; + +SET force_parallel_execute=0; +SELECT * FROM t1 WHERE i<3; +DROP TABLE t1; + +CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, i INT, j INT, INDEX (i), INDEX (j)); +INSERT INTO t1 (i,j) VALUES (1,1); +SELECT * FROM t1 WHERE i<3 and j < 4; +DROP TABLE t1; + +CREATE TABLE t1 (i INT, j INT, PRIMARY KEY (i), INDEX (j)); +INSERT INTO t1 (i,j) VALUES (1,1); +SELECT * FROM t1 WHERE j<3; +DROP TABLE t1; diff --git a/mysql-test/suite/parallel_query/t/pq_sp_trigger.test b/mysql-test/suite/parallel_query/t/pq_sp_trigger.test new file mode 100644 index 000000000..4377471fc --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_sp_trigger.test @@ -0,0 +1,238 @@ +--source include/pq_test.inc + +# +# BUG#4579 +# + +delimiter |; + +create table t3 (f1 int, f2 int)| +insert into t3 values (1,1)| + +--disable_warnings ER_SP_DOES_NOT_EXIST ONCE +drop procedure if exists bug4579_1| +create procedure bug4579_1 () +begin + declare sf1 int; + + select f1 into sf1 from t3 where f1=1 and f2=1; + update t3 set f2 = f2 + 1 where f1=1 and f2=1; + call bug4579_2(); +end| + +--disable_warnings ER_SP_DOES_NOT_EXIST ONCE +drop procedure if exists bug4579_2| +create procedure bug4579_2 () +begin +end| + +call bug4579_1()| +call bug4579_1()| +call bug4579_1()| + +drop procedure bug4579_1| +drop procedure bug4579_2| +drop table t3| + +# +# Bug#20028 Function with select return no data +# + +--disable_warnings +drop function if exists func_20028_a| +drop function if exists func_20028_b| +drop function if exists func_20028_c| +drop procedure if exists proc_20028_a| +drop procedure if exists proc_20028_b| +drop procedure if exists proc_20028_c| +drop table if exists table_20028| +--enable_warnings + +create table table_20028 (i int)| + +SET @save_sql_mode=@@sql_mode| + +SET sql_mode=''| + +create function func_20028_a() returns integer +begin + declare temp integer; + select i into temp from table_20028 limit 1; + return ifnull(temp, 0); +end| + +create function func_20028_b() returns integer +begin + return func_20028_a(); +end| + +create function func_20028_c() returns integer +begin + declare div_zero integer; + set SQL_MODE='TRADITIONAL'; + select 1/0 into div_zero; + return div_zero; +end| + +create procedure proc_20028_a() +begin + declare temp integer; + select i into temp from table_20028 limit 1; +end| + +create procedure proc_20028_b() +begin + call proc_20028_a(); +end| + +create procedure proc_20028_c() +begin + declare div_zero integer; + set SQL_MODE='TRADITIONAL'; + select 1/0 into div_zero; +end| + +select func_20028_a()| +select func_20028_b()| +--error ER_DIVISION_BY_ZERO +select func_20028_c()| +call proc_20028_a()| +call proc_20028_b()| +--error ER_DIVISION_BY_ZERO +call proc_20028_c()| + +SET sql_mode='TRADITIONAL'| + +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| + +create function func_20028_a() returns integer +begin + declare temp integer; + select i into temp from table_20028 limit 1; + return ifnull(temp, 0); +end| + +create function func_20028_b() returns integer +begin + return func_20028_a(); +end| + +create function func_20028_c() returns integer +begin + declare div_zero integer; + set SQL_MODE=''; + select 1/0 into div_zero; + return div_zero; +end| + +create procedure proc_20028_a() +begin + declare temp integer; + select i into temp from table_20028 limit 1; +end| + +create procedure proc_20028_b() +begin + call proc_20028_a(); +end| + +create procedure proc_20028_c() +begin + declare div_zero integer; + set SQL_MODE=''; + select 1/0 into div_zero; +end| + +select func_20028_a()| +select func_20028_b()| +select func_20028_c()| +call proc_20028_a()| +call proc_20028_b()| +call proc_20028_c()| + +SET @@sql_mode=@save_sql_mode| + +drop function func_20028_a| +drop function func_20028_b| +drop function func_20028_c| +drop procedure proc_20028_a| +drop procedure proc_20028_b| +drop procedure proc_20028_c| +drop table table_20028| + +# Test for bug #6812 "Triggers are not activated for INSERT ... SELECT". +# (We also check the fact that trigger modifies some field does not affect +# value of next record inserted). + +create table t1 (i int, j int default 10)| +create table t2 (i int)| +insert into t2 values (1), (2)| +create trigger trg1 before insert on t1 for each row +begin + if new.i = 1 then + set new.j := 1; + end if; +end| +create trigger trg2 after insert on t1 for each row set @a:= 1| +set @a:= 0| +insert into t1 (i) select * from t2| +select * from t1| +select @a| +drop table t1, t2| + +delimiter ;| + +# Test for bug #17764 "Trigger crashes table" +# +# Table was reported as crashed when it was subject table of trigger invoked +# by insert statement which was executed with enabled bulk insert mode (which +# is actually set of optimizations enabled by handler::start_bulk_insert()) +# and this trigger also explicitly referenced it. +# The same problem arose when table to which bulk insert was done was also +# referenced in function called by insert statement. +create table t1 (a varchar(64), b int); +create table t2 like t1; +create trigger t1_ai after insert on t1 for each row + set @a:= (select max(a) from t1); +insert into t1 (a) values + ("Twas"),("brillig"),("and"),("the"),("slithy"),("toves"), + ("Did"),("gyre"),("and"),("gimble"),("in"),("the"),("wabe"); +create trigger t2_ai after insert on t2 for each row + set @a:= (select max(a) from t2); +insert into t2 select * from t1; +load data infile '../../std_data/words.dat' into table t1 (a); +drop trigger t1_ai; +drop trigger t2_ai; +drop table t1,t2; +# + +# Test for bug that the statement "delete t from t" goes through the parallel query process, +# causing non-execution. + +# prepare +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; +create trigger trg_del_t2 after delete on t2 for each row + insert into t1 values (1); +insert into t1 values (1); +insert into t2 values (1),(2); + + +# exec cases A, B - see multi_update.test + +# A. send_error() w/o send_eof() branch + +--error ER_DUP_ENTRY +delete t2 from t2; + +# cleanup +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/parallel_query/t/pq_sql_cond.test b/mysql-test/suite/parallel_query/t/pq_sql_cond.test new file mode 100644 index 000000000..108b82048 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_sql_cond.test @@ -0,0 +1,10 @@ +--source include/pq_test.inc + +CREATE TABLE t1 (a enum ('aac','aab','aaa') not null); +INSERT INTO t1 VALUES ('aaa'),('aab'),('aac'); + +explain SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; + +SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a; + +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_stable_output.test b/mysql-test/suite/parallel_query/t/pq_stable_output.test new file mode 100644 index 000000000..ce71bba33 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_stable_output.test @@ -0,0 +1,428 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +# +# Tests with the euckr character set +# +--disable_warnings +drop table if exists t1; +--enable_warnings + +SET @test_character_set= 'euckr'; +SET @test_collation= 'euckr_korean_ci'; +-- source include/ctype_common.inc + +--echo # +--echo # WL#3332 Korean Enhancements +--echo # euckr valid codes are now [81..FE][41..5A,61..7A,81..FE] +--echo # +SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; +CREATE TABLE t1 (a binary(1), key(a)); + +--disable_query_log +let $1=255; +while($1) +{ + eval INSERT INTO t1 VALUES (unhex(hex($1))); + dec $1; +} +--enable_query_log + +CREATE TABLE t2 (s VARCHAR(4), a VARCHAR(1) CHARACTER SET euckr); +--disable_warnings +INSERT INTO t2 +SELECT hex(concat(t11.a, t12.a)), concat(t11.a, t12.a) +FROM t1 t11, t1 t12 +WHERE t11.a >= 0x81 AND t11.a <= 0xFE +AND t12.a >= 0x41 AND t12.a <= 0xFE +ORDER BY t11.a, t12.a; +--enable_warnings +SELECT s as bad_code FROM t2 WHERE a='' ORDER BY s; +DELETE FROM t2 WHERE a=''; +ALTER TABLE t2 ADD u VARCHAR(1) CHARACTER SET utf8, ADD a2 VARCHAR(1) CHARACTER SET euckr; +--disable_warnings +UPDATE t2 SET u=a, a2=u; +--enable_warnings +SELECT s as unassigned_code FROM t2 WHERE u='?'; +DELETE FROM t2 WHERE u='?'; +# Make sure there are no euckr->utf8->euckr roundtrip problems +SELECT count(*) as roundtrip_problem_chars FROM t2 WHERE hex(a) <> hex(a2); +SELECT s, hex(a), hex(u), hex(a2) FROM t2 ORDER BY s; +DROP TABLE t1, t2; +SET sql_mode = default; +--echo End of 5.4 tests + +## TABLE SCAN + +CREATE TABLE t1 (a int, b int); + +--disable_query_log +let $1 = 128; +let $2 = 64; +while($1) +{ + while($2) + { + eval INSERT INTO t1 VALUES (MOD($1, 31), $2); + dec $2; + } + dec $1; +} +--enable_query_log + +select * from t1; + +## test limit + +select * from t1 limit 1; +select * from t1 limit 10; +select * from t1 limit 100; +select b, a from t1 limit 50; + +select * from t1 limit 100, 10; +select * from t1 limit 500, 10; +select * from t1 limit 3000, 50; + +select b, a from t1 limit 2000, 50; +select b, a from t1 limit 4000, 50; + +drop table t1; + + +## ORDER BY + +CREATE TABLE t1 (a int, b int, c int); + +let $1 = 64; +let $2 = 32; +let $3 = 16; + +--disable_query_log + +while($1) +{ + while($2) + { + while($3) + { + eval INSERT INTO t1 VALUES (MOD($1, 31), MOD($2, 13), $3); + dec $3; + } + dec $2; + } + dec $1; +} + +--enable_query_log + +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t1 ORDER BY b, a; +SELECT * FROM t1 ORDER BY a, c; +SELECT * FROM t1 ORDER BY a desc, b asc; +SELECT * FROM t1 ORDER BY b desc, c asc, a desc; +SELECT * FROM t1 ORDER BY c asc, a desc; +SELECT * FROM t1 ORDER BY NULL, a desc, b; + +## with limit + +SELECT * FROM t1 ORDER BY a limit 10; +SELECT * FROM t1 ORDER BY a desc, b asc limit 50; +SELECT * FROM t1 ORDER BY NULL, a desc, b asc limit 50; +SELECT * FROM t1 ORDER BY NULL, a desc, b asc, NULL limit 50; + +drop table t1; + +## optimized-order-by + +## PRIMARY KEY + +--disable_warnings + +CREATE TABLE t2 ( + id int(6) NOT NULL auto_increment, + description varchar(40) NOT NULL, + idform varchar(40), + ordre int(6) unsigned DEFAULT '0' NOT NULL, + image varchar(60), + PRIMARY KEY (id), + KEY id (id, ordre) +); + +--enable_warnings + +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre un appel d offres','en_construction.html',10,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre des soumissions','en_construction.html',20,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Liste des t2','t2_liste_form.phtml',51060,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Consulter les soumissions','consulter_soumissions.phtml',200,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Modifier des clients','en_construction.html',40010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Effacer des clients','en_construction.html',40020,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Effacer des clients','en_construction.html',40020,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre un appel d offres','en_construction.html',10,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Emettre des soumissions','en_construction.html',20,'emettre.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Liste des t2','t2_liste_form.phtml',51060,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Modifier des clients','en_construction.html',40010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) VALUES ('Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif'); +INSERT INTO t2 (description, idform, ordre, image) SELECT description, idform, ordre, image FROM t2; + +SELECT * FROM t2 ORDER BY id; +SELECT * FROM t2 ORDER BY id, ordre; +SELECT * FROM t2 ORDER BY id, ordre desc; +SELECT description, idform FROM t2 ORDER BY id desc; + +SELECT * FROM t2 ORDER BY id limit 15; +SELECT * FROM t2 ORDER BY id, ordre limit 15; +SELECT * FROM t2 ORDER BY id, ordre desc limit 15; + +DROP TABLE t2; + +CREATE TABLE t1( + f0 int auto_increment PRIMARY KEY, + f1 int, + f2 varchar(200) +) charset latin1; + +--disable_query_log +let $1=1024; +while($1) +{ + eval INSERT INTO t1 (f1, f2) VALUES (MOD($1, 511), CONCAT(MOD($1, 119), ' 0')); + dec $1; +} +--enable_query_log + +SELECT * FROM t1 ORDER BY f0; +SELECT * FROM t1 ORDER BY f0 desc; + +SELECT * FROM t1 ORDER BY f0, f1 limit 100, 20; +SELECT * FROM t1 ORDER BY f0, f1 desc limit 100, 25; + +DROP TABLE t1; +## UNIQUE_KEY && KEY + +CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, + UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)) charset utf8mb4; + +--disable_query_log + +INSERT INTO t2 (a, b, c, d) VALUES +('domestic', 26, 0.25, 4.7), ('domestic', 27, 0.25, 6), +('domestic', 19, 2, 6.3), ('domestic', 19, 5, 7.77), +('domestic', 19, 10, 10.3), ('domestic', 19, 20, 14.83), +('domestic', 19, 30, 20.88), ('domestic', 20, 2, 7.3), +('domestic', 20, 5, 8.77), ('domestic', 20, 10, 11.3), +('domestic', 20, 20, 15.83), ('domestic', 20, 30, 21.88), +('domestic', 23, 2, 18.8), ('domestic', 23, 5, 20.8), +('domestic', 23, 10, 24.8), ('domestic', 23, 20, 27.8), +('domestic', 23, 30, 30.8), ('domestic', 24, 2, 21.1405), +('domestic', 24, 5, 22.3705), ('domestic', 24, 10, 25.0905), +('domestic', 24, 20, 29.7705), ('domestic', 24, 30, 35.9605), +('domestic', 17, 2, 7.2), ('domestic', 17, 5, 8.43), +('domestic', 17, 10, 11.15), ('domestic', 17, 20, 15.83), +('domestic', 17, 30, 22.02), ('domestic', 18, 2, 8.2), +('domestic', 18, 5, 9.43), ('domestic', 18, 10, 12.15), +('domestic', 18, 20, 16.83), ('domestic', 18, 30, 23.02), +('domestic', 28, 2, 17), ('domestic', 28, 5, 19), +('domestic', 28, 10, 22), ('domestic', 28, 20, 28), +('domestic', 28, 30, 35), ('domestic', 29, 30, 29.5), +('foreign', 25, 200, 0), ('domestic', 3, 100, 59), +('foreign', 10, 30, 0), ('foreign', 22, 0, 0), +('foreign', 11, 30, 0), ('foreign', 12, 30, 0), +('all', 1, 10000, 0), ('all', 2, 10000, 0), +('domestic', 9, 10000, 0), ('domestic', 4, 500, 0), +('domestic', 5, 500, 0), ('domestic', 6, 500, 0), +('domestic', 7, 500, 0), ('domestic', 8, 500, 0), +('domestic', 21, 3.9, 10.8), ('domestic', 21, 4.9, 12.2), +('domestic', 21, 9.9, 15.3), ('domestic', 21, 19.9, 20.6), +('domestic', 21, 30, 28.1), ('plfcz1', 16, 0.5, 19), +('plfcz2', 16, 0.5, 25), ( 'ppfcz2', 15, 16, 76.5), +( 'ppfcz2', 15, 15, 75.5), ( 'ppfcz2', 15, 14, 73.5), +( 'ppfcz2', 15, 13, 71.5), ( 'ppfcz2', 15, 12, 69.5), +( 'ppfcz2', 15, 11, 67.5), ( 'ppfcz2', 15, 10, 65.5), +( 'ppfcz2', 15, 9, 62.5), ( 'ppfcz2', 15, 8, 59.5), +( 'ppfcz2', 15, 7, 56.5), ( 'ppfcz2', 15, 6, 53.5), +( 'ppfcz2', 15, 5, 50.5), ( 'ppfcz2', 15, 4, 46.5), +( 'ppfcz2', 15, 3, 42.5), ( 'ppfcz2', 15, 2, 38.5), +('ppfcz1', 15, 2, 33.5), ('ppfcz1', 15, 3, 36.5), +('ppfcz1', 15, 4, 39.5), ('ppfcz1', 15, 5, 41.5), +('ppfcz1', 15, 6, 42.5), ('ppfcz1', 15, 7, 43.5), +('ppfcz1', 15, 8, 44.5), ('ppfcz1', 15, 9, 45.5), +('ppfcz1', 15, 10, 46.5), ('ppfcz1', 15, 11, 47.5), +( 'ppfcz1', 15, 12, 48.5), ( 'ppfcz1', 15, 13, 49.5), ( 'ppfcz1', 15, 14, 50.5), +( 'ppfcz1', 15, 15, 51.5), ( 'ppfcz1', 15, 16, 52.5), ( 'ppfcz1', 15, 17, 53.5), +( 'ppfcz1', 15, 18, 54.5), ( 'ppfcz1', 15, 19, 55.5), ( 'ppfcz1', 15, 20, 56.5), +( 'ppfcz1', 15, 21, 57.5), ( 'ppfcz1', 15, 22, 58.5), ( 'ppfcz1', 15, 23, 59.5), +( 'ppfcz1', 15, 24, 60.5), ( 'ppfcz1', 15, 25, 61.5), ( 'ppfcz1', 15, 26, 62.5), +( 'ppfcz1', 15, 27, 63.5), ( 'ppfcz1', 15, 28, 64.5), ( 'ppfcz1', 15, 29, 65.5), +( 'ppfcz1', 15, 30, 66.5), ( 'ppfcz2', 15, 17, 77.5), ( 'ppfcz2', 15, 18, 78.5), +( 'ppfcz2', 15, 19, 79.5), ( 'ppfcz2', 15, 20, 80.5), ( 'ppfcz2', 15, 21, 81.5), +( 'ppfcz2', 15, 22, 82.5), ( 'ppfcz2', 15, 23, 83.5), ( 'ppfcz2', 15, 24, 84.5), +( 'ppfcz2', 15, 25, 85.5), ( 'ppfcz2', 15, 26, 86.5), ( 'ppfcz2', 15, 27, 87.5), +( 'ppfcz2', 15, 28, 88.5), ( 'ppfcz2', 15, 29, 89.5), ( 'ppfcz2', 15, 30, 90.5), +( 'ppfcz3', 15, 2, 39.5), ( 'ppfcz3', 15, 3, 45.5), ( 'ppfcz3', 15, 4, 51.5), +( 'ppfcz3', 15, 5, 57.5), ( 'ppfcz3', 15, 6, 63.5), ( 'ppfcz3', 15, 7, 69.5), +( 'ppfcz3', 15, 8, 75.5), ( 'ppfcz3', 15, 9, 81.5), ( 'ppfcz3', 15, 10, 87.5), +( 'ppfcz3', 15, 11, 93.5), ( 'ppfcz3', 15, 12, 99.5), ( 'ppfcz3', 15, 13, 105.5), +( 'ppfcz3', 15, 14, 111.5), ( 'ppfcz3', 15, 15, 117.5), ( 'ppfcz3', 15, 16, 122.5), +( 'ppfcz3', 15, 17, 127.5), ( 'ppfcz3', 15, 18, 132.5), ( 'ppfcz3', 15, 19, 137.5), +( 'ppfcz3', 15, 20, 142.5), ( 'ppfcz3', 15, 21, 146.5), ( 'ppfcz3', 15, 22, 150.5), +( 'ppfcz3', 15, 23, 154.5), ( 'ppfcz3', 15, 24, 158.5), ( 'ppfcz3', 15, 25, 162.5), +( 'ppfcz3', 15, 26, 166.5), ( 'ppfcz3', 15, 27, 170.5), ( 'ppfcz3', 15, 28, 174.5), +( 'ppfcz3', 15, 29, 178.5), ( 'ppfcz3', 15, 30, 182.5), ( 'ppfcz4', 15, 2, 44.5), +( 'ppfcz4', 15, 3, 51.5), ( 'ppfcz4', 15, 4, 58.5), ( 'ppfcz4', 15, 5, 65.5), +( 'ppfcz4', 15, 6, 72.5), ( 'ppfcz4', 15, 7, 79.5), ( 'ppfcz4', 15, 8, 86.5), +( 'ppfcz4', 15, 9, 93.5), ( 'ppfcz4', 15, 10, 100.5), ( 'ppfcz4', 15, 11, 105.5), +( 'ppfcz4', 15, 12, 110.5), ( 'ppfcz4', 15, 13, 115.5), ( 'ppfcz4', 15, 14, 120.5), +( 'ppfcz4', 15, 15, 125.5), ( 'ppfcz4', 15, 16, 130.5), ( 'ppfcz4', 15, 17, 135.5), +( 'ppfcz4', 15, 18, 140.5), ( 'ppfcz4', 15, 19, 145.5), ( 'ppfcz4', 15, 20, 150.5), +( 'ppfcz4', 15, 21, 154.5), ( 'ppfcz4', 15, 22, 158.5), ( 'ppfcz4', 15, 23, 162.5), +( 'ppfcz4', 15, 24, 166.5), ( 'ppfcz4', 15, 25, 170.5), ( 'ppfcz4', 15, 26, 174.5), +( 'ppfcz4', 15, 27, 178.5), ( 'ppfcz4', 15, 28, 182.5), ( 'ppfcz4', 15, 29, 186.5), +( 'ppfcz4', 15, 30, 190.5), ( 'ppfcz5', 15, 2, 48.5), ( 'ppfcz5', 15, 3, 56.5), +( 'ppfcz5', 15, 4, 64.5), ( 'ppfcz5', 15, 5, 72.5), ( 'ppfcz5', 15, 6, 80.5), +( 'ppfcz5', 15, 7, 88.5), ( 'ppfcz5', 15, 8, 96.5), ( 'ppfcz5', 15, 9, 104.5), +( 'ppfcz5', 15, 10, 112.5), ( 'ppfcz5', 15, 11, 119.5), ( 'ppfcz5', 15, 12, 126.5), +( 'ppfcz5', 15, 13, 133.5), ( 'ppfcz5', 15, 14, 140.5), ( 'ppfcz5', 15, 15, 147.5), +( 'ppfcz5', 15, 16, 153.5), ( 'ppfcz5', 15, 17, 161.5), ( 'ppfcz5', 15, 18, 167.5), +( 'ppfcz5', 15, 19, 173.5), ( 'ppfcz5', 15, 20, 179.5), ( 'ppfcz5', 15, 21, 185.5), +( 'ppfcz5', 15, 22, 191.5), ( 'ppfcz5', 15, 23, 197.5), ( 'ppfcz5', 15, 24, 203.5), +( 'ppfcz5', 15, 25, 207.5), ( 'ppfcz5', 15, 26, 212.5), ( 'ppfcz5', 15, 27, 217.5), +( 'ppfcz5', 15, 28, 222.5), ( 'ppfcz5', 15, 29, 227.5), ( 'ppfcz5', 15, 30, 232.5), +( 'ppfcz1', 14, 2, 37.5), ( 'ppfcz1', 14, 3, 41.5), ( 'ppfcz1', 14, 4, 45.5), +( 'ppfcz1', 14, 5, 48.5), ( 'ppfcz1', 14, 6, 52.5), ( 'ppfcz1', 14, 7, 55.5), +( 'ppfcz1', 14, 8, 57.5), ( 'ppfcz1', 14, 9, 59.5), ( 'ppfcz1', 14, 10, 61.5), +( 'ppfcz1', 14, 11, 62.5), ( 'ppfcz1', 14, 12, 63.5), ( 'ppfcz1', 14, 13, 64.5), +( 'ppfcz1', 14, 14, 65.5), ( 'ppfcz1', 14, 15, 66.5), ( 'ppfcz1', 14, 16, 67.5), +( 'ppfcz1', 14, 17, 68.5), ( 'ppfcz1', 14, 18, 69.5), ( 'ppfcz1', 14, 19, 70.5), +( 'ppfcz1', 14, 20, 71.5), ( 'ppfcz1', 14, 21, 72.5), ( 'ppfcz1', 14, 22, 73.5), +( 'ppfcz1', 14, 23, 74.5), ( 'ppfcz1', 14, 24, 75.5), ( 'ppfcz1', 14, 25, 76.5), +( 'ppfcz1', 14, 26, 77.5), ( 'ppfcz1', 14, 27, 78.5), ( 'ppfcz1', 14, 28, 79.5), +( 'ppfcz1', 14, 29, 80.5), ( 'ppfcz1', 14, 30, 81.5), ( 'ppfcz2', 14, 2, 43.5), +( 'ppfcz2', 14, 3, 48.5), ( 'ppfcz2', 14, 4, 53.5), ( 'ppfcz2', 14, 5, 57.5), +( 'ppfcz2', 14, 6, 61.5), ( 'ppfcz2', 14, 7, 65.5), ( 'ppfcz2', 14, 8, 69.5), +( 'ppfcz2', 14, 9, 73.5), ( 'ppfcz2', 14, 10, 77.5), ( 'ppfcz2', 14, 11, 80.5), +( 'ppfcz2', 14, 12, 83.5), ( 'ppfcz2', 14, 13, 86.5), ( 'ppfcz2', 14, 14, 89.5), +( 'ppfcz2', 14, 15, 92.5), ( 'ppfcz2', 14, 16, 94.5), ( 'ppfcz2', 14, 17, 96.5), +( 'ppfcz2', 14, 18, 98.5), ( 'ppfcz2', 14, 19, 99.5), ( 'ppfcz2', 14, 20, 100.5), +( 'ppfcz2', 14, 21, 101.5), ( 'ppfcz2', 14, 22, 102.5), ( 'ppfcz2', 14, 23, 103.5), +( 'ppfcz2', 14, 24, 104.5), ( 'ppfcz2', 14, 25, 105.5), ( 'ppfcz2', 14, 26, 106.5), +( 'ppfcz2', 14, 27, 107.5), ( 'ppfcz2', 14, 28, 108.5), ( 'ppfcz2', 14, 29, 109.5), +( 'ppfcz2', 14, 30, 110.5), ( 'ppfcz3', 14, 2, 47.5), ( 'ppfcz3', 14, 3, 56.5), +( 'ppfcz3', 14, 4, 67.5), ( 'ppfcz3', 14, 5, 78.5), ( 'ppfcz3', 14, 6, 87.5), +( 'ppfcz3', 14, 7, 96.5), ( 'ppfcz3', 14, 8, 105.5), ( 'ppfcz3', 14, 9, 114.5), +( 'ppfcz3', 14, 10, 123.5), ( 'ppfcz3', 14, 11, 131.5), ( 'ppfcz3', 14, 12, 139.5), +( 'ppfcz3', 14, 13, 147.5), ( 'ppfcz3', 14, 14, 155.5), ( 'ppfcz3', 14, 15, 163.5), +( 'ppfcz3', 14, 16, 171.5), ( 'ppfcz3', 14, 17, 179.5), ( 'ppfcz3', 14, 18, 187.5), +( 'ppfcz3', 14, 19, 195.5), ( 'ppfcz3', 14, 20, 203.5), ( 'ppfcz3', 14, 21, 210.5), +( 'ppfcz3', 14, 22, 217.5), ( 'ppfcz3', 14, 23, 224.5), ( 'ppfcz3', 14, 24, 231.5), +( 'ppfcz3', 14, 25, 238.5), ( 'ppfcz3', 14, 26, 245.5), ( 'ppfcz3', 14, 27, 252.5), +( 'ppfcz3', 14, 28, 259.5), ( 'ppfcz3', 14, 29, 266.5), ( 'ppfcz3', 14, 30, 273.5), +( 'ppfcz4', 14, 2, 54.5), ( 'ppfcz4', 14, 3, 68.5), ( 'ppfcz4', 14, 4, 81.5), +( 'ppfcz4', 14, 5, 95.5), ( 'ppfcz4', 14, 6, 108.5), ( 'ppfcz4', 14, 7, 121.5), +( 'ppfcz4', 14, 8, 134.5), ( 'ppfcz4', 14, 9, 147.5), ( 'ppfcz4', 14, 10, 160.5), +( 'ppfcz4', 14, 11, 168.5), ( 'ppfcz4', 14, 12, 178.5), ( 'ppfcz4', 14, 13, 188.5), +( 'ppfcz4', 14, 14, 198.5), ( 'ppfcz4', 14, 15, 208.5), ( 'ppfcz4', 14, 16, 216.5), +( 'ppfcz4', 14, 17, 224.5), ( 'ppfcz4', 14, 18, 232.5), ( 'ppfcz4', 14, 19, 240.5), +( 'ppfcz4', 14, 20, 248.5), ( 'ppfcz4', 14, 21, 256.5), ( 'ppfcz4', 14, 22, 264.5), +( 'ppfcz4', 14, 23, 272.5), ( 'ppfcz4', 14, 24, 280.5), ( 'ppfcz4', 14, 25, 288.5), +( 'ppfcz4', 14, 26, 296.5), ( 'ppfcz4', 14, 27, 304.5), ( 'ppfcz4', 14, 28, 312.5), +( 'ppfcz4', 14, 29, 320.5), ( 'ppfcz4', 14, 30, 328.5), ( 'ppfcz5', 14, 2, 66.5), +( 'ppfcz5', 14, 3, 84.5), ( 'ppfcz5', 14, 4, 102.5), ( 'ppfcz5', 14, 5, 120.5), +( 'ppfcz5', 14, 6, 137.5), ( 'ppfcz5', 14, 7, 154.5), ( 'ppfcz5', 14, 8, 171.5), +( 'ppfcz5', 14, 9, 188.5), ( 'ppfcz5', 14, 10, 205.5), ( 'ppfcz5', 14, 11, 220.5), +( 'ppfcz5', 14, 12, 235.5), ( 'ppfcz5', 14, 13, 250.5), ( 'ppfcz5', 14, 14, 265.5), +( 'ppfcz5', 14, 15, 280.5), ( 'ppfcz5', 14, 16, 295.5), ( 'ppfcz5', 14, 17, 310.5), +( 'ppfcz5', 14, 18, 325.5), ( 'ppfcz5', 14, 19, 340.5), ( 'ppfcz5', 14, 20, 355.5), +( 'ppfcz5', 14, 21, 368.5), ( 'ppfcz5', 14, 22, 381.5), ( 'ppfcz5', 14, 23, 394.5), +( 'ppfcz5', 14, 24, 407.5), ( 'ppfcz5', 14, 25, 420.5), ( 'ppfcz5', 14, 26, 433.5), +( 'ppfcz5', 14, 27, 446.5), ( 'ppfcz5', 14, 28, 459.5), ( 'ppfcz5', 14, 29, 472.5), +( 'ppfcz5', 14, 30, 485.5), ( 'ppfcz1', 30, 0.5, 56.5), ( 'ppfcz1', 30, 1, 63.5), +( 'ppfcz1', 30, 1.5, 69.5), ( 'ppfcz1', 30, 2, 75.5), ( 'ppfcz1', 30, 2.5, 80.5), +( 'ppfcz1', 30, 3, 86.5), ( 'ppfcz1', 30, 3.5, 92.5), ( 'ppfcz1', 30, 4, 99.5), +( 'ppfcz1', 30, 4.5, 105.5), ( 'ppfcz1', 30, 5, 111.5), ( 'ppfcz1', 30, 6, 118.5), +( 'ppfcz1', 30, 7, 126.5), ( 'ppfcz1', 30, 8, 133.5), ( 'ppfcz1', 30, 9, 141.5), +( 'ppfcz1', 30, 10, 148.5), ( 'ppfcz1', 30, 11, 156.5), ( 'ppfcz1', 30, 12, 163.5), +( 'ppfcz1', 30, 13, 171.5), ( 'ppfcz1', 30, 14, 178.5), ( 'ppfcz1', 30, 15, 186.5), +( 'ppfcz1', 30, 16, 193.5), ( 'ppfcz1', 30, 17, 201.5), ( 'ppfcz1', 30, 18, 209.5), +( 'ppfcz1', 30, 19, 216.5), ( 'ppfcz1', 30, 20, 224.5), ( 'ppfcz1', 30, 21, 231.5), +( 'ppfcz1', 30, 22, 239.5), ( 'ppfcz1', 30, 23, 246.5), ( 'ppfcz1', 30, 24, 254.5), +( 'ppfcz1', 30, 25, 261.5), ( 'ppfcz1', 30, 26, 269.5), ( 'ppfcz1', 30, 27, 276.5), +( 'ppfcz1', 30, 28, 284.5), ( 'ppfcz1', 30, 29, 291.5), ( 'ppfcz1', 30, 30, 299.5), +( 'ppfcz2', 30, 0.5, 61.5), ( 'ppfcz2', 30, 1, 65.5), ( 'ppfcz2', 30, 1.5, 75.5), +( 'ppfcz2', 30, 2, 80.5), ( 'ppfcz2', 30, 2.5, 86.5), ( 'ppfcz2', 30, 3, 99.5), +( 'ppfcz2', 30, 3.5, 109.5), ( 'ppfcz2', 30, 4, 113.5), ( 'ppfcz2', 30, 4.5, 121.5), +( 'ppfcz2', 30, 5, 129.5), ( 'ppfcz2', 30, 6, 139.5), ( 'ppfcz2', 30, 7, 149.5), +( 'ppfcz2', 30, 8, 159.5), ( 'ppfcz2', 30, 9, 169.5), ( 'ppfcz2', 30, 10, 180.5), +( 'ppfcz2', 30, 11, 189.5), ( 'ppfcz2', 30, 12, 199.5), ( 'ppfcz2', 30, 13, 210.5), +( 'ppfcz2', 30, 14, 219.5), ( 'ppfcz2', 30, 15, 229.5), ( 'ppfcz2', 30, 16, 240.5), +( 'ppfcz2', 30, 17, 249.5), ( 'ppfcz2', 30, 18, 259.5), ( 'ppfcz2', 30, 19, 270.5), +( 'ppfcz2', 30, 20, 280.5), ( 'ppfcz2', 30, 21, 289.5), ( 'ppfcz2', 30, 22, 300.5), +( 'ppfcz2', 30, 23, 310.5), ( 'ppfcz2', 30, 24, 320.5), ( 'ppfcz2', 30, 25, 330.5), +( 'ppfcz2', 30, 26, 340.5), ( 'ppfcz2', 30, 27, 350.5), ( 'ppfcz2', 30, 28, 360.5), +( 'ppfcz2', 30, 29, 370.5), ( 'ppfcz2', 30, 30, 381.5), ( 'ppfcz3', 30, 0.5, 74.5), +( 'ppfcz3', 30, 1, 83.5), ( 'ppfcz3', 30, 1.5, 90.5), ( 'ppfcz3', 30, 2, 99.5), +( 'ppfcz3', 30, 2.5, 107.5), ( 'ppfcz3', 30, 3, 114.5), ( 'ppfcz3', 30, 3.5, 122.5), +( 'ppfcz3', 30, 4, 130.5), ( 'ppfcz3', 30, 4.5, 140.5), ( 'ppfcz3', 30, 5, 147.5), +( 'ppfcz3', 30, 6, 162.5), ( 'ppfcz3', 30, 7, 174.5), ( 'ppfcz3', 30, 8, 188.5), +( 'ppfcz3', 30, 9, 201.5), ( 'ppfcz3', 30, 10, 213.5), ( 'ppfcz3', 30, 11, 227.5), +( 'ppfcz3', 30, 12, 240.5), ( 'ppfcz3', 30, 13, 252.5), ( 'ppfcz3', 30, 14, 266.5), +( 'ppfcz3', 30, 15, 278.5), ( 'ppfcz3', 30, 16, 290.5), ( 'ppfcz3', 30, 17, 304.5), +( 'ppfcz3', 30, 18, 317.5), ( 'ppfcz3', 30, 19, 330.5), ( 'ppfcz3', 30, 20, 343.5), +( 'ppfcz3', 30, 21, 354.5), ( 'ppfcz3', 30, 22, 363.5), ( 'ppfcz3', 30, 23, 375.5), +( 'ppfcz3', 30, 24, 385.5), ( 'ppfcz3', 30, 25, 396.5), ( 'ppfcz3', 30, 26, 405.5), +( 'ppfcz3', 30, 27, 417.5), ( 'ppfcz3', 30, 28, 428.5), ( 'ppfcz3', 30, 29, 438.5), +( 'ppfcz3', 30, 30, 448.5), ( 'ppfcz4', 30, 0.5, 90.5), ( 'ppfcz4', 30, 1, 104.5), +( 'ppfcz4', 30, 1.5, 118.5), ( 'ppfcz4', 30, 2, 134.5), ( 'ppfcz4', 30, 2.5, 146.5), +( 'ppfcz4', 30, 3, 163.5), ( 'ppfcz4', 30, 3.5, 179.5), ( 'ppfcz4', 30, 4, 195.5), +( 'ppfcz4', 30, 4.5, 211.5), ( 'ppfcz4', 30, 5, 232.5), ( 'ppfcz4', 30, 6, 257.5), +( 'ppfcz4', 30, 7, 278.5), ( 'ppfcz4', 30, 8, 300.5), ( 'ppfcz4', 30, 9, 321.5), +( 'ppfcz4', 30, 10, 343.5), ( 'ppfcz4', 30, 11, 364.5), ( 'ppfcz4', 30, 12, 386.5), +( 'ppfcz4', 30, 13, 407.5), ( 'ppfcz4', 30, 14, 429.5), ( 'ppfcz4', 30, 15, 450.5), +( 'ppfcz4', 30, 16, 472.5), ( 'ppfcz4', 30, 17, 493.5), ( 'ppfcz4', 30, 18, 515.5), +( 'ppfcz4', 30, 19, 536.5), ( 'ppfcz4', 30, 20, 558.5), ( 'ppfcz4', 30, 21, 579.5), +( 'ppfcz4', 30, 22, 601.5), ( 'ppfcz4', 30, 23, 622.5), ( 'ppfcz4', 30, 24, 644.5), +( 'ppfcz4', 30, 25, 665.5), ( 'ppfcz4', 30, 26, 687.5), ( 'ppfcz4', 30, 27, 708.5), +( 'ppfcz4', 30, 28, 730.5), ( 'ppfcz4', 30, 29, 751.5), ( 'ppfcz4', 30, 30, 773.5), +( 'ppfcz5', 30, 0.5, 97.5), ( 'ppfcz5', 30, 1, 114.5), ( 'ppfcz5', 30, 1.5, 131.5), +( 'ppfcz5', 30, 2, 148.5), ( 'ppfcz5', 30, 2.5, 165.5), ( 'ppfcz5', 30, 3, 183.5), +( 'ppfcz5', 30, 3.5, 200.5), ( 'ppfcz5', 30, 4, 221.5), ( 'ppfcz5', 30, 4.5, 243.5), +( 'ppfcz5', 30, 5, 264.5), ( 'ppfcz5', 30, 6, 289.5), ( 'ppfcz5', 30, 7, 313.5), +( 'ppfcz5', 30, 8, 336.5), ( 'ppfcz5', 30, 9, 360.5), ( 'ppfcz5', 30, 10, 384.5), +( 'ppfcz5', 30, 11, 407.5), ( 'ppfcz5', 30, 12, 431.5), ( 'ppfcz5', 30, 13, 455.5), +( 'ppfcz5', 30, 14, 478.5), ( 'ppfcz5', 30, 15, 502.5), ( 'ppfcz5', 30, 16, 526.5), +( 'ppfcz5', 30, 17, 549.5), ( 'ppfcz5', 30, 18, 573.5), ( 'ppfcz5', 30, 19, 597.5), +( 'ppfcz5', 30, 20, 620.5), ( 'ppfcz5', 30, 21, 644.5), ( 'ppfcz5', 30, 22, 668.5), +( 'ppfcz5', 30, 23, 691.5), ( 'ppfcz5', 30, 24, 715.5), ( 'ppfcz5', 30, 25, 738.5), +( 'ppfcz5', 30, 26, 762.5), ( 'ppfcz5', 30, 27, 786.5), ( 'ppfcz5', 30, 28, 809.5), +( 'ppfcz5', 30, 29, 833.5), ( 'ppfcz5', 30, 30, 857.5), ( 'foreign', 13, 30, 0), +( 'all', 32, 10000, 23.2342007434944); + +--enable_query_log + +SELECT * FROM t2 ORDER BY a, b, c; +SELECT * FROM t2 ORDER BY a, b, c limit 10; +SELECT * FROM t2 ORDER BY a, b, c limit 1000, 20; +SELECT * FROM t2 ORDER BY a, b, d limit 200, 20; +SELECT * FROM t2 ORDER BY a asc, b asc, c desc; + +SELECT * FROM t2 ORDER BY b, c, d; +SELECT * FROM t2 ORDER BY b, d limit 1000, 50; +SELECT * FROM t2 ORDER BY c desc, d limit 500, 20; +SELECT d FROM t2 WHERE t2.b=14 ORDER BY t2.c; + +DROP TABLE t2; diff --git a/mysql-test/suite/parallel_query/t/pq_tempory_table_release.test b/mysql-test/suite/parallel_query/t/pq_tempory_table_release.test new file mode 100644 index 000000000..5e3c273a6 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_tempory_table_release.test @@ -0,0 +1,21 @@ +create table t1(a int primary key, b varchar(10), c decimal(5,2)); + +insert into t1 values (1, 'The', '3.14'); +insert into t1 values (2, 'quick', '4.25'); +insert into t1 values (3, 'brown', '5.36'); +insert into t1 values (4, 'fox', '6.47'); +insert into t1 values (5, 'jumps', '3.14'); +insert into t1 values (6, 'over', '4.25'); +insert into t1 values (7, 'the', '5.36'); +insert into t1 values (8, 'lazy', '6.47'); +insert into t1 values (9, 'dog', '7.58'); + + +set session force_parallel_execute=1; +explain select c,sum(a) from t1 group by(c); +select c,sum(a) from t1 group by(c); + +drop table t1; + +--source include/restart_mysqld.inc + diff --git a/mysql-test/suite/parallel_query/t/pq_tpch.test b/mysql-test/suite/parallel_query/t/pq_tpch.test new file mode 100644 index 000000000..435f40339 --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_tpch.test @@ -0,0 +1,828 @@ +--source include/pq_test.inc +--disable_warnings +drop database if exists pq_database; +--enable_warnings +create database pq_database; +use pq_database; + +--disable_warnings +DROP TABLE IF EXISTS `nation`; +--enable_warnings +CREATE TABLE `nation` ( + `n_nationkey` int NOT NULL, + `N_NAME` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `N_REGIONKEY` int NOT NULL, + `N_COMMENT` varchar(152) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + PRIMARY KEY (`n_nationkey`) USING BTREE, + INDEX `NATION_FK1`(`N_REGIONKEY`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO nation VALUES(0, 'ALGERIA', 0, 'haggle. carefully final deposits detect slyly agai'); +INSERT INTO nation VALUES(1, 'ARGENTINA', 1, 'al foxes promise slyly according to the regular accounts. bold requests alon'); +INSERT INTO nation VALUES(2, 'BRAZIL', 1, 'y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special'); +INSERT INTO nation VALUES(3, 'CANADA', 1, 'eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold'); +INSERT INTO nation VALUES(18, 'CHINA', 2, 'c dependencies. furiously express notornis sleep slyly regular accounts. ideas sleep. depos'); +INSERT INTO nation VALUES(4, 'EGYPT', 4, 'y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d'); +INSERT INTO nation VALUES(5, 'ETHIOPIA', 0, 'ven packages wake quickly. regu'); +INSERT INTO nation VALUES(6, 'FRANCE', 3, 'refully final requests. regular, ironi'); +INSERT INTO nation VALUES(7, 'GERMANY', 3, 'l platelets. regular accounts x-ray: unusual, regular acco'); +INSERT INTO nation VALUES(8, 'INDIA', 2, 'ss excuses cajole slyly across the packages. deposits print aroun'); +INSERT INTO nation VALUES(9, 'INDONESIA', 2, 'slyly express asymptotes. regular deposits haggle slyly. carefully ironic hockey players sleep blithely. carefull'); +INSERT INTO nation VALUES(10, 'IRAN', 4, 'efully alongside of the slyly final dependencies.'); +INSERT INTO nation VALUES(11, 'IRAQ', 4, 'nic deposits boost atop the quickly final requests? quickly regula'); +INSERT INTO nation VALUES(12, 'JAPAN', 2, 'ously. final, express gifts cajole a'); +INSERT INTO nation VALUES(13, 'JORDAN', 4, 'ic deposits are blithely about the carefully regular pa'); +INSERT INTO nation VALUES(14, 'KENYA', 0, 'pending excuses haggle furiously deposits. pending, express pinto beans wake fluffily past t'); +INSERT INTO nation VALUES(15, 'MOROCCO',0, 'rns. blithely bold courts among the closely regular packages use furiously bold platelets?'); +INSERT INTO nation VALUES(16, 'MOZAMBIQUE', 0, 's. ironic, unusual asymptotes wake blithely r'); +INSERT INTO nation VALUES(17, 'PERU', 1, 'platelets. blithely pending dependencies use fluffily across the even pinto beans. carefully silent accoun'); +INSERT INTO nation VALUES(19, 'ROMANIA', 3, 'ular asymptotes are about the furious multipliers. express dependencies nag above the ironically ironic account'); +INSERT INTO nation VALUES(22, 'RUSSIA', 3, 'requests against the platelets use never according to the quickly regular pint'); +INSERT INTO nation VALUES(20, 'SAUDI ARABIA', 4, 'ts. silent requests haggle. closely express packages sleep across the blithely'); +INSERT INTO nation VALUES(23, 'UNITED KINGDOM', 3, 'eans boost carefully special requests. accounts are. carefull'); +INSERT INTO nation VALUES(24, 'UNITED STATES', 1, 'y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be'); +INSERT INTO nation VALUES(21, 'VIETNAM', 2, 'hely enticingly express accounts. even, final'); + +--disable_warnings +DROP TABLE IF EXISTS `supplier`; +--enable_warnings +CREATE TABLE `supplier` ( + `s_suppkey` int NOT NULL, + `S_NAME` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `S_ADDRESS` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `S_NATIONKEY` int NOT NULL, + `S_PHONE` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `S_ACCTBAL` decimal(15, 2) NOT NULL, + `S_COMMENT` varchar(101) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + PRIMARY KEY (`s_suppkey`) USING BTREE, + INDEX `SUPPLIER_FK1`(`S_NATIONKEY`) USING BTREE, + CONSTRAINT `supplier_ibfk_1` FOREIGN KEY (`S_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `supplier_ibfk_2` FOREIGN KEY (`S_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `supplier_ibfk_3` FOREIGN KEY (`S_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO supplier VALUES (605, 'Supplier#000000605', 'wdwiNoNT8pVHOTHQ8jhVzaOTkU', 6, '16-835-870-9488', 6071.58,'foxes poach blithely beneath the excuses: ironic multipliers haggle quickly furiously unu'); +INSERT INTO supplier VALUES (839, 'Supplier#000000839', '1fSx9Sv6LraqnVP3u', 6, '16-845-687-7291',2761.59, 'ess, regular accounts haggle slyly across the carefully'); +INSERT INTO supplier VALUES (996, 'Supplier#000000996', 'Wx4dQwOAwWjfSCGupfrM', 7, '17-447-811-3282', 6329.90, 'ironic forges cajole blithely agai'); +INSERT INTO supplier VALUES (741, 'Supplier#000000741', 'BLP6zAc29lDLOvSE3 h2', 7, '17-292-821-2297', 824.94, 'even, unusual instructions b'); +INSERT INTO `supplier` VALUES (800, 'Supplier#000000800', 'Z4 hpmBjpjBXREqzixsBCIaF', 0, '10-497-654-8607', 7956.80, 'he bold foxes boost blithely about the blithely final epitaphs. slyly'); +INSERT INTO `supplier` VALUES (817, 'Supplier#000000817', '0GTKh7JybR8sVahPoJT8kbNtDV0TzA79Q', 0, '10-282-124-6047', 4468.89, ' blithely even requests. blithely ironic deposits wake slyly. ideas haggle! quickly i'); +INSERT INTO `supplier` VALUES (370, 'Supplier#000000370', 'yyNSJAG9UXcWit4SeMkEIrNcdVq5', 0, '10-602-768-3758', 8515.99, 'ound the unusual foxes sleep finally within the furiously unusual requests. sl'); +INSERT INTO `supplier` VALUES (567, 'Supplier#000000567', 'fvuRpAap0MvoBguGKBfp', 1, '11-390-878-2811', 5264.91, 'ke fluffily furiously ironic ideas. qu'); +INSERT INTO `supplier` VALUES (678, 'Supplier#000000678', 'SLpBfeoHSImv', 1, '11-465-565-3513', -58.41, 'he blithely even requests. blithely unusual theodolites sleep furiously against the'); +INSERT INTO `supplier` VALUES (801, 'Supplier#000000801', 'zohVF4 4GHOJpWy9kdytvYwm27mJEBhk', 1, '11-673-791-6926', 976.53, 'ckly final accounts wake since the even instructions. regular, permanent accounts are against t'); +INSERT INTO `supplier` VALUES (300, 'Supplier#000000300', 'YU QZvXHJC7,ZspUPGwaIOa', 2, '12-468-732-4623', 811.42, 'furiously even theodolites haggle along the final, ironic foxes. bold deposits are.'); +INSERT INTO `supplier` VALUES (743, 'Supplier#000000743', 'ccFQShf qHch yPwbryx12DfnIYAp83,F', 2, '12-841-918-5889', 4384.23, 'e slyly after the quickly final platelets? special, special foxes nag slyl'); +INSERT INTO `supplier` VALUES (993, 'Supplier#000000993', 'z2NwUJ TPfd9MP8K3Blp1prYQ116 ', 2, '12-316-384-2073', 2336.52, ' asymptotes haggle slowly above the'); +INSERT INTO `supplier` VALUES (887, 'Supplier#000000887', 'urEaTejH5POADP2ARrf', 3, '13-738-297-6117', 3113.73, 's. regular realms haggle. special, unusual accounts wake furiously. bold pearls play c'); +INSERT INTO `supplier` VALUES (475, 'Supplier#000000475', 'xw4V6,4QQW LI5Qg EOKy4JD B4Cq1tjzaOma9Y', 3, '13-397-755-1516', -115.01, 'among the slyly regular deposits cajole after the even theodolites. carefully unusua'); +INSERT INTO `supplier` VALUES (402, 'Supplier#000000402', 'i9Sw4DoyMhzhKXCH9By,AYSgmD', 3, '13-109-731-3195', 4943.01, 'around the carefully pending dolp'); +INSERT INTO `supplier` VALUES (378, 'Supplier#000000378', 'FfbhyCxWvcPrO8ltp9', 3, '13-930-567-5190', 4429.27, ' among the furiously pending excuses. fluffily express deposits except the slyly final packages'); +INSERT INTO `supplier` VALUES (928, 'Supplier#000000928', 'VL,J8Fq0GI0BnVTaTU9Dcp9Z', 18, '28-382-849-1505', 8512.48, 'equests are. slyly specia'); +INSERT INTO `supplier` VALUES (255, 'Supplier#000000255', 'qx16XyCEUh9OawVeQWOlGlhAU32iHFPNkO', 18, '28-629-327-4139', 4663.08, 's boost. ironic pinto beans along the slyly unusual foxes haggle regular, final asymptotes. reque'); +INSERT INTO `supplier` VALUES (584, 'Supplier#000000584', 'XvDYsHYpmY5AkX60fj0bZo4WW', 18, '28-223-704-2186', 6912.86, 'e requests haggle carefully even ideas. express, bold requests integrate quickly furiously '); +INSERT INTO `supplier` VALUES (301, 'Supplier#000000301', 'YPFTsQOPRAGIlBw', 4, '14-434-699-9741', 6472.62, 'express foxes sleep carefully even packages. carefully special ideas cajole slyly. carefully r'); +INSERT INTO `supplier` VALUES (67, 'Supplier#000000067', '7YrEKJncHFk5D W7ZaqfAXV', 4, '14-563-538-1657', 3576.55, 'ray slyly final foxes. furio'); +INSERT INTO `supplier` VALUES (78, 'Supplier#000000078', '9y3OZ2CV hGrsrQxzB7V3zTtygHVHlG3SD6yrz', 5, '15-670-998-6860', 1044.10, ', regular packages wake quickly bold requests. carefully unusual requests about the unusual request'); +INSERT INTO `supplier` VALUES (243, 'Supplier#000000243', '8aQ3HGeOXxgYeMAXZQe B5y2RKEF5jdmN3Qb', 6, '16-554-376-5494', 747.88, 'kly silent requests among the blithely regular foxes use fu'); +INSERT INTO `supplier` VALUES (417, 'Supplier#000000417', 'b3CbQxCMWWu,YyeQU 51fccuv7Mt', 6, '16-563-597-5520', -113.45, 'equests hinder quiet courts. carefully'); +INSERT INTO `supplier` VALUES (451, 'Supplier#000000451', 'cqMKQiLjokvIFG', 6, '16-328-146-7253', 2503.45, 'cial packages. pinto beans '); +INSERT INTO `supplier` VALUES (254, 'Supplier#000000254', 'c6h4mizJAVT0Oz', 7, '17-100-212-8737', 6230.48, 'nos. bold ideas wake carefully among the furiously '); +INSERT INTO `supplier` VALUES (786, 'Supplier#000000786', 'QiKBtsiRdDZ2xGcwZgOSoMaKSH4HQ360,88L', 8, '18-280-624-2919', 406.37, 'uests. regular warthogs across the blithely express'); +INSERT INTO `supplier` VALUES (878, 'Supplier#000000878', 'cennOpnejXFuwxsxrfoz6U,WN TC7', 8, '18-462-213-5795', 4140.02, 'gular theodolites wake. blithely bold deposit'); +INSERT INTO `supplier` VALUES (551, 'Supplier#000000551', 'ZNiqP1w6Z SGZsLllIhaicTnLCCuAepdNbkm6pJ', 8, '18-297-775-8421', 9364.67, 'lithely even instructions poach quickly. furiously bold accounts sleep final, final accoun'); +INSERT INTO `supplier` VALUES (702, 'Supplier#000000702', '1IfvvCrOk6tDle1AjJisjgmZTSrf6Y 2t,Mdv', 9, '19-354-412-3179', 7655.97, 'about the unusual, bold foxes. quickl'); +INSERT INTO `supplier` VALUES (505, 'Supplier#000000505', 'aqcYZYQD5TYlLDgIxhKZyFCzL3Ch5qKOxj', 9, '19-480-691-1853', 6399.78, ' requests engage slyly regular ideas. fina'); +INSERT INTO `supplier` VALUES (676, 'Supplier#000000676', 'USGIdhKusoe8dcvWdBbZWUfxnVxNnsgY mG', 9, '19-833-604-9178', 5783.61, 's use deposits. quickly even packages haggle quickl'); +INSERT INTO `supplier` VALUES (834, 'Supplier#000000834', 'fwX0Z5,PgFaauaEXlVQX6UmHM0RDKS4EXe,Tn3nJ', 9, '19-419-490-3356', 3732.75, ' express foxes nag slyly after the regular pinto beans. regul'); +INSERT INTO `supplier` VALUES (504, 'Supplier#000000504', 'P8k2mjRiRUFCJfxw7KrEdRpNNQPDxiI', 10, '20-322-544-5770', 9050.12, 'y final pinto beans. blithely regular instructions wake abo'); +INSERT INTO `supplier` VALUES (240, 'Supplier#000000240', 'yMzL86zw28z6sMa', 10, '20-843-630-4161', 6537.07, 'sly. final, regular pinto beans unwind slyl'); +INSERT INTO `supplier` VALUES (286, 'Supplier#000000286', 'o80iAPvmwqM3WOA93pqBHT4Dsgy1rwG', 10, '20-459-893-8984', 7517.31, 'iously regular pinto beans sleep carefully slyly even accounts. packages cajol'); +INSERT INTO `supplier` VALUES (176, 'Supplier#000000176', 'OLVnGuOx8m6NfApzODj4 JP01JJIm,qI53BChmgQ', 10, '20-970-245-2712', 6387.89, 's according to the carefully expr'); +INSERT INTO `supplier` VALUES (613, 'Supplier#000000613', 'DYwZjMQj26Es8D8pxn2zx', 11, '21-796-340-9401', 2201.94, 'e furiously. final foxes haggle carefully quickly express theodolites. regular deposits affix bli'); +INSERT INTO `supplier` VALUES (5, 'Supplier#000000005', 'Gcdm2rJRzl5qlTVzc', 11, '21-151-690-3663', -283.84, '. slyly regular pinto bea'); +INSERT INTO `supplier` VALUES (493, 'Supplier#000000493', '7tdI3AtlDll57sj5K48WLX j5RDbc', 11, '21-252-702-2543', 4999.17, 'gular foxes. slyly pending requests hang along'); +INSERT INTO `supplier` VALUES (113, 'Supplier#000000113', '5 YOpqbaHs7dR gG4EmXrI7XtA7DcnRMsWPU1z2D', 11, '21-211-117-1937', 1882.05, 'blithely regular courts wake quickly even pl'); +INSERT INTO `supplier` VALUES (337, 'Supplier#000000337', 'IRrbCdIS,GB4YYhr', 12, '22-951-643-8793', 9029.85, 'en theodolites-- special, final deposits should have to boost ca'); +INSERT INTO `supplier` VALUES (550, 'Supplier#000000550', 'QQavssDXnYHbvOrg', 12, '22-648-743-9295', 9238.79, 'en, bold ideas. ironic, unusual deposits boost carefully quick accounts. slyly e'); +INSERT INTO `supplier` VALUES (837, 'Supplier#000000837', '717LGrDM2ChnIS91,PE4 ycp4mu4HPdcX', 12, '22-626-153-5392', 5167.00, 'gular instructions are furiously a'); +INSERT INTO `supplier` VALUES (36, 'Supplier#000000036', 'mzSpBBJvbjdx3UKTW3bLFewRD78D91lAC879', 13, '23-273-493-3679', 2371.51, 'ular theodolites must haggle regular, bold accounts. slyly final pinto beans bo'); +INSERT INTO `supplier` VALUES (577, 'Supplier#000000577', 'kn5oGAnFD1CQjet8awWorC,UMf37MP71yNcVD', 13, '23-973-363-7797', 5593.17, 'olites along the quick accounts cajole throughout the regular asymptotes. accounts maintain'); +INSERT INTO `supplier` VALUES (508, 'Supplier#000000508', 'F9,suuHYbe6kCRCPZaeSHSPAFBk9vOcFX8TUx', 14, '24-179-400-2422', 3878.22, 'sits. blithely furious requests boost slyly about the quickly even packages. closely'); +INSERT INTO `supplier` VALUES (808, 'Supplier#000000808', 'B3zlGM54ECUk5MgRzKI9f7F bB8', 15, '25-297-954-4894', 9438.28, 'y even packages. requests sleep quickly fo'); +INSERT INTO `supplier` VALUES (4, 'Supplier#000000004', 'Bk7ah4CK8SYQTepEmvMkkgMwg', 15, '25-843-787-7479', 4641.08, 'riously even requests above the exp'); +INSERT INTO `supplier` VALUES (755, 'Supplier#000000755', 'IRW3Y6qorkh4GBy4gHSpVTF5L', 15, '25-750-724-4757', 9046.17, 'ding accounts was. carefully express ac'); +INSERT INTO `supplier` VALUES (178, 'Supplier#000000178', 'VJ9DInoVjbDg', 16, '26-471-122-2582', 4693.27, 'hely final foxes instead of the express, expres'); +INSERT INTO `supplier` VALUES (8, 'Supplier#000000008', '9Sq4bBH2FQEmaFOocY45sRTxo6yuoG', 17, '27-498-742-3860', 7627.85, 'al pinto beans. asymptotes haggl'); +INSERT INTO `supplier` VALUES (754, 'Supplier#000000754', 'GLSmwjGddmyMx2D BlOKJm1Ji', 17, '27-971-371-9417', 7425.83, 'leep. pinto beans haggle according to the unusual, e'); +INSERT INTO `supplier` VALUES (656, 'Supplier#000000656', 'mQXqRMgstvOI', 19, '29-633-362-8481', 8069.74, 'ronic packages integrate. even excuses integrate carefully ruthlessly bold packages. regular ideas a'); +INSERT INTO `supplier` VALUES (925, 'Supplier#000000925', 'x3n4pg,q28EckYO,613G7seoAmTPSX0jTvDvM2U', 19, '29-398-723-8226', 406.59, 'regular packages can haggle acro'); +INSERT INTO `supplier` VALUES (123, 'Supplier#000000123', 'IqRn20xsj5ibqAQjb6YNQf0xah', 19, '29-602-688-1506', 5726.19, 'nts x-ray quickly according to t'); +INSERT INTO `supplier` VALUES (952, 'Supplier#000000952', 'n8W6MbJdih Ckh6wDvYJz84ZmabvK4yQDz', 22, '32-276-558-4960', 8621.52, 'cajole permanently? carefully slow deposits cajole quickly. regular'); +INSERT INTO `supplier` VALUES (578, 'Supplier#000000578', 'bn5J0A4426DpcW7m rQ9,qxqJ1KN', 20, '30-105-334-1726', 7428.76, 'carefully about the slyly regular warthogs. special packages above the regular pa'); +INSERT INTO `supplier` VALUES (426, 'Supplier#000000426', 'zjIHPRMAI8vF', 23, '33-576-289-4702', 8621.42, ' requests nag. slyly regular ideas '); +INSERT INTO `supplier` VALUES (939, 'Supplier#000000939', 'mWBKbdzDn3yJNpOT8p', 23, '33-487-125-3117', 7815.06, 'efully. final requests after the unusual requests wake fluffily after the furiously r'); +INSERT INTO `supplier` VALUES (202, 'Supplier#000000202', 'NALZjSfea6SY zB1,I09OJYGrA8bwR4pU', 23, '33-549-918-5721', 6739.52, 'courts cajole bold, special accounts. bold packages haggle re'); +INSERT INTO `supplier` VALUES (84, 'Supplier#000000084', 'DcYjWMiZGQqEKOJi4wAmIV08ikx', 24, '34-869-118-7803', 4780.93, 'even depths. regular foxes use slyly. theod'); +INSERT INTO `supplier` VALUES (87, 'Supplier#000000087', 'WCw7URDj8zoZ7tqC3cpm7', 24, '34-860-229-1674', 4746.66, 'all are quickly after the ironic platelets. pending dolphins are. final the'); +INSERT INTO `supplier` VALUES (828, 'Supplier#000000828', '0B2aPqJ6KTEr2fqxuC7z ', 21, '31-911-715-8972', 289.32, 'ions are carefully along the regular, pending pinto beans. special '); +INSERT INTO `supplier` VALUES (870, 'Supplier#000000870', 'QIgRinpKvCLPG', 21, '31-675-338-9417', 3689.14, 'ronic accounts. quickly pending pinto beans after the regular asymptotes sleep furiously'); +INSERT INTO `supplier` VALUES (863, 'Supplier#000000863', 'TsC9OuodnybJhWXq4PFNdEJf9jx2y181N3ilV', 21, '31-589-608-3508', 487.31, 'ounts. fluffily special platelets along the even pinto beans boost'); + +--disable_warnings +DROP TABLE IF EXISTS `customer`; +--enable_warnings +CREATE TABLE `customer` ( + `c_custkey` int NOT NULL, + `C_NAME` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `C_ADDRESS` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `C_NATIONKEY` int NOT NULL, + `C_PHONE` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `C_ACCTBAL` decimal(15, 2) NOT NULL, + `C_MKTSEGMENT` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `C_COMMENT` varchar(117) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + PRIMARY KEY (`c_custkey`) USING BTREE, + INDEX `CUSTOMER_FK1`(`C_NATIONKEY`) USING BTREE, + CONSTRAINT `customer_ibfk_1` FOREIGN KEY (`C_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `customer_ibfk_2` FOREIGN KEY (`C_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `customer_ibfk_3` FOREIGN KEY (`C_NATIONKEY`) REFERENCES `nation` (`n_nationkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO customer VALUES (301, 'Customer#000000301', 'FtFq9Cgg5UAzUL', 7, '17-265-345-9265', + 9305.05, 'HOUSEHOLD', 'ular, regular notornis sleep along the furiously pending foxes'); +INSERT INTO customer VALUES (71, 'Customer#000000071', 'TlGalgdXWBmMV,6agLyWYDyIz9MKzcY8gl,w6t1B', + 7, '17-710-812-5403', -611.19, 'HOUSEHOLD', 'g courts across the regular, final pinto beans are blithely pending ac'); +INSERT INTO customer VALUES (46, 'Customer#000000046', 'eaTXWWm10L9', 6, '16-357-681-2007', + 5744.59, 'AUTOMOBILE', 'ctions. accounts sleep furiously even requests. regular, regular accounts cajole blithely around the final pa'); +INSERT INTO customer VALUES (281, 'Customer#000000281', 'x5gJ8IGm2Fo9Jigt', 6, '16-809-382-6446', + 4361.70, 'BUILDING', 'fully quiet ideas detect quickly even packages. regular instructions accor'); + +--disable_warnings +DROP TABLE IF EXISTS `orders`; +--enable_warnings +CREATE TABLE `orders` ( + `o_orderkey` int NOT NULL, + `O_CUSTKEY` int NOT NULL, + `O_ORDERSTATUS` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `O_TOTALPRICE` decimal(15, 2) NOT NULL, + `O_ORDERDATE` date NOT NULL, + `O_ORDERPRIORITY` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `O_CLERK` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `O_SHIPPRIORITY` int NOT NULL, + `O_COMMENT` varchar(79) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + PRIMARY KEY (`o_orderkey`) USING BTREE, + INDEX `ORDERS_FK1`(`O_CUSTKEY`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO `orders` VALUES (118370, 301, 'P', 168147.19, '1995-04-29', '5-LOW', 'Clerk#000000272', 0, 'ickly. regular requests play furiously. slyly express accounts a'); +INSERT INTO `orders` VALUES (520707, 71, 'O', 116317.26, '1996-06-01', '3-MEDIUM', 'Clerk#000000381', 0, 'blithely permanent'); +INSERT INTO `orders` VALUES (584192, 46, 'P', 180239.21, '1995-03-19', '1-URGENT', 'Clerk#000000844', 0, 'to the final requests. quickl'); +INSERT INTO `orders` VALUES (479207, 281, 'O ', 169385.50, '1996-02-22', '2-HIGH', 'Clerk#000000930', 0, 'yly. carefully express deposits poach regular re'); +INSERT INTO `orders` VALUES (554307, 2915, 'O', 206510.07, '1998-06-13', '2-HIGH', 'Clerk#000000524', 0, 'ely about the ironic, final foxes. quickly bold accou'); +INSERT INTO `orders` VALUES (111521, 7412, 'O', 182164.10, '1997-02-15', '4-NOT SPECIFIED', 'Clerk#000000329', 0, 'ites are carefully among the furiously ironic acco'); +INSERT INTO `orders` VALUES (444225, 10408, 'O', 306687.42, '1996-06-20', '1-URGENT', 'Clerk#000000096', 0, 'kages use slyly over the slyly blithe dolph'); +INSERT INTO `orders` VALUES (245857, 8044, 'O', 318891.86, '1995-12-24', '5-LOW', 'Clerk#000000721', 0, 'ajole slyly furiously final packages. blithely final ex'); +INSERT INTO `orders` VALUES (132321, 12107, 'F', 243124.18, '1994-02-07', '1-URGENT', 'Clerk#000000853', 0, 'fily final asymptotes sleep furiously across the regul'); +INSERT INTO `orders` VALUES (438816, 6655, 'F', 221287.80, '1993-02-24', '5-LOW', 'Clerk#000000276', 0, 'blithely quickly express pac'); +INSERT INTO `orders` VALUES (74497, 3776, 'F', 191392.39, '1992-12-14', '3-MEDIUM', 'Clerk#000000444', 0, 'fully near the pending, even requests. blithe'); +INSERT INTO `orders` VALUES (89510, 5669, 'O', 216768.31, '1998-05-06', '1-URGENT', 'Clerk#000000190', 0, 'oxes. furiously pending d'); +INSERT INTO `orders` VALUES (157444, 12382, 'O', 215961.16, '1997-02-05', '5-LOW', 'Clerk#000000322', 0, 'carefully silent instructions. carefully thin t'); +INSERT INTO `orders` VALUES (233090, 13514, 'O', 278845.12, '1996-03-24', '3-MEDIUM', 'Clerk#000000736', 0, 'ts above the slyly ruthless requests boost furiously fi'); +INSERT INTO `orders` VALUES (287744, 2327, 'F', 41484.05, '1995-02-04', '1-URGENT', 'Clerk#000000176', 0, 'asymptotes are. furiously regular excuses detect across the blithely fi'); +INSERT INTO `orders` VALUES (91747, 12295, 'F', 157138.78, '1994-09-18', '4-NOT SPECIFIED', 'Clerk#000000591', 0, 'ggle among the blithely unusual instructions. furiously unusual reque'); +INSERT INTO `orders` VALUES (54277, 3023, 'F', 253275.46, '1993-01-03', '1-URGENT', 'Clerk#000000163', 0, 'bove the deposits. carefully unusual sheaves cajole bli'); +INSERT INTO `orders` VALUES (75299, 11546, 'F', 200783.02, '1992-12-19', '2-HIGH', 'Clerk#000000117', 0, 'riously ironic deposits. silent accounts nag. carefully permanent not'); +INSERT INTO `orders` VALUES (529379, 7471, 'O', 274221.23, '1998-04-16', '5-LOW', 'Clerk#000000698', 0, 'usly bold ideas run furiously along the blithely unusual requests'); +INSERT INTO `orders` VALUES (32005, 10379, 'O', 207579.11, '1997-06-01', '4-NOT SPECIFIED', 'Clerk#000000765', 0, 'fily even foxes are slyly requests: careful theodolites haggle slyly '); +INSERT INTO `orders` VALUES (7907, 5645, 'O', 157133.02, '1996-10-10', '5-LOW', 'Clerk#000000418', 0, 'ly even requests wake slyly along the blithely regular packages. sl'); +INSERT INTO `orders` VALUES (196260, 9337, 'O', 200452.87, '1995-12-14', '5-LOW', 'Clerk#000000890', 0, 'sts integrate. furiously special instructions believe quickly amo'); +INSERT INTO `orders` VALUES (346592, 13015, 'F', 182905.27, '1994-08-16', '1-URGENT', 'Clerk#000000849', 0, 'lly. blithely ironic packages are furiously ironic accounts. ca'); +INSERT INTO `orders` VALUES (388736, 8510, 'F', 56404.94, '1993-03-11', '3-MEDIUM', 'Clerk#000000617', 0, 'o beans sleep blithely alongs'); +INSERT INTO `orders` VALUES (552771, 7894, 'F', 334693.22, '1992-04-25', '2-HIGH', 'Clerk#000000691', 0, 'yly unusual dependencies nag blithely among the flu'); +INSERT INTO `orders` VALUES (56134, 11779, 'O', 243929.66, '1998-04-01', '2-HIGH', 'Clerk#000000404', 0, 'uriously ironic requests cajole ideas. blithely r'); +INSERT INTO `orders` VALUES (226145, 7430, 'O', 60709.47, '1997-10-27', '4-NOT SPECIFIED', 'Clerk#000000644', 0, 'pinto beans. regular p'); +INSERT INTO `orders` VALUES (35427, 3022, 'O', 65591.02, '1996-02-25', '4-NOT SPECIFIED', 'Clerk#000000321', 0, 'onic asymptotes! stealthily ruthless Tiresias nag. carefully e'); +INSERT INTO `orders` VALUES (183524, 11161, 'O', 278859.04, '1995-07-07', '5-LOW', 'Clerk#000000879', 0, ' affix furiously. stealthy, regular accounts haggle carefully express package'); +INSERT INTO `orders` VALUES (247297, 2053, 'F', 278670.11, '1994-09-04', '1-URGENT', 'Clerk#000000213', 0, 'rint furiously ironic, unusua'); +INSERT INTO `orders` VALUES (201607, 14615, 'F', 137139.20, '1993-01-09', '3-MEDIUM', 'Clerk#000000008', 0, ' accounts breach slyly. entic'); +INSERT INTO `orders` VALUES (10948, 6694, 'F', 227941.08, '1992-08-14', '3-MEDIUM', 'Clerk#000000489', 0, 'nic grouches detect stealthily fluffily even de'); +INSERT INTO `orders` VALUES (519911, 2474, 'O', 85447.40, '1998-05-09', '5-LOW', 'Clerk#000000901', 0, 'ld, final instructions cajole slyly of the slyly ironi'); +INSERT INTO `orders` VALUES (292454, 6178, 'O', 237065.90, '1997-07-28', '5-LOW', 'Clerk#000000570', 0, 'ites. final, sly requests boost slyly. furiously even shea'); +INSERT INTO `orders` VALUES (233921, 2129, 'O', 163162.77, '1996-02-09', '2-HIGH', 'Clerk#000000382', 0, 'fluffy packages: carefully speci'); +INSERT INTO `orders` VALUES (562599, 14189, 'P', 246108.56, '1995-05-17', '3-MEDIUM', 'Clerk#000000899', 0, 'ding packages. quickly ironic pinto beans above the blithely fl'); +INSERT INTO `orders` VALUES (20199, 2923, 'F', 208687.85, '1994-04-27', '1-URGENT', 'Clerk#000000933', 0, 'lar foxes alongside of the quickly even dolphi'); +INSERT INTO `orders` VALUES (375971, 5954, 'F', 319538.48, '1993-03-26', '5-LOW', 'Clerk#000000129', 0, 'ts hang. slyly regular requests haggle furi'); +INSERT INTO `orders` VALUES (156774, 9308, 'F', 171093.18, '1992-09-11', '2-HIGH', 'Clerk#000000564', 0, 'ans. warhorses sleep. bold accounts promise'); +INSERT INTO `orders` VALUES (281319, 10241, 'O', 94440.21, '1998-04-03', '3-MEDIUM', 'Clerk#000000569', 0, 'en theodolites. blithely express accounts are furiously. stealthil'); +INSERT INTO `orders` VALUES (25029, 13751, 'O', 49638.36, '1997-11-15', '2-HIGH', 'Clerk#000000284', 0, 'ar foxes. blithely even e'); +INSERT INTO `orders` VALUES (180997, 7627, 'O', 164460.51, '1996-08-28', '3-MEDIUM', 'Clerk#000000989', 0, ' furiously ironic deco'); +INSERT INTO `orders` VALUES (545542, 11422, 'O', 269307.75, '1995-07-27', '5-LOW', 'Clerk#000000788', 0, 'ptotes sleep slyly ironic foxes. pending requests integrate fu'); +INSERT INTO `orders` VALUES (111235, 979, 'F', 242840.39, '1994-06-12', '2-HIGH', 'Clerk#000000464', 0, 'old, pending theodolites. q'); +INSERT INTO `orders` VALUES (71975, 12628, 'F', 206803.03, '1993-10-14', '2-HIGH', 'Clerk#000000948', 0, 'onically ironic instructions'); +INSERT INTO `orders` VALUES (284743, 1295, 'F', 89977.99, '1992-02-28', '5-LOW', 'Clerk#000000088', 0, 'ly special requests dazzle blithely. silent packages are quickly r'); +INSERT INTO `orders` VALUES (239905, 6661, 'O', 222791.73, '1998-01-17', '5-LOW', 'Clerk#000000574', 0, ' final dinos according to the carefully un'); +INSERT INTO `orders` VALUES (77026, 3913, 'O', 174749.79, '1997-01-16', '1-URGENT', 'Clerk#000000807', 0, 'equests at the slyly special instructions use furiously after the regular i'); +INSERT INTO `orders` VALUES (56902, 8291, 'O', 150428.22, '1996-11-10', '4-NOT SPECIFIED', 'Clerk#000000788', 0, 'deposits wake never among the regular courts. bold, express asympt'); +INSERT INTO `orders` VALUES (591970, 14726, 'P', 270683.83, '1995-05-10', '5-LOW', 'Clerk#000000408', 0, 'bold accounts. express, regular accounts engage furiously even, ir'); +INSERT INTO `orders` VALUES (290081, 8926, 'F', 159281.61, '1994-07-23', '4-NOT SPECIFIED', 'Clerk#000000530', 0, 'y special deposits alongside of the'); +INSERT INTO `orders` VALUES (240676, 7609, 'F', 149107.47, '1993-09-13', '5-LOW', 'Clerk#000000803', 0, 'mptotes lose about the fluffily regular requ'); +INSERT INTO `orders` VALUES (543332, 11716, 'F', 251043.20, '1992-11-25', '5-LOW', 'Clerk#000000635', 0, 's use slyly final requests.'); +INSERT INTO `orders` VALUES (60162, 8227, 'O', 27699.32, '1998-07-21', '3-MEDIUM', 'Clerk#000000381', 0, 're. furiously ironic acc'); +INSERT INTO `orders` VALUES (28391, 5416, 'O', 177042.21, '1997-12-31', '4-NOT SPECIFIED', 'Clerk#000000302', 0, 'ts. express, regular p'); +INSERT INTO `orders` VALUES (143237, 12463, 'O', 137599.97, '1996-06-17', '3-MEDIUM', 'Clerk#000000054', 0, 't carefully packages. quickly regular do'); +INSERT INTO `orders` VALUES (184738, 2479, 'F', 264759.05, '1995-02-24', '2-HIGH', 'Clerk#000000116', 0, '. furiously even ideas wake carefully. furiously final'); +INSERT INTO `orders` VALUES (355009, 10513, 'F', 258908.67, '1994-10-11', '2-HIGH', 'Clerk#000000090', 0, ' the regular, final packages sleep among the regular cour'); +INSERT INTO `orders` VALUES (267012, 5912, 'F', 140872.95, '1993-05-16', '4-NOT SPECIFIED', 'Clerk#000000004', 0, 'onic theodolites wake slyly after the carefully regular ideas. quickl'); +INSERT INTO `orders` VALUES (463459, 13636, 'F', 166984.44, '1992-09-18', '3-MEDIUM', 'Clerk#000000346', 0, 'blithely above the bu'); +INSERT INTO `orders` VALUES (158240, 2822, 'O', 198647.49, '1998-04-02', '4-NOT SPECIFIED', 'Clerk#000000923', 0, 'ymptotes nag fluffily regular theodolites. enticingl'); +INSERT INTO `orders` VALUES (101056, 11518, 'O', 243377.30, '1997-04-24', '2-HIGH', 'Clerk#000000380', 0, ' warhorses cajole bold, special deposits. blithely exp'); +INSERT INTO `orders` VALUES (374149, 451, 'O', 81750.52, '1996-04-12', '4-NOT SPECIFIED', 'Clerk#000000866', 0, 'ts are furiously. carefully special pac'); +INSERT INTO `orders` VALUES (561857, 13111, 'O', 249337.85, '1995-12-13', '1-URGENT', 'Clerk#000000555', 0, 'ly ironic deposits. fin'); +INSERT INTO `orders` VALUES (422529, 1943, 'F', 158004.97, '1994-04-10', '5-LOW', 'Clerk#000000238', 0, 's wake slyly among the always regular ideas. pending,'); +INSERT INTO `orders` VALUES (186275, 12335, 'F', 277388.41, '1993-08-25', '3-MEDIUM', 'Clerk#000000370', 0, 'y final packages. carefully ironic requests nag silently reg'); +INSERT INTO `orders` VALUES (203457, 8491, 'F', 210610.26, '1992-07-09', '2-HIGH', 'Clerk#000000864', 0, 'ronic requests. instructions wake al'); +INSERT INTO `orders` VALUES (413282, 11311, 'O', 90313.25, '1998-04-18', '3-MEDIUM', 'Clerk#000000435', 0, 'e silent asymptotes grow fluffily carefully final cou'); +INSERT INTO `orders` VALUES (93794, 232, 'O', 228122.85, '1997-08-08', '2-HIGH', 'Clerk#000000480', 0, 'elets cajole quickly about the blithely busy pinto be'); +INSERT INTO `orders` VALUES (550241, 4813, 'O', 218976.24, '1996-01-13', '5-LOW', 'Clerk#000000043', 0, 'usly even dependencies affix deposits. furiously regular excu'); +INSERT INTO `orders` VALUES (340576, 12532, 'O', 316138.21, '1995-12-23', '5-LOW', 'Clerk#000000806', 0, 'gular requests detect furiously. enticing, special accounts will have to cajo'); +INSERT INTO `orders` VALUES (36896, 6136, 'F', 214441.63, '1994-11-04', '1-URGENT', 'Clerk#000000699', 0, 's cajole fluffily brave theodolites. express requests sleep furi'); +INSERT INTO `orders` VALUES (71269, 10151, 'F', 114358.27, '1993-01-20', '5-LOW', 'Clerk#000000766', 0, ' even packages haggle sl'); +INSERT INTO `orders` VALUES (391013, 6413, 'F', 305358.46, '1992-03-28', '4-NOT SPECIFIED', 'Clerk#000000729', 0, '. fluffily special asymptotes haggle blithe'); +INSERT INTO `orders` VALUES (108838, 4615, 'O', 255956.94, '1998-01-14', '1-URGENT', 'Clerk#000000374', 0, 'ckly bold packages sle'); +INSERT INTO `orders` VALUES (440067, 11368, 'O', 105309.92, '1997-03-10', '4-NOT SPECIFIED', 'Clerk#000000394', 0, 'final realms sleep. blithely unusual '); +INSERT INTO `orders` VALUES (79333, 5875, 'O', 193685.31, '1996-05-24', '4-NOT SPECIFIED', 'Clerk#000000486', 0, 'iously pending requests affix fluffily. blith'); +INSERT INTO `orders` VALUES (248417, 12583, 'O', 81229.81, '1995-09-14', '5-LOW', 'Clerk#000000554', 0, 'ly silent packages use pend'); +INSERT INTO `orders` VALUES (247557, 203, 'F', 221236.41, '1994-10-28', '2-HIGH', 'Clerk#000000062', 0, 'hely ironic packages are. ironic deposits haggle. packages boost slyly a'); +INSERT INTO `orders` VALUES (24866, 7361, 'F', 119100.11, '1993-12-05', '4-NOT SPECIFIED', 'Clerk#000000941', 0, 'ajole blithely slyly final deposits. furiously regul'); +INSERT INTO `orders` VALUES (439175, 9439, 'F', 119521.71, '1992-06-22', '4-NOT SPECIFIED', 'Clerk#000000622', 0, 'ial accounts use across the deposits.'); +INSERT INTO `orders` VALUES (442278, 5485, 'O', 138815.96, '1998-04-07', '2-HIGH', 'Clerk#000000901', 0, 'y above the even, pend'); +INSERT INTO `orders` VALUES (498596, 11428, 'O', 207055.52, '1997-05-06', '1-URGENT', 'Clerk#000000413', 0, 'e quickly quickly special foxes. special accounts sleep'); +INSERT INTO `orders` VALUES (359047, 9205, 'O', 147075.49, '1996-08-17', '2-HIGH', 'Clerk#000000643', 0, 'ven deposits on the furiously ironic platelets sleep never carefully ironi'); +INSERT INTO `orders` VALUES (480391, 14464, 'O', 228575.29, '1995-07-23', '3-MEDIUM', 'Clerk#000000653', 0, 'ar instructions nag slyly slyly express dolphins. unusual, ironic foxes hag'); +INSERT INTO `orders` VALUES (358918, 5815, 'F', 130495.07, '1994-05-06', '2-HIGH', 'Clerk#000000008', 0, 'thely express deposits. bli'); +INSERT INTO `orders` VALUES (408641, 8767, 'F', 103243.69, '1993-08-04', '4-NOT SPECIFIED', 'Clerk#000000167', 0, 'le furiously blithely pending pinto beans. furiously'); +INSERT INTO `orders` VALUES (117221, 7189, 'F', 155260.65, '1992-12-14', '3-MEDIUM', 'Clerk#000000352', 0, 'ncies haggle evenly. quickly ironic deposits haggle blithely a'); +INSERT INTO `orders` VALUES (204871, 1828, 'O', 106488.18, '1998-03-22', '4-NOT SPECIFIED', 'Clerk#000000783', 0, 'ithely fluffily bold ide'); +INSERT INTO `orders` VALUES (67426, 8593, 'O', 295962.76, '1997-03-08', '3-MEDIUM', 'Clerk#000000699', 0, 'ake always carefully final foxes. finally unusual requests affix a'); +INSERT INTO `orders` VALUES (156000, 8777, 'O', 132256.74, '1996-10-12', '3-MEDIUM', 'Clerk#000000505', 0, 'olites use quickly against the carefully ironic warhors'); +INSERT INTO `orders` VALUES (68322, 9095, 'O', 227844.86, '1995-10-08', '2-HIGH', 'Clerk#000000930', 0, 'uiet hockey players. blithely regular packages sleep above the fina'); +INSERT INTO `orders` VALUES (185315, 7027, 'F', 165274.21, '1994-08-24', '2-HIGH', 'Clerk#000000762', 0, 'es at the quickly special '); +INSERT INTO `orders` VALUES (380708, 796, 'F', 136913.45, '1993-03-09', '3-MEDIUM', 'Clerk#000000473', 0, 'y special courts detect ironically accounts?'); +INSERT INTO `orders` VALUES (214951, 535, 'F', 182746.71, '1992-04-12', '1-URGENT', 'Clerk#000000816', 0, 'yly at the excuses. f'); +INSERT INTO `orders` VALUES (370689, 10045, 'O', 94356.50, '1998-07-09', '3-MEDIUM', 'Clerk#000000159', 0, 'ep. quickly special requests cajole slyly along the closel'); +INSERT INTO `orders` VALUES (408548, 12508, 'O', 196969.96, '1997-04-29', '1-URGENT', 'Clerk#000000591', 0, 'ic attainments cajole abo'); +INSERT INTO `orders` VALUES (455750, 8741, 'O', 70777.01, '1996-05-26', '5-LOW', 'Clerk#000000159', 0, 'along the final requests. fluffily bold dolphins at the ca'); +INSERT INTO `orders` VALUES (283046, 4640, 'O', 279900.46, '1995-11-21', '3-MEDIUM', 'Clerk#000000280', 0, ' pending, unusual packages. pinto b'); +INSERT INTO `orders` VALUES (92258, 5122, 'F', 165050.88, '1994-04-14', '4-NOT SPECIFIED', 'Clerk#000000926', 0, 'al requests sleep-- finally regular wa'); +INSERT INTO `orders` VALUES (206208, 656, 'F', 76543.28, '1993-10-13', '1-URGENT', 'Clerk#000000245', 0, 'tions wake. even attainments nag'); +INSERT INTO `orders` VALUES (145507, 4564, 'F', 193243.57, '1992-07-06', '1-URGENT', 'Clerk#000000794', 0, 'lyly final deposits cajole quickly among the fina'); +INSERT INTO `orders` VALUES (153351, 5620, 'O', 255270.94, '1998-04-21', '4-NOT SPECIFIED', 'Clerk#000000450', 0, 'nal dependencies. carefully enticing asymptotes until the never ironic theodol'); +INSERT INTO `orders` VALUES (466977, 2878, 'O', 262631.99, '1997-09-03', '2-HIGH', 'Clerk#000000643', 0, 'thely. unusual accounts about the fluffily even deposits'); +INSERT INTO `orders` VALUES (103810, 8923, 'O', 245711.92, '1996-05-15', '1-URGENT', 'Clerk#000000840', 0, 'e deposits. furiously pending foxes detect final, sly forges. caref'); +INSERT INTO `orders` VALUES (110178, 5164, 'O', 205720.59, '1995-06-15', '3-MEDIUM', 'Clerk#000000299', 0, ' against the blithely regular requests. furiously final deposi'); +INSERT INTO `orders` VALUES (13698, 14821, 'F', 175122.99, '1994-08-05', '4-NOT SPECIFIED', 'Clerk#000000640', 0, 'iously bold deposits are carefully blithely unusual '); +INSERT INTO `orders` VALUES (172710, 2641, 'F', 210749.12, '1993-10-31', '5-LOW', 'Clerk#000000500', 0, 'ly bold pearls. quickly ironic requests affix accounts: blithely final i'); +INSERT INTO `orders` VALUES (528513, 11021, 'F', 164509.80, '1992-05-22', '2-HIGH', 'Clerk#000000599', 0, ' the decoys. furiously bold packages cajole slyly. even, bold deposits '); +INSERT INTO `orders` VALUES (420295, 298, 'O', 170798.06, '1998-01-06', '2-HIGH', 'Clerk#000000056', 0, 'deas cajole blithely. asymptotes boost furiously ar'); +INSERT INTO `orders` VALUES (150465, 12545, 'O', 192854.70, '1997-01-13', '2-HIGH', 'Clerk#000000638', 0, ', unusual pinto beans are slyly final epitaphs. furiously regular requests af'); +INSERT INTO `orders` VALUES (139616, 9278, 'O', 156706.85, '1996-11-04', '4-NOT SPECIFIED', 'Clerk#000000608', 0, 'l accounts about the ironic, regular packages snooze car'); +INSERT INTO `orders` VALUES (180832, 12367, 'O', 365903.02, '1995-11-04', '2-HIGH', 'Clerk#000000106', 0, 'nal accounts. grouches breach against the furiously fluffy theo'); +INSERT INTO `orders` VALUES (312962, 10448, 'F', 76205.53, '1994-03-03', '1-URGENT', 'Clerk#000000131', 0, ', special deposits sleep instru'); +INSERT INTO `orders` VALUES (111942, 5354, 'F', 142010.74, '1993-01-26', '2-HIGH', 'Clerk#000000831', 0, 'nic requests. carefully bold theodolites sleep. blithely special package'); +INSERT INTO `orders` VALUES (188032, 3595, 'F', 231980.13, '1992-06-17', '5-LOW', 'Clerk#000000584', 0, 'counts boost blithely against the slyly ironic notornis-- regular'); +INSERT INTO `orders` VALUES (315844, 9257, 'O', 80492.03, '1998-07-28', '5-LOW', 'Clerk#000000788', 0, 'n sublate. fluffily'); +INSERT INTO `orders` VALUES (324771, 2933, 'O', 231373.80, '1997-01-31', '5-LOW', 'Clerk#000000698', 0, 'l, blithe requests boost quickly even plat'); +INSERT INTO `orders` VALUES (323234, 12136, 'O', 226785.51, '1996-11-05', '5-LOW', 'Clerk#000000685', 0, 's. ideas use. sentiments do wake among the ironic re'); +INSERT INTO `orders` VALUES (229475, 9820, 'O', 245629.36, '1995-12-21', '5-LOW', 'Clerk#000000761', 0, 's. final, unusual packages affix against'); +INSERT INTO `orders` VALUES (364805, 8956, 'F', 23880.77, '1994-05-19', '3-MEDIUM', 'Clerk#000000275', 0, 'n carefully above the carefully even instructions. quickly final pa'); +INSERT INTO `orders` VALUES (246052, 9604, 'F', 65364.61, '1993-08-15', '2-HIGH', 'Clerk#000000205', 0, 'ticing, special platelets. ironic, ironic packages can was'); +INSERT INTO `orders` VALUES (159940, 9760, 'F', 57327.04, '1992-10-22', '5-LOW', 'Clerk#000000941', 0, ' are quietly above the furiously express packages. qui'); +INSERT INTO `orders` VALUES (88773, 2074, 'O', 193398.58, '1998-04-29', '4-NOT SPECIFIED', 'Clerk#000000568', 0, 'asymptotes. even, final ideas a'); +INSERT INTO `orders` VALUES (61059, 12005, 'O', 163479.86, '1997-12-02', '4-NOT SPECIFIED', 'Clerk#000000155', 0, 'le quickly even package'); +INSERT INTO `orders` VALUES (75712, 12296, 'O', 97092.35, '1996-01-04', '3-MEDIUM', 'Clerk#000000285', 0, 'nic deposits wake furiously '); +INSERT INTO `orders` VALUES (502210, 12883, 'O', 30929.99, '1995-07-11', '4-NOT SPECIFIED', 'Clerk#000000717', 0, ' the quickly pending foxes breach sp'); +INSERT INTO `orders` VALUES (581318, 6445, 'F', 229949.49, '1994-09-20', '3-MEDIUM', 'Clerk#000000850', 0, 'ourts across the carefully final requests use quickly slyly '); +INSERT INTO `orders` VALUES (262180, 10639, 'F', 35438.89, '1993-01-24', '2-HIGH', 'Clerk#000000735', 0, 'express, regular dep'); +INSERT INTO `orders` VALUES (442529, 7211, 'F', 100580.86, '1992-09-04', '1-URGENT', 'Clerk#000000376', 0, 'hely bold requests. regular, ironic deposits '); +INSERT INTO `orders` VALUES (393062, 6769, 'O', 124823.56, '1998-05-28', '2-HIGH', 'Clerk#000000072', 0, 'the packages. furiously regular deposits about the ironic packages sleep '); +INSERT INTO `orders` VALUES (440802, 3157, 'O', 98539.44, '1997-07-20', '5-LOW', 'Clerk#000000501', 0, 'kages haggle blithely. asymptotes use slyly. furi'); +INSERT INTO `orders` VALUES (129282, 2881, 'O', 214294.02, '1996-07-14', '1-URGENT', 'Clerk#000000962', 0, 'eas wake even, regular instructions: s'); +INSERT INTO `orders` VALUES (53189, 7924, 'O', 36320.43, '1995-08-24', '1-URGENT', 'Clerk#000000127', 0, 'blithely regular de'); +INSERT INTO `orders` VALUES (220419, 2569, 'F', 118619.37, '1994-04-07', '4-NOT SPECIFIED', 'Clerk#000000208', 0, 'tain. bold deposits about t'); +INSERT INTO `orders` VALUES (235171, 7286, 'F', 339797.80, '1993-06-11', '2-HIGH', 'Clerk#000000801', 0, 'fully silent excuses about the special requests wake against the instru'); +INSERT INTO `orders` VALUES (406339, 14738, 'F', 218329.22, '1992-06-16', '1-URGENT', 'Clerk#000000154', 0, ' dinos. special, even excuses along the bold excuses grow carefully even, un'); +INSERT INTO `orders` VALUES (78567, 8092, 'O', 179276.82, '1998-05-26', '5-LOW', 'Clerk#000000281', 0, 'are quickly even, unusual pinto beans. fi'); +INSERT INTO `orders` VALUES (451809, 10708, 'O', 65517.87, '1997-09-16', '2-HIGH', 'Clerk#000000580', 0, 'y after the blithely ironic accounts. slyly regular ac'); +INSERT INTO `orders` VALUES (133601, 12047, 'O', 203661.30, '1996-05-10', '2-HIGH', 'Clerk#000000520', 0, 'regular packages bo'); +INSERT INTO `orders` VALUES (467232, 353, 'F', 74983.09, '1995-01-26', '5-LOW', 'Clerk#000000458', 0, 'dolphins play blithely final, regular foxes. dogg'); +INSERT INTO `orders` VALUES (208480, 5143, 'F', 222813.18, '1994-12-29', '4-NOT SPECIFIED', 'Clerk#000000883', 0, 'ress hockey players ca'); +INSERT INTO `orders` VALUES (487680, 2024, 'F', 149428.95, '1993-09-25', '3-MEDIUM', 'Clerk#000000047', 0, 'regular, final instructions boost even,'); +INSERT INTO `orders` VALUES (363841, 4426, 'F', 169547.16, '1992-03-21', '5-LOW', 'Clerk#000000827', 0, 'e blithely bold, bold deposits. furiously even soma'); +INSERT INTO `orders` VALUES (216454, 10072, 'O', 214680.26, '1998-01-18', '3-MEDIUM', 'Clerk#000000322', 0, 'platelets after the regular '); +INSERT INTO `orders` VALUES (61954, 8164, 'O', 164853.36, '1997-01-14', '2-HIGH', 'Clerk#000000562', 0, 'press platelets cajole fluffily'); +INSERT INTO `orders` VALUES (150531, 2335, 'O', 63449.78, '1996-08-28', '1-URGENT', 'Clerk#000000516', 0, 'regular courts. orbits detect furiously. p'); +INSERT INTO `orders` VALUES (265476, 4067, 'P', 78738.68, '1995-04-16', '2-HIGH', 'Clerk#000000375', 0, 'ular, final deposits. furiously pending platelets boost a'); +INSERT INTO `orders` VALUES (205574, 13831, 'F', 95856.59, '1994-03-08', '1-URGENT', 'Clerk#000000033', 0, 'ording to the closely unusual accounts. ironic accounts are carefully amo'); +INSERT INTO `orders` VALUES (474403, 3341, 'F', 57130.19, '1993-05-17', '3-MEDIUM', 'Clerk#000000413', 0, 'ess realms are fluffily even i'); +INSERT INTO `orders` VALUES (94338, 10078, 'F', 132893.14, '1992-10-11', '3-MEDIUM', 'Clerk#000000391', 0, 'counts. slyly regular asymptotes agains'); +INSERT INTO `orders` VALUES (126337, 4126, 'O', 349901.54, '1998-02-22', '1-URGENT', 'Clerk#000000124', 0, 'ckages. slyly stealthy requests i'); +INSERT INTO `orders` VALUES (121606, 13733, 'O', 326252.88, '1997-02-25', '5-LOW', 'Clerk#000000517', 0, 'ously special packages against the pending instructions cajole fluffi'); +INSERT INTO `orders` VALUES (509413, 7315, 'O', 202720.54, '1996-04-16', '1-URGENT', 'Clerk#000000580', 0, 'ackages wake slyly. bold, unusual packages breach. blithely'); +INSERT INTO `orders` VALUES (192197, 6175, 'O', 2453.65, '1995-08-07', '1-URGENT', 'Clerk#000000126', 0, 'ily express platelets. furiously final sentiments are b'); +INSERT INTO `orders` VALUES (32358, 14771, 'F', 245782.82, '1994-06-10', '2-HIGH', 'Clerk#000000174', 0, 'final foxes sleep furi'); +INSERT INTO `orders` VALUES (42375, 3332, 'F', 188459.13, '1993-10-02', '2-HIGH', 'Clerk#000000728', 0, ' enticing deposits. blithely final theodolites ar'); +INSERT INTO `orders` VALUES (53984, 4147, 'F', 59589.68, '1992-12-11', '3-MEDIUM', 'Clerk#000000040', 0, 's wake about the blithely final'); +INSERT INTO `orders` VALUES (52167, 12748, 'O', 253368.62, '1998-07-11', '1-URGENT', 'Clerk#000000971', 0, 'slyly special deposits cajole orbi'); +INSERT INTO `orders` VALUES (350083, 7954, 'O', 31094.84, '1997-06-06', '1-URGENT', 'Clerk#000000516', 0, 'ress dinos are quickly. slyly ironic acco'); +INSERT INTO `orders` VALUES (407073, 11647, 'O', 152916.08, '1996-04-03', '3-MEDIUM', 'Clerk#000000793', 0, 'cies. special, regular deposits among the slyly ironic packages b'); +INSERT INTO `orders` VALUES (22532, 5971, 'F', 54887.64, '1995-02-09', '1-URGENT', 'Clerk#000000907', 0, 'ust have to sleep about th'); +INSERT INTO `orders` VALUES (19047, 5740, 'F', 236935.71, '1994-01-29', '2-HIGH', 'Clerk#000000036', 0, 'ake. instructions integrate along the furiously unus'); +INSERT INTO `orders` VALUES (166243, 8321, 'F', 248901.42, '1993-12-27', '3-MEDIUM', 'Clerk#000000340', 0, 't furiously slyly unusual asymptotes. careful'); +INSERT INTO `orders` VALUES (220421, 340, 'F', 94461.44, '1992-02-14', '4-NOT SPECIFIED', 'Clerk#000000323', 0, ' nag carefully after the even p'); +INSERT INTO `orders` VALUES (9287, 7897, 'O', 14628.23, '1998-01-02', '4-NOT SPECIFIED', 'Clerk#000000636', 0, 'ously unusual packages. regular foxes detect. blithely slow ideas sl'); +INSERT INTO `orders` VALUES (45862, 9674, 'O', 46102.50, '1997-07-02', '4-NOT SPECIFIED', 'Clerk#000000850', 0, 'erns. final requests haggle slyly. theodolites wake after the furio'); +INSERT INTO `orders` VALUES (92002, 131, 'O', 121046.69, '1996-09-09', '2-HIGH', 'Clerk#000000353', 0, 's. regular theodolit'); +INSERT INTO `orders` VALUES (389633, 8653, 'P', 161208.66, '1995-03-19', '1-URGENT', 'Clerk#000000457', 0, 'ites are carefully silent deposits. fluffily ironic request'); +INSERT INTO `orders` VALUES (96739, 8362, 'F', 175525.87, '1994-07-12', '2-HIGH', 'Clerk#000000596', 0, 's was carefully unusual sauternes. furiou'); +INSERT INTO `orders` VALUES (575109, 4259, 'F', 181707.71, '1993-03-25', '3-MEDIUM', 'Clerk#000000461', 0, 'ans. ironic, express platelets use regularly. fluffily regular instru'); +INSERT INTO `orders` VALUES (284578, 2647, 'F', 22278.93, '1992-03-06', '2-HIGH', 'Clerk#000000531', 0, 'ake quickly. final plate'); +INSERT INTO `orders` VALUES (351843, 7504, 'O', 72209.48, '1998-03-01', '2-HIGH', 'Clerk#000000663', 0, 'phins. furiously final theodolites boost daringly care'); +INSERT INTO `orders` VALUES (19014, 10459, 'O', 259321.32, '1997-09-23', '5-LOW', 'Clerk#000000340', 0, 'r dependencies haggle quickly bold accounts; pending dependencies '); +INSERT INTO `orders` VALUES (22436, 7495, 'O', 191816.91, '1996-05-24', '1-URGENT', 'Clerk#000000068', 0, 'ar packages. even, bold foxes wake. dependencies cajole carefully iron'); +INSERT INTO `orders` VALUES (59108, 6067, 'O', 271402.46, '1995-10-08', '5-LOW', 'Clerk#000000259', 0, ' deposits cajole above the quickly ironic deposits. carefully express '); +INSERT INTO `orders` VALUES (593637, 7817, 'F', 208444.44, '1994-11-17', '3-MEDIUM', 'Clerk#000000249', 0, 'ously multipliers. regular requests cajol'); +INSERT INTO `orders` VALUES (15744, 12130, 'F', 48861.07, '1993-03-22', '1-URGENT', 'Clerk#000000939', 0, 'ily ironic pinto beans. ironic, unusual instructions n'); +INSERT INTO `orders` VALUES (303877, 4105, 'F', 201610.61, '1992-11-18', '4-NOT SPECIFIED', 'Clerk#000000745', 0, 'dolites sleep furiously after the even, ironi'); + +--disable_warnings +DROP TABLE IF EXISTS `part`; +--enable_warnings +CREATE TABLE `part` ( + `p_partkey` int NOT NULL, + `P_NAME` varchar(55) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `P_MFGR` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `P_BRAND` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `P_TYPE` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `P_SIZE` int NOT NULL, + `P_CONTAINER` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `P_RETAILPRICE` decimal(15, 2) NOT NULL, + `P_COMMENT` varchar(23) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + PRIMARY KEY (`p_partkey`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO `part` VALUES (299, 'deep coral dodger green peach', 'Manufacturer#4', 'Brand#41', 'STANDARD ANODIZED COPPER', 26, 'WRAP PKG', 1199.29, 'regular dol'); +INSERT INTO `part` VALUES (316, 'almond rosy green hot midnight', 'Manufacturer#4', 'Brand#41', 'MEDIUM BRUSHED TIN', 9, 'MED CASE', 1216.31, 'deposits haggle'); +INSERT INTO `part` VALUES (119, 'olive metallic slate peach green', 'Manufacturer#4', 'Brand#43', 'LARGE POLISHED STEEL', 30, 'WRAP CASE', 1019.11, 'out the quickly r'); +INSERT INTO `part` VALUES (177, 'indian turquoise purple green spring', 'Manufacturer#2', 'Brand#21', 'MEDIUM BRUSHED STEEL', 42, 'LG BAG', 1077.17, 'ermanently eve'); +INSERT INTO `part` VALUES (300, 'light goldenrod green lime papaya', 'Manufacturer#4', 'Brand#44', 'PROMO ANODIZED BRASS', 1, 'WRAP PACK', 1200.30, 'tructions int'); +INSERT INTO `part` VALUES (242, 'spring green lemon medium olive', 'Manufacturer#3', 'Brand#35', 'SMALL POLISHED STEEL', 42, 'LG BAG', 1142.24, 'ously final theodo'); +INSERT INTO `part` VALUES (886, 'turquoise dodger lemon antique green', 'Manufacturer#5', 'Brand#55', 'LARGE BRUSHED COPPER', 46, 'MED BAG', 1786.88, 'tornis haggle! '); +INSERT INTO `part` VALUES (474, 'papaya green royal burlywood saddle', 'Manufacturer#1', 'Brand#14', 'ECONOMY PLATED STEEL', 45, 'LG PACK', 1374.47, 'ously even reques'); +INSERT INTO `part` VALUES (401, 'almond chiffon indian green dim', 'Manufacturer#2', 'Brand#21', 'ECONOMY POLISHED STEEL', 10, 'SM PKG', 1301.40, 'ideas cajole '); +INSERT INTO `part` VALUES (377, 'green forest rose slate cornflower', 'Manufacturer#4', 'Brand#44', 'STANDARD BURNISHED COPPER', 16, 'WRAP BOX', 1277.37, 'ly regula'); +INSERT INTO `part` VALUES (4, 'cornflower chocolate smoke green pink', 'Manufacturer#3', 'Brand#34', 'SMALL PLATED BRASS', 14, 'MED DRUM', 904.00, 'p furiously r'); +INSERT INTO `part` VALUES (83, 'blush green dim lawn peru', 'Manufacturer#1', 'Brand#12', 'PROMO BURNISHED NICKEL', 47, 'SM CAN', 983.08, 'ly regul'); +INSERT INTO `part` VALUES (577, 'lime green dark misty chiffon', 'Manufacturer#2', 'Brand#22', 'LARGE BRUSHED STEEL', 34, 'JUMBO BAG', 1477.57, 'ding, fur'); +INSERT INTO `part` VALUES (327, 'metallic lavender green firebrick ghost', 'Manufacturer#2', 'Brand#23', 'PROMO POLISHED BRASS', 14, 'SM PACK', 1227.32, 'regular'); +INSERT INTO `part` VALUES (416, 'ghost misty chocolate peach green', 'Manufacturer#1', 'Brand#13', 'MEDIUM POLISHED STEEL', 11, 'WRAP JAR', 1316.41, 'yly pending deposit'); +INSERT INTO `part` VALUES (450, 'sky lace green pale lime', 'Manufacturer#4', 'Brand#43', 'MEDIUM BURNISHED TIN', 23, 'SM CASE', 1350.45, 'slyly'); +INSERT INTO `part` VALUES (3, 'spring green yellow purple cornsilk', 'Manufacturer#4', 'Brand#42', 'STANDARD POLISHED BRASS', 21, 'WRAP CASE', 903.00, 'egular deposits hag'); +INSERT INTO `part` VALUES (35, 'green blush tomato burlywood seashell', 'Manufacturer#4', 'Brand#43', 'MEDIUM ANODIZED BRASS', 14, 'JUMBO PACK', 935.03, 'e carefully furi'); +INSERT INTO `part` VALUES (201, 'dodger white chiffon moccasin green', 'Manufacturer#4', 'Brand#42', 'SMALL POLISHED STEEL', 18, 'JUMBO BAG', 1101.20, ' courts sl'); +INSERT INTO `part` VALUES (175, 'magenta blue chartreuse tan green', 'Manufacturer#1', 'Brand#11', 'PROMO ANODIZED TIN', 45, 'JUMBO JAR', 1075.17, 'ole against the'); +INSERT INTO `part` VALUES (489, 'smoke green blush deep royal', 'Manufacturer#2', 'Brand#22', 'LARGE BURNISHED TIN', 36, 'LG CAN', 1389.48, 'unts. quickly bold id'); +INSERT INTO `part` VALUES (362, 'sienna green ghost rose lawn', 'Manufacturer#1', 'Brand#13', 'ECONOMY POLISHED COPPER', 9, 'JUMBO BAG', 1262.36, 'accounts. furi'); +INSERT INTO `part` VALUES (86, 'green blanched firebrick dim cream', 'Manufacturer#4', 'Brand#44', 'STANDARD PLATED TIN', 37, 'LG CASE', 986.08, ' daring sheaves '); +INSERT INTO `part` VALUES (326, 'sky papaya green azure chiffon', 'Manufacturer#3', 'Brand#34', 'LARGE ANODIZED STEEL', 48, 'JUMBO CAN', 1226.32, 'aggle slyly special f'); +INSERT INTO `part` VALUES (7, 'moccasin green thistle khaki floral', 'Manufacturer#1', 'Brand#11', 'SMALL PLATED COPPER', 45, 'SM BAG', 907.00, 'lyly. ex'); +INSERT INTO `part` VALUES (257, 'blue gainsboro maroon green burnished', 'Manufacturer#4', 'Brand#41', 'ECONOMY POLISHED COPPER', 11, 'SM JAR', 1157.25, 'riously final foxes'); +INSERT INTO `part` VALUES (557, 'firebrick ghost steel green chartreuse', 'Manufacturer#3', 'Brand#35', 'LARGE BURNISHED TIN', 8, 'JUMBO PKG', 1457.55, 'ccounts im'); +INSERT INTO `part` VALUES (905, 'burlywood honeydew cornsilk indian green', 'Manufacturer#2', 'Brand#25', 'PROMO BRUSHED BRASS', 27, 'MED CASE', 1805.90, 'es. furiously ir'); +INSERT INTO `part` VALUES (674, 'tomato chartreuse cornflower green pale', 'Manufacturer#3', 'Brand#35', 'SMALL BRUSHED TIN', 5, 'LG PKG', 1574.67, 'unts use slyly bold'); +INSERT INTO `part` VALUES (872, 'papaya frosted cornflower green almond', 'Manufacturer#1', 'Brand#15', 'MEDIUM PLATED STEEL', 41, 'LG CASE', 1772.87, 'gular inst'); +INSERT INTO `part` VALUES (1436, 'smoke floral green medium blush', 'Manufacturer#5', 'Brand#54', 'ECONOMY ANODIZED COPPER', 10, 'LG BAG', 1337.43, 'sily pending inst'); +INSERT INTO `part` VALUES (336, 'maroon medium green tomato rosy', 'Manufacturer#2', 'Brand#25', 'PROMO ANODIZED TIN', 3, 'WRAP JAR', 1236.33, 'nto beans.'); + +--disable_warnings +DROP TABLE IF EXISTS `partsupp`; +--enable_warnings +CREATE TABLE `partsupp` ( + `ps_partkey` int NOT NULL, + `PS_SUPPKEY` int NOT NULL, + `PS_AVAILQTY` int NOT NULL, + `PS_SUPPLYCOST` decimal(15, 2) NOT NULL, + `PS_COMMENT` varchar(199) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + PRIMARY KEY (`ps_partkey`, `PS_SUPPKEY`) USING BTREE, + INDEX `PARTSUPP_FK1`(`PS_SUPPKEY`) USING BTREE, + CONSTRAINT `partsupp_ibfk_1` FOREIGN KEY (`PS_SUPPKEY`) REFERENCES `supplier` (`s_suppkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `partsupp_ibfk_2` FOREIGN KEY (`ps_partkey`) REFERENCES `part` (`p_partkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `partsupp_ibfk_3` FOREIGN KEY (`PS_SUPPKEY`) REFERENCES `supplier` (`s_suppkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `partsupp_ibfk_4` FOREIGN KEY (`ps_partkey`) REFERENCES `part` (`p_partkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `partsupp_ibfk_5` FOREIGN KEY (`PS_SUPPKEY`) REFERENCES `supplier` (`s_suppkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `partsupp_ibfk_6` FOREIGN KEY (`ps_partkey`) REFERENCES `part` (`p_partkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO `partsupp` VALUES (299, 800, 2035, 248.11, 'ithely final foxes cajole. blithely pending packages grow slyly special, ironic platelets. fluffily pending dept'); +INSERT INTO `partsupp` VALUES (316, 817, 8752, 591.79, 'sts hinder carefully. furiously unusual deposits haggle fluffily '); +INSERT INTO `partsupp` VALUES (119, 370, 1452, 676.92, 'ular instructions was slyly. furiously bold gifts boost f'); +INSERT INTO `partsupp` VALUES (177, 678, 9872, 252.42, 'sual platelets. bold foxes affix furiously. pending, pending accounts lose furiously. pending platelets along the unusual, even foxes wake regular, even theo'); +INSERT INTO `partsupp` VALUES (300, 801, 7118, 743.78, 'sts wake carefully regular, pending pinto beans. unusual foxes wake slyly among the ironic, reg'); +INSERT INTO `partsupp` VALUES (242, 743, 2514, 208.39, 'ckages. permanent, even warhorses cajole blithely after the final accounts. quickly pending packag'); +INSERT INTO `partsupp` VALUES (886, 887, 4069, 19.56, 'r requests across the carefully final deposits nag ironic ideas. unusual dolphins nag furiously near the furiou'); +INSERT INTO `partsupp` VALUES (474, 475, 3200, 728.15, 'ding to the express courts. furiously ironic deposits nod accounts. bold deposits cajole throughout the carefully close accounts. fluffily final attainments will cajole blithely even foxes. slyl'); +INSERT INTO `partsupp` VALUES (401, 402, 3408, 214.06, 'eep slyly-- slyly fluffy deposits thrash fluffily fluffily even deposits. final accounts are slyly among the final ideas. unusual packages print slyly carefully iro'); +INSERT INTO `partsupp` VALUES (377, 378, 9022, 665.73, 'hely pending deposits integrate according to the regular foxes. furiously ironic ideas sleep about the ironic'); +INSERT INTO `partsupp` VALUES (4, 255, 6377, 591.18, 'ly final courts haggle carefully regular accounts. carefully regular accounts could integrate slyly. slyly express packages about the accounts wake slyly'); +INSERT INTO `partsupp` VALUES (83, 584, 5974, 657.22, ' even packages boost furiously. slyly regular gifts above the accounts are quickly express packages. slyly pending deposits besides the express, even asymptotes haggle after the ironic ins'); +INSERT INTO `partsupp` VALUES (577, 78, 9072, 373.75, 'ges detect quickly final requests. unusual pinto beans sleep furiously'); +INSERT INTO `partsupp` VALUES (327, 78, 7862, 290.17, 'uests. regular requests haggle. blithely bold requests l'); +INSERT INTO `partsupp` VALUES (416, 417, 4241, 813.99, 'of the pending, even requests could lose slyly regular ideas. slyly final dependencies use-- furiousl'); +INSERT INTO `partsupp` VALUES (450, 451, 1191, 118.60, 'cording to the pending requests. ironic ideas use slyly against the final requests. regular accoun'); +INSERT INTO `partsupp` VALUES (3, 254, 4093, 498.13, 'ending dependencies haggle fluffily. regular deposits boost quickly carefully regular requests. deposits affix furiously around the pinto beans. ironic, unusual platelets across the p'); +INSERT INTO `partsupp` VALUES (35, 786, 2025, 411.17, 's cajole fluffily final deposits. furiously express packages after the blithely special realms boost evenly even requests. slow requests use above the unusual accoun'); +INSERT INTO `partsupp` VALUES (201, 702, 4125, 534.11, 'uctions sleep slyly final theodolites. ironic, regular pinto beans along the sly'); +INSERT INTO `partsupp` VALUES (175, 676, 8501, 706.61, 'int above the instructions. furiously regular requests integrate blithely according to the instructions. slyly pending foxes are asymptotes. slyly ruthless accounts wake. r'); +INSERT INTO `partsupp` VALUES (489, 240, 3471, 937.30, 'dogged pinto beans above the silent, bold requests wake slyly about the regular accounts. blithely ironic deposits wake. even, express sheaves haggle carefully deposits. specia'); +INSERT INTO `partsupp` VALUES (362, 613, 6711, 357.00, 'ss the blithely express ideas integrate furiously alongside of the requests. silent instructions engage. furiously special pa'); +INSERT INTO `partsupp` VALUES (86, 337, 2773, 250.04, 'ding accounts. slyly special requests will have to affix carefully along the furiously unusual packages. regular theodol'); +INSERT INTO `partsupp` VALUES (326, 577, 7160, 592.60, 'ronic deposits wake slyly regular ideas. pinto beans across the carefully even ideas affix furiously fluffily final accounts. packages are blithely above the r'); +INSERT INTO `partsupp` VALUES (7, 508, 3377, 68.77, 'usly against the daring asymptotes. slyly regular platelets sleep quickly blithely regular deposits. boldly regular deposits wake blithely ironic accounts'); +INSERT INTO `partsupp` VALUES (257, 508, 276, 612.44, 'among the packages. thinly special packages sleep. blithely ironic packages are furiously around the furiously even packages. carefully unusual accounts nag bold dolphins. blithely ironic depend'); +INSERT INTO `partsupp` VALUES (557, 808, 106, 823.28, 'ns. slyly final packages wake. carefully ironic packages affix. even, final accounts according to the fluffily final pinto beans use slyl'); +INSERT INTO `partsupp` VALUES (905, 656, 5818, 118.80, 'closely bold packages haggle furiously final requests. regular requests cajole slyly. carefully final asymptote'); +INSERT INTO `partsupp` VALUES (674, 925, 2476, 726.52, 'e furiously even dolphins use across the final, bold deposits. regular pinto beans doubt thinly furiously pending dolphins. theodolites cajole slyly. blithely special deposits are furiously. s'); +INSERT INTO `partsupp` VALUES (872, 123, 8098, 669.74, 'ly pending packages. requests wake carefully ironic, unusual dependencies. carefully pending pinto beans wake after the blithely special instructions. fluffily quiet requests'); +INSERT INTO `partsupp` VALUES (1436, 939, 2379, 231.49, 'pending pinto beans play furiously furiously unusual requests. '); +INSERT INTO `partsupp` VALUES (336, 87, 1661, 339.32, 'ntain along the furiously ironic packages. express accounts sleep quickly. deposits cajole slyly regular ideas. final excus'); + +--disable_warnings +DROP TABLE IF EXISTS `lineitem`; +--enable_warnings +CREATE TABLE `lineitem` ( + `l_orderkey` int NOT NULL, + `L_PARTKEY` int NOT NULL, + `L_SUPPKEY` int NOT NULL, + `L_LINENUMBER` int NOT NULL, + `L_QUANTITY` decimal(15, 2) NOT NULL, + `L_EXTENDEDPRICE` decimal(15, 2) NOT NULL, + `L_DISCOUNT` decimal(15, 2) NOT NULL, + `L_TAX` decimal(15, 2) NOT NULL, + `L_RETURNFLAG` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `L_LINESTATUS` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `L_SHIPDATE` date NOT NULL, + `L_COMMITDATE` date NOT NULL, + `L_RECEIPTDATE` date NOT NULL, + `L_SHIPINSTRUCT` char(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `L_SHIPMODE` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `L_COMMENT` varchar(44) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + PRIMARY KEY (`l_orderkey`, `L_LINENUMBER`) USING BTREE, + INDEX `LINEITEM_FK2`(`L_PARTKEY`, `L_SUPPKEY`) USING BTREE, + CONSTRAINT `lineitem_ibfk_1` FOREIGN KEY (`l_orderkey`) REFERENCES `orders` (`o_orderkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `lineitem_ibfk_3` FOREIGN KEY (`l_orderkey`) REFERENCES `orders` (`o_orderkey`) ON DELETE RESTRICT ON UPDATE RESTRICT, + CONSTRAINT `lineitem_ibfk_5` FOREIGN KEY (`l_orderkey`) REFERENCES `orders` (`o_orderkey`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +INSERT INTO lineitem VALUES(118370, 5349, 605, 2, 42.00, 52682.28, 0.08, 0.07, +'R', 'F', '1995-05-30', '1995-06-20', '1995-06-04', 'NONE', 'AIR', 'carefully final requests. furiously final'); +INSERT INTO lineitem VALUES(520707, 19569 , 839, 2, 31.00, 46145.36, 0.08, 0.03, + 'N', 'O', '1996-07-20', '1996-07-02', '1996-07-30', 'NONE', 'AIR' , 'y pending shea'); +INSERT INTO lineitem VALUES(584192, 5740, 996, 1, 28.00, 46080.72, 0.09, 0.03, + 'N', 'O', '1995-06-28', '1995-06-14', '1995-07-28', 'TAKE BACK RETURN', 'AIR', 'ual ideas. blithely special acco'); +INSERT INTO lineitem VALUES( 479207, 1238, 741, 5, 30.00, 34176.90, 0.06, 0.03, + 'N', 'O', '1996-03-07', '1996-05-21', '1996-03-20', 'DELIVER IN PERSON', 'RAIL', 'ons. special, pending accounts wake care'); +INSERT INTO `lineitem` VALUES (554307, 299, 800, 5, 31.00, 37177.99, 0.10, 0.03, 'N', 'O', '1998-09-17', '1998-07-20', '1998-09-24', 'TAKE BACK RETURN', 'RAIL', 'carefully regul'); +INSERT INTO `lineitem` VALUES (111521, 316, 817, 2, 27.00, 32840.37, 0.04, 0.05, 'N', 'O', '1997-03-30', '1997-05-09', '1997-04-04', 'DELIVER IN PERSON', 'REG AIR', 'old deposits doubt '); +INSERT INTO `lineitem` VALUES (444225, 119, 370, 1, 44.00, 44840.84, 0.01, 0.01, 'N', 'O', '1996-08-28', '1996-09-06', '1996-09-27', 'COLLECT COD', 'FOB', 'uriously special '); +INSERT INTO `lineitem` VALUES (245857, 119, 370, 4, 42.00, 42802.62, 0.03, 0.08, 'N', 'O', '1996-02-12', '1996-02-12', '1996-02-13', 'TAKE BACK RETURN', 'SHIP', 'tions along the reg'); +INSERT INTO `lineitem` VALUES (132321, 119, 370, 2, 43.00, 43821.73, 0.04, 0.00, 'A', 'F', '1994-03-09', '1994-04-24', '1994-03-12', 'NONE', 'MAIL', 'ickly pendin'); +INSERT INTO `lineitem` VALUES (438816, 119, 370, 1, 39.00, 39745.29, 0.06, 0.07, 'A', 'F', '1993-05-11', '1993-04-22', '1993-05-24', 'TAKE BACK RETURN', 'TRUCK', ' special accounts nag '); +INSERT INTO `lineitem` VALUES (74497, 119, 370, 4, 38.00, 38726.18, 0.09, 0.01, 'A', 'F', '1993-02-24', '1993-01-31', '1993-03-04', 'DELIVER IN PERSON', 'REG AIR', 'ckages among the car'); +INSERT INTO `lineitem` VALUES (89510, 316, 567, 2, 46.00, 55950.26, 0.05, 0.07, 'N', 'O', '1998-08-01', '1998-06-29', '1998-08-13', 'NONE', 'SHIP', 'packages are blithely final requests. car'); +INSERT INTO `lineitem` VALUES (157444, 177, 678, 7, 6.00, 6463.02, 0.01, 0.08, 'N', 'O', '1997-03-06', '1997-03-25', '1997-03-28', 'NONE', 'TRUCK', 'es against the regular instr'); +INSERT INTO `lineitem` VALUES (233090, 177, 678, 2, 1.00, 1077.17, 0.07, 0.06, 'N', 'O', '1996-05-03', '1996-06-19', '1996-05-23', 'NONE', 'MAIL', 'stealthily slyly idle dolphins. regular i'); +INSERT INTO `lineitem` VALUES (287744, 316, 567, 3, 6.00, 7297.86, 0.07, 0.06, 'R', 'F', '1995-04-14', '1995-03-15', '1995-04-16', 'TAKE BACK RETURN', 'REG AIR', ' express foxes. dep'); +INSERT INTO `lineitem` VALUES (91747, 300, 801, 7, 9.00, 10802.70, 0.04, 0.06, 'R', 'F', '1994-09-28', '1994-12-10', '1994-10-19', 'NONE', 'MAIL', 'detect slyly plat'); +INSERT INTO `lineitem` VALUES (54277, 177, 678, 3, 32.00, 34469.44, 0.02, 0.03, 'A', 'F', '1993-02-17', '1993-03-05', '1993-02-28', 'DELIVER IN PERSON', 'AIR', ' fluffy, ironic packages. furiou'); +INSERT INTO `lineitem` VALUES (75299, 177, 678, 2, 32.00, 34469.44, 0.04, 0.07, 'R', 'F', '1993-04-15', '1993-01-19', '1993-04-25', 'TAKE BACK RETURN', 'SHIP', 'ding decoys cajole slyly. bravely bold'); +INSERT INTO `lineitem` VALUES (529379, 299, 300, 2, 18.00, 21587.22, 0.08, 0.02, 'N', 'O', '1998-07-06', '1998-06-18', '1998-08-01', 'TAKE BACK RETURN', 'AIR', 'es are furiously across the fi'); +INSERT INTO `lineitem` VALUES (32005, 242, 743, 1, 48.00, 54827.52, 0.05, 0.06, 'N', 'O', '1997-08-07', '1997-07-01', '1997-08-30', 'TAKE BACK RETURN', 'TRUCK', ' slyly along the furiously express'); +INSERT INTO `lineitem` VALUES (7907, 242, 743, 3, 42.00, 47974.08, 0.01, 0.04, 'N', 'O', '1996-12-02', '1996-11-22', '1996-12-08', 'DELIVER IN PERSON', 'SHIP', 'nst the sometimes pending pa'); +INSERT INTO `lineitem` VALUES (196260, 242, 993, 2, 20.00, 22844.80, 0.07, 0.00, 'N', 'O', '1996-02-19', '1996-03-01', '1996-03-01', 'TAKE BACK RETURN', 'AIR', 'al ideas wake carefully quickly unusu'); +INSERT INTO `lineitem` VALUES (346592, 242, 743, 5, 18.00, 20560.32, 0.10, 0.03, 'A', 'F', '1994-12-05', '1994-10-17', '1994-12-26', 'DELIVER IN PERSON', 'RAIL', 'y alongside of the furious'); +INSERT INTO `lineitem` VALUES (388736, 242, 743, 2, 43.00, 49116.32, 0.06, 0.04, 'A', 'F', '1993-05-11', '1993-04-27', '1993-05-15', 'COLLECT COD', 'TRUCK', 'blithely special dolphi'); +INSERT INTO `lineitem` VALUES (552771, 242, 743, 2, 1.00, 1142.24, 0.06, 0.01, 'A', 'F', '1992-08-09', '1992-07-02', '1992-08-25', 'TAKE BACK RETURN', 'TRUCK', 'unusual deposits. slyly express i'); +INSERT INTO `lineitem` VALUES (56134, 886, 887, 4, 24.00, 42885.12, 0.07, 0.02, 'N', 'O', '1998-05-31', '1998-06-29', '1998-06-23', 'COLLECT COD', 'TRUCK', 'l packages maintain about '); +INSERT INTO `lineitem` VALUES (226145, 474, 475, 4, 16.00, 21991.52, 0.08, 0.00, 'N', 'O', '1997-11-09', '1998-01-01', '1997-11-22', 'NONE', 'TRUCK', 'arefully final foxes boost furiou'); +INSERT INTO `lineitem` VALUES (35427, 401, 402, 3, 5.00, 6507.00, 0.05, 0.07, 'N', 'O', '1996-05-23', '1996-05-19', '1996-05-24', 'TAKE BACK RETURN', 'REG AIR', 'ully across the quickly '); +INSERT INTO `lineitem` VALUES (183524, 377, 378, 1, 11.00, 14051.07, 0.00, 0.07, 'N', 'O', '1995-09-15', '1995-08-12', '1995-10-10', 'COLLECT COD', 'RAIL', 'sily accor'); +INSERT INTO `lineitem` VALUES (247297, 377, 378, 2, 46.00, 58759.02, 0.07, 0.02, 'R', 'F', '1994-09-18', '1994-10-17', '1994-09-24', 'NONE', 'SHIP', ' deposits. boldly pending deposits'); +INSERT INTO `lineitem` VALUES (201607, 401, 402, 6, 1.00, 1301.40, 0.02, 0.02, 'R', 'F', '1993-02-11', '1993-02-12', '1993-03-10', 'COLLECT COD', 'AIR', 'y unusual packages. blithely regular dino'); +INSERT INTO `lineitem` VALUES (10948, 377, 378, 1, 44.00, 56204.28, 0.09, 0.01, 'A', 'F', '1992-10-24', '1992-10-16', '1992-11-01', 'TAKE BACK RETURN', 'SHIP', 'leep blithely deposits. foxes n'); +INSERT INTO `lineitem` VALUES (519911, 177, 928, 3, 5.00, 5385.85, 0.08, 0.04, 'N', 'O', '1998-06-06', '1998-06-26', '1998-06-10', 'COLLECT COD', 'MAIL', ' fluffily even foxes integrate the'); +INSERT INTO `lineitem` VALUES (292454, 4, 255, 2, 15.00, 13560.00, 0.05, 0.02, 'N', 'O', '1997-11-04', '1997-09-03', '1997-11-09', 'TAKE BACK RETURN', 'MAIL', 'fluffily unusual instructions '); +INSERT INTO `lineitem` VALUES (233921, 83, 584, 2, 45.00, 44238.60, 0.04, 0.04, 'N', 'O', '1996-05-06', '1996-04-14', '1996-05-20', 'COLLECT COD', 'AIR', 't the sauternes wake fluffily alon'); +INSERT INTO `lineitem` VALUES (562599, 4, 255, 4, 19.00, 17176.00, 0.09, 0.00, 'N', 'O', '1995-07-06', '1995-07-08', '1995-08-03', 'TAKE BACK RETURN', 'AIR', 'eposits are acro'); +INSERT INTO `lineitem` VALUES (20199, 4, 255, 1, 29.00, 26216.00, 0.09, 0.01, 'A', 'F', '1994-07-12', '1994-05-28', '1994-07-18', 'COLLECT COD', 'AIR', 'osits use after the furiously express '); +INSERT INTO `lineitem` VALUES (375971, 4, 255, 7, 16.00, 14464.00, 0.10, 0.08, 'A', 'F', '1993-05-02', '1993-06-22', '1993-05-29', 'COLLECT COD', 'MAIL', ' slyly instead of'); +INSERT INTO `lineitem` VALUES (156774, 4, 255, 1, 20.00, 18080.00, 0.07, 0.01, 'A', 'F', '1992-10-21', '1992-10-31', '1992-10-27', 'COLLECT COD', 'MAIL', 't the special package'); +INSERT INTO `lineitem` VALUES (281319, 300, 301, 2, 22.00, 26406.60, 0.10, 0.05, 'N', 'O', '1998-05-27', '1998-05-22', '1998-06-13', 'DELIVER IN PERSON', 'REG AIR', 'theodolites. unusual foxes integrate boldl'); +INSERT INTO `lineitem` VALUES (25029, 300, 301, 2, 12.00, 14403.60, 0.08, 0.04, 'N', 'O', '1998-02-09', '1998-01-18', '1998-02-22', 'COLLECT COD', 'AIR', 's affix blithely regular waters.'); +INSERT INTO `lineitem` VALUES (180997, 316, 67, 4, 22.00, 26758.82, 0.02, 0.06, 'N', 'O', '1996-10-06', '1996-11-17', '1996-11-02', 'DELIVER IN PERSON', 'MAIL', 'counts integrate. carefully even ideas a'); +INSERT INTO `lineitem` VALUES (545542, 300, 301, 1, 43.00, 51612.90, 0.01, 0.06, 'N', 'O', '1995-10-06', '1995-09-11', '1995-10-26', 'NONE', 'TRUCK', 'ts sleep blithely abov'); +INSERT INTO `lineitem` VALUES (111235, 300, 301, 1, 40.00, 48012.00, 0.00, 0.04, 'A', 'F', '1994-06-27', '1994-07-23', '1994-07-11', 'COLLECT COD', 'FOB', 'unusual ideas boost around the blithely fin'); +INSERT INTO `lineitem` VALUES (71975, 316, 67, 4, 50.00, 60815.50, 0.08, 0.03, 'R', 'F', '1993-10-30', '1993-12-06', '1993-11-27', 'DELIVER IN PERSON', 'SHIP', ' haggle quickly against the bl'); +INSERT INTO `lineitem` VALUES (284743, 316, 67, 1, 40.00, 48652.40, 0.09, 0.00, 'R', 'F', '1992-05-18', '1992-04-02', '1992-05-24', 'DELIVER IN PERSON', 'SHIP', 'xcuses. blith'); +INSERT INTO `lineitem` VALUES (239905, 577, 78, 4, 27.00, 39894.39, 0.05, 0.08, 'N', 'O', '1998-05-04', '1998-04-03', '1998-05-16', 'DELIVER IN PERSON', 'REG AIR', 'ously regular '); +INSERT INTO `lineitem` VALUES (77026, 327, 78, 5, 33.00, 40501.56, 0.10, 0.05, 'N', 'O', '1997-04-22', '1997-03-08', '1997-05-03', 'COLLECT COD', 'TRUCK', 'ully even deposits. '); +INSERT INTO `lineitem` VALUES (56902, 577, 78, 5, 45.00, 66490.65, 0.05, 0.01, 'N', 'O', '1996-11-13', '1996-12-17', '1996-11-14', 'DELIVER IN PERSON', 'FOB', ' quickly regular accounts. instructions'); +INSERT INTO `lineitem` VALUES (591970, 327, 78, 3, 40.00, 49092.80, 0.09, 0.08, 'N', 'O', '1995-07-21', '1995-07-08', '1995-08-01', 'NONE', 'MAIL', 's use carefully finally'); +INSERT INTO `lineitem` VALUES (290081, 577, 78, 3, 17.00, 25118.69, 0.04, 0.06, 'R', 'F', '1994-10-01', '1994-09-05', '1994-10-27', 'NONE', 'TRUCK', 'carefully even requests. request'); +INSERT INTO `lineitem` VALUES (240676, 577, 78, 1, 7.00, 10342.99, 0.01, 0.00, 'R', 'F', '1993-10-14', '1993-11-25', '1993-11-12', 'DELIVER IN PERSON', 'RAIL', ' deposits. pending foxes nag. p'); +INSERT INTO `lineitem` VALUES (543332, 327, 78, 3, 33.00, 40501.56, 0.04, 0.02, 'R', 'F', '1993-03-07', '1993-02-04', '1993-03-25', 'NONE', 'REG AIR', 'ically ironic requests. silently sp'); +INSERT INTO `lineitem` VALUES (60162, 242, 243, 1, 25.00, 28556.00, 0.03, 0.00, 'N', 'O', '1998-08-16', '1998-09-06', '1998-08-23', 'COLLECT COD', 'FOB', 'ly. furiously ironic attainments h'); +INSERT INTO `lineitem` VALUES (28391, 242, 243, 3, 12.00, 13706.88, 0.06, 0.04, 'N', 'O', '1998-01-12', '1998-03-16', '1998-01-30', 'COLLECT COD', 'AIR', 'ic ideas. blithely even ideas wak'); +INSERT INTO `lineitem` VALUES (143237, 416, 417, 1, 14.00, 18429.74, 0.10, 0.03, 'N', 'O', '1996-08-26', '1996-07-17', '1996-09-04', 'NONE', 'MAIL', 'y even accoun'); +INSERT INTO `lineitem` VALUES (184738, 416, 417, 5, 28.00, 36859.48, 0.04, 0.07, 'R', 'F', '1995-05-08', '1995-05-23', '1995-05-27', 'DELIVER IN PERSON', 'MAIL', 'slyly bold '); +INSERT INTO `lineitem` VALUES (355009, 450, 451, 5, 30.00, 40513.50, 0.00, 0.05, 'R', 'F', '1995-02-09', '1994-11-15', '1995-02-28', 'NONE', 'SHIP', 'ajole blithely pending requests'); +INSERT INTO `lineitem` VALUES (267012, 242, 243, 2, 9.00, 10280.16, 0.01, 0.04, 'A', 'F', '1993-09-11', '1993-07-04', '1993-09-26', 'NONE', 'RAIL', 'le fluffily. blithely unusual '); +INSERT INTO `lineitem` VALUES (463459, 242, 243, 4, 13.00, 14849.12, 0.05, 0.06, 'R', 'F', '1992-10-06', '1992-12-05', '1992-10-19', 'TAKE BACK RETURN', 'RAIL', 'ounts affix quickly care'); +INSERT INTO `lineitem` VALUES (158240, 3, 254, 6, 23.00, 20769.00, 0.02, 0.08, 'N', 'O', '1998-07-01', '1998-06-17', '1998-07-20', 'COLLECT COD', 'AIR', 'ounts. quietly ironic '); +INSERT INTO `lineitem` VALUES (101056, 3, 254, 7, 24.00, 21672.00, 0.04, 0.01, 'N', 'O', '1997-06-08', '1997-06-09', '1997-06-27', 'DELIVER IN PERSON', 'FOB', ' the blithely final accounts. silent'); +INSERT INTO `lineitem` VALUES (374149, 3, 254, 1, 39.00, 35217.00, 0.10, 0.08, 'N', 'O', '1996-06-24', '1996-06-25', '1996-07-13', 'TAKE BACK RETURN', 'RAIL', 'iresias boost'); +INSERT INTO `lineitem` VALUES (561857, 3, 254, 3, 44.00, 39732.00, 0.06, 0.00, 'N', 'O', '1996-01-01', '1996-02-23', '1996-01-16', 'COLLECT COD', 'SHIP', 'thely unusual gifts after'); +INSERT INTO `lineitem` VALUES (422529, 3, 254, 2, 45.00, 40635.00, 0.07, 0.03, 'A', 'F', '1994-06-12', '1994-05-19', '1994-07-11', 'TAKE BACK RETURN', 'REG AIR', 'y pending accounts impress acros'); +INSERT INTO `lineitem` VALUES (186275, 3, 254, 5, 10.00, 9030.00, 0.01, 0.03, 'A', 'F', '1993-12-09', '1993-10-15', '1993-12-14', 'COLLECT COD', 'MAIL', 'yly against the express accounts. even re'); +INSERT INTO `lineitem` VALUES (203457, 3, 254, 3, 39.00, 35217.00, 0.00, 0.05, 'R', 'F', '1992-11-01', '1992-09-08', '1992-11-05', 'DELIVER IN PERSON', 'FOB', ' boost quickly even pinto beans! slyly s'); +INSERT INTO `lineitem` VALUES (413282, 35, 786, 2, 17.00, 15895.51, 0.10, 0.08, 'N', 'O', '1998-07-16', '1998-06-16', '1998-07-26', 'TAKE BACK RETURN', 'RAIL', 'lar requests wake blithely ironic, regular '); +INSERT INTO `lineitem` VALUES (93794, 35, 786, 6, 9.00, 8415.27, 0.07, 0.07, 'N', 'O', '1997-11-08', '1997-10-14', '1997-12-08', 'NONE', 'FOB', 'ideas along the always expr'); +INSERT INTO `lineitem` VALUES (550241, 35, 786, 4, 12.00, 11220.36, 0.01, 0.06, 'N', 'O', '1996-01-26', '1996-03-19', '1996-02-12', 'NONE', 'RAIL', 'carefully daring deposits. fluffil'); +INSERT INTO `lineitem` VALUES (340576, 377, 878, 2, 29.00, 37043.73, 0.07, 0.00, 'N', 'O', '1996-03-05', '1996-02-29', '1996-03-20', 'DELIVER IN PERSON', 'RAIL', 'pecial warthogs cajole above t'); +INSERT INTO `lineitem` VALUES (36896, 35, 786, 2, 7.00, 6545.21, 0.08, 0.00, 'R', 'F', '1994-11-10', '1994-12-30', '1994-11-23', 'TAKE BACK RETURN', 'AIR', 's are inside the even, bold accounts. ca'); +INSERT INTO `lineitem` VALUES (71269, 300, 551, 1, 6.00, 7201.80, 0.05, 0.04, 'A', 'F', '1993-03-14', '1993-02-21', '1993-03-27', 'COLLECT COD', 'RAIL', 'ual, ironic requests are regular, even dep'); +INSERT INTO `lineitem` VALUES (391013, 35, 786, 4, 28.00, 26180.84, 0.03, 0.04, 'R', 'F', '1992-05-15', '1992-05-16', '1992-05-21', 'NONE', 'MAIL', 'te according to the instructions. b'); +INSERT INTO `lineitem` VALUES (108838, 201, 702, 5, 15.00, 16518.00, 0.01, 0.06, 'N', 'O', '1998-01-22', '1998-04-03', '1998-02-07', 'DELIVER IN PERSON', 'SHIP', 'equests? q'); +INSERT INTO `lineitem` VALUES (440067, 4, 505, 4, 45.00, 40680.00, 0.02, 0.03, 'N', 'O', '1997-03-20', '1997-05-18', '1997-04-02', 'TAKE BACK RETURN', 'FOB', 'tect atop the slyly fina'); +INSERT INTO `lineitem` VALUES (79333, 175, 676, 5, 31.00, 33330.27, 0.02, 0.00, 'N', 'O', '1996-06-21', '1996-07-11', '1996-06-28', 'NONE', 'SHIP', 'requests agai'); +INSERT INTO `lineitem` VALUES (248417, 4, 505, 3, 41.00, 37064.00, 0.08, 0.02, 'N', 'O', '1995-10-13', '1995-11-05', '1995-10-24', 'DELIVER IN PERSON', 'FOB', 'ag furiously. carefully even deposit'); +INSERT INTO `lineitem` VALUES (247557, 83, 834, 3, 4.00, 3932.32, 0.10, 0.07, 'A', 'F', '1994-12-31', '1995-01-09', '1995-01-19', 'COLLECT COD', 'REG AIR', ' pinto beans sublate. epitaphs h'); +INSERT INTO `lineitem` VALUES (24866, 4, 505, 4, 22.00, 19888.00, 0.09, 0.03, 'A', 'F', '1994-01-14', '1994-02-06', '1994-01-31', 'NONE', 'SHIP', 'rts. requests nag quickly to the'); +INSERT INTO `lineitem` VALUES (439175, 83, 834, 1, 47.00, 46204.76, 0.07, 0.03, 'A', 'F', '1992-10-02', '1992-08-06', '1992-10-17', 'TAKE BACK RETURN', 'FOB', ' after the quickly'); +INSERT INTO `lineitem` VALUES (442278, 3, 504, 2, 12.00, 10836.00, 0.08, 0.05, 'N', 'O', '1998-05-28', '1998-05-15', '1998-06-18', 'TAKE BACK RETURN', 'SHIP', 'requests sleep blithely f'); +INSERT INTO `lineitem` VALUES (498596, 3, 504, 5, 46.00, 41538.00, 0.07, 0.03, 'N', 'O', '1997-06-22', '1997-07-17', '1997-07-11', 'COLLECT COD', 'REG AIR', 'efully regular instructions. slyly'); +INSERT INTO `lineitem` VALUES (359047, 489, 240, 6, 31.00, 43073.88, 0.07, 0.03, 'N', 'O', '1996-12-14', '1996-11-08', '1996-12-15', 'DELIVER IN PERSON', 'AIR', 's! silent packages sleep fluf'); +INSERT INTO `lineitem` VALUES (480391, 3, 504, 5, 38.00, 34314.00, 0.06, 0.00, 'N', 'O', '1995-10-03', '1995-09-25', '1995-10-16', 'NONE', 'TRUCK', 'r packages. quickly ironic pinto beans was'); +INSERT INTO `lineitem` VALUES (358918, 35, 286, 2, 41.00, 38336.23, 0.05, 0.04, 'A', 'F', '1994-05-23', '1994-07-21', '1994-05-31', 'DELIVER IN PERSON', 'FOB', 'ular accounts. quickly silent ideas use sl'); +INSERT INTO `lineitem` VALUES (408641, 3, 504, 3, 15.00, 13545.00, 0.09, 0.01, 'R', 'F', '1993-09-17', '1993-09-23', '1993-10-13', 'TAKE BACK RETURN', 'REG AIR', 'lets sleep: furiou'); +INSERT INTO `lineitem` VALUES (117221, 175, 176, 3, 34.00, 36555.78, 0.02, 0.05, 'A', 'F', '1993-01-11', '1993-01-22', '1993-01-30', 'COLLECT COD', 'AIR', 'e quickly even f'); +INSERT INTO `lineitem` VALUES (204871, 362, 613, 1, 6.00, 7574.16, 0.09, 0.02, 'N', 'O', '1998-04-05', '1998-05-20', '1998-04-17', 'NONE', 'AIR', ' blithely furiously bold ideas. regular,'); +INSERT INTO `lineitem` VALUES (67426, 4, 5, 4, 17.00, 15368.00, 0.07, 0.08, 'N', 'O', '1997-04-09', '1997-04-15', '1997-04-24', 'DELIVER IN PERSON', 'AIR', 'er the even excuses are furiously regula'); +INSERT INTO `lineitem` VALUES (156000, 4, 5, 3, 16.00, 14464.00, 0.09, 0.04, 'N', 'O', '1996-11-20', '1997-01-05', '1996-12-17', 'DELIVER IN PERSON', 'FOB', 'ronic ideas sleep'); +INSERT INTO `lineitem` VALUES (68322, 242, 493, 1, 41.00, 46831.84, 0.02, 0.06, 'N', 'O', '1996-02-02', '1996-01-02', '1996-02-05', 'NONE', 'AIR', 'imes final the'); +INSERT INTO `lineitem` VALUES (185315, 4, 5, 2, 28.00, 25312.00, 0.08, 0.01, 'A', 'F', '1994-09-08', '1994-10-31', '1994-10-05', 'TAKE BACK RETURN', 'AIR', ' express instructions'); +INSERT INTO `lineitem` VALUES (380708, 4, 5, 3, 14.00, 12656.00, 0.10, 0.07, 'R', 'F', '1993-05-14', '1993-05-23', '1993-06-07', 'DELIVER IN PERSON', 'FOB', 'olve blithely regular plat'); +INSERT INTO `lineitem` VALUES (214951, 362, 113, 4, 24.00, 30296.64, 0.09, 0.04, 'A', 'F', '1992-08-11', '1992-07-06', '1992-08-23', 'NONE', 'SHIP', 're against the regular re'); +INSERT INTO `lineitem` VALUES (370689, 86, 337, 2, 6.00, 5916.48, 0.01, 0.06, 'N', 'O', '1998-07-16', '1998-08-19', '1998-07-26', 'DELIVER IN PERSON', 'AIR', 'n enticingly '); +INSERT INTO `lineitem` VALUES (408548, 299, 550, 2, 14.00, 16790.06, 0.09, 0.08, 'N', 'O', '1997-05-23', '1997-06-21', '1997-06-03', 'NONE', 'AIR', 'y according to '); +INSERT INTO `lineitem` VALUES (455750, 86, 837, 1, 2.00, 1972.16, 0.08, 0.04, 'N', 'O', '1996-09-17', '1996-08-16', '1996-09-19', 'NONE', 'RAIL', 'r accounts dazzle clo'); +INSERT INTO `lineitem` VALUES (283046, 86, 837, 5, 37.00, 36484.96, 0.05, 0.08, 'N', 'O', '1995-12-09', '1996-02-10', '1995-12-30', 'TAKE BACK RETURN', 'MAIL', 'uriously carefully p'); +INSERT INTO `lineitem` VALUES (92258, 86, 837, 5, 19.00, 18735.52, 0.08, 0.05, 'A', 'F', '1994-05-22', '1994-06-01', '1994-06-13', 'COLLECT COD', 'FOB', 'pinto beans'); +INSERT INTO `lineitem` VALUES (206208, 86, 337, 1, 21.00, 20707.68, 0.06, 0.02, 'A', 'F', '1993-12-16', '1993-11-16', '1994-01-15', 'TAKE BACK RETURN', 'FOB', 'ndencies. blit'); +INSERT INTO `lineitem` VALUES (145507, 86, 837, 1, 17.00, 16763.36, 0.07, 0.05, 'R', 'F', '1992-10-12', '1992-09-15', '1992-11-09', 'TAKE BACK RETURN', 'AIR', 'regular dolphins. furiously'); +INSERT INTO `lineitem` VALUES (153351, 35, 36, 3, 33.00, 30855.99, 0.05, 0.08, 'N', 'O', '1998-05-16', '1998-05-23', '1998-05-24', 'COLLECT COD', 'AIR', 'e quickly above'); +INSERT INTO `lineitem` VALUES (466977, 35, 36, 5, 42.00, 39271.26, 0.07, 0.04, 'N', 'O', '1997-10-04', '1997-10-16', '1997-10-28', 'COLLECT COD', 'REG AIR', 'tes are blithely final pa'); +INSERT INTO `lineitem` VALUES (103810, 35, 36, 1, 38.00, 35531.14, 0.06, 0.02, 'N', 'O', '1996-06-13', '1996-08-13', '1996-06-25', 'NONE', 'RAIL', 'le on the requ'); +INSERT INTO `lineitem` VALUES (110178, 35, 36, 2, 41.00, 38336.23, 0.07, 0.02, 'N', 'O', '1995-08-04', '1995-07-20', '1995-09-03', 'DELIVER IN PERSON', 'REG AIR', 'yly regular'); +INSERT INTO `lineitem` VALUES (13698, 35, 36, 1, 50.00, 46751.50, 0.03, 0.03, 'A', 'F', '1994-09-23', '1994-11-01', '1994-09-26', 'TAKE BACK RETURN', 'MAIL', 'ffily express accounts use after th'); +INSERT INTO `lineitem` VALUES (172710, 35, 36, 1, 45.00, 42076.35, 0.10, 0.07, 'A', 'F', '1993-11-15', '1994-01-13', '1993-12-13', 'NONE', 'SHIP', 'ges wake after the furious'); +INSERT INTO `lineitem` VALUES (528513, 326, 577, 4, 24.00, 29431.68, 0.09, 0.00, 'R', 'F', '1992-08-27', '1992-07-31', '1992-09-21', 'DELIVER IN PERSON', 'RAIL', 'integrate carefully aft'); +INSERT INTO `lineitem` VALUES (420295, 7, 508, 2, 49.00, 44443.00, 0.09, 0.04, 'N', 'O', '1998-03-09', '1998-03-30', '1998-03-11', 'TAKE BACK RETURN', 'RAIL', 'al deposits. thinly exp'); +INSERT INTO `lineitem` VALUES (150465, 257, 508, 4, 1.00, 1157.25, 0.01, 0.06, 'N', 'O', '1997-03-12', '1997-02-26', '1997-04-06', 'COLLECT COD', 'RAIL', 'yly final packages are furiously. '); +INSERT INTO `lineitem` VALUES (139616, 257, 508, 1, 32.00, 37032.00, 0.00, 0.04, 'N', 'O', '1997-03-05', '1997-01-20', '1997-03-28', 'DELIVER IN PERSON', 'TRUCK', 'ainst the fu'); +INSERT INTO `lineitem` VALUES (180832, 7, 508, 4, 13.00, 11791.00, 0.06, 0.08, 'N', 'O', '1996-02-22', '1996-01-18', '1996-02-25', 'COLLECT COD', 'TRUCK', 'ross the slyly silent accoun'); +INSERT INTO `lineitem` VALUES (312962, 257, 508, 1, 6.00, 6943.50, 0.02, 0.02, 'R', 'F', '1994-05-19', '1994-04-11', '1994-06-08', 'NONE', 'REG AIR', ' regular ideas haggle blithely slyly iron'); +INSERT INTO `lineitem` VALUES (111942, 7, 508, 1, 19.00, 17233.00, 0.00, 0.02, 'R', 'F', '1993-05-05', '1993-04-03', '1993-05-23', 'DELIVER IN PERSON', 'REG AIR', 'usual ideas nag ruthlessly slyl'); +INSERT INTO `lineitem` VALUES (188032, 257, 508, 4, 12.00, 13887.00, 0.00, 0.05, 'R', 'F', '1992-09-18', '1992-07-21', '1992-10-16', 'NONE', 'TRUCK', 'e slyly. quickly special '); +INSERT INTO `lineitem` VALUES (315844, 557, 808, 2, 49.00, 71419.95, 0.00, 0.03, 'N', 'O', '1998-11-24', '1998-08-28', '1998-12-16', 'NONE', 'MAIL', 'efully. slyly ruthless ideas use fluffily '); +INSERT INTO `lineitem` VALUES (324771, 3, 4, 3, 21.00, 18963.00, 0.09, 0.00, 'N', 'O', '1997-03-07', '1997-04-06', '1997-03-20', 'NONE', 'SHIP', 'uriously acro'); +INSERT INTO `lineitem` VALUES (323234, 3, 4, 1, 3.00, 2709.00, 0.03, 0.04, 'N', 'O', '1996-12-24', '1997-02-03', '1997-01-12', 'COLLECT COD', 'REG AIR', 'es cajole sl'); +INSERT INTO `lineitem` VALUES (229475, 3, 4, 2, 43.00, 38829.00, 0.04, 0.03, 'N', 'O', '1996-03-10', '1996-02-12', '1996-03-26', 'DELIVER IN PERSON', 'AIR', 'counts use fluffily final dependencies. re'); +INSERT INTO `lineitem` VALUES (364805, 3, 4, 2, 7.00, 6321.00, 0.10, 0.02, 'A', 'F', '1994-09-11', '1994-07-01', '1994-10-06', 'COLLECT COD', 'FOB', 's are quickly according to the reque'); +INSERT INTO `lineitem` VALUES (246052, 4, 755, 1, 22.00, 19888.00, 0.07, 0.06, 'A', 'F', '1993-11-04', '1993-09-17', '1993-11-17', 'NONE', 'REG AIR', 'egular idea'); +INSERT INTO `lineitem` VALUES (159940, 3, 4, 2, 27.00, 24381.00, 0.02, 0.02, 'A', 'F', '1992-10-28', '1993-01-10', '1992-11-20', 'NONE', 'RAIL', ' boldly silent asymptotes a'); +INSERT INTO `lineitem` VALUES (88773, 177, 178, 1, 27.00, 29083.59, 0.03, 0.06, 'N', 'O', '1998-05-10', '1998-06-09', '1998-05-28', 'NONE', 'REG AIR', 'es. blithely even requests s'); +INSERT INTO `lineitem` VALUES (61059, 177, 178, 3, 19.00, 20466.23, 0.00, 0.06, 'N', 'O', '1998-03-31', '1998-01-24', '1998-04-15', 'NONE', 'TRUCK', 'aintain. expre'); +INSERT INTO `lineitem` VALUES (75712, 177, 178, 3, 7.00, 7540.19, 0.02, 0.03, 'N', 'O', '1996-04-19', '1996-03-30', '1996-04-25', 'COLLECT COD', 'AIR', ' furiously according to the special fox'); +INSERT INTO `lineitem` VALUES (502210, 177, 178, 1, 12.00, 12926.04, 0.09, 0.00, 'N', 'O', '1995-11-07', '1995-09-16', '1995-11-27', 'TAKE BACK RETURN', 'RAIL', 'es poach. blithely '); +INSERT INTO `lineitem` VALUES (581318, 177, 178, 7, 10.00, 10771.70, 0.10, 0.03, 'R', 'F', '1994-11-02', '1994-12-09', '1994-11-08', 'DELIVER IN PERSON', 'REG AIR', 'ets. blithely regular excuses boost flu'); +INSERT INTO `lineitem` VALUES (262180, 177, 178, 1, 35.00, 37700.95, 0.06, 0.00, 'R', 'F', '1993-03-23', '1993-04-23', '1993-03-26', 'COLLECT COD', 'TRUCK', 'lar ideas. fluff'); +INSERT INTO `lineitem` VALUES (442529, 177, 178, 3, 17.00, 18311.89, 0.07, 0.03, 'R', 'F', '1992-10-22', '1992-10-27', '1992-11-17', 'TAKE BACK RETURN', 'RAIL', 'wake carefu'); +INSERT INTO `lineitem` VALUES (393062, 7, 8, 1, 47.00, 42629.00, 0.02, 0.02, 'N', 'O', '1998-07-19', '1998-06-30', '1998-07-20', 'DELIVER IN PERSON', 'FOB', 'quests. request'); +INSERT INTO `lineitem` VALUES (440802, 7, 8, 2, 49.00, 44443.00, 0.07, 0.06, 'N', 'O', '1997-08-06', '1997-08-20', '1997-08-18', 'TAKE BACK RETURN', 'TRUCK', 's engage. re'); +INSERT INTO `lineitem` VALUES (129282, 3, 754, 5, 45.00, 40635.00, 0.02, 0.02, 'N', 'O', '1996-11-03', '1996-08-15', '1996-11-18', 'DELIVER IN PERSON', 'SHIP', 's haggle above the blithely '); +INSERT INTO `lineitem` VALUES (53189, 3, 754, 2, 3.00, 2709.00, 0.03, 0.01, 'N', 'O', '1995-09-30', '1995-11-07', '1995-10-30', 'COLLECT COD', 'FOB', 'regular ideas. iron'); +INSERT INTO `lineitem` VALUES (220419, 7, 8, 5, 27.00, 24489.00, 0.08, 0.01, 'A', 'F', '1994-04-22', '1994-06-03', '1994-05-11', 'DELIVER IN PERSON', 'REG AIR', 's haggle carefully against the furio'); +INSERT INTO `lineitem` VALUES (235171, 3, 754, 2, 36.00, 32508.00, 0.08, 0.07, 'R', 'F', '1993-06-28', '1993-08-13', '1993-07-21', 'COLLECT COD', 'FOB', 's nag around the special packag'); +INSERT INTO `lineitem` VALUES (406339, 3, 754, 1, 36.00, 32508.00, 0.05, 0.05, 'A', 'F', '1992-10-03', '1992-08-27', '1992-10-21', 'COLLECT COD', 'FOB', 'ly ironic id'); +INSERT INTO `lineitem` VALUES (78567, 905, 656, 4, 44.00, 79459.60, 0.08, 0.06, 'N', 'O', '1998-08-20', '1998-08-23', '1998-08-21', 'NONE', 'RAIL', 'onic requests haggle fl'); +INSERT INTO `lineitem` VALUES (451809, 674, 925, 3, 6.00, 9448.02, 0.03, 0.04, 'N', 'O', '1997-12-10', '1997-11-02', '1997-12-16', 'TAKE BACK RETURN', 'REG AIR', 'lly ironicall'); +INSERT INTO `lineitem` VALUES (133601, 674, 925, 5, 7.00, 11022.69, 0.02, 0.06, 'N', 'O', '1996-08-22', '1996-08-01', '1996-08-26', 'COLLECT COD', 'SHIP', 'ggle quickly against the bravely unusual a'); +INSERT INTO `lineitem` VALUES (467232, 872, 123, 2, 7.00, 12410.09, 0.01, 0.03, 'R', 'F', '1995-03-22', '1995-03-25', '1995-03-27', 'NONE', 'REG AIR', 'ound the iron'); +INSERT INTO `lineitem` VALUES (208480, 872, 123, 6, 28.00, 49640.36, 0.02, 0.05, 'R', 'F', '1995-02-20', '1995-02-10', '1995-03-14', 'TAKE BACK RETURN', 'FOB', 'ites might hinder alongside of the slo'); +INSERT INTO `lineitem` VALUES (487680, 872, 123, 5, 17.00, 30138.79, 0.02, 0.06, 'R', 'F', '1993-10-04', '1993-12-23', '1993-10-13', 'DELIVER IN PERSON', 'AIR', 's wake blithely final ideas. regul'); +INSERT INTO `lineitem` VALUES (363841, 674, 925, 4, 19.00, 29918.73, 0.10, 0.08, 'A', 'F', '1992-07-10', '1992-06-09', '1992-07-19', 'NONE', 'RAIL', 'ongside of the fluffily regular accounts.'); +INSERT INTO `lineitem` VALUES (216454, 201, 952, 7, 35.00, 38542.00, 0.07, 0.04, 'N', 'O', '1998-03-15', '1998-04-07', '1998-03-27', 'COLLECT COD', 'AIR', 'ly furiously unusual foxes. '); +INSERT INTO `lineitem` VALUES (61954, 201, 952, 2, 30.00, 33036.00, 0.03, 0.06, 'N', 'O', '1997-04-07', '1997-03-30', '1997-04-12', 'TAKE BACK RETURN', 'RAIL', 'lieve at the'); +INSERT INTO `lineitem` VALUES (150531, 201, 952, 2, 9.00, 9910.80, 0.07, 0.05, 'N', 'O', '1996-11-13', '1996-10-04', '1996-12-07', 'DELIVER IN PERSON', 'SHIP', 'efully express packages. slyl'); +INSERT INTO `lineitem` VALUES (265476, 201, 952, 1, 27.00, 29732.40, 0.09, 0.03, 'N', 'F', '1995-05-28', '1995-05-19', '1995-06-25', 'DELIVER IN PERSON', 'RAIL', ' pending theodolites wake. furiously reg'); +INSERT INTO `lineitem` VALUES (205574, 201, 952, 2, 32.00, 35238.40, 0.03, 0.05, 'A', 'F', '1994-06-26', '1994-05-01', '1994-07-03', 'COLLECT COD', 'TRUCK', ' carefully bold pinto beans wake sl'); +INSERT INTO `lineitem` VALUES (474403, 201, 952, 2, 48.00, 52857.60, 0.01, 0.06, 'R', 'F', '1993-08-14', '1993-07-30', '1993-09-13', 'DELIVER IN PERSON', 'TRUCK', 'permanent, even ideas integrate c'); +INSERT INTO `lineitem` VALUES (94338, 201, 952, 5, 38.00, 41845.60, 0.01, 0.03, 'A', 'F', '1992-12-26', '1992-12-13', '1993-01-14', 'DELIVER IN PERSON', 'RAIL', 'ironic asymptotes sleep ab'); +INSERT INTO `lineitem` VALUES (126337, 327, 578, 3, 47.00, 57684.04, 0.10, 0.01, 'N', 'O', '1998-05-26', '1998-04-27', '1998-06-17', 'COLLECT COD', 'SHIP', 'ng to the '); +INSERT INTO `lineitem` VALUES (121606, 327, 578, 1, 48.00, 58911.36, 0.00, 0.07, 'N', 'O', '1997-03-15', '1997-05-09', '1997-03-26', 'DELIVER IN PERSON', 'RAIL', 'its. ironic requests was. ironic acc'); +INSERT INTO `lineitem` VALUES (509413, 327, 578, 5, 10.00, 12273.20, 0.07, 0.06, 'N', 'O', '1996-05-14', '1996-07-11', '1996-06-02', 'NONE', 'AIR', 'r theodoli'); +INSERT INTO `lineitem` VALUES (192197, 327, 578, 1, 2.00, 2454.64, 0.02, 0.02, 'N', 'O', '1995-11-13', '1995-10-02', '1995-11-29', 'COLLECT COD', 'RAIL', ', regular epitaphs haggle slyly final dep'); +INSERT INTO `lineitem` VALUES (32358, 327, 578, 6, 38.00, 46638.16, 0.07, 0.07, 'A', 'F', '1994-08-01', '1994-07-30', '1994-08-20', 'DELIVER IN PERSON', 'REG AIR', 'unts are care'); +INSERT INTO `lineitem` VALUES (42375, 327, 578, 3, 49.00, 60138.68, 0.06, 0.02, 'A', 'F', '1993-11-11', '1993-12-24', '1993-12-07', 'NONE', 'REG AIR', ' x-ray carefully bold instru'); +INSERT INTO `lineitem` VALUES (53984, 327, 578, 1, 18.00, 22091.76, 0.03, 0.08, 'A', 'F', '1993-01-19', '1993-02-10', '1993-01-24', 'COLLECT COD', 'TRUCK', 'thy deposits. silent requests agains'); +INSERT INTO `lineitem` VALUES (52167, 175, 426, 2, 22.00, 23653.74, 0.09, 0.04, 'N', 'O', '1998-08-03', '1998-08-23', '1998-08-08', 'TAKE BACK RETURN', 'TRUCK', 'ess deposits eat blithely. brave '); +INSERT INTO `lineitem` VALUES (350083, 175, 426, 2, 23.00, 24728.91, 0.10, 0.07, 'N', 'O', '1997-09-15', '1997-08-01', '1997-10-12', 'NONE', 'TRUCK', 'accounts wake accounts. packages wake fi'); +INSERT INTO `lineitem` VALUES (407073, 1436, 939, 3, 38.00, 50822.34, 0.07, 0.01, 'N', 'O', '1996-06-07', '1996-05-05', '1996-06-13', 'NONE', 'TRUCK', ' bold accounts. final acco'); +INSERT INTO `lineitem` VALUES (22532, 201, 202, 1, 9.00, 9910.80, 0.08, 0.00, 'R', 'F', '1995-06-07', '1995-04-22', '1995-06-08', 'TAKE BACK RETURN', 'AIR', ' the express, slow theodoli'); +INSERT INTO `lineitem` VALUES (19047, 175, 426, 2, 45.00, 48382.65, 0.03, 0.01, 'A', 'F', '1994-03-20', '1994-03-09', '1994-03-22', 'DELIVER IN PERSON', 'FOB', 'pending, daring '); +INSERT INTO `lineitem` VALUES (166243, 201, 202, 2, 25.00, 27530.00, 0.06, 0.03, 'R', 'F', '1994-02-09', '1994-03-17', '1994-02-15', 'NONE', 'TRUCK', 'ogs breach blithely ideas. unusual reques'); +INSERT INTO `lineitem` VALUES (220421, 175, 426, 3, 23.00, 24728.91, 0.06, 0.05, 'R', 'F', '1992-06-10', '1992-04-02', '1992-06-18', 'TAKE BACK RETURN', 'RAIL', 'unusual deposits accordin'); +INSERT INTO `lineitem` VALUES (9287, 83, 84, 1, 16.00, 15729.28, 0.07, 0.00, 'N', 'O', '1998-03-25', '1998-02-10', '1998-04-16', 'DELIVER IN PERSON', 'FOB', 'ironic accounts sl'); +INSERT INTO `lineitem` VALUES (45862, 83, 84, 3, 1.00, 983.08, 0.00, 0.02, 'N', 'O', '1997-07-17', '1997-08-19', '1997-07-22', 'COLLECT COD', 'SHIP', 'accounts-- fluffily pending deposits a'); +INSERT INTO `lineitem` VALUES (92002, 83, 84, 1, 45.00, 44238.60, 0.01, 0.06, 'N', 'O', '1996-12-26', '1996-10-17', '1996-12-28', 'COLLECT COD', 'SHIP', 'ts. blithely even '); +INSERT INTO `lineitem` VALUES (389633, 336, 87, 2, 2.00, 2472.66, 0.09, 0.06, 'N', 'O', '1995-07-14', '1995-04-21', '1995-07-23', 'DELIVER IN PERSON', 'AIR', 'thely about the carefully'); +INSERT INTO `lineitem` VALUES (96739, 83, 84, 1, 48.00, 47187.84, 0.04, 0.00, 'R', 'F', '1994-08-24', '1994-08-14', '1994-09-22', 'NONE', 'REG AIR', 'sual accounts sle'); +INSERT INTO `lineitem` VALUES (575109, 83, 84, 2, 35.00, 34407.80, 0.09, 0.02, 'R', 'F', '1993-05-21', '1993-06-19', '1993-06-11', 'TAKE BACK RETURN', 'FOB', '. blithely ironic ideas after the carefull'); +INSERT INTO `lineitem` VALUES (284578, 83, 84, 2, 14.00, 13763.12, 0.03, 0.08, 'R', 'F', '1992-03-13', '1992-05-14', '1992-03-29', 'TAKE BACK RETURN', 'SHIP', 'lar requests. ironic packages nag '); +INSERT INTO `lineitem` VALUES (351843, 327, 828, 4, 11.00, 13500.52, 0.02, 0.04, 'N', 'O', '1998-03-21', '1998-04-30', '1998-04-05', 'NONE', 'TRUCK', 'ly silent requests-- fina'); +INSERT INTO `lineitem` VALUES (19014, 119, 870, 5, 38.00, 38726.18, 0.10, 0.05, 'N', 'O', '1997-10-08', '1997-11-23', '1997-10-26', 'NONE', 'REG AIR', 'sual theodol'); +INSERT INTO `lineitem` VALUES (22436, 362, 863, 3, 27.00, 34083.72, 0.10, 0.00, 'N', 'O', '1996-06-17', '1996-06-23', '1996-06-23', 'TAKE BACK RETURN', 'REG AIR', 'ackages haggle slyly '); +INSERT INTO `lineitem` VALUES (59108, 119, 870, 6, 21.00, 21401.31, 0.00, 0.06, 'N', 'O', '1995-11-16', '1995-12-13', '1995-11-27', 'DELIVER IN PERSON', 'SHIP', ' slyly. stealthily slow requests solve'); +INSERT INTO `lineitem` VALUES (593637, 327, 828, 6, 11.00, 13500.52, 0.03, 0.06, 'R', 'F', '1994-11-22', '1994-12-23', '1994-12-02', 'DELIVER IN PERSON', 'AIR', 'sly regular instructions.'); +INSERT INTO `lineitem` VALUES (15744, 119, 870, 1, 17.00, 17324.87, 0.10, 0.05, 'R', 'F', '1993-06-20', '1993-05-29', '1993-07-09', 'DELIVER IN PERSON', 'RAIL', 'quickly final requests sle'); +INSERT INTO `lineitem` VALUES (303877, 362, 863, 3, 39.00, 49232.04, 0.00, 0.01, 'A', 'F', '1992-11-28', '1992-12-18', '1992-11-29', 'DELIVER IN PERSON', 'MAIL', 'furiously.'); + +ANALYZE TABLE supplier; +ANALYZE TABLE lineitem; +ANALYZE TABLE orders; +ANALYZE TABLE customer; +ANALYZE TABLE nation; +ANALYZE TABLE part; +ANALYZE TABLE partsupp; + +explain select + supp_nation, + cust_nation, + l_year, + sum(volume) as revenue +from + ( + select + n1.n_name as supp_nation, + n2.n_name as cust_nation, + extract(year from l_shipdate) as l_year, + l_extendedprice * (1 - l_discount) as volume + from + supplier, + lineitem, + orders, + customer, + nation n1, + nation n2 + where + s_suppkey = l_suppkey + and o_orderkey = l_orderkey + and c_custkey = o_custkey + and s_nationkey = n1.n_nationkey + and c_nationkey = n2.n_nationkey + and ( + (n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') + or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE') + ) + and l_shipdate between date '1995-01-01' and date '1996-12-31' + ) as shipping +group by + supp_nation, + cust_nation, + l_year +order by + supp_nation, + cust_nation, + l_year; +select + supp_nation, + cust_nation, + l_year, + sum(volume) as revenue +from + ( + select + n1.n_name as supp_nation, + n2.n_name as cust_nation, + extract(year from l_shipdate) as l_year, + l_extendedprice * (1 - l_discount) as volume + from + supplier, + lineitem, + orders, + customer, + nation n1, + nation n2 + where + s_suppkey = l_suppkey + and o_orderkey = l_orderkey + and c_custkey = o_custkey + and s_nationkey = n1.n_nationkey + and c_nationkey = n2.n_nationkey + and ( + (n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') + or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE') + ) + and l_shipdate between date '1995-01-01' and date '1996-12-31' + ) as shipping +group by + supp_nation, + cust_nation, + l_year +order by + supp_nation, + cust_nation, + l_year; + +explain select + nation, + o_year, + sum(amount) as sum_profit +from + ( + select + n_name as nation, + extract(year from o_orderdate) as o_year, + l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount + from + part, + supplier, + lineitem, + partsupp, + orders, + nation + where + s_suppkey = l_suppkey + and ps_suppkey = l_suppkey + and ps_partkey = l_partkey + and p_partkey = l_partkey + and o_orderkey = l_orderkey + and s_nationkey = n_nationkey + and p_name like '%green%' + ) as profit +group by + nation, + o_year +order by + nation, + o_year desc; +select + nation, + o_year, + sum(amount) as sum_profit +from + ( + select + n_name as nation, + extract(year from o_orderdate) as o_year, + l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount + from + part, + supplier, + lineitem, + partsupp, + orders, + nation + where + s_suppkey = l_suppkey + and ps_suppkey = l_suppkey + and ps_partkey = l_partkey + and p_partkey = l_partkey + and o_orderkey = l_orderkey + and s_nationkey = n_nationkey + and p_name like '%green%' + ) as profit +group by + nation, + o_year +order by + nation, + o_year desc; + +drop table partsupp; +drop table supplier; +drop table lineitem; +drop table orders; +drop table customer; +drop table nation; +drop table part; +drop database pq_database; \ No newline at end of file diff --git a/mysql-test/suite/parallel_query/t/pq_variables.test b/mysql-test/suite/parallel_query/t/pq_variables.test new file mode 100644 index 000000000..dd015c99b --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_variables.test @@ -0,0 +1,129 @@ +--source include/not_valgrind.inc +--source include/pq_test.inc +--source include/have_debug.inc + +set @saved_force_parallel_execute = @@force_parallel_execute; +set @saved_parallel_cost_threshold = @@parallel_cost_threshold; +set @saved_parallel_default_dop = @@parallel_default_dop; +set @saved_parallel_max_threads = @@parallel_max_threads; + +create table t1(id int); +insert into t1 select 1; + +let $loop=10; +while($loop) +{ + eval insert into t1 select id + 1 from t1; + dec $loop; +} + +set session force_parallel_execute = true; + + +--echo ### test parallel_cost_threadhold + +set session parallel_cost_threshold = 0; +explain select sum(id) from t1; + +set session parallel_cost_threshold = 99999; +explain select sum(id) from t1; + + +--echo ### test parallel_default_dop +set session parallel_cost_threshold = 0; + +set session parallel_default_dop=10; +explain select sum(id) from t1; + +set session parallel_default_dop=2; +explain select sum(id) from t1; + +set session parallel_default_dop=0; +explain select sum(id) from t1; + + +--echo ### test parallel hint +set session parallel_default_dop=4; + +set session force_parallel_execute = false; + +explain select sum(id) from t1; +explain select/*+ PQ */ sum(id) from t1; +explain select/*+ PQ(10) */ sum(id) from t1; + + +--echo ### test force_parallel query +set session parallel_default_dop=4; + +set session force_parallel_execute = false; +explain select sum(id) from t1; + +set session force_parallel_execute = true; +explain select sum(id) from t1; + + +--echo ### test parallel max_threads +set session force_parallel_execute = true; +set session parallel_default_dop=4; + +set global parallel_max_threads = 64; +explain select/*+ PQ(32) */ sum(id) from t1; + +set global parallel_max_threads = 16; +explain select/*+ PQ(32) */ sum(id) from t1; + +set global parallel_max_threads = 64; +explain select/*+ NO_PQ */ sum(id) from t1; + +--echo ### test parallel queue_timeout + +set global parallel_max_threads=8; +set global debug_pq_worker_stall = true; + +connect (con1, localhost, root); +connect (con2, localhost, root); +connect (con3, localhost, root); + +--connection con1 +--send select/*+ PQ(8) */ sum(id) from t1; + +--connection default + +--sleep 1 +show status like "PQ_threads_running"; + +--connection con2 +--echo ----con2 wait parallel threads 5s----- +set session parallel_queue_timeout=5000; # 5000ms +--send explain select/*+ PQ(8) */ sum(id) from t1; + +--connection con3 +--echo ----con3 no wait for parallel threads----- +set session parallel_queue_timeout=0; # 0ms +--send explain select/*+ PQ(8) */ sum(id) from t1; + +--connection default +set global debug_pq_worker_stall = false; + +--connection con1 +--reap + +--connection con2 +--echo ----con2 parallel query----- +--reap + +--connection con3 +--echo ----con3 no parallel query----- +--reap + +disconnect con1; +disconnect con2; +disconnect con3; + +--connection default +set session parallel_default_dop = @saved_parallel_default_dop; +set global parallel_max_threads = @saved_parallel_max_threads; +set session parallel_cost_threshold = @saved_parallel_cost_threshold; +set session force_parallel_execute = @saved_force_parallel_execute; + +drop table t1; diff --git a/mysql-test/suite/parallel_query/t/pq_worker_error.test b/mysql-test/suite/parallel_query/t/pq_worker_error.test new file mode 100644 index 000000000..4ae7bbe3a --- /dev/null +++ b/mysql-test/suite/parallel_query/t/pq_worker_error.test @@ -0,0 +1,183 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +--disable_query_log +CALL mtr.add_suppression("\\[Warning\\] .* worker [0-9]+ has failed to start up*"); +CALL mtr.add_suppression("Make worker plan failed"); +CALL mtr.add_suppression("Create worker tmp tables or make join read info failed"); +CALL mtr.add_suppression("Create worker result mq failed"); +--enable_query_log + +create table t1(id int, a varchar(10)); +insert into t1 values(1, 'aa'), (2, 'bb'); + +set @saved_force_parallel_execute = @@force_parallel_execute; +set session force_parallel_execute = 1; +set session sql_mode = ''; + +--disable_query_log +let $1=500; +while ($1) +{ + eval INSERT INTO t1 VALUES (MOD($1, 43), 'cc'); + dec $1; +} +--enable_query_log + +set session debug=""; +set session debug="+d, pq_worker_abort1"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1; +show status like "PQ_memory_used"; + +set session debug=""; +set session debug="+d, pq_worker_abort2"; +--error ER_PARALLEL_EXEC_ERROR +select a, sum(a) from t1 group by a order by a desc, id; +show status like "PQ_memory_used"; + +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id; +show status like "PQ_memory_used"; + +set @@parallel_default_dop = 8; +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id; + +set session debug=""; +set session debug="+d, pq_worker_error1"; +--error ER_PARALLEL_EXEC_ERROR +select a, sum(a) from t1 group by a order by a desc, id; + +set session debug=""; +set session debug="+d, pq_worker_error2"; +--error ER_PARALLEL_EXEC_ERROR +select a, sum(a) from t1 group by a order by a desc, id; + +set session debug=""; +set session debug="+d, pq_worker_error3"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1 order by id desc, a; + +set session debug=""; +set session debug="+d, pq_worker_error4"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1 order by id desc, a; + +set session debug=""; +set session debug="+d, pq_worker_error5"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1 order by id desc, a; + +set session debug=""; +set session debug="+d, pq_worker_error6"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1; + +set session debug=""; +set session debug="+d, pq_worker_error7"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1; + +set session debug=""; +set session debug="+d, pq_worker_error8"; +--error ER_PARALLEL_EXEC_ERROR +select * from t1; + +set session debug=""; +set session debug="+d, pq_worker_error9"; +select * from t1 limit 15; + +set session debug=""; +set session force_parallel_execute = 0; +select * from t1 limit 15; + +set session force_parallel_execute = 1; +set @@parallel_default_dop = 8; +set session debug=""; +select a, sum(a) from t1 group by a order by a desc, id; +DROP TABLE t1; + +create table t3( + a int NOT NULL, + b int NOT NULL, + c int NOT NULL, + primary key (a, b), + unique key(c) +) ENGINE=Innodb DEFAULT CHARSET=utf8mb4; + +insert into t3 values (1, 1, 2); +insert into t3 values (1, 2, 1); +insert into t3 values (0, 1, 3); +insert into t3 values (1, 0, 4); + +explain select * from t3; + +set session debug=""; +set session debug="+d, pq_msort_error1"; +--error ER_PARALLEL_EXEC_ERROR +select * from t3; + +set session debug=""; +set session debug="+d, pq_msort_error2"; +--error ER_PARALLEL_EXEC_ERROR +select * from t3; + +set session debug=""; +set session debug="+d, pq_msort_error3"; +--error ER_PARALLEL_EXEC_ERROR +select * from t3; + +set session debug=""; +set session debug="+d, pq_msort_error4"; +--error ER_PARALLEL_EXEC_ERROR +select * from t3; + +set session debug=""; +set session debug="+d, pq_msort_error5"; +--error ER_STD_BAD_ALLOC_ERROR +select * from t3 order by a; + +DROP TABLE t3; + +CREATE TABLE t(a varbinary(10)); +INSERT INTO t VALUES(0xFF00F0F0), (0xF0F0FF); +INSERT INTO t VALUES(0xFF00F0F0), (0xF0F000); + +set session debug=""; +--error ER_INVALID_BITWISE_OPERANDS_SIZE +SELECT BIT_AND(a) FROM t; +DROP TABLE t; + +# filesort.cc +create table t1(a int) ; +insert into t1 values(1),(2),(3); + +# Do not mtr.add_suppression here, avoid "Deadlock found ..." messages in log. + +--let $force_parallel_execute=`show variables like 'force_parallel_execute'` +--let $pq_enable = `SELECT SUBSTRING_INDEX('$force_parallel_execute', ' ', -1)` + +set session debug=""; +# no-parallel +if($pq_enable != ON) +{ + set debug='d,bug19656296'; +} + +if($pq_enable == ON) +{ + set session debug='+d,ha_pq_next_deadlock'; +} + +--error ER_LOCK_DEADLOCK +select * from t1 order by a; +drop table t1; +SET debug= DEFAULT; + + +--let $wait_counter= 10000 +--source include/restart_mysqld.inc + + + diff --git a/mysql-test/suite/parts/r/partition_alter3_innodb.result-pq b/mysql-test/suite/parts/r/partition_alter3_innodb.result-pq new file mode 100644 index 000000000..d5c6f47dc --- /dev/null +++ b/mysql-test/suite/parts/r/partition_alter3_innodb.result-pq @@ -0,0 +1,818 @@ +SET @max_row = 20; +SET @@session.default_storage_engine = 'InnoDB'; + +#------------------------------------------------------------------------ +# 0. Setting of auxiliary variables + Creation of an auxiliary tables +# needed in many testcases +#------------------------------------------------------------------------ +SELECT @max_row DIV 2 INTO @max_row_div2; +SELECT @max_row DIV 3 INTO @max_row_div3; +SELECT @max_row DIV 4 INTO @max_row_div4; +SET @max_int_4 = 2147483647; +DROP TABLE IF EXISTS t0_template; +CREATE TABLE t0_template ( +f_int1 INTEGER, +f_int2 INTEGER, +f_char1 CHAR(20), +f_char2 CHAR(20), +f_charbig VARCHAR(1000) , +PRIMARY KEY(f_int1)) +ENGINE = MEMORY; +# Logging of INSERTs into t0_template suppressed +DROP TABLE IF EXISTS t0_definition; +CREATE TABLE t0_definition ( +state CHAR(3), +create_command VARBINARY(5000), +file_list VARBINARY(10000), +PRIMARY KEY (state) +) ENGINE = MEMORY; +DROP TABLE IF EXISTS t0_aux; +CREATE TABLE t0_aux ( f_int1 INTEGER, +f_int2 INTEGER, +f_char1 CHAR(20), +f_char2 CHAR(20), +f_charbig VARCHAR(1000) ) +ENGINE = MEMORY; +SET AUTOCOMMIT= 1; +SET @@session.sql_mode= ''; +# End of basic preparations needed for all tests +#----------------------------------------------- + +#======================================================================== +# 1. Partition management commands on HASH partitioned table +# column in partitioning function is of type DATE +#======================================================================== +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)); +INSERT INTO t1 (f_date, f_varchar) +SELECT CONCAT(CAST((f_int1 + 999) AS CHAR),'-02-10'), CAST(f_char1 AS CHAR) +FROM t0_template +WHERE f_int1 + 999 BETWEEN 1000 AND 9999; +SELECT IF(9999 - 1000 + 1 > @max_row, @max_row , 9999 - 1000 + 1) +INTO @exp_row_count; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +t1.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +#------------------------------------------------------------------------ +# 1.1 Increase number of PARTITIONS +#------------------------------------------------------------------------ +# 1.1.1 ADD PARTITION to not partitioned table --> must fail +ALTER TABLE t1 ADD PARTITION (PARTITION part2); +ERROR HY000: Partition management on a not partitioned table is not possible +# 1.1.2 Assign HASH partitioning +ALTER TABLE t1 PARTITION BY HASH(YEAR(f_date)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) */ +t1#P#p0.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 1.1.3 Assign other HASH partitioning to already partitioned table +# + test and switch back + test +ALTER TABLE t1 PARTITION BY HASH(DAYOFYEAR(f_date)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (dayofyear(`f_date`)) */ +t1#P#p0.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 PARTITION BY HASH(YEAR(f_date)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) */ +t1#P#p0.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 1.1.4 Add PARTITIONS not fitting to HASH --> must fail +ALTER TABLE t1 ADD PARTITION (PARTITION part1 VALUES IN (0)); +ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition +ALTER TABLE t1 ADD PARTITION (PARTITION part2 VALUES LESS THAN (0)); +ERROR HY000: Only RANGE PARTITIONING can use VALUES LESS THAN in partition definition +# 1.1.5 Add two named partitions + test +ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 1.1.6 Add two named partitions, name clash --> must fail +ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7); +ERROR HY000: Duplicate partition name part1 +# 1.1.7 Add one named partition + test +ALTER TABLE t1 ADD PARTITION (PARTITION part2); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 1.1.8 Add four not named partitions + test +ALTER TABLE t1 ADD PARTITION PARTITIONS 4; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB, + PARTITION p5 ENGINE = InnoDB, + PARTITION p6 ENGINE = InnoDB, + PARTITION p7 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#p5.ibd +t1#P#p6.ibd +t1#P#p7.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +#------------------------------------------------------------------------ +# 1.2 Decrease number of PARTITIONS +#------------------------------------------------------------------------ +# 1.2.1 DROP PARTITION is not supported for HASH --> must fail +ALTER TABLE t1 DROP PARTITION part1; +ERROR HY000: DROP PARTITION can only be used on RANGE/LIST partitions +# 1.2.2 COALESCE PARTITION partitionname is not supported +ALTER TABLE t1 COALESCE PARTITION part1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'part1' at line 1 +# 1.2.3 Decrease by 0 is non sense --> must fail +ALTER TABLE t1 COALESCE PARTITION 0; +ERROR HY000: At least one partition must be coalesced +# 1.2.4 COALESCE one partition + test loop +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB, + PARTITION p5 ENGINE = InnoDB, + PARTITION p6 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#p5.ibd +t1#P#p6.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB, + PARTITION p5 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#p5.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY HASH (year(`f_date`)) +(PARTITION p0 ENGINE = InnoDB) */ +t1#P#p0.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 1.2.5 COALESCE of last partition --> must fail +ALTER TABLE t1 COALESCE PARTITION 1; +ERROR HY000: Cannot remove all partitions, use DROP TABLE instead +# 1.2.6 Remove partitioning +ALTER TABLE t1 REMOVE PARTITIONING; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_date` date DEFAULT NULL, + `f_varchar` varchar(30) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +t1.ibd +EXPLAIN SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`f_date` = DATE'1000-02-10') +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 1.2.7 Remove partitioning from not partitioned table --> ???? +ALTER TABLE t1 REMOVE PARTITIONING; +ERROR HY000: Partition management on a not partitioned table is not possible +DROP TABLE t1; +# Attention: There are unused files. +# Either the DROP TABLE or a preceding ALTER TABLE +# worked incomplete. +# We found: +unified filelist +--- not determined --- + +#======================================================================== +# 2. Partition management commands on KEY partitioned table +#======================================================================== +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +f_int1 INTEGER, +f_int2 INTEGER, +f_char1 CHAR(20), +f_char2 CHAR(20), +f_charbig VARCHAR(1000) +); +INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) +SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +t1.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(`count(0)`) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +#------------------------------------------------------------------------ +# 2.1 Increase number of PARTITIONS +# Some negative testcases are omitted (already checked with HASH). +#------------------------------------------------------------------------ +# 2.1.1 Assign KEY partitioning +ALTER TABLE t1 PARTITION BY KEY(f_int1); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) */ +t1#P#p0.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 2.1.2 Add PARTITIONS not fitting to KEY --> must fail +ALTER TABLE t1 ADD PARTITION (PARTITION part1 VALUES IN (0)); +ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition +ALTER TABLE t1 ADD PARTITION (PARTITION part2 VALUES LESS THAN (0)); +ERROR HY000: Only RANGE PARTITIONING can use VALUES LESS THAN in partition definition +# 2.1.3 Add two named partitions + test +ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 2.1.4 Add one named partition + test +ALTER TABLE t1 ADD PARTITION (PARTITION part2); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 2.1.5 Add four not named partitions + test +ALTER TABLE t1 ADD PARTITION PARTITIONS 4; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB, + PARTITION p5 ENGINE = InnoDB, + PARTITION p6 ENGINE = InnoDB, + PARTITION p7 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#p5.ibd +t1#P#p6.ibd +t1#P#p7.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +#------------------------------------------------------------------------ +# 2.2 Decrease number of PARTITIONS +# Some negative testcases are omitted (already checked with HASH). +#------------------------------------------------------------------------ +# 2.2.1 DROP PARTITION is not supported for KEY --> must fail +ALTER TABLE t1 DROP PARTITION part1; +ERROR HY000: DROP PARTITION can only be used on RANGE/LIST partitions +# 2.2.4 COALESCE one partition + test loop +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB, + PARTITION p5 ENGINE = InnoDB, + PARTITION p6 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#p5.ibd +t1#P#p6.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 25.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB, + PARTITION p5 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#p5.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB, + PARTITION p4 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#p4.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB, + PARTITION part2 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part2.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 20.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB, + PARTITION part7 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +t1#P#part7.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 14.29 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB, + PARTITION part1 ENGINE = InnoDB) */ +t1#P#p0.ibd +t1#P#part1.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +/*!50100 PARTITION BY KEY (f_int1) +(PARTITION p0 ENGINE = InnoDB) */ +t1#P#p0.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(0) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 2.2.5 COALESCE of last partition --> must fail +ALTER TABLE t1 COALESCE PARTITION 1; +ERROR HY000: Cannot remove all partitions, use DROP TABLE instead +# 2.2.6 Remove partitioning +ALTER TABLE t1 REMOVE PARTITIONING; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f_int1` int DEFAULT NULL, + `f_int2` int DEFAULT NULL, + `f_char1` char(20) DEFAULT NULL, + `f_char2` char(20) DEFAULT NULL, + `f_charbig` varchar(1000) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +t1.ibd +EXPLAIN SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 20 10.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where +Warnings: +Note 1003 /* select#1 */ select (count(`count(0)`) <> 1) AS `COUNT(*) <> 1` from `test`.`t1` where (`test`.`t1`.`f_int1` = 3) +# check read single success: 1 +# check read all success: 1 +# check read row by row success: 1 +# 2.2.7 Remove partitioning from not partitioned table --> ???? +ALTER TABLE t1 REMOVE PARTITIONING; +ERROR HY000: Partition management on a not partitioned table is not possible +DROP TABLE t1; +# Attention: There are unused files. +# Either the DROP TABLE or a preceding ALTER TABLE +# worked incomplete. +# We found: +unified filelist +--- not determined --- +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t0_aux; +DROP TABLE IF EXISTS t0_definition; +DROP TABLE IF EXISTS t0_template; diff --git a/mysql-test/suite/perfschema/r/batch_table_io_func.result-pq b/mysql-test/suite/perfschema/r/batch_table_io_func.result-pq new file mode 100644 index 000000000..0bc09ff22 --- /dev/null +++ b/mysql-test/suite/perfschema/r/batch_table_io_func.result-pq @@ -0,0 +1,188 @@ +UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES'; +UPDATE performance_schema.setup_instruments SET enabled = 'YES' +WHERE name in ('wait/io/table/sql/handler', +'wait/lock/table/sql/handler'); +drop procedure if exists before_payload; +drop procedure if exists after_payload; +create procedure before_payload() +begin +TRUNCATE TABLE performance_schema.table_io_waits_summary_by_index_usage; +TRUNCATE TABLE performance_schema.table_io_waits_summary_by_table; +TRUNCATE TABLE performance_schema.events_waits_history_long; +TRUNCATE TABLE performance_schema.events_waits_history; +TRUNCATE TABLE performance_schema.events_waits_current; +end +$$ +create procedure after_payload() +begin +select count(1) as number_seen, +OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, +OPERATION, NUMBER_OF_BYTES +from performance_schema.events_waits_history_long +where OBJECT_SCHEMA = "test" + group by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, OPERATION, NUMBER_OF_BYTES; +select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, +COUNT_STAR, COUNT_READ, COUNT_WRITE +from performance_schema.table_io_waits_summary_by_index_usage +where OBJECT_SCHEMA = "test" + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME; +select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, +COUNT_STAR, COUNT_READ, COUNT_WRITE +from performance_schema.table_io_waits_summary_by_table +where OBJECT_SCHEMA = "test" + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +end +$$ +drop table if exists t1; +drop table if exists t2; +drop table if exists t3; +create table t0(v int); +create table t1(id1 int, a int); +create table t2(id1 int, id2 int, b int); +create table t3(id2 int, id3 int, c int); +insert into t0 values +(0), (1), (2), (3), (4), +(5), (6), (7), (8), (9); +insert into t1(id1, a) +select v, 100*v from t0; +insert into t2(id1, id2, b) +select X.v, 10*X.v + Y.v, 100*X.v + 10*Y.v +from t0 X, t0 Y; +insert into t3(id2, id3, c) +select 10*X.v + Y.v, 100*X.v + 10*Y.v + Z.v, 100*X.v + 10*Y.v + Z.v +from t0 X, t0 Y, t0 Z; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status OK +select * from t1 order by a; +id1 a +0 0 +1 100 +2 200 +3 300 +4 400 +5 500 +6 600 +7 700 +8 800 +9 900 +select * from t2 +where (b >= 180) and (b <= 220) +order by b; +id1 id2 b +1 18 180 +1 19 190 +2 20 200 +2 21 210 +2 22 220 +select * from t3 +where (c >= 587) and (c <= 612) +order by c; +id2 id3 c +58 587 587 +58 588 588 +58 589 589 +59 590 590 +59 591 591 +59 592 592 +59 593 593 +59 594 594 +59 595 595 +59 596 596 +59 597 597 +59 598 598 +59 599 599 +60 600 600 +60 601 601 +60 602 602 +60 603 603 +60 604 604 +60 605 605 +60 606 606 +60 607 607 +60 608 608 +60 609 609 +61 610 610 +61 611 611 +61 612 612 +explain select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1000 10.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`id2` = `test`.`t2`.`id2`)) +call before_payload(); +select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +call after_payload(); +number_seen OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME OPERATION NUMBER_OF_BYTES +3 TABLE test t1 NULL read external NULL +3 TABLE test t2 NULL read external NULL +3 TABLE test t3 NULL read external NULL +1 TABLE test t1 NULL fetch 10 +1 TABLE test t2 NULL fetch 100 +1 TABLE test t3 NULL fetch 1000 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 NULL 0 0 0 +TABLE test t1 NULL 10 10 0 +TABLE test t2 NULL 100 100 0 +TABLE test t3 NULL 1000 1000 0 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 0 0 0 +TABLE test t1 10 10 0 +TABLE test t2 100 100 0 +TABLE test t3 1000 1000 0 +alter table t1 add unique index(id1); +alter table t2 add unique index(id2); +alter table t2 add index(id1); +alter table t3 add unique index(id3); +alter table t3 add index(id2); +explain select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 10 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL id1 NULL NULL NULL 10 100.00 Using where +2 SIMPLE t2 NULL ref id2,id1 id1 5 test.t1.id1 10 100.00 Using where +2 SIMPLE t3 NULL ref id2 id2 5 test.t2.id2 10 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`id2` = `test`.`t2`.`id2`)) +call before_payload(); +select t1.*, t2.*, t3.* +from t1 join t2 using (id1) join t3 using (id2); +call after_payload(); +number_seen OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME OPERATION NUMBER_OF_BYTES +3 TABLE test t1 id1 read external NULL +3 TABLE test t2 id2 read external NULL +3 TABLE test t3 id3 read external NULL +11 TABLE test t1 NULL fetch 1 +110 TABLE test t2 id1 fetch 1 +100 TABLE test t3 id2 fetch 10 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 NULL 0 0 0 +TABLE test t1 NULL 11 11 0 +TABLE test t1 id1 0 0 0 +TABLE test t2 id1 110 110 0 +TABLE test t2 id2 0 0 0 +TABLE test t3 id2 1000 1000 0 +TABLE test t3 id3 0 0 0 +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME COUNT_STAR COUNT_READ COUNT_WRITE +TABLE test t0 0 0 0 +TABLE test t1 11 11 0 +TABLE test t2 110 110 0 +TABLE test t3 1000 1000 0 +drop table t0; +drop table t1; +drop table t2; +drop table t3; +drop procedure before_payload; +drop procedure after_payload; +UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; diff --git a/mysql-test/suite/perfschema/r/dml_setup_instruments.result-pq b/mysql-test/suite/perfschema/r/dml_setup_instruments.result-pq new file mode 100644 index 000000000..897b91968 --- /dev/null +++ b/mysql-test/suite/perfschema/r/dml_setup_instruments.result-pq @@ -0,0 +1,87 @@ +select * from performance_schema.setup_instruments; +select * from performance_schema.setup_instruments +where name like 'Wait/Synch/Mutex/sql/%' + and name not in ('wait/synch/mutex/sql/DEBUG_SYNC::mutex') +order by name limit 10; +NAME ENABLED TIMED PROPERTIES VOLATILITY DOCUMENTATION +wait/synch/mutex/sql/Commit_order_manager::m_mutex YES YES 0 NULL +wait/synch/mutex/sql/Cost_constant_cache::LOCK_cost_const YES YES singleton 0 NULL +wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state YES YES singleton 0 NULL +wait/synch/mutex/sql/Gtid_set::gtid_executed::free_intervals_mutex YES YES 0 NULL +wait/synch/mutex/sql/Gtid_state YES YES singleton 0 NULL +wait/synch/mutex/sql/hash_filo::lock YES YES 0 NULL +wait/synch/mutex/sql/key_mts_gaq_LOCK YES YES 0 NULL +wait/synch/mutex/sql/key_mts_temp_table_LOCK YES YES 0 NULL +wait/synch/mutex/sql/LOCK_acl_cache_flush YES YES singleton 0 NULL +wait/synch/mutex/sql/LOCK_admin_tls_ctx_options YES YES 0 A lock to control all of the --ssl-* CTX related command line options for administrative connection port +select * from performance_schema.setup_instruments +where name like 'Wait/Synch/Rwlock/sql/%' + and name not in ( +'wait/synch/rwlock/sql/CRYPTO_dynlock_value::lock', +'wait/synch/rwlock/sql/LOCK_named_pipe_full_access_group') +order by name limit 10; +NAME ENABLED TIMED PROPERTIES VOLATILITY DOCUMENTATION +wait/synch/rwlock/sql/Binlog_relay_IO_delegate::lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/Binlog_storage_delegate::lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/Binlog_transmit_delegate::lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/channel_lock YES YES 0 NULL +wait/synch/rwlock/sql/channel_map_lock YES YES 0 NULL +wait/synch/rwlock/sql/channel_to_filter_lock YES YES 0 NULL +wait/synch/rwlock/sql/gtid_commit_rollback YES YES singleton 0 NULL +wait/synch/rwlock/sql/gtid_mode_lock YES YES singleton 0 NULL +wait/synch/rwlock/sql/gtid_retrieved YES YES singleton 0 NULL +wait/synch/rwlock/sql/LOCK_sys_init_connect YES YES singleton 0 NULL +select * from performance_schema.setup_instruments +where name like 'Wait/Synch/Cond/sql/%' + and name not in ( +'wait/synch/cond/sql/COND_open', +'wait/synch/cond/sql/COND_handler_count', +'wait/synch/cond/sql/DEBUG_SYNC::cond', +'wait/synch/cond/sql/COND_socket_listener_active', +'wait/synch/cond/sql/COND_start_signal_handler') +order by name limit 10; +NAME ENABLED TIMED PROPERTIES VOLATILITY DOCUMENTATION +wait/synch/cond/sql/Commit_order_manager::m_workers.cond YES YES 0 NULL +wait/synch/cond/sql/COND_compress_gtid_table YES YES singleton 0 NULL +wait/synch/cond/sql/COND_connection_count YES YES singleton 0 NULL +wait/synch/cond/sql/COND_flush_thread_cache YES YES singleton 0 NULL +wait/synch/cond/sql/COND_manager YES YES singleton 0 NULL +wait/synch/cond/sql/COND_pq_threads_running YES YES singleton 0 NULL +wait/synch/cond/sql/COND_queue_state YES YES singleton 0 NULL +wait/synch/cond/sql/COND_server_started YES YES singleton 0 NULL +wait/synch/cond/sql/COND_thd_list YES YES 0 NULL +wait/synch/cond/sql/COND_thr_lock YES YES 0 NULL +select * from performance_schema.setup_instruments +where name='Wait'; +select * from performance_schema.setup_instruments +where enabled='YES'; +insert into performance_schema.setup_instruments +set name='FOO', enabled='YES', timed='YES'; +ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'setup_instruments' +update performance_schema.setup_instruments +set name='FOO'; +ERROR HY000: Invalid performance_schema usage. +update performance_schema.setup_instruments +set enabled='NO'; +update performance_schema.setup_instruments +set timed='NO'; +select * from performance_schema.setup_instruments; +update performance_schema.setup_instruments +set enabled='YES', timed='YES'; +delete from performance_schema.setup_instruments; +ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'setup_instruments' +delete from performance_schema.setup_instruments +where name like 'Wait/Synch/%'; +ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'setup_instruments' +LOCK TABLES performance_schema.setup_instruments READ; +UNLOCK TABLES; +LOCK TABLES performance_schema.setup_instruments WRITE; +UNLOCK TABLES; + +# Bug#13813193 ASSERTION `TABLE->READ_SET == +# &TABLE->DEF_READ_SET' FAILED / MYSQL_UPDATE + +UPDATE performance_schema.setup_instruments SET timed='NO' +ORDER BY RAND(); +update performance_schema.setup_instruments +set enabled='YES', TIMED='YES'; diff --git a/mysql-test/suite/perfschema/r/innodb_table_io.result-pq b/mysql-test/suite/perfschema/r/innodb_table_io.result-pq new file mode 100644 index 000000000..6516d646e --- /dev/null +++ b/mysql-test/suite/perfschema/r/innodb_table_io.result-pq @@ -0,0 +1,146 @@ +drop table if exists test.marker; +create table test.marker(a int); +update performance_schema.setup_consumers set enabled='NO'; +update performance_schema.setup_instruments set enabled='NO'; +update performance_schema.setup_instruments set enabled='YES' + where name like "wait/io/table/%"; +truncate table performance_schema.events_waits_history_long; +flush status; +flush tables; +drop table if exists test.no_index_tab; +update performance_schema.setup_consumers set enabled='YES'; +insert into marker set a = 1; +create table test.no_index_tab +( a varchar(255) not null, b int not null) engine = InnoDB; +insert into marker set a = 1; +show create table test.no_index_tab; +Table Create Table +no_index_tab CREATE TABLE `no_index_tab` ( + `a` varchar(255) NOT NULL, + `b` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci +insert into marker set a = 1; +insert into test.no_index_tab set a = 'foo', b = 1; +insert into marker set a = 1; +insert into test.no_index_tab set a = 'foo', b = 2; +insert into marker set a = 1; +insert into test.no_index_tab set a = 'foo', b = 3; +insert into marker set a = 1; +select * from test.no_index_tab; +a b +foo 1 +foo 2 +foo 3 +insert into marker set a = 1; +update test.no_index_tab set a = 'bar'; +insert into marker set a = 1; +select * from test.no_index_tab limit 2; +a b +bar 1 +bar 2 +insert into marker set a = 1; +delete from test.no_index_tab where b = 3; +insert into marker set a = 1; +select * from test.no_index_tab; +a b +bar 1 +bar 2 +insert into marker set a = 1; +optimize table test.no_index_tab; +Table Op Msg_type Msg_text +test.no_index_tab optimize note Table does not support optimize, doing recreate + analyze instead +test.no_index_tab optimize status OK +insert into marker set a = 1; +select * from test.no_index_tab; +a b +bar 1 +bar 2 +insert into marker set a = 1; +truncate table test.no_index_tab; +insert into marker set a = 1; +drop table test.no_index_tab; +update performance_schema.setup_consumers set enabled='NO'; +select event_name, +left(source, locate(":", source)) as short_source, +object_type, object_schema, +if (locate("#sql-", object_name), "#sql-XXXX", object_name) +as pretty_name, +operation, number_of_bytes +from performance_schema.events_waits_history_long +where event_name like 'wait/io/table/%' + and object_schema in ("test") +order by thread_id, event_id; +event_name short_source object_type object_schema pretty_name operation number_of_bytes +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab update 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab update 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab update 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab delete 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test marker insert 1 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 3 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 2 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 2 +wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch 2 +show global status like 'performance_schema_%_lost'; +Variable_name Value +Performance_schema_accounts_lost 0 +Performance_schema_cond_classes_lost 0 +Performance_schema_cond_instances_lost 0 +Performance_schema_digest_lost 0 +Performance_schema_file_classes_lost 0 +Performance_schema_file_handles_lost 0 +Performance_schema_file_instances_lost 0 +Performance_schema_hosts_lost 0 +Performance_schema_index_stat_lost 0 +Performance_schema_locker_lost 0 +Performance_schema_memory_classes_lost 0 +Performance_schema_metadata_lock_lost 0 +Performance_schema_mutex_classes_lost 0 +Performance_schema_mutex_instances_lost 0 +Performance_schema_nested_statement_lost 0 +Performance_schema_prepared_statements_lost 0 +Performance_schema_program_lost 0 +Performance_schema_rwlock_classes_lost 0 +Performance_schema_rwlock_instances_lost 0 +Performance_schema_session_connect_attrs_lost 0 +Performance_schema_socket_classes_lost 0 +Performance_schema_socket_instances_lost 0 +Performance_schema_stage_classes_lost 0 +Performance_schema_statement_classes_lost 0 +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +Performance_schema_thread_classes_lost 0 +Performance_schema_thread_instances_lost 0 +Performance_schema_users_lost 0 +truncate performance_schema.events_waits_history_long; +flush status; +update performance_schema.setup_consumers set enabled='NO'; +truncate performance_schema.events_waits_history_long; +drop table test.marker; +flush status; +update performance_schema.setup_instruments set enabled='YES'; +update performance_schema.setup_consumers set enabled='YES'; diff --git a/mysql-test/suite/perfschema/r/start_server_low_table_lock.result-pq b/mysql-test/suite/perfschema/r/start_server_low_table_lock.result-pq new file mode 100644 index 000000000..8f04ad403 --- /dev/null +++ b/mysql-test/suite/perfschema/r/start_server_low_table_lock.result-pq @@ -0,0 +1,207 @@ +show databases; +Database +information_schema +mtr +mysql +performance_schema +sys +test +select count(*) from performance_schema.performance_timers; +count(*) +4 +select count(*) from performance_schema.setup_consumers; +count(*) +15 +select count(*) > 4 from performance_schema.setup_instruments; +count(*) > 4 +1 +select * from performance_schema.accounts; +select * from performance_schema.cond_instances; +select * from performance_schema.events_stages_current; +select * from performance_schema.events_stages_history; +select * from performance_schema.events_stages_history_long; +select * from performance_schema.events_stages_summary_by_account_by_event_name; +select * from performance_schema.events_stages_summary_by_host_by_event_name; +select * from performance_schema.events_stages_summary_by_thread_by_event_name; +select * from performance_schema.events_stages_summary_by_user_by_event_name; +select * from performance_schema.events_stages_summary_global_by_event_name; +select * from performance_schema.events_statements_current; +select * from performance_schema.events_statements_histogram_by_digest; +select * from performance_schema.events_statements_histogram_global; +select * from performance_schema.events_statements_history; +select * from performance_schema.events_statements_history_long; +select * from performance_schema.events_statements_summary_by_account_by_event_name; +select * from performance_schema.events_statements_summary_by_digest; +select * from performance_schema.events_statements_summary_by_host_by_event_name; +select * from performance_schema.events_statements_summary_by_thread_by_event_name; +select * from performance_schema.events_statements_summary_by_user_by_event_name; +select * from performance_schema.events_statements_summary_global_by_event_name; +select * from performance_schema.events_transactions_current; +select * from performance_schema.events_transactions_history; +select * from performance_schema.events_transactions_history_long; +select * from performance_schema.events_transactions_summary_by_account_by_event_name; +select * from performance_schema.events_transactions_summary_by_host_by_event_name; +select * from performance_schema.events_transactions_summary_by_thread_by_event_name; +select * from performance_schema.events_transactions_summary_by_user_by_event_name; +select * from performance_schema.events_transactions_summary_global_by_event_name; +select * from performance_schema.events_waits_current; +select * from performance_schema.events_waits_history; +select * from performance_schema.events_waits_history_long; +select * from performance_schema.events_waits_summary_by_account_by_event_name; +select * from performance_schema.events_waits_summary_by_host_by_event_name; +select * from performance_schema.events_waits_summary_by_instance; +select * from performance_schema.events_waits_summary_by_thread_by_event_name; +select * from performance_schema.events_waits_summary_by_user_by_event_name; +select * from performance_schema.events_waits_summary_global_by_event_name; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.events_errors_summary_by_account_by_error; +select * from performance_schema.events_errors_summary_by_host_by_error; +select * from performance_schema.events_errors_summary_by_thread_by_error; +select * from performance_schema.events_errors_summary_by_user_by_error; +select * from performance_schema.events_errors_summary_global_by_error; +select * from performance_schema.file_instances; +select * from performance_schema.file_summary_by_event_name; +select * from performance_schema.file_summary_by_instance; +select * from performance_schema.host_cache; +select * from performance_schema.hosts; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.metadata_locks; +select * from performance_schema.mutex_instances; +select * from performance_schema.objects_summary_global_by_type; +select * from performance_schema.performance_timers; +select * from performance_schema.rwlock_instances; +select * from performance_schema.data_locks; +select * from performance_schema.data_lock_waits; +select * from performance_schema.session_account_connect_attrs; +select * from performance_schema.session_connect_attrs; +select * from performance_schema.setup_actors; +select * from performance_schema.setup_consumers; +select * from performance_schema.setup_instruments; +select * from performance_schema.setup_objects; +select * from performance_schema.setup_threads; +select * from performance_schema.socket_instances; +select * from performance_schema.socket_summary_by_instance; +select * from performance_schema.socket_summary_by_event_name; +select * from performance_schema.table_handles; +select * from performance_schema.table_io_waits_summary_by_index_usage; +select * from performance_schema.table_io_waits_summary_by_table; +select * from performance_schema.table_lock_waits_summary_by_table; +select * from performance_schema.threads; +select * from performance_schema.users; +select * from performance_schema.replication_connection_configuration; +select * from performance_schema.replication_connection_status; +select * from performance_schema.replication_applier_configuration; +select * from performance_schema.replication_applier_status; +select * from performance_schema.replication_applier_status_by_coordinator; +select * from performance_schema.replication_applier_status_by_worker; +select * from performance_schema.global_status; +select * from performance_schema.status_by_thread; +select * from performance_schema.status_by_user; +select * from performance_schema.status_by_host; +select * from performance_schema.status_by_account; +select * from performance_schema.session_status; +select * from performance_schema.global_variables; +select * from performance_schema.variables_by_thread; +select * from performance_schema.session_variables; +show engine PERFORMANCE_SCHEMA status; +show global status like "performance_schema%"; +drop table if exists db1.t1; +drop database if exists db1; +create database db1; +create table db1.t1 (a int, b char(10) default 'default'); +insert into db1.t1 values('1', 'abc'); +insert into db1.t1 values('2', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +5 TABLE db1 t1 +flush tables; +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +5 TABLE db1 t1 +select variable_value from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value +0 +create table db1.t2 (a int, b char(10) default 'default', +unique key uidx(a)); +insert into db1.t1 values('3', 'abc'); +insert into db1.t1 values('4', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +insert into db1.t2 values('1', 'abc'); +insert into db1.t2 values('2', 'abc'); +select * from db1.t2 where a='1'; +a b +1 abc +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +3 TABLE db1 t2 +flush tables; +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +0 TABLE db1 t2 +select variable_value > 0 from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value > 0 +1 +flush status; +update performance_schema.setup_objects set ENABLED='NO' + where OBJECT_TYPE='TABLE' and OBJECT_SCHEMA="%"; +insert into db1.t1 values('5', 'abc'); +insert into db1.t1 values('6', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +insert into db1.t2 values('3', 'abc'); +insert into db1.t2 values('4', 'abc'); +select * from db1.t2 where a='1'; +a b +1 abc +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +0 TABLE db1 t2 +flush tables; +select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME +from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' + order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; +COUNT_STAR OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME +10 TABLE db1 t1 +0 TABLE db1 t2 +select variable_value from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value +0 +drop database db1; +update performance_schema.setup_objects set ENABLED='YES' + where OBJECT_TYPE='TABLE' and OBJECT_SCHEMA="%"; diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_lock.result-pq b/mysql-test/suite/perfschema/r/start_server_no_table_lock.result-pq new file mode 100644 index 000000000..a30c59b42 --- /dev/null +++ b/mysql-test/suite/perfschema/r/start_server_no_table_lock.result-pq @@ -0,0 +1,143 @@ +show databases; +Database +information_schema +mtr +mysql +performance_schema +sys +test +select count(*) from performance_schema.performance_timers; +count(*) +4 +select count(*) from performance_schema.setup_consumers; +count(*) +15 +select count(*) > 4 from performance_schema.setup_instruments; +count(*) > 4 +1 +select * from performance_schema.accounts; +select * from performance_schema.cond_instances; +select * from performance_schema.events_stages_current; +select * from performance_schema.events_stages_history; +select * from performance_schema.events_stages_history_long; +select * from performance_schema.events_stages_summary_by_account_by_event_name; +select * from performance_schema.events_stages_summary_by_host_by_event_name; +select * from performance_schema.events_stages_summary_by_thread_by_event_name; +select * from performance_schema.events_stages_summary_by_user_by_event_name; +select * from performance_schema.events_stages_summary_global_by_event_name; +select * from performance_schema.events_statements_current; +select * from performance_schema.events_statements_histogram_by_digest; +select * from performance_schema.events_statements_histogram_global; +select * from performance_schema.events_statements_history; +select * from performance_schema.events_statements_history_long; +select * from performance_schema.events_statements_summary_by_account_by_event_name; +select * from performance_schema.events_statements_summary_by_digest; +select * from performance_schema.events_statements_summary_by_host_by_event_name; +select * from performance_schema.events_statements_summary_by_thread_by_event_name; +select * from performance_schema.events_statements_summary_by_user_by_event_name; +select * from performance_schema.events_statements_summary_global_by_event_name; +select * from performance_schema.events_transactions_current; +select * from performance_schema.events_transactions_history; +select * from performance_schema.events_transactions_history_long; +select * from performance_schema.events_transactions_summary_by_account_by_event_name; +select * from performance_schema.events_transactions_summary_by_host_by_event_name; +select * from performance_schema.events_transactions_summary_by_thread_by_event_name; +select * from performance_schema.events_transactions_summary_by_user_by_event_name; +select * from performance_schema.events_transactions_summary_global_by_event_name; +select * from performance_schema.events_waits_current; +select * from performance_schema.events_waits_history; +select * from performance_schema.events_waits_history_long; +select * from performance_schema.events_waits_summary_by_account_by_event_name; +select * from performance_schema.events_waits_summary_by_host_by_event_name; +select * from performance_schema.events_waits_summary_by_instance; +select * from performance_schema.events_waits_summary_by_thread_by_event_name; +select * from performance_schema.events_waits_summary_by_user_by_event_name; +select * from performance_schema.events_waits_summary_global_by_event_name; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.events_errors_summary_by_account_by_error; +select * from performance_schema.events_errors_summary_by_host_by_error; +select * from performance_schema.events_errors_summary_by_thread_by_error; +select * from performance_schema.events_errors_summary_by_user_by_error; +select * from performance_schema.events_errors_summary_global_by_error; +select * from performance_schema.file_instances; +select * from performance_schema.file_summary_by_event_name; +select * from performance_schema.file_summary_by_instance; +select * from performance_schema.host_cache; +select * from performance_schema.hosts; +select * from performance_schema.memory_summary_by_account_by_event_name; +select * from performance_schema.memory_summary_by_host_by_event_name; +select * from performance_schema.memory_summary_by_thread_by_event_name; +select * from performance_schema.memory_summary_by_user_by_event_name; +select * from performance_schema.memory_summary_global_by_event_name; +select * from performance_schema.metadata_locks; +select * from performance_schema.mutex_instances; +select * from performance_schema.objects_summary_global_by_type; +select * from performance_schema.performance_timers; +select * from performance_schema.rwlock_instances; +select * from performance_schema.data_locks; +select * from performance_schema.data_lock_waits; +select * from performance_schema.session_account_connect_attrs; +select * from performance_schema.session_connect_attrs; +select * from performance_schema.setup_actors; +select * from performance_schema.setup_consumers; +select * from performance_schema.setup_instruments; +select * from performance_schema.setup_objects; +select * from performance_schema.setup_threads; +select * from performance_schema.socket_instances; +select * from performance_schema.socket_summary_by_instance; +select * from performance_schema.socket_summary_by_event_name; +select * from performance_schema.table_handles; +select * from performance_schema.table_io_waits_summary_by_index_usage; +select * from performance_schema.table_io_waits_summary_by_table; +select * from performance_schema.table_lock_waits_summary_by_table; +select * from performance_schema.threads; +select * from performance_schema.users; +select * from performance_schema.replication_connection_configuration; +select * from performance_schema.replication_connection_status; +select * from performance_schema.replication_applier_configuration; +select * from performance_schema.replication_applier_status; +select * from performance_schema.replication_applier_status_by_coordinator; +select * from performance_schema.replication_applier_status_by_worker; +select * from performance_schema.global_status; +select * from performance_schema.status_by_thread; +select * from performance_schema.status_by_user; +select * from performance_schema.status_by_host; +select * from performance_schema.status_by_account; +select * from performance_schema.session_status; +select * from performance_schema.global_variables; +select * from performance_schema.variables_by_thread; +select * from performance_schema.session_variables; +show engine PERFORMANCE_SCHEMA status; +show global status like "performance_schema%"; +drop table if exists db1.t1; +drop database if exists db1; +create database db1; +create table db1.t1 (a int, b char(10) default 'default'); +insert into db1.t1 values('1', 'abc'); +insert into db1.t1 values('2', 'abc'); +select * from db1.t1 where a='1'; +a b +1 abc +select COUNT_STAR from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1'; +COUNT_STAR +5 +FLUSH TABLES; +select COUNT_STAR from performance_schema.table_lock_waits_summary_by_table +where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1'; +COUNT_STAR +0 +select variable_value > 0 from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value > 0 +1 +FLUSH STATUS; +select variable_value from performance_schema.global_status +where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST'; +variable_value +0 +drop database db1; diff --git a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result-pq new file mode 100644 index 000000000..85bef9e95 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result-pq @@ -0,0 +1,1741 @@ +update performance_schema.setup_consumers +set enabled='NO' where name='thread_instrumentation'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation NO +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 120 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 40 24 16 0 0 0 0 24 0 16 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 116 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result-pq new file mode 100644 index 000000000..f609a4131 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result-pq @@ -0,0 +1,1722 @@ +update performance_schema.setup_consumers +set enabled='NO' where name='thread_instrumentation'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation NO +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 80 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 0 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result-pq new file mode 100644 index 000000000..9ab1cff9f --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result-pq @@ -0,0 +1,1859 @@ +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/lock/table/sql/handler 11 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/lock/table/sql/handler 12 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +wait/lock/table/sql/handler 13 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/lock/table/sql/handler 11 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/lock/table/sql/handler 12 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +wait/lock/table/sql/handler 13 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/lock/table/sql/handler 20 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/lock/table/sql/handler 22 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +wait/lock/table/sql/handler 24 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/lock/table/sql/handler 20 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/lock/table/sql/handler 22 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +wait/lock/table/sql/handler 24 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 72 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 72 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 24 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 26 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 22 16 6 0 0 0 0 16 0 6 +TABLE test t2 24 16 8 0 0 0 0 16 0 8 +TABLE test t3 26 16 10 0 0 0 0 16 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 48 +TABLE test t2 68 +TABLE test t3 100 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/lock/table/sql/handler 24 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/lock/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +wait/lock/table/sql/handler 28 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result-pq new file mode 100644 index 000000000..9f5a25e3f --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result-pq @@ -0,0 +1,1800 @@ +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 80 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 80 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 36 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 44 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 0 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result-pq new file mode 100644 index 000000000..845d1d0f7 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result-pq @@ -0,0 +1,1859 @@ +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/lock/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/lock/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +wait/lock/table/sql/handler 11 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/lock/table/sql/handler 20 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/lock/table/sql/handler 18 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/lock/table/sql/handler 20 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +wait/lock/table/sql/handler 22 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/lock/table/sql/handler 30 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/lock/table/sql/handler 27 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/lock/table/sql/handler 30 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +wait/lock/table/sql/handler 33 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 120 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 120 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 36 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 40 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 44 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 40 24 16 0 0 0 0 24 0 16 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 116 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/lock/table/sql/handler 38 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/lock/table/sql/handler 42 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +wait/lock/table/sql/handler 46 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result-pq new file mode 100644 index 000000000..1b5d2cf59 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result-pq @@ -0,0 +1,1722 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 24 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 24 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 0 +TABLE test t3 36 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 24 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 24 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 0 +TABLE test t3 36 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 44 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 44 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 0 +TABLE test t3 82 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 44 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 44 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 0 +TABLE test t3 82 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 48 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 48 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 22 16 6 0 0 0 0 16 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 26 16 10 0 0 0 0 16 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 48 +TABLE test t2 0 +TABLE test t3 100 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 4 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 4 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 4 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 4 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 52 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 52 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 0 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result-pq new file mode 100644 index 000000000..34f30e680 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result-pq @@ -0,0 +1,1741 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 36 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 36 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 11 8 3 0 0 0 0 8 0 3 +TABLE test t2 12 8 4 0 0 0 0 8 0 4 +TABLE test t3 13 8 5 0 0 0 0 8 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 20 +TABLE test t2 26 +TABLE test t3 36 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 66 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 66 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 20 14 6 0 0 0 0 14 0 6 +TABLE test t2 22 14 8 0 0 0 0 14 0 8 +TABLE test t3 24 14 10 0 0 0 0 14 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 42 +TABLE test t2 58 +TABLE test t3 82 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 72 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 72 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 22 16 6 0 0 0 0 16 0 6 +TABLE test t2 24 16 8 0 0 0 0 16 0 8 +TABLE test t3 26 16 10 0 0 0 0 16 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 48 +TABLE test t2 68 +TABLE test t3 100 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 6 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 6 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 6 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 6 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 78 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 78 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 24 17 7 0 0 0 0 17 0 7 +TABLE test t2 26 17 9 0 0 0 0 17 0 9 +TABLE test t3 28 17 11 0 0 0 0 17 0 11 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 50 +TABLE test t2 70 +TABLE test t3 102 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result-pq new file mode 100644 index 000000000..4b88cd545 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result-pq @@ -0,0 +1,1722 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 20 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 20 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 0 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 40 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 40 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 0 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 0 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 16 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 20 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 20 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 80 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 80 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 0 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 20 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 16 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 16 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 16 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 24 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 20 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 20 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 20 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 24 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 20 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 20 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 20 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 84 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 84 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 0 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result-pq b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result-pq new file mode 100644 index 000000000..557bb6cb1 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result-pq @@ -0,0 +1,1741 @@ +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 30 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 30 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 9 6 3 0 0 0 0 6 0 3 +TABLE test t2 10 6 4 0 0 0 0 6 0 4 +TABLE test t3 11 6 5 0 0 0 0 6 0 5 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 16 +TABLE test t2 20 +TABLE test t3 26 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 60 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 60 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 18 12 6 0 0 0 0 12 0 6 +TABLE test t2 20 12 8 0 0 0 0 12 0 8 +TABLE test t3 22 12 10 0 0 0 0 12 0 10 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 35 +TABLE test t2 46 +TABLE test t3 62 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 90 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 90 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 27 18 9 0 0 0 0 18 0 9 +TABLE test t2 30 18 12 0 0 0 0 18 0 12 +TABLE test t3 33 18 15 0 0 0 0 18 0 15 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 57 +TABLE test t2 78 +TABLE test t3 108 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 24 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 30 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 30 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 120 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 120 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 36 24 12 0 0 0 0 24 0 12 +TABLE test t2 40 24 16 0 0 0 0 24 0 16 +TABLE test t3 44 24 20 0 0 0 0 24 0 20 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 82 +TABLE test t2 116 +TABLE test t3 164 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 30 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 24 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 24 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 24 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 36 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 30 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 30 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 30 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 36 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 30 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 30 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 30 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 126 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 126 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 38 25 13 0 0 0 0 25 0 13 +TABLE test t2 42 25 17 0 0 0 0 25 0 17 +TABLE test t3 46 25 21 0 0 0 0 25 0 21 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 84 +TABLE test t2 118 +TABLE test t3 166 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result-pq new file mode 100644 index 000000000..954e14d35 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result-pq @@ -0,0 +1,1762 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result-pq new file mode 100644 index 000000000..c72bee60c --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result-pq @@ -0,0 +1,1801 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 9 TABLE test t1 +wait/io/table/sql/handler 14 TABLE test t2 +wait/io/table/sql/handler 23 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 22 TABLE test t1 +wait/io/table/sql/handler 36 TABLE test t2 +wait/io/table/sql/handler 58 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 26 TABLE test t1 +wait/io/table/sql/handler 44 TABLE test t2 +wait/io/table/sql/handler 74 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result-pq new file mode 100644 index 000000000..53b272be8 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result-pq @@ -0,0 +1,1762 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result-pq new file mode 100644 index 000000000..bc3667dd6 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result-pq @@ -0,0 +1,1801 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current YES +events_stages_history YES +events_stages_history_long YES +events_statements_current YES +events_statements_history YES +events_statements_history_long YES +events_transactions_current YES +events_transactions_history YES +events_transactions_history_long YES +events_waits_current YES +events_waits_history YES +events_waits_history_long YES +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 7 TABLE test t1 +wait/io/table/sql/handler 10 TABLE test t2 +wait/io/table/sql/handler 15 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 17 TABLE test t1 +wait/io/table/sql/handler 26 TABLE test t2 +wait/io/table/sql/handler 40 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 30 TABLE test t1 +wait/io/table/sql/handler 48 TABLE test t2 +wait/io/table/sql/handler 75 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +wait/io/table/sql/handler 46 TABLE test t1 +wait/io/table/sql/handler 76 TABLE test t2 +wait/io/table/sql/handler 120 TABLE test t3 +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result-pq new file mode 100644 index 000000000..e3d164b57 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result-pq @@ -0,0 +1,1724 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 0 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 80 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 80 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 0 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 10 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 20 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 10 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 20 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 100 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 100 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 0 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result-pq new file mode 100644 index 000000000..d2418b861 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result-pq @@ -0,0 +1,1743 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_actors +where user in ('user2', 'user4'); +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user3 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 46 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 46 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 6 5 1 5 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 11 9 2 9 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 16 13 3 13 3 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 9 6 3 6 1 2 0 +TABLE test t2 14 10 4 10 2 2 0 +TABLE test t3 23 17 6 17 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 9 +TABLE test t2 14 +TABLE test t3 23 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 116 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 116 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 14 12 2 12 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 26 22 4 22 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 38 32 6 32 6 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 22 14 8 14 2 6 0 +TABLE test t2 36 24 12 24 4 8 0 +TABLE test t3 58 40 18 40 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 22 +TABLE test t2 36 +TABLE test t3 58 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 14 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 28 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 14 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 28 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 144 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 144 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 16 2 16 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 8 2 6 2 0 6 0 +TABLE test t2 NULL 34 30 4 30 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 10 2 8 2 0 8 0 +TABLE test t3 NULL 50 44 6 44 6 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 14 2 12 2 0 12 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 26 18 8 18 2 6 0 +TABLE test t2 44 32 12 32 4 8 0 +TABLE test t3 74 56 18 56 6 12 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 26 +TABLE test t2 44 +TABLE test t3 74 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result-pq new file mode 100644 index 000000000..c44f9a909 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result-pq @@ -0,0 +1,1724 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +delete from performance_schema.setup_objects +where object_name='t2'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 22 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 22 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 0 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 57 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 57 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 0 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 105 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 105 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 0 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 17 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 25 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 33 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 41 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 22 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 35 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 48 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 61 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 22 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 35 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 48 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 166 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 166 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 0 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result-pq b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result-pq new file mode 100644 index 000000000..5204f15a8 --- /dev/null +++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result-pq @@ -0,0 +1,1743 @@ +update performance_schema.setup_instruments +set enabled='NO' where name='wait/lock/table/sql/handler'; +update performance_schema.setup_consumers +set enabled='NO' where name like 'event%'; +select * from performance_schema.setup_actors +order by USER, HOST, `ROLE`; +HOST USER ROLE ENABLED HISTORY +localhost user1 % YES YES +localhost user2 % YES YES +localhost user3 % YES YES +localhost user4 % YES YES +select * from performance_schema.setup_objects +order by object_type, object_schema, object_name; +OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME ENABLED TIMED +TABLE test t1 YES YES +TABLE test t2 YES NO +TABLE test t3 YES NO +select * from performance_schema.setup_consumers; +NAME ENABLED +events_stages_current NO +events_stages_history NO +events_stages_history_long NO +events_statements_current NO +events_statements_history NO +events_statements_history_long NO +events_transactions_current NO +events_transactions_history NO +events_transactions_history_long NO +events_waits_current NO +events_waits_history NO +events_waits_history_long NO +global_instrumentation YES +thread_instrumentation YES +statements_digest YES +flush tables; +truncate performance_schema.objects_summary_global_by_type; +truncate performance_schema.table_io_waits_summary_by_index_usage; +truncate performance_schema.table_io_waits_summary_by_table; +truncate performance_schema.table_lock_waits_summary_by_table; +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +truncate performance_schema.events_waits_summary_by_account_by_event_name; +truncate performance_schema.events_waits_summary_by_user_by_event_name; +truncate performance_schema.events_waits_summary_by_host_by_event_name; +truncate performance_schema.events_waits_summary_global_by_event_name; +truncate performance_schema.events_waits_history_long; +show global variables like "performance_schema%table%"; +Variable_name Value +performance_schema_max_table_handles -1 +performance_schema_max_table_instances -1 +performance_schema_max_table_lock_stat -1 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 +"================== Step 1 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +execute dump_waits_user; +user event_name count_star +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +select concat(current_user(), " is connected") as status; +status +user1@localhost is connected +"================== Step 2 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +insert into test.t1 set a=101, b=1, c=1; +insert into test.t2 set a=102, b=2, c=2; +insert into test.t2 set a=103, b=3, c=3; +insert into test.t3 set a=104, b=4, c=4; +insert into test.t3 set a=105, b=5, c=5; +insert into test.t3 set a=106, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 0 +select * from test.t2; +a b c d +102 2 2 0 +103 3 3 0 +select * from test.t3; +a b c d +104 4 4 0 +105 5 5 0 +106 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=101; +update test.t2 set d=d+1 where a=101; +update test.t3 set d=d+1 where a=101; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 1 +"================== con1 marker ==================" +"================== Step 3-A ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +flush tables; +"================== con1 FLUSH ==================" +"================== Step 3-B ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +select concat(current_user(), " is connected") as status; +status +user2@localhost is connected +"================== Step 4 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 32 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 32 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 4 3 1 3 1 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 3 1 2 1 0 2 0 +TABLE test t2 NULL 7 5 2 5 2 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 3 1 2 1 0 2 0 +TABLE test t3 NULL 10 7 3 7 3 0 0 +TABLE test t3 index_b 1 1 0 1 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 4 1 3 1 0 3 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 7 4 3 4 1 2 0 +TABLE test t2 10 6 4 6 2 2 0 +TABLE test t3 15 9 6 9 3 3 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 7 +TABLE test t2 10 +TABLE test t3 15 +insert into test.t1 set a=201, b=1, c=1; +insert into test.t2 set a=202, b=2, c=2; +insert into test.t2 set a=203, b=3, c=3; +insert into test.t3 set a=204, b=4, c=4; +insert into test.t3 set a=205, b=5, c=5; +insert into test.t3 set a=206, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 2 +201 1 1 0 +select * from test.t2; +a b c d +102 2 2 1 +103 3 3 1 +202 2 2 0 +203 3 3 0 +select * from test.t3; +a b c d +104 4 4 1 +105 5 5 1 +106 6 6 1 +204 4 4 0 +205 5 5 0 +206 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=201; +update test.t2 set d=d+1 where a=201; +update test.t3 set d=d+1 where a=201; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 2 +205 5 5 1 +"================== con2 marker ==================" +"================== Step 5 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +select concat(current_user(), " is connected") as status; +status +user3@localhost is connected +"================== Step 6 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 83 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 83 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 10 8 2 8 2 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 7 2 5 2 0 5 0 +TABLE test t2 NULL 18 14 4 14 4 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 8 2 6 2 0 6 0 +TABLE test t3 NULL 26 20 6 20 6 0 0 +TABLE test t3 index_b 3 3 0 3 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 11 2 9 2 0 9 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 17 10 7 10 2 5 0 +TABLE test t2 26 16 10 16 4 6 0 +TABLE test t3 40 25 15 25 6 9 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 17 +TABLE test t2 26 +TABLE test t3 40 +insert into test.t1 set a=301, b=1, c=1; +insert into test.t2 set a=302, b=2, c=2; +insert into test.t2 set a=303, b=3, c=3; +insert into test.t3 set a=304, b=4, c=4; +insert into test.t3 set a=305, b=5, c=5; +insert into test.t3 set a=306, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 3 +201 1 1 2 +301 1 1 0 +select * from test.t2; +a b c d +102 2 2 2 +103 3 3 2 +202 2 2 1 +203 3 3 1 +302 2 2 0 +303 3 3 0 +select * from test.t3; +a b c d +104 4 4 2 +105 5 5 2 +106 6 6 2 +204 4 4 1 +205 5 5 1 +206 6 6 1 +304 4 4 0 +305 5 5 0 +306 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=301; +update test.t2 set d=d+1 where a=301; +update test.t3 set d=d+1 where a=301; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 3 +205 5 5 2 +305 5 5 1 +"================== con3 marker ==================" +"================== Step 7 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +select concat(current_user(), " is connected") as status; +status +user4@localhost is connected +"================== Step 8 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 153 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 153 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 18 15 3 15 3 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 12 3 9 3 0 9 0 +TABLE test t2 NULL 33 27 6 27 6 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 15 3 12 3 0 12 0 +TABLE test t3 NULL 48 39 9 39 9 0 0 +TABLE test t3 index_b 6 6 0 6 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 21 3 18 3 0 18 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 30 18 12 18 3 9 0 +TABLE test t2 48 30 18 30 6 12 0 +TABLE test t3 75 48 27 48 9 18 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 30 +TABLE test t2 48 +TABLE test t3 75 +insert into test.t1 set a=401, b=1, c=1; +insert into test.t2 set a=402, b=2, c=2; +insert into test.t2 set a=403, b=3, c=3; +insert into test.t3 set a=404, b=4, c=4; +insert into test.t3 set a=405, b=5, c=5; +insert into test.t3 set a=406, b=6, c=6; +select * from test.t1; +a b c d +101 1 1 4 +201 1 1 3 +301 1 1 2 +401 1 1 0 +select * from test.t2; +a b c d +102 2 2 3 +103 3 3 3 +202 2 2 2 +203 3 3 2 +302 2 2 1 +303 3 3 1 +402 2 2 0 +403 3 3 0 +select * from test.t3; +a b c d +104 4 4 3 +105 5 5 3 +106 6 6 3 +204 4 4 2 +205 5 5 2 +206 6 6 2 +304 4 4 1 +305 5 5 1 +306 6 6 1 +404 4 4 0 +405 5 5 0 +406 6 6 0 +update test.t1 set d=d+1; +update test.t2 set d=d+1; +update test.t3 set d=d+1; +update test.t1 set d=d+1 where a=401; +update test.t2 set d=d+1 where a=401; +update test.t3 set d=d+1 where a=401; +select * from test.t1 force index(index_b) where b=5; +a b c d +select * from test.t2 force index(index_b) where b=5; +a b c d +select * from test.t3 force index(index_b) where b=5; +a b c d +105 5 5 4 +205 5 5 3 +305 5 5 2 +405 5 5 1 +"================== con4 marker ==================" +"================== Step 9 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +lock tables test.t1 read, test.t2 read, test.t3 read; +unlock tables; +lock tables test.t1 write, test.t2 write, test.t3 write; +unlock tables; +"================== con1 marker ==================" +"================== Step 10 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +flush tables; +"================== flush marker ==================" +"================== Step 11 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +set global read_only=1; +set global read_only=0; +"================== global read_only marker ==================" +"================== Step 12 ==================" +call dump_thread(); +username event_name count_star +user1 wait/io/table/sql/handler 25 +user1 wait/lock/table/sql/handler 0 +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con1 disconnected ==================" +"================== Step 13 ==================" +call dump_thread(); +username status +user1 not found +username event_name count_star +user2 wait/io/table/sql/handler 37 +user2 wait/lock/table/sql/handler 0 +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con2 disconnected ==================" +"================== Step 14 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username event_name count_star +user3 wait/io/table/sql/handler 49 +user3 wait/lock/table/sql/handler 0 +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con3 disconnected ==================" +"================== Step 15 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username event_name count_star +user4 wait/io/table/sql/handler 61 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +"================== con4 disconnected ==================" +"================== Step 16 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_thread_by_event_name; +"================== BY_THREAD truncated ==================" +"================== Step 17 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 32 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 51 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 70 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 89 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_account_by_event_name; +"================== BY_ACCOUNT truncated ==================" +"================== Step 18 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 32 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 51 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 70 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 89 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_user_by_event_name; +"================== BY_USER truncated ==================" +"================== Step 19 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 242 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_by_host_by_event_name; +"================== BY_HOST truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 242 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 28 24 4 24 4 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 18 4 14 4 0 14 0 +TABLE test t2 NULL 52 44 8 44 8 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 24 4 20 4 0 20 0 +TABLE test t3 NULL 76 64 12 64 12 0 0 +TABLE test t3 index_b 10 10 0 10 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 34 4 30 4 0 30 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 46 28 18 28 4 14 0 +TABLE test t2 76 48 28 48 8 20 0 +TABLE test t3 120 78 42 78 12 30 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 46 +TABLE test t2 76 +TABLE test t3 120 +truncate performance_schema.events_waits_summary_global_by_event_name; +"================== GLOBAL truncated ==================" +"================== Step 21 ==================" +call dump_thread(); +username status +user1 not found +username status +user2 not found +username status +user3 not found +username status +user4 not found +execute dump_waits_account; +user host event_name count_star +user1 localhost wait/io/table/sql/handler 0 +user1 localhost wait/lock/table/sql/handler 0 +user2 localhost wait/io/table/sql/handler 0 +user2 localhost wait/lock/table/sql/handler 0 +user3 localhost wait/io/table/sql/handler 0 +user3 localhost wait/lock/table/sql/handler 0 +user4 localhost wait/io/table/sql/handler 0 +user4 localhost wait/lock/table/sql/handler 0 +execute dump_waits_user; +user event_name count_star +user1 wait/io/table/sql/handler 0 +user1 wait/lock/table/sql/handler 0 +user2 wait/io/table/sql/handler 0 +user2 wait/lock/table/sql/handler 0 +user3 wait/io/table/sql/handler 0 +user3 wait/lock/table/sql/handler 0 +user4 wait/io/table/sql/handler 0 +user4 wait/lock/table/sql/handler 0 +execute dump_waits_host; +host event_name count_star +localhost wait/io/table/sql/handler 0 +localhost wait/lock/table/sql/handler 0 +execute dump_waits_global; +event_name count_star +wait/io/table/sql/handler 0 +wait/lock/table/sql/handler 0 +execute dump_waits_history; +event_name count(event_name) object_type object_schema object_name +execute dump_waits_index_io; +object_type object_schema object_name index_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 NULL 0 0 0 0 0 0 0 +TABLE test t1 index_b 0 0 0 0 0 0 0 +TABLE test t1 index_cb 0 0 0 0 0 0 0 +TABLE test t1 PRIMARY 0 0 0 0 0 0 0 +TABLE test t2 NULL 0 0 0 0 0 0 0 +TABLE test t2 index_b 0 0 0 0 0 0 0 +TABLE test t2 index_cb 0 0 0 0 0 0 0 +TABLE test t2 PRIMARY 0 0 0 0 0 0 0 +TABLE test t3 NULL 0 0 0 0 0 0 0 +TABLE test t3 index_b 0 0 0 0 0 0 0 +TABLE test t3 index_cb 0 0 0 0 0 0 0 +TABLE test t3 PRIMARY 0 0 0 0 0 0 0 +execute dump_waits_table_io; +object_type object_schema object_name count_star count_read count_write count_fetch count_insert count_update count_delete +TABLE test t1 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 +execute dump_waits_table_lock; +object_type object_schema object_name count_star count_read count_write count_read_normal count_read_with_shared_locks count_read_high_priority count_read_no_insert count_read_external count_write_low_priority count_write_external +TABLE test t1 0 0 0 0 0 0 0 0 0 0 +TABLE test t2 0 0 0 0 0 0 0 0 0 0 +TABLE test t3 0 0 0 0 0 0 0 0 0 0 +execute dump_objects_summary; +object_type object_schema object_name count_star +TABLE test t1 0 +TABLE test t2 0 +TABLE test t3 0 +show global status like "performance_schema%table%_lost"; +Variable_name Value +Performance_schema_table_handles_lost 0 +Performance_schema_table_instances_lost 0 +Performance_schema_table_lock_stat_lost 0 diff --git a/mysql-test/suite/perfschema/r/transaction.result-pq b/mysql-test/suite/perfschema/r/transaction.result-pq new file mode 100644 index 000000000..d003bf07c --- /dev/null +++ b/mysql-test/suite/perfschema/r/transaction.result-pq @@ -0,0 +1,604 @@ + +======================================================================== +STEP 1 - SETUP +======================================================================== + +# Control thread + +SET SESSION AUTOCOMMIT= 1; +SELECT thread_id INTO @my_thread_id +FROM performance_schema.threads +WHERE processlist_id = connection_id(); + +# Connection 1 + +SET SESSION AUTOCOMMIT= 0; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE; + +# Create test tables, one transactional and one non-transactional + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS nt1; +CREATE TABLE t1 (s1 int, s2 varchar(64)) ENGINE=INNODB; +CREATE TABLE nt1 (s1 int, s2 varchar(64)) ENGINE=MYISAM; + +# Get tables loaded in data-dictionary cache + + +# Disable all events from the control thread + + +# Clear transaction tables + +CALL clear_transaction_tables(); + +======================================================================== +# STEP 2 - BASIC TRANSACTION +======================================================================== + +SELECT @@global.transaction_isolation; +@@global.transaction_isolation +REPEATABLE-READ +SELECT @@global.autocommit; +@@global.autocommit +1 +SELECT @@transaction_isolation; +@@transaction_isolation +REPEATABLE-READ +SELECT @@autocommit; +@@autocommit +0 + +# STEP 2.1 - START/COMMIT + +START TRANSACTION; +INSERT INTO t1 VALUES (101, 'COMMITTED'); +COMMIT; + +# STEP 2.2 - ROLLBACK + +START TRANSACTION; +INSERT INTO t1 VALUES (102, 'ROLLED BACK'); +ROLLBACK; + +## Expect 1 committed and 1 rolled back transaction +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +# STEP 2.3 - COMMIT AND CHAIN + +START TRANSACTION; +INSERT INTO t1 VALUES (103, 'COMMIT AND CHAIN'); +COMMIT AND CHAIN; +INSERT INTO t1 VALUES (104, 'COMMIT AND CHAIN'); +COMMIT; + +## Expect 2 committed transactions +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 2); +ACTUAL EXPECTED + 2 2 +CALL clear_transaction_tables(); + +======================================================================== +# STEP 3 - ISOLATION LEVEL +======================================================================== + +connection con1 +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +START TRANSACTION; +INSERT INTO t1 VALUES (301, 'SERIALIZABLE'); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +START TRANSACTION; +INSERT INTO t1 VALUES (302, 'REPEATABLE READ'); +COMMIT; +SELECT @@binlog_format INTO @binlog_save; +SET SESSION BINLOG_FORMAT='ROW'; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +START TRANSACTION; +INSERT INTO t1 VALUES (303, 'READ COMMITTED'); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +START TRANSACTION; +INSERT INTO t1 VALUES (304, 'READ UNCOMMITTED'); +COMMIT; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SET binlog_format= @binlog_save; + +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'SERIALIZABLE', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'READ COMMITTED', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'READ UNCOMMITTED', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +======================================================================== +# STEP 4 - ACCESS MODE +======================================================================== +# +# STEP 4.1 - READ ONLY, TIMING ENABLED +# + +connection con1 +SET SESSION TRANSACTION READ WRITE; +START TRANSACTION; +INSERT INTO t1 VALUES (410, 'READ ONLY'); +INSERT INTO t1 VALUES (411, 'READ ONLY'); +INSERT INTO t1 VALUES (412, 'READ ONLY'); +INSERT INTO t1 VALUES (413, 'READ ONLY'); +COMMIT; +SET SESSION TRANSACTION READ ONLY; +START TRANSACTION; +SELECT * FROM t1 ORDER BY s1; +s1 s2 +101 COMMITTED +103 COMMIT AND CHAIN +104 COMMIT AND CHAIN +301 SERIALIZABLE +302 REPEATABLE READ +303 READ COMMITTED +304 READ UNCOMMITTED +410 READ ONLY +411 READ ONLY +412 READ ONLY +413 READ ONLY +COMMIT; + +## Expect 1 read only, committed transaction in events_transactions_history +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ ONLY', 'REPEATABLE READ', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +# +# STEP 4.2 - READ ONLY, TIMING DISABLED +# + +## Disable timing stats for 'transaction' +UPDATE performance_schema.setup_instruments SET timed = 'NO' WHERE name = 'transaction'; + +TRUNCATE performance_schema.events_transactions_summary_global_by_event_name; +connection con1 +START TRANSACTION; +SELECT * FROM t1 ORDER BY s1; +s1 s2 +101 COMMITTED +103 COMMIT AND CHAIN +104 COMMIT AND CHAIN +301 SERIALIZABLE +302 REPEATABLE READ +303 READ COMMITTED +304 READ UNCOMMITTED +410 READ ONLY +411 READ ONLY +412 READ ONLY +413 READ ONLY +COMMIT; + +SET SESSION TRANSACTION READ WRITE; + +## Expect 1 event, 0 stats +SELECT * FROM performance_schema.events_transactions_summary_global_by_event_name; +EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT COUNT_READ_WRITE SUM_TIMER_READ_WRITE MIN_TIMER_READ_WRITE AVG_TIMER_READ_WRITE MAX_TIMER_READ_WRITE COUNT_READ_ONLY SUM_TIMER_READ_ONLY MIN_TIMER_READ_ONLY AVG_TIMER_READ_ONLY MAX_TIMER_READ_ONLY +transaction 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 + +## Restore setup_instruments +UPDATE performance_schema.setup_instruments SET enabled = 'YES' WHERE name = 'transaction'; + +======================================================================== +# STEP 5 - IMPLICIT START +======================================================================== +# When AUTOCOMMIT is disabled, the first statement following a committed +# transaction marks the start of a new transaction. Subsequent statements will +# be part of the transaction until it is committed. + +SET SESSION AUTOCOMMIT = 0; +INSERT INTO t1 VALUES (501, 'IMPLICIT START'); + +## Expect 1 active transaction in events_transactions_current +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +INSERT INTO t1 VALUES (502, 'IMPLICIT START'); +COMMIT; + +## Expect one committed transaction in events_transactions_current and history +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +======================================================================== +# STEP 6 - IMPLICIT COMMIT (DDL, ETC) +======================================================================== +# Transactions are implicitly ended by DDL statements, locking statements +# and server administration commands. + +SET SESSION AUTOCOMMIT = 0; +INSERT INTO t1 VALUES (601, 'IMPLICIT COMMIT'); + +## Expect one active transaction in events_transactions_current, zero events in history +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', 'NO', 0, 0, 0, 0); +ACTUAL EXPECTED + 0 0 +INSERT INTO t1 VALUES (602, 'IMPLICIT COMMIT'); +## Issue a DDL statement to force a commmit +## This DDL needs to fail early, to avoid starting its own transaction +## which will disturb the state. +ALTER TABLE t1 ADD KEY (s3); +ERROR 42000: Key column 's3' doesn't exist in table + +## Expect 0 active transactions, 1 committed transaction +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 0); +ACTUAL EXPECTED + 0 0 +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +======================================================================== +STEP 7 - XA TRANSACTIONS +======================================================================== +# +# STEP 7.1 - XA START +# +XA START 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890; + +## Expect 1 active XA transaction, state ACTIVE +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'ACTIVE', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 + +# STEP 7.2 - XA END + +INSERT INTO t1 VALUES (701, 'XA'); +XA END 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890; + +## Expect 1 active XA transaction, state IDLE +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'IDLE', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 + +# +# STEP 7.3 - XA PREPARE +# +XA PREPARE 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890; + +## Expect 1 active XA transaction, state PREPARED +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'PREPARED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 + +# +# STEP 7.4 - XA COMMIT +# +XA COMMIT 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890; + +## Expect 1 committed XA transaction, state COMMITTED in current and history +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +# +# STEP 7.5 - XA ROLLBACK +# +XA START 'XA_CON1_002'; +INSERT INTO t1 VALUES (702, 'XA'); +XA END 'XA_CON1_002'; +XA PREPARE 'XA_CON1_002'; + +## Expect 1 active XA transaction, state PREPARED +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, 'XA_CON1_002', '', 'PREPARED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +XA ROLLBACK 'XA_CON1_002'; + +## Expect 1 XA transaction, state ROLLBACK ONLY in current and history +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, 'XA_CON1_002', '', 'ROLLBACK ONLY', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, 'XA_CON1_002', '', 'ROLLBACK ONLY', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); +SELECT * FROM performance_schema.events_transactions_current ORDER BY event_id; +THREAD_ID EVENT_ID END_EVENT_ID EVENT_NAME STATE TRX_ID GTID XID_FORMAT_ID XID_GTRID XID_BQUAL XA_STATE SOURCE TIMER_START TIMER_END TIMER_WAIT ACCESS_MODE ISOLATION_LEVEL AUTOCOMMIT NUMBER_OF_SAVEPOINTS NUMBER_OF_ROLLBACK_TO_SAVEPOINT NUMBER_OF_RELEASE_SAVEPOINT OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID NESTING_EVENT_TYPE +# +# STEP 7.6 - XA TRANSACTION - LONG GTRID AND BQUAL +# +XA START 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890; +INSERT INTO t1 VALUES (703, 'XA LONG'); +XA END 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890; +XA PREPARE 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890; +XA COMMIT 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890; + +## Expect 1 committed XA transaction, state COMMITTED in current and history +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', 'BQUAL_6789012345678901234567890123456789012345678901234567890123', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', 'BQUAL_6789012345678901234567890123456789012345678901234567890123', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); +# +# STEP 7.7 - XA TRANSACTION - LONG GTRID AND BINARY BQUAL +# +XA START 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890; +INSERT INTO t1 VALUES (704, 'XA LONG/BINARY'); +XA END 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890; +XA PREPARE 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890; +XA COMMIT 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890; + +## Expect 1 committed XA transaction, state COMMITTED in current and history +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', '0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', '0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +======================================================================== +# STEP 8 - TRANSACTIONAL AND NON-TRANSACTIONAL TABLES +======================================================================== + +SET SESSION AUTOCOMMIT = 0; +SELECT COUNT(*) FROM performance_schema.events_transactions_current ORDER BY event_id; +COUNT(*) +0 + +# +# STEP 8.1 - UPDATE NON-TRANSACTIONAL TABLE +# +INSERT INTO nt1 VALUES (801, 'NON-TRANSACTIONAL'); + +## Expect 0 transactions in events_transactions_current +CALL transaction_verifier(0, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', '', 0, 0, 0, 0); +ACTUAL EXPECTED + 0 0 +COMMIT; + +## Expect 0 transactions in events_transactions_history +CALL transaction_verifier(1, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', '', 0, 0, 0, 0); +ACTUAL EXPECTED + 0 0 + +# +# STEP 8.2 - UPDATE TRANSACTIONAL AND NON-TRANSACTIONAL TABLES +# + +## First non-transactional... + +INSERT INTO nt1 VALUES (802, 'NON-TRANSACTIONAL'); + +## Expect 0 transactions in events_transactions_current +CALL transaction_verifier(0, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', '', 0, 0, 0, 0); +ACTUAL EXPECTED + 0 0 + +## Now transactional. Transaction should be started. +INSERT INTO t1 VALUES (802, 'TRANSACTIONAL'); + +## Expect 1 transaction in events_transactions_current +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 + +COMMIT; + +## Expect 1 committed transaction in events_transactions_current and history +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +======================================================================== +# STEP 9 - SAVEPOINTS +======================================================================== +# +# STEP 9.1 - SAVEPOINT 1 +# +START TRANSACTION; +INSERT INTO t1 VALUES (901, 'SAVEPOINT'); +SAVEPOINT SVP001; + +## Expect 1 active transaction with 1 savepoint +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 1, 0, 0, 1); +ACTUAL EXPECTED + 1 1 + +# +# STEP 9.2 - SAVEPOINTS 2 and 3 +# +INSERT INTO t1 VALUES (902, 'SAVEPOINT'); +SAVEPOINT SVP002; +INSERT INTO t1 VALUES (903, 'SAVEPOINT'); +SAVEPOINT SVP003; +INSERT INTO t1 VALUES (904, 'SAVEPOINT'); +SELECT COUNT(*) FROM t1 WHERE s1 > 900; +COUNT(*) +4 + +# +# STEP 9.3 - ROLLBACK TO SAVEPOINT 2 +# +ROLLBACK TO SVP002; + +## Expect 1 active transaction with 3 savepoints, 1 rollback to savepoint +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 1, 0, 1); +ACTUAL EXPECTED + 1 1 + +# +# STEP 9.4 - RELEASE SAVEPOINT 1 +# +RELEASE SAVEPOINT SVP001; + +## Expect 1 active transaction with 3 savepoints, 1 rollback to savepoint, 1 release savepoint +CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 1, 1, 1); +ACTUAL EXPECTED + 1 1 +# +# STEP 9.5 - COMMIT +# +COMMIT; + +## Expect 1 committed transaction with 3 savepoints, 1 rollback to savepoint, 1 release savepoint +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 1, 1, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +======================================================================== +# STEP 10 - GTIDs +======================================================================== +GTIDs are tested in transaction_gtid.test. + +======================================================================== +# STEP 11 - MISCELLANY +======================================================================== +# +# STEP 11.1 - TRUNCATE DURING ACTIVE TRANSACTION +# + +# Verify that truncating events_transactions_current during an active transaction +# does not leave an orphaned transaction event, and that the row index to +# events_transactions_history is reset to 0. + +START TRANSACTION; +INSERT INTO t1 VALUES (1110, 'INSERT 1110'); +TRUNCATE performance_schema.events_transactions_current; + +COMMIT; + +START TRANSACTION; +INSERT INTO t1 VALUES (1111, 'INSERT 1111'); +COMMIT; + +## Expect 1 transaction for connection 1 +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', '', '', '', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_transaction_tables(); + +# +# STEP 11.2 - DISABLE THREAD INSTRUMENTATION +# +UPDATE performance_schema.setup_consumers +SET enabled = 'NO' + WHERE name = 'thread_instrumentation'; + +TRUNCATE performance_schema.events_transactions_summary_global_by_event_name; + +START TRANSACTION; +INSERT INTO t1 VALUES (1120, 'INSERT 1120'); +COMMIT; + +## Expect 1 event with non-zero summary stats +SELECT EVENT_NAME, COUNT_STAR, SUM_TIMER_WAIT, MIN_TIMER_WAIT, AVG_TIMER_WAIT, COUNT_READ_WRITE +FROM performance_schema.events_transactions_summary_global_by_event_name +WHERE count_star = 1 and sum_timer_wait != 0; +EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT COUNT_READ_WRITE + +## Disable timing stats for 'transaction' +UPDATE performance_schema.setup_instruments SET timed = 'NO' WHERE name = 'transaction'; + +TRUNCATE performance_schema.events_transactions_summary_global_by_event_name; + +START TRANSACTION; +INSERT INTO t1 VALUES (1121, 'INSERT 1121'); +COMMIT; + +## Expect 1 event, 0 stats +SELECT * FROM performance_schema.events_transactions_summary_global_by_event_name; +EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT COUNT_READ_WRITE SUM_TIMER_READ_WRITE MIN_TIMER_READ_WRITE AVG_TIMER_READ_WRITE MAX_TIMER_READ_WRITE COUNT_READ_ONLY SUM_TIMER_READ_ONLY MIN_TIMER_READ_ONLY AVG_TIMER_READ_ONLY MAX_TIMER_READ_ONLY +transaction 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 + +## Restore setup_consumers and setup_instruments +UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name = 'thread_instrumentation'; +UPDATE performance_schema.setup_instruments SET enabled = 'YES' WHERE name = 'transaction'; + +DELETE FROM t1; +CALL clear_history(); + +# +# STEP 11.3 - STATEMENT ROLLBACK - AUTOCOMMIT OFF - BINLOG FORMAT 'STATEMENT' +# +SET SESSION binlog_format = STATEMENT; +SET SESSION AUTOCOMMIT = 0; + +START TRANSACTION; +INSERT INTO t1 VALUES (1130, 'INSERT 1130'); + +## Expect binlog statement mode error +UPDATE t1, performance_schema.setup_instruments pfs +SET t1.s1 = 1, pfs.timed = 'NO'; + +COMMIT; + +SET SESSION AUTOCOMMIT = 1; + +## Expect 1 committed transaction +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', '', '', 'NO', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 + +DELETE FROM t1; +CALL clear_history(); + +# +# STEP 11.4 - STATEMENT ROLLBACK - AUTOCOMMIT ON - BINLOG FORMAT 'STATEMENT' +# +SET SESSION binlog_format = STATEMENT; +SET SESSION AUTOCOMMIT = 1; + +## Expect binlog statement mode error +UPDATE t1, performance_schema.setup_instruments pfs +SET t1.s1 = 1, pfs.timed = 'NO'; + +## Expect 1 rolled back transaction +CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', '', '', 'YES', 0, 0, 0, 1); +ACTUAL EXPECTED + 1 1 +CALL clear_history(); + +======================================================================== +# CLEAN UP +======================================================================== + +DROP TABLE t1; +DROP TABLE nt1; +DROP PROCEDURE clear_transaction_tables; +DROP PROCEDURE clear_transaction_history; +DROP PROCEDURE clear_statement_history; +DROP PROCEDURE clear_history; +DROP PROCEDURE transaction_verifier; diff --git a/mysql-test/suite/perfschema/r/transaction_nested_events.result-pq b/mysql-test/suite/perfschema/r/transaction_nested_events.result-pq new file mode 100644 index 000000000..46e53c604 --- /dev/null +++ b/mysql-test/suite/perfschema/r/transaction_nested_events.result-pq @@ -0,0 +1,674 @@ + +#======================================================================== +# STEP 1 - SETUP +#======================================================================== + +## Setup control thread + +SET SESSION AUTOCOMMIT= 1; +USE test; +DROP DATABASE IF EXISTS db; + +## Create test database, test tables, one transactional and one non-transactional +CREATE DATABASE db; +CREATE TABLE db.t1 (s1 int, s2 varchar(64)) ENGINE=INNODB; +CREATE TABLE db.nt1 (s1 int, s2 varchar(64)) ENGINE=MYISAM; +CREATE PROCEDURE db.tp_update() UPDATE t1 SET s1 = s1 + 1; +CREATE PROCEDURE db.tp_start() START TRANSACTION; +CREATE PROCEDURE db.tp_rollback() ROLLBACK; +CREATE PROCEDURE db.tp_commit() COMMIT; +CREATE FUNCTION db.fn_add(x INT, y INT) RETURNS INT +BEGIN +INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y"); +RETURN x+y; +END | + +## Warm-up data-dictionary cache. + +## Setup connection 1 +USE db; +SET SESSION AUTOCOMMIT = 1; +SELECT thread_id INTO @my_thread_id +FROM performance_schema.threads +WHERE processlist_id = connection_id(); + +## Disable events from the control (default) connection +UPDATE performance_schema.threads SET instrumented = 'NO' WHERE processlist_id = CONNECTION_ID(); +SET @all_threads= 0; + +## Enable only transaction and statement instruments +UPDATE performance_schema.setup_instruments SET enabled='NO', timed='NO'; +UPDATE performance_schema.setup_instruments SET enabled='YES' + WHERE name LIKE ('statement/%') OR name = 'transaction'; + +## Clear statement and transaction history +CALL test.clear_history(); + +#======================================================================== +# STEP 2 - BASIC TRANSACTION +#======================================================================== +# +# STEP 2.1 - IMPLICIT +# +INSERT INTO t1 VALUES (210, "INSERT 210"); +INSERT INTO t1 VALUES (211, "INSERT 211"); +INSERT INTO t1 VALUES (212, "INSERT 212"); +UPDATE t1 SET s1 = s1 + 1 WHERE s1 = 212; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 8 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 2 transaction COMMITTED READ WRITE REPEATABLE READ YES 1 STATEMENT +thread_id 4 4 transaction COMMITTED READ WRITE REPEATABLE READ YES 3 STATEMENT +thread_id 6 6 transaction COMMITTED READ WRITE REPEATABLE READ YES 5 STATEMENT +thread_id 8 8 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/insert NULL NULL NULL 0 INSERT INTO t1 VALUES (210, "INSERT 210") +thread_id 3 4 statement/sql/insert NULL NULL NULL 0 INSERT INTO t1 VALUES (211, "INSERT 211") +thread_id 5 6 statement/sql/insert NULL NULL NULL 0 INSERT INTO t1 VALUES (212, "INSERT 212") +thread_id 7 8 statement/sql/update NULL NULL NULL 0 UPDATE t1 SET s1 = s1 + 1 WHERE s1 = 212 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/insert NULL NULL INSERT INTO t1 VALUES (210, "INSERT 210") +thread_id 2 2 transaction 1 STATEMENT +thread_id 3 4 statement/sql/insert NULL NULL INSERT INTO t1 VALUES (211, "INSERT 211") +thread_id 4 4 transaction 3 STATEMENT +thread_id 5 6 statement/sql/insert NULL NULL INSERT INTO t1 VALUES (212, "INSERT 212") +thread_id 6 6 transaction 5 STATEMENT +thread_id 7 8 statement/sql/update NULL NULL UPDATE t1 SET s1 = s1 + 1 WHERE s1 = 212 +thread_id 8 8 transaction 7 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 2.2 - EXPLICIT +# +START TRANSACTION; +INSERT INTO t1 VALUES (220, "INSERT 220"), (221, "INSERT 221"); +UPDATE t1 SET s2 = "UPDATE 221" WHERE s1 = 221; +COMMIT; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 5 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 5 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (220, "INSERT 220"), (221, "INSERT 221") +thread_id 4 4 statement/sql/update NULL 2 TRANSACTION 0 UPDATE t1 SET s2 = "UPDATE 221" WHERE s1 = 221 +thread_id 5 5 statement/sql/commit NULL 2 TRANSACTION 0 COMMIT + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 5 transaction 1 STATEMENT +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (220, "INSERT 220"), (221, "INSERT 221") +thread_id 4 4 statement/sql/update 2 TRANSACTION UPDATE t1 SET s2 = "UPDATE 221" WHERE s1 = 221 +thread_id 5 5 statement/sql/commit 2 TRANSACTION COMMIT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +#======================================================================== +# STEP 3 - TRANSACTIONS AND STORED PROCEDURES +#======================================================================== +# +# STEP 3.1 - STORED PROCEDURE STARTED WITHIN TRANSACTION +# + +START TRANSACTION; +INSERT INTO t1 VALUES (310, "INSERT 310"); +INSERT INTO t1 VALUES (311, "INSERT 311"); +INSERT INTO t1 VALUES (312, "INSERT 312"); +INSERT INTO t1 VALUES (313, "INSERT 313"); +CALL tp_update(); +COMMIT; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (310, "INSERT 310") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (311, "INSERT 311") +thread_id 5 5 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (312, "INSERT 312") +thread_id 6 6 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (313, "INSERT 313") +thread_id 7 8 statement/sql/call_procedure NULL 2 TRANSACTION 0 CALL tp_update() +thread_id 8 8 statement/sp/stmt tp_update 7 STATEMENT 1 UPDATE t1 SET s1 = s1 + 1 +thread_id 9 9 statement/sql/commit NULL 2 TRANSACTION 0 COMMIT + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 9 transaction 1 STATEMENT +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (310, "INSERT 310") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (311, "INSERT 311") +thread_id 5 5 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (312, "INSERT 312") +thread_id 6 6 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (313, "INSERT 313") +thread_id 7 8 statement/sql/call_proced 2 TRANSACTION CALL tp_update() +thread_id 8 8 statement/sp/stmt 7 STATEMENT UPDATE t1 SET s1 = s1 + 1 +thread_id 9 9 statement/sql/commit 2 TRANSACTION COMMIT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 3.2 - TRANSACTION STARTED WITHIN STORED PROCEDURE +# + +CALL tp_start(); +INSERT INTO t1 VALUES (320, "INSERT 320"),(321, "INSERT 321"); +INSERT INTO t1 VALUES (322, "INSERT 322"),(323, "INSERT 323"); +UPDATE t1 SET s1 = s1 + 1 WHERE s1 > 320; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +320 INSERT 320 +322 INSERT 321 +323 INSERT 322 +324 INSERT 323 +COMMIT; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 7 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 8 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 7 STATEMENT +thread_id 8 9 transaction COMMITTED READ WRITE REPEATABLE READ NO 7 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 3 statement/sql/call_procedure NULL NULL NULL 0 CALL tp_start() +thread_id 2 3 statement/sp/stmt tp_start 1 STATEMENT 1 START TRANSACTION +thread_id 4 4 statement/sql/insert NULL 3 TRANSACTION 0 INSERT INTO t1 VALUES (320, "INSERT 320"),(321, "INSERT 321") +thread_id 5 5 statement/sql/insert NULL 3 TRANSACTION 0 INSERT INTO t1 VALUES (322, "INSERT 322"),(323, "INSERT 323") +thread_id 6 6 statement/sql/update NULL 3 TRANSACTION 0 UPDATE t1 SET s1 = s1 + 1 WHERE s1 > 320 +thread_id 7 8 statement/sql/select NULL 3 TRANSACTION 0 SELECT * FROM t1 ORDER BY s1 +thread_id 9 9 statement/sql/commit NULL NULL NULL 0 COMMIT + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 3 statement/sql/call_proced NULL NULL CALL tp_start() +thread_id 2 3 statement/sp/stmt 1 STATEMENT START TRANSACTION +thread_id 4 4 statement/sql/insert 3 TRANSACTION INSERT INTO t1 VALUES (320, "INSERT 320"),(321, "INSERT 321") +thread_id 5 5 statement/sql/insert 3 TRANSACTION INSERT INTO t1 VALUES (322, "INSERT 322"),(323, "INSERT 323") +thread_id 6 6 statement/sql/update 3 TRANSACTION UPDATE t1 SET s1 = s1 + 1 WHERE s1 > 320 +thread_id 7 8 statement/sql/select 3 TRANSACTION SELECT * FROM t1 ORDER BY s1 +thread_id 8 8 transaction 7 STATEMENT +thread_id 8 9 transaction 7 STATEMENT +thread_id 9 9 statement/sql/commit NULL NULL COMMIT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 3.3 - TRANSACTION ENDED WITHIN STORED PROCEDURE +# + +## COMMIT within stored procedure +START TRANSACTION; +INSERT INTO t1 VALUES (330, "INSERT 330"),(331, "INSERT 331"); +INSERT INTO t1 VALUES (332, "INSERT 332"),(333, "INSERT 333"); +DELETE FROM t1 WHERE s1 > 331; +CALL tp_commit(); + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +330 INSERT 330 +331 INSERT 331 + +## ROLLBACK within stored procedure +START TRANSACTION; +UPDATE t1 SET s1 = s1*2 WHERE s1 > 331; +CALL tp_rollback(); + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +330 INSERT 330 +331 INSERT 331 +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 18 18 transaction COMMITTED READ WRITE REPEATABLE READ YES 16 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 7 transaction COMMITTED READ WRITE REPEATABLE READ NO 1 STATEMENT +thread_id 10 10 transaction COMMITTED READ WRITE REPEATABLE READ YES 8 STATEMENT +thread_id 10 10 transaction COMMITTED READ WRITE REPEATABLE READ YES 8 STATEMENT +thread_id 12 15 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 11 STATEMENT +thread_id 18 18 transaction COMMITTED READ WRITE REPEATABLE READ YES 16 STATEMENT +thread_id 18 18 transaction COMMITTED READ WRITE REPEATABLE READ YES 16 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (330, "INSERT 330"),(331, "INSERT 331") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (332, "INSERT 332"),(333, "INSERT 333") +thread_id 5 5 statement/sql/delete NULL 2 TRANSACTION 0 DELETE FROM t1 WHERE s1 > 331 +thread_id 6 7 statement/sql/call_procedure NULL 2 TRANSACTION 0 CALL tp_commit() +thread_id 7 7 statement/sp/stmt tp_commit 6 STATEMENT 1 COMMIT +thread_id 8 10 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 +thread_id 11 12 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 13 13 statement/sql/update NULL 12 TRANSACTION 0 UPDATE t1 SET s1 = s1*2 WHERE s1 > 331 +thread_id 14 15 statement/sql/call_procedure NULL 12 TRANSACTION 0 CALL tp_rollback() +thread_id 15 15 statement/sp/stmt tp_rollback 14 STATEMENT 1 ROLLBACK +thread_id 16 18 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 7 transaction 1 STATEMENT +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (330, "INSERT 330"),(331, "INSERT 331") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (332, "INSERT 332"),(333, "INSERT 333") +thread_id 5 5 statement/sql/delete 2 TRANSACTION DELETE FROM t1 WHERE s1 > 331 +thread_id 6 7 statement/sql/call_proced 2 TRANSACTION CALL tp_commit() +thread_id 7 7 statement/sp/stmt 6 STATEMENT COMMIT +thread_id 8 10 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 10 10 transaction 8 STATEMENT +thread_id 11 12 statement/sql/begin NULL NULL START TRANSACTION +thread_id 12 15 transaction 11 STATEMENT +thread_id 13 13 statement/sql/update 12 TRANSACTION UPDATE t1 SET s1 = s1*2 WHERE s1 > 331 +thread_id 14 15 statement/sql/call_proced 12 TRANSACTION CALL tp_rollback() +thread_id 15 15 statement/sp/stmt 14 STATEMENT ROLLBACK +thread_id 16 18 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 18 18 transaction 16 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +#======================================================================== +# STEP 4 - TRANSACTIONS AND STORED FUNCTIONS +#======================================================================== + +# +# STEP 4.1 - FUNCTION WITHIN A TRANSACTION +# + +## Clear history +CALL test.clear_history(); + +START TRANSACTION; +INSERT INTO t1 VALUES (410, "INSERT 410"); +INSERT INTO t1 VALUES (411, "INSERT 411"); +INSERT INTO t1 VALUES (412, "INSERT 412"); +DELETE FROM t1 WHERE s1 > 410; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +410 INSERT 410 + +SELECT fn_add(413, 414); +fn_add(413, 414) +827 +COMMIT; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +410 INSERT 410 +413 INSERT x +414 INSERT y +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 15 15 transaction COMMITTED READ WRITE REPEATABLE READ YES 13 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 8 8 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 7 STATEMENT +thread_id 8 12 transaction COMMITTED READ WRITE REPEATABLE READ NO 7 STATEMENT +thread_id 15 15 transaction COMMITTED READ WRITE REPEATABLE READ YES 13 STATEMENT +thread_id 15 15 transaction COMMITTED READ WRITE REPEATABLE READ YES 13 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (410, "INSERT 410") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (411, "INSERT 411") +thread_id 5 5 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (412, "INSERT 412") +thread_id 6 6 statement/sql/delete NULL 2 TRANSACTION 0 DELETE FROM t1 WHERE s1 > 410 +thread_id 7 8 statement/sql/select NULL 2 TRANSACTION 0 SELECT * FROM t1 ORDER BY s1 +thread_id 9 11 statement/sql/select NULL NULL NULL 0 SELECT fn_add(413, 414) +thread_id 10 10 statement/sp/stmt fn_add 9 STATEMENT 1 INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 11 11 statement/sp/freturn fn_add 9 STATEMENT 1 NULL +thread_id 12 12 statement/sql/commit NULL NULL NULL 0 COMMIT +thread_id 13 15 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (410, "INSERT 410") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (411, "INSERT 411") +thread_id 5 5 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (412, "INSERT 412") +thread_id 6 6 statement/sql/delete 2 TRANSACTION DELETE FROM t1 WHERE s1 > 410 +thread_id 7 8 statement/sql/select 2 TRANSACTION SELECT * FROM t1 ORDER BY s1 +thread_id 8 8 transaction 7 STATEMENT +thread_id 8 12 transaction 7 STATEMENT +thread_id 9 11 statement/sql/select NULL NULL SELECT fn_add(413, 414) +thread_id 10 10 statement/sp/stmt 9 STATEMENT INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 11 11 statement/sp/freturn 9 STATEMENT NULL +thread_id 12 12 statement/sql/commit NULL NULL COMMIT +thread_id 13 15 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 15 15 transaction 13 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + + +## Again, but this time with a rollback + +START TRANSACTION; +SELECT fn_add(415, 416); +fn_add(415, 416) +831 + +ROLLBACK; + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 9 9 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 2 6 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 1 STATEMENT +thread_id 9 9 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT +thread_id 9 9 transaction COMMITTED READ WRITE REPEATABLE READ YES 7 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 5 statement/sql/select NULL 2 TRANSACTION 0 SELECT fn_add(415, 416) +thread_id 4 4 statement/sp/stmt fn_add 3 STATEMENT 1 INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 5 5 statement/sp/freturn fn_add 3 STATEMENT 1 NULL +thread_id 6 6 statement/sql/rollback NULL 2 TRANSACTION 0 ROLLBACK +thread_id 7 9 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 2 6 transaction 1 STATEMENT +thread_id 3 5 statement/sql/select 2 TRANSACTION SELECT fn_add(415, 416) +thread_id 4 4 statement/sp/stmt 3 STATEMENT INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y") +thread_id 5 5 statement/sp/freturn 3 STATEMENT NULL +thread_id 6 6 statement/sql/rollback 2 TRANSACTION ROLLBACK +thread_id 7 9 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 9 9 transaction 7 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# +# STEP 4.2 - TRANSACTION CANNOT BE STARTED OR ENDED WITHIN FUNCTION +# +CREATE FUNCTION fn_err1() RETURNS VARCHAR(10) BEGIN START TRANSACTION ; RETURN invalid ; END| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. + +## Expect 0 transactions +SELECT COUNT(*) FROM performance_schema.events_transactions_history; +COUNT(*) +0 + +## Expect stored function does not exist + +SELECT fn_err1(); +ERROR 42000: FUNCTION db.fn_err1 does not exist + +## Expect 0 transactions +SELECT COUNT(*) FROM performance_schema.events_transactions_history; +COUNT(*) +0 + +CREATE FUNCTION fn_err2() RETURNS VARCHAR(10) BEGIN COMMIT; RETURN invalid ; END| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. + +## Expect stored function does not exist + +START TRANSACTION; +DELETE FROM t1 WHERE s1 > 320; +SELECT fn_err2(); +ERROR 42000: FUNCTION db.fn_err2 does not exist + +## Expect 0 transactions +SELECT COUNT(*) FROM performance_schema.events_transactions_history; +COUNT(*) +0 + +## Clear transaction and statement tables +CALL test.clear_history(); +#======================================================================== +# STEP 5 - TRANSACTIONS AND TRIGGERS +#======================================================================== + +# +# STEP 5.1 - FORCE STATEMENT ROLLBACK FROM TRIGGER +# +## Create a trigger to force statement rollback + +CREATE TRIGGER trigger_before_update BEFORE UPDATE ON t1 +FOR EACH ROW +BEGIN +IF OLD.s1 >= 505 THEN +SIGNAL sqlstate '45001' SET message_text = "FORCE ERROR"; +END IF; +END;| + +## Warm-up data-dictionary cache. + +## Clear history +CALL test.clear_history(); + +## Insert multiple rows, then update. Trigger will force rollback the +## UPDATE statement, but the transaction should not roll back. + +START TRANSACTION; +INSERT INTO t1 VALUES (500, "INSERT 500"); +INSERT INTO t1 VALUES (501, "INSERT 501"); +INSERT INTO t1 VALUES (502, "INSERT 502"); +INSERT INTO t1 VALUES (503, "INSERT 503"); +INSERT INTO t1 VALUES (504, "INSERT 504"); +INSERT INTO t1 VALUES (505, "INSERT 505"); + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +500 INSERT 500 +501 INSERT 501 +502 INSERT 502 +503 INSERT 503 +504 INSERT 504 +505 INSERT 505 + +## Expect error when UPDATE hits record 505 + +UPDATE t1 SET s1 = s1 * 2 WHERE s1 >= 500; +ERROR 45001: FORCE ERROR + +## Verify that INSERT succeeded, UPDATE failed and transaction did not rollback + +SELECT * FROM t1 ORDER BY s1; +s1 s2 +500 INSERT 500 +501 INSERT 501 +502 INSERT 502 +503 INSERT 503 +504 INSERT 504 +505 INSERT 505 +COMMIT; + +DROP TRIGGER trigger_before_update; +#======================================================================== +# Verify +#======================================================================== +EVENTS_TRANSACTIONS_CURRENT + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 23 23 transaction COMMITTED READ WRITE REPEATABLE READ NO 22 STATEMENT + +EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME STATE ACCESS_MODE ISOLATION_LEVEL AUTO R_NESTING_EVENT_ID NESTING_EVENT_TYPE +thread_id 10 10 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 9 STATEMENT +thread_id 20 20 transaction ROLLED BACK READ WRITE REPEATABLE READ NO 19 STATEMENT +thread_id 20 21 transaction COMMITTED READ WRITE REPEATABLE READ NO 19 STATEMENT +thread_id 23 23 transaction COMMITTED READ WRITE REPEATABLE READ NO 22 STATEMENT + +EVENTS_STATEMENTS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME OBJECT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE LEVEL SQL_TEXT +thread_id 1 2 statement/sql/begin NULL NULL NULL 0 START TRANSACTION +thread_id 3 3 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (500, "INSERT 500") +thread_id 4 4 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (501, "INSERT 501") +thread_id 5 5 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (502, "INSERT 502") +thread_id 6 6 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (503, "INSERT 503") +thread_id 7 7 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (504, "INSERT 504") +thread_id 8 8 statement/sql/insert NULL 2 TRANSACTION 0 INSERT INTO t1 VALUES (505, "INSERT 505") +thread_id 9 10 statement/sql/select NULL 2 TRANSACTION 0 SELECT * FROM t1 ORDER BY s1 +thread_id 11 18 statement/sql/update NULL NULL NULL 0 UPDATE t1 SET s1 = s1 * 2 WHERE s1 >= 500 +thread_id 12 12 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 13 13 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 14 14 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 15 15 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 16 16 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 17 17 statement/sp/jump_if_not trigger_befo 11 STATEMENT 1 NULL +thread_id 18 18 statement/sp/stmt trigger_befo 11 STATEMENT 1 SIGNAL sqlstate '45001' SET message_text = "FORCE ERROR" +thread_id 19 20 statement/sql/select NULL NULL NULL 0 SELECT * FROM t1 ORDER BY s1 +thread_id 21 21 statement/sql/commit NULL NULL NULL 0 COMMIT +thread_id 22 23 statement/sql/drop_trigger NULL NULL NULL 0 DROP TRIGGER trigger_before_update + +## Combined statement and transaction event history ordered by event id + +EVENTS_STATEMENTS_HISTORY_LONG + EVENTS_TRANSACTIONS_HISTORY_LONG + +THREAD_ID R_EVENT_ID R_END_EVENT_ID EVENT_NAME R_NESTING_EVENT_ID NESTING_EVENT_TYPE SQL_TXT +thread_id 1 2 statement/sql/begin NULL NULL START TRANSACTION +thread_id 3 3 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (500, "INSERT 500") +thread_id 4 4 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (501, "INSERT 501") +thread_id 5 5 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (502, "INSERT 502") +thread_id 6 6 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (503, "INSERT 503") +thread_id 7 7 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (504, "INSERT 504") +thread_id 8 8 statement/sql/insert 2 TRANSACTION INSERT INTO t1 VALUES (505, "INSERT 505") +thread_id 9 10 statement/sql/select 2 TRANSACTION SELECT * FROM t1 ORDER BY s1 +thread_id 10 10 transaction 9 STATEMENT +thread_id 11 18 statement/sql/update NULL NULL UPDATE t1 SET s1 = s1 * 2 WHERE s1 >= 500 +thread_id 12 12 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 13 13 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 14 14 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 15 15 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 16 16 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 17 17 statement/sp/jump_if_not 11 STATEMENT NULL +thread_id 18 18 statement/sp/stmt 11 STATEMENT SIGNAL sqlstate '45001' SET message_text = "FORCE ERROR" +thread_id 19 20 statement/sql/select NULL NULL SELECT * FROM t1 ORDER BY s1 +thread_id 20 20 transaction 19 STATEMENT +thread_id 20 21 transaction 19 STATEMENT +thread_id 21 21 statement/sql/commit NULL NULL COMMIT +thread_id 22 23 statement/sql/drop_trigge NULL NULL DROP TRIGGER trigger_before_update +thread_id 23 23 transaction 22 STATEMENT + +## Clear statement and transaction history +CALL test.clear_history(); +## Reset db.t1 +DELETE FROM db.t1; + +# TODO: Detect statement events from scheduled event +#======================================================================= +# Cleanup +#======================================================================= +DROP DATABASE db; +UPDATE performance_schema.setup_instruments SET enabled='YES', timed='YES'; +DROP PROCEDURE clear_transaction_tables; +DROP PROCEDURE clear_transaction_history; +DROP PROCEDURE clear_statement_history; +DROP PROCEDURE clear_history; +DROP PROCEDURE transaction_verifier; diff --git a/mysql-test/suite/perfschema/t/transaction.test b/mysql-test/suite/perfschema/t/transaction.test index ae0f373c4..661a2c27d 100644 --- a/mysql-test/suite/perfschema/t/transaction.test +++ b/mysql-test/suite/perfschema/t/transaction.test @@ -527,7 +527,14 @@ ROLLBACK TO SVP002; --echo --echo ## Expect 1 active transaction with 3 savepoints, 1 rollback to savepoint --connection default -CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 0, 1); +if ($PQ_TEST) +{ + CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 1, 0, 1); +} +if (!$PQ_TEST) +{ + CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 0, 1); +} --echo --echo # @@ -539,7 +546,14 @@ RELEASE SAVEPOINT SVP001; --echo --echo ## Expect 1 active transaction with 3 savepoints, 1 rollback to savepoint, 1 release savepoint --connection default -CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 1, 1); +if ($PQ_TEST) +{ + CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 1, 1, 1); +} +if (!$PQ_TEST) +{ + CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 1, 1); +} --echo # --echo # STEP 9.5 - COMMIT @@ -550,7 +564,14 @@ COMMIT; --echo --echo ## Expect 1 committed transaction with 3 savepoints, 1 rollback to savepoint, 1 release savepoint --connection default -CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 1, 1); +if ($PQ_TEST) +{ + CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 1, 1, 1); +} +if (!$PQ_TEST) +{ + CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 1, 1); +} CALL clear_transaction_tables(); --echo diff --git a/mysql-test/suite/rpl/r/rpl_invisible_indexes.result-pq b/mysql-test/suite/rpl/r/rpl_invisible_indexes.result-pq new file mode 100644 index 000000000..fa7a037c2 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_invisible_indexes.result-pq @@ -0,0 +1,91 @@ +include/master-slave.inc +Warnings: +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. +[connection master] +# Create a table with an index +CREATE TABLE t1 ( i INT , KEY (i)); +INSERT INTO t1 VALUES (2),(3),(5),(7),(11),(13); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Check that the index is on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 i 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +# Make the index invisible +ALTER TABLE t1 ALTER INDEX i INVISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the index is invisible on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 i 1 i A 6 NULL NULL YES BTREE NO NULL +EXPLAIN SELECT * FROM t1 WHERE i=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 6 16.67 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`i` = 3) +[Connection Master] +ALTER TABLE t1 ALTER INDEX i VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the index is visible on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 1 i 1 i A 6 NULL NULL YES BTREE YES NULL +EXPLAIN SELECT * FROM t1 WHERE i=3; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ref i i 5 const 1 100.00 Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`i` = 3) +[Connection Master] +# Create an invisible index on the table +CREATE UNIQUE INDEX idx ON t1(i) INVISIBLE; +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the invisible is created on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 idx 1 i A 6 NULL NULL YES BTREE NO NULL +t1 1 i 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +ALTER TABLE t1 DROP INDEX i, ALTER INDEX idx VISIBLE, ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 idx 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +# Alter the engine +ALTER TABLE t1 ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +t1 0 idx 1 i A 6 NULL NULL YES BTREE YES NULL +[Connection Master] +# Clean up +DROP TABLE t1; +include/sync_slave_sql_with_master.inc +[Connection Slave] +SELECT * FROM t1; +ERROR 42S02: Table 'test.t1' doesn't exist +include/rpl_end.inc diff --git a/mysql-test/suite/secondary_engine/r/explain.result-pq b/mysql-test/suite/secondary_engine/r/explain.result-pq new file mode 100644 index 000000000..20266a79e --- /dev/null +++ b/mysql-test/suite/secondary_engine/r/explain.result-pq @@ -0,0 +1,105 @@ +# +# Bug#28556942: ADD USING SECONDARY ENGINE TO EXPLAIN +# +CREATE TABLE t1 (a INT) SECONDARY_ENGINE MOCK; +# Before table is loaded, the secondary engine should not be used. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 1 100.00 Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "table_name": "", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "parallel_execute": "1 workers", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "16" + }, + "used_columns": [ + "a" + ], + "query_block": { + "cost_info": { + "query_cost": "0.35" + }, + "table": { + "select_id": 2, + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "cost_info": { + "read_cost": "0.25", + "eval_cost": "0.10", + "prefix_cost": "0.35", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ] + } + } + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +ALTER TABLE t1 SECONDARY_LOAD; +# After table is loaded, the secondary engine should be used. +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using secondary engine MOCK +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +EXPLAIN FORMAT=JSON SELECT * FROM t1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost_info": { + "query_cost": "0.60" + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows_examined_per_scan": 1, + "rows_produced_per_join": 1, + "filtered": "100.00", + "using_secondary_engine": "MOCK", + "cost_info": { + "read_cost": "0.50", + "eval_cost": "0.10", + "prefix_cost": "0.60", + "data_read_per_join": "8" + }, + "used_columns": [ + "a" + ] + } + } +} +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` +DROP TABLE t1; diff --git a/mysql-test/suite/secondary_engine/r/plan_cost_debug.result-pq b/mysql-test/suite/secondary_engine/r/plan_cost_debug.result-pq new file mode 100644 index 000000000..4e0191c0d --- /dev/null +++ b/mysql-test/suite/secondary_engine/r/plan_cost_debug.result-pq @@ -0,0 +1,84 @@ +# +# Bug#29023387: GET PLAN COST FROM SECONDARY ENGINE +# +CREATE TABLE t1(x INT, y INT) SECONDARY_ENGINE MOCK; +CREATE TABLE t2(x INT, y INT) SECONDARY_ENGINE MOCK; +CREATE TABLE t3(x INT, y INT) SECONDARY_ENGINE MOCK; +INSERT INTO t1 VALUES (1, 2), (3, 4); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t2 VALUES (1, 2), (3, 4); +INSERT INTO t2 SELECT * FROM t2; +INSERT INTO t3 VALUES (1, 2), (3, 4); +ALTER TABLE t1 SECONDARY_LOAD; +ALTER TABLE t2 SECONDARY_LOAD; +ALTER TABLE t3 SECONDARY_LOAD; +ANALYZE TABLE t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +SET @@optimizer_trace='enabled=on'; +EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.x = t2.y LEFT JOIN t3 ON t2.x = t3.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join); Using secondary engine MOCK +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join); Using secondary engine MOCK +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y`,`test`.`t3`.`x` AS `x`,`test`.`t3`.`y` AS `y` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`y` = `test`.`t2`.`x`)) where (`test`.`t1`.`x` = `test`.`t2`.`y`) +SELECT TRACE->'$**.secondary_engine_cost' FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +TRACE->'$**.secondary_engine_cost' +[9.10036, 5.90021] +SET @@optimizer_trace='enabled=off'; +SET DEBUG = '+d,secondary_engine_mock_change_join_order'; +EXPLAIN SELECT * FROM t1 AS X JOIN t2 ON X.x = t2.y LEFT JOIN t3 ON t2.x = t3.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK +1 SIMPLE X NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join); Using secondary engine MOCK +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join); Using secondary engine MOCK +EXPLAIN SELECT * FROM t1 JOIN t2 AS X ON t1.x = X.y LEFT JOIN t3 ON X.x = t3.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE X NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK +1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join); Using secondary engine MOCK +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join); Using secondary engine MOCK +EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.x = t2.y LEFT JOIN t3 AS X ON t2.x = X.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 Using secondary engine MOCK +1 SIMPLE X NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join); Using secondary engine MOCK +1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join); Using secondary engine MOCK +SET DEBUG = '-d,secondary_engine_mock_change_join_order'; +SET DEBUG = '+d,secondary_engine_mock_compare_cost_error'; +EXPLAIN SELECT * FROM t1 JOIN t2 ON t1.x = t2.y LEFT JOIN t3 ON t2.x = t3.y; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL 4 100.00 Parallel execute (1 workers) +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 100.00 NULL +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (hash join) +2 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y`,`test`.`t2`.`x` AS `x`,`test`.`t2`.`y` AS `y`,`test`.`t3`.`x` AS `x`,`test`.`t3`.`y` AS `y` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`y` = `test`.`t2`.`x`)) where (`test`.`t1`.`x` = `test`.`t2`.`y`) +SET DEBUG = '-d,secondary_engine_mock_compare_cost_error'; +SET optimizer_trace = 'enabled=on'; +SET use_secondary_engine = 'FORCED'; +SELECT * FROM t1 a, t2 b, t1 c, t2 d +WHERE a.x = b.x AND b.x = c.y AND a.x >= d.y; +x y x y x y x y +SELECT JSON_LENGTH( +TRACE->'$**.considered_execution_plans**.secondary_engine_cost') +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_LENGTH( +TRACE->'$**.considered_execution_plans**.secondary_engine_cost') +3 +SET DEBUG = '+d,secondary_engine_mock_choose_first_plan'; +SELECT * FROM t1 a, t2 b, t1 c, t2 d +WHERE a.x = b.x AND b.x = c.y AND a.x >= d.y; +x y x y x y x y +SELECT JSON_LENGTH( +TRACE->'$**.considered_execution_plans**.secondary_engine_cost') +FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_LENGTH( +TRACE->'$**.considered_execution_plans**.secondary_engine_cost') +1 +SET DEBUG = '-d,secondary_engine_mock_choose_first_plan'; +SET use_secondary_engine = DEFAULT; +SET optimizer_trace = 'enabled=off'; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/sys_vars/r/all_vars.result-pq b/mysql-test/suite/sys_vars/r/all_vars.result-pq new file mode 100644 index 000000000..9c4053b4f --- /dev/null +++ b/mysql-test/suite/sys_vars/r/all_vars.result-pq @@ -0,0 +1,92 @@ +create table t1 (test_name text); +create table t2 (variable_name text); +load data infile "MYSQLTEST_VARDIR/tmp/sys_vars.all_vars.txt" into table t1; +insert into t2 select variable_name from performance_schema.global_variables; +insert into t2 select variable_name from performance_schema.session_variables; +update t2 set variable_name= replace(variable_name, "performance_schema_", "pfs_"); +update t2 set variable_name= replace(variable_name, "_history_long_", "_hl_"); +update t2 set variable_name= replace(variable_name, "_history_", "_h_"); +update t2 set variable_name= replace(variable_name, "_throttle_queries_not_using_indexes", "_throttle_qni"); +update t2 set variable_name= replace(variable_name, "lock_order_", "lo_"); +select variable_name as `There should be *no* long test name listed below:` from t2 +where length(variable_name) > 50; +There should be *no* long test name listed below: +select variable_name as `There should be *no* variables listed below:` from t2 +left join t1 on variable_name=test_name where test_name is null ORDER BY variable_name; +There should be *no* variables listed below: +activate_all_roles_on_login +activate_all_roles_on_login +binlog_encryption +binlog_encryption +binlog_rotate_encryption_master_key_at_startup +binlog_rotate_encryption_master_key_at_startup +cte_max_recursion_depth +cte_max_recursion_depth +default_collation_for_utf8mb4 +default_collation_for_utf8mb4 +disabled_storage_engines +disabled_storage_engines +force_parallel_execute +force_parallel_execute +generated_random_password_length +generated_random_password_length +group_replication_consistency +group_replication_consistency +innodb_dedicated_server +innodb_dedicated_server +innodb_log_spin_cpu_abs_lwm +innodb_log_spin_cpu_abs_lwm +innodb_log_spin_cpu_pct_hwm +innodb_log_spin_cpu_pct_hwm +innodb_log_wait_for_flush_spin_hwm +innodb_log_wait_for_flush_spin_hwm +keyring_operations +keyring_operations +mandatory_roles +mandatory_roles +max_length_for_sort_data +max_length_for_sort_data +parallel_cost_threshold +parallel_cost_threshold +parallel_default_dop +parallel_default_dop +parallel_max_threads +parallel_max_threads +parallel_memory_limit +parallel_memory_limit +parallel_queue_timeout +parallel_queue_timeout +partial_revokes +partial_revokes +password_require_current +password_require_current +regexp_stack_limit +regexp_stack_limit +regexp_time_limit +regexp_time_limit +replication_optimize_for_static_plugin_config +replication_optimize_for_static_plugin_config +replication_sender_observe_commit_only +replication_sender_observe_commit_only +resultset_metadata +select_into_buffer_size +select_into_buffer_size +select_into_disk_sync +select_into_disk_sync +select_into_disk_sync_delay +select_into_disk_sync_delay +skip_slave_start +skip_slave_start +sql_require_primary_key +sql_require_primary_key +temptable_max_mmap +temptable_max_mmap +temptable_use_mmap +temptable_use_mmap +tls_ciphersuites +tls_ciphersuites +tls_version +tls_version +use_secondary_engine +drop table t1; +drop table t2; diff --git a/mysql-test/suite/sys_vars/r/debug_pq_worker_stall_basic.result-pq b/mysql-test/suite/sys_vars/r/debug_pq_worker_stall_basic.result-pq new file mode 100644 index 000000000..358bd41d8 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/debug_pq_worker_stall_basic.result-pq @@ -0,0 +1,16 @@ +# +# debug_pq_worker_stall_basic.test +# +SELECT @@global.debug_pq_worker_stall; +@@global.debug_pq_worker_stall +0 +show variables like '%debug_pq_worker_stall%'; +Variable_name Value +debug_pq_worker_stall OFF +set debug_pq_worker_stall=1; +ERROR HY000: Variable 'debug_pq_worker_stall' is a GLOBAL variable and should be set with SET GLOBAL +set global debug_pq_worker_stall=1; +SELECT @@global.debug_pq_worker_stall; +@@global.debug_pq_worker_stall +1 +set global debug_pq_worker_stall=0; diff --git a/mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result-pq b/mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result-pq new file mode 100644 index 000000000..7aa8e2f12 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result-pq @@ -0,0 +1,686 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; diff --git a/mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result-pq b/mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result-pq new file mode 100644 index 000000000..7aa8e2f12 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_monitor_enable_basic.result-pq @@ -0,0 +1,686 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; diff --git a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result-pq b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result-pq new file mode 100644 index 000000000..7aa8e2f12 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result-pq @@ -0,0 +1,686 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; diff --git a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result-pq b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result-pq new file mode 100644 index 000000000..4a858750f --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result-pq @@ -0,0 +1,694 @@ +set global innodb_monitor_disable = All; +select name, status from information_schema.innodb_metrics; +name status +metadata_table_handles_opened disabled +metadata_table_handles_closed disabled +metadata_table_reference_count disabled +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +buffer_pool_size disabled +buffer_pool_reads disabled +buffer_pool_read_requests disabled +buffer_pool_write_requests disabled +buffer_pool_wait_free disabled +buffer_pool_read_ahead disabled +buffer_pool_read_ahead_evicted disabled +buffer_pool_pages_total disabled +buffer_pool_pages_misc disabled +buffer_pool_pages_data disabled +buffer_pool_bytes_data disabled +buffer_pool_pages_dirty disabled +buffer_pool_bytes_dirty disabled +buffer_pool_pages_free disabled +buffer_pages_created disabled +buffer_pages_written disabled +buffer_pages_read disabled +buffer_data_reads disabled +buffer_data_written disabled +buffer_flush_batch_scanned disabled +buffer_flush_batch_num_scan disabled +buffer_flush_batch_scanned_per_call disabled +buffer_flush_batch_total_pages disabled +buffer_flush_batches disabled +buffer_flush_batch_pages disabled +buffer_flush_neighbor_total_pages disabled +buffer_flush_neighbor disabled +buffer_flush_neighbor_pages disabled +buffer_flush_n_to_flush_requested disabled +buffer_flush_n_to_flush_by_dirty_page disabled +buffer_flush_n_to_flush_by_age disabled +buffer_flush_adaptive_avg_time_slot disabled +buffer_LRU_batch_flush_avg_time_slot disabled +buffer_flush_adaptive_avg_time_thread disabled +buffer_LRU_batch_flush_avg_time_thread disabled +buffer_flush_adaptive_avg_time_est disabled +buffer_LRU_batch_flush_avg_time_est disabled +buffer_flush_avg_time disabled +buffer_flush_adaptive_avg_pass disabled +buffer_LRU_batch_flush_avg_pass disabled +buffer_flush_avg_pass disabled +buffer_LRU_get_free_loops disabled +buffer_LRU_get_free_waits disabled +buffer_flush_avg_page_rate disabled +buffer_flush_lsn_avg_rate disabled +buffer_flush_pct_for_dirty disabled +buffer_flush_pct_for_lsn disabled +buffer_flush_sync_waits disabled +buffer_flush_adaptive_total_pages disabled +buffer_flush_adaptive disabled +buffer_flush_adaptive_pages disabled +buffer_flush_sync_total_pages disabled +buffer_flush_sync disabled +buffer_flush_sync_pages disabled +buffer_flush_background_total_pages disabled +buffer_flush_background disabled +buffer_flush_background_pages disabled +buffer_LRU_batch_scanned disabled +buffer_LRU_batch_num_scan disabled +buffer_LRU_batch_scanned_per_call disabled +buffer_LRU_batch_flush_total_pages disabled +buffer_LRU_batches_flush disabled +buffer_LRU_batch_flush_pages disabled +buffer_LRU_batch_evict_total_pages disabled +buffer_LRU_batches_evict disabled +buffer_LRU_batch_evict_pages disabled +buffer_LRU_single_flush_scanned disabled +buffer_LRU_single_flush_num_scan disabled +buffer_LRU_single_flush_scanned_per_call disabled +buffer_LRU_single_flush_failure_count disabled +buffer_LRU_get_free_search disabled +buffer_LRU_search_scanned disabled +buffer_LRU_search_num_scan disabled +buffer_LRU_search_scanned_per_call disabled +buffer_LRU_unzip_search_scanned disabled +buffer_LRU_unzip_search_num_scan disabled +buffer_LRU_unzip_search_scanned_per_call disabled +buffer_page_read_index_leaf disabled +buffer_page_read_index_non_leaf disabled +buffer_page_read_index_ibuf_leaf disabled +buffer_page_read_index_ibuf_non_leaf disabled +buffer_page_read_undo_log disabled +buffer_page_read_index_inode disabled +buffer_page_read_ibuf_free_list disabled +buffer_page_read_ibuf_bitmap disabled +buffer_page_read_system_page disabled +buffer_page_read_trx_system disabled +buffer_page_read_fsp_hdr disabled +buffer_page_read_xdes disabled +buffer_page_read_blob disabled +buffer_page_read_zblob disabled +buffer_page_read_zblob2 disabled +buffer_page_read_rseg_array disabled +buffer_page_read_other disabled +buffer_page_written_index_leaf disabled +buffer_page_written_index_non_leaf disabled +buffer_page_written_index_ibuf_leaf disabled +buffer_page_written_index_ibuf_non_leaf disabled +buffer_page_written_undo_log disabled +buffer_page_written_index_inode disabled +buffer_page_written_ibuf_free_list disabled +buffer_page_written_ibuf_bitmap disabled +buffer_page_written_system_page disabled +buffer_page_written_trx_system disabled +buffer_page_written_fsp_hdr disabled +buffer_page_written_xdes disabled +buffer_page_written_blob disabled +buffer_page_written_zblob disabled +buffer_page_written_zblob2 disabled +buffer_page_written_rseg_array disabled +buffer_page_written_other disabled +buffer_page_written_on_log_no_waits disabled +buffer_page_written_on_log_waits disabled +buffer_page_written_on_log_wait_loops disabled +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs disabled +os_pending_reads disabled +os_pending_writes disabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs disabled +os_log_pending_writes disabled +trx_rw_commits disabled +trx_ro_commits disabled +trx_nl_ro_commits disabled +trx_commits_insert_update disabled +trx_rollbacks disabled +trx_rollbacks_savepoint disabled +trx_rollback_active disabled +trx_active_transactions disabled +trx_allocations disabled +trx_on_log_no_waits disabled +trx_on_log_waits disabled +trx_on_log_wait_loops disabled +trx_rseg_history_len disabled +trx_undo_slots_used disabled +trx_undo_slots_cached disabled +trx_rseg_current_size disabled +purge_del_mark_records disabled +purge_upd_exist_or_extern_records disabled +purge_invoked disabled +purge_undo_log_pages disabled +purge_dml_delay_usec disabled +purge_stop_count disabled +purge_resume_count disabled +purge_truncate_history_count disabled +purge_truncate_history_usec disabled +undo_truncate_count disabled +undo_truncate_start_logging_count disabled +undo_truncate_done_logging_count disabled +undo_truncate_usec disabled +log_lsn_last_flush disabled +log_lsn_last_checkpoint disabled +log_lsn_current disabled +log_lsn_archived disabled +log_lsn_checkpoint_age disabled +log_lsn_buf_dirty_pages_added disabled +log_lsn_buf_pool_oldest_approx disabled +log_lsn_buf_pool_oldest_lwm disabled +log_max_modified_age_async disabled +log_max_modified_age_sync disabled +log_waits disabled +log_write_requests disabled +log_writes disabled +log_flush_total_time disabled +log_flush_max_time disabled +log_flush_avg_time disabled +log_flush_lsn_avg_rate disabled +log_full_block_writes disabled +log_partial_block_writes disabled +log_padded disabled +log_next_file disabled +log_checkpoints disabled +log_free_space disabled +log_concurrency_margin disabled +log_writer_no_waits disabled +log_writer_waits disabled +log_writer_wait_loops disabled +log_writer_on_file_space_waits disabled +log_writer_on_archiver_waits disabled +log_flusher_no_waits disabled +log_flusher_waits disabled +log_flusher_wait_loops disabled +log_write_notifier_no_waits disabled +log_write_notifier_waits disabled +log_write_notifier_wait_loops disabled +log_flush_notifier_no_waits disabled +log_flush_notifier_waits disabled +log_flush_notifier_wait_loops disabled +log_write_to_file_requests_interval disabled +log_on_write_no_waits disabled +log_on_write_waits disabled +log_on_write_wait_loops disabled +log_on_flush_no_waits disabled +log_on_flush_waits disabled +log_on_flush_wait_loops disabled +log_on_recent_written_wait_loops disabled +log_on_recent_closed_wait_loops disabled +log_on_buffer_space_no_waits disabled +log_on_buffer_space_waits disabled +log_on_buffer_space_wait_loops disabled +log_on_file_space_no_waits disabled +log_on_file_space_waits disabled +log_on_file_space_wait_loops disabled +compress_pages_compressed disabled +compress_pages_decompressed disabled +compression_pad_increments disabled +compression_pad_decrements disabled +index_page_splits disabled +index_page_merge_attempts disabled +index_page_merge_successful disabled +index_page_reorg_attempts disabled +index_page_reorg_successful disabled +index_page_discards disabled +adaptive_hash_searches disabled +adaptive_hash_searches_btree disabled +adaptive_hash_pages_added disabled +adaptive_hash_pages_removed disabled +adaptive_hash_rows_added disabled +adaptive_hash_rows_removed disabled +adaptive_hash_rows_deleted_no_hash_entry disabled +adaptive_hash_rows_updated disabled +file_num_open_files disabled +ibuf_merges_insert disabled +ibuf_merges_delete_mark disabled +ibuf_merges_delete disabled +ibuf_merges_discard_insert disabled +ibuf_merges_discard_delete_mark disabled +ibuf_merges_discard_delete disabled +ibuf_merges disabled +ibuf_size disabled +innodb_master_thread_sleeps disabled +innodb_activity_count disabled +innodb_master_active_loops disabled +innodb_master_idle_loops disabled +innodb_background_drop_table_usec disabled +innodb_ibuf_merge_usec disabled +innodb_mem_validate_usec disabled +innodb_master_purge_usec disabled +innodb_dict_lru_usec disabled +innodb_dict_lru_count disabled +innodb_dblwr_writes disabled +innodb_dblwr_pages_written disabled +innodb_page_size disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +dml_reads disabled +dml_inserts disabled +dml_deletes disabled +dml_updates disabled +dml_system_reads disabled +dml_system_inserts disabled +dml_system_deletes disabled +dml_system_updates disabled +sampled_pages_read disabled +sampled_pages_skipped disabled +ddl_background_drop_tables disabled +ddl_online_create_index disabled +ddl_pending_alter_table disabled +ddl_sort_file_alter_table disabled +ddl_log_file_alter_table disabled +icp_attempts disabled +icp_no_match disabled +icp_out_of_range disabled +icp_match disabled +module_cpu disabled +cpu_utime_abs disabled +cpu_stime_abs disabled +cpu_utime_pct disabled +cpu_stime_pct disabled +cpu_n disabled +module_page_track disabled +page_track_resets disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +page_track_checkpoint_partial_flush_request disabled +module_dblwr disabled +dblwr_async_requests disabled +dblwr_sync_requests disabled +dblwr_flush_requests disabled +dblwr_flush_wait_events disabled +set global innodb_monitor_enable = all; +create table monitor_test(col int) engine = innodb; +drop table monitor_test; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_enable = aaa; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of 'aaa' +set global innodb_monitor_disable = All; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_reset_all = all; +select name from information_schema.innodb_metrics where count!=0; +name +set global innodb_monitor_enable = "%lock%"; +select name from information_schema.innodb_metrics +where status != IF(name like "%lock%", 'enabled', 'disabled'); +name +set global innodb_monitor_disable = "%lock%"; +select name, status from information_schema.innodb_metrics +where name like "%lock%"; +name status +lock_deadlocks disabled +lock_deadlock_false_positives disabled +lock_deadlock_rounds disabled +lock_threads_waiting disabled +lock_timeouts disabled +lock_rec_lock_waits disabled +lock_table_lock_waits disabled +lock_rec_lock_requests disabled +lock_rec_release_attempts disabled +lock_rec_grant_attempts disabled +lock_rec_lock_created disabled +lock_rec_lock_removed disabled +lock_rec_locks disabled +lock_table_lock_created disabled +lock_table_lock_removed disabled +lock_table_locks disabled +lock_row_lock_current_waits disabled +lock_row_lock_time disabled +lock_row_lock_time_max disabled +lock_row_lock_waits disabled +lock_row_lock_time_avg disabled +lock_schedule_refreshes disabled +log_full_block_writes disabled +log_partial_block_writes disabled +innodb_rwlock_s_spin_waits disabled +innodb_rwlock_x_spin_waits disabled +innodb_rwlock_sx_spin_waits disabled +innodb_rwlock_s_spin_rounds disabled +innodb_rwlock_x_spin_rounds disabled +innodb_rwlock_sx_spin_rounds disabled +innodb_rwlock_s_os_waits disabled +innodb_rwlock_x_os_waits disabled +innodb_rwlock_sx_os_waits disabled +page_track_partial_block_writes disabled +page_track_full_block_writes disabled +set global innodb_monitor_enable = "%lock*"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '%lock*' +set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%%%%%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="%"; +select name from information_schema.innodb_metrics where status!='enabled'; +name +set global innodb_monitor_disable="%_%"; +select name from information_schema.innodb_metrics where status!='disabled'; +name +set global innodb_monitor_enable="log%%%%"; +select name from information_schema.innodb_metrics +where status != IF(name like "log%", 'enabled', 'disabled'); +name +set global innodb_monitor_enable="os_%a_fs_ncs"; +set global innodb_monitor_enable="os%pending%"; +select name, status from information_schema.innodb_metrics +where name like "os%"; +name status +os_data_reads disabled +os_data_writes disabled +os_data_fsyncs enabled +os_pending_reads enabled +os_pending_writes enabled +os_log_bytes_written disabled +os_log_fsyncs disabled +os_log_pending_fsyncs enabled +os_log_pending_writes enabled +set global innodb_monitor_enable=""; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '' +set global innodb_monitor_enable="_"; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '_' +SET global innodb_monitor_disable = module_metadata; +SET global innodb_monitor_reset_all = module_metadata; +set global innodb_monitor_enable = metadata_table_handles_opened; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 NULL NULL 0 enabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 3 NULL 3 enabled +set global innodb_monitor_disable = metadata_table_handles_opened; +set global innodb_monitor_reset = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +drop table monitor_test; +create table monitor_test(col int) engine = innodb; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 6 NULL 6 NULL NULL 0 disabled +set global innodb_monitor_reset_all = metadata_table_handles_opened; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = metadata_table_handles_opened; +drop table monitor_test; +create table monitor_test(col int) engine = innodb stats_persistent=0; +select * from monitor_test; +col +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_opened"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 3 NULL 3 3 NULL 3 enabled +set global innodb_monitor_enable = metadata_table_handles_closed; +create index idx on monitor_test(col); +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name = "metadata_table_handles_closed"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 4 NULL 4 enabled +metadata_table_handles_closed 3 NULL 3 3 NULL 3 enabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_metadata; +set global innodb_monitor_reset = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened 4 NULL 4 NULL NULL 0 disabled +metadata_table_handles_closed 3 NULL 3 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_reset_all = module_metadata; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "metadata%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +metadata_table_handles_opened NULL NULL 0 NULL NULL 0 disabled +metadata_table_handles_closed NULL NULL 0 NULL NULL 0 disabled +metadata_table_reference_count NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = module_trx; +begin; +insert into monitor_test values(9); +commit; +begin; +insert into monitor_test values(9); +rollback; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "trx_rollbacks" or name like "trx_active_transactions"; +name max_count min_count count max_count_reset min_count_reset count_reset status +trx_rollbacks 1 NULL 1 1 NULL 1 enabled +trx_active_transactions 1 0 0 1 0 0 enabled +set global innodb_monitor_disable = module_trx; +set global innodb_monitor_enable = module_dml; +insert into monitor_test values(9); +update monitor_test set col = 10 where col = 9; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 4 NULL 4 4 NULL 4 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 0 NULL 0 0 NULL 0 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 6 NULL 6 enabled +dml_inserts 1 NULL 1 1 NULL 1 enabled +dml_deletes 2 NULL 2 2 NULL 2 enabled +dml_updates 2 NULL 2 2 NULL 2 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 6 NULL 6 0 NULL 0 enabled +dml_inserts 1 NULL 1 0 NULL 0 enabled +dml_deletes 2 NULL 2 0 NULL 0 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 enabled +dml_inserts 3 NULL 3 2 NULL 2 enabled +dml_deletes 4 NULL 4 2 NULL 2 enabled +dml_updates 2 NULL 2 0 NULL 0 enabled +dml_system_reads 0 NULL 0 0 NULL 0 enabled +dml_system_inserts 0 NULL 0 0 NULL 0 enabled +dml_system_deletes 0 NULL 0 0 NULL 0 enabled +dml_system_updates 0 NULL 0 0 NULL 0 enabled +set global innodb_monitor_disable = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads 8 NULL 8 2 NULL 2 disabled +dml_inserts 3 NULL 3 2 NULL 2 disabled +dml_deletes 4 NULL 4 2 NULL 2 disabled +dml_updates 2 NULL 2 0 NULL 0 disabled +dml_system_reads 0 NULL 0 0 NULL 0 disabled +dml_system_inserts 0 NULL 0 0 NULL 0 disabled +dml_system_deletes 0 NULL 0 0 NULL 0 disabled +dml_system_updates 0 NULL 0 0 NULL 0 disabled +set global innodb_monitor_reset_all = module_dml; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts NULL NULL 0 NULL NULL 0 disabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_enable = dml_inserts; +insert into monitor_test values(9); +insert into monitor_test values(1); +delete from monitor_test; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "dml%"; +name max_count min_count count max_count_reset min_count_reset count_reset status +dml_reads NULL NULL 0 NULL NULL 0 disabled +dml_inserts 2 NULL 2 2 NULL 2 enabled +dml_deletes NULL NULL 0 NULL NULL 0 disabled +dml_updates NULL NULL 0 NULL NULL 0 disabled +dml_system_reads NULL NULL 0 NULL NULL 0 disabled +dml_system_inserts NULL NULL 0 NULL NULL 0 disabled +dml_system_deletes NULL NULL 0 NULL NULL 0 disabled +dml_system_updates NULL NULL 0 NULL NULL 0 disabled +set global innodb_monitor_disable = module_dml; +drop table monitor_test; +set global innodb_monitor_enable = file_num_open_files; +select name, max_count, min_count, count, +max_count_reset, min_count_reset, count_reset, status +from information_schema.innodb_metrics +where name like "file_num_open_files"; +name max_count min_count count max_count_reset min_count_reset count_reset status +file_num_open_files # # # # # # enabled +set global innodb_monitor_disable = file_num_open_files; +set global innodb_monitor_enable = "icp%"; +create table monitor_test(a char(3), b int, c char(2), +primary key (a(1), c(1)), key(b)) engine = innodb; +insert into monitor_test values("13", 2, "aa"); +select a from monitor_test where b < 1 for update; +a +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 1 +icp_no_match 0 +icp_out_of_range 1 +icp_match 0 +select a from monitor_test where b < 3 for update; +a +13 +select name, count from information_schema.innodb_metrics +where name like "icp%"; +name count +icp_attempts 2 +icp_no_match 0 +icp_out_of_range 1 +icp_match 1 +drop table monitor_test; +set global innodb_monitor_disable = All; +set global innodb_monitor_reset_all = all; +set global innodb_monitor_reset_all=0xe7; +ERROR 42000: Variable 'innodb_monitor_reset_all' can't be set to the value of '\xE7' +set global innodb_monitor_enable =0xee; +ERROR 42000: Variable 'innodb_monitor_enable' can't be set to the value of '\xEE' +set global innodb_monitor_reset =0xe9; +ERROR 42000: Variable 'innodb_monitor_reset' can't be set to the value of '\xE9' +set global innodb_monitor_disable =0xed; +ERROR 42000: Variable 'innodb_monitor_disable' can't be set to the value of '\xED' diff --git a/mysql-test/suite/sys_vars/r/max_seeks_for_key_func.result-pq b/mysql-test/suite/sys_vars/r/max_seeks_for_key_func.result-pq new file mode 100644 index 000000000..2d93c5080 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/max_seeks_for_key_func.result-pq @@ -0,0 +1,95 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 +(a INT AUTO_INCREMENT PRIMARY KEY, +b CHAR(20) +); +SET @start_value= @@global.max_seeks_for_key; +'#--------------------FN_DYNVARS_084_01-------------------------#' +SELECT @@global.max_seeks_for_key = 10; +@@global.max_seeks_for_key = 10 +0 +SELECT @@session.max_seeks_for_key = 10; +@@session.max_seeks_for_key = 10 +0 +SET @@global.max_seeks_for_key = 20; +SELECT @@global.max_seeks_for_key; +@@global.max_seeks_for_key +20 +INSERT INTO t1(b) VALUES("AREc"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +SET @@session.max_seeks_for_key = 2; +SELECT @@session.max_seeks_for_key; +@@session.max_seeks_for_key +2 +INSERT INTO t1(b) VALUES("BREc"); +INSERT INTO t1(b) VALUES("CRec"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +'#--------------------FN_DYNVARS_084_02-------------------------#' +SELECT @@global.max_seeks_for_key = 10; +@@global.max_seeks_for_key = 10 +0 +SELECT @@session.max_seeks_for_key = 10; +@@session.max_seeks_for_key = 10 +0 +SET @@global.max_seeks_for_key = 20; +SELECT @@global.max_seeks_for_key; +@@global.max_seeks_for_key +20 +INSERT INTO t1(b) VALUES("AREc"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +SET @@session.max_seeks_for_key = 2; +SELECT @@session.max_seeks_for_key; +@@session.max_seeks_for_key +2 +INSERT INTO t1(b) VALUES("BREc"); +INSERT INTO t1(b) VALUES("CRec"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +INSERT INTO t1 VALUES(null,"test"); +INSERT INTO t1 VALUES (null,"a"),(null,"a"),(null,"a"), +(null,"a"),(null,"a"),(null,"a"),(null,"a"), +(null,"a"),(null,"a"),(null,"a"); +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SET MAX_SEEKS_FOR_KEY=1; +EXPLAIN SELECT STRAIGHT_JOIN * FROM t1,t1 AS t2 WHERE t1.b = t2.b; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL ALL NULL NULL NULL NULL # # Parallel execute (1 workers) +2 SIMPLE t1 NULL ALL NULL NULL NULL NULL # # NULL +2 SIMPLE t2 NULL ALL NULL NULL NULL NULL # # Using where; Using join buffer (hash join) +Warnings: +Note 1003 /* select#1 */ select straight_join `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`b` = `test`.`t1`.`b`) +SET MAX_SEEKS_FOR_KEY=DEFAULT; +DROP TABLE t1; +SET @@global.max_seeks_for_key= @start_value; diff --git a/mysql-test/suite/sys_vars/t/debug_pq_worker_stall_basic.test b/mysql-test/suite/sys_vars/t/debug_pq_worker_stall_basic.test new file mode 100644 index 000000000..078c63703 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/debug_pq_worker_stall_basic.test @@ -0,0 +1,16 @@ +--source include/pq_test.inc +--source include/have_debug.inc + +--echo # +--echo # debug_pq_worker_stall_basic.test +--echo # + +SELECT @@global.debug_pq_worker_stall; +show variables like '%debug_pq_worker_stall%'; + +--error ER_GLOBAL_VARIABLE +set debug_pq_worker_stall=1; + +set global debug_pq_worker_stall=1; +SELECT @@global.debug_pq_worker_stall; +set global debug_pq_worker_stall=0; diff --git a/mysql-test/suite/sysschema/r/pr_statement_performance_analyzer.result-pq b/mysql-test/suite/sysschema/r/pr_statement_performance_analyzer.result-pq new file mode 100644 index 000000000..0e315fc63 --- /dev/null +++ b/mysql-test/suite/sysschema/r/pr_statement_performance_analyzer.result-pq @@ -0,0 +1,199 @@ +use test; +DROP TABLE IF EXISTS t1; +DROP TEMPORARY TABLE IF EXISTS tmp_digests_ini; +DROP VIEW IF EXISTS view_digests; +CREATE TABLE t1 (id INT PRIMARY KEY, val int); +use test; +UPDATE performance_schema.threads SET INSTRUMENTED = IF(THREAD_ID = CON1_THREAD_ID, 'YES', 'NO'); +CALL sys.ps_setup_enable_consumer('events_statements_history_long'); +CALL sys.ps_truncate_all_tables(FALSE); +INSERT INTO t1 VALUES (1, 0); +UPDATE t1 SET val = 1 WHERE id = 1; +SELECT t1a.* FROM t1 AS t1a LEFT OUTER JOIN (SELECT * FROM t1 AS t1b1 INNER JOIN t1 AS t1b2 USING (id, val)) AS t1b ON t1b.id > t1a.id ORDER BY t1a.val, t1a.id; +id val +1 1 +CALL sys.statement_performance_analyzer('create_tmp', 'test.tmp_digests_ini', NULL); +CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); +CALL sys.statement_performance_analyzer('save', 'test.tmp_digests_ini', NULL); +DO SLEEP(1.2); +INSERT INTO t1 VALUES (2, 0); +UPDATE t1 SET val = 1 WHERE id = 2; +SELECT t1a.* FROM t1 AS t1a LEFT OUTER JOIN (SELECT * FROM t1 AS t1b1 INNER JOIN t1 AS t1b2 USING (id, val)) AS t1b ON t1b.id > t1a.id ORDER BY t1a.val, t1a.id; +id val +1 1 +2 1 +CALL sys.statement_performance_analyzer('snapshot', NULL, NULL); +SELECT DIGEST, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest; +DIGEST COUNT_STAR +DIGEST_INSERT 2 +DIGEST_SELECT 2 +DIGEST_UPDATE 2 +CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile'); +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_runtimes_in_95th_percentile'); +CALL sys.statement_performance_analyzer('overall', NULL, 'analysis'); +Next Output +QUERY_INSERT test 2 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 0 0 2 1 0 0 0 0 DIGEST_INSERT FIRST_SEEN LAST_SEEN +QUERY_SELECT test * 2 0 0 LATENCY LATENCY LATENCY LATENCY 3 2 15 8 0 0 0 0 3 0 DIGEST_SELECT FIRST_SEEN LAST_SEEN +QUERY_UPDATE test 2 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 2 1 2 1 0 0 0 0 DIGEST_UPDATE FIRST_SEEN LAST_SEEN +Top 100 Queries Ordered by Total Latency +query db full_scan exec_count err_count warn_count total_latency max_latency avg_latency lock_latency rows_sent rows_sent_avg rows_examined rows_examined_avg rows_affected rows_affected_avg tmp_tables tmp_disk_tables rows_sorted sort_merge_passes digest first_seen last_seen +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'analysis'); +Next Output +QUERY_INSERT test 1 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 0 0 1 1 0 0 0 0 DIGEST_INSERT FIRST_SEEN LAST_SEEN +QUERY_SELECT test * 1 0 0 LATENCY LATENCY LATENCY LATENCY 2 2 11 11 0 0 0 0 2 0 DIGEST_SELECT FIRST_SEEN LAST_SEEN +QUERY_UPDATE test 1 0 0 LATENCY LATENCY LATENCY LATENCY 0 0 1 1 1 1 0 0 0 0 DIGEST_UPDATE FIRST_SEEN LAST_SEEN +Top 100 Queries Ordered by Total Latency +query db full_scan exec_count err_count warn_count total_latency max_latency avg_latency lock_latency rows_sent rows_sent_avg rows_examined rows_examined_avg rows_affected rows_affected_avg tmp_tables tmp_disk_tables rows_sorted sort_merge_passes digest first_seen last_seen +CALL sys.statement_performance_analyzer('overall', NULL, 'with_errors_or_warnings'); +Next Output +Top 100 Queries with Errors +query db exec_count errors error_pct warnings warning_pct first_seen last_seen digest +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_errors_or_warnings'); +Next Output +Top 100 Queries with Errors +query db exec_count errors error_pct warnings warning_pct first_seen last_seen digest +CALL sys.statement_performance_analyzer('overall', NULL, 'with_full_table_scans'); +Next Output +Top 100 Queries with Full Table Scan +query db exec_count total_latency no_index_used_count no_good_index_used_count no_index_used_pct rows_sent rows_examined rows_sent_avg rows_examined_avg first_seen last_seen digest +QUERY_SELECT test 2 LATENCY 2 0 100 3 15 2 8 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_full_table_scans'); +Next Output +Top 100 Queries with Full Table Scan +query db exec_count total_latency no_index_used_count no_good_index_used_count no_index_used_pct rows_sent rows_examined rows_sent_avg rows_examined_avg first_seen last_seen digest +QUERY_SELECT test 1 LATENCY 1 0 100 2 11 2 11 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('overall', NULL, 'with_sorting'); +Next Output +Top 100 Queries with Sorting +query db exec_count total_latency sort_merge_passes avg_sort_merges sorts_using_scans sort_using_range rows_sorted avg_rows_sorted first_seen last_seen digest +QUERY_SELECT test 2 LATENCY 0 0 2 0 3 2 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_sorting'); +Next Output +Top 100 Queries with Sorting +query db exec_count total_latency sort_merge_passes avg_sort_merges sorts_using_scans sort_using_range rows_sorted avg_rows_sorted first_seen last_seen digest +QUERY_SELECT test 1 LATENCY 0 0 1 0 2 2 FIRST_SEEN LAST_SEEN DIGEST_SELECT +CALL sys.statement_performance_analyzer('overall', NULL, 'with_temp_tables'); +Next Output +Top 100 Queries with Internal Temporary Tables +query db exec_count total_latency memory_tmp_tables disk_tmp_tables avg_tmp_tables_per_query tmp_tables_to_disk_pct first_seen last_seen digest +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'with_temp_tables'); +Next Output +Top 100 Queries with Internal Temporary Tables +query db exec_count total_latency memory_tmp_tables disk_tmp_tables avg_tmp_tables_per_query tmp_tables_to_disk_pct first_seen last_seen digest +CREATE VIEW test.view_digests AS +SELECT sys.format_statement(DIGEST_TEXT) AS query, +SCHEMA_NAME AS db, +COUNT_STAR AS exec_count, +format_pico_time(SUM_TIMER_WAIT) AS total_latency, +format_pico_time(AVG_TIMER_WAIT) AS avg_latency, +ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg, +ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg, +ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg, +DIGEST AS digest +FROM performance_schema.events_statements_summary_by_digest +ORDER BY SUBSTRING(query, 1, 6); +SET @sys.statement_performance_analyzer.view = 'test.view_digests'; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 100 Queries Using Custom View +query db exec_count total_latency avg_latency rows_sent_avg rows_examined_avg rows_affected_avg digest +QUERY_INSERT test 2 LATENCY LATENCY 0 0 1 DIGEST_INSERT +QUERY_SELECT test 2 LATENCY LATENCY 2 8 0 DIGEST_SELECT +QUERY_UPDATE test 2 LATENCY LATENCY 0 1 1 DIGEST_UPDATE +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'custom'); +Next Output +Top 100 Queries Using Custom View +query db exec_count total_latency avg_latency rows_sent_avg rows_examined_avg rows_affected_avg digest +QUERY_INSERT test 1 LATENCY LATENCY 0 0 1 DIGEST_INSERT +QUERY_SELECT test 1 LATENCY LATENCY 2 11 0 DIGEST_SELECT +QUERY_UPDATE test 1 LATENCY LATENCY 0 1 1 DIGEST_UPDATE +SET @sys.statement_performance_analyzer.limit = 2; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 2 Queries Using Custom View +query db exec_count total_latency avg_latency rows_sent_avg rows_examined_avg rows_affected_avg digest +QUERY_INSERT test 2 LATENCY LATENCY 0 0 1 DIGEST_INSERT +QUERY_SELECT test 2 LATENCY LATENCY 2 8 0 DIGEST_SELECT +SET SESSION sql_mode = ''; +CALL sys.statement_performance_analyzer('do magic', NULL, NULL); +ERROR 45000: Unknown action. Supported actions are: cleanup, create_table, create_tmp, delta, overall, save, snapshot +SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; +CALL sys.statement_performance_analyzer('do magic', NULL, NULL); +ERROR 01000: Data truncated for column 'in_action' at row 1 +CALL sys.statement_performance_analyzer('create_tmp', 'sys.tmp_digests', NULL); +ERROR 45000: Invalid value for in_table: `sys`.`tmp_digests` is reserved table name. +CALL sys.statement_performance_analyzer('create_tmp', 'sys.tmp_digests_delta', NULL); +ERROR 45000: Invalid value for in_table: `sys`.`tmp_digests_delta` is reserved table name. +CALL sys.statement_performance_analyzer('create_tmp', 'tmp_digests', NULL); +ERROR 45000: Invalid value for in_table: `sys`.`tmp_digests` is reserved table name. +CALL sys.statement_performance_analyzer('create_tmp', 'test.tmp_digests', NULL); +CREATE TABLE test.tmp_unsupported LIKE test.tmp_digests_ini; +CALL sys.statement_performance_analyzer('create_tmp', 'test.tmp_digests_ini', NULL); +ERROR 45000: Cannot create the table `test`.`tmp_digests_ini` as it already exists. +CALL sys.statement_performance_analyzer('create_table', 'test.tmp_digests_ini', NULL); +ERROR 45000: Cannot create the table `test`.`tmp_digests_ini` as it already exists as a temporary table. +CALL sys.statement_performance_analyzer('create_table', 'test.tmp_unsupported', NULL); +ERROR 45000: Cannot create the table `test`.`tmp_unsupported` as it already exists. +ALTER TABLE test.tmp_unsupported ADD COLUMN myvar int DEFAULT 0; +CALL sys.statement_performance_analyzer('save', 'test.tmp_unsupported', NULL); +ERROR 45000: The table `test`.`tmp_unsupported` has the wrong definition. +CALL sys.statement_performance_analyzer('snapshot', 'test.new_table', NULL); +ERROR 45000: The snapshot action requires in_table to be NULL, NOW() or specify an existing table. The table ...`.`new_table` does not exist. +CALL sys.statement_performance_analyzer('overall', 'test.new_table', 'analysis'); +ERROR 45000: The overall action requires in_table to be NULL, NOW() or specify an existing table. The table ...`.`new_table` does not exist. +CALL sys.statement_performance_analyzer('delta', 'test.new_table', 'analysis'); +ERROR 45000: The delta action requires in_table to be an existing table. The table `test`.`new_table` does not exist. +CALL sys.statement_performance_analyzer('save', 'test.new_table', NULL); +ERROR 45000: The save action requires in_table to be an existing table. The table `test`.`new_table` does not exist. +SET @sys.statement_performance_analyzer.view = NULL; +DELETE FROM sys.sys_config WHERE variable = 'statement_performance_analyzer.view'; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 2 Queries Using Custom View +ERROR 45000: The @sys.statement_performance_analyzer.view user variable must be set with the view or query to use. +SET @sys.statement_performance_analyzer.view = 'test.tmp_unsupported'; +CALL sys.statement_performance_analyzer('overall', NULL, 'custom'); +Next Output +Top 2 Queries Using Custom View +ERROR 45000: The @sys.statement_performance_analyzer.view user variable is set but specified neither an existing view nor a query. +CALL sys.table_exists('sys', 'tmp_digests', @exists); +SELECT @exists; +@exists +TEMPORARY +CALL sys.table_exists('sys', 'tmp_digests_delta', @exists); +SELECT @exists; +@exists +TEMPORARY +CALL sys.statement_performance_analyzer('cleanup', NULL, NULL); +DROP TEMPORARY TABLE sys.tmp_digests; +ERROR 42S02: Unknown table 'sys.tmp_digests' +DROP TEMPORARY TABLE sys.tmp_digests_delta; +ERROR 42S02: Unknown table 'sys.tmp_digests_delta' +CALL sys.statement_performance_analyzer('delta', 'test.tmp_digests_ini', 'analysis'); +ERROR 45000: An existing snapshot generated with the statement_performance_analyzer() must exist. +DROP TEMPORARY TABLE sys.tmp_digests_delta; +ERROR 42S02: Unknown table 'sys.tmp_digests_delta' +SET @identifier := REPEAT('a', 65); +CALL sys.statement_performance_analyzer('snapshot', CONCAT(@identifier, '.', @identifier), NULL); +ERROR 22001: Data too long for column 'in_table' at row 1 +DROP TEMPORARY TABLE test.tmp_digests_ini; +DROP TEMPORARY TABLE test.tmp_digests; +DROP TABLE test.tmp_unsupported; +DROP TABLE test.t1; +DROP VIEW view_digests; +SET @identifier := NULL; +SET SESSION sql_mode = @@global.sql_mode; +SET @sys.statement_performance_analyzer.limit = NULL; +SET @sys.statement_performance_analyzer.view = NULL; +UPDATE performance_schema.setup_consumers SET enabled = 'YES'; +UPDATE performance_schema.threads SET instrumented = 'YES'; +SET @sys.ignore_sys_config_triggers := true; +DELETE FROM sys.sys_config; +INSERT IGNORE INTO sys.sys_config (variable, value) VALUES +('statement_truncate_len', 64), +('statement_performance_analyzer.limit', 100), +('statement_performance_analyzer.view', NULL), +('diagnostics.allow_i_s_tables', 'OFF'), +('diagnostics.include_raw', 'OFF'), +('ps_thread_trx_info.max_length', 65535); +SET @sys.ignore_sys_config_triggers := NULL; diff --git a/mysql-test/suite/test_service_sql_api/r/test_sql_complex.result-pq b/mysql-test/suite/test_service_sql_api/r/test_sql_complex.result-pq new file mode 100644 index 000000000..d4b2b12ec --- /dev/null +++ b/mysql-test/suite/test_service_sql_api/r/test_sql_complex.result-pq @@ -0,0 +1,6424 @@ +------ Run plugin ------------------------------------------------ +INSTALL PLUGIN test_sql_complex SONAME 'TEST_SQL_COMPLEX'; +------ Stop plugin ----------------------------------------------- +UNINSTALL PLUGIN test_sql_complex; +------ plugin log ------------------------------------------------ +======================================================================== +Test in a server thread +[srv_session_open] +------------------------------------------------------------------ +EXECUTING:[35][SELECT 'first complex command' as a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][CREATE DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[8][USE test] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[343][CREATE TABLE test_inserts( a INT UNSIGNED, b VARCHAR(100), c DOUBLE, d INT, e FLOAT,f DATETIME, g DATE, h TIME, i TINYINT, k TINYINT UNSIGNED,l SMALLINT, m SMALLINT UNSIGNED, n MEDIUMINT, o MEDIUMINT UNSIGNED,p INTEGER, q INTEGER UNSIGNED, r BIGINT, s BIGINT UNSIGNED,t YEAR, u DECIMAL(5,2) UNSIGNED, v DECIMAL(5,2), PRIMARY KEY(a), INDEX(d));] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[244][INSERT INTO test_inserts VALUES (1, 'one', 1.23, -1, 11.2323, '2014-07-06 07:06:05', '1980-02-19', '-830:12:23', 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615,1901, 999.99, -999.99)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[236][INSERT INTO test_inserts VALUES (2, 'two', 2.34, -2, 22.3434, '2015-07-06 21:22:23', '2014-06-05', '356:22:33', -128, 0, -32768, 32768, -8388608, 8388607, -2147483648, 0, -9223372036854775808, 18446744073709551615,2039, 123.45, -543.21)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[179][INSERT INTO test_inserts VALUES (3, 'three',3.45,-3, 33.4545, '2016-09-12 11:12:13', '2013-05-04', '821:33:44', -1, 128, -1, 65534, -1, 16777214, 1, 2, 3, 4,2155, 222.22, -567.89)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][SELECT * FROM test1.test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[34][DELETE FROM test_inserts WHERE a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][TRUNCATE test_inserts] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][PREPARE ps1 FROM 'select 1'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1 + [meta][field] org col name: + [meta][field] length: 1 + [meta][field] charsetnr: 8 + [meta][field] flags: 129 (NOT_NULL BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1][ 1][1] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[24][CREATE TABLE tbl (a INT)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[55][PREPARE ps1 FROM 'INSERT INTO tbl VALUES (1), (2), (3)'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Records: 3 Duplicates: 0 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[46][SELECT IF(SUM(a)=6, 'OK:)', 'FAIL:(') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a)=6, 'OK:)', 'FAIL:(') + [meta][field] org col name: + [meta][field] length: 18 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a)=6, 'OK:)', 'FAIL:(')][ 4][OK:)] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[7][garbage] +[CS_TEXT_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][SELECT b FROM tbl] +[CS_TEXT_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][ALTER USER bogus@remotehost PASSWORD EXPIRE] +[CS_TEXT_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[26][CREATE TABLE tbld (d TIME)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[36][INSERT INTO tbld VALUES ('43141231')] +[CS_TEXT_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[10][SELECT 1/0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1/0 + [meta][field] org col name: + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 4 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1/0][ 6][[NULL]] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=5] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 15, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 15, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 15, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][START TRANSACTION READ ONLY] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 8195 + [end] server status: IN_TRANS AUTOCOMMIT IN_TRANS_READONLY + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] +[1792][25006][Cannot execute statement in a READ ONLY transaction.] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[16][SET autocommit=0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 33 + [meta] server status: IN_TRANS QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[35][set @a=((2) in (select a from tbl))] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][set @b=42] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @b] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[20][SELECT @non_existing] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[0][] +[CS_TEXT_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[14][DROP TABLE tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[15][DROP TABLE tbld] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[19][DROP DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 256 + [end] server status: DB_DROPPED + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +[srv_session_close] +Follows threaded run +======================================================================== +init thread +[srv_session_open] +------------------------------------------------------------------ +EXECUTING:[35][SELECT 'first complex command' as a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: a + [meta][field] org col name: + [meta][field] length: 63 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.a][ 21][first complex command] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][CREATE DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[8][USE test] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[343][CREATE TABLE test_inserts( a INT UNSIGNED, b VARCHAR(100), c DOUBLE, d INT, e FLOAT,f DATETIME, g DATE, h TIME, i TINYINT, k TINYINT UNSIGNED,l SMALLINT, m SMALLINT UNSIGNED, n MEDIUMINT, o MEDIUMINT UNSIGNED,p INTEGER, q INTEGER UNSIGNED, r BIGINT, s BIGINT UNSIGNED,t YEAR, u DECIMAL(5,2) UNSIGNED, v DECIMAL(5,2), PRIMARY KEY(a), INDEX(d));] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[244][INSERT INTO test_inserts VALUES (1, 'one', 1.23, -1, 11.2323, '2014-07-06 07:06:05', '1980-02-19', '-830:12:23', 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615,1901, 999.99, -999.99)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[236][INSERT INTO test_inserts VALUES (2, 'two', 2.34, -2, 22.3434, '2015-07-06 21:22:23', '2014-06-05', '356:22:33', -128, 0, -32768, 32768, -8388608, 8388607, -2147483648, 0, -9223372036854775808, 18446744073709551615,2039, 123.45, -543.21)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[179][INSERT INTO test_inserts VALUES (3, 'three',3.45,-3, 33.4545, '2016-09-12 11:12:13', '2013-05-04', '821:33:44', -1, 128, -1, 65534, -1, 16777214, 1, 2, 3, 4,2155, 222.22, -567.89)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][SELECT * FROM test1.test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 3 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][2] + [data][test_inserts.b][ 3][two] + [data][test_inserts.c][ 4][2.34] + [data][test_inserts.d][ 2][-2] + [data][test_inserts.e][ 7][22.3434] + [data][test_inserts.f][ 19][2015-07-06 21:22:23] + [data][test_inserts.g][ 10][2014-06-05] + [data][test_inserts.h][ 9][356:22:33] + [data][test_inserts.i][ 4][-128] + [data][test_inserts.k][ 1][0] + [data][test_inserts.l][ 6][-32768] + [data][test_inserts.m][ 5][32768] + [data][test_inserts.n][ 8][-8388608] + [data][test_inserts.o][ 7][8388607] + [data][test_inserts.p][ 11][-2147483648] + [data][test_inserts.q][ 1][0] + [data][test_inserts.r][ 20][-9223372036854775808] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][2039] + [data][test_inserts.u][ 6][123.45] + [data][test_inserts.v][ 7][-543.21] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[34][DELETE FROM test_inserts WHERE a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 2 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][test_inserts.a][ 1][1] + [data][test_inserts.b][ 3][one] + [data][test_inserts.c][ 4][1.23] + [data][test_inserts.d][ 2][-1] + [data][test_inserts.e][ 7][11.2323] + [data][test_inserts.f][ 19][2014-07-06 07:06:05] + [data][test_inserts.g][ 10][1980-02-19] + [data][test_inserts.h][ 10][-830:12:23] + [data][test_inserts.i][ 3][127] + [data][test_inserts.k][ 3][255] + [data][test_inserts.l][ 5][32767] + [data][test_inserts.m][ 5][65535] + [data][test_inserts.n][ 7][8388607] + [data][test_inserts.o][ 8][16777215] + [data][test_inserts.p][ 10][2147483647] + [data][test_inserts.q][ 10][4294967295] + [data][test_inserts.r][ 19][9223372036854775807] + [data][test_inserts.s][ 20][18446744073709551615] + [data][test_inserts.t][ 4][1901] + [data][test_inserts.u][ 6][999.99] + [data][test_inserts.v][ 7][-999.99] + + [data][test_inserts.a][ 1][3] + [data][test_inserts.b][ 5][three] + [data][test_inserts.c][ 4][3.45] + [data][test_inserts.d][ 2][-3] + [data][test_inserts.e][ 7][33.4545] + [data][test_inserts.f][ 19][2016-09-12 11:12:13] + [data][test_inserts.g][ 10][2013-05-04] + [data][test_inserts.h][ 9][821:33:44] + [data][test_inserts.i][ 2][-1] + [data][test_inserts.k][ 3][128] + [data][test_inserts.l][ 2][-1] + [data][test_inserts.m][ 5][65534] + [data][test_inserts.n][ 2][-1] + [data][test_inserts.o][ 8][16777214] + [data][test_inserts.p][ 1][1] + [data][test_inserts.q][ 1][2] + [data][test_inserts.r][ 1][3] + [data][test_inserts.s][ 1][4] + [data][test_inserts.t][ 4][2155] + [data][test_inserts.u][ 6][222.22] + [data][test_inserts.v][ 7][-567.89] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[21][TRUNCATE test_inserts] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[37][SELECT * FROM test_inserts ORDER BY a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 21 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: a + [meta][field] org col name: a + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 4129 (NOT_NULL UNSIGNED NO_DEFAULT_VALUE ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: b + [meta][field] org col name: b + [meta][field] length: 400 + [meta][field] charsetnr: 255 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: VARCHAR (15) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: c + [meta][field] org col name: c + [meta][field] length: 22 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: DOUBLE (5) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: d + [meta][field] org col name: d + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: e + [meta][field] org col name: e + [meta][field] length: 12 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 31 + [meta][field] type: FLOAT (4) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: f + [meta][field] org col name: f + [meta][field] length: 19 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATETIME (12) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: g + [meta][field] org col name: g + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: DATE (10) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: h + [meta][field] org col name: h + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: TIME (11) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: i + [meta][field] org col name: i + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: k + [meta][field] org col name: k + [meta][field] length: 3 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: TINY (1) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: l + [meta][field] org col name: l + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: m + [meta][field] org col name: m + [meta][field] length: 5 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: SHORT (2) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: n + [meta][field] org col name: n + [meta][field] length: 9 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: o + [meta][field] org col name: o + [meta][field] length: 8 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: INT24 (9) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: p + [meta][field] org col name: p + [meta][field] length: 11 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: q + [meta][field] org col name: q + [meta][field] length: 10 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONG (3) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: r + [meta][field] org col name: r + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: s + [meta][field] org col name: s + [meta][field] length: 20 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: t + [meta][field] org col name: t + [meta][field] length: 4 + [meta][field] charsetnr: 8 + [meta][field] flags: 96 (UNSIGNED ZEROFILL ) + [meta][field] decimals: 0 + [meta][field] type: YEAR (13) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: u + [meta][field] org col name: u + [meta][field] length: 6 + [meta][field] charsetnr: 8 + [meta][field] flags: 32 (UNSIGNED ) + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + [meta][field] db name: test1 + [meta][field] table name: test_inserts + [meta][field] org table name: test_inserts + [meta][field] col name: v + [meta][field] org col name: v + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 0 + [meta][field] decimals: 2 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][PREPARE ps1 FROM 'select 1'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1 + [meta][field] org col name: + [meta][field] length: 1 + [meta][field] charsetnr: 8 + [meta][field] flags: 129 (NOT_NULL BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1][ 1][1] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[24][CREATE TABLE tbl (a INT)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[55][PREPARE ps1 FROM 'INSERT INTO tbl VALUES (1), (2), (3)'] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: Statement prepared +------------------------------------------------------------------ +EXECUTING:[11][EXECUTE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Records: 3 Duplicates: 0 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[46][SELECT IF(SUM(a)=6, 'OK:)', 'FAIL:(') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a)=6, 'OK:)', 'FAIL:(') + [meta][field] org col name: + [meta][field] length: 18 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a)=6, 'OK:)', 'FAIL:(')][ 4][OK:)] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[22][DEALLOCATE PREPARE ps1] +[CS_TEXT_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1243][HY000][Unknown prepared statement handler (ps1) given to DEALLOCATE PREPARE] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[7][garbage] +[CS_TEXT_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1064][42000][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][SELECT b FROM tbl] +[CS_TEXT_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1054][42S22][Unknown column 'b' in 'field list'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[43][ALTER USER bogus@remotehost PASSWORD EXPIRE] +[CS_TEXT_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1396][HY000][Operation ALTER USER failed for 'bogus'@'remotehost'] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[26][CREATE TABLE tbld (d TIME)] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[36][INSERT INTO tbld VALUES ('43141231')] +[CS_TEXT_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1292][22007][Incorrect time value: '43141231' for column 'd' at row 1] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[10][SELECT 1/0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 2 + [meta] server status: AUTOCOMMIT + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: 1/0 + [meta][field] org col name: + [meta][field] length: 7 + [meta][field] charsetnr: 8 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 4 + [meta][field] type: NEWDECIMAL (246) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.1/0][ 6][[NULL]] + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 1 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=5] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 15, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 15, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 15, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[17][START TRANSACTION] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 3 + [end] server status: IN_TRANS AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=4] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 35 + [end] server status: IN_TRANS AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(a) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(a) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(a) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[27][START TRANSACTION READ ONLY] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 8195 + [end] server status: IN_TRANS AUTOCOMMIT IN_TRANS_READONLY + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] +[1792][25006][Cannot execute statement in a READ ONLY transaction.] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[6][COMMIT] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 2 + [end] server status: AUTOCOMMIT + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 34 + [meta] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 34 + [end] server status: AUTOCOMMIT QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[16][SET autocommit=0] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[18][UPDATE tbl SET a=2] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 3 + [end] last insert id: 0 + [end] message: Rows matched: 3 Changed: 3 Warnings: 0 +------------------------------------------------------------------ +EXECUTING:[8][ROLLBACK] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[45][SELECT IF(SUM(4) = 12, 'OK', 'FAIL') FROM tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 33 + [meta] server status: IN_TRANS QUERY_NO_INDEX_USED + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: IF(SUM(4) = 12, 'OK', 'FAIL') + [meta][field] org col name: + [meta][field] length: 12 + [meta][field] charsetnr: 33 + [meta][field] flags: 1 (NOT_NULL ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.IF(SUM(4) = 12, 'OK', 'FAIL')][ 2][OK] + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[35][set @a=((2) in (select a from tbl))] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 33 + [end] server status: IN_TRANS QUERY_NO_INDEX_USED + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @a] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @a + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@a][ 1][0] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][set @b=42] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[9][SELECT @b] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @b + [meta][field] org col name: + [meta][field] length: 21 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 0 + [meta][field] type: LONGLONG (8) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@b][ 2][42] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[20][SELECT @non_existing] +[CS_TEXT_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] + [meta] rows: 1 + [meta] cols: 1 + [meta] server status: 1 + [meta] server status: IN_TRANS + [meta] warning count: 0 + + [meta][field] db name: + [meta][field] table name: + [meta][field] org table name: + [meta][field] col name: @non_existing + [meta][field] org col name: + [meta][field] length: 65535 + [meta][field] charsetnr: 33 + [meta][field] flags: 128 (BINARY ) + [meta][field] decimals: 31 + [meta][field] type: VARCHAR (15) + + + [meta][charset result] number: 33 + [meta][charset result] name: utf8mb3 + [meta][charset result] collation: utf8_general_ci + [meta][charset result] sort order: + + [data][.@non_existing][ 6][[NULL]] + + [end] server status: 1 + [end] server status: IN_TRANS + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[0][] +[CS_TEXT_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +[CS_BINARY_REPRESENTATION] +[1065][42000][Query was empty] [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[14][DROP TABLE tbl] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[15][DROP TABLE tbld] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 0 + [end] server status: + [end] warning count: 0 + [end] affected rows: 0 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +EXECUTING:[19][DROP DATABASE test1] +[CS_TEXT_REPRESENTATION] + [meta] rows: 0 + [meta] cols: 0 + [meta] server status: 0 + [meta] server status: + [meta] warning count: 0 + + [meta] no columns + + [meta] no charset + + [data] no rows + + [end] server status: 256 + [end] server status: DB_DROPPED + [end] warning count: 0 + [end] affected rows: 1 + [end] last insert id: 0 + [end] message: +------------------------------------------------------------------ +[srv_session_close] +deinit thread +------ cleanup --------------------------------------------------- diff --git a/mysql-test/suite/x/r/crud_resultset_metadata.result-pq b/mysql-test/suite/x/r/crud_resultset_metadata.result-pq new file mode 100644 index 000000000..490f7a264 --- /dev/null +++ b/mysql-test/suite/x/r/crud_resultset_metadata.result-pq @@ -0,0 +1,24 @@ +CREATE SCHEMA xtest; +CREATE TABLE xtest.xtable (x INT AUTO_INCREMENT PRIMARY KEY, y VARCHAR(1) NOT NULL, z INT UNSIGNED UNIQUE); +INSERT INTO xtest.xtable VALUES (1,2,3); +CREATE TABLE xtest.ytable (a INT ZEROFILL, b TIMESTAMP, c FLOAT UNSIGNED, INDEX(a)); +Warnings: +Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. +Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. +INSERT INTO xtest.ytable VALUES (1,'2015-02-15',3); +x y z +1 2 3 +x:SINT: NOT_NULL +y:BYTES: NOT_NULL +z:UINT: +command ok +a b c +1 2015-02-15 00:00:00 3 +a:UINT: ZEROFILL +b:DATETIME: TIMESTAMP +c:FLOAT: UNSIGNED +command ok +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/suite/x/r/find_crud_conditionalclauses_o.result-pq b/mysql-test/suite/x/r/find_crud_conditionalclauses_o.result-pq new file mode 100644 index 000000000..28e3754d6 --- /dev/null +++ b/mysql-test/suite/x/r/find_crud_conditionalclauses_o.result-pq @@ -0,0 +1,1469 @@ +============================================== +CRUD FIND CONDITIONAL CLAUSES SCENARIOS +============================================== + +================================================================================ +PREAMBLE +================================================================================ +create user crudfinduser@localhost identified by 'crudfinduser'; +grant all on *.* to crudfinduser@localhost; +================================================================================ +TEST START +================================================================================ +RUN DROP SCHEMA if EXISTS minisakila + +0 rows affected +RUN CREATE SCHEMA minisakila + +1 rows affected +RUN USE minisakila + +0 rows affected +RUN CREATE TABLE actor ( + actor_id int unsigned NOT NULL AUTO_INCREMENT, + first_name varchar(45) NOT NULL, + last_name varchar(45) NOT NULL, + is_active bit(1) NOT NULL, + PRIMARY KEY (actor_id) +) + +0 rows affected +RUN INSERT INTO actor VALUES +(NULL,'Victor','Otero',true), +(NULL,'Gonzalo','Crhystens',false), +(NULL,'Abraham','Vega',true), +(NULL,'Jennifer','Leon',false), +(NULL,'Jhonny','Test',true) + +5 rows affected +last insert id: 1 +Records: 5 Duplicates: 0 Warnings: 0 +Table based scenarios +Find all the rows including all the metadata +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE +} + +Mysqlx.Resultset.ColumnMetaData { + type: UINT + name: "actor_id" + original_name: "actor_id" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + length: 10 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "first_name" + original_name: "first_name" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + collation: 255 + length: 180 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "last_name" + original_name: "last_name" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + collation: 255 + length: 180 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BIT + name: "is_active" + original_name: "is_active" + table: "actor" + original_table: "actor" + schema: "minisakila" + catalog: "def" + length: 1 + flags: 16 +} + +Mysqlx.Resultset.Row { + field: "\001" + field: "Victor\000" + field: "Otero\000" + field: "\001" +} + +Mysqlx.Resultset.Row { + field: "\002" + field: "Gonzalo\000" + field: "Crhystens\000" + field: "\000" +} + +Mysqlx.Resultset.Row { + field: "\003" + field: "Abraham\000" + field: "Vega\000" + field: "\001" +} + +Mysqlx.Resultset.Row { + field: "\004" + field: "Jennifer\000" + field: "Leon\000" + field: "\000" +} + +Mysqlx.Resultset.Row { + field: "\005" + field: "Jhonny\000" + field: "Test\000" + field: "\001" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Sql.StmtExecuteOk { +} + +Find all the rows without the metadata +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +5 Jhonny Test 1 +command ok + Find with limit row count and offset +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + limit { + row_count: 1 + offset: 3 + } +} + +actor_id first_name last_name is_active +4 Jennifer Leon 0 +command ok +Find with limit row count +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + limit { + row_count: 4 + } +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +command ok +Find specific row with == Operator +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +command ok +Find specific row with != Operator +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +5 Jhonny Test 1 +command ok +Find specific row with like Operator +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%on%" + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +5 Jhonny Test 1 +command ok +Find specific row with && and like Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%on%" + } + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "last_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%ns%" + } + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +command ok +Find specific row with || and in Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "||" + param { + type: OPERATOR + operator { + name: "in" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%ham%" + } + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +1 Victor Otero 1 +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +command ok +Find specific row with not_in Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "||" + param { + type: OPERATOR + operator { + name: "not_in" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%ham%" + } + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +3 Abraham Vega 1 +4 Jennifer Leon 0 +5 Jhonny Test 1 +command ok +Find specific row with &&, <= and >= Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<=" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 4 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">=" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +3 Abraham Vega 1 +4 Jennifer Leon 0 +command ok +Find specific row with &&, < and > Operators +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 4 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 2 + } + } + } + } + } + } +} + +actor_id first_name last_name is_active +3 Abraham Vega 1 +command ok +Find specific row with like Operator using string +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_STRING + v_string { + value: "%on%" + } + } + } + } + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +5 Jhonny Test 1 +command ok +Find specific row with != Operator with order desc +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_STRING + v_string { + value: "Omar" + } + } + } + } + } + order { + expr { + type: IDENT + identifier { + name: "last_name" + } + } + direction: DESC + } +} + +actor_id first_name last_name is_active +3 Abraham Vega 1 +5 Jhonny Test 1 +1 Victor Otero 1 +4 Jennifer Leon 0 +2 Gonzalo Crhystens 0 +command ok +Find specific row with != Operator with order asc +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + name: "first_name" + } + } + param { + type: LITERAL + literal { + type: V_STRING + v_string { + value: "Omar" + } + } + } + } + } + order { + expr { + type: IDENT + identifier { + name: "last_name" + } + } + direction: ASC + } +} + +actor_id first_name last_name is_active +2 Gonzalo Crhystens 0 +4 Jennifer Leon 0 +1 Victor Otero 1 +5 Jhonny Test 1 +3 Abraham Vega 1 +command ok +Find using not available schema name +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "noavailableschema" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +Got expected error: Unknown database 'noavailableschema' (code 1049) +Find using not available table name +send Mysqlx.Crud.Find { + collection { + name: "notavailableatable" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "actor_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +Got expected error: Table 'minisakila.notavailableatable' doesn't exist (code 1146) +Find using not available column name +send Mysqlx.Crud.Find { + collection { + name: "actor" + schema: "minisakila" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "notavailablecolumn" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 1 + } + } + } + } +} + +Got expected error: Unknown column 'notavailablecolumn' in 'where clause' (code 1054) +Mysqlx.Ok { + msg: "bye!" +} +ok +RUN CREATE SCHEMA mysqlxcoll + +1 rows affected + +command ok +RUN USE mysqlxcoll + +0 rows affected +RUN INSERT INTO maincoll (doc) values + ('{"_id": "1", "name": "Victor", "last_name": "Otero","amount": 4.99}'), + ('{"_id": "2", "name": "Gonzalo", "last_name": "Crhystens","amount": 120.57}'), + ('{"_id": "3", "name": "Abraham", "last_name": "Vega","amount": 74.56}'), + ('{"_id": "4", "name": "Jennifer", "last_name": "Leon","amount": 387.14}'), + ('{"_id": "5", "name": "Jhonny", "last_name": "Test","amount": 125.45}') + +5 rows affected +Records: 5 Duplicates: 0 Warnings: 0 +Collection based scenarios +Find all the rows including all metadata +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "doc" + original_name: "doc" + table: "maincoll" + original_table: "maincoll" + schema: "mysqlxcoll" + catalog: "def" + collation: 63 + length: 4294967295 + content_type: 2 +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"1\", \"name\": \"Victor\", \"amount\": 4.99, \"last_name\": \"Otero\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"2\", \"name\": \"Gonzalo\", \"amount\": 120.57, \"last_name\": \"Crhystens\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"3\", \"name\": \"Abraham\", \"amount\": 74.56, \"last_name\": \"Vega\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"4\", \"name\": \"Jennifer\", \"amount\": 387.14, \"last_name\": \"Leon\"}\000" +} + +Mysqlx.Resultset.Row { + field: "{\"_id\": \"5\", \"name\": \"Jhonny\", \"amount\": 125.45, \"last_name\": \"Test\"}\000" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Sql.StmtExecuteOk { +} + +Find all the rows without all metadata +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +{"_id": "5", "name": "Jhonny", "amount": 125.45, "last_name": "Test"} +command ok + Find with limit row count and offset +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + limit { + row_count: 2 + offset: 3 + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +{"_id": "5", "name": "Jhonny", "amount": 125.45, "last_name": "Test"} +command ok + Find with limit row count +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + limit { + row_count: 3 + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +command ok +Find specific row with == Operator +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +command ok +Find specific row with != Operator +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "!=" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "Jhonny" + } + } + } + } + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with like Operator +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%er%" + } + } + } + } + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with && and like Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%er%" + } + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "last_name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "%on%" + } + } + } + } + } + } + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with || and in Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "||" + param { + type: OPERATOR + operator { + name: "in" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 3 + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 4 + } + } + } + } + param { + type: OPERATOR + operator { + name: "like" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "name" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "Gonzalo" + } + } + } + } + } + } + } +} + +doc +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +command ok +Find specific row with not_in Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "not_in" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "2" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "3" + } + } + } + } + } +} + +doc +{"_id": "4", "name": "Jennifer", "amount": 387.14, "last_name": "Leon"} +{"_id": "5", "name": "Jhonny", "amount": 125.45, "last_name": "Test"} +command ok +Find specific row with &&, <= and >= Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<=" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 120.57 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">=" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 4.99 + } + } + } + } + } + } +} + +doc +{"_id": "1", "name": "Victor", "amount": 4.99, "last_name": "Otero"} +{"_id": "2", "name": "Gonzalo", "amount": 120.57, "last_name": "Crhystens"} +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +command ok +Find specific row with &&, < and > Operators +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "&&" + param { + type: OPERATOR + operator { + name: "<" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 120.57 + } + } + } + } + param { + type: OPERATOR + operator { + name: ">" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "amount" + } + } + } + param { + type: LITERAL + literal { + type: V_DOUBLE + v_double: 4.99 + } + } + } + } + } + } +} + +doc +{"_id": "3", "name": "Abraham", "amount": 74.56, "last_name": "Vega"} +command ok +Find with not available schema name +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "notavailableschema" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "not_in" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "==" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +Got expected error: Unknown database 'notavailableschema' (code 1049) +Find with not available table name +send Mysqlx.Crud.Find { + collection { + name: "notavailabletable" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + name: "_id" + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +Got expected error: Table 'mysqlxcoll.notavailabletable' doesn't exist (code 1146) +Find with not available column name +send Mysqlx.Crud.Find { + collection { + name: "maincoll" + schema: "mysqlxcoll" + } + data_model: DOCUMENT + criteria { + type: OPERATOR + operator { + name: "==" + param { + type: IDENT + identifier { + document_path { + type: MEMBER + value: "notavailablecolumn" + } + } + } + param { + type: LITERAL + literal { + type: V_OCTETS + v_octets { + value: "1" + } + } + } + } + } +} + +doc +command ok +================================================================================ +CLEAN UP +================================================================================ +RUN DROP SCHEMA IF EXISTS minisakila + +1 rows affected +RUN DROP SCHEMA IF EXISTS mysqlxcoll + +1 rows affected +RUN DROP USER crudfinduser@localhost + +0 rows affected +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/suite/x/r/find_table_find.result-pq b/mysql-test/suite/x/r/find_table_find.result-pq new file mode 100644 index 000000000..4dd3d2b07 --- /dev/null +++ b/mysql-test/suite/x/r/find_table_find.result-pq @@ -0,0 +1,202 @@ +create schema xtest default charset 'utf8mb4'; +RUN use xtest + +0 rows affected +RUN CREATE TABLE `city` ( + `ID` int(11) NOT NULL auto_increment, + `Name` char(35) NOT NULL default '', + `CountryCode` char(3) NOT NULL default '', + `District` char(20) NOT NULL default '', + `Population` int(11) NOT NULL default '0', + PRIMARY KEY (`ID`) +) + +0 rows affected +RUN INSERT INTO `city` VALUES (1,'Kabul','AFG','Kabol',1780000) + +1 rows affected +last insert id: 1 +RUN INSERT INTO `city` VALUES (2,'Qandahar','AFG','Qandahar',237500) + +1 rows affected +last insert id: 2 +RUN INSERT INTO `city` VALUES (3,'Herat','AFG','Herat',186800) + +1 rows affected +last insert id: 3 +RUN INSERT INTO `city` VALUES (4,'Mazar-e-Sharif','AFG','Balkh',127800) + +1 rows affected +last insert id: 4 +RUN INSERT INTO `city` VALUES (5,'Amsterdam','NLD','Noord-Holland',731200) + +1 rows affected +last insert id: 5 +RUN INSERT INTO `city` VALUES (6,'Rotterdam','NLD','Zuid-Holland',593321) + +1 rows affected +last insert id: 6 +RUN INSERT INTO `city` VALUES (7,'Haag','NLD','Zuid-Holland',440900) + +1 rows affected +last insert id: 7 +RUN INSERT INTO `city` VALUES (8,'Utrecht','NLD','Utrecht',234323) + +1 rows affected +last insert id: 8 +RUN INSERT INTO `city` VALUES (9,'Eindhoven','NLD','Noord-Brabant',201843) + +1 rows affected +last insert id: 9 +RUN INSERT INTO `city` VALUES (10,'Tilburg','NLD','Noord-Brabant',193238) + +1 rows affected +last insert id: 10 +RUN INSERT INTO `city` VALUES (11,'Groningen','NLD','Groningen',172701) + +1 rows affected +last insert id: 11 +RUN INSERT INTO `city` VALUES (12,'Breda','NLD','Noord-Brabant',160398) + +1 rows affected +last insert id: 12 +RUN INSERT INTO `city` VALUES (13,'Apeldoorn','NLD','Gelderland',153491) + +1 rows affected +last insert id: 13 +RUN INSERT INTO `city` VALUES (14,'Nijmegen','NLD','Gelderland',152463) + +1 rows affected +last insert id: 14 +RUN INSERT INTO `city` VALUES (15,'Enschede','NLD','Overijssel',149544) + +1 rows affected +last insert id: 15 +RUN INSERT INTO `city` VALUES (16,'Haarlem','NLD','Noord-Holland',148772) + +1 rows affected +last insert id: 16 +send Mysqlx.Crud.Find { + collection { + name: "city" + schema: "xtest" + } + data_model: TABLE + criteria { + type: OPERATOR + operator { + name: "<" + param { + type: IDENT + identifier { + name: "Population" + } + } + param { + type: LITERAL + literal { + type: V_SINT + v_signed_int: 150000 + } + } + } + } +} + +Mysqlx.Resultset.ColumnMetaData { + type: SINT + name: "ID" + original_name: "ID" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + length: 11 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "Name" + original_name: "Name" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + collation: 255 + length: 140 + flags: 17 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "CountryCode" + original_name: "CountryCode" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + collation: 255 + length: 12 + flags: 17 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "District" + original_name: "District" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + collation: 255 + length: 80 + flags: 17 +} + +Mysqlx.Resultset.ColumnMetaData { + type: SINT + name: "Population" + original_name: "Population" + table: "city" + original_table: "city" + schema: "xtest" + catalog: "def" + length: 11 + flags: 16 +} + +Mysqlx.Resultset.Row { + field: "\010" + field: "Mazar-e-Sharif\000" + field: "AFG\000" + field: "Balkh\000" + field: "\360\314\017" +} + +Mysqlx.Resultset.Row { + field: "\036" + field: "Enschede\000" + field: "NLD\000" + field: "Overijssel\000" + field: "\320\240\022" +} + +Mysqlx.Resultset.Row { + field: " " + field: "Haarlem\000" + field: "NLD\000" + field: "Noord-Holland\000" + field: "\310\224\022" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Sql.StmtExecuteOk { +} + +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/suite/x/r/stmtexecute_query_result.result-pq b/mysql-test/suite/x/r/stmtexecute_query_result.result-pq new file mode 100644 index 000000000..9c375ed05 --- /dev/null +++ b/mysql-test/suite/x/r/stmtexecute_query_result.result-pq @@ -0,0 +1,102 @@ +RUN drop schema if exists xtest + +0 rows affected +RUN create schema xtest + +1 rows affected +RUN use xtest + +0 rows affected +RUN create table mytable (pk int primary key auto_increment, data varchar(100)) + +0 rows affected +RUN create procedure result_and_error () +begin + select 1; + select * from invalid_table; +end + +0 rows affected +send Mysqlx.Sql.StmtExecute { + stmt: "insert into mytable values (DEFAULT, \'one\')" +} + + +1 rows affected +last insert id: 1 +send Mysqlx.Sql.StmtExecute { + stmt: "insert into mytable values (DEFAULT, \'two\')" +} + + +1 rows affected +last insert id: 2 +send Mysqlx.Sql.StmtExecute { + stmt: "insert into mytable values (DEFAULT, \'three\')" +} + + +1 rows affected +last insert id: 3 +send Mysqlx.Sql.StmtExecute { + stmt: "select * from mytable" +} + +Mysqlx.Resultset.ColumnMetaData { + type: SINT + name: "pk" + original_name: "pk" + table: "mytable" + original_table: "mytable" + schema: "xtest" + catalog: "def" + length: 11 + flags: 16 +} + +Mysqlx.Resultset.ColumnMetaData { + type: BYTES + name: "data" + original_name: "data" + table: "mytable" + original_table: "mytable" + schema: "xtest" + catalog: "def" + collation: 255 + length: 400 +} + +Mysqlx.Resultset.Row { + field: "\002" + field: "one\000" +} + +Mysqlx.Resultset.Row { + field: "\004" + field: "two\000" +} + +Mysqlx.Resultset.Row { + field: "\006" + field: "three\000" +} + +Mysqlx.Resultset.FetchDone { +} + +Mysqlx.Notice.Frame { + type: 3 + scope: LOCAL + payload: "Mysqlx.Notice.SessionStateChanged { param: ROWS_AFFECTED\nvalue {\n type: V_UINT\n v_unsigned_int: 0\n}\n }" +} + +Mysqlx.Sql.StmtExecuteOk { +} + +RUN drop schema if exists xtest + +1 rows affected +Mysqlx.Ok { + msg: "bye!" +} +ok diff --git a/mysql-test/t/all_persisted_variables.test b/mysql-test/t/all_persisted_variables.test index 00c707b52..b33ae5e11 100644 --- a/mysql-test/t/all_persisted_variables.test +++ b/mysql-test/t/all_persisted_variables.test @@ -41,7 +41,7 @@ call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* Changing innodb_extend_and_i call mtr.add_suppression("Failed to initialize TLS for channel: mysql_main"); let $total_global_vars=`SELECT COUNT(*) FROM performance_schema.global_variables where variable_name NOT LIKE 'ndb_%'`; -let $total_persistent_vars=412; +let $total_persistent_vars=419; --echo *************************************************************** --echo * 0. Verify that variables present in performance_schema.global diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index a57e74d01..ebeaca7a5 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -120,7 +120,15 @@ create table t1(a int) ; insert into t1 values(1),(2),(3); # Do not mtr.add_suppression here, avoid "Deadlock found ..." messages in log. -set debug='d,bug19656296'; +if ($PQ_TEST) +{ + set session debug=""; + set session debug='+d,ha_pq_next_deadlock'; +} +if (!$PQ_TEST) +{ + set debug='d,bug19656296'; +} --error ER_LOCK_DEADLOCK select * from t1 order by a; drop table t1; diff --git a/mysql-test/t/mysqlpump.test b/mysql-test/t/mysqlpump.test index 030ba4973..bb45de465 100644 --- a/mysql-test/t/mysqlpump.test +++ b/mysql-test/t/mysqlpump.test @@ -220,8 +220,16 @@ FLUSH PRIVILEGES; --exec $MYSQL_PUMP --include-databases=db1 --log-error-file=$MYSQLTEST_VARDIR/log/bug27096081.log > $MYSQLTEST_VARDIR/tmp/bug27096081.sql ---error 23, 42, 139, 169, 1449, -1073741819 ---exec $MYSQL_PUMP --include-databases=db2 --log-error-file=$MYSQLTEST_VARDIR/log/bug27096081.log > $MYSQLTEST_VARDIR/tmp/bug27096081.sql +if ($PQ_TEST) +{ + --error 1, 23, 42, 139, 169, 1449, -1073741819 + --exec $MYSQL_PUMP --include-databases=db2 --log-error-file=$MYSQLTEST_VARDIR/log/bug27096081.log > $MYSQLTEST_VARDIR/tmp/bug27096081.sql +} +if (!$PQ_TEST) +{ + --error 23, 42, 139, 169, 1449, -1073741819 + --exec $MYSQL_PUMP --include-databases=db2 --log-error-file=$MYSQLTEST_VARDIR/log/bug27096081.log > $MYSQLTEST_VARDIR/tmp/bug27096081.sql +} --let SEARCH_FILE= $MYSQLTEST_VARDIR/log/bug27096081.log --let SEARCH_PATTERN= \[ERROR\] \(1449\) The user specified as a definer \('u1'@'%'\) does not exist diff --git a/mysql-test/t/opt_hint_timeout.test b/mysql-test/t/opt_hint_timeout.test index ffa26dc9e..f6f37eb61 100644 --- a/mysql-test/t/opt_hint_timeout.test +++ b/mysql-test/t/opt_hint_timeout.test @@ -1,5 +1,9 @@ --echo # WL#8017 Infrastructure for Optimizer Hints +--disable_query_log +call mtr.add_suppression("Make worker plan failed"); +--enable_query_log + --echo # MAX_EXECUTION_TIME hint testing --source include/have_statement_timeout.inc diff --git a/mysql-test/t/opt_hints_set_var.test b/mysql-test/t/opt_hints_set_var.test index 55c92143e..8dfaa3ad8 100644 --- a/mysql-test/t/opt_hints_set_var.test +++ b/mysql-test/t/opt_hints_set_var.test @@ -1,5 +1,9 @@ --source include/not_hypergraph.inc # Optimizer hints are not supported. +--disable_query_log +call mtr.add_suppression("Make worker plan failed"); +--enable_query_log + CREATE TABLE t1(f1 INT); # Parser tests diff --git a/mysys/dbug.cc b/mysys/dbug.cc index 0da19457a..3521c9549 100644 --- a/mysys/dbug.cc +++ b/mysys/dbug.cc @@ -923,6 +923,19 @@ void _db_pop_() { } } +void pq_stack_copy(CODE_STATE *leader_cs) { + CODE_STATE *cs; + get_code_state_or_return; + assert(cs->stack == &init_settings); + cs->stack = leader_cs->stack; +} + +void pq_stack_reset() { + CODE_STATE *cs; + get_code_state_or_return; + cs->stack = &init_settings; +} + /* * FUNCTION * diff --git a/mysys/my_alloc.cc b/mysys/my_alloc.cc index f7a30c18c..137a4ce12 100644 --- a/mysys/my_alloc.cc +++ b/mysys/my_alloc.cc @@ -1,4 +1,6 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. @@ -99,6 +101,39 @@ std::pair MEM_ROOT::AllocBlock( return {new_block, length}; } +void *MEM_ROOT::Alloc(size_t length) { + void *ret = nullptr; + length = ALIGN_SIZE(length); + + // Skip the straight path if simulating OOM; it should always fail. + DBUG_EXECUTE_IF("simulate_out_of_memory", return AllocSlow(length);); + + size_t old_alloc_size = m_allocated_size; + // Fast path, used in the majority of cases. It would be faster here + // (saving one register due to CSE) to instead test + // + // m_current_free_start + length <= m_current_free_end + // + // but it would invoke undefined behavior, and in particular be prone + // to wraparound on 32-bit platforms. + if (static_cast(m_current_free_end - m_current_free_start) >= length) { + ret = m_current_free_start; + m_current_free_start += length; + return ret; + } + + ret = AllocSlow(length); + assert(m_allocated_size >= old_alloc_size); + if (allocCBFunc && (m_allocated_size - old_alloc_size)) { + allocCBFunc( + m_psi_key, m_allocated_size - old_alloc_size, + ((reinterpret_cast(this) >> PQ_MEMORY_USED_BUCKET) & + 0xf)); + } + + return ret; +} + void *MEM_ROOT::AllocSlow(size_t length) { DBUG_TRACE; DBUG_PRINT("enter", ("root: %p", this)); @@ -166,6 +201,12 @@ void MEM_ROOT::Clear() { DBUG_TRACE; DBUG_PRINT("enter", ("root: %p", this)); + if (freeCBFunc && m_allocated_size) { + freeCBFunc( + m_psi_key, m_allocated_size, + (reinterpret_cast(this) >> PQ_MEMORY_USED_BUCKET) & 0xf); + } + // Already cleared, or memset() to zero, so just ignore. if (m_current_block == nullptr) return; @@ -188,6 +229,8 @@ void MEM_ROOT::ClearForReuse() { return; } + size_t old_alloc_size = m_allocated_size; + // Already cleared, or memset() to zero, so just ignore. if (m_current_block == nullptr) return; @@ -198,6 +241,12 @@ void MEM_ROOT::ClearForReuse() { m_current_block->prev = nullptr; m_allocated_size = m_current_free_end - m_current_free_start; + if (freeCBFunc && (old_alloc_size - m_allocated_size)) { + freeCBFunc( + m_psi_key, old_alloc_size - m_allocated_size, + (reinterpret_cast(this) >> PQ_MEMORY_USED_BUCKET) & 0xf); + } + FreeBlocks(start); } diff --git a/share/messages_to_clients.txt b/share/messages_to_clients.txt index 7ff9af752..1ad31d407 100644 --- a/share/messages_to_clients.txt +++ b/share/messages_to_clients.txt @@ -1,4 +1,5 @@ # Copyright (c) 2017, 2021, Oracle and/or its affiliates. +# Copyright (c) 2022, Huawei Technologies Co., Ltd. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2.0, @@ -9555,6 +9556,22 @@ ER_CHANGE_RPL_SRC_WRONG_COMPRESSION_ALGORITHM_SIZE reserved-error-section 5000 5999 +################################################################################ +# Error numbers starting at 7500: server-to-client messages hwsql +# +# Start of hwsql error messages (error log). +# + +start-error-number 7500 + +ER_PARALLEL_FAIL_INIT + eng "Failed to parallel execute. this SQL is not supported." + +ER_WARN_BAD_PARALLEL_NUM + eng "Incorrect number for degree of parallel" + +ER_PARALLEL_EXEC_ERROR + eng "Parallel execution error" ################################################################################ # DO NOT add messages for the error-log to this file; diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 5fd225c1e..315044ef7 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (c) 2006, 2021, Oracle and/or its affiliates. +# Copyright (c) 2022, Huawei Technologies Co., Ltd. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2.0, @@ -459,6 +460,7 @@ SET(SQL_SHARED_SOURCES protocol_classic.cc psi_memory_key.cc query_result.cc + msg_queue.cc records.cc regexp/errors.cc regexp/regexp_engine.cc @@ -527,6 +529,10 @@ SET(SQL_SHARED_SOURCES sql_locale.cc sql_manager.cc sql_optimizer.cc + sql_parallel.cc + pq_condition.cc + pq_clone.cc + pq_clone_item.cc sql_parse.cc sql_partition.cc sql_partition_admin.cc @@ -587,6 +593,10 @@ SET(SQL_SHARED_SOURCES uniques.cc xa.cc daemon_proxy_keyring/daemon_proxy_keyring.cc + exchange.cc + exchange_sort.cc + exchange_nosort.cc + msg_queue.cc ) # BISON_TARGET( diff --git a/sql/basic_row_iterators.h b/sql/basic_row_iterators.h index bba4d07a2..cd9479cbd 100644 --- a/sql/basic_row_iterators.h +++ b/sql/basic_row_iterators.h @@ -2,6 +2,7 @@ #define SQL_BASIC_ROW_ITERATORS_H_ /* Copyright (c) 2018, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -41,6 +42,7 @@ #include "sql/mem_root_array.h" #include "sql/row_iterator.h" #include "sql/sql_list.h" +#include "filesort.h" class Filesort_info; class Item; @@ -50,6 +52,80 @@ class THD; class handler; struct IO_CACHE; struct TABLE; +class Gather_operator; +class ORDER; +class MQ_record_gather; +class QEP_TAB; + +/** + * Parallel scan iterator, which is used in parallel leader + */ +class ParallelScanIterator final : public TableRowIterator { + public: + ParallelScanIterator(THD *thd, QEP_TAB *tab, TABLE *table, + ha_rows *examined_rows, JOIN *join, + Gather_operator *gather, bool stab_output = false, + uint ref_length = 0); + + ~ParallelScanIterator() override; + + bool Init() override; + int Read() override; + int End() override; + void UnlockRow() override {} + void SetNullRowFlag(bool) override {} + void StartPSIBatchMode() override {} + void EndPSIBatchModeIfStarted() override {} + + private: + uchar *const m_record; + ha_rows *const m_examined_rows; + uint m_dop; + JOIN *m_join; + Gather_operator *m_gather; + MQ_record_gather *m_record_gather; + ORDER *m_order; /** use for records merge sort */ + QEP_TAB *m_tab; + bool m_stable_sort; /** determine whether using stable sort */ + uint m_ref_length; + + /** construct filesort on leader when needing stab_output or merge_sort */ + bool pq_make_filesort(Filesort **sort); + /** init m_record_gather */ + bool pq_init_record_gather(); + /** launch worker threads to execute parallel query */ + bool pq_launch_worker(); + /** wait all workers finished */ + void pq_wait_workers_finished(); + /** outoput parallel query error code */ + int pq_error_code(); +}; + +class PQ_worker_manager; + +/** + * block scan iterator, which is used is in parallel worker. + * a whole talbe is cut into many blocks for parallel scan + */ +class PQblockScanIterator final : public TableRowIterator { + public: + PQblockScanIterator(THD *thd, TABLE *table, uchar *record, + ha_rows *examined_rows, Gather_operator *gather, + bool need_rowid = false); + ~PQblockScanIterator() override; + + bool Init() override; + int Read() override; + int End() override; + + private: + uchar *const m_record; + ha_rows *const m_examined_rows; + void *m_pq_ctx; // parallel query context + uint keyno; + Gather_operator *m_gather; + bool m_need_rowid; +}; /** Scan a table from beginning to end. diff --git a/sql/binary_heap.h b/sql/binary_heap.h new file mode 100644 index 000000000..7628d16a1 --- /dev/null +++ b/sql/binary_heap.h @@ -0,0 +1,190 @@ +#ifndef MYSQL_BINARY_HEAP_H +#define MYSQL_BINARY_HEAP_H + +/* Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "sql/sql_class.h" + +// compare based on the sort_key +typedef bool (*binaryheap_comparator)(int a, int b, void *arg); +class binary_heap { + public: + binary_heap(int element_size, void *arg, binaryheap_comparator cmp, THD *thd) + : m_queue(nullptr), + m_capacity(element_size), + m_size(0), + m_compare(cmp), + m_arg(arg), + m_thd(thd) {} + + /* @retval: false of success, and true otherwise. */ + bool init_binary_heap() { + if (m_capacity <= 0) { + return true; + } + m_queue = new (m_thd->pq_mem_root) int[m_capacity + 1]; + if (!m_queue || DBUG_EVALUATE_IF("pq_msort_error9", true, false)) { + my_error(ER_STD_BAD_ALLOC_ERROR, MYF(0), "", "(PQ::init)"); + return true; + } + return false; + } + + void reset() { m_size = 0; } + + void add_unorderd(int element) { + if (m_size >= m_capacity || + DBUG_EVALUATE_IF("pq_msort_error8", true, false)) { + my_error(ER_STD_BAD_ALLOC_ERROR, MYF(0), "", "(PQ::add_unorderd)"); + return; + } + m_queue[m_size++] = element; + } + + void build() { + if (m_size <= 1) { + return; + } + for (int i = parent(m_size - 1); i >= 0; i--) { + sift_down(i); + } + } + + int first() { + assert(!empty()); + return m_queue[0]; + } + + int remove_first() { + assert(!empty()); + if (m_size == 1) { + m_size--; + return m_queue[0]; + } + + swap_node(0, m_size - 1); + m_size--; + sift_down(0); + + return m_queue[m_size]; + } + + void replace_first(int element) { + assert(!empty()); + m_queue[0] = element; + if (m_size > 1) { + sift_down(0); + } + } + + bool empty() { return m_size == 0; } + + void cleanup() { + if (m_queue) { + destroy(m_queue); + } + } + + private: + /* return the index ((i - 1) / 2) of the parent node of node i */ + int parent(unsigned int i) { + assert(i != 0); + return (--i) >> 1; + } + + /* return the index (2 * i + 1) of the left child of node i */ + int left(unsigned int i) { return (i << 1) | 1; } + + /* return the index (2 * i + 2) of the right child of node */ + int right(unsigned int i) { return (++i) << 1; } + + uint size() { return m_size; } + + void add(int element) { + if (m_size >= m_capacity) { + my_error(ER_STD_BAD_ALLOC_ERROR, MYF(0), "out of binary heap space"); + return; + } + m_queue[m_size++] = element; + sift_up(m_size - 1); + } + + void swap_node(int a, int b) { + int temp; + temp = m_queue[a]; + m_queue[a] = m_queue[b]; + m_queue[b] = temp; + } + + void sift_down(int node_off) { + while (true) { + int left_off = left(node_off); + int right_off = right(node_off); + int swap_off = 0; + + if (left_off < m_size && + m_compare(m_queue[left_off], m_queue[node_off], m_arg)) { + swap_off = left_off; + } + + if (right_off < m_size && + m_compare(m_queue[right_off], m_queue[node_off], m_arg)) { + if (!swap_off || + m_compare(m_queue[right_off], m_queue[left_off], m_arg)) { + swap_off = right_off; + } + } + + if (!swap_off) { + break; + } + + swap_node(swap_off, node_off); + node_off = swap_off; + } + } + + void sift_up(int node_off) { + bool cmp = false; + int parent_off; + while (node_off != 0) { + parent_off = parent(node_off); + cmp = m_compare(m_queue[parent_off], m_queue[node_off], m_arg); + if (cmp) { + break; + } + + swap_node(node_off, parent_off); + node_off = parent_off; + } + } + + int *m_queue; + int m_capacity; + int m_size; + binaryheap_comparator m_compare; + void *m_arg; + THD *m_thd; +}; +#endif // MYSQL_BINARY_HEAP_H diff --git a/sql/cmp_varlen_keys.h b/sql/cmp_varlen_keys.h index 220c29496..43391ff28 100644 --- a/sql/cmp_varlen_keys.h +++ b/sql/cmp_varlen_keys.h @@ -1,4 +1,5 @@ /* Copyright (c) 2016, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -39,12 +40,14 @@ @param s1 pointer to record 1 @param s2 pointer to record 2 @return true/false according to sorting order - true : s1 < s2 - false : s1 >= s2 + * return: + * - if s1 < s2; + * 0 if s1 = s2; + * + if s1 > s2; */ inline bool cmp_varlen_keys( Bounds_checked_array sort_field_array, bool use_hash, - const uchar *s1, const uchar *s2) { + const uchar *s1, const uchar *s2, int *pq_cmp_value=nullptr) { const uchar *kp1 = s1 + Sort_param::size_of_varlength_field; const uchar *kp2 = s2 + Sort_param::size_of_varlength_field; int res; @@ -53,7 +56,11 @@ inline bool cmp_varlen_keys( if (sort_field.maybe_null) { const int k1_nullbyte = *kp1++; const int k2_nullbyte = *kp2++; - if (k1_nullbyte != k2_nullbyte) return k1_nullbyte < k2_nullbyte; + + if (k1_nullbyte != k2_nullbyte) { + if (pq_cmp_value) *pq_cmp_value = k1_nullbyte - k2_nullbyte; + return k1_nullbyte < k2_nullbyte; + } if (k1_nullbyte == 0 || k1_nullbyte == 0xff) { if (!sort_field.is_varlen) { kp1 += sort_field.length; @@ -79,12 +86,23 @@ inline bool cmp_varlen_keys( res = memcmp(kp1, kp2, kp_len); - if (res) return res < 0; + if (res) { + if (pq_cmp_value) + *pq_cmp_value = res; + return res < 0; + } + if (kp1_len != kp2_len) { - if (sort_field.reverse) + if (sort_field.reverse) { + if (pq_cmp_value) + *pq_cmp_value = kp2_len - kp1_len; return kp2_len < kp1_len; - else + } + else { + if (pq_cmp_value) + *pq_cmp_value = kp1_len - kp2_len; return kp1_len < kp2_len; + } } kp1 += kp1_len; @@ -93,8 +111,11 @@ inline bool cmp_varlen_keys( if (use_hash) { // Compare hashes at the end of sort keys - return memcmp(kp1, kp2, 8) < 0; + int cmp_value = memcmp(kp1, kp2, 8); + if (pq_cmp_value) *pq_cmp_value = cmp_value; + return cmp_value < 0; } else { + if (pq_cmp_value) *pq_cmp_value = 1; return false; } } diff --git a/sql/composite_iterators.cc b/sql/composite_iterators.cc index dff62b694..0d69b992d 100644 --- a/sql/composite_iterators.cc +++ b/sql/composite_iterators.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2018, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -179,6 +180,10 @@ int LimitOffsetIterator::Read() { return result; } +int LimitOffsetIterator::End() { + return m_source->End(); +} + AggregateIterator::AggregateIterator( THD *thd, unique_ptr_destroy_only source, JOIN *join, TableCollection tables, bool rollup) @@ -193,7 +198,7 @@ AggregateIterator::AggregateIterator( } bool AggregateIterator::Init() { - assert(!m_join->tmp_table_param.precomputed_group_by); + assert(!m_join->tmp_table_param->precomputed_group_by); // Disable any leftover rollup items used in children. m_current_rollup_position = -1; @@ -214,6 +219,10 @@ bool AggregateIterator::Init() { return false; } +int AggregateIterator::End() { + return m_source->End(); +} + int AggregateIterator::Read() { switch (m_state) { case READING_FIRST_ROW: { @@ -1187,6 +1196,10 @@ int TemptableAggregateIterator::Read() { return m_table_iterator->Read(); } +int TemptableAggregateIterator::End() { + return m_subquery_iterator->End(); +} + MaterializedTableFunctionIterator::MaterializedTableFunctionIterator( THD *thd, Table_function *table_function, TABLE *table, unique_ptr_destroy_only table_iterator) diff --git a/sql/composite_iterators.h b/sql/composite_iterators.h index 7e1b31fc9..9bff5e443 100644 --- a/sql/composite_iterators.h +++ b/sql/composite_iterators.h @@ -2,6 +2,7 @@ #define SQL_COMPOSITE_ITERATORS_INCLUDED /* Copyright (c) 2018, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -81,6 +82,8 @@ class FilterIterator final : public RowIterator { int Read() override; + int End() override { return m_source->End(); } + void SetNullRowFlag(bool is_null_row) override { m_source->SetNullRowFlag(is_null_row); } @@ -135,6 +138,8 @@ class LimitOffsetIterator final : public RowIterator { int Read() override; + int End() override; + void SetNullRowFlag(bool is_null_row) override { m_source->SetNullRowFlag(is_null_row); } @@ -205,6 +210,8 @@ class AggregateIterator final : public RowIterator { bool Init() override; int Read() override; + int End() override; + void SetNullRowFlag(bool is_null_row) override { m_source->SetNullRowFlag(is_null_row); } @@ -535,6 +542,13 @@ class MaterializeIterator final : public TableRowIterator { bool Init() override; int Read() override; + int End() override { + for (auto &qb : m_query_blocks_to_materialize) { + qb.subquery_iterator->End(); + } + return thd()->is_worker() ? -1 : 1; + } + void SetNullRowFlag(bool is_null_row) override { m_table_iterator->SetNullRowFlag(is_null_row); } @@ -654,6 +668,10 @@ class StreamingIterator final : public TableRowIterator { int Read() override; + int End() override { + return m_subquery_iterator->End(); + } + void StartPSIBatchMode() override { m_subquery_iterator->StartPSIBatchMode(); } @@ -691,6 +709,8 @@ class TemptableAggregateIterator final : public TableRowIterator { bool Init() override; int Read() override; + int End() override; + void SetNullRowFlag(bool is_null_row) override { m_table_iterator->SetNullRowFlag(is_null_row); } diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 49b810f9d..20db49a33 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2009, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -932,7 +933,7 @@ static void debug_sync_remove_action(st_debug_sync_control *ds_control, uint dsp_idx = static_cast(action - ds_control->ds_action); DBUG_TRACE; assert(ds_control); - assert(ds_control == current_thd->debug_sync_control); + assert(ds_control == current_thd->debug_sync_control || ds_control == current_thd->pq_leader->debug_sync_control); assert(action); assert(dsp_idx < ds_control->ds_active); diff --git a/sql/exchange.cc b/sql/exchange.cc new file mode 100644 index 000000000..2d1b4ecc6 --- /dev/null +++ b/sql/exchange.cc @@ -0,0 +1,223 @@ +/* Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "exchange.h" +#include "field.h" +#include "table.h" + +/** + * alloc space for mqueue_handles + * + * @return false for success, and otherwise true. + */ +bool Exchange::init() { + uint i = 0; + MQueue **mqueues = nullptr; + /** note that: all workers share one receiver. */ + m_receiver = new (m_thd->pq_mem_root) MQ_event(m_thd); + if (m_receiver == nullptr) { + goto err; + } + + mqueue_handles = + new (m_thd->pq_mem_root) MQueue_handle *[m_nqueues] { nullptr }; + if (mqueue_handles == nullptr) { + goto err; + } + + mqueues = new (m_thd->pq_mem_root) MQueue *[m_nqueues] { nullptr }; + if (mqueues == nullptr) { + goto err; + } + + for (i = 0; i < m_nqueues; i++) { + char *ring_buffer = new (m_thd->pq_mem_root) char[RING_SIZE]; + if (ring_buffer == nullptr) { + goto err; + } + + MQ_event *sender = new (m_thd->pq_mem_root) MQ_event(); + if (sender == nullptr) { + goto err; + } + + mqueues[i] = new (m_thd->pq_mem_root) + MQueue(sender, m_receiver, ring_buffer, RING_SIZE); + if (mqueues[i] == nullptr || + DBUG_EVALUATE_IF("pq_mq_error1", true, false)) { + goto err; + } + } + + for (i = 0; i < m_nqueues; i++) { + mqueue_handles[i] = + new (m_thd->pq_mem_root) MQueue_handle(mqueues[i], MQ_BUFFER_SIZE); + if (mqueue_handles[i] == nullptr || + mqueue_handles[i]->init_mqueue_handle(m_thd) || + DBUG_EVALUATE_IF("pq_mq_error2", true, false)) { + goto err; + } + } + + return false; + +err: + sql_print_error("alloc space for exchange_record_pq error"); + return true; +} + +void Exchange::cleanup() { + destroy(m_receiver); + if (mqueue_handles) { + for (uint i = 0; i < m_nqueues; i++) { + if (mqueue_handles[i]) { + mqueue_handles[i]->cleanup(); + } + } + } +} + +/* +* determine the checked value corresponding to CONST_ITEM/NULL_FIELD +* using look-up table to accelerate this process, such as + t[0] = {false, false}, t[1] = {false, true}, + t[2] = {true, false}, t[3] = {true, true} +*/ +static char bool_item_field[8] = {0, 0, 0, 1, 1, 0, 1, 1}; + +char *const_item_and_field_flag(uint value) { + assert(value < 4); + return bool_item_field + 2 * value; +} + +/** + * reconstruct table->record[0] from MQ's message + * @data: the message data + * @msg_len: the message length + * + * @return true if successful execution, and return false otherwise + * + * Note that: in this process, we can receive an error msg from worker, which + * may come from the several conditions: + * (1) some workers may produce an error during the execution; + * (2) the sending/receiving msg procedure occurs an error; + * (3) some unexpected errors; + * + */ +bool Exchange::convert_mq_data_to_record(uchar *data, int msg_len, + uchar *row_id) { + /** there is error */ + if (m_thd->is_killed() || m_thd->pq_error) { + return false; + } + if (msg_len == 1 || DBUG_EVALUATE_IF("pq_worker_error10", true, false)) { + if (data[0] == EMPTY_MSG && + DBUG_EVALUATE_IF("pq_worker_error10", false, true)) { + return true; + } else { + const char *msg = (data[0] == ERROR_MSG) ? "error msg" : "unknown error"; + sql_print_error("[Parallel query]: error info. %s\n", msg); + m_thd->pq_error = true; + return false; + } + } + + memset(m_table->record[0], 255, m_table->s->reclength); + int size_field = m_table->s->fields; + + // fetch the row_id info. from MQ + if (m_stab_output) { + if (row_id) { + memcpy(row_id, data, m_ref_length); + } + data += m_ref_length; + } + + uint null_len = *(uint16 *)data; + data = data + sizeof(uint16); + uchar *null_flag = (uchar *)data; + + /** + * Note that: we use one more byte to store Field_varstring::length_bytes. + */ + if (DBUG_EVALUATE_IF("pq_worker_error11", true, false) || + msg_len > + (int)(m_table->s->reclength + 6 + null_len + m_table->s->fields + + (m_stab_output ? m_ref_length : 0))) { + m_thd->pq_error = true; + sql_print_error( + "[Parallel query]: sending (or receiving) msg from MQ error"); + return false; + } + + bool null_field = false; + bool const_item = false; + uint bit_value; + char *status_flag = nullptr; + uint null_offset = 0; + uint ptr_offset = null_len; + Field *item_field = nullptr; + int i = 0, j; + for (; i < size_field; i++) { + item_field = m_table->field[i]; + /** determine whether it is a CONST_ITEM or NULL_FIELD */ + j = (null_offset >> 3) + 1; + assert((null_offset & 1) == 0); + bit_value = (null_flag[j] >> (6 - (null_offset & 7))) & 3; + status_flag = const_item_and_field_flag(bit_value); + const_item = *status_flag; + null_field = *(status_flag + 1); + enum_field_types field_type = item_field->type(); + /** we should fill data into record[0] only when NOT_CONST_ITEM & + * NOT_NULL_FIELD */ + if (!const_item && !null_field) { + if (field_type == MYSQL_TYPE_VARCHAR || + field_type == MYSQL_TYPE_VAR_STRING) { + Field_varstring *field_var = static_cast(item_field); + field_var->length_bytes = (uint)data[ptr_offset]; + ptr_offset++; // moving to the real value + uint field_length = (field_var->length_bytes == 1) + ? (uint)data[ptr_offset] + : uint2korr(&data[ptr_offset]); + uint pack_length = field_length + field_var->length_bytes; + memcpy(field_var->ptr, &data[ptr_offset], pack_length); + ptr_offset += pack_length; + } else { + uint pack_length = item_field->pack_length(); + memcpy(item_field->ptr, &data[ptr_offset], pack_length); + ptr_offset += pack_length; + } + } + /** set NULL flag of field */ + if (!const_item) { + if (null_field) { + item_field->set_null(); + } else { + item_field->set_notnull(); + } + } + null_offset += 2; + } + + return true; +} diff --git a/sql/exchange.h b/sql/exchange.h new file mode 100644 index 000000000..f58ceecc7 --- /dev/null +++ b/sql/exchange.h @@ -0,0 +1,98 @@ +#ifndef EXCHAGE_H +#define EXCHAGE_H + +/* Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "msg_queue.h" + +class Exchange { + public: + enum EXCHANGE_TYPE { + EXCHANGE_NOSORT = 0, + EXCHANGE_SORT, + }; + + Exchange() + : mqueue_handles(nullptr), + m_thd(nullptr), + m_table(nullptr), + m_nqueues(0), + m_receiver(nullptr), + m_ref_length(0), + m_stab_output(false) {} + + Exchange(THD *thd, TABLE *table, uint32 workers, uint ref_length, + bool stab_output = false) + : mqueue_handles(nullptr), + m_thd(thd), + m_table(table), + m_nqueues(workers), + m_receiver(nullptr), + m_ref_length(ref_length), + m_stab_output(stab_output) {} + + virtual ~Exchange() {} + + virtual bool read_mq_record() = 0; + virtual EXCHANGE_TYPE get_exchange_type() = 0; + virtual bool init(); + virtual void cleanup(); + virtual bool convert_mq_data_to_record(uchar *data, int msg_len, + uchar *row_id = nullptr); + + inline THD *get_thd() { return m_thd ? m_thd : current_thd; } + + inline MQueue_handle *get_mq_handle(uint32 i) { + assert(mqueue_handles); + assert(i < m_nqueues); + return mqueue_handles[i]; + } + + inline void mqueue_mmove(int mq_next_readers, int number_workers) { + memmove(&mqueue_handles[mq_next_readers], + &mqueue_handles[mq_next_readers + 1], + sizeof(MQueue_handle *) * (number_workers - mq_next_readers)); + } + + inline int lanuch_workers() { return m_nqueues; } + + inline TABLE *get_table() { return m_table; } + + inline int ref_length() { return m_ref_length; } + + inline bool is_stable() { return m_stab_output; } + + public: + MQueue_handle **mqueue_handles; + THD *m_thd; + TABLE *m_table; + + private: + uint32 m_nqueues; + MQ_event *m_receiver; + uint m_ref_length; + bool m_stab_output; +}; + +#endif // EXCHAGE_H diff --git a/sql/exchange_nosort.cc b/sql/exchange_nosort.cc new file mode 100644 index 000000000..e04b4e65e --- /dev/null +++ b/sql/exchange_nosort.cc @@ -0,0 +1,125 @@ +/* Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "exchange_nosort.h" + +/** + * read one message from MQ[next_queue] + * + * @retval: true for success, and otherwise false + */ +bool Exchange_nosort::get_next(void **datap, uint32 *m_len, bool *done) { + MQ_RESULT result; + if (done != nullptr) { + *done = false; + } + MQueue_handle *reader = get_mq_handle(m_next_queue); + result = reader->receive(datap, m_len); + if (result == MQ_DETACHED) { + if (done != nullptr) { + *done = true; + } + return false; + } + if (result == MQ_WOULD_BLOCK) { + return false; + } + + return true; +} + +/** + * read one message from MQ in a round-robin method + * @datap: the message data + * @m_len: the message length + * + * @retval: true for success, and otherwise false + */ +bool Exchange_nosort::read_next(void **datap, uint32 *m_len) { + bool readerdone = false; + int nvisited = 0; + bool read_result = false; + THD *thd = get_thd(); + + /** round-robin method to acquire the data */ + while (!thd->is_killed() && !thd->pq_error) { + read_result = get_next(datap, m_len, &readerdone); + /** detached and its content is also read done */ + if (readerdone) { + assert(false == read_result); + m_active_readers--; + /** read done for all queues */ + if (m_active_readers == 0) { + return false; + } + mqueue_mmove(m_next_queue, m_active_readers); + if (m_next_queue >= m_active_readers) { + m_next_queue = 0; + } + continue; + } + + /** data has successfully read into datap */ + if (read_result) { + return true; + } + /** move to next worker */ + m_next_queue++; + if (m_next_queue >= m_active_readers) { + m_next_queue = 0; + } + nvisited++; + /** In a round-robin, we cannot read one message from MQ */ + if (nvisited >= m_active_readers) { + /** + * this barrier ensures that the receiver first enters into a + * waiting status and then is waked by one sender. + */ + memory_barrier(); + MQ_event *receiver = get_mq_handle(0)->get_receiver(); + if (receiver) { + receiver->wait_latch(); + receiver->reset_latch(); + } + nvisited = 0; + } + } + + return false; +} + +/** + * read one message from MQ and fill it to table->record[0] + * + * @retval: true for success, and otherwise false + */ +bool Exchange_nosort::read_mq_record() { + assert(!is_stable() && get_exchange_type() == EXCHANGE_NOSORT); + bool result = false; + uchar *data = nullptr; + uint32 msg_len = 0; + + /** read a message from MQ's local buffer */ + result = read_next((void **)&data, &msg_len); + return (result && convert_mq_data_to_record(data, msg_len)); +} diff --git a/sql/exchange_nosort.h b/sql/exchange_nosort.h new file mode 100644 index 000000000..e866c324f --- /dev/null +++ b/sql/exchange_nosort.h @@ -0,0 +1,57 @@ +#ifndef EXCHANGE_NOSORT_H +#define EXCHANGE_NOSORT_H + +/* Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "exchange.h" + +class Exchange_nosort : public Exchange { + public: + Exchange_nosort() : Exchange(), m_next_queue(0), m_active_readers(0) {} + + Exchange_nosort(THD *thd, TABLE *table, int workers, int ref_length, + bool stab_output) + : Exchange(thd, table, workers, ref_length, stab_output), + m_next_queue(0), + m_active_readers(workers) {} + + virtual ~Exchange_nosort() {} + + /** read/convert one message from mq to table->record[0] */ + bool read_mq_record() override; + + inline EXCHANGE_TYPE get_exchange_type() override { return EXCHANGE_NOSORT; } + + private: + /** read one message from MQ[next_queue] */ + bool get_next(void **datap, uint32 *len, bool *done); + /** read one message from MQ in a round-robin manner */ + bool read_next(void **datap, uint32 *len); + + int m_next_queue; /** the next read queue */ + int m_active_readers; /** number of left queues which is sending or + receiving message */ +}; + +#endif // EXCHANGE_NOSORT_H diff --git a/sql/exchange_sort.cc b/sql/exchange_sort.cc new file mode 100644 index 000000000..c5126f1da --- /dev/null +++ b/sql/exchange_sort.cc @@ -0,0 +1,350 @@ +/* Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "exchange_sort.h" +#include "bounded_queue.h" +#include "sql_executor.h" + +/** + * allocate memory for members + * + * @retval: + * false for success, and otherwise true. + */ +bool Exchange_sort::alloc() { + int i, j; + int readers = lanuch_workers(); + THD *thd = get_thd(); + + m_min_records = new (thd->pq_mem_root) mq_record_st *[readers] { NULL }; + if (!m_min_records) goto err; + + for (i = 0; i < readers; i++) { + m_min_records[i] = new (thd->pq_mem_root) mq_record_st(); + if (!m_min_records[i]) goto err; + } + + m_record_groups = new (thd->pq_mem_root) mq_records_batch_st[readers]; + if (!m_record_groups) goto err; + + for (i = 0; i < readers; i++) { + m_record_groups[i].records = + new (thd->pq_mem_root) mq_record_st *[MAX_RECORD_STORE] { NULL }; + if (!m_record_groups[i].records) goto err; + + for (j = 0; j < MAX_RECORD_STORE; j++) { + m_record_groups[i].records[j] = new (thd->pq_mem_root) mq_record_st(); + if (!m_record_groups[i].records[j]) goto err; + + m_record_groups[i].records[j]->m_data = + new (thd->pq_mem_root) uchar[RECORD_BUFFER_SIZE]; + if (!m_record_groups[i].records[j]->m_data) goto err; + } + } + m_heap = new (thd->pq_mem_root) + binary_heap(readers + 1, this, heap_compare_records, thd); + if (!m_heap || m_heap->init_binary_heap()) goto err; + + return false; + +err: + sql_print_error("allocate space in Exchange_sort::alloc() error"); + return true; +} + +/* + * init sort-related structure + * + * @retval: + * false for success, and otherwise true. + */ +bool Exchange_sort::init() { + if (Exchange::init()) return true; + + THD *thd = get_thd(); + uint row_id_length = ref_length(); + + /** init Sort_param */ + if (m_sort && m_sort->m_order) { + /** generate sort_order */ + int s_length = m_sort->make_sortorder(m_sort->m_order, false); + if (!s_length) return true; + m_sort_param = new (thd->pq_mem_root) Sort_param(); + if (!m_sort_param) return true; + + /** generate sort_param */ + TABLE *const table = get_table(); + m_sort_param->init_for_filesort( + m_sort, make_array(m_sort->sortorder, s_length), + sortlength(thd, m_sort->sortorder, s_length), {table}, lanuch_workers(), + false); + + m_sort_param->local_sortorder = + Bounds_checked_array(m_sort->sortorder, s_length); + + /** cache sort key for compare */ + m_tmp_key = new (thd->pq_mem_root) uchar[row_id_length]; + memset(m_tmp_key, 0, row_id_length); + if (!m_tmp_key) return true; + } + + assert(m_sort_param || is_stable()); + if (m_sort_param) { + int key_len = m_sort_param->max_record_length() + 1; + keys[0] = new (thd->pq_mem_root) uchar[key_len]; + keys[1] = new (thd->pq_mem_root) uchar[key_len]; + + if (keys[0] == nullptr || keys[1] == nullptr) return true; + + memset(keys[0], 0, key_len); + memset(keys[1], 0, key_len); + } + + if (is_stable()) { + assert(m_file->ht->db_type == DB_TYPE_INNODB); + assert(row_id_length == m_file->ref_length); + row_id[0] = new (thd->pq_mem_root) uchar[row_id_length]; + row_id[1] = new (thd->pq_mem_root) uchar[row_id_length]; + + if (row_id[0] == nullptr || row_id[1] == nullptr) return true; + + memset(row_id[0], 0, row_id_length); + memset(row_id[1], 0, row_id_length); + } + + /** alloc space for binary heap etc. */ + return alloc(); +} + +/** build the binary heap */ +void Exchange_sort::build_heap() { + int ngroups = lanuch_workers(); + for (int i = 0; i < ngroups; i++) { + m_record_groups[i].completed = false; + m_record_groups[i].n_read = 0; + m_record_groups[i].n_total = 0; + m_min_records[i]->m_data = nullptr; + } + + /** reset for binary heap */ + m_heap->reset(); + /** when nowait = false, ensure that each slot has one record through + read message from MQ in a blocking mode */ + bool nowait = false; + +reread: + for (int i = 0; i < ngroups; i++) { + if (!m_record_groups[i].completed) { + if (m_min_records[i]->m_data == nullptr) { + if (read_group(i, nowait)) m_heap->add_unorderd(i); + } else { + load_group_records(i); + } + } + } + + /** recheck each slot in m_records */ + for (int i = 0; i < ngroups; i++) { + if (!m_record_groups[i].completed && !m_min_records[i]->m_data) { + nowait = false; + goto reread; + } + } + + /** build the binary heap */ + m_heap->build(); + m_init_heap = true; +} + +/**return the next minimum record */ +mq_record_st *Exchange_sort::get_min_record() { + int i; + + if (!m_init_heap) { + build_heap(); + } else { + /** (1) obtain the top element of binary heap */ + i = m_heap->first(); + /** + * (2) try to read a record from MQ[i] in a blocking mode. + * If read_next() == true, then we push it into binary heap and + * adjust the binary heap; otherwise, there is no more message in + * MQ[i], and we should remove the i-th worker from binary heap. + * + */ + if (read_group(i, false)) { + m_heap->replace_first(i); + } else { + m_heap->remove_first(); + } + } + /** (3) fetch the top element of binary heap */ + if (m_heap->empty()) { + return nullptr; + } else { + i = m_heap->first(); + return m_min_records[i]; + } +} + +/** + * try to load a batch of messages into a record group + * @id: the worker to be loaded + */ +void Exchange_sort::load_group_records(int id) { + assert(0 <= id && id < lanuch_workers()); + mq_records_batch_st *rec_group = &m_record_groups[id]; + /** try to read message from MQ with a non-blocking mode */ + for (int i = rec_group->n_total; i < MAX_RECORD_STORE; i++) { + if (!load_group_record(id, i, &rec_group->completed, true)) break; + /** now, read a new message */ + rec_group->n_total++; + } +} + +/** + * fetch the current minimum record of the id-th records group + * + * @i: the ID of group + * @nowait: the fetch mode, nowait = false for blocking-mode and + * otherwise, nowait = true + */ +bool Exchange_sort::read_group(int id, bool nowait) { + assert(0 <= id && id < lanuch_workers()); + mq_records_batch_st *rec_group = &m_record_groups[id]; + + /** the record has been fetched into records_batch */ + if (rec_group->n_read < rec_group->n_total) { + m_min_records[id] = rec_group->records[rec_group->n_read++]; + return true; + } else if (rec_group->completed) { + return false; + } else { + if (rec_group->n_read == rec_group->n_total) + rec_group->n_read = rec_group->n_total = 0; + + /** fetch the record from the id-th MQ */ + int i = rec_group->n_read; + if (!load_group_record(id, i, &rec_group->completed, nowait)) return false; + + rec_group->n_total++; + m_min_records[id] = rec_group->records[rec_group->n_read++]; + + /** load a batch of records into the id-th record group */ + load_group_records(id); + return true; + } +} + +/** + * store the message from table->record as mq_record_struct + * + * @data: the message data + * @msg_len: the message length + */ +bool Exchange_sort::store_mq_record(mq_record_st *rec, uchar *data, + uint32 msg_len) { + assert(rec && data); + THD *thd = get_thd(); + /** + * Making a deep copy from data to rec. First, we determine whether rec has + * enough space to copy data. If there is not enough space, then alloc space + * for rec. + */ + if (msg_len > rec->m_buffer_len || + DBUG_EVALUATE_IF("pq_msort_error5", true, false)) { + if (rec->m_data) destroy(rec->m_data); + + uint32 new_buffer_len = rec->m_buffer_len; + while (msg_len > new_buffer_len) new_buffer_len *= 2; + rec->m_data = new (thd->pq_mem_root) uchar[new_buffer_len]; + if (!rec->m_data || DBUG_EVALUATE_IF("pq_msort_error5", true, false)) + goto err; + rec->m_buffer_len = new_buffer_len; + } + + assert(rec->m_data); + memcpy(rec->m_data, data, msg_len); + rec->m_length = msg_len; + return true; + +err: + my_error(ER_STD_BAD_ALLOC_ERROR, MYF(0), "", "(MSort::store_mq_record)"); + return false; +} + +/** + * read one message from MQ[id] and then copy it to + * m_record_groups[id].records[i] + * + * @id: the ID of worker + * @i: the i-th cached record in m_record_groups[id] + * @completed: indicates whether MQ[i] has been read completed + * @nowait: the mode of read message from MQ + */ +bool Exchange_sort::load_group_record(int id, int i, bool *completed, + bool nowait) { + assert(0 <= id && id < lanuch_workers()); + assert(0 <= i && i < MAX_RECORD_STORE); + + MQueue_handle *handle = get_mq_handle(id); + uchar *data = nullptr; + uint32 msg_len = 0; + + if (completed) *completed = false; + /** receive one message from MQ */ + MQ_RESULT result = handle->receive((void **)&data, &msg_len, nowait); + mq_records_batch_st *rec_group = &m_record_groups[id]; + if (result == MQ_DETACHED) { + rec_group->completed = true; + return false; + } + if (result == MQ_WOULD_BLOCK) { + return false; + } + + assert(result == MQ_SUCCESS); + /** copy data into m_record_groups[id].records[i] */ + if (store_mq_record(rec_group->records[i], data, msg_len)) return true; + + return false; +} + +/** + * read the minimum record among all workers and fill it into table->record[0] + * + * @retval: true for success, and otherwise false + */ +bool Exchange_sort::read_mq_record() { + assert(get_exchange_type() == EXCHANGE_SORT); + mq_record_st *record = get_min_record(); + if (!record) return false; + return convert_mq_data_to_record(record->m_data, record->m_length); +} + +/** cleanup allocated space */ +void Exchange_sort::cleanup() { + Exchange::cleanup(); + if (m_heap) m_heap->cleanup(); + if (m_sort_param) destroy(m_sort_param); +} diff --git a/sql/exchange_sort.h b/sql/exchange_sort.h new file mode 100644 index 000000000..704709183 --- /dev/null +++ b/sql/exchange_sort.h @@ -0,0 +1,159 @@ +#ifndef EXCHANGE_SORT_H +#define EXCHANGE_SORT_H + +/* Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include +#include "sql/binary_heap.h" +#include "sql/exchange.h" +#include "sql/filesort.h" +#include "sql/handler.h" +#include "sql/sql_class.h" +#include "sql/sql_sort.h" + +struct TABLE; +class THD; +class Filesort; + +#define MAX_RECORD_STORE 10 +#define RECORD_BUFFER_SIZE 128 + +/** wrapper of message in MQ */ +typedef struct mq_record_struct { + uchar *m_data; /** the message data in MQ */ + uint32 m_length; /** the message length */ + uint32 m_buffer_len; /** the length of buffer used to cache this message */ + mq_record_struct() + : m_data(nullptr), m_length(0), m_buffer_len(RECORD_BUFFER_SIZE) {} +} mq_record_st; + +/** batch of records cached */ +typedef struct mq_records_batch_struct { + mq_record_st **records; /** the cached message from MQ, where records[i] + is the i-th worker's cached records */ + int n_total; /** total number of records cached */ + int n_read; /** number of records have been read */ + bool completed; /** the status of worker's MQ completed = true indicates + that all messages have been read from MQ, + otherwise, completed = false */ +} mq_records_batch_st; + +class Exchange_sort : public Exchange { + public: + Sort_param *m_sort_param; /** sort param */ + uchar *row_id[2]{NULL}; /** row_id (or PK) used for stable output */ + handler *m_file; /** innodb handler */ + uchar *keys[2]{NULL}; /** compared-keys of two nodes in heap*/ + + private: + mq_record_st **m_min_records; /** array of minimum records */ + mq_records_batch_st + *m_record_groups; /** array of minimum recors of each worker's group */ + binary_heap *m_heap; /** binary heap used for merge sort */ + Filesort *m_sort; /** sort structure */ + bool m_init_heap; /** indicates whether init the heap */ + uchar *m_tmp_key; /** tmp key for comparing */ + + public: + Exchange_sort() + : Exchange(), + m_sort_param(nullptr), + m_file(nullptr), + m_min_records(nullptr), + m_record_groups(nullptr), + m_heap(nullptr), + m_sort(nullptr), + m_init_heap(false), + m_tmp_key(nullptr) {} + Exchange_sort(THD *thd, TABLE *table, Filesort *sort, handler *file, + uint32 workers, uint ref_len, bool stab_output = false) + : Exchange(thd, table, workers, ref_len, stab_output), + m_sort_param(nullptr), + m_file(file), + m_min_records(nullptr), + m_record_groups(nullptr), + m_heap(nullptr), + m_sort(sort), + m_init_heap(false), + m_tmp_key(nullptr) {} + + virtual ~Exchange_sort() {} + + public: + /** init members */ + bool init() override; + /** read message from MQ and fill it into table->record[0] */ + bool read_mq_record() override; + /** cleanup */ + void cleanup() override; + + /** get the k-th record in m_min_records */ + mq_record_st *get_record(int k) { + assert(0 <= k && k < lanuch_workers()); + mq_record_st *record = m_min_records[k]; + return record; + } + + inline handler *get_file() { return m_file; } + + inline const Filesort *get_filesort() { return m_sort; } + + inline uchar *get_row_id(int i) { + assert(0 <= i && i < 2); + return row_id[i]; + } + + inline uchar *get_key(int i) { + assert(0 <= i && i < 2); + return keys[i]; + } + + inline const uchar *get_tmp_key() { return m_tmp_key; } + + inline Sort_param *get_sort_param() { return m_sort_param; } + + EXCHANGE_TYPE get_exchange_type() override { return EXCHANGE_SORT; } + + private: + /** alloc space for sort */ + bool alloc(); + /** build the binary heap */ + void build_heap(); + /** get minimum record */ + mq_record_st *get_min_record(); + /** read one message from MQ[id] and then copy it + to m_record_groups[id].records[i] */ + bool load_group_record(int id, int i, bool *completed, bool nowait); + /** fetch the current minimum record of the id-th records group + and store it in m_min_records */ + bool read_group(int id, bool nowait); + /** try to load a batch of messages in no-blocking mode */ + void load_group_records(int id); + /** store message from table->record as a mq_record */ + bool store_mq_record(mq_record_st *rec, uchar *data, uint32 msg_len); +}; + +/** compare two nodes in heap */ +extern bool heap_compare_records(int a, int b, void *arg); +#endif // PQ_MERGE_SORT_H diff --git a/sql/field.cc b/sql/field.cc index 1226d1377..5436f682e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -1870,6 +1871,22 @@ uchar *Field::pack(uchar *to, const uchar *from, size_t max_length) const { return to + length; } +/* + * store extra info. (a.k.a. Aggr.->count) into Field + * + * @param extra the value of Aggr.->count + * @param len the length of (Aggr.->count), i.e., sizeof(longlong) + */ +type_conversion_status Field::store_extra(const uchar *extra, size_t len) { + if(len == 0 || extra == nullptr) { + return TYPE_OK; + } + assert(pack_length() >= len); + uchar *extra_ptr = ptr + pack_length() - len; + memcpy(extra_ptr,extra,len); + return TYPE_OK; +} + /** Unpack a field from row data. @@ -2750,7 +2767,9 @@ Field_new_decimal::Field_new_decimal(uint32 len_arg, bool is_nullable_arg, bin_size = my_decimal_get_binary_size(precision, dec); } -Field *Field_new_decimal::create_from_item(const Item *item) { +Field *Field_new_decimal::create_from_item(const Item *item, MEM_ROOT *root) { + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; + uint8 dec = item->decimals; uint8 intg = item->decimal_precision() - dec; uint32 len = item->max_char_length(); @@ -2786,7 +2805,7 @@ Field *Field_new_decimal::create_from_item(const Item *item) { /* Corrected value fits. */ len = required_length; } - return new (*THR_MALLOC) + return new (pq_check_root) Field_new_decimal(len, item->is_nullable(), item->item_name.ptr(), dec, item->unsigned_flag); } diff --git a/sql/field.h b/sql/field.h index 235ba53ef..e3fd64b63 100644 --- a/sql/field.h +++ b/sql/field.h @@ -2,6 +2,7 @@ #define FIELD_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -105,9 +106,10 @@ class Send_field; class THD; class Time_zone; class my_decimal; +class Item_sum; struct TYPELIB; struct timeval; - +struct Field_raw_data; using Mysql::Nullable; /* @@ -627,7 +629,6 @@ class Field { return (auto_flags & (GENERATED_FROM_EXPRESSION | DEFAULT_NOW)) == 0; } - protected: /// Holds the position to the field in record uchar *ptr; @@ -676,6 +677,7 @@ class Field { const char *orig_db_name{nullptr}; /// Pointer to original table name, only non-NULL for a temporary table const char *orig_table_name{nullptr}; + Item_sum *item_sum_ref{nullptr}; const char **table_name, *field_name; LEX_CSTRING comment; /* Field is part of the following keys */ @@ -732,9 +734,9 @@ class Field { // Length of field. Never write to this member directly; instead, use // set_field_length(). uint32 field_length; + uint32 extra_length{0}; virtual void set_field_length(uint32 length) { field_length = length; } - private: uint32 flags{0}; uint16 m_field_index; // field number in fields array @@ -919,6 +921,7 @@ class Field { return store(nr, false); } virtual type_conversion_status store_decimal(const my_decimal *d) = 0; + virtual type_conversion_status store_extra(const uchar *, size_t); /** Store MYSQL_TIME value with the given amount of decimal digits into a field. @@ -2095,6 +2098,7 @@ class Field_new_decimal : public Field_num { is. */ bool m_keep_precision{false}; + ulonglong *m_result_count_ptr{nullptr}; int do_save_field_metadata(uchar *first_byte) const final; public: @@ -2137,7 +2141,7 @@ class Field_new_decimal : public Field_num { bool zero_pack() const final { return false; } void sql_type(String &str) const final; uint32 max_display_length() const final { return field_length; } - uint32 pack_length() const final { return (uint32)bin_size; } + uint32 pack_length() const final { return (uint32)(bin_size + extra_length); } uint pack_length_from_metadata(uint field_metadata) const final; bool compatible_field_size(uint field_metadata, Relay_log_info *, uint16, int *order_var) const final; @@ -2147,7 +2151,7 @@ class Field_new_decimal : public Field_num { return new (mem_root) Field_new_decimal(*this); } const uchar *unpack(uchar *to, const uchar *from, uint param_data) final; - static Field *create_from_item(const Item *item); + static Field *create_from_item(const Item *item, MEM_ROOT *root = nullptr); bool send_to_protocol(Protocol *protocol) const final; void set_keep_precision(bool arg) { m_keep_precision = arg; } }; @@ -2472,7 +2476,7 @@ class Field_double final : public Field_real { bool send_to_protocol(Protocol *protocol) const final; int cmp(const uchar *, const uchar *) const final; size_t make_sort_key(uchar *buff, size_t length) const final; - uint32 pack_length() const final { return sizeof(double); } + uint32 pack_length() const final { return sizeof(double) + extra_length; } void sql_type(String &str) const final; Field_double *clone(MEM_ROOT *mem_root) const final { assert(type() == MYSQL_TYPE_DOUBLE); @@ -3517,7 +3521,6 @@ class Field_varstring : public Field_longstr { bool is_text_key_type() const final { return binary() ? false : true; } uint32 get_length_bytes() const override { return length_bytes; } - private: /* Store number of bytes used to store length (1 or 2) */ uint32 length_bytes; @@ -4614,6 +4617,7 @@ class Copy_field { void set(Field *to, Field *from, bool save); // Field to field private: + void do_copy_extra(const Field *, Field *); void (*m_do_copy)(Copy_field *, const Field *, Field *); void (*m_do_copy2)(Copy_field *, const Field *, Field *); // Used to handle null values @@ -4716,4 +4720,13 @@ const char *get_field_name_or_expression(THD *thd, const Field *field); */ bool pre_validate_value_generator_expr(Item *expression, const char *name, Value_generator_source source); + +// build field raw data from Field +extern uint32 pq_build_field_raw(Field *field, Field_raw_data *field_raw); + +extern void pq_build_mq_fields(Field *field, Field_raw_data *field_raw, + bool *null_array, int &null_num, uint32 &total_bytes); + +extern void pq_build_mq_item(Item *item, Field_raw_data *field_raw, + bool *null_array, int &null_num, uint32 &total_bytes); #endif /* FIELD_INCLUDED */ diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 72763102a..a3f24a2c1 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -56,6 +57,8 @@ #include "sql/table.h" #include "sql_string.h" #include "template_utils.h" // down_cast +#include "msg_queue.h" +#include "sql/log.h" /** Check if geometry type sub is a subtype of super. @@ -544,6 +547,19 @@ static void do_varstring(Copy_field *, const Field *from_field, /*************************************************************************** ** The different functions that fills in a Copy_field class ***************************************************************************/ +/** copy extra info between two fields */ +void Copy_field::do_copy_extra(const Field *from, Field *to) { + uint32 extra_from_len = from ? from->extra_length : 0; + uint32 extra_to_len = to ? to->extra_length : 0; + + /* strict constraints */ + if (extra_from_len == extra_to_len && extra_from_len > 0 && + from->pack_length() == to->pack_length()) { + uchar *copy_from = from->ptr + from->pack_length() - extra_from_len; + uchar *copy_to = to->ptr + to->pack_length() - extra_from_len; + memcpy(copy_to, copy_from, extra_from_len); + } +} void Copy_field::invoke_do_copy(bool reverse) { const Field *from = reverse ? m_to_field : m_from_field; @@ -551,6 +567,10 @@ void Copy_field::invoke_do_copy(bool reverse) { (*(m_do_copy))(this, from, to); + if (current_thd->parallel_exec) { + do_copy_extra(from, to); + } + if (from->is_tmp_null() && !to->is_tmp_null()) { to->set_tmp_nullable(); to->set_tmp_null(); @@ -898,3 +918,91 @@ type_conversion_status field_conv(Field *to, const Field *from) { } else return to->store(from->val_int(), from->is_flag_set(UNSIGNED_FLAG)); } + +/** + * copy field->ptr to MQ + * @field + * @field_raw: the corresponding copy structure in MQ + */ +uint32 pq_build_field_raw(Field *field, Field_raw_data *field_raw) { + // field must not be NULL value + assert(field && !field->is_null()); + + uint32 copy_bytes = 0; + auto field_type = field->type(); + /* + * For the variable-length field, we should first extract its + * effective length and then only copy these effective content. + * Corresponding, we need to use one byte to store field->length_bytes, as + follows: + * |one byte | m_var_len | field_len | + \-------m_len-------/ + */ + if (field_type == MYSQL_TYPE_VARCHAR || field_type == MYSQL_TYPE_VAR_STRING) { + Field_varstring *from = static_cast(field); + uint field_length = + (from->length_bytes == 1) ? *from->ptr : uint2korr(from->ptr); + field_raw->m_ptr = from->ptr; + field_raw->m_var_len = from->length_bytes; // m_var_len = 1 or 2 + field_raw->m_len = from->length_bytes + field_length; + + // Note that: we use one more byte to store the + // Field_varstring::length_bytes + copy_bytes += 1 + field_raw->m_len; + } + /* + * For the other fields, they are fixed-length fields whose field length + * is field->pack_length(); + */ + else { + field_raw->m_ptr = field->ptr; + field_raw->m_len = field->pack_length(); + field_raw->m_var_len = 0; + copy_bytes += field_raw->m_len; + } + + return copy_bytes; +} + +/** + * build fields' raw data sending to MQ, and fill the NULL value info of field + * to the null_array. + * @field: + * @field_raw: + * @null_array: + * @null_num: number of maybe-NULL field + * @total_bytes: number of total copied bytes + */ +void pq_build_mq_fields(Field *field, Field_raw_data *mq_fields, + bool *null_array, int &null_num, uint32 &total_bytes) { + /* + * for a clearly defined NOT NULL field, its m_null_ptr is nullptr and we + * should not mark it in null_array. For a maybe-NULL field, we first + * determine this field is NULL or not. + */ + /* (1) first, mark it as a NOT_CONST_ITEM */ + null_array[null_num++] = 0; + + /* (2) then, determine whether the field is NULL */ + null_array[null_num++] = field->is_null() ? 1 : 0; + + // If this field is a not NULL-value, then we copy it to MQ + if (!null_array[null_num - 1]) { + /* the case of NOT_CONST_ITEM & NOT_NULL_FIELD (i.e., 00)*/ + mq_fields->m_need_send = true; + total_bytes += pq_build_field_raw(field, mq_fields); + } else { + /* the case of NOT_CONST_ITEM & NULL_FIELD (i.e., 01)*/ + mq_fields->m_need_send = false; + } +} + +void pq_build_mq_item(Item *item MY_ATTRIBUTE((unused)), + Field_raw_data *mq_fields, bool *null_array, + int &null_num, + uint32 &total_bytes MY_ATTRIBUTE((unused))) { + assert(item && (item->const_item() || item->basic_const_item())); + null_array[null_num++] = 1; + null_array[null_num++] = 0; + mq_fields->m_need_send = false; +} diff --git a/sql/filesort.cc b/sql/filesort.cc index 725ee0fed..0c136c5e4 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -77,6 +78,7 @@ #include "sql/debug_sync.h" #include "sql/derror.h" #include "sql/error_handler.h" +#include "sql/exchange_sort.h" #include "sql/field.h" #include "sql/filesort_utils.h" #include "sql/handler.h" @@ -601,8 +603,7 @@ bool filesort(THD *thd, Filesort *filesort, RowIterator *source_iterator, else sort_mode.append("fixed_sort_key"); sort_mode.append(", "); - sort_mode.append(param->using_packed_addons() - ? "packed_additional_fields" + sort_mode.append(param->using_packed_addons() ? "packed_additional_fields" : param->using_addon_fields() ? "additional_fields" : "rowid"); sort_mode.append(">"); @@ -683,6 +684,7 @@ Filesort::Filesort(THD *thd, Mem_root_array
tables_arg, bool sort_positions, bool unwrap_rollup) : m_thd(thd), tables(std::move(tables_arg)), + m_order(order), keep_buffers(keep_buffers_arg), limit(limit_arg), sortorder(nullptr), @@ -691,7 +693,11 @@ Filesort::Filesort(THD *thd, Mem_root_array
tables_arg, force_stable_sort), // keep relative order of equiv. elts m_remove_duplicates(remove_duplicates), m_force_sort_positions(sort_positions), - m_sort_order_length(make_sortorder(order, unwrap_rollup)) {} + m_sort_order_length(0) { + if (order) { + m_sort_order_length = make_sortorder(order, unwrap_rollup); + } + } uint Filesort::make_sortorder(ORDER *order, bool unwrap_rollup) { uint count; @@ -2314,3 +2320,111 @@ void change_double_for_sort(double nr, uchar *to) { swap(to[3], to[4]); #endif } + +/** + * compare table->record[0] of two workers in PQ_merge_sort + * @a: the ID of first worker + * @b: the ID of second worker + * @arg: PQ_merge sort + * @return + * true if a's record is less than b's record; + * false otherwise. + */ +bool heap_compare_records(int a, int b, void *arg) { + assert(arg); + bool convert_res; + + Exchange_sort *merge_sort = static_cast(arg); + const Filesort *filesort = merge_sort->get_filesort(); + THD *thd = merge_sort->get_thd(); + assert(filesort && current_thd == thd); + + uchar *row_id_0 = merge_sort->get_row_id(0); + uchar *row_id_1 = merge_sort->get_row_id(1); + uchar *key_0 = merge_sort->get_key(0); + uchar *key_1 = merge_sort->get_key(1); + + /** using previous old table when comparing row_id (or PK) */ + handler *file = merge_sort->get_file(); + assert(file->ht->db_type == DB_TYPE_INNODB); +#if !defined(NDEBUG) + uint ref_len = merge_sort->ref_length(); + assert(ref_len == file->ref_length); +#endif + bool force_stable_sort = merge_sort->is_stable(); + + Sort_param *sort_param = merge_sort->get_sort_param(); + int key_len = 0, compare_len = 0; + + if (sort_param) { + key_len = sort_param->max_record_length() + 1; + compare_len = sort_param->max_compare_length(); + } + + /** + * the compare process contains the following three steps: + * 1. copy to table->record[0] + * 2. add row_id info. + * 3. generate sort key + */ + mq_record_st *compare_a = merge_sort->get_record(a); + convert_res = merge_sort->convert_mq_data_to_record( + compare_a->m_data, compare_a->m_length, row_id_0); + + // there is an error during execution + if (!convert_res || DBUG_EVALUATE_IF("pq_msort_error6", true, false)) { + thd->pq_error = true; + return true; + } + + /* + * using row_id to achieve stable sort, i.e., + * record1 < record2 <=> key1 < key2 or (key1 = key2 && row_id1 < row_id2) + */ + if (sort_param) { + sort_param->make_sortkey(key_0, key_len, filesort->tables); + } + + mq_record_st *compare_b = merge_sort->get_record(b); + convert_res = merge_sort->convert_mq_data_to_record( + compare_b->m_data, compare_b->m_length, row_id_1); + + // there is an error during execution + if (!convert_res || DBUG_EVALUATE_IF("pq_msort_error7", true, false)) { + thd->pq_error = true; + return true; + } + + if (sort_param) { + sort_param->make_sortkey(key_1, key_len, filesort->tables); + } + + // c1: table scan (or index scan with optimized order = nullptr) + if (!filesort->sortorder) { + assert(sort_param == nullptr && force_stable_sort); + assert(row_id_0 && row_id_1); + return file->cmp_ref(row_id_0, row_id_1) < 0; + } else { + int cmp_key_result; + // c2: with order + if (sort_param != nullptr && sort_param->using_varlen_keys()) { + cmp_varlen_keys(sort_param->local_sortorder, sort_param->use_hash, key_0, + key_1, &cmp_key_result); + if (!force_stable_sort) { + return cmp_key_result < 0; + } else { + assert(row_id_0 && row_id_1); + return (cmp_key_result < 0 || + (cmp_key_result == 0 && file->cmp_ref(row_id_0, row_id_1) < 0)); + } + } else { + int cmp = memcmp(key_0, key_1, compare_len); + if (!force_stable_sort) { + return cmp < 0; + } else { + assert(row_id_0 && row_id_1); + return (cmp < 0 || (cmp == 0 && file->cmp_ref(row_id_0, row_id_1) < 0)); + } + } + } +} diff --git a/sql/filesort.h b/sql/filesort.h index 7197ee875..6c7ce384a 100644 --- a/sql/filesort.h +++ b/sql/filesort.h @@ -1,4 +1,5 @@ /* Copyright (c) 2006, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -53,6 +54,8 @@ class Filesort { THD *m_thd; /// The tables we are sorting. Mem_root_array
tables; + /// list of expressions to order the table by + ORDER *m_order; /// If true, do not free the filesort buffers (use if you expect to sort many /// times, like in an uncacheable subquery). const bool keep_buffers; @@ -96,10 +99,10 @@ class Filesort { /// circumstances (see NewWeedoutAccessPathForTables()). void clear_addon_fields(); - private: /* Prepare ORDER BY list for sorting. */ uint make_sortorder(ORDER *order, bool unwrap_rollup); - + + private: uint m_sort_order_length; }; diff --git a/sql/handler.cc b/sql/handler.cc index 9219a8729..f7f215c86 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -2942,6 +2943,30 @@ int handler::ha_rnd_init(bool scan) { return result; } +int handler::ha_pq_init(uint &dop, uint keyno) { + DBUG_EXECUTE_IF("ha_pq_init_fail", return HA_ERR_TABLE_DEF_CHANGED;); + int result; + DBUG_ENTER("handler::ha_pq_init"); + assert(table_share->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); + assert(inited == NONE || inited == INDEX || (inited == PQ_LEADER)); + THD *cur_thd = table->in_use; + inited = (result = pq_leader_scan_init(keyno, cur_thd->pq_ctx, dop)) + ? NONE + : PQ_LEADER; + end_range = NULL; + pq_ref = false; + pq_reverse_scan = false; + DBUG_RETURN(result); +} + +int handler::ha_pq_signal_all() { + DBUG_ENTER("handler::ha_pq_signal_all"); + int result; + THD *cur_thd = table->in_use; + result = pq_leader_signal_all(cur_thd->pq_ctx); + DBUG_RETURN(result); +} + /** End use of random access. @@ -2959,9 +2984,25 @@ int handler::ha_rnd_end() { inited = NONE; end_range = nullptr; m_record_buffer = nullptr; + pq_range_type = PQ_QUICK_SELECT_NONE; return rnd_end(); } +int handler::ha_pq_end() { + DBUG_ENTER("handler::ha_pq_end"); + + if(pq_table_scan){ + inited = RND; + ha_rnd_end(); + } else { + inited = INDEX; + ha_index_end(); + } + + THD *thd = current_thd; + DBUG_RETURN(pq_leader_scan_end(thd->pq_ctx)); +} + /** Read next row via random scan. @@ -2992,6 +3033,28 @@ int handler::ha_rnd_next(uchar *buf) { return result; } +int handler::ha_pq_next(uchar *buf, void *scan_ctx) { + int result; + DBUG_EXECUTE_IF("ha_pq_next_deadlock", return HA_ERR_LOCK_DEADLOCK;); + DBUG_ENTER("handler::ha_pq_next"); + assert(table_share->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); + + // Set status for the need to update generated fields + m_update_generated_read_fields = table->has_gcol(); + + MYSQL_TABLE_IO_WAIT(PSI_TABLE_FETCH_ROW, + pq_table_scan ? MAX_KEY : active_index, result, + { result = pq_worker_scan_next(scan_ctx, buf); }) + if (!result && m_update_generated_read_fields) { + result = update_generated_read_fields( + buf, table, pq_table_scan ? MAX_KEY : active_index); + m_update_generated_read_fields = false; + } + + table->set_row_status_from_handler(result); + DBUG_RETURN(result); +} + /** Read row via random scan from position. @@ -6456,6 +6519,14 @@ int DsMrr_impl::dsmrr_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param, return retval; } + if (thd->in_sp_trigger == 0 && thd->parallel_exec && + table->file->pq_range_type != PQ_QUICK_SELECT_NONE) { + use_default_impl = true; + retval = h->handler::multi_range_read_init(seq_funcs, seq_init_param, + n_ranges, mode, buf); + return retval; + } + /* This assert will hit if we have pushed an index condition to the primary key index and then "change our mind" and use a different diff --git a/sql/handler.h b/sql/handler.h index 76e55abc9..81d900378 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3,6 +3,7 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -69,6 +70,7 @@ #include "sql/sql_plugin_ref.h" // plugin_ref #include "thr_lock.h" // thr_lock_type #include "typelib.h" +#include "pq_range.h" class Alter_info; class Create_field; @@ -4134,6 +4136,12 @@ class handler { ha_rows estimation_rows_to_insert; public: + uint pq_range_type{0}; + key_range pq_ref_key; + bool pq_ref{false}; + bool pq_table_scan{false}; + bool pq_reverse_scan{false}; + handlerton *ht; /* storage engine of this handler */ /** Pointer to current row */ uchar *ref; @@ -4206,7 +4214,7 @@ class handler { /** Length of ref (1-8 or the clustered key length) */ uint ref_length; FT_INFO *ft_handler; - enum { NONE = 0, INDEX, RND, SAMPLING } inited; + enum { NONE = 0, INDEX, RND, SAMPLING, PQ_LEADER, PQ_WORKER } inited; bool implicit_emptied; /* Can be !=0 only if HEAP */ const Item *pushed_cond; @@ -4442,8 +4450,12 @@ class handler { int ha_index_init(uint idx, bool sorted); int ha_index_end(); int ha_rnd_init(bool scan); + int ha_pq_init(uint &dop, uint keyno); int ha_rnd_end(); + int ha_pq_end(); + int ha_pq_signal_all(); int ha_rnd_next(uchar *buf); + int ha_pq_next(uchar *buf, void *scan_ctx); // See the comment on m_update_generated_read_fields. int ha_rnd_pos(uchar *buf, uchar *pos); int ha_index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, @@ -4461,7 +4473,23 @@ class handler { int ha_reset(); /* this is necessary in many places, e.g. in HANDLER command */ int ha_index_or_rnd_end() { - return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0; + switch (inited) + { + case INDEX: + return ha_index_end(); + break; + case RND: + return ha_rnd_end(); + break; + case PQ_LEADER: + return ha_pq_end(); + break; + case PQ_WORKER: + return pq_worker_scan_end(nullptr); + break; + default: + return 0; + } } /** The cached_table_flags is set at ha_open and ha_external_lock @@ -4515,6 +4543,10 @@ class handler { int ha_unload_table(const char *db_name, const char *table_name, bool error_if_not_loaded); + virtual int pq_leader_signal_all(void *scan_ctx MY_ATTRIBUTE((unused))) { + return (0); + } + /** Initializes a parallel scan. It creates a parallel_scan_ctx that has to be used across all parallel_scan methods. Also, gets the number of @@ -4535,6 +4567,17 @@ class handler { return 0; } + virtual int pq_leader_scan_init(uint keyno MY_ATTRIBUTE((unused)), + void *&scan_ctx MY_ATTRIBUTE((unused)), + uint &n_threads MY_ATTRIBUTE((unused))) { + return (0); + } + + virtual int pq_worker_scan_init(uint keyno MY_ATTRIBUTE((unused)), + void *scan_ctx MY_ATTRIBUTE((unused))) { + return (0); + } + /** This callback is called by each parallel load thread at the beginning of the parallel load for the adapter scan. @@ -4601,6 +4644,11 @@ class handler { return 0; } + virtual int pq_worker_scan_next(void *scan_ctx MY_ATTRIBUTE((unused)), + uchar* buf MY_ATTRIBUTE((unused))) { + return (0); + } + /** End of the parallel scan. @param[in] scan_ctx A scan context created by parallel_scan_init. @@ -4609,6 +4657,14 @@ class handler { return; } + virtual int pq_leader_scan_end(void *parallel_scan_ctx MY_ATTRIBUTE((unused))) { + return (0); + } + + virtual int pq_worker_scan_end(void *parallel_scan_ctx MY_ATTRIBUTE((unused))) { + return (0); + } + /** Submit a dd::Table object representing a core DD table having hardcoded data to be filled in by the DDSE. This function can be diff --git a/sql/item.cc b/sql/item.cc index cad56f47d..cd9f2d7cd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -174,7 +175,11 @@ Item::Item(THD *thd, const Item *item) derived_used(item->derived_used), m_accum_properties(item->m_accum_properties) { #ifndef NDEBUG - assert(item->contextualized); + /* + PQ will build a tmp table to store result, so the origin item of tmp item + which is created by resolvation could be uncontextualized. + */ + assert(thd->parallel_exec || item->contextualized); contextualized = true; #endif // NDEBUG @@ -1964,45 +1969,12 @@ void Item_name_const::print(const THD *thd, String *str, str->append(')'); } -/* - need a special class to adjust printing : references to aggregate functions - must not be printed as refs because the aggregate functions that are added to - the front of select list are not printed as well. -*/ -class Item_aggregate_ref : public Item_ref { - public: - Item_aggregate_ref(Name_resolution_context *context_arg, Item **item, - const char *db_name_arg, const char *table_name_arg, - const char *field_name_arg, Query_block *depended_from_arg) - : Item_ref(context_arg, item, db_name_arg, table_name_arg, - field_name_arg) { - depended_from = depended_from_arg; - } - - void print(const THD *thd, String *str, - enum_query_type query_type) const override { - if (ref) - (*ref)->print(thd, str, query_type); - else - Item_ident::print(thd, str, query_type); - } - Ref_Type ref_type() const override { return AGGREGATE_REF; } - - /** - Walker processor used by Query_block::transform_grouped_to_derived to - replace an aggregate's reference to one in the new derived table's (hidden) - select list. - - @param arg An info object of type Item::Aggregate_ref_update - @returns false - */ - bool update_aggr_refs(uchar *arg) override { - auto *info = pointer_cast(arg); - if (*ref != info->m_target) return false; - ref = info->m_owner->add_hidden_item(info->m_target); - return false; - } -}; +bool Item_aggregate_ref::update_aggr_refs(uchar *arg) { + auto *info = pointer_cast(arg); + if (*ref != info->m_target) return false; + ref = info->m_owner->add_hidden_item(info->m_target); + return false; +} /** 1. Move SUM items out from item tree and replace with reference. @@ -2948,6 +2920,16 @@ my_decimal *Item_field::val_decimal(my_decimal *decimal_value) { return field->val_decimal(decimal_value); } +const uchar *Item_field::val_extra(uint32 *len) { + assert(len != nullptr); + *len = field->extra_length; + if (*len == 0) { + return nullptr; + } + + return (field->ptr + field->pack_length() - *len); +} + bool Item_field::get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) { if ((null_value = field->is_null()) || field->get_date(ltime, fuzzydate)) { memset(ltime, 0, sizeof(*ltime)); @@ -4696,7 +4678,7 @@ static Item **find_field_in_group_list(Item *find_item, ORDER *group_list) { - resolved item - if the item was resolved */ -static Item **resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, +Item **resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, Query_block *select) { DBUG_TRACE; Item **select_ref = nullptr; @@ -5880,27 +5862,29 @@ bool Item::eq_by_collation(Item *item, bool binary_cmp, @param table Table for which the field is created */ -Field *Item::make_string_field(TABLE *table) const { +Field *Item::make_string_field(TABLE *table, MEM_ROOT *root) const { Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; + assert(collation.collation); if (data_type() == MYSQL_TYPE_JSON) field = - new (*THR_MALLOC) Field_json(max_length, m_nullable, item_name.ptr()); + new (pq_check_root) Field_json(max_length, m_nullable, item_name.ptr()); else if (data_type() == MYSQL_TYPE_GEOMETRY) { - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_geom(max_length, m_nullable, item_name.ptr(), Field::GEOM_GEOMETRY, Nullable()); } else if (max_length / collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB) - field = new (*THR_MALLOC) Field_blob( + field = new (pq_check_root) Field_blob( max_length, m_nullable, item_name.ptr(), collation.collation, true); /* Item_type_holder holds the exact type, do not change it */ else if (max_length > 0 && (type() != Item::TYPE_HOLDER || data_type() != MYSQL_TYPE_STRING)) - field = new (*THR_MALLOC) Field_varstring( + field = new (pq_check_root) Field_varstring( max_length, m_nullable, item_name.ptr(), table->s, collation.collation); else - field = new (*THR_MALLOC) Field_string( + field = new (pq_check_root) Field_string( max_length, m_nullable, item_name.ptr(), collation.collation); if (field) field->init(table); return field; @@ -5917,67 +5901,69 @@ Field *Item::make_string_field(TABLE *table) const { */ Field *Item::tmp_table_field_from_field_type(TABLE *table, - bool fixed_length) const { + bool fixed_length, + MEM_ROOT *root) const { /* The field functions defines a field to be not null if null_ptr is not 0 */ Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; switch (data_type()) { case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_NEWDECIMAL: - field = Field_new_decimal::create_from_item(this); + field = Field_new_decimal::create_from_item(this, root); break; case MYSQL_TYPE_TINY: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_tiny(max_length, m_nullable, item_name.ptr(), unsigned_flag); break; case MYSQL_TYPE_SHORT: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_short(max_length, m_nullable, item_name.ptr(), unsigned_flag); break; case MYSQL_TYPE_LONG: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_long(max_length, m_nullable, item_name.ptr(), unsigned_flag); break; case MYSQL_TYPE_LONGLONG: - field = new (*THR_MALLOC) Field_longlong(max_length, m_nullable, + field = new (pq_check_root) Field_longlong(max_length, m_nullable, item_name.ptr(), unsigned_flag); break; case MYSQL_TYPE_FLOAT: - field = new (*THR_MALLOC) Field_float( + field = new (pq_check_root) Field_float( max_length, m_nullable, item_name.ptr(), decimals, unsigned_flag); break; case MYSQL_TYPE_DOUBLE: - field = new (*THR_MALLOC) Field_double( + field = new (pq_check_root) Field_double( max_length, m_nullable, item_name.ptr(), decimals, unsigned_flag); break; case MYSQL_TYPE_INT24: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_medium(max_length, m_nullable, item_name.ptr(), unsigned_flag); break; case MYSQL_TYPE_DATE: case MYSQL_TYPE_NEWDATE: - field = new (*THR_MALLOC) Field_newdate(m_nullable, item_name.ptr()); + field = new (pq_check_root) Field_newdate(m_nullable, item_name.ptr()); break; case MYSQL_TYPE_TIME: field = - new (*THR_MALLOC) Field_timef(m_nullable, item_name.ptr(), decimals); + new (pq_check_root) Field_timef(m_nullable, item_name.ptr(), decimals); break; case MYSQL_TYPE_TIMESTAMP: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_timestampf(m_nullable, item_name.ptr(), decimals); break; case MYSQL_TYPE_DATETIME: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_datetimef(m_nullable, item_name.ptr(), decimals); break; case MYSQL_TYPE_YEAR: assert(max_length == 4); // Field_year is only for length 4. - field = new (*THR_MALLOC) Field_year(m_nullable, item_name.ptr()); + field = new (pq_check_root) Field_year(m_nullable, item_name.ptr()); break; case MYSQL_TYPE_BIT: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_bit_as_char(max_length, m_nullable, item_name.ptr()); break; case MYSQL_TYPE_INVALID: @@ -5990,7 +5976,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, case MYSQL_TYPE_STRING: case MYSQL_TYPE_NULL: if (fixed_length && max_length <= CONVERT_IF_BIGGER_TO_BLOB) { - field = new (*THR_MALLOC) Field_string( + field = new (pq_check_root) Field_string( max_length, m_nullable, item_name.ptr(), collation.collation); break; } @@ -5999,26 +5985,26 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, case MYSQL_TYPE_SET: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: - return make_string_field(table); + return make_string_field(table, root); case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_BLOB: if (this->type() == Item::TYPE_HOLDER) - field = new (*THR_MALLOC) Field_blob( + field = new (pq_check_root) Field_blob( max_length, m_nullable, item_name.ptr(), collation.collation, true); else - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_blob(max_length, m_nullable, item_name.ptr(), collation.collation, false); break; // Blob handled outside of case case MYSQL_TYPE_GEOMETRY: - field = new (*THR_MALLOC) Field_geom( + field = new (pq_check_root) Field_geom( max_length, m_nullable, item_name.ptr(), get_geometry_type(), {}); break; case MYSQL_TYPE_JSON: field = - new (*THR_MALLOC) Field_json(max_length, m_nullable, item_name.ptr()); + new (pq_check_root) Field_json(max_length, m_nullable, item_name.ptr()); } if (field) field->init(table); return field; @@ -6037,6 +6023,10 @@ void Item_field::make_field(Send_field *tmp_field) { tmp_field->org_col_name = m_orig_field_name != nullptr ? m_orig_field_name : ""; tmp_field->field = true; + if (ref) { + tmp_field->org_col_name = ref_col_name; + tmp_field->org_table_name = orig_table_name(); + } } /** @@ -6138,6 +6128,10 @@ type_conversion_status Item::save_in_field(Field *field, bool no_conversions) { type_conversion_status Item::save_in_field_inner(Field *field, bool no_conversions) { + uint32 extra_len; + const uchar *extra = val_extra(&extra_len); + field->store_extra(extra, extra_len); + // Storing of arrays should be handled by specialized subclasses. assert(!returns_array()); @@ -7427,7 +7421,8 @@ Item_ref::Item_ref(Name_resolution_context *context_arg, Item **item, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg, bool alias_of_expr_arg) : Item_ident(context_arg, db_name_arg, table_name_arg, field_name_arg), - ref(item) { + ref(item), + copy_type(WITH_CONTEXT_REF) { m_alias_of_expr = alias_of_expr_arg; /* This constructor used to create some internals references over fixed items @@ -9824,16 +9819,17 @@ uint32 Item_aggregate_type::display_length(Item *item) { created field */ -Field *Item_aggregate_type::make_field_by_type(TABLE *table, bool strict) { +Field *Item_aggregate_type::make_field_by_type(TABLE *table, bool strict, MEM_ROOT *root) { /* The field functions defines a field to be not null if null_ptr is not 0 */ Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; switch (data_type()) { case MYSQL_TYPE_ENUM: assert(m_typelib != nullptr); - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_enum(max_length, is_nullable(), item_name.ptr(), get_enum_pack_length(m_typelib->count), m_typelib, collation.collation); @@ -9841,17 +9837,17 @@ Field *Item_aggregate_type::make_field_by_type(TABLE *table, bool strict) { break; case MYSQL_TYPE_SET: assert(m_typelib != nullptr); - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_set(max_length, is_nullable(), item_name.ptr(), get_set_pack_length(m_typelib->count), m_typelib, collation.collation); if (field) field->init(table); break; case MYSQL_TYPE_NULL: - field = make_string_field(table); + field = make_string_field(table, root); break; default: - field = tmp_table_field_from_field_type(table, false); + field = tmp_table_field_from_field_type(table, false, root); break; } if (field == nullptr) return nullptr; diff --git a/sql/item.h b/sql/item.h index 62abaddc4..a54c79554 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2,6 +2,7 @@ #define ITEM_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -69,6 +70,7 @@ #include "sql/trigger_def.h" // enum_trigger_variable_type #include "sql_string.h" #include "template_utils.h" +#include "sql_class.h" class Item; class Item_field; @@ -86,6 +88,9 @@ typedef Bounds_checked_array Ref_item_array; void item_init(void); /* Init item functions */ +/** this item needs extra bytes for storing count info. */ +extern bool need_extra(Item_sum *ref_item); + /** Default condition filtering (selectivity) values used by get_filtering_effect() and friends when better estimates @@ -779,6 +784,26 @@ class Item : public Parse_tree_node { friend class udf_handler; virtual bool is_expensive_processor(uchar *) { return false; } + public: + /** + During resolve/optimize phase, a item maybe subsituted by a new one, for example + convert_constant_item()/resolve_const_item(), this point to old item for new item. + */ + Item *origin_item{nullptr}; + + /** + During create_tmp_table, const_item can be skipped when hidden_field_count <= 0; + and thus, these skipped items will not create result_field in tmp table. Here, we + should mark it when sending data to MQ. + */ + bool skip_create_tmp_table{false}; + + /** + During itemize (or new item()), some item are added to THD::m_item_list for ease of + releasing the space allocated at runtime. + */ + bool pq_alloc_item{false}; + protected: /** Sets the result value of the function an empty string, using the current @@ -1007,6 +1032,18 @@ class Item : public Parse_tree_node { */ Item(THD *thd, const Item *item); + virtual Item *pq_clone(THD *thd, Query_block *select); + + virtual bool pq_copy_from(THD *thd, Query_block *select, Item *item); + + virtual size_t pq_extra_len(bool) { return 0; } + + virtual const uchar *val_extra(uint32 *len) { + assert(len != nullptr); + *len = 0; + return nullptr; + } + /** Parse-time context-independent constructor. @@ -1098,7 +1135,7 @@ class Item : public Parse_tree_node { */ virtual void notify_removal() {} virtual void make_field(Send_field *field); - virtual Field *make_string_field(TABLE *table) const; + virtual Field *make_string_field(TABLE *table, MEM_ROOT *root = nullptr) const; virtual bool fix_fields(THD *, Item **); /** Fix after tables have been moved from one query_block level to the parent @@ -2845,7 +2882,7 @@ class Item : public Parse_tree_node { // used in row subselects to get value of elements virtual void bring_value() {} - Field *tmp_table_field_from_field_type(TABLE *table, bool fixed_length) const; + Field *tmp_table_field_from_field_type(TABLE *table, bool fixed_length, MEM_ROOT *root = nullptr) const; virtual Item_field *field_for_view_update() { return nullptr; } /** Informs an item that it is wrapped in a truth test, in case it wants to @@ -3419,6 +3456,8 @@ class Item_basic_constant : public Item { } bool basic_const_item() const override { return true; } void set_str_value(String *str) { str_value = *str; } + + bool pq_copy_from(THD *thd, Query_block *select, Item* item) override; }; /***************************************************************************** @@ -3632,6 +3671,9 @@ class Item_name_const final : public Item { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item* item) override; + protected: type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override { @@ -3696,6 +3738,8 @@ class Item_ident : public Item { the source base table. */ const char *m_orig_db_name; + + public: /** Names the original table that is the source of the field. If field is from - a non-aliased base table, the same as table_name. @@ -3706,6 +3750,8 @@ class Item_ident : public Item { - a temporary table (in optimization stage), the name of the source base tbl */ const char *m_orig_table_name; + + protected: /** Names the field in the source base table. If field is from - an expression, a NULL pointer. @@ -3762,6 +3808,7 @@ class Item_ident : public Item { cached_table should be replaced by table_ref ASAP. */ TABLE_LIST *cached_table; + uint m_tableno{0}; Query_block *depended_from; Item_ident(Name_resolution_context *context_arg, const char *db_name_arg, @@ -3906,6 +3953,8 @@ class Item_ident : public Item { bool any_privileges); bool is_strong_side_column_not_in_fd(uchar *arg) override; bool is_column_not_in_fd(uchar *arg) override; + + bool pq_copy_from(THD *thd, Query_block *select, Item* item) override; }; class Item_ident_for_show final : public Item { @@ -3969,8 +4018,9 @@ class Item_field : public Item_ident { TABLE_LIST *table_ref; /// Source field Field *field; + const char *ref_col_name{nullptr}; + bool ref{false}; - private: /// Result field Field *result_field{nullptr}; @@ -4043,6 +4093,8 @@ class Item_field : public Item_ident { bool itemize(Parse_context *pc, Item **res) override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item* item) override; enum Type type() const override { return FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const override; double val_real() override; @@ -4052,6 +4104,7 @@ class Item_field : public Item_ident { longlong val_time_temporal_at_utc() override; longlong val_date_temporal_at_utc() override; my_decimal *val_decimal(my_decimal *) override; + const uchar *val_extra(uint32 *len) override; String *val_str(String *) override; bool val_json(Json_wrapper *result) override; bool send(Protocol *protocol, String *str_arg) override; @@ -4214,6 +4267,11 @@ class Item_field : public Item_ident { bool replace_field_processor(uchar *arg) override; bool strip_db_table_name_processor(uchar *) override; + size_t pq_extra_len(bool) override { + return field->item_sum_ref && need_extra(field->item_sum_ref) + ? sizeof(longlong) : 0; + } + /** Checks if the current object represents an asterisk select list item @@ -4327,6 +4385,7 @@ class Item_null : public Item_basic_constant { Item *safe_charset_converter(THD *thd, const CHARSET_INFO *tocs) override; bool check_partition_func_processor(uchar *) override { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /// Dynamic parameters used as placeholders ('?') inside prepared statements @@ -4704,6 +4763,9 @@ class Item_int : public Item_num { bool no_conversions) override; public: + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item* item) override; + enum Type type() const override { return INT_ITEM; } Item_result result_type() const override { return INT_RESULT; } longlong val_int() override { @@ -4742,6 +4804,8 @@ class Item_int_0 final : public Item_int { public: Item_int_0() : Item_int(NAME_STRING("0"), 0, 1) {} explicit Item_int_0(const POS &pos) : Item_int(pos, NAME_STRING("0"), 0, 1) {} + + Item *pq_clone(THD *, Query_block *) override { return this; } }; /* @@ -4822,6 +4886,7 @@ class Item_uint : public Item_int { enum_query_type query_type) const override; Item_num *neg() override; uint decimal_precision() const override { return max_length; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /* decimal (fixed point) constant */ @@ -4869,6 +4934,7 @@ class Item_decimal : public Item_num { bool eq(const Item *, bool binary_cmp) const override; void set_decimal_value(const my_decimal *value_par); bool check_partition_func_processor(uchar *) override { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_float : public Item_num { @@ -4952,6 +5018,7 @@ class Item_float : public Item_num { void print(const THD *thd, String *str, enum_query_type query_type) const override; bool eq(const Item *, bool binary_cmp) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_pi : public Item_float { @@ -5074,6 +5141,8 @@ class Item_string : public Item_basic_constant { fixed = true; } + Item *pq_clone(THD *thd, Query_block *select) override; + /* This is used in stored procedures to avoid memory leaks and does a deep copy of its argument. @@ -5168,7 +5237,7 @@ double double_from_string_with_check(const CHARSET_INFO *cs, const char *cptr, const char *end); class Item_static_string_func : public Item_string { - const Name_string func_name; + Name_string func_name; public: Item_static_string_func(const Name_string &name_par, const char *str, @@ -5196,6 +5265,8 @@ class Item_static_string_func : public Item_string { func_arg->banned_function_name = func_name.ptr(); return true; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /* for show tables */ @@ -5300,6 +5371,7 @@ class Item_hex_string : public Item_basic_constant { bool check_partition_func_processor(uchar *) override { return false; } static LEX_CSTRING make_hex_str(const char *str, size_t str_length); uint decimal_precision() const override; + Item *pq_clone(THD *thd, Query_block *select) override; private: void hex_string_init(const char *str, uint str_length); @@ -5318,6 +5390,8 @@ class Item_bin_string final : public Item_hex_string { static LEX_CSTRING make_bin_str(const char *str, size_t str_length); + Item *pq_clone(THD *thd, Query_block *select) override; + private: void bin_string_init(const char *str, size_t str_length); }; @@ -5340,9 +5414,8 @@ class Item_bin_string final : public Item_hex_string { available. */ class Item_result_field : public Item { - protected: - Field *result_field{nullptr}; /* Save result here */ public: + Field *result_field{nullptr}; /* Save result here */ Item_result_field() = default; explicit Item_result_field(const POS &pos) : Item(pos) {} @@ -5433,15 +5506,26 @@ class Item_ref : public Item_ident { public: Item **ref; + enum PQ_copy_type { + WITH_CONTEXT = 0, + WITHOUT_CONTEXT, + WITH_CONTEXT_REF, + WITH_REF_ONLY + }; + + PQ_copy_type copy_type; + public: Item_ref(Name_resolution_context *context_arg, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg) : Item_ident(context_arg, db_name_arg, table_name_arg, field_name_arg), - ref(nullptr) {} + ref(nullptr), + copy_type(WITH_CONTEXT) {} Item_ref(const POS &pos, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg) : Item_ident(pos, db_name_arg, table_name_arg, field_name_arg), - ref(nullptr) {} + ref(nullptr), + copy_type(WITHOUT_CONTEXT) {} /* This constructor is used in two scenarios: @@ -5467,7 +5551,8 @@ class Item_ref : public Item_ident { Item_ref(THD *thd, Item_ref *item) : Item_ident(thd, item), result_field(item->result_field), - ref(item->ref) {} + ref(item->ref), + copy_type(WITH_REF_ONLY) {} enum Type type() const override { return REF_ITEM; } bool eq(const Item *item, bool binary_cmp) const override { const Item *it = const_cast(item)->real_item(); @@ -5617,6 +5702,8 @@ class Item_ref : public Item_ident { return (*ref)->check_column_in_group_by(arg); } bool collect_item_field_or_ref_processor(uchar *arg) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -5658,6 +5745,8 @@ class Item_view_ref final : public Item_ref { bool fix_fields(THD *, Item **) override; + Item *pq_clone(THD *thd, Query_block *select) override; + /** Takes into account whether an Item in a derived table / view is part of an inner table of an outer join. @@ -5866,6 +5955,8 @@ class Item_int_with_ref : public Item_int { } Item *clone_item() const override; Item *real_item() override { return ref; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /* @@ -5915,6 +6006,8 @@ class Item_datetime_with_ref final : public Item_temporal_with_ref { assert(0); return val_int(); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /* @@ -5940,6 +6033,8 @@ class Item_time_with_ref final : public Item_temporal_with_ref { assert(0); return val_int(); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -6125,6 +6220,7 @@ class Item_default_value final : public Item_field { } Item *transform(Item_transformer transformer, uchar *args) override; + Item *pq_clone(THD *thd, Query_block *select) override; private: /// The argument for this function @@ -6320,8 +6416,9 @@ class Item_trigger_field final : public Item_field, }; class Item_cache : public Item_basic_constant { - protected: + public: Item *example{nullptr}; + protected: table_map used_table_map{0}; /** Field that this object will get value from. This is used by @@ -6449,6 +6546,9 @@ class Item_cache : public Item_basic_constant { if (!example) return INT_RESULT; return Field::result_merge_type(example->data_type()); } + + Item *get_example() { return example;} + bool pq_copy_from(THD *thd, Query_block *select, Item* item) override; }; class Item_cache_int final : public Item_cache { @@ -6477,6 +6577,7 @@ class Item_cache_int final : public Item_cache { bool get_time(MYSQL_TIME *ltime) override { return get_time_from_int(ltime); } Item_result result_type() const override { return INT_RESULT; } bool cache_value() override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_cache_real final : public Item_cache { @@ -6498,6 +6599,8 @@ class Item_cache_real final : public Item_cache { Item_result result_type() const override { return REAL_RESULT; } bool cache_value() override; void store_value(Item *expr, double value); + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_cache_decimal final : public Item_cache { @@ -6520,6 +6623,8 @@ class Item_cache_decimal final : public Item_cache { Item_result result_type() const override { return DECIMAL_RESULT; } bool cache_value() override; void store_value(Item *expr, my_decimal *d); + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_cache_str final : public Item_cache { @@ -6554,6 +6659,8 @@ class Item_cache_str final : public Item_cache { const CHARSET_INFO *charset() const { return value->charset(); } bool cache_value() override; void store_value(Item *expr, String &s); + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_cache_row final : public Item_cache { @@ -6610,6 +6717,8 @@ class Item_cache_row final : public Item_cache { void bring_value() override; void cleanup() override { Item_cache::cleanup(); } bool cache_value() override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_cache_datetime : public Item_cache { @@ -6649,6 +6758,8 @@ class Item_cache_datetime : public Item_cache { Item_cache::clear(); str_value_cached = false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /// An item cache for values of type JSON. @@ -6706,7 +6817,7 @@ class Item_aggregate_type : public Item { Item_result result_type() const override; bool join_types(THD *, Item *); - Field *make_field_by_type(TABLE *table, bool strict); + Field *make_field_by_type(TABLE *table, bool strict, MEM_ROOT *root = nullptr); static uint32 display_length(Item *item); Field::geometry_type get_geometry_type() const override { return geometry_type; @@ -6852,4 +6963,42 @@ inline Item *GetNthVisibleField(const mem_root_deque &fields, return nullptr; } +/* + need a special class to adjust printing : references to aggregate functions + must not be printed as refs because the aggregate functions that are added to + the front of select list are not printed as well. +*/ +class Item_aggregate_ref : public Item_ref { + public: + Item_aggregate_ref(Name_resolution_context *context_arg, Item **item, + const char *db_name_arg, const char *table_name_arg, const char *field_name_arg, + Query_block *depended_from_arg) + : Item_ref(context_arg, item, db_name_arg, table_name_arg, field_name_arg) { + depended_from = depended_from_arg; + } + + void print(const THD *thd, String *str, + enum_query_type query_type) const override { + if (ref != nullptr && (*ref) != nullptr) { + (*ref)->print(thd, str, query_type); + } else { + Item_ident::print(thd, str, query_type); + } + } + + Ref_Type ref_type() const override { return AGGREGATE_REF; } + + /** + Walker processor used by Query_block::transform_grouped_to_derived to replace + an aggregate's reference to one in the new derived table's (hidden) select + list. + + @param arg An info object of type Item::Aggregate_ref_update + @returns false + */ + bool update_aggr_refs(uchar *arg) override; + + Item *pq_clone(class THD *thd, class Query_block *select) override; +}; + #endif /* ITEM_INCLUDED */ diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 443940f64..a37212938 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -6884,6 +6885,7 @@ bool Item_equal::fix_fields(THD *thd, Item **) { not_null_tables_cache = used_tables_cache = 0; bool nullable = false; while ((item = li++)) { + if (!item->fixed && item->fix_fields(thd, &item)) return true; used_tables_cache |= item->used_tables(); not_null_tables_cache |= item->not_null_tables(); nullable |= item->is_nullable(); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index b77a6570c..4044ce367 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -2,6 +2,7 @@ #define ITEM_CMPFUNC_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -370,6 +371,7 @@ class Item_func_true : public Item_func_bool_const { str->append("true"); } enum Functype functype() const override { return TRUE_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /// A predicate that is "always false". @@ -384,6 +386,7 @@ class Item_func_false : public Item_func_bool_const { void print(const THD *, String *str, enum_query_type) const override { str->append("false"); } + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -448,6 +451,8 @@ class Item_func_truth final : public Item_bool_func { } } + Item *pq_clone(THD *thd, Query_block *select) override; + protected: Bool_test truth_test; ///< The value we're testing for. }; @@ -717,6 +722,8 @@ class Item_func_xor final : public Item_bool_func2 { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_not : public Item_bool_func { @@ -735,6 +742,8 @@ class Item_func_not : public Item_bool_func { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -892,6 +901,7 @@ class Item_func_trig_cond final : public Item_bool_func { plan_idx idx() const { return m_idx; } bool contains_only_equi_join_condition() const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_not_all : public Item_func_not { @@ -1046,6 +1056,8 @@ class Item_func_eq : public Item_func_comparison { /// we save a list of all of the fields that were considered equal. void ensure_multi_equality_fields_are_available(table_map left_side_tables, table_map right_side_tables); + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1078,6 +1090,8 @@ class Item_func_equal final : public Item_func_comparison { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1098,6 +1112,8 @@ class Item_func_ge final : public Item_func_comparison { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1118,6 +1134,8 @@ class Item_func_gt final : public Item_func_comparison { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1138,6 +1156,8 @@ class Item_func_le final : public Item_func_comparison { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1180,6 +1200,8 @@ class Item_func_lt final : public Item_func_comparison { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1200,6 +1222,8 @@ class Item_func_ne final : public Item_func_comparison { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /* @@ -1236,6 +1260,7 @@ class Item_func_opt_neg : public Item_int_func { } bool eq(const Item *item, bool binary_cmp) const override; bool subst_argument_checker(uchar **) override { return true; } + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_between final : public Item_func_opt_neg { @@ -1288,6 +1313,8 @@ class Item_func_between final : public Item_func_opt_neg { args[0]->not_null_tables() | (args[1]->not_null_tables() & args[2]->not_null_tables()); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_strcmp final : public Item_bool_func2 { @@ -1308,6 +1335,8 @@ class Item_func_strcmp final : public Item_bool_func2 { fix_char_length(2); // returns "1" or "0" or "-1" return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; struct interval_range { @@ -1332,15 +1361,27 @@ class Item_func_interval final : public Item_int_func { allowed_arg_cols = 0; // Fetch this value from first argument } + Item_func_interval(const POS &pos, Item_row *tmprow) + : super(pos, tmprow), + row(tmprow), + use_decimal_comparison(false), + intervals(0) { + allowed_arg_cols = 0; + } + bool itemize(Parse_context *pc, Item **res) override; longlong val_int() override; bool resolve_type(THD *) override; + enum Functype functype() const override { return INTERVAL_FUNC; } const char *func_name() const override { return "interval"; } uint decimal_precision() const override { return 2; } void print(const THD *thd, String *str, enum_query_type query_type) const override; void update_used_tables() override; + Item* pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; + private: // Runs in CTOR init list, cannot access *this as Item_func_interval static Item_row *alloc_row(const POS &pos, MEM_ROOT *mem_root, Item *expr1, @@ -1387,6 +1428,7 @@ class Item_func_coalesce : public Item_func_numhybrid { enum Item_result result_type() const override { return hybrid_type; } const char *func_name() const override { return "coalesce"; } enum Functype functype() const override { return COALESCE_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_ifnull final : public Item_func_coalesce { @@ -1406,6 +1448,7 @@ class Item_func_ifnull final : public Item_func_coalesce { const char *func_name() const override { return "ifnull"; } Field *tmp_table_field(TABLE *table) override; uint decimal_precision() const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1420,6 +1463,7 @@ class Item_func_any_value final : public Item_func_coalesce { const char *func_name() const override { return "any_value"; } bool aggregate_check_group(uchar *arg) override; bool aggregate_check_distinct(uchar *arg) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_if final : public Item_func { @@ -1462,6 +1506,8 @@ class Item_func_if final : public Item_func { not_null_tables_cache = (args[1]->not_null_tables() & args[2]->not_null_tables()); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_nullif final : public Item_bool_func2 { @@ -1500,6 +1546,8 @@ class Item_func_nullif final : public Item_bool_func2 { inherit from Item_func instead of Item_bool_func2 */ bool is_bool_func() const override { return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /* Functions to handle the optimized IN */ @@ -1554,6 +1602,8 @@ class in_vector { virtual bool is_row_result() const { return false; } + virtual in_vector* pq_clone(THD *thd MY_ATTRIBUTE((unused))) { return nullptr; } + /** Fill the vector by evaluating the items passed as arguments. Note that null values are skipped so the vector may end up containing @@ -1627,6 +1677,7 @@ class in_longlong : public in_vector { } bool find_item(Item *item) override; bool compare_elems(uint pos1, uint pos2) const override; + void resize_and_sort_ll() {resize_and_sort();} private: void set(uint pos, Item *item) override { val_item(item, &base[pos]); } @@ -1971,6 +2022,8 @@ class Item_func_case final : public Item_func { return cmp_collation.collation; } enum Functype functype() const override { return CASE_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; /** @@ -2068,6 +2121,8 @@ class Item_func_in final : public Item_func_opt_neg { not_null_tables_cache |= args[0]->not_null_tables(); } + Item *pq_clone(THD *thd, Query_block *select) override; + private: /** Usable if @ is made only of constants. Returns true if one @@ -2192,6 +2247,8 @@ class Item_func_isnull : public Item_bool_func { return args[0]->collation.collation; } bool fix_fields(THD *thd, Item **ref) override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; /* Functions used by HAVING for rewriting IN subquery */ @@ -2254,6 +2311,7 @@ class Item_func_isnotnull final : public Item_bool_func { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_like final : public Item_bool_func2 { @@ -2315,6 +2373,7 @@ class Item_func_like final : public Item_bool_func2 { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + Item *pq_clone(THD *thd, Query_block *select) override; private: /** @@ -2393,6 +2452,7 @@ class Item_cond : public Item_bool_func { /// Treat UNKNOWN result like FALSE because callers see no difference bool ignore_unknown() const { return abort_on_null; } bool equality_substitution_analyzer(uchar **) override { return true; } + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; /* @@ -2487,6 +2547,7 @@ class Item_equal final : public Item_bool_func { Item_equal(Item *c, Item_field *f); Item_equal(Item_equal *item_equal); + inline List get_fields() {return fields;} inline Item *get_const() { return const_item; } void set_const(Item *c) { const_item = c; } bool compare_const(THD *thd, Item *c); @@ -2555,6 +2616,8 @@ class Item_equal final : public Item_bool_func { const MY_BITMAP *fields_to_ignore, double rows_in_table) override; Item *m_const_folding[2]; ///< temporary area used for constant folding + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; private: void check_covering_prefix_keys(); @@ -2609,6 +2672,8 @@ class Item_cond_and final : public Item_cond { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; bool contains_only_equi_join_condition() const override; }; @@ -2638,6 +2703,7 @@ class Item_cond_or final : public Item_cond { table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /// Builds condition: (a AND b) IS TRUE diff --git a/sql/item_func.cc b/sql/item_func.cc index 77e847f66..936a55ea1 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -6555,10 +6556,13 @@ static int get_var_with_binlog(THD *thd, enum_sql_command sql_command, Binlog_user_var_event *user_var_event; user_var_entry *var_entry; + /* obtain user variables from leader thread */ + THD *entry_thd = thd->is_worker() ? thd->pq_leader : thd; + /* Protects thd->user_vars. */ - mysql_mutex_lock(&thd->LOCK_thd_data); - var_entry = get_variable(thd, name, nullptr); - mysql_mutex_unlock(&thd->LOCK_thd_data); + mysql_mutex_lock(&entry_thd->LOCK_thd_data); + var_entry = get_variable(entry_thd, name, nullptr); + mysql_mutex_unlock(&entry_thd->LOCK_thd_data); *out_entry = var_entry; @@ -6845,6 +6849,29 @@ bool Item_func_get_user_var::set_value(THD *thd, sp_rcontext * /*ctx*/, suv->update()); } +bool Item_func_get_user_var::pq_copy_from(THD *thd, Query_block *select, + Item *item) { + if (Item_var_func::pq_copy_from(thd, select, item)) { + return true; + } + Item_func_get_user_var *orig_item = + dynamic_cast(item); + assert(orig_item); + + // obtain var_entry from leader +#ifndef NDEBUG + THD *entry_thd = thd->pq_leader; + assert(entry_thd); + mysql_mutex_lock(&entry_thd->LOCK_thd_data); + var_entry = get_variable(entry_thd, name, nullptr); + mysql_mutex_unlock(&entry_thd->LOCK_thd_data); +#endif + if (orig_item != nullptr) { + m_cached_result_type = orig_item->m_cached_result_type; + } + return false; +} + bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) { assert(fixed == 0); diff --git a/sql/item_func.h b/sql/item_func.h index 3dbb10a8f..ed3296059 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -2,6 +2,7 @@ #define ITEM_FUNC_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -285,7 +286,9 @@ class Item_func : public Item_result_field { JSON_UNQUOTE_FUNC, MEMBER_OF_FUNC, STRCMP_FUNC, - TRUE_FUNC + TRUE_FUNC, + JSON_FUNC, + XML_FUNC }; enum optimize_type { OPTIMIZE_NONE, @@ -698,6 +701,7 @@ class Item_func : public Item_result_field { bool check_column_in_group_by(uchar *arg) override; longlong val_int_from_real(); + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_real_func : public Item_func { @@ -972,6 +976,9 @@ class Item_func_connection_id final : public Item_int_func { return ((func_arg->source == VGS_GENERATED_COLUMN) || (func_arg->source == VGS_CHECK_CONSTRAINT)); } + + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_typecast_signed final : public Item_int_func { @@ -985,6 +992,7 @@ class Item_typecast_signed final : public Item_int_func { void print(const THD *thd, String *str, enum_query_type query_type) const override; enum Functype functype() const override { return TYPECAST_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_typecast_unsigned final : public Item_int_func { @@ -998,14 +1006,16 @@ class Item_typecast_unsigned final : public Item_int_func { void print(const THD *thd, String *str, enum_query_type query_type) const override; enum Functype functype() const override { return TYPECAST_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_typecast_decimal final : public Item_func { public: Item_typecast_decimal(const POS &pos, Item *a, int len, int dec) - : Item_func(pos, a) { + : Item_func(pos, a), pq_precision(len) { set_data_type_decimal(len, dec); } + int pq_precision; String *val_str(String *str) override; double val_real() override; longlong val_int() override; @@ -1026,6 +1036,7 @@ class Item_typecast_decimal final : public Item_func { enum Functype functype() const override { return TYPECAST_FUNC; } void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1055,6 +1066,7 @@ class Item_typecast_real final : public Item_func { enum Functype functype() const override { return TYPECAST_FUNC; } void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_additive_op : public Item_num_op { @@ -1082,6 +1094,7 @@ class Item_func_plus final : public Item_func_additive_op { double real_op() override; my_decimal *decimal_op(my_decimal *) override; enum Functype functype() const override { return PLUS_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_minus final : public Item_func_additive_op { @@ -1099,6 +1112,7 @@ class Item_func_minus final : public Item_func_additive_op { my_decimal *decimal_op(my_decimal *) override; bool resolve_type(THD *thd) override; enum Functype functype() const override { return MINUS_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mul final : public Item_num_op { @@ -1114,6 +1128,7 @@ class Item_func_mul final : public Item_num_op { bool check_partition_func_processor(uchar *) override { return false; } bool check_function_as_value_generator(uchar *) override { return false; } enum Functype functype() const override { return MUL_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_div final : public Item_num_op { @@ -1130,6 +1145,7 @@ class Item_func_div final : public Item_num_op { bool resolve_type(THD *thd) override; void result_precision() override; enum Functype functype() const override { return DIV_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_int_div final : public Item_int_func { @@ -1148,6 +1164,7 @@ class Item_func_int_div final : public Item_int_func { bool check_partition_func_processor(uchar *) override { return false; } bool check_function_as_value_generator(uchar *) override { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mod final : public Item_num_op { @@ -1164,6 +1181,7 @@ class Item_func_mod final : public Item_num_op { bool check_partition_func_processor(uchar *) override { return false; } bool check_function_as_value_generator(uchar *) override { return false; } enum Functype functype() const override { return MOD_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_neg final : public Item_func_num1 { @@ -1183,6 +1201,7 @@ class Item_func_neg final : public Item_func_num1 { } bool check_partition_func_processor(uchar *) override { return false; } bool check_function_as_value_generator(uchar *) override { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_abs final : public Item_func_num1 { @@ -1196,6 +1215,7 @@ class Item_func_abs final : public Item_func_num1 { bool check_partition_func_processor(uchar *) override { return false; } bool check_function_as_value_generator(uchar *) override { return false; } enum Functype functype() const override { return ABS_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; // A class to handle logarithmic and trigonometric functions @@ -1215,6 +1235,7 @@ class Item_func_exp final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "exp"; } enum Functype functype() const override { return EXP_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_ln final : public Item_dec_func { @@ -1223,6 +1244,7 @@ class Item_func_ln final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "ln"; } enum Functype functype() const override { return LN_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_log final : public Item_dec_func { @@ -1232,6 +1254,7 @@ class Item_func_log final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "log"; } enum Functype functype() const override { return LOG_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_log2 final : public Item_dec_func { @@ -1239,6 +1262,7 @@ class Item_func_log2 final : public Item_dec_func { Item_func_log2(const POS &pos, Item *a) : Item_dec_func(pos, a) {} double val_real() override; const char *func_name() const override { return "log2"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_log10 final : public Item_dec_func { @@ -1247,6 +1271,7 @@ class Item_func_log10 final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "log10"; } enum Functype functype() const override { return LOG10_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_sqrt final : public Item_dec_func { @@ -1255,6 +1280,7 @@ class Item_func_sqrt final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "sqrt"; } enum Functype functype() const override { return SQRT_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_pow final : public Item_dec_func { @@ -1262,6 +1288,7 @@ class Item_func_pow final : public Item_dec_func { Item_func_pow(const POS &pos, Item *a, Item *b) : Item_dec_func(pos, a, b) {} double val_real() override; const char *func_name() const override { return "pow"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_acos final : public Item_dec_func { @@ -1270,6 +1297,7 @@ class Item_func_acos final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "acos"; } enum Functype functype() const override { return ACOS_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_asin final : public Item_dec_func { @@ -1278,6 +1306,7 @@ class Item_func_asin final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "asin"; } enum Functype functype() const override { return ASIN_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_atan final : public Item_dec_func { @@ -1287,6 +1316,7 @@ class Item_func_atan final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "atan"; } enum Functype functype() const override { return ATAN_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_cos final : public Item_dec_func { @@ -1295,6 +1325,7 @@ class Item_func_cos final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "cos"; } enum Functype functype() const override { return COS_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_sin final : public Item_dec_func { @@ -1303,6 +1334,7 @@ class Item_func_sin final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "sin"; } enum Functype functype() const override { return SIN_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_tan final : public Item_dec_func { @@ -1311,6 +1343,7 @@ class Item_func_tan final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "tan"; } enum Functype functype() const override { return TAN_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_cot final : public Item_dec_func { @@ -1319,6 +1352,7 @@ class Item_func_cot final : public Item_dec_func { double val_real() override; const char *func_name() const override { return "cot"; } enum Functype functype() const override { return COT_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_int_val : public Item_func_num1 { @@ -1339,6 +1373,7 @@ class Item_func_ceiling final : public Item_func_int_val { bool check_partition_func_processor(uchar *) override { return false; } bool check_function_as_value_generator(uchar *) override { return false; } enum Functype functype() const override { return CEILING_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_floor final : public Item_func_int_val { @@ -1352,6 +1387,7 @@ class Item_func_floor final : public Item_func_int_val { bool check_partition_func_processor(uchar *) override { return false; } bool check_function_as_value_generator(uchar *) override { return false; } enum Functype functype() const override { return FLOOR_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /* This handles round and truncate */ @@ -1375,6 +1411,7 @@ class Item_func_round final : public Item_func_num1 { enum Functype functype() const override { return truncate ? TRUNCATE_FUNC : ROUND_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_rand final : public Item_real_func { @@ -1413,6 +1450,8 @@ class Item_func_rand final : public Item_real_func { (func_arg->source == VGS_CHECK_CONSTRAINT)); } + Item *pq_clone(THD *thd, Query_block *select) override; + private: void seed_random(Item *val); }; @@ -1533,6 +1572,7 @@ class Item_func_min final : public Item_func_min_max { : Item_func_min_max(pos, opt_list, true) {} const char *func_name() const override { return "least"; } enum Functype functype() const override { return LEAST_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_max final : public Item_func_min_max { @@ -1541,6 +1581,7 @@ class Item_func_max final : public Item_func_min_max { : Item_func_min_max(pos, opt_list, false) {} const char *func_name() const override { return "greatest"; } enum Functype functype() const override { return GREATEST_FUNC; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1639,6 +1680,7 @@ class Item_func_length : public Item_int_func { max_length = 10; return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_bit_length final : public Item_func_length { @@ -1649,6 +1691,7 @@ class Item_func_bit_length final : public Item_func_length { return Item_func_length::val_int() * 8; } const char *func_name() const override { return "bit_length"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_char_length final : public Item_int_func { @@ -1663,6 +1706,9 @@ class Item_func_char_length final : public Item_int_func { max_length = 10; return Item_int_func::resolve_type(thd); } + + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_coercibility final : public Item_int_func { @@ -1677,6 +1723,8 @@ class Item_func_coercibility final : public Item_int_func { set_nullable(false); return Item_int_func::resolve_type(thd); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_locate : public Item_int_func { @@ -1695,6 +1743,8 @@ class Item_func_locate : public Item_int_func { bool resolve_type(THD *thd) override; void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_instr final : public Item_func_locate { @@ -1703,6 +1753,7 @@ class Item_func_instr final : public Item_func_locate { : Item_func_locate(pos, a, b) {} const char *func_name() const override { return "instr"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_validate_password_strength final : public Item_int_func { @@ -1731,6 +1782,7 @@ class Item_func_field final : public Item_int_func { longlong val_int() override; const char *func_name() const override { return "field"; } bool resolve_type(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_ascii final : public Item_int_func { @@ -1744,6 +1796,7 @@ class Item_func_ascii final : public Item_int_func { max_length = 3; return Item_int_func::resolve_type(thd); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_ord final : public Item_int_func { @@ -1753,6 +1806,7 @@ class Item_func_ord final : public Item_int_func { Item_func_ord(const POS &pos, Item *a) : Item_int_func(pos, a) {} longlong val_int() override; const char *func_name() const override { return "ord"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_find_in_set final : public Item_int_func { @@ -1770,6 +1824,7 @@ class Item_func_find_in_set final : public Item_int_func { const CHARSET_INFO *compare_collation() const override { return cmp_collation.collation; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */ @@ -1815,6 +1870,8 @@ class Item_func_bit : public Item_func { return get_time_from_string(ltime); } + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; + private: /** @brief Performs the operation on integers to produce a result of type @@ -1856,6 +1913,7 @@ class Item_func_bit_or final : public Item_func_bit_two_param { Item_func_bit_or(const POS &pos, Item *a, Item *b) : Item_func_bit_two_param(pos, a, b) {} const char *func_name() const override { return "|"; } + Item *pq_clone(THD *thd, Query_block *select) override; private: longlong int_op() override { return eval_int_op(std::bit_or()); } @@ -1869,6 +1927,7 @@ class Item_func_bit_and final : public Item_func_bit_two_param { Item_func_bit_and(const POS &pos, Item *a, Item *b) : Item_func_bit_two_param(pos, a, b) {} const char *func_name() const override { return "&"; } + Item *pq_clone(THD *thd, Query_block *select) override; private: longlong int_op() override { return eval_int_op(std::bit_and()); } @@ -1882,6 +1941,7 @@ class Item_func_bit_xor final : public Item_func_bit_two_param { Item_func_bit_xor(const POS &pos, Item *a, Item *b) : Item_func_bit_two_param(pos, a, b) {} const char *func_name() const override { return "^"; } + Item *pq_clone(THD *thd, Query_block *select) override; private: longlong int_op() override { return eval_int_op(std::bit_xor()); } @@ -1904,6 +1964,7 @@ class Item_func_bit_count final : public Item_int_func { max_length = MAX_BIGINT_WIDTH + 1; return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_shift : public Item_func_bit { @@ -1926,6 +1987,7 @@ class Item_func_shift_left final : public Item_func_shift { Item_func_shift_left(const POS &pos, Item *a, Item *b) : Item_func_shift(pos, a, b) {} const char *func_name() const override { return "<<"; } + Item *pq_clone(THD *thd, Query_block *select) override; private: longlong int_op() override { return eval_int_op(); } @@ -1937,6 +1999,7 @@ class Item_func_shift_right final : public Item_func_shift { Item_func_shift_right(const POS &pos, Item *a, Item *b) : Item_func_shift(pos, a, b) {} const char *func_name() const override { return ">>"; } + Item *pq_clone(THD *thd, Query_block *select) override; private: longlong int_op() override { return eval_int_op(); } @@ -1956,6 +2019,7 @@ class Item_func_bit_neg final : public Item_func_bit { enum_query_type query_type) const override { Item_func::print(thd, str, query_type); } + Item *pq_clone(THD *thd, Query_block *select) override; private: longlong int_op() override; @@ -1986,6 +2050,8 @@ class Item_func_last_insert_id final : public Item_int_func { func_arg->banned_function_name = func_name(); return true; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_benchmark final : public Item_int_func { @@ -2019,6 +2085,8 @@ class Item_func_benchmark final : public Item_int_func { func_arg->banned_function_name = func_name(); return true; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; void item_func_sleep_init(); @@ -2053,6 +2121,7 @@ class Item_func_sleep final : public Item_int_func { return Item_int_func::resolve_type(thd); } longlong val_int() override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_udf_func : public Item_func { @@ -2277,6 +2346,7 @@ class Item_func_get_lock final : public Item_int_func { return true; } uint decimal_precision() const override { return max_length; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_release_lock final : public Item_int_func { @@ -2461,6 +2531,7 @@ class Item_func_can_access_table : public Item_int_func { set_nullable(true); return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_can_access_user : public Item_int_func { @@ -2562,6 +2633,8 @@ class Item_func_is_visible_dd_object : public Item_int_func { set_nullable(true); return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_table_rows : public Item_int_func { @@ -2577,6 +2650,8 @@ class Item_func_internal_table_rows : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_avg_row_length : public Item_int_func { @@ -2592,6 +2667,8 @@ class Item_func_internal_avg_row_length : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_data_length : public Item_int_func { @@ -2607,6 +2684,8 @@ class Item_func_internal_data_length : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_max_data_length : public Item_int_func { @@ -2622,6 +2701,8 @@ class Item_func_internal_max_data_length : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_index_length : public Item_int_func { @@ -2637,6 +2718,8 @@ class Item_func_internal_index_length : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_data_free : public Item_int_func { @@ -2652,6 +2735,8 @@ class Item_func_internal_data_free : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_auto_increment : public Item_int_func { @@ -2667,6 +2752,8 @@ class Item_func_internal_auto_increment : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_checksum : public Item_int_func { @@ -2681,6 +2768,8 @@ class Item_func_internal_checksum : public Item_int_func { null_on_null = false; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_keys_disabled : public Item_int_func { @@ -3301,6 +3390,9 @@ class Item_func_get_user_var : public Item_var_func, Settable_routine_parameter *get_settable_routine_parameter() override { return this; } + + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; /* @@ -3425,6 +3517,9 @@ class Item_func_get_system_var final : public Item_var_func { void cleanup() override; bool bind(THD *thd); + + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class JOIN; @@ -3914,6 +4009,8 @@ class Item_func_found_rows final : public Item_int_func { func_arg->banned_function_name = func_name(); return true; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; void uuid_short_init(); @@ -3949,6 +4046,8 @@ class Item_func_version final : public Item_static_string_func { explicit Item_func_version(const POS &pos); bool itemize(Parse_context *pc, Item **res) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index 84267e177..178240eca 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -2,6 +2,7 @@ #define ITEM_GEOFUNC_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -690,6 +691,8 @@ class Item_func_latfromgeohash : public Item_func_latlongfromgeohash { false) {} const char *func_name() const override { return "ST_LATFROMGEOHASH"; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -703,6 +706,8 @@ class Item_func_longfromgeohash : public Item_func_latlongfromgeohash { } const char *func_name() const override { return "ST_LONGFROMGEOHASH"; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_centroid : public Item_geometry_func { @@ -1085,6 +1090,7 @@ class Item_func_st_contains final : public Item_func_spatial_relation { const char *func_name() const override { return "st_contains"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_st_crosses final : public Item_func_spatial_relation { @@ -1096,6 +1102,7 @@ class Item_func_st_crosses final : public Item_func_spatial_relation { const char *func_name() const override { return "st_crosses"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_st_disjoint final : public Item_func_spatial_relation { @@ -1107,6 +1114,7 @@ class Item_func_st_disjoint final : public Item_func_spatial_relation { const char *func_name() const override { return "st_disjoint"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_st_equals final : public Item_func_spatial_relation { @@ -1118,6 +1126,7 @@ class Item_func_st_equals final : public Item_func_spatial_relation { const char *func_name() const override { return "st_equals"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_st_intersects final : public Item_func_spatial_relation { @@ -1129,6 +1138,7 @@ class Item_func_st_intersects final : public Item_func_spatial_relation { const char *func_name() const override { return "st_intersects"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrcontains final : public Item_func_spatial_relation { @@ -1140,6 +1150,7 @@ class Item_func_mbrcontains final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrcontains"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrcoveredby final : public Item_func_spatial_relation { @@ -1151,6 +1162,7 @@ class Item_func_mbrcoveredby final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrcoveredby"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrcovers final : public Item_func_spatial_relation { @@ -1162,6 +1174,7 @@ class Item_func_mbrcovers final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrcovers"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrdisjoint final : public Item_func_spatial_relation { @@ -1173,6 +1186,7 @@ class Item_func_mbrdisjoint final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrdisjoint"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrequals final : public Item_func_spatial_relation { @@ -1184,6 +1198,7 @@ class Item_func_mbrequals final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrequals"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrintersects final : public Item_func_spatial_relation { @@ -1195,6 +1210,7 @@ class Item_func_mbrintersects final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrintersects"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbroverlaps final : public Item_func_spatial_relation { @@ -1206,6 +1222,7 @@ class Item_func_mbroverlaps final : public Item_func_spatial_relation { const char *func_name() const override { return "mbroverlaps"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrtouches final : public Item_func_spatial_relation { @@ -1217,6 +1234,7 @@ class Item_func_mbrtouches final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrtouches"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_mbrwithin final : public Item_func_spatial_relation { @@ -1228,6 +1246,7 @@ class Item_func_mbrwithin final : public Item_func_spatial_relation { const char *func_name() const override { return "mbrwithin"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_st_overlaps final : public Item_func_spatial_relation { @@ -1239,6 +1258,7 @@ class Item_func_st_overlaps final : public Item_func_spatial_relation { const char *func_name() const override { return "st_overlaps"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_st_touches final : public Item_func_spatial_relation { @@ -1250,6 +1270,7 @@ class Item_func_st_touches final : public Item_func_spatial_relation { const char *func_name() const override { return "st_touches"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_st_within final : public Item_func_spatial_relation { @@ -1261,6 +1282,7 @@ class Item_func_st_within final : public Item_func_spatial_relation { const char *func_name() const override { return "st_within"; } bool eval(const dd::Spatial_reference_system *srs, const gis::Geometry *g1, const gis::Geometry *g2, bool *result, bool *null) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1787,6 +1809,8 @@ class Item_func_st_srid_mutator : public Item_geometry_func { if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_LONGLONG)) return true; return Item_geometry_func::resolve_type(thd); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /// This class implements the one-parameter ST_SRID function which diff --git a/sql/item_inetfunc.h b/sql/item_inetfunc.h index bc559061f..5caad1d69 100644 --- a/sql/item_inetfunc.h +++ b/sql/item_inetfunc.h @@ -2,6 +2,7 @@ #define ITEM_INETFUNC_INCLUDED /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -54,6 +55,8 @@ class Item_func_inet_aton : public Item_int_func { unsigned_flag = true; return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /************************************************************************* @@ -76,6 +79,8 @@ class Item_func_inet_ntoa : public Item_str_func { set_nullable(true); return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /************************************************************************* @@ -133,6 +138,8 @@ class Item_func_inet6_aton : public Item_func_inet_str_base { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; + protected: bool calc_value(String *arg, String *buffer) override; }; @@ -160,6 +167,8 @@ class Item_func_inet6_ntoa : public Item_func_inet_str_base { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; + protected: bool calc_value(String *arg, String *buffer) override; }; diff --git a/sql/item_json_func.h b/sql/item_json_func.h index 3701eb4f7..dd772b643 100644 --- a/sql/item_json_func.h +++ b/sql/item_json_func.h @@ -2,6 +2,7 @@ #define ITEM_JSON_FUNC_INCLUDED /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -192,6 +193,7 @@ class Item_json_func : public Item_func { double val_real() override; my_decimal *val_decimal(my_decimal *decimal_value) override; + enum Functype functype() const override { return JSON_FUNC; } void cleanup() override; Item_result cast_to_int_type() const override { return INT_RESULT; } @@ -343,6 +345,8 @@ class Item_func_json_schema_valid final : public Item_bool_func { void cleanup() override; + Item *pq_clone(THD *thd, Query_block *select) override; + private: // Wrap the object in a unique_ptr so that the relevant rapidjson destructors // are called. @@ -416,6 +420,8 @@ class Item_func_json_contains final : public Item_int_func { enum_const_item_cache can_cache_json_arg(Item *arg) override { return (arg == args[0] || arg == args[1]) ? CACHE_JSON_VALUE : CACHE_NONE; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -541,6 +547,7 @@ class Item_func_json_depth final : public Item_int_func { } longlong val_int() override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -894,6 +901,7 @@ class Item_func_json_quote : public Item_str_func { } String *val_str(String *tmpspace) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** diff --git a/sql/item_pfs_func.h b/sql/item_pfs_func.h index 42b7734f8..af701cba3 100644 --- a/sql/item_pfs_func.h +++ b/sql/item_pfs_func.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -78,6 +79,8 @@ class Item_func_pfs_format_bytes final : public Item_str_func { const char *func_name() const override { return "format_bytes"; } bool resolve_type(THD *) override; String *val_str(String *str) override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; /** format_pico_time() */ @@ -93,6 +96,7 @@ class Item_func_pfs_format_pico_time final : public Item_str_func { const char *func_name() const override { return "format_pico_time"; } bool resolve_type(THD *) override; String *val_str(String *str) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; #endif /* ITEM_PFS_FUNC_INCLUDED */ diff --git a/sql/item_regexp_func.h b/sql/item_regexp_func.h index 4c84589cf..06e69af61 100644 --- a/sql/item_regexp_func.h +++ b/sql/item_regexp_func.h @@ -2,6 +2,7 @@ #define SQL_ITEM_REGEXP_FUNC_H_ /* Copyright (c) 2017, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -263,6 +264,8 @@ class Item_func_regexp_instr : public Item_func_regexp { bool get_time(MYSQL_TIME *t) override { return get_time_from_int(t); } /// @} + Item *pq_clone(THD *thd, Query_block *select) override; + protected: int pos_arg_pos() const override { return 2; } int occ_arg_pos() const override { return 3; } @@ -307,6 +310,8 @@ class Item_func_regexp_like : public Item_func_regexp { bool get_time(MYSQL_TIME *t) override { return get_time_from_int(t); } /// @} + Item *pq_clone(THD *thd, Query_block *select) override; + protected: int pos_arg_pos() const override { return -1; } int occ_arg_pos() const override { return -1; } diff --git a/sql/item_row.h b/sql/item_row.h index 6cdeed0b2..59231ebd5 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -2,6 +2,7 @@ #define ITEM_ROW_INCLUDED /* Copyright (c) 2002, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -152,6 +153,8 @@ class Item_row : public Item { bool null_inside() override { return with_null; } void bring_value() override; bool check_function_as_value_generator(uchar *) override { return false; } + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; #endif /* ITEM_ROW_INCLUDED */ diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index c1a0b07fd..f2f9a03ca 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -185,6 +186,7 @@ class Item_func_md5 final : public Item_str_ascii_func { String *val_str_ascii(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "md5"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_sha : public Item_str_ascii_func { @@ -193,6 +195,7 @@ class Item_func_sha : public Item_str_ascii_func { String *val_str_ascii(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "sha"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_sha2 : public Item_str_ascii_func { @@ -202,6 +205,7 @@ class Item_func_sha2 : public Item_str_ascii_func { String *val_str_ascii(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "sha2"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_to_base64 final : public Item_str_ascii_func { @@ -212,6 +216,7 @@ class Item_func_to_base64 final : public Item_str_ascii_func { String *val_str_ascii(String *) override; bool resolve_type(THD *) override; const char *func_name() const override { return "to_base64"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_statement_digest final : public Item_str_ascii_func { @@ -270,6 +275,7 @@ class Item_func_from_base64 final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "from_base64"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_aes_encrypt final : public Item_str_func { @@ -286,6 +292,7 @@ class Item_func_aes_encrypt final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *) override; const char *func_name() const override { return "aes_encrypt"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_aes_decrypt : public Item_str_func { @@ -301,6 +308,7 @@ class Item_func_aes_decrypt : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "aes_decrypt"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_random_bytes : public Item_str_func { @@ -317,6 +325,7 @@ class Item_func_random_bytes : public Item_str_func { String *val_str(String *a) override; const char *func_name() const override { return "random_bytes"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_concat : public Item_str_func { @@ -331,6 +340,7 @@ class Item_func_concat : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "concat"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_concat_ws : public Item_str_func { @@ -347,6 +357,7 @@ class Item_func_concat_ws : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "concat_ws"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_reverse : public Item_str_func { @@ -359,6 +370,7 @@ class Item_func_reverse : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "reverse"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_replace : public Item_str_func { @@ -372,6 +384,7 @@ class Item_func_replace : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "replace"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_insert : public Item_str_func { @@ -386,6 +399,7 @@ class Item_func_insert : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "insert"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_str_conv : public Item_str_func { @@ -397,6 +411,7 @@ class Item_str_conv : public Item_str_func { public: Item_str_conv(const POS &pos, Item *item) : Item_str_func(pos, item) {} String *val_str(String *) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_lower : public Item_str_conv { @@ -404,6 +419,7 @@ class Item_func_lower : public Item_str_conv { Item_func_lower(const POS &pos, Item *item) : Item_str_conv(pos, item) {} const char *func_name() const override { return "lower"; } bool resolve_type(THD *) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_upper : public Item_str_conv { @@ -411,6 +427,7 @@ class Item_func_upper : public Item_str_conv { Item_func_upper(const POS &pos, Item *item) : Item_str_conv(pos, item) {} const char *func_name() const override { return "upper"; } bool resolve_type(THD *) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_left : public Item_str_func { @@ -421,6 +438,7 @@ class Item_func_left : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "left"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_right : public Item_str_func { @@ -432,6 +450,7 @@ class Item_func_right : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "right"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_substr : public Item_str_func { @@ -450,6 +469,7 @@ class Item_func_substr : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "substr"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_substr_index final : public Item_str_func { @@ -461,6 +481,7 @@ class Item_func_substr_index final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *) override; const char *func_name() const override { return "substring_index"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_trim : public Item_str_func { @@ -542,18 +563,23 @@ class Item_func_trim : public Item_str_func { } void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_ltrim final : public Item_func_trim { public: Item_func_ltrim(const POS &pos, Item *a) : Item_func_trim(pos, a, TRIM_LTRIM) {} + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_rtrim final : public Item_func_trim { public: Item_func_rtrim(const POS &pos, Item *a) : Item_func_trim(pos, a, TRIM_RTRIM) {} + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_sysconst : public Item_str_func { @@ -602,6 +628,8 @@ class Item_func_database : public Item_func_sysconst { const Name_string fully_qualified_func_name() const override { return NAME_STRING("database()"); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_user : public Item_func_sysconst { @@ -649,6 +677,7 @@ class Item_func_user : public Item_func_sysconst { } String *val_str(String *) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_current_user : public Item_func_user { @@ -669,6 +698,7 @@ class Item_func_current_user : public Item_func_user { } String *val_str(String *) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_soundex : public Item_str_func { @@ -680,6 +710,7 @@ class Item_func_soundex : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "soundex"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_elt final : public Item_str_func { @@ -691,15 +722,16 @@ class Item_func_elt final : public Item_str_func { String *val_str(String *str) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "elt"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_make_set final : public Item_str_func { typedef Item_str_func super; + public: Item *item; String tmp_str; - public: Item_func_make_set(const POS &pos, Item *a, PT_item_list *opt_list) : Item_str_func(pos, opt_list), item(a) {} @@ -730,6 +762,8 @@ class Item_func_make_set final : public Item_str_func { Item *transform(Item_transformer transformer, uchar *arg) override; void print(const THD *thd, String *str, enum_query_type query_type) const override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_format final : public Item_str_ascii_func { @@ -748,6 +782,8 @@ class Item_func_format final : public Item_str_ascii_func { const char *func_name() const override { return "format"; } void print(const THD *thd, String *str, enum_query_type query_type) const override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_char final : public Item_str_func { @@ -767,6 +803,7 @@ class Item_func_char final : public Item_str_func { return false; } const char *func_name() const override { return "char"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_repeat final : public Item_str_func { @@ -778,6 +815,7 @@ class Item_func_repeat final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "repeat"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_space final : public Item_str_func { @@ -786,6 +824,7 @@ class Item_func_space final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *) override; const char *func_name() const override { return "space"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_rpad final : public Item_str_func { @@ -797,6 +836,8 @@ class Item_func_rpad final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *) override; const char *func_name() const override { return "rpad"; } + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_lpad final : public Item_str_func { @@ -808,6 +849,8 @@ class Item_func_lpad final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *) override; const char *func_name() const override { return "lpad"; } + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_uuid_to_bin final : public Item_str_func { @@ -822,6 +865,7 @@ class Item_func_uuid_to_bin final : public Item_str_func { String *val_str(String *) override; bool resolve_type(THD *) override; const char *func_name() const override { return "uuid_to_bin"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_bin_to_uuid final : public Item_str_ascii_func { @@ -836,6 +880,7 @@ class Item_func_bin_to_uuid final : public Item_str_ascii_func { String *val_str_ascii(String *) override; bool resolve_type(THD *thd) override; const char *func_name() const override { return "bin_to_uuid"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_is_uuid final : public Item_bool_func { @@ -861,6 +906,7 @@ class Item_func_conv final : public Item_str_func { const char *func_name() const override { return "conv"; } String *val_str(String *) override; bool resolve_type(THD *) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_hex : public Item_str_ascii_func { @@ -875,6 +921,7 @@ class Item_func_hex : public Item_str_ascii_func { set_data_type_string(args[0]->max_length * 2U, default_charset()); return false; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_unhex final : public Item_str_func { @@ -888,6 +935,7 @@ class Item_func_unhex final : public Item_str_func { const char *func_name() const override { return "unhex"; } String *val_str(String *) override; bool resolve_type(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; #ifndef NDEBUG @@ -945,6 +993,7 @@ class Item_typecast_char final : public Item_str_func { bool resolve_type(THD *) override; void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_load_file final : public Item_str_func { @@ -989,6 +1038,7 @@ class Item_func_export_set final : public Item_str_func { String *val_str(String *str) override; bool resolve_type(THD *) override; const char *func_name() const override { return "export_set"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_quote : public Item_str_func { @@ -999,6 +1049,7 @@ class Item_func_quote : public Item_str_func { const char *func_name() const override { return "quote"; } String *val_str(String *) override; bool resolve_type(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_conv_charset final : public Item_str_func { @@ -1050,6 +1101,7 @@ class Item_func_conv_charset final : public Item_str_func { const char *func_name() const override { return "convert"; } void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_set_collation final : public Item_str_func { @@ -1074,6 +1126,9 @@ class Item_func_set_collation final : public Item_str_func { /* this function is transparent for view updating */ return args[0]->field_for_view_update(); } + + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_charset final : public Item_str_func { @@ -1088,6 +1143,8 @@ class Item_func_charset final : public Item_str_func { set_nullable(false); return Item_str_func::resolve_type(thd); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_collation : public Item_str_func { @@ -1103,6 +1160,8 @@ class Item_func_collation : public Item_str_func { set_nullable(false); return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_weight_string final : public Item_str_func { @@ -1134,6 +1193,7 @@ class Item_func_weight_string final : public Item_str_func { bool resolve_type(THD *) override; void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_crc32 final : public Item_int_func { @@ -1150,6 +1210,7 @@ class Item_func_crc32 final : public Item_int_func { return false; } longlong val_int() override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_uncompressed_length final : public Item_int_func { @@ -1165,6 +1226,7 @@ class Item_func_uncompressed_length final : public Item_int_func { return false; } longlong val_int() override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_compress final : public Item_str_func { @@ -1179,6 +1241,7 @@ class Item_func_compress final : public Item_str_func { } const char *func_name() const override { return "compress"; } String *val_str(String *str) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_uncompress final : public Item_str_func { @@ -1194,6 +1257,7 @@ class Item_func_uncompress final : public Item_str_func { } const char *func_name() const override { return "uncompress"; } String *val_str(String *str) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_uuid final : public Item_str_func { @@ -1218,6 +1282,8 @@ class Item_func_uuid final : public Item_str_func { return ((func_arg->source == VGS_GENERATED_COLUMN) || (func_arg->source == VGS_CHECK_CONSTRAINT)); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_gtid_subtract final : public Item_str_ascii_func { @@ -1342,6 +1408,8 @@ class Item_func_get_dd_create_options final : public Item_str_func { const char *func_name() const override { return "get_dd_create_options"; } String *val_str(String *) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_get_dd_schema_options final : public Item_str_func { @@ -1389,6 +1457,7 @@ class Item_func_internal_get_comment_or_error final : public Item_str_func { } String *val_str(String *) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_get_dd_tablespace_private_data final : public Item_str_func { diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index f3d5d862e..0d965d964 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2002, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -3453,7 +3454,7 @@ bool subselect_hash_sj_engine::exec(THD *thd) { } /* Set tmp_param only if its usable, i.e. there are Copy_field's. */ - tmp_param = &(item->unit->outer_query_block()->join->tmp_table_param); + tmp_param = (item->unit->outer_query_block()->join->tmp_table_param); if (tmp_param && tmp_param->copy_fields.empty()) tmp_param = nullptr; } // if (!is_materialized) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 4882708fb..67ebbdb96 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -631,22 +632,24 @@ bool Item_sum::has_aggregate_ref_in_group_by(uchar *) { return aggr_query_block != nullptr && aggr_query_block->group_fix_field; } -Field *Item_sum::create_tmp_field(bool, TABLE *table) { +Field *Item_sum::create_tmp_field(bool, TABLE *table, MEM_ROOT *root) { DBUG_TRACE; Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; + switch (result_type()) { case REAL_RESULT: - field = new (*THR_MALLOC) Field_double( + field = new (pq_check_root) Field_double( max_length, is_nullable(), item_name.ptr(), decimals, false, true); break; case INT_RESULT: - field = new (*THR_MALLOC) Field_longlong(max_length, is_nullable(), + field = new (pq_check_root) Field_longlong(max_length, is_nullable(), item_name.ptr(), unsigned_flag); break; case STRING_RESULT: return make_string_field(table); case DECIMAL_RESULT: - field = Field_new_decimal::create_from_item(this); + field = Field_new_decimal::create_from_item(this, root); break; case ROW_RESULT: default: @@ -1732,9 +1735,11 @@ bool Item_sum_hybrid::setup_hybrid(Item *item, Item *value_arg) { return false; } -Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table) { +Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table, MEM_ROOT *root) { DBUG_TRACE; Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; + if (args[0]->type() == Item::FIELD_ITEM) { field = down_cast(args[0])->field; @@ -1753,22 +1758,22 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table) { */ switch (args[0]->data_type()) { case MYSQL_TYPE_DATE: - field = new (*THR_MALLOC) Field_newdate(is_nullable(), item_name.ptr()); + field = new (pq_check_root) Field_newdate(is_nullable(), item_name.ptr()); break; case MYSQL_TYPE_TIME: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_timef(is_nullable(), item_name.ptr(), decimals); break; case MYSQL_TYPE_TIMESTAMP: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_timestampf(is_nullable(), item_name.ptr(), decimals); break; case MYSQL_TYPE_DATETIME: - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_datetimef(is_nullable(), item_name.ptr(), decimals); break; default: - return Item_sum::create_tmp_field(group, table); + return Item_sum::create_tmp_field(group, table, root); } if (field) field->init(table); return field; @@ -2073,6 +2078,10 @@ double Aggregator_simple::arg_val_real() { return item_sum->args[0]->val_real(); } +longlong Aggregator_simple::arg_val_int() { + return item_sum->args[0]->val_int(); +} + bool Aggregator_simple::arg_is_null(bool use_null_value) { Item **item = item_sum->args; const uint item_count = item_sum->arg_count; @@ -2098,6 +2107,11 @@ double Aggregator_distinct::arg_val_real() { : item_sum->args[0]->val_real(); } +longlong Aggregator_distinct::arg_val_int() { + return use_distinct_values ? table->field[0]->val_int() + : item_sum->args[0]->val_int(); +} + bool Aggregator_distinct::arg_is_null(bool use_null_value) { if (use_distinct_values) { const bool rc = table->field[0]->is_null(); @@ -2124,7 +2138,7 @@ bool Item_sum_count::add() { if (aggr->arg_is_null(false)) { return current_thd->is_error(); } - count++; + count += is_fake ? args[0]->val_int() : 1; return current_thd->is_error(); } @@ -2169,6 +2183,27 @@ void Item_sum_count::cleanup() { bool Item_sum_avg::resolve_type(THD *thd) { if (Item_sum_sum::resolve_type(thd)) return true; + /** + * for the rewritten Item_sum_avg, we should keep the same precision as that + * of Item_sum_sum. For the case of "3.1415926", we obtain + * precision = len(31415926) = 8; + * decimals = len(1315926) = 7; + * max_length = len(3.1415926 + signed_flag) = 9; + * if scale == 2: scale(3.1415926) = 3.14 + */ + if (pq_avg_type == PQ_WORKER || pq_avg_type == PQ_LEADER) { + prec_increment = 0; + if (hybrid_type == DECIMAL_RESULT) { + f_precision = args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS; + decimals = args[0]->decimals; + max_length = my_decimal_precision_to_length_no_truncation( + f_precision, decimals, unsigned_flag); + f_scale = args[0]->decimals; + dec_bin_size = my_decimal_get_binary_size(f_precision, f_scale); + } + return false; + } + set_nullable(true); null_value = true; prec_increment = thd->variables.div_precincrement; @@ -2194,28 +2229,32 @@ bool Item_sum_avg::resolve_type(THD *thd) { Item *Item_sum_avg::copy_or_same(THD *thd) { DBUG_TRACE; - Item *result = + Item_sum_avg *result = m_is_window_function ? this : new (thd->mem_root) Item_sum_avg(thd, this); + if (!result) return result; + result->pq_avg_type = pq_avg_type; return result; } -Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table) { +Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table, MEM_ROOT *root) { DBUG_TRACE; Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; + if (group) { /* We must store both value and counter in the temporary table in one field. The easiest way is to do this is to store both value in a string and unpack on access. */ - field = new (*THR_MALLOC) Field_string( + field = new (pq_check_root) Field_string( ((hybrid_type == DECIMAL_RESULT) ? dec_bin_size : sizeof(double)) + sizeof(longlong), false, item_name.ptr(), &my_charset_bin); } else if (hybrid_type == DECIMAL_RESULT) field = Field_new_decimal::create_from_item(this); else - field = new (*THR_MALLOC) Field_double( + field = new (pq_check_root) Field_double( max_length, is_nullable(), item_name.ptr(), decimals, false, true); if (field) field->init(table); return field; @@ -2226,7 +2265,17 @@ void Item_sum_avg::clear() { Item_sum_sum::clear(); } bool Item_sum_avg::add() { assert(!m_is_window_function); if (Item_sum_sum::add()) return true; - if (!aggr->arg_is_null(true)) m_count++; + if (!aggr->arg_is_null(true)) { + if (pq_avg_type == PQ_REBUILD) { + uint32 extra_len; + auto val = args[0]->val_extra((uint32 *)&extra_len); + if (val != nullptr) { + m_count += uint8korr(val); + } + } else { + m_count++; + } + } return false; } @@ -2251,6 +2300,10 @@ double Item_sum_avg::val_real() { null_value = true; return 0.0; } + if (pq_avg_type == PQ_WORKER) { + return Item_sum_sum::val_real(); + } + return Item_sum_sum::val_real() / ulonglong2double(m_count); } } @@ -2333,6 +2386,10 @@ my_decimal *Item_sum_avg::val_decimal(my_decimal *val) { return result; } + if (pq_avg_type == PQ_WORKER) { + return (dec_buffs + curr_dec_buff); + } + sum_dec = dec_buffs + curr_dec_buff; int2my_decimal(E_DEC_FATAL_ERROR, m_count, false, &cnt); my_decimal_div(E_DEC_FATAL_ERROR, val, sum_dec, &cnt, prec_increment); @@ -2340,6 +2397,11 @@ my_decimal *Item_sum_avg::val_decimal(my_decimal *val) { } } +const uchar *Item_sum_avg::val_extra(uint32 *len) { + *len = pq_extra_len(false); + return (const uchar*)(&m_count); +} + String *Item_sum_avg::val_str(String *str) { if (aggr) aggr->endup(); if (hybrid_type == DECIMAL_RESULT) return val_string_from_decimal(str); @@ -2571,9 +2633,11 @@ Item *Item_sum_variance::copy_or_same(THD *thd) { If we're grouping, then we need some space to serialize variables into, to pass around. */ -Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table) { +Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table, MEM_ROOT *root) { DBUG_TRACE; Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; + if (group) { /* We must store both value and counter in the temporary table in one field. @@ -2581,10 +2645,10 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table) { and unpack on access. */ field = - new (*THR_MALLOC) Field_string(sizeof(double) * 2 + sizeof(longlong), + new (pq_check_root) Field_string(sizeof(double) * 2 + sizeof(longlong), false, item_name.ptr(), &my_charset_bin); } else - field = new (*THR_MALLOC) Field_double( + field = new (pq_check_root) Field_double( max_length, is_nullable(), item_name.ptr(), decimals, false, true); if (field != nullptr) field->init(table); @@ -3305,7 +3369,9 @@ void Item_sum_count::reset_field() { longlong nr = 0; assert(aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR); - if (!args[0]->is_nullable() || !args[0]->is_null()) nr = 1; + if (!args[0]->is_nullable() || !args[0]->is_null()) { + nr = is_fake ? args[0]->val_int() : 1; + } int8store(result_field->field_ptr(), nr); } @@ -3318,8 +3384,14 @@ void Item_sum_avg::reset_field() { if (args[0]->null_value) { arg_dec = &decimal_zero; tmp = 0; - } else - tmp = 1; + } else { + uint32 extra_len; + if (pq_avg_type == PQ_REBUILD && args[0]->val_extra(&extra_len) != nullptr) { + tmp = sint8korr(args[0]->val_extra(&extra_len)); + } else { + tmp = 1; + } + } my_decimal2binary(E_DEC_FATAL_ERROR, arg_dec, res, f_precision, f_scale); res += dec_bin_size; int8store(res, tmp); @@ -3329,7 +3401,13 @@ void Item_sum_avg::reset_field() { if (args[0]->null_value) memset(res, 0, sizeof(double) + sizeof(longlong)); else { - longlong tmp = 1; + longlong tmp; + uint32 extra_len; + if (pq_avg_type == PQ_REBUILD && args[0]->val_extra(&extra_len) != nullptr) { + tmp = sint8korr(args[0]->val_extra(&extra_len)); + } else { + tmp = 1; + } float8store(res, nr); res += sizeof(double); int8store(res, tmp); @@ -3405,13 +3483,15 @@ void Item_sum_count::update_field() { uchar *res = result_field->field_ptr(); nr = sint8korr(res); - if (!args[0]->is_nullable() || !args[0]->is_null()) nr++; + if (!args[0]->is_nullable() || !args[0]->is_null()) { + nr += is_fake ? args[0]->val_int() : 1; + } int8store(res, nr); } void Item_sum_avg::update_field() { DBUG_TRACE; - longlong field_count; + ulonglong field_count; uchar *res = result_field->field_ptr(); assert(aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR); @@ -3421,12 +3501,19 @@ void Item_sum_avg::update_field() { if (!args[0]->null_value) { binary2my_decimal(E_DEC_FATAL_ERROR, res, dec_buffs + 1, f_precision, f_scale); - field_count = sint8korr(res + dec_bin_size); + field_count = uint8korr(res + dec_bin_size); my_decimal_add(E_DEC_FATAL_ERROR, dec_buffs, arg_val, dec_buffs + 1); my_decimal2binary(E_DEC_FATAL_ERROR, dec_buffs, res, f_precision, f_scale); res += dec_bin_size; - field_count++; + if (pq_avg_type == PQ_REBUILD) { + uint32 extra_len; + if (args[0]->val_extra(&extra_len) != nullptr) { + field_count += uint8korr(args[0]->val_extra(&extra_len)); + } + } else { + field_count++; + } int8store(res, field_count); } } else { @@ -3439,7 +3526,14 @@ void Item_sum_avg::update_field() { old_nr += nr; float8store(res, old_nr); res += sizeof(double); - field_count++; + if (pq_avg_type == PQ_REBUILD) { + uint32 extra_len; + if (args[0]->val_extra(&extra_len) != nullptr) { + field_count += sint8korr(args[0]->val_extra(&extra_len)); + } + } else { + field_count++; + } int8store(res, field_count); } } @@ -3574,6 +3668,8 @@ Item_avg_field::Item_avg_field(Item_result res_type, Item_sum_avg *item) { field = item->get_result_field(); set_nullable(true); hybrid_type = res_type; + avg_item = item; + pq_avg_type = item->pq_avg_type; set_data_type(hybrid_type == DECIMAL_RESULT ? MYSQL_TYPE_NEWDECIMAL : MYSQL_TYPE_DOUBLE); prec_increment = item->prec_increment; @@ -3595,6 +3691,10 @@ double Item_avg_field::val_real() { res = (field->field_ptr() + sizeof(double)); count = sint8korr(res); + if (pq_avg_type == PQ_WORKER) { + return nr; + } + if ((null_value = !count)) return 0.0; return nr / (double)count; } @@ -3606,6 +3706,13 @@ my_decimal *Item_avg_field::val_decimal(my_decimal *dec_buf) { if ((null_value = !count)) return nullptr; my_decimal dec_count, dec_field; + + if (pq_avg_type == PQ_WORKER) { + binary2my_decimal(E_DEC_FATAL_ERROR, field->ptr, dec_buf, f_precision, + f_scale); + return dec_buf; + } + binary2my_decimal(E_DEC_FATAL_ERROR, field->field_ptr(), &dec_field, f_precision, f_scale); int2my_decimal(E_DEC_FATAL_ERROR, count, false, &dec_count); @@ -3614,6 +3721,11 @@ my_decimal *Item_avg_field::val_decimal(my_decimal *dec_buf) { return dec_buf; } +const uchar *Item_avg_field::val_extra(uint32 *len) { + *len = pq_extra_len(false); + return (field->ptr + field->pack_length() - *len); +} + String *Item_avg_field::val_str(String *str) { // fix_fields() never calls for this Item if (hybrid_type == DECIMAL_RESULT) return val_string_from_decimal(str); @@ -4218,8 +4330,9 @@ void Item_func_group_concat::cleanup() { row_count = 0; } -Field *Item_func_group_concat::make_string_field(TABLE *table_arg) const { +Field *Item_func_group_concat::make_string_field(TABLE *table_arg, MEM_ROOT *root) const { Field *field; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; assert(collation.collation); /* Use mbminlen to determine maximum number of characters. @@ -4233,11 +4346,11 @@ Field *Item_func_group_concat::make_string_field(TABLE *table_arg) const { const uint32 max_characters = group_concat_max_len / collation.collation->mbminlen; if (max_characters > CONVERT_IF_BIGGER_TO_BLOB) - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_blob(max_characters * collation.collation->mbmaxlen, is_nullable(), item_name.ptr(), collation.collation, true); else - field = new (*THR_MALLOC) Field_varstring( + field = new (pq_check_root) Field_varstring( max_characters * collation.collation->mbmaxlen, is_nullable(), item_name.ptr(), table_arg->s, collation.collation); @@ -6196,8 +6309,8 @@ void Item_rollup_sum_switcher::print(const THD *thd, String *str, } } -Field *Item_rollup_sum_switcher::create_tmp_field(bool group, TABLE *table) { - return master()->create_tmp_field(group, table); +Field *Item_rollup_sum_switcher::create_tmp_field(bool group, TABLE *table, MEM_ROOT *root) { + return master()->create_tmp_field(group, table, root); } void Item_rollup_sum_switcher::clear() { @@ -6483,3 +6596,8 @@ void Item_sum_collect::reset_field() { add(); store_result_field(); } + +bool need_extra(Item_sum *ref_item) +{ + return ref_item->sum_func() == Item_sum::AVG_FUNC; +} diff --git a/sql/item_sum.h b/sql/item_sum.h index 53c777038..89ddfab9b 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -2,6 +2,7 @@ #define ITEM_SUM_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -148,6 +149,8 @@ class Aggregator { virtual my_decimal *arg_val_decimal(my_decimal *value) = 0; /** Floating point value of being-aggregated argument */ virtual double arg_val_real() = 0; + /** Longlong point value of being-aggregated argument */ + virtual longlong arg_val_int() = 0; /** NULLness of being-aggregated argument. @@ -497,6 +500,7 @@ class Item_sum : public Item_func { WF allowance status afterwards. */ nesting_map save_deny_window_func; + Item_sum *orig_func {nullptr}; protected: /** @@ -606,7 +610,8 @@ class Item_sum : public Item_func { aggregator_clear(); } virtual void make_unique() { force_copy_fields = true; } - virtual Field *create_tmp_field(bool group, TABLE *table); + virtual Field *create_tmp_field(bool group, TABLE *table, + MEM_ROOT *root = nullptr); /// argument used by walk method collect_grouped_aggregates ("cga") struct Collect_grouped_aggregate_info { @@ -752,6 +757,10 @@ class Item_sum : public Item_func { */ bool wf_common_init(); + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; + virtual Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, Item *item); + virtual uint32 pq_extra_size() { return 0; } + protected: /* Raise an error (ER_NOT_SUPPORTED_YET) with the detail that this @@ -877,6 +886,7 @@ class Aggregator_distinct : public Aggregator { void endup() override; my_decimal *arg_val_decimal(my_decimal *value) override; double arg_val_real() override; + longlong arg_val_int() override; bool arg_is_null(bool use_null_value) override; bool unique_walk_function(void *element); @@ -899,6 +909,7 @@ class Aggregator_simple : public Aggregator { void endup() override {} my_decimal *arg_val_decimal(my_decimal *value) override; double arg_val_real() override; + longlong arg_val_int() override; bool arg_is_null(bool use_null_value) override; }; @@ -943,6 +954,7 @@ class Item_sum_num : public Item_sum { return get_time_from_numeric(ltime); /* Decimal or real */ } void reset_field() override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_sum_int : public Item_sum_num { @@ -979,10 +991,12 @@ class Item_sum_int : public Item_sum_num { }; class Item_sum_sum : public Item_sum_num { + public: + my_decimal dec_buffs[2]; + protected: Item_result hybrid_type; double sum; - my_decimal dec_buffs[2]; uint curr_dec_buff; bool resolve_type(THD *thd) override; /** @@ -1025,6 +1039,8 @@ class Item_sum_sum : public Item_sum_num { void update_field() override; const char *func_name() const override { return "sum"; } Item *copy_or_same(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, Item *item) override; }; class Item_sum_count : public Item_sum_int { @@ -1037,8 +1053,15 @@ class Item_sum_count : public Item_sum_int { void cleanup() override; public: - Item_sum_count(const POS &pos, Item *item_par, PT_window *w) - : Item_sum_int(pos, item_par, w), count(0) {} + /* + * mark faked item_sum_count. when we have read one more + * records from table, the faked-item_sum_sum have the same result with the original + * Item_sum_count, then is_fake = false; + */ + bool is_fake{false}; //mark Item_sum_count + + Item_sum_count(const POS &pos, Item *item_par, PT_window *w, bool fake = false) + : Item_sum_int(pos, item_par, w), count(0), is_fake(fake) {} Item_sum_count(Item_int *number) : Item_sum_int(number), count(0) {} /** Constructs an instance for COUNT(DISTINCT) @@ -1051,11 +1074,11 @@ class Item_sum_count : public Item_sum_int { */ Item_sum_count(const POS &pos, PT_item_list *list, PT_window *w) - : Item_sum_int(pos, list, w), count(0) { + : Item_sum_int(pos, list, w), count(0), is_fake(false) { set_distinct(true); } Item_sum_count(THD *thd, Item_sum_count *item) - : Item_sum_int(thd, item), count(item->count) {} + : Item_sum_int(thd, item), count(item->count), is_fake(false) {} enum Sumfunctype sum_func() const override { return has_with_distinct() ? COUNT_DISTINCT_FUNC : COUNT_FUNC; } @@ -1075,6 +1098,9 @@ class Item_sum_count : public Item_sum_int { void update_field() override; const char *func_name() const override { return "count"; } Item *copy_or_same(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, + Item *item) override; }; /* Item to get the value of a stored sum function */ @@ -1134,14 +1160,28 @@ class Item_sum_num_field : public Item_sum_hybrid_field { bool is_null() override { return update_null_value() || null_value; } }; +enum PqAvgType{ + PQ_LEADER, + PQ_WORKER, + PQ_REBUILD, + PQ_INVALID +}; + class Item_avg_field : public Item_sum_num_field { public: uint f_precision, f_scale, dec_bin_size; uint prec_increment; + Item_sum_avg *avg_item; + PqAvgType pq_avg_type; Item_avg_field(Item_result res_type, Item_sum_avg *item); enum Type type() const override { return FIELD_AVG_ITEM; } double val_real() override; my_decimal *val_decimal(my_decimal *) override; + size_t pq_extra_len(bool) override { + return ((pq_avg_type == PQ_WORKER || pq_avg_type == PQ_LEADER) + ? sizeof(longlong) : 0); + }; + const uchar *val_extra(uint32 *len) override; String *val_str(String *) override; bool resolve_type(THD *) override { return false; } const char *func_name() const override { @@ -1280,6 +1320,7 @@ class Item_sum_avg final : public Item_sum_sum { typedef Item_sum_sum super; my_decimal m_avg_dec; double m_avg; + PqAvgType pq_avg_type {PQ_INVALID}; Item_sum_avg(const POS &pos, Item *item_par, bool distinct, PT_window *w) : Item_sum_sum(pos, item_par, distinct, w) {} @@ -1305,12 +1346,21 @@ class Item_sum_avg final : public Item_sum_sum { } const char *func_name() const override { return "avg"; } Item *copy_or_same(THD *thd) override; - Field *create_tmp_field(bool group, TABLE *table) override; + Field *create_tmp_field(bool group, TABLE *table, MEM_ROOT *root) override; void cleanup() override { m_count = 0; m_frame_null_count = 0; Item_sum_sum::cleanup(); } + + Item *pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, + Query_block *select, Item *item) override; + size_t pq_extra_len(bool group) override { + return ((!group && (pq_avg_type == PQ_WORKER || pq_avg_type == PQ_LEADER)) + ? sizeof(longlong) : 0); + } + const uchar *val_extra(uint32* len) override; }; class Item_sum_variance; @@ -1439,7 +1489,8 @@ class Item_sum_variance : public Item_sum_num { return sample ? "var_samp" : "variance"; } Item *copy_or_same(THD *thd) override; - Field *create_tmp_field(bool group, TABLE *table) override; + Field *create_tmp_field(bool group, TABLE *table, + MEM_ROOT *root = nullptr) override; enum Item_result result_type() const override { return REAL_RESULT; } void cleanup() override { count = 0; @@ -1475,6 +1526,8 @@ class Item_std_field final : public Item_variance_field { */ class Item_sum_std : public Item_sum_variance { + typedef Item_sum_variance Item_supper; + public: Item_sum_std(const POS &pos, Item *item_par, uint sample_arg, PT_window *w) : Item_sum_variance(pos, item_par, sample_arg, w) {} @@ -1645,12 +1698,13 @@ class Item_sum_hybrid : public Item_sum { void cleanup() override; bool any_value() { return was_values; } void no_rows_in_result() override; - Field *create_tmp_field(bool group, TABLE *table) override; + Field *create_tmp_field(bool group, TABLE *table, MEM_ROOT *root = nullptr) override; bool uses_only_one_row() const override { return m_optimize; } bool add() override; Item *copy_or_same(THD *thd) override; bool check_wf_semantics1(THD *thd, Query_block *select, Window_evaluation_requirements *r) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; private: /* @@ -1675,6 +1729,8 @@ class Item_sum_min final : public Item_sum_hybrid { : Item_sum_hybrid(thd, item) {} enum Sumfunctype sum_func() const override { return MIN_FUNC; } const char *func_name() const override { return "min"; } + Item* pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, Item *item) override; private: Item_sum_min *clone_hybrid(THD *thd) const override; @@ -1689,6 +1745,8 @@ class Item_sum_max final : public Item_sum_hybrid { : Item_sum_hybrid(thd, item) {} enum Sumfunctype sum_func() const override { return MAX_FUNC; } const char *func_name() const override { return "max"; } + Item* pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, Item *item) override; private: Item_sum_max *clone_hybrid(THD *thd) const override; @@ -1822,6 +1880,7 @@ class Item_sum_bit : public Item_sum { bool add() override; /// @returns true iff this is BIT_AND. inline bool is_and() const { return reset_bits != 0; } + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; private: /** @@ -1866,6 +1925,8 @@ class Item_sum_or final : public Item_sum_bit { Item_sum_or(THD *thd, Item_sum_or *item) : Item_sum_bit(thd, item) {} const char *func_name() const override { return "bit_or"; } Item *copy_or_same(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, Item *item) override; }; class Item_sum_and final : public Item_sum_bit { @@ -1876,6 +1937,8 @@ class Item_sum_and final : public Item_sum_bit { Item_sum_and(THD *thd, Item_sum_and *item) : Item_sum_bit(thd, item) {} const char *func_name() const override { return "bit_and"; } Item *copy_or_same(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, Item *item) override; }; class Item_sum_xor final : public Item_sum_bit { @@ -1888,6 +1951,8 @@ class Item_sum_xor final : public Item_sum_bit { Item_sum_xor(THD *thd, Item_sum_xor *item) : Item_sum_bit(thd, item) {} const char *func_name() const override { return "bit_xor"; } Item *copy_or_same(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; + Item_sum *pq_rebuild_sum_func(THD *thd, Query_block *select, Item *item) override; }; /* @@ -2133,7 +2198,8 @@ class Item_func_group_concat final : public Item_sum { enum Sumfunctype sum_func() const override { return GROUP_CONCAT_FUNC; } const char *func_name() const override { return "group_concat"; } Item_result result_type() const override { return STRING_RESULT; } - Field *make_string_field(TABLE *table_arg) const override; + Field *make_string_field(TABLE *table_arg, + MEM_ROOT *root = nullptr) const override; void clear() override; bool add() override; void reset_field() override { assert(0); } // not used @@ -2697,7 +2763,7 @@ class Item_rollup_sum_switcher final : public Item_sum { } void print(const THD *thd, String *str, enum_query_type query_type) const override; - Field *create_tmp_field(bool group, TABLE *table) override; + Field *create_tmp_field(bool group, TABLE *table, MEM_ROOT *root = nullptr) override; enum Sumfunctype sum_func() const override { return master()->sum_func(); } enum Sumfunctype real_sum_func() const override { diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 21bf2eae1..76984ae27 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -2,6 +2,7 @@ #define ITEM_TIMEFUNC_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -69,6 +70,7 @@ class Item_func_period_add final : public Item_int_func { longlong val_int() override; const char *func_name() const override { return "period_add"; } bool resolve_type(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_period_diff final : public Item_int_func { @@ -78,6 +80,7 @@ class Item_func_period_diff final : public Item_int_func { longlong val_int() override; const char *func_name() const override { return "period_diff"; } bool resolve_type(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_to_days final : public Item_int_func { @@ -93,6 +96,7 @@ class Item_func_to_days final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_to_seconds final : public Item_int_func { @@ -118,6 +122,7 @@ class Item_func_to_seconds final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_dayofmonth final : public Item_int_func { @@ -132,6 +137,7 @@ class Item_func_dayofmonth final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -166,6 +172,7 @@ class Item_func_month final : public Item_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_monthname final : public Item_str_func { @@ -181,6 +188,7 @@ class Item_func_monthname final : public Item_str_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_dayofyear final : public Item_int_func { @@ -194,6 +202,7 @@ class Item_func_dayofyear final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_hour final : public Item_int_func { @@ -207,6 +216,7 @@ class Item_func_hour final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_time_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_minute final : public Item_int_func { @@ -220,6 +230,7 @@ class Item_func_minute final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_time_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_quarter final : public Item_int_func { @@ -233,6 +244,7 @@ class Item_func_quarter final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_second final : public Item_int_func { @@ -246,6 +258,7 @@ class Item_func_second final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_time_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_week final : public Item_int_func { @@ -261,6 +274,7 @@ class Item_func_week final : public Item_int_func { const char *func_name() const override { return "week"; } enum Functype functype() const override { return WEEK_FUNC; } bool resolve_type(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_yearweek final : public Item_int_func { @@ -274,6 +288,7 @@ class Item_func_yearweek final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_year final : public Item_int_func { @@ -289,6 +304,7 @@ class Item_func_year final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_typecast_year final : public Item_int_func { @@ -300,6 +316,7 @@ class Item_typecast_year final : public Item_int_func { const char *func_name() const override { return "cast_as_year"; } enum Functype functype() const override { return TYPECAST_FUNC; } bool resolve_type(THD *thd) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -338,6 +355,7 @@ class Item_func_weekday : public Item_func { bool check_valid_arguments_processor(uchar *) override { return !has_date_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -363,6 +381,7 @@ class Item_func_dayname final : public Item_func_weekday { enum Item_result result_type() const override { return STRING_RESULT; } bool resolve_type(THD *thd) override; bool check_partition_func_processor(uchar *) override { return true; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /* @@ -446,6 +465,8 @@ class Item_func_unix_timestamp final : public Item_timeval_func { return ((func_arg->source == VGS_GENERATED_COLUMN) || (func_arg->source == VGS_CHECK_CONSTRAINT)); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_time_to_sec final : public Item_int_func { @@ -460,6 +481,7 @@ class Item_func_time_to_sec final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_time_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -561,6 +583,7 @@ class Item_temporal_hybrid_func : public Item_str_func { } bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override; bool get_time(MYSQL_TIME *ltime) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; /* @@ -859,6 +882,7 @@ class Item_date_literal final : public Item_date_func { table_map not_null_tables() const override { return used_tables(); } void cleanup() override { assert(marker == MARKER_NONE); } bool eq(const Item *item, bool binary_cmp) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -866,6 +890,7 @@ class Item_date_literal final : public Item_date_func { */ class Item_time_literal final : public Item_time_func { MYSQL_TIME_cache cached_time; + uint pq_dec_arg; public: /** @@ -874,6 +899,7 @@ class Item_time_literal final : public Item_time_func { @param dec_arg number of fractional digits in ltime. */ Item_time_literal(MYSQL_TIME *ltime, uint dec_arg) { + pq_dec_arg = dec_arg; set_data_type_time(std::min(dec_arg, uint(DATETIME_MAX_DECIMALS))); cached_time.set_time(ltime, decimals); fixed = true; @@ -900,6 +926,7 @@ class Item_time_literal final : public Item_time_func { table_map not_null_tables() const override { return used_tables(); } void cleanup() override { assert(marker == MARKER_NONE); } bool eq(const Item *item, bool binary_cmp) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -944,6 +971,7 @@ class Item_datetime_literal final : public Item_datetime_func { table_map not_null_tables() const override { return used_tables(); } void cleanup() override { assert(marker == MARKER_NONE); } bool eq(const Item *item, bool binary_cmp) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -981,6 +1009,8 @@ class Item_func_at_time_zone final : public Item_datetime_func { const char *specifier_string() const { return m_specifier_string; } + Item *pq_clone(THD *thd, Query_block *select) override; + protected: bool check_type() const; @@ -1045,6 +1075,7 @@ class Item_func_curtime_local final : public Item_func_curtime { Item_func_curtime_local(const POS &pos, uint8 dec_arg) : Item_func_curtime(pos, dec_arg) {} const char *func_name() const override { return "curtime"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_curtime_utc final : public Item_func_curtime { @@ -1055,6 +1086,7 @@ class Item_func_curtime_utc final : public Item_func_curtime { Item_func_curtime_utc(const POS &pos, uint8 dec_arg) : Item_func_curtime(pos, dec_arg) {} const char *func_name() const override { return "utc_time"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1099,6 +1131,7 @@ class Item_func_curdate_local final : public Item_func_curdate { public: explicit Item_func_curdate_local(const POS &pos) : Item_func_curdate(pos) {} const char *func_name() const override { return "curdate"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_curdate_utc final : public Item_func_curdate { @@ -1108,6 +1141,7 @@ class Item_func_curdate_utc final : public Item_func_curdate { public: Item_func_curdate_utc(const POS &pos) : Item_func_curdate(pos) {} const char *func_name() const override { return "utc_date"; } + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -1207,6 +1241,8 @@ class Item_func_sysdate_local final : public Item_datetime_func { table_map get_initial_pseudo_tables() const override { return RAND_TABLE_BIT; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_from_days final : public Item_date_func { @@ -1222,6 +1258,8 @@ class Item_func_from_days final : public Item_date_func { if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_LONGLONG)) return true; return Item_date_func::resolve_type(thd); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_date_format final : public Item_str_func { @@ -1240,6 +1278,8 @@ class Item_func_date_format final : public Item_str_func { bool resolve_type(THD *thd) override; uint format_length(const String *format); bool eq(const Item *item, bool binary_cmp) const override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_from_unixtime final : public Item_datetime_func { @@ -1250,6 +1290,7 @@ class Item_func_from_unixtime final : public Item_datetime_func { enum Functype functype() const override { return FROM_UNIXTIME_FUNC; } bool resolve_type(THD *thd) override; bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /* @@ -1280,6 +1321,7 @@ class Item_func_convert_tz final : public Item_datetime_func { bool resolve_type(THD *) override; bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override; void cleanup() override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_sec_to_time final : public Item_time_func { @@ -1295,6 +1337,7 @@ class Item_func_sec_to_time final : public Item_time_func { } const char *func_name() const override { return "sec_to_time"; } bool get_time(MYSQL_TIME *ltime) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; extern const char *interval_names[]; @@ -1329,6 +1372,7 @@ class Item_date_add_interval final : public Item_temporal_hybrid_func { bool eq(const Item *item, bool binary_cmp) const override; void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_extract final : public Item_int_func { @@ -1381,6 +1425,9 @@ class Item_extract final : public Item_int_func { } return true; } + + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_typecast_date final : public Item_date_func { @@ -1406,6 +1453,8 @@ class Item_typecast_date final : public Item_date_func { bool is_explicit_cast() const { return m_explicit_cast; } bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override; const char *cast_type() const { return "date"; } + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_typecast_time final : public Item_time_func { @@ -1443,6 +1492,9 @@ class Item_typecast_time final : public Item_time_func { set_nullable(true); return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_typecast_datetime final : public Item_datetime_func { @@ -1481,6 +1533,8 @@ class Item_typecast_datetime final : public Item_datetime_func { return false; } bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_makedate final : public Item_date_func { @@ -1495,6 +1549,8 @@ class Item_func_makedate final : public Item_date_func { if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_LONGLONG)) return true; return Item_date_func::resolve_type(thd); } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_add_time final : public Item_temporal_hybrid_func { @@ -1522,6 +1578,7 @@ class Item_func_add_time final : public Item_temporal_hybrid_func { const char *func_name() const override { return "add_time"; } enum Functype functype() const override { return ADDTIME_FUNC; } int get_sign() const { return sign; } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_timediff final : public Item_time_func { @@ -1544,6 +1601,7 @@ class Item_func_timediff final : public Item_time_func { return false; } bool get_time(MYSQL_TIME *ltime) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_maketime final : public Item_time_func { @@ -1561,6 +1619,7 @@ class Item_func_maketime final : public Item_time_func { } const char *func_name() const override { return "maketime"; } bool get_time(MYSQL_TIME *ltime) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_microsecond final : public Item_int_func { @@ -1574,6 +1633,7 @@ class Item_func_microsecond final : public Item_int_func { bool check_valid_arguments_processor(uchar *) override { return !has_time_args(); } + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_timestamp_diff final : public Item_int_func { @@ -1594,6 +1654,7 @@ class Item_func_timestamp_diff final : public Item_int_func { } void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; enum date_time_format { @@ -1619,6 +1680,7 @@ class Item_func_get_format final : public Item_str_ascii_func { } void print(const THD *thd, String *str, enum_query_type query_type) const override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_str_to_date final : public Item_temporal_hybrid_func { @@ -1633,6 +1695,8 @@ class Item_func_str_to_date final : public Item_temporal_hybrid_func { : Item_temporal_hybrid_func(pos, a, b) {} const char *func_name() const override { return "str_to_date"; } bool resolve_type(THD *) override; + Item *pq_clone(THD *thd, Query_block *select) override; + bool pq_copy_from(THD *thd, Query_block *select, Item *item) override; }; class Item_func_last_day final : public Item_date_func { @@ -1656,6 +1720,7 @@ class Item_func_internal_update_time final : public Item_datetime_func { const char *func_name() const override { return "internal_update_time"; } bool resolve_type(THD *thd) override; bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class Item_func_internal_check_time final : public Item_datetime_func { @@ -1666,6 +1731,7 @@ class Item_func_internal_check_time final : public Item_datetime_func { const char *func_name() const override { return "internal_check_time"; } bool resolve_type(THD *thd) override; bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; /* Function prototypes */ diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h index ba0ba0e0c..5b2957d40 100644 --- a/sql/item_xmlfunc.h +++ b/sql/item_xmlfunc.h @@ -2,6 +2,7 @@ #define ITEM_XMLFUNC_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -74,6 +75,7 @@ class Item_xml_str_func : public Item_str_func { if (!nodeset_func_permanent) nodeset_func = nullptr; } bool check_function_as_value_generator(uchar *) override { return false; } + enum Functype functype() const override { return XML_FUNC; } protected: /** diff --git a/sql/join_optimizer/access_path.cc b/sql/join_optimizer/access_path.cc index 2ea9c00a6..6558a662e 100644 --- a/sql/join_optimizer/access_path.cc +++ b/sql/join_optimizer/access_path.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2020, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -212,6 +213,10 @@ table_map GetUsedTables(const AccessPath *path) { .table->pos_in_table_list->map(); case AccessPath::CACHE_INVALIDATOR: return GetUsedTables(path->cache_invalidator().child); + case AccessPath::PARALLEL_SCAN: + return path->parallel_scan().table->pos_in_table_list->map(); + case AccessPath::PQBLOCK_SCAN: + return path->pqblock_scan().table->pos_in_table_list->map(); } assert(false); return 0; @@ -706,6 +711,20 @@ unique_ptr_destroy_only CreateIteratorFromAccessPath( NewIterator(thd, move(child), param.name); break; } + case AccessPath::PARALLEL_SCAN: { + const auto ¶m = path->parallel_scan(); + iterator = NewIterator( + thd, param.tab, param.table, nullptr, join, param.gather, + param.stable_sort, param.ref_length); + break; + } + case AccessPath::PQBLOCK_SCAN: { + const auto ¶m = path->pqblock_scan(); + iterator = NewIterator( + thd, param.table, param.table->record[0], &join->examined_rows, + param.gather, param.need_rowid); + break; + } } path->iterator = iterator.get(); diff --git a/sql/join_optimizer/access_path.h b/sql/join_optimizer/access_path.h index 86526e82a..b01e1f7d6 100644 --- a/sql/join_optimizer/access_path.h +++ b/sql/join_optimizer/access_path.h @@ -1,4 +1,5 @@ /* Copyright (c) 2020, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -37,6 +38,7 @@ class Common_table_expr; class Filesort; +class Gather_operator; class Item; class Item_func_eq; class JOIN; @@ -197,7 +199,9 @@ struct AccessPath { WEEDOUT, REMOVE_DUPLICATES, ALTERNATIVE, - CACHE_INVALIDATOR + CACHE_INVALIDATOR, + PARALLEL_SCAN, + PQBLOCK_SCAN } type; /// Whether this access path counts as one that scans a base table, @@ -558,6 +562,22 @@ struct AccessPath { assert(type == CACHE_INVALIDATOR); return u.cache_invalidator; } + auto ¶llel_scan() { + assert(type == PARALLEL_SCAN); + return u.parallel_scan; + } + const auto ¶llel_scan() const { + assert(type == PARALLEL_SCAN); + return u.parallel_scan; + } + auto &pqblock_scan() { + assert(type == PQBLOCK_SCAN); + return u.pqblock_scan; + } + const auto &pqblock_scan() const { + assert(type == PQBLOCK_SCAN); + return u.pqblock_scan; + } private: // We'd prefer if this could be an std::variant, but we don't have C++17 yet. @@ -762,6 +782,18 @@ struct AccessPath { AccessPath *child; const char *name; } cache_invalidator; + struct { + QEP_TAB *tab; + TABLE *table; + Gather_operator *gather; + bool stable_sort; /** determine whether using stable sort */ + uint ref_length; + } parallel_scan; + struct { + TABLE *table; + Gather_operator *gather; + bool need_rowid; + } pqblock_scan; } u; }; static_assert(std::is_trivially_destructible::value, @@ -1226,6 +1258,31 @@ inline AccessPath *NewInvalidatorAccessPath(THD *thd, AccessPath *child, return path; } +inline AccessPath *NewParallelScanAccessPath(THD *thd, QEP_TAB *tab, + TABLE *table, + Gather_operator *gather, + bool stable_sort, uint ref_length) { + AccessPath *path = new (thd->mem_root) AccessPath; + path->type = AccessPath::PARALLEL_SCAN; + path->parallel_scan().tab = tab; + path->parallel_scan().table = table; + path->parallel_scan().gather = gather; + path->parallel_scan().stable_sort = stable_sort; + path->parallel_scan().ref_length = ref_length; + return path; +} + +inline AccessPath *NewPQBlockScanAccessPath(THD *thd, TABLE *table, + Gather_operator *gather, + bool need_rowid) { + AccessPath *path = new (thd->mem_root) AccessPath; + path->type = AccessPath::PQBLOCK_SCAN; + path->pqblock_scan().table = table; + path->pqblock_scan().gather = gather; + path->pqblock_scan().need_rowid = need_rowid; + return path; +} + void FindTablesToGetRowidFor(AccessPath *path); unique_ptr_destroy_only CreateIteratorFromAccessPath( diff --git a/sql/join_optimizer/explain_access_path.cc b/sql/join_optimizer/explain_access_path.cc index 1b7a586a3..468360c5b 100644 --- a/sql/join_optimizer/explain_access_path.cc +++ b/sql/join_optimizer/explain_access_path.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2020, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -801,6 +802,65 @@ ExplainData ExplainAccessPath(const AccessPath *path, JOIN *join) { path->cache_invalidator().name + ")"); children.push_back({path->cache_invalidator().child}); break; + case AccessPath::PARALLEL_SCAN: { + description.push_back(string("Parallel scan on ") + + path->parallel_scan().table->alias + + path->parallel_scan().table->file->explain_extra()); + Gather_operator *gather = path->parallel_scan().gather; + AccessPath *root_path = gather->m_workers[0]->thd_worker->lex->unit->m_root_access_path; + children.push_back({root_path, "", gather->m_template_join}); + break; + } + case AccessPath::PQBLOCK_SCAN: { + auto ¶m = path->pqblock_scan(); + Gather_operator *gather = param.gather; + TABLE *table = param.table; + const KEY *key = &(table->key_info[gather->keyno]); + int tab_idx = gather->m_template_join->pq_tab_idx; + assert(tab_idx >= (int)gather->m_template_join->const_tables && + gather->m_template_join->qep_tab[tab_idx].do_parallel_scan); + QEP_TAB *tab = &gather->m_template_join->qep_tab[tab_idx]; + + string str; + switch (tab->type()) { + case JT_ALL: + str = string("PQblock scan on ") + table->alias; + break; + case JT_RANGE: + str = string("PQblock range scan on ") + table->alias + " using " + + key->name; + if (table->file->pushed_idx_cond != nullptr) { + str += string(", with index condition: ") + + ItemToString(table->file->pushed_idx_cond); + } + break; + case JT_REF: + str = string("PQblock lookup on ") + table->alias + + string(" using ") + key->name + " (" + + RefToString(tab->ref(), key, /*include_nulls=*/false); + if (tab->m_reversed_access) { + str += string("; iterate backwards"); + } + str += string(")"); + if (table->file->pushed_idx_cond != nullptr) { + str += string(", with index condition: ") + + ItemToString(table->file->pushed_idx_cond); + } + break; + case JT_INDEX_SCAN: + str = + string("PQblock scan on ") + table->alias + " using " + key->name; + if (tab->m_reversed_access) { + str += string(" (reverse)"); + } + break; + default: + assert(0); + break; + } + description.push_back(str + table->file->explain_extra()); + break; + } } if (path->num_output_rows >= 0.0) { double first_row_cost; diff --git a/sql/join_optimizer/walk_access_paths.h b/sql/join_optimizer/walk_access_paths.h index b1b7fabd3..2f1a30ee4 100644 --- a/sql/join_optimizer/walk_access_paths.h +++ b/sql/join_optimizer/walk_access_paths.h @@ -1,4 +1,5 @@ /* Copyright (c) 2020, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -86,6 +87,8 @@ void WalkAccessPaths(AccessPath *path, const JOIN *join, case AccessPath::ZERO_ROWS_AGGREGATED: case AccessPath::MATERIALIZED_TABLE_FUNCTION: case AccessPath::UNQUALIFIED_COUNT: + case AccessPath::PARALLEL_SCAN: + case AccessPath::PQBLOCK_SCAN: // No children. return; case AccessPath::NESTED_LOOP_JOIN: diff --git a/sql/lex.h b/sql/lex.h index 74fb8362b..e76b0abd8 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -2,6 +2,7 @@ #define LEX_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -859,6 +860,8 @@ static const SYMBOL symbols[] = { /* Insert new optimizer hint keywords after that commentary: */ + {SYM_H("PQ", PQ_HINT)}, + {SYM_H("NO_PQ", NO_PQ_HINT)}, {SYM_H("BKA", BKA_HINT)}, {SYM_H("BNL", BNL_HINT)}, {SYM_H("DUPSWEEDOUT", DUPSWEEDOUT_HINT)}, diff --git a/sql/mdl.cc b/sql/mdl.cc index 7aba6f207..d2bfbc0df 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2007, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -52,6 +53,7 @@ #include "prealloced_array.h" #include "sql/debug_sync.h" #include "sql/thr_malloc.h" +#include "sql/sql_class.h" extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info; @@ -2635,6 +2637,8 @@ bool equivalent(const MDL_ticket *a, const MDL_ticket *b, } #endif /* not defined NDEBUG */ +THD *invalid_thd = (THD *)0x1; + /** Check whether the context already holds a compatible lock ticket on an object. @@ -2654,6 +2658,13 @@ MDL_ticket *MDL_context::find_ticket(MDL_request *mdl_request, enum_mdl_duration *result_duration) { auto h = m_ticket_store.find(*mdl_request); *result_duration = h.m_dur; + // PQ worker need to judge its leader got this ticket or not + // during xa recover, get_thd() maybe NULL + if (!h.m_ticket && get_thd() && get_thd() != invalid_thd && + get_thd()->pq_leader) { + return get_thd()->pq_leader->mdl_context.find_ticket(mdl_request, + result_duration); + } return h.m_ticket; } diff --git a/sql/memory/aligned_atomic.h b/sql/memory/aligned_atomic.h index 3fed8df60..a668bce11 100644 --- a/sql/memory/aligned_atomic.h +++ b/sql/memory/aligned_atomic.h @@ -77,7 +77,9 @@ static inline size_t _cache_line_size() { #elif defined(__linux__) static inline size_t _cache_line_size() { - return sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + long size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + if (size == -1 || size == 0) return 64; + return static_cast(size); } #else diff --git a/sql/msg_queue.cc b/sql/msg_queue.cc new file mode 100644 index 000000000..20ee39296 --- /dev/null +++ b/sql/msg_queue.cc @@ -0,0 +1,394 @@ +/* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "msg_queue.h" +#include + +#ifndef NDEBUG +bool dbug_pq_worker_stall = 0; +#endif + +/** + * send data of nbytes to MQ + * @nbytes + * @data + * @written: number of bytes that have written into MQ + * @nowait: the mode of write data, i.e., blocking/non-blocking mode + * + * @return the send status + */ +MQ_RESULT MQueue_handle::send_bytes(uint32 nbytes, const void *data, + uint32 *written, bool nowait) { + uint32 used; + uint32 ringsize = m_queue->m_ring_size; + uint32 sent = 0, available; + + /** only worker thread can send data to message queue */ + THD *thd = current_thd; + assert(!m_queue->m_sender_event->PQ_caller || + thd == m_queue->m_sender_event->PQ_caller); + + uint64 rb, wb; + while (!thd->is_pq_error() && (sent < nbytes)) { + /** atomically obtain the read position */ + rb = atomic_read_u64(&m_queue->m_bytes_read); + /** atomically obtain the write position */ + wb = atomic_read_u64(&m_queue->m_bytes_written); + assert(wb >= rb); + + used = wb - rb; + assert(used <= ringsize); + available = std::min(ringsize - used, nbytes - sent); + + compiler_barrier(); + if (m_queue->detached == MQ_HAVE_DETACHED) { + *written = sent; + return MQ_DETACHED; + } + + if (m_queue->detached == MQ_TMP_DETACHED) { + *written = sent; + return MQ_SUCCESS; + } + + /** + * Considering the case that available = 0: sender first notifies receiver + * to receive data from MQ. If nowait = false, then sender enters into a + * blocking status until receiver has received data from MQ; otherwise, + * sender directly returns. + */ + if (available == 0) { + /** notify receiver to receive data from MQ */ + end_wait(m_queue->m_receiver_event); + /** blocking mode by default, i.e, nowait = false */ + if (nowait) { + *written = sent; + return MQ_WOULD_BLOCK; + } + /** sender enters into the blocking wait status */ + set_wait(m_queue->m_sender_event); + /** reset the wait status */ + reset_wait(m_queue->m_sender_event); + } else { + uint32 offset; + uint32 sent_once; + + /** compute the real write position in ring array */ + offset = MOD(wb, ringsize); + sent_once = std::min(available, ringsize - offset); + + /** this barrier ensures that memcpy() is finished before end_wait() */ + memory_barrier(); + memcpy(&m_queue->m_buffer[offset], + reinterpret_cast(const_cast(data)) + sent, + sent_once); + sent += sent_once; + + /** atomically update the write position */ + atomic_inc_bytes_written(sent_once); + /** notify receiver to receive data */ + end_wait(m_queue->m_receiver_event); + } +#ifndef NDEBUG + if (dbug_pq_worker_stall) { + sleep(1); // 1 second + } +#endif + } + + if (thd->is_pq_error()) { + set_datched_status(MQ_HAVE_DETACHED); + return MQ_DETACHED; + } + + assert(sent == nbytes); + *written = sent; + return MQ_SUCCESS; +} + +/** + * sending data to message queue is divided into two steps: + * (s1) send the message length + * (s2) send the whole message + * + * Note that: the sending process is in a blocking mode. + * @data: the message data + * @len: the message length + * @nowait: the sending status + */ +MQ_RESULT MQueue_handle::send(const void *data, uint32 len, bool nowait) { + MQ_RESULT res; + uint32 nbytes = len; + uint32 written; + + /** (1) write the message length into MQ */ + res = send_bytes(WORD_LENGTH, (char *)&nbytes, &written, nowait); + if (res != MQ_SUCCESS) { + assert(res == MQ_DETACHED); + return res; + } + assert((!written && m_queue->detached == MQ_TMP_DETACHED) || + written == WORD_LENGTH); + + /** (2) write the message data into MQ */ + res = send_bytes(nbytes, data, &written, nowait); + if (res != MQ_SUCCESS) { + assert(res == MQ_DETACHED); + return res; + } + assert((!written && m_queue->detached == MQ_TMP_DETACHED) || + written == nbytes); + return MQ_SUCCESS; +} + +/** sending message to MQ in a Field_raw_data manner */ +MQ_RESULT MQueue_handle::send(Field_raw_data *fm) { + MQ_RESULT res = MQ_SUCCESS; + uint32 written; + + /** (s1) sending the variable-field's length_bytes */ + if (fm->m_var_len) { + res = send_bytes(1, (void *)&fm->m_var_len, &written); + assert((res == MQ_SUCCESS && written == 1) || res == MQ_DETACHED || + (!written && m_queue->detached == MQ_TMP_DETACHED)); + } + + /** (s2) sending the data of field->ptr */ + if (MQ_SUCCESS == res) { + res = send_bytes(fm->m_len, fm->m_ptr, &written); + assert((res == MQ_SUCCESS && written == fm->m_len) || + res == MQ_DETACHED || + (!written && m_queue->detached == MQ_TMP_DETACHED)); + } + return res; +} + +/** + * receive data of bytes_needed from MQ + * @bytes_needed: number of bytes needed from the read position + * @nbytesp: the acutal bytes read + * @datap: the data read + * @nowait: reading mode, nowait=true by default + * @return + */ +MQ_RESULT MQueue_handle::receive_bytes(uint32 bytes_needed, uint32 *nbytesp, + void *datap, bool nowait) { + uint64 rb, wb; + uint32 used, offset; + + *nbytesp = 0; + uint32 ringsize = m_queue->m_ring_size; + THD *thd = current_thd; + assert(!m_queue->m_receiver_event->PQ_caller || + thd == m_queue->m_receiver_event->PQ_caller); + while (!thd->is_killed() && !thd->pq_error) { + rb = atomic_read_u64(&m_queue->m_bytes_read) + m_consume_pending; + wb = atomic_read_u64(&m_queue->m_bytes_written); + assert(wb >= rb); + + used = wb - rb; + assert(used <= ringsize); + offset = MOD(rb, ringsize); + + /** we have enough space and then directly read bytes_needed data into datap + */ + if (used >= bytes_needed) { + /** (s1) read data located in [offset, ..., ringsize] */ + if (offset + bytes_needed <= ringsize) { + memcpy(datap, &m_queue->m_buffer[offset], bytes_needed); + } else { + /** (s2) read data located in [offset, ringsize], [0, bytes_needed - + * (ringsize - offset))] */ + int part_1 = ringsize - offset; + int part_2 = bytes_needed - part_1; + + memcpy(datap, &m_queue->m_buffer[offset], part_1); + memcpy((char *)datap + part_1, &m_queue->m_buffer[0], part_2); + } + + *nbytesp = bytes_needed; + memory_barrier(); + + /** notify sender that there is available space in MQ */ + end_wait(m_queue->m_sender_event); + return MQ_SUCCESS; + } + + /** + * there are not enough data for receiver, and receiver only + * receives the data located into [offset, ringsize]. + */ + if (offset + used >= ringsize) { + memcpy(datap, &m_queue->m_buffer[offset], ringsize - offset); + *nbytesp = ringsize - offset; + + memory_barrier(); + end_wait(m_queue->m_sender_event); + return MQ_SUCCESS; + } + + /** + * if m_queue is detached and there are still data in m_queue, + * receiver can receive data until it reads all data. + */ + if (m_queue->detached == MQ_HAVE_DETACHED) { + read_barrier(); + if (wb != atomic_read_u64(&m_queue->m_bytes_written)) { + continue; + } + return MQ_DETACHED; + } + + /** + * updating the read position, note that + * { + * atomic_inc_bytes_read(m_consume_pending); + * m_consume_pending = 0; + * } + * should be a group of atomic operation. + */ + if (m_consume_pending > 0) { + offset = m_consume_pending; + m_consume_pending = 0; + + /** ensure that: consume_pending has written into memory */ + memory_barrier(); + atomic_inc_bytes_read(offset); + } + + /** the blocking-read mode */ + if (nowait) { + return MQ_WOULD_BLOCK; + } + + set_wait(m_queue->m_receiver_event); + reset_wait(m_queue->m_receiver_event); + } + return MQ_DETACHED; +} + +/** + * receive message from MQ + * @datap + * @nbytesp + * @nowait + */ +MQ_RESULT MQueue_handle::receive(void **datap, uint32 *nbytesp, bool nowait) { + MQ_RESULT res; + uint32 nbytes, offset; + uint32 rb = 0; + /** + * only when m_consume_pending is greater than 1/4 * m_ring_size, we update + * the read position m_read_bytes using m_consume_pending; otherwise, the + * number of read bytes is firstly accumulated to m_consume_pending and then + * using (m_read_bytes + m_consume_pending) as the real read position in ring + * array. + * + */ + if (m_consume_pending > m_queue->m_ring_size / 4) { + offset = m_consume_pending; + m_consume_pending = 0; + + memory_barrier(); + atomic_inc_bytes_read(offset); + } + + /** + * for the receive process: + * (1) first, we read the message length from MQ; + * (2) then, we read the message data. + * As in the non-blocking mode, we read bytes from MQ as many as possible + * when there is available data in MQ. Thus, we should remember the read + * info. of last receive process. + * + */ + + /** (1) read the message length */ + while (!m_length_word_complete) { + assert(m_partial_bytes < WORD_LENGTH); + res = receive_bytes(WORD_LENGTH - m_partial_bytes, &rb, + &m_buffer[m_partial_bytes], nowait); + if (res != MQ_SUCCESS) { + return res; + } + + uint32x2_t v_a = {m_partial_bytes, m_consume_pending}; + uint32x2_t v_b = {rb, rb}; + + v_a = vadd_u32(v_a, v_b); + m_partial_bytes = vget_lane_u32(v_a, 0); + m_consume_pending = vget_lane_u32(v_a, 1); + + if (m_partial_bytes >= WORD_LENGTH) { + assert(m_partial_bytes == WORD_LENGTH); + m_expected_bytes = *(uint32 *)m_buffer; + m_length_word_complete = true; + m_partial_bytes = 0; + } + } + nbytes = m_expected_bytes; + + /** re-allocing local buffer when m_buffer_len is smaller than nbytes */ + if (m_buffer_len < nbytes || DBUG_EVALUATE_IF("pq_mq_error3", true, false)) { + while (m_buffer_len < nbytes) { + m_buffer_len *= 2; + } + if (m_buffer) { + destroy(m_buffer); + } + THD *thd = current_thd; + assert(!m_queue->m_receiver_event->PQ_caller || + thd == m_queue->m_receiver_event->PQ_caller); + m_buffer = new (thd->pq_mem_root) char[m_buffer_len]; + /** if m_buffer allocates fail, then directly return my_error */ + if (m_buffer == nullptr || DBUG_EVALUATE_IF("pq_mq_error3", true, false)) { + my_error(ER_STD_BAD_ALLOC_ERROR, MYF(0), "", "(MQ::receive)"); + return MQ_DETACHED; + } + } + + /** (2) read data of nbytes **/ + for (;;) { + size_t still_needed; + assert(m_partial_bytes <= nbytes); + + still_needed = nbytes - m_partial_bytes; + res = receive_bytes(still_needed, &rb, &m_buffer[m_partial_bytes], nowait); + if (res != MQ_SUCCESS) { + return res; + } + m_partial_bytes += rb; + m_consume_pending += rb; + if (m_partial_bytes >= nbytes) { + break; + } + } + + /** reset for next read */ + m_length_word_complete = false; + m_partial_bytes = 0; + + *nbytesp = nbytes; + *datap = m_buffer; + return MQ_SUCCESS; +} diff --git a/sql/msg_queue.h b/sql/msg_queue.h new file mode 100644 index 000000000..0abdc012b --- /dev/null +++ b/sql/msg_queue.h @@ -0,0 +1,321 @@ +#ifndef _MESSAGE_QUEUE_PQ +#define _MESSAGE_QUEUE_PQ + +/* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "log.h" +#include "my_dbug.h" +#include "my_sys.h" +#include "pq_global.h" +#include "sql_base.h" +#include "sql_class.h" +#include "sql_error.h" + +#define MQ_BUFFER_SIZE 1024 +#define RING_SIZE 1048576 + +// one message cannot exceed 2^32 bytes +const size_t WORD_LENGTH = sizeof(uint32); +enum MQ_RESULT { + MQ_SUCCESS, /** Sent or received a message */ + MQ_WOULD_BLOCK, /** Not completed; retry later */ + MQ_DETACHED /** worker has detached queue */ +}; + +enum MQ_DETACHED_STATUS { + MQ_NOT_DETACHED = 0, /** not detached from MQ */ + MQ_HAVE_DETACHED, /** have detached from MQ */ + MQ_TMP_DETACHED /** tmp detached from MQ, and reset MQ_NOT_DETACHED later */ +}; + +enum MESSAGE_TYPE { EMPTY_MSG, ERROR_MSG }; + +/** + * field raw data, used to store in MQ + * + * */ +struct Field_raw_data { + uchar *m_ptr; /** point to raw data buffer */ + uint32 m_len; /** length of message */ + uchar m_var_len; /** length of varstring */ + + /** + * m_need_send = true indicates message should be sent to MQ; + * otherwise, m_need_send = false. + */ + bool m_need_send; + Field_raw_data() { + m_ptr = nullptr; + m_len = 0; + m_var_len = 0; + m_need_send = true; + } +}; + +const uint RING_SIZE_MOD = RING_SIZE - 1; +#define MOD(x, y) ((x)&RING_SIZE_MOD) + +/** lock-free operation */ +#define write_barrier() __atomic_thread_fence(__ATOMIC_RELEASE) +#define read_barrier() __atomic_thread_fence(__ATOMIC_ACQUIRE) +#define compiler_barrier() __asm__ __volatile__("" ::: "memory") +#define memory_barrier() __sync_synchronize() + +/** atomic CAS operation */ +static inline bool atomic_compare_exchange_u64(volatile uint64 *ptr, + uint64 *expected, + uint64 newval) { + bool ret; + uint64 current; + current = __sync_val_compare_and_swap(ptr, *expected, newval); + ret = current == *expected; + *expected = current; + return ret; +} + +/** atomic read uint64 value */ +static inline uint64 atomic_read_u64(volatile uint64 *ptr) { + uint64 old = 0; + atomic_compare_exchange_u64(ptr, &old, 0); + return old; +} + +/** atomic write uint64 value */ +static inline uint64 atomic_write_u64(volatile uint64 *ptr, uint64 val) { + uint64 old = *ptr; + while (!atomic_compare_exchange_u64(ptr, &old, val)) + ; + return old; +} + +class MQ_event { + public: + THD *PQ_caller; + std::atomic latch; + + public: + MQ_event(THD *thd) : PQ_caller(thd), latch(false) {} + MQ_event() { + PQ_caller = nullptr; + latch = false; + } + ~MQ_event() {} + + /** set waiting status */ + void set_latch() { latch.store(true); } + + /** + * Check whether the partner has set latch's status in a loop manner until + * reaching the maximal timeout time (100ms, by default). + */ + void wait_latch(uint64 wait_max_time = 100) { + struct timespec start_ts; + struct timespec end_ts; + ulong difftime; + + set_timespec(&start_ts, 0); + latch.load(); + THD *thd = PQ_caller ? PQ_caller : current_thd; + while (!latch && (thd && !thd->is_killed())) { + set_timespec(&end_ts, 0); + difftime = (end_ts.tv_sec - start_ts.tv_sec) * TIME_THOUSAND + + (end_ts.tv_nsec - start_ts.tv_nsec) / TIME_MILLION; + + if (difftime >= wait_max_time) break; + latch.load(); + } + } + + /** reset waiting status */ + void reset_latch() { latch.store(false); } +}; + +class MQueue { + public: + MQ_event *m_sender_event; /** sender's event */ + MQ_event *m_receiver_event; /** receiver's event */ + uint64 m_bytes_written; /** number of written bytes */ + uint64 m_bytes_read; /** number of read bytes */ + char *m_buffer; /** ring array that stores the message */ + uint32 m_ring_size; /** the size of ring array */ + MQ_DETACHED_STATUS detached; /** the status of message queue */ + + public: + MQueue() + : m_sender_event(nullptr), + m_receiver_event(nullptr), + m_bytes_written(0), + m_bytes_read(0), + m_buffer(nullptr), + m_ring_size(0), + detached(MQ_NOT_DETACHED) {} + + MQueue(MQ_event *sender_event, MQ_event *receiver_event, char *ring, + size_t ring_size) + : m_sender_event(sender_event), + m_receiver_event(receiver_event), + m_bytes_written(0), + m_bytes_read(0), + m_buffer(ring), + m_ring_size(ring_size), + detached(MQ_NOT_DETACHED) {} +}; + +class MQueue_handle { + public: + MQueue *m_queue; /** message queue */ + + private: + char *m_buffer; /** local buffer for cache reading */ + uint32 m_buffer_len; /** the length of local buffer */ + uint32 m_consume_pending; /** accumulated read bytes for updating read number + of bytes in batch manner */ + uint32 m_partial_bytes; /** partial bytes that has been read in one message */ + uint32 m_expected_bytes; /** expected bytes for one complete message */ + bool m_length_word_complete; /** indicates whether message's length has been + completely read */ + + public: + public: + MQueue_handle() + : m_queue(nullptr), + m_buffer(nullptr), + m_buffer_len(0), + m_consume_pending(0), + m_partial_bytes(0), + m_expected_bytes(0), + m_length_word_complete(false) {} + + MQueue_handle(MQueue *queue, size_t buffer_len) + : m_queue(queue), + m_buffer(nullptr), + m_buffer_len(buffer_len), + m_consume_pending(0), + m_partial_bytes(0), + m_expected_bytes(0), + m_length_word_complete(false) {} + + ~MQueue_handle() {} + + public: + MQ_RESULT send(Field_raw_data *fm); + MQ_RESULT send(const void *datap, uint32 len, bool nowait = false); + MQ_RESULT receive(void **datap, uint32 *, bool nowait = true); + + inline MQueue *get_mqueue() { return m_queue; } + inline MQ_event *get_receiver() { return m_queue->m_receiver_event; } + + inline MQ_event *get_sender() { return m_queue->m_sender_event; } + /** set detached status */ + inline void set_datched_status(MQ_DETACHED_STATUS status) { + if (m_queue) m_queue->detached = status; + } + + inline bool send_exception_msg(MESSAGE_TYPE msg) { + MQ_RESULT result = send((void *)&msg, 1); + if ((result != MQ_SUCCESS && result != MQ_DETACHED) || + DBUG_EVALUATE_IF("pq_mq_error6", true, false)) { + /* + * Note that: if we can not send error msg to MQ, then the only + * solution is to generate my_error info. + */ + my_error(ER_PARALLEL_EXEC_ERROR, MYF(0)); + return true; + } + return false; + } + + /** + * init the handle structure + * @retval: + * false for success, and otherwise true. + */ + bool init_mqueue_handle(THD *thd) { + if (!m_buffer_len) return true; + m_buffer = new (thd->pq_mem_root) char[m_buffer_len]; + if (!m_buffer) return true; + + return false; + } + + /** cleanup the allocated buffer */ + void cleanup() { + destroy(m_buffer); + if (m_queue) { + destroy(m_queue->m_sender_event); + destroy(m_queue->m_buffer); + } + destroy(m_queue); + } + + private: + /**increase #read bytes in atomic manner */ + void atomic_inc_bytes_read(int n) { + read_barrier(); + atomic_write_u64(&m_queue->m_bytes_read, + atomic_read_u64(&m_queue->m_bytes_read) + n); + } + + /** increase #written bytes in atomic manner */ + void atomic_inc_bytes_written(int n) { + write_barrier(); + atomic_write_u64(&m_queue->m_bytes_written, + atomic_read_u64(&m_queue->m_bytes_written) + n); + } + + /** let event into wait status */ + void set_wait(MQ_event *event) { + assert(event != nullptr); + event->wait_latch(); + } + + /** end event's wait status */ + void end_wait(MQ_event *event) { + assert(event != nullptr); + event->set_latch(); + } + + /** reset event's wait status */ + void reset_wait(MQ_event *event) { + assert(event != nullptr); + event->reset_latch(); + } + + MQ_RESULT send_bytes(uint32 nbytes, const void *data, uint32 *written, + bool nowait = false); + MQ_RESULT receive_bytes(uint32 bytes_needed, uint32 *nbytesp, void *datap, + bool nowait = true); +}; + +#endif diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 83643f76a..1fa395ff3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -857,6 +858,7 @@ MySQL clients support the protocol: #include "thr_mutex.h" #include "typelib.h" #include "violite.h" +#include "sql/sql_parallel.h" #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE #include "storage/perfschema/pfs_server.h" @@ -1096,6 +1098,8 @@ static PSI_mutex_key key_LOCK_admin_tls_ctx_options; static PSI_mutex_key key_LOCK_rotate_binlog_master_key; static PSI_mutex_key key_LOCK_partial_revokes; #endif /* HAVE_PSI_INTERFACE */ +static PSI_mutex_key key_LOCK_pq_threads_running; +static PSI_cond_key key_COND_pq_threads_running; /** Statement instrumentation key for replication. @@ -2645,6 +2649,8 @@ static void clean_up_mutexes() { mysql_mutex_destroy(&LOCK_rotate_binlog_master_key); mysql_mutex_destroy(&LOCK_admin_tls_ctx_options); mysql_mutex_destroy(&LOCK_partial_revokes); + mysql_mutex_destroy(&LOCK_pq_threads_running); + mysql_cond_destroy(&COND_pq_threads_running); } /**************************************************************************** @@ -5092,6 +5098,8 @@ static int init_thread_environment() { MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_partial_revokes, &LOCK_partial_revokes, MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_LOCK_pq_threads_running, &LOCK_pq_threads_running, MY_MUTEX_INIT_FAST); + mysql_cond_init(key_COND_pq_threads_running, &COND_pq_threads_running); return 0; } @@ -8598,6 +8606,14 @@ static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff) { return 0; } +static int show_pq_memory(THD *, SHOW_VAR *var, char *buff) { + var->type = SHOW_INT; + var->value = buff; + unsigned int *value = reinterpret_cast(buff); + *value = get_pq_memory_total(); + return 0; +} + static int show_net_compression_algorithm(THD *thd, SHOW_VAR *var, char *buff) { const char *s = thd->get_protocol()->get_compression_algorithm(); var->type = SHOW_CHAR; @@ -9180,6 +9196,13 @@ SHOW_VAR status_vars[] = { SHOW_SCOPE_ALL}, {"Prepared_stmt_count", (char *)&show_prepared_stmt_count, SHOW_FUNC, SHOW_SCOPE_GLOBAL}, + {"PQ_threads_refused", (char*)¶llel_threads_refused, SHOW_INT, + SHOW_SCOPE_GLOBAL}, + {"PQ_memory_refused", (char*)¶llel_memory_refused, SHOW_INT, + SHOW_SCOPE_GLOBAL}, + {"PQ_threads_running", (char*)¶llel_threads_running, SHOW_INT, + SHOW_SCOPE_GLOBAL}, + {"PQ_memory_used", (char*)&show_pq_memory, SHOW_FUNC, SHOW_SCOPE_GLOBAL}, {"Queries", (char *)&show_queries, SHOW_FUNC, SHOW_SCOPE_ALL}, {"Questions", (char *)offsetof(System_status_var, questions), SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, @@ -11107,7 +11130,8 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_tls_ctx_options, "LOCK_tls_ctx_options", 0, 0, "A lock to control all of the --ssl-* CTX related command line options for client server connection port"}, { &key_LOCK_admin_tls_ctx_options, "LOCK_admin_tls_ctx_options", 0, 0, "A lock to control all of the --ssl-* CTX related command line options for administrative connection port"}, { &key_LOCK_rotate_binlog_master_key, "LOCK_rotate_binlog_master_key", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, - { &key_monitor_info_run_lock, "Source_IO_monitor::run_lock", 0, 0, PSI_DOCUMENT_ME} + { &key_monitor_info_run_lock, "Source_IO_monitor::run_lock", 0, 0, PSI_DOCUMENT_ME}, + { &key_LOCK_pq_threads_running, "LOCK_pq_threads_running", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME} }; /* clang-format on */ @@ -11217,7 +11241,8 @@ static PSI_cond_info all_server_conds[]= { &key_COND_compress_gtid_table, "COND_compress_gtid_table", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, { &key_commit_order_manager_cond, "Commit_order_manager::m_workers.cond", 0, 0, PSI_DOCUMENT_ME}, { &key_cond_slave_worker_hash, "Relay_log_info::slave_worker_hash_lock", 0, 0, PSI_DOCUMENT_ME}, - { &key_monitor_info_run_cond, "Source_IO_monitor::run_cond", 0, 0, PSI_DOCUMENT_ME} + { &key_monitor_info_run_cond, "Source_IO_monitor::run_cond", 0, 0, PSI_DOCUMENT_ME}, + { &key_COND_pq_threads_running, "COND_pq_threads_running", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME} }; /* clang-format on */ @@ -11227,6 +11252,7 @@ PSI_thread_key key_thread_one_connection; PSI_thread_key key_thread_compress_gtid_table; PSI_thread_key key_thread_parser_service; PSI_thread_key key_thread_handle_con_admin_sockets; +PSI_thread_key key_thread_parallel_query; /* clang-format off */ static PSI_thread_info all_server_threads[]= @@ -11245,6 +11271,7 @@ static PSI_thread_info all_server_threads[]= { &key_thread_compress_gtid_table, "compress_gtid_table", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, { &key_thread_parser_service, "parser_service", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, { &key_thread_handle_con_admin_sockets, "admin_interface", PSI_FLAG_USER, 0, PSI_DOCUMENT_ME}, + { &key_thread_parallel_query, "parallel_query", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, }; /* clang-format on */ diff --git a/sql/mysqld.h b/sql/mysqld.h index a7a80a223..f778a5a03 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -1,4 +1,5 @@ /* Copyright (c) 2010, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -148,6 +149,9 @@ enum enum_server_operational_state { }; enum_server_operational_state get_server_state(); +extern uint parallel_threads_running; +extern uint parallel_threads_refused; +extern uint parallel_memory_refused; extern bool opt_large_files, server_id_supplied; extern bool opt_bin_log; extern bool opt_log_slave_updates; @@ -481,6 +485,7 @@ extern PSI_thread_key key_thread_compress_gtid_table; extern PSI_thread_key key_thread_parser_service; extern PSI_thread_key key_thread_handle_con_admin_sockets; extern PSI_cond_key key_monitor_info_run_cond; +extern PSI_thread_key key_thread_parallel_query; extern PSI_file_key key_file_binlog; extern PSI_file_key key_file_binlog_index; diff --git a/sql/opt_explain.cc b/sql/opt_explain.cc index aabeb29ff..7eb6d7867 100644 --- a/sql/opt_explain.cc +++ b/sql/opt_explain.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -72,6 +73,7 @@ #include "sql/mysqld_thd_manager.h" // Global_THD_manager #include "sql/opt_costmodel.h" #include "sql/opt_explain_format.h" +#include "sql/opt_explain_json.h" #include "sql/opt_range.h" // QUICK_SELECT_I #include "sql/opt_trace.h" // Opt_trace_* #include "sql/protocol.h" @@ -94,6 +96,7 @@ #include "sql/temp_table_param.h" // Func_ptr #include "sql_string.h" #include "template_utils.h" +#include "sql/sql_parallel.h" class Opt_trace_context; @@ -428,7 +431,7 @@ class Explain_join : public Explain_table_base { Query_block *query_block_arg, bool need_tmp_table_arg, bool need_order_arg, bool distinct_arg) : Explain_table_base(CTX_JOIN, explain_thd_arg, query_thd_arg, - query_block_arg), + query_block_arg, nullptr), need_tmp_table(need_tmp_table_arg), need_order(need_order_arg), distinct(distinct_arg), @@ -448,6 +451,7 @@ class Explain_join : public Explain_table_base { bool end_simple_sort_context(Explain_sort_clause clause, enum_parsing_context ctx); bool explain_qep_tab(size_t tab_num); + bool explain_pq_gather(QEP_TAB *tab); protected: bool shallow_explain() override; @@ -1135,6 +1139,12 @@ bool Explain_join::explain_modify_flags() { break; default:; }; + + if (query_thd->parallel_exec && + (const_cast(query_thd))->is_worker() == false) { + fmt->entry()->mod_type = MT_GATHER; + } + return false; } @@ -1275,6 +1285,10 @@ bool Explain_join::shallow_explain() { if (begin_sort_context(ESC_BUFFER_RESULT, CTX_BUFFER_RESULT)) return true; /* purecov: inspected */ + if (join->thd->parallel_exec && join->primary_tables == 0) { + join->primary_tables = 1; + } + for (size_t t = 0, cnt = fmt->is_hierarchical() ? join->primary_tables : join->tables; t < cnt; t++) { @@ -1293,6 +1307,45 @@ bool Explain_join::shallow_explain() { return false; } +bool Explain_join::explain_pq_gather(QEP_TAB *tab) { + assert(tab->gather); + + JOIN *gather_join = tab->gather->m_template_join; + Query_block *query_block = gather_join->query_block; + const Explain_format_flags *flags = &gather_join->explain_flags; + const bool need_tmp_table = flags->any(ESP_USING_TMPTABLE); + const bool need_order = flags->any(ESP_USING_FILESORT); + const bool distinct = flags->get(ESC_DISTINCT, ESP_EXISTS); + query_block->join->best_read = this->join->best_read; + bool ret = true; + + gather_join->thd->lock_query_plan(); + bool explain_other = explain_thd != query_thd; + Explain_join *ej = new (gather_join->thd->pq_mem_root) + Explain_join(explain_thd, explain_other ? gather_join->thd : explain_thd, + query_block, need_tmp_table, need_order, distinct); + if (ej == nullptr) { + goto END; + } + + if (!explain_other) { + ej->query_thd = gather_join->thd; + } + + if (ej->fmt->begin_context(CTX_GATHER, nullptr)) { + goto END; + } + + ret = ej->shallow_explain() || ej->explain_subqueries(); + if (!ret) { + ret = ej->fmt->end_context(CTX_GATHER); + } + +END: + gather_join->thd->unlock_query_plan(); + return ret; +} + bool Explain_join::explain_qep_tab(size_t tabnum) { tab = join->qep_tab + tabnum; if (!tab->position()) return false; @@ -1322,6 +1375,11 @@ bool Explain_join::explain_qep_tab(size_t tabnum) { Semijoin_mat_exec *const sjm = tab->sj_mat_exec(); const enum_parsing_context c = sjm ? CTX_MATERIALIZATION : CTX_QEP_TAB; + if (tab->gather) { + need_tmp_table = false; + need_order = false; + } + if (fmt->begin_context(c) || prepare_columns()) return true; fmt->entry()->query_block_id = table->pos_in_table_list->query_block_id(); @@ -1348,6 +1406,9 @@ bool Explain_join::explain_qep_tab(size_t tabnum) { if (fmt->end_context(c)) return true; + // explain parallel query execute plan + if (tab->gather) explain_pq_gather(tab); + if (first_non_const) { if (end_simple_sort_context(ESC_GROUP_BY, CTX_SIMPLE_GROUP_BY)) return true; if (end_simple_sort_context(ESC_DISTINCT, CTX_SIMPLE_DISTINCT)) return true; @@ -1613,6 +1674,13 @@ bool Explain_join::explain_extra() { push_extra(ET_USING_SECONDARY_ENGINE, table->file->table_type())) return true; + if (tab->gather) { + StringBuffer<64> buff(cs); + buff.append_ulonglong(tab->gather->m_dop); + buff.append(" workers"); + if (push_extra(ET_PARALLEL_EXE, buff)) return true; + } + return false; } @@ -2066,9 +2134,13 @@ static bool ExplainIterator(THD *ethd, const THD *query_thd, default: break; } - explain += PrintQueryPlan(base_level, unit->root_access_path(), + if (ethd->parallel_exec && ethd->lex->is_explain_analyze) { + explain += ethd->pq_explain; + } else { + explain += PrintQueryPlan(base_level, unit->root_access_path(), unit->is_union() ? nullptr : join, /*is_root_of_join=*/!unit->is_union()); + } } else { explain += PrintQueryPlan(0, /*path=*/nullptr, /*join=*/nullptr, /*is_root_of_join=*/false); diff --git a/sql/opt_explain_format.h b/sql/opt_explain_format.h index 947197ccf..1439c9213 100644 --- a/sql/opt_explain_format.h +++ b/sql/opt_explain_format.h @@ -1,4 +1,5 @@ /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -91,6 +92,7 @@ enum Extra_tag { ET_SKIP_RECORDS_IN_RANGE, ET_USING_SECONDARY_ENGINE, ET_REMATERIALIZE, + ET_PARALLEL_EXE, //------------------------------------ ET_total }; @@ -131,7 +133,7 @@ class context; } // Table modification type -enum enum_mod_type { MT_NONE, MT_INSERT, MT_UPDATE, MT_DELETE, MT_REPLACE }; +enum enum_mod_type { MT_NONE, MT_INSERT, MT_UPDATE, MT_DELETE, MT_REPLACE, MT_GATHER }; /** Helper class for table property buffering @@ -523,6 +525,8 @@ class Explain_format { virtual bool is_tree() const { return false; } + virtual bool is_json() const { return false; } + /** Send EXPLAIN header item(s) to output stream diff --git a/sql/opt_explain_json.cc b/sql/opt_explain_json.cc index 4fe198213..f5f7dcd35 100644 --- a/sql/opt_explain_json.cc +++ b/sql/opt_explain_json.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -94,7 +95,8 @@ static const char *json_extra_tags[ET_total] = { "table_function", // ET_TABLE_FUNCTION "skip_records_in_range_due_to_force", // ET_SKIP_RECORDS_IN_RANGE "using_secondary_engine", // ET_USING_SECONDARY_ENGINE - "rematerialize" // ET_REMATERIALIZE + "rematerialize", // ET_REMATERIALIZE + "parallel_execute" // ET_PARALLEL_EXE }; // JSON key names @@ -172,6 +174,7 @@ class sort_ctx; class subquery_ctx; class union_result_ctx; class window_ctx; +class join_ctx; /** @note Keep in sync with the @c list_names array. @@ -266,6 +269,14 @@ class context : public Explain_context { */ virtual size_t id(bool hide = false) = 0; + virtual size_t join_tabs_count() { + assert(0); + return 0; + } + + virtual sort_ctx* get_sort() { return nullptr; } + virtual window_ctx* get_window() { return nullptr; } + virtual bool cacheable() { assert(0); return true; @@ -394,6 +405,13 @@ class context : public Explain_context { return false; } + virtual int add_gather(join_ctx *ctx MY_ATTRIBUTE((unused)), + Query_expression *subquery + MY_ATTRIBUTE((unused))) { + assert(0); + return false; + } + /// Helper function to format output for derived subquery if any virtual bool format_derived(Opt_trace_context *) { return false; } @@ -402,6 +420,9 @@ class context : public Explain_context { /// Helper function to format output for HAVING, ORDER/GROUP BY subqueries virtual bool format_query_expression(Opt_trace_context *) { return false; } + + /// Helper function to format output for parallel gather if any + virtual bool format_gather(Opt_trace_context *) { return false; } }; /** @@ -629,7 +650,7 @@ bool table_base_ctx::format_body(Opt_trace_context *json, Opt_trace_object *obj) { StringBuffer<64> buff; - if (mod_type != MT_NONE) obj->add(mod_type_name[mod_type], true); + if (mod_type != MT_NONE && mod_type != MT_GATHER) obj->add(mod_type_name[mod_type], true); if (!col_id.is_empty() && !is_hidden_id) obj->add(K_SELECT_ID, col_id.value); @@ -701,7 +722,7 @@ bool table_base_ctx::format_body(Opt_trace_context *json, if (format_where(json)) return true; } - return format_derived(json) || format_query_expression(json); + return format_gather(json) || format_derived(json) || format_query_expression(json); } /** @@ -764,6 +785,7 @@ class union_result_ctx : public table_base_ctx, public unit_ctx { class table_with_where_and_derived : public table_base_ctx { public: List where_subqueries; ///< associated WHERE clause subqueries + List gather; ///< associated parallel gather table_with_where_and_derived(enum_parsing_context type_arg, const char *name_arg, context *parent_arg) @@ -796,6 +818,8 @@ class table_with_where_and_derived : public table_base_ctx { } return false; } + + virtual bool format_gather(Opt_trace_context *json); }; /** @@ -842,6 +866,9 @@ class message_ctx : public joinable_ctx, public table_with_where_and_derived { bool format_derived(Opt_trace_context *json) override { return table_with_where_and_derived::format_derived(json); } + virtual bool format_gather(Opt_trace_context *json) { + return table_with_where_and_derived::format_gather(json); + } bool format_where(Opt_trace_context *json) override { return table_with_where_and_derived::format_where(json); } @@ -860,6 +887,9 @@ class message_ctx : public joinable_ctx, public table_with_where_and_derived { int add_where_subquery(subquery_ctx *ctx, Query_expression *) override { return where_subqueries.push_back(ctx); } + virtual int add_gather(join_ctx *ctx, Query_expression *) { + return gather.push_back(ctx); + } }; /** @@ -893,6 +923,9 @@ class join_tab_ctx : public joinable_ctx, public table_with_where_and_derived { bool format_derived(Opt_trace_context *json) override { return table_with_where_and_derived::format_derived(json); } + virtual bool format_gather(Opt_trace_context *json) { + return table_with_where_and_derived::format_gather(json); + } bool format_where(Opt_trace_context *json) override { return table_with_where_and_derived::format_where(json); } @@ -921,6 +954,10 @@ class join_tab_ctx : public joinable_ctx, public table_with_where_and_derived { return -1; } + virtual int add_gather(join_ctx *ctx, Query_expression *subquery MY_ATTRIBUTE((unused))) { + return gather.push_back(ctx); + } + bool find_and_set_derived(context *subquery) override { if (query_block_id == subquery->id()) { derived_from.push_back(subquery); @@ -969,6 +1006,10 @@ class simple_sort_ctx : public joinable_ctx { return join_tab->add_where_subquery(ctx, subquery); } + virtual int add_gather(join_ctx *ctx, Query_expression *subquery) { + return join_tab->add_gather(ctx, subquery); + } + bool find_and_set_derived(context *subquery) override { return join_tab->find_and_set_derived(subquery); } @@ -1029,6 +1070,7 @@ class simple_sort_with_subqueries_ctx : public simple_sort_ctx { class join_ctx : public unit_ctx, virtual public qep_row { protected: List join_tabs; ///< hosted JOIN_TAB nodes + public: sort_ctx *sort; window_ctx *window; @@ -1078,6 +1120,10 @@ class join_ctx : public unit_ctx, virtual public qep_row { bool dependent() override; int add_where_subquery(subquery_ctx *ctx, Query_expression *subquery) override; + virtual int add_gather(join_ctx *ctx, Query_expression *subquery); + virtual size_t join_tabs_count() { return join_tabs.elements; } + virtual sort_ctx* get_sort() { return sort; } + virtual window_ctx* get_window() { return window; } }; /** @@ -1321,6 +1367,8 @@ bool join_ctx::format_body(Opt_trace_context *json, Opt_trace_object *obj) { Opt_trace_object insert_from(json, "insert_from"); if (format_body_inner(json, obj)) return true; /* purecov: inspected */ } + } else if (join_tabs.elements && (join_tabs.head()->get_mod_type() == MT_GATHER)) { + join_tabs.head()->format(json); } else if (format_body_inner(json, obj)) return true; /* purecov: inspected */ return format_query_expression(json); @@ -1451,6 +1499,22 @@ int join_ctx::add_where_subquery(subquery_ctx *ctx, return false; } +int join_ctx::add_gather(join_ctx *ctx, Query_expression *subquery) { + if (sort) + return sort->join_ctx::add_gather(ctx, subquery); + else if (window) + return window->join_ctx::add_gather(ctx, subquery); + + List_iterator it(join_tabs); + joinable_ctx *j; + while ((j = it++)) { + int ret = j->add_gather(ctx, subquery); + if (ret > 0) return true; + } + + return false; +} + /** Context class to group materialized JOIN_TABs to "materialized" array. Is used for semijoin materialization. @@ -1490,6 +1554,9 @@ class materialize_ctx : public joinable_ctx, Query_expression *subquery) override { return join_ctx::add_where_subquery(ctx, subquery); } + virtual int add_gather(join_ctx *ctx, Query_expression *subquery) { + return join_ctx::add_gather(ctx, subquery); + } bool find_and_set_derived(context *subquery) override { return join_ctx::find_and_set_derived(subquery); } @@ -1541,6 +1608,37 @@ class materialize_ctx : public joinable_ctx, } }; +bool table_with_where_and_derived::format_gather(Opt_trace_context *json) { + if (gather.elements == 0) + return false; + else if (gather.elements == 1) { + if (gather.head()->get_sort()) + return gather.head()->get_sort()->join_ctx::format(json); + else if (gather.head()->get_window()) + return gather.head()->get_window()->join_ctx::format(json); + else if (gather.head()->join_tabs_count()) { + return gather.head()->format(json); + } + } else { + Opt_trace_array loops(json, K_NESTED_LOOP); + + List_iterator it(gather); + context *c; + while ((c = it++)) { + Opt_trace_object anonymous_wrapper(json); + if (c->get_sort()) + return c->get_sort()->join_ctx::format(json); + else if (c->get_window()) + return c->get_window()->join_ctx::format(json); + else if (c->join_tabs_count() && c->format(json)) { + return true; + } + } + } + + return false; +} + /** Context class to represent JOIN_TABs in duplication weedout sequence */ @@ -1568,6 +1666,9 @@ class duplication_weedout_ctx : public joinable_ctx, public join_ctx { Query_expression *subquery) override { return join_ctx::add_where_subquery(ctx, subquery); } + virtual int add_gather(join_ctx *ctx, Query_expression *subquery) { + return join_ctx::add_gather(ctx, subquery); + } bool find_and_set_derived(context *subquery) override { return join_ctx::find_and_set_derived(subquery); } @@ -1691,7 +1792,7 @@ bool Explain_format_JSON::begin_context(enum_parsing_context ctx_arg, return true; break; case CTX_ORDER_BY: { - assert(current_context->type == CTX_JOIN); + assert(current_context->type == CTX_JOIN || current_context->type == CTX_GATHER); sort_ctx *ctx = new (*THR_MALLOC) sort_with_subqueries_ctx( CTX_ORDER_BY, K_ORDERING_OPERATION, current_context, SQ_ORDER_BY, flags, ESC_ORDER_BY); @@ -1704,7 +1805,8 @@ bool Explain_format_JSON::begin_context(enum_parsing_context ctx_arg, assert(current_context->type == CTX_JOIN || current_context->type == CTX_ORDER_BY || current_context->type == CTX_DISTINCT || - current_context->type == CTX_WINDOW); + current_context->type == CTX_WINDOW || + current_context->type == CTX_GATHER); sort_ctx *ctx = new (*THR_MALLOC) sort_with_subqueries_ctx( CTX_GROUP_BY, K_GROUPING_OPERATION, current_context, SQ_GROUP_BY, flags, ESC_GROUP_BY); @@ -1729,7 +1831,8 @@ bool Explain_format_JSON::begin_context(enum_parsing_context ctx_arg, current_context->type == CTX_ORDER_BY || current_context->type == CTX_DISTINCT || current_context->type == CTX_WINDOW || - current_context->type == CTX_GROUP_BY); + current_context->type == CTX_GROUP_BY || + current_context->type == CTX_GATHER); sort_ctx *ctx = new (*THR_MALLOC) sort_ctx(CTX_BUFFER_RESULT, K_BUFFER_RESULT, current_context, flags, ESC_BUFFER_RESULT); @@ -1749,7 +1852,8 @@ bool Explain_format_JSON::begin_context(enum_parsing_context ctx_arg, current_context->type == CTX_BUFFER_RESULT || current_context->type == CTX_SIMPLE_GROUP_BY || current_context->type == CTX_SIMPLE_ORDER_BY || - current_context->type == CTX_SIMPLE_DISTINCT); + current_context->type == CTX_SIMPLE_DISTINCT || + current_context->type == CTX_GATHER); join_tab_ctx *ctx = new (*THR_MALLOC) join_tab_ctx(CTX_QEP_TAB, current_context); if (ctx == nullptr || current_context->add_join_tab(ctx)) return true; @@ -1828,7 +1932,8 @@ bool Explain_format_JSON::begin_context(enum_parsing_context ctx_arg, current_context->type == CTX_DISTINCT || current_context->type == CTX_WINDOW || current_context->type == CTX_BUFFER_RESULT || - current_context->type == CTX_MATERIALIZATION); + current_context->type == CTX_MATERIALIZATION || + current_context->type == CTX_GATHER); duplication_weedout_ctx *ctx = new (*THR_MALLOC) duplication_weedout_ctx(current_context); if (ctx == nullptr || current_context->add_join_tab(ctx)) return true; @@ -1893,6 +1998,14 @@ bool Explain_format_JSON::begin_context(enum_parsing_context ctx_arg, current_context = ctx; break; } + case CTX_GATHER: { + join_ctx *ctx = + new (*THR_MALLOC) join_ctx(CTX_GATHER, K_QUERY_BLOCK, current_context); + if (ctx == nullptr || current_context->add_gather(ctx, subquery)) + return true; + current_context = ctx; + break; + } case CTX_HAVING: { subquery_ctx *ctx = new (*THR_MALLOC) subquery_ctx(CTX_HAVING, nullptr, current_context); diff --git a/sql/opt_explain_json.h b/sql/opt_explain_json.h index 340854273..5fd860fd7 100644 --- a/sql/opt_explain_json.h +++ b/sql/opt_explain_json.h @@ -1,4 +1,5 @@ /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -51,6 +52,7 @@ class Explain_format_JSON : public Explain_format { bool end_context(enum_parsing_context context) override; bool flush_entry() override { return false; } qep_row *entry() override; + bool is_json() const override { return true; } }; #endif // OPT_EXPLAIN_FORMAT_JSON_INCLUDED diff --git a/sql/opt_explain_traditional.cc b/sql/opt_explain_traditional.cc index 945cfacd2..b7fb916ff 100644 --- a/sql/opt_explain_traditional.cc +++ b/sql/opt_explain_traditional.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -79,11 +80,12 @@ static const char *traditional_extra_tags[ET_total] = { "Table function:", // ET_TABLE_FUNCTION "Index dive skipped due to FORCE", // ET_SKIP_RECORDS_IN_RANGE "Using secondary engine", // ET_USING_SECONDARY_ENGINE - "Rematerialize" // ET_REMATERIALIZE + "Rematerialize", // ET_REMATERIALIZE + "Parallel execute" // ET_PARALLEL_SCAN }; static const char *mod_type_name[] = {"NONE", "INSERT", "UPDATE", "DELETE", - "REPLACE"}; + "REPLACE", "SIMPLE"}; bool Explain_format_traditional::send_headers(Query_result *result) { return ((nil = new Item_null) == nullptr || @@ -251,6 +253,7 @@ bool Explain_format_traditional::flush_entry() { case ET_USING_JOIN_BUFFER: case ET_FIRST_MATCH: case ET_REMATERIALIZE: + case ET_PARALLEL_EXE: brackets = true; // for backward compatibility break; default: diff --git a/sql/opt_hints.cc b/sql/opt_hints.cc index af3b4e3bd..9233e67df 100644 --- a/sql/opt_hints.cc +++ b/sql/opt_hints.cc @@ -84,6 +84,8 @@ struct st_opt_hint_info opt_hint_info[] = { {"JOIN_INDEX", false, false, false}, {"GROUP_INDEX", false, false, false}, {"ORDER_INDEX", false, false, false}, + {"PQ", true, true, false}, + {"NO_PQ", true, true, false}, {"DERIVED_CONDITION_PUSHDOWN", true, true, false}, {nullptr, false, false, false}}; diff --git a/sql/opt_hints.h b/sql/opt_hints.h index 9b19e116c..5744b746e 100644 --- a/sql/opt_hints.h +++ b/sql/opt_hints.h @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -83,6 +84,8 @@ enum opt_hints_enum { JOIN_INDEX_HINT_ENUM, GROUP_INDEX_HINT_ENUM, ORDER_INDEX_HINT_ENUM, + PQ_HINT_ENUM, + NO_PQ_HINT_ENUM, DERIVED_CONDITION_PUSHDOWN_HINT_ENUM, MAX_HINT_ENUM }; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ec848bf6c..341a655f8 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -188,6 +189,7 @@ #include "sql/thr_malloc.h" #include "sql/uniques.h" // Unique #include "template_utils.h" +#include "pq_range.h" using std::max; using std::min; @@ -920,6 +922,74 @@ void QUICK_SELECT_I::trace_quick_description(Opt_trace_context *trace) { range_trace.add_utf8("used_index", range_info.ptr(), range_info.length()); } +bool QUICK_SELECT_I::pq_copy_from(THD *thd MY_ATTRIBUTE((unused)), + QUICK_SELECT_I *quick) { + records = quick->records; + cost_est.reset(); + cost_est += quick->cost_est; + max_used_key_length = quick->max_used_key_length; + used_key_parts = quick->used_key_parts; + forced_by_hint = quick->forced_by_hint; + last_rowid = quick->last_rowid; + return false; +} + +uint QUICK_RANGE_SELECT::quick_select_type() { return PQ_RANGE_SELECT; } + +QUICK_SELECT_I *QUICK_RANGE_SELECT::pq_clone(THD *thd, TABLE *table) { + bool create_err = false; + QUICK_SELECT_I *pq_quick = + new QUICK_RANGE_SELECT(thd, table, index, false, nullptr, &create_err); + if (create_err || pq_quick->pq_copy_from(thd, this) || pq_quick->init() || + DBUG_EVALUATE_IF("pq_clone_error1", true, false)) { + delete pq_quick; + return nullptr; + } + return pq_quick; +} + +// select *from t1 where a > 1 and a < 5; +bool QUICK_RANGE_SELECT::pq_copy_from(THD *thd, QUICK_SELECT_I *quick) { + QUICK_SELECT_I::pq_copy_from(thd, quick); + QUICK_RANGE_SELECT *quick_range_select = + dynamic_cast(quick); + assert(quick_range_select); + in_ror_merged_scan = quick_range_select->in_ror_merged_scan; + bitmap_copy(&column_bitmap, &quick_range_select->column_bitmap); + for (size_t ix = 0; ix < quick_range_select->ranges.size(); ++ix) { + QUICK_RANGE *orig = quick_range_select->ranges[ix]; + QUICK_RANGE *range = new (alloc.get()) + QUICK_RANGE(orig->min_key, orig->min_length, orig->min_keypart_map, + orig->max_key, orig->max_length, orig->max_keypart_map, + orig->flag, orig->rkey_func_flag); + if (!range) { + return true; + } + ranges.push_back(range); + } + + free_file = quick_range_select->free_file; + + /*Will init by reset: cur_range,last_range,qr_traversal_ctx,mrr_buf_desc */ + mrr_flags = quick_range_select->mrr_flags; + mrr_buf_size = quick_range_select->mrr_buf_size; + uint range_key_size = quick_range_select->used_key_parts; + + key_parts = (KEY_PART *)alloc->Alloc(sizeof(KEY_PART) * range_key_size); + if (!key_parts) { + return true; + } + memcpy(key_parts, quick_range_select->key_parts, + sizeof(KEY_PART) * range_key_size); + + for (uint i = 0; i < range_key_size; i++) { + key_parts[i].field = key_part_info[i].field; + } + + dont_free = quick_range_select->dont_free; + return false; +} + QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr, bool no_alloc, MEM_ROOT *parent_alloc, bool *create_error) @@ -1008,6 +1078,36 @@ QUICK_INDEX_MERGE_SELECT::QUICK_INDEX_MERGE_SELECT(THD *thd_param, TABLE *table) thd->variables.range_alloc_block_size, 0); } +bool QUICK_INDEX_MERGE_SELECT::pq_copy_from(THD *thd, QUICK_SELECT_I *quick) { + QUICK_SELECT_I::pq_copy_from(thd, quick); + QUICK_INDEX_MERGE_SELECT *quick_index_merge_select = + dynamic_cast(quick); + assert(quick_index_merge_select); + + List_iterator_fast it( + quick_index_merge_select->quick_selects); + QUICK_RANGE_SELECT *quick_select; + while ((quick_select = it++)) { + QUICK_SELECT_I *quick_select_new = quick_select->pq_clone(thd, head); + if (quick_select_new == nullptr) { + return true; + } + quick_selects.push_back((QUICK_RANGE_SELECT *)quick_select_new); + } + + return false; +} + +QUICK_SELECT_I *QUICK_INDEX_MERGE_SELECT::pq_clone(THD *thd, TABLE *tab) { + QUICK_SELECT_I *pq_quick = new QUICK_INDEX_MERGE_SELECT(thd, tab); + if (pq_quick->pq_copy_from(thd, this) || pq_quick->init()) { + delete pq_quick; + return nullptr; + } + + return pq_quick; +} + int QUICK_INDEX_MERGE_SELECT::init() { DBUG_TRACE; return 0; @@ -1289,6 +1389,37 @@ bool QUICK_ROR_INTERSECT_SELECT::push_quick_back(QUICK_RANGE_SELECT *quick) { return quick_selects.push_back(quick); } +bool QUICK_ROR_INTERSECT_SELECT::pq_copy_from(THD *thd, QUICK_SELECT_I* quick) { + QUICK_SELECT_I::pq_copy_from(thd, quick); + QUICK_ROR_INTERSECT_SELECT *quick_ror_intersect_select = dynamic_cast(quick); + assert(quick_ror_intersect_select); + scans_inited = quick_ror_intersect_select->scans_inited; + if (quick_ror_intersect_select->cpk_quick) { + cpk_quick = dynamic_cast(quick_ror_intersect_select->cpk_quick->pq_clone(thd, head)); + if (!cpk_quick) return true; + } + + List_iterator_fast it(quick_ror_intersect_select->quick_selects); + QUICK_RANGE_SELECT *orig_quick_range_select = nullptr; + QUICK_RANGE_SELECT *new_quick_range_select = nullptr; + while ((orig_quick_range_select = it++)) { + new_quick_range_select = dynamic_cast(orig_quick_range_select->pq_clone(thd, head)); + if (new_quick_range_select == nullptr) return true; + quick_selects.push_back(new_quick_range_select); + } + + return false; +} + +QUICK_SELECT_I* QUICK_ROR_INTERSECT_SELECT::pq_clone(THD *thd, TABLE *table) { + QUICK_SELECT_I *pq_quick = new QUICK_ROR_INTERSECT_SELECT(thd, table, need_to_fetch_row, NULL); + if (pq_quick->pq_copy_from(thd, this) || pq_quick->init()) { + delete pq_quick; + return nullptr; + } + return pq_quick; +} + QUICK_ROR_INTERSECT_SELECT::~QUICK_ROR_INTERSECT_SELECT() { DBUG_TRACE; quick_selects.delete_elements(); @@ -1393,6 +1524,36 @@ int QUICK_ROR_UNION_SELECT::reset() { return 0; } +bool QUICK_ROR_UNION_SELECT::pq_copy_from(THD *thd, QUICK_SELECT_I *quick) { + QUICK_SELECT_I::pq_copy_from(thd, quick); + QUICK_ROR_UNION_SELECT *quick_ror_union_select = + dynamic_cast(quick); + assert(quick_ror_union_select); + + List_iterator_fast it(quick_ror_union_select->quick_selects); + QUICK_SELECT_I *quick_select; + while ((quick_select = it++)) { + QUICK_SELECT_I *quick_select_new = quick_select->pq_clone(thd, head); + if (quick_select_new == nullptr) { + return true; + } + quick_selects.push_back(quick_select_new); + } + + return false; +} + +QUICK_SELECT_I* QUICK_ROR_UNION_SELECT::pq_clone(THD *thd, TABLE *table) { + QUICK_SELECT_I *pq_quick = + new QUICK_ROR_UNION_SELECT(thd, table); + if (pq_quick->pq_copy_from(thd, this) || + pq_quick->init() || DBUG_EVALUATE_IF("pq_clone_error1", true, false)) { + delete pq_quick; + return nullptr; + } + return pq_quick; +} + bool QUICK_ROR_UNION_SELECT::push_quick_back(QUICK_SELECT_I *quick_sel_range) { return quick_selects.push_back(quick_sel_range); } @@ -10285,6 +10446,27 @@ QUICK_SELECT_DESC::QUICK_SELECT_DESC(QUICK_RANGE_SELECT *q, q->dont_free = true; // Don't free shared mem } +QUICK_SELECT_I* QUICK_SELECT_DESC::pq_clone(THD* thd, TABLE* table) { + QUICK_RANGE_SELECT *quick_range_select = + dynamic_cast(this->QUICK_RANGE_SELECT::pq_clone(thd, table)); + if(!quick_range_select) { + return nullptr; + } + QUICK_SELECT_I *pq_quick = quick_range_select->make_reverse(m_used_key_parts); + delete quick_range_select; + if(!pq_quick || pq_quick->init()) { + if(pq_quick) { + delete pq_quick; + } + return nullptr; + } + return pq_quick; +} + +uint QUICK_SELECT_DESC::quick_select_type() { + return PQ_RANGE_SELECT; +} + int QUICK_SELECT_DESC::get_next() { DBUG_TRACE; diff --git a/sql/opt_range.h b/sql/opt_range.h index 58515d0af..049c8f260 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -264,6 +265,8 @@ class QUICK_SELECT_I { QUICK_SELECT_I(const QUICK_SELECT_I &) = default; virtual ~QUICK_SELECT_I() {} + virtual uint quick_select_type() { return PQ_QUICK_SELECT_NONE; } + /* Do post-constructor initialization. SYNOPSIS @@ -429,6 +432,9 @@ class QUICK_SELECT_I { */ virtual void get_fields_used(MY_BITMAP *used_fields) = 0; void trace_quick_description(Opt_trace_context *trace); + + virtual bool pq_copy_from(THD *thd,QUICK_SELECT_I*); + virtual QUICK_SELECT_I* pq_clone(THD *, TABLE*){ return nullptr; } }; class PARAM; @@ -516,6 +522,7 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I { MEM_ROOT *parent_alloc, bool *create_error); ~QUICK_RANGE_SELECT() override; + uint quick_select_type() override; void need_sorted_output() override; int init() override; int reset(void) override; @@ -544,6 +551,9 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I { bitmap_set_bit(used_fields, key_parts[i].field->field_index()); } + bool pq_copy_from(THD *thd, QUICK_SELECT_I*) override; + QUICK_SELECT_I* pq_clone(THD *thd, TABLE *table) override; + private: /* Default copy ctor used by QUICK_SELECT_DESC */ QUICK_RANGE_SELECT(const QUICK_RANGE_SELECT &) = default; @@ -637,6 +647,8 @@ class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I { void add_keys_and_lengths(String *key_names, String *used_lengths) override; void add_info_string(String *str) override; bool is_keys_used(const MY_BITMAP *fields) override; + virtual bool pq_copy_from(THD *thd, QUICK_SELECT_I* quick); + virtual QUICK_SELECT_I* pq_clone(THD *thd, TABLE *tab); #ifndef NDEBUG void dbug_dump(int indent, bool verbose) override; #endif @@ -725,6 +737,8 @@ class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I { #endif int init_ror_merged_scan(bool reuse_handler) override; bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range); + bool pq_copy_from(THD *thd, QUICK_SELECT_I*) override; + QUICK_SELECT_I* pq_clone(THD *thd, TABLE *table) override; /* Range quick selects this intersection consists of, not including @@ -811,6 +825,9 @@ class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I { void dbug_dump(int indent, bool verbose) override; #endif + bool pq_copy_from(THD *thd, QUICK_SELECT_I*) override; + QUICK_SELECT_I* pq_clone(THD *thd, TABLE *table) override; + bool push_quick_back(QUICK_SELECT_I *quick_sel_range); List quick_selects; /* Merged quick selects */ @@ -995,6 +1012,9 @@ class QUICK_SELECT_DESC : public QUICK_RANGE_SELECT { return this; // is already reverse sorted } + QUICK_SELECT_I* pq_clone(THD*, TABLE*); + uint quick_select_type() override; + private: bool range_reads_after_key(QUICK_RANGE *range); int reset(void) override { diff --git a/sql/parse_tree_hints.cc b/sql/parse_tree_hints.cc index b3413928b..8e0a35866 100644 --- a/sql/parse_tree_hints.cc +++ b/sql/parse_tree_hints.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -269,6 +270,15 @@ bool PT_qb_level_hint::contextualize(Parse_context *pc) { else pc->select->add_base_options(SELECT_STRAIGHT_JOIN); break; + case PQ_HINT_ENUM: + if (args > 0) + pc->thd->pq_dop = args; + else + pc->thd->pq_dop = pc->thd->variables.parallel_default_dop; + break; + case NO_PQ_HINT_ENUM: + pc->thd->no_pq = true; + break; default: assert(0); } diff --git a/sql/parse_tree_items.h b/sql/parse_tree_items.h index 254ecf576..6632f22d0 100644 --- a/sql/parse_tree_items.h +++ b/sql/parse_tree_items.h @@ -1,4 +1,5 @@ /* Copyright (c) 2013, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -161,6 +162,7 @@ class PTI_function_call_nonkeyword_now final : public Item_func_now_local { : super(pos, dec_arg) {} bool itemize(Parse_context *pc, Item **res) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class PTI_function_call_nonkeyword_sysdate : public Parse_tree_item { @@ -256,6 +258,7 @@ class PTI_text_literal_text_string : public PTI_text_literal { : super(pos, is_7bit_arg, literal_arg) {} bool itemize(Parse_context *pc, Item **res) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class PTI_text_literal_nchar_string : public PTI_text_literal { @@ -267,6 +270,7 @@ class PTI_text_literal_nchar_string : public PTI_text_literal { : super(pos, is_7bit_arg, literal_arg) {} bool itemize(Parse_context *pc, Item **res) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class PTI_text_literal_underscore_charset : public PTI_text_literal { @@ -289,6 +293,8 @@ class PTI_text_literal_underscore_charset : public PTI_text_literal { set_cs_specified(true); return false; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class PTI_text_literal_concat : public PTI_text_literal { @@ -341,6 +347,8 @@ class PTI_literal_underscore_charset_hex_num : public Item_string { set_cs_specified(true); return check_well_formed_result(&str_value, true, true) == nullptr; } + + Item *pq_clone(THD *thd, Query_block *select) override; }; class PTI_literal_underscore_charset_bin_num : public Item_string { @@ -379,6 +387,8 @@ class PTI_user_variable final : public Item_func_get_user_var { PTI_user_variable(const POS &pos, const LEX_STRING &var) : super(pos, var) {} bool itemize(Parse_context *pc, Item **res) override; + + Item *pq_clone(THD *thd, Query_block *select) override; }; /** @@ -415,6 +425,7 @@ class PTI_count_sym : public Item_sum_count { : super(pos, (Item *)nullptr, w) {} bool itemize(Parse_context *pc, Item **res) override; + Item *pq_clone(THD *thd, Query_block *select) override; }; class PTI_in_sum_expr : public Parse_tree_item { @@ -427,6 +438,7 @@ class PTI_in_sum_expr : public Parse_tree_item { : super(pos), expr(expr_arg) {} bool itemize(Parse_context *pc, Item **res) override; + Item *pq_clone(THD *, Query_block *) override { return this; } }; class PTI_singlerow_subselect : public Parse_tree_item { diff --git a/sql/parse_tree_node_base.h b/sql/parse_tree_node_base.h index dd550dc93..a2bbab370 100644 --- a/sql/parse_tree_node_base.h +++ b/sql/parse_tree_node_base.h @@ -1,4 +1,5 @@ /* Copyright (c) 2013, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -61,6 +62,7 @@ enum enum_parsing_context { CTX_INSERT_VALUES, ///< INSERT ... VALUES CTX_INSERT_UPDATE, ///< INSERT ... ON DUPLICATE KEY UPDATE ... CTX_JOIN, + CTX_GATHER, CTX_QEP_TAB, CTX_MATERIALIZATION, CTX_DUPLICATES_WEEDOUT, diff --git a/sql/parse_tree_nodes.cc b/sql/parse_tree_nodes.cc index d25cd950e..06ee91e57 100644 --- a/sql/parse_tree_nodes.cc +++ b/sql/parse_tree_nodes.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2013, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -1743,6 +1744,8 @@ bool PT_create_table_default_collation::contextualize( bool PT_locking_clause::contextualize(Parse_context *pc) { LEX *lex = pc->thd->lex; + pc->thd->locking_clause = true; + if (lex->is_explain()) return false; if (m_locked_row_action == Locked_row_action::SKIP) diff --git a/sql/pq_clone.cc b/sql/pq_clone.cc new file mode 100644 index 000000000..3e0e77e03 --- /dev/null +++ b/sql/pq_clone.cc @@ -0,0 +1,1215 @@ +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "sql/pq_clone.h" +#include "include/my_dbug.h" +#include "include/mysql/psi/mysql_thread.h" +#include "sql/mysqld.h" +#include "sql/opt_range.h" +#include "sql/sql_base.h" +#include "sql/sql_lex.h" +#include "sql/sql_opt_exec_shared.h" +#include "sql/sql_optimizer.h" +#include "sql/sql_parallel.h" +#include "sql/sql_resolver.h" +#include "sql/system_variables.h" + +class COND_CMP; +bool propagate_cond_constants(THD *thd, I_List *save_list, + Item *and_father, Item *cond); + +bool POSITION::pq_copy(THD *thd, POSITION *orig) { + rows_fetched = orig->rows_fetched; + read_cost = orig->read_cost; + filter_effect = orig->filter_effect; + prefix_rowcount = orig->prefix_rowcount; + prefix_cost = orig->prefix_cost; + table = orig->table; + if (orig->key) { + key = orig->key->pq_clone(thd); + if (key == nullptr) { + return true; + } + } else { + key = nullptr; + } + ref_depend_map = orig->ref_depend_map; + use_join_buffer = orig->use_join_buffer; + sj_strategy = orig->sj_strategy; + n_sj_tables = orig->n_sj_tables; + dups_producing_tables = orig->dups_producing_tables; + first_loosescan_table = orig->first_loosescan_table; + loosescan_need_tables = orig->loosescan_need_tables; + loosescan_key = orig->loosescan_key; + loosescan_parts = orig->loosescan_parts; + first_firstmatch_table = orig->first_firstmatch_table; + first_firstmatch_rtbl = orig->first_firstmatch_rtbl; + firstmatch_need_tables = orig->firstmatch_need_tables; + first_dupsweedout_table = orig->first_dupsweedout_table; + dupsweedout_tables = orig->dupsweedout_tables; + sjm_scan_last_inner = orig->sjm_scan_last_inner; + sjm_scan_need_tables = orig->sjm_scan_need_tables; + + return false; +} + +bool QEP_TAB::pq_copy(THD *thd, QEP_TAB *orig) { + set_type(orig->type()); + set_index(orig->index()); + set_first_inner(orig->first_inner()); + set_last_inner(orig->last_inner()); + set_first_sj_inner(orig->first_sj_inner()); + set_last_sj_inner(orig->last_sj_inner()); + keys().merge(orig->keys()); + m_reversed_access = orig->m_reversed_access; + do_parallel_scan = orig->do_parallel_scan; + firstmatch_return = orig->firstmatch_return; + cache_idx_cond = orig->cache_idx_cond; + loosescan_key_len = orig->loosescan_key_len; + POSITION *position = new (thd->pq_mem_root) POSITION; + if (!position || position->pq_copy(thd, orig->position())) { + return true; + } + + set_position(position); + if (orig->pq_cond) { + JOIN *join = this->join(); + if (join == nullptr) { + return true; + } + pq_cond = orig->pq_cond->pq_clone(join->thd, join->query_block); + if (pq_cond == nullptr) { + return true; + } + } + + return false; +} + +bool TABLE::pq_copy(THD *thd, void *select_arg, TABLE *orig) { + Query_block *select = static_cast(select_arg); + possible_quick_keys = orig->possible_quick_keys; + covering_keys = orig->covering_keys; + key_read = orig->key_read; + const_table = orig->const_table; + nullable = orig->nullable; + null_row = orig->null_row; + m_cost_model = orig->m_cost_model; + memcpy(record[0], orig->record[0], orig->s->rec_buff_length); + + reginfo = orig->reginfo; + + file->pushed_idx_cond_keyno = orig->file->pushed_idx_cond_keyno; + Item *index_pushdown = orig->file->pushed_idx_cond; + // needs deep copy + file->pushed_idx_cond = + index_pushdown ? index_pushdown->pq_clone(thd, select) : nullptr; + Item *copy_index_pushdown = file->pushed_idx_cond; + if ((index_pushdown && copy_index_pushdown == nullptr) || + (copy_index_pushdown && + copy_index_pushdown->fix_fields(thd, ©_index_pushdown))) { + return true; + } + + return false; +} + +/* + * copy table_ref info. + * + * @retval: + * false if copy successfully, and otherwise true. + */ +bool TABLE_REF::pq_copy(JOIN *join, TABLE_REF *ref, QEP_TAB *qep_tab) { + THD *thd = join->thd; + key_parts = ref->key_parts; + key_length = ref->key_length; + key_err = ref->key_err; + key = ref->key; + null_rejecting = ref->null_rejecting; + depend_map = ref->depend_map; + use_count = ref->use_count; + disable_cache = ref->disable_cache; + + if (!(key_buff = thd->pq_mem_root->ArrayAlloc(ALIGN_SIZE(key_length))) || + !(key_buff2 = + thd->pq_mem_root->ArrayAlloc(ALIGN_SIZE(key_length))) || + !(key_copy = thd->pq_mem_root->ArrayAlloc(key_parts)) || + !(items = thd->pq_mem_root->ArrayAlloc(key_parts)) || + !(cond_guards = thd->pq_mem_root->ArrayAlloc(key_parts))) { + return true; + } + + if (ref->null_ref_key != nullptr) { + null_ref_key = key_buff; + } + + memcpy(key_buff, ref->key_buff, ALIGN_SIZE(key_length)); + memcpy(key_buff2, ref->key_buff2, ALIGN_SIZE(key_length)); + uchar *key_buff_tmp = key_buff; + + for (uint i = 0; i < key_parts; i++) { + items[i] = ref->items[i]->pq_clone(thd, join->query_block); + if (items[i] == nullptr) { + return true; + } + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || items[i]); + if (!items[i]->fixed) { + items[i]->fix_fields(thd, &items[i]); + } + + if (qep_tab->table()->key_info) { + KEY *const keyinfo = qep_tab->table()->key_info + key; + bool maybe_null = keyinfo->key_part[i].null_bit; + qep_tab->position()->key->val = items[i]; + qep_tab->position()->key->used_tables = + qep_tab->position()->key->val->used_tables(); + if (ref->key_copy[i] != nullptr) { + key_copy[i] = get_store_key( + thd, qep_tab->position()->key->val, + qep_tab->position()->key->used_tables, join->const_table_map, + &keyinfo->key_part[i], key_buff_tmp, maybe_null); + } + + key_buff_tmp += keyinfo->key_part[i].store_length; + } + + if (!key_copy[i]) { + key_copy[i] = ref->key_copy[i]; + } + cond_guards[i] = ref->cond_guards[i]; + } + return false; +} +/* + * get table index + * + * @retval: + * -1 means not found. + */ +int get_qep_tab_index(QEP_TAB *src, TABLE_LIST *first_tbl) { + int index = 0; + for (TABLE_LIST *tl = first_tbl; tl != nullptr; tl = tl->next_leaf) { + if (src->table_ref == tl) { + return index; + } + index++; + } + return -1; +} + +TABLE_LIST *get_next_table(TABLE_LIST *start_table, + table_list_type_enum list_type) { + if (list_type == TABLE_LIST_TYPE_DEFAULT) { + return start_table->next_local; + } else if (list_type == TABLE_LIST_TYPE_LEAF) { + return start_table->next_leaf; + } else if (list_type == TABLE_LIST_TYPE_MERGE) { + return start_table->merge_underlying_list; + } else { + return start_table->next_global; + } + return nullptr; +} + +TABLE_LIST *get_table_by_index(TABLE_LIST *start_table, + table_list_type_enum list_type, int index) { + if (start_table == nullptr) { + return nullptr; + } + if (list_type == TABLE_LIST_TYPE_MERGE) { + start_table = start_table->merge_underlying_list; + } + int it = 0; + for (TABLE_LIST *tbl_list = start_table; tbl_list != nullptr; it++) { + if (it == index) { + return tbl_list; + } + tbl_list = get_next_table(tbl_list, list_type); + } + return nullptr; +} + +int get_qep_tab_index(QEP_TAB *tab, JOIN *join) { + for (uint i = 0; i < join->tables; i++) { + if (&join->qep_tab0[i] == tab) { + return i; + } + } + return -1; +} + +bool copy_flush(QEP_TAB *des, JOIN *orig, int index, JOIN *join) { + QEP_TAB *src = &orig->qep_tab[index]; + SJ_TMP_TABLE_TAB sjtabs[MAX_TABLES]; + SJ_TMP_TABLE_TAB *last_tab = sjtabs; + if (src->flush_weedout_table->tabs != nullptr) { + for (SJ_TMP_TABLE_TAB *t = src->flush_weedout_table->tabs; + t < src->flush_weedout_table->tabs_end; t++) { + int n = get_qep_tab_index(t->qep_tab, orig); + if (n == -1) { + return false; + } + last_tab->qep_tab = &join->qep_tab[n]; + ++last_tab; + } + } + + SJ_TMP_TABLE *sjtbl = create_sj_tmp_table(join->thd, join, sjtabs, last_tab); + des->flush_weedout_table = sjtbl; + QEP_TAB *start = &orig->qep_tab[index]; + int dis = 0; + for (uint i = index + 1; i < orig->tables; i++) { + QEP_TAB *t = &orig->qep_tab[i]; + if (t->check_weed_out_table == start->flush_weedout_table) { + dis = i - index; + break; + } + } + + QEP_TAB *last_sj_tab = des + dis; + last_sj_tab->check_weed_out_table = sjtbl; + return true; +} +/** + * duplicate qep_tabs in JOIN + * + * @join : target JOIN + * @orig : origin JOIN + * @setup : setup qep_tab object + * + */ +bool pq_dup_tabs(JOIN *join, JOIN *orig, bool setup MY_ATTRIBUTE((unused))) { + Item *m_having_cond = nullptr; + + join->const_tables = orig->const_tables; + join->primary_tables = orig->primary_tables; + Query_block *select = join->query_block; + + // phase 1. Create qep_tab and qep_tab->qs; + QEP_shared *qs = new (join->thd->pq_mem_root) QEP_shared[join->tables + 1]; + if (qs == nullptr) { + goto err; + } + join->qep_tab0 = new (join->thd->pq_mem_root) QEP_TAB[join->tables + 1]; + if (join->qep_tab0 == nullptr) { + goto err; + } + join->qep_tab = join->qep_tab0; + + for (uint i = 0; i < join->tables; i++) { + join->qep_tab[i].set_qs(&qs[i]); + join->qep_tab[i].set_join(join); + join->qep_tab[i].set_idx(i); + join->qep_tab[i].match_tab = orig->qep_tab[i].match_tab; + join->qep_tab[i].flush_weedout_table = orig->qep_tab[i].flush_weedout_table; + join->qep_tab[i].check_weed_out_table = + orig->qep_tab[i].check_weed_out_table; + join->qep_tab[i].op_type = orig->qep_tab[i].op_type; + join->qep_tab[i].table_ref = orig->qep_tab[i].table_ref; + join->qep_tab[i].using_dynamic_range = orig->qep_tab[i].using_dynamic_range; + } + + for (uint i = 0; i < join->primary_tables; i++) { + QEP_TAB *tab = &join->qep_tab[i]; + QEP_TAB *orig_tab = &orig->qep_tab[i]; + + // phase 3. Set tables to qep_tab according to db/table name + if (tab->pq_copy(join->thd, orig_tab)) { + goto err; + } + TABLE *tb = orig_tab->table(); + tab->table_name = new (join->thd->pq_mem_root) + LEX_CSTRING{tb->s->table_name.str, tb->s->table_name.length}; + + tab->db = new (join->thd->pq_mem_root) + LEX_CSTRING{tb->s->db.str, tb->s->db.length}; + if (tab->table_name == nullptr || tab->db == nullptr) { + goto err; + } + + /* + * note: currently, setup is true. + * Because duplicate qep_tabs in JOIN need fix_field to convert item to + * field. + */ + assert(select->leaf_tables); + /* + * setup physic table object + * Sometimes there are multiple tables with the same name in the + * leaf_tables, such as select empnum from t1 where hours in (select hours + * from t1); The leaf_tables has two t1's in it,at this point we need to + * copy the corresponding table of the same name. + */ + int index = get_qep_tab_index(orig_tab, orig->query_block->leaf_tables); + if (index == -1) { + goto err; + } + TABLE_LIST *tl = + get_table_by_index(select->leaf_tables, TABLE_LIST_TYPE_LEAF, index); + if (tl == nullptr) { + goto err; + } + bitmap_copy(tl->table->read_set, tab->table_ref->table->read_set); + bitmap_copy(tl->table->write_set, tab->table_ref->table->write_set); + tab->set_table(tl->table); + tab->table_ref = tl; + + // phase 4. Copy table properties from leader + if (tab->ref().pq_copy(join, &orig_tab->ref(), tab)) { + goto err; + } + + if (orig_tab->table()) { + if (tab->table()->pq_copy(join->thd, (void *)select, orig_tab->table())) { + goto err; + } + tab->set_keyread_optim(); + } + + // phase 2. clone conditions in qep_tab + Item *condition = orig_tab->condition(); + if ((condition != nullptr) && i < orig->primary_tables) { + Item *cond = condition->pq_clone(join->thd, select); + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || cond); + if (cond == nullptr) { + goto err; + } + if (cond->fix_fields(join->thd, &cond)) { + goto err; + } + tab->set_condition(cond); + tab->set_condition_optim(); + } + + // phase 2. clone cache_idx_cond in qep_tab + Item *cache_idx_cond = orig_tab->cache_idx_cond; + if ((cache_idx_cond != nullptr) && i < orig->primary_tables) { + Item *cond = cache_idx_cond->pq_clone(join->thd, select); + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || cond); + if (cond == nullptr) { + goto err; + } + if (cond->fix_fields(join->thd, &cond)) { + goto err; + } + tab->cache_idx_cond = cond; + } + + // phase 5. setup pq condition for index push down + if ((tab->has_pq_cond && !tab->pq_cond) || + (tab->pq_cond && tab->pq_cond->fix_fields(join->thd, &tab->pq_cond)) || + DBUG_EVALUATE_IF("pq_clone_error2", true, false)) { + sql_print_warning("[Parallel query]: ICP condition pushdown failed"); + goto err; + } + + // phase 6. copy quick select + MEM_ROOT *saved_mem_root = join->thd->mem_root; + if (orig_tab->quick()) { + QUICK_SELECT_I *quick = + orig_tab->quick()->pq_clone(join->thd, tab->table()); + assert(DBUG_EVALUATE_IF("pq_clone_error1", true, false) || quick); + if (quick == nullptr) { + goto err; + } + tab->set_quick(quick); + tab->set_quick_optim(); + } + join->thd->mem_root = saved_mem_root; + } + + // phase 7. Copy having condition + m_having_cond = select->having_cond(); + if (m_having_cond) { + assert(m_having_cond->is_bool_func()); + join->thd->where = "having clause"; + select->having_fix_field = true; + select->resolve_place = Query_block::RESOLVE_HAVING; + if (!m_having_cond->fixed && + (m_having_cond->fix_fields(join->thd, &m_having_cond) || + m_having_cond->check_cols(1))) { + goto err; + } + + select->having_fix_field = false; + select->resolve_place = Query_block::RESOLVE_NONE; + } + + for (uint i = 0; i < join->tables; i++) { + QEP_TAB *t = &orig->qep_tab[i]; + if (t->flush_weedout_table != nullptr) { + if (!copy_flush(&join->qep_tab[i], orig, i, join)) { + goto err; + } + } + } + return false; + +err: + return true; +} + +/* + * clone order structure + */ +ORDER *pq_dup_order(THD *thd, Query_block *select, ORDER *orig) { + ORDER *order = new (thd->pq_mem_root) ORDER(); + if (order == nullptr) { + return nullptr; + } + + if ((*orig->item)->is_derived_used() || !orig->in_field_list) { + order->item_initial = (*orig->item)->pq_clone(thd, select); + } else { + order->item_initial = orig->item_initial->pq_clone(thd, select); + } + + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || + order->item_initial); + if (order->item_initial == nullptr) { + return nullptr; + } + + order->next = nullptr; + order->item = &order->item_initial; + order->direction = orig->direction; + order->in_field_list = orig->in_field_list; + order->used_alias = orig->used_alias; + order->field_in_tmp_table = nullptr; + order->buff = nullptr; + order->used = 0; + order->depend_map = 0; + order->is_position = orig->is_position; + order->is_explicit = orig->is_explicit; + + return order; +} + +int get_table_index(TABLE_LIST *start_table, table_list_type_enum list_type, + TABLE_LIST *tl) { + if (start_table == nullptr) { + return -1; + } + int index = 0; + for (TABLE_LIST *tbl_list = start_table; tbl_list != nullptr; index++) { + if (tbl_list == tl) { + return index; + } + tbl_list = get_next_table(tbl_list, list_type); + } + return -1; +} + +TABLE_LIST *copy_table(THD *thd, TABLE_LIST *src, Query_block *select, + Query_block *orig) { + TABLE_LIST *ptr = new (thd->mem_root) TABLE_LIST; + if (ptr == nullptr) { + return nullptr; + } + ptr->query_block = select; + ptr->derived = src->derived; + ptr->effective_algorithm = src->effective_algorithm; + ptr->outer_join = src->outer_join; + if (src->merge_underlying_list != nullptr) { + TABLE_LIST *foundtable = nullptr; + int index = get_table_index(orig->leaf_tables, TABLE_LIST_TYPE_GLOBAL, + src->merge_underlying_list); + if (index != -1) { + foundtable = get_table_by_index(select->leaf_tables, + TABLE_LIST_TYPE_GLOBAL, index); + if (foundtable == nullptr) { + return nullptr; + } + ptr->merge_underlying_list = foundtable; + } else { + ptr->merge_underlying_list = + copy_table(thd, src->merge_underlying_list, select, orig); + } + } + ptr->field_translation = nullptr; + ptr->table_name = src->table_name; + ptr->table_name_length = src->table_name_length; + ptr->alias = src->alias; + ptr->is_alias = src->is_alias; + ptr->table_function = src->table_function; + if (src->table_function) { + ptr->derived_key_list.clear(); + } + ptr->is_fqtn = src->is_fqtn; + ptr->db = src->db; + ptr->db_length = src->db_length; + ptr->set_tableno(src->tableno()); + ptr->set_lock({TL_UNLOCK, THR_DEFAULT}); + ptr->updating = false; + ptr->ignore_leaves = false; + ptr->is_system_view = src->is_system_view; + + if (!ptr->is_derived() && !ptr->is_table_function() && + is_infoschema_db(ptr->db, ptr->db_length)) { + dd::info_schema::convert_table_name_case( + const_cast(ptr->db), const_cast(ptr->table_name)); + ST_SCHEMA_TABLE *schema_table = nullptr; + if (!ptr->is_system_view) { + schema_table = find_schema_table(thd, ptr->table_name); + if (schema_table) { + ptr->schema_table = schema_table; + } + } + } + ptr->cacheable_table = true; + ptr->index_hints = nullptr; + ptr->option = nullptr; + ptr->next_name_resolution_table = nullptr; + ptr->partition_names = nullptr; + MDL_REQUEST_INIT(&ptr->mdl_request, MDL_key::TABLE, ptr->db, ptr->table_name, + MDL_SHARED_READ, MDL_TRANSACTION); + return ptr; +} + +bool copy_table_field(TABLE_LIST *src, TABLE_LIST *des, THD *thd, + Query_block *dest_select) { + int count = src->field_translation_end - src->field_translation; + if (count <= 0) { + return false; + } + if (des->field_translation_end - des->field_translation != count) { + return true; + } + if (des->field_translation[0].item != nullptr) { + return false; + } + for (int i = 0; i < count; i++) { + des->field_translation[i].name = src->field_translation[i].name; + if (src->field_translation[i].item == nullptr) { + return true; + } + des->field_translation[i].item = + src->field_translation[i].item->pq_clone(thd, dest_select); + if (des->field_translation[i].item == nullptr) { + return true; + } + } + return false; +} + +bool copy_merge_table_field(THD *thd, Query_block *dest_select, int tableindex, + int mergeindex, TABLE_LIST *srctb) { + TABLE_LIST *tb = get_table_by_index(dest_select->table_list.first, + TABLE_LIST_TYPE_DEFAULT, tableindex); + if (tb == nullptr) { + return true; + } + TABLE_LIST *mergetable = + get_table_by_index(tb, TABLE_LIST_TYPE_MERGE, mergeindex); + if (mergetable == nullptr) { + return true; + } + if (copy_table_field(srctb, mergetable, thd, dest_select)) { + return true; + } + return false; +} + +bool copy_global_table_list_field(THD *thd, Query_block *orig, + Query_block *dest_select) { + int tableindex = 0; + for (TABLE_LIST *tbl_list = orig->leaf_tables; tbl_list != nullptr; + tbl_list = tbl_list->next_global) { + if (tbl_list->field_translation != nullptr) { + TABLE_LIST *src = get_table_by_index(dest_select->leaf_tables, + TABLE_LIST_TYPE_GLOBAL, tableindex); + if (src == nullptr) { + return true; + } + if (copy_table_field(tbl_list, src, thd, dest_select)) { + return true; + } + } + tableindex++; + } + return false; +} + +bool init_table_field_space(THD *thd, TABLE_LIST *src, TABLE_LIST *des) { + int count = src->field_translation_end - src->field_translation; + if (count > 0 && des->field_translation == nullptr) { + Field_translator *transl = (Field_translator *)thd->stmt_arena->alloc( + count * sizeof(Field_translator)); + if (transl == nullptr) { + return true; + } + for (int i = 0; i < count; i++) { + transl[i].name = nullptr; + transl[i].item = nullptr; + } + des->field_translation = transl; + des->field_translation_end = transl + count; + } + return false; +} + +bool copy_leaf_tables(THD *thd, Query_block *orig, Query_block *dest_select) { + TABLE_LIST *last = nullptr; + dest_select->leaf_tables = nullptr; + for (TABLE_LIST *tbl_list = orig->leaf_tables; tbl_list != nullptr; + tbl_list = tbl_list->next_leaf) { + TABLE_LIST *tl = copy_table(thd, tbl_list, dest_select, orig); + if (tl == nullptr) { + return true; + } + if (dest_select->leaf_tables == nullptr) { + dest_select->leaf_tables = tl; + last = tl; + } else { + last->next_name_resolution_table = tl; + last->next_leaf = tl; + last = tl; + } + } + last->next_leaf = nullptr; + return false; +} + +void set_up_leaf_tables(THD *thd, Query_block *select) { + select->partitioned_table_count = 0; + for (TABLE_LIST *tr = select->leaf_tables; tr != nullptr; + tr = tr->next_leaf) { + TABLE *const table = tr->table; + select->leaf_table_count++; + if (select->first_execution && + select->opt_hints_qb && // QB hints initialized + !tr->opt_hints_table) // Table hints are not adjusted yet + { + tr->opt_hints_table = select->opt_hints_qb->adjust_table_hints(tr); + } + if (table == nullptr) { + continue; + } + table->pos_in_table_list = tr; + } + if (select->opt_hints_qb) { + select->opt_hints_qb->check_unresolved(thd); + } +} + +bool copy_global_tables(THD *thd, Query_block *orig, Query_block *dest_select) { + for (TABLE_LIST *tbl_list = orig->leaf_tables; tbl_list != nullptr; + tbl_list = tbl_list->next_global) { + int index = + get_table_index(orig->leaf_tables, TABLE_LIST_TYPE_LEAF, tbl_list); + TABLE_LIST *tmp = nullptr; + if (index != -1) { + tmp = get_table_by_index(dest_select->leaf_tables, TABLE_LIST_TYPE_LEAF, + index); + } else { + tmp = copy_table(thd, tbl_list, dest_select, orig); + } + if (tmp == nullptr) { + return true; + } + thd->lex->add_to_query_tables(tmp); + } + return false; +} + +bool copy_table_list(THD *thd, Query_block *orig, Query_block *dest_select) { + for (TABLE_LIST *tbl_list = orig->table_list.first; tbl_list != nullptr; + tbl_list = tbl_list->next_local) { + int index = + get_table_index(orig->leaf_tables, TABLE_LIST_TYPE_GLOBAL, tbl_list); + TABLE_LIST *tmp = nullptr; + if (index != -1) { + tmp = get_table_by_index(dest_select->leaf_tables, TABLE_LIST_TYPE_GLOBAL, + index); + } else { + tmp = copy_table(thd, tbl_list, dest_select, orig); + } + if (tmp == nullptr) { + return true; + } + dest_select->table_list.link_in_list(tmp, &tmp->next_local); + } + return false; +} + +bool init_table_list_field_space(THD *thd, Query_block *select, + table_list_type_enum list_type) { + TABLE_LIST *start_src = nullptr; + TABLE_LIST *start_des = nullptr; + if (list_type == TABLE_LIST_TYPE_DEFAULT) { + start_src = select->orig->table_list.first; + start_des = select->table_list.first; + } else { + start_src = select->orig->leaf_tables; + start_des = select->leaf_tables; + } + int tableindex = 0; + for (TABLE_LIST *tbl_list = start_src; tbl_list != nullptr; tableindex++) { + if (tbl_list->field_translation != nullptr) { + TABLE_LIST *des = get_table_by_index(start_des, list_type, tableindex); + if (des == nullptr) { + return true; + } + if (init_table_field_space(thd, tbl_list, des)) { + return true; + } + } + tbl_list = get_next_table(tbl_list, list_type); + } + return false; +} +bool init_field_space(THD *thd, Query_block *orig, Query_block *select) { + if (init_table_list_field_space(thd, select, TABLE_LIST_TYPE_DEFAULT) || + init_table_list_field_space(thd, select, TABLE_LIST_TYPE_GLOBAL)) { + return true; + } + + int tableindex = 0; + for (TABLE_LIST *tbl_list = orig->table_list.first; tbl_list != nullptr; + tbl_list = tbl_list->next_local) { + if (tbl_list->merge_underlying_list != nullptr) { + int mergeindex = 0; + for (TABLE_LIST *tb = tbl_list->merge_underlying_list; tb != nullptr; + tb = tb->merge_underlying_list) { + if (tb->field_translation != nullptr) { + TABLE_LIST *ta = get_table_by_index( + select->table_list.first, TABLE_LIST_TYPE_DEFAULT, tableindex); + if (ta == nullptr) { + return true; + } + TABLE_LIST *mergetable = + get_table_by_index(ta, TABLE_LIST_TYPE_MERGE, mergeindex); + if (mergetable == nullptr) { + return true; + } + if (init_table_field_space(thd, tb, mergetable)) { + return true; + } + } + mergeindex++; + } + } + tableindex++; + } + return false; +} + +bool copy_merge_table_list_field(THD *thd, Query_block *orig, + Query_block *dest_select) { + int tableindex = 0; + int mergeindex = 0; + for (TABLE_LIST *tbl_list = orig->table_list.first; tbl_list != nullptr; + tbl_list = tbl_list->next_local) { + if (tbl_list->merge_underlying_list != nullptr) { + mergeindex = 0; + for (TABLE_LIST *tb = tbl_list->merge_underlying_list; tb != nullptr; + tb = tb->merge_underlying_list) { + if (tb->field_translation != nullptr && + copy_merge_table_field(thd, dest_select, tableindex, mergeindex, + tb)) { + return true; + } + mergeindex++; + } + } + tableindex++; + } + return false; +} + +bool copy_table_list_field(THD *thd, Query_block *orig, + Query_block *dest_select) { + int tableindex = 0; + for (TABLE_LIST *tbl_list = orig->table_list.first; tbl_list != nullptr; + tbl_list = tbl_list->next_local) { + if (tbl_list->field_translation != nullptr) { + TABLE_LIST *src = get_table_by_index(dest_select->table_list.first, + TABLE_LIST_TYPE_DEFAULT, tableindex); + if (src == nullptr) { + return true; + } + if (copy_table_field(tbl_list, src, thd, dest_select)) { + return true; + } + } + tableindex++; + } + return false; +} + +bool copy_all_table_list(THD *thd, Query_block *orig, + Query_block *dest_select) { + if (copy_leaf_tables(thd, orig, dest_select) || + copy_global_tables(thd, orig, dest_select) || + copy_table_list(thd, orig, dest_select)) { + return true; + } + if (init_field_space(thd, orig, dest_select) || + copy_merge_table_list_field(thd, orig, dest_select) || + copy_global_table_list_field(thd, orig, dest_select) || + copy_table_list_field(thd, orig, dest_select)) { + return true; + } + return false; +} + +Query_block *pq_dup_select(THD *thd, Query_block *orig) { + Item *new_item = nullptr; + Item *where = nullptr; + Item *having = nullptr; + ORDER *group = nullptr; + ORDER *group_new = nullptr; + ORDER *order = nullptr; + ORDER *order_new = nullptr; + Query_block *select = nullptr; + SQL_I_List orig_list; + + LEX *lex = new (thd->pq_mem_root) LEX(); + if (lex == nullptr) { + goto err; + } + lex->reset(); + lex->result = orig->parent_lex->result; + lex->sql_command = orig->parent_lex->sql_command; + lex->explain_format = orig->parent_lex->explain_format; + lex->is_explain_analyze = orig->parent_lex->is_explain_analyze; + thd->lex = lex; + lex->thd = thd; + thd->query_plan.set_query_plan(SQLCOM_SELECT, lex, false); + + select = lex->new_query(nullptr); + if (!select || DBUG_EVALUATE_IF("dup_select_abort1", true, false)) { + goto err; + } + select->orig = orig; + select->renumber(thd->lex); + select->with_sum_func = orig->with_sum_func; + select->n_child_sum_items = orig->n_child_sum_items; + select->n_sum_items = orig->n_sum_items; + select->select_n_having_items = orig->select_n_having_items; + select->select_n_where_fields = orig->select_n_where_fields; + select->m_active_options = orig->m_active_options; + lex->set_current_query_block(select); + lex->unit = select->master_query_expression(); + thd->lex->query_block = select; + + // phase 1. clone tables and open/lock them + if (copy_all_table_list(thd, orig, select)) { + goto err; + } + + assert(select->context.query_block == select); + select->context.table_list = select->context.first_name_resolution_table = + select->leaf_tables; + + // phase 1. open tables and lock them + if (open_tables_for_query(thd, thd->lex->query_tables, 0) || + lock_tables(thd, thd->lex->query_tables, thd->lex->table_count, 0)) { + goto err; + } + set_up_leaf_tables(thd, select); + // phase 1. copy table->nullable + // before setup_fields, propagate_nullability will change table->nullable, + // which may affect item->maybe_null, so we copy it here. + // see in Query_block:: prepare + for (TABLE_LIST *tl = orig->leaf_tables; tl != nullptr; tl = tl->next_leaf) { + for (TABLE_LIST *tbl_list = select->leaf_tables; tbl_list != nullptr; + tbl_list = tbl_list->next_leaf) { + const char *db = tbl_list->db; + const char *table_name = tbl_list->table_name; + const char *alias = tbl_list->alias; + + if (!strncmp(db, tl->db, strlen(db)) && strlen(tl->db) == strlen(db) && + !strncmp(table_name, tl->table_name, strlen(table_name)) && + strlen(tl->table_name) == strlen(table_name) && + !strncmp(alias, tl->alias, strlen(alias)) && + strlen(tl->alias) == strlen(alias)) { + if (tl->table != nullptr && tl->table->is_nullable()) { + tbl_list->table->set_nullable(); + } + break; + } + } + } + + // phase 2. clone select fields list + for (Item *item : orig->fields) { + if (item->hidden) { + continue; + } + new_item = item->pq_clone(thd, select); + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || new_item); + if (new_item == nullptr) { + goto err; + } + + select->fields.push_back(new_item); + } + + // phase 3. duplicate group list + /* + * for template select_lex, we use leader's saved_group_list_ptrs to + * restore original group_list, and then copy it to template. For + * worker's select_lex, we directly use template's info to generate + * its group_list. + */ + if (orig->saved_group_list_ptrs) { + restore_list(orig->saved_group_list_ptrs, orig_list); + assert(orig_list.elements == orig->group_list.elements); + } else { // the case of template select_lex + orig_list = orig->group_list; + } + + // duplicate group list + if (orig_list.elements) { + for (group = orig_list.first; group; group = group->next) { + group_new = pq_dup_order(thd, select, group); + if (group_new == nullptr) { + goto err; + } + + select->group_list.link_in_list(group_new, &group_new->next); + } + } + + if (orig->saved_order_list_ptrs) { + restore_list(orig->saved_order_list_ptrs, orig_list); + assert(orig_list.elements == orig->order_list.elements); + } else { // the case of template select_lex + orig_list = orig->order_list; + } + + // duplicate order list + if (orig_list.elements) { + for (order = orig_list.first; order; order = order->next) { + order_new = pq_dup_order(thd, select, order); + if (order_new == nullptr) { + goto err; + } + + select->order_list.link_in_list(order_new, &order_new->next); + } + } + + /** mianly used for optimized_group_by */ + if (select->group_list.elements) { + select->fix_prepare_information_for_order(thd, &select->group_list, + &select->saved_group_list_ptrs); + } + if (select->order_list.elements) { + select->fix_prepare_information_for_order(thd, &select->order_list, + &select->saved_order_list_ptrs); + } + + if (select->setup_base_ref_items(thd) || + DBUG_EVALUATE_IF("dup_select_abort2", true, false)) { + goto err; + } + + thd->mark_used_columns = MARK_COLUMNS_READ; + + // phase 5. duplicate where cond + if (orig->where_cond()) { + where = orig->where_cond()->pq_clone(thd, select); + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || where); + if (where == nullptr) { + goto err; + } + select->set_where_cond(where); + } else { + select->set_where_cond(nullptr); + } + + // phase 6. duplicate having cond + if (orig->having_cond()) { + having = orig->having_cond()->pq_clone(thd, select); + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || having); + if (having == nullptr) { + goto err; + } + select->set_having_cond(having); + } else { + select->set_having_cond(nullptr); + } + + // phase 7: allow local set functions in HAVING and ORDER BY + lex->allow_sum_func |= (nesting_map)1 << (nesting_map)select->nest_level; + select->set_query_result(lex->result); + return select; + +err: + return nullptr; +} + +/** + * resolve query block, setup tables list, fields list, group list\order list + * + * @select: query block + * + */ +static bool pq_select_prepare(THD *thd, Query_block *select, + mem_root_deque &orig_all_fields) { + // Setup.1 setup all fields + int all_fields_count = select->fields.size(); + thd->mark_used_columns = MARK_COLUMNS_READ; + ulong want_privilege = 0; + if (setup_fields(thd, want_privilege, true, true, false, nullptr, + &select->fields, select->base_ref_items, true)) { + return true; + } + + // Setup.2 setup GROUP BY clause + if (select->group_list.elements && select->setup_group(thd)) { + return true; + } + select->hidden_group_field_count = select->fields.size() - all_fields_count; + + // Setup.3 setup ORDER BY clause + if (select->order_list.elements && + setup_order(thd, select->base_ref_items, select->table_list.first, + &select->fields, select->order_list.first)) { + return true; + } + + select->hidden_order_field_count = select->fields.size() - all_fields_count; + + if (select->order_list.elements && select->setup_order_final(thd)) { + return true; + } + + // Setup.4: check item's property */ + if (select->fields.size() != orig_all_fields.size()) { + return true; + } + + Item *orig_item = nullptr; + uint i = 0; + for (Item *item : select->fields) { + orig_item = orig_all_fields[i]; + if (item == nullptr || (item->type() != orig_item->type())) return true; + i++; + } + + return false; +} + +JOIN *pq_make_join(THD *thd, JOIN *join) { + JOIN *pq_join = nullptr; + Query_block *select = pq_dup_select(thd, join->query_block); + if (!select || pq_select_prepare(thd, select, join->query_block->fields)) { + goto err; + } + + thd->lex->unit->set_prepared(); + + pq_join = new (thd->pq_mem_root) JOIN(thd, select); + if (!pq_join || DBUG_EVALUATE_IF("dup_join_abort", true, false)) { + goto err; + } + pq_join->pq_copy_from(join); + /** + * limit cannot push down to worker, for the cases: + * (1) with aggregation + * (2) with sorting after optimized-group-by + */ + if (join->query_expression()->select_limit_cnt) { + if (join->query_block->with_sum_func || // c1 + (join->pq_rebuilt_group && // c2 + join->pq_last_sort_idx >= (int)join->primary_tables)) { + pq_join->m_select_limit = HA_POS_ERROR; // no limit + pq_join->query_expression()->select_limit_cnt = HA_POS_ERROR; + } + } + return pq_join; + +err: + return nullptr; +} + +bool System_variables::pq_copy_from(struct System_variables orig) { + pseudo_thread_id = orig.pseudo_thread_id; + sql_mode = orig.sql_mode; + collation_connection = orig.collation_connection; + div_precincrement = orig.div_precincrement; + time_zone = orig.time_zone; + big_tables = orig.big_tables; + lc_time_names = orig.lc_time_names; + my_aes_mode = orig.my_aes_mode; + transaction_isolation = orig.transaction_isolation; + option_bits = orig.option_bits; + explicit_defaults_for_timestamp = orig.explicit_defaults_for_timestamp; + sortbuff_size = orig.sortbuff_size; + join_buff_size = orig.join_buff_size; + return false; +} + +bool System_status_var::pq_merge_status(struct System_status_var worker) { + filesort_range_count += worker.filesort_range_count; + filesort_rows += worker.filesort_rows; + filesort_scan_count += worker.filesort_scan_count; + + ha_read_first_count += worker.ha_read_first_count; + ha_read_last_count += worker.ha_read_last_count; + ha_read_key_count += worker.ha_read_key_count; + ha_read_next_count += worker.ha_read_next_count; + ha_read_prev_count += worker.ha_read_prev_count; + ha_read_rnd_count += worker.ha_read_rnd_count; + ha_read_rnd_next_count += worker.ha_read_rnd_next_count; + return false; +} + +bool THD::pq_copy_from(THD *thd) { + variables.pq_copy_from(thd->variables); + start_time = thd->start_time; + user_time = thd->user_time; + m_query_string = thd->m_query_string; + tx_isolation = thd->tx_isolation; + tx_read_only = thd->tx_read_only; + parallel_exec = thd->parallel_exec; + pq_dop = thd->pq_dop; + arg_of_last_insert_id_function = thd->arg_of_last_insert_id_function; + first_successful_insert_id_in_prev_stmt = + thd->first_successful_insert_id_in_prev_stmt; + first_successful_insert_id_in_prev_stmt_for_binlog = + thd->first_successful_insert_id_in_prev_stmt_for_binlog; + first_successful_insert_id_in_cur_stmt = + thd->first_successful_insert_id_in_cur_stmt; + stmt_depends_on_first_successful_insert_id_in_prev_stmt = + thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt; + return false; +} + +bool THD::pq_merge_status(THD *thd) { + status_var.pq_merge_status(thd->status_var); + current_found_rows += thd->current_found_rows; + pq_current_found_rows = thd->current_found_rows; + m_examined_row_count += thd->m_examined_row_count; + return false; +} + +bool THD::pq_status_reset() { + current_found_rows = 0; + m_examined_row_count = 0; + return false; +} diff --git a/sql/pq_clone.h b/sql/pq_clone.h new file mode 100644 index 000000000..9cbcac801 --- /dev/null +++ b/sql/pq_clone.h @@ -0,0 +1,58 @@ +#ifndef PQ_CLONE_INCLUDE_H +#define PQ_CLONE_INCLUDE_H + +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "sql/sql_list.h" +class Item; +class Item_ident; +class THD; +class Query_block; +class JOIN; +class ORDER; +class ORDER_with_src; +class TABLE_LIST; +enum table_list_type_enum { + TABLE_LIST_TYPE_DEFAULT, + TABLE_LIST_TYPE_LEAF, + TABLE_LIST_TYPE_GLOBAL, + TABLE_LIST_TYPE_MERGE +}; + +bool pq_dup_tabs(JOIN *pq_join, JOIN *join, bool setup); + +TABLE_LIST *get_table_by_index(TABLE_LIST *start_table, + table_list_type_enum list_type, int index); + +int get_table_index(TABLE_LIST *start_table, table_list_type_enum list_type, + TABLE_LIST *tl); + +extern Item **resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, + Query_block *select); + +JOIN *pq_make_join(THD *thd, JOIN *join); + +bool copy_all_table_list(THD *thd, Query_block *orig, Query_block *dest_select); + +#endif // PQ_CLONE_INCLUDE_H diff --git a/sql/pq_clone_item.cc b/sql/pq_clone_item.cc new file mode 100644 index 000000000..25e68f775 --- /dev/null +++ b/sql/pq_clone_item.cc @@ -0,0 +1,1990 @@ +#ifndef PQ_CLONE_ITEM_H +#define PQ_CLONE_ITEM_H + +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "item_geofunc.h" +#include "item_inetfunc.h" +#include "item_pfs_func.h" +#include "mem_root_deque.h" +#include "sql/item.h" +#include "sql/item_cmpfunc.h" +#include "sql/item_regexp_func.h" +#include "sql/item_sum.h" +#include "sql/item_timefunc.h" +#include "sql/log.h" +#include "sql/parse_tree_items.h" +#include "sql/parse_tree_nodes.h" +#include "sql/pq_clone.h" +#include "sql/sql_optimizer.h" + +#define CHECK_TYPE(T) \ + if (typeid(*this) != typeid(T) || \ + DBUG_EVALUATE_IF("simulate_item_type_mismatch", true, false)) { \ + sql_print_warning( \ + "Caller's type %s is not equals to this class type %s, " \ + "will not use parallel query, SQL= %s", \ + typeid(*this).name(), typeid(T).name(), thd->query().str); \ + assert(DBUG_EVALUATE_IF("simulate_item_type_mismatch", true, false) || \ + false); \ + return nullptr; \ + } + +#define COPY_FROM_SUPER(D, B) \ + if (B::pq_copy_from(thd, select, item)) { \ + return true; \ + } \ + D *orig_item MY_ATTRIBUTE((unused)) = dynamic_cast(item); \ + assert(orig_item); + +#define COPY_SELF_ATTR(OBJ) \ + if (!OBJ || OBJ->pq_copy_from(thd, select, this)) { \ + return nullptr; \ + } + +#define PQ_CLONE_DEF(T) \ + Item *T::pq_clone(THD *thd, Query_block *select) { \ + CHECK_TYPE(T) \ + T *new_item = nullptr; + +#define PQ_CLONE_RETURN \ + COPY_SELF_ATTR(new_item) \ + return new_item; \ + } + +#define PQ_CLONE_ARGS \ + mem_root_deque item_list(thd->pq_mem_root); \ + for (uint i = 0; i < arg_count; i++) { \ + Item *arg = args[i]->pq_clone(thd, select); \ + if (arg == nullptr) return nullptr; \ + item_list.push_back(arg); \ + } + +#define PQ_COPY_FROM_DEF(D, B) \ + bool D::pq_copy_from(THD *thd, Query_block *select, Item *item) { \ + COPY_FROM_SUPER(D, B) + +#define PQ_COPY_FROM_RETURN \ + return false; \ + } + +#define PQ_REBUILD_SUM_DEF(T) \ + Item_sum *T::pq_rebuild_sum_func(THD *thd, Query_block *select, \ + Item *item) { \ + CHECK_TYPE(T) \ + T *new_item = nullptr; + +#define PQ_REBUILD_SUM_RETURN \ + COPY_SELF_ATTR(new_item) \ + return new_item; \ + } + +#define ARG0 copy_args[0] +#define ARG1 copy_args[1] +#define ARG2 copy_args[2] +#define ARG3 copy_args[3] +#define ARG4 copy_args[4] +#define COPY_FUNC_ITEM(T, ...) \ + Item *T::pq_clone(THD *thd, Query_block *select) { \ + CHECK_TYPE(T); \ + Item *copy_args[5]; \ + assert(arg_count < 5); \ + for (uint i = 0; i < arg_count; i++) { \ + copy_args[i] = args[i]->pq_clone(thd, select); \ + if (copy_args[i] == nullptr) { \ + return nullptr; \ + } \ + } \ + Item *new_item = nullptr; \ + new_item = new (thd->pq_mem_root) T(__VA_ARGS__); \ + COPY_SELF_ATTR(new_item) \ + return new_item; \ + } + +Item *Item::pq_clone(THD *thd MY_ATTRIBUTE((unused)), + Query_block *select MY_ATTRIBUTE((unused))) { + sql_print_warning( + "Item type %s's deep copy method is not implemented, " + "will not use parallel query, SQL= %s", + typeid(*this).name(), thd->query().str); + assert(DBUG_EVALUATE_IF("simulate_no_item_copy_function", true, false) || + false); + return nullptr; +} + +bool Item::pq_copy_from(THD *thd MY_ATTRIBUTE((unused)), + Query_block *select MY_ATTRIBUTE((unused)), + Item *item) { + cmp_context = item->cmp_context; + marker = item->marker; + + collation = item->collation; + item_name.copy(item->item_name.ptr(), item->item_name.length(), + system_charset_info, item->item_name.is_autogenerated()); + orig_name.copy(item->orig_name.ptr(), item->orig_name.length(), + system_charset_info, item->orig_name.is_autogenerated()); + decimals = item->decimals; + derived_used = item->derived_used; + is_expensive_cache = item->is_expensive_cache; + m_accum_properties = item->m_accum_properties; + m_data_type = item->m_data_type; + m_is_window_function = item->m_is_window_function; + max_length = item->max_length; + m_nullable = item->is_nullable(); + null_value = item->null_value; + str_value = item->str_value; + hidden = item->hidden; + +#ifndef NDEBUG + contextualized = item->contextualized; +#endif + unsigned_flag = item->unsigned_flag; + + if (!pq_alloc_item && item->pq_alloc_item) thd->add_item(this); + + return false; +} + +/* Item_basic_constant start */ +PQ_COPY_FROM_DEF(Item_basic_constant, Item) { + if (orig_item != nullptr) { + used_table_map = orig_item->used_table_map; + } +} +PQ_COPY_FROM_RETURN + +/* Item_cache start */ +PQ_COPY_FROM_DEF(Item_cache, Item_basic_constant) { + if (orig_item != nullptr) { + used_table_map = orig_item->used_table_map; + cached_field = orig_item->cached_field; + } + if (orig_item != nullptr && orig_item->example != nullptr) { + Item *example_arg = orig_item->example->pq_clone(thd, select); + if (example_arg == nullptr) return true; + if (!example_arg->fixed) { + example_arg->fix_fields(thd, &example_arg); + } + setup(example_arg); + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_cache_datetime) { + new_item = new (thd->pq_mem_root) Item_cache_datetime(data_type()); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_cache_decimal) { + new_item = new (thd->pq_mem_root) Item_cache_decimal(); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_cache_int) { + new_item = new (thd->pq_mem_root) Item_cache_int(); + if (new_item == nullptr) { + return nullptr; + } + if (origin_item) { + new_item->example = origin_item->pq_clone(thd, select); + if (new_item->example == nullptr) { + return nullptr; + } + } +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_cache_real) { + new_item = new (thd->pq_mem_root) Item_cache_real(); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_cache_row) { + new_item = new (thd->pq_mem_root) Item_cache_row(); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_cache_str) { + const Item *item = static_cast(this); + new_item = new (thd->pq_mem_root) Item_cache_str(item); +} +PQ_CLONE_RETURN +/* Item_cache end */ + +/* Item_hex_string start */ +PQ_CLONE_DEF(Item_hex_string) { + new_item = new (thd->pq_mem_root) Item_hex_string(POS()); +} +PQ_CLONE_RETURN + +// TOOD str_value copyed twice +PQ_CLONE_DEF(Item_bin_string) { + new_item = new (thd->pq_mem_root) + Item_bin_string(str_value.ptr(), str_value.length()); +} +PQ_CLONE_RETURN +/* Item_hex_string end */ + +/* Item_null start */ +PQ_CLONE_DEF(Item_null) { new_item = new (thd->pq_mem_root) Item_null(POS()); } +PQ_CLONE_RETURN +/* Item_null end */ + +/* Item_num start */ +PQ_CLONE_DEF(Item_int_with_ref) { + Item *pq_ref = ref->pq_clone(thd, select); + if (pq_ref == nullptr) return nullptr; + new_item = new (thd->pq_mem_root) + Item_int_with_ref(pq_ref->data_type(), value, pq_ref, unsigned_flag); +} +PQ_CLONE_RETURN +/* Item_num end */ + +/* Item_string start */ +PQ_CLONE_DEF(Item_string) { + if (origin_item) return origin_item->pq_clone(thd, select); + + new_item = new (thd->pq_mem_root) Item_string( + static_cast(item_name), str_value.ptr(), str_value.length(), + collation.collation, collation.derivation, collation.repertoire); + if (new_item) { + new_item->set_cs_specified(m_cs_specified); + } +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_static_string_func) { + if (origin_item) return origin_item->pq_clone(thd, select); + + new_item = new (thd->pq_mem_root) + Item_static_string_func(func_name, str_value.ptr(), str_value.length(), + collation.collation, collation.derivation); +} +PQ_CLONE_RETURN +/* Item_string end */ +/* Item_basic_constant end */ + +/* Item_ident start */ +PQ_COPY_FROM_DEF(Item_ident, Item) { + DBUG_EXECUTE_IF("simulate_item_clone_attr_copy_error", return true;); + + context = &select->context; + + if (orig_item->cached_table == nullptr) { + m_tableno = orig_item->m_tableno; + } else { + m_tableno = orig_item->cached_table->m_tableno; + } +} +PQ_COPY_FROM_RETURN + +PQ_COPY_FROM_DEF(Item_field, Item_ident) { + DBUG_EXECUTE_IF("simulate_item_field_copy_error", return true;); + + if (orig_item->table_ref != nullptr) { + m_tableno = orig_item->table_ref->m_tableno; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_field) { + DBUG_EXECUTE_IF("simulate_item_clone_error", return nullptr;); + DBUG_EXECUTE_IF("simulate_no_item_copy_function", + return Item::pq_clone(thd, select);); + + new_item = + new (thd->pq_mem_root) Item_field(POS(), db_name, table_name, field_name); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_default_value) { + Item *new_arg = nullptr; + if (arg) { + new_arg = arg->pq_clone(thd, select); + if (new_arg == nullptr) return nullptr; + } + new_item = new (thd->pq_mem_root) Item_default_value(POS(), new_arg); +} +PQ_CLONE_RETURN + +int find_ref_in_table(TABLE_LIST *tl, Item **ref) { + int count = tl->field_translation_end - tl->field_translation; + if (count <= 0) { + return -1; + } + for (int i = 0; i < count; i++) { + if (*ref == tl->field_translation[i].item) { + return i; + } + } + return -1; +} + +TABLE_LIST *get_table_in_merge_tablelist(Query_block *select, TABLE_LIST *tb) { + int tableindex = 0; + for (TABLE_LIST *tbl_list = select->orig->table_list.first; + tbl_list != nullptr; tbl_list = tbl_list->next_local) { + if (tbl_list->merge_underlying_list != nullptr) { + int index = get_table_index(tbl_list->merge_underlying_list, + TABLE_LIST_TYPE_MERGE, tb); + if (index != -1) { + TABLE_LIST *tbl = get_table_by_index( + select->table_list.first, TABLE_LIST_TYPE_DEFAULT, tableindex); + return get_table_by_index(tbl, TABLE_LIST_TYPE_MERGE, index); + } + } + tableindex++; + } + return nullptr; +} + +Item *Item_view_ref::pq_clone(class THD *thd, class Query_block *select) { + Item_view_ref *item = nullptr; + Item **item_ref = nullptr; + + if (select->orig != nullptr) { + TABLE_LIST *found_table = nullptr; + int index = get_table_index(select->orig->table_list.first, + TABLE_LIST_TYPE_DEFAULT, cached_table); + if (index != -1) { + found_table = get_table_by_index(select->table_list.first, + TABLE_LIST_TYPE_DEFAULT, index); + } + + if (found_table == nullptr) { + index = get_table_index(select->orig->leaf_tables, TABLE_LIST_TYPE_GLOBAL, + cached_table); + if (index != -1) { + found_table = get_table_by_index(select->leaf_tables, + TABLE_LIST_TYPE_GLOBAL, index); + } + } + + if (found_table == nullptr) { + found_table = get_table_in_merge_tablelist(select, cached_table); + } + + if (found_table == nullptr) { + return nullptr; + } + + int field_index = find_ref_in_table(cached_table, ref); + if (field_index == -1 || found_table->field_translation == nullptr || + found_table->field_translation_end - found_table->field_translation <= + field_index) { + return nullptr; + } + + item_ref = &found_table->field_translation[field_index].item; + + const char *db_name; + if (found_table->is_view()) { + db_name = found_table->db; + } else { + db_name = nullptr; + } + + item = new (thd->pq_mem_root) + Item_view_ref(&select->context, item_ref, db_name, table_name, + orig_table_name(), field_name, found_table); + } else { + item_ref = new (thd->pq_mem_root) Item *(); + if (item_ref == nullptr) return nullptr; + *item_ref = (*ref)->pq_clone(thd, select); + if (*item_ref == nullptr) return nullptr; + item = new (thd->pq_mem_root) + Item_view_ref(&select->context, item_ref, db_name, table_name, + orig_table_name(), field_name, cached_table); + } + + if (item == nullptr || item->pq_copy_from(thd, select, this)) { + return nullptr; + } + + return item; +} + +/** + Item_aggregate_ref wil be created from ref in setup_fields() afterwards, + so clone ref for the item. +*/ +Item *Item_aggregate_ref::pq_clone(class THD *thd, class Query_block *select) { + Item *item_ref = (*ref)->pq_clone(thd, select); + if (item_ref == nullptr) { + return nullptr; + } + + return item_ref; +} + +Item *Item_ref::pq_clone(class THD *thd, class Query_block *select) { + /* + * c1: (Name_resolution_context, db_name, table_name, field_name) + * c2: (pos, db_name, table_name, field_name) + * c3: (context, ref, db_name, table_name, field_name) + * c4: (thd, ref_item) + */ + Item_ref *new_item = nullptr; + Name_resolution_context *new_context = &select->context; + + if (copy_type == WITH_CONTEXT) + new_item = new (thd->pq_mem_root) + Item_ref(new_context, db_name, table_name, field_name); + else if (copy_type == WITHOUT_CONTEXT) + new_item = + new (thd->pq_mem_root) Item_ref(POS(), db_name, table_name, field_name); + else if (copy_type == WITH_CONTEXT_REF) { + return (*ref)->pq_clone(thd, select); + } else { + assert(copy_type == WITH_REF_ONLY); + new_item = new (thd->pq_mem_root) Item_ref(thd, this); + } + if (new_item == nullptr || new_item->pq_copy_from(thd, select, this)) + return nullptr; + + new_item->context = &select->context; + return new_item; +} + +PQ_CLONE_DEF(Item_name_const) { + Item *name_arg, *val_arg; + if (name_item == nullptr) { + name_arg = nullptr; + } else { + name_arg = name_item->pq_clone(thd, select); + if (name_arg == nullptr) return nullptr; + } + if (value_item == nullptr) { + val_arg = nullptr; + } else { + val_arg = value_item->pq_clone(thd, select); + if (val_arg == nullptr) return nullptr; + } + new_item = new (thd->pq_mem_root) Item_name_const(POS(), name_arg, val_arg); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_name_const, Item) { + if (orig_item != nullptr) { + valid_args = orig_item->valid_args; + } +} +PQ_COPY_FROM_RETURN + +/* Item_result_field start */ +/* Item_func start */ +PQ_COPY_FROM_DEF(Item_func, Item_result_field) { + if (orig_item != nullptr) { + null_on_null = orig_item->null_on_null; + used_tables_cache = orig_item->used_tables_cache; + not_null_tables_cache = orig_item->not_null_tables_cache; + } +} +PQ_COPY_FROM_RETURN + +/* Item_func_bit start */ +PQ_COPY_FROM_DEF(Item_func_bit, Item_func) { + if (orig_item != nullptr) { + hybrid_type = orig_item->hybrid_type; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(PTI_literal_underscore_charset_hex_num) { + LEX_STRING str = {const_cast(str_value.ptr()), str_value.length()}; + new_item = new (thd->pq_mem_root) + PTI_literal_underscore_charset_hex_num(POS(), collation.collation, str); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_bit_neg, POS(), ARG0) + +COPY_FUNC_ITEM(Item_func_bit_and, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_bit_or, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_bit_xor, POS(), ARG0, ARG1) + +COPY_FUNC_ITEM(Item_func_shift_left, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_shift_right, POS(), ARG0, ARG1) +/* Item_func_bit end */ + +PQ_CLONE_DEF(Item_func_case) { + PQ_CLONE_ARGS + new_item = new (thd->pq_mem_root) + Item_func_case(POS(), &item_list, nullptr, nullptr); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_case, Item_func) { + if (orig_item != nullptr) { + first_expr_num = orig_item->first_expr_num; + else_expr_num = orig_item->else_expr_num; + cached_result_type = orig_item->cached_result_type; + left_result_type = orig_item->left_result_type; + ncases = orig_item->ncases; + cmp_type = orig_item->cmp_type; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_if, ARG0, ARG1, ARG2) +COPY_FUNC_ITEM(Item_func_month, POS(), ARG0) + +/* Item_func_coalesce start */ +PQ_CLONE_DEF(Item_func_coalesce) { + assert(arg_count < 3); + Item *new_args[2] = {nullptr}; + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + if (arg_count == 1) { + new_item = new (thd->pq_mem_root) Item_func_coalesce(POS(), new_args[0]); + } else if (arg_count == 2) { + new_item = new (thd->pq_mem_root) + Item_func_coalesce(POS(), new_args[0], new_args[1]); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_any_value, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_ifnull, POS(), ARG0, ARG1) +/* Item_func_coalesce end */ + +/* Item_func_min_max start */ +PQ_CLONE_DEF(Item_func_max) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) Item_func_max(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_min) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) Item_func_min(POS(), &pt_item_list); +} +PQ_CLONE_RETURN +/* Item_func_min_max end */ + +/* Item_func_num1 start */ +COPY_FUNC_ITEM(Item_func_abs, POS(), ARG0) + +COPY_FUNC_ITEM(Item_func_ceiling, ARG0) +COPY_FUNC_ITEM(Item_func_floor, ARG0) + +COPY_FUNC_ITEM(Item_func_neg, ARG0) +COPY_FUNC_ITEM(Item_func_round, ARG0, ARG1, truncate) +/* Item_func_num1 end */ + +/* Item_num_op start */ +COPY_FUNC_ITEM(Item_func_plus, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_minus, ARG0, ARG1) + +COPY_FUNC_ITEM(Item_func_div, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mod, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mul, ARG0, ARG1) +/* Item_num_op end */ + +/* Item_func_regexp start */ +PQ_CLONE_DEF(Item_func_regexp_instr) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + new_item = + new (thd->pq_mem_root) Item_func_regexp_instr(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_regexp_like) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) Item_func_regexp_like(POS(), &pt_item_list); +} +PQ_CLONE_RETURN +/* Item_func_regexp end */ + +/* Item_func_weekday start */ +PQ_CLONE_DEF(Item_func_weekday) { + PQ_CLONE_ARGS + new_item = new (thd->pq_mem_root) + Item_func_weekday(POS(), item_list[0], this->odbc_type); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_dayname, POS(), ARG0) +/* Item_func_weekday end */ + +/* Item_int_func start */ +/* Item_bool_func2 start */ +COPY_FUNC_ITEM(Item_func_eq, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_equal, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_ge, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_gt, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_le, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_lt, ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_ne, ARG0, ARG1) + +PQ_CLONE_DEF(Item_func_like) { + Item *arg[3]; + for (uint i = 0; i < arg_count; i++) { + arg[i] = args[i]->pq_clone(thd, select); + if (arg[i] == nullptr) return nullptr; + } + + if (arg_count == 2) { + new_item = new (thd->pq_mem_root) Item_func_like(arg[0], arg[1]); + } else if (arg_count == 3) { + new_item = new (thd->pq_mem_root) Item_func_like(arg[0], arg[1], arg[2]); + } else { + sql_print_warning("arg_count is wrong!"); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_nullif, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrcontains, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_strcmp, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_xor, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_contains, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrcoveredby, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrcovers, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_crosses, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_disjoint, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_equals, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_intersects, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_overlaps, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_touches, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_st_within, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrwithin, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrtouches, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbroverlaps, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrintersects, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrequals, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_mbrdisjoint, POS(), ARG0, ARG1) +/* Item_bool_func2 end */ + +/* Item_cond start */ +PQ_COPY_FROM_DEF(Item_cond, Item_bool_func) { + Item *list_item; + List_iterator_fast list_it(orig_item->list); + while ((list_item = list_it++)) { + Item *arg = list_item->pq_clone(thd, select); + if (arg == nullptr) return true; + list.push_back(arg); + } + if (orig_item != nullptr) { + abort_on_null = orig_item->abort_on_null; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_cond_and) { + new_item = new (thd->pq_mem_root) Item_cond_and(); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_cond_and, Item_cond) { + if (orig_item != nullptr) { + cond_equal.max_members = orig_item->cond_equal.max_members; + } + Item_equal *item_equal; + List_iterator_fast it(orig_item->cond_equal.current_level); + for (size_t i = 0; (item_equal = it++); i++) { + Item_equal *new_item_equal = + dynamic_cast(item_equal->pq_clone(thd, select)); + if (new_item_equal == nullptr) return true; + cond_equal.current_level.push_back(new_item_equal); + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_cond_or) { new_item = new (thd->pq_mem_root) Item_cond_or(); } +PQ_CLONE_RETURN +/* Item_cond end */ + +PQ_CLONE_DEF(Item_equal) { new_item = new (thd->pq_mem_root) Item_equal(); } +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_equal, Item_bool_func) { + Item_field *item_field; + List_iterator_fast it(orig_item->fields); + for (size_t i = 0; (item_field = it++); i++) { + Item_field *new_field = + dynamic_cast(item_field->pq_clone(thd, select)); + if (new_field == nullptr) return true; + fields.push_back(new_field); + } + if (orig_item != nullptr && orig_item->const_item != nullptr) { + const_item = orig_item->const_item->pq_clone(thd, select); + if (const_item == nullptr) { + return true; + } + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_true, POS()) + +COPY_FUNC_ITEM(Item_func_isnotnull, ARG0) + +PQ_CLONE_DEF(Item_func_isnull) { + Item *arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + new_item = new (thd->pq_mem_root) Item_func_isnull(POS(), arg); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_isnull, Item_bool_func) { + if (orig_item != nullptr) { + cached_value = orig_item->cached_value; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_json_schema_valid, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_not, ARG0) + +PQ_CLONE_DEF(Item_func_truth) { + PQ_CLONE_ARGS + new_item = + new (thd->pq_mem_root) Item_func_truth(POS(), item_list[0], truth_test); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_extract) { + PQ_CLONE_ARGS + new_item = + new (thd->pq_mem_root) Item_extract(POS(), this->int_type, item_list[0]); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_extract, Item_int_func) { + if (orig_item != nullptr) { + date_value = orig_item->date_value; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_typecast_year) { + PQ_CLONE_ARGS + new_item = new (thd->pq_mem_root) Item_typecast_year(POS(), item_list[0]); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_ascii, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_bit_count, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_char_length) { + assert(arg_count == 1); + Item *arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + new_item = new (thd->pq_mem_root) Item_func_char_length(POS(), arg); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_char_length, Item_int_func) { + if (orig_item != nullptr) { + value.copy(orig_item->value); + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_coercibility, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_crc32, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_dayofmonth, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_dayofyear, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_field) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) Item_func_field(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_find_in_set, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_get_lock, POS(), ARG0, ARG1); +COPY_FUNC_ITEM(Item_func_hour, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_inet_aton, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_int_div, POS(), ARG0, ARG1) + +PQ_CLONE_DEF(Item_func_interval) { + assert(arg_count == 1 && args[0]->type() == Item::ROW_ITEM); + Item_row *row = down_cast(args[0]->pq_clone(thd, select)); + if (nullptr == row) return nullptr; + new_item = new (thd->pq_mem_root) Item_func_interval(POS(), row); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_interval, Item_int_func) { + if (orig_item != nullptr) { + use_decimal_comparison = orig_item->use_decimal_comparison; + intervals = orig_item->intervals; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_func_json_contains) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = + new (thd->pq_mem_root) Item_func_json_contains(thd, POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_json_depth, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_last_insert_id) { + Item *item_arg = nullptr; + if (arg_count == 1) { + item_arg = args[0]->pq_clone(thd, select); + if (item_arg == nullptr) { + return nullptr; + } + } + + if (arg_count == 0) { + new_item = new (thd->pq_mem_root) Item_func_last_insert_id(POS()); + } else if (arg_count == 1) { + new_item = new (thd->pq_mem_root) Item_func_last_insert_id(POS(), item_arg); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_length, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_bit_length, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_minute, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_locate) { + assert(arg_count < 4); + Item *new_args[4] = {nullptr}; + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + + if (arg_count == 2) { + new_item = new (thd->pq_mem_root) + Item_func_locate(POS(), new_args[0], new_args[1]); + } else if (arg_count == 3) { + new_item = new (thd->pq_mem_root) + Item_func_locate(POS(), new_args[0], new_args[1], new_args[2]); + } +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_locate, Item_int_func) { + if (orig_item != nullptr) { + cmp_collation = orig_item->cmp_collation; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_instr, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_microsecond, POS(), ARG0) + +PQ_COPY_FROM_DEF(Item_func_opt_neg, Item_int_func) { + if (orig_item != nullptr) { + negated = orig_item->negated; + pred_level = orig_item->pred_level; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_between, POS(), ARG0, ARG1, ARG2, negated); + +PQ_CLONE_DEF(Item_func_in) { + PT_select_item_list pt_item; + for (uint i = 0; i < arg_count; i++) { + Item *arg = args[i]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + pt_item.value.push_back(arg); + } + new_item = new (thd->pq_mem_root) Item_func_in(POS(), &pt_item, negated); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_ord, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_period_add, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_period_diff, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_quarter, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_second, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_sleep, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_time_to_sec, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_timestamp_diff, POS(), ARG0, ARG1, int_type) +COPY_FUNC_ITEM(Item_func_to_days, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_to_seconds, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_uncompressed_length, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_week, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_year, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_yearweek, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_typecast_signed, POS(), ARG0) +COPY_FUNC_ITEM(Item_typecast_unsigned, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_can_access_table, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_is_visible_dd_object, POS(), ARG0) +/* Item_int_func end */ + +/* Item_real_func start */ +/* Item_dec_func start*/ +COPY_FUNC_ITEM(Item_func_sin, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_sqrt, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_cos, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_tan, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_cot, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_pow, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_ln, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_log2, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_log10, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_asin, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_acos, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_exp, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_atan) { + Item *item_args[2]; + assert(arg_count < 3); + for (uint i = 0; i < arg_count; i++) { + item_args[i] = args[i]->pq_clone(thd, select); + if (item_args[i] == nullptr) return nullptr; + } + + if (arg_count == 1) + new_item = new (thd->pq_mem_root) Item_func_atan(POS(), item_args[0]); + else if (arg_count == 2) + new_item = new (thd->pq_mem_root) + Item_func_atan(POS(), item_args[0], item_args[1]); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_log) { + Item *item_args[2]; + assert(arg_count < 3); + for (uint i = 0; i < arg_count; i++) { + item_args[i] = args[i]->pq_clone(thd, select); + if (item_args[i] == nullptr) return nullptr; + } + + if (arg_count == 1) + new_item = new (thd->pq_mem_root) Item_func_log(POS(), item_args[0]); + else if (arg_count == 2) + new_item = + new (thd->pq_mem_root) Item_func_log(POS(), item_args[0], item_args[1]); +} +PQ_CLONE_RETURN + +/* Item_dec_func end*/ + +COPY_FUNC_ITEM(Item_func_longfromgeohash, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_rand) { + new_item = new (thd->pq_mem_root) Item_func_rand(POS()); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_latfromgeohash, POS(), ARG0) +/* Item_real_func end */ + +/* Item_str_func start */ +PQ_CLONE_DEF(Item_func_aes_decrypt) { + assert(arg_count < 4); + Item *new_args[4] = {nullptr}; + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + + if (arg_count == 2) { + new_item = new (thd->pq_mem_root) + Item_func_aes_decrypt(POS(), new_args[0], new_args[1]); + } else if (arg_count == 3) { + new_item = new (thd->pq_mem_root) + Item_func_aes_decrypt(POS(), new_args[0], new_args[1], new_args[2]); + } +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_aes_encrypt) { + assert(arg_count < 4); + Item *new_args[4] = {nullptr}; + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + + if (arg_count == 2) { + new_item = new (thd->pq_mem_root) + Item_func_aes_encrypt(POS(), new_args[0], new_args[1]); + } else if (arg_count == 3) { + new_item = new (thd->pq_mem_root) + Item_func_aes_encrypt(POS(), new_args[0], new_args[1], new_args[2]); + } +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_char) { + PQ_CLONE_ARGS + PT_item_list pt_item_list; + pt_item_list.value = item_list; + new_item = new (thd->pq_mem_root) Item_func_char(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_charset, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_collation, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_compress, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_concat) { + PQ_CLONE_ARGS + PT_item_list pt_item_list; + pt_item_list.value = item_list; + new_item = new (thd->pq_mem_root) Item_func_concat(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_concat_ws) { + PQ_CLONE_ARGS + PT_item_list pt_item_list; + pt_item_list.value = item_list; + new_item = new (thd->pq_mem_root) Item_func_concat_ws(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_conv, POS(), ARG0, ARG1, ARG2) +COPY_FUNC_ITEM(Item_func_conv_charset, POS(), ARG0, conv_charset) + +PQ_CLONE_DEF(Item_func_date_format) { + PQ_CLONE_ARGS + new_item = new (thd->pq_mem_root) Item_func_date_format( + POS(), item_list[0], item_list[1], this->is_time_format); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_date_format, Item_str_func) { + if (orig_item != nullptr) { + value.copy(orig_item->value); + fixed_length = orig_item->fixed_length; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_func_elt) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) Item_func_elt(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_export_set) { + PQ_CLONE_ARGS + + if (arg_count == 3) { + new_item = new (thd->pq_mem_root) + Item_func_export_set(POS(), item_list[0], item_list[1], item_list[2]); + } else if (arg_count == 4) { + new_item = new (thd->pq_mem_root) Item_func_export_set( + POS(), item_list[0], item_list[1], item_list[2], item_list[3]); + } else if (arg_count == 5) { + new_item = new (thd->pq_mem_root) + Item_func_export_set(POS(), item_list[0], item_list[1], item_list[2], + item_list[3], item_list[4]); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_from_base64, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_inet_ntoa, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_insert, POS(), ARG0, ARG1, ARG2, ARG3) + +PQ_CLONE_DEF(Item_func_json_quote) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) Item_func_json_quote(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_left, POS(), ARG0, ARG1) + +COPY_FUNC_ITEM(Item_func_lpad, POS(), ARG0, ARG1, ARG2) + +PQ_COPY_FROM_DEF(Item_func_lpad, Item_str_func) { + if (orig_item != nullptr) lpad_str.copy(orig_item->lpad_str); +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_func_make_set) { + Item *arg_a = item->pq_clone(thd, select); + if (arg_a == nullptr) return nullptr; + + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = + new (thd->pq_mem_root) Item_func_make_set(POS(), arg_a, &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_table_rows) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_table_rows(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_avg_row_length) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_avg_row_length(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_data_length) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_data_length(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_max_data_length) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_max_data_length(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_index_length) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_index_length(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_data_free) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = + new (thd->pq_mem_root) Item_func_internal_data_free(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_auto_increment) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_auto_increment(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_update_time) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_update_time(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_check_time) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = new (thd->pq_mem_root) + Item_func_internal_check_time(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_checksum) { + PQ_CLONE_ARGS + + PT_item_list pt_item_list; + pt_item_list.value = item_list; + + new_item = + new (thd->pq_mem_root) Item_func_internal_checksum(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_internal_get_comment_or_error) { + PQ_CLONE_ARGS + PT_item_list pt_item_list; + pt_item_list.value = item_list; + new_item = new (thd->pq_mem_root) + Item_func_internal_get_comment_or_error(POS(), &pt_item_list); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_monthname, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_pfs_format_bytes, POS(), ARG0) + +PQ_COPY_FROM_DEF(Item_func_pfs_format_bytes, Item_str_func) { + if (orig_item != nullptr) { + m_value = orig_item->m_value; + memcpy(orig_item->m_value_buffer, m_value_buffer, 20); + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_pfs_format_pico_time, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_quote, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_repeat, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_replace, POS(), ARG0, ARG1, ARG2) +COPY_FUNC_ITEM(Item_func_reverse, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_random_bytes, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_right) { + PQ_CLONE_ARGS + new_item = + new (thd->pq_mem_root) Item_func_right(POS(), item_list[0], item_list[1]); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_rpad, POS(), ARG0, ARG1, ARG2) + +PQ_COPY_FROM_DEF(Item_func_rpad, Item_str_func) { + if (orig_item != nullptr) { + rpad_str.copy(orig_item->rpad_str); + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_set_collation, POS(), ARG0, collation_string) + +PQ_COPY_FROM_DEF(Item_func_set_collation, Item_str_func) { + if (orig_item != nullptr && orig_item->args[1] != nullptr) { + args[1] = orig_item->args[1]->pq_clone(thd, select); + if (args[1] == nullptr) return true; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_soundex, ARG0) +COPY_FUNC_ITEM(Item_func_space, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_substr) { + assert(arg_count < 4); + Item *new_args[4] = {nullptr}; + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + + if (arg_count == 2) { + new_item = new (thd->pq_mem_root) + Item_func_substr(POS(), new_args[0], new_args[1]); + } else if (arg_count == 3) { + new_item = new (thd->pq_mem_root) + Item_func_substr(POS(), new_args[0], new_args[1], new_args[2]); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_substr_index, POS(), ARG0, ARG1, ARG2) +COPY_FUNC_ITEM(Item_func_database, POS()) +COPY_FUNC_ITEM(Item_func_user, POS()) + +PQ_CLONE_DEF(Item_func_trim) { + PQ_CLONE_ARGS + + if (arg_count > 1) + new_item = new (thd->pq_mem_root) + Item_func_trim(POS(), item_list[0], item_list[1], m_trim_mode); + else + new_item = + new (thd->pq_mem_root) Item_func_trim(POS(), item_list[0], m_trim_mode); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_ltrim, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_rtrim, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_uncompress, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_unhex, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_uuid, POS()) +COPY_FUNC_ITEM(Item_func_get_dd_create_options, POS(), ARG0, ARG1, ARG2) +PQ_CLONE_DEF(Item_func_uuid_to_bin) { + assert(arg_count < 3); + Item *new_args[4] = {nullptr}; + + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + + if (arg_count == 1) { + new_item = new (thd->pq_mem_root) Item_func_uuid_to_bin(POS(), new_args[0]); + } else if (arg_count == 2) { + new_item = new (thd->pq_mem_root) + Item_func_uuid_to_bin(POS(), new_args[0], new_args[1]); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_weight_string, POS(), ARG0, result_length, + num_codepoints, flags, as_binary) +COPY_FUNC_ITEM(Item_func_st_srid_mutator, POS(), ARG0, ARG1) + +PQ_CLONE_DEF(Item_func_bin_to_uuid) { + assert(arg_count < 3); + Item *new_args[4] = {nullptr}; + + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + + if (arg_count == 1) { + new_item = new (thd->pq_mem_root) Item_func_bin_to_uuid(POS(), new_args[0]); + } else if (arg_count == 2) { + new_item = new (thd->pq_mem_root) + Item_func_bin_to_uuid(POS(), new_args[0], new_args[1]); + } +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_format) { + assert(arg_count < 4); + Item *new_args[4] = {nullptr}; + for (uint i = 0; i < arg_count; i++) { + new_args[i] = args[i]->pq_clone(thd, select); + if (new_args[i] == nullptr) return nullptr; + } + + if (arg_count == 2) + new_item = new (thd->pq_mem_root) + Item_func_format(POS(), new_args[0], new_args[1]); + else if (arg_count == 3) + new_item = new (thd->pq_mem_root) + Item_func_format(POS(), new_args[0], new_args[1], new_args[2]); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_get_format) { + assert(arg_count == 1); + Item *arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + + new_item = new (thd->pq_mem_root) Item_func_get_format(POS(), type, arg); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_hex, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_inet6_aton, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_inet6_ntoa, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_md5, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_sha, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_sha2, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_to_base64, POS(), ARG0) + +PQ_COPY_FROM_DEF(Item_str_conv, Item_str_func) { + if (orig_item != nullptr) { + multiply = orig_item->multiply; + converter = orig_item->converter; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_func_upper, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_lower, POS(), ARG0) + +PQ_COPY_FROM_DEF(Item_temporal_hybrid_func, Item_str_func) { + if (orig_item != nullptr) { + sql_mode = orig_item->sql_mode; + ascii_buf.copy(orig_item->ascii_buf); + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_date_add_interval) { + Item *arg_a = args[0]->pq_clone(thd, select); + Item *arg_b = args[1]->pq_clone(thd, select); + if (arg_a == nullptr || arg_b == nullptr) return nullptr; + new_item = new (thd->pq_mem_root) + Item_date_add_interval(arg_a, arg_b, int_type, date_sub_interval); + if (new_item) { + new_item->set_data_type(data_type()); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_add_time, POS(), ARG0, ARG1, is_date, + sign == -1 ? true : false) + +COPY_FUNC_ITEM(Item_func_str_to_date, POS(), ARG0, ARG1) + +PQ_COPY_FROM_DEF(Item_func_str_to_date, Item_temporal_hybrid_func) { + if (orig_item != nullptr) { + cached_timestamp_type = orig_item->cached_timestamp_type; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_typecast_char, ARG0, cast_length, cast_cs) + +PQ_CLONE_DEF(Item_date_literal) { + MYSQL_TIME ltime; + cached_time.get_time(<ime); + new_item = new (thd->pq_mem_root) Item_date_literal(<ime); +} +PQ_CLONE_RETURN +/* Item_str_func end */ + +COPY_FUNC_ITEM(Item_func_curdate_utc, POS()) +COPY_FUNC_ITEM(Item_func_curdate_local, POS()) +COPY_FUNC_ITEM(Item_func_from_days, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_makedate, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_typecast_date, POS(), ARG0) + +PQ_COPY_FROM_DEF(Item_typecast_date, Item_date_func) { + if (orig_item != nullptr) { + m_explicit_cast = orig_item->m_explicit_cast; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_datetime_literal) { + MYSQL_TIME *ltime = new (thd->pq_mem_root) MYSQL_TIME(); + if (ltime != nullptr) { + this->get_date(ltime, 0); + new_item = new (thd->pq_mem_root) Item_datetime_literal( + ltime, this->cached_time.decimals(), thd->variables.time_zone); + } +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_convert_tz, POS(), ARG0, ARG1, ARG2) +COPY_FUNC_ITEM(Item_func_from_unixtime, POS(), ARG0) + +PQ_CLONE_DEF(Item_func_sysdate_local) { + new_item = new (thd->pq_mem_root) Item_func_sysdate_local(decimals); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_typecast_datetime) { + if (origin_item) { + return origin_item->pq_clone(thd, select); + } + Item *arg_item = args[0]->pq_clone(thd, select); + if (arg_item == nullptr) return nullptr; + + new_item = new (thd->pq_mem_root) Item_typecast_datetime(POS(), arg_item); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_typecast_datetime, Item_datetime_func) { + if (orig_item != nullptr) { + detect_precision_from_arg = orig_item->detect_precision_from_arg; + decimals = orig_item->decimals; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_func_at_time_zone) { + Item *arg_item = args[0]->pq_clone(thd, select); + if (arg_item == nullptr) return nullptr; + + new_item = new (thd->pq_mem_root) Item_func_at_time_zone( + POS(), arg_item, m_specifier_string, m_is_interval); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_curtime_local) { + PQ_CLONE_ARGS + new_item = + new (thd->pq_mem_root) Item_func_curtime_local(POS(), this->decimals); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_curtime_utc) { + new_item = new (thd->pq_mem_root) Item_func_curtime_utc(POS(), decimals); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_func_maketime, POS(), ARG0, ARG1, ARG2) +COPY_FUNC_ITEM(Item_func_sec_to_time, POS(), ARG0) +COPY_FUNC_ITEM(Item_func_timediff, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_typecast_time, POS(), ARG0) + +PQ_COPY_FROM_DEF(Item_typecast_time, Item_time_func) { + if (orig_item != nullptr) { + detect_precision_from_arg = orig_item->detect_precision_from_arg; + decimals = orig_item->decimals; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_time_literal) { + MYSQL_TIME *ltime = new (thd->pq_mem_root) MYSQL_TIME(); + if (ltime == nullptr) return nullptr; + cached_time.get_time(ltime); + new_item = new (thd->pq_mem_root) Item_time_literal(ltime, pq_dec_arg); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_typecast_decimal) { + Item *item_arg = args[0]->pq_clone(thd, select); + if (item_arg == nullptr) return nullptr; + + new_item = new (thd->pq_mem_root) + Item_typecast_decimal(POS(), item_arg, pq_precision, decimals); +} +PQ_CLONE_RETURN + +COPY_FUNC_ITEM(Item_typecast_real, ARG0) + +PQ_CLONE_DEF(Item_func_get_system_var) { + sys_var *var_arg = var; + + if (var_arg == nullptr) { + var_arg = var_tracker.bind_system_variable(thd); + } + + if (var_arg != nullptr) { + new_item = new (thd->pq_mem_root) Item_func_get_system_var( + var_arg, var_type, &component, item_name.ptr(), item_name.length()); + } +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_get_system_var, Item_var_func) { + if (orig_item != nullptr) { + cached_llval = orig_item->cached_llval; + cached_dval = orig_item->cached_dval; + cached_strval.copy(orig_item->cached_strval); + cached_null_value = orig_item->cached_null_value; + used_query_id = orig_item->used_query_id; + cache_present = orig_item->cache_present; + } +} +PQ_COPY_FROM_RETURN +/* Item_func end */ + +/* Item sum start */ +PQ_COPY_FROM_DEF(Item_sum, Item_result_field) { + if (orig_item != nullptr) { + force_copy_fields = orig_item->force_copy_fields; + with_distinct = orig_item->with_distinct; + max_aggr_level = orig_item->max_aggr_level; + max_sum_func_level = orig_item->max_sum_func_level; + allow_group_via_temp_table = orig_item->allow_group_via_temp_table; + save_deny_window_func = orig_item->save_deny_window_func; + used_tables_cache = orig_item->used_tables_cache; + forced_const = orig_item->forced_const; + } +} +PQ_COPY_FROM_RETURN + +Item_sum *Item_sum::pq_rebuild_sum_func( + THD *thd MY_ATTRIBUTE((unused)), Query_block *select MY_ATTRIBUTE((unused)), + Item *item MY_ATTRIBUTE((unused))) { + sql_print_warning( + "Item type %s's rebuild sum method is not implemented, " + "will not use parallel query, SQL= %s", + typeid(*this).name(), thd->query().str); + assert(DBUG_EVALUATE_IF("simulate_no_item_rebuild_function", true, false) || + false); + return nullptr; +} + +PQ_COPY_FROM_DEF(Item_sum_bit, Item_sum) { + if (orig_item != nullptr) { + reset_bits = orig_item->reset_bits; + bits = orig_item->bits; + hybrid_type = orig_item->hybrid_type; + m_count = orig_item->m_count; + m_frame_null_count = orig_item->m_frame_null_count; + } + m_digit_cnt = nullptr; + m_digit_cnt_card = 0; + if (orig_item != nullptr) { + m_is_xor = orig_item->m_is_xor; + } +} +PQ_COPY_FROM_RETURN + +PQ_REBUILD_SUM_DEF(Item_sum_and) { + new_item = new (thd->pq_mem_root) Item_sum_and(POS(), item, nullptr); +} +PQ_REBUILD_SUM_RETURN + +PQ_CLONE_DEF(Item_sum_and) { + Item *arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + + new_item = new (thd->pq_mem_root) Item_sum_and(POS(), arg, nullptr); +} +PQ_CLONE_RETURN + +PQ_REBUILD_SUM_DEF(Item_sum_or) { + new_item = new (thd->pq_mem_root) Item_sum_or(POS(), item, nullptr); +} +PQ_REBUILD_SUM_RETURN + +PQ_CLONE_DEF(Item_sum_or) { + Item *arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + + new_item = new (thd->pq_mem_root) Item_sum_or(POS(), arg, nullptr); +} +PQ_CLONE_RETURN + +PQ_REBUILD_SUM_DEF(Item_sum_xor) { + new_item = new (thd->pq_mem_root) Item_sum_xor(POS(), item, nullptr); +} +PQ_REBUILD_SUM_RETURN + +PQ_CLONE_DEF(Item_sum_xor) { + Item *arg = args[0]->pq_clone(thd, select); + if (nullptr == arg) return nullptr; + + new_item = new (thd->pq_mem_root) Item_sum_xor(POS(), arg, nullptr); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_sum_hybrid, Item_sum) { + if (orig_item == nullptr) { + return true; + } + + hybrid_type = orig_item->hybrid_type; + was_values = orig_item->was_values; + m_nulls_first = orig_item->m_nulls_first; + m_optimize = orig_item->m_optimize; + m_want_first = orig_item->m_want_first; + m_cnt = orig_item->m_cnt; + m_saved_last_value_at = orig_item->m_saved_last_value_at; +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_sum_max, ARG0); + +PQ_REBUILD_SUM_DEF(Item_sum_max) { + new_item = new (thd->pq_mem_root) Item_sum_max(POS(), item, nullptr); +} +PQ_REBUILD_SUM_RETURN + +COPY_FUNC_ITEM(Item_sum_min, ARG0); + +PQ_REBUILD_SUM_DEF(Item_sum_min) { + new_item = new (thd->pq_mem_root) Item_sum_min(POS(), item, nullptr); +} +PQ_REBUILD_SUM_RETURN + +PQ_COPY_FROM_DEF(Item_sum_num, Item_sum) { + DBUG_EXECUTE_IF("simulate_item_rebuild_attr_copy_error", return true;); + if (orig_item != nullptr) { + is_evaluated = orig_item->is_evaluated; + } +} +PQ_COPY_FROM_RETURN + +COPY_FUNC_ITEM(Item_sum_count, POS(), ARG0, nullptr) + +Item_sum *Item_sum_count::pq_rebuild_sum_func(THD *thd, Query_block *select, + Item *item) { + DBUG_EXECUTE_IF("simulate_item_rebuild_error", return nullptr;); + DBUG_EXECUTE_IF("simulate_no_item_rebuild_function", + return Item_sum::pq_rebuild_sum_func(thd, select, item);); + + Item_sum_count *new_item_sum = + new (thd->pq_mem_root) Item_sum_count(POS(), item, nullptr, true); + if (new_item_sum == nullptr || + new_item_sum->Item_sum_num::pq_copy_from(thd, select, this)) + return nullptr; + return new_item_sum; +} + +Item *PTI_count_sym::pq_clone(THD *thd, Query_block *select) { + CHECK_TYPE(PTI_count_sym) + Item *arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + Item_sum_count *new_count = + new (thd->pq_mem_root) Item_sum_count(POS(), arg, nullptr); + if (new_count == nullptr || new_count->pq_copy_from(thd, select, this)) + return nullptr; + return new_count; +} + +COPY_FUNC_ITEM(Item_sum_sum, POS(), ARG0, has_with_distinct(), nullptr) + +PQ_REBUILD_SUM_DEF(Item_sum_sum) { + new_item = new (thd->pq_mem_root) + Item_sum_sum(POS(), item, has_with_distinct(), nullptr); +} +PQ_REBUILD_SUM_RETURN + +PQ_CLONE_DEF(Item_sum_avg) { + assert(arg_count == 1); + Item *arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + new_item = new (thd->pq_mem_root) + Item_sum_avg(POS(), arg, has_with_distinct(), nullptr); + if (new_item) { + new_item->pq_avg_type = PQ_WORKER; + } +} +PQ_CLONE_RETURN + +PQ_REBUILD_SUM_DEF(Item_sum_avg) { + new_item = new (thd->pq_mem_root) + Item_sum_avg(POS(), item, has_with_distinct(), nullptr); + if (new_item) { + new_item->pq_avg_type = PQ_REBUILD; + } +} +PQ_REBUILD_SUM_RETURN +/* Item sum end */ +/* Item_result_field end */ + +PQ_CLONE_DEF(Item_row) { + assert(arg_count > 0); + Item *arg_head = items[0]->pq_clone(thd, select); + if (arg_head == nullptr) return nullptr; + mem_root_deque tail(thd->pq_mem_root); + for (uint i = 1; i < arg_count; i++) { + Item *arg_tail = items[i]->pq_clone(thd, select); + if (arg_tail == nullptr) return nullptr; + tail.push_back(arg_tail); + } + new_item = new (thd->pq_mem_root) Item_row(arg_head, tail); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_row, Item) { + // generated a random item_name for item_row + if (orig_item != nullptr) { + if (orig_item->item_name.length() == 0) { + assert(orig_item->item_name.ptr() == nullptr); + uint32 addr_mid_8 = ((uint64)this >> 32) << 24; + std::string std_addr = "ITEM_ROW" + std::to_string(addr_mid_8); + item_name.copy(std_addr.c_str(), std_addr.length(), system_charset_info, + true); + } + used_tables_cache = orig_item->used_tables_cache; + not_null_tables_cache = orig_item->not_null_tables_cache; + with_null = orig_item->with_null; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_float) { + new_item = + new (thd->pq_mem_root) Item_float(item_name, value, decimals, max_length); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_int) { new_item = new (thd->pq_mem_root) Item_int(this); } +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_int, Item_num) { + if (orig_item != nullptr) { + value = orig_item->value; + } +} +PQ_COPY_FROM_RETURN + +PQ_CLONE_DEF(Item_uint) { + new_item = new (thd->pq_mem_root) Item_uint(item_name, value, max_length); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_decimal) { + new_item = new (thd->pq_mem_root) + Item_decimal(item_name, &decimal_value, decimals, max_length); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_version) { + new_item = new (thd->pq_mem_root) Item_func_version(POS()); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(PTI_function_call_nonkeyword_now) { + new_item = + new (thd->pq_mem_root) PTI_function_call_nonkeyword_now(POS(), decimals); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(PTI_text_literal_text_string) { + new_item = new (thd->pq_mem_root) + PTI_text_literal_text_string(POS(), is_7bit, literal); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(PTI_text_literal_nchar_string) { + new_item = new (thd->pq_mem_root) + PTI_text_literal_nchar_string(POS(), is_7bit, literal); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(PTI_text_literal_underscore_charset) { + new_item = new (thd->pq_mem_root) + PTI_text_literal_underscore_charset(POS(), is_7bit, cs, literal); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(PTI_user_variable) { + new_item = new (thd->pq_mem_root) PTI_user_variable(POS(), {const_cast(name.m_str), name.m_length}); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_get_user_var) { + new_item = new (thd->pq_mem_root) Item_func_get_user_var(POS(), name); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_connection_id) { + new_item = new (thd->pq_mem_root) Item_func_connection_id(POS()); +} +PQ_CLONE_RETURN + +PQ_CLONE_DEF(Item_func_trig_cond) { + Item *arg = nullptr; + if (arg_count > 0) arg = args[0]->pq_clone(thd, select); + if (arg == nullptr) return nullptr; + new_item = new (thd->pq_mem_root) Item_func_trig_cond( + arg, trig_var, thd->lex->unit->first_query_block()->join, m_idx, + trig_type); +} +PQ_CLONE_RETURN + +PQ_COPY_FROM_DEF(Item_func_connection_id, Item_int_func) { + if (orig_item != nullptr) { + value = orig_item->value; + } +} +PQ_COPY_FROM_RETURN + +Item *Item_func_unix_timestamp::pq_clone(THD *thd, Query_block *select) { + Item *arg_item = nullptr; + if (arg_count > 0) { + arg_item = args[0]->pq_clone(thd, select); + if (arg_item == nullptr) return nullptr; + } + + Item_func_unix_timestamp *new_item = nullptr; + if (arg_count) { + new_item = new (thd->pq_mem_root) Item_func_unix_timestamp(POS(), arg_item); + } else { + new_item = new (thd->pq_mem_root) Item_func_unix_timestamp(POS()); + } + + if (!new_item || new_item->pq_copy_from(thd, select, this)) return nullptr; + + return new_item; +} + +Item *Item_func_current_user::pq_clone(THD *thd, Query_block *select) { + Item_func_current_user *new_item = + new (thd->pq_mem_root) Item_func_current_user(POS()); + if (!new_item || new_item->pq_copy_from(thd, select, this)) return nullptr; + + new_item->context = &select->context; + return new_item; +} + +COPY_FUNC_ITEM(Item_func_benchmark, POS(), ARG0, ARG1) +COPY_FUNC_ITEM(Item_func_found_rows, POS()) + +Item *Item_func_false::pq_clone(THD *thd, Query_block *select) { + CHECK_TYPE(Item_func_false); + + Item *new_item = new (thd->pq_mem_root) Item_func_false(POS()); + COPY_SELF_ATTR(new_item) + + if (item_name.ptr() == antijoin_null_cond) { + new_item->item_name.set(antijoin_null_cond); + } + + return new_item; +} + +Item *Item_datetime_with_ref::pq_clone(THD *thd, Query_block *select) { + CHECK_TYPE(Item_datetime_with_ref); + if (origin_item) { + return origin_item->pq_clone(thd, select); + } + + return ref->pq_clone(thd, select); +} + +Item *Item_time_with_ref::pq_clone(THD *thd, Query_block *select) { + CHECK_TYPE(Item_time_with_ref); + if (origin_item) { + return origin_item->pq_clone(thd, select); + } + + return ref->pq_clone(thd, select); +} + +#endif diff --git a/sql/pq_condition.cc b/sql/pq_condition.cc new file mode 100644 index 000000000..8587b489a --- /dev/null +++ b/sql/pq_condition.cc @@ -0,0 +1,1014 @@ +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "sql/pq_condition.h" +#include "sql/item_strfunc.h" +#include "sql/item_sum.h" +#include "sql/mysqld.h" +#include "sql/opt_range.h" +#include "sql/sql_lex.h" +#include "sql/sql_optimizer.h" +#include "sql/sql_parallel.h" +#include "sql/sql_tmp_table.h" + +const enum_field_types NO_PQ_SUPPORTED_FIELD_TYPES[] = { + MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_BLOB, + MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_JSON, MYSQL_TYPE_GEOMETRY}; + +const Item_sum::Sumfunctype NO_PQ_SUPPORTED_AGG_FUNC_TYPES[] = { + Item_sum::COUNT_DISTINCT_FUNC, + Item_sum::SUM_DISTINCT_FUNC, + Item_sum::AVG_DISTINCT_FUNC, + Item_sum::GROUP_CONCAT_FUNC, + Item_sum::JSON_AGG_FUNC, + Item_sum::UDF_SUM_FUNC, + Item_sum::STD_FUNC, + Item_sum::VARIANCE_FUNC, + Item_sum::SUM_BIT_FUNC}; + +const Item_func::Functype NO_PQ_SUPPORTED_FUNC_TYPES[] = { + Item_func::FT_FUNC, Item_func::MATCH_FUNC, Item_func::SUSERVAR_FUNC, + Item_func::FUNC_SP, Item_func::JSON_FUNC, Item_func::SUSERVAR_FUNC, + Item_func::UDF_FUNC, Item_func::XML_FUNC}; + +const char *NO_PQ_SUPPORTED_FUNC_ARGS[] = { + "rand", "json_valid", "json_length", + "json_type", "json_contains_path", "json_unquote", + "st_distance", "get_lock", "is_free_lock", + "is_used_lock", "release_lock", "sleep", + "xml_str", "json_func", + "weight_string", // Data truncation (MySQL BUG) + "des_decrypt" // Data truncation +}; + +const char *NO_PQ_SUPPORTED_FUNC_NO_ARGS[] = {"release_all_locks"}; + +/** + * return true when type is a not_supported_field; return false otherwise. + */ +bool pq_not_support_datatype(enum_field_types type) { + for (const enum_field_types &field_type : NO_PQ_SUPPORTED_FIELD_TYPES) { + if (type == field_type) { + return true; + } + } + + return false; +} + +/** + * check PQ supported function type + */ +bool pq_not_support_functype(Item_func::Functype type) { + for (const Item_func::Functype &func_type : NO_PQ_SUPPORTED_FUNC_TYPES) { + if (type == func_type) { + return true; + } + } + + return false; +} + +/** + * check PQ supported function + */ +bool pq_not_support_func(Item_func *func) { + if (pq_not_support_functype(func->functype())) { + return true; + } + + for (const char *funcname : NO_PQ_SUPPORTED_FUNC_ARGS) { + if (!strcmp(func->func_name(), funcname) && func->arg_count != 0) { + return true; + } + } + + for (const char *funcname : NO_PQ_SUPPORTED_FUNC_NO_ARGS) { + if (!strcmp(func->func_name(), funcname)) { + return true; + } + } + + return false; +} + +/** + * check PQ support aggregation function + */ +bool pq_not_support_aggr_functype(Item_sum::Sumfunctype type) { + for (const Item_sum::Sumfunctype &sum_func_type : + NO_PQ_SUPPORTED_AGG_FUNC_TYPES) { + if (type == sum_func_type) { + return true; + } + } + + return false; +} + +/** + * check PQ supported ref function + */ +bool pq_not_support_ref(Item_ref *ref, bool having) { + Item_ref::Ref_Type type = ref->ref_type(); + if (type == Item_ref::OUTER_REF) { + return true; + } + /** + * Now, when the sql contains a aggregate function after the 'having', + * we do not support parallel query. For example: + * select t1.col1 from t1 group by t1.col1 having avg(t1.col1) > 0; + * So, we disable the sql; + */ + if (having && type == Item_ref::AGGREGATE_REF) { + return true; + } + + return false; +} + +typedef bool (*PQ_CHECK_ITEM_FUN)(Item *item, bool having); + +struct PQ_CHECK_ITEM_TYPE { + Item::Type item_type; + PQ_CHECK_ITEM_FUN fun_ptr; +}; + +bool check_pq_support_fieldtype(Item *item, bool having); + +bool check_pq_support_fieldtype_of_field_item(Item *item, + bool MY_ATTRIBUTE((unused))) { + Field *field = static_cast(item)->field; + assert(field); + // not supported for generated column + if (field && (field->is_gcol() || pq_not_support_datatype(field->type()))) { + return false; + } + + return true; +} + +bool check_pq_support_fieldtype_of_func_item(Item *item, bool having) { + Item_func *func = static_cast(item); + assert(func); + + // check func type + if (pq_not_support_func(func)) { + return false; + } + + // the case of Item_func_make_set + if (!strcmp(func->func_name(), "make_set")) { + Item *arg_item = down_cast(func)->item; + if (arg_item && !check_pq_support_fieldtype(arg_item, having)) { + return false; + } + } + + // check func args type + for (uint i = 0; i < func->arg_count; i++) { + // c: args contain unsupported fields + Item *arg_item = func->arguments()[i]; + if (arg_item == nullptr || + !check_pq_support_fieldtype(arg_item, having)) { // c + return false; + } + } + + // the case of Item_equal + if (func->functype() == Item_func::MULT_EQUAL_FUNC) { + Item_equal *item_equal = down_cast(item); + assert(item_equal); + + // check const_item + Item *const_item = item_equal->get_const(); + if (const_item && + (const_item->type() == Item::SUM_FUNC_ITEM || // c1 + !check_pq_support_fieldtype(const_item, having))) { // c2 + return false; + } + + // check fields + Item *field_item = nullptr; + List fields = item_equal->get_fields(); + List_iterator_fast it(fields); + for (size_t i = 0; (field_item = it++); i++) { + if (!check_pq_support_fieldtype(field_item, having)) { + return false; + } + } + } + + return true; +} + +bool check_pq_support_fieldtype_of_cond_item(Item *item, bool having) { + Item_cond *cond = static_cast(item); + assert(cond); + + if (pq_not_support_functype(cond->functype())) { + return false; + } + + Item *arg_item = nullptr; + List_iterator_fast it(*cond->argument_list()); + for (size_t i = 0; (arg_item = it++); i++) { + if (arg_item->type() == Item::SUM_FUNC_ITEM || // c1 + !check_pq_support_fieldtype(arg_item, having)) { // c2 + return false; + } + } + + return true; +} + +bool check_pq_support_fieldtype_of_sum_func_item(Item *item, bool having) { + /** + * Now, when the sql contains a reference to the aggregate function after the + * 'having', we do not support parallel query. For example: select t1.col1, + * avg(t1.col1) as avg from t1 group by t1.col1 having avg > 0; So, we disable + * the sql. + */ + if (having) { + return false; + } + Item_sum *sum = static_cast(item); + if (!sum || pq_not_support_aggr_functype(sum->sum_func())) { + return false; + } + + for (uint i = 0; i < sum->argument_count(); i++) { + if (!check_pq_support_fieldtype(sum->get_arg(i), having)) { + return false; + } + } + + return true; +} + +bool check_pq_support_fieldtype_of_ref_item(Item *item, bool having) { + Item_ref *item_ref = down_cast(item); + if (item_ref == nullptr || pq_not_support_ref(item_ref, having)) { + return false; + } + + if (!check_pq_support_fieldtype(item_ref->ref[0], having)) { + return false; + } + + return true; +} + +bool check_pq_support_fieldtype_of_cache_item(Item *item, bool having) { + Item_cache *item_cache = dynamic_cast(item); + if (item_cache == nullptr) { + return false; + } + + Item *example_item = item_cache->get_example(); + if (example_item == nullptr || + example_item->type() == Item::SUM_FUNC_ITEM || // c1 + !check_pq_support_fieldtype(example_item, having)) { // c2 + return false; + } + + return true; +} + +bool check_pq_support_fieldtype_of_row_item(Item *item, bool having) { + // check each item in Item_row + Item_row *row_item = down_cast(item); + for (uint i = 0; i < row_item->cols(); i++) { + Item *n_item = row_item->element_index(i); + if (n_item == nullptr || n_item->type() == Item::SUM_FUNC_ITEM || // c1 + !check_pq_support_fieldtype(n_item, having)) { // c2 + return false; + } + } + + return true; +} + +PQ_CHECK_ITEM_TYPE g_check_item_type[] = { + {Item::INVALID_ITEM, nullptr}, + {Item::FIELD_ITEM, check_pq_support_fieldtype_of_field_item}, + {Item::FUNC_ITEM, check_pq_support_fieldtype_of_func_item}, + {Item::SUM_FUNC_ITEM, check_pq_support_fieldtype_of_sum_func_item}, + {Item::STRING_ITEM, nullptr}, + {Item::INT_ITEM, nullptr}, + {Item::REAL_ITEM, nullptr}, + {Item::NULL_ITEM, nullptr}, + {Item::VARBIN_ITEM, nullptr}, + {Item::METADATA_COPY_ITEM, nullptr}, + {Item::FIELD_AVG_ITEM, nullptr}, + {Item::DEFAULT_VALUE_ITEM, nullptr}, + {Item::PROC_ITEM, nullptr}, + {Item::COND_ITEM, check_pq_support_fieldtype_of_cond_item}, + {Item::REF_ITEM, check_pq_support_fieldtype_of_ref_item}, + {Item::FIELD_STD_ITEM, nullptr}, + {Item::FIELD_VARIANCE_ITEM, nullptr}, + {Item::INSERT_VALUE_ITEM, nullptr}, + {Item::SUBSELECT_ITEM, nullptr}, + {Item::ROW_ITEM, check_pq_support_fieldtype_of_row_item}, + {Item::CACHE_ITEM, check_pq_support_fieldtype_of_cache_item}, + {Item::TYPE_HOLDER, nullptr}, + {Item::PARAM_ITEM, nullptr}, + {Item::TRIGGER_FIELD_ITEM, nullptr}, + {Item::DECIMAL_ITEM, nullptr}, + {Item::XPATH_NODESET, nullptr}, + {Item::XPATH_NODESET_CMP, nullptr}, + {Item::VIEW_FIXER_ITEM, nullptr}, + {Item::FIELD_BIT_ITEM, nullptr}, + {Item::VALUES_COLUMN_ITEM, nullptr}}; + +/** + * check item is supported by Parallel Query or not + * + * @retval: + * true : supported + * false : not supported + */ +bool check_pq_support_fieldtype(Item *item, bool having) { + if (item == nullptr || pq_not_support_datatype(item->data_type())) { + return false; + } + + if (g_check_item_type[item->type()].fun_ptr != nullptr) { + return g_check_item_type[item->type()].fun_ptr(item, having); + } + + return true; +} + +/* + * check if order_list contains aggregate function + * + * @retval: + * true: contained + * false: + */ +bool check_pq_sort_aggregation(const ORDER_with_src &order_list) { + if (order_list.order == nullptr) { + return false; + } + + ORDER *tmp = nullptr; + Item *order_item = nullptr; + + for (tmp = order_list.order; tmp; tmp = tmp->next) { + order_item = *(tmp->item); + if (!check_pq_support_fieldtype(order_item, false)) { + return true; + } + } + + return false; +} + +/* + * generate item's result_field + * + * @retval: + * false: generate success + * ture: otherwise + */ +bool pq_create_result_fields(THD *thd, Temp_table_param *param, + mem_root_deque &fields, bool save_sum_fields, + ulonglong select_options, MEM_ROOT *root) { + const bool not_all_columns = !(select_options & TMP_TABLE_ALL_COLUMNS); + long hidden_field_count = param->hidden_field_count; + Field *from_field = nullptr; + Field **tmp_from_field = &from_field; + Field **default_field = &from_field; + + bool force_copy_fields = false; + TABLE_SHARE s; + TABLE table; + table.s = &s; + + uint copy_func_count = param->func_count; + if (param->precomputed_group_by) { + copy_func_count += param->sum_func_count; + } + + Func_ptr_array *copy_func = new (root) Func_ptr_array(root); + if (copy_func == nullptr) { + return true; + } + + copy_func->reserve(copy_func_count); + for (Item *item : fields) { + Item::Type type = item->type(); + const bool is_sum_func = + type == Item::SUM_FUNC_ITEM && !item->m_is_window_function; + + if (not_all_columns && item != nullptr) { + if (item->has_aggregation() && type != Item::SUM_FUNC_ITEM) { + if (item->is_outer_reference()) item->update_used_tables(); + if (type == Item::SUBSELECT_ITEM || + (item->used_tables() & ~OUTER_REF_TABLE_BIT)) { + param->using_outer_summary_function = 1; + goto update_hidden; + } + } + + if (item->m_is_window_function) { + if (!param->m_window || param->m_window_frame_buffer) { + goto update_hidden; + } + + if (param->m_window != down_cast(item)->window()) { + goto update_hidden; + } + } else if (item->has_wf()) { + if (param->m_window == nullptr || !param->m_window->is_last()) { + goto update_hidden; + } + } + + if (item->const_item()) continue; + } + + if (is_sum_func && !save_sum_fields) { + /* Can't calc group yet */ + } else { + Field *new_field = nullptr; + if (param->schema_table) { + new_field = + item ? create_tmp_field_for_schema(item, &table, root) : nullptr; + } else { + new_field = + item ? create_tmp_field(thd, &table, item, type, copy_func, + tmp_from_field, default_field, false, //(1) + !force_copy_fields && not_all_columns, + item->marker == Item::MARKER_BIT || + param->bit_fields_as_long, //(2) + force_copy_fields, false, root) + : nullptr; + } + + if (new_field == nullptr) { + assert(thd->is_fatal_error()); + return true; + } + + if (not_all_columns && type == Item::SUM_FUNC_ITEM) { + ((Item_sum *)item)->result_field = new_field; + } + + s.fields++; + } + + update_hidden: + if (!--hidden_field_count) { + param->hidden_field_count = 0; + } + } // end of while ((item=li++)). + + if (s.fields == 0) return true; + + Field *result_field = nullptr; + + for (Item *item : fields) { + // c1: const_item will not produce field in the first rewritten table + if (item->const_item() || item->basic_const_item()) { + continue; + } + + if (item->has_aggregation() && item->type() != Item::SUM_FUNC_ITEM) { + if (item->type() == Item::SUBSELECT_ITEM || + (item->used_tables() & ~OUTER_REF_TABLE_BIT)) { + continue; + } + } + + result_field = item->get_result_field(); + if (result_field) { + enum_field_types field_type = result_field->type(); + // c3: result_field contains unsupported data type + if (pq_not_support_datatype(field_type)) { + return true; + } + } else { + // c4: item is not FIELD_ITEM and it has no result_field + if (item->type() != Item::FIELD_ITEM) { + return true; + } + + result_field = down_cast(item)->result_field; + if (result_field && pq_not_support_datatype(result_field->type())) { + return true; + } + } + } + + return false; +} + +/** + * check whether the select result fields is suitable for parallel query + * + * @return: + * true, suitable + * false. + */ +bool check_pq_select_result_fields(JOIN *join) { + DBUG_ENTER("check result fields is suitable for parallel query or not"); + MEM_ROOT *pq_check_root = ::new MEM_ROOT(); + if (pq_check_root == nullptr) { + DBUG_RETURN(false); + } + + init_sql_alloc(key_memory_thd_main_mem_root, pq_check_root, + global_system_variables.query_alloc_block_size, + global_system_variables.query_prealloc_size); + + bool suit_for_parallel = false; + + mem_root_deque *tmp_all_fields = join->fields; + + join->tmp_table_param->pq_copy(join->saved_tmp_table_param); + join->tmp_table_param->copy_fields.clear(); + + Temp_table_param *tmp_param = + new (pq_check_root) Temp_table_param(*join->tmp_table_param); + + if (tmp_param == nullptr) { + // free the memory + free_root(pq_check_root, MYF(0)); + if (pq_check_root) { + ::delete pq_check_root; + } + DBUG_RETURN(suit_for_parallel); + } + + tmp_param->m_window_frame_buffer = true; + mem_root_deque tmplist(*tmp_all_fields); + tmp_param->hidden_field_count = CountHiddenFields(*tmp_all_fields); + + // create_tmp_table may change the original item's result_field, hence + // we must save it before. + std::vector saved_result_field(tmplist.size(), nullptr); + + int i = 0; + for (Item *tmp_item : *tmp_all_fields) { + if (tmp_item->type() == Item::FIELD_ITEM || + tmp_item->type() == Item::DEFAULT_VALUE_ITEM) { + saved_result_field[i] = down_cast(tmp_item)->result_field; + } else { + saved_result_field[i] = tmp_item->get_result_field(); + } + i++; + } + + if (pq_create_result_fields(join->thd, tmp_param, tmplist, true, + join->query_block->active_options(), + pq_check_root)) { + suit_for_parallel = false; + } else { + suit_for_parallel = true; + } + + // restore result_field + i = 0; + for (Item *tmp_item : *tmp_all_fields) { + if (tmp_item->type() == Item::FIELD_ITEM || + tmp_item->type() == Item::DEFAULT_VALUE_ITEM) { + down_cast(tmp_item)->result_field = saved_result_field[i]; + } else { + tmp_item->set_result_field(saved_result_field[i]); + } + i++; + } + + // free the memory + free_root(pq_check_root, MYF(0)); + if (pq_check_root) { + ::delete pq_check_root; + } + DBUG_RETURN(suit_for_parallel); +} + +/** + * check whether the select fields is suitable for parallel query + * + * @return: + * true, suitable + * false. + */ +bool check_pq_select_fields(JOIN *join) { + // check whether contains blob, text, json and geometry field + for (Item *item : *join->query_block_fields) { + if (!check_pq_support_fieldtype(item, false)) { + return false; + } + } + + Item *n_where_cond = join->query_block->where_cond(); + Item *n_having_cond = join->query_block->having_cond(); + + if (n_where_cond && !check_pq_support_fieldtype(n_where_cond, false)) { + return false; + } + + /* + * For Having Aggr. function, the having_item will be pushed + * into all_fields in prepare phase. Currently, we have not support this + * operation. + */ + if (n_having_cond && !check_pq_support_fieldtype(n_having_cond, true)) { + return false; + } + + if (check_pq_sort_aggregation(join->order)) { + return false; + } + + if (!check_pq_select_result_fields(join)) { + return false; + } + + return true; +} + +/** + * choose a table that do parallel query, currently only do parallel scan on + * first no-const primary table. + * Disallow splitting inner tables, such as select * from t1 left join t2 on 1 + * where t1.a = 't1'. We can't split t2 when t1 is const table. + * Disallow splitting semijion inner tables,such as select * from t1 where + * exists (select * from t2). We can't split t2. + * + * @return: + * true, found a parallel scan table + * false, cann't found a parallel scan table + */ +bool choose_parallel_scan_table(JOIN *join) { + QEP_TAB *tab = &join->qep_tab[join->const_tables]; + if (tab->is_inner_table_of_outer_join() || tab->m_qs->first_sj_inner() >= 0) { + return false; + } + tab->do_parallel_scan = true; + return true; +} + +void set_pq_dop(THD *thd) { + if (!thd->no_pq && thd->variables.force_parallel_execute && + thd->pq_dop == 0) { + thd->pq_dop = thd->variables.parallel_default_dop; + } +} + +/** + * check whether the parallel query is enabled and set the + * parallel query condition status + * + */ +void set_pq_condition_status(THD *thd) { + set_pq_dop(thd); + + if (thd->pq_dop > 0) { + thd->m_suite_for_pq = PqConditionStatus::ENABLED; + } else { + thd->m_suite_for_pq = PqConditionStatus::NOT_SUPPORTED; + } +} + +bool suite_for_parallel_query(THD *thd) { + if (thd->in_sp_trigger != 0 || // store procedure or trigger + thd->m_attachable_trx || // attachable transaction + thd->tx_isolation == + ISO_SERIALIZABLE) { // serializable without snapshot read + return false; + } + + return true; +} + +bool suite_for_parallel_query(LEX *lex) { + if (lex->in_execute_ps) { + return false; + } + + return true; +} + +bool suite_for_parallel_query(Query_expression *unit) { + if (!unit->is_simple()) { + return false; + } + + return true; +} + +bool suite_for_parallel_query(TABLE_LIST *tbl_list) { + if (tbl_list->is_view() || // view + tbl_list->lock_descriptor().type > TL_READ || // explicit table lock + tbl_list->is_fulltext_searched() || // fulltext match search + current_thd->locking_clause) { + return false; + } + + TABLE *tb = tbl_list->table; + if (tb != nullptr && + (tb->s->tmp_table != NO_TMP_TABLE || // template table + tb->file->ht->db_type != DB_TYPE_INNODB || // Non-InnoDB table + tb->part_info)) { // partition table + return false; + } + + return true; +} + +bool suite_for_parallel_query(Query_block *select) { + if (select->first_inner_query_expression() != + nullptr || // nesting subquery, including view〝derived + // table〝subquery condition and so on. + select->outer_query_block() != nullptr || // nested subquery + select->is_distinct() || // select distinct + select->saved_windows_elements) { // windows function + return false; + } + + for (TABLE_LIST *tbl_list = select->table_list.first; tbl_list != nullptr; + tbl_list = tbl_list->next_local) { + if (!suite_for_parallel_query(tbl_list)) { + return false; + } + } + + for (TABLE_LIST *tbl_list = select->table_list.first; tbl_list != nullptr; + tbl_list = tbl_list->next_global) { + if (!suite_for_parallel_query(tbl_list)) { + return false; + } + } + + for (TABLE_LIST *tbl_list = select->leaf_tables; tbl_list != nullptr; + tbl_list = tbl_list->next_leaf) { + if (!suite_for_parallel_query(tbl_list)) { + return false; + } + } + return true; +} + +bool suite_for_parallel_query(JOIN *join) { + if ((join->best_read < join->thd->variables.parallel_cost_threshold) || + (join->primary_tables == join->const_tables) || + (join->select_distinct || join->select_count) || + (join->query_block_fields->size() > MAX_FIELDS) || + (join->rollup_state != JOIN::RollupState::NONE) || + (join->zero_result_cause != nullptr)) { + return false; + } + QEP_TAB *tab = &join->qep_tab[join->const_tables]; + // only support table/index full/range scan + join_type scan_type = tab->type(); + if (scan_type != JT_ALL && scan_type != JT_INDEX_SCAN && + scan_type != JT_REF && + (scan_type != JT_RANGE || !tab->quick() || + tab->quick()->quick_select_type() != PQ_RANGE_SELECT)) { + return false; + } + if (!check_pq_select_fields(join)) { + return false; + } + + return true; +} + +bool check_pq_running_threads(uint dop, ulong timeout_ms) { + bool success = false; + mysql_mutex_lock(&LOCK_pq_threads_running); + if (parallel_threads_running + dop > parallel_max_threads) { + if (timeout_ms > 0) { + struct timespec start_ts; + struct timespec end_ts; + struct timespec abstime; + ulong wait_timeout = timeout_ms; + int wait_result; + + start: + set_timespec(&start_ts, 0); + /* Calcuate the waiting period. */ + abstime.tv_sec = start_ts.tv_sec + wait_timeout / TIME_THOUSAND; + abstime.tv_nsec = + start_ts.tv_nsec + (wait_timeout % TIME_THOUSAND) * TIME_MILLION; + if (abstime.tv_nsec >= TIME_BILLION) { + abstime.tv_sec++; + abstime.tv_nsec -= TIME_BILLION; + } + wait_result = mysql_cond_timedwait(&COND_pq_threads_running, + &LOCK_pq_threads_running, &abstime); + if (parallel_threads_running + dop <= parallel_max_threads) { + success = true; + } else { + success = false; + if (!wait_result) { // wait isn't timeout + set_timespec(&end_ts, 0); + ulong difftime = (end_ts.tv_sec - start_ts.tv_sec) * TIME_THOUSAND + + (end_ts.tv_nsec - start_ts.tv_nsec) / TIME_MILLION; + wait_timeout -= difftime; + goto start; + } + } + } + } else { + success = true; + } + + if (success) { + parallel_threads_running += dop; + current_thd->pq_threads_running += dop; + } + + mysql_mutex_unlock(&LOCK_pq_threads_running); + return success; +} + +class PQCheck { + public: + explicit PQCheck(Query_block *select_lex_arg) : select_lex(select_lex_arg) {} + + virtual ~PQCheck() {} + + virtual bool suite_for_parallel_query(); + + protected: + virtual void set_select_id(); + virtual void set_select_type(); + + protected: + uint select_id{}; + enum_explain_type select_type{}; + + private: + Query_block *select_lex; +}; + +class PlanReadyPQCheck : public PQCheck { + public: + explicit PlanReadyPQCheck(Query_block *select_lex_arg) + : PQCheck(select_lex_arg), join(select_lex_arg->join) {} + + ~PlanReadyPQCheck() {} + + bool suite_for_parallel_query() override; + + private: + void set_select_id() override; + void set_select_type() override; + + private: + JOIN *join; + QEP_TAB *tab{nullptr}; +}; + +void PQCheck::set_select_id() { select_id = select_lex->select_number; } + +void PQCheck::set_select_type() { select_type = select_lex->type(); } + +bool PQCheck::suite_for_parallel_query() { + set_select_id(); + set_select_type(); + + if (select_id > 1 || select_type != enum_explain_type::EXPLAIN_SIMPLE) { + return false; + } + + return true; +} + +void PlanReadyPQCheck::set_select_id() { + if (tab && sj_is_materialize_strategy(tab->get_sj_strategy())) { + select_id = tab->sjm_query_block_id(); + } else { + PQCheck::set_select_id(); + } +} + +void PlanReadyPQCheck::set_select_type() { + if (tab && sj_is_materialize_strategy(tab->get_sj_strategy())) { + select_type = enum_explain_type::EXPLAIN_MATERIALIZED; + } else { + PQCheck::set_select_type(); + } +} + +bool PlanReadyPQCheck::suite_for_parallel_query() { + for (uint t = 0; t < join->tables; t++) { + tab = join->qep_tab + t; + if (!tab->position()) { + continue; + } + + if (!PQCheck::suite_for_parallel_query()) { + return false; + } + } + + return true; +} + +bool check_select_id_and_type(Query_block *select_lex) { + JOIN *join = select_lex->join; + std::unique_ptr check; + bool ret = false; + + if (join == nullptr) { + check.reset(new PQCheck(select_lex)); + goto END; + } + + switch (join->get_plan_state()) { + case JOIN::NO_PLAN: + case JOIN::ZERO_RESULT: + case JOIN::NO_TABLES: { + check.reset(new PQCheck(select_lex)); + break; + } + + case JOIN::PLAN_READY: { + check.reset(new PlanReadyPQCheck(select_lex)); + break; + } + + default: + assert(0); + } + +END: + if (check != nullptr) { + ret = check->suite_for_parallel_query(); + } + + return ret; +} + +bool check_pq_conditions(THD *thd) { + // max PQ memory size limit + if (get_pq_memory_total() >= parallel_memory_limit) { + atomic_add(parallel_memory_refused, 1); + return false; + } + + // max PQ threads limit + if (!check_pq_running_threads(thd->pq_dop, + thd->variables.parallel_queue_timeout)) { + atomic_add(parallel_threads_refused, 1); + return false; + } + + // RBO limit + if (!suite_for_parallel_query(thd)) { + return false; + } + + if (!suite_for_parallel_query(thd->lex)) { + return false; + } + + if (!suite_for_parallel_query(thd->lex->unit)) { + return false; + } + + Query_block *select = thd->lex->unit->first_query_block(); + if (!suite_for_parallel_query(select)) { + return false; + } + + if (!suite_for_parallel_query(select->join)) { + return false; + } + + if (!check_select_id_and_type(select)) { + return false; + } + + if (!choose_parallel_scan_table(select->join)) { + return false; + } + + return true; +} diff --git a/sql/pq_condition.h b/sql/pq_condition.h new file mode 100644 index 000000000..290058550 --- /dev/null +++ b/sql/pq_condition.h @@ -0,0 +1,35 @@ +#ifndef PQ_CONDITION_H +#define PQ_CONDITION_H + +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2021, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +class THD; + +enum class PqConditionStatus { INIT, NOT_SUPPORTED, ENABLED, SUPPORTED }; + +void set_pq_condition_status(THD *thd); + +bool check_pq_conditions(THD *thd); + +#endif /* PQ_CONDITION_H */ diff --git a/sql/pq_global.h b/sql/pq_global.h new file mode 100644 index 000000000..1c27bd615 --- /dev/null +++ b/sql/pq_global.h @@ -0,0 +1,47 @@ +#ifndef MYSQL_PQ_SQL_GLOBAL_H +#define MYSQL_PQ_SQL_GLOBAL_H + +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include +#include +#include "my_compiler.h" +#include "my_alloc.h" + +#define TIME_THOUSAND 1000 +#define TIME_MILLION 1000000 +#define TIME_BILLION 1000000000 + +template +T atomic_add(T &value, T n) { + return __sync_fetch_and_add(&value, n); +} + +template +T atomic_sub(T &value, T n) { + return __sync_fetch_and_sub(&value, n); +} + +#endif //MYSQL_PQ_SQL_GLOBAL_H + diff --git a/sql/pq_range.h b/sql/pq_range.h new file mode 100644 index 000000000..430c9e8a9 --- /dev/null +++ b/sql/pq_range.h @@ -0,0 +1,39 @@ +#ifndef PQ_RANGE_INCLUDED +#define PQ_RANGE_INCLUDED + +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +enum PQ_RANGE_TYPE { + PQ_QUICK_SELECT_NONE, + PQ_RANGE_SELECT, + PQ_RANGE_SELECT_DESC, + PQ_SKIP_SCAN_SELECT, + PQ_GROUP_MIN_MAX_SELECT, + PQ_INDEX_MERGE_SELECT, + PQ_ROR_INTERSECT_SELECT, + PQ_ROR_UNION_SELECT, + PQ_QUICK_SELECT_INVALID +}; + +#endif /* PQ_RANGE_INCLUDED */ diff --git a/sql/protocol_classic.h b/sql/protocol_classic.h index 557569c7e..75e9f2061 100644 --- a/sql/protocol_classic.h +++ b/sql/protocol_classic.h @@ -2,6 +2,7 @@ #define PROTOCOL_CLASSIC_INCLUDED /* Copyright (c) 2002, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -60,7 +61,7 @@ class Protocol_classic : public Protocol { THD *m_thd; String *packet; String convert; - uint field_pos; + int field_pos; bool send_metadata; #ifndef NDEBUG enum enum_field_types *field_types; diff --git a/sql/psi_memory_key.cc b/sql/psi_memory_key.cc index 1658c7754..8bcf9a586 100644 --- a/sql/psi_memory_key.cc +++ b/sql/psi_memory_key.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -147,6 +148,7 @@ PSI_memory_key key_memory_user_var_entry; PSI_memory_key key_memory_user_var_entry_value; PSI_memory_key key_memory_sp_cache; PSI_memory_key key_memory_write_set_extraction; +PSI_memory_key key_memory_pq_mem_root; #ifdef HAVE_PSI_INTERFACE @@ -168,6 +170,8 @@ static PSI_memory_info all_server_memory[] = { PSI_DOCUMENT_ME}, {&key_memory_thd_main_mem_root, "THD::main_mem_root", PSI_FLAG_THREAD, 0, "Main mem root used for e.g. the query arena."}, + {&key_memory_pq_mem_root, "THD::parallel_query_mem_root", PSI_FLAG_THREAD, 0, + PSI_DOCUMENT_ME}, {&key_memory_help, "help", 0, 0, "Temporary memroot used to print help texts as part of usage " "description."}, diff --git a/sql/psi_memory_key.h b/sql/psi_memory_key.h index df52ef8eb..674806434 100644 --- a/sql/psi_memory_key.h +++ b/sql/psi_memory_key.h @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -164,6 +165,7 @@ extern PSI_memory_key key_memory_table_mapping_root; extern PSI_memory_key key_memory_table_share; extern PSI_memory_key key_memory_test_quick_select_exec; extern PSI_memory_key key_memory_thd_main_mem_root; +extern PSI_memory_key key_memory_pq_mem_root; extern PSI_memory_key key_memory_thd_timer; extern PSI_memory_key key_memory_thd_transactions; extern PSI_memory_key key_memory_user_conn; diff --git a/sql/query_result.cc b/sql/query_result.cc index 745aa140e..cd26aa8f8 100644 --- a/sql/query_result.cc +++ b/sql/query_result.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -28,6 +29,7 @@ #include "my_config.h" #ifdef HAVE_UNISTD_H #include +#include "sql/sql_tmp_table.h" #endif #include @@ -56,6 +58,9 @@ #include "sql/system_variables.h" #include "sql_string.h" #include "template_utils.h" // pointer_cast +#include "sql_optimizer.h" +#include "msg_queue.h" +#include "sql/handler.h" using std::min; @@ -116,6 +121,230 @@ bool Query_result_send::send_eof(THD *thd) { return false; } +Query_result_mq::Query_result_mq(JOIN *join, + MQueue_handle *msg_handler, + handler *file, bool stab_output) : + Query_result(), m_table(nullptr), + m_param(nullptr), + send_fields(nullptr), + send_fields_size(0), + mq_fields_data(nullptr), + mq_fields_null_array(nullptr), + mq_fields_null_flag(nullptr) + { + m_join = join; + m_handler = msg_handler; + m_file = file; + m_stable_output = stab_output; + } + +#define MQ_FIELDS_DATA_HEADER_LENGTH 4 + +bool Query_result_mq::send_result_set_metadata(THD *thd, const mem_root_deque &list MY_ATTRIBUTE((unused)), + uint flags MY_ATTRIBUTE((unused))){ + + m_param = new (thd->pq_mem_root) Temp_table_param (); + if(!m_param || m_join->make_pq_tables_info()) + return true; + + send_fields = &m_join->tmp_fields[REF_SLICE_PQ_TMP]; + uint field_size = send_fields->size(); + send_fields_size = field_size + MQ_FIELDS_DATA_HEADER_LENGTH; + + mq_fields_data = new (thd->pq_mem_root) Field_raw_data[send_fields_size]{}; + mq_fields_null_array = new (thd->pq_mem_root) bool[2 * field_size]; + mq_fields_null_flag = new (thd->pq_mem_root) char[field_size / MQ_FIELDS_DATA_HEADER_LENGTH + 2]; + + if(!mq_fields_data || !mq_fields_null_array || !mq_fields_null_flag) { + return true; + } + + return false; +} + +bool Query_result_mq::send_data(THD *thd, const mem_root_deque &items MY_ATTRIBUTE((unused))) { + DBUG_ENTER("Query_result_mq::send_data"); + int null_num = 0; + uint32 total_copy_bytes = 0; + int i, j; + + //empty message + if (send_fields_size == MQ_FIELDS_DATA_HEADER_LENGTH){ + thd->inc_sent_row_count(1); + DBUG_RETURN(m_handler->send_exception_msg(EMPTY_MSG)); + } + + Field *result_field = nullptr; + int fields_idx= MQ_FIELDS_DATA_HEADER_LENGTH; + /* currently supporting ITEM_FIELD and ITEM_FUNC */ + //for(Item *item = it++; item; item = it++, fields_idx++){ + for(Item *item : *send_fields){ + assert(!item->skip_create_tmp_table); + //c0: skip null item + if (item->type() == Item::NULL_ITEM || item->type() == Item::STRING_ITEM) { + pq_build_mq_item(item, &mq_fields_data[fields_idx], + mq_fields_null_array, null_num, total_copy_bytes); + fields_idx++; + continue; + } + + //c2: check Item_copy. In the original execution plan, const_item will be + //transformed into Item_copy in tmp_table (or ORDERED_GROUP_BY) + #if 0 + if (item->type() == Item::COPY_STR_ITEM) { + Item *orig_item = down_cast(item)->get_item(); + assert(orig_item && !orig_item->skip_create_tmp_table); + if (orig_item->const_item() || + orig_item->basic_const_item()) { + pq_build_mq_item(orig_item, &mq_fields_data[fields_idx], + mq_fields_null_array,null_num, total_copy_bytes); + continue; + } + } + #endif + + //c3: check item_result_field and item_field + result_field = item->get_result_field(); + if (!result_field) { + if(item->type() == Item::FIELD_ITEM + && DBUG_EVALUATE_IF("pq_mq_error4", false, true)) { + result_field = down_cast(item)->field; + } else { + //c4: other cases will be shielded in JOIN::check_first_rewritten_tab + sql_print_error("not supported field"); + m_handler->send_exception_msg(ERROR_MSG); + DBUG_RETURN(true); + } + } else { + item->save_in_field(result_field, true); + } + + assert(result_field); + pq_build_mq_fields(result_field, &mq_fields_data[fields_idx], + mq_fields_null_array, null_num, total_copy_bytes); + + fields_idx++; + } + + assert((uint)null_num == 2 * (send_fields_size - MQ_FIELDS_DATA_HEADER_LENGTH)); + uint16 null_len = ((null_num % 8 == 0) ? + null_num / 8 : + null_num / 8 + 1) + 1; + + memset(mq_fields_null_flag, 0, null_len); + + /* + * Now, we use 2 bps/field as a header to send each Item, where the first bit indicates that the corresponding + * item is a CONST_ITEM or not, and the second bit indicates that the related result_field is NULL_FILED or not. + * These two bits have at most four status: + * (0, 0) => NOT_CONST_ITEM & NON_NULL_FIELD + * (0, 1) => NOT_CONST_ITEM & NULL_FIELD + * (1, 0) => CONST_ITEM & NON_NULL_FIELD + * (1, 1) => CONST_ITEM & NULL_FIELD (such as Item_null) + * + * Only for the first case (0, 0), we need send the field data to MQ. + * + * null_flag[j] = 0 indicates the corresponding field is NOT NULL (or it is not a const_item()). + * otherwise, null_flag[j] = 1. + */ + + for(i = 0; i < null_num; i++){ + if(mq_fields_null_array[i]){ + j = (i >> 3) + 1; + mq_fields_null_flag[j] += 1 << (7 - (i & 7)); + } + } + + mq_fields_data[3].m_ptr = (uchar *)mq_fields_null_flag; + mq_fields_data[3].m_len = null_len; + total_copy_bytes += null_len; + + /* there are at most 4096 fields and thus null_len is less than 2 * 2^12/8 = 2^10. + * So, we can use 2 bytes to store it. + */ + mq_fields_data[2].m_ptr = (uchar *) &null_len; + mq_fields_data[2].m_len = 2; + total_copy_bytes += 2; + + if (m_stable_output) { + assert(m_file && m_file->ht->db_type == DB_TYPE_INNODB); + mq_fields_data[1].m_ptr = &m_file->ref[0]; + mq_fields_data[1].m_len = m_file->ref_length; + mq_fields_data[1].m_var_len = 0; + mq_fields_data[1].m_need_send = m_file->ref_length ? true : false; + total_copy_bytes += m_file->ref_length; + } else { + mq_fields_data[1].m_need_send = false; + } + + /* for total_copy_bytes, it is less than 2^16 * 2^16 = 2^32 and + * we can use 4 bytes to store it + */ + mq_fields_data[0].m_ptr = (uchar *) &total_copy_bytes; + mq_fields_data[0].m_len = 4; + + // send messages to mq + MQ_RESULT res; + for (i = 0; i < (int) send_fields_size; i++) { + /* for the case of NULL field, we need not send msg to MQ */ + if (!mq_fields_data[i].m_need_send) + continue; + + res = m_handler->send(&mq_fields_data[i]); + + //In some case, we should detach the MQ and thus the MQ_DETACHED status can also + // be considered as an normal status. + if (res == MQ_DETACHED) + DBUG_RETURN(false); + + if (res != MQ_SUCCESS + || DBUG_EVALUATE_IF("pq_mq_error5", true, false)) { + sql_print_error("send message to MQ error"); + m_handler->send_exception_msg(ERROR_MSG); + DBUG_RETURN(true); + } + } + + thd->inc_sent_row_count(1); + DBUG_RETURN(false); +} + +void Query_result_mq::cleanup(THD *thd MY_ATTRIBUTE((unused))) { + if (m_param) { + m_param->cleanup(); + destroy(m_param); + m_param = nullptr; + } + + if (m_table) { + close_tmp_table(m_table); + free_tmp_table(m_table); + m_table = nullptr; + } + + if (mq_fields_data) { + destroy(mq_fields_data); + mq_fields_data = nullptr; + } + + if (mq_fields_null_array) { + destroy(mq_fields_null_array); + mq_fields_null_array = nullptr; + } + + if (mq_fields_null_flag) { + destroy(mq_fields_null_flag); + mq_fields_null_flag = nullptr; + } +} + +bool Query_result_mq::send_eof(THD * thd) { + + if (thd->is_error()) return true; + ::my_eof(thd); + return false; +} + static const String default_line_term("\n", default_charset_info); static const String default_escaped("\\", default_charset_info); static const String default_field_term("\t", default_charset_info); diff --git a/sql/query_result.h b/sql/query_result.h index e6e297bc7..4fc3495fb 100644 --- a/sql/query_result.h +++ b/sql/query_result.h @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -44,9 +45,15 @@ class Item; class Item_subselect; class PT_select_var; class Query_expression; +class TABLE; +class Temp_table_param; class THD; struct CHARSET_INFO; struct TABLE_LIST; +class JOIN; +class MQueue_handle; +struct Field_raw_data; +class handler; /* This is used to get result from a query @@ -68,6 +75,8 @@ class Query_result { */ double estimated_cost; + virtual MQueue_handle *get_mq_handler () { return nullptr; } + Query_result() : unit(nullptr), estimated_rowcount(0), estimated_cost(0) {} virtual ~Query_result() {} @@ -208,6 +217,48 @@ class Query_result_interceptor : public Query_result { bool is_interceptor() const final { return true; } }; +class Query_result_mq : public Query_result { +public: + Query_result_mq () : Query_result(), m_table(nullptr), + m_param(nullptr), + m_handler(nullptr), + m_join(nullptr), + send_fields(nullptr), + send_fields_size(0), + mq_fields_data(nullptr), + mq_fields_null_array(nullptr), + mq_fields_null_flag(nullptr), + m_file(nullptr), + m_stable_output(false) + {} + + Query_result_mq (JOIN *join, MQueue_handle *msg_handler, + handler *file=nullptr, bool stab_output=false); + bool send_result_set_metadata(THD *thd, const mem_root_deque &list, + uint flags) override; + bool send_data(THD *thd, const mem_root_deque &items) override; + bool send_eof(THD *thd MY_ATTRIBUTE((unused))) override; + bool check_simple_query_block() const override { return false; } + void cleanup(THD *) override; + MQueue_handle *get_mq_handler() override { return m_handler; } + + TABLE *m_table{nullptr}; + Temp_table_param *m_param{nullptr}; + MQueue_handle *m_handler{nullptr}; + +private: + JOIN *m_join{nullptr}; + mem_root_deque *send_fields{nullptr}; + uint send_fields_size{0}; + Field_raw_data *mq_fields_data{nullptr}; + bool *mq_fields_null_array{nullptr}; + char *mq_fields_null_flag{nullptr}; + + //for stable output + handler *m_file; + bool m_stable_output; +}; + class Query_result_send : public Query_result { /** True if we have sent result set metadata to the client. diff --git a/sql/records.cc b/sql/records.cc index 48b49d471..a91977f81 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -53,6 +54,11 @@ #include "sql/sql_tmp_table.h" #include "sql/table.h" #include "sql/timing_iterator.h" +#include "sql/sql_parallel.h" +#include "sql/exchange_sort.h" +#include "sql/sql_parse.h" +#include "sql/mysqld.h" +#include "sql/exchange.h" using std::string; using std::vector; @@ -152,7 +158,7 @@ template class IndexScanIterator; See AccessPath::count_examined_rows. */ AccessPath *create_table_access_path(THD *thd, TABLE *table, QEP_TAB *qep_tab, - bool count_examined_rows) { + bool count_examined_rows, bool *pq_replace_path) { // If only 'table' is given, assume no quick, no condition. if (table != nullptr && qep_tab != nullptr) { assert(table == qep_tab->table()); @@ -160,16 +166,23 @@ AccessPath *create_table_access_path(THD *thd, TABLE *table, QEP_TAB *qep_tab, table = qep_tab->table(); } + bool could_replace_path = false; + AccessPath *path; if (qep_tab != nullptr && qep_tab->quick() != nullptr) { path = NewIndexRangeScanAccessPath(thd, table, qep_tab->quick(), count_examined_rows); + could_replace_path = true; } else if (qep_tab != nullptr && qep_tab->table_ref != nullptr && qep_tab->table_ref->is_recursive_reference()) { path = NewFollowTailAccessPath(thd, table, count_examined_rows); } else { path = NewTableScanAccessPath(thd, table, count_examined_rows); + could_replace_path = true; } + + if (pq_replace_path) *pq_replace_path = could_replace_path; + if (qep_tab != nullptr && qep_tab->position() != nullptr) { SetCostOnTableAccessPath(*thd->cost_model(), qep_tab->position(), /*is_after_filter=*/false, path); @@ -320,6 +333,344 @@ int IndexRangeScanIterator::Read() { return 0; } +ParallelScanIterator::ParallelScanIterator(THD *thd, QEP_TAB *tab, TABLE *table, + ha_rows *examined_rows, JOIN *join, + Gather_operator *gather, + bool stab_output, uint ref_length) + : TableRowIterator(thd, table), + m_record(table->record[0]), + m_examined_rows(examined_rows), + m_dop(gather->m_dop), + m_join(join), + m_gather(gather), + m_record_gather(nullptr), + m_order(nullptr), + m_tab(tab), + m_stable_sort(stab_output), + m_ref_length(ref_length) { + thd->pq_iterator = this; +} + +/** + * construct filesort on leader when needing stab_output or merge_sort + * + * @retavl: false if success, and otherwise true + */ +bool ParallelScanIterator::pq_make_filesort(Filesort **sort) { + *sort = NULL; + + /** construct sort order based on group */ + if (m_join->pq_rebuilt_group) { + assert(m_join->query_block->saved_group_list_ptrs); + restore_list(m_join->query_block->saved_group_list_ptrs, + m_join->query_block->group_list); + m_order = restore_optimized_group_order( + m_join->query_block->group_list, + m_join->saved_optimized_vars.optimized_group_flags); + } else { + /** + * if sorting is built after the first rewritten table, then + * we have no need to rebuilt the sort order on leader, because + * leader will do SortingIterator. + */ + if (m_join->pq_last_sort_idx >= (int)m_join->tables && + m_join->qep_tab[m_join->pq_last_sort_idx].filesort != nullptr) { + return false; + } else { + if ((m_order = m_join->order.order) == nullptr) { + if (m_join->m_ordered_index_usage == JOIN::ORDERED_INDEX_ORDER_BY && + m_join->query_block->saved_order_list_ptrs) { + restore_list(m_join->query_block->saved_order_list_ptrs, + m_join->query_block->order_list); + m_order = restore_optimized_group_order( + m_join->query_block->order_list, + m_join->saved_optimized_vars.optimized_order_flags); + } else { + std::vector used_key_fields; + if (get_table_key_fields(&m_join->qep_tab0[m_tab->pos], + used_key_fields) || + DBUG_EVALUATE_IF("pq_msort_error1", true, false)) + return true; + + if (set_key_order(m_tab, used_key_fields, &m_order, + &m_join->ref_items[REF_SLICE_PQ_TMP]) || + DBUG_EVALUATE_IF("pq_msort_error2", true, false)) + return true; + } + } + } + } + + /** support stable sort on TABLE/INDEX SCAN */ + if (m_order || m_stable_sort) { + *sort = m_tab->filesort; + if (!(*sort)) { + (*sort) = new (m_join->thd->pq_mem_root) + Filesort(m_join->thd, {m_tab->table()}, false, m_order, HA_POS_ERROR, + false, false, false, false); + if (!(*sort) || DBUG_EVALUATE_IF("pq_msort_error3", true, false)) + return true; + } + } + return false; +} + +/** + * init the mq_record_gather + */ +bool ParallelScanIterator::pq_init_record_gather() { + THD *thd = m_join->thd; + Filesort *sort = NULL; + if (pq_make_filesort(&sort)) return true; + m_record_gather = new (thd->pq_mem_root) MQ_record_gather(thd, m_tab); + if (!m_record_gather || + m_record_gather->mq_scan_init(sort, m_gather->m_dop, m_ref_length, + m_stable_sort) || + DBUG_EVALUATE_IF("pq_msort_error4", true, false)) + return true; + + /** set each worker's MQ_handle */ + for (uint i = 0; i < m_gather->m_dop; i++) { + m_gather->m_workers[i]->m_handle = + m_record_gather->m_exchange->get_mq_handle(i); + } + return false; +} + +/** + * launch worker threads + * + * @retval: false if success, and otherwise true + */ +bool ParallelScanIterator::pq_launch_worker() { + THD *thd = m_join->thd; + assert(thd == current_thd); + + Gather_operator *gather = m_tab->gather; + PQ_worker_manager **workers = gather->m_workers; + int launch_workers = 0; + + /** when workers encounter error during execution, directly abort the parallel + * execution */ + for (uint i = 0; i < m_gather->m_dop; i++) { + assert(!workers[i]->thd_worker && + (workers[i]->m_status == PQ_worker_state::INIT)); + if (thd->is_error() || thd->pq_error) goto err; + my_thread_handle id; + id.thread = 0; + /** + * pq_worker_error8: all workers are fialed to landuch + * pq_worker_error9: worker's id in [0, 2, 4, ..] are failed to lanuch + */ + if (DBUG_EVALUATE_IF("pq_worker_error8", false, true) && + DBUG_EVALUATE_IF("pq_worker_error9", (i % 2), true)) { + mysql_thread_create(key_thread_parallel_query, &id, NULL, pq_worker_exec, + (void *)workers[i]); + } + workers[i]->thread_id = id; + int expected_status = PQ_worker_state::READY | PQ_worker_state::COMPELET | + PQ_worker_state::ERROR; + if (id.thread != 0) { + /** Record the thread id so that we can later determine whether the thread + * started */ + workers[i]->m_active = workers[i]->wait_for_status(thd, expected_status); + /** partial workers may fail before execution */ + if (!workers[i]->m_active || + DBUG_EVALUATE_IF("pq_worker_error7", (i >= m_gather->m_dop / 2), + false)) { + goto err; + } + launch_workers++; + } else { + sql_print_warning("worker %d has failed to start up\n", i); + MQueue_handle *mq_handler = m_record_gather->m_exchange->get_mq_handle(i); + if (mq_handler) mq_handler->set_datched_status(MQ_HAVE_DETACHED); + } + } + /** if all workers are not launched, then directly return false */ + if (!launch_workers) goto err; + return false; + +err: + for (uint i = 0; i < m_gather->m_dop; i++) { + if (workers[i]->thread_id.thread && workers[i]->thd_worker) { + workers[i]->thd_worker->pq_error = true; + } + } + return true; +} + +/** + * wait all workers finish their execution + */ +void ParallelScanIterator::pq_wait_workers_finished() { + THD *leader_thd = m_join->thd; + assert(leader_thd == current_thd); + + /** + * leader first detached the message queue, and then wait workers finish + * the execution. The reason for detach MQ is that leader has fetched the + * satisfied #records (e.g., limit operation). + */ + if (m_record_gather) { + Exchange *exchange = m_record_gather->m_exchange; + MQueue_handle *m_handle = nullptr; + for (uint i = 0; i < m_gather->m_dop; i++) { + if ((m_handle = exchange->get_mq_handle(i))) { + m_handle->set_datched_status(MQ_HAVE_DETACHED); + } + } + } + + /** + * wait all such workers to finish execution, two conditions must meet: + * c1: the worker thread has been created + * c2: the worker has not yet finished + */ + int expected_status = PQ_worker_state::COMPELET | PQ_worker_state::ERROR; + for (uint i = 0; i < m_gather->m_dop; i++) { + if (m_gather->m_workers[i]->thread_id.thread != 0) // c1 + { + if (m_gather->m_workers[i]->m_active && + !(((unsigned int)m_gather->m_workers[i]->m_status) & + PQ_worker_state::COMPELET)) { + m_gather->m_workers[i]->wait_for_status(leader_thd, expected_status); + } + my_thread_join(&m_gather->m_workers[i]->thread_id, NULL); + } + } +} + +int ParallelScanIterator::pq_error_code() { + THD *thd = m_join->thd; + + if (m_gather->m_ha_err == HA_ERR_TABLE_DEF_CHANGED) { + m_gather->m_ha_err = 0; + return HA_ERR_TABLE_DEF_CHANGED; + } + + if (thd->is_killed()) { + thd->send_kill_message(); + } + + /** collect worker threads status from DA info */ + JOIN *tmplate_join = m_gather->m_template_join; + THD *temp_thd = tmplate_join->thd; + thd->pq_status_reset(); + thd->pq_merge_status(temp_thd); + Diagnostics_area *da = temp_thd->get_stmt_da(); + if (temp_thd->is_error()) { + temp_thd->raise_condition(da->mysql_errno(), da->returned_sqlstate(), + Sql_condition::SL_ERROR, da->message_text()); + } + + if (da->cond_count() > 0) { + Diagnostics_area::Sql_condition_iterator it = da->sql_conditions(); + const Sql_condition *cond; + while ((cond = it++)) { + thd->raise_condition(cond->mysql_errno(), NULL, cond->severity(), + cond->message_text()); + } + } + /** output parallel error code */ + if (!temp_thd->is_error() && !thd->is_error() && thd->pq_error && + !thd->running_explain_analyze) { + my_error(ER_PARALLEL_EXEC_ERROR, MYF(0)); + } + return 1; +} + +bool ParallelScanIterator::Init() { + assert(current_thd == m_join->thd); + if (m_gather->init() || /** cur innodb data, + should be called first(will change dop based on + split count) */ + pq_init_record_gather() || /** init mq_record_gather */ + pq_launch_worker() || /** launch worker threads */ + DBUG_EVALUATE_IF("pq_worker_error6", true, false)) { + m_join->thd->pq_error = true; + return true; + } + return false; +} + +int ParallelScanIterator::Read() { + /** kill query */ + if (m_join->thd->is_killed()) { + m_join->thd->send_kill_message(); + return 1; + } + /** fetch message from MQ to table->record[0] */ + if (m_record_gather->mq_scan_next()) return 0; + return -1; +} + +int ParallelScanIterator::End() { + /** wait all workers to finish their execution */ + pq_wait_workers_finished(); + /** output error code */ + return pq_error_code(); +} + +ParallelScanIterator::~ParallelScanIterator() { + table()->file->ha_index_or_rnd_end(); + /** cleanup m_record_gather */ + if (m_record_gather) { + m_record_gather->mq_scan_end(); + } +} + +PQblockScanIterator::PQblockScanIterator(THD *thd, TABLE *table, uchar *record, + ha_rows *examined_rows, + Gather_operator *gather, + bool need_rowid) + : TableRowIterator(thd, table), + m_record(record), + m_examined_rows(examined_rows), + m_pq_ctx(gather->m_pq_ctx), + keyno(gather->keyno), + m_gather(gather), + m_need_rowid(need_rowid) { + thd->pq_iterator = this; +} + +bool PQblockScanIterator::Init() { + table()->file->pq_worker_scan_init(keyno, m_pq_ctx); + return false; +} + +int PQblockScanIterator::End() { + assert(thd() && thd()->pq_leader); + if (m_gather) m_gather->signalAll(); + return -1; +} + +PQblockScanIterator::~PQblockScanIterator() {} + +int PQblockScanIterator::Read() { + int tmp; + while ((tmp = table()->file->ha_pq_next(m_record, m_pq_ctx))) { + /* + ha_rnd_next can return RECORD_DELETED for MyISAM when one thread is + reading and another deleting without locks. + */ + if (tmp == HA_ERR_RECORD_DELETED && !thd()->killed) continue; + return HandleError(tmp); + } + + if (m_examined_rows != nullptr) { + ++*m_examined_rows; + } + // write row_id into file + if (m_need_rowid) { + assert(table()->file->ht->db_type == DB_TYPE_INNODB); + assert(table()->record[0] == m_record); + table()->file->position(m_record); + } + + return 0; +} + TableScanIterator::TableScanIterator(THD *thd, TABLE *table, double expected_rows, ha_rows *examined_rows) diff --git a/sql/records.h b/sql/records.h index 5b6f47a85..20d773586 100644 --- a/sql/records.h +++ b/sql/records.h @@ -1,6 +1,7 @@ #ifndef SQL_RECORDS_H #define SQL_RECORDS_H /* Copyright (c) 2008, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -40,7 +41,7 @@ struct AccessPath; struct TABLE; AccessPath *create_table_access_path(THD *thd, TABLE *table, QEP_TAB *qep_tab, - bool count_examined_rows); + bool count_examined_rows, bool *pq_replace_path = nullptr); /** Creates an iterator for the given table, then calls Init() on the resulting diff --git a/sql/row_iterator.h b/sql/row_iterator.h index 0f014582e..aaf126fce 100644 --- a/sql/row_iterator.h +++ b/sql/row_iterator.h @@ -2,6 +2,7 @@ #define SQL_ROW_ITERATOR_H_ /* Copyright (c) 2018, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -186,6 +187,14 @@ class RowIterator { virtual RowIterator *real_iterator() { return this; } virtual const RowIterator *real_iterator() const { return this; } + /** + * Ends the iterator + * @return 0: the normal iterator + * @return 1: the ParallelScanIterator + * @retrun -1: the PQblockScanIterator + */ + virtual int End() { return 0; } + protected: THD *thd() const { return m_thd; } diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 1d9defb2c..abd7484e4 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -142,6 +143,9 @@ extern "C" void handle_fatal_signal(int sig) { case THD::KILL_TIMEOUT: kreason = "KILL_TIMEOUT"; break; + case THD::KILL_PQ_QUERY: + kreason = "KILL_PQ_QUERY"; + break; case THD::KILLED_NO_VALUE: kreason = "KILLED_NO_VALUE"; break; diff --git a/sql/sorting_iterator.h b/sql/sorting_iterator.h index 18ce47b14..8eb9c14f3 100644 --- a/sql/sorting_iterator.h +++ b/sql/sorting_iterator.h @@ -2,6 +2,7 @@ #define SQL_SORTING_ITERATOR_H_ /* Copyright (c) 2018, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -86,6 +87,8 @@ class SortingIterator final : public RowIterator { int Read() override { return m_result_iterator->Read(); } + int End() override { return m_source_iterator->End(); } + void SetNullRowFlag(bool is_null_row) override { if (m_result_iterator == nullptr) { // If we don't have a result yet, it will come up with the flag unset. diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 5faf0a2f6..f4f4d71a3 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2002, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -2488,7 +2489,10 @@ bool sp_head::execute_trigger(THD *thd, const LEX_CSTRING &db_name, locker = MYSQL_START_SP(&psi_state, m_sp_share); #endif + // disable paralle query for trigger + thd->in_sp_trigger++; err_status = execute(thd, false); + thd->in_sp_trigger--; #ifdef HAVE_PSI_SP_INTERFACE MYSQL_END_SP(locker); #endif @@ -2666,7 +2670,10 @@ bool sp_head::execute_function(THD *thd, Item **argp, uint argcount, locker = MYSQL_START_SP(&psi_state, m_sp_share); #endif + // disable paralle query for store function + thd->in_sp_trigger++; err_status = execute(thd, true); + thd->in_sp_trigger--; #ifdef HAVE_PSI_SP_INTERFACE MYSQL_END_SP(locker); #endif @@ -2868,7 +2875,10 @@ bool sp_head::execute_procedure(THD *thd, mem_root_deque *args) { locker = MYSQL_START_SP(&psi_state, m_sp_share); #endif + // disable parallel query for store procedure + thd->in_sp_trigger++; if (!err_status) err_status = execute(thd, true); + thd->in_sp_trigger--; #ifdef HAVE_PSI_SP_INTERFACE MYSQL_END_SP(locker); #endif diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9611eed37..2d471cbcd 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -2719,7 +2720,9 @@ static bool tdc_wait_for_old_version(THD *thd, const char *db, bool res = false; mysql_mutex_lock(&LOCK_open); - if ((share = get_cached_table_share(db, table_name)) && + // when current thread is PQ thread, no need to wait for flush tables. because flush + // thread is waiting PQ leader thread finish. + if (!thd->is_worker() && (share = get_cached_table_share(db, table_name)) && share->has_old_version()) { struct timespec abstime; set_timespec(&abstime, wait_timeout); @@ -3277,7 +3280,7 @@ retry_share : { share_found: if (!(flags & MYSQL_OPEN_IGNORE_FLUSH)) { - if (share->has_old_version()) { + if (!thd->is_worker() && share->has_old_version()) { /* We already have an MDL lock. But we have encountered an old version of table in the table definition cache which is possible @@ -7921,10 +7924,16 @@ Field *find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *first_table, for (cur_table = first_table; cur_table != last_table; cur_table = cur_table->next_name_resolution_table) { - Field *cur_field = find_field_in_table_ref( + Field *cur_field = nullptr; + if (thd->parallel_exec && item->m_tableno != cur_table->m_tableno) { + continue; + } else { + cur_field = find_field_in_table_ref( thd, cur_table, name, length, item->item_name.ptr(), db, table_name, ref, want_privilege, allow_rowid, &field_index, register_tree_change, &actual_table); + } + if ((cur_field == nullptr && thd->is_error()) || cur_field == WRONG_GRANT) return nullptr; @@ -8900,7 +8909,7 @@ bool setup_fields(THD *thd, ulong want_privilege, bool allow_sum_func, bool split_sum_funcs, bool column_update, const mem_root_deque *typed_items, mem_root_deque *fields, - Ref_item_array ref_item_array) { + Ref_item_array ref_item_array, bool skip_check_grant) { DBUG_TRACE; Query_block *const select = thd->lex->current_query_block(); @@ -8913,12 +8922,14 @@ bool setup_fields(THD *thd, ulong want_privilege, bool allow_sum_func, assert(want_privilege == 0 || want_privilege == SELECT_ACL || want_privilege == INSERT_ACL || want_privilege == UPDATE_ACL); assert(!(column_update && (want_privilege & SELECT_ACL))); - if (want_privilege & SELECT_ACL) + if (!skip_check_grant) { + if (want_privilege & SELECT_ACL) thd->mark_used_columns = MARK_COLUMNS_READ; else if (want_privilege & (INSERT_ACL | UPDATE_ACL) && !column_update) thd->mark_used_columns = MARK_COLUMNS_WRITE; else thd->mark_used_columns = MARK_COLUMNS_NONE; + } DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns)); if (allow_sum_func) diff --git a/sql/sql_base.h b/sql/sql_base.h index df45796c4..bf02ba7f7 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -1,4 +1,5 @@ /* Copyright (c) 2010, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -219,7 +220,7 @@ bool setup_fields(THD *thd, ulong want_privilege, bool allow_sum_func, bool split_sum_funcs, bool column_update, const mem_root_deque *typed_items, mem_root_deque *fields, - Ref_item_array ref_item_array); + Ref_item_array ref_item_array, bool skip_check_grant = false); bool fill_record(THD *thd, TABLE *table, const mem_root_deque &fields, const mem_root_deque &values, MY_BITMAP *bitmap, MY_BITMAP *insert_into_fields_bitmap, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e01d33815..d44ee3742 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -107,6 +108,7 @@ #include "sql/xa.h" #include "template_utils.h" #include "thr_mutex.h" +#include "sql/sql_parallel.h" class Parse_tree_root; @@ -337,6 +339,40 @@ void THD::enter_stage(const PSI_stage_info *new_stage, return; } +void THD::enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex, + const PSI_stage_info *stage, PSI_stage_info *old_stage, + const char *src_function, const char *src_file, + int src_line) { + DBUG_TRACE; + mysql_mutex_assert_owner(mutex); + /* + Sic: We don't lock LOCK_current_cond here. + If we did, we could end up in deadlock with THD::awake() + which locks current_mutex while LOCK_current_cond is locked. + */ + current_mutex = mutex; + current_cond = cond; + enter_stage(stage, old_stage, src_function, src_file, src_line); + return; +} + +void THD::exit_cond(const PSI_stage_info *stage, const char *src_function, + const char *src_file, int src_line) { + DBUG_TRACE; + /* + current_mutex must be unlocked _before_ LOCK_current_cond is + locked (if that would not be the case, you'll get a deadlock if someone + does a THD::awake() on you). + */ + mysql_mutex_assert_not_owner(current_mutex.load()); + mysql_mutex_lock(&LOCK_current_cond); + current_mutex = nullptr; + current_cond = nullptr; + mysql_mutex_unlock(&LOCK_current_cond); + enter_stage(stage, nullptr, src_function, src_file, src_line); + return; +} + void Open_tables_state::set_open_tables_state(Open_tables_state *state) { this->open_tables = state->open_tables; @@ -371,6 +407,16 @@ THD::THD(bool enable_plugins) m_dd_client(new dd::cache::Dictionary_client(this)), m_query_string(NULL_CSTR), m_db(NULL_CSTR), + pq_leader(nullptr), + parallel_exec(false), + pq_threads_running(0), + pq_dop(0), + no_pq(false), + in_sp_trigger(0), + locking_clause(0), + pq_error(false), + pq_check_fields(0), + pq_check_reclen(0), rli_fake(nullptr), rli_slave(nullptr), initial_status_var(nullptr), @@ -458,6 +504,13 @@ THD::THD(bool enable_plugins) init_sql_alloc(key_memory_thd_main_mem_root, &main_mem_root, global_system_variables.query_alloc_block_size, global_system_variables.query_prealloc_size); + pq_mem_root = nullptr, + pq_mem_root = new MEM_ROOT(); + init_sql_alloc(key_memory_pq_mem_root, pq_mem_root, + global_system_variables.query_alloc_block_size, + global_system_variables.query_prealloc_size); + pq_mem_root->allocCBFunc = add_pq_memory; + pq_mem_root->freeCBFunc = sub_pq_memory; stmt_arena = this; thread_stack = nullptr; m_catalog.str = "std"; @@ -471,6 +524,7 @@ THD::THD(bool enable_plugins) num_truncated_fields = 0L; m_sent_row_count = 0L; current_found_rows = 0; + pq_current_found_rows = 0; previous_found_rows = 0; is_operating_gtid_table_implicitly = false; is_operating_substatement_implicitly = false; @@ -517,6 +571,7 @@ THD::THD(bool enable_plugins) mysql_mutex_init(key_LOCK_query_plan, &LOCK_query_plan, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_current_cond, &LOCK_current_cond, MY_MUTEX_INIT_FAST); + mysql_mutex_init(0, &pq_lock_worker, MY_MUTEX_INIT_FAST); mysql_cond_init(key_COND_thr_lock, &COND_thr_lock); /* Variables with default values */ @@ -979,7 +1034,9 @@ void THD::cleanup(void) { /* Protects user_vars. */ mysql_mutex_lock(&LOCK_thd_data); - user_vars.clear(); + if (!is_worker()) { + user_vars.clear(); + } mysql_mutex_unlock(&LOCK_thd_data); /* @@ -1113,6 +1170,7 @@ THD::~THD() { mysql_mutex_destroy(&LOCK_thd_sysvar); mysql_mutex_destroy(&LOCK_thd_protocol); mysql_mutex_destroy(&LOCK_current_cond); + mysql_mutex_destroy(&pq_lock_worker); mysql_cond_destroy(&COND_thr_lock); #ifndef NDEBUG dbug_sentry = THD_SENTRY_GONE; @@ -1137,6 +1195,11 @@ THD::~THD() { unregister_slave(this, true, true); free_root(&main_mem_root, MYF(0)); + if (pq_mem_root) + { + free_root(pq_mem_root, MYF(0)); + delete pq_mem_root; + } if (m_token_array != nullptr) { my_free(m_token_array); @@ -1187,6 +1250,17 @@ void THD::awake(THD::killed_state state_to_set) { killed = state_to_set; } + /* Kill the workers if parallel query. */ + if (parallel_exec) { + mysql_mutex_lock(&pq_lock_worker); + for (auto pq_worker : pq_workers) { + mysql_mutex_lock(&pq_worker->LOCK_thd_data); + pq_worker->awake(state_to_set); + mysql_mutex_unlock(&pq_worker->LOCK_thd_data); + } + mysql_mutex_unlock(&pq_lock_worker); + } + if (state_to_set != THD::KILL_QUERY && state_to_set != THD::KILL_TIMEOUT) { if (this != current_thd || kill_immunizer) { assert(!kill_immunizer || !kill_immunizer->is_active()); @@ -1484,6 +1558,25 @@ void THD::cleanup_after_query() { if (rli_slave) rli_slave->cleanup_after_query(); // Set the default "cute" mode for the execution environment: check_for_truncated_fields = CHECK_FIELD_IGNORE; + + if (in_sp_trigger == 0) { + // cleanup for parallel query + if (pq_threads_running > 0) { + release_pq_running_threads(pq_threads_running); + pq_threads_running = 0; + } + if(pq_mem_root) + free_root(pq_mem_root, MYF(0)); + pq_dop = 0; + no_pq = false; + locking_clause = 0; + pq_error = false; + pq_workers.clear(); + pq_explain.clear(); + + if (killed == THD::KILL_PQ_QUERY) + killed.store(THD::NOT_KILLED); // restore killed for next query + } } /* @@ -1552,6 +1645,22 @@ void THD::update_charset() { variables.character_set_filesystem, ¬_used); } +/** + * Record a transient change to a pointer to an Item whitin another Item. + */ +void THD::change_item_tree(Item **place, Item *new_value) { + /* TODO: check for OOM condition here */ + if (!stmt_arena->is_regular()) { + DBUG_PRINT("info", ("change_item_tree place %p old_value %p new_value %p", + place, *place, new_value)); + nocheck_register_item_tree_change(place, new_value); + } + if (new_value != nullptr && new_value != *place) { + new_value->origin_item = *place; + } + *place = new_value; +} + int THD::send_explain_fields(Query_result *result) { mem_root_deque field_list(current_thd->mem_root); Item *item; @@ -1657,16 +1766,18 @@ void THD::rollback_item_tree_changes() { } void Query_arena::add_item(Item *item) { + item->pq_alloc_item = true; item->next_free = m_item_list; m_item_list = item; } -void Query_arena::free_items() { +void Query_arena::free_items(bool parallel_exec MY_ATTRIBUTE((unused))) { Item *next; DBUG_TRACE; /* This works because items are allocated with (*THR_MALLOC)->Alloc() */ for (; m_item_list; m_item_list = next) { next = m_item_list->next_free; + assert(!parallel_exec || (parallel_exec && m_item_list->pq_alloc_item)); m_item_list->delete_self(); } /* Postcondition: free_list is 0 */ @@ -1808,7 +1919,8 @@ void THD::send_kill_message() const { assuming it's come as far as the execution stage, so that the user can look at the execution plan and statistics so far. */ - if (!running_explain_analyze) { + if ((pq_leader != nullptr && !pq_leader->running_explain_analyze) || + (pq_leader == nullptr && !running_explain_analyze)) { my_error(err, MYF(ME_FATALERROR)); } } diff --git a/sql/sql_class.h b/sql/sql_class.h index e76edaaf7..3815220d1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -94,6 +95,7 @@ #include "sql/resourcegroups/resource_group_basic_types.h" #include "sql/rpl_context.h" // Rpl_thd_context #include "sql/rpl_gtid.h" +#include "sql/row_iterator.h" #include "sql/session_tracker.h" // Session_tracker #include "sql/sql_connect.h" #include "sql/sql_const.h" @@ -105,6 +107,7 @@ #include "sql/system_variables.h" // system_variables #include "sql/transaction_info.h" // Ha_trx_info #include "sql/xa.h" +#include "sql/pq_condition.h" #include "sql_string.h" #include "template_utils.h" #include "thr_lock.h" @@ -284,7 +287,7 @@ class Query_arena { void reset_item_list() { m_item_list = nullptr; } void set_item_list(Item *item) { m_item_list = item; } void add_item(Item *item); - void free_items(); + void free_items(bool parallel_exec = false); void set_state(enum_state state_arg) { state = state_arg; } enum_state get_state() const { return state; } bool is_stmt_prepare() const { return state == STMT_INITIALIZED; } @@ -935,6 +938,43 @@ class THD : public MDL_context_owner, String m_rewritten_query; public: + /* parallel reader context */ + void *pq_ctx; + /* using for PQ worker threads */ + THD *pq_leader; + /* using for explain */ + bool parallel_exec; + /* parallel query running threads in session*/ + uint pq_threads_running; + /* degree of parallel */ + uint pq_dop; + /* disable parallel execute */ + bool no_pq; + /* disable parallel query for store procedure and trigger */ + uint in_sp_trigger; + /* select .. fro share/update */ + bool locking_clause; + /* indicates whether parallel query is supported */ + enum PqConditionStatus m_suite_for_pq{PqConditionStatus::INIT}; + + /* indicates whether occurring error during execution */ + bool pq_error{false}; + + /* save ParallelScanIterator or PQblockScanIterator here to call end() */ + RowIterator *pq_iterator{NULL}; + + /* check first table. */ + uint pq_check_fields{0}; + uint pq_check_reclen{0}; + + /* save PQ worker THDs. */ + std::vector pq_workers; + /* protects THD::pq_workers. */ + mysql_mutex_t pq_lock_worker; + + /* for explain analyze. */ + std::string pq_explain; + /* Used to execute base64 coded binlog events in MySQL server */ Relay_log_info *rli_fake; /* Slave applier execution context */ @@ -1190,7 +1230,7 @@ class THD : public MDL_context_owner, return pointer_cast(m_protocol); } - private: + public: Protocol *m_protocol; // Current protocol /** SSL data attached to this connection. @@ -1636,6 +1676,7 @@ class THD : public MDL_context_owner, const char *m_trans_log_file; char *m_trans_fixed_log_file; my_off_t m_trans_end_pos; + public: /**@}*/ // NOTE: Ideally those two should be in Protocol, // but currently its design doesn't allow that. @@ -1796,6 +1837,7 @@ class THD : public MDL_context_owner, Attachable_trx_rw &operator=(const Attachable_trx_rw &); }; + public: Attachable_trx *m_attachable_trx; public: @@ -2018,6 +2060,7 @@ class THD : public MDL_context_owner, stable throughout the next query, see update_previous_found_rows. */ ulonglong current_found_rows; + ulonglong pq_current_found_rows; /* Indicate if the gtid_executed table is being operated implicitly @@ -2401,6 +2444,7 @@ class THD : public MDL_context_owner, KILL_CONNECTION = ER_SERVER_SHUTDOWN, KILL_QUERY = ER_QUERY_INTERRUPTED, KILL_TIMEOUT = ER_QUERY_TIMEOUT, + KILL_PQ_QUERY = ER_PARALLEL_EXEC_ERROR, KILLED_NO_VALUE /* means neither of the states */ }; std::atomic killed; @@ -2685,36 +2729,10 @@ class THD : public MDL_context_owner, void enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex, const PSI_stage_info *stage, PSI_stage_info *old_stage, const char *src_function, const char *src_file, - int src_line) override { - DBUG_TRACE; - mysql_mutex_assert_owner(mutex); - /* - Sic: We don't lock LOCK_current_cond here. - If we did, we could end up in deadlock with THD::awake() - which locks current_mutex while LOCK_current_cond is locked. - */ - current_mutex = mutex; - current_cond = cond; - enter_stage(stage, old_stage, src_function, src_file, src_line); - return; - } + int src_line) override; void exit_cond(const PSI_stage_info *stage, const char *src_function, - const char *src_file, int src_line) override { - DBUG_TRACE; - /* - current_mutex must be unlocked _before_ LOCK_current_cond is - locked (if that would not be the case, you'll get a deadlock if someone - does a THD::awake() on you). - */ - mysql_mutex_assert_not_owner(current_mutex.load()); - mysql_mutex_lock(&LOCK_current_cond); - current_mutex = nullptr; - current_cond = nullptr; - mysql_mutex_unlock(&LOCK_current_cond); - enter_stage(stage, nullptr, src_function, src_file, src_line); - return; - } + const char *src_file, int src_line) override; int is_killed() const final { return killed; } bool might_have_commit_order_waiters() const final { @@ -2809,7 +2827,12 @@ class THD : public MDL_context_owner, in the next statement. */ inline void update_previous_found_rows() { - previous_found_rows = current_found_rows; + if (pq_current_found_rows != 0) { + previous_found_rows = pq_current_found_rows; + pq_current_found_rows = 0; + } else { + previous_found_rows = current_found_rows; + } } /** @@ -2927,6 +2950,13 @@ class THD : public MDL_context_owner, */ inline bool is_error() const { return get_stmt_da()->is_error(); } + inline bool is_pq_error() const { + return !pq_leader ? pq_error + : (pq_error || (pq_leader->is_killed() || + pq_leader->pq_error || + pq_leader->is_error())); + } + /// Returns first Diagnostics Area for the current statement. Diagnostics_area *get_stmt_da() { return m_stmt_da; } @@ -3010,15 +3040,7 @@ class THD : public MDL_context_owner, /** Record a transient change to a pointer to an Item within another Item. */ - void change_item_tree(Item **place, Item *new_value) { - /* TODO: check for OOM condition here */ - if (!stmt_arena->is_regular()) { - DBUG_PRINT("info", ("change_item_tree place %p old_value %p new_value %p", - place, *place, new_value)); - nocheck_register_item_tree_change(place, new_value); - } - *place = new_value; - } + void change_item_tree(Item **place, Item *new_value); /** Remember that place was updated with new_value so it can be restored @@ -3760,6 +3782,7 @@ class THD : public MDL_context_owner, uint code, const char *message_text); friend void my_message_sql(uint, const char *, myf); + public: /** Raise a generic SQL condition. Also calls mysql_audit_notify() unless the condition is handled by a SQL condition handler. @@ -3775,7 +3798,6 @@ class THD : public MDL_context_owner, Sql_condition::enum_severity_level level, const char *msg, bool fatal_error = false); - public: void set_command(enum enum_server_command command); inline enum enum_server_command get_command() const { return m_command; } @@ -4032,6 +4054,10 @@ class THD : public MDL_context_owner, void mark_transaction_to_rollback(bool all); + public: + /** This memory root is used for Parallel Query */ + MEM_ROOT *pq_mem_root; + private: /** The current internal error handler for this thread, or NULL. */ Internal_error_handler *m_internal_handler; @@ -4346,6 +4372,10 @@ class THD : public MDL_context_owner, public: bool is_system_user(); void set_system_user(bool system_user_flag); + bool is_worker(); + bool pq_copy_from(THD *thd); + bool pq_merge_status(THD *thd); + bool pq_status_reset(); public: Transactional_ddl_context m_transactional_ddl{this}; @@ -4426,4 +4456,8 @@ inline void THD::set_system_user(bool system_user_flag) { m_is_system_user.store(system_user_flag, std::memory_order_seq_cst); } +inline bool THD::is_worker() { + return pq_leader != nullptr; +} + #endif /* SQL_CLASS_INCLUDED */ diff --git a/sql/sql_executor.cc b/sql/sql_executor.cc index 923d9a214..87a8ddf12 100644 --- a/sql/sql_executor.cc +++ b/sql/sql_executor.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -126,6 +127,7 @@ #include "tables_contained_in.h" #include "template_utils.h" #include "thr_lock.h" +#include "msg_queue.h" using std::make_pair; using std::max; @@ -193,7 +195,7 @@ string RefToString(const TABLE_REF &ref, const KEY *key, bool include_nulls) { bool JOIN::create_intermediate_table( QEP_TAB *const tab, const mem_root_deque &tmp_table_fields, - ORDER_with_src &tmp_table_group, bool save_sum_fields) { + ORDER_with_src &tmp_table_group, bool save_sum_fields, bool force_disk_table) { DBUG_TRACE; THD_STAGE_INFO(thd, stage_creating_tmp_table); const bool windowing = m_windows.elements > 0; @@ -208,7 +210,11 @@ bool JOIN::create_intermediate_table( ? m_select_limit : HA_POS_ERROR; - tab->tmp_table_param = new (thd->mem_root) Temp_table_param(tmp_table_param); + tab->tmp_table_param = new (thd->mem_root) Temp_table_param(*tmp_table_param); + if (tab->tmp_table_param == nullptr) { + return true; + } + tab->tmp_table_param->skip_create_table = true; bool distinct_arg = @@ -222,9 +228,9 @@ bool JOIN::create_intermediate_table( TABLE *table = create_tmp_table(thd, tab->tmp_table_param, tmp_table_fields, tmp_table_group.order, distinct_arg, save_sum_fields, - query_block->active_options(), tmp_rows_limit, ""); + query_block->active_options(), tmp_rows_limit, "", force_disk_table); if (!table) return true; - tmp_table_param.using_outer_summary_function = + tmp_table_param->using_outer_summary_function = tab->tmp_table_param->using_outer_summary_function; assert(tab->idx() > 0); @@ -259,11 +265,15 @@ bool JOIN::create_intermediate_table( if (!group_list.empty() && simple_group) { DBUG_PRINT("info", ("Sorting for group")); - if (m_ordered_index_usage != ORDERED_INDEX_GROUP_BY && - add_sorting_to_table(const_tables, &group_list, + if (m_ordered_index_usage != ORDERED_INDEX_GROUP_BY) { + if (add_sorting_to_table(const_tables, &group_list, /*force_stable_sort=*/false, /*sort_before_group=*/true)) - goto err; + goto err; + + pq_last_sort_idx = const_tables; + pq_rebuilt_group = true; + } if (alloc_group_fields(this, group_list.order)) goto err; if (make_sum_func_list(*fields, true)) goto err; @@ -289,11 +299,14 @@ bool JOIN::create_intermediate_table( simple_order && rollup_state == RollupState::NONE && !m_windows_sort) { DBUG_PRINT("info", ("Sorting for order")); - if (m_ordered_index_usage != ORDERED_INDEX_ORDER_BY && - add_sorting_to_table(const_tables, &order, + if (m_ordered_index_usage != ORDERED_INDEX_ORDER_BY) { + if (add_sorting_to_table(const_tables, &order, /*force_stable_sort=*/false, /*sort_before_group=*/false)) goto err; + + pq_last_sort_idx = const_tables; + } order.clean(); } } @@ -641,7 +654,7 @@ QEP_TAB::enum_op_type JOIN::get_end_select_func() { more aggregate functions). Use end_send if the query should not be grouped. */ - if (streaming_aggregation && !tmp_table_param.precomputed_group_by) { + if (streaming_aggregation && !tmp_table_param->precomputed_group_by) { DBUG_PRINT("info", ("Using end_send_group")); return QEP_TAB::OT_AGGREGATE; } @@ -1473,12 +1486,12 @@ AccessPath *GetAccessPathForDerivedTable( if (query_expression->is_simple()) { subjoin = query_expression->first_query_block()->join; select_number = query_expression->first_query_block()->select_number; - tmp_table_param = &subjoin->tmp_table_param; + tmp_table_param = subjoin->tmp_table_param; } else if (query_expression->fake_query_block != nullptr) { // NOTE: subjoin here is never used, as ConvertItemsToCopy only uses it // for ROLLUP, and fake_query_block can't have ROLLUP. subjoin = query_expression->fake_query_block->join; - tmp_table_param = &subjoin->tmp_table_param; + tmp_table_param = subjoin->tmp_table_param; select_number = query_expression->fake_query_block->select_number; } else { tmp_table_param = new (thd->mem_root) Temp_table_param; @@ -1528,7 +1541,7 @@ AccessPath *GetAccessPathForDerivedTable( // also conservative; if the CTE is defined within this join and used // only once, we could still stream without losing performance. path = NewStreamingAccessPath(thd, query_expression->root_access_path(), - subjoin, &subjoin->tmp_table_param, table, + subjoin, subjoin->tmp_table_param, table, /*ref_slice=*/-1); CopyCosts(*query_expression->root_access_path(), path); } else { @@ -2828,37 +2841,45 @@ AccessPath *JOIN::create_root_access_path_for_join() { path->num_output_rows = query_block->row_value_list->size(); path->cost = 0.0; } else if (const_tables == primary_tables) { - // Only const tables, so add a fake single row to join in all - // the const tables (only inner-joined tables are promoted to - // const tables in the optimizer). - path = NewFakeSingleRowAccessPath(thd, /*count_examined_rows=*/true); - qep_tab_map conditions_depend_on_outer_tables = 0; - if (where_cond != nullptr) { - path = PossiblyAttachFilter(path, vector{where_cond}, thd, - &conditions_depend_on_outer_tables); - } + if (need_tmp_pq_leader) { + assert(thd->parallel_exec && !thd->is_worker()); + QEP_TAB *tab = &qep_tab[const_tables]; + path = NewParallelScanAccessPath(thd, tab, tab->table(), tab->gather, + pq_stable_sort, + tab->old_table()->file->ref_length); + } else { + // Only const tables, so add a fake single row to join in all + // the const tables (only inner-joined tables are promoted to + // const tables in the optimizer). + path = NewFakeSingleRowAccessPath(thd, /*count_examined_rows=*/true); + qep_tab_map conditions_depend_on_outer_tables = 0; + if (where_cond != nullptr) { + path = PossiblyAttachFilter(path, vector{where_cond}, thd, + &conditions_depend_on_outer_tables); + } - // Surprisingly enough, we can specify that the const tables are - // to be dumped immediately to a temporary table. If we don't do this, - // we risk that there are fields that are not copied correctly - // (tmp_table_param contains copy_funcs we'd otherwise miss). - if (const_tables > 0) { - QEP_TAB *qep_tab = &this->qep_tab[const_tables]; - if (qep_tab->op_type == QEP_TAB::OT_MATERIALIZE) { - qep_tab->table()->alias = ""; - AccessPath *table_path = - create_table_access_path(thd, nullptr, qep_tab, - /*count_examined_rows=*/false); - path = NewMaterializeAccessPath( - thd, - SingleMaterializeQueryBlock( - thd, path, query_block->select_number, this, - /*copy_fields_and_items=*/true, qep_tab->tmp_table_param), - qep_tab->invalidators, qep_tab->table(), table_path, - /*cte=*/nullptr, query_expression(), qep_tab->ref_item_slice, - /*rematerialize=*/true, qep_tab->tmp_table_param->end_write_records, - /*reject_multiple_rows=*/false); - EstimateMaterializeCost(path); + // Surprisingly enough, we can specify that the const tables are + // to be dumped immediately to a temporary table. If we don't do this, + // we risk that there are fields that are not copied correctly + // (tmp_table_param contains copy_funcs we'd otherwise miss). + if (const_tables > 0) { + QEP_TAB *qep_tab = &this->qep_tab[const_tables]; + if (qep_tab->op_type == QEP_TAB::OT_MATERIALIZE) { + qep_tab->table()->alias = ""; + AccessPath *table_path = + create_table_access_path(thd, nullptr, qep_tab, + /*count_examined_rows=*/false); + path = NewMaterializeAccessPath( + thd, + SingleMaterializeQueryBlock( + thd, path, query_block->select_number, this, + /*copy_fields_and_items=*/true, qep_tab->tmp_table_param), + qep_tab->invalidators, qep_tab->table(), table_path, + /*cte=*/nullptr, query_expression(), qep_tab->ref_item_slice, + /*rematerialize=*/true, qep_tab->tmp_table_param->end_write_records, + /*reject_multiple_rows=*/false); + EstimateMaterializeCost(path); + } } } } else { @@ -3024,7 +3045,7 @@ AccessPath *JOIN::create_root_access_path_for_join() { qep_tab->invalidators, qep_tab->table(), table_path, /*cte=*/nullptr, query_expression(), /*ref_slice=*/-1, - /*rematerialize=*/true, tmp_table_param.end_write_records, + /*rematerialize=*/true, tmp_table_param->end_write_records, /*reject_multiple_rows=*/false); EstimateMaterializeCost(path); } @@ -3114,17 +3135,17 @@ AccessPath *JOIN::create_root_access_path_for_join() { do_aggregate = (qep_tab[primary_tables + tmp_tables].op_type == QEP_TAB::OT_AGGREGATE) || ((grouped || group_optimized_away) && - tmp_table_param.precomputed_group_by); + tmp_table_param->precomputed_group_by); } if (do_aggregate) { // Aggregate as we go, with output into a special slice of the same table. - assert(streaming_aggregation || tmp_table_param.precomputed_group_by); + assert(streaming_aggregation || tmp_table_param->precomputed_group_by); #ifndef NDEBUG for (unsigned table_idx = const_tables; table_idx < tables; ++table_idx) { assert(qep_tab->op_type != QEP_TAB::OT_AGGREGATE_THEN_MATERIALIZE); } #endif - if (!tmp_table_param.precomputed_group_by) { + if (!tmp_table_param->precomputed_group_by) { path = NewAggregateAccessPath(thd, path, rollup_state != RollupState::NONE); } @@ -3899,7 +3920,12 @@ bool DynamicRangeIterator::Init() { Key_map needed_reg_dummy; QUICK_SELECT_I *old_qck = m_qep_tab->quick(); QUICK_SELECT_I *qck; - DEBUG_SYNC(thd(), "quick_not_created"); + if (thd()->pq_leader != nullptr) { + DEBUG_SYNC(thd()->pq_leader, "quick_not_created"); + } else { + DEBUG_SYNC(thd(), "quick_not_created"); + } + const int rc = test_quick_select( thd(), m_qep_tab->keys(), 0, // empty table map @@ -3921,7 +3947,11 @@ bool DynamicRangeIterator::Init() { that, we need to take mutex and change type and quick_optim. */ - DEBUG_SYNC(thd(), "quick_created_before_mutex"); + if (thd()->pq_leader != nullptr) { + DEBUG_SYNC(thd()->pq_leader, "quick_created_before_mutex"); + } else { + DEBUG_SYNC(thd(), "quick_created_before_mutex"); + } thd()->lock_query_plan(); m_qep_tab->set_type(qck ? calc_join_type(qck->get_type()) : JT_ALL); @@ -3929,7 +3959,11 @@ bool DynamicRangeIterator::Init() { thd()->unlock_query_plan(); delete old_qck; - DEBUG_SYNC(thd(), "quick_droped_after_mutex"); + if (thd()->pq_leader != nullptr) { + DEBUG_SYNC(thd()->pq_leader, "quick_droped_after_mutex"); + } else { + DEBUG_SYNC(thd(), "quick_droped_after_mutex"); + } // Clear out and destroy any old iterators before we start constructing // new ones, since they may share the same memory in the union. @@ -4150,14 +4184,16 @@ bool AlternativeIterator::Init() { AccessPath *QEP_TAB::access_path() { assert(table()); // Only some access methods support reversed access: - assert(!m_reversed_access || type() == JT_REF || type() == JT_INDEX_SCAN); + assert(current_thd->parallel_exec || !m_reversed_access || type() == JT_REF || type() == JT_INDEX_SCAN); TABLE_REF *used_ref = nullptr; AccessPath *path = nullptr; const TABLE *pushed_root = table()->file->member_of_pushed_join(); const bool is_pushed_child = (pushed_root && pushed_root != table()); // A 'pushed_child' has to be a REF type - assert(!is_pushed_child || type() == JT_REF || type() == JT_EQ_REF); + assert(current_thd->parallel_exec || !is_pushed_child || type() == JT_REF || type() == JT_EQ_REF); + + bool pq_replace_accesspath = false; switch (type()) { case JT_REF: @@ -4170,6 +4206,8 @@ AccessPath *QEP_TAB::access_path() { path = NewRefAccessPath(join()->thd, table(), &ref(), use_order(), m_reversed_access, /*count_examined_rows=*/true); + + pq_replace_accesspath = true; } used_ref = &ref(); break; @@ -4208,6 +4246,8 @@ AccessPath *QEP_TAB::access_path() { path = NewIndexScanAccessPath(join()->thd, table(), index(), use_order(), m_reversed_access, /*count_examined_rows=*/true); + + pq_replace_accesspath = true; break; case JT_ALL: case JT_RANGE: @@ -4217,7 +4257,7 @@ AccessPath *QEP_TAB::access_path() { /*count_examined_rows=*/true); } else { path = create_table_access_path(join()->thd, nullptr, this, - /*count_examined_rows=*/true); + /*count_examined_rows=*/true, &pq_replace_accesspath); } break; default: @@ -4225,6 +4265,12 @@ AccessPath *QEP_TAB::access_path() { break; } + /** note that: for gather operator, we have no need to generate iterator */ + if (current_thd->is_worker() && pq_replace_accesspath && do_parallel_scan) { + path = NewPQBlockScanAccessPath(current_thd, table(), gather, + join()->pq_stable_sort); + } + /* If we have an item like IN ( SELECT f2 FROM t2 ), and we were not able to rewrite it into a semijoin, the optimizer may rewrite it into @@ -6270,13 +6316,23 @@ bool change_to_use_tmp_fields(mem_root_deque *fields, THD *thd, ifield->table_name = iref->table_name; ifield->set_orig_db_name(iref->orig_db_name()); ifield->db_name = iref->db_name; + if (thd->parallel_exec) { + ifield->ref = true; + Send_field tmp_field; + item->make_field(&tmp_field); + ifield->field->flags = tmp_field.flags; + ifield->ref_col_name = iref->item_name.ptr(); + ifield->set_orig_table_name(iref->orig_table_name()); + } } if (orig_field != nullptr && item != new_item) { down_cast(new_item)->set_orig_table_name( orig_field->orig_table_name()); } #ifndef NDEBUG - if (!new_item->item_name.is_set()) { + /* Do not set the item_name here when parallel query to keep the MTR + execution results of the release and debug versions same. */ + if (!new_item->item_name.is_set() && thd->m_suite_for_pq == PqConditionStatus::NOT_SUPPORTED) { char buff[256]; String str(buff, sizeof(buff), &my_charset_bin); str.length(0); @@ -6289,6 +6345,10 @@ bool change_to_use_tmp_fields(mem_root_deque *fields, THD *thd, replace_embedded_rollup_references_with_tmp_fields(thd, item, fields); } + if (item->type() == Item::SUM_FUNC_ITEM && item->const_item() && thd->parallel_exec) { + new_item = item; + } + new_item->hidden = item->hidden; res_fields->push_back(new_item); const size_t idx = @@ -6615,7 +6675,7 @@ int UnqualifiedCountIterator::Read() { // If we are outputting to a temporary table, we need to copy the results // into it here. It is also used for nonaggregated items, even when there are // no temporary tables involved. - if (copy_fields_and_funcs(&m_join->tmp_table_param, m_join->thd)) { + if (copy_fields_and_funcs(m_join->tmp_table_param, m_join->thd)) { return 1; } diff --git a/sql/sql_executor.h b/sql/sql_executor.h index 465e23883..fa8dc51b2 100644 --- a/sql/sql_executor.h +++ b/sql/sql_executor.h @@ -2,6 +2,7 @@ #define SQL_EXECUTOR_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -44,6 +45,7 @@ #include "sql/sql_opt_exec_shared.h" // QEP_shared_owner #include "sql/table.h" #include "sql/temp_table_param.h" // Temp_table_param +#include "sql/query_result.h" class CacheInvalidatorIterator; class Cached_item; @@ -256,11 +258,16 @@ bool make_group_fields(JOIN *main_join, JOIN *curr_join); bool check_unique_constraint(TABLE *table); ulonglong unique_hash(const Field *field, ulonglong *hash); +class Gather_operator; class QEP_TAB : public QEP_shared_owner { public: QEP_TAB() : QEP_shared_owner(), + gather(nullptr), + do_parallel_scan(false), table_ref(nullptr), + pos(0), + pq_cond(nullptr), flush_weedout_table(nullptr), check_weed_out_table(nullptr), firstmatch_return(NO_PLAN_IDX), @@ -275,6 +282,7 @@ class QEP_TAB : public QEP_shared_owner { ref_item_slice(REF_SLICE_SAVED_BASE), m_condition_optim(nullptr), m_quick_optim(nullptr), + m_old_quick_optim(nullptr), m_keyread_optim(false), m_reversed_access(false), lateral_derived_tables_depend_on_me(0) {} @@ -282,13 +290,15 @@ class QEP_TAB : public QEP_shared_owner { /// Initializes the object from a JOIN_TAB void init(JOIN_TAB *jt); // Cleans up. - void cleanup(); + void cleanup(bool is_free = true); // Getters and setters Item *condition_optim() const { return m_condition_optim; } QUICK_SELECT_I *quick_optim() const { return m_quick_optim; } void set_quick_optim() { m_quick_optim = quick(); } + QUICK_SELECT_I *old_quick_optim() const { return m_old_quick_optim; } + void set_old_quick_optim() { m_old_quick_optim = quick(); } void set_condition_optim() { m_condition_optim = condition(); } bool keyread_optim() const { return m_keyread_optim; } void set_keyread_optim() { @@ -302,6 +312,10 @@ class QEP_TAB : public QEP_shared_owner { if (t) t->reginfo.qep_tab = this; } + void set_old_table(TABLE *t) { + m_qs->set_old_table(t); + } + /// @returns semijoin strategy for this table. uint get_sj_strategy() const; @@ -323,6 +337,8 @@ class QEP_TAB : public QEP_shared_owner { */ void init_join_cache(JOIN_TAB *join_tab); + bool pq_copy(THD *thd, QEP_TAB *qep_tab); + /** @returns query block id for an inner table of materialized semi-join, and 0 for all other tables. @@ -363,9 +379,20 @@ class QEP_TAB : public QEP_shared_owner { bool pfs_batch_update(const JOIN *join) const; public: + Gather_operator *gather; + bool do_parallel_scan; + /// Pointer to table reference TABLE_LIST *table_ref; + uint pos; // position in qep_tab array + + bool has_pq_cond{false}; + Item *pq_cond; + + LEX_CSTRING *table_name{nullptr}; + LEX_CSTRING *db{nullptr}; + /* Variables for semi-join duplicate elimination */ SJ_TMP_TABLE *flush_weedout_table; SJ_TMP_TABLE *check_weed_out_table; @@ -478,6 +505,7 @@ class QEP_TAB : public QEP_shared_owner { LOCK_query_plan mutex. */ QUICK_SELECT_I *m_quick_optim; + QUICK_SELECT_I *m_old_quick_optim; /** True if only index is going to be read for this table. This is the @@ -548,7 +576,8 @@ struct PendingCondition { unique_ptr_destroy_only PossiblyAttachFilterIterator( unique_ptr_destroy_only iterator, - const std::vector &conditions, THD *thd); + const std::vector &conditions, THD *thd, + table_map *conditions_depend_on_outer_tables); void SplitConditions(Item *condition, QEP_TAB *current_table, std::vector *predicates_below_join, diff --git a/sql/sql_hints.yy b/sql/sql_hints.yy index d3780b6ad..d4f6e9773 100644 --- a/sql/sql_hints.yy +++ b/sql/sql_hints.yy @@ -1,5 +1,6 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -130,6 +131,8 @@ static bool parse_int(longlong *to, const char *from, size_t from_length) %token DERIVED_CONDITION_PUSHDOWN_HINT 1047 %token NO_DERIVED_CONDITION_PUSHDOWN_HINT 1048 %token HINT_ARG_FLOATING_POINT_NUMBER 1049 +%token PQ_HINT 1050 +%token NO_PQ_HINT 1051 /* YYUNDEF in internal to Bison. Please don't change its number, or change @@ -419,6 +422,34 @@ qb_level_hint: if ($$ == NULL) YYABORT; // OOM } + | + PQ_HINT + { + $$= NEW_PTN PT_qb_level_hint(NULL_CSTR, true, PQ_HINT_ENUM, 0); + if ($$ == NULL) + YYABORT; // OOM + } + | + PQ_HINT '(' HINT_ARG_NUMBER ')' + { + longlong n; + if (parse_int(&n, $3.str, $3.length) || n > UINT_MAX32 || n <= 0) + { + scanner->syntax_warning(ER_THD(thd, + ER_WARN_BAD_PARALLEL_NUM)); + $$= NULL; + } else { + $$= NEW_PTN PT_qb_level_hint(NULL_CSTR, true, PQ_HINT_ENUM, n); + if ($$ == NULL) + YYABORT; // OOM + } + } + | + NO_PQ_HINT { + $$= NEW_PTN PT_qb_level_hint(NULL_CSTR, true, NO_PQ_HINT_ENUM, 0); + if ($$ == NULL) + YYABORT; // OOM + } ; semijoin_strategies: diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 146a46047..c279da3c8 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -4216,6 +4217,18 @@ bool LEX::locate_var_assignment(const Name_string &name) { return false; } +void Query_block::fix_prepare_information_for_order( + THD *thd, SQL_I_List *list, Group_list_ptrs **list_ptrs) { + Group_list_ptrs *p = *list_ptrs; + if (p == nullptr) { + void *mem = thd->stmt_arena->alloc(sizeof(Group_list_ptrs)); + *list_ptrs = p = new (mem) Group_list_ptrs(thd->stmt_arena->mem_root); + } + p->reserve(list->elements); + for (ORDER *order = list->first; order; order = order->next) + p->push_back(order); +} + /** Save properties for ORDER clauses so that they can be reconstructed for a new optimization of the query block. diff --git a/sql/sql_lex.h b/sql/sql_lex.h index ce5ecd548..f8cd5f3fc 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -337,6 +338,7 @@ class Table_ident { using List_item = mem_root_deque; using Group_list_ptrs = Mem_root_array; +using PQ_Group_list_ptrs = Mem_root_array; /** Structure to hold parameters for CHANGE MASTER, START SLAVE, and STOP SLAVE. @@ -674,7 +676,9 @@ class Query_expression { unfinished materialization (see optimize()). */ unique_ptr_destroy_only m_root_iterator; + public: AccessPath *m_root_access_path = nullptr; + private: /** If there is an unfinished materialization (see optimize()), @@ -695,13 +699,13 @@ class Query_expression { Mem_root_array setup_materialization( THD *thd, TABLE *dst_table, bool union_distinct_only); + public: /** Convert the executor structures to a set of access paths, storing the result in m_root_access_path. */ void create_access_paths(THD *thd); - public: /** result of this query can't be cached, bit field, can be : UNCACHEABLE_DEPENDENT @@ -880,6 +884,7 @@ class Query_expression { /// Set new query result object for this query expression void set_query_result(Query_result *res) { m_query_result = res; } + void set_slave(Query_block *select_lex) { slave = select_lex; } /** Whether there is a chance that optimize() is capable of materializing @@ -1087,6 +1092,7 @@ enum class enum_explain_type { EXPLAIN_UNION, EXPLAIN_UNION_RESULT, EXPLAIN_MATERIALIZED, + EXPLAIN_GATHER, // Total: EXPLAIN_total ///< fake type, total number of all valid types @@ -1100,6 +1106,7 @@ enum class enum_explain_type { */ class Query_block { public: + Query_block *orig; /** @note the group_by and order_by lists below will probably be added to the constructor when the parser is converted into a true bottom-up design. @@ -1181,6 +1188,8 @@ class Query_block { TABLE_LIST *find_table_by_name(const Table_ident *ident); + void set_master_unit(Query_expression *unit) { master = unit; } + /** @return true If STRAIGHT_JOIN applies to all tables. @return false Else. @@ -1876,6 +1885,13 @@ class Query_block { SQL_I_List group_list{}; Group_list_ptrs *group_list_ptrs{nullptr}; + /* + * the backup of group_list/order_list before optimization, which is used + * to generate worker's group_list/order_list. + */ + PQ_Group_list_ptrs *saved_group_list_ptrs{nullptr}; + PQ_Group_list_ptrs *saved_order_list_ptrs{nullptr}; + // Used so that AggregateIterator knows which items to signal when the rollup // level changes. Obviously only used in the presence of rollup. Prealloced_array rollup_group_items{ @@ -2178,8 +2194,10 @@ class Query_block { bool resolve_rollup(THD *thd); bool setup_wild(THD *thd); + public: bool setup_order_final(THD *thd); bool setup_group(THD *thd); + private: void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block); void remove_redundant_subquery_clauses(THD *thd, @@ -2233,10 +2251,12 @@ class Query_block { // Delete unused columns from merged derived tables void delete_unused_merged_columns(mem_root_deque *tables); + public: /// Helper for fix_prepare_information() void fix_prepare_information_for_order(THD *thd, SQL_I_List *list, Group_list_ptrs **list_ptrs); + private: bool prepare_values(THD *thd); bool check_only_full_group_by(THD *thd); bool is_row_count_valid_for_semi_join(); @@ -2251,10 +2271,16 @@ class Query_block { Template parameter is "true": no need to run DTORs on pointers. */ Mem_root_array *sj_candidates{nullptr}; - + public: /// How many expressions are part of the order by but not select list. int hidden_order_field_count{0}; + /** + Windows function maybe be optimized, so we save this value to determine + whether support parallel query. + */ + uint saved_windows_elements{0}; + private: /** Intrusive double-linked list of all query blocks within the same query expression. @@ -2279,6 +2305,8 @@ class Query_block { should not be modified after resolving is done. */ ulonglong m_base_options{0}; + + public: /** Active options. Derived from base options, modifiers added during resolving and values from session variable option_bits. Since the latter @@ -2286,6 +2314,7 @@ class Query_block { */ ulonglong m_active_options{0}; + private: TABLE_LIST *resolve_nest{ nullptr}; ///< Used when resolving outer join condition @@ -2301,10 +2330,10 @@ class Query_block { /// Condition to be evaluated on grouped rows after grouping. Item *m_having_cond; - + public: /// Number of GROUP BY expressions added to all_fields int hidden_group_field_count; - + private: /** True if query block has semi-join nests merged into it. Notice that this is updated earlier than sj_nests, so check this if info is needed @@ -3900,6 +3929,7 @@ struct LEX : public Query_tables_list { bool has_udf() const { return m_has_udf; } st_parsing_options parsing_options; Alter_info *alter_info; + bool in_execute_ps{false}; /* Prepared statements SQL syntax:*/ LEX_CSTRING prepared_stmt_name; /* Statement name (in all queries) */ /* diff --git a/sql/sql_lex_hints.cc b/sql/sql_lex_hints.cc index a8d5caed3..b5609a57b 100644 --- a/sql/sql_lex_hints.cc +++ b/sql/sql_lex_hints.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2014, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -226,6 +227,8 @@ void Hint_scanner::add_hint_token_digest() { case NO_ORDER_INDEX_HINT: case DERIVED_CONDITION_PUSHDOWN_HINT: case NO_DERIVED_CONDITION_PUSHDOWN_HINT: + case PQ_HINT: + case NO_PQ_HINT: break; default: assert(false); diff --git a/sql/sql_opt_exec_shared.h b/sql/sql_opt_exec_shared.h index 2018c7c77..59e189f32 100644 --- a/sql/sql_opt_exec_shared.h +++ b/sql/sql_opt_exec_shared.h @@ -1,4 +1,5 @@ /* Copyright (c) 2014, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -150,6 +151,8 @@ struct TABLE_REF { return false; } + bool pq_copy(JOIN *join, TABLE_REF *ref, QEP_TAB *qep_tab); + /** Check if there are triggered/guarded conditions that might be 'switched off' by the subquery code when executing 'Full scan on @@ -229,9 +232,11 @@ enum join_type { class QEP_shared { public: QEP_shared() - : m_join(nullptr), + : m_old_ref(nullptr), + m_join(nullptr), m_idx(NO_PLAN_IDX), m_table(nullptr), + m_old_table(nullptr), m_position(nullptr), m_sj_mat_exec(nullptr), m_first_sj_inner(NO_PLAN_IDX), @@ -239,9 +244,11 @@ class QEP_shared { m_first_inner(NO_PLAN_IDX), m_last_inner(NO_PLAN_IDX), m_first_upper(NO_PLAN_IDX), - m_ref(), + m_orign_ref(), + m_ref(&m_orign_ref), m_index(0), m_type(JT_UNKNOWN), + m_old_type(JT_UNKNOWN), m_condition(nullptr), m_keys(), m_records(0), @@ -268,7 +275,9 @@ class QEP_shared { m_idx = i; } TABLE *table() const { return m_table; } + TABLE *old_table() const { return m_old_table; } void set_table(TABLE *t) { m_table = t; } + void set_old_table(TABLE *t) { m_old_table = t; } POSITION *position() const { return m_position; } void set_position(POSITION *p) { m_position = p; } Semijoin_mat_exec *sj_mat_exec() const { return m_sj_mat_exec; } @@ -283,11 +292,17 @@ class QEP_shared { void set_first_upper(plan_idx i) { m_first_upper = i; } plan_idx last_inner() { return m_last_inner; } plan_idx first_upper() { return m_first_upper; } - TABLE_REF &ref() { return m_ref; } + TABLE_REF &ref() { return *m_ref; } + void set_ref(TABLE_REF *ref) { m_ref = ref; } + TABLE_REF &old_ref() { return *m_old_ref; } + void set_old_ref(TABLE_REF *ref) { m_old_ref = ref; } uint index() const { return m_index; } void set_index(uint i) { m_index = i; } enum join_type type() const { return m_type; } void set_type(enum join_type t) { m_type = t; } + //for dealing with first rewritten tab + enum join_type old_type() const { return m_old_type; } + void set_old_type(enum join_type t) { m_old_type = t;} Item *condition() const { return m_condition; } void set_condition(Item *c) { m_condition = c; } bool condition_is_pushed_to_sort() const { @@ -349,6 +364,10 @@ class QEP_shared { bool skip_records_in_range() const { return m_skip_records_in_range; } + public: + // the origin index type of the first rewritten qep_tab in leader + TABLE_REF *m_old_ref; + private: JOIN *m_join; @@ -362,6 +381,8 @@ class QEP_shared { /// Corresponding table. Might be an internal temporary one. TABLE *m_table; + // parallel query old_table + TABLE *m_old_table; /// Points into best_positions array. Includes cost info. POSITION *m_position; @@ -397,7 +418,8 @@ class QEP_shared { Used when we read constant tables, in misc optimization (like remove_const()), and in execution. */ - TABLE_REF m_ref; + TABLE_REF m_orign_ref; + TABLE_REF *m_ref; /// ID of index used for index scan or semijoin LooseScan uint m_index; @@ -405,6 +427,8 @@ class QEP_shared { /// Type of chosen access method (scan, etc). enum join_type m_type; + enum join_type m_old_type; + /** Table condition, ie condition to be evaluated for a row from this table. Notice that the condition may refer to rows from previous tables in the @@ -479,6 +503,8 @@ class QEP_shared_owner { m_qs = q; } + QEP_shared *get_qs() { return m_qs; } + // Getters/setters forwarding to QEP_shared: JOIN *join() const { return m_qs ? m_qs->join() : nullptr; } @@ -492,6 +518,7 @@ class QEP_shared_owner { qep_tab_map idx_map() const { return qep_tab_map{1} << m_qs->idx(); } TABLE *table() const { return m_qs->table(); } + TABLE *old_table() const { return m_qs->old_table(); } POSITION *position() const { return m_qs->position(); } void set_position(POSITION *p) { return m_qs->set_position(p); } Semijoin_mat_exec *sj_mat_exec() const { return m_qs->sj_mat_exec(); } @@ -509,10 +536,16 @@ class QEP_shared_owner { void set_last_sj_inner(plan_idx i) { return m_qs->set_last_sj_inner(i); } void set_first_upper(plan_idx i) { return m_qs->set_first_upper(i); } TABLE_REF &ref() const { return m_qs->ref(); } + void set_ref(TABLE_REF *ref) { m_qs->set_ref(ref); } + TABLE_REF &old_ref() const { return m_qs->old_ref(); } + void set_old_ref(TABLE_REF *ref) { m_qs->set_old_ref(ref);} uint index() const { return m_qs->index(); } void set_index(uint i) { return m_qs->set_index(i); } enum join_type type() const { return m_qs->type(); } void set_type(enum join_type t) { return m_qs->set_type(t); } + //for dealing with first rewritten tab + enum join_type old_type() const { return m_qs->old_type(); } + void set_old_type(enum join_type t) { m_qs->set_old_type(t); } Item *condition() const { return m_qs->condition(); } void set_condition(Item *to) { return m_qs->set_condition(to); } bool condition_is_pushed_to_sort() const { @@ -560,7 +593,7 @@ class QEP_shared_owner { void qs_cleanup(); - protected: + public: QEP_shared *m_qs; // qs stands for Qep_Shared }; @@ -619,6 +652,10 @@ enum { table */ REF_SLICE_TMP2, + /* + * Use to store PQ worker query result + */ + REF_SLICE_PQ_TMP, /** The slice with pointers to columns of table(s), ie., the actual Items. Only used for queries involving temporary tables or the likes; for simple diff --git a/sql/sql_optimizer.cc b/sql/sql_optimizer.cc index 29a3049e0..cb0782a0b 100644 --- a/sql/sql_optimizer.cc +++ b/sql/sql_optimizer.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -107,6 +108,8 @@ #include "sql/window.h" #include "sql_string.h" #include "template_utils.h" +#include "sql/pq_clone.h" +#include "sql/item_strfunc.h" using std::max; using std::min; @@ -164,15 +167,22 @@ JOIN::JOIN(THD *thd_arg, Query_block *select) // Needed in case optimizer short-cuts, set properly in // make_tmp_tables_info() fields(&select->fields), - tmp_table_param(thd_arg->mem_root), + origin_tmp_table_param(thd_arg->mem_root), + tmp_table_param(&origin_tmp_table_param), + saved_tmp_table_param(nullptr), lock(thd->lock), // @todo Can this be substituted with select->is_implicitly_grouped()? implicit_grouping(select->is_implicitly_grouped()), select_distinct(select->is_distinct()), - keyuse_array(thd->mem_root), + origin_keyuse_array(thd_arg->mem_root), + keyuse_array(&origin_keyuse_array), query_block_fields(&select->fields), order(select->order_list.first, ESC_ORDER_BY), group_list(select->group_list.first, ESC_GROUP_BY), + pq_tab_idx(-1), + pq_rebuilt_group(false), + pq_stable_sort(false), + pq_last_sort_idx(-1), m_windows(select->m_windows), /* Those four members are meaningless before JOIN::optimize(), so force a @@ -183,7 +193,9 @@ JOIN::JOIN(THD *thd_arg, Query_block *select) having_for_explain(reinterpret_cast(1)), tables_list(reinterpret_cast(1)), current_ref_item_slice(REF_SLICE_SAVED_BASE), - with_json_agg(select->json_agg_func_used()) { + last_slice_before_pq(REF_SLICE_SAVED_BASE), + with_json_agg(select->json_agg_func_used()), + select_count(false) { rollup_state = RollupState::NONE; if (select->order_list.first) explain_flags.set(ESC_ORDER_BY, ESP_EXISTS); if (select->group_list.first) explain_flags.set(ESC_GROUP_BY, ESP_EXISTS); @@ -192,6 +204,8 @@ JOIN::JOIN(THD *thd_arg, Query_block *select) // Calculate the number of groups for (ORDER *group = group_list.order; group; group = group->next) send_group_parts++; + + tmp_table_param->end_write_records = HA_POS_ERROR; } bool JOIN::alloc_ref_item_slice(THD *thd_arg, int sliceno) { @@ -204,16 +218,148 @@ bool JOIN::alloc_ref_item_slice(THD *thd_arg, int sliceno) { return false; } +bool JOIN::alloc_indirection_slices1() { + const uint card = REF_SLICE_WIN_1 + m_windows.elements * 2; + + assert(ref_items1 == nullptr); + + ref_items1 = + (Ref_item_array *)(*THR_MALLOC)->ArrayAlloc(card); + if (ref_items1 == nullptr) return true; + + tmp_fields1 = + (*THR_MALLOC)->ArrayAlloc>(card, *THR_MALLOC); + if (tmp_fields1 == nullptr) return true; + + for (uint i = 0; i < card; i++) { + ref_items1[i].reset(); + } + + ref_items = ref_items1; + tmp_fields = tmp_fields1; + + return false; +} + bool JOIN::alloc_indirection_slices() { const uint card = REF_SLICE_WIN_1 + m_windows.elements * 2; - assert(ref_items == nullptr); - ref_items = (*THR_MALLOC)->ArrayAlloc(card); - if (ref_items == nullptr) return true; + assert(ref_items0 == nullptr); + ref_items0 = (*THR_MALLOC)->ArrayAlloc(card); + if (ref_items0 == nullptr) return true; - tmp_fields = + tmp_fields0 = (*THR_MALLOC)->ArrayAlloc>(card, *THR_MALLOC); - if (tmp_fields == nullptr) return true; + if (tmp_fields0 == nullptr) return true; + + for (uint i = 0; i < card; i++) { + ref_items0[i].reset(); + } + + ref_items = ref_items0; + tmp_fields = tmp_fields0; + + return false; +} + +void count_field_types(Query_block *select_lex, Temp_table_param *param, + List &fields, bool reset_with_sum_func, + bool save_sum_fields); + +bool JOIN::restore_optimized_vars() { + + //restore the make_tmp_tables_info's parameter through saved_optimized_variables + grouped = saved_optimized_vars.pq_grouped; + group_optimized_away = saved_optimized_vars.pq_group_optimized_away; + implicit_grouping = saved_optimized_vars.pq_implicit_grouping; + need_tmp_before_win = saved_optimized_vars.pq_need_tmp_before_win; + simple_group = saved_optimized_vars.pq_simple_group; + simple_order = saved_optimized_vars.pq_simple_order; + streaming_aggregation = saved_optimized_vars.pq_streaming_aggregation; + m_ordered_index_usage = static_cast(saved_optimized_vars.pq_m_ordered_index_usage); + skip_sort_order = saved_optimized_vars.pq_skip_sort_order; + + // no need for template_join + if (need_tmp_pq || need_tmp_pq_leader) { + ORDER *optimized_order = NULL; + group_list.clean(); + + optimized_order = restore_optimized_group_order(query_block->group_list, + saved_optimized_vars.optimized_group_flags); + if (optimized_order) { + group_list = ORDER_with_src(optimized_order, ESC_GROUP_BY); + } + + order.clean(); + optimized_order = restore_optimized_group_order(query_block->order_list, + saved_optimized_vars.optimized_order_flags); + + if (optimized_order) { + order = ORDER_with_src(optimized_order, ESC_ORDER_BY); + } + + if (!group_list.empty()) { + uint old_group_parts = tmp_table_param->group_parts; + calc_group_buffer(this, group_list.order); + send_group_parts = tmp_table_param->group_parts; /* Save org parts */ + if (send_group_parts != old_group_parts) //error: leader and worker have different group fields + return true; + } + + /** Traverse expressions and inject cast nodes to compatible data types (in + * general for time related item), if needed */ + { + for (Item *item : *query_block_fields) { + item->walk(&Item::cast_incompatible_args, enum_walk::POSTFIX, nullptr); + } + } + } + return false; +} + +void JOIN::save_optimized_vars() { + // saved optimized variables + saved_optimized_vars.pq_grouped= grouped; + saved_optimized_vars.pq_group_optimized_away= group_optimized_away; + saved_optimized_vars.pq_implicit_grouping= implicit_grouping; + saved_optimized_vars.pq_need_tmp_before_win= need_tmp_before_win; + saved_optimized_vars.pq_simple_group= simple_group; + saved_optimized_vars.pq_simple_order= simple_order; + saved_optimized_vars.pq_streaming_aggregation= streaming_aggregation; + saved_optimized_vars.pq_skip_sort_order= skip_sort_order; + saved_optimized_vars.pq_m_ordered_index_usage = m_ordered_index_usage; + + //record the mapping: JOIN::group_list -> query_block->group_list + record_optimized_group_order(query_block->saved_group_list_ptrs, group_list, + saved_optimized_vars.optimized_group_flags); + record_optimized_group_order(query_block->saved_order_list_ptrs, order, + saved_optimized_vars.optimized_order_flags); +} + +bool JOIN::setup_tmp_table_info(JOIN* orig) +{ + if (alloc_indirection_slices()) return true; + + // The base ref items from query block are assigned as JOIN's ref items + ref_items[REF_SLICE_ACTIVE] = query_block->base_ref_items; + + // make aggregation temp table info and create temp table for group by/order by/sort + tmp_table_param->pq_copy(orig->saved_tmp_table_param); + saved_tmp_table_param = new (thd->mem_root) Temp_table_param(); + if(!saved_tmp_table_param) { + return true; + } + saved_tmp_table_param->pq_copy(orig->saved_tmp_table_param); + + // aggregation + if(restore_optimized_vars()) + return true; + + select_distinct = orig->select_distinct; + + if(alloc_func_list()) { + return true; + } return false; } @@ -275,9 +421,9 @@ bool JOIN::optimize() { trace_optimize.add_select_number(query_block->select_number); Opt_trace_array trace_steps(trace, "steps"); - count_field_types(query_block, &tmp_table_param, *fields, false, false); + count_field_types(query_block, tmp_table_param, *fields, false, false); - assert(tmp_table_param.sum_func_count == 0 || !group_list.empty() || + assert(tmp_table_param->sum_func_count == 0 || !group_list.empty() || implicit_grouping); const bool has_windows = m_windows.elements != 0; @@ -468,7 +614,7 @@ bool JOIN::optimize() { best_rowcount = 1; error = 0; if (make_tmp_tables_info()) return true; - count_field_types(query_block, &tmp_table_param, *fields, false, false); + count_field_types(query_block, tmp_table_param, *fields, false, false); // Make plan visible for EXPLAIN set_plan_state(NO_TABLES); create_access_paths(); @@ -495,7 +641,7 @@ bool JOIN::optimize() { substitute_gc(thd, query_block, where_cond, group_list.order, order.order)) { // We added hidden fields to the all_fields list, count them. - count_field_types(query_block, &tmp_table_param, query_block->fields, false, + count_field_types(query_block, tmp_table_param, query_block->fields, false, false); } // Ensure there are no errors prior making query plan @@ -698,10 +844,10 @@ bool JOIN::optimize() { // JOIN::optimize_rollup() may set allow_group_via_temp_table = false, // and we must not undo that. const bool save_allow_group_via_temp_table = - tmp_table_param.allow_group_via_temp_table; + tmp_table_param->allow_group_via_temp_table; - count_field_types(query_block, &tmp_table_param, *fields, false, false); - tmp_table_param.allow_group_via_temp_table = + count_field_types(query_block, tmp_table_param, *fields, false, false); + tmp_table_param->allow_group_via_temp_table = save_allow_group_via_temp_table; } @@ -852,6 +998,18 @@ bool JOIN::optimize() { return true; // error == -1 } + if (thd->m_suite_for_pq == PqConditionStatus::ENABLED) { + // save temp table param for later PQ scan + saved_tmp_table_param = new (thd->mem_root) Temp_table_param(); + if (!saved_tmp_table_param) return true; + + saved_tmp_table_param->pq_copy(tmp_table_param); + + // saved optimized variables to saved_optimized_vars. + save_optimized_vars(); + saved_optimized_vars.pq_no_jbuf_after = no_jbuf_after; + } + if (make_join_readinfo(this, no_jbuf_after)) return true; /* purecov: inspected */ @@ -875,7 +1033,7 @@ bool JOIN::optimize() { sort_cost = 0.0; } - count_field_types(query_block, &tmp_table_param, *fields, false, false); + count_field_types(query_block, tmp_table_param, *fields, false, false); create_access_paths(); @@ -975,6 +1133,26 @@ bool JOIN::push_to_engines() { return false; } +bool JOIN::pq_copy_from(JOIN *orig) { + query_block->join = this; + where_cond = query_block->where_cond(); + tables_list = query_block->leaf_tables; + having_for_explain = orig->having_for_explain; + tables = orig->tables; + explain_flags = orig->explain_flags; + set_plan_state(JOIN::PLAN_READY); + pq_tab_idx = orig->pq_tab_idx; + calc_found_rows = orig->calc_found_rows; + m_select_limit = orig->m_select_limit; + query_expression()->select_limit_cnt = + orig->query_expression()->select_limit_cnt; + query_expression()->offset_limit_cnt = 0; + pq_stable_sort = orig->pq_stable_sort; + saved_optimized_vars = orig->saved_optimized_vars; + + return false; +} + /** Substitute all expressions in the WHERE condition and ORDER/GROUP lists that match generated columns (GC) expressions with GC fields, if any. @@ -1128,10 +1306,53 @@ bool JOIN::alloc_qep(uint n) { ASSERT_BEST_REF_IN_JOIN_ORDER(this); - qep_tab = new (thd->mem_root) + qep_tab0 = new (thd->mem_root) QEP_TAB[n + 1]; // The last one holds only the final op_type. - if (!qep_tab) return true; /* purecov: inspected */ - for (uint i = 0; i < n; ++i) qep_tab[i].init(best_ref[i]); + if (!qep_tab0) return true; /* purecov: inspected */ + for (uint i = 0; i < n; ++i) + { + qep_tab0[i].init(best_ref[i]); + qep_tab0[i].pos = i; + } + qep_tab = qep_tab0; + return false; +} + +bool JOIN::alloc_qep1(uint n) { + static_assert(MAX_TABLES <= INT_MAX8, "plan_idx needs to be wide enough."); + assert(tables == n); + + qep_tab1 = new (thd->pq_mem_root) QEP_TAB[n + 1]; + if (!qep_tab1) return true; /* purecov: inspected */ + + for (uint i=0; i< n; i++) qep_tab1[i].pos = i; + + for (uint i=0; i < n; i++){ + qep_tab1[i].set_qs(qep_tab0[i].get_qs()); + qep_tab1[i].set_join(this); + qep_tab1[i].match_tab = qep_tab0[i].match_tab; + qep_tab1[i].check_weed_out_table = qep_tab0[i].check_weed_out_table; + qep_tab1[i].flush_weedout_table = qep_tab0[i].flush_weedout_table; + qep_tab1[i].op_type = qep_tab0[i].op_type; + qep_tab1[i].table_ref = qep_tab0[i].table_ref; + qep_tab1[i].using_dynamic_range = qep_tab0[i].using_dynamic_range; + qep_tab0[i].set_old_type(qep_tab0[i].type()); + qep_tab0[i].set_old_ref(&qep_tab0[i].ref()); + qep_tab0[i].set_old_quick_optim(); + } + + for (uint i=0; i < primary_tables; i++) + { + qep_tab1[i].pq_copy(thd, &qep_tab0[i]); + TABLE *tb = qep_tab0[i].table(); + qep_tab1[i].set_table(tb); + + if(qep_tab0[i].quick()) { + qep_tab1[i].set_quick(qep_tab0[i].quick()); + } + } + qep_tab = qep_tab1; + return false; } @@ -1275,7 +1496,7 @@ bool JOIN::optimize_distinct_group_order() { const bool windowing = m_windows.elements > 0; const bool may_trace = select_distinct || !group_list.empty() || !order.empty() || windowing || - tmp_table_param.sum_func_count; + tmp_table_param->sum_func_count; Opt_trace_context *const trace = &thd->opt_trace; Opt_trace_disable_I_S trace_disabled(trace, !may_trace); Opt_trace_object wrapper(trace); @@ -1319,7 +1540,7 @@ bool JOIN::optimize_distinct_group_order() { JOIN_TAB *const tab = best_ref[const_tables]; if (plan_is_single_table() && (!group_list.empty() || select_distinct) && - !tmp_table_param.sum_func_count && + !tmp_table_param->sum_func_count && (!tab->quick() || tab->quick()->get_type() != QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) { if (!group_list.empty() && rollup_state == RollupState::NONE && @@ -1339,7 +1560,7 @@ bool JOIN::optimize_distinct_group_order() { .add("removed_distinct", true); } } - if (!(!group_list.empty() || tmp_table_param.sum_func_count || windowing) && + if (!(!group_list.empty() || tmp_table_param->sum_func_count || windowing) && select_distinct && plan_is_single_table() && rollup_state == RollupState::NONE) { int order_idx = -1, group_idx = -1; @@ -1365,7 +1586,7 @@ bool JOIN::optimize_distinct_group_order() { tab, order, m_select_limit, true, // no_changes &tab->table()->keys_in_use_for_order_by, &order_idx); - count_field_types(query_block, &tmp_table_param, *fields, false, false); + count_field_types(query_block, tmp_table_param, *fields, false, false); } ORDER *o; bool all_order_fields_used; @@ -1380,7 +1601,7 @@ bool JOIN::optimize_distinct_group_order() { true, // no_changes &tab->table()->keys_in_use_for_group_by, &group_idx); - count_field_types(query_block, &tmp_table_param, *fields, false, false); + count_field_types(query_block, tmp_table_param, *fields, false, false); // ORDER BY and GROUP BY are using different indexes, can't skip sorting if (group_idx >= 0 && order_idx >= 0 && group_idx != order_idx) skip_sort_order = false; @@ -1403,7 +1624,7 @@ bool JOIN::optimize_distinct_group_order() { Force MySQL to read the table in sorted order to get result in ORDER BY order. */ - tmp_table_param.allow_group_via_temp_table = false; + tmp_table_param->allow_group_via_temp_table = false; } grouped = true; // For end_write_group trace_opt.add("changed_distinct_to_group_by", true); @@ -1435,7 +1656,7 @@ bool JOIN::optimize_distinct_group_order() { } calc_group_buffer(this, group_list.order); - send_group_parts = tmp_table_param.group_parts; /* Save org parts */ + send_group_parts = tmp_table_param->group_parts; /* Save org parts */ /* If ORDER BY is a prefix of GROUP BY and if windowing or ROLLUP @@ -1445,7 +1666,7 @@ bool JOIN::optimize_distinct_group_order() { */ if ((test_if_subpart(group_list.order, order.order) && !m_windows_sort && query_block->olap != ROLLUP_TYPE) || - (group_list.empty() && tmp_table_param.sum_func_count)) { + (group_list.empty() && tmp_table_param->sum_func_count)) { if (!order.empty()) { order.clean(); trace_opt.add("removed_order_by", true); @@ -1503,7 +1724,7 @@ void JOIN::test_skip_sort() { TODO: Explain the allow_group_via_temp_table part of the test below. */ if ((m_ordered_index_usage != ORDERED_INDEX_GROUP_BY) && - (tmp_table_param.allow_group_via_temp_table || + (tmp_table_param->allow_group_via_temp_table || (tab->emb_sj_nest && tab->position()->sj_strategy == SJ_OPT_LOOSE_SCAN))) { need_tmp_before_win = true; @@ -2453,7 +2674,7 @@ check_reverse_order: tab->set_type(calc_join_type(tab->quick()->get_type())); tab->use_quick = QS_RANGE; if (tab->quick()->is_loose_index_scan()) - join->tmp_table_param.precomputed_group_by = true; + join->tmp_table_param->precomputed_group_by = true; tab->position()->filter_effect = COND_FILTER_STALE; } } // best_key >= 0 @@ -2836,7 +3057,7 @@ bool JOIN::get_best_combination() { (!group_list.empty() || (implicit_grouping && m_windows.elements) > 0 ? 1 : 0) + - (select_distinct ? (tmp_table_param.outer_sum_func_count ? 2 : 1) : 0) + + (select_distinct ? (tmp_table_param->outer_sum_func_count ? 2 : 1) : 0) + (order.empty() ? 0 : 1) + (query_block->active_options() & (SELECT_BIG_RESULT | OPTION_BUFFER_RESULT) @@ -4612,7 +4833,7 @@ static bool change_cond_ref_to_const(THD *thd, I_List *save_list, @returns false if success, true if error */ -static bool propagate_cond_constants(THD *thd, I_List *save_list, +bool propagate_cond_constants(THD *thd, I_List *save_list, Item *and_father, Item *cond) { assert(cond->real_item()->is_bool_func()); if (cond->type() == Item::COND_ITEM) { @@ -5010,7 +5231,7 @@ bool JOIN::make_join_plan() { // Build the key access information, which is the basis for ref access. if (where_cond || query_block->outer_join) { - if (update_ref_and_keys(thd, &keyuse_array, join_tab, tables, where_cond, + if (update_ref_and_keys(thd, keyuse_array, join_tab, tables, where_cond, ~query_block->outer_join, query_block, &sargables)) return true; } @@ -7842,7 +8063,7 @@ static void add_loose_index_scan_and_skip_scan_keys(JOIN *join, (uchar *)&indexed_fields); } cause = "distinct"; - } else if (join->tmp_table_param.sum_func_count && + } else if (join->tmp_table_param->sum_func_count && is_indexed_agg_distinct(join, &indexed_fields)) { /* SELECT list with AGGFN(distinct col). The query qualifies for @@ -10348,8 +10569,8 @@ static TABLE *get_sort_by_table(ORDER *a, ORDER *b, TABLE_LIST *tables) { */ void JOIN::optimize_keyuse() { - for (size_t ix = 0; ix < keyuse_array.size(); ++ix) { - Key_use *keyuse = &keyuse_array.at(ix); + for (size_t ix = 0; ix < keyuse_array->size(); ++ix) { + Key_use *keyuse = &keyuse_array->at(ix); table_map map; /* If we find a ref, assume this table matches a proportional @@ -10878,9 +11099,9 @@ double calculate_subquery_executions(const Item_subselect *subquery, */ bool JOIN::optimize_rollup() { - tmp_table_param.allow_group_via_temp_table = false; + tmp_table_param->allow_group_via_temp_table = false; rollup_state = RollupState::INITED; - tmp_table_param.group_parts = send_group_parts; + tmp_table_param->group_parts = send_group_parts; return false; } diff --git a/sql/sql_optimizer.h b/sql/sql_optimizer.h index 53a88995b..964693d82 100644 --- a/sql/sql_optimizer.h +++ b/sql/sql_optimizer.h @@ -2,6 +2,7 @@ #define SQL_OPTIMIZER_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -51,7 +52,9 @@ #include "sql/sql_select.h" // Key_use #include "sql/table.h" #include "sql/temp_table_param.h" +#include "sql/sql_parallel.h" +struct PQ_optimized_var; enum class Subquery_strategy : int; class COND_EQUAL; class Item_subselect; @@ -59,8 +62,10 @@ class Item_sum; class Opt_trace_context; class THD; class Window; +class MQueue_handle; struct AccessPath; struct MYSQL_LOCK; +class Gather_operator; class Item_equal; template @@ -136,7 +141,7 @@ class JOIN { /// Query block that is optimized and executed using this JOIN Query_block *const query_block; /// Thread handler - THD *const thd; + THD *thd; /** Optimal query execution plan. Initialized with a tentative plan in @@ -146,6 +151,8 @@ class JOIN { JOIN_TAB *join_tab{nullptr}; /// Array of QEP_TABs QEP_TAB *qep_tab{nullptr}; + QEP_TAB *qep_tab0{nullptr}; + QEP_TAB *qep_tab1{nullptr}; /** Array of plan operators representing the current (partial) best @@ -207,6 +214,7 @@ class JOIN { 5. semi-joined tables used with materialization strategy */ uint tables{0}; ///< Total number of tables in query block + uint old_tables{0}; ///< Save old total number of tables in query block uint primary_tables{0}; ///< Number of primary input tables in query block uint const_tables{0}; ///< Number of primary tables deemed constant uint tmp_tables{0}; ///< Number of temporary tables used by query @@ -311,7 +319,9 @@ class JOIN { The one here is transiently used as a model by create_intermediate_table(), to build the tmp table's own tmp_table_param. */ - Temp_table_param tmp_table_param; + Temp_table_param origin_tmp_table_param; + Temp_table_param *tmp_table_param; + Temp_table_param *saved_tmp_table_param; MYSQL_LOCK *lock; enum class RollupState { NONE, INITED, READY }; @@ -348,8 +358,8 @@ class JOIN { should be used instead of a filesort when computing ORDER/GROUP BY. */ - enum { - ORDERED_INDEX_VOID, // No ordered index avail. + enum ORDERED_INDEX_USAGE { + ORDERED_INDEX_VOID = 0, // No ordered index avail. ORDERED_INDEX_GROUP_BY, // Use index for GROUP BY ORDERED_INDEX_ORDER_BY // Use index for ORDER BY } m_ordered_index_usage{ORDERED_INDEX_VOID}; @@ -367,11 +377,18 @@ class JOIN { */ bool need_tmp_before_win{false}; + // need a tmp table to store Parallel Query result + bool need_tmp_pq{false}; + + // need a tmp table for leader thread + bool need_tmp_pq_leader{false}; + /// If JOIN has lateral derived tables (is set at start of planning) bool has_lateral{false}; /// Used and updated by JOIN::make_join_plan() and optimize_keyuse() - Key_use_array keyuse_array; + Key_use_array origin_keyuse_array; + Key_use_array *keyuse_array; /// List storing all expressions used in query block mem_root_deque *query_block_fields; @@ -392,6 +409,8 @@ class JOIN { @see JOIN::make_tmp_tables_info() */ mem_root_deque *tmp_fields = nullptr; + mem_root_deque *tmp_fields0 = nullptr; + mem_root_deque *tmp_fields1 = nullptr; int error{0}; ///< set in optimize(), exec(), prepare_result() @@ -400,6 +419,18 @@ class JOIN { */ ORDER_with_src order, group_list; + //used for worker's make_tmp_tables_info + PQ_optimized_var saved_optimized_vars; + + // the split table + int pq_tab_idx{-1}; + + bool pq_rebuilt_group{false}; + + bool pq_stable_sort{false}; + + int pq_last_sort_idx{-1}; + // Used so that AggregateIterator knows which items to signal when the rollup // level changes. Obviously only used in the presence of rollup. Prealloced_array rollup_group_items{ @@ -512,6 +543,12 @@ class JOIN { Ref_item_array *ref_items{ nullptr}; // cardinality: REF_SLICE_SAVED_BASE + 1 + #windows*2 + Ref_item_array + *ref_items0{nullptr}; // cardinality: REF_SLICE_SAVED_BASE + 1 + #windows*2 + + Ref_item_array + *ref_items1{nullptr}; // use for parallel Query leader + /** The slice currently stored in ref_items[0]. Used to restore the base ref_items slice from the "save" slice after it @@ -519,6 +556,9 @@ class JOIN { */ uint current_ref_item_slice; + // used for Parallel Query + uint last_slice_before_pq; + /** Used only if this query block is recursive. Contains count of all executions of this recursive query block, since the last @@ -664,7 +704,7 @@ class JOIN { returning the row. */ bool send_row_on_empty_set() const { - return (do_send_rows && tmp_table_param.sum_func_count != 0 && + return (do_send_rows && tmp_table_param->sum_func_count != 0 && group_list.empty() && !group_optimized_away && query_block->having_value != Item::COND_FALSE); } @@ -779,7 +819,7 @@ class JOIN { bool create_intermediate_table(QEP_TAB *tab, const mem_root_deque &tmp_table_fields, ORDER_with_src &tmp_table_group, - bool save_sum_fields); + bool save_sum_fields, bool force_disk_table = false); /** Optimize distinct when used on a subset of the tables. @@ -887,8 +927,36 @@ class JOIN { POSITION *sjm_pos); bool add_having_as_tmp_table_cond(uint curr_tmp_table); + + public: bool make_tmp_tables_info(); + + // make Paralle Query leader's qep tables info + bool make_leader_tables_info(); + // make a tmp table in Query_result_mq for PQ + bool make_pq_tables_info(); + bool alloc_qep1(uint n); + + /** + Test if an index could be used to replace filesort for ORDER BY/GROUP BY + + @details + Investigate whether we may use an ordered index as part of either + DISTINCT, GROUP BY or ORDER BY execution. An ordered index may be + used for only the first of any of these terms to be executed. This + is reflected in the order which we check for test_if_skip_sort_order() + below. However we do not check for DISTINCT here, as it would have + been transformed to a GROUP BY at this stage if it is a candidate for + ordered index optimization. + If a decision was made to use an ordered index, the availability + if such an access path is stored in 'm_ordered_index_usage' for later + use by 'execute' or 'explain' + */ + void test_skip_sort(); + void set_plan_state(enum_plan_state plan_state_arg); + + private: bool compare_costs_of_subquery_strategies(Subquery_strategy *method); ORDER *remove_const(ORDER *first_order, Item *cond, bool change_list, bool *simple_order, bool group_by); @@ -911,31 +979,8 @@ class JOIN { */ bool optimize_distinct_group_order(); - /** - Test if an index could be used to replace filesort for ORDER BY/GROUP BY - - @details - Investigate whether we may use an ordered index as part of either - DISTINCT, GROUP BY or ORDER BY execution. An ordered index may be - used for only the first of any of these terms to be executed. This - is reflected in the order which we check for test_if_skip_sort_order() - below. However we do not check for DISTINCT here, as it would have - been transformed to a GROUP BY at this stage if it is a candidate for - ordered index optimization. - If a decision was made to use an ordered index, the availability - if such an access path is stored in 'm_ordered_index_usage' for later - use by 'execute' or 'explain' - */ - void test_skip_sort(); - bool alloc_indirection_slices(); - /** - Convert the executor structures to a set of access paths, storing - the result in m_root_access_path. - */ - void create_access_paths(); - /** Create access paths with the knowledge that there are going to be zero rows coming from tables (before aggregation); typically because we know that @@ -952,11 +997,28 @@ class JOIN { AccessPath *attach_access_paths_for_having_and_limit(AccessPath *path); /** @} */ + public: /** An access path you can read from to get all records for this query (after you create an iterator from it). */ AccessPath *m_root_access_path = nullptr; + + /** + Convert the executor structures to a set of access paths, stroing + the result in m_root_access_path. + */ + void create_access_paths(); + + bool pq_copy_from(JOIN *orig); + + bool alloc_indirection_slices1(); + + bool setup_tmp_table_info(JOIN *orig); + + bool restore_optimized_vars(); + + void save_optimized_vars(); }; /** @@ -966,7 +1028,7 @@ class JOIN { */ #define ASSERT_BEST_REF_IN_JOIN_ORDER(join) \ do { \ - assert((join)->tables == 0 || ((join)->best_ref && !(join)->join_tab)); \ + assert((join)->thd->parallel_exec || (join)->tables == 0 || ((join)->best_ref && !(join)->join_tab)); \ } while (0) /** @@ -1135,6 +1197,12 @@ extern const char *antijoin_null_cond; */ bool evaluate_during_optimization(const Item *item, const Query_block *select); +extern Field *create_tmp_field_for_schema(Item *item, TABLE *table, MEM_ROOT *root); +extern void record_optimized_group_order(PQ_Group_list_ptrs *ptr, ORDER_with_src &new_list, + std::vector &optimized_flags); +extern ORDER *restore_optimized_group_order(SQL_I_List &orig_list, + std::vector &optimized_flags); + /** Find the multiple equality predicate containing a field. diff --git a/sql/sql_parallel.cc b/sql/sql_parallel.cc new file mode 100644 index 000000000..8b03c28c8 --- /dev/null +++ b/sql/sql_parallel.cc @@ -0,0 +1,1210 @@ +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "sql/sql_parallel.h" +#include "include/my_alloc.h" +#include "include/my_dbug.h" +#include "include/mysql/psi/mysql_thread.h" +#include "sql/auth/auth_acls.h" +#include "sql/basic_row_iterators.h" +#include "sql/exchange_nosort.h" +#include "sql/exchange_sort.h" +#include "sql/filesort.h" +#include "sql/handler.h" +#include "sql/item_sum.h" +#include "sql/log.h" +#include "sql/msg_queue.h" +#include "sql/mysqld.h" +#include "sql/mysqld_thd_manager.h" // Global_THD_manager +#include "sql/opt_range.h" +#include "sql/opt_trace.h" +#include "sql/pq_clone.h" +#include "sql/pq_condition.h" +#include "sql/pq_global.h" +#include "sql/query_result.h" +#include "sql/sql_base.h" +#include "sql/sql_optimizer.h" +#include "sql/sql_tmp_table.h" +#include "sql/timing_iterator.h" +#include "sql/transaction.h" +#include "sql/join_optimizer/explain_access_path.h" + +ulonglong parallel_memory_limit = 0; +ulong parallel_max_threads = 0; +uint parallel_threads_running = 0; +uint parallel_threads_refused = 0; +uint parallel_memory_refused = 0; +uint pq_memory_used[16] = {0}; +uint pq_memory_total_used = 0; + +mysql_mutex_t LOCK_pq_threads_running; +mysql_cond_t COND_pq_threads_running; + +Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, + bool other_tbls_ok); + +Item *make_cond_remainder(Item *cond, bool exclude_index); + +void thd_set_thread_stack(THD *thd, const char *stack_start); + +static JOIN *make_pq_worker_plan(PQ_worker_manager *mngr); + +void release_pq_running_threads(uint dop) { + mysql_mutex_lock(&LOCK_pq_threads_running); + parallel_threads_running -= dop; + current_thd->pq_threads_running -= dop; + mysql_cond_broadcast(&COND_pq_threads_running); + mysql_mutex_unlock(&LOCK_pq_threads_running); +} + +/** + * Init record gather + * + * @retval: false if success, and otherwise true + */ +bool MQ_record_gather::mq_scan_init(Filesort *sort, int workers, + uint ref_length, bool stab_output) { + if (sort) { + m_exchange = new (m_thd->pq_mem_root) + Exchange_sort(m_thd, m_tab->table(), sort, m_tab->old_table()->file, + workers, ref_length, stab_output); + } else { + m_exchange = new (m_thd->pq_mem_root) Exchange_nosort( + m_thd, m_tab->table(), workers, ref_length, stab_output); + } + + if (!m_exchange || m_exchange->init()) return true; + + return false; +} + +/** + * read table->record[0] from workers through message queue + * + * @retval: false if success, and otherwise true + */ + +bool MQ_record_gather::mq_scan_next() { + assert(m_exchange); + return (m_exchange->read_mq_record()); +} + +void MQ_record_gather::mq_scan_end() { + assert(m_exchange); + m_exchange->cleanup(); +} + +PQ_worker_manager::PQ_worker_manager(uint id) + : m_id(id), + m_gather(nullptr), + thd_leader(nullptr), + thd_worker(nullptr), + m_handle(nullptr), + m_status(INIT), + m_active(false) { + mysql_mutex_init(0, &m_mutex, MY_MUTEX_INIT_FAST); + mysql_cond_init(0, &m_cond); +} + +PQ_worker_manager::~PQ_worker_manager() { + mysql_mutex_destroy(&m_mutex); + mysql_cond_destroy(&m_cond); +} + +/* + * PQ worker wait for an status + * + * @leader: PQ leader thread + * @status: + * + * @retval: + * true if normally execute, and otherwise false (i.e., execution-error) + */ + +bool PQ_worker_manager::wait_for_status(THD *leader MY_ATTRIBUTE((unused)), + uint status) { + assert(leader == current_thd); + mysql_mutex_lock(&m_mutex); + while (!(((unsigned int)this->m_status) & status)) { + struct timespec abstime; + Timeout_type wait_time = 5; + set_timespec(&abstime, wait_time * TIME_MILLION); + mysql_cond_timedwait(&m_cond, &m_mutex, &abstime); + } + mysql_mutex_unlock(&m_mutex); + return !(((unsigned int)this->m_status) & PQ_worker_state::ERROR); +} + +void PQ_worker_manager::signal_status(THD *thd, PQ_worker_state status) { + mysql_mutex_lock(&m_mutex); + if (!((unsigned int)this->m_status & (unsigned int)status)) { + this->m_status = status; + this->thd_worker = thd; + } + mysql_cond_signal(&m_cond); + mysql_mutex_unlock(&m_mutex); +} + +Gather_operator::Gather_operator(uint dop) + : m_dop(dop), + m_template_join(nullptr), + m_workers(nullptr), + m_table(nullptr), + m_pq_ctx(nullptr), + m_tab(nullptr), + keyno(0), + m_ha_err(0), + m_stmt_da(false), + m_code_state(nullptr), + table_scan(false) { + mysql_mutex_init(0, &lock_stmt_da, MY_MUTEX_INIT_FAST); +} + +Gather_operator::~Gather_operator() { mysql_mutex_destroy(&lock_stmt_da); } + +/* + * replace the parameter item of Aggr. with the generated item in rewritten tab. + * + */ +void pq_replace_avg_func(THD *thd, Query_block *select MY_ATTRIBUTE((unused)), + mem_root_deque *fields, + nesting_map select_nest_level MY_ATTRIBUTE((unused))) { + size_t i = 0; + for (Item *item : *fields) { + if (item->real_item()->type() == Item::SUM_FUNC_ITEM) { + Item_sum *item_old = (Item_sum *)(item->real_item()); + assert(item_old); + if (item_old->sum_func() == Item_sum::AVG_FUNC) { + Item_sum_avg *item_avg = dynamic_cast(item_old); + assert(item_avg); + item_avg->pq_avg_type = PQ_LEADER; + item_avg->resolve_type(thd); + } + } else if (item->real_item()->type() == Item::FIELD_AVG_ITEM) { + Item_avg_field *item_avg_field = + dynamic_cast(item->real_item()); + Item_sum_avg *item_avg = item_avg_field->avg_item; + item_avg->pq_avg_type = PQ_LEADER; + item_avg_field->pq_avg_type = PQ_LEADER; + item_avg->resolve_type(thd); + (*fields)[i] = item_avg; + + } else if (item->real_item()->type() == Item::FIELD_ITEM) { + Item_field *item_field = dynamic_cast(item->real_item()); + Item_sum *item_sum = item_field->field->item_sum_ref; + if (item_sum && item_sum->sum_func() == Item_sum::AVG_FUNC) { + Item_sum_avg *item_avg = down_cast(item_sum); + item_avg->pq_avg_type = PQ_LEADER; + item_avg->resolve_type(thd); + (*fields)[i] = item_avg; + } + } + i++; + } +} + +/** + * build sum funcs based on PQ leader temp table field when orig JOIN old + * fields_list contain sum funcs. because origin sum item has been replaced by + * Item_field in temp table fields list + * + * @fields_orig:orig fields list which could contain sum funs item + * @fields_new: PQ leader temp table's fields list + * + */ +bool pq_build_sum_funcs(THD *thd, Query_block *select, Ref_item_array &ref_ptr, + mem_root_deque &fields, uint elements, + nesting_map select_nest_level) { + uint saved_allow_sum_funcs = thd->lex->allow_sum_func; + thd->lex->allow_sum_func |= select_nest_level; + uint border = fields.size() - elements; + + size_t i = 0; + for (Item *item : fields) { + if (item->real_item()->type() == Item::FIELD_ITEM) { + Item_field *item_field = dynamic_cast(item); + + if (item_field == nullptr || item_field->field == nullptr || + item_field->field->item_sum_ref == nullptr) { + i++; + continue; + } + + Item_sum *item_ref = item_field->field->item_sum_ref; + + if (item_ref->type() == Item::SUM_FUNC_ITEM) { + Item_sum *sum_func = + item_ref->pq_rebuild_sum_func(thd, select, item_field); + assert(DBUG_EVALUATE_IF("skip_pq_clone_check", true, false) || + sum_func); + if (!sum_func) { + thd->lex->allow_sum_func = saved_allow_sum_funcs; + return true; + } + sum_func->fix_fields(thd, nullptr); + item_field->field->item_sum_ref = sum_func; + fields[i] = sum_func; + ref_ptr[((i < border) ? fields.size() - i - 1 : i - border)] = + sum_func; + } + } + i++; + } + thd->lex->allow_sum_func = saved_allow_sum_funcs; + return false; +} + +THD *pq_new_thd(THD *thd) { + DBUG_TRACE; + + THD *new_thd = new (thd->pq_mem_root) THD(); + if (!new_thd || + DBUG_EVALUATE_IF("dup_thd_abort", (!(new_thd->net.error = 0)), false)) { + goto err; + } + + new_thd->set_new_thread_id(); + thd_set_thread_stack(new_thd, (char *)&new_thd); + new_thd->init_cost_model(); + new_thd->store_globals(); + new_thd->want_privilege = 0; + new_thd->net.error = 0; + new_thd->set_db(thd->db()); + new_thd->pq_copy_from(thd); + + return new_thd; + +err: + if (new_thd) { + end_connection(new_thd); + close_connection(new_thd, 0, false, false); + new_thd->release_resources(); + new_thd->get_stmt_da()->reset_diagnostics_area(); + destroy(new_thd); + } + return nullptr; +} + +/** + * make a parallel query gather operator from a serial query plan + * + * @join : is a pysics serial query plan + * @table : table need to parallel scan + * @dop is : the degree of parallel + * + */ +Gather_operator *make_pq_gather_operator(JOIN *join, QEP_TAB *tab, uint dop) { + THD *thd = current_thd; + assert(thd == join->thd && thd->parallel_exec); + JOIN *template_join = nullptr; + Gather_operator *gather_opr = nullptr; + + // duplicate a query plan template from join, which is used in PQ workers + THD *new_thd = pq_new_thd(join->thd); + if (!new_thd) goto err; + new_thd->pq_leader = thd; + new_thd->parallel_exec = true; + template_join = pq_make_join(new_thd, join); + + if (!template_join || pq_dup_tabs(template_join, join, true)) { + goto err; + } + + if (template_join->setup_tmp_table_info(join) || + DBUG_EVALUATE_IF("pq_gather_error1", true, false)) { + sql_print_warning("[Parallel query] Setup gather tmp tables failed"); + goto err; + } + + /** duplicate a new THD and set it as current_thd, so here should restore old + * THD */ + thd->store_globals(); + gather_opr = new (thd->pq_mem_root) Gather_operator(dop); + + if (!gather_opr || DBUG_EVALUATE_IF("pq_gather_error2", true, false)) { + goto err; + } + + tab->gather = gather_opr; + gather_opr->m_template_join = template_join; + gather_opr->m_tab = tab; + gather_opr->m_table = tab->table(); +#ifndef NDEBUG + gather_opr->m_code_state = my_thread_var_dbug(); + assert(gather_opr->m_code_state && *(gather_opr->m_code_state)); +#endif + template_join->thd->push_diagnostics_area(&gather_opr->m_stmt_da); + + gather_opr->m_workers = + thd->pq_mem_root->ArrayAlloc(dop); + + if (!gather_opr->m_workers || + DBUG_EVALUATE_IF("pq_gather_error3", (!(gather_opr->m_workers = nullptr)), + false)) { + goto err; + } + + for (uint i = 0; i < dop; i++) { + gather_opr->m_workers[i] = new (thd->pq_mem_root) PQ_worker_manager(i); + if (!gather_opr->m_workers[i]) goto err; + gather_opr->m_workers[i]->m_gather = gather_opr; + gather_opr->m_workers[i]->thd_leader = thd; + gather_opr->m_workers[i]->thd_worker = nullptr; + gather_opr->m_workers[i]->thread_id.thread = 0; + } + return gather_opr; + +err: + if (new_thd) new_thd->store_globals(); + pq_free_join(template_join); + pq_free_thd(new_thd); + if (gather_opr && gather_opr->m_workers) { + for (uint i = 0; i < dop; i++) { + destroy(gather_opr->m_workers[i]); + } + } + destroy(gather_opr); + thd->store_globals(); + return nullptr; +} + +bool Gather_operator::init() { + int error = 0; + THD *thd = current_thd; + assert(thd == m_table->in_use); + int tab_idx = m_template_join->pq_tab_idx; + assert(tab_idx >= (int)m_template_join->const_tables && + m_template_join->qep_tab[tab_idx].do_parallel_scan); + + QEP_TAB *tab = &m_template_join->qep_tab[tab_idx]; + m_table->file->pq_reverse_scan = tab->m_reversed_access; + m_table->file->pq_range_type = PQ_QUICK_SELECT_NONE; + join_type type = tab->type(); + switch (type) { + case JT_ALL: + keyno = m_table->s->primary_key; + /* + * Note that: order/group-by may be optimized in test_skip_sort(), and + * correspondingly the order/group-by is finished with the generated + * tab->quick(). + */ + if (m_tab->quick() && + m_template_join->m_ordered_index_usage != JOIN::ORDERED_INDEX_VOID) { + keyno = m_tab->quick()->index; + } + table_scan = true; + break; + case JT_RANGE: + assert(m_tab->quick()); + keyno = m_tab->quick()->index; + break; + case JT_REF: + m_table->file->pq_ref_key.key = tab->ref().key_buff; + m_table->file->pq_ref_key.keypart_map = + make_prev_keypart_map(tab->ref().key_parts); + m_table->file->pq_ref_key.length = tab->ref().key_length; + m_table->file->pq_ref_key.flag = HA_READ_KEY_OR_NEXT; + m_table->file->pq_ref = true; + keyno = tab->ref().key; + break; + case JT_INDEX_SCAN: + keyno = m_tab->index(); + break; + default: + assert(0); + keyno = m_table->s->primary_key; + } + + QUICK_SELECT_I *quick = m_tab->quick(); + if (quick && type == JT_RANGE) { + m_table->file->pq_range_type = quick->quick_select_type(); + if (quick->reset()) return true; + if (quick->reverse_sorted()) m_table->file->pq_reverse_scan = true; + } + + /** partition table into blocks for parallel scan by multiple workers, + * if blocks number is less than workers, m_dop will be changed to blocks + * number + */ + uint dop_orig = m_dop; + error = m_table->file->ha_pq_init(m_dop, keyno); + m_pq_ctx = thd->pq_ctx; + if (error) { + m_table->file->print_error(error, MYF(0)); + m_ha_err = error; + return true; + } + + if (dop_orig != m_dop) { + release_pq_running_threads(dop_orig - m_dop); + } + + return false; +} + +/* + * signal the threads waiting for data + */ +void Gather_operator::signalAll() { m_table->file->ha_pq_signal_all(); } + +void pq_free_gather(Gather_operator *gather) { + THD *thd_temp = gather->m_template_join->thd; + if (thd_temp == nullptr) return; + + THD *saved_thd = current_thd; + gather->m_table->file->ha_index_or_rnd_end(); + + // explain format=tree called make_pq_worker_plan, hence + // need to free worker join/thd + for (uint i = 0; i < gather->m_dop; i++) { + if (gather->m_workers[i]->thd_worker) { + gather->m_workers[i]->thd_worker->store_globals(); + gather->m_workers[i]->thd_worker->lex->unit->cleanup( + gather->m_workers[i]->thd_worker, true); + pq_free_thd(gather->m_workers[i]->thd_worker); + } + } + + thd_set_thread_stack(thd_temp, (char *)thd_temp); + thd_temp->store_globals(); + + uint tables = gather->m_template_join->tables; + for (uint i = 0; i < tables; i++) { + if (gather->m_template_join->qep_tab[i].table()) { + gather->m_template_join->qep_tab[i].table()->set_keyread(false); + gather->m_template_join->qep_tab[i].set_keyread_optim(); + } + } + + pq_free_join(gather->m_template_join); + for (uint i = 0; i < gather->m_dop; i++) { + destroy(gather->m_workers[i]); + } + destroy(gather); + + pq_free_thd(thd_temp); + thd_set_thread_stack(saved_thd, (char *)&saved_thd); + saved_thd->store_globals(); +} + +void Gather_operator::end() { pq_free_gather(this); } + +static void restore_leader_plan(JOIN *join) { + join->pq_stable_sort = false; + join->qep_tab = join->qep_tab0; + join->ref_items = join->ref_items0; + join->tmp_fields = join->tmp_fields0; +} + +/** + * make parallel query leader's physical query plan + * + * @join : origin serial query plan + * @dop : degree of parallel + * @return + * + * SEQ_EXEC: can not run in parallel mode, due to RBO. + * PARL_EXEC: successfully run in parallel mode + * ABORT_EXEC: run error in parallal mode and then drop it + */ +PQ_exec_status make_pq_leader_plan(THD *thd) { + if (!check_pq_conditions(thd)) { + thd->m_suite_for_pq = PqConditionStatus::NOT_SUPPORTED; + return PQ_exec_status::SEQ_EXEC; + } else { + thd->m_suite_for_pq = PqConditionStatus::SUPPORTED; + } + + uint dop = thd->pq_dop; + JOIN *join = thd->lex->unit->first_query_block()->join; + mem_root_deque *fields_old = join->fields; + QEP_TAB *tab = nullptr; + Gather_operator *gather = nullptr; + char buff[64] = {0}; + ulong saved_thd_want_privilege = thd->want_privilege; + thd->want_privilege = 0; + + Opt_trace_context *const trace = &thd->opt_trace; + Opt_trace_object trace_wrapper(trace); + Opt_trace_object trace_exec(trace, "make_parallel_query_plan"); + trace_exec.add_select_number(join->query_block->select_number); + Opt_trace_array trace_detail(trace, "detail"); + + MEM_ROOT *saved_mem_root = thd->mem_root; + thd->mem_root = thd->pq_mem_root; + thd->parallel_exec = true; // pass the RBO + + uint tab_idx = 0; + for (uint i = join->const_tables; i < join->primary_tables; i++) { + if (join->qep_tab[i].do_parallel_scan) { + tab_idx = i; + join->pq_tab_idx = tab_idx; + break; + } + } + + if (tab_idx < join->primary_tables) { + TABLE_LIST *table_ref = join->qep_tab[tab_idx].table_ref; + Opt_trace_object trace_one_table(trace); + trace_one_table.add_utf8_table(table_ref).add("degree of parallel", dop); + + join->alloc_qep1(join->tables); + join->alloc_indirection_slices1(); + join->ref_items1[REF_SLICE_ACTIVE] = join->query_block->base_ref_items; + + join->pq_stable_sort = pq_check_stable_sort(join, tab_idx); + gather = make_pq_gather_operator(join, &join->qep_tab[tab_idx], dop); + if (!gather || DBUG_EVALUATE_IF("pq_leader_abort1", true, false)) { + goto err; + } + assert(gather->m_template_join->thd->pq_leader); + tab = &join->qep_tab[tab_idx]; + tab->set_old_table(tab->table()); + // replace parallel scan table with a tmp table + join->primary_tables = tab_idx; + join->need_tmp_pq_leader = true; + join->restore_optimized_vars(); + if (join->make_leader_tables_info() || + DBUG_EVALUATE_IF("pq_leader_abort2", true, false)) + goto err; + join->old_tables = join->tables; + join->tables = join->primary_tables + join->tmp_tables; + + assert(tab->table()->s->table_category == TABLE_CATEGORY_TEMPORARY); + tab->set_type(JT_ALL); + tab->gather = gather; + tab->check_weed_out_table = nullptr; + tab->flush_weedout_table = nullptr; + + // create TABLE_LIST object for explain + TABLE_LIST *tbl = new (thd->pq_mem_root) TABLE_LIST; + if (!tbl) goto err; + + tbl->query_block = join->query_block; + tbl->table_name = (char *)thd->memdup(tab->table()->s->table_name.str, + tab->table()->s->table_name.length); + tbl->table_name_length = tab->table()->s->table_name.length; + tbl->db = (char *)thd->memdup(tab->table()->s->db.str, + tab->table()->s->db.length); + tbl->db_length = tab->table()->s->db.length; + snprintf(buff, 64, "", + gather->m_template_join->query_block->select_number); + tbl->alias = (char *)thd->memdup(buff, 64); + if (!tbl->table_name || !tbl->db || !tbl->alias) goto err; + + tab->table_ref = tbl; + tbl->set_tableno(tab_idx); + tab->table()->pos_in_table_list = tbl; + join->query_block->table_list.link_in_list(tbl, &tbl->next_local); + TABLE_REF *ref = new (thd->pq_mem_root) TABLE_REF(); + if (!ref) goto err; + + tab->set_ref(ref); + for (uint i = 0; i < join->tables; i++) { + join->qep_tab[i].set_condition(nullptr); + // we have shrinked primary_tables, so we update position here + if (i > join->primary_tables) { + join->qep_tab[i].set_position(nullptr); + } + } + + join->query_expression()->clear_root_access_path(); + + // generate execution tree + join->m_root_access_path = nullptr; + join->create_access_paths(); + join->query_expression()->create_access_paths(thd); + if (join->query_expression()->force_create_iterators(thd)) goto err; + + thd->mem_root = saved_mem_root; + thd->want_privilege = saved_thd_want_privilege; + + if (thd->lex->is_explain()) { + // Treat the first tmp_table which obtained info from worker as + // primary_table, because explain format=json need `primary_tables >= 1` + join->primary_tables += 1; + join->tmp_tables -= 1; + + // explain format=[traditional/tree/json] need real dop, so we call + // gather->init here, explain format=analyze will call gather->init, do + // not need call here + if (!thd->lex->is_explain_analyze) { + gather->init(); + } + + // explain format=tree need generate worker plan first + if (thd->lex->explain_format->is_tree() && + !thd->lex->is_explain_analyze) { + JOIN *worker_join = make_pq_worker_plan(gather->m_workers[0]); + gather->m_workers[0]->thd_worker = worker_join->thd; + + /** make_pq_worker_plan will duplicate a new THD and set it as + * current_thd, so here should restore old THD + */ + thd->store_globals(); + } + } + + return PQ_exec_status::PARL_EXEC; + } + +err: + thd->mem_root = saved_mem_root; + if (gather) pq_free_gather(gather); + + join->fields = fields_old; + thd->want_privilege = saved_thd_want_privilege; + restore_leader_plan(join); + + my_error(ER_PARALLEL_FAIL_INIT, MYF(0)); + return PQ_exec_status::ABORT_EXEC; +} + +/** + * make a parallel query worker's pysics query plan + * + * @template_join : template query plan + */ +static JOIN *make_pq_worker_plan(PQ_worker_manager *mngr) { + JOIN *join = nullptr; + Gather_operator *gather = mngr->m_gather; + JOIN *template_join = gather->m_template_join; + handler *file = nullptr; + Query_result *mq_result = nullptr; + MQueue_handle *msg_handler = mngr->m_handle; + + // duplicate a query plan from template join, which is used in PQ workers + THD *new_thd = pq_new_thd(template_join->thd); + if (!new_thd) goto err; + new_thd->pq_leader = mngr->thd_leader; + new_thd->mem_root = new_thd->pq_mem_root; + + /* save worker's THD in leader's THD */ + mysql_mutex_lock(&mngr->thd_leader->pq_lock_worker); + if (mngr->thd_leader->killed) { + mysql_mutex_unlock(&mngr->thd_leader->pq_lock_worker); + goto err; + } + mngr->thd_leader->pq_workers.push_back(new_thd); + mysql_mutex_unlock(&mngr->thd_leader->pq_lock_worker); + + join = pq_make_join(new_thd, template_join); + if (!join || pq_dup_tabs(join, template_join, true) || + DBUG_EVALUATE_IF("pq_worker_abort1", true, false)) { + goto err; + } + + join->having_cond = join->query_block->having_cond(); + join->need_tmp_pq = true; + if (join->setup_tmp_table_info(template_join) || + join->make_tmp_tables_info() || + pq_make_join_readinfo(join, mngr, + join->saved_optimized_vars.pq_no_jbuf_after) || + DBUG_EVALUATE_IF("pq_worker_abort2", true, false)) { + sql_print_warning( + "[Parallel query] Create worker tmp tables or make join read info " + "failed"); + goto err; + } + + /** set query result */ + file = join->qep_tab[join->pq_tab_idx].table()->file; + mq_result = new (join->thd->pq_mem_root) + Query_result_mq(join, msg_handler, file, join->pq_stable_sort); + if (!mq_result || DBUG_EVALUATE_IF("pq_worker_error2", true, false)) { + sql_print_warning("[Parallel query] Create worker result mq failed"); + goto err; + } + + join->query_expression()->set_query_result(mq_result); + join->query_block->set_query_result(mq_result); + + return join; + +err: + if (new_thd) new_thd->store_globals(); + pq_free_join(join); + pq_free_thd(new_thd); + mngr->thd_leader->store_globals(); + return nullptr; +} + +/** + * main function of parallel worker. + * + */ +void *pq_worker_exec(void *arg) { + if (my_thread_init()) { + my_thread_exit(0); + return nullptr; + } + + Diagnostics_area *da; + const Sql_condition *cond; + /** only for single query block */ + Query_result *result = nullptr; + THD *thd = nullptr, *leader_thd = nullptr; + + PQ_worker_manager *mngr = static_cast(arg); + assert(mngr->m_gather); +#ifndef NDEBUG + pq_stack_copy(*mngr->m_gather->m_code_state); +#endif + leader_thd = mngr->thd_leader; + THD *temp_thd = mngr->m_gather->m_template_join->thd; + MQueue_handle *msg_handler = mngr->m_handle; + bool send_error_status = true; + + JOIN *join = make_pq_worker_plan(mngr); + if (!join || DBUG_EVALUATE_IF("pq_worker_error1", true, false)) { + sql_print_warning("[Parallel query] Make worker plan failed"); + goto err; + } + + thd = join->thd; + assert(current_thd == thd && thd->pq_leader == leader_thd); + mngr->signal_status(thd, PQ_worker_state::READY); + join->query_expression()->ExecuteIteratorQuery(thd); + + if (thd->lex->is_explain_analyze && mngr->m_id == 0) { + Query_expression *unit = leader_thd->lex->unit; + leader_thd->pq_explain += PrintQueryPlan( + 0, unit->root_access_path(), + unit->is_union() ? nullptr : unit->first_query_block()->join, + !unit->is_union()); + } + + if (join->thd->is_error() || join->thd->pq_error || + DBUG_EVALUATE_IF("pq_worker_error3", true, false)) { + goto err; + } + send_error_status = false; + +err: + + /* s1: send error msg to MQ */ + if (send_error_status) { + assert(msg_handler && leader_thd); + leader_thd->pq_error = true; + msg_handler->send_exception_msg(ERROR_MSG); + } + msg_handler->set_datched_status(MQ_HAVE_DETACHED); + /** during pq_make_join, join->thd may have been created */ + thd = (join && join->thd) ? join->thd : thd; + + /* s2: release resource */ + result = join ? join->query_block->query_result() : nullptr; + if (result) { + result->cleanup(thd); + destroy(result); + } + + if (join) { + join->join_free(); + } + + if (thd) { + thd->lex->unit->cleanup(thd, true); + } + + /* s3: collect error message */ + if (thd) { + mysql_mutex_t *stmt_lock = &mngr->m_gather->lock_stmt_da; + mysql_mutex_lock(stmt_lock); + temp_thd->pq_merge_status(thd); + da = thd->get_stmt_da(); + if (thd->is_error()) { + temp_thd->raise_condition(da->mysql_errno(), da->returned_sqlstate(), + Sql_condition::SL_ERROR, da->message_text(), + false); + } + if (da->cond_count() > 0) { + Diagnostics_area::Sql_condition_iterator it = da->sql_conditions(); + while ((cond = it++)) { + temp_thd->raise_condition(cond->mysql_errno(), NULL, cond->severity(), + cond->message_text(), false); + } + } + mysql_mutex_unlock(stmt_lock); + pq_free_thd(thd); + thd = NULL; + } + +#ifndef NDEBUG + pq_stack_reset(); +#endif + + /* Clean up openssl errors. */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L + ERR_remove_thread_state(0); +#endif + + my_thread_end(); + /* s4: send last status to leader */ + PQ_worker_state status = + send_error_status ? PQ_worker_state::ERROR : PQ_worker_state::COMPELET; + mngr->signal_status(thd, status); + my_thread_exit(0); + return nullptr; +} + +/** +Plan refinement stage: do various setup things for the executor, including + - setup join buffering use + - push index conditions + - increment relevant counters + - etc + +@return false if successful, true if error (Out of memory) +*/ +bool pq_make_join_readinfo(JOIN *join, PQ_worker_manager *mngr, + uint no_jbuf_after MY_ATTRIBUTE((unused))) { + const bool prep_for_pos = join->need_tmp_before_win || + join->select_distinct || join->grouped || + !join->order.empty() || join->m_windows.elements > 0; + + for (uint i = join->const_tables; i < join->primary_tables; i++) { + QEP_TAB *const qep_tab = &join->qep_tab[i]; + TABLE *const table = qep_tab->table(); + if (prep_for_pos || (qep_tab->do_parallel_scan && join->pq_stable_sort)) + table->prepare_for_position(); + } + std::vector predicates_below_join; + std::vector predicates_above_join; + join->m_root_access_path = nullptr; + Gather_operator *gather = mngr->m_gather; + + for (uint i = 0; i < join->tables; i++) { + QEP_TAB *qep_tab = &join->qep_tab[i]; + if (qep_tab->do_parallel_scan) { + qep_tab->table()->file->pq_table_scan = gather->table_scan; + qep_tab->gather = mngr->m_gather; + + /* index push down */ + uint keyno = gather->keyno; + if (!(keyno == qep_tab->table()->s->primary_key && + qep_tab->table()->file->primary_key_is_clustered()) && + qep_tab->pq_cond) { + TABLE *tbl = qep_tab->table(); + Item *cond = qep_tab->pq_cond; + Item *idx_cond = make_cond_for_index(cond, tbl, keyno, false); + if (idx_cond) { + Item *idx_remainder_cond = tbl->file->idx_cond_push(keyno, idx_cond); + if (idx_remainder_cond != idx_cond) + qep_tab->ref().disable_cache = true; + + Item *row_cond = make_cond_remainder(qep_tab->pq_cond, true); + if (row_cond) { + if (idx_remainder_cond) + and_conditions(&row_cond, idx_remainder_cond); + idx_remainder_cond = row_cond; + } + qep_tab->set_condition(idx_remainder_cond); + } + } + + /** optimize order by */ + if (join->pq_last_sort_idx == int(i) && i >= join->primary_tables) { + assert(qep_tab->filesort); + /** if there is limit on tmp table, we cannot remove sort */ + if (join->m_select_limit == HA_POS_ERROR) { + destroy(qep_tab->filesort); + qep_tab->filesort = nullptr; + } + + if (join->pq_rebuilt_group) { + assert(join->query_block->saved_group_list_ptrs); + assert(join->m_select_limit == HA_POS_ERROR); + restore_list(join->query_block->saved_group_list_ptrs, + join->query_block->group_list); + ORDER *order = restore_optimized_group_order( + join->query_block->group_list, + join->saved_optimized_vars.optimized_group_flags); + if (order) { + ORDER_with_src group_list = ORDER_with_src(order, ESC_GROUP_BY); + join->add_sorting_to_table(i, &group_list, false, true); + } + } + } + } + } + + /** generate execution tree */ + join->set_optimized(); + join->query_expression()->set_optimized(); + join->create_access_paths(); + join->query_expression()->create_access_paths(join->thd); + join->query_expression()->force_create_iterators(join->thd); + + return false; +} + +bool pq_check_stable_sort(JOIN *join, int idx) { + if ((join->pq_last_sort_idx >= 0 && join->pq_last_sort_idx != idx) || + join->need_tmp_before_win) { + return false; + } + return true; +} + +/* + * record the mapping: + * L = join->query_block->group_list -------> join->group_list = R + * + * @result: + * if L[i] \in R, then optimized_flags[i] = 0; otherwise, optimized_flags[i] + * = 1 (i.e., L[i] is optimized in JOIN::optimized()). Correspondingly, we can + * use L and optimized_flags to retrieve R. + * + */ +void record_optimized_group_order(PQ_Group_list_ptrs *ptr, + ORDER_with_src &new_list, + std::vector &optimized_flags) { + optimized_flags.clear(); + // group_list (or order) is optimized to NULL. + if (new_list.order == nullptr || ptr == nullptr) { + return; + } + + optimized_flags.resize(ptr->size(), true); + int i = 0; + auto iterator = ptr->begin(); + auto order = new_list.order; + + while (iterator != ptr->end() && order) { + // find this item, i.e., this item is not optimized + if ((*iterator)->item[0] && order->item[0] && + ((*iterator)->item[0]->eq(order->item[0], false))) { + optimized_flags[i] = false; + order = order->next; + } else { + optimized_flags[i] = true; + } + i++; + iterator++; + } +} + +/* + * restore the optimized group/order list, using original and optimized_flags + */ +ORDER *restore_optimized_group_order(SQL_I_List &orig_list, + std::vector &optimized_flags) { + int size = optimized_flags.size(); + if (0 == size) return nullptr; + + ORDER *header = orig_list.first; + ORDER **prev_ptr = &header; + ORDER *iterator; + + int idx = 0; + + for (iterator = orig_list.first; iterator; iterator = iterator->next) { + if (!optimized_flags[idx]) { + *prev_ptr = iterator; + prev_ptr = &iterator->next; + } + idx++; + } + *prev_ptr = 0; + + return header; +} + +void restore_list(PQ_Group_list_ptrs *ptr, SQL_I_List &orig_list) { + orig_list.clear(); + + ORDER *order = nullptr; + ORDER **iterator = ptr->begin(); + for (; iterator != ptr->end(); iterator++) { + order = *iterator; + orig_list.link_in_list(order, &order->next); + } +} + +void pq_free_thd(THD *thd) { + if (!thd) return; + close_thread_tables(thd); + thd->mdl_context.release_transactional_locks(); + trans_commit_stmt(thd); + end_connection(thd); + close_connection(thd, 0, false, false); + Diagnostics_area *da = thd->get_stmt_da(); + if (thd->is_error() && thd->pq_leader) { + thd->pq_leader->raise_condition(da->mysql_errno(), da->returned_sqlstate(), + Sql_condition::SL_ERROR, da->message_text(), + false); + } + thd->get_stmt_da()->reset_diagnostics_area(); + thd->release_resources(); + thd->free_items(); + destroy(thd); +} + +void pq_free_join(JOIN *join) { + if (!join) return; + join->join_free(); + join->destroy(); + destroy(join); +} + +/** + * fetch the used key + * @table: the first non-const table + * @key: the index of the key in table->key_info + * @key_parts: #fields in this key + * @res_fields: the set of all fields in this key + */ +static void get_key_fields(TABLE *table, int key, uint key_parts, + std::vector &key_fields) { + assert(table && table->key_info); + + KEY_PART_INFO *kp = table->key_info[key].key_part; + for (uint i = 0; i < key_parts; i++, kp++) { + key_fields.emplace_back(kp->field->field_name); + } +} + +/** + * fetch the key fields used in the tab + * @tab + * @res_fields + * + * @retval: + * false for success, and otherwise true + */ +bool get_table_key_fields(QEP_TAB *tab, std::vector &key_fields) { + key_fields.clear(); + assert(tab); + auto type = tab->old_type(); + + // the original table in leader_join's qep_tab + TABLE *table = tab->old_table(); + TABLE_REF *ref = &tab->old_ref(); + if (!table || !ref) return true; + + // consider the following cases to obtain the sort filed: + // (1) the case of explicitly using primary key + if (tab->old_ref().key_parts) { + get_key_fields(table, ref->key, ref->key_parts, key_fields); + } + // (2) the case of index scan + else if (type == JT_INDEX_SCAN) { + int key = tab->index(); + uint key_parts = table->key_info[key].user_defined_key_parts; + get_key_fields(table, key, key_parts, key_fields); + } + + // (3) the case of index range. + else if (type == JT_RANGE || (type == JT_REF && tab->old_quick_optim())) { + // Note: please confirm whether 'quick' belongs to old qep_tab; + QUICK_SELECT_I *quick = tab->old_quick_optim(); + if (!quick) return true; + + if (quick->index != MAX_KEY) + get_key_fields(table, quick->index, quick->used_key_parts, key_fields); + } + // (4) the case of implicitly using primary key + else { + if (table->s->primary_key != MAX_KEY) { + int key = table->s->primary_key; + int key_parts = table->key_info[key].user_defined_key_parts; + get_key_fields(table, key, key_parts, key_fields); + } + // (5) other cases + } + return false; +} + +bool set_key_order(QEP_TAB *tab, std::vector &key_fields, + ORDER **order_ptr, Ref_item_array *ref_ptrs) { + JOIN *join = tab->join(); + assert(join && join->order.empty()); + if (!key_fields.size()) { + *order_ptr = NULL; + return false; + } + + std::map fields_map; // map[field] = item + std::map::iterator iter; + std::vector order_items; + + Ref_item_array &ref_items = *ref_ptrs; + /** (1) build the map: {name} -> {item} */ + for (uint i = 0; i < join->query_block_fields->size(); i++) { + Item *item = ref_items[i]; + if (item && item->type() == Item::FIELD_ITEM) { + std::string field_name = + static_cast(item)->field->field_name; + fields_map[field_name] = &ref_items[i]; + } + } + + /** (2) find the item whose name in res_fields */ + for (std::string key : key_fields) { + iter = fields_map.find(key); + if (iter != fields_map.end()) { + order_items.push_back(iter->second); + } + } + + /** (3) generate sort order */ + THD *thd = join->thd; + SQL_I_List order_list; + + for (Item **item : order_items) { + ORDER *order = new (thd->pq_mem_root) ORDER(); + if (!order) { + *order_ptr = NULL; + return true; + } + + order->item_initial = *item; + order->item = item; + order->in_field_list = 1; + order->is_explicit = 0; + add_to_list(order_list, order); + } + + *order_ptr = order_list.first; + return false; +} + +uint get_pq_memory_total() { + uint sum_memory = 0; + for (int i = 0; i < PQ_MEMORY_USED_BUCKET; i++) + sum_memory += atomic_add(pq_memory_used[i], 0); + return sum_memory; +} + +void add_pq_memory(PSI_memory_key key, size_t length, + unsigned int id /*MY_ATTRIBUTE((unused))*/) { + if (key == key_memory_pq_mem_root) + atomic_add(pq_memory_used[id], length); +} + +void sub_pq_memory(PSI_memory_key key, size_t length, + unsigned int id /*MY_ATTRIBUTE((unused))*/) { + if (key == key_memory_pq_mem_root) + atomic_sub(pq_memory_used[id], length); +} diff --git a/sql/sql_parallel.h b/sql/sql_parallel.h new file mode 100644 index 000000000..e819f9564 --- /dev/null +++ b/sql/sql_parallel.h @@ -0,0 +1,207 @@ +#ifndef SQL_PARALLEL_H +#define SQL_PARALLEL_H + +/* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2022, Huawei Technologies Co., Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + 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, version 2.0, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "sql/basic_row_iterators.h" +#include "sql/msg_queue.h" +#include "sql/sql_base.h" +#include "sql/sql_lex.h" + +class QEP_TAB; +class Query_block; +class THD; +class Gather_operator; +class JOIN; +class ORDER_with_src; +class Exchange; +class Filesort; + +/** optimized variables */ +struct PQ_optimized_var { + bool pq_grouped; + bool pq_implicit_grouping; + bool pq_simple_group; + bool pq_simple_order; + bool pq_streaming_aggregation; + bool pq_group_optimized_away; + bool pq_need_tmp_before_win; + bool pq_skip_sort_order; + int pq_m_ordered_index_usage; + + /* + * optimized_*_flags record each element in select_lex->group_list (or + * order_list) is optimized or not. Specifically, optimized_group_flags[i] = 1 + * means that group_list[i] is optimized in JOIN::optimize(); otherwise, + * pq_group_optimized[i] = 0 and group_list[i] is remained in + * JOIN::group_list. + */ + std::vector optimized_group_flags; + std::vector optimized_order_flags; + uint pq_no_jbuf_after; // for read_set and index push down +}; + +enum PQ_exec_status { SEQ_EXEC = 0, PARL_EXEC, ABORT_EXEC }; + +enum PQ_worker_state { + INIT = 1, + READY = 2, + COMPELET = 4, + ERROR = 8, + OVER = 16 +}; + +class MQ_record_gather { + public: + THD *m_thd; + QEP_TAB *m_tab; + Exchange *m_exchange; + + public: + MQ_record_gather() : m_thd(nullptr), m_tab(nullptr), m_exchange(nullptr) {} + + MQ_record_gather(THD *thd, QEP_TAB *tab) + : m_thd(thd), m_tab(tab), m_exchange(nullptr) {} + + bool mq_scan_init(Filesort *sort, int workers, uint ref_length, + bool stab_output = false); + + bool mq_scan_next(); + + void mq_scan_end(); +}; + +/** + * Parallel scan worker's manager struct + */ +class PQ_worker_manager { + public: + uint m_id; // worker number + Gather_operator *m_gather; + THD *thd_leader; // pointer to leader thread + THD *thd_worker; // pointer to worker thread + MQueue_handle *m_handle; // worker's message queue handle + PQ_worker_state m_status; // worker status + my_thread_handle thread_id; // Thread id + bool m_active{false}; // true if this worker is created, and false otherwise. + + private: + mysql_mutex_t m_mutex; // mutex protect previous members + mysql_cond_t m_cond; + + public: + PQ_worker_manager() = delete; + + PQ_worker_manager(uint id); + + ~PQ_worker_manager(); + + bool wait_for_status(THD *thd, uint state); + + void signal_status(THD *thd, PQ_worker_state state); + + void kill(); +}; + +struct CODE_STATE; +/** + * Gather operator for parallel scan + */ +class Gather_operator { + public: + uint m_dop; // Degree of parallel execution; + // (if m_pq_ctx->m_ctxs.size() is less than exepected m_dop, + // m_dop will change to m_pq_ctx->m_ctxs.size() in init() + // function) + JOIN *m_template_join; // physical query plan template + PQ_worker_manager **m_workers; // parallel workers manager info + TABLE *m_table; // the table need parallel query + void *m_pq_ctx; // innodb Parallel query context + QEP_TAB *m_tab; // the rewrite qep_tab + uint keyno; // the index for paralleling read + int m_ha_err; + Diagnostics_area m_stmt_da; + mysql_mutex_t lock_stmt_da; + CODE_STATE **m_code_state; + bool table_scan; + + public: + Gather_operator() = delete; + + Gather_operator(uint dop); + + ~Gather_operator(); + + bool init(); + + void end(); + + void signalAll(); +}; + +Gather_operator *make_pq_gather_operator(JOIN *join, QEP_TAB *tab, uint dop); +PQ_exec_status make_pq_leader_plan(THD *thd); +void *pq_worker_exec(void *arg); +bool pq_build_sum_funcs(THD *thd, Query_block *select, Ref_item_array &ref_ptr, + mem_root_deque &fields, uint elements, + nesting_map select_nest_level); +void pq_replace_avg_func(THD *thd, Query_block *select, mem_root_deque *fields, + nesting_map select_nest_level); +extern bool get_table_key_fields(QEP_TAB *tab, + std::vector &res_fields); +extern bool setup_order(THD *thd, Ref_item_array ref_item_array, + TABLE_LIST *tables, List &fields, + List &all_fields, ORDER *order); +extern void release_pq_running_threads(uint dop); +extern void add_pq_memory(PSI_memory_key key, size_t length, unsigned int id); +extern void sub_pq_memory(PSI_memory_key key, size_t length, unsigned int id); +extern uint get_pq_memory_total(); +extern void add_to_list(SQL_I_List &list, ORDER *order); + +extern ulonglong parallel_memory_limit; +extern ulong parallel_max_threads; +extern uint pq_memory_used[16]; +extern uint pq_memory_total_used; +extern uint parallel_threads_running; + +extern mysql_mutex_t LOCK_pq_threads_running; +extern mysql_cond_t COND_pq_threads_running; + +bool pq_make_join_readinfo(JOIN *join, PQ_worker_manager *mngr, + uint no_jbuf_after); + +bool pq_check_stable_sort(JOIN *join, int idx); + +bool set_key_order(QEP_TAB *tab, std::vector &res_fields, + ORDER **order_ptr, Ref_item_array *ref_ptrs); + +void restore_list(PQ_Group_list_ptrs *ptr, SQL_I_List &orig_list); + +void pq_free_thd(THD *thd); + +void pq_free_join(JOIN *join); + +void pq_free_gather(Gather_operator *gather); + +#endif /* SQL_PARALLEL_H */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 52f7f1643..43c85fa26 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,4 +1,5 @@ /* Copyright (c) 1999, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -173,6 +174,7 @@ #include "sql/thd_raii.h" #include "sql/transaction.h" // trans_rollback_implicit #include "sql/transaction_info.h" +#include "sql/pq_condition.h" #include "sql_string.h" #include "template_utils.h" #include "thr_lock.h" @@ -2739,6 +2741,8 @@ int mysql_execute_command(THD *thd, bool first_level) { thd->work_part_info = nullptr; + set_pq_condition_status(thd); + if (thd->optimizer_switch_flag(OPTIMIZER_SWITCH_SUBQUERY_TO_DERIVED)) lex->add_statement_options(OPTION_NO_CONST_TABLES); @@ -4411,6 +4415,8 @@ int mysql_execute_command(THD *thd, bool first_level) { res = lex->m_sql_cmd->execute(thd); + thd = current_thd; + break; } case SQLCOM_ALTER_USER: { @@ -4855,6 +4861,9 @@ void THD::reset_for_next_command() { a grant/revoke or flush. */ thd->security_context()->checkout_access_maps(); + + thd->parallel_exec = false; + #ifndef NDEBUG thd->set_tmp_table_seq_id(1); #endif @@ -4998,6 +5007,7 @@ void dispatch_sql_command(THD *thd, Parser_state *parser_state) { thd, &src_res_grp, &dest_res_grp, &ticket, &cur_ticket); error = mysql_execute_command(thd, true); + thd = current_thd; if (switched) mgr_ptr->restore_original_resource_group(thd, src_res_grp, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1d4f5983d..f6d005ef9 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2002, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -403,6 +404,9 @@ class Statement_backup { m_query_string = thd->query(); thd->set_query(stmt->m_query_string); + if (thd->lex != nullptr) { + thd->lex->in_execute_ps = true; + } m_safe_to_display = thd->safe_to_display(); @@ -429,6 +433,7 @@ class Statement_backup { stmt->m_query_string = thd->query(); thd->set_query(m_query_string); + thd->lex->in_execute_ps = false; return; } diff --git a/sql/sql_resolver.cc b/sql/sql_resolver.cc index 0c116ca63..0ff87166a 100644 --- a/sql/sql_resolver.cc +++ b/sql/sql_resolver.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -181,6 +182,8 @@ bool Query_block::prepare(THD *thd, mem_root_deque *insert_field_list) { Query_expression *const unit = master_query_expression(); + if (has_windows()) saved_windows_elements = m_windows.elements; + if (!top_join_list.empty()) propagate_nullability(&top_join_list, false); /* @@ -580,6 +583,15 @@ bool Query_block::prepare(THD *thd, mem_root_deque *insert_field_list) { if (olap == ROLLUP_TYPE && resolve_rollup_wfs(thd)) return true; /* purecov: inspected */ + if (thd->m_suite_for_pq == PqConditionStatus::ENABLED) { + if (group_list.elements > 0) + fix_prepare_information_for_order(thd, &group_list, + &saved_group_list_ptrs); + if (order_list.elements > 0) + fix_prepare_information_for_order(thd, &order_list, + &saved_order_list_ptrs); + } + assert(!thd->is_error()); return false; } @@ -4244,9 +4256,15 @@ bool find_order_in_list(THD *thd, Ref_item_array ref_item_array, order->is_position = true; return false; } - /* Lookup the current GROUP/ORDER field in the SELECT clause. */ - select_item = find_item_in_list(thd, order_item, fields, &counter, + + if (thd->parallel_exec && !order->in_field_list) { + select_item = not_found_item; + } else { + /* Lookup the current GROUP/ORDER field in the SELECT clause. */ + select_item = find_item_in_list(thd, order_item, fields, &counter, REPORT_EXCEPT_NOT_FOUND, &resolution); + } + if (!select_item) return true; /* The item is not unique, or some other error occurred. */ @@ -4272,7 +4290,7 @@ bool find_order_in_list(THD *thd, Ref_item_array ref_item_array, order_item_type == Item::FIELD_ITEM) || order_item_type == Item::REF_ITEM) { from_field = find_field_in_tables(thd, (Item_ident *)order_item, tables, - nullptr, &view_ref, IGNORE_ERRORS, true, + nullptr, &view_ref, IGNORE_ERRORS, !thd->pq_leader, // view_ref is a local variable, so // don't record a change to roll back: false); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0d5929ff9..c4110b07c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -118,11 +119,12 @@ #include "sql_string.h" #include "template_utils.h" #include "thr_lock.h" +#include "sql/sql_parallel.h" using std::max; using std::min; -static store_key *get_store_key(THD *thd, Item *val, table_map used_tables, +store_key *get_store_key(THD *thd, Item *val, table_map used_tables, table_map const_tables, const KEY_PART_INFO *key_part, uchar *key_buff, uint maybe_null); @@ -760,6 +762,8 @@ static bool optimize_secondary_engine(THD *thd) { secondary_engine->optimize_secondary_engine(thd, thd->lex); } +void thd_set_thread_stack(THD *thd, const char *stack_start); + /** Execute a DML statement. This is the default implementation for a DML statement and uses a @@ -783,6 +787,19 @@ bool Sql_cmd_dml::execute_inner(THD *thd) { // Perform secondary engine optimizations, if needed. if (optimize_secondary_engine(thd)) return true; + if (thd->m_suite_for_pq == PqConditionStatus::ENABLED) + { + PQ_exec_status status = make_pq_leader_plan(thd); + if (status == PQ_exec_status::ABORT_EXEC) { + return true; + } + + assert(status == PQ_exec_status::SEQ_EXEC || + status == PQ_exec_status::PARL_EXEC); + + DEBUG_SYNC(thd, "after_pq_leader_plan"); + } + // We know by now that execution will complete (successful or with error) lex->set_exec_completed(); if (lex->is_explain()) { @@ -1186,6 +1203,7 @@ SJ_TMP_TABLE *create_sj_tmp_table(THD *thd, JOIN *join, if (!(sjtbl = new (thd->mem_root) SJ_TMP_TABLE)) return nullptr; /* purecov: inspected */ sjtbl->tmp_table = nullptr; + sjtbl->tabs = nullptr; sjtbl->is_confluent = true; sjtbl->have_confluent_row = false; } @@ -1705,16 +1723,33 @@ void JOIN::destroy() { if (qep_tab) { assert(!join_tab); - for (uint i = 0; i < tables; i++) { - TABLE *table = qep_tab[i].table(); + uint tables_num = tables >= old_tables ? tables : old_tables; + for (uint i = 0; i < tables_num; i++) { + QEP_TAB *qtab = &qep_tab[i]; + if (qtab->gather && !thd->running_explain_analyze && !thd->is_worker()) { + qtab->gather->end(); + qtab->gather = nullptr; + } + + TABLE *table = qep_tab0[i].table(); + TABLE *old_table = qep_tab0[i].old_table(); + if (table != nullptr) { - // These were owned by the root iterator, which we just destroyed. - // Keep filesort_free_buffers() from trying to call CleanupAfterQuery() - // on them. table->sorting_iterator = nullptr; table->duplicate_removal_iterator = nullptr; } - qep_tab[i].cleanup(); + + if (old_table != nullptr) { + old_table->sorting_iterator = nullptr; + old_table->duplicate_removal_iterator = nullptr; + } + + /* only clean iterator, filesort, op (etc.) info. */ + if (qep_tab1 != nullptr) { + qep_tab1[i].cleanup(false); + } + + qep_tab0[i].cleanup(true); } } else { // Same, for hypergraph queries. @@ -1751,15 +1786,27 @@ void JOIN::destroy() { // Run Cached_item DTORs! group_fields.destroy_elements(); - tmp_table_param.cleanup(); + tmp_table_param->cleanup(); /* Cleanup items referencing temporary table columns */ - if (tmp_fields != nullptr) { - cleanup_item_list(tmp_fields[REF_SLICE_TMP1]); - cleanup_item_list(tmp_fields[REF_SLICE_TMP2]); + if (tmp_fields1 != nullptr) { + cleanup_item_list(tmp_fields1[REF_SLICE_TMP1]); + cleanup_item_list(tmp_fields1[REF_SLICE_TMP2]); + cleanup_item_list(tmp_fields1[REF_SLICE_PQ_TMP]); + for (uint widx = 0; widx < m_windows.elements; widx++) { + cleanup_item_list(tmp_fields1[REF_SLICE_WIN_1 + widx]); + cleanup_item_list(tmp_fields1[REF_SLICE_WIN_1 + widx + + m_windows.elements]); // frame buffer + } + } + + if (tmp_fields0 != nullptr) { + cleanup_item_list(tmp_fields0[REF_SLICE_TMP1]); + cleanup_item_list(tmp_fields0[REF_SLICE_TMP2]); + cleanup_item_list(tmp_fields0[REF_SLICE_PQ_TMP]); for (uint widx = 0; widx < m_windows.elements; widx++) { - cleanup_item_list(tmp_fields[REF_SLICE_WIN_1 + widx]); - cleanup_item_list(tmp_fields[REF_SLICE_WIN_1 + widx + + cleanup_item_list(tmp_fields0[REF_SLICE_WIN_1 + widx]); + cleanup_item_list(tmp_fields0[REF_SLICE_WIN_1 + widx + m_windows.elements]); // frame buffer } } @@ -1778,7 +1825,7 @@ void JOIN::destroy() { while ((sjm = sjm_list_it++)) ::destroy(sjm); sjm_exec_list.clear(); - keyuse_array.clear(); + keyuse_array->clear(); // Free memory for rollup arrays if (query_block->olap == ROLLUP_TYPE) { rollup_group_items.clear(); @@ -2404,7 +2451,7 @@ class store_key_json_item final : public store_key_item { } // namespace -static store_key *get_store_key(THD *thd, Item *val, table_map used_tables, +store_key *get_store_key(THD *thd, Item *val, table_map used_tables, table_map const_tables, const KEY_PART_INFO *key_part, uchar *key_buff, uint maybe_null) { @@ -2631,7 +2678,7 @@ bool and_conditions(Item **e1, Item *e2) { Index condition, or NULL if no condition could be inferred. */ -static Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, +Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, bool other_tbls_ok) { assert(cond != nullptr); @@ -2698,7 +2745,7 @@ static Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, return cond; } -static Item *make_cond_remainder(Item *cond, bool exclude_index) { +Item *make_cond_remainder(Item *cond, bool exclude_index) { if (exclude_index && cond->marker == Item::MARKER_ICP_COND_USES_INDEX_ONLY) return nullptr; /* Already checked */ @@ -2829,6 +2876,12 @@ void QEP_TAB::push_index_cond(const JOIN_TAB *join_tab, uint keyno, !has_guarded_conds() && type() != JT_CONST && type() != JT_SYSTEM && !(keyno == tbl->s->primary_key && tbl->file->primary_key_is_clustered())) { + if (do_parallel_scan) { + has_pq_cond = true; + pq_cond = condition()->pq_clone(join_->thd, join_->query_block); + if (pq_cond == nullptr) { return; } + } + DBUG_EXECUTE("where", print_where(join_->thd, condition(), "full cond", QT_ORDINARY);); Item *idx_cond = @@ -3385,13 +3438,18 @@ void JOIN_TAB::cleanup() { qs_cleanup(); } -void QEP_TAB::cleanup() { +/** + As qep_tab0 and qep_tab1 share the same table info, we only free these tables once + and the free procedure is finished in qep_tab0. +*/ +void QEP_TAB::cleanup(bool is_free) { // Delete parts specific of QEP_TAB: destroy(filesort); filesort = nullptr; if (quick_optim() != quick()) delete quick_optim(); TABLE *const t = table(); + TABLE *const old_t = old_table(); if (t != nullptr) { t->reginfo.qep_tab = nullptr; @@ -3399,21 +3457,36 @@ void QEP_TAB::cleanup() { } // Delete shared parts: - qs_cleanup(); + if (is_free) { qs_cleanup(); } // Order of qs_cleanup() and this, matters: - if (op_type == QEP_TAB::OT_MATERIALIZE || - op_type == QEP_TAB::OT_AGGREGATE_THEN_MATERIALIZE || - op_type == QEP_TAB::OT_AGGREGATE_INTO_TMP_TABLE || - op_type == QEP_TAB::OT_WINDOWING_FUNCTION) { - if (t != nullptr) // Check tmp table is not yet freed. - { - close_tmp_table(t); - free_tmp_table(t); + if (is_free) { + if (op_type == QEP_TAB::OT_MATERIALIZE || + op_type == QEP_TAB::OT_AGGREGATE_THEN_MATERIALIZE || + op_type == QEP_TAB::OT_AGGREGATE_INTO_TMP_TABLE || + op_type == QEP_TAB::OT_WINDOWING_FUNCTION) { + // free only tmp table + if (old_t != nullptr) { + close_tmp_table(old_t); + free_tmp_table(old_t); + } + + // Check tmp table is not yet freed. + if (t != nullptr) { + close_tmp_table(t); + free_tmp_table(t); + } + + destroy(tmp_table_param); + tmp_table_param = nullptr; + } else { + if (t != nullptr && old_t != nullptr && t->s->table_category == TABLE_CATEGORY_TEMPORARY) { + close_tmp_table(t); + free_tmp_table(t); + } } - destroy(tmp_table_param); - tmp_table_param = nullptr; } + if (table_ref != nullptr && table_ref->uses_materialization()) { assert(t == table_ref->table); t->merge_keys.clear_all(); @@ -3439,6 +3512,20 @@ void QEP_shared_owner::qs_cleanup() { table_ref->derived_key_list.clear(); } } + + if (old_table() && + (old_table()->s->tmp_table != INTERNAL_TMP_TABLE || old_table()->is_created())) { + old_table()->set_keyread(false); + old_table()->file->ha_index_or_rnd_end(); + free_io_cache(old_table()); + filesort_free_buffers(old_table(), true); + TABLE_LIST *const table_ref = old_table()->pos_in_table_list; + if (table_ref) { + table_ref->derived_keys_ready = false; + table_ref->derived_key_list.clear(); + } + } + delete quick(); } @@ -3599,6 +3686,9 @@ void JOIN::cleanup() { assert(!join_tab); qtab = &qep_tab[i]; table = qtab->table(); + if (qtab->gather && !thd->running_explain_analyze && !thd->is_worker()) { + qtab->gather->m_table->file->ha_index_or_rnd_end(); + } } else { qtab = nullptr; table = (join_tab ? &join_tab[i] : best_ref[i])->table(); @@ -3619,6 +3709,105 @@ void JOIN::cleanup() { set_ref_item_slice(REF_SLICE_SAVED_BASE); } +bool JOIN::make_pq_tables_info() { + + DBUG_ENTER("JOIN::make_pq_tables_info"); + TABLE *table = nullptr; + mem_root_deque table_item_list(thd->mem_root); + Query_result_mq *query_result = nullptr; + + mem_root_deque *curr_fields = fields; + + const bool may_trace = // just to avoid an empty trace block + need_tmp_before_win || implicit_grouping || m_windowing_steps || + grouped || !order.empty(); + + Opt_trace_context *const trace = &thd->opt_trace; + Opt_trace_disable_I_S trace_disabled(trace, !may_trace); + Opt_trace_object wrapper(trace); + Opt_trace_array trace_tmp(trace, "making tmp table for MQ"); + + query_result = down_cast(query_expression()->query_result()); + assert(query_result && query_result->m_param); + + Temp_table_param *tmp_param = query_result->m_param; + tmp_param->pq_copy(saved_tmp_table_param); + tmp_param->hidden_field_count = CountHiddenFields(*curr_fields); + tmp_param->m_window_frame_buffer = true; + tmp_param->skip_create_table = true; + + /* + set saved_sum_func= true, then temp table will create a Item_field for sum funcs + in tmplist, which we call it sum_field that use for recieving PQ workers's sum data. + */ + table = create_tmp_table(thd, tmp_param, *curr_fields, nullptr, false, true, + query_block->active_options(), HA_POS_ERROR, "", true, true); + query_result->m_table = table; + + // the leader/worker's table is not same + if (!table || !thd->pq_leader + || table->s->fields != thd->pq_leader->pq_check_fields + || table->s->reclength != thd->pq_leader->pq_check_reclen + || DBUG_EVALUATE_IF("pq_worker_error5", true, false)) { + goto ERR; + } + + // we should remove const_item that doesn't generate result_field in table->field + for (Item *tmp_item : *curr_fields) { + // check const_item + if (tmp_item->skip_create_tmp_table) { + assert(tmp_item->const_item()); + continue; + } + + // check Item_copy. + /* + if (tmp_item->type() == Item::COPY_STR_ITEM) { + Item *orig_item = down_cast(tmp_item)->get_item(); + assert(orig_item); + if (orig_item->skip_create_tmp_table) { + assert(orig_item->const_item()); + continue; + } + } */ + + // check an item that refers to a summary function. + if (tmp_item->has_aggregation() && tmp_item->type() != Item::SUM_FUNC_ITEM) { + if (tmp_item->type() == Item::SUBSELECT_ITEM || + (tmp_item->used_tables() & ~OUTER_REF_TABLE_BIT)) { + continue; + } + } + + table_item_list.push_back(tmp_item); + } + + if (table_item_list.size() != table->s->fields + || alloc_ref_item_slice(thd, REF_SLICE_PQ_TMP)) { + goto ERR; + } + + /* + table_item_list consists of items needed to send to MQ, + and we store this list into REF_SLICE_PQ_TMP position. + */ + tmp_fields[REF_SLICE_PQ_TMP] = table_item_list; + DBUG_RETURN(false); + +ERR: + if (!thd->pq_error) { + // here, occurs an error + MQueue_handle *handle = query_result->get_mq_handler(); + if (handle != nullptr) { + handle->send_exception_msg(ERROR_MSG); + handle->set_datched_status(MQ_HAVE_DETACHED); + } + thd->pq_error = true; + } + + DBUG_RETURN(true); +} + /** Filter out ORDER BY items that are equal to constants in WHERE condition @@ -3941,9 +4130,9 @@ void calc_group_buffer(JOIN *join, ORDER *group) { parts++; if (group_item->is_nullable()) null_parts++; } - join->tmp_table_param.group_length = key_length + null_parts; - join->tmp_table_param.group_parts = parts; - join->tmp_table_param.group_null_parts = null_parts; + join->tmp_table_param->group_length = key_length + null_parts; + join->tmp_table_param->group_parts = parts; + join->tmp_table_param->group_null_parts = null_parts; } /** @@ -3960,7 +4149,7 @@ bool JOIN::alloc_func_list() { uint func_count, group_parts; DBUG_TRACE; - func_count = tmp_table_param.sum_func_count; + func_count = tmp_table_param->sum_func_count; /* If we are using rollup, we need a copy of the summary functions for each level @@ -4146,6 +4335,540 @@ bool JOIN::add_having_as_tmp_table_cond(uint curr_tmp_table) { return false; } +bool JOIN::make_leader_tables_info() { + mem_root_deque *curr_fields = fields; + bool materialize_join = false; + uint curr_tmp_table = primary_tables; + TABLE *exec_tmp_table = nullptr; + + const bool may_trace = // just to avoid an empty trace block + need_tmp_before_win || implicit_grouping || m_windowing_steps || + !group_list.empty() || !order.empty(); + + Opt_trace_context *const trace = &thd->opt_trace; + Opt_trace_disable_I_S trace_disabled(trace, !may_trace); + Opt_trace_object wrapper(trace); + Opt_trace_array trace_tmp(trace, "considering_tmp_tables"); + + DBUG_ENTER("JOIN::make_leader_tables_info"); + + const bool has_group_by = this->grouped; + tmp_table_param->cleanup(); + tmp_table_param->pq_copy(saved_tmp_table_param); + tmp_table_param->copy_fields.clear(); + + if (alloc_ref_item_slice(thd, REF_SLICE_SAVED_BASE)) { DBUG_RETURN(true); } + copy_ref_item_slice(REF_SLICE_SAVED_BASE, REF_SLICE_ACTIVE); + current_ref_item_slice = REF_SLICE_SAVED_BASE; + + Opt_trace_object trace_this_tbl(trace); + trace_this_tbl.add("adding_tmp_table_in_plan_at_position", curr_tmp_table) + .add_alnum("cause", "output_for_parallel_query"); + QEP_TAB *tab = &qep_tab[curr_tmp_table]; + + pq_replace_avg_func(thd, query_block, curr_fields, + (nesting_map)1 << (unsigned int)query_block->nest_level); + + Temp_table_param *tmp_param = + new (thd->mem_root) Temp_table_param(*tmp_table_param); + if (tmp_param == nullptr) { DBUG_RETURN(true); } + tmp_param->m_window_frame_buffer = true; + tmp_param->hidden_field_count = CountHiddenFields(*curr_fields); + tmp_param->skip_create_table = true; + + mem_root_deque tmplist(*curr_fields); + + /* + create_tmp_table may change the original item's result_field, hence + we must save it before. + */ + std::vector saved_result_field (tmplist.size(), nullptr); + uint i = 0; + + for (Item *tmp_item : *curr_fields) { + if (tmp_item->type() == Item::FIELD_ITEM || tmp_item->type() == Item::DEFAULT_VALUE_ITEM) { + saved_result_field[i] = down_cast(tmp_item)->result_field; + } else { + saved_result_field[i] = tmp_item->get_result_field(); + } + i++; + } + + std::vector saved_join_fields (fields->size(), nullptr); + i = 0; + for (Item *tmp_item : *fields) { + if (tmp_item->type() == Item::FIELD_ITEM || tmp_item->type() == Item::DEFAULT_VALUE_ITEM) { + saved_join_fields[i] = down_cast(tmp_item)->field; + } + i++; + } + + /* + set saved_sum_func= true, then temp table will create a Item_field for sum funcs + in tmplist, which we call it sum_field that use for recieving PQ workers's sum data + */ + TABLE *table = + create_tmp_table(thd, tmp_param, tmplist, nullptr, false, true, + query_block->active_options(), HA_POS_ERROR, "", true, true); + if (table == nullptr) { DBUG_RETURN(true); } + table->materialized= false; + tmp_tables = 1; + + // check the rewritten table + thd->pq_check_fields = table->s->fields; + thd->pq_check_reclen = table->s->reclength; + + tab->set_table(table); + tab->tmp_table_param = tmp_param; + + // restore result_field->name + i = 0; + for (Item *tmp_item : *curr_fields) { + if (tmp_item->type() == Item::FIELD_ITEM || tmp_item->type() == Item::DEFAULT_VALUE_ITEM) { + // create_tmp_table may change the original item's result_field, + // restore field_name to pass the main.metadata test. + (down_cast(tmp_item)->result_field)->field_name = saved_result_field[i]->field_name; + if (tmp_item->const_item()) { + uint32 length = (down_cast(tmp_item)->base_item_field())->field->data_length(); + memmove((down_cast(tmp_item)->result_field)->ptr, + (down_cast(tmp_item)->base_item_field())->field->ptr, + length); + } + } + i++; + } + + /* + Allocate a slice of ref items that describe the items to be copied + from the second temporary table. + */ + if (alloc_ref_item_slice(thd, REF_SLICE_PQ_TMP)) DBUG_RETURN(true); + + // No sum funcs anymore + if (change_to_use_tmp_fields( + curr_fields, thd, + ref_items[REF_SLICE_PQ_TMP], + &tmp_fields[REF_SLICE_PQ_TMP], + query_block->m_added_non_hidden_fields)) { + DBUG_RETURN(true); + } + + /* + * create sum() base on tmp table's sum_field which is sum of worker send. + */ + if (pq_build_sum_funcs(thd, query_block, ref_items[REF_SLICE_PQ_TMP], + tmp_fields[REF_SLICE_PQ_TMP], CountVisibleFields(tmp_fields[REF_SLICE_PQ_TMP]), + (nesting_map)1 << (unsigned int) query_block->nest_level)) { + DBUG_RETURN(true); + } + curr_fields = &tmp_fields[REF_SLICE_PQ_TMP]; + set_ref_item_slice(REF_SLICE_PQ_TMP); + + if (qep_tab != nullptr) { + qep_tab[curr_tmp_table].ref_item_slice = REF_SLICE_PQ_TMP; + } + + /* save based slice of parallel query */ + copy_ref_item_slice(REF_SLICE_SAVED_BASE, REF_SLICE_ACTIVE); + current_ref_item_slice = REF_SLICE_SAVED_BASE; + + /* re-generate group_list based on group_list and curr_all_fields */ + if (!group_list.empty()) { + group_fields_cache.clear(); + group_fields.destroy_elements(); + } + + if (!group_list.empty() || tmp_table_param->sum_func_count) { + if (make_sum_func_list(*curr_fields, true, true)) { + DBUG_RETURN(true); + } + } + + /* + Create the first temporary table if distinct elimination is requested or + if the sort is too complicated to be evaluated as a filesort. + */ + if (need_tmp_before_win) { + curr_tmp_table++; + tmp_tables++; + /* + Create temporary table for use in a single execution. + (Will be reused if this is a subquery that is executed several times + for one execution of the statement) + Don't use tmp table grouping for json aggregate funcs as it's + very ineffective. + */ + ORDER_with_src tmp_group; + if (!simple_group && !(test_flags & TEST_NO_KEY_GROUP) && !with_json_agg) + tmp_group = group_list; + + tmp_table_param->hidden_field_count = CountHiddenFields(*curr_fields); + + QEP_TAB *win_tab = &qep_tab[curr_tmp_table]; + win_tab->set_old_table(win_tab->table()); + if (create_intermediate_table(&qep_tab[curr_tmp_table], *curr_fields, + tmp_group, !group_list.empty() && simple_group)) + DBUG_RETURN(true); + exec_tmp_table = qep_tab[curr_tmp_table].table(); + + if (exec_tmp_table->s->is_distinct) optimize_distinct(); + + /* + Allocate a slice of ref items that describe the items to be copied + from the first temporary table. + */ + if (alloc_ref_item_slice(thd, REF_SLICE_TMP1)) DBUG_RETURN(true); + + // Change sum_fields reference to calculated fields in tmp_table + if (streaming_aggregation || qep_tab[curr_tmp_table].table()->group || + tmp_table_param->precomputed_group_by) { + if (change_to_use_tmp_fields(curr_fields, thd, + ref_items[REF_SLICE_TMP1], + &tmp_fields[REF_SLICE_TMP1], + query_block->m_added_non_hidden_fields)) + DBUG_RETURN(true); + } else { + if (change_to_use_tmp_fields_except_sums(curr_fields, thd, query_block, + ref_items[REF_SLICE_TMP1], + &tmp_fields[REF_SLICE_TMP1], + query_block->m_added_non_hidden_fields)) + DBUG_RETURN(true); + } + + curr_fields = &tmp_fields[REF_SLICE_TMP1]; + // Need to set them now for correct group_fields setup, reset at the end. + set_ref_item_slice(REF_SLICE_TMP1); + qep_tab[curr_tmp_table].ref_item_slice = REF_SLICE_TMP1; + setup_tmptable_write_func(&qep_tab[curr_tmp_table], &trace_this_tbl); + //last_slice_before_windowing = REF_SLICE_TMP1; + + /* + If having is not handled here, it will be checked before the row is sent + to the client. + */ + if (having_cond && (streaming_aggregation || + (exec_tmp_table->s->is_distinct && group_list.empty()))) { + /* + If there is no select distinct or rollup, then move the having to table + conds of tmp table. + NOTE : We cannot apply having after distinct. If columns of having are + not part of select distinct, then distinct may remove rows + which can satisfy having. + + As this condition will read the tmp table, it is appropriate that + REF_SLICE_TMP1 is in effect when we create it below. + */ + if ((!select_distinct && rollup_state == RollupState::NONE) && + add_having_as_tmp_table_cond(curr_tmp_table)) + DBUG_RETURN(true); + + /* + Having condition which we are not able to add as tmp table conds are + kept as before. And, this will be applied before storing the rows in + tmp table. + */ + qep_tab[curr_tmp_table].having = having_cond; + having_cond = NULL; // Already done + } + + tmp_table_param->func_count = 0; + + if (streaming_aggregation || qep_tab[curr_tmp_table].table()->group) { + tmp_table_param->field_count += tmp_table_param->sum_func_count; + tmp_table_param->sum_func_count = 0; + } + /** check if group by has to respect ordering. If true, move group by + to order by */ + if (exec_tmp_table->group) { // Already grouped + if (order.empty() && !skip_sort_order) { + for (ORDER *group = group_list.order; group; group = group->next) { + if (group->direction != ORDER_NOT_RELEVANT) { + order = group_list; /* order by group */ + break; + } + } + } + group_list.clean(); + } + /* + If we have different sort & group then we must sort the data by group + and copy it to a second temporary table. + This code is also used if we are using distinct something + we haven't been able to store in the temporary table yet + like SEC_TO_TIME(SUM(...)) or when distinct is used with rollup. + */ +// ============== not yet test ================== + if ((!group_list.empty() && + (!test_if_subpart(group_list.order, order.order) || select_distinct || + m_windowing_steps || rollup_state != RollupState::NONE)) || + (select_distinct && (tmp_table_param->using_outer_summary_function || + rollup_state != RollupState::NONE))) { + DBUG_PRINT("info", ("Creating group table")); + + calc_group_buffer(this, group_list.order); + count_field_types(query_block, tmp_table_param, + tmp_fields[REF_SLICE_TMP1], + select_distinct && group_list.empty(), false); + tmp_table_param->hidden_field_count = + CountHiddenFields(tmp_fields[REF_SLICE_TMP1]); + streaming_aggregation = false; + if (!exec_tmp_table->group && !exec_tmp_table->s->is_distinct) { + // 1st tmp table were materializing join result + materialize_join = true; + explain_flags.set(ESC_BUFFER_RESULT, ESP_USING_TMPTABLE); + } + curr_tmp_table++; + tmp_tables++; + trace_this_tbl.add("adding_tmp_table_in_plan_at_position", curr_tmp_table) + .add_alnum("cause", "sorting_to_make_groups"); + + /* group data to new table */ + /* + If the access method is loose index scan then all MIN/MAX + functions are precomputed, and should be treated as regular + functions. See extended comment above. + */ + if (qep_tab[0].quick() && qep_tab[0].quick()->is_loose_index_scan()) + tmp_table_param->precomputed_group_by = true; + + ORDER_with_src dummy; + + if (create_intermediate_table(&qep_tab[curr_tmp_table], *curr_fields, + dummy, true)) + DBUG_RETURN(true); + + if (!group_list.empty()) { + explain_flags.set(group_list.src, ESP_USING_TMPTABLE); + if (!plan_is_const()) // No need to sort a single row + { + if (add_sorting_to_table(curr_tmp_table - 1, &group_list, false, true)) + DBUG_RETURN(true); + pq_last_sort_idx= curr_tmp_table - 1; + pq_rebuilt_group= true; + } + + if (make_group_fields(this, this)) DBUG_RETURN(true); + } + + // Setup sum funcs only when necessary, otherwise we might break info + // for the first table + if (!group_list.empty() || tmp_table_param->sum_func_count) { + if (make_sum_func_list(*curr_fields, true, true)) return true; + const bool need_distinct = + !(qep_tab[0].quick() && + qep_tab[0].quick()->is_agg_loose_index_scan()); + if (prepare_sum_aggregators(sum_funcs, need_distinct)) + DBUG_RETURN(true); + group_list.clean(); + if (setup_sum_funcs(thd, sum_funcs)) DBUG_RETURN(true); + } + + /* + Allocate a slice of ref items that describe the items to be copied + from the second temporary table. + */ + if (alloc_ref_item_slice(thd, REF_SLICE_TMP2)) DBUG_RETURN(true); + + // No sum funcs anymore + if (change_to_use_tmp_fields( + &tmp_fields[REF_SLICE_TMP1], thd, + ref_items[REF_SLICE_TMP2], + &tmp_fields[REF_SLICE_TMP2], + query_block->m_added_non_hidden_fields)) + DBUG_RETURN(true); + + curr_fields = &tmp_fields[REF_SLICE_TMP2]; + set_ref_item_slice(REF_SLICE_TMP2); + qep_tab[curr_tmp_table].ref_item_slice = REF_SLICE_TMP2; + setup_tmptable_write_func(&qep_tab[curr_tmp_table], &trace_this_tbl); + //last_slice_before_windowing = REF_SLICE_TMP2; + } + if (qep_tab[curr_tmp_table].table()->s->is_distinct) + select_distinct = false; /* Each row is unique */ + + if (select_distinct && group_list.empty() && !m_windowing_steps) { + if (having_cond) { + qep_tab[curr_tmp_table].having = having_cond; + having_cond->update_used_tables(); + having_cond = NULL; + } + qep_tab[curr_tmp_table].needs_duplicate_removal = true; + trace_this_tbl.add("reading_from_table_eliminates_duplicates", true); + explain_flags.set(ESC_DISTINCT, ESP_DUPS_REMOVAL); + select_distinct = false; + } + /* Clean tmp_table_param for the next tmp table. */ + tmp_table_param->field_count = tmp_table_param->sum_func_count = + tmp_table_param->func_count = 0; + + tmp_table_param->cleanup(); + streaming_aggregation = false; + + if (!group_optimized_away) { + grouped = false; + } else { + /* + If grouping has been optimized away, a temporary table is + normally not needed unless we're explicitly requested to create + one (e.g. due to a SQL_BUFFER_RESULT hint or INSERT ... SELECT or + there is a windowing function that needs sorting). + + In this case (grouping was optimized away), temp_table was + created without a grouping expression and JOIN::exec() will not + perform the necessary grouping (by the use of end_send_group() + or end_write_group()) if JOIN::group is set to false. + */ + /* + The temporary table was explicitly requested or there is a window + function which needs sorting (check need_tmp_before_win in + JOIN::optimize). + */ + assert(query_block->active_options() & OPTION_BUFFER_RESULT || + m_windowing_steps); + // the temporary table does not have a grouping expression + assert(!qep_tab[curr_tmp_table].table()->group); + } + calc_group_buffer(this, group_list.order); + count_field_types(query_block, tmp_table_param, *curr_fields, false, + false); + } +// ====================================== + /* + Set up structures for a temporary table but do not actually create + the temporary table if one of these conditions are true: + - The query is implicitly grouped. + - The query is explicitly grouped and + + implemented as a simple grouping, or + + LIMIT 1 is specified, or + + ROLLUP is specified, or + + . + */ + + if ((grouped || implicit_grouping) && !m_windowing_steps) { + if (make_group_fields(this, this)) return true; + + if (make_sum_func_list(*curr_fields, true, true)) return true; + + const bool need_distinct = !(qep_tab && qep_tab[0].quick() && + qep_tab[0].quick()->is_agg_loose_index_scan()); + if (prepare_sum_aggregators(sum_funcs, need_distinct)) DBUG_RETURN(true); + if (setup_sum_funcs(thd, sum_funcs) || thd->is_fatal_error()) return true; + } + + if (qep_tab && (!group_list.empty() || (!order.empty() && !m_windowing_steps /* [1] */))) { + /* + [1] above: too early to do query ORDER BY if we have windowing; must + wait till after window processing. + */ + /* call from pq_tmp_table_info, join->join_tab/join->best_ref is null */ + // ASSERT_BEST_REF_IN_JOIN_ORDER(this); + DBUG_PRINT("info", ("Sorting for send_result_set_metadata")); + /* + If we have already done the group, add HAVING to sorted table except + when rollup is present + */ + if (having_cond && group_list.empty() && !streaming_aggregation && + rollup_state == RollupState::NONE) { + if (add_having_as_tmp_table_cond(curr_tmp_table)) DBUG_RETURN(true); + } + + if (grouped) + m_select_limit = HA_POS_ERROR; + else if (!need_tmp_before_win) { + /* + We can abort sorting after thd->select_limit rows if there are no + filter conditions for any tables after the sorted one. + Filter conditions come in several forms: + 1. as a condition item attached to the join_tab, or + 2. as a keyuse attached to the join_tab (ref access). + */ + for (i = const_tables + 1; i < primary_tables; i++) { + QEP_TAB *const local_tab = qep_tab + i; + if (local_tab->condition() || // 1 + (best_ref[tab->idx()]->keyuse() && + local_tab->first_inner() == NO_PLAN_IDX)) // 2 + { + /* We have to sort all rows */ + m_select_limit = HA_POS_ERROR; + break; + } + } + } + /* + Here we add sorting stage for ORDER BY/GROUP BY clause, if the + optimiser chose FILESORT to be faster than INDEX SCAN or there is + no suitable index present. + OPTION_FOUND_ROWS supersedes LIMIT and is taken into account. + */ + DBUG_PRINT("info", ("Sorting for order by/group by")); + ORDER_with_src order_arg = group_list.empty() ? order : group_list; + if (qep_tab && + m_ordered_index_usage != + (group_list.empty() ? ORDERED_INDEX_ORDER_BY : ORDERED_INDEX_GROUP_BY) && + // Windowing will change order, so it's too early to sort here + !m_windowing_steps) { + // Sort either first non-const table or the last tmp table + QEP_TAB *const sort_tab = &qep_tab[curr_tmp_table]; + if (need_tmp_before_win && !materialize_join && !exec_tmp_table->group) + explain_flags.set(order_arg.src, ESP_USING_TMPTABLE); + + if (add_sorting_to_table(curr_tmp_table, &order_arg, pq_stable_sort, false)) + return true; + /* + filesort_limit: Return only this many rows from filesort(). + We can use select_limit_cnt only if we have no group_by and 1 table. + This allows us to use Bounded_queue for queries like: + "select * from t1 order by b desc limit 1;" + m_select_limit == HA_POS_ERROR (we need a full table scan) + query_expression()->select_limit_cnt == 1 (we only need one row in the result set) + */ + + pq_last_sort_idx = curr_tmp_table; + if (sort_tab->filesort) { + sort_tab->filesort->limit = + (has_group_by || (primary_tables > curr_tmp_table + 1) || + calc_found_rows) + ? m_select_limit + : query_expression()->select_limit_cnt; + } + } + } + fields = curr_fields; + i = 0; + for (Item *tmp_item : *fields) { + if ((tmp_item->type() == Item::FIELD_ITEM || tmp_item->type() == Item::DEFAULT_VALUE_ITEM) && + saved_join_fields[i] && saved_join_fields[i]->orig_table_name) { + (down_cast(tmp_item))->field->orig_table_name = saved_join_fields[i]->orig_table_name; + } + i++; + } + + // Reset before execution + set_ref_item_slice(REF_SLICE_SAVED_BASE); + if (qep_tab) { + qep_tab[primary_tables + tmp_tables].op_type = + get_end_select_func(); + } + grouped = has_group_by; + + unplug_join_tabs(); + + /* + Tmp tables are a layer between the nested loop and the derived table's + result, WITH RECURSIVE cannot work with them. This should not happen, as a + recursive query cannot have clauses which use a tmp table (GROUP BY, + etc). + */ + assert(!query_block->is_recursive() || !tmp_tables); + DBUG_RETURN(false); + + if (table != NULL) { + free_tmp_table(table); + tab->set_table(NULL); + } + DBUG_RETURN(true); +} + /** Init tmp tables usage info. @@ -4225,7 +4948,7 @@ bool JOIN::make_tmp_tables_info() { */ if (qep_tab && qep_tab[0].quick() && qep_tab[0].quick()->is_loose_index_scan()) - tmp_table_param.precomputed_group_by = + tmp_table_param->precomputed_group_by = !qep_tab[0].quick()->is_agg_loose_index_scan(); uint last_slice_before_windowing = REF_SLICE_ACTIVE; @@ -4264,7 +4987,7 @@ bool JOIN::make_tmp_tables_info() { if (!simple_group && !(test_flags & TEST_NO_KEY_GROUP) && !with_json_agg) tmp_group = group_list; - tmp_table_param.hidden_field_count = CountHiddenFields(*fields); + tmp_table_param->hidden_field_count = CountHiddenFields(*fields); if (create_intermediate_table(&qep_tab[curr_tmp_table], *fields, tmp_group, !group_list.empty() && simple_group)) @@ -4280,6 +5003,7 @@ bool JOIN::make_tmp_tables_info() { sorted access even if final result is not to be sorted. */ assert( + thd->parallel_exec || !(m_ordered_index_usage == ORDERED_INDEX_VOID && !plan_is_const() && qep_tab[const_tables].position()->sj_strategy != SJ_OPT_LOOSE_SCAN && qep_tab[const_tables].use_order())); @@ -4292,7 +5016,7 @@ bool JOIN::make_tmp_tables_info() { // Change sum_fields reference to calculated fields in tmp_table if (streaming_aggregation || qep_tab[curr_tmp_table].table()->group || - tmp_table_param.precomputed_group_by) { + tmp_table_param->precomputed_group_by) { if (change_to_use_tmp_fields(fields, thd, ref_items[REF_SLICE_TMP1], &tmp_fields[REF_SLICE_TMP1], query_block->m_added_non_hidden_fields)) @@ -4310,6 +5034,7 @@ bool JOIN::make_tmp_tables_info() { qep_tab[curr_tmp_table].ref_item_slice = REF_SLICE_TMP1; setup_tmptable_write_func(&qep_tab[curr_tmp_table], &trace_this_outer); last_slice_before_windowing = REF_SLICE_TMP1; + last_slice_before_pq = REF_SLICE_TMP1; /* If having is not handled here, it will be checked before the row is sent @@ -4341,11 +5066,11 @@ bool JOIN::make_tmp_tables_info() { having_cond = nullptr; // Already done } - tmp_table_param.func_count = 0; + tmp_table_param->func_count = 0; if (streaming_aggregation || qep_tab[curr_tmp_table].table()->group) { - tmp_table_param.field_count += tmp_table_param.sum_func_count; - tmp_table_param.sum_func_count = 0; + tmp_table_param->field_count += tmp_table_param->sum_func_count; + tmp_table_param->sum_func_count = 0; } if (exec_tmp_table->group) { // Already grouped @@ -4374,15 +5099,15 @@ bool JOIN::make_tmp_tables_info() { if ((!group_list.empty() && (!test_if_subpart(group_list.order, order.order) || select_distinct || m_windowing_steps || rollup_state != RollupState::NONE)) || - (select_distinct && (tmp_table_param.using_outer_summary_function || + (select_distinct && (tmp_table_param->using_outer_summary_function || rollup_state != RollupState::NONE))) { DBUG_PRINT("info", ("Creating group table")); calc_group_buffer(this, group_list.order); - count_field_types(query_block, &tmp_table_param, + count_field_types(query_block, tmp_table_param, tmp_fields[REF_SLICE_TMP1], select_distinct && group_list.empty(), false); - tmp_table_param.hidden_field_count = + tmp_table_param->hidden_field_count = CountHiddenFields(tmp_fields[REF_SLICE_TMP1]); streaming_aggregation = false; if (!exec_tmp_table->group && !exec_tmp_table->s->is_distinct) { @@ -4403,7 +5128,7 @@ bool JOIN::make_tmp_tables_info() { functions. See extended comment above. */ if (qep_tab[0].quick() && qep_tab[0].quick()->is_loose_index_scan()) - tmp_table_param.precomputed_group_by = true; + tmp_table_param->precomputed_group_by = true; ORDER_with_src dummy; // TODO can use table->group here also @@ -4426,7 +5151,7 @@ bool JOIN::make_tmp_tables_info() { // Setup sum funcs only when necessary, otherwise we might break info // for the first table - if (!group_list.empty() || tmp_table_param.sum_func_count) { + if (!group_list.empty() || tmp_table_param->sum_func_count) { if (make_sum_func_list(*curr_fields, true, true)) return true; const bool need_distinct = !(qep_tab[0].quick() && @@ -4454,6 +5179,7 @@ bool JOIN::make_tmp_tables_info() { qep_tab[curr_tmp_table].ref_item_slice = REF_SLICE_TMP2; setup_tmptable_write_func(&qep_tab[curr_tmp_table], &trace_this_tbl); last_slice_before_windowing = REF_SLICE_TMP2; + last_slice_before_pq = REF_SLICE_TMP2; } if (qep_tab[curr_tmp_table].table()->s->is_distinct) select_distinct = false; /* Each row is unique */ @@ -4470,10 +5196,10 @@ bool JOIN::make_tmp_tables_info() { select_distinct = false; } /* Clean tmp_table_param for the next tmp table. */ - tmp_table_param.field_count = tmp_table_param.sum_func_count = - tmp_table_param.func_count = 0; + tmp_table_param->field_count = tmp_table_param->sum_func_count = + tmp_table_param->func_count = 0; - tmp_table_param.cleanup(); + tmp_table_param->cleanup(); streaming_aggregation = false; if (!group_optimized_away) { @@ -4501,7 +5227,7 @@ bool JOIN::make_tmp_tables_info() { assert(!qep_tab[curr_tmp_table].table()->group); } calc_group_buffer(this, group_list.order); - count_field_types(query_block, &tmp_table_param, *curr_fields, false, + count_field_types(query_block, tmp_table_param, *curr_fields, false, false); } @@ -4556,7 +5282,7 @@ bool JOIN::make_tmp_tables_info() { for (uint i = const_tables + 1; i < primary_tables; i++) { QEP_TAB *const tab = qep_tab + i; if (tab->condition() || // 1 - (best_ref[tab->idx()]->keyuse() && + (best_ref != nullptr && best_ref[tab->idx()]->keyuse() && tab->first_inner() == NO_PLAN_IDX)) // 2 { /* We have to sort all rows */ @@ -4585,7 +5311,7 @@ bool JOIN::make_tmp_tables_info() { explain_flags.set(order_arg.src, ESP_USING_TMPTABLE); if (add_sorting_to_table(curr_tmp_table, &order_arg, - /*force_stable_sort=*/false, + /*force_stable_sort=*/pq_stable_sort, /*sort_before_group=*/false)) return true; /* @@ -4597,18 +5323,18 @@ bool JOIN::make_tmp_tables_info() { query_expression->select_limit_cnt == 1 (we only need one row in the result set) */ - if (sort_tab->filesort) - sort_tab->filesort->limit = - (has_group_by || (primary_tables > curr_tmp_table + 1) || - calc_found_rows) - ? m_select_limit - : query_expression()->select_limit_cnt; + pq_last_sort_idx = curr_tmp_table; + sort_tab->filesort->limit = + (has_group_by || (primary_tables > curr_tmp_table + 1) || + calc_found_rows) + ? m_select_limit + : query_expression()->select_limit_cnt; } } if (qep_tab && m_windowing_steps) { for (uint wno = 0; wno < m_windows.elements; wno++) { - tmp_table_param.m_window = m_windows[wno]; + tmp_table_param->m_window = m_windows[wno]; if (!tmp_tables) { curr_tmp_table = primary_tables; @@ -4635,12 +5361,12 @@ bool JOIN::make_tmp_tables_info() { ORDER_with_src dummy; if (last_slice_before_windowing == REF_SLICE_ACTIVE) { - tmp_table_param.hidden_field_count = CountHiddenFields(*fields); + tmp_table_param->hidden_field_count = CountHiddenFields(*fields); } else { assert(tmp_tables >= 1 && last_slice_before_windowing > REF_SLICE_ACTIVE); - tmp_table_param.hidden_field_count = + tmp_table_param->hidden_field_count = CountHiddenFields(tmp_fields[last_slice_before_windowing]); } @@ -4663,7 +5389,7 @@ bool JOIN::make_tmp_tables_info() { buffering. */ Temp_table_param *par = - new (thd->mem_root) Temp_table_param(tmp_table_param); + new (thd->mem_root) Temp_table_param(*tmp_table_param); par->m_window_frame_buffer = true; TABLE *table = create_tmp_table(thd, par, *curr_fields, nullptr, false, false, @@ -4804,6 +5530,11 @@ bool JOIN::make_tmp_tables_info() { } void JOIN::unplug_join_tabs() { + //clone JOIN info from pq_tmp_tables_info, best_bef = NULL + if (tables !=0 && !(best_ref && !join_tab)) { + return; + } + ASSERT_BEST_REF_IN_JOIN_ORDER(this); /* diff --git a/sql/sql_select.h b/sql/sql_select.h index 9c4f4aed7..24bb5d29e 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2,6 +2,7 @@ #define SQL_SELECT_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -205,6 +206,18 @@ class Key_use { fanout(0.0), read_cost(0.0) {} + Key_use *pq_clone(THD *thd) { + Key_use *new_key_use = new (thd->pq_mem_root) Key_use( + nullptr, nullptr, used_tables, key, keypart, optimize, keypart_map, + ref_table_rows, null_rejecting, cond_guard, sj_pred_no); + if (new_key_use != nullptr) { + new_key_use->bound_keyparts = bound_keyparts; + new_key_use->fanout = fanout; + new_key_use->read_cost = read_cost; + } + return new_key_use; + } + TABLE_LIST *table_ref; ///< table owning the index /** @@ -566,6 +579,8 @@ struct POSITION { } prefix_rowcount *= filter_effect; } + + bool pq_copy(THD *thd, POSITION *orig); }; /** @@ -990,4 +1005,8 @@ SJ_TMP_TABLE *create_sj_tmp_table(THD *thd, JOIN *join, */ uint actual_key_flags(const KEY *key_info); +store_key *get_store_key(THD *thd, Item *val, table_map used_tables, + table_map const_tables, const KEY_PART_INFO *key_part, + uchar *key_buff, uint maybe_null); + #endif /* SQL_SELECT_INCLUDED */ diff --git a/sql/sql_tmp_table.cc b/sql/sql_tmp_table.cc index adcfe0f8c..1bd259f7d 100644 --- a/sql/sql_tmp_table.cc +++ b/sql/sql_tmp_table.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2011, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -86,6 +87,7 @@ #include "sql/thr_malloc.h" #include "sql/window.h" #include "template_utils.h" +#include "sql/temp_table_param.h" using std::max; using std::min; @@ -175,8 +177,9 @@ static bool alloc_record_buffers(THD *thd, TABLE *table); Field *create_tmp_field_from_field(THD *thd, const Field *org_field, const char *name, TABLE *table, - Item_field *item) { - Field *new_field = org_field->new_field(thd->mem_root, table); + Item_field *item, MEM_ROOT *root) { + MEM_ROOT *pq_check_root = root ? root : thd->mem_root; + Field *new_field = org_field->new_field(pq_check_root, table); if (new_field == nullptr) return nullptr; new_field->init(table); @@ -216,13 +219,14 @@ Field *create_tmp_field_from_field(THD *thd, const Field *org_field, new_created field */ -static Field *create_tmp_field_from_item(Item *item, TABLE *table) { +static Field *create_tmp_field_from_item(Item *item, TABLE *table, MEM_ROOT *root) { bool maybe_null = item->is_nullable(); Field *new_field = nullptr; + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; switch (item->result_type()) { case REAL_RESULT: - new_field = new (*THR_MALLOC) + new_field = new (pq_check_root) Field_double(item->max_length, maybe_null, item->item_name.ptr(), item->decimals, false, true); break; @@ -234,11 +238,11 @@ static Field *create_tmp_field_from_item(Item *item, TABLE *table) { Field_long : make them Field_longlong. */ if (item->max_length >= (MY_INT32_NUM_DECIMAL_DIGITS - 1)) - new_field = new (*THR_MALLOC) + new_field = new (pq_check_root) Field_longlong(item->max_length, maybe_null, item->item_name.ptr(), item->unsigned_flag); else - new_field = new (*THR_MALLOC) + new_field = new (pq_check_root) Field_long(item->max_length, maybe_null, item->item_name.ptr(), item->unsigned_flag); break; @@ -251,14 +255,18 @@ static Field *create_tmp_field_from_item(Item *item, TABLE *table) { */ if (item->is_temporal() || item->data_type() == MYSQL_TYPE_GEOMETRY || item->data_type() == MYSQL_TYPE_JSON) { - new_field = item->tmp_table_field_from_field_type(table, true); + new_field = item->tmp_table_field_from_field_type(table, true, root); } else { - new_field = item->make_string_field(table); + new_field = item->make_string_field(table, root); + } + + if (new_field != nullptr) { + new_field->set_derivation(item->collation.derivation); } - new_field->set_derivation(item->collation.derivation); + break; case DECIMAL_RESULT: - new_field = Field_new_decimal::create_from_item(item); + new_field = Field_new_decimal::create_from_item(item, root); break; case ROW_RESULT: default: @@ -288,15 +296,16 @@ static Field *create_tmp_field_from_item(Item *item, TABLE *table) { new_created field */ -static Field *create_tmp_field_for_schema(const Item *item, TABLE *table) { +Field *create_tmp_field_for_schema(Item *item, TABLE *table, MEM_ROOT *root) { + MEM_ROOT *pq_check_root = root ? root : *THR_MALLOC; if (item->data_type() == MYSQL_TYPE_VARCHAR) { Field *field; if (item->max_length > MAX_FIELD_VARCHARLENGTH) - field = new (*THR_MALLOC) + field = new (pq_check_root) Field_blob(item->max_length, item->is_nullable(), item->item_name.ptr(), item->collation.collation, false); else { - field = new (*THR_MALLOC) Field_varstring( + field = new (pq_check_root) Field_varstring( item->max_length, item->is_nullable(), item->item_name.ptr(), table->s, item->collation.collation); table->s->db_create_options |= HA_OPTION_PACK_RECORD; @@ -304,7 +313,7 @@ static Field *create_tmp_field_for_schema(const Item *item, TABLE *table) { if (field) field->init(table); return field; } - return item->tmp_table_field_from_field_type(table, false); + return item->tmp_table_field_from_field_type(table, false, root); } /** @@ -350,7 +359,7 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, Func_ptr_array *copy_func, Field **from_field, Field **default_field, bool group, bool modify_item, bool table_cant_handle_bit_fields, bool make_copy_field, - bool copy_result_field) { + bool copy_result_field, MEM_ROOT *root) { DBUG_TRACE; Field *result = nullptr; Item::Type orig_type = type; @@ -378,10 +387,10 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, if (item_field->is_nullable() && !(item_field->field->is_nullable() || item_field->field->table->is_nullable())) { - result = create_tmp_field_from_item(item_field, table); + result = create_tmp_field_from_item(item_field, table, root); } else if (table_cant_handle_bit_fields && item_field->field->type() == MYSQL_TYPE_BIT) { - result = create_tmp_field_from_item(item_field, table); + result = create_tmp_field_from_item(item_field, table, root); /* If the item is a function, a pointer to the item is stored in copy_func. We separate fields from functions by checking if the @@ -395,7 +404,7 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, : item_field->item_name.ptr(), table, (modify_item && orig_type != Item::REF_ITEM) ? item_field - : nullptr); + : nullptr, root); } if (result == nullptr) return nullptr; if (modify_item) { @@ -430,7 +439,7 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, result = create_tmp_field_from_field(thd, sp_result_field, item_func_sp->item_name.ptr(), - table, nullptr); + table, nullptr, root); if (!result) break; if (modify_item) item_func_sp->set_result_field(result); break; @@ -456,7 +465,7 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, case Item::SUM_FUNC_ITEM: if (type == Item::SUM_FUNC_ITEM && !is_wf) { Item_sum *item_sum = down_cast(item); - result = item_sum->create_tmp_field(group, table); + result = item_sum->create_tmp_field(group, table, root); if (!result) my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR)); } else { /* @@ -482,7 +491,7 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, assert(*from_field); } - result = create_tmp_field_from_item(item, table); + result = create_tmp_field_from_item(item, table, root); if (result == nullptr) return nullptr; if (modify_item) item->set_result_field(result); if (copy_func && !make_copy_field && item->is_result_field()) @@ -493,12 +502,17 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, case Item::TYPE_HOLDER: case Item::VALUES_COLUMN_ITEM: result = down_cast(item)->make_field_by_type( - table, thd->is_strict_mode()); + table, thd->is_strict_mode(), root); break; default: // Doesn't have to be stored assert(false); break; } + + if (result != nullptr && thd->parallel_exec) { + result->extra_length = item->pq_extra_len(group); + } + return result; } @@ -828,6 +842,27 @@ inline void relocate_field(Field *field, uchar *pos, uchar *null_flags, field->reset(); } +void Temp_table_param::pq_copy(Temp_table_param *orig) +{ + end_write_records = orig->end_write_records; + field_count = orig->field_count; + func_count = orig->func_count; + sum_func_count = orig->sum_func_count; + hidden_field_count = orig->hidden_field_count; + group_parts = orig->group_parts; + group_length = orig->group_length; + group_null_parts = orig->group_null_parts; + outer_sum_func_count = orig->outer_sum_func_count; + using_outer_summary_function = orig->using_outer_summary_function; + schema_table = orig->schema_table; + precomputed_group_by = orig->precomputed_group_by; + force_copy_fields = orig->force_copy_fields; + skip_create_table = orig->skip_create_table; + bit_fields_as_long = orig->bit_fields_as_long; + can_use_pk_for_unique = orig->can_use_pk_for_unique; + m_window_short_circuit = orig->m_window_short_circuit; +} + /** Create a temp table according to a field list. @@ -869,7 +904,8 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, const mem_root_deque &fields, ORDER *group, bool distinct, bool save_sum_fields, ulonglong select_options, ha_rows rows_limit, - const char *table_alias) { + const char *table_alias, bool force_disk_table, + bool parallel_query) { DBUG_TRACE; if (!param->allow_group_via_temp_table) group = nullptr; // Can't use group key @@ -1030,8 +1066,18 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, if (param->m_window == nullptr || !param->m_window->is_last()) store_column = false; } - if (item->const_item() && hidden_field_count <= 0) - continue; // We don't have to store this + + if (item->const_item()) { + if ((int)hidden_field_count <= 0) { + // mark this item and then we can identify it without sending a message to MQ. + item->skip_create_tmp_table = true; + continue; // We don't have to store this + } + if (parallel_query) { + item->skip_create_tmp_table = true; + goto HIDDEN; + } + } } if (store_column && is_sum_func && !group && @@ -1046,6 +1092,12 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, &from_field[fieldnr], &default_field[fieldnr], group != nullptr, not_all_columns, false, false, false); if (new_field == nullptr) return nullptr; // Should be OOM + if (thd->parallel_exec) { + new_field->item_sum_ref = sum_item; + new_field->extra_length = sum_item->sum_func() == Item_sum::AVG_FUNC + ? sizeof(longlong) + : 0; + } new_field->set_field_index(fieldnr); reg_field[fieldnr++] = new_field; share->reclength += new_field->pack_length(); @@ -1123,8 +1175,16 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, But only for the group-by table. So do not set result_field if this is a tmp table for UNION or derived table materialization. */ - if (not_all_columns && type == Item::SUM_FUNC_ITEM) + if (not_all_columns && type == Item::SUM_FUNC_ITEM) { + new_field->item_sum_ref = ((Item_sum *) item); down_cast(item)->set_result_field(new_field); + } + if (item->type() == Item::FIELD_AVG_ITEM) { + Item_avg_field *item_avg_field= static_cast(item->real_item()); + Item_sum_avg *item_avg= item_avg_field->avg_item; + new_field->item_sum_ref= item_avg; + } + share->reclength += new_field->pack_length(); if (!new_field->is_flag_set(NOT_NULL_FLAG)) null_count++; if (new_field->type() == MYSQL_TYPE_BIT) @@ -1168,6 +1228,7 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, } } +HIDDEN: hidden_field_count--; if (hidden_field_count == 0) { /* @@ -1365,7 +1426,7 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, table->hash_field = field; } - if (setup_tmp_table_handler(thd, table, select_options, false, + if (setup_tmp_table_handler(thd, table, select_options, force_disk_table, param->schema_table)) return nullptr; /* purecov: inspected */ diff --git a/sql/sql_tmp_table.h b/sql/sql_tmp_table.h index 217723ccd..16338aa00 100644 --- a/sql/sql_tmp_table.h +++ b/sql/sql_tmp_table.h @@ -2,6 +2,7 @@ #define SQL_TMP_TABLE_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -55,7 +56,8 @@ TABLE *create_tmp_table(THD *thd, Temp_table_param *param, const mem_root_deque &fields, ORDER *group, bool distinct, bool save_sum_fields, ulonglong select_options, ha_rows rows_limit, - const char *table_alias); + const char *table_alias, bool force_disk_table = false, + bool parallel_query = false); bool open_tmp_table(TABLE *table); TABLE *create_tmp_table_from_fields(THD *thd, List &field_list, bool is_virtual = true, @@ -75,10 +77,17 @@ Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, Func_ptr_array *copy_func, Field **from_field, Field **default_field, bool group, bool modify_item, bool table_cant_handle_bit_fields, bool make_copy_field, - bool copy_result_field = false); + bool copy_result_field = false, MEM_ROOT *root = nullptr); Field *create_tmp_field_from_field(THD *thd, const Field *org_field, const char *name, TABLE *table, - Item_field *item); + Item_field *item, MEM_ROOT *root = nullptr); + +Field *create_tmp_field_from_item(Item *item, TABLE *table, + Func_ptr_array *copy_func, bool modify_item, + MEM_ROOT *root = nullptr); + +Field *create_tmp_field_for_schema(Item *item, TABLE *table, + MEM_ROOT *root = nullptr); /** Get the minimum of max_key_length and max_key_part_length between diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 76977f95a..1827a44bc 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2001, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -845,7 +846,7 @@ Query_expression::setup_materialization(THD *thd, TABLE *dst_table, assert(join && join->is_optimized()); assert(join->root_access_path() != nullptr); ConvertItemsToCopy(*join->fields, dst_table->visible_field_ptr(), - &join->tmp_table_param); + join->tmp_table_param); query_block.subquery_path = join->root_access_path(); assert(query_block.subquery_path != nullptr); @@ -854,7 +855,7 @@ Query_expression::setup_materialization(THD *thd, TABLE *dst_table, query_block.disable_deduplication_by_hash_field = (mixed_union_operators() && !activate_deduplication); query_block.copy_fields_and_items = true; - query_block.temp_table_param = &join->tmp_table_param; + query_block.temp_table_param = join->tmp_table_param; query_block.is_recursive_reference = select->recursive_reference; query_blocks.push_back(move(query_block)); @@ -962,10 +963,10 @@ void Query_expression::create_access_paths(THD *thd) { JOIN *join = select->join; assert(join && join->is_optimized()); ConvertItemsToCopy(*join->fields, tmp_table->visible_field_ptr(), - &join->tmp_table_param); + join->tmp_table_param); AppendPathParameters param; param.path = NewStreamingAccessPath(thd, join->root_access_path(), join, - &join->tmp_table_param, tmp_table, + join->tmp_table_param, tmp_table, /*ref_slice=*/-1); param.join = join; CopyCosts(*join->root_access_path(), param.path); @@ -1209,6 +1210,11 @@ bool Query_expression::ExecuteIteratorQuery(THD *thd) { { auto join_cleanup = create_scope_guard([this, thd] { + /** for parallel scan, we should end the pq iterator */ + if (thd->parallel_exec && thd->pq_iterator) { + thd->pq_iterator->End(); + } + for (Query_block *sl = first_query_block(); sl; sl = sl->next_query_block()) { JOIN *join = sl->join; @@ -1224,30 +1230,61 @@ bool Query_expression::ExecuteIteratorQuery(THD *thd) { return true; } + uint read_records_num = 0; + MQueue_handle *handler = query_result->get_mq_handler(); + if (handler) { + handler->set_datched_status(MQ_NOT_DETACHED); + } + PFSBatchMode pfs_batch_mode(m_root_iterator.get()); + bool execute_error = false; for (;;) { int error = m_root_iterator->Read(); DBUG_EXECUTE_IF("bug13822652_1", thd->killed = THD::KILL_QUERY;); - if (error > 0 || thd->is_error()) // Fatal error - return true; + if (error > 0 || thd->is_error() || thd->is_pq_error()) // Fatal error + execute_error = true; else if (error < 0) break; else if (thd->killed) // Aborted by user { thd->send_kill_message(); - return true; + execute_error = true; } + if (execute_error) break; ++*send_records_ptr; + read_records_num++; if (query_result->send_data(thd, *fields)) { - return true; + execute_error = true; + break; } thd->get_stmt_da()->inc_current_row_for_condition(); } + // if there is error, then for worker it should send an error msg to MQ and + // detach the MQ. Note that, only worker can detach the MQ. + if ((execute_error || !read_records_num || + DBUG_EVALUATE_IF("pq_worker_error4", true, false)) && + thd->is_worker()) { + MQ_DETACHED_STATUS status = MQ_NOT_DETACHED; + // there is an error during the execution + if (execute_error || DBUG_EVALUATE_IF("pq_worker_error4", true, false)) { + thd->pq_error = true; + if (handler != nullptr) { + handler->send_exception_msg(ERROR_MSG); + } + status = MQ_HAVE_DETACHED; + } else if (!read_records_num) { + status = MQ_TMP_DETACHED; + } + if (handler) handler->set_datched_status(status); + } + + if (execute_error) return true; + // NOTE: join_cleanup must be done before we send EOF, so that we get the // row counts right. } diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 3b8473bd1..6f83dfd03 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2009, 2021, Oracle and/or its affiliates. + Copyright (c) 2021, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -136,6 +137,8 @@ #include "sql/xa.h" #include "template_utils.h" // pointer_cast #include "thr_lock.h" +#include "sql/sql_parallel.h" + #ifdef _WIN32 #include "sql/named_pipe.h" #endif @@ -880,6 +883,54 @@ static Sys_var_bool Sys_windowing_use_high_precision( HINT_UPDATEABLE SESSION_VAR(windowing_use_high_precision), CMD_LINE(OPT_ARG), DEFAULT(true)); +#ifndef NDEBUG +extern bool dbug_pq_worker_stall; + +static Sys_var_bool Sys_Debug_pq_worker_stall( + "debug_pq_worker_stall", + "PQ worker stall while send date to message queue.", + HINT_UPDATEABLE GLOBAL_VAR(dbug_pq_worker_stall), CMD_LINE(OPT_ARG), + DEFAULT(false)); +#endif + +static Sys_var_bool Sys_sql_force_parallel_execute( + "force_parallel_execute", "force parallel execute in session", + HINT_UPDATEABLE SESSION_VAR(force_parallel_execute), CMD_LINE(OPT_ARG), + DEFAULT(0)); + +static Sys_var_ulonglong Sys_parallel_memory_limit( + "parallel_memory_limit", + "upper limit memory size that parallel query can use", + GLOBAL_VAR(parallel_memory_limit), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, ULONG_MAX), DEFAULT(100 * 1024 * 1024), BLOCK_SIZE(IO_SIZE), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(NULL)); + +static Sys_var_ulong Sys_parallel_max_threads( + "parallel_max_threads", "max running threads of parallel query.", + GLOBAL_VAR(parallel_max_threads), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, ULONG_MAX), DEFAULT(64), BLOCK_SIZE(1), NO_MUTEX_GUARD, + NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(NULL)); + +static Sys_var_ulong Sys_parallel_cost_threshold( + "parallel_cost_threshold", "Cost threshold for parallel query.", + SESSION_VAR(parallel_cost_threshold), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, ULONG_MAX), DEFAULT(1000), BLOCK_SIZE(1), NO_MUTEX_GUARD, + NOT_IN_BINLOG); + +static Sys_var_ulong Sys_parallel_default_dop( + "parallel_default_dop", "default degree of parallel query.", + SESSION_VAR(parallel_default_dop), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, 1024), DEFAULT(4), BLOCK_SIZE(1), NO_MUTEX_GUARD, + NOT_IN_BINLOG); + +static Sys_var_ulong Sys_parallel_queue_timeout( + "parallel_queue_timeout", + "queue timeout for parallel query when resource is not enough ." + "the unit is microseconds", + SESSION_VAR(parallel_queue_timeout), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, + NOT_IN_BINLOG); + static Sys_var_uint Sys_cte_max_recursion_depth( "cte_max_recursion_depth", "Abort a recursive common table expression " diff --git a/sql/system_variables.h b/sql/system_variables.h index 932ae91f5..a9e6f2ce6 100644 --- a/sql/system_variables.h +++ b/sql/system_variables.h @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -422,6 +423,16 @@ struct System_variables { @sa Sys_select_disk_sync_delay */ uint select_into_disk_sync_delay; + + bool force_parallel_execute; + + ulong parallel_cost_threshold; + + ulong parallel_default_dop; + + ulong parallel_queue_timeout; + + bool pq_copy_from(System_variables leader); }; /** @@ -504,6 +515,8 @@ struct System_status_var { */ double last_query_cost; ulonglong last_query_partial_plans; + bool reset{false}; + bool pq_merge_status(System_status_var worker); }; /* diff --git a/sql/table.h b/sql/table.h index 491d64d35..4ccae669b 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2,6 +2,7 @@ #define TABLE_INCLUDED /* Copyright (c) 2000, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -108,6 +109,7 @@ struct TABLE; struct TABLE_LIST; struct TABLE_SHARE; struct handlerton; +struct Field_raw_data; typedef int8 plan_idx; namespace dd { @@ -280,7 +282,7 @@ struct ORDER { ORDER *next{nullptr}; - protected: + public: /** The initial ordering expression. Usually substituted during resolving and must not be used during optimization and execution. @@ -2101,6 +2103,10 @@ struct TABLE { bool should_binlog_drop_if_temp_flag{false}; public: + + /** copy table property from orig table */ + bool pq_copy(THD *thd, void *select, TABLE *orig); + /** Does this table have any columns that can be updated using partial update in the current row? @@ -3324,13 +3330,14 @@ struct TABLE_LIST { const Lock_descriptor &lock_descriptor() const { return m_lock_descriptor; } - private: + public: /** The members below must be kept aligned so that (1 << m_tableno) == m_map. A table that takes part in a join operation must be assigned a unique table number. */ uint m_tableno{0}; ///< Table number within query block + private: table_map m_map{0}; ///< Table map, derived from m_tableno /** If this table or join nest is the Y in "X [LEFT] JOIN Y ON C", this @@ -3404,7 +3411,6 @@ struct TABLE_LIST { */ Table_function *table_function{nullptr}; - private: /** This field is set to non-null for derived tables and views. It points to the Query_expression representing the derived table/view. @@ -3413,6 +3419,7 @@ struct TABLE_LIST { */ Query_expression *derived{nullptr}; /* Query_expression of derived table */ + private: /// If non-NULL, the CTE which this table is derived from. Common_table_expr *m_common_table_expr{nullptr}; /** @@ -3511,9 +3518,9 @@ struct TABLE_LIST { ulonglong view_suid{0}; ///< view is suid (true by default) ulonglong with_check{0}; ///< WITH CHECK OPTION - private: /// The view algorithm that is actually used, if this is a view. enum_view_algorithm effective_algorithm{VIEW_ALGORITHM_UNDEFINED}; + private: Lock_descriptor m_lock_descriptor; public: diff --git a/sql/temp_table_param.h b/sql/temp_table_param.h index bfff4928e..f898c3c9b 100644 --- a/sql/temp_table_param.h +++ b/sql/temp_table_param.h @@ -1,4 +1,5 @@ /* Copyright (c) 2015, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -211,6 +212,7 @@ class Temp_table_param { m_window(nullptr) {} void cleanup() { copy_fields.clear(); } + void pq_copy(Temp_table_param *orig); }; #endif // TEMP_TABLE_PARAM_INCLUDED diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 08c46bbed..8c65e284f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4,6 +4,7 @@ Copyright (c) 2000, 2021, Oracle and/or its affiliates. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2022, Huawei Technologies Co., Ltd. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -9953,7 +9954,12 @@ int ha_innobase::index_read( m_prebuilt->ins_sel_stmt = thd_is_ins_sel_stmt(m_user_thd); + auto saved_ipc = m_prebuilt->idx_cond; + if (m_prebuilt->pq_index_read) { + m_prebuilt->idx_cond = false; + } ret = row_search_mvcc(buf, mode, m_prebuilt, match_mode, 0); + m_prebuilt->idx_cond = saved_ipc; } else { m_prebuilt->session = thd_to_innodb_session(m_user_thd); diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 2ad48f4b2..9d3775856 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -448,6 +449,18 @@ class ha_innobase : public handler { int parallel_scan_init(void *&scan_ctx, size_t *num_threads, bool use_reserved_threads) override; + int pq_leader_range_select_scan_init(uint keyno, void *&pq_ctx, uint &n_threads); + + int pq_leader_skip_scan_select_scan_init(uint keyno, void *&pq_ctx, uint n_threads); + + int pq_leader_ref_init(uint keyno, void *&pq_ctx, uint &n_threads); + + int pq_leader_scan_init(uint keyno, void *&scan_ctx, uint &n_threads) override; + + int pq_worker_scan_init(uint keyno, void *scan_ctx) override; + + int pq_leader_signal_all(void *scan_ctx) override; + /** Start parallel read of InnoDB records. @param[in] scan_ctx A scan context created by parallel_scan_init @param[in] thread_ctxs Context for each of the spawned threads @@ -462,10 +475,16 @@ class ha_innobase : public handler { int parallel_scan(void *scan_ctx, void **thread_ctxs, Reader::Init_fn init_fn, Reader::Load_fn load_fn, Reader::End_fn end_fn) override; + int pq_worker_scan_next(void *scan_ctx, uchar* buf) override; + /** End of the parallel scan. @param[in] scan_ctx A scan context created by parallel_scan_init. */ void parallel_scan_end(void *scan_ctx) override; + int pq_leader_scan_end(void *parallel_scan_ctx) override; + + int pq_worker_scan_end(void *parallel_scan_ctx) override; + bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) override; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index bfef1bc85..515db889e 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2021, Oracle and/or its affiliates. +Copyright (c) 2021, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -1159,12 +1160,476 @@ bool ha_innobase::prepare_inplace_alter_table(TABLE *altered_table, return prepare_inplace_alter_table_impl( altered_table, ha_alter_info, old_dd_tab, new_dd_tab); } +int ha_innobase::pq_worker_scan_init(uint keyno, void *scan_ctx) { + active_index = keyno; + + Parallel_reader *pq_reader = static_cast(scan_ctx); + update_thd(); + m_prebuilt->index = innobase_get_index(pq_reader->key); + /** + * here, we must init m_prebuilt->is_attach_ctx because this value may + * not be reset in the last execution. + */ + m_prebuilt->is_attach_ctx = false; + auto trx = m_prebuilt->trx; + innobase_register_trx(ht, ha_thd(), trx); + trx_start_if_not_started_xa(trx, false); + if (trx->read_view == nullptr && pq_reader->snapshot) { + trx_clone_read_view(trx, pq_reader->snapshot); + } + build_template(false); + inited = handler::PQ_WORKER; + + return (0); +} + +int ha_innobase::pq_leader_range_select_scan_init(uint keyno, void *&pq_ctx, + uint &n_threads) { + pq_ctx = nullptr; + update_thd(); + auto trx = m_prebuilt->trx; + innobase_register_trx(ht, ha_thd(), trx); + trx_start_if_not_started_xa(trx, false); + trx_assign_read_view(trx); + + auto pq_reader = UT_NEW_NOKEY( + Parallel_reader(Parallel_reader::available_threads(n_threads))); + if (pq_reader == nullptr || !pq_reader->pq_have_event()) { + if (pq_reader) UT_DELETE(pq_reader); + return (HA_ERR_OUT_OF_MEM); + } + + dict_index_t *index{nullptr}; + pq_reader->key = keyno; + index = innobase_get_index(keyno); + m_prebuilt->index = index; + + uint range_res{0}; + while (!(range_res = mrr_funcs.next(mrr_iter, &mrr_cur_range))) { + dtuple_t *range_start{nullptr}; + dtuple_t *range_end{nullptr}; + uint range_errno{0}; + mem_heap_t *heap{nullptr}; + btr_pcur_t *pcur{nullptr}; + + auto start_key = + mrr_cur_range.start_key.keypart_map ? &mrr_cur_range.start_key : 0; + auto end_key = + mrr_cur_range.end_key.keypart_map ? &mrr_cur_range.end_key : 0; + + // alloc heap for range_scan tuple + if (index != nullptr) { + ulint search_tuple_n_fields; + search_tuple_n_fields = 2 * (index->table->get_n_cols() + + dict_table_get_n_v_cols(index->table)); + if (!heap) + heap = mem_heap_create(DTUPLE_EST_ALLOC(search_tuple_n_fields)); + } + + range_errno = 0; + // set range boundary + /* 1) seq scan. range_start is pos on the first rec that is fulfill the + range condition range_end is pos on the next rec of the last rec fulfill + the range contition 2) reverse scan. range_start is pos on the prev rec + of the first rec fulfill the range conition range_end is pos on the last + rec fulfill the range conition + */ + if (start_key) { + const uchar *key = start_key->key; + auto keypart_map = start_key->keypart_map; + uint key_len = calculate_key_len(table, keyno, keypart_map); + + auto start_flag = start_key->flag; + if (!pq_reverse_scan) { + start_flag = (start_key->flag == HA_READ_AFTER_KEY) + ? HA_READ_AFTER_KEY + : HA_READ_KEY_OR_NEXT; + } else { + start_flag = (start_key->flag == HA_READ_AFTER_KEY) + ? HA_READ_KEY_OR_PREV + : HA_READ_BEFORE_KEY; + } + + m_prebuilt->pq_index_read = true; + int err = index_read(table->record[0], key, key_len, start_flag); + m_prebuilt->pq_index_read = false; + + if (!err) { + range_start = dtuple_copy(m_prebuilt->pq_tuple, heap); + range_start->n_fields_cmp = m_prebuilt->pq_tuple->n_fields_cmp; + } else if (pq_reverse_scan) { + range_errno = (err == HA_ERR_KEY_NOT_FOUND) ? 0 : err; + } else { + range_errno = err; + } + } + + if (end_key && !range_errno) { + const uchar *key = end_key->key; + auto keypart_map = end_key->keypart_map; + uint key_len = calculate_key_len(table, keyno, keypart_map); + + auto end_flag = end_key->flag; + if (!pq_reverse_scan) { + end_flag = (end_key->flag == HA_READ_BEFORE_KEY) ? HA_READ_KEY_OR_NEXT + : HA_READ_AFTER_KEY; + } else { + end_flag = (end_key->flag == HA_READ_BEFORE_KEY) ? HA_READ_BEFORE_KEY + : HA_READ_KEY_OR_PREV; + } + + m_prebuilt->pq_index_read = true; + int err = index_read(table->record[0], key, key_len, end_flag); + m_prebuilt->pq_index_read = false; + if (!err) { + range_end = dtuple_copy(m_prebuilt->pq_tuple, heap); + range_end->n_fields_cmp = m_prebuilt->pq_tuple->n_fields_cmp; + pcur = m_prebuilt->pcur; + } else { + if (err == HA_ERR_KEY_NOT_FOUND) { + index_last(table->record[0]); + pcur = m_prebuilt->pcur; + range_errno = 0; + } else { + range_errno = err; + } + } + } else if (end_key == nullptr && !range_errno) { + index_last(table->record[0]); + pcur = m_prebuilt->pcur; + } + + Parallel_reader::Scan_range range_scan{range_start, range_end}; + Parallel_reader::Config config(range_scan, index); + config.m_range_errno = range_errno; + config.m_pcur = pcur; + config.m_pq_reverse_scan = pq_reverse_scan; + + auto success = pq_reader->add_scan(trx, config, nullptr, false); + pq_reader->snapshot = trx->read_view; + + if (heap != nullptr) { + mem_heap_free(heap); + } + if (success != DB_SUCCESS) { + UT_DELETE(pq_reader); + return (HA_ERR_GENERIC); + } + + if (pq_reverse_scan) pq_reader->pq_set_reverse_scan(); + } + + pq_ctx = pq_reader; + build_template(false); + + if (pq_reader->max_splits() < n_threads) { + n_threads = pq_reader->max_splits() > 1 ? pq_reader->max_splits() : 1; + } + + return (0); +} + +int ha_innobase::pq_leader_ref_init(uint keyno, void *&pq_ctx, + uint &n_threads) { + pq_ctx = nullptr; + update_thd(); + auto trx = m_prebuilt->trx; + innobase_register_trx(ht, ha_thd(), trx); + trx_start_if_not_started_xa(trx, false); + trx_assign_read_view(trx); + + dtuple_t *range_start{nullptr}; + dtuple_t *range_end{nullptr}; + dict_index_t *index{nullptr}; + uint range_errno{0}; + mem_heap_t *heap{nullptr}; + btr_pcur_t *pcur{nullptr}; + + auto pq_reader = UT_NEW_NOKEY( + Parallel_reader(Parallel_reader::available_threads(n_threads))); + if (pq_reader == nullptr || !pq_reader->pq_have_event()) { + if (pq_reader) UT_DELETE(pq_reader); + return (HA_ERR_OUT_OF_MEM); + } + + pq_reader->key = keyno; + index = innobase_get_index(keyno); + m_prebuilt->index = index; + + // create search tuple on this index + if (index != nullptr) { + ulint search_tuple_n_fields; + search_tuple_n_fields = 2 * (index->table->get_n_cols() + + dict_table_get_n_v_cols(index->table)); + if (!heap) heap = mem_heap_create(DTUPLE_EST_ALLOC(search_tuple_n_fields)); + } + + range_errno = 0; + const uchar *key = pq_ref_key.key; + auto keypart_map = pq_ref_key.keypart_map; + uint key_len = calculate_key_len(table, keyno, keypart_map); + + // populate search range boudary from ref record value + int ret = index_read(table->record[0], key, key_len, HA_READ_KEY_EXACT); + if (ret) { + // record errorno when can't find ref key. which will lead process finish + // early + range_errno = ret; + } else { + // record range boudary for searching + auto start_flag = + pq_reverse_scan ? HA_READ_BEFORE_KEY : HA_READ_KEY_OR_NEXT; + + m_prebuilt->pq_index_read = true; + int err = index_read(table->record[0], key, key_len, start_flag); + m_prebuilt->pq_index_read = false; + + if (!err) { + range_start = dtuple_copy(m_prebuilt->pq_tuple, heap); + range_start->n_fields_cmp = m_prebuilt->pq_tuple->n_fields_cmp; + } else { + if (err == HA_ERR_KEY_NOT_FOUND) { + index_first(table->record[0]); + pcur = m_prebuilt->pcur; + range_errno = 0; + } else { + range_errno = err; + } + } + + if (!range_errno) { + auto end_flag = pq_reverse_scan ? HA_READ_KEY_OR_PREV : HA_READ_AFTER_KEY; + m_prebuilt->pq_index_read = true; + int err = index_read(table->record[0], key, key_len, end_flag); + m_prebuilt->pq_index_read = false; + if (!err) { + range_end = dtuple_copy(m_prebuilt->pq_tuple, heap); + range_end->n_fields_cmp = m_prebuilt->pq_tuple->n_fields_cmp; + pcur = m_prebuilt->pcur; + } else { + if (err == HA_ERR_KEY_NOT_FOUND) { + index_last(table->record[0]); + pcur = m_prebuilt->pcur; + range_errno = 0; + } else { + range_errno = err; + } + } + } + } + + Parallel_reader::Scan_range range_scan{range_start, range_end}; + Parallel_reader::Config config(range_scan, index); + config.m_range_errno = range_errno; + config.m_pcur = pcur; + config.m_pq_reverse_scan = pq_reverse_scan; + + auto success = pq_reader->add_scan(trx, config, nullptr, false); + pq_reader->snapshot = trx->read_view; + + if (heap != nullptr) { + mem_heap_free(heap); + } + if (success != DB_SUCCESS) { + UT_DELETE(pq_reader); + return (HA_ERR_GENERIC); + } + + if (pq_reverse_scan) pq_reader->pq_set_reverse_scan(); + pq_ctx = pq_reader; + build_template(false); + + if (pq_reader->max_splits() < n_threads) { + n_threads = pq_reader->max_splits() > 1 ? pq_reader->max_splits() : 1; + } + + return (0); +} + +int ha_innobase::pq_leader_scan_init(uint keyno, void *&pq_ctx, + uint &n_threads) { + if (dict_table_is_discarded(m_prebuilt->table)) { + ib_senderrf(ha_thd(), IB_LOG_LEVEL_ERROR, ER_TABLESPACE_DISCARDED, + table->s->table_name.str); + + return (HA_ERR_NO_SUCH_TABLE); + } + + btr_pcur_t *pcur{nullptr}; + active_index = keyno; + int result = change_active_index(active_index); + if (result) return result; + + // equality reference + if (pq_ref) return pq_leader_ref_init(keyno, pq_ctx, n_threads); + + // range scan + if (PQ_RANGE_SELECT == pq_range_type) + return pq_leader_range_select_scan_init(keyno, pq_ctx, n_threads); + + // table or index scan + pq_ctx = nullptr; + update_thd(); + auto trx = m_prebuilt->trx; + innobase_register_trx(ht, ha_thd(), trx); + trx_start_if_not_started_xa(trx, false); + trx_assign_read_view(trx); + + dtuple_t *range_start{nullptr}; + dtuple_t *range_end{nullptr}; + dict_index_t *index{nullptr}; + + auto pq_reader = UT_NEW_NOKEY( + Parallel_reader(Parallel_reader::available_threads(n_threads))); + + if (pq_reader == nullptr || !pq_reader->pq_have_event()) { + if (pq_reader) UT_DELETE(pq_reader); + return (HA_ERR_OUT_OF_MEM); + } + + pq_reader->key = keyno; + index = innobase_get_index(keyno); + + if (index == nullptr) { + if (pq_reader != nullptr) UT_DELETE(pq_reader); + return HA_ERR_GENERIC; + } + + m_prebuilt->index = index; + + int ret; + if (pq_reverse_scan) { + ret = index_last(table->record[0]); + if (!ret) { + pcur = m_prebuilt->pcur; + } + } else { + ret = index_first(table->record[0]); + } + + Parallel_reader::Scan_range range_scan{range_start, range_end}; + Parallel_reader::Config config(range_scan, index); + config.m_range_errno = ret; + config.m_pcur = pcur; + config.m_pq_reverse_scan = pq_reverse_scan; + + auto success = pq_reader->add_scan(trx, config, nullptr, false); + pq_reader->snapshot = trx->read_view; + + if (success != DB_SUCCESS) { + UT_DELETE(pq_reader); + return (HA_ERR_GENERIC); + } + + if (pq_reverse_scan) pq_reader->pq_set_reverse_scan(); + + pq_ctx = pq_reader; + build_template(false); + + if (pq_reader->pq_need_change_dop() && pq_reader->max_splits() < n_threads) { + n_threads = pq_reader->max_splits() > 1 ? pq_reader->max_splits() : 1; + } + + return (0); +} + +static int convert_error_code(dberr_t err, int flags, THD *thd, + row_prebuilt_t *prebuilt, TABLE *table) { + int error; + switch (err) { + case DB_SUCCESS: + error = 0; + srv_stats.n_rows_read.add(thd_get_thread_id(prebuilt->trx->mysql_thd), 1); + break; + case DB_END_OF_INDEX: + error = HA_ERR_END_OF_FILE; + break; + default: + error = convert_error_code_to_mysql(err, prebuilt->table->flags, thd); + break; + } + + return error; +} + +int ha_innobase::pq_leader_signal_all(void *pq_ctx) { + auto pq_reader = static_cast(pq_ctx); + + pq_reader->pq_wakeup_workers(); + + return DB_SUCCESS; +} + +/** + * parallel scan worker read a record from partititon and store it in buf + * + */ +int ha_innobase::pq_worker_scan_next(void *pq_ctx, uchar *buf) { + dberr_t err{DB_SUCCESS}; + ut_a(pq_ctx != nullptr); + ha_statistic_increment(&System_status_var::ha_read_rnd_next_count); + auto pq_reader = static_cast(pq_ctx); + if (pq_reader->is_error_set()) return err; + +retry: + if (!m_prebuilt->is_attach_ctx) { + err = pq_reader->dispatch_ctx(m_prebuilt); + if (err == DB_SUCCESS) { + m_prebuilt->is_attach_ctx = true; + } else { + goto end; + } + } + + { + auto ctx = m_prebuilt->ctx; + err = ctx->read_record(buf, m_prebuilt); + if (err != DB_SUCCESS) { + if (err == DB_END_OF_INDEX) { + m_prebuilt->is_attach_ctx = false; + pq_reader->ctx_completed_inc(); + goto retry; + } else if (err == DB_END_OF_RANGE) { + m_prebuilt->is_attach_ctx = false; + goto retry; + } else if (err == DB_NOT_FOUND) { + goto retry; + } else if (!pq_reader->is_error_set()) { + pq_reader->set_error_state(err); + } + } + } + +end: + return (convert_error_code(err, 0, current_thd, m_prebuilt, table)); +} + +int ha_innobase::pq_leader_scan_end(void *pq_ctx) { + active_index = MAX_KEY; + Parallel_reader *parallel_reader = static_cast(pq_ctx); + + /* wake up worker thread*/ + parallel_reader->pq_wakeup_workers(); + UT_DELETE(parallel_reader); + return 0; +} + +int ha_innobase::pq_worker_scan_end(void *pq_ctx) { + if (m_prebuilt->trx->read_view != nullptr && + m_prebuilt->trx->read_view->skip_view_list == true) { + UT_DELETE(m_prebuilt->trx->read_view); + m_prebuilt->trx->read_view = nullptr; + } + + inited = handler::NONE; + return 0; +} int ha_innobase::parallel_scan_init(void *&scan_ctx, size_t *num_threads, bool use_reserved_threads) { if (dict_table_is_discarded(m_prebuilt->table)) { ib_senderrf(ha_thd(), IB_LOG_LEVEL_ERROR, ER_TABLESPACE_DISCARDED, - m_prebuilt->table->name.m_name); + table->s->table_name.str); return (HA_ERR_NO_SUCH_TABLE); } @@ -1228,7 +1693,7 @@ int ha_innobase::parallel_scan(void *scan_ctx, void **thread_ctxs, Reader::End_fn end_fn) { if (dict_table_is_discarded(m_prebuilt->table)) { ib_senderrf(ha_thd(), IB_LOG_LEVEL_ERROR, ER_TABLESPACE_DISCARDED, - m_prebuilt->table->name.m_name); + table->s->table_name.str); return (HA_ERR_NO_SUCH_TABLE); } @@ -9821,7 +10286,7 @@ int ha_innopart::parallel_scan_init(void *&scan_ctx, size_t *num_threads, if (dict_table_is_discarded(m_prebuilt->table)) { ib_senderrf(ha_thd(), IB_LOG_LEVEL_ERROR, ER_TABLESPACE_DISCARDED, - m_prebuilt->table->name.m_name); + table->s->table_name.str); UT_DELETE(adapter); return HA_ERR_NO_SUCH_TABLE; diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index d18a42873..338ed4052 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -519,7 +520,6 @@ struct btr_pcur_t { return (old_fetch_mode); } - private: /** Moves the persistent cursor backward if it is on the first record of the page. Commits mtr. Note that to prevent a possible deadlock, the operation first stores the position of the cursor, commits mtr, acquires @@ -532,7 +532,6 @@ struct btr_pcur_t { @param[in,out] mtr Mini-tranaction. */ void move_backward_from_page(mtr_t *mtr); - public: /** a B-tree cursor */ btr_cur_t m_btr_cur; diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index 8639fc0d1..b7625bbce 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -810,6 +811,9 @@ struct dtuple_t { } return (false); } + + int compare(const rec_t *rec, const dict_index_t *index, const dict_index_t *index2, + const ulint *offsets); }; /** A slot for a field in a big rec vector */ diff --git a/storage/innobase/include/data0data.ic b/storage/innobase/include/data0data.ic index 509f32d68..98191d85c 100644 --- a/storage/innobase/include/data0data.ic +++ b/storage/innobase/include/data0data.ic @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -572,6 +573,16 @@ dtuple_t *dtuple_copy(const dtuple_t *tuple, /*!< in: tuple to copy from */ return (new_tuple); } +UNIV_INLINE +dtuple_t *pq_dtuple_copy(const dtuple_t *tuple, /*!< in: tuple to copy from */ + mem_heap_t *heap) /*!< in: memory heap + where the tuple is created */ +{ + dtuple_t *new_tuple = dtuple_copy(tuple, heap); + dtuple_set_n_fields_cmp(new_tuple, tuple->n_fields_cmp); + return (new_tuple); +} + /** The following function returns the sum of data lengths of a tuple. The space occupied by the field structs or the tuple struct is not counted. Neither is possible space in externally stored parts of the field. diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index ccdcd0ca0..fb6350414 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -209,6 +210,7 @@ enum dberr_t { DB_END_OF_BLOCK, DB_END_OF_INDEX, DB_END_SAMPLE_READ, + DB_END_OF_RANGE, // reach parallel query range end /** Generic error code for "Not found" type of errors */ DB_NOT_FOUND, diff --git a/storage/innobase/include/read0types.h b/storage/innobase/include/read0types.h index a27506f81..44c1dd11b 100644 --- a/storage/innobase/include/read0types.h +++ b/storage/innobase/include/read0types.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -150,6 +151,9 @@ class ReadView { public: ReadView(); ~ReadView(); + + void Copy_readView(const ReadView &); + /** Check whether transaction id is valid. @param[in] id transaction id to check @param[in] name table name */ @@ -274,9 +278,11 @@ class ReadView { private: // Disable copying - ReadView(const ReadView &); ReadView &operator=(const ReadView &); + public: + bool skip_view_list{false}; + private: /** The read should not see any transaction with trx id >= this value. In other words, this is the "high water mark". */ diff --git a/storage/innobase/include/rem0cmp.h b/storage/innobase/include/rem0cmp.h index d637981f6..7173c038b 100644 --- a/storage/innobase/include/rem0cmp.h +++ b/storage/innobase/include/rem0cmp.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -118,6 +119,10 @@ int cmp_dtuple_rec_with_gis_internal(const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets, const dd::Spatial_reference_system *srs); +int cmp_sec_dtuple_pri_rec_with_match(const dtuple_t *dtuple, const rec_t *rec, + const dict_index_t *index, const dict_index_t *clust_index, + const ulint *offsets, ulint n_cmp); + /** Compare a data tuple to a physical record. @param[in] dtuple data tuple @param[in] rec record diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 9491a602a..214cdb315 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -61,6 +62,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0types.h" #include "univ.i" #include "ut0bool_scope_guard.h" +#include "row0pread.h" // Forward declarations class THD; @@ -900,6 +902,15 @@ struct row_prebuilt_t { @return true iff duplicated values should be allowed */ bool allow_duplicates() { return (replace || on_duplicate_key_update); } + std::shared_ptr ctx{}; + bool is_attach_ctx{false}; + mem_heap_t *pq_heap{nullptr}; + dtuple_t *pq_tuple{nullptr}; + bool pq_index_read{false}; + /** Number of externally stored columns. */ + ulint pq_m_n_ext{ULINT_UNDEFINED}; + bool pq_requires_clust_rec{false}; + private: /** A helper function for init_search_tuples_types() which prepares the shape of the tuple to match the index diff --git a/storage/innobase/include/row0pread-adapter.h b/storage/innobase/include/row0pread-adapter.h index addc9fac3..f7ed6383b 100644 --- a/storage/innobase/include/row0pread-adapter.h +++ b/storage/innobase/include/row0pread-adapter.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2018, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -67,7 +68,7 @@ class Parallel_reader_adapter { @param[in] f Callback function. @retval error. */ dberr_t add_scan(trx_t *trx, const Parallel_reader::Config &config, - Parallel_reader::F &&f) MY_ATTRIBUTE((warn_unused_result)); + Parallel_reader::F &&f, bool split = false) MY_ATTRIBUTE((warn_unused_result)); /** Run the parallel scan. @param[in] thread_contexts Context for each of the spawned threads diff --git a/storage/innobase/include/row0pread-histogram.h b/storage/innobase/include/row0pread-histogram.h index 142e71145..204c55904 100644 --- a/storage/innobase/include/row0pread-histogram.h +++ b/storage/innobase/include/row0pread-histogram.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2019, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -35,6 +36,7 @@ Created 2019-04-20 by Darshan M N. */ #include #include "row0pread.h" #include "ut0counter.h" +#include "handler.h" class Histogram_sampler { public: diff --git a/storage/innobase/include/row0pread.h b/storage/innobase/include/row0pread.h index 2189e5866..9e914441c 100644 --- a/storage/innobase/include/row0pread.h +++ b/storage/innobase/include/row0pread.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2018, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -35,9 +36,6 @@ Created 2018-01-27 by Sunny Bains. */ #include #include -#include "os0thread-create.h" -#include "row0sel.h" - // Forward declarations struct trx_t; struct mtr_t; @@ -96,6 +94,7 @@ reference counting, this allows us to dispose of the Ctx instances without worrying about dangling pointers. NOTE: Secondary index scans are not supported currently. */ +class ReadView; class Parallel_reader { public: /** Maximum value for innodb-parallel-read-threads. */ @@ -177,7 +176,12 @@ class Parallel_reader { m_is_compact(config.m_is_compact), m_page_size(config.m_page_size), m_read_level(config.m_read_level), - m_partition_id(config.m_partition_id) {} + m_partition_id(config.m_partition_id), + m_range_errno(config.m_range_errno), + m_pcur(config.m_pcur), + m_pq_reverse_scan(config.m_pq_reverse_scan) {} + + ~Config() {} /** Range to scan. */ const Scan_range m_scan_range; @@ -197,6 +201,12 @@ class Parallel_reader { /** Partition id if the index to be scanned belongs to a partitioned table, else std::numeric_limits::max(). */ size_t m_partition_id{std::numeric_limits::max()}; + + uint m_range_errno{0}; + + btr_pcur_t *m_pcur{nullptr}; + + bool m_pq_reverse_scan{false}; }; /** Thread related context information. */ @@ -291,7 +301,7 @@ class Parallel_reader { @param[in] f Callback function. (default is 0 which is leaf level) @return error. */ - dberr_t add_scan(trx_t *trx, const Config &config, F &&f) + dberr_t add_scan(trx_t *trx, const Config &config, F &&f, bool split = false) MY_ATTRIBUTE((warn_unused_result)); /** Wait for the join of threads spawned by the parallel reader. */ @@ -325,11 +335,29 @@ class Parallel_reader { @return DB_SUCCESS or error code. */ dberr_t run(size_t n_threads = 0) MY_ATTRIBUTE((warn_unused_result)); + /** dispatch a execution context to the prebuilt object */ + dberr_t dispatch_ctx(row_prebuilt_t *prebuilt); + + void ctx_completed_inc(); + + void pq_set_worker_done(); + + void pq_wakeup_workers(); + + void pq_set_reverse_scan(); + + bool pq_get_reverse_scan() { return m_pq_reverse_scan; } + /** @return the configured max threads size. */ size_t max_threads() const MY_ATTRIBUTE((warn_unused_result)) { return m_max_threads; } + /** @return the queue size. */ + size_t max_splits() const MY_ATTRIBUTE((warn_unused_result)) { + return m_ctxs.size(); + } + /** @return true if in error state. */ bool is_error_set() const MY_ATTRIBUTE((warn_unused_result)) { return (m_err.load(std::memory_order_relaxed) != DB_SUCCESS); @@ -347,6 +375,15 @@ class Parallel_reader { Parallel_reader &operator=(Parallel_reader &&) = delete; Parallel_reader &operator=(const Parallel_reader &) = delete; + /** obtain m_event **/ + bool pq_have_event() { return m_event ? true : false; } + + bool pq_need_change_dop() { return m_need_change_dop; } + + ReadView *snapshot{}; + + uint key{0}; + private: /** Reset error state. */ void reset_error_state() { m_err = DB_SUCCESS; } @@ -376,9 +413,9 @@ class Parallel_reader { /** Create the threads and do a parallel read across the partitions. */ void parallel_read(); - /** @return true if tasks are still executing. */ - bool is_active() const MY_ATTRIBUTE((warn_unused_result)) { - return (m_n_completed.load(std::memory_order_relaxed) < + /** @return true if tasks are over. */ + bool is_ctx_over() const MY_ATTRIBUTE((warn_unused_result)) { + return !(m_n_completed.load(std::memory_order_relaxed) < m_ctx_id.load(std::memory_order_relaxed)); } @@ -397,6 +434,10 @@ class Parallel_reader { /** Maximum number of worker threads to use. */ const size_t m_max_threads; + /** True: dop will change to m_ctxs.size() when m_ctxs.size() is less then + * exepected dop. */ + bool m_need_change_dop{true}; + /** Number of worker threads that will be spawned. */ size_t m_n_threads{0}; @@ -446,11 +487,17 @@ class Parallel_reader { /** If the caller wants to wait for the parallel_read to finish it's run */ bool m_sync; + /** state of worker currently doing parallel reads. */ + std::atomic work_done{false}; + + bool m_pq_reverse_scan{false}; + /** Context information related to each parallel reader thread. */ std::vector> m_thread_ctxs; friend class Ctx; friend class Scan_ctx; + friend class Parallel_reader_adapter; }; /** Parallel reader context. */ @@ -598,6 +645,12 @@ class Parallel_reader::Scan_ctx { bool check_visibility(const rec_t *&rec, ulint *&offsets, mem_heap_t *&heap, mtr_t *mtr) MY_ATTRIBUTE((warn_unused_result)); + dberr_t find_visible_record(byte *buf, const rec_t *&rec, + const rec_t *&clust_rec, ulint *&offsets, + ulint *&clust_offsets, mem_heap_t *&heap, + mtr_t *mtr, row_prebuilt_t *prebuilt = nullptr) + MY_ATTRIBUTE((warn_unused_result)); + /** Create an execution context for a range and add it to the Parallel_reader's run queue. @param[in] range Range for which to create the context. @@ -680,7 +733,7 @@ class Parallel_reader::Ctx { @param[in] scan_ctx Scan context. @param[in] range Range that the thread has to read. */ Ctx(size_t id, Scan_ctx *scan_ctx, const Scan_ctx::Range &range) - : m_id(id), m_range(range), m_scan_ctx(scan_ctx) {} + : m_id(id), m_range(range), m_scan_ctx(scan_ctx), reader(nullptr) {} public: /** Destructor. */ @@ -794,9 +847,24 @@ class Parallel_reader::Ctx { ulint *m_offsets{}; + dberr_t read_record(uchar *buf, row_prebuilt_t *prebuilt) + MY_ATTRIBUTE((warn_unused_result)); + /** Start of a new range to scan. */ bool m_start{}; + /** Current row curous */ + btr_pcur_t *m_pcur{}; + + bool start_read{true}; // start to read range's records + mem_heap_t *m_blob_heap{}; // heap for containing mysql records + mem_heap_t *m_heap{}; // heap for containing innnodb rec + + ulint offsets_[REC_OFFS_NORMAL_SIZE]{}; + ulint clust_offsets_[REC_OFFS_NORMAL_SIZE]{}; + + Parallel_reader *reader; + friend class Parallel_reader; }; diff --git a/storage/innobase/include/row0sel.h b/storage/innobase/include/row0sel.h index 62a5b882d..1670f6796 100644 --- a/storage/innobase/include/row0sel.h +++ b/storage/innobase/include/row0sel.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -120,6 +121,12 @@ bool row_sel_store_mysql_rec(byte *mysql_rec, row_prebuilt_t *prebuilt, lob::undo_vers_t *lob_undo, mem_heap_t *&blob_heap); +void pq_row_sel_store_row_id_to_prebuilt( + row_prebuilt_t *prebuilt, /*!< in/out: prebuilt */ + const rec_t *index_rec, /*!< in: record */ + const dict_index_t *index, /*!< in: index of the record */ + const ulint *offsets); /*!< in: rec_get_offsets */ + /** Converts a key value stored in MySQL format to an Innobase dtuple. The last field of the key value may be just a prefix of a fixed length field: hence the parameter key_len. But currently we do not allow search keys where the @@ -163,7 +170,6 @@ position and fetch next or fetch prev must not be tried to the cursor! cursor 'direction' should be 0. @return DB_SUCCESS, DB_RECORD_NOT_FOUND, DB_END_OF_INDEX, DB_DEADLOCK, DB_LOCK_TABLE_FULL, DB_CORRUPTION, or DB_TOO_BIG_RECORD */ -UNIV_INLINE dberr_t row_search_for_mysql(byte *buf, page_cur_mode_t mode, row_prebuilt_t *prebuilt, ulint match_mode, ulint direction) @@ -511,6 +517,42 @@ bool row_search_index_stats(const char *db_name, const char *tbl_name, const char *index_name, ulint col_offset, ulonglong *cardinality); +/** Helper class to cache clust_rec and old_ver */ +class Row_sel_get_clust_rec_for_mysql { + const rec_t *cached_clust_rec; + rec_t *cached_old_vers; + + public: + /** Constructor */ + Row_sel_get_clust_rec_for_mysql() + : cached_clust_rec(nullptr), cached_old_vers(nullptr) {} + + /** Retrieve the clustered index record corresponding to a record in a + non-clustered index. Does the necessary locking. + @param[in] prebuilt prebuilt struct in the handle + @param[in] sec_index secondary index where rec resides + @param[in] rec record in a non-clustered index + @param[in] thr query thread + @param[out] out_rec clustered record or an old version of it, + NULL if the old version did not exist in the + read view, i.e., it was a fresh inserted version + @param[in,out] offsets in: offsets returned by + rec_get_offsets(rec, sec_index); + out: offsets returned by + rec_get_offsets(out_rec, clust_index) + @param[in,out] offset_heap memory heap from which the offsets are allocated + @param[out] vrow virtual column to fill + @param[in] mtr mtr used to get access to the non-clustered record; + the same mtr is used to access the clustered index + @param[in] lob_undo the LOB undo information. + @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ + dberr_t operator()(row_prebuilt_t *prebuilt, dict_index_t *sec_index, + const rec_t *rec, que_thr_t *thr, const rec_t **out_rec, + ulint **offsets, mem_heap_t **offset_heap, + const dtuple_t **vrow, mtr_t *mtr, + lob::undo_vers_t *lob_undo); +}; + #include "row0sel.ic" #endif diff --git a/storage/innobase/include/row0sel.ic b/storage/innobase/include/row0sel.ic index 9b06770c0..db4d029f9 100644 --- a/storage/innobase/include/row0sel.ic +++ b/storage/innobase/include/row0sel.ic @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -31,6 +32,8 @@ this program; if not, write to the Free Software Foundation, Inc., *******************************************************/ #include "que0que.h" +#include "row0sel.h" +#include "row0mysql.h" /** Gets the plan node for the nth table in a join. @return plan node */ @@ -97,34 +100,3 @@ que_thr_t *open_step(que_thr_t *thr) /*!< in: query thread */ return (thr); } - -/** Searches for rows in the database. This is used in the interface to -MySQL. This function opens a cursor, and also implements fetch next -and fetch prev. NOTE that if we do a search with a full key value -from a unique index (ROW_SEL_EXACT), then we will not store the cursor -position and fetch next or fetch prev must not be tried to the cursor! - -@param[out] buf buffer for the fetched row in MySQL format -@param[in] mode search mode PAGE_CUR_L -@param[in,out] prebuilt prebuilt struct for the table handler; - this contains the info to search_tuple, - index; if search tuple contains 0 field then - we position the cursor at start or the end of - index, depending on 'mode' -@param[in] match_mode 0 or ROW_SEL_EXACT or ROW_SEL_EXACT_PREFIX -@param[in] direction 0 or ROW_SEL_NEXT or ROW_SEL_PREV; - Note: if this is != 0, then prebuilt must has a - pcur with stored position! In opening of a - cursor 'direction' should be 0. -@return DB_SUCCESS, DB_RECORD_NOT_FOUND, DB_END_OF_INDEX, DB_DEADLOCK, -DB_LOCK_TABLE_FULL, DB_CORRUPTION, or DB_TOO_BIG_RECORD */ -UNIV_INLINE -dberr_t row_search_for_mysql(byte *buf, page_cur_mode_t mode, - row_prebuilt_t *prebuilt, ulint match_mode, - ulint direction) { - if (!prebuilt->table->is_intrinsic()) { - return (row_search_mvcc(buf, mode, prebuilt, match_mode, direction)); - } else { - return (row_search_no_mvcc(buf, mode, prebuilt, match_mode, direction)); - } -} diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index f22a2179b..60416e83f 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -234,6 +235,8 @@ void trx_mark_sql_stat_end(trx_t *trx); /*!< in: trx handle */ when this function is first called for a new started transaction. */ ReadView *trx_assign_read_view(trx_t *trx); /*!< in: active transaction */ +ReadView *trx_clone_read_view(trx_t *trx, ReadView *readview); + /** @return the transaction's read view or NULL if one not assigned. */ UNIV_INLINE ReadView *trx_get_read_view(trx_t *trx); diff --git a/storage/innobase/read/read0read.cc b/storage/innobase/read/read0read.cc index 4351d31ac..5eca03c1b 100644 --- a/storage/innobase/read/read0read.cc +++ b/storage/innobase/read/read0read.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -320,6 +321,12 @@ ReadView::ReadView() ut_d(m_view_low_limit_no = 0); } +void ReadView::Copy_readView(const ReadView &view) { + copy_prepare(view); + copy_complete(); + m_creator_trx_id = view.m_creator_trx_id; +} + /** ReadView destructor */ ReadView::~ReadView() { @@ -721,8 +728,10 @@ void MVCC::view_close(ReadView *&view, bool own_mutex) { view->close(); - UT_LIST_REMOVE(m_views, view); - UT_LIST_ADD_LAST(m_free, view); + if (!view->skip_view_list) { + UT_LIST_REMOVE(m_views, view); + UT_LIST_ADD_LAST(m_free, view); + } ut_ad(validate()); diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index e0ec4bbcb..f1f0187ac 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -596,6 +597,79 @@ int cmp_data_data(ulint mtype, ulint prtype, bool is_asc, const byte *data1, return (cmp_data(mtype, prtype, is_asc, data1, len1, data2, len2)); } +int cmp_sec_dtuple_pri_rec_with_match(const dtuple_t *dtuple, const rec_t *rec, + const dict_index_t *index, + const dict_index_t *clust_index, + const ulint *offsets, ulint n_cmp) { + ut_ad(dtuple_check_typed(dtuple)); + ut_ad(rec_offs_validate(rec, clust_index, offsets)); + ut_ad(n_cmp > 0); + ut_ad(n_cmp <= dtuple_get_n_fields(dtuple)); + + for (ulint i = 0; i < n_cmp; ++i) { + const auto dtuple_field = dtuple_get_nth_field(dtuple, i); + + const auto dtuple_b_ptr = + static_cast(dfield_get_data(dtuple_field)); + + const auto type = dfield_get_type(dtuple_field); + + auto dtuple_f_len = dfield_get_len(dtuple_field); + + ut_ad(!rec_offs_nth_extern(offsets, i)); + + ut_ad(!rec_offs_nth_default(offsets, i)); + + // caculate the pos + auto pos = dict_index_get_nth_field_pos(clust_index, index, i); + + ulint rec_f_len; + + const auto rec_b_ptr = rec_get_nth_field(rec, offsets, pos, &rec_f_len); + + ut_ad(!dfield_is_ext(dtuple_field)); + + int ret{}; + + if (dfield_is_multi_value(dtuple_field) && + (dtuple_f_len == UNIV_MULTI_VALUE_ARRAY_MARKER || + dtuple_f_len == UNIV_NO_INDEX_VALUE)) { + /* If it's the value parsed from the array, or NULL, then + the calculation can be done in a normal way in the else branch */ + ut_ad(index->is_multi_value()); + if (dtuple_f_len == UNIV_NO_INDEX_VALUE) { + ret = 1; + } else { + multi_value_data *mv_data = + static_cast(dtuple_field->data); + ret = mv_data->has(type, rec_b_ptr, rec_f_len) ? 0 : 1; + } + } else { + /* For now, change buffering is only supported on + indexes with ascending order on the columns. */ + if (dtuple_f_len != UNIV_SQL_NULL && rec_f_len != UNIV_SQL_NULL && + dtuple_f_len < rec_f_len) { + const dict_field_t *field = index->get_field(i); + if (field->prefix_len > 0) { + rec_f_len = dtype_get_at_most_n_mbchars( + field->col->prtype, field->col->mbminmaxlen, field->prefix_len, + rec_f_len, reinterpret_cast(rec_b_ptr)); + } + } + ret = cmp_data( + type->mtype, type->prtype, + dict_index_is_ibuf(index) || index->get_field(i)->is_ascending, + dtuple_b_ptr, dtuple_f_len, rec_b_ptr, rec_f_len); + } + + if (ret) { + return (ret); + } + } + + return (0); +} + int cmp_dtuple_rec_with_match_low(const dtuple_t *dtuple, const rec_t *rec, const dict_index_t *index, const ulint *offsets, ulint n_cmp, @@ -648,8 +722,16 @@ int cmp_dtuple_rec_with_match_low(const dtuple_t *dtuple, const rec_t *rec, ut_ad(!rec_offs_nth_default(offsets, i)); ulint rec_f_len; + const byte *rec_b_ptr = nullptr; + if(index->has_instant_cols()) { + rec_b_ptr = rec_get_nth_field_instant(rec, offsets, i, index, &rec_f_len); + } + else { + /* So does the field with default value */ + ut_ad(!rec_offs_nth_default(offsets, i)); - const auto rec_b_ptr = rec_get_nth_field(rec, offsets, i, &rec_f_len); + rec_b_ptr = rec_get_nth_field(rec, offsets, i, &rec_f_len); + } ut_ad(!dfield_is_ext(dtuple_field)); @@ -1130,3 +1212,9 @@ int dtuple_t::compare(const rec_t *rec, const dict_index_t *index, return (cmp_dtuple_rec_with_match_low(this, rec, index, offsets, n_fields_cmp, matched_fields)); } + +int dtuple_t::compare(const rec_t *rec, const dict_index_t *index, + const dict_index_t *index2, const ulint *offsets) { + return cmp_sec_dtuple_pri_rec_with_match(this, rec, index, index2, offsets, + n_fields_cmp); +} diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 55c6ada91..6612d7c23 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -993,6 +994,12 @@ void row_prebuilt_free(row_prebuilt_t *prebuilt, ibool dict_locked) { } prebuilt->m_lob_undo.destroy(); + prebuilt->ctx = nullptr; + + if (prebuilt->pq_heap) { + mem_heap_free(prebuilt->pq_heap); + prebuilt->pq_heap = nullptr; + } mem_heap_free(prebuilt->heap); } diff --git a/storage/innobase/row/row0pread-adapter.cc b/storage/innobase/row/row0pread-adapter.cc index 4a7e40db0..eb0efea0b 100644 --- a/storage/innobase/row/row0pread-adapter.cc +++ b/storage/innobase/row/row0pread-adapter.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2018, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -43,8 +44,8 @@ Parallel_reader_adapter::Parallel_reader_adapter(size_t max_threads, dberr_t Parallel_reader_adapter::add_scan(trx_t *trx, const Parallel_reader::Config &config, - Parallel_reader::F &&f) { - return m_parallel_reader.add_scan(trx, config, std::move(f)); + Parallel_reader::F &&f, bool split) { + return m_parallel_reader.add_scan(trx, config, std::move(f), split); } Parallel_reader_adapter::Thread_ctx::Thread_ctx() { diff --git a/storage/innobase/row/row0pread.cc b/storage/innobase/row/row0pread.cc index 9e962da5e..54789a73b 100644 --- a/storage/innobase/row/row0pread.cc +++ b/storage/innobase/row/row0pread.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2018, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -39,11 +40,23 @@ Created 2018-01-27 by Sunny Bains */ #include "row0row.h" #include "row0vers.h" #include "ut0new.h" +#include "row0sel.h" #ifdef UNIV_PFS_THREAD mysql_pfs_key_t parallel_read_thread_key; #endif /* UNIV_PFS_THREAD */ +ICP_RESULT row_search_idx_cond_check( + byte *mysql_rec, /*!< out: record + in MySQL format (invalid unless + prebuilt->idx_cond == true and + we return ICP_MATCH) */ + row_prebuilt_t *prebuilt, /*!< in/out: prebuilt struct + for the table handle */ + const rec_t *rec, /*!< in: InnoDB record */ + const ulint *offsets); /*!< in: rec_get_offsets() */ + + std::atomic_size_t Parallel_reader::s_active_threads{}; /** Tree depth at which we decide to split blocks further. */ @@ -86,7 +99,13 @@ Parallel_reader::Scan_ctx::Iter::~Iter() { m_heap = nullptr; } -Parallel_reader::Ctx::~Ctx() {} +Parallel_reader::Ctx::~Ctx() { + if (m_blob_heap) + mem_heap_free(m_blob_heap); + + if(m_heap) + mem_heap_free(m_heap); +} Parallel_reader::Scan_ctx::~Scan_ctx() {} @@ -220,6 +239,7 @@ class PCursor { /** Check if there are threads waiting on the index latch. Yield the latch so that other threads can progress. */ void yield(); + void yield_prev(); /** Move to the next block. @param[in] index Index being traversed. @@ -227,6 +247,9 @@ class PCursor { dberr_t move_to_next_block(dict_index_t *index) MY_ATTRIBUTE((warn_unused_result)); + dberr_t move_to_prev_block(dict_index_t *index) + MY_ATTRIBUTE((warn_unused_result)); + /** Restore the cursor position. */ void restore_position() { auto relative = m_pcur->m_rel_pos; @@ -240,7 +263,8 @@ class PCursor { } } else { ut_ad(relative == BTR_PCUR_AFTER || - relative == BTR_PCUR_AFTER_LAST_IN_TREE); + relative == BTR_PCUR_AFTER_LAST_IN_TREE || + relative == BTR_PCUR_BEFORE); } } @@ -295,6 +319,35 @@ void PCursor::yield() { } } +void PCursor::yield_prev() { + /* We should always yield on a block boundary. */ + ut_ad(m_pcur->is_before_first_on_page()); + + /* Store the cursor position on the first user record on the page. */ + m_pcur->move_to_next_on_page(); + + m_pcur->store_position(m_mtr); + + m_mtr->commit(); + + /* Yield so that another thread can proceed. */ + std::this_thread::yield(); + + m_mtr->start(); + + m_mtr->set_log_mode(MTR_LOG_NO_REDO); + + /* Restore position on the record, or its predecessor if the record + was purged meanwhile. */ + + restore_position(); + + if (!m_pcur->is_before_first_on_page()) { + /* Move to the successor of the saved record. */ + m_pcur->move_to_prev_on_page(); + } +} + dberr_t PCursor::move_to_next_block(dict_index_t *index) { ut_ad(m_pcur->is_after_last_on_page()); @@ -345,6 +398,45 @@ dberr_t PCursor::move_to_next_block(dict_index_t *index) { return (DB_SUCCESS); } +dberr_t PCursor::move_to_prev_block(dict_index_t * index) { + ut_ad(m_pcur->is_before_first_on_page()); + + if (rw_lock_get_waiters(dict_index_get_lock(index))) { + /* There are waiters on the index tree lock. Store and restore + the cursor position, and yield so that scanning a large table + will not starve other threads. */ + + yield_prev(); + + /* It's possible that the restore places the cursor in the middle of + the block. We need to account for that too. */ + + if (m_pcur->is_on_user_rec()) { + return (DB_SUCCESS); + } + } + + auto cur = m_pcur->get_page_cur(); + + auto prev_page_no = btr_page_get_prev(page_cur_get_page(cur), m_mtr); + + if (prev_page_no == FIL_NULL) { + m_mtr->commit(); + + return (DB_END_OF_INDEX); + } + + m_pcur->move_backward_from_page(m_mtr); + + /* Skip the supremum record. */ + page_cur_move_to_prev(cur); + + /* Page can't be empty unless it is a root page. */ + ut_ad(!page_cur_is_before_first(cur)); + + return (DB_SUCCESS); +} + bool Parallel_reader::Scan_ctx::check_visibility(const rec_t *&rec, ulint *&offsets, mem_heap_t *&heap, @@ -383,8 +475,6 @@ bool Parallel_reader::Scan_ctx::check_visibility(const rec_t *&rec, } } } else { - /* Secondary index scan not supported yet. */ - ut_error; auto max_trx_id = page_get_max_trx_id(page_align(rec)); @@ -404,12 +494,149 @@ bool Parallel_reader::Scan_ctx::check_visibility(const rec_t *&rec, return (false); } - ut_ad(!m_trx || m_trx->isolation_level == TRX_ISO_READ_UNCOMMITTED || - !rec_offs_any_null_extern(rec, offsets)); - return (true); } +dberr_t Parallel_reader::Scan_ctx::find_visible_record(byte *buf, + const rec_t *&rec, + const rec_t *&clust_rec, + ulint *&offsets, + ulint *&clust_offsets, + mem_heap_t *&heap, + mtr_t *mtr, + row_prebuilt_t *prebuilt) { + + const auto table_name = m_config.m_index->table->name; + ut_ad(m_trx->read_view == nullptr || MVCC::is_view_active(m_trx->read_view)); + if (prebuilt != nullptr) { + prebuilt->pq_requires_clust_rec = false; + } + if (m_trx->read_view != nullptr) { + auto view = m_trx->read_view; + + if (m_config.m_index->is_clustered()) { + trx_id_t rec_trx_id; + + if (m_config.m_index->trx_id_offset > 0) { + rec_trx_id = trx_read_trx_id(rec + m_config.m_index->trx_id_offset); + } else { + rec_trx_id = row_get_rec_trx_id(rec, m_config.m_index, offsets); + } + + if (m_trx->isolation_level > TRX_ISO_READ_UNCOMMITTED && + !view->changes_visible(rec_trx_id, table_name)) { + rec_t *old_vers = nullptr; + + row_vers_build_for_consistent_read(rec, mtr, m_config.m_index, &offsets, + view, &heap, heap, &old_vers, + nullptr, nullptr); + + rec = old_vers; + if (rec == nullptr) { + return DB_NOT_FOUND; + } + } + } else { + /* Secondary index scan not supported yet. */ + auto max_trx_id = page_get_max_trx_id(page_align(rec)); + ut_ad(max_trx_id > 0); + + if (!view->sees(max_trx_id) || + (prebuilt && prebuilt->need_to_access_clustered)) { + if (prebuilt) + { + if (prebuilt->idx_cond) { + switch (row_search_idx_cond_check(buf, prebuilt, rec, offsets)) + { + case ICP_NO_MATCH: + return DB_NOT_FOUND; + case ICP_OUT_OF_RANGE: + return DB_END_OF_RANGE; + case ICP_MATCH: + break; + } + } + if (prebuilt->sel_graph == nullptr) + row_prebuild_sel_graph(prebuilt); + + Row_sel_get_clust_rec_for_mysql row_sel_get_clust_rec_for_mysql; + que_thr_t *thr = que_fork_get_first_thr(prebuilt->sel_graph); + + prebuilt->pq_requires_clust_rec = true; + int err = row_sel_get_clust_rec_for_mysql(prebuilt, m_config.m_index, rec, thr, &clust_rec, + &clust_offsets, &heap, NULL, mtr, nullptr); + + if (err != DB_SUCCESS) + return DB_NOT_FOUND; + else { + if (clust_rec == NULL) { + /* The record did not exist in the read view */ + ut_ad(prebuilt->select_lock_type == LOCK_NONE); + + return DB_NOT_FOUND; + } + else if(rec_get_deleted_flag(clust_rec, m_config.m_is_compact)) { + /* The record is delete marked: we can skip it */ + return DB_NOT_FOUND; + } + else { + return DB_SUCCESS; + } + } + } else + return DB_NOT_FOUND; + } + } + } else if (srv_read_only_mode && /** innodb_read_only */ + (prebuilt && prebuilt->need_to_access_clustered && /** secondary index and non-covered index */ + !m_config.m_index->is_clustered())) { + if (prebuilt->idx_cond) { + switch (row_search_idx_cond_check(buf, prebuilt, rec, offsets)) + { + case ICP_NO_MATCH: + return DB_NOT_FOUND; + case ICP_OUT_OF_RANGE: + return DB_END_OF_RANGE; + case ICP_MATCH: + break; + } + } + + if (prebuilt->sel_graph == nullptr) + row_prebuild_sel_graph(prebuilt); + + que_thr_t *thr = que_fork_get_first_thr(prebuilt->sel_graph); + prebuilt->pq_requires_clust_rec = true; + Row_sel_get_clust_rec_for_mysql row_sel_get_clust_rec_for_mysql; + int err = row_sel_get_clust_rec_for_mysql(prebuilt, m_config.m_index, rec, thr, &clust_rec, + &clust_offsets, &heap, NULL, mtr, nullptr); + + if (err != DB_SUCCESS) + return DB_NOT_FOUND; + else { + if (clust_rec == NULL) { + /* The record did not exist in the read view */ + ut_ad(prebuilt->select_lock_type == LOCK_NONE); + + return DB_NOT_FOUND; + } else if(rec_get_deleted_flag(clust_rec, m_config.m_is_compact)) { + /* The record is delete marked: we can skip it */ + return DB_NOT_FOUND; + } else { + return DB_SUCCESS; + } + } + } + + if (rec_get_deleted_flag(rec, m_config.m_is_compact)) { + /* This record was deleted in the latest committed version, or it was + deleted and then reinserted-by-update before purge kicked in. Skip it. */ + return DB_NOT_FOUND; + } + + return DB_SUCCESS; +} + void Parallel_reader::Scan_ctx::copy_row(const rec_t *rec, Iter *iter) const { iter->m_offsets = rec_get_offsets(rec, m_config.m_index, nullptr, ULINT_UNDEFINED, &iter->m_heap); @@ -503,6 +730,145 @@ bool Parallel_reader::Ctx::move_to_next_node(PCursor *pcursor, mtr_t *mtr) { return (true); } +dberr_t Parallel_reader::Ctx::read_record(uchar* buf, row_prebuilt_t *prebuilt) { + mtr_t mtr; + btr_pcur_t *pcur; + + dberr_t err{DB_SUCCESS}; + dberr_t err1{DB_SUCCESS}; + int ret{0}; + const rec_t *clust_rec = nullptr; + const rec_t *rec = nullptr; + const rec_t *result_rec = nullptr; + ulint *offsets = offsets_; + ulint *clust_offsets = clust_offsets_; + + if(start_read) { + rec_offs_init(offsets_); + rec_offs_init(clust_offsets_); + start_read = false; + } + + mtr.start(); + mtr.set_log_mode(MTR_LOG_NO_REDO); + + auto &from = m_scan_ctx->m_config.m_pq_reverse_scan ? m_range.second : m_range.first; + pcur = from->m_pcur; + + PCursor pcursor(pcur, &mtr, m_scan_ctx->m_config.m_read_level); + pcursor.restore_position(); + + + const auto &end_tuple = m_scan_ctx->m_config.m_pq_reverse_scan ? m_range.first->m_tuple : m_range.second->m_tuple; + auto index = m_scan_ctx->m_config.m_index; + auto cur = pcur->get_page_cur(); + dict_index_t *clust_index = index->table->first_index(); + + if(m_blob_heap == nullptr) + m_blob_heap = mem_heap_create(srv_page_size); + if(m_heap == nullptr) + m_heap = mem_heap_create(srv_page_size / 4); + + if(!m_scan_ctx->m_config.m_pq_reverse_scan && page_cur_is_after_last(cur)) { + // pcur point to last record, move to next block + mem_heap_empty(m_heap); + offsets = offsets_; + rec_offs_init(offsets_); + + err = pcursor.move_to_next_block(index); + if (err != DB_SUCCESS) { + ut_a(!mtr.is_active()); + return err; + } + ut_ad(!page_cur_is_before_first(cur)); + } else if(m_scan_ctx->m_config.m_pq_reverse_scan && page_cur_is_before_first(cur)) { + // pcur point to first record, move to prev block + mem_heap_empty(m_heap); + offsets = offsets_; + rec_offs_init(offsets_); + + err = pcursor.move_to_prev_block(index); + if (err != DB_SUCCESS) { + ut_a(!mtr.is_active()); + return err; + } + ut_ad(!page_cur_is_after_last(cur)); + } + + // 1. read record + rec = page_cur_get_rec(cur); + offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &m_heap); + clust_offsets = rec_get_offsets(rec, index, clust_offsets, ULINT_UNDEFINED, &m_heap); + + // 2. find visible version record + err1 = m_scan_ctx->find_visible_record(buf, rec, clust_rec, offsets, clust_offsets, m_heap, &mtr, prebuilt); + + if (err1 == DB_END_OF_RANGE) + { + err = DB_END_OF_RANGE; + goto func_exit; + } + + + if (err1 != DB_NOT_FOUND) { + // 3. check range boundary + m_block = page_cur_get_block(cur); + if (rec != nullptr && end_tuple != nullptr) { + if (!m_scan_ctx->m_config.m_index->is_clustered() && + prebuilt->need_to_access_clustered) + ret = ((dtuple_t *)end_tuple)->compare(clust_rec, index, clust_index, clust_offsets); + else + ret = end_tuple->compare(rec, index, offsets); + + /* Note: The range creation doesn't use MVCC. Therefore it's possible + that the range boundary entry could have been deleted. */ + if((!m_scan_ctx->m_config.m_pq_reverse_scan && ret <= 0) || (m_scan_ctx->m_config.m_pq_reverse_scan && ret >= 0)) { + m_scan_ctx->m_reader->ctx_completed_inc(); + err= DB_END_OF_RANGE; + goto func_exit; + } + } + + // 4. convert record to mysql format + if(prebuilt->pq_requires_clust_rec) + { + result_rec = clust_rec; + if (!row_sel_store_mysql_rec(buf, prebuilt, clust_rec, nullptr, + true, clust_index, prebuilt->index, clust_offsets, false, nullptr, m_blob_heap)) + err= DB_ERROR; + } else { + result_rec = rec; + if (!row_sel_store_mysql_rec(buf, prebuilt, rec, nullptr, + m_scan_ctx->m_config.m_index->is_clustered(), + index, prebuilt->index, offsets, false, nullptr, m_blob_heap)) + err= DB_ERROR; + } + if (prebuilt->clust_index_was_generated) { + pq_row_sel_store_row_id_to_prebuilt(prebuilt, result_rec, + result_rec == rec ? index : clust_index, + result_rec == rec ? offsets:clust_offsets); + } + } + else + { + err = DB_NOT_FOUND; + goto next_record; + } + +next_record: + if(!m_scan_ctx->m_config.m_pq_reverse_scan) + page_cur_move_to_next(cur); + else + page_cur_move_to_prev(cur); + +func_exit: + pcur->store_position(&mtr); + ut_a(mtr.is_active()); + mtr.commit(); + + return err; +} + dberr_t Parallel_reader::Ctx::traverse() { /* Take index lock if the requested read level is on a non-leaf level as the index lock is required to access non-leaf page. */ @@ -636,14 +1002,24 @@ std::shared_ptr Parallel_reader::dequeue() { return (nullptr); } - auto ctx = m_ctxs.front(); - m_ctxs.pop_front(); + std::shared_ptr ctx{}; + if(!m_pq_reverse_scan) { + ctx = m_ctxs.front(); + m_ctxs.pop_front(); + } else { + ctx = m_ctxs.back(); + m_ctxs.pop_back(); + } mutex_exit(&m_mutex); return (ctx); } +void Parallel_reader::pq_set_reverse_scan() { + m_pq_reverse_scan = true; +} + bool Parallel_reader::is_queue_empty() const { mutex_enter(&m_mutex); auto empty = m_ctxs.empty(); @@ -743,6 +1119,62 @@ void Parallel_reader::worker(Parallel_reader::Thread_ctx *thread_ctx) { ut_a(is_error_set() || (m_n_completed == m_ctx_id && is_queue_empty())); } +void Parallel_reader::ctx_completed_inc() +{ + m_n_completed.fetch_add(1, std::memory_order_relaxed); +} + +void Parallel_reader::pq_set_worker_done() +{ + work_done.store(true, std::memory_order_relaxed); +} + +void Parallel_reader::pq_wakeup_workers() +{ + pq_set_worker_done(); + os_event_set(m_event); +} + +dberr_t Parallel_reader::dispatch_ctx(row_prebuilt_t *prebuilt) { + dberr_t err{DB_SUCCESS}; + + for (;;) { + int64_t sig_count = os_event_reset(m_event); + + auto ctx = dequeue(); + bool done = work_done.load(std::memory_order_relaxed); + + if (ctx == nullptr) { + prebuilt->ctx = nullptr; + if (is_ctx_over() || done) { + /* Wakeup other worker threads before exiting */ + os_event_set(m_event); + ut_a(is_queue_empty()); + return DB_END_OF_INDEX; + } + else { + /* wait for other worker */ + constexpr auto FOREVER = OS_SYNC_INFINITE_TIME; + os_event_wait_time_low(m_event, FOREVER, sig_count); + } + } + else { + if (ctx->m_split) { + err = ctx->split(); + /* Tell the other threads that there is work to do. */ + os_event_set(m_event); + ctx_completed_inc(); + } + else { + prebuilt->ctx = ctx; + break; + } + } + } + + return err; +} + page_no_t Parallel_reader::Scan_ctx::search(const buf_block_t *block, const dtuple_t *key) const { ut_ad(index_s_own()); @@ -848,6 +1280,8 @@ dberr_t Parallel_reader::Scan_ctx::create_ranges(const Scan_range &scan_range, ut_ad(index_s_own()); ut_a(max_threads() > 0); ut_a(page_no != FIL_NULL); + if (m_config.m_range_errno) + return (DB_SUCCESS); /* Do a breadth first traversal of the B+Tree using recursion. We want to set up the scan ranges in one pass. This guarantees that the tree structure @@ -864,6 +1298,8 @@ dberr_t Parallel_reader::Scan_ctx::create_ranges(const Scan_range &scan_range, auto block = block_get_s_latched(page_id, mtr, __LINE__); + page_no_t child_page_no = FIL_NULL; + /* read_level requested should be less than the tree height. */ ut_ad(m_config.m_read_level < btr_page_get_level(buf_block_get_frame(block), mtr) + 1); @@ -916,7 +1352,7 @@ dberr_t Parallel_reader::Scan_ctx::create_ranges(const Scan_range &scan_range, const auto end = scan_range.m_end; - if (end != nullptr && end->compare(rec, index, offsets) <= 0) { + if (end != nullptr && end->compare(rec, index, offsets) < 0) { break; } @@ -926,6 +1362,7 @@ dberr_t Parallel_reader::Scan_ctx::create_ranges(const Scan_range &scan_range, the root level. */ if (at_level > m_config.m_read_level) { auto page_no = btr_node_ptr_get_child_page_no(rec, offsets); + child_page_no = page_no; if (depth < split_level) { /* Need to create a range starting at a lower level in the tree. */ @@ -983,6 +1420,11 @@ dberr_t Parallel_reader::Scan_ctx::create_ranges(const Scan_range &scan_range, page_cur_move_to_next(&page_cursor); } + if (ranges.size() == 1 && depth == split_level && !at_leaf && child_page_no != FIL_NULL) { + ranges.clear(); + create_ranges(scan_range, child_page_no, depth + 1, split_level + 1, ranges, mtr); + } + savepoints.push_back(savepoint); for (auto &savepoint : savepoints) { @@ -1010,14 +1452,28 @@ dberr_t Parallel_reader::Scan_ctx::partition( err = create_ranges(scan_range, m_config.m_index->page, 0, split_level, ranges, &mtr); - if (err == DB_SUCCESS && scan_range.m_end != nullptr && !ranges.empty()) { + if (m_config.m_pq_reverse_scan && !ranges.empty()) { + auto &iter = ranges.back().second; + auto block = m_config.m_pcur->get_block(); + page_id_t page_id(m_config.m_index->space, block->get_page_no()); + auto s_block MY_ATTRIBUTE((unused)) = block_get_s_latched(page_id, &mtr, __LINE__); + assert(block == s_block); + + auto page_cursor = m_config.m_pcur->get_page_cur(); + page_cursor->index = m_config.m_index; + iter = create_persistent_cursor(*page_cursor, &mtr); + + /* deep copy of start of first ctx */ + if(scan_range.m_start == nullptr) { + auto &first_iter = ranges.front().first; + first_iter = std::make_shared(); + } + } else if (scan_range.m_end != nullptr && !ranges.empty()) { + auto &iter = ranges.back().second; - ut_a(iter->m_heap == nullptr); - iter->m_heap = mem_heap_create(sizeof(btr_pcur_t) + (srv_page_size / 16)); - - iter->m_tuple = dtuple_copy(scan_range.m_end, iter->m_heap); + iter->m_tuple = pq_dtuple_copy(scan_range.m_end, iter->m_heap); /* Do a deep copy. */ for (size_t i = 0; i < dtuple_get_n_fields(iter->m_tuple); ++i) { @@ -1049,6 +1505,7 @@ dberr_t Parallel_reader::Scan_ctx::create_context(const Range &range, return (DB_OUT_OF_MEMORY); } else { ctx->m_split = split; + ctx->reader = m_reader; m_reader->enqueue(ctx); } @@ -1069,10 +1526,20 @@ dberr_t Parallel_reader::Scan_ctx::create_contexts(const Ranges &ranges) { split_point = max_threads(); } + if (ranges.size() > split_point) { + m_reader->m_need_change_dop = false; + } + size_t i{}; + size_t split_num = 0; + if (ranges.size() > split_point) { + split_num = ranges.size() - split_point; + } + bool split; for (auto range : ranges) { - auto err = create_context(range, i >= split_point); + split = m_config.m_pq_reverse_scan ? i < split_num : i >= split_point; + auto err = create_context(range, split); if (err != DB_SUCCESS) { return (err); @@ -1190,7 +1657,7 @@ dberr_t Parallel_reader::run(size_t n_threads) { dberr_t Parallel_reader::add_scan(trx_t *trx, const Parallel_reader::Config &config, - Parallel_reader::F &&f) { + Parallel_reader::F &&f, bool split) { // clang-format off auto scan_ctx = std::shared_ptr( diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index bb13b3daf..04d56a250 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -2,6 +2,7 @@ Copyright (c) 1997, 2021, Oracle and/or its affiliates. Copyright (c) 2008, Google Inc. +Copyright (c) 2022, Huawei Technologies Co., Ltd. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -2534,6 +2535,15 @@ static void row_sel_store_row_id_to_prebuilt( ut_memcpy(prebuilt->row_id, data, len); } +void pq_row_sel_store_row_id_to_prebuilt(row_prebuilt_t *prebuilt, /*!< in/out: prebuilt */ + const rec_t *index_rec, /*!< in: record */ + const dict_index_t *index, /*!< in: index of the record */ + const ulint *offsets)/*!< in: rec_get_offsets + (index_rec, index) */ +{ + row_sel_store_row_id_to_prebuilt(prebuilt, index_rec, index, offsets); +} + #ifdef UNIV_DEBUG /** Convert a non-SQL-NULL field from Innobase format to MySQL format. */ #define row_sel_field_store_in_mysql_format(dest, templ, idx, field, src, len, \ @@ -3148,42 +3158,6 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return err; } -/** Helper class to cache clust_rec and old_ver */ -class Row_sel_get_clust_rec_for_mysql { - const rec_t *cached_clust_rec; - rec_t *cached_old_vers; - - public: - /** Constructor */ - Row_sel_get_clust_rec_for_mysql() - : cached_clust_rec(nullptr), cached_old_vers(nullptr) {} - - /** Retrieve the clustered index record corresponding to a record in a - non-clustered index. Does the necessary locking. - @param[in] prebuilt prebuilt struct in the handle - @param[in] sec_index secondary index where rec resides - @param[in] rec record in a non-clustered index - @param[in] thr query thread - @param[out] out_rec clustered record or an old version of it, - NULL if the old version did not exist in the - read view, i.e., it was a fresh inserted version - @param[in,out] offsets in: offsets returned by - rec_get_offsets(rec, sec_index); - out: offsets returned by - rec_get_offsets(out_rec, clust_index) - @param[in,out] offset_heap memory heap from which the offsets are allocated - @param[out] vrow virtual column to fill - @param[in] mtr mtr used to get access to the non-clustered record; - the same mtr is used to access the clustered index - @param[in] lob_undo the LOB undo information. - @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ - dberr_t operator()(row_prebuilt_t *prebuilt, dict_index_t *sec_index, - const rec_t *rec, que_thr_t *thr, const rec_t **out_rec, - ulint **offsets, mem_heap_t **offset_heap, - const dtuple_t **vrow, mtr_t *mtr, - lob::undo_vers_t *lob_undo); -}; - /** Retrieve the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ @@ -3820,7 +3794,7 @@ static ulint row_sel_try_search_shortcut_for_mysql( /** Check a pushed-down index condition. @return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ -static ICP_RESULT row_search_idx_cond_check( +ICP_RESULT row_search_idx_cond_check( byte *mysql_rec, /*!< out: record in MySQL format (invalid unless prebuilt->idx_cond == true and @@ -6017,6 +5991,15 @@ normal_return: /*-------------------------------------------------------------*/ que_thr_stop_for_mysql_no_error(thr, trx); + if(err == DB_SUCCESS && prebuilt->pq_index_read) { + if(prebuilt->pq_heap) + mem_heap_free(prebuilt->pq_heap); + prebuilt->pq_heap = mem_heap_create(sizeof(btr_pcur_t) + (srv_page_size / 16)); + prebuilt->pq_tuple = row_rec_to_index_entry_low(rec, index, + rec_get_offsets(rec, index,nullptr, ULINT_UNDEFINED, &prebuilt->heap), + prebuilt->pq_heap); + } + mtr_commit(&mtr); /* Rollback blocking transactions from hit list for high priority @@ -6506,3 +6489,33 @@ bool row_search_index_stats(const char *db_name, const char *tbl_name, mem_heap_free(heap); return (false); } + +/** Searches for rows in the database. This is used in the interface to +MySQL. This function opens a cursor, and also implements fetch next +and fetch prev. NOTE that if we do a search with a full key value +from a unique index (ROW_SEL_EXACT), then we will not store the cursor +position and fetch next or fetch prev must not be tried to the cursor! + +@param[out] buf buffer for the fetched row in MySQL format +@param[in] mode search mode PAGE_CUR_L +@param[in,out] prebuilt prebuilt struct for the table handler; + this contains the info to search_tuple, + index; if search tuple contains 0 field then + we position the cursor at start or the end of + index, depending on 'mode' +@param[in] match_mode 0 or ROW_SEL_EXACT or ROW_SEL_EXACT_PREFIX +@param[in] direction 0 or ROW_SEL_NEXT or ROW_SEL_PREV; + Note: if this is != 0, then prebuilt must has a + pcur with stored position! In opening of a + cursor 'direction' should be 0. +@return DB_SUCCESS, DB_RECORD_NOT_FOUND, DB_END_OF_INDEX, DB_DEADLOCK, +DB_LOCK_TABLE_FULL, DB_CORRUPTION, or DB_TOO_BIG_RECORD */ +dberr_t row_search_for_mysql(byte *buf, page_cur_mode_t mode, + row_prebuilt_t *prebuilt, ulint match_mode, + ulint direction) { + if (!prebuilt->table->is_intrinsic()) { + return (row_search_mvcc(buf, mode, prebuilt, match_mode, direction)); + } else { + return (row_search_no_mvcc(buf, mode, prebuilt, match_mode, direction)); + } +} diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 074de0ff5..e9bb3fb39 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -2165,6 +2166,16 @@ ReadView *trx_assign_read_view(trx_t *trx) /*!< in/out: active transaction */ return (trx->read_view); } +ReadView *trx_clone_read_view(trx_t *trx, ReadView *snapshot) /*!< in/out: active transaction */ +{ + trx->read_view = UT_NEW_NOKEY(ReadView()); + if (trx->read_view != nullptr) { + trx->read_view->Copy_readView(*snapshot); + trx->read_view->skip_view_list = true; + } + return (trx->read_view); +} + /** Prepares a transaction for commit/rollback. */ void trx_commit_or_rollback_prepare(trx_t *trx) /*!< in/out: transaction */ { diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 0fb499715..cdea8fb77 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2021, Oracle and/or its affiliates. +Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -433,6 +434,8 @@ const char *ut_strerr(dberr_t num) { return ("End of index"); case DB_END_OF_BLOCK: return ("End of block"); + case DB_END_OF_RANGE: + return ("Reach end of Parallel Query Range"); case DB_IO_ERROR: return ("I/O error"); case DB_TABLE_IN_FK_CHECK: diff --git a/storage/temptable/include/temptable/block.h b/storage/temptable/include/temptable/block.h index 9cd32b201..794c66537 100644 --- a/storage/temptable/include/temptable/block.h +++ b/storage/temptable/include/temptable/block.h @@ -1,4 +1,5 @@ /* Copyright (c) 2019, 2021, Oracle and/or its affiliates. + Copyright (c) 2022, Huawei Technologies Co., Ltd. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -371,13 +372,16 @@ inline size_t Block::deallocate(Chunk chunk, size_t chunk_size) noexcept { inline void Block::destroy() noexcept { assert(!is_empty()); - assert(Header::number_of_used_chunks() == 0); - DBUG_PRINT("temptable_allocator", - ("destroying the block: (%s)", to_string().c_str())); - deallocate_from(Header::memory_source_type(), Header::block_size(), - Header::block_address()); - Header::reset(); + // PQ worker thread could quit early + if (Header::number_of_used_chunks() == 0) { + DBUG_PRINT("temptable_allocator", + ("destroying the block: (%s)", to_string().c_str())); + + deallocate_from(Header::memory_source_type(), Header::block_size(), + Header::block_address()); + Header::reset(); + } } inline bool Block::is_empty() const { -- Gitee